[PATCH] D44141: [clang-format] Use NestedBlockIndent as a 0 column in formatted raw strings

Krasimir Georgiev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 8 03:33:12 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL326996: [clang-format] Use NestedBlockIndent as a 0 column in formatted raw strings (authored by krasimir, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D44141

Files:
  cfe/trunk/lib/Format/ContinuationIndenter.cpp
  cfe/trunk/unittests/Format/FormatTestRawStrings.cpp


Index: cfe/trunk/lib/Format/ContinuationIndenter.cpp
===================================================================
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp
@@ -1385,9 +1385,10 @@
   // violate the rectangle rule and visually flows within the surrounding
   // source.
   bool ContentStartsOnNewline = Current.TokenText[OldPrefixSize] == '\n';
-  unsigned NextStartColumn = ContentStartsOnNewline
-                                 ? State.Stack.back().Indent + Style.IndentWidth
-                                 : FirstStartColumn;
+  unsigned NextStartColumn =
+      ContentStartsOnNewline
+          ? State.Stack.back().NestedBlockIndent + Style.IndentWidth
+          : FirstStartColumn;
 
   // The last start column is the column the raw string suffix starts if it is
   // put on a newline.
@@ -1399,7 +1400,7 @@
   //     indent.
   unsigned LastStartColumn = Current.NewlinesBefore
                                  ? FirstStartColumn - NewPrefixSize
-                                 : State.Stack.back().Indent;
+                                 : State.Stack.back().NestedBlockIndent;
 
   std::pair<tooling::Replacements, unsigned> Fixes = internal::reformat(
       RawStringStyle, RawText, {tooling::Range(0, RawText.size())},
Index: cfe/trunk/unittests/Format/FormatTestRawStrings.cpp
===================================================================
--- cfe/trunk/unittests/Format/FormatTestRawStrings.cpp
+++ cfe/trunk/unittests/Format/FormatTestRawStrings.cpp
@@ -681,15 +681,14 @@
 })test",
                    getRawStringPbStyleWithColumns(20)));
 
-  // Align the suffix with the surrounding FirstIndent if the prefix is not on
+  // Align the suffix with the surrounding indent if the prefix is not on
   // a line of its own.
   expect_eq(R"test(
 int s() {
-  auto S = PTP(
-      R"pb(
-        item_1: 1,
-        item_2: 2
-      )pb");
+  auto S = PTP(R"pb(
+    item_1: 1,
+    item_2: 2
+  )pb");
 })test",
             format(R"test(
 int s() {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44141.137553.patch
Type: text/x-patch
Size: 2046 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180308/87cc54ef/attachment.bin>


More information about the llvm-commits mailing list