[clangd] Semantic highlighting for constrained-parameter
authorNathan Ridge <zeratul976@hotmail.com>
Mon, 30 Jan 2023 08:09:00 +0000 (03:09 -0500)
committerNathan Ridge <zeratul976@hotmail.com>
Mon, 6 Feb 2023 08:44:36 +0000 (03:44 -0500)
Differential Revision: https://reviews.llvm.org/D142871

clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

index f76bede..1caf701 100644 (file)
@@ -1044,6 +1044,17 @@ public:
     return RecursiveASTVisitor::TraverseConstructorInitializer(Init);
   }
 
+  bool TraverseTypeConstraint(const TypeConstraint *TC) {
+    // We want to handle all ConceptReferences but RAV is missing a
+    // polymorphic Visit or Traverse method for it, so we handle
+    // TypeConstraints specially here.
+    Out(ReferenceLoc{TC->getNestedNameSpecifierLoc(),
+                     TC->getConceptNameLoc(),
+                     /*IsDecl=*/false,
+                     {TC->getNamedConcept()}});
+    return RecursiveASTVisitor::TraverseTypeConstraint(TC);
+  }
+
 private:
   /// Obtain information about a reference directly defined in \p N. Does not
   /// recurse into child nodes, e.g. do not expect references for constructor
index 08d9453..f517497 100644 (file)
@@ -1022,7 +1022,7 @@ $Bracket[[>]]$Bracket[[>]] $LocalVariable_def[[s6]];
         class $Class_def[[Z]] {};
         template $Bracket[[<]]typename, typename$Bracket[[>]]
         concept $Concept_decl[[C2]] = true;
-        template $Bracket[[<]]C2$Bracket[[<]]int$Bracket[[>]] $TemplateParameter_def[[A]]$Bracket[[>]]
+        template $Bracket[[<]]$Concept[[C2]]$Bracket[[<]]int$Bracket[[>]] $TemplateParameter_def[[A]]$Bracket[[>]]
         class $Class_def[[B]] {};
       )cpp",
       // no crash