13#ifndef LLVM_FILECHECK_FILECHECK_H
14#define LLVM_FILECHECK_FILECHECK_H
87 std::bitset<FileCheckKindModifier::Size> Modifiers;
115class MatchResultDiag;
187 SearchRange(SearchRange) {}
229 Status(Status), MatchRange(MatchRange) {}
256 "expected to change successful status to unsuccessful");
260 std::optional<SMRange>
getMatchRange()
const override {
return MatchRange; }
297 std::optional<SMRange>
getMatchRange()
const override {
return std::nullopt; }
320 assert(!MRD &&
"expected setMatchResultDiag to be called only once");
340 bool isError()
const override {
return false; }
344 return SMRange(MatchStart, MatchStart);
354 std::optional<SMRange> MatchRange;
378 bool AddsError =
false)
380 AddsError(AddsError), MatchRange(MatchRange) {}
389 const std::string &
getNote()
const {
return Note; }
395 bool isError()
const override {
return AddsError; }
397 std::optional<SMRange>
getMatchRange()
const override {
return MatchRange; }
404 using vector_type = std::vector<std::unique_ptr<FileCheckDiag>>;
405 vector_type DiagList;
414 template <
typename DiagTy,
typename... ArgTys>
416 DiagList.emplace_back(
417 std::make_unique<DiagTy>(std::forward<ArgTys>(Args)...));
420 CurMatchResultDiag = MRD;
424 if (!CurMatchResultDiag)
426 Note->setMatchResultDiag(CurMatchResultDiag);
433 class const_iterator {
434 friend FileCheckDiagList;
444 vector_type::const_iterator Itr;
445 const_iterator(vector_type::const_iterator Itr) : Itr(Itr) {}
455 const_iterator Old = *
this;
460 return Itr ==
Other.Itr;
463 return Itr !=
Other.Itr;
474class FileCheckPatternContext;
475struct FileCheckString;
481 std::unique_ptr<FileCheckPatternContext> PatternContext;
482 std::vector<FileCheckString> CheckStrings;
496 std::pair<unsigned, unsigned> *ImpPatBufferIDRange =
nullptr);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static constexpr unsigned SM(unsigned Version)
LLVM_ABI std::string getDescription(StringRef Prefix) const
FileCheckType(FileCheckKind Kind=CheckNone)
FileCheckType & operator=(const FileCheckType &)=default
bool isLiteralMatch() const
LLVM_ABI std::string getModifiersDescription() const
FileCheckType & setLiteralMatch(bool Literal=true)
LLVM_ABI FileCheckType & setCount(int C)
FileCheckType(const FileCheckType &)=default
bool operator!=(const const_iterator &Other) const
pointer operator->() const
std::ptrdiff_t difference_type
reference operator*() const
bool operator==(const const_iterator &Other) const
const FileCheckDiag * pointer
const_iterator operator++(int)
std::forward_iterator_tag iterator_category
const_iterator & operator++()
const FileCheckDiag & reference
A FileCheckDiag series emitted by the FileCheck library.
const FileCheckDiag & operator[](size_type I) const
const_iterator begin() const
const_iterator end() const
void emplace(ArgTys &&...Args)
Emplace a new FileCheckDiag of type DiagTy.
vector_type::size_type size_type
void adjustPrevMatchFoundDiag(MatchFoundDiag::StatusTy Status)
Adjust the previous MatchResultDiag, which must be a MatchFoundDiag, from successful status to unsucc...
Abstract base class for recording a FileCheck diagnostic for a pattern (e.g., CHECK-NEXT directive or...
virtual const MatchResultDiag & getMatchResultDiag() const =0
If this is a MatchResultDiag, return itself.
virtual std::optional< SMRange > getMatchRange() const =0
Return the input range for which this diagnostic indicates text that was matched in some way (e....
FileCheckDiag(FileCheckDiagKind Kind)
virtual bool isError() const =0
Does this diagnostic reveal a new error?
FileCheckDiagKind getKind() const
Of what derived class is this an instance?
virtual ~FileCheckDiag()=0
Destructor is purely virtual to ensure this remains an abstract class.
LLVM_ABI bool readCheckFile(SourceMgr &SM, StringRef Buffer, std::pair< unsigned, unsigned > *ImpPatBufferIDRange=nullptr)
Reads the check file from Buffer and records the expected strings it contains.
LLVM_ABI StringRef CanonicalizeFile(MemoryBuffer &MB, SmallVectorImpl< char > &OutputBuffer)
Canonicalizes whitespaces in the file.
LLVM_ABI FileCheck(FileCheckRequest Req)
LLVM_ABI bool checkInput(SourceMgr &SM, StringRef Buffer, FileCheckDiagList *Diags=nullptr)
Checks the input to FileCheck provided in the Buffer against the expected strings read from the check...
LLVM_ABI bool ValidateCheckPrefixes()
bool isError() const override
Does this note indicate an additional error not indicated by the associated MatchResultDiag?
MatchCustomNoteDiag(SMRange MatchRange, StringRef Note, bool AddsError=false)
If MatchRange is specified, it is a range for input text that was matched in some way (e....
static bool classof(const FileCheckDiag *FCD)
Is FCD an instance of MatchCustomNoteDiag?
const std::string & getNote() const
MatchCustomNoteDiag(StringRef Note)
std::optional< SMRange > getMatchRange() const override
Return the match range described by the note, or std::nullopt if none.
std::optional< SMRange > getMatchRange() const override
Return the match's input range, never std::nullopt.
@ Success
Indicates a good match for an expected pattern.
@ Excluded
Indicates a match for an excluded pattern (error).
@ Discarded
Indicates a discarded match for an expected pattern (not an error).
@ WrongLine
Indicates a match for an expected pattern, but the match is on the wrong line (error).
StatusTy getStatus() const
Was this a successful match?
static bool classof(const FileCheckDiag *FCD)
Is FCD an instance of MatchFoundDiag?
void markUnsuccessful(StatusTy S)
Adjust a successful status to a non-successful status.
MatchFoundDiag(const Check::FileCheckType &CheckTy, SMLoc CheckLoc, StatusTy Status, SMRange MatchRange, SMRange SearchRange)
bool isError() const override
Does this match produce an error?
std::optional< SMRange > getMatchRange() const override
Return an input range (never std::nullopt) starting and ending at the match start.
bool isError() const override
Always false.
MatchFuzzyDiag(SMLoc MatchStart)
static bool classof(const FileCheckDiag *FCD)
Is FCD an instance of MatchFuzzyDiag?
static bool classof(const FileCheckDiag *FCD)
Is FCD an instance of MatchNoneDiag?
bool isError() const override
Does the lack of match represent an error?
StatusTy getStatus() const
Does the lack of a match indicate a success? If not, why not?
@ Expected
Indicates no match for an expected pattern (error).
@ Success
Indicates no match for an excluded pattern.
@ InvalidPattern
Indicates no match due to an expected or excluded pattern that has proven to be invalid at match time...
MatchNoneDiag(const Check::FileCheckType &CheckTy, SMLoc CheckLoc, StatusTy Status, SMRange SearchRange)
std::optional< SMRange > getMatchRange() const override
Return std::nullopt.
Abstract base class for recording a FileCheck diagnostic that provides an additional note (possibly a...
MatchNoteDiag(FileCheckDiagKind Kind)
static bool classof(const FileCheckDiag *FCD)
Is FCD an instance of MatchNoteDiag?
const MatchResultDiag & getMatchResultDiag() const override
Get the note's associated MatchResultDiag.
virtual ~MatchNoteDiag()=0
Destructor is purely virtual to ensure this remains an abstract class.
void setMatchResultDiag(MatchResultDiag *MRDNew)
Set the note's associated MatchResultDiag.
Abstract base class for recording a FileCheck diagnostic that reports a match result for a pattern.
Check::FileCheckType getCheckTy() const
What is the type of pattern for this match result?
virtual ~MatchResultDiag()=0
Destructor is purely virtual to ensure this remains an abstract class.
SMLoc getCheckLoc() const
Where is the pattern for this match result?
SMRange getSearchRange() const
What is the search range for the match result?
MatchResultDiag(FileCheckDiagKind Kind, const Check::FileCheckType &CheckTy, SMLoc CheckLoc, SMRange SearchRange)
const MatchResultDiag & getMatchResultDiag() const override
Get itself.
static bool classof(const FileCheckDiag *FCD)
Is FCD an instance of MatchResultDiag?
This interface provides simple read-only access to a block of memory, and provides simple methods for...
Represents a location in source code.
Represents a range in source code.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling.
Represent a constant reference to a string, i.e.
@ C
The default llvm calling convention, compatible with C.
@ ModifierLiteral
Modifies directive to perform literal match.
@ CheckBadNot
Marks when parsing found a -NOT check combined with another CHECK suffix.
@ CheckBadCount
Marks when parsing found a -COUNT directive with invalid count value.
@ CheckEOF
Indicates the pattern only matches the end of file.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Contains info about various FileCheck options.
bool IsDefaultCheckPrefix
std::vector< StringRef > GlobalDefines
bool NoCanonicalizeWhiteSpace
std::vector< StringRef > ImplicitCheckNot
std::vector< StringRef > CommentPrefixes
std::vector< StringRef > CheckPrefixes
bool AllowDeprecatedDagOverlap