brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 3d65caf Raw
43 lines · cpp
1// RUN: %clangxx -fsanitize=integer -g0 %s -o %t2 3// Suppression by symbol name (unsigned-integer-overflow:do_overflow below)4// requires the compiler-rt runtime to be able to symbolize stack addresses.5// REQUIRES: can-symbolize6// UNSUPPORTED: android7// Output differs on OpenBSD longer by displaying the values.8// XFAIL: target={{.*openbsd.*}}9 10// Fails without any suppression.11// RUN: %env_ubsan_opts=halt_on_error=1 not %run %t 2>&1 | FileCheck %s12 13// RUN: echo "signed-integer-overflow:%t" > %t.wrong-supp14// RUN: %env_ubsan_opts=halt_on_error=1:suppressions='"%t.wrong-supp"' not %run %t 2>&1 | FileCheck %s15 16// RUN: echo "unsigned-integer-overflow:do_overflow" > %t.func-supp17// RUN: %env_ubsan_opts=halt_on_error=1:suppressions='"%t.func-supp"' %run %t18// FIXME: The '%t' substitution can't be used for the module name because it19// contains a colon, so we have to use the basename, which is20// suppressions.cpp.tmp.21// RUN: echo "unsigned-integer-overflow:suppressions.cpp.tmp" > %t.module-supp22// RUN: %env_ubsan_opts=halt_on_error=1:suppressions='"%t.module-supp"' %run %t23 24// Note: file-level suppressions should work even without debug info.25// RUN: echo "unsigned-integer-overflow:%s" > %t.file-supp26// RUN: %env_ubsan_opts=halt_on_error=1:suppressions='"%t.file-supp"' %run %t27 28// Suppressions don't work for unrecoverable kinds.29// RUN: %clangxx -fsanitize=integer -fno-sanitize-recover=integer %s -o %t-norecover30// RUN: %env_ubsan_opts=halt_on_error=1:suppressions='"%t.module-supp"' not %run %t-norecover 2>&1 | FileCheck %s31 32#include <stdint.h>33 34extern "C" void do_overflow() {35  (void)(uint64_t(10000000000000000000ull) + uint64_t(9000000000000000000ull));36  // CHECK: runtime error: unsigned integer overflow37}38 39int main() {40  do_overflow();41  return 0;42}43