[PATCH] D152801: [include-cleaner] Don't apply PreferredHeader hings for standard headers.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 13 10:00:11 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG48967c6e5504: [include-cleaner] Don't apply the PreferredHeader hint for standard headers. (authored by hokein).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152801/new/
https://reviews.llvm.org/D152801
Files:
clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
Index: clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
===================================================================
--- clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
@@ -486,5 +486,16 @@
}
}
+TEST_F(HeadersForSymbolTest, StandardHeaders) {
+ Inputs.Code = "void assert();";
+ buildAST();
+ EXPECT_THAT(
+ headersFor("assert"),
+ // Respect the ordering from the stdlib mapping.
+ UnorderedElementsAre(tooling::stdlib::Header::named("<cassert>"),
+ tooling::stdlib::Header::named("<assert.h>")));
+}
+
+
} // namespace
} // namespace clang::include_cleaner
Index: clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
===================================================================
--- clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
+++ clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
@@ -248,6 +248,10 @@
// Add name match hints to deduplicated providers.
llvm::StringRef SymbolName = symbolName(S);
for (auto &H : Headers) {
+ // Don't apply name match hints to standard headers as the standard headers
+ // are already ranked in the stdlib mapping.
+ if (H.kind() == Header::Standard)
+ continue;
if (nameMatch(SymbolName, H))
H.Hint |= Hints::PreferredHeader;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152801.530956.patch
Type: text/x-patch
Size: 1381 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230613/d9a329f6/attachment.bin>
More information about the cfe-commits
mailing list