Richard Smith | c4dabad | 2012-11-05 22:04:41 +0000 | [diff] [blame] | 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 |
| 42 | SANITIZER("address", Address) |
| 43 | |
Evgeniy Stepanov | 09ccf39 | 2012-12-03 13:20:43 +0000 | [diff] [blame] | 44 | // MemorySanitizer |
| 45 | SANITIZER("memory", Memory) |
| 46 | |
Richard Smith | c4dabad | 2012-11-05 22:04:41 +0000 | [diff] [blame] | 47 | // ThreadSanitizer |
| 48 | SANITIZER("thread", Thread) |
| 49 | |
Sergey Matveev | 050309f | 2013-05-27 11:17:01 +0000 | [diff] [blame] | 50 | // LeakSanitizer |
| 51 | SANITIZER("leak", Leak) |
| 52 | |
Richard Smith | c4dabad | 2012-11-05 22:04:41 +0000 | [diff] [blame] | 53 | // UndefinedBehaviorSanitizer |
Richard Smith | c4dabad | 2012-11-05 22:04:41 +0000 | [diff] [blame] | 54 | SANITIZER("alignment", Alignment) |
Richard Smith | 69170e6 | 2013-10-22 22:51:04 +0000 | [diff] [blame] | 55 | SANITIZER("array-bounds", ArrayBounds) |
Richard Smith | 463b48b | 2012-12-13 07:11:50 +0000 | [diff] [blame] | 56 | SANITIZER("bool", Bool) |
Richard Smith | 463b48b | 2012-12-13 07:11:50 +0000 | [diff] [blame] | 57 | SANITIZER("enum", Enum) |
Will Dietz | b854036 | 2012-11-27 15:01:55 +0000 | [diff] [blame] | 58 | SANITIZER("float-cast-overflow", FloatCastOverflow) |
| 59 | SANITIZER("float-divide-by-zero", FloatDivideByZero) |
Peter Collingbourne | b914e87 | 2013-10-20 21:29:19 +0000 | [diff] [blame] | 60 | SANITIZER("function", Function) |
Will Dietz | b854036 | 2012-11-27 15:01:55 +0000 | [diff] [blame] | 61 | SANITIZER("integer-divide-by-zero", IntegerDivideByZero) |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 62 | SANITIZER("nonnull-attribute", NonnullAttribute) |
Will Dietz | b854036 | 2012-11-27 15:01:55 +0000 | [diff] [blame] | 63 | SANITIZER("null", Null) |
| 64 | SANITIZER("object-size", ObjectSize) |
| 65 | SANITIZER("return", Return) |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 66 | SANITIZER("returns-nonnull-attribute", ReturnsNonnullAttribute) |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 67 | SANITIZER("shift-base", ShiftBase) |
| 68 | SANITIZER("shift-exponent", ShiftExponent) |
| 69 | SANITIZER_GROUP("shift", Shift, ShiftBase | ShiftExponent) |
Will Dietz | b854036 | 2012-11-27 15:01:55 +0000 | [diff] [blame] | 70 | SANITIZER("signed-integer-overflow", SignedIntegerOverflow) |
| 71 | SANITIZER("unreachable", Unreachable) |
| 72 | SANITIZER("vla-bound", VLABound) |
| 73 | SANITIZER("vptr", Vptr) |
| 74 | |
| 75 | // IntegerSanitizer |
| 76 | SANITIZER("unsigned-integer-overflow", UnsignedIntegerOverflow) |
Richard Smith | c4dabad | 2012-11-05 22:04:41 +0000 | [diff] [blame] | 77 | |
Peter Collingbourne | 2eeed71 | 2013-08-07 22:47:34 +0000 | [diff] [blame] | 78 | // DataFlowSanitizer |
| 79 | SANITIZER("dataflow", DataFlow) |
| 80 | |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 81 | // Control Flow Integrity |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 82 | SANITIZER("cfi-cast-strict", CFICastStrict) |
| 83 | SANITIZER("cfi-derived-cast", CFIDerivedCast) |
| 84 | SANITIZER("cfi-unrelated-cast", CFIUnrelatedCast) |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 85 | SANITIZER("cfi-vptr", CFIVptr) |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 86 | SANITIZER_GROUP("cfi", CFI, CFIDerivedCast | CFIUnrelatedCast | CFIVptr) |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 87 | |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 88 | // -fsanitize=undefined-trap includes sanitizers from -fsanitize=undefined |
| 89 | // that can be used without runtime support, generally by providing extra |
Chad Rosier | 78d85b1 | 2013-01-29 23:31:22 +0000 | [diff] [blame] | 90 | // -fsanitize-undefined-trap-on-error flag. |
| 91 | SANITIZER_GROUP("undefined-trap", UndefinedTrap, |
Richard Smith | 69170e6 | 2013-10-22 22:51:04 +0000 | [diff] [blame] | 92 | Alignment | Bool | ArrayBounds | Enum | FloatCastOverflow | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 93 | FloatDivideByZero | IntegerDivideByZero | NonnullAttribute | |
| 94 | Null | ObjectSize | Return | ReturnsNonnullAttribute | |
| 95 | Shift | SignedIntegerOverflow | Unreachable | VLABound) |
Chad Rosier | 78d85b1 | 2013-01-29 23:31:22 +0000 | [diff] [blame] | 96 | |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 97 | // -fsanitize=undefined includes all the sanitizers which have low overhead, no |
| 98 | // ABI or address space layout implications, and only catch undefined behavior. |
| 99 | SANITIZER_GROUP("undefined", Undefined, UndefinedTrap | Function | Vptr) |
| 100 | |
Will Dietz | b854036 | 2012-11-27 15:01:55 +0000 | [diff] [blame] | 101 | SANITIZER_GROUP("integer", Integer, |
| 102 | SignedIntegerOverflow | UnsignedIntegerOverflow | Shift | |
| 103 | IntegerDivideByZero) |
Richard Smith | c4dabad | 2012-11-05 22:04:41 +0000 | [diff] [blame] | 104 | |
Richard Smith | 69170e6 | 2013-10-22 22:51:04 +0000 | [diff] [blame] | 105 | SANITIZER("local-bounds", LocalBounds) |
| 106 | SANITIZER_GROUP("bounds", Bounds, ArrayBounds | LocalBounds) |
| 107 | |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 108 | // Magic group, containing all sanitizers. For example, "-fno-sanitize=all" |
| 109 | // can be used to disable all the sanitizers. |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 110 | SANITIZER_GROUP("all", All, ~0ULL) |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 111 | |
Richard Smith | c4dabad | 2012-11-05 22:04:41 +0000 | [diff] [blame] | 112 | #undef SANITIZER |
| 113 | #undef SANITIZER_GROUP |