From: John McCall Date: Wed, 2 Mar 2011 06:57:14 +0000 (+0000) Subject: Hack in something so that we emit better debug information about X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d113a6fb6d09778bfc2e6edfd7c8b978a366f013;p=clang Hack in something so that we emit better debug information about captured __block variables in the block-literal type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126834 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 49eb6c3d4c..e6d2af3a53 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -2049,10 +2049,24 @@ void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block, } const VarDecl *variable = capture->getVariable(); - QualType type = (capture->isByRef() ? C.VoidPtrTy : variable->getType()); llvm::StringRef name = variable->getName(); - fields.push_back(createFieldType(name, type, 0, loc, AS_public, - offsetInBits, tunit)); + + llvm::DIType fieldType; + if (capture->isByRef()) { + std::pair ptrInfo = C.getTypeInfo(C.VoidPtrTy); + + // FIXME: this creates a second copy of this type! + uint64_t xoffset; + fieldType = EmitTypeForVarWithBlocksAttr(variable, &xoffset); + fieldType = DBuilder.createPointerType(fieldType, ptrInfo.first); + fieldType = DBuilder.createMemberType(name, tunit, line, + ptrInfo.first, ptrInfo.second, + offsetInBits, 0, fieldType); + } else { + fieldType = createFieldType(name, variable->getType(), 0, + loc, AS_public, offsetInBits, tunit); + } + fields.push_back(fieldType); } llvm::SmallString<36> typeName;