$ cat test.cc #define MACRO_1 i++ #define MACRO_2 void test(int i) { if( i % 3) i--; // OK else if( i % 2) MACRO_1; // KO, no braces else MACRO_2; // OK } $ clang_tidy -checks=-*,readability-braces-around-statements -fix test.cc -- 2 warnings generated. test.cc:6:19: warning: statement should be inside braces [readability-braces-around-statements] if( i % 3) i--; // OK ^ test.cc:6:19: note: FIX-IT applied suggested code changes if( i % 3) i--; // OK ^ test.cc:7:9: note: FIX-IT applied suggested code changes else if( i % 2) MACRO_1; // KO, no braces ^ test.cc:8:13: warning: statement should be inside braces [readability-braces-around-statements] else MACRO_2; // OK ^ test.cc:8:13: note: FIX-IT applied suggested code changes else MACRO_2; // OK ^ test.cc:8:28: note: FIX-IT applied suggested code changes else MACRO_2; // OK ^ clang-tidy applied 4 of 4 suggested fixes.
Another test case: $ cat test.cc #define M(x) x int f(bool b) { if (b) return 1; else return 2; if (b) return 1; else M(return 2); } $ clang_tidy -fix test.cc -- 3 warnings generated. ... clang-tidy applied 6 of 6 suggested fixes. $ cat test.cc #define M(x) x int f(bool b) { if (b) { return 1; } else { return 2; } if (b) { return 1; } else M(return 2); }
Hello, This two examples works fine with LLVM 11.0.0.