Fixes https://github.com/llvm/llvm-project/issues/62635
Differential Revision: https://reviews.llvm.org/D152801
// 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;
}
}
}
+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