[cfe-dev] How to define class on the fly from LLVM

Yifei Zheng via cfe-dev cfe-dev at lists.llvm.org
Tue Jul 18 19:48:12 PDT 2017


Hi there,

*This is "dev"'s list, shall I post here?*

I have a code generator project which generates C++ code. But it is 
somewhat cumbersome, and thus I want to port it to LLVM, i.e. write a 
compiler directly instead of code generator.

The thing is it uses some STL containers in C++, not to mention the 
supporting code. Rewriting it into LLVM is simply impractical. There are 
generated `struct` from the DSL and it is this type passed as template 
parameter to many containers.

So I'm planning to make use of clang for this part of code, while port 
the core part to LLVM IR. The problem is that the `struct` is defined in 
LLVM side now since the DSL syntax differs from C++. But to instantiate 
templates, I sure have to notify clang of that. My question is hence, 
how can I define a class on the fly with clang? Which clang framework 
shall I use?

Thanks,

Yifei



More information about the cfe-dev mailing list