This is an archive of the discontinued LLVM Phabricator instance.

[clangd] synthesize fix message when the diagnostic doesn't provide one.
ClosedPublic

Authored by sammccall on Mar 29 2018, 4:18 PM.

Details

Summary

Currently if a fix is attached directly to a diagnostic, we repeat the
diagnostic message as the fix message. From eyeballing the top diagnostics,
it seems describing the textual replacement would be much clearer.

e.g.
error: use of undeclared identifier 'goo'; did you mean 'foo'?
action before: use of undeclared identifier 'goo'; did you mean 'foo'?
action after: change 'goo' to 'foo'

Diff Detail

Repository
rL LLVM

Event Timeline

sammccall created this revision.Mar 29 2018, 4:18 PM
ilya-biryukov accepted this revision.Apr 3 2018, 4:26 AM

LGTM with a small nit

clangd/Diagnostics.cpp
322 ↗(On Diff #140357)

I don't really see a way out of it, but having a limit is a bit frustrating.

It seems weird to have change 'foo' to 'bar', but couldn't find 'fsdfsdf'. did you mean 'verylongidentifierthatsumsuptomorethan200'? for the same error.
Maybe if the message that clang provides is also very long, use the generated message anyway?

This revision is now accepted and ready to land.Apr 3 2018, 4:26 AM
sammccall added inline comments.Apr 3 2018, 10:38 AM
clangd/Diagnostics.cpp
322 ↗(On Diff #140357)

Hard to know exactly what to do here without motivating cases. I just removed it.

My reasoning: these diagnostics get printed by clang, if they need a shortened message then the diagnostic should/will provide one as note text.

(An alternative that I tried out was replacing the middle of the text with "..." if it was too long, this worked well but probably isn't worth the extra lines of code)

This revision was automatically updated to reflect the committed changes.