Files
clang-p2996/compiler-rt/test/ubsan_minimal/TestCases/recover-dedup.cpp
Igor Kudrin 84c4efbc6d [ubsan-minimal] Report the address of an error
This implements a FIXME in the runtime library and adds printing the
address at the end of the message as "by 0x123abc". The buffer for the
message is allocated on the stack in a handler, so the stack memory
consumption is slightly increased. No additional external dependencies
are added.

Differential revision: https://reviews.llvm.org/D131914
2022-09-05 14:18:25 +04:00

40 lines
824 B
C++

// RUN: %clangxx -w -fsanitize=signed-integer-overflow,nullability-return,returns-nonnull-attribute -fsanitize-recover=all %s -o %t && %run %t 2>&1 | FileCheck %s
#include <stdint.h>
#include <stdio.h>
int *_Nonnull h() {
// CHECK: nullability-return by 0x{{[[:xdigit:]]+$}}
return NULL;
}
__attribute__((returns_nonnull))
int *i() {
// CHECK: nonnull-return by 0x{{[[:xdigit:]]+$}}
return NULL;
}
__attribute__((noinline))
int f(int x, int y) {
// CHECK: mul-overflow by 0x{{[[:xdigit:]]+$}}
return x * y;
}
__attribute__((noinline))
int g(int x, int y) {
// CHECK: mul-overflow by 0x{{[[:xdigit:]]+$}}
return x * (y + 1);
}
int main() {
h();
i();
int x = 2;
for (int i = 0; i < 10; ++i)
x = f(x, x);
x = 2;
for (int i = 0; i < 10; ++i)
x = g(x, x);
// CHECK-NOT: mul-overflow
}