Merge remote-tracking branch 'origin/swift-4.1-branch' into stable
diff --git a/docs/ReleaseNotes.rst b/docs/ReleaseNotes.rst
index deffa24..d6bc7d1 100644
--- a/docs/ReleaseNotes.rst
+++ b/docs/ReleaseNotes.rst
@@ -61,7 +61,7 @@
 New Compiler Flags
 ------------------
 
-The option ....
+- --autocomplete was implemented to obtain a list of flags and its arguments. This is used for shell autocompletion.
 
 Deprecated Compiler Flags
 -------------------------
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h
index b35f436..3b5ea9f 100644
--- a/include/clang-c/Index.h
+++ b/include/clang-c/Index.h
@@ -3206,6 +3206,8 @@
   CXCallingConv_X86RegCall = 8,
   CXCallingConv_IntelOclBicc = 9,
   CXCallingConv_Win64 = 10,
+  /* Alias for compatibility with older versions of API. */
+  CXCallingConv_X86_64Win64 = CXCallingConv_Win64,
   CXCallingConv_X86_64SysV = 11,
   CXCallingConv_X86VectorCall = 12,
   CXCallingConv_Swift = 13,
diff --git a/include/clang-c/Refactor.h b/include/clang-c/Refactor.h
index 8345842..b11cfb8 100644
--- a/include/clang-c/Refactor.h
+++ b/include/clang-c/Refactor.h
@@ -49,7 +49,7 @@
  * \brief Returns a new option set.
  */
 CINDEX_LINKAGE
-CXRefactoringOptionSet clang_RefactoringOptionSet_create();
+CXRefactoringOptionSet clang_RefactoringOptionSet_create(void);
 
 /**
  * \brief Parses and returns a new option set or NULL if the given string is
diff --git a/include/clang/AST/StmtCXX.h b/include/clang/AST/StmtCXX.h
index d6c9654..77f8183 100644
--- a/include/clang/AST/StmtCXX.h
+++ b/include/clang/AST/StmtCXX.h
@@ -317,6 +317,7 @@
   unsigned NumParams;
 
   friend class ASTStmtReader;
+  friend class ASTReader;
   friend TrailingObjects;
 
   Stmt **getStoredStmts() { return getTrailingObjects<Stmt *>(); }
@@ -347,6 +348,8 @@
 
 public:
   static CoroutineBodyStmt *Create(const ASTContext &C, CtorArgs const &Args);
+  static CoroutineBodyStmt *Create(const ASTContext &C, EmptyShell,
+                                   unsigned NumParams);
 
   bool hasDependentPromiseType() const {
     return getPromiseDecl()->getType()->isDependentType();
@@ -444,6 +447,8 @@
     SubStmts[SubStmt::PromiseCall] = PromiseCall;
   }
 
+  CoreturnStmt(EmptyShell) : CoreturnStmt({}, {}, {}) {}
+
   SourceLocation getKeywordLoc() const { return CoreturnLoc; }
 
   /// \brief Retrieve the operand of the 'co_return' statement. Will be nullptr
diff --git a/include/clang/Basic/BuiltinsX86.def b/include/clang/Basic/BuiltinsX86.def
index a516bf6..6d3a478 100644
--- a/include/clang/Basic/BuiltinsX86.def
+++ b/include/clang/Basic/BuiltinsX86.def
@@ -338,8 +338,8 @@
 TARGET_HEADER_BUILTIN(_mm_lfence, "v", "h", "emmintrin.h", ALL_LANGUAGES, "sse2")
 TARGET_BUILTIN(__builtin_ia32_mfence, "v", "", "sse2")
 TARGET_HEADER_BUILTIN(_mm_mfence, "v", "h", "emmintrin.h", ALL_LANGUAGES, "sse2")
-TARGET_BUILTIN(__builtin_ia32_pause, "v", "", "sse2")
-TARGET_HEADER_BUILTIN(_mm_pause, "v", "h", "emmintrin.h", ALL_LANGUAGES, "sse2")
+TARGET_BUILTIN(__builtin_ia32_pause, "v", "", "")
+TARGET_HEADER_BUILTIN(_mm_pause, "v", "h", "emmintrin.h", ALL_LANGUAGES, "")
 TARGET_BUILTIN(__builtin_ia32_pmuludq128, "V2LLiV4iV4i", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_psraw128, "V8sV8sV8s", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_psrad128, "V4iV4iV4i", "", "sse2")
diff --git a/include/clang/Basic/DiagnosticDriverKinds.td b/include/clang/Basic/DiagnosticDriverKinds.td
index 3e9fcc6..0551452 100644
--- a/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/include/clang/Basic/DiagnosticDriverKinds.td
@@ -138,9 +138,10 @@
 def err_drv_lto_without_lld : Error<"LTO requires -fuse-ld=lld">;
 def err_drv_preamble_format : Error<
     "incorrect format for -preamble-bytes=N,END">;
-def err_invalid_ios_deployment_target : Error<
+def warn_invalid_ios_deployment_target : Warning<
   "invalid iOS deployment version '%0', iOS 10 is the maximum deployment "
-  "target for 32-bit targets">;
+  "target for 32-bit targets">, InGroup<InvalidIOSDeploymentTarget>,
+  DefaultError;
 def err_drv_conflicting_deployment_targets : Error<
   "conflicting deployment targets, both '%0' and '%1' are present in environment">;
 def err_arc_unsupported_on_runtime : Error<
diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td
index cea2838..d75a302 100644
--- a/include/clang/Basic/DiagnosticGroups.td
+++ b/include/clang/Basic/DiagnosticGroups.td
@@ -152,6 +152,9 @@
 def GNUFoldingConstant : DiagGroup<"gnu-folding-constant">;
 def FormatExtraArgs : DiagGroup<"format-extra-args">;
 def FormatZeroLength : DiagGroup<"format-zero-length">;
+
+def InvalidIOSDeploymentTarget : DiagGroup<"invalid-ios-deployment-target">;
+
 def CXX1zCompatMangling : DiagGroup<"c++1z-compat-mangling">;
 // Name of this warning in GCC.
 def NoexceptType : DiagGroup<"noexcept-type", [CXX1zCompatMangling]>;
diff --git a/include/clang/Driver/ToolChain.h b/include/clang/Driver/ToolChain.h
index eb42f12..6651491 100644
--- a/include/clang/Driver/ToolChain.h
+++ b/include/clang/Driver/ToolChain.h
@@ -315,7 +315,7 @@
 
   /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables
   /// by default.
-  virtual bool IsUnwindTablesDefault() const;
+  virtual bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const;
 
   /// \brief Test whether this toolchain defaults to PIC.
   virtual bool isPICDefault() const = 0;
diff --git a/include/clang/Lex/ModuleMap.h b/include/clang/Lex/ModuleMap.h
index 23e9fcd..eb224a6 100644
--- a/include/clang/Lex/ModuleMap.h
+++ b/include/clang/Lex/ModuleMap.h
@@ -352,6 +352,8 @@
             const LangOptions &LangOpts, const TargetInfo *Target,
             HeaderSearch &HeaderInfo);
 
+  const LangOptions &getLangOpts() const { return LangOpts; }
+
   /// \brief Destroy the module map.
   ///
   ~ModuleMap();
diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h
index 6b40781..9227b33 100644
--- a/include/clang/Serialization/ASTBitCodes.h
+++ b/include/clang/Serialization/ASTBitCodes.h
@@ -1545,9 +1545,14 @@
 
       // ARC
       EXPR_OBJC_BRIDGED_CAST,     // ObjCBridgedCastExpr
-      
+
       STMT_MS_DEPENDENT_EXISTS,   // MSDependentExistsStmt
-      EXPR_LAMBDA                 // LambdaExpr
+      EXPR_LAMBDA,                // LambdaExpr
+      STMT_COROUTINE_BODY,
+      STMT_CORETURN,
+      EXPR_COAWAIT,
+      EXPR_COYIELD,
+      EXPR_DEPENDENT_COAWAIT,
     };
 
     /// \brief The kinds of designators that can occur in a
diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp
index 6713fca..fe45b5e 100644
--- a/lib/AST/ExprCXX.cpp
+++ b/lib/AST/ExprCXX.cpp
@@ -1052,7 +1052,9 @@
           :Type->getType()->isRValueReferenceType()? VK_XValue
           :VK_RValue),
          OK_Ordinary,
-         Type->getType()->isDependentType(), true, true,
+         Type->getType()->isDependentType() ||
+             Type->getType()->getContainedDeducedType(),
+         true, true,
          Type->getType()->containsUnexpandedParameterPack()),
     Type(Type),
     LParenLoc(LParenLoc),
diff --git a/lib/AST/ODRHash.cpp b/lib/AST/ODRHash.cpp
index b191353..121724a 100644
--- a/lib/AST/ODRHash.cpp
+++ b/lib/AST/ODRHash.cpp
@@ -378,8 +378,12 @@
   assert(Record && Record->hasDefinition() &&
          "Expected non-null record to be a definition.");
 
-  if (isa<ClassTemplateSpecializationDecl>(Record)) {
-    return;
+  const DeclContext *DC = Record;
+  while (DC) {
+    if (isa<ClassTemplateSpecializationDecl>(DC)) {
+      return;
+    }
+    DC = DC->getParent();
   }
 
   AddDecl(Record);
diff --git a/lib/AST/StmtCXX.cpp b/lib/AST/StmtCXX.cpp
index 8466cd6..666f5dc 100644
--- a/lib/AST/StmtCXX.cpp
+++ b/lib/AST/StmtCXX.cpp
@@ -96,6 +96,20 @@
   return new (Mem) CoroutineBodyStmt(Args);
 }
 
+CoroutineBodyStmt *CoroutineBodyStmt::Create(const ASTContext &C, EmptyShell,
+                                             unsigned NumParams) {
+  std::size_t Size = totalSizeToAlloc<Stmt *>(
+      CoroutineBodyStmt::FirstParamMove + NumParams);
+
+  void *Mem = C.Allocate(Size, alignof(CoroutineBodyStmt));
+  auto *Result = new (Mem) CoroutineBodyStmt(CtorArgs());
+  Result->NumParams = NumParams;
+  auto *ParamBegin = Result->getStoredStmts() + SubStmt::FirstParamMove;
+  std::uninitialized_fill(ParamBegin, ParamBegin + NumParams,
+                          static_cast<Stmt *>(nullptr));
+  return Result;
+}
+
 CoroutineBodyStmt::CoroutineBodyStmt(CoroutineBodyStmt::CtorArgs const &Args)
     : Stmt(CoroutineBodyStmtClass), NumParams(Args.ParamMoves.size()) {
   Stmt **SubStmts = getStoredStmts();
diff --git a/lib/CodeGen/TargetInfo.cpp b/lib/CodeGen/TargetInfo.cpp
index c178289..eb230aa 100644
--- a/lib/CodeGen/TargetInfo.cpp
+++ b/lib/CodeGen/TargetInfo.cpp
@@ -5573,17 +5573,14 @@
   // AAPCS apparently requires runtime support functions to be soft-float, but
   // that's almost certainly for historic reasons (Thumb1 not supporting VFP
   // most likely). It's more convenient for AAPCS16_VFP to be hard-float.
-  switch (getABIKind()) {
-  case APCS:
-  case AAPCS16_VFP:
-    if (abiCC != getLLVMDefaultCC())
+
+  // The Run-time ABI for the ARM Architecture section 4.1.2 requires
+  // AEABI-complying FP helper functions to use the base AAPCS.
+  // These AEABI functions are expanded in the ARM llvm backend, all the builtin
+  // support functions emitted by clang such as the _Complex helpers follow the
+  // abiCC.
+  if (abiCC != getLLVMDefaultCC())
       BuiltinCC = abiCC;
-    break;
-  case AAPCS:
-  case AAPCS_VFP:
-    BuiltinCC = llvm::CallingConv::ARM_AAPCS;
-    break;
-  }
 }
 
 ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty,
@@ -6754,14 +6751,6 @@
       return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
     }
 
-    // Use indirect if the aggregate cannot fit into registers for
-    // passing arguments according to the ABI
-    unsigned Threshold = IsO32 ? 16 : 64;
-
-    if(getContext().getTypeSizeInChars(Ty) > CharUnits::fromQuantity(Threshold))
-      return ABIArgInfo::getIndirect(CharUnits::fromQuantity(Align), true,
-                                     getContext().getTypeAlign(Ty) / 8 > Align);
-
     // If we have reached here, aggregates are passed directly by coercing to
     // another structure type. Padding is inserted if the offset of the
     // aggregate is unaligned.
diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp
index 2be7f0f..9a858df 100644
--- a/lib/Driver/ToolChain.cpp
+++ b/lib/Driver/ToolChain.cpp
@@ -217,7 +217,7 @@
   }
 }
 
-bool ToolChain::IsUnwindTablesDefault() const {
+bool ToolChain::IsUnwindTablesDefault(const ArgList &Args) const {
   return false;
 }
 
diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp
index 2dc7fa9..ccd71f6 100644
--- a/lib/Driver/ToolChains/Clang.cpp
+++ b/lib/Driver/ToolChains/Clang.cpp
@@ -2538,7 +2538,7 @@
   bool AsynchronousUnwindTables =
       Args.hasFlag(options::OPT_fasynchronous_unwind_tables,
                    options::OPT_fno_asynchronous_unwind_tables,
-                   (getToolChain().IsUnwindTablesDefault() ||
+                   (getToolChain().IsUnwindTablesDefault(Args) ||
                     getToolChain().getSanitizerArgs().needsUnwindTables()) &&
                        !KernelOrKext);
   if (Args.hasFlag(options::OPT_funwind_tables, options::OPT_fno_unwind_tables,
diff --git a/lib/Driver/ToolChains/CrossWindows.cpp b/lib/Driver/ToolChains/CrossWindows.cpp
index 7d0c438..04b71c4 100644
--- a/lib/Driver/ToolChains/CrossWindows.cpp
+++ b/lib/Driver/ToolChains/CrossWindows.cpp
@@ -214,7 +214,7 @@
   }
 }
 
-bool CrossWindowsToolChain::IsUnwindTablesDefault() const {
+bool CrossWindowsToolChain::IsUnwindTablesDefault(const ArgList &Args) const {
   // FIXME: all non-x86 targets need unwind tables, however, LLVM currently does
   // not know how to emit them.
   return getArch() == llvm::Triple::x86_64;
diff --git a/lib/Driver/ToolChains/CrossWindows.h b/lib/Driver/ToolChains/CrossWindows.h
index 5375a63..2f66446 100644
--- a/lib/Driver/ToolChains/CrossWindows.h
+++ b/lib/Driver/ToolChains/CrossWindows.h
@@ -56,7 +56,7 @@
                         const llvm::opt::ArgList &Args);
 
   bool IsIntegratedAssemblerDefault() const override { return true; }
-  bool IsUnwindTablesDefault() const override;
+  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
   bool isPICDefault() const override;
   bool isPIEDefault() const override;
   bool isPICDefaultForced() const override;
diff --git a/lib/Driver/ToolChains/Darwin.cpp b/lib/Driver/ToolChains/Darwin.cpp
index 0e58169..be047fc 100644
--- a/lib/Driver/ToolChains/Darwin.cpp
+++ b/lib/Driver/ToolChains/Darwin.cpp
@@ -1179,13 +1179,12 @@
   unsigned Major, Minor, Micro;
   bool HadExtra;
 
-  // iOS 10 is the maximum deployment target for 32-bit targets.
-  if (iOSVersion && getTriple().isArch32Bit() &&
-      Driver::GetReleaseVersion(iOSVersion->getValue(), Major, Minor, Micro,
-                                HadExtra) &&
-      Major > 10)
-    getDriver().Diag(diag::err_invalid_ios_deployment_target)
-        << iOSVersion->getAsString(Args);
+  // The iOS deployment target that is explicitly specified via a command line
+  // option or an environment variable.
+  std::string ExplicitIOSDeploymentTargetStr;
+
+  if (iOSVersion)
+    ExplicitIOSDeploymentTargetStr = iOSVersion->getAsString(Args);
 
   // Add a macro to differentiate between m(iphone|tv|watch)os-version-min=X.Y and
   // -m(iphone|tv|watch)simulator-version-min=X.Y.
@@ -1228,13 +1227,9 @@
     if (char *env = ::getenv("WATCHOS_DEPLOYMENT_TARGET"))
       WatchOSTarget = env;
 
-    // iOS 10 is the maximum deployment target for 32-bit targets.
-    if (!iOSTarget.empty() && getTriple().isArch32Bit() &&
-        Driver::GetReleaseVersion(iOSTarget.c_str(), Major, Minor, Micro,
-                                  HadExtra) &&
-        Major > 10)
-      getDriver().Diag(diag::err_invalid_ios_deployment_target)
-          << std::string("IPHONEOS_DEPLOYMENT_TARGET=") + iOSTarget;
+    if (!iOSTarget.empty())
+      ExplicitIOSDeploymentTargetStr =
+          std::string("IPHONEOS_DEPLOYMENT_TARGET=") + iOSTarget;
 
     // If there is no command-line argument to specify the Target version and
     // no environment variable defined, see if we can set the default based
@@ -1398,12 +1393,19 @@
         HadExtra || Major >= 100 || Minor >= 100 || Micro >= 100)
       getDriver().Diag(diag::err_drv_invalid_version_number)
           << iOSVersion->getAsString(Args);
-    // iOS 10 is the maximum deployment target for 32-bit targets. If the
-    // inferred deployment target is iOS 11 or later, set it to 10.99.
+    // For 32-bit targets, the deployment target for iOS has to be earlier than
+    // iOS 11.
     if (getTriple().isArch32Bit() && Major >= 11) {
-      Major = 10;
-      Minor = 99;
-      Micro = 99;
+      // If the deployment target is explicitly specified, print a diagnostic.
+      if (!ExplicitIOSDeploymentTargetStr.empty()) {
+        getDriver().Diag(diag::warn_invalid_ios_deployment_target)
+            << ExplicitIOSDeploymentTargetStr;
+      // Otherwise, set it to 10.99.99.
+      } else {
+        Major = 10;
+        Minor = 99;
+        Micro = 99;
+      }
     }
   } else if (Platform == TvOS) {
     if (!Driver::GetReleaseVersion(TvOSVersion->getValue(), Major, Minor,
@@ -1847,8 +1849,8 @@
   return DAL;
 }
 
-bool MachO::IsUnwindTablesDefault() const {
-  return getArch() == llvm::Triple::x86_64;
+bool MachO::IsUnwindTablesDefault(const ArgList &Args) const {
+  return !UseSjLjExceptions(Args);
 }
 
 bool MachO::UseDwarfDebugFlags() const {
diff --git a/lib/Driver/ToolChains/Darwin.h b/lib/Driver/ToolChains/Darwin.h
index 6cb1d04..77c569e 100644
--- a/lib/Driver/ToolChains/Darwin.h
+++ b/lib/Driver/ToolChains/Darwin.h
@@ -216,7 +216,7 @@
 
   bool UseObjCMixedDispatch() const override { return true; }
 
-  bool IsUnwindTablesDefault() const override;
+  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
 
   RuntimeLibType GetDefaultRuntimeLibType() const override {
     return ToolChain::RLT_CompilerRT;
diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp
index bc26ee1..72a9f85 100644
--- a/lib/Driver/ToolChains/Gnu.cpp
+++ b/lib/Driver/ToolChains/Gnu.cpp
@@ -2291,7 +2291,7 @@
   CudaInstallation.print(OS);
 }
 
-bool Generic_GCC::IsUnwindTablesDefault() const {
+bool Generic_GCC::IsUnwindTablesDefault(const ArgList &Args) const {
   return getArch() == llvm::Triple::x86_64;
 }
 
diff --git a/lib/Driver/ToolChains/Gnu.h b/lib/Driver/ToolChains/Gnu.h
index cdf6100..f29342b 100644
--- a/lib/Driver/ToolChains/Gnu.h
+++ b/lib/Driver/ToolChains/Gnu.h
@@ -284,7 +284,7 @@
 
   void printVerboseInfo(raw_ostream &OS) const override;
 
-  bool IsUnwindTablesDefault() const override;
+  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
   bool isPICDefault() const override;
   bool isPIEDefault() const override;
   bool isPICDefaultForced() const override;
diff --git a/lib/Driver/ToolChains/MSVC.cpp b/lib/Driver/ToolChains/MSVC.cpp
index 9e9d943..b871c85 100644
--- a/lib/Driver/ToolChains/MSVC.cpp
+++ b/lib/Driver/ToolChains/MSVC.cpp
@@ -699,7 +699,7 @@
   return true;
 }
 
-bool MSVCToolChain::IsUnwindTablesDefault() const {
+bool MSVCToolChain::IsUnwindTablesDefault(const ArgList &Args) const {
   // Emit unwind tables by default on Win64. All non-x86_32 Windows platforms
   // such as ARM and PPC actually require unwind tables, but LLVM doesn't know
   // how to generate them yet.
diff --git a/lib/Driver/ToolChains/MSVC.h b/lib/Driver/ToolChains/MSVC.h
index 055830c..d153691 100644
--- a/lib/Driver/ToolChains/MSVC.h
+++ b/lib/Driver/ToolChains/MSVC.h
@@ -73,7 +73,7 @@
                 Action::OffloadKind DeviceOffloadKind) const override;
 
   bool IsIntegratedAssemblerDefault() const override;
-  bool IsUnwindTablesDefault() const override;
+  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
   bool isPICDefault() const override;
   bool isPIEDefault() const override;
   bool isPICDefaultForced() const override;
diff --git a/lib/Driver/ToolChains/MinGW.cpp b/lib/Driver/ToolChains/MinGW.cpp
index 7550bab..632b76d 100644
--- a/lib/Driver/ToolChains/MinGW.cpp
+++ b/lib/Driver/ToolChains/MinGW.cpp
@@ -347,7 +347,7 @@
   return new tools::MinGW::Linker(*this);
 }
 
-bool toolchains::MinGW::IsUnwindTablesDefault() const {
+bool toolchains::MinGW::IsUnwindTablesDefault(const ArgList &Args) const {
   return getArch() == llvm::Triple::x86_64;
 }
 
diff --git a/lib/Driver/ToolChains/MinGW.h b/lib/Driver/ToolChains/MinGW.h
index cf1628a..9b3d7c5 100644
--- a/lib/Driver/ToolChains/MinGW.h
+++ b/lib/Driver/ToolChains/MinGW.h
@@ -60,7 +60,7 @@
         const llvm::opt::ArgList &Args);
 
   bool IsIntegratedAssemblerDefault() const override;
-  bool IsUnwindTablesDefault() const override;
+  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
   bool isPICDefault() const override;
   bool isPIEDefault() const override;
   bool isPICDefaultForced() const override;
diff --git a/lib/Driver/ToolChains/NetBSD.h b/lib/Driver/ToolChains/NetBSD.h
index 412d081..5163ff7 100644
--- a/lib/Driver/ToolChains/NetBSD.h
+++ b/lib/Driver/ToolChains/NetBSD.h
@@ -65,7 +65,10 @@
       const llvm::opt::ArgList &DriverArgs,
       llvm::opt::ArgStringList &CC1Args) const override;
 
-  bool IsUnwindTablesDefault() const override { return true; }
+  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override {
+    return true;
+  }
+
   SanitizerMask getSupportedSanitizers() const override;
 
 protected:
diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp
index 64128df..92d6136 100644
--- a/lib/Frontend/InitPreprocessor.cpp
+++ b/lib/Frontend/InitPreprocessor.cpp
@@ -497,6 +497,8 @@
     Builder.defineMacro("__cpp_ref_qualifiers", "200710");
     Builder.defineMacro("__cpp_alias_templates", "200704");
   }
+  if (LangOpts.ThreadsafeStatics)
+    Builder.defineMacro("__cpp_threadsafe_static_init", "200806");
 
   // C++14 features.
   if (LangOpts.CPlusPlus14) {
@@ -519,6 +521,7 @@
     Builder.defineMacro("__cpp_noexcept_function_type", "201510");
     Builder.defineMacro("__cpp_capture_star_this", "201603");
     Builder.defineMacro("__cpp_if_constexpr", "201606");
+    Builder.defineMacro("__cpp_deduction_guides", "201611");
     Builder.defineMacro("__cpp_template_auto", "201606");
     Builder.defineMacro("__cpp_namespace_attributes", "201411");
     Builder.defineMacro("__cpp_enumerator_attributes", "201411");
@@ -528,8 +531,6 @@
     Builder.defineMacro("__cpp_structured_bindings", "201606");
     Builder.defineMacro("__cpp_nontype_template_args", "201411");
     Builder.defineMacro("__cpp_fold_expressions", "201603");
-    // FIXME: This is not yet listed in SD-6.
-    Builder.defineMacro("__cpp_deduction_guides", "201611");
   }
   if (LangOpts.AlignedAllocation)
     Builder.defineMacro("__cpp_aligned_new", "201606");
diff --git a/lib/Index/IndexRecordHasher.cpp b/lib/Index/IndexRecordHasher.cpp
index dd3c11d..855f902 100644
--- a/lib/Index/IndexRecordHasher.cpp
+++ b/lib/Index/IndexRecordHasher.cpp
@@ -304,7 +304,7 @@
       return COMBINE_HASH('t', TTP->getDepth(), TTP->getIndex());
     }
 
-    return COMBINE_HASH(Hasher.hash(Template));
+    return COMBINE_HASH(Hasher.hash(Template->getCanonicalDecl()));
   }
 
   // FIXME: Hash dependent template names.
diff --git a/lib/Lex/HeaderSearch.cpp b/lib/Lex/HeaderSearch.cpp
index 1ebcc0a..b9fb005 100644
--- a/lib/Lex/HeaderSearch.cpp
+++ b/lib/Lex/HeaderSearch.cpp
@@ -1108,6 +1108,7 @@
 
   // Get information about this file.
   HeaderFileInfo &FileInfo = getFileInfo(File);
+  bool isCompilingModule = ModMap.getLangOpts().isCompilingModule();
 
   // FIXME: this is a workaround for the lack of proper modules-aware support
   // for #import / #pragma once
@@ -1143,7 +1144,7 @@
     // headers find in the wild might rely only on #import and do not contain
     // controlling macros, be conservative and only try to enter textual headers
     // if such macro is present.
-    if (!FileInfo.isModuleHeader &&
+    if ((isCompilingModule || !isImport) && !FileInfo.isModuleHeader &&
         FileInfo.getControllingMacro(ExternalLookup))
       TryEnterHdr = true;
     return TryEnterHdr;
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index 19ba7b6..6f22620 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -548,6 +548,9 @@
     // __attribute__((weakref)) is basically a definition.
     if (ND->hasAttr<WeakRefAttr>()) continue;
 
+    if (isa<CXXDeductionGuideDecl>(ND))
+      continue;
+
     if (FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
       if (FD->isDefined())
         continue;
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp
index 517b38c..700cf38 100644
--- a/lib/Sema/SemaCodeComplete.cpp
+++ b/lib/Sema/SemaCodeComplete.cpp
@@ -2353,10 +2353,7 @@
 static std::string GetDefaultValueString(const ParmVarDecl *Param,
                                          const SourceManager &SM,
                                          const LangOptions &LangOpts) {
-  const Expr *defaultArg = Param->getDefaultArg();
-  if (!defaultArg)
-    return "";
-  const SourceRange SrcRange = defaultArg->getSourceRange();
+  const SourceRange SrcRange = Param->getDefaultArgRange();
   CharSourceRange CharSrcRange = CharSourceRange::getTokenRange(SrcRange);
   bool Invalid = CharSrcRange.isInvalid();
   if (Invalid)
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 63666b9..29ea2e6 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -7005,6 +7005,21 @@
           return;
         }
       }
+
+      if (cast<VarDecl>(ShadowedDecl)->hasLocalStorage()) {
+        // A variable can't shadow a local variable in an enclosing scope, if
+        // they are separated by a non-capturing declaration context.
+        for (DeclContext *ParentDC = NewDC;
+             ParentDC && !ParentDC->Equals(OldDC);
+             ParentDC = getLambdaAwareParentOfDeclContext(ParentDC)) {
+          // Only block literals, captured statements, and lambda expressions
+          // can capture; other scopes don't.
+          if (!isa<BlockDecl>(ParentDC) && !isa<CapturedDecl>(ParentDC) &&
+              !isLambdaCallOperator(ParentDC)) {
+            return;
+          }
+        }
+      }
     }
   }
 
diff --git a/lib/Serialization/ASTReaderStmt.cpp b/lib/Serialization/ASTReaderStmt.cpp
index 21adcdd..3f5da02 100644
--- a/lib/Serialization/ASTReaderStmt.cpp
+++ b/lib/Serialization/ASTReaderStmt.cpp
@@ -367,28 +367,45 @@
 }
 
 void ASTStmtReader::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+  VisitStmt(S);
+  assert(Record.peekInt() == S->NumParams);
+  Record.skipInts(1);
+  auto *StoredStmts = S->getStoredStmts();
+  for (unsigned i = 0;
+       i < CoroutineBodyStmt::SubStmt::FirstParamMove + S->NumParams; ++i)
+    StoredStmts[i] = Record.readSubStmt();
 }
 
 void ASTStmtReader::VisitCoreturnStmt(CoreturnStmt *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+  VisitStmt(S);
+  S->CoreturnLoc = Record.readSourceLocation();
+  for (auto &SubStmt: S->SubStmts)
+    SubStmt = Record.readSubStmt();
+  S->IsImplicit = Record.readInt() != 0;
 }
 
-void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+void ASTStmtReader::VisitCoawaitExpr(CoawaitExpr *E) {
+  VisitExpr(E);
+  E->KeywordLoc = ReadSourceLocation();
+  for (auto &SubExpr: E->SubExprs)
+    SubExpr = Record.readSubStmt();
+  E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
+  E->setIsImplicit(Record.readInt() != 0);
 }
 
-void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *E) {
+  VisitExpr(E);
+  E->KeywordLoc = ReadSourceLocation();
+  for (auto &SubExpr: E->SubExprs)
+    SubExpr = Record.readSubStmt();
+  E->OpaqueValue = cast_or_null<OpaqueValueExpr>(Record.readSubStmt());
 }
 
-void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+void ASTStmtReader::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
+  VisitExpr(E);
+  E->KeywordLoc = ReadSourceLocation();
+  for (auto &SubExpr: E->SubExprs)
+    SubExpr = Record.readSubStmt();
 }
 
 void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
@@ -3947,6 +3964,29 @@
       S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
       break;
     }
+
+    case STMT_COROUTINE_BODY: {
+      unsigned NumParams = Record[ASTStmtReader::NumStmtFields];
+      S = CoroutineBodyStmt::Create(Context, Empty, NumParams);
+      break;
+    }
+
+    case STMT_CORETURN:
+      S = new (Context) CoreturnStmt(Empty);
+      break;
+
+    case EXPR_COAWAIT:
+      S = new (Context) CoawaitExpr(Empty);
+      break;
+
+    case EXPR_COYIELD:
+      S = new (Context) CoyieldExpr(Empty);
+      break;
+
+    case EXPR_DEPENDENT_COAWAIT:
+      S = new (Context) DependentCoawaitExpr(Empty);
+      break;
+
     }
 
     // We hit a STMT_STOP, so we're done with this expression.
diff --git a/lib/Serialization/ASTWriterStmt.cpp b/lib/Serialization/ASTWriterStmt.cpp
index ae2e0b8..6971339 100644
--- a/lib/Serialization/ASTWriterStmt.cpp
+++ b/lib/Serialization/ASTWriterStmt.cpp
@@ -286,7 +286,7 @@
   }
 
   // Outputs
-  for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {      
+  for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
     Record.AddStmt(S->getOutputExpr(I));
     Record.AddString(S->getOutputConstraint(I));
   }
@@ -300,29 +300,48 @@
   Code = serialization::STMT_MSASM;
 }
 
-void ASTStmtWriter::VisitCoroutineBodyStmt(CoroutineBodyStmt *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+void ASTStmtWriter::VisitCoroutineBodyStmt(CoroutineBodyStmt *CoroStmt) {
+  VisitStmt(CoroStmt);
+  Record.push_back(CoroStmt->getParamMoves().size());
+  for (Stmt *S : CoroStmt->children())
+    Record.AddStmt(S);
+  Code = serialization::STMT_COROUTINE_BODY;
 }
 
 void ASTStmtWriter::VisitCoreturnStmt(CoreturnStmt *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+  VisitStmt(S);
+  Record.AddSourceLocation(S->getKeywordLoc());
+  Record.AddStmt(S->getOperand());
+  Record.AddStmt(S->getPromiseCall());
+  Record.push_back(S->isImplicit());
+  Code = serialization::STMT_CORETURN;
 }
 
-void ASTStmtWriter::VisitCoawaitExpr(CoawaitExpr *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+void ASTStmtWriter::VisitCoroutineSuspendExpr(CoroutineSuspendExpr *E) {
+  VisitExpr(E);
+  Record.AddSourceLocation(E->getKeywordLoc());
+  for (Stmt *S : E->children())
+    Record.AddStmt(S);
+  Record.AddStmt(E->getOpaqueValue());
 }
 
-void ASTStmtWriter::VisitDependentCoawaitExpr(DependentCoawaitExpr *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+void ASTStmtWriter::VisitCoawaitExpr(CoawaitExpr *E) {
+  VisitCoroutineSuspendExpr(E);
+  Record.push_back(E->isImplicit());
+  Code = serialization::EXPR_COAWAIT;
 }
 
-void ASTStmtWriter::VisitCoyieldExpr(CoyieldExpr *S) {
-  // FIXME: Implement coroutine serialization.
-  llvm_unreachable("unimplemented");
+void ASTStmtWriter::VisitCoyieldExpr(CoyieldExpr *E) {
+  VisitCoroutineSuspendExpr(E);
+  Code = serialization::EXPR_COYIELD;
+}
+
+void ASTStmtWriter::VisitDependentCoawaitExpr(DependentCoawaitExpr *E) {
+  VisitExpr(E);
+  Record.AddSourceLocation(E->getKeywordLoc());
+  for (Stmt *S : E->children())
+    Record.AddStmt(S);
+  Code = serialization::EXPR_DEPENDENT_COAWAIT;
 }
 
 void ASTStmtWriter::VisitCapturedStmt(CapturedStmt *S) {
diff --git a/test/CXX/drs/dr20xx.cpp b/test/CXX/drs/dr20xx.cpp
index b97a9a4..5819c31 100644
--- a/test/CXX/drs/dr20xx.cpp
+++ b/test/CXX/drs/dr20xx.cpp
@@ -10,7 +10,7 @@
 #define static_assert(...) _Static_assert(__VA_ARGS__)
 #endif
 
-namespace dr2094 { // dr2094: 5.0
+namespace dr2094 { // dr2094: 5
   struct A { int n; };
   struct B { volatile int n; };
   static_assert(__is_trivially_copyable(volatile int), "");
diff --git a/test/CXX/drs/dr4xx.cpp b/test/CXX/drs/dr4xx.cpp
index a55bb91..a30b82f 100644
--- a/test/CXX/drs/dr4xx.cpp
+++ b/test/CXX/drs/dr4xx.cpp
@@ -1202,7 +1202,7 @@
   long n2 = s2;
 }
 
-namespace dr496 { // dr496: sup dr2094
+namespace dr496 { // dr496: sup 2094
   struct A { int n; };
   struct B { volatile int n; };
   int check1[ __is_trivially_copyable(const int) ? 1 : -1];
diff --git a/test/CodeCompletion/uninstantiated_params.cpp b/test/CodeCompletion/uninstantiated_params.cpp
new file mode 100644
index 0000000..57a520d
--- /dev/null
+++ b/test/CodeCompletion/uninstantiated_params.cpp
@@ -0,0 +1,13 @@
+template <class T>
+struct unique_ptr {
+  typedef T* pointer;
+
+  void reset(pointer ptr = pointer());
+};
+
+void test() {
+  unique_ptr<int> x;
+  x.
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:5 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // CHECK-CC1: [#void#]reset({#<#unique_ptr<int>::pointer ptr = pointer()#>#})
+}
diff --git a/test/CodeGen/arm-float-helpers.c b/test/CodeGen/arm-float-helpers.c
new file mode 100644
index 0000000..3036330
--- /dev/null
+++ b/test/CodeGen/arm-float-helpers.c
@@ -0,0 +1,233 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabihf %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi -target-feature "+soft-float" -target-feature "+soft-float-abi" %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi -target-feature "+soft-float" %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -meabi gnu %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -target-feature "+soft-float" -target-feature "+soft-float-abi" -meabi gnu %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabi -target-feature "+soft-float" -meabi gnu %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabihf %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-eabihf -meabi gnu %s | FileCheck %s
+
+// The Runtime ABI for the ARM Architecture IHI0043 section 4.1.2 The
+// floating-point helper functions to always use the base AAPCS (soft-float)
+// calling convention.
+//
+// These helper functions such as __aeabi_fadd are not explicitly called by
+// clang, instead they are generated by the ARMISelLowering when they are
+// needed; clang relies on llvm to use the base AAPCS.
+//
+// In this test we check that clang is not directly calling the __aeabi_
+// functions. We rely on llvm to test that the base AAPCS is used for any
+// __aeabi_ function from 4.1.2 that is used.
+//
+// When compiled to an object file with -mfloat-abi=soft each function F
+// below should result in a call to __aeabi_F. If clang is changed to call any
+// of these functions directly the test will need to be altered to check that
+// arm_aapcscc is used.
+//
+// Note that it is only the functions in 4.1.2 that must use the base AAPCS,
+// other runtime functions such as the _Complex helper routines are not covered.
+
+float fadd(float a, float b) { return a + b; }
+// CHECK-LABEL: define float @fadd(float %a, float %b)
+// CHECK-NOT: __aeabi_fadd
+// CHECK: %add = fadd float  {{.*}}, {{.*}}
+
+float fdiv(float a, float b) { return a / b; }
+// CHECK-LABEL: define float @fdiv(float %a, float %b)
+// CHECK-NOT: __aeabi_fdiv
+// CHECK: %div = fdiv float  {{.*}}, {{.*}}
+
+float fmul(float a, float b) { return a * b; }
+// CHECK-LABEL: define float @fmul(float %a, float %b)
+// CHECK-NOT: __aeabi_fmul
+// CHECK: %mul = fmul float  {{.*}}, {{.*}}
+
+float fsub(float a, float b) { return a - b; }
+// CHECK-LABEL: define float @fsub(float %a, float %b)
+// CHECK-NOT: __aeabi_fsub
+// CHECK: %sub = fsub float  {{.*}}, {{.*}}
+
+int fcmpeq(float a, float b) { return a == b; }
+// CHECK-LABEL: define i32 @fcmpeq(float %a, float %b)
+// CHECK-NOT: __aeabi_fcmpeq
+// CHECK: %cmp = fcmp oeq float  {{.*}}, {{.*}}
+
+int fcmplt(float a, float b) { return a < b; }
+// CHECK-LABEL: define i32 @fcmplt(float %a, float %b)
+// CHECK-NOT: __aeabi_fcmplt
+// CHECK: %cmp = fcmp olt float  {{.*}}, {{.*}}
+
+int fcmple(float a, float b) { return a <= b; }
+// CHECK-LABEL: define i32 @fcmple(float %a, float %b)
+// CHECK-NOT: __aeabi_fcmple
+// CHECK: %cmp = fcmp ole float  {{.*}}, {{.*}}
+
+int fcmpge(float a, float b) { return a >= b; }
+// CHECK-LABEL: define i32 @fcmpge(float %a, float %b)
+// CHECK-NOT: __aeabi_fcmpge
+// CHECK: %cmp = fcmp oge float  {{.*}}, {{.*}}
+
+int fcmpgt(float a, float b) { return a > b; }
+// CHECK-LABEL: define i32 @fcmpgt(float %a, float %b)
+// CHECK-NOT: __aeabi_fcmpgt
+// CHECK: %cmp = fcmp ogt float  {{.*}}, {{.*}}
+
+int fcmpun(float a, float b) { return __builtin_isunordered(a, b); }
+// CHECK-LABEL: define i32 @fcmpun(float %a, float %b)
+// CHECK-NOT: __aeabi_fcmpun
+// CHECK: %cmp = fcmp uno double %conv, %conv1
+
+double dadd(double a, double b) { return a + b; }
+// CHECK-LABEL: define double @dadd(double %a, double %b)
+// CHECK-NOT: __aeabi_dadd
+// CHECK: %add = fadd double  {{.*}}, {{.*}}
+
+double ddiv(double a, double b) { return a / b; }
+// CHECK-LABEL: define double @ddiv(double %a, double %b)
+// CHECK-NOT: __aeabi_ddiv
+// CHECK: %div = fdiv double  {{.*}}, {{.*}}
+
+double dmul(double a, double b) { return a * b; }
+// CHECK-LABEL: define double @dmul(double %a, double %b)
+// CHECK-NOT: __aeabi_dmul
+// CHECK: %mul = fmul double  {{.*}}, {{.*}}
+
+double dsub(double a, double b) { return a - b; }
+// CHECK-LABEL: define double @dsub(double %a, double %b)
+// CHECK-NOT: __aeabi_dsub
+// CHECK: %sub = fsub double  {{.*}}, {{.*}}
+
+int dcmpeq(double a, double b) { return a == b; }
+// CHECK-LABEL: define i32 @dcmpeq(double %a, double %b)
+// CHECK-NOT: __aeabi_dcmpeq
+// CHECK: %cmp = fcmp oeq double  {{.*}}, {{.*}}
+
+int dcmplt(double a, double b) { return a < b; }
+// CHECK-LABEL: define i32 @dcmplt(double %a, double %b)
+// CHECK-NOT: __aeabi_dcmplt
+// CHECK: %cmp = fcmp olt double  {{.*}}, {{.*}}
+
+int dcmple(double a, double b) { return a <= b; }
+// CHECK-LABEL: define i32 @dcmple(double %a, double %b)
+// CHECK-NOT: __aeabi_dcmple
+// CHECK: %cmp = fcmp ole double  {{.*}}, {{.*}}
+
+int dcmpge(double a, double b) { return a >= b; }
+// CHECK-LABEL: define i32 @dcmpge(double %a, double %b)
+// CHECK-NOT: __aeabi_dcmpge
+// CHECK: %cmp = fcmp oge double  {{.*}}, {{.*}}
+
+int dcmpgt(double a, double b) { return a > b; }
+// CHECK-LABEL: define i32 @dcmpgt(double %a, double %b)
+// CHECK-NOT: __aeabi_dcmpgt
+// CHECK: %cmp = fcmp ogt double  {{.*}}, {{.*}}
+
+int dcmpun(double a, double b) { return __builtin_isunordered(a, b); }
+// CHECK-LABEL: define i32 @dcmpun(double %a, double %b)
+// CHECK-NOT: __aeabi_dcmpun
+// CHECK: %cmp = fcmp uno double  {{.*}}, {{.*}}
+
+int d2iz(double a) { return (int)a; }
+// CHECK-LABEL: define i32 @d2iz(double %a)
+// CHECK-NOT: __aeabi_d2iz
+// CHECK: %conv = fptosi double  {{.*}} to i32
+
+unsigned int d2uiz(double a) { return (unsigned int)a; }
+// CHECK-LABEL: define i32 @d2uiz(double %a)
+// CHECK-NOT: __aeabi_d2uiz
+// CHECK: %conv = fptoui double  {{.*}} to i32
+
+long long d2lz(double a) { return (long long)a; }
+// CHECK-LABEL: define i64 @d2lz(double %a)
+// CHECK-NOT: __aeabi_d2lz
+// CHECK: %conv = fptosi double  {{.*}} to i64
+
+unsigned long long d2ulz(double a) { return (unsigned long long)a; }
+// CHECK-LABEL: define i64 @d2ulz(double %a)
+// CHECK-NOT: __aeabi_d2ulz
+// CHECK: %conv = fptoui double  {{.*}} to i64
+
+int f2iz(float a) { return (int)a; }
+// CHECK-LABEL: define i32 @f2iz(float %a)
+// CHECK-NOT: __aeabi_f2iz
+// CHECK: %conv = fptosi float  {{.*}} to i32
+
+unsigned int f2uiz(float a) { return (unsigned int)a; }
+// CHECK-LABEL: define i32 @f2uiz(float %a)
+// CHECK-NOT: __aeabi_f2uiz
+// CHECK: %conv = fptoui float  {{.*}} to i32
+
+long long f2lz(float a) { return (long long)a; }
+// CHECK-LABEL: define i64 @f2lz(float %a)
+// CHECK-NOT: __aeabi_f2lz
+// CHECK: %conv = fptosi float  {{.*}} to i64
+
+unsigned long long f2ulz(float a) { return (unsigned long long)a; }
+// CHECK-LABEL: define i64 @f2ulz(float %a)
+// CHECK-NOT: __aeabi_f2ulz
+// CHECK: %conv = fptoui float  {{.*}} to i64
+
+float d2f(double a) { return (float)a; }
+// CHECK-LABEL: define float @d2f(double %a)
+// CHECK-NOT: __aeabi_d2f
+// CHECK: %conv = fptrunc double  {{.*}} to float
+
+double f2d(float a) { return (double)a; }
+// CHECK-LABEL: define double @f2d(float %a)
+// CHECK-NOT: __aeabi_f2d
+// CHECK: %conv = fpext float  {{.*}} to double
+
+double i2d(int a) { return (double)a; }
+// CHECK-LABEL: define double @i2d(i32 %a)
+// CHECK-NOT: __aeabi_i2d
+// CHECK: %conv = sitofp i32  {{.*}} to double
+
+double ui2d(unsigned int a) { return (double)a; }
+// CHECK-LABEL: define double @ui2d(i32 %a)
+// CHECK-NOT: __aeabi_ui2d
+// CHECK: %conv = uitofp i32  {{.*}} to double
+
+double l2d(long long a) { return (double)a; }
+// CHECK-LABEL: define double @l2d(i64 %a)
+// CHECK-NOT: __aeabi_l2d
+// CHECK: %conv = sitofp i64  {{.*}} to double
+
+double ul2d(unsigned long long a) { return (unsigned long long)a; }
+// CHECK-LABEL: define double @ul2d(i64 %a)
+// CHECK-NOT: __aeabi_ul2d
+// CHECK: %conv = uitofp i64  {{.*}} to double
+
+float i2f(int a) { return (int)a; }
+// CHECK-LABEL: define float @i2f(i32 %a)
+// CHECK-NOT: __aeabi_i2f
+// CHECK: %conv = sitofp i32  {{.*}} to float
+
+float ui2f(unsigned int a) { return (unsigned int)a; }
+// CHECK-LABEL: define float @ui2f(i32 %a)
+// CHECK-NOT: __aeabi_ui2f
+// CHECK: %conv = uitofp i32  {{.*}} to float
+
+float l2f(long long a) { return (long long)a; }
+// CHECK-LABEL: define float @l2f(i64 %a)
+// CHECK-NOT: __aeabi_l2f
+// CHECK: %conv = sitofp i64  {{.*}} to float
+
+float ul2f(unsigned long long a) { return (unsigned long long)a; }
+// CHECK-LABEL: define float @ul2f(i64 %a)
+// CHECK-NOT: __aeabi_ul2f
+// CHECK: %conv = uitofp i64  {{.*}} to float
+
+// Functions in section 4.1.2 not used by llvm and don't easily map directly to
+// C source code.
+// cfcmpeq
+// cfcmple
+// cfrcmple
+// cdcmpeq
+// cdcmple
+// cdrcmple
+// frsub
+// drsub
diff --git a/test/CodeGen/complex-math.c b/test/CodeGen/complex-math.c
index 96c7ad9..8792ca1 100644
--- a/test/CodeGen/complex-math.c
+++ b/test/CodeGen/complex-math.c
@@ -2,7 +2,8 @@
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple x86_64-pc-win64 -o - | FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple i686-unknown-unknown -o - | FileCheck %s --check-prefix=X86
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple powerpc-unknown-unknown -o - | FileCheck %s --check-prefix=PPC
-// RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabihf -o - | FileCheck %s --check-prefix=ARM
+// RUN %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabi -o - | FileCheck %s --check-prefix=ARM
+// RUN: %clang_cc1 %s -O1 -emit-llvm -triple armv7-none-linux-gnueabihf -o - | FileCheck %s --check-prefix=ARMHF
 // RUN: %clang_cc1 %s -O1 -emit-llvm -triple thumbv7k-apple-watchos2.0 -o - -target-abi aapcs16 | FileCheck %s --check-prefix=ARM7K
 
 float _Complex add_float_rr(float a, float b) {
@@ -476,8 +477,15 @@
 
 // Check that the libcall will obtain proper calling convention on ARM
 _Complex double foo(_Complex double a, _Complex double b) {
+  // These functions are not defined as floating point helper functions in
+  // Run-time ABI for the ARM architecture document so they must not always
+  // use the base AAPCS.
+
   // ARM-LABEL: @foo(
-  // ARM: call arm_aapcscc { double, double } @__muldc3
+  // ARM: call void { double, double } @__muldc3
+
+  // ARMHF-LABEL: @foo(
+  // ARMHF: call { double, double } @__muldc3
 
   // ARM7K-LABEL: @foo(
   // ARM7K: call { double, double } @__muldc3
diff --git a/test/CodeGen/mips-aggregate-arg.c b/test/CodeGen/mips-aggregate-arg.c
deleted file mode 100644
index ccf30df..0000000
--- a/test/CodeGen/mips-aggregate-arg.c
+++ /dev/null
@@ -1,38 +0,0 @@
-// RUN: %clang_cc1 -triple mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | FileCheck -check-prefix=O32 %s
-// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  -target-abi n32 | FileCheck -check-prefix=N32-N64 %s
-// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  -target-abi n64 | FileCheck -check-prefix=N32-N64 %s
-
-struct t1 {
-  char t1[10];
-};
-
-struct t2 {
-  char t2[20];
-};
-
-struct t3 {
-  char t3[65];
-};
-
-extern struct t1 g1;
-extern struct t2 g2;
-extern struct t3 g3;
-extern void f1(struct t1);
-extern void f2(struct t2);
-extern void f3(struct t3);
-
-void f() {
-
-// O32:  call void @f1(i32 inreg %{{[0-9]+}}, i32 inreg %{{[0-9]+}}, i16 inreg %{{[0-9]+}})
-// O32:  call void @f2(%struct.t2* byval align 4 %{{.*}})
-// O32:  call void @f3(%struct.t3* byval align 4 %{{.*}})
-
-// N32-N64:  call void @f1(i64 inreg %{{[0-9]+}}, i16 inreg %{{[0-9]+}})
-// N32-N64:  call void @f2(i64 inreg %{{[0-9]+}}, i64 inreg %{{[0-9]+}}, i32 inreg %{{[0-9]+}})
-// N32-N64:  call void @f3(%struct.t3* byval align 8 %{{.*}})
-
-  f1(g1);
-  f2(g2);
-  f3(g3);
-}
-
diff --git a/test/CodeGen/pause.c b/test/CodeGen/pause.c
new file mode 100644
index 0000000..1a8e10a
--- /dev/null
+++ b/test/CodeGen/pause.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -ffreestanding %s -triple=i386-pc-win32 -target-feature -sse2 -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=i386-pc-win32 -target-feature +sse2 -emit-llvm -o - -Wall -Werror | FileCheck %s
+
+
+#include <x86intrin.h>
+
+void test_mm_pause() {
+  // CHECK-LABEL: test_mm_pause
+  // CHECK: call void @llvm.x86.sse2.pause()
+  return _mm_pause();
+}
diff --git a/test/Driver/clang-translation.c b/test/Driver/clang-translation.c
index 7c7b2f0..545951d 100644
--- a/test/Driver/clang-translation.c
+++ b/test/Driver/clang-translation.c
@@ -69,6 +69,14 @@
 // ARMV7_HARDFLOAT-NOT: "-msoft-float"
 // ARMV7_HARDFLOAT: "-x" "c"
 
+// RUN: %clang -target arm64-apple-ios10 -### -S %s -arch arm64 2>&1 | \
+// RUN: FileCheck -check-prefix=ARM64-APPLE %s
+// ARM64-APPLE: -munwind-table
+
+// RUN: %clang -target armv7k-apple-watchos4.0 -### -S %s -arch armv7k 2>&1 | \
+// RUN: FileCheck -check-prefix=ARMV7K-APPLE %s
+// ARMV7K-APPLE: -munwind-table
+
 // RUN: %clang -target arm-linux -### -S %s -march=armv5e 2>&1 | \
 // RUN: FileCheck -check-prefix=ARMV5E %s
 // ARMV5E: clang
diff --git a/test/Driver/darwin-version.c b/test/Driver/darwin-version.c
index 12c7ef6..3ff49ac 100644
--- a/test/Driver/darwin-version.c
+++ b/test/Driver/darwin-version.c
@@ -26,6 +26,8 @@
 
 // RUN: %clang -target armv7-apple-ios11.1 -c -### %s 2>&1 | \
 // RUN: FileCheck --check-prefix=CHECK-VERSION-IOS7 %s
+// RUN: %clang -target armv7-apple-ios9 -Wno-missing-sysroot -isysroot SDKs/iPhoneOS11.0.sdk -c -### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-VERSION-IOS7 %s
 // CHECK-VERSION-IOS7: thumbv7-apple-ios10.99.99
 
 // RUN: env IPHONEOS_DEPLOYMENT_TARGET=11.0 \
@@ -45,6 +47,10 @@
 // RUN: FileCheck --check-prefix=CHECK-VERSION-IOS11 %s
 // CHECK-VERSION-IOS11: arm64-apple-ios11.1.0
 
+// RUN: %clang -target armv7-apple-ios9.0 -miphoneos-version-min=11.0 -c -Wno-invalid-ios-deployment-target -### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-VERSION-IOS12 %s
+// CHECK-VERSION-IOS12: thumbv7-apple-ios11.0.0
+
 // RUN: %clang -target i686-apple-darwin8 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX4 %s
 // RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.4 -c %s -### 2>&1 | \
diff --git a/test/Index/Store/json-with-module.m.json b/test/Index/Store/json-with-module.m.json
index bb020cc..5c9bf3a 100644
--- a/test/Index/Store/json-with-module.m.json
+++ b/test/Index/Store/json-with-module.m.json
@@ -22,7 +22,7 @@
     {
       "kind": "type-alias",
       "lang": "C",
-      "usr": "c:ModTop.h@T@ModTopStruct",
+      "usr": "c:@T@ModTopStruct",
       "name": "ModTopStruct",
       "roles": "Def,Ref,RelCont"
     },
diff --git a/test/Index/Store/record-hash-crash.cpp b/test/Index/Store/record-hash-crash.cpp
index 8239901..3d71ac9 100644
--- a/test/Index/Store/record-hash-crash.cpp
+++ b/test/Index/Store/record-hash-crash.cpp
@@ -10,3 +10,22 @@
 // CHECK: [[@LINE+1]]:6 | function/C
 auto getit() { return []() {}; }
 }
+
+namespace crash2 {
+// CHECK: [[@LINE+2]]:7 | class(Gen)/C++ | c:@N@crash2@ST>1#T@Foo | Ref,RelCont | rel: 1
+template <typename T>
+class Foo; // canonical decl
+
+// CHECK: [[@LINE+2]]:7 | class(Gen)/C++ | c:@N@crash2@ST>1#T@Foo | Def,RelChild | rel: 1
+template <typename T>
+class Foo {};
+
+// CHECK: [[@LINE+2]]:8 | struct(Gen)/C++ | c:@N@crash2@ST>1#t>1#pT@Wrapper | Def,RelChild | rel: 1
+template <template <typename... ARGS> class TYPE>
+struct Wrapper {};
+
+// CHECK: [[@LINE+3]]:8 | struct(Gen,TS)/C++ | c:@N@crash2@S@Wrapper>#@N@crash2@ST>1#T@Foo | Def,RelChild,RelSpecialization | rel: 2
+// CHECK:	RelSpecialization | c:@N@crash2@ST>1#t>1#pT@Wrapper
+template <>
+struct Wrapper<Foo> {};
+}
diff --git a/test/Lexer/cxx-features.cpp b/test/Lexer/cxx-features.cpp
index 24f38e5..04821bd 100644
--- a/test/Lexer/cxx-features.cpp
+++ b/test/Lexer/cxx-features.cpp
@@ -4,7 +4,7 @@
 // RUN: %clang_cc1 -std=c++14 -fcxx-exceptions -fsized-deallocation -verify %s
 // RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fsized-deallocation -verify %s
 // RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fsized-deallocation -fconcepts-ts -DCONCEPTS_TS=1 -verify %s
-// RUN: %clang_cc1 -fno-rtti -verify %s -DNO_EXCEPTIONS -DNO_RTTI
+// RUN: %clang_cc1 -fno-rtti -fno-threadsafe-statics -verify %s -DNO_EXCEPTIONS -DNO_RTTI -DNO_THREADSAFE_STATICS
 // RUN: %clang_cc1 -fcoroutines-ts -DNO_EXCEPTIONS -DCOROUTINES -verify %s
 
 // expected-no-diagnostics
@@ -22,19 +22,15 @@
 
 // --- C++17 features ---
 
-#if check(variadic_using, 0, 0, 0, 201611) // FIXME: provisional name
-#error "wrong value for __cpp_variadic_using"
-#endif
-
 #if check(hex_float, 0, 0, 0, 201603)
 #error "wrong value for __cpp_hex_float"
 #endif
 
-#if check(inline_variables, 0, 0, 0, 201606) // FIXME: provisional name
+#if check(inline_variables, 0, 0, 0, 201606)
 #error "wrong value for __cpp_inline_variables"
 #endif
 
-#if check(aligned_new, 0, 0, 0, 201606) // FIXME: provisional name
+#if check(aligned_new, 0, 0, 0, 201606)
 #error "wrong value for __cpp_aligned_new"
 #endif
 
@@ -52,7 +48,7 @@
 
 // constexpr checked below
 
-#if check(if_constexpr, 0, 0, 0, 201606) // FIXME: provisional name
+#if check(if_constexpr, 0, 0, 0, 201606)
 #error "wrong value for __cpp_if_constexpr"
 #endif
 
@@ -60,7 +56,11 @@
 
 // static_assert checked below
 
-#if check(template_auto, 0, 0, 0, 201606) // FIXME: provisional name
+#if check(deduction_guides, 0, 0, 0, 201611)
+#error "wrong value for __cpp_deduction_guides"
+#endif
+
+#if check(template_auto, 0, 0, 0, 201606)
 #error "wrong value for __cpp_template_auto"
 #endif
 
@@ -80,6 +80,10 @@
 
 // inheriting_constructors checked below
 
+#if check(variadic_using, 0, 0, 0, 201611)
+#error "wrong value for __cpp_variadic_using"
+#endif
+
 #if check(aggregate_bases, 0, 0, 0, 201603)
 #error "wrong value for __cpp_aggregate_bases"
 #endif
@@ -96,10 +100,6 @@
 #error "wrong value for __cpp_template_template_args"
 #endif
 
-#if check(deduction_guides, 0, 0, 0, 201611) // FIXME: provisional name
-#error "wrong value for __cpp_deduction_guides"
-#endif
-
 // --- C++14 features ---
 
 #if check(binary_literals, 0, 0, 201304, 201304)
@@ -163,6 +163,10 @@
 #error "wrong value for __cpp_user_defined_literals"
 #endif
 
+#if defined(NO_THREADSAFE_STATICS) ? check(threadsafe_static_init, 0, 0, 0, 0) : check(threadsafe_static_init, 200806, 200806, 200806, 200806)
+#error "wrong value for __cpp_threadsafe_static_init"
+#endif
+
 #if check(lambdas, 0, 200907, 200907, 200907)
 #error "wrong value for __cpp_lambdas"
 #endif
diff --git a/test/Modules/Inputs/import-textual/x.h b/test/Modules/Inputs/import-textual/x.h
new file mode 100644
index 0000000..9b41ccd
--- /dev/null
+++ b/test/Modules/Inputs/import-textual/x.h
@@ -0,0 +1,6 @@
+#ifndef RANDOM_DEP
+
+@interface X
+@end
+
+#endif // RANDOM_DEP
diff --git a/test/Modules/import-textual-nomodules.m b/test/Modules/import-textual-nomodules.m
new file mode 100644
index 0000000..7cf8c1e
--- /dev/null
+++ b/test/Modules/import-textual-nomodules.m
@@ -0,0 +1,8 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps -I%S/Inputs/import-textual -fmodules-cache-path=%t %s -verify
+
+// expected-no-diagnostics
+
+#import "x.h"
+#import "x.h"
+
diff --git a/test/PCH/coroutines.cpp b/test/PCH/coroutines.cpp
new file mode 100644
index 0000000..46a2872
--- /dev/null
+++ b/test/PCH/coroutines.cpp
@@ -0,0 +1,77 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %s -verify -std=c++1z -fcoroutines-ts %s
+
+// Test with pch.
+// RUN: %clang_cc1 -std=c++1z -fcoroutines-ts  -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -verify -std=c++1z -fcoroutines-ts %s
+
+#ifndef HEADER
+#define HEADER
+
+namespace std::experimental {
+template <typename... T> struct coroutine_traits;
+
+template <class Promise = void> struct coroutine_handle {
+  coroutine_handle() = default;
+  static coroutine_handle from_address(void *) noexcept;
+};
+template <> struct coroutine_handle<void> {
+  static coroutine_handle from_address(void *) noexcept;
+  coroutine_handle() = default;
+  template <class PromiseType>
+  coroutine_handle(coroutine_handle<PromiseType>) noexcept;
+};
+}
+
+struct suspend_always {
+  bool await_ready() noexcept;
+  void await_suspend(std::experimental::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+template <typename... Args> struct std::experimental::coroutine_traits<void, Args...> {
+  struct promise_type {
+    void get_return_object() noexcept;
+    suspend_always initial_suspend() noexcept;
+    suspend_always final_suspend() noexcept;
+    void return_void() noexcept;
+    suspend_always yield_value(int) noexcept;
+    promise_type();
+    ~promise_type() noexcept;
+    void unhandled_exception() noexcept;
+  };
+};
+
+template <typename... Args> struct std::experimental::coroutine_traits<int, Args...> {
+  struct promise_type {
+    int get_return_object() noexcept;
+    suspend_always initial_suspend() noexcept;
+    suspend_always final_suspend() noexcept;
+    void return_value(int) noexcept;
+    promise_type();
+    ~promise_type() noexcept;
+    void unhandled_exception() noexcept;
+  };
+};
+
+template <typename T>
+void f(T x) {  // checks coawait_expr and coroutine_body_stmt
+  co_yield 42; // checks coyield_expr
+  co_await x;  // checks dependent_coawait
+  co_return;   // checks coreturn_stmt
+}
+
+template <typename T>
+int f2(T x) {  // checks coawait_expr and coroutine_body_stmt
+  co_return x;   // checks coreturn_stmt with expr
+}
+
+#else
+
+// expected-no-diagnostics
+void g() {
+  f(suspend_always{});
+  f2(42);
+}
+
+#endif
diff --git a/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp b/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
index 159b707..9232a8b 100644
--- a/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ b/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -1,4 +1,9 @@
-// RUN: %clang_cc1 -std=c++1z -verify %s
+// RUN: %clang_cc1 -std=c++1z -verify %s -DERRORS
+// RUN: %clang_cc1 -std=c++1z -verify %s -UERRORS
+
+// This test is split into two because we only produce "undefined internal"
+// warnings if we didn't produce any errors.
+#if ERRORS
 
 namespace std {
   using size_t = decltype(sizeof(0));
@@ -280,3 +285,44 @@
     scoped_lock l = {};
   }
 }
+
+namespace dependent {
+  template<typename T> struct X {
+    X(T);
+  };
+  template<typename T> int Var(T t) {
+    X x(t);
+    return X(x) + 1; // expected-error {{invalid operands}}
+  }
+  template<typename T> int Cast(T t) {
+    return X(X(t)) + 1; // expected-error {{invalid operands}}
+  }
+  template<typename T> int New(T t) {
+    return X(new X(t)) + 1; // expected-error {{invalid operands}}
+  };
+  template int Var(float); // expected-note {{instantiation of}}
+  template int Cast(float); // expected-note {{instantiation of}}
+  template int New(float); // expected-note {{instantiation of}}
+  template<typename T> int operator+(X<T>, int);
+  template int Var(int);
+  template int Cast(int);
+  template int New(int);
+}
+
+#else
+
+// expected-no-diagnostics
+namespace undefined_warnings {
+  // Make sure we don't get an "undefined but used internal symbol" warning for the deduction guide here.
+  namespace {
+    template <typename T>
+    struct TemplDObj {
+      explicit TemplDObj(T func) noexcept {}
+    };
+    auto test1 = TemplDObj(0);
+
+    TemplDObj(float) -> TemplDObj<double>;
+    auto test2 = TemplDObj(.0f);
+  }
+}
+#endif
diff --git a/test/SemaCXX/warn-shadow.cpp b/test/SemaCXX/warn-shadow.cpp
index d5f0623..3d09c78 100644
--- a/test/SemaCXX/warn-shadow.cpp
+++ b/test/SemaCXX/warn-shadow.cpp
@@ -213,3 +213,12 @@
 void handleLinkageSpec() {
   typedef void externC; // expected-warning {{declaration shadows a typedef in the global namespace}}
 }
+
+namespace PR33947 {
+void f(int a) {
+  struct A {
+    void g(int a) {}
+    A() { int a; }
+  };
+}
+}
diff --git a/www/cxx_dr_status.html b/www/cxx_dr_status.html
index d852dec..b192036 100644
--- a/www/cxx_dr_status.html
+++ b/www/cxx_dr_status.html
@@ -591,7 +591,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#92">92</a></td>
     <td>CD4</td>
     <td>Should <I>exception-specification</I>s be part of the type system?</td>
-    <td class="svn" align="center">Clang 4 (C++17 onwards)</td>
+    <td class="full" align="center">Clang 4 (C++17 onwards)</td>
   </tr>
   <tr id="93">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#93">93</a></td>
@@ -813,7 +813,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#129">129</a></td>
     <td>CD3</td>
     <td>Stability of uninitialized auto variables</td>
-    <td class="svn" align="center">Duplicate of <a href="#616">616</a></td>
+    <td class="full" align="center">Duplicate of <a href="#616">616</a></td>
   </tr>
   <tr id="130">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#130">130</a></td>
@@ -1480,7 +1480,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#240">240</a></td>
     <td>CD3</td>
     <td>Uninitialized values and undefined behavior</td>
-    <td class="svn" align="center">Duplicate of <a href="#616">616</a></td>
+    <td class="full" align="center">Duplicate of <a href="#616">616</a></td>
   </tr>
   <tr id="241">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#241">241</a></td>
@@ -1594,7 +1594,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#259">259</a></td>
     <td>CD1</td>
     <td>Restrictions on explicit specialization and instantiation</td>
-    <td class="svn" align="center">Clang 4</td>
+    <td class="full" align="center">Clang 4</td>
   </tr>
   <tr class="open" id="260">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#260">260</a></td>
@@ -1913,7 +1913,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#312">312</a></td>
     <td>CD3</td>
     <td>&#8220;use&#8221; of invalid pointer value not defined</td>
-    <td class="svn" align="center">Duplicate of <a href="#616">616</a></td>
+    <td class="full" align="center">Duplicate of <a href="#616">616</a></td>
   </tr>
   <tr id="313">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#313">313</a></td>
@@ -2279,7 +2279,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#373">373</a></td>
     <td>C++11</td>
     <td>Lookup on namespace qualified name in using-directive</td>
-    <td class="svn" align="center">SVN</td>
+    <td class="svn" align="center">Clang 5</td>
   </tr>
   <tr id="374">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#374">374</a></td>
@@ -3017,7 +3017,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#496">496</a></td>
     <td>CD3</td>
     <td>Is a volatile-qualified type really a POD?</td>
-    <td class="none" align="center">Superseded by <a href="#dr2094">dr2094</a></td>
+    <td class="svn" align="center">Superseded by <a href="#2094">2094</a></td>
   </tr>
   <tr id="497">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#497">497</a></td>
@@ -3541,7 +3541,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#583">583</a></td>
     <td>CD3</td>
     <td>Relational pointer comparisons against the null pointer constant</td>
-    <td class="svn" align="center">Clang 4</td>
+    <td class="full" align="center">Clang 4</td>
   </tr>
   <tr id="584">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#584">584</a></td>
@@ -3613,7 +3613,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#595">595</a></td>
     <td>dup</td>
     <td>Exception specifications in templates instantiated from class bodies</td>
-    <td class="svn" align="center">Duplicate of <a href="#1330">1330</a></td>
+    <td class="full" align="center">Duplicate of <a href="#1330">1330</a></td>
   </tr>
   <tr class="open" id="596">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#596">596</a></td>
@@ -3739,7 +3739,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#616">616</a></td>
     <td>CD3</td>
     <td>Definition of &#8220;indeterminate value&#8221;</td>
-    <td class="svn" align="center">Clang 4</td>
+    <td class="full" align="center">Clang 4</td>
   </tr>
   <tr class="open" id="617">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#617">617</a></td>
@@ -5839,7 +5839,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1004">1004</a></td>
     <td>C++11</td>
     <td>Injected-class-names as arguments for template template parameters</td>
-    <td class="svn" align="center">SVN</td>
+    <td class="svn" align="center">Clang 5</td>
   </tr>
   <tr id="1005">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#1005">1005</a></td>
@@ -7093,7 +7093,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1213">1213</a></td>
     <td>CD3</td>
     <td>Array subscripting and xvalues</td>
-    <td class="svn" align="center">Clang 4</td>
+    <td class="full" align="center">Clang 4</td>
   </tr>
   <tr id="1214">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1214">1214</a></td>
@@ -7405,7 +7405,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1265">1265</a></td>
     <td>CD3</td>
     <td>Mixed use of the <TT>auto</TT> specifier</td>
-    <td class="svn" align="center">SVN</td>
+    <td class="svn" align="center">Clang 5</td>
   </tr>
   <tr class="open" id="1266">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1266">1266</a></td>
@@ -7585,7 +7585,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1295">1295</a></td>
     <td>CD3</td>
     <td>Binding a reference to an rvalue bit-field</td>
-    <td class="svn" align="center">Clang 4</td>
+    <td class="full" align="center">Clang 4</td>
   </tr>
   <tr id="1296">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1296">1296</a></td>
@@ -7675,7 +7675,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1310">1310</a></td>
     <td>CD3</td>
     <td>What is an &#8220;acceptable lookup result?&#8221;</td>
-    <td class="svn" align="center">SVN</td>
+    <td class="svn" align="center">Clang 5</td>
   </tr>
   <tr id="1311">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1311">1311</a></td>
@@ -7795,7 +7795,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1330">1330</a></td>
     <td>CD3</td>
     <td>Delayed instantiation of <TT>noexcept</TT> specifiers</td>
-    <td class="svn" align="center">Clang 4 (C++11 onwards)</td>
+    <td class="full" align="center">Clang 4 (C++11 onwards)</td>
   </tr>
   <tr class="open" id="1331">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#1331">1331</a></td>
@@ -8143,7 +8143,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1388">1388</a></td>
     <td>CD3</td>
     <td>Missing non-deduced context following a function parameter pack</td>
-    <td class="svn" align="center">Clang 4</td>
+    <td class="full" align="center">Clang 4</td>
   </tr>
   <tr id="1389">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#1389">1389</a></td>
@@ -8209,7 +8209,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1399">1399</a></td>
     <td>CD3</td>
     <td>Deduction with multiple function parameter packs</td>
-    <td class="svn" align="center">Duplicate of <a href="#1388">1388</a></td>
+    <td class="full" align="center">Duplicate of <a href="#1388">1388</a></td>
   </tr>
   <tr id="1400">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#1400">1400</a></td>
@@ -8785,7 +8785,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1495">1495</a></td>
     <td>CD3</td>
     <td>Partial specialization of variadic class template</td>
-    <td class="svn" align="center">Clang 4</td>
+    <td class="full" align="center">Clang 4</td>
   </tr>
   <tr id="1496">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1496">1496</a></td>
@@ -8887,7 +8887,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1512">1512</a></td>
     <td>CD3</td>
     <td>Pointer comparison vs qualification conversions</td>
-    <td class="svn" align="center">Clang 4</td>
+    <td class="full" align="center">Clang 4</td>
   </tr>
   <tr class="open" id="1513">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1513">1513</a></td>
@@ -8923,7 +8923,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1518">1518</a></td>
     <td>CD4</td>
     <td>Explicit default constructors and copy-list-initialization</td>
-    <td class="svn" align="center">Clang 4</td>
+    <td class="full" align="center">Clang 4</td>
   </tr>
   <tr id="1519">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#1519">1519</a></td>
@@ -9733,7 +9733,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1653">1653</a></td>
     <td>CD4</td>
     <td>Removing deprecated increment of <TT>bool</TT></td>
-    <td class="svn" align="center">Clang 4 (C++17 onwards)</td>
+    <td class="full" align="center">Clang 4 (C++17 onwards)</td>
   </tr>
   <tr id="1654">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#1654">1654</a></td>
@@ -9763,7 +9763,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1658">1658</a></td>
     <td>C++14</td>
     <td>Deleted default constructor for abstract class via destructor</td>
-    <td class="svn" align="center">SVN</td>
+    <td class="svn" align="center">Clang 5</td>
   </tr>
   <tr class="open" id="1659">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1659">1659</a></td>
@@ -11161,7 +11161,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1891">1891</a></td>
     <td>CD4</td>
     <td>Move constructor/assignment for closure class</td>
-    <td class="svn" align="center">Clang 4</td>
+    <td class="full" align="center">Clang 4</td>
   </tr>
   <tr id="1892">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1892">1892</a></td>
@@ -12379,7 +12379,7 @@
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2094">2094</a></td>
     <td>DR</td>
     <td>Trivial copy/move constructor for class with volatile member</td>
-    <td class="full" align="center">Clang 5.0</td>
+    <td class="svn" align="center">Clang 5</td>
   </tr>
   <tr id="2095">
     <td><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#2095">2095</a></td>
diff --git a/www/cxx_status.html b/www/cxx_status.html
index 2fc73e1..943a4e7 100644
--- a/www/cxx_status.html
+++ b/www/cxx_status.html
@@ -854,9 +854,9 @@
     <th>Available in Clang?</th>
  </tr>
     <tr>
-      <td rowspan="3">SD-6: SG10 feature test recommendations</td>
-      <td rowspan="3"><a href="http://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations">SD-6</a></td>
-      <td rowspan="3">N/A</td>
+      <td rowspan="4">SD-6: SG10 feature test recommendations</td>
+      <td rowspan="4"><a href="http://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations">SD-6</a></td>
+      <td rowspan="4">N/A</td>
       <td class="full" align="center">
         Clang 3.4 (<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3745">N3745</a>)</br>
       </td>
@@ -871,6 +871,11 @@
         Clang 4 (<a href="http://wg21.link/p0096r3">P0096R3</a>)</a>
       </td>
     </tr>
+    <tr>
+      <td class="svn" align="center">
+        Clang 5 (<a href="http://wg21.link/p0096r4">P0096R4</a>)</a>
+      </td>
+    </tr>
     <!-- FIXME: Implement latest recommendations.
     <tr>
       <td class="svn" align="center">
diff --git a/www/make_cxx_dr_status b/www/make_cxx_dr_status
index 8a05d41..f942db2 100755
--- a/www/make_cxx_dr_status
+++ b/www/make_cxx_dr_status
@@ -108,11 +108,11 @@
   if status == 'unknown':
     avail = 'Unknown'
     avail_style = ' class="none"'
-  elif status == '5':
+  elif status == '6':
     avail = 'SVN'
     avail_style = ' class="svn"'
-  elif status == '4':
-    avail = 'Clang 4'
+  elif status == '5':
+    avail = 'Clang 5'
     avail_style = ' class="svn"'
   elif re.match('^[0-9]+\.?[0-9]*', status):
     avail = 'Clang %s' % status