This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Also mark output arguments of operator call expressions
ClosedPublic

Authored by ckandeler on Jun 22 2022, 1:53 AM.

Details

Summary

There's no reason that arguments to e.g. lambda calls should be treated
differently than those to "real" functions.

Diff Detail

Event Timeline

ckandeler created this revision.Jun 22 2022, 1:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 22 2022, 1:53 AM
ckandeler requested review of this revision.Jun 22 2022, 1:53 AM
nridge added a subscriber: nridge.Jun 26 2022, 4:57 PM

Thanks for the patch!

nit: please make the commit message a bit more specific, e.g. "Also apply the 'mutable' semantic token modifier to arguments of overloaded call operators"

clang-tools-extra/clangd/SemanticHighlighting.cpp
539–540

Please update the FIXME to something like:

// FIXME: consider highlighting parameters of some other overloaded operators as well

(There's some discussion here about which other cases would make sense to highlight, and which wouldn't.)

540–547

I think this could be expressed a bit more cleanly with the ArrayRef API:

(Please note also the convention in this codebase to capitalize local variable names.)

llvm::ArrayRef<const Expr *const> Args = {E->getArgs(), E->getNumArgs()};
if (const auto CallOp = ...) {
  if (CallOp->getOperator() != OO_Call)
    return true;
  
  Args = Args.drop_front();  // Drop object parameter
}

highlightMutableReferenceArguments(..., Args);
ckandeler updated this revision to Diff 440650.Jun 28 2022, 9:09 AM
ckandeler marked 2 inline comments as done.

Improvements as per review comments.

nridge accepted this revision.Jun 28 2022, 3:54 PM

Thanks!

I'm going to take the liberty of approving this, as it seems straightforward and unlikely to be contentious in any way.

Please let me know if you need me to commit it.

This revision is now accepted and ready to land.Jun 28 2022, 3:54 PM

I'm going to take the liberty of approving this, as it seems straightforward and unlikely to be contentious in any way.

Thanks!

Please let me know if you need me to commit it.

Yes, please.

This revision was automatically updated to reflect the committed changes.