This is an archive of the discontinued LLVM Phabricator instance.

[ASTImporter] Fix ClassTemplateSpecialization in wrong DC
ClosedPublic

Authored by martong on May 18 2018, 3:58 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

martong created this revision.May 18 2018, 3:58 AM
a.sidorin accepted this revision.May 18 2018, 9:21 AM

Hi Gabor! I have a question.

lib/AST/ASTImporter.cpp
4305 ↗(On Diff #147467)

Can we write if (D2->isExplicitInstantiationOrSpecialization()) instead? How we should treat TSK_Undeclared case?

This revision is now accepted and ready to land.May 18 2018, 9:21 AM
a.sidorin requested changes to this revision.May 18 2018, 9:22 AM

(Sorry, accepted accidentially).

This revision now requires changes to proceed.May 18 2018, 9:22 AM
martong updated this revision to Diff 147966.May 22 2018, 2:10 AM
martong marked an inline comment as done.

Use isExplicitInstantiationOrSpecialization

martong added inline comments.May 22 2018, 2:12 AM
lib/AST/ASTImporter.cpp
4305 ↗(On Diff #147467)

Yes, this is a good catch! Changed it.

Hi Gabor,
Could you add a test for TSK_Undeclared as well?

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.

a.sidorin accepted this revision.May 24 2018, 10:43 AM

Ok, I got it, thank you!

This revision is now accepted and ready to land.May 24 2018, 10:43 AM
This revision was automatically updated to reflect the committed changes.