[cfe-dev] Copying Decl instances

via cfe-dev cfe-dev at lists.llvm.org
Wed Apr 17 00:21:27 PDT 2019


Bruno, thanks!

I found that only way to clone decl is to follow ASTParser and ASTReader workflow. And this is definitely non-trivial task to do. Here is some draft snipped, but I found way not to do it though...

https://pastebin.com/MG50vQiD

Stepan Dyatkovskiy

12.04.2019, 16:47, "Bruno Ricci" <riccibrun at gmail.com>:
> On 12/04/2019 13:07, via cfe-dev wrote:
>>  Hi! Is here any legal way to clone Decl instance?
>
> As far as I know, not really. The issue here is that the cloned Decl node will not
> be present in the AST. Inserting it is not trivial since the invariants of the AST
> have to be preserved.
>
> Also note that some declaration/statement nodes have trailing objects, and therefore
> some kind of "clone" function would have to be provided. For some reason the copy/move
> ctors/operators of Decl and Stmt are not deleted, but trying to just copy them is
> going to fail badly. (fixed in D60123 for Stmt).
>
> Bruno
>
>>  Thanks!
>>  Stepan Dyatkovskiy
>>  _______________________________________________
>>  cfe-dev mailing list
>>  cfe-dev at lists.llvm.org
>>  https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



More information about the cfe-dev mailing list