aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Tooling/Syntax/TreeTest.cpp
diff options
context:
space:
mode:
authorEduardo Caldas <ecaldas@google.com>2020-07-01 13:58:18 +0000
committerEduardo Caldas <ecaldas@google.com>2020-07-02 06:28:41 +0000
commitfdbd78333fc6f1deb3037d0961130f05dce059e7 (patch)
tree4f2f9962de2c76b7f9e40a20877629d1db5c15a5 /clang/unittests/Tooling/Syntax/TreeTest.cpp
parentc59aec0ca1edac409d8789956049ae13af24e370 (diff)
downloadllvm-fdbd78333fc6f1deb3037d0961130f05dce059e7.zip
llvm-fdbd78333fc6f1deb3037d0961130f05dce059e7.tar.gz
llvm-fdbd78333fc6f1deb3037d0961130f05dce059e7.tar.bz2
Add parenthesized expression to SyntaxTree
Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D82960
Diffstat (limited to 'clang/unittests/Tooling/Syntax/TreeTest.cpp')
-rw-r--r--clang/unittests/Tooling/Syntax/TreeTest.cpp59
1 files changed, 57 insertions, 2 deletions
diff --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp b/clang/unittests/Tooling/Syntax/TreeTest.cpp
index 7a438f1..094a495 100644
--- a/clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -1129,6 +1129,61 @@ void test(S s) {
)txt"));
}
+TEST_P(SyntaxTreeTest, ParenExpr) {
+ EXPECT_TRUE(treeDumpEqual(
+ R"cpp(
+void test() {
+ (1);
+ ((1));
+ (1 + (2));
+}
+)cpp",
+ R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+ |-void
+ |-SimpleDeclarator
+ | |-test
+ | `-ParametersAndQualifiers
+ | |-(
+ | `-)
+ `-CompoundStatement
+ |-{
+ |-ExpressionStatement
+ | |-ParenExpression
+ | | |-(
+ | | |-IntegerLiteralExpression
+ | | | `-1
+ | | `-)
+ | `-;
+ |-ExpressionStatement
+ | |-ParenExpression
+ | | |-(
+ | | |-ParenExpression
+ | | | |-(
+ | | | |-IntegerLiteralExpression
+ | | | | `-1
+ | | | `-)
+ | | `-)
+ | `-;
+ |-ExpressionStatement
+ | |-ParenExpression
+ | | |-(
+ | | |-BinaryOperatorExpression
+ | | | |-IntegerLiteralExpression
+ | | | | `-1
+ | | | |-+
+ | | | `-ParenExpression
+ | | | |-(
+ | | | |-IntegerLiteralExpression
+ | | | | `-2
+ | | | `-)
+ | | `-)
+ | `-;
+ `-}
+)txt"));
+}
+
TEST_P(SyntaxTreeTest, IntegerLiteral) {
EXPECT_TRUE(treeDumpEqual(
R"cpp(
@@ -2040,7 +2095,7 @@ void test(int a, int b) {
|-{
|-ExpressionStatement
| |-BinaryOperatorExpression
- | | |-UnknownExpression
+ | | |-ParenExpression
| | | |-(
| | | |-BinaryOperatorExpression
| | | | |-IntegerLiteralExpression
@@ -2050,7 +2105,7 @@ void test(int a, int b) {
| | | | `-2
| | | `-)
| | |-*
- | | `-UnknownExpression
+ | | `-ParenExpression
| | |-(
| | |-BinaryOperatorExpression
| | | |-IntegerLiteralExpression