release/20.x: [clang-format] RemoveParentheses shouldn't remove empty parentheses (#138229)
Backport d3506ee573a2aa1403817642ef45f8c0305bb572
This commit is contained in:
parent
5429418cb0
commit
a7166c3739
@ -2581,7 +2581,8 @@ bool UnwrappedLineParser::parseParens(TokenType AmpAmpTokenType) {
|
||||
if (Prev) {
|
||||
auto OptionalParens = [&] {
|
||||
if (MightBeStmtExpr || MightBeFoldExpr || Line->InMacroBody ||
|
||||
SeenComma || Style.RemoveParentheses == FormatStyle::RPS_Leave) {
|
||||
SeenComma || Style.RemoveParentheses == FormatStyle::RPS_Leave ||
|
||||
RParen->getPreviousNonComment() == LParen) {
|
||||
return false;
|
||||
}
|
||||
const bool DoubleParens =
|
||||
|
@ -27895,6 +27895,8 @@ TEST_F(FormatTest, RemoveParentheses) {
|
||||
verifyFormat("return ((... && std::is_convertible_v<TArgsLocal, TArgs>));",
|
||||
"return (((... && std::is_convertible_v<TArgsLocal, TArgs>)));",
|
||||
Style);
|
||||
verifyFormat("MOCK_METHOD(void, Function, (), override);",
|
||||
"MOCK_METHOD(void, Function, (), (override));", Style);
|
||||
|
||||
Style.RemoveParentheses = FormatStyle::RPS_ReturnStatement;
|
||||
verifyFormat("#define Return0 return (0);", Style);
|
||||
|
Loading…
x
Reference in New Issue
Block a user