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 @@ -543,9 +543,14 @@ // operators as well llvm::ArrayRef Args = {E->getArgs(), E->getNumArgs()}; if (const auto callOp = dyn_cast(E)) { - if (callOp->getOperator() != OO_Call) + switch (callOp->getOperator()) { + case OO_Call: + case OO_Subscript: + Args = Args.drop_front(); // Drop object parameter + break; + default: return true; - Args = Args.drop_front(); // Drop object parameter + } } highlightMutableReferenceArguments( 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 @@ -742,6 +742,8 @@ void operator()(int); void operator()(int, int &); void operator()(int, int, const int &); + int &operator[](int &); + int operator[](int) const; }; void $Function_decl[[fun]](int, const int, int*, const int*, @@ -768,9 +770,12 @@ [](int&){}($LocalVariable_usedAsMutableReference[[val]]); [](const int&){}($LocalVariable[[val]]); $Class[[ClassWithOp]] $LocalVariable_decl[[c]]; + const $Class[[ClassWithOp]] $LocalVariable_decl_readonly[[c2]]; $LocalVariable[[c]]($LocalVariable[[val]]); $LocalVariable[[c]](0, $LocalVariable_usedAsMutableReference[[val]]); $LocalVariable[[c]](0, 0, $LocalVariable[[val]]); + $LocalVariable[[c]][$LocalVariable_usedAsMutableReference[[val]]]; + $LocalVariable_readonly[[c2]][$LocalVariable[[val]]]; } struct $Class_decl[[S]] { $Class_decl[[S]](int&) {