diff options
author | Chris Lattner <sabre@nondot.org> | 2010-06-12 16:20:56 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-06-12 16:20:56 +0000 |
commit | bc6bcabc6134c74d9e6dc3568d604d2d8679d736 (patch) | |
tree | 633db373763e4057b8aec17a89717b0e6a4952b9 /clang/lib/Frontend/PrintPreprocessedOutput.cpp | |
parent | 0892ee503a46cae03a5e1ff526cfc7854bd5583e (diff) | |
download | llvm-bc6bcabc6134c74d9e6dc3568d604d2d8679d736.zip llvm-bc6bcabc6134c74d9e6dc3568d604d2d8679d736.tar.gz llvm-bc6bcabc6134c74d9e6dc3568d604d2d8679d736.tar.bz2 |
fix PR7360: -P mode turns off line markers, but not blank space.
Apparently some programs which abuse the preprocessor depend
on this.
llvm-svn: 105889
Diffstat (limited to 'clang/lib/Frontend/PrintPreprocessedOutput.cpp')
-rw-r--r-- | clang/lib/Frontend/PrintPreprocessedOutput.cpp | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp index e89c425..80e697d 100644 --- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp @@ -174,20 +174,6 @@ void PrintPPOutputPPCallbacks::WriteLineInfo(unsigned LineNo, /// #line directive. This returns false if already at the specified line, true /// if some newlines were emitted. bool PrintPPOutputPPCallbacks::MoveToLine(unsigned LineNo) { - if (DisableLineMarkers) { - if (LineNo == CurLine) return false; - - CurLine = LineNo; - - if (!EmittedTokensOnThisLine && !EmittedMacroOnThisLine) - return true; - - OS << '\n'; - EmittedTokensOnThisLine = false; - EmittedMacroOnThisLine = false; - return true; - } - // If this line is "close enough" to the original line, just print newlines, // otherwise print a #line directive. if (LineNo-CurLine <= 8) { @@ -199,8 +185,17 @@ bool PrintPPOutputPPCallbacks::MoveToLine(unsigned LineNo) { const char *NewLines = "\n\n\n\n\n\n\n\n"; OS.write(NewLines, LineNo-CurLine); } - } else { + } else if (!DisableLineMarkers) { + // Emit a #line or line marker. WriteLineInfo(LineNo, 0, 0); + } else { + // Okay, we're in -P mode, which turns off line markers. However, we still + // need to emit a newline between tokens on different lines. + if (EmittedTokensOnThisLine || EmittedMacroOnThisLine) { + OS << '\n'; + EmittedTokensOnThisLine = false; + EmittedMacroOnThisLine = false; + } } CurLine = LineNo; |