Hi Sebastian,<br><br>Thanks.<br><br>Attached 3 files: the patch "clone.diff". should be applied on the clang directory.<br>                         RewriteLoopUnroll.cpp you have to put it in the clang-cc directory.<br>
                         test2.c: simple testcase for a forloop with array access in the body.<br><br><br>you can invoke the loopunroller using:<br><br> ../../../../Debug/bin/clang-cc -loop-unroll tests/test2.c<br><br>Currently it crashes because ImplicitCastExpr object doesn't get cloned. The Stmt base class gets called instead of ImplicitCastExpr<br>
<br>Best regards,<br>Moataz<br><br><div class="gmail_quote">On Sat, May 16, 2009 at 8:48 PM, Sebastian Redl <span dir="ltr"><<a href="mailto:sebastian.redl@getdesigned.at">sebastian.redl@getdesigned.at</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">moataz ragab wrote:<br>
> Hi,<br>
><br>
> I am implementing the clone method and would like to contribute the<br>
> implementation. Since this my first contribution, I would check if<br>
> anybody have technical issues to highlight.<br>
</div>Be careful. Everyone who's working on template instantiation could be<br>
implementing these as they go along. I'm about to commit cloners for<br>
various literals (FloatingLiteral, CharacterLiteral, StringLiteral,<br>
CXXBooleanLiteralExpr, CXXNullPtrExpr, GNUNullExpr, PredefinedExpr).<br>
<div class="im">><br>
> I also would like to check on some issues:<br>
> 1.  I started out by making it virtual and provided default impl. in<br>
> the base classes that just print the object class name. This is to<br>
> allow me to test my clone methods before implementing it in all the<br>
> AST classes. but finally it should be pure virtual.<br>
</div>Yes, it should.<br>
<div class="im">> 2.  Should the clone return base class pointers or derived class<br>
> pointers? For example currently, there is clone method implemented for<br>
> literals in Expr.cpp. and it returns a pointer to the specifc literal<br>
> type.<br>
</div>Always return the type you're cloning. Covariance is a wonderful thing.<br>
<div class="im">> 3. I have implemented the clone method for different Stmts and Exprs<br>
> and it seems working fine with exception of ImplicitCastExpr. Whenever<br>
> I call clone on objects of these class I get the base class (Stmt)<br>
> clone method invoked. I would appericiate if you could advise on this.<br>
><br>
</div><div class="im">> Stmt *ImplicitCastExpr::Clone(ASTContext &C) const {<br>
>   SourceLocation cpLoc;<br>
>   ImplicitCastExpr *cp= new (C) ImplicitCastExpr(getType(),<br>
> dyn_cast<Expr>(getSubExpr()->Clone(C)), isLvalueCast());<br>
>   return cp;<br>
> }<br>
</div>I see nothing wrong with this. Perhaps if you sent a patch and an<br>
example where we can try it out?<br>
<br>
One comment: in the code above, you know that the result of<br>
getSubExpr()->Clone() has to be an Expr. Use cast<> instead of<br>
dyn_cast<> there.<br>
<font color="#888888"><br>
Sebastian<br>
</font></blockquote></div><br>