diff options
author | Leonard Chan <leonardchan@google.com> | 2018-09-22 01:03:16 +0000 |
---|---|---|
committer | Leonard Chan <leonardchan@google.com> | 2018-09-22 01:03:16 +0000 |
commit | d05cbec4c2c7fcf52a428d3253ca0c97662d7285 (patch) | |
tree | 12f9f818881e738cb5963c4574a81d84b80aabe1 /test/Lexer | |
parent | 167b402df58ab0d972f5a67f46ce2f30c68f82ae (diff) | |
download | clang-d05cbec4c2c7fcf52a428d3253ca0c97662d7285.tar.gz |
[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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342793 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Lexer')
-rw-r--r-- | test/Lexer/has_feature_undefined_behavior_sanitizer.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp b/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp new file mode 100644 index 0000000000..62e5316dde --- /dev/null +++ b/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp @@ -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 |