[PATCH] D23096: [Sema] Pass CombineWithOuterScope = true to constructor of LocalInstantiationScope

Serge Pavlov via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 5 11:29:39 PDT 2016


sepavloff added a comment.

IIUC, the problem is observed because `Sema::getTemplateInstantiationArgs` does not handle the case of variable templates properly. Classes and functions are declaration contexts and implementation of the aforementioned function (and probably others) relies on this fact. Variable does not represents a context, and this causes errors like this. We cannot make `VarTemplateSpecializationDecl` a subclass of `DeclContext` because the latter not only serves as a host for other declarations but also supports name lookup. None is pertinent to the case of variable specialization.

I think, logic of `getTemplateInstantiationArgs` should be changed. The new implementation could inspect current instantiation (`Sema::ActiveTemplateInstantiations`) to check if it is an instantiation of a variable template. This could eliminate need of `VarTemplateSpec` and `VarTemplateSpecializationRAII`. Such solution looks more flexible as variable initializer may contain references to other variable instantiations, so single value of `VarTemplateSpec` is not sufficient to track instantiations.


https://reviews.llvm.org/D23096





More information about the cfe-commits mailing list