aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-06-19 19:29:21 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-06-19 19:29:21 +0000
commit28d16d79e464063c09aa63c87afe10c25cb66c7c (patch)
treeeedee6ca4ed200acf449c104e9eb2f8e1839e585
parent8731ca76acf81826df7048bffd0c44c7c0f96c7f (diff)
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
-rw-r--r--lib/Frontend/PCHReaderDecl.cpp3
-rw-r--r--lib/Frontend/PCHWriterDecl.cpp12
-rw-r--r--test/PCH/cxx-templates.cpp3
3 files changed, 16 insertions, 2 deletions
diff --git a/lib/Frontend/PCHReaderDecl.cpp b/lib/Frontend/PCHReaderDecl.cpp
index fe11ca76d3..3fc159ace2 100644
--- a/lib/Frontend/PCHReaderDecl.cpp
+++ b/lib/Frontend/PCHReaderDecl.cpp
@@ -590,6 +590,9 @@ void PCHDeclReader::VisitCXXRecordDecl(CXXRecordDecl *D) {
}
}
+ // FIXME: Hack. See PCHDeclWriter::VisitTypeDecl.
+ D->setTypeForDecl(Reader.GetType(Record[Idx++]).getTypePtr());
+
// FIXME: this is far from complete
if (D->isDefinition()) {
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<CXXRecordDecl>(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);
diff --git a/test/PCH/cxx-templates.cpp b/test/PCH/cxx-templates.cpp
index 00756736c2..948763a590 100644
--- a/test/PCH/cxx-templates.cpp
+++ b/test/PCH/cxx-templates.cpp
@@ -1,3 +1,4 @@
// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-templates.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only %s
-// Placeholder for stuff using the header.
+S<float> v;