[cfe-dev] [LLVMdev] Cloning a FunctionDecl?

Dillon Sharlet dsharlet at gmail.com
Wed Mar 28 10:44:36 PDT 2012


Eli, thanks for your answer. Sorry about the mailing list mixup!

Not to sound lazy, but I'm trying to figure out how to use TreeTransform to
do what I want and it is not clear to me. Basically, here is what I'm
trying to do:

- I want to clone a FunctionDecl to a new function that is a complete copy
of the original function.
- Then, I want to apply different attributes to the arguments. I've already
enabled overloading of functions with my attribute on the arguments, so
there shouldn't be an issue there.
- After the arguments are modified, I want to run the parser on the copied
FunctionDecl (just like it would be on an instantiated template)

I'm looking at the template instantiation code, and it is a very large
class that looks like it handles all of the syntax elements that might be
found in a template. I'm trying to avoid this as it really shouldn't be
necessary and it creates a code maintenance issue. Is there some way I can
re-use the template instantiation code to do what I'm trying to do above?


On Tue, Mar 27, 2012 at 5:44 PM, Eli Friedman <eli.friedman at gmail.com>wrote:
>
> There is code inside Sema to do something like this as part of
> template instantiation; see TreeTransform.h . It isn't exposed outside
> of Sema, though,
>
> No, the instantiated function exists independently in the AST.
>
> cfe-dev would be a better list for followup questions.
>
> -Eli
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120328/c75723a4/attachment.html>


More information about the cfe-dev mailing list