    }
  }
  
-@@ -2125,9 +2171,16 @@
+@@ -2125,9 +2162,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.

   if (!Reader.getContext().getLangOpts().Modules)
     return;
   
@@ -1731,7 +1739,16 @@
     return (FuncX->getLinkage() == FuncY->getLinkage()) &&
       FuncX->getASTContext().hasSameType(FuncX->getType(), FuncY->getType());
   }
-  
+
+  if (const FunctionTemplateDecl* FTDX = dyn_cast<FunctionTemplateDecl>(X)) {
+    const FunctionTemplateDecl* FTDY = cast<FunctionTemplateDecl>(Y);
+    if (isSameEntity(FTDX->getTemplatedDecl(), FTDY->getTemplatedDecl())) {
+      return FTDX->getTemplatedDecl()->getNumParams() 
+        == FTDY->getTemplatedDecl()->getNumParams();
+
+    }
+  }
+    
   // Variables with the same type and linkage match.
   if (VarDecl *VarX = dyn_cast<VarDecl>(X)) {
     VarDecl *VarY = cast<VarDecl>(Y);
@@ -1744,20 +1761,26 @@
     NamespaceDecl *NamespaceY = cast<NamespaceDecl>(Y);
     return NamespaceX->isInline() == NamespaceY->isInline();
   }

+}
Index: tools/clang/lib/Serialization/ASTReader.cpp
===================================================================
--- tools/clang/lib/Serialization/ASTReader.cpp	(revision 161724)
+++ tools/clang/lib/Serialization/ASTReader.cpp	(working copy)
@@ -4930,6 +4930,9 @@
         if (!ND)
