forked from OSchip/llvm-project
[clangd] Also mark output arguments of array subscript expressions
... with the "usedAsMutableReference" semantic token modifier. It's quite unusual to declare the index parameter of a subscript operator as a non-const reference type, but arguably that makes it even more helpful to be aware of it when working with such code. Reviewed By: nridge Differential Revision: https://reviews.llvm.org/D128892
This commit is contained in:
parent
dc34d8df4c
commit
ac511fd439
|
@ -543,9 +543,14 @@ public:
|
|||
// 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)
|
||||
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(
|
||||
|
|
|
@ -742,6 +742,8 @@ sizeof...($TemplateParameter[[Elements]]);
|
|||
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 @@ sizeof...($TemplateParameter[[Elements]]);
|
|||
[](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&) {
|
||||
|
|
Loading…
Reference in New Issue