[clang] [include-cleaner] Support multi-header symbols in mapping generator (PR #147720)
kadir çetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 18 03:47:27 PDT 2025
================
@@ -2525,6 +3589,10 @@ SYMBOL(remainderf, None, <math.h>)
SYMBOL(remainderl, std::, <cmath>)
SYMBOL(remainderl, None, <cmath>)
SYMBOL(remainderl, None, <math.h>)
+SYMBOL(remove, std::, <cstdio>)
+SYMBOL(remove, std::, <algorithm>)
----------------
kadircet wrote:
so we mainly had two reasons for multiple headers per symbol:
- Alternative headers that provide it (like `std::rend`), making sure we have the most common header as the first header is a good enough solution (which you already handle with this patch).
- Completely unrelated symbols, that happened to have the same name (like `std::remove` here). Unfortunately these are ambiguous and picking any would be wrong (e.g. we'll keep inserting cstdio when a user is actually modifying a container with std::remove rather than deleting files).
I think these two cases can be distinguished by checking whether we acquired all the headers from the same symbol page or a different one. We should still make sure we're dropping all the symbol names that showed up in multiple pages and only preserve symbols that showed up once.
WDYT?
https://github.com/llvm/llvm-project/pull/147720
More information about the cfe-commits
mailing list