Skip to content

Commit

Permalink
[clang-format] Fix braced initializer with templated base class
Browse files Browse the repository at this point in the history
Fixes #64134.

Differential Revision: https://reviews.llvm.org/D156705
  • Loading branch information
Galen Elias authored and owenca committed Aug 1, 2023
1 parent 1d9c7c4 commit 400da11
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clang/lib/Format/UnwrappedLineParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,8 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) {
ProbablyBracedList =
ProbablyBracedList ||
(NextTok->is(tok::l_brace) && LBraceStack.back().PrevTok &&
LBraceStack.back().PrevTok->is(tok::identifier));
LBraceStack.back().PrevTok->isOneOf(tok::identifier,
tok::greater));

ProbablyBracedList =
ProbablyBracedList ||
Expand Down
2 changes: 2 additions & 0 deletions clang/unittests/Format/FormatTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13458,6 +13458,8 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
verifyFormat(
"class A {\n"
" A() : a{} {}\n"
" A() : Base<int>{} {}\n"
" A() : Base<Foo<int>>{} {}\n"
" A(int b) : b(b) {}\n"
" A(int a, int b) : a(a), bs{{bs...}} { f(); }\n"
" int a, b;\n"
Expand Down

0 comments on commit 400da11

Please sign in to comment.