[compiler-rt] [NFC][cfi] Update diagnostic tests for better location matching (PR #194557)

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 28 00:20:33 PDT 2026


https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/194557

>From 90372f5555e6d9f3a350fa5c4aa6a5deef265a8a Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Tue, 28 Apr 2026 00:01:12 -0700
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.7
---
 compiler-rt/test/cfi/cross-dso-diagnostic.cpp           | 2 +-
 compiler-rt/test/cfi/cross-dso/icall/icall-from-dso.cpp | 2 +-
 compiler-rt/test/cfi/cross-dso/icall/icall.cpp          | 2 +-
 compiler-rt/test/cfi/icall/bad-signature.c              | 5 ++---
 compiler-rt/test/cfi/mfcall.cpp                         | 4 ++--
 5 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/compiler-rt/test/cfi/cross-dso-diagnostic.cpp b/compiler-rt/test/cfi/cross-dso-diagnostic.cpp
index ed2cab04c9180..9d0e077a7eaf7 100644
--- a/compiler-rt/test/cfi/cross-dso-diagnostic.cpp
+++ b/compiler-rt/test/cfi/cross-dso-diagnostic.cpp
@@ -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
 
diff --git a/compiler-rt/test/cfi/cross-dso/icall/icall-from-dso.cpp b/compiler-rt/test/cfi/cross-dso/icall/icall-from-dso.cpp
index b08135758efcf..d9f128ddf1026 100644
--- a/compiler-rt/test/cfi/cross-dso/icall/icall-from-dso.cpp
+++ b/compiler-rt/test/cfi/cross-dso/icall/icall-from-dso.cpp
@@ -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=
diff --git a/compiler-rt/test/cfi/cross-dso/icall/icall.cpp b/compiler-rt/test/cfi/cross-dso/icall/icall.cpp
index b4ee48d94ea03..479047a6b05d6 100644
--- a/compiler-rt/test/cfi/cross-dso/icall/icall.cpp
+++ b/compiler-rt/test/cfi/cross-dso/icall/icall.cpp
@@ -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=
diff --git a/compiler-rt/test/cfi/icall/bad-signature.c b/compiler-rt/test/cfi/icall/bad-signature.c
index 183e62738bb26..044c0e0f3cb4f 100644
--- a/compiler-rt/test/cfi/icall/bad-signature.c
+++ b/compiler-rt/test/cfi/icall/bad-signature.c
@@ -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
diff --git a/compiler-rt/test/cfi/mfcall.cpp b/compiler-rt/test/cfi/mfcall.cpp
index d4666df8d5333..b7e1acf6c8824 100644
--- a/compiler-rt/test/cfi/mfcall.cpp
+++ b/compiler-rt/test/cfi/mfcall.cpp
@@ -63,12 +63,12 @@ int main(int argc, char **argv) {
   switch (argv[1][0]) {
     case 'a':
       // A: runtime error: control flow integrity check for type 'int (S::*)()' failed during non-virtual pointer to member function call
-      // A: note: S::f1() defined here
+      // A: {{ld-temp.o|mfcall.cpp}}: note: S::f1() defined here
       (s.*bitcast<S_int>(&S::f1))();
       break;
     case 'b':
       // B: runtime error: control flow integrity check for type 'int (T::*)()' failed during non-virtual pointer to member function call
-      // B: note: S::f2() defined here
+      // B: {{ld-temp.o|mfcall.cpp}}: note: S::f2() defined here
       (t.*bitcast<T_int>(&S::f2))();
       break;
     case 'c':

>From f29980535ad5599500097ceac2dc06720ac986a9 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Tue, 28 Apr 2026 00:20:15 -0700
Subject: [PATCH 2/2] update

Created using spr 1.3.7
---
 compiler-rt/test/cfi/cross-dso/icall/diag.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compiler-rt/test/cfi/cross-dso/icall/diag.cpp b/compiler-rt/test/cfi/cross-dso/icall/diag.cpp
index 4df0a3858b418..a8c7f36608980 100644
--- a/compiler-rt/test/cfi/cross-dso/icall/diag.cpp
+++ b/compiler-rt/test/cfi/cross-dso/icall/diag.cpp
@@ -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 {



More information about the llvm-commits mailing list