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

Chapter 10. Clang Tools with LibTooling

In this chapter, we will see how many tools use the Clang frontend as a library to manipulate C/C++ programs for different purposes. In particular, all of them rely on LibTooling, a Clang library that allows standalone tools to be written. In this case, instead of writing a plugin to fit into the Clang compilation pipeline, you design your very own tool that uses Clang parsing abilities, allowing your users to directly call your tool. The tools presented in this chapter are available in the Clang Extra Tools package; refer to Chapter 2, External Projects, for information on how to install them. We will finish this chapter with a working example of how to create your own code-refactoring tool. We will cover the following topics:

  • Generating a compile command database

  • Understanding and using several Clang tools that rely on LibTooling, such as Clang Tidy, Clang Modernizer, Clang Apply Replacements, ClangFormat, Modularize, PPTrace, and Clang Query

  • Building...