Continuation of work on ObjC2's properties.
Added iterators, methods to find property and categories.
Use them in doing semantic analysis on property implementation
declarations. Fixed typos.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50050 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index a5eb07a..04e9993 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -137,6 +137,47 @@
delete[] ParamInfo;
}
+/// FindPropertyDeclaration - Finds declaration of the property given its name
+/// in 'PropertyId' and returns it. It returns 0, if not found.
+///
+ObjCPropertyDecl *
+ ObjCInterfaceDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const {
+ for (ObjCInterfaceDecl::classprop_iterator I = classprop_begin(),
+ E = classprop_end(); I != E; ++I) {
+ ObjCPropertyDecl *property = *I;
+ if (property->getIdentifier() == PropertyId)
+ return property;
+ }
+ return 0;
+}
+
+/// FindCategoryDeclaration - Finds category declaration in the list of
+/// categories for this class and returns it. Name of the category is passed
+/// in 'CategoryId'. If category not found, return 0;
+///
+ObjCCategoryDecl *
+ ObjCInterfaceDecl::FindCategoryDeclaration(IdentifierInfo *CategoryId) const {
+ for (ObjCCategoryDecl *Category = getCategoryList();
+ Category; Category = Category->getNextClassCategory())
+ if (Category->getIdentifier() == CategoryId)
+ return Category;
+ return 0;
+}
+
+/// FindIvarDeclaration - Find an Ivar declaration in this class given its
+/// name in 'IvarId'. On failure to find, return 0;
+///
+ObjCIvarDecl *
+ ObjCInterfaceDecl::FindIvarDeclaration(IdentifierInfo *IvarId) const {
+ for (ObjCInterfaceDecl::ivar_iterator IVI = ivar_begin(),
+ IVE = ivar_end(); IVI != IVE; ++IVI) {
+ ObjCIvarDecl* Ivar = (*IVI);
+ if (Ivar->getIdentifier() == IvarId)
+ return Ivar;
+ }
+ return 0;
+}
+
/// ObjCAddInstanceVariablesToClass - Inserts instance variables
/// into ObjCInterfaceDecl's fields.
///
@@ -274,6 +315,20 @@
AtEndLoc = endLoc;
}
+/// FindPropertyDeclaration - Finds declaration of the property given its name
+/// in 'PropertyId' and returns it. It returns 0, if not found.
+///
+ObjCPropertyDecl *
+ObjCCategoryDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const {
+ for (ObjCCategoryDecl::classprop_iterator I = classprop_begin(),
+ E = classprop_end(); I != E; ++I) {
+ ObjCPropertyDecl *property = *I;
+ if (property->getIdentifier() == PropertyId)
+ return property;
+ }
+ return 0;
+}
+
ObjCIvarDecl *ObjCInterfaceDecl::lookupInstanceVariable(
IdentifierInfo *ID, ObjCInterfaceDecl *&clsDeclared) {
ObjCInterfaceDecl* ClassDecl = this;