Brussels / 3 & 4 February 2024

schedule

Build your first Clang compilation database plugin


The compilation database aids tools such as clangd in selecting the correct compiler flags for source files. It is commonly located found as compilation_database.json in the build directory. With tools like compdb, you can modify the file according to your needs. clangd itself provides a flexible configuration file. But what if you require more flexibility or have specific needs for your code base?

In this introductory presentation I give a brief overview of how Clang utilizes the compilation database and discuss the reasons and methods for extending it. Clang's CompilationDatabasePlugin allows extending and modifying compilation commands directly in your tooling at runtime. I show an example plugin that uses custom heuristics to find compiler flags for unknown files, e.g. for header files.

Plugins can interface with other Clang and LLVM components and writing one is a great way to get started writing Clang-based tooling.

Speakers

Photo of Pascal Jungblut Pascal Jungblut

Links