r216291 - DebugInfo: Provide scopes for C++11 range-for loop variables similar to r216288 (which was for plain-for loop condition variables).

David Blaikie dblaikie at gmail.com
Fri Aug 22 14:54:29 PDT 2014


Author: dblaikie
Date: Fri Aug 22 16:54:29 2014
New Revision: 216291

URL: http://llvm.org/viewvc/llvm-project?rev=216291&view=rev
Log:
DebugInfo: Provide scopes for C++11 range-for loop variables similar to r216288 (which was for plain-for loop condition variables).

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

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=216291&r1=216290&r2=216291&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Fri Aug 22 16:54:29 2014
@@ -909,11 +909,7 @@ CodeGenFunction::EmitCXXForRangeStmt(con
                                      const ArrayRef<const Attr *> &ForAttrs) {
   JumpDest LoopExit = getJumpDestInCurrentScope("for.end");
 
-  RunCleanupsScope ForScope(*this);
-
-  CGDebugInfo *DI = getDebugInfo();
-  if (DI)
-    DI->EmitLexicalBlockStart(Builder, S.getSourceRange().getBegin());
+  LexicalScope ForScope(*this, S.getSourceRange());
 
   // Evaluate the first pieces before the loop.
   EmitStmt(S.getRangeStmt());
@@ -963,7 +959,7 @@ CodeGenFunction::EmitCXXForRangeStmt(con
 
   {
     // Create a separate cleanup scope for the loop variable and body.
-    RunCleanupsScope BodyScope(*this);
+    LexicalScope BodyScope(*this, S.getSourceRange());
     EmitStmt(S.getLoopVarStmt());
     EmitStmt(S.getBody());
   }
@@ -979,9 +975,6 @@ CodeGenFunction::EmitCXXForRangeStmt(con
 
   ForScope.ForceCleanup();
 
-  if (DI)
-    DI->EmitLexicalBlockEnd(Builder, S.getSourceRange().getEnd());
-
   LoopStack.pop();
 
   // Emit the fall-through block.

Modified: cfe/trunk/test/CodeGenCXX/debug-info-scope.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-scope.cpp?rev=216291&r1=216290&r2=216291&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-scope.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-scope.cpp Fri Aug 22 16:54:29 2014
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -g -emit-llvm %s -o -| FileCheck %s
+// RUN: %clang_cc1 -g -std=c++11 -emit-llvm %s -o -| FileCheck %s
 //
 // Two variables with the same name in subsequent if staments need to be in separate scopes.
 //
@@ -44,4 +44,12 @@ void func() {
   // CHECK: [[FOR_COMPOUND]] = metadata !{i32 {{.*}}, metadata [[FOR_BODY]], i32 [[@LINE-6]], {{.*}}} ; [ DW_TAG_lexical_block ]
     bool b = i % 2;
   }
+
+  int x[] = {1, 2};
+  // CHECK: = metadata !{i32 786688, metadata [[RANGE_FOR:![0-9]*]], {{.*}} ; [ DW_TAG_auto_variable ] [__range] [line 0]
+  // CHECK: [[RANGE_FOR]] = metadata !{i32 {{.*}}, metadata !{{.*}}, i32 [[@LINE+1]], {{.*}}} ; [ DW_TAG_lexical_block ]
+  for (int i : x) {
+  // CHECK: = metadata !{i32 786688, metadata [[RANGE_FOR_BODY:![0-9]*]], {{.*}} ; [ DW_TAG_auto_variable ] [i] [line [[@LINE-1]]]
+  // CHECK: [[RANGE_FOR_BODY]] = metadata !{i32 {{.*}}, metadata [[RANGE_FOR]], i32 [[@LINE-2]], {{.*}}} ; [ DW_TAG_lexical_block ]
+  }
 }





More information about the cfe-commits mailing list