forked from OSchip/llvm-project
[Lexer] Add udefined_behavior_sanitizer feature
This can be used to detect whether the code is being built with UBSan using the __has_feature(undefined_behavior_sanitizer) predicate. Differential Revision: https://reviews.llvm.org/D52386 llvm-svn: 342793
This commit is contained in:
parent
6ce2a2b48e
commit
b32d40417e
|
@ -38,6 +38,8 @@ FEATURE(hwaddress_sanitizer,
|
|||
LangOpts.Sanitize.hasOneOf(SanitizerKind::HWAddress |
|
||||
SanitizerKind::KernelHWAddress))
|
||||
FEATURE(xray_instrument, LangOpts.XRayInstrument)
|
||||
FEATURE(undefined_behavior_sanitizer,
|
||||
LangOpts.Sanitize.hasOneOf(SanitizerKind::Undefined))
|
||||
FEATURE(assume_nonnull, true)
|
||||
FEATURE(attribute_analyzer_noreturn, true)
|
||||
FEATURE(attribute_availability, true)
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
// RUN: %clang -E -fsanitize=undefined %s -o - | FileCheck --check-prefix=CHECK-UBSAN %s
|
||||
// RUN: %clang -E -fsanitize=alignment %s -o - | FileCheck --check-prefix=CHECK-ALIGNMENT %s
|
||||
// RUN: %clang -E %s -o - | FileCheck --check-prefix=CHECK-NO-UBSAN %s
|
||||
|
||||
#if __has_feature(undefined_behavior_sanitizer)
|
||||
int UBSanEnabled();
|
||||
#else
|
||||
int UBSanDisabled();
|
||||
#endif
|
||||
|
||||
// CHECK-UBSAN: UBSanEnabled
|
||||
// CHECK-ALIGNMENT: UBSanEnabled
|
||||
// CHECK-NO-UBSAN: UBSanDisabled
|
Loading…
Reference in New Issue