[clang] a722d6a - [SyntaxTree] Split ExplicitTemplateInstantiation test

Eduardo Caldas via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 24 07:32:05 PDT 2020


Author: Eduardo Caldas
Date: 2020-08-24T14:31:45Z
New Revision: a722d6a197c7a4f7a1afb72b4732b8ebe8272628

URL: https://github.com/llvm/llvm-project/commit/a722d6a197c7a4f7a1afb72b4732b8ebe8272628
DIFF: https://github.com/llvm/llvm-project/commit/a722d6a197c7a4f7a1afb72b4732b8ebe8272628.diff

LOG: [SyntaxTree] Split ExplicitTemplateInstantiation test

Differential Revision: https://reviews.llvm.org/D86441

Added: 
    

Modified: 
    clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
index 8dbf99c32db8..4fc648df90b3 100644
--- a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -3051,84 +3051,105 @@ template <class T> struct X {
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, ExplicitTemplateInstantations) {
+TEST_P(SyntaxTreeTest, ExplicitClassTemplateInstantation_Definition) {
   if (!GetParam().isCXX()) {
     return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
       R"cpp(
 template <class T> struct X {};
-template <class T> struct X<T*> {};
-template <> struct X<int> {};
+[[template struct X<double>;]]
+)cpp",
+      {R"txt(
+ExplicitTemplateInstantiation
+|-template
+`-SimpleDeclaration
+  |-struct
+  |-X
+  |-<
+  |-double
+  |->
+  `-;
+)txt"}));
+}
 
-template struct X<double>;
-extern template struct X<float>;
+TEST_P(SyntaxTreeTest, ExplicitClassTemplateInstantation_Declaration) {
+  if (!GetParam().isCXX()) {
+    return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+      R"cpp(
+template <class T> struct X {};
+[[extern template struct X<float>;]]
 )cpp",
-      R"txt(
-*: TranslationUnit
-|-TemplateDeclaration
-| |-template
-| |-<
-| |-UnknownDeclaration
-| | |-class
-| | `-T
-| |->
-| `-SimpleDeclaration
-|   |-struct
-|   |-X
-|   |-{
-|   |-}
-|   `-;
-|-TemplateDeclaration
-| |-template
-| |-<
-| |-UnknownDeclaration
-| | |-class
-| | `-T
-| |->
-| `-SimpleDeclaration
-|   |-struct
-|   |-X
-|   |-<
-|   |-T
-|   |-*
-|   |->
-|   |-{
-|   |-}
-|   `-;
-|-TemplateDeclaration
-| |-template
-| |-<
-| |->
-| `-SimpleDeclaration
-|   |-struct
-|   |-X
-|   |-<
-|   |-int
-|   |->
-|   |-{
-|   |-}
-|   `-;
-|-ExplicitTemplateInstantiation
-| |-template
-| `-SimpleDeclaration
-|   |-struct
-|   |-X
-|   |-<
-|   |-double
-|   |->
-|   `-;
-`-ExplicitTemplateInstantiation
-  |-extern
-  |-template
-  `-SimpleDeclaration
-    |-struct
-    |-X
-    |-<
-    |-float
-    |->
-    `-;
-)txt"));
+      {R"txt(
+ExplicitTemplateInstantiation
+|-extern
+|-template
+`-SimpleDeclaration
+  |-struct
+  |-X
+  |-<
+  |-float
+  |->
+  `-;
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, ClassTemplateSpecialization_Partial) {
+  if (!GetParam().isCXX()) {
+    return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+      R"cpp(
+template <class T> struct X {};
+[[template <class T> struct X<T*> {};]]
+)cpp",
+      {R"txt(
+TemplateDeclaration
+|-template
+|-<
+|-UnknownDeclaration
+| |-class
+| `-T
+|->
+`-SimpleDeclaration
+  |-struct
+  |-X
+  |-<
+  |-T
+  |-*
+  |->
+  |-{
+  |-}
+  `-;
+)txt"}));
+}
+
+TEST_P(SyntaxTreeTest, ClassTemplateSpecialization_Full) {
+  if (!GetParam().isCXX()) {
+    return;
+  }
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
+      R"cpp(
+template <class T> struct X {};
+[[template <> struct X<int> {};]]
+)cpp",
+      {R"txt(
+TemplateDeclaration
+|-template
+|-<
+|->
+`-SimpleDeclaration
+  |-struct
+  |-X
+  |-<
+  |-int
+  |->
+  |-{
+  |-}
+  `-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, UsingType) {


        


More information about the cfe-commits mailing list