diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2022-10-11 15:38:48 -0700 |
---|---|---|
committer | Jan Svoboda <jan_svoboda@apple.com> | 2022-10-11 15:57:20 -0700 |
commit | c1c72302fe4553a39be37b5c310d046975e55019 (patch) | |
tree | ea7ee869862402674d6765163e31d8be5c7ba911 /clang/lib/Frontend/FrontendAction.cpp | |
parent | 060b25346b95cc161d21418f31c333f9a115d77e (diff) | |
download | llvm-c1c72302fe4553a39be37b5c310d046975e55019.zip llvm-c1c72302fe4553a39be37b5c310d046975e55019.tar.gz llvm-c1c72302fe4553a39be37b5c310d046975e55019.tar.bz2 |
[clang][deps] Prevent emitting diagnostics outside of source file
The dependency scanner needs to report the module map file describing the module whose implementation is being compiled (see D134222). However, calling `Preprocessor::getCurrentModuleImplementation()` in the scanner might cause a diagnostic during module map parsing and emitting a diagnostic without being "in" a source file is illegal (e.g. in `TextDiagnosticPrinter`). This patch ensures the module map parse is triggered while the compiler is still "in" a source file, avoiding the failure case.
Reviewed By: Bigcheese
Differential Revision: https://reviews.llvm.org/D135637
Diffstat (limited to 'clang/lib/Frontend/FrontendAction.cpp')
-rw-r--r-- | clang/lib/Frontend/FrontendAction.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index b541c59..45f04ea 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -914,6 +914,9 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, CI.getDiagnostics().Report(diag::err_module_map_not_found) << Filename; } + // If compiling implementation of a module, load its module map file now. + (void)CI.getPreprocessor().getCurrentModuleImplementation(); + // Add a module declaration scope so that modules from -fmodule-map-file // arguments may shadow modules found implicitly in search paths. CI.getPreprocessor() |