diff options
author | Jordan Rose <jordan_rose@apple.com> | 2013-02-21 18:53:19 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2013-02-21 18:53:19 +0000 |
commit | cb8a1aca35ecc33a5adcc0892aa31fb2a7750dc8 (patch) | |
tree | 579e2f5e4f7eb40093d7fb178cd34bae92420c05 /clang/lib/Lex/PPDirectives.cpp | |
parent | 50f0c80341bb021501788ac26611cd05bf563252 (diff) | |
download | bcm5719-llvm-cb8a1aca35ecc33a5adcc0892aa31fb2a7750dc8.tar.gz bcm5719-llvm-cb8a1aca35ecc33a5adcc0892aa31fb2a7750dc8.zip |
Preprocessor: preserve whitespace in -traditional-cpp mode.
Note that unlike GNU cpp we currently do not preserve whitespace in macros
(even in -traditional-cpp mode).
<rdar://problem/12897179>
llvm-svn: 175778
Diffstat (limited to 'clang/lib/Lex/PPDirectives.cpp')
-rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index 18250281c1d..54457c36cfd 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -269,7 +269,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc, if (Tok.isNot(tok::raw_identifier)) { CurPPLexer->ParsingPreprocessorDirective = false; // Restore comment saving mode. - if (CurLexer) CurLexer->SetCommentRetentionState(KeepComments); + if (CurLexer) CurLexer->resetExtendedTokenMode(); continue; } @@ -285,7 +285,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc, FirstChar != 'i' && FirstChar != 'e') { CurPPLexer->ParsingPreprocessorDirective = false; // Restore comment saving mode. - if (CurLexer) CurLexer->SetCommentRetentionState(KeepComments); + if (CurLexer) CurLexer->resetExtendedTokenMode(); continue; } @@ -302,7 +302,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc, if (IdLen >= 20) { CurPPLexer->ParsingPreprocessorDirective = false; // Restore comment saving mode. - if (CurLexer) CurLexer->SetCommentRetentionState(KeepComments); + if (CurLexer) CurLexer->resetExtendedTokenMode(); continue; } memcpy(DirectiveBuf, &DirectiveStr[0], IdLen); @@ -408,7 +408,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc, CurPPLexer->ParsingPreprocessorDirective = false; // Restore comment saving mode. - if (CurLexer) CurLexer->SetCommentRetentionState(KeepComments); + if (CurLexer) CurLexer->resetExtendedTokenMode(); } // Finally, if we are out of the conditional (saw an #endif or ran off the end @@ -594,6 +594,7 @@ void Preprocessor::HandleDirective(Token &Result) { // mode. Tell the lexer this so any newlines we see will be converted into an // EOD token (which terminates the directive). CurPPLexer->ParsingPreprocessorDirective = true; + if (CurLexer) CurLexer->SetKeepWhitespaceMode(false); ++NumDirectives; @@ -638,14 +639,9 @@ void Preprocessor::HandleDirective(Token &Result) { // and reset to previous state when returning from this function. ResetMacroExpansionHelper helper(this); -TryAgain: switch (Result.getKind()) { case tok::eod: return; // null directive. - case tok::comment: - // Handle stuff like "# /*foo*/ define X" in -E -C mode. - LexUnexpandedToken(Result); - goto TryAgain; case tok::code_completion: if (CodeComplete) CodeComplete->CodeCompleteDirective( |