r187650 - clang-format: Fix string breaking after "<<".
Daniel Jasper
djasper at google.com
Fri Aug 2 04:01:15 PDT 2013
Author: djasper
Date: Fri Aug 2 06:01:15 2013
New Revision: 187650
URL: http://llvm.org/viewvc/llvm-project?rev=187650&view=rev
Log:
clang-format: Fix string breaking after "<<".
Before, clang-format would not break overly long string literals
following a "<<" with FormatStyle::AlwaysBreakBeforeMultilineStrings
being set.
Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=187650&r1=187649&r2=187650&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Fri Aug 2 06:01:15 2013
@@ -936,7 +936,7 @@ private:
State.NextToken = State.NextToken->Next;
if (!Newline && Style.AlwaysBreakBeforeMultilineStrings &&
- Current.is(tok::string_literal))
+ Current.is(tok::string_literal) && Current.CanBreakBefore)
return 0;
return breakProtrudingToken(Current, State, DryRun);
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=187650&r1=187649&r2=187650&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Aug 2 06:01:15 2013
@@ -5167,6 +5167,11 @@ TEST_F(FormatTest, BreakStringLiterals)
"aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa "
"aaaaaaaaaaaaaaaaaaaaaa\");",
getGoogleStyle()));
+ EXPECT_EQ("llvm::outs() << \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \"\n"
+ " \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\";",
+ format("llvm::outs() << "
+ "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaa"
+ "aaaaaaaaaaaaaaaaaaa\";"));
FormatStyle AlignLeft = getLLVMStyleWithColumns(12);
AlignLeft.AlignEscapedNewlinesLeft = true;
More information about the cfe-commits
mailing list