Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Clang Compiler Frontend
  • Table Of Contents Toc
Clang Compiler Frontend

Clang Compiler Frontend

By : Ivan Murashko
5 (1)
close
close
Clang Compiler Frontend

Clang Compiler Frontend

5 (1)
By: Ivan Murashko

Overview of this book

Discover the power of Clang, a versatile compiler known for its compilation speed and insightful error and warning messages. This book will get you acquainted with the capabilities of Clang, helping you harness its features for performance improvements and modularity by creating custom compiler tools. While focused on Clang compiler frontend, this book also covers other parts of LLVM, essential to understanding Clang's functionality, to keep up with the constantly evolving LLVM project. Starting with LLVM fundamentals, from installation procedures to development tools, this book walks you through Clang's internal architecture and its integral role within LLVM. As you progress, you’ll also tackle optimizing compilation performance through features such as C++ modules and header maps. The later chapters cover tools developed using the Clang/LLVM, including clang-tidy for linting, refactoring tools, and IDE support, and feature many examples to illustrate the material. By the end of this book, you’ll have a solid understanding of Clang, different Clang Tools, and how to use them to their fullest potential.
Table of Contents (17 chapters)
close
close
Lock Free Chapter
1
Part I: Clang Setup and Architecture
6
Part II: Clang Tools
11
Part III: Appendix
12
Bibliography

7.2 Custom code modification tool

We will create a Clang tool that will help us to rename methods for a class that is used for unit testing. We will start with a description for the clang::Rewriter class – the basic class that is used for code modifications.

7.2.1 Code modification support at Clang

clang::Rewriter is a Clang library class that facilitates source code rewriting operations within a translation unit. It provides methods for inserting, removing, and replacing code within theAbstract Syntax Tree (AST) of the source code. Developers can use clang::Rewriter for complex code modifications, such as restructuring or generating new code constructs. It can be applied for both code generation and code refactoring tasks, making it versatile for various code transformation purposes.

The class has several methods for text insertion; for instance, clang::Rewriter ::InsertText inserts the text at the specified source location, and clang ::SourceLocation is used to specify the...

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Clang Compiler Frontend
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon