aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Serialization/ModuleManager.cpp
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-08-30 08:45:59 +0000
committerBoris Kolpackov <boris@codesynthesis.com>2017-08-30 08:45:59 +0000
commit7a71b4b6584fd70f43b88049174f8894cab3a4d2 (patch)
treef5b82d4b250eaeb6ee5d3838d470f1bf8a707271 /clang/lib/Serialization/ModuleManager.cpp
parentbe5b60f735587104d1fe580bcabd1e011ac0c566 (diff)
downloadllvm-7a71b4b6584fd70f43b88049174f8894cab3a4d2.zip
llvm-7a71b4b6584fd70f43b88049174f8894cab3a4d2.tar.gz
llvm-7a71b4b6584fd70f43b88049174f8894cab3a4d2.tar.bz2
[modules] Add ability to specify module name to module file mapping
Extend the -fmodule-file option to support the [<name>=]<file> value format. If the name is omitted, then the old semantics is preserved (the module file is loaded whether needed or not). If the name is specified, then the mapping is treated as just another prebuilt module search mechanism, similar to -fprebuilt-module-path, and the module file is only loaded if actually used (e.g., via import). With one exception: this mapping also overrides module file references embedded in other modules (which can be useful if module files are moved/renamed as often happens during remote compilation). This override semantics requires some extra work: we now store the module name in addition to the file name in the serialized AST representation. Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D35020 llvm-svn: 312105
Diffstat (limited to 'clang/lib/Serialization/ModuleManager.cpp')
-rw-r--r--clang/lib/Serialization/ModuleManager.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/clang/lib/Serialization/ModuleManager.cpp b/clang/lib/Serialization/ModuleManager.cpp
index 1dee4d0..7563440 100644
--- a/clang/lib/Serialization/ModuleManager.cpp
+++ b/clang/lib/Serialization/ModuleManager.cpp
@@ -28,7 +28,7 @@
using namespace clang;
using namespace serialization;
-ModuleFile *ModuleManager::lookup(StringRef Name) const {
+ModuleFile *ModuleManager::lookupByFileName(StringRef Name) const {
const FileEntry *Entry = FileMgr.getFile(Name, /*openFile=*/false,
/*cacheFailure=*/false);
if (Entry)
@@ -37,6 +37,14 @@ ModuleFile *ModuleManager::lookup(StringRef Name) const {
return nullptr;
}
+ModuleFile *ModuleManager::lookupByModuleName(StringRef Name) const {
+ if (const Module *Mod = HeaderSearchInfo.getModuleMap().findModule(Name))
+ if (const FileEntry *File = Mod->getASTFile())
+ return lookup(File);
+
+ return nullptr;
+}
+
ModuleFile *ModuleManager::lookup(const FileEntry *File) const {
auto Known = Modules.find(File);
if (Known == Modules.end())
@@ -306,9 +314,11 @@ void ModuleManager::moduleFileAccepted(ModuleFile *MF) {
}
ModuleManager::ModuleManager(FileManager &FileMgr, MemoryBufferCache &PCMCache,
- const PCHContainerReader &PCHContainerRdr)
+ const PCHContainerReader &PCHContainerRdr,
+ const HeaderSearch& HeaderSearchInfo)
: FileMgr(FileMgr), PCMCache(&PCMCache), PCHContainerRdr(PCHContainerRdr),
- GlobalIndex(), FirstVisitState(nullptr) {}
+ HeaderSearchInfo (HeaderSearchInfo), GlobalIndex(),
+ FirstVisitState(nullptr) {}
ModuleManager::~ModuleManager() { delete FirstVisitState; }