fune/tools/clang-tidy/test/readability-braces-around-statements.cpp
Jeff Gilbert 85bbcbfa5e Bug 1602143 - Use ShortStatementLines=1 for readability-braces-around-statements. r=andi
This will reduce the false-positive rate that sometimes causes devs to
ignore other important warnings because they expect to see these
warnings because of module/legacy code styles.

```
if (foo) return; // no longer warns
if (bar)
  return; // still warns
```
clang-format will sometimes turn long-line versions of the former into
the latter, and this warning will pick those as readability warnings.
NB: This is Chromium style for same-line conditional statements.

Another test result json has its EOL-newline removed too, since that's
what the script does and I'm just committing its results.

Differential Revision: https://phabricator.services.mozilla.com/D105497
2021-02-18 08:26:11 +00:00

38 lines
494 B
C++

void do_something(const char *) {}
bool cond(const char *) {
return false;
}
void test() {
if (cond("if0") /*comment*/) do_something("same-line");
if (cond("if1") /*comment*/)
do_something("next-line");
if (!1) return;
if (!2) { return; }
if (!3)
return;
if (!4) {
return;
}
}
void foo() {
if (1) while (2) if (3) for (;;) do ; while(false) /**/;/**/
}
void f() {}
void foo2() {
constexpr bool a = true;
if constexpr (a) {
f();
} else {
f();
}
}