llvm.org GIT mirror llvm / 9074a87
[FileCheck] Implement -v and -vv for tracing matches -v prints all directive pattern matches. -vv additionally prints info that might be noise to users but that can be helpful to FileCheck developers. To maximize code reuse and to make diagnostics more consistent, this patch also adjusts and extends some of the existing diagnostics. CHECK-NOT failures now report variables uses. Many more diagnostics now report the check prefix and kind of directive. Reviewed By: probinson Differential Revision: https://reviews.llvm.org/D47114 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336967 91177308-0d34-0410-b5e6-96231b3b80d8 Joel E. Denny 1 year, 4 months ago
11 changed file(s) with 306 addition(s) and 65 deletion(s). Raw diff Collapse all Expand all
9393 .. option:: -version
9494
9595 Show the version number of this program.
96
97 .. option:: -v
98
99 Print directive pattern matches.
100
101 .. option:: -vv
102
103 Print information helpful in diagnosing internal FileCheck issues, such as
104 discarded overlapping ``CHECK-DAG:`` matches, implicit EOF pattern matches,
105 and ``CHECK-NOT:`` patterns that do not have matches. Implies ``-v``.
96106
97107 .. option:: --allow-deprecated-dag-overlap
98108
88 ; EMPTY-ERR: FileCheck error: '-' is empty.
99 ; EMPTY-ERR-NEXT: FileCheck command line: {{.*}}FileCheck{{.*}}-check-prefix={{.*}}FOO {{.*}}check-empty.txt
1010 ; NO-EMPTY-ERR-NOT: FileCheck error: '-' is empty.
11 ; NOT-FOUND: error: expected string not found in input
11 ; NOT-FOUND: error: FOO: expected string not found in input
66 CHECK-DAG: {{^}}foo
77 CHECK-LABEL: {{^}}zed
88
9 ERROR: error: expected string not found in input
9 ERROR: error: CHECK-DAG: expected string not found in input
1010 ERROR-NEXT: CHECK-DAG: {{.....}}foo
77 ; FOO: fo{{o}}
88 ; BAR: ba{{r}}
99
10 ; CHECK: {{error: expected string not found in input}}
10 ; CHECK: {{error: FOO: expected string not found in input}}
1111 ; CHECK-NEXT: {{F}}OO: fo{{[{][{]o[}][}]}}
77 ; BAR: ba{{z}}
88 ; FOO: fo{{o}}
99
10 ; CHECK: {{error: expected string not found in input}}
10 ; CHECK: {{error: BAR: expected string not found in input}}
1111 ; CHECK-NEXT: {{B}}AR: ba{{[{][{]z[}][}]}}
11
22 CHECK-NOT: test
33
4 DIAG: CHECK-NOT: pattern specified here
4 DIAG: error: CHECK-NOT: excluded string found in input
55 DIAG-NEXT: CHECK-NOT: test
66 DIAG-NEXT: {{^ \^}}
7 DIAG-NEXT: note: found here
8 DIAG-NEXT: CHECK-NOT: test
9 DIAG-NEXT: {{^ \^}}
0 ; RUN: FileCheck -DVALUE=10 -input-file %s %s
11 ; RUN: not FileCheck -DVALUE=20 -input-file %s %s 2>&1 | FileCheck %s -check-prefix ERRMSG
2 ;
3 ; RUN: not FileCheck -DVALUE=10 -check-prefix NOT -input-file %s %s 2>&1 | FileCheck %s -check-prefix NOT-ERRMSG
4 ; RUN: FileCheck -DVALUE=20 -check-prefix NOT -input-file %s %s
25
36 Value = 10
47 ; CHECK: Value = [[VALUE]]
8 ; NOT-NOT: Value = [[VALUE]]
59
6 ; ERRMSG: defines.txt:5:10: error: expected string not found in input
10 ; ERRMSG: defines.txt:8:10: error: CHECK: expected string not found in input
11 ; ERRMSG: defines.txt:1:1: note: scanning from here
712 ; ERRMSG: defines.txt:1:1: note: with variable "VALUE" equal to "20"
8 ; ERRMSG: defines.txt:4:1: note: possible intended match here
13 ; ERRMSG: defines.txt:7:1: note: possible intended match here
14
15 ; NOT-ERRMSG: defines.txt:9:12: error: {{NOT}}-NOT: excluded string found in input
16 ; NOT-ERRMSG: defines.txt:7:1: note: found here
17 ; NOT-ERRMSG: defines.txt:7:1: note: with variable "VALUE" equal to "10"
88
99 warning: aaa
1010 ; CHECK-PASS: warning: aaa
11 ; CHECK-ERROR1: error: CHECK-FAIL1-NOT: string occurred!
12 ; CHECK-ERROR1: command line:1:22: note: CHECK-FAIL1-NOT: pattern specified here
11 ; CHECK-ERROR1: command line:1:22: error: CHECK-FAIL1-NOT: excluded string found in input
1312 ; CHECK-ERROR1-NEXT: -implicit-check-not='warning:'
13 ; CHECK-ERROR1: note: found here
1414 ; CHECK-FAIL2: warning: aaa
1515 ; CHECK-FAIL3: warning: aaa
16 ; CHECK-ERROR4: error: CHECK-FAIL1-NOT: string occurred!
17 ; CHECK-ERROR4: command line:1:22: note: CHECK-FAIL1-NOT: pattern specified here
16 ; CHECK-ERROR4: command line:1:22: error: CHECK-FAIL1-NOT: excluded string found in input
1817 ; CHECK-ERROR4-NEXT: {{-implicit-check-not='\{\{aaa\|bbb\|ccc\}\}'}}
19 ; CHECK-ERROR5: error: CHECK-FAIL1-NOT: string occurred!
20 ; CHECK-ERROR5: command line:1:22: note: CHECK-FAIL1-NOT: pattern specified here
18 ; CHECK-ERROR4: note: found here
19 ; CHECK-ERROR5: command line:1:22: error: CHECK-FAIL1-NOT: excluded string found in input
2120 ; CHECK-ERROR5-NEXT: -implicit-check-not='aaa'
21 ; CHECK-ERROR5: note: found here
2222
2323 warning: bbb
2424 ; CHECK-PASS: warning: bbb
2525 ; CHECK-FAIL1: warning: bbb
26 ; CHECK-ERROR2: error: CHECK-FAIL2-NOT: string occurred!
27 ; CHECK-ERROR2: command line:1:22: note: CHECK-FAIL2-NOT: pattern specified here
26 ; CHECK-ERROR2: command line:1:22: error: CHECK-FAIL2-NOT: excluded string found in input
2827 ; CHECK-ERROR2-NEXT: -implicit-check-not='warning:'
28 ; CHECK-ERROR2: note: found here
2929 ; CHECK-FAIL3: warning: bbb
30 ; CHECK-ERROR6: error: CHECK-FAIL2-NOT: string occurred!
31 ; CHECK-ERROR6: command line:1:22: note: CHECK-FAIL2-NOT: pattern specified here
30 ; CHECK-ERROR6: command line:1:22: error: CHECK-FAIL2-NOT: excluded string found in input
3231 ; CHECK-ERROR6-NEXT: -implicit-check-not='bbb'
32 ; CHECK-ERROR6: note: found here
3333
3434 warning: ccc
3535 ; CHECK-PASS: warning: ccc
3636 ; CHECK-FAIL1: warning: ccc
3737 ; CHECK-FAIL2: warning: ccc
38 ; CHECK-ERROR3: error: CHECK-FAIL3-NOT: string occurred!
39 ; CHECK-ERROR3: command line:1:22: note: CHECK-FAIL3-NOT: pattern specified here
38 ; CHECK-ERROR3: command line:1:22: error: CHECK-FAIL3-NOT: excluded string found in input
4039 ; CHECK-ERROR3-NEXT: -implicit-check-not='warning:'
41 ; CHECK-ERROR7: error: CHECK-FAIL3-NOT: string occurred!
42 ; CHECK-ERROR7: command line:1:22: note: CHECK-FAIL3-NOT: pattern specified here
40 ; CHECK-ERROR3: note: found here
41 ; CHECK-ERROR7: command line:1:22: error: CHECK-FAIL3-NOT: excluded string found in input
4342 ; CHECK-ERROR7-NEXT: -implicit-check-not='ccc'
43 ; CHECK-ERROR7: note: found here
2525 // CHECK:a line
2626 // CHECK:trailing whitespace
2727 // CHECK:trailing more whitespace
28 // ERROR-STRICT:error: expected string not found in input
28 // ERROR-STRICT:error: {{C}}HECK: expected string not found in input
2929 // ERROR-STRICT:// {{C}}HECK:trailing whitespace
3030
3131 // CHECK-LABEL:Label 2
3232 // CHECK:a line
3333 // CHECK-NEXT:leading whitespace
3434 // CHECK-NEXT: leading more whitespace
35 // ERROR-STRICT:error: expected string not found in input
35 // ERROR-STRICT:error: {{C}}HECK-NEXT: expected string not found in input
3636 // ERROR-STRICT:// {{C}}HECK-NEXT:leading whitespace
3737
3838 // CHECK-LABEL:Label 3
3939 // CHECK:line
40 // ERROR:error: expected string not found in input
40 // ERROR:error: {{C}}HECK: expected string not found in input
4141 // ERROR:// {{C}}HECK:line
4242
4343 // CHECK-LABEL:Label 4
4444 // CHECK:a line
4545 // CHECK-NOT:random
46 // ERROR:error: {{C}}HECK-NOT: string occurred!
46 // ERROR:error: {{C}}HECK-NOT: excluded string found in input
4747 // ERROR:a random thing
4848
4949 // CHECK-LABEL:Label 5
5050 // CHECK-LABEL:Label 6
51 // ERROR:error: expected string not found in input
51 // ERROR:error: {{C}}HECK-LABEL: expected string not found in input
5252 // ERROR:{{C}}HECK-LABEL:Label 6
0 ; RUN: FileCheck -input-file %s %s 2>&1 | FileCheck -check-prefix QUIET --allow-empty %s
1 ; RUN: FileCheck -v -input-file %s %s 2>&1 | FileCheck -check-prefix V %s
2 ; RUN: FileCheck -vv -input-file %s %s 2>&1 | FileCheck -check-prefixes V,VV %s
3
4 foo
5 bar
6 CHECK: foo
7 CHECK-NOT: raboof
8 CHECK-NEXT: bar
9
10 V: verbose.txt:[[@LINE-4]]:8: remark: {{C}}HECK: expected string found in input
11 V-NEXT: {{C}}HECK: foo{{$}}
12 V-NEXT: {{^ \^$}}
13 V-NEXT: verbose.txt:[[@LINE-9]]:1: note: found here
14 V-NEXT: {{^}}foo{{$}}
15 V-NEXT: {{^}}^~~{{$}}
16
17 V-NEXT: verbose.txt:[[@LINE-9]]:13: remark: {{C}}HECK-NEXT: expected string found in input
18 V-NEXT: {{C}}HECK-NEXT: bar{{$}}
19 V-NEXT: {{^ \^$}}
20 V-NEXT: verbose.txt:[[@LINE-15]]:1: note: found here
21 V-NEXT: {{^}}bar{{$}}
22 V-NEXT: {{^}}^~~{{$}}
23
24 VV-NEXT: verbose.txt:[[@LINE-17]]:12: remark: {{C}}HECK-NOT: excluded string not found in input
25 VV-NEXT: {{C}}HECK-NOT: raboof{{$}}
26 VV-NEXT: {{^ \^$}}
27 VV-NEXT: verbose.txt:[[@LINE-22]]:1: note: scanning from here
28 VV-NEXT: {{^}}bar{{$}}
29 VV-NEXT: {{^}}^{{$}}
30
31 before empty
32
33 after empty
34 CHECK: before empty
35 CHECK-EMPTY:
36 CHECK-NEXT: after empty
37
38 V: verbose.txt:[[@LINE-4]]:8: remark: {{C}}HECK: expected string found in input
39 V-NEXT: {{C}}HECK: before empty{{$}}
40 V-NEXT: {{^ \^$}}
41 V-NEXT: verbose.txt:[[@LINE-10]]:1: note: found here
42 V-NEXT: {{^}}before empty{{$}}
43 V-NEXT: {{^}}^~~~~~~~~~~~{{$}}
44
45 V-NEXT: verbose.txt:[[@LINE-10]]:13: remark: {{C}}HECK-EMPTY: expected string found in input
46 V-NEXT: {{C}}HECK-EMPTY:{{$}}
47 V-NEXT: {{^ \^$}}
48 V-NEXT: verbose.txt:[[@LINE-16]]:1: note: found here
49 V-EMPTY:
50 V-NEXT: {{^}}^{{$}}
51
52 V-NEXT: verbose.txt:[[@LINE-16]]:13: remark: {{C}}HECK-NEXT: expected string found in input
53 V-NEXT: {{C}}HECK-NEXT: after empty{{$}}
54 V-NEXT: {{^ \^$}}
55 V-NEXT: verbose.txt:[[@LINE-22]]:1: note: found here
56 V-NEXT: {{^}}after empty{{$}}
57 V-NEXT: {{^}}^~~~~~~~~~~{{$}}
58
59 abcdef
60 abcdef
61 CHECK-DAG: abcdef
62 CHECK-DAG: def
63
64 V-NEXT: verbose.txt:[[@LINE-3]]:12: remark: {{C}}HECK-DAG: expected string found in input
65 V-NEXT: {{C}}HECK-DAG: abcdef
66 V-NEXT: {{^ \^$}}
67 V-NEXT: verbose.txt:[[@LINE-8]]:1: note: found here
68 V-NEXT: {{^}}abcdef{{$}}
69 V-NEXT: {{^}}^~~~~~{{$}}
70
71 VV-NEXT: verbose.txt:[[@LINE-9]]:12: remark: {{C}}HECK-DAG: expected string found in input
72 VV-NEXT: {{C}}HECK-DAG: def
73 VV-NEXT: {{^ \^$}}
74 VV-NEXT: verbose.txt:[[@LINE-15]]:4: note: found here
75 VV-NEXT: {{^abcdef$}}
76 VV-NEXT: {{^ \^~~$}}
77 VV-NEXT: verbose.txt:[[@LINE-18]]:1: note: match discarded, overlaps earlier DAG match here
78 VV-NEXT: {{^}}abcdef{{$}}
79 VV-NEXT: {{^}}^~~~~~{{$}}
80
81 V-NEXT: verbose.txt:[[@LINE-19]]:12: remark: {{C}}HECK-DAG: expected string found in input
82 V-NEXT: {{C}}HECK-DAG: def
83 V-NEXT: {{^ \^$}}
84 V-NEXT: verbose.txt:[[@LINE-24]]:4: note: found here
85 V-NEXT: {{^abcdef$}}
86 V-NEXT: {{^ \^~~$}}
87
88 xyz
89 CHECK: xyz
90 CHECK-NOT: {{z}}yx
91
92 V: verbose.txt:[[@LINE-3]]:8: remark: {{C}}HECK: expected string found in input
93 V-NEXT: {{C}}HECK: xyz{{$}}
94 V-NEXT: {{^ \^$}}
95 V-NEXT: verbose.txt:[[@LINE-7]]:1: note: found here
96 V-NEXT: {{^}}xyz{{$}}
97 V-NEXT: {{^}}^~~{{$}}
98
99 VV-NEXT: verbose.txt:[[@LINE-9]]:19: remark: implicit EOF: expected string found in input
100 VV-NEXT: {{C}}HECK-NOT: {{[{][{]z[}][}]yx$}}
101 VV-NEXT: {{^ \^$}}
102 VV-NEXT: verbose.txt:[[@LINE+13]]:1: note: found here
103 VV-NOT: {{.}}
104 VV: {{^\^$}}
105
106 VV-NEXT: verbose.txt:[[@LINE-16]]:12: remark: {{C}}HECK-NOT: excluded string not found in input
107 VV-NEXT: {{C}}HECK-NOT: {{[{][{]z[}][}]yx$}}
108 VV-NEXT: {{^ \^$}}
109 VV-NEXT: verbose.txt:[[@LINE-20]]:1: note: scanning from here
110 VV-NEXT: {{^C}}HECK: xyz{{$}}
111 VV-NEXT: {{^\^$}}
112
113 QUIET-NOT: {{.}}
114 V-NOT: {{.}}
8989 "provided for convenience as old tests are migrated to the new\n"
9090 "non-overlapping CHECK-DAG implementation.\n"));
9191
92 static cl::opt Verbose("v", cl::init(false),
93 cl::desc("Print directive pattern matches.\n"));
94
95 static cl::opt VerboseVerbose(
96 "vv", cl::init(false),
97 cl::desc("Print information helpful in diagnosing internal FileCheck\n"
98 "issues. Implies -v.\n"));
99
92100 typedef cl::list::const_iterator prefix_iterator;
93101
94102 //===----------------------------------------------------------------------===//
153161 unsigned LineNumber);
154162 size_t Match(StringRef Buffer, size_t &MatchLen,
155163 StringMap &VariableTable) const;
156 void PrintFailureInfo(const SourceMgr &SM, StringRef Buffer,
157 const StringMap &VariableTable) const;
164 void PrintVariableUses(const SourceMgr &SM, StringRef Buffer,
165 const StringMap &VariableTable,
166 SMRange MatchRange = None) const;
167 void PrintFuzzyMatch(const SourceMgr &SM, StringRef Buffer,
168 const StringMap &VariableTable) const;
158169
159170 bool hasVariable() const {
160171 return !(VariableUses.empty() && VariableDefs.empty());
483494 VariableTable[VariableDef.first] = MatchInfo[VariableDef.second];
484495 }
485496
486 MatchLen = FullMatch.size();
487 return FullMatch.data() - Buffer.data();
497 // Like CHECK-NEXT, CHECK-EMPTY's match range is considered to start after
498 // the required preceding newline, which is consumed by the pattern in the
499 // case of CHECK-EMPTY but not CHECK-NEXT.
500 size_t MatchStartSkip = CheckTy == Check::CheckEmpty;
501 MatchLen = FullMatch.size() - MatchStartSkip;
502 return FullMatch.data() - Buffer.data() + MatchStartSkip;
488503 }
489504
490505
510525 return BufferPrefix.edit_distance(ExampleString);
511526 }
512527
513 /// Prints additional information about a failure to match involving this
514 /// pattern.
515 void Pattern::PrintFailureInfo(
516 const SourceMgr &SM, StringRef Buffer,
517 const StringMap &VariableTable) const {
528 void Pattern::PrintVariableUses(const SourceMgr &SM, StringRef Buffer,
529 const StringMap &VariableTable,
530 SMRange MatchRange) const {
518531 // If this was a regular expression using variables, print the current
519532 // variable values.
520533 if (!VariableUses.empty()) {
546559 }
547560 }
548561
549 SM.PrintMessage(SMLoc::getFromPointer(Buffer.data()), SourceMgr::DK_Note,
550 OS.str());
551 }
552 }
553
562 if (MatchRange.isValid())
563 SM.PrintMessage(MatchRange.Start, SourceMgr::DK_Note, OS.str(),
564 {MatchRange});
565 else
566 SM.PrintMessage(SMLoc::getFromPointer(Buffer.data()),
567 SourceMgr::DK_Note, OS.str());
568 }
569 }
570 }
571
572 void Pattern::PrintFuzzyMatch(
573 const SourceMgr &SM, StringRef Buffer,
574 const StringMap &VariableTable) const {
554575 // Attempt to find the closest/best fuzzy match. Usually an error happens
555576 // because some string in the output didn't exactly match. In these cases, we
556577 // would like to show the user a best guess at what "should have" matched, to
740761 llvm_unreachable("Bad check type");
741762 }
742763
764 // Get a description of the type.
765 static std::string CheckTypeName(StringRef Prefix, Check::CheckType Ty) {
766 switch (Ty) {
767 case Check::CheckNone:
768 return "invalid";
769 case Check::CheckPlain:
770 return Prefix;
771 case Check::CheckNext:
772 return Prefix.str() + "-NEXT";
773 case Check::CheckSame:
774 return Prefix.str() + "-SAME";
775 case Check::CheckNot:
776 return Prefix.str() + "-NOT";
777 case Check::CheckDAG:
778 return Prefix.str() + "-DAG";
779 case Check::CheckLabel:
780 return Prefix.str() + "-LABEL";
781 case Check::CheckEmpty:
782 return Prefix.str() + "-EMPTY";
783 case Check::CheckEOF:
784 return "implicit EOF";
785 case Check::CheckBadNot:
786 return "bad NOT";
787 }
788 llvm_unreachable("unknown CheckType");
789 }
790
743791 static Check::CheckType FindCheckType(StringRef Buffer, StringRef Prefix) {
744792 if (Buffer.size() <= Prefix.size())
745793 return Check::CheckNone;
9891037 return false;
9901038 }
9911039
992 static void PrintCheckFailed(const SourceMgr &SM, SMLoc Loc, const Pattern &Pat,
993 StringRef Buffer,
994 StringMap &VariableTable) {
1040 static void PrintMatch(bool ExpectedMatch, const SourceMgr &SM,
1041 StringRef Prefix, SMLoc Loc, const Pattern &Pat,
1042 StringRef Buffer, StringMap &VariableTable,
1043 size_t MatchPos, size_t MatchLen) {
1044 if (ExpectedMatch) {
1045 if (!Verbose)
1046 return;
1047 if (!VerboseVerbose && Pat.getCheckTy() == Check::CheckEOF)
1048 return;
1049 }
1050 SMLoc MatchStart = SMLoc::getFromPointer(Buffer.data() + MatchPos);
1051 SMLoc MatchEnd = SMLoc::getFromPointer(Buffer.data() + MatchPos + MatchLen);
1052 SMRange MatchRange(MatchStart, MatchEnd);
1053 SM.PrintMessage(
1054 Loc, ExpectedMatch ? SourceMgr::DK_Remark : SourceMgr::DK_Error,
1055 CheckTypeName(Prefix, Pat.getCheckTy()) + ": " +
1056 (ExpectedMatch ? "expected" : "excluded") +
1057 " string found in input");
1058 SM.PrintMessage(MatchStart, SourceMgr::DK_Note, "found here", {MatchRange});
1059 Pat.PrintVariableUses(SM, Buffer, VariableTable, MatchRange);
1060 }
1061
1062 static void PrintMatch(bool ExpectedMatch, const SourceMgr &SM,
1063 const CheckString &CheckStr, StringRef Buffer,
1064 StringMap &VariableTable, size_t MatchPos,
1065 size_t MatchLen) {
1066 PrintMatch(ExpectedMatch, SM, CheckStr.Prefix, CheckStr.Loc, CheckStr.Pat,
1067 Buffer, VariableTable, MatchPos, MatchLen);
1068 }
1069
1070 static void PrintNoMatch(bool ExpectedMatch, const SourceMgr &SM,
1071 StringRef Prefix, SMLoc Loc, const Pattern &Pat,
1072 StringRef Buffer,
1073 StringMap &VariableTable) {
1074 if (!ExpectedMatch && !VerboseVerbose)
1075 return;
1076
9951077 // Otherwise, we have an error, emit an error message.
996 SM.PrintMessage(Loc, SourceMgr::DK_Error,
997 "expected string not found in input");
1078 SM.PrintMessage(Loc,
1079 ExpectedMatch ? SourceMgr::DK_Error : SourceMgr::DK_Remark,
1080 CheckTypeName(Prefix, Pat.getCheckTy()) + ": " +
1081 (ExpectedMatch ? "expected" : "excluded") +
1082 " string not found in input");
9981083
9991084 // Print the "scanning from here" line. If the current position is at the
10001085 // end of a line, advance to the start of the next line.
10041089 "scanning from here");
10051090
10061091 // Allow the pattern to print additional information if desired.
1007 Pat.PrintFailureInfo(SM, Buffer, VariableTable);
1008 }
1009
1010 static void PrintCheckFailed(const SourceMgr &SM, const CheckString &CheckStr,
1011 StringRef Buffer,
1012 StringMap &VariableTable) {
1013 PrintCheckFailed(SM, CheckStr.Loc, CheckStr.Pat, Buffer, VariableTable);
1092 Pat.PrintVariableUses(SM, Buffer, VariableTable);
1093 if (ExpectedMatch)
1094 Pat.PrintFuzzyMatch(SM, Buffer, VariableTable);
1095 }
1096
1097 static void PrintNoMatch(bool ExpectedMatch, const SourceMgr &SM,
1098 const CheckString &CheckStr, StringRef Buffer,
1099 StringMap &VariableTable) {
1100 PrintNoMatch(ExpectedMatch, SM, CheckStr.Prefix, CheckStr.Loc, CheckStr.Pat,
1101 Buffer, VariableTable);
10141102 }
10151103
10161104 /// Count the number of newlines in the specified range.
10581146 StringRef MatchBuffer = Buffer.substr(LastPos);
10591147 size_t MatchPos = Pat.Match(MatchBuffer, MatchLen, VariableTable);
10601148 if (MatchPos == StringRef::npos) {
1061 PrintCheckFailed(SM, *this, MatchBuffer, VariableTable);
1149 PrintNoMatch(true, SM, *this, MatchBuffer, VariableTable);
10621150 return StringRef::npos;
10631151 }
1152 PrintMatch(true, SM, *this, MatchBuffer, VariableTable, MatchPos, MatchLen);
10641153
10651154 // Similar to the above, in "label-scan mode" we can't yet handle CHECK-NEXT
10661155 // or CHECK-NOT
11051194
11061195 const char *FirstNewLine = nullptr;
11071196 unsigned NumNewLines = CountNumNewlinesBetween(Buffer, FirstNewLine);
1108
1109 // For CHECK-EMPTY, the preceding new line is consumed by the pattern, so
1110 // this needs to be re-added.
1111 if (Pat.getCheckTy() == Check::CheckEmpty)
1112 ++NumNewLines;
11131197
11141198 if (NumNewLines == 0) {
11151199 SM.PrintMessage(Loc, SourceMgr::DK_Error,
11761260 size_t MatchLen = 0;
11771261 size_t Pos = Pat->Match(Buffer, MatchLen, VariableTable);
11781262
1179 if (Pos == StringRef::npos)
1263 if (Pos == StringRef::npos) {
1264 PrintNoMatch(false, SM, Prefix, Pat->getLoc(), *Pat, Buffer,
1265 VariableTable);
11801266 continue;
1181
1182 SM.PrintMessage(SMLoc::getFromPointer(Buffer.data() + Pos),
1183 SourceMgr::DK_Error, Prefix + "-NOT: string occurred!");
1184 SM.PrintMessage(Pat->getLoc(), SourceMgr::DK_Note,
1185 Prefix + "-NOT: pattern specified here");
1267 }
1268
1269 PrintMatch(false, SM, Prefix, Pat->getLoc(), *Pat, Buffer, VariableTable,
1270 Pos, MatchLen);
1271
11861272 return true;
11871273 }
11881274
12291315 // With a group of CHECK-DAGs, a single mismatching means the match on
12301316 // that group of CHECK-DAGs fails immediately.
12311317 if (MatchPosBuf == StringRef::npos) {
1232 PrintCheckFailed(SM, Pat.getLoc(), Pat, MatchBuffer, VariableTable);
1318 PrintNoMatch(true, SM, Prefix, Pat.getLoc(), Pat, MatchBuffer,
1319 VariableTable);
12331320 return StringRef::npos;
12341321 }
12351322 // Re-calc it as the offset relative to the start of the original string.
12361323 MatchPos += MatchPosBuf;
1324 if (VerboseVerbose)
1325 PrintMatch(true, SM, Prefix, Pat.getLoc(), Pat, Buffer, VariableTable,
1326 MatchPos, MatchLen);
12371327 if (AllowDeprecatedDagOverlap)
12381328 break;
12391329 // Iterate previous matches until overlapping match or insertion point.
12521342 Matches.insert(MI, M);
12531343 break;
12541344 }
1345 if (VerboseVerbose) {
1346 SMLoc OldStart = SMLoc::getFromPointer(Buffer.data() + MI->Pos);
1347 SMLoc OldEnd = SMLoc::getFromPointer(Buffer.data() + MI->End);
1348 SMRange OldRange(OldStart, OldEnd);
1349 SM.PrintMessage(OldStart, SourceMgr::DK_Note,
1350 "match discarded, overlaps earlier DAG match here",
1351 {OldRange});
1352 }
12551353 MatchPos = MI->End;
12561354 }
1355 if (!VerboseVerbose)
1356 PrintMatch(true, SM, Prefix, Pat.getLoc(), Pat, Buffer, VariableTable,
1357 MatchPos, MatchLen);
12571358
12581359 if (!NotStrings.empty()) {
12591360 if (MatchPos < LastPos) {
14541555 return 2;
14551556 }
14561557
1558 if (VerboseVerbose)
1559 Verbose = true;
1560
14571561 SourceMgr SM;
14581562
14591563 // Read the expected strings from the check file.