~/talk

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

Talkat CppCon 2018 · 2018-09-23..09-28· [compilers-and-language-design, c-and-cpp]
slides:none on file

Builds a runtime C++ reflection system over a weekend using Clang LibTooling and LLVM that parses ASTs, matches classes/fields annotated with an attribute, and generates C++ source (a .generated.h) to include in the program. Handles primitives plus special-case implementations for std::string and std::vector, emits offsets and type hashes for safe JSON (de)serialization, and can invoke reflected functions with trampoline tricks. AST dumps hit ~106k lines with >2k records and ~1k fields; implementation is working and published as metareflect on GitHub.

AI-written summary · about

  1. 0:00Introduction to reflection
  2. 1:47Problems with manual serialization
  3. 3:56C# reflection capabilities
  4. 6:49Translating to C++ reflection
  5. 9:04Designing the reflection API
  6. 12:42Handling primitive types
  7. 14:54Type dispatch for templates
  8. 16:18Automating reflection with LLVM
  9. 21:14Annotating classes for reflection
  10. 24:50Generating reflection code
  11. 29:28Demo of generated reflection
  12. 33:12Future improvements and optimizations
  13. 35:20Implementation details
  14. 38:39Q&A session
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.