Nice! On Oct 18, 2012, at 12:17 , Anna Zaks <[email protected]> wrote:
> Author: zaks > Date: Thu Oct 18 14:17:53 2012 > New Revision: 166210 > > URL: http://llvm.org/viewvc/llvm-project?rev=166210&view=rev > Log: > Factor CollectClassPropertyImplementations out of Sema into AST > > This would make it possible for the analyzer to use the function. > > Modified: > cfe/trunk/include/clang/AST/DeclObjC.h > cfe/trunk/lib/AST/DeclObjC.cpp > cfe/trunk/lib/Sema/SemaObjCProperty.cpp > > Modified: cfe/trunk/include/clang/AST/DeclObjC.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=166210&r1=166209&r2=166210&view=diff > ============================================================================== > --- cfe/trunk/include/clang/AST/DeclObjC.h (original) > +++ cfe/trunk/include/clang/AST/DeclObjC.h Thu Oct 18 14:17:53 2012 > @@ -541,6 +541,12 @@ > > ObjCPropertyDecl *FindPropertyDeclaration(IdentifierInfo *PropertyId) const; > > + typedef llvm::DenseMap<IdentifierInfo *, ObjCPropertyDecl*> PropertyMap; > + > + /// This routine collects list of properties to be implemented in the > class. > + /// This includes, class's and its conforming protocols' properties. > + virtual void collectPropertiesToImplement(PropertyMap& PM) const {} Nitpicking: the ampersand should go with the name, and the asterisks are inconsistent in the typedef. I'd also appreciate a reminder that the superclass's properties are NOT included in the list. > SourceLocation getAtStartLoc() const { return AtStart; } > void setAtStartLoc(SourceLocation Loc) { AtStart = Loc; } > > @@ -900,6 +906,8 @@ > ObjCPropertyDecl > *FindPropertyVisibleInPrimaryClass(IdentifierInfo *PropertyId) const; > > + virtual void collectPropertiesToImplement(PropertyMap& PM) const; Ampersand. > /// isSuperClassOf - Return true if this class is the specified class or is > a > /// super class of the specified interface class. > bool isSuperClassOf(const ObjCInterfaceDecl *I) const { > @@ -1294,6 +1302,8 @@ > return getFirstDeclaration(); > } > > + virtual void collectPropertiesToImplement(PropertyMap& PM) const; Ampersand. > static bool classof(const Decl *D) { return classofKind(D->getKind()); } > static bool classofKind(Kind K) { return K == ObjCProtocol; } > > > Modified: cfe/trunk/lib/AST/DeclObjC.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=166210&r1=166209&r2=166210&view=diff > ============================================================================== > --- cfe/trunk/lib/AST/DeclObjC.cpp (original) > +++ cfe/trunk/lib/AST/DeclObjC.cpp Thu Oct 18 14:17:53 2012 > @@ -190,6 +190,18 @@ > return 0; > } > > +void ObjCInterfaceDecl::collectPropertiesToImplement(PropertyMap& PM) const { > + for (ObjCContainerDecl::prop_iterator P = prop_begin(), > + E = prop_end(); P != E; ++P) { > + ObjCPropertyDecl *Prop = *P; > + PM[Prop->getIdentifier()] = Prop; > + } > + for (ObjCInterfaceDecl::all_protocol_iterator > + PI = all_referenced_protocol_begin(), > + E = all_referenced_protocol_end(); PI != E; ++PI) > + (*PI)->collectPropertiesToImplement(PM); > +} I'd appreciate a reminder that properties declared only in class extensions are still copied into the main @interface's property list, and therefore we don't explicitly have to search class extension properties. (I just spent five minutes or so verifying that this was true.) > void ObjCInterfaceDecl::mergeClassExtensionProtocolList( > ObjCProtocolDecl *const* ExtList, unsigned > ExtNum, > ASTContext &C) > @@ -1313,6 +1325,20 @@ > RD->Data = this->Data; > } > Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=166210&r1=166209&r2=166210&view=diff > ============================================================================== > --- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original) > +++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Thu Oct 18 14:17:53 2012 > @@ -1435,8 +1435,8 @@ > /// CollectImmediateProperties - This routine collects all properties in > /// the class and its conforming protocols; but not those it its super class. > void Sema::CollectImmediateProperties(ObjCContainerDecl *CDecl, > - llvm::DenseMap<IdentifierInfo *, ObjCPropertyDecl*>& PropMap, > - llvm::DenseMap<IdentifierInfo *, ObjCPropertyDecl*>& > SuperPropMap) { > + ObjCContainerDecl::PropertyMap& PropMap, > + ObjCContainerDecl::PropertyMap& SuperPropMap) { > if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(CDecl)) { > for (ObjCContainerDecl::prop_iterator P = IDecl->prop_begin(), > E = IDecl->prop_end(); P != E; ++P) { > @@ -1482,44 +1482,14 @@ > } > } Ampersands. > /// CollectSuperClassPropertyImplementations - This routine collects list of > /// properties to be implemented in super class(s) and also coming from their > /// conforming protocols. > static void CollectSuperClassPropertyImplementations(ObjCInterfaceDecl *CDecl, > - llvm::DenseMap<IdentifierInfo *, ObjCPropertyDecl*>& > PropMap) { > + ObjCInterfaceDecl::PropertyMap& PropMap) > { > if (ObjCInterfaceDecl *SDecl = CDecl->getSuperClass()) { > while (SDecl) { > - CollectClassPropertyImplementations(SDecl, PropMap); > + SDecl->collectPropertiesToImplement(PropMap); > SDecl = SDecl->getSuperClass(); > } > } Ampersand. Also wondering if this could be made a little more compact, but it doesn't actually seem to get much cleaner. _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
