diff options
author | Mike Stump <mrs@apple.com> | 2009-09-30 02:43:10 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-09-30 02:43:10 +0000 |
commit | 2e722b915c8903e2c3c02e0895f554d2702bb158 (patch) | |
tree | 6f287bd358b301d66a07bfd719632368f5dc5b60 /clang/lib/CodeGen/CGBlocks.cpp | |
parent | 882f4c11edfff236f5fd1c23f195182e1ffbf683 (diff) | |
download | bcm5719-llvm-2e722b915c8903e2c3c02e0895f554d2702bb158.tar.gz bcm5719-llvm-2e722b915c8903e2c3c02e0895f554d2702bb158.zip |
Improve debugging information for BlockDeclRefExpr. WIP. Given this
scheme, we can switch the previous scheme over to using this code
path. There's a bit of simplifications yet to do as well.
llvm-svn: 83138
Diffstat (limited to 'clang/lib/CodeGen/CGBlocks.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGBlocks.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index daeeee56f90..e9648251d2b 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -11,6 +11,7 @@ // //===----------------------------------------------------------------------===// +#include "CGDebugInfo.h" #include "CodeGenFunction.h" #include "CodeGenModule.h" #include "clang/AST/DeclObjC.h" @@ -661,9 +662,40 @@ CodeGenFunction::GenerateBlockFunction(const BlockExpr *BExpr, StartFunction(BD, ResultType, Fn, Args, BExpr->getBody()->getLocEnd()); + + // Save a spot to insert the debug information for all the BlockDeclRefDecls. + llvm::BasicBlock *entry = Builder.GetInsertBlock(); + llvm::BasicBlock::iterator entry_ptr = Builder.GetInsertPoint(); + CurFuncDecl = OuterFuncDecl; CurCodeDecl = BD; EmitStmt(BExpr->getBody()); + + if (CGDebugInfo *DI = getDebugInfo()) { + llvm::BasicBlock *end = Builder.GetInsertBlock(); + llvm::BasicBlock::iterator end_ptr = Builder.GetInsertPoint(); + + // Emit debug information for all the BlockDeclRefDecls. + // First, go back to the entry... + Builder.SetInsertPoint(entry, entry_ptr); + + // And then insert the debug information.. + for (unsigned i=0; i < BlockDeclRefDecls.size(); ++i) { + const Expr *E = BlockDeclRefDecls[i]; + const BlockDeclRefExpr *BDRE = dyn_cast<BlockDeclRefExpr>(E); + if (BDRE) { + const ValueDecl *D = BDRE->getDecl(); + DI->setLocation(D->getLocation()); + DI->EmitDeclareOfBlockDeclRefVariable(BDRE, + LocalDeclMap[getBlockStructDecl()], + Builder, this); + } + } + + // Then go back to the end, and we're done. + Builder.SetInsertPoint(end, end_ptr); + } + FinishFunction(cast<CompoundStmt>(BExpr->getBody())->getRBracLoc()); // The runtime needs a minimum alignment of a void *. |