Index: llvm/include/llvm/Support/FileCheck.h =================================================================== --- llvm/include/llvm/Support/FileCheck.h +++ llvm/include/llvm/Support/FileCheck.h @@ -161,7 +161,8 @@ /// What kind of match result does this diagnostic describe? /// /// There might be more than one of these for the same directive. For - /// example, there might be a fuzzy match after a fail. + /// example, there might be several discards before either a final or fail, + /// and there might be a fuzzy match after a fail. /// /// We iterate these types, so they must have contiguous values in /// [0, MatchTypeCount). Moreover, keep match types together if they use the @@ -173,6 +174,7 @@ MatchTypeFirst = MatchFinalAndExpected, MatchFinalButExcluded, //< the final match for an excluded pattern MatchFinalButIllegal, //< the final but illegal match for an expected pattern + MatchDiscard, //< a discarded match for an expected pattern MatchNoneButExpected, //< no match for an expected pattern MatchFuzzy, //< a fuzzy match (because no perfect match) MatchTypeCount, Index: llvm/lib/Support/FileCheck.cpp =================================================================== --- llvm/lib/Support/FileCheck.cpp +++ llvm/lib/Support/FileCheck.cpp @@ -1284,7 +1284,7 @@ "match discarded, overlaps earlier DAG match here", {OldRange}); if (Diags) - Diags->pop_back(); + Diags->rbegin()->MatchTy = FileCheckDiag::MatchDiscard; } MatchPos = MI->End; } Index: llvm/test/FileCheck/dump-input-annotations.txt =================================================================== --- llvm/test/FileCheck/dump-input-annotations.txt +++ llvm/test/FileCheck/dump-input-annotations.txt @@ -298,7 +298,7 @@ ; NOT2-NOT: {{.}} ;-------------------------------------------------- -; CHECK-DAG (also: matches in different order than directives) +; CHECK-DAG (also: matches in different order than directives, discarded match) ;-------------------------------------------------- ; Good match, discarded match plus good match, and no match. @@ -315,18 +315,23 @@ ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \ ; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG,DAG-Q ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG,DAG-V +; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG,DAG-V,DAG-VQ ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \ ; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG,DAG-V,DAG-VV ; DAG: <<<<<< ; DAG-NEXT: 1: abc ; DAG-V-NEXT: dag:2 ^~~ +; DAG-VV-NEXT: dag:3'0 !~~ ; DAG-NEXT: 2: def ; DAG-V-NEXT: dag:1 ^~~ +; DAG-VV-NEXT: dag:4'0 !~~ ; DAG-NEXT: 3: abc -; DAG-V-NEXT: dag:3 ^~~ -; DAG-NEXT: dag:4 X~~ +; DAG-VQ-NEXT: dag:3 ^~~ +; DAG-VV-NEXT: dag:3'1 ^~~ +; DAG-Q-NEXT: dag:4 X~~ +; DAG-VQ-NEXT: dag:4 X~~ +; DAG-VV-NEXT: dag:4'1 X~~ ; DAG-NEXT: >>>>>> ; DAG-NOT: {{.}} Index: llvm/utils/FileCheck/FileCheck.cpp =================================================================== --- llvm/utils/FileCheck/FileCheck.cpp +++ llvm/utils/FileCheck/FileCheck.cpp @@ -143,6 +143,11 @@ return MatchTypeStyle('!', true, raw_ostream::RED, MatchTypeStyle::Quiet, "the final but illegal match for an expected " "pattern (e.g., CHECK-NEXT)"); + case FileCheckDiag::MatchDiscard: + return MatchTypeStyle('!', true, raw_ostream::CYAN, + MatchTypeStyle::VerboseVerbose, + "a discarded match for an expected pattern (e.g., " + "CHECK-DAG)"); case FileCheckDiag::MatchNoneButExpected: return MatchTypeStyle('X', true, raw_ostream::RED, MatchTypeStyle::Quiet, "the search range for an unmatched expected " @@ -205,6 +210,10 @@ if (Req.Verbose) { OS << ", "; WithColor(OS, raw_ostream::CYAN, true, true) << "unmatched"; + if (Req.VerboseVerbose) { + OS << ", "; + WithColor(OS, raw_ostream::CYAN, true, false) << "discarded"; + } } OS << ", "; WithColor(OS, raw_ostream::MAGENTA, true) << "fuzzy";