39 this->LineNumber = LineNumber;
44 while (!PatternStr.
empty() &&
45 (PatternStr.
back() ==
' ' || PatternStr.
back() ==
'\t'))
46 PatternStr = PatternStr.
substr(0, PatternStr.
size() - 1);
51 "found empty check string with prefix '" + Prefix +
":'");
58 "found non-empty check string for empty check with prefix '" + Prefix +
69 if (!MatchFullLinesHere &&
72 FixedStr = PatternStr;
76 if (MatchFullLinesHere) {
84 unsigned CurParen = 1;
88 while (!PatternStr.
empty()) {
92 size_t End = PatternStr.
find(
"}}");
96 "found start of regex string with no end '}}'");
107 if (AddRegExToRegEx(PatternStr.
substr(2, End - 2), CurParen, SM))
111 PatternStr = PatternStr.
substr(End + 2);
123 size_t End = FindRegexVarEnd(PatternStr.
substr(2), SM);
128 "invalid named regex reference, no ]] found");
133 PatternStr = PatternStr.
substr(End + 4);
136 size_t NameEnd = MatchStr.
find(
':');
141 "invalid name in named regex: empty name");
148 bool IsExpression =
false;
149 for (
unsigned i = 0, e = Name.
size(); i != e; ++i) {
153 if (Name[i] ==
'@') {
157 "invalid name in named regex definition");
164 if (Name[i] !=
'_' && !isalnum(Name[i]) &&
165 (!IsExpression || (Name[i] !=
'+' && Name[i] !=
'-'))) {
173 if (isdigit(static_cast<unsigned char>(Name[0]))) {
175 "invalid name in named regex");
183 if (VariableDefs.find(Name) != VariableDefs.end()) {
184 unsigned VarParenNum = VariableDefs[
Name];
185 if (VarParenNum < 1 || VarParenNum > 9) {
188 "Can't back-reference more than 9 variables");
191 AddBackrefToRegEx(VarParenNum);
193 VariableUses.push_back(std::make_pair(Name, RegExStr.size()));
199 VariableDefs[
Name] = CurParen;
203 if (AddRegExToRegEx(MatchStr.
substr(NameEnd + 1), CurParen, SM))
211 size_t FixedMatchEnd = PatternStr.
find(
"{{");
212 FixedMatchEnd = std::min(FixedMatchEnd, PatternStr.
find(
"[["));
214 PatternStr = PatternStr.
substr(FixedMatchEnd);
217 if (MatchFullLinesHere) {
226 bool FileCheckPattern::AddRegExToRegEx(
StringRef RS,
unsigned &CurParen,
SourceMgr &SM) {
231 "invalid regex: " + Error);
235 RegExStr += RS.
str();
240 void FileCheckPattern::AddBackrefToRegEx(
unsigned BackrefNum) {
241 assert(BackrefNum >= 1 && BackrefNum <= 9 &&
"Invalid backref number");
242 std::string Backref = std::string(
"\\") + std::string(1,
'0' + BackrefNum);
249 bool FileCheckPattern::EvaluateExpression(
StringRef Expr, std::string &
Value)
const {
258 else if (Expr[0] !=
'-')
280 return Buffer.
size();
284 if (!FixedStr.
empty()) {
285 MatchLen = FixedStr.
size();
286 return Buffer.
find(FixedStr);
295 if (!VariableUses.empty()) {
298 unsigned InsertOffset = 0;
299 for (
const auto &VariableUse : VariableUses) {
302 if (VariableUse.first[0] ==
'@') {
303 if (!EvaluateExpression(VariableUse.first, Value))
307 VariableTable.
find(VariableUse.first);
309 if (it == VariableTable.
end())
317 TmpStr.insert(TmpStr.begin() + VariableUse.second + InsertOffset,
318 Value.begin(), Value.end());
319 InsertOffset += Value.size();
323 RegExToMatch = TmpStr;
331 assert(!MatchInfo.
empty() &&
"Didn't get any match");
335 for (
const auto &VariableDef : VariableDefs) {
336 assert(VariableDef.second < MatchInfo.
size() &&
"Internal paren error");
337 VariableTable[VariableDef.first] = MatchInfo[VariableDef.second];
344 MatchLen = FullMatch.size() - MatchStartSkip;
345 return FullMatch.data() - Buffer.
data() + MatchStartSkip;
353 FileCheckPattern::ComputeMatchDistance(
StringRef Buffer,
362 if (ExampleString.
empty())
363 ExampleString = RegExStr;
367 BufferPrefix = BufferPrefix.
split(
'\n').first;
376 if (!VariableUses.empty()) {
377 for (
const auto &VariableUse : VariableUses) {
383 if (EvaluateExpression(Var, Value)) {
384 OS <<
"with expression \"";
388 OS <<
"uses incorrect expression \"";
395 if (it == VariableTable.
end()) {
396 OS <<
"uses undefined variable \"";
399 OS <<
"with variable \"";
418 StringRef Buffer,
size_t Pos,
size_t Len,
419 std::vector<FileCheckDiag> *Diags,
420 bool AdjustPrevDiag =
false) {
426 Diags->rbegin()->MatchTy = MatchTy;
428 Diags->emplace_back(SM, CheckTy, Loc, MatchTy, Range);
436 std::vector<FileCheckDiag> *Diags)
const {
441 size_t NumLinesForward = 0;
443 double BestQuality = 0;
446 for (
size_t i = 0, e = std::min(
size_t(4096), Buffer.
size()); i != e; ++i) {
447 if (Buffer[i] ==
'\n')
452 if (Buffer[i] ==
' ' || Buffer[i] ==
'\t')
457 unsigned Distance = ComputeMatchDistance(Buffer.
substr(i), VariableTable);
458 double Quality = Distance + (NumLinesForward / 100.);
462 BestQuality = Quality;
474 "possible intended match here");
490 size_t BracketDepth = 0;
492 while (!Str.
empty()) {
493 if (Str.
startswith(
"]]") && BracketDepth == 0)
495 if (Str[0] ==
'\\') {
507 if (BracketDepth == 0) {
510 "missing closing \"]\" for regex variable");
534 if (Ptr <= End - 2 && Ptr[0] ==
'\r' && Ptr[1] ==
'\n') {
540 if (Req.NoCanonicalizeWhiteSpace || (*Ptr !=
' ' && *Ptr !=
'\t')) {
547 while (Ptr + 1 != End && (Ptr[1] ==
' ' || Ptr[1] ==
'\t'))
560 : CheckTy(CheckTy), MatchTy(MatchTy) {
573 return (isalnum(c) || c ==
'-' || c ==
'_');
577 assert(Count > 0 &&
"zero and negative counts are not supported");
579 "count supported only for plain CHECK directives");
591 return Prefix.
str() +
"-COUNT";
594 return Prefix.
str() +
"-NEXT";
596 return Prefix.
str() +
"-SAME";
598 return Prefix.
str() +
"-NOT";
600 return Prefix.
str() +
"-DAG";
602 return Prefix.
str() +
"-LABEL";
604 return Prefix.
str() +
"-EMPTY";
606 return "implicit EOF";
615 static std::pair<Check::FileCheckType, StringRef>
620 char NextChar = Buffer[Prefix.
size()];
630 if (Rest.consume_front(
"COUNT-")) {
632 if (Rest.consumeInteger(10, Count))
635 if (Count <= 0 || Count > INT32_MAX)
637 if (!Rest.consume_front(
":"))
642 if (Rest.consume_front(
"NEXT:"))
645 if (Rest.consume_front(
"SAME:"))
648 if (Rest.consume_front(
"NOT:"))
651 if (Rest.consume_front(
"DAG:"))
654 if (Rest.consume_front(
"LABEL:"))
657 if (Rest.consume_front(
"EMPTY:"))
661 if (Rest.startswith(
"DAG-NOT:") || Rest.startswith(
"NOT-DAG:") ||
662 Rest.startswith(
"NEXT-NOT:") || Rest.startswith(
"NOT-NEXT:") ||
663 Rest.startswith(
"SAME-NOT:") || Rest.startswith(
"NOT-SAME:") ||
664 Rest.startswith(
"EMPTY-NOT:") || Rest.startswith(
"NOT-EMPTY:"))
700 static std::pair<StringRef, StringRef>
705 while (!Buffer.
empty()) {
707 if (!PrefixRE.
match(Buffer, &Matches))
716 "Prefix doesn't start inside of buffer!");
717 size_t Loc = Prefix.
data() - Buffer.
data();
720 LineNumber += Skipped.
count(
'\n');
730 std::tie(CheckTy, AfterSuffix) =
FindCheckType(Buffer, Prefix);
734 return {
Prefix, AfterSuffix};
753 std::vector<FileCheckString> &CheckStrings) {
754 std::vector<FileCheckPattern> ImplicitNegativeChecks;
755 for (
const auto &PatternString : Req.ImplicitCheckNot) {
758 std::string
Prefix =
"-implicit-check-not='";
759 std::string Suffix =
"'";
761 Prefix + PatternString + Suffix,
"command line");
764 CmdLine->getBuffer().
substr(Prefix.size(), PatternString.size());
768 ImplicitNegativeChecks.back().ParsePattern(PatternInBuffer,
769 "IMPLICIT-CHECK", SM, 0, Req);
772 std::vector<FileCheckPattern> DagNotMatches = ImplicitNegativeChecks;
776 unsigned LineNumber = 1;
784 std::tie(UsedPrefix, AfterSuffix) =
786 if (UsedPrefix.
empty())
789 "Failed to move Buffer's start forward, or pointed prefix outside " 793 "Parsing after suffix doesn't start inside of buffer!");
796 const char *UsedPrefixStart = UsedPrefix.
data();
806 "unsupported -NOT combo on prefix '" + UsedPrefix +
"'");
813 "invalid count in -COUNT specification on prefix '" +
820 if (!(Req.NoCanonicalizeWhiteSpace && Req.MatchFullLines))
831 if (P.ParsePattern(Buffer.
substr(0, EOL), UsedPrefix, SM, LineNumber, Req))
838 "found '" + UsedPrefix +
"-LABEL:'" 839 " with variable definition or use");
843 Buffer = Buffer.
substr(EOL);
848 CheckStrings.empty()) {
854 "found '" + UsedPrefix +
"-" + Type +
855 "' without previous '" + UsedPrefix +
": line");
861 DagNotMatches.push_back(P);
866 CheckStrings.emplace_back(P, UsedPrefix, PatternLoc);
867 std::swap(DagNotMatches, CheckStrings.back().DagNotStrings);
868 DagNotMatches = ImplicitNegativeChecks;
873 if (!DagNotMatches.empty()) {
876 std::swap(DagNotMatches, CheckStrings.back().DagNotStrings);
879 if (CheckStrings.empty()) {
880 errs() <<
"error: no check strings found with prefix" 881 << (Req.CheckPrefixes.size() > 1 ?
"es " :
" ");
882 auto I = Req.CheckPrefixes.begin();
883 auto E = Req.CheckPrefixes.end();
885 errs() <<
"\'" << *
I <<
":'";
889 errs() <<
", \'" << *
I <<
":'";
903 std::vector<FileCheckDiag> *Diags) {
913 SM, Loc, Pat.
getCheckTy(), Buffer, MatchPos, MatchLen, Diags);
914 std::string Message =
formatv(
"{0}: {1} string found in input",
916 (ExpectedMatch ?
"expected" :
"excluded"))
919 Message +=
formatv(
" ({0} out of {1})", MatchedCount, Pat.
getCount()).str();
932 std::vector<FileCheckDiag> *Diags) {
934 MatchedCount, Buffer, VariableTable, MatchPos, MatchLen, Req,
943 std::vector<FileCheckDiag> *Diags) {
944 if (!ExpectedMatch && !VerboseVerbose)
948 std::string Message =
formatv(
"{0}: {1} string not found in input",
950 (ExpectedMatch ?
"expected" :
"excluded"))
953 Message +=
formatv(
" ({0} out of {1})", MatchedCount, Pat.
getCount()).str();
978 std::vector<FileCheckDiag> *Diags) {
980 MatchedCount, Buffer, VariableTable, VerboseVerbose, Diags);
985 const char *&FirstNewLine) {
986 unsigned NumNewLines = 0;
996 if (Range.
size() > 1 && (Range[1] ==
'\n' || Range[1] ==
'\r') &&
997 (Range[0] != Range[1]))
1001 if (NumNewLines == 1)
1002 FirstNewLine = Range.
begin();
1008 bool IsLabelScanMode,
size_t &MatchLen,
1011 std::vector<FileCheckDiag> *Diags)
const {
1013 std::vector<const FileCheckPattern *> NotStrings;
1019 if (!IsLabelScanMode) {
1021 LastPos = CheckDag(SM, Buffer, NotStrings, VariableTable, Req, Diags);
1027 size_t LastMatchEnd = LastPos;
1028 size_t FirstMatchPos = 0;
1031 assert(Pat.getCount() != 0 &&
"pattern count can not be zero");
1032 for (
int i = 1; i <= Pat.getCount(); i++) {
1034 size_t CurrentMatchLen;
1036 size_t MatchPos = Pat.Match(MatchBuffer, CurrentMatchLen, VariableTable);
1038 FirstMatchPos = LastPos + MatchPos;
1042 PrintNoMatch(
true, SM, *
this, i, MatchBuffer, VariableTable,
1046 PrintMatch(
true, SM, *
this, i, MatchBuffer, VariableTable, MatchPos,
1047 CurrentMatchLen, Req, Diags);
1050 LastMatchEnd += MatchPos + CurrentMatchLen;
1053 MatchLen = LastMatchEnd - FirstMatchPos;
1057 if (!IsLabelScanMode) {
1058 size_t MatchPos = FirstMatchPos - LastPos;
1066 Pat.getCheckTy(), MatchBuffer, MatchPos, MatchLen,
1075 Pat.getCheckTy(), MatchBuffer, MatchPos, MatchLen,
1082 if (
CheckNot(SM, SkippedRegion, NotStrings, VariableTable, Req, Diags))
1086 return FirstMatchPos;
1103 ->getBufferStart() &&
1104 "CHECK-NEXT and CHECK-EMPTY can't be the first check in a file");
1106 const char *FirstNewLine =
nullptr;
1109 if (NumNewLines == 0) {
1111 CheckName +
": is on the same line as previous match");
1113 "'next' match was here");
1115 "previous match ended here");
1119 if (NumNewLines != 1) {
1122 ": is not on the line after the previous match");
1124 "'next' match was here");
1126 "previous match ended here");
1128 "non-matching line after previous match is here");
1144 ->getBufferStart() &&
1145 "CHECK-SAME can't be the first check in a file");
1147 const char *FirstNewLine =
nullptr;
1150 if (NumNewLines != 0) {
1153 "-SAME: is not on the same line as the previous match");
1155 "'next' match was here");
1157 "previous match ended here");
1167 const std::vector<const FileCheckPattern *> &NotStrings,
1169 std::vector<FileCheckDiag> *Diags)
const {
1173 size_t MatchLen = 0;
1174 size_t Pos = Pat->Match(Buffer, MatchLen, VariableTable);
1182 PrintMatch(
false, SM,
Prefix, Pat->getLoc(), *Pat, 1, Buffer, VariableTable,
1183 Pos, MatchLen, Req, Diags);
1194 std::vector<const FileCheckPattern *> &NotStrings,
1197 std::vector<FileCheckDiag> *Diags)
const {
1198 if (DagNotStrings.empty())
1202 size_t StartPos = 0;
1211 std::list<MatchRange> MatchRanges;
1215 for (
auto PatItr = DagNotStrings.begin(), PatEnd = DagNotStrings.end();
1216 PatItr != PatEnd; ++PatItr) {
1220 "Invalid CHECK-DAG or CHECK-NOT!");
1223 NotStrings.push_back(&Pat);
1230 size_t MatchLen = 0, MatchPos = StartPos;
1234 for (
auto MI = MatchRanges.begin(), ME = MatchRanges.end();
true; ++
MI) {
1236 size_t MatchPosBuf = Pat.
Match(MatchBuffer, MatchLen, VariableTable);
1245 MatchPos += MatchPosBuf;
1248 VariableTable, MatchPos, MatchLen, Req, Diags);
1249 MatchRange M{MatchPos, MatchPos + MatchLen};
1250 if (Req.AllowDeprecatedDagOverlap) {
1254 if (MatchRanges.empty())
1255 MatchRanges.insert(MatchRanges.end(), M);
1257 auto Block = MatchRanges.begin();
1258 Block->Pos = std::min(Block->Pos, M.Pos);
1259 Block->End =
std::max(Block->End, M.End);
1264 bool Overlap =
false;
1265 for (;
MI != ME; ++
MI) {
1266 if (M.Pos <
MI->End) {
1269 Overlap =
MI->Pos < M.End;
1275 MatchRanges.insert(
MI, M);
1278 if (Req.VerboseVerbose) {
1281 SMRange OldRange(OldStart, OldEnd);
1283 "match discarded, overlaps earlier DAG match here",
1292 MatchPos, MatchLen, Req, Diags);
1295 if (std::next(PatItr) == PatEnd ||
1297 if (!NotStrings.empty()) {
1302 Buffer.
slice(StartPos, MatchRanges.begin()->Pos);
1303 if (
CheckNot(SM, SkippedRegion, NotStrings, VariableTable, Req, Diags))
1310 StartPos = MatchRanges.rbegin()->End;
1312 MatchRanges.clear();
1321 Regex Validator(
"^[a-zA-Z0-9_-]*$");
1322 return Validator.
match(CheckPrefix);
1333 if (!PrefixSet.
insert(Prefix).second)
1351 if (Req.CheckPrefixes.empty())
1352 Req.CheckPrefixes.push_back(
"CHECK");
1358 if (Prefix != Req.CheckPrefixes.
front())
1361 PrefixRegexStr.
append(Prefix);
1364 return Regex(PrefixRegexStr);
1371 for (
const auto &Var : VariableTable)
1372 if (Var.first()[0] !=
'$')
1375 for (
const auto &Var : LocalVars)
1376 VariableTable.erase(Var);
1385 std::vector<FileCheckDiag> *Diags) {
1386 bool ChecksFailed =
false;
1391 for (
const auto&
Def : Req.GlobalDefines)
1394 unsigned i = 0, j = 0, e = CheckStrings.
size();
1398 CheckRegion = Buffer;
1407 size_t MatchLabelLen = 0;
1408 size_t MatchLabelPos = CheckLabelStr.
Check(
1409 SM, Buffer,
true, MatchLabelLen, VariableTable, Req, Diags);
1414 CheckRegion = Buffer.
substr(0, MatchLabelPos + MatchLabelLen);
1415 Buffer = Buffer.
substr(MatchLabelPos + MatchLabelLen);
1419 if (Req.EnableVarScope)
1422 for (; i != j; ++i) {
1427 size_t MatchLen = 0;
1428 size_t MatchPos = CheckStr.
Check(SM, CheckRegion,
false, MatchLen,
1429 VariableTable, Req, Diags);
1432 ChecksFailed =
true;
1437 CheckRegion = CheckRegion.
substr(MatchPos + MatchLen);
1445 return !ChecksFailed;
Represents a range in source code.
Indicates a good match for an expected pattern.
bool ValidateCheckPrefixes()
unsigned FindBufferContainingLoc(SMLoc Loc) const
Return the ID of the buffer containing the specified location.
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Indicates no match for an excluded pattern.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
This class represents lattice values for constants.
Indicates a discarded match for an expected pattern.
void PrintFuzzyMatch(const SourceMgr &SM, StringRef Buffer, const StringMap< StringRef > &VariableTable, std::vector< FileCheckDiag > *Diags) const
void push_back(const T &Elt)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
bool CheckSame(const SourceMgr &SM, StringRef Buffer) const
Verify there is no newline in the given buffer.
static std::string escape(StringRef String)
Turn String into a regex by escaping its special characters.
iterator find(StringRef Key)
A raw_ostream that writes to an SmallVector or SmallString.
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
std::string getDescription(StringRef Prefix) const
static std::pair< StringRef, StringRef > split(StringRef Str, char Separator)
Checked version of split, to ensure mandatory subparts.
Marks when parsing found a -NOT check combined with another CHECK suffix.
size_t getBufferSize() const
void reserve(size_type N)
Compile for newline-sensitive matching.
std::pair< unsigned, unsigned > getLineAndColumn(SMLoc Loc, unsigned BufferID=0) const
Find the line and column number for the specified location in the specified file. ...
LLVM_NODISCARD unsigned edit_distance(StringRef Other, bool AllowReplacements=true, unsigned MaxEditDistance=0) const
Determine the edit distance between this string and another string.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
bool CheckNext(const SourceMgr &SM, StringRef Buffer) const
Verify there is a single line in the given buffer.
static LLVM_ATTRIBUTE_ALWAYS_INLINE bool CheckSame(const unsigned char *MatcherTable, unsigned &MatcherIndex, SDValue N, const SmallVectorImpl< std::pair< SDValue, SDNode *>> &RecordedNodes)
CheckSame - Implements OP_CheckSame.
StringRef Prefix
Which prefix name this check matched.
bool match(Val *V, const Pattern &P)
FileCheckPattern Pat
The pattern to match.
void PrintMessage(raw_ostream &OS, SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges=None, ArrayRef< SMFixIt > FixIts=None, bool ShowColors=true) const
Emit a message about the specified location with the specified string.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
bool NoCanonicalizeWhiteSpace
bool ParsePattern(StringRef PatternStr, StringRef Prefix, SourceMgr &SM, unsigned LineNumber, const FileCheckRequest &Req)
Parses the given string into the Pattern.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM_NODISCARD size_t count(char C) const
Return the number of occurrences of C in the string.
SMLoc Loc
The location in the match file that the check string was specified.
Check::FileCheckType CheckTy
What is the FileCheck directive for this diagnostic?
Indicates a match for an expected pattern, but the match is on the wrong line.
Marks when parsing found a -COUNT directive with invalid count value.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
bool CheckNot(const SourceMgr &SM, StringRef Buffer, const std::vector< const FileCheckPattern *> &NotStrings, StringMap< StringRef > &VariableTable, const FileCheckRequest &Req, std::vector< FileCheckDiag > *Diags) const
Verify there's no "not strings" in the given buffer.
const MemoryBuffer * getMemoryBuffer(unsigned i) const
std::string itostr(int64_t X)
static std::pair< Check::FileCheckType, StringRef > FindCheckType(StringRef Buffer, StringRef Prefix)
static unsigned CountNumNewlinesBetween(StringRef Range, const char *&FirstNewLine)
Count the number of newlines in the specified range.
unsigned AddNewSourceBuffer(std::unique_ptr< MemoryBuffer > F, SMLoc IncludeLoc)
Add a new source buffer to this source manager.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
StringRef CanonicalizeFile(MemoryBuffer &MB, SmallVectorImpl< char > &OutputBuffer)
Canonicalize whitespaces in the file.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Contains info about various FileCheck options.
static bool ValidateCheckPrefix(StringRef CheckPrefix)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
static void PrintNoMatch(bool ExpectedMatch, const SourceMgr &SM, StringRef Prefix, SMLoc Loc, const FileCheckPattern &Pat, int MatchedCount, StringRef Buffer, StringMap< StringRef > &VariableTable, bool VerboseVerbose, std::vector< FileCheckDiag > *Diags)
void PrintVariableUses(const SourceMgr &SM, StringRef Buffer, const StringMap< StringRef > &VariableTable, SMRange MatchRange=None) const
void append(in_iter S, in_iter E)
Append from an iterator pair.
A check that we found in the input file.
size_t Check(const SourceMgr &SM, StringRef Buffer, bool IsLabelScanMode, size_t &MatchLen, StringMap< StringRef > &VariableTable, FileCheckRequest &Req, std::vector< FileCheckDiag > *Diags) const
Match check string and its "not strings" and/or "dag strings".
FileCheckDiag(const SourceMgr &SM, const Check::FileCheckType &CheckTy, SMLoc CheckLoc, MatchType MatchTy, SMRange InputRange)
The instances of the Type class are immutable: once they are created, they are never changed...
bool ReadCheckFile(SourceMgr &SM, StringRef Buffer, Regex &PrefixRE, std::vector< FileCheckString > &CheckStrings)
Read the check file, which specifies the sequence of expected strings.
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static void PrintMatch(bool ExpectedMatch, const SourceMgr &SM, StringRef Prefix, SMLoc Loc, const FileCheckPattern &Pat, int MatchedCount, StringRef Buffer, StringMap< StringRef > &VariableTable, size_t MatchPos, size_t MatchLen, const FileCheckRequest &Req, std::vector< FileCheckDiag > *Diags)
LLVM_NODISCARD size_t find_first_not_of(char C, size_t From=0) const
Find the first character in the string that is not C or npos if not found.
bool CheckInput(SourceMgr &SM, StringRef Buffer, ArrayRef< FileCheckString > CheckStrings, std::vector< FileCheckDiag > *Diags=nullptr)
Check the input to FileCheck provided in the Buffer against the CheckStrings read from the check file...
unsigned CheckLine
Where is the FileCheck directive for this diagnostic?
SMLoc getLoc() const
Returns the location in source code.
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
Check::FileCheckType getCheckTy() const
LLVM_NODISCARD char back() const
back - Get the last character in the string.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
std::pair< typename base::iterator, bool > insert(StringRef Key)
size_t Match(StringRef Buffer, size_t &MatchLen, StringMap< StringRef > &VariableTable) const
Matches the pattern string against the input buffer Buffer.
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
Indicates the pattern only matches the end of file.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
static size_t SkipWord(StringRef Str, size_t Loc)
raw_ostream & write_escaped(StringRef Str, bool UseHexEscapes=false)
Output Str, turning '\', '', ' ', '"', and anything that doesn't satisfy llvm::isPrint into an escape...
Indicates a fuzzy match that serves as a suggestion for the next intended match for an expected patte...
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
size_t CheckDag(const SourceMgr &SM, StringRef Buffer, std::vector< const FileCheckPattern *> &NotStrings, StringMap< StringRef > &VariableTable, const FileCheckRequest &Req, std::vector< FileCheckDiag > *Diags) const
Match "dag strings" and their mixed "not strings".
static std::pair< StringRef, StringRef > FindFirstMatchingPrefix(Regex &PrefixRE, StringRef &Buffer, unsigned &LineNumber, Check::FileCheckType &CheckTy)
Search the buffer for the first prefix in the prefix regular expression.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Indicates no match for an expected pattern, but this might follow good matches when multiple matches ...
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
bool isValid(std::string &Error) const
isValid - returns the error encountered during regex compilation, or matching, if any...
StringRef str()
Return a StringRef for the vector contents.
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
This interface provides simple read-only access to a block of memory, and provides simple methods for...
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
static std::unique_ptr< MemoryBuffer > getMemBufferCopy(StringRef InputData, const Twine &BufferName="")
Open the specified memory range as a MemoryBuffer, copying the contents and taking ownership of it...
static SMRange ProcessMatchResult(FileCheckDiag::MatchType MatchTy, const SourceMgr &SM, SMLoc Loc, Check::FileCheckType CheckTy, StringRef Buffer, size_t Pos, size_t Len, std::vector< FileCheckDiag > *Diags, bool AdjustPrevDiag=false)
unsigned getNumMatches() const
getNumMatches - In a valid regex, return the number of parenthesized matches it contains.
static SMLoc getFromPointer(const char *Ptr)
unsigned InputStartLine
The search range if MatchTy is MatchNoneAndExcluded or MatchNoneButExpected, or the match range other...
Indicates a match for an excluded pattern.
const char * getBufferEnd() const
FileCheckType & setCount(int C)
pointer data()
Return a pointer to the vector's buffer, even if empty().
LLVM_NODISCARD bool empty() const
Regex buildCheckPrefixRegex()
LLVM_NODISCARD size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
const char * getBufferStart() const
static bool IsPartOfWord(char c)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM_NODISCARD char front() const
front - Get the first character in the string.
LLVM Value Representation.
StringSet - A wrapper for StringMap that provides set-like functionality.
bool match(StringRef String, SmallVectorImpl< StringRef > *Matches=nullptr)
matches - Match the regex against a given String.
StringRef - Represent a constant reference to a string, i.e.
static void ClearLocalVars(StringMap< StringRef > &VariableTable)
MatchType
What type of match result does this diagnostic describe?
Represents a location in source code.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t find(char C, size_t From=0) const
Search for the first character C in the string.