]> granicus.if.org Git - clang/commitdiff
Include a hack to allow loading of templated CXXRecordDecls and test template reading...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 19 Jun 2010 19:29:21 +0000 (19:29 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 19 Jun 2010 19:29:21 +0000 (19:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106393 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/PCHReaderDecl.cpp
lib/Frontend/PCHWriterDecl.cpp
test/PCH/cxx-templates.cpp

index fe11ca76d3ebed04fc34db787e561906e8115b96..3fc159ace2c23cb3602eae435417186409973fcb 100644 (file)
@@ -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()) {
index 06717108826a6232df9db8df10073cf40be8973c..a704d6762d17a1c5a687f75166516c453a4c565d 100644 (file)
@@ -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);
index 00756736c290f9cf32ebe5b886078be087deba34..948763a5905a69faf3b89cdf12230cccc34faf5c 100644 (file)
@@ -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;