]> granicus.if.org Git - clang/commitdiff
Debug info: Don't emit a bogus location for the global block pointer type
authorAdrian Prantl <aprantl@apple.com>
Mon, 6 Jul 2015 21:31:35 +0000 (21:31 +0000)
committerAdrian Prantl <aprantl@apple.com>
Mon, 6 Jul 2015 21:31:35 +0000 (21:31 +0000)
(__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
test/CodeGen/debug-info-block.c

index 8c4b4b3d0617af1a7cefe058c6269904e087c2a1..959c80632a629e82bd4caacda9172e3ee0f6955e 100644 (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);
index c4930bfc3c866f0e5be2141341921e898f1d88e3..697ed9ce7daac63b02e2e2c52be69d445f3c6a39 100644 (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;