summaryrefslogtreecommitdiffstats
path: root/clang/unittests
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2016-01-05 13:06:27 +0000
committerDaniel Jasper <djasper@google.com>2016-01-05 13:06:27 +0000
commit0a589416e89dbcc1747ce4c2fe053bae53f66bf6 (patch)
tree1f8fc5cd9b9901e6d1592c104b2e4cb4f0011b1a /clang/unittests
parent801cdb27e4639ffab3bec7141ed16c8830c44e62 (diff)
downloadbcm5719-llvm-0a589416e89dbcc1747ce4c2fe053bae53f66bf6.tar.gz
bcm5719-llvm-0a589416e89dbcc1747ce4c2fe053bae53f66bf6.zip
clang-format: Handle \n the same way as std::endl with stream operator.
clang-format breaks 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" Patch by Jean-Philippe Dufraigne, thank you. llvm-svn: 256832
Diffstat (limited to 'clang/unittests')
-rw-r--r--clang/unittests/Format/FormatTest.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 11acb9ec1b9..8156dc7a3aa 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -5065,6 +5065,15 @@ TEST_F(FormatTest, AlignsPipes) {
verifyFormat("llvm::errs() << aaaaaaaaaaaaaaaaaaaaaa << endl\n"
" << bbbbbbbbbbbbbbbbbbbbbb << endl;");
verifyFormat("llvm::errs() << endl << bbbbbbbbbbbbbbbbbbbbbb << endl;");
+
+ // Handle '\n'.
+ verifyFormat("llvm::errs() << aaaaaaaaaaaaaaaaaaaaaa << \"\\n\"\n"
+ " << bbbbbbbbbbbbbbbbbbbbbb << \"\\n\";");
+ verifyFormat("llvm::errs() << aaaaaaaaaaaaaaaaaaaaaa << \'\\n\'\n"
+ " << bbbbbbbbbbbbbbbbbbbbbb << \'\\n\';");
+ verifyFormat("llvm::errs() << aaaa << \"aaaaaaaaaaaaaaaaaa\\n\"\n"
+ " << bbbb << \"bbbbbbbbbbbbbbbbbb\\n\";");
+ verifyFormat("llvm::errs() << \"\\n\" << bbbbbbbbbbbbbbbbbbbbbb << \"\\n\";");
}
TEST_F(FormatTest, UnderstandsEquals) {
OpenPOWER on IntegriCloud