aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInstance.cpp
diff options
context:
space:
mode:
authorBen Langmuir <blangmuir@apple.com>2022-08-02 13:26:01 -0700
committerBen Langmuir <blangmuir@apple.com>2022-08-05 12:24:40 -0700
commitfb89cc0ddbd9a588ee15148451e7d0bcbc1ef411 (patch)
tree301b732650bd4861f3284b37bc0efb67c53ce805 /clang/lib/Frontend/CompilerInstance.cpp
parentd038bb196c51dcf80cbe771f4229b4e227c6c5b6 (diff)
downloadllvm-fb89cc0ddbd9a588ee15148451e7d0bcbc1ef411.zip
llvm-fb89cc0ddbd9a588ee15148451e7d0bcbc1ef411.tar.gz
llvm-fb89cc0ddbd9a588ee15148451e7d0bcbc1ef411.tar.bz2
[clang][modules] Don't depend on sharing FileManager during module build
Sharing the FileManager between the importer and the module build should only be an optimization. Add a cc1 option -fno-modules-share-filemanager to allow us to test this. Fix the path to modulemap files, which previously depended on the shared FileManager when using path mapped to an external file in a VFS. Differential Revision: https://reviews.llvm.org/D131076
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 2cd7efd..51c7bc2 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -1213,11 +1213,16 @@ compileModuleImpl(CompilerInstance &ImportingInstance, SourceLocation ImportLoc,
ImportingInstance.getDiagnosticClient()),
/*ShouldOwnClient=*/true);
- // Note that this module is part of the module build stack, so that we
- // can detect cycles in the module graph.
- Instance.setFileManager(&ImportingInstance.getFileManager());
+ if (FrontendOpts.ModulesShareFileManager) {
+ Instance.setFileManager(&ImportingInstance.getFileManager());
+ } else {
+ Instance.createFileManager(&ImportingInstance.getVirtualFileSystem());
+ }
Instance.createSourceManager(Instance.getFileManager());
SourceManager &SourceMgr = Instance.getSourceManager();
+
+ // Note that this module is part of the module build stack, so that we
+ // can detect cycles in the module graph.
SourceMgr.setModuleBuildStack(
ImportingInstance.getSourceManager().getModuleBuildStack());
SourceMgr.pushModuleBuildStack(ModuleName,
@@ -1303,12 +1308,16 @@ static bool compileModule(CompilerInstance &ImportingInstance,
ModuleMapFile, ImportingInstance.getFileManager()))
ModuleMapFile = PublicMMFile;
+ // FIXME: Update header search to keep FileEntryRef rather than rely on
+ // getLastRef().
+ StringRef ModuleMapFilePath =
+ ModuleMapFile->getLastRef().getNameAsRequested();
+
// Use the module map where this module resides.
Result = compileModuleImpl(
ImportingInstance, ImportLoc, Module->getTopLevelModuleName(),
- FrontendInputFile(ModuleMapFile->getName(), IK, +Module->IsSystem),
- ModMap.getModuleMapFileForUniquing(Module)->getName(),
- ModuleFileName);
+ FrontendInputFile(ModuleMapFilePath, IK, +Module->IsSystem),
+ ModMap.getModuleMapFileForUniquing(Module)->getName(), ModuleFileName);
} else {
// FIXME: We only need to fake up an input file here as a way of
// transporting the module's directory to the module map parser. We should