From 5f8a176ddf220de8d337a8446ea1dab7bca48089 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Mon, 6 Jul 2015 21:31:35 +0000 Subject: [PATCH] Debug info: Don't emit a bogus location for the global block pointer type (__block_literal_generic). The arbitrary nature of the location confuses lldb and prevents type uniquing. rdar://problem/21602473 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241511 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDebugInfo.cpp | 8 ++++---- test/CodeGen/debug-info-block.c | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 8c4b4b3d06..959c80632a 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -723,10 +723,10 @@ llvm::DIType *CGDebugInfo::CreateType(const BlockPointerType *Ty, EltTys.clear(); unsigned Flags = llvm::DINode::FlagAppleBlock; - unsigned LineNo = getLineNumber(CurLoc); + unsigned LineNo = 0; auto *EltTy = - DBuilder.createStructType(Unit, "__block_descriptor", Unit, LineNo, + DBuilder.createStructType(Unit, "__block_descriptor", nullptr, LineNo, FieldOffset, 0, Flags, nullptr, Elements); // Bit size, align and offset of the type. @@ -746,7 +746,7 @@ llvm::DIType *CGDebugInfo::CreateType(const BlockPointerType *Ty, FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); FieldSize = CGM.getContext().getTypeSize(Ty); FieldAlign = CGM.getContext().getTypeAlign(Ty); - EltTys.push_back(DBuilder.createMemberType(Unit, "__descriptor", Unit, LineNo, + EltTys.push_back(DBuilder.createMemberType(Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign, FieldOffset, 0, DescTy)); @@ -754,7 +754,7 @@ llvm::DIType *CGDebugInfo::CreateType(const BlockPointerType *Ty, Elements = DBuilder.getOrCreateArray(EltTys); EltTy = - DBuilder.createStructType(Unit, "__block_literal_generic", Unit, LineNo, + DBuilder.createStructType(Unit, "__block_literal_generic", nullptr, LineNo, FieldOffset, 0, Flags, nullptr, Elements); BlockLiteralGeneric = DBuilder.createPointerType(EltTy, Size); diff --git a/test/CodeGen/debug-info-block.c b/test/CodeGen/debug-info-block.c index c4930bfc3c..697ed9ce7d 100644 --- a/test/CodeGen/debug-info-block.c +++ b/test/CodeGen/debug-info-block.c @@ -1,9 +1,11 @@ // RUN: %clang_cc1 -fblocks -g -emit-llvm -o - %s | FileCheck %s // Verify that the desired debugging type is generated for a structure -// member that is a pointer to a block. +// member that is a pointer to a block. // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "__block_literal_generic" +// CHECK-NOT: line // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "__block_descriptor" +// CHECK-NOT: line struct inStruct { void (^genericBlockPtr)(); } is; -- 2.40.0