[clang-tools-extra] [clang-tidy][include-cleaner] Fix false positive for stdlib-like macros (PR #173149)

kadir çetinkaya via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 19 00:11:59 PST 2026


================
@@ -56,10 +56,11 @@ std::vector<Hinted<SymbolLocation>> locateDecl(const Decl &D) {
 
 std::vector<Hinted<SymbolLocation>> locateMacro(const Macro &M,
                                                 const tooling::stdlib::Lang L) {
-  // FIXME: Should we also provide physical locations?
+  std::vector<Hinted<SymbolLocation>> Result;
+  Result.push_back({M.Definition, Hints::CompleteSymbol});
----------------
kadircet wrote:

we also need to take care of "logical" duplicates now (see the comments in clang-tools-extra/include-cleaner/lib/FindHeaders.cpp near `headersForSymbol`), when the physical provider and stdlib provider are two independent headers we don't really have an issue, but that's actually the rare case. in the common case, we'll both recognize a symbol through stdlib mappings (e.g. `assert` and `<assert>`) and through a physical definition (`assert` and `/usr/include/something/assert`). despite of these being "same" headers, we'll treat them separately and might assign different ranking symbols, yielding hard-to-debug failures/confusion down the line.

I don't have good ideas around how to do this at the top of my head, but I am happy to iterate if you have some proposals.

https://github.com/llvm/llvm-project/pull/173149


More information about the cfe-commits mailing list