[llvm] 5809100 - Revert "[FileCheck] Add a diff output option for FileCheck (#187120)" (#192803)

via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 18 11:33:41 PDT 2026


Author: Fangrui Song
Date: 2026-04-18T11:33:36-07:00
New Revision: 580910073482c0b49be5364f9595ba2dc2bf8f2e

URL: https://github.com/llvm/llvm-project/commit/580910073482c0b49be5364f9595ba2dc2bf8f2e
DIFF: https://github.com/llvm/llvm-project/commit/580910073482c0b49be5364f9595ba2dc2bf8f2e.diff

LOG: Revert "[FileCheck] Add a diff output option for FileCheck (#187120)" (#192803)

This reverts commit 40333cde2bbd62936d67478eab15ed1fa55b0532.

The implementation is buggy. There are thousands of failures in
```
FILECHECK_OPTS=--diff ninja -C /tmp/Rel check-llvm-mc
FILECHECK_OPTS=--diff ninja -C /tmp/Rel check-lld-elf
```

Added: 
    

Modified: 
    llvm/docs/CommandGuide/FileCheck.rst
    llvm/include/llvm/FileCheck/FileCheck.h
    llvm/lib/FileCheck/FileCheck.cpp
    llvm/lib/FileCheck/FileCheckImpl.h
    llvm/utils/FileCheck/FileCheck.cpp

Removed: 
    llvm/test/FileCheck/diff/diff-blank-stray.txt
    llvm/test/FileCheck/diff/diff-empty-check.txt
    llvm/test/FileCheck/diff/diff-label-boundary.txt
    llvm/test/FileCheck/diff/diff-label-fuzzy-match.txt
    llvm/test/FileCheck/diff/diff-label-next.txt
    llvm/test/FileCheck/diff/diff-multi-block.txt
    llvm/test/FileCheck/diff/diff-multi-failres.txt
    llvm/test/FileCheck/diff/diff-multi-mismatch.txt
    llvm/test/FileCheck/diff/diff-next-stray-line.txt
    llvm/test/FileCheck/diff/diff-regex-escaping.txt
    llvm/test/FileCheck/diff/diff-resync-after-noise.txt
    llvm/test/FileCheck/diff/diff-resync-high-noise.txt
    llvm/test/FileCheck/diff/diff-skipped-expected.txt
    llvm/test/FileCheck/diff/diff-stress-large-input.txt


################################################################################
diff  --git a/llvm/docs/CommandGuide/FileCheck.rst b/llvm/docs/CommandGuide/FileCheck.rst
index d99cbbdd9f36f..22101d3ef2ac7 100644
--- a/llvm/docs/CommandGuide/FileCheck.rst
+++ b/llvm/docs/CommandGuide/FileCheck.rst
@@ -110,14 +110,6 @@ and from the command line.
   -verify``. With this option FileCheck will verify that input does not contain
   warnings not covered by any ``CHECK:`` patterns.
 
-.. option:: --
diff  <value>
-
-  Controls how mismatches between the check patterns and the input are
-  reported. If ``--
diff `` is specified without a value, it defaults to ``uni
diff ``.
-
-  * ``none`` – Use the standard FileCheck diagnostic messages.
-  * ``uni
diff `` – Display mismatches using a unified 
diff  format.
-
 .. option:: --dump-input <value>
 
   Dump input to stderr, adding annotations representing currently enabled

diff  --git a/llvm/include/llvm/FileCheck/FileCheck.h b/llvm/include/llvm/FileCheck/FileCheck.h
index 7896a942a3466..b44ed8ed3f839 100644
--- a/llvm/include/llvm/FileCheck/FileCheck.h
+++ b/llvm/include/llvm/FileCheck/FileCheck.h
@@ -27,9 +27,6 @@ class MemoryBuffer;
 class SourceMgr;
 template <typename T> class SmallVectorImpl;
 
-// Diff the output on failures.
-enum DiffFormatType { None, Unified };
-
 /// Contains info about various FileCheck options.
 struct FileCheckRequest {
   std::vector<StringRef> CheckPrefixes;
@@ -46,7 +43,6 @@ struct FileCheckRequest {
   bool AllowDeprecatedDagOverlap = false;
   bool Verbose = false;
   bool VerboseVerbose = false;
-  DiffFormatType DiffFormat = DiffFormatType::None;
 };
 
 namespace Check {

diff  --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp
index 307be0b6e2faf..d50e5d9cb088b 100644
--- a/llvm/lib/FileCheck/FileCheck.cpp
+++ b/llvm/lib/FileCheck/FileCheck.cpp
@@ -20,7 +20,6 @@
 #include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/FormatVariadic.h"
-#include "llvm/Support/WithColor.h"
 #include <cstdint>
 #include <list>
 #include <set>
@@ -1262,8 +1261,7 @@ unsigned Pattern::computeMatchDistance(StringRef Buffer) const {
 void Pattern::printSubstitutions(const SourceMgr &SM, StringRef Buffer,
                                  SMRange Range,
                                  FileCheckDiag::MatchType MatchTy,
-                                 std::vector<FileCheckDiag> *Diags,
-                                 const FileCheckRequest &Req) const {
+                                 std::vector<FileCheckDiag> *Diags) const {
   // Print what we know about substitutions.
   if (!Substitutions.empty()) {
     for (const auto &Substitution : Substitutions) {
@@ -1289,9 +1287,8 @@ void Pattern::printSubstitutions(const SourceMgr &SM, StringRef Buffer,
       if (Diags)
         Diags->emplace_back(SM, CheckTy, getLoc(), MatchTy,
                             SMRange(Range.Start, Range.Start), OS.str());
-      else if (Req.DiffFormat == DiffFormatType::None) {
+      else
         SM.PrintMessage(Range.Start, SourceMgr::DK_Note, OS.str());
-      }
     }
   }
 }
@@ -1371,8 +1368,7 @@ static SMRange ProcessMatchResult(FileCheckDiag::MatchType MatchTy,
 }
 
 void Pattern::printFuzzyMatch(const SourceMgr &SM, StringRef Buffer,
-                              std::vector<FileCheckDiag> *Diags,
-                              const FileCheckRequest &Req) const {
+                              std::vector<FileCheckDiag> *Diags) const {
   // Attempt to find the closest/best fuzzy match.  Usually an error happens
   // because some string in the output didn't exactly match. In these cases, we
   // would like to show the user a best guess at what "should have" matched, to
@@ -1415,9 +1411,8 @@ void Pattern::printFuzzyMatch(const SourceMgr &SM, StringRef Buffer,
     SMRange MatchRange =
         ProcessMatchResult(FileCheckDiag::MatchFuzzy, SM, getLoc(),
                            getCheckTy(), Buffer, Best, 0, Diags);
-    if (Req.DiffFormat == DiffFormatType::None)
-      SM.PrintMessage(MatchRange.Start, SourceMgr::DK_Note,
-                      "possible intended match here");
+    SM.PrintMessage(MatchRange.Start, SourceMgr::DK_Note,
+                    "possible intended match here");
 
     // FIXME: If we wanted to be really friendly we would show why the match
     // failed, as it can be hard to spot simple one character 
diff erences.
@@ -2062,7 +2057,7 @@ static Error printMatch(bool ExpectedMatch, const SourceMgr &SM,
                                           Buffer, MatchResult.TheMatch->Pos,
                                           MatchResult.TheMatch->Len, Diags);
   if (Diags) {
-    Pat.printSubstitutions(SM, Buffer, MatchRange, MatchTy, Diags, Req);
+    Pat.printSubstitutions(SM, Buffer, MatchRange, MatchTy, Diags);
     Pat.printVariableDefs(SM, MatchTy, Diags);
   }
   if (!PrintDiag) {
@@ -2083,7 +2078,7 @@ static Error printMatch(bool ExpectedMatch, const SourceMgr &SM,
                   {MatchRange});
 
   // Print additional information, which can be useful even if there are errors.
-  Pat.printSubstitutions(SM, Buffer, MatchRange, MatchTy, nullptr, Req);
+  Pat.printSubstitutions(SM, Buffer, MatchRange, MatchTy, nullptr);
   Pat.printVariableDefs(SM, MatchTy, nullptr);
 
   // Print errors and add them to Diags.  We report these errors after the match
@@ -2107,7 +2102,7 @@ static Error printMatch(bool ExpectedMatch, const SourceMgr &SM,
 static Error printNoMatch(bool ExpectedMatch, const SourceMgr &SM,
                           StringRef Prefix, SMLoc Loc, const Pattern &Pat,
                           int MatchedCount, StringRef Buffer, Error MatchError,
-                          bool VerboseVerbose, const FileCheckRequest &Req,
+                          bool VerboseVerbose,
                           std::vector<FileCheckDiag> *Diags) {
   // Print any pattern errors, and record them to be added to Diags later.
   bool HasError = ExpectedMatch;
@@ -2153,7 +2148,7 @@ static Error printNoMatch(bool ExpectedMatch, const SourceMgr &SM,
     for (StringRef ErrorMsg : ErrorMsgs)
       Diags->emplace_back(SM, Pat.getCheckTy(), Loc, MatchTy, NoteRange,
                           ErrorMsg);
-    Pat.printSubstitutions(SM, Buffer, SearchRange, MatchTy, Diags, Req);
+    Pat.printSubstitutions(SM, Buffer, SearchRange, MatchTy, Diags);
   }
   if (!PrintDiag) {
     assert(!HasError && "expected to report more diagnostics for error");
@@ -2170,20 +2165,18 @@ static Error printNoMatch(bool ExpectedMatch, const SourceMgr &SM,
     if (Pat.getCount() > 1)
       Message +=
           formatv(" ({0} out of {1})", MatchedCount, Pat.getCount()).str();
-    if (Req.DiffFormat == DiffFormatType::None) {
-      SM.PrintMessage(
-          Loc, ExpectedMatch ? SourceMgr::DK_Error : SourceMgr::DK_Remark,
-          Message);
-      SM.PrintMessage(SearchRange.Start, SourceMgr::DK_Note,
-                      "scanning from here");
-    }
+    SM.PrintMessage(Loc,
+                    ExpectedMatch ? SourceMgr::DK_Error : SourceMgr::DK_Remark,
+                    Message);
+    SM.PrintMessage(SearchRange.Start, SourceMgr::DK_Note,
+                    "scanning from here");
   }
 
   // Print additional information, which can be useful even after a pattern
   // error.
-  Pat.printSubstitutions(SM, Buffer, SearchRange, MatchTy, nullptr, Req);
+  Pat.printSubstitutions(SM, Buffer, SearchRange, MatchTy, nullptr);
   if (ExpectedMatch)
-    Pat.printFuzzyMatch(SM, Buffer, Diags, Req);
+    Pat.printFuzzyMatch(SM, Buffer, Diags);
   return ErrorReported::reportedOrSuccess(HasError);
 }
 
@@ -2199,7 +2192,7 @@ static Error reportMatchResult(bool ExpectedMatch, const SourceMgr &SM,
     return printMatch(ExpectedMatch, SM, Prefix, Loc, Pat, MatchedCount, Buffer,
                       std::move(MatchResult), Req, Diags);
   return printNoMatch(ExpectedMatch, SM, Prefix, Loc, Pat, MatchedCount, Buffer,
-                      std::move(MatchResult.TheError), Req.VerboseVerbose, Req,
+                      std::move(MatchResult.TheError), Req.VerboseVerbose,
                       Diags);
 }
 
@@ -2282,7 +2275,7 @@ size_t FileCheckString::Check(const SourceMgr &SM, StringRef Buffer,
 
     // If this check is a "CHECK-NEXT", verify that the previous match was on
     // the previous line (i.e. that there is one newline between them).
-    if (CheckNext(SM, SkippedRegion, Req)) {
+    if (CheckNext(SM, SkippedRegion)) {
       ProcessMatchResult(FileCheckDiag::MatchFoundButWrongLine, SM, Loc,
                          Pat.getCheckTy(), MatchBuffer, MatchPos, MatchLen,
                          Diags, Req.Verbose);
@@ -2307,8 +2300,7 @@ size_t FileCheckString::Check(const SourceMgr &SM, StringRef Buffer,
   return FirstMatchPos;
 }
 
-bool FileCheckString::CheckNext(const SourceMgr &SM, StringRef Buffer,
-                                const FileCheckRequest &Req) const {
+bool FileCheckString::CheckNext(const SourceMgr &SM, StringRef Buffer) const {
   if (Pat.getCheckTy() != Check::CheckNext &&
       Pat.getCheckTy() != Check::CheckEmpty)
     return false;
@@ -2320,7 +2312,8 @@ bool FileCheckString::CheckNext(const SourceMgr &SM, StringRef Buffer,
   // Count the number of newlines between the previous match and this one.
   const char *FirstNewLine = nullptr;
   unsigned NumNewLines = CountNumNewlinesBetween(Buffer, FirstNewLine);
-  if (NumNewLines == 0 && Req.DiffFormat == DiffFormatType::None) {
+
+  if (NumNewLines == 0) {
     SM.PrintMessage(Loc, SourceMgr::DK_Error,
                     CheckName + ": is on the same line as previous match");
     SM.PrintMessage(SMLoc::getFromPointer(Buffer.end()), SourceMgr::DK_Note,
@@ -2330,7 +2323,7 @@ bool FileCheckString::CheckNext(const SourceMgr &SM, StringRef Buffer,
     return true;
   }
 
-  if (NumNewLines != 1 && Req.DiffFormat == DiffFormatType::None) {
+  if (NumNewLines != 1) {
     SM.PrintMessage(Loc, SourceMgr::DK_Error,
                     CheckName +
                         ": is not on the line after the previous match");
@@ -2731,168 +2724,9 @@ void FileCheckPatternContext::clearLocalVars() {
     GlobalNumericVariableTable.erase(Var);
 }
 
-struct DiffContext {
-  StringRef Line;
-  StringRef LineBefore;
-  StringRef LineAfter;
-};
-
-// Provides the "surrounding context" for 
diff  output.
-static DiffContext getDiffContext(SourceMgr &SM, unsigned LineNo,
-                                  unsigned BufID) {
-  const MemoryBuffer *Buffer = SM.getMemoryBuffer(BufID);
-  StringRef BufText = Buffer->getBuffer();
-
-  auto getLineText = [&](unsigned L) -> StringRef {
-    if (L == 0)
-      return "";
-
-    SMLoc LineLoc = SM.FindLocForLineAndColumn(BufID, L, 1);
-    if (!LineLoc.isValid())
-      return "";
-
-    StringRef FromLineStart(LineLoc.getPointer(),
-                            BufText.end() - LineLoc.getPointer());
-    return FromLineStart
-        .take_while([](char C) { return C != '\n' && C != '\r'; })
-        .trim();
-  };
-
-  return {getLineText(LineNo), getLineText(LineNo - 1),
-          getLineText(LineNo + 1)};
-}
-
-// Renders a diagnostic 
diff  via llvm::errs().
-static void renderDiff(unsigned ExpectedLineNo, unsigned ActualLineNo,
-                       StringRef ExpectedLine, StringRef ActualLine,
-                       const DiffContext &Ctx) {
-  auto &OS = errs();
-
-  // Header
-  OS.changeColor(raw_ostream::CYAN);
-  OS << "@@ -" << ExpectedLineNo << " +" << ActualLineNo << " @@\n";
-  OS.resetColor();
-
-  // Before Context
-  if (!Ctx.LineBefore.empty()) {
-    OS << " " << Ctx.LineBefore << "\n";
-  }
-
-  // Mismatch
-  OS.changeColor(raw_ostream::RED);
-  OS << "-" << ExpectedLine << "\n";
-
-  OS.changeColor(raw_ostream::GREEN);
-  OS << "+" << ActualLine.ltrim() << "\n";
-  OS.resetColor();
-
-  // After Context
-  if (!Ctx.LineAfter.empty()) {
-    OS << " " << Ctx.LineAfter << "\n";
-  }
-}
-
-static bool printDiff(const FileCheckString &CheckStr, StringRef ActualLine,
-                      SourceMgr &SM, std::vector<FileCheckDiag> *Diags,
-                      unsigned OverwriteActualLine = 0) {
-  SMLoc PatternLoc = CheckStr.Pat.getLoc();
-  unsigned ExpectedLineNo = SM.getLineAndColumn(PatternLoc).first;
-  const char *PatPtr = PatternLoc.getPointer();
-  StringRef ExpectedLine = StringRef(PatPtr).split('\n').first.rtrim();
-
-  // Resolve the Actual (Input) line number.
-  // Priority: 1. OverwriteActualLine (Found via Fuzzy match)
-  //           2. Direct pointer resolution via SourceMgr.
-  SMLoc InputLoc = SMLoc::getFromPointer(ActualLine.data());
-
-  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 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--;
-
-  unsigned BufID = SM.FindBufferContainingLoc(InputLoc);
-  DiffContext Context = getDiffContext(SM, ActualLineNo, BufID);
-
-  renderDiff(ExpectedLineNo, ActualLineNo, ExpectedLine, ActualLine, Context);
-
-  errs() << '\n';
-  return true;
-}
-
-// Report the mismatch on the current line and advance to the next line.
-static bool handleDiffFailure(const FileCheckString &CheckStr,
-                              StringRef &CheckRegion, SourceMgr &SM,
-                              std::vector<FileCheckDiag> *Diags,
-                              raw_ostream &OS, bool &HeaderPrinted,
-                              unsigned &TotalMismatches) {
-  // Print headers once per CheckRegion.
-  if (!HeaderPrinted) {
-    StringRef CheckFile =
-        SM.getMemoryBuffer(SM.getMainFileID())->getBufferIdentifier();
-    unsigned InputBufID =
-        SM.FindBufferContainingLoc(SMLoc::getFromPointer(CheckRegion.data()));
-    StringRef InputFile = SM.getMemoryBuffer(InputBufID)->getBufferIdentifier();
-
-    OS.changeColor(raw_ostream::WHITE, true);
-    OS << "--- " << CheckFile << "\n";
-    OS << "+++ " << InputFile << "\n";
-    OS.resetColor();
-    HeaderPrinted = true;
-  }
-
-  size_t EOL = CheckRegion.find('\n');
-
-  SMLoc CurrentLoc = SMLoc::getFromPointer(CheckRegion.data());
-  StringRef TargetLine;
-  unsigned TargetLineNo = 0;
-
-  // Check if the existing diagnostics already found a fuzzy match.
-  if (Diags) {
-    for (const auto &D : llvm::reverse(*Diags)) {
-      if (D.CheckLoc == CheckStr.Pat.getLoc() &&
-          D.MatchTy == FileCheckDiag::MatchFuzzy) {
-        TargetLineNo = D.InputStartLine;
-        // Get the actual text of that fuzzy match from the SourceMgr
-        unsigned BufID = SM.FindBufferContainingLoc(CurrentLoc);
-        SMLoc FuzzyLoc = SM.FindLocForLineAndColumn(BufID, TargetLineNo, 1);
-        TargetLine = StringRef(FuzzyLoc.getPointer()).split('\n').first;
-        break;
-      }
-    }
-  }
-
-  // If no fuzzy match was found by the engine, just use the next line.
-  if (TargetLine.empty()) {
-    TargetLine = CheckRegion.substr(0, EOL);
-    TargetLineNo = SM.getLineAndColumn(CurrentLoc).first;
-  }
-
-  printDiff(CheckStr, TargetLine, SM, Diags, TargetLineNo);
-  TotalMismatches++;
-
-  // Advance CheckRegion past the current line to recover for the next CHECK.
-  if (EOL != StringRef::npos)
-    CheckRegion = CheckRegion.substr(EOL + 1);
-  else
-    CheckRegion = "";
-
-  return true;
-}
-
 bool FileCheck::checkInput(SourceMgr &SM, StringRef Buffer,
                            std::vector<FileCheckDiag> *Diags) {
   bool ChecksFailed = false;
-  unsigned TotalMismatches = 0;
-  bool HeaderPrinted = false;
-  bool IsDiffFormat = Req.DiffFormat != DiffFormatType::None;
-  auto &OS = errs();
 
   unsigned i = 0, j = 0, e = CheckStrings.size();
   while (true) {
@@ -2925,40 +2759,16 @@ 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];
 
-      bool IsStrict = CheckStr.Pat.getCheckTy() == Check::CheckNext ||
-                      CheckStr.Pat.getCheckTy() == Check::CheckEmpty;
-
+      // Check each string within the scanned region, including a second check
+      // of any final CHECK-LABEL (to verify CHECK-NOT and CHECK-DAG)
       size_t MatchLen = 0;
       size_t MatchPos =
           CheckStr.Check(SM, CheckRegion, false, MatchLen, Req, Diags);
 
-      // Handle failure
       if (MatchPos == StringRef::npos) {
-        if (IsDiffFormat) {
-          handleDiffFailure(CheckStr, CheckRegion, SM, Diags, OS, HeaderPrinted,
-                            TotalMismatches);
-        }
-        ChecksFailed = true;
-        i = j;
-        break;
-      }
-      // In Diff Mode, while doing strick checking even if we found a match
-      // later i.e. MatchPos > 0, we must stop processing this block and print
-      // the gap as mismatch.
-      if (IsDiffFormat && IsStrict && MatchPos > 0) {
-        // Create a temporary view that starts with next new line.
-        size_t CurrentLineEnd = CheckRegion.find_first_of("\n\r");
-        StringRef NextLineRegion =
-            (CurrentLineEnd != StringRef::npos)
-                ? CheckRegion.drop_front(CurrentLineEnd + 1)
-                : CheckRegion;
-        handleDiffFailure(CheckStr, NextLineRegion, SM, Diags, OS,
-                          HeaderPrinted, TotalMismatches);
         ChecksFailed = true;
         i = j;
         break;
@@ -2971,12 +2781,6 @@ bool FileCheck::checkInput(SourceMgr &SM, StringRef Buffer,
       break;
   }
 
-  if (Req.DiffFormat != DiffFormatType::None && TotalMismatches > 0) {
-    OS.changeColor(llvm::raw_ostream::YELLOW, true);
-    OS << "FileCheck: Found " << TotalMismatches << " unique textual mismatch"
-       << (TotalMismatches > 1 ? "es." : ".") << "\n";
-    OS.resetColor();
-  }
   // Success if no checks failed.
   return !ChecksFailed;
 }

diff  --git a/llvm/lib/FileCheck/FileCheckImpl.h b/llvm/lib/FileCheck/FileCheckImpl.h
index 58a03d280b658..5851cfc4b5d5c 100644
--- a/llvm/lib/FileCheck/FileCheckImpl.h
+++ b/llvm/lib/FileCheck/FileCheckImpl.h
@@ -734,11 +734,9 @@ class Pattern {
   /// Prints the value of successful substitutions.
   void printSubstitutions(const SourceMgr &SM, StringRef Buffer,
                           SMRange MatchRange, FileCheckDiag::MatchType MatchTy,
-                          std::vector<FileCheckDiag> *Diags,
-                          const FileCheckRequest &Req) const;
+                          std::vector<FileCheckDiag> *Diags) const;
   void printFuzzyMatch(const SourceMgr &SM, StringRef Buffer,
-                       std::vector<FileCheckDiag> *Diags,
-                       const FileCheckRequest &Req) const;
+                       std::vector<FileCheckDiag> *Diags) const;
 
   bool hasVariable() const {
     return !(Substitutions.empty() && VariableDefs.empty());
@@ -876,8 +874,7 @@ struct FileCheckString {
 
   /// Verifies that there is a single line in the given \p Buffer. Errors are
   /// reported against \p SM.
-  bool CheckNext(const SourceMgr &SM, StringRef Buffer,
-                 const FileCheckRequest &Req) const;
+  bool CheckNext(const SourceMgr &SM, StringRef Buffer) const;
   /// Verifies that there is no newline in the given \p Buffer. Errors are
   /// reported against \p SM.
   bool CheckSame(const SourceMgr &SM, StringRef Buffer) const;

diff  --git a/llvm/test/FileCheck/
diff /
diff -blank-stray.txt b/llvm/test/FileCheck/
diff /
diff -blank-stray.txt
deleted file mode 100644
index 6065c74b66f40..0000000000000
--- a/llvm/test/FileCheck/
diff /
diff -blank-stray.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-; RUN: split-file %s %t
-; RUN: %ProtectFileCheckOutput not FileCheck %t/check.txt --input-file=%t/input.txt --
diff =uni
diff  2>&1 \
-; RUN:   | FileCheck %s --check-prefix=DIFF
-
-;--- input.txt
-LINE1
-
-
-
-LINE2
-
-;--- check.txt
-; CHECK:      LINE1
-; CHECK-NEXT: LINE2
-
-; DIFF:      @@ -[[#]] +[[#]] @@
-; DIFF-NEXT: -LINE2
-; DIFF-NEXT: +

diff  --git a/llvm/test/FileCheck/
diff /
diff -empty-check.txt b/llvm/test/FileCheck/
diff /
diff -empty-check.txt
deleted file mode 100644
index bba0b9993627d..0000000000000
--- a/llvm/test/FileCheck/
diff /
diff -empty-check.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-; RUN: split-file %s %t
-; RUN: %ProtectFileCheckOutput not FileCheck %t/check.txt --input-file=%t/input.txt --
diff =uni
diff  2>&1 \
-; RUN:   | FileCheck %s --check-prefix=DIFF
-
-;--- input.txt
-START_TRANS
-  [LOG] Transaction initiated...
-END_TRANS
-
-;--- check.txt
-; CHECK:       START_TRANS
-; CHECK-EMPTY:
-; CHECK:       END_TRANS
-
-; DIFF:      @@ -[[#]] +[[#]] @@
-; DIFF-NEXT:  START_TRANS
-; DIFF-NEXT:  -
-; DIFF-NEXT:  +[LOG] Transaction initiated...
-; DIFF-NEXT:  END_TRANS

diff  --git a/llvm/test/FileCheck/
diff /
diff -label-boundary.txt b/llvm/test/FileCheck/
diff /
diff -label-boundary.txt
deleted file mode 100644
index cb9595f760149..0000000000000
--- a/llvm/test/FileCheck/
diff /
diff -label-boundary.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-; RUN: split-file %s %t
-; RUN: %ProtectFileCheckOutput not FileCheck %t/check.txt --input-file=%t/input.txt --
diff =uni
diff  2>&1 \
-; RUN:   | FileCheck %s --check-prefix=DIFF
-
-;--- input.txt
-FUNCTION_A
-  BAD_OP
-FUNCTION_B
-  GOOD_OP
-
-;--- check.txt
-; CHECK-LABEL: FUNCTION_A
-; CHECK:         CORRECT_OP
-; CHECK-LABEL: FUNCTION_B
-
-; DIFF:      @@ -[[#]] +[[#]] @@
-; DIFF-NEXT:  FUNCTION_A
-; DIFF-NEXT: -CORRECT_OP
-; DIFF-NEXT: +BAD_OP
-; DIFF-NEXT:  FUNCTION_B

diff  --git a/llvm/test/FileCheck/
diff /
diff -label-fuzzy-match.txt b/llvm/test/FileCheck/
diff /
diff -label-fuzzy-match.txt
deleted file mode 100644
index a04f2e84ac70b..0000000000000
--- a/llvm/test/FileCheck/
diff /
diff -label-fuzzy-match.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-; RUN: split-file %s %t
-; RUN: %ProtectFileCheckOutput not FileCheck %t/check.txt --input-file=%t/input.txt --
diff =uni
diff  2>&1 \
-; RUN:   | FileCheck %s --check-prefix=DIFF
-
-;--- input.txt
-define void @foo() {
-  call void @work_task()
-}
-
-;--- check.txt
-; CHECK-LABEL: define void @foo()
-; CHECK:        call void @work_test()
-
-; DIFF:      @@ -[[#]] +[[#]] @@
-; DIFF:      define void @foo() {
-; DIFF-NEXT: -call void @work_test()
-; DIFF-NEXT: +call void @work_task()
-; DIFF-NEXT:  }

diff  --git a/llvm/test/FileCheck/
diff /
diff -label-next.txt b/llvm/test/FileCheck/
diff /
diff -label-next.txt
deleted file mode 100644
index 240cd14596da1..0000000000000
--- a/llvm/test/FileCheck/
diff /
diff -label-next.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-; RUN: split-file %s %t
-; RUN: %ProtectFileCheckOutput not FileCheck %t/check.txt --input-file=%t/input.txt --
diff =uni
diff  2>&1 \
-; RUN:   | FileCheck %s --check-prefix=DIFF
-
-;--- input.txt
-FUNC_A
-  mov r0, #1
-FUNC_B
-  mov r1, #2
-
-;--- check.txt
-; CHECK-LABEL: FUNC_A
-; CHECK-NEXT:  mov r0, #5
-; CHECK-LABEL: FUNC_B
-
-; DIFF:      @@ -[[#]] +[[#]] @@
-; DIFF-NEXT:  FUNC_A
-; DIFF-NEXT: -mov r0, #5
-; DIFF-NEXT: +mov r0, #1

diff  --git a/llvm/test/FileCheck/
diff /
diff -multi-block.txt b/llvm/test/FileCheck/
diff /
diff -multi-block.txt
deleted file mode 100644
index 2a53fb6fdd9c4..0000000000000
--- a/llvm/test/FileCheck/
diff /
diff -multi-block.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-; RUN: split-file %s %t
-; RUN: %ProtectFileCheckOutput not FileCheck %t/check.txt --input-file=%t/input.txt --
diff =uni
diff  2>&1 \
-; RUN:   | FileCheck %s --check-prefix=DIFF
-
-;--- input.txt
-define void @func_a() {
-  %result = add i32 %1, %2
-  ret void
-}
-define void @func_b() {
-  %val = load i32, ptr %p
-  store i32 %val, ptr %q
-  ret void
-}
-
-;--- check.txt
-; CHECK-LABEL: define void @func_a()
-; CHECK-NEXT:  %result = mul i32 %1, %2
-; CHECK-LABEL: define void @func_b()
-; CHECK-NEXT:  store i32 %val, ptr %q
-
-; DIFF:      --- {{.*}}check.txt
-; DIFF-NEXT: +++ {{.*}}input.txt
-; DIFF:      @@ -[[#]] +[[#]] @@
-; DIFF-NEXT:  define void @func_a() {
-; DIFF-NEXT: -%result = mul i32 %1, %2
-; DIFF-NEXT: +%result = add i32 %1, %2
-; DIFF:      @@ -[[#]] +[[#]] @@
-; DIFF-NEXT:  define void @func_b() {
-; DIFF-NEXT: -store i32 %val, ptr %q
-; DIFF-NEXT: +%val = load i32, ptr %p
-; DIFF:      FileCheck: Found 2 unique textual mismatches.

diff  --git a/llvm/test/FileCheck/
diff /
diff -multi-failres.txt b/llvm/test/FileCheck/
diff /
diff -multi-failres.txt
deleted file mode 100644
index 85408544e2073..0000000000000
--- a/llvm/test/FileCheck/
diff /
diff -multi-failres.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-; RUN: split-file %s %t
-; RUN: %ProtectFileCheckOutput not FileCheck %t/check.txt --input-file=%t/input.txt --
diff =uni
diff  2>&1 \
-; RUN:   | FileCheck %s --check-prefix=DIFF
-
-;--- input.txt
-LINE1
-BAD_LINE
-LINE3
-LINE4
-BAD_LINE
-LINE6
-
-;--- check.txt
-; CHECK: LINE1
-; CHECK: LINE2
-; CHECK: LINE3
-; CHECK: LINE4
-; CHECK: LINE5
-; CHECK: LINE6
-
-; DIFF:      @@ -[[#]] +[[#]] @@
-; DIFF-NEXT:  LINE1
-; DIFF-NEXT: -LINE2
-; DIFF-NEXT: +BAD_LINE
-; DIFF-NEXT:  LINE3

diff  --git a/llvm/test/FileCheck/
diff /
diff -multi-mismatch.txt b/llvm/test/FileCheck/
diff /
diff -multi-mismatch.txt
deleted file mode 100644
index ace3d7cd093bd..0000000000000
--- a/llvm/test/FileCheck/
diff /
diff -multi-mismatch.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-; RUN: split-file %s %t
-; RUN: %ProtectFileCheckOutput not FileCheck %t/check.txt --input-file=%t/input.txt --
diff =uni
diff  2>&1 \
-; RUN:   | FileCheck %s --check-prefix=DIFF
-
-;--- input.txt
-BLOCK1_FAIL
-MATCH 1
-MATCH 2
-MATCH 3
-MATCH 4
-MATCH 5
-MATCH 6
-MATCH 7
-BLOCK2_FAIL
-
-;--- check.txt
-; CHECK: BLOCK1_PASS
-; CHECK: MATCH 1
-; CHECK: MATCH 2
-; CHECK: MATCH 3
-; CHECK: MATCH 4
-; CHECK: MATCH 5
-; CHECK: MATCH 6
-; CHECK: MATCH 7
-; CHECK: BLOCK2_PASS
-
-; First Hunk
-; DIFF:      @@ -[[#]] +[[#]] @@
-; DIFF-NEXT: -BLOCK1_PASS
-; DIFF-NEXT: +BLOCK1_FAIL
-; DIFF-NEXT:  MATCH 1
-
-; FIXME: We should continue to report failure even after first.
-; Second Hunk
-; DIFF-NOT: -BLOCK2_PASS
-; DIFF-NOT: +BLOCK2_FAIL

diff  --git a/llvm/test/FileCheck/
diff /
diff -next-stray-line.txt b/llvm/test/FileCheck/
diff /
diff -next-stray-line.txt
deleted file mode 100644
index dd19a0e2c6dd2..0000000000000
--- a/llvm/test/FileCheck/
diff /
diff -next-stray-line.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-; RUN: split-file %s %t
-; RUN: %ProtectFileCheckOutput not FileCheck %t/check.txt --input-file=%t/input.txt --
diff =uni
diff  2>&1 \
-; RUN:   | FileCheck %s --check-prefix=DIFF
-
-;--- input.txt
-LINE1
-STRAY
-LINE2
-
-;--- check.txt
-; CHECK:      LINE1
-; CHECK-NEXT: LINE2
-
-; DIFF:      @@ -[[#]] +[[#]] @@
-; DIFF-NEXT:  LINE1
-; DIFF-NEXT: -LINE2
-; DIFF-NEXT: +STRAY
-; DIFF-NEXT:  LINE2

diff  --git a/llvm/test/FileCheck/
diff /
diff -regex-escaping.txt b/llvm/test/FileCheck/
diff /
diff -regex-escaping.txt
deleted file mode 100644
index 8f3ebc6163f04..0000000000000
--- a/llvm/test/FileCheck/
diff /
diff -regex-escaping.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-; RUN: split-file %s %t
-; RUN: %ProtectFileCheckOutput not FileCheck %t/check.txt --input-file=%t/input.txt --
diff =uni
diff  2>&1 \
-; RUN:   | FileCheck %s --check-prefix=DIFF
-
-;--- input.txt
-hello world
-
-;--- check.txt
-; CHECK: hello {{U}}niverse
-
-; DIFF:      @@ -[[#]] +1 @@
-; DIFF-NEXT: -hello {{[{][{]U[}][}]}}niverse
-; DIFF-NEXT: +hello world

diff  --git a/llvm/test/FileCheck/
diff /
diff -resync-after-noise.txt b/llvm/test/FileCheck/
diff /
diff -resync-after-noise.txt
deleted file mode 100644
index 854ee188b2944..0000000000000
--- a/llvm/test/FileCheck/
diff /
diff -resync-after-noise.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-; RUN: split-file %s %t
-; RUN: %ProtectFileCheckOutput not FileCheck %t/check.txt --input-file=%t/input.txt --
diff =uni
diff  2>&1 \
-; RUN:   | FileCheck %s --check-prefix=DIFF
-
-;--- input.txt
-HEADER
-Noise1
-Noise2
-Noise3
-Noise4
-TARGET_BLOCK
-Stray1
-Stray2
-MATCH_ME
-NEXT_LINE
-Noise5
-Noise6
-
-;--- check.txt
-; CHECK-LABEL: HEADER
-; CHECK:       TARGET_BLOCK
-; CHECK:       MATCH_ME
-; CHECK-NEXT: WRONG_NEXT
-; CHECK:       END_OF_FUNCTION
-
-; DIFF:      @@ -[[#]] +[[#]] @@
-; DIFF-NEXT:  MATCH_ME
-; DIFF-NEXT: -WRONG_NEXT
-; DIFF-NEXT: +NEXT_LINE
-; DIFF-NEXT:  Noise5

diff  --git a/llvm/test/FileCheck/
diff /
diff -resync-high-noise.txt b/llvm/test/FileCheck/
diff /
diff -resync-high-noise.txt
deleted file mode 100644
index d7ecfe48d3b78..0000000000000
--- a/llvm/test/FileCheck/
diff /
diff -resync-high-noise.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-; RUN: split-file %s %t
-; RUN: %ProtectFileCheckOutput not FileCheck %t/check.txt --input-file=%t/input.txt --
diff =uni
diff  2>&1 \
-; RUN:   | FileCheck %s --check-prefix=DIFF
-
-;--- input.txt
-START
-Noise1
-Noise2
-Noise3
-Noise4
-TARGET
-END
-
-;--- check.txt
-; CHECK: START
-; CHECK-NEXT: TARGET
-; CHECK: END
-
-; DIFF:      @@ -[[#]] +[[#]] @@
-; DIFF-NEXT:  START
-; DIFF-NEXT: -TARGET
-; DIFF-NEXT: +Noise1
-; DIFF-NEXT:  Noise2

diff  --git a/llvm/test/FileCheck/
diff /
diff -skipped-expected.txt b/llvm/test/FileCheck/
diff /
diff -skipped-expected.txt
deleted file mode 100644
index f8b4d2f303bb5..0000000000000
--- a/llvm/test/FileCheck/
diff /
diff -skipped-expected.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-; RUN: split-file %s %t
-; RUN: %ProtectFileCheckOutput not FileCheck %t/check.txt --input-file=%t/input.txt --
diff =uni
diff  2>&1 \
-; RUN:   | FileCheck %s --check-prefix=DIFF
-
-;--- input.txt
-ALPHA
-GAMMA
-
-;--- check.txt
-; CHECK: ALPHA
-; CHECK: BETA
-; CHECK: GAMMA
-
-; DIFF:      @@ -[[#]] +[[#]] @@
-; DIFF-NEXT:  ALPHA
-; DIFF-NEXT: -BETA
-; DIFF-NEXT: +GAMMA

diff  --git a/llvm/test/FileCheck/
diff /
diff -stress-large-input.txt b/llvm/test/FileCheck/
diff /
diff -stress-large-input.txt
deleted file mode 100644
index 68488d4b39a13..0000000000000
--- a/llvm/test/FileCheck/
diff /
diff -stress-large-input.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-; RUN: split-file %s %t
-; RUN: %python -c "for i in range(5000): print(f'DATA_{i}')" > %t/input.txt
-; RUN: %ProtectFileCheckOutput not FileCheck %t/check.txt --input-file=%t/input.txt --
diff =uni
diff  2>&1 \
-; RUN:   | FileCheck %s --check-prefix=DIFF
-
-;--- check.txt
-; CHECK: DATA_0
-; CHECK: DATA_2500_WRONG
-; CHECK: DATA_4999
-
-; DIFF:      @@ -2 +21 @@
-; DIFF-NEXT:  DATA_19
-; DIFF-NEXT: -DATA_2500_WRONG
-; DIFF-NEXT: +DATA_20
-; DIFF-NEXT:  DATA_21

diff  --git a/llvm/utils/FileCheck/FileCheck.cpp b/llvm/utils/FileCheck/FileCheck.cpp
index f200e94becaa2..12fdbfd45279d 100644
--- a/llvm/utils/FileCheck/FileCheck.cpp
+++ b/llvm/utils/FileCheck/FileCheck.cpp
@@ -113,13 +113,6 @@ static cl::opt<bool> VerboseVerbose(
              "issues, or add it to the input dump if enabled.  Implies\n"
              "-v.\n"));
 
-static cl::opt<DiffFormatType> DiffFormat(
-    "
diff ", cl::desc("Show mismatches using a 
diff -style format.\n"),
-    cl::ValueOptional,
-    cl::values(clEnumValN(None, "none", "Standard FileCheck diagnostics"),
-               clEnumValN(Unified, "uni
diff ", "Outputs a Unified 
diff "),
-               clEnumValN(Unified, "", "")));
-
 // The order of DumpInputValue members affects their precedence, as documented
 // for -dump-input below.
 enum DumpInputValue {
@@ -794,7 +787,6 @@ int main(int argc, char **argv) {
   if (GlobalDefineError)
     return 2;
 
-  Req.DiffFormat = DiffFormat;
   Req.AllowEmptyInput = AllowEmptyInput;
   Req.AllowUnusedPrefixes = AllowUnusedPrefixes;
   Req.EnableVarScope = EnableVarScope;
@@ -866,9 +858,8 @@ int main(int argc, char **argv) {
                                DumpInput == DumpInputNever ? nullptr : &Diags)
                      ? EXIT_SUCCESS
                      : 1;
-  if ((DumpInput == DumpInputAlways ||
-       (ExitCode == 1 && DumpInput == DumpInputFail)) &&
-      Req.DiffFormat == DiffFormatType::None) {
+  if (DumpInput == DumpInputAlways ||
+      (ExitCode == 1 && DumpInput == DumpInputFail)) {
     errs() << "\n"
            << "Input file: " << InputFilename << "\n"
            << "Check file: " << CheckFilename << "\n"


        


More information about the llvm-commits mailing list