1// RUN: %clangxx -w -fsanitize=signed-integer-overflow,nullability-return,returns-nonnull-attribute -fsanitize-recover=all %s -o %t && %run %t 2>&1 | FileCheck %s
2
3#include <stdint.h>
4#include <stdio.h>
5
6int *_Nonnull h() {
7 // CHECK: nullability-return by 0x{{[[:xdigit:]]+$}}
8 return NULL;
9}
10
11__attribute__((returns_nonnull))
12int *i() {
13 // CHECK: nonnull-return by 0x{{[[:xdigit:]]+$}}
14 return NULL;
15}
16
17__attribute__((noinline))
18int f(int x, int y) {
19 // CHECK: mul-overflow by 0x{{[[:xdigit:]]+$}}
20 return x * y;
21}
22
23__attribute__((noinline))
24int g(int x, int y) {
25 // CHECK: mul-overflow by 0x{{[[:xdigit:]]+$}}
26 return x * (y + 1);
27}
28
29int main() {
30 h();
31 i();
32 int x = 2;
33 for (int i = 0; i < 10; ++i)
34 x = f(x, y: x);
35 x = 2;
36 for (int i = 0; i < 10; ++i)
37 x = g(x, y: x);
38 // CHECK-NOT: mul-overflow
39}
40

source code of compiler-rt/test/ubsan_minimal/TestCases/recover-dedup.cpp