Make replacements in preprocessor directives
-regex-replace-rgx matchFileName -regex-replace-fmt replacementFileName
-regex-replace-rgx
replaces tokens in preprocessor directives for the purposes of Polyspace® analysis. The original source code is unchanged. You match a token using a
regular expression in the file matchFileName -regex-replace-fmt replacementFileName and
replace the token using a replacement in the file
matchFileNamereplacementFileName.
Use this option only to replace or remove tokens in the preprocessor directives
before preprocessing. If a token in your source code causes a
compilation error, you can typically replace or remove the token from the preprocessed code.
Use the more convenient option Command/script to apply to preprocessed files
(-post-preprocessing-command). You cannot make the replacements in
preprocessed code only for tokens in preprocessor directives.
If you are running an analysis from the user interface
(Polyspace desktop products only), on the Configuration pane, you can
enter this option in the Other field. See Other.
In the user interface, specify absolute paths to the text files with the search and replace patterns.
Suppose you want to replace &_rom_beg in this
#define
directive:
#define ROM_BEG_ADDR (uint16_t)(&_rom_beg)
#define ROM_BEG_ADDR (0x4000u)
Specify this regular expression in a file
match.txt:
^#define\s+ROM_BEG_ADDR\s+\(uint16_t\)\(\&_rom_beg\)
^ asserts position at the start of a line.
\s+ represents one or more whitespace characters.
The characters *, &, ( and ) in the
original expression are escaped with \. For a complete list of regular
expressions, see Perl documentation.
Specify the replacement in a file replace.txt.
#define ROM_BEG_ADDR \(0x4000u\)
Specify the two text files during analysis with the options
-regex-replace-rgx and
-regex-replace-fmt:
Bug Finder:
polyspace-bug-finder -sources filename -regex-replace-rgx match.txt -regex-replace-fmt replace.txt
Code Prover:
polyspace-code-prover -sources filename -regex-replace-rgx match.txt -regex-replace-fmt replace.txt
Bug Finder Server:
polyspace-bug-finder-server -sources filename -regex-replace-rgx match.txt -regex-replace-fmt replace.txt
Code Prover Server:
polyspace-code-prover-server -sources filename -regex-replace-rgx match.txt -regex-replace-fmt replace.txt
If you use Polyspace as You Code extensions in IDEs, enter this option in an analysis options file. See options file.