diff options
-rw-r--r-- | include/clang/AST/DeclObjC.h | 4 | ||||
-rw-r--r-- | lib/AST/DeclObjC.cpp | 13 | ||||
-rw-r--r-- | lib/Sema/SemaObjCProperty.cpp | 18 |
3 files changed, 21 insertions, 14 deletions
diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index 18819087ae..3500f9446e 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -1327,6 +1327,10 @@ public: return PropertyIvarDecl; } + /// Lookup a property by name in the specified DeclContext. + static ObjCPropertyDecl *findPropertyDecl(DeclContext *DC, + IdentifierInfo *propertyID); + static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const ObjCPropertyDecl *D) { return true; } static bool classofKind(Kind K) { return K == ObjCProperty; } diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index c94a551ae2..597b0d1bf0 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -89,6 +89,19 @@ ObjCContainerDecl::getMethod(Selector Sel, bool isInstance) const { return 0; } +ObjCPropertyDecl * +ObjCPropertyDecl::findPropertyDecl(DeclContext *DC, + IdentifierInfo *propertyID) { + + DeclContext::lookup_iterator I, E; + llvm::tie(I, E) = DC->lookup(propertyID); + for ( ; I != E; ++I) + if (ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(*I)) + return PD; + + return 0; +} + /// FindPropertyDeclaration - Finds declaration of the property given its name /// in 'PropertyId' and returns it. It returns 0, if not found. /// FIXME: Convert to DeclContext lookup... diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 7659062905..3a0fe0a61a 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -66,18 +66,6 @@ Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc, Attributes, T, MethodImplKind)); } -static ObjCPropertyDecl *findPropertyDecl(DeclContext *DC, - IdentifierInfo *propertyID) { - - DeclContext::lookup_iterator I, E; - llvm::tie(I, E) = DC->lookup(propertyID); - for ( ; I != E; ++I) - if (ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(*I)) - return PD; - - return 0; -} - Sema::DeclPtrTy Sema::HandlePropertyInClassExtension(Scope *S, ObjCCategoryDecl *CDecl, SourceLocation AtLoc, FieldDeclarator &FD, @@ -93,7 +81,8 @@ Sema::HandlePropertyInClassExtension(Scope *S, ObjCCategoryDecl *CDecl, DeclContext *DC = cast<DeclContext>(CDecl); IdentifierInfo *PropertyId = FD.D.getIdentifier(); - if (ObjCPropertyDecl *prevDecl = findPropertyDecl(DC, PropertyId)) { + if (ObjCPropertyDecl *prevDecl = + ObjCPropertyDecl::findPropertyDecl(DC, PropertyId)) { Diag(AtLoc, diag::err_duplicate_property); Diag(prevDecl->getLocation(), diag::note_property_declare); return DeclPtrTy(); @@ -231,7 +220,8 @@ ObjCPropertyDecl *Sema::CreatePropertyDecl(Scope *S, FD.D.getIdentifierLoc(), PropertyId, AtLoc, T); - if (ObjCPropertyDecl *prevDecl = findPropertyDecl(DC, PropertyId)) { + if (ObjCPropertyDecl *prevDecl = + ObjCPropertyDecl::findPropertyDecl(DC, PropertyId)) { Diag(PDecl->getLocation(), diag::err_duplicate_property); Diag(prevDecl->getLocation(), diag::note_property_declare); PDecl->setInvalidDecl(); |