You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Any C++11 compiler should work. For compilers with partial C++11 support it may work. If your compiler has the C++11 features that are available in Visual Studio 2015 then it will work. If nullptr is not supported by your compiler then this can be emulated using the header lib/cxx11emu.h.
There are multiple compilation choices:
Windows: Visual Studio (Visual Studio 2015 and above)
Linux: g++ 4.6 (or later)
Mac: clang++
Visual Studio
Use the tsancode.sln file. The file is configured for Visual Studio 2015, but the platform toolset can be changed easily to older or newer versions. The solution contains platform targets for both x86 and x64.
Select option Release to build release version.
g++ or clang++
Simple build (no dependencies):
make
Usage at a glance
This simple example contains a potential null pointer defect. Checking if p is null indicates that p might be null, so dereferencing p *p is not safe outside the if-scope.
// func.cppvoidfunc(int* p) {
if(p == NULL) {
printf("p is null!");
}
printf("p is %d", *p);
}
Run TscanCode:
./tscancode --xml func.cpp 2>result.xml
Error list, result.xml:
<?xml version="1.0" encoding="UTF-8"?>
<results>
<errorfile="func.cpp"line="7"id="nullpointer"subid="dereferenceAfterCheck"severity="error"msg="Comparing [p] to null at line 3 implies [p] might be null. Dereferencing null pointer [p]." />
</results>