diff options
author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2018-07-19 12:32:06 +0000 |
---|---|---|
committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2018-07-19 12:32:06 +0000 |
commit | 7315d2d721508cc684371dc5495fb6007076b479 (patch) | |
tree | 844c2a0f817eee403b5e26f04c915a83f9ae6dbc /clang/lib/Frontend/FrontendAction.cpp | |
parent | 4b0028a3d16d83e24ae963fc417eea5cb6d99329 (diff) | |
download | bcm5719-llvm-7315d2d721508cc684371dc5495fb6007076b479.tar.gz bcm5719-llvm-7315d2d721508cc684371dc5495fb6007076b479.zip |
[PCH+Modules] Load -fmodule-map-file content before including PCHs
Consider:
1) Generate PCH with -fmodules and -fmodule-map-file
2) Use PCH with -fmodules and the same -fmodule-map-file
If we don't load -fmodule-map-file content before including PCHs,
the modules that are dependencies in PCHs cannot get loaded,
since there's no matching module map file when reading back the AST.
rdar://problem/40852867
Differential Revision: https://reviews.llvm.org/D48685
llvm-svn: 337447
Diffstat (limited to 'clang/lib/Frontend/FrontendAction.cpp')
-rw-r--r-- | clang/lib/Frontend/FrontendAction.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index 7711d8460c5..a5929424e52 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -766,6 +766,22 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, if (!BeginSourceFileAction(CI)) goto failure; + // If we were asked to load any module map files, do so now. + for (const auto &Filename : CI.getFrontendOpts().ModuleMapFiles) { + if (auto *File = CI.getFileManager().getFile(Filename)) + CI.getPreprocessor().getHeaderSearchInfo().loadModuleMapFile( + File, /*IsSystem*/false); + else + CI.getDiagnostics().Report(diag::err_module_map_not_found) << Filename; + } + + // Add a module declaration scope so that modules from -fmodule-map-file + // arguments may shadow modules found implicitly in search paths. + CI.getPreprocessor() + .getHeaderSearchInfo() + .getModuleMap() + .finishModuleDeclarationScope(); + // Create the AST context and consumer unless this is a preprocessor only // action. if (!usesPreprocessorOnly()) { @@ -855,22 +871,6 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, "doesn't support modules"); } - // If we were asked to load any module map files, do so now. - for (const auto &Filename : CI.getFrontendOpts().ModuleMapFiles) { - if (auto *File = CI.getFileManager().getFile(Filename)) - CI.getPreprocessor().getHeaderSearchInfo().loadModuleMapFile( - File, /*IsSystem*/false); - else - CI.getDiagnostics().Report(diag::err_module_map_not_found) << Filename; - } - - // Add a module declaration scope so that modules from -fmodule-map-file - // arguments may shadow modules found implicitly in search paths. - CI.getPreprocessor() - .getHeaderSearchInfo() - .getModuleMap() - .finishModuleDeclarationScope(); - // If we were asked to load any module files, do so now. for (const auto &ModuleFile : CI.getFrontendOpts().ModuleFiles) if (!CI.loadModuleFile(ModuleFile)) |