[cfe-dev] Warning on strange indent
Nico Weber
thakis at chromium.org
Sun Feb 23 15:58:26 PST 2014
Hi,
motivated by the current libsecurity_ssl brouhaha, I experimented with
giving clang a -Windent that warns on strange indent. For performance and
other reasons, it it only compares the indent of the first statement after
a non-composite if/for/while with the indent of the if/for/while itself,
and warns if the statement following the if/for/while (not the child of the
if/for/while, but the statement after that) has a higher indent than the
if/for/while. So it'd warn on this:
if (1)
do_stuff();
do_stuff(); // Has higher indent than the if
This works better than I thought it would – I tried it on chromium, and
while it fires quite a bit, when it fires it's justified most of the time.
It's probably too loud to be enabled by default, but it should do well in
nicely-formatted codebases such as llvm, webkit, chromium's non-third-party
code, etc.
I'm away for the next week, but maybe someone wants to pick it up. The
patch and many code snippets that are tricky are in
http://llvm.org/bugs/show_bug.cgi?id=18938 .
(I also tried a different approach that didn't work as well, see bug.)
Nico
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140223/e165ae57/attachment.html>
More information about the cfe-dev
mailing list