summaryrefslogtreecommitdiff
path: root/utils/FileCheck
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-04-09 06:18:02 +0000
committerChris Lattner <sabre@nondot.org>2011-04-09 06:18:02 +0000
commit13a38c4cb4c90a6d2b5313a6517d6291cb924730 (patch)
treee7d2a99332b6ee31a307459c68497a5159495c30 /utils/FileCheck
parent1bdedb9e463030aa1f764fc0541b0c907ed1813f (diff)
downloadllvm-13a38c4cb4c90a6d2b5313a6517d6291cb924730.tar.gz
llvm-13a38c4cb4c90a6d2b5313a6517d6291cb924730.tar.bz2
llvm-13a38c4cb4c90a6d2b5313a6517d6291cb924730.tar.xz
various cleanups, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129192 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/FileCheck')
-rw-r--r--utils/FileCheck/FileCheck.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/utils/FileCheck/FileCheck.cpp b/utils/FileCheck/FileCheck.cpp
index 5d4cb0c0c5..58001b73ab 100644
--- a/utils/FileCheck/FileCheck.cpp
+++ b/utils/FileCheck/FileCheck.cpp
@@ -131,26 +131,26 @@ bool Pattern::ParsePattern(StringRef PatternStr, SourceMgr &SM) {
}
// Paren value #0 is for the fully matched string. Any new parenthesized
- // values add from their.
+ // values add from there.
unsigned CurParen = 1;
// Otherwise, there is at least one regex piece. Build up the regex pattern
// by escaping scary characters in fixed strings, building up one big regex.
while (!PatternStr.empty()) {
// RegEx matches.
- if (PatternStr.size() >= 2 &&
- PatternStr[0] == '{' && PatternStr[1] == '{') {
+ if (PatternStr.startswith("{{")) {
// Otherwise, 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()),
- "found start of regex string with no end '}}'", "error");
+ "found start of regex string with no end '}}'","error");
return true;
}
if (AddRegExToRegEx(PatternStr.substr(2, End-2), CurParen, SM))
return true;
+
PatternStr = PatternStr.substr(End+2);
continue;
}
@@ -160,8 +160,7 @@ bool Pattern::ParsePattern(StringRef PatternStr, SourceMgr &SM) {
// second form is [[foo]] which is a reference to foo. The variable name
// itself must be of the form "[a-zA-Z_][0-9a-zA-Z_]*", otherwise we reject
// it. This is to catch some common errors.
- if (PatternStr.size() >= 2 &&
- PatternStr[0] == '[' && PatternStr[1] == '[') {
+ if (PatternStr.startswith("[[")) {
// Verify that it is terminated properly.
size_t End = PatternStr.find("]]");
if (End == StringRef::npos) {
@@ -185,10 +184,7 @@ bool Pattern::ParsePattern(StringRef PatternStr, SourceMgr &SM) {
// Verify that the name is well formed.
for (unsigned i = 0, e = Name.size(); i != e; ++i)
- if (Name[i] != '_' &&
- (Name[i] < 'a' || Name[i] > 'z') &&
- (Name[i] < 'A' || Name[i] > 'Z') &&
- (Name[i] < '0' || Name[i] > '9')) {
+ if (Name[i] != '_' && !isalnum(Name[i])) {
SM.PrintMessage(SMLoc::getFromPointer(Name.data()+i),
"invalid name in named regex", "error");
return true;