diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-05-31 20:56:55 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-05-31 20:56:55 +0000 |
commit | 8b7061049403323a2872e031cbb7222b2a85ff97 (patch) | |
tree | ea7678a7e8a5b7a4169fcf5ea91c36687f122fe4 /clang/lib/Frontend/FrontendAction.cpp | |
parent | 8ea89eaf7d1c0636059228c82c8628348770c835 (diff) | |
download | bcm5719-llvm-8b7061049403323a2872e031cbb7222b2a85ff97.tar.gz bcm5719-llvm-8b7061049403323a2872e031cbb7222b2a85ff97.zip |
[modules] When compiling a preprocessed module map, look for headers relative
to the original module map.
Also use the path and name of the original module map when emitting that
information into the .pcm file. The upshot of this is that the produced .pcm
file will track information for headers in their original locations (where the
module was preprocessed), not relative to whatever directory the preprocessed
module map was in when it was built.
llvm-svn: 304346
Diffstat (limited to 'clang/lib/Frontend/FrontendAction.cpp')
-rw-r--r-- | clang/lib/Frontend/FrontendAction.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index 874c1b6be41..cd67e469dda 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -373,10 +373,11 @@ collectModuleHeaderIncludes(const LangOptions &LangOpts, FileManager &FileMgr, return std::error_code(); } -static bool -loadModuleMapForModuleBuild(CompilerInstance &CI, StringRef Filename, - bool IsSystem, bool IsPreprocessed, - unsigned &Offset) { +static bool loadModuleMapForModuleBuild(CompilerInstance &CI, + StringRef Filename, bool IsSystem, + bool IsPreprocessed, + std::string &PresumedModuleMapFile, + unsigned &Offset) { auto &SrcMgr = CI.getSourceManager(); HeaderSearch &HS = CI.getPreprocessor().getHeaderSearchInfo(); @@ -388,16 +389,15 @@ loadModuleMapForModuleBuild(CompilerInstance &CI, StringRef Filename, // line directives are not part of the module map syntax in general. Offset = 0; if (IsPreprocessed) { - std::string PresumedModuleMapFile; SourceLocation EndOfLineMarker = ReadOriginalFileName(CI, PresumedModuleMapFile, /*AddLineNote*/true); if (EndOfLineMarker.isValid()) Offset = CI.getSourceManager().getDecomposedLoc(EndOfLineMarker).second; - // FIXME: Use PresumedModuleMapFile as the MODULE_MAP_FILE in the PCM. } // Load the module map file. - if (HS.loadModuleMapFile(ModuleMap, IsSystem, ModuleMapID, &Offset)) + if (HS.loadModuleMapFile(ModuleMap, IsSystem, ModuleMapID, &Offset, + PresumedModuleMapFile)) return true; if (SrcMgr.getBuffer(ModuleMapID)->getBufferSize() == Offset) @@ -664,15 +664,19 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, if (Input.getKind().getFormat() == InputKind::ModuleMap) { CI.getLangOpts().setCompilingModule(LangOptions::CMK_ModuleMap); + std::string PresumedModuleMapFile; unsigned OffsetToContents; if (loadModuleMapForModuleBuild(CI, Input.getFile(), Input.isSystem(), - Input.isPreprocessed(), OffsetToContents)) + Input.isPreprocessed(), + PresumedModuleMapFile, OffsetToContents)) goto failure; auto *CurrentModule = prepareToBuildModule(CI, Input.getFile()); if (!CurrentModule) goto failure; + CurrentModule->PresumedModuleMapFile = PresumedModuleMapFile; + if (OffsetToContents) // If the module contents are in the same file, skip to them. CI.getPreprocessor().setSkipMainFilePreamble(OffsetToContents, true); |