Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Clang Compiler Frontend

You're reading from  Clang Compiler Frontend

Product type Book
Published in Mar 2024
Publisher Packt
ISBN-13 9781837630981
Pages 326 pages
Edition 1st Edition
Languages
Author (1):
Ivan Murashko Ivan Murashko
Profile icon Ivan Murashko

Table of Contents (17) Chapters

Preface 1. Part I: Clang Setup and Architecture
2. Chapter 1: Environment Setup 3. Chapter 2: Clang Architecture 4. Chapter 3: Clang AST 5. Chapter 4: Basic Libraries and Tools 6. Part II: Clang Tools
7. Chapter 5: Clang-Tidy Linter Framework 8. Chapter 6: Advanced Code Analysis 9. Chapter 7: Refactoring Tools 10. Chapter 8: IDE Support and Clangd 11. Part III: Appendix
12. Bibliography
13. Index 14. Other Books You Might Enjoy Appendix 1: Compilation Database 1. Appendix 2: Build Speed Optimization

7.4 Code modification and Clang-Format

Clang-Format is an essential tool in the Clang/LLVM project, designed for formatting C, C++, Java, JavaScript, Objective-C, or Protobuf code. It plays a crucial role in the Clang tooling ecosystem, offering capabilities for parsing, analyzing, and manipulating source code.

Clang-Format is a part of Clang and has to be installed if we have built and installed the Clang compiler. Let’s look at how it can be used.

7.4.1 Clang-Format configuration and usage examples

Clang-Format uses .clang-format configuration files. The utility will use the closest configuration file; i.e., if the file is located at the folder with the source files we want to format, then the configuration from the folder will be used. The format for configuration files is YAML, which is the same format used for Clang-Tidy configuration files, as shown in Figure 5.12, Clang-Tidy configuration. Let’s create the following simple configuration file:

BasedOnStyle...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}