From b7c5f7426456bcc119c94aec3bb20a8e523c32cb Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Wed, 25 Sep 2013 19:36:32 +0000 Subject: ObjectiveC: Handle the case of qualifying protocols declared in a typedef declaraton used as super class of an ObjC class. Curretnly, these protocols are dropped from the class hierarchy. Test shows that it is now included. // rdar://15051465 llvm-svn: 191395 --- clang/lib/Sema/SemaDeclObjC.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'clang/lib/Sema/SemaDeclObjC.cpp') diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index b938bd6f8b0..14f8658face 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -592,6 +592,29 @@ ActOnStartClassInterface(SourceLocation AtInterfaceLoc, return ActOnObjCContainerStartDefinition(IDecl); } +/// ActOnTypedefedProtocols - this action finds protocol list as part of the +/// typedef'ed use for a qualified super class and adds them to the list +/// of the protocols. +void Sema::ActOnTypedefedProtocols(SmallVectorImpl &ProtocolRefs, + IdentifierInfo *SuperName, + SourceLocation SuperLoc) { + if (!SuperName) + return; + NamedDecl* IDecl = LookupSingleName(TUScope, SuperName, SuperLoc, + LookupOrdinaryName); + if (!IDecl) + return; + + if (const TypedefNameDecl *TDecl = dyn_cast_or_null(IDecl)) { + QualType T = TDecl->getUnderlyingType(); + if (T->isObjCObjectType()) + if (const ObjCObjectType *OPT = T->getAs()) + for (ObjCObjectType::qual_iterator I = OPT->qual_begin(), + E = OPT->qual_end(); I != E; ++I) + ProtocolRefs.push_back(*I); + } +} + /// ActOnCompatibilityAlias - this action is called after complete parsing of /// a \@compatibility_alias declaration. It sets up the alias relationships. Decl *Sema::ActOnCompatibilityAlias(SourceLocation AtLoc, -- cgit v1.2.1