LLVM: lib/FileCheck/FileCheck.cpp File Reference (original) (raw)
#include "[llvm/FileCheck/FileCheck.h](FileCheck%5F8h%5Fsource.html)"#include "[FileCheckImpl.h](FileCheckImpl%5F8h%5Fsource.html)"#include "[llvm/ADT/STLExtras.h](STLExtras%5F8h%5Fsource.html)"#include "[llvm/ADT/StringExtras.h](StringExtras%5F8h%5Fsource.html)"#include "[llvm/ADT/StringSet.h](StringSet%5F8h%5Fsource.html)"#include "[llvm/ADT/Twine.h](Twine%5F8h%5Fsource.html)"#include "[llvm/Support/FormatVariadic.h](FormatVariadic%5F8h%5Fsource.html)"#include <cstdint>#include <list>#include <set>#include <tuple>#include <utility>
Go to the source code of this file.
| Functions | |
|---|---|
| static unsigned | nextAPIntBitWidth (unsigned BitWidth) |
| static APInt | toSigned (APInt AbsVal, bool Negative) |
| static char | popFront (StringRef &S) |
| 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 AdjustPrevDiags=false) |
| static bool | IsPartOfWord (char c) |
| static std::pair< Check::FileCheckType, StringRef > | FindCheckType (const FileCheckRequest &Req, StringRef Buffer, StringRef Prefix, bool &Misspelled) |
| static std::pair< Check::FileCheckType, StringRef > | FindCheckType (const FileCheckRequest &Req, StringRef Buffer, StringRef Prefix) |
| static size_t | SkipWord (StringRef Str, size_t Loc) |
| static void | addDefaultPrefixes (FileCheckRequest &Req) |
| static std::pair< StringRef, StringRef > | FindFirstMatchingPrefix (const FileCheckRequest &Req, PrefixMatcher &Matcher, StringRef &Buffer, unsigned &LineNumber, Check::FileCheckType &CheckTy) |
| Searches the buffer for the first prefix in the prefix regular expression. | |
| static Error | printMatch (bool ExpectedMatch, const SourceMgr &SM, StringRef Prefix, SMLoc Loc, const Pattern &Pat, int MatchedCount, StringRef Buffer, Pattern::MatchResult MatchResult, const FileCheckRequest &Req, std::vector< FileCheckDiag > *Diags) |
| Returns either (1) ErrorSuccess if there was no error or (2) ErrorReported if an error was reported, such as an unexpected match. | |
| static Error | printNoMatch (bool ExpectedMatch, const SourceMgr &SM, StringRef Prefix, SMLoc Loc, const Pattern &Pat, int MatchedCount, StringRef Buffer, Error MatchError, bool VerboseVerbose, std::vector< FileCheckDiag > *Diags) |
| Returns either (1) ErrorSuccess if there was no error, or (2) ErrorReported if an error was reported, such as an expected match not found. | |
| static Error | reportMatchResult (bool ExpectedMatch, const SourceMgr &SM, StringRef Prefix, SMLoc Loc, const Pattern &Pat, int MatchedCount, StringRef Buffer, Pattern::MatchResult MatchResult, const FileCheckRequest &Req, std::vector< FileCheckDiag > *Diags) |
| Returns either (1) ErrorSuccess if there was no error, or (2) ErrorReported if an error was reported. | |
| static unsigned | CountNumNewlinesBetween (StringRef Range, const char *&FirstNewLine) |
| Counts the number of newlines in the specified range. | |
| static bool | ValidatePrefixes (StringRef Kind, StringSet<> &UniquePrefixes, ArrayRef< StringRef > SuppliedPrefixes) |
◆ addDefaultPrefixes()
◆ CountNumNewlinesBetween()
◆ FindCheckType() [1/2]
◆ FindCheckType() [2/2]
Definition at line 1588 of file FileCheck.cpp.
References llvm::Check::CheckBadCount, llvm::Check::CheckBadNot, llvm::Check::CheckComment, llvm::Check::CheckDAG, llvm::Check::CheckEmpty, llvm::Check::CheckLabel, llvm::Check::CheckNext, llvm::Check::CheckNone, llvm::Check::CheckNot, llvm::Check::CheckPlain, llvm::Check::CheckSame, llvm::FileCheckRequest::CommentPrefixes, llvm::StringRef::consume_front(), llvm::StringRef::consumeInteger(), llvm::Count, llvm::StringRef::drop_front(), llvm::StringRef::front(), llvm::is_contained(), llvm::StringRef::ltrim(), llvm::StringRef::size(), and llvm::StringRef::starts_with().
Referenced by FindCheckType(), and FindFirstMatchingPrefix().
◆ FindFirstMatchingPrefix()
Searches the buffer for the first prefix in the prefix regular expression.
This searches the buffer using the provided regular expression, however it enforces constraints beyond that: 1) The found prefix must not be a suffix of something that looks like a valid prefix. 2) The found prefix must be followed by a valid check type suffix using FindCheckType above.
Returns
a pair of StringRefs into the Buffer, which combines:
- the first match of the regular expression to satisfy these two is returned, otherwise an empty StringRef is returned to indicate failure.
- buffer rewound to the location right after parsed suffix, for parsing to continue from
If this routine returns a valid prefix, it will also shrink Buffer to start at the beginning of the returned prefix, increment LineNumber for each new line consumed from Buffer, and set CheckTy to the type of check found by examining the suffix.
If no valid prefix is found, the state of Buffer, LineNumber, and CheckTy is unspecified.
Definition at line 1769 of file FileCheck.cpp.
References assert(), llvm::Check::CheckNone, llvm::StringRef::data(), llvm::StringRef::drop_front(), llvm::StringRef::empty(), FindCheckType(), IsPartOfWord(), llvm::StringRef::size(), SkipWord(), and llvm::StringRef::substr().
Referenced by llvm::FileCheck::readCheckFile().
◆ IsPartOfWord()
◆ nextAPIntBitWidth()
◆ popFront()
◆ printMatch()
Returns either (1) [ErrorSuccess](classllvm%5F1%5F1ErrorSuccess.html "Subclass of Error for the sole purpose of identifying the success path in the type system.") if there was no error or (2) [ErrorReported](classllvm%5F1%5F1ErrorReported.html "An error that has already been reported.") if an error was reported, such as an unexpected match.
Definition at line 2027 of file FileCheck.cpp.
References assert(), llvm::Check::CheckEOF, llvm::SourceMgr::DK_Error, llvm::SourceMgr::DK_Note, llvm::SourceMgr::DK_Remark, E(), llvm::formatv(), llvm::Pattern::getCheckTy(), llvm::Pattern::getCount(), llvm::Check::FileCheckType::getDescription(), llvm::handleAllErrors(), llvm::FileCheckDiag::MatchFoundAndExpected, llvm::FileCheckDiag::MatchFoundButExcluded, llvm::SourceMgr::PrintMessage(), llvm::Pattern::printSubstitutions(), llvm::Pattern::printVariableDefs(), ProcessMatchResult(), llvm::ErrorReported::reportedOrSuccess(), llvm::SMRange::Start, llvm::Pattern::MatchResult::TheError, llvm::Pattern::MatchResult::TheMatch, llvm::FileCheckRequest::Verbose, and llvm::FileCheckRequest::VerboseVerbose.
Referenced by llvm::FileCheckString::CheckDag(), and reportMatchResult().
◆ printNoMatch()
Returns either (1) [ErrorSuccess](classllvm%5F1%5F1ErrorSuccess.html "Subclass of Error for the sole purpose of identifying the success path in the type system.") if there was no error, or (2) [ErrorReported](classllvm%5F1%5F1ErrorReported.html "An error that has already been reported.") if an error was reported, such as an expected match not found.
Definition at line 2097 of file FileCheck.cpp.
References assert(), llvm::SourceMgr::DK_Error, llvm::SourceMgr::DK_Note, llvm::SourceMgr::DK_Remark, E(), llvm::errs(), llvm::formatv(), llvm::Pattern::getCheckTy(), llvm::Pattern::getCount(), llvm::Check::FileCheckType::getDescription(), llvm::handleAllErrors(), llvm::FileCheckDiag::MatchNoneAndExcluded, llvm::FileCheckDiag::MatchNoneButExpected, llvm::FileCheckDiag::MatchNoneForInvalidPattern, llvm::Pattern::printFuzzyMatch(), llvm::SourceMgr::PrintMessage(), llvm::Pattern::printSubstitutions(), ProcessMatchResult(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::ErrorReported::reportedOrSuccess(), llvm::StringRef::size(), and llvm::SMRange::Start.
Referenced by reportMatchResult().
◆ ProcessMatchResult()
◆ reportMatchResult()
◆ SkipWord()
| size_t SkipWord ( StringRef Str, size_t Loc ) | static |
|---|
◆ toSigned()
◆ ValidatePrefixes()
◆ DefaultCheckPrefixes
| const char* DefaultCheckPrefixes[] = {"CHECK"} | static |
|---|
◆ DefaultCommentPrefixes
| const char* DefaultCommentPrefixes[] = {"COM", "RUN"} | static |
|---|