diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-12-06 03:21:08 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-12-06 03:21:08 +0000 |
| commit | 223d3f2e4d49c52b0b5516f001d1827c6e55d44b (patch) | |
| tree | 6dd167c06ef5d45dfde2115046f74e9f3c353d5b /clang/lib | |
| parent | e7633631e1f10de34484d65a009256217bbb5cc8 (diff) | |
| download | bcm5719-llvm-223d3f2e4d49c52b0b5516f001d1827c6e55d44b.tar.gz bcm5719-llvm-223d3f2e4d49c52b0b5516f001d1827c6e55d44b.zip | |
[modules] If we import a module, and we've seen a module map that describes the
module, use the path from the module map file in preference to the path from
the .pcm file when resolving relative paths in the .pcm file. This allows
diagnostics (and .d output) to give relative paths if the module was found via
a relative path.
llvm-svn: 223577
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index e1c418b30c8..eea4ba84b0c 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -2508,9 +2508,31 @@ ASTReader::ReadControlBlock(ModuleFile &F, Listener->ReadModuleName(F.ModuleName); break; - case MODULE_DIRECTORY: - F.BaseDirectory = Blob; + case MODULE_DIRECTORY: { + assert(!F.ModuleName.empty() && + "MODULE_DIRECTORY found before MODULE_NAME"); + // If we've already loaded a module map file covering this module, we may + // have a better path for it (relative to the current build). + Module *M = PP.getHeaderSearchInfo().lookupModule(F.ModuleName); + if (M && M->Directory) { + // If we're implicitly loading a module, the base directory can't + // change between the build and use. + if (F.Kind != MK_ExplicitModule) { + const DirectoryEntry *BuildDir = + PP.getFileManager().getDirectory(Blob); + if (!BuildDir || BuildDir != M->Directory) { + if ((ClientLoadCapabilities & ARR_OutOfDate) == 0) + Diag(diag::err_imported_module_relocated) + << F.ModuleName << Blob << M->Directory->getName(); + return OutOfDate; + } + } + F.BaseDirectory = M->Directory->getName(); + } else { + F.BaseDirectory = Blob; + } break; + } case MODULE_MAP_FILE: if (ASTReadResult Result = |

