clang-format: Fix corner case with comment in ctor initializer.
Formatting: Constructor() : // Comment forcing unwanted break. aaaa(aaaa) {} Before: Constructor() : // Comment forcing unwanted break. aaaa(aaaa) {} After: Constructor() : // Comment forcing unwanted break. aaaa(aaaa) {} llvm-svn: 199107
This commit is contained in:
parent
4e033b0e92
commit
f6c7c18b8e
|
@ -1436,6 +1436,7 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
|
|||
const FormatToken &Right) {
|
||||
if (Right.is(tok::comment)) {
|
||||
return Right.Previous->BlockKind != BK_BracedInit &&
|
||||
Right.Previous->Type != TT_CtorInitializerColon &&
|
||||
Right.NewlinesBefore > 0;
|
||||
} else if (Right.Previous->isTrailingComment() ||
|
||||
(Right.isStringLiteral() && Right.Previous->isStringLiteral())) {
|
||||
|
|
|
@ -2896,6 +2896,13 @@ TEST_F(FormatTest, ConstructorInitializers) {
|
|||
" : aaaaa(aaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaa,\n"
|
||||
" aaaaaaaaaaaaaaaaaaaaaa) {}",
|
||||
OnePerLine);
|
||||
|
||||
EXPECT_EQ("Constructor()\n"
|
||||
" : // Comment forcing unwanted break.\n"
|
||||
" aaaa(aaaa) {}",
|
||||
format("Constructor() :\n"
|
||||
" // Comment forcing unwanted break.\n"
|
||||
" aaaa(aaaa) {}"));
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, MemoizationTests) {
|
||||
|
|
Loading…
Reference in New Issue