aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2023-07-20 23:11:56 +0200
committerSam McCall <sam.mccall@gmail.com>2023-07-26 13:41:55 +0200
commitf6307b260b0c0d93d25d13bab7ec02d762f4a2a6 (patch)
tree1b01c386614ec8ea7447fe786c4c77897e22b83f /clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
parentae4849f96706cde460e6c792a6c8110791a6db32 (diff)
downloadllvm-f6307b260b0c0d93d25d13bab7ec02d762f4a2a6.zip
llvm-f6307b260b0c0d93d25d13bab7ec02d762f4a2a6.tar.gz
llvm-f6307b260b0c0d93d25d13bab7ec02d762f4a2a6.tar.bz2
[include-cleaner] Switch Include from FileEntry* -> FileEntryRef
Unlike Header, we really do have a preferred spelling for an include: the one that we used to open the file. The fact that Header is still FileEntry* makes it difficult to accidentally use path equality when we want inode equality. Differential Revision: https://reviews.llvm.org/D155885
Diffstat (limited to 'clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
index 064eccd..f6292d7 100644
--- a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
@@ -147,7 +147,7 @@ void IncludeCleanerCheck::check(const MatchFinder::MatchResult &Result) {
continue;
// Check if main file is the public interface for a private header. If so
// we shouldn't diagnose it as unused.
- if (auto PHeader = RecordedPI.getPublic(I.Resolved); !PHeader.empty()) {
+ if (auto PHeader = RecordedPI.getPublic(*I.Resolved); !PHeader.empty()) {
PHeader = PHeader.trim("<>\"");
// Since most private -> public mappings happen in a verbatim way, we
// check textually here. This might go wrong in presence of symlinks or
@@ -156,9 +156,10 @@ void IncludeCleanerCheck::check(const MatchFinder::MatchResult &Result) {
continue;
}
- if (llvm::none_of(IgnoreHeadersRegex,
- [Resolved = I.Resolved->tryGetRealPathName()](
- const llvm::Regex &R) { return R.match(Resolved); }))
+ if (llvm::none_of(
+ IgnoreHeadersRegex,
+ [Resolved = (*I.Resolved).getFileEntry().tryGetRealPathName()](
+ const llvm::Regex &R) { return R.match(Resolved); }))
Unused.push_back(&I);
}