summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2013-05-03 20:11:48 +0000
committerAdrian Prantl <aprantl@apple.com>2013-05-03 20:11:48 +0000
commit52bf3c4c3ff23f404e38e0351c9b89c53a57eb6c (patch)
treebaa2288302b827495418016a35718f4d035c400a /clang/lib/CodeGen/CodeGenFunction.cpp
parentd36712df8d34cd9191a92c633f2edc058f78f612 (diff)
downloadbcm5719-llvm-52bf3c4c3ff23f404e38e0351c9b89c53a57eb6c.tar.gz
bcm5719-llvm-52bf3c4c3ff23f404e38e0351c9b89c53a57eb6c.zip
Reapply r180982 with repaired logic and an additional testcase.
Un-break the gdb buildbot. - Use the debug location of the return expression for the cleanup code if the return expression is trivially evaluatable, regardless of the number of stop points in the function. - Ensure that any EH code in the cleanup still gets the line number of the closing } of the lexical scope. - Added a testcase with EH in the cleanup. rdar://problem/13442648 llvm-svn: 181056
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 493ee91ec7e..791c1a81525 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -44,7 +44,7 @@ CodeGenFunction::CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext)
DebugInfo(0), DisableDebugInfo(false), CalleeWithThisReturn(0),
DidCallStackSave(false),
IndirectBranch(0), SwitchInsn(0), CaseRangeBlock(0), UnreachableBlock(0),
- NumStopPoints(0), NumSimpleReturnExprs(0),
+ NumReturnExprs(0), NumSimpleReturnExprs(0),
CXXABIThisDecl(0), CXXABIThisValue(0), CXXThisValue(0),
CXXDefaultInitExprThis(0),
CXXStructorImplicitParamDecl(0), CXXStructorImplicitParamValue(0),
@@ -188,14 +188,16 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
assert(BreakContinueStack.empty() &&
"mismatched push/pop in break/continue stack!");
- // If the function contains only a single, simple return statement,
- // the cleanup code may become the first breakpoint in the
- // function. To be safe set the debug location for it to the
- // location of the return statement. Otherwise point it to end of
- // the function's lexical scope.
+ bool OnlySimpleReturnStmts = NumSimpleReturnExprs > 0
+ && NumSimpleReturnExprs == NumReturnExprs;
+ // If the function contains only a simple return statement, the
+ // cleanup code may become the first breakpoint in the function. To
+ // be safe, set the debug location for it to the location of the
+ // return statement. Otherwise point it to end of the function's
+ // lexical scope.
if (CGDebugInfo *DI = getDebugInfo()) {
- if (NumSimpleReturnExprs == 1 && NumStopPoints == 1)
- DI->EmitLocation(Builder, FirstStopPoint);
+ if (OnlySimpleReturnStmts)
+ DI->EmitLocation(Builder, LastStopPoint);
else
DI->EmitLocation(Builder, EndLoc);
}
@@ -206,14 +208,14 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
// edges will be *really* confused.
bool EmitRetDbgLoc = true;
if (EHStack.stable_begin() != PrologueCleanupDepth) {
- PopCleanupBlocks(PrologueCleanupDepth);
+ PopCleanupBlocks(PrologueCleanupDepth, EndLoc);
// Make sure the line table doesn't jump back into the body for
// the ret after it's been at EndLoc.
EmitRetDbgLoc = false;
if (CGDebugInfo *DI = getDebugInfo())
- if (NumSimpleReturnExprs == 1 && NumStopPoints == 1)
+ if (OnlySimpleReturnStmts)
DI->EmitLocation(Builder, EndLoc);
}
OpenPOWER on IntegriCloud