From 62bcb75ce5108c2536b8bf7f4428034d418b9c0b Mon Sep 17 00:00:00 2001 From: Sam McCall Date: Wed, 15 Dec 2021 21:59:54 +0100 Subject: [PATCH] [AST] Add more testcases to QualTypeNamesTest. NFC These all currently pass, but are tricky cases not currently covered. https://reviews.llvm.org/D114251 would break them in its current state. --- clang/unittests/Tooling/QualTypeNamesTest.cpp | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/clang/unittests/Tooling/QualTypeNamesTest.cpp b/clang/unittests/Tooling/QualTypeNamesTest.cpp index 4ae6861751b8..336a27e69be5 100644 --- a/clang/unittests/Tooling/QualTypeNamesTest.cpp +++ b/clang/unittests/Tooling/QualTypeNamesTest.cpp @@ -92,6 +92,9 @@ TEST(QualTypeNameTest, getFullyQualifiedName) { "OuterTemplateClass::Inner"; Visitor.ExpectedQualTypeNames["CheckM"] = "const A::B::Class0 *"; Visitor.ExpectedQualTypeNames["CheckN"] = "const X *"; + Visitor.ExpectedQualTypeNames["ttp_using"] = + "OuterTemplateClass"; + Visitor.ExpectedQualTypeNames["alias_of_template"] = "ABTemplate0IntInt"; Visitor.runOver( "int CheckInt;\n" "template \n" @@ -124,6 +127,9 @@ TEST(QualTypeNameTest, getFullyQualifiedName) { "}\n" "using A::B::Class0;\n" "void Function(Class0 CheckF);\n" + "OuterTemplateClass ttp_using;\n" + "using ABTemplate0IntInt = A::B::Template0;\n" + "void Function(ABTemplate0IntInt alias_of_template);\n" "using namespace A::B::C;\n" "void Function(MyInt CheckG);\n" "void f() {\n" @@ -182,6 +188,25 @@ TEST(QualTypeNameTest, getFullyQualifiedName) { " struct A { typedef int X; };" "}"); + TypeNameVisitor DoubleUsing; + DoubleUsing.ExpectedQualTypeNames["direct"] = "a::A<0>"; + DoubleUsing.ExpectedQualTypeNames["indirect"] = "b::B"; + DoubleUsing.ExpectedQualTypeNames["double_indirect"] = "b::B"; + DoubleUsing.runOver(R"cpp( + namespace a { + template class A {}; + A<0> direct; + } + namespace b { + using B = ::a::A<0>; + B indirect; + } + namespace b { + using ::b::B; + B double_indirect; + } + )cpp"); + TypeNameVisitor GlobalNsPrefix; GlobalNsPrefix.WithGlobalNsPrefix = true; GlobalNsPrefix.ExpectedQualTypeNames["IntVal"] = "int";