diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-11-13 01:02:40 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-11-13 01:02:40 +0000 |
commit | 36675b75fbeb6578d510db29ade03596b4bc32af (patch) | |
tree | 914f9ee02dc2c967895dbd4ebca37fb45a49d575 | |
parent | 744611f9baebba0bcf255a62471a31abcca2f541 (diff) | |
download | bcm5719-llvm-36675b75fbeb6578d510db29ade03596b4bc32af.tar.gz bcm5719-llvm-36675b75fbeb6578d510db29ade03596b4bc32af.zip |
In Lexer::LexTokenInternal, avoid code duplication; no functionality change.
llvm-svn: 167800
-rw-r--r-- | clang/lib/Lex/Lexer.cpp | 65 |
1 files changed, 26 insertions, 39 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index c5fe1d879b1..e6e7ca5ee17 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -3019,26 +3019,8 @@ LexNextToken: // 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 @@ LexNextToken: // 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 @@ LexNextToken: // 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); } |