[cfe-commits] r167800 - /cfe/trunk/lib/Lex/Lexer.cpp
Sean Silva
silvas at purdue.edu
Mon Nov 12 18:48:23 PST 2012
Did you heed the comment above LexTokenInternal to carefully benchmark
any changes? If so, please cite the methodology and the results
obtained.
-- Sean Silva
On Mon, Nov 12, 2012 at 8:02 PM, Argyrios Kyrtzidis <akyrtzi at gmail.com> wrote:
> Author: akirtzidis
> Date: Mon Nov 12 19:02:40 2012
> New Revision: 167800
>
> URL: http://llvm.org/viewvc/llvm-project?rev=167800&view=rev
> Log:
> In Lexer::LexTokenInternal, avoid code duplication; no functionality change.
>
> Modified:
> cfe/trunk/lib/Lex/Lexer.cpp
>
> Modified: cfe/trunk/lib/Lex/Lexer.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=167800&r1=167799&r2=167800&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Lex/Lexer.cpp (original)
> +++ cfe/trunk/lib/Lex/Lexer.cpp Mon Nov 12 19:02:40 2012
> @@ -3019,26 +3019,8 @@
> // it's actually the start of a preprocessing directive. Callback to
> // the preprocessor to handle it.
> // FIXME: -fpreprocessed mode??
> - if (Result.isAtStartOfLine() && !LexingRawMode && !Is_PragmaLexer) {
> - FormTokenWithChars(Result, CurPtr, tok::hash);
> - PP->HandleDirective(Result);
> -
> - // As an optimization, if the preprocessor didn't switch lexers, tail
> - // recurse.
> - if (PP->isCurrentLexer(this)) {
> - // Start a new token. If this is a #include or something, the PP may
> - // want us starting at the beginning of the line again. If so, set
> - // the StartOfLine flag and clear LeadingSpace.
> - if (IsAtStartOfLine) {
> - Result.setFlag(Token::StartOfLine);
> - Result.clearFlag(Token::LeadingSpace);
> - IsAtStartOfLine = false;
> - }
> - goto LexNextToken; // GCC isn't tail call eliminating.
> - }
> -
> - return PP->Lex(Result);
> - }
> + if (Result.isAtStartOfLine() && !LexingRawMode && !Is_PragmaLexer)
> + goto HandleDirective;
>
> Kind = tok::hash;
> }
> @@ -3203,25 +3185,8 @@
> // it's actually the start of a preprocessing directive. Callback to
> // the preprocessor to handle it.
> // FIXME: -fpreprocessed mode??
> - if (Result.isAtStartOfLine() && !LexingRawMode && !Is_PragmaLexer) {
> - FormTokenWithChars(Result, CurPtr, tok::hash);
> - PP->HandleDirective(Result);
> -
> - // As an optimization, if the preprocessor didn't switch lexers, tail
> - // recurse.
> - if (PP->isCurrentLexer(this)) {
> - // Start a new token. If this is a #include or something, the PP may
> - // want us starting at the beginning of the line again. If so, set
> - // the StartOfLine flag and clear LeadingSpace.
> - if (IsAtStartOfLine) {
> - Result.setFlag(Token::StartOfLine);
> - Result.clearFlag(Token::LeadingSpace);
> - IsAtStartOfLine = false;
> - }
> - goto LexNextToken; // GCC isn't tail call eliminating.
> - }
> - return PP->Lex(Result);
> - }
> + if (Result.isAtStartOfLine() && !LexingRawMode && !Is_PragmaLexer)
> + goto HandleDirective;
>
> Kind = tok::hash;
> }
> @@ -3248,4 +3213,26 @@
>
> // Update the location of token as well as BufferPtr.
> FormTokenWithChars(Result, CurPtr, Kind);
> + return;
> +
> +HandleDirective:
> + // We parsed a # character and it's the start of a preprocessing directive.
> +
> + FormTokenWithChars(Result, CurPtr, tok::hash);
> + PP->HandleDirective(Result);
> +
> + // As an optimization, if the preprocessor didn't switch lexers, tail
> + // recurse.
> + if (PP->isCurrentLexer(this)) {
> + // Start a new token. If this is a #include or something, the PP may
> + // want us starting at the beginning of the line again. If so, set
> + // the StartOfLine flag and clear LeadingSpace.
> + if (IsAtStartOfLine) {
> + Result.setFlag(Token::StartOfLine);
> + Result.clearFlag(Token::LeadingSpace);
> + IsAtStartOfLine = false;
> + }
> + goto LexNextToken; // GCC isn't tail call eliminating.
> + }
> + return PP->Lex(Result);
> }
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list