Static Analysis for C/C++ in CI
Compiler warnings, clang-tidy, the clang static analyzer, cppcheck and the commercial tools — what each finds, how to roll analysis onto a legacy codebase without blocking everyone, and how SARIF and diff-scoped runs make it survivable.
Overview
Complementary to sanitizers, not a substitute
Static analysis finds defects without running the program. Sanitizers see only the paths tests execute; static analysis reads every path but cannot know which are reachable in practice.
> [!IMPORTANT] That asymmetry is why both exist, and it is the first thing an interviewer wants you to articulate.
Key concepts
- Compilation database
- clang-tidy check prefixes
- .clang-tidy configuration file
- HeaderFilterRegex
- Path-sensitive vs AST-matching analysis
- Baseline and ratchet
- SARIF 2.1.0
- NOLINT and its scope
Interview questions
- You are asked to turn on clang-tidy for a two-million-line legacy C++ codebase. Walk me through the rollout.
- Which warnings do -Wall and -Wextra not give you, and which ones do people wrongly disable?
- Why -Werror in CI but not in local developer builds?
- Describe a false-positive triage workflow. What do you do with a check that is 40 percent false positives?
- clang-tidy, the clang static analyzer, cppcheck, and Coverity — what does each actually do differently?
Sign up free to read the full topic
More DevOps topics
- Sigstore & Software Supply Chain Security
- SLO / SLI / Error Budgets
- SLSA — Software Supply Chain Security
- Software Supply Chain Security
- SonarQube — Quality Gates, Web API, Administration, Errors and Mistakes
- Sources — Git, OCI, Helm, Bucket
- Storage Errors — FailedMount, Pending PVCs, Multi-Attach and Full Volumes
- Strangler Fig
- Team Topologies
- Tekton
- Terraform — Production Errors, Mistakes and Recovery
- Terraform & OpenTofu
Start free on Cariara · Coding problems · System design studio