[cfe-dev] Modifying struct layout
Cristiano Giuffrida
c.giuffrida at vu.nl
Tue Jan 17 14:31:28 PST 2012
Hi,
I'm interested in programmatically modifying the layout of arbitrary
(non-packed) structs in C programs using a source-to-source
transformation. In particular, I would like to: (1) reorder the
members of a struct basing on a predetermined criteria; (2) add
predefined padding (or dummy members of a predefined size) at the
beginning of the struct and between consecutive struct members.
LLVM types are immutable and I don't think the transformation can be
implemented as an LLVM pass. I'm considering using clang (ideally a
clang plugin) for the job, but I'm not sure this is possible/easy to
do.
Is there any way to achieve (1) and/or (2) with clang? For example,
changing an existing type declaration
(clang::TypeDecl::setTypeForDecl()) with a newly-created type or
modifying ASTRecordLayout directly?
Thanks,
Cristiano
More information about the cfe-dev
mailing list