This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Fix feature modules to drop diagnostics
ClosedPublic

Authored by kadircet on May 30 2021, 11:29 PM.

Details

Summary

Ignored diagnostics were only checked after level adjusters and assumed
it would stay the same for the rest. But it can also be modified by
FeatureModules.

Diff Detail

Event Timeline

kadircet created this revision.May 30 2021, 11:29 PM
kadircet requested review of this revision.May 30 2021, 11:29 PM
kadircet updated this revision to Diff 348733.May 30 2021, 11:49 PM

Exit after introducing cleanup function

kadircet updated this revision to Diff 348747.May 31 2021, 1:54 AM

Get rid of LastDiagWasSuppressed state in StoreDiags

sammccall accepted this revision.Jun 1 2021, 3:11 AM
sammccall added inline comments.
clang-tools-extra/clangd/Diagnostics.cpp
732–733

If I'm reading this right:

  • we previously discarded the diagnostic "quickly" without creating a Diag
  • now, we construct the Diag as normal but never emit it
  • ... but we still use the old early-exit codepath for notes, if the primary diagnostic will be discarded

The new scheme seems functionally correct, but it potentially constructs more Diags. Question is, is it ever enough to care about performance?

I believe *warnings in headers* are ultimately filtered out by the adjuster and are now extra work/allocations after this patch. Mostly this only affects preamble (exceptions: things like llvm tablegen includes) which is already slow, maybe it doesn't matter.

If you want to avoid regressing it, I'd suggest keeping the early bail out here, but instead of setting LastPrimaryDiagnosticWasSuppressed, just construct an empty Diag and set its level to Ignored. Rest of the logic can stay the same I think.

Doesn't seem like much extra code, but if you don't think it's worthwhile that's fine too of course.

789

(Hmm, the isExcluded case seems like it belongs next to the level adjuster logic rather than at the end.)

This revision is now accepted and ready to land.Jun 1 2021, 3:11 AM
kadircet added inline comments.Jun 1 2021, 8:13 AM
clang-tools-extra/clangd/Diagnostics.cpp
732–733

I also had the same hesitation, but it looked like this is only suppressing diags based on config and tidy suppression comments (ones from header are still handled at flush).

So didn't feel like a big deal, But still it can be regression in cases when these diags have some complicated fixes attached to them (we'll compute them just for dropping on the floor).

The main reasoning for dropping the early exit was because I wanted the logic to look more uniform between diagcb and adjusters (to not think about it again when the day comes and we merge the two).

So how do you feel about filling in the diagbase in any case (which has some string copies, especially around diag message), then running Adjuster, DiagCB and isExcluded, and after that we perform early return before adding fixes or running include fixer?

789

i agree, but didn't want to raise eyebrows :P moving it next to adjuster logic.

kadircet updated this revision to Diff 352628.Jun 17 2021, 12:17 AM
kadircet marked 2 inline comments as done.
  • Bail out early before filling in diag info
  • Move isExcluded check into handleDiagnostics, rather than handling it during

flushing

sammccall accepted this revision.Jun 17 2021, 12:28 AM

LG, I'm a bit sad to see we're not able to skip much work in the diagnostics-outside-main-file case but that's a separate patch.

This revision was landed with ongoing or failed builds.Jun 17 2021, 12:30 AM
This revision was automatically updated to reflect the committed changes.