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 // More features of AddressSanitizer that should be turned on explicitly.
     44 SANITIZER("init-order", InitOrder)
     45 SANITIZER("use-after-return", UseAfterReturn)
     46 SANITIZER("use-after-scope", UseAfterScope)
     47 
     48 SANITIZER_GROUP("address-full", AddressFull,
     49                 Address | InitOrder | UseAfterReturn | UseAfterScope)
     50 
     51 // MemorySanitizer
     52 SANITIZER("memory", Memory)
     53 
     54 // ThreadSanitizer
     55 SANITIZER("thread", Thread)
     56 
     57 // UndefinedBehaviorSanitizer
     58 SANITIZER("alignment", Alignment)
     59 SANITIZER("bool", Bool)
     60 SANITIZER("bounds", Bounds)
     61 SANITIZER("enum", Enum)
     62 SANITIZER("float-cast-overflow", FloatCastOverflow)
     63 SANITIZER("float-divide-by-zero", FloatDivideByZero)
     64 SANITIZER("integer-divide-by-zero", IntegerDivideByZero)
     65 SANITIZER("null", Null)
     66 SANITIZER("object-size", ObjectSize)
     67 SANITIZER("return", Return)
     68 SANITIZER("shift", Shift)
     69 SANITIZER("signed-integer-overflow", SignedIntegerOverflow)
     70 SANITIZER("unreachable", Unreachable)
     71 SANITIZER("vla-bound", VLABound)
     72 SANITIZER("vptr", Vptr)
     73 
     74 // IntegerSanitizer
     75 SANITIZER("unsigned-integer-overflow", UnsignedIntegerOverflow)
     76 
     77 // -fsanitize=undefined includes all the sanitizers which have low overhead, no
     78 // ABI or address space layout implications, and only catch undefined behavior.
     79 SANITIZER_GROUP("undefined", Undefined,
     80                 Alignment | Bool | Bounds | Enum | FloatCastOverflow |
     81                 FloatDivideByZero | IntegerDivideByZero | Null | ObjectSize |
     82                 Return | Shift | SignedIntegerOverflow | Unreachable |
     83                 VLABound | Vptr)
     84 
     85 // -fsanitize=undefined-trap (and its alias -fcatch-undefined-behavior) includes
     86 // all sanitizers included by -fsanitize=undefined, except those that require
     87 // runtime support.  This group is generally used in conjunction with the
     88 // -fsanitize-undefined-trap-on-error flag.
     89 SANITIZER_GROUP("undefined-trap", UndefinedTrap,
     90                 Alignment | Bool | Bounds | Enum | FloatCastOverflow |
     91                 FloatDivideByZero | IntegerDivideByZero | Null | ObjectSize |
     92                 Return | Shift | SignedIntegerOverflow | Unreachable |
     93                 VLABound)
     94 
     95 SANITIZER_GROUP("integer", Integer,
     96                 SignedIntegerOverflow | UnsignedIntegerOverflow | Shift |
     97                 IntegerDivideByZero)
     98 
     99 #undef SANITIZER
    100 #undef SANITIZER_GROUP
    101