A GCC-based checker for compliance with MISRA-C's single-translation-unit rules
Published in Connection Science, 2023
Chih-Yuan Chen, Yung-An Fang, Guan-Ren Wang, Peng-Sheng Chen
Several static analysis tools can detect whether a program is compliant with the MISRA-C rules. These tools are either commercial or open source. Examples of commercial software include Parasoft (Parasoft, n.d.), PC-Lint (Vector Informatik, n.d.), Helix QAC (Perforce Software, n.d.), PVS-Studio (PVS-Studio, n.d.), IAR C-STAT (IAR Systems, n.d.), Coverity (Synopsys, n.d.a), CodeSonar (GrammaTech, n.d.), and Polyspace (MathWorks, n.d.). The most well-known and widely used open-source tool is Cppcheck (Cppcheck, n.d.), which can detect software bugs, undefined behavior, dangerous coding constructs, and coding style. In Cppcheck, a program is preprocessed to an internal token list. Each token can access the related syntax tree and symbol information via proper APIs. The checker analyzes the token list according to pre-defined rules. Cppcheck also contains a value-flow analysis and simple control-flow analysis to improve the correctness of the analysis. Users can easily customise checking rules to meet their needs. All these tools are third-party software independent of the compiler.