1*0a6a1f1dSLionel Sambuc<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 2*0a6a1f1dSLionel Sambuc "http://www.w3.org/TR/html4/strict.dtd"> 3*0a6a1f1dSLionel Sambuc<html> 4*0a6a1f1dSLionel Sambuc<head> 5*0a6a1f1dSLionel Sambuc <title>Implicit Checks</title> 6*0a6a1f1dSLionel Sambuc <link type="text/css" rel="stylesheet" href="menu.css"> 7*0a6a1f1dSLionel Sambuc <link type="text/css" rel="stylesheet" href="content.css"> 8*0a6a1f1dSLionel Sambuc <script type="text/javascript" src="scripts/menu.js"></script> 9*0a6a1f1dSLionel Sambuc <script type="text/javascript" src="scripts/expandcollapse.js"></script> 10*0a6a1f1dSLionel Sambuc <style type="text/css"> 11*0a6a1f1dSLionel Sambuc tr:first-child { width:20%; } 12*0a6a1f1dSLionel Sambuc </style> 13*0a6a1f1dSLionel Sambuc</head> 14*0a6a1f1dSLionel Sambuc<body onload="initExpandCollapse()"> 15*0a6a1f1dSLionel Sambuc 16*0a6a1f1dSLionel Sambuc<div id="page"> 17*0a6a1f1dSLionel Sambuc<!--#include virtual="menu.html.incl"--> 18*0a6a1f1dSLionel Sambuc 19*0a6a1f1dSLionel Sambuc<div id="content"> 20*0a6a1f1dSLionel Sambuc<h1>Implicit Checkers</h1> 21*0a6a1f1dSLionel SambucEven though the implicit checkers do not produce any warnings, they are used to 22*0a6a1f1dSLionel Sambucsupport the analyzer core and model known APIs. See also 23*0a6a1f1dSLionel Sambuc<a href = "available_checks.html">Default Checkers</a> 24*0a6a1f1dSLionel Sambucand <a href = "alpha_checks.html">Experimental (Alpha) Checkers</a>. 25*0a6a1f1dSLionel Sambuc<ul> 26*0a6a1f1dSLionel Sambuc<li><a href="#core_implicit_checkers">Core Implicit Checkers</a></li> 27*0a6a1f1dSLionel Sambuc<li><a href="#osx_implicit_checkers">OS X Implicit Checkers</a></li> 28*0a6a1f1dSLionel Sambuc</ul> 29*0a6a1f1dSLionel Sambuc 30*0a6a1f1dSLionel Sambuc<!------------------------------- core implicit -------------------------------> 31*0a6a1f1dSLionel Sambuc<h3 id="core_implicit_checkers">Core Implicit Checkers</h3> 32*0a6a1f1dSLionel Sambuc<table class="checkers"> 33*0a6a1f1dSLionel Sambuc<colgroup><col class="namedescr"><col class="example"></colgroup> 34*0a6a1f1dSLionel Sambuc<thead><tr><td>Name, Description</td><td>Example</td></tr></thead> 35*0a6a1f1dSLionel Sambuc 36*0a6a1f1dSLionel Sambuc<tbody> 37*0a6a1f1dSLionel Sambuc<tr><td><div class="namedescr expandable"><span class="name"> 38*0a6a1f1dSLionel Sambuccore.DynamicTypePropagation</span><span class="lang"> 39*0a6a1f1dSLionel Sambuc(C++, ObjC)</span><div class="descr"> 40*0a6a1f1dSLionel SambucGenerate dynamic type information.</div></div></td> 41*0a6a1f1dSLionel Sambuc<td><div class="exampleContainer expandable"> 42*0a6a1f1dSLionel Sambuc<div class="example"><pre> 43*0a6a1f1dSLionel Sambuc// C++ 44*0a6a1f1dSLionel Sambucclass A { 45*0a6a1f1dSLionel Sambucpublic: 46*0a6a1f1dSLionel Sambuc A(int x) {} 47*0a6a1f1dSLionel Sambuc virtual int foo(); 48*0a6a1f1dSLionel Sambuc}; 49*0a6a1f1dSLionel Sambuc 50*0a6a1f1dSLionel Sambucclass B: public A { 51*0a6a1f1dSLionel Sambucpublic: 52*0a6a1f1dSLionel Sambuc B() 53*0a6a1f1dSLionel Sambuc :A(foo()) 54*0a6a1f1dSLionel Sambuc // DynamicTypeInfo for 'this' rigion will wrap type 'A' 55*0a6a1f1dSLionel Sambuc // unless the base constructor call expression is processed 56*0a6a1f1dSLionel Sambuc {} 57*0a6a1f1dSLionel Sambuc virtual int foo(); 58*0a6a1f1dSLionel Sambuc}; 59*0a6a1f1dSLionel Sambuc</pre></div><div class="separator"></div> 60*0a6a1f1dSLionel Sambuc<div class="example"><pre> 61*0a6a1f1dSLionel Sambuc// Objective-C 62*0a6a1f1dSLionel Sambuc@interface MyClass : NSObject {} 63*0a6a1f1dSLionel Sambuc@end 64*0a6a1f1dSLionel Sambuc 65*0a6a1f1dSLionel Sambuc@implementation MyClass 66*0a6a1f1dSLionel Sambuc+ (void)foo { 67*0a6a1f1dSLionel Sambuc MyClass *x = [[self alloc] init]; 68*0a6a1f1dSLionel Sambuc // DynamicTypeInfo from a cast: from 'id' to 'MyClass *' 69*0a6a1f1dSLionel Sambuc} 70*0a6a1f1dSLionel Sambuc@end 71*0a6a1f1dSLionel Sambuc 72*0a6a1f1dSLionel Sambucvoid test() { 73*0a6a1f1dSLionel Sambuc MyClass *x = [MyClass alloc]; 74*0a6a1f1dSLionel Sambuc // DynamicTypeInfo from a call to alloc: 75*0a6a1f1dSLionel Sambuc // from 'id' to 'MyClass *' 76*0a6a1f1dSLionel Sambuc} 77*0a6a1f1dSLionel Sambuc</pre></div></div></td></tr> 78*0a6a1f1dSLionel Sambuc 79*0a6a1f1dSLionel Sambuc 80*0a6a1f1dSLionel Sambuc<tr><td><div class="namedescr expandable"><span class="name"> 81*0a6a1f1dSLionel Sambuccore.builtin.BuiltinFunctions</span><span class="lang"> 82*0a6a1f1dSLionel Sambuc(C)</span><div class="descr"> 83*0a6a1f1dSLionel SambucEvaluate compiler builtin functions (e.g., <code>alloca()</code>)</div></div></td> 84*0a6a1f1dSLionel Sambuc<td><div class="exampleContainer expandable"> 85*0a6a1f1dSLionel Sambuc<div class="example"><pre> 86*0a6a1f1dSLionel Sambucvoid test(int x) { 87*0a6a1f1dSLionel Sambuc int *p = (int *)__builtin_alloca(8); 88*0a6a1f1dSLionel Sambuc // evaluates to AllocaRegion 89*0a6a1f1dSLionel Sambuc 90*0a6a1f1dSLionel Sambuc if(__builtin_expect(x > 10, 0)) // evaluates to 'x > 10' 91*0a6a1f1dSLionel Sambuc x = 0; 92*0a6a1f1dSLionel Sambuc} 93*0a6a1f1dSLionel Sambuc</pre></div></div></td></tr> 94*0a6a1f1dSLionel Sambuc 95*0a6a1f1dSLionel Sambuc 96*0a6a1f1dSLionel Sambuc<tr><td><div class="namedescr expandable"><span class="name"> 97*0a6a1f1dSLionel Sambuccore.builtin.NoReturnFunctions</span><span class="lang"> 98*0a6a1f1dSLionel Sambuc(C, ObjC)</span><div class="descr"> 99*0a6a1f1dSLionel SambucEvaluate "panic" functions that are known to not return to the caller.</div></div></td> 100*0a6a1f1dSLionel Sambuc<td><div class="exampleContainer expandable"> 101*0a6a1f1dSLionel Sambuc<div class="example"><pre> 102*0a6a1f1dSLionel Sambuc// C 103*0a6a1f1dSLionel Sambucvoid test() { 104*0a6a1f1dSLionel Sambuc panic(); // generate sink 105*0a6a1f1dSLionel Sambuc} 106*0a6a1f1dSLionel Sambuc</pre></div><div class="separator"></div> 107*0a6a1f1dSLionel Sambuc<div class="example"><pre> 108*0a6a1f1dSLionel Sambuc// Objective-C 109*0a6a1f1dSLionel Sambuc@interface MyObj : NSObject {} 110*0a6a1f1dSLionel Sambuc- (void)foo; 111*0a6a1f1dSLionel Sambuc@end 112*0a6a1f1dSLionel Sambuc 113*0a6a1f1dSLionel Sambuc@implementation MyObj 114*0a6a1f1dSLionel Sambuc- (void)foo { 115*0a6a1f1dSLionel Sambuc [[NSAssertionHandler currentHandler] handleFailureInMethod:_cmd 116*0a6a1f1dSLionel Sambuc object:self 117*0a6a1f1dSLionel Sambuc file:(@"somefile.m") 118*0a6a1f1dSLionel Sambuc lineNumber:1 119*0a6a1f1dSLionel Sambuc description:(@"some text")]; 120*0a6a1f1dSLionel Sambuc // generate sink 121*0a6a1f1dSLionel Sambuc} 122*0a6a1f1dSLionel Sambuc@end 123*0a6a1f1dSLionel Sambuc</pre></div></div></td></tr> 124*0a6a1f1dSLionel Sambuc 125*0a6a1f1dSLionel Sambuc</tbody></table> 126*0a6a1f1dSLionel Sambuc 127*0a6a1f1dSLionel Sambuc<!---------------------------- OS X implicit ----------------------------------> 128*0a6a1f1dSLionel Sambuc<h3 id="osx_implicit_checkers">OS X Implicit Checkers</h3> 129*0a6a1f1dSLionel Sambuc<table class="checkers"> 130*0a6a1f1dSLionel Sambuc<colgroup><col class="namedescr"><col class="example"></colgroup> 131*0a6a1f1dSLionel Sambuc<thead><tr><td>Name, Description</td><td>Example</td></tr></thead> 132*0a6a1f1dSLionel Sambuc 133*0a6a1f1dSLionel Sambuc<tbody> 134*0a6a1f1dSLionel Sambuc<tr><td><div class="namedescr expandable"><span class="name"> 135*0a6a1f1dSLionel Sambucosx.cocoa.Loops</span><span class="lang"> 136*0a6a1f1dSLionel Sambuc(ObjC)</span><div class="descr"> 137*0a6a1f1dSLionel SambucImproved modeling of loops using Cocoa collection types.</div></div></td> 138*0a6a1f1dSLionel Sambuc<td><div class="exampleContainer expandable"> 139*0a6a1f1dSLionel Sambuc<div class="example"><pre> 140*0a6a1f1dSLionel Sambucvoid test() { 141*0a6a1f1dSLionel Sambuc id x; 142*0a6a1f1dSLionel Sambuc for (x in [NSArray testObject]) { 143*0a6a1f1dSLionel Sambuc // assume the value of 'x' is non-nil 144*0a6a1f1dSLionel Sambuc } 145*0a6a1f1dSLionel Sambuc} 146*0a6a1f1dSLionel Sambuc</pre></div></div></td></tr> 147*0a6a1f1dSLionel Sambuc 148*0a6a1f1dSLionel Sambuc 149*0a6a1f1dSLionel Sambuc<tr><td><div class="namedescr expandable"><span class="name"> 150*0a6a1f1dSLionel Sambucosx.cocoa.NonNilReturnValue</span><span class="lang"> 151*0a6a1f1dSLionel Sambuc(ObjC)</span><div class="descr"> 152*0a6a1f1dSLionel SambucModel the APIs that are guaranteed to return a non-nil value.</div></div></td> 153*0a6a1f1dSLionel Sambuc<td><div class="exampleContainer expandable"> 154*0a6a1f1dSLionel Sambuc<div class="example"><pre> 155*0a6a1f1dSLionel Sambucvoid test(NSArray *A) { 156*0a6a1f1dSLionel Sambuc id subscriptObj = A[1]; // assume the value is non-nil 157*0a6a1f1dSLionel Sambuc} 158*0a6a1f1dSLionel Sambuc</pre></div></div></td></tr> 159*0a6a1f1dSLionel Sambuc 160*0a6a1f1dSLionel Sambuc</tbody></table> 161*0a6a1f1dSLionel Sambuc 162*0a6a1f1dSLionel Sambuc</div> <!-- page --> 163*0a6a1f1dSLionel Sambuc</div> <!-- content --> 164*0a6a1f1dSLionel Sambuc</body> 165*0a6a1f1dSLionel Sambuc</html> 166