- IAR Embedded Workbench for Arm 10.10.x
- C-STAT® Static Analysis
- C-STAT® for static analysis
- Using C-STAT
- The C-STAT configuration file
The C-STAT configuration file
The configuration file specifies all options that C-STAT needs for the analysis, along with a set of rules to match files and checks using regular expressions and globs.
Syntax
Settings: Timeout:integerEnableFalsePositives:BooleanRunLinkAnalysis:BooleanMatchAgainstProjectPaths:BooleanMessageLimit:integerExtraOptions:stringOutputDir:pathRules: - PathMatch:regexpAdd: -glob[...] [Remove: -glob...] [...]
Syntactical elements
Timeout | See ‑‑timeout. |
| See ‑‑fpe. |
| See the description of the option Run link analysis in C-STAT Tools Options. |
| The C-STAT configuration file uses the |
| See the description of the option Limit messages in C-STAT Tools Options. |
| See 追加オプション. |
| See the description of the option Output directory in C-STAT Tools Options. |
| Specifies a regular expression pattern. All files whose path matches the pattern will be analyzed. The path delimiter is a forward slash. |
| Every glob pattern specified after a dash adds all checks whose name matches the pattern. For example, |
| Every glob pattern specified after a dash removes all checks whose name matches the pattern. The |
Example
Settings: Timeout: 600 EnableFalsePositives: true RunLinkAnalysis: true MatchAgainstProjectPaths: false MessageLimit: 100 ExtraOptions: "--parallel 4 –full" OutputDir: Debug/C-STAT Rules: - PathMatch: .* Add: - ARR* - *zero-check Remove: - "*" - PathMatch: .*Group.* Remove: - ARR*
In this example, the .* rule is first matched, then .*Group.*, where the final set of rules for a file is the superset of all rules matched to that file. The Add and Remove rules add/remove all checks that match the glob pattern: ARR* adds/removes all checks that start with ARR and *-zero-check adds all checks that end in -zero-check.
The file D:\test\main.c matches the PathMatch: .* pattern of the first rule, so—because Remove sections are processed first—all checks ("*") are removed before all checks that begin with ARR* and all checks that end in zero-check are added. The second rule is not matched, so it is not processed.
For the file D:\test\Group\file.c, both rules are matched, so the second rule removes all ARR checks added from the first rule, which leaves only checks that end in zero-check.
In other words, main.c is analyzed using the checks that begin with ARR* and end in zero-check, and file.c is analyzed using the checks that end in zero-check.
Using the configuration file with other tools
The YAML configuration file makes C-STAT easier to use together with other tools.
The C-STAT configuration file in YAML format can be used to set C-STAT options automatically when you create a new project using one of the project templates Import CMakeLists.txt or Attach to pre-configured CMake directory, see CMakeプロジェクトをIDEに追加する. When the project is created, it looks for cache variables that begin with IAR_CSTAT_CONFIG_FILE. The configuration file pointed out by IAR_CSTAT_CONFIG_FILE will be applied to all build configurations of your project, and any cache variables called IAR_CSTAT_CONFIG_FILE_buildconfig will be applied to a specific build configuration.
C-STAT can be used as a Language Server in the Embedded Workbench editor, providing continuous feedback on your code. It uses the settings from the project, either checks selected in the IDE or from a configuration file's pattern matching. See 言語サーバー(Language Servers) オプション.