Updated to Clang 3.5a.

Change-Id: I8127eb568f674c2e72635b639a3295381fe8af82
diff --git a/test/Modules/Inputs/ModuleMapLocations/Both/a.h b/test/Modules/Inputs/ModuleMapLocations/Both/a.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Both/a.h
diff --git a/test/Modules/Inputs/ModuleMapLocations/Both/b.h b/test/Modules/Inputs/ModuleMapLocations/Both/b.h
new file mode 100644
index 0000000..3abbd39
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Both/b.h
@@ -0,0 +1 @@
+void wont_be_found1(void);
diff --git a/test/Modules/Inputs/ModuleMapLocations/Both/module.map b/test/Modules/Inputs/ModuleMapLocations/Both/module.map
new file mode 100644
index 0000000..bf5aaed
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Both/module.map
@@ -0,0 +1,3 @@
+module both {
+  header "b.h"
+}
diff --git a/test/Modules/Inputs/ModuleMapLocations/Both/module.modulemap b/test/Modules/Inputs/ModuleMapLocations/Both/module.modulemap
new file mode 100644
index 0000000..0bfa096
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Both/module.modulemap
@@ -0,0 +1,3 @@
+module both {
+  header "a.h"
+}
diff --git a/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Headers/a.h b/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Headers/a.h
new file mode 100644
index 0000000..9dabfc0
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Headers/a.h
@@ -0,0 +1 @@
+void will_be_found2(void);
diff --git a/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Headers/b.h b/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Headers/b.h
new file mode 100644
index 0000000..26169fa
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Headers/b.h
@@ -0,0 +1 @@
+void wont_be_found2(void);
diff --git a/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Modules/module.modulemap b/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Modules/module.modulemap
new file mode 100644
index 0000000..da49ba5
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/Modules/module.modulemap
@@ -0,0 +1,3 @@
+framework module Both_F {
+  header "a.h"
+}
diff --git a/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/module.map b/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/module.map
new file mode 100644
index 0000000..8fc108d
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Both_F.framework/module.map
@@ -0,0 +1,3 @@
+framework module Both_F {
+  header "b.h"
+}
diff --git a/test/Modules/Inputs/ModuleMapLocations/Inferred.framework/Headers/Inferred.h b/test/Modules/Inputs/ModuleMapLocations/Inferred.framework/Headers/Inferred.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Inferred.framework/Headers/Inferred.h
diff --git a/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap/a.h b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap/a.h
new file mode 100644
index 0000000..d571c6e
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap/a.h
@@ -0,0 +1 @@
+void will_be_found1(void);
diff --git a/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap/module.modulemap b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap/module.modulemap
new file mode 100644
index 0000000..2ac7cc5
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap/module.modulemap
@@ -0,0 +1,3 @@
+module module_modulemap {
+  header "a.h"
+}
diff --git a/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/Headers/a.h b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/Headers/a.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/Headers/a.h
diff --git a/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/Modules/module.modulemap b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/Modules/module.modulemap
new file mode 100644
index 0000000..400f304
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/Modules/module.modulemap
@@ -0,0 +1,3 @@
+framework module Module_ModuleMap_F {
+  header "a.h"
+}
diff --git a/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/Modules/module.private.modulemap b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/Modules/module.private.modulemap
new file mode 100644
index 0000000..25a469d
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/Modules/module.private.modulemap
@@ -0,0 +1,3 @@
+explicit framework module Module_ModuleMap_F.Private {
+  header "private.h"
+}
diff --git a/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/PrivateHeaders/private.h b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/PrivateHeaders/private.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/Module_ModuleMap_F.framework/PrivateHeaders/private.h
diff --git a/test/Modules/Inputs/ModuleMapLocations/module.modulemap b/test/Modules/Inputs/ModuleMapLocations/module.modulemap
new file mode 100644
index 0000000..a8f5d1f
--- /dev/null
+++ b/test/Modules/Inputs/ModuleMapLocations/module.modulemap
@@ -0,0 +1,2 @@
+framework module * {
+}
diff --git a/test/Modules/Inputs/autolink-sub3.h b/test/Modules/Inputs/autolink-sub3.h
new file mode 100644
index 0000000..132c729
--- /dev/null
+++ b/test/Modules/Inputs/autolink-sub3.h
@@ -0,0 +1 @@
+int autolink_sub3(void);
diff --git a/test/Modules/Inputs/autolink-sub3.pch b/test/Modules/Inputs/autolink-sub3.pch
new file mode 100644
index 0000000..f63b2d5
--- /dev/null
+++ b/test/Modules/Inputs/autolink-sub3.pch
@@ -0,0 +1 @@
+@import autolink.sub3;
diff --git a/test/Modules/Inputs/c-header-bad.h b/test/Modules/Inputs/c-header-bad.h
new file mode 100644
index 0000000..7f7cd87
--- /dev/null
+++ b/test/Modules/Inputs/c-header-bad.h
@@ -0,0 +1,4 @@
+} // expected-error {{extraneous closing brace ('}')}}
+int not_in_extern_c;
+extern "C" { // expected-note {{to match this '{'}}
+// expected-error {{expected '}'}}
diff --git a/test/Modules/Inputs/c-header.h b/test/Modules/Inputs/c-header.h
new file mode 100644
index 0000000..e12f644
--- /dev/null
+++ b/test/Modules/Inputs/c-header.h
@@ -0,0 +1 @@
+int f(void);
diff --git a/test/Modules/Inputs/cxx-header.h b/test/Modules/Inputs/cxx-header.h
new file mode 100644
index 0000000..7ed7775
--- /dev/null
+++ b/test/Modules/Inputs/cxx-header.h
@@ -0,0 +1 @@
+int f();
diff --git a/test/Modules/Inputs/cxx-inline-namespace-b.h b/test/Modules/Inputs/cxx-inline-namespace-b.h
new file mode 100644
index 0000000..242a585
--- /dev/null
+++ b/test/Modules/Inputs/cxx-inline-namespace-b.h
@@ -0,0 +1,5 @@
+@import cxx_inline_namespace;
+
+struct X::Y::Z {
+  void f(struct Elaborated);
+};
diff --git a/test/Modules/Inputs/cxx-inline-namespace.h b/test/Modules/Inputs/cxx-inline-namespace.h
index 2525ad3..4feb850 100644
--- a/test/Modules/Inputs/cxx-inline-namespace.h
+++ b/test/Modules/Inputs/cxx-inline-namespace.h
@@ -9,3 +9,9 @@
     typedef int size_t;
   }
 }
+
+namespace X {
+  inline namespace Y {
+    struct Z;
+  }
+}
diff --git a/test/Modules/Inputs/cxx-irgen-left.h b/test/Modules/Inputs/cxx-irgen-left.h
new file mode 100644
index 0000000..970ac76
--- /dev/null
+++ b/test/Modules/Inputs/cxx-irgen-left.h
@@ -0,0 +1,7 @@
+#include "cxx-irgen-top.h"
+
+S<int> s;
+
+inline int instantiate_min() {
+  return min(1, 2);
+}
diff --git a/test/Modules/Inputs/cxx-irgen-right.h b/test/Modules/Inputs/cxx-irgen-right.h
new file mode 100644
index 0000000..4400c76
--- /dev/null
+++ b/test/Modules/Inputs/cxx-irgen-right.h
@@ -0,0 +1,3 @@
+#include "cxx-irgen-top.h"
+
+inline int h() { return S<int>::f(); }
diff --git a/test/Modules/Inputs/cxx-irgen-top.h b/test/Modules/Inputs/cxx-irgen-top.h
new file mode 100644
index 0000000..8113e94
--- /dev/null
+++ b/test/Modules/Inputs/cxx-irgen-top.h
@@ -0,0 +1,10 @@
+template<typename T> struct S {
+  __attribute__((always_inline)) static int f() { return 0; }
+  __attribute__((always_inline, visibility("hidden"))) static int g() { return 0; }
+};
+
+extern template struct S<int>;
+
+template<typename T> T min(T a, T b) { return a < b ? a : b; }
+
+extern decltype(min(1, 2)) instantiate_min_decl;
diff --git a/test/Modules/Inputs/cxx-templates-a.h b/test/Modules/Inputs/cxx-templates-a.h
index 0b1614d..6ecc2ca 100644
--- a/test/Modules/Inputs/cxx-templates-a.h
+++ b/test/Modules/Inputs/cxx-templates-a.h
@@ -48,3 +48,5 @@
 template<> struct MergeSpecializations<char> {
   typedef int explicitly_specialized_in_a;
 };
+
+void InstantiateWithFriend(Std::WithFriend<int> wfi) {}
diff --git a/test/Modules/Inputs/cxx-templates-b.h b/test/Modules/Inputs/cxx-templates-b.h
index 6cd83fa..a682855 100644
--- a/test/Modules/Inputs/cxx-templates-b.h
+++ b/test/Modules/Inputs/cxx-templates-b.h
@@ -66,4 +66,5 @@
 
 void TriggerInstantiation() {
   UseDefinedInBImpl<void>();
+  Std::f<int>();
 }
diff --git a/test/Modules/Inputs/cxx-templates-common.h b/test/Modules/Inputs/cxx-templates-common.h
index 40a11e2..9b46539 100644
--- a/test/Modules/Inputs/cxx-templates-common.h
+++ b/test/Modules/Inputs/cxx-templates-common.h
@@ -9,3 +9,15 @@
 template<typename T> struct CommonTemplate {
   enum E { a = 1, b = 2, c = 3 };
 };
+
+namespace Std {
+  template<typename T> struct WithFriend {
+    friend bool operator!=(const WithFriend &A, const WithFriend &B) { return false; }
+  };
+}
+
+namespace Std {
+  template<typename T> void f() {
+    extern T g();
+  }
+}
diff --git a/test/Modules/Inputs/declare-use/e.h b/test/Modules/Inputs/declare-use/e.h
index ed8d843..31247f7 100644
--- a/test/Modules/Inputs/declare-use/e.h
+++ b/test/Modules/Inputs/declare-use/e.h
@@ -1,6 +1,7 @@
 #ifndef E_H
 #define E_H
-#include "a.h"
+#define HEADER "a.h"
+#include HEADER
 #include "b.h"
 const int e = a*b;
 #endif
diff --git a/test/Modules/Inputs/declare-use/h.h b/test/Modules/Inputs/declare-use/h.h
index df99a6d..379e501 100644
--- a/test/Modules/Inputs/declare-use/h.h
+++ b/test/Modules/Inputs/declare-use/h.h
@@ -1,7 +1,7 @@
 #ifndef H_H
 #define H_H
 #include "c.h"
-#include "d.h" // expected-error {{use of a module not declared used}}
+#include "d.h" // expected-error {{does not depend on a module exporting}}
 #include "h1.h"
 const int h1 = aux_h*c*7*d;
 #endif
diff --git a/test/Modules/Inputs/declare-use/i.h b/test/Modules/Inputs/declare-use/i.h
new file mode 100644
index 0000000..30e7ded
--- /dev/null
+++ b/test/Modules/Inputs/declare-use/i.h
@@ -0,0 +1 @@
+int aux_i = 13;
diff --git a/test/Modules/Inputs/declare-use/j.h b/test/Modules/Inputs/declare-use/j.h
new file mode 100644
index 0000000..04d46a9
--- /dev/null
+++ b/test/Modules/Inputs/declare-use/j.h
@@ -0,0 +1,14 @@
+#ifndef J_H
+#define J_H
+
+#define STR(x) #x
+#define HDR(x) STR(x.h)
+
+#include ALLOWED_INC
+#include HDR(a)
+
+const int j = a * a + b;
+
+// expected-no-diagnostics
+
+#endif
diff --git a/test/Modules/Inputs/declare-use/module.map b/test/Modules/Inputs/declare-use/module.map
index 774fc37..a176fb3 100644
--- a/test/Modules/Inputs/declare-use/module.map
+++ b/test/Modules/Inputs/declare-use/module.map
@@ -9,21 +9,25 @@
 module XC {
   header "c.h"
   use XA
+  // Intentionally doesn't use XB to show that -fdecl-use isn't transitive.
 }
 
 module XD {
   header "d.h"
   use XA
+  // Intentionally doesn't use XB to show that -fdecl-use isn't transitive.
 }
 
 module XE {
   header "e.h"
+  header "unavailable.h"
   use XA
   use XB
 }
 
 module XF {
   header "f.h"
+  header "unavailable.h"
   use XA
   use XB
 }
@@ -33,11 +37,20 @@
   header "g1.h"
   use XC
   use XE
+  use XJ
 }
 
 module XH {
   header "h.h"
   header "h1.h"
+  header "s.h"
   use XC
   use XE
 }
+
+module XJ {
+  header "j.h"
+}
+
+module XS {
+}
diff --git a/test/Modules/Inputs/declare-use/s.h b/test/Modules/Inputs/declare-use/s.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Modules/Inputs/declare-use/s.h
diff --git a/test/Modules/Inputs/elsewhere/c-header-indirect.h b/test/Modules/Inputs/elsewhere/c-header-indirect.h
new file mode 100644
index 0000000..083c41f
--- /dev/null
+++ b/test/Modules/Inputs/elsewhere/c-header-indirect.h
@@ -0,0 +1 @@
+#include "c-header.h"
diff --git a/test/Modules/Inputs/elsewhere/module.map b/test/Modules/Inputs/elsewhere/module.map
new file mode 100644
index 0000000..2c56820
--- /dev/null
+++ b/test/Modules/Inputs/elsewhere/module.map
@@ -0,0 +1 @@
+module c_library_indirect { header "c-header-indirect.h" }
diff --git a/test/Modules/Inputs/include-relative/a.h b/test/Modules/Inputs/include-relative/a.h
new file mode 100644
index 0000000..b95284b
--- /dev/null
+++ b/test/Modules/Inputs/include-relative/a.h
@@ -0,0 +1 @@
+extern int n;
diff --git a/test/Modules/Inputs/include-relative/module.map b/test/Modules/Inputs/include-relative/module.map
new file mode 100644
index 0000000..bb00c84
--- /dev/null
+++ b/test/Modules/Inputs/include-relative/module.map
@@ -0,0 +1 @@
+module a { header "a.h" }
diff --git a/test/Modules/Inputs/macro-undef-through-pch/A.h b/test/Modules/Inputs/macro-undef-through-pch/A.h
new file mode 100644
index 0000000..6a2cc5c
--- /dev/null
+++ b/test/Modules/Inputs/macro-undef-through-pch/A.h
@@ -0,0 +1,2 @@
+#define AB
+#undef AB
diff --git a/test/Modules/Inputs/macro-undef-through-pch/foo.h b/test/Modules/Inputs/macro-undef-through-pch/foo.h
new file mode 100644
index 0000000..9d0256b
--- /dev/null
+++ b/test/Modules/Inputs/macro-undef-through-pch/foo.h
@@ -0,0 +1 @@
+@import A;
diff --git a/test/Modules/Inputs/macro-undef-through-pch/module.map b/test/Modules/Inputs/macro-undef-through-pch/module.map
new file mode 100644
index 0000000..63f68ca
--- /dev/null
+++ b/test/Modules/Inputs/macro-undef-through-pch/module.map
@@ -0,0 +1,3 @@
+module A {
+  header "A.h"
+}
diff --git a/test/Modules/Inputs/macros_other.h b/test/Modules/Inputs/macros_other.h
index ea686bf..4923a7f 100644
--- a/test/Modules/Inputs/macros_other.h
+++ b/test/Modules/Inputs/macros_other.h
@@ -1 +1,6 @@
-#define OTHER_INTEGER int
+#undef TOP_OTHER_UNDEF1
+#define TOP_OTHER_UNDEF2 42
+#define TOP_OTHER_REDEF1 1
+#define TOP_OTHER_REDEF1 3
+
+#define TOP_OTHER_DEF_RIGHT_UNDEF 4
diff --git a/test/Modules/Inputs/macros_right.h b/test/Modules/Inputs/macros_right.h
index dbbd2c3..a70c350 100644
--- a/test/Modules/Inputs/macros_right.h
+++ b/test/Modules/Inputs/macros_right.h
@@ -17,3 +17,5 @@
 #define TOP_RIGHT_REDEF float
 
 #define FN_ADD(x, y) (x+y)
+
+#undef TOP_OTHER_DEF_RIGHT_UNDEF
diff --git a/test/Modules/Inputs/macros_right_undef.h b/test/Modules/Inputs/macros_right_undef.h
index 49473e3..15a8366 100644
--- a/test/Modules/Inputs/macros_right_undef.h
+++ b/test/Modules/Inputs/macros_right_undef.h
@@ -1 +1,4 @@
 #undef TOP_RIGHT_UNDEF
+
+@import macros_top;
+#undef TOP_OTHER_DEF_RIGHT_UNDEF
diff --git a/test/Modules/Inputs/macros_top.h b/test/Modules/Inputs/macros_top.h
index dd303ff..1093504 100644
--- a/test/Modules/Inputs/macros_top.h
+++ b/test/Modules/Inputs/macros_top.h
@@ -14,3 +14,11 @@
 
 #define TOP_RIGHT_UNDEF int
 
+#define TOP_OTHER_UNDEF1 42
+#undef TOP_OTHER_UNDEF2
+#define TOP_OTHER_REDEF1 1
+#define TOP_OTHER_REDEF2 2
+
+#define TOP_OTHER_DEF_RIGHT_UNDEF void
+
+#define TOP_REDEF_IN_SUBMODULES 0
diff --git a/test/Modules/Inputs/macros_top_b.h b/test/Modules/Inputs/macros_top_b.h
new file mode 100644
index 0000000..cfee17c
--- /dev/null
+++ b/test/Modules/Inputs/macros_top_b.h
@@ -0,0 +1,5 @@
+#include "macros_top.h"
+#undef TOP_REDEF_IN_SUBMODULES
+#define TOP_REDEF_IN_SUBMODULES 1
+#undef TOP_REDEF_IN_SUBMODULES
+#define TOP_REDEF_IN_SUBMODULES 2
diff --git a/test/Modules/Inputs/macros_top_c.h b/test/Modules/Inputs/macros_top_c.h
new file mode 100644
index 0000000..aee8246
--- /dev/null
+++ b/test/Modules/Inputs/macros_top_c.h
@@ -0,0 +1,2 @@
+#include "macros_top_b.h"
+#undef TOP_REDEF_IN_SUBMODULES
diff --git a/test/Modules/Inputs/malformed/a1.h b/test/Modules/Inputs/malformed/a1.h
new file mode 100644
index 0000000..400b916
--- /dev/null
+++ b/test/Modules/Inputs/malformed/a1.h
@@ -0,0 +1 @@
+void f() {
diff --git a/test/Modules/Inputs/malformed/a2.h b/test/Modules/Inputs/malformed/a2.h
new file mode 100644
index 0000000..5c34318
--- /dev/null
+++ b/test/Modules/Inputs/malformed/a2.h
@@ -0,0 +1 @@
+}
diff --git a/test/Modules/Inputs/malformed/b1.h b/test/Modules/Inputs/malformed/b1.h
new file mode 100644
index 0000000..3d98bc1
--- /dev/null
+++ b/test/Modules/Inputs/malformed/b1.h
@@ -0,0 +1,3 @@
+struct S {
+  #include "b2.h"
+};
diff --git a/test/Modules/Inputs/malformed/b2.h b/test/Modules/Inputs/malformed/b2.h
new file mode 100644
index 0000000..7fc5340
--- /dev/null
+++ b/test/Modules/Inputs/malformed/b2.h
@@ -0,0 +1 @@
+void g() {}
diff --git a/test/Modules/Inputs/malformed/module.map b/test/Modules/Inputs/malformed/module.map
new file mode 100644
index 0000000..5277ffa
--- /dev/null
+++ b/test/Modules/Inputs/malformed/module.map
@@ -0,0 +1,8 @@
+module malformed_a {
+  module a1 { header "a1.h" }
+  module a2 { header "a2.h" }
+}
+module malformed_b {
+  module b1 { header "b1.h" }
+  module b2 { header "b2.h" }
+}
diff --git a/test/Modules/Inputs/module.map b/test/Modules/Inputs/module.map
index cf8a298..d6effcf 100644
--- a/test/Modules/Inputs/module.map
+++ b/test/Modules/Inputs/module.map
@@ -1,3 +1,6 @@
+module c_library [extern_c] { module inner { header "c-header.h" } }
+module cxx_library { header "cxx-header.h" requires cplusplus }
+module c_library_bad [extern_c] { header "c-header-bad.h" }
 module diamond_top { header "diamond_top.h" }
 module diamond_left { 
   header "diamond_left.h" 
@@ -12,6 +15,9 @@
   export *
 }
 module irgen { header "irgen.h" }
+module cxx_irgen_top { header "cxx-irgen-top.h" }
+module cxx_irgen_left { header "cxx-irgen-left.h" }
+module cxx_irgen_right { header "cxx-irgen-right.h" }
 module lookup_left_objc { header "lookup_left.h" }
 module lookup_right_objc { header "lookup_right.h" }
 module lookup_left_cxx { header "lookup_left.hpp" }
@@ -20,6 +26,8 @@
 module module_private_right { header "module_private_right.h" }
 module macros_top { 
   header "macros_top.h" 
+  explicit module b { header "macros_top_b.h" }
+  explicit module c { header "macros_top_c.h" }
 }
 module macros_left { 
   header "macros_left.h" 
@@ -33,6 +41,7 @@
   }
 }
 module macros { header "macros.h" }
+module macros_other { header "macros_other.h" }
 module category_top { header "category_top.h" }
 module category_left { 
   header "category_left.h" 
@@ -166,6 +175,11 @@
     header "autolink-sub2.h"
     link framework "autolink_framework"
   }
+
+  explicit module sub3 {
+    header "autolink-sub3.h"
+    link "autolink_from_pch"
+  }
 }
 
 module weird_objc {
@@ -184,6 +198,10 @@
   header "cxx-inline-namespace.h"
 }
 
+module cxx_inline_namespace_b {
+  header "cxx-inline-namespace-b.h"
+}
+
 module cxx_linkage_cache {
   header "cxx-linkage-cache.h"
 }
@@ -281,3 +299,9 @@
 module recursive_visibility_c {
   header "recursive_visibility_c.h"
 }
+module recursive1 {
+  header "recursive1.h"
+}
+module recursive2 {
+  header "recursive2.h"
+}
diff --git a/test/Modules/Inputs/namespaces-left.h b/test/Modules/Inputs/namespaces-left.h
index bd192af..787fe75 100644
--- a/test/Modules/Inputs/namespaces-left.h
+++ b/test/Modules/Inputs/namespaces-left.h
@@ -1,5 +1,18 @@
+namespace RedeclAcrossImport {
+  enum E { e };
+}
+
+namespace AddAndReexportBeforeImport {
+  struct S {};
+  extern struct S t;
+}
+
 @import namespaces_top;
 
+namespace RedeclAcrossImport {
+  E x = e;
+}
+
 float &global(float);
 float &global2(float);
 
diff --git a/test/Modules/Inputs/namespaces-top.h b/test/Modules/Inputs/namespaces-top.h
index 7aa8490..7bf5394 100644
--- a/test/Modules/Inputs/namespaces-top.h
+++ b/test/Modules/Inputs/namespaces-top.h
@@ -17,3 +17,7 @@
   int f(int);
   void (*p)() = &f;
 }
+
+namespace AddAndReexportBeforeImport {
+  int S;
+}
diff --git a/test/Modules/Inputs/recursive1.h b/test/Modules/Inputs/recursive1.h
new file mode 100644
index 0000000..8cb5917
--- /dev/null
+++ b/test/Modules/Inputs/recursive1.h
@@ -0,0 +1 @@
+#include "recursive2.h"
diff --git a/test/Modules/Inputs/recursive2.h b/test/Modules/Inputs/recursive2.h
new file mode 100644
index 0000000..d9480aa
--- /dev/null
+++ b/test/Modules/Inputs/recursive2.h
@@ -0,0 +1 @@
+#include "recursive1.h"
diff --git a/test/Modules/Inputs/string_names/a.h b/test/Modules/Inputs/string_names/a.h
new file mode 100644
index 0000000..a36dc1b
--- /dev/null
+++ b/test/Modules/Inputs/string_names/a.h
@@ -0,0 +1,4 @@
+#ifndef A_H
+#define A_H
+const int a = 2;
+#endif
diff --git a/test/Modules/Inputs/string_names/b.h b/test/Modules/Inputs/string_names/b.h
new file mode 100644
index 0000000..55daf72
--- /dev/null
+++ b/test/Modules/Inputs/string_names/b.h
@@ -0,0 +1,4 @@
+#ifndef B_H
+#define B_H
+const int b = 3;
+#endif
diff --git a/test/Modules/Inputs/string_names/c.h b/test/Modules/Inputs/string_names/c.h
new file mode 100644
index 0000000..38c278f
--- /dev/null
+++ b/test/Modules/Inputs/string_names/c.h
@@ -0,0 +1,4 @@
+#ifndef C_H
+#define C_H
+const int c = 2;
+#endif
diff --git a/test/Modules/Inputs/string_names/module.map b/test/Modules/Inputs/string_names/module.map
new file mode 100644
index 0000000..4e70eda
--- /dev/null
+++ b/test/Modules/Inputs/string_names/module.map
@@ -0,0 +1,16 @@
+module "my/module-a" {
+  header "a.h"
+  use "my/module-c"
+
+  module "Sub" {
+    header "sub.h"
+  }
+}
+
+module "my/module-b" {
+  header "b.h"
+}
+
+module "my/module-c" {
+  header "c.h"
+}
diff --git a/test/Modules/Inputs/string_names/sub.h b/test/Modules/Inputs/string_names/sub.h
new file mode 100644
index 0000000..64b9112
--- /dev/null
+++ b/test/Modules/Inputs/string_names/sub.h
@@ -0,0 +1,4 @@
+#ifndef SUB_H
+#define SUB_H
+const int sub = 2;
+#endif
diff --git a/test/Modules/Inputs/submodules/import-self-b.h b/test/Modules/Inputs/submodules/import-self-b.h
index f88b56d..9852094 100644
--- a/test/Modules/Inputs/submodules/import-self-b.h
+++ b/test/Modules/Inputs/submodules/import-self-b.h
@@ -1,10 +1,12 @@
+// FIXME: This import has no effect, because the submodule isn't built yet, and
+// we don't map an @import to a #include in this case.
 @import import_self.c;
 #include "import-self-d.h"
 
 // FIXME: This should not work; names from 'a' should not be visible here.
 MyTypeA import_self_test_a;
 
-// FIXME: This should work but does not; names from 'b' are not actually visible here.
+// FIXME: This should work but does not; names from 'c' are not actually visible here.
 //MyTypeC import_self_test_c;
 
 MyTypeD import_self_test_d;
diff --git a/test/Modules/Inputs/submodules/module.map b/test/Modules/Inputs/submodules/module.map
index c91e94f..1593103 100644
--- a/test/Modules/Inputs/submodules/module.map
+++ b/test/Modules/Inputs/submodules/module.map
@@ -10,3 +10,8 @@
   module c { header "import-self-c.h" }
   module d { header "import-self-d.h" }
 }
+
+module missing_headers {
+  module missing { header "missing.h" }
+  module not_missing { header "not_missing.h" }
+}
diff --git a/test/Modules/Inputs/submodules/not_missing.h b/test/Modules/Inputs/submodules/not_missing.h
new file mode 100644
index 0000000..1f8d048
--- /dev/null
+++ b/test/Modules/Inputs/submodules/not_missing.h
@@ -0,0 +1,2 @@
+void NotMissingFunction() {
+}
diff --git a/test/Modules/Inputs/template-specialization-visibility/a.h b/test/Modules/Inputs/template-specialization-visibility/a.h
new file mode 100644
index 0000000..e8820555
--- /dev/null
+++ b/test/Modules/Inputs/template-specialization-visibility/a.h
@@ -0,0 +1,8 @@
+#ifndef A_H
+#define A_H
+template<typename T> struct S;
+template<typename U> struct T {
+  struct S;
+  enum E : int;
+};
+#endif
diff --git a/test/Modules/Inputs/template-specialization-visibility/b.h b/test/Modules/Inputs/template-specialization-visibility/b.h
new file mode 100644
index 0000000..1a09826
--- /dev/null
+++ b/test/Modules/Inputs/template-specialization-visibility/b.h
@@ -0,0 +1,7 @@
+#ifndef B_H
+#define B_H
+#include "a.h"
+S<int> *s1;
+T<int>::S *s2;
+T<int>::E e1;
+#endif
diff --git a/test/Modules/Inputs/template-specialization-visibility/c.h b/test/Modules/Inputs/template-specialization-visibility/c.h
new file mode 100644
index 0000000..a92fb3b
--- /dev/null
+++ b/test/Modules/Inputs/template-specialization-visibility/c.h
@@ -0,0 +1,6 @@
+#ifndef C_H
+#define C_H
+template<typename T> struct S { int n; };
+template<typename U> struct T<U>::S { int n; };
+template<typename U> enum T<U>::E : int { e };
+#endif
diff --git a/test/Modules/Inputs/template-specialization-visibility/d.h b/test/Modules/Inputs/template-specialization-visibility/d.h
new file mode 100644
index 0000000..3048272
--- /dev/null
+++ b/test/Modules/Inputs/template-specialization-visibility/d.h
@@ -0,0 +1,5 @@
+#ifndef D_H
+#define D_H
+template<typename> struct S;
+template<typename> struct T;
+#endif
diff --git a/test/Modules/Inputs/template-specialization-visibility/e.h b/test/Modules/Inputs/template-specialization-visibility/e.h
new file mode 100644
index 0000000..5d6b142
--- /dev/null
+++ b/test/Modules/Inputs/template-specialization-visibility/e.h
@@ -0,0 +1,6 @@
+#ifndef E_H
+#define E_H
+#include "c.h"
+template struct S<char>;
+template struct T<char>;
+#endif
diff --git a/test/Modules/Inputs/template-specialization-visibility/module.map b/test/Modules/Inputs/template-specialization-visibility/module.map
new file mode 100644
index 0000000..f0e2a0e
--- /dev/null
+++ b/test/Modules/Inputs/template-specialization-visibility/module.map
@@ -0,0 +1,7 @@
+module tsv {
+  module a { header "a.h" }
+  module b { header "b.h" }
+  module c { header "c.h" }
+  module d { header "d.h" }
+  module e { header "e.h" }
+}
diff --git a/test/Modules/Inputs/unnecessary-module-map-parsing/a1.h b/test/Modules/Inputs/unnecessary-module-map-parsing/a1.h
new file mode 100644
index 0000000..56757a7
--- /dev/null
+++ b/test/Modules/Inputs/unnecessary-module-map-parsing/a1.h
@@ -0,0 +1 @@
+void f() {}
diff --git a/test/Modules/Inputs/unnecessary-module-map-parsing/module.map b/test/Modules/Inputs/unnecessary-module-map-parsing/module.map
new file mode 100644
index 0000000..6d4ceee
--- /dev/null
+++ b/test/Modules/Inputs/unnecessary-module-map-parsing/module.map
@@ -0,0 +1,3 @@
+module a {
+  eader "unknown.h"
+}
diff --git a/test/Modules/Inputs/update-after-load/a.h b/test/Modules/Inputs/update-after-load/a.h
new file mode 100644
index 0000000..0ebcf3e
--- /dev/null
+++ b/test/Modules/Inputs/update-after-load/a.h
@@ -0,0 +1 @@
+namespace llvm {}
diff --git a/test/Modules/Inputs/update-after-load/b.h b/test/Modules/Inputs/update-after-load/b.h
new file mode 100644
index 0000000..64e9bfd
--- /dev/null
+++ b/test/Modules/Inputs/update-after-load/b.h
@@ -0,0 +1,2 @@
+#include "a.h"
+namespace llvm { void f(); }
diff --git a/test/Modules/Inputs/update-after-load/module.map b/test/Modules/Inputs/update-after-load/module.map
new file mode 100644
index 0000000..21e160e
--- /dev/null
+++ b/test/Modules/Inputs/update-after-load/module.map
@@ -0,0 +1 @@
+module a { header "a.h" } module b { header "b.h" }
diff --git a/test/Modules/Inputs/update-after-load/modules.timestamp b/test/Modules/Inputs/update-after-load/modules.timestamp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/Modules/Inputs/update-after-load/modules.timestamp