LoopConvert shadowing variables

+cfe-dev

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.

  • Doug

I did try getLookupParent() and I get the same results as getParent(). The problem that I found by using DeclContext it that all VarDecls within the same FunctionDecl share the same DeclContext even if they belong to different CompoundStmts.

I also tried using ASTContext.getParents() which gives more information that DeclContext but I still agree with Doug that I should be able to get the information from DeclContexts.

Airel

I did try getLookupParent() and I get the same results as getParent(). The problem that I found by using DeclContext it that all VarDecls within the same FunctionDecl share the same DeclContext even if they belong to different CompoundStmts.

That’s the “conservative” part of this. You can use DeclContexts to figure out whether there are any declarations of the same name within the same FunctionDecl, but you don’t actually have enough scope information to tell whether they will actually intersect. For that, you need to walk the statements looking for the actual declaration.

  - Doug