[clang] [clang][Index] Use HeuristicResolver in libIndex (PR #125153)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 16 22:04:48 PST 2025
================
@@ -168,51 +169,33 @@ class BodyIndexer : public RecursiveASTVisitor<BodyIndexer> {
Parent, ParentDC, Roles, Relations, E);
}
- bool indexDependentReference(
- const Expr *E, const Type *T, const DeclarationNameInfo &NameInfo,
- llvm::function_ref<bool(const NamedDecl *ND)> Filter) {
- if (!T)
- return true;
- const TemplateSpecializationType *TST =
- T->getAs<TemplateSpecializationType>();
- if (!TST)
- return true;
- TemplateName TN = TST->getTemplateName();
- const ClassTemplateDecl *TD =
- dyn_cast_or_null<ClassTemplateDecl>(TN.getAsTemplateDecl());
- if (!TD)
- return true;
- CXXRecordDecl *RD = TD->getTemplatedDecl();
- if (!RD->hasDefinition())
- return true;
- RD = RD->getDefinition();
- std::vector<const NamedDecl *> Symbols =
- RD->lookupDependentName(NameInfo.getName(), Filter);
+ bool indexDependentReference(const Expr *E, SourceLocation Loc,
+ std::vector<const NamedDecl *> TargetSymbols) {
// FIXME: Improve overload handling.
- if (Symbols.size() != 1)
+ if (TargetSymbols.size() != 1)
return true;
- SourceLocation Loc = NameInfo.getLoc();
if (Loc.isInvalid())
Loc = E->getBeginLoc();
SmallVector<SymbolRelation, 4> Relations;
SymbolRoleSet Roles = getRolesForRef(E, Relations);
- return IndexCtx.handleReference(Symbols[0], Loc, Parent, ParentDC, Roles,
- Relations, E);
+ return IndexCtx.handleReference(TargetSymbols[0], Loc, Parent, ParentDC,
+ Roles, Relations, E);
}
bool VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E) {
- const DeclarationNameInfo &Info = E->getMemberNameInfo();
- return indexDependentReference(
- E, E->getBaseType().getTypePtrOrNull(), Info,
- [](const NamedDecl *D) { return D->isCXXInstanceMember(); });
+ auto *Resolver = IndexCtx.getResolver();
+ if (!Resolver)
+ return true;
----------------
zyn0217 wrote:
Yeah, if that is the case, I think I'm contented with an assertion
https://github.com/llvm/llvm-project/pull/125153
More information about the cfe-commits
mailing list