diff options
author | Devang Patel <dpatel@apple.com> | 2011-01-11 00:30:27 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2011-01-11 00:30:27 +0000 |
commit | b1fd0eb8abe0b972ab793edab1d6f5e976217178 (patch) | |
tree | fdb4e34cee7bad08bc3aabecb20685df4fab02d0 /lib/CodeGen/CGDebugInfo.cpp | |
parent | 10ffc00e2177f042808f507c8dd50b744ed6f738 (diff) |
Fix debug info for __block variable referenced outside of block.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123199 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 37a88efcc4..ff07f758ed 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -1740,7 +1740,36 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, unsigned Tag, llvm::StringRef Name = VD->getName(); if (!Name.empty()) { - // Create the descriptor for the variable. + if (VD->hasAttr<BlocksAttr>()) { + CharUnits offset = CharUnits::fromQuantity(32); + llvm::SmallVector<llvm::Value *, 9> addr; + const llvm::Type *Int64Ty = llvm::Type::getInt64Ty(CGM.getLLVMContext()); + addr.push_back(llvm::ConstantInt::get(Int64Ty, llvm::DIFactory::OpPlus)); + // offset of __forwarding field + offset = + CharUnits::fromQuantity(CGM.getContext().Target.getPointerWidth(0)/8); + addr.push_back(llvm::ConstantInt::get(Int64Ty, offset.getQuantity())); + addr.push_back(llvm::ConstantInt::get(Int64Ty, llvm::DIFactory::OpDeref)); + addr.push_back(llvm::ConstantInt::get(Int64Ty, llvm::DIFactory::OpPlus)); + // offset of x field + offset = CharUnits::fromQuantity(XOffset/8); + addr.push_back(llvm::ConstantInt::get(Int64Ty, offset.getQuantity())); + + // Create the descriptor for the variable. + llvm::DIVariable D = + DBuilder.CreateComplexVariable(Tag, + llvm::DIDescriptor(RegionStack.back()), + VD->getName(), Unit, Line, Ty, + addr.data(), addr.size()); + + // Insert an llvm.dbg.declare into the current block. + llvm::Instruction *Call = + DBuilder.InsertDeclare(Storage, D, Builder.GetInsertBlock()); + + Call->setDebugLoc(llvm::DebugLoc::get(Line, Column, Scope)); + return; + } + // Create the descriptor for the variable. llvm::DIVariable D = DBuilder.CreateLocalVariable(Tag, llvm::DIDescriptor(Scope), Name, Unit, Line, Ty, |