[llvm-commits] [llvm] r82780 - /llvm/trunk/utils/FileCheck/FileCheck.cpp
Chris Lattner
sabre at nondot.org
Fri Sep 25 10:29:36 PDT 2009
Author: lattner
Date: Fri Sep 25 12:29:36 2009
New Revision: 82780
URL: http://llvm.org/viewvc/llvm-project?rev=82780&view=rev
Log:
reject attempts to use ()'s in patterns, these are reserved for filecheck.
Modified:
llvm/trunk/utils/FileCheck/FileCheck.cpp
Modified: llvm/trunk/utils/FileCheck/FileCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/FileCheck/FileCheck.cpp?rev=82780&r1=82779&r2=82780&view=diff
==============================================================================
--- llvm/trunk/utils/FileCheck/FileCheck.cpp (original)
+++ llvm/trunk/utils/FileCheck/FileCheck.cpp Fri Sep 25 12:29:36 2009
@@ -45,6 +45,9 @@
//===----------------------------------------------------------------------===//
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 @@
};
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 @@
// 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 @@
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();
}
More information about the llvm-commits
mailing list