Photo of Arvid Gerstmann

Arvid Gerstmann

Arvid Gerstmann is a passionate programmer and computer enthusiast, with a focus on writing high-performance C++ systems. His area of expertise includes writing compilers, standard libraries and game engines.

Building a C++ Reflection System in One Weekend Using Clang and LLVM

Tuesday 13:30
60 minute presentation
Intermediate

Designing and building the runtime reflection system from tomorrow, today!

With the introduction of libraries like LLVM and libclang, building custom tools for C++ is more approachable than it has ever been before. With Clang we have a fantastic tool to analyze and augment the C++ AST without writing our own compiler or parser.

In this talk we'll go over the design and implementation of a compile time & runtime reflection system, demonstrating the use of Clang and the LLVM framework to craft custom C++ tools for your own needs. We'll be able to query the members of a class, inspect their types and size, as well as qualifiers and user-definable flags. To show-case a real-world usage of the solution, we'll add a way to easily serialize any class to or from a byte stream, by making use of the reflection information. The implementation is available under a permissive open-source license on Github.