[PATCH] D47058: [ASTImporter] Fix ClassTemplateSpecialization in wrong DC
Gabor Marton via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri May 18 03:58:24 PDT 2018
martong created this revision.
martong added reviewers: a.sidorin, r.stahl, xazax.hun.
Herald added subscribers: cfe-commits, dkrupp, rnkovacs.
ClassTemplateSpecialization is put in the wrong DeclContex if implicitly
instantiated. This patch fixes it.
Repository:
rC Clang
https://reviews.llvm.org/D47058
Files:
lib/AST/ASTImporter.cpp
unittests/AST/ASTImporterTest.cpp
Index: unittests/AST/ASTImporterTest.cpp
===================================================================
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -1246,7 +1246,7 @@
TEST_P(
ASTImporterTestBase,
- DISABLED_TUshouldNotContainClassTemplateSpecializationOfImplicitInstantiation) {
+ TUshouldNotContainClassTemplateSpecializationOfImplicitInstantiation) {
Decl *From, *To;
std::tie(From, To) = getImportedDecl(
Index: lib/AST/ASTImporter.cpp
===================================================================
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -4298,9 +4298,13 @@
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->getTemplateSpecializationKind() != TSK_ImplicitInstantiation) {
+ LexicalDC->addDeclInternal(D2);
+ }
}
Importer.Imported(D, D2);
if (D->isCompleteDefinition() && ImportDefinition(D, D2))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47058.147467.patch
Type: text/x-patch
Size: 1217 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180518/9317ae61/attachment-0001.bin>
More information about the cfe-commits
mailing list