[cfe-dev] Using clang as a meta-data generator.

chris nuernberger cnuernber at gmail.com
Mon Jun 21 14:16:53 PDT 2010


Hey,

I need to expose the binary layout of several c++ classes to a third
party system.  I would like to use clang to parse the header files of
these classes and output a meta data table describing the count and
types of all member variables of a given class.

I have never looked at Clang and this is a very prototype project but
it could help a lot of people when they need to write, read, and
manipulate their c++ classes.  An example usage, for instance, would
be to automatically produce boost::serialization bindings for your
classes.  Or to a c++->XML or god forbid OODB mapping without needing
to change your original classes at all.

Has anyone tried to do this before using Clang?

Is it an appropriate usage?  It seems like it would be a great test or
example usage of Clang as a pure front end.

If I should start, where should I start?  My initial plan is to get
Clang, figure out which libs I need to produce the AST in memory (not
output to a file) and figure out how to manipulate this AST to find
all the target types and output their binary layout.

Chris

-- 
A foolish consistency is the hobgoblin of little minds - Emerson



More information about the cfe-dev mailing list