[cfe-commits] r61172 - /cfe/trunk/lib/Lex/PTHLexer.cpp

Chris Lattner clattner at apple.com
Wed Dec 17 16:55:36 PST 2008


On Dec 17, 2008, at 3:52 PM, Ted Kremenek wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=61172&view=rev
> Log:
> Rewrite PTHLexer::DiscardToEndOfLine() to not use GetToken and  
> instead only read the bytes needed to determine if a token is not at  
> the start of the line.

nice:

> +  while (1) {
> +    // Read the token kind.  Are we at the end of the file?
> +    tok::TokenKind x = (tok::TokenKind) (uint8_t) *p;
> +    if (x == tok::eof) break;
> +
> +    // Read the token flags.  Are we at the start of the next line?
> +    Token::TokenFlags y = (Token::TokenFlags) (uint8_t) p[1];
> +    if (y == Token::StartOfLine) break;

I think this should be:

if (y & Token::StartOfLine)

in case other flags (e.g. leading whitespace) are set.

-Chris




More information about the cfe-commits mailing list