<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Jun 17, 2013, at 12:29 AM, Manuel Klimek <<a href="mailto:klimek@google.com">klimek@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div dir="ltr"><div>+cfe-dev</div><div><br></div>On Fri, Jun 14, 2013 at 9:48 PM, Bernal, Ariel J<span class="Apple-converted-space"> </span><span dir="ltr"><<a href="mailto:ariel.j.bernal@intel.com" target="_blank">ariel.j.bernal@intel.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div lang="EN-US" link="blue" vlink="purple"><p class="MsoNormal">Manuel, Douglas<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">I’m working on a patch to prevent LoopConvert for shadowing variables  <a href="http://llvm-reviews.chandlerc.com/D950" target="_blank">http://llvm-reviews.chandlerc.com/D950</a><span class="Apple-converted-space"> </span> but I don’t feel like it’s the right solution. Maybe you could shed some light on this.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">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.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">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.</p></div></blockquote><div><br></div><div>Added some comments to the review thread. Also, for trying to simulate the unqualified lookup, did you also try getLookupParent()?</div><div><br></div><div>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.</div></div></div></div></div></blockquote><br></div><div>Statement and expression nodes in the instantiation will only be shared between the template definition and template instantiation when there are no dependent expressions, types, or declarations anywhere in the statement/expression. A declaration in a template is always instantiated, and will have the instantiation as its DeclContext. There should be enough information in the DeclContexts to conservatively determine whether a newly-introduced variable will shadow an existing variable.</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">       </span>- Doug</div><div><br></div><br></body></html>