[cfe-commits] r106393 - in /cfe/trunk: lib/Frontend/PCHReaderDecl.cpp lib/Frontend/PCHWriterDecl.cpp test/PCH/cxx-templates.cpp
Argyrios Kyrtzidis
akyrtzi at gmail.com
Sat Jun 19 12:29:21 PDT 2010
Author: akirtzidis
Date: Sat Jun 19 14:29:21 2010
New Revision: 106393
URL: http://llvm.org/viewvc/llvm-project?rev=106393&view=rev
Log:
Include a hack to allow loading of templated CXXRecordDecls and test template reading from PCH.
Modified:
cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
cfe/trunk/lib/Frontend/PCHWriterDecl.cpp
cfe/trunk/test/PCH/cxx-templates.cpp
Modified: cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderDecl.cpp?rev=106393&r1=106392&r2=106393&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderDecl.cpp Sat Jun 19 14:29:21 2010
@@ -590,6 +590,9 @@
}
}
+ // FIXME: Hack. See PCHDeclWriter::VisitTypeDecl.
+ D->setTypeForDecl(Reader.GetType(Record[Idx++]).getTypePtr());
+
// FIXME: this is far from complete
if (D->isDefinition()) {
Modified: cfe/trunk/lib/Frontend/PCHWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriterDecl.cpp?rev=106393&r1=106392&r2=106393&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriterDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriterDecl.cpp Sat Jun 19 14:29:21 2010
@@ -136,7 +136,14 @@
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 @@
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);
Modified: cfe/trunk/test/PCH/cxx-templates.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx-templates.cpp?rev=106393&r1=106392&r2=106393&view=diff
==============================================================================
--- cfe/trunk/test/PCH/cxx-templates.cpp (original)
+++ cfe/trunk/test/PCH/cxx-templates.cpp Sat Jun 19 14:29:21 2010
@@ -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;
More information about the cfe-commits
mailing list