Clang Project

clang_source_code/test/Lexer/has_feature_undefined_behavior_sanitizer.cpp
1// RUN: %clang -E -fsanitize=undefined %s -o - | FileCheck --check-prefix=CHECK-UBSAN %s
2// RUN: %clang -E -fsanitize=alignment %s -o - | FileCheck --check-prefix=CHECK-ALIGNMENT %s
3// RUN: %clang -E  %s -o - | FileCheck --check-prefix=CHECK-NO-UBSAN %s
4
5#if __has_feature(undefined_behavior_sanitizer)
6int UBSanEnabled();
7#else
8int UBSanDisabled();
9#endif
10
11// CHECK-UBSAN: UBSanEnabled
12// CHECK-ALIGNMENT: UBSanEnabled
13// CHECK-NO-UBSAN: UBSanDisabled
14