std::remove from algorithm is a lot more common than the overload from
the cstdio (which deletes files). This patch introduces a set of symbols
for which we should prefer the overloaded versions.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/clangd/StdSymbolMap.inc | ||
---|---|---|
958 | Is the stdio version so uncommon we are willing to be wrong about it? For move we omit it from here and consider it case-by-case, I'd have imagined doing the same here (BTW at some point we may want to extend this to list alternative headers for ambiguous symbols) | |
clang-tools-extra/clangd/include-mapping/cppreference_parser.py | ||
140–142 | This logic seems a bit weird and non-general: it allows us to accept any variant and reject any non-variant, but it doesn't allow us to accept a*specific* variant (they are named) and doesn't allow us to accept both (which currently would lead to the symbol being dropped as ambiguous). |
clang-tools-extra/clangd/StdSymbolMap.inc | ||
---|---|---|
958 |
Waiting for permissions on a big codebase with lots of third_party code to perform some analysis.
std::move is different, both occurrences are marked as variants. We don't really drop it during post-processing saying there are multiple options, it just never makes it to the final list. move<>() (algorithm) (since C++11) move<>() (utility) (since C++11) I am not sure how we ended up with this ignore the varianted symbols behavior.
I agree, there is some room for improvement, like also listing different overloads with expected number of parameters and language versions. | |
clang-tools-extra/clangd/include-mapping/cppreference_parser.py | ||
140–142 | I was trying to keep the change to a minimum. Happy to go with a solution that accepts a dictionary in the form of (FQN, list_of_accepted_variants), where the list can have "" variant, or instead of a list we can also have a glob, but I don't think it'll provide much value considering the irregularity of std header names. |
1658 | remove | NULL |
1731 | std::__u::remove | llvm/include/c++/v1/__algorithm/remove.h |
for whatever reason I remembered the std::remove to have been referenced ~17k. looks like these two are much closer. I don't think it makes sense to prefer one or the other here.
I suggest moving forward with a mechanism that enables accepting certain variants and accepting both unnamed and algorithm variants for std::remove, hence it being rejected as an ambiguous symbol in the end. That way we won't have a special case to handle once we start including multiple options for a symbol.
WDYT?
Agree, for StdSymbolMap.inc this means neither version of remove should be there.
I suggest moving forward with a mechanism that enables accepting certain variants and accepting both unnamed and algorithm variants for std::remove, hence it being rejected as an ambiguous symbol in the end. That way we won't have a special case to handle once we start including multiple options for a symbol.
WDYT?
In practice we don't actually need the ability to accept specific variants, just variants in general.
(Maybe we'll need it later, but maybe not.)
clang-tools-extra/clangd/CSymbolMap.inc | ||
---|---|---|
701 ↗ | (On Diff #390405) | hmm, I would expect this to still be in CSymbolMap, it's not ambiguous there. |
clang-tools-extra/clangd/include-mapping/cppreference_parser.py | ||
140–142 | I'd just change this to variant or (ns + name in variants to accept) That way we accept both versions of move, and end up dropping it as ambiguous. | |
168 | we should have a comment on the symbol
|
Is the stdio version so uncommon we are willing to be wrong about it? For move we omit it from here and consider it case-by-case, I'd have imagined doing the same here
(BTW at some point we may want to extend this to list alternative headers for ambiguous symbols)