diff options
author | Gabor Marton <martongabesz@gmail.com> | 2018-06-26 13:44:24 +0000 |
---|---|---|
committer | Gabor Marton <martongabesz@gmail.com> | 2018-06-26 13:44:24 +0000 |
commit | 5915777eca88a8c14c58869219aa6fe1543a70b5 (patch) | |
tree | 5175c18c841ff3b80e7fa4c8f493c9918a740c5b /clang/lib | |
parent | 04803b3ef2cf327166a65c7f8a7804a2b93e6d2f (diff) | |
download | bcm5719-llvm-5915777eca88a8c14c58869219aa6fe1543a70b5.tar.gz bcm5719-llvm-5915777eca88a8c14c58869219aa6fe1543a70b5.zip |
[ASTImporter] Use InjectedClassNameType at import of templated record.
Summary:
At import of a record describing a template set its type to
InjectedClassNameType (instead of RecordType).
Reviewers: a.sidorin, martong, r.stahl
Reviewed By: a.sidorin, martong, r.stahl
Subscribers: a_sidorin, rnkovacs, martong, cfe-commits
Differential Revision: https://reviews.llvm.org/D47450
Patch by Balazs Keri!
llvm-svn: 335600
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/ASTImporter.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index f812244ed3c..6f14ab02ea8 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -2135,6 +2135,29 @@ Decl *ASTNodeImporter::VisitRecordDecl(RecordDecl *D) { 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 = |