1//===--- Sanitizers.def - Runtime sanitizer options -------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the options for specifying which runtime sanitizers to
10// enable. Users of this file must define the SANITIZER macro to make use of
11// this information. Users of this file can also define the SANITIZER_GROUP
12// macro to get information on options which refer to sets of sanitizers.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef SANITIZER
17#error "Define SANITIZER prior to including this file!"
18#endif
19
20// SANITIZER(NAME, ID)
21
22// The first value is the name of the sanitizer as a string. The sanitizer can
23// be enabled by specifying -fsanitize=NAME.
24
25// The second value is an identifier which can be used to refer to the
26// sanitizer.
27
28
29// SANITIZER_GROUP(NAME, ID, ALIAS)
30
31// The first two values have the same semantics as the corresponding SANITIZER
32// values. The third value is an expression ORing together the IDs of individual
33// sanitizers in this group.
34
35#ifndef SANITIZER_GROUP
36#define SANITIZER_GROUP(NAME, ID, ALIAS)
37#endif
38
39
40// AddressSanitizer
41SANITIZER("address", Address)
42
43// Requires AddressSanitizer
44SANITIZER("pointer-compare", PointerCompare)
45
46// Requires AddressSanitizer
47SANITIZER("pointer-subtract", PointerSubtract)
48
49// Kernel AddressSanitizer (KASan)
50SANITIZER("kernel-address", KernelAddress)
51
52// Hardware-assisted AddressSanitizer
53SANITIZER("hwaddress", HWAddress)
54
55// Kernel Hardware-assisted AddressSanitizer (KHWASan)
56SANITIZER("kernel-hwaddress", KernelHWAddress)
57
58// A variant of AddressSanitizer using AArch64 MTE extension.
59SANITIZER("memtag-stack", MemtagStack)
60SANITIZER("memtag-heap", MemtagHeap)
61SANITIZER("memtag-globals", MemtagGlobals)
62SANITIZER_GROUP("memtag", MemTag, MemtagStack | MemtagHeap | MemtagGlobals)
63
64// MemorySanitizer
65SANITIZER("memory", Memory)
66
67// Kernel MemorySanitizer (KMSAN)
68SANITIZER("kernel-memory", KernelMemory)
69
70// libFuzzer
71SANITIZER("fuzzer", Fuzzer)
72
73// libFuzzer-required instrumentation, no linking.
74SANITIZER("fuzzer-no-link", FuzzerNoLink)
75
76// ThreadSanitizer
77SANITIZER("thread", Thread)
78
79// LeakSanitizer
80SANITIZER("leak", Leak)
81
82// UndefinedBehaviorSanitizer
83SANITIZER("alignment", Alignment)
84SANITIZER("array-bounds", ArrayBounds)
85SANITIZER("bool", Bool)
86SANITIZER("builtin", Builtin)
87SANITIZER("enum", Enum)
88SANITIZER("float-cast-overflow", FloatCastOverflow)
89SANITIZER("float-divide-by-zero", FloatDivideByZero)
90SANITIZER("function", Function)
91SANITIZER("integer-divide-by-zero", IntegerDivideByZero)
92SANITIZER("nonnull-attribute", NonnullAttribute)
93SANITIZER("null", Null)
94SANITIZER("nullability-arg", NullabilityArg)
95SANITIZER("nullability-assign", NullabilityAssign)
96SANITIZER("nullability-return", NullabilityReturn)
97SANITIZER_GROUP("nullability", Nullability,
98 NullabilityArg | NullabilityAssign | NullabilityReturn)
99SANITIZER("object-size", ObjectSize)
100SANITIZER("pointer-overflow", PointerOverflow)
101SANITIZER("return", Return)
102SANITIZER("returns-nonnull-attribute", ReturnsNonnullAttribute)
103SANITIZER("shift-base", ShiftBase)
104SANITIZER("shift-exponent", ShiftExponent)
105SANITIZER_GROUP("shift", Shift, ShiftBase | ShiftExponent)
106SANITIZER("signed-integer-overflow", SignedIntegerOverflow)
107SANITIZER("unreachable", Unreachable)
108SANITIZER("vla-bound", VLABound)
109SANITIZER("vptr", Vptr)
110
111// IntegerSanitizer
112SANITIZER("unsigned-integer-overflow", UnsignedIntegerOverflow)
113SANITIZER("unsigned-shift-base", UnsignedShiftBase)
114
115// DataFlowSanitizer
116SANITIZER("dataflow", DataFlow)
117
118// Control Flow Integrity
119SANITIZER("cfi-cast-strict", CFICastStrict)
120SANITIZER("cfi-derived-cast", CFIDerivedCast)
121SANITIZER("cfi-icall", CFIICall)
122SANITIZER("cfi-mfcall", CFIMFCall)
123SANITIZER("cfi-unrelated-cast", CFIUnrelatedCast)
124SANITIZER("cfi-nvcall", CFINVCall)
125SANITIZER("cfi-vcall", CFIVCall)
126SANITIZER_GROUP("cfi", CFI,
127 CFIDerivedCast | CFIICall | CFIMFCall | CFIUnrelatedCast |
128 CFINVCall | CFIVCall)
129
130// Kernel Control Flow Integrity
131SANITIZER("kcfi", KCFI)
132
133// Safe Stack
134SANITIZER("safe-stack", SafeStack)
135
136// Shadow Call Stack
137SANITIZER("shadow-call-stack", ShadowCallStack)
138
139// -fsanitize=undefined includes all the sanitizers which have low overhead, no
140// ABI or address space layout implications, and only catch undefined behavior.
141SANITIZER_GROUP("undefined", Undefined,
142 Alignment | Bool | Builtin | ArrayBounds | Enum |
143 FloatCastOverflow |
144 IntegerDivideByZero | NonnullAttribute | Null | ObjectSize |
145 PointerOverflow | Return | ReturnsNonnullAttribute | Shift |
146 SignedIntegerOverflow | Unreachable | VLABound | Function |
147 Vptr)
148
149// -fsanitize=undefined-trap is an alias for -fsanitize=undefined.
150SANITIZER_GROUP("undefined-trap", UndefinedTrap, Undefined)
151
152// ImplicitConversionSanitizer
153SANITIZER("implicit-unsigned-integer-truncation",
154 ImplicitUnsignedIntegerTruncation)
155SANITIZER("implicit-signed-integer-truncation", ImplicitSignedIntegerTruncation)
156SANITIZER_GROUP("implicit-integer-truncation", ImplicitIntegerTruncation,
157 ImplicitUnsignedIntegerTruncation |
158 ImplicitSignedIntegerTruncation)
159
160SANITIZER("implicit-integer-sign-change", ImplicitIntegerSignChange)
161
162SANITIZER_GROUP("implicit-integer-arithmetic-value-change",
163 ImplicitIntegerArithmeticValueChange,
164 ImplicitIntegerSignChange | ImplicitSignedIntegerTruncation)
165
166SANITIZER("objc-cast", ObjCCast)
167
168// FIXME:
169//SANITIZER_GROUP("implicit-integer-conversion", ImplicitIntegerConversion,
170// ImplicitIntegerArithmeticValueChange |
171// ImplicitUnsignedIntegerTruncation)
172//SANITIZER_GROUP("implicit-conversion", ImplicitConversion,
173// ImplicitIntegerConversion)
174
175SANITIZER_GROUP("implicit-conversion", ImplicitConversion,
176 ImplicitIntegerArithmeticValueChange |
177 ImplicitUnsignedIntegerTruncation)
178
179SANITIZER_GROUP("integer", Integer,
180 ImplicitConversion | IntegerDivideByZero | Shift |
181 SignedIntegerOverflow | UnsignedIntegerOverflow |
182 UnsignedShiftBase)
183
184SANITIZER("local-bounds", LocalBounds)
185SANITIZER_GROUP("bounds", Bounds, ArrayBounds | LocalBounds)
186
187// Scudo hardened allocator
188SANITIZER("scudo", Scudo)
189
190// Magic group, containing all sanitizers. For example, "-fno-sanitize=all"
191// can be used to disable all the sanitizers.
192SANITIZER_GROUP("all", All, ~SanitizerMask())
193
194#undef SANITIZER
195#undef SANITIZER_GROUP
196

source code of clang/include/clang/Basic/Sanitizers.def