aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2012-11-07 00:33:12 +0000
committerManuel Klimek <klimek@google.com>2012-11-07 00:33:12 +0000
commitcb7b45e6d80c14d7d12db1eff17dc14b4ae8a35e (patch)
tree6b539f5a022f802e0abd47560f914400a156d0ce /test
parent530564196fe7e2e30fbc2b0edae45975447583e0 (diff)
Create helper functions in StmtDumper for outputting the indentation, newlines, and brackets.
This is preparation for adding Decl dumping. Patch by Philip Craig. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167509 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Misc/ast-dump-stmt.c35
-rw-r--r--test/Misc/ast-dump-stmt.m36
2 files changed, 71 insertions, 0 deletions
diff --git a/test/Misc/ast-dump-stmt.c b/test/Misc/ast-dump-stmt.c
new file mode 100644
index 0000000000..d7fdce8d59
--- /dev/null
+++ b/test/Misc/ast-dump-stmt.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -ast-dump -ast-dump-filter Test %s | FileCheck -strict-whitespace %s
+
+int TestLocation = 0;
+// CHECK: Dumping TestLocation
+// CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <{{.*}}:3:20> 'int' 0
+
+int TestIndent = 1 + (1);
+// CHECK: Dumping TestIndent
+// CHECK-NEXT: {{\(BinaryOperator[^()]*$}}
+// CHECK-NEXT: {{^ \(IntegerLiteral.*0[^()]*\)$}}
+// CHECK-NEXT: {{^ \(ParenExpr.*0[^()]*$}}
+// CHECK-NEXT: {{^ \(IntegerLiteral.*0[^()]*\)\)\)$}}
+
+void TestDeclStmt() {
+ int x = 0;
+ int y, z;
+}
+// CHECK: Dumping TestDeclStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: int x =
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: DeclStmt
+// CHECK-NEXT: int y
+// CHECK-NEXT: int z
+
+int TestOpaqueValueExpr = 0 ?: 1;
+// CHECK: Dumping TestOpaqueValueExpr
+// CHECK-NEXT: BinaryConditionalOperator
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: OpaqueValueExpr
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: OpaqueValueExpr
+// CHECK-NEXT: IntegerLiteral
+// CHECK-NEXT: IntegerLiteral
diff --git a/test/Misc/ast-dump-stmt.m b/test/Misc/ast-dump-stmt.m
new file mode 100644
index 0000000000..8dfee74ab5
--- /dev/null
+++ b/test/Misc/ast-dump-stmt.m
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -Wno-unused -fblocks -fobjc-exceptions -ast-dump -ast-dump-filter Test %s | FileCheck -strict-whitespace %s
+
+void TestBlockExpr(int x) {
+ ^{ x; };
+}
+// CHECK: Dumping TestBlockExpr
+// CHECK: BlockExpr{{.*}} decl=
+// CHECK-NEXT: capture ParmVar
+// CHECK-NEXT: CompoundStmt
+
+void TestExprWithCleanup(int x) {
+ ^{ x; };
+}
+// CHECK: Dumping TestExprWithCleanup
+// CHECK: ExprWithCleanups
+// CHECK-NEXT: cleanup Block
+// CHECK-NEXT: BlockExpr
+
+@interface A
+@end
+
+void TestObjCAtCatchStmt() {
+ @try {
+ } @catch(A *a) {
+ } @catch(...) {
+ } @finally {
+ }
+}
+// CHECK: Dumping TestObjCAtCatchStmt
+// CHECK: ObjCAtTryStmt
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: ObjCAtCatchStmt{{.*}} catch parm = "A *a"
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: ObjCAtCatchStmt{{.*}} catch all
+// CHECK-NEXT: CompoundStmt
+// CHECK-NEXT: ObjCAtFinallyStmt