[clang][deps] Prevent emitting diagnostics outside of source file
authorJan Svoboda <jan_svoboda@apple.com>
Tue, 11 Oct 2022 22:38:48 +0000 (15:38 -0700)
committerJan Svoboda <jan_svoboda@apple.com>
Tue, 11 Oct 2022 22:57:20 +0000 (15:57 -0700)
commitc1c72302fe4553a39be37b5c310d046975e55019
treeea7ee869862402674d6765163e31d8be5c7ba911
parent060b25346b95cc161d21418f31c333f9a115d77e
[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
clang/lib/Frontend/FrontendAction.cpp
clang/test/ClangScanDeps/modules-implementation-module-map.c [new file with mode: 0644]