Dynamically adding a new FunctionDecl to the AST

Hello,

I’m attempting to construct a new function in the course of parsing the AST. I’ve got it mostly working, except the function I’ve generated only gets emitted as a declaration in LLVM, not a definition. I’m attempting to figure out where in the template instanatiation logic the function gets added to the AST for code gen, but I haven’t been able to find it.

If I create a new function, how do I get it to be emitted in the AST consumer? I’ve copied just about all of the logic that I can from TemplateDeclInstantiator::VisitFunctionDecl (which does basically the same thing I’m doing, adds a dynamically generated FunctionDecl to the AST) without much luck.

Thanks for any advice!

Dillon