aboutsummaryrefslogtreecommitdiff
path: root/Lex/Lexer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Lex/Lexer.cpp')
-rw-r--r--Lex/Lexer.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lex/Lexer.cpp b/Lex/Lexer.cpp
index f23d34ed42..c45a36a9a5 100644
--- a/Lex/Lexer.cpp
+++ b/Lex/Lexer.cpp
@@ -92,6 +92,17 @@ std::string Lexer::Stringify(const std::string &Str, bool Charify) {
return Result;
}
+/// Stringify - Convert the specified string into a C string by escaping '\'
+/// and " characters. This does not add surrounding ""'s to the string.
+void Lexer::Stringify(llvm::SmallVectorImpl<char> &Str) {
+ for (unsigned i = 0, e = Str.size(); i != e; ++i) {
+ if (Str[i] == '\\' || Str[i] == '"') {
+ Str.insert(Str.begin()+i, '\\');
+ ++i; ++e;
+ }
+ }
+}
+
//===----------------------------------------------------------------------===//
// Character information.