There is this new "LLVM" compiler that supports __builtin_bswap but thinks it's gcc...
[oota-llvm.git] / include / llvm / Support / Regex.h
index c954c0d31abe21aaf7396a7a4882f26d189af605..ea65ccf3aa3aab86cea0ebbcf2a1b0dba5c78c2d 100644 (file)
@@ -36,7 +36,7 @@ namespace llvm {
     /// 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 = NoFlags);
+    Regex(StringRef Regex, unsigned Flags = NoFlags);
     ~Regex();
 
     /// isValid - returns the error encountered during regex compilation, or
@@ -55,7 +55,20 @@ namespace llvm {
     /// the first group is always the entire pattern.
     ///
     /// This returns true on a successful match.
-    bool match(const StringRef &String, SmallVectorImpl<StringRef> *Matches=0);
+    bool match(StringRef String, SmallVectorImpl<StringRef> *Matches = 0);
+
+    /// sub - Return the result of replacing the first match of the regex in
+    /// \arg String with the \arg Repl string. Backreferences like "\0" in the
+    /// replacement string are replaced with the appropriate match substring.
+    ///
+    /// Note that the replacement string has backslash escaping performed on
+    /// it. Invalid backreferences are ignored (replaced by empty strings).
+    ///
+    /// \param Error If non-null, any errors in the substitution (invalid
+    /// backreferences, trailing backslashes) will be recorded as a non-empty
+    /// string.
+    std::string sub(StringRef Repl, StringRef String, std::string *Error = 0);
+
   private:
     struct llvm_regex *preg;
     int error;