]> granicus.if.org Git - clang/commitdiff
Fix a pretty big but subtle bug counting the number of newlines to emit.
authorChris Lattner <sabre@nondot.org>
Sun, 9 Dec 2007 20:45:43 +0000 (20:45 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 9 Dec 2007 20:45:43 +0000 (20:45 +0000)
This would cause us to emit different code (in -E mode) for these two files:

---
#define t(x) x

t(a
3)
---
#define t(x) x
t(a
3)
---

In one case, -E would print "a\n3", in the other it printed "a3".  Now
it prints "a3" for both.

This is part of PR1848.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44742 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/PrintPreprocessedOutput.cpp

index da0023760d1390aecf32ab09caa1167ebdf89534..9783754654a8e37b27626b09535a2c3eb3af56c8 100644 (file)
@@ -188,8 +188,8 @@ void PrintPPOutputPPCallbacks::MoveToLine(SourceLocation Loc) {
     else {
       const char *NewLines = "\n\n\n\n\n\n\n\n";
       OutputString(NewLines, LineNo-CurLine);
-      CurLine = LineNo;
     }
+    CurLine = LineNo;
   } else {
     if (EmittedTokensOnThisLine) {
       OutputChar('\n');