Home | History | Annotate | Download | only in Basic
      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 
     44 // Kernel AddressSanitizer (KASan)
     45 SANITIZER("kernel-address", KernelAddress)
     46 
     47 // MemorySanitizer
     48 SANITIZER("memory", Memory)
     49 
     50 // ThreadSanitizer
     51 SANITIZER("thread", Thread)
     52 
     53 // LeakSanitizer
     54 SANITIZER("leak", Leak)
     55 
     56 // UndefinedBehaviorSanitizer
     57 SANITIZER("alignment", Alignment)
     58 SANITIZER("array-bounds", ArrayBounds)
     59 SANITIZER("bool", Bool)
     60 SANITIZER("enum", Enum)
     61 SANITIZER("float-cast-overflow", FloatCastOverflow)
     62 SANITIZER("float-divide-by-zero", FloatDivideByZero)
     63 SANITIZER("function", Function)
     64 SANITIZER("integer-divide-by-zero", IntegerDivideByZero)
     65 SANITIZER("nonnull-attribute", NonnullAttribute)
     66 SANITIZER("null", Null)
     67 SANITIZER("nullability-arg", NullabilityArg)
     68 SANITIZER("nullability-assign", NullabilityAssign)
     69 SANITIZER("nullability-return", NullabilityReturn)
     70 SANITIZER_GROUP("nullability", Nullability,
     71                 NullabilityArg | NullabilityAssign | NullabilityReturn)
     72 SANITIZER("object-size", ObjectSize)
     73 SANITIZER("return", Return)
     74 SANITIZER("returns-nonnull-attribute", ReturnsNonnullAttribute)
     75 SANITIZER("shift-base", ShiftBase)
     76 SANITIZER("shift-exponent", ShiftExponent)
     77 SANITIZER_GROUP("shift", Shift, ShiftBase | ShiftExponent)
     78 SANITIZER("signed-integer-overflow", SignedIntegerOverflow)
     79 SANITIZER("unreachable", Unreachable)
     80 SANITIZER("vla-bound", VLABound)
     81 SANITIZER("vptr", Vptr)
     82 
     83 // IntegerSanitizer
     84 SANITIZER("unsigned-integer-overflow", UnsignedIntegerOverflow)
     85 
     86 // DataFlowSanitizer
     87 SANITIZER("dataflow", DataFlow)
     88 
     89 // Control Flow Integrity
     90 SANITIZER("cfi-cast-strict", CFICastStrict)
     91 SANITIZER("cfi-derived-cast", CFIDerivedCast)
     92 SANITIZER("cfi-icall", CFIICall)
     93 SANITIZER("cfi-unrelated-cast", CFIUnrelatedCast)
     94 SANITIZER("cfi-nvcall", CFINVCall)
     95 SANITIZER("cfi-vcall", CFIVCall)
     96 SANITIZER_GROUP("cfi", CFI,
     97                 CFIDerivedCast | CFIICall | CFIUnrelatedCast | CFINVCall |
     98                 CFIVCall)
     99 
    100 // Safe Stack
    101 SANITIZER("safe-stack", SafeStack)
    102 
    103 // -fsanitize=undefined includes all the sanitizers which have low overhead, no
    104 // ABI or address space layout implications, and only catch undefined behavior.
    105 SANITIZER_GROUP("undefined", Undefined,
    106                 Alignment | Bool | ArrayBounds | Enum | FloatCastOverflow |
    107                     FloatDivideByZero | IntegerDivideByZero | NonnullAttribute |
    108                     Null | ObjectSize | Return | ReturnsNonnullAttribute |
    109                     Shift | SignedIntegerOverflow | Unreachable | VLABound |
    110                     Function | Vptr)
    111 
    112 // -fsanitize=undefined-trap is an alias for -fsanitize=undefined.
    113 SANITIZER_GROUP("undefined-trap", UndefinedTrap, Undefined)
    114 
    115 SANITIZER_GROUP("integer", Integer,
    116                 SignedIntegerOverflow | UnsignedIntegerOverflow | Shift |
    117                 IntegerDivideByZero)
    118 
    119 SANITIZER("local-bounds", LocalBounds)
    120 SANITIZER_GROUP("bounds", Bounds, ArrayBounds | LocalBounds)
    121 
    122 // EfficiencySanitizer
    123 SANITIZER("efficiency-cache-frag", EfficiencyCacheFrag)
    124 SANITIZER("efficiency-working-set", EfficiencyWorkingSet)
    125 // Meta-group only used internally.
    126 SANITIZER_GROUP("efficiency-all", Efficiency,
    127                 EfficiencyCacheFrag | EfficiencyWorkingSet)
    128 
    129 // Magic group, containing all sanitizers. For example, "-fno-sanitize=all"
    130 // can be used to disable all the sanitizers.
    131 SANITIZER_GROUP("all", All, ~0ULL)
    132 
    133 #undef SANITIZER
    134 #undef SANITIZER_GROUP
    135