[PATCH] Better support for multiline string literals (including C++11 raw string literals).

Daniel Jasper djasper at google.com
Thu Aug 29 07:24:56 PDT 2013


  A few remarks, otherwise looks good.


================
Comment at: lib/Format/ContinuationIndenter.h:87
@@ -86,1 +86,3 @@
 
+  unsigned addMultilineStringLiteral(const FormatToken &Current,
+                                     LineState &State);
----------------
comment

================
Comment at: lib/Format/ContinuationIndenter.cpp:586
@@ +585,3 @@
+  StringRef Text = Current.TokenText;
+  size_t FirstLineBreak = Text.find('\n');
+  size_t LastLineBreak = Text.find_last_of('\n');
----------------
Add a comment saying that we do not have to look at/penalize the lengths of any but the first line as they are outside of clang-format's influence anyway.

================
Comment at: lib/Format/ContinuationIndenter.cpp:620
@@ +619,3 @@
+    if (Current.TokenText.find('\n') != StringRef::npos)
+      return addMultilineStringLiteral(Current, State);
+
----------------
It seems bad to call Current.TokenText.find('\n') again in addMultilineStringLiteral (and even assert on the result). How about just passing this in?

================
Comment at: lib/Format/ContinuationIndenter.cpp:623
@@ -595,3 +622,3 @@
     // Only break up default narrow strings.
     if (!Current.TokenText.startswith("\""))
       return 0;
----------------
Why not still do this first? Seems to be the faster operation.


http://llvm-reviews.chandlerc.com/D1544

BRANCH
  svn

ARCANIST PROJECT
  clang



More information about the cfe-commits mailing list