This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy][include-cleaner] Don't warn for the same symbol twice
Needs ReviewPublic

Authored by abrachet on Jul 13 2023, 9:35 AM.

Details

Summary

Only one diagnostic per symbol is necessary, after that the diagnostics
can become overbearing.

Diff Detail

Event Timeline

abrachet created this revision.Jul 13 2023, 9:35 AM
abrachet requested review of this revision.Jul 13 2023, 9:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 13 2023, 9:35 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Hi Alex,

Thank you for the patch.
We are aware that issuing one diagnostic per symbol reference might be overwhelming. However, we have decided to choose it over other options after considering the use cases that we'd like to cover.
This check is intended to be used in review tooling, where the user usually only sees their own change/diff. Issuing only one diagnostic for the first symbol reference would render this check mostly useless in code review, since the first symbol reference is not in the scope of the user's change most of the time.

Moreover, it's desirable to have similar behavior in include-cleaner checks across multiple clang tools. The current behaviour corresponds to the behaviour of built-in include-cleaner in clangd for similar reasons, i.e., users are most prone to act on a finding if it shows up in the piece of code they're currently editing.

The currently ongoing cleanup efforts should help the make the findings less overwhelming as well.

Check emits warnings per symbol/usage, but fixes header includes, won't it make duplicate includes ?

Problem that I see is that multiple warnings for same symbol will generate lot of noise.
And when dealing with diff why developer should be forced to fix legacy issues just because he/she used same symbol, after all issue is actually peer symbol, whatever how many times is used.
Stil...

I cannot make "decision" here.
Both patch author, and check author got a point.

There is only one option, could this be made configurable ?

nridge added a subscriber: nridge.Aug 5 2023, 4:48 PM