clang-format: Improve braced init list detection:
Before:
std::this_thread::sleep_for(std::chrono::nanoseconds{
std::chrono::seconds { 1 }
} /
5);
After:
std::this_thread::sleep_for(
std::chrono::nanoseconds{ std::chrono::seconds{ 1 } } / 5);
This fixes llvm.org/PR16554.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189451 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp
index d77f931..168b59e 100644
--- a/lib/Format/UnwrappedLineParser.cpp
+++ b/lib/Format/UnwrappedLineParser.cpp
@@ -284,8 +284,12 @@
// Thus, if the parent is a braced init list, we consider all
// brace blocks inside it braced init list. That works good enough
// for now, but we will need to fix it to correctly handle lambdas.
+ //
+ // We exclude + and - as they can be ObjC visibility modifiers.
if (NextTok->isOneOf(tok::comma, tok::semi, tok::r_paren,
- tok::l_brace, tok::colon)) {
+ tok::l_brace, tok::colon) ||
+ (NextTok->isBinaryOperator() &&
+ !NextTok->isOneOf(tok::plus, tok::minus))) {
Tok->BlockKind = BK_BracedInit;
LBraceStack.back()->BlockKind = BK_BracedInit;
} else {