This is an archive of the discontinued LLVM Phabricator instance.

[include-cleaner] Traverse implicit template instantations if the templates are inside the main file.
Needs ReviewPublic

Authored by hokein on Jun 12 2023, 1:10 PM.

Details

Reviewers
kadircet
Summary

This patch tweaks the WalkAST to traverse imlicit template
instantations, presumably this is a big behavior change.

when traversing impplicit instantations, all reported references are
implicit as they are not spelled in the source code, thus they are not
contributed to the #include insertions.

This would fix some unused-include false positives where we report an
#include is unused despite the used references is in an instantiated
body.

Diff Detail

Event Timeline

hokein created this revision.Jun 12 2023, 1:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 12 2023, 1:10 PM
hokein requested review of this revision.Jun 12 2023, 1:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 12 2023, 1:10 PM

Though I'm not a reviewer, I was looking through the emails and found this change interesting. This is not intended to block the review in any way, just trying to get a picture of the direction include-cleaner is taking.

Is this a digression from the initial idea of include-what-you-spell?
I thought that the whole point was in trying to make the analysis more "local" and avoid relying on implicit instantiations.

What is our strategy on balancing the number of false-positive removals we produce with the number of false-negatives where we don't remove something that's actually unused?