Book Image

Getting started with LLVM core libraries

Book Image

Getting started with LLVM core libraries

Overview of this book

Table of Contents (17 chapters)
Getting Started with LLVM Core Libraries
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

The clang-tidy tool


In this section, we will present clang-tidy as an example of a LibTooling tool and explain how to use it. All other Clang tools will have a similar look and feel, thereby allowing you to comfortably explore them.

The clang-tidy tool is a linter, based on Clang. In general, a linter is a tool that analyzes code and denounces parts that do not follow best practices. It can check for specific characteristics, such as the following:

  • Whether the code will be portable across different compilers

  • If the code follows a specific idiom or code convention

  • If the code may lead to a bug due to abuse of a dangerous language feature

In the specific case of clang-tidy, the tool is able to run two types of checkers: those from the original Clang Static Analyzer and those specially written for clang-tidy. Despite being able to run static analyzer checks, notice that clang-tidy and other LibTooling-based tools are based on source code analysis, and that this is quite different from the elaborated...