aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaObjCProperty.cpp
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2012-10-18 19:17:53 +0000
committerAnna Zaks <ganna@apple.com>2012-10-18 19:17:53 +0000
commitb36ea375e20f71df19c101fa2399b7ea3a607e04 (patch)
tree3dff56c7523d88da9b3ecebc798159631ebbd9f5 /lib/Sema/SemaObjCProperty.cpp
parenta7a68b61e809a74fb5d34d57d7429fcc95e1ccad (diff)
Factor CollectClassPropertyImplementations out of Sema into AST
This would make it possible for the analyzer to use the function. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166210 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaObjCProperty.cpp')
-rw-r--r--lib/Sema/SemaObjCProperty.cpp54
1 files changed, 12 insertions, 42 deletions
diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp
index e7fbb8ffac..6ed6d00d2e 100644
--- a/lib/Sema/SemaObjCProperty.cpp
+++ b/lib/Sema/SemaObjCProperty.cpp
@@ -1435,8 +1435,8 @@ bool Sema::isPropertyReadonly(ObjCPropertyDecl *PDecl,
/// 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 @@ void Sema::CollectImmediateProperties(ObjCContainerDecl *CDecl,
}
}
-/// CollectClassPropertyImplementations - This routine collects list of
-/// properties to be implemented in the class. This includes, class's
-/// and its conforming protocols' properties.
-static void CollectClassPropertyImplementations(ObjCContainerDecl *CDecl,
- llvm::DenseMap<IdentifierInfo *, ObjCPropertyDecl*>& PropMap) {
- if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(CDecl)) {
- for (ObjCContainerDecl::prop_iterator P = IDecl->prop_begin(),
- E = IDecl->prop_end(); P != E; ++P) {
- ObjCPropertyDecl *Prop = *P;
- PropMap[Prop->getIdentifier()] = Prop;
- }
- for (ObjCInterfaceDecl::all_protocol_iterator
- PI = IDecl->all_referenced_protocol_begin(),
- E = IDecl->all_referenced_protocol_end(); PI != E; ++PI)
- CollectClassPropertyImplementations((*PI), PropMap);
- }
- else if (ObjCProtocolDecl *PDecl = dyn_cast<ObjCProtocolDecl>(CDecl)) {
- for (ObjCProtocolDecl::prop_iterator P = PDecl->prop_begin(),
- E = PDecl->prop_end(); P != E; ++P) {
- ObjCPropertyDecl *Prop = *P;
- // Insert into PropMap if not there already.
- PropMap.insert(std::make_pair(Prop->getIdentifier(), Prop));
- }
- // scan through protocol's protocols.
- for (ObjCProtocolDecl::protocol_iterator PI = PDecl->protocol_begin(),
- E = PDecl->protocol_end(); PI != E; ++PI)
- CollectClassPropertyImplementations((*PI), PropMap);
- }
-}
-
/// 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();
}
}
@@ -1530,20 +1500,20 @@ static void CollectSuperClassPropertyImplementations(ObjCInterfaceDecl *CDecl,
void Sema::DefaultSynthesizeProperties(Scope *S, ObjCImplDecl* IMPDecl,
ObjCInterfaceDecl *IDecl) {
- llvm::DenseMap<IdentifierInfo *, ObjCPropertyDecl*> PropMap;
- CollectClassPropertyImplementations(IDecl, PropMap);
+ ObjCInterfaceDecl::PropertyMap PropMap;
+ IDecl->collectPropertiesToImplement(PropMap);
if (PropMap.empty())
return;
- llvm::DenseMap<IdentifierInfo *, ObjCPropertyDecl*> SuperPropMap;
+ ObjCInterfaceDecl::PropertyMap SuperPropMap;
CollectSuperClassPropertyImplementations(IDecl, SuperPropMap);
- for (llvm::DenseMap<IdentifierInfo *, ObjCPropertyDecl*>::iterator
+ for (ObjCInterfaceDecl::PropertyMap::iterator
P = PropMap.begin(), E = PropMap.end(); P != E; ++P) {
ObjCPropertyDecl *Prop = P->second;
// If property to be implemented in the super class, ignore.
if (SuperPropMap[Prop->getIdentifier()])
continue;
- // Is there a matching propery synthesize/dynamic?
+ // Is there a matching property synthesize/dynamic?
if (Prop->isInvalidDecl() ||
Prop->getPropertyImplementation() == ObjCPropertyDecl::Optional ||
IMPDecl->FindPropertyImplIvarDecl(Prop->getIdentifier()))
@@ -1596,11 +1566,11 @@ void Sema::DefaultSynthesizeProperties(Scope *S, Decl *D) {
void Sema::DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl,
ObjCContainerDecl *CDecl,
const SelectorSet &InsMap) {
- llvm::DenseMap<IdentifierInfo *, ObjCPropertyDecl*> SuperPropMap;
+ ObjCContainerDecl::PropertyMap SuperPropMap;
if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(CDecl))
CollectSuperClassPropertyImplementations(IDecl, SuperPropMap);
- llvm::DenseMap<IdentifierInfo *, ObjCPropertyDecl*> PropMap;
+ ObjCContainerDecl::PropertyMap PropMap;
CollectImmediateProperties(CDecl, PropMap, SuperPropMap);
if (PropMap.empty())
return;
@@ -1611,7 +1581,7 @@ void Sema::DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl,
EI = IMPDecl->propimpl_end(); I != EI; ++I)
PropImplMap.insert(I->getPropertyDecl());
- for (llvm::DenseMap<IdentifierInfo *, ObjCPropertyDecl*>::iterator
+ for (ObjCContainerDecl::PropertyMap::iterator
P = PropMap.begin(), E = PropMap.end(); P != E; ++P) {
ObjCPropertyDecl *Prop = P->second;
// Is there a matching propery synthesize/dynamic?