From 28d16d79e464063c09aa63c87afe10c25cb66c7c Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Sat, 19 Jun 2010 19:29:21 +0000 Subject: Include a hack to allow loading of templated CXXRecordDecls and test template reading from PCH. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106393 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Frontend/PCHWriterDecl.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib/Frontend/PCHWriterDecl.cpp') diff --git a/lib/Frontend/PCHWriterDecl.cpp b/lib/Frontend/PCHWriterDecl.cpp index 0671710882..a704d6762d 100644 --- a/lib/Frontend/PCHWriterDecl.cpp +++ b/lib/Frontend/PCHWriterDecl.cpp @@ -136,7 +136,14 @@ void PCHDeclWriter::VisitNamedDecl(NamedDecl *D) { void PCHDeclWriter::VisitTypeDecl(TypeDecl *D) { VisitNamedDecl(D); - Writer.AddTypeRef(QualType(D->getTypeForDecl(), 0), Record); + if (isa(D)) { + // FIXME: Hack. To read a templated CXXRecordDecl from PCH, we need an + // initialized CXXRecordDecl before creating an InjectedClassNameType. + // Delay emitting/reading CXXRecordDecl's TypeForDecl until when we handle + // CXXRecordDecl emitting/initialization. + Writer.AddTypeRef(QualType(), Record); + } else + Writer.AddTypeRef(QualType(D->getTypeForDecl(), 0), Record); } void PCHDeclWriter::VisitTypedefDecl(TypedefDecl *D) { @@ -591,6 +598,9 @@ void PCHDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) { Record.push_back(CXXRecNotTemplate); } + // FIXME: Hack. See PCHDeclWriter::VisitTypeDecl. + Writer.AddTypeRef(QualType(D->getTypeForDecl(), 0), Record); + if (D->isDefinition()) { unsigned NumBases = D->getNumBases(); Record.push_back(NumBases); -- cgit v1.2.3-18-g5258