This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Support "usedAsMutableReference" in member initializations
ClosedPublic

Authored by ckandeler on Jul 1 2022, 2:47 AM.

Details

Summary

That is, mark constructor parameters being used to initialize
non-const reference members.

Diff Detail

Event Timeline

ckandeler created this revision.Jul 1 2022, 2:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 1 2022, 2:47 AM
ckandeler requested review of this revision.Jul 1 2022, 2:47 AM
nridge requested changes to this revision.Jul 4 2022, 11:19 PM

Thanks, this seems like a useful extension of the usedAsMutableReference modifier

clang-tools-extra/clangd/SemanticHighlighting.cpp
541

Use auto *Member to make clang-tidy happy (const auto * is also fine)

Likewise in a few places below

543

Can we factor out this logic into a helper function highlightMutableReferenceArgument(QualType TargetType, const Expr *Arg)?

Then here we can call highlightMutableReferenceArgument(MemberType, Init->getInit())

563

nits from previous patch -- I'm getting clang-tidy diagnostics on this line about:

  1. naming (should be CallOp)
  2. it seems clang-tidy prefers writing this as auto *CallOp =

Could you fix these as part of this patch?

clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
752

Maybe we can add a line where the initializer expression is not a constructor parameter, but e.g. a non-const static data member of another class.

This revision now requires changes to proceed.Jul 4 2022, 11:19 PM
ckandeler updated this revision to Diff 442257.Jul 5 2022, 4:20 AM
ckandeler marked 4 inline comments as done.

Implemented reviewer suggestions.

clang-tools-extra/clangd/SemanticHighlighting.cpp
541

Ewww... But okay.

Note that the build failure seems unrelated, as it's due to a failing clang-tidy test.

nridge accepted this revision.Jul 8 2022, 1:11 AM

Thanks!

This revision is now accepted and ready to land.Jul 8 2022, 1:11 AM

Can you please merge it as well?

nridge added a comment.Jul 8 2022, 1:51 AM

Yes, I plan to. I'm just building it locally to verify the tests are passing. (And sometimes, for reasons I don't understand, LLVM's build system triggers a full rebuild even though I've only applied a patch that touches a couple of files...)

Yes, I plan to. I'm just building it locally to verify the tests are passing. (And sometimes, for reasons I don't understand, LLVM's build system triggers a full rebuild even though I've only applied a patch that touches a couple of files...)

I see, thanks.
Regarding the scope of rebuilds, it seems to me that the build system pulls in repository meta data, as there's lots of files rebuilt after simply amending a commit with no sources having changed.

This revision was landed with ongoing or failed builds.Jul 8 2022, 8:16 PM
This revision was automatically updated to reflect the committed changes.