[LLVMdev] Cloning a FunctionDecl?

Dillon Sharlet dsharlet at gmail.com
Tue Mar 27 16:08:51 PDT 2012


Hello,

Is there a way to clone a FunctionDecl, including the body Stmt if it
exists? I want to add an entirely new decl to the AST with its own copy of
the body. I would like to start with a completely identical Decl and body,
and then modify it to produce a new overload, such that this
cloned function would appear in overload resolution for calls to the
original function.

What I want to do is somewhat similar to template instantiation, but I've
been looking through this mechanism and it *appears* that function
templates don't actually duplicate the body of the function until LLVM code
gen, is that true? I need a proper clone of the function so that mechanism
is not useful as a starting point if that is the case.

What is the most effective way to accomplish this?

Thanks
Dillon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120327/a1b94e81/attachment.html>


More information about the llvm-dev mailing list