summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Christopher <echristo@apple.com>2011-10-06 00:31:18 +0000
committerEric Christopher <echristo@apple.com>2011-10-06 00:31:18 +0000
commitfab289a47da142d2d04c3a8d2a954ce9d4b82c8d (patch)
tree7c491a261e36a9741dbdd39a36815cdad6fcbfb1
parent8c552308c63e70f92b4a64af4220a9f51e2959e8 (diff)
downloadbcm5719-llvm-fab289a47da142d2d04c3a8d2a954ce9d4b82c8d.tar.gz
bcm5719-llvm-fab289a47da142d2d04c3a8d2a954ce9d4b82c8d.zip
When constructing debug information for synthesized variables for the
non-fragile ABI we may not be able to lay out the type and the debugger would ignore us even if we did put in the offset. Go ahead and just put any value there and don't look up the offset since it may not exist. rdar://10210157 llvm-svn: 141261
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp11
-rw-r--r--clang/test/CodeGenObjC/debug-info-crash-2.m15
2 files changed, 23 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 1a7ba4d7df5..7bd6fc2fb00 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1148,8 +1148,8 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
unsigned Line = getLineNumber(ID->getLocation());
unsigned RuntimeLang = TheCU.getLanguage();
- // If this is just a forward declaration, return a special forward-declaration
- // debug type.
+ // If this is just a forward declaration return a special forward-declaration
+ // debug type since we won't be able to lay out the entire type.
if (ID->isForwardDecl()) {
llvm::DIType FwdDecl =
DBuilder.createStructType(Unit, ID->getName(),
@@ -1223,7 +1223,12 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
FieldAlign = CGM.getContext().getTypeAlign(FType);
}
- uint64_t FieldOffset = RL.getFieldOffset(FieldNo);
+ // We can't know the offset of our ivar in the structure if we're using
+ // the non-fragile abi and the debugger should ignore the value anyways.
+ // Call it the FieldNo+1 due to how debuggers use the information,
+ // e.g. negating the value when it needs a lookup in the dynamic table.
+ uint64_t FieldOffset = CGM.getLangOptions().ObjCNonFragileABI ? FieldNo+1
+ : RL.getFieldOffset(FieldNo);
unsigned Flags = 0;
if (Field->getAccessControl() == ObjCIvarDecl::Protected)
diff --git a/clang/test/CodeGenObjC/debug-info-crash-2.m b/clang/test/CodeGenObjC/debug-info-crash-2.m
new file mode 100644
index 00000000000..a2acd9dc917
--- /dev/null
+++ b/clang/test/CodeGenObjC/debug-info-crash-2.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -g -S %s -o -
+@class Bar;
+@interface Foo
+@property (strong, nonatomic) Bar *window;
+@end
+
+@interface Foo__ : Foo
+@end
+@implementation Foo__
+@end
+
+@implementation Foo
+@synthesize window = _window;
+@end
+
OpenPOWER on IntegriCloud