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

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


hokein updated this revision to Diff 425481.
hokein added a comment.

Fix the broken test.


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.425481.patch
Type: text/x-patch
Size: 1683 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220427/98d7a04d/attachment-0001.bin>


More information about the cfe-commits mailing list