clang-format: Improve <<-formatting.

This fixes a regression caused by r186115.

Before:
  Diag(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
       bbbbbbbbb) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
                  << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;

After:
  Diag(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb)
      << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
      << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;

llvm-svn: 186164
This commit is contained in:
Daniel Jasper 2013-07-12 15:14:05 +00:00
parent 764d8d3d6f
commit 77d5d31320
2 changed files with 10 additions and 0 deletions

View File

@ -1174,6 +1174,11 @@ private:
State.Stack.back().BreakBeforeParameter)
return true;
// Same as above, but for the first "<<" operator.
if (Current.is(tok::lessless) && State.Stack.back().BreakBeforeParameter &&
State.Stack.back().FirstLessLess == 0)
return true;
// FIXME: Comparing LongestObjCSelectorName to 0 is a hacky way of finding
// out whether it is the first parameter. Clean this up.
if (Current.Type == TT_ObjCSelectorName &&

View File

@ -3026,6 +3026,11 @@ TEST_F(FormatTest, AlignsPipes) {
" << aaaaaaaaaaaaaaaaaaaaaaaaaaaa;",
getLLVMStyleWithColumns(70));
// But sometimes, breaking before the first "<<" is necessary.
verifyFormat("Diag(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb)\n"
" << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
" << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;");
verifyFormat(
"llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
" .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();");