summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/Support/FileCheck.h5
-rw-r--r--llvm/lib/Support/FileCheck.cpp2
-rw-r--r--llvm/test/FileCheck/dump-input-annotations.txt13
-rw-r--r--llvm/utils/FileCheck/FileCheck.cpp8
4 files changed, 22 insertions, 6 deletions
diff --git a/llvm/include/llvm/Support/FileCheck.h b/llvm/include/llvm/Support/FileCheck.h
index 54820bec1cb..c79e9cb683e 100644
--- a/llvm/include/llvm/Support/FileCheck.h
+++ b/llvm/include/llvm/Support/FileCheck.h
@@ -160,7 +160,8 @@ struct FileCheckDiag {
/// 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.
enum MatchType {
// TODO: More members will appear with later patches in this series.
/// Indicates the final match for an expected pattern.
@@ -170,6 +171,8 @@ struct FileCheckDiag {
/// Indicates the final match for an expected pattern, but the match is on
/// the wrong line.
MatchFinalButWrongLine,
+ /// Indicates a discarded match for an expected pattern.
+ MatchDiscard,
/// Indicates no match for an expected pattern.
MatchNoneButExpected,
/// Indicates a possible intended match because there's no perfect match.
diff --git a/llvm/lib/Support/FileCheck.cpp b/llvm/lib/Support/FileCheck.cpp
index 068fa96b9fa..52da7e9865d 100644
--- a/llvm/lib/Support/FileCheck.cpp
+++ b/llvm/lib/Support/FileCheck.cpp
@@ -1284,7 +1284,7 @@ FileCheckString::CheckDag(const SourceMgr &SM, StringRef Buffer,
"match discarded, overlaps earlier DAG match here",
{OldRange});
if (Diags)
- Diags->pop_back();
+ Diags->rbegin()->MatchTy = FileCheckDiag::MatchDiscard;
}
MatchPos = MI->End;
}
diff --git a/llvm/test/FileCheck/dump-input-annotations.txt b/llvm/test/FileCheck/dump-input-annotations.txt
index 4dc32418e1f..20598809851 100644
--- a/llvm/test/FileCheck/dump-input-annotations.txt
+++ b/llvm/test/FileCheck/dump-input-annotations.txt
@@ -302,7 +302,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.
@@ -319,18 +319,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 !~~ discard: overlaps earlier match
; DAG-NEXT: 2: def
; DAG-V-NEXT: dag:1 ^~~
+; DAG-VV-NEXT: dag:4'0 !~~ discard: overlaps earlier match
; DAG-NEXT: 3: abc
-; DAG-V-NEXT: dag:3 ^~~
-; DAG-NEXT: dag:4 X~~ error: no match found
+; DAG-VQ-NEXT: dag:3 ^~~
+; DAG-VV-NEXT: dag:3'1 ^~~
+; DAG-Q-NEXT: dag:4 X~~ error: no match found
+; DAG-VQ-NEXT: dag:4 X~~ error: no match found
+; DAG-VV-NEXT: dag:4'1 X~~ error: no match found
; DAG-NEXT: >>>>>>
; DAG-NOT: {{.}}
diff --git a/llvm/utils/FileCheck/FileCheck.cpp b/llvm/utils/FileCheck/FileCheck.cpp
index 6248453a754..cde9bb95706 100644
--- a/llvm/utils/FileCheck/FileCheck.cpp
+++ b/llvm/utils/FileCheck/FileCheck.cpp
@@ -150,6 +150,9 @@ static MarkerStyle GetMarker(FileCheckDiag::MatchType MatchTy) {
return MarkerStyle('!', raw_ostream::RED, "error: no match expected");
case FileCheckDiag::MatchFinalButWrongLine:
return MarkerStyle('!', raw_ostream::RED, "error: match on wrong line");
+ case FileCheckDiag::MatchDiscard:
+ return MarkerStyle('!', raw_ostream::CYAN,
+ "discard: overlaps earlier match");
case FileCheckDiag::MatchNoneButExpected:
return MarkerStyle('X', raw_ostream::RED, "error: no match found");
case FileCheckDiag::MatchFuzzy:
@@ -191,10 +194,13 @@ static void DumpInputAnnotationHelp(raw_ostream &OS) {
OS << " marks bad match, such as:\n"
<< " - CHECK-NEXT on same line as previous match (error)\n"
<< " - CHECK-NOT found (error)\n"
+ << " - CHECK-DAG overlapping match (discarded, reported if "
+ << "-vv)\n"
<< " - ";
WithColor(OS, raw_ostream::SAVEDCOLOR, true) << "X~~";
OS << " marks search range when no match is found, such as:\n"
<< " - CHECK-NEXT not found (error)\n"
+ << " - CHECK-DAG not found after discarded matches (error)\n"
<< " - ";
WithColor(OS, raw_ostream::SAVEDCOLOR, true) << "?";
OS << " marks fuzzy match when no match is found\n";
@@ -207,6 +213,8 @@ static void DumpInputAnnotationHelp(raw_ostream &OS) {
OS << ", ";
WithColor(OS, raw_ostream::MAGENTA, true) << "fuzzy match";
OS << ", ";
+ WithColor(OS, raw_ostream::CYAN, true, false) << "discarded match";
+ OS << ", ";
WithColor(OS, raw_ostream::CYAN, true, true) << "unmatched input";
OS << "\n\n"
<< "If you are not seeing color above or in input dumps, try: -color\n";
OpenPOWER on IntegriCloud