llvm clang struct creating functions on the fly
- by anon
I'm using LLVM-clang on Linux.
Suppose in foo.cpp I have:
struct Foo {
int x, y;
};
How can I create a function "magic" such that:
typedef (Foo) SomeFunc(Foo a, Foo b);
SomeFunc func = magic("struct Foo { int x, y; };");
so that:
func(SomeFunc a, SomeFunc b); // returns a.x + b.y;
?
Note:
So basically, "magic" needs to take a char*, have LLVM parse it to get how C++ lays out the struct, then create a function on the fly that returns a.x + b.y;
Thanks!