Author: Eduardo Caldas Date: 2020-08-24T14:31:45Z New Revision: 4e8dd506e66642329dcd530524f43b0d2b528521
URL: https://github.com/llvm/llvm-project/commit/4e8dd506e66642329dcd530524f43b0d2b528521 DIFF: https://github.com/llvm/llvm-project/commit/4e8dd506e66642329dcd530524f43b0d2b528521.diff LOG: [SyntaxTree] Split array declarator tests Differential Revision: https://reviews.llvm.org/D86437 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 994dd68028ea..a8e675468257 100644 --- a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp +++ b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp @@ -3342,45 +3342,63 @@ void test() { )txt")); } -TEST_P(SyntaxTreeTest, ArraySubscriptsInDeclarators) { +TEST_P(SyntaxTreeTest, ArrayDeclarator_Simple) { EXPECT_TRUE(treeDumpEqual( R"cpp( int a[10]; +)cpp", + R"txt( +*: TranslationUnit +`-SimpleDeclaration + |-int + |-SimpleDeclarator + | |-a + | `-ArraySubscript + | |-[ + | |-IntegerLiteralExpression + | | `-10 + | `-] + `-; +)txt")); +} + +TEST_P(SyntaxTreeTest, ArrayDeclarator_Multidimensional) { + EXPECT_TRUE(treeDumpEqual( + R"cpp( int b[1][2][3]; +)cpp", + R"txt( +*: TranslationUnit +`-SimpleDeclaration + |-int + |-SimpleDeclarator + | |-b + | |-ArraySubscript + | | |-[ + | | |-IntegerLiteralExpression + | | | `-1 + | | `-] + | |-ArraySubscript + | | |-[ + | | |-IntegerLiteralExpression + | | | `-2 + | | `-] + | `-ArraySubscript + | |-[ + | |-IntegerLiteralExpression + | | `-3 + | `-] + `-; +)txt")); +} + +TEST_P(SyntaxTreeTest, ArrayDeclarator_UnknownBound) { + EXPECT_TRUE(treeDumpEqual( + R"cpp( int c[] = {1,2,3}; )cpp", R"txt( *: TranslationUnit -|-SimpleDeclaration -| |-int -| |-SimpleDeclarator -| | |-a -| | `-ArraySubscript -| | |-[ -| | |-IntegerLiteralExpression -| | | `-10 -| | `-] -| `-; -|-SimpleDeclaration -| |-int -| |-SimpleDeclarator -| | |-b -| | |-ArraySubscript -| | | |-[ -| | | |-IntegerLiteralExpression -| | | | `-1 -| | | `-] -| | |-ArraySubscript -| | | |-[ -| | | |-IntegerLiteralExpression -| | | | `-2 -| | | `-] -| | `-ArraySubscript -| | |-[ -| | |-IntegerLiteralExpression -| | | `-3 -| | `-] -| `-; `-SimpleDeclaration |-int |-SimpleDeclarator @@ -3405,7 +3423,7 @@ int c[] = {1,2,3}; )txt")); } -TEST_P(SyntaxTreeTest, StaticArraySubscriptsInDeclarators) { +TEST_P(SyntaxTreeTest, ArrayDeclarator_Static) { if (!GetParam().isC99OrLater()) { return; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits