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 |
API functions provide access to information in project source files.
Language Module Support: Internal representation for compilation units, source files, and source file instances is available for C/C++, binary, C#, and Java analyses.
A project is a combination of compilation units. Each compilation unit has:
We distinguish between "files" and "file instances" because a given file may have multiple roles in a project. The top-level file instances and the include-file instances of a project are collectively known as source-file instances.
The following table summarizes the information stored about each compilation unit.
| each... | ...has an associated... | ...that... |
|---|---|---|
| compilation unit | unique identifier (UID) | is assigned when the unit is (re)compiled |
| include tree | represents the inclusion relations among the file instances | |
| source file | unique source-file identifier (SF) | is generated as needed and only remains valid for the duration of the browsing session. |
| unnormalized file path | identifies its location in the file system | |
| normalized file path |
is generated from the unnormalized file path as follows.
|
|
| directory | directly contains the source file | |
| source file instance | unique source-file-instance identifier (SFID) | is generated as needed and only remains valid for the duration of the browsing session. |
| include path | identifies its location in a compilation unit's include tree. | |
| character in a source file | line and column | specifies its location within the file |
| character in a source file instance | offset | specifies its location within the compilation unit |
Suppose we build a project based on observing the following compilation:
where the project source files are as follows.
/* m.c */ #include "a.h" #include "b.h" #define ONE #include "b.h" #undef ONE /* ... */ |
/* a.h */ /* (no #include statements) */ |
/* b.h */ #ifdef ONE #include "a.h" #else #include "c.h" #endif /* ... */ |
/* c.h */ /* (no #include statements) */ |
The project has:
In a project with multiple compilation units, a single source file could have instances in more than one compilation unit.
API functions provide access to compilation unit information as follows:
| Given: | Return: |
|---|---|
| UID |
|
| UID + include path |
|
| UID + offset | |
| UID + offset1 + offset2 | |
| SF |
|
| SFID |
|
| SFID + line |
By API language:
| C++ | classes compunit, sfile , and sfileinst |
|---|---|
| Python | classes compunit, sfile , and sfileinst |
| C | Header cs_source_files.h provides functions and types for source files, file instances, and compilation units. |
See also:
To report problems with this documentation, please visit https://support.codesecure.com/.