/// region - end of a DW_TAG_lexical_block.
void CGDebugInfo::EmitLexicalBlockEnd(CGBuilderTy &Builder, SourceLocation Loc) {
assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
-
- // Provide an entry in the line table for the end of the block.
- EmitLocation(Builder, Loc);
-
LexicalBlockStack.pop_back();
}
/// cleanups.
~LexicalScope() {
if (PopDebugStack) {
- CGDebugInfo *DI = CGF.getDebugInfo();
- if (DI) DI->EmitLexicalBlockEnd(CGF.Builder, Range.getEnd());
+ if (CGDebugInfo *DI = CGF.getDebugInfo()) {
+ if (RunCleanupsScope::requiresCleanups())
+ DI->EmitLocation(CGF.Builder, Range.getEnd());
+ DI->EmitLexicalBlockEnd(CGF.Builder, Range.getEnd());
+ }
}
}
void ForceCleanup() {
RunCleanupsScope::ForceCleanup();
if (CGDebugInfo *DI = CGF.getDebugInfo()) {
+ if (RunCleanupsScope::requiresCleanups())
+ DI->EmitLocation(CGF.Builder, Range.getEnd());
DI->EmitLexicalBlockEnd(CGF.Builder, Range.getEnd());
PopDebugStack = false;
}
--- /dev/null
+// RUN: %clang_cc1 -g -S -emit-llvm %s -o - | FileCheck %s
+
+int bar();
+
+int foo(int i) {
+ int j = 0;
+ if (i) {
+ j = bar();
+ }
+ else {
+ j = bar() + 2;
+ }
+ return j;
+}
+
+// Make sure we don't have a line table entry for a block with no cleanups.
+// CHECK-NOT: i32 9, i32 3, metadata