Quality and Debugging
Quality and Debugging
Static analysis, formatting, sanitizers, and include-management tools for catching C++ problems earlier.
Quality and Debugging
- clang-tidy: static analysis and automated modernize, readability, and bug-prone checks.
- clang-format: automatic code formatting for consistent style.
- Include What You Use: helps reduce unnecessary includes and clarify header dependencies.
Sanitizers
Practical guidance
- Run clang-tidy early to catch API misuse, modernization gaps, and readability problems before code review.
- Run AddressSanitizer by default in debug or CI builds for native code that touches memory heavily.
- Add ThreadSanitizer when you introduce concurrency rather than after race conditions become intermittent production bugs.
When to use this page
- setting up a local or CI quality loop for a native C++ project
- deciding which diagnostics tool should run first
- debugging memory corruption, undefined behavior, or data races
Suggested workflow order
- Run clang-format to remove style noise before inspection.
- Run clang-tidy to catch structural and API-level issues.
- Run AddressSanitizer for memory-heavy code paths.
- Add UndefinedBehaviorSanitizer when logic bugs may involve invalid operations.
- Add ThreadSanitizer for concurrent code or suspected races.
The point is to move from cheap broad feedback toward heavier runtime diagnostics only when they are relevant.