[cfe-commits] r112935 - in /cfe/trunk: include/clang/Lex/Token.h lib/Lex/Preprocessor.cpp lib/Parse/ParseObjc.cpp test/SemaObjCXX/cxxoperator-selector.mm

Chris Lattner clattner at apple.com
Fri Sep 3 09:40:20 PDT 2010


On Sep 3, 2010, at 8:10 AM, Fariborz Jahanian wrote:
>>> Patch to allow alternative representation of c++
>>> operators (and, or, etc.) to be used as selectors
>>> to match g++'s behavior.
>> 
>> Hi Fariborz,
>> 
>> Instead of adding this to Token, can you just use SomeToken.getIdentifier()->isCPlusPlusOperatorKeyword() wherever you'd check Tok.isCPlusPlusOpKeyword()?
> 
> I tried this first. When we set the Identifier field to 0 when we detect such tokens. I tried to remove code which does that. But there are
> assumptions of Token.getIdentifier() to be 0 and several tests broke. So, I use a 1-bit flag instead.

Ah interesting!  I think it would work to catch things like "tok::ampamp", then check the spelling (with PP::getSpelling) to see if it is spelled "and" or "&&".  In the former, turn it back into an identifier.  That would localize this weirdness to the ObjC frontend instead of needing a bit on Token,

-Chris





More information about the cfe-commits mailing list