[clang] [clang][Index] Use HeuristicResolver in IndexTypeSourceInfo as well (PR #128106)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 20 20:04:28 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Nathan Ridge (HighCommander4)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/128106.diff
1 Files Affected:
- (modified) clang/lib/Index/IndexTypeSourceInfo.cpp (+3-21)
``````````diff
diff --git a/clang/lib/Index/IndexTypeSourceInfo.cpp b/clang/lib/Index/IndexTypeSourceInfo.cpp
index b986ccde57452..d5d0a3c422871 100644
--- a/clang/lib/Index/IndexTypeSourceInfo.cpp
+++ b/clang/lib/Index/IndexTypeSourceInfo.cpp
@@ -11,6 +11,7 @@
#include "clang/AST/PrettyPrinter.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/AST/TypeLoc.h"
+#include "clang/Sema/HeuristicResolver.h"
#include "llvm/ADT/ScopeExit.h"
using namespace clang;
@@ -207,27 +208,8 @@ class TypeIndexer : public RecursiveASTVisitor<TypeIndexer> {
}
bool VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
- const DependentNameType *DNT = TL.getTypePtr();
- const NestedNameSpecifier *NNS = DNT->getQualifier();
- const Type *T = NNS->getAsType();
- 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();
- DeclarationName Name(DNT->getIdentifier());
- std::vector<const NamedDecl *> Symbols = RD->lookupDependentName(
- Name, [](const NamedDecl *ND) { return isa<TypeDecl>(ND); });
+ std::vector<const NamedDecl *> Symbols =
+ IndexCtx.getResolver()->resolveDependentNameType(TL.getTypePtr());
if (Symbols.size() != 1)
return true;
return IndexCtx.handleReference(Symbols[0], TL.getNameLoc(), Parent,
``````````
</details>
https://github.com/llvm/llvm-project/pull/128106
More information about the cfe-commits
mailing list