Skip to content

Commit b500368

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.4
2 parents d193a58 + 0b7e7b7 commit b500368

File tree

3 files changed

+207
-2
lines changed

3 files changed

+207
-2
lines changed

clang/include/clang/Basic/Features.def

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,46 @@ FEATURE(memtag_globals,
5454
FEATURE(xray_instrument, LangOpts.XRayInstrument)
5555
FEATURE(undefined_behavior_sanitizer,
5656
LangOpts.Sanitize.hasOneOf(SanitizerKind::Undefined))
57+
// These are all part of undefined_behavior_sanitizer:
58+
FEATURE(alignment_sanitizer,
59+
LangOpts.Sanitize.has(SanitizerKind::Alignment))
60+
FEATURE(bool_sanitizer,
61+
LangOpts.Sanitize.has(SanitizerKind::Bool))
62+
FEATURE(builtin_sanitizer,
63+
LangOpts.Sanitize.has(SanitizerKind::Builtin))
64+
FEATURE(array_bounds_sanitizer,
65+
LangOpts.Sanitize.has(SanitizerKind::ArrayBounds))
66+
FEATURE(enum_sanitizer,
67+
LangOpts.Sanitize.has(SanitizerKind::Enum))
68+
FEATURE(float_cast_overflow_sanitizer,
69+
LangOpts.Sanitize.has(SanitizerKind::FloatCastOverflow))
70+
FEATURE(integer_divide_by_zero_sanitizer,
71+
LangOpts.Sanitize.has(SanitizerKind::IntegerDivideByZero))
72+
FEATURE(nonnull_attribute_sanitizer,
73+
LangOpts.Sanitize.has(SanitizerKind::NonnullAttribute))
74+
FEATURE(null_sanitizer,
75+
LangOpts.Sanitize.has(SanitizerKind::Null))
76+
FEATURE(object_size_sanitizer,
77+
LangOpts.Sanitize.has(SanitizerKind::ObjectSize))
78+
FEATURE(pointer_overflow_sanitizer,
79+
LangOpts.Sanitize.has(SanitizerKind::PointerOverflow))
80+
FEATURE(return_sanitizer,
81+
LangOpts.Sanitize.has(SanitizerKind::Return))
82+
FEATURE(returns_nonnull_attribute_sanitizer,
83+
LangOpts.Sanitize.has(SanitizerKind::ReturnsNonnullAttribute))
84+
FEATURE(shift_base_sanitizer, LangOpts.Sanitize.has(SanitizerKind::ShiftBase))
85+
FEATURE(shift_exponent_sanitizer, LangOpts.Sanitize.has(SanitizerKind::ShiftExponent))
86+
FEATURE(shift_sanitizer,
87+
LangOpts.Sanitize.hasOneOf(SanitizerKind::Shift))
88+
FEATURE(signed_integer_overflow_sanitizer,
89+
LangOpts.Sanitize.has(SanitizerKind::SignedIntegerOverflow))
90+
FEATURE(unreachable_sanitizer,
91+
LangOpts.Sanitize.has(SanitizerKind::Unreachable))
92+
FEATURE(vla_bound_sanitizer,
93+
LangOpts.Sanitize.has(SanitizerKind::VLABound))
94+
FEATURE(function_sanitizer,
95+
LangOpts.Sanitize.has(SanitizerKind::Function))
96+
5797
FEATURE(realtime_sanitizer,
5898
LangOpts.Sanitize.has(SanitizerKind::Realtime))
5999
FEATURE(coverage_sanitizer, LangOpts.SanitizeCoverage)
Lines changed: 162 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
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();
829
int 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

llvm/docs/Remarks.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ Enabling optimization remarks
5757
There are two modes that are supported for enabling optimization remarks in
5858
LLVM: through remark diagnostics, or through serialized remarks.
5959

60+
See also the clang flags
61+
`-Rpass <https://clang.llvm.org/docs/UsersManual.html#options-to-emit-optimization-reports>`_
62+
and
63+
`-fsave-optimization-record <http://clang.llvm.org/docs/UsersManual.html#cmdoption-f-no-save-optimization-record>`_.
64+
6065
Remark diagnostics
6166
------------------
6267

0 commit comments

Comments
 (0)