[cfe-dev] Clang Static Analyzer (different.ConversionToBool check)

Alexey Knyshev via cfe-dev cfe-dev at lists.llvm.org
Wed Nov 29 01:20:40 PST 2017


Hello everyone!

I have implemented a prototype of "different.ConversionToBool (C, C++)".
According to list of potential checkers (https://clang-analyzer.llvm.
org/potential_checkers.html) I've implemented it as the part of
existing alpha.core.BoolAssignment
checker. There is one problem I've faced while testing changes via
llvm-lit. There are many FnChecks calls like *clang_analyzer_eval* in
Analysis/casts.[c/m] which are called with integer arguments instead of
bool according declaration. Obviously it leads to false positives in
implemented checker (implicit cast to boolean). Actually, the question is:
What is the best way to avoid such false-positives? I came up with the
following possible solutions:

1. Is there way to distinguish FnCheck CallExpr from common CallExpr (any
flag or whatever). If so, it's quite simple to ignore them in the checker.
2. Is there way to determine if checker is running in testing env? And
afterwards filter any calls to FnChecks like* clang_analyzer_eval *by name.
As it was implemented in *CStringChecker:evalCall*.
3. Add special FnCheck like *clang_analyser_eval_implicit_cast(bool)* which
is supposed to replace *clang_analyzer_eval *in cast tests.

Any suggestions?

Thanks, Alexey K

-- 
linkedin.com/profile
<https://www.linkedin.com/profile/view?id=AAMAABn6oKQBDhBteiQnWsYm-S9yxT7wQkfWhSw>

github.com/alexeyknyshev
bitbucket.org/alexeyknyshev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20171129/927d2aff/attachment-0001.html>


More information about the cfe-dev mailing list