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

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 5 10:55:46 PDT 2023


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 > test2.cpp



  test2.cpp:7:12: warning: using the result of an assignment as a condition
        without parentheses [-Wparentheses]
    while (p = bar()) {
           ~~^~~~~~~
  test2.cpp:7:12: note: place parentheses around the assignment to silence this
        warning
    while (p = bar()) {
             ^
           (        )
  test2.cpp:7:12: note: use '==' to turn this assignment into an equality
        comparison
    while (p = bar()) {
             ^
             ==
  1 warning generated.




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154484/new/

https://reviews.llvm.org/D154484



More information about the cfe-commits mailing list