[cfe-commits] r49882 - in /cfe/trunk: include/clang/AST/DeclObjC.h include/clang/Basic/DiagnosticKinds.def include/clang/Parse/Action.h lib/Parse/ParseObjc.cpp lib/Sema/Sema.h lib/Sema/SemaDeclObjC.cpp
Chris Lattner
clattner at apple.com
Sat Apr 19 21:18:34 PDT 2008
On Apr 17, 2008, at 5:19 PM, Fariborz Jahanian wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=49882&view=rev
> Log:
> Initial work for property implementation declarations.
> Mostly semantic checking in this patch. This is on going
> and incomplete.
ok
>
> +++ cfe/trunk/include/clang/AST/DeclObjC.h Thu Apr 17 19:19:30 2008
> @@ -807,6 +808,9 @@
>
> /// implemented class methods
> llvm::SmallVector<ObjCMethodDecl*, 32> ClassMethods;
> +
> + /// Propertys' being implemented
> + llvm::SmallVector<ObjCPropertyImplDecl*, 8>
> PropertyImplementations;
Typo "Propertys'". I would just say "Property Implementations in this
category". Also, can you please add a comment above the
ObjCCategoryImplDecl class giving an example of how these occur in
ObjC code?
> // Get the instance method definition for this implementation.
> ObjCMethodDecl *getInstanceMethod(Selector Sel);
>
> // Get the class method definition for this implementation.
> ObjCMethodDecl *getClassMethod(Selector Sel);
> +
> + void addPropertyImplementation(ObjCPropertyImplDecl *property) {
> + PropertyImplementations.push_back(property);
> + }
>
> + unsigned getNumPropertyImplementations() const
> + { return PropertyImplementations.size(); }
> +
Please add an iterator interface for these.
Same comments for ObjCImplementationDecl.
> @@ -1041,14 +1063,15 @@
> OBJC_PR_IMPL_DYNAMIC
> };
> private:
> + SourceLocation AtLoc; // location of @syntheisze or @dynamic
Typo 'syntheisze'
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/include/clang/Parse/Action.h (original)
> +++ cfe/trunk/include/clang/Parse/Action.h Thu Apr 17 19:19:30 2008
> @@ -626,6 +626,18 @@
> SourceLocation CatLoc) {
> return 0;
> }
> + // ActOnPropertyImplDecl - called for every property implementation
> + virtual DeclTy *ActOnPropertyImplDecl(
> + SourceLocation AtLoc, // location of the @syntheize/
> @dynamic
Typo syntheize.
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Apr 17 19:19:30 2008
> @@ -929,5 +929,116 @@
> return PDecl;
> }
>
> -
> +/// ActOnPropertyImplDecl - This routine performas semantic checks
> and
typo 'performas'.
>
> +/// build the AST node for a property implementation declaration;
> declared
> +/// as @synthesize ot @dynamic
Please end the sentence with a period. Typo "ot".
>
> +///
> +Sema::DeclTy *Sema::ActOnPropertyImplDecl(SourceLocation AtLoc,
> + SourceLocation PropertyLoc,
> + bool Synthesize,
> + DeclTy *ClassCatImpDecl,
> + IdentifierInfo *PropertyId,
> + IdentifierInfo
> *PropertyIvar) {
> + Decl *ClassImpDecl = static_cast<Decl*>(ClassCatImpDecl);
> + // Make sure we have a context for the property implementation
> declaration.
> + if (!ClassImpDecl) {
> + Diag(AtLoc, diag::error_missing_property_context);
> + return 0;
> + }
> + ObjCPropertyDecl *property = 0;
> + ObjCInterfaceDecl* IDecl = 0;
> + // Find the class or category class where this property must have
> + // a declaration.
> + if (ObjCImplementationDecl *IC =
> + dyn_cast<ObjCImplementationDecl>(ClassImpDecl)) {
> + IDecl = getObjCInterfaceDecl(IC->getIdentifier());
> + if (!IDecl) {
> + Diag(AtLoc, diag::error_missing_property_interface);
> + return 0;
> + }
> + // Look for this property declaration in the @implementation's
> @interface
> + ObjCInterfaceDecl::classprop_iterator I,E;
> + for (I = IDecl->classprop_begin(),
> + E = IDecl->classprop_end(); I != E; ++I) {
> + property = *I;
> + if (property->getIdentifier() == PropertyId)
> + break;
> + }
This loop should be a helper method on ObjCInterfaceDecl.
>
> + if (I == E) {
> + Diag(PropertyLoc, diag::error_bad_property_decl, IDecl-
> >getName());
> + return 0;
> + }
> + }
> + else if (ObjCCategoryImplDecl* CatImplClass =
> + dyn_cast<ObjCCategoryImplDecl>(ClassImpDecl)) {
> + IDecl = CatImplClass->getClassInterface();
> + if (!IDecl) {
> + Diag(AtLoc, diag::error_missing_property_interface);
> + return 0;
> + }
> + ObjCCategoryDecl *Categories;
> + for (ObjCCategoryDecl *Categories = IDecl->getCategoryList();
> + Categories; Categories = Categories->getNextClassCategory())
> + if (Categories->getIdentifier() == CatImplClass-
> >getIdentifier())
> + break;
>
> + // If category for this implementation not found, it is an
> error which
> + // has already been reported eralier.
> + if (!Categories)
> + return 0;
This should be a method on ObjCCategoryDecl.
>
> + // Look for this property declaration in @implementation's
> category
> + ObjCCategoryDecl::classprop_iterator I,E;
> + for (I = Categories->classprop_begin(),
> + E = Categories->classprop_end(); I != E; ++I) {
> + property = *I;
> + if (property->getIdentifier() == PropertyId)
> + break;
> + }
> + if (I == E) {
> + Diag(PropertyLoc, diag::error_bad_property_decl,
> + Categories->getName());
> + return 0;
> + }
This should be a method on ObjCCategoryDecl.
...
> + // Check that this is a previously declared 'ivar' in 'IDecl'
> interface
> + ObjCInterfaceDecl::ivar_iterator IVI, IVE;
> + for (IVI = IDecl->ivar_begin(), IVE = IDecl->ivar_end();
> + IVI != IVE; ++IVI) {
> + ObjCIvarDecl* ImplIvar = (*IVI);
> + if (ImplIvar->getIdentifier() == PropertyIvar)
> + break;
> + }
This should be (is?) a method on ObjCInterfaceDecl.
-Chris
More information about the cfe-commits
mailing list