summaryrefslogtreecommitdiffstats
path: root/llvm/utils/FileCheck/FileCheck.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-09-25 17:29:36 +0000
committerChris Lattner <sabre@nondot.org>2009-09-25 17:29:36 +0000
commit0a4c44bdf4d0f5e095f5f208163030e4d7b9baea (patch)
tree82266955f9f55b265c6045d906bbb9290c773908 /llvm/utils/FileCheck/FileCheck.cpp
parentb16ab0c40a642f07731a66041343c389b394a23d (diff)
downloadbcm5719-llvm-0a4c44bdf4d0f5e095f5f208163030e4d7b9baea.tar.gz
bcm5719-llvm-0a4c44bdf4d0f5e095f5f208163030e4d7b9baea.zip
reject attempts to use ()'s in patterns, these are reserved for filecheck.
llvm-svn: 82780
Diffstat (limited to 'llvm/utils/FileCheck/FileCheck.cpp')
-rw-r--r--llvm/utils/FileCheck/FileCheck.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/llvm/utils/FileCheck/FileCheck.cpp b/llvm/utils/FileCheck/FileCheck.cpp
index 1e6af371d8e..8e63a9961a0 100644
--- a/llvm/utils/FileCheck/FileCheck.cpp
+++ b/llvm/utils/FileCheck/FileCheck.cpp
@@ -45,6 +45,9 @@ NoCanonicalizeWhiteSpace("strict-whitespace",
//===----------------------------------------------------------------------===//
class Pattern {
+ SourceMgr *SM;
+ SMLoc PatternLoc;
+
/// FixedStr - If non-empty, this pattern is a fixed string match with the
/// specified fixed string.
StringRef FixedStr;
@@ -67,6 +70,9 @@ private:
};
bool Pattern::ParsePattern(StringRef PatternStr, SourceMgr &SM) {
+ this->SM = &SM;
+ PatternLoc = SMLoc::getFromPointer(PatternStr.data());
+
// Ignore trailing whitespace.
while (!PatternStr.empty() &&
(PatternStr.back() == ' ' || PatternStr.back() == '\t'))
@@ -74,9 +80,8 @@ bool Pattern::ParsePattern(StringRef PatternStr, SourceMgr &SM) {
// Check that there is something on the line.
if (PatternStr.empty()) {
- SM.PrintMessage(SMLoc::getFromPointer(PatternStr.data()),
- "found empty check string with prefix '"+CheckPrefix+":'",
- "error");
+ SM.PrintMessage(PatternLoc, "found empty check string with prefix '" +
+ CheckPrefix+":'", "error");
return true;
}
@@ -170,6 +175,13 @@ size_t Pattern::Match(StringRef Buffer, size_t &MatchLen) const {
assert(!MatchInfo.empty() && "Didn't get any match");
StringRef FullMatch = MatchInfo[0];
+
+ if (MatchInfo.size() != 1) {
+ SM->PrintMessage(PatternLoc, "regex cannot use grouping parens", "error");
+ exit(1);
+ }
+
+
MatchLen = FullMatch.size();
return FullMatch.data()-Buffer.data();
}
OpenPOWER on IntegriCloud