aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/FileCheck.cpp
diff options
context:
space:
mode:
authorThomas Preud'homme <thomasp@graphcore.ai>2019-05-08 21:47:31 +0000
committerThomas Preud'homme <thomasp@graphcore.ai>2019-05-08 21:47:31 +0000
commit4a8ef1128b50e03b37d90065bf8565d84d6a051c (patch)
treeae57bedccabbea55acdf275f7c186ee2cbc60f1c /llvm/lib/Support/FileCheck.cpp
parent1dbf721315b85f3e5ac67b1f03207fe9f4495f34 (diff)
downloadllvm-4a8ef1128b50e03b37d90065bf8565d84d6a051c.zip
llvm-4a8ef1128b50e03b37d90065bf8565d84d6a051c.tar.gz
llvm-4a8ef1128b50e03b37d90065bf8565d84d6a051c.tar.bz2
[FileCheck] Fix code style of method comments
Summary: Fix various issues in code style of method comments: 1) Move all heading comments to all non-static methods near their declaration in the FileCheck.h header file. 2) Harmonize the action verb in doxygen comments for methods to always be in third person 3) Use \returns instead of free text "return" and "returns". 4) Document a couple more parameters while at it. Reviewers: jhenderson, probinson, arichardson Subscribers: javed.absar, kristof.beyls, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D61445 llvm-svn: 360288
Diffstat (limited to 'llvm/lib/Support/FileCheck.cpp')
-rw-r--r--llvm/lib/Support/FileCheck.cpp50
1 files changed, 3 insertions, 47 deletions
diff --git a/llvm/lib/Support/FileCheck.cpp b/llvm/lib/Support/FileCheck.cpp
index c5946df..25ea7e4 100644
--- a/llvm/lib/Support/FileCheck.cpp
+++ b/llvm/lib/Support/FileCheck.cpp
@@ -145,12 +145,6 @@ FileCheckPattern::parseNumericExpression(StringRef Name, StringRef Trailer,
return Context->makeNumExpr(Value);
}
-/// Parses the given string into the Pattern.
-///
-/// \p Prefix provides which prefix is being matched, \p SM provides the
-/// SourceMgr used for error reports, and \p LineNumber is the line number in
-/// the input file from which the pattern string was read. Returns true in
-/// case of an error, false otherwise.
bool FileCheckPattern::ParsePattern(StringRef PatternStr, StringRef Prefix,
SourceMgr &SM, unsigned LineNumber,
const FileCheckRequest &Req) {
@@ -377,15 +371,6 @@ void FileCheckPattern::AddBackrefToRegEx(unsigned BackrefNum) {
RegExStr += Backref;
}
-/// Matches the pattern string against the input buffer \p Buffer
-///
-/// This returns the position that is matched or npos if there is no match. If
-/// there is a match, the size of the matched string is returned in \p
-/// MatchLen.
-///
-/// The GlobalVariableTable StringMap in the FileCheckPatternContext class
-/// instance provides the current values of FileCheck pattern variables and is
-/// updated if this match defines new values.
size_t FileCheckPattern::match(StringRef Buffer, size_t &MatchLen) const {
// If this is the EOF pattern, match it immediately.
if (CheckTy == Check::CheckEOF) {
@@ -451,9 +436,6 @@ size_t FileCheckPattern::match(StringRef Buffer, size_t &MatchLen) const {
return FullMatch.data() - Buffer.data() + MatchStartSkip;
}
-/// Computes an arbitrary estimate for the quality of matching this pattern at
-/// the start of \p Buffer; a distance of zero should correspond to a perfect
-/// match.
unsigned FileCheckPattern::computeMatchDistance(StringRef Buffer) const {
// Just compute the number of matching characters. For regular expressions, we
// just compare against the regex itself and hope for the best.
@@ -590,11 +572,6 @@ FileCheckNumExpr *FileCheckPatternContext::makeNumExpr(Types... Args) {
return NumExprs.back().get();
}
-/// Finds the closing sequence of a regex variable usage or definition.
-///
-/// \p Str has to point in the beginning of the definition (right after the
-/// opening sequence). Returns the offset of the closing sequence within Str,
-/// or npos if it was not found.
size_t FileCheckPattern::FindRegexVarEnd(StringRef Str, SourceMgr &SM) {
// Offset keeps track of the current offset within the input Str
size_t Offset = 0;
@@ -633,8 +610,6 @@ size_t FileCheckPattern::FindRegexVarEnd(StringRef Str, SourceMgr &SM) {
return StringRef::npos;
}
-/// Canonicalize whitespaces in the file. Line endings are replaced with
-/// UNIX-style '\n'.
StringRef
llvm::FileCheck::CanonicalizeFile(MemoryBuffer &MB,
SmallVectorImpl<char> &OutputBuffer) {
@@ -693,7 +668,6 @@ Check::FileCheckType &Check::FileCheckType::setCount(int C) {
return *this;
}
-// Get a description of the type.
std::string Check::FileCheckType::getDescription(StringRef Prefix) const {
switch (Kind) {
case Check::CheckNone:
@@ -786,7 +760,7 @@ static size_t SkipWord(StringRef Str, size_t Loc) {
return Loc;
}
-/// Search the buffer for the first prefix in the prefix regular expression.
+/// 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:
@@ -795,7 +769,7 @@ static size_t SkipWord(StringRef Str, size_t Loc) {
/// 2) The found prefix must be followed by a valid check type suffix using \c
/// FindCheckType above.
///
-/// Returns a pair of StringRefs into the Buffer, which combines:
+/// \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.
@@ -856,10 +830,6 @@ FindFirstMatchingPrefix(Regex &PrefixRE, StringRef &Buffer,
return {StringRef(), StringRef()};
}
-/// Read the check file, which specifies the sequence of expected strings.
-///
-/// The strings are added to the CheckStrings vector. Returns true in case of
-/// an error, false otherwise.
bool llvm::FileCheck::ReadCheckFile(
SourceMgr &SM, StringRef Buffer, Regex &PrefixRE,
std::vector<FileCheckString> &CheckStrings) {
@@ -1111,7 +1081,7 @@ static void PrintNoMatch(bool ExpectedMatch, const SourceMgr &SM,
MatchedCount, Buffer, VerboseVerbose, Diags);
}
-/// Count the number of newlines in the specified range.
+/// Counts the number of newlines in the specified range.
static unsigned CountNumNewlinesBetween(StringRef Range,
const char *&FirstNewLine) {
unsigned NumNewLines = 0;
@@ -1134,7 +1104,6 @@ static unsigned CountNumNewlinesBetween(StringRef Range,
}
}
-/// Match check string and its "not strings" and/or "dag strings".
size_t FileCheckString::Check(const SourceMgr &SM, StringRef Buffer,
bool IsLabelScanMode, size_t &MatchLen,
FileCheckRequest &Req,
@@ -1215,7 +1184,6 @@ size_t FileCheckString::Check(const SourceMgr &SM, StringRef Buffer,
return FirstMatchPos;
}
-/// Verify there is a single line in the given buffer.
bool FileCheckString::CheckNext(const SourceMgr &SM, StringRef Buffer) const {
if (Pat.getCheckTy() != Check::CheckNext &&
Pat.getCheckTy() != Check::CheckEmpty)
@@ -1255,7 +1223,6 @@ bool FileCheckString::CheckNext(const SourceMgr &SM, StringRef Buffer) const {
return false;
}
-/// Verify there is no newline in the given buffer.
bool FileCheckString::CheckSame(const SourceMgr &SM, StringRef Buffer) const {
if (Pat.getCheckTy() != Check::CheckSame)
return false;
@@ -1278,7 +1245,6 @@ bool FileCheckString::CheckSame(const SourceMgr &SM, StringRef Buffer) const {
return false;
}
-/// Verify there's no "not strings" in the given buffer.
bool FileCheckString::CheckNot(
const SourceMgr &SM, StringRef Buffer,
const std::vector<const FileCheckPattern *> &NotStrings,
@@ -1304,7 +1270,6 @@ bool FileCheckString::CheckNot(
return false;
}
-/// Match "dag strings" and their mixed "not strings".
size_t
FileCheckString::CheckDag(const SourceMgr &SM, StringRef Buffer,
std::vector<const FileCheckPattern *> &NotStrings,
@@ -1459,11 +1424,6 @@ bool llvm::FileCheck::ValidateCheckPrefixes() {
return true;
}
-// Combines the check prefixes into a single regex so that we can efficiently
-// scan for any of the set.
-//
-// The semantics are that the longest-match wins which matches our regex
-// library.
Regex llvm::FileCheck::buildCheckPrefixRegex() {
// I don't think there's a way to specify an initial value for cl::list,
// so if nothing was specified, add the default
@@ -1548,10 +1508,6 @@ void FileCheckPatternContext::clearLocalVars() {
GlobalVariableTable.erase(Var);
}
-/// Check the input to FileCheck provided in the \p Buffer against the \p
-/// CheckStrings read from the check file.
-///
-/// Returns false if the input fails to satisfy the checks.
bool llvm::FileCheck::CheckInput(SourceMgr &SM, StringRef Buffer,
ArrayRef<FileCheckString> CheckStrings,
std::vector<FileCheckDiag> *Diags) {