[PATCH] D73282: Fix debug-info generation for block invocations so that we set the LinkageName instead of the Name
Shafik Yaghmour via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 23 10:46:04 PST 2020
shafik created this revision.
shafik added a reviewer: aprantl.
clang has an extension for block invocations <https://github.com/llvm-mirror/llvm/blob/master/include/llvm/Demangle/ItaniumDemangle.h#L5535> whose mangled name starts with `___Z`. Currently when generating debug-info for block invocations we are setting the `Name` to the mangled name as opposed to the `LinkageName`. This means we see the mangled name for block invcations ends up in `DW_AT_Name` as opposed to `DW_AT_linkage_name`.
This patch fixes this case so the `LinkageName` for block invocations is set to the mangled name.
https://reviews.llvm.org/D73282
Files:
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-block-invocation-linkage-name.cpp
Index: clang/test/CodeGenCXX/debug-info-block-invocation-linkage-name.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-block-invocation-linkage-name.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -fblocks -triple %itanium_abi_triple %s -o - | FileCheck %s
+
+// CHECK: !DISubprogram(linkageName: "___Z1fU13block_pointerFviE_block_invoke"
+void g(void (^call)(int));
+
+void f(void (^callback)(int)) {
+ g(^(int x){
+ callback(x);
+ });
+}
+
+void h() {
+ f(^(int x){});
+}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3656,7 +3656,11 @@
Fn);
} else {
// Use llvm function name.
- Name = Fn->getName();
+ if (Fn->getName().startswith("___Z"))
+ LinkageName = Fn->getName();
+ else
+ Name = Fn->getName();
+
Flags |= llvm::DINode::FlagPrototyped;
}
if (Name.startswith("\01"))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73282.239933.patch
Type: text/x-patch
Size: 1108 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200123/0cdaeff3/attachment-0001.bin>
More information about the cfe-commits
mailing list