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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.