[PATCH] Prevent LoopConvert from shadowing already defined variables with the same name as the loop variable.

Edwin Vane edwin.vane at intel.com
Mon Jun 17 06:06:03 PDT 2013



================
Comment at: cpp11-migrate/LoopConvert/VariableNaming.cpp:111
@@ +110,3 @@
+  while(DeclAncestor != NULL) {
+    if (const TemplateDecl *T = dyn_cast<TemplateDecl>(DeclAncestor)) {
+      // Check that the symbol is not a template parameter of the current
----------------
Manuel Klimek wrote:
> Edwin Vane wrote:
> > I think we could get away with just using DeclContexts directly and not making a whole DeclAncestor map. The information being stored in that map is just a replication of what's available by moving up the DeclContext chain.
> +1. Also, if you have some declaration reference in your statement at whose level you're trying to insert, you could get from that declrefexpr to the decl, and then get up the declcontext chain.
> 
> Also, I'd be interested why using getParent from ASTContext doesn't give you what you want (and you can even use that with hasAncestor to directly get to the decl you're interested in from the matcher without the need to drill through all this yourself).
I think the not using ASTContext's parent map is my fault. I suggested trying to use RevereseAST since this transform was already populating a kind of parent map. I figured why incur the cost of constructing that map a second time. But perhaps it is better to use after all?


http://llvm-reviews.chandlerc.com/D950



More information about the cfe-commits mailing list