Skip to content

Commit

Permalink
[c++20][clangd] Simplify code using the new ConceptReference nodes.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jensmassberg committed Aug 31, 2023
1 parent 34a35a8 commit c39dcd2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 23 deletions.
20 changes: 5 additions & 15 deletions clang-tools-extra/clangd/FindTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 0 additions & 8 deletions clang-tools-extra/clangd/SemanticHighlighting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit c39dcd2

Please sign in to comment.