summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-02-04 07:34:48 +0000
committerDaniel Jasper <djasper@google.com>2013-02-04 07:34:48 +0000
commit2603ee0dc6003be0fbe43038b34580864d1e0c85 (patch)
treeebed4e5e8411eea58e2240bf06db70992cedafea /clang/lib/Format/TokenAnnotator.cpp
parent1f140981b6af0c8cf0455a9999707a837de071ad (diff)
downloadbcm5719-llvm-2603ee0dc6003be0fbe43038b34580864d1e0c85.tar.gz
bcm5719-llvm-2603ee0dc6003be0fbe43038b34580864d1e0c85.zip
Improve formatting of stream operators.
If there are string literals on either side of a '<<', chances are high that they represent logically separate concepts. Otherwise, the author could just have just a single literal (possible split over multiple lines). So, we can now nicely format things like: cout << "somepacket = {\n" << " val a = " << ValueA << "\n" << " val b = " << ValueB << "\n" << "}"; llvm-svn: 174310
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 0cfd9903cb8..34bccb978e7 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -669,6 +669,10 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedToken &Current) {
(Current.is(tok::string_literal) &&
Current.Parent->is(tok::string_literal))) {
Current.MustBreakBefore = true;
+ } else if (Current.is(tok::lessless) && !Current.Children.empty() &&
+ Current.Parent->is(tok::string_literal) &&
+ Current.Children[0].is(tok::string_literal)) {
+ Current.MustBreakBefore = true;
} else {
Current.MustBreakBefore = false;
}
OpenPOWER on IntegriCloud