[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / www / analyzer / implicit_checks.html
blob959c7fc18dd9a3837d53c5a0db92dcd16aaadb80
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()">
16 <div id="page">
17 <!--#include virtual="menu.html.incl"-->
19 <div id="content">
20 <h1>Implicit Checkers</h1>
21 Even though the implicit checkers do not produce any warnings, they are used to
22 support the analyzer core and model known APIs. See also
23 <a href = "available_checks.html">Default Checkers</a>
24 and <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>
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>
36 <tbody>
37 <tr><td><div class="namedescr expandable"><span class="name">
38 core.DynamicTypePropagation</span><span class="lang">
39 (C++, ObjC)</span><div class="descr">
40 Generate dynamic type information.</div></div></td>
41 <td><div class="exampleContainer expandable">
42 <div class="example"><pre>
43 // C++
44 class A {
45 public:
46 A(int x) {}
47 virtual int foo();
50 class B: public A {
51 public:
52 B()
53 :A(foo())
54 // DynamicTypeInfo for 'this' rigion will wrap type 'A'
55 // unless the base constructor call expression is processed
57 virtual int foo();
59 </pre></div><div class="separator"></div>
60 <div class="example"><pre>
61 // Objective-C
62 @interface MyClass : NSObject {}
63 @end
65 @implementation MyClass
66 + (void)foo {
67 MyClass *x = [[self alloc] init];
68 // DynamicTypeInfo from a cast: from 'id' to 'MyClass *'
70 @end
72 void test() {
73 MyClass *x = [MyClass alloc];
74 // DynamicTypeInfo from a call to alloc:
75 // from 'id' to 'MyClass *'
77 </pre></div></div></td></tr>
80 <tr><td><div class="namedescr expandable"><span class="name">
81 core.builtin.BuiltinFunctions</span><span class="lang">
82 (C)</span><div class="descr">
83 Evaluate compiler builtin functions (e.g., <code>alloca()</code>)</div></div></td>
84 <td><div class="exampleContainer expandable">
85 <div class="example"><pre>
86 void test(int x) {
87 int *p = (int *)__builtin_alloca(8);
88 // evaluates to AllocaRegion
90 if(__builtin_expect(x > 10, 0)) // evaluates to 'x > 10'
91 x = 0;
93 </pre></div></div></td></tr>
96 <tr><td><div class="namedescr expandable"><span class="name">
97 core.builtin.NoReturnFunctions</span><span class="lang">
98 (C, ObjC)</span><div class="descr">
99 Evaluate "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
103 void test() {
104 panic(); // generate sink
106 </pre></div><div class="separator"></div>
107 <div class="example"><pre>
108 // Objective-C
109 @interface MyObj : NSObject {}
110 - (void)foo;
111 @end
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
122 @end
123 </pre></div></div></td></tr>
125 </tbody></table>
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>
133 <tbody>
134 <tr><td><div class="namedescr expandable"><span class="name">
135 osx.cocoa.Loops</span><span class="lang">
136 (ObjC)</span><div class="descr">
137 Improved modeling of loops using Cocoa collection types.</div></div></td>
138 <td><div class="exampleContainer expandable">
139 <div class="example"><pre>
140 void test() {
141 id x;
142 for (x in [NSArray testObject]) {
143 // assume the value of 'x' is non-nil
146 </pre></div></div></td></tr>
149 <tr><td><div class="namedescr expandable"><span class="name">
150 osx.cocoa.NonNilReturnValue</span><span class="lang">
151 (ObjC)</span><div class="descr">
152 Model 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>
155 void test(NSArray *A) {
156 id subscriptObj = A[1]; // assume the value is non-nil
158 </pre></div></div></td></tr>
160 </tbody></table>
162 </div> <!-- page -->
163 </div> <!-- content -->
164 </body>
165 </html>