Author: shafik Date: 2020-02-05T11:07:30-08:00 New Revision: 428583dd22fdc8f789390822e7b8ef4a5534721d
URL: https://github.com/llvm/llvm-project/commit/428583dd22fdc8f789390822e7b8ef4a5534721d DIFF: https://github.com/llvm/llvm-project/commit/428583dd22fdc8f789390822e7b8ef4a5534721d.diff LOG: [DebugInfo] Fix debug-info generation for block invocations so that we set the LinkageName Currently when generating debug-info for a BlockDecl we are setting the Name to the mangled name and not setting the LinkageName. This means we see the mangled name for block invcations ends up in DW_AT_Name and not in DW_AT_linkage_name. This patch fixes this case so that we also set the LinkageName as well. Differential Revision: https://reviews.llvm.org/D73282 Added: clang/test/CodeGenCXX/debug-info-block-invocation-linkage-name.cpp Modified: clang/lib/CodeGen/CGDebugInfo.cpp Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 99af4e222b9a..0e54e9419356 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -3665,8 +3665,11 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, SourceLocation Loc, Name = getDynamicInitializerName(cast<VarDecl>(D), GD.getDynamicInitKind(), Fn); } else { - // Use llvm function name. Name = Fn->getName(); + + if (const auto *BD = dyn_cast<BlockDecl>(D)) + LinkageName = Name; + Flags |= llvm::DINode::FlagPrototyped; } if (Name.startswith("\01")) diff --git a/clang/test/CodeGenCXX/debug-info-block-invocation-linkage-name.cpp b/clang/test/CodeGenCXX/debug-info-block-invocation-linkage-name.cpp new file mode 100644 index 000000000000..5fadae9b439f --- /dev/null +++ b/clang/test/CodeGenCXX/debug-info-block-invocation-linkage-name.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -fblocks -triple %itanium_abi_triple %s -o - | FileCheck %s + +// CHECK: !DISubprogram(name: "___Z1fU13block_pointerFviE_block_invoke", 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){ + }); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits