[PATCH] D47450: [ASTImporter] Use InjectedClassNameType at import of templated record.
Gabor Marton via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 26 06:49:22 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rC335600: [ASTImporter] Use InjectedClassNameType at import of templated record. (authored by martong, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D47450?vs=152634&id=152880#toc
Repository:
rC Clang
https://reviews.llvm.org/D47450
Files:
lib/AST/ASTImporter.cpp
test/ASTMerge/injected-class-name-decl/Inputs/inject1.cpp
test/ASTMerge/injected-class-name-decl/Inputs/inject2.cpp
test/ASTMerge/injected-class-name-decl/test.cpp
Index: test/ASTMerge/injected-class-name-decl/Inputs/inject2.cpp
===================================================================
--- test/ASTMerge/injected-class-name-decl/Inputs/inject2.cpp
+++ test/ASTMerge/injected-class-name-decl/Inputs/inject2.cpp
@@ -0,0 +1,2 @@
+template <class X>
+X C<X>::x;
Index: test/ASTMerge/injected-class-name-decl/Inputs/inject1.cpp
===================================================================
--- test/ASTMerge/injected-class-name-decl/Inputs/inject1.cpp
+++ test/ASTMerge/injected-class-name-decl/Inputs/inject1.cpp
@@ -0,0 +1,2 @@
+template <class X>
+class C { static X x; };
Index: test/ASTMerge/injected-class-name-decl/test.cpp
===================================================================
--- test/ASTMerge/injected-class-name-decl/test.cpp
+++ test/ASTMerge/injected-class-name-decl/test.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -std=c++1z -emit-pch -o %t.ast %S/Inputs/inject1.cpp
+// RUN: %clang_cc1 -std=c++1z -emit-obj -o /dev/null -ast-merge %t.ast %S/Inputs/inject2.cpp
+// expected-no-diagnostics
Index: lib/AST/ASTImporter.cpp
===================================================================
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -2135,6 +2135,29 @@
if (!ToDescribed)
return nullptr;
D2CXX->setDescribedClassTemplate(ToDescribed);
+ if (!DCXX->isInjectedClassName()) {
+ // In a record describing a template the type should be an
+ // InjectedClassNameType (see Sema::CheckClassTemplate). Update the
+ // previously set type to the correct value here (ToDescribed is not
+ // available at record create).
+ // FIXME: The previous type is cleared but not removed from
+ // ASTContext's internal storage.
+ CXXRecordDecl *Injected = nullptr;
+ for (NamedDecl *Found : D2CXX->noload_lookup(Name)) {
+ auto *Record = dyn_cast<CXXRecordDecl>(Found);
+ if (Record && Record->isInjectedClassName()) {
+ Injected = Record;
+ break;
+ }
+ }
+ D2CXX->setTypeForDecl(nullptr);
+ Importer.getToContext().getInjectedClassNameType(D2CXX,
+ ToDescribed->getInjectedClassNameSpecialization());
+ if (Injected) {
+ Injected->setTypeForDecl(nullptr);
+ Importer.getToContext().getTypeDeclType(Injected, D2CXX);
+ }
+ }
} else if (MemberSpecializationInfo *MemberInfo =
DCXX->getMemberSpecializationInfo()) {
TemplateSpecializationKind SK =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47450.152880.patch
Type: text/x-patch
Size: 2602 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180626/03303332/attachment-0001.bin>
More information about the cfe-commits
mailing list