aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/ModuleDependencyCollector.cpp
diff options
context:
space:
mode:
authorJan Svoboda <jan_svoboda@apple.com>2024-02-08 19:19:18 +0100
committerGitHub <noreply@github.com>2024-02-08 10:19:18 -0800
commitda95d926f6fce4ed9707c77908ad96624268f134 (patch)
tree53a2e62923f0d999ed7017a76f56b3f89e445f87 /clang/lib/Frontend/ModuleDependencyCollector.cpp
parent35fae044c5faf8ddb9be7b47bb7573e839f77472 (diff)
downloadllvm-da95d926f6fce4ed9707c77908ad96624268f134.zip
llvm-da95d926f6fce4ed9707c77908ad96624268f134.tar.gz
llvm-da95d926f6fce4ed9707c77908ad96624268f134.tar.bz2
[clang][lex] Always pass suggested module to `InclusionDirective()` callback (#81061)
This patch provides more information to the `PPCallbacks::InclusionDirective()` hook. We now always pass the suggested module, regardless of whether it was actually imported or not. The extra `bool ModuleImported` parameter then denotes whether the header `#include` will be automatically translated into import the the module. The main change is in `clang/lib/Lex/PPDirectives.cpp`, where we take care to not modify `SuggestedModule` after it's been populated by `LookupHeaderIncludeOrImport()`. We now exclusively use the `SM` (`ModuleToImport`) variable instead, which has been equivalent to `SuggestedModule` until now. This allows us to use the original non-modified `SuggestedModule` for the callback itself. (This patch turns out to be necessary for https://github.com/apple/llvm-project/pull/8011).
Diffstat (limited to 'clang/lib/Frontend/ModuleDependencyCollector.cpp')
-rw-r--r--clang/lib/Frontend/ModuleDependencyCollector.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Frontend/ModuleDependencyCollector.cpp b/clang/lib/Frontend/ModuleDependencyCollector.cpp
index 939e611..b88cb60 100644
--- a/clang/lib/Frontend/ModuleDependencyCollector.cpp
+++ b/clang/lib/Frontend/ModuleDependencyCollector.cpp
@@ -55,7 +55,8 @@ struct ModuleDependencyPPCallbacks : public PPCallbacks {
StringRef FileName, bool IsAngled,
CharSourceRange FilenameRange,
OptionalFileEntryRef File, StringRef SearchPath,
- StringRef RelativePath, const Module *Imported,
+ StringRef RelativePath, const Module *SuggestedModule,
+ bool ModuleImported,
SrcMgr::CharacteristicKind FileType) override {
if (!File)
return;