5.2 Overview of Clang-Tidy and usage examples
Clang-Tidy is a linter and static analysis tool for C and C++ code. It is a part of the Clang and LLVM project. The tool is built on top of the Clang frontend, which means it understands your code in depth, giving it the ability to catch a wide range of issues.
Here are some key points to understand about Clang-Tidy:
Checks: Clang-Tidy contains a series of ”checks” that identify various issues or suggest enhancements. These checks range from performance improvements and potential bugs to coding style and modern C++ best practices. For instance, it might suggest using
emplace_back
instead ofpush_back
for certain cases or identify areas where you might be accidentally using integer overflow.Extensibility: New checks can be added to Clang-Tidy, making it a highly extensible tool. If you have specific coding guidelines or practices you want to enforce, you can write a check for it.
Integration: Clang-Tidy is often used within...