[NFC][cfi] Update diagnostic tests for better location matching (#194557)

This commit is contained in:
Vitaly Buka
2026-04-28 10:55:18 -07:00
committed by GitHub
parent 264ac2d3af
commit 6d01ff1c50
5 changed files with 6 additions and 7 deletions

View File

@@ -33,7 +33,7 @@ int main() {
}
// CHECK: runtime error: control flow integrity check for type 'void *()' failed during indirect function call
// CHECK: dso_symbol defined here
// CHECK: cross-dso-diagnostic.cpp:[[@LINE-13]]: note: dso_symbol defined here
// CHECK: check failed in {{.*}}_exe_suffix, destination function located in {{.*}}[[DSONAME]]
void *S = fp(); // trigger cfi-icall failure

View File

@@ -113,7 +113,7 @@ int main(int argc, char *argv[]) {
void *p;
if (argv[1][0] == 'i') {
// ICALL-DIAG: runtime error: control flow integrity check for type 'void *(int)' failed during indirect function call
// ICALL-DIAG-NEXT: note: create_B() defined here
// ICALL-DIAG-NEXT: dynamic.so+0x{{[[:xdigit:]]+}}): note: create_B() defined here
// ICALL-NODIAG-NOT: runtime error: control flow integrity check {{.*}} during indirect function call
p = ((void *(*)(int))create_B)(42);
} else {

View File

@@ -18,7 +18,7 @@ void f() {
// CHECK: =2=
fprintf(stderr, "=2=\n");
// CFI-DIAG: runtime error: control flow integrity check for type 'void (int)' failed during indirect function call
// CFI-DIAG-NEXT: note: g() defined here
// CFI-DIAG-NEXT: ({{.*}}exe+0x{{[[:xdigit:]]+}}): note: g() defined here
((void (*)(int))g)(42); // UB here
// CHECK-DIAG: =3=
// CHECK-NOT: =3=

View File

@@ -21,7 +21,7 @@ int main() {
// CHECK: =2=
fprintf(stderr, "=2=\n");
// CFI-DIAG: runtime error: control flow integrity check for type 'void (int)' failed during indirect function call
// CFI-DIAG-NEXT: note: f() defined here
// CFI-DIAG-NEXT: ({{.*}}dynamic.so+0x{{[[:xdigit:]]+}}): note: f() defined here
((void (*)(int))f)(42); // UB here
// CHECK-DIAG: =3=
// CHECK-NOT: =3=

View File

@@ -9,8 +9,7 @@
#include <stdio.h>
void f() {
}
void f() {}
int main() {
// CFI: 1
@@ -18,7 +17,7 @@ int main() {
fprintf(stderr, "1\n");
// CFI-DIAG: runtime error: control flow integrity check for type 'void (int)' failed during indirect function call
// CFI-DIAG: f defined here
// CFI-DIAG: bad-signature.c:[[@LINE-8]]: note: f defined here
((void (*)(int))f)(42); // UB here
// CFI-NOT: 2