[llvm] [FileCheck] Add a diff output option for FileCheck (PR #187120)

Shivam Gupta via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 31 00:28:24 PDT 2026


================
@@ -2759,20 +2940,47 @@ bool FileCheck::checkInput(SourceMgr &SM, StringRef Buffer,
     if (i != 0 && Req.EnableVarScope)
       PatternContext->clearLocalVars();
 
+    // Check each string within the scanned region, including a second check
+    // of any final CHECK-LABEL (to verify CHECK-NOT and CHECK-DAG)
     for (; i != j; ++i) {
       const FileCheckString &CheckStr = CheckStrings[i];
 
-      // Check each string within the scanned region, including a second check
-      // of any final CHECK-LABEL (to verify CHECK-NOT and CHECK-DAG)
+      bool IsStrict = CheckStr.Pat.getCheckTy() == Check::CheckNext ||
+                      CheckStr.Pat.getCheckTy() == Check::CheckEmpty;
+
       size_t MatchLen = 0;
       size_t MatchPos =
           CheckStr.Check(SM, CheckRegion, false, MatchLen, Req, Diags);
 
+      // Handle failure
       if (MatchPos == StringRef::npos) {
+        if (IsDiffMode) {
+          handleDiffFailure(CheckStr, CheckRegion, SM, Diags, OS, HeaderPrinted,
+                            TotalMismatches);
+        }
         ChecksFailed = true;
         i = j;
         break;
       }
+      // For strict checks in Diff Mode, any skipped non-whitespace text is
+      // treated as a stray line. Even if a match is found later, we report
+      // the gap as a mismatch.
----------------
xgupta wrote:

Fix that in latest update.

https://github.com/llvm/llvm-project/pull/187120


More information about the llvm-commits mailing list