[PATCH] D39279: Stringizing raw string literals containing newline

Jan Korous via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 1 08:48:17 PST 2017


jkorous-apple added a comment.

Thank you for your patience @twoh and sorry for the delay.
I have few suggestions about doxygen annotations but otherwise LGTM.



================
Comment at: include/clang/Lex/Lexer.h:247
+  /// add surrounding ""'s to the string. If Charify is true, this escapes the
+  /// ' character instead of ".
   static std::string Stringify(StringRef Str, bool Charify = false);
----------------
Shouldn't we put all the details from implementation annotation here as well (since this is the public interface that people will actually use)?


================
Comment at: include/clang/Lex/Lexer.h:251
+  /// Stringify - Convert the specified string into a C string. This does not
+  /// add surrounding ""'s to the string.
   static void Stringify(SmallVectorImpl<char> &Str);
----------------
Shouldn't we put all the details from implementation annotation here as well (since this is the public interface that people will actually use)?


================
Comment at: lib/Lex/Lexer.cpp:214
+/// specified string into a C string by i) escaping '\' and " characters and
+/// ii) replacing newline character(s) with "\n".
+template <typename T>
----------------
I am not sure I understand this correctly but wouldn't it be more precise if these literals are escaped?
... escaping '\' ... -> ...escaping '\\' ... 
... with "\n" ... -> ... with "\\n"

Alternatively we could use R"(\)" and R"(\n)".


https://reviews.llvm.org/D39279





More information about the cfe-commits mailing list