nextToken();
if (FormatTok->is(tok::exclaim))
nextToken();
+
+ bool KeepIfBraces = false;
+ bool KeepElseBraces = false;
if (FormatTok->is(tok::kw_consteval)) {
+ KeepIfBraces = true;
+ KeepElseBraces = true;
nextToken();
} else {
if (FormatTok->isOneOf(tok::kw_constexpr, tok::identifier))
parseUnbracedBody();
}
- bool KeepIfBraces = false;
if (Style.RemoveBracesLLVM) {
assert(!NestedTooDeep.empty());
- KeepIfBraces = (IfLeftBrace && !IfLeftBrace->MatchingParen) ||
+ KeepIfBraces = KeepIfBraces ||
+ (IfLeftBrace && !IfLeftBrace->MatchingParen) ||
NestedTooDeep.back() || IfBlockKind == IfStmtKind::IfOnly ||
IfBlockKind == IfStmtKind::IfElseIf;
}
return nullptr;
assert(!NestedTooDeep.empty());
- const bool KeepElseBraces =
- (ElseLeftBrace && !ElseLeftBrace->MatchingParen) || NestedTooDeep.back();
+ KeepElseBraces = KeepElseBraces ||
+ (ElseLeftBrace && !ElseLeftBrace->MatchingParen) ||
+ NestedTooDeep.back();
NestedTooDeep.pop_back();
"}",
Style);
+ verifyFormat("if consteval {\n"
+ " f();\n"
+ "} else {\n"
+ " g();\n"
+ "}",
+ Style);
+
+ verifyFormat("if not consteval {\n"
+ " f();\n"
+ "} else if (a) {\n"
+ " g();\n"
+ "}",
+ Style);
+
+ verifyFormat("if !consteval {\n"
+ " g();\n"
+ "}",
+ Style);
+
Style.ColumnLimit = 65;
verifyFormat("if (condition) {\n"