Call UpdateLineDirectiveRegion every time we want to emit a stop
point in the code. Ensures that we don't miss any places and the
check is reasonably cheap.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140737 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index b48475f..2edb065 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -1763,6 +1763,10 @@
     if (!Builder.getCurrentDebugLocation().isUnknown())
       return;
 
+  // The file may have had a line directive change. Process any of
+  // those before updating the state.
+  UpdateLineDirectiveRegion(Builder);
+  
   // Update last state.
   PrevLoc = CurLoc;
 
diff --git a/lib/CodeGen/CGDebugInfo.h b/lib/CodeGen/CGDebugInfo.h
index fdc3baf..e59aed9 100644
--- a/lib/CodeGen/CGDebugInfo.h
+++ b/lib/CodeGen/CGDebugInfo.h
@@ -149,6 +149,10 @@
                          llvm::DIFile F,
                          SmallVectorImpl<llvm::Value *> &EltTys);
 
+  // UpdateLineDirectiveRegion - Update region stack only if #line directive
+  // has introduced scope change.
+  void UpdateLineDirectiveRegion(CGBuilderTy &Builder);
+
 public:
   CGDebugInfo(CodeGenModule &CGM);
   ~CGDebugInfo();
@@ -170,10 +174,6 @@
   /// EmitFunctionEnd - Constructs the debug code for exiting a function.
   void EmitFunctionEnd(CGBuilderTy &Builder);
 
-  /// UpdateLineDirectiveRegion - Update region stack only if #line directive
-  /// has introduced scope change.
-  void UpdateLineDirectiveRegion(CGBuilderTy &Builder);
-
   /// UpdateCompletedType - Update type cache because the type is now
   /// translated.
   void UpdateCompletedType(const TagDecl *TD);
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 22f264b..5fe33ff 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -2170,7 +2170,6 @@
                                      ReturnValueSlot ReturnValue) {
   if (CGDebugInfo *DI = getDebugInfo()) {
     DI->setLocation(E->getLocStart());
-    DI->UpdateLineDirectiveRegion(Builder);
     DI->EmitStopPoint(Builder);
   }
 
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp
index 93763e3..e070cc3 100644
--- a/lib/CodeGen/CGStmt.cpp
+++ b/lib/CodeGen/CGStmt.cpp
@@ -35,7 +35,6 @@
       DI->setLocation(S->getLocEnd());
     else
       DI->setLocation(S->getLocStart());
-    DI->UpdateLineDirectiveRegion(Builder);
     DI->EmitStopPoint(Builder);
   }
 }