aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/FrontendActions.cpp
AgeCommit message (Collapse)AuthorFilesLines
2018-02-10[Templight] Template Instantiation ObserverGabor Horvath1-0/+153
This patch adds a base-class called TemplateInstantiationObserver which gets notified whenever a template instantiation is entered or exited during semantic analysis. This is a base class used to implement the template profiling and debugging tool called Templight (https://github.com/mikael-s-persson/templight). The patch also makes a few more changes: * ActiveTemplateInstantiation class is moved out of the Sema class (so it can be used with inclusion of Sema.h). * CreateFrontendAction function in front-end utilities is given external linkage (not longer a hidden static function). * TemplateInstObserverChain data member added to Sema class to hold the list of template-inst observers. * Notifications to the template-inst observer are added at the key places where templates are instantiated. Patch by: Abel Sinkovics! Differential Revision: https://reviews.llvm.org/D5767 llvm-svn: 324808
2017-11-16Allow to store precompiled preambles in memory.Ilya Biryukov1-7/+13
Summary: These preambles are built by ASTUnit and clangd. Previously, preambles were always stored on disk. In-memory preambles are routed back to the compiler as virtual files in a custom VFS. Interface of ASTUnit does not allow to use in-memory preambles, as ASTUnit::CodeComplete receives FileManager as a parameter, so we can't change VFS used by the compiler inside the CodeComplete method. A follow-up commit will update clangd in clang-tools-extra to use in-memory preambles. Reviewers: klimek, sammccall, bkramer Reviewed By: klimek Subscribers: ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D39842 llvm-svn: 318411
2017-09-20[PCH] Fixed preamble breaking with BOM presence (and particularly, ↵Cameron Desrochers1-1/+1
fluctuating BOM presence) This patch fixes broken preamble-skipping when the preamble region includes a byte order mark (BOM). Previously, parsing would fail if preamble PCH generation was enabled and a BOM was present. This also fixes preamble invalidation when a BOM appears or disappears. This may seem to be an obscure edge case, but it happens regularly with IDEs that pass buffer overrides that never (or always) have a BOM, yet the underlying file from the initial parse that generated a PCH might (or might not) have a BOM. I've included a test case for these scenarios. Differential Revision: https://reviews.llvm.org/D37491 llvm-svn: 313796
2017-08-31[modules] Add ability to specify module name to module file mapping (reapply)Boris Kolpackov1-2/+2
Extend the -fmodule-file option to support the [<name>=]<file> value format. If the name is omitted, then the old semantics is preserved (the module file is loaded whether needed or not). If the name is specified, then the mapping is treated as just another prebuilt module search mechanism, similar to -fprebuilt-module-path, and the module file is only loaded if actually used (e.g., via import). With one exception: this mapping also overrides module file references embedded in other modules (which can be useful if module files are moved/renamed as often happens during remote compilation). This override semantics requires some extra work: we now store the module name in addition to the file name in the serialized AST representation. Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D35020 llvm-svn: 312220
2017-08-30Revert r312105 [modules] Add ability to specify module name to module file ↵Victor Leschuk1-2/+2
mapping Looks like it breaks win10 builder. llvm-svn: 312112
2017-08-30[modules] Add ability to specify module name to module file mappingBoris Kolpackov1-2/+2
Extend the -fmodule-file option to support the [<name>=]<file> value format. If the name is omitted, then the old semantics is preserved (the module file is loaded whether needed or not). If the name is specified, then the mapping is treated as just another prebuilt module search mechanism, similar to -fprebuilt-module-path, and the module file is only loaded if actually used (e.g., via import). With one exception: this mapping also overrides module file references embedded in other modules (which can be useful if module files are moved/renamed as often happens during remote compilation). This override semantics requires some extra work: we now store the module name in addition to the file name in the serialized AST representation. Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D35020 llvm-svn: 312105
2017-07-06Reject attempts to build a module without -fmodules, rather than silently ↵Richard Smith1-0/+10
doing weird things. llvm-svn: 307316
2017-06-29Teach ASTReader how to read only the Preprocessor state from an AST file, ↵Richard Smith1-1/+1
not the ASTContext state. We use this when running a preprocessor-only action on an AST file in order to avoid paying the runtime cost of loading the extra information. llvm-svn: 306760
2017-06-16Killing a tab and some other spurious whitespace; NFC.Aaron Ballman1-1/+1
llvm-svn: 305586
2017-06-09Remove 'Filename' parameter from BeginSourceFileAction.Richard Smith1-10/+4
No-one was using this, and it's not meaningful in general -- FrontendActions can be run on inputs that don't have a corresponding source file. The current frontend input can be obtained by asking the FrontendAction if any future action actually needs it. llvm-svn: 305045
2017-06-01Escape filenames in module map line marker directives, to unbreak Windows ↵Richard Smith1-2/+5
build bots. llvm-svn: 304464
2017-05-05Add support for building modules from preprocessed source.Richard Smith1-0/+12
To support this, an optional marker "#pragma clang module contents" is recognized in module map files, and the rest of the module map file from that point onwards is treated as the source of the module. Preprocessing a module map produces the input module followed by the marker and then the preprocessed contents of the module. Ignoring line markers, a preprocessed module might look like this: module A { header "a.h" } #pragma clang module contents #pragma clang module begin A // ... a.h ... #pragma clang module end The preprocessed output generates line markers, which are not accepted by the module map parser, so -x c++-module-map-cpp-output should be used to compile such outputs. A couple of major parts do not work yet: 1) The files that are listed in the module map must exist on disk, in order to build the on-disk header -> module lookup table in the PCM file. To fix this, we need the preprocessed output to track the file size and other stat information we might use to build the lookup table. 2) Declaration ownership semantics don't work properly yet, since mapping from a source location to a module relies on mapping from FileIDs to modules, which we can't do if module transitions can occur in the middle of a file. llvm-svn: 302309
2017-04-28Move functionality for handling module maps as inputs from the -emit-moduleRichard Smith1-236/+6
action to the general FrontendAction infrastructure. This permits applying -E, -ast-dump, -fsyntax-only, and so on to a module map compilation. (The -E form is not currently especially useful yet as there's no good way to take the output and use it to actually build a module.) In order to support this, -cc1 now accepts -x <lang>-module-map in all cases where it accepts -x <lang> for a language we can parse (not ir/ast). And for uniformity, we also accept -x <lang>-header for all such languages (we used to reject for cuda and renderscript), and -x <lang>-cpp-output for all such languages (we used to reject for c, cl, and renderscript). (None of these new alternatives are accepted by the driver yet, so no user-visible changes.) llvm-svn: 301610
2017-04-26Refactor frontend InputKind to prepare for treating module maps as a ↵Richard Smith1-17/+15
distinct kind of input. No functionality change intended. llvm-svn: 301442
2017-03-09Add -cc1 flag -ast-dump-all to perform an AST dump including entities that ↵Richard Smith1-0/+1
haven't yet been deserialized. llvm-svn: 297412
2017-02-27[GeneratePCHAction] If preprocessor option 'AllowPCHWithCompilerErrors' is ↵Argyrios Kyrtzidis1-1/+7
enabled, don't delete the produced PCH file if error diagnostics occurred. llvm-svn: 296320
2017-02-25[modules] For -module-file-info, print out the resource dir path, since it ↵Argyrios Kyrtzidis1-0/+1
is included in the module hash. llvm-svn: 296261
2017-01-09PCH: fix a regression that reports a module is defined in both pch and pcm.Manman Ren1-0/+6
In r276159, we started to say that a module X is defined in a pch if we specify -fmodule-name when building the pch. This caused a regression that reports module X is defined in both pch and pcm if we generate the pch with -fmodule-name=X and then in a separate clang invocation, we include the pch and also import X.pcm. This patch adds an option CompilingPCH similar to CompilingModule. When we use -fmodule-name=X while building a pch, modular headers in X will be textually included and the compiler knows that we are not building module X, so we don't put module X in SUBMODULE_DEFINITION of the pch. Differential Revision: http://reviews.llvm.org/D28415 llvm-svn: 291465
2016-12-12Revert "[Modules] Make header inclusion order from umbrella dirs deterministic"Bruno Cardoso Lopes1-11/+3
Reverts commit r289478. This broke http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/2070 (and maybe http://lab.llvm.org:8011/builders/clang-x86_64-linux-selfhost-modules-2/builds/2246) llvm-svn: 289494
2016-12-12[Modules] Make header inclusion order from umbrella dirs deterministicBruno Cardoso Lopes1-3/+11
Sort the headers by name before adding the includes in collectModuleHeaderIncludes. This makes the include order for building umbrellas deterministic across different filesystems and also guarantees that the ASTWriter always dump top headers in the same order. There's currently no good way to test for this behavior. rdar://problem/28116411 llvm-svn: 289478
2016-08-26C++ Modules TS: add frontend support for building pcm files from moduleRichard Smith1-31/+50
interface files. At the moment, all declarations (and no macros) are exported, and 'export' declarations are not supported yet. llvm-svn: 279794
2016-08-25Refactor to remove the assumption that we know the name of the module we're ↵Richard Smith1-2/+2
emitting at the point when we create a PCHGenerator (with the C++ modules TS, we find that out part way through parsing the input). llvm-svn: 279766
2016-08-18Module: add -fprebuilt-module-path to support loading prebuilt modules.Manman Ren1-1/+2
In this mode, there is no need to load any module map and the programmer can simply use "@import" syntax to load the module directly from a prebuilt module path. When loading from prebuilt module path, we don't support rebuilding of the module files and we ignore compatible configuration mismatches. rdar://27290316 Differential Revision: http://reviews.llvm.org/D23125 llvm-svn: 279096
2016-08-17Print the module format in clang -module-file-info.Adrian Prantl1-2/+7
llvm-svn: 279005
2016-08-17Support object-file-wrapped modules in clang -module-file-info.Adrian Prantl1-0/+8
rdar://problem/24504815 llvm-svn: 279004
2016-07-26Modules: add command line option fmodules-disable-diagnostic-validationManman Ren1-1/+5
With PCH+Module, sometimes compiler gives a hard error: Module file ‘<some-file path>.pcm' is out of date and needs to be rebuilt This happens when we have a pch importing a module and the module gets overwritten by another compiler instance after we build the pch (one example is that both compiler instances hash to the same pcm file but use different diagnostic options). When we try to load the pch later on, the compiler notices that the imported module is out of date (modification date, size do not match) but it can't handle this out of date pcm (i.e it does not know how to rebuild the pch). This commit introduces a new command line option so for PCH + module, we can turn on this option and if two compiler instances only differ in diagnostic options, the latter instance will not invalidate the original pcm. rdar://26675801 Differential Revision: http://reviews.llvm.org/D22773 llvm-svn: 276769
2016-07-18[NFC] Header cleanupMehdi Amini1-3/+2
Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
2016-07-15Frontend: Simplify ownership model for clang's output streams.Peter Collingbourne1-18/+25
This changes the CompilerInstance::createOutputFile function to return a std::unique_ptr<llvm::raw_ostream>, rather than an llvm::raw_ostream implicitly owned by the CompilerInstance. This in most cases required that I move ownership of the output stream to the relevant ASTConsumer. The motivation for this change is to allow BackendConsumer to be a client of interfaces such as D20268 which take ownership of the output stream. Differential Revision: http://reviews.llvm.org/D21537 llvm-svn: 275507
2016-07-13[PCH] Add a fno-pch-timestamp option to cc1 to disable inclusion of ↵Pierre Gousseau1-1/+4
timestamps in PCH files. This is to allow distributed build systems, that do not preserve time stamps, to use PCH files. Second and last part of the patch proposed at: Differential Revision: http://reviews.llvm.org/D20867 llvm-svn: 275267
2016-06-09RenderScript support in the FrontendPirama Arumuga Nainar1-0/+1
Summary: Create a new Frontend LangOpt to specify the renderscript language. It is enabled by the "-x renderscript" option from the driver. Add a "kernel" function attribute only for RenderScript (an "ignored attribute" warning is generated otherwise). Make the NativeHalfType and NativeHalfArgsAndReturns LangOpts be implied by the RenderScript LangOpt. Reviewers: rsmith Subscribers: cfe-commits, srhines Differential Revision: http://reviews.llvm.org/D21198 llvm-svn: 272342
2016-05-16[Modules] Use vfs for (recursive) directory iterationBruno Cardoso Lopes1-6/+7
Clang performs directory walk while searching headers inside modules by using the ::sys::fs instead of ::vfs. This prevents any code that uses the VFS (e.g, reproducer scripts) to actually find such headers, since the VFS will never be searched for those. Change these places to use vfs::recursive_directory_iterator and vfs::directory_iterator instead. Differential Revision: http://reviews.llvm.org/D20266 rdar://problem/25880368 llvm-svn: 269661
2016-05-12[Tooling] Fix broken dependency for shared buildEtienne Bergeron1-0/+3
Summary: There virtual destructor can't be found and cause a compilation error on a shared build. To repro: [Release + Shared] ``` -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON ``` Which produce this error: ``` tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/ToolingTest.cpp.o: In function `clang::tooling::newFrontendActionFactory_CreatesFrontendActionFactoryFromType_Test::TestBody()': ToolingTest.cpp:(.text._ZN5clang7tooling66newFrontendActionFactory_CreatesFrontendActionFactoryFromType_Test8TestBodyEv+0x49): undefined reference to `clang::SyntaxOnlyAction::~SyntaxOnlyAction()' ``` Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D20218 llvm-svn: 269334
2016-03-02[modules] addHeaderInclude() can't fail.Davide Italiano1-21/+12
Differential Revision: http://reviews.llvm.org/D17794 llvm-svn: 262463
2016-02-19[modules] Flatten -fmodule-name= and -fmodule-implementation-of= into a singleRichard Smith1-0/+2
option. Previously these options could both be used to specify that you were compiling the implementation file of a module, with a different set of minor bugs in each case. This change removes -fmodule-implementation-of, and instead tracks a flag to determine whether we're currently building a module. -fmodule-name now behaves the same way that -fmodule-implementation-of previously did. llvm-svn: 261372
2016-02-18Remove use of builtin comma operator.Richard Trieu1-1/+2
Cleanup for upcoming Clang warning -Wcomma. No functionality change intended. llvm-svn: 261271
2016-01-08[modules] Make sure we always include the contents of private headers whenRichard Smith1-9/+11
building a module. Prior to this change, the private header's content would only be included if the header were included by another header in the same module. If not (if the private header is only used by the .cc files of the module, or is included from outside the module via -Wno-private-header), a #include of that file would be silently ignored. llvm-svn: 257222
2015-11-26[modules] Refactor handling of -fmodules-embed-*. Track this properly ratherRichard Smith1-10/+11
than reusing the "overridden buffer" mechanism. This will allow us to make embedded files and overridden files behave differently in future. llvm-svn: 254121
2015-11-24[modules] Add -cc1 flag -fmodules-embed-all-files.Richard Smith1-0/+2
This flag causes all files that were read by the compilation to be embedded into a produced module file. This is useful for distributed build systems that use an include scanning system to determine which files are "needed" by a compilation, and only provide those files to remote compilation workers. Since using a module can require any file that is part of that module (or anything it transitively includes), files that are not found by an include scanner can be required in a regular build using explicit modules. With this flag, only files that are actually referenced by transitively-#included files are required to be present on the build machine. llvm-svn: 253950
2015-11-03Introduce module file extensions to piggy-back data onto module files.Douglas Gregor1-5/+25
Introduce the notion of a module file extension, which introduces additional information into a module file at the time it is built that can then be queried when the module file is read. Module file extensions are identified by a block name (which must be unique to the extension) and can write any bitstream records into their own extension block within the module file. When a module file is loaded, any extension blocks are matched up with module file extension readers, that are per-module-file and are given access to the input bitstream. Note that module file extensions can only be introduced by programmatic clients that have access to the CompilerInvocation. There is only one such extension at the moment, which is used for testing the module file extension harness. As a future direction, one could imagine allowing the plugin mechanism to introduce new module file extensions. llvm-svn: 251955
2015-09-19Further simplify the interface of PCHContainerGeneratorAdrian Prantl1-2/+2
by dropping the const qualifier on the CI. NFC llvm-svn: 248101
2015-09-18Simplify the interface of PCHContainerGenerator and friendsAdrian Prantl1-10/+4
by passing in a CompilerInstance instead of all its individual members. NFC. llvm-svn: 248053
2015-08-17[modules] When explicitly building a module file, don't include timestamps inRichard Smith1-1/+3
the produced pcm file for stable file creation across distributed build systems. llvm-svn: 245199
2015-08-14[modules] Add an experimental -cc1 feature to embed the contents of an inputRichard Smith1-2/+11
file in the .pcm files. This allows a smaller set of files to be sent to a remote build worker when building with explicit modules (for instance, module map files need not be sent along with the corresponding precompiled modules). This doesn't actually make the embedded files visible to header search, so it's not useful as a packaging format for public header files. llvm-svn: 245028
2015-07-17Make the clang module container format selectable from the command line.Adrian Prantl1-4/+4
- introduces a new cc1 option -fmodule-format=[raw,obj] with 'raw' being the default - supports arbitrary module container formats that libclang is agnostic to - adds the format to the module hash to avoid collisions - splits the old PCHContainerOperations into PCHContainerWriter and a PCHContainerReader. Thanks to Richard Smith for reviewing this patch! llvm-svn: 242499
2015-06-23[Modules] Consider -fmodule-feature in module hash and when loadingBen Langmuir1-0/+7
Any extra features from -fmodule-feature are part of the module hash and need to get validated on load. Also print them with -module-file-info. llvm-svn: 240433
2015-06-22Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko1-1/+1
llvm-svn: 240353
2015-06-22Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko1-1/+1
The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
2015-06-20Introduce a PCHContainerOperations interface (NFC).Adrian Prantl1-20/+39
A PCHContainerOperations abstract interface provides operations for creating and unwrapping containers for serialized ASTs (precompiled headers and clang modules). The default implementation is RawPCHContainerOperations, which uses a flat file for the output. The main application for this interface will be an ObjectFilePCHContainerOperations implementation that uses LLVM to wrap the module in an ELF/Mach-O/COFF container to store debug info alongside the AST. rdar://problem/20091852 llvm-svn: 240225
2015-05-16[modules] Retain the name as written for umbrella headers and directories, ↵Richard Smith1-30/+22
rather than converting to an absolute path. No observable change expected, but this allows us to correctly compute the module for an umbrella header, which later changes will require. llvm-svn: 237508
2015-04-14Use raw_pwrite_stream in clang.Rafael Espindola1-6/+1
This is a small improvement to -emit-pth and allows llvm to start requiring it. llvm-svn: 234897