[clang] [clang] Fix crash on no-prototype indirect calls with -fexperimental-call-graph-section (PR #210846)
Roland McGrath via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 13 20:54:08 PDT 2026
================
@@ -0,0 +1,123 @@
+/// Tests that we assign appropriate identifiers to indirect calls for no-prototype
+/// functions based on call site argument types.
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -fexperimental-call-graph-section \
+// RUN: -emit-llvm -o /dev/null %s 2>&1 | FileCheck --check-prefixes=WARN_NO_PROTOTYPE_ITANIUM %s
+
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fexperimental-call-graph-section \
+// RUN: -emit-llvm -o /dev/null %s 2>&1 | FileCheck --check-prefixes=WARN_NO_PROTOTYPE_MS %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -fexperimental-call-graph-section \
+// RUN: -emit-llvm -o - %s | FileCheck --check-prefixes=CHECK,ITANIUM %s
+
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -fexperimental-call-graph-section \
+// RUN: -emit-llvm -o - %s | FileCheck --check-prefixes=CHECK,MS %s
+
+// CHECK-LABEL: define {{(dso_local)?}} void @foo(
+// CHECK-SAME: {{.*}} !callgraph [[F_TVOID_NOPROTO:![0-9]+]]
+void foo() {
+}
+
+// CHECK-LABEL: define {{(dso_local)?}} void @foo_with_proto(
+// CHECK-SAME: {{.*}} !callgraph [[F_TVOID:![0-9]+]]
+void foo_with_proto(void) {
+}
+
+// CHECK-LABEL: define {{(dso_local)?}} void @bar(
+// CHECK-SAME: {{.*}} !callgraph [[F_TVOID_NOPROTO]]
+void bar() {
+ void (*fp)() = foo;
+ // ITANIUM: call {{.*}}, !callee_type [[F_TVOID_CT:![0-9]+]]
+ // MS: call {{.*}}, !callee_type [[F_TVOID_CT:![0-9]+]]
+ // WARN_NO_PROTOTYPE_ITANIUM: warning: indirect call to a function with no prototype; generating type metadata for assumed prototype 'void (void)' (type string: _ZTSFvvE) [-Wcall-graph-section-no-prototype]
----------------
frobtech wrote:
I don't think you should match on the mangled strings in this test. That's not the purpose of the test. Aside from that, the messages don't differ for the different C++ ABIs. So the test can use a single set of matching patterns with regexps to ignore the actual string. (It's not 100% clear to me that anyone needs to see that string in this warning, since they have the normalized readable type name that humans want to see. But that's a separate issue from the question of avoiding so much duplication and boilerplate in the lit test.)
https://github.com/llvm/llvm-project/pull/210846
More information about the cfe-commits
mailing list