[cfe-commits] r112002 - in /cfe/trunk: lib/CodeGen/CGStmt.cpp test/CodeGen/debug-info-scope.c

Devang Patel dpatel at apple.com
Tue Aug 24 17:28:56 PDT 2010


Author: dpatel
Date: Tue Aug 24 19:28:56 2010
New Revision: 112002

URL: http://llvm.org/viewvc/llvm-project?rev=112002&view=rev
Log:
Fix 'for' loop variables' scope.

Added:
    cfe/trunk/test/CodeGen/debug-info-scope.c
Modified:
    cfe/trunk/lib/CodeGen/CGStmt.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=112002&r1=112001&r2=112002&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Tue Aug 24 19:28:56 2010
@@ -501,6 +501,12 @@
 
   RunCleanupsScope ForScope(*this);
 
+  CGDebugInfo *DI = getDebugInfo();
+  if (DI) {
+    DI->setLocation(S.getSourceRange().getBegin());
+    DI->EmitRegionStart(Builder);
+  }
+
   // Evaluate the first part before the loop.
   if (S.getInit())
     EmitStmt(S.getInit());
@@ -558,12 +564,6 @@
   // Store the blocks to use for break and continue.
   BreakContinueStack.push_back(BreakContinue(LoopExit, Continue));
 
-  CGDebugInfo *DI = getDebugInfo();
-  if (DI) {
-    DI->setLocation(S.getSourceRange().getBegin());
-    DI->EmitRegionStart(Builder);
-  }
-
   {
     // Create a separate cleanup scope for the body, in case it is not
     // a compound statement.

Added: cfe/trunk/test/CodeGen/debug-info-scope.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-scope.c?rev=112002&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/debug-info-scope.c (added)
+++ cfe/trunk/test/CodeGen/debug-info-scope.c Tue Aug 24 19:28:56 2010
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -g -emit-llvm < %s | FileCheck %s
+// Two variables with same name in separate scope.
+// Radar 8330217.
+int main() {
+	int j = 0;
+	int k = 0;
+// CHECK: DW_TAG_auto_variable
+// CHECK-NEXT: DW_TAG_lexical_block
+	for (int i = 0; i < 10; i++)
+		j++;
+	for (int i = 0; i < 10; i++)
+		k++;
+	return 0;
+}





More information about the cfe-commits mailing list