Skip to content

Conversation

@SergejSalnikov
Copy link
Contributor

No description provided.

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Nov 5, 2025
@llvmbot
Copy link
Member

llvmbot commented Nov 5, 2025

@llvm/pr-subscribers-clang

Author: Sergej Salnikov (SergejSalnikov)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/166631.diff

1 Files Affected:

  • (modified) clang/lib/Frontend/PrintPreprocessedOutput.cpp (+1-1)
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 {

@SergejSalnikov SergejSalnikov changed the title Correctly handle negative line changes [clang]Correctly handle negative line changes in MoveToLine Nov 5, 2025
@SergejSalnikov SergejSalnikov changed the title [clang]Correctly handle negative line changes in MoveToLine [clang]Correctly handle negative line changes in PrintPreprocessedOutput::MoveToLine Nov 5, 2025
Copy link
Collaborator

@shafik shafik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change needs a summary explaining the problem and how this fixes it. It is not obvious what your are fixing and without more narrative I can't review this properly. It also needs a test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants