31 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,unsigned-integer-overflow \3// RUN: -fsanitize-trap=signed-integer-overflow,unsigned-integer-overflow \4// RUN: -emit-llvm %s -o - | FileCheck --check-prefixes=CHECK,DETAILED %s5 6// RUN: %clang_cc1 -triple arm64-apple-macosx14.0.0 -O0 -debug-info-kind=standalone -dwarf-version=5 \7// RUN: -fsanitize=signed-integer-overflow,unsigned-integer-overflow \8// RUN: -fsanitize-trap=signed-integer-overflow,unsigned-integer-overflow \9// RUN: -fsanitize-debug-trap-reasons=basic \10// RUN: -emit-llvm %s -o - | FileCheck --check-prefixes=CHECK,BASIC %s11 12int smul_overflow(int a, int b) { return a * b; }13 14unsigned mul_overflow(unsigned c, unsigned d) { return c * d; }15 16// CHECK-LABEL: @smul_overflow17// CHECK: call void @llvm.ubsantrap(i8 12) {{.*}}!dbg [[SLOC:![0-9]+]]18 19// CHECK-LABEL: @mul_overflow20// CHECK: call void @llvm.ubsantrap(i8 12) {{.*}}!dbg [[LOC:![0-9]+]]21 22// DETAILED: [[SLOC]] = !DILocation(line: 0, scope: [[SMSG:![0-9]+]], {{.+}})23// DETAILED: [[SMSG]] = distinct !DISubprogram(name: "__clang_trap_msg$Undefined Behavior Sanitizer$signed integer multiplication overflow in 'a * b'"24// DETAILED: [[LOC]] = !DILocation(line: 0, scope: [[MSG:![0-9]+]], {{.+}})25// DETAILED: [[MSG]] = distinct !DISubprogram(name: "__clang_trap_msg$Undefined Behavior Sanitizer$unsigned integer multiplication overflow in 'c * d'"26 27// In "Basic" mode the trap reason is shared by both functions.28// BASIC: [[SLOC]] = !DILocation(line: 0, scope: [[MSG:![0-9]+]], {{.+}})29// BASIC: [[MSG]] = distinct !DISubprogram(name: "__clang_trap_msg$Undefined Behavior Sanitizer$Integer multiplication overflowed"30// BASIC: [[LOC]] = !DILocation(line: 0, scope: [[MSG:![0-9]+]], {{.+}})31