Debian Codegraph @

clang/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp

raw
1 // RUN: %clang -E -target x86_64-unknown-linux-gnu -fsanitize=undefined %s -o - | FileCheck --check-prefix=CHECK-UBSAN %s
2 // RUN: %clang -E -target x86_64-unknown-linux-gnu -fsanitize=alignment %s -o - | FileCheck --check-prefixes=CHECK-UBSAN,CHECK-ALIGNMENT %s
3 // RUN: %clang -E -target x86_64-unknown-linux-gnu -fsanitize=bool %s -o - | FileCheck --check-prefixes=CHECK-UBSAN,CHECK-BOOL %s
4 // RUN: %clang -E -target x86_64-unknown-linux-gnu -fsanitize=builtin %s -o - | FileCheck --check-prefixes=CHECK-UBSAN,CHECK-BUILTIN %s
5 // RUN: %clang -E -target x86_64-unknown-linux-gnu -fsanitize=array-bounds %s -o - | FileCheck --check-prefixes=CHECK-UBSAN,CHECK-ARRAY-BOUNDS %s
6 // RUN: %clang -E -target x86_64-unknown-linux-gnu -fsanitize=enum %s -o - | FileCheck --check-prefixes=CHECK-UBSAN,CHECK-ENUM %s
7 // RUN: %clang -E -target x86_64-unknown-linux-gnu -fsanitize=float-cast-overflow %s -o - | FileCheck --check-prefixes=CHECK-UBSAN,CHECK-FLOAT-CAST-OVERFLOW %s
8 // RUN: %clang -E -target x86_64-unknown-linux-gnu -fsanitize=integer-divide-by-zero %s -o - | FileCheck --check-prefixes=CHECK-UBSAN,CHECK-INTEGER-DIVIDE-BY-ZERO %s
9 // RUN: %clang -E -target x86_64-unknown-linux-gnu -fsanitize=nonnull-attribute %s -o - | FileCheck --check-prefixes=CHECK-UBSAN,CHECK-NONNULL-ATTRIBUTE %s
10 // RUN: %clang -E -target x86_64-unknown-linux-gnu -fsanitize=null %s -o - | FileCheck --check-prefixes=CHECK-UBSAN,CHECK-NULL %s
11 // object-size is a no-op at O0.
12 // RUN: %clang -E -target x86_64-unknown-linux-gnu -O2 -fsanitize=object-size %s -o - | FileCheck --check-prefixes=CHECK-UBSAN,CHECK-OBJECT-SIZE %s
13 // RUN: %clang -E -target x86_64-unknown-linux-gnu -fsanitize=pointer-overflow %s -o - | FileCheck --check-prefixes=CHECK-UBSAN,CHECK-POINTER-OVERFLOW %s
14 // RUN: %clang -E -target x86_64-unknown-linux-gnu -fsanitize=return %s -o - | FileCheck --check-prefixes=CHECK-UBSAN,CHECK-RETURN %s
15 // RUN: %clang -E -target x86_64-unknown-linux-gnu -fsanitize=returns-nonnull-attribute %s -o - | FileCheck --check-prefixes=CHECK-UBSAN,CHECK-RETURNS-NONNULL-ATTRIBUTE %s
16 // RUN: %clang -E -target x86_64-unknown-linux-gnu -fsanitize=shift-base %s -o - | FileCheck --check-prefixes=CHECK-UBSAN,CHECK-SHIFT-BASE,CHECK-SHIFT %s
17 // RUN: %clang -E -target x86_64-unknown-linux-gnu -fsanitize=shift-exponent %s -o - | FileCheck --check-prefixes=CHECK-UBSAN,CHECK-SHIFT-EXPONENT,CHECK-SHIFT %s
18 // RUN: %clang -E -target x86_64-unknown-linux-gnu -fsanitize=shift %s -o - | FileCheck --check-prefixes=CHECK-UBSAN,CHECK-SHIFT %s
19 // RUN: %clang -E -target x86_64-unknown-linux-gnu -fsanitize=signed-integer-overflow %s -o - | FileCheck --check-prefixes=CHECK-UBSAN,CHECK-SIGNED-INTEGER-OVERFLOW %s
20 // RUN: %clang -E -target x86_64-unknown-linux-gnu -fsanitize=unreachable %s -o - | FileCheck --check-prefixes=CHECK-UBSAN,CHECK-UNREACHABLE %s
21 // RUN: %clang -E -target x86_64-unknown-linux-gnu -fsanitize=vla-bound %s -o - | FileCheck --check-prefixes=CHECK-UBSAN,CHECK-VLA-BOUND %s
22 // RUN: %clang -E -target x86_64-unknown-linux-gnu -fsanitize=function %s -o - | FileCheck --check-prefixes=CHECK-UBSAN,CHECK-FUNCTION %s
23
24 // RUN: %clang -E %s -o - | FileCheck --check-prefix=CHECK-NO-UBSAN %s
25
26 // REQUIRES: x86-registered-target
27
28 #if !__has_feature(undefined_behavior_sanitizer_finegrained_feature_checks)
29 #error "Missing undefined_behavior_sanitizer_finegrained_feature_checks"
30 #endif
31
32 #if __has_feature(undefined_behavior_sanitizer)
33 int UBSanEnabled();
34 #else
35 int UBSanDisabled();
36 #endif
37
38 #if __has_feature(alignment_sanitizer)
39 int AlignmentSanitizerEnabled();
40 #else
41 int AlignmentSanitizerDisabled();
42 #endif
43
44 #if __has_feature(bool_sanitizer)
45 int BoolSanitizerEnabled();
46 #else
47 int BoolSanitizerDisabled();
48 #endif
49
50 #if __has_feature(builtin_sanitizer)
51 int BuiltinSanitizerEnabled();
52 #else
53 int BuiltinSanitizerDisabled();
54 #endif
55
56 #if __has_feature(array_bounds_sanitizer)
57 int ArrayBoundsSanitizerEnabled();
58 #else
59 int ArrayBoundsSanitizerDisabled();
60 #endif
61
62 #if __has_feature(enum_sanitizer)
63 int EnumSanitizerEnabled();
64 #else
65 int EnumSanitizerDisabled();
66 #endif
67
68 #if __has_feature(float_cast_overflow_sanitizer)
69 int FloatCastOverflowSanitizerEnabled();
70 #else
71 int FloatCastOverflowSanitizerDisabled();
72 #endif
73
74 #if __has_feature(integer_divide_by_zero_sanitizer)
75 int IntegerDivideByZeroSanitizerEnabled();
76 #else
77 int IntegerDivideByZeroSanitizerDisabled();
78 #endif
79
80 #if __has_feature(nonnull_attribute_sanitizer)
81 int NonnullAttributeSanitizerEnabled();
82 #else
83 int NonnullAttributeSanitizerDisabled();
84 #endif
85
86 #if __has_feature(null_sanitizer)
87 int NullSanitizerEnabled();
88 #else
89 int NullSanitizerDisabled();
90 #endif
91
92 #if __has_feature(object_size_sanitizer)
93 int ObjectSizeSanitizerEnabled();
94 #else
95 int ObjectSizeSanitizerDisabled();
96 #endif
97
98 #if __has_feature(pointer_overflow_sanitizer)
99 int PointerOverflowSanitizerEnabled();
100 #else
101 int PointerOverflowSanitizerDisabled();
102 #endif
103
104 #if __has_feature(return_sanitizer)
105 int ReturnSanitizerEnabled();
106 #else
107 int ReturnSanitizerDisabled();
108 #endif
109
110 #if __has_feature(returns_nonnull_attribute_sanitizer)
111 int ReturnsNonnullAttributeSanitizerEnabled();
112 #else
113 int ReturnsNonnullAttributeSanitizerDisabled();
114 #endif
115
116 #if __has_feature(shift_base_sanitizer)
117 int ShiftBaseSanitizerEnabled();
118 #else
119 int ShiftBaseSanitizerDisabled();
120 #endif
121
122 #if __has_feature(shift_exponent_sanitizer)
123 int ShiftExponentSanitizerEnabled();
124 #else
125 int ShiftExponentSanitizerDisabled();
126 #endif
127
128 #if __has_feature(shift_sanitizer)
129 int ShiftSanitizerEnabled();
130 #else
131 int ShiftSanitizerDisabled();
132 #endif
133
134 #if __has_feature(signed_integer_overflow_sanitizer)
135 int SignedIntegerOverflowSanitizerEnabled();
136 #else
137 int SignedIntegerOverflowSanitizerDisabled();
138 #endif
139
140 #if __has_feature(unreachable_sanitizer)
141 int UnreachableSanitizerEnabled();
142 #else
143 int UnreachableSanitizerDisabled();
144 #endif
145
146 #if __has_feature(vla_bound_sanitizer)
147 int VLABoundSanitizerEnabled();
148 #else
149 int VLABoundSanitizerDisabled();
150 #endif
151
152 #if __has_feature(function_sanitizer)
153 int FunctionSanitizerEnabled();
154 #else
155 int FunctionSanitizerDisabled();
156 #endif
157
158 // CHECK-UBSAN: UBSanEnabled
159 // CHECK-ALIGNMENT: AlignmentSanitizerEnabled
160 // CHECK-BOOL: BoolSanitizerEnabled
161 // CHECK-BUILTIN: BuiltinSanitizerEnabled
162 // CHECK-ARRAY-BOUNDS: ArrayBoundsSanitizerEnabled
163 // CHECK-ENUM: EnumSanitizerEnabled
164 // CHECK-FLOAT-CAST-OVERFLOW: FloatCastOverflowSanitizerEnabled
165 // CHECK-INTEGER-DIVIDE-BY-ZERO: IntegerDivideByZeroSanitizerEnabled
166 // CHECK-NONNULL-ATTRIBUTE: NonnullAttributeSanitizerEnabled
167 // CHECK-NULL: NullSanitizerEnabled
168 // CHECK-OBJECT-SIZE: ObjectSizeSanitizerEnabled
169 // CHECK-POINTER-OVERFLOW: PointerOverflowSanitizerEnabled
170 // CHECK-RETURN: ReturnSanitizerEnabled
171 // CHECK-RETURNS-NONNULL-ATTRIBUTE: ReturnsNonnullAttributeSanitizerEnabled
172 // CHECK-SHIFT-BASE: ShiftBaseSanitizerEnabled
173 // CHECK-SHIFT-EXPONENT: ShiftExponentSanitizerEnabled
174 // CHECK-SHIFT: ShiftSanitizerEnabled
175 // CHECK-SIGNED-INTEGER-OVERFLOW: SignedIntegerOverflowSanitizerEnabled
176 // CHECK-UNREACHABLE: UnreachableSanitizerEnabled
177 // CHECK-VLA-BOUND: VLABoundSanitizerEnabled
178 // CHECK-FUNCTION: FunctionSanitizerEnabled
179 // CHECK-NO-UBSAN: UBSanDisabled