[cfe-commits] r62037 - in /cfe/trunk: include/clang/AST/DeclObjC.h lib/AST/DeclObjC.cpp lib/CodeGen/CGObjCMac.cpp lib/Sema/SemaDeclObjC.cpp
Steve Naroff
snaroff at apple.com
Sun Jan 11 04:48:00 PST 2009
Author: snaroff
Date: Sun Jan 11 06:47:58 2009
New Revision: 62037
URL: http://llvm.org/viewvc/llvm-project?rev=62037&view=rev
Log:
Convert property implementation to DeclContext::addDecl().
This completes the ObjCContainerDecl AST cleanup (for now).
Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/AST/DeclObjC.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=62037&r1=62036&r2=62037&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Sun Jan 11 06:47:58 2009
@@ -250,33 +250,25 @@
/// Current sub-classes are ObjCInterfaceDecl, ObjCCategoryDecl, and
/// ObjCProtocolDecl.
/// FIXME: Use for ObjC implementation decls.
-/// FIXME: Convert property implementation to DeclContext::addDecl(). Holding
-/// off until we have an iterator adaptor that plays with DeclContext.
///
class ObjCContainerDecl : public ScopedDecl, public DeclContext {
- /// class properties
- ObjCPropertyDecl **PropertyDecl; // Null if no property
- unsigned NumPropertyDecl; // 0 if none.
-
SourceLocation AtEndLoc; // marks the end of the method container.
public:
ObjCContainerDecl(Kind DK, DeclContext *DC, SourceLocation L,
IdentifierInfo *Id)
- : ScopedDecl(DK, DC, L, Id), DeclContext(DK),
- PropertyDecl(0), NumPropertyDecl(0) {}
+ : ScopedDecl(DK, DC, L, Id), DeclContext(DK) {}
virtual ~ObjCContainerDecl();
- void addProperties(ObjCPropertyDecl **Properties, unsigned NumProperties);
-
- typedef ObjCPropertyDecl * const * prop_iterator;
- prop_iterator prop_begin() const { return PropertyDecl; }
- prop_iterator prop_end() const {
- return PropertyDecl+NumPropertyDecl;
+ // Iterator access to properties.
+ typedef specific_decl_iterator<ObjCPropertyDecl> prop_iterator;
+ prop_iterator prop_begin() const {
+ return prop_iterator(decls_begin(), decls_end());
+ }
+ prop_iterator prop_end() const {
+ return prop_iterator(decls_end(), decls_end());
}
-
- ObjCPropertyDecl *FindPropertyDeclaration(IdentifierInfo *PropertyId) const;
// Iterator access to instance/class methods.
typedef specific_decl_iterator<ObjCMethodDecl> method_iterator;
@@ -311,6 +303,8 @@
ObjCMethodDecl *getInstanceMethod(Selector Sel) const;
ObjCMethodDecl *getClassMethod(Selector Sel) const;
+ ObjCPropertyDecl *FindPropertyDeclaration(IdentifierInfo *PropertyId) const;
+
// Get the number of methods, properties. These methods are slow, O(n).
unsigned getNumInstanceMethods() const;
unsigned getNumClassMethods() const;
Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=62037&r1=62036&r2=62037&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Sun Jan 11 06:47:58 2009
@@ -62,7 +62,6 @@
}
ObjCContainerDecl::~ObjCContainerDecl() {
- delete [] PropertyDecl;
}
ObjCInterfaceDecl::~ObjCInterfaceDecl() {
@@ -390,20 +389,9 @@
return sum;
}
-/// addProperties - Insert property declaration AST nodes into
-/// ObjCContainerDecl's PropertyDecl field.
-///
-void ObjCContainerDecl::addProperties(ObjCPropertyDecl **Properties,
- unsigned NumProperties) {
- if (NumProperties == 0) return;
-
- NumPropertyDecl = NumProperties;
- PropertyDecl = new ObjCPropertyDecl*[NumProperties];
- memcpy(PropertyDecl, Properties, NumProperties*sizeof(ObjCPropertyDecl*));
-}
-
/// 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...
///
ObjCPropertyDecl *
ObjCContainerDecl::FindPropertyDeclaration(IdentifierInfo *PropertyId) const {
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=62037&r1=62036&r2=62037&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Sun Jan 11 06:47:58 2009
@@ -341,9 +341,8 @@
/// EmitPropertyList - Emit the given property list. The return
/// value has type PropertyListPtrTy.
llvm::Constant *EmitPropertyList(const std::string &Name,
- const Decl *Container,
- ObjCPropertyDecl * const *begin,
- ObjCPropertyDecl * const *end);
+ const Decl *Container,
+ const ObjCContainerDecl *OCD);
/// GetOrEmitProtocol - Get the protocol object for the given
/// declaration, emitting it if necessary. The return value has type
@@ -783,9 +782,7 @@
OptClassMethods);
Values[3] = EmitPropertyList("\01L_OBJC_$_PROP_PROTO_LIST_" +
PD->getNameAsString(),
- 0,
- PD->prop_begin(),
- PD->prop_end());
+ 0, PD);
// Return null if no extension bits are used.
if (Values[1]->isNullValue() && Values[2]->isNullValue() &&
@@ -863,11 +860,11 @@
*/
llvm::Constant *CGObjCMac::EmitPropertyList(const std::string &Name,
const Decl *Container,
- ObjCPropertyDecl * const *begin,
- ObjCPropertyDecl * const *end) {
+ const ObjCContainerDecl *OCD) {
std::vector<llvm::Constant*> Properties, Prop(2);
- for (; begin != end; ++begin) {
- const ObjCPropertyDecl *PD = *begin;
+ for (ObjCContainerDecl::prop_iterator I = OCD->prop_begin(),
+ E = OCD->prop_end(); I != E; ++I) {
+ const ObjCPropertyDecl *PD = *I;
Prop[0] = GetPropertyName(PD->getIdentifier());
Prop[1] = GetPropertyTypeString(PD, Container);
Properties.push_back(llvm::ConstantStruct::get(ObjCTypes.PropertyTy,
@@ -1003,9 +1000,7 @@
// If there is no category @interface then there can be no properties.
if (Category) {
Values[6] = EmitPropertyList(std::string("\01L_OBJC_$_PROP_LIST_") + ExtName,
- OCD,
- Category->prop_begin(),
- Category->prop_end());
+ OCD, Category);
} else {
Values[6] = llvm::Constant::getNullValue(ObjCTypes.PropertyListPtrTy);
}
@@ -1280,9 +1275,7 @@
// FIXME: Output weak_ivar_layout string.
Values[1] = llvm::Constant::getNullValue(ObjCTypes.Int8PtrTy);
Values[2] = EmitPropertyList("\01L_OBJC_$_PROP_LIST_" + ID->getNameAsString(),
- ID,
- ID->getClassInterface()->prop_begin(),
- ID->getClassInterface()->prop_end());
+ ID, ID->getClassInterface());
// Return null if no extension bits are used.
if (Values[1]->isNullValue() && Values[2]->isNullValue())
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=62037&r1=62036&r2=62037&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Sun Jan 11 06:47:58 2009
@@ -1143,14 +1143,7 @@
|| isa<ObjCProtocolDecl>(ClassDecl);
bool checkIdenticalMethods = isa<ObjCImplementationDecl>(ClassDecl);
- if (pNum != 0) {
- if (ObjCContainerDecl *CDecl = dyn_cast<ObjCContainerDecl>(ClassDecl))
- CDecl->addProperties((ObjCPropertyDecl**)allProperties, pNum);
- else
- assert(false && "ActOnAtEnd - property declaration misplaced");
- }
DeclContext *DC = dyn_cast<DeclContext>(ClassDecl);
- assert(DC && "Missing DeclContext");
// FIXME: Remove these and use the ObjCContainerDecl/DeclContext.
llvm::DenseMap<Selector, const ObjCMethodDecl*> InsMap;
@@ -1525,10 +1518,11 @@
if (t->isArrayType() || t->isFunctionType())
Diag(AtLoc, diag::err_property_type) << T;
- ObjCPropertyDecl *PDecl = ObjCPropertyDecl::Create(Context, CurContext, AtLoc,
+ DeclContext *DC = dyn_cast<DeclContext>(ClassDecl);
+ assert(DC && "ClassDecl is not a DeclContext");
+ ObjCPropertyDecl *PDecl = ObjCPropertyDecl::Create(Context, DC, AtLoc,
FD.D.getIdentifier(), T);
- // FIXME: PushOnScopeChains?
- CurContext->addDecl(Context, PDecl);
+ DC->addDecl(Context, PDecl);
// Regardless of setter/getter attribute, we save the default getter/setter
// selector names in anticipation of declaration of setter/getter methods.
More information about the cfe-commits
mailing list