Debian Codegraph @

compiler-rt/test/ubsan_minimal/TestCases/override-callback.c

raw
1 // RUN: %clang -fsanitize=implicit-integer-sign-change %s -o %t && %run %t 2>&1 | FileCheck %s
2 // RUN: %clang -fsanitize=implicit-integer-sign-change -fno-sanitize-recover=all %s -o %t && not --crash %run %t 2>&1 | FileCheck %s
3 // RUN: %clang -fsanitize=implicit-integer-sign-change -fno-sanitize-recover=all -DOVERRIDE=1 %s -o %t && not --crash %run %t 2>&1 | FileCheck %s --check-prefixes=FATAL
4
5 #include <stdint.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8
9 static int Result;
10
11 void __ubsan_report_error(const char *kind, uintptr_t caller) {
12 fprintf(stderr, "CUSTOM_CALLBACK: %s\n", kind);
13 }
14
15 #if OVERRIDE
16 void __ubsan_report_error_fatal(const char *kind, uintptr_t caller) {
17 fprintf(stderr, "FATAL_CALLBACK: %s\n", kind);
18 }
19 #endif
20
21 int main(int argc, const char **argv) {
22 int32_t t0 = (~((uint32_t)0));
23 // CHECK: CUSTOM_CALLBACK: implicit-conversion
24 // FATAL: FATAL_CALLBACK: implicit-conversion
25 }