[llvm] r349425 - [FileCheck] Annotate input dump (final tweaks)
Joel E. Denny via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 17 16:03:51 PST 2018
Author: jdenny
Date: Mon Dec 17 16:03:51 2018
New Revision: 349425
URL: http://llvm.org/viewvc/llvm-project?rev=349425&view=rev
Log:
[FileCheck] Annotate input dump (final tweaks)
Apply final suggestions from probinson for this patch series plus a
few more tweaks:
* Improve various docs, for MatchType in particular.
* Rename some members of MatchType. The main problem was that the
term "final match" became a misnomer when CHECK-COUNT-<N> was
created.
* Split InputStartLine, etc. declarations into multiple lines.
Differential Revision: https://reviews.llvm.org/D55738
Reviewed By: probinson
Modified:
llvm/trunk/include/llvm/Support/FileCheck.h
llvm/trunk/lib/Support/FileCheck.cpp
llvm/trunk/test/FileCheck/dump-input-annotations.txt
llvm/trunk/utils/FileCheck/FileCheck.cpp
Modified: llvm/trunk/include/llvm/Support/FileCheck.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/FileCheck.h?rev=349425&r1=349424&r2=349425&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/FileCheck.h (original)
+++ llvm/trunk/include/llvm/Support/FileCheck.h Mon Dec 17 16:03:51 2018
@@ -157,32 +157,46 @@ struct FileCheckDiag {
Check::FileCheckType CheckTy;
/// Where is the FileCheck directive for this diagnostic?
unsigned CheckLine, CheckCol;
- /// What kind of match result does this diagnostic describe?
+ /// What type of match result does this diagnostic describe?
///
- /// There might be more than one of these for the same directive. For
- /// example, there might be several discards before either a final or fail,
- /// and there might be a fuzzy match after a fail.
+ /// A directive's supplied pattern is said to be either expected or excluded
+ /// depending on whether the pattern must have or must not have a match in
+ /// order for the directive to succeed. For example, a CHECK directive's
+ /// pattern is expected, and a CHECK-NOT directive's pattern is excluded.
+ /// All match result types whose names end with "Excluded" are for excluded
+ /// patterns, and all others are for expected patterns.
+ ///
+ /// There might be more than one match result for a single pattern. For
+ /// example, there might be several discarded matches
+ /// (MatchFoundButDiscarded) before either a good match
+ /// (MatchFoundAndExpected) or a failure to match (MatchNoneButExpected),
+ /// and there might be a fuzzy match (MatchFuzzy) after the latter.
enum MatchType {
- // TODO: More members will appear with later patches in this series.
- /// Indicates the final match for an expected pattern.
- MatchFinalAndExpected,
- /// Indicates the final match for an excluded pattern.
- MatchFinalButExcluded,
- /// Indicates the final match for an expected pattern, but the match is on
- /// the wrong line.
- MatchFinalButWrongLine,
+ /// Indicates a good match for an expected pattern.
+ MatchFoundAndExpected,
+ /// Indicates a match for an excluded pattern.
+ MatchFoundButExcluded,
+ /// Indicates a match for an expected pattern, but the match is on the
+ /// wrong line.
+ MatchFoundButWrongLine,
/// Indicates a discarded match for an expected pattern.
- MatchDiscard,
+ MatchFoundButDiscarded,
/// Indicates no match for an excluded pattern.
MatchNoneAndExcluded,
- /// Indicates no match for an expected pattern.
+ /// Indicates no match for an expected pattern, but this might follow good
+ /// matches when multiple matches are expected for the pattern, or it might
+ /// follow discarded matches for the pattern.
MatchNoneButExpected,
- /// Indicates a possible intended match because there's no perfect match.
+ /// Indicates a fuzzy match that serves as a suggestion for the next
+ /// intended match for an expected pattern with too few or no good matches.
MatchFuzzy,
} MatchTy;
- /// The match range if MatchTy is not MatchNoneAndExcluded or
- /// MatchNoneButExpected, or the search range otherwise.
- unsigned InputStartLine, InputStartCol, InputEndLine, InputEndCol;
+ /// The search range if MatchTy is MatchNoneAndExcluded or
+ /// MatchNoneButExpected, or the match range otherwise.
+ unsigned InputStartLine;
+ unsigned InputStartCol;
+ unsigned InputEndLine;
+ unsigned InputEndCol;
FileCheckDiag(const SourceMgr &SM, const Check::FileCheckType &CheckTy,
SMLoc CheckLoc, MatchType MatchTy, SMRange InputRange);
};
Modified: llvm/trunk/lib/Support/FileCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/FileCheck.cpp?rev=349425&r1=349424&r2=349425&view=diff
==============================================================================
--- llvm/trunk/lib/Support/FileCheck.cpp (original)
+++ llvm/trunk/lib/Support/FileCheck.cpp Mon Dec 17 16:03:51 2018
@@ -908,8 +908,8 @@ static void PrintMatch(bool ExpectedMatc
return;
}
SMRange MatchRange = ProcessMatchResult(
- ExpectedMatch ? FileCheckDiag::MatchFinalAndExpected
- : FileCheckDiag::MatchFinalButExcluded,
+ ExpectedMatch ? FileCheckDiag::MatchFoundAndExpected
+ : FileCheckDiag::MatchFoundButExcluded,
SM, Loc, Pat.getCheckTy(), Buffer, MatchPos, MatchLen, Diags);
std::string Message = formatv("{0}: {1} string found in input",
Pat.getCheckTy().getDescription(Prefix),
@@ -1062,7 +1062,7 @@ size_t FileCheckString::Check(const Sour
// 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)) {
- ProcessMatchResult(FileCheckDiag::MatchFinalButWrongLine, SM, Loc,
+ ProcessMatchResult(FileCheckDiag::MatchFoundButWrongLine, SM, Loc,
Pat.getCheckTy(), MatchBuffer, MatchPos, MatchLen,
Diags, Req.Verbose);
return StringRef::npos;
@@ -1071,7 +1071,7 @@ size_t FileCheckString::Check(const Sour
// If this check is a "CHECK-SAME", verify that the previous match was on
// the same line (i.e. that there is no newline between them).
if (CheckSame(SM, SkippedRegion)) {
- ProcessMatchResult(FileCheckDiag::MatchFinalButWrongLine, SM, Loc,
+ ProcessMatchResult(FileCheckDiag::MatchFoundButWrongLine, SM, Loc,
Pat.getCheckTy(), MatchBuffer, MatchPos, MatchLen,
Diags, Req.Verbose);
return StringRef::npos;
@@ -1283,7 +1283,7 @@ FileCheckString::CheckDag(const SourceMg
"match discarded, overlaps earlier DAG match here",
{OldRange});
if (Diags)
- Diags->rbegin()->MatchTy = FileCheckDiag::MatchDiscard;
+ Diags->rbegin()->MatchTy = FileCheckDiag::MatchFoundButDiscarded;
}
MatchPos = MI->End;
}
Modified: llvm/trunk/test/FileCheck/dump-input-annotations.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FileCheck/dump-input-annotations.txt?rev=349425&r1=349424&r2=349425&view=diff
==============================================================================
--- llvm/trunk/test/FileCheck/dump-input-annotations.txt (original)
+++ llvm/trunk/test/FileCheck/dump-input-annotations.txt Mon Dec 17 16:03:51 2018
@@ -322,6 +322,13 @@
; RUN: echo 'CHECK-DAG: abc' >> %t.chk
; RUN: echo 'CHECK-DAG: def' >> %t.chk
+; Prefixes used here:
+; DAG = quiet, -v, or -vv
+; DAG-Q = quiet
+; DAG-V = -v or -vv (-vv implies -v)
+; DAG-VQ = -v and not -vv
+; DAG-VV = -vv
+
; 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 \
Modified: llvm/trunk/utils/FileCheck/FileCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/FileCheck/FileCheck.cpp?rev=349425&r1=349424&r2=349425&view=diff
==============================================================================
--- llvm/trunk/utils/FileCheck/FileCheck.cpp (original)
+++ llvm/trunk/utils/FileCheck/FileCheck.cpp Mon Dec 17 16:03:51 2018
@@ -144,13 +144,13 @@ struct MarkerStyle {
static MarkerStyle GetMarker(FileCheckDiag::MatchType MatchTy) {
switch (MatchTy) {
- case FileCheckDiag::MatchFinalAndExpected:
+ case FileCheckDiag::MatchFoundAndExpected:
return MarkerStyle('^', raw_ostream::GREEN);
- case FileCheckDiag::MatchFinalButExcluded:
+ case FileCheckDiag::MatchFoundButExcluded:
return MarkerStyle('!', raw_ostream::RED, "error: no match expected");
- case FileCheckDiag::MatchFinalButWrongLine:
+ case FileCheckDiag::MatchFoundButWrongLine:
return MarkerStyle('!', raw_ostream::RED, "error: match on wrong line");
- case FileCheckDiag::MatchDiscard:
+ case FileCheckDiag::MatchFoundButDiscarded:
return MarkerStyle('!', raw_ostream::CYAN,
"discard: overlaps earlier match");
case FileCheckDiag::MatchNoneAndExcluded:
@@ -241,8 +241,8 @@ struct InputAnnotation {
unsigned InputStartCol, InputEndCol;
/// The marker to use.
MarkerStyle Marker;
- /// Whether this annotation represents a final match for an expected pattern.
- bool FinalAndExpectedMatch;
+ /// Whether this annotation represents a good match for an expected pattern.
+ bool FoundAndExpectedMatch;
};
/// Get an abbreviation for the check type.
@@ -310,8 +310,8 @@ static void BuildInputAnnotations(const
MarkerStyle Marker = GetMarker(DiagItr->MatchTy);
A.Marker = Marker;
- A.FinalAndExpectedMatch =
- DiagItr->MatchTy == FileCheckDiag::MatchFinalAndExpected;
+ A.FoundAndExpectedMatch =
+ DiagItr->MatchTy == FileCheckDiag::MatchFoundAndExpected;
// Compute the mark location, and break annotation into multiple
// annotations if it spans multiple lines.
@@ -351,7 +351,7 @@ static void BuildInputAnnotations(const
B.Marker.Note = "";
} else
B.InputEndCol = DiagItr->InputEndCol;
- B.FinalAndExpectedMatch = A.FinalAndExpectedMatch;
+ B.FoundAndExpectedMatch = A.FoundAndExpectedMatch;
Annotations.push_back(B);
}
}
@@ -424,15 +424,15 @@ static void DumpAnnotatedInput(raw_ostre
WithColor(OS, raw_ostream::BLACK, true)
<< format_decimal(Line, LabelWidth) << ": ";
- // For case where -v and colors are enabled, find the annotations for final
- // matches for expected patterns in order to highlight everything else in
- // the line. There are no such annotations if -v is disabled.
- std::vector<InputAnnotation> FinalAndExpectedMatches;
+ // For the case where -v and colors are enabled, find the annotations for
+ // good matches for expected patterns in order to highlight everything
+ // else in the line. There are no such annotations if -v is disabled.
+ std::vector<InputAnnotation> FoundAndExpectedMatches;
if (Req.Verbose && WithColor(OS).colorsEnabled()) {
for (auto I = AnnotationItr; I != AnnotationEnd && I->InputLine == Line;
++I) {
- if (I->FinalAndExpectedMatch)
- FinalAndExpectedMatches.push_back(*I);
+ if (I->FoundAndExpectedMatch)
+ FoundAndExpectedMatches.push_back(*I);
}
}
@@ -447,7 +447,7 @@ static void DumpAnnotatedInput(raw_ostre
for (unsigned Col = 1; InputFilePtr != InputFileEnd && !Newline; ++Col) {
bool WasInMatch = InMatch;
InMatch = false;
- for (auto M : FinalAndExpectedMatches) {
+ for (auto M : FoundAndExpectedMatches) {
if (M.InputStartCol <= Col && Col < M.InputEndCol) {
InMatch = true;
break;
More information about the llvm-commits
mailing list