From 2603ee0dc6003be0fbe43038b34580864d1e0c85 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 4 Feb 2013 07:34:48 +0000 Subject: 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 --- clang/lib/Format/TokenAnnotator.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'clang/lib/Format/TokenAnnotator.cpp') 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; } -- cgit v1.2.3