[cfe-commits] r134091 - in /cfe/trunk: lib/CodeGen/CGDecl.cpp test/CodeGenObjC/arc-compound-stmt.m

Fariborz Jahanian fjahanian at apple.com
Wed Jun 29 13:00:16 PDT 2011


Author: fjahanian
Date: Wed Jun 29 15:00:16 2011
New Revision: 134091

URL: http://llvm.org/viewvc/llvm-project?rev=134091&view=rev
Log:
objc-arc: fix a IRGen crash when checking for
accessibility of an initializer which is a compound 
statement. // rdar://9694706

Added:
    cfe/trunk/test/CodeGenObjC/arc-compound-stmt.m
Modified:
    cfe/trunk/lib/CodeGen/CGDecl.cpp

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=134091&r1=134090&r2=134091&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Jun 29 15:00:16 2011
@@ -454,7 +454,8 @@
   }
 
   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;

Added: cfe/trunk/test/CodeGenObjC/arc-compound-stmt.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-compound-stmt.m?rev=134091&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/arc-compound-stmt.m (added)
+++ cfe/trunk/test/CodeGenObjC/arc-compound-stmt.m Wed Jun 29 15:00:16 2011
@@ -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;
+
+ at interface NSString
+- (NSString *)stringByAppendingString:(NSString *)aString;
+- (NSString *)substringFromIndex:(NSUInteger)from;
+ at end
+
+ at interface MyClass
+- (void)inst;
+ at end
+
+ at implementation MyClass
+
+- (void)inst;
+{
+    NSString *propName;
+
+    NSString *capitalPropName = ({
+        NSString *cap;
+        if (propName)
+            cap = [cap stringByAppendingString:[propName substringFromIndex:1]];
+        cap;
+    });
+}
+
+ at end





More information about the cfe-commits mailing list