Debian Codegraph @

clang/test/DebugInfo/Generic/ubsan-trap-reason-flag.c

raw
1 // RUN: %clang_cc1 -triple arm64-apple-macosx14.0.0 -O0 -debug-info-kind=standalone -dwarf-version=5 \
2 // RUN: -fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow -emit-llvm %s -o - \
3 // RUN: | FileCheck %s --check-prefix=ANNOTATE
4
5 //==============================================================================
6 // Detailed trap reasons
7 //==============================================================================
8
9 // RUN: %clang_cc1 -triple arm64-apple-macosx14.0.0 -O0 -debug-info-kind=standalone -dwarf-version=5 \
10 // RUN: -fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow \
11 // RUN: -fsanitize-debug-trap-reasons -emit-llvm %s -o - | FileCheck %s --check-prefixes=ANNOTATE,DETAILED
12
13 // RUN: %clang_cc1 -triple arm64-apple-macosx14.0.0 -O0 -debug-info-kind=standalone -dwarf-version=5 \
14 // RUN: -fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow \
15 // RUN: -fsanitize-debug-trap-reasons=detailed -emit-llvm %s -o - | FileCheck %s --check-prefixes=ANNOTATE,DETAILED
16
17 //==============================================================================
18 // Basic trap reasons
19 //==============================================================================
20
21 // RUN: %clang_cc1 -triple arm64-apple-macosx14.0.0 -O0 -debug-info-kind=standalone -dwarf-version=5 \
22 // RUN: -fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow \
23 // RUN: -fsanitize-debug-trap-reasons=basic -emit-llvm %s -o - | FileCheck %s --check-prefixes=ANNOTATE,BASIC
24
25 //==============================================================================
26 // No trap reasons
27 //==============================================================================
28
29 // RUN: %clang_cc1 -triple arm64-apple-macosx14.0.0 -O0 -debug-info-kind=standalone -dwarf-version=5 \
30 // RUN: -fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow \
31 // RUN: -fno-sanitize-debug-trap-reasons -emit-llvm %s -o - | FileCheck %s --check-prefix=NO-ANNOTATE
32
33 // RUN: %clang_cc1 -triple arm64-apple-macosx14.0.0 -O0 -debug-info-kind=standalone -dwarf-version=5 \
34 // RUN: -fsanitize=signed-integer-overflow -fsanitize-trap=signed-integer-overflow \
35 // RUN: -fsanitize-debug-trap-reasons=none -emit-llvm %s -o - | FileCheck %s --check-prefix=NO-ANNOTATE
36
37 int add_overflow(int a, int b) { return a + b; }
38
39 // ANNOTATE-LABEL: @add_overflow
40 // ANNOTATE: call void @llvm.ubsantrap(i8 0) {{.*}}!dbg [[LOC:![0-9]+]]
41 // ANNOTATE: [[LOC]] = !DILocation(line: 0, scope: [[MSG:![0-9]+]], {{.+}})
42 // DETAILED: [[MSG]] = distinct !DISubprogram(name: "__clang_trap_msg$Undefined Behavior Sanitizer$signed integer addition overflow in 'a + b'"
43 // BASIC: [[MSG]] = distinct !DISubprogram(name: "__clang_trap_msg$Undefined Behavior Sanitizer$Integer addition overflowed"
44
45 // NO-ANNOTATE-LABEL: @add_overflow
46 // NO-ANNOTATE: call void @llvm.ubsantrap(i8 0) {{.*}}!dbg [[LOC:![0-9]+]]
47 // NO-ANNOTATE-NOT: __clang_trap_msg