When a module completes the definition of a class template specialization imported from another module, emit an update record, rather than using the broken decl rewriting mechanism. If multiple modules do this, merge the definitions together, much as we would if they were separate declarations.

llvm-svn: 206680
diff --git a/clang/test/Modules/Inputs/cxx-irgen-left.h b/clang/test/Modules/Inputs/cxx-irgen-left.h
index 970ac76..ceb5084 100644
--- a/clang/test/Modules/Inputs/cxx-irgen-left.h
+++ b/clang/test/Modules/Inputs/cxx-irgen-left.h
@@ -5,3 +5,7 @@
 inline int instantiate_min() {
   return min(1, 2);
 }
+
+inline int instantiate_CtorInit(CtorInit<int> i = CtorInit<int>()) {
+  return i.a;
+}
diff --git a/clang/test/Modules/Inputs/cxx-irgen-top.h b/clang/test/Modules/Inputs/cxx-irgen-top.h
index 8113e94..8753d8d 100644
--- a/clang/test/Modules/Inputs/cxx-irgen-top.h
+++ b/clang/test/Modules/Inputs/cxx-irgen-top.h
@@ -8,3 +8,9 @@
 template<typename T> T min(T a, T b) { return a < b ? a : b; }
 
 extern decltype(min(1, 2)) instantiate_min_decl;
+
+template<typename T> struct CtorInit {
+  static int f() { return 0; }
+  int a;
+  CtorInit() : a(f()) {}
+};
diff --git a/clang/test/Modules/Inputs/templates-left.h b/clang/test/Modules/Inputs/templates-left.h
index e76598d..99e39bb 100644
--- a/clang/test/Modules/Inputs/templates-left.h
+++ b/clang/test/Modules/Inputs/templates-left.h
@@ -33,3 +33,9 @@
 void redeclDefinitionEmit(){}
 
 typedef Outer<int>::Inner OuterIntInner_left;
+
+int defineListDoubleLeft() {
+  List<double> ld;
+  ld.push_back(0.0);
+  return ld.size;
+}
diff --git a/clang/test/Modules/Inputs/templates-right.h b/clang/test/Modules/Inputs/templates-right.h
index 16d0a71..7e18c95 100644
--- a/clang/test/Modules/Inputs/templates-right.h
+++ b/clang/test/Modules/Inputs/templates-right.h
@@ -31,3 +31,9 @@
 void redeclDefinitionEmit(){}
 
 typedef Outer<int>::Inner OuterIntInner_right;
+
+int defineListDoubleRight() {
+  List<double> ld;
+  ld.push_back(0.0);
+  return ld.size;
+}
diff --git a/clang/test/Modules/Inputs/templates-top.h b/clang/test/Modules/Inputs/templates-top.h
index 87dcd8b..0b13359 100644
--- a/clang/test/Modules/Inputs/templates-top.h
+++ b/clang/test/Modules/Inputs/templates-top.h
@@ -9,6 +9,8 @@
   unsigned size;
 };
 
+extern List<double> *instantiateListDoubleDeclaration;
+
 namespace A {
   class Y {
     template <typename T> friend class WhereAmI;
diff --git a/clang/test/Modules/cxx-irgen.cpp b/clang/test/Modules/cxx-irgen.cpp
index 8c7281b..7c680f8 100644
--- a/clang/test/Modules/cxx-irgen.cpp
+++ b/clang/test/Modules/cxx-irgen.cpp
@@ -3,6 +3,10 @@
 // FIXME: When we have a syntax for modules in C++, use that.
 
 @import cxx_irgen_top;
+
+// CHECK-DAG: call i32 @_ZN8CtorInitIiE1fEv(
+CtorInit<int> x;
+
 @import cxx_irgen_left;
 @import cxx_irgen_right;
 
diff --git a/clang/test/Modules/templates.mm b/clang/test/Modules/templates.mm
index 080f9e7..0f1bc43 100644
--- a/clang/test/Modules/templates.mm
+++ b/clang/test/Modules/templates.mm
@@ -20,6 +20,9 @@
 
   N::Set<char> set_char;
   set_char.insert('A');
+
+  List<double> list_double;
+  list_double.push_back(0.0);
 }
 
 void testPendingInstantiations() {