48 lines · c
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=ANNOTATE4 5//==============================================================================6// Detailed trap reasons7//==============================================================================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,DETAILED12 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,DETAILED16 17//==============================================================================18// Basic trap reasons19//==============================================================================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,BASIC24 25//==============================================================================26// No trap reasons27//==============================================================================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-ANNOTATE32 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-ANNOTATE36 37int add_overflow(int a, int b) { return a + b; }38 39// ANNOTATE-LABEL: @add_overflow40// 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_overflow46// NO-ANNOTATE: call void @llvm.ubsantrap(i8 0) {{.*}}!dbg [[LOC:![0-9]+]]47// NO-ANNOTATE-NOT: __clang_trap_msg48