7
Refactoring Tools
Clang is renowned for its ability to provide suggestions for code fixes. For instance, if you miss a semicolon, Clang will suggest that you insert it. The ability to modify source code goes beyond the compilation process and is widely used in various tools for code modifications, particularly in refactoring tools. The ability to offer fixes is a powerful feature that extends the capabilities of a linter framework, such as Clang-Tidy, which not only detects issues but also provides suggestions for fixing them.
In this chapter, we will explore refactoring tools. We will begin by discussing the fundamental classes used for code modification, notably clang
::
Rewriter
. We will use Rewriter to build a custom refactoring tool that changes method names within a class. Later in the chapter, we will reimplement the tool using Clang-Tidy and delve into clang
::
FixItHint
, a component of the Clang Diagnostics subsystem that is employed by both Clang-Tidy and the Clang compiler to...