Author: Nathan Ridge
Date: 2023-02-06T03:44:36-05:00
New Revision: 6c4691391419814d0fd8fcd92c99026813c35b47

URL: 
https://github.com/llvm/llvm-project/commit/6c4691391419814d0fd8fcd92c99026813c35b47
DIFF: 
https://github.com/llvm/llvm-project/commit/6c4691391419814d0fd8fcd92c99026813c35b47.diff

LOG: [clangd] Semantic highlighting for constrained-parameter

Differential Revision: https://reviews.llvm.org/D142871

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index f76bedee03515..1caf70183fdb6 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -1044,6 +1044,17 @@ class ExplicitReferenceCollector
     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

diff  --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp 
b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
index 08d94537f4d29..f5174979a8d6e 100644
--- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -1022,7 +1022,7 @@ sizeof...($TemplateParameter[[Elements]]);
         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


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to