1 // RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -triple x86_64-apple-darwin12 -Wno-error=invalid-gnu-asm-cast %s > %t 2>&1
2 // RUN: FileCheck --input-file=%t --check-prefix=CHECK %s
4 // This file is the C version of cfg.cpp.
5 // Tests that are C-specific should go into this file.
7 // CHECK-LABEL: void checkWrap(int i)
9 // CHECK-NEXT: Succs (1): B1
11 // CHECK: Succs (21): B2 B3 B4 B5 B6 B7 B8 B9
12 // CHECK: B10 B11 B12 B13 B14 B15 B16 B17 B18 B19
15 // CHECK-NEXT: Preds (21): B2 B3 B4 B5 B6 B7 B8 B9
16 // CHECK-NEXT: B10 B11 B12 B13 B14 B15 B16 B17 B18 B19
17 // CHECK-NEXT: B20 B21 B1
18 void checkWrap(int i
) {
43 // CHECK-LABEL: void checkGCCAsmRValueOutput(void)
44 // CHECK: [B2 (ENTRY)]
45 // CHECK-NEXT: Succs (1): B1
47 // CHECK-NEXT: 1: int arg
49 // CHECK-NEXT: 3: (int)[B1.2] (CStyleCastExpr, NoOp, int)
50 // CHECK-NEXT: 4: asm ("" : "=r" ([B1.3]));
52 // CHECK-NEXT: 6: asm ("" : "=r" ([B1.5]));
53 void checkGCCAsmRValueOutput(void) {
55 __asm__("" : "=r"((int)arg
)); // rvalue output operand
56 __asm__("" : "=r"(arg
)); // lvalue output operand
59 // CHECK-LABEL: int overlap_compare(int x)
62 // CHECK-NEXT: 2: return [B2.1];
63 // CHECK-NEXT: Preds (1): B3(Unreachable)
64 // CHECK-NEXT: Succs (1): B0
67 // CHECK-NEXT: 2: [B3.1] (ImplicitCastExpr, LValueToRValue, int)
69 // CHECK-NEXT: 4: [B3.2] > [B3.3]
70 // CHECK-NEXT: T: if [B4.5] && [B3.4]
71 // CHECK-NEXT: Preds (1): B4
72 // CHECK-NEXT: Succs (2): B2(Unreachable) B1
73 int overlap_compare(int x
) {
80 // CHECK-LABEL: void vla_simple(int x)
83 // CHECK-NEXT: 2: [B1.1] (ImplicitCastExpr, LValueToRValue, int)
84 // CHECK-NEXT: 3: int vla[x];
85 void vla_simple(int x
) {
89 // CHECK-LABEL: void vla_typedef(int x)
92 // CHECK-NEXT: 2: [B1.1] (ImplicitCastExpr, LValueToRValue, int)
93 // CHECK-NEXT: 3: typedef int VLA[x];
94 void vla_typedef(int x
) {
98 // CHECK-LABEL: void vla_typedef_multi(int x, int y)
101 // CHECK-NEXT: 2: [B1.1] (ImplicitCastExpr, LValueToRValue, int)
103 // CHECK-NEXT: 4: [B1.3] (ImplicitCastExpr, LValueToRValue, int)
104 // CHECK-NEXT: 5: typedef int VLA[x][y];
105 void vla_typedef_multi(int x
, int y
) {
106 typedef int VLA
[x
][y
];
109 // CHECK-LABEL: void vla_type_indirect(int x)
111 // CHECK-NEXT: 1: int (*p_vla)[x];
112 // CHECK-NEXT: 2: void (*fp_vla)(int *);
113 void vla_type_indirect(int x
) {
115 // FIXME: does not work
119 void (*fp_vla
)(int[x
]);