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

llvm-svn: 241511
This commit is contained in:
Adrian Prantl 2015-07-06 21:31:35 +00:00
parent f2ea7e1d02
commit 498fff661d
2 changed files with 7 additions and 5 deletions

View File

@ -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);

View File

@ -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;