facebookexperimental / object-introspection

Object Introspection (OI) enables on-demand, hierarchical profiling of objects in arbitrary C/C++ programs with no recompilation.
Apache License 2.0
160 stars 13 forks source link

tbv2: update std::variant #489

Closed JakeHillion closed 6 months ago

JakeHillion commented 6 months ago

tbv2: update std::variant

std::variant is the last archetypal container missing in TreeBuilder-v2. The code for it isn't hugely complicated and relies on pack expansion.

This change introduces a new field to the container specification: scoped_extra. This field allows you to write extra code that will be included within the TypeHandler in CodeGen. This means it will not have collisions with other containers, unlike the existing extra field. It's used here to write the recursive getSizeType function for std::variant.

Tech debt is introduced here by comparing the container name to std::variant in CodeGen to conditionally generate some code. We've worked hard to remove references to containers in code and move them to .toml files. On balance, this is worth having to include the example of std::variant. It should be moved into a container spec field at some point, the design of which is still to be determined.

Test plan: