[llvm] [FileCheck] Add a diff output option for FileCheck (PR #187120)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 27 04:02:33 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- llvm/include/llvm/FileCheck/FileCheck.h llvm/lib/FileCheck/FileCheck.cpp llvm/lib/FileCheck/FileCheckImpl.h llvm/utils/FileCheck/FileCheck.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp
index 8fd815331..a354b9d38 100644
--- a/llvm/lib/FileCheck/FileCheck.cpp
+++ b/llvm/lib/FileCheck/FileCheck.cpp
@@ -2825,25 +2825,25 @@ static bool printDiff(DiffFormatType Mode, const FileCheckString &CheckStr,
unsigned ActualLineNo = OverwriteActualLine;
- // If no Fuzzy match was found, calculate the line number directly
- // from the InputLoc pointer using the SourceManager.
- if (ActualLineNo == 0)
- ActualLineNo = SM.getLineAndColumn(InputLoc).first;
+ // If no Fuzzy match was found, calculate the line number directly
+ // from the InputLoc pointer using the SourceManager.
+ if (ActualLineNo == 0)
+ ActualLineNo = SM.getLineAndColumn(InputLoc).first;
- // if we are at an empty line (and not from fuzzy), usually the relevant
- // context is the line just before it.
- if (ActualLine.empty() && ActualLineNo > 1)
- ActualLineNo--;
+ // if we are at an empty line (and not from fuzzy), usually the relevant
+ // context is the line just before it.
+ if (ActualLine.empty() && ActualLineNo > 1)
+ ActualLineNo--;
- // Gather contextual diff to print (a line above and a line below).
- unsigned BufID = SM.FindBufferContainingLoc(InputLoc);
- DiffContext Context = getDiffContext(SM, ActualLineNo, BufID);
+ // Gather contextual diff to print (a line above and a line below).
+ unsigned BufID = SM.FindBufferContainingLoc(InputLoc);
+ DiffContext Context = getDiffContext(SM, ActualLineNo, BufID);
- renderDiff(Mode, ExpectedLineNo, ActualLineNo, ActualLine, ExpectedText,
- Context, OverwriteActualLine);
+ renderDiff(Mode, ExpectedLineNo, ActualLineNo, ActualLine, ExpectedText,
+ Context, OverwriteActualLine);
- llvm::errs() << "\n";
- return true;
+ llvm::errs() << "\n";
+ return true;
}
// Report the mismatch on the current line and advance to the next line.
``````````
</details>
https://github.com/llvm/llvm-project/pull/187120
More information about the llvm-commits
mailing list