blob: 65ababd5ac8679f264aba5cc01475038a43273d9 [file] [log] [blame]
Richard Smithc4dabad2012-11-05 22:04:41 +00001//===--- 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
Evgeniy Stepanov09ccf392012-12-03 13:20:43 +000044// MemorySanitizer
45SANITIZER("memory", Memory)
46
Richard Smithc4dabad2012-11-05 22:04:41 +000047// ThreadSanitizer
48SANITIZER("thread", Thread)
49
Sergey Matveev050309f2013-05-27 11:17:01 +000050// LeakSanitizer
51SANITIZER("leak", Leak)
52
Richard Smithc4dabad2012-11-05 22:04:41 +000053// UndefinedBehaviorSanitizer
Richard Smithc4dabad2012-11-05 22:04:41 +000054SANITIZER("alignment", Alignment)
Richard Smith69170e62013-10-22 22:51:04 +000055SANITIZER("array-bounds", ArrayBounds)
Richard Smith463b48b2012-12-13 07:11:50 +000056SANITIZER("bool", Bool)
Richard Smith463b48b2012-12-13 07:11:50 +000057SANITIZER("enum", Enum)
Will Dietzb8540362012-11-27 15:01:55 +000058SANITIZER("float-cast-overflow", FloatCastOverflow)
59SANITIZER("float-divide-by-zero", FloatDivideByZero)
Peter Collingbourneb914e872013-10-20 21:29:19 +000060SANITIZER("function", Function)
Will Dietzb8540362012-11-27 15:01:55 +000061SANITIZER("integer-divide-by-zero", IntegerDivideByZero)
Stephen Hines176edba2014-12-01 14:53:08 -080062SANITIZER("nonnull-attribute", NonnullAttribute)
Will Dietzb8540362012-11-27 15:01:55 +000063SANITIZER("null", Null)
64SANITIZER("object-size", ObjectSize)
65SANITIZER("return", Return)
Stephen Hines176edba2014-12-01 14:53:08 -080066SANITIZER("returns-nonnull-attribute", ReturnsNonnullAttribute)
Pirama Arumuga Nainar3ea9e332015-04-08 08:57:32 -070067SANITIZER("shift-base", ShiftBase)
68SANITIZER("shift-exponent", ShiftExponent)
69SANITIZER_GROUP("shift", Shift, ShiftBase | ShiftExponent)
Will Dietzb8540362012-11-27 15:01:55 +000070SANITIZER("signed-integer-overflow", SignedIntegerOverflow)
71SANITIZER("unreachable", Unreachable)
72SANITIZER("vla-bound", VLABound)
73SANITIZER("vptr", Vptr)
74
75// IntegerSanitizer
76SANITIZER("unsigned-integer-overflow", UnsignedIntegerOverflow)
Richard Smithc4dabad2012-11-05 22:04:41 +000077
Peter Collingbourne2eeed712013-08-07 22:47:34 +000078// DataFlowSanitizer
79SANITIZER("dataflow", DataFlow)
80
Stephen Hines0e2c34f2015-03-23 12:09:02 -070081// Control Flow Integrity
Pirama Arumuga Nainar3ea9e332015-04-08 08:57:32 -070082SANITIZER("cfi-cast-strict", CFICastStrict)
83SANITIZER("cfi-derived-cast", CFIDerivedCast)
84SANITIZER("cfi-unrelated-cast", CFIUnrelatedCast)
Pirama Arumuga Nainar33337ca2015-05-06 11:48:57 -070085SANITIZER("cfi-nvcall", CFINVCall)
86SANITIZER("cfi-vcall", CFIVCall)
87SANITIZER_GROUP("cfi", CFI,
88 CFIDerivedCast | CFIUnrelatedCast | CFINVCall | CFIVCall)
Stephen Hines0e2c34f2015-03-23 12:09:02 -070089
Pirama Arumuga Nainar3ea9e332015-04-08 08:57:32 -070090// -fsanitize=undefined-trap includes sanitizers from -fsanitize=undefined
91// that can be used without runtime support, generally by providing extra
Chad Rosier78d85b12013-01-29 23:31:22 +000092// -fsanitize-undefined-trap-on-error flag.
93SANITIZER_GROUP("undefined-trap", UndefinedTrap,
Richard Smith69170e62013-10-22 22:51:04 +000094 Alignment | Bool | ArrayBounds | Enum | FloatCastOverflow |
Stephen Hines176edba2014-12-01 14:53:08 -080095 FloatDivideByZero | IntegerDivideByZero | NonnullAttribute |
96 Null | ObjectSize | Return | ReturnsNonnullAttribute |
97 Shift | SignedIntegerOverflow | Unreachable | VLABound)
Chad Rosier78d85b12013-01-29 23:31:22 +000098
Pirama Arumuga Nainar3ea9e332015-04-08 08:57:32 -070099// -fsanitize=undefined includes all the sanitizers which have low overhead, no
100// ABI or address space layout implications, and only catch undefined behavior.
101SANITIZER_GROUP("undefined", Undefined, UndefinedTrap | Function | Vptr)
102
Will Dietzb8540362012-11-27 15:01:55 +0000103SANITIZER_GROUP("integer", Integer,
104 SignedIntegerOverflow | UnsignedIntegerOverflow | Shift |
105 IntegerDivideByZero)
Richard Smithc4dabad2012-11-05 22:04:41 +0000106
Richard Smith69170e62013-10-22 22:51:04 +0000107SANITIZER("local-bounds", LocalBounds)
108SANITIZER_GROUP("bounds", Bounds, ArrayBounds | LocalBounds)
109
Stephen Hines0e2c34f2015-03-23 12:09:02 -0700110// Magic group, containing all sanitizers. For example, "-fno-sanitize=all"
111// can be used to disable all the sanitizers.
Pirama Arumuga Nainar3ea9e332015-04-08 08:57:32 -0700112SANITIZER_GROUP("all", All, ~0ULL)
Stephen Hines0e2c34f2015-03-23 12:09:02 -0700113
Richard Smithc4dabad2012-11-05 22:04:41 +0000114#undef SANITIZER
115#undef SANITIZER_GROUP