eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86441

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

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===================================================================
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -3051,84 +3051,105 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, ExplicitTemplateInstantations) {
+TEST_P(SyntaxTreeTest, ExplicitTemplateInstantation_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, ExplicitTemplateInstantation_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, TemplateSpecialization_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, TemplateSpecialization_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) {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to