diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp --- a/clang-tools-extra/clangd/SemanticHighlighting.cpp +++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp @@ -538,12 +538,20 @@ return true; // FIXME ...here it would make sense though. - if (isa(E)) - return true; + Expr **args = nullptr; + unsigned numArgs = 0; + if (const auto callOp = dyn_cast(E)) { + if (callOp->getOperator() != OO_Call) + return true; + args = E->getArgs() + 1; + numArgs = E->getNumArgs() - 1; + } else { + args = E->getArgs(); + numArgs = E->getNumArgs(); + } highlightMutableReferenceArguments( - dyn_cast_or_null(E->getCalleeDecl()), - {E->getArgs(), E->getNumArgs()}); + dyn_cast_or_null(E->getCalleeDecl()), {args, numArgs}); return true; } diff --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp --- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp +++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp @@ -738,6 +738,11 @@ )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 @@ $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&) {