[cfe-dev] a patch for clang static checker: optimization.StrLengthCalculation

Richard legalize at xmission.com
Mon Feb 2 13:30:32 PST 2015


In article <7bd94015.2f8.14b4bb8bc12.Coremail.wuming_81 at 163.com>,
    <wuming_81 at 163.com> writes:

>     I implemented another checker for clang static checker. 
>     It checks that some code uses strlen(or wcslen)  to calculate the
> length of an std::string( or std::wstring).
>     
>    example: 
> 
> 
> #include <string>
> #include <string.h>
> 
> void test() {
>   std::string s;
>   if (strlen(s.c_str()) != 0) {}; // warn 
> }   

Great!  Are you implementing these only as warnings for the static
analyzer or are you also implementing a check for clang-tidy since the
fix is easy to apply?
-- 
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
     The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
         The Terminals Wiki <http://terminals.classiccmp.org>
  Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>



More information about the cfe-dev mailing list