Technical requirements
This chapter expects you to have a build of the Clang executable. You can obtain this by running the following command:
$ ninja clang
Here is a useful command to print textual content right after preprocessing:
The -E
command-line option for clang
is pretty useful for printing textual content right after preprocessing. As an example, foo.c
has the following content:
#define HELLO 4 int foo(int x) { Â Â return x + HELLO; }
Use the following command:
$ clang -E foo.c
The preceding command will give you this output:
… int foo(int x) {   return x + 4; }
As you can see, HELLO
was replaced by 4
in the code. You might be able to use this trick to debug when developing custom extensions in later sections.
Code used in this chapter can be found at this link: https://github.com/PacktPublishing/LLVM-Techniques-Tips-and-Best-Practices-Clang-and-Middle-End-Libraries/tree/main/Chapter06.