Author: Jens Massberg Date: 2023-08-31T13:53:56+02:00 New Revision: c39dcd2c2bc7fd142ac8305b3a41f24e1addbd8c
URL: https://github.com/llvm/llvm-project/commit/c39dcd2c2bc7fd142ac8305b3a41f24e1addbd8c DIFF: https://github.com/llvm/llvm-project/commit/c39dcd2c2bc7fd142ac8305b3a41f24e1addbd8c.diff LOG: [c++20][clangd] Simplify code using the new `ConceptReference` nodes. 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. Differential Revision: https://reviews.llvm.org/D159268 Added: Modified: clang-tools-extra/clangd/FindTarget.cpp clang-tools-extra/clangd/SemanticHighlighting.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/FindTarget.cpp b/clang-tools-extra/clangd/FindTarget.cpp index 630b75059b6baf..c1ec030275c4f6 100644 --- a/clang-tools-extra/clangd/FindTarget.cpp +++ b/clang-tools-extra/clangd/FindTarget.cpp @@ -742,13 +742,6 @@ llvm::SmallVector<ReferenceLoc> refInStmt(const Stmt *S, // 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 @@ 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(), + bool VisitConceptReference(ConceptReference *ConceptRef) { + Out(ReferenceLoc{ConceptRef->getNestedNameSpecifierLoc(), + ConceptRef->getConceptNameLoc(), /*IsDecl=*/false, - {TC->getNamedConcept()}}); - return RecursiveASTVisitor::TraverseTypeConstraint(TC); + {ConceptRef->getNamedConcept()}}); + return true; } private: diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp index 8003a3c98f0ad8..45c01634e2e38d 100644 --- a/clang-tools-extra/clangd/SemanticHighlighting.cpp +++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp @@ -736,14 +736,6 @@ class CollectExtraHighlightings 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) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits