From: Fariborz Jahanian Date: Mon, 30 Nov 2009 18:43:52 +0000 (+0000) Subject: Fix a crash when ivar type is a __strong SEL. Fallout from X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8d2c0a9814e56c2b22e22d1045181c735aef62fd;p=clang Fix a crash when ivar type is a __strong SEL. Fallout from recent change to make SEL a builtin type (fixes radar 7425510). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90145 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index 5b09ef08ec..349487f879 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -2548,12 +2548,7 @@ public: return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCClass) && !Protocols.size(); } - - /// isObjCSelType - true for "SEL". - bool isObjCSelType() const { - return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCSel); - } - + /// isObjCQualifiedIdType - true for "id

". bool isObjCQualifiedIdType() const { return getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCId) && @@ -2902,8 +2897,8 @@ inline bool Type::isObjCClassType() const { return false; } inline bool Type::isObjCSelType() const { - if (const ObjCObjectPointerType *OPT = getAs()) - return OPT->isObjCSelType(); + if (const PointerType *OPT = getAs()) + return OPT->getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCSel); return false; } inline bool Type::isObjCBuiltinType() const { diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 2579a6e879..6c9ecf089b 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -3413,13 +3413,13 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S, return; } - if (isObjCSelType(T)) { - S += ':'; - return; - } - if (const PointerType *PT = T->getAs()) { + if (PT->isObjCSelType()) { + S += ':'; + return; + } QualType PointeeTy = PT->getPointeeType(); + bool isReadOnly = false; // For historical/compatibility reasons, the read-only qualifier of the // pointee gets emitted _before_ the '^'. The read-only qualifier of diff --git a/test/CodeGenObjC/encode-test.m b/test/CodeGenObjC/encode-test.m index 7aca79a8f3..db8470b6bb 100644 --- a/test/CodeGenObjC/encode-test.m +++ b/test/CodeGenObjC/encode-test.m @@ -66,6 +66,7 @@ struct Innermost { @interface Test { int ivar; + __attribute__((objc_gc(weak))) SEL selector; } -(void) test3: (Test* [3] [4])b ; - (SEL**) meth : (SEL) arg : (SEL*****) arg1 : (SEL*)arg2 : (SEL**) arg3;