aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInstance.cpp
AgeCommit message (Collapse)AuthorFilesLines
2015-05-18[modules] Move implicit creation of ImportDecls for #includes transformed ↵Richard Smith1-19/+0
into module imports from the frontend into Sema where it belongs. llvm-svn: 237555
2015-05-16[modules] Retain the name as written for umbrella headers and directories, ↵Richard Smith1-3/+5
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-05-15[modules] Add local submodule visibility support for declarations.Richard Smith1-0/+5
With this change, enabling -fmodules-local-submodule-visibility results in name visibility rules being applied to submodules of the current module in addition to imported modules (that is, names no longer "leak" between submodules of the same top-level module). This also makes it much safer to textually include a non-modular library into a module: each submodule that textually includes that library will get its own "copy" of that library, and so the library becomes visible no matter which including submodule you import. llvm-svn: 237473
2015-05-01[modules] Start moving the module visibility information off the Module itself.Richard Smith1-6/+4
It has no place there; it's not a property of the Module, and it makes restoring the visibility set when we leave a submodule more difficult. llvm-svn: 236300
2015-04-29[modules] Stop trying to fake up a linear MacroDirective history.Richard Smith1-63/+35
Modules builds fundamentally have a non-linear macro history. In the interest of better source fidelity, represent the macro definition information faithfully: we have a linear macro directive history within each module, and at any point we have a unique "latest" local macro directive and a collection of visible imported directives. This also removes the attendent complexity of attempting to create a correct MacroDirective history (which we got wrong in the general case). No functionality change intended. llvm-svn: 236176
2015-04-14Use raw_pwrite_stream in clang.Rafael Espindola1-13/+17
This is a small improvement to -emit-pth and allows llvm to start requiring it. llvm-svn: 234897
2015-04-10[Frontend] Close open file handles before renaming output filesReid Kleckner1-10/+12
The placement of the 'delete' call that was removed in the unique_ptr migration in r234597 was not an accident. The raw_ostream has to be destroyed before you do the rename on Windows, otherwise you get ERROR_ACCESS_DENIED. We can still use unique_ptr, we just need to do a manual reset(). Also, range-for-loop-ify this code. llvm-svn: 234612
2015-04-10Return std::unique_ptr to avoid a release and recreate.Rafael Espindola1-4/+4
llvm-svn: 234598
2015-04-10Use a std::unique_ptr to make it easier to see who owns the stream.Rafael Espindola1-10/+11
llvm-svn: 234597
2015-03-28[Modules] Don't compute a modules cache path if we're not using modules!Chandler Carruth1-1/+2
Notably, this prevents us from doing *tons* of work to compute the modules hash, including trying to read a darwin specific plist file off of the system. There is a lot that needs cleaning up below this layer too. llvm-svn: 233462
2015-03-24[Modules] Stop creating timestamps for the modules cache and trying toChandler Carruth1-3/+4
prune it when we have disabled implicit module generation and thus are not using any cached modules. Also update a test of explicitly generated modules to pass this CC1 flag correctly. This fixes an issue where Clang was dropping files into the source tree while running its tests. llvm-svn: 233117
2015-03-18Remove many superfluous SmallString::str() calls.Yaron Keren1-5/+4
Now that SmallString is a first-class citizen, most SmallString::str() calls are not required. This patch removes a whole bunch of them, yet there are lots more. There are two use cases where str() is really needed: 1) To use one of StringRef member functions which is not available in SmallString. 2) To convert to std::string, as StringRef implicitly converts while SmallString do not. We may wish to change this, but it may introduce ambiguity. llvm-svn: 232622
2015-03-18Make module files passed to a module build via -fmodule-file= available toRichard Smith1-0/+13
consumers of that module. Previously, such a file would only be available if the module happened to actually import something from that module. llvm-svn: 232583
2015-02-28Give better diagnostics when -fmodule-file= finds a bad file: if the file isRichard Smith1-3/+13
found indirectly, explain how we got there, and distinguish between 'file not found' and 'file found but invalid'. llvm-svn: 230839
2015-02-25[modules] Even if we already have a definition of a class, loading in anotherRichard Smith1-1/+4
one can give us more lookup results (due to implicit special members). Be sure to complete the redecl chain for every kind of DeclContext before performing a lookup into it, rather than only doing so for NamespaceDecls. llvm-svn: 230558
2015-02-25[modules] Fix a bug that would result in a build with P paths through a moduleRichard Smith1-0/+3
graph with M modules to take O(P) time, not just O(M) time, when using explicit module builds. llvm-svn: 230412
2015-02-20Add -fno-implicit-modules.Manuel Klimek1-0/+6
If this flag is set, we error out when a module build is required. This is useful in environments where all required modules are passed via -fmodule-file. llvm-svn: 230006
2015-02-19[PCH/Modules] Check that the specific module cache path the PCH was built ↵Argyrios Kyrtzidis1-8/+12
with, is the same as the one in the current compiler invocation. If they differ reject the PCH. This protects against the badness occurring from getting modules loaded from different module caches (see crashes). rdar://19889860 llvm-svn: 229909
2015-02-09Diagnose timeouts in the LockFileManager and delete the dead lock fileBen Langmuir1-2/+12
If the lock file manager times out, we should give an error rather than silently trying to load the existing module. And delete the (presumably) dead lock file, since it will otherwise prevent progress in future invokations. This is unsound since we have no way to prove that the lock file we are deleting is the same one we timed out on, but since the lock is only to avoid excessive rebuilding anyway it should be okay. Depends on llvm r228603. llvm-svn: 228604
2015-02-04[modules] When using -E, we may try to merge decls despite having no SemaRichard Smith1-14/+13
object. In such a case, use the TU's DC for merging global decls rather than giving up when we find there is no TU scope. Ultimately, we should probably avoid all loading of decls when preprocessing, but there are other reasonable use cases for loading an AST file with no Sema object for which this is the right thing. llvm-svn: 228234
2015-01-23PR22299: Relocate code for handling -fmodule-map-file= so that we don't try toRichard Smith1-8/+0
produce diagnostics with source locations before the diagnostics system is ready for them. llvm-svn: 226882
2014-12-09[modules] If the same .pcm file is imported via two different paths, don'tRichard Smith1-1/+3
complain that the contained modules are defined twice. llvm-svn: 223724
2014-12-06PR21217: Slightly more eagerly load -fmodule-map-file= files and provideRichard Smith1-0/+8
diagnostics if they don't exist. Based on a patch by John Thompson! llvm-svn: 223561
2014-12-02[modules] Track how 'header' directives were written in module map files,Richard Smith1-2/+9
rather than trying to extract this information from the FileEntry after the fact. This has a number of beneficial effects. For instance, diagnostic messages for failed module builds give a path relative to the "module root" rather than an absolute file path, and the contents of the module includes file is no longer dependent on what files the including TU happened to inspect prior to triggering the module build. llvm-svn: 223095
2014-11-17Make DiagnosticsEngine::takeClient return std::unique_ptr<>Alexander Kornienko1-5/+3
Summary: Make DiagnosticsEngine::takeClient return std::unique_ptr<>. Updated callers to store conditional ownership using a pair of pointer and unique_ptr instead of a pointer + bool. Updated code that temporarily registers clients to use the non-owning registration (+ removed extra calls to takeClient). Reviewers: dblaikie Reviewed By: dblaikie Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D6294 llvm-svn: 222193
2014-11-17A small correction for r221884. No functional changes.Alexander Kornienko1-1/+1
llvm-svn: 222130
2014-11-13Support non-owned DiagnosticConsumer in SetupSerializedDiagnosticsAlexander Kornienko1-4/+8
This fixes an assertion when running clang-tidy on a file having --serialize-diagnostics in compiler options. Committing a regression test for clang-tidy separately. Patch by Aaron Wishnick! llvm-svn: 221884
2014-10-27[modules] Load .pcm files specified by -fmodule-file lazily.Richard Smith1-44/+67
llvm-svn: 220731
2014-10-26Make VFS and FileManager match the current MemoryBuffer API.Benjamin Kramer1-6/+6
This eliminates converting back and forth between the 3 formats and gives us a more homogeneous interface. llvm-svn: 220657
2014-10-23Driver: Include driver diagnostics when we --serialize-diagnosticsJustin Bogner1-11/+1
Currently, when --serialize-diagnostics is passed this only includes the diagnostics from clang -cc1, and driver diagnostics are dropped. This causes issues for tools that use the serialized diagnostics, since stderr is lost and these diagnostics aren't seen at all. We handle this by merging the diagnostics from the CC1 process and the driver diagnostics into a single file when the driver invokes CC1. Fixes rdar://problem/10585062 llvm-svn: 220525
2014-10-22[modules] Initial support for explicitly loading .pcm files.Richard Smith1-3/+51
Implicit module builds are not well-suited to a lot of build systems. In particular, they fare badly in distributed build systems, and they lead to build artifacts that are not tracked as part of the usual dependency management process. This change allows explicitly-built module files (which are already supported through the -emit-module flag) to be explicitly loaded into a build, allowing build systems to opt to manage module builds and dependencies themselves. This is only the first step in supporting such configurations, and it should be considered experimental and subject to change or removal for now. llvm-svn: 220359
2014-10-14Extend -Rmodule-build to also remark when module building finishes.Richard Smith1-4/+9
In cases of nested module builds, or when you care how long module builds take, this information was not previously easily available / obvious. llvm-svn: 219658
2014-09-26Ensure that all module build failures get diagnosedBen Langmuir1-2/+11
Otherwise we can end up silently skipping an import. If we happen to be building another module at the time, we may build a mysteriously broken module and not know why it seems to be missing symbols. llvm-svn: 218552
2014-09-15unique_ptrify ChainedDiagnosticConsumer's ctor parametersDavid Blaikie1-6/+11
llvm-svn: 217793
2014-09-15Fix memory leak of raw_ostreams in LogDiagnosticPrinter handling.David Blaikie1-7/+7
This is another case of conditional ownership (in this case a raw reference, plus a boolean to indicate whether the referenced object should be deleted). While it's not ideal, I prefer to make the ownership explicit with a unique_ptr than using a boolean flag (though it does make the reference and the unique_ptr redundant in the sense that they both refer to the same memory). At some point we might write a reusable conditional ownership pointer (a stateful custom deleter for a unique_ptr may be appropriate). Based on a patch from a patch by Anton Yartsev. llvm-svn: 217791
2014-08-29unique_ptrify the raw_ostream argument to clang::serialized_diags::createDavid Blaikie1-4/+3
llvm-svn: 216767
2014-08-29Provide a BuryPointer for unique_ptrs.David Blaikie1-0/+1
In theory, it'd be nice if we could move to a case where all buried pointers were buried via unique_ptr to demonstrate that the program had finished with the value (that we could really have cleanly deallocated it) but instead chose to bury it. I think the main reason that's not possible right now is the various IntrusiveRefCntPtrs in the Frontend, sharing ownership for a variety of compiler bits (see the various similar "CompilerInstance::releaseAndLeak*" functions). I have yet to figure out their correct ownership semantics - but perhaps, even if the intrusiveness can be removed, the shared ownership may yet remain and that would lead to a non-unique burying as is there today. (though we could model that a little better - by passing in a shared_ptr, etc - rather than needing the two step that's currently used in those other releaseAndLeak* functions) This might be a bit more robust if BuryPointer took the boolean: BuryPointer(bool, unique_ptr<T>) and the choice to bury was made internally - that way, even when DisableFree was not set, the unique_ptr would still be null in the caller and there'd be no chance of accidentally having a different codepath where the value is used after burial in !DisableFree, but it becomes null only in DisableFree, etc... llvm-svn: 216742
2014-08-29unique_ptrify SourceManager::createFileIDDavid Blaikie1-1/+2
llvm-svn: 216715
2014-08-27Overload SourceManager::overrideFileContents so that unconditionally passing ↵David Blaikie1-3/+3
ownership is explicitly done using unique_ptr. Only those callers who are dynamically passing ownership should need the 3 argument form. Those accepting the default ("do pass ownership") should do so explicitly with a unique_ptr now. llvm-svn: 216614
2014-08-27Update for LLVM api change.Rafael Espindola1-2/+2
llvm-svn: 216585
2014-08-27Add support for the static analyzer to synthesize function implementations ↵Ted Kremenek1-2/+3
from external model files. Currently the analyzer lazily models some functions using 'BodyFarm', which constructs a fake function implementation that the analyzer can simulate that approximates the semantics of the function when it is called. BodyFarm does this by constructing the AST for such definitions on-the-fly. One strength of BodyFarm is that all symbols and types referenced by synthesized function bodies are contextual adapted to the containing translation unit. The downside is that these ASTs are hardcoded in Clang's own source code. A more scalable model is to allow these models to be defined as source code in separate "model" files and have the analyzer use those definitions lazily when a function body is needed. Among other things, it will allow more customization of the analyzer for specific APIs and platforms. This patch provides the initial infrastructure for this feature. It extends BodyFarm to use an abstract API 'CodeInjector' that can be used to synthesize function bodies. That 'CodeInjector' is implemented using a new 'ModelInjector' in libFrontend, which lazily parses a model file and injects the ASTs into the current translation unit. Models are currently found by specifying a 'model-path' as an analyzer option; if no path is specified the CodeInjector is not used, thus defaulting to the current behavior in the analyzer. Models currently contain a single function definition, and can be found by finding the file <function name>.model. This is an initial starting point for something more rich, but it bootstraps this feature for future evolution. This patch was contributed by Gábor Horváth as part of his Google Summer of Code project. Some notes: - This introduces the notion of a "model file" into FrontendAction and the Preprocessor. This nomenclature is specific to the static analyzer, but possibly could be generalized. Essentially these are sources pulled in exogenously from the principal translation. Preprocessor gets a 'InitializeForModelFile' and 'FinalizeForModelFile' which could possibly be hoisted out of Preprocessor if Preprocessor exposed a new API to change the PragmaHandlers and some other internal pieces. This can be revisited. FrontendAction gets a 'isModelParsingAction()' predicate function used to allow a new FrontendAction to recycle the Preprocessor and ASTContext. This name could probably be made something more general (i.e., not tied to 'model files') at the expense of losing the intent of why it exists. This can be revisited. - This is a moderate sized patch; it has gone through some amount of offline code review. Most of the changes to the non-analyzer parts are fairly small, and would make little sense without the analyzer changes. - Most of the analyzer changes are plumbing, with the interesting behavior being introduced by ModelInjector.cpp and ModelConsumer.cpp. - The new functionality introduced by this change is off-by-default. It requires an analyzer config option to enable. llvm-svn: 216550
2014-08-26Return a std::unique_ptr from getBufferForFile. NFC.Rafael Espindola1-2/+2
llvm-svn: 216476
2014-08-25Update for llvm api change.Rafael Espindola1-36/+26
llvm-svn: 216397
2014-08-11Revert r215331, "unique_ptrify CompilerInstance::OutputFile(s) and remove a ↵NAKAMURA Takumi1-16/+14
unique_ptr around a non-owning raw_ostream in CodeGenAction::CreateASTConsumer" It cannot be compiled on Visual Studio 2012. clang\include\clang/Frontend/CompilerInstance.h(153): error C2248: 'std::unique_ptr<_Ty>::unique_ptr' : cannot access private member declared in class 'std::unique_ptr<_Ty>' with [ _Ty=llvm::raw_ostream ] D:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\memory(1447) : see declaration of 'std::unique_ptr<_Ty>::unique_ptr' with [ _Ty=llvm::raw_ostream ] This diagnostic occurred in the compiler generated function 'clang::CompilerInstance::OutputFile::OutputFile(const clang::CompilerInstance::OutputFile &)' llvm-svn: 215346
2014-08-10unique_ptrify CompilerInstance::OutputFile(s) and remove a unique_ptr around ↵David Blaikie1-14/+16
a non-owning raw_ostream in CodeGenAction::CreateASTConsumer llvm-svn: 215331
2014-08-10Out-of-line CompilerInstance::takeSema to avoid a header dependence from ↵David Blaikie1-1/+5
CompilerInstance.h on Sema.h Hopefully this fixes the libstdc++ build on some of the buildbots after r215321. llvm-svn: 215325
2014-08-10Recommit 213307: unique_ptr-ify ownership of ASTConsumers (reverted in r213325)David Blaikie1-2/+2
After post-commit review and community discussion, this seems like a reasonable direction to continue, making ownership semantics explicit in the source using the type system. llvm-svn: 215323
2014-08-09Refactor the module map file used for uniquing a module name out ofBen Langmuir1-2/+3
class Module. It's almost always going to be the same as getContainingModule() for top-level modules, so just add a map to cover the remaining cases. This lets us do less bookkeeping to keep the ModuleMap fields up to date. llvm-svn: 215268
2014-07-23Add stopgap option -fmodule-implementation-of <name>Ben Langmuir1-2/+8
This flag specifies that we are building an implementation file of the module <name>, preventing importing <name> as a module. This does not consider this to be the 'current module' for the purposes of doing modular checks like decluse or non-modular-include warnings, unlike -fmodule-name. This is needed as a stopgap until: 1) we can resolve relative includes to a VFS-mapped module (or can safely import a header textually and as part of a module) and ideally 2) we can safely do incremental rebuilding when implementation files import submodules. llvm-svn: 213767
2014-07-19If a module build reports errors, don't try to load itBen Langmuir1-13/+21
... just to find out that it didn't build. llvm-svn: 213454