Clang Project

clang_source_code/include/clang/StaticAnalyzer/Checkers/Checkers.td
1//===--- Checkers.td - Static Analyzer Checkers -===-----------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9include "CheckerBase.td"
10
11//===----------------------------------------------------------------------===//
12// Packages.
13//===----------------------------------------------------------------------===//
14
15// The Alpha package is for checkers that have too many false positives to be
16// turned on by default. The hierarchy under Alpha should be organized in the
17// hierarchy checkers would have had if they were truly at the top level.
18// (For example, a Cocoa-specific checker that is alpha should be in
19// alpha.osx.cocoa).
20def Alpha : Package<"alpha">;
21
22def Core : Package<"core">;
23def CoreBuiltin : Package<"builtin">, ParentPackage<Core>;
24def CoreUninitialized  : Package<"uninitialized">, ParentPackage<Core>;
25def CoreAlpha : Package<"core">, ParentPackage<Alpha>;
26
27// The OptIn package is for checkers that are not alpha and that would normally
28// be on by default but where the driver does not have enough information to
29// determine when they are applicable. For example, localizability checkers fit
30// this criterion because the driver cannot determine whether a project is
31// localized or not -- this is best determined at the IDE or build-system level.
32//
33// The checker hierarchy under OptIn should mirror that in Alpha: checkers
34// should be organized as if they were at the top level.
35//
36// Note: OptIn is *not* intended for checkers that are too noisy to be on by
37// default. Such checkers belong in the alpha package.
38def OptIn : Package<"optin">;
39
40// In the Portability package reside checkers for finding code that relies on
41// implementation-defined behavior. Such checks are wanted for cross-platform
42// development, but unwanted for developers who target only a single platform.
43def PortabilityOptIn : Package<"portability">, ParentPackage<OptIn>;
44
45def Nullability : Package<"nullability">;
46
47def Cplusplus : Package<"cplusplus">;
48def CplusplusAlpha : Package<"cplusplus">, ParentPackage<Alpha>;
49def CplusplusOptIn : Package<"cplusplus">, ParentPackage<OptIn>;
50
51def Valist : Package<"valist">;
52
53def DeadCode : Package<"deadcode">;
54def DeadCodeAlpha : Package<"deadcode">, ParentPackage<Alpha>;
55
56def Performance : Package<"performance">, ParentPackage<OptIn>;
57
58def Security : Package <"security">;
59def InsecureAPI : Package<"insecureAPI">, ParentPackage<Security>;
60def SecurityAlpha : Package<"security">, ParentPackage<Alpha>;
61def Taint : Package<"taint">, ParentPackage<SecurityAlpha>;
62
63def Unix : Package<"unix">;
64def UnixAlpha : Package<"unix">, ParentPackage<Alpha>;
65def CString : Package<"cstring">, ParentPackage<Unix>;
66def CStringAlpha : Package<"cstring">, ParentPackage<UnixAlpha>;
67
68def OSX : Package<"osx">;
69def OSXAlpha : Package<"osx">, ParentPackage<Alpha>;
70def OSXOptIn : Package<"osx">, ParentPackage<OptIn>;
71
72def Cocoa : Package<"cocoa">, ParentPackage<OSX>;
73def CocoaAlpha : Package<"cocoa">, ParentPackage<OSXAlpha>;
74def CocoaOptIn : Package<"cocoa">, ParentPackage<OSXOptIn>;
75
76def CoreFoundation : Package<"coreFoundation">, ParentPackage<OSX>;
77def Containers : Package<"containers">, ParentPackage<CoreFoundation>;
78
79def LocalizabilityAlpha : Package<"localizability">, ParentPackage<CocoaAlpha>;
80def LocalizabilityOptIn : Package<"localizability">, ParentPackage<CocoaOptIn>;
81
82def MPI : Package<"mpi">, ParentPackage<OptIn>;
83
84def LLVM : Package<"llvm">;
85def LLVMAlpha : Package<"llvm">, ParentPackage<Alpha>;
86
87// The APIModeling package is for checkers that model APIs and don't perform
88// any diagnostics. These checkers are always turned on; this package is
89// intended for API modeling that is not controlled by the target triple.
90def APIModeling : Package<"apiModeling">;
91def GoogleAPIModeling : Package<"google">, ParentPackage<APIModeling>;
92
93def Debug : Package<"debug">;
94
95def CloneDetectionAlpha : Package<"clone">, ParentPackage<Alpha>;
96
97def NonDeterminismAlpha : Package<"nondeterminism">, ParentPackage<Alpha>;
98
99//===----------------------------------------------------------------------===//
100// Core Checkers.
101//===----------------------------------------------------------------------===//
102
103let ParentPackage = Core in {
104
105def DereferenceChecker : Checker<"NullDereference">,
106  HelpText<"Check for dereferences of null pointers">,
107  Documentation<HasDocumentation>;
108
109def CallAndMessageChecker : Checker<"CallAndMessage">,
110  HelpText<"Check for logical errors for function calls and Objective-C "
111           "message expressions (e.g., uninitialized arguments, null function "
112           "pointers)">,
113  Documentation<HasDocumentation>;
114
115def NonNullParamChecker : Checker<"NonNullParamChecker">,
116  HelpText<"Check for null pointers passed as arguments to a function whose "
117           "arguments are references or marked with the 'nonnull' attribute">,
118  Documentation<HasDocumentation>;
119
120def VLASizeChecker : Checker<"VLASize">,
121  HelpText<"Check for declarations of VLA of undefined or zero size">,
122  Documentation<HasDocumentation>;
123
124def DivZeroChecker : Checker<"DivideZero">,
125  HelpText<"Check for division by zero">,
126  Documentation<HasDocumentation>;
127
128def UndefResultChecker : Checker<"UndefinedBinaryOperatorResult">,
129  HelpText<"Check for undefined results of binary operators">,
130  Documentation<HasDocumentation>;
131
132def StackAddrEscapeBase : Checker<"StackAddrEscapeBase">,
133  HelpText<"Generate information about stack address escapes.">,
134  Documentation<NotDocumented>;
135
136def StackAddrEscapeChecker : Checker<"StackAddressEscape">,
137  HelpText<"Check that addresses to stack memory do not escape the function">,
138  Dependencies<[StackAddrEscapeBase]>,
139  Documentation<HasDocumentation>;
140
141def DynamicTypePropagation : Checker<"DynamicTypePropagation">,
142  HelpText<"Generate dynamic type information">,
143  Documentation<NotDocumented>;
144
145def NonnullGlobalConstantsChecker: Checker<"NonnilStringConstants">,
146  HelpText<"Assume that const string-like globals are non-null">,
147  Documentation<NotDocumented>;
148
149} // end "core"
150
151let ParentPackage = CoreAlpha in {
152
153def BoolAssignmentChecker : Checker<"BoolAssignment">,
154  HelpText<"Warn about assigning non-{0,1} values to Boolean variables">,
155  Documentation<HasAlphaDocumentation>;
156
157def CastSizeChecker : Checker<"CastSize">,
158  HelpText<"Check when casting a malloc'ed type T, whether the size is a "
159           "multiple of the size of T">,
160  Documentation<HasAlphaDocumentation>;
161
162def CastToStructChecker : Checker<"CastToStruct">,
163  HelpText<"Check for cast from non-struct pointer to struct pointer">,
164  Documentation<HasAlphaDocumentation>;
165
166def ConversionChecker : Checker<"Conversion">,
167  HelpText<"Loss of sign/precision in implicit conversions">,
168  Documentation<HasAlphaDocumentation>;
169
170def IdenticalExprChecker : Checker<"IdenticalExpr">,
171  HelpText<"Warn about unintended use of identical expressions in operators">,
172  Documentation<HasAlphaDocumentation>;
173
174def FixedAddressChecker : Checker<"FixedAddr">,
175  HelpText<"Check for assignment of a fixed address to a pointer">,
176  Documentation<HasAlphaDocumentation>;
177
178def PointerArithChecker : Checker<"PointerArithm">,
179  HelpText<"Check for pointer arithmetic on locations other than array "
180           "elements">,
181  Documentation<HasAlphaDocumentation>;
182
183def PointerSubChecker : Checker<"PointerSub">,
184  HelpText<"Check for pointer subtractions on two pointers pointing to "
185           "different memory chunks">,
186  Documentation<HasAlphaDocumentation>;
187
188def SizeofPointerChecker : Checker<"SizeofPtr">,
189  HelpText<"Warn about unintended use of sizeof() on pointer expressions">,
190  Documentation<HasAlphaDocumentation>;
191
192def CallAndMessageUnInitRefArg : Checker<"CallAndMessageUnInitRefArg">,
193  HelpText<"Check for logical errors for function calls and Objective-C "
194           "message expressions (e.g., uninitialized arguments, null function "
195           "pointers, and pointer to undefined variables)">,
196  Dependencies<[CallAndMessageChecker]>,
197  Documentation<HasAlphaDocumentation>;
198
199def TestAfterDivZeroChecker : Checker<"TestAfterDivZero">,
200  HelpText<"Check for division by variable that is later compared against 0. "
201           "Either the comparison is useless or there is division by zero.">,
202  Documentation<HasAlphaDocumentation>;
203
204def DynamicTypeChecker : Checker<"DynamicTypeChecker">,
205  HelpText<"Check for cases where the dynamic and the static type of an object "
206           "are unrelated.">,
207  Documentation<HasAlphaDocumentation>;
208
209def StackAddrAsyncEscapeChecker : Checker<"StackAddressAsyncEscape">,
210  HelpText<"Check that addresses to stack memory do not escape the function">,
211  Dependencies<[StackAddrEscapeBase]>,
212  Documentation<HasAlphaDocumentation>;
213
214} // end "alpha.core"
215
216//===----------------------------------------------------------------------===//
217// Nullability checkers.
218//===----------------------------------------------------------------------===//
219
220let ParentPackage = Nullability in {
221
222def NullabilityBase : Checker<"NullabilityBase">,
223  HelpText<"Stores information during the analysis about nullability.">,
224  Documentation<NotDocumented>;
225
226def NullPassedToNonnullChecker : Checker<"NullPassedToNonnull">,
227  HelpText<"Warns when a null pointer is passed to a pointer which has a "
228           "_Nonnull type.">,
229  Dependencies<[NullabilityBase]>,
230  Documentation<HasDocumentation>;
231
232def NullReturnedFromNonnullChecker : Checker<"NullReturnedFromNonnull">,
233  HelpText<"Warns when a null pointer is returned from a function that has "
234           "_Nonnull return type.">,
235  Dependencies<[NullabilityBase]>,
236  Documentation<HasDocumentation>;
237
238def NullableDereferencedChecker : Checker<"NullableDereferenced">,
239  HelpText<"Warns when a nullable pointer is dereferenced.">,
240  Dependencies<[NullabilityBase]>,
241  Documentation<HasDocumentation>;
242
243def NullablePassedToNonnullChecker : Checker<"NullablePassedToNonnull">,
244  HelpText<"Warns when a nullable pointer is passed to a pointer which has a "
245           "_Nonnull type.">,
246  Dependencies<[NullabilityBase]>,
247  Documentation<HasDocumentation>;
248
249def NullableReturnedFromNonnullChecker : Checker<"NullableReturnedFromNonnull">,
250  HelpText<"Warns when a nullable pointer is returned from a function that has "
251           "_Nonnull return type.">,
252  Dependencies<[NullabilityBase]>,
253  Documentation<NotDocumented>;
254
255} // end "nullability"
256
257//===----------------------------------------------------------------------===//
258// APIModeling.
259//===----------------------------------------------------------------------===//
260
261let ParentPackage = APIModeling in {
262
263def StdCLibraryFunctionsChecker : Checker<"StdCLibraryFunctions">,
264  HelpText<"Improve modeling of the C standard library functions">,
265  Documentation<NotDocumented>;
266
267def TrustNonnullChecker : Checker<"TrustNonnull">,
268  HelpText<"Trust that returns from framework methods annotated with _Nonnull "
269           "are not null">,
270  Documentation<NotDocumented>;
271
272} // end "apiModeling"
273
274//===----------------------------------------------------------------------===//
275// Evaluate "builtin" functions.
276//===----------------------------------------------------------------------===//
277
278let ParentPackage = CoreBuiltin in {
279
280def NoReturnFunctionChecker : Checker<"NoReturnFunctions">,
281  HelpText<"Evaluate \"panic\" functions that are known to not return to the "
282           "caller">,
283  Documentation<NotDocumented>;
284
285def BuiltinFunctionChecker : Checker<"BuiltinFunctions">,
286  HelpText<"Evaluate compiler builtin functions (e.g., alloca())">,
287  Documentation<NotDocumented>;
288
289} // end "core.builtin"
290
291//===----------------------------------------------------------------------===//
292// Uninitialized values checkers.
293//===----------------------------------------------------------------------===//
294
295let ParentPackage = CoreUninitialized in {
296
297def UndefinedArraySubscriptChecker : Checker<"ArraySubscript">,
298  HelpText<"Check for uninitialized values used as array subscripts">,
299  Documentation<HasDocumentation>;
300
301def UndefinedAssignmentChecker : Checker<"Assign">,
302  HelpText<"Check for assigning uninitialized values">,
303  Documentation<HasDocumentation>;
304
305def UndefBranchChecker : Checker<"Branch">,
306  HelpText<"Check for uninitialized values used as branch conditions">,
307  Documentation<HasDocumentation>;
308
309def UndefCapturedBlockVarChecker : Checker<"CapturedBlockVariable">,
310  HelpText<"Check for blocks that capture uninitialized values">,
311  Documentation<NotDocumented>;
312
313def ReturnUndefChecker : Checker<"UndefReturn">,
314  HelpText<"Check for uninitialized values being returned to the caller">,
315  Documentation<HasDocumentation>;
316
317} // end "core.uninitialized"
318
319//===----------------------------------------------------------------------===//
320// Unix API checkers.
321//===----------------------------------------------------------------------===//
322
323let ParentPackage = CString in {
324
325def CStringModeling : Checker<"CStringModeling">,
326  HelpText<"The base of several CString related checkers. On it's own it emits "
327           "no reports, but adds valuable information to the analysis when "
328           "enabled.">,
329  Documentation<NotDocumented>;
330
331def CStringNullArg : Checker<"NullArg">,
332  HelpText<"Check for null pointers being passed as arguments to C string "
333           "functions">,
334  Dependencies<[CStringModeling]>,
335  Documentation<HasDocumentation>;
336
337def CStringSyntaxChecker : Checker<"BadSizeArg">,
338  HelpText<"Check the size argument passed into C string functions for common "
339           "erroneous patterns">,
340  Dependencies<[CStringModeling]>,
341  Documentation<HasDocumentation>;
342
343} // end "unix.cstring"
344
345let ParentPackage = CStringAlpha in {
346
347def CStringOutOfBounds : Checker<"OutOfBounds">,
348  HelpText<"Check for out-of-bounds access in string functions">,
349  Dependencies<[CStringModeling]>,
350  Documentation<HasAlphaDocumentation>;
351
352def CStringBufferOverlap : Checker<"BufferOverlap">,
353  HelpText<"Checks for overlap in two buffer arguments">,
354  Dependencies<[CStringModeling]>,
355  Documentation<HasAlphaDocumentation>;
356
357def CStringNotNullTerm : Checker<"NotNullTerminated">,
358  HelpText<"Check for arguments which are not null-terminating strings">,
359  Dependencies<[CStringModeling]>,
360  Documentation<HasAlphaDocumentation>;
361
362} // end "alpha.unix.cstring"
363
364let ParentPackage = Unix in {
365
366def UnixAPIMisuseChecker : Checker<"API">,
367  HelpText<"Check calls to various UNIX/Posix functions">,
368  Documentation<HasDocumentation>;
369
370def DynamicMemoryModeling: Checker<"DynamicMemoryModeling">,
371  HelpText<"The base of several malloc() related checkers. On it's own it "
372           "emits no reports, but adds valuable information to the analysis "
373           "when enabled.">,
374  Dependencies<[CStringModeling]>,
375  Documentation<NotDocumented>;
376
377def MallocChecker: Checker<"Malloc">,
378  HelpText<"Check for memory leaks, double free, and use-after-free problems. "
379           "Traces memory managed by malloc()/free().">,
380  Dependencies<[DynamicMemoryModeling]>,
381  Documentation<HasDocumentation>;
382
383def MallocSizeofChecker : Checker<"MallocSizeof">,
384  HelpText<"Check for dubious malloc arguments involving sizeof">,
385  Documentation<HasDocumentation>;
386
387def MismatchedDeallocatorChecker : Checker<"MismatchedDeallocator">,
388  HelpText<"Check for mismatched deallocators.">,
389  Dependencies<[DynamicMemoryModeling]>,
390  Documentation<HasDocumentation>;
391
392def VforkChecker : Checker<"Vfork">,
393  HelpText<"Check for proper usage of vfork">,
394  Documentation<HasDocumentation>;
395
396} // end "unix"
397
398let ParentPackage = UnixAlpha in {
399
400def ChrootChecker : Checker<"Chroot">,
401  HelpText<"Check improper use of chroot">,
402  Documentation<HasAlphaDocumentation>;
403
404def PthreadLockChecker : Checker<"PthreadLock">,
405  HelpText<"Simple lock -> unlock checker">,
406  Documentation<HasAlphaDocumentation>;
407
408def StreamChecker : Checker<"Stream">,
409  HelpText<"Check stream handling functions">,
410  Documentation<HasAlphaDocumentation>;
411
412def SimpleStreamChecker : Checker<"SimpleStream">,
413  HelpText<"Check for misuses of stream APIs">,
414  Documentation<HasAlphaDocumentation>;
415
416def BlockInCriticalSectionChecker : Checker<"BlockInCriticalSection">,
417  HelpText<"Check for calls to blocking functions inside a critical section">,
418  Documentation<HasAlphaDocumentation>;
419
420} // end "alpha.unix"
421
422//===----------------------------------------------------------------------===//
423// C++ checkers.
424//===----------------------------------------------------------------------===//
425
426let ParentPackage = Cplusplus in {
427
428def InnerPointerChecker : Checker<"InnerPointer">,
429  HelpText<"Check for inner pointers of C++ containers used after "
430           "re/deallocation">,
431  Dependencies<[DynamicMemoryModeling]>,
432  Documentation<NotDocumented>;
433
434def NewDeleteChecker : Checker<"NewDelete">,
435  HelpText<"Check for double-free and use-after-free problems. Traces memory "
436           "managed by new/delete.">,
437  Dependencies<[DynamicMemoryModeling]>,
438  Documentation<HasDocumentation>;
439
440def NewDeleteLeaksChecker : Checker<"NewDeleteLeaks">,
441  HelpText<"Check for memory leaks. Traces memory managed by new/delete.">,
442  Dependencies<[NewDeleteChecker]>,
443  Documentation<HasDocumentation>;
444
445def CXXSelfAssignmentChecker : Checker<"SelfAssignment">,
446  HelpText<"Checks C++ copy and move assignment operators for self assignment">,
447  Documentation<NotDocumented>;
448
449def MoveChecker: Checker<"Move">,
450   HelpText<"Find use-after-move bugs in C++">,
451  Documentation<HasDocumentation>;
452
453} // end: "cplusplus"
454
455let ParentPackage = CplusplusOptIn in {
456
457def VirtualCallChecker : Checker<"VirtualCall">,
458  HelpText<"Check virtual function calls during construction or destruction">,
459  Documentation<HasDocumentation>;
460
461} // end: "optin.cplusplus"
462
463let ParentPackage = CplusplusAlpha in {
464
465def DeleteWithNonVirtualDtorChecker : Checker<"DeleteWithNonVirtualDtor">,
466  HelpText<"Reports destructions of polymorphic objects with a non-virtual "
467           "destructor in their base class">,
468  Documentation<HasAlphaDocumentation>;
469
470def EnumCastOutOfRangeChecker : Checker<"EnumCastOutOfRange">,
471  HelpText<"Check integer to enumeration casts for out of range values">,
472  Documentation<HasAlphaDocumentation>;
473
474def IteratorModeling : Checker<"IteratorModeling">,
475  HelpText<"Models iterators of C++ containers">,
476  Documentation<NotDocumented>;
477
478def InvalidatedIteratorChecker : Checker<"InvalidatedIterator">,
479  HelpText<"Check for use of invalidated iterators">,
480  Dependencies<[IteratorModeling]>,
481  Documentation<HasAlphaDocumentation>;
482
483def IteratorRangeChecker : Checker<"IteratorRange">,
484  HelpText<"Check for iterators used outside their valid ranges">,
485  Dependencies<[IteratorModeling]>,
486  Documentation<HasAlphaDocumentation>;
487
488def MismatchedIteratorChecker : Checker<"MismatchedIterator">,
489  HelpText<"Check for use of iterators of different containers where iterators "
490           "of the same container are expected">,
491  Dependencies<[IteratorModeling]>,
492  Documentation<HasAlphaDocumentation>;
493
494def UninitializedObjectChecker: Checker<"UninitializedObject">,
495     HelpText<"Reports uninitialized fields after object construction">,
496  Documentation<HasAlphaDocumentation>;
497
498} // end: "alpha.cplusplus"
499
500
501//===----------------------------------------------------------------------===//
502// Valist checkers.
503//===----------------------------------------------------------------------===//
504
505let ParentPackage = Valist in {
506
507def ValistBase : Checker<"ValistBase">,
508  HelpText<"Gathers information about va_lists.">,
509  Documentation<NotDocumented>;
510
511def UninitializedChecker : Checker<"Uninitialized">,
512  HelpText<"Check for usages of uninitialized (or already released) va_lists.">,
513  Dependencies<[ValistBase]>,
514  Documentation<NotDocumented>;
515
516def UnterminatedChecker : Checker<"Unterminated">,
517  HelpText<"Check for va_lists which are not released by a va_end call.">,
518  Dependencies<[ValistBase]>,
519  Documentation<NotDocumented>;
520
521def CopyToSelfChecker : Checker<"CopyToSelf">,
522  HelpText<"Check for va_lists which are copied onto itself.">,
523  Dependencies<[ValistBase]>,
524  Documentation<NotDocumented>;
525
526} // end : "valist"
527
528//===----------------------------------------------------------------------===//
529// Deadcode checkers.
530//===----------------------------------------------------------------------===//
531
532let ParentPackage = DeadCode in {
533
534def DeadStoresChecker : Checker<"DeadStores">,
535  HelpText<"Check for values stored to variables that are never read "
536           "afterwards">,
537  Documentation<HasDocumentation>;
538
539} // end DeadCode
540
541let ParentPackage = DeadCodeAlpha in {
542
543def UnreachableCodeChecker : Checker<"UnreachableCode">,
544  HelpText<"Check unreachable code">,
545  Documentation<HasAlphaDocumentation>;
546
547} // end "alpha.deadcode"
548
549//===----------------------------------------------------------------------===//
550// Performance checkers.
551//===----------------------------------------------------------------------===//
552
553let ParentPackage = Performance in {
554
555def PaddingChecker : Checker<"Padding">,
556  HelpText<"Check for excessively padded structs.">,
557  Documentation<NotDocumented>;
558
559} // end: "padding"
560
561//===----------------------------------------------------------------------===//
562// Security checkers.
563//===----------------------------------------------------------------------===//
564
565let ParentPackage = InsecureAPI in {
566
567def SecuritySyntaxChecker : Checker<"SecuritySyntaxChecker">,
568  HelpText<"Base of various security function related checkers">,
569  Documentation<NotDocumented>;
570
571def bcmp : Checker<"bcmp">,
572  HelpText<"Warn on uses of the 'bcmp' function">,
573  Dependencies<[SecuritySyntaxChecker]>,
574  Documentation<HasDocumentation>;
575
576def bcopy : Checker<"bcopy">,
577  HelpText<"Warn on uses of the 'bcopy' function">,
578  Dependencies<[SecuritySyntaxChecker]>,
579  Documentation<HasDocumentation>;
580
581def bzero : Checker<"bzero">,
582  HelpText<"Warn on uses of the 'bzero' function">,
583  Dependencies<[SecuritySyntaxChecker]>,
584  Documentation<HasDocumentation>;
585
586def gets : Checker<"gets">,
587  HelpText<"Warn on uses of the 'gets' function">,
588  Dependencies<[SecuritySyntaxChecker]>,
589  Documentation<HasDocumentation>;
590
591def getpw : Checker<"getpw">,
592  HelpText<"Warn on uses of the 'getpw' function">,
593  Dependencies<[SecuritySyntaxChecker]>,
594  Documentation<HasDocumentation>;
595
596def mktemp : Checker<"mktemp">,
597  HelpText<"Warn on uses of the 'mktemp' function">,
598  Dependencies<[SecuritySyntaxChecker]>,
599  Documentation<HasDocumentation>;
600
601def mkstemp : Checker<"mkstemp">,
602  HelpText<"Warn when 'mkstemp' is passed fewer than 6 X's in the format "
603           "string">,
604  Dependencies<[SecuritySyntaxChecker]>,
605  Documentation<HasDocumentation>;
606
607def rand : Checker<"rand">,
608  HelpText<"Warn on uses of the 'rand', 'random', and related functions">,
609  Dependencies<[SecuritySyntaxChecker]>,
610  Documentation<HasDocumentation>;
611
612def strcpy : Checker<"strcpy">,
613  HelpText<"Warn on uses of the 'strcpy' and 'strcat' functions">,
614  Dependencies<[SecuritySyntaxChecker]>,
615  Documentation<HasDocumentation>;
616
617def vfork : Checker<"vfork">,
618  HelpText<"Warn on uses of the 'vfork' function">,
619  Dependencies<[SecuritySyntaxChecker]>,
620  Documentation<HasDocumentation>;
621
622def UncheckedReturn : Checker<"UncheckedReturn">,
623  HelpText<"Warn on uses of functions whose return values must be always "
624           "checked">,
625  Dependencies<[SecuritySyntaxChecker]>,
626  Documentation<HasDocumentation>;
627
628def DeprecatedOrUnsafeBufferHandling :
629  Checker<"DeprecatedOrUnsafeBufferHandling">,
630  HelpText<"Warn on uses of unsecure or deprecated buffer manipulating "
631           "functions">,
632  Dependencies<[SecuritySyntaxChecker]>,
633  Documentation<HasDocumentation>;
634
635} // end "security.insecureAPI"
636
637let ParentPackage = Security in {
638
639def FloatLoopCounter : Checker<"FloatLoopCounter">,
640  HelpText<"Warn on using a floating point value as a loop counter (CERT: "
641           "FLP30-C, FLP30-CPP)">,
642  Dependencies<[SecuritySyntaxChecker]>,
643  Documentation<HasDocumentation>;
644
645} // end "security"
646
647let ParentPackage = SecurityAlpha in {
648
649def ArrayBoundChecker : Checker<"ArrayBound">,
650  HelpText<"Warn about buffer overflows (older checker)">,
651  Documentation<HasAlphaDocumentation>;
652
653def ArrayBoundCheckerV2 : Checker<"ArrayBoundV2">,
654  HelpText<"Warn about buffer overflows (newer checker)">,
655  Documentation<HasAlphaDocumentation>;
656
657def ReturnPointerRangeChecker : Checker<"ReturnPtrRange">,
658  HelpText<"Check for an out-of-bound pointer being returned to callers">,
659  Documentation<HasAlphaDocumentation>;
660
661def MallocOverflowSecurityChecker : Checker<"MallocOverflow">,
662  HelpText<"Check for overflows in the arguments to malloc()">,
663  Documentation<HasAlphaDocumentation>;
664
665// Operating systems specific PROT_READ/PROT_WRITE values is not implemented,
666// the defaults are correct for several common operating systems though,
667// but may need to be overridden via the related analyzer-config flags.
668def MmapWriteExecChecker : Checker<"MmapWriteExec">,
669  HelpText<"Warn on mmap() calls that are both writable and executable">,
670  Documentation<HasAlphaDocumentation>;
671
672} // end "alpha.security"
673
674//===----------------------------------------------------------------------===//
675// Taint checkers.
676//===----------------------------------------------------------------------===//
677
678let ParentPackage = Taint in {
679
680def GenericTaintChecker : Checker<"TaintPropagation">,
681  HelpText<"Generate taint information used by other checkers">,
682  Documentation<HasAlphaDocumentation>;
683
684} // end "alpha.security.taint"
685
686//===----------------------------------------------------------------------===//
687// Mac OS X, Cocoa, and Core Foundation checkers.
688//===----------------------------------------------------------------------===//
689
690let ParentPackage = Cocoa in {
691
692def RetainCountBase : Checker<"RetainCountBase">,
693  HelpText<"Common base of various retain count related checkers">,
694  Documentation<NotDocumented>;
695
696} // end "osx.cocoa"
697
698let ParentPackage = OSX in {
699
700def NSOrCFErrorDerefChecker : Checker<"NSOrCFErrorDerefChecker">,
701  HelpText<"Implementation checker for NSErrorChecker and CFErrorChecker">,
702  Documentation<NotDocumented>;
703
704def NumberObjectConversionChecker : Checker<"NumberObjectConversion">,
705  HelpText<"Check for erroneous conversions of objects representing numbers "
706           "into numbers">,
707  Documentation<NotDocumented>;
708
709def MacOSXAPIChecker : Checker<"API">,
710  HelpText<"Check for proper uses of various Apple APIs">,
711  Documentation<HasDocumentation>;
712
713def MacOSKeychainAPIChecker : Checker<"SecKeychainAPI">,
714  HelpText<"Check for proper uses of Secure Keychain APIs">,
715  Documentation<HasDocumentation>;
716
717def MIGChecker : Checker<"MIG">,
718  HelpText<"Find violations of the Mach Interface Generator "
719           "calling convention">,
720  Documentation<NotDocumented>;
721
722def ObjCPropertyChecker : Checker<"ObjCProperty">,
723  HelpText<"Check for proper uses of Objective-C properties">,
724  Documentation<NotDocumented>;
725
726def OSObjectRetainCountChecker : Checker<"OSObjectRetainCount">,
727  HelpText<"Check for leaks and improper reference count management for "
728           "OSObject">,
729  Dependencies<[RetainCountBase]>,
730  Documentation<NotDocumented>;
731
732} // end "osx"
733
734let ParentPackage = Cocoa in {
735
736def RunLoopAutoreleaseLeakChecker : Checker<"RunLoopAutoreleaseLeak">,
737  HelpText<"Check for leaked memory in autorelease pools that will never be "
738           "drained">,
739  Documentation<NotDocumented>;
740
741def ObjCAtSyncChecker : Checker<"AtSync">,
742  HelpText<"Check for nil pointers used as mutexes for @synchronized">,
743  Documentation<HasDocumentation>;
744
745def NilArgChecker : Checker<"NilArg">,
746  HelpText<"Check for prohibited nil arguments to ObjC method calls">,
747  Documentation<HasDocumentation>;
748
749def ClassReleaseChecker : Checker<"ClassRelease">,
750  HelpText<"Check for sending 'retain', 'release', or 'autorelease' directly "
751           "to a Class">,
752  Documentation<HasDocumentation>;
753
754def VariadicMethodTypeChecker : Checker<"VariadicMethodTypes">,
755  HelpText<"Check for passing non-Objective-C types to variadic collection "
756           "initialization methods that expect only Objective-C types">,
757  Documentation<HasDocumentation>;
758
759def NSAutoreleasePoolChecker : Checker<"NSAutoreleasePool">,
760  HelpText<"Warn for suboptimal uses of NSAutoreleasePool in Objective-C GC "
761           "mode">,
762  Documentation<HasDocumentation>;
763
764def ObjCMethSigsChecker : Checker<"IncompatibleMethodTypes">,
765  HelpText<"Warn about Objective-C method signatures with type "
766           "incompatibilities">,
767  Documentation<HasDocumentation>;
768
769def ObjCUnusedIvarsChecker : Checker<"UnusedIvars">,
770  HelpText<"Warn about private ivars that are never used">,
771  Documentation<HasDocumentation>;
772
773def ObjCSelfInitChecker : Checker<"SelfInit">,
774  HelpText<"Check that 'self' is properly initialized inside an initializer "
775           "method">,
776  Documentation<HasDocumentation>;
777
778def ObjCLoopChecker : Checker<"Loops">,
779  HelpText<"Improved modeling of loops using Cocoa collection types">,
780  Documentation<NotDocumented>;
781
782def ObjCNonNilReturnValueChecker : Checker<"NonNilReturnValue">,
783  HelpText<"Model the APIs that are guaranteed to return a non-nil value">,
784  Documentation<NotDocumented>;
785
786def ObjCSuperCallChecker : Checker<"MissingSuperCall">,
787  HelpText<"Warn about Objective-C methods that lack a necessary call to "
788           "super">,
789  Documentation<NotDocumented>;
790
791def NSErrorChecker : Checker<"NSError">,
792  HelpText<"Check usage of NSError** parameters">,
793  Dependencies<[NSOrCFErrorDerefChecker]>,
794  Documentation<HasDocumentation>;
795
796def RetainCountChecker : Checker<"RetainCount">,
797  HelpText<"Check for leaks and improper reference count management">,
798  Dependencies<[RetainCountBase]>,
799  Documentation<HasDocumentation>;
800
801def ObjCGenericsChecker : Checker<"ObjCGenerics">,
802  HelpText<"Check for type errors when using Objective-C generics">,
803  Dependencies<[DynamicTypePropagation]>,
804  Documentation<HasDocumentation>;
805
806def ObjCDeallocChecker : Checker<"Dealloc">,
807  HelpText<"Warn about Objective-C classes that lack a correct implementation "
808           "of -dealloc">,
809  Documentation<HasDocumentation>;
810
811def ObjCSuperDeallocChecker : Checker<"SuperDealloc">,
812  HelpText<"Warn about improper use of '[super dealloc]' in Objective-C">,
813  Documentation<HasDocumentation>;
814
815def AutoreleaseWriteChecker : Checker<"AutoreleaseWrite">,
816  HelpText<"Warn about potentially crashing writes to autoreleasing objects "
817           "from different autoreleasing pools in Objective-C">,
818  Documentation<NotDocumented>;
819
820} // end "osx.cocoa"
821
822let ParentPackage = Performance in {
823
824def GCDAntipattern : Checker<"GCDAntipattern">,
825  HelpText<"Check for performance anti-patterns when using Grand Central "
826           "Dispatch">,
827  Documentation<NotDocumented>;
828} // end "optin.performance"
829
830let ParentPackage = OSXOptIn in {
831
832def OSObjectCStyleCast : Checker<"OSObjectCStyleCast">,
833  HelpText<"Checker for C-style casts of OSObjects">,
834  Documentation<NotDocumented>;
835
836} // end "optin.osx"
837
838let ParentPackage = CocoaAlpha in {
839
840def IvarInvalidationModeling : Checker<"IvarInvalidationModeling">,
841  HelpText<"Gathers information for annotation driven invalidation checking "
842           "for classes that contains a method annotated with "
843           "'objc_instance_variable_invalidator'">,
844  Documentation<NotDocumented>;
845
846def InstanceVariableInvalidation : Checker<"InstanceVariableInvalidation">,
847  HelpText<"Check that the invalidatable instance variables are invalidated in "
848           "the methods annotated with objc_instance_variable_invalidator">,
849  Dependencies<[IvarInvalidationModeling]>,
850  Documentation<HasAlphaDocumentation>;
851
852def MissingInvalidationMethod : Checker<"MissingInvalidationMethod">,
853  HelpText<"Check that the invalidation methods are present in classes that "
854           "contain invalidatable instance variables">,
855  Dependencies<[IvarInvalidationModeling]>,
856  Documentation<HasAlphaDocumentation>;
857
858def DirectIvarAssignment : Checker<"DirectIvarAssignment">,
859  HelpText<"Check for direct assignments to instance variables">,
860  Documentation<HasAlphaDocumentation>;
861
862def DirectIvarAssignmentForAnnotatedFunctions :
863  Checker<"DirectIvarAssignmentForAnnotatedFunctions">,
864  HelpText<"Check for direct assignments to instance variables in the methods "
865           "annotated with objc_no_direct_instance_variable_assignment">,
866  Dependencies<[DirectIvarAssignment]>,
867  Documentation<HasAlphaDocumentation>;
868
869} // end "alpha.osx.cocoa"
870
871let ParentPackage = CoreFoundation in {
872
873def CFNumberChecker : Checker<"CFNumber">,
874  HelpText<"Check for proper uses of CFNumber APIs">,
875  Documentation<HasDocumentation>;
876
877def CFRetainReleaseChecker : Checker<"CFRetainRelease">,
878  HelpText<"Check for null arguments to CFRetain/CFRelease/CFMakeCollectable">,
879  Documentation<HasDocumentation>;
880
881def CFErrorChecker : Checker<"CFError">,
882  HelpText<"Check usage of CFErrorRef* parameters">,
883  Dependencies<[NSOrCFErrorDerefChecker]>,
884  Documentation<HasDocumentation>;
885
886} // end "osx.coreFoundation"
887
888let ParentPackage = Containers in {
889
890def ObjCContainersASTChecker : Checker<"PointerSizedValues">,
891  HelpText<"Warns if 'CFArray', 'CFDictionary', 'CFSet' are created with "
892           "non-pointer-size values">,
893  Documentation<HasDocumentation>;
894
895def ObjCContainersChecker : Checker<"OutOfBounds">,
896  HelpText<"Checks for index out-of-bounds when using 'CFArray' API">,
897  Documentation<HasDocumentation>;
898
899} // end "osx.coreFoundation.containers"
900
901let ParentPackage = LocalizabilityOptIn in {
902
903def NonLocalizedStringChecker : Checker<"NonLocalizedStringChecker">,
904  HelpText<"Warns about uses of non-localized NSStrings passed to UI methods "
905           "expecting localized NSStrings">,
906  Documentation<HasDocumentation>;
907
908def EmptyLocalizationContextChecker :
909  Checker<"EmptyLocalizationContextChecker">,
910  HelpText<"Check that NSLocalizedString macros include a comment for context">,
911  Documentation<HasDocumentation>;
912
913} // end "optin.osx.cocoa.localizability"
914
915let ParentPackage = LocalizabilityAlpha in {
916
917def PluralMisuseChecker : Checker<"PluralMisuseChecker">,
918  HelpText<"Warns against using one vs. many plural pattern in code when "
919           "generating localized strings.">,
920  Documentation<HasAlphaDocumentation>;
921
922} // end "alpha.osx.cocoa.localizability"
923
924let ParentPackage = MPI in {
925
926def MPIChecker : Checker<"MPI-Checker">,
927  HelpText<"Checks MPI code">,
928  Documentation<HasDocumentation>;
929
930} // end "optin.mpi"
931
932//===----------------------------------------------------------------------===//
933// Checkers for LLVM development.
934//===----------------------------------------------------------------------===//
935
936let ParentPackage = LLVMAlpha in {
937
938def LLVMConventionsChecker : Checker<"Conventions">,
939  HelpText<"Check code for LLVM codebase conventions">,
940  Documentation<HasAlphaDocumentation>;
941
942} // end "llvm"
943
944//===----------------------------------------------------------------------===//
945// Checkers modeling Google APIs.
946//===----------------------------------------------------------------------===//
947
948let ParentPackage = GoogleAPIModeling in {
949
950def GTestChecker : Checker<"GTest">,
951  HelpText<"Model gtest assertion APIs">,
952  Documentation<NotDocumented>;
953
954} // end "apiModeling.google"
955
956//===----------------------------------------------------------------------===//
957// Debugging checkers (for analyzer development).
958//===----------------------------------------------------------------------===//
959
960let ParentPackage = Debug in {
961
962def AnalysisOrderChecker : Checker<"AnalysisOrder">,
963  HelpText<"Print callbacks that are called during analysis in order">,
964  Documentation<NotDocumented>;
965
966def DominatorsTreeDumper : Checker<"DumpDominators">,
967  HelpText<"Print the dominance tree for a given CFG">,
968  Documentation<NotDocumented>;
969
970def LiveVariablesDumper : Checker<"DumpLiveVars">,
971  HelpText<"Print results of live variable analysis">,
972  Documentation<NotDocumented>;
973
974def LiveStatementsDumper : Checker<"DumpLiveStmts">,
975  HelpText<"Print results of live statement analysis">,
976  Documentation<NotDocumented>;
977
978def CFGViewer : Checker<"ViewCFG">,
979  HelpText<"View Control-Flow Graphs using GraphViz">,
980  Documentation<NotDocumented>;
981
982def CFGDumper : Checker<"DumpCFG">,
983  HelpText<"Display Control-Flow Graphs">,
984  Documentation<NotDocumented>;
985
986def CallGraphViewer : Checker<"ViewCallGraph">,
987  HelpText<"View Call Graph using GraphViz">,
988  Documentation<NotDocumented>;
989
990def CallGraphDumper : Checker<"DumpCallGraph">,
991  HelpText<"Display Call Graph">,
992  Documentation<NotDocumented>;
993
994def ConfigDumper : Checker<"ConfigDumper">,
995  HelpText<"Dump config table">,
996  Documentation<NotDocumented>;
997
998def TraversalDumper : Checker<"DumpTraversal">,
999  HelpText<"Print branch conditions as they are traversed by the engine">,
1000  Documentation<NotDocumented>;
1001
1002def CallDumper : Checker<"DumpCalls">,
1003  HelpText<"Print calls as they are traversed by the engine">,
1004  Documentation<NotDocumented>;
1005
1006def AnalyzerStatsChecker : Checker<"Stats">,
1007  HelpText<"Emit warnings with analyzer statistics">,
1008  Documentation<NotDocumented>;
1009
1010def TaintTesterChecker : Checker<"TaintTest">,
1011  HelpText<"Mark tainted symbols as such.">,
1012  Documentation<NotDocumented>;
1013
1014def ExprInspectionChecker : Checker<"ExprInspection">,
1015  HelpText<"Check the analyzer's understanding of expressions">,
1016  Documentation<NotDocumented>;
1017
1018def ExplodedGraphViewer : Checker<"ViewExplodedGraph">,
1019  HelpText<"View Exploded Graphs using GraphViz">,
1020  Documentation<NotDocumented>;
1021
1022def ReportStmts : Checker<"ReportStmts">,
1023  HelpText<"Emits a warning for every statement.">,
1024  Documentation<NotDocumented>;
1025
1026} // end "debug"
1027
1028
1029//===----------------------------------------------------------------------===//
1030// Clone Detection
1031//===----------------------------------------------------------------------===//
1032
1033let ParentPackage = CloneDetectionAlpha in {
1034
1035def CloneChecker : Checker<"CloneChecker">,
1036  HelpText<"Reports similar pieces of code.">,
1037  Documentation<HasAlphaDocumentation>;
1038
1039} // end "clone"
1040
1041//===----------------------------------------------------------------------===//
1042// Portability checkers.
1043//===----------------------------------------------------------------------===//
1044
1045let ParentPackage = PortabilityOptIn in {
1046
1047def UnixAPIPortabilityChecker : Checker<"UnixAPI">,
1048  HelpText<"Finds implementation-defined behavior in UNIX/Posix functions">,
1049  Documentation<NotDocumented>;
1050
1051} // end optin.portability
1052
1053//===----------------------------------------------------------------------===//
1054// NonDeterminism checkers.
1055//===----------------------------------------------------------------------===//
1056
1057let ParentPackage = NonDeterminismAlpha in {
1058
1059def PointerSortingChecker : Checker<"PointerSorting">,
1060  HelpText<"Check for non-determinism caused by sorting of pointers">,
1061  Documentation<HasDocumentation>;
1062
1063} // end alpha.nondeterminism
1064