ClassTemplateSpecialization is put in the wrong DeclContex if implicitly
instantiated. This patch fixes it.
Details
Diff Detail
- Repository
- rC Clang
- Build Status
Buildable 18315 Build 18315: arc lint + arc unit
Event Timeline
Hi Gabor! I have a question.
lib/AST/ASTImporter.cpp | ||
---|---|---|
4305 | Can we write if (D2->isExplicitInstantiationOrSpecialization()) instead? How we should treat TSK_Undeclared case? |
lib/AST/ASTImporter.cpp | ||
---|---|---|
4305 | Yes, this is a good catch! Changed it. |
Could you add a test for TSK_Undeclared as well?
TLDR: No, I cannot.
TSK_Undeclared is used to indicate that a template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
Consequently, ClassTemplateSpecializationDecl::ClassTemplateSpecializationDecl and VarTemplateSpecializationDecl::VarTemplateSpecializationDecl initializes its member SpecializationKind to the value TSK_Undeclared.
SpecializationKind is getting set during parsing to a meaningful kind, it is never left as TSK_Undeclared.
So, the only way I could write a test is to manually change the SpecializationKind in the "From" context, but I consider that as not a meaningful test, since we cannot create such Decl by the parser.
Can we write if (D2->isExplicitInstantiationOrSpecialization()) instead? How we should treat TSK_Undeclared case?