[clang] Correctly handle negative line changes (PR #166631)
Sergej Salnikov via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 5 12:25:39 PST 2025
https://github.com/SergejSalnikov created https://github.com/llvm/llvm-project/pull/166631
None
>From a53cdabdd7fcf83c2377cf78f2848c1f795c7b2c Mon Sep 17 00:00:00 2001
From: Sergej Salnikov <skill at google.com>
Date: Wed, 5 Nov 2025 21:25:04 +0100
Subject: [PATCH] Correctly handle negative line changes
---
clang/lib/Frontend/PrintPreprocessedOutput.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
index 9e046633328d7..32e2b8cdcf4c6 100644
--- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -306,7 +306,7 @@ bool PrintPPOutputPPCallbacks::MoveToLine(unsigned LineNo,
*OS << '\n';
StartedNewLine = true;
} else if (!DisableLineMarkers) {
- if (LineNo - CurLine <= 8) {
+ if (LineNo >= CurLine && LineNo - CurLine <= 8) {
const char *NewLines = "\n\n\n\n\n\n\n\n";
OS->write(NewLines, LineNo - CurLine);
} else {
More information about the cfe-commits
mailing list