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 | 6aad4a31b35df07fe818f193fcfd3c0197aea467 (patch) | |
tree | 45f93f98a5082636c1f7473cc06710790c618bb7 /lib/Lex/PPDirectives.cpp | |
parent | 649aa6adc4d8650033508d38d3b442d355d90824 (diff) |
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>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175778 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PPDirectives.cpp')
-rw-r--r-- | lib/Lex/PPDirectives.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/lib/Lex/PPDirectives.cpp b/lib/Lex/PPDirectives.cpp index 18250281c1..54457c36cf 100644 --- a/lib/Lex/PPDirectives.cpp +++ b/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( |