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
C and C++
Binaries

Source Files: cs_source_files.h

Defines a set of source file operations for CodeSonar.



Links


Defines

#define CS_SOURCE_FILES_H

Types

typedef cs_sf_instance_iter
Definition typedef struct __cs_sf_instance_iter cs_sf_instance_iter
Notes For a specific source file (cs_sf), an iterator over all the instances (cs_sfid) of that file in the analyzed project.

Used by

typedef cs_sfid_children_iter
Definition typedef struct cs_sfid_children_iter cs_sfid_children_iter
Notes An iterator over the file instances (cs_sfid) #included in a specified file instance.

API clients should never directly access the fields of this type. This is only exported so that clients may stack allocate these things. Future versions of the API reserve the right to change the definition of this iterator type.

On Separate Pages

struct __cs_sf_instance_iter
struct cs_sfid_children_iter

Functions

cs_boolean cs_language_is_machine_code ( cs_language lang )
Check: is the specified language is a machine code language (as opposed to a source language or special cs_language value)?
cs_result cs_file_get_normalized_name ( cs_uid uid, cs_file_path file_path, cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Get the normalized cs_file_path corresponding to a compilation unit.
cs_result cs_file_get_name ( cs_uid uid, cs_file_path file_path, cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Get the unnormalized cs_file_path corresponding to a compilation unit.
cs_result cs_file_get_include_pos_name ( cs_sfid sfid, cs_sfid rpath[], cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Get the include path for a source file instance.
cs_result cs_file_get_normalized_include_name ( cs_sfid sfid, cs_file_path pname, cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Get the normalized absolute path name for a source file instance.
cs_result cs_file_get_include_name ( cs_sfid sfid, cs_file_path pname, cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Get the unnormalized absolute path name for a source file instance.
cs_result cs_file_get_normalized_include_name64 ( cs_sfid sfid, cs_const_string64 * pname )
Get the normalized absolute path name for a source file instance.
cs_result cs_file_get_include_name64 ( cs_sfid sfid, cs_const_string64 * pname )
Get the unnormalized absolute path name for a source file instance.
cs_result cs_file_get_characters ( cs_sfid sfid, cs_line line_start, cs_column col_start, cs_line line_end, cs_column col_end, cs_string substr, cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Get a substring from a file using (line, column) pairs to specify the beginning and end of the substring.
cs_result cs_file_ast ( cs_uid uid, cs_ast_family ast_family, cs_ast * out_ast )
Get the cs_ast for a specified compilation unit.
cs_result cs_file_asts_at ( cs_sfid sfid, cs_line sfline, const cs_ast_class * interest_classes, cs_ast * out_asts, cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Get the ASTs (cs_ast) at a specified location in a compilation unit.
cs_result cs_file_get_linecount ( cs_sfid sfid, cs_line * out_l )
Get the number of lines in a source file instance.
cs_result cs_file_get_line_offset ( cs_sfid sfid, cs_line fline, cs_file_offset * out_offset )
Get the character offset for a line within a source file instance.
cs_result cs_file_get_line_range ( cs_sfid sfid, cs_line fline, cs_file_offset * out_start, cs_file_offset * out_end )
Get the character offsets for the beginning and the end of a line within a source file instance.
cs_result cs_file_get_line_num ( cs_sfid sfid, cs_file_offset point_offset, cs_line * out_line )
Get the cs_line associated with a point identified by an offset and a source file instance.
cs_result cs_file_get_linecol ( cs_sfid sfid, cs_file_offset point_offset, cs_line * out_line, cs_column * out_column )
Get the cs_line and cs_column associated with a point identified by an offset and a source file instance.
cs_result cs_file_language ( cs_uid uid, cs_language * lang )
Get the source language of a compilation unit.
cs_result cs_file_group_uid ( cs_uid uid, csuint32 * group_uid )
Get the group to which a compilation unit belongs.
cs_result cs_file_webid ( cs_uid uid, cs_string webid, cs_size_t capacity_bytes, cs_size_t * bytes_needed )
[CodeSonar only] Get the value used to identify a compilation unit to the hub: this will allow you to construct a hub URL.
cs_result cs_file_compiler_model ( cs_uid uid, cs_string compiler_model, cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Get the name of the compiler model used to build uid.
cs_result cs_file_native_command_line ( cs_uid uid, cs_const_string64 outbuf[], cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Get the native command line used to build uid.
cs_result cs_file_effective_native_flags ( cs_uid uid, cs_const_string64 outbuf[], cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Get the effective flags for the native build of uid.
cs_result cs_file_frontend_command_line ( cs_uid uid, cs_const_string64 outbuf[], cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Get the front end command line used to build uid.
cs_result cs_file_compiler_wall_enable_flags ( cs_uid uid, cs_const_string64 outbuf[], cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Get the list of flags the compiler uses to enable all warnings.
cs_result cs_file_seen_wall_disable_flags ( cs_uid uid, cs_const_string64 outbuf[], cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Get the list of seen command line options that disable some warnings.
cs_result cs_file_compiler_werror_enable_flags ( cs_uid uid, cs_const_string64 outbuf[], cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Get the list of flags the compiler uses to treat warnings as errors.
cs_result cs_file_seen_werror_disable_flags ( cs_uid uid, cs_const_string64 outbuf[], cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Get the list of seen command line options that disable or downgrade errors.
cs_result cs_file_error_count ( cs_uid uid, cs_size_t * num_errors )
Get the number of errors encountered in compiling a compilation unit.
cs_result cs_file_warning_count ( cs_uid uid, cs_size_t * num_warnings )
Get the number of warnings encountered compiling the given unit.
cs_result cs_file_uid_get_sfid ( cs_uid uid, cs_sfid * sfid )
Get the root source file instance of a compilation unit.
cs_result cs_file_sfid_get_uid ( cs_sfid sfid, cs_uid * uid )
Get the compilation unit to which a specified file instance belongs.
cs_boolean cs_sfid_is_system_include ( cs_sfid sfid )
Check: is the specified cs_sfid considered a system include according to SYSTEM_INCLUDE_PATHS?
cs_result cs_file_sfid_get_children ( cs_sfid sfid, cs_sfid child_list[], cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Get the include-tree children of a source file instance.
cs_result cs_file_sfid_children_iter_first ( cs_sfid sfid, cs_sfid * child, cs_sfid_children_iter * iter )
Get the first cs_sfid from the list of #included file instances for a specified file instance and set up an iterator over the remaining children.
cs_result cs_file_sfid_children_iter_next ( cs_sfid * child, cs_sfid_children_iter * iter )
Advance the provided include tree child iterator and retrieve the next element.
cs_result cs_file_sfid_children_iter_close ( cs_sfid_children_iter * iter )
Close a cs_sfid_children_iter iterator.
cs_result cs_file_sfid_get_parent ( cs_sfid sfid, cs_sfid * arg_parent )
Get the include-tree parent of a source file instance.
cs_result cs_file_sfid_get_parent_line ( cs_sfid arg_sfid, cs_sfid * arg_parent, cs_line * line )
Get the include location of a source file instance.
cs_result cs_file_sfid_get_child_at ( cs_sfid sfid, cs_line include_line, cs_sfid * child )
Get the source file instance included at the given location.
cs_result cs_file_color_map_iter_first ( cs_sfid sfid, cs_syntax_kind syn_kind, cs_line * start_line, cs_column * start_column, cs_line * end_line, cs_column * end_column, cs_color_map_iter * iter )
Get the location of the first span of the specified cs_syntax_kind from the specified source file instance.
cs_result cs_file_color_map_iter_scan_first ( cs_sfid sfid, cs_syntax_kind syn_kind, cs_line lowerbound, cs_line * start_line, cs_column * start_column, cs_line * end_line, cs_column * end_column, cs_color_map_iter * iter )
Get the location of the first span of the specified cs_syntax_kind at or after the specified line in the specified source file instance; set up an iterator over the remaining spans of that type.
cs_result cs_file_color_map_iter_next ( cs_line * start_line, cs_column * start_column, cs_line * end_line, cs_column * end_column, cs_color_map_iter * iter )
Get the next span from a cs_color_map_iter iterator.
cs_result cs_file_color_map_iter_close ( cs_color_map_iter * iter )
Close a cs_color_map_iter iterator.
cs_result cs_uid_pdgs_iter_first ( cs_uid uid, cs_pdg * pdg, cs_uid_pdgs_iter * itr )
Get the first cs_pdg from the compilation unit whose cs_uid is uid.
cs_result cs_uid_pdgs_iter_next ( cs_pdg * pdg, cs_uid_pdgs_iter * itr )
Retrieve the next cs_pdg in a compilation unit, using an iterator.
cs_result cs_uid_pdgs_iter_close ( cs_uid_pdgs_iter * itr )
Close a cs_uid_pdgs_iter iterator.
cs_result cs_uid_nonlocals_iter_first ( cs_uid uid, cs_abs_loc * abs_loc, cs_uid_nonlocals_iter * itr )
Get the first nonlocal symbol (cs_abs_loc) from the compilation unit whose cs_uid is uid, and set up an iterator to traverse the remaining nonlocal symbols.
cs_result cs_uid_nonlocals_iter_next ( cs_abs_loc * abs_loc, cs_uid_nonlocals_iter * itr )
Retrieve the next nonlocal cs_abs_loc in a compilation unit, using an iterator.
cs_result cs_uid_nonlocals_iter_close ( cs_uid_nonlocals_iter * itr )
Close a cs_uid_nonlocals_iter iterator.
cs_result cs_file_count_lines ( cs_sfid sfid, cs_line start, cs_line end, cs_size_t * blank_count, cs_size_t * comment_count, cs_size_t * code_count, cs_size_t * mixed_count )
For a set of adjacent lines in a file, retrieve statistics about the classifications of the lines in the set.
cs_result cs_uid_create ( cs_const_string file_name, cs_language lang, cs_uid * out_uid )
Create a new compilation unit.
cs_boolean cs_uid_is_user_unit ( cs_uid uid )
Check: does the specified cs_uid correspond to a user-generated compilation unit?
cs_boolean cs_uid_is_library_model_unit ( cs_uid uid )
Check: does the specified cs_uid correspond to a compilation unit for a library model shipped with CodeSonar or CodeSurfer?
cs_boolean cs_uid_is_rewriting_unit ( cs_uid uid )
Check: does the specified cs_uid correspond to a rewriting compilation unit (created via cs_uid_create())?
cs_boolean cs_uid_is_backend_unit ( cs_uid uid )
Check: does the specified cs_uid correspond to a compilation unit generated by the back end to hold #System_Initialization and undefined functions?
cs_result cs_uid_is_shared_unit ( cs_uid uid, cs_boolean * out )
Check: can a compilation unit be shared by multiple projects and analyses?
cs_result cs_uid_is_summary ( cs_uid uid, cs_boolean * is_summary )
Get the is_summary flag for this compilation unit.
cs_result cs_uid_is_hidden_binary ( cs_uid cuid, cs_boolean * is_hidden )
[CodeSonar for Binaries only] Checks if a compilation unit is an 'offstage binary' (that is, one that is analyzed but not included in results).
cs_result cs_uid_limit_reached ( cs_uid cuid, cs_boolean * limit_reached )
Check: did the front end reach any limits while parsing the specified compilation unit (which may have resulted in missing IR)?
cs_result cs_sfid_sf ( cs_sfid sfid, cs_sf * sf )
Get the source file corresponding to a specified file instance.
cs_result cs_sf_arbitrary_sfid ( cs_sf sf, cs_sfid * sfid )
Get an (arbitrary) instance of a specified source file.
cs_result cs_sf_instance_iter_first ( cs_sf sf, cs_sfid * sfid, cs_sf_instance_iter * iter )
Get the first cs_sfid from the list of instances (in the analyzed project) of the specified source file; set up an iterator over the remaining instances.
cs_result cs_sf_instance_iter_next ( cs_sfid * sfid, cs_sf_instance_iter * iter )
Get the next instance of a (previously specified) source file, using an iterator.
cs_result cs_sf_instance_iter_close ( cs_sf_instance_iter * iter )
Close a cs_sf_instance_iter iterator.
cs_result cs_sf_line_pdgs ( cs_sf sf, cs_line line, cs_boolean exact, cs_pdg pdg_list[], cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Get a list of the PDGs (cs_pdg) whose definition is at the specified source file and line number.
const char * cs_sfid_normalized_string ( cs_sfid sfid )
Get the normalized absolute path name for a source file instance.
const char * cs_sfid_string ( cs_sfid sfid )
Get the unnormalized absolute path name for a source file instance.
cs_result cs_sf_get_parent ( cs_sf sf, cs_directory * dir )
Get the parent cs_directory for a source file.
const char * cs_sf_normalized_string ( cs_sf sf )
Get the normalized absolute path name for a source file.
const char * cs_sf_string ( cs_sf sf )
Get the unnormalized absolute path name for a source file.
cs_hash_t cs_sf_stable_hash ( cs_sf sf )
Get a hash value for a cs_sf, with stable results across sufficiently-similar analyses.
int cs_sf_stable_compare ( cs_sf sf_a, cs_sf sf_b )
Compare two cs_sf objects, with stable results across sufficiently-similar analyses.
cs_hash_t cs_sfid_stable_hash ( cs_sfid sf )
Get a hash value for a cs_sfid, with stable results across sufficiently-similar analyses.
int cs_sfid_stable_compare ( cs_sfid sfid_a, cs_sfid sfid_b )
Compare two cs_sfid objects, with stable results across sufficiently-similar analyses.
const char * cs_uid_normalized_filename_string ( cs_uid uid )
Get the normalized absolute path name for a compilation unit.
const char * cs_uid_filename_string ( cs_uid uid )
Get the unnormalized absolute path name for a compilation unit.
const char * cs_uid_language_string ( cs_uid uid )
Get the name of a compilation unit's language.
cs_result cs_uid_get_handle ( cs_uid uid, cs_string uid_handle, cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Get a storable handle for a compilation unit (cs_uid).
cs_result cs_uid_lookup_handle ( cs_const_string uid_handle, cs_uid * uid )
Retrieve a compilation unit (cs_uid) from a handle.
cs_result cs_sf_get_handle ( cs_sf sf, cs_string sf_handle, cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Get a storable handle for a source file (cs_sf).
cs_result cs_sf_lookup_handle ( cs_const_string sf_handle, cs_sf * sf )
Retrieve a source file (cs_sf) from a handle.
cs_result cs_sfid_get_handle ( cs_sfid sfid, cs_string sfid_handle, cs_size_t capacity_bytes, cs_size_t * bytes_needed )
Get a storable handle for a source file instance (cs_sfid).
cs_result cs_sfid_lookup_handle ( cs_const_string sfid_handle, cs_sfid * sfid )
Retrieve a source file instance (cs_sfid) from a handle.

Function Descriptions

Function cs_language_is_machine_code
cs_boolean cs_language_is_machine_code (
Check: is the specified language is a machine code language (as opposed to a source language or special cs_language value)?
Parameters
lang [in] The cs_language to check.
Returns A cs_boolean:
  • cs_true if lang is a machine-code language,
  • cs_false otherwise (including csl_wildcard and csl_synthetic).
Function cs_file_get_normalized_name
cs_result cs_file_get_normalized_name (
Get the normalized cs_file_path corresponding to a compilation unit.
Parameters
uid [in] The unique identifier for the compilation unit.
file_path [out] A user-allocated buffer to be populated with the normalized cs_file_path corresponding to uid.
  • Windows: this path is the downcased version of the one output by cs_file_get_name(), with backslash directory separators replaced by forward slashes.
  • Mac: this path is the downcased version of the one output by cs_file_get_name().
  • Otherwise: this path is the same as the one output by cs_file_get_name().
capacity_bytes [in] The capacity of file_path, measured in bytes.
bytes_needed [out] The number of bytes required to store the entire normalized file path.
Returns A cs_result:
Notes Use cs_file_get_name() to get the unnormalized cs_file_path.

Call this function with file_path NULL and capacity_bytes 0 (zero) to determine the memory needed to hold the entire path.

Function cs_file_get_name
cs_result cs_file_get_name (
Get the unnormalized cs_file_path corresponding to a compilation unit.
Parameters
uid [in] The unique identifier for the compilation unit.
file_path [out] A user-allocated buffer to be populated with the unnormalized cs_file_path corresponding to uid.
capacity_bytes [in] The capacity of file_path, measured in bytes.
bytes_needed [out] The number of bytes required to store the entire unnormalized file path.
Returns A cs_result:
Notes Use cs_file_get_normalized_name() to get the normalized cs_file_path.

Call this function with file_path NULL and capacity_bytes 0 (zero) to determine the memory needed to hold the entire path.

Function cs_file_get_include_pos_name
cs_result cs_file_get_include_pos_name (
Get the include path for a source file instance.
Parameters
sfid [in] The cs_sfid of the source file instance for which the include path should be obtained.
rpath [out] A user-allocated array to be populated with the include path of the file corresponding to sfid.
capacity_bytes [in] The capacity of rpath, measured in bytes.
bytes_needed [out] The number of bytes required to store the entire include path of the file corresponding to sfid.
Returns A cs_result:
Notes Retrieve the include-path for sfid. The include-path is a list of cs_sfid elements.

Call this function with rpath NULL and capacity_bytes 0 (zero) to determine the memory needed to hold the entire path.

Function cs_file_get_normalized_include_name
cs_result cs_file_get_normalized_include_name (
Get the normalized absolute path name for a source file instance.
Parameters
sfid [in] The cs_sfid of the source file instance for which the absolute path name should be obtained.
pname [out] A user-allocated buffer to be populated with the normalized absolute path name for the file corresponding to sfid.
capacity_bytes [in] The capacity of pname, measured in bytes.
bytes_needed [out] The number of bytes required to store the entire normalized absolute path name of the file corresponding to sfid.
Returns A cs_result:
Notes Use cs_file_get_include_name() to get the unnormalized cs_file_path.

Call this function with pname NULL and capacity_bytes 0 (zero) to determine the memory needed to hold the entire path.

Function cs_file_get_include_name
cs_result cs_file_get_include_name (
Get the unnormalized absolute path name for a source file instance.
Parameters
sfid [in] The cs_sfid of the source file instance for which the absolute path name should be obtained.
pname [out] A user-allocated buffer to be populated with the unnormalized absolute path name for the file corresponding to sfid.
capacity_bytes [in] The capacity of pname, measured in bytes.
bytes_needed [out] The number of bytes required to store the entire unnormalized absolute path name of the file corresponding to sfid.
Returns A cs_result:
Notes Use cs_file_get_normalized_include_name() to get the normalized cs_file_path.

Call this function with pname NULL and capacity_bytes 0 (zero) to determine the memory needed to hold the entire path.

Function cs_file_get_normalized_include_name64
cs_result cs_file_get_normalized_include_name64 (
Get the normalized absolute path name for a source file instance.
Parameters
sfid [in] The cs_sfid of the source file instance for which the absolute path name should be obtained.
pname [out] A cs_const_string64 to be populated with the normalized absolute path name for the file corresponding to sfid.
Returns A cs_result:
Notes Use cs_file_get_include_name64() to get the unnormalized version of the path.
Function cs_file_get_include_name64
cs_result cs_file_get_include_name64 (
Get the unnormalized absolute path name for a source file instance.
Parameters
sfid [in] The cs_sfid of the source file instance for which the absolute path name should be obtained.
pname [out] A cs_const_string64 to be populated with the unnormalized absolute path name for the file corresponding to sfid.
Returns A cs_result:
Notes Use cs_file_get_normalized_include_name64() to get the normalized version of the path.
Function cs_file_get_characters
cs_result cs_file_get_characters (
Get a substring from a file using (line, column) pairs to specify the beginning and end of the substring.
Parameters
sfid [in] A cs_sfid identifying the file to be read from.
line_start [in] The beginning line of the substring.
col_start [in] The beginning column of the substring.
line_end [in] The ending line of the substring. (If you want to read to the end of the file, use cs_file_get_linecount() to get the number of lines in the instance.)
col_end [in] The ending column of the substring, exclusive. Set to -1 to read to the end of line_end.
substr [out] A user-allocated buffer to be populated with the characters from sfid from ( line_start, col_start ) to ( line_end, col_end ).
capacity_bytes [in] The capacity of substr, measured in bytes.
bytes_needed [out] The number of bytes required to store the entire substring.
Returns A cs_result:
Notes Call this function with substr NULL and capacity_bytes 0 (zero) to determine the memory needed to hold the entire substring.
Function cs_file_ast
cs_result cs_file_ast (
Get the cs_ast for a specified compilation unit.
Parameters
uid [in] The cs_uid of the compilation unit for which the cs_ast is required.
ast_family [in] The compilation unit may be associated with multiple ASTs (cs_ast) from different families. This specifies which one to get.
out_ast [out] The cs_ast of family ast_family associated with uid.
Returns A cs_result:
Time-Complexity O(1)
Function cs_file_asts_at
cs_result cs_file_asts_at (
Get the ASTs (cs_ast) at a specified location in a compilation unit.
Parameters
sfid [in] The cs_sfid for the source file instance of interest.
sfline [in] A line number in the source file specified by sfid.
interest_classes [in] A null-terminated list of the AST classes (cs_ast_class) of interest. If interest_classes is NULL, all classes will be considered to be of interest.
out_asts [out] A user-allocated buffer to be populated with the ASTs (cs_ast) that are located at line sfline of the source file specified by sfid and are of the specified interest_classes.
capacity_bytes [in] The capacity of out_asts, in bytes.
bytes_needed [out] The number of bytes needed to store all the ASTs (cs_ast) of the specified interest_classes at (sfid, sfline).
Returns A cs_result:
  • CS_SUCCESS if the entire requested list of cs_ast was copied into out_asts.
  • CS_TRUNCATED if out_asts is not large enough to hold the entire list of cs_ast (and so the list was truncated).
  • CS_NOT_IMPLEMENTED if the retrieval function is not implemented for the language module being used. (Retrieval is implemented for the C/C++ language module.)
  • CS_ELEMENT_NOT_PRESENT if uid is not present in the project, or if the information is not available for the compilation.
Notes Call this function with out_asts NULL and capacity_bytes 0 (zero) to determine the memory needed to hold the entire list.
Function cs_file_get_linecount
cs_result cs_file_get_linecount (
Get the number of lines in a source file instance.
Parameters
sfid [in] The cs_sfid specifying the source file instance from which to obtain the line count.
out_l [out] The number of lines in the source file of sfid.
Returns CS_SUCCESS on success.
Function cs_file_get_line_offset
cs_result cs_file_get_line_offset (
Get the character offset for a line within a source file instance.
Parameters
sfid [in] The cs_sfid specifying the source file instance in which the line appears.
fline [in] The line for which to obtain the character offset in sfid.
out_offset [out] The character offset, from the start of the source file instance.
Returns A cs_result:
Function cs_file_get_line_range
cs_result cs_file_get_line_range (
Get the character offsets for the beginning and the end of a line within a source file instance.
Parameters
sfid [in] The cs_sfid specifying the source file instance from which to obtain the character offset.
fline [in] The line for which to obtain the character offsets in sfid.
out_start [out] The character offset, from the start of the source file instance, of the first character of fline.
out_end [out] The character offset, from the start of the source file instance, of the last character of fline.
Returns A cs_result:
Notes Get the character offsets, from the start of the compilation unit to which sfid belongs, of the first character and the last character of fline. If fline is out of range, out_start and out_end will be the offsets of the beginning and end of the last line in the compilation unit.
Function cs_file_get_line_num
cs_result cs_file_get_line_num (
Get the cs_line associated with a point identified by an offset and a source file instance.
Parameters
sfid [in] The source file instance.
point_offset [in] The offset of the point in the source file.
out_line [out] The line number within out_sfid on which the point appears.
Returns A cs_result:
Notes Find the cs_line associated with a point identified by an offset and a source file instance.
Function cs_file_get_linecol
cs_result cs_file_get_linecol (
Get the cs_line and cs_column associated with a point identified by an offset and a source file instance.
Parameters
sfid [in] The source file instance.
point_offset [in] The offset of the point in the source file instance.
out_line [out] The line number within sfid on which the point appears.
out_column [out] The column number within line on which the point appears.
Returns A cs_result:
Function cs_file_language
cs_result cs_file_language (
Get the source language of a compilation unit.
Parameters
uid [in] The unique identifier for the compilation unit.
lang [out] A user-allocated buffer to be populated with the source language of uid.
Returns A cs_result
Notes The retrieved cs_language identifies the front end used to build the compilation unit specified by uid and the source language the compilation unit is in.
Function cs_file_group_uid
cs_result cs_file_group_uid (
Get the group to which a compilation unit belongs.
Parameters
uid [in] The unique identifier for the compilation unit.
group_uid [out] A user-allocated buffer to be populated with the Group UID corresponding to uid.
Returns A cs_result
Notes For C and C++ compilation units, group_uid will always match uid.

For Java compilation units, group_uid is the first cs_uid encountered during the cs-java-scan invocation that produced the compilation unit with uid. This may be an existing compilation unit UID for a .java file that is being reanalyzed, or a new UID produced for a .java file that does not already have a corresponding compilation unit in the project.

For C# compilation units, the situation is analogous to that for Java: group_uid is the first cs_uid encountered during the cs-dotnet-scan invocation that produced the compilation unit with uid.

For example, suppose cs-java-scan is invoked on a file J.jar containing two class files: A.class and B.class. Then:

  • Two compilation units will be produced from this invocation: one for A.class and one for B.class. We will refer to the compilation unit UIDs for these as UID_A and UID_B, respectively.
  • These two compilation units constitute a group, because they were produced by the same cs-java-scan invocation.
  • The group UID of the group is either UID_A or UID_B, depending on whether A.class and B.class was encountered first during the cs-java-scan invocation.

Additional notes:

  • Group UIDs and invocations of cs-java-scan / cs-dotnet-scan / C/C++ compiler are NOT in one-to-one correspondence in general.
  • Do not use group_uid in contexts that require a cs_uid. Depending on the sequence of events during the CodeSonar project build phase, it may no longer refer to a compilation unit that is present in the project.
  • For Java and C#, the group UID for a compilation unit can change as the project is built. In particular, if the same artifact is built into the CodeSonar project multiple times via multiple invocations of cs-java-scan or cs-dotnet-scan, the first compilation unit encountered is not necessarily the same each time.

    For example, say A.class is encountered first in an earlier invocation of cs-bin-scan on J.jar. Then the group UID for the compilation units corresponding to A.class and B.class will be UID_A. If A.class is then removed from J.jar and cs-bin-scan is invoked again, B.class will be encountered first (because it is the only class left) and so the group UID for the compilation unit corresponding to B.class is updated to UID_B.

  • For C and C++, the group UID of an existing compilation unit does not change, and will always match the compilation unit UID.
Function cs_file_webid
cs_result cs_file_webid (
[CodeSonar only] Get the value used to identify a compilation unit to the hub: this will allow you to construct a hub URL.
Parameters
uid [in] The unique identifier for the compilation unit.
webid [out] A user-allocated buffer to be populated with the identifying information.
capacity_bytes [in] The capacity of webid, measured in bytes.
bytes_needed [out] The number of bytes required to store the entire string that identifies uid to the hub.
Returns A cs_result:
Notes The hub URL for the Parse Details Log for uid can be constructed from the value written to webid as follows. Let W be the value written to webid by a successful call to this function; let host:port be the hub location. Then the URL is http://host:port/frontendrun/W.html.

Call this function with webid NULL and capacity_bytes 0 (zero) to determine the memory needed to hold the entire web ID.

Function cs_file_compiler_model
cs_result cs_file_compiler_model (
Get the name of the compiler model used to build uid.
Parameters
uid [in] The unique identifier for the compilation unit.
compiler_model [out] A user-allocated buffer to be populated with the compiler model name.
capacity_bytes [in] The capacity of compiler_model, measured in bytes.
bytes_needed [out] The number of bytes required to store the entire string representing the compiler model used to build uid.
Returns A cs_result:
Notes Call this function with compiler_model NULL and capacity_bytes 0 (zero) to determine the memory needed to hold the entire compiler model ID.
Function cs_file_native_command_line
cs_result cs_file_native_command_line (
Get the native command line used to build uid.
Parameters
uid [in] The unique identifier for the compilation unit.
outbuf [out] A user-allocated buffer to be populated with the native command line: one element for each command line token. Use cs_const_string64_value() to retrieve character strings from outbuf elements.
capacity_bytes [in] The capacity of outbuf, measured in bytes.
bytes_needed [out] The number of bytes required to store the entire native command line.
Returns A cs_result:
Notes All compilations built from a single native compiler invocation will share the same native command line.

Call this function with outbuf NULL and capacity_bytes 0 (zero) to determine the memory needed to hold the entire command line.

Function cs_file_effective_native_flags
cs_result cs_file_effective_native_flags (
Get the effective flags for the native build of uid.
Parameters
uid [in] The unique identifier for the compilation unit.
outbuf [out] A user-allocated buffer to be populated with the effective native command line flags: one element for each flag. Use cs_const_string64_value() to retrieve character strings from outbuf elements.
capacity_bytes [in] The capacity of outbuf, measured in bytes.
bytes_needed [out] The number of bytes required to store the entire list of flags.
Returns A cs_result:
Notes Retrieves the effective flags after the content of the command file (the file specified as the value of '@') is inserted; input and output file names are removed; and flags like -c, -o are dropped.

Call this function with outbuf NULL and capacity_bytes 0 (zero) to determine the memory needed to hold the entire list.

Function cs_file_frontend_command_line
cs_result cs_file_frontend_command_line (
Get the front end command line used to build uid.
Parameters
uid [in] The unique identifier for the compilation unit.
outbuf [out] A user-allocated buffer to be populated with the front end command line: one element for each command line token. Use cs_const_string64_value() to retrieve character strings from outbuf elements.
capacity_bytes [in] The capacity of outbuf, measured in bytes.
bytes_needed [out] The number of bytes required to store the entire front end command line.
Returns A cs_result:
Notes For the C/C++ front end, this includes options specified with configuration file parameters EDG_FRONTEND_OPTIONS_PREPEND and EDG_FRONTEND_OPTIONS_APPEND, and excludes CodeSurfer options.

Call this function with outbuf NULL and capacity_bytes 0 (zero) to determine the memory needed to hold the entire command line.

Function cs_file_compiler_wall_enable_flags
cs_result cs_file_compiler_wall_enable_flags (
Get the list of flags the compiler uses to enable all warnings.
Parameters
uid [in] The unique identifier for the compilation unit.
outbuf [out] A user-allocated buffer to be populated with a list of flags that enable all warnings: one element for each flag Use cs_const_string64_value() to retrieve character strings from outbuf elements.
capacity_bytes [in] The capacity of outbuf, measured in bytes.
bytes_needed [out] The number of bytes required to store the entire front end command line.
Returns A cs_result:
Notes For the C/C++ front end, this includes options specified with configuration file parameters EDG_FRONTEND_OPTIONS_PREPEND and EDG_FRONTEND_OPTIONS_APPEND, and excludes CodeSurfer options.

Call this function with outbuf NULL and capacity_bytes 0 (zero) to determine the memory needed to hold the entire command line.

Function cs_file_seen_wall_disable_flags
cs_result cs_file_seen_wall_disable_flags (
Get the list of seen command line options that disable some warnings.
Parameters
uid [in] The unique identifier for the compilation unit.
outbuf [out] A user-allocated buffer to be populated with a list of seen command line options that disable warnings: one element for each option. Use cs_const_string64_value() to retrieve character strings from outbuf elements.
capacity_bytes [in] The capacity of outbuf, measured in bytes.
bytes_needed [out] The number of bytes required to store the entire front end command line.
Returns A cs_result:
Notes For the C/C++ front end, this includes options specified with configuration file parameters EDG_FRONTEND_OPTIONS_PREPEND and EDG_FRONTEND_OPTIONS_APPEND, and excludes CodeSurfer options.

Call this function with outbuf NULL and capacity_bytes 0 (zero) to determine the memory needed to hold the entire command line.

Function cs_file_compiler_werror_enable_flags
cs_result cs_file_compiler_werror_enable_flags (
Get the list of flags the compiler uses to treat warnings as errors.
Parameters
uid [in] The unique identifier for the compilation unit.
outbuf [out] A user-allocated buffer to be populated with a list of flags that treat warnings as errors: one element for each flag Use cs_const_string64_value() to retrieve character strings from outbuf elements.
capacity_bytes [in] The capacity of outbuf, measured in bytes.
bytes_needed [out] The number of bytes required to store the entire front end command line.
Returns A cs_result:
Notes For the C/C++ front end, this includes options specified with configuration file parameters EDG_FRONTEND_OPTIONS_PREPEND and EDG_FRONTEND_OPTIONS_APPEND, and excludes CodeSurfer options.

Call this function with outbuf NULL and capacity_bytes 0 (zero) to determine the memory needed to hold the entire command line.

Function cs_file_seen_werror_disable_flags
cs_result cs_file_seen_werror_disable_flags (
Get the list of seen command line options that disable or downgrade errors.
Parameters
uid [in] The unique identifier for the compilation unit.
outbuf [out] A user-allocated buffer to be populated with a list of seen command line options that disable or downgrade errors: one element for each option. Use cs_const_string64_value() to retrieve character strings from outbuf elements.
capacity_bytes [in] The capacity of outbuf, measured in bytes.
bytes_needed [out] The number of bytes required to store the entire front end command line.
Returns A cs_result:
Notes For the C/C++ front end, this includes options specified with configuration file parameters EDG_FRONTEND_OPTIONS_PREPEND and EDG_FRONTEND_OPTIONS_APPEND, and excludes CodeSurfer options.

Call this function with outbuf NULL and capacity_bytes 0 (zero) to determine the memory needed to hold the entire command line.

Function cs_file_error_count
cs_result cs_file_error_count (
Get the number of errors encountered in compiling a compilation unit.
Parameters
uid [in] The unique identifier for the compilation unit.
num_errors [out] The aggregate number of errors for the compilation unit.
Returns A cs_result:
Function cs_file_warning_count
cs_result cs_file_warning_count (
Get the number of warnings encountered compiling the given unit.
Parameters
uid [in] The unique identifier of the compilation unit.
num_warnings [out] The aggregate number of warnings for the compilation unit.
Returns A cs_result:
Function cs_file_uid_get_sfid
cs_result cs_file_uid_get_sfid (
Get the root source file instance of a compilation unit.
Parameters
uid [in] The cs_uid of the compilation unit.
sfid [out] The cs_sfid of the file instance.
Returns A cs_result:
Notes Get the root source file instance of a compilation unit. This can be thought of as the root of the include tree for that compilation unit (for example, the .c file containing main).
Function cs_file_sfid_get_uid
cs_result cs_file_sfid_get_uid (
Get the compilation unit to which a specified file instance belongs.
Parameters
sfid [in] The cs_sfid of the file instance.
uid [out] The cs_uid of the compilation unit containing the file instance.
Returns CS_SUCCESS on success.
Function cs_sfid_is_system_include
cs_boolean cs_sfid_is_system_include (
Check: is the specified cs_sfid considered a system include according to SYSTEM_INCLUDE_PATHS?
Parameters
sfid [in] The cs_sfid of the file instance.
Returns A cs_boolean:
  • cs_true if the sfid is considered a system include.
  • cs_false otherwise.
Function cs_file_sfid_get_children
cs_result cs_file_sfid_get_children (
Get the include-tree children of a source file instance.
Parameters
sfid [in] The cs_sfid of the file instance.
child_list [inout] A user-allocated array of cs_sfid elements that will be populated with the children of sfid.
capacity_bytes [in] The user-allocated capacity of child_list.
bytes_needed [out] The number of bytes written to child_list.
Returns CS_SUCCESS on success.
Notes The children of a source file instance are the source file instances that it #includes.

Call this function with child_list NULL and capacity_bytes 0 (zero) to determine the memory needed to hold the entire list.

Function cs_file_sfid_children_iter_first
cs_result cs_file_sfid_children_iter_first (
Get the first cs_sfid from the list of #included file instances for a specified file instance and set up an iterator over the remaining children.
Parameters
sfid [in] The cs_sfid of the file instance for which to retrieve #included children.
child [out] The cs_sfid of the first #included file instance for sfid.
iter [inout] A cs_sfid_children_iter iterator opened to traverse the list of #included file instances.
Returns A cs_result:
Notes The ordering of #included children used by the iterator is not necessarily based on the ordering of #include statements in the file instance.
Function cs_file_sfid_children_iter_next
cs_result cs_file_sfid_children_iter_next (
Advance the provided include tree child iterator and retrieve the next element.
Parameters
child [out] The cs_sfid of the next #included file instance retrieved from iter.
iter [inout] The cs_sfid_children_iter iterator from which to retrieve the next child.
Returns A cs_result:
Notes The ordering of #included children used by the iterator is not necessarily based on the ordering of #include statements in the file instance.
Function cs_file_sfid_children_iter_close
cs_result cs_file_sfid_children_iter_close (
Close a cs_sfid_children_iter iterator.
Parameters
iter [inout] The cs_sfid_children_iter iterator to close.
Returns CS_SUCCESS on successful close.
Function cs_file_sfid_get_parent
cs_result cs_file_sfid_get_parent (
Get the include-tree parent of a source file instance.
Parameters
sfid [in] The source file instance for which to retrieve the parent.
arg_parent [out] The cs_sfid of the source file instance that includes sfid.
Returns CS_SUCCESS on success.
Function cs_file_sfid_get_parent_line
cs_result cs_file_sfid_get_parent_line (
Get the include location of a source file instance.
Parameters
arg_sfid [in] The source file instance for which to retrieve the location
arg_parent [out] The cs_sfid of the source file instance that includes arg_sfid.
line [out] The cs_line at which arg_sfid is included.
Returns A cs_result:
Function cs_file_sfid_get_child_at
cs_result cs_file_sfid_get_child_at (
Get the source file instance included at the given location.
Parameters
sfid [in] The source file instance the location is in.
include_line [in] The cs_line at which the sfid is included.
child [out] The cs_sfid of the source file instance included at the given location.
Returns A cs_result:
  • CS_ELEMENT_NOT_PRESENT if no file is included at the given location. For example, this will occur if sfid is a C source file and include_line does not contain a #include directive.
  • CS_SUCCESS otherwise.
Function cs_file_color_map_iter_first
cs_result cs_file_color_map_iter_first (
Get the location of the first span of the specified cs_syntax_kind from the specified source file instance.
Parameters
sfid [in] The cs_sfid of the file instance.
syn_kind [in] The desired cs_syntax_kind.
start_line [out] The cs_line on which the span begins.
start_column [out] The cs_column on start_line at which the span begins.
end_line [out] The cs_line on which the span ends.
end_column [out] The cs_column on end_line at which the span ends.
iter [inout] The cs_color_map_iter iterator opened to traverse the syn_kind blocks in file instance sfid.
Returns A cs_result:
Function cs_file_color_map_iter_scan_first
cs_result cs_file_color_map_iter_scan_first (
Get the location of the first span of the specified cs_syntax_kind at or after the specified line in the specified source file instance; set up an iterator over the remaining spans of that type.
Parameters
sfid [in] The cs_sfid of the file instance.
syn_kind [in] The desired cs_syntax_kind.
lowerbound [in] The cs_line from which to start iterating.
start_line [out] The cs_line on which the span begins.
start_column [out] The cs_column on start_line at which the span begins.
end_line [out] The cs_line on which the span ends.
end_column [out] The cs_column on end_line at which the span ends.
iter [inout] The cs_color_map_iter iterator opened to traverse the remaining syn_kind blocks in file instance sfid.
Returns A cs_result:
Function cs_file_color_map_iter_next
cs_result cs_file_color_map_iter_next (
Get the next span from a cs_color_map_iter iterator.
Parameters
start_line [out] The cs_line on which the span begins.
start_column [out] The cs_column on start_line at which the span begins.
end_line [out] The cs_line on which the span ends.
end_column [out] The cs_column on end_line at which the span ends.
iter [inout] The cs_color_map_iter iterator from which to retrieve the span.
Returns A cs_result:
Function cs_file_color_map_iter_close
cs_result cs_file_color_map_iter_close (
Close a cs_color_map_iter iterator.
Parameters
iter [inout] The cs_color_map_iter iterator to close.
Returns CS_SUCCESS on success.
Function cs_uid_pdgs_iter_first
cs_result cs_uid_pdgs_iter_first (
Get the first cs_pdg from the compilation unit whose cs_uid is uid.
Parameters
uid [in] The cs_uid of the compilation unit from which to get the first cs_pdg
pdg [out] The first cs_pdg in the compilation unit.
itr [out] The cs_uid_pdgs_iter opened to traverse the compilation unit.
Returns A cs_result:
Function cs_uid_pdgs_iter_next
cs_result cs_uid_pdgs_iter_next (
Retrieve the next cs_pdg in a compilation unit, using an iterator.
Parameters
pdg [out] The next cs_pdg retrieved from itr.
itr [inout] The cs_uid_pdgs_iter from which to obtain the next cs_pdg .
Returns A cs_result:
Function cs_uid_pdgs_iter_close
cs_result cs_uid_pdgs_iter_close (
Close a cs_uid_pdgs_iter iterator.
Parameters
itr [inout] The cs_uid_pdgs_iter to close.
Returns CS_SUCCESS on success.
Function cs_uid_nonlocals_iter_first
cs_result cs_uid_nonlocals_iter_first (
Get the first nonlocal symbol (cs_abs_loc) from the compilation unit whose cs_uid is uid, and set up an iterator to traverse the remaining nonlocal symbols.
Parameters
uid [in] The cs_uid of the compilation unit from which to get the first nonlocal cs_abs_loc.
abs_loc [out] The first nonlocal cs_abs_loc in the compilation unit.
itr [out] The cs_uid_nonlocals_iter opened to traverse the compilation unit.
Returns A cs_result:
Notes The nonlocals for a compilation unit U are:
  • the file static variables in U
  • any global variables referenced in U
  • any string literals in U

To iterate over local variables for PDGs in the compilation unit, use a cs_uid_pdgs_iter iterator (cs_uid_pdgs_iter_first(), cs_uid_pdgs_iter_next(), cs_uid_pdgs_iter_close()) and a cs_pdg_locals_iter iterator (cs_pdg_locals_iter_first(), cs_pdg_locals_iter_next(), cs_pdg_locals_iter_close()).

Note that neither a UID nonlocals iterator nor a PDG locals iterator will access symbols (cs_abs_loc) of kind cs_abs_loc_kind_param. To iterate over these, call cs_abs_loc_get_param() with increasing num argument until it returns CS_ELEMENT_NOT_PRESENT.

Function cs_uid_nonlocals_iter_next
cs_result cs_uid_nonlocals_iter_next (
Retrieve the next nonlocal cs_abs_loc in a compilation unit, using an iterator.
Parameters
abs_loc [out] The next nonlocal cs_abs_loc retrieved from itr.
itr [inout] The cs_uid_nonlocals_iter from which to obtain the next cs_abs_loc.
Returns A cs_result:
Function cs_uid_nonlocals_iter_close
cs_result cs_uid_nonlocals_iter_close (
Close a cs_uid_nonlocals_iter iterator.
Parameters
itr [inout] The cs_uid_nonlocals_iter to close.
Returns CS_SUCCESS on success.
Function cs_file_count_lines
cs_result cs_file_count_lines (
For a set of adjacent lines in a file, retrieve statistics about the classifications of the lines in the set.
Parameters
sfid [in] The cs_sfid of the file containing the lines.
start [in] The first line in the set.
end [in] The last line in the set (inclusive). Use -1 to denote the end of the file.
blank_count [out] The number of lines in the set that are blank.
comment_count [out] The number of lines in the set that contain comments only.
code_count [out] The number of lines in the set that contain code only.
mixed_count [out] The number of lines in the set that contain a combination of code and comments.
Returns CS_SUCCESS on success.
Function cs_uid_create
cs_result cs_uid_create (
Create a new compilation unit.
Parameters
file_name [in] The full path to the top-level file for the new compilation unit. The file does not need to exist.
lang [in] The cs_language of the compilation unit.
out_uid [out] The cs_uid of then newly-created compilation unit.
Returns A cs_result:
Function cs_uid_is_user_unit
cs_boolean cs_uid_is_user_unit (
Check: does the specified cs_uid correspond to a user-generated compilation unit?
Parameters
uid [in] The cs_uid to be checked.
Returns A cs_boolean:
  • cs_true if uid corresponds to a user-generated compilation unit.
  • cs_false if uid does not correspond to a user-generated compilation unit.
Notes This function will return cs_false for the following kinds of compilation units.
  • Compilation units generated in the back end.
  • Compilation units created with cs_uid_create().
  • Library models.
Function cs_uid_is_library_model_unit
cs_boolean cs_uid_is_library_model_unit (
Check: does the specified cs_uid correspond to a compilation unit for a library model shipped with CodeSonar or CodeSurfer?
Parameters
uid [in] The cs_uid to be checked.
Returns A cs_boolean:
  • cs_true if uid corresponds to a library model compilation unit.
  • cs_false if uid does not correspond to a library model compilation unit.
Function cs_uid_is_rewriting_unit
cs_boolean cs_uid_is_rewriting_unit (
Check: does the specified cs_uid correspond to a rewriting compilation unit (created via cs_uid_create())?
Parameters
uid [in] The cs_uid to be checked.
Returns A cs_boolean:
  • cs_true if uid corresponds to a rewriting compilation unit.
  • cs_false if uid does not correspond to a rewriting compilation unit.
Function cs_uid_is_backend_unit
cs_boolean cs_uid_is_backend_unit (
Check: does the specified cs_uid correspond to a compilation unit generated by the back end to hold #System_Initialization and undefined functions?
Parameters
uid [in] The cs_uid to be checked.
Returns A cs_boolean:
  • cs_true if uid corresponds to a back end compilation unit.
  • cs_false if uid does not correspond to a back end compilation unit.
Function cs_uid_is_shared_unit
cs_result cs_uid_is_shared_unit (
Check: can a compilation unit be shared by multiple projects and analyses?
Parameters
uid [in] The cs_uid of the compilation unit to be checked.
out [out] When function returns CS_SUCCESS, this is set to cs_true if uid can be shared, cs_false otherwise. If the function returns a different cs_result, out is undefined.
Returns A cs_result:
Notes Only compilation units for library models can be shared by multiple projects and analyses. This function checks whether a specific compilation unit fits into this category (it does not check whether any such sharing is currently occurring).
Function cs_uid_is_summary
cs_result cs_uid_is_summary (
Get the is_summary flag for this compilation unit.
Parameters
uid [in] The unique identifier for the compilation unit.
is_summary [out] A user-allocated buffer to be populated with a cs_boolean: cs_true if uid is a summary file created by the front end, cs_false otherwise.
Returns A cs_result
  • CS_SUCCESS if the compilation unit indicated by uid exists.
Notes If the retrieved is_summary value is cs_true, uid will not be license-charged.
Function cs_uid_is_hidden_binary
cs_result cs_uid_is_hidden_binary (
[CodeSonar for Binaries only] Checks if a compilation unit is an 'offstage binary' (that is, one that is analyzed but not included in results).
Parameters
cuid [in] The cs_uid of the compilation unit.
is_hidden [out] The cs_boolean:
  • cs_true if the compilation unit is an offstage binary.
  • cs_false if the compilation unit is not an offstage binary.
Returns A cs_result:
Function cs_uid_limit_reached
cs_result cs_uid_limit_reached (
Check: did the front end reach any limits while parsing the specified compilation unit (which may have resulted in missing IR)?
Parameters
cuid [in] The cs_uid of the compilation unit.
limit_reached [out] A user-allocated buffer. When the function returns CS_SUCCESS, this is populated with a cs_boolean (otherwise it is undefined):
  • cs_true if the front end encountered one or more limits (such as INITIALIZER_LIMIT, CONSTEXPR_CALL_DEPTH_LIMIT, AST_DEPTH_LIMIT) while processing the compilation unit identified by cuid. Part of the compilation unit internal representation (IR) may have been dropped in this case.
  • cs_false if the front end did not encounter any of these limits while processing the compilation unit
Returns A cs_result:
Function cs_sfid_sf
cs_result cs_sfid_sf (
Get the source file corresponding to a specified file instance.
Parameters
sfid [in] The cs_sfid of the file instance.
sf [out] A pointer to the cs_sf corresponding to sfid.
Returns A cs_result:
Function cs_sf_arbitrary_sfid
cs_result cs_sf_arbitrary_sfid (
Get an (arbitrary) instance of a specified source file.
Parameters
sf [in] The cs_sf of the source file.
sfid [out] A pointer to the cs_sfid of an instance of sf.
Returns A cs_result:
Function cs_sf_instance_iter_first
cs_result cs_sf_instance_iter_first (
Get the first cs_sfid from the list of instances (in the analyzed project) of the specified source file; set up an iterator over the remaining instances.
Parameters
sf [in] The cs_sf of the source file for which the instance iterator is required.
sfid [out] The cs_sfid of the first instance of sf in the list.
iter [inout] A cs_sf_instance_iter iterator opened to traverse the list of file instances.
Returns A cs_result:
Function cs_sf_instance_iter_next
cs_result cs_sf_instance_iter_next (
Get the next instance of a (previously specified) source file, using an iterator.
Parameters
sfid [out] The next cs_sfid retrieved from iter.
iter [inout] The cs_sf_instance_iter from which to obtain the next cs_sfid
Returns A cs_result:
Function cs_sf_instance_iter_close
cs_result cs_sf_instance_iter_close (
Close a cs_sf_instance_iter iterator.
Parameters
iter [inout] The cs_sf_instance_iter to close.
Returns CS_SUCCESS on success.
Function cs_sf_line_pdgs
cs_result cs_sf_line_pdgs (
Get a list of the PDGs (cs_pdg) whose definition is at the specified source file and line number.
Parameters
sf [in] The source file.
line [in] The line in sf.
exact [in] If cs_true, this function only returns PDGs that are considered to be "defined on" the given line. Otherwise, returns PDGs for which at least part of the definition appears the given line. The concept of "defined on" is not necessarily a well-defined one; when in doubt, it is better to set this to cs_false.
pdg_list [in] A user-allocated array to be populated with the PDGs (cs_pdg) found at the source file and line.
capacity_bytes [in] The capacity of pdg_list, measured in bytes.
bytes_needed [out] The actual number of bytes needed for pdg_list.
Returns A cs_result:
Time-Complexity O(nm), where n is the number of cs_sfid elements associated with the cs_sf, and m is the average number of cs_pdg elements per compilation unit associated with the cs_sfid elements.
Notes Call this function with pdg_list NULL and capacity_bytes 0 (zero) to determine the memory needed to hold the entire list.
Function cs_sfid_normalized_string
const char * cs_sfid_normalized_string (
Get the normalized absolute path name for a source file instance.
Parameters
sfid [in] The cs_sfid for the source file instance.
Returns A pointer to a buffer containing the normalized absolute path name for sfid (as a char*). The buffer is only valid until another API function is invoked.
  • Windows: this path is the downcased version of the one returned by cs_sfid_string(), with backslash directory separators replaced by forward slashes.
  • Mac: this path is the downcased version of the one output by cs_sfid_string().
  • Otherwise: this path is the same as the one output by cs_sfid_string().
Notes Do not modify or free the returned buffer.

This function entails less user overhead than cs_file_get_normalized_include_name(), and so can be more convenient to use; the tradeoff is that the returned value is not under user control and has a constrained lifetime.

Use cs_sfid_string() to get the unnormalized version of the path.

Function cs_sfid_string
const char * cs_sfid_string (
Get the unnormalized absolute path name for a source file instance.
Parameters
sfid [in] The cs_sfid for the source file instance.
Returns A pointer to a buffer containing the unnormalized absolute path name for sfid (as a char*). The buffer is only valid until another API function is invoked.
Notes Do not modify or free the returned buffer.

This function entails less user overhead than cs_file_get_include_name(), and so can be more convenient to use; the tradeoff is that the returned value is not under user control and has a constrained lifetime.

Use cs_sfid_normalized_string() to get the normalized version of the path.

Function cs_sf_get_parent
cs_result cs_sf_get_parent (
Get the parent cs_directory for a source file.
Parameters
sf [in] The cs_sf for the source file.
dir [out] The cs_directory parent of the source file.
Returns CS_SUCCESS on success.
Function cs_sf_normalized_string
const char * cs_sf_normalized_string (
Get the normalized absolute path name for a source file.
Parameters
sf [in] The cs_sf for the source file.
Returns A pointer to a buffer containing the normalized absolute path name for sf (as a char*). The buffer is only valid until another API function is invoked.
  • Windows: this path is the downcased version of the one returned by cs_sf_string(), with backslash directory separators replaced by forward slashes.
  • Mac: this path is the downcased version of the one output by cs_sf_string().
  • Otherwise: this path is the same as the one output by cs_sf_string().
Notes Do not modify or free the returned buffer.

This function entails less user overhead than calling cs_sf_arbitrary_sfid() followed by cs_file_get_normalized_include_name(), and so can be more convenient to use; the tradeoff is that the returned value is not under user control and has a constrained lifetime.

Use cs_sf_string() to get the unnormalized version of the path.

Function cs_sf_string
const char * cs_sf_string (
Get the unnormalized absolute path name for a source file.
Parameters
sf [in] The cs_sf for the source file.
Returns A pointer to a buffer containing the unnormalized absolute path name for sf (as a char*). The buffer is only valid until another API function is invoked.
Notes Do not modify or free the returned buffer.

This function entails less user overhead than calling cs_sf_arbitrary_sfid() followed by cs_file_get_include_name(), and so can be more convenient to use; the tradeoff is that the returned value is not under user control and has a constrained lifetime.

Use cs_sf_normalized_string() to get the normalized version of the path.

Function cs_sf_stable_hash
cs_hash_t cs_sf_stable_hash (
Get a hash value for a cs_sf, with stable results across sufficiently-similar analyses.
Parameters
sf [in] The cs_sf for which the hash should be obtained.
Returns A hash derived from sf.
Notes This hash value is stable in the following sense. Suppose there are two analyses A1 and A2 generated with exactly the same inputs (including identical analyzed code, underlying build commands and ordering, command line and configuration settings, increment order and contents). Let s1 be a cs_sf in A1, and s2 be the cs_sf in A2 that corresponds to s1. Then cs_sf_stable_hash(s1)==cs_sf_stable_hash(s2).

If you do not need hash values to be stable across analyses, use cs_sf_hash(): it has better performance.

Function cs_sf_stable_compare
int cs_sf_stable_compare (
Compare two cs_sf objects, with stable results across sufficiently-similar analyses.
Parameters
sf_a [in] First argument to comparison.
sf_b [in] Second argument to comparison.
Returns An integer N, such that:
  • N<0 if sf_a considered less than sf_b
  • N==0 if sf_a considered equal to sf_b
  • N>0 if sf_a considered greater than sf_b
Notes This function is provided so cs_sf objects can be stored in ordered containers that provide stable iteration order.

The comparison is stable in the following sense. Suppose there are two analyses A1 and A2 generated with exactly the same inputs (including identical analyzed code, underlying build commands and ordering, command line and configuration settings, increment order and contents). Let a1 and b1 be two cs_sf values in A1, and a2 and b2 be the cs_sf values in A2 that correspond to a1 and b1 respectively. Then cs_sf_stable_compare(a1,b1)==cs_sf_stable_compare(a2,b2).

If you do not need comparison results to be stable across different analyses, use cs_sf_compare(): it has better performance.

Function cs_sfid_stable_hash
cs_hash_t cs_sfid_stable_hash (
Get a hash value for a cs_sfid, with stable results across sufficiently-similar analyses.
Parameters
sf [in] The cs_sfid value to hash.
Returns A hash derived from sf.
Notes This hash value is stable in the following sense. Suppose there are two analyses A1 and A2 generated with exactly the same inputs (including identical analyzed code, underlying build commands and ordering, command line and configuration settings, increment order and contents). Let s1 be a cs_sfid in A1, and s2 be the cs_sfid in A2 that corresponds to s1. Then cs_sfid_stable_hash(s1)==cs_sfid_stable_hash(s2).

If you do not need hash values to be stable across analyses, use cs_sfid_hash(): it has better performance.

Function cs_sfid_stable_compare
int cs_sfid_stable_compare (
Compare two cs_sfid objects, with stable results across sufficiently-similar analyses.
Parameters
sfid_a [in] First argument to comparison.
sfid_b [in] Second argument to comparison.
Returns An integer N, such that:
  • N<0 if sfid_a considered less than sfid_b
  • N==0 if sfid_a considered equal to sfid_b
  • N>0 if sfid_a considered greater than sfid_b
Notes This function is provided so cs_sfid objects can be stored in ordered containers that provide stable iteration order.

The comparison is stable in the following sense. Suppose there are two analyses A1 and A2 generated with exactly the same inputs (including identical analyzed code, underlying build commands and ordering, command line and configuration settings, increment order and contents). Let a1 and b1 be two cs_sfid values in A1, and a2 and b2 be the cs_sfid values in A2 that correspond to a1 and b1 respectively. Then cs_sfid_stable_compare(a1,b1)==cs_sfid_stable_compare(a2,b2).

If you do not need comparison results to be stable across different analyses, use cs_sfid_compare(): it has better performance.

Function cs_uid_normalized_filename_string
const char * cs_uid_normalized_filename_string (
Get the normalized absolute path name for a compilation unit.
Parameters
uid [in] The cs_uid for the compilation unit.
Returns A pointer to a buffer containing the absolute path name for uid (as a char*). The buffer is only valid until another API function is invoked.
Notes Do not modify or free the returned buffer.

This function entails less user overhead than calling cs_file_get_normalized_name(), and so can be more convenient to use; the tradeoff is that the returned value is not under user control and has a constrained lifetime.

Use cs_uid_filename_string() to get the unnormalized version of the path.

Function cs_uid_filename_string
const char * cs_uid_filename_string (
Get the unnormalized absolute path name for a compilation unit.
Parameters
uid [in] The cs_uid for the compilation unit.
Returns A pointer to a buffer containing the unnormalized absolute path name for uid (as a char*). The buffer is only valid until another API function is invoked.
Notes Do not modify or free the returned buffer.

This function entails less user overhead than calling cs_file_get_name(), and so can be more convenient to use; the tradeoff is that the returned value is not under user control and has a constrained lifetime.

Use cs_uid_normalized_filename_string() to get the normalized version of the path.

Function cs_uid_language_string
const char * cs_uid_language_string (
Get the name of a compilation unit's language.
Parameters
uid [in] The cs_uid for the compilation unit.
Returns A pointer to a buffer containing the name of the language for uid (as a char*). The buffer is only valid until another API function is invoked.
Notes Do not modify or free the returned buffer.

This function entails less user overhead than calling cs_file_language() followed by cs_language_name(), and so can be more convenient to use; the tradeoff is that the returned value is not under user control and has a constrained lifetime.

Function cs_uid_get_handle
cs_result cs_uid_get_handle (
Get a storable handle for a compilation unit (cs_uid).
Parameters
uid [in] The cs_uid to return a handle for.
uid_handle [out] The handle of the cs_uid.
capacity_bytes [in] The size of the provided buffer.
bytes_needed [out] Buffer size needed for the handle.
Returns A cs_result:
Notes This function returns a handle to the compilation unit which is suitable for storing externally, allowing the compilation unit to be retrieved whenever needed.
Function cs_uid_lookup_handle
cs_result cs_uid_lookup_handle (
Retrieve a compilation unit (cs_uid) from a handle.
Parameters
uid_handle [in] The handle of the cs_uid.
uid [out] A cs_uid matching the handle.
Returns A cs_result:
Notes This function uses the provided handle to retrieve a compilation unit.
Function cs_sf_get_handle
cs_result cs_sf_get_handle (
Get a storable handle for a source file (cs_sf).
Parameters
sf [in] The cs_sf to return a handle for.
sf_handle [out] The handle of the cs_sf.
capacity_bytes [in] The size of the provided buffer.
bytes_needed [out] Buffer size needed for the handle.
Returns A cs_result:
Notes This function returns a handle to the source file which is suitable for storing externally, allowing the source file to be retrieved whenever needed.
Function cs_sf_lookup_handle
cs_result cs_sf_lookup_handle (
Retrieve a source file (cs_sf) from a handle.
Parameters
sf_handle [in] The handle of the cs_sf.
sf [out] A cs_sf matching the handle.
Returns A cs_result:
Notes This function uses the provided handle to retrieve a source file.
Function cs_sfid_get_handle
cs_result cs_sfid_get_handle (
Get a storable handle for a source file instance (cs_sfid).
Parameters
sfid [in] The cs_sfid to return a handle for.
sfid_handle [out] The handle of the cs_sfid.
capacity_bytes [in] The size of the provided buffer.
bytes_needed [out] Buffer size needed for the handle.
Returns A cs_result:
Notes This function returns a handle to the source file instance which is suitable for storing externally, allowing the source file instance to be retrieved whenever needed.
Function cs_sfid_lookup_handle
cs_result cs_sfid_lookup_handle (
Retrieve a source file instance (cs_sfid) from a handle.
Parameters
sfid_handle [in] The handle of the cs_sfid.
sfid [out] A cs_sfid matching the handle.
Returns A cs_result:
Notes This function uses the provided handle to retrieve a source file instance.
 

To report problems with this documentation, please visit https://support.codesecure.com/.