Debug info: An if condition now creates a lexical scope of its own.
Two variables with the same name declared in two if conditions in the same
scope are no longer coalesced into one.
rdar://problem/14024005
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183597 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp
index 3e9b8d4..0db31ac 100644
--- a/lib/CodeGen/CGStmt.cpp
+++ b/lib/CodeGen/CGStmt.cpp
@@ -419,6 +419,11 @@
// unequal to 0. The condition must be a scalar type.
RunCleanupsScope ConditionScope(*this);
+ // Also open a debugger-visible lexical scope for the condition.
+ CGDebugInfo *DI = getDebugInfo();
+ if (DI)
+ DI->EmitLexicalBlockStart(Builder, S.getSourceRange().getBegin());
+
if (S.getConditionVariable())
EmitAutoVarDecl(*S.getConditionVariable());
@@ -439,6 +444,8 @@
RunCleanupsScope ExecutedScope(*this);
EmitStmt(Executed);
}
+ if (DI)
+ DI->EmitLexicalBlockEnd(Builder, S.getSourceRange().getEnd());
return;
}
}
@@ -476,6 +483,9 @@
EmitBranch(ContBlock);
}
+ if (DI)
+ DI->EmitLexicalBlockEnd(Builder, S.getSourceRange().getEnd());
+
// Emit the continuation block for code after the if.
EmitBlock(ContBlock, true);
}