[cfe-dev] a patch for static analyzer to check : std::list::empty()

彩云追月 wuming_81 at 163.com
Sun Feb 1 14:35:44 PST 2015


Hello, 
    recently, as an exercise, I have implemented a checker for clang static analyzer.It checks the call of std::list::size( ) .


    It is more efficient to use containers empty() method to identify an empty container.Codes like bellow :


    int f() {
        list<int> l;
        if (l.empty() == 0) {
        }
     }    
    will be warned.


 btw, I  did my dev on the release 3.5. 


  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150202/b9f9097e/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: EmptyContainerChecker.cpp
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150202/b9f9097e/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: empty_container_test.cpp
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150202/b9f9097e/attachment-0001.ksh>


More information about the cfe-dev mailing list