This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rG5b0022a9df3f: [clangd] Support UnresolvedUsingTypeLoc AST
node in FindTarget. (authored by hokein).
Changed prior to commit:
https://reviews.llvm.org/D125684?vs=429694&id=430949#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125684/new/
https://reviews.llvm.org/D125684
Files:
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -268,6 +268,17 @@
EXPECT_DECLS("DeducedTemplateSpecializationTypeLoc",
{"using ns::S", Rel::Alias}, {"template <typename T> class S"},
{"class S", Rel::TemplatePattern});
+
+ Code = R"cpp(
+ template<typename T>
+ class Foo { public: class foo {}; };
+ template <class T> class A : public Foo<T> {
+ using typename Foo<T>::foo;
+ [[foo]] abc;
+ };
+ )cpp";
+ EXPECT_DECLS("UnresolvedUsingTypeLoc",
+ {"using typename Foo<T>::foo", Rel::Alias});
}
TEST_F(TargetDeclTest, BaseSpecifier) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===================================================================
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -127,11 +127,6 @@
// template<class X> using pvec = vector<x*>; pvec<int> x;
// There's no Decl `pvec<int>`, we must choose `pvec<X>` or `vector<int*>`
// and both are lossy. We must know upfront what the caller ultimately
wants.
-//
-// FIXME: improve common dependent scope using name lookup in primary
templates.
-// We currently handle several dependent constructs, but some others remain to
-// be handled:
-// - UnresolvedUsingTypenameDecl
struct TargetFinder {
using RelSet = DeclRelationSet;
using Rel = DeclRelation;
@@ -207,6 +202,10 @@
}
}
Flags |= Rel::Alias; // continue with the alias
+ } else if (isa<UnresolvedUsingTypenameDecl>(D)) {
+ // FIXME: improve common dependent scope using name lookup in primary
+ // templates.
+ Flags |= Rel::Alias;
} else if (const UsingShadowDecl *USD = dyn_cast<UsingShadowDecl>(D)) {
// Include the Introducing decl, but don't traverse it. This may end up
// including *all* shadows, which we don't want.
@@ -382,6 +381,9 @@
// TypeLoc never has a deduced type. https://llvm.org/PR42914
Outer.add(DT->getDeducedType(), Flags);
}
+ void VisitUnresolvedUsingType(const UnresolvedUsingType *UUT) {
+ Outer.add(UUT->getDecl(), Flags);
+ }
void VisitDeducedTemplateSpecializationType(
const DeducedTemplateSpecializationType *DTST) {
if (const auto *USD = DTST->getTemplateName().getAsUsingShadowDecl())
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -268,6 +268,17 @@
EXPECT_DECLS("DeducedTemplateSpecializationTypeLoc",
{"using ns::S", Rel::Alias}, {"template <typename T> class S"},
{"class S", Rel::TemplatePattern});
+
+ Code = R"cpp(
+ template<typename T>
+ class Foo { public: class foo {}; };
+ template <class T> class A : public Foo<T> {
+ using typename Foo<T>::foo;
+ [[foo]] abc;
+ };
+ )cpp";
+ EXPECT_DECLS("UnresolvedUsingTypeLoc",
+ {"using typename Foo<T>::foo", Rel::Alias});
}
TEST_F(TargetDeclTest, BaseSpecifier) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===================================================================
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -127,11 +127,6 @@
// template<class X> using pvec = vector<x*>; pvec<int> x;
// There's no Decl `pvec<int>`, we must choose `pvec<X>` or `vector<int*>`
// and both are lossy. We must know upfront what the caller ultimately wants.
-//
-// FIXME: improve common dependent scope using name lookup in primary templates.
-// We currently handle several dependent constructs, but some others remain to
-// be handled:
-// - UnresolvedUsingTypenameDecl
struct TargetFinder {
using RelSet = DeclRelationSet;
using Rel = DeclRelation;
@@ -207,6 +202,10 @@
}
}
Flags |= Rel::Alias; // continue with the alias
+ } else if (isa<UnresolvedUsingTypenameDecl>(D)) {
+ // FIXME: improve common dependent scope using name lookup in primary
+ // templates.
+ Flags |= Rel::Alias;
} else if (const UsingShadowDecl *USD = dyn_cast<UsingShadowDecl>(D)) {
// Include the Introducing decl, but don't traverse it. This may end up
// including *all* shadows, which we don't want.
@@ -382,6 +381,9 @@
// TypeLoc never has a deduced type. https://llvm.org/PR42914
Outer.add(DT->getDeducedType(), Flags);
}
+ void VisitUnresolvedUsingType(const UnresolvedUsingType *UUT) {
+ Outer.add(UUT->getDecl(), Flags);
+ }
void VisitDeducedTemplateSpecializationType(
const DeducedTemplateSpecializationType *DTST) {
if (const auto *USD = DTST->getTemplateName().getAsUsingShadowDecl())
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits