[cfe-dev] Help reg. clang

Nemanja Ivanovic via cfe-dev cfe-dev at lists.llvm.org
Fri Apr 1 06:37:43 PDT 2016


As with most warnings, there are respective -W options to enable them. For
example, -Wempty-body. That should be on by default though. Keep in mind
that there are conditions under which you get no warnings (you can see it
in the code). For example, you WILL NOT get the empty body warning for a
loop with an empty body if the semicolon follows the loop header and the
next statement is NOT indented.

And of course, you can look at the clang-tidy checks as Kim mentioned.

On Fri, Apr 1, 2016 at 2:50 PM, Kim Gräsman <kim.grasman at gmail.com> wrote:

> There's also a pretty ambitious clang-tidy check for exactly this:
>
> http://clang.llvm.org/extra/clang-tidy/checks/misc-suspicious-semicolon.html
>
> It was added quite recently:
> http://reviews.llvm.org/D16535
>
> - Kim
>
> On Fri, Apr 1, 2016 at 2:18 PM, Nemanja Ivanovic via cfe-dev
> <cfe-dev at lists.llvm.org> wrote:
> > There is already some handling for this type of thing. Perhaps this does
> not
> > suffice for your purposes but it is likely worth a look.
> > See warnings in Sema::ActOnIfStmt (that calls
> Sema::DiagnoseEmptyStmtBody)
> > and Sema::DiagnoseEmptyLoopBody (in lib/Sema/SemaChecking.cpp and
> > lib/Sema/SemaStmt.cpp respectively).
> >
> > Nemanja
> >
> > On Fri, Apr 1, 2016 at 12:43 PM, Swaresh Sankpal via cfe-dev
> > <cfe-dev at lists.llvm.org> wrote:
> >>
> >> Hi,
> >>
> >> I am trying to produce warnings when semicolon is found after
> if,for,while
> >> loops.How to achieve this solution using ast matcher?.Basically, have to
> >> match null statement inside a loop(for,if,while).Any help is
> appreciated.
> >>
> >> Swaresh
> >> IIT Bombay,India
> >>
> >> _______________________________________________
> >> cfe-dev mailing list
> >> cfe-dev at lists.llvm.org
> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
> >>
> >
> >
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160401/747c5e74/attachment.html>


More information about the cfe-dev mailing list