mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-20 01:57:37 +00:00
[clang-format] Don't remove parentheses in macro definitions (#81444)
Closes #81399. (cherry picked from commit 4af24d4ab76539706bfbceec4b3923426fb1b9e7)
This commit is contained in:
parent
872fe20ddd
commit
ab57f6ced6
@ -2515,7 +2515,7 @@ bool UnwrappedLineParser::parseParens(TokenType AmpAmpTokenType) {
|
||||
parseChildBlock();
|
||||
break;
|
||||
case tok::r_paren:
|
||||
if (!MightBeStmtExpr &&
|
||||
if (!MightBeStmtExpr && !Line->InMacroBody &&
|
||||
Style.RemoveParentheses > FormatStyle::RPS_Leave) {
|
||||
const auto *Prev = LeftParen->Previous;
|
||||
const auto *Next = Tokens->peekNextToken();
|
||||
|
@ -26856,6 +26856,7 @@ TEST_F(FormatTest, RemoveParentheses) {
|
||||
EXPECT_EQ(Style.RemoveParentheses, FormatStyle::RPS_Leave);
|
||||
|
||||
Style.RemoveParentheses = FormatStyle::RPS_MultipleParentheses;
|
||||
verifyFormat("#define Foo(...) foo((__VA_ARGS__))", Style);
|
||||
verifyFormat("int x __attribute__((aligned(16))) = 0;", Style);
|
||||
verifyFormat("decltype((foo->bar)) baz;", Style);
|
||||
verifyFormat("class __declspec(dllimport) X {};",
|
||||
@ -26890,6 +26891,7 @@ TEST_F(FormatTest, RemoveParentheses) {
|
||||
verifyFormat("return (({ 0; }));", "return ((({ 0; })));", Style);
|
||||
|
||||
Style.RemoveParentheses = FormatStyle::RPS_ReturnStatement;
|
||||
verifyFormat("#define Return0 return (0);", Style);
|
||||
verifyFormat("return 0;", "return (0);", Style);
|
||||
verifyFormat("co_return 0;", "co_return ((0));", Style);
|
||||
verifyFormat("return 0;", "return (((0)));", Style);
|
||||
|
Loading…
x
Reference in New Issue
Block a user