Also minor refactoring in related functions was done.
Details
Diff Detail
- Repository
 - rC Clang
 
Event Timeline
| lib/AST/ASTImporter.cpp | ||
|---|---|---|
| 4296–4297 | I usually prefer to keep the type if it doesn't give a large space win because it hurts readability a bit. From VarDecl *, we can instantly find the type; for auto, we have to look forward. (Yes, VarTemplatePartialSpecializationDecl has to be replaced immediately :) ).  | |
| lib/AST/ASTImporter.cpp | ||
|---|---|---|
| 2858 | 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. @xazax.hun perhaps we should open source some of our fixes as well?  | |
| 4455 | 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  | |
Just ignore my previous comments, the issue with explicit instantiations could be fixed in a separate independent patch. All is good.
| lib/AST/ASTImporter.cpp | ||
|---|---|---|
| 2858 | 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?  | |
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?