aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Tooling/Syntax/TreeTest.cpp
diff options
context:
space:
mode:
authorEduardo Caldas <ecaldas@google.com>2020-06-22 16:04:54 +0000
committerEduardo Caldas <ecaldas@google.com>2020-06-25 15:37:53 +0000
commit7f7f8564808b51aa62744edf75c07c0df102056a (patch)
treefce822ccd70c5e3c60c1e83c347c185178d6e1bb /clang/unittests/Tooling/Syntax/TreeTest.cpp
parentc9e8c9e3ea2681dc18dd3a2d43d6aa8f37252649 (diff)
downloadllvm-7f7f8564808b51aa62744edf75c07c0df102056a.zip
llvm-7f7f8564808b51aa62744edf75c07c0df102056a.tar.gz
llvm-7f7f8564808b51aa62744edf75c07c0df102056a.tar.bz2
Add `BoolLiteralExpression` to SyntaxTree
Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D82310
Diffstat (limited to 'clang/unittests/Tooling/Syntax/TreeTest.cpp')
-rw-r--r--clang/unittests/Tooling/Syntax/TreeTest.cpp52
1 files changed, 45 insertions, 7 deletions
diff --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp b/clang/unittests/Tooling/Syntax/TreeTest.cpp
index 5f48ef1..d32ce62 100644
--- a/clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -69,6 +69,10 @@ struct TestClangConfig {
Language == Lang_CXX20;
}
+ bool hasBoolType() const {
+ return Language == Lang_C89 || Language == Lang_C99;
+ }
+
bool supportsCXXDynamicExceptionSpecification() const {
return Language == Lang_CXX03 || Language == Lang_CXX11 ||
Language == Lang_CXX14;
@@ -1228,6 +1232,40 @@ void test() {
)txt"));
}
+TEST_P(SyntaxTreeTest, BoolLiteral) {
+ if (GetParam().hasBoolType()) {
+ return;
+ }
+ EXPECT_TRUE(treeDumpEqual(
+ R"cpp(
+void test() {
+ true;
+ false;
+}
+)cpp",
+ R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+ |-void
+ |-SimpleDeclarator
+ | |-test
+ | `-ParametersAndQualifiers
+ | |-(
+ | `-)
+ `-CompoundStatement
+ |-{
+ |-ExpressionStatement
+ | |-BoolLiteralExpression
+ | | `-true
+ | `-;
+ |-ExpressionStatement
+ | |-BoolLiteralExpression
+ | | `-false
+ | `-;
+ `-}
+)txt"));
+}
+
TEST_P(SyntaxTreeTest, IntegerLiteral) {
EXPECT_TRUE(treeDumpEqual(
R"cpp(
@@ -1691,18 +1729,18 @@ void test(int a) {
|-{
|-ExpressionStatement
| |-BinaryOperatorExpression
- | | |-UnknownExpression
+ | | |-BoolLiteralExpression
| | | `-true
| | |-||
- | | `-UnknownExpression
+ | | `-BoolLiteralExpression
| | `-false
| `-;
|-ExpressionStatement
| |-BinaryOperatorExpression
- | | |-UnknownExpression
+ | | |-BoolLiteralExpression
| | | `-true
| | |-or
- | | `-UnknownExpression
+ | | `-BoolLiteralExpression
| | `-false
| `-;
|-ExpressionStatement
@@ -2556,7 +2594,7 @@ static_assert(true);
|-StaticAssertDeclaration
| |-static_assert
| |-(
-| |-UnknownExpression
+| |-BoolLiteralExpression
| | `-true
| |-,
| |-UnknownExpression
@@ -2566,7 +2604,7 @@ static_assert(true);
`-StaticAssertDeclaration
|-static_assert
|-(
- |-UnknownExpression
+ |-BoolLiteralExpression
| `-true
|-)
`-;
@@ -3186,7 +3224,7 @@ int b() noexcept(true);
| |-)
| |-noexcept
| |-(
- | |-UnknownExpression
+ | |-BoolLiteralExpression
| | `-true
| `-)
`-;