[cfe-commits] r105889 - in /cfe/trunk: lib/Frontend/PrintPreprocessedOutput.cpp test/Preprocessor/print_line_track.c
Chris Lattner
sabre at nondot.org
Sat Jun 12 09:20:56 PDT 2010
Author: lattner
Date: Sat Jun 12 11:20:56 2010
New Revision: 105889
URL: http://llvm.org/viewvc/llvm-project?rev=105889&view=rev
Log:
fix PR7360: -P mode turns off line markers, but not blank space.
Apparently some programs which abuse the preprocessor depend
on this.
Modified:
cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
cfe/trunk/test/Preprocessor/print_line_track.c
Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=105889&r1=105888&r2=105889&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Sat Jun 12 11:20:56 2010
@@ -174,20 +174,6 @@
/// #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 @@
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;
Modified: cfe/trunk/test/Preprocessor/print_line_track.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/print_line_track.c?rev=105889&r1=105888&r2=105889&view=diff
==============================================================================
--- cfe/trunk/test/Preprocessor/print_line_track.c (original)
+++ cfe/trunk/test/Preprocessor/print_line_track.c Sat Jun 12 11:20:56 2010
@@ -3,8 +3,8 @@
* RUN: %clang_cc1 -E -P %s | grep 'a 3'
* RUN: %clang_cc1 -E -P %s | grep 'b 16'
* RUN: %clang_cc1 -E %s | not grep '# 0 '
- * PR1848
- * PR3437
+ * RUN: %clang_cc1 -E -P %s | count 4
+ * PR1848 PR3437 PR7360
*/
#define t(x) x
More information about the cfe-commits
mailing list