[cfe-commits] r41723 - in /cfe/trunk: Parse/ParseExpr.cpp Parse/ParseObjc.cpp include/clang/Parse/Parser.h test/Parser/method-prototype-1.m

Fariborz Jahanian fjahanian at apple.com
Wed Sep 26 17:03:33 PDT 2007


On Sep 26, 2007, at 4:44 PM, Chris Lattner wrote:

> On Sep 5, 2007, at 12:52 PM, Fariborz Jahanian wrote:
>> Author: fjahanian
>> Date: Wed Sep  5 14:52:07 2007
>> New Revision: 41723
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=41723&view=rev
>> Log:
>> 1. Fix parsing of method prototype involving c-style argument  
>> declarations.
>> 2. Fixes all allowable key-words used as selectors.
>> 3. Template to do the messaging parse.
>> 4. A test case for all allowable selector names.
>
> Hi Fariborz,
>
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> --- cfe/trunk/Parse/ParseObjc.cpp (original)
>> +++ cfe/trunk/Parse/ParseObjc.cpp Wed Sep  5 14:52:07 2007
>> @@ -384,10 +384,9 @@
>>   tok::TokenKind tKind = Tok.getKind();
>>   IdentifierInfo *II = 0;
>>
>> +  if (tKind == tok::identifier   || tKind == tok::kw_typeof ||
>> +      tKind == tok::kw___alignof ||
>>       (tKind >= tok::kw_auto && tKind <= tok::kw__Complex)) {
>>     II = Tok.getIdentifierInfo();
>>     ConsumeToken();
>>   }
>
> This predicate in Parser::ParseObjCSelector() seems really fragile  
> to me, because it prevents reordering of keywords in the keyword  
> table.  Is the idea here to allow any identifier or keyword?  If so,  
> a better thing to do would be:
>
>  IdentifierInfo *II = Tok.getIdentifierInfo();
>  if (II != 0)
>    ConsumeToken();
>
>  ...
>
> This will eat and return the identifier info for anything that is an  
> identifier or keyword.  Would this work for your needs here?

I am afraid not. Attached test case is all keywords allowed as  
selector name (this must match gcc's). We must be selective on  
selector names :). Maybe we can turn this into a case statement if you  
are not comfortable with order depenedency of this test.

- Fariborz

>
>
> -Chris




More information about the cfe-commits mailing list