clang-format: Fix bug in column layout.

Before (with 60 character limit in Google style):
  return {
      {aaaaaaaaaaaaaaaaaaaaaaaaa}, {aaaaaaaaaaaaaaaaa},
      {aaaaaaaaaaaaaaaaaaaaaaaaa}, {aaaaaaaaaaaaaaaaa}};
After:
  return {{aaaaaaaaaaaaaaaaaaaaaaaaa}, {aaaaaaaaaaaaaaaaa},
          {aaaaaaaaaaaaaaaaaaaaaaaaa}, {aaaaaaaaaaaaaaaaa}};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189327 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/FormatToken.cpp b/lib/Format/FormatToken.cpp
index 24a296a..e6c72ab 100644
--- a/lib/Format/FormatToken.cpp
+++ b/lib/Format/FormatToken.cpp
@@ -39,9 +39,13 @@
       LBrace->Next->Type == TT_DesignatedInitializerPeriod)
     return 0;
 
+  // Calculate the number of code points we have to format this list. As the
+  // first token is already placed, we have to subtract it.
+  unsigned RemainingCodePoints = Style.ColumnLimit - State.Column +
+                                 State.NextToken->Previous->CodePointCount;
+
   // Find the best ColumnFormat, i.e. the best number of columns to use.
-  unsigned RemainingCharacters = Style.ColumnLimit - State.Stack.back().Indent;
-  const ColumnFormat *Format = getColumnFormat(RemainingCharacters);
+  const ColumnFormat *Format = getColumnFormat(RemainingCodePoints);
   if (!Format)
     return 0;
 
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index fed054d..19a764c 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -4195,6 +4195,9 @@
                "                  1, 1, 1, 1,\n"
                "                  /**/ /**/ };",
                getLLVMStyleWithColumns(39));
+  verifyFormat("return { { aaaaaaaaaaaaaaaaaaaaa }, { aaaaaaaaaaaaaaaaaaa },\n"
+               "         { aaaaaaaaaaaaaaaaaaaaa }, { aaaaaaaaaaaaaaaaa } };",
+               getLLVMStyleWithColumns(60));
 }
 
 TEST_F(FormatTest, PullTrivialFunctionDefinitionsIntoSingleLine) {