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/D86345

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
@@ -102,282 +102,196 @@
 }
 
 TEST_P(SyntaxTreeTest, If) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
       R"cpp(
-int main() {
-  if (1) {}
-  if (1) {} else if (0) {}
+void test() {
+  [[if (1) {}]]
+  [[if (1) {} else if (0) {}]]
 }
 )cpp",
-      R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-int
-  |-SimpleDeclarator
-  | |-main
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
+      {R"txt(
+IfStatement
+|-if
+|-(
+|-IntegerLiteralExpression
+| `-1
+|-)
+`-CompoundStatement
+  |-{
+  `-}
+  )txt",
+       R"txt(
+IfStatement
+|-if
+|-(
+|-IntegerLiteralExpression
+| `-1
+|-)
+|-CompoundStatement
+| |-{
+| `-}
+|-else
+`-IfStatement
+  |-if
+  |-(
+  |-IntegerLiteralExpression
+  | `-0
+  |-)
   `-CompoundStatement
     |-{
-    |-IfStatement
-    | |-if
-    | |-(
-    | |-IntegerLiteralExpression
-    | | `-1
-    | |-)
-    | `-CompoundStatement
-    |   |-{
-    |   `-}
-    |-IfStatement
-    | |-if
-    | |-(
-    | |-IntegerLiteralExpression
-    | | `-1
-    | |-)
-    | |-CompoundStatement
-    | | |-{
-    | | `-}
-    | |-else
-    | `-IfStatement
-    |   |-if
-    |   |-(
-    |   |-IntegerLiteralExpression
-    |   | `-0
-    |   |-)
-    |   `-CompoundStatement
-    |     |-{
-    |     `-}
     `-}
-)txt"));
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, For) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
       R"cpp(
 void test() {
-  for (;;)  {}
+  [[for (;;)  {}]]
 }
 )cpp",
-      R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
-  `-CompoundStatement
-    |-{
-    |-ForStatement
-    | |-for
-    | |-(
-    | |-;
-    | |-;
-    | |-)
-    | `-CompoundStatement
-    |   |-{
-    |   `-}
-    `-}
-)txt"));
+      {R"txt(
+ForStatement
+|-for
+|-(
+|-;
+|-;
+|-)
+`-CompoundStatement
+  |-{
+  `-}
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, RangeBasedFor) {
   if (!GetParam().isCXX11OrLater()) {
     return;
   }
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
       R"cpp(
 void test() {
   int a[3];
-  for (int x : a)
-    ;
+  [[for (int x : a)
+    ;]]
 }
 )cpp",
-      R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
-  `-CompoundStatement
-    |-{
-    |-DeclarationStatement
-    | |-SimpleDeclaration
-    | | |-int
-    | | `-SimpleDeclarator
-    | |   |-a
-    | |   `-ArraySubscript
-    | |     |-[
-    | |     |-IntegerLiteralExpression
-    | |     | `-3
-    | |     `-]
-    | `-;
-    |-RangeBasedForStatement
-    | |-for
-    | |-(
-    | |-SimpleDeclaration
-    | | |-int
-    | | |-SimpleDeclarator
-    | | | `-x
-    | | `-:
-    | |-IdExpression
-    | | `-UnqualifiedId
-    | |   `-a
-    | |-)
-    | `-EmptyStatement
-    |   `-;
-    `-}
-)txt"));
+      {R"txt(
+RangeBasedForStatement
+|-for
+|-(
+|-SimpleDeclaration
+| |-int
+| |-SimpleDeclarator
+| | `-x
+| `-:
+|-IdExpression
+| `-UnqualifiedId
+|   `-a
+|-)
+`-EmptyStatement
+  `-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, DeclarationStatement) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
       R"cpp(
 void test() {
-  int a = 10;
+  [[int a = 10;]]
 }
 )cpp",
-      R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
-  `-CompoundStatement
-    |-{
-    |-DeclarationStatement
-    | |-SimpleDeclaration
-    | | |-int
-    | | `-SimpleDeclarator
-    | |   |-a
-    | |   |-=
-    | |   `-IntegerLiteralExpression
-    | |     `-10
-    | `-;
-    `-}
-)txt"));
+      {R"txt(
+DeclarationStatement
+|-SimpleDeclaration
+| |-int
+| `-SimpleDeclarator
+|   |-a
+|   |-=
+|   `-IntegerLiteralExpression
+|     `-10
+`-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, Switch) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
       R"cpp(
 void test() {
-  switch (1) {
+  [[switch (1) {
     case 0:
     default:;
-  }
+  }]]
 }
 )cpp",
-      R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
-  `-CompoundStatement
-    |-{
-    |-SwitchStatement
-    | |-switch
-    | |-(
-    | |-IntegerLiteralExpression
-    | | `-1
-    | |-)
-    | `-CompoundStatement
-    |   |-{
-    |   |-CaseStatement
-    |   | |-case
-    |   | |-IntegerLiteralExpression
-    |   | | `-0
-    |   | |-:
-    |   | `-DefaultStatement
-    |   |   |-default
-    |   |   |-:
-    |   |   `-EmptyStatement
-    |   |     `-;
-    |   `-}
-    `-}
-)txt"));
+      {R"txt(
+SwitchStatement
+|-switch
+|-(
+|-IntegerLiteralExpression
+| `-1
+|-)
+`-CompoundStatement
+  |-{
+  |-CaseStatement
+  | |-case
+  | |-IntegerLiteralExpression
+  | | `-0
+  | |-:
+  | `-DefaultStatement
+  |   |-default
+  |   |-:
+  |   `-EmptyStatement
+  |     `-;
+  `-}
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, While) {
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
       R"cpp(
 void test() {
-  while (1) { continue; break; }
+  [[while (1) { continue; break; }]]
 }
 )cpp",
-      R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
-  `-CompoundStatement
-    |-{
-    |-WhileStatement
-    | |-while
-    | |-(
-    | |-IntegerLiteralExpression
-    | | `-1
-    | |-)
-    | `-CompoundStatement
-    |   |-{
-    |   |-ContinueStatement
-    |   | |-continue
-    |   | `-;
-    |   |-BreakStatement
-    |   | |-break
-    |   | `-;
-    |   `-}
-    `-}
-)txt"));
+      {R"txt(
+WhileStatement
+|-while
+|-(
+|-IntegerLiteralExpression
+| `-1
+|-)
+`-CompoundStatement
+  |-{
+  |-ContinueStatement
+  | |-continue
+  | `-;
+  |-BreakStatement
+  | |-break
+  | `-;
+  `-}
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, UnhandledStatement) {
   // Unhandled statements should end up as 'unknown statement'.
   // This example uses a 'label statement', which does not yet have a syntax
   // counterpart.
-  EXPECT_TRUE(treeDumpEqual(
+  EXPECT_TRUE(treeDumpEqualOnAnnotations(
       R"cpp(
-int main() {
-  foo: return 100;
+int test() {
+  [[foo: return 100;]]
 }
 )cpp",
-      R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-int
-  |-SimpleDeclarator
-  | |-main
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
-  `-CompoundStatement
-    |-{
-    |-UnknownStatement
-    | |-foo
-    | |-:
-    | `-ReturnStatement
-    |   |-return
-    |   |-IntegerLiteralExpression
-    |   | `-100
-    |   `-;
-    `-}
-)txt"));
+      {R"txt(
+UnknownStatement
+|-foo
+|-:
+`-ReturnStatement
+  |-return
+  |-IntegerLiteralExpression
+  | `-100
+  `-;
+)txt"}));
 }
 
 TEST_P(SyntaxTreeTest, Expressions) {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to