[PATCH] D84146: [AST][RecoveryExpr] Add recovery-ast tests for C language, NFC.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 20 02:48:47 PDT 2020
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: clang.
some examples are working already.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D84146
Files:
clang/test/AST/ast-dump-recovery.c
Index: clang/test/AST/ast-dump-recovery.c
===================================================================
--- /dev/null
+++ clang/test/AST/ast-dump-recovery.c
@@ -0,0 +1,56 @@
+// RUN: not %clang_cc1 -triple x86_64-unknown-unknown -frecovery-ast -fno-recovery-ast-type -ast-dump %s | FileCheck -strict-whitespace %s
+
+int some_func(int);
+
+// CHECK: VarDecl {{.*}} unmatch_arg_call 'int' cinit
+// CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT: `-DeclRefExpr {{.*}} 'some_func'
+int unmatch_arg_call = some_func();
+
+const int a = 1;
+
+// CHECK: VarDecl {{.*}} postfix_inc
+// CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT: `-DeclRefExpr {{.*}} 'a'
+int postfix_inc = a++;
+
+// CHECK: VarDecl {{.*}} prefix_inc
+// CHECK-NEXT:`-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT: `-DeclRefExpr {{.*}} 'a'
+int prefix_inc = ++a;
+
+// CHECK: VarDecl {{.*}} unary_address
+// CHECK-NEXT:`-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT: `-ParenExpr {{.*}}
+// CHECK-NEXT: `-BinaryOperator {{.*}} '+'
+// CHECK-NEXT: |-ImplicitCastExpr
+// CHECK-NEXT: | `-DeclRefExpr {{.*}} 'a'
+// CHECK-NEXT: `-IntegerLiteral {{.*}} 'int'
+int unary_address = &(a + 1);
+
+// CHECK: VarDecl {{.*}} unary_bitinverse
+// CHECK-NEXT:`-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT: `-ParenExpr {{.*}}
+// CHECK-NEXT: `-BinaryOperator {{.*}} '+'
+// CHECK-NEXT: |-ImplicitCastExpr
+// CHECK-NEXT: | `-ImplicitCastExpr
+// CHECK-NEXT: | `-DeclRefExpr {{.*}} 'a'
+// CHECK-NEXT: `-FloatingLiteral {{.*}} 'double'
+int unary_bitinverse = ~(a + 0.0);
+
+// CHECK: VarDecl {{.*}} ternary 'int' cinit
+// CHECK-NEXT: `-RecoveryExpr {{.*}}
+// CHECK-NEXT: |-DeclRefExpr {{.*}} 'a'
+// CHECK-NEXT: |-TypoExpr {{.*}}
+// CHECK-NEXT: `-DeclRefExpr {{.*}} 'a'
+// FIXME: The TypoExpr should never be print, and should be downgraded to
+// RecoveryExpr -- typo correction is performed too early in C-only codepath,
+// which makes no correction when clang finishes the full expr (Sema::Sema::ActOnFinishFullExpr).
+// this will be fixed when we support dependent mechanism and delayed typo correction for C.
+int ternary = a ? undef : a;
+
+void test1() {
+ // CHECK: `-RecoveryExpr {{.*}} contains-errors
+ // CHECK-NEXT: `-DeclRefExpr {{.*}} 'a' 'const int'
+ static int foo = a++; // verify no crash on local static var decl.
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84146.279159.patch
Type: text/x-patch
Size: 2449 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200720/4f2c873b/attachment.bin>
More information about the cfe-commits
mailing list