[PATCH] D159268: [c++20][clangd] Simplify code using the new `ConceptReference` nodes.

Jens Massberg via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 31 04:25:25 PDT 2023


massberg created this revision.
massberg added a reviewer: sammccall.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
massberg requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Directly traverse `ConceptReference`s in FindTarget.cpp.

There is no need for the extra logic for `AutoTypeLoc`s in SemanticHightlighting.cpp as the concept information is stored in a `ConceptReference` which is now traversed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159268

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/SemanticHighlighting.cpp


Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===================================================================
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -736,14 +736,6 @@
     return true;
   }
 
-  bool VisitAutoTypeLoc(AutoTypeLoc L) {
-    if (L.isConstrained()) {
-      H.addAngleBracketTokens(L.getLAngleLoc(), L.getRAngleLoc());
-      H.addToken(L.getConceptNameInfo().getLoc(), HighlightingKind::Concept);
-    }
-    return true;
-  }
-
   bool VisitFunctionDecl(FunctionDecl *D) {
     if (D->isOverloadedOperator()) {
       const auto AddOpDeclToken = [&](SourceLocation Loc) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===================================================================
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -742,13 +742,6 @@
     // FIXME: handle more complicated cases: more ObjC, designated initializers.
     llvm::SmallVector<ReferenceLoc> Refs;
 
-    void VisitConceptSpecializationExpr(const ConceptSpecializationExpr *E) {
-      Refs.push_back(ReferenceLoc{E->getNestedNameSpecifierLoc(),
-                                  E->getConceptNameLoc(),
-                                  /*IsDecl=*/false,
-                                  {E->getNamedConcept()}});
-    }
-
     void VisitDeclRefExpr(const DeclRefExpr *E) {
       Refs.push_back(ReferenceLoc{E->getQualifierLoc(),
                                   E->getNameInfo().getLoc(),
@@ -1063,15 +1056,12 @@
     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(),
+  bool TraverseConceptReference(ConceptReference *ConceptRef) {
+    Out(ReferenceLoc{ConceptRef->getNestedNameSpecifierLoc(),
+                     ConceptRef->getConceptNameLoc(),
                      /*IsDecl=*/false,
-                     {TC->getNamedConcept()}});
-    return RecursiveASTVisitor::TraverseTypeConstraint(TC);
+                     {ConceptRef->getNamedConcept()}});
+    return RecursiveASTVisitor::TraverseConceptReference(ConceptRef);
   }
 
 private:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159268.554978.patch
Type: text/x-patch
Size: 2439 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230831/aaa209a8/attachment.bin>


More information about the cfe-commits mailing list