1 //===- FileCheck.cpp - Check that File's Contents match what is expected --===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // FileCheck does a line-by line check of a file that validates whether it
11 // contains the expected content. This is useful for regression tests etc.
13 // This program exits with an error status of 2 on error, exit status of 0 if
14 // the file matched the expected contents, and exit status of 1 if it did not
15 // contain the expected contents.
17 //===----------------------------------------------------------------------===//
19 #include "llvm/ADT/OwningPtr.h"
20 #include "llvm/Support/CommandLine.h"
21 #include "llvm/Support/MemoryBuffer.h"
22 #include "llvm/Support/PrettyStackTrace.h"
23 #include "llvm/Support/Regex.h"
24 #include "llvm/Support/SourceMgr.h"
25 #include "llvm/Support/raw_ostream.h"
26 #include "llvm/Support/Signals.h"
27 #include "llvm/Support/system_error.h"
28 #include "llvm/ADT/SmallString.h"
29 #include "llvm/ADT/StringMap.h"
33 static cl::opt<std::string>
34 CheckFilename(cl::Positional, cl::desc("<check-file>"), cl::Required);
36 static cl::opt<std::string>
37 InputFilename("input-file", cl::desc("File to check (defaults to stdin)"),
38 cl::init("-"), cl::value_desc("filename"));
40 static cl::opt<std::string>
41 CheckPrefix("check-prefix", cl::init("CHECK"),
42 cl::desc("Prefix to use from check file (defaults to 'CHECK')"));
45 NoCanonicalizeWhiteSpace("strict-whitespace",
46 cl::desc("Do not treat all horizontal whitespace as equivalent"));
48 //===----------------------------------------------------------------------===//
49 // Pattern Handling Code.
50 //===----------------------------------------------------------------------===//
55 /// MatchEOF - When set, this pattern only matches the end of file. This is
56 /// used for trailing CHECK-NOTs.
59 /// FixedStr - If non-empty, this pattern is a fixed string match with the
60 /// specified fixed string.
63 /// RegEx - If non-empty, this is a regex pattern.
66 /// VariableUses - Entries in this vector map to uses of a variable in the
67 /// pattern, e.g. "foo[[bar]]baz". In this case, the RegExStr will contain
68 /// "foobaz" and we'll get an entry in this vector that tells us to insert the
69 /// value of bar at offset 3.
70 std::vector<std::pair<StringRef, unsigned> > VariableUses;
72 /// VariableDefs - Entries in this vector map to definitions of a variable in
73 /// the pattern, e.g. "foo[[bar:.*]]baz". In this case, the RegExStr will
74 /// contain "foo(.*)baz" and VariableDefs will contain the pair "bar",1. The
75 /// index indicates what parenthesized value captures the variable value.
76 std::vector<std::pair<StringRef, unsigned> > VariableDefs;
80 Pattern(bool matchEOF = false) : MatchEOF(matchEOF) { }
82 bool ParsePattern(StringRef PatternStr, SourceMgr &SM);
84 /// Match - Match the pattern string against the input buffer Buffer. This
85 /// returns the position that is matched or npos if there is no match. If
86 /// there is a match, the size of the matched string is returned in MatchLen.
88 /// The VariableTable StringMap provides the current values of filecheck
89 /// variables and is updated if this match defines new values.
90 size_t Match(StringRef Buffer, size_t &MatchLen,
91 StringMap<StringRef> &VariableTable) const;
93 /// PrintFailureInfo - Print additional information about a failure to match
94 /// involving this pattern.
95 void PrintFailureInfo(const SourceMgr &SM, StringRef Buffer,
96 const StringMap<StringRef> &VariableTable) const;
99 static void AddFixedStringToRegEx(StringRef FixedStr, std::string &TheStr);
100 bool AddRegExToRegEx(StringRef RegExStr, unsigned &CurParen, SourceMgr &SM);
102 /// ComputeMatchDistance - Compute an arbitrary estimate for the quality of
103 /// matching this pattern at the start of \arg Buffer; a distance of zero
104 /// should correspond to a perfect match.
105 unsigned ComputeMatchDistance(StringRef Buffer,
106 const StringMap<StringRef> &VariableTable) const;
110 bool Pattern::ParsePattern(StringRef PatternStr, SourceMgr &SM) {
111 PatternLoc = SMLoc::getFromPointer(PatternStr.data());
113 // Ignore trailing whitespace.
114 while (!PatternStr.empty() &&
115 (PatternStr.back() == ' ' || PatternStr.back() == '\t'))
116 PatternStr = PatternStr.substr(0, PatternStr.size()-1);
118 // Check that there is something on the line.
119 if (PatternStr.empty()) {
120 SM.PrintMessage(PatternLoc, "found empty check string with prefix '" +
121 CheckPrefix+":'", "error");
125 // Check to see if this is a fixed string, or if it has regex pieces.
126 if (PatternStr.size() < 2 ||
127 (PatternStr.find("{{") == StringRef::npos &&
128 PatternStr.find("[[") == StringRef::npos)) {
129 FixedStr = PatternStr;
133 // Paren value #0 is for the fully matched string. Any new parenthesized
134 // values add from their.
135 unsigned CurParen = 1;
137 // Otherwise, there is at least one regex piece. Build up the regex pattern
138 // by escaping scary characters in fixed strings, building up one big regex.
139 while (!PatternStr.empty()) {
141 if (PatternStr.size() >= 2 &&
142 PatternStr[0] == '{' && PatternStr[1] == '{') {
144 // Otherwise, this is the start of a regex match. Scan for the }}.
145 size_t End = PatternStr.find("}}");
146 if (End == StringRef::npos) {
147 SM.PrintMessage(SMLoc::getFromPointer(PatternStr.data()),
148 "found start of regex string with no end '}}'", "error");
152 if (AddRegExToRegEx(PatternStr.substr(2, End-2), CurParen, SM))
154 PatternStr = PatternStr.substr(End+2);
158 // Named RegEx matches. These are of two forms: [[foo:.*]] which matches .*
159 // (or some other regex) and assigns it to the FileCheck variable 'foo'. The
160 // second form is [[foo]] which is a reference to foo. The variable name
161 // itself must be of the form "[a-zA-Z_][0-9a-zA-Z_]*", otherwise we reject
162 // it. This is to catch some common errors.
163 if (PatternStr.size() >= 2 &&
164 PatternStr[0] == '[' && PatternStr[1] == '[') {
165 // Verify that it is terminated properly.
166 size_t End = PatternStr.find("]]");
167 if (End == StringRef::npos) {
168 SM.PrintMessage(SMLoc::getFromPointer(PatternStr.data()),
169 "invalid named regex reference, no ]] found", "error");
173 StringRef MatchStr = PatternStr.substr(2, End-2);
174 PatternStr = PatternStr.substr(End+2);
176 // Get the regex name (e.g. "foo").
177 size_t NameEnd = MatchStr.find(':');
178 StringRef Name = MatchStr.substr(0, NameEnd);
181 SM.PrintMessage(SMLoc::getFromPointer(Name.data()),
182 "invalid name in named regex: empty name", "error");
186 // Verify that the name is well formed.
187 for (unsigned i = 0, e = Name.size(); i != e; ++i)
188 if (Name[i] != '_' &&
189 (Name[i] < 'a' || Name[i] > 'z') &&
190 (Name[i] < 'A' || Name[i] > 'Z') &&
191 (Name[i] < '0' || Name[i] > '9')) {
192 SM.PrintMessage(SMLoc::getFromPointer(Name.data()+i),
193 "invalid name in named regex", "error");
197 // Name can't start with a digit.
198 if (isdigit(Name[0])) {
199 SM.PrintMessage(SMLoc::getFromPointer(Name.data()),
200 "invalid name in named regex", "error");
205 if (NameEnd == StringRef::npos) {
206 VariableUses.push_back(std::make_pair(Name, RegExStr.size()));
210 // Handle [[foo:.*]].
211 VariableDefs.push_back(std::make_pair(Name, CurParen));
215 if (AddRegExToRegEx(MatchStr.substr(NameEnd+1), CurParen, SM))
221 // Handle fixed string matches.
222 // Find the end, which is the start of the next regex.
223 size_t FixedMatchEnd = PatternStr.find("{{");
224 FixedMatchEnd = std::min(FixedMatchEnd, PatternStr.find("[["));
225 AddFixedStringToRegEx(PatternStr.substr(0, FixedMatchEnd), RegExStr);
226 PatternStr = PatternStr.substr(FixedMatchEnd);
233 void Pattern::AddFixedStringToRegEx(StringRef FixedStr, std::string &TheStr) {
234 // Add the characters from FixedStr to the regex, escaping as needed. This
235 // avoids "leaning toothpicks" in common patterns.
236 for (unsigned i = 0, e = FixedStr.size(); i != e; ++i) {
237 switch (FixedStr[i]) {
238 // These are the special characters matched in "p_ere_exp".
254 TheStr += FixedStr[i];
260 bool Pattern::AddRegExToRegEx(StringRef RegexStr, unsigned &CurParen,
264 if (!R.isValid(Error)) {
265 SM.PrintMessage(SMLoc::getFromPointer(RegexStr.data()),
266 "invalid regex: " + Error, "error");
270 RegExStr += RegexStr.str();
271 CurParen += R.getNumMatches();
275 /// Match - Match the pattern string against the input buffer Buffer. This
276 /// returns the position that is matched or npos if there is no match. If
277 /// there is a match, the size of the matched string is returned in MatchLen.
278 size_t Pattern::Match(StringRef Buffer, size_t &MatchLen,
279 StringMap<StringRef> &VariableTable) const {
280 // If this is the EOF pattern, match it immediately.
283 return Buffer.size();
286 // If this is a fixed string pattern, just match it now.
287 if (!FixedStr.empty()) {
288 MatchLen = FixedStr.size();
289 return Buffer.find(FixedStr);
294 // If there are variable uses, we need to create a temporary string with the
296 StringRef RegExToMatch = RegExStr;
298 if (!VariableUses.empty()) {
301 unsigned InsertOffset = 0;
302 for (unsigned i = 0, e = VariableUses.size(); i != e; ++i) {
303 StringMap<StringRef>::iterator it =
304 VariableTable.find(VariableUses[i].first);
305 // If the variable is undefined, return an error.
306 if (it == VariableTable.end())
307 return StringRef::npos;
309 // Look up the value and escape it so that we can plop it into the regex.
311 AddFixedStringToRegEx(it->second, Value);
313 // Plop it into the regex at the adjusted offset.
314 TmpStr.insert(TmpStr.begin()+VariableUses[i].second+InsertOffset,
315 Value.begin(), Value.end());
316 InsertOffset += Value.size();
319 // Match the newly constructed regex.
320 RegExToMatch = TmpStr;
324 SmallVector<StringRef, 4> MatchInfo;
325 if (!Regex(RegExToMatch, Regex::Newline).match(Buffer, &MatchInfo))
326 return StringRef::npos;
328 // Successful regex match.
329 assert(!MatchInfo.empty() && "Didn't get any match");
330 StringRef FullMatch = MatchInfo[0];
332 // If this defines any variables, remember their values.
333 for (unsigned i = 0, e = VariableDefs.size(); i != e; ++i) {
334 assert(VariableDefs[i].second < MatchInfo.size() &&
335 "Internal paren error");
336 VariableTable[VariableDefs[i].first] = MatchInfo[VariableDefs[i].second];
339 MatchLen = FullMatch.size();
340 return FullMatch.data()-Buffer.data();
343 unsigned Pattern::ComputeMatchDistance(StringRef Buffer,
344 const StringMap<StringRef> &VariableTable) const {
345 // Just compute the number of matching characters. For regular expressions, we
346 // just compare against the regex itself and hope for the best.
348 // FIXME: One easy improvement here is have the regex lib generate a single
349 // example regular expression which matches, and use that as the example
351 StringRef ExampleString(FixedStr);
352 if (ExampleString.empty())
353 ExampleString = RegExStr;
355 // Only compare up to the first line in the buffer, or the string size.
356 StringRef BufferPrefix = Buffer.substr(0, ExampleString.size());
357 BufferPrefix = BufferPrefix.split('\n').first;
358 return BufferPrefix.edit_distance(ExampleString);
361 void Pattern::PrintFailureInfo(const SourceMgr &SM, StringRef Buffer,
362 const StringMap<StringRef> &VariableTable) const{
363 // If this was a regular expression using variables, print the current
365 if (!VariableUses.empty()) {
366 for (unsigned i = 0, e = VariableUses.size(); i != e; ++i) {
367 StringRef Var = VariableUses[i].first;
368 StringMap<StringRef>::const_iterator it = VariableTable.find(Var);
369 SmallString<256> Msg;
370 raw_svector_ostream OS(Msg);
372 // Check for undefined variable references.
373 if (it == VariableTable.end()) {
374 OS << "uses undefined variable \"";
375 OS.write_escaped(Var) << "\"";;
377 OS << "with variable \"";
378 OS.write_escaped(Var) << "\" equal to \"";
379 OS.write_escaped(it->second) << "\"";
382 SM.PrintMessage(SMLoc::getFromPointer(Buffer.data()), OS.str(), "note",
387 // Attempt to find the closest/best fuzzy match. Usually an error happens
388 // because some string in the output didn't exactly match. In these cases, we
389 // would like to show the user a best guess at what "should have" matched, to
390 // save them having to actually check the input manually.
391 size_t NumLinesForward = 0;
392 size_t Best = StringRef::npos;
393 double BestQuality = 0;
395 // Use an arbitrary 4k limit on how far we will search.
396 for (size_t i = 0, e = std::min(size_t(4096), Buffer.size()); i != e; ++i) {
397 if (Buffer[i] == '\n')
400 // Patterns have leading whitespace stripped, so skip whitespace when
401 // looking for something which looks like a pattern.
402 if (Buffer[i] == ' ' || Buffer[i] == '\t')
405 // Compute the "quality" of this match as an arbitrary combination of the
406 // match distance and the number of lines skipped to get to this match.
407 unsigned Distance = ComputeMatchDistance(Buffer.substr(i), VariableTable);
408 double Quality = Distance + (NumLinesForward / 100.);
410 if (Quality < BestQuality || Best == StringRef::npos) {
412 BestQuality = Quality;
416 // Print the "possible intended match here" line if we found something
417 // reasonable and not equal to what we showed in the "scanning from here"
419 if (Best && Best != StringRef::npos && BestQuality < 50) {
420 SM.PrintMessage(SMLoc::getFromPointer(Buffer.data() + Best),
421 "possible intended match here", "note");
423 // FIXME: If we wanted to be really friendly we would show why the match
424 // failed, as it can be hard to spot simple one character differences.
428 //===----------------------------------------------------------------------===//
430 //===----------------------------------------------------------------------===//
432 /// CheckString - This is a check that we found in the input file.
434 /// Pat - The pattern to match.
437 /// Loc - The location in the match file that the check string was specified.
440 /// IsCheckNext - This is true if this is a CHECK-NEXT: directive (as opposed
441 /// to a CHECK: directive.
444 /// NotStrings - These are all of the strings that are disallowed from
445 /// occurring between this match string and the previous one (or start of
447 std::vector<std::pair<SMLoc, Pattern> > NotStrings;
449 CheckString(const Pattern &P, SMLoc L, bool isCheckNext)
450 : Pat(P), Loc(L), IsCheckNext(isCheckNext) {}
453 /// CanonicalizeInputFile - Remove duplicate horizontal space from the specified
454 /// memory buffer, free it, and return a new one.
455 static MemoryBuffer *CanonicalizeInputFile(MemoryBuffer *MB) {
456 SmallString<128> NewFile;
457 NewFile.reserve(MB->getBufferSize());
459 for (const char *Ptr = MB->getBufferStart(), *End = MB->getBufferEnd();
461 // Eliminate trailing dosish \r.
462 if (Ptr <= End - 2 && Ptr[0] == '\r' && Ptr[1] == '\n') {
466 // If C is not a horizontal whitespace, skip it.
467 if (*Ptr != ' ' && *Ptr != '\t') {
468 NewFile.push_back(*Ptr);
472 // Otherwise, add one space and advance over neighboring space.
473 NewFile.push_back(' ');
474 while (Ptr+1 != End &&
475 (Ptr[1] == ' ' || Ptr[1] == '\t'))
479 // Free the old buffer and return a new one.
481 MemoryBuffer::getMemBufferCopy(NewFile.str(), MB->getBufferIdentifier());
488 /// ReadCheckFile - Read the check file, which specifies the sequence of
489 /// expected strings. The strings are added to the CheckStrings vector.
490 static bool ReadCheckFile(SourceMgr &SM,
491 std::vector<CheckString> &CheckStrings) {
492 // Open the check file, and tell SourceMgr about it.
493 OwningPtr<MemoryBuffer> File;
495 MemoryBuffer::getFileOrSTDIN(CheckFilename.c_str(), File)) {
496 errs() << "Could not open check file '" << CheckFilename << "': "
497 << ec.message() << '\n';
500 MemoryBuffer *F = File.take();
502 // If we want to canonicalize whitespace, strip excess whitespace from the
503 // buffer containing the CHECK lines.
504 if (!NoCanonicalizeWhiteSpace)
505 F = CanonicalizeInputFile(F);
507 SM.AddNewSourceBuffer(F, SMLoc());
509 // Find all instances of CheckPrefix followed by : in the file.
510 StringRef Buffer = F->getBuffer();
512 std::vector<std::pair<SMLoc, Pattern> > NotMatches;
515 // See if Prefix occurs in the memory buffer.
516 Buffer = Buffer.substr(Buffer.find(CheckPrefix));
518 // If we didn't find a match, we're done.
522 const char *CheckPrefixStart = Buffer.data();
524 // When we find a check prefix, keep track of whether we find CHECK: or
526 bool IsCheckNext = false, IsCheckNot = false;
528 // Verify that the : is present after the prefix.
529 if (Buffer[CheckPrefix.size()] == ':') {
530 Buffer = Buffer.substr(CheckPrefix.size()+1);
531 } else if (Buffer.size() > CheckPrefix.size()+6 &&
532 memcmp(Buffer.data()+CheckPrefix.size(), "-NEXT:", 6) == 0) {
533 Buffer = Buffer.substr(CheckPrefix.size()+7);
535 } else if (Buffer.size() > CheckPrefix.size()+5 &&
536 memcmp(Buffer.data()+CheckPrefix.size(), "-NOT:", 5) == 0) {
537 Buffer = Buffer.substr(CheckPrefix.size()+6);
540 Buffer = Buffer.substr(1);
544 // Okay, we found the prefix, yay. Remember the rest of the line, but
545 // ignore leading and trailing whitespace.
546 Buffer = Buffer.substr(Buffer.find_first_not_of(" \t"));
548 // Scan ahead to the end of line.
549 size_t EOL = Buffer.find_first_of("\n\r");
551 // Remember the location of the start of the pattern, for diagnostics.
552 SMLoc PatternLoc = SMLoc::getFromPointer(Buffer.data());
554 // Parse the pattern.
556 if (P.ParsePattern(Buffer.substr(0, EOL), SM))
559 Buffer = Buffer.substr(EOL);
562 // Verify that CHECK-NEXT lines have at least one CHECK line before them.
563 if (IsCheckNext && CheckStrings.empty()) {
564 SM.PrintMessage(SMLoc::getFromPointer(CheckPrefixStart),
565 "found '"+CheckPrefix+"-NEXT:' without previous '"+
566 CheckPrefix+ ": line", "error");
572 NotMatches.push_back(std::make_pair(SMLoc::getFromPointer(Buffer.data()),
578 // Okay, add the string we captured to the output vector and move on.
579 CheckStrings.push_back(CheckString(P,
582 std::swap(NotMatches, CheckStrings.back().NotStrings);
585 // Add an EOF pattern for any trailing CHECK-NOTs.
586 if (!NotMatches.empty()) {
587 CheckStrings.push_back(CheckString(Pattern(true),
588 SMLoc::getFromPointer(Buffer.data()),
590 std::swap(NotMatches, CheckStrings.back().NotStrings);
593 if (CheckStrings.empty()) {
594 errs() << "error: no check strings found with prefix '" << CheckPrefix
602 static void PrintCheckFailed(const SourceMgr &SM, const CheckString &CheckStr,
604 StringMap<StringRef> &VariableTable) {
605 // Otherwise, we have an error, emit an error message.
606 SM.PrintMessage(CheckStr.Loc, "expected string not found in input",
609 // Print the "scanning from here" line. If the current position is at the
610 // end of a line, advance to the start of the next line.
611 Buffer = Buffer.substr(Buffer.find_first_not_of(" \t\n\r"));
613 SM.PrintMessage(SMLoc::getFromPointer(Buffer.data()), "scanning from here",
616 // Allow the pattern to print additional information if desired.
617 CheckStr.Pat.PrintFailureInfo(SM, Buffer, VariableTable);
620 /// CountNumNewlinesBetween - Count the number of newlines in the specified
622 static unsigned CountNumNewlinesBetween(StringRef Range) {
623 unsigned NumNewLines = 0;
626 Range = Range.substr(Range.find_first_of("\n\r"));
627 if (Range.empty()) return NumNewLines;
631 // Handle \n\r and \r\n as a single newline.
632 if (Range.size() > 1 &&
633 (Range[1] == '\n' || Range[1] == '\r') &&
634 (Range[0] != Range[1]))
635 Range = Range.substr(1);
636 Range = Range.substr(1);
640 int main(int argc, char **argv) {
641 sys::PrintStackTraceOnErrorSignal();
642 PrettyStackTraceProgram X(argc, argv);
643 cl::ParseCommandLineOptions(argc, argv);
647 // Read the expected strings from the check file.
648 std::vector<CheckString> CheckStrings;
649 if (ReadCheckFile(SM, CheckStrings))
652 // Open the file to check and add it to SourceMgr.
653 OwningPtr<MemoryBuffer> File;
655 MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), File)) {
656 errs() << "Could not open input file '" << InputFilename << "': "
657 << ec.message() << '\n';
660 MemoryBuffer *F = File.take();
662 if (F->getBufferSize() == 0) {
663 errs() << "FileCheck error: '" << InputFilename << "' is empty.\n";
667 // Remove duplicate spaces in the input file if requested.
668 if (!NoCanonicalizeWhiteSpace)
669 F = CanonicalizeInputFile(F);
671 SM.AddNewSourceBuffer(F, SMLoc());
673 /// VariableTable - This holds all the current filecheck variables.
674 StringMap<StringRef> VariableTable;
676 // Check that we have all of the expected strings, in order, in the input
678 StringRef Buffer = F->getBuffer();
680 const char *LastMatch = Buffer.data();
682 for (unsigned StrNo = 0, e = CheckStrings.size(); StrNo != e; ++StrNo) {
683 const CheckString &CheckStr = CheckStrings[StrNo];
685 StringRef SearchFrom = Buffer;
687 // Find StrNo in the file.
689 size_t MatchPos = CheckStr.Pat.Match(Buffer, MatchLen, VariableTable);
690 Buffer = Buffer.substr(MatchPos);
692 // If we didn't find a match, reject the input.
693 if (MatchPos == StringRef::npos) {
694 PrintCheckFailed(SM, CheckStr, SearchFrom, VariableTable);
698 StringRef SkippedRegion(LastMatch, Buffer.data()-LastMatch);
700 // If this check is a "CHECK-NEXT", verify that the previous match was on
701 // the previous line (i.e. that there is one newline between them).
702 if (CheckStr.IsCheckNext) {
703 // Count the number of newlines between the previous match and this one.
704 assert(LastMatch != F->getBufferStart() &&
705 "CHECK-NEXT can't be the first check in a file");
707 unsigned NumNewLines = CountNumNewlinesBetween(SkippedRegion);
708 if (NumNewLines == 0) {
709 SM.PrintMessage(CheckStr.Loc,
710 CheckPrefix+"-NEXT: is on the same line as previous match",
712 SM.PrintMessage(SMLoc::getFromPointer(Buffer.data()),
713 "'next' match was here", "note");
714 SM.PrintMessage(SMLoc::getFromPointer(LastMatch),
715 "previous match was here", "note");
719 if (NumNewLines != 1) {
720 SM.PrintMessage(CheckStr.Loc,
722 "-NEXT: is not on the line after the previous match",
724 SM.PrintMessage(SMLoc::getFromPointer(Buffer.data()),
725 "'next' match was here", "note");
726 SM.PrintMessage(SMLoc::getFromPointer(LastMatch),
727 "previous match was here", "note");
732 // If this match had "not strings", verify that they don't exist in the
734 for (unsigned ChunkNo = 0, e = CheckStr.NotStrings.size();
735 ChunkNo != e; ++ChunkNo) {
737 size_t Pos = CheckStr.NotStrings[ChunkNo].second.Match(SkippedRegion,
740 if (Pos == StringRef::npos) continue;
742 SM.PrintMessage(SMLoc::getFromPointer(LastMatch+Pos),
743 CheckPrefix+"-NOT: string occurred!", "error");
744 SM.PrintMessage(CheckStr.NotStrings[ChunkNo].first,
745 CheckPrefix+"-NOT: pattern specified here", "note");
750 // Otherwise, everything is good. Step over the matched text and remember
751 // the position after the match as the end of the last match.
752 Buffer = Buffer.substr(MatchLen);
753 LastMatch = Buffer.data();