Index: include/llvm/Support/Regex.h =================================================================== --- include/llvm/Support/Regex.h +++ include/llvm/Support/Regex.h @@ -74,7 +74,8 @@ /// the first group is always the entire pattern. /// /// This returns true on a successful match. - bool match(StringRef String, SmallVectorImpl *Matches = nullptr); + bool match(StringRef String, + SmallVectorImpl *Matches = nullptr) const; /// sub - Return the result of replacing the first match of the regex in /// \p String with the \p Repl string. Backreferences like "\0" in the @@ -98,7 +99,7 @@ private: struct llvm_regex *preg; - int error; + mutable int error; }; } Index: lib/Support/Regex.cpp =================================================================== --- lib/Support/Regex.cpp +++ lib/Support/Regex.cpp @@ -56,7 +56,7 @@ return preg->re_nsub; } -bool Regex::match(StringRef String, SmallVectorImpl *Matches){ +bool Regex::match(StringRef String, SmallVectorImpl *Matches) const { unsigned nmatch = Matches ? preg->re_nsub+1 : 0; // pmatch needs to have at least one element.