]> granicus.if.org Git - clang/commitdiff
Emit DW_TAG_lexical_scope to surround foreach.
authorDevang Patel <dpatel@apple.com>
Wed, 19 Jan 2011 01:36:36 +0000 (01:36 +0000)
committerDevang Patel <dpatel@apple.com>
Wed, 19 Jan 2011 01:36:36 +0000 (01:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123802 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGObjC.cpp
test/CodeGenObjC/debug-info-foreach.m [new file with mode: 0644]

index c7f834acb6f36e91cfde2ee63397a63edd730d45..0837c578a79122f3458d21da412bbefa192dac19 100644 (file)
@@ -11,6 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "CGDebugInfo.h"
 #include "CGObjCRuntime.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
@@ -612,6 +613,12 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){
     return;
   }
 
+  CGDebugInfo *DI = getDebugInfo();
+  if (DI) {
+    DI->setLocation(S.getSourceRange().getBegin());
+    DI->EmitRegionStart(Builder);
+  }
+
   JumpDest LoopEnd = getJumpDestInCurrentScope("forcoll.end");
   JumpDest AfterBody = getJumpDestInCurrentScope("forcoll.next");
 
@@ -842,6 +849,11 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){
     EmitStoreThroughLValue(RValue::get(null), elementLValue, elementType);
   }
 
+  if (DI) {
+    DI->setLocation(S.getSourceRange().getEnd());
+    DI->EmitRegionEnd(Builder);
+  }
+
   EmitBlock(LoopEnd.getBlock());
 }
 
diff --git a/test/CodeGenObjC/debug-info-foreach.m b/test/CodeGenObjC/debug-info-foreach.m
new file mode 100644 (file)
index 0000000..c056e0e
--- /dev/null
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fobjc-default-synthesize-properties -emit-llvm -g %s -o %t 
+// RUN: grep DW_TAG_lexical_block %t | count 5
+// rdar://8757124
+
+@class NSArray;
+
+void f(NSArray *a) {
+  id keys;
+  for (id thisKey in keys) {
+  }
+  for (id thisKey in keys) {
+  }
+}