[cfe-commits] r57991 - in /cfe/trunk: include/clang/AST/DeclCXX.h include/clang/Basic/DiagnosticKinds.def include/clang/Parse/Action.h include/clang/Parse/Parser.h lib/AST/DeclCXX.cpp lib/Parse/ParseDeclCXX.cpp lib/Sema/Sema.h lib/Sema/SemaDeclCX

Chris Lattner clattner at apple.com
Thu Oct 23 21:45:02 PDT 2008


On Oct 23, 2008, at 8:53 AM, Doug Gregor wrote:
>>> +public:
>>> +  static CXXBaseSpecifier *Create(ASTContext &C, SourceRange R,  
>>> bool V,
>>> bool BC,
>>> +                                  AccessSpecifier A, QualType T);
>>
>> you're making an array of pointers to CXXBaseSpecifier's.  Would it  
>> be
>> better to just have an array of CXXBaseSpecifier's directly?   
>> Alternatively,
>> instead of an array of pointers, maybe a linked list of  
>> CXXBaseSpecifier's
>> would be better?  If you prefer to stay with an array, maybe  
>> "ObjCList" (see
>> the top of DeclObjC.h) would work better and should be generalized.
>
> I'd like it to be an array of CXXBaseSpecifiers.
>
> The annoying problem here is that we return CXXBaseSpecifier pointers
> to the parser (as a BaseTy*, which is just a void*), when we'd really
> prefer to just return a CXXBaseSpecifier. Anyway, I'll switch over to
> an array of CXXBaseSpecifiers.

Your follow-on commit looks like an awesome step, thanks!

Is there a good way to fix this issue and avoid the new/delete pair in  
the common case?

It probably isn't worth the implementation effort, but one option  
would be to have a parser level version of 'CXXBaseSpecifier' and have  
the parser aggregate these together into a SmallVector and have Sema  
handle the whole list at once.  Base specifiers are probably not  
common enough to go to heroic measures to optimize, but it's an  
option. *shrug*

-Chris




More information about the cfe-commits mailing list