Move UnescapeString to a static function for its sole client; its inefficient and...
authorDaniel Dunbar <daniel@zuster.org>
Sat, 17 Oct 2009 20:43:42 +0000 (20:43 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sat, 17 Oct 2009 20:43:42 +0000 (20:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84358 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/StringExtras.h
lib/Support/StringExtras.cpp
utils/TableGen/AsmWriterEmitter.cpp

index 76779fc306686a49cda23ae6e87115dcc9e89eea..899823d5c6c84e3a2310969d29f3fc62f4c75782 100644 (file)
@@ -217,11 +217,6 @@ void SplitString(const std::string &Source,
                  std::vector<std::string> &OutFragments,
                  const char *Delimiters = " \t\n\v\f\r");
 
-/// UnescapeString - Modify the argument string, turning two character sequences
-/// like '\\' 'n' into '\n'.  This handles: \e \a \b \f \n \r \t \v \' \\ and
-/// \num (where num is a 1-3 byte octal value).
-void UnescapeString(std::string &Str);
-
 /// HashString - Hash funtion for strings.
 ///
 /// This is the Bernstein hash function.
index 0a6e497f1ea6728af135674d6801fad0e17e6b89..c72f12165343116fcdf8c0496d0023cf7c1ee651 100644 (file)
@@ -56,33 +56,3 @@ void llvm::SplitString(const std::string &Source,
     S2 = getToken(S, Delimiters);
   }
 }
-
-
-
-/// UnescapeString - Modify the argument string, turning two character sequences
-/// @verbatim
-/// like '\\' 'n' into '\n'.  This handles: \e \a \b \f \n \r \t \v \' \ and
-/// \num (where num is a 1-3 byte octal value).
-/// @endverbatim
-void llvm::UnescapeString(std::string &Str) {
-  for (unsigned i = 0; i != Str.size(); ++i) {
-    if (Str[i] == '\\' && i != Str.size()-1) {
-      switch (Str[i+1]) {
-      default: continue;  // Don't execute the code after the switch.
-      case 'a': Str[i] = '\a'; break;
-      case 'b': Str[i] = '\b'; break;
-      case 'e': Str[i] = 27; break;
-      case 'f': Str[i] = '\f'; break;
-      case 'n': Str[i] = '\n'; break;
-      case 'r': Str[i] = '\r'; break;
-      case 't': Str[i] = '\t'; break;
-      case 'v': Str[i] = '\v'; break;
-      case '"': Str[i] = '\"'; break;
-      case '\'': Str[i] = '\''; break;
-      case '\\': Str[i] = '\\'; break;
-      }
-      // Nuke the second character.
-      Str.erase(Str.begin()+i+1);
-    }
-  }
-}
index 84a647bea309e61ba753db6694a36d908e142c18..ff348e8e706dff499ed4a3970503ee0e91a239a6 100644 (file)
@@ -538,6 +538,29 @@ FindUniqueOperandCommands(std::vector<std::string> &UniqueOperandCommands,
 }
 
 
+static void UnescapeString(std::string &Str) {
+  for (unsigned i = 0; i != Str.size(); ++i) {
+    if (Str[i] == '\\' && i != Str.size()-1) {
+      switch (Str[i+1]) {
+      default: continue;  // Don't execute the code after the switch.
+      case 'a': Str[i] = '\a'; break;
+      case 'b': Str[i] = '\b'; break;
+      case 'e': Str[i] = 27; break;
+      case 'f': Str[i] = '\f'; break;
+      case 'n': Str[i] = '\n'; break;
+      case 'r': Str[i] = '\r'; break;
+      case 't': Str[i] = '\t'; break;
+      case 'v': Str[i] = '\v'; break;
+      case '"': Str[i] = '\"'; break;
+      case '\'': Str[i] = '\''; break;
+      case '\\': Str[i] = '\\'; break;
+      }
+      // Nuke the second character.
+      Str.erase(Str.begin()+i+1);
+    }
+  }
+}
+
 /// EmitPrintInstruction - Generate the code for the "printInstruction" method
 /// implementation.
 void AsmWriterEmitter::EmitPrintInstruction(raw_ostream &O) {