The end of a block doesn't necessarily need a line table entry unless
there's something going on there. Remove the unconditional line entry
and only add one if we're emitting cleanups (any other statements
would be handled normally).

Fixes rdar://9199234

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160033 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index c604e56..11a5ddc 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -2135,10 +2135,6 @@
 /// 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();
 }
 
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
index b737a9e..8740fd0 100644
--- a/lib/CodeGen/CodeGenFunction.h
+++ b/lib/CodeGen/CodeGenFunction.h
@@ -854,8 +854,11 @@
     /// 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());
+        }
       }
     }
 
@@ -864,6 +867,8 @@
     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;
       }