summaryrefslogtreecommitdiff
path: root/clang/test/CodeGen/call-graph-section-callback.cpp
diff options
context:
space:
mode:
authorFlorian Mayer <fmayer@google.com>2025-10-22 10:55:10 -0700
committerFlorian Mayer <fmayer@google.com>2025-10-22 10:55:10 -0700
commita0abc0af0a0a90878822f8107d70dad6f7cdfc26 (patch)
tree3317f49277cc325327cfe3d9a7be4b6e9bacd0f5 /clang/test/CodeGen/call-graph-section-callback.cpp
parente8230892228fd3b3e543c869f1238fa199d48bc1 (diff)
parent735b1ad667ac7373c89ccc0f0e757ef418f8f790 (diff)
[𝘀𝗽𝗿] changes introduced through rebaseusers/fmayer/spr/main.wip-smartpointers
Created using spr 1.3.7 [skip ci]
Diffstat (limited to 'clang/test/CodeGen/call-graph-section-callback.cpp')
-rw-r--r--clang/test/CodeGen/call-graph-section-callback.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/clang/test/CodeGen/call-graph-section-callback.cpp b/clang/test/CodeGen/call-graph-section-callback.cpp
new file mode 100644
index 000000000000..e9b0a1818e3a
--- /dev/null
+++ b/clang/test/CodeGen/call-graph-section-callback.cpp
@@ -0,0 +1,30 @@
+// Tests that callback function whose address is taken is attached Type ID metadata
+// as it is a potential indirect call target.
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -fexperimental-call-graph-section \
+// RUN: -emit-llvm -o %t %s
+// RUN: FileCheck %s < %t
+
+////////////////////////////////////////////////////////////////////////////////
+typedef void (*CallbackFn)(int);
+
+// Callback function with "internal" linkage.
+// CHECK-LABEL: define internal void @_ZL10myCallbacki(
+// CHECK-SAME: {{.*}} !type [[F_CALLBACK:![0-9]+]]
+static void myCallback(int value)
+{
+ volatile int sink = value;
+ (void)sink;
+}
+
+int takeCallbackAddress() {
+ // Take the address of the callback explicitly (address-taken function)
+ CallbackFn cb = &myCallback;
+ // Store the address in a volatile pointer to keep it observable
+ volatile void* addr = (void*)cb;
+ (void)addr;
+
+ return 0;
+}
+
+// CHECK: [[F_CALLBACK]] = !{i64 0, !"_ZTSFviE.generalized"}