[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Driver / fsanitize-coverage.c
blob16853ed7d04aa4fac79680fd01828fdebbce864b
1 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=0 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-0
2 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=edge -fsanitize-coverage=0 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-0
3 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-0
4 // CHECK-SANITIZE-COVERAGE-0-NOT: fsanitize-coverage-type
5 // CHECK-SANITIZE-COVERAGE-0: -fsanitize=address
7 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
8 // RUN: %clang -target x86_64-linux-gnu -fsanitize=kernel-address -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
9 // RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
10 // RUN: %clang -target x86_64-linux-gnu -fsanitize=kernel-hwaddress -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
11 // RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
12 // RUN: %clang -target x86_64-linux-gnu -fsanitize=kernel-memory -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
13 // RUN: %clang -target x86_64-linux-gnu -fsanitize=leak -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
14 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
15 // RUN: %clang -target x86_64-linux-gnu -fsanitize=bounds -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
16 // RUN: %clang -target x86_64-linux-gnu -fsanitize=bool -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
17 // RUN: %clang -target x86_64-linux-gnu -fsanitize=dataflow -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
18 // RUN: %clang -target x86_64-linux-gnu -fsanitize=thread -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
19 // RUN: %clang -target x86_64-linux-gnu -fsanitize=kcfi -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
20 // RUN: %clang -target %itanium_abi_triple -fsanitize=float-divide-by-zero -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
21 // RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
22 // CHECK-SANITIZE-COVERAGE-FUNC: fsanitize-coverage-type=1
24 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=bb %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-BB
25 // CHECK-SANITIZE-COVERAGE-BB: fsanitize-coverage-type=2
27 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=edge %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-EDGE
28 // CHECK-SANITIZE-COVERAGE-EDGE: fsanitize-coverage-type=3
30 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=edge,indirect-calls %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FUNC_INDIR
31 // CHECK-SANITIZE-COVERAGE-FUNC_INDIR: fsanitize-coverage-type=3
32 // CHECK-SANITIZE-COVERAGE-FUNC_INDIR: fsanitize-coverage-indirect-calls
34 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=1 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-1
35 // CHECK-SANITIZE-COVERAGE-1: warning: argument '-fsanitize-coverage=1' is deprecated, use '-fsanitize-coverage=trace-pc-guard' instead
37 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=func %s -### 2>&1 | FileCheck %s --check-prefix=CHECK_FUNC_BB_EDGE_DEPRECATED
38 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=bb %s -### 2>&1 | FileCheck %s --check-prefix=CHECK_FUNC_BB_EDGE_DEPRECATED
39 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=edge %s -### 2>&1 | FileCheck %s --check-prefix=CHECK_FUNC_BB_EDGE_DEPRECATED
40 // CHECK_FUNC_BB_EDGE_DEPRECATED: warning: argument '-fsanitize-coverage=[func|bb|edge]' is deprecated, use '-fsanitize-coverage=[func|bb|edge],[trace-pc-guard|trace-pc],[control-flow]' instead
42 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=edge,indirect-calls,trace-pc,trace-cmp,trace-loads,trace-stores,trace-div,trace-gep %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANITIZE-COVERAGE-FEATURES
43 // CHECK-SANITIZE-COVERAGE-FEATURES: -fsanitize-coverage-type=3
44 // CHECK-SANITIZE-COVERAGE-FEATURES: -fsanitize-coverage-indirect-calls
45 // CHECK-SANITIZE-COVERAGE-FEATURES: -fsanitize-coverage-trace-cmp
46 // CHECK-SANITIZE-COVERAGE-FEATURES: -fsanitize-coverage-trace-div
47 // CHECK-SANITIZE-COVERAGE-FEATURES: -fsanitize-coverage-trace-gep
48 // CHECK-SANITIZE-COVERAGE-FEATURES: -fsanitize-coverage-trace-pc
49 // CHECK-SANITIZE-COVERAGE-FEATURES: -fsanitize-coverage-trace-loads
50 // CHECK-SANITIZE-COVERAGE-FEATURES: -fsanitize-coverage-trace-stores
52 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=func,edge,indirect-calls,trace-cmp -fno-sanitize-coverage=edge,indirect-calls %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MASK
53 // CHECK-MASK: -fsanitize-coverage-type=1
54 // CHECK-MASK: -fsanitize-coverage-trace-cmp
55 // CHECK-MASK-NOT: -fsanitize-coverage-
57 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=foobar %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-INVALID-VALUE
58 // CHECK-INVALID-VALUE: error: unsupported argument 'foobar' to option '-fsanitize-coverage='
60 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=func -fsanitize-coverage=edge %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-INCOMPATIBLE
61 // CHECK-INCOMPATIBLE: error: invalid argument '-fsanitize-coverage=func' not allowed with '-fsanitize-coverage=edge'
63 // RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=8bit-counters %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-8BIT
64 // CHECK-8BIT: warning: argument '-fsanitize-coverage=8bit-counters' is deprecated, use '-fsanitize-coverage=trace-pc-guard' instead
65 // RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=trace-bb %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TRACE-BB
66 // CHECK-TRACE-BB: warning: argument '-fsanitize-coverage=trace-bb' is deprecated, use '-fsanitize-coverage=trace-pc-guard' instead
68 // RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TRACE_PC_EDGE
69 // RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=edge,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TRACE_PC_EDGE
70 // CHECK-TRACE_PC_EDGE: -fsanitize-coverage-type=3
71 // CHECK-TRACE_PC_EDGE: -fsanitize-coverage-trace-pc
72 // RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TRACE_PC_FUNC
73 // CHECK-TRACE_PC_FUNC: -fsanitize-coverage-type=1
74 // CHECK-TRACE_PC_FUNC: -fsanitize-coverage-trace-pc
76 // RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=trace-pc-guard %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TRACE_PC_GUARD_EDGE
77 // RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=edge,trace-pc-guard %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TRACE_PC_GUARD_EDGE
78 // CHECK-TRACE_PC_GUARD_EDGE: -fsanitize-coverage-type=3
79 // CHECK-TRACE_PC_GUARD_EDGE: -fsanitize-coverage-trace-pc-guard
80 // RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=func,trace-pc-guard %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TRACE_PC_GUARD_FUNC
81 // CHECK-TRACE_PC_GUARD_FUNC: -fsanitize-coverage-type=1
82 // CHECK-TRACE_PC_GUARD_FUNC: -fsanitize-coverage-trace-pc-guard
84 // RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=stack-depth %s \
85 // RUN: -### 2>&1 | FileCheck %s --check-prefix=CHECK-STACK-DEPTH
86 // RUN: %clang -target x86_64-linux-gnu \
87 // RUN: -fsanitize-coverage=trace-pc-guard,stack-depth %s -### 2>&1 | \
88 // RUN: FileCheck %s --check-prefix=CHECK-STACK-DEPTH-PC-GUARD
89 // CHECK-STACK-DEPTH: -fsanitize-coverage-type=1
90 // CHECK-STACK-DEPTH: -fsanitize-coverage-stack-depth
91 // CHECK-STACK-DEPTH-PC-GUARD: -fsanitize-coverage-type=3
92 // CHECK-STACK-DEPTH-PC-GUARD: -fsanitize-coverage-trace-pc-guard
93 // CHECK-STACK-DEPTH-PC-GUARD: -fsanitize-coverage-stack-depth
95 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=trace-cmp,indirect-calls %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-TYPE-NECESSARY
96 // CHECK-NO-TYPE-NECESSARY-NOT: error:
97 // CHECK-NO-TYPE-NECESSARY: -fsanitize-coverage-indirect-calls
98 // CHECK-NO-TYPE-NECESSARY: -fsanitize-coverage-trace-cmp
100 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-coverage=func -fsanitize-coverage=trace-cmp %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-EXTEND-LEGACY
101 // CHECK-EXTEND-LEGACY: -fsanitize-coverage-type=1
102 // CHECK-EXTEND-LEGACY: -fsanitize-coverage-trace-cmp
104 // RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=no-prune,trace-pc %s -### 2>&1 | FileCheck %s --check-prefix=CHECK_NOPRUNE
105 // RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=no-prune,func,trace-pc-guard %s -### 2>&1 | FileCheck %s --check-prefix=CHECK_NOPRUNE
106 // CHECK_NOPRUNE: -fsanitize-coverage-no-prune
108 // RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=inline-8bit-counters %s -### 2>&1 | FileCheck %s --check-prefix=CHECK_INLINE8BIT
109 // RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=bb,inline-8bit-counters %s -### 2>&1 | FileCheck %s --check-prefix=CHECK_INLINE8BIT
110 // CHECK_INLINE8BIT-NOT: warning:
111 // CHECK_INLINE8BIT: -fsanitize-coverage-inline-8bit-counters
113 // RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=inline-8bit-counters,pc-table %s -### 2>&1 | FileCheck %s --check-prefix=CHECK_PC_TABLE_FOR_INLINE8BIT
114 // RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=trace-pc-guard,pc-table %s -### 2>&1 | FileCheck %s --check-prefix=CHECK_PC_TABLE_FOR_INLINE8BIT
115 // CHECK_PC_TABLE_FOR_INLINE8BIT: -fsanitize-coverage-pc-table
117 // RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=inline-bool-flag %s -### 2>&1 | FileCheck %s --check-prefix=CHECK_INLINE_BOOL_FLAG
118 // RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=bb,inline-bool-flag %s -### 2>&1 | FileCheck %s --check-prefix=CHECK_INLINE_BOOL_FLAG
119 // CHECK_INLINE_BOOL_FLAG-NOT: warning:
120 // CHECK_INLINE_BOOL_FLAG: -fsanitize-coverage-inline-bool-flag
122 // RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=inline-bool-flag,pc-table %s -### 2>&1 | FileCheck %s --check-prefix=CHECK_PC_TABLE_FOR_INLINEBOOL
123 // RUN: %clang -target x86_64-linux-gnu -fsanitize-coverage=trace-pc-guard,pc-table %s -### 2>&1 | FileCheck %s --check-prefix=CHECK_PC_TABLE_FOR_INLINEBOOL
124 // CHECK_PC_TABLE_FOR_INLINEBOOL: -fsanitize-coverage-pc-table
126 // RUN: %clang_cl --target=i386-pc-win32 -fsanitize=address -fsanitize-coverage=func,trace-pc-guard -c -### -- %s 2>&1 | FileCheck %s -check-prefix=CLANG-CL-COVERAGE
127 // CLANG-CL-COVERAGE-NOT: error:
128 // CLANG-CL-COVERAGE-NOT: warning:
129 // CLANG-CL-COVERAGE-NOT: argument unused
130 // CLANG-CL-COVERAGE-NOT: unknown argument
131 // CLANG-CL-COVERAGE: -fsanitize-coverage-type=1
132 // CLANG-CL-COVERAGE: -fsanitize=address
134 // RUN: %clang -target x86_64-linux-gnu -fsanitize=safe-stack -fsanitize-coverage=trace-pc-guard %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VS-SAFESTACK
135 // CHECK-VS-SAFESTACK: -fsanitize-coverage-trace-pc-guard
136 // CHECK-VS-SAFESTACK: -fsanitize=safe-stack
138 // RUN: %clang -target x86_64-linux-gnu -fsanitize=safe-stack -fsanitize-coverage=trace-pc-guard -fno-sanitize=safe-stack %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-SAFESTACK
139 // CHECK-NO-SAFESTACK-NOT: error:
140 // CHECK-NO-SAFESTACK-NOT: warning:
141 // CHECK-NO-SAFESTACK-NOT: argument unused
142 // CHECK-NO-SAFESTACK-NOT: unknown argument
143 // CHECK-NO-SAFESTACK-NOT: -fsanitize=safe-stack
144 // CHECK-NO-SAFESTACK: -fsanitize-coverage-trace-pc-guard
146 // RUN: %clang -target x86_64-linux-gnu -fsanitize=shadow-call-stack -fsanitize-coverage=trace-pc-guard %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-VS-SHADOWCALLSTACK
147 // CHECK-VS-SHADOWCALLSTACK: -fsanitize-coverage-trace-pc-guard
148 // CHECK-VS-SHADOWCALLSTACK: -fsanitize=shadow-call-stack
150 // RUN: %clang -target x86_64-linux-gnu -fsanitize=shadow-call-stack -fsanitize-coverage=trace-pc-guard -fno-sanitize=shadow-call-stack %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-SAFESTACK
151 // CHECK-NO-SHADOWCALLSTACK-NOT: error:
152 // CHECK-NO-SHADOWCALLSTACK-NOT: warning:
153 // CHECK-NO-SHADOWCALLSTACK-NOT: argument unused
154 // CHECK-NO-SHADOWCALLSTACK-NOT: unknown argument
155 // CHECK-NO-SHADOWCALLSTACK-NOT: -fsanitize=shadow-call-stack
156 // CHECK-NO-SHADOWCALLSTACK: -fsanitize-coverage-trace-pc-guard