[cfe-commits] r58817 - in /cfe/trunk: include/clang/AST/ include/clang/Basic/ include/clang/Parse/ lib/AST/ lib/Basic/ lib/Parse/ lib/Sema/ test/SemaCXX/ www/

Chris Lattner clattner at apple.com
Sun Nov 16 20:01:15 PST 2008


On Nov 10, 2008, at 8:36 AM, Sebastian Redl wrote:
>>>> +IdentifierInfo *Parser::MaybeParseOperatorFunctionId() {
>>>> +  if (Tok.isNot(tok::kw_operator))
>>>> +    return 0;
>>>> +
>>>> +  OverloadedOperatorKind Op = OO_None;
>>>> +  switch (NextToken().getKind()) {
>>>>
>>>>
>>> Hmm ... I know very little about how Clang's parser works, but  
>>> wouldn't it
>>> be easier to just consume the operator keyword no matter what?  
>>> What's the
>>> use case of leaving it in there? (Obviously, the part that parses a
>>> conversion operator would have to be adapted.)
>>>
>>
>> If the token after the 'operator' does not start an
>> operator-function-id, we don't parse the 'operator'. Instead, we end
>> up parsing a conversion-function-id, which consumes the 'operator'.
>>
> Well, the conversion-function-id could simply not consume the  
> 'operator'.

It's a pretty minor issue (overloaded operators are not that common in  
the big picture) but avoiding lookahead is a very good thing for  
performance.  It is good to do this unless it makes the code really  
horrible an unmaintainable.  I'll let you guys make the call though.

-Chris



More information about the cfe-commits mailing list