[PATCH] D43012: [ASTImporter] Fix lexical DC for templated decls; support VarTemplatePartialSpecDecl
Gabor Marton via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 10 09:12:22 PST 2018
martong added inline comments.
================
Comment at: lib/AST/ASTImporter.cpp:2858
+
+ // Templated declarations should never appear in the enclosing DeclContext.
+ if (!D->getDescribedVarTemplate())
----------------
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?
================
Comment at: lib/AST/ASTImporter.cpp:4455
D2->setLexicalDeclContext(LexicalDC);
LexicalDC->addDeclInternal(D2);
+
----------------
This is related to my other comment, perhaps we should not add `D2` to the DeclContext unconditionnally. I think only implicit instantiations should be added. See
https://github.com/Ericsson/clang/pull/270/files
Repository:
rC Clang
https://reviews.llvm.org/D43012
More information about the cfe-commits
mailing list