C/C++test Standard can be integrated with JetBrains CLion, enabling users to run static analysis directly from the IDE. The integration is configured by adding C/C++test as an external tool in CLion.
Prerequisites:
<INSTALL_DIR>). The cpptest directory, which contains all C/C++test files, will be created. C/C++test: Analyze Project<INSTALL_DIR>/cpptestcliArguments: -compiler <COMPILER_CONFIGURATION> -config <TEST_CONFIGURATION> -report <REPORT_DIR_NAME> -property report.format=sarif -input $CMakeCurrentBuildDir$/compile_commands.json
$ProjectFileDir$
C/C++test: Analyze Selected File<INSTALL_DIR>/cpptestcli-compiler <COMPILER_CONFIGURATION> -config <TEST_CONFIGURATION> -report <REPORT_DIR_NAME> -property report.format=sarif -input $CMakeCurrentBuildDir$/compile_commands.json -resource $FilePath$$ProjectFileDir$
The following CLion macros are used in the external tool configurations:
$CMakeCurrentBuildDir$ — resolves to the current CMake build directory.$FilePath$ — resolves to the path of the file currently selected in CLion.$ProjectFileDir$ — resolves to the project directory.Refer to the CLion documentation for more information about IDE macros and external tool configuration.
The C/C++test-specific parameters are:
<COMPILER_CONFIGURATION> — the C/C++test compiler configuration. For more information, see Running Static Analysis.<TEST_CONFIGURATION> — the C/C++test test configuration. For more information, see Configuring Test Configurations.<REPORT_DIR_NAME> — the directory where analysis reports will be generated.After static analysis is executed, C/C++test generates a SARIF report file in the specified report directory.
To view the results in CLion, double-click the SARIF report file. CLion opens the file in the SARIF Viewer, where you can inspect the reported static analysis findings.
Refer to the CLion documentation for more information about the SARIF Viewer.