[llvm-branch-commits] [clang] 2c9feb0 - [clang-format] Fix braced initializer with templated base class
Tobias Hieta via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Aug 30 08:08:26 PDT 2023
Author: Galen Elias
Date: 2023-08-30T16:59:39+02:00
New Revision: 2c9feb07f3370d2f5bab2a4731dd2500079e4ec8
URL: https://github.com/llvm/llvm-project/commit/2c9feb07f3370d2f5bab2a4731dd2500079e4ec8
DIFF: https://github.com/llvm/llvm-project/commit/2c9feb07f3370d2f5bab2a4731dd2500079e4ec8.diff
LOG: [clang-format] Fix braced initializer with templated base class
Fixes #64134.
Differential Revision: https://reviews.llvm.org/D156705
(cherry picked from commit 400da115c58ae19445cfdc871a3f559f160fc5c6)
Added:
Modified:
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTest.cpp
Removed:
################################################################################
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 32619bc56f7a3f..28e2954b5bebaf 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -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 ||
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index e512a861dc4e35..ed0c5e64f44743 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -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"
More information about the llvm-branch-commits
mailing list