When creating a jump destination, its scope should be the scope of the
enclosing normal cleanup, not the top of the EH stack.  I'm *really*
surprised this hasn't been causing more problems.

Fixes rdar://problem/8231514.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109569 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index d6e498f..396ab4e 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -1055,6 +1055,9 @@
 ///
 /// As a side-effect, this method clears the insertion point.
 void CodeGenFunction::EmitBranchThroughCleanup(JumpDest Dest) {
+  assert(Dest.getScopeDepth().encloses(EHStack.getInnermostNormalCleanup())
+         && "stale jump destination");
+
   if (!HaveInsertPoint())
     return;