Adding a new static analysis checker by default

Hi all,

I just wrote a new static analysis checker and would like to add it as a default checker.
Can anyone please give me a guide how to manage default checkers?
I can only see the list of default checkers using scan-build command.

$ scan-build --help-checkers
core.CallAndMessage
core.DivideZero
core.DynamicTypePropagation
core.NonNullParamChecker
core.NullDereference
core.StackAddressEscape
core.UndefinedBinaryOperatorResult
core.VLASize
core.builtin.BuiltinFunctions
core.builtin.NoReturnFunctions
core.uninitialized.ArraySubscript
core.uninitialized.Assign
core.uninitialized.Branch
core.uninitialized.CapturedBlockVariable
core.uninitialized.UndefReturn
cplusplus.NewDelete
deadcode.DeadStores
security.insecureAPI.UncheckedReturn
security.insecureAPI.getpw
security.insecureAPI.gets
security.insecureAPI.mkstemp
security.insecureAPI.mktemp
security.insecureAPI.vfork
unix.API
unix.Malloc
unix.MallocSizeof
unix.MismatchedDeallocator
unix.cstring.BadSizeArg
unix.cstring.NullArg

Thank you all,

Honggyu

Did you follow the steps described in the developer's manual?

Right, the problem was that I put the checker as an alpha checker.
I have moved to core checker list, then it works fine now.
Thank you very much.

Honggyu

Actually, you can make any checker as a default by enabling it in Tools.cpp (http://clang.llvm.org/doxygen/Tools_8cpp_source.html)

02729 // Add default argument set.
02730 if (!Args.hasArg(options::OPT__analyzer_no_default_checks)) {
02731 CmdArgs.push_back(“-analyzer-checker=core”);
02732
02733 if (!IsWindowsMSVC)
02734 CmdArgs.push_back(“-analyzer-checker=unix”);
02735
02736 if (getToolChain().getTriple().getVendor() == llvm::Triple::Apple)
02737 CmdArgs.push_back(“-analyzer-checker=osx”);
02738
02739 CmdArgs.push_back(“-analyzer-checker=deadcode”);
02740
02741 if (types::isCXX(Inputs[0].getType()))
02742 CmdArgs.push_back(“-analyzer-checker=cplusplus”);
02743
02744 // Enable the following experimental checkers for testing.
02745 CmdArgs.push_back(
02746 “-analyzer-checker=security.insecureAPI.UncheckedReturn”);
02747 CmdArgs.push_back(“-analyzer-checker=security.insecureAPI.getpw”);
02748 CmdArgs.push_back(“-analyzer-checker=security.insecureAPI.gets”);
02749 CmdArgs.push_back(“-analyzer-checker=security.insecureAPI.mktemp”);
02750 CmdArgs.push_back(“-analyzer-checker=security.insecureAPI.mkstemp”);
02751 CmdArgs.push_back(“-analyzer-checker=security.insecureAPI.vfork”);

// Add your checker here to enable it by default.

02752 }

I think the checkers are classified according to their functionality, and not whether they should be default or not.

hth,
-Aditya

Hi Aditya,

Your answer is absolutely right. The checkers are not classified if they
are default checkers or not.
I appreciate your detail answer.

Thanks,

Honggyu