]> granicus.if.org Git - clang/commitdiff
Use llvm::Regex::Escape in VerifyDiagnosticConsumer.cpp
authorHans Wennborg <hans@hanshq.net>
Thu, 12 Dec 2013 00:27:31 +0000 (00:27 +0000)
committerHans Wennborg <hans@hanshq.net>
Thu, 12 Dec 2013 00:27:31 +0000 (00:27 +0000)
This depends on LLVM r197096.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197101 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/VerifyDiagnosticConsumer.cpp

index b53fde257dee6d586380e88b0701d43f4f2b0b8c..40992fec3f6aafbd5c40573b0ababb705575768a 100644 (file)
@@ -851,36 +851,6 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() {
   ED.Notes.clear();
 }
 
-// Add the characters from FixedStr to RegexStr, escaping as needed.  This
-// avoids the need for backslash-escaping in common patterns.
-static void AddFixedStringToRegEx(StringRef FixedStr, std::string &RegexStr) {
-  // FIXME: Expose FileCheck.cpp's Pattern::AddFixedStringToRegEx as a utility
-  // method in RegEx.
-
-  for (unsigned i = 0, e = FixedStr.size(); i != e; ++i) {
-    switch (FixedStr[i]) {
-    // These are the special characters matched in "p_ere_exp".
-    case '(':
-    case ')':
-    case '^':
-    case '$':
-    case '|':
-    case '*':
-    case '+':
-    case '?':
-    case '.':
-    case '[':
-    case '\\':
-    case '{':
-      RegexStr += '\\';
-      // FALL THROUGH.
-    default:
-      RegexStr += FixedStr[i];
-      break;
-    }
-  }
-}
-
 Directive *Directive::create(bool RegexKind, SourceLocation DirectiveLoc,
                              SourceLocation DiagnosticLoc, StringRef Text,
                              unsigned Min, unsigned Max) {
@@ -905,7 +875,7 @@ Directive *Directive::create(bool RegexKind, SourceLocation DirectiveLoc,
       if (VerbatimMatchLength == StringRef::npos)
         VerbatimMatchLength = S.size();
       // Escape and append the fixed string.
-      AddFixedStringToRegEx(S.substr(0, VerbatimMatchLength), RegexStr);
+      RegexStr += llvm::Regex::escape(S.substr(0, VerbatimMatchLength));
       S = S.drop_front(VerbatimMatchLength);
     }
   }