The difficulty of parsing C++ has presented a high barrier to entry for developers wanting to write tools that process C++ code. The Clang libraries such as libclang and libtooling provide access to standalone tools, the syntactic and semantic information available to a C++ compiler. While these libraries make writing your own tool possible, there are still many details to be worked out, this presentation will run through the process of building simple standalone tools with libtooling. We will cover:

  • The compilation database.
  • Building the Clang libraries and integrating them with your tool.
  • Navigating the Clang abstract syntax tree.
  • Adding an error message to clang via a plugin.
  • Making edits to the C++ source code.

The intended audience is C/C++ developers wanting to build their own tools that more structural information about C++ than regular expressions can provide.