1 //===--- Checkers.td - Static Analyzer Checkers -===-----------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 include "CheckerBase.td"
12 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
16 // The Alpha package is for checkers that have too many false positives to be
17 // turned on by default. The hierarchy under Alpha should be organized in the
18 // hierarchy checkers would have had if they were truly at the top level.
19 // (For example, a Cocoa-specific checker that is alpha should be in
21 def Alpha : Package<"alpha">;
23 def Core : Package<"core">;
24 def CoreBuiltin : Package<"builtin">, ParentPackage<Core>;
25 def CoreUninitialized : Package<"uninitialized">, ParentPackage<Core>;
26 def CoreAlpha : Package<"core">, ParentPackage<Alpha>;
28 // The OptIn package is for checkers that are not alpha and that would normally
29 // be on by default but where the driver does not have enough information to
30 // determine when they are applicable. For example, localizability checkers fit
31 // this criterion because the driver cannot determine whether a project is
32 // localized or not -- this is best determined at the IDE or build-system level.
34 // The checker hierarchy under OptIn should mirror that in Alpha: checkers
35 // should be organized as if they were at the top level.
37 // Note: OptIn is *not* intended for checkers that are too noisy to be on by
38 // default. Such checkers belong in the alpha package.
39 def OptIn : Package<"optin">;
41 // In the Portability package reside checkers for finding code that relies on
42 // implementation-defined behavior. Such checks are wanted for cross-platform
43 // development, but unwanted for developers who target only a single platform.
44 def PortabilityOptIn : Package<"portability">, ParentPackage<OptIn>;
46 def Nullability : Package<"nullability">;
48 def Cplusplus : Package<"cplusplus">;
49 def CplusplusAlpha : Package<"cplusplus">, ParentPackage<Alpha>;
50 def CplusplusOptIn : Package<"cplusplus">, ParentPackage<OptIn>;
52 def Valist : Package<"valist">;
54 def DeadCode : Package<"deadcode">;
55 def DeadCodeAlpha : Package<"deadcode">, ParentPackage<Alpha>;
57 def Performance : Package<"performance">, ParentPackage<OptIn>;
59 def Security : Package <"security">;
60 def InsecureAPI : Package<"insecureAPI">, ParentPackage<Security>;
61 def SecurityAlpha : Package<"security">, ParentPackage<Alpha>;
62 def Taint : Package<"taint">, ParentPackage<SecurityAlpha>;
64 def Unix : Package<"unix">;
65 def UnixAlpha : Package<"unix">, ParentPackage<Alpha>;
66 def CString : Package<"cstring">, ParentPackage<Unix>;
67 def CStringAlpha : Package<"cstring">, ParentPackage<UnixAlpha>;
69 def OSX : Package<"osx">;
70 def OSXAlpha : Package<"osx">, ParentPackage<Alpha>;
71 def OSXOptIn : Package<"osx">, ParentPackage<OptIn>;
73 def Cocoa : Package<"cocoa">, ParentPackage<OSX>;
74 def CocoaAlpha : Package<"cocoa">, ParentPackage<OSXAlpha>;
75 def CocoaOptIn : Package<"cocoa">, ParentPackage<OSXOptIn>;
77 def CoreFoundation : Package<"coreFoundation">, ParentPackage<OSX>;
78 def Containers : Package<"containers">, ParentPackage<CoreFoundation>;
80 def LocalizabilityAlpha : Package<"localizability">, ParentPackage<CocoaAlpha>;
81 def LocalizabilityOptIn : Package<"localizability">, ParentPackage<CocoaOptIn>;
83 def MPI : Package<"mpi">, ParentPackage<OptIn>;
85 def LLVM : Package<"llvm">;
86 def LLVMAlpha : Package<"llvm">, ParentPackage<Alpha>;
88 // The APIModeling package is for checkers that model APIs and don't perform
89 // any diagnostics. These checkers are always turned on; this package is
90 // intended for API modeling that is not controlled by the target triple.
91 def APIModeling : Package<"apiModeling">;
92 def GoogleAPIModeling : Package<"google">, ParentPackage<APIModeling>;
94 def Debug : Package<"debug">;
96 def CloneDetectionAlpha : Package<"clone">, ParentPackage<Alpha>;
98 //===----------------------------------------------------------------------===//
100 //===----------------------------------------------------------------------===//
102 let ParentPackage = Core in {
104 def DereferenceChecker : Checker<"NullDereference">,
105 HelpText<"Check for dereferences of null pointers">,
106 Documentation<HasDocumentation>;
108 def CallAndMessageChecker : Checker<"CallAndMessage">,
109 HelpText<"Check for logical errors for function calls and Objective-C "
110 "message expressions (e.g., uninitialized arguments, null function "
112 Documentation<HasDocumentation>;
114 def NonNullParamChecker : Checker<"NonNullParamChecker">,
115 HelpText<"Check for null pointers passed as arguments to a function whose "
116 "arguments are references or marked with the 'nonnull' attribute">,
117 Documentation<HasDocumentation>;
119 def VLASizeChecker : Checker<"VLASize">,
120 HelpText<"Check for declarations of VLA of undefined or zero size">,
121 Documentation<HasDocumentation>;
123 def DivZeroChecker : Checker<"DivideZero">,
124 HelpText<"Check for division by zero">,
125 Documentation<HasDocumentation>;
127 def UndefResultChecker : Checker<"UndefinedBinaryOperatorResult">,
128 HelpText<"Check for undefined results of binary operators">,
129 Documentation<HasDocumentation>;
131 def StackAddrEscapeChecker : Checker<"StackAddressEscape">,
132 HelpText<"Check that addresses to stack memory do not escape the function">,
133 Documentation<HasDocumentation>;
135 def DynamicTypePropagation : Checker<"DynamicTypePropagation">,
136 HelpText<"Generate dynamic type information">,
137 Documentation<NotDocumented>;
139 def NonnullGlobalConstantsChecker: Checker<"NonnilStringConstants">,
140 HelpText<"Assume that const string-like globals are non-null">,
141 Documentation<NotDocumented>;
145 let ParentPackage = CoreAlpha in {
147 def BoolAssignmentChecker : Checker<"BoolAssignment">,
148 HelpText<"Warn about assigning non-{0,1} values to Boolean variables">,
149 Documentation<HasAlphaDocumentation>;
151 def CastSizeChecker : Checker<"CastSize">,
152 HelpText<"Check when casting a malloc'ed type T, whether the size is a "
153 "multiple of the size of T">,
154 Documentation<HasAlphaDocumentation>;
156 def CastToStructChecker : Checker<"CastToStruct">,
157 HelpText<"Check for cast from non-struct pointer to struct pointer">,
158 Documentation<HasAlphaDocumentation>;
160 def ConversionChecker : Checker<"Conversion">,
161 HelpText<"Loss of sign/precision in implicit conversions">,
162 Documentation<HasAlphaDocumentation>;
164 def IdenticalExprChecker : Checker<"IdenticalExpr">,
165 HelpText<"Warn about unintended use of identical expressions in operators">,
166 Documentation<HasAlphaDocumentation>;
168 def FixedAddressChecker : Checker<"FixedAddr">,
169 HelpText<"Check for assignment of a fixed address to a pointer">,
170 Documentation<HasAlphaDocumentation>;
172 def PointerArithChecker : Checker<"PointerArithm">,
173 HelpText<"Check for pointer arithmetic on locations other than array "
175 Documentation<HasAlphaDocumentation>;
177 def PointerSubChecker : Checker<"PointerSub">,
178 HelpText<"Check for pointer subtractions on two pointers pointing to "
179 "different memory chunks">,
180 Documentation<HasAlphaDocumentation>;
182 def SizeofPointerChecker : Checker<"SizeofPtr">,
183 HelpText<"Warn about unintended use of sizeof() on pointer expressions">,
184 Documentation<HasAlphaDocumentation>;
186 def CallAndMessageUnInitRefArg : Checker<"CallAndMessageUnInitRefArg">,
187 HelpText<"Check for logical errors for function calls and Objective-C "
188 "message expressions (e.g., uninitialized arguments, null function "
189 "pointers, and pointer to undefined variables)">,
190 Documentation<HasAlphaDocumentation>;
192 def TestAfterDivZeroChecker : Checker<"TestAfterDivZero">,
193 HelpText<"Check for division by variable that is later compared against 0. "
194 "Either the comparison is useless or there is division by zero.">,
195 Documentation<HasAlphaDocumentation>;
197 def DynamicTypeChecker : Checker<"DynamicTypeChecker">,
198 HelpText<"Check for cases where the dynamic and the static type of an object "
200 Documentation<HasAlphaDocumentation>;
202 def StackAddrAsyncEscapeChecker : Checker<"StackAddressAsyncEscape">,
203 HelpText<"Check that addresses to stack memory do not escape the function">,
204 Documentation<HasAlphaDocumentation>;
206 } // end "alpha.core"
208 let ParentPackage = Nullability in {
210 def NullPassedToNonnullChecker : Checker<"NullPassedToNonnull">,
211 HelpText<"Warns when a null pointer is passed to a pointer which has a "
213 Documentation<HasDocumentation>;
215 def NullReturnedFromNonnullChecker : Checker<"NullReturnedFromNonnull">,
216 HelpText<"Warns when a null pointer is returned from a function that has "
217 "_Nonnull return type.">,
218 Documentation<HasDocumentation>;
220 def NullableDereferencedChecker : Checker<"NullableDereferenced">,
221 HelpText<"Warns when a nullable pointer is dereferenced.">,
222 Documentation<HasDocumentation>;
224 def NullablePassedToNonnullChecker : Checker<"NullablePassedToNonnull">,
225 HelpText<"Warns when a nullable pointer is passed to a pointer which has a "
227 Documentation<HasDocumentation>;
229 def NullableReturnedFromNonnullChecker : Checker<"NullableReturnedFromNonnull">,
230 HelpText<"Warns when a nullable pointer is returned from a function that has "
231 "_Nonnull return type.">,
232 Documentation<NotDocumented>;
234 } // end "nullability"
236 let ParentPackage = APIModeling in {
238 def StdCLibraryFunctionsChecker : Checker<"StdCLibraryFunctions">,
239 HelpText<"Improve modeling of the C standard library functions">,
240 Documentation<NotDocumented>;
242 def TrustNonnullChecker : Checker<"TrustNonnull">,
243 HelpText<"Trust that returns from framework methods annotated with _Nonnull "
245 Documentation<NotDocumented>;
247 } // end "apiModeling"
249 //===----------------------------------------------------------------------===//
250 // Evaluate "builtin" functions.
251 //===----------------------------------------------------------------------===//
253 let ParentPackage = CoreBuiltin in {
255 def NoReturnFunctionChecker : Checker<"NoReturnFunctions">,
256 HelpText<"Evaluate \"panic\" functions that are known to not return to the "
258 Documentation<NotDocumented>;
260 def BuiltinFunctionChecker : Checker<"BuiltinFunctions">,
261 HelpText<"Evaluate compiler builtin functions (e.g., alloca())">,
262 Documentation<NotDocumented>;
264 } // end "core.builtin"
266 //===----------------------------------------------------------------------===//
267 // Uninitialized values checkers.
268 //===----------------------------------------------------------------------===//
270 let ParentPackage = CoreUninitialized in {
272 def UndefinedArraySubscriptChecker : Checker<"ArraySubscript">,
273 HelpText<"Check for uninitialized values used as array subscripts">,
274 Documentation<HasDocumentation>;
276 def UndefinedAssignmentChecker : Checker<"Assign">,
277 HelpText<"Check for assigning uninitialized values">,
278 Documentation<HasDocumentation>;
280 def UndefBranchChecker : Checker<"Branch">,
281 HelpText<"Check for uninitialized values used as branch conditions">,
282 Documentation<HasDocumentation>;
284 def UndefCapturedBlockVarChecker : Checker<"CapturedBlockVariable">,
285 HelpText<"Check for blocks that capture uninitialized values">,
286 Documentation<NotDocumented>;
288 def ReturnUndefChecker : Checker<"UndefReturn">,
289 HelpText<"Check for uninitialized values being returned to the caller">,
290 Documentation<HasDocumentation>;
292 } // end "core.uninitialized"
294 //===----------------------------------------------------------------------===//
296 //===----------------------------------------------------------------------===//
298 let ParentPackage = Cplusplus in {
300 def InnerPointerChecker : Checker<"InnerPointer">,
301 HelpText<"Check for inner pointers of C++ containers used after "
303 Documentation<NotDocumented>;
305 def NewDeleteChecker : Checker<"NewDelete">,
306 HelpText<"Check for double-free and use-after-free problems. Traces memory "
307 "managed by new/delete.">,
308 Documentation<HasDocumentation>;
310 def NewDeleteLeaksChecker : Checker<"NewDeleteLeaks">,
311 HelpText<"Check for memory leaks. Traces memory managed by new/delete.">,
312 Documentation<HasDocumentation>;
314 def CXXSelfAssignmentChecker : Checker<"SelfAssignment">,
315 HelpText<"Checks C++ copy and move assignment operators for self assignment">,
316 Documentation<NotDocumented>;
318 def MoveChecker: Checker<"Move">,
319 HelpText<"Find use-after-move bugs in C++">,
320 Documentation<HasDocumentation>;
322 } // end: "cplusplus"
324 let ParentPackage = CplusplusOptIn in {
326 def VirtualCallChecker : Checker<"VirtualCall">,
327 HelpText<"Check virtual function calls during construction or destruction">,
328 Documentation<HasDocumentation>;
330 } // end: "optin.cplusplus"
332 let ParentPackage = CplusplusAlpha in {
334 def DeleteWithNonVirtualDtorChecker : Checker<"DeleteWithNonVirtualDtor">,
335 HelpText<"Reports destructions of polymorphic objects with a non-virtual "
336 "destructor in their base class">,
337 Documentation<HasAlphaDocumentation>;
339 def EnumCastOutOfRangeChecker : Checker<"EnumCastOutOfRange">,
340 HelpText<"Check integer to enumeration casts for out of range values">,
341 Documentation<HasAlphaDocumentation>;
343 def InvalidatedIteratorChecker : Checker<"InvalidatedIterator">,
344 HelpText<"Check for use of invalidated iterators">,
345 Documentation<HasAlphaDocumentation>;
347 def IteratorRangeChecker : Checker<"IteratorRange">,
348 HelpText<"Check for iterators used outside their valid ranges">,
349 Documentation<HasAlphaDocumentation>;
351 def MismatchedIteratorChecker : Checker<"MismatchedIterator">,
352 HelpText<"Check for use of iterators of different containers where iterators "
353 "of the same container are expected">,
354 Documentation<HasAlphaDocumentation>;
356 def UninitializedObjectChecker: Checker<"UninitializedObject">,
357 HelpText<"Reports uninitialized fields after object construction">,
358 Documentation<HasAlphaDocumentation>;
360 } // end: "alpha.cplusplus"
363 //===----------------------------------------------------------------------===//
365 //===----------------------------------------------------------------------===//
367 let ParentPackage = Valist in {
369 def UninitializedChecker : Checker<"Uninitialized">,
370 HelpText<"Check for usages of uninitialized (or already released) va_lists.">,
371 Documentation<NotDocumented>;
373 def UnterminatedChecker : Checker<"Unterminated">,
374 HelpText<"Check for va_lists which are not released by a va_end call.">,
375 Documentation<NotDocumented>;
377 def CopyToSelfChecker : Checker<"CopyToSelf">,
378 HelpText<"Check for va_lists which are copied onto itself.">,
379 Documentation<NotDocumented>;
383 //===----------------------------------------------------------------------===//
384 // Deadcode checkers.
385 //===----------------------------------------------------------------------===//
387 let ParentPackage = DeadCode in {
389 def DeadStoresChecker : Checker<"DeadStores">,
390 HelpText<"Check for values stored to variables that are never read "
392 Documentation<HasDocumentation>;
396 let ParentPackage = DeadCodeAlpha in {
398 def UnreachableCodeChecker : Checker<"UnreachableCode">,
399 HelpText<"Check unreachable code">,
400 Documentation<HasAlphaDocumentation>;
402 } // end "alpha.deadcode"
404 //===----------------------------------------------------------------------===//
405 // Performance checkers.
406 //===----------------------------------------------------------------------===//
408 let ParentPackage = Performance in {
410 def PaddingChecker : Checker<"Padding">,
411 HelpText<"Check for excessively padded structs.">,
412 Documentation<NotDocumented>;
416 //===----------------------------------------------------------------------===//
417 // Security checkers.
418 //===----------------------------------------------------------------------===//
420 let ParentPackage = InsecureAPI in {
422 def bcmp : Checker<"bcmp">,
423 HelpText<"Warn on uses of the 'bcmp' function">,
424 Documentation<HasDocumentation>;
425 def bcopy : Checker<"bcopy">,
426 HelpText<"Warn on uses of the 'bcopy' function">,
427 Documentation<HasDocumentation>;
428 def bzero : Checker<"bzero">,
429 HelpText<"Warn on uses of the 'bzero' function">,
430 Documentation<HasDocumentation>;
431 def gets : Checker<"gets">,
432 HelpText<"Warn on uses of the 'gets' function">,
433 Documentation<HasDocumentation>;
434 def getpw : Checker<"getpw">,
435 HelpText<"Warn on uses of the 'getpw' function">,
436 Documentation<HasDocumentation>;
437 def mktemp : Checker<"mktemp">,
438 HelpText<"Warn on uses of the 'mktemp' function">,
439 Documentation<HasDocumentation>;
440 def mkstemp : Checker<"mkstemp">,
441 HelpText<"Warn when 'mkstemp' is passed fewer than 6 X's in the format "
443 Documentation<HasDocumentation>;
444 def rand : Checker<"rand">,
445 HelpText<"Warn on uses of the 'rand', 'random', and related functions">,
446 Documentation<HasDocumentation>;
447 def strcpy : Checker<"strcpy">,
448 HelpText<"Warn on uses of the 'strcpy' and 'strcat' functions">,
449 Documentation<HasDocumentation>;
450 def vfork : Checker<"vfork">,
451 HelpText<"Warn on uses of the 'vfork' function">,
452 Documentation<HasDocumentation>;
453 def UncheckedReturn : Checker<"UncheckedReturn">,
454 HelpText<"Warn on uses of functions whose return values must be always "
456 Documentation<HasDocumentation>;
458 } // end "security.insecureAPI"
460 let ParentPackage = Security in {
462 def FloatLoopCounter : Checker<"FloatLoopCounter">,
463 HelpText<"Warn on using a floating point value as a loop counter (CERT: "
464 "FLP30-C, FLP30-CPP)">,
465 Documentation<HasDocumentation>;
469 let ParentPackage = SecurityAlpha in {
471 def ArrayBoundChecker : Checker<"ArrayBound">,
472 HelpText<"Warn about buffer overflows (older checker)">,
473 Documentation<HasAlphaDocumentation>;
475 def ArrayBoundCheckerV2 : Checker<"ArrayBoundV2">,
476 HelpText<"Warn about buffer overflows (newer checker)">,
477 Documentation<HasAlphaDocumentation>;
479 def ReturnPointerRangeChecker : Checker<"ReturnPtrRange">,
480 HelpText<"Check for an out-of-bound pointer being returned to callers">,
481 Documentation<HasAlphaDocumentation>;
483 def MallocOverflowSecurityChecker : Checker<"MallocOverflow">,
484 HelpText<"Check for overflows in the arguments to malloc()">,
485 Documentation<HasAlphaDocumentation>;
487 // Operating systems specific PROT_READ/PROT_WRITE values is not implemented,
488 // the defaults are correct for several common operating systems though,
489 // but may need to be overridden via the related analyzer-config flags.
490 def MmapWriteExecChecker : Checker<"MmapWriteExec">,
491 HelpText<"Warn on mmap() calls that are both writable and executable">,
492 Documentation<HasAlphaDocumentation>;
494 } // end "alpha.security"
496 //===----------------------------------------------------------------------===//
498 //===----------------------------------------------------------------------===//
500 let ParentPackage = Taint in {
502 def GenericTaintChecker : Checker<"TaintPropagation">,
503 HelpText<"Generate taint information used by other checkers">,
504 Documentation<HasAlphaDocumentation>;
506 } // end "alpha.security.taint"
508 //===----------------------------------------------------------------------===//
509 // Unix API checkers.
510 //===----------------------------------------------------------------------===//
512 let ParentPackage = Unix in {
514 def UnixAPIMisuseChecker : Checker<"API">,
515 HelpText<"Check calls to various UNIX/Posix functions">,
516 Documentation<HasDocumentation>;
518 def MallocChecker: Checker<"Malloc">,
519 HelpText<"Check for memory leaks, double free, and use-after-free problems. "
520 "Traces memory managed by malloc()/free().">,
521 Documentation<HasDocumentation>;
523 def MallocSizeofChecker : Checker<"MallocSizeof">,
524 HelpText<"Check for dubious malloc arguments involving sizeof">,
525 Documentation<HasDocumentation>;
527 def MismatchedDeallocatorChecker : Checker<"MismatchedDeallocator">,
528 HelpText<"Check for mismatched deallocators.">,
529 Documentation<HasDocumentation>;
531 def VforkChecker : Checker<"Vfork">,
532 HelpText<"Check for proper usage of vfork">,
533 Documentation<HasDocumentation>;
537 let ParentPackage = UnixAlpha in {
539 def ChrootChecker : Checker<"Chroot">,
540 HelpText<"Check improper use of chroot">,
541 Documentation<HasAlphaDocumentation>;
543 def PthreadLockChecker : Checker<"PthreadLock">,
544 HelpText<"Simple lock -> unlock checker">,
545 Documentation<HasAlphaDocumentation>;
547 def StreamChecker : Checker<"Stream">,
548 HelpText<"Check stream handling functions">,
549 Documentation<HasAlphaDocumentation>;
551 def SimpleStreamChecker : Checker<"SimpleStream">,
552 HelpText<"Check for misuses of stream APIs">,
553 Documentation<HasAlphaDocumentation>;
555 def BlockInCriticalSectionChecker : Checker<"BlockInCriticalSection">,
556 HelpText<"Check for calls to blocking functions inside a critical section">,
557 Documentation<HasAlphaDocumentation>;
559 } // end "alpha.unix"
561 let ParentPackage = CString in {
563 def CStringNullArg : Checker<"NullArg">,
564 HelpText<"Check for null pointers being passed as arguments to C string "
566 Documentation<HasDocumentation>;
568 def CStringSyntaxChecker : Checker<"BadSizeArg">,
569 HelpText<"Check the size argument passed into C string functions for common "
570 "erroneous patterns">,
571 Documentation<HasDocumentation>;
573 } // end "unix.cstring"
575 let ParentPackage = CStringAlpha in {
577 def CStringOutOfBounds : Checker<"OutOfBounds">,
578 HelpText<"Check for out-of-bounds access in string functions">,
579 Documentation<HasAlphaDocumentation>;
581 def CStringBufferOverlap : Checker<"BufferOverlap">,
582 HelpText<"Checks for overlap in two buffer arguments">,
583 Documentation<HasAlphaDocumentation>;
585 def CStringNotNullTerm : Checker<"NotNullTerminated">,
586 HelpText<"Check for arguments which are not null-terminating strings">,
587 Documentation<HasAlphaDocumentation>;
589 } // end "alpha.unix.cstring"
591 //===----------------------------------------------------------------------===//
592 // Mac OS X, Cocoa, and Core Foundation checkers.
593 //===----------------------------------------------------------------------===//
595 let ParentPackage = OSX in {
597 def NumberObjectConversionChecker : Checker<"NumberObjectConversion">,
598 HelpText<"Check for erroneous conversions of objects representing numbers "
600 Documentation<NotDocumented>;
602 def MacOSXAPIChecker : Checker<"API">,
603 HelpText<"Check for proper uses of various Apple APIs">,
604 Documentation<HasDocumentation>;
606 def MacOSKeychainAPIChecker : Checker<"SecKeychainAPI">,
607 HelpText<"Check for proper uses of Secure Keychain APIs">,
608 Documentation<HasDocumentation>;
610 def ObjCPropertyChecker : Checker<"ObjCProperty">,
611 HelpText<"Check for proper uses of Objective-C properties">,
612 Documentation<NotDocumented>;
614 def OSObjectRetainCountChecker : Checker<"OSObjectRetainCount">,
615 HelpText<"Check for leaks and improper reference count management for OSObject">,
616 Documentation<NotDocumented>;
620 let ParentPackage = Cocoa in {
622 def RunLoopAutoreleaseLeakChecker : Checker<"RunLoopAutoreleaseLeak">,
623 HelpText<"Check for leaked memory in autorelease pools that will never be "
625 Documentation<NotDocumented>;
627 def ObjCAtSyncChecker : Checker<"AtSync">,
628 HelpText<"Check for nil pointers used as mutexes for @synchronized">,
629 Documentation<HasDocumentation>;
631 def NilArgChecker : Checker<"NilArg">,
632 HelpText<"Check for prohibited nil arguments to ObjC method calls">,
633 Documentation<HasDocumentation>;
635 def ClassReleaseChecker : Checker<"ClassRelease">,
636 HelpText<"Check for sending 'retain', 'release', or 'autorelease' directly "
638 Documentation<HasDocumentation>;
640 def VariadicMethodTypeChecker : Checker<"VariadicMethodTypes">,
641 HelpText<"Check for passing non-Objective-C types to variadic collection "
642 "initialization methods that expect only Objective-C types">,
643 Documentation<HasDocumentation>;
645 def NSAutoreleasePoolChecker : Checker<"NSAutoreleasePool">,
646 HelpText<"Warn for suboptimal uses of NSAutoreleasePool in Objective-C GC "
648 Documentation<HasDocumentation>;
650 def ObjCMethSigsChecker : Checker<"IncompatibleMethodTypes">,
651 HelpText<"Warn about Objective-C method signatures with type "
652 "incompatibilities">,
653 Documentation<HasDocumentation>;
655 def ObjCUnusedIvarsChecker : Checker<"UnusedIvars">,
656 HelpText<"Warn about private ivars that are never used">,
657 Documentation<HasDocumentation>;
659 def ObjCSelfInitChecker : Checker<"SelfInit">,
660 HelpText<"Check that 'self' is properly initialized inside an initializer "
662 Documentation<HasDocumentation>;
664 def ObjCLoopChecker : Checker<"Loops">,
665 HelpText<"Improved modeling of loops using Cocoa collection types">,
666 Documentation<NotDocumented>;
668 def ObjCNonNilReturnValueChecker : Checker<"NonNilReturnValue">,
669 HelpText<"Model the APIs that are guaranteed to return a non-nil value">,
670 Documentation<NotDocumented>;
672 def ObjCSuperCallChecker : Checker<"MissingSuperCall">,
673 HelpText<"Warn about Objective-C methods that lack a necessary call to "
675 Documentation<NotDocumented>;
677 def NSErrorChecker : Checker<"NSError">,
678 HelpText<"Check usage of NSError** parameters">,
679 Documentation<HasDocumentation>;
681 def RetainCountChecker : Checker<"RetainCount">,
682 HelpText<"Check for leaks and improper reference count management">,
683 Documentation<HasDocumentation>;
685 def ObjCGenericsChecker : Checker<"ObjCGenerics">,
686 HelpText<"Check for type errors when using Objective-C generics">,
687 Documentation<HasDocumentation>;
689 def ObjCDeallocChecker : Checker<"Dealloc">,
690 HelpText<"Warn about Objective-C classes that lack a correct implementation "
692 Documentation<HasDocumentation>;
694 def ObjCSuperDeallocChecker : Checker<"SuperDealloc">,
695 HelpText<"Warn about improper use of '[super dealloc]' in Objective-C">,
696 Documentation<HasDocumentation>;
698 def AutoreleaseWriteChecker : Checker<"AutoreleaseWrite">,
699 HelpText<"Warn about potentially crashing writes to autoreleasing objects "
700 "from different autoreleasing pools in Objective-C">,
701 Documentation<NotDocumented>;
705 let ParentPackage = Performance in {
707 def GCDAntipattern : Checker<"GCDAntipattern">,
708 HelpText<"Check for performance anti-patterns when using Grand Central "
710 Documentation<NotDocumented>;
711 } // end "optin.performance"
713 let ParentPackage = CocoaAlpha in {
715 def InstanceVariableInvalidation : Checker<"InstanceVariableInvalidation">,
716 HelpText<"Check that the invalidatable instance variables are invalidated in "
717 "the methods annotated with objc_instance_variable_invalidator">,
718 Documentation<HasAlphaDocumentation>;
720 def MissingInvalidationMethod : Checker<"MissingInvalidationMethod">,
721 HelpText<"Check that the invalidation methods are present in classes that "
722 "contain invalidatable instance variables">,
723 Documentation<HasAlphaDocumentation>;
725 def DirectIvarAssignment : Checker<"DirectIvarAssignment">,
726 HelpText<"Check for direct assignments to instance variables">,
727 Documentation<HasAlphaDocumentation>;
729 def DirectIvarAssignmentForAnnotatedFunctions :
730 Checker<"DirectIvarAssignmentForAnnotatedFunctions">,
731 HelpText<"Check for direct assignments to instance variables in the methods "
732 "annotated with objc_no_direct_instance_variable_assignment">,
733 Documentation<HasAlphaDocumentation>;
735 } // end "alpha.osx.cocoa"
737 let ParentPackage = CoreFoundation in {
739 def CFNumberChecker : Checker<"CFNumber">,
740 HelpText<"Check for proper uses of CFNumber APIs">,
741 Documentation<HasDocumentation>;
743 def CFRetainReleaseChecker : Checker<"CFRetainRelease">,
744 HelpText<"Check for null arguments to CFRetain/CFRelease/CFMakeCollectable">,
745 Documentation<HasDocumentation>;
747 def CFErrorChecker : Checker<"CFError">,
748 HelpText<"Check usage of CFErrorRef* parameters">,
749 Documentation<HasDocumentation>;
751 } // end "osx.coreFoundation"
753 let ParentPackage = Containers in {
755 def ObjCContainersASTChecker : Checker<"PointerSizedValues">,
756 HelpText<"Warns if 'CFArray', 'CFDictionary', 'CFSet' are created with "
757 "non-pointer-size values">,
758 Documentation<HasDocumentation>;
760 def ObjCContainersChecker : Checker<"OutOfBounds">,
761 HelpText<"Checks for index out-of-bounds when using 'CFArray' API">,
762 Documentation<HasDocumentation>;
764 } // end "osx.coreFoundation.containers"
766 let ParentPackage = LocalizabilityOptIn in {
768 def NonLocalizedStringChecker : Checker<"NonLocalizedStringChecker">,
769 HelpText<"Warns about uses of non-localized NSStrings passed to UI methods "
770 "expecting localized NSStrings">,
771 Documentation<HasDocumentation>;
773 def EmptyLocalizationContextChecker :
774 Checker<"EmptyLocalizationContextChecker">,
775 HelpText<"Check that NSLocalizedString macros include a comment for context">,
776 Documentation<HasDocumentation>;
778 } // end "optin.osx.cocoa.localizability"
780 let ParentPackage = LocalizabilityAlpha in {
782 def PluralMisuseChecker : Checker<"PluralMisuseChecker">,
783 HelpText<"Warns against using one vs. many plural pattern in code when "
784 "generating localized strings.">,
785 Documentation<HasAlphaDocumentation>;
787 } // end "alpha.osx.cocoa.localizability"
789 let ParentPackage = MPI in {
791 def MPIChecker : Checker<"MPI-Checker">,
792 HelpText<"Checks MPI code">,
793 Documentation<HasDocumentation>;
797 //===----------------------------------------------------------------------===//
798 // Checkers for LLVM development.
799 //===----------------------------------------------------------------------===//
801 let ParentPackage = LLVMAlpha in {
803 def LLVMConventionsChecker : Checker<"Conventions">,
804 HelpText<"Check code for LLVM codebase conventions">,
805 Documentation<HasAlphaDocumentation>;
809 //===----------------------------------------------------------------------===//
810 // Checkers modeling Google APIs.
811 //===----------------------------------------------------------------------===//
813 let ParentPackage = GoogleAPIModeling in {
815 def GTestChecker : Checker<"GTest">,
816 HelpText<"Model gtest assertion APIs">,
817 Documentation<NotDocumented>;
819 } // end "apiModeling.google"
821 //===----------------------------------------------------------------------===//
822 // Debugging checkers (for analyzer development).
823 //===----------------------------------------------------------------------===//
825 let ParentPackage = Debug in {
827 def AnalysisOrderChecker : Checker<"AnalysisOrder">,
828 HelpText<"Print callbacks that are called during analysis in order">,
829 Documentation<NotDocumented>;
831 def DominatorsTreeDumper : Checker<"DumpDominators">,
832 HelpText<"Print the dominance tree for a given CFG">,
833 Documentation<NotDocumented>;
835 def LiveVariablesDumper : Checker<"DumpLiveVars">,
836 HelpText<"Print results of live variable analysis">,
837 Documentation<NotDocumented>;
839 def LiveStatementsDumper : Checker<"DumpLiveStmts">,
840 HelpText<"Print results of live statement analysis">,
841 Documentation<NotDocumented>;
843 def CFGViewer : Checker<"ViewCFG">,
844 HelpText<"View Control-Flow Graphs using GraphViz">,
845 Documentation<NotDocumented>;
847 def CFGDumper : Checker<"DumpCFG">,
848 HelpText<"Display Control-Flow Graphs">,
849 Documentation<NotDocumented>;
851 def CallGraphViewer : Checker<"ViewCallGraph">,
852 HelpText<"View Call Graph using GraphViz">,
853 Documentation<NotDocumented>;
855 def CallGraphDumper : Checker<"DumpCallGraph">,
856 HelpText<"Display Call Graph">,
857 Documentation<NotDocumented>;
859 def ConfigDumper : Checker<"ConfigDumper">,
860 HelpText<"Dump config table">,
861 Documentation<NotDocumented>;
863 def TraversalDumper : Checker<"DumpTraversal">,
864 HelpText<"Print branch conditions as they are traversed by the engine">,
865 Documentation<NotDocumented>;
867 def CallDumper : Checker<"DumpCalls">,
868 HelpText<"Print calls as they are traversed by the engine">,
869 Documentation<NotDocumented>;
871 def AnalyzerStatsChecker : Checker<"Stats">,
872 HelpText<"Emit warnings with analyzer statistics">,
873 Documentation<NotDocumented>;
875 def TaintTesterChecker : Checker<"TaintTest">,
876 HelpText<"Mark tainted symbols as such.">,
877 Documentation<NotDocumented>;
879 def ExprInspectionChecker : Checker<"ExprInspection">,
880 HelpText<"Check the analyzer's understanding of expressions">,
881 Documentation<NotDocumented>;
883 def ExplodedGraphViewer : Checker<"ViewExplodedGraph">,
884 HelpText<"View Exploded Graphs using GraphViz">,
885 Documentation<NotDocumented>;
890 //===----------------------------------------------------------------------===//
892 //===----------------------------------------------------------------------===//
894 let ParentPackage = CloneDetectionAlpha in {
896 def CloneChecker : Checker<"CloneChecker">,
897 HelpText<"Reports similar pieces of code.">,
898 Documentation<HasAlphaDocumentation>;
902 //===----------------------------------------------------------------------===//
903 // Portability checkers.
904 //===----------------------------------------------------------------------===//
906 let ParentPackage = PortabilityOptIn in {
908 def UnixAPIPortabilityChecker : Checker<"UnixAPI">,
909 HelpText<"Finds implementation-defined behavior in UNIX/Posix functions">,
910 Documentation<NotDocumented>;
912 } // end optin.portability