[cfe-commits] r41801 - in /cfe/trunk: AST/Decl.cpp Parse/ParseObjc.cpp Sema/Sema.h Sema/SemaDecl.cpp include/clang/AST/Decl.h include/clang/Parse/Action.h include/clang/Parse/Parser.h
Chris Lattner
clattner at apple.com
Mon Sep 10 21:02:39 PDT 2007
On Sep 10, 2007, at 4:02 PM, Steve Naroff wrote:
>
> On Sep 10, 2007, at 2:19 PM, Chris Lattner wrote:
>
>>
>> On Sep 10, 2007, at 1:47 PM, Devang Patel wrote:
>>
>>>
>>> On Sep 10, 2007, at 1:33 PM, Fariborz Jahanian wrote:
>>>
>>>> + /// Insert collected methods declarations into the @interface
>>>> object.
>>>> + Actions.ObjcAddMethodsToClass(interfaceDecl, &allMethods[0],
>>>> allMethods.size());
>>> ...
>>>> +void Sema::ObjcAddMethodsToClass(DeclTy *ClassDecl,
>>>> + DeclTy **allMethods, unsigned allNum) {
>>>
>>> Is there a reason to not pass SmallVector reference directly ?
>>
>> Passing it like this allows the implementation in the client to not
>> use a smallvector: it could use a vector or a C array if it chose to.
>>
>
> Isn't ownership the key API issue here?
Partially.
> That is, even if we passed in the SmallVector, it is typically a
> short-lived stack object. This means the Action hook would still
> need extract all the elements from the SmallVector (which is what
> passing the <DeclTy **, unsigned> tuple is doing.
>
> It seems like handing the SmallVector directly to the actions
> method is more error prone (not simply an issue of choice).
This is true as well. However, the action method *could* be declared
as taking a const reference to a smallvector. This would make it
clear that the client owns the smallvector, not the actions
implementation.
However, this would artificially limit the interface, and wouldn't
make it much more concrete.
-Chris
More information about the cfe-commits
mailing list