aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/FrontendActions.cpp
AgeCommit message (Collapse)AuthorFilesLines
2020-08-26[X86] Default to -mtune=generic unless -march is passed to the driver. Add ↵Craig Topper1-0/+1
TuneCPU to the AST serialization This patch defaults to -mtune=generic unless -march is present. If -march is present we'll use the empty string unless its overridden by mtune. The back should use the target cpu if the tune-cpu isn't present. It also adds AST serialization support to fix some tests that emit AST and parse it back. These tests diff the IR against the output from not going through AST. So if we don't serialize the tune CPU we fail the diff. Differential Revision: https://reviews.llvm.org/D86488
2020-06-22Add -ast-dump-decl-types flag to include types of value and typeRichard Smith1-1/+2
declarations in AST dumps. Includes a testcase for deduction guide transformation that makes use of this new dumping feature.
2020-06-08Remove improper uses of DiagnosticErrorTrap and hasErrorOccurred.Richard Smith1-0/+4
DiagnosticErrorTrap is usually inappropriate because it indicates whether an error message was rendered in a given region (and is therefore affected by -ferror-limit and by suppression of errors if we see an invalid declaration). hasErrorOccurred() is usually inappropriate because it indicates whethere an "error:" message was displayed, regardless of whether the message was a warning promoted to an error, and therefore depends on things like -Werror that are usually irrelevant. Where applicable, CodeSynthesisContexts are used to attach notes to the first diagnostic produced in a region of code, isnstead of using an error trap and then attaching a note to whichever diagnostic happened to be produced last (or suppressing the note if the final diagnostic is a disabled warning!). This is mostly NFC.
2020-03-11Prune TargetInfo.h include from ParsedAttr.h, NFCReid Kleckner1-0/+1
Saves ~400 includes of related headers: $ diff -u <(sort thedeps-before.txt) <(sort thedeps-after.txt) \ | grep '^[-+] ' | sort | uniq -c | sort -nr 468 - llvm-project/clang/include/clang/Basic/TargetInfo.h 468 - llvm-project/clang/include/clang/Basic/TargetCXXABI.h 368 - llvm-project/llvm/include/llvm/Support/CodeGen.h 368 - llvm-project/clang/include/clang/Basic/XRayInstr.h 368 - llvm-project/clang/include/clang/Basic/CodeGenOptions.h 368 - llvm-project/clang/include/clang/Basic/CodeGenOptions.def 367 - llvm-project/llvm/include/llvm/ADT/FloatingPointMode.h 367 - llvm-project/clang/include/clang/Basic/DebugInfoOptions.h
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer1-4/+4
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2020-01-19[Concepts] Requires ExpressionsSaar Raz1-0/+4
Implement support for C++2a requires-expressions. Re-commit after compilation failure on some platforms due to alignment issues with PointerIntPair. Differential Revision: https://reviews.llvm.org/D50360
2020-01-18Revert "[Concepts] Requires Expressions"Saar Raz1-4/+0
This reverts commit 027931899763409e2c61a84bdee6057b5e838ffa. There have been some failing tests on some platforms, reverting while investigating.
2020-01-18[Concepts] Requires ExpressionsSaar Raz1-0/+4
Implement support for C++2a requires-expressions. Differential Revision: https://reviews.llvm.org/D50360
2019-12-23[Concepts] Constrained partial specializations and function overloads.Saar Raz1-0/+4
Added support for constraint satisfaction checking and partial ordering of constraints in constrained partial specialization and function template overloads. Re-commit after fixing another crash (added regression test). Differential Revision: https://reviews.llvm.org/D41910
2019-12-22Revert "[Concepts] Constrained partial specializations and function overloads."Reid Kleckner1-4/+0
This reverts commit d3f5769d5e93b30d4a8b4696381d5e4a304992fa. Causes crashes on Chromium. Have reproducer, will reduce and send along.
2019-12-22[Concepts] Constrained partial specializations and function overloads.Saar Raz1-0/+4
Added support for constraint satisfaction checking and partial ordering of constraints in constrained partial specialization and function template overloads. Re-commit after fixing some crashes and warnings. Differential Revision: https://reviews.llvm.org/D41910
2019-12-19Re-land "Add an -fno-temp-file flag for compilation"Hans Wennborg1-1/+1
This time making sure to initialize FrontendOptions::UseTemporary. Patch by Zachary Henkel! Differential revision: https://reviews.llvm.org/D70615
2019-12-18Revert concepts changes from D41910Vedant Kumar1-4/+0
These changes caused LibcxxVariantDataFormatterTestCase in lldb to fail with an assert: Assertion failed: (Idx < size() && "Out-of-bounds Bit access."), function operator[], file /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include/llvm/ADT/SmallBitVector.h, line 452. In: 7 clang-10 0x00000001094b79d9 isAtLeastAsSpecializedAs(clang::Sema&, clang::SourceLocation, clang::FunctionTemplateDecl*, clang::FunctionTemplateDecl*, clang::TemplatePartialOrderingContext, unsigned int) + 1865 8 clang-10 0x00000001094b7111 clang::Sema::getMoreSpecializedTemplate(clang::FunctionTemplateDecl*, clang::FunctionTemplateDecl*, clang::SourceLocation, clang::TemplatePartialOrderingContext, unsigned int, unsigned int) + 97 9 clang-10 0x000000010939bf88 clang::isBetterOverloadCandidate(clang::Sema&, clang::OverloadCandidate const&, clang::OverloadCandidate const&, clang::SourceLocation, clang::OverloadCandidateSet::CandidateSetKind) + 1128 Revert "[Concepts] Fix incorrect move out of temporary in D41910" This reverts commit 11d5fa6e87e3584f72056ecc2b17f88c58323dde. Revert "[Concepts] Fix crash in D41910" This reverts commit 12038be20ee6a903cdbd3fddce65535ef683e31d. Revert "[Concepts] Constrained partial specializations and function overloads." This reverts commit fc0731b98a67c793862288f8ae334322666214dc.
2019-12-18[Concepts] Constrained partial specializations and function overloads.Saar Raz1-0/+4
Added support for constraint satisfaction checking and partial ordering of constraints in constrained partial specialization and function template overloads. Phabricator: D41910
2019-12-18Revert "Add an -fno-temp-file flag for compilation"Mitch Phillips1-1/+1
This reverts commit d129aa1d5369781deff6c6b854cb612e160d3fb2. This broke the MSan buildbots. More information available in the original PR: https://reviews.llvm.org/D70615
2019-12-18Add an -fno-temp-file flag for compilationHans Wennborg1-1/+1
Our build system does not handle randomly named files created during the build well. We'd prefer to write compilation output directly without creating a temporary file. Function parameters already existed to control this behavior but were not exposed all the way out to the command line. Patch by Zachary Henkel! Differential revision: https://reviews.llvm.org/D70615
2019-12-10[c++20] Implement P1185R2 (as modified by P2002R0).Richard Smith1-0/+2
For each defaulted operator<=> in a class that doesn't explicitly declare any operator==, also inject a matching implicit defaulted operator==.
2019-10-19[c++20] Add rewriting from comparison operators to <=> / ==.Richard Smith1-0/+2
This adds support for rewriting <, >, <=, and >= to a normal or reversed call to operator<=>, for rewriting != to a normal or reversed call to operator==, and for rewriting <=> and == to reversed forms of those same operators. Note that this is a breaking change for various C++17 code patterns, including some in use in LLVM. The most common patterns (where an operator== becomes ambiguous with a reversed form of itself) are still accepted under this patch, as an extension (with a warning). I'm hopeful that we can get the language rules fixed before C++20 ships, and the extension warning is aimed primarily at providing data to inform that decision. llvm-svn: 375306
2019-10-15[Concepts] Concept Specialization ExpressionsSaar Raz1-0/+4
Part of C++20 Concepts implementation effort. Added Concept Specialization Expressions that are created when a concept is refe$ D41217 on Phabricator. (recommit after fixing failing Parser test on windows) llvm-svn: 374903
2019-10-15Revert 374882 "[Concepts] Concept Specialization Expressions"Nico Weber1-4/+0
This reverts commit ec87b003823d63f3342cf648f55a134c1522e612. The test fails on Windows, see e.g. http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/11533/steps/stage%201%20check/logs/stdio Also revert follow-up r374893. llvm-svn: 374899
2019-10-15[Concepts] Concept Specialization ExpressionsSaar Raz1-0/+4
Part of C++20 Concepts implementation effort. Added Concept Specialization Expressions that are created when a concept is referenced with arguments, and tests thereof. llvm-svn: 374882
2019-09-12Removed some questionable default arguments from settersDmitri Gribenko1-1/+1
Summary: They can be confusing -- what does it mean to call a setter without a value? Also, some setters, like `setPrintTemplateTree` had `false` as the default value! The callers are largely not using these default arguments anyway. Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67491 llvm-svn: 371731
2019-08-22Introduce FileEntryRef and use it when handling includes to report correct ↵Alex Lorenz1-4/+4
dependencies when the FileManager is reused across invocations This commit introduces a parallel API to FileManager's getFile: getFileEntryRef, which returns a reference to the FileEntry, and the name that was used to access the file. In the case of a VFS with 'use-external-names', the FileEntyRef contains the external name of the file, not the filename that was used to access it. The new API is adopted only in the HeaderSearch and Preprocessor for include file lookup, so that the accessed path can be propagated to SourceManager's FileInfo. SourceManager's FileInfo now can report this accessed path, using the new getName method. This API is then adopted in the dependency collector, which now correctly reports dependencies when a file is included both using a symlink and a real path in the case when the FileManager is reused across multiple Preprocessor invocations. Note that this patch does not fix all dependency collector issues, as the same problem is still present in other cases when dependencies are obtained using FileSkipped, InclusionDirective, and HasInclude. This will be fixed in follow-up commits. Differential Revision: https://reviews.llvm.org/D65907 llvm-svn: 369680
2019-08-14[Clang] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere1-10/+10
Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368942
2019-08-05Move LangStandard*, InputKind::Language to BasicRainer Orth1-11/+12
This patch is a prerequisite for using LangStandard from Driver in https://reviews.llvm.org/D64793. It moves LangStandard* and InputKind::Language to Basic. It is mostly mechanical, with only a few changes of note: - enum Language has been changed into enum class Language : uint8_t to avoid a clash between OpenCL in enum Language and OpenCL in enum LangFeatures and not to increase the size of class InputKind. - Now that getLangStandardForName, which is currently unused, also checks both canonical and alias names, I've introduced a helper getLangKind which factors out a code pattern already used 3 times. The patch has been tested on x86_64-pc-solaris2.11, sparcv9-sun-solaris2.11, and x86_64-pc-linux-gnu. There's a companion patch for lldb which uses LangStandard.h (https://reviews.llvm.org/D65717). While polly includes isl which in turn uses InputKind::C, that part of the code isn't even built inside the llvm tree. I've posted a patch to allow for both InputKind::C and Language::C upstream (https://groups.google.com/forum/#!topic/isl-development/6oEvNWOSQFE). Differential Revision: https://reviews.llvm.org/D65562 llvm-svn: 367864
2019-08-05Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFCFangrui Song1-1/+1
F_{None,Text,Append} are kept for compatibility since r334221. llvm-svn: 367800
2019-07-16Fix parameter name comments using clang-tidy. NFC.Rui Ueyama1-2/+2
This patch applies clang-tidy's bugprone-argument-comment tool to LLVM, clang and lld source trees. Here is how I created this patch: $ git clone https://github.com/llvm/llvm-project.git $ cd llvm-project $ mkdir build $ cd build $ cmake -GNinja -DCMAKE_BUILD_TYPE=Debug \ -DLLVM_ENABLE_PROJECTS='clang;lld;clang-tools-extra' \ -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DLLVM_ENABLE_LLD=On \ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ../llvm $ ninja $ parallel clang-tidy -checks='-*,bugprone-argument-comment' \ -config='{CheckOptions: [{key: StrictMode, value: 1}]}' -fix \ ::: ../llvm/lib/**/*.{cpp,h} ../clang/lib/**/*.{cpp,h} ../lld/**/*.{cpp,h} llvm-svn: 366177
2019-06-03Add clang source minimizer that reduces source to directivesAlex Lorenz1-1/+32
that might affect the dependency list for a compilation This commit introduces a dependency directives source minimizer to clang that minimizes header and source files to the minimum necessary preprocessor directives for evaluating includes. It reduces the source down to #define, #include, The source minimizer works by lexing the input with a custom fast lexer that recognizes the preprocessor directives it cares about, and emitting those directives in the minimized source. It ignores source code, comments, and normalizes whitespace. It gives up and fails if seems any directives that it doesn't recognize as valid (e.g. #define 0). In addition to the source minimizer this patch adds a -print-dependency-directives-minimized-source CC1 option that allows you to invoke the minimizer from clang directly. Differential Revision: https://reviews.llvm.org/D55463 llvm-svn: 362459
2019-05-13Introduce the ability to dump the AST to JSON.Aaron Ballman1-5/+4
This adds the -ast-dump=json cc1 flag (in addition to -ast-dump=default, which is the default if no dump format is specified), as well as some initial AST dumping functionality and tests. llvm-svn: 360622
2019-04-14[c++20] Enable driver and frontend support for building and usingRichard Smith1-3/+3
modules when -std=c++2a is specified. llvm-svn: 358355
2019-03-12Modules: Add LangOptions::CacheGeneratedPCHDuncan P. N. Exon Smith1-1/+3
Add an option to cache the generated PCH in the ModuleCache when emitting it. This protects clients that build PCHs and read them in the same process, allowing them to avoid race conditions between parallel jobs the same way that Clang's implicit module build system does. rdar://problem/48740787 llvm-svn: 355950
2019-03-09Modules: Rename MemoryBufferCache to InMemoryModuleCacheDuncan P. N. Exon Smith1-11/+11
Change MemoryBufferCache to InMemoryModuleCache, moving it from Basic to Serialization. Another patch will start using it to manage module build more explicitly, but this is split out because it's mostly mechanical. Because of the move to Serialization we can no longer abuse the Preprocessor to forward it to the ASTReader. Besides the rename and file move, that means Preprocessor::Preprocessor has one fewer parameter and ASTReader::ASTReader has one more. llvm-svn: 355777
2019-02-05[Preprocessor] Add a note with framework location for "file not found" error.Volodymyr Sapsai1-1/+1
When a framework with the same name is available at multiple framework search paths, we use the first matching location. If a framework at this location doesn't have all the headers, it can be confusing for developers because they see only an error `'Foo/Foo.h' file not found`, can find the complete framework with required header, and don't know the incomplete framework was used instead. Add a note explaining a framework without required header was found. Also mention framework directory path to make it easier to find the incomplete framework. rdar://problem/39246514 Reviewers: arphaman, erik.pilkington, jkorous Reviewed By: jkorous Subscribers: jkorous, dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D56561 llvm-svn: 353231
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-12-04PTH-- Remove feature entirely-Erich Keane1-10/+0
When debugging a boost build with a modified version of Clang, I discovered that the PTH implementation stores TokenKind in 8 bits. However, we currently have 368 TokenKinds. The result is that the value gets truncated and the wrong token gets picked up when including PTH files. It seems that this will go wrong every time someone uses a token that uses the 9th bit. Upon asking on IRC, it was brought up that this was a highly experimental features that was considered a failure. I discovered via googling that BoostBuild (mostly Boost.Math) is the only user of this feature, using the CC1 flag directly. I believe that this can be transferred over to normal PCH with minimal effort: https://github.com/boostorg/build/issues/367 Based on advice on IRC and research showing that this is a nearly completely unused feature, this patch removes it entirely. Note: I considered leaving the build-flags in place and making them emit an error/warning, however since I've basically identified and warned the only user, it seemed better to just remove them. Differential Revision: https://reviews.llvm.org/D54547 Change-Id: If32744275ef1f585357bd6c1c813d96973c4d8d9 llvm-svn: 348266
2018-10-03[Frontend] Delete -print-decl-contextsFangrui Song1-6/+0
Summary: Its job is covered by -ast-dump. The option is rarely used and lacks many AST nodes which will lead to llvm_unreachable() crash. Reviewers: rsmith, arphaman Reviewed By: rsmith Subscribers: jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D52529 llvm-svn: 343660
2018-09-15[modules] Support use of -E on modules built from the command line.Richard Smith1-3/+1
llvm-svn: 342306
2018-09-15[modules] Frontend support for building a header module from a list ofRichard Smith1-0/+70
headaer files. llvm-svn: 342304
2018-09-11[Modules] Add imported modules to the output of -module-file-infoBruno Cardoso Lopes1-0/+11
Fix a bug in the deserialization of IMPORTS section and allow for imported modules to also be printed with -module-file-info. rdar://problem/43867753 llvm-svn: 341902
2018-09-05PR38627: Fix handling of exception specification adjustment forRichard Smith1-0/+2
destructors. We previously tried to patch up the exception specification after completing the class, which went wrong when the exception specification was needed within the class body (in particular, by a friend redeclaration of the destructor in a nested class). We now mark the destructor as having a not-yet-computed exception specification immediately after creating it. This requires delaying various checks against the exception specification (where we'd previously have just got the wrong exception specification, and now find we have an exception specification that we can't compute yet) when those checks fire while the class is being defined. This also exposed an issue that we were missing a CodeSynthesisContext for computation of exception specifications (otherwise we'd fail to make the module containing the definition of the class visible when computing its members' exception specs). Adding that incidentally also gives us a diagnostic quality improvement. This has also exposed an pre-existing problem: making the exception specification evaluation context a non-SFINAE context (as it should be) results in a bootstrap failure; PR38850 filed for this. llvm-svn: 341499
2018-07-30Remove trailing spaceFangrui Song1-5/+5
sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
2018-07-18[modules] Print input files when -module-file-info file switch is passed.Vassil Vassilev1-0/+39
This patch improves traceability of duplicated header files which end up in multiple pcms. Differential Revision: https://reviews.llvm.org/D47118 llvm-svn: 337353
2018-06-25[clang-cl] Don't emit dllexport inline functions etc. from pch files (PR37801)Hans Wennborg1-4/+4
With MSVC, PCH files are created along with an object file that needs to be linked into the final library or executable. That object file contains the code generated when building the headers. In particular, it will include definitions of inline dllexport functions, and because they are emitted in this object file, other files using the PCH do not need to emit them. See the bug for an example. This patch makes clang-cl match MSVC's behaviour in this regard, causing significant compile-time savings when building dlls using precompiled headers. For example, in a 64-bit optimized shared library build of Chromium with PCH, it reduces the binary size and compile time of stroke_opacity_custom.obj from 9315564 bytes to 3659629 bytes and 14.6 to 6.63 s. The wall-clock time of building blink_core.dll goes from 38m41s to 22m33s. ("user" time goes from 1979m to 1142m). Differential Revision: https://reviews.llvm.org/D48426 llvm-svn: 335466
2018-05-31Add a new driver mode to dump compiler feature and extension options.Aaron Ballman1-0/+48
Add the ability to dump compiler option-related information to a JSON file via the -compiler-options-dump option. Specifically, it dumps the features/extensions lists -- however, this output could be extended to other information should it be useful. In order to support features and extensions, I moved them into a .def file so that we could build the various lists we care about from them without a significant increase in maintenance burden. llvm-svn: 333653
2018-05-09Remove \brief commands from doxygen comments.Adrian Prantl1-1/+1
This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
2018-04-25[HIP] Add hip input kind and codegen for kernel launchingYaxun Liu1-0/+1
HIP is a language similar to CUDA (https://github.com/ROCm-Developer-Tools/HIP/blob/master/docs/markdown/hip_kernel_language.md ). The language syntax is very similar, which allows a hip program to be compiled as a CUDA program by Clang. The main difference is the host API. HIP has a set of vendor neutral host API which can be implemented on different platforms. Currently there is open source implementation of HIP runtime on amdgpu target (https://github.com/ROCm-Developer-Tools/HIP). This patch adds support of input kind and language standard hip. When hip file is compiled, both LangOpts.CUDA and LangOpts.HIP is turned on. This allows compilation of hip program as CUDA in most cases and only special handling of hip program is needed LangOpts.HIP is checked. This patch also adds support of kernel launching of HIP program using HIP host API. When -x hip is not specified, there is no behaviour change for CUDA. Patch by Greg Rodgers. Revised and lit test added by Yaxun Liu. Differential Revision: https://reviews.llvm.org/D44984 llvm-svn: 330790
2018-04-10Revert r329684 (and follow-ups 329693, 329714). See discussion on ↵Nico Weber1-4/+0
https://reviews.llvm.org/D43578. llvm-svn: 329739
2018-04-10-ftime-report switch support in Clang.Andrew V. Tischenko1-0/+4
The current support of the feature produces only 2 lines in report: -Some general Code Generation Time; -Total time of Backend Consumer actions. This patch extends Clang time report with new lines related to Preprocessor, Include Filea Search, Parsing, etc. Differential Revision: https://reviews.llvm.org/D43578 llvm-svn: 329684
2018-04-06Allow the creation of human-friendly ASTDumper to arbitrary output streamAlexander Kornienko1-1/+2
Summary: `ASTPrinter` allows setting the ouput to any O-Stream, but that printer creates source-code-like syntax (and is also marked with a `FIXME`). The nice, colourful, mostly human-readable `ASTDumper` only works on the standard output, which is not feasible in case a user wants to see the AST of a file through a code navigation/comprehension tool. This small addition of an overload solves generating a nice colourful AST block for the users of a tool I'm working on, [[ http://github.com/Ericsson/CodeCompass | CodeCompass ]], as opposed to having to duplicate the behaviour of definitions that only exist in the anonymous namespace of implementation TUs related to this module. Reviewers: alexfh, klimek, rsmith Reviewed By: alexfh Subscribers: rnkovacs, dkrupp, gsd, xazax.hun, cfe-commits, #clang Tags: #clang Patch by Whisperity! Differential Revision: https://reviews.llvm.org/D45096 llvm-svn: 329391
2018-02-10Make a build bot happy.Gabor Horvath1-6/+6
llvm-svn: 324809