r266925 - [Tooling] Fix getting fully qualified names of template alias types.

Chaoren Lin via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 20 15:12:07 PDT 2016


Author: chaoren
Date: Wed Apr 20 17:12:07 2016
New Revision: 266925

URL: http://llvm.org/viewvc/llvm-project?rev=266925&view=rev
Log:
[Tooling] Fix getting fully qualified names of template alias types.

Reviewers: rsmith, rnk

Subscribers: cfe-commits, klimek

Differential Revision: http://reviews.llvm.org/D19253

Modified:
    cfe/trunk/lib/Tooling/Core/QualTypeNames.cpp
    cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp

Modified: cfe/trunk/lib/Tooling/Core/QualTypeNames.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/QualTypeNames.cpp?rev=266925&r1=266924&r2=266925&view=diff
==============================================================================
--- cfe/trunk/lib/Tooling/Core/QualTypeNames.cpp (original)
+++ cfe/trunk/lib/Tooling/Core/QualTypeNames.cpp Wed Apr 20 17:12:07 2016
@@ -304,6 +304,8 @@ static NestedNameSpecifier *createNested
     Decl = TDT->getDecl();
   } else if (const auto *TagDeclType = dyn_cast<TagType>(TypePtr)) {
     Decl = TagDeclType->getDecl();
+  } else if (const auto *TST = dyn_cast<TemplateSpecializationType>(TypePtr)) {
+    Decl = TST->getTemplateName().getAsTemplateDecl();
   } else {
     Decl = TypePtr->getAsCXXRecordDecl();
   }

Modified: cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp?rev=266925&r1=266924&r2=266925&view=diff
==============================================================================
--- cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/QualTypeNamesTest.cpp Wed Apr 20 17:12:07 2016
@@ -87,13 +87,19 @@ TEST(QualTypeNameTest, getFullyQualified
   Visitor.ExpectedQualTypeNames["non_dependent_type_var"] =
       "Foo<X>::non_dependent_type";
   Visitor.ExpectedQualTypeNames["AnEnumVar"] = "EnumScopeClass::AnEnum";
+  Visitor.ExpectedQualTypeNames["AliasTypeVal"] = "A::B::C::InnerAlias<int>";
   Visitor.runOver(
       "int CheckInt;\n"
+      "template <typename T>\n"
+      "class OuterTemplateClass { };\n"
       "namespace A {\n"
       " namespace B {\n"
       "   class Class0 { };\n"
       "   namespace C {\n"
       "     typedef int MyInt;"
+      "     template <typename T>\n"
+      "     using InnerAlias = OuterTemplateClass<T>;\n"
+      "     InnerAlias<int> AliasTypeVal;\n"
       "   }\n"
       "   template<class X, class Y> class Template0;"
       "   template<class X, class Y> class Template1;"
@@ -148,7 +154,8 @@ TEST(QualTypeNameTest, getFullyQualified
       "public:\n"
       "  enum AnEnum { ZERO, ONE };\n"
       "};\n"
-      "EnumScopeClass::AnEnum AnEnumVar;\n"
+      "EnumScopeClass::AnEnum AnEnumVar;\n",
+      TypeNameVisitor::Lang_CXX11
 );
 
   TypeNameVisitor Complex;




More information about the cfe-commits mailing list