JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.
If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.
If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.
| CodeSonar® 9.2p0 | CONFIDENTIAL | CodeSecure Inc |
This section shows some sample C statements and their corresponding ASTs.
ASTs are shown in "list" format. Note that CodeSonar transforms some statements into one or more normalized statements with the same meaning. There is one PDG_VERTEX for each such normalized statement, each with its corresponding AST.
| C/C++ Statement | Normalized Statement | Normalized AST (only key fields shown) |
|---|---|---|
j = i + 1; |
. |
(c:=
:1 (c:variable :name "j")
:2 (c:+
:1 (c:variable :name "i")
:2 (c:integer-value-32 :value 1)))
|
j = i + (i * 2); |
. |
(c:=
:1 (c:variable :name "j")
:2 (c:+
:1 (c:variable :name "i")
:2 (c:*
:1 (c:variable :name "i")
:2 (c:integer-value-32 :value 2))))
|
k = &i; |
. |
(c:=
:1 (c:variable :name "k")
:2 (c:addr
:1 (c:variable :name "i")))
|
j = i++; |
$temp1 = i; i = i + 1; j = $temp1; |
|
*(k + i) = 1; |
. |
(c:=
:1 (c:ptr
:1 (c:+
:1 (c:variable :name "k")
:2 (c:variable :name "i")))
:2 (c:integer-value-32 :value 1))
|
k[i] = 1; |
*(k + i) = 1; |
(c:=
:1 (c:ptr
:1 (c:+
:1 (c:variable :name "k")
:2 (c:variable :name "i")))
:2 (c:integer-value-32 :value 1))
|
i = sizeof(unsigned); |
i = 4; |
(c:=
:1 (c:variable :name "i")
:2 (c:integer-value-32
:value 4 ))
|
x.i = (short) i & 2; |
x.i = (short int) i & 2; |
(c:=
:1 (c:dot
:1 (c:variable :name "x")
:2 (c:field :name "i"))
:2 (c:&
:1 (c:cast
:1 (c:integer :integer-kind short)
:2 (c:variable :name "i"))
:2 (c:integer-value-32 :value 2)))
|
General information:
| ASTs | Overview of Abstract Syntax Trees in CodeSonar. |
|---|---|
| AST Patterns | Constructs that describe AST properties, for matching. |
| AST Class Index | Index page for the AST class descriptions. |
| Tutorial | Annotated example plug-ins (in each supported API language) that use AST patterns to implement a custom check. |
Specific API languages:
| C++ | classes ast, ast_class, ast_pattern, ast_ordinal, ast_iterator |
|---|---|
| Python | classes ast, ast_class, ast_pattern, ast_ordinal, ast_iterator |
| C | C API: AST Functions and Types |
To report problems with this documentation, please visit https://support.codesecure.com/.