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