[cfe-commits] r49817 - in /cfe/trunk: Driver/ASTConsumers.cpp include/clang/AST/DeclObjC.h lib/AST/DeclObjC.cpp lib/Sema/SemaDeclObjC.cpp
Fariborz Jahanian
fjahanian at apple.com
Thu Apr 17 09:37:32 PDT 2008
On Apr 16, 2008, at 7:54 PM, Chris Lattner wrote:
> On Apr 16, 2008, at 2:08 PM, Fariborz Jahanian wrote:
>> URL: http://llvm.org/viewvc/llvm-project?rev=49817&view=rev
>> Log:
>> This patch adds support for declaraing properties in categories,
>> just as they are declared in objc classes.
>
> Nice!
>
>> Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=49817&r1=49816&r2=49817&view=diff
>>
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Wed Apr 16 16:08:45 2008
>> @@ -699,6 +699,9 @@
>> if (pNum != 0)
>> if (ObjCInterfaceDecl *IDecl =
>> dyn_cast<ObjCInterfaceDecl>(ClassDecl))
>> IDecl->addProperties((ObjCPropertyDecl**)allProperties, pNum);
>> + else
>> + if (ObjCCategoryDecl *CDecl =
>> dyn_cast<ObjCCategoryDecl>(ClassDecl))
>> + CDecl->addProperties((ObjCPropertyDecl**)allProperties,
>> pNum);
>>
>> for (unsigned i = 0; i < allNum; i++ ) {
>> ObjCMethodDecl *Method =
>
> What if ClassDecl is neither an ObjCInterfaceDecl or a
> ObjCCategoryDecl? Should there be an assert or error here?
I still need to do more in this area. Protocols are OK,
implementations are not. Much more sementaics checking need be done.
>
>
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- cfe/trunk/include/clang/AST/DeclObjC.h (original)
>> +++ cfe/trunk/include/clang/AST/DeclObjC.h Wed Apr 16 16:08:45 2008
>> @@ -672,6 +672,10 @@
>> public:
>>
>> @@ -705,6 +709,11 @@
>> unsigned getNumInstanceMethods() const { return
>> NumInstanceMethods; }
>> unsigned getNumClassMethods() const { return NumClassMethods; }
>>
>> + void addProperties(ObjCPropertyDecl **Properties, unsigned
>> NumProperties);
>> + unsigned getNumPropertyDecl() const { return NumPropertyDecl; }
>> +
>> + ObjCPropertyDecl * const * getPropertyDecl() const { return
>> PropertyDecl; }
>> +
>> typedef ObjCMethodDecl * const * instmeth_iterator;
>> instmeth_iterator instmeth_begin() const { return InstanceMethods; }
>> instmeth_iterator instmeth_end() const {
>>
>
> This looks good, but please add an iterarator interface to this,
> just like instmeth_begin/end and the iterators in InterfaceDecl.
Yes.
>
>
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =====================================================================
>> --- cfe/trunk/Driver/ASTConsumers.cpp (original)
>> +++ cfe/trunk/Driver/ASTConsumers.cpp Wed Apr 16 16:08:45 2008
>> @@ -345,6 +345,69 @@
>> Out << "@interface "
>> << PID->getClassInterface()->getName()
>> << '(' << PID->getName() << ");\n";
>> + // Output property declarations.
>> + int NumProperties = PID->getNumPropertyDecl();
>> + if (NumProperties > 0) {
>> + for (int i = 0; i < NumProperties; i++) {
>> + ObjCPropertyDecl *PDecl = PID->getPropertyDecl()[i];
>
> Please use the iterator interface instead of getNumPropertyDecl/
> getPropertyDecl. There is no need to check to see if NumProperties
> > 0.
Just wanted to do a print to look at the validity of the ASTs. Much
clean up need be done here.
>
>
>>
>> + Out << "@property";
>
> Should all this code be split out to a helper function that takes an
> ObjCPropertyDecl? This code should be generally shared with
> interfaces.
Yes. I just cut and pasted from interface to do a quick sanity check.
This need be consolidated with the one in interface (and protocol).
- Faribnorz
>
>
> -Chris
More information about the cfe-commits
mailing list