brintos

brintos / llvm-project-archived public Read only

0
0
Text · 755 B · 9304f51 Raw
26 lines · c
1// RUN: %clang_cc1 -triple arm64-apple-macosx14.0.0 -O0 -debug-info-kind=standalone -dwarf-version=5 \2// RUN: -fsanitize=cfi-icall -fsanitize-trap=cfi-icall -emit-llvm %s -o - | FileCheck %s3 4typedef int (*fp_t)(int);5 6int good(int x) { return x + 1; }7 8int bad(void) { return 0; }9 10int cfi_trigger(int a) {11  fp_t p = good;12  int r1 = p(a);13 14  p = (fp_t)(void *)bad;15  int r2 = p(a);16 17  return r1 + r2;18}19 20// CHECK-LABEL: @good21// CHECK-LABEL: @bad22// CHECK-LABEL: @cfi_trigger23// CHECK: call void @llvm.ubsantrap(i8 2) {{.*}}!dbg [[LOC:![0-9]+]]24// CHECK: [[LOC]] = !DILocation(line: 0, scope: [[MSG:![0-9]+]], {{.+}})25// CHECK: [[MSG]] = distinct !DISubprogram(name: "__clang_trap_msg$Undefined Behavior Sanitizer$Control flow integrity check failed"26