[cfe-dev] Adding support for Cloning in the AST
dgregor at apple.com
Fri May 22 17:55:49 CDT 2009
On May 19, 2009, at 7:18 PM, moataz ragab wrote:
> I am just testing the cloning by calling it recursively over the AST
> so it goes on. It should stop at the DeclRefExpr.
> Whether it might be useful or not to clone a declaration, it might
> be useful if you want to create a new variable declaration similar
> to another declaration and only change the name.
Hmmm, interesting. It seems to me like we really want to give the
expression's Clone method some information that tells it what to do
with declarations. For your loop-unrolling rewriter, we want to
replace some variable declarations with other, similar variables
(e.g., when the original variable was declared in the loop) or reuse
the same variable declaration (if the variable is declared outside the
loop). For my purposes, where I need to build a canonical expression,
we replace types with their canonical types and replace some
declarations (e.g., for non-type template parameters) with their
"canonical" declarations. This tells me that we need to think about
some kind of policy argument for Clone() that permits these changes.
More information about the cfe-dev