diff options
-rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 4 | ||||
-rw-r--r-- | test/CodeGenObjC/blocks-ivar-debug.m | 20 |
2 files changed, 23 insertions, 1 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index fff4d60cc1..59b6b72ad5 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -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 index 0000000000..92a5a72d42 --- /dev/null +++ b/test/CodeGenObjC/blocks-ivar-debug.m @@ -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 + |