Skip to content

Commit 400da11

Browse files
Galen Eliasowenca
Galen Elias
authored andcommitted
[clang-format] Fix braced initializer with templated base class
Fixes #64134. Differential Revision: https://reviews.llvm.org/D156705
1 parent 1d9c7c4 commit 400da11

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,8 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) {
581581
ProbablyBracedList =
582582
ProbablyBracedList ||
583583
(NextTok->is(tok::l_brace) && LBraceStack.back().PrevTok &&
584-
LBraceStack.back().PrevTok->is(tok::identifier));
584+
LBraceStack.back().PrevTok->isOneOf(tok::identifier,
585+
tok::greater));
585586

586587
ProbablyBracedList =
587588
ProbablyBracedList ||

clang/unittests/Format/FormatTest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13458,6 +13458,8 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
1345813458
verifyFormat(
1345913459
"class A {\n"
1346013460
" A() : a{} {}\n"
13461+
" A() : Base<int>{} {}\n"
13462+
" A() : Base<Foo<int>>{} {}\n"
1346113463
" A(int b) : b(b) {}\n"
1346213464
" A(int a, int b) : a(a), bs{{bs...}} { f(); }\n"
1346313465
" int a, b;\n"

0 commit comments

Comments
 (0)