LLVM  9.0.0svn
FileCheck.h
Go to the documentation of this file.
1 //==-- llvm/Support/FileCheck.h ---------------------------*- C++ -*-==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 /// \file This file has some utilities to use FileCheck as an API
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_SUPPORT_FILECHECK_H
14 #define LLVM_SUPPORT_FILECHECK_H
15 
16 #include "llvm/ADT/StringMap.h"
18 #include "llvm/Support/Regex.h"
19 #include "llvm/Support/SourceMgr.h"
20 #include <vector>
21 #include <map>
22 
23 namespace llvm {
24 
25 /// Contains info about various FileCheck options.
27  std::vector<std::string> CheckPrefixes;
29  std::vector<std::string> ImplicitCheckNot;
30  std::vector<std::string> GlobalDefines;
31  bool AllowEmptyInput = false;
32  bool MatchFullLines = false;
33  bool EnableVarScope = false;
35  bool Verbose = false;
36  bool VerboseVerbose = false;
37 };
38 
39 //===----------------------------------------------------------------------===//
40 // Numeric substitution handling code.
41 //===----------------------------------------------------------------------===//
42 
43 /// Class representing a numeric variable with a given value in a numeric
44 /// expression. Each definition of a variable gets its own instance of this
45 /// class. Variable uses share the same instance as their respective
46 /// definition.
48 private:
49  /// Name of the numeric variable.
51 
52  /// Value of numeric variable, if defined, or None otherwise.
54 
55  /// Line number where this variable is defined. Used to determine whether a
56  /// variable is defined on the same line as a given use.
57  size_t DefLineNumber;
58 
59 public:
60  /// Constructor for a variable \p Name defined at line \p DefLineNumber.
61  FileCheckNumericVariable(size_t DefLineNumber, StringRef Name)
62  : Name(Name), DefLineNumber(DefLineNumber) {}
63 
64  /// Constructor for numeric variable \p Name with a known \p Value at parse
65  /// time (e.g. the @LINE numeric variable).
66  FileCheckNumericVariable(StringRef Name, uint64_t Value)
67  : Name(Name), Value(Value), DefLineNumber(0) {}
68 
69  /// \returns name of that numeric variable.
70  StringRef getName() const { return Name; }
71 
72  /// \returns value of this numeric variable.
73  Optional<uint64_t> getValue() const { return Value; }
74 
75  /// Sets value of this numeric variable if not defined. \returns whether the
76  /// variable was already defined.
77  bool setValue(uint64_t Value);
78 
79  /// Clears value of this numeric variable. \returns whether the variable was
80  /// already undefined.
81  bool clearValue();
82 
83  /// \returns the line number where this variable is defined.
84  size_t getDefLineNumber() { return DefLineNumber; }
85 };
86 
87 /// Type of functions evaluating a given binary operation.
88 using binop_eval_t = uint64_t (*)(uint64_t, uint64_t);
89 
90 /// Class representing a numeric expression consisting of either a single
91 /// numeric variable or a binary operation between a numeric variable and an
92 /// immediate.
94 private:
95  /// Left operand.
97 
98  /// Right operand.
99  uint64_t RightOp;
100 
101  /// Pointer to function that can evaluate this binary operation.
102  binop_eval_t EvalBinop;
103 
104 public:
106  FileCheckNumericVariable *OperandLeft, uint64_t OperandRight)
107  : LeftOp(OperandLeft), RightOp(OperandRight), EvalBinop(EvalBinop) {}
108 
109  /// Evaluates the value of this numeric expression, using EvalBinop to
110  /// perform the binary operation it consists of. \returns None if the numeric
111  /// variable used is undefined, or the expression value otherwise.
112  Optional<uint64_t> eval() const;
113 
114  /// \returns the name of the undefined variable used in this expression if
115  /// any or an empty string otherwise.
116  StringRef getUndefVarName() const;
117 };
118 
120 
121 /// Class representing a substitution to perform in the RegExStr string.
123 protected:
124  /// Pointer to a class instance holding, among other things, the table with
125  /// the values of live string variables at the start of any given CHECK line.
126  /// Used for substituting string variables with the text they were defined
127  /// as. Numeric expressions are linked to the numeric variables they use at
128  /// parse time and directly access the value of the numeric variable to
129  /// evaluate their value.
131 
132  /// The string that needs to be substituted for something else. For a
133  /// string variable this is its name, otherwise this is the whole numeric
134  /// expression.
136 
137  // Index in RegExStr of where to do the substitution.
138  size_t InsertIdx;
139 
140 public:
142  size_t InsertIdx)
143  : Context(Context), FromStr(VarName), InsertIdx(InsertIdx) {}
144 
145  virtual ~FileCheckSubstitution() = default;
146 
147  /// \returns the string to be substituted for something else.
148  StringRef getFromString() const { return FromStr; }
149 
150  /// \returns the index where the substitution is to be performed in RegExStr.
151  size_t getIndex() const { return InsertIdx; }
152 
153  /// \returns a string containing the result of the substitution represented
154  /// by this class instance or None if substitution failed.
155  virtual Optional<std::string> getResult() const = 0;
156 
157  /// \returns the name of the variable used in this substitution if undefined,
158  /// or an empty string otherwise.
159  virtual StringRef getUndefVarName() const = 0;
160 };
161 
163 public:
165  StringRef VarName, size_t InsertIdx)
166  : FileCheckSubstitution(Context, VarName, InsertIdx) {}
167 
168  /// \returns the text that the string variable in this substitution matched
169  /// when defined, or None if the variable is undefined.
170  Optional<std::string> getResult() const override;
171 
172  /// \returns the name of the string variable used in this substitution if
173  /// undefined, or an empty string otherwise.
174  StringRef getUndefVarName() const override;
175 };
176 
178 private:
179  /// Pointer to the class representing the numeric expression whose value is
180  /// to be substituted.
181  FileCheckNumExpr *NumExpr;
182 
183 public:
185  FileCheckNumExpr *NumExpr, size_t InsertIdx)
186  : FileCheckSubstitution(Context, Expr, InsertIdx), NumExpr(NumExpr) {}
187 
188  /// \returns a string containing the result of evaluating the numeric
189  /// expression in this substitution, or None if evaluation failed.
190  Optional<std::string> getResult() const override;
191 
192  /// \returns the name of the numeric variable used in this substitution if
193  /// undefined, or an empty string otherwise.
194  StringRef getUndefVarName() const override;
195 };
196 
197 //===----------------------------------------------------------------------===//
198 // Pattern handling code.
199 //===----------------------------------------------------------------------===//
200 
201 namespace Check {
202 
212 
213  /// Indicates the pattern only matches the end of file. This is used for
214  /// trailing CHECK-NOTs.
216 
217  /// Marks when parsing found a -NOT check combined with another CHECK suffix.
219 
220  /// Marks when parsing found a -COUNT directive with invalid count value.
222 };
223 
226  int Count; ///< optional Count for some checks
227 
228 public:
229  FileCheckType(FileCheckKind Kind = CheckNone) : Kind(Kind), Count(1) {}
230  FileCheckType(const FileCheckType &) = default;
231 
232  operator FileCheckKind() const { return Kind; }
233 
234  int getCount() const { return Count; }
235  FileCheckType &setCount(int C);
236 
237  // \returns a description of \p Prefix.
238  std::string getDescription(StringRef Prefix) const;
239 };
240 } // namespace Check
241 
242 struct FileCheckDiag;
243 
244 /// Class holding the FileCheckPattern global state, shared by all patterns:
245 /// tables holding values of variables and whether they are defined or not at
246 /// any given time in the matching process.
248  friend class FileCheckPattern;
249 
250 private:
251  /// When matching a given pattern, this holds the value of all the string
252  /// variables defined in previous patterns. In a pattern, only the last
253  /// definition for a given variable is recorded in this table.
254  /// Back-references are used for uses after any the other definition.
255  StringMap<StringRef> GlobalVariableTable;
256 
257  /// Map of all string variables defined so far. Used at parse time to detect
258  /// a name conflict between a numeric variable and a string variable when
259  /// the former is defined on a later line than the latter.
260  StringMap<bool> DefinedVariableTable;
261 
262  /// When matching a given pattern, this holds the pointers to the classes
263  /// representing the last definitions of numeric variables defined in
264  /// previous patterns. Earlier definitions of the variables, if any, have
265  /// their own class instance not referenced by this table. When matching a
266  /// pattern all definitions for that pattern are recorded in the
267  /// NumericVariableDefs table in the FileCheckPattern instance of that
268  /// pattern.
269  StringMap<FileCheckNumericVariable *> GlobalNumericVariableTable;
270 
271  /// Vector holding pointers to all parsed numeric expressions. Used to
272  /// automatically free the numeric expressions once they are guaranteed to no
273  /// longer be used.
274  std::vector<std::unique_ptr<FileCheckNumExpr>> NumExprs;
275 
276  /// Vector holding pointers to all parsed numeric variables. Used to
277  /// automatically free them once they are guaranteed to no longer be used.
278  std::vector<std::unique_ptr<FileCheckNumericVariable>> NumericVariables;
279 
280  /// Vector holding pointers to all substitutions. Used to automatically free
281  /// them once they are guaranteed to no longer be used.
282  std::vector<std::unique_ptr<FileCheckSubstitution>> Substitutions;
283 
284 public:
285  /// \returns the value of string variable \p VarName or None if no such
286  /// variable has been defined.
287  Optional<StringRef> getPatternVarValue(StringRef VarName);
288 
289  /// Defines string and numeric variables from definitions given on the
290  /// command line, passed as a vector of [#]VAR=VAL strings in
291  /// \p CmdlineDefines. Reports any error to \p SM and \returns whether an
292  /// error occured.
293  bool defineCmdlineVariables(std::vector<std::string> &CmdlineDefines,
294  SourceMgr &SM);
295 
296  /// Undefines local variables (variables whose name does not start with a '$'
297  /// sign), i.e. removes them from GlobalVariableTable and from
298  /// GlobalNumericVariableTable and also clears the value of numeric
299  /// variables.
300  void clearLocalVars();
301 
302 private:
303  /// Makes a new numeric expression instance and registers it for destruction
304  /// when the context is destroyed.
305  FileCheckNumExpr *makeNumExpr(binop_eval_t EvalBinop,
306  FileCheckNumericVariable *OperandLeft,
307  uint64_t OperandRight);
308 
309  /// Makes a new numeric variable and registers it for destruction when the
310  /// context is destroyed.
311  template <class... Types>
312  FileCheckNumericVariable *makeNumericVariable(Types... args);
313 
314  /// Makes a new string substitution and registers it for destruction when the
315  /// context is destroyed.
316  FileCheckSubstitution *makeStringSubstitution(StringRef VarName,
317  size_t InsertIdx);
318 
319  /// Makes a new numeric substitution and registers it for destruction when
320  /// the context is destroyed.
321  FileCheckSubstitution *makeNumericSubstitution(StringRef Expr,
322  FileCheckNumExpr *NumExpr,
323  size_t InsertIdx);
324 };
325 
327  SMLoc PatternLoc;
328 
329  /// A fixed string to match as the pattern or empty if this pattern requires
330  /// a regex match.
331  StringRef FixedStr;
332 
333  /// A regex string to match as the pattern or empty if this pattern requires
334  /// a fixed string to match.
335  std::string RegExStr;
336 
337  /// Entries in this vector represent a substitution of a string variable or a
338  /// numeric expression in the RegExStr regex at match time. For example, in
339  /// the case of a CHECK directive with the pattern "foo[[bar]]baz[[#N+1]]",
340  /// RegExStr will contain "foobaz" and we'll get two entries in this vector
341  /// that tells us to insert the value of string variable "bar" at offset 3
342  /// and the value of numeric expression "N+1" at offset 6.
343  std::vector<FileCheckSubstitution *> Substitutions;
344 
345  /// Maps names of string variables defined in a pattern to the number of
346  /// their parenthesis group in RegExStr capturing their last definition.
347  ///
348  /// E.g. for the pattern "foo[[bar:.*]]baz([[bar]][[QUUX]][[bar:.*]])",
349  /// RegExStr will be "foo(.*)baz(\1<quux value>(.*))" where <quux value> is
350  /// the value captured for QUUX on the earlier line where it was defined, and
351  /// VariableDefs will map "bar" to the third parenthesis group which captures
352  /// the second definition of "bar".
353  ///
354  /// Note: uses std::map rather than StringMap to be able to get the key when
355  /// iterating over values.
356  std::map<StringRef, unsigned> VariableDefs;
357 
358  /// Structure representing the definition of a numeric variable in a pattern.
359  /// It holds the pointer to the class representing the numeric variable whose
360  /// value is being defined and the number of the parenthesis group in
361  /// RegExStr to capture that value.
362  struct FileCheckNumExprMatch {
363  /// Pointer to class representing the numeric variable whose value is being
364  /// defined.
365  FileCheckNumericVariable *DefinedNumericVariable;
366 
367  /// Number of the parenthesis group in RegExStr that captures the value of
368  /// this numeric variable definition.
369  unsigned CaptureParenGroup;
370  };
371 
372  /// Holds the number of the parenthesis group in RegExStr and pointer to the
373  /// corresponding FileCheckNumericVariable class instance of all numeric
374  /// variable definitions. Used to set the matched value of all those
375  /// variables.
376  StringMap<FileCheckNumExprMatch> NumericVariableDefs;
377 
378  /// Pointer to a class instance holding the global state shared by all
379  /// patterns:
380  /// - separate tables with the values of live string and numeric variables
381  /// respectively at the start of any given CHECK line;
382  /// - table holding whether a string variable has been defined at any given
383  /// point during the parsing phase.
385 
386  Check::FileCheckType CheckTy;
387 
388  /// Line number for this CHECK pattern. Used to determine whether a variable
389  /// definition is made on an earlier line to the one with this CHECK.
390  size_t LineNumber;
391 
392 public:
394  size_t Line)
395  : Context(Context), CheckTy(Ty), LineNumber(Line) {}
396 
397  /// \returns the location in source code.
398  SMLoc getLoc() const { return PatternLoc; }
399 
400  /// \returns the pointer to the global state for all patterns in this
401  /// FileCheck instance.
403 
404  /// \returns whether \p C is a valid first character for a variable name.
405  static bool isValidVarNameStart(char C);
406  /// Parses the string at the start of \p Str for a variable name and \returns
407  /// whether the variable name is ill-formed. If parsing succeeded, sets
408  /// \p IsPseudo to indicate if it is a pseudo variable, sets \p Name to the
409  /// parsed variable name and strips \p Str from the variable name.
410  static bool parseVariable(StringRef &Str, StringRef &Name, bool &IsPseudo);
411  /// Parses \p Expr for the definition of a numeric variable, returning an
412  /// error if \p Context already holds a string variable with the same name.
413  /// \returns whether parsing fails, in which case errors are reported on
414  /// \p SM. Otherwise, sets \p Name to the name of the parsed numeric
415  /// variable.
416  static bool parseNumericVariableDefinition(StringRef &Expr, StringRef &Name,
417  FileCheckPatternContext *Context,
418  const SourceMgr &SM);
419  /// Parses \p Expr for a numeric substitution block. \returns the class
420  /// representing the AST of the numeric expression whose value must be
421  /// substituted, or nullptr if parsing fails, in which case errors are
422  /// reported on \p SM. Sets \p DefinedNumericVariable to point to the class
423  /// representing the numeric variable defined in this numeric substitution
424  /// block, or nullptr if this block does not define any variable.
425  FileCheckNumExpr *parseNumericSubstitutionBlock(
426  StringRef Expr, FileCheckNumericVariable *&DefinedNumericVariable,
427  const SourceMgr &SM) const;
428  /// Parses the pattern in \p PatternStr and initializes this FileCheckPattern
429  /// instance accordingly.
430  ///
431  /// \p Prefix provides which prefix is being matched, \p Req describes the
432  /// global options that influence the parsing such as whitespace
433  /// canonicalization, \p SM provides the SourceMgr used for error reports.
434  /// \returns true in case of an error, false otherwise.
435  bool parsePattern(StringRef PatternStr, StringRef Prefix, SourceMgr &SM,
436  const FileCheckRequest &Req);
437  /// Matches the pattern string against the input buffer \p Buffer
438  ///
439  /// \returns the position that is matched or npos if there is no match. If
440  /// there is a match, updates \p MatchLen with the size of the matched
441  /// string.
442  ///
443  /// The GlobalVariableTable StringMap in the FileCheckPatternContext class
444  /// instance provides the current values of FileCheck string variables and
445  /// is updated if this match defines new values. Likewise, the
446  /// GlobalNumericVariableTable StringMap in the same class provides the
447  /// current values of FileCheck numeric variables and is updated if this
448  /// match defines new numeric values.
449  size_t match(StringRef Buffer, size_t &MatchLen, const SourceMgr &SM) const;
450  /// Prints the value of successful substitutions or the name of the undefined
451  /// string or numeric variable preventing a successful substitution.
452  void printSubstitutions(const SourceMgr &SM, StringRef Buffer,
453  SMRange MatchRange = None) const;
454  void printFuzzyMatch(const SourceMgr &SM, StringRef Buffer,
455  std::vector<FileCheckDiag> *Diags) const;
456 
457  bool hasVariable() const {
458  return !(Substitutions.empty() && VariableDefs.empty());
459  }
460 
461  Check::FileCheckType getCheckTy() const { return CheckTy; }
462 
463  int getCount() const { return CheckTy.getCount(); }
464 
465 private:
466  bool AddRegExToRegEx(StringRef RS, unsigned &CurParen, SourceMgr &SM);
467  void AddBackrefToRegEx(unsigned BackrefNum);
468  /// Computes an arbitrary estimate for the quality of matching this pattern
469  /// at the start of \p Buffer; a distance of zero should correspond to a
470  /// perfect match.
471  unsigned computeMatchDistance(StringRef Buffer) const;
472  /// Finds the closing sequence of a regex variable usage or definition.
473  ///
474  /// \p Str has to point in the beginning of the definition (right after the
475  /// opening sequence). \p SM holds the SourceMgr used for error repporting.
476  /// \returns the offset of the closing sequence within Str, or npos if it
477  /// was not found.
478  size_t FindRegexVarEnd(StringRef Str, SourceMgr &SM);
479 
480  /// Parses \p Expr for the use of a numeric variable. \returns the pointer to
481  /// the class instance representing that variable if successful, or nullptr
482  /// otherwise, in which case errors are reported on \p SM.
483  FileCheckNumericVariable *parseNumericVariableUse(StringRef &Expr,
484  const SourceMgr &SM) const;
485  /// Parses \p Expr for a binary operation.
486  /// \returns the class representing the binary operation of the numeric
487  /// expression, or nullptr if parsing fails, in which case errors are
488  /// reported on \p SM.
489  FileCheckNumExpr *parseBinop(StringRef &Expr, const SourceMgr &SM) const;
490 };
491 
492 //===----------------------------------------------------------------------===//
493 /// Summary of a FileCheck diagnostic.
494 //===----------------------------------------------------------------------===//
495 
497  /// What is the FileCheck directive for this diagnostic?
499  /// Where is the FileCheck directive for this diagnostic?
500  unsigned CheckLine, CheckCol;
501  /// What type of match result does this diagnostic describe?
502  ///
503  /// A directive's supplied pattern is said to be either expected or excluded
504  /// depending on whether the pattern must have or must not have a match in
505  /// order for the directive to succeed. For example, a CHECK directive's
506  /// pattern is expected, and a CHECK-NOT directive's pattern is excluded.
507  /// All match result types whose names end with "Excluded" are for excluded
508  /// patterns, and all others are for expected patterns.
509  ///
510  /// There might be more than one match result for a single pattern. For
511  /// example, there might be several discarded matches
512  /// (MatchFoundButDiscarded) before either a good match
513  /// (MatchFoundAndExpected) or a failure to match (MatchNoneButExpected),
514  /// and there might be a fuzzy match (MatchFuzzy) after the latter.
515  enum MatchType {
516  /// Indicates a good match for an expected pattern.
518  /// Indicates a match for an excluded pattern.
520  /// Indicates a match for an expected pattern, but the match is on the
521  /// wrong line.
523  /// Indicates a discarded match for an expected pattern.
525  /// Indicates no match for an excluded pattern.
527  /// Indicates no match for an expected pattern, but this might follow good
528  /// matches when multiple matches are expected for the pattern, or it might
529  /// follow discarded matches for the pattern.
531  /// Indicates a fuzzy match that serves as a suggestion for the next
532  /// intended match for an expected pattern with too few or no good matches.
534  } MatchTy;
535  /// The search range if MatchTy is MatchNoneAndExcluded or
536  /// MatchNoneButExpected, or the match range otherwise.
537  unsigned InputStartLine;
538  unsigned InputStartCol;
539  unsigned InputEndLine;
540  unsigned InputEndCol;
541  FileCheckDiag(const SourceMgr &SM, const Check::FileCheckType &CheckTy,
542  SMLoc CheckLoc, MatchType MatchTy, SMRange InputRange);
543 };
544 
545 //===----------------------------------------------------------------------===//
546 // Check Strings.
547 //===----------------------------------------------------------------------===//
548 
549 /// A check that we found in the input file.
551  /// The pattern to match.
553 
554  /// Which prefix name this check matched.
556 
557  /// The location in the match file that the check string was specified.
559 
560  /// All of the strings that are disallowed from occurring between this match
561  /// string and the previous one (or start of file).
562  std::vector<FileCheckPattern> DagNotStrings;
563 
565  : Pat(P), Prefix(S), Loc(L) {}
566 
567  /// Matches check string and its "not strings" and/or "dag strings".
568  size_t Check(const SourceMgr &SM, StringRef Buffer, bool IsLabelScanMode,
569  size_t &MatchLen, FileCheckRequest &Req,
570  std::vector<FileCheckDiag> *Diags) const;
571 
572  /// Verifies that there is a single line in the given \p Buffer. Errors are
573  /// reported against \p SM.
574  bool CheckNext(const SourceMgr &SM, StringRef Buffer) const;
575  /// Verifies that there is no newline in the given \p Buffer. Errors are
576  /// reported against \p SM.
577  bool CheckSame(const SourceMgr &SM, StringRef Buffer) const;
578  /// Verifies that none of the strings in \p NotStrings are found in the given
579  /// \p Buffer. Errors are reported against \p SM and diagnostics recorded in
580  /// \p Diags according to the verbosity level set in \p Req.
581  bool CheckNot(const SourceMgr &SM, StringRef Buffer,
582  const std::vector<const FileCheckPattern *> &NotStrings,
583  const FileCheckRequest &Req,
584  std::vector<FileCheckDiag> *Diags) const;
585  /// Matches "dag strings" and their mixed "not strings".
586  size_t CheckDag(const SourceMgr &SM, StringRef Buffer,
587  std::vector<const FileCheckPattern *> &NotStrings,
588  const FileCheckRequest &Req,
589  std::vector<FileCheckDiag> *Diags) const;
590 };
591 
592 /// FileCheck class takes the request and exposes various methods that
593 /// use information from the request.
594 class FileCheck {
595  FileCheckRequest Req;
596  FileCheckPatternContext PatternContext;
597 
598 public:
599  FileCheck(FileCheckRequest Req) : Req(Req) {}
600 
601  // Combines the check prefixes into a single regex so that we can efficiently
602  // scan for any of the set.
603  //
604  // The semantics are that the longest-match wins which matches our regex
605  // library.
606  Regex buildCheckPrefixRegex();
607 
608  /// Reads the check file from \p Buffer and records the expected strings it
609  /// contains in the \p CheckStrings vector. Errors are reported against
610  /// \p SM.
611  ///
612  /// Only expected strings whose prefix is one of those listed in \p PrefixRE
613  /// are recorded. \returns true in case of an error, false otherwise.
614  bool ReadCheckFile(SourceMgr &SM, StringRef Buffer, Regex &PrefixRE,
615  std::vector<FileCheckString> &CheckStrings);
616 
617  bool ValidateCheckPrefixes();
618 
619  /// Canonicalizes whitespaces in the file. Line endings are replaced with
620  /// UNIX-style '\n'.
621  StringRef CanonicalizeFile(MemoryBuffer &MB,
622  SmallVectorImpl<char> &OutputBuffer);
623 
624  /// Checks the input to FileCheck provided in the \p Buffer against the
625  /// \p CheckStrings read from the check file and record diagnostics emitted
626  /// in \p Diags. Errors are recorded against \p SM.
627  ///
628  /// \returns false if the input fails to satisfy the checks.
629  bool CheckInput(SourceMgr &SM, StringRef Buffer,
630  ArrayRef<FileCheckString> CheckStrings,
631  std::vector<FileCheckDiag> *Diags = nullptr);
632 };
633 } // namespace llvm
634 #endif
static bool Check(DecodeStatus &Out, DecodeStatus In)
uint64_t CallInst * C
Represents a range in source code.
Definition: SMLoc.h:48
Indicates a good match for an expected pattern.
Definition: FileCheck.h:517
Indicates no match for an excluded pattern.
Definition: FileCheck.h:526
LLVMContext & Context
This class represents lattice values for constants.
Definition: AllocatorList.h:23
std::vector< std::string > ImplicitCheckNot
Definition: FileCheck.h:29
Indicates a discarded match for an expected pattern.
Definition: FileCheck.h:524
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
FileCheckPatternContext * Context
Pointer to a class instance holding, among other things, the table with the values of live string var...
Definition: FileCheck.h:130
Marks when parsing found a -NOT check combined with another CHECK suffix.
Definition: FileCheck.h:218
FileCheckType(FileCheckKind Kind=CheckNone)
Definition: FileCheck.h:229
bool AllowDeprecatedDagOverlap
Definition: FileCheck.h:34
Class representing a numeric variable with a given value in a numeric expression. ...
Definition: FileCheck.h:47
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.
FileCheckNumExpr(binop_eval_t EvalBinop, FileCheckNumericVariable *OperandLeft, uint64_t OperandRight)
Definition: FileCheck.h:105
StringRef Prefix
Which prefix name this check matched.
Definition: FileCheck.h:555
bool match(Val *V, const Pattern &P)
Definition: PatternMatch.h:47
FileCheckPattern Pat
The pattern to match.
Definition: FileCheck.h:552
Class holding the FileCheckPattern global state, shared by all patterns: tables holding values of var...
Definition: FileCheck.h:247
SMLoc Loc
The location in the match file that the check string was specified.
Definition: FileCheck.h:558
Check::FileCheckType CheckTy
What is the FileCheck directive for this diagnostic?
Definition: FileCheck.h:498
Indicates a match for an expected pattern, but the match is on the wrong line.
Definition: FileCheck.h:522
FileCheckStringSubstitution(FileCheckPatternContext *Context, StringRef VarName, size_t InsertIdx)
Definition: FileCheck.h:164
Class representing a substitution to perform in the RegExStr string.
Definition: FileCheck.h:122
Marks when parsing found a -COUNT directive with invalid count value.
Definition: FileCheck.h:221
std::vector< std::string > CheckPrefixes
Definition: FileCheck.h:27
FileCheckPattern(Check::FileCheckType Ty, FileCheckPatternContext *Context, size_t Line)
Definition: FileCheck.h:393
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:32
Contains info about various FileCheck options.
Definition: FileCheck.h:26
FileCheck(FileCheckRequest Req)
Definition: FileCheck.h:599
std::vector< std::string > GlobalDefines
Definition: FileCheck.h:30
static std::string getDescription(const CallGraphSCC &SCC)
FileCheckNumericSubstitution(FileCheckPatternContext *Context, StringRef Expr, FileCheckNumExpr *NumExpr, size_t InsertIdx)
Definition: FileCheck.h:184
unsigned InputEndLine
Definition: FileCheck.h:539
FileCheckSubstitution(FileCheckPatternContext *Context, StringRef VarName, size_t InsertIdx)
Definition: FileCheck.h:141
#define P(N)
A check that we found in the input file.
Definition: FileCheck.h:550
std::vector< FileCheckPattern > DagNotStrings
All of the strings that are disallowed from occurring between this match string and the previous one ...
Definition: FileCheck.h:562
StringRef getFromString() const
Definition: FileCheck.h:148
unsigned CheckLine
Where is the FileCheck directive for this diagnostic?
Definition: FileCheck.h:500
StringRef FromStr
The string that needs to be substituted for something else.
Definition: FileCheck.h:135
SMLoc getLoc() const
Definition: FileCheck.h:398
size_t getIndex() const
Definition: FileCheck.h:151
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
Definition: SourceMgr.h:41
Optional< uint64_t > getValue() const
Definition: FileCheck.h:73
Check::FileCheckType getCheckTy() const
Definition: FileCheck.h:461
bool hasVariable() const
Definition: FileCheck.h:457
StringRef getName() const
Definition: FileCheck.h:70
Indicates the pattern only matches the end of file.
Definition: FileCheck.h:215
Indicates a fuzzy match that serves as a suggestion for the next intended match for an expected patte...
Definition: FileCheck.h:533
Indicates no match for an expected pattern, but this might follow good matches when multiple matches ...
Definition: FileCheck.h:530
unsigned InputEndCol
Definition: FileCheck.h:540
uint64_t(*)(uint64_t, uint64_t) binop_eval_t
Type of functions evaluating a given binary operation.
Definition: FileCheck.h:88
FileCheckPatternContext * getContext() const
Definition: FileCheck.h:402
This interface provides simple read-only access to a block of memory, and provides simple methods for...
Definition: MemoryBuffer.h:41
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition: StringMap.h:219
unsigned InputStartLine
The search range if MatchTy is MatchNoneAndExcluded or MatchNoneButExpected, or the match range other...
Definition: FileCheck.h:537
Indicates a match for an excluded pattern.
Definition: FileCheck.h:519
Summary of a FileCheck diagnostic.
Definition: FileCheck.h:496
FileCheckNumericVariable(StringRef Name, uint64_t Value)
Constructor for numeric variable Name with a known Value at parse time (e.g.
Definition: FileCheck.h:66
unsigned InputStartCol
Definition: FileCheck.h:538
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
MatchType
What type of match result does this diagnostic describe?
Definition: FileCheck.h:515
FileCheckNumericVariable(size_t DefLineNumber, StringRef Name)
Constructor for a variable Name defined at line DefLineNumber.
Definition: FileCheck.h:61
int getCount() const
Definition: FileCheck.h:463
Represents a location in source code.
Definition: SMLoc.h:23
FileCheck class takes the request and exposes various methods that use information from the request...
Definition: FileCheck.h:594
Class representing a numeric expression consisting of either a single numeric variable or a binary op...
Definition: FileCheck.h:93
FileCheckString(const FileCheckPattern &P, StringRef S, SMLoc L)
Definition: FileCheck.h:564