Author: fjahanian
Date: Fri Feb 15 15:14:50 2013
New Revision: 175298

URL: http://llvm.org/viewvc/llvm-project?rev=175298&view=rev
Log:
objective-C: Fixes a compiler crash when encoding
an ivar of type pointer to a typedef'ed object.
// rdar://13190095

Modified:
    cfe/trunk/include/clang/AST/ASTContext.h
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/test/CodeGenObjC/encode-test-6.m

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=175298&r1=175297&r2=175298&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Fri Feb 15 15:14:50 2013
@@ -2119,7 +2119,8 @@ private:
                                   bool EncodingProperty = false,
                                   bool StructField = false,
                                   bool EncodeBlockParameters = false,
-                                  bool EncodeClassNames = false) const;
+                                  bool EncodeClassNames = false,
+                                  bool EncodePointerToObjCTypedef = false) 
const;
 
   // Adds the encoding of the structure's members.
   void getObjCEncodingForStructureImpl(RecordDecl *RD, std::string &S,

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=175298&r1=175297&r2=175298&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri Feb 15 15:14:50 2013
@@ -4994,7 +4994,8 @@ void ASTContext::getObjCEncodingForTypeI
                                             bool EncodingProperty,
                                             bool StructField,
                                             bool EncodeBlockParameters,
-                                            bool EncodeClassNames) const {
+                                            bool EncodeClassNames,
+                                            bool EncodePointerToObjCTypedef) 
const {
   CanQualType CT = getCanonicalType(T);
   switch (CT->getTypeClass()) {
   case Type::Builtin:
@@ -5244,7 +5245,9 @@ void ASTContext::getObjCEncodingForTypeI
       if (Field->isBitField())
         getObjCEncodingForTypeImpl(Field->getType(), S, false, true, Field);
       else
-        getObjCEncodingForTypeImpl(Field->getType(), S, false, true, FD);
+        getObjCEncodingForTypeImpl(Field->getType(), S, false, true, FD,
+                                   false, false, false, false, false,
+                                   EncodePointerToObjCTypedef);
     }
     S += '}';
     return;
@@ -5286,14 +5289,17 @@ void ASTContext::getObjCEncodingForTypeI
 
     QualType PointeeTy = OPT->getPointeeType();
     if (!EncodingProperty &&
-        isa<TypedefType>(PointeeTy.getTypePtr())) {
+        isa<TypedefType>(PointeeTy.getTypePtr()) &&
+        !EncodePointerToObjCTypedef) {
       // Another historical/compatibility reason.
       // We encode the underlying type which comes out as
       // {...};
       S += '^';
       getObjCEncodingForTypeImpl(PointeeTy, S,
                                  false, ExpandPointedToStructures,
-                                 NULL);
+                                 NULL,
+                                 false, false, false, false, false,
+                                 /*EncodePointerToObjCTypedef*/true);
       return;
     }
 

Modified: cfe/trunk/test/CodeGenObjC/encode-test-6.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/encode-test-6.m?rev=175298&r1=175297&r2=175298&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/encode-test-6.m (original)
+++ cfe/trunk/test/CodeGenObjC/encode-test-6.m Fri Feb 15 15:14:50 2013
@@ -17,3 +17,21 @@ typedef struct {} Z;
 // CHECK: internal global [14 x i8] c"v16@0:8{?=}16
 // CHECK: internal global [26 x i8] c"v32@0:8{?=}16*16{?=}24d24
 
+
+// rdar://13190095
+@interface NSObject @end
+
+@class BABugExample;
+typedef BABugExample BABugExampleRedefinition;
+
+@interface BABugExample : NSObject {
+    BABugExampleRedefinition *_property; // .asciz   
"^{BABugExample=^{BABugExample}}"
+}
+@property (copy) BABugExampleRedefinition *property;
+@end
+
+@implementation BABugExample
+@synthesize property = _property;
+@end
+
+// CHECK: internal global [24 x i8] c"^{BABugExample=@}16


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to