[cfe-dev] LoopConvert shadowing variables
Manuel Klimek
klimek at google.com
Mon Jun 17 00:29:40 PDT 2013
+cfe-dev
On Fri, Jun 14, 2013 at 9:48 PM, Bernal, Ariel J
<ariel.j.bernal at intel.com>wrote:
> Manuel, Douglas****
>
> ** **
>
> I’m working on a patch to prevent LoopConvert for shadowing variables
> http://llvm-reviews.chandlerc.com/D950 but I don’t feel like it’s the
> right solution. Maybe you could shed some light on this.****
>
> ** **
>
> The first loop goes over CompoundStms and we look for VarDecls that could
> match the name of the new variable until we reach the FunctionDecl then the
> next loop goes over Decls to get any VarDecl/FieldDecl/ParamVarDecl...
> defined in a parent context. ****
>
> ** **
>
> Unfortunately DeclContext::getParent doesn’t return the parent Decl when
> it comes to templates but I think it could be possible to use DeclContext
> instead of using a Decl-Decl map to reverse the AST.
>
Added some comments to the review thread. Also, for trying to simulate the
unqualified lookup, did you also try getLookupParent()?
Regarding templates, note that statement nodes are shared between the
"model" CXXRecordDecl formed by the template definition and containing lots
of dependent types and the ClassTemplateSpecializationDecl, which you
probably want. So it's important that the first declcontext you get to from
the statement where you want to insert the declaration is the one created
by the ClassTemplateSpecializationDecl.
Cheers,
/Manuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130617/b6167c5c/attachment.html>
More information about the cfe-dev
mailing list