[PATCH] D152645: [clangd] Handle DependentNameType in HeuristicResolver::resolveTypeToRecordDecl()

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 16 02:57:58 PDT 2023


hokein accepted this revision.
hokein added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang-tools-extra/clangd/HeuristicResolver.cpp:33
 
+const Type *resolveDeclsToType(const std::vector<const NamedDecl *> &Decls,
+                               ASTContext &Ctx) {
----------------
nit: move this helper function to anonymous namespace.


================
Comment at: clang-tools-extra/clangd/HeuristicResolver.cpp:56
+  if (const auto *DNT = T->getAs<DependentNameType>()) {
+    T = resolveDeclsToType(resolveDependentNameType(DNT));
+    if (!T)
----------------
nridge wrote:
> hokein wrote:
> > Is the `resolveDeclsToType` call necessary here?  
> > The code path we're doing is `dependent-type => Decl* => Type => Decl*`, the later two steps seems redundant, can we just use the Decl result from `resolveDependentNameType()`?
> > 
> > 
> The Decl returned by `resolveDependentNameType()` in this testcase is a `TypeAliasDecl`. The function needs to return the `CXXRecordDecl` which is named by the target type of the alias.
> 
> We could add logic to "desugar" the `TypeAliasDecl`, but it seems easier to reuse the existing logic that does the desugaring in type-land.
I see, thanks for the explanation (this part of code is a bit hard to follow). 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152645/new/

https://reviews.llvm.org/D152645



More information about the cfe-commits mailing list