This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Propagate data in diagnostics
ClosedPublic

Authored by kadircet on Mar 12 2021, 7:10 AM.

Diff Detail

Event Timeline

kadircet created this revision.Mar 12 2021, 7:10 AM
kadircet requested review of this revision.Mar 12 2021, 7:10 AM
sammccall added inline comments.Mar 15 2021, 10:09 AM
clang-tools-extra/clangd/Diagnostics.h
59

Second sentence is confusing because of inverted sense. And really I don't think the reason is that we don't want to send extra data, but rather the fear that old clients will choke on it.

If we're *not* afraid of that, i.e. we think they'll just drop it on the floor, then I don't think we should bother to feature-detect it just so *we* can drop it on the floor.
Not sure how you feel about this, but it's pretty tempting to me...

78

Maybe call this OpaqueData or Data?
I like the comment but I'm not sure where this is ultimately set is so important at this level (and we might use it in other ways!)

clang-tools-extra/clangd/Protocol.h
851

The array representation seems a bit awkward in practice: it's ~always going to have 1 element (or none), so it seems like unnecessary wrapping.
I think the "natural" representation is something like {"fooTweakParam": 42} or {"fooTweakParams": {"x": 1, "y": 2}}.

This array prevents tweaks from clobbering each other but OTOH it means the data they read doesn't match the data they write. I think making data an Object and passing in a mutable ref to it will work fine in practice.

Herald added a project: Restricted Project. · View Herald TranscriptMar 15 2021, 10:09 AM
kadircet updated this revision to Diff 332636.Mar 23 2021, 5:31 AM
kadircet marked 2 inline comments as done.
  • Ignore capability
  • Store data as a json::Object rather than an Array.
kadircet added inline comments.Mar 24 2021, 8:55 AM
clang-tools-extra/clangd/Diagnostics.h
59

as discussed offline dropping this completely. since we don't really guard against adding "extra" properties to objects, and the worst that could happen is clangd won't surface a particular tweak on clients without support.

sammccall accepted this revision.Mar 24 2021, 9:48 AM
sammccall added inline comments.
clang-tools-extra/clangd/Diagnostics.h
78

Hmm, you've replaced the json::Array with an array of objects :-)
Any reason we can't just use llvm::json::Object here?

We don't really handle conflicts anyway, and I don't think having one tweak read another one's data out of this field is a real concern.

clang-tools-extra/clangd/Protocol.cpp
615

std::move is a fancy way to spell copy here, since Params is const.

json::Value(*Data) (or can you just use mapOptOrNull?)

clang-tools-extra/clangd/Protocol.h
413

this is now unused

clang-tools-extra/clangd/refactor/Tweak.h
71

unrelated?
(well not quite, but neither populated or used in this patch)

This revision is now accepted and ready to land.Mar 24 2021, 9:48 AM
kadircet marked 4 inline comments as done.Mar 29 2021, 2:25 PM
kadircet added inline comments.
clang-tools-extra/clangd/Diagnostics.h
78

oops, that wasn't the intention. changed to llvm::json::Object.

clang-tools-extra/clangd/Protocol.cpp
615

std::move is a fancy way to spell copy here, since Params is const.

right.. dropped that.

json::Value(*Data) (or can you just use mapOptOrNull?)

we can't mapOptOrNull as fromJSON doesn't have output specializations for JSON types. i don't think it is worth having them (i think, they would actually be confusing). but if you think it's worth, maybe we can have some identity mapper specialization.

clang-tools-extra/clangd/refactor/Tweak.h
71

yeah this was supposed to be a separate change but forgot to strip this bit off..

kadircet updated this revision to Diff 333982.Mar 29 2021, 2:25 PM
kadircet marked 2 inline comments as done.
  • Address comments
This revision was landed with ongoing or failed builds.Apr 13 2021, 8:50 AM
This revision was automatically updated to reflect the committed changes.