[clangd] Also mark output arguments of operator call expressions

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

Reviewed By: nridge

Differential Revision: https://reviews.llvm.org/D128329
This commit is contained in:
Christian Kandeler 2022-06-29 20:12:36 -04:00 committed by Nathan Ridge
parent 1b8c73522e
commit c09e533374
2 changed files with 21 additions and 5 deletions

View File

@ -539,13 +539,17 @@ public:
if (isa<UserDefinedLiteral>(E))
return true;
// FIXME ...here it would make sense though.
if (isa<CXXOperatorCallExpr>(E))
return true;
// FIXME: consider highlighting parameters of some other overloaded
// operators as well
llvm::ArrayRef<const Expr *> Args = {E->getArgs(), E->getNumArgs()};
if (const auto callOp = dyn_cast<CXXOperatorCallExpr>(E)) {
if (callOp->getOperator() != OO_Call)
return true;
Args = Args.drop_front(); // Drop object parameter
}
highlightMutableReferenceArguments(
dyn_cast_or_null<FunctionDecl>(E->getCalleeDecl()),
{E->getArgs(), E->getNumArgs()});
dyn_cast_or_null<FunctionDecl>(E->getCalleeDecl()), Args);
return true;
}

View File

@ -738,6 +738,11 @@ sizeof...($TemplateParameter[[Elements]]);
)cpp",
// Modifier for variables passed as non-const references
R"cpp(
struct $Class_decl[[ClassWithOp]] {
void operator()(int);
void operator()(int, int &);
void operator()(int, int, const int &);
};
void $Function_decl[[fun]](int, const int,
int*, const int*,
int&, const int&,
@ -759,6 +764,13 @@ sizeof...($TemplateParameter[[Elements]]);
$LocalVariable[[array]], $LocalVariable_usedAsMutableReference[[array]],
$LocalVariable[[array]]
);
[](int){}($LocalVariable[[val]]);
[](int&){}($LocalVariable_usedAsMutableReference[[val]]);
[](const int&){}($LocalVariable[[val]]);
$Class[[ClassWithOp]] $LocalVariable_decl[[c]];
$LocalVariable[[c]]($LocalVariable[[val]]);
$LocalVariable[[c]](0, $LocalVariable_usedAsMutableReference[[val]]);
$LocalVariable[[c]](0, 0, $LocalVariable[[val]]);
}
struct $Class_decl[[S]] {
$Class_decl[[S]](int&) {