aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CodeGen/CGDebugInfo.cpp6
-rw-r--r--lib/CodeGen/CGDebugInfo.h2
-rw-r--r--lib/CodeGen/CGDecl.cpp9
-rw-r--r--lib/CodeGen/CGStmt.cpp11
-rw-r--r--lib/CodeGen/CodeGenFunction.cpp8
-rw-r--r--lib/CodeGen/CodeGenModule.cpp3
6 files changed, 16 insertions, 23 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index 240343dd82..f326be2769 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -59,6 +59,8 @@ CGDebugInfo::CGDebugInfo(CodeGenModule *m)
CGDebugInfo::~CGDebugInfo()
{
+ assert(RegionStack.empty() && "Region stack mismatch, stack not empty!");
+
delete SR;
// Free CompileUnitCache.
@@ -111,7 +113,8 @@ CGDebugInfo::~CGDebugInfo()
}
void CGDebugInfo::setLocation(SourceLocation loc) {
- CurLoc = M->getContext().getSourceManager().getLogicalLoc(loc);
+ if (loc.isValid())
+ CurLoc = M->getContext().getSourceManager().getLogicalLoc(loc);
}
/// getCastValueFor - Return a llvm representation for a given debug information
@@ -711,6 +714,7 @@ void CGDebugInfo::EmitRegionEnd(llvm::Function *Fn, llvm::IRBuilder<> &Builder)
llvm::DebugInfoDesc *DID = RegionStack.back();
Builder.CreateCall(RegionEndFn, getCastValueFor(DID), "");
RegionStack.pop_back();
+ // FIXME: Should be freeing here?
}
/// EmitDeclare - Emit local variable declaration debug info.
diff --git a/lib/CodeGen/CGDebugInfo.h b/lib/CodeGen/CGDebugInfo.h
index 7e41143837..22a45ce8b5 100644
--- a/lib/CodeGen/CGDebugInfo.h
+++ b/lib/CodeGen/CGDebugInfo.h
@@ -101,6 +101,8 @@ public:
CGDebugInfo(CodeGenModule *m);
~CGDebugInfo();
+ /// setLocation - Update the current source location. If \arg loc is
+ /// invalid it is ignored.
void setLocation(SourceLocation loc);
/// EmitStopPoint - Emit a call to llvm.dbg.stoppoint to indicate a change of
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp
index 57e9c39832..fd2e357370 100644
--- a/lib/CodeGen/CGDecl.cpp
+++ b/lib/CodeGen/CGDecl.cpp
@@ -130,8 +130,7 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) {
// Emit global variable debug descriptor for static vars.
CGDebugInfo *DI = CGM.getDebugInfo();
if(DI) {
- if(D.getLocation().isValid())
- DI->setLocation(D.getLocation());
+ DI->setLocation(D.getLocation());
DI->EmitGlobalVariable(static_cast<llvm::GlobalVariable *>(GV), &D);
}
@@ -177,8 +176,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
// Emit debug info for local var declaration.
CGDebugInfo *DI = CGM.getDebugInfo();
if(DI) {
- if(D.getLocation().isValid())
- DI->setLocation(D.getLocation());
+ DI->setLocation(D.getLocation());
DI->EmitDeclare(&D, llvm::dwarf::DW_TAG_auto_variable,
DeclPtr, Builder);
}
@@ -235,8 +233,7 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, llvm::Value *Arg) {
// Emit debug info for param declaration.
CGDebugInfo *DI = CGM.getDebugInfo();
if(DI) {
- if(D.getLocation().isValid())
- DI->setLocation(D.getLocation());
+ DI->setLocation(D.getLocation());
DI->EmitDeclare(&D, llvm::dwarf::DW_TAG_arg_variable,
DeclPtr, Builder);
}
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp
index fed0eee7f0..20312de5ba 100644
--- a/lib/CodeGen/CGStmt.cpp
+++ b/lib/CodeGen/CGStmt.cpp
@@ -33,10 +33,7 @@ void CodeGenFunction::EmitStmt(const Stmt *S) {
// executable code. So do not generate a stoppoint for that.
CGDebugInfo *DI = CGM.getDebugInfo();
if (DI && S->getStmtClass() != Stmt::CompoundStmtClass) {
- if (S->getLocStart().isValid()) {
- DI->setLocation(S->getLocStart());
- }
-
+ DI->setLocation(S->getLocStart());
DI->EmitStopPoint(CurFn, Builder);
}
@@ -122,8 +119,7 @@ RValue CodeGenFunction::EmitCompoundStmt(const CompoundStmt &S, bool GetLast,
// FIXME: handle vla's etc.
CGDebugInfo *DI = CGM.getDebugInfo();
if (DI) {
- if (S.getLBracLoc().isValid())
- DI->setLocation(S.getLBracLoc());
+ DI->setLocation(S.getLBracLoc());
DI->EmitRegionStart(CurFn, Builder);
}
@@ -132,8 +128,7 @@ RValue CodeGenFunction::EmitCompoundStmt(const CompoundStmt &S, bool GetLast,
EmitStmt(*I);
if (DI) {
- if (S.getRBracLoc().isValid())
- DI->setLocation(S.getRBracLoc());
+ DI->setLocation(S.getRBracLoc());
DI->EmitRegionEnd(CurFn, Builder);
}
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index b182ecf055..12e468c127 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -73,9 +73,7 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
// Emit debug descriptor for function end.
if (CGDebugInfo *DI = CGM.getDebugInfo()) {
- if (EndLoc.isValid()) {
- DI->setLocation(EndLoc);
- }
+ DI->setLocation(EndLoc);
DI->EmitRegionEnd(CurFn, Builder);
}
@@ -126,10 +124,8 @@ void CodeGenFunction::StartFunction(const Decl *D, QualType RetTy,
// FIXME: The cast here is a huge hack.
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
if (CGDebugInfo *DI = CGM.getDebugInfo()) {
- CompoundStmt* body = dyn_cast<CompoundStmt>(FD->getBody());
- if (body && body->getLBracLoc().isValid()) {
+ if (CompoundStmt* body = dyn_cast<CompoundStmt>(FD->getBody()))
DI->setLocation(body->getLBracLoc());
- }
DI->EmitFunctionStart(FD, CurFn, Builder);
}
}
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp
index a74f0578a5..a8d8825aea 100644
--- a/lib/CodeGen/CodeGenModule.cpp
+++ b/lib/CodeGen/CodeGenModule.cpp
@@ -615,8 +615,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {
// Emit global variable debug information.
CGDebugInfo *DI = getDebugInfo();
if(DI) {
- if(D->getLocation().isValid())
- DI->setLocation(D->getLocation());
+ DI->setLocation(D->getLocation());
DI->EmitGlobalVariable(GV, D);
}
}