summaryrefslogtreecommitdiffstats
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
commit26b72453f75496f3e554cb89d81ba340368d786c (patch)
treedb3c7482b87131890f21b52bafe502695e5faeac
parent95c04caf9247d2d459003a649d5e434e820f3350 (diff)
downloadbcm5719-llvm-26b72453f75496f3e554cb89d81ba340368d786c.tar.gz
bcm5719-llvm-26b72453f75496f3e554cb89d81ba340368d786c.zip
Include a hack to allow loading of templated CXXRecordDecls and test template reading from PCH.
llvm-svn: 106393
-rw-r--r--clang/lib/Frontend/PCHReaderDecl.cpp3
-rw-r--r--clang/lib/Frontend/PCHWriterDecl.cpp12
-rw-r--r--clang/test/PCH/cxx-templates.cpp3
3 files changed, 16 insertions, 2 deletions
diff --git a/clang/lib/Frontend/PCHReaderDecl.cpp b/clang/lib/Frontend/PCHReaderDecl.cpp
index fe11ca76d3e..3fc159ace2c 100644
--- a/clang/lib/Frontend/PCHReaderDecl.cpp
+++ b/clang/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/clang/lib/Frontend/PCHWriterDecl.cpp b/clang/lib/Frontend/PCHWriterDecl.cpp
index 06717108826..a704d6762d1 100644
--- a/clang/lib/Frontend/PCHWriterDecl.cpp
+++ b/clang/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/clang/test/PCH/cxx-templates.cpp b/clang/test/PCH/cxx-templates.cpp
index 00756736c29..948763a5905 100644
--- a/clang/test/PCH/cxx-templates.cpp
+++ b/clang/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;
OpenPOWER on IntegriCloud