aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2008-10-17 01:07:56 +0000
committerDaniel Dunbar <daniel@zuster.org>2008-10-17 01:07:56 +0000
commit5273f514a1e8dd5f5ebd0f94d2c59f7e0e88a674 (patch)
tree27244824831c143576257bf0c272238ef34872da /lib/CodeGen/CGDebugInfo.cpp
parentcd162ccbbf96fcdc1f62f3bb604ae4455af3a442 (diff)
Quick patch for PR2784, assert genereting debug info for opaque
structure. - I'm not sure yet about the behavior, but this at least prevents the crash. Add some asserts on RegionStack usage. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57661 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--lib/CodeGen/CGDebugInfo.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index d6902bb93e..240343dd82 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -383,6 +383,10 @@ CGDebugInfo::getOrCreateRecordType(QualType type, llvm::CompileUnitDesc *Unit)
return NULL;
RecordDecl *RecDecl = type->getAsRecordType()->getDecl();
+ // We can not get the type for forward declarations.
+ // FIXME: What *should* we be doing here?
+ if (!RecDecl->getDefinition(M->getContext()))
+ return NULL;
const ASTRecordLayout &RL = M->getContext().getASTRecordLayout(RecDecl);
SourceManager &SM = M->getContext().getSourceManager();
@@ -676,7 +680,7 @@ void CGDebugInfo::EmitRegionStart(llvm::Function *Fn,
llvm::IRBuilder<> &Builder)
{
llvm::BlockDesc *Block = new llvm::BlockDesc();
- if (RegionStack.size() > 0)
+ if (!RegionStack.empty())
Block->setContext(RegionStack.back());
RegionStack.push_back(Block);
@@ -693,6 +697,8 @@ void CGDebugInfo::EmitRegionStart(llvm::Function *Fn,
/// region - "llvm.dbg.region.end."
void CGDebugInfo::EmitRegionEnd(llvm::Function *Fn, llvm::IRBuilder<> &Builder)
{
+ assert(!RegionStack.empty() && "Region stack mismatch, stack empty!");
+
// Lazily construct llvm.dbg.region.end function.
if (!RegionEndFn)
RegionEndFn =llvm::Intrinsic::getDeclaration(&M->getModule(),
@@ -712,6 +718,8 @@ void CGDebugInfo::EmitDeclare(const VarDecl *decl, unsigned Tag,
llvm::Value *AI,
llvm::IRBuilder<> &Builder)
{
+ assert(!RegionStack.empty() && "Region stack mismatch, stack empty!");
+
// FIXME: If it is a compiler generated temporary then return.
// Construct llvm.dbg.declare function.