Skip to content

Commit c39dcd2

Browse files
committed
[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
1 parent 34a35a8 commit c39dcd2

File tree

2 files changed

+5
-23
lines changed

2 files changed

+5
-23
lines changed

clang-tools-extra/clangd/FindTarget.cpp

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -742,13 +742,6 @@ llvm::SmallVector<ReferenceLoc> refInStmt(const Stmt *S,
742742
// FIXME: handle more complicated cases: more ObjC, designated initializers.
743743
llvm::SmallVector<ReferenceLoc> Refs;
744744

745-
void VisitConceptSpecializationExpr(const ConceptSpecializationExpr *E) {
746-
Refs.push_back(ReferenceLoc{E->getNestedNameSpecifierLoc(),
747-
E->getConceptNameLoc(),
748-
/*IsDecl=*/false,
749-
{E->getNamedConcept()}});
750-
}
751-
752745
void VisitDeclRefExpr(const DeclRefExpr *E) {
753746
Refs.push_back(ReferenceLoc{E->getQualifierLoc(),
754747
E->getNameInfo().getLoc(),
@@ -1063,15 +1056,12 @@ class ExplicitReferenceCollector
10631056
return RecursiveASTVisitor::TraverseConstructorInitializer(Init);
10641057
}
10651058

1066-
bool TraverseTypeConstraint(const TypeConstraint *TC) {
1067-
// We want to handle all ConceptReferences but RAV is missing a
1068-
// polymorphic Visit or Traverse method for it, so we handle
1069-
// TypeConstraints specially here.
1070-
Out(ReferenceLoc{TC->getNestedNameSpecifierLoc(),
1071-
TC->getConceptNameLoc(),
1059+
bool VisitConceptReference(ConceptReference *ConceptRef) {
1060+
Out(ReferenceLoc{ConceptRef->getNestedNameSpecifierLoc(),
1061+
ConceptRef->getConceptNameLoc(),
10721062
/*IsDecl=*/false,
1073-
{TC->getNamedConcept()}});
1074-
return RecursiveASTVisitor::TraverseTypeConstraint(TC);
1063+
{ConceptRef->getNamedConcept()}});
1064+
return true;
10751065
}
10761066

10771067
private:

clang-tools-extra/clangd/SemanticHighlighting.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -736,14 +736,6 @@ class CollectExtraHighlightings
736736
return true;
737737
}
738738

739-
bool VisitAutoTypeLoc(AutoTypeLoc L) {
740-
if (L.isConstrained()) {
741-
H.addAngleBracketTokens(L.getLAngleLoc(), L.getRAngleLoc());
742-
H.addToken(L.getConceptNameInfo().getLoc(), HighlightingKind::Concept);
743-
}
744-
return true;
745-
}
746-
747739
bool VisitFunctionDecl(FunctionDecl *D) {
748740
if (D->isOverloadedOperator()) {
749741
const auto AddOpDeclToken = [&](SourceLocation Loc) {

0 commit comments

Comments
 (0)