forked from OSchip/llvm-project
[AST] Consider QualifiedTemplateName in TemplateName::getAsUsingDecl().
If the underlying template name of a qualified template name is a using decl, TemplateName::getAsUsingDecl() will return it. This will make the UsingTemplateName consumer life easier. Differential Revision: https://reviews.llvm.org/D124437
This commit is contained in:
parent
74273d575f
commit
8052f4d22a
|
@ -90,6 +90,14 @@ TEST(IncludeCleaner, ReferencedLocations) {
|
||||||
template <template <typename> class T> class X {};
|
template <template <typename> class T> class X {};
|
||||||
X<A> x;
|
X<A> x;
|
||||||
)cpp"},
|
)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(
|
{R"cpp(
|
||||||
namespace ns { template<typename T> struct ^A { ^A(T); }; }
|
namespace ns { template<typename T> struct ^A { ^A(T); }; }
|
||||||
using ns::^A;
|
using ns::^A;
|
||||||
|
|
|
@ -172,6 +172,8 @@ UsingShadowDecl *TemplateName::getAsUsingShadowDecl() const {
|
||||||
if (Decl *D = Storage.dyn_cast<Decl *>())
|
if (Decl *D = Storage.dyn_cast<Decl *>())
|
||||||
if (UsingShadowDecl *USD = dyn_cast<UsingShadowDecl>(D))
|
if (UsingShadowDecl *USD = dyn_cast<UsingShadowDecl>(D))
|
||||||
return USD;
|
return USD;
|
||||||
|
if (QualifiedTemplateName *QTN = getAsQualifiedTemplateName())
|
||||||
|
return QTN->getUnderlyingTemplate().getAsUsingShadowDecl();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ TEST(TemplateName, QualifiedUsingTemplate) {
|
||||||
const auto *USD = QTN->getUnderlyingTemplate().getAsUsingShadowDecl();
|
const auto *USD = QTN->getUnderlyingTemplate().getAsUsingShadowDecl();
|
||||||
EXPECT_TRUE(USD);
|
EXPECT_TRUE(USD);
|
||||||
EXPECT_EQ(USD->getTargetDecl(), TN.getAsTemplateDecl());
|
EXPECT_EQ(USD->getTargetDecl(), TN.getAsTemplateDecl());
|
||||||
|
EXPECT_EQ(TN.getAsUsingShadowDecl(), USD);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(TemplateName, UsingTemplate) {
|
TEST(TemplateName, UsingTemplate) {
|
||||||
|
|
Loading…
Reference in New Issue