We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$ 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.
The text was updated successfully, but these errors were encountered:
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); }
Sorry, something went wrong.
Hello,
This two examples works fine with LLVM 11.0.0.
No branches or pull requests
Extended Description
$ 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.
The text was updated successfully, but these errors were encountered: