aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.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-tools-extra/clang-tidy/llvm/IncludeOrderCheck.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-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp b/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
index bdd72f8..4246c8c5 100644
--- a/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
@@ -27,7 +27,8 @@ public:
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;
void EndOfMainFile() override;
@@ -81,8 +82,8 @@ static int getPriority(StringRef Filename, bool IsAngled, bool IsMainModule) {
void IncludeOrderPPCallbacks::InclusionDirective(
SourceLocation HashLoc, const Token &IncludeTok, StringRef FileName,
bool IsAngled, CharSourceRange FilenameRange, OptionalFileEntryRef File,
- StringRef SearchPath, StringRef RelativePath, const Module *Imported,
- SrcMgr::CharacteristicKind FileType) {
+ StringRef SearchPath, StringRef RelativePath, const Module *SuggestedModule,
+ bool ModuleImported, SrcMgr::CharacteristicKind FileType) {
// We recognize the first include as a special main module header and want
// to leave it in the top position.
IncludeDirective ID = {HashLoc, FilenameRange, std::string(FileName),