summaryrefslogtreecommitdiff
path: root/utils/FileCheck
diff options
context:
space:
mode:
authorEli Bendersky <eliben@google.com>2012-11-30 14:22:14 +0000
committerEli Bendersky <eliben@google.com>2012-11-30 14:22:14 +0000
commit1e5cbcb10adaca5c80121293b6c414d9285ebcee (patch)
treea0587855e8b3347e6cd35081311cf382feb64c0e /utils/FileCheck
parent7f8e76f5140be7cc9ed1cb66cdcdedfa28147641 (diff)
downloadllvm-1e5cbcb10adaca5c80121293b6c414d9285ebcee.tar.gz
llvm-1e5cbcb10adaca5c80121293b6c414d9285ebcee.tar.bz2
llvm-1e5cbcb10adaca5c80121293b6c414d9285ebcee.tar.xz
Clean up whitespace and add comments
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169002 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/FileCheck')
-rw-r--r--utils/FileCheck/FileCheck.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/utils/FileCheck/FileCheck.cpp b/utils/FileCheck/FileCheck.cpp
index 0dc8432dc9..fb66ac2fce 100644
--- a/utils/FileCheck/FileCheck.cpp
+++ b/utils/FileCheck/FileCheck.cpp
@@ -83,6 +83,10 @@ public:
Pattern(bool matchEOF = false) : MatchEOF(matchEOF) { }
+ /// ParsePattern - Parse the given string into the Pattern. SM provides the
+ /// SourceMgr used for error reports, and 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 ParsePattern(StringRef PatternStr, SourceMgr &SM, unsigned LineNumber);
/// Match - Match the pattern string against the input buffer Buffer. This
@@ -150,8 +154,7 @@ bool Pattern::ParsePattern(StringRef PatternStr, SourceMgr &SM,
while (!PatternStr.empty()) {
// RegEx matches.
if (PatternStr.startswith("{{")) {
-
- // Otherwise, this is the start of a regex match. Scan for the }}.
+ // This is the start of a regex match. Scan for the }}.
size_t End = PatternStr.find("}}");
if (End == StringRef::npos) {
SM.PrintMessage(SMLoc::getFromPointer(PatternStr.data()),
@@ -554,9 +557,9 @@ static MemoryBuffer *CanonicalizeInputFile(MemoryBuffer *MB) {
/// ReadCheckFile - 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.
static bool ReadCheckFile(SourceMgr &SM,
std::vector<CheckString> &CheckStrings) {
- // Open the check file, and tell SourceMgr about it.
OwningPtr<MemoryBuffer> File;
if (error_code ec =
MemoryBuffer::getFileOrSTDIN(CheckFilename.c_str(), File)) {
@@ -575,9 +578,10 @@ static bool ReadCheckFile(SourceMgr &SM,
// Find all instances of CheckPrefix followed by : in the file.
StringRef Buffer = F->getBuffer();
-
std::vector<std::pair<SMLoc, Pattern> > NotMatches;
+ // LineNumber keeps track of the line on which CheckPrefix instances are
+ // found.
unsigned LineNumber = 1;
while (1) {
@@ -587,7 +591,6 @@ static bool ReadCheckFile(SourceMgr &SM,
if (PrefixLoc == StringRef::npos)
break;
- // Recalculate line number.
LineNumber += Buffer.substr(0, PrefixLoc).count('\n');
Buffer = Buffer.substr(PrefixLoc);
@@ -631,7 +634,6 @@ static bool ReadCheckFile(SourceMgr &SM,
Buffer = Buffer.substr(EOL);
-
// Verify that CHECK-NEXT lines have at least one CHECK line before them.
if (IsCheckNext && CheckStrings.empty()) {
SM.PrintMessage(SMLoc::getFromPointer(CheckPrefixStart),
@@ -648,7 +650,6 @@ static bool ReadCheckFile(SourceMgr &SM,
continue;
}
-
// Okay, add the string we captured to the output vector and move on.
CheckStrings.push_back(CheckString(P,
PatternLoc,