summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/CompilerInstance.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Modules: Use hash of PCM content for SIGNATUREDuncan P. N. Exon Smith2017-03-131-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Change ASTFileSignature from a random 32-bit number to the hash of the PCM content. - Move definition ASTFileSignature to Basic/Module.h so Module and ASTSourceDescriptor can use it. - Change the signature from uint64_t to std::array<uint32_t,5>. - Stop using (saving/reading) the size and modification time of PCM files when there is a valid SIGNATURE. - Add UNHASHED_CONTROL_BLOCK, and use it to store the SIGNATURE record and other records that shouldn't affect the hash. Because implicit modules reuses the same file for multiple levels of -Werror, this includes DIAGNOSTIC_OPTIONS and DIAG_PRAGMA_MAPPINGS. This helps to solve a PCH + implicit Modules dependency issue: PCH files are handled by the external build system, whereas implicit modules are handled by internal compiler build system. This prevents invalidating a PCH when the compiler overwrites a PCM file with the same content (modulo the diagnostic differences). Design and original patch by Manman Ren! llvm-svn: 297655
* Modules: Simplify CompilerInstance constructor, NFCDuncan P. N. Exon Smith2017-02-021-4/+1
| | | | | | | Initialize fields directly in header. Note that the ModuleManager field is an IntrusiveRefCntPtr, so there's no need for explicit initialization. llvm-svn: 293863
* Reapply "IntrusiveRefCntPtr -> std::shared_ptr for CompilerInvocationBase ↵David Blaikie2017-01-061-6/+8
| | | | | | | | | | | | | | and CodeCompleteConsumer" Aleksey Shlypanikov pointed out my mistake in migrating an explicit unique_ptr to auto - I was expecting the function returned a unique_ptr, but instead it returned a raw pointer - introducing a leak. Thanks Aleksey! This reapplies r291184, reverted in r291249. llvm-svn: 291270
* Revert "IntrusiveRefCntPtr -> std::shared_ptr for CompilerInvocationBase and ↵David Blaikie2017-01-061-8/+6
| | | | | | | | | | CodeCompleteConsumer" Caused a memory leak reported by asan. Reverting while I investigate. This reverts commit r291184. llvm-svn: 291249
* shared_ptrify (from InclusiveRefCntPtr) HeaderSearchOptionsDavid Blaikie2017-01-061-5/+3
| | | | llvm-svn: 291202
* IntrusiveRefCntPtr -> std::shared_ptr for CompilerInvocationBase and ↵David Blaikie2017-01-051-6/+8
| | | | | | CodeCompleteConsumer llvm-svn: 291184
* Move Preprocessor over to std::shared_ptr rather than IntrusiveRefCntPtrDavid Blaikie2017-01-051-5/+7
| | | | llvm-svn: 291166
* Move PreprocessorOptions to std::shared_ptr from IntrusiveRefCntPtrDavid Blaikie2017-01-051-2/+3
| | | | llvm-svn: 291160
* Move FailedModulesSet over to shared_ptr from IntrusiveRefCntPtrDavid Blaikie2017-01-051-1/+2
| | | | llvm-svn: 291159
* Use shared_ptr instead of IntrusiveRefCntPtr for ModuleFileExtensionDavid Blaikie2017-01-051-1/+1
| | | | | | | The intrusiveness wasn't needed here, so this simplifies/clarifies the ownership model. llvm-svn: 291150
* [CrashReproducer] Add support for merging -ivfsoverlayBruno Cardoso Lopes2016-12-221-0/+21
| | | | | | | | | | | Merge all VFS mapped files inside -ivfsoverlay inputs into the vfs overlay provided by the crash reproducer. This is the last missing piece to allow crash reproducers to fully work with user frameworks; when combined with headermaps, it allows clang to find additional frameworks. rdar://problem/27913709 llvm-svn: 290326
* [CrashReproducer] Collect PCH included via -include-pchBruno Cardoso Lopes2016-12-121-0/+33
| | | | | | | | | | | | Collect the necessary input PCH files. Do not try to validate the AST before copying it out because if the crash is in this path, we won't be able to collect it. Instead only check if it's a file containg an AST. rdar://problem/27913709 llvm-svn: 289460
* [CrashReproducer] Collect headermap filesBruno Cardoso Lopes2016-12-111-1/+13
| | | | | | | | | | Include headermaps (.hmap files) in the .cache directory and add VFS entries. All headermaps are known after HeaderSearch setup, collect them right after. rdar://problem/27913709 llvm-svn: 289360
* Revert r288626, which reverts r288449. Original commit message:Richard Smith2016-12-061-4/+17
| | | | | | Recover better from an incompatible .pcm file being provided by -fmodule-file=. We try to include the headers of the module textually in this case, still enforcing the modules semantic rules. In order to make that work, we need to still track that we're entering and leaving the module. Also, if the module was also marked as unavailable (perhaps because it was missing a file), we shouldn't mark the module unavailable -- we don't need the module to be complete if we're going to enter it textually. llvm-svn: 288741
* Revert "Recover better from an incompatible .pcm file being provided by ↵Daniel Jasper2016-12-041-17/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -fmodule-file=. We try to include the headers of the module textually in this case, still enforcing the modules semantic rules. In order to make that work, we need to still track that we're entering and leaving the module. Also, if the module was also marked as unavailable (perhaps because it was missing a file), we shouldn't mark the module unavailable -- we don't need the module to be complete if we're going to enter it textually." This reverts commit r288449. I believe that this is currently faulty wrt. modules being imported inside namespaces. Adding these lines to the new test: namespace n { #include "foo.h" } Makes it break with fatal error: import of module 'M' appears within namespace 'n' However, I believe it should fail with error: redundant #include of module 'M' appears within namespace 'n' I have tracked this down to us now inserting a tok::annot_module_begin instead of a tok::annot_module_include in Preprocessor::HandleIncludeDirective() and then later in Parser::parseMisplacedModuleImport(), we hit the code path for tok::annot_module_begin, which doesn't set FromInclude of checkModuleImportContext to true (thus leading to the "wrong" diagnostic). llvm-svn: 288626
* Recover better from an incompatible .pcm file being provided by -fmodule-file=.Richard Smith2016-12-021-4/+17
| | | | | | | | | | | We try to include the headers of the module textually in this case, still enforcing the modules semantic rules. In order to make that work, we need to still track that we're entering and leaving the module. Also, if the module was also marked as unavailable (perhaps because it was missing a file), we shouldn't mark the module unavailable -- we don't need the module to be complete if we're going to enter it textually. llvm-svn: 288449
* Adapt to llvm NamedRegionTimer changesMatthias Braun2016-11-181-5/+10
| | | | | | We have to specify a name and description for the timers and groups now. llvm-svn: 287371
* [CUDA] Initialize our header search using the host triple.Justin Lebar2016-11-181-2/+9
| | | | | | | | | | | | | | | | Summary: This used to work because system headers are found in a (somewhat) predictable set of locations on Linux. But this is not the case on MacOS; without this change, we don't look in the right places for our headers when doing device-side compilation on Mac. Reviewers: tra Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26776 llvm-svn: 287286
* [Frontend] Allow attaching an external sema source to compiler instance and ↵Benjamin Kramer2016-11-161-0/+10
| | | | | | | | | | | extra diags to TypoCorrections This can be used to append alternative typo corrections to an existing diag. include-fixer can use it to suggest includes to be added. Differential Revision: https://reviews.llvm.org/D26745 llvm-svn: 287128
* Switch SmallSetVector to use DenseSet when it overflows its inline space.Justin Lebar2016-10-211-1/+2
| | | | | | | | | | | | | | | | | | | | Summary: SetVector already used DenseSet, but SmallSetVector used std::set. This leads to surprising performance differences. Moreover, it means that the set of key types accepted by SetVector and SmallSetVector are quite different! In order to make this change, we had to convert some callsites that used SmallSetVector<std::string, N> to use SmallSetVector<CachedHashString, N> instead. Reviewers: timshen Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D25648 llvm-svn: 284887
* Adapt to LLVM EnableStatistics() change.Matthias Braun2016-09-271-1/+1
| | | | llvm-svn: 282533
* CC1: Add -save-stats optionMatthias Braun2016-09-261-4/+19
| | | | | | | | | This option behaves in a similar spirit as -save-temps and writes internal llvm statistics in json format to a file. Differential Revision: https://reviews.llvm.org/D24820 llvm-svn: 282426
* C++ Modules TS: add frontend support for building pcm files from moduleRichard Smith2016-08-261-1/+1
| | | | | | | interface files. At the moment, all declarations (and no macros) are exported, and 'export' declarations are not supported yet. llvm-svn: 279794
* Module: add -fprebuilt-module-path to support loading prebuilt modules.Manman Ren2016-08-181-9/+60
| | | | | | | | | | | | | 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
* [OpenCL][AMDGPU] Add support for -cl-denorms-are-zeroYaxun Liu2016-08-091-0/+3
| | | | | | | | | | | | Adjust target features for amdgcn target when -cl-denorms-are-zero is set. Denormal support is controlled by feature strings fp32-denormals fp64-denormals in amdgcn target. If -cl-denorms-are-zero is not set and the command line does not set fp32/64-denormals feature string, +fp32-denormals +fp64-denormals will be on for GPU's supporting them. A new virtual function virtual void TargetInfo::adjustTargetOptions(const CodeGenOptions &CGOpts, TargetOptions &TargetOpts) const is introduced to allow adjusting target option by codegen option. Differential Revision: https://reviews.llvm.org/D22815 llvm-svn: 278151
* [NFC] Header cleanupMehdi Amini2016-07-181-0/+1
| | | | | | | | | | 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
* Frontend: Simplify ownership model for clang's output streams.Peter Collingbourne2016-07-151-16/+7
| | | | | | | | | | | | | | 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
* Add some std::move where the value is only read otherwise.Benjamin Kramer2016-06-121-2/+2
| | | | | | This mostly affects smart pointers. No functionality change intended. llvm-svn: 272520
* [Modules] Improve diagnostics for LockFileManager errorsBruno Cardoso Lopes2016-06-041-1/+1
| | | | | | | | Uses error message now provided by LockFileManager in LLVM r271755. rdar://problem/26529101 llvm-svn: 271758
* Apply clang-tidy's misc-move-constructor-init throughout Clang.Benjamin Kramer2016-05-271-1/+3
| | | | | | No functionality change intended, maybe a tiny performance improvement. llvm-svn: 270996
* [CUDA] Copy host builtin types to NVPTXTargetInfo.Justin Lebar2016-04-291-1/+2
| | | | | | | | | | | | | | | | | Summary: Host and device types must match, otherwise when we pass values back and forth between the host and device, we will get the wrong result. This patch makes NVPTXTargetInfo inherit most of its type information from the host's target info. Reviewers: rsmith Subscribers: cfe-commits, jhen, tra Differential Revision: http://reviews.llvm.org/D19346 llvm-svn: 268131
* revert SVN r265702, r265640Saleem Abdulrasool2016-04-081-4/+2
| | | | | | | | | | | Revert the two changes to thread CodeGenOptions into the TargetInfo allocation and to fix the layering violation by moving CodeGenOptions into Basic. Code Generation is arguably not particularly "basic". This addresses Richard's post-commit review comments. This change purely does the mechanical revert and will be followed up with an alternate approach to thread the desired information into TargetInfo. llvm-svn: 265806
* Basic: thread CodeGenOptions into TargetInfoSaleem Abdulrasool2016-04-071-2/+4
| | | | | | | | | This threads CodeGenOptions into the TargetInfo hierarchy. This is motivated by ARM which can change some target information based on the EABI selected (-meabi). Similar options exist for other platforms (e.g. MIPS) and thus is generally useful. NFC. llvm-svn: 265640
* [CrashReproducer] Cleanup and move functionality around in ↵Bruno Cardoso Lopes2016-03-291-6/+8
| | | | | | | | | | | ModuleDependencyCollector. NFC - Make ModuleDependencyCollector use the DependencyCollector interface - Move some methods from ModuleDependencyListener to ModuleDependencyCollector in order to share common functionality with other future possible callbacks. llvm-svn: 264808
* clang-cl: Fix remaining bugs in interaction of /Yc and /FI /showIncludes.Nico Weber2016-03-231-4/+4
| | | | | | | | | | Instead of putting the /Yc header into ExtraDeps, give DependencyOutputOptions a dedicated field for /Yc mode, and let HeaderIncludesCallback hang on to the full DependencyOutputOptions object, not just ExtraDeps. Reverts parts of r263352 that are now no longer needed. llvm-svn: 264182
* clang-cl: Include /FI headers in /showIncludes output.Nico Weber2016-03-231-1/+1
| | | | | | | | | | | | | | | | | -H in gcc mode doesn't print -include headers, but they are included in depfiles written by MMD and friends. Since /showIncludes is what's used instead of depfiles, printing /FI there seems important (and matches cl.exe). Instead of giving HeaderIncludeGen more options, just switch on ShowAllHeaders in clang-cl mode and let clang::InitializePreprocessor() not put -include flags in the <command line> block. This changes the behavior of -E slightly, and it removes the <command line> flag from the output triggered by setting the obscure CC_PRINT_HEADERS=1 env var to true while running clang. Both of these seem ok to change. http://reviews.llvm.org/D18401 llvm-svn: 264174
* clang-cl: Add /Yc argument to /showIncludes output.Nico Weber2016-03-131-7/+8
| | | | | | | | | | To make this work, delay printing of ExtraDeps in HeaderIncludesCallback a bit, so that it happens after CompilerInstance::InitializeSourceManager() has run. General /FI arguments are still missing from /showIncludes output, this still needs to be fixed. llvm-svn: 263352
* clang-cl: Implement initial limited support for precompiled headers.Nico Weber2016-03-011-4/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the gcc precompiled header model, one explicitly runs clang with `-x c++-header` on a .h file to produce a gch file, and then includes the header with `-include foo.h` and if a .gch file exists for that header it gets used. This is documented at http://clang.llvm.org/docs/UsersManual.html#precompiled-headers cl.exe's model is fairly different, and controlled by the two flags /Yc and /Yu. A pch file is generated as a side effect of a regular compilation when /Ycheader.h is passed. While the compilation is running, the compiler keeps track of #include lines in the main translation unit and writes everything up to an `#include "header.h"` line into a pch file. Conversely, /Yuheader.h tells the compiler to skip all code in the main TU up to and including `#include "header.h"` and instead load header.pch. (It's also possible to use /Yc and /Yu without an argument, in that case a `#pragma hrdstop` takes the role of controlling the point where pch ends and real code begins.) This patch implements limited support for this in that it requires the pch header to be passed as a /FI force include flag – with this restriction, it can be implemented almost completely in the driver with fairly small amounts of code. For /Yu, this is trivial, and for /Yc a separate pch action is added that runs before the actual compilation. After r261774, the first failing command makes a compilation stop – this means if the pch fails to build the main compilation won't run, which is what we want. However, in /fallback builds we need to run the main compilation even if the pch build fails so that the main compilation's fallback can run. To achieve this, add a ForceSuccessCommand that pretends that the pch build always succeeded in /fallback builds (the main compilation will then fail to open the pch and run the fallback cl.exe invocation). If /Yc /Yu are used in a setup that clang-cl doesn't implement yet, clang-cl will now emit a "not implemented yet; flag ignored" warning that can be disabled using -Wno-clang-cl-pch. Since clang-cl doesn't yet serialize some important things (most notably `pragma comment(lib, ...)`, this feature is disabled by default and only enabled by an internal driver flag. Once it's more stable, this internal flag will disappear. (The default stdafx.h setup passes stdafx.h as explicit argument to /Yc but not as /FI – instead every single TU has to `#include <stdafx.h>` as first thing it does. Implementing support for this should be possible with the approach in this patch with minimal frontend changes by passing a --stop-at / --start-at flag from the driver to the frontend. This is left for a follow-up. I don't think we ever want to support `#pragma hdrstop`, and supporting it with this approach isn't easy: This approach relies on the driver knowing the pch filename in advance, and `#pragma hdrstop(out.pch)` can set the output filename, so the driver can't know about it in advance.) clang-cl now also honors /Fp and puts pch files in the same spot that cl.exe would put them, but the pch file format is of course incompatible. This has ramifications on /fallback, so /Yc /Yu aren't passed through to cl.exe in /fallback builds. http://reviews.llvm.org/D17695 llvm-svn: 262420
* [modules] Flatten -fmodule-name= and -fmodule-implementation-of= into a singleRichard Smith2016-02-191-8/+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
* Reduce the number of implicit StringRef->std::string conversions by ↵Benjamin Kramer2016-02-131-1/+1
| | | | | | | | threading StringRef through more APIs. No functionality change intended. llvm-svn: 260815
* Update for llvm API change.Rafael Espindola2015-12-161-1/+0
| | | | llvm-svn: 255838
* [Frontend] Rangify for loop. NFC.Vedant Kumar2015-11-161-2/+2
| | | | llvm-svn: 253178
* [modules] If we're given a module file, via -fmodule-file=, for a module, butRichard Smith2015-11-051-4/+24
| | | | | | | | | we can't load that file due to a configuration mismatch, and implicit module building is disabled, and the user turns off the error-by-default warning for that situation, then fall back to textual inclusion for the module rather than giving an error if any of its headers are included. llvm-svn: 252114
* Introduce module file extensions to piggy-back data onto module files.Douglas Gregor2015-11-031-5/+9
| | | | | | | | | | | | | | | | | | | | | 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
* [modules] Allow the error when explicitly loading an incompatible module fileRichard Smith2015-10-161-5/+14
| | | | | | | | | via -fmodule-file= to be turned off; in that case, just include the relevant files textually. This allows module files to be unconditionally passed to all compile actions via CXXFLAGS, and to be ignored for rules that specify custom incompatible flags. llvm-svn: 250577
* Use llvm::errc instead of std::errc.Rafael Espindola2015-10-051-1/+1
| | | | llvm-svn: 249302
* Replace double negation of !FileID.isInvalid() with FileID.isValid().Yaron Keren2015-10-031-3/+3
| | | | | | +couple more of double-negated !SourceLocation.isInvalid() unfixed in r249228. llvm-svn: 249235
* [CUDA] Allow parsing of host and device code simultaneously.Artem Belevich2015-09-221-5/+11
| | | | | | | | | | | | * adds -aux-triple option to specify target triple * propagates aux target info to AST context and Preprocessor * pulls in target specific preprocessor macros. * pulls in target-specific builtins from aux target. * sets appropriate host or device attribute on builtins. Differential Revision: http://reviews.llvm.org/D12917 llvm-svn: 248299
* createOutputFile should set Error to something if it returns null.Douglas Katzman2015-09-171-1/+3
| | | | | | | This is not portably unit-testable because the only visible effect is a change from one random message string to another. llvm-svn: 247900
* Initialize the AST consumer as soon as we have both an ASTConsumer and anRichard Smith2015-08-181-8/+15
| | | | | | | ASTContext. Fixes some cases where we could previously initialize the AST consumer more than once. llvm-svn: 245346
OpenPOWER on IntegriCloud