Putting it together

In this example, we will take the opportunity to introduce you to the Clang C++ interface and will not rely on the libclang C interface anymore. We will create a program that will apply the lexer, the parser, and the semantic analysis to input files by using the internal Clang C++ classes; thus, we will have the opportunity to do the work of a simple FrontendAction object. You can continue using the Makefile that we presented at the beginning of this chapter. However, you may be interested in turning off the -Wall -Wextra compiler flags because it will generate a large volume of warnings for Clang headers regarding unused parameters.

The source code for this example is reproduced as follows:

#include "llvm/ADT/IntrusiveRefCntPtr.h" ...

Get Getting Started with LLVM Core Libraries now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.