mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-19 11:35:51 -04:00

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
14 lines
453 B
C++
14 lines
453 B
C++
// 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
|