[PATCH] D43012: [ASTImporter] Fix lexical DC for templated decls; support VarTemplatePartialSpecDecl

Aleksei Sidorin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 12 01:28:11 PST 2018


a.sidorin added inline comments.


================
Comment at: lib/AST/ASTImporter.cpp:2858
+
+  // Templated declarations should never appear in the enclosing DeclContext.
+  if (!D->getDescribedVarTemplate())
----------------
martong wrote:
> In case of class templates, the explicit instantiation is the member of the DeclContext. It does not belong to the DeclContext only in case of implicit instantiations.
> I suppose the same is true for template variables as well.
> In our code base we fixed it by checking on the TSK_ kind, see https://github.com/Ericsson/clang/pull/270/files.
> 
> @xazax.hun perhaps we should open source some of our fixes as well?
This code handles templated declarations, not template instantiations. Every TemplateDecl has an underlying templated declaration that is used while instantiating the template; it is not the same as template specialization. And it is not visible from the DeclContext it refers to via lookup. Or am I misunderstanding something?
Yes, the issue with implicit instantiations still persists but it is not the target for this patch. I have took a look at the patch; it looks like it fixes a separate issue (and I welcome you to post the patch here!).


Repository:
  rC Clang

https://reviews.llvm.org/D43012





More information about the cfe-commits mailing list