blob: 7d71ac0b559803f0b42c3758acef04bb955bb1cc [file] [log] [blame]
Jordan Rosea779e272012-08-22 01:03:39 +00001The analyzer contains a number of checkers which can aid in debugging. Enable them by using the "-analyzer-checker=" flag, followed by the name of the checker.
2
3General Analysis Dumpers
4========================
5These checkers are used to dump the results of various infrastructural analyses to stderr. Some checkers also have "view" variants, which will display a graph using a 'dot' format viewer (such as Graphviz on OS X) instead.
6
7- debug.DumpCallGraph, debug.ViewCallGraph: Show the call graph generated for the current translation unit. This is used to determine the order in which to analyze functions when inlining is enabled.
8- debug.DumpCFG, debug.ViewCFG: Show the CFG generated for each top-level function being analyzed.
9- debug.DumpDominators: Shows the dominance tree for the CFG of each top-level function.
10- debug.DumpLiveVars: Show the results of live variable analysis for each top-level function being analyzed.
11
12
13Path Tracking
14=============
15These checkers print information about the path taken by the analyzer engine.
16
17- debug.DumpCalls: Prints out every function or method call encountered during a path traversal. This is indented to show the call stack, but does NOT do any special handling of branches, meaning different paths could end up interleaved.
18- debug.DumpTraversal: Prints the name of each branch statement encountered during a path traversal ("IfStmt", "WhileStmt", etc). Currently used to check whether the analysis engine is doing BFS or DFS.
19
20
21State Checking
22==============
23These checkers will print out information about the analyzer state in the form of analysis warnings. They are intended for use with the -verify functionality in regression tests.
24
25- debug.TaintTest: Prints out the word "tainted" for every expression that carries taint. At the time of this writing, taint was only introduced by the checks under experimental.security.taint.TaintPropagation; this checker may eventually move to the security.taint package.
26- debug.ExprInspection: Responds to certain function calls, which are modeled after builtins. These function calls should affect the program state other than the evaluation of their arguments; to use them, you will need to declare them within your test file. The available functions are described below.
27
28(FIXME: debug.ExprInspection should probably be renamed, since it no longer only inspects expressions.)
29
30
31ExprInspection checks
32---------------------
33
34// Prints TRUE if the argument is known to have a non-zero value,
35// FALSE if the argument is known to have a zero or null value, and
36// UNKNOWN if the argument isn't sufficiently constrained on this path.
37// You can use this to test other values by using expressions like "x == 5".
38// Note that this functionality is currently DISABLED in inlined functions,
39// since different calls to the same inlined function could provide different
40// information, making it difficult to write proper -verify directives.
41//
42// In C, the argument can be typed as 'int' or as '_Bool'.
43void clang_analyzer_eval(bool);
44
45
46// If a call occurs within an inlined function, prints TRUE or FALSE according to
47// the value of its argument. If a call occurs outside an inlined function,
48// nothing is printed.
49//
50// The intended use of this checker is to assert that a function is inlined at
51// least once (by passing 'true' and expecting a warning), or to assert that a
52// function is never inlined (by passing 'false' and expecting no warning). The
53// argument is technically unnecessary but is intended to clarify intent.
54//
55// You might wonder why we can't print TRUE if a function is ever inlined and
56// FALSE if it is not. The problem is that any inlined function could conceivably
57// also be analyzed as a top-level function (in which case both TRUE and FALSE
58// would be printed), depending on the value of the -analyzer-inlining option.
59//
60// In C, the argument can be typed as 'int' or as '_Bool'.
61void clang_analyzer_checkInlined(bool);
62
63
64Statistics
65==========
66The debug.Stats checker collects various information about the analysis, such as how many blocks were reached and if the analyzer timed out. There is also an additional -analyzer-stats flag, which enables various statistics within the analyzer engine.
67
68(FIXME: We should probably just have the debug.Stats checker enabled when -analyzer-stats is passed. We can't do the other way around because by the time checkers are enabled it's a bit too late to start a timer.)