| 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 |
|
| 6 |
int *_Nonnull h() { |
| 7 |
// CHECK: nullability-return by 0x{{[[:xdigit:]]+$}} |
| 8 |
return NULL; |
| 9 |
} |
| 10 |
|
| 11 |
__attribute__((returns_nonnull)) |
| 12 |
int *i() { |
| 13 |
// CHECK: nonnull-return by 0x{{[[:xdigit:]]+$}} |
| 14 |
return NULL; |
| 15 |
} |
| 16 |
|
| 17 |
__attribute__((noinline)) |
| 18 |
int f(int x, int y) { |
| 19 |
// CHECK: mul-overflow by 0x{{[[:xdigit:]]+$}} |
| 20 |
return x * y; |
| 21 |
} |
| 22 |
|
| 23 |
__attribute__((noinline)) |
| 24 |
int g(int x, int y) { |
| 25 |
// CHECK: mul-overflow by 0x{{[[:xdigit:]]+$}} |
| 26 |
return x * (y + 1); |
| 27 |
} |
| 28 |
|
| 29 |
int main() { |
| 30 |
h(); |
| 31 |
i(); |
| 32 |
int x = 2; |
| 33 |
for (int i = 0; i < 10; ++i) |
| 34 |
x = f(x, x); |
| 35 |
x = 2; |
| 36 |
for (int i = 0; i < 10; ++i) |
| 37 |
x = g(x, x); |
| 38 |
// CHECK-NOT: mul-overflow |
| 39 |
} |