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++

C/C++ Source Modifications: Patching and Replacement

Depending on your source file format and configuration file settings, C and C++ source files may undergo various modifications before they are incorporated into a CodeSonar project. This section describes the modifications and their consequences.



The source modifications described in this section are applied to source files incorporated into the CodeSonar project during the CodeSonar build phase.

The Modifications

Each time it recognizes a compiler call, CodeSonar updates the project definition to incorporate source files associated with that call. As part of the incorporation process, each source file F.x undergoes the following modifications (in order of application).

  1. For each directory D specified with a SOURCE_PATCH_DIRECTORIES rule in any of the project's configuration files, CodeSonar attempts to patch F.x with every patch file in subdirectory D/F.x/.
  2. If F.x is in UTF-16 format, it is converted to UTF-8.
  3. F.x undergoes all text replacements specified with SOURCE_REPLACE_COMMAND rules in any of the project's configuration files. If there are multiple SOURCE_REPLACE_COMMAND rules, they are applied in the same order as the rules are specified.
  4. F.x undergoes all text replacements specified with SOURCE_PATTERN_REPLACEMENT rules or SOURCE_PATTERN/SOURCE_REPLACEMENT/SOURCE_MODIFIERS triples in any of the project's configuration files. If there are multiple such rules, they are applied in the same order as the rules are specified. For the sake of order determination, the location of a SOURCE_PATTERN/SOURCE_REPLACEMENT/SOURCE_MODIFIERS triple is considered to be the location of the next SOURCE_PATTERN rule, or at the end of the file if there is no such rule.

Section Configuration Files: Configuration File Loading explains the order in which the various configuration files are processed.

Consequences

Because the CodeSonar analysis encounters only the modified versions of the project source files, analysis results will be generated and reported based on the modified versions. If your project uses source patching or replacement functionality, you may encounter one or more of the following effects.

Source Listings GUI Source Listings reflect the contents of files after modification. This means that you can see exactly what the modified source looked like, but also means that the contents of a Source Listing page may not be an exact match to the original source file.
Line Discrepancies If any of the file modifications added more lines than were removed (or vice versa) at any file location, there will be line numbering discrepancies between the original source and the modified version. Therefore, line numbers in CodeSonar results may correspond to lines that have different numbers in the original source.
Naming Discrepancies If the modifications include any identifier renaming, the new name will be used in CodeSonar analysis results. Developers that use CodeSonar results to inform changes to source code will need to be aware of any such renaming.

Further Information

Native Compilation Details Log Includes information about diagnostic output that may be generated during source replacement and source patching.
Source File Patching Detailed information about CodeSonar's source file patching functionality.
Source File Patching Example An annotated example illustrating source file patch creation and deployment.
 

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