Issue |
89595
|
Summary |
`readability-misleading-indentation` false positive on several stacked loops without indentation
|
Labels |
new issue
|
Assignees |
|
Reporter |
HolyBlackCat
|
```cpp
int main()
{
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
{}
(void)42;
}
```
Analyzing with `clang-tidy 1.cpp -checks=readability-misleading-indentation -- -Wall -Wextra` results in a false positive:
```
1 warning generated.
/path/to/1.cpp:6:5: warning: misleading indentation: statement is indented too deeply [readability-misleading-indentation]
6 | (void)42;
| ^
/path/to/1.cpp:3:5: note: did you mean this line to be inside this 'for'
3 | for (int i = 0; i < 3; i++)
| ^
```
Using this indentation style for 2D loops is not unheard of, and it's a shame that clang-tidy warns about those. (The warning is otherwise useful, so I don't want to disable it everywhere.)
I suggest that this warning should be skipped for control statements with non-indented bodies.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs