diff options
author | Ben Langmuir <blangmuir@apple.com> | 2014-04-14 18:00:01 +0000 |
---|---|---|
committer | Ben Langmuir <blangmuir@apple.com> | 2014-04-14 18:00:01 +0000 |
commit | beee15e721f6b192db90e068be40dfb24df98713 (patch) | |
tree | f52690678905dec887909f618b04b8604c3a1278 /clang/lib/Frontend/FrontendAction.cpp | |
parent | 8f80ccc6353f929c9861586b27f165b7ac66273b (diff) | |
download | llvm-beee15e721f6b192db90e068be40dfb24df98713.zip llvm-beee15e721f6b192db90e068be40dfb24df98713.tar.gz llvm-beee15e721f6b192db90e068be40dfb24df98713.tar.bz2 |
Allow multiple modules with the same name to coexist in the module cache
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
Diffstat (limited to 'clang/lib/Frontend/FrontendAction.cpp')
-rw-r--r-- | clang/lib/Frontend/FrontendAction.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index d2ece7e..dc4dd89 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -256,6 +256,10 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, if (!BeginSourceFileAction(CI, InputFile)) goto failure; + // Initialize the main file entry. + if (!CI.InitializeSourceManager(CurrentInput)) + goto failure; + return true; } @@ -302,6 +306,11 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, if (!BeginSourceFileAction(CI, InputFile)) goto failure; + // Initialize the main file entry. It is important that this occurs after + // BeginSourceFileAction, which may change CurrentInput during module builds. + if (!CI.InitializeSourceManager(CurrentInput)) + goto failure; + // Create the AST context and consumer unless this is a preprocessor only // action. if (!usesPreprocessorOnly()) { @@ -389,13 +398,6 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, bool FrontendAction::Execute() { CompilerInstance &CI = getCompilerInstance(); - // Initialize the main file entry. This needs to be delayed until after PCH - // has loaded. - if (!isCurrentFileAST()) { - if (!CI.InitializeSourceManager(getCurrentInput())) - return false; - } - if (CI.hasFrontendTimer()) { llvm::TimeRegion Timer(CI.getFrontendTimer()); ExecuteAction(); |