[PATCH] D124437: [AST] Consider QualifiedTemplateName in TemplateName::getAsUsingDecl().

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 27 05:16:42 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8052f4d22a12: [AST] Consider QualifiedTemplateName in TemplateName::getAsUsingDecl(). (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124437

Files:
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
  clang/lib/AST/TemplateName.cpp
  clang/unittests/AST/TemplateNameTest.cpp


Index: clang/unittests/AST/TemplateNameTest.cpp
===================================================================
--- clang/unittests/AST/TemplateNameTest.cpp
+++ clang/unittests/AST/TemplateNameTest.cpp
@@ -82,6 +82,7 @@
   const auto *USD = QTN->getUnderlyingTemplate().getAsUsingShadowDecl();
   EXPECT_TRUE(USD);
   EXPECT_EQ(USD->getTargetDecl(), TN.getAsTemplateDecl());
+  EXPECT_EQ(TN.getAsUsingShadowDecl(), USD);
 }
 
 TEST(TemplateName, UsingTemplate) {
Index: clang/lib/AST/TemplateName.cpp
===================================================================
--- clang/lib/AST/TemplateName.cpp
+++ clang/lib/AST/TemplateName.cpp
@@ -172,6 +172,8 @@
   if (Decl *D = Storage.dyn_cast<Decl *>())
     if (UsingShadowDecl *USD = dyn_cast<UsingShadowDecl>(D))
       return USD;
+  if (QualifiedTemplateName *QTN = getAsQualifiedTemplateName())
+    return QTN->getUnderlyingTemplate().getAsUsingShadowDecl();
   return nullptr;
 }
 
Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -90,6 +90,14 @@
           template <template <typename> class T> class X {};
           X<A> x;
         )cpp"},
+      {R"cpp(
+          namespace ns { template<typename T> class A {}; }
+          namespace absl {using ns::^A;}
+       )cpp",
+       R"cpp(
+          template <template <typename> class T> class X {};
+          X<absl::A> x;
+       )cpp"},
       {R"cpp(
           namespace ns { template<typename T> struct ^A { ^A(T); }; }
           using ns::^A;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124437.425486.patch
Type: text/x-patch
Size: 1683 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220427/91a20a1a/attachment.bin>


More information about the cfe-commits mailing list