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