[cfe-dev] Hacking Clang to generate mock objects

Dave Elcock dave.elcock at gmail.com
Thu Sep 1 15:36:23 PDT 2011


Hello.

I've recently discovered Clang and I've come up with the hair-brained
idea of playing/hacking with it to achieve something akin to
HippoMocks (http://www.hippomocks.com/wiki/), essentially using an
abstract class as a template, and generating stubs and implementations
for pure virtual methods on-the-fly.

I'm imagining writing some sort of extension that could modify vtables
etc, but be inserted into Clang with a command line switch a la LLVM's
transformation passes. I reckon I need to do that before it gets as
far as LLVM itself, just so there is richer type information still
around.

Before I go wasting any more time, is this just plain bonkers? Is it
going to be possible as an external modification, or am I going to be
stuck with a hacked clang executable/libs?

If I'm in with a chance, where would I start looking for documentation
about how Clang builds up vtables etc, and how it's all stitched
together? Is doxygen the best source of that sort of information, or
have I missed some key architecture docs?

Cheers for any help,
Dave.



More information about the cfe-dev mailing list