r333269 - [ASTImporter] Fix ClassTemplateSpecialization in wrong DC
Gabor Marton via cfe-commits
cfe-commits at lists.llvm.org
Fri May 25 04:21:24 PDT 2018
Author: martong
Date: Fri May 25 04:21:24 2018
New Revision: 333269
URL: http://llvm.org/viewvc/llvm-project?rev=333269&view=rev
Log:
[ASTImporter] Fix ClassTemplateSpecialization in wrong DC
Summary:
ClassTemplateSpecialization is put in the wrong DeclContex if implicitly
instantiated. This patch fixes it.
Reviewers: a.sidorin, r.stahl, xazax.hun
Subscribers: rnkovacs, dkrupp, cfe-commits
Differential Revision: https://reviews.llvm.org/D47058
Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp
Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=333269&r1=333268&r2=333269&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Fri May 25 04:21:24 2018
@@ -4320,9 +4320,13 @@ Decl *ASTNodeImporter::VisitClassTemplat
D2->setTemplateSpecializationKind(D->getTemplateSpecializationKind());
- // Add the specialization to this context.
+ // Set the context of this specialization/instantiation.
D2->setLexicalDeclContext(LexicalDC);
- LexicalDC->addDeclInternal(D2);
+
+ // Add to the DC only if it was an explicit specialization/instantiation.
+ if (D2->isExplicitInstantiationOrSpecialization()) {
+ LexicalDC->addDeclInternal(D2);
+ }
}
Importer.Imported(D, D2);
if (D->isCompleteDefinition() && ImportDefinition(D, D2))
Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=333269&r1=333268&r2=333269&view=diff
==============================================================================
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Fri May 25 04:21:24 2018
@@ -1214,7 +1214,7 @@ TEST_P(ASTImporterTestBase, TUshouldNotC
TEST_P(
ASTImporterTestBase,
- DISABLED_TUshouldNotContainClassTemplateSpecializationOfImplicitInstantiation) {
+ TUshouldNotContainClassTemplateSpecializationOfImplicitInstantiation) {
Decl *From, *To;
std::tie(From, To) = getImportedDecl(
More information about the cfe-commits
mailing list