    
    // Build up the list of redeclarations.
    RedeclChainVisitor Visitor(*this, SearchDecls, RedeclsDeserialized, CanonID);
-@@ -2478,3 +2526,60 @@
+@@ -2478,3 +2530,60 @@
      }
    }
  }

   return Redecl;
 }
 
@@ -1515,6 +1521,7 @@
 template <typename T>
 ASTDeclReader::RedeclarableResult 
 ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) {

   } else {
     RedeclarableTemplateDecl *TD = cast<RedeclarableTemplateDecl>(D);
-    TD->RedeclLink.setNext(cast<RedeclarableTemplateDecl>(previous));
+    RedeclarableTemplateDecl *PrevTD = cast<RedeclarableTemplateDecl>(previous);
+    TD->RedeclLink
+      = Redeclarable<RedeclarableTemplateDecl>::PreviousDeclLink(PrevTD);
+    // We should attach the templated decl as well:
+    attachPreviousDecl(TD->getTemplatedDecl(), PrevTD->getTemplatedDecl());
+    //TD->RedeclLink.setNext(cast<RedeclarableTemplateDecl>(previous));
   }
 }
 
@@ -1846,9 +1889,11 @@
                                                    cast<NamespaceDecl>(Latest));
   } else {
     RedeclarableTemplateDecl *TD = cast<RedeclarableTemplateDecl>(D);
+    RedeclarableTemplateDecl *LatestTD = cast<RedeclarableTemplateDecl>(Latest);
     TD->RedeclLink
-      = Redeclarable<RedeclarableTemplateDecl>::LatestDeclLink(
-                                        cast<RedeclarableTemplateDecl>(Latest));
+      = Redeclarable<RedeclarableTemplateDecl>::LatestDeclLink(LatestTD);
+    // We should attach the templated decl as well:
+    attachLatestDecl(TD->getTemplatedDecl(), LatestTD->getTemplatedDecl());
   }
 }
 
@@ -2125,9 +2170,16 @@
   // AST consumer might need to know about, queue it.
   // We don't pass it to the consumer immediately because we may be in recursive
   // loading, and some declarations may still be initializing.
