brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 8c04a00 Raw
41 lines · c
1// RUN: %clang_min_runtime -fsanitize=implicit-integer-sign-change                                                  %s -o %t &&             %run %t 2>&1 | FileCheck %s2// RUN: %clang_min_runtime -fsanitize=implicit-integer-sign-change -fsanitize-handler-preserve-all-regs -DPRESERVE  %s -o %t &&             %run %t 2>&1 | FileCheck %s --check-prefixes=PRESERVE3// RUN: %clang_min_runtime -fsanitize=implicit-integer-sign-change -fno-sanitize-recover=all                        %s -o %t && not --crash %run %t 2>&1 | FileCheck %s4// RUN: %clang_min_runtime -fsanitize=implicit-integer-sign-change -fno-sanitize-recover=all -DOVERRIDE=1           %s -o %t && not --crash %run %t 2>&1 | FileCheck %s --check-prefixes=FATAL5 6#include <stdint.h>7#include <stdio.h>8#include <stdlib.h>9 10static int Result;11 12void __ubsan_report_error(const char *kind, uintptr_t caller) {13// -fsanitize-handler-preserve-all-regs is ignored on other architectures.14// Prented we called to other handler on those.15#if defined(PRESERVE) && !defined(__aarch64__) && !defined(__x86_64__)16  fprintf(stderr, "CUSTOM_CALLBACK_PRESERVE: %s\n", kind);17#else18  fprintf(stderr, "CUSTOM_CALLBACK: %s\n", kind);19#endif20}21 22#if defined(__aarch64__) || defined(__x86_64__)23[[clang::preserve_all]] void __ubsan_report_error_preserve(const char *kind,24                                                           uintptr_t caller) {25  fprintf(stderr, "CUSTOM_CALLBACK_PRESERVE: %s\n", kind);26}27#endif28 29#if OVERRIDE30void __ubsan_report_error_fatal(const char *kind, uintptr_t caller) {31  fprintf(stderr, "FATAL_CALLBACK: %s\n", kind);32}33#endif34 35int main(int argc, const char **argv) {36  int32_t t0 = (~((uint32_t)0));37  // CHECK: CUSTOM_CALLBACK: implicit-conversion38  // PRESERVE: CUSTOM_CALLBACK_PRESERVE: implicit-conversion39  // FATAL: FATAL_CALLBACK: implicit-conversion40}41