[cfe-dev] [analyzer]How to avoid the clang static analyzer to analyze system include files

Johnson Haul via cfe-dev cfe-dev at lists.llvm.org
Sun Apr 19 00:57:49 PDT 2020


Hi,
I am using clang static analyzer in Microsoft Visual C++ projects, but I found it very time-consuming when analyzing MFC cpp files. I found too many warnings in MFC include files, looks like:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\atlmfc\include\atlsimpstr.h(800,3): warning:
      Returned pointer value points outside the original object (potential buffer overflow)
                return( reinterpret_cast< CStringData* >( m_pszData )-1 );
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\atlmfc\include\atlsimpstr.h(900,3): warning:
      Returned pointer value points outside the original object (potential buffer overflow)
                return( pNewData );
                ^~~~~~~~~~~~~~~~~~
AlexfPerf.cpp(190,8): warning: Casting a non-structure type to a structure type and accessing a field can lead to memory access
      errors or data corruption
        pot = (PPERF_OBJECT_TYPE)((PBYTE)pdb + pdb->HeaderLength);
......

So, I'm thinking if clang is analyzing too much on these system header files. How to have clang avoid to analyze them?

Thanks,

Johnson Haul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200419/bf962701/attachment.html>


More information about the cfe-dev mailing list