aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Serialization/ModuleManager.cpp
AgeCommit message (Collapse)AuthorFilesLines
2015-05-20Allow skipping imports in the module visitor.Manuel Klimek1-22/+57
Skip imports when we know that we do not need to visit any imports because we've already deserialized the redecls from a module. llvm-svn: 237782
2015-03-24A couple of readASTFileSignature improvements (NFC)Ben Langmuir1-2/+1
* Strength reduce a std::function to a function pointer, * Factor out checking the AST file magic number, * Add a brief doc comment to readAStFileSignature Thanks to Chandler for spotting these oddities. llvm-svn: 233050
2015-03-18Make module files passed to a module build via -fmodule-file= available toRichard Smith1-0/+11
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-25Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."Adrian Prantl1-5/+4
llvm-svn: 230454
2015-02-25Wrap clang module files in a Mach-O, ELF, or COFF container.Adrian Prantl1-4/+5
This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. This reapplies r230044 with a fixed configure+make build and updated dependencies and testcase requirements. Over the last iteration this version adds - missing target requirements for testcases that specify an x86 triple, - a missing clangCodeGen.a dependency to libClang.a in the make build. rdar://problem/19104245 llvm-svn: 230423
2015-02-24Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."Adrian Prantl1-5/+4
This reverts commit r230305. Off to fix another round of missing dependencies on various platforms. llvm-svn: 230309
2015-02-24Wrap clang module files in a Mach-O, ELF, or COFF container.Adrian Prantl1-4/+5
This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. rdar://problem/19104245 This reapplies r230044 with a fixed configure+make build and updated dependencies. Take 3. llvm-svn: 230305
2015-02-21Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."Adrian Prantl1-5/+4
This reverts commit 230099. The Linux configure+make build variant still needs some work. llvm-svn: 230103
2015-02-20Wrap clang module files in a Mach-O, ELF, or COFF container.Adrian Prantl1-4/+5
This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. rdar://problem/19104245 This reapplies r230044 with a fixed configure+make build and updated dependencies. Take 2. llvm-svn: 230089
2015-02-20Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."Adrian Prantl1-5/+4
This reverts commit r230067. Investigating another batch of problems found by the bots. llvm-svn: 230073
2015-02-20Wrap clang module files in a Mach-O, ELF, or COFF container.Adrian Prantl1-4/+5
This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. rdar://problem/19104245 This reapplies r230044 with a fixed configure+make build and updated dependencies. llvm-svn: 230067
2015-02-20Revert "Wrap clang module files in a Mach-O, ELF, or COFF container."Adrian Prantl1-5/+4
This reverts commit r230044 while dealing with buildbot breakage. Conflicts: test/Modules/module_container.m llvm-svn: 230052
2015-02-20Wrap clang module files in a Mach-O, ELF, or COFF container.Adrian Prantl1-4/+5
This is a necessary prerequisite for debugging with modules. The .pcm files become containers that hold the serialized AST which allows us to store debug information in the module file that can be shared by all object files that were built importing the module. rdar://problem/19104245 llvm-svn: 230044
2014-11-21[modules] When explicitly importing a module, it's fine for the imported moduleRichard Smith1-0/+7
to be newer than we were expecting. That happens if .pcm's get moved between file systems during a distributed build. (It's still not OK for them to actually be different, though, so we still check the size and signature matches.) llvm-svn: 222507
2014-11-08Check module signature when the module has already been loadedBen Langmuir1-7/+13
We may need to verify the signature on subsequent imports as well, just like we verify the size/modtime: @import A; @import B; // imports A @import C; // imports A llvm-svn: 221569
2014-10-26Make VFS and FileManager match the current MemoryBuffer API.Benjamin Kramer1-13/+12
This eliminates converting back and forth between the 3 formats and gives us a more homogeneous interface. llvm-svn: 220657
2014-10-24[Modules] Free modules that failed signature verification.Benjamin Kramer1-0/+1
The control flow and ownership is weird enough so unique_ptr doesn't help here :( llvm-svn: 220569
2014-10-23Add a "signature" to AST files to verify that they haven't changedBen Langmuir1-0/+18
Since the order of the IDs in the AST file (e.g. DeclIDs, SelectorIDs) is not stable, it is not safe to load an AST file that depends on another AST file that has been rebuilt since the importer was built, even if "nothing changed". We previously used size and modtime to check this, but I've seen cases where a module rebuilt quickly enough to foil this check and caused very hard to debug build errors. To save cycles when we're loading the AST, we just generate a random nonce value and check that it hasn't changed when we load an imported module, rather than actually hash the whole file. This is slightly complicated by the fact that we need to verify the signature inside addModule, since we might otherwise consider that a mdoule is "OutOfDate" when really it is the importer that is out of date. I didn't see any regressions in module load time after this change. llvm-svn: 220493
2014-10-22[modules] Initial support for explicitly loading .pcm files.Richard Smith1-1/+1
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-08-26Return a std::unique_ptr from getBufferForFile. NFC.Rafael Espindola1-3/+3
llvm-svn: 216476
2014-08-18Store std::unique_ptr in InMemoryBuffers. NFC.Rafael Espindola1-11/+12
llvm-svn: 215928
2014-08-17Repace SmallPtrSet with SmallPtrSetImpl in function arguments to avoid ↵Craig Topper1-1/+1
needing to mention the size. llvm-svn: 215869
2014-07-06Update for llvm api change.Rafael Espindola1-1/+5
llvm-svn: 212408
2014-06-20Avoid invalidating successfully loaded module filesBen Langmuir1-22/+17
Successfully loaded module files may be referenced in other ModuleManagers, so don't invalidate them. Two related things are fixed: 1) I thought the last module in the manager was always the one that failed, but it isn't. So check explicitly against the list of vetted modules from ReadASTCore. 2) We now keep the file descriptor of pcm file open, which avoids the possibility of having two different pcms for the same module loaded when building in parallel with headers being modified during a build. <rdar://problem/16835846> llvm-svn: 211330
2014-06-12Include system_error directly.Rafael Espindola1-1/+1
llvm-svn: 210802
2014-06-12Replace llvm::error_code with std::error_code.Rafael Espindola1-1/+1
llvm-svn: 210780
2014-05-30Invalidate the file system cache entries for files that may rebuildBen Langmuir1-5/+21
This reapplies r209910 with a fix for the assertion failures hit on the buildbots. original commit message: I thought we could get away without this, but it means that the FileEntry objects actually refer to the wrong files, since pcms are not updated inplace, they are atomically renamed into place after compiling a module. So we are close to the original behaviour of invalidating the cache for all modules being removed, but now we should only invalidate the ones that depend on whichever module failed to load. Unfortunately I haven't come up with a new test that didn't require a race between parallel invocations of clang. <rdar://problem/17038180> llvm-svn: 209922
2014-05-30Revert "Invalidate the file system cache entries for files that may rebuild"Ben Langmuir1-18/+5
This reverts commit r209910, which is breaking some of the bots. llvm-svn: 209911
2014-05-30Invalidate the file system cache entries for files that may rebuildBen Langmuir1-5/+18
I thought we could get away without this, but it means that the FileEntry objects actually refer to the wrong files, since pcms are not updated inplace, they are atomically renamed into place after compiling a module. So we are close to the original behaviour of invalidating the cache for all modules being removed, but now we should only invalidate the ones that depend on whichever module failed to load. Unfortunately I haven't come up with a new test that didn't require a race between parallel invocations of clang. <rdar://problem/17038180> llvm-svn: 209910
2014-05-22[C++11] Use 'nullptr'. Serialization edition.Craig Topper1-8/+8
llvm-svn: 209392
2014-05-20Speculative fix for Windows buildbot after r209138Ben Langmuir1-0/+5
It appears that Windows doesn't like renaming over open files, which we do in clearOutputFiles. The file being compiled should be safe to removed, but this isn't very satisfying - we don't want to manually manage the lifetime of files we cannot prove have no references. llvm-svn: 209195
2014-05-19Don't refresh stat() info for pcm filesBen Langmuir1-13/+1
Follow-up fix for 209138. Actually, since we already have this file open, we don't want to refresh the stat() info, since that might be newer than what we have open (bad!). llvm-svn: 209143
2014-05-19Fix use-after-free and spurious error during module loadBen Langmuir1-2/+13
FileManager::invalidateCache is not safe to call when there may be existing references to the file. What module load failure needs is to refresh so stale stat() info isn't stored. This may be the last user of invalidateCache; I'll take a look and remove it if possible in a future commit. This caused a use-after-free error as well as a spurious error message that a module was "found in both 'X.pcm' and 'X.pcm'" in some cases. llvm-svn: 209138
2014-05-04Fix a use-after-free bug I recently introduced in lookupModuleFileBen Langmuir1-4/+3
llvm-svn: 207932
2014-05-01Avoid a potential race between stat() and open() of ASTFileBen Langmuir1-1/+5
We need to open an ASTFile while checking its expected size and modification time, or another clang instance can modify the file between the stat() and the open(). llvm-svn: 207735
2014-04-14Allow multiple modules with the same name to coexist in the module cacheBen Langmuir1-2/+3
To differentiate between two modules with the same name, we will consider the path the module map file that they are defined by* part of the ‘key’ for looking up the precompiled module (pcm file). Specifically, this patch renames the precompiled module (pcm) files from cache-path/<module hash>/Foo.pcm to cache-path/<module hash>/Foo-<hash of module map path>.pcm In addition, I’ve taught the ASTReader to re-resolve the names of imported modules during module loading so that if the header search context changes between when a module was originally built and when it is loaded we can rebuild it if necessary. For example, if module A imports module B first time: clang -I /path/to/A -I /path/to/B ... second time: clang -I /path/to/A -I /different/path/to/B ... will now rebuild A as expected. * in the case of inferred modules, we use the module map file that allowed the inference, not the __inferred_module.map file, since the inferred file path is the same for every inferred module. llvm-svn: 206201
2014-03-03[C++11] Remove a now unnecessary use of std::function for a remove_ifChandler Carruth1-4/+3
predicate. The wrapper used by SetVector was erroneously requiring an adaptable predicate. It has been fixed and we really don't want to require an indirect call for every predicate evaluation. llvm-svn: 202744
2014-03-01[C++11] Replace verbose functors with succinct lambdasBenjamin Kramer1-17/+3
No functionality change. llvm-svn: 202590
2014-02-20Recommit virtual file systemBen Langmuir1-1/+1
Previously reverted in r201755 due to causing an assertion failure. I've removed the offending assertion, and taught the CompilerInstance to create a default virtual file system inside createFileManager. In the future, we should be able to reach into the CompilerInvocation to customize this behaviour without breaking clients that don't care. llvm-svn: 201818
2014-02-20Reverting the virtual file system implementation, because it triggers an ↵Juergen Ributzka1-1/+1
assertion in our internal build bots. This reverts commits 201618, 201635, 201636, 201639, 201685, 201691, and 201696. llvm-svn: 201755
2014-02-19Initial implementation of virtual file systemBen Langmuir1-1/+1
This adds the minimum virtual file system support to start migrating FileManager onto the VFS. Originally discussed here: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-February/035188.html Differential Revision: http://llvm-reviews.chandlerc.com/D2745 llvm-svn: 201618
2014-02-12Add an option to allow Clang verify source files for a module only once duringDmitri Gribenko1-0/+10
the build When Clang loads the module, it verifies the user source files that the module was built from. If any file was changed, the module is rebuilt. There are two problems with this: 1. correctness: we don't verify system files (there are too many of them, and stat'ing all of them would take a lot of time); 2. performance: the same module file is verified again and again during a single build. This change allows the build system to optimize source file verification. The idea is based on the fact that while the project is being built, the source files don't change. This allows us to verify the module only once during a single build session. The build system passes a flag, -fbuild-session-timestamp=, to inform Clang of the time when the build started. The build system also requests to enable this feature by passing -fmodules-validate-once-per-build-session. If these flags are not passed, the behavior is not changed. When Clang verifies the module the first time, it writes out a timestamp file. Then, when Clang loads the module the second time, it finds a timestamp file, so it can compare the verification timestamp of the module with the time when the build started. If the verification timestamp is too old, the module is verified again, and the timestamp file is updated. llvm-svn: 201224
2013-09-05Add a bit more info to modules fatal error.Eli Friedman1-2/+4
Just a minor tweak to make it easier to track down the cause of fatal errors with modules. llvm-svn: 190108
2013-08-24This wasn't headers, just missing namespaces.Benjamin Kramer1-1/+0
/me bows head in shame. llvm-svn: 189172
2013-08-24Add missing includes.Benjamin Kramer1-1/+2
llvm-svn: 189171
2013-08-23Use pop_back_val() instead of both back() and pop_back().Robert Wilhelm1-2/+1
No functionality change intended. llvm-svn: 189112
2013-06-11Include Path.h instead of PathV2.h.Rafael Espindola1-1/+1
I am about to move PathV2.h to Path.h. llvm-svn: 183795
2013-03-27<rdar://problem/13509689> Introduce -module-file-info option that provides ↵Douglas Gregor1-1/+13
information about a particular module file. This option can be useful for end users who want to know why they ended up with a ton of different variants of the "std" module in their module cache. This problem should go away over time, as we reduce the need for module variants, but it will never go away entirely. llvm-svn: 178148
2013-03-22<rdar://problem/13479539> Simplify ModuleManager/GlobalModuleIndex ↵Douglas Gregor1-47/+18
interaction to eliminate a pile of extraneous stats(). The refactoring in r177367 introduced a serious performance bug where the "lazy" resolution of module file names in the global module index to actual module file entries in the module manager would perform repeated negative stats(). The new interaction requires the module manager to inform the global module index when a module file has been loaded, eliminating the extraneous stat()s and a bunch of bookkeeping on both sides. llvm-svn: 177750
2013-03-21Remove unused variable.Benjamin Kramer1-3/+0
llvm-svn: 177657