[clang] Correctly handle negative line changes (PR #166631)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 5 12:26:12 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Sergej Salnikov (SergejSalnikov)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/166631.diff
1 Files Affected:
- (modified) clang/lib/Frontend/PrintPreprocessedOutput.cpp (+1-1)
``````````diff
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 {
``````````
</details>
https://github.com/llvm/llvm-project/pull/166631
More information about the cfe-commits
mailing list