[PATCH] D128892: [clangd] Also mark output arguments of array subscript expressions

Nathan Ridge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 1 01:45:36 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGac511fd4392d: [clangd] Also mark output arguments of array subscript expressions (authored by ckandeler, committed by nridge).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128892/new/

https://reviews.llvm.org/D128892

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ 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&) {
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===================================================================
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -543,9 +543,14 @@
     // 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(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128892.441637.patch
Type: text/x-patch
Size: 2103 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220701/ae0c3797/attachment.bin>


More information about the cfe-commits mailing list