From 27d20a24a1b816cecbd142727d2c81af5a6a111b Mon Sep 17 00:00:00 2001 From: Steve Naroff Date: Wed, 28 Oct 2009 22:03:49 +0000 Subject: [PATCH] Fix . Avoid crashing on 'Class

' when generating meta-data for a class. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85440 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ASTContext.cpp | 9 ++++++--- test/CodeGenObjC/encode-test-2.m | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index eb6d39225b..7be55ebb11 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -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

'. + // 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 += '<'; diff --git a/test/CodeGenObjC/encode-test-2.m b/test/CodeGenObjC/encode-test-2.m index 6901168b1d..07a5336755 100644 --- a/test/CodeGenObjC/encode-test-2.m +++ b/test/CodeGenObjC/encode-test-2.m @@ -3,7 +3,7 @@ // RUN: grep -e "@\\\22\\\22" %t && // RUN: grep -e "@\\\22\\\22" %t && // RUN: grep -e "@\\\22Foo\\\22" %t && -// RUN: grep -e "{Intf=@@@@}" %t +// RUN: grep -e "{Intf=@@@@#}" %t @protocol X, Y, Z; @class Foo; @@ -17,6 +17,7 @@ id IVAR_x; id IVAR_xy; id IVAR_xyz; Foo *IVAR_Fooxyz; +Class IVAR_Classx; } @end -- 2.40.0