This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Handle \n the same way as std::endl with stream operator.
ClosedPublic

Authored by jeanphilippeD on Dec 6 2015, 9:15 AM.

Details

Reviewers
djasper
Summary

clang-format break multi-line streams after std::endl.
It now also break for '\n', the suggested replacement for std::endl: http://llvm.org/docs/CodingStandards.html#avoid-std-endl

Before:
llvm::errs() << aaaaaaaaaaaaaaaaaaaaaa << '\n' << bbbbbbbbbbbbbbbbbbbbbb

<< '\n';

llvm::errs() << aaaa << "aaaaaaaaaaaaaaaaaa\n" << bbbb

<< "bbbbbbbbbbbbbbbbbb\n";

After:
llvm::errs() << aaaaaaaaaaaaaaaaaaaaaa << '\n'

<< bbbbbbbbbbbbbbbbbbbbbb << '\n';

llvm::errs() << aaaa << "aaaaaaaaaaaaaaaaaa\n"

<< bbbb << "bbbbbbbbbbbbbbbbbb\n";

This changeset ensure that multiline streams have a line break after:
-std::endl
-'\n'
-"\n"
-"Some Text\n"

Test:
-Run unit tests
-Run clang format on Format.cpp without it making changes compared to current clang-format.

Diff Detail

Event Timeline

jeanphilippeD retitled this revision from to [clang-format] Handle \n the same way as std::endl with stream operator..
jeanphilippeD updated this object.
jeanphilippeD added a reviewer: djasper.
jeanphilippeD added a subscriber: cfe-commits.

Ping.
Is that patch of interest?

djasper accepted this revision.Jan 4 2016, 2:01 AM
djasper edited edge metadata.

Looks good.

This revision is now accepted and ready to land.Jan 4 2016, 2:01 AM

Thanks,
Would you be happy to commit it for me since i do not have commit access.

djasper closed this revision.Jan 5 2016, 5:10 AM

Submitted as r256832.