]> granicus.if.org Git - clang/commitdiff
Fix <rdar://problem/7330784>. Avoid crashing on 'Class<p>' when generating meta-data...
authorSteve Naroff <snaroff@apple.com>
Wed, 28 Oct 2009 22:03:49 +0000 (22:03 +0000)
committerSteve Naroff <snaroff@apple.com>
Wed, 28 Oct 2009 22:03:49 +0000 (22:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85440 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp
test/CodeGenObjC/encode-test-2.m

index eb6d39225b8d139a1f1e5a143eccc78a1033efa7..7be55ebb1125ac3b47d125e3d431cf884515e78a 100644 (file)
@@ -3419,7 +3419,10 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
       return;
     }
 
-    if (OPT->isObjCClassType()) {
+    if (OPT->isObjCClassType() || OPT->isObjCQualifiedClassType()) {
+      // FIXME: Consider if we need to output qualifiers for 'Class<p>'.
+      // Since this is a binary compatibility issue, need to consult with runtime
+      // folks. Fortunately, this is a *very* obsure construct.
       S += '#';
       return;
     }
@@ -3457,9 +3460,9 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
     }
 
     S += '@';
-    if (FD || EncodingProperty) {
+    if (OPT->getInterfaceDecl() && (FD || EncodingProperty)) {
       S += '"';
-      S += OPT->getInterfaceDecl()->getNameAsCString();
+      S += OPT->getInterfaceDecl()->getIdentifier()->getName();
       for (ObjCObjectPointerType::qual_iterator I = OPT->qual_begin(),
            E = OPT->qual_end(); I != E; ++I) {
         S += '<';
index 6901168b1d09a7c1dec94d115ec5828e48fb885f..07a53367557a04d8f3b8ea8a71d47996d2e6c0c7 100644 (file)
@@ -3,7 +3,7 @@
 // RUN: grep -e "@\\\22<X><Y>\\\22" %t  &&
 // RUN: grep -e "@\\\22<X><Y><Z>\\\22" %t  &&
 // RUN: grep -e "@\\\22Foo<X><Y><Z>\\\22" %t  &&
-// RUN: grep -e "{Intf=@@@@}" %t  
+// RUN: grep -e "{Intf=@@@@#}" %t  
 
 @protocol X, Y, Z;
 @class Foo;
@@ -17,6 +17,7 @@ id <X> IVAR_x;
 id <X, Y> IVAR_xy;
 id <X, Y, Z> IVAR_xyz;
 Foo <X, Y, Z> *IVAR_Fooxyz;
+Class <X> IVAR_Classx;
 }
 @end