Start FreeLog in
SonarCloud | Advanced setup | Languages | C/C++/Objective C | Analysis modes

CFamily Analysis modes

On this page

The analysis can operate in Automatic Analysis or Manual configuration (Compilation Database) modes. 

  • Automatic Analysis automatically analyzes your code simply by reading it from your GitHub repository, without the need to configure a CI-based analysis.
  • Compilation Database mode gives you more control over the configuration and requires a CI-based analysis configuration.  You can activate this mode by deactivating Automatic Analysis and supplying a compile_commands.json to the SonarScanner.

The analyzer must understand the code's intended compilation options to ensure an accurate static analysis of the CFamily code. 

  • In Compilation Database mode, these options are provided to the analyzer through Compilation Database: a JSON file introduced by the LLVM project.
  • In Automatic Analysis mode, the analyzer attempts to deduce these options automatically. A set of high-level Automatic Analysis properties can tune the automatic deduction process. For details, see the "Automatic Analysis specific properties" section in Customizing the analysis.

Choosing the right analysis mode

Compilation Database mode is recommended if:

  • Your projects aren’t hosted on GitHub. Automatic Analysis is only available for GitHub repositories.
  • You’re seeking the highest CFamily analysis quality SonarCloud can provide. Please note that in rare instances, Automatic Analysis may result in some issues being overlooked.
  • You want to have finer control over the analysis configuration, such as analyzing a specific build variant. 
  • You require faster analysis. In Compilation Database mode, you can control the hardware capacity on the CI where the analysis runs.
  • Your projects have Objective-C code: Objective-C analysis is not supported in Automatic Analysis mode.
  • Your projects use or plan to use C++20 modules (see C++20 Modules in Customizing the analysis).

Automatic Analysis mode is recommended if:

  • Your projects use compilers that don’t meet the supported compiler prerequisite of Compilation Database mode (see Prerequisites).
  • Your projects use compilation environments where generating a compilation database is not feasible (see Prerequisites).
  • You desire a swift analysis setup without the need to allocate human resources for the maintenance of a CI pipeline and the generation of a Compilation Database.
  • Your projects have a low CFamily code percentage.

Was this page helpful?

© 2008-2024 SonarSource SA. All rights reserved. SONAR, SONARSOURCE, SONARQUBE, and CLEAN AS YOU CODE are trademarks of SonarSource SA.

Creative Commons License