[PATCH] D154484: [clang-format] Add an option to remove redundant parentheses

2023-07-11 Thread Owen Pan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG3a6a0702c2a4: [clang-format] Add an option to remove redundant parentheses (authored by owenpan). Changed prior to commit:

[PATCH] D154484: [clang-format] Add an option to remove redundant parentheses

2023-07-10 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision. HazardyKnusperkeks added a comment. In D154484#4483659 , @sstwcw wrote: > Did you forget about GNU statement expressions? > > if (({ > foo(); > bar(); > })) { > } I wouldn't haven

[PATCH] D154484: [clang-format] Add an option to remove redundant parentheses

2023-07-09 Thread Owen Pan via Phabricator via cfe-commits
owenpan marked an inline comment as done. owenpan added a comment. In D154484#4483659 , @sstwcw wrote: > Did you forget about GNU statement expressions? > > if (({ > foo(); > bar(); > })) { > } Thanks! CHANGES SINCE LAST

[PATCH] D154484: [clang-format] Add an option to remove redundant parentheses

2023-07-09 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 538470. owenpan added a reviewer: sstwcw. owenpan removed a subscriber: sstwcw. owenpan added a comment. Don't treat `(` as `l_paren` if it's followed by `{`. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D154484/new/

[PATCH] D154484: [clang-format] Add an option to remove redundant parentheses

2023-07-09 Thread sstwcw via Phabricator via cfe-commits
sstwcw added a comment. Did you forget about GNU statement expressions? if (({ foo(); bar(); })) { } Comment at: clang/docs/ReleaseNotes.rst:804 - Add ``KeepEmptyLinesAtEOF`` to keep empty lines at end of file. +- Add ``RemoveParenthese`` to remove

[PATCH] D154484: [clang-format] Add an option to remove redundant parentheses

2023-07-07 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments. Comment at: clang/unittests/Format/FormatTest.cpp:25808 +TEST_F(FormatTest, RemoveParentheses) { + FormatStyle Style = getLLVMStyle(); owenpan wrote: > HazardyKnusperkeks wrote: > > Should check for `__attribute((what

[PATCH] D154484: [clang-format] Add an option to remove redundant parentheses

2023-07-06 Thread Owen Pan via Phabricator via cfe-commits
owenpan marked an inline comment as done. owenpan added a comment. In D154484#4475377 , @MyDeveloperDay wrote: > I reckon you could detect the `=` condition between the matching paren don't > you? Absolutely. Comment at:

[PATCH] D154484: [clang-format] Add an option to remove redundant parentheses

2023-07-06 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 537971. owenpan added a comment. This revision is now accepted and ready to land. Don't remove the outermost double parentheses after `if`/`while` if there is an `=` inside. Also rename the options. CHANGES SINCE LAST ACTION

[PATCH] D154484: [clang-format] Add an option to remove redundant parentheses

2023-07-06 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments. Comment at: clang/unittests/Format/FormatTest.cpp:25808 +TEST_F(FormatTest, RemoveParentheses) { + FormatStyle Style = getLLVMStyle(); Should check for `__attribute((what ever))__`. Repository: rG LLVM Github

[PATCH] D154484: [clang-format] Add an option to remove redundant parentheses

2023-07-05 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment. I reckon you could detect the `=` condition between the matching paren don't you? I ran this on my quite large code base and this was one of the only issues I've seen thus far.. This is a great feature, for my codebase this generated changes in about 10% of

[PATCH] D154484: [clang-format] Add an option to remove redundant parentheses

2023-07-05 Thread Owen Pan via Phabricator via cfe-commits
owenpan planned changes to this revision. owenpan added a comment. Yep! After reformating `clang/lib/Format/` and rebuilding clang-format, I got the same warning: WhitespaceManager.cpp:233:45: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]

[PATCH] D154484: [clang-format] Add an option to remove redundant parentheses

2023-07-05 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment. Here is a potential failure scenario (test.cpp) void *bar(); void foo() { void *p; int i = 0; while ((p = bar())) { i++; } } (.clang-format) Language: Cpp RemoveParentheses: ReturnStatement clang-format test.cpp >

[PATCH] D154484: [clang-format] Add an option to remove redundant parentheses

2023-07-05 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision. MyDeveloperDay added a comment. This revision is now accepted and ready to land. A thousand times yes! Comment at: clang/docs/ClangFormatStyleOptions.rst:4354 + + * ``RPS_None`` (in configuration: ``None``) +Do not remove

[PATCH] D154484: [clang-format] Add an option to remove redundant parentheses

2023-07-05 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision. Herald added projects: All, clang, clang-format. Herald added a subscriber: cfe-commits. Herald added reviewers: rymiel, HazardyKnusperkeks, MyDeveloperDay. owenpan requested review of this revision. Repository: rG LLVM Github Monorepo