aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Support/Regex.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-09-26 21:27:04 +0000
committerChris Lattner <sabre@nondot.org>2009-09-26 21:27:04 +0000
commit81f46d9ce1888308b33336f9bea72147430da36b (patch)
treef3c232cbd37d132f5dc3c530151bd860335125bb /include/llvm/Support/Regex.h
parent282098be8463035143bd8444796e6a58b0205c29 (diff)
downloadexternal_llvm-81f46d9ce1888308b33336f9bea72147430da36b.tar.gz
external_llvm-81f46d9ce1888308b33336f9bea72147430da36b.tar.bz2
external_llvm-81f46d9ce1888308b33336f9bea72147430da36b.zip
remove support for "NoSub" from regex. It seems like a minor optimization
and makes the API more annoying. Add a Regex::getNumMatches() method. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82877 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/Regex.h')
-rw-r--r--include/llvm/Support/Regex.h21
1 files changed, 8 insertions, 13 deletions
diff --git a/include/llvm/Support/Regex.h b/include/llvm/Support/Regex.h
index 0bf253f4c1..c954c0d31a 100644
--- a/include/llvm/Support/Regex.h
+++ b/include/llvm/Support/Regex.h
@@ -22,47 +22,42 @@ namespace llvm {
class Regex {
public:
enum {
- /// Compile with support for subgroup matches, this is just to make
- /// constructs like Regex("...", 0) more readable as Regex("...", Sub).
- Sub=0,
+ NoFlags=0,
/// Compile for matching that ignores upper/lower case distinctions.
IgnoreCase=1,
- /// Compile for matching that need only report success or failure,
- /// not what was matched.
- NoSub=2,
/// Compile for newline-sensitive matching. With this flag '[^' bracket
/// expressions and '.' never match newline. A ^ anchor matches the
/// null string after any newline in the string in addition to its normal
/// function, and the $ anchor matches the null string before any
/// newline in the string in addition to its normal function.
- Newline=4
+ Newline=2
};
/// Compiles the given POSIX Extended Regular Expression \arg Regex.
/// This implementation supports regexes and matching strings with embedded
/// NUL characters.
- Regex(const StringRef &Regex, unsigned Flags=NoSub);
+ Regex(const StringRef &Regex, unsigned Flags = NoFlags);
~Regex();
/// isValid - returns the error encountered during regex compilation, or
/// matching, if any.
bool isValid(std::string &Error);
+ /// getNumMatches - In a valid regex, return the number of parenthesized
+ /// matches it contains. The number filled in by match will include this
+ /// many entries plus one for the whole regex (as element 0).
+ unsigned getNumMatches() const;
+
/// matches - Match the regex against a given \arg String.
///
/// \param Matches - If given, on a succesful match this will be filled in
/// with references to the matched group expressions (inside \arg String),
/// the first group is always the entire pattern.
- /// By default the regex is compiled with NoSub, which disables support for
- /// Matches.
- /// For this feature to be enabled you must construct the regex using
- /// Regex("...", Regex::Sub) constructor.
///
/// This returns true on a successful match.
bool match(const StringRef &String, SmallVectorImpl<StringRef> *Matches=0);
private:
struct llvm_regex *preg;
int error;
- bool sub;
};
}