[PATCH] D19586: Misleading Indentation check
Etienne Bergeron via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 29 10:41:49 PDT 2016
etienneb added a comment.
You should not limit the checker to "if".
The for-statement and while-statement are also wrong for the same reasons:
while (x)
statement1();
statement2();
for (...)
statement1();
statement2();
You should test your code over large code base.
You should catch these cases:
https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/core/frame/FrameView.cpp&q=setMediaType&sq=package:chromium&type=cs&l=1253
You will also find strange cases like:
https://code.google.com/p/chromium/codesearch#chromium/src/third_party/icu/source/i18n/usearch.cpp&q=initializepattern&sq=package:chromium&type=cs&l=438
The rule also apply for statements in a same compound:
{
statement1();
statement2();
statement3();
see: https://code.google.com/p/chromium/codesearch#chromium/src/third_party/icu/source/common/ushape.cpp&q=third_party/icu/source/common/ushape.cpp&sq=package:chromium&type=cs&l=784
But this can be a further improvement.
http://reviews.llvm.org/D19586
More information about the cfe-commits
mailing list