1//===--- Sanitizers.def - Runtime sanitizer options -------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines the options for specifying which runtime sanitizers to
11// enable. Users of this file must define the SANITIZER macro to make use of
12// this information. Users of this file can also define the SANITIZER_GROUP
13// macro to get information on options which refer to sets of sanitizers.
14//
15//===----------------------------------------------------------------------===//
16
17#ifndef SANITIZER
18#error "Define SANITIZER prior to including this file!"
19#endif
20
21// SANITIZER(NAME, ID)
22
23// The first value is the name of the sanitizer as a string. The sanitizer can
24// be enabled by specifying -fsanitize=NAME.
25
26// The second value is an identifier which can be used to refer to the
27// sanitizer.
28
29
30// SANITIZER_GROUP(NAME, ID, ALIAS)
31
32// The first two values have the same semantics as the corresponding SANITIZER
33// values. The third value is an expression ORing together the IDs of individual
34// sanitizers in this group.
35
36#ifndef SANITIZER_GROUP
37#define SANITIZER_GROUP(NAME, ID, ALIAS)
38#endif
39
40
41// AddressSanitizer
42SANITIZER("address", Address)
43
44// Kernel AddressSanitizer (KASan)
45SANITIZER("kernel-address", KernelAddress)
46
47// MemorySanitizer
48SANITIZER("memory", Memory)
49
50// ThreadSanitizer
51SANITIZER("thread", Thread)
52
53// LeakSanitizer
54SANITIZER("leak", Leak)
55
56// UndefinedBehaviorSanitizer
57SANITIZER("alignment", Alignment)
58SANITIZER("array-bounds", ArrayBounds)
59SANITIZER("bool", Bool)
60SANITIZER("enum", Enum)
61SANITIZER("float-cast-overflow", FloatCastOverflow)
62SANITIZER("float-divide-by-zero", FloatDivideByZero)
63SANITIZER("function", Function)
64SANITIZER("integer-divide-by-zero", IntegerDivideByZero)
65SANITIZER("nonnull-attribute", NonnullAttribute)
66SANITIZER("null", Null)
67SANITIZER("object-size", ObjectSize)
68SANITIZER("return", Return)
69SANITIZER("returns-nonnull-attribute", ReturnsNonnullAttribute)
70SANITIZER("shift-base", ShiftBase)
71SANITIZER("shift-exponent", ShiftExponent)
72SANITIZER_GROUP("shift", Shift, ShiftBase | ShiftExponent)
73SANITIZER("signed-integer-overflow", SignedIntegerOverflow)
74SANITIZER("unreachable", Unreachable)
75SANITIZER("vla-bound", VLABound)
76SANITIZER("vptr", Vptr)
77
78// IntegerSanitizer
79SANITIZER("unsigned-integer-overflow", UnsignedIntegerOverflow)
80
81// DataFlowSanitizer
82SANITIZER("dataflow", DataFlow)
83
84// Control Flow Integrity
85SANITIZER("cfi-cast-strict", CFICastStrict)
86SANITIZER("cfi-derived-cast", CFIDerivedCast)
87SANITIZER("cfi-icall", CFIICall)
88SANITIZER("cfi-unrelated-cast", CFIUnrelatedCast)
89SANITIZER("cfi-nvcall", CFINVCall)
90SANITIZER("cfi-vcall", CFIVCall)
91SANITIZER_GROUP("cfi", CFI,
92                CFIDerivedCast | CFIICall | CFIUnrelatedCast | CFINVCall |
93                CFIVCall)
94
95// Safe Stack
96SANITIZER("safe-stack", SafeStack)
97
98// -fsanitize=undefined includes all the sanitizers which have low overhead, no
99// ABI or address space layout implications, and only catch undefined behavior.
100SANITIZER_GROUP("undefined", Undefined,
101                Alignment | Bool | ArrayBounds | Enum | FloatCastOverflow |
102                    FloatDivideByZero | IntegerDivideByZero | NonnullAttribute |
103                    Null | ObjectSize | Return | ReturnsNonnullAttribute |
104                    Shift | SignedIntegerOverflow | Unreachable | VLABound |
105                    Function | Vptr)
106
107// -fsanitize=undefined-trap is an alias for -fsanitize=undefined.
108SANITIZER_GROUP("undefined-trap", UndefinedTrap, Undefined)
109
110SANITIZER_GROUP("integer", Integer,
111                SignedIntegerOverflow | UnsignedIntegerOverflow | Shift |
112                IntegerDivideByZero)
113
114SANITIZER("local-bounds", LocalBounds)
115SANITIZER_GROUP("bounds", Bounds, ArrayBounds | LocalBounds)
116
117// Magic group, containing all sanitizers. For example, "-fno-sanitize=all"
118// can be used to disable all the sanitizers.
119SANITIZER_GROUP("all", All, ~0ULL)
120
121#undef SANITIZER
122#undef SANITIZER_GROUP
123