From: Fariborz Jahanian Date: Wed, 29 Jun 2011 20:00:16 +0000 (+0000) Subject: objc-arc: fix a IRGen crash when checking for X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8fefc8e245c47daacae7a7fb218677fdcb85d122;p=clang objc-arc: fix a IRGen crash when checking for accessibility of an initializer which is a compound statement. // rdar://9694706 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134091 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index 68b1d3be66..d508ff7390 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -454,7 +454,8 @@ static bool isAccessedBy(const VarDecl &var, const Stmt *s) { } for (Stmt::const_child_range children = s->children(); children; ++children) - if (isAccessedBy(var, *children)) + // children might be null; as in missing decl or conditional of an if-stmt. + if ((*children) && isAccessedBy(var, *children)) return true; return false; diff --git a/test/CodeGenObjC/arc-compound-stmt.m b/test/CodeGenObjC/arc-compound-stmt.m new file mode 100644 index 0000000000..946d72f005 --- /dev/null +++ b/test/CodeGenObjC/arc-compound-stmt.m @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-nonfragile-abi -fobjc-arc -o - %s +// rdar://9694706 + +typedef unsigned long NSUInteger; + +@interface NSString +- (NSString *)stringByAppendingString:(NSString *)aString; +- (NSString *)substringFromIndex:(NSUInteger)from; +@end + +@interface MyClass +- (void)inst; +@end + +@implementation MyClass + +- (void)inst; +{ + NSString *propName; + + NSString *capitalPropName = ({ + NSString *cap; + if (propName) + cap = [cap stringByAppendingString:[propName substringFromIndex:1]]; + cap; + }); +} + +@end