forked from OSchip/llvm-project
Only break string literals as a last resort.
We might want to move towards doing this if the formatting can be significantly improved, but we need to carefully evaluate the different situations first. Before (the string literal was split by clang-format here): aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaa, aaaaaa("aaa aaaaa aaa aaa aaaaa aaa " "aaaaa aaa aaa aaaaaa")); After: aaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaa, aaaaaa("aaa aaaaa aaa aaa aaaaa aaa aaaaa aaa aaa aaaaaa")); llvm-svn: 176084
This commit is contained in:
parent
46c0bc233b
commit
5497fce41c
|
@ -727,7 +727,7 @@ private:
|
|||
TailOffset += SplitPoint + 1;
|
||||
TailLength -= SplitPoint + 1;
|
||||
OffsetFromStart = 1;
|
||||
Penalty += 100;
|
||||
Penalty += Style.PenaltyExcessCharacter;
|
||||
}
|
||||
State.Column = StartColumn + TailLength;
|
||||
return Penalty;
|
||||
|
|
|
@ -2984,6 +2984,12 @@ TEST_F(FormatTest, BreakStringLiterals) {
|
|||
" \"text\",\n"
|
||||
" other);",
|
||||
format("f(\"some text\", other);", getLLVMStyleWithColumns(10)));
|
||||
|
||||
// Only break as a last resort.
|
||||
verifyFormat(
|
||||
"aaaaaaaaaaaaaaaaaaaa(\n"
|
||||
" aaaaaaaaaaaaaaaaaaaa,\n"
|
||||
" aaaaaa(\"aaa aaaaa aaa aaa aaaaa aaa aaaaa aaa aaa aaaaaa\"));");
|
||||
}
|
||||
|
||||
} // end namespace tooling
|
||||
|
|
Loading…
Reference in New Issue