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 |
ASTs are objects. Thus, each AST is an instance of a given class. The classes are arranged in a hierarchy in which each class is a subclass of <ast-root>.
AST classes and AST families are represented in the API as shown in the following table.
| API Language | AST Family | AST Class |
|---|---|---|
| C++ | cs::ast_family static member | cs::ast_class static member |
| Python | cs.ast_family static member | cs.ast_class static member |
| C | cs_ast_family enum symbol | cs_ast_class enum symbol |
For C and C++ programs:
CodeSonar generates two kinds of ASTs for C/C++ programs. We refer to these as the two AST families.
For each AST family we provide full details of each AST class along with two indexes: an alphabetical index to facilitate lookup by class name, and a tree index whose structure reflects that of the class inheritance hierarchy.
| Family | Purpose | AST Family ; AST Class representation in API (see API note) | ||
|---|---|---|---|---|
| C++ | Python | C | ||
| unnormalized ASTs |
An AST that has not been affected by normalization.
Unnormalized ASTs are truer to the source code but are also more complex and unwieldy than normalized ASTs. |
cs::ast_family::C_UNNORMALIZED; cs::ast_class::UC_* |
cs.ast_family.C_UNNORMALIZED; cs.ast_class.UC_* |
csaf_c_unnormalized; csac_uc_* |
| normalized ASTs |
An abstract syntax tree that represents program points that
CodeSonar has normalized.
Normalized ASTs are simpler and easier to learn than unnormalized ASTs, while still giving all the semantics of the program. Normalized ASTs are preferable for most applications because your scripts have fewer cases to handle. |
cs::ast_family::C_NORMALIZED; cs::ast_class::NC_* |
cs.ast_family.C_NORMALIZED; cs.ast_class.NC_* |
csaf_c_normalized; csac_nc_* |
The C/C++ AST families share a number of helper types.
Program points of some kinds have associated ASTs, as shown in the following table.
| normAST | "X" if program points of this kind have an associated normalized C/C++ AST, "." otherwise. |
|---|---|
| unnormASTs | "X" if program points of this kind have one or more associated unnormalized C/C++ AST, "." otherwise. |
| Kind | normAST | unnormASTs |
|---|---|---|
| actual-in | X | X |
| actual-out | X | X |
| auxiliary | . | . |
| body | . | X |
| call-site | . | X |
| control-point | X | X |
| declaration | . | X |
| entry | . | X |
| exceptional-exit | X | X |
| exceptional-return | X | X |
| exit | . | X |
| expression | X | X |
| formal-in | . | X |
| formal-out | . | X |
| global-actual-in | . | . |
| global-actual-out | . | . |
| global-formal-in | . | . |
| global-formal-out | . | . |
| indirect-call | X | X |
| jump | X | X |
| label | X | X |
| normal-exit | X | X |
| normal-return | X | X |
| phi | . | . |
| pi | . | . |
| return | X | X |
| switch-case | X | X |
| unavailable | . | X |
| unknown | . | . |
| variable-initialization | X | X |
General information:
| ASTs | Overview of Abstract Syntax Trees in CodeSonar. |
|---|---|
| AST Patterns | Constructs that describe AST properties, for matching. |
| Examples of Normalized C/C++ ASTs | Some sample C statements and their corresponding ASTs. |
| 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/.