New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IncludeCleaner's filtering of UsingShadows is too aggressive with templates #59147
Comments
It is unclear whether it will introduce side effects (diagnostic regression etc) in clang.
Probably works, but
This seems the best to me (simple code), and it aligns with the current clangd include-cleaner behavior. |
Can you please provide an example?
SGTM, this was added in D135859, @kadircet may have an opinion |
this definitely sounds like possibly a bigger change (due to rest of the places that might be depending on it, as @hokein mentioned). but I don't see anything conceptually wrong about an implicit instantiation marking the template it's using as used.
I don't think that's gonna work without additional changes. even if this wasn't in place, we don't really get shadowdecls for (partial) specializations of the template, only the primary pattern is mentioned.
this feels like the right approach to me. it'd be better to have this properly handled in the AST one day, but until then I think it's fine to special case templates here and report a a bunch of extra used decls by our own search, rather than AST telling us. |
That seems like a relatively tiny/inconsequential limitation (how often this really result in a different set of includes in practice), and also one that might be addressed in other ways (on the use side, rather than at the UsingDecl).
Certainly, that's why it made sense to try this approach. But this is "only" a false-negative issue, and we don't have any evidence that there are many of these. |
not sure what you mean by false-negative exactly, but to me this feels like a false positive. just because a library you transitively depend on declares But still i think you're right about us not having enough evidence in real world to see how much this matters. So we can strip off the filtering and report as ambiguous. |
The
|
The using-decl should be marked as a reference to either
vector<T>
orvector<int>
, but is not.The reason is that (in an implementation file) we iterate over the UsingShadowDecls and drop those whose targets are not
Used
orReferenced
. In this case the UsingShadowDecl points at the primary templatevector<T>
but only the specializationvector<int>
is marked as used.Possible fixes:
The text was updated successfully, but these errors were encountered: