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

Edwin Vane edwin.vane at intel.com
Fri Jun 14 11:43:57 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
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.

Comment at: cpp11-migrate/LoopConvert/VariableNaming.cpp:89
@@ +88,3 @@
+  const Stmt *StmtAncestor = ReverseAST->lookup(StmtChild);
+  while (StmtAncestor != NULL) {
+    for (Stmt::const_child_iterator I = StmtAncestor->child_begin(),
It seems like there must be a better solution using DeclContexts to handle this problem of CompoundStmts adding extra scopes.


More information about the cfe-commits mailing list