| 1 |
// REQUIRES: target={{x86_64.*}} |
| 2 |
// |
| 3 |
// RUN: %clangxx -fsanitize=builtin -fno-inline -w %s -O3 -o %t |
| 4 |
// RUN: %run %t 2>&1 | FileCheck %s --check-prefix=RECOVER |
| 5 |
// RUN: %clangxx -fsanitize=builtin -fno-inline -fno-sanitize-recover=builtin -w %s -O3 -o %t.abort |
| 6 |
// RUN: not %run %t.abort 2>&1 | FileCheck %s --check-prefix=ABORT |
| 7 |
|
| 8 |
void check_ctz(int n) { |
| 9 |
// ABORT: builtins.cpp:[[@LINE+2]]:17: runtime error: passing zero to __builtin_ctz(), which is not a valid argument |
| 10 |
// RECOVER: builtins.cpp:[[@LINE+1]]:17: runtime error: passing zero to __builtin_ctz(), which is not a valid argument |
| 11 |
__builtin_ctz(n); |
| 12 |
|
| 13 |
// RECOVER: builtins.cpp:[[@LINE+1]]:18: runtime error: passing zero to __builtin_ctz(), which is not a valid argument |
| 14 |
__builtin_ctzl(n); |
| 15 |
|
| 16 |
// RECOVER: builtins.cpp:[[@LINE+1]]:19: runtime error: passing zero to __builtin_ctz(), which is not a valid argument |
| 17 |
__builtin_ctzll(n); |
| 18 |
} |
| 19 |
|
| 20 |
void check_clz(int n) { |
| 21 |
// RECOVER: builtins.cpp:[[@LINE+1]]:17: runtime error: passing zero to __builtin_clz(), which is not a valid argument |
| 22 |
__builtin_clz(n); |
| 23 |
|
| 24 |
// RECOVER: builtins.cpp:[[@LINE+1]]:18: runtime error: passing zero to __builtin_clz(), which is not a valid argument |
| 25 |
__builtin_clzl(n); |
| 26 |
|
| 27 |
// RECOVER: builtins.cpp:[[@LINE+1]]:19: runtime error: passing zero to __builtin_clz(), which is not a valid argument |
| 28 |
__builtin_clzll(n); |
| 29 |
} |
| 30 |
|
| 31 |
void check_assume(int n) { |
| 32 |
// RECOVER: builtins.cpp:[[@LINE+1]]:20: runtime error: assumption is violated during execution |
| 33 |
__builtin_assume(n); |
| 34 |
} |
| 35 |
|
| 36 |
void check_assume_attr(int n) { |
| 37 |
// RECOVER: builtins.cpp:[[@LINE+1]]:25: runtime error: assumption is violated during execution |
| 38 |
__attribute__((assume(n))); |
| 39 |
} |
| 40 |
|
| 41 |
int main() { |
| 42 |
check_ctz(0); |
| 43 |
check_clz(0); |
| 44 |
check_assume(0); |
| 45 |
check_assume_attr(0); |
| 46 |
return 0; |
| 47 |
} |