Read/write function template specializations for PCH, properly this time.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107665 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/PCHReaderDecl.cpp b/lib/Frontend/PCHReaderDecl.cpp
index 698adf4..e21cbab 100644
--- a/lib/Frontend/PCHReaderDecl.cpp
+++ b/lib/Frontend/PCHReaderDecl.cpp
@@ -977,9 +977,12 @@
   if (PrevDecl == 0) {
     // This FunctionTemplateDecl owns a CommonPtr; read it.
 
-    // FunctionTemplateSpecializationInfos are filled through the
-    // templated FunctionDecl's setFunctionTemplateSpecialization, no need to
-    // read them here.
+    // Read the function specialization declarations.
+    // FunctionTemplateDecl's FunctionTemplateSpecializationInfos are filled
+    // through the specialized FunctionDecl's setFunctionTemplateSpecialization.
+    unsigned NumSpecs = Record[Idx++];
+    while (NumSpecs--)
+      Reader.GetDecl(Record[Idx++]);
 
     if (FunctionTemplateDecl *CTD
           = cast_or_null<FunctionTemplateDecl>(Reader.GetDecl(Record[Idx++]))) {
diff --git a/lib/Frontend/PCHWriterDecl.cpp b/lib/Frontend/PCHWriterDecl.cpp
index 2dc5972..7c672bd 100644
--- a/lib/Frontend/PCHWriterDecl.cpp
+++ b/lib/Frontend/PCHWriterDecl.cpp
@@ -923,9 +923,12 @@
   if (D->getPreviousDeclaration() == 0) {
     // This FunctionTemplateDecl owns the CommonPtr; write it.
 
-    // FunctionTemplateSpecializationInfos are filled through the
-    // templated FunctionDecl's setFunctionTemplateSpecialization, no need to
-    // write them here.
+    // Write the function specialization declarations.
+    Record.push_back(D->getSpecializations().size());
+    for (llvm::FoldingSet<FunctionTemplateSpecializationInfo>::iterator
+           I = D->getSpecializations().begin(),
+           E = D->getSpecializations().end()   ; I != E; ++I)
+      Writer.AddDeclRef(I->Function, Record);
 
     Writer.AddDeclRef(D->getInstantiatedFromMemberTemplate(), Record);
     if (D->getInstantiatedFromMemberTemplate())