2011-02-15 02:13:31 +08:00
|
|
|
//===--- Checkers.td - Static Analyzer Checkers -===-----------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
include "clang/StaticAnalyzer/Checkers/CheckerBase.td"
|
|
|
|
|
2011-02-16 05:25:03 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Packages.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2011-02-15 15:42:33 +08:00
|
|
|
def Core : Package<"core">;
|
2011-02-15 02:13:31 +08:00
|
|
|
def Cocoa : Package<"cocoa">;
|
2011-02-15 15:42:33 +08:00
|
|
|
def Unix : Package<"unix">;
|
|
|
|
def MacOSX : Package<"macosx">;
|
|
|
|
|
2011-02-16 05:25:03 +08:00
|
|
|
def CoreExperimental : Package<"experimental">,
|
|
|
|
InPackage<Core>, Hidden;
|
|
|
|
|
2011-02-18 05:39:33 +08:00
|
|
|
def CocoaExperimental : Package<"experimental">,
|
|
|
|
InPackage<Cocoa>, Hidden;
|
|
|
|
|
2011-02-16 05:25:03 +08:00
|
|
|
def UnixExperimental : Package<"experimental">,
|
|
|
|
InPackage<Unix>, Hidden;
|
|
|
|
|
2011-02-18 05:39:24 +08:00
|
|
|
def LLVM : Package<"llvm">;
|
2011-02-18 05:39:39 +08:00
|
|
|
def Debug : Package<"debug">;
|
2011-02-18 05:39:24 +08:00
|
|
|
|
2011-02-16 05:25:03 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Groups.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
def AllExperimental : CheckerGroup<"all-experimental">,
|
|
|
|
Hidden;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Checkers.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2011-02-15 15:42:33 +08:00
|
|
|
let ParentPackage = Cocoa in {
|
2011-02-15 02:13:31 +08:00
|
|
|
|
2011-02-15 15:42:38 +08:00
|
|
|
def ObjCSelfInitChecker : Checker<"SelfInit">,
|
2011-02-15 02:13:31 +08:00
|
|
|
HelpText<"Check that 'self' is propely initialized inside an initializer method">,
|
|
|
|
DescFile<"ObjCSelfInitChecker.cpp">;
|
2011-02-15 15:42:33 +08:00
|
|
|
|
2011-02-15 15:42:38 +08:00
|
|
|
def ObjCAtSyncChecker : Checker<"AtSync">,
|
2011-02-15 15:42:33 +08:00
|
|
|
HelpText<"Check for null pointers used as mutexes for @synchronized">,
|
|
|
|
DescFile<"ObjCAtSyncChecker.cpp">;
|
|
|
|
|
2011-02-16 09:40:52 +08:00
|
|
|
def NilArgChecker : Checker<"NilArg">,
|
|
|
|
HelpText<"Check for prohibited nil arguments to ObjC method calls">,
|
|
|
|
DescFile<"BasicObjCFoundationChecks.cpp">;
|
|
|
|
|
|
|
|
def ClassReleaseChecker : Checker<"ClassRelease">,
|
|
|
|
HelpText<"Check for sending 'retain', 'release', or 'autorelease' directly to a Class">,
|
|
|
|
DescFile<"BasicObjCFoundationChecks.cpp">;
|
|
|
|
|
2011-02-26 06:19:14 +08:00
|
|
|
def NSAutoreleasePoolChecker : Checker<"NSAutoreleasePool">,
|
|
|
|
HelpText<"Warn for subpar uses of NSAutoreleasePool">,
|
2011-02-16 09:40:52 +08:00
|
|
|
DescFile<"NSAutoreleasePoolChecker.cpp">;
|
|
|
|
|
2011-02-18 05:39:33 +08:00
|
|
|
def ObjCMethSigsChecker : Checker<"MethodSigs">,
|
|
|
|
HelpText<"Warn about Objective-C method signatures with type incompatibilities">,
|
|
|
|
DescFile<"CheckObjCInstMethSignature.cpp">;
|
|
|
|
|
|
|
|
def ObjCUnusedIvarsChecker : Checker<"UnusedIvars">,
|
|
|
|
HelpText<"Warn about private ivars that are never used">,
|
|
|
|
DescFile<"ObjCUnusedIVarsChecker.cpp">;
|
|
|
|
|
2011-02-26 06:00:43 +08:00
|
|
|
} // end "cocoa"
|
2011-02-15 15:42:33 +08:00
|
|
|
|
2011-02-28 09:27:07 +08:00
|
|
|
let ParentPackage = Core in {
|
|
|
|
|
2011-02-28 09:27:54 +08:00
|
|
|
def VLASizeChecker : Checker<"VLASize">,
|
|
|
|
HelpText<"Check for declarations of VLA of undefined or zero size">,
|
|
|
|
DescFile<"VLASizeChecker.cpp">;
|
|
|
|
|
2011-02-28 09:27:50 +08:00
|
|
|
def DivZeroChecker : Checker<"DivZero">,
|
|
|
|
HelpText<"Check for division by zeros">,
|
|
|
|
DescFile<"DivZeroChecker.cpp">;
|
|
|
|
|
2011-02-28 09:27:46 +08:00
|
|
|
def ReturnUndefChecker : Checker<"UndefReturn">,
|
|
|
|
HelpText<"Check for undefined or garbage values being returned to the caller">,
|
|
|
|
DescFile<"ReturnUndefChecker.cpp">;
|
|
|
|
|
2011-02-28 09:27:41 +08:00
|
|
|
def UndefinedArraySubscriptChecker : Checker<"UndefArraySubscript">,
|
|
|
|
HelpText<"Check for undefined array subscripts">,
|
|
|
|
DescFile<"UndefinedArraySubscriptChecker.cpp">;
|
|
|
|
|
2011-02-28 09:27:37 +08:00
|
|
|
def UndefinedAssignmentChecker : Checker<"UndefAssign">,
|
|
|
|
HelpText<"Check for assigning undefined values">,
|
|
|
|
DescFile<"UndefinedAssignmentChecker.cpp">;
|
|
|
|
|
2011-02-28 09:27:33 +08:00
|
|
|
def UndefBranchChecker : Checker<"UndefBranch">,
|
|
|
|
HelpText<"Check for undefined branch conditions">,
|
|
|
|
DescFile<"UndefBranchChecker.cpp">;
|
|
|
|
|
2011-02-28 09:27:26 +08:00
|
|
|
def UndefCapturedBlockVarChecker : Checker<"UndefBlockVar">,
|
|
|
|
HelpText<"Check for blocks that capture uninitialized values">,
|
|
|
|
DescFile<"UndefCapturedBlockVarChecker.cpp">;
|
|
|
|
|
2011-02-28 09:27:22 +08:00
|
|
|
def UndefResultChecker : Checker<"UndefBinOpResult">,
|
|
|
|
HelpText<"Check for undefined results of non-assignment binary operators">,
|
|
|
|
DescFile<"UndefResultChecker.cpp">;
|
|
|
|
|
2011-02-28 09:27:17 +08:00
|
|
|
def NoReturnFunctionChecker : Checker<"NoReturnFunc">,
|
|
|
|
HelpText<"Evaluate functions that do not return to the caller">,
|
|
|
|
DescFile<"NoReturnFunctionChecker.cpp">;
|
|
|
|
|
2011-02-28 09:27:07 +08:00
|
|
|
def BuiltinFunctionChecker : Checker<"BuiltinFunc">,
|
|
|
|
HelpText<"Evaluate clang builtin functions">,
|
|
|
|
DescFile<"BuiltinFunctionChecker.cpp">;
|
|
|
|
|
2011-02-26 06:00:43 +08:00
|
|
|
def StackAddrEscapeChecker : Checker<"StackAddrEscape">,
|
|
|
|
HelpText<"Check that addresses to stack memory do not escape the function">,
|
|
|
|
DescFile<"StackAddrEscapeChecker.cpp">;
|
2011-02-15 15:42:33 +08:00
|
|
|
|
2011-02-28 09:27:12 +08:00
|
|
|
} // end "core"
|
|
|
|
|
2011-02-18 05:39:33 +08:00
|
|
|
def DeadStoresChecker : Checker<"DeadStores">,
|
2011-02-26 06:00:43 +08:00
|
|
|
HelpText<"Check for values stored to a variables that are never read afterwards">,
|
2011-02-18 05:39:33 +08:00
|
|
|
DescFile<"DeadStoresChecker.cpp">;
|
|
|
|
|
2011-02-15 15:42:38 +08:00
|
|
|
def UnixAPIChecker : Checker<"API">,
|
2011-02-15 15:42:33 +08:00
|
|
|
InPackage<Unix>,
|
|
|
|
HelpText<"Check calls to various UNIX/Posix functions">,
|
|
|
|
DescFile<"UnixAPIChecker.cpp">;
|
|
|
|
|
2011-02-15 15:42:38 +08:00
|
|
|
def MacOSXAPIChecker : Checker<"API">,
|
2011-02-15 15:42:33 +08:00
|
|
|
InPackage<MacOSX>,
|
2011-02-26 06:00:43 +08:00
|
|
|
HelpText<"Check for proper uses of various Mac OS X APIs">,
|
2011-02-15 15:42:33 +08:00
|
|
|
DescFile<"MacOSXAPIChecker.cpp">;
|
2011-02-16 05:25:03 +08:00
|
|
|
|
2011-02-28 09:27:02 +08:00
|
|
|
def OSAtomicChecker : Checker<"AtomicCAS">,
|
|
|
|
InPackage<MacOSX>,
|
|
|
|
HelpText<"Evaluate calls to OSAtomic functions">,
|
|
|
|
DescFile<"OSAtomicChecker.cpp">;
|
|
|
|
|
2011-02-16 09:40:52 +08:00
|
|
|
def CFNumberCreateChecker : Checker<"CFNumber">,
|
|
|
|
InPackage<MacOSX>,
|
2011-02-26 06:00:43 +08:00
|
|
|
HelpText<"Check for proper uses of CFNumberCreate">,
|
2011-02-16 09:40:52 +08:00
|
|
|
DescFile<"BasicObjCFoundationChecks.cpp">;
|
|
|
|
|
|
|
|
def CFRetainReleaseChecker : Checker<"CFRetainRelease">,
|
|
|
|
InPackage<MacOSX>,
|
|
|
|
HelpText<"Check for null arguments to CFRetain/CFRelease">,
|
|
|
|
DescFile<"BasicObjCFoundationChecks.cpp">;
|
|
|
|
|
2011-02-18 05:39:24 +08:00
|
|
|
def LLVMConventionsChecker : Checker<"Conventions">,
|
|
|
|
InPackage<LLVM>,
|
|
|
|
HelpText<"Check code for LLVM codebase conventions">,
|
|
|
|
DescFile<"LLVMConventionsChecker.cpp">;
|
|
|
|
|
2011-02-18 05:39:39 +08:00
|
|
|
def LiveVariablesDumper : Checker<"DumpLiveVars">,
|
|
|
|
InPackage<Debug>,
|
|
|
|
HelpText<"Print results of live variable analysis">,
|
|
|
|
DescFile<"DebugCheckers.cpp">;
|
|
|
|
|
|
|
|
def CFGViewer : Checker<"ViewCFG">,
|
|
|
|
InPackage<Debug>,
|
|
|
|
HelpText<"View Control-Flow Graphs using GraphViz">,
|
|
|
|
DescFile<"DebugCheckers.cpp">;
|
|
|
|
|
|
|
|
def CFGDumper : Checker<"DumpCFG">,
|
|
|
|
InPackage<Debug>,
|
|
|
|
HelpText<"Display Control-Flow Graphs">,
|
|
|
|
DescFile<"DebugCheckers.cpp">;
|
|
|
|
|
2011-02-28 09:26:50 +08:00
|
|
|
def AnalyzerStatsChecker : Checker<"Stats">,
|
|
|
|
InPackage<Debug>,
|
|
|
|
HelpText<"Emit warnings with analyzer statistics">,
|
|
|
|
DescFile<"AnalyzerStatsChecker.cpp">;
|
|
|
|
|
2011-02-16 05:25:03 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Hidden experimental checkers.
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
let Group = AllExperimental in {
|
|
|
|
|
2011-02-28 09:26:57 +08:00
|
|
|
def ArrayBoundCheckerV2 : Checker<"Overflow">,
|
|
|
|
InPackage<CoreExperimental>,
|
|
|
|
HelpText<"Warn about buffer overflows">,
|
|
|
|
DescFile<"ArrayBoundCheckerV2.cpp">,
|
|
|
|
Hidden; // Must be specified explicitly in order to run.
|
|
|
|
|
2011-02-28 09:26:35 +08:00
|
|
|
def MallocChecker : Checker<"Malloc">,
|
|
|
|
InPackage<CoreExperimental>,
|
|
|
|
HelpText<"Check for potential memory leaks, double free, and use-after-free problems">,
|
|
|
|
DescFile<"MallocChecker.cpp">;
|
|
|
|
|
2011-02-16 05:25:03 +08:00
|
|
|
def CStringChecker : Checker<"CString">,
|
|
|
|
InPackage<CoreExperimental>,
|
|
|
|
HelpText<"Check calls to functions in <string.h>">,
|
|
|
|
DescFile<"CStringChecker.cpp">;
|
|
|
|
|
|
|
|
def UnreachableCodeChecker : Checker<"UnreachableCode">,
|
|
|
|
InPackage<CoreExperimental>,
|
|
|
|
HelpText<"Check unreachable code">,
|
2011-02-25 05:42:52 +08:00
|
|
|
DescFile<"UnreachableCodeChecker.cpp">,
|
|
|
|
Hidden; // Must be specified explicitly in order to run.
|
2011-02-16 05:25:03 +08:00
|
|
|
|
2011-02-16 06:55:14 +08:00
|
|
|
def IdempotentOperationChecker : Checker<"IdempotentOps">,
|
|
|
|
InPackage<CoreExperimental>,
|
|
|
|
HelpText<"Warn about idempotent operations">,
|
|
|
|
DescFile<"IdempotentOperationChecker.cpp">;
|
|
|
|
|
2011-02-16 06:55:20 +08:00
|
|
|
def CastToStructChecker : Checker<"CastToStruct">,
|
|
|
|
InPackage<CoreExperimental>,
|
|
|
|
HelpText<"Check for cast from non-struct pointer to struct pointer">,
|
|
|
|
DescFile<"CastToStructChecker.cpp">;
|
|
|
|
|
|
|
|
def FixedAddressChecker : Checker<"FixedAddr">,
|
|
|
|
InPackage<CoreExperimental>,
|
|
|
|
HelpText<"Check for assignment of a fixed address to a pointer">,
|
|
|
|
DescFile<"FixedAddressChecker.cpp">;
|
|
|
|
|
|
|
|
def PointerArithChecker : Checker<"PointerArithm">,
|
|
|
|
InPackage<CoreExperimental>,
|
|
|
|
HelpText<"Check for pointer arithmetic on locations other than array elements">,
|
|
|
|
DescFile<"PointerArithChecker">;
|
|
|
|
|
|
|
|
def PointerSubChecker : Checker<"PointerSub">,
|
|
|
|
InPackage<CoreExperimental>,
|
|
|
|
HelpText<"Check for pointer subtractions on two pointers pointing to different memory chunks">,
|
|
|
|
DescFile<"PointerSubChecker">;
|
|
|
|
|
2011-02-18 05:39:33 +08:00
|
|
|
def SizeofPointerChecker : Checker<"SizeofPtr">,
|
|
|
|
InPackage<CoreExperimental>,
|
|
|
|
HelpText<"Warn about unintended use of sizeof() on pointer expressions">,
|
|
|
|
DescFile<"CheckSizeofPointer.cpp">;
|
|
|
|
|
|
|
|
def SecuritySyntaxChecker : Checker<"SecuritySyntactic">,
|
|
|
|
InPackage<CoreExperimental>,
|
|
|
|
HelpText<"Perform quick security checks that require no data flow">,
|
|
|
|
DescFile<"CheckSecuritySyntaxOnly.cpp">;
|
|
|
|
|
2011-02-24 16:41:57 +08:00
|
|
|
def ReturnPointerRangeChecker : Checker<"ReturnPtrRange">,
|
|
|
|
InPackage<CoreExperimental>,
|
|
|
|
HelpText<"Check for an out-of-bound pointer being returned to callers">,
|
|
|
|
DescFile<"ReturnPointerRangeChecker.cpp">;
|
|
|
|
|
2011-02-24 16:42:12 +08:00
|
|
|
def ArrayBoundChecker : Checker<"ArrayBound">,
|
|
|
|
InPackage<CoreExperimental>,
|
|
|
|
HelpText<"Check for an out-of-bound pointer being returned to callers">,
|
|
|
|
DescFile<"ArrayBoundChecker.cpp">;
|
|
|
|
|
2011-02-25 05:42:49 +08:00
|
|
|
def CastSizeChecker : Checker<"CastSize">,
|
|
|
|
InPackage<CoreExperimental>,
|
|
|
|
HelpText<"Check when casting a malloc'ed type T, whether the size is a multiple of the size of T">,
|
|
|
|
DescFile<"CastSizeChecker.cpp">;
|
|
|
|
|
2011-02-18 05:39:33 +08:00
|
|
|
def ObjCDeallocChecker : Checker<"Dealloc">,
|
|
|
|
InPackage<CocoaExperimental>,
|
|
|
|
HelpText<"Warn about Objective-C classes that lack a correct implementation of -dealloc">,
|
|
|
|
DescFile<"CheckObjCDealloc.cpp">;
|
|
|
|
|
2011-02-16 05:25:03 +08:00
|
|
|
def ChrootChecker : Checker<"Chroot">,
|
|
|
|
InPackage<UnixExperimental>,
|
|
|
|
HelpText<"Check improper use of chroot">,
|
|
|
|
DescFile<"ChrootChecker.cpp">;
|
|
|
|
|
|
|
|
def PthreadLockChecker : Checker<"PthreadLock">,
|
|
|
|
InPackage<UnixExperimental>,
|
|
|
|
HelpText<"Simple lock -> unlock checker">,
|
|
|
|
DescFile<"PthreadLockChecker.cpp">;
|
|
|
|
|
|
|
|
def StreamChecker : Checker<"Stream">,
|
|
|
|
InPackage<UnixExperimental>,
|
|
|
|
HelpText<"Check stream handling functions">,
|
|
|
|
DescFile<"StreamChecker.cpp">;
|
|
|
|
|
|
|
|
}
|