[PATCH] D85316: [SyntaxTree] Proposition of new tree dump

Eduardo Caldas via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 5 08:13:03 PDT 2020


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

Some key choices to highlight:

- Surround Tokens with "''"
- Do not print `UnknownRole`, to reduce noise
- Surround Roles with "<", to clarify the difference in meaning


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85316

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


Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===================================================================
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -307,45 +307,45 @@
 }
 )cpp",
       R"txt(
-*: TranslationUnit
+TranslationUnit   <*>
 `-SimpleDeclaration
-  |-int
-  |-SimpleDeclarator
-  | |-main
+  |-'int'
+  |-SimpleDeclarator   <SimpleDeclaration_declarator>
+  | |-'main'
   | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
+  |   |-'('   <OpenParen>
+  |   `-')'   <CloseParen>
   `-CompoundStatement
-    |-{
-    |-IfStatement
-    | |-if
-    | |-(
+    |-'{'   <OpenParen>
+    |-IfStatement   <CompoundStatement_statement>
+    | |-'if'   <IntroducerKeyword>
+    | |-'('
     | |-IntegerLiteralExpression
-    | | `-1
-    | |-)
-    | `-CompoundStatement
-    |   |-{
-    |   `-}
-    |-IfStatement
-    | |-if
-    | |-(
+    | | `-'1'   <LiteralToken>
+    | |-')'
+    | `-CompoundStatement   <IfStatement_thenStatement>
+    |   |-'{'   <OpenParen>
+    |   `-'}'   <CloseParen>
+    |-IfStatement   <CompoundStatement_statement>
+    | |-'if'   <IntroducerKeyword>
+    | |-'('
     | |-IntegerLiteralExpression
-    | | `-1
-    | |-)
-    | |-CompoundStatement
-    | | |-{
-    | | `-}
-    | |-else
-    | `-IfStatement
-    |   |-if
-    |   |-(
+    | | `-'1'   <LiteralToken>
+    | |-')'
+    | |-CompoundStatement   <IfStatement_thenStatement>
+    | | |-'{'   <OpenParen>
+    | | `-'}'   <CloseParen>
+    | |-'else'   <IfStatement_elseKeyword>
+    | `-IfStatement   <IfStatement_elseStatement>
+    |   |-'if'   <IntroducerKeyword>
+    |   |-'('
     |   |-IntegerLiteralExpression
-    |   | `-0
-    |   |-)
-    |   `-CompoundStatement
-    |     |-{
-    |     `-}
-    `-}
+    |   | `-'0'   <LiteralToken>
+    |   |-')'
+    |   `-CompoundStatement   <IfStatement_thenStatement>
+    |     |-'{'   <OpenParen>
+    |     `-'}'   <CloseParen>
+    `-'}'   <CloseParen>
 )txt"));
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85316.283249.patch
Type: text/x-patch
Size: 1996 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200805/9e9d18be/attachment-0001.bin>


More information about the cfe-commits mailing list