]> granicus.if.org Git - clang/commitdiff
Improve clang-format's stream formatting.
authorDaniel Jasper <djasper@google.com>
Wed, 22 May 2013 09:13:26 +0000 (09:13 +0000)
committerDaniel Jasper <djasper@google.com>
Wed, 22 May 2013 09:13:26 +0000 (09:13 +0000)
clang-format was a bit too aggressive when trying to keep labels and
values on the same line.

Before:
    llvm::outs()
         << "aaaaaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaa(
                                           aaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
  llvm::outs() << "aaaaaaaaaaaaaaaaaaa: "
               << aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182458 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp

index 598eb1ae77b77d240bd14a6df19bbf223fb4a36b..4541c6b3c4bbc95c023c39d998e55387a3c6abc3 100644 (file)
@@ -991,7 +991,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
       Content = Content.drop_back(1).drop_front(1).trim();
       if (Content.size() > 1 &&
           (Content.back() == ':' || Content.back() == '='))
-        return 100;
+        return 20;
     }
     return prec::Shift;
   }
index 8c178d6a5c1f05edc14c393a4c0d06fcbf36c5ce..5ea531f350e63a4720f62479258a02a2f03f6958 100644 (file)
@@ -2360,6 +2360,8 @@ TEST_F(FormatTest, AlignsPipes) {
       "             << \"eeeeeeeeeeeeeeeee = \" << eeeeeeeeeeeeeeeee;");
   verifyFormat("llvm::outs() << aaaaaaaaaaaaaaaaaaaaaaaa << \"=\"\n"
                "             << bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;");
+  verifyFormat("llvm::outs() << \"aaaaaaaaaaaaaaaaaaaaaaaa: \"\n"
+               "             << aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
 
   verifyFormat(
       "llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"