[PATCH] D66738: [clangd] Added highlighting for structured bindings.

Johan Vikström via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 30 07:06:38 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL370473: [clangd] Added highlighting for structured bindings. (authored by jvikstrom, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66738?vs=217652&id=218090#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D66738

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


Index: clang-tools-extra/trunk/clangd/SemanticHighlighting.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/trunk/clangd/SemanticHighlighting.cpp
@@ -233,6 +233,10 @@
                                                : HighlightingKind::Variable);
       return;
     }
+    if (isa<BindingDecl>(D)) {
+      addToken(Loc, HighlightingKind::Variable);
+      return;
+    }
     if (isa<FunctionDecl>(D)) {
       addToken(Loc, HighlightingKind::Function);
       return;
Index: clang-tools-extra/trunk/clangd/unittests/SemanticHighlightingTests.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/trunk/clangd/unittests/SemanticHighlightingTests.cpp
@@ -436,6 +436,21 @@
         assert($Variable[[x]] != $Variable[[y]]);
         assert($Variable[[x]] != $Function[[f]]());
       }
+    )cpp",
+    R"cpp(
+      struct $Class[[S]] {
+        $Primitive[[float]] $Field[[Value]];
+        $Class[[S]] *$Field[[Next]];
+      };
+      $Class[[S]] $Variable[[Global]][2] = {$Class[[S]](), $Class[[S]]()};
+      $Primitive[[void]] $Function[[f]]($Class[[S]] $Parameter[[P]]) {
+        $Primitive[[int]] $LocalVariable[[A]][2] = {1,2};
+        auto [$Variable[[B1]], $Variable[[B2]]] = $LocalVariable[[A]];
+        auto [$Variable[[G1]], $Variable[[G2]]] = $Variable[[Global]];
+        $Class[[auto]] [$Variable[[P1]], $Variable[[P2]]] = $Parameter[[P]];
+        // Highlights references to BindingDecls.
+        $Variable[[B1]]++;
+      }
     )cpp"};
   for (const auto &TestCase : TestCases) {
     checkHighlightings(TestCase);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66738.218090.patch
Type: text/x-patch
Size: 1760 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190830/63acf556/attachment-0001.bin>


More information about the cfe-commits mailing list