r348008 - Adding tests for -ast-dump; NFC.

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 30 09:19:07 PST 2018


Author: aaronballman
Date: Fri Nov 30 09:19:06 2018
New Revision: 348008

URL: http://llvm.org/viewvc/llvm-project?rev=348008&view=rev
Log:
Adding tests for -ast-dump; NFC.

This adds tests for GenericSelectionExpr; note that it points out a minor whitespace bug for selection expression cases.

Modified:
    cfe/trunk/test/Misc/ast-dump-stmt.c

Modified: cfe/trunk/test/Misc/ast-dump-stmt.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-dump-stmt.c?rev=348008&r1=348007&r2=348008&view=diff
==============================================================================
--- cfe/trunk/test/Misc/ast-dump-stmt.c (original)
+++ cfe/trunk/test/Misc/ast-dump-stmt.c Fri Nov 30 09:19:06 2018
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -ast-dump -ast-dump-filter Test %s | FileCheck -strict-whitespace %s
+// RUN: %clang_cc1 -std=c11 -ast-dump -ast-dump-filter Test %s | FileCheck -strict-whitespace %s
 
 int TestLocation = 0;
 // CHECK:      VarDecl{{.*}}TestLocation
@@ -65,3 +65,64 @@ void TestUnaryOperatorExpr(void) {
   // CHECK-NEXT:     ImplicitCastExpr
   // CHECK-NEXT:       DeclRefExpr{{.*}}'T2' 'int'
 }
+
+void TestGenericSelectionExpressions(int i) {
+  _Generic(i, int : 12);
+  // CHECK: GenericSelectionExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:23> 'int'
+  // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
+  // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
+  // FIXME: note that the following test line has a spurious whitespace.
+  // CHECK-NEXT: case  'int' selected
+  // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
+  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:21> 'int' 12
+  _Generic(i, int : 12, default : 0);
+  // CHECK: GenericSelectionExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:36> 'int'
+  // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
+  // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
+  // FIXME: note that the following test line has a spurious whitespace.
+  // CHECK-NEXT: case  'int' selected
+  // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
+  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:21> 'int' 12
+  // CHECK-NEXT: default
+  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:35> 'int' 0
+  _Generic(i, default : 0, int : 12);
+  // CHECK: GenericSelectionExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:36> 'int'
+  // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
+  // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
+  // CHECK-NEXT: default
+  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:25> 'int' 0
+  // FIXME: note that the following test line has a spurious whitespace.
+  // CHECK-NEXT: case  'int' selected
+  // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
+  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:34> 'int' 12
+  _Generic(i, int : 12, float : 10, default : 100);
+  // CHECK: GenericSelectionExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:50> 'int'
+  // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
+  // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
+  // FIXME: note that the following test line has a spurious whitespace.
+  // CHECK-NEXT: case  'int' selected
+  // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
+  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:21> 'int' 12
+  // FIXME: note that the following test line has a spurious whitespace.
+  // CHECK-NEXT: case  'float'
+  // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'float'
+  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:33> 'int' 10
+  // CHECK-NEXT: default
+  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:47> 'int' 100
+
+  int j = _Generic(i, int : 12);
+  // CHECK: DeclStmt 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:32>
+  // CHECK-NEXT: VarDecl 0x{{[^ ]*}} <col:3, col:31> col:7 j 'int' cinit
+  // CHECK-NEXT: GenericSelectionExpr 0x{{[^ ]*}} <col:11, col:31> 'int'
+  // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}}
+  // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:20> 'int' lvalue ParmVar 0x{{[^ ]*}} 'i' 'int'
+  // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
+  // FIXME: note that the following test line has a spurious whitespace.
+  // CHECK-NEXT: case  'int' selected
+  // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'int'
+  // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} <col:29> 'int' 12
+}




More information about the cfe-commits mailing list