]> granicus.if.org Git - clang/commitdiff
If variable location is invalid then use current location.
authorDevang Patel <dpatel@apple.com>
Mon, 10 May 2010 17:24:58 +0000 (17:24 +0000)
committerDevang Patel <dpatel@apple.com>
Mon, 10 May 2010 17:24:58 +0000 (17:24 +0000)
This fixes radar 7959934.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103408 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
test/CodeGenObjC/blocks-ivar-debug.m [new file with mode: 0644]

index fff4d60cc1fde964078dba5d2168251638600e9b..59b6b72ad528766b202ce92bf08862632b7cb296 100644 (file)
@@ -1536,7 +1536,9 @@ void CGDebugInfo::EmitDeclare(const BlockDeclRefExpr *BDRE, unsigned Tag,
   if (!PLoc.isInvalid())
     Line = PLoc.getLine();
   else
-    Unit = llvm::DIFile();
+    // If variable location is invalid, use current location to find 
+    // corresponding file info.
+    Unit = getOrCreateFile(CurLoc);
 
   CharUnits offset = CGF->BlockDecls[VD];
   llvm::SmallVector<llvm::Value *, 9> addr;
diff --git a/test/CodeGenObjC/blocks-ivar-debug.m b/test/CodeGenObjC/blocks-ivar-debug.m
new file mode 100644 (file)
index 0000000..92a5a72
--- /dev/null
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -g %s -fblocks -S -o /dev/null
+// Radar 7959934
+
+@interface NSObject {
+  struct objc_object *isa;
+}
+@end
+@interface Foo : NSObject {
+  int _prop;
+}
+@end
+
+@implementation Foo
+- (int)doSomething {
+  int (^blk)(void) = ^{ return _prop; };
+  return blk();
+}
+
+@end
+