AST API Tutorial/Example

This tutorial illustrates the use of the CodeSonar Plug-In API functions and types for Abstract Syntax Trees.

The tutorial examples are implemented as CodeSonar plug-ins. If you have not already worked through the plug-in tutorial, we recommend that you do so now.

CodeSonar SaaS Note: If you want to use your own custom plug-ins with CodeSonar SaaS, contact CodeSecure support for assistance. The installation instructions provided in this page are not sufficient to make plug-ins available to SaaS analyses.

We have provided an annotated example plug-in that detects casts from const to non-const types, along with a small example program that exercises the plug-in. There is a version of the plug-in for each supported API language: C++, Python, and C.

You can experiment with any or all of the of the plug-ins: note that if you install more than one, every problem will be flagged multiple times.

Note

In this section (and throughout this manual), $CSONAR indicates the CodeSonar installation directory.

Getting Started

To get started: