Better support for constructor initializers.
authorDaniel Jasper <djasper@google.com>
Tue, 18 Dec 2012 21:05:13 +0000 (21:05 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 18 Dec 2012 21:05:13 +0000 (21:05 +0000)
commit2af6bbe7e0fae3eebb4ea3992c44dd10b38536c2
treef9745faa6895d577bbf6fea13476d86792a5e846
parent78eaf05fa72bd1376c0923329953fec20671b6b6
Better support for constructor initializers.

We used to format initializers like this (with a sort of hacky implementation):
Constructor()
    : Val1(A),
      Val2(B) {

and now format like this (with a somewhat better solution):
Constructor()
    : Val1(A), Val2(B) {

assuming this would not fit on a single line. Also added tests.

As a side effect we now first analyze whether an UnwrappedLine needs to be
split at all. If not, not splitting it is the best solution by definition. As
this should be a very common case in normal code, not exploring the entire
solution space can provide significant speedup.

llvm-svn: 170457
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTest.cpp