diff options
author | Eduardo Caldas <ecaldas@google.com> | 2020-06-25 16:25:42 +0000 |
---|---|---|
committer | Eduardo Caldas <ecaldas@google.com> | 2020-06-25 17:05:08 +0000 |
commit | 466e8b7ea6e162d48cac42ccda210bdeb11080e3 (patch) | |
tree | 30de652041435da57ae00703c6f389511c44b0f7 /clang/unittests/Tooling/Syntax/TreeTest.cpp | |
parent | 221d7bbe49cceb0e408f0f46d9f8371e6c9fee2c (diff) | |
download | llvm-466e8b7ea6e162d48cac42ccda210bdeb11080e3.zip llvm-466e8b7ea6e162d48cac42ccda210bdeb11080e3.tar.gz llvm-466e8b7ea6e162d48cac42ccda210bdeb11080e3.tar.bz2 |
Add StringLiteral to SyntaxTree
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D82360
Diffstat (limited to 'clang/unittests/Tooling/Syntax/TreeTest.cpp')
-rw-r--r-- | clang/unittests/Tooling/Syntax/TreeTest.cpp | 105 |
1 files changed, 104 insertions, 1 deletions
diff --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp b/clang/unittests/Tooling/Syntax/TreeTest.cpp index 0a20950..bc2a65b 100644 --- a/clang/unittests/Tooling/Syntax/TreeTest.cpp +++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp @@ -1399,6 +1399,109 @@ void test() { )txt")); } +TEST_P(SyntaxTreeTest, StringLiteral) { + EXPECT_TRUE(treeDumpEqual( + R"cpp( +void test() { + "a\n\0\x20"; + L"αβ"; +} +)cpp", + R"txt( +*: TranslationUnit +`-SimpleDeclaration + |-void + |-SimpleDeclarator + | |-test + | `-ParametersAndQualifiers + | |-( + | `-) + `-CompoundStatement + |-{ + |-ExpressionStatement + | |-StringLiteralExpression + | | `-"a\n\0\x20" + | `-; + |-ExpressionStatement + | |-StringLiteralExpression + | | `-L"αβ" + | `-; + `-} +)txt")); +} + +TEST_P(SyntaxTreeTest, StringLiteralUtf) { + if (!GetParam().isCXX11OrLater()) { + return; + } + EXPECT_TRUE(treeDumpEqual( + R"cpp( +void test() { + u8"a\x1f\x05"; + u"C++抽象構文木"; + U"📖🌲\n"; +} +)cpp", + R"txt( +*: TranslationUnit +`-SimpleDeclaration + |-void + |-SimpleDeclarator + | |-test + | `-ParametersAndQualifiers + | |-( + | `-) + `-CompoundStatement + |-{ + |-ExpressionStatement + | |-StringLiteralExpression + | | `-u8"a\x1f\x05" + | `-; + |-ExpressionStatement + | |-StringLiteralExpression + | | `-u"C++抽象構文木" + | `-; + |-ExpressionStatement + | |-StringLiteralExpression + | | `-U"📖🌲\n" + | `-; + `-} +)txt")); +} + +TEST_P(SyntaxTreeTest, StringLiteralRaw) { + if (!GetParam().isCXX11OrLater()) { + return; + } + EXPECT_TRUE(treeDumpEqual( + R"cpp( +void test() { + R"SyntaxTree( + Hello "Syntax" \" + )SyntaxTree"; +} +)cpp", + R"txt( +*: TranslationUnit +`-SimpleDeclaration + |-void + |-SimpleDeclarator + | |-test + | `-ParametersAndQualifiers + | |-( + | `-) + `-CompoundStatement + |-{ + |-ExpressionStatement + | |-StringLiteralExpression + | | `-R"SyntaxTree( + Hello "Syntax" \" + )SyntaxTree" + | `-; + `-} +)txt")); +} + TEST_P(SyntaxTreeTest, IntegerLiteral) { EXPECT_TRUE(treeDumpEqual( R"cpp( @@ -2730,7 +2833,7 @@ static_assert(true); | |-BoolLiteralExpression | | `-true | |-, -| |-UnknownExpression +| |-StringLiteralExpression | | `-"message" | |-) | `-; |