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
When a statement contains a line continuation, google-readability-braces-around-statements creates invalid code when fixit is applied.
Original code:
#include <stdio.h>
void f(int i) { if (i > 0) printf("This is one line\n This is another line.\n This is yet another line.\n"); }
Code as modified by clang-tidy:
void f(int i) { if (i > 0) { printf("This is one line\n This is another line.\n This is yet another line.\n") }; }
Correct code should be:
void f(int i) { if (i > 0) { printf("This is one line\n This is another line.\n This is yet another line.\n"); } }
The text was updated successfully, but these errors were encountered:
A smaller repro: $ cat /tmp/q.cc void f(const char p) { if (!p) f(" "); } $ clang_tidy -checks=-,google-readability-braces-around-statements -fix /tmp/q.cc -- 1 warning generated. /tmp/q.cc:2:10: warning: statement should be inside braces [google-readability-braces-around-statements] if (!p) ^ /tmp/q.cc:2:10: note: FIX-IT applied suggested code changes /tmp/q.cc:4:3: note: FIX-IT applied suggested code changes "); ^ clang-tidy applied 2 of 2 suggested fixes. $ cat /tmp/q.cc void f(const char *p) { if (!p) { f(" ") }; }
Sorry, something went wrong.
Paweł's patch addressing this is in review here: https://reviews.llvm.org/D30748.
No branches or pull requests
Extended Description
When a statement contains a line continuation, google-readability-braces-around-statements creates invalid code when fixit is applied.
Original code:
#include <stdio.h>
void f(int i) {
if (i > 0)
printf("This is one line\n
This is another line.\n
This is yet another line.\n");
}
Code as modified by clang-tidy:
#include <stdio.h>
void f(int i) {
if (i > 0) {
printf("This is one line\n
This is another line.\n
This is yet another line.\n")
};
}
Correct code should be:
#include <stdio.h>
void f(int i) {
if (i > 0) {
printf("This is one line\n
This is another line.\n
This is yet another line.\n");
}
}
The text was updated successfully, but these errors were encountered: