xref: /llvm-project/clang/test/Driver/fsanitize-signed-integer-overflow.c (revision 5f38436d34360d17b58f643650f3605bb9609a34)
1*5f38436dSFangrui Song /// When -fwrapv (implied by -fno-strict-overflow) is enabled,
2*5f38436dSFangrui Song /// -fsanitize=undefined does not expand to signed-integer-overflow.
3*5f38436dSFangrui Song /// -fsanitize=signed-integer-overflow is unaffected by -fwrapv.
4*5f38436dSFangrui Song 
5*5f38436dSFangrui Song // RUN: %clang -### --target=x86_64-linux -fwrapv -fsanitize=signed-integer-overflow %s 2>&1 | FileCheck %s
6*5f38436dSFangrui Song // CHECK: -fsanitize=signed-integer-overflow
7*5f38436dSFangrui Song // CHECK: -fsanitize-recover=signed-integer-overflow
8*5f38436dSFangrui Song 
9*5f38436dSFangrui Song // RUN: %clang -### --target=x86_64-linux -fno-strict-overflow -fsanitize=undefined %s 2>&1 | FileCheck %s --check-prefix=EXCLUDE
10*5f38436dSFangrui Song // RUN: %clang -### --target=x86_64-linux -fstrict-overflow -fwrapv -fsanitize=undefined %s 2>&1 | FileCheck %s --check-prefix=EXCLUDE
11*5f38436dSFangrui Song // EXCLUDE:     -fsanitize=alignment,array-bounds,
12*5f38436dSFangrui Song // EXCLUDE-NOT: signed-integer-overflow,
13*5f38436dSFangrui Song // EXCLUDE:      -fsanitize-recover=alignment,array-bounds,
14*5f38436dSFangrui Song // EXCLUDE-SAME: signed-integer-overflow
15*5f38436dSFangrui Song 
16*5f38436dSFangrui Song // RUN: %clang -### --target=x86_64-linux -fwrapv -fsanitize=undefined -fsanitize=signed-integer-overflow %s 2>&1 | FileCheck %s --check-prefix=INCLUDE
17*5f38436dSFangrui Song // RUN: %clang -### --target=x86_64-linux -fno-strict-overflow -fno-sanitize=signed-integer-overflow -fsanitize=undefined -fsanitize=signed-integer-overflow %s 2>&1 | FileCheck %s --check-prefix=INCLUDE
18*5f38436dSFangrui Song // INCLUDE:      -fsanitize=alignment,array-bounds,
19*5f38436dSFangrui Song // INCLUDE-SAME: signed-integer-overflow
20*5f38436dSFangrui Song // INCLUDE:      -fsanitize-recover=alignment,array-bounds,
21*5f38436dSFangrui Song // INCLUDE-SAME: signed-integer-overflow
22*5f38436dSFangrui Song 
23*5f38436dSFangrui Song /// -fsanitize-trap=undefined expands to signed-integer-overflow regardless of -fwrapv.
24*5f38436dSFangrui Song // RUN: %clang -### --target=x86_64-linux -fwrapv -fsanitize=undefined -fsanitize=signed-integer-overflow -fsanitize-trap=undefined %s 2>&1 | FileCheck %s --check-prefix=INCLUDE-TRAP
25*5f38436dSFangrui Song // INCLUDE-TRAP:      -fsanitize=alignment,array-bounds,
26*5f38436dSFangrui Song // INCLUDE-TRAP-SAME: signed-integer-overflow
27*5f38436dSFangrui Song // INCLUDE-TRAP:      -fsanitize-trap=alignment,array-bounds,
28*5f38436dSFangrui Song // INCLUDE-TRAP-SAME: signed-integer-overflow
29