aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-01-09 21:04:52 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-01-09 21:04:52 +0000
commita66793ee8d2589ead81739d9b8a968650db3d452 (patch)
tree08bf49c9e69c2c71f016f5627a0f6f92979366b9
parent8fa73ed04dfad53696813cbd68058478d6c0becf (diff)
This patch removes mergeProperties and does the property lookup
in designated protocols lazily. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62007 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/DeclObjC.h6
-rw-r--r--lib/AST/DeclObjC.cpp35
-rw-r--r--lib/Sema/SemaDeclObjC.cpp13
-rw-r--r--test/SemaObjC/property-4.m3
4 files changed, 14 insertions, 43 deletions
diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h
index c9c8958981..561a0142e9 100644
--- a/include/clang/AST/DeclObjC.h
+++ b/include/clang/AST/DeclObjC.h
@@ -270,10 +270,6 @@ public:
void addProperties(ObjCPropertyDecl **Properties, unsigned NumProperties);
- // FIXME: Replace with appropriate lookup. Currently used by interfaces and
- // categories.
- void mergeProperties(ObjCPropertyDecl **Properties, unsigned NumProperties);
-
typedef ObjCPropertyDecl * const * prop_iterator;
prop_iterator prop_begin() const { return PropertyDecl; }
prop_iterator prop_end() const {
@@ -640,7 +636,7 @@ public:
// found, we search referenced protocols and class categories.
ObjCMethodDecl *lookupInstanceMethod(Selector Sel);
ObjCMethodDecl *lookupClassMethod(Selector Sel);
-
+
bool isForwardDecl() const { return isForwardProtoDecl; }
void setForwardDecl(bool val) { isForwardProtoDecl = val; }
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index 98d7164ba3..56da9a6dfa 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -378,31 +378,6 @@ unsigned ObjCContainerDecl::getNumClassMethods() const {
return sum;
}
-/// mergeProperties - Adds properties to the end of list of current properties
-/// for this class.
-
-void ObjCContainerDecl::mergeProperties(ObjCPropertyDecl **Properties,
- unsigned NumNewProperties) {
- if (NumNewProperties == 0) return;
-
- if (PropertyDecl) {
- ObjCPropertyDecl **newPropertyDecl =
- new ObjCPropertyDecl*[NumNewProperties + NumPropertyDecl];
- ObjCPropertyDecl **buf = newPropertyDecl;
- // put back original properties in buffer.
- memcpy(buf, PropertyDecl, NumPropertyDecl*sizeof(ObjCPropertyDecl*));
- // Add new properties to this buffer.
- memcpy(buf+NumPropertyDecl, Properties,
- NumNewProperties*sizeof(ObjCPropertyDecl*));
- delete[] PropertyDecl;
- PropertyDecl = newPropertyDecl;
- NumPropertyDecl += NumNewProperties;
- }
- else {
- addProperties(Properties, NumNewProperties);
- }
-}
-
/// addProperties - Insert property declaration AST nodes into
/// ObjCContainerDecl's PropertyDecl field.
///
@@ -425,6 +400,16 @@ ObjCContainerDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const {
if (property->getIdentifier() == PropertyId)
return property;
}
+ const ObjCProtocolDecl *PID = dyn_cast<ObjCProtocolDecl>(this);
+ if (PID) {
+ for (ObjCProtocolDecl::protocol_iterator P = PID->protocol_begin(),
+ E = PID->protocol_end();
+ P != E; ++P)
+ if (ObjCPropertyDecl *property =
+ (*P)->FindPropertyDeclaration(PropertyId))
+ return property;
+ }
+
const ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(this);
if (OID) {
// Look through categories.
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 49a8c835c5..d47f98af25 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -340,7 +340,6 @@ Sema::ComparePropertiesInBaseAndSuper(ObjCInterfaceDecl *IDecl) {
void
Sema::MergeOneProtocolPropertiesIntoClass(Decl *CDecl,
ObjCProtocolDecl *PDecl) {
- llvm::SmallVector<ObjCPropertyDecl*, 16> mergeProperties;
ObjCInterfaceDecl *IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(CDecl);
if (!IDecl) {
// Category
@@ -355,14 +354,10 @@ Sema::MergeOneProtocolPropertiesIntoClass(Decl *CDecl,
CP != CE; ++CP)
if ((*CP)->getIdentifier() == Pr->getIdentifier())
break;
- if (CP == CE)
- // Add this property to list of properties for thie class.
- mergeProperties.push_back(Pr);
- else
+ if (CP != CE)
// Property protocol already exist in class. Diagnose any mismatch.
DiagnosePropertyMismatch((*CP), Pr, PDecl->getIdentifier());
}
- CatDecl->mergeProperties(&mergeProperties[0], mergeProperties.size());
return;
}
for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(),
@@ -374,14 +369,10 @@ Sema::MergeOneProtocolPropertiesIntoClass(Decl *CDecl,
CP != CE; ++CP)
if ((*CP)->getIdentifier() == Pr->getIdentifier())
break;
- if (CP == CE)
- // Add this property to list of properties for thie class.
- mergeProperties.push_back(Pr);
- else
+ if (CP != CE)
// Property protocol already exist in class. Diagnose any mismatch.
DiagnosePropertyMismatch((*CP), Pr, PDecl->getIdentifier());
}
- IDecl->mergeProperties(&mergeProperties[0], mergeProperties.size());
}
/// MergeProtocolPropertiesIntoClass - This routine merges properties
diff --git a/test/SemaObjC/property-4.m b/test/SemaObjC/property-4.m
index 0fcc67d05d..b3000967fc 100644
--- a/test/SemaObjC/property-4.m
+++ b/test/SemaObjC/property-4.m
@@ -24,7 +24,6 @@
int newO;
int oldO;
}
-@property (retain) id MayCauseError; // expected-warning {{property 'MayCauseError' 'copy' attribute does not match the property inherited from 'GCObject'}} \
- expected-warning {{property 'MayCauseError' 'copy' attribute does not match the property inherited from 'ProtocolObject'}}
+@property (retain) id MayCauseError; // expected-warning {{property 'MayCauseError' 'copy' attribute does not match the property inherited from 'ProtocolObject'}}
@end