[cfe-dev] [patch] Support for C++0x raw string literals

Chris Lattner clattner at apple.com
Tue Aug 9 22:41:53 PDT 2011


On Aug 9, 2011, at 12:07 AM, Craig Topper wrote:

> Here's my new and improved patch. Changes from previous version:
> 

Hi Craig,

I don't know enough about the standard to know if this implements the right thing, but here's a general code review:

+++ include/clang/Lex/LiteralSupport.h	(working copy)
@@ -197,6 +197,7 @@
 
 private:
   void init(const Token *StringToks, unsigned NumStringToks);
+  void CopyStringFragment(const char *Start, const char *End);


This should probably take a StringRef.


+++ lib/Lex/Lexer.cpp	(working copy)

+  while (PrefixLen != 16 && isRawStringDelimBody(CurPtr[PrefixLen]))
+     ++PrefixLen;

Please indent by 2, not 3 spaces.

+      if (C == '"') {
+        break;
+      } else 

No need for "else" after break, or the curlies around the break.


Given how terrible it could have been ("undoing" phases of translation etc), I'm very pleased with how clean the Lexer code turned out!


+++ lib/Lex/TokenConcatenation.cpp	(working copy)

+// IsStringPrefix - Return true if the buffer contains a string prefix
+static inline bool IsStringPrefix(const char *Ptr, unsigned length,

Please make this a proper doxygen context, and finish your thought in the comment :).

Please make it take a StringRef instead of ptr+length.  This may also let you simplify its body, using startsWith etc.

Please change the body of this function to be multiple if statements instead of one big ||/&& conglomeration :)

I'll trust you on the LiteralSupport.cpp part :)

Thanks Craig, this is great work!  Feel free to commit with these updates if you agree to them,

-Chris



More information about the cfe-dev mailing list