Implicit Checkers
Even though the implicit checkers do not produce any warnings, they are used to
support the analyzer core and model known APIs. See also
Default Checkers
and
Experimental (Alpha) Checkers.
Core Implicit Checkers
Name, Description | Example |
core.DynamicTypePropagation
(C++, ObjC)
Generate dynamic type information. |
// C++
class A {
public:
A(int x) {}
virtual int foo();
};
class B: public A {
public:
B()
:A(foo())
// DynamicTypeInfo for 'this' rigion will wrap type 'A'
// unless the base constructor call expression is processed
{}
virtual int foo();
};
// Objective-C
@interface MyClass : NSObject {}
@end
@implementation MyClass
+ (void)foo {
MyClass *x = [[self alloc] init];
// DynamicTypeInfo from a cast: from 'id' to 'MyClass *'
}
@end
void test() {
MyClass *x = [MyClass alloc];
// DynamicTypeInfo from a call to alloc:
// from 'id' to 'MyClass *'
}
|
core.builtin.BuiltinFunctions
(C)
Evaluate compiler builtin functions (e.g., alloca() ) |
void test(int x) {
int *p = (int *)__builtin_alloca(8);
// evaluates to AllocaRegion
if(__builtin_expect(x > 10, 0)) // evaluates to 'x > 10'
x = 0;
}
|
core.builtin.NoReturnFunctions
(C, ObjC)
Evaluate "panic" functions that are known to not return to the caller. |
// C
void test() {
panic(); // generate sink
}
// Objective-C
@interface MyObj : NSObject {}
- (void)foo;
@end
@implementation MyObj
- (void)foo {
[[NSAssertionHandler currentHandler] handleFailureInMethod:_cmd
object:self
file:(@"somefile.m")
lineNumber:1
description:(@"some text")];
// generate sink
}
@end
|
OS X Implicit Checkers
Name, Description | Example |
osx.cocoa.Loops
(ObjC)
Improved modeling of loops using Cocoa collection types. |
void test() {
id x;
for (x in [NSArray testObject]) {
// assume the value of 'x' is non-nil
}
}
|
osx.cocoa.NonNilReturnValue
(ObjC)
Model the APIs that are guaranteed to return a non-nil value. |
void test(NSArray *A) {
id subscriptObj = A[1]; // assume the value is non-nil
}
|