[clang] [clang]: support std::meta::info for primitive types (PR #190356)

Nhat Nguyen via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 13 14:54:54 PDT 2026


https://github.com/changkhothuychung updated https://github.com/llvm/llvm-project/pull/190356

>From e41e160d5881b1383fcaa7fc847c1f5a375c0ac7 Mon Sep 17 00:00:00 2001
From: changkhothuychung <nhat7203 at gmail.com>
Date: Fri, 3 Apr 2026 11:48:07 -0400
Subject: [PATCH 01/23] initial commit

---
 clang/include/clang/AST/APValue.h             | 37 ++++++++++-
 clang/include/clang/AST/ASTContext.h          |  1 +
 clang/include/clang/AST/BuiltinTypes.def      |  3 +
 clang/include/clang/AST/ExprCXX.h             | 20 +++---
 clang/include/clang/AST/Reflection.h          | 25 ++++++++
 clang/include/clang/AST/TypeBase.h            |  5 ++
 clang/include/clang/Basic/TargetInfo.h        |  5 ++
 clang/lib/AST/APValue.cpp                     | 22 +++++++
 clang/lib/AST/ASTContext.cpp                  |  7 +++
 clang/lib/AST/ExprCXX.cpp                     |  9 +--
 clang/lib/AST/ExprConstant.cpp                | 63 +++++++++++++++++++
 clang/lib/AST/Type.cpp                        | 10 +++
 clang/lib/Basic/TargetInfo.cpp                |  2 +
 clang/lib/CodeGen/CodeGenModule.cpp           |  3 +
 clang/lib/CodeGen/CodeGenTypes.cpp            |  4 ++
 clang/lib/CodeGen/ItaniumCXXABI.cpp           |  1 +
 clang/lib/Sema/SemaExpr.cpp                   |  7 +++
 clang/lib/Sema/SemaOverload.cpp               | 16 +++++
 clang/lib/Sema/TreeTransform.h                |  5 +-
 .../CodeGenCXX/reflection-mangle-itanium.cpp  |  4 ++
 .../test/CodeGenCXX/reflection-mangle-ms.cpp  |  3 +
 .../test/Parser/reflection-meta-info.fail.cpp | 21 +++++++
 .../test/Parser/reflection-meta-info.pass.cpp | 39 ++++++++++++
 23 files changed, 298 insertions(+), 14 deletions(-)
 create mode 100644 clang/include/clang/AST/Reflection.h
 create mode 100644 clang/test/Parser/reflection-meta-info.fail.cpp
 create mode 100644 clang/test/Parser/reflection-meta-info.pass.cpp

diff --git a/clang/include/clang/AST/APValue.h b/clang/include/clang/AST/APValue.h
index 8a2d6d434792a..efd293914ff32 100644
--- a/clang/include/clang/AST/APValue.h
+++ b/clang/include/clang/AST/APValue.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_CLANG_AST_APVALUE_H
 #define LLVM_CLANG_AST_APVALUE_H
 
+#include "clang/AST/Reflection.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/APFixedPoint.h"
 #include "llvm/ADT/APFloat.h"
@@ -140,7 +141,8 @@ class APValue {
     Struct,
     Union,
     MemberPointer,
-    AddrLabelDiff
+    AddrLabelDiff,
+    Reflection
   };
 
   class alignas(uint64_t) LValueBase {
@@ -304,12 +306,16 @@ class APValue {
     const AddrLabelExpr* LHSExpr;
     const AddrLabelExpr* RHSExpr;
   };
+  struct ReflectionData {
+    const ReflectionKind OperandKind;
+    const void *Operand;
+  };
   struct MemberPointerData;
 
   // We ensure elsewhere that Data is big enough for LV and MemberPointerData.
   typedef llvm::AlignedCharArrayUnion<void *, APSInt, APFloat, ComplexAPSInt,
                                       ComplexAPFloat, Vec, Arr, StructData,
-                                      UnionData, AddrLabelDiffData> DataType;
+                                      UnionData, AddrLabelDiffData, ReflectionData> DataType;
   static const size_t DataSize = sizeof(DataType);
 
   DataType Data;
@@ -396,6 +402,15 @@ class APValue {
       : Kind(None), AllowConstexprUnknown(false) {
     MakeArray(InitElts, Size);
   }
+
+  /// Creates a new Reflection APValue.
+  /// \param OperandKind The kind of reflection.
+  /// \param Operand The entity being reflected.
+  APValue(ReflectionKind OperandKind, const void *Operand)
+      : Kind(None) {
+    MakeReflection(OperandKind, Operand);
+  }
+
   /// Creates a new struct APValue.
   /// \param UninitStruct Marker. Pass an empty UninitStruct.
   /// \param NumBases Number of bases.
@@ -476,6 +491,7 @@ class APValue {
   bool isUnion() const { return Kind == Union; }
   bool isMemberPointer() const { return Kind == MemberPointer; }
   bool isAddrLabelDiff() const { return Kind == AddrLabelDiff; }
+  bool isReflection() const { return Kind == Reflection; }
 
   void dump() const;
   void dump(raw_ostream &OS, const ASTContext &Context) const;
@@ -651,6 +667,16 @@ class APValue {
     return ((const AddrLabelDiffData *)(const char *)&Data)->RHSExpr;
   }
 
+  const ReflectionKind getReflectionOperandKind() const {
+    assert(isReflection() && "Invalid accessor");
+    return ((const ReflectionData *)(const char *)&Data)->OperandKind;
+  }
+
+  const void* getOpaqueReflectionOperand() const {
+    assert(isReflection() && "Invalid accessor");
+    return ((const ReflectionData *)(const char *)&Data)->Operand;
+  }
+
   void setInt(APSInt I) {
     assert(isInt() && "Invalid accessor");
     *(APSInt *)(char *)&Data = std::move(I);
@@ -696,6 +722,13 @@ class APValue {
 
 private:
   void DestroyDataAndMakeUninit();
+  void MakeReflection(ReflectionKind OperandKind,
+                      const void *Operand) {
+    assert(isAbsent() && "Bad state change");
+    new ((void *)(char *)Data.buffer) ReflectionData(
+            OperandKind, Operand);
+    Kind = Reflection;
+  }
   void MakeInt() {
     assert(isAbsent() && "Bad state change");
     new ((void *)&Data) APSInt(1);
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h
index 05302c30d18d1..0f96ce9fc7f7b 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1315,6 +1315,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
   CanQualType BFloat16Ty;
   CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3
   CanQualType VoidPtrTy, NullPtrTy;
+  CanQualType MetaInfoTy;
   CanQualType DependentTy, OverloadTy, BoundMemberTy, UnresolvedTemplateTy,
       UnknownAnyTy;
   CanQualType BuiltinFnTy;
diff --git a/clang/include/clang/AST/BuiltinTypes.def b/clang/include/clang/AST/BuiltinTypes.def
index 444be4311a743..87a376a839cda 100644
--- a/clang/include/clang/AST/BuiltinTypes.def
+++ b/clang/include/clang/AST/BuiltinTypes.def
@@ -226,6 +226,9 @@ FLOATING_TYPE(Ibm128, Ibm128Ty)
 // This is the type of C++0x 'nullptr'.
 BUILTIN_TYPE(NullPtr, NullPtrTy)
 
+// 'std::meta::info' in C++
+BUILTIN_TYPE(MetaInfo, MetaInfoTy)
+
 // The primitive Objective C 'id' type.  The user-visible 'id'
 // type is a typedef of an ObjCObjectPointerType to an
 // ObjCObjectType with this as its base.  In fact, this only ever
diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h
index c40cd929b7408..824d96cb9dae1 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -25,6 +25,7 @@
 #include "clang/AST/Expr.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/OperationKinds.h"
+#include "clang/AST/Reflection.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/TemplateBase.h"
@@ -5508,15 +5509,18 @@ class BuiltinBitCastExpr final
 ///  - an id-expression.
 class CXXReflectExpr : public Expr {
 
-  // TODO(Reflection): add support for TemplateReference, NamespaceReference and
-  // DeclRefExpr
-  using operand_type = llvm::PointerUnion<const TypeSourceInfo *>;
 
-  SourceLocation CaretCaretLoc;
-  operand_type Operand;
+  private:
+    // TODO(Reflection): add support for TemplateReference, NamespaceReference and
+    // DeclRefExpr
+    using operand_type = llvm::PointerUnion<const TypeSourceInfo *>;
 
-  CXXReflectExpr(SourceLocation CaretCaretLoc, const TypeSourceInfo *TSI);
-  CXXReflectExpr(EmptyShell Empty);
+    SourceLocation CaretCaretLoc;
+    ReflectionKind Kind;
+    operand_type Operand;
+
+    CXXReflectExpr(ASTContext &C, SourceLocation CaretCaretLoc, const TypeSourceInfo *TSI);
+    CXXReflectExpr(EmptyShell Empty);
 
 public:
   static CXXReflectExpr *Create(ASTContext &C, SourceLocation OperatorLoc,
@@ -5538,6 +5542,8 @@ class CXXReflectExpr : public Expr {
 
   /// Returns location of the '^^'-operator.
   SourceLocation getOperatorLoc() const { return CaretCaretLoc; }
+  ReflectionKind getKind() const { return Kind; }
+  const void* getOpaqueValue() const { return Operand.getOpaqueValue(); }
 
   child_range children() {
     // TODO(Reflection)
diff --git a/clang/include/clang/AST/Reflection.h b/clang/include/clang/AST/Reflection.h
new file mode 100644
index 0000000000000..140f48af6efe3
--- /dev/null
+++ b/clang/include/clang/AST/Reflection.h
@@ -0,0 +1,25 @@
+//===--- Reflection.h - Kind of reflection operands ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file declares the kinds of reflection operands.
+//
+//===----------------------------------------------------------------------===//
+
+
+#ifndef LLVM_CLANG_AST_REFLECTION_H
+#define LLVM_CLANG_AST_REFLECTION_H
+namespace clang {
+
+// TODO(Reflection): Add support for Template, Namespace and DeclRefExpr.
+enum class ReflectionKind {
+  Type
+};
+
+}
+
+#endif
diff --git a/clang/include/clang/AST/TypeBase.h b/clang/include/clang/AST/TypeBase.h
index 9402469f5e12b..bdbca5b8d9dae 100644
--- a/clang/include/clang/AST/TypeBase.h
+++ b/clang/include/clang/AST/TypeBase.h
@@ -2634,6 +2634,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
   bool isRecordType() const;
   bool isClassType() const;
   bool isStructureType() const;
+  bool isMetaInfoType() const;
   bool isStructureTypeWithFlexibleArrayMember() const;
   bool isObjCBoxableRecordType() const;
   bool isInterfaceType() const;
@@ -8953,6 +8954,10 @@ inline bool Type::isVoidType() const {
   return isSpecificBuiltinType(BuiltinType::Void);
 }
 
+inline bool Type::isMetaInfoType() const {
+  return isSpecificBuiltinType(BuiltinType::MetaInfo);
+}
+
 inline bool Type::isHalfType() const {
   // FIXME: Should we allow complex __fp16? Probably not.
   return isSpecificBuiltinType(BuiltinType::Half);
diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h
index ec6cd2be7c3c5..a830d165de98c 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -96,6 +96,7 @@ struct TransferrableTargetInfo {
   unsigned char FloatWidth, FloatAlign;
   unsigned char DoubleWidth, DoubleAlign;
   unsigned char LongDoubleWidth, LongDoubleAlign, Float128Align, Ibm128Align;
+  unsigned char MetaInfoWidth, MetaInfoAlign;
   unsigned char LargeArrayMinWidth, LargeArrayAlign;
   unsigned char LongWidth, LongAlign;
   unsigned char LongLongWidth, LongLongAlign;
@@ -824,6 +825,10 @@ class TargetInfo : public TransferrableTargetInfo,
   unsigned getIbm128Align() const { return Ibm128Align; }
   const llvm::fltSemantics &getIbm128Format() const { return *Ibm128Format; }
 
+  /// getMetaInfoWidth/Align - Returns the size/align of std::meta::info.
+  unsigned getMetaInfoWidth() const { return MetaInfoWidth; }
+  unsigned getMetaInfoAlign() const { return MetaInfoAlign; }
+
   /// Return the mangled code of long double.
   virtual const char *getLongDoubleMangling() const { return "e"; }
 
diff --git a/clang/lib/AST/APValue.cpp b/clang/lib/AST/APValue.cpp
index 2e1c8eb3726cf..803c54d4f1c07 100644
--- a/clang/lib/AST/APValue.cpp
+++ b/clang/lib/AST/APValue.cpp
@@ -377,6 +377,9 @@ APValue::APValue(const APValue &RHS)
     MakeAddrLabelDiff();
     setAddrLabelDiff(RHS.getAddrLabelDiffLHS(), RHS.getAddrLabelDiffRHS());
     break;
+  case Reflection:
+    MakeReflection(RHS.getReflectionOperandKind(), RHS.getOpaqueReflectionOperand());
+    break;
   }
 }
 
@@ -430,6 +433,8 @@ void APValue::DestroyDataAndMakeUninit() {
     ((MemberPointerData *)(char *)&Data)->~MemberPointerData();
   else if (Kind == AddrLabelDiff)
     ((AddrLabelDiffData *)(char *)&Data)->~AddrLabelDiffData();
+  else if (Kind == Reflection)
+    ((ReflectionData *)(char *)&Data)->~ReflectionData();
   Kind = None;
   AllowConstexprUnknown = false;
 }
@@ -439,6 +444,7 @@ bool APValue::needsCleanup() const {
   case None:
   case Indeterminate:
   case AddrLabelDiff:
+  case Reflection:
     return false;
   case Struct:
   case Union:
@@ -486,6 +492,18 @@ static void profileIntValue(llvm::FoldingSetNodeID &ID, const llvm::APInt &V) {
     ID.AddInteger((uint32_t)V.extractBitsAsZExtValue(std::min(32u, N - I), I));
 }
 
+static void profileReflection(llvm::FoldingSetNodeID &ID, APValue V) {
+  ID.AddInteger(static_cast<int>(V.getReflectionOperandKind()));
+  switch (V.getReflectionOperandKind()) {
+    case ReflectionKind::Type: {
+      const TypeSourceInfo* info = static_cast<const TypeSourceInfo*>(V.getOpaqueReflectionOperand());
+      ID.AddPointer((info->getType().getCanonicalType().getAsOpaquePtr()));
+      return;
+    }
+    assert(false && "unknown or unimplemented reflection entities");
+  }
+}
+
 void APValue::Profile(llvm::FoldingSetNodeID &ID) const {
   // Note that our profiling assumes that only APValues of the same type are
   // ever compared. As a result, we don't consider collisions that could only
@@ -624,6 +642,9 @@ void APValue::Profile(llvm::FoldingSetNodeID &ID) const {
     for (const CXXRecordDecl *D : getMemberPointerPath())
       ID.AddPointer(D);
     return;
+  case Reflection:
+    profileReflection(ID, *this);
+    return;
   }
 
   llvm_unreachable("Unknown APValue kind!");
@@ -1139,6 +1160,7 @@ LinkageInfo LinkageComputer::getLVForValue(const APValue &V,
   case APValue::ComplexInt:
   case APValue::ComplexFloat:
   case APValue::Vector:
+  case APValue::Reflection:
     break;
 
   case APValue::AddrLabelDiff:
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index b74766dab38f8..937bcb17da44f 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1452,6 +1452,9 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target,
   // nullptr type (C++0x 2.14.7)
   InitBuiltinType(NullPtrTy,           BuiltinType::NullPtr);
 
+  // std::meta::info type (C++26 21.4.1)
+  InitBuiltinType(MetaInfoTy, BuiltinType::MetaInfo);
+
   // half type (OpenCL 6.1.1.1) / ARM NEON __fp16
   InitBuiltinType(HalfTy, BuiltinType::Half);
 
@@ -2280,6 +2283,10 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
       Width = Target->getPointerWidth(LangAS::Default);
       Align = Target->getPointerAlign(LangAS::Default);
       break;
+    case BuiltinType::MetaInfo:
+      Width = Target->getMetaInfoWidth();
+      Align = Target->getMetaInfoAlign();
+      break;
     case BuiltinType::ObjCId:
     case BuiltinType::ObjCClass:
     case BuiltinType::ObjCSel:
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index bcc481fc8399f..489ad54b1509c 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -24,6 +24,7 @@
 #include "clang/AST/Expr.h"
 #include "clang/AST/LambdaCapture.h"
 #include "clang/AST/NestedNameSpecifier.h"
+#include "clang/AST/Reflection.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/Type.h"
 #include "clang/AST/TypeLoc.h"
@@ -1942,15 +1943,15 @@ TypeTraitExpr *TypeTraitExpr::CreateDeserialized(const ASTContext &C,
 CXXReflectExpr::CXXReflectExpr(EmptyShell Empty)
     : Expr(CXXReflectExprClass, Empty) {}
 
-CXXReflectExpr::CXXReflectExpr(SourceLocation CaretCaretLoc,
+CXXReflectExpr::CXXReflectExpr(ASTContext &C, SourceLocation CaretCaretLoc,
                                const TypeSourceInfo *TSI)
-    : Expr(CXXReflectExprClass, TSI->getType(), VK_PRValue, OK_Ordinary),
-      CaretCaretLoc(CaretCaretLoc), Operand(TSI) {}
+    : Expr(CXXReflectExprClass, C.MetaInfoTy, VK_PRValue, OK_Ordinary),
+      CaretCaretLoc(CaretCaretLoc), Kind(ReflectionKind::Type), Operand(TSI) {}
 
 CXXReflectExpr *CXXReflectExpr::Create(ASTContext &C,
                                        SourceLocation CaretCaretLoc,
                                        TypeSourceInfo *TSI) {
-  return new (C) CXXReflectExpr(CaretCaretLoc, TSI);
+  return new (C) CXXReflectExpr(C, CaretCaretLoc, TSI);
 }
 
 CXXReflectExpr *CXXReflectExpr::CreateEmpty(ASTContext &C) {
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 5973315406aed..069c9b9116af6 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -51,6 +51,7 @@
 #include "clang/AST/StmtVisitor.h"
 #include "clang/AST/Type.h"
 #include "clang/AST/TypeLoc.h"
+#include "clang/AST/Reflection.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/DiagnosticSema.h"
 #include "clang/Basic/TargetBuiltins.h"
@@ -2469,6 +2470,8 @@ static bool CheckEvaluationResult(CheckEvaluationResultKind CERK,
         Value.getUnionValue(), Kind, Value.getUnionField(), CheckedTemps);
   }
   if (Value.isStruct()) {
+    if (Type->isMetaInfoType())
+        return true;
     auto *RD = Type->castAsRecordDecl();
     if (const CXXRecordDecl *CD = dyn_cast<CXXRecordDecl>(RD)) {
       unsigned BaseIndex = 0;
@@ -10895,6 +10898,46 @@ bool PointerExprEvaluator::VisitCXXNewExpr(const CXXNewExpr *E) {
 
   return true;
 }
+
+//===----------------------------------------------------------------------===//
+// Reflection expression evaluation
+//===----------------------------------------------------------------------===//
+
+namespace {
+class ReflectionEvaluator
+  : public ExprEvaluatorBase<ReflectionEvaluator> {
+
+  using BaseType = ExprEvaluatorBase<ReflectionEvaluator>;
+
+  APValue &Result;
+public:
+  ReflectionEvaluator(EvalInfo &E, APValue &Result)
+    : ExprEvaluatorBaseTy(E), Result(Result) {}
+
+  bool Success(const APValue &V, const Expr *E) {
+    Result = V;
+    return true;
+  }
+
+  bool VisitCXXReflectExpr(const CXXReflectExpr *E);
+};
+
+bool ReflectionEvaluator::VisitCXXReflectExpr(const CXXReflectExpr *E) {
+  switch (E->getKind()) {
+    case ReflectionKind::Type: {
+      APValue Result(ReflectionKind::Type, E->getOpaqueValue());
+      return Success(Result, E);
+    }
+  }
+  llvm_unreachable("invalid reflection");
+}
+}  // end anonymous namespace
+
+static bool EvaluateReflection(const Expr *E, APValue &Result, EvalInfo &Info) {
+  assert(E->isPRValue() && E->getType()->isMetaInfoType());
+  return ReflectionEvaluator(Info, Result).Visit(E);
+}
+
 //===----------------------------------------------------------------------===//
 // Member Pointer Evaluation
 //===----------------------------------------------------------------------===//
@@ -18277,6 +18320,23 @@ EvaluateComparisonBinaryOperator(EvalInfo &Info, const BinaryOperator *E,
     return Success(CmpResult::Equal, E);
   }
 
+  if (LHSTy->isMetaInfoType() && RHSTy->isMetaInfoType()) {
+    APValue LHSValue, RHSValue;
+    llvm::FoldingSetNodeID LID, RID;
+    if (!Evaluate(LHSValue, Info, E->getLHS()))
+      return false;
+    LHSValue.Profile(LID);
+
+    if (!Evaluate(RHSValue, Info, E->getRHS()))
+      return false;
+    RHSValue.Profile(RID);
+
+    if (LID == RID)
+      return Success(CmpResult::Equal, E);
+    else
+      return Success(CmpResult::Unequal, E);
+  }
+
   return DoAfter();
 }
 
@@ -20432,6 +20492,9 @@ static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E) {
   } else if (T->isIntegralOrEnumerationType()) {
     if (!IntExprEvaluator(Info, Result).Visit(E))
       return false;
+  } else if (T->isMetaInfoType()) {
+    if(!EvaluateReflection(E, Result, Info))
+      return false;
   } else if (T->hasPointerRepresentation()) {
     LValue LV;
     if (!EvaluatePointer(E, LV, Info))
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index a85f08753a132..eebea6811b5c6 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -3105,6 +3105,13 @@ bool Type::isLiteralType(const ASTContext &Ctx) const {
     return true;
   }
 
+  // C++26 [basic.types]p9:
+  // -- std::meta::info is a scalar type
+  // C++26 [basic.types]p10:
+  // -- a scalar type is a literal type
+  if(isMetaInfoType())
+    return true;
+
   // We treat _Atomic T as a literal type if T is a literal type.
   if (const auto *AT = BaseTy->getAs<AtomicType>())
     return AT->getValueType()->isLiteralType(Ctx);
@@ -3480,6 +3487,8 @@ StringRef BuiltinType::getName(const PrintingPolicy &Policy) const {
     return "unsigned _Accum";
   case ULongAccum:
     return "unsigned long _Accum";
+  case BuiltinType::MetaInfo:
+    return "meta::info";
   case BuiltinType::ShortFract:
     return "short _Fract";
   case BuiltinType::Fract:
@@ -5194,6 +5203,7 @@ bool Type::canHaveNullability(bool ResultIfUnknown) const {
 #include "clang/Basic/HLSLIntangibleTypes.def"
     case BuiltinType::BuiltinFn:
     case BuiltinType::NullPtr:
+    case BuiltinType::MetaInfo:
     case BuiltinType::IncompleteMatrixIdx:
     case BuiltinType::ArraySection:
     case BuiltinType::OMPArrayShaping:
diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 794621c4b3e1f..3943347947d5c 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -125,6 +125,8 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : Triple(T) {
   LongDoubleAlign = 64;
   Float128Align = 128;
   Ibm128Align = 128;
+  MetaInfoWidth = 64;
+  MetaInfoAlign = 64;
   LargeArrayMinWidth = 0;
   LargeArrayAlign = 0;
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 0;
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 35ee108cdc4fc..fb341ba9615dc 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -6085,6 +6085,9 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
   if (getLangOpts().OpenCL && ASTTy->isSamplerT())
     return;
 
+  if (getLangOpts().Reflection && ASTTy->isMetaInfoType())
+    return;
+
   // HLSL default buffer constants will be emitted during HLSLBufferDecl codegen
   if (getLangOpts().HLSL &&
       D->getType().getAddressSpace() == LangAS::hlsl_constant)
diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp
index 6bd79056e599a..b17d38e659450 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -515,6 +515,10 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
       ResultType = llvm::PointerType::getUnqual(getLLVMContext());
       break;
 
+    case BuiltinType::MetaInfo:
+      ResultType = llvm::IntegerType::get(getLLVMContext(), 64);
+      break;
+
     case BuiltinType::UInt128:
     case BuiltinType::Int128:
       ResultType = llvm::IntegerType::get(getLLVMContext(), 128);
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 397db2ee59408..740a1bae37e8b 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -3774,6 +3774,7 @@ static bool TypeInfoIsInStandardLibrary(const BuiltinType *Ty) {
     case BuiltinType::SatUFract:
     case BuiltinType::SatULongFract:
     case BuiltinType::BFloat16:
+    case BuiltinType::MetaInfo:
       return false;
 
     case BuiltinType::Dependent:
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 82da5dc032237..91a51ee23c064 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -12890,6 +12890,13 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
         *CCT, Loc, ComparisonCategoryUsage::OperatorInExpression);
   };
 
+  if(LHSType->isMetaInfoType() && RHSType->isMetaInfoType()){
+    if(!BinaryOperator::isEqualityOp(Opc)) {
+      return InvalidOperands(Loc, LHS, RHS);
+    }
+    return computeResultTy();
+  }
+
   if (!IsOrdered && LHSIsNull != RHSIsNull) {
     bool IsEquality = Opc == BO_EQ;
     if (RHSIsNull)
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index c513e72db1094..26f1e8a6a70c8 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -9049,6 +9049,10 @@ class BuiltinCandidateTypeSet  {
   /// candidate set.
   bool HasNullPtrType;
 
+  /// A flag indicating whether the reflection type was present in the
+  /// candidate set.
+  bool HasReflectionType;
+
   /// Sema - The semantic analysis instance where we are building the
   /// candidate type set.
   Sema &SemaRef;
@@ -9068,6 +9072,7 @@ class BuiltinCandidateTypeSet  {
     : HasNonRecordTypes(false),
       HasArithmeticOrEnumeralTypes(false),
       HasNullPtrType(false),
+      HasReflectionType(false),
       SemaRef(SemaRef),
       Context(SemaRef.Context) { }
 
@@ -9092,6 +9097,7 @@ class BuiltinCandidateTypeSet  {
   bool hasNonRecordTypes() { return HasNonRecordTypes; }
   bool hasArithmeticOrEnumeralTypes() { return HasArithmeticOrEnumeralTypes; }
   bool hasNullPtrType() const { return HasNullPtrType; }
+  bool hasReflectionType() const { return HasReflectionType; }
 };
 
 } // end anonymous namespace
@@ -9273,6 +9279,8 @@ BuiltinCandidateTypeSet::AddTypesConvertedFrom(QualType Ty,
     MatrixTypes.insert(Ty);
   } else if (Ty->isNullPtrType()) {
     HasNullPtrType = true;
+  } else if (Ty->isMetaInfoType()) {
+    HasReflectionType = true;
   } else if (AllowUserConversions && TyIsRec) {
     // No conversion functions in incomplete types.
     if (!SemaRef.isCompleteType(Loc, Ty))
@@ -9752,6 +9760,14 @@ class BuiltinOperatorOverloadBuilder {
           S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);
         }
       }
+
+      if (CandidateTypes[ArgIdx].hasReflectionType()) {
+        CanQualType InfoTy = S.Context.getCanonicalType(S.Context.MetaInfoTy);
+        if (AddedTypes.insert(InfoTy).second) {
+          QualType ParamTypes[2] = { InfoTy, InfoTy };
+          S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);
+        }
+      }
     }
   }
 
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 1a050bd6a8737..4cabed7aea323 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13079,7 +13079,10 @@ ExprResult TreeTransform<Derived>::TransformSYCLUniqueStableNameExpr(
 template <typename Derived>
 ExprResult TreeTransform<Derived>::TransformCXXReflectExpr(CXXReflectExpr *E) {
   // TODO(reflection): Implement its transform
-  assert(false && "not implemented yet");
+  if (!E->isTypeDependent())
+    return E;
+
+  assert(false && "unknown or unimplemented reflection entities");
   return ExprError();
 }
 
diff --git a/clang/test/CodeGenCXX/reflection-mangle-itanium.cpp b/clang/test/CodeGenCXX/reflection-mangle-itanium.cpp
index a6266165e77f8..1530b4064169a 100644
--- a/clang/test/CodeGenCXX/reflection-mangle-itanium.cpp
+++ b/clang/test/CodeGenCXX/reflection-mangle-itanium.cpp
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 -std=c++26 -freflection -triple x86_64-unknown-linux-gnu \
 // RUN:   -emit-llvm -o - %s -verify
 
+constexpr auto r = ^^int;
+constexpr auto q = r;
+
+
 int main() {
   (void)(^^int); // expected-error {{cannot compile this scalar expression yet}}
   return 0;
diff --git a/clang/test/CodeGenCXX/reflection-mangle-ms.cpp b/clang/test/CodeGenCXX/reflection-mangle-ms.cpp
index 327bc0111bae8..224049521e77e 100644
--- a/clang/test/CodeGenCXX/reflection-mangle-ms.cpp
+++ b/clang/test/CodeGenCXX/reflection-mangle-ms.cpp
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -std=c++26 -freflection -triple x86_64-pc-windows-msvc \
 // RUN:   -emit-llvm -o - %s -verify
 
+constexpr auto r = ^^int;
+constexpr auto q = r;
+
 int main() {
   (void)(^^int); // expected-error {{cannot compile this scalar expression yet}}
   return 0;
diff --git a/clang/test/Parser/reflection-meta-info.fail.cpp b/clang/test/Parser/reflection-meta-info.fail.cpp
new file mode 100644
index 0000000000000..2eade98ea6c5d
--- /dev/null
+++ b/clang/test/Parser/reflection-meta-info.fail.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -std=c++26 -freflection -fsyntax-only -verify
+
+using info = decltype(^^int);
+
+struct X { int a; }; // expected-note {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'meta::info' to 'const X' for 1st argument}} \
+                     // expected-note {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'meta::info' to 'X' for 1st argument}} \
+                     // expected-note {{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}}
+template <typename T = X, auto ptm = &X::a>
+constexpr auto ptmOp = ((T)(^^int)).*ptm; // expected-error {{no matching conversion for C-style cast from 'meta::info' to 'X'}}
+constexpr auto var = ptmOp<>; // expected-note {{in instantiation of variable template specialization 'ptmOp' requested here}}
+
+consteval void test()
+{
+    (^^char)++; // expected-error {{cannot increment value of type 'meta::info'}}
+    (^^short)++; // expected-error {{cannot increment value of type 'meta::info'}}
+    (^^int)++; // expected-error {{cannot increment value of type 'meta::info'}}
+
+    (^^char)--; // expected-error {{cannot decrement value of type 'meta::info'}}
+    (^^short)--; // expected-error {{cannot decrement value of type 'meta::info'}}
+    (^^int)--; // expected-error {{cannot decrement value of type 'meta::info'}}
+}
diff --git a/clang/test/Parser/reflection-meta-info.pass.cpp b/clang/test/Parser/reflection-meta-info.pass.cpp
new file mode 100644
index 0000000000000..843227000bcec
--- /dev/null
+++ b/clang/test/Parser/reflection-meta-info.pass.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 %s -std=c++26 -freflection -fsyntax-only
+
+using info = decltype(^^int);
+
+consteval void test()
+{
+    constexpr auto r = ^^int;
+    constexpr auto q = ^^int;
+
+    static_assert(__is_same(decltype(^^int), info));
+    static_assert(__is_same(decltype(^^float), info));
+    static_assert(__is_same(decltype(^^double), info));
+    static_assert(__is_same(decltype(^^long), info));
+    static_assert(__is_same(decltype(^^long long), info));
+    static_assert(__is_same(decltype(^^short), info));
+    static_assert(__is_same(decltype(^^char), info));
+    static_assert(__is_same(decltype(^^unsigned char), info));
+    static_assert(__is_same(decltype(^^unsigned short), info));
+    static_assert(__is_same(decltype(^^unsigned int), info));
+    static_assert(__is_same(decltype(^^unsigned long), info));
+    static_assert(__is_same(decltype(^^unsigned long long), info));
+
+    static_assert(__is_same(decltype(^^int), decltype(^^int)));
+    static_assert(__is_same(decltype(^^int), decltype(^^float)));
+    static_assert(__is_same(decltype(^^int), decltype(^^char)));
+    static_assert(__is_same(decltype(^^double), decltype(^^float)));
+
+    static_assert(!__is_same(decltype(^^int), int));
+
+    static_assert(sizeof(^^int) == sizeof(^^float));
+    static_assert(sizeof(^^int) == 8);
+
+
+    static_assert(^^int == ^^int);
+    static_assert(^^int != ^^float);
+    static_assert(^^float != ^^int);
+    static_assert(!(^^float == ^^int));
+    static_assert(r == q);
+}

>From 8fad3d6f4fd1bdd01bce7bfea8ce03c76c8a83db Mon Sep 17 00:00:00 2001
From: changkhothuychung <nhat7203 at gmail.com>
Date: Mon, 6 Apr 2026 16:05:28 -0400
Subject: [PATCH 02/23] clang format

---
 clang/include/clang/AST/APValue.h    |  119 +-
 clang/include/clang/AST/ExprCXX.h    |  111 +-
 clang/include/clang/AST/Reflection.h |    7 +-
 clang/lib/AST/APValue.cpp            |  120 +-
 clang/lib/AST/ExprConstant.cpp       | 3921 +++++++++++++-------------
 clang/lib/AST/Type.cpp               |    2 +-
 clang/lib/Sema/SemaExpr.cpp          | 2524 +++++++++--------
 clang/lib/Sema/SemaOverload.cpp      | 2729 +++++++++---------
 8 files changed, 4716 insertions(+), 4817 deletions(-)

diff --git a/clang/include/clang/AST/APValue.h b/clang/include/clang/AST/APValue.h
index 2492dd4847b3e..d48155de208b6 100644
--- a/clang/include/clang/AST/APValue.h
+++ b/clang/include/clang/AST/APValue.h
@@ -28,18 +28,18 @@ namespace serialization {
 template <typename T> class BasicReaderBase;
 } // end namespace serialization
 
-  class AddrLabelExpr;
-  class ASTContext;
-  class CharUnits;
-  class CXXRecordDecl;
-  class Decl;
-  class DiagnosticBuilder;
-  class Expr;
-  class FieldDecl;
-  struct PrintingPolicy;
-  class Type;
-  class ValueDecl;
-  class QualType;
+class AddrLabelExpr;
+class ASTContext;
+class CharUnits;
+class CXXRecordDecl;
+class Decl;
+class DiagnosticBuilder;
+class Expr;
+class FieldDecl;
+struct PrintingPolicy;
+class Type;
+class ValueDecl;
+class QualType;
 
 /// Symbolic representation of typeid(T) for some type T.
 class TypeInfoLValue {
@@ -55,7 +55,7 @@ class TypeInfoLValue {
   const void *getOpaqueValue() const { return T; }
   static TypeInfoLValue getFromOpaqueValue(const void *Value) {
     TypeInfoLValue V;
-    V.T = reinterpret_cast<const Type*>(Value);
+    V.T = reinterpret_cast<const Type *>(Value);
     return V;
   }
 
@@ -89,10 +89,10 @@ class DynamicAllocLValue {
 
   static constexpr int NumLowBitsAvailable = 3;
 };
-}
+} // namespace clang
 
 namespace llvm {
-template<> struct PointerLikeTypeTraits<clang::TypeInfoLValue> {
+template <> struct PointerLikeTypeTraits<clang::TypeInfoLValue> {
   static const void *getAsVoidPointer(clang::TypeInfoLValue V) {
     return V.getOpaqueValue();
   }
@@ -104,7 +104,7 @@ template<> struct PointerLikeTypeTraits<clang::TypeInfoLValue> {
   static constexpr int NumLowBitsAvailable = 3;
 };
 
-template<> struct PointerLikeTypeTraits<clang::DynamicAllocLValue> {
+template <> struct PointerLikeTypeTraits<clang::DynamicAllocLValue> {
   static const void *getAsVoidPointer(clang::DynamicAllocLValue V) {
     return V.getOpaqueValue();
   }
@@ -114,7 +114,7 @@ template<> struct PointerLikeTypeTraits<clang::DynamicAllocLValue> {
   static constexpr int NumLowBitsAvailable =
       clang::DynamicAllocLValue::NumLowBitsAvailable;
 };
-}
+} // namespace llvm
 
 namespace clang {
 /// APValue - This class implements a discriminated union of [uninitialized]
@@ -124,6 +124,7 @@ class APValue {
   typedef llvm::APFixedPoint APFixedPoint;
   typedef llvm::APSInt APSInt;
   typedef llvm::APFloat APFloat;
+
 public:
   enum ValueKind {
     /// There is no such object (it's outside its lifetime).
@@ -313,8 +314,8 @@ class APValue {
     ~UnionData();
   };
   struct AddrLabelDiffData {
-    const AddrLabelExpr* LHSExpr;
-    const AddrLabelExpr* RHSExpr;
+    const AddrLabelExpr *LHSExpr;
+    const AddrLabelExpr *RHSExpr;
   };
   struct ReflectionData {
     const ReflectionKind OperandKind;
@@ -323,9 +324,10 @@ class APValue {
   struct MemberPointerData;
 
   // We ensure elsewhere that Data is big enough for LV and MemberPointerData.
-  typedef llvm::AlignedCharArrayUnion<void *, APSInt, APFloat, ComplexAPSInt,
-                                      ComplexAPFloat, Vec, Mat, Arr, StructData,
-                                      UnionData, AddrLabelDiffData, ReflectionData> DataType;
+  typedef llvm::AlignedCharArrayUnion<
+      void *, APSInt, APFloat, ComplexAPSInt, ComplexAPFloat, Vec, Mat, Arr,
+      StructData, UnionData, AddrLabelDiffData, ReflectionData>
+      DataType;
   static const size_t DataSize = sizeof(DataType);
 
   DataType Data;
@@ -341,11 +343,13 @@ class APValue {
   APValue() : Kind(None), AllowConstexprUnknown(false) {}
   /// Creates an integer APValue holding the given value.
   explicit APValue(APSInt I) : Kind(None), AllowConstexprUnknown(false) {
-    MakeInt(); setInt(std::move(I));
+    MakeInt();
+    setInt(std::move(I));
   }
   /// Creates a float APValue holding the given value.
   explicit APValue(APFloat F) : Kind(None), AllowConstexprUnknown(false) {
-    MakeFloat(); setFloat(std::move(F));
+    MakeFloat();
+    setFloat(std::move(F));
   }
   /// Creates a fixed-point APValue holding the given value.
   explicit APValue(APFixedPoint FX) : Kind(None), AllowConstexprUnknown(false) {
@@ -355,7 +359,8 @@ class APValue {
   /// are read from \p E.
   explicit APValue(const APValue *E, unsigned N)
       : Kind(None), AllowConstexprUnknown(false) {
-    MakeVector(); setVector(E, N);
+    MakeVector();
+    setVector(E, N);
   }
   /// Creates a matrix APValue with given dimensions. The elements
   /// are read from \p E and assumed to be in row-major order.
@@ -367,11 +372,13 @@ class APValue {
   /// Creates an integer complex APValue with the given real and imaginary
   /// values.
   APValue(APSInt R, APSInt I) : Kind(None), AllowConstexprUnknown(false) {
-    MakeComplexInt(); setComplexInt(std::move(R), std::move(I));
+    MakeComplexInt();
+    setComplexInt(std::move(R), std::move(I));
   }
   /// Creates a float complex APValue with the given real and imaginary values.
   APValue(APFloat R, APFloat I) : Kind(None), AllowConstexprUnknown(false) {
-    MakeComplexFloat(); setComplexFloat(std::move(R), std::move(I));
+    MakeComplexFloat();
+    setComplexFloat(std::move(R), std::move(I));
   }
   APValue(const APValue &RHS);
   APValue(APValue &&RHS);
@@ -423,8 +430,7 @@ class APValue {
   /// Creates a new Reflection APValue.
   /// \param OperandKind The kind of reflection.
   /// \param Operand The entity being reflected.
-  APValue(ReflectionKind OperandKind, const void *Operand)
-      : Kind(None) {
+  APValue(ReflectionKind OperandKind, const void *Operand) : Kind(None) {
     MakeReflection(OperandKind, Operand);
   }
 
@@ -459,7 +465,8 @@ class APValue {
   /// \param RHSExpr The right-hand side of the difference.
   APValue(const AddrLabelExpr *LHSExpr, const AddrLabelExpr *RHSExpr)
       : Kind(None), AllowConstexprUnknown(false) {
-    MakeAddrLabelDiff(); setAddrLabelDiff(LHSExpr, RHSExpr);
+    MakeAddrLabelDiff();
+    setAddrLabelDiff(LHSExpr, RHSExpr);
   }
   static APValue IndeterminateValue() {
     APValue Result;
@@ -524,9 +531,7 @@ class APValue {
     assert(isInt() && "Invalid accessor");
     return *(APSInt *)(char *)&Data;
   }
-  const APSInt &getInt() const {
-    return const_cast<APValue*>(this)->getInt();
-  }
+  const APSInt &getInt() const { return const_cast<APValue *>(this)->getInt(); }
 
   /// Try to convert this value to an integral constant. This works if it's an
   /// integer, null pointer, or offset from a null pointer. Returns true on
@@ -539,7 +544,7 @@ class APValue {
     return *(APFloat *)(char *)&Data;
   }
   const APFloat &getFloat() const {
-    return const_cast<APValue*>(this)->getFloat();
+    return const_cast<APValue *>(this)->getFloat();
   }
 
   APFixedPoint &getFixedPoint() {
@@ -555,7 +560,7 @@ class APValue {
     return ((ComplexAPSInt *)(char *)&Data)->Real;
   }
   const APSInt &getComplexIntReal() const {
-    return const_cast<APValue*>(this)->getComplexIntReal();
+    return const_cast<APValue *>(this)->getComplexIntReal();
   }
 
   APSInt &getComplexIntImag() {
@@ -563,7 +568,7 @@ class APValue {
     return ((ComplexAPSInt *)(char *)&Data)->Imag;
   }
   const APSInt &getComplexIntImag() const {
-    return const_cast<APValue*>(this)->getComplexIntImag();
+    return const_cast<APValue *>(this)->getComplexIntImag();
   }
 
   APFloat &getComplexFloatReal() {
@@ -571,7 +576,7 @@ class APValue {
     return ((ComplexAPFloat *)(char *)&Data)->Real;
   }
   const APFloat &getComplexFloatReal() const {
-    return const_cast<APValue*>(this)->getComplexFloatReal();
+    return const_cast<APValue *>(this)->getComplexFloatReal();
   }
 
   APFloat &getComplexFloatImag() {
@@ -579,13 +584,13 @@ class APValue {
     return ((ComplexAPFloat *)(char *)&Data)->Imag;
   }
   const APFloat &getComplexFloatImag() const {
-    return const_cast<APValue*>(this)->getComplexFloatImag();
+    return const_cast<APValue *>(this)->getComplexFloatImag();
   }
 
   const LValueBase getLValueBase() const;
   CharUnits &getLValueOffset();
   const CharUnits &getLValueOffset() const {
-    return const_cast<APValue*>(this)->getLValueOffset();
+    return const_cast<APValue *>(this)->getLValueOffset();
   }
   bool isLValueOnePastTheEnd() const;
   bool hasLValuePath() const;
@@ -600,7 +605,7 @@ class APValue {
     return ((Vec *)(char *)&Data)->Elts[I];
   }
   const APValue &getVectorElt(unsigned I) const {
-    return const_cast<APValue*>(this)->getVectorElt(I);
+    return const_cast<APValue *>(this)->getVectorElt(I);
   }
   unsigned getVectorLength() const {
     assert(isVector() && "Invalid accessor");
@@ -644,7 +649,7 @@ class APValue {
     return ((Arr *)(char *)&Data)->Elts[I];
   }
   const APValue &getArrayInitializedElt(unsigned I) const {
-    return const_cast<APValue*>(this)->getArrayInitializedElt(I);
+    return const_cast<APValue *>(this)->getArrayInitializedElt(I);
   }
   bool hasArrayFiller() const {
     return getArrayInitializedElts() != getArraySize();
@@ -655,7 +660,7 @@ class APValue {
     return ((Arr *)(char *)&Data)->Elts[getArrayInitializedElts()];
   }
   const APValue &getArrayFiller() const {
-    return const_cast<APValue*>(this)->getArrayFiller();
+    return const_cast<APValue *>(this)->getArrayFiller();
   }
   unsigned getArrayInitializedElts() const {
     assert(isArray() && "Invalid accessor");
@@ -685,10 +690,10 @@ class APValue {
     return ((StructData *)(char *)&Data)->Elts[getStructNumBases() + i];
   }
   const APValue &getStructBase(unsigned i) const {
-    return const_cast<APValue*>(this)->getStructBase(i);
+    return const_cast<APValue *>(this)->getStructBase(i);
   }
   const APValue &getStructField(unsigned i) const {
-    return const_cast<APValue*>(this)->getStructField(i);
+    return const_cast<APValue *>(this)->getStructField(i);
   }
 
   const FieldDecl *getUnionField() const {
@@ -700,18 +705,18 @@ class APValue {
     return *((UnionData *)(char *)&Data)->Value;
   }
   const APValue &getUnionValue() const {
-    return const_cast<APValue*>(this)->getUnionValue();
+    return const_cast<APValue *>(this)->getUnionValue();
   }
 
   const ValueDecl *getMemberPointerDecl() const;
   bool isMemberPointerToDerivedMember() const;
-  ArrayRef<const CXXRecordDecl*> getMemberPointerPath() const;
+  ArrayRef<const CXXRecordDecl *> getMemberPointerPath() const;
 
-  const AddrLabelExpr* getAddrLabelDiffLHS() const {
+  const AddrLabelExpr *getAddrLabelDiffLHS() const {
     assert(isAddrLabelDiff() && "Invalid accessor");
     return ((const AddrLabelDiffData *)(const char *)&Data)->LHSExpr;
   }
-  const AddrLabelExpr* getAddrLabelDiffRHS() const {
+  const AddrLabelExpr *getAddrLabelDiffRHS() const {
     assert(isAddrLabelDiff() && "Invalid accessor");
     return ((const AddrLabelDiffData *)(const char *)&Data)->RHSExpr;
   }
@@ -721,7 +726,7 @@ class APValue {
     return ((const ReflectionData *)(const char *)&Data)->OperandKind;
   }
 
-  const void* getOpaqueReflectionOperand() const {
+  const void *getOpaqueReflectionOperand() const {
     assert(isReflection() && "Invalid accessor");
     return ((const ReflectionData *)(const char *)&Data)->Operand;
   }
@@ -768,19 +773,17 @@ class APValue {
                  ArrayRef<LValuePathEntry> Path, bool OnePastTheEnd,
                  bool IsNullPtr);
   void setUnion(const FieldDecl *Field, const APValue &Value);
-  void setAddrLabelDiff(const AddrLabelExpr* LHSExpr,
-                        const AddrLabelExpr* RHSExpr) {
+  void setAddrLabelDiff(const AddrLabelExpr *LHSExpr,
+                        const AddrLabelExpr *RHSExpr) {
     ((AddrLabelDiffData *)(char *)&Data)->LHSExpr = LHSExpr;
     ((AddrLabelDiffData *)(char *)&Data)->RHSExpr = RHSExpr;
   }
 
 private:
   void DestroyDataAndMakeUninit();
-  void MakeReflection(ReflectionKind OperandKind,
-                      const void *Operand) {
+  void MakeReflection(ReflectionKind OperandKind, const void *Operand) {
     assert(isAbsent() && "Bad state change");
-    new ((void *)(char *)Data.buffer) ReflectionData(
-            OperandKind, Operand);
+    new ((void *)(char *)Data.buffer) ReflectionData(OperandKind, Operand);
     Kind = Reflection;
   }
   void MakeInt() {
@@ -831,7 +834,7 @@ class APValue {
     Kind = Union;
   }
   void MakeMemberPointer(const ValueDecl *Member, bool IsDerivedMember,
-                         ArrayRef<const CXXRecordDecl*> Path);
+                         ArrayRef<const CXXRecordDecl *> Path);
   void MakeAddrLabelDiff() {
     assert(isAbsent() && "Bad state change");
     new ((void *)(char *)&Data) AddrLabelDiffData();
@@ -869,13 +872,13 @@ class APValue {
 } // end namespace clang.
 
 namespace llvm {
-template<> struct DenseMapInfo<clang::APValue::LValueBase> {
+template <> struct DenseMapInfo<clang::APValue::LValueBase> {
   static clang::APValue::LValueBase getEmptyKey();
   static clang::APValue::LValueBase getTombstoneKey();
   static unsigned getHashValue(const clang::APValue::LValueBase &Base);
   static bool isEqual(const clang::APValue::LValueBase &LHS,
                       const clang::APValue::LValueBase &RHS);
 };
-}
+} // namespace llvm
 
 #endif
diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h
index 824d96cb9dae1..6d55bb76b4e1c 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -497,12 +497,10 @@ class CXXDynamicCastExpr final
   friend class CastExpr;
   friend TrailingObjects;
 
-  static CXXDynamicCastExpr *Create(const ASTContext &Context, QualType T,
-                                    ExprValueKind VK, CastKind Kind, Expr *Op,
-                                    const CXXCastPath *Path,
-                                    TypeSourceInfo *Written, SourceLocation L,
-                                    SourceLocation RParenLoc,
-                                    SourceRange AngleBrackets);
+  static CXXDynamicCastExpr *
+  Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind,
+         Expr *Op, const CXXCastPath *Path, TypeSourceInfo *Written,
+         SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets);
 
   static CXXDynamicCastExpr *CreateEmpty(const ASTContext &Context,
                                          unsigned pathSize);
@@ -542,12 +540,10 @@ class CXXReinterpretCastExpr final
   friend class CastExpr;
   friend TrailingObjects;
 
-  static CXXReinterpretCastExpr *Create(const ASTContext &Context, QualType T,
-                                        ExprValueKind VK, CastKind Kind,
-                                        Expr *Op, const CXXCastPath *Path,
-                                 TypeSourceInfo *WrittenTy, SourceLocation L,
-                                        SourceLocation RParenLoc,
-                                        SourceRange AngleBrackets);
+  static CXXReinterpretCastExpr *
+  Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind,
+         Expr *Op, const CXXCastPath *Path, TypeSourceInfo *WrittenTy,
+         SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets);
   static CXXReinterpretCastExpr *CreateEmpty(const ASTContext &Context,
                                              unsigned pathSize);
 
@@ -696,7 +692,7 @@ class UserDefinedLiteral final : public CallExpr {
   /// removed).
   Expr *getCookedLiteral();
   const Expr *getCookedLiteral() const {
-    return const_cast<UserDefinedLiteral*>(this)->getCookedLiteral();
+    return const_cast<UserDefinedLiteral *>(this)->getCookedLiteral();
   }
 
   SourceLocation getBeginLoc() const {
@@ -815,8 +811,8 @@ class CXXStdInitializerListExpr : public Expr {
     setDependence(computeDependence(this));
   }
 
-  Expr *getSubExpr() { return static_cast<Expr*>(SubExpr); }
-  const Expr *getSubExpr() const { return static_cast<const Expr*>(SubExpr); }
+  Expr *getSubExpr() { return static_cast<Expr *>(SubExpr); }
+  const Expr *getSubExpr() const { return static_cast<const Expr *>(SubExpr); }
 
   SourceLocation getBeginLoc() const LLVM_READONLY {
     return SubExpr->getBeginLoc();
@@ -870,9 +866,9 @@ class CXXTypeidExpr : public Expr {
   CXXTypeidExpr(EmptyShell Empty, bool isExpr)
       : Expr(CXXTypeidExprClass, Empty) {
     if (isExpr)
-      Operand = (Expr*)nullptr;
+      Operand = (Expr *)nullptr;
     else
-      Operand = (TypeSourceInfo*)nullptr;
+      Operand = (TypeSourceInfo *)nullptr;
   }
 
   /// Determine whether this typeid has a type operand which is potentially
@@ -970,13 +966,13 @@ class MSPropertyRefExpr : public Expr {
     else if (QualifierLoc)
       return QualifierLoc.getBeginLoc();
     else
-        return MemberLoc;
+      return MemberLoc;
   }
 
   SourceLocation getEndLoc() const { return getMemberLoc(); }
 
   child_range children() {
-    return child_range((Stmt**)&BaseExpr, (Stmt**)&BaseExpr + 1);
+    return child_range((Stmt **)&BaseExpr, (Stmt **)&BaseExpr + 1);
   }
 
   const_child_range children() const {
@@ -1090,11 +1086,11 @@ class CXXUuidofExpr : public Expr {
   }
 
   CXXUuidofExpr(EmptyShell Empty, bool isExpr)
-    : Expr(CXXUuidofExprClass, Empty) {
+      : Expr(CXXUuidofExprClass, Empty) {
     if (isExpr)
-      Operand = (Expr*)nullptr;
+      Operand = (Expr *)nullptr;
     else
-      Operand = (TypeSourceInfo*)nullptr;
+      Operand = (TypeSourceInfo *)nullptr;
   }
 
   bool isTypeOperand() const { return isa<TypeSourceInfo *>(Operand); }
@@ -1471,9 +1467,7 @@ class CXXTemporary {
 
   const CXXDestructorDecl *getDestructor() const { return Destructor; }
 
-  void setDestructor(const CXXDestructorDecl *Dtor) {
-    Destructor = Dtor;
-  }
+  void setDestructor(const CXXDestructorDecl *Dtor) { Destructor = Dtor; }
 };
 
 /// Represents binding an expression to a temporary.
@@ -1508,7 +1502,7 @@ class CXXBindTemporaryExpr : public Expr {
       : Expr(CXXBindTemporaryExprClass, Empty) {}
 
   static CXXBindTemporaryExpr *Create(const ASTContext &C, CXXTemporary *Temp,
-                                      Expr* SubExpr);
+                                      Expr *SubExpr);
 
   CXXTemporary *getTemporary() { return Temp; }
   const CXXTemporary *getTemporary() const { return Temp; }
@@ -2214,9 +2208,7 @@ class CXXScalarValueInitExpr : public Expr {
   explicit CXXScalarValueInitExpr(EmptyShell Shell)
       : Expr(CXXScalarValueInitExprClass, Shell) {}
 
-  TypeSourceInfo *getTypeSourceInfo() const {
-    return TypeInfo;
-  }
+  TypeSourceInfo *getTypeSourceInfo() const { return TypeInfo; }
 
   SourceLocation getRParenLoc() const {
     return CXXScalarValueInitExprBits.RParenLoc;
@@ -2777,12 +2769,11 @@ class CXXPseudoDestructorExpr : public Expr {
   PseudoDestructorTypeStorage DestroyedType;
 
 public:
-  CXXPseudoDestructorExpr(const ASTContext &Context,
-                          Expr *Base, bool isArrow, SourceLocation OperatorLoc,
+  CXXPseudoDestructorExpr(const ASTContext &Context, Expr *Base, bool isArrow,
+                          SourceLocation OperatorLoc,
                           NestedNameSpecifierLoc QualifierLoc,
                           TypeSourceInfo *ScopeType,
-                          SourceLocation ColonColonLoc,
-                          SourceLocation TildeLoc,
+                          SourceLocation ColonColonLoc, SourceLocation TildeLoc,
                           PseudoDestructorTypeStorage DestroyedType);
 
   explicit CXXPseudoDestructorExpr(EmptyShell Shell)
@@ -2925,8 +2916,7 @@ class TypeTraitExpr final
   static TypeTraitExpr *Create(const ASTContext &C, QualType T,
                                SourceLocation Loc, TypeTrait Kind,
                                ArrayRef<TypeSourceInfo *> Args,
-                               SourceLocation RParenLoc,
-                               bool Value);
+                               SourceLocation RParenLoc, bool Value);
 
   static TypeTraitExpr *Create(const ASTContext &C, QualType T,
                                SourceLocation Loc, TypeTrait Kind,
@@ -3043,7 +3033,10 @@ class ArrayTypeTraitExpr : public Expr {
 
   TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; }
 
-  uint64_t getValue() const { assert(!isTypeDependent()); return Value; }
+  uint64_t getValue() const {
+    assert(!isTypeDependent());
+    return Value;
+  }
 
   Expr *getDimensionExpression() const { return Dimension; }
 
@@ -3076,7 +3069,7 @@ class ExpressionTraitExpr : public Expr {
   SourceLocation RParen;
 
   /// The expression being queried.
-  Expr* QueriedExpression = nullptr;
+  Expr *QueriedExpression = nullptr;
 
 public:
   friend class ASTStmtReader;
@@ -3810,7 +3803,7 @@ class CXXUnresolvedConstructExpr final
   arg_iterator arg_end() { return arg_begin() + getNumArgs(); }
   arg_range arguments() { return arg_range(arg_begin(), arg_end()); }
 
-  using const_arg_iterator = const Expr* const *;
+  using const_arg_iterator = const Expr *const *;
   using const_arg_range = llvm::iterator_range<const_arg_iterator>;
 
   const_arg_iterator arg_begin() const { return getTrailingObjects(); }
@@ -4420,9 +4413,7 @@ class PackExpansionExpr : public Expr {
   }
 
   // Iterators
-  child_range children() {
-    return child_range(&Pattern, &Pattern + 1);
-  }
+  child_range children() { return child_range(&Pattern, &Pattern + 1); }
 
   const_child_range children() const {
     return const_child_range(&Pattern, &Pattern + 1);
@@ -4525,9 +4516,7 @@ class SizeOfPackExpr final
   ///
   ///   template<typename ...Ts> using X = int[sizeof...(Ts)];
   ///   template<typename ...Us> void f(X<Us..., 1, 2, 3, Us...>);
-  bool isPartiallySubstituted() const {
-    return isValueDependent() && Length;
-  }
+  bool isPartiallySubstituted() const { return isValueDependent() && Length; }
 
   /// Get
   ArrayRef<TemplateArgument> getPartialArguments() const {
@@ -5056,8 +5045,8 @@ class CXXFoldExpr : public Expr {
   UnresolvedLookupExpr *getCallee() const {
     return static_cast<UnresolvedLookupExpr *>(SubExprs[SubExpr::Callee]);
   }
-  Expr *getLHS() const { return static_cast<Expr*>(SubExprs[SubExpr::LHS]); }
-  Expr *getRHS() const { return static_cast<Expr*>(SubExprs[SubExpr::RHS]); }
+  Expr *getLHS() const { return static_cast<Expr *>(SubExprs[SubExpr::LHS]); }
+  Expr *getRHS() const { return static_cast<Expr *>(SubExprs[SubExpr::RHS]); }
 
   /// Does this produce a right-associated sequence of operators?
   bool isRightFold() const {
@@ -5304,22 +5293,22 @@ class CoroutineSuspendExpr : public Expr {
   }
 
   Expr *getCommonExpr() const {
-    return static_cast<Expr*>(SubExprs[SubExpr::Common]);
+    return static_cast<Expr *>(SubExprs[SubExpr::Common]);
   }
 
   /// getOpaqueValue - Return the opaque value placeholder.
   OpaqueValueExpr *getOpaqueValue() const { return OpaqueValue; }
 
   Expr *getReadyExpr() const {
-    return static_cast<Expr*>(SubExprs[SubExpr::Ready]);
+    return static_cast<Expr *>(SubExprs[SubExpr::Ready]);
   }
 
   Expr *getSuspendExpr() const {
-    return static_cast<Expr*>(SubExprs[SubExpr::Suspend]);
+    return static_cast<Expr *>(SubExprs[SubExpr::Suspend]);
   }
 
   Expr *getResumeExpr() const {
-    return static_cast<Expr*>(SubExprs[SubExpr::Resume]);
+    return static_cast<Expr *>(SubExprs[SubExpr::Resume]);
   }
 
   // The syntactic operand written in the code
@@ -5509,18 +5498,18 @@ class BuiltinBitCastExpr final
 ///  - an id-expression.
 class CXXReflectExpr : public Expr {
 
+private:
+  // TODO(Reflection): add support for TemplateReference, NamespaceReference and
+  // DeclRefExpr
+  using operand_type = llvm::PointerUnion<const TypeSourceInfo *>;
 
-  private:
-    // TODO(Reflection): add support for TemplateReference, NamespaceReference and
-    // DeclRefExpr
-    using operand_type = llvm::PointerUnion<const TypeSourceInfo *>;
-
-    SourceLocation CaretCaretLoc;
-    ReflectionKind Kind;
-    operand_type Operand;
+  SourceLocation CaretCaretLoc;
+  ReflectionKind Kind;
+  operand_type Operand;
 
-    CXXReflectExpr(ASTContext &C, SourceLocation CaretCaretLoc, const TypeSourceInfo *TSI);
-    CXXReflectExpr(EmptyShell Empty);
+  CXXReflectExpr(ASTContext &C, SourceLocation CaretCaretLoc,
+                 const TypeSourceInfo *TSI);
+  CXXReflectExpr(EmptyShell Empty);
 
 public:
   static CXXReflectExpr *Create(ASTContext &C, SourceLocation OperatorLoc,
@@ -5543,7 +5532,7 @@ class CXXReflectExpr : public Expr {
   /// Returns location of the '^^'-operator.
   SourceLocation getOperatorLoc() const { return CaretCaretLoc; }
   ReflectionKind getKind() const { return Kind; }
-  const void* getOpaqueValue() const { return Operand.getOpaqueValue(); }
+  const void *getOpaqueValue() const { return Operand.getOpaqueValue(); }
 
   child_range children() {
     // TODO(Reflection)
diff --git a/clang/include/clang/AST/Reflection.h b/clang/include/clang/AST/Reflection.h
index 140f48af6efe3..c50c20a0c5afc 100644
--- a/clang/include/clang/AST/Reflection.h
+++ b/clang/include/clang/AST/Reflection.h
@@ -10,16 +10,13 @@
 //
 //===----------------------------------------------------------------------===//
 
-
 #ifndef LLVM_CLANG_AST_REFLECTION_H
 #define LLVM_CLANG_AST_REFLECTION_H
 namespace clang {
 
 // TODO(Reflection): Add support for Template, Namespace and DeclRefExpr.
-enum class ReflectionKind {
-  Type
-};
+enum class ReflectionKind { Type };
 
-}
+} // namespace clang
 
 #endif
diff --git a/clang/lib/AST/APValue.cpp b/clang/lib/AST/APValue.cpp
index 32faed3bcb1dc..03b45bd3dc461 100644
--- a/clang/lib/AST/APValue.cpp
+++ b/clang/lib/AST/APValue.cpp
@@ -61,8 +61,9 @@ APValue::LValueBase APValue::LValueBase::getTypeInfo(TypeInfoLValue LV,
 }
 
 QualType APValue::LValueBase::getType() const {
-  if (!*this) return QualType();
-  if (const ValueDecl *D = dyn_cast<const ValueDecl*>()) {
+  if (!*this)
+    return QualType();
+  if (const ValueDecl *D = dyn_cast<const ValueDecl *>()) {
     // FIXME: It's unclear where we're supposed to take the type from, and
     // this actually matters for arrays of unknown bound. Eg:
     //
@@ -85,7 +86,7 @@ QualType APValue::LValueBase::getType() const {
   if (is<DynamicAllocLValue>())
     return getDynamicAllocType();
 
-  const Expr *Base = get<const Expr*>();
+  const Expr *Base = get<const Expr *>();
 
   // For a materialized temporary, the type of the temporary we materialized
   // may not be the type of the expression.
@@ -94,8 +95,8 @@ QualType APValue::LValueBase::getType() const {
     SmallVector<const Expr *, 2> CommaLHSs;
     SmallVector<SubobjectAdjustment, 2> Adjustments;
     const Expr *Temp = MTE->getSubExpr();
-    const Expr *Inner = Temp->skipRValueSubobjectAdjustments(CommaLHSs,
-                                                             Adjustments);
+    const Expr *Inner =
+        Temp->skipRValueSubobjectAdjustments(CommaLHSs, Adjustments);
     // Keep any cv-qualifiers from the reference if we generated a temporary
     // for it directly. Otherwise use the type after adjustment.
     if (!Adjustments.empty())
@@ -142,7 +143,7 @@ bool operator==(const APValue::LValueBase &LHS,
   return LHS.Local.CallIndex == RHS.Local.CallIndex &&
          LHS.Local.Version == RHS.Local.Version;
 }
-}
+} // namespace clang
 
 APValue::LValuePathEntry::LValuePathEntry(BaseOrMemberType BaseOrMember) {
   if (const Decl *D = BaseOrMember.getPointer())
@@ -163,38 +164,34 @@ QualType APValue::LValuePathSerializationHelper::getType() {
 }
 
 namespace {
-  struct LVBase {
-    APValue::LValueBase Base;
-    CharUnits Offset;
-    unsigned PathLength;
-    bool IsNullPtr : 1;
-    bool IsOnePastTheEnd : 1;
-  };
-}
+struct LVBase {
+  APValue::LValueBase Base;
+  CharUnits Offset;
+  unsigned PathLength;
+  bool IsNullPtr : 1;
+  bool IsOnePastTheEnd : 1;
+};
+} // namespace
 
 void *APValue::LValueBase::getOpaqueValue() const {
   return Ptr.getOpaqueValue();
 }
 
-bool APValue::LValueBase::isNull() const {
-  return Ptr.isNull();
-}
+bool APValue::LValueBase::isNull() const { return Ptr.isNull(); }
 
-APValue::LValueBase::operator bool () const {
-  return static_cast<bool>(Ptr);
-}
+APValue::LValueBase::operator bool() const { return static_cast<bool>(Ptr); }
 
 clang::APValue::LValueBase
 llvm::DenseMapInfo<clang::APValue::LValueBase>::getEmptyKey() {
   clang::APValue::LValueBase B;
-  B.Ptr = DenseMapInfo<const ValueDecl*>::getEmptyKey();
+  B.Ptr = DenseMapInfo<const ValueDecl *>::getEmptyKey();
   return B;
 }
 
 clang::APValue::LValueBase
 llvm::DenseMapInfo<clang::APValue::LValueBase>::getTombstoneKey() {
   clang::APValue::LValueBase B;
-  B.Ptr = DenseMapInfo<const ValueDecl*>::getTombstoneKey();
+  B.Ptr = DenseMapInfo<const ValueDecl *>::getTombstoneKey();
   return B;
 }
 
@@ -205,7 +202,7 @@ llvm::hash_code hash_value(const APValue::LValueBase &Base) {
   return llvm::hash_combine(Base.getOpaqueValue(), Base.getCallIndex(),
                             Base.getVersion());
 }
-}
+} // namespace clang
 
 unsigned llvm::DenseMapInfo<clang::APValue::LValueBase>::getHashValue(
     const clang::APValue::LValueBase &Base) {
@@ -237,7 +234,7 @@ struct APValue::LV : LVBase {
     if (Length == PathLength)
       return;
     if (hasPathPtr())
-      delete [] PathPtr;
+      delete[] PathPtr;
     PathLength = Length;
     if (hasPathPtr())
       PathPtr = new LValuePathEntry[Length];
@@ -253,15 +250,15 @@ struct APValue::LV : LVBase {
 };
 
 namespace {
-  struct MemberPointerBase {
-    llvm::PointerIntPair<const ValueDecl*, 1, bool> MemberAndIsDerivedMember;
-    unsigned PathLength;
-  };
-}
+struct MemberPointerBase {
+  llvm::PointerIntPair<const ValueDecl *, 1, bool> MemberAndIsDerivedMember;
+  unsigned PathLength;
+};
+} // namespace
 
 struct APValue::MemberPointerData : MemberPointerBase {
   static const unsigned InlinePathSpace =
-      (DataSize - sizeof(MemberPointerBase)) / sizeof(const CXXRecordDecl*);
+      (DataSize - sizeof(MemberPointerBase)) / sizeof(const CXXRecordDecl *);
   typedef const CXXRecordDecl *PathElem;
   union {
     PathElem Path[InlinePathSpace];
@@ -275,7 +272,7 @@ struct APValue::MemberPointerData : MemberPointerBase {
     if (Length == PathLength)
       return;
     if (hasPathPtr())
-      delete [] PathPtr;
+      delete[] PathPtr;
     PathLength = Length;
     if (hasPathPtr())
       PathPtr = new PathElem[Length];
@@ -284,29 +281,23 @@ struct APValue::MemberPointerData : MemberPointerBase {
   bool hasPathPtr() const { return PathLength > InlinePathSpace; }
 
   PathElem *getPath() { return hasPathPtr() ? PathPtr : Path; }
-  const PathElem *getPath() const {
-    return hasPathPtr() ? PathPtr : Path;
-  }
+  const PathElem *getPath() const { return hasPathPtr() ? PathPtr : Path; }
 };
 
 // FIXME: Reduce the malloc traffic here.
 
-APValue::Arr::Arr(unsigned NumElts, unsigned Size) :
-  Elts(new APValue[NumElts + (NumElts != Size ? 1 : 0)]),
-  NumElts(NumElts), ArrSize(Size) {}
-APValue::Arr::~Arr() { delete [] Elts; }
+APValue::Arr::Arr(unsigned NumElts, unsigned Size)
+    : Elts(new APValue[NumElts + (NumElts != Size ? 1 : 0)]), NumElts(NumElts),
+      ArrSize(Size) {}
+APValue::Arr::~Arr() { delete[] Elts; }
 
-APValue::StructData::StructData(unsigned NumBases, unsigned NumFields) :
-  Elts(new APValue[NumBases+NumFields]),
-  NumBases(NumBases), NumFields(NumFields) {}
-APValue::StructData::~StructData() {
-  delete [] Elts;
-}
+APValue::StructData::StructData(unsigned NumBases, unsigned NumFields)
+    : Elts(new APValue[NumBases + NumFields]), NumBases(NumBases),
+      NumFields(NumFields) {}
+APValue::StructData::~StructData() { delete[] Elts; }
 
 APValue::UnionData::UnionData() : Field(nullptr), Value(new APValue) {}
-APValue::UnionData::~UnionData () {
-  delete Value;
-}
+APValue::UnionData::~UnionData() { delete Value; }
 
 APValue::APValue(const APValue &RHS)
     : Kind(None), AllowConstexprUnknown(RHS.AllowConstexprUnknown) {
@@ -383,7 +374,8 @@ APValue::APValue(const APValue &RHS)
     setAddrLabelDiff(RHS.getAddrLabelDiffLHS(), RHS.getAddrLabelDiffRHS());
     break;
   case Reflection:
-    MakeReflection(RHS.getReflectionOperandKind(), RHS.getOpaqueReflectionOperand());
+    MakeReflection(RHS.getReflectionOperandKind(),
+                   RHS.getOpaqueReflectionOperand());
     break;
   }
 }
@@ -503,11 +495,12 @@ static void profileIntValue(llvm::FoldingSetNodeID &ID, const llvm::APInt &V) {
 static void profileReflection(llvm::FoldingSetNodeID &ID, APValue V) {
   ID.AddInteger(static_cast<int>(V.getReflectionOperandKind()));
   switch (V.getReflectionOperandKind()) {
-    case ReflectionKind::Type: {
-      const TypeSourceInfo* info = static_cast<const TypeSourceInfo*>(V.getOpaqueReflectionOperand());
-      ID.AddPointer((info->getType().getCanonicalType().getAsOpaquePtr()));
-      return;
-    }
+  case ReflectionKind::Type: {
+    const TypeSourceInfo *info =
+        static_cast<const TypeSourceInfo *>(V.getOpaqueReflectionOperand());
+    ID.AddPointer((info->getType().getCanonicalType().getAsOpaquePtr()));
+    return;
+  }
     assert(false && "unknown or unimplemented reflection entities");
   }
 }
@@ -809,8 +802,8 @@ void APValue::printPretty(raw_ostream &Out, const PrintingPolicy &Policy,
     return;
   case APValue::LValue: {
     bool IsReference = Ty->isReferenceType();
-    QualType InnerTy
-      = IsReference ? Ty.getNonReferenceType() : Ty->getPointeeType();
+    QualType InnerTy =
+        IsReference ? Ty.getNonReferenceType() : Ty->getPointeeType();
     if (InnerTy.isNull())
       InnerTy = Ty;
 
@@ -846,18 +839,17 @@ void APValue::printPretty(raw_ostream &Out, const PrintingPolicy &Policy,
         Out << '&';
       }
 
-      if (const ValueDecl *VD = Base.dyn_cast<const ValueDecl*>())
+      if (const ValueDecl *VD = Base.dyn_cast<const ValueDecl *>())
         Out << *VD;
       else if (TypeInfoLValue TI = Base.dyn_cast<TypeInfoLValue>()) {
         TI.print(Out, Policy);
       } else if (DynamicAllocLValue DA = Base.dyn_cast<DynamicAllocLValue>()) {
-        Out << "{*new "
-            << Base.getDynamicAllocType().stream(Policy) << "#"
+        Out << "{*new " << Base.getDynamicAllocType().stream(Policy) << "#"
             << DA.getIndex() << "}";
       } else {
         assert(Base.get<const Expr *>() != nullptr &&
                "Expecting non-null Expr");
-        Base.get<const Expr*>()->printPretty(Out, nullptr, Policy);
+        Base.get<const Expr *>()->printPretty(Out, nullptr, Policy);
       }
 
       if (!O.isZero()) {
@@ -875,7 +867,7 @@ void APValue::printPretty(raw_ostream &Out, const PrintingPolicy &Policy,
       Out << "*(&";
 
     QualType ElemTy = Base.getType().getNonReferenceType();
-    if (const ValueDecl *VD = Base.dyn_cast<const ValueDecl*>()) {
+    if (const ValueDecl *VD = Base.dyn_cast<const ValueDecl *>()) {
       Out << *VD;
     } else if (TypeInfoLValue TI = Base.dyn_cast<TypeInfoLValue>()) {
       TI.print(Out, Policy);
@@ -883,7 +875,7 @@ void APValue::printPretty(raw_ostream &Out, const PrintingPolicy &Policy,
       Out << "{*new " << Base.getDynamicAllocType().stream(Policy) << "#"
           << DA.getIndex() << "}";
     } else {
-      const Expr *E = Base.get<const Expr*>();
+      const Expr *E = Base.get<const Expr *>();
       assert(E != nullptr && "Expecting non-null Expr");
       E->printPretty(Out, nullptr, Policy);
     }
@@ -973,8 +965,8 @@ void APValue::printPretty(raw_ostream &Out, const PrintingPolicy &Policy,
         Out << ", ";
       if (FI->isUnnamedBitField())
         continue;
-      getStructField(FI->getFieldIndex()).
-        printPretty(Out, Policy, FI->getType(), Ctx);
+      getStructField(FI->getFieldIndex())
+          .printPretty(Out, Policy, FI->getType(), Ctx);
       First = false;
     }
     Out << '}';
@@ -1130,7 +1122,7 @@ bool APValue::isMemberPointerToDerivedMember() const {
   return MPD.MemberAndIsDerivedMember.getInt();
 }
 
-ArrayRef<const CXXRecordDecl*> APValue::getMemberPointerPath() const {
+ArrayRef<const CXXRecordDecl *> APValue::getMemberPointerPath() const {
   assert(isMemberPointer() && "Invalid accessor");
   const MemberPointerData &MPD =
       *((const MemberPointerData *)(const char *)&Data);
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 827710c01e73b..752a3733f5a38 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -48,10 +48,10 @@
 #include "clang/AST/OSLog.h"
 #include "clang/AST/OptionalDiagnostic.h"
 #include "clang/AST/RecordLayout.h"
+#include "clang/AST/Reflection.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/AST/Type.h"
 #include "clang/AST/TypeLoc.h"
-#include "clang/AST/Reflection.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/DiagnosticSema.h"
 #include "clang/Basic/TargetBuiltins.h"
@@ -75,667 +75,651 @@
 
 using namespace clang;
 using llvm::APFixedPoint;
+using llvm::APFloat;
 using llvm::APInt;
 using llvm::APSInt;
-using llvm::APFloat;
 using llvm::FixedPointSemantics;
 
 namespace {
-  struct LValue;
-  class CallStackFrame;
-  class EvalInfo;
+struct LValue;
+class CallStackFrame;
+class EvalInfo;
 
-  using SourceLocExprScopeGuard =
-      CurrentSourceLocExprScope::SourceLocExprScopeGuard;
+using SourceLocExprScopeGuard =
+    CurrentSourceLocExprScope::SourceLocExprScopeGuard;
 
-  static QualType getType(APValue::LValueBase B) {
-    return B.getType();
-  }
+static QualType getType(APValue::LValueBase B) { return B.getType(); }
 
-  /// Get an LValue path entry, which is known to not be an array index, as a
-  /// field declaration.
-  static const FieldDecl *getAsField(APValue::LValuePathEntry E) {
-    return dyn_cast_or_null<FieldDecl>(E.getAsBaseOrMember().getPointer());
-  }
-  /// Get an LValue path entry, which is known to not be an array index, as a
-  /// base class declaration.
-  static const CXXRecordDecl *getAsBaseClass(APValue::LValuePathEntry E) {
-    return dyn_cast_or_null<CXXRecordDecl>(E.getAsBaseOrMember().getPointer());
-  }
-  /// Determine whether this LValue path entry for a base class names a virtual
-  /// base class.
-  static bool isVirtualBaseClass(APValue::LValuePathEntry E) {
-    return E.getAsBaseOrMember().getInt();
-  }
+/// Get an LValue path entry, which is known to not be an array index, as a
+/// field declaration.
+static const FieldDecl *getAsField(APValue::LValuePathEntry E) {
+  return dyn_cast_or_null<FieldDecl>(E.getAsBaseOrMember().getPointer());
+}
+/// Get an LValue path entry, which is known to not be an array index, as a
+/// base class declaration.
+static const CXXRecordDecl *getAsBaseClass(APValue::LValuePathEntry E) {
+  return dyn_cast_or_null<CXXRecordDecl>(E.getAsBaseOrMember().getPointer());
+}
+/// Determine whether this LValue path entry for a base class names a virtual
+/// base class.
+static bool isVirtualBaseClass(APValue::LValuePathEntry E) {
+  return E.getAsBaseOrMember().getInt();
+}
 
-  /// Given an expression, determine the type used to store the result of
-  /// evaluating that expression.
-  static QualType getStorageType(const ASTContext &Ctx, const Expr *E) {
-    if (E->isPRValue())
-      return E->getType();
-    return Ctx.getLValueReferenceType(E->getType());
-  }
+/// Given an expression, determine the type used to store the result of
+/// evaluating that expression.
+static QualType getStorageType(const ASTContext &Ctx, const Expr *E) {
+  if (E->isPRValue())
+    return E->getType();
+  return Ctx.getLValueReferenceType(E->getType());
+}
 
-  /// Attempts to unwrap a CallExpr (with an alloc_size attribute) from an Expr.
-  /// This will look through a single cast.
-  ///
-  /// Returns null if we couldn't unwrap a function with alloc_size.
-  static const CallExpr *tryUnwrapAllocSizeCall(const Expr *E) {
-    if (!E->getType()->isPointerType())
-      return nullptr;
+/// Attempts to unwrap a CallExpr (with an alloc_size attribute) from an Expr.
+/// This will look through a single cast.
+///
+/// Returns null if we couldn't unwrap a function with alloc_size.
+static const CallExpr *tryUnwrapAllocSizeCall(const Expr *E) {
+  if (!E->getType()->isPointerType())
+    return nullptr;
 
-    E = E->IgnoreParens();
-    // If we're doing a variable assignment from e.g. malloc(N), there will
-    // probably be a cast of some kind. In exotic cases, we might also see a
-    // top-level ExprWithCleanups. Ignore them either way.
-    if (const auto *FE = dyn_cast<FullExpr>(E))
-      E = FE->getSubExpr()->IgnoreParens();
+  E = E->IgnoreParens();
+  // If we're doing a variable assignment from e.g. malloc(N), there will
+  // probably be a cast of some kind. In exotic cases, we might also see a
+  // top-level ExprWithCleanups. Ignore them either way.
+  if (const auto *FE = dyn_cast<FullExpr>(E))
+    E = FE->getSubExpr()->IgnoreParens();
 
-    if (const auto *Cast = dyn_cast<CastExpr>(E))
-      E = Cast->getSubExpr()->IgnoreParens();
+  if (const auto *Cast = dyn_cast<CastExpr>(E))
+    E = Cast->getSubExpr()->IgnoreParens();
 
-    if (const auto *CE = dyn_cast<CallExpr>(E))
-      return CE->getCalleeAllocSizeAttr() ? CE : nullptr;
-    return nullptr;
-  }
+  if (const auto *CE = dyn_cast<CallExpr>(E))
+    return CE->getCalleeAllocSizeAttr() ? CE : nullptr;
+  return nullptr;
+}
 
-  /// Determines whether or not the given Base contains a call to a function
-  /// with the alloc_size attribute.
-  static bool isBaseAnAllocSizeCall(APValue::LValueBase Base) {
-    const auto *E = Base.dyn_cast<const Expr *>();
-    return E && E->getType()->isPointerType() && tryUnwrapAllocSizeCall(E);
-  }
+/// Determines whether or not the given Base contains a call to a function
+/// with the alloc_size attribute.
+static bool isBaseAnAllocSizeCall(APValue::LValueBase Base) {
+  const auto *E = Base.dyn_cast<const Expr *>();
+  return E && E->getType()->isPointerType() && tryUnwrapAllocSizeCall(E);
+}
 
-  /// Determines whether the given kind of constant expression is only ever
-  /// used for name mangling. If so, it's permitted to reference things that we
-  /// can't generate code for (in particular, dllimported functions).
-  static bool isForManglingOnly(ConstantExprKind Kind) {
-    switch (Kind) {
-    case ConstantExprKind::Normal:
-    case ConstantExprKind::ClassTemplateArgument:
-    case ConstantExprKind::ImmediateInvocation:
-      // Note that non-type template arguments of class type are emitted as
-      // template parameter objects.
-      return false;
+/// Determines whether the given kind of constant expression is only ever
+/// used for name mangling. If so, it's permitted to reference things that we
+/// can't generate code for (in particular, dllimported functions).
+static bool isForManglingOnly(ConstantExprKind Kind) {
+  switch (Kind) {
+  case ConstantExprKind::Normal:
+  case ConstantExprKind::ClassTemplateArgument:
+  case ConstantExprKind::ImmediateInvocation:
+    // Note that non-type template arguments of class type are emitted as
+    // template parameter objects.
+    return false;
 
-    case ConstantExprKind::NonClassTemplateArgument:
-      return true;
-    }
-    llvm_unreachable("unknown ConstantExprKind");
+  case ConstantExprKind::NonClassTemplateArgument:
+    return true;
   }
+  llvm_unreachable("unknown ConstantExprKind");
+}
 
-  static bool isTemplateArgument(ConstantExprKind Kind) {
-    switch (Kind) {
-    case ConstantExprKind::Normal:
-    case ConstantExprKind::ImmediateInvocation:
-      return false;
+static bool isTemplateArgument(ConstantExprKind Kind) {
+  switch (Kind) {
+  case ConstantExprKind::Normal:
+  case ConstantExprKind::ImmediateInvocation:
+    return false;
 
-    case ConstantExprKind::ClassTemplateArgument:
-    case ConstantExprKind::NonClassTemplateArgument:
-      return true;
-    }
-    llvm_unreachable("unknown ConstantExprKind");
-  }
-
-  /// The bound to claim that an array of unknown bound has.
-  /// The value in MostDerivedArraySize is undefined in this case. So, set it
-  /// to an arbitrary value that's likely to loudly break things if it's used.
-  static const uint64_t AssumedSizeForUnsizedArray =
-      std::numeric_limits<uint64_t>::max() / 2;
-
-  /// Determines if an LValue with the given LValueBase will have an unsized
-  /// array in its designator.
-  /// Find the path length and type of the most-derived subobject in the given
-  /// path, and find the size of the containing array, if any.
-  static unsigned
-  findMostDerivedSubobject(const ASTContext &Ctx, APValue::LValueBase Base,
-                           ArrayRef<APValue::LValuePathEntry> Path,
-                           uint64_t &ArraySize, QualType &Type, bool &IsArray,
-                           bool &FirstEntryIsUnsizedArray) {
-    // This only accepts LValueBases from APValues, and APValues don't support
-    // arrays that lack size info.
-    assert(!isBaseAnAllocSizeCall(Base) &&
-           "Unsized arrays shouldn't appear here");
-    unsigned MostDerivedLength = 0;
-    // The type of Base is a reference type if the base is a constexpr-unknown
-    // variable. In that case, look through the reference type.
-    Type = getType(Base).getNonReferenceType();
-
-    for (unsigned I = 0, N = Path.size(); I != N; ++I) {
-      if (Type->isArrayType()) {
-        const ArrayType *AT = Ctx.getAsArrayType(Type);
-        Type = AT->getElementType();
-        MostDerivedLength = I + 1;
-        IsArray = true;
-
-        if (auto *CAT = dyn_cast<ConstantArrayType>(AT)) {
-          ArraySize = CAT->getZExtSize();
-        } else {
-          assert(I == 0 && "unexpected unsized array designator");
-          FirstEntryIsUnsizedArray = true;
-          ArraySize = AssumedSizeForUnsizedArray;
-        }
-      } else if (Type->isAnyComplexType()) {
-        const ComplexType *CT = Type->castAs<ComplexType>();
-        Type = CT->getElementType();
-        ArraySize = 2;
-        MostDerivedLength = I + 1;
-        IsArray = true;
-      } else if (const auto *VT = Type->getAs<VectorType>()) {
-        Type = VT->getElementType();
-        ArraySize = VT->getNumElements();
-        MostDerivedLength = I + 1;
-        IsArray = true;
-      } else if (const FieldDecl *FD = getAsField(Path[I])) {
-        Type = FD->getType();
-        ArraySize = 0;
-        MostDerivedLength = I + 1;
-        IsArray = false;
+  case ConstantExprKind::ClassTemplateArgument:
+  case ConstantExprKind::NonClassTemplateArgument:
+    return true;
+  }
+  llvm_unreachable("unknown ConstantExprKind");
+}
+
+/// The bound to claim that an array of unknown bound has.
+/// The value in MostDerivedArraySize is undefined in this case. So, set it
+/// to an arbitrary value that's likely to loudly break things if it's used.
+static const uint64_t AssumedSizeForUnsizedArray =
+    std::numeric_limits<uint64_t>::max() / 2;
+
+/// Determines if an LValue with the given LValueBase will have an unsized
+/// array in its designator.
+/// Find the path length and type of the most-derived subobject in the given
+/// path, and find the size of the containing array, if any.
+static unsigned
+findMostDerivedSubobject(const ASTContext &Ctx, APValue::LValueBase Base,
+                         ArrayRef<APValue::LValuePathEntry> Path,
+                         uint64_t &ArraySize, QualType &Type, bool &IsArray,
+                         bool &FirstEntryIsUnsizedArray) {
+  // This only accepts LValueBases from APValues, and APValues don't support
+  // arrays that lack size info.
+  assert(!isBaseAnAllocSizeCall(Base) &&
+         "Unsized arrays shouldn't appear here");
+  unsigned MostDerivedLength = 0;
+  // The type of Base is a reference type if the base is a constexpr-unknown
+  // variable. In that case, look through the reference type.
+  Type = getType(Base).getNonReferenceType();
+
+  for (unsigned I = 0, N = Path.size(); I != N; ++I) {
+    if (Type->isArrayType()) {
+      const ArrayType *AT = Ctx.getAsArrayType(Type);
+      Type = AT->getElementType();
+      MostDerivedLength = I + 1;
+      IsArray = true;
+
+      if (auto *CAT = dyn_cast<ConstantArrayType>(AT)) {
+        ArraySize = CAT->getZExtSize();
       } else {
-        // Path[I] describes a base class.
-        ArraySize = 0;
-        IsArray = false;
-      }
-    }
-    return MostDerivedLength;
-  }
-
-  /// A path from a glvalue to a subobject of that glvalue.
-  struct SubobjectDesignator {
-    /// True if the subobject was named in a manner not supported by C++11. Such
-    /// lvalues can still be folded, but they are not core constant expressions
-    /// and we cannot perform lvalue-to-rvalue conversions on them.
-    LLVM_PREFERRED_TYPE(bool)
-    unsigned Invalid : 1;
-
-    /// Is this a pointer one past the end of an object?
-    LLVM_PREFERRED_TYPE(bool)
-    unsigned IsOnePastTheEnd : 1;
-
-    /// Indicator of whether the first entry is an unsized array.
-    LLVM_PREFERRED_TYPE(bool)
-    unsigned FirstEntryIsAnUnsizedArray : 1;
-
-    /// Indicator of whether the most-derived object is an array element.
-    LLVM_PREFERRED_TYPE(bool)
-    unsigned MostDerivedIsArrayElement : 1;
-
-    /// The length of the path to the most-derived object of which this is a
-    /// subobject.
-    unsigned MostDerivedPathLength : 28;
-
-    /// The size of the array of which the most-derived object is an element.
-    /// This will always be 0 if the most-derived object is not an array
-    /// element. 0 is not an indicator of whether or not the most-derived object
-    /// is an array, however, because 0-length arrays are allowed.
-    ///
-    /// If the current array is an unsized array, the value of this is
-    /// undefined.
-    uint64_t MostDerivedArraySize;
-    /// The type of the most derived object referred to by this address.
-    QualType MostDerivedType;
-
-    typedef APValue::LValuePathEntry PathEntry;
-
-    /// The entries on the path from the glvalue to the designated subobject.
-    SmallVector<PathEntry, 8> Entries;
-
-    SubobjectDesignator() : Invalid(true) {}
-
-    explicit SubobjectDesignator(QualType T)
-        : Invalid(false), IsOnePastTheEnd(false),
-          FirstEntryIsAnUnsizedArray(false), MostDerivedIsArrayElement(false),
-          MostDerivedPathLength(0), MostDerivedArraySize(0),
-          MostDerivedType(T.isNull() ? QualType() : T.getNonReferenceType()) {}
-
-    SubobjectDesignator(const ASTContext &Ctx, const APValue &V)
-        : Invalid(!V.isLValue() || !V.hasLValuePath()), IsOnePastTheEnd(false),
-          FirstEntryIsAnUnsizedArray(false), MostDerivedIsArrayElement(false),
-          MostDerivedPathLength(0), MostDerivedArraySize(0) {
-      assert(V.isLValue() && "Non-LValue used to make an LValue designator?");
-      if (!Invalid) {
-        IsOnePastTheEnd = V.isLValueOnePastTheEnd();
-        llvm::append_range(Entries, V.getLValuePath());
-        if (V.getLValueBase()) {
-          bool IsArray = false;
-          bool FirstIsUnsizedArray = false;
-          MostDerivedPathLength = findMostDerivedSubobject(
-              Ctx, V.getLValueBase(), V.getLValuePath(), MostDerivedArraySize,
-              MostDerivedType, IsArray, FirstIsUnsizedArray);
-          MostDerivedIsArrayElement = IsArray;
-          FirstEntryIsAnUnsizedArray = FirstIsUnsizedArray;
-        }
+        assert(I == 0 && "unexpected unsized array designator");
+        FirstEntryIsUnsizedArray = true;
+        ArraySize = AssumedSizeForUnsizedArray;
       }
+    } else if (Type->isAnyComplexType()) {
+      const ComplexType *CT = Type->castAs<ComplexType>();
+      Type = CT->getElementType();
+      ArraySize = 2;
+      MostDerivedLength = I + 1;
+      IsArray = true;
+    } else if (const auto *VT = Type->getAs<VectorType>()) {
+      Type = VT->getElementType();
+      ArraySize = VT->getNumElements();
+      MostDerivedLength = I + 1;
+      IsArray = true;
+    } else if (const FieldDecl *FD = getAsField(Path[I])) {
+      Type = FD->getType();
+      ArraySize = 0;
+      MostDerivedLength = I + 1;
+      IsArray = false;
+    } else {
+      // Path[I] describes a base class.
+      ArraySize = 0;
+      IsArray = false;
     }
+  }
+  return MostDerivedLength;
+}
 
-    void truncate(ASTContext &Ctx, APValue::LValueBase Base,
-                  unsigned NewLength) {
-      if (Invalid)
-        return;
+/// A path from a glvalue to a subobject of that glvalue.
+struct SubobjectDesignator {
+  /// True if the subobject was named in a manner not supported by C++11. Such
+  /// lvalues can still be folded, but they are not core constant expressions
+  /// and we cannot perform lvalue-to-rvalue conversions on them.
+  LLVM_PREFERRED_TYPE(bool)
+  unsigned Invalid : 1;
 
-      assert(Base && "cannot truncate path for null pointer");
-      assert(NewLength <= Entries.size() && "not a truncation");
+  /// Is this a pointer one past the end of an object?
+  LLVM_PREFERRED_TYPE(bool)
+  unsigned IsOnePastTheEnd : 1;
 
-      if (NewLength == Entries.size())
-        return;
-      Entries.resize(NewLength);
+  /// Indicator of whether the first entry is an unsized array.
+  LLVM_PREFERRED_TYPE(bool)
+  unsigned FirstEntryIsAnUnsizedArray : 1;
 
-      bool IsArray = false;
-      bool FirstIsUnsizedArray = false;
-      MostDerivedPathLength = findMostDerivedSubobject(
-          Ctx, Base, Entries, MostDerivedArraySize, MostDerivedType, IsArray,
-          FirstIsUnsizedArray);
-      MostDerivedIsArrayElement = IsArray;
-      FirstEntryIsAnUnsizedArray = FirstIsUnsizedArray;
-    }
+  /// Indicator of whether the most-derived object is an array element.
+  LLVM_PREFERRED_TYPE(bool)
+  unsigned MostDerivedIsArrayElement : 1;
 
-    void setInvalid() {
-      Invalid = true;
-      Entries.clear();
-    }
+  /// The length of the path to the most-derived object of which this is a
+  /// subobject.
+  unsigned MostDerivedPathLength : 28;
 
-    /// Determine whether the most derived subobject is an array without a
-    /// known bound.
-    bool isMostDerivedAnUnsizedArray() const {
-      assert(!Invalid && "Calling this makes no sense on invalid designators");
-      return Entries.size() == 1 && FirstEntryIsAnUnsizedArray;
+  /// The size of the array of which the most-derived object is an element.
+  /// This will always be 0 if the most-derived object is not an array
+  /// element. 0 is not an indicator of whether or not the most-derived object
+  /// is an array, however, because 0-length arrays are allowed.
+  ///
+  /// If the current array is an unsized array, the value of this is
+  /// undefined.
+  uint64_t MostDerivedArraySize;
+  /// The type of the most derived object referred to by this address.
+  QualType MostDerivedType;
+
+  typedef APValue::LValuePathEntry PathEntry;
+
+  /// The entries on the path from the glvalue to the designated subobject.
+  SmallVector<PathEntry, 8> Entries;
+
+  SubobjectDesignator() : Invalid(true) {}
+
+  explicit SubobjectDesignator(QualType T)
+      : Invalid(false), IsOnePastTheEnd(false),
+        FirstEntryIsAnUnsizedArray(false), MostDerivedIsArrayElement(false),
+        MostDerivedPathLength(0), MostDerivedArraySize(0),
+        MostDerivedType(T.isNull() ? QualType() : T.getNonReferenceType()) {}
+
+  SubobjectDesignator(const ASTContext &Ctx, const APValue &V)
+      : Invalid(!V.isLValue() || !V.hasLValuePath()), IsOnePastTheEnd(false),
+        FirstEntryIsAnUnsizedArray(false), MostDerivedIsArrayElement(false),
+        MostDerivedPathLength(0), MostDerivedArraySize(0) {
+    assert(V.isLValue() && "Non-LValue used to make an LValue designator?");
+    if (!Invalid) {
+      IsOnePastTheEnd = V.isLValueOnePastTheEnd();
+      llvm::append_range(Entries, V.getLValuePath());
+      if (V.getLValueBase()) {
+        bool IsArray = false;
+        bool FirstIsUnsizedArray = false;
+        MostDerivedPathLength = findMostDerivedSubobject(
+            Ctx, V.getLValueBase(), V.getLValuePath(), MostDerivedArraySize,
+            MostDerivedType, IsArray, FirstIsUnsizedArray);
+        MostDerivedIsArrayElement = IsArray;
+        FirstEntryIsAnUnsizedArray = FirstIsUnsizedArray;
+      }
     }
+  }
 
-    /// Determine what the most derived array's size is. Results in an assertion
-    /// failure if the most derived array lacks a size.
-    uint64_t getMostDerivedArraySize() const {
-      assert(!isMostDerivedAnUnsizedArray() && "Unsized array has no size");
-      return MostDerivedArraySize;
-    }
+  void truncate(ASTContext &Ctx, APValue::LValueBase Base, unsigned NewLength) {
+    if (Invalid)
+      return;
 
-    /// Determine whether this is a one-past-the-end pointer.
-    bool isOnePastTheEnd() const {
-      assert(!Invalid);
-      if (IsOnePastTheEnd)
-        return true;
-      if (!isMostDerivedAnUnsizedArray() && MostDerivedIsArrayElement &&
-          Entries[MostDerivedPathLength - 1].getAsArrayIndex() ==
-              MostDerivedArraySize)
-        return true;
-      return false;
-    }
+    assert(Base && "cannot truncate path for null pointer");
+    assert(NewLength <= Entries.size() && "not a truncation");
 
-    /// Get the range of valid index adjustments in the form
-    ///   {maximum value that can be subtracted from this pointer,
-    ///    maximum value that can be added to this pointer}
-    std::pair<uint64_t, uint64_t> validIndexAdjustments() {
-      if (Invalid || isMostDerivedAnUnsizedArray())
-        return {0, 0};
+    if (NewLength == Entries.size())
+      return;
+    Entries.resize(NewLength);
 
-      // [expr.add]p4: For the purposes of these operators, a pointer to a
-      // nonarray object behaves the same as a pointer to the first element of
-      // an array of length one with the type of the object as its element type.
-      bool IsArray = MostDerivedPathLength == Entries.size() &&
-                     MostDerivedIsArrayElement;
-      uint64_t ArrayIndex = IsArray ? Entries.back().getAsArrayIndex()
-                                    : (uint64_t)IsOnePastTheEnd;
-      uint64_t ArraySize =
-          IsArray ? getMostDerivedArraySize() : (uint64_t)1;
-      return {ArrayIndex, ArraySize - ArrayIndex};
-    }
+    bool IsArray = false;
+    bool FirstIsUnsizedArray = false;
+    MostDerivedPathLength =
+        findMostDerivedSubobject(Ctx, Base, Entries, MostDerivedArraySize,
+                                 MostDerivedType, IsArray, FirstIsUnsizedArray);
+    MostDerivedIsArrayElement = IsArray;
+    FirstEntryIsAnUnsizedArray = FirstIsUnsizedArray;
+  }
 
-    /// Check that this refers to a valid subobject.
-    bool isValidSubobject() const {
-      if (Invalid)
-        return false;
-      return !isOnePastTheEnd();
-    }
-    /// Check that this refers to a valid subobject, and if not, produce a
-    /// relevant diagnostic and set the designator as invalid.
-    bool checkSubobject(EvalInfo &Info, const Expr *E, CheckSubobjectKind CSK);
+  void setInvalid() {
+    Invalid = true;
+    Entries.clear();
+  }
 
-    /// Get the type of the designated object.
-    QualType getType(ASTContext &Ctx) const {
-      assert(!Invalid && "invalid designator has no subobject type");
-      return MostDerivedPathLength == Entries.size()
-                 ? MostDerivedType
-                 : Ctx.getCanonicalTagType(getAsBaseClass(Entries.back()));
-    }
+  /// Determine whether the most derived subobject is an array without a
+  /// known bound.
+  bool isMostDerivedAnUnsizedArray() const {
+    assert(!Invalid && "Calling this makes no sense on invalid designators");
+    return Entries.size() == 1 && FirstEntryIsAnUnsizedArray;
+  }
 
-    /// Update this designator to refer to the first element within this array.
-    void addArrayUnchecked(const ConstantArrayType *CAT) {
-      Entries.push_back(PathEntry::ArrayIndex(0));
+  /// Determine what the most derived array's size is. Results in an assertion
+  /// failure if the most derived array lacks a size.
+  uint64_t getMostDerivedArraySize() const {
+    assert(!isMostDerivedAnUnsizedArray() && "Unsized array has no size");
+    return MostDerivedArraySize;
+  }
 
-      // This is a most-derived object.
-      MostDerivedType = CAT->getElementType();
-      MostDerivedIsArrayElement = true;
-      MostDerivedArraySize = CAT->getZExtSize();
-      MostDerivedPathLength = Entries.size();
-    }
-    /// Update this designator to refer to the first element within the array of
-    /// elements of type T. This is an array of unknown size.
-    void addUnsizedArrayUnchecked(QualType ElemTy) {
-      Entries.push_back(PathEntry::ArrayIndex(0));
-
-      MostDerivedType = ElemTy;
-      MostDerivedIsArrayElement = true;
-      // The value in MostDerivedArraySize is undefined in this case. So, set it
-      // to an arbitrary value that's likely to loudly break things if it's
-      // used.
-      MostDerivedArraySize = AssumedSizeForUnsizedArray;
-      MostDerivedPathLength = Entries.size();
-    }
-    /// Update this designator to refer to the given base or member of this
-    /// object.
-    void addDeclUnchecked(const Decl *D, bool Virtual = false) {
-      Entries.push_back(APValue::BaseOrMemberType(D, Virtual));
-
-      // If this isn't a base class, it's a new most-derived object.
-      if (const FieldDecl *FD = dyn_cast<FieldDecl>(D)) {
-        MostDerivedType = FD->getType();
-        MostDerivedIsArrayElement = false;
-        MostDerivedArraySize = 0;
-        MostDerivedPathLength = Entries.size();
-      }
-    }
-    /// Update this designator to refer to the given complex component.
-    void addComplexUnchecked(QualType EltTy, bool Imag) {
-      Entries.push_back(PathEntry::ArrayIndex(Imag));
+  /// Determine whether this is a one-past-the-end pointer.
+  bool isOnePastTheEnd() const {
+    assert(!Invalid);
+    if (IsOnePastTheEnd)
+      return true;
+    if (!isMostDerivedAnUnsizedArray() && MostDerivedIsArrayElement &&
+        Entries[MostDerivedPathLength - 1].getAsArrayIndex() ==
+            MostDerivedArraySize)
+      return true;
+    return false;
+  }
 
-      // This is technically a most-derived object, though in practice this
-      // is unlikely to matter.
-      MostDerivedType = EltTy;
-      MostDerivedIsArrayElement = true;
-      MostDerivedArraySize = 2;
+  /// Get the range of valid index adjustments in the form
+  ///   {maximum value that can be subtracted from this pointer,
+  ///    maximum value that can be added to this pointer}
+  std::pair<uint64_t, uint64_t> validIndexAdjustments() {
+    if (Invalid || isMostDerivedAnUnsizedArray())
+      return {0, 0};
+
+    // [expr.add]p4: For the purposes of these operators, a pointer to a
+    // nonarray object behaves the same as a pointer to the first element of
+    // an array of length one with the type of the object as its element type.
+    bool IsArray =
+        MostDerivedPathLength == Entries.size() && MostDerivedIsArrayElement;
+    uint64_t ArrayIndex =
+        IsArray ? Entries.back().getAsArrayIndex() : (uint64_t)IsOnePastTheEnd;
+    uint64_t ArraySize = IsArray ? getMostDerivedArraySize() : (uint64_t)1;
+    return {ArrayIndex, ArraySize - ArrayIndex};
+  }
+
+  /// Check that this refers to a valid subobject.
+  bool isValidSubobject() const {
+    if (Invalid)
+      return false;
+    return !isOnePastTheEnd();
+  }
+  /// Check that this refers to a valid subobject, and if not, produce a
+  /// relevant diagnostic and set the designator as invalid.
+  bool checkSubobject(EvalInfo &Info, const Expr *E, CheckSubobjectKind CSK);
+
+  /// Get the type of the designated object.
+  QualType getType(ASTContext &Ctx) const {
+    assert(!Invalid && "invalid designator has no subobject type");
+    return MostDerivedPathLength == Entries.size()
+               ? MostDerivedType
+               : Ctx.getCanonicalTagType(getAsBaseClass(Entries.back()));
+  }
+
+  /// Update this designator to refer to the first element within this array.
+  void addArrayUnchecked(const ConstantArrayType *CAT) {
+    Entries.push_back(PathEntry::ArrayIndex(0));
+
+    // This is a most-derived object.
+    MostDerivedType = CAT->getElementType();
+    MostDerivedIsArrayElement = true;
+    MostDerivedArraySize = CAT->getZExtSize();
+    MostDerivedPathLength = Entries.size();
+  }
+  /// Update this designator to refer to the first element within the array of
+  /// elements of type T. This is an array of unknown size.
+  void addUnsizedArrayUnchecked(QualType ElemTy) {
+    Entries.push_back(PathEntry::ArrayIndex(0));
+
+    MostDerivedType = ElemTy;
+    MostDerivedIsArrayElement = true;
+    // The value in MostDerivedArraySize is undefined in this case. So, set it
+    // to an arbitrary value that's likely to loudly break things if it's
+    // used.
+    MostDerivedArraySize = AssumedSizeForUnsizedArray;
+    MostDerivedPathLength = Entries.size();
+  }
+  /// Update this designator to refer to the given base or member of this
+  /// object.
+  void addDeclUnchecked(const Decl *D, bool Virtual = false) {
+    Entries.push_back(APValue::BaseOrMemberType(D, Virtual));
+
+    // If this isn't a base class, it's a new most-derived object.
+    if (const FieldDecl *FD = dyn_cast<FieldDecl>(D)) {
+      MostDerivedType = FD->getType();
+      MostDerivedIsArrayElement = false;
+      MostDerivedArraySize = 0;
       MostDerivedPathLength = Entries.size();
     }
+  }
+  /// Update this designator to refer to the given complex component.
+  void addComplexUnchecked(QualType EltTy, bool Imag) {
+    Entries.push_back(PathEntry::ArrayIndex(Imag));
 
-    void addVectorElementUnchecked(QualType EltTy, uint64_t Size,
-                                   uint64_t Idx) {
-      Entries.push_back(PathEntry::ArrayIndex(Idx));
-      MostDerivedType = EltTy;
-      MostDerivedPathLength = Entries.size();
-      MostDerivedArraySize = 0;
-      MostDerivedIsArrayElement = false;
-    }
+    // This is technically a most-derived object, though in practice this
+    // is unlikely to matter.
+    MostDerivedType = EltTy;
+    MostDerivedIsArrayElement = true;
+    MostDerivedArraySize = 2;
+    MostDerivedPathLength = Entries.size();
+  }
 
-    void diagnoseUnsizedArrayPointerArithmetic(EvalInfo &Info, const Expr *E);
-    void diagnosePointerArithmetic(EvalInfo &Info, const Expr *E,
-                                   const APSInt &N);
-    /// Add N to the address of this subobject.
-    void adjustIndex(EvalInfo &Info, const Expr *E, APSInt N, const LValue &LV);
-  };
+  void addVectorElementUnchecked(QualType EltTy, uint64_t Size, uint64_t Idx) {
+    Entries.push_back(PathEntry::ArrayIndex(Idx));
+    MostDerivedType = EltTy;
+    MostDerivedPathLength = Entries.size();
+    MostDerivedArraySize = 0;
+    MostDerivedIsArrayElement = false;
+  }
 
-  /// A scope at the end of which an object can need to be destroyed.
-  enum class ScopeKind {
-    Block,
-    FullExpression,
-    Call
-  };
+  void diagnoseUnsizedArrayPointerArithmetic(EvalInfo &Info, const Expr *E);
+  void diagnosePointerArithmetic(EvalInfo &Info, const Expr *E,
+                                 const APSInt &N);
+  /// Add N to the address of this subobject.
+  void adjustIndex(EvalInfo &Info, const Expr *E, APSInt N, const LValue &LV);
+};
 
-  /// A reference to a particular call and its arguments.
-  struct CallRef {
-    CallRef() : OrigCallee(), CallIndex(0), Version() {}
-    CallRef(const FunctionDecl *Callee, unsigned CallIndex, unsigned Version)
-        : OrigCallee(Callee), CallIndex(CallIndex), Version(Version) {}
-
-    explicit operator bool() const { return OrigCallee; }
-
-    /// Get the parameter that the caller initialized, corresponding to the
-    /// given parameter in the callee.
-    const ParmVarDecl *getOrigParam(const ParmVarDecl *PVD) const {
-      return OrigCallee ? OrigCallee->getParamDecl(PVD->getFunctionScopeIndex())
-                        : PVD;
-    }
-
-    /// The callee at the point where the arguments were evaluated. This might
-    /// be different from the actual callee (a different redeclaration, or a
-    /// virtual override), but this function's parameters are the ones that
-    /// appear in the parameter map.
-    const FunctionDecl *OrigCallee;
-    /// The call index of the frame that holds the argument values.
-    unsigned CallIndex;
-    /// The version of the parameters corresponding to this call.
-    unsigned Version;
-  };
+/// A scope at the end of which an object can need to be destroyed.
+enum class ScopeKind { Block, FullExpression, Call };
+
+/// A reference to a particular call and its arguments.
+struct CallRef {
+  CallRef() : OrigCallee(), CallIndex(0), Version() {}
+  CallRef(const FunctionDecl *Callee, unsigned CallIndex, unsigned Version)
+      : OrigCallee(Callee), CallIndex(CallIndex), Version(Version) {}
+
+  explicit operator bool() const { return OrigCallee; }
+
+  /// Get the parameter that the caller initialized, corresponding to the
+  /// given parameter in the callee.
+  const ParmVarDecl *getOrigParam(const ParmVarDecl *PVD) const {
+    return OrigCallee ? OrigCallee->getParamDecl(PVD->getFunctionScopeIndex())
+                      : PVD;
+  }
+
+  /// The callee at the point where the arguments were evaluated. This might
+  /// be different from the actual callee (a different redeclaration, or a
+  /// virtual override), but this function's parameters are the ones that
+  /// appear in the parameter map.
+  const FunctionDecl *OrigCallee;
+  /// The call index of the frame that holds the argument values.
+  unsigned CallIndex;
+  /// The version of the parameters corresponding to this call.
+  unsigned Version;
+};
 
-  /// A stack frame in the constexpr call stack.
-  class CallStackFrame : public interp::Frame {
-  public:
-    EvalInfo &Info;
+/// A stack frame in the constexpr call stack.
+class CallStackFrame : public interp::Frame {
+public:
+  EvalInfo &Info;
 
-    /// Parent - The caller of this stack frame.
-    CallStackFrame *Caller;
+  /// Parent - The caller of this stack frame.
+  CallStackFrame *Caller;
 
-    /// Callee - The function which was called.
-    const FunctionDecl *Callee;
+  /// Callee - The function which was called.
+  const FunctionDecl *Callee;
 
-    /// This - The binding for the this pointer in this call, if any.
-    const LValue *This;
+  /// This - The binding for the this pointer in this call, if any.
+  const LValue *This;
 
-    /// CallExpr - The syntactical structure of member function calls
-    const Expr *CallExpr;
+  /// CallExpr - The syntactical structure of member function calls
+  const Expr *CallExpr;
 
-    /// Information on how to find the arguments to this call. Our arguments
-    /// are stored in our parent's CallStackFrame, using the ParmVarDecl* as a
-    /// key and this value as the version.
-    CallRef Arguments;
+  /// Information on how to find the arguments to this call. Our arguments
+  /// are stored in our parent's CallStackFrame, using the ParmVarDecl* as a
+  /// key and this value as the version.
+  CallRef Arguments;
 
-    /// Source location information about the default argument or default
-    /// initializer expression we're evaluating, if any.
-    CurrentSourceLocExprScope CurSourceLocExprScope;
+  /// Source location information about the default argument or default
+  /// initializer expression we're evaluating, if any.
+  CurrentSourceLocExprScope CurSourceLocExprScope;
 
-    // Note that we intentionally use std::map here so that references to
-    // values are stable.
-    typedef std::pair<const void *, unsigned> MapKeyTy;
-    typedef std::map<MapKeyTy, APValue> MapTy;
-    /// Temporaries - Temporary lvalues materialized within this stack frame.
-    MapTy Temporaries;
+  // Note that we intentionally use std::map here so that references to
+  // values are stable.
+  typedef std::pair<const void *, unsigned> MapKeyTy;
+  typedef std::map<MapKeyTy, APValue> MapTy;
+  /// Temporaries - Temporary lvalues materialized within this stack frame.
+  MapTy Temporaries;
 
-    /// CallRange - The source range of the call expression for this call.
-    SourceRange CallRange;
+  /// CallRange - The source range of the call expression for this call.
+  SourceRange CallRange;
 
-    /// Index - The call index of this call.
-    unsigned Index;
+  /// Index - The call index of this call.
+  unsigned Index;
 
-    /// The stack of integers for tracking version numbers for temporaries.
-    SmallVector<unsigned, 2> TempVersionStack = {1};
-    unsigned CurTempVersion = TempVersionStack.back();
+  /// The stack of integers for tracking version numbers for temporaries.
+  SmallVector<unsigned, 2> TempVersionStack = {1};
+  unsigned CurTempVersion = TempVersionStack.back();
 
-    unsigned getTempVersion() const { return TempVersionStack.back(); }
+  unsigned getTempVersion() const { return TempVersionStack.back(); }
 
-    void pushTempVersion() {
-      TempVersionStack.push_back(++CurTempVersion);
-    }
+  void pushTempVersion() { TempVersionStack.push_back(++CurTempVersion); }
 
-    void popTempVersion() {
-      TempVersionStack.pop_back();
-    }
+  void popTempVersion() { TempVersionStack.pop_back(); }
 
-    CallRef createCall(const FunctionDecl *Callee) {
-      return {Callee, Index, ++CurTempVersion};
-    }
+  CallRef createCall(const FunctionDecl *Callee) {
+    return {Callee, Index, ++CurTempVersion};
+  }
 
-    // FIXME: Adding this to every 'CallStackFrame' may have a nontrivial impact
-    // on the overall stack usage of deeply-recursing constexpr evaluations.
-    // (We should cache this map rather than recomputing it repeatedly.)
-    // But let's try this and see how it goes; we can look into caching the map
-    // as a later change.
+  // FIXME: Adding this to every 'CallStackFrame' may have a nontrivial impact
+  // on the overall stack usage of deeply-recursing constexpr evaluations.
+  // (We should cache this map rather than recomputing it repeatedly.)
+  // But let's try this and see how it goes; we can look into caching the map
+  // as a later change.
 
-    /// LambdaCaptureFields - Mapping from captured variables/this to
-    /// corresponding data members in the closure class.
-    llvm::DenseMap<const ValueDecl *, FieldDecl *> LambdaCaptureFields;
-    FieldDecl *LambdaThisCaptureField = nullptr;
+  /// LambdaCaptureFields - Mapping from captured variables/this to
+  /// corresponding data members in the closure class.
+  llvm::DenseMap<const ValueDecl *, FieldDecl *> LambdaCaptureFields;
+  FieldDecl *LambdaThisCaptureField = nullptr;
 
-    CallStackFrame(EvalInfo &Info, SourceRange CallRange,
-                   const FunctionDecl *Callee, const LValue *This,
-                   const Expr *CallExpr, CallRef Arguments);
-    ~CallStackFrame();
+  CallStackFrame(EvalInfo &Info, SourceRange CallRange,
+                 const FunctionDecl *Callee, const LValue *This,
+                 const Expr *CallExpr, CallRef Arguments);
+  ~CallStackFrame();
 
-    // Return the temporary for Key whose version number is Version.
-    APValue *getTemporary(const void *Key, unsigned Version) {
-      MapKeyTy KV(Key, Version);
-      auto LB = Temporaries.lower_bound(KV);
-      if (LB != Temporaries.end() && LB->first == KV)
-        return &LB->second;
-      return nullptr;
-    }
+  // Return the temporary for Key whose version number is Version.
+  APValue *getTemporary(const void *Key, unsigned Version) {
+    MapKeyTy KV(Key, Version);
+    auto LB = Temporaries.lower_bound(KV);
+    if (LB != Temporaries.end() && LB->first == KV)
+      return &LB->second;
+    return nullptr;
+  }
 
-    // Return the current temporary for Key in the map.
-    APValue *getCurrentTemporary(const void *Key) {
-      auto UB = Temporaries.upper_bound(MapKeyTy(Key, UINT_MAX));
-      if (UB != Temporaries.begin() && std::prev(UB)->first.first == Key)
-        return &std::prev(UB)->second;
-      return nullptr;
-    }
+  // Return the current temporary for Key in the map.
+  APValue *getCurrentTemporary(const void *Key) {
+    auto UB = Temporaries.upper_bound(MapKeyTy(Key, UINT_MAX));
+    if (UB != Temporaries.begin() && std::prev(UB)->first.first == Key)
+      return &std::prev(UB)->second;
+    return nullptr;
+  }
 
-    // Return the version number of the current temporary for Key.
-    unsigned getCurrentTemporaryVersion(const void *Key) const {
-      auto UB = Temporaries.upper_bound(MapKeyTy(Key, UINT_MAX));
-      if (UB != Temporaries.begin() && std::prev(UB)->first.first == Key)
-        return std::prev(UB)->first.second;
-      return 0;
-    }
+  // Return the version number of the current temporary for Key.
+  unsigned getCurrentTemporaryVersion(const void *Key) const {
+    auto UB = Temporaries.upper_bound(MapKeyTy(Key, UINT_MAX));
+    if (UB != Temporaries.begin() && std::prev(UB)->first.first == Key)
+      return std::prev(UB)->first.second;
+    return 0;
+  }
 
-    /// Allocate storage for an object of type T in this stack frame.
-    /// Populates LV with a handle to the created object. Key identifies
-    /// the temporary within the stack frame, and must not be reused without
-    /// bumping the temporary version number.
-    template<typename KeyT>
-    APValue &createTemporary(const KeyT *Key, QualType T,
-                             ScopeKind Scope, LValue &LV);
+  /// Allocate storage for an object of type T in this stack frame.
+  /// Populates LV with a handle to the created object. Key identifies
+  /// the temporary within the stack frame, and must not be reused without
+  /// bumping the temporary version number.
+  template <typename KeyT>
+  APValue &createTemporary(const KeyT *Key, QualType T, ScopeKind Scope,
+                           LValue &LV);
 
-    /// Allocate storage for a parameter of a function call made in this frame.
-    APValue &createParam(CallRef Args, const ParmVarDecl *PVD, LValue &LV);
+  /// Allocate storage for a parameter of a function call made in this frame.
+  APValue &createParam(CallRef Args, const ParmVarDecl *PVD, LValue &LV);
 
-    void describe(llvm::raw_ostream &OS) const override;
+  void describe(llvm::raw_ostream &OS) const override;
 
-    Frame *getCaller() const override { return Caller; }
-    SourceRange getCallRange() const override { return CallRange; }
-    const FunctionDecl *getCallee() const override { return Callee; }
+  Frame *getCaller() const override { return Caller; }
+  SourceRange getCallRange() const override { return CallRange; }
+  const FunctionDecl *getCallee() const override { return Callee; }
 
-    bool isStdFunction() const {
-      for (const DeclContext *DC = Callee; DC; DC = DC->getParent())
-        if (DC->isStdNamespace())
-          return true;
-      return false;
-    }
+  bool isStdFunction() const {
+    for (const DeclContext *DC = Callee; DC; DC = DC->getParent())
+      if (DC->isStdNamespace())
+        return true;
+    return false;
+  }
 
-    /// Whether we're in a context where [[msvc::constexpr]] evaluation is
-    /// permitted. See MSConstexprDocs for description of permitted contexts.
-    bool CanEvalMSConstexpr = false;
+  /// Whether we're in a context where [[msvc::constexpr]] evaluation is
+  /// permitted. See MSConstexprDocs for description of permitted contexts.
+  bool CanEvalMSConstexpr = false;
 
-  private:
-    APValue &createLocal(APValue::LValueBase Base, const void *Key, QualType T,
-                         ScopeKind Scope);
-  };
+private:
+  APValue &createLocal(APValue::LValueBase Base, const void *Key, QualType T,
+                       ScopeKind Scope);
+};
 
-  /// Temporarily override 'this'.
-  class ThisOverrideRAII {
-  public:
-    ThisOverrideRAII(CallStackFrame &Frame, const LValue *NewThis, bool Enable)
-        : Frame(Frame), OldThis(Frame.This) {
-      if (Enable)
-        Frame.This = NewThis;
-    }
-    ~ThisOverrideRAII() {
-      Frame.This = OldThis;
-    }
-  private:
-    CallStackFrame &Frame;
-    const LValue *OldThis;
-  };
+/// Temporarily override 'this'.
+class ThisOverrideRAII {
+public:
+  ThisOverrideRAII(CallStackFrame &Frame, const LValue *NewThis, bool Enable)
+      : Frame(Frame), OldThis(Frame.This) {
+    if (Enable)
+      Frame.This = NewThis;
+  }
+  ~ThisOverrideRAII() { Frame.This = OldThis; }
 
-  // A shorthand time trace scope struct, prints source range, for example
-  // {"name":"EvaluateAsRValue","args":{"detail":"<test.cc:8:21, col:25>"}}}
-  class ExprTimeTraceScope {
-  public:
-    ExprTimeTraceScope(const Expr *E, const ASTContext &Ctx, StringRef Name)
-        : TimeScope(Name, [E, &Ctx] {
-            return E->getSourceRange().printToString(Ctx.getSourceManager());
-          }) {}
+private:
+  CallStackFrame &Frame;
+  const LValue *OldThis;
+};
 
-  private:
-    llvm::TimeTraceScope TimeScope;
-  };
+// A shorthand time trace scope struct, prints source range, for example
+// {"name":"EvaluateAsRValue","args":{"detail":"<test.cc:8:21, col:25>"}}}
+class ExprTimeTraceScope {
+public:
+  ExprTimeTraceScope(const Expr *E, const ASTContext &Ctx, StringRef Name)
+      : TimeScope(Name, [E, &Ctx] {
+          return E->getSourceRange().printToString(Ctx.getSourceManager());
+        }) {}
 
-  /// RAII object used to change the current ability of
-  /// [[msvc::constexpr]] evaulation.
-  struct MSConstexprContextRAII {
-    CallStackFrame &Frame;
-    bool OldValue;
-    explicit MSConstexprContextRAII(CallStackFrame &Frame, bool Value)
-        : Frame(Frame), OldValue(Frame.CanEvalMSConstexpr) {
-      Frame.CanEvalMSConstexpr = Value;
-    }
+private:
+  llvm::TimeTraceScope TimeScope;
+};
 
-    ~MSConstexprContextRAII() { Frame.CanEvalMSConstexpr = OldValue; }
-  };
-}
+/// RAII object used to change the current ability of
+/// [[msvc::constexpr]] evaulation.
+struct MSConstexprContextRAII {
+  CallStackFrame &Frame;
+  bool OldValue;
+  explicit MSConstexprContextRAII(CallStackFrame &Frame, bool Value)
+      : Frame(Frame), OldValue(Frame.CanEvalMSConstexpr) {
+    Frame.CanEvalMSConstexpr = Value;
+  }
+
+  ~MSConstexprContextRAII() { Frame.CanEvalMSConstexpr = OldValue; }
+};
+} // namespace
 
-static bool HandleDestruction(EvalInfo &Info, const Expr *E,
-                              const LValue &This, QualType ThisType);
+static bool HandleDestruction(EvalInfo &Info, const Expr *E, const LValue &This,
+                              QualType ThisType);
 static bool HandleDestruction(EvalInfo &Info, SourceLocation Loc,
                               APValue::LValueBase LVBase, APValue &Value,
                               QualType T);
 
 namespace {
-  /// A cleanup, and a flag indicating whether it is lifetime-extended.
-  class Cleanup {
-    llvm::PointerIntPair<APValue*, 2, ScopeKind> Value;
-    APValue::LValueBase Base;
-    QualType T;
+/// A cleanup, and a flag indicating whether it is lifetime-extended.
+class Cleanup {
+  llvm::PointerIntPair<APValue *, 2, ScopeKind> Value;
+  APValue::LValueBase Base;
+  QualType T;
 
-  public:
-    Cleanup(APValue *Val, APValue::LValueBase Base, QualType T,
-            ScopeKind Scope)
-        : Value(Val, Scope), Base(Base), T(T) {}
-
-    /// Determine whether this cleanup should be performed at the end of the
-    /// given kind of scope.
-    bool isDestroyedAtEndOf(ScopeKind K) const {
-      return (int)Value.getInt() >= (int)K;
-    }
-    bool endLifetime(EvalInfo &Info, bool RunDestructors) {
-      if (RunDestructors) {
-        SourceLocation Loc;
-        if (const ValueDecl *VD = Base.dyn_cast<const ValueDecl*>())
-          Loc = VD->getLocation();
-        else if (const Expr *E = Base.dyn_cast<const Expr*>())
-          Loc = E->getExprLoc();
-        return HandleDestruction(Info, Loc, Base, *Value.getPointer(), T);
-      }
-      *Value.getPointer() = APValue();
-      return true;
-    }
+public:
+  Cleanup(APValue *Val, APValue::LValueBase Base, QualType T, ScopeKind Scope)
+      : Value(Val, Scope), Base(Base), T(T) {}
+
+  /// Determine whether this cleanup should be performed at the end of the
+  /// given kind of scope.
+  bool isDestroyedAtEndOf(ScopeKind K) const {
+    return (int)Value.getInt() >= (int)K;
+  }
+  bool endLifetime(EvalInfo &Info, bool RunDestructors) {
+    if (RunDestructors) {
+      SourceLocation Loc;
+      if (const ValueDecl *VD = Base.dyn_cast<const ValueDecl *>())
+        Loc = VD->getLocation();
+      else if (const Expr *E = Base.dyn_cast<const Expr *>())
+        Loc = E->getExprLoc();
+      return HandleDestruction(Info, Loc, Base, *Value.getPointer(), T);
+    }
+    *Value.getPointer() = APValue();
+    return true;
+  }
 
-    bool hasSideEffect() {
-      return T.isDestructedType();
-    }
-  };
+  bool hasSideEffect() { return T.isDestructedType(); }
+};
 
-  /// A reference to an object whose construction we are currently evaluating.
-  struct ObjectUnderConstruction {
-    APValue::LValueBase Base;
-    ArrayRef<APValue::LValuePathEntry> Path;
-    friend bool operator==(const ObjectUnderConstruction &LHS,
-                           const ObjectUnderConstruction &RHS) {
-      return LHS.Base == RHS.Base && LHS.Path == RHS.Path;
-    }
-    friend llvm::hash_code hash_value(const ObjectUnderConstruction &Obj) {
-      return llvm::hash_combine(Obj.Base, Obj.Path);
-    }
-  };
-  enum class ConstructionPhase {
-    None,
-    Bases,
-    AfterBases,
-    AfterFields,
-    Destroying,
-    DestroyingBases
-  };
-}
+/// A reference to an object whose construction we are currently evaluating.
+struct ObjectUnderConstruction {
+  APValue::LValueBase Base;
+  ArrayRef<APValue::LValuePathEntry> Path;
+  friend bool operator==(const ObjectUnderConstruction &LHS,
+                         const ObjectUnderConstruction &RHS) {
+    return LHS.Base == RHS.Base && LHS.Path == RHS.Path;
+  }
+  friend llvm::hash_code hash_value(const ObjectUnderConstruction &Obj) {
+    return llvm::hash_combine(Obj.Base, Obj.Path);
+  }
+};
+enum class ConstructionPhase {
+  None,
+  Bases,
+  AfterBases,
+  AfterFields,
+  Destroying,
+  DestroyingBases
+};
+} // namespace
 
 namespace llvm {
-template<> struct DenseMapInfo<ObjectUnderConstruction> {
+template <> struct DenseMapInfo<ObjectUnderConstruction> {
   using Base = DenseMapInfo<APValue::LValueBase>;
   static ObjectUnderConstruction getEmptyKey() {
-    return {Base::getEmptyKey(), {}}; }
+    return {Base::getEmptyKey(), {}};
+  }
   static ObjectUnderConstruction getTombstoneKey() {
     return {Base::getTombstoneKey(), {}};
   }
@@ -747,541 +731,531 @@ template<> struct DenseMapInfo<ObjectUnderConstruction> {
     return LHS == RHS;
   }
 };
-}
+} // namespace llvm
 
 namespace {
-  /// A dynamically-allocated heap object.
-  struct DynAlloc {
-    /// The value of this heap-allocated object.
-    APValue Value;
-    /// The allocating expression; used for diagnostics. Either a CXXNewExpr
-    /// or a CallExpr (the latter is for direct calls to operator new inside
-    /// std::allocator<T>::allocate).
-    const Expr *AllocExpr = nullptr;
-
-    enum Kind {
-      New,
-      ArrayNew,
-      StdAllocator
-    };
+/// A dynamically-allocated heap object.
+struct DynAlloc {
+  /// The value of this heap-allocated object.
+  APValue Value;
+  /// The allocating expression; used for diagnostics. Either a CXXNewExpr
+  /// or a CallExpr (the latter is for direct calls to operator new inside
+  /// std::allocator<T>::allocate).
+  const Expr *AllocExpr = nullptr;
+
+  enum Kind { New, ArrayNew, StdAllocator };
+
+  /// Get the kind of the allocation. This must match between allocation
+  /// and deallocation.
+  Kind getKind() const {
+    if (auto *NE = dyn_cast<CXXNewExpr>(AllocExpr))
+      return NE->isArray() ? ArrayNew : New;
+    assert(isa<CallExpr>(AllocExpr));
+    return StdAllocator;
+  }
+};
+
+struct DynAllocOrder {
+  bool operator()(DynamicAllocLValue L, DynamicAllocLValue R) const {
+    return L.getIndex() < R.getIndex();
+  }
+};
+
+/// EvalInfo - This is a private struct used by the evaluator to capture
+/// information about a subexpression as it is folded.  It retains information
+/// about the AST context, but also maintains information about the folded
+/// expression.
+///
+/// If an expression could be evaluated, it is still possible it is not a C
+/// "integer constant expression" or constant expression.  If not, this struct
+/// captures information about how and why not.
+///
+/// One bit of information passed *into* the request for constant folding
+/// indicates whether the subexpression is "evaluated" or not according to C
+/// rules.  For example, the RHS of (0 && foo()) is not evaluated.  We can
+/// evaluate the expression regardless of what the RHS is, but C only allows
+/// certain things in certain situations.
+class EvalInfo final : public interp::State {
+public:
+  /// CurrentCall - The top of the constexpr call stack.
+  CallStackFrame *CurrentCall;
+
+  /// CallStackDepth - The number of calls in the call stack right now.
+  unsigned CallStackDepth;
+
+  /// NextCallIndex - The next call index to assign.
+  unsigned NextCallIndex;
+
+  /// StepsLeft - The remaining number of evaluation steps we're permitted
+  /// to perform. This is essentially a limit for the number of statements
+  /// we will evaluate.
+  unsigned StepsLeft;
+
+  /// Enable the experimental new constant interpreter. If an expression is
+  /// not supported by the interpreter, an error is triggered.
+  bool EnableNewConstInterp;
+
+  /// BottomFrame - The frame in which evaluation started. This must be
+  /// initialized after CurrentCall and CallStackDepth.
+  CallStackFrame BottomFrame;
 
-    /// Get the kind of the allocation. This must match between allocation
-    /// and deallocation.
-    Kind getKind() const {
-      if (auto *NE = dyn_cast<CXXNewExpr>(AllocExpr))
-        return NE->isArray() ? ArrayNew : New;
-      assert(isa<CallExpr>(AllocExpr));
-      return StdAllocator;
+  /// A stack of values whose lifetimes end at the end of some surrounding
+  /// evaluation frame.
+  llvm::SmallVector<Cleanup, 16> CleanupStack;
+
+  /// EvaluatingDecl - This is the declaration whose initializer is being
+  /// evaluated, if any.
+  APValue::LValueBase EvaluatingDecl;
+
+  enum class EvaluatingDeclKind {
+    None,
+    /// We're evaluating the construction of EvaluatingDecl.
+    Ctor,
+    /// We're evaluating the destruction of EvaluatingDecl.
+    Dtor,
+  };
+  EvaluatingDeclKind IsEvaluatingDecl = EvaluatingDeclKind::None;
+
+  /// EvaluatingDeclValue - This is the value being constructed for the
+  /// declaration whose initializer is being evaluated, if any.
+  APValue *EvaluatingDeclValue;
+
+  /// Stack of loops and 'switch' statements which we're currently
+  /// breaking/continuing; null entries are used to mark unlabeled
+  /// break/continue.
+  SmallVector<const Stmt *> BreakContinueStack;
+
+  /// Set of objects that are currently being constructed.
+  llvm::DenseMap<ObjectUnderConstruction, ConstructionPhase>
+      ObjectsUnderConstruction;
+
+  /// Current heap allocations, along with the location where each was
+  /// allocated. We use std::map here because we need stable addresses
+  /// for the stored APValues.
+  std::map<DynamicAllocLValue, DynAlloc, DynAllocOrder> HeapAllocs;
+
+  /// The number of heap allocations performed so far in this evaluation.
+  unsigned NumHeapAllocs = 0;
+
+  struct EvaluatingConstructorRAII {
+    EvalInfo &EI;
+    ObjectUnderConstruction Object;
+    bool DidInsert;
+    EvaluatingConstructorRAII(EvalInfo &EI, ObjectUnderConstruction Object,
+                              bool HasBases)
+        : EI(EI), Object(Object) {
+      DidInsert =
+          EI.ObjectsUnderConstruction
+              .insert({Object, HasBases ? ConstructionPhase::Bases
+                                        : ConstructionPhase::AfterBases})
+              .second;
+    }
+    void finishedConstructingBases() {
+      EI.ObjectsUnderConstruction[Object] = ConstructionPhase::AfterBases;
+    }
+    void finishedConstructingFields() {
+      EI.ObjectsUnderConstruction[Object] = ConstructionPhase::AfterFields;
+    }
+    ~EvaluatingConstructorRAII() {
+      if (DidInsert)
+        EI.ObjectsUnderConstruction.erase(Object);
     }
   };
 
-  struct DynAllocOrder {
-    bool operator()(DynamicAllocLValue L, DynamicAllocLValue R) const {
-      return L.getIndex() < R.getIndex();
+  struct EvaluatingDestructorRAII {
+    EvalInfo &EI;
+    ObjectUnderConstruction Object;
+    bool DidInsert;
+    EvaluatingDestructorRAII(EvalInfo &EI, ObjectUnderConstruction Object)
+        : EI(EI), Object(Object) {
+      DidInsert = EI.ObjectsUnderConstruction
+                      .insert({Object, ConstructionPhase::Destroying})
+                      .second;
+    }
+    void startedDestroyingBases() {
+      EI.ObjectsUnderConstruction[Object] = ConstructionPhase::DestroyingBases;
+    }
+    ~EvaluatingDestructorRAII() {
+      if (DidInsert)
+        EI.ObjectsUnderConstruction.erase(Object);
     }
   };
 
-  /// EvalInfo - This is a private struct used by the evaluator to capture
-  /// information about a subexpression as it is folded.  It retains information
-  /// about the AST context, but also maintains information about the folded
-  /// expression.
-  ///
-  /// If an expression could be evaluated, it is still possible it is not a C
-  /// "integer constant expression" or constant expression.  If not, this struct
-  /// captures information about how and why not.
-  ///
-  /// One bit of information passed *into* the request for constant folding
-  /// indicates whether the subexpression is "evaluated" or not according to C
-  /// rules.  For example, the RHS of (0 && foo()) is not evaluated.  We can
-  /// evaluate the expression regardless of what the RHS is, but C only allows
-  /// certain things in certain situations.
-  class EvalInfo final : public interp::State {
-  public:
-    /// CurrentCall - The top of the constexpr call stack.
-    CallStackFrame *CurrentCall;
-
-    /// CallStackDepth - The number of calls in the call stack right now.
-    unsigned CallStackDepth;
-
-    /// NextCallIndex - The next call index to assign.
-    unsigned NextCallIndex;
-
-    /// StepsLeft - The remaining number of evaluation steps we're permitted
-    /// to perform. This is essentially a limit for the number of statements
-    /// we will evaluate.
-    unsigned StepsLeft;
-
-    /// Enable the experimental new constant interpreter. If an expression is
-    /// not supported by the interpreter, an error is triggered.
-    bool EnableNewConstInterp;
-
-    /// BottomFrame - The frame in which evaluation started. This must be
-    /// initialized after CurrentCall and CallStackDepth.
-    CallStackFrame BottomFrame;
-
-    /// A stack of values whose lifetimes end at the end of some surrounding
-    /// evaluation frame.
-    llvm::SmallVector<Cleanup, 16> CleanupStack;
-
-    /// EvaluatingDecl - This is the declaration whose initializer is being
-    /// evaluated, if any.
-    APValue::LValueBase EvaluatingDecl;
-
-    enum class EvaluatingDeclKind {
-      None,
-      /// We're evaluating the construction of EvaluatingDecl.
-      Ctor,
-      /// We're evaluating the destruction of EvaluatingDecl.
-      Dtor,
-    };
-    EvaluatingDeclKind IsEvaluatingDecl = EvaluatingDeclKind::None;
-
-    /// EvaluatingDeclValue - This is the value being constructed for the
-    /// declaration whose initializer is being evaluated, if any.
-    APValue *EvaluatingDeclValue;
-
-    /// Stack of loops and 'switch' statements which we're currently
-    /// breaking/continuing; null entries are used to mark unlabeled
-    /// break/continue.
-    SmallVector<const Stmt *> BreakContinueStack;
-
-    /// Set of objects that are currently being constructed.
-    llvm::DenseMap<ObjectUnderConstruction, ConstructionPhase>
-        ObjectsUnderConstruction;
-
-    /// Current heap allocations, along with the location where each was
-    /// allocated. We use std::map here because we need stable addresses
-    /// for the stored APValues.
-    std::map<DynamicAllocLValue, DynAlloc, DynAllocOrder> HeapAllocs;
-
-    /// The number of heap allocations performed so far in this evaluation.
-    unsigned NumHeapAllocs = 0;
-
-    struct EvaluatingConstructorRAII {
-      EvalInfo &EI;
-      ObjectUnderConstruction Object;
-      bool DidInsert;
-      EvaluatingConstructorRAII(EvalInfo &EI, ObjectUnderConstruction Object,
-                                bool HasBases)
-          : EI(EI), Object(Object) {
-        DidInsert =
-            EI.ObjectsUnderConstruction
-                .insert({Object, HasBases ? ConstructionPhase::Bases
-                                          : ConstructionPhase::AfterBases})
-                .second;
-      }
-      void finishedConstructingBases() {
-        EI.ObjectsUnderConstruction[Object] = ConstructionPhase::AfterBases;
-      }
-      void finishedConstructingFields() {
-        EI.ObjectsUnderConstruction[Object] = ConstructionPhase::AfterFields;
-      }
-      ~EvaluatingConstructorRAII() {
-        if (DidInsert) EI.ObjectsUnderConstruction.erase(Object);
-      }
-    };
-
-    struct EvaluatingDestructorRAII {
-      EvalInfo &EI;
-      ObjectUnderConstruction Object;
-      bool DidInsert;
-      EvaluatingDestructorRAII(EvalInfo &EI, ObjectUnderConstruction Object)
-          : EI(EI), Object(Object) {
-        DidInsert = EI.ObjectsUnderConstruction
-                        .insert({Object, ConstructionPhase::Destroying})
-                        .second;
-      }
-      void startedDestroyingBases() {
-        EI.ObjectsUnderConstruction[Object] =
-            ConstructionPhase::DestroyingBases;
-      }
-      ~EvaluatingDestructorRAII() {
-        if (DidInsert)
-          EI.ObjectsUnderConstruction.erase(Object);
-      }
-    };
+  ConstructionPhase
+  isEvaluatingCtorDtor(APValue::LValueBase Base,
+                       ArrayRef<APValue::LValuePathEntry> Path) {
+    return ObjectsUnderConstruction.lookup({Base, Path});
+  }
 
-    ConstructionPhase
-    isEvaluatingCtorDtor(APValue::LValueBase Base,
-                         ArrayRef<APValue::LValuePathEntry> Path) {
-      return ObjectsUnderConstruction.lookup({Base, Path});
-    }
+  /// If we're currently speculatively evaluating, the outermost call stack
+  /// depth at which we can mutate state, otherwise 0.
+  unsigned SpeculativeEvaluationDepth = 0;
 
-    /// If we're currently speculatively evaluating, the outermost call stack
-    /// depth at which we can mutate state, otherwise 0.
-    unsigned SpeculativeEvaluationDepth = 0;
+  /// The current array initialization index, if we're performing array
+  /// initialization.
+  uint64_t ArrayInitIndex = -1;
 
-    /// The current array initialization index, if we're performing array
-    /// initialization.
-    uint64_t ArrayInitIndex = -1;
+  EvalInfo(const ASTContext &C, Expr::EvalStatus &S, EvaluationMode Mode)
+      : State(const_cast<ASTContext &>(C), S), CurrentCall(nullptr),
+        CallStackDepth(0), NextCallIndex(1),
+        StepsLeft(C.getLangOpts().ConstexprStepLimit),
+        EnableNewConstInterp(C.getLangOpts().EnableNewConstInterp),
+        BottomFrame(*this, SourceLocation(), /*Callee=*/nullptr,
+                    /*This=*/nullptr,
+                    /*CallExpr=*/nullptr, CallRef()),
+        EvaluatingDecl((const ValueDecl *)nullptr),
+        EvaluatingDeclValue(nullptr) {
+    EvalMode = Mode;
+  }
 
-    EvalInfo(const ASTContext &C, Expr::EvalStatus &S, EvaluationMode Mode)
-        : State(const_cast<ASTContext &>(C), S), CurrentCall(nullptr),
-          CallStackDepth(0), NextCallIndex(1),
-          StepsLeft(C.getLangOpts().ConstexprStepLimit),
-          EnableNewConstInterp(C.getLangOpts().EnableNewConstInterp),
-          BottomFrame(*this, SourceLocation(), /*Callee=*/nullptr,
-                      /*This=*/nullptr,
-                      /*CallExpr=*/nullptr, CallRef()),
-          EvaluatingDecl((const ValueDecl *)nullptr),
-          EvaluatingDeclValue(nullptr) {
-      EvalMode = Mode;
-    }
+  ~EvalInfo() { discardCleanups(); }
 
-    ~EvalInfo() {
-      discardCleanups();
-    }
+  void setEvaluatingDecl(APValue::LValueBase Base, APValue &Value,
+                         EvaluatingDeclKind EDK = EvaluatingDeclKind::Ctor) {
+    EvaluatingDecl = Base;
+    IsEvaluatingDecl = EDK;
+    EvaluatingDeclValue = &Value;
+  }
 
-    void setEvaluatingDecl(APValue::LValueBase Base, APValue &Value,
-                           EvaluatingDeclKind EDK = EvaluatingDeclKind::Ctor) {
-      EvaluatingDecl = Base;
-      IsEvaluatingDecl = EDK;
-      EvaluatingDeclValue = &Value;
+  bool CheckCallLimit(SourceLocation Loc) {
+    // Don't perform any constexpr calls (other than the call we're checking)
+    // when checking a potential constant expression.
+    if (checkingPotentialConstantExpression() && CallStackDepth > 1)
+      return false;
+    if (NextCallIndex == 0) {
+      // NextCallIndex has wrapped around.
+      FFDiag(Loc, diag::note_constexpr_call_limit_exceeded);
+      return false;
     }
-
-    bool CheckCallLimit(SourceLocation Loc) {
-      // Don't perform any constexpr calls (other than the call we're checking)
-      // when checking a potential constant expression.
-      if (checkingPotentialConstantExpression() && CallStackDepth > 1)
-        return false;
-      if (NextCallIndex == 0) {
-        // NextCallIndex has wrapped around.
-        FFDiag(Loc, diag::note_constexpr_call_limit_exceeded);
-        return false;
-      }
-      if (CallStackDepth <= getLangOpts().ConstexprCallDepth)
-        return true;
-      FFDiag(Loc, diag::note_constexpr_depth_limit_exceeded)
+    if (CallStackDepth <= getLangOpts().ConstexprCallDepth)
+      return true;
+    FFDiag(Loc, diag::note_constexpr_depth_limit_exceeded)
         << getLangOpts().ConstexprCallDepth;
+    return false;
+  }
+
+  bool CheckArraySize(SourceLocation Loc, unsigned BitWidth, uint64_t ElemCount,
+                      bool Diag) {
+    // FIXME: GH63562
+    // APValue stores array extents as unsigned,
+    // so anything that is greater that unsigned would overflow when
+    // constructing the array, we catch this here.
+    if (BitWidth > ConstantArrayType::getMaxSizeBits(Ctx) ||
+        ElemCount > uint64_t(std::numeric_limits<unsigned>::max())) {
+      if (Diag)
+        FFDiag(Loc, diag::note_constexpr_new_too_large) << ElemCount;
       return false;
     }
 
-    bool CheckArraySize(SourceLocation Loc, unsigned BitWidth,
-                        uint64_t ElemCount, bool Diag) {
-      // FIXME: GH63562
-      // APValue stores array extents as unsigned,
-      // so anything that is greater that unsigned would overflow when
-      // constructing the array, we catch this here.
-      if (BitWidth > ConstantArrayType::getMaxSizeBits(Ctx) ||
-          ElemCount > uint64_t(std::numeric_limits<unsigned>::max())) {
-        if (Diag)
-          FFDiag(Loc, diag::note_constexpr_new_too_large) << ElemCount;
-        return false;
-      }
-
-      // FIXME: GH63562
-      // Arrays allocate an APValue per element.
-      // We use the number of constexpr steps as a proxy for the maximum size
-      // of arrays to avoid exhausting the system resources, as initialization
-      // of each element is likely to take some number of steps anyway.
-      uint64_t Limit = getLangOpts().ConstexprStepLimit;
-      if (Limit != 0 && ElemCount > Limit) {
-        if (Diag)
-          FFDiag(Loc, diag::note_constexpr_new_exceeds_limits)
-              << ElemCount << Limit;
-        return false;
-      }
-      return true;
+    // FIXME: GH63562
+    // Arrays allocate an APValue per element.
+    // We use the number of constexpr steps as a proxy for the maximum size
+    // of arrays to avoid exhausting the system resources, as initialization
+    // of each element is likely to take some number of steps anyway.
+    uint64_t Limit = getLangOpts().ConstexprStepLimit;
+    if (Limit != 0 && ElemCount > Limit) {
+      if (Diag)
+        FFDiag(Loc, diag::note_constexpr_new_exceeds_limits)
+            << ElemCount << Limit;
+      return false;
     }
+    return true;
+  }
 
-    std::pair<CallStackFrame *, unsigned>
-    getCallFrameAndDepth(unsigned CallIndex) {
-      assert(CallIndex && "no call index in getCallFrameAndDepth");
-      // We will eventually hit BottomFrame, which has Index 1, so Frame can't
-      // be null in this loop.
-      unsigned Depth = CallStackDepth;
-      CallStackFrame *Frame = CurrentCall;
-      while (Frame->Index > CallIndex) {
-        Frame = Frame->Caller;
-        --Depth;
-      }
-      if (Frame->Index == CallIndex)
-        return {Frame, Depth};
-      return {nullptr, 0};
+  std::pair<CallStackFrame *, unsigned>
+  getCallFrameAndDepth(unsigned CallIndex) {
+    assert(CallIndex && "no call index in getCallFrameAndDepth");
+    // We will eventually hit BottomFrame, which has Index 1, so Frame can't
+    // be null in this loop.
+    unsigned Depth = CallStackDepth;
+    CallStackFrame *Frame = CurrentCall;
+    while (Frame->Index > CallIndex) {
+      Frame = Frame->Caller;
+      --Depth;
     }
+    if (Frame->Index == CallIndex)
+      return {Frame, Depth};
+    return {nullptr, 0};
+  }
 
-    bool nextStep(const Stmt *S) {
-      if (getLangOpts().ConstexprStepLimit == 0)
-        return true;
-
-      if (!StepsLeft) {
-        FFDiag(S->getBeginLoc(), diag::note_constexpr_step_limit_exceeded);
-        return false;
-      }
-      --StepsLeft;
+  bool nextStep(const Stmt *S) {
+    if (getLangOpts().ConstexprStepLimit == 0)
       return true;
-    }
-
-    APValue *createHeapAlloc(const Expr *E, QualType T, LValue &LV);
 
-    std::optional<DynAlloc *> lookupDynamicAlloc(DynamicAllocLValue DA) {
-      std::optional<DynAlloc *> Result;
-      auto It = HeapAllocs.find(DA);
-      if (It != HeapAllocs.end())
-        Result = &It->second;
-      return Result;
+    if (!StepsLeft) {
+      FFDiag(S->getBeginLoc(), diag::note_constexpr_step_limit_exceeded);
+      return false;
     }
+    --StepsLeft;
+    return true;
+  }
 
-    /// Get the allocated storage for the given parameter of the given call.
-    APValue *getParamSlot(CallRef Call, const ParmVarDecl *PVD) {
-      CallStackFrame *Frame = getCallFrameAndDepth(Call.CallIndex).first;
-      return Frame ? Frame->getTemporary(Call.getOrigParam(PVD), Call.Version)
-                   : nullptr;
-    }
+  APValue *createHeapAlloc(const Expr *E, QualType T, LValue &LV);
 
-    /// Information about a stack frame for std::allocator<T>::[de]allocate.
-    struct StdAllocatorCaller {
-      unsigned FrameIndex;
-      QualType ElemType;
-      const Expr *Call;
-      explicit operator bool() const { return FrameIndex != 0; };
-    };
+  std::optional<DynAlloc *> lookupDynamicAlloc(DynamicAllocLValue DA) {
+    std::optional<DynAlloc *> Result;
+    auto It = HeapAllocs.find(DA);
+    if (It != HeapAllocs.end())
+      Result = &It->second;
+    return Result;
+  }
 
-    StdAllocatorCaller getStdAllocatorCaller(StringRef FnName) const {
-      for (const CallStackFrame *Call = CurrentCall; Call != &BottomFrame;
-           Call = Call->Caller) {
-        const auto *MD = dyn_cast_or_null<CXXMethodDecl>(Call->Callee);
-        if (!MD)
-          continue;
-        const IdentifierInfo *FnII = MD->getIdentifier();
-        if (!FnII || !FnII->isStr(FnName))
-          continue;
+  /// Get the allocated storage for the given parameter of the given call.
+  APValue *getParamSlot(CallRef Call, const ParmVarDecl *PVD) {
+    CallStackFrame *Frame = getCallFrameAndDepth(Call.CallIndex).first;
+    return Frame ? Frame->getTemporary(Call.getOrigParam(PVD), Call.Version)
+                 : nullptr;
+  }
 
-        const auto *CTSD =
-            dyn_cast<ClassTemplateSpecializationDecl>(MD->getParent());
-        if (!CTSD)
-          continue;
+  /// Information about a stack frame for std::allocator<T>::[de]allocate.
+  struct StdAllocatorCaller {
+    unsigned FrameIndex;
+    QualType ElemType;
+    const Expr *Call;
+    explicit operator bool() const { return FrameIndex != 0; };
+  };
 
-        const IdentifierInfo *ClassII = CTSD->getIdentifier();
-        const TemplateArgumentList &TAL = CTSD->getTemplateArgs();
-        if (CTSD->isInStdNamespace() && ClassII &&
-            ClassII->isStr("allocator") && TAL.size() >= 1 &&
-            TAL[0].getKind() == TemplateArgument::Type)
-          return {Call->Index, TAL[0].getAsType(), Call->CallExpr};
-      }
+  StdAllocatorCaller getStdAllocatorCaller(StringRef FnName) const {
+    for (const CallStackFrame *Call = CurrentCall; Call != &BottomFrame;
+         Call = Call->Caller) {
+      const auto *MD = dyn_cast_or_null<CXXMethodDecl>(Call->Callee);
+      if (!MD)
+        continue;
+      const IdentifierInfo *FnII = MD->getIdentifier();
+      if (!FnII || !FnII->isStr(FnName))
+        continue;
 
-      return {};
-    }
+      const auto *CTSD =
+          dyn_cast<ClassTemplateSpecializationDecl>(MD->getParent());
+      if (!CTSD)
+        continue;
 
-    void performLifetimeExtension() {
-      // Disable the cleanups for lifetime-extended temporaries.
-      llvm::erase_if(CleanupStack, [](Cleanup &C) {
-        return !C.isDestroyedAtEndOf(ScopeKind::FullExpression);
-      });
+      const IdentifierInfo *ClassII = CTSD->getIdentifier();
+      const TemplateArgumentList &TAL = CTSD->getTemplateArgs();
+      if (CTSD->isInStdNamespace() && ClassII && ClassII->isStr("allocator") &&
+          TAL.size() >= 1 && TAL[0].getKind() == TemplateArgument::Type)
+        return {Call->Index, TAL[0].getAsType(), Call->CallExpr};
     }
 
-    /// Throw away any remaining cleanups at the end of evaluation. If any
-    /// cleanups would have had a side-effect, note that as an unmodeled
-    /// side-effect and return false. Otherwise, return true.
-    bool discardCleanups() {
-      for (Cleanup &C : CleanupStack) {
-        if (C.hasSideEffect() && !noteSideEffect()) {
-          CleanupStack.clear();
-          return false;
-        }
+    return {};
+  }
+
+  void performLifetimeExtension() {
+    // Disable the cleanups for lifetime-extended temporaries.
+    llvm::erase_if(CleanupStack, [](Cleanup &C) {
+      return !C.isDestroyedAtEndOf(ScopeKind::FullExpression);
+    });
+  }
+
+  /// Throw away any remaining cleanups at the end of evaluation. If any
+  /// cleanups would have had a side-effect, note that as an unmodeled
+  /// side-effect and return false. Otherwise, return true.
+  bool discardCleanups() {
+    for (Cleanup &C : CleanupStack) {
+      if (C.hasSideEffect() && !noteSideEffect()) {
+        CleanupStack.clear();
+        return false;
       }
-      CleanupStack.clear();
-      return true;
     }
+    CleanupStack.clear();
+    return true;
+  }
 
-  private:
-    const interp::Frame *getCurrentFrame() override { return CurrentCall; }
-    const interp::Frame *getBottomFrame() const override { return &BottomFrame; }
+private:
+  const interp::Frame *getCurrentFrame() override { return CurrentCall; }
+  const interp::Frame *getBottomFrame() const override { return &BottomFrame; }
 
-    unsigned getCallStackDepth() override { return CallStackDepth; }
-    bool stepsLeft() const override { return StepsLeft > 0; }
+  unsigned getCallStackDepth() override { return CallStackDepth; }
+  bool stepsLeft() const override { return StepsLeft > 0; }
 
-  public:
-    /// Notes that we failed to evaluate an expression that other expressions
-    /// directly depend on, and determine if we should keep evaluating. This
-    /// should only be called if we actually intend to keep evaluating.
-    ///
-    /// Call noteSideEffect() instead if we may be able to ignore the value that
-    /// we failed to evaluate, e.g. if we failed to evaluate Foo() in:
-    ///
-    /// (Foo(), 1)      // use noteSideEffect
-    /// (Foo() || true) // use noteSideEffect
-    /// Foo() + 1       // use noteFailure
-    [[nodiscard]] bool noteFailure() {
-      // Failure when evaluating some expression often means there is some
-      // subexpression whose evaluation was skipped. Therefore, (because we
-      // don't track whether we skipped an expression when unwinding after an
-      // evaluation failure) every evaluation failure that bubbles up from a
-      // subexpression implies that a side-effect has potentially happened. We
-      // skip setting the HasSideEffects flag to true until we decide to
-      // continue evaluating after that point, which happens here.
-      bool KeepGoing = keepEvaluatingAfterFailure();
-      EvalStatus.HasSideEffects |= KeepGoing;
-      return KeepGoing;
-    }
-
-    class ArrayInitLoopIndex {
-      EvalInfo &Info;
-      uint64_t OuterIndex;
+public:
+  /// Notes that we failed to evaluate an expression that other expressions
+  /// directly depend on, and determine if we should keep evaluating. This
+  /// should only be called if we actually intend to keep evaluating.
+  ///
+  /// Call noteSideEffect() instead if we may be able to ignore the value that
+  /// we failed to evaluate, e.g. if we failed to evaluate Foo() in:
+  ///
+  /// (Foo(), 1)      // use noteSideEffect
+  /// (Foo() || true) // use noteSideEffect
+  /// Foo() + 1       // use noteFailure
+  [[nodiscard]] bool noteFailure() {
+    // Failure when evaluating some expression often means there is some
+    // subexpression whose evaluation was skipped. Therefore, (because we
+    // don't track whether we skipped an expression when unwinding after an
+    // evaluation failure) every evaluation failure that bubbles up from a
+    // subexpression implies that a side-effect has potentially happened. We
+    // skip setting the HasSideEffects flag to true until we decide to
+    // continue evaluating after that point, which happens here.
+    bool KeepGoing = keepEvaluatingAfterFailure();
+    EvalStatus.HasSideEffects |= KeepGoing;
+    return KeepGoing;
+  }
+
+  class ArrayInitLoopIndex {
+    EvalInfo &Info;
+    uint64_t OuterIndex;
 
-    public:
-      ArrayInitLoopIndex(EvalInfo &Info)
-          : Info(Info), OuterIndex(Info.ArrayInitIndex) {
-        Info.ArrayInitIndex = 0;
-      }
-      ~ArrayInitLoopIndex() { Info.ArrayInitIndex = OuterIndex; }
+  public:
+    ArrayInitLoopIndex(EvalInfo &Info)
+        : Info(Info), OuterIndex(Info.ArrayInitIndex) {
+      Info.ArrayInitIndex = 0;
+    }
+    ~ArrayInitLoopIndex() { Info.ArrayInitIndex = OuterIndex; }
 
-      operator uint64_t&() { return Info.ArrayInitIndex; }
-    };
+    operator uint64_t &() { return Info.ArrayInitIndex; }
   };
+};
 
-  /// Object used to treat all foldable expressions as constant expressions.
-  struct FoldConstant {
-    EvalInfo &Info;
-    bool Enabled;
-    bool HadNoPriorDiags;
-    EvaluationMode OldMode;
+/// Object used to treat all foldable expressions as constant expressions.
+struct FoldConstant {
+  EvalInfo &Info;
+  bool Enabled;
+  bool HadNoPriorDiags;
+  EvaluationMode OldMode;
 
-    explicit FoldConstant(EvalInfo &Info, bool Enabled)
-      : Info(Info),
-        Enabled(Enabled),
-        HadNoPriorDiags(Info.EvalStatus.Diag &&
-                        Info.EvalStatus.Diag->empty() &&
+  explicit FoldConstant(EvalInfo &Info, bool Enabled)
+      : Info(Info), Enabled(Enabled),
+        HadNoPriorDiags(Info.EvalStatus.Diag && Info.EvalStatus.Diag->empty() &&
                         !Info.EvalStatus.HasSideEffects),
         OldMode(Info.EvalMode) {
-      if (Enabled)
-        Info.EvalMode = EvaluationMode::ConstantFold;
-    }
-    void keepDiagnostics() { Enabled = false; }
-    ~FoldConstant() {
-      if (Enabled && HadNoPriorDiags && !Info.EvalStatus.Diag->empty() &&
-          !Info.EvalStatus.HasSideEffects)
-        Info.EvalStatus.Diag->clear();
-      Info.EvalMode = OldMode;
-    }
-  };
+    if (Enabled)
+      Info.EvalMode = EvaluationMode::ConstantFold;
+  }
+  void keepDiagnostics() { Enabled = false; }
+  ~FoldConstant() {
+    if (Enabled && HadNoPriorDiags && !Info.EvalStatus.Diag->empty() &&
+        !Info.EvalStatus.HasSideEffects)
+      Info.EvalStatus.Diag->clear();
+    Info.EvalMode = OldMode;
+  }
+};
 
-  /// RAII object used to set the current evaluation mode to ignore
-  /// side-effects.
-  struct IgnoreSideEffectsRAII {
-    EvalInfo &Info;
-    EvaluationMode OldMode;
-    explicit IgnoreSideEffectsRAII(EvalInfo &Info)
-        : Info(Info), OldMode(Info.EvalMode) {
-      Info.EvalMode = EvaluationMode::IgnoreSideEffects;
-    }
+/// RAII object used to set the current evaluation mode to ignore
+/// side-effects.
+struct IgnoreSideEffectsRAII {
+  EvalInfo &Info;
+  EvaluationMode OldMode;
+  explicit IgnoreSideEffectsRAII(EvalInfo &Info)
+      : Info(Info), OldMode(Info.EvalMode) {
+    Info.EvalMode = EvaluationMode::IgnoreSideEffects;
+  }
 
-    ~IgnoreSideEffectsRAII() { Info.EvalMode = OldMode; }
-  };
+  ~IgnoreSideEffectsRAII() { Info.EvalMode = OldMode; }
+};
 
-  /// RAII object used to optionally suppress diagnostics and side-effects from
-  /// a speculative evaluation.
-  class SpeculativeEvaluationRAII {
-    EvalInfo *Info = nullptr;
-    Expr::EvalStatus OldStatus;
-    unsigned OldSpeculativeEvaluationDepth = 0;
+/// RAII object used to optionally suppress diagnostics and side-effects from
+/// a speculative evaluation.
+class SpeculativeEvaluationRAII {
+  EvalInfo *Info = nullptr;
+  Expr::EvalStatus OldStatus;
+  unsigned OldSpeculativeEvaluationDepth = 0;
 
-    void moveFromAndCancel(SpeculativeEvaluationRAII &&Other) {
-      Info = Other.Info;
-      OldStatus = Other.OldStatus;
-      OldSpeculativeEvaluationDepth = Other.OldSpeculativeEvaluationDepth;
-      Other.Info = nullptr;
-    }
+  void moveFromAndCancel(SpeculativeEvaluationRAII &&Other) {
+    Info = Other.Info;
+    OldStatus = Other.OldStatus;
+    OldSpeculativeEvaluationDepth = Other.OldSpeculativeEvaluationDepth;
+    Other.Info = nullptr;
+  }
 
-    void maybeRestoreState() {
-      if (!Info)
-        return;
+  void maybeRestoreState() {
+    if (!Info)
+      return;
 
-      Info->EvalStatus = OldStatus;
-      Info->SpeculativeEvaluationDepth = OldSpeculativeEvaluationDepth;
-    }
+    Info->EvalStatus = OldStatus;
+    Info->SpeculativeEvaluationDepth = OldSpeculativeEvaluationDepth;
+  }
 
-  public:
-    SpeculativeEvaluationRAII() = default;
+public:
+  SpeculativeEvaluationRAII() = default;
 
-    SpeculativeEvaluationRAII(
-        EvalInfo &Info, SmallVectorImpl<PartialDiagnosticAt> *NewDiag = nullptr)
-        : Info(&Info), OldStatus(Info.EvalStatus),
-          OldSpeculativeEvaluationDepth(Info.SpeculativeEvaluationDepth) {
-      Info.EvalStatus.Diag = NewDiag;
-      Info.SpeculativeEvaluationDepth = Info.CallStackDepth + 1;
-    }
+  SpeculativeEvaluationRAII(
+      EvalInfo &Info, SmallVectorImpl<PartialDiagnosticAt> *NewDiag = nullptr)
+      : Info(&Info), OldStatus(Info.EvalStatus),
+        OldSpeculativeEvaluationDepth(Info.SpeculativeEvaluationDepth) {
+    Info.EvalStatus.Diag = NewDiag;
+    Info.SpeculativeEvaluationDepth = Info.CallStackDepth + 1;
+  }
 
-    SpeculativeEvaluationRAII(const SpeculativeEvaluationRAII &Other) = delete;
-    SpeculativeEvaluationRAII(SpeculativeEvaluationRAII &&Other) {
-      moveFromAndCancel(std::move(Other));
-    }
+  SpeculativeEvaluationRAII(const SpeculativeEvaluationRAII &Other) = delete;
+  SpeculativeEvaluationRAII(SpeculativeEvaluationRAII &&Other) {
+    moveFromAndCancel(std::move(Other));
+  }
 
-    SpeculativeEvaluationRAII &operator=(SpeculativeEvaluationRAII &&Other) {
-      maybeRestoreState();
-      moveFromAndCancel(std::move(Other));
-      return *this;
-    }
+  SpeculativeEvaluationRAII &operator=(SpeculativeEvaluationRAII &&Other) {
+    maybeRestoreState();
+    moveFromAndCancel(std::move(Other));
+    return *this;
+  }
 
-    ~SpeculativeEvaluationRAII() { maybeRestoreState(); }
-  };
+  ~SpeculativeEvaluationRAII() { maybeRestoreState(); }
+};
 
-  /// RAII object wrapping a full-expression or block scope, and handling
-  /// the ending of the lifetime of temporaries created within it.
-  template<ScopeKind Kind>
-  class ScopeRAII {
-    EvalInfo &Info;
-    unsigned OldStackSize;
-  public:
-    ScopeRAII(EvalInfo &Info)
-        : Info(Info), OldStackSize(Info.CleanupStack.size()) {
-      // Push a new temporary version. This is needed to distinguish between
-      // temporaries created in different iterations of a loop.
-      Info.CurrentCall->pushTempVersion();
-    }
-    bool destroy(bool RunDestructors = true) {
-      bool OK = cleanup(Info, RunDestructors, OldStackSize);
-      OldStackSize = std::numeric_limits<unsigned>::max();
-      return OK;
-    }
-    ~ScopeRAII() {
-      if (OldStackSize != std::numeric_limits<unsigned>::max())
-        destroy(false);
-      // Body moved to a static method to encourage the compiler to inline away
-      // instances of this class.
-      Info.CurrentCall->popTempVersion();
-    }
-  private:
-    static bool cleanup(EvalInfo &Info, bool RunDestructors,
-                        unsigned OldStackSize) {
-      assert(OldStackSize <= Info.CleanupStack.size() &&
-             "running cleanups out of order?");
+/// RAII object wrapping a full-expression or block scope, and handling
+/// the ending of the lifetime of temporaries created within it.
+template <ScopeKind Kind> class ScopeRAII {
+  EvalInfo &Info;
+  unsigned OldStackSize;
 
-      // Run all cleanups for a block scope, and non-lifetime-extended cleanups
-      // for a full-expression scope.
-      bool Success = true;
-      for (unsigned I = Info.CleanupStack.size(); I > OldStackSize; --I) {
-        if (Info.CleanupStack[I - 1].isDestroyedAtEndOf(Kind)) {
-          if (!Info.CleanupStack[I - 1].endLifetime(Info, RunDestructors)) {
-            Success = false;
-            break;
-          }
+public:
+  ScopeRAII(EvalInfo &Info)
+      : Info(Info), OldStackSize(Info.CleanupStack.size()) {
+    // Push a new temporary version. This is needed to distinguish between
+    // temporaries created in different iterations of a loop.
+    Info.CurrentCall->pushTempVersion();
+  }
+  bool destroy(bool RunDestructors = true) {
+    bool OK = cleanup(Info, RunDestructors, OldStackSize);
+    OldStackSize = std::numeric_limits<unsigned>::max();
+    return OK;
+  }
+  ~ScopeRAII() {
+    if (OldStackSize != std::numeric_limits<unsigned>::max())
+      destroy(false);
+    // Body moved to a static method to encourage the compiler to inline away
+    // instances of this class.
+    Info.CurrentCall->popTempVersion();
+  }
+
+private:
+  static bool cleanup(EvalInfo &Info, bool RunDestructors,
+                      unsigned OldStackSize) {
+    assert(OldStackSize <= Info.CleanupStack.size() &&
+           "running cleanups out of order?");
+
+    // Run all cleanups for a block scope, and non-lifetime-extended cleanups
+    // for a full-expression scope.
+    bool Success = true;
+    for (unsigned I = Info.CleanupStack.size(); I > OldStackSize; --I) {
+      if (Info.CleanupStack[I - 1].isDestroyedAtEndOf(Kind)) {
+        if (!Info.CleanupStack[I - 1].endLifetime(Info, RunDestructors)) {
+          Success = false;
+          break;
         }
       }
-
-      // Compact any retained cleanups.
-      auto NewEnd = Info.CleanupStack.begin() + OldStackSize;
-      if (Kind != ScopeKind::Block)
-        NewEnd =
-            std::remove_if(NewEnd, Info.CleanupStack.end(), [](Cleanup &C) {
-              return C.isDestroyedAtEndOf(Kind);
-            });
-      Info.CleanupStack.erase(NewEnd, Info.CleanupStack.end());
-      return Success;
     }
-  };
-  typedef ScopeRAII<ScopeKind::Block> BlockScopeRAII;
-  typedef ScopeRAII<ScopeKind::FullExpression> FullExpressionRAII;
-  typedef ScopeRAII<ScopeKind::Call> CallScopeRAII;
-}
+
+    // Compact any retained cleanups.
+    auto NewEnd = Info.CleanupStack.begin() + OldStackSize;
+    if (Kind != ScopeKind::Block)
+      NewEnd = std::remove_if(NewEnd, Info.CleanupStack.end(), [](Cleanup &C) {
+        return C.isDestroyedAtEndOf(Kind);
+      });
+    Info.CleanupStack.erase(NewEnd, Info.CleanupStack.end());
+    return Success;
+  }
+};
+typedef ScopeRAII<ScopeKind::Block> BlockScopeRAII;
+typedef ScopeRAII<ScopeKind::FullExpression> FullExpressionRAII;
+typedef ScopeRAII<ScopeKind::Call> CallScopeRAII;
+} // namespace
 
 bool SubobjectDesignator::checkSubobject(EvalInfo &Info, const Expr *E,
                                          CheckSubobjectKind CSK) {
   if (Invalid)
     return false;
   if (isOnePastTheEnd()) {
-    Info.CCEDiag(E, diag::note_constexpr_past_end_subobject)
-      << CSK;
+    Info.CCEDiag(E, diag::note_constexpr_past_end_subobject) << CSK;
     setInvalid();
     return false;
   }
@@ -1305,11 +1279,9 @@ void SubobjectDesignator::diagnosePointerArithmetic(EvalInfo &Info,
   // the most derived array.
   if (MostDerivedPathLength == Entries.size() && MostDerivedIsArrayElement)
     Info.CCEDiag(E, diag::note_constexpr_array_index)
-      << N << /*array*/ 0
-      << static_cast<unsigned>(getMostDerivedArraySize());
+        << N << /*array*/ 0 << static_cast<unsigned>(getMostDerivedArraySize());
   else
-    Info.CCEDiag(E, diag::note_constexpr_array_index)
-      << N << /*non-array*/ 1;
+    Info.CCEDiag(E, diag::note_constexpr_array_index) << N << /*non-array*/ 1;
   setInvalid();
 }
 
@@ -1392,322 +1364,314 @@ static bool isValidIndeterminateAccess(AccessKinds AK) {
 }
 
 namespace {
-  struct ComplexValue {
-  private:
-    bool IsInt;
+struct ComplexValue {
+private:
+  bool IsInt;
 
-  public:
-    APSInt IntReal, IntImag;
-    APFloat FloatReal, FloatImag;
+public:
+  APSInt IntReal, IntImag;
+  APFloat FloatReal, FloatImag;
 
-    ComplexValue() : FloatReal(APFloat::Bogus()), FloatImag(APFloat::Bogus()) {}
+  ComplexValue() : FloatReal(APFloat::Bogus()), FloatImag(APFloat::Bogus()) {}
 
-    void makeComplexFloat() { IsInt = false; }
-    bool isComplexFloat() const { return !IsInt; }
-    APFloat &getComplexFloatReal() { return FloatReal; }
-    APFloat &getComplexFloatImag() { return FloatImag; }
+  void makeComplexFloat() { IsInt = false; }
+  bool isComplexFloat() const { return !IsInt; }
+  APFloat &getComplexFloatReal() { return FloatReal; }
+  APFloat &getComplexFloatImag() { return FloatImag; }
 
-    void makeComplexInt() { IsInt = true; }
-    bool isComplexInt() const { return IsInt; }
-    APSInt &getComplexIntReal() { return IntReal; }
-    APSInt &getComplexIntImag() { return IntImag; }
+  void makeComplexInt() { IsInt = true; }
+  bool isComplexInt() const { return IsInt; }
+  APSInt &getComplexIntReal() { return IntReal; }
+  APSInt &getComplexIntImag() { return IntImag; }
 
-    void moveInto(APValue &v) const {
-      if (isComplexFloat())
-        v = APValue(FloatReal, FloatImag);
-      else
-        v = APValue(IntReal, IntImag);
-    }
-    void setFrom(const APValue &v) {
-      assert(v.isComplexFloat() || v.isComplexInt());
-      if (v.isComplexFloat()) {
-        makeComplexFloat();
-        FloatReal = v.getComplexFloatReal();
-        FloatImag = v.getComplexFloatImag();
-      } else {
-        makeComplexInt();
-        IntReal = v.getComplexIntReal();
-        IntImag = v.getComplexIntImag();
-      }
+  void moveInto(APValue &v) const {
+    if (isComplexFloat())
+      v = APValue(FloatReal, FloatImag);
+    else
+      v = APValue(IntReal, IntImag);
+  }
+  void setFrom(const APValue &v) {
+    assert(v.isComplexFloat() || v.isComplexInt());
+    if (v.isComplexFloat()) {
+      makeComplexFloat();
+      FloatReal = v.getComplexFloatReal();
+      FloatImag = v.getComplexFloatImag();
+    } else {
+      makeComplexInt();
+      IntReal = v.getComplexIntReal();
+      IntImag = v.getComplexIntImag();
     }
-  };
+  }
+};
 
-  struct LValue {
-    APValue::LValueBase Base;
-    CharUnits Offset;
-    SubobjectDesignator Designator;
-    bool IsNullPtr : 1;
-    bool InvalidBase : 1;
-    // P2280R4 track if we have an unknown reference or pointer.
-    bool AllowConstexprUnknown = false;
-
-    const APValue::LValueBase getLValueBase() const { return Base; }
-    bool allowConstexprUnknown() const { return AllowConstexprUnknown; }
-    CharUnits &getLValueOffset() { return Offset; }
-    const CharUnits &getLValueOffset() const { return Offset; }
-    SubobjectDesignator &getLValueDesignator() { return Designator; }
-    const SubobjectDesignator &getLValueDesignator() const { return Designator;}
-    bool isNullPointer() const { return IsNullPtr;}
-
-    unsigned getLValueCallIndex() const { return Base.getCallIndex(); }
-    unsigned getLValueVersion() const { return Base.getVersion(); }
-
-    void moveInto(APValue &V) const {
-      if (Designator.Invalid)
-        V = APValue(Base, Offset, APValue::NoLValuePath(), IsNullPtr);
-      else {
-        assert(!InvalidBase && "APValues can't handle invalid LValue bases");
-        V = APValue(Base, Offset, Designator.Entries,
-                    Designator.IsOnePastTheEnd, IsNullPtr);
-      }
-      if (AllowConstexprUnknown)
-        V.setConstexprUnknown();
-    }
-    void setFrom(const ASTContext &Ctx, const APValue &V) {
-      assert(V.isLValue() && "Setting LValue from a non-LValue?");
-      Base = V.getLValueBase();
-      Offset = V.getLValueOffset();
-      InvalidBase = false;
-      Designator = SubobjectDesignator(Ctx, V);
-      IsNullPtr = V.isNullPointer();
-      AllowConstexprUnknown = V.allowConstexprUnknown();
+struct LValue {
+  APValue::LValueBase Base;
+  CharUnits Offset;
+  SubobjectDesignator Designator;
+  bool IsNullPtr : 1;
+  bool InvalidBase : 1;
+  // P2280R4 track if we have an unknown reference or pointer.
+  bool AllowConstexprUnknown = false;
+
+  const APValue::LValueBase getLValueBase() const { return Base; }
+  bool allowConstexprUnknown() const { return AllowConstexprUnknown; }
+  CharUnits &getLValueOffset() { return Offset; }
+  const CharUnits &getLValueOffset() const { return Offset; }
+  SubobjectDesignator &getLValueDesignator() { return Designator; }
+  const SubobjectDesignator &getLValueDesignator() const { return Designator; }
+  bool isNullPointer() const { return IsNullPtr; }
+
+  unsigned getLValueCallIndex() const { return Base.getCallIndex(); }
+  unsigned getLValueVersion() const { return Base.getVersion(); }
+
+  void moveInto(APValue &V) const {
+    if (Designator.Invalid)
+      V = APValue(Base, Offset, APValue::NoLValuePath(), IsNullPtr);
+    else {
+      assert(!InvalidBase && "APValues can't handle invalid LValue bases");
+      V = APValue(Base, Offset, Designator.Entries, Designator.IsOnePastTheEnd,
+                  IsNullPtr);
     }
+    if (AllowConstexprUnknown)
+      V.setConstexprUnknown();
+  }
+  void setFrom(const ASTContext &Ctx, const APValue &V) {
+    assert(V.isLValue() && "Setting LValue from a non-LValue?");
+    Base = V.getLValueBase();
+    Offset = V.getLValueOffset();
+    InvalidBase = false;
+    Designator = SubobjectDesignator(Ctx, V);
+    IsNullPtr = V.isNullPointer();
+    AllowConstexprUnknown = V.allowConstexprUnknown();
+  }
 
-    void set(APValue::LValueBase B, bool BInvalid = false) {
+  void set(APValue::LValueBase B, bool BInvalid = false) {
 #ifndef NDEBUG
-      // We only allow a few types of invalid bases. Enforce that here.
-      if (BInvalid) {
-        const auto *E = B.get<const Expr *>();
-        assert((isa<MemberExpr>(E) || tryUnwrapAllocSizeCall(E)) &&
-               "Unexpected type of invalid base");
-      }
+    // We only allow a few types of invalid bases. Enforce that here.
+    if (BInvalid) {
+      const auto *E = B.get<const Expr *>();
+      assert((isa<MemberExpr>(E) || tryUnwrapAllocSizeCall(E)) &&
+             "Unexpected type of invalid base");
+    }
 #endif
 
-      Base = B;
-      Offset = CharUnits::fromQuantity(0);
-      InvalidBase = BInvalid;
-      Designator = SubobjectDesignator(getType(B));
-      IsNullPtr = false;
-      AllowConstexprUnknown = false;
-    }
+    Base = B;
+    Offset = CharUnits::fromQuantity(0);
+    InvalidBase = BInvalid;
+    Designator = SubobjectDesignator(getType(B));
+    IsNullPtr = false;
+    AllowConstexprUnknown = false;
+  }
 
-    void setNull(ASTContext &Ctx, QualType PointerTy) {
-      Base = (const ValueDecl *)nullptr;
-      Offset =
-          CharUnits::fromQuantity(Ctx.getTargetNullPointerValue(PointerTy));
-      InvalidBase = false;
-      Designator = SubobjectDesignator(PointerTy->getPointeeType());
-      IsNullPtr = true;
-      AllowConstexprUnknown = false;
-    }
+  void setNull(ASTContext &Ctx, QualType PointerTy) {
+    Base = (const ValueDecl *)nullptr;
+    Offset = CharUnits::fromQuantity(Ctx.getTargetNullPointerValue(PointerTy));
+    InvalidBase = false;
+    Designator = SubobjectDesignator(PointerTy->getPointeeType());
+    IsNullPtr = true;
+    AllowConstexprUnknown = false;
+  }
 
-    void setInvalid(APValue::LValueBase B, unsigned I = 0) {
-      set(B, true);
-    }
+  void setInvalid(APValue::LValueBase B, unsigned I = 0) { set(B, true); }
 
-    std::string toString(ASTContext &Ctx, QualType T) const {
-      APValue Printable;
-      moveInto(Printable);
-      return Printable.getAsString(Ctx, T);
-    }
+  std::string toString(ASTContext &Ctx, QualType T) const {
+    APValue Printable;
+    moveInto(Printable);
+    return Printable.getAsString(Ctx, T);
+  }
 
-  private:
-    // Check that this LValue is not based on a null pointer. If it is, produce
-    // a diagnostic and mark the designator as invalid.
-    template <typename GenDiagType>
-    bool checkNullPointerDiagnosingWith(const GenDiagType &GenDiag) {
-      if (Designator.Invalid)
-        return false;
-      if (IsNullPtr) {
-        GenDiag();
-        Designator.setInvalid();
-        return false;
-      }
-      return true;
+private:
+  // Check that this LValue is not based on a null pointer. If it is, produce
+  // a diagnostic and mark the designator as invalid.
+  template <typename GenDiagType>
+  bool checkNullPointerDiagnosingWith(const GenDiagType &GenDiag) {
+    if (Designator.Invalid)
+      return false;
+    if (IsNullPtr) {
+      GenDiag();
+      Designator.setInvalid();
+      return false;
     }
+    return true;
+  }
 
-  public:
-    bool checkNullPointer(EvalInfo &Info, const Expr *E,
-                          CheckSubobjectKind CSK) {
-      return checkNullPointerDiagnosingWith([&Info, E, CSK] {
-        Info.CCEDiag(E, diag::note_constexpr_null_subobject) << CSK;
-      });
-    }
+public:
+  bool checkNullPointer(EvalInfo &Info, const Expr *E, CheckSubobjectKind CSK) {
+    return checkNullPointerDiagnosingWith([&Info, E, CSK] {
+      Info.CCEDiag(E, diag::note_constexpr_null_subobject) << CSK;
+    });
+  }
 
-    bool checkNullPointerForFoldAccess(EvalInfo &Info, const Expr *E,
-                                       AccessKinds AK) {
-      return checkNullPointerDiagnosingWith([&Info, E, AK] {
-        if (AK == AccessKinds::AK_Dereference)
-          Info.FFDiag(E, diag::note_constexpr_dereferencing_null);
-        else
-          Info.FFDiag(E, diag::note_constexpr_access_null) << AK;
-      });
-    }
+  bool checkNullPointerForFoldAccess(EvalInfo &Info, const Expr *E,
+                                     AccessKinds AK) {
+    return checkNullPointerDiagnosingWith([&Info, E, AK] {
+      if (AK == AccessKinds::AK_Dereference)
+        Info.FFDiag(E, diag::note_constexpr_dereferencing_null);
+      else
+        Info.FFDiag(E, diag::note_constexpr_access_null) << AK;
+    });
+  }
 
-    // Check this LValue refers to an object. If not, set the designator to be
-    // invalid and emit a diagnostic.
-    bool checkSubobject(EvalInfo &Info, const Expr *E, CheckSubobjectKind CSK) {
-      return (CSK == CSK_ArrayToPointer || checkNullPointer(Info, E, CSK)) &&
-             Designator.checkSubobject(Info, E, CSK);
-    }
+  // Check this LValue refers to an object. If not, set the designator to be
+  // invalid and emit a diagnostic.
+  bool checkSubobject(EvalInfo &Info, const Expr *E, CheckSubobjectKind CSK) {
+    return (CSK == CSK_ArrayToPointer || checkNullPointer(Info, E, CSK)) &&
+           Designator.checkSubobject(Info, E, CSK);
+  }
 
-    void addDecl(EvalInfo &Info, const Expr *E,
-                 const Decl *D, bool Virtual = false) {
-      if (checkSubobject(Info, E, isa<FieldDecl>(D) ? CSK_Field : CSK_Base))
-        Designator.addDeclUnchecked(D, Virtual);
-    }
-    void addUnsizedArray(EvalInfo &Info, const Expr *E, QualType ElemTy) {
-      if (!Designator.Entries.empty()) {
-        Info.CCEDiag(E, diag::note_constexpr_unsupported_unsized_array);
-        Designator.setInvalid();
-        return;
-      }
-      if (checkSubobject(Info, E, CSK_ArrayToPointer)) {
-        assert(getType(Base).getNonReferenceType()->isPointerType() ||
-               getType(Base).getNonReferenceType()->isArrayType());
-        Designator.FirstEntryIsAnUnsizedArray = true;
-        Designator.addUnsizedArrayUnchecked(ElemTy);
-      }
-    }
-    void addArray(EvalInfo &Info, const Expr *E, const ConstantArrayType *CAT) {
-      if (checkSubobject(Info, E, CSK_ArrayToPointer))
-        Designator.addArrayUnchecked(CAT);
-    }
-    void addComplex(EvalInfo &Info, const Expr *E, QualType EltTy, bool Imag) {
-      if (checkSubobject(Info, E, Imag ? CSK_Imag : CSK_Real))
-        Designator.addComplexUnchecked(EltTy, Imag);
-    }
-    void addVectorElement(EvalInfo &Info, const Expr *E, QualType EltTy,
-                          uint64_t Size, uint64_t Idx) {
-      if (checkSubobject(Info, E, CSK_VectorElement))
-        Designator.addVectorElementUnchecked(EltTy, Size, Idx);
+  void addDecl(EvalInfo &Info, const Expr *E, const Decl *D,
+               bool Virtual = false) {
+    if (checkSubobject(Info, E, isa<FieldDecl>(D) ? CSK_Field : CSK_Base))
+      Designator.addDeclUnchecked(D, Virtual);
+  }
+  void addUnsizedArray(EvalInfo &Info, const Expr *E, QualType ElemTy) {
+    if (!Designator.Entries.empty()) {
+      Info.CCEDiag(E, diag::note_constexpr_unsupported_unsized_array);
+      Designator.setInvalid();
+      return;
     }
-    void clearIsNullPointer() {
-      IsNullPtr = false;
+    if (checkSubobject(Info, E, CSK_ArrayToPointer)) {
+      assert(getType(Base).getNonReferenceType()->isPointerType() ||
+             getType(Base).getNonReferenceType()->isArrayType());
+      Designator.FirstEntryIsAnUnsizedArray = true;
+      Designator.addUnsizedArrayUnchecked(ElemTy);
     }
-    void adjustOffsetAndIndex(EvalInfo &Info, const Expr *E,
-                              const APSInt &Index, CharUnits ElementSize) {
-      // An index of 0 has no effect. (In C, adding 0 to a null pointer is UB,
-      // but we're not required to diagnose it and it's valid in C++.)
-      if (!Index)
-        return;
-
-      // Compute the new offset in the appropriate width, wrapping at 64 bits.
-      // FIXME: When compiling for a 32-bit target, we should use 32-bit
-      // offsets.
-      uint64_t Offset64 = Offset.getQuantity();
-      uint64_t ElemSize64 = ElementSize.getQuantity();
-      uint64_t Index64 = Index.extOrTrunc(64).getZExtValue();
-      Offset = CharUnits::fromQuantity(Offset64 + ElemSize64 * Index64);
+  }
+  void addArray(EvalInfo &Info, const Expr *E, const ConstantArrayType *CAT) {
+    if (checkSubobject(Info, E, CSK_ArrayToPointer))
+      Designator.addArrayUnchecked(CAT);
+  }
+  void addComplex(EvalInfo &Info, const Expr *E, QualType EltTy, bool Imag) {
+    if (checkSubobject(Info, E, Imag ? CSK_Imag : CSK_Real))
+      Designator.addComplexUnchecked(EltTy, Imag);
+  }
+  void addVectorElement(EvalInfo &Info, const Expr *E, QualType EltTy,
+                        uint64_t Size, uint64_t Idx) {
+    if (checkSubobject(Info, E, CSK_VectorElement))
+      Designator.addVectorElementUnchecked(EltTy, Size, Idx);
+  }
+  void clearIsNullPointer() { IsNullPtr = false; }
+  void adjustOffsetAndIndex(EvalInfo &Info, const Expr *E, const APSInt &Index,
+                            CharUnits ElementSize) {
+    // An index of 0 has no effect. (In C, adding 0 to a null pointer is UB,
+    // but we're not required to diagnose it and it's valid in C++.)
+    if (!Index)
+      return;
 
-      if (checkNullPointer(Info, E, CSK_ArrayIndex))
-        Designator.adjustIndex(Info, E, Index, *this);
+    // Compute the new offset in the appropriate width, wrapping at 64 bits.
+    // FIXME: When compiling for a 32-bit target, we should use 32-bit
+    // offsets.
+    uint64_t Offset64 = Offset.getQuantity();
+    uint64_t ElemSize64 = ElementSize.getQuantity();
+    uint64_t Index64 = Index.extOrTrunc(64).getZExtValue();
+    Offset = CharUnits::fromQuantity(Offset64 + ElemSize64 * Index64);
+
+    if (checkNullPointer(Info, E, CSK_ArrayIndex))
+      Designator.adjustIndex(Info, E, Index, *this);
+    clearIsNullPointer();
+  }
+  void adjustOffset(CharUnits N) {
+    Offset += N;
+    if (N.getQuantity())
       clearIsNullPointer();
-    }
-    void adjustOffset(CharUnits N) {
-      Offset += N;
-      if (N.getQuantity())
-        clearIsNullPointer();
-    }
-  };
+  }
+};
 
-  struct MemberPtr {
-    MemberPtr() {}
-    explicit MemberPtr(const ValueDecl *Decl)
-        : DeclAndIsDerivedMember(Decl, false) {}
-
-    /// The member or (direct or indirect) field referred to by this member
-    /// pointer, or 0 if this is a null member pointer.
-    const ValueDecl *getDecl() const {
-      return DeclAndIsDerivedMember.getPointer();
-    }
-    /// Is this actually a member of some type derived from the relevant class?
-    bool isDerivedMember() const {
-      return DeclAndIsDerivedMember.getInt();
-    }
-    /// Get the class which the declaration actually lives in.
-    const CXXRecordDecl *getContainingRecord() const {
-      return cast<CXXRecordDecl>(
-          DeclAndIsDerivedMember.getPointer()->getDeclContext());
-    }
-
-    void moveInto(APValue &V) const {
-      V = APValue(getDecl(), isDerivedMember(), Path);
-    }
-    void setFrom(const APValue &V) {
-      assert(V.isMemberPointer());
-      DeclAndIsDerivedMember.setPointer(V.getMemberPointerDecl());
-      DeclAndIsDerivedMember.setInt(V.isMemberPointerToDerivedMember());
-      Path.clear();
-      llvm::append_range(Path, V.getMemberPointerPath());
-    }
-
-    /// DeclAndIsDerivedMember - The member declaration, and a flag indicating
-    /// whether the member is a member of some class derived from the class type
-    /// of the member pointer.
-    llvm::PointerIntPair<const ValueDecl*, 1, bool> DeclAndIsDerivedMember;
-    /// Path - The path of base/derived classes from the member declaration's
-    /// class (exclusive) to the class type of the member pointer (inclusive).
-    SmallVector<const CXXRecordDecl*, 4> Path;
-
-    /// Perform a cast towards the class of the Decl (either up or down the
-    /// hierarchy).
-    bool castBack(const CXXRecordDecl *Class) {
-      assert(!Path.empty());
-      const CXXRecordDecl *Expected;
-      if (Path.size() >= 2)
-        Expected = Path[Path.size() - 2];
-      else
-        Expected = getContainingRecord();
-      if (Expected->getCanonicalDecl() != Class->getCanonicalDecl()) {
-        // C++11 [expr.static.cast]p12: In a conversion from (D::*) to (B::*),
-        // if B does not contain the original member and is not a base or
-        // derived class of the class containing the original member, the result
-        // of the cast is undefined.
-        // C++11 [conv.mem]p2 does not cover this case for a cast from (B::*) to
-        // (D::*). We consider that to be a language defect.
-        return false;
-      }
-      Path.pop_back();
-      return true;
+struct MemberPtr {
+  MemberPtr() {}
+  explicit MemberPtr(const ValueDecl *Decl)
+      : DeclAndIsDerivedMember(Decl, false) {}
+
+  /// The member or (direct or indirect) field referred to by this member
+  /// pointer, or 0 if this is a null member pointer.
+  const ValueDecl *getDecl() const {
+    return DeclAndIsDerivedMember.getPointer();
+  }
+  /// Is this actually a member of some type derived from the relevant class?
+  bool isDerivedMember() const { return DeclAndIsDerivedMember.getInt(); }
+  /// Get the class which the declaration actually lives in.
+  const CXXRecordDecl *getContainingRecord() const {
+    return cast<CXXRecordDecl>(
+        DeclAndIsDerivedMember.getPointer()->getDeclContext());
+  }
+
+  void moveInto(APValue &V) const {
+    V = APValue(getDecl(), isDerivedMember(), Path);
+  }
+  void setFrom(const APValue &V) {
+    assert(V.isMemberPointer());
+    DeclAndIsDerivedMember.setPointer(V.getMemberPointerDecl());
+    DeclAndIsDerivedMember.setInt(V.isMemberPointerToDerivedMember());
+    Path.clear();
+    llvm::append_range(Path, V.getMemberPointerPath());
+  }
+
+  /// DeclAndIsDerivedMember - The member declaration, and a flag indicating
+  /// whether the member is a member of some class derived from the class type
+  /// of the member pointer.
+  llvm::PointerIntPair<const ValueDecl *, 1, bool> DeclAndIsDerivedMember;
+  /// Path - The path of base/derived classes from the member declaration's
+  /// class (exclusive) to the class type of the member pointer (inclusive).
+  SmallVector<const CXXRecordDecl *, 4> Path;
+
+  /// Perform a cast towards the class of the Decl (either up or down the
+  /// hierarchy).
+  bool castBack(const CXXRecordDecl *Class) {
+    assert(!Path.empty());
+    const CXXRecordDecl *Expected;
+    if (Path.size() >= 2)
+      Expected = Path[Path.size() - 2];
+    else
+      Expected = getContainingRecord();
+    if (Expected->getCanonicalDecl() != Class->getCanonicalDecl()) {
+      // C++11 [expr.static.cast]p12: In a conversion from (D::*) to (B::*),
+      // if B does not contain the original member and is not a base or
+      // derived class of the class containing the original member, the result
+      // of the cast is undefined.
+      // C++11 [conv.mem]p2 does not cover this case for a cast from (B::*) to
+      // (D::*). We consider that to be a language defect.
+      return false;
     }
-    /// Perform a base-to-derived member pointer cast.
-    bool castToDerived(const CXXRecordDecl *Derived) {
-      if (!getDecl())
-        return true;
-      if (!isDerivedMember()) {
-        Path.push_back(Derived);
-        return true;
-      }
-      if (!castBack(Derived))
-        return false;
-      if (Path.empty())
-        DeclAndIsDerivedMember.setInt(false);
+    Path.pop_back();
+    return true;
+  }
+  /// Perform a base-to-derived member pointer cast.
+  bool castToDerived(const CXXRecordDecl *Derived) {
+    if (!getDecl())
+      return true;
+    if (!isDerivedMember()) {
+      Path.push_back(Derived);
       return true;
     }
-    /// Perform a derived-to-base member pointer cast.
-    bool castToBase(const CXXRecordDecl *Base) {
-      if (!getDecl())
-        return true;
-      if (Path.empty())
-        DeclAndIsDerivedMember.setInt(true);
-      if (isDerivedMember()) {
-        Path.push_back(Base);
-        return true;
-      }
-      return castBack(Base);
-    }
-  };
-
-  /// Compare two member pointers, which are assumed to be of the same type.
-  static bool operator==(const MemberPtr &LHS, const MemberPtr &RHS) {
-    if (!LHS.getDecl() || !RHS.getDecl())
-      return !LHS.getDecl() && !RHS.getDecl();
-    if (LHS.getDecl()->getCanonicalDecl() != RHS.getDecl()->getCanonicalDecl())
+    if (!castBack(Derived))
       return false;
-    return LHS.Path == RHS.Path;
+    if (Path.empty())
+      DeclAndIsDerivedMember.setInt(false);
+    return true;
   }
+  /// Perform a derived-to-base member pointer cast.
+  bool castToBase(const CXXRecordDecl *Base) {
+    if (!getDecl())
+      return true;
+    if (Path.empty())
+      DeclAndIsDerivedMember.setInt(true);
+    if (isDerivedMember()) {
+      Path.push_back(Base);
+      return true;
+    }
+    return castBack(Base);
+  }
+};
+
+/// Compare two member pointers, which are assumed to be of the same type.
+static bool operator==(const MemberPtr &LHS, const MemberPtr &RHS) {
+  if (!LHS.getDecl() || !RHS.getDecl())
+    return !LHS.getDecl() && !RHS.getDecl();
+  if (LHS.getDecl()->getCanonicalDecl() != RHS.getDecl()->getCanonicalDecl())
+    return false;
+  return LHS.Path == RHS.Path;
 }
+} // namespace
 
 void SubobjectDesignator::adjustIndex(EvalInfo &Info, const Expr *E, APSInt N,
                                       const LValue &LV) {
@@ -1758,9 +1722,8 @@ void SubobjectDesignator::adjustIndex(EvalInfo &Info, const Expr *E, APSInt N,
 }
 
 static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E);
-static bool EvaluateInPlace(APValue &Result, EvalInfo &Info,
-                            const LValue &This, const Expr *E,
-                            bool AllowNonLiteralTypes = false);
+static bool EvaluateInPlace(APValue &Result, EvalInfo &Info, const LValue &This,
+                            const Expr *E, bool AllowNonLiteralTypes = false);
 static bool EvaluateLValue(const Expr *E, LValue &Result, EvalInfo &Info,
                            bool InvalidBaseOK = false);
 static bool EvaluatePointer(const Expr *E, LValue &Result, EvalInfo &Info,
@@ -1803,7 +1766,7 @@ static void negateAsSigned(APSInt &Int) {
   Int = -Int;
 }
 
-template<typename KeyT>
+template <typename KeyT>
 APValue &CallStackFrame::createTemporary(const KeyT *Key, QualType T,
                                          ScopeKind Scope, LValue &LV) {
   unsigned Version = getTempVersion();
@@ -1878,9 +1841,9 @@ void CallStackFrame::describe(raw_ostream &Out) const {
       Object->printPretty(Out, /*Helper=*/nullptr, Info.Ctx.getPrintingPolicy(),
                           /*Indentation=*/0);
       if (Object->getType()->isPointerType())
-          Out << "->";
+        Out << "->";
       else
-          Out << ".";
+        Out << ".";
     } else if (const auto *OCE =
                    dyn_cast_if_present<CXXOperatorCallExpr>(CallExpr)) {
       OCE->getArg(0)->printPretty(Out, /*Helper=*/nullptr,
@@ -1951,7 +1914,7 @@ static bool IsGlobalLValue(APValue::LValueBase B) {
   if (!B)
     return true;
 
-  if (const ValueDecl *D = B.dyn_cast<const ValueDecl*>()) {
+  if (const ValueDecl *D = B.dyn_cast<const ValueDecl *>()) {
     // ... the address of an object with static storage duration,
     if (const VarDecl *VD = dyn_cast<VarDecl>(D))
       return VD->hasGlobalStorage();
@@ -1966,7 +1929,7 @@ static bool IsGlobalLValue(APValue::LValueBase B) {
   if (B.is<TypeInfoLValue>() || B.is<DynamicAllocLValue>())
     return true;
 
-  const Expr *E = B.get<const Expr*>();
+  const Expr *E = B.get<const Expr *>();
   switch (E->getStmtClass()) {
   default:
     return false;
@@ -2013,7 +1976,7 @@ static bool IsGlobalLValue(APValue::LValueBase B) {
 }
 
 static const ValueDecl *GetLValueBaseDecl(const LValue &LVal) {
-  return LVal.Base.dyn_cast<const ValueDecl*>();
+  return LVal.Base.dyn_cast<const ValueDecl *>();
 }
 
 // Information about an LValueBase that is some kind of string.
@@ -2130,8 +2093,7 @@ static bool HasSameBase(const LValue &A, const LValue &B) {
   if (!B.getLValueBase())
     return false;
 
-  if (A.getLValueBase().getOpaqueValue() !=
-      B.getLValueBase().getOpaqueValue())
+  if (A.getLValueBase().getOpaqueValue() != B.getLValueBase().getOpaqueValue())
     return false;
 
   return A.getLValueCallIndex() == B.getLValueCallIndex() &&
@@ -2140,7 +2102,7 @@ static bool HasSameBase(const LValue &A, const LValue &B) {
 
 static void NoteLValueLocation(EvalInfo &Info, APValue::LValueBase Base) {
   assert(Base && "no location for a null lvalue");
-  const ValueDecl *VD = Base.dyn_cast<const ValueDecl*>();
+  const ValueDecl *VD = Base.dyn_cast<const ValueDecl *>();
 
   // For a parameter, find the corresponding call stack frame (if it still
   // exists), and point at the parameter of the function definition we actually
@@ -2159,7 +2121,7 @@ static void NoteLValueLocation(EvalInfo &Info, APValue::LValueBase Base) {
 
   if (VD)
     Info.Note(VD->getLocation(), diag::note_declared_at);
-  else if (const Expr *E = Base.dyn_cast<const Expr*>())
+  else if (const Expr *E = Base.dyn_cast<const Expr *>())
     Info.Note(E->getExprLoc(), diag::note_constexpr_temporary_here);
   else if (DynamicAllocLValue DA = Base.dyn_cast<DynamicAllocLValue>()) {
     // FIXME: Produce a note for dangling pointers too.
@@ -2201,7 +2163,7 @@ static bool CheckLValueConstantExpression(EvalInfo &Info, SourceLocation Loc,
   const SubobjectDesignator &Designator = LVal.getLValueDesignator();
 
   const Expr *BaseE = Base.dyn_cast<const Expr *>();
-  const ValueDecl *BaseVD = Base.dyn_cast<const ValueDecl*>();
+  const ValueDecl *BaseVD = Base.dyn_cast<const ValueDecl *>();
 
   // Additional restrictions apply in a template argument. We only enforce the
   // C++20 restrictions here; additional syntactic and semantic restrictions
@@ -2363,7 +2325,7 @@ static bool CheckLValueConstantExpression(EvalInfo &Info, SourceLocation Loc,
   // Does this refer one past the end of some object?
   if (!Designator.Invalid && Designator.isOnePastTheEnd()) {
     Info.FFDiag(Loc, diag::note_constexpr_past_end, 1)
-      << !Designator.Entries.empty() << !!BaseVD << BaseVD;
+        << !Designator.Entries.empty() << !!BaseVD << BaseVD;
     NoteLValueLocation(Info, Base);
   }
 
@@ -2419,8 +2381,7 @@ static bool CheckLiteralType(EvalInfo &Info, const Expr *E,
 
   // Prvalue constant expressions must be of literal types.
   if (Info.getLangOpts().CPlusPlus11)
-    Info.FFDiag(E, diag::note_constexpr_nonliteral)
-      << E->getType();
+    Info.FFDiag(E, diag::note_constexpr_nonliteral) << E->getType();
   else
     Info.FFDiag(E, diag::note_invalid_subexpr_in_const_expr);
   return false;
@@ -2474,7 +2435,7 @@ static bool CheckEvaluationResult(CheckEvaluationResultKind CERK,
   }
   if (Value.isStruct()) {
     if (Type->isMetaInfoType())
-        return true;
+      return true;
     auto *RD = Type->castAsRecordDecl();
     if (const CXXRecordDecl *CD = dyn_cast<CXXRecordDecl>(RD)) {
       unsigned BaseIndex = 0;
@@ -2514,7 +2475,8 @@ static bool CheckEvaluationResult(CheckEvaluationResultKind CERK,
 
   if (Value.isMemberPointer() &&
       CERK == CheckEvaluationResultKind::ConstantExpression)
-    return CheckMemberPointerConstantExpression(Info, DiagLoc, Type, Value, Kind);
+    return CheckMemberPointerConstantExpression(Info, DiagLoc, Type, Value,
+                                                Kind);
 
   // Everything else is fine.
   return true;
@@ -2572,7 +2534,7 @@ static bool EvalPointerValueAsBool(const APValue &Value, bool &Result) {
   // We have a non-null base.  These are generally known to be true, but if it's
   // a weak declaration it can be null at runtime.
   Result = true;
-  const ValueDecl *Decl = Value.getLValueBase().dyn_cast<const ValueDecl*>();
+  const ValueDecl *Decl = Value.getLValueBase().dyn_cast<const ValueDecl *>();
   return !Decl || !Decl->isWeak();
 }
 
@@ -2629,9 +2591,9 @@ static bool EvaluateAsBooleanCondition(const Expr *E, bool &Result,
   return HandleConversionToBool(Val, Result);
 }
 
-template<typename T>
-static bool HandleOverflow(EvalInfo &Info, const Expr *E,
-                           const T &SrcValue, QualType DestType) {
+template <typename T>
+static bool HandleOverflow(EvalInfo &Info, const Expr *E, const T &SrcValue,
+                           QualType DestType) {
   Info.CCEDiag(E, diag::note_constexpr_overflow) << SrcValue << DestType;
   if (const auto *OBT = DestType->getAs<OverflowBehaviorType>();
       OBT && OBT->isTrapKind()) {
@@ -2649,8 +2611,8 @@ static bool HandleFloatToIntCast(EvalInfo &Info, const Expr *E,
 
   Result = APSInt(DestWidth, !DestSigned);
   bool ignored;
-  if (Value.convertToInteger(Result, llvm::APFloat::rmTowardZero, &ignored)
-      & APFloat::opInvalidOp)
+  if (Value.convertToInteger(Result, llvm::APFloat::rmTowardZero, &ignored) &
+      APFloat::opInvalidOp)
     return HandleOverflow(Info, E, Value, DestType);
   return true;
 }
@@ -2739,17 +2701,17 @@ static APSInt HandleIntToIntCast(EvalInfo &Info, const Expr *E,
 }
 
 static bool HandleIntToFloatCast(EvalInfo &Info, const Expr *E,
-                                 const FPOptions FPO,
-                                 QualType SrcType, const APSInt &Value,
-                                 QualType DestType, APFloat &Result) {
+                                 const FPOptions FPO, QualType SrcType,
+                                 const APSInt &Value, QualType DestType,
+                                 APFloat &Result) {
   Result = APFloat(Info.Ctx.getFloatTypeSemantics(DestType), 1);
   llvm::RoundingMode RM = getActiveRoundingMode(Info, E);
   APFloat::opStatus St = Result.convertFromAPInt(Value, Value.isSigned(), RM);
   return checkFloatingPointResult(Info, E, St);
 }
 
-static bool truncateBitfieldValue(EvalInfo &Info, const Expr *E,
-                                  APValue &Value, const FieldDecl *FD) {
+static bool truncateBitfieldValue(EvalInfo &Info, const Expr *E, APValue &Value,
+                                  const FieldDecl *FD) {
   assert(FD->isBitField() && "truncateBitfieldValue on non-bitfield");
 
   if (!Value.isInt()) {
@@ -2772,7 +2734,7 @@ static bool truncateBitfieldValue(EvalInfo &Info, const Expr *E,
 /// Perform the given integer operation, which is known to need at most BitWidth
 /// bits, and check for overflow in the original type (if that type was not an
 /// unsigned type).
-template<typename Operation>
+template <typename Operation>
 static bool CheckedIntArithmetic(EvalInfo &Info, const Expr *E,
                                  const APSInt &LHS, const APSInt &RHS,
                                  unsigned BitWidth, Operation Op,
@@ -2814,9 +2776,15 @@ static bool handleIntIntBinOp(EvalInfo &Info, const BinaryOperator *E,
   case BO_Sub:
     return CheckedIntArithmetic(Info, E, LHS, RHS, LHS.getBitWidth() + 1,
                                 std::minus<APSInt>(), Result);
-  case BO_And: Result = LHS & RHS; return true;
-  case BO_Xor: Result = LHS ^ RHS; return true;
-  case BO_Or:  Result = LHS | RHS; return true;
+  case BO_And:
+    Result = LHS & RHS;
+    return true;
+  case BO_Xor:
+    Result = LHS ^ RHS;
+    return true;
+  case BO_Or:
+    Result = LHS | RHS;
+    return true;
   case BO_Div:
   case BO_Rem:
     if (RHS == 0) {
@@ -2836,7 +2804,7 @@ static bool handleIntIntBinOp(EvalInfo &Info, const BinaryOperator *E,
     if (Info.getLangOpts().OpenCL)
       // OpenCL 6.3j: shift values are effectively % word size of LHS.
       RHS &= APSInt(llvm::APInt(RHS.getBitWidth(),
-                    static_cast<uint64_t>(LHS.getBitWidth() - 1)),
+                                static_cast<uint64_t>(LHS.getBitWidth() - 1)),
                     RHS.isUnsigned());
     else if (RHS.isSigned() && RHS.isNegative()) {
       // During constant-folding, a negative shift is an opposite shift. Such
@@ -2850,10 +2818,10 @@ static bool handleIntIntBinOp(EvalInfo &Info, const BinaryOperator *E,
   shift_left:
     // C++11 [expr.shift]p1: Shift width must be less than the bit width of
     // the shifted type.
-    unsigned SA = (unsigned) RHS.getLimitedValue(LHS.getBitWidth()-1);
+    unsigned SA = (unsigned)RHS.getLimitedValue(LHS.getBitWidth() - 1);
     if (SA != RHS) {
       Info.CCEDiag(E, diag::note_constexpr_large_shift)
-        << RHS << E->getType() << LHS.getBitWidth();
+          << RHS << E->getType() << LHS.getBitWidth();
       if (!Info.noteUndefinedBehavior())
         return false;
     } else if (LHS.isSigned() && !Info.getLangOpts().CPlusPlus20) {
@@ -2878,7 +2846,7 @@ static bool handleIntIntBinOp(EvalInfo &Info, const BinaryOperator *E,
     if (Info.getLangOpts().OpenCL)
       // OpenCL 6.3j: shift values are effectively % word size of LHS.
       RHS &= APSInt(llvm::APInt(RHS.getBitWidth(),
-                    static_cast<uint64_t>(LHS.getBitWidth() - 1)),
+                                static_cast<uint64_t>(LHS.getBitWidth() - 1)),
                     RHS.isUnsigned());
     else if (RHS.isSigned() && RHS.isNegative()) {
       // During constant-folding, a negative shift is an opposite shift. Such a
@@ -2892,24 +2860,36 @@ static bool handleIntIntBinOp(EvalInfo &Info, const BinaryOperator *E,
   shift_right:
     // C++11 [expr.shift]p1: Shift width must be less than the bit width of the
     // shifted type.
-    unsigned SA = (unsigned) RHS.getLimitedValue(LHS.getBitWidth()-1);
+    unsigned SA = (unsigned)RHS.getLimitedValue(LHS.getBitWidth() - 1);
     if (SA != RHS) {
       Info.CCEDiag(E, diag::note_constexpr_large_shift)
-        << RHS << E->getType() << LHS.getBitWidth();
+          << RHS << E->getType() << LHS.getBitWidth();
       if (!Info.noteUndefinedBehavior())
         return false;
     }
 
     Result = LHS >> SA;
     return true;
-  }
-
-  case BO_LT: Result = LHS < RHS; return true;
-  case BO_GT: Result = LHS > RHS; return true;
-  case BO_LE: Result = LHS <= RHS; return true;
-  case BO_GE: Result = LHS >= RHS; return true;
-  case BO_EQ: Result = LHS == RHS; return true;
-  case BO_NE: Result = LHS != RHS; return true;
+  }
+
+  case BO_LT:
+    Result = LHS < RHS;
+    return true;
+  case BO_GT:
+    Result = LHS > RHS;
+    return true;
+  case BO_LE:
+    Result = LHS <= RHS;
+    return true;
+  case BO_GE:
+    Result = LHS >= RHS;
+    return true;
+  case BO_EQ:
+    Result = LHS == RHS;
+    return true;
+  case BO_NE:
+    Result = LHS != RHS;
+    return true;
   case BO_Cmp:
     llvm_unreachable("BO_Cmp should be handled elsewhere");
   }
@@ -3127,7 +3107,8 @@ static bool CastToDerivedClass(EvalInfo &Info, const Expr *E, LValue &Result,
   // Truncate the path to the subobject, and remove any derived-to-base offsets.
   const RecordDecl *RD = TruncatedType;
   for (unsigned I = TruncatedElements, N = D.Entries.size(); I != N; ++I) {
-    if (RD->isInvalidDecl()) return false;
+    if (RD->isInvalidDecl())
+      return false;
     const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(RD);
     const CXXRecordDecl *Base = getAsBaseClass(D.Entries[I]);
     if (isVirtualBaseClass(D.Entries[I]))
@@ -3145,7 +3126,8 @@ static bool HandleLValueDirectBase(EvalInfo &Info, const Expr *E, LValue &Obj,
                                    const CXXRecordDecl *Base,
                                    const ASTRecordLayout *RL = nullptr) {
   if (!RL) {
-    if (Derived->isInvalidDecl()) return false;
+    if (Derived->isInvalidDecl())
+      return false;
     RL = &Info.Ctx.getASTRecordLayout(Derived);
   }
 
@@ -3176,7 +3158,8 @@ static bool HandleLValueBase(EvalInfo &Info, const Expr *E, LValue &Obj,
     return false;
 
   // Find the virtual base class.
-  if (DerivedDecl->isInvalidDecl()) return false;
+  if (DerivedDecl->isInvalidDecl())
+    return false;
   const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(DerivedDecl);
   Obj.addDecl(Info, E, BaseDecl, /*Virtual*/ true);
   Obj.getLValueOffset() += Layout.getVBaseClassOffset(BaseDecl);
@@ -3188,8 +3171,7 @@ static bool HandleLValueBasePath(EvalInfo &Info, const CastExpr *E,
   for (CastExpr::path_const_iterator PathI = E->path_begin(),
                                      PathE = E->path_end();
        PathI != PathE; ++PathI) {
-    if (!HandleLValueBase(Info, E, Result, Type->getAsCXXRecordDecl(),
-                          *PathI))
+    if (!HandleLValueBase(Info, E, Result, Type->getAsCXXRecordDecl(), *PathI))
       return false;
     Type = (*PathI)->getType();
   }
@@ -3217,7 +3199,8 @@ static bool HandleLValueMember(EvalInfo &Info, const Expr *E, LValue &LVal,
                                const FieldDecl *FD,
                                const ASTRecordLayout *RL = nullptr) {
   if (!RL) {
-    if (FD->getParent()->isInvalidDecl()) return false;
+    if (FD->getParent()->isInvalidDecl())
+      return false;
     RL = &Info.Ctx.getASTRecordLayout(FD->getParent());
   }
 
@@ -3412,8 +3395,7 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
         !Info.CurrentCall->Callee ||
         !Info.CurrentCall->Callee->Equals(VD->getDeclContext())) {
       if (Info.getLangOpts().CPlusPlus11) {
-        Info.FFDiag(E, diag::note_constexpr_function_param_value_unknown)
-            << VD;
+        Info.FFDiag(E, diag::note_constexpr_function_param_value_unknown) << VD;
         NoteLValueLocation(Info, Base);
       } else {
         Info.FFDiag(E);
@@ -3437,8 +3419,7 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
     // Don't diagnose during potential constant expression checking; an
     // initializer might be added later.
     if (!Info.checkingPotentialConstantExpression()) {
-      Info.FFDiag(E, diag::note_constexpr_var_init_unknown, 1)
-        << VD;
+      Info.FFDiag(E, diag::note_constexpr_var_init_unknown, 1) << VD;
       NoteLValueLocation(Info, Base);
     }
     return false;
@@ -3456,9 +3437,11 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
     // have been value-dependent too), so diagnose that.
     assert(!VD->mightBeUsableInConstantExpressions(Info.Ctx));
     if (!Info.checkingPotentialConstantExpression()) {
-      Info.FFDiag(E, Info.getLangOpts().CPlusPlus11
-                         ? diag::note_constexpr_ltor_non_constexpr
-                         : diag::note_constexpr_ltor_non_integral, 1)
+      Info.FFDiag(E,
+                  Info.getLangOpts().CPlusPlus11
+                      ? diag::note_constexpr_ltor_non_constexpr
+                      : diag::note_constexpr_ltor_non_integral,
+                  1)
           << VD << VD->getType();
       NoteLValueLocation(Info, Base);
     }
@@ -3522,7 +3505,8 @@ static unsigned getBaseIndex(const CXXRecordDecl *Derived,
   Base = Base->getCanonicalDecl();
   unsigned Index = 0;
   for (CXXRecordDecl::base_class_const_iterator I = Derived->bases_begin(),
-         E = Derived->bases_end(); I != E; ++I, ++Index) {
+                                                E = Derived->bases_end();
+       I != E; ++I, ++Index) {
     if (I->getType()->getAsCXXRecordDecl()->getCanonicalDecl() == Base)
       return Index;
   }
@@ -3547,8 +3531,7 @@ static APSInt extractStringLiteralCharacter(EvalInfo &Info, const Expr *Lit,
   if (auto PE = dyn_cast<PredefinedExpr>(Lit))
     Lit = PE->getFunctionName();
   const StringLiteral *S = cast<StringLiteral>(Lit);
-  const ConstantArrayType *CAT =
-      Info.Ctx.getAsConstantArrayType(S->getType());
+  const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(S->getType());
   assert(CAT && "string literal isn't an array");
   QualType CharType = CAT->getElementType();
   assert(CharType->isIntegerType() && "unexpected character type");
@@ -3573,8 +3556,8 @@ static void expandStringLiteral(EvalInfo &Info, const StringLiteral *S,
   assert(CharType->isIntegerType() && "unexpected character type");
 
   unsigned Elts = CAT->getZExtSize();
-  Result = APValue(APValue::UninitArray(),
-                   std::min(S->getLength(), Elts), Elts);
+  Result =
+      APValue(APValue::UninitArray(), std::min(S->getLength(), Elts), Elts);
   APSInt Value(Info.Ctx.getTypeSize(CharType),
                CharType->isUnsignedIntegerType());
   if (Result.hasArrayFiller())
@@ -3592,7 +3575,7 @@ static void expandArray(APValue &Array, unsigned Index) {
 
   // Always at least double the number of elements for which we store a value.
   unsigned OldElts = Array.getArrayInitializedElts();
-  unsigned NewElts = std::max(Index+1, OldElts * 2);
+  unsigned NewElts = std::max(Index + 1, OldElts * 2);
   NewElts = std::min(Size, std::max(NewElts, 8u));
 
   // Copy the data across.
@@ -4126,7 +4109,7 @@ struct CompleteObject {
     if (!Info.getLangOpts().CPlusPlus14 &&
         AK != AccessKinds::AK_IsWithinLifetime)
       return false;
-    return lifetimeStartedInEvaluation(Info, Base, /*MutableSubobject*/true);
+    return lifetimeStartedInEvaluation(Info, Base, /*MutableSubobject*/ true);
   }
 
   explicit operator bool() const { return !Type.isNull(); }
@@ -4173,7 +4156,8 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj,
 
   // Walk the designator's path to find the subobject.
   for (unsigned I = 0, N = Sub.Entries.size(); /**/; ++I) {
-    // Reading an indeterminate value is undefined, but assigning over one is OK.
+    // Reading an indeterminate value is undefined, but assigning over one is
+    // OK.
     if ((O->isAbsent() && !(handler.AccessKind == AK_Construct && I == N)) ||
         (O->isIndeterminate() &&
          !isValidIndeterminateAccess(handler.AccessKind))) {
@@ -4215,7 +4199,7 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj,
             DiagKind = 2;
             Loc = VolatileField->getLocation();
             Decl = VolatileField;
-          } else if (auto *VD = Obj.Base.dyn_cast<const ValueDecl*>()) {
+          } else if (auto *VD = Obj.Base.dyn_cast<const ValueDecl *>()) {
             DiagKind = 1;
             Loc = VD->getLocation();
             Decl = VD;
@@ -4248,8 +4232,8 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj,
         return false;
 
       // If we modified a bit-field, truncate it to the right width.
-      if (isModification(handler.AccessKind) &&
-          LastField && LastField->isBitField() &&
+      if (isModification(handler.AccessKind) && LastField &&
+          LastField->isBitField() &&
           !truncateBitfieldValue(Info, E, *O, LastField))
         return false;
 
@@ -4269,7 +4253,7 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj,
         // designator which points more than one past the end of the array.
         if (Info.getLangOpts().CPlusPlus11)
           Info.FFDiag(E, diag::note_constexpr_access_past_end)
-            << handler.AccessKind;
+              << handler.AccessKind;
         else
           Info.FFDiag(E);
         return handler.failed();
@@ -4294,7 +4278,7 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj,
       if (Index > 1) {
         if (Info.getLangOpts().CPlusPlus11)
           Info.FFDiag(E, diag::note_constexpr_access_past_end)
-            << handler.AccessKind;
+              << handler.AccessKind;
         else
           Info.FFDiag(E);
         return handler.failed();
@@ -4305,12 +4289,13 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj,
 
       assert(I == N - 1 && "extracting subobject of scalar?");
       if (O->isComplexInt()) {
-        return handler.found(Index ? O->getComplexIntImag()
-                                   : O->getComplexIntReal(), ObjType);
+        return handler.found(
+            Index ? O->getComplexIntImag() : O->getComplexIntReal(), ObjType);
       } else {
         assert(O->isComplexFloat());
         return handler.found(Index ? O->getComplexFloatImag()
-                                   : O->getComplexFloatReal(), ObjType);
+                                   : O->getComplexFloatReal(),
+                             ObjType);
       }
     } else if (const auto *VT = ObjType->getAs<VectorType>()) {
       uint64_t Index = Sub.Entries[I].getAsArrayIndex();
@@ -4346,7 +4331,7 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj,
       if (Field->isMutable() &&
           !Obj.mayAccessMutableMembers(Info, handler.AccessKind)) {
         Info.FFDiag(E, diag::note_constexpr_access_mutable, 1)
-          << handler.AccessKind << Field;
+            << handler.AccessKind << Field;
         Info.Note(Field->getLocation(), diag::note_declared_at);
         return handler.failed();
       }
@@ -4479,9 +4464,8 @@ const AccessKinds ModifySubobjectHandler::AccessKind;
 /// Update the designated sub-object of an rvalue to the given value.
 static bool modifySubobject(EvalInfo &Info, const Expr *E,
                             const CompleteObject &Obj,
-                            const SubobjectDesignator &Sub,
-                            APValue &NewVal) {
-  ModifySubobjectHandler Handler = { Info, NewVal, E };
+                            const SubobjectDesignator &Sub, APValue &NewVal) {
+  ModifySubobjectHandler Handler = {Info, NewVal, E};
   return findSubobject(Info, E, Obj, Sub, Handler);
 }
 
@@ -4582,7 +4566,7 @@ static CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E,
   if (isFormalAccess(AK) && LValType.isVolatileQualified()) {
     if (Info.getLangOpts().CPlusPlus)
       Info.FFDiag(E, diag::note_constexpr_access_volatile_type)
-        << AK << LValType;
+          << AK << LValType;
     else
       Info.FFDiag(E);
     return CompleteObject();
@@ -4702,9 +4686,11 @@ static CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E,
         // folding of const floating-point types, in order to make static const
         // data members of such types (supported as an extension) more useful.
         if (Info.getLangOpts().CPlusPlus) {
-          Info.CCEDiag(E, Info.getLangOpts().CPlusPlus11
-                              ? diag::note_constexpr_ltor_non_constexpr
-                              : diag::note_constexpr_ltor_non_integral, 1)
+          Info.CCEDiag(E,
+                       Info.getLangOpts().CPlusPlus11
+                           ? diag::note_constexpr_ltor_non_constexpr
+                           : diag::note_constexpr_ltor_non_integral,
+                       1)
               << VD << BaseType;
           Info.Note(VD->getLocation(), diag::note_declared_at);
         } else {
@@ -4713,9 +4699,11 @@ static CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E,
       } else {
         // Never allow reading a non-const value.
         if (Info.getLangOpts().CPlusPlus) {
-          Info.FFDiag(E, Info.getLangOpts().CPlusPlus11
-                             ? diag::note_constexpr_ltor_non_constexpr
-                             : diag::note_constexpr_ltor_non_integral, 1)
+          Info.FFDiag(E,
+                      Info.getLangOpts().CPlusPlus11
+                          ? diag::note_constexpr_ltor_non_constexpr
+                          : diag::note_constexpr_ltor_non_integral,
+                      1)
               << VD << BaseType;
           Info.Note(VD->getLocation(), diag::note_declared_at);
         } else {
@@ -4754,7 +4742,7 @@ static CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E,
   // When binding to a reference, the variable does not need to be
   // within its lifetime.
   else if (AK != clang::AK_Dereference) {
-    const Expr *Base = LVal.Base.dyn_cast<const Expr*>();
+    const Expr *Base = LVal.Base.dyn_cast<const Expr *>();
 
     if (!Frame) {
       if (const MaterializeTemporaryExpr *MTE =
@@ -4881,7 +4869,7 @@ handleLValueToRValueConversion(EvalInfo &Info, const Expr *Conv, QualType Type,
     return false;
 
   // Check for special cases where there is no existing APValue to look at.
-  const Expr *Base = LVal.Base.dyn_cast<const Expr*>();
+  const Expr *Base = LVal.Base.dyn_cast<const Expr *>();
 
   AccessKinds AK =
       WantObjectRepresentation ? AK_ReadObjectRepresentation : AK_Read;
@@ -5034,8 +5022,7 @@ struct CompoundAssignSubobjectHandler {
       Value = HandleIntToIntCast(Info, E, SubobjType, PromotedLHSType, LHS);
       return true;
     } else if (RHS.isFloat()) {
-      const FPOptions FPO = E->getFPFeaturesInEffect(
-                                    Info.Ctx.getLangOpts());
+      const FPOptions FPO = E->getFPFeaturesInEffect(Info.Ctx.getLangOpts());
       APFloat FValue(0.0);
       return HandleIntToFloatCast(Info, E, FPO, SubobjType, Value,
                                   PromotedLHSType, FValue) &&
@@ -5100,8 +5087,8 @@ static bool handleCompoundAssignment(EvalInfo &Info,
   }
 
   CompleteObject Obj = findCompleteObject(Info, E, AK_Assign, LVal, LValType);
-  CompoundAssignSubobjectHandler Handler = { Info, E, PromotedLValType, Opcode,
-                                             RVal };
+  CompoundAssignSubobjectHandler Handler = {Info, E, PromotedLValType, Opcode,
+                                            RVal};
   return Obj && findSubobject(Info, E, Obj, LVal.Designator, Handler);
 }
 
@@ -5138,13 +5125,15 @@ struct IncDecSubobjectHandler {
     case APValue::Float:
       return found(Subobj.getFloat(), SubobjType);
     case APValue::ComplexInt:
-      return found(Subobj.getComplexIntReal(),
-                   SubobjType->castAs<ComplexType>()->getElementType()
-                     .withCVRQualifiers(SubobjType.getCVRQualifiers()));
+      return found(
+          Subobj.getComplexIntReal(),
+          SubobjType->castAs<ComplexType>()->getElementType().withCVRQualifiers(
+              SubobjType.getCVRQualifiers()));
     case APValue::ComplexFloat:
-      return found(Subobj.getComplexFloatReal(),
-                   SubobjType->castAs<ComplexType>()->getElementType()
-                     .withCVRQualifiers(SubobjType.getCVRQualifiers()));
+      return found(
+          Subobj.getComplexFloatReal(),
+          SubobjType->castAs<ComplexType>()->getElementType().withCVRQualifiers(
+              SubobjType.getCVRQualifiers()));
     case APValue::LValue:
       return foundPointer(Subobj, SubobjType);
     default:
@@ -5164,7 +5153,8 @@ struct IncDecSubobjectHandler {
       return false;
     }
 
-    if (Old) *Old = APValue(Value);
+    if (Old)
+      *Old = APValue(Value);
 
     // bool arithmetic promotes to int, and the conversion back to bool
     // doesn't reduce mod 2^n, so special-case it.
@@ -5182,7 +5172,7 @@ struct IncDecSubobjectHandler {
 
       if (!WasNegative && Value.isNegative() && E->canOverflow() &&
           !SubobjType.isWrapType()) {
-        APSInt ActualValue(Value, /*IsUnsigned*/true);
+        APSInt ActualValue(Value, /*IsUnsigned*/ true);
         return HandleOverflow(Info, E, ActualValue, SubobjType);
       }
     } else {
@@ -5191,7 +5181,7 @@ struct IncDecSubobjectHandler {
       if (WasNegative && !Value.isNegative() && E->canOverflow() &&
           !SubobjType.isWrapType()) {
         unsigned BitWidth = Value.getBitWidth();
-        APSInt ActualValue(Value.sext(BitWidth + 1), /*IsUnsigned*/false);
+        APSInt ActualValue(Value.sext(BitWidth + 1), /*IsUnsigned*/ false);
         ActualValue.setBit(BitWidth);
         return HandleOverflow(Info, E, ActualValue, SubobjType);
       }
@@ -5202,7 +5192,8 @@ struct IncDecSubobjectHandler {
     if (!checkConst(SubobjType))
       return false;
 
-    if (Old) *Old = APValue(Value);
+    if (Old)
+      *Old = APValue(Value);
 
     APFloat One(Value.getSemantics(), 1);
     llvm::RoundingMode RM = getActiveRoundingMode(Info, E);
@@ -5284,8 +5275,7 @@ static bool EvaluateObjectArgument(EvalInfo &Info, const Expr *Object,
 /// \return The field or method declaration to which the member pointer refers,
 ///         or 0 if evaluation fails.
 static const ValueDecl *HandleMemberPointerAccess(EvalInfo &Info,
-                                                  QualType LVType,
-                                                  LValue &LV,
+                                                  QualType LVType, LValue &LV,
                                                   const Expr *RHS,
                                                   bool IncludeMember = true) {
   MemberPtr MemPtr;
@@ -5315,8 +5305,8 @@ static const ValueDecl *HandleMemberPointerAccess(EvalInfo &Info,
     unsigned PathLengthToMember =
         LV.Designator.Entries.size() - MemPtr.Path.size();
     for (unsigned I = 0, N = MemPtr.Path.size(); I != N; ++I) {
-      const CXXRecordDecl *LVDecl = getAsBaseClass(
-          LV.Designator.Entries[PathLengthToMember + I]);
+      const CXXRecordDecl *LVDecl =
+          getAsBaseClass(LV.Designator.Entries[PathLengthToMember + I]);
       const CXXRecordDecl *MPDecl = MemPtr.Path[I];
       if (LVDecl->getCanonicalDecl() != MPDecl->getCanonicalDecl()) {
         Info.FFDiag(RHS);
@@ -5375,7 +5365,7 @@ static const ValueDecl *HandleMemberPointerAccess(EvalInfo &Info,
       if (!HandleLValueMember(Info, RHS, LV, FD))
         return nullptr;
     } else if (const IndirectFieldDecl *IFD =
-                 dyn_cast<IndirectFieldDecl>(MemPtr.getDecl())) {
+                   dyn_cast<IndirectFieldDecl>(MemPtr.getDecl())) {
       if (!HandleLValueIndirectMember(Info, RHS, LV, IFD))
         return nullptr;
     } else {
@@ -5646,12 +5636,10 @@ struct TempVersionRAII {
     Frame.pushTempVersion();
   }
 
-  ~TempVersionRAII() {
-    Frame.popTempVersion();
-  }
+  ~TempVersionRAII() { Frame.popTempVersion(); }
 };
 
-}
+} // namespace
 
 static EvalStmtResult EvaluateStmt(StmtResult &Result, EvalInfo &Info,
                                    const Stmt *S,
@@ -5898,8 +5886,7 @@ static EvalStmtResult EvaluateStmt(StmtResult &Result, EvalInfo &Info,
         }
       }
 
-      EvalStmtResult ESR =
-          EvaluateLoopBody(Result, Info, FS->getBody(), Case);
+      EvalStmtResult ESR = EvaluateLoopBody(Result, Info, FS->getBody(), Case);
       if (ShouldPropagateBreakContinue(Info, FS, /*Scopes=*/{}, ESR))
         return ESR;
       if (ESR != ESR_Continue)
@@ -5990,10 +5977,9 @@ static EvalStmtResult EvaluateStmt(StmtResult &Result, EvalInfo &Info,
       // We know we returned, but we don't know what the value is.
       return ESR_Failed;
     }
-    if (RetExpr &&
-        !(Result.Slot
-              ? EvaluateInPlace(Result.Value, Info, *Result.Slot, RetExpr)
-              : Evaluate(Result.Value, Info, RetExpr)))
+    if (RetExpr && !(Result.Slot ? EvaluateInPlace(Result.Value, Info,
+                                                   *Result.Slot, RetExpr)
+                                 : Evaluate(Result.Value, Info, RetExpr)))
       return ESR_Failed;
     return Scope.destroy() ? ESR_Returned : ESR_Failed;
   }
@@ -6318,7 +6304,7 @@ static bool CheckTrivialDefaultConstructor(EvalInfo &Info, SourceLocation Loc,
       // FIXME: If DiagDecl is an implicitly-declared special member function,
       // we should be much more explicit about why it's not constexpr.
       Info.CCEDiag(Loc, diag::note_constexpr_invalid_function, 1)
-        << /*IsConstexpr*/0 << /*IsConstructor*/1 << CD;
+          << /*IsConstexpr*/ 0 << /*IsConstructor*/ 1 << CD;
       Info.Note(CD->getLocation(), diag::note_declared_at);
     } else {
       Info.CCEDiag(Loc, diag::note_invalid_subexpr_in_const_expr);
@@ -6362,7 +6348,7 @@ static bool CheckConstexprFunction(EvalInfo &Info, SourceLocation CallLoc,
   // Can we evaluate this function call?
   if (Definition && Body &&
       (Definition->isConstexpr() || (Info.CurrentCall->CanEvalMSConstexpr &&
-                                        Definition->hasAttr<MSConstexprAttr>())))
+                                     Definition->hasAttr<MSConstexprAttr>())))
     return true;
 
   const FunctionDecl *DiagDecl = Definition ? Definition : Declaration;
@@ -6395,10 +6381,10 @@ static bool CheckConstexprFunction(EvalInfo &Info, SourceLocation CallLoc,
     // it's not constexpr.
     if (CD && CD->isInheritingConstructor())
       Info.FFDiag(CallLoc, diag::note_constexpr_invalid_inhctor, 1)
-        << CD->getInheritedConstructor().getConstructor()->getParent();
+          << CD->getInheritedConstructor().getConstructor()->getParent();
     else
       Info.FFDiag(CallLoc, diag::note_constexpr_invalid_function, 1)
-        << DiagDecl->isConstexpr() << (bool)CD << DiagDecl;
+          << DiagDecl->isConstexpr() << (bool)CD << DiagDecl;
     Info.Note(DiagDecl->getLocation(), diag::note_declared_at);
   } else {
     Info.FFDiag(CallLoc, diag::note_invalid_subexpr_in_const_expr);
@@ -6481,8 +6467,8 @@ struct DynamicType {
 
 static const CXXRecordDecl *getBaseClassType(SubobjectDesignator &Designator,
                                              unsigned PathLength) {
-  assert(PathLength >= Designator.MostDerivedPathLength && PathLength <=
-      Designator.Entries.size() && "invalid path length");
+  assert(PathLength >= Designator.MostDerivedPathLength &&
+         PathLength <= Designator.Entries.size() && "invalid path length");
   return (PathLength == Designator.MostDerivedPathLength)
              ? Designator.MostDerivedType->getAsCXXRecordDecl()
              : getAsBaseClass(Designator.Entries[PathLength - 1]);
@@ -6686,7 +6672,7 @@ static bool HandleDynamicCast(EvalInfo &Info, const ExplicitCastExpr *E,
   assert(C && "dynamic_cast target is not void pointer nor class");
   CanQualType CQT = Info.Ctx.getCanonicalTagType(C);
 
-  auto RuntimeCheckFailed = [&] (CXXBasePaths *Paths) {
+  auto RuntimeCheckFailed = [&](CXXBasePaths *Paths) {
     // C++ [expr.dynamic.cast]p9:
     if (!E->isGLValue()) {
       //   The value of a failed cast to pointer type is the null pointer value
@@ -6810,7 +6796,7 @@ static bool MaybeHandleUnionActiveMemberChange(EvalInfo &Info,
   if (LHS.InvalidBase || LHS.Designator.Invalid)
     return false;
 
-  llvm::SmallVector<std::pair<unsigned, const FieldDecl*>, 4> UnionPathLengths;
+  llvm::SmallVector<std::pair<unsigned, const FieldDecl *>, 4> UnionPathLengths;
   // C++ [class.union]p5:
   //   define the set S(E) of subexpressions of E as follows:
   unsigned PathLength = LHS.Designator.Entries.size();
@@ -6836,9 +6822,9 @@ static bool MaybeHandleUnionActiveMemberChange(EvalInfo &Info,
 
       E = ME->getBase();
       --PathLength;
-      assert(declaresSameEntity(FD,
-                                LHS.Designator.Entries[PathLength]
-                                    .getAsBaseOrMember().getPointer()));
+      assert(declaresSameEntity(
+          FD,
+          LHS.Designator.Entries[PathLength].getAsBaseOrMember().getPointer()));
 
       //   -- If E is of the form A[B] and is interpreted as a built-in array
       //      subscripting operator, S(E) is [S(the array operand, if any)].
@@ -6871,10 +6857,11 @@ static bool MaybeHandleUnionActiveMemberChange(EvalInfo &Info,
         --PathLength;
         assert(declaresSameEntity(Elt->getType()->getAsCXXRecordDecl(),
                                   LHS.Designator.Entries[PathLength]
-                                      .getAsBaseOrMember().getPointer()));
+                                      .getAsBaseOrMember()
+                                      .getPointer()));
       }
 
-    //   -- Otherwise, S(E) is empty.
+      //   -- Otherwise, S(E) is empty.
     } else {
       break;
     }
@@ -6891,7 +6878,7 @@ static bool MaybeHandleUnionActiveMemberChange(EvalInfo &Info,
   if (!Obj)
     return false;
   for (std::pair<unsigned, const FieldDecl *> LengthAndField :
-           llvm::reverse(UnionPathLengths)) {
+       llvm::reverse(UnionPathLengths)) {
     // Form a designator for the union object.
     SubobjectDesignator D = LHS.Designator;
     D.truncate(Info.Ctx, LHS.Base, LengthAndField.first);
@@ -7121,10 +7108,11 @@ static bool HandleConstructorCall(const Expr *E, const LValue &This,
                        RD->getNumFields());
     else
       // A union starts with no active member.
-      Result = APValue((const FieldDecl*)nullptr);
+      Result = APValue((const FieldDecl *)nullptr);
   }
 
-  if (RD->isInvalidDecl()) return false;
+  if (RD->isInvalidDecl())
+    return false;
   const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(RD);
 
   // A scope for temporaries lifetime-extended by reference members.
@@ -7283,7 +7271,7 @@ static bool HandleConstructorCall(const Expr *E, const LValue &This,
 }
 
 static bool HandleConstructorCall(const Expr *E, const LValue &This,
-                                  ArrayRef<const Expr*> Args,
+                                  ArrayRef<const Expr *> Args,
                                   const CXXConstructorDecl *Definition,
                                   EvalInfo &Info, APValue &Result) {
   CallScopeRAII CallScope(Info);
@@ -7430,7 +7418,7 @@ static bool HandleDestructionImpl(EvalInfo &Info, SourceRange CallRange,
 
   // We don't have a good way to iterate fields in reverse, so collect all the
   // fields first and then walk them backwards.
-  SmallVector<FieldDecl*, 16> Fields(RD->fields());
+  SmallVector<FieldDecl *, 16> Fields(RD->fields());
   for (const FieldDecl *FD : llvm::reverse(Fields)) {
     if (FD->isUnnamedBitField())
       continue;
@@ -7492,12 +7480,12 @@ struct DestroyObjectHandler {
     return false;
   }
 };
-}
+} // namespace
 
 /// Perform a destructor or pseudo-destructor call on the given object, which
 /// might in general not be a complete object.
-static bool HandleDestruction(EvalInfo &Info, const Expr *E,
-                              const LValue &This, QualType ThisType) {
+static bool HandleDestruction(EvalInfo &Info, const Expr *E, const LValue &This,
+                              QualType ThisType) {
   CompleteObject Obj = findCompleteObject(Info, E, AK_Destroy, This, ThisType);
   DestroyObjectHandler Handler = {Info, E, This, AK_Destroy};
   return Obj && findSubobject(Info, E, Obj, This.Designator, Handler);
@@ -7701,8 +7689,8 @@ class BitCastBuffer {
 
 public:
   BitCastBuffer(CharUnits Width, bool TargetIsLittleEndian)
-      : Bytes(Width.getQuantity()),
-        TargetIsLittleEndian(TargetIsLittleEndian) {}
+      : Bytes(Width.getQuantity()), TargetIsLittleEndian(TargetIsLittleEndian) {
+  }
 
   [[nodiscard]] bool readObject(CharUnits Offset, CharUnits Width,
                                 SmallVectorImpl<unsigned char> &Output) const {
@@ -8025,8 +8013,7 @@ class BufferToAPValueConverter {
                          T->isSpecificBuiltinType(BuiltinType::Char_U));
       if (!IsStdByte && !IsUChar) {
         QualType DisplayType(EnumSugar ? (const Type *)EnumSugar : T, 0);
-        Info.FFDiag(BCE->getExprLoc(),
-                    diag::note_constexpr_bit_cast_indet_dest)
+        Info.FFDiag(BCE->getExprLoc(), diag::note_constexpr_bit_cast_indet_dest)
             << DisplayType << Info.Ctx.getLangOpts().CharIsSigned;
         return std::nullopt;
       }
@@ -8379,10 +8366,9 @@ static bool handleLValueToRValueBitCast(EvalInfo &Info, APValue &DestValue,
 }
 
 template <class Derived>
-class ExprEvaluatorBase
-  : public ConstStmtVisitor<Derived, bool> {
+class ExprEvaluatorBase : public ConstStmtVisitor<Derived, bool> {
 private:
-  Derived &getDerived() { return static_cast<Derived&>(*this); }
+  Derived &getDerived() { return static_cast<Derived &>(*this); }
   bool DerivedSuccess(const APValue &V, const Expr *E) {
     return getDerived().Success(V, E);
   }
@@ -8393,7 +8379,7 @@ class ExprEvaluatorBase
   // Check whether a conditional operator with a non-constant condition is a
   // potential constant expression. If neither arm is a potential constant
   // expression, then the conditional operator is not either.
-  template<typename ConditionalOperator>
+  template <typename ConditionalOperator>
   void CheckPotentialConstantConditional(const ConditionalOperator *E) {
     assert(Info.checkingPotentialConstantExpression());
 
@@ -8417,8 +8403,7 @@ class ExprEvaluatorBase
     Error(E, diag::note_constexpr_conditional_never_const);
   }
 
-
-  template<typename ConditionalOperator>
+  template <typename ConditionalOperator>
   bool HandleConditionalOperator(const ConditionalOperator *E) {
     bool BoolResult;
     if (!EvaluateAsBooleanCondition(E->getCond(), BoolResult, Info)) {
@@ -8472,9 +8457,7 @@ class ExprEvaluatorBase
   bool VisitStmt(const Stmt *) {
     llvm_unreachable("Expression evaluator should not be called on stmts");
   }
-  bool VisitExpr(const Expr *E) {
-    return Error(E);
-  }
+  bool VisitExpr(const Expr *E) { return Error(E); }
 
   bool VisitEmbedExpr(const EmbedExpr *E) {
     const auto It = E->begin();
@@ -8491,18 +8474,25 @@ class ExprEvaluatorBase
     return StmtVisitorTy::Visit(E->getSubExpr());
   }
 
-  bool VisitParenExpr(const ParenExpr *E)
-    { return StmtVisitorTy::Visit(E->getSubExpr()); }
-  bool VisitUnaryExtension(const UnaryOperator *E)
-    { return StmtVisitorTy::Visit(E->getSubExpr()); }
-  bool VisitUnaryPlus(const UnaryOperator *E)
-    { return StmtVisitorTy::Visit(E->getSubExpr()); }
-  bool VisitChooseExpr(const ChooseExpr *E)
-    { return StmtVisitorTy::Visit(E->getChosenSubExpr()); }
-  bool VisitGenericSelectionExpr(const GenericSelectionExpr *E)
-    { return StmtVisitorTy::Visit(E->getResultExpr()); }
-  bool VisitSubstNonTypeTemplateParmExpr(const SubstNonTypeTemplateParmExpr *E)
-    { return StmtVisitorTy::Visit(E->getReplacement()); }
+  bool VisitParenExpr(const ParenExpr *E) {
+    return StmtVisitorTy::Visit(E->getSubExpr());
+  }
+  bool VisitUnaryExtension(const UnaryOperator *E) {
+    return StmtVisitorTy::Visit(E->getSubExpr());
+  }
+  bool VisitUnaryPlus(const UnaryOperator *E) {
+    return StmtVisitorTy::Visit(E->getSubExpr());
+  }
+  bool VisitChooseExpr(const ChooseExpr *E) {
+    return StmtVisitorTy::Visit(E->getChosenSubExpr());
+  }
+  bool VisitGenericSelectionExpr(const GenericSelectionExpr *E) {
+    return StmtVisitorTy::Visit(E->getResultExpr());
+  }
+  bool
+  VisitSubstNonTypeTemplateParmExpr(const SubstNonTypeTemplateParmExpr *E) {
+    return StmtVisitorTy::Visit(E->getReplacement());
+  }
   bool VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *E) {
     TempVersionRAII RAII(*Info.CurrentCall);
     SourceLocExprScopeGuard Guard(E, Info.CurrentCall->CurSourceLocExprScope);
@@ -8531,16 +8521,16 @@ class ExprEvaluatorBase
   bool VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *E) {
     CCEDiag(E, diag::note_constexpr_invalid_cast)
         << diag::ConstexprInvalidCastKind::Reinterpret;
-    return static_cast<Derived*>(this)->VisitCastExpr(E);
+    return static_cast<Derived *>(this)->VisitCastExpr(E);
   }
   bool VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *E) {
     if (!Info.Ctx.getLangOpts().CPlusPlus20)
       CCEDiag(E, diag::note_constexpr_invalid_cast)
           << diag::ConstexprInvalidCastKind::Dynamic;
-    return static_cast<Derived*>(this)->VisitCastExpr(E);
+    return static_cast<Derived *>(this)->VisitCastExpr(E);
   }
   bool VisitBuiltinBitCastExpr(const BuiltinBitCastExpr *E) {
-    return static_cast<Derived*>(this)->VisitCastExpr(E);
+    return static_cast<Derived *>(this)->VisitCastExpr(E);
   }
 
   bool VisitBinaryOperator(const BinaryOperator *E) {
@@ -8590,7 +8580,7 @@ class ExprEvaluatorBase
     // side-effects. This is an important GNU extension. See GCC PR38377
     // for discussion.
     if (const CallExpr *CallCE =
-          dyn_cast<CallExpr>(E->getCond()->IgnoreParenCasts()))
+            dyn_cast<CallExpr>(E->getCond()->IgnoreParenCasts()))
       if (CallCE->getBuiltinCallee() == Builtin::BI__builtin_constant_p)
         IsBcpCall = true;
 
@@ -8664,7 +8654,7 @@ class ExprEvaluatorBase
   }
 
   bool handleCallExpr(const CallExpr *E, APValue &Result,
-                     const LValue *ResultSlot) {
+                      const LValue *ResultSlot) {
     CallScopeRAII CallScope(Info);
 
     const Expr *Callee = E->getCallee()->IgnoreParens();
@@ -8726,7 +8716,7 @@ class ExprEvaluatorBase
       // Don't call function pointers which have been cast to some other type.
       // Per DR (no number yet), the caller and callee can differ in noexcept.
       if (!Info.Ctx.hasSameFunctionTypeIgnoringExceptionSpec(
-        CalleeType->getPointeeType(), FD->getType())) {
+              CalleeType->getPointeeType(), FD->getType())) {
         return Error(E);
       }
 
@@ -8909,7 +8899,8 @@ class ExprEvaluatorBase
     QualType BaseTy = E->getBase()->getType();
 
     const FieldDecl *FD = dyn_cast<FieldDecl>(E->getMemberDecl());
-    if (!FD) return Error(E);
+    if (!FD)
+      return Error(E);
     assert(!FD->getType()->isReferenceType() && "prvalue reference?");
     assert(BaseTy->castAsCanonical<RecordType>()->getDecl() ==
                FD->getParent()->getCanonicalDecl() &&
@@ -9066,7 +9057,7 @@ class ExprEvaluatorBase
       }
 
       APValue ReturnValue;
-      StmtResult Result = { ReturnValue, nullptr };
+      StmtResult Result = {ReturnValue, nullptr};
       EvalStmtResult ESR = EvaluateStmt(Result, Info, *BI);
       if (ESR != ESR_Succeeded) {
         // FIXME: If the statement-expression terminated due to 'return',
@@ -9087,9 +9078,7 @@ class ExprEvaluatorBase
   }
 
   /// Visit a value which is evaluated, but whose value is ignored.
-  void VisitIgnoredValue(const Expr *E) {
-    EvaluateIgnoredValue(Info, E);
-  }
+  void VisitIgnoredValue(const Expr *E) { EvaluateIgnoredValue(Info, E); }
 
   /// Potentially visit a MemberExpr's base expression.
   void VisitIgnoredBaseExpression(const Expr *E) {
@@ -9107,9 +9096,8 @@ class ExprEvaluatorBase
 // Common base class for lvalue and temporary evaluation.
 //===----------------------------------------------------------------------===//
 namespace {
-template<class Derived>
-class LValueExprEvaluatorBase
-  : public ExprEvaluatorBase<Derived> {
+template <class Derived>
+class LValueExprEvaluatorBase : public ExprEvaluatorBase<Derived> {
 protected:
   LValue &Result;
   bool InvalidBaseOK;
@@ -9209,7 +9197,7 @@ class LValueExprEvaluatorBase
     }
   }
 };
-}
+} // namespace
 
 //===----------------------------------------------------------------------===//
 // LValue Evaluation
@@ -9246,10 +9234,10 @@ class LValueExprEvaluatorBase
 //===----------------------------------------------------------------------===//
 namespace {
 class LValueExprEvaluator
-  : public LValueExprEvaluatorBase<LValueExprEvaluator> {
+    : public LValueExprEvaluatorBase<LValueExprEvaluator> {
 public:
-  LValueExprEvaluator(EvalInfo &Info, LValue &Result, bool InvalidBaseOK) :
-    LValueExprEvaluatorBaseTy(Info, Result, InvalidBaseOK) {}
+  LValueExprEvaluator(EvalInfo &Info, LValue &Result, bool InvalidBaseOK)
+      : LValueExprEvaluatorBaseTy(Info, Result, InvalidBaseOK) {}
 
   bool VisitVarDecl(const Expr *E, const VarDecl *VD);
   bool VisitUnaryPreIncDec(const UnaryOperator *UO);
@@ -9366,7 +9354,8 @@ static bool EvaluateLValue(const Expr *E, LValue &Result, EvalInfo &Info,
                            bool InvalidBaseOK) {
   assert(!E->isValueDependent());
   assert(E->isGLValue() || E->getType()->isFunctionType() ||
-         E->getType()->isVoidType() || isa<ObjCSelectorExpr>(E->IgnoreParens()));
+         E->getType()->isVoidType() ||
+         isa<ObjCSelectorExpr>(E->IgnoreParens()));
   return LValueExprEvaluator(Info, Result, InvalidBaseOK).Visit(E);
 }
 
@@ -9548,8 +9537,8 @@ bool LValueExprEvaluator::VisitMaterializeTemporaryExpr(
   return true;
 }
 
-bool
-LValueExprEvaluator::VisitCompoundLiteralExpr(const CompoundLiteralExpr *E) {
+bool LValueExprEvaluator::VisitCompoundLiteralExpr(
+    const CompoundLiteralExpr *E) {
   assert((!Info.getLangOpts().CPlusPlus || E->isFileScope()) &&
          "lvalue compound literal in c++?");
   APValue *Lit;
@@ -9588,8 +9577,8 @@ bool LValueExprEvaluator::VisitCXXTypeidExpr(const CXXTypeidExpr *E) {
   } else {
     if (!Info.Ctx.getLangOpts().CPlusPlus20) {
       Info.CCEDiag(E, diag::note_constexpr_typeid_polymorphic)
-        << E->getExprOperand()->getType()
-        << E->getExprOperand()->getSourceRange();
+          << E->getExprOperand()->getType()
+          << E->getExprOperand()->getSourceRange();
     }
 
     if (!Visit(E->getExprOperand()))
@@ -9744,9 +9733,8 @@ bool LValueExprEvaluator::VisitUnaryPreIncDec(const UnaryOperator *UO) {
   if (!this->Visit(UO->getSubExpr()))
     return false;
 
-  return handleIncDec(
-      this->Info, UO, Result, UO->getSubExpr()->getType(),
-      UO->isIncrementOp(), nullptr);
+  return handleIncDec(this->Info, UO, Result, UO->getSubExpr()->getType(),
+                      UO->isIncrementOp(), nullptr);
 }
 
 bool LValueExprEvaluator::VisitCompoundAssignOperator(
@@ -9769,8 +9757,8 @@ bool LValueExprEvaluator::VisitCompoundAssignOperator(
     return false;
 
   return handleCompoundAssignment(
-      this->Info, CAO,
-      Result, CAO->getLHS()->getType(), CAO->getComputationLHSType(),
+      this->Info, CAO, Result, CAO->getLHS()->getType(),
+      CAO->getComputationLHSType(),
       CAO->getOpForCompoundAssignment(CAO->getOpcode()), RHS);
 }
 
@@ -9858,8 +9846,7 @@ static bool evaluateLValueAsAllocSize(EvalInfo &Info, APValue::LValueBase Base,
 }
 
 namespace {
-class PointerExprEvaluator
-  : public ExprEvaluatorBase<PointerExprEvaluator> {
+class PointerExprEvaluator : public ExprEvaluatorBase<PointerExprEvaluator> {
   LValue &Result;
   bool InvalidBaseOK;
 
@@ -9877,8 +9864,8 @@ class PointerExprEvaluator
   }
 
   bool visitNonBuiltinCallExpr(const CallExpr *E);
-public:
 
+public:
   PointerExprEvaluator(EvalInfo &info, LValue &Result, bool InvalidBaseOK)
       : ExprEvaluatorBaseTy(info), Result(Result),
         InvalidBaseOK(InvalidBaseOK) {}
@@ -9893,10 +9880,9 @@ class PointerExprEvaluator
   }
 
   bool VisitBinaryOperator(const BinaryOperator *E);
-  bool VisitCastExpr(const CastExpr* E);
+  bool VisitCastExpr(const CastExpr *E);
   bool VisitUnaryAddrOf(const UnaryOperator *E);
-  bool VisitObjCStringLiteral(const ObjCStringLiteral *E)
-      { return Success(E); }
+  bool VisitObjCStringLiteral(const ObjCStringLiteral *E) { return Success(E); }
   bool VisitObjCBoxedExpr(const ObjCBoxedExpr *E) {
     if (E->isExpressibleAsConstantInitializer())
       return Success(E);
@@ -9910,8 +9896,7 @@ class PointerExprEvaluator
   bool VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) {
     return E->isExpressibleAsConstantInitializer() ? Success(E) : Error(E);
   }
-  bool VisitAddrLabelExpr(const AddrLabelExpr *E)
-      { return Success(E); }
+  bool VisitAddrLabelExpr(const AddrLabelExpr *E) { return Success(E); }
   bool VisitCallExpr(const CallExpr *E);
   bool VisitBuiltinCallExpr(const CallExpr *E, unsigned BuiltinOp);
   bool VisitBlockExpr(const BlockExpr *E) {
@@ -10001,7 +9986,7 @@ class PointerExprEvaluator
 };
 } // end anonymous namespace
 
-static bool EvaluatePointer(const Expr* E, LValue& Result, EvalInfo &Info,
+static bool EvaluatePointer(const Expr *E, LValue &Result, EvalInfo &Info,
                             bool InvalidBaseOK) {
   assert(!E->isValueDependent());
   assert(E->isPRValue() && E->getType()->hasPointerRepresentation());
@@ -10009,8 +9994,7 @@ static bool EvaluatePointer(const Expr* E, LValue& Result, EvalInfo &Info,
 }
 
 bool PointerExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
-  if (E->getOpcode() != BO_Add &&
-      E->getOpcode() != BO_Sub)
+  if (E->getOpcode() != BO_Add && E->getOpcode() != BO_Sub)
     return ExprEvaluatorBaseTy::VisitBinaryOperator(E);
 
   const Expr *PExp = E->getLHS();
@@ -10132,9 +10116,10 @@ bool PointerExprEvaluator::VisitCastExpr(const CastExpr *E) {
 
     // Now figure out the necessary offset to add to the base LV to get from
     // the derived class to the base class.
-    return HandleLValueBasePath(Info, E, E->getSubExpr()->getType()->
-                                  castAs<PointerType>()->getPointeeType(),
-                                Result);
+    return HandleLValueBasePath(
+        Info, E,
+        E->getSubExpr()->getType()->castAs<PointerType>()->getPointeeType(),
+        Result);
 
   case CK_BaseToDerived:
     if (!Visit(E->getSubExpr()))
@@ -10460,8 +10445,7 @@ bool PointerExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
     if (!EvaluateInteger(E->getArg(1), Desired, Info))
       return false;
     uint64_t MaxLength = uint64_t(-1);
-    if (BuiltinOp != Builtin::BIstrchr &&
-        BuiltinOp != Builtin::BIwcschr &&
+    if (BuiltinOp != Builtin::BIstrchr && BuiltinOp != Builtin::BIwcschr &&
         BuiltinOp != Builtin::BI__builtin_strchr &&
         BuiltinOp != Builtin::BI__builtin_wcschr) {
       APSInt N;
@@ -10478,9 +10462,8 @@ bool PointerExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
     QualType CharTy = Result.Designator.getType(Info.Ctx);
     bool IsRawByte = BuiltinOp == Builtin::BImemchr ||
                      BuiltinOp == Builtin::BI__builtin_memchr;
-    assert(IsRawByte ||
-           Info.Ctx.hasSameUnqualifiedType(
-               CharTy, E->getArg(0)->getType()->getPointeeType()));
+    assert(IsRawByte || Info.Ctx.hasSameUnqualifiedType(
+                            CharTy, E->getArg(0)->getType()->getPointeeType()));
     // Pointers to const void may point to objects of incomplete type.
     if (IsRawByte && CharTy->isIncompleteType()) {
       Info.FFDiag(E, diag::note_constexpr_ltor_incomplete_type) << CharTy;
@@ -10631,7 +10614,7 @@ bool PointerExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
       llvm::APInt::udivrem(OrigN, TSize, N, Remainder);
       if (Remainder) {
         Info.FFDiag(E, diag::note_constexpr_memcpy_unsupported)
-            << Move << WChar << 0 << T << toString(OrigN, 10, /*Signed*/false)
+            << Move << WChar << 0 << T << toString(OrigN, 10, /*Signed*/ false)
             << (unsigned)TSize;
         return false;
       }
@@ -10645,7 +10628,7 @@ bool PointerExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
     if (N.ugt(RemainingSrcSize) || N.ugt(RemainingDestSize)) {
       Info.FFDiag(E, diag::note_constexpr_memcpy_unsupported)
           << Move << WChar << (N.ugt(RemainingSrcSize) ? 1 : 2) << T
-          << toString(N, 10, /*Signed*/false);
+          << toString(N, 10, /*Signed*/ false);
       return false;
     }
     uint64_t NElems = N.getZExtValue();
@@ -10841,8 +10824,7 @@ bool PointerExprEvaluator::VisitCXXNewExpr(const CXXNewExpr *E) {
     AllocType = Info.Ctx.getConstantArrayType(AllocType, ArrayBound, nullptr,
                                               ArraySizeModifier::Normal, 0);
   } else {
-    assert(!AllocType->isArrayType() &&
-           "array allocation with non-array new");
+    assert(!AllocType->isArrayType() && "array allocation with non-array new");
   }
 
   APValue *Val;
@@ -10945,15 +10927,15 @@ bool PointerExprEvaluator::VisitCXXNewExpr(const CXXNewExpr *E) {
 //===----------------------------------------------------------------------===//
 
 namespace {
-class ReflectionEvaluator
-  : public ExprEvaluatorBase<ReflectionEvaluator> {
+class ReflectionEvaluator : public ExprEvaluatorBase<ReflectionEvaluator> {
 
   using BaseType = ExprEvaluatorBase<ReflectionEvaluator>;
 
   APValue &Result;
+
 public:
   ReflectionEvaluator(EvalInfo &E, APValue &Result)
-    : ExprEvaluatorBaseTy(E), Result(Result) {}
+      : ExprEvaluatorBaseTy(E), Result(Result) {}
 
   bool Success(const APValue &V, const Expr *E) {
     Result = V;
@@ -10965,14 +10947,14 @@ class ReflectionEvaluator
 
 bool ReflectionEvaluator::VisitCXXReflectExpr(const CXXReflectExpr *E) {
   switch (E->getKind()) {
-    case ReflectionKind::Type: {
-      APValue Result(ReflectionKind::Type, E->getOpaqueValue());
-      return Success(Result, E);
-    }
+  case ReflectionKind::Type: {
+    APValue Result(ReflectionKind::Type, E->getOpaqueValue());
+    return Success(Result, E);
+  }
   }
   llvm_unreachable("invalid reflection");
 }
-}  // end anonymous namespace
+} // end anonymous namespace
 
 static bool EvaluateReflection(const Expr *E, APValue &Result, EvalInfo &Info) {
   assert(E->isPRValue() && E->getType()->isMetaInfoType());
@@ -10985,24 +10967,24 @@ static bool EvaluateReflection(const Expr *E, APValue &Result, EvalInfo &Info) {
 
 namespace {
 class MemberPointerExprEvaluator
-  : public ExprEvaluatorBase<MemberPointerExprEvaluator> {
+    : public ExprEvaluatorBase<MemberPointerExprEvaluator> {
   MemberPtr &Result;
 
   bool Success(const ValueDecl *D) {
     Result = MemberPtr(D);
     return true;
   }
-public:
 
+public:
   MemberPointerExprEvaluator(EvalInfo &Info, MemberPtr &Result)
-    : ExprEvaluatorBaseTy(Info), Result(Result) {}
+      : ExprEvaluatorBaseTy(Info), Result(Result) {}
 
   bool Success(const APValue &V, const Expr *E) {
     Result.setFrom(V);
     return true;
   }
   bool ZeroInitialization(const Expr *E) {
-    return Success((const ValueDecl*)nullptr);
+    return Success((const ValueDecl *)nullptr);
   }
 
   bool VisitCastExpr(const CastExpr *E);
@@ -11053,7 +11035,8 @@ bool MemberPointerExprEvaluator::VisitCastExpr(const CastExpr *E) {
     if (!Visit(E->getSubExpr()))
       return false;
     for (CastExpr::path_const_iterator PathI = E->path_begin(),
-         PathE = E->path_end(); PathI != PathE; ++PathI) {
+                                       PathE = E->path_end();
+         PathI != PathE; ++PathI) {
       assert(!(*PathI)->isVirtual() && "memptr cast through vbase");
       const CXXRecordDecl *Base = (*PathI)->getType()->getAsCXXRecordDecl();
       if (!Result.castToBase(Base))
@@ -11074,42 +11057,41 @@ bool MemberPointerExprEvaluator::VisitUnaryAddrOf(const UnaryOperator *E) {
 //===----------------------------------------------------------------------===//
 
 namespace {
-  class RecordExprEvaluator
-  : public ExprEvaluatorBase<RecordExprEvaluator> {
-    const LValue &This;
-    APValue &Result;
-  public:
+class RecordExprEvaluator : public ExprEvaluatorBase<RecordExprEvaluator> {
+  const LValue &This;
+  APValue &Result;
 
-    RecordExprEvaluator(EvalInfo &info, const LValue &This, APValue &Result)
+public:
+  RecordExprEvaluator(EvalInfo &info, const LValue &This, APValue &Result)
       : ExprEvaluatorBaseTy(info), This(This), Result(Result) {}
 
-    bool Success(const APValue &V, const Expr *E) {
-      Result = V;
-      return true;
-    }
-    bool ZeroInitialization(const Expr *E) {
-      return ZeroInitialization(E, E->getType());
-    }
-    bool ZeroInitialization(const Expr *E, QualType T);
+  bool Success(const APValue &V, const Expr *E) {
+    Result = V;
+    return true;
+  }
+  bool ZeroInitialization(const Expr *E) {
+    return ZeroInitialization(E, E->getType());
+  }
+  bool ZeroInitialization(const Expr *E, QualType T);
 
-    bool VisitCallExpr(const CallExpr *E) {
-      return handleCallExpr(E, Result, &This);
-    }
-    bool VisitCastExpr(const CastExpr *E);
-    bool VisitInitListExpr(const InitListExpr *E);
-    bool VisitCXXConstructExpr(const CXXConstructExpr *E) {
-      return VisitCXXConstructExpr(E, E->getType());
-    }
-    bool VisitLambdaExpr(const LambdaExpr *E);
-    bool VisitCXXInheritedCtorInitExpr(const CXXInheritedCtorInitExpr *E);
-    bool VisitCXXConstructExpr(const CXXConstructExpr *E, QualType T);
-    bool VisitCXXStdInitializerListExpr(const CXXStdInitializerListExpr *E);
-    bool VisitBinCmp(const BinaryOperator *E);
-    bool VisitCXXParenListInitExpr(const CXXParenListInitExpr *E);
-    bool VisitCXXParenListOrInitListExpr(const Expr *ExprToVisit,
-                                         ArrayRef<Expr *> Args);
-  };
-}
+  bool VisitCallExpr(const CallExpr *E) {
+    return handleCallExpr(E, Result, &This);
+  }
+  bool VisitCastExpr(const CastExpr *E);
+  bool VisitInitListExpr(const InitListExpr *E);
+  bool VisitCXXConstructExpr(const CXXConstructExpr *E) {
+    return VisitCXXConstructExpr(E, E->getType());
+  }
+  bool VisitLambdaExpr(const LambdaExpr *E);
+  bool VisitCXXInheritedCtorInitExpr(const CXXInheritedCtorInitExpr *E);
+  bool VisitCXXConstructExpr(const CXXConstructExpr *E, QualType T);
+  bool VisitCXXStdInitializerListExpr(const CXXStdInitializerListExpr *E);
+  bool VisitBinCmp(const BinaryOperator *E);
+  bool VisitCXXParenListInitExpr(const CXXParenListInitExpr *E);
+  bool VisitCXXParenListOrInitListExpr(const Expr *ExprToVisit,
+                                       ArrayRef<Expr *> Args);
+};
+} // namespace
 
 /// Perform zero-initialization on an object of non-union class type.
 /// C++11 [dcl.init]p5:
@@ -11126,13 +11108,15 @@ static bool HandleClassZeroInitialization(EvalInfo &Info, const Expr *E,
   Result = APValue(APValue::UninitStruct(), CD ? CD->getNumBases() : 0,
                    RD->getNumFields());
 
-  if (RD->isInvalidDecl()) return false;
+  if (RD->isInvalidDecl())
+    return false;
   const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(RD);
 
   if (CD) {
     unsigned Index = 0;
     for (CXXRecordDecl::base_class_const_iterator I = CD->bases_begin(),
-           End = CD->bases_end(); I != End; ++I, ++Index) {
+                                                  End = CD->bases_end();
+         I != End; ++I, ++Index) {
       const CXXRecordDecl *Base = I->getType()->getAsCXXRecordDecl();
       LValue Subobject = This;
       if (!HandleLValueDirectBase(Info, E, Subobject, CD, Base, &Layout))
@@ -11153,8 +11137,8 @@ static bool HandleClassZeroInitialization(EvalInfo &Info, const Expr *E,
       return false;
 
     ImplicitValueInitExpr VIE(I->getType());
-    if (!EvaluateInPlace(
-          Result.getStructField(I->getFieldIndex()), Info, Subobject, &VIE))
+    if (!EvaluateInPlace(Result.getStructField(I->getFieldIndex()), Info,
+                         Subobject, &VIE))
       return false;
   }
 
@@ -11163,7 +11147,8 @@ static bool HandleClassZeroInitialization(EvalInfo &Info, const Expr *E,
 
 bool RecordExprEvaluator::ZeroInitialization(const Expr *E, QualType T) {
   const auto *RD = T->castAsRecordDecl();
-  if (RD->isInvalidDecl()) return false;
+  if (RD->isInvalidDecl())
+    return false;
   if (RD->isUnion()) {
     // C++11 [dcl.init]p5: If T is a (possibly cv-qualified) union type, the
     // object's first non-static named data member is zero-initialized
@@ -11171,7 +11156,7 @@ bool RecordExprEvaluator::ZeroInitialization(const Expr *E, QualType T) {
     while (I != RD->field_end() && (*I)->isUnnamedBitField())
       ++I;
     if (I == RD->field_end()) {
-      Result = APValue((const FieldDecl*)nullptr);
+      Result = APValue((const FieldDecl *)nullptr);
       return true;
     }
 
@@ -11211,7 +11196,8 @@ bool RecordExprEvaluator::VisitCastExpr(const CastExpr *E) {
     APValue *Value = &DerivedObject;
     const CXXRecordDecl *RD = E->getSubExpr()->getType()->getAsCXXRecordDecl();
     for (CastExpr::path_const_iterator PathI = E->path_begin(),
-         PathE = E->path_end(); PathI != PathE; ++PathI) {
+                                       PathE = E->path_end();
+         PathI != PathE; ++PathI) {
       assert(!(*PathI)->isVirtual() && "record rvalue with virtual base");
       const CXXRecordDecl *Base = (*PathI)->getType()->getAsCXXRecordDecl();
       Value = &Value->getStructBase(getBaseIndex(RD, Base));
@@ -11268,7 +11254,8 @@ bool RecordExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
 bool RecordExprEvaluator::VisitCXXParenListOrInitListExpr(
     const Expr *ExprToVisit, ArrayRef<Expr *> Args) {
   const auto *RD = ExprToVisit->getType()->castAsRecordDecl();
-  if (RD->isInvalidDecl()) return false;
+  if (RD->isInvalidDecl())
+    return false;
   const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(RD);
   auto *CXXRD = dyn_cast<CXXRecordDecl>(RD);
 
@@ -11411,7 +11398,8 @@ bool RecordExprEvaluator::VisitCXXConstructExpr(const CXXConstructExpr *E,
   // Note that E's type is not necessarily the type of our class here; we might
   // be initializing an array element instead.
   const CXXConstructorDecl *FD = E->getConstructor();
-  if (FD->isInvalidDecl() || FD->getParent()->isInvalidDecl()) return false;
+  if (FD->isInvalidDecl() || FD->getParent()->isInvalidDecl())
+    return false;
 
   bool ZeroInit = E->requiresZeroInitialization();
   if (CheckTrivialDefaultConstructor(Info, E->getExprLoc(), FD, ZeroInit)) {
@@ -11446,9 +11434,8 @@ bool RecordExprEvaluator::VisitCXXConstructExpr(const CXXConstructExpr *E,
     return false;
 
   auto Args = ArrayRef(E->getArgs(), E->getNumArgs());
-  return HandleConstructorCall(E, This, Args,
-                               cast<CXXConstructorDecl>(Definition), Info,
-                               Result);
+  return HandleConstructorCall(
+      E, This, Args, cast<CXXConstructorDecl>(Definition), Info, Result);
 }
 
 bool RecordExprEvaluator::VisitCXXInheritedCtorInitExpr(
@@ -11534,7 +11521,7 @@ bool RecordExprEvaluator::VisitLambdaExpr(const LambdaExpr *E) {
          "The number of lambda capture initializers should equal the number of "
          "fields within the closure type");
 
-  Result = APValue(APValue::UninitStruct(), /*NumBases*/0, NumFields);
+  Result = APValue(APValue::UninitStruct(), /*NumBases*/ 0, NumFields);
   // Iterate through all the lambda's closure object's fields and initialize
   // them.
   auto *CaptureInitIt = E->capture_init_begin();
@@ -11565,8 +11552,8 @@ bool RecordExprEvaluator::VisitLambdaExpr(const LambdaExpr *E) {
   return Success;
 }
 
-static bool EvaluateRecord(const Expr *E, const LValue &This,
-                           APValue &Result, EvalInfo &Info) {
+static bool EvaluateRecord(const Expr *E, const LValue &This, APValue &Result,
+                           EvalInfo &Info) {
   assert(!E->isValueDependent());
   assert(E->isPRValue() && E->getType()->isRecordType() &&
          "can't evaluate expression as a record rvalue");
@@ -11582,10 +11569,10 @@ static bool EvaluateRecord(const Expr *E, const LValue &This,
 //===----------------------------------------------------------------------===//
 namespace {
 class TemporaryExprEvaluator
-  : public LValueExprEvaluatorBase<TemporaryExprEvaluator> {
+    : public LValueExprEvaluatorBase<TemporaryExprEvaluator> {
 public:
-  TemporaryExprEvaluator(EvalInfo &Info, LValue &Result) :
-    LValueExprEvaluatorBaseTy(Info, Result, false) {}
+  TemporaryExprEvaluator(EvalInfo &Info, LValue &Result)
+      : LValueExprEvaluatorBaseTy(Info, Result, false) {}
 
   /// Visit an expression which constructs the value of this temporary.
   bool VisitConstructExpr(const Expr *E) {
@@ -11609,15 +11596,11 @@ class TemporaryExprEvaluator
   bool VisitCXXConstructExpr(const CXXConstructExpr *E) {
     return VisitConstructExpr(E);
   }
-  bool VisitCallExpr(const CallExpr *E) {
-    return VisitConstructExpr(E);
-  }
+  bool VisitCallExpr(const CallExpr *E) { return VisitConstructExpr(E); }
   bool VisitCXXStdInitializerListExpr(const CXXStdInitializerListExpr *E) {
     return VisitConstructExpr(E);
   }
-  bool VisitLambdaExpr(const LambdaExpr *E) {
-    return VisitConstructExpr(E);
-  }
+  bool VisitLambdaExpr(const LambdaExpr *E) { return VisitConstructExpr(E); }
 };
 } // end anonymous namespace
 
@@ -11633,44 +11616,42 @@ static bool EvaluateTemporary(const Expr *E, LValue &Result, EvalInfo &Info) {
 //===----------------------------------------------------------------------===//
 
 namespace {
-  class VectorExprEvaluator
-  : public ExprEvaluatorBase<VectorExprEvaluator> {
-    APValue &Result;
-  public:
+class VectorExprEvaluator : public ExprEvaluatorBase<VectorExprEvaluator> {
+  APValue &Result;
 
-    VectorExprEvaluator(EvalInfo &info, APValue &Result)
+public:
+  VectorExprEvaluator(EvalInfo &info, APValue &Result)
       : ExprEvaluatorBaseTy(info), Result(Result) {}
 
-    bool Success(ArrayRef<APValue> V, const Expr *E) {
-      assert(V.size() == E->getType()->castAs<VectorType>()->getNumElements());
-      // FIXME: remove this APValue copy.
-      Result = APValue(V.data(), V.size());
-      return true;
-    }
-    bool Success(const APValue &V, const Expr *E) {
-      assert(V.isVector());
-      Result = V;
-      return true;
-    }
-    bool ZeroInitialization(const Expr *E);
-
-    bool VisitUnaryReal(const UnaryOperator *E)
-      { return Visit(E->getSubExpr()); }
-    bool VisitCastExpr(const CastExpr* E);
-    bool VisitInitListExpr(const InitListExpr *E);
-    bool VisitUnaryImag(const UnaryOperator *E);
-    bool VisitBinaryOperator(const BinaryOperator *E);
-    bool VisitUnaryOperator(const UnaryOperator *E);
-    bool VisitCallExpr(const CallExpr *E);
-    bool VisitConvertVectorExpr(const ConvertVectorExpr *E);
-    bool VisitShuffleVectorExpr(const ShuffleVectorExpr *E);
-
-    // FIXME: Missing: conditional operator (for GNU
-    //                 conditional select), ExtVectorElementExpr
-  };
+  bool Success(ArrayRef<APValue> V, const Expr *E) {
+    assert(V.size() == E->getType()->castAs<VectorType>()->getNumElements());
+    // FIXME: remove this APValue copy.
+    Result = APValue(V.data(), V.size());
+    return true;
+  }
+  bool Success(const APValue &V, const Expr *E) {
+    assert(V.isVector());
+    Result = V;
+    return true;
+  }
+  bool ZeroInitialization(const Expr *E);
+
+  bool VisitUnaryReal(const UnaryOperator *E) { return Visit(E->getSubExpr()); }
+  bool VisitCastExpr(const CastExpr *E);
+  bool VisitInitListExpr(const InitListExpr *E);
+  bool VisitUnaryImag(const UnaryOperator *E);
+  bool VisitBinaryOperator(const BinaryOperator *E);
+  bool VisitUnaryOperator(const UnaryOperator *E);
+  bool VisitCallExpr(const CallExpr *E);
+  bool VisitConvertVectorExpr(const ConvertVectorExpr *E);
+  bool VisitShuffleVectorExpr(const ShuffleVectorExpr *E);
+
+  // FIXME: Missing: conditional operator (for GNU
+  //                 conditional select), ExtVectorElementExpr
+};
 } // end anonymous namespace
 
-static bool EvaluateVector(const Expr* E, APValue& Result, EvalInfo &Info) {
+static bool EvaluateVector(const Expr *E, APValue &Result, EvalInfo &Info) {
   assert(E->isPRValue() && E->getType()->isVectorType() &&
          "not a vector prvalue");
   return VectorExprEvaluator(Info, Result).Visit(E);
@@ -11800,8 +11781,7 @@ bool VectorExprEvaluator::VisitCastExpr(const CastExpr *E) {
   }
 }
 
-bool
-VectorExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
+bool VectorExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
   const VectorType *VT = E->getType()->castAs<VectorType>();
   unsigned NumInits = E->getNumInits();
   unsigned NumElements = VT->getNumElements();
@@ -11821,8 +11801,8 @@ VectorExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
   unsigned CountInits = 0, CountElts = 0;
   while (CountElts < NumElements) {
     // Handle nested vector initialization.
-    if (CountInits < NumInits
-        && E->getInit(CountInits)->getType()->isVectorType()) {
+    if (CountInits < NumInits &&
+        E->getInit(CountInits)->getType()->isVectorType()) {
       APValue v;
       if (!EvaluateVector(E->getInit(CountInits), v, Info))
         return Error(E);
@@ -11854,8 +11834,7 @@ VectorExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
   return Success(Elements, E);
 }
 
-bool
-VectorExprEvaluator::ZeroInitialization(const Expr *E) {
+bool VectorExprEvaluator::ZeroInitialization(const Expr *E) {
   const auto *VT = E->getType()->castAs<VectorType>();
   QualType EltTy = VT->getElementType();
   APValue ZeroElement;
@@ -14882,73 +14861,71 @@ bool MatrixExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
 //===----------------------------------------------------------------------===//
 
 namespace {
-  class ArrayExprEvaluator
-  : public ExprEvaluatorBase<ArrayExprEvaluator> {
-    const LValue &This;
-    APValue &Result;
-  public:
+class ArrayExprEvaluator : public ExprEvaluatorBase<ArrayExprEvaluator> {
+  const LValue &This;
+  APValue &Result;
 
-    ArrayExprEvaluator(EvalInfo &Info, const LValue &This, APValue &Result)
+public:
+  ArrayExprEvaluator(EvalInfo &Info, const LValue &This, APValue &Result)
       : ExprEvaluatorBaseTy(Info), This(This), Result(Result) {}
 
-    bool Success(const APValue &V, const Expr *E) {
-      assert(V.isArray() && "expected array");
-      Result = V;
-      return true;
-    }
-
-    bool ZeroInitialization(const Expr *E) {
-      const ConstantArrayType *CAT =
-          Info.Ctx.getAsConstantArrayType(E->getType());
-      if (!CAT) {
-        if (E->getType()->isIncompleteArrayType()) {
-          // We can be asked to zero-initialize a flexible array member; this
-          // is represented as an ImplicitValueInitExpr of incomplete array
-          // type. In this case, the array has zero elements.
-          Result = APValue(APValue::UninitArray(), 0, 0);
-          return true;
-        }
-        // FIXME: We could handle VLAs here.
-        return Error(E);
-      }
+  bool Success(const APValue &V, const Expr *E) {
+    assert(V.isArray() && "expected array");
+    Result = V;
+    return true;
+  }
 
-      Result = APValue(APValue::UninitArray(), 0, CAT->getZExtSize());
-      if (!Result.hasArrayFiller())
+  bool ZeroInitialization(const Expr *E) {
+    const ConstantArrayType *CAT =
+        Info.Ctx.getAsConstantArrayType(E->getType());
+    if (!CAT) {
+      if (E->getType()->isIncompleteArrayType()) {
+        // We can be asked to zero-initialize a flexible array member; this
+        // is represented as an ImplicitValueInitExpr of incomplete array
+        // type. In this case, the array has zero elements.
+        Result = APValue(APValue::UninitArray(), 0, 0);
         return true;
+      }
+      // FIXME: We could handle VLAs here.
+      return Error(E);
+    }
 
-      // Zero-initialize all elements.
-      LValue Subobject = This;
-      Subobject.addArray(Info, E, CAT);
-      ImplicitValueInitExpr VIE(CAT->getElementType());
-      return EvaluateInPlace(Result.getArrayFiller(), Info, Subobject, &VIE);
-    }
-
-    bool VisitCallExpr(const CallExpr *E) {
-      return handleCallExpr(E, Result, &This);
-    }
-    bool VisitCastExpr(const CastExpr *E);
-    bool VisitInitListExpr(const InitListExpr *E,
-                           QualType AllocType = QualType());
-    bool VisitArrayInitLoopExpr(const ArrayInitLoopExpr *E);
-    bool VisitCXXConstructExpr(const CXXConstructExpr *E);
-    bool VisitCXXConstructExpr(const CXXConstructExpr *E,
-                               const LValue &Subobject,
-                               APValue *Value, QualType Type);
-    bool VisitStringLiteral(const StringLiteral *E,
-                            QualType AllocType = QualType()) {
-      expandStringLiteral(Info, E, Result, AllocType);
+    Result = APValue(APValue::UninitArray(), 0, CAT->getZExtSize());
+    if (!Result.hasArrayFiller())
       return true;
-    }
-    bool VisitCXXParenListInitExpr(const CXXParenListInitExpr *E);
-    bool VisitCXXParenListOrInitListExpr(const Expr *ExprToVisit,
-                                         ArrayRef<Expr *> Args,
-                                         const Expr *ArrayFiller,
-                                         QualType AllocType = QualType());
-  };
+
+    // Zero-initialize all elements.
+    LValue Subobject = This;
+    Subobject.addArray(Info, E, CAT);
+    ImplicitValueInitExpr VIE(CAT->getElementType());
+    return EvaluateInPlace(Result.getArrayFiller(), Info, Subobject, &VIE);
+  }
+
+  bool VisitCallExpr(const CallExpr *E) {
+    return handleCallExpr(E, Result, &This);
+  }
+  bool VisitCastExpr(const CastExpr *E);
+  bool VisitInitListExpr(const InitListExpr *E,
+                         QualType AllocType = QualType());
+  bool VisitArrayInitLoopExpr(const ArrayInitLoopExpr *E);
+  bool VisitCXXConstructExpr(const CXXConstructExpr *E);
+  bool VisitCXXConstructExpr(const CXXConstructExpr *E, const LValue &Subobject,
+                             APValue *Value, QualType Type);
+  bool VisitStringLiteral(const StringLiteral *E,
+                          QualType AllocType = QualType()) {
+    expandStringLiteral(Info, E, Result, AllocType);
+    return true;
+  }
+  bool VisitCXXParenListInitExpr(const CXXParenListInitExpr *E);
+  bool VisitCXXParenListOrInitListExpr(const Expr *ExprToVisit,
+                                       ArrayRef<Expr *> Args,
+                                       const Expr *ArrayFiller,
+                                       QualType AllocType = QualType());
+};
 } // end anonymous namespace
 
-static bool EvaluateArray(const Expr *E, const LValue &This,
-                          APValue &Result, EvalInfo &Info) {
+static bool EvaluateArray(const Expr *E, const LValue &This, APValue &Result,
+                          EvalInfo &Info) {
   assert(!E->isValueDependent());
   assert(E->isPRValue() && E->getType()->isArrayType() &&
          "not an array prvalue");
@@ -15202,10 +15179,10 @@ bool ArrayExprEvaluator::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *E) {
     // array element, if any.
     FullExpressionRAII Scope(Info);
 
-    if (!EvaluateInPlace(Result.getArrayInitializedElt(Index),
-                         Info, Subobject, E->getSubExpr()) ||
-        !HandleLValueArrayAdjustment(Info, E, Subobject,
-                                     CAT->getElementType(), 1)) {
+    if (!EvaluateInPlace(Result.getArrayInitializedElt(Index), Info, Subobject,
+                         E->getSubExpr()) ||
+        !HandleLValueArrayAdjustment(Info, E, Subobject, CAT->getElementType(),
+                                     1)) {
       if (!Info.noteFailure())
         return false;
       Success = false;
@@ -15224,17 +15201,16 @@ bool ArrayExprEvaluator::VisitCXXConstructExpr(const CXXConstructExpr *E) {
 
 bool ArrayExprEvaluator::VisitCXXConstructExpr(const CXXConstructExpr *E,
                                                const LValue &Subobject,
-                                               APValue *Value,
-                                               QualType Type) {
+                                               APValue *Value, QualType Type) {
   bool HadZeroInit = Value->hasValue();
 
   if (const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(Type)) {
     unsigned FinalSize = CAT->getZExtSize();
 
     // Preserve the array filler if we had prior zero-initialization.
-    APValue Filler =
-      HadZeroInit && Value->hasArrayFiller() ? Value->getArrayFiller()
-                                             : APValue();
+    APValue Filler = HadZeroInit && Value->hasArrayFiller()
+                         ? Value->getArrayFiller()
+                         : APValue();
 
     *Value = APValue(APValue::UninitArray(), 0, FinalSize);
     if (FinalSize == 0)
@@ -15296,7 +15272,7 @@ bool ArrayExprEvaluator::VisitCXXConstructExpr(const CXXConstructExpr *E,
     return Error(E);
 
   return RecordExprEvaluator(Info, Subobject, *Value)
-             .VisitCXXConstructExpr(E, Type);
+      .VisitCXXConstructExpr(E, Type);
 }
 
 bool ArrayExprEvaluator::VisitCXXParenListInitExpr(
@@ -15317,9 +15293,9 @@ bool ArrayExprEvaluator::VisitCXXParenListInitExpr(
 //===----------------------------------------------------------------------===//
 
 namespace {
-class IntExprEvaluator
-        : public ExprEvaluatorBase<IntExprEvaluator> {
+class IntExprEvaluator : public ExprEvaluatorBase<IntExprEvaluator> {
   APValue &Result;
+
 public:
   IntExprEvaluator(EvalInfo &info, APValue &result)
       : ExprEvaluatorBaseTy(info), Result(result) {}
@@ -15345,7 +15321,7 @@ class IntExprEvaluator
            "Invalid evaluation result.");
     Result = APValue(APSInt(I));
     Result.getInt().setIsUnsigned(
-                            E->getType()->isUnsignedIntegerOrEnumerationType());
+        E->getType()->isUnsignedIntegerOrEnumerationType());
     return true;
   }
   bool Success(const llvm::APInt &I, const Expr *E) {
@@ -15415,7 +15391,7 @@ class IntExprEvaluator
   bool VisitOffsetOfExpr(const OffsetOfExpr *E);
   bool VisitUnaryOperator(const UnaryOperator *E);
 
-  bool VisitCastExpr(const CastExpr* E);
+  bool VisitCastExpr(const CastExpr *E);
   bool VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *E);
 
   bool VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *E) {
@@ -15437,9 +15413,7 @@ class IntExprEvaluator
   }
 
   // Note, GNU defines __null as an integer, not a pointer.
-  bool VisitGNUNullExpr(const GNUNullExpr *E) {
-    return ZeroInitialization(E);
-  }
+  bool VisitGNUNullExpr(const GNUNullExpr *E) { return ZeroInitialization(E); }
 
   bool VisitTypeTraitExpr(const TypeTraitExpr *E) {
     if (E->isStoredAsBoolean())
@@ -15480,7 +15454,7 @@ class FixedPointExprEvaluator
     : public ExprEvaluatorBase<FixedPointExprEvaluator> {
   APValue &Result;
 
- public:
+public:
   FixedPointExprEvaluator(EvalInfo &info, APValue &result)
       : ExprEvaluatorBaseTy(info), Result(result) {}
 
@@ -15506,9 +15480,7 @@ class FixedPointExprEvaluator
     return true;
   }
 
-  bool ZeroInitialization(const Expr *E) {
-    return Success(0, E);
-  }
+  bool ZeroInitialization(const Expr *E) { return Success(0, E); }
 
   //===--------------------------------------------------------------------===//
   //                            Visitor Methods
@@ -15595,14 +15567,14 @@ static bool EvaluateFixedPointOrInteger(const Expr *E, APFixedPoint &Result,
 /// Check whether the given declaration can be directly converted to an integral
 /// rvalue. If not, no diagnostic is produced; there are other things we can
 /// try.
-bool IntExprEvaluator::CheckReferencedDecl(const Expr* E, const Decl* D) {
+bool IntExprEvaluator::CheckReferencedDecl(const Expr *E, const Decl *D) {
   // Enums are integer constant exprs.
   if (const EnumConstantDecl *ECD = dyn_cast<EnumConstantDecl>(D)) {
     // Check for signedness/width mismatches between E type and ECD value.
-    bool SameSign = (ECD->getInitVal().isSigned()
-                     == E->getType()->isSignedIntegerOrEnumerationType());
-    bool SameWidth = (ECD->getInitVal().getBitWidth()
-                      == Info.Ctx.getIntWidth(E->getType()));
+    bool SameSign = (ECD->getInitVal().isSigned() ==
+                     E->getType()->isSignedIntegerOrEnumerationType());
+    bool SameWidth =
+        (ECD->getInitVal().getBitWidth() == Info.Ctx.getIntWidth(E->getType()));
     if (SameSign && SameWidth)
       return Success(ECD->getInitVal(), E);
     else {
@@ -15635,17 +15607,20 @@ GCCTypeClass EvaluateBuiltinClassifyType(QualType T,
 #include "clang/AST/TypeNodes.inc"
   case Type::Auto:
   case Type::DeducedTemplateSpecialization:
-      llvm_unreachable("unexpected non-canonical or dependent type");
+    llvm_unreachable("unexpected non-canonical or dependent type");
 
   case Type::Builtin:
-      switch (cast<BuiltinType>(CanTy)->getKind()) {
+    switch (cast<BuiltinType>(CanTy)->getKind()) {
 #define BUILTIN_TYPE(ID, SINGLETON_ID)
-#define SIGNED_TYPE(ID, SINGLETON_ID) \
-    case BuiltinType::ID: return GCCTypeClass::Integer;
-#define FLOATING_TYPE(ID, SINGLETON_ID) \
-    case BuiltinType::ID: return GCCTypeClass::RealFloat;
-#define PLACEHOLDER_TYPE(ID, SINGLETON_ID) \
-    case BuiltinType::ID: break;
+#define SIGNED_TYPE(ID, SINGLETON_ID)                                          \
+  case BuiltinType::ID:                                                        \
+    return GCCTypeClass::Integer;
+#define FLOATING_TYPE(ID, SINGLETON_ID)                                        \
+  case BuiltinType::ID:                                                        \
+    return GCCTypeClass::RealFloat;
+#define PLACEHOLDER_TYPE(ID, SINGLETON_ID)                                     \
+  case BuiltinType::ID:                                                        \
+    break;
 #include "clang/AST/BuiltinTypes.def"
     case BuiltinType::Void:
       return GCCTypeClass::Void;
@@ -15685,22 +15660,19 @@ GCCTypeClass EvaluateBuiltinClassifyType(QualType T,
     case BuiltinType::ObjCId:
     case BuiltinType::ObjCClass:
     case BuiltinType::ObjCSel:
-#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
-    case BuiltinType::Id:
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)                   \
+  case BuiltinType::Id:
 #include "clang/Basic/OpenCLImageTypes.def"
-#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
-    case BuiltinType::Id:
+#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) case BuiltinType::Id:
 #include "clang/Basic/OpenCLExtensionTypes.def"
     case BuiltinType::OCLSampler:
     case BuiltinType::OCLEvent:
     case BuiltinType::OCLClkEvent:
     case BuiltinType::OCLQueue:
     case BuiltinType::OCLReserveID:
-#define SVE_TYPE(Name, Id, SingletonId) \
-    case BuiltinType::Id:
+#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
 #include "clang/Basic/AArch64ACLETypes.def"
-#define PPC_VECTOR_TYPE(Name, Id, Size) \
-    case BuiltinType::Id:
+#define PPC_VECTOR_TYPE(Name, Id, Size) case BuiltinType::Id:
 #include "clang/Basic/PPCTypes.def"
 #define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
 #include "clang/Basic/RISCVVTypes.def"
@@ -15776,8 +15748,8 @@ GCCTypeClass EvaluateBuiltinClassifyType(QualType T,
 
 /// EvaluateBuiltinClassifyType - Evaluate __builtin_classify_type the same way
 /// as GCC.
-static GCCTypeClass
-EvaluateBuiltinClassifyType(const CallExpr *E, const LangOptions &LangOpts) {
+static GCCTypeClass EvaluateBuiltinClassifyType(const CallExpr *E,
+                                                const LangOptions &LangOpts) {
   // If no argument was supplied, default to None. This isn't
   // ideal, however it is what gcc does.
   if (E->getNumArgs() == 0)
@@ -15865,10 +15837,10 @@ static bool EvaluateBuiltinConstantP(EvalInfo &Info, const Expr *Arg) {
 /// Retrieves the "underlying object type" of the given expression,
 /// as used by __builtin_object_size.
 static QualType getObjectType(APValue::LValueBase B) {
-  if (const ValueDecl *D = B.dyn_cast<const ValueDecl*>()) {
+  if (const ValueDecl *D = B.dyn_cast<const ValueDecl *>()) {
     if (const VarDecl *VD = dyn_cast<VarDecl>(D))
       return VD->getType();
-  } else if (const Expr *E = B.dyn_cast<const Expr*>()) {
+  } else if (const Expr *E = B.dyn_cast<const Expr *>()) {
     if (isa<CompoundLiteralExpr>(E))
       return E->getType();
   } else if (B.is<TypeInfoLValue>()) {
@@ -16663,10 +16635,18 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
       return false;
     unsigned Arg;
     switch (Val.getCategory()) {
-    case APFloat::fcNaN: Arg = 0; break;
-    case APFloat::fcInfinity: Arg = 1; break;
-    case APFloat::fcNormal: Arg = Val.isDenormal() ? 3 : 2; break;
-    case APFloat::fcZero: Arg = 4; break;
+    case APFloat::fcNaN:
+      Arg = 0;
+      break;
+    case APFloat::fcInfinity:
+      Arg = 1;
+      break;
+    case APFloat::fcNormal:
+      Arg = Val.isDenormal() ? 3 : 2;
+      break;
+    case APFloat::fcZero:
+      Arg = 4;
+      break;
     }
     return Visit(E->getArg(Arg));
   }
@@ -16972,8 +16952,7 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
       return false;
 
     uint64_t MaxLength = uint64_t(-1);
-    if (BuiltinOp != Builtin::BIstrcmp &&
-        BuiltinOp != Builtin::BIwcscmp &&
+    if (BuiltinOp != Builtin::BIstrcmp && BuiltinOp != Builtin::BIwcscmp &&
         BuiltinOp != Builtin::BI__builtin_strcmp &&
         BuiltinOp != Builtin::BI__builtin_wcscmp) {
       APSInt N;
@@ -17115,8 +17094,8 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
       }
     }
 
-    return BuiltinOp == Builtin::BI__atomic_always_lock_free ?
-        Success(0, E) : Error(E);
+    return BuiltinOp == Builtin::BI__atomic_always_lock_free ? Success(0, E)
+                                                             : Error(E);
   }
   case Builtin::BI__builtin_addcb:
   case Builtin::BI__builtin_addcs:
@@ -17211,7 +17190,7 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
       bool IsSigned = LHS.isSigned() || RHS.isSigned() ||
                       ResultType->isSignedIntegerOrEnumerationType();
       bool AllSigned = LHS.isSigned() && RHS.isSigned() &&
-                      ResultType->isSignedIntegerOrEnumerationType();
+                       ResultType->isSignedIntegerOrEnumerationType();
       uint64_t LHSSize = LHS.getBitWidth();
       uint64_t RHSSize = RHS.getBitWidth();
       uint64_t ResultSize = Info.Ctx.getTypeSize(ResultType);
@@ -17929,7 +17908,7 @@ class DataRecursiveIntBinOpEvaluator {
 
 public:
   DataRecursiveIntBinOpEvaluator(IntExprEvaluator &IntEval, APValue &Result)
-    : IntEval(IntEval), Info(IntEval.getEvalInfo()), FinalResult(Result) { }
+      : IntEval(IntEval), Info(IntEval.getEvalInfo()), FinalResult(Result) {}
 
   /// True if \param E is a binary operator that we are going to handle
   /// data recursively.
@@ -17948,7 +17927,8 @@ class DataRecursiveIntBinOpEvaluator {
     while (!Queue.empty())
       process(PrevResult);
 
-    if (PrevResult.Failed) return false;
+    if (PrevResult.Failed)
+      return false;
 
     FinalResult.swap(PrevResult.Val);
     return true;
@@ -17961,12 +17941,8 @@ class DataRecursiveIntBinOpEvaluator {
   bool Success(const APSInt &Value, const Expr *E, APValue &Result) {
     return IntEval.Success(Value, E, Result);
   }
-  bool Error(const Expr *E) {
-    return IntEval.Error(E);
-  }
-  bool Error(const Expr *E, diag::kind D) {
-    return IntEval.Error(E, D);
-  }
+  bool Error(const Expr *E) { return IntEval.Error(E); }
+  bool Error(const Expr *E, diag::kind D) { return IntEval.Error(E, D); }
 
   OptionalDiagnostic CCEDiag(const Expr *E, diag::kind D) {
     return Info.CCEDiag(E, D);
@@ -17989,17 +17965,17 @@ class DataRecursiveIntBinOpEvaluator {
 
   void enqueue(const Expr *E) {
     E = E->IgnoreParens();
-    Queue.resize(Queue.size()+1);
+    Queue.resize(Queue.size() + 1);
     Queue.back().E = E;
     Queue.back().Kind = Job::AnyExprKind;
   }
 };
 
-}
+} // namespace
 
-bool DataRecursiveIntBinOpEvaluator::
-       VisitBinOpLHSOnly(EvalResult &LHSResult, const BinaryOperator *E,
-                         bool &SuppressRHSDiags) {
+bool DataRecursiveIntBinOpEvaluator::VisitBinOpLHSOnly(EvalResult &LHSResult,
+                                                       const BinaryOperator *E,
+                                                       bool &SuppressRHSDiags) {
   if (E->getOpcode() == BO_Comma) {
     // Ignore LHS but note if we could not evaluate it.
     if (LHSResult.Failed)
@@ -18051,13 +18027,14 @@ static void addOrSubLValueAsInteger(APValue &LVal, const APSInt &Index,
   CharUnits &Offset = LVal.getLValueOffset();
   uint64_t Offset64 = Offset.getQuantity();
   uint64_t Index64 = Index.extOrTrunc(64).getZExtValue();
-  Offset = CharUnits::fromQuantity(IsSub ? Offset64 - Index64
-                                         : Offset64 + Index64);
+  Offset =
+      CharUnits::fromQuantity(IsSub ? Offset64 - Index64 : Offset64 + Index64);
 }
 
-bool DataRecursiveIntBinOpEvaluator::
-       VisitBinOp(const EvalResult &LHSResult, const EvalResult &RHSResult,
-                  const BinaryOperator *E, APValue &Result) {
+bool DataRecursiveIntBinOpEvaluator::VisitBinOp(const EvalResult &LHSResult,
+                                                const EvalResult &RHSResult,
+                                                const BinaryOperator *E,
+                                                APValue &Result) {
   if (E->getOpcode() == BO_Comma) {
     if (RHSResult.Failed)
       return false;
@@ -18106,10 +18083,9 @@ bool DataRecursiveIntBinOpEvaluator::
   }
 
   // Handle cases like 4 + (unsigned long)&a
-  if (E->getOpcode() == BO_Add &&
-      RHSVal.isLValue() && LHSVal.isInt()) {
+  if (E->getOpcode() == BO_Add && RHSVal.isLValue() && LHSVal.isInt()) {
     Result = RHSVal;
-    addOrSubLValueAsInteger(Result, LHSVal.getInt(), /*IsSub*/false);
+    addOrSubLValueAsInteger(Result, LHSVal.getInt(), /*IsSub*/ false);
     return true;
   }
 
@@ -18118,8 +18094,8 @@ bool DataRecursiveIntBinOpEvaluator::
     if (!LHSVal.getLValueOffset().isZero() ||
         !RHSVal.getLValueOffset().isZero())
       return false;
-    const Expr *LHSExpr = LHSVal.getLValueBase().dyn_cast<const Expr*>();
-    const Expr *RHSExpr = RHSVal.getLValueBase().dyn_cast<const Expr*>();
+    const Expr *LHSExpr = LHSVal.getLValueBase().dyn_cast<const Expr *>();
+    const Expr *RHSExpr = RHSVal.getLValueBase().dyn_cast<const Expr *>();
     if (!LHSExpr || !RHSExpr)
       return false;
     const AddrLabelExpr *LHSAddrExpr = dyn_cast<AddrLabelExpr>(LHSExpr);
@@ -18153,43 +18129,43 @@ void DataRecursiveIntBinOpEvaluator::process(EvalResult &Result) {
   Job &job = Queue.back();
 
   switch (job.Kind) {
-    case Job::AnyExprKind: {
-      if (const BinaryOperator *Bop = dyn_cast<BinaryOperator>(job.E)) {
-        if (shouldEnqueue(Bop)) {
-          job.Kind = Job::BinOpKind;
-          enqueue(Bop->getLHS());
-          return;
-        }
-      }
-
-      EvaluateExpr(job.E, Result);
-      Queue.pop_back();
-      return;
-    }
-
-    case Job::BinOpKind: {
-      const BinaryOperator *Bop = cast<BinaryOperator>(job.E);
-      bool SuppressRHSDiags = false;
-      if (!VisitBinOpLHSOnly(Result, Bop, SuppressRHSDiags)) {
-        Queue.pop_back();
+  case Job::AnyExprKind: {
+    if (const BinaryOperator *Bop = dyn_cast<BinaryOperator>(job.E)) {
+      if (shouldEnqueue(Bop)) {
+        job.Kind = Job::BinOpKind;
+        enqueue(Bop->getLHS());
         return;
       }
-      if (SuppressRHSDiags)
-        job.startSpeculativeEval(Info);
-      job.LHSResult.swap(Result);
-      job.Kind = Job::BinOpVisitedLHSKind;
-      enqueue(Bop->getRHS());
-      return;
     }
 
-    case Job::BinOpVisitedLHSKind: {
-      const BinaryOperator *Bop = cast<BinaryOperator>(job.E);
-      EvalResult RHS;
-      RHS.swap(Result);
-      Result.Failed = !VisitBinOp(job.LHSResult, RHS, Bop, Result.Val);
+    EvaluateExpr(job.E, Result);
+    Queue.pop_back();
+    return;
+  }
+
+  case Job::BinOpKind: {
+    const BinaryOperator *Bop = cast<BinaryOperator>(job.E);
+    bool SuppressRHSDiags = false;
+    if (!VisitBinOpLHSOnly(Result, Bop, SuppressRHSDiags)) {
       Queue.pop_back();
       return;
     }
+    if (SuppressRHSDiags)
+      job.startSpeculativeEval(Info);
+    job.LHSResult.swap(Result);
+    job.Kind = Job::BinOpVisitedLHSKind;
+    enqueue(Bop->getRHS());
+    return;
+  }
+
+  case Job::BinOpVisitedLHSKind: {
+    const BinaryOperator *Bop = cast<BinaryOperator>(job.E);
+    EvalResult RHS;
+    RHS.swap(Result);
+    Result.Failed = !VisitBinOp(job.LHSResult, RHS, Bop, Result.Val);
+    Queue.pop_back();
+    return;
+  }
   }
 
   llvm_unreachable("Invalid Job::Kind!");
@@ -18285,9 +18261,9 @@ EvaluateComparisonBinaryOperator(EvalInfo &Info, const BinaryOperator *E,
 
     if (LHS.isComplexFloat()) {
       APFloat::cmpResult CR_r =
-        LHS.getComplexFloatReal().compare(RHS.getComplexFloatReal());
+          LHS.getComplexFloatReal().compare(RHS.getComplexFloatReal());
       APFloat::cmpResult CR_i =
-        LHS.getComplexFloatImag().compare(RHS.getComplexFloatImag());
+          LHS.getComplexFloatImag().compare(RHS.getComplexFloatImag());
       bool IsEqual = CR_r == APFloat::cmpEqual && CR_i == APFloat::cmpEqual;
       return Success(IsEqual ? CmpResult::Equal : CmpResult::Unequal, E);
     } else {
@@ -18298,8 +18274,7 @@ EvaluateComparisonBinaryOperator(EvalInfo &Info, const BinaryOperator *E,
     }
   }
 
-  if (LHSTy->isRealFloatingType() &&
-      RHSTy->isRealFloatingType()) {
+  if (LHSTy->isRealFloatingType() && RHSTy->isRealFloatingType()) {
     APFloat RHS(0.0), LHS(0.0);
 
     bool LHSOK = EvaluateFloat(E->getRHS(), RHS, Info);
@@ -18311,8 +18286,7 @@ EvaluateComparisonBinaryOperator(EvalInfo &Info, const BinaryOperator *E,
 
     assert(E->isComparisonOp() && "Invalid binary operator!");
     llvm::APFloatBase::cmpResult APFloatCmpResult = LHS.compare(RHS);
-    if (!Info.InConstantContext &&
-        APFloatCmpResult == APFloat::cmpUnordered &&
+    if (!Info.InConstantContext && APFloatCmpResult == APFloat::cmpUnordered &&
         E->getFPFeaturesInEffect(Info.Ctx.getLangOpts()).isFPConstrained()) {
       // Note: Compares may raise invalid in some cases involving NaN or sNaN.
       Info.FFDiag(E, diag::note_constexpr_float_arithmetic_strict);
@@ -18352,7 +18326,7 @@ EvaluateComparisonBinaryOperator(EvalInfo &Info, const BinaryOperator *E,
       if (Info.checkingPotentialConstantExpression() &&
           (LHSValue.AllowConstexprUnknown || RHSValue.AllowConstexprUnknown))
         return false;
-      auto DiagComparison = [&] (unsigned DiagID, bool Reversed = false) {
+      auto DiagComparison = [&](unsigned DiagID, bool Reversed = false) {
         std::string LHS = LHSValue.toString(Info.Ctx, E->getLHS()->getType());
         std::string RHS = RHSValue.toString(Info.Ctx, E->getRHS()->getType());
         Info.FFDiag(E, DiagID)
@@ -18401,7 +18375,7 @@ EvaluateComparisonBinaryOperator(EvalInfo &Info, const BinaryOperator *E,
         return DiagComparison(diag::note_constexpr_pointer_comparison_past_end,
                               true);
       if (RHSValue.Base && RHSValue.Offset.isZero() &&
-           isOnePastTheEndOfCompleteObject(Info.Ctx, LHSValue))
+          isOnePastTheEndOfCompleteObject(Info.Ctx, LHSValue))
         return DiagComparison(diag::note_constexpr_pointer_comparison_past_end,
                               false);
       // We can't tell whether an object is at the same address as another
@@ -18647,8 +18621,7 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
     auto OnSuccess = [&](CmpResult CR, const BinaryOperator *E) {
       assert((CR != CmpResult::Unequal || E->isEqualityOp()) &&
              "should only produce Unequal for equality comparisons");
-      bool IsEqual   = CR == CmpResult::Equal,
-           IsLess    = CR == CmpResult::Less,
+      bool IsEqual = CR == CmpResult::Equal, IsLess = CR == CmpResult::Less,
            IsGreater = CR == CmpResult::Greater;
       auto Op = E->getOpcode();
       switch (Op) {
@@ -18781,8 +18754,8 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
 /// VisitUnaryExprOrTypeTraitExpr - Evaluate a sizeof, alignof or vec_step with
 /// a result as the expression's type.
 bool IntExprEvaluator::VisitUnaryExprOrTypeTraitExpr(
-                                    const UnaryExprOrTypeTraitExpr *E) {
-  switch(E->getKind()) {
+    const UnaryExprOrTypeTraitExpr *E) {
+  switch (E->getKind()) {
   case UETT_PreferredAlignOf:
   case UETT_AlignOf: {
     if (E->isArgumentType())
@@ -18833,11 +18806,11 @@ bool IntExprEvaluator::VisitUnaryExprOrTypeTraitExpr(
   }
   case UETT_OpenMPRequiredSimdAlign:
     assert(E->isArgumentType());
-    return Success(
-        Info.Ctx.toCharUnitsFromBits(
-                    Info.Ctx.getOpenMPDefaultSimdAlign(E->getArgumentType()))
-            .getQuantity(),
-        E);
+    return Success(Info.Ctx
+                       .toCharUnitsFromBits(Info.Ctx.getOpenMPDefaultSimdAlign(
+                           E->getArgumentType()))
+                       .getQuantity(),
+                   E);
   case UETT_VectorElements: {
     QualType Ty = E->getTypeOfArgument();
     // If the vector has a fixed size, we can determine the number of elements
@@ -18929,7 +18902,8 @@ bool IntExprEvaluator::VisitOffsetOfExpr(const OffsetOfExpr *OOE) {
       const auto *RD = CurrentType->getAsRecordDecl();
       if (!RD)
         return Error(OOE);
-      if (RD->isInvalidDecl()) return false;
+      if (RD->isInvalidDecl())
+        return false;
       const ASTRecordLayout &RL = Info.Ctx.getASTRecordLayout(RD);
       unsigned i = MemberDecl->getFieldIndex();
       assert(i < RL.getFieldCount() && "offsetof field in wrong type");
@@ -18950,7 +18924,8 @@ bool IntExprEvaluator::VisitOffsetOfExpr(const OffsetOfExpr *OOE) {
       const auto *RD = CurrentType->getAsCXXRecordDecl();
       if (!RD)
         return Error(OOE);
-      if (RD->isInvalidDecl()) return false;
+      if (RD->isInvalidDecl())
+        return false;
       const ASTRecordLayout &RL = Info.Ctx.getASTRecordLayout(RD);
 
       // Find the base class itself.
@@ -18984,7 +18959,8 @@ bool IntExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) {
   case UO_Minus: {
     if (!Visit(E->getSubExpr()))
       return false;
-    if (!Result.isInt()) return Error(E);
+    if (!Result.isInt())
+      return Error(E);
     const APSInt &Value = Result.getInt();
     if (Value.isSigned() && Value.isMinSignedValue() && E->canOverflow() &&
         !E->getType().isWrapType()) {
@@ -19004,7 +18980,8 @@ bool IntExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) {
   case UO_Not: {
     if (!Visit(E->getSubExpr()))
       return false;
-    if (!Result.isInt()) return Error(E);
+    if (!Result.isInt())
+      return Error(E);
     return Success(~Result.getInt(), E);
   }
   case UO_LNot: {
@@ -19173,8 +19150,8 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr *E) {
       }
     }
 
-    return Success(HandleIntToIntCast(Info, E, DestType, SrcType,
-                                      Result.getInt()), E);
+    return Success(
+        HandleIntToIntCast(Info, E, DestType, SrcType, Result.getInt()), E);
   }
 
   case CK_PointerToIntegral: {
@@ -19293,7 +19270,7 @@ bool IntExprEvaluator::VisitCXXNoexceptExpr(const CXXNoexceptExpr *E) {
 }
 
 bool IntExprEvaluator::VisitConceptSpecializationExpr(
-       const ConceptSpecializationExpr *E) {
+    const ConceptSpecializationExpr *E) {
   return Success(E->isSatisfied(), E);
 }
 
@@ -19303,28 +19280,29 @@ bool IntExprEvaluator::VisitRequiresExpr(const RequiresExpr *E) {
 
 bool FixedPointExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) {
   switch (E->getOpcode()) {
-    default:
-      // Invalid unary operators
+  default:
+    // Invalid unary operators
+    return Error(E);
+  case UO_Plus:
+    // The result is just the value.
+    return Visit(E->getSubExpr());
+  case UO_Minus: {
+    if (!Visit(E->getSubExpr()))
+      return false;
+    if (!Result.isFixedPoint())
       return Error(E);
-    case UO_Plus:
-      // The result is just the value.
-      return Visit(E->getSubExpr());
-    case UO_Minus: {
-      if (!Visit(E->getSubExpr())) return false;
-      if (!Result.isFixedPoint())
-        return Error(E);
-      bool Overflowed;
-      APFixedPoint Negated = Result.getFixedPoint().negate(&Overflowed);
-      if (Overflowed && !HandleOverflow(Info, E, Negated, E->getType()))
-        return false;
-      return Success(Negated, E);
-    }
-    case UO_LNot: {
-      bool bres;
-      if (!EvaluateAsBooleanCondition(E->getSubExpr(), bres, Info))
-        return false;
-      return Success(!bres, E);
-    }
+    bool Overflowed;
+    APFixedPoint Negated = Result.getFixedPoint().negate(&Overflowed);
+    if (Overflowed && !HandleOverflow(Info, E, Negated, E->getType()))
+      return false;
+    return Success(Negated, E);
+  }
+  case UO_LNot: {
+    bool bres;
+    if (!EvaluateAsBooleanCondition(E->getSubExpr(), bres, Info))
+      return false;
+    return Success(!bres, E);
+  }
   }
 }
 
@@ -19344,9 +19322,9 @@ bool FixedPointExprEvaluator::VisitCastExpr(const CastExpr *E) {
     APFixedPoint Result = Src.convert(DestFXSema, &Overflowed);
     if (Overflowed) {
       if (Info.checkingForUndefinedBehavior())
-        Info.Ctx.getDiagnostics().Report(E->getExprLoc(),
-                                         diag::warn_fixedpoint_constant_overflow)
-          << Result.toString() << E->getType();
+        Info.Ctx.getDiagnostics().Report(
+            E->getExprLoc(), diag::warn_fixedpoint_constant_overflow)
+            << Result.toString() << E->getType();
       if (!HandleOverflow(Info, E, Result, E->getType()))
         return false;
     }
@@ -19363,9 +19341,9 @@ bool FixedPointExprEvaluator::VisitCastExpr(const CastExpr *E) {
 
     if (Overflowed) {
       if (Info.checkingForUndefinedBehavior())
-        Info.Ctx.getDiagnostics().Report(E->getExprLoc(),
-                                         diag::warn_fixedpoint_constant_overflow)
-          << IntResult.toString() << E->getType();
+        Info.Ctx.getDiagnostics().Report(
+            E->getExprLoc(), diag::warn_fixedpoint_constant_overflow)
+            << IntResult.toString() << E->getType();
       if (!HandleOverflow(Info, E, IntResult, E->getType()))
         return false;
     }
@@ -19383,9 +19361,9 @@ bool FixedPointExprEvaluator::VisitCastExpr(const CastExpr *E) {
 
     if (Overflowed) {
       if (Info.checkingForUndefinedBehavior())
-        Info.Ctx.getDiagnostics().Report(E->getExprLoc(),
-                                         diag::warn_fixedpoint_constant_overflow)
-          << Result.toString() << E->getType();
+        Info.Ctx.getDiagnostics().Report(
+            E->getExprLoc(), diag::warn_fixedpoint_constant_overflow)
+            << Result.toString() << E->getType();
       if (!HandleOverflow(Info, E, Result, E->getType()))
         return false;
     }
@@ -19421,17 +19399,17 @@ bool FixedPointExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
   switch (E->getOpcode()) {
   case BO_Add: {
     Result = LHSFX.add(RHSFX, &OpOverflow)
-                  .convert(ResultFXSema, &ConversionOverflow);
+                 .convert(ResultFXSema, &ConversionOverflow);
     break;
   }
   case BO_Sub: {
     Result = LHSFX.sub(RHSFX, &OpOverflow)
-                  .convert(ResultFXSema, &ConversionOverflow);
+                 .convert(ResultFXSema, &ConversionOverflow);
     break;
   }
   case BO_Mul: {
     Result = LHSFX.mul(RHSFX, &OpOverflow)
-                  .convert(ResultFXSema, &ConversionOverflow);
+                 .convert(ResultFXSema, &ConversionOverflow);
     break;
   }
   case BO_Div: {
@@ -19440,7 +19418,7 @@ bool FixedPointExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
       return false;
     }
     Result = LHSFX.div(RHSFX, &OpOverflow)
-                  .convert(ResultFXSema, &ConversionOverflow);
+                 .convert(ResultFXSema, &ConversionOverflow);
     break;
   }
   case BO_Shl:
@@ -19473,7 +19451,7 @@ bool FixedPointExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
     if (Info.checkingForUndefinedBehavior())
       Info.Ctx.getDiagnostics().Report(E->getExprLoc(),
                                        diag::warn_fixedpoint_constant_overflow)
-        << Result.toString() << E->getType();
+          << Result.toString() << E->getType();
     if (!HandleOverflow(Info, E, Result, E->getType()))
       return false;
   }
@@ -19485,12 +19463,12 @@ bool FixedPointExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
 //===----------------------------------------------------------------------===//
 
 namespace {
-class FloatExprEvaluator
-  : public ExprEvaluatorBase<FloatExprEvaluator> {
+class FloatExprEvaluator : public ExprEvaluatorBase<FloatExprEvaluator> {
   APFloat &Result;
+
 public:
   FloatExprEvaluator(EvalInfo &info, APFloat &result)
-    : ExprEvaluatorBaseTy(info), Result(result) {}
+      : ExprEvaluatorBaseTy(info), Result(result) {}
 
   bool Success(const APValue &V, const Expr *e) {
     Result = V.getFloat();
@@ -19516,19 +19494,18 @@ class FloatExprEvaluator
 };
 } // end anonymous namespace
 
-static bool EvaluateFloat(const Expr* E, APFloat& Result, EvalInfo &Info) {
+static bool EvaluateFloat(const Expr *E, APFloat &Result, EvalInfo &Info) {
   assert(!E->isValueDependent());
   assert(E->isPRValue() && E->getType()->isRealFloatingType());
   return FloatExprEvaluator(Info, Result).Visit(E);
 }
 
-static bool TryEvaluateBuiltinNaN(const ASTContext &Context,
-                                  QualType ResultTy,
-                                  const Expr *Arg,
-                                  bool SNaN,
+static bool TryEvaluateBuiltinNaN(const ASTContext &Context, QualType ResultTy,
+                                  const Expr *Arg, bool SNaN,
                                   llvm::APFloat &Result) {
   const StringLiteral *S = dyn_cast<StringLiteral>(Arg->IgnoreParenCasts());
-  if (!S) return false;
+  if (!S)
+    return false;
 
   const llvm::fltSemantics &Sem = Context.getFloatTypeSemantics(ResultTy);
 
@@ -19579,7 +19556,7 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) {
   case Builtin::BI__builtin_inff16:
   case Builtin::BI__builtin_inff128: {
     const llvm::fltSemantics &Sem =
-      Info.Ctx.getFloatTypeSemantics(E->getType());
+        Info.Ctx.getFloatTypeSemantics(E->getType());
     Result = llvm::APFloat::getInf(Sem);
     return true;
   }
@@ -19589,8 +19566,8 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) {
   case Builtin::BI__builtin_nansl:
   case Builtin::BI__builtin_nansf16:
   case Builtin::BI__builtin_nansf128:
-    if (!TryEvaluateBuiltinNaN(Info.Ctx, E->getType(), E->getArg(0),
-                               true, Result))
+    if (!TryEvaluateBuiltinNaN(Info.Ctx, E->getType(), E->getArg(0), true,
+                               Result))
       return Error(E);
     return true;
 
@@ -19601,8 +19578,8 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) {
   case Builtin::BI__builtin_nanf128:
     // If this is __builtin_nan() turn this into a nan, otherwise we
     // can't constant fold it.
-    if (!TryEvaluateBuiltinNaN(Info.Ctx, E->getType(), E->getArg(0),
-                               false, Result))
+    if (!TryEvaluateBuiltinNaN(Info.Ctx, E->getType(), E->getArg(0), false,
+                               Result))
       return Error(E);
     return true;
 
@@ -19626,9 +19603,9 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) {
   case Builtin::BI__arithmetic_fence:
     return EvaluateFloat(E->getArg(0), Result, Info);
 
-  // FIXME: Builtin::BI__builtin_powi
-  // FIXME: Builtin::BI__builtin_powif
-  // FIXME: Builtin::BI__builtin_powil
+    // FIXME: Builtin::BI__builtin_powi
+    // FIXME: Builtin::BI__builtin_powif
+    // FIXME: Builtin::BI__builtin_powil
 
   case Builtin::BI__builtin_copysign:
   case Builtin::BI__builtin_copysignf:
@@ -19751,7 +19728,8 @@ bool FloatExprEvaluator::VisitUnaryImag(const UnaryOperator *E) {
 
 bool FloatExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) {
   switch (E->getOpcode()) {
-  default: return Error(E);
+  default:
+    return Error(E);
   case UO_Plus:
     return EvaluateFloat(E->getSubExpr(), Result, Info);
   case UO_Minus:
@@ -19783,7 +19761,7 @@ bool FloatExprEvaluator::VisitFloatingLiteral(const FloatingLiteral *E) {
 }
 
 bool FloatExprEvaluator::VisitCastExpr(const CastExpr *E) {
-  const Expr* SubExpr = E->getSubExpr();
+  const Expr *SubExpr = E->getSubExpr();
 
   switch (E->getCastKind()) {
   default:
@@ -19794,11 +19772,10 @@ bool FloatExprEvaluator::VisitCastExpr(const CastExpr *E) {
 
   case CK_IntegralToFloating: {
     APSInt IntResult;
-    const FPOptions FPO = E->getFPFeaturesInEffect(
-                                  Info.Ctx.getLangOpts());
+    const FPOptions FPO = E->getFPFeaturesInEffect(Info.Ctx.getLangOpts());
     return EvaluateInteger(SubExpr, IntResult, Info) &&
-           HandleIntToFloatCast(Info, E, FPO, SubExpr->getType(),
-                                IntResult, E->getType(), Result);
+           HandleIntToFloatCast(Info, E, FPO, SubExpr->getType(), IntResult,
+                                E->getType(), Result);
   }
 
   case CK_FixedPointToFloating: {
@@ -19861,13 +19838,12 @@ bool FloatExprEvaluator::VisitCastExpr(const CastExpr *E) {
 //===----------------------------------------------------------------------===//
 
 namespace {
-class ComplexExprEvaluator
-  : public ExprEvaluatorBase<ComplexExprEvaluator> {
+class ComplexExprEvaluator : public ExprEvaluatorBase<ComplexExprEvaluator> {
   ComplexValue &Result;
 
 public:
   ComplexExprEvaluator(EvalInfo &info, ComplexValue &Result)
-    : ExprEvaluatorBaseTy(info), Result(Result) {}
+      : ExprEvaluatorBaseTy(info), Result(Result) {}
 
   bool Success(const APValue &V, const Expr *e) {
     Result.setFrom(V);
@@ -19913,7 +19889,7 @@ bool ComplexExprEvaluator::ZeroInitialization(const Expr *E) {
 }
 
 bool ComplexExprEvaluator::VisitImaginaryLiteral(const ImaginaryLiteral *E) {
-  const Expr* SubExpr = E->getSubExpr();
+  const Expr *SubExpr = E->getSubExpr();
 
   if (SubExpr->getType()->isRealFloatingType()) {
     Result.makeComplexFloat();
@@ -20025,8 +20001,8 @@ bool ComplexExprEvaluator::VisitCastExpr(const CastExpr *E) {
       return false;
 
     QualType To = E->getType()->castAs<ComplexType>()->getElementType();
-    QualType From
-      = E->getSubExpr()->getType()->castAs<ComplexType>()->getElementType();
+    QualType From =
+        E->getSubExpr()->getType()->castAs<ComplexType>()->getElementType();
 
     return HandleFloatToFloatCast(Info, E, From, To, Result.FloatReal) &&
            HandleFloatToFloatCast(Info, E, From, To, Result.FloatImag);
@@ -20037,13 +20013,13 @@ bool ComplexExprEvaluator::VisitCastExpr(const CastExpr *E) {
       return false;
 
     QualType To = E->getType()->castAs<ComplexType>()->getElementType();
-    QualType From
-      = E->getSubExpr()->getType()->castAs<ComplexType>()->getElementType();
+    QualType From =
+        E->getSubExpr()->getType()->castAs<ComplexType>()->getElementType();
     Result.makeComplexInt();
-    return HandleFloatToIntCast(Info, E, From, Result.FloatReal,
-                                To, Result.IntReal) &&
-           HandleFloatToIntCast(Info, E, From, Result.FloatImag,
-                                To, Result.IntImag);
+    return HandleFloatToIntCast(Info, E, From, Result.FloatReal, To,
+                                Result.IntReal) &&
+           HandleFloatToIntCast(Info, E, From, Result.FloatImag, To,
+                                Result.IntImag);
   }
 
   case CK_IntegralRealToComplex: {
@@ -20061,8 +20037,8 @@ bool ComplexExprEvaluator::VisitCastExpr(const CastExpr *E) {
       return false;
 
     QualType To = E->getType()->castAs<ComplexType>()->getElementType();
-    QualType From
-      = E->getSubExpr()->getType()->castAs<ComplexType>()->getElementType();
+    QualType From =
+        E->getSubExpr()->getType()->castAs<ComplexType>()->getElementType();
 
     Result.IntReal = HandleIntToIntCast(Info, E, To, From, Result.IntReal);
     Result.IntImag = HandleIntToIntCast(Info, E, To, From, Result.IntImag);
@@ -20073,16 +20049,15 @@ bool ComplexExprEvaluator::VisitCastExpr(const CastExpr *E) {
     if (!Visit(E->getSubExpr()))
       return false;
 
-    const FPOptions FPO = E->getFPFeaturesInEffect(
-                                  Info.Ctx.getLangOpts());
+    const FPOptions FPO = E->getFPFeaturesInEffect(Info.Ctx.getLangOpts());
     QualType To = E->getType()->castAs<ComplexType>()->getElementType();
-    QualType From
-      = E->getSubExpr()->getType()->castAs<ComplexType>()->getElementType();
+    QualType From =
+        E->getSubExpr()->getType()->castAs<ComplexType>()->getElementType();
     Result.makeComplexFloat();
-    return HandleIntToFloatCast(Info, E, FPO, From, Result.IntReal,
-                                To, Result.FloatReal) &&
-           HandleIntToFloatCast(Info, E, FPO, From, Result.IntImag,
-                                To, Result.FloatImag);
+    return HandleIntToFloatCast(Info, E, FPO, From, Result.IntReal, To,
+                                Result.FloatReal) &&
+           HandleIntToFloatCast(Info, E, FPO, From, Result.IntImag, To,
+                                Result.FloatImag);
   }
   }
 
@@ -20346,7 +20321,8 @@ bool ComplexExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
   assert(!(LHSReal && RHSReal) &&
          "Cannot have both operands of a complex operation be real.");
   switch (E->getOpcode()) {
-  default: return Error(E);
+  default:
+    return Error(E);
   case BO_Add:
     if (Result.isComplexFloat()) {
       Result.getComplexFloatReal().add(RHS.getComplexFloatReal(),
@@ -20413,11 +20389,11 @@ bool ComplexExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
     } else {
       ComplexValue LHS = Result;
       Result.getComplexIntReal() =
-        (LHS.getComplexIntReal() * RHS.getComplexIntReal() -
-         LHS.getComplexIntImag() * RHS.getComplexIntImag());
+          (LHS.getComplexIntReal() * RHS.getComplexIntReal() -
+           LHS.getComplexIntImag() * RHS.getComplexIntImag());
       Result.getComplexIntImag() =
-        (LHS.getComplexIntReal() * RHS.getComplexIntImag() +
-         LHS.getComplexIntImag() * RHS.getComplexIntReal());
+          (LHS.getComplexIntReal() * RHS.getComplexIntImag() +
+           LHS.getComplexIntImag() * RHS.getComplexIntReal());
     }
     break;
   case BO_Div:
@@ -20451,16 +20427,18 @@ bool ComplexExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
     } else {
       ComplexValue LHS = Result;
       APSInt Den = RHS.getComplexIntReal() * RHS.getComplexIntReal() +
-        RHS.getComplexIntImag() * RHS.getComplexIntImag();
+                   RHS.getComplexIntImag() * RHS.getComplexIntImag();
       if (Den.isZero())
         return Error(E, diag::note_expr_divide_by_zero);
 
       Result.getComplexIntReal() =
-        (LHS.getComplexIntReal() * RHS.getComplexIntReal() +
-         LHS.getComplexIntImag() * RHS.getComplexIntImag()) / Den;
+          (LHS.getComplexIntReal() * RHS.getComplexIntReal() +
+           LHS.getComplexIntImag() * RHS.getComplexIntImag()) /
+          Den;
       Result.getComplexIntImag() =
-        (LHS.getComplexIntImag() * RHS.getComplexIntReal() -
-         LHS.getComplexIntReal() * RHS.getComplexIntImag()) / Den;
+          (LHS.getComplexIntImag() * RHS.getComplexIntReal() -
+           LHS.getComplexIntReal() * RHS.getComplexIntImag()) /
+          Den;
     }
     break;
   }
@@ -20485,8 +20463,7 @@ bool ComplexExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) {
     if (Result.isComplexFloat()) {
       Result.getComplexFloatReal().changeSign();
       Result.getComplexFloatImag().changeSign();
-    }
-    else {
+    } else {
       Result.getComplexIntReal() = -Result.getComplexIntReal();
       Result.getComplexIntImag() = -Result.getComplexIntImag();
     }
@@ -20544,10 +20521,10 @@ bool ComplexExprEvaluator::VisitCallExpr(const CallExpr *E) {
 //===----------------------------------------------------------------------===//
 
 namespace {
-class AtomicExprEvaluator :
-    public ExprEvaluatorBase<AtomicExprEvaluator> {
+class AtomicExprEvaluator : public ExprEvaluatorBase<AtomicExprEvaluator> {
   const LValue *This;
   APValue &Result;
+
 public:
   AtomicExprEvaluator(EvalInfo &Info, const LValue *This, APValue &Result)
       : ExprEvaluatorBaseTy(Info), This(This), Result(Result) {}
@@ -20594,8 +20571,7 @@ static bool EvaluateAtomic(const Expr *E, const LValue *This, APValue &Result,
 //===----------------------------------------------------------------------===//
 
 namespace {
-class VoidExprEvaluator
-  : public ExprEvaluatorBase<VoidExprEvaluator> {
+class VoidExprEvaluator : public ExprEvaluatorBase<VoidExprEvaluator> {
 public:
   VoidExprEvaluator(EvalInfo &Info) : ExprEvaluatorBaseTy(Info) {}
 
@@ -20740,7 +20716,7 @@ static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E) {
     if (!IntExprEvaluator(Info, Result).Visit(E))
       return false;
   } else if (T->isMetaInfoType()) {
-    if(!EvaluateReflection(E, Result, Info))
+    if (!EvaluateReflection(E, Result, Info))
       return false;
   } else if (T->hasPointerRepresentation()) {
     LValue LV;
@@ -20758,7 +20734,8 @@ static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E) {
       return false;
     C.moveInto(Result);
   } else if (T->isFixedPointType()) {
-    if (!FixedPointExprEvaluator(Info, Result).Visit(E)) return false;
+    if (!FixedPointExprEvaluator(Info, Result).Visit(E))
+      return false;
   } else if (T->isMemberPointerType()) {
     MemberPtr P;
     if (!EvaluateMemberPointer(E, P, Info))
@@ -20781,8 +20758,7 @@ static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E) {
     Result = Value;
   } else if (T->isVoidType()) {
     if (!Info.getLangOpts().CPlusPlus11)
-      Info.CCEDiag(E, diag::note_constexpr_nonliteral)
-        << E->getType();
+      Info.CCEDiag(E, diag::note_constexpr_nonliteral) << E->getType();
     if (!EvaluateVoid(E, Info))
       return false;
   } else if (T->isAtomicType()) {
@@ -21135,7 +21111,7 @@ bool Expr::EvaluateAsConstantExpr(EvalResult &Result, const ASTContext &Ctx,
   // If we're evaluating a prvalue, fake up a MaterializeTemporaryExpr to
   // represent the result of the evaluation. CheckConstantExpression ensures
   // this doesn't escape.
-  MaterializeTemporaryExpr BaseMTE(T, const_cast<Expr*>(this), true);
+  MaterializeTemporaryExpr BaseMTE(T, const_cast<Expr *>(this), true);
   APValue::LValueBase Base(&BaseMTE);
   Info.setEvaluatingDecl(Base, Result.Val);
 
@@ -21372,13 +21348,13 @@ struct ICEDiag {
   ICEDiag(ICEKind IK, SourceLocation l) : Kind(IK), Loc(l) {}
 };
 
-}
+} // namespace
 
 static ICEDiag NoDiag() { return ICEDiag(IK_ICE, SourceLocation()); }
 
 static ICEDiag Worst(ICEDiag A, ICEDiag B) { return A.Kind >= B.Kind ? A : B; }
 
-static ICEDiag CheckEvalInICE(const Expr* E, const ASTContext &Ctx) {
+static ICEDiag CheckEvalInICE(const Expr *E, const ASTContext &Ctx) {
   Expr::EvalResult EVResult;
   Expr::EvalStatus Status;
   EvalInfo Info(Ctx, Status, EvaluationMode::ConstantExpression);
@@ -21391,7 +21367,7 @@ static ICEDiag CheckEvalInICE(const Expr* E, const ASTContext &Ctx) {
   return NoDiag();
 }
 
-static ICEDiag CheckICE(const Expr* E, const ASTContext &Ctx) {
+static ICEDiag CheckICE(const Expr *E, const ASTContext &Ctx) {
   assert(!E->isValueDependent() && "Should not see value dependent exprs!");
   if (!E->getType()->isIntegralOrEnumerationType())
     return ICEDiag(IK_NotICE, E->getBeginLoc());
@@ -21528,8 +21504,8 @@ static ICEDiag CheckICE(const Expr* E, const ASTContext &Ctx) {
     return CheckICE(cast<PackIndexingExpr>(E)->getSelectedExpr(), Ctx);
 
   case Expr::SubstNonTypeTemplateParmExprClass:
-    return
-      CheckICE(cast<SubstNonTypeTemplateParmExpr>(E)->getReplacement(), Ctx);
+    return CheckICE(cast<SubstNonTypeTemplateParmExpr>(E)->getReplacement(),
+                    Ctx);
 
   case Expr::ConstantExprClass:
     return CheckICE(cast<ConstantExpr>(E)->getSubExpr(), Ctx);
@@ -21622,7 +21598,7 @@ static ICEDiag CheckICE(const Expr* E, const ASTContext &Ctx) {
   }
   case Expr::UnaryExprOrTypeTraitExprClass: {
     const UnaryExprOrTypeTraitExpr *Exp = cast<UnaryExprOrTypeTraitExpr>(E);
-    if ((Exp->getKind() ==  UETT_SizeOf) &&
+    if ((Exp->getKind() == UETT_SizeOf) &&
         Exp->getTypeOfArgument()->isVariableArrayType())
       return ICEDiag(IK_NotICE, E->getBeginLoc());
     if (Exp->getKind() == UETT_CountOf) {
@@ -21685,8 +21661,7 @@ static ICEDiag CheckICE(const Expr* E, const ASTContext &Ctx) {
     case BO_Cmp: {
       ICEDiag LHSResult = CheckICE(Exp->getLHS(), Ctx);
       ICEDiag RHSResult = CheckICE(Exp->getRHS(), Ctx);
-      if (Exp->getOpcode() == BO_Div ||
-          Exp->getOpcode() == BO_Rem) {
+      if (Exp->getOpcode() == BO_Div || Exp->getOpcode() == BO_Rem) {
         // EvaluateAsRValue gives an error for undefined Div/Rem, so make sure
         // we don't evaluate one.
         if (LHSResult.Kind == IK_ICE && RHSResult.Kind == IK_ICE) {
@@ -21741,8 +21716,8 @@ static ICEDiag CheckICE(const Expr* E, const ASTContext &Ctx) {
   case Expr::ObjCBridgedCastExprClass: {
     const Expr *SubExpr = cast<CastExpr>(E)->getSubExpr();
     if (isa<ExplicitCastExpr>(E)) {
-      if (const FloatingLiteral *FL
-            = dyn_cast<FloatingLiteral>(SubExpr->IgnoreParenImpCasts())) {
+      if (const FloatingLiteral *FL =
+              dyn_cast<FloatingLiteral>(SubExpr->IgnoreParenImpCasts())) {
         unsigned DestWidth = Ctx.getIntWidth(E->getType());
         bool DestSigned = E->getType()->isSignedIntegerOrEnumerationType();
         APSInt IgnoredVal(DestWidth, !DestSigned);
@@ -21750,9 +21725,9 @@ static ICEDiag CheckICE(const Expr* E, const ASTContext &Ctx) {
         // If the value does not fit in the destination type, the behavior is
         // undefined, so we are not required to treat it as a constant
         // expression.
-        if (FL->getValue().convertToInteger(IgnoredVal,
-                                            llvm::APFloat::rmTowardZero,
-                                            &Ignored) & APFloat::opInvalidOp)
+        if (FL->getValue().convertToInteger(
+                IgnoredVal, llvm::APFloat::rmTowardZero, &Ignored) &
+            APFloat::opInvalidOp)
           return ICEDiag(IK_NotICE, E->getBeginLoc());
         return NoDiag();
       }
@@ -21772,12 +21747,16 @@ static ICEDiag CheckICE(const Expr* E, const ASTContext &Ctx) {
   case Expr::BinaryConditionalOperatorClass: {
     const BinaryConditionalOperator *Exp = cast<BinaryConditionalOperator>(E);
     ICEDiag CommonResult = CheckICE(Exp->getCommon(), Ctx);
-    if (CommonResult.Kind == IK_NotICE) return CommonResult;
+    if (CommonResult.Kind == IK_NotICE)
+      return CommonResult;
     ICEDiag FalseResult = CheckICE(Exp->getFalseExpr(), Ctx);
-    if (FalseResult.Kind == IK_NotICE) return FalseResult;
-    if (CommonResult.Kind == IK_ICEIfUnevaluated) return CommonResult;
+    if (FalseResult.Kind == IK_NotICE)
+      return FalseResult;
+    if (CommonResult.Kind == IK_ICEIfUnevaluated)
+      return CommonResult;
     if (FalseResult.Kind == IK_ICEIfUnevaluated &&
-        Exp->getCommon()->EvaluateKnownConstInt(Ctx) != 0) return NoDiag();
+        Exp->getCommon()->EvaluateKnownConstInt(Ctx) != 0)
+      return NoDiag();
     return FalseResult;
   }
   case Expr::ConditionalOperatorClass: {
@@ -21786,8 +21765,8 @@ static ICEDiag CheckICE(const Expr* E, const ASTContext &Ctx) {
     // then only the true side is actually considered in an integer constant
     // expression, and it is fully evaluated.  This is an important GNU
     // extension.  See GCC PR38377 for discussion.
-    if (const CallExpr *CallCE
-        = dyn_cast<CallExpr>(Exp->getCond()->IgnoreParenCasts()))
+    if (const CallExpr *CallCE =
+            dyn_cast<CallExpr>(Exp->getCond()->IgnoreParenCasts()))
       if (CallCE->getBuiltinCallee() == Builtin::BI__builtin_constant_p)
         return CheckEvalInICE(E, Ctx);
     ICEDiag CondResult = CheckICE(Exp->getCond(), Ctx);
@@ -21843,7 +21822,8 @@ static bool EvaluateCPlusPlus11IntegralConstantExpr(const ASTContext &Ctx,
   if (!Result.isInt())
     return false;
 
-  if (Value) *Value = Result.getInt();
+  if (Value)
+    *Value = Result.getInt();
   return true;
 }
 
@@ -21934,7 +21914,7 @@ bool Expr::isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result) const {
 
 bool Expr::EvaluateWithSubstitution(APValue &Value, ASTContext &Ctx,
                                     const FunctionDecl *Callee,
-                                    ArrayRef<const Expr*> Args,
+                                    ArrayRef<const Expr *> Args,
                                     const Expr *This) const {
   assert(!isValueDependent() &&
          "Expression evaluator can't be called on a dependent expression.");
@@ -21971,14 +21951,13 @@ bool Expr::EvaluateWithSubstitution(APValue &Value, ASTContext &Ctx,
   }
 
   CallRef Call = Info.CurrentCall->createCall(Callee);
-  for (ArrayRef<const Expr*>::iterator I = Args.begin(), E = Args.end();
+  for (ArrayRef<const Expr *>::iterator I = Args.begin(), E = Args.end();
        I != E; ++I) {
     unsigned Idx = I - Args.begin();
     if (Idx >= Callee->getNumParams())
       break;
     const ParmVarDecl *PVD = Callee->getParamDecl(Idx);
-    if ((*I)->isValueDependent() ||
-        !EvaluateCallArg(PVD, *I, Call, Info) ||
+    if ((*I)->isValueDependent() || !EvaluateCallArg(PVD, *I, Call, Info) ||
         Info.EvalStatus.HasSideEffects) {
       // If evaluation fails, throw away the argument entirely.
       if (APValue *Slot = Info.getParamSlot(Call, PVD))
@@ -22004,9 +21983,8 @@ bool Expr::EvaluateWithSubstitution(APValue &Value, ASTContext &Ctx,
          !Info.EvalStatus.HasSideEffects;
 }
 
-bool Expr::isPotentialConstantExpr(const FunctionDecl *FD,
-                                   SmallVectorImpl<
-                                     PartialDiagnosticAt> &Diags) {
+bool Expr::isPotentialConstantExpr(
+    const FunctionDecl *FD, SmallVectorImpl<PartialDiagnosticAt> &Diags) {
   // FIXME: It would be useful to check constexpr function templates, but at the
   // moment the constant expression evaluator cannot cope with the non-rigorous
   // ASTs which we build for dependent expressions.
@@ -22045,7 +22023,7 @@ bool Expr::isPotentialConstantExpr(const FunctionDecl *FD,
                                : Info.Ctx.IntTy);
   This.set({&VIE, Info.CurrentCall->Index});
 
-  ArrayRef<const Expr*> Args;
+  ArrayRef<const Expr *> Args;
 
   APValue Scratch;
   if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(FD)) {
@@ -22064,10 +22042,9 @@ bool Expr::isPotentialConstantExpr(const FunctionDecl *FD,
   return Diags.empty();
 }
 
-bool Expr::isPotentialConstantExprUnevaluated(Expr *E,
-                                              const FunctionDecl *FD,
-                                              SmallVectorImpl<
-                                                PartialDiagnosticAt> &Diags) {
+bool Expr::isPotentialConstantExprUnevaluated(
+    Expr *E, const FunctionDecl *FD,
+    SmallVectorImpl<PartialDiagnosticAt> &Diags) {
   assert(!E->isValueDependent() &&
          "Expression evaluator can't be called on a dependent expression.");
 
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index e93397d149f0b..59b61e13772d1 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -3119,7 +3119,7 @@ bool Type::isLiteralType(const ASTContext &Ctx) const {
   // -- std::meta::info is a scalar type
   // C++26 [basic.types]p10:
   // -- a scalar type is a literal type
-  if(isMetaInfoType())
+  if (isMetaInfoType())
     return true;
 
   // We treat _Atomic T as a literal type if T is a literal type.
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index e1c86e56b5255..7e53e0ad214ae 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -141,7 +141,7 @@ void Sema::NoteDeletedFunction(FunctionDecl *Decl) {
     return NoteDeletedInheritingConstructor(Ctor);
 
   Diag(Decl->getLocation(), diag::note_availability_specified_here)
-    << Decl << 1;
+      << Decl << 1;
 }
 
 /// Determine whether a FunctionDecl was ever declared with an
@@ -219,7 +219,7 @@ void Sema::MaybeSuggestAddingStaticToDecl(const FunctionDecl *Cur) {
   if (!hasAnyExplicitStorageClass(First)) {
     SourceLocation DeclBegin = First->getSourceRange().getBegin();
     Diag(DeclBegin, diag::note_convert_inline_to_static)
-      << Cur << FixItHint::CreateInsertion(DeclBegin, "static ");
+        << Cur << FixItHint::CreateInsertion(DeclBegin, "static ");
   }
 }
 
@@ -258,7 +258,7 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
   if (ParsingInitForAutoVars.count(D)) {
     if (isa<BindingDecl>(D)) {
       Diag(Loc, diag::err_binding_cannot_appear_in_own_initializer)
-        << D->getDeclName();
+          << D->getDeclName();
     } else {
       Diag(Loc, diag::err_auto_variable_cannot_appear_in_own_initializer)
           << diag::ParsingInitFor::Var << D->getDeclName()
@@ -300,8 +300,7 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
         // constraint expression, for example)
         return true;
       if (!Satisfaction.IsSatisfied) {
-        Diag(Loc,
-             diag::err_reference_to_function_with_unsatisfied_constraints)
+        Diag(Loc, diag::err_reference_to_function_with_unsatisfied_constraints)
             << D;
         DiagnoseUnsatisfiedConstraint(Satisfaction);
         return true;
@@ -316,7 +315,6 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
 
     if (getLangOpts().CUDA && !CUDA().CheckCall(Loc, FD))
       return true;
-
   }
 
   if (auto *Concept = dyn_cast<ConceptDecl>(D);
@@ -330,12 +328,12 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
           cast<CXXConstructorDecl>(MD)->isDefaultConstructor()) ||
          MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator())) {
       Diag(Loc, diag::warn_cxx17_compat_lambda_def_ctor_assign)
-        << !isa<CXXConstructorDecl>(MD);
+          << !isa<CXXConstructorDecl>(MD);
     }
   }
 
-  auto getReferencedObjCProp = [](const NamedDecl *D) ->
-                                      const ObjCPropertyDecl * {
+  auto getReferencedObjCProp =
+      [](const NamedDecl *D) -> const ObjCPropertyDecl * {
     if (const auto *MD = dyn_cast<ObjCMethodDecl>(D))
       return MD->findPropertyDecl();
     return nullptr;
@@ -344,7 +342,7 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
     if (diagnoseArgIndependentDiagnoseIfAttrs(ObjCPDecl, Loc))
       return true;
   } else if (diagnoseArgIndependentDiagnoseIfAttrs(D, Loc)) {
-      return true;
+    return true;
   }
 
   // [OpenMP 4.0], 2.15 declare reduction Directive, Restrictions
@@ -521,7 +519,8 @@ ExprResult Sema::DefaultFunctionArrayConversion(Expr *E, bool Diagnose) {
   // Handle any placeholder expressions which made it here.
   if (E->hasPlaceholderType()) {
     ExprResult result = CheckPlaceholderExpr(E);
-    if (result.isInvalid()) return ExprError();
+    if (result.isInvalid())
+      return ExprError();
     E = result.get();
   }
 
@@ -535,7 +534,8 @@ ExprResult Sema::DefaultFunctionArrayConversion(Expr *E, bool Diagnose) {
           return ExprError();
 
     E = ImpCastExprToType(E, Context.getPointerType(Ty),
-                          CK_FunctionToPointerDecay).get();
+                          CK_FunctionToPointerDecay)
+            .get();
   } else if (Ty->isArrayType()) {
     // In C90 mode, arrays only promote to pointers if the array expression is
     // an lvalue.  The relevant legalese is C90 6.2.2.1p3: "an lvalue that has
@@ -585,8 +585,7 @@ static void CheckForNullPointerDereference(Sema &S, Expr *E) {
 }
 
 static void DiagnoseDirectIsaAccess(Sema &S, const ObjCIvarRefExpr *OIRE,
-                                    SourceLocation AssignLoc,
-                                    const Expr* RHS) {
+                                    SourceLocation AssignLoc, const Expr *RHS) {
   const ObjCIvarDecl *IV = OIRE->getDecl();
   if (!IV)
     return;
@@ -604,13 +603,12 @@ static void DiagnoseDirectIsaAccess(Sema &S, const ObjCIvarRefExpr *OIRE,
     if (ObjCInterfaceDecl *IDecl = OTy->getInterface()) {
       ObjCInterfaceDecl *ClassDeclared = nullptr;
       ObjCIvarDecl *IV = IDecl->lookupInstanceVariable(Member, ClassDeclared);
-      if (!ClassDeclared->getSuperClass()
-          && (*ClassDeclared->ivar_begin()) == IV) {
+      if (!ClassDeclared->getSuperClass() &&
+          (*ClassDeclared->ivar_begin()) == IV) {
         if (RHS) {
-          NamedDecl *ObjectSetClass =
-            S.LookupSingleName(S.TUScope,
-                               &S.Context.Idents.get("object_setClass"),
-                               SourceLocation(), S.LookupOrdinaryName);
+          NamedDecl *ObjectSetClass = S.LookupSingleName(
+              S.TUScope, &S.Context.Idents.get("object_setClass"),
+              SourceLocation(), S.LookupOrdinaryName);
           if (ObjectSetClass) {
             SourceLocation RHSLocEnd = S.getLocForEndOfToken(RHS->getEndLoc());
             S.Diag(OIRE->getExprLoc(), diag::warn_objc_isa_assign)
@@ -619,14 +617,12 @@ static void DiagnoseDirectIsaAccess(Sema &S, const ObjCIvarRefExpr *OIRE,
                 << FixItHint::CreateReplacement(
                        SourceRange(OIRE->getOpLoc(), AssignLoc), ",")
                 << FixItHint::CreateInsertion(RHSLocEnd, ")");
-          }
-          else
+          } else
             S.Diag(OIRE->getLocation(), diag::warn_objc_isa_assign);
         } else {
-          NamedDecl *ObjectGetClass =
-            S.LookupSingleName(S.TUScope,
-                               &S.Context.Idents.get("object_getClass"),
-                               SourceLocation(), S.LookupOrdinaryName);
+          NamedDecl *ObjectGetClass = S.LookupSingleName(
+              S.TUScope, &S.Context.Idents.get("object_getClass"),
+              SourceLocation(), S.LookupOrdinaryName);
           if (ObjectGetClass)
             S.Diag(OIRE->getExprLoc(), diag::warn_objc_isa_use)
                 << FixItHint::CreateInsertion(OIRE->getBeginLoc(),
@@ -645,14 +641,16 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) {
   // Handle any placeholder expressions which made it here.
   if (E->hasPlaceholderType()) {
     ExprResult result = CheckPlaceholderExpr(E);
-    if (result.isInvalid()) return ExprError();
+    if (result.isInvalid())
+      return ExprError();
     E = result.get();
   }
 
   // C++ [conv.lval]p1:
   //   A glvalue of a non-function, non-array type T can be
   //   converted to a prvalue.
-  if (!E->isGLValue()) return E;
+  if (!E->isGLValue())
+    return E;
 
   QualType T = E->getType();
   assert(!T.isNull() && "r-value conversion on typeless expression?");
@@ -683,16 +681,15 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) {
   if (getLangOpts().OpenCL &&
       !getOpenCLOptions().isAvailableOption("cl_khr_fp16", getLangOpts()) &&
       T->isHalfType()) {
-    Diag(E->getExprLoc(), diag::err_opencl_half_load_store)
-      << 0 << T;
+    Diag(E->getExprLoc(), diag::err_opencl_half_load_store) << 0 << T;
     return ExprError();
   }
 
   CheckForNullPointerDereference(*this, E);
   if (const ObjCIsaExpr *OISA = dyn_cast<ObjCIsaExpr>(E->IgnoreParenCasts())) {
-    NamedDecl *ObjectGetClass = LookupSingleName(TUScope,
-                                     &Context.Idents.get("object_getClass"),
-                                     SourceLocation(), LookupOrdinaryName);
+    NamedDecl *ObjectGetClass =
+        LookupSingleName(TUScope, &Context.Idents.get("object_getClass"),
+                         SourceLocation(), LookupOrdinaryName);
     if (ObjectGetClass)
       Diag(E->getExprLoc(), diag::warn_objc_isa_use)
           << FixItHint::CreateInsertion(OISA->getBeginLoc(), "object_getClass(")
@@ -700,10 +697,9 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) {
                  SourceRange(OISA->getOpLoc(), OISA->getIsaMemberLoc()), ")");
     else
       Diag(E->getExprLoc(), diag::warn_objc_isa_use);
-  }
-  else if (const ObjCIvarRefExpr *OIRE =
-            dyn_cast<ObjCIvarRefExpr>(E->IgnoreParenCasts()))
-    DiagnoseDirectIsaAccess(*this, OIRE, SourceLocation(), /* Expr*/nullptr);
+  } else if (const ObjCIvarRefExpr *OIRE =
+                 dyn_cast<ObjCIvarRefExpr>(E->IgnoreParenCasts()))
+    DiagnoseDirectIsaAccess(*this, OIRE, SourceLocation(), /* Expr*/ nullptr);
 
   // C++ [conv.lval]p1:
   //   [...] If T is a non-class type, the type of the prvalue is the
@@ -727,8 +723,8 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) {
     return Res;
   E = Res.get();
 
-  // Loading a __weak object implicitly retains the value, so we need a cleanup to
-  // balance that.
+  // Loading a __weak object implicitly retains the value, so we need a cleanup
+  // to balance that.
   if (E->getType().getObjCLifetime() == Qualifiers::OCL_Weak)
     Cleanup.setExprNeedsCleanups(true);
 
@@ -937,8 +933,8 @@ ExprResult Sema::DefaultArgumentPromotion(Expr *E) {
   // potentially potentially evaluated contexts.
   if (getLangOpts().CPlusPlus && E->isGLValue() && !isUnevaluatedContext()) {
     ExprResult Temp = PerformCopyInitialization(
-                       InitializedEntity::InitializeTemporary(E->getType()),
-                                                E->getExprLoc(), E);
+        InitializedEntity::InitializeTemporary(E->getType()), E->getExprLoc(),
+        E);
     if (Temp.isInvalid())
       return ExprError();
     E = Temp.get();
@@ -1134,8 +1130,10 @@ static bool handleComplexIntegerToFloatConversion(Sema &S, ExprResult &IntExpr,
                                                   QualType IntTy,
                                                   QualType ComplexTy,
                                                   bool SkipCast) {
-  if (IntTy->isComplexType() || IntTy->isRealFloatingType()) return true;
-  if (SkipCast) return false;
+  if (IntTy->isComplexType() || IntTy->isRealFloatingType())
+    return true;
+  if (SkipCast)
+    return false;
   if (IntTy->isIntegerType()) {
     QualType fpTy = ComplexTy->castAs<ComplexType>()->getElementType();
     IntExpr = S.ImpCastExprToType(IntExpr.get(), fpTy, CK_IntegralToFloating);
@@ -1211,8 +1209,8 @@ static QualType handleIntToFloatConversion(Sema &S, ExprResult &FloatExpr,
   if (IntTy->isIntegerType()) {
     if (ConvertInt)
       // Convert intExpr to the lhs floating point type.
-      IntExpr = S.ImpCastExprToType(IntExpr.get(), FloatTy,
-                                    CK_IntegralToFloating);
+      IntExpr =
+          S.ImpCastExprToType(IntExpr.get(), FloatTy, CK_IntegralToFloating);
     return FloatTy;
   }
 
@@ -1227,17 +1225,17 @@ static QualType handleIntToFloatConversion(Sema &S, ExprResult &FloatExpr,
 
   // float -> _Complex float
   if (ConvertFloat)
-    FloatExpr = S.ImpCastExprToType(FloatExpr.get(), result,
-                                    CK_FloatingRealToComplex);
+    FloatExpr =
+        S.ImpCastExprToType(FloatExpr.get(), result, CK_FloatingRealToComplex);
 
   return result;
 }
 
 /// Handle arithmethic conversion with floating point types.  Helper
 /// function of UsualArithmeticConversions()
-static QualType handleFloatConversion(Sema &S, ExprResult &LHS,
-                                      ExprResult &RHS, QualType LHSType,
-                                      QualType RHSType, bool IsCompAssign) {
+static QualType handleFloatConversion(Sema &S, ExprResult &LHS, ExprResult &RHS,
+                                      QualType LHSType, QualType RHSType,
+                                      bool IsCompAssign) {
   bool LHSFloat = LHSType->isRealFloatingType();
   bool RHSFloat = RHSType->isRealFloatingType();
 
@@ -1274,11 +1272,11 @@ static QualType handleFloatConversion(Sema &S, ExprResult &LHS,
 
     return handleIntToFloatConversion(S, LHS, RHS, LHSType, RHSType,
                                       /*ConvertFloat=*/!IsCompAssign,
-                                      /*ConvertInt=*/ true);
+                                      /*ConvertInt=*/true);
   }
   assert(RHSFloat);
   return handleIntToFloatConversion(S, RHS, LHS, RHSType, LHSType,
-                                    /*ConvertFloat=*/ true,
+                                    /*ConvertFloat=*/true,
                                     /*ConvertInt=*/!IsCompAssign);
 }
 
@@ -1323,7 +1321,7 @@ ExprResult doComplexIntegralCast(Sema &S, Expr *op, QualType toType) {
   return S.ImpCastExprToType(op, S.Context.getComplexType(toType),
                              CK_IntegralComplexCast);
 }
-}
+} // namespace
 
 /// Handle integer arithmetic conversions.  Helper function of
 /// UsualArithmeticConversions()
@@ -1368,7 +1366,7 @@ static QualType handleIntegerConversion(Sema &S, ExprResult &LHS,
     // on most 32-bit systems).  Use the unsigned type corresponding
     // to the signed type.
     QualType result =
-      S.Context.getCorrespondingUnsignedType(LHSSigned ? LHSType : RHSType);
+        S.Context.getCorrespondingUnsignedType(LHSSigned ? LHSType : RHSType);
     RHS = (*doRHSCast)(S, RHS.get(), result);
     if (!IsCompAssign)
       LHS = (*doLHSCast)(S, LHS.get(), result);
@@ -1389,8 +1387,8 @@ static QualType handleComplexIntConversion(Sema &S, ExprResult &LHS,
     QualType LHSEltType = LHSComplexInt->getElementType();
     QualType RHSEltType = RHSComplexInt->getElementType();
     QualType ScalarType =
-      handleIntegerConversion<doComplexIntegralCast, doComplexIntegralCast>
-        (S, LHS, RHS, LHSEltType, RHSEltType, IsCompAssign);
+        handleIntegerConversion<doComplexIntegralCast, doComplexIntegralCast>(
+            S, LHS, RHS, LHSEltType, RHSEltType, IsCompAssign);
 
     return S.Context.getComplexType(ScalarType);
   }
@@ -1398,11 +1396,10 @@ static QualType handleComplexIntConversion(Sema &S, ExprResult &LHS,
   if (LHSComplexInt) {
     QualType LHSEltType = LHSComplexInt->getElementType();
     QualType ScalarType =
-      handleIntegerConversion<doComplexIntegralCast, doIntegralCast>
-        (S, LHS, RHS, LHSEltType, RHSType, IsCompAssign);
+        handleIntegerConversion<doComplexIntegralCast, doIntegralCast>(
+            S, LHS, RHS, LHSEltType, RHSType, IsCompAssign);
     QualType ComplexType = S.Context.getComplexType(ScalarType);
-    RHS = S.ImpCastExprToType(RHS.get(), ComplexType,
-                              CK_IntegralRealToComplex);
+    RHS = S.ImpCastExprToType(RHS.get(), ComplexType, CK_IntegralRealToComplex);
 
     return ComplexType;
   }
@@ -1411,13 +1408,12 @@ static QualType handleComplexIntConversion(Sema &S, ExprResult &LHS,
 
   QualType RHSEltType = RHSComplexInt->getElementType();
   QualType ScalarType =
-    handleIntegerConversion<doIntegralCast, doComplexIntegralCast>
-      (S, LHS, RHS, LHSType, RHSEltType, IsCompAssign);
+      handleIntegerConversion<doIntegralCast, doComplexIntegralCast>(
+          S, LHS, RHS, LHSType, RHSEltType, IsCompAssign);
   QualType ComplexType = S.Context.getComplexType(ScalarType);
 
   if (!IsCompAssign)
-    LHS = S.ImpCastExprToType(LHS.get(), ComplexType,
-                              CK_IntegralRealToComplex);
+    LHS = S.ImpCastExprToType(LHS.get(), ComplexType, CK_IntegralRealToComplex);
   return ComplexType;
 }
 
@@ -1788,7 +1784,6 @@ QualType Sema::UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS,
 //  Semantic Analysis for various Expression Types
 //===----------------------------------------------------------------------===//
 
-
 ExprResult Sema::ActOnGenericSelectionExpr(
     SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc,
     bool PredicateIsExpr, void *ControllingExprOrType,
@@ -1796,10 +1791,10 @@ ExprResult Sema::ActOnGenericSelectionExpr(
   unsigned NumAssocs = ArgTypes.size();
   assert(NumAssocs == ArgExprs.size());
 
-  TypeSourceInfo **Types = new TypeSourceInfo*[NumAssocs];
+  TypeSourceInfo **Types = new TypeSourceInfo *[NumAssocs];
   for (unsigned i = 0; i < NumAssocs; ++i) {
     if (ArgTypes[i])
-      (void) GetTypeFromParser(ArgTypes[i], &Types[i]);
+      (void)GetTypeFromParser(ArgTypes[i], &Types[i]);
     else
       Types[i] = nullptr;
   }
@@ -1817,7 +1812,7 @@ ExprResult Sema::ActOnGenericSelectionExpr(
   ExprResult ER = CreateGenericSelectionExpr(
       KeyLoc, DefaultLoc, RParenLoc, PredicateIsExpr, ControllingExprOrType,
       llvm::ArrayRef(Types, NumAssocs), ArgExprs);
-  delete [] Types;
+  delete[] Types;
   return ER;
 }
 
@@ -1966,19 +1961,17 @@ ExprResult Sema::CreateGenericSelectionExpr(
 
         // C11 6.5.1.1p2 "No two generic associations in the same generic
         // selection shall specify compatible types."
-        for (unsigned j = i+1; j < NumAssocs; ++j)
+        for (unsigned j = i + 1; j < NumAssocs; ++j)
           if (Types[j] && !Types[j]->getType()->isDependentType() &&
               areTypesCompatibleForGeneric(Context, Types[i]->getType(),
                                            Types[j]->getType())) {
             Diag(Types[j]->getTypeLoc().getBeginLoc(),
                  diag::err_assoc_compatible_types)
-              << Types[j]->getTypeLoc().getSourceRange()
-              << Types[j]->getType()
-              << Types[i]->getType();
-            Diag(Types[i]->getTypeLoc().getBeginLoc(),
-                 diag::note_compat_assoc)
-              << Types[i]->getTypeLoc().getSourceRange()
-              << Types[i]->getType();
+                << Types[j]->getTypeLoc().getSourceRange()
+                << Types[j]->getType() << Types[i]->getType();
+            Diag(Types[i]->getTypeLoc().getBeginLoc(), diag::note_compat_assoc)
+                << Types[i]->getTypeLoc().getSourceRange()
+                << Types[i]->getType();
             TypeErrorFound = true;
           }
       }
@@ -2047,10 +2040,8 @@ ExprResult Sema::CreateGenericSelectionExpr(
     Diag(SR.getBegin(), diag::err_generic_sel_multi_match)
         << SR << P.second << (unsigned)CompatIndices.size();
     for (unsigned I : CompatIndices) {
-      Diag(Types[I]->getTypeLoc().getBeginLoc(),
-           diag::note_compat_assoc)
-        << Types[I]->getTypeLoc().getSourceRange()
-        << Types[I]->getType();
+      Diag(Types[I]->getTypeLoc().getBeginLoc(), diag::note_compat_assoc)
+          << Types[I]->getTypeLoc().getSourceRange() << Types[I]->getType();
     }
     return ExprError();
   }
@@ -2071,8 +2062,7 @@ ExprResult Sema::CreateGenericSelectionExpr(
   // then the result expression of the generic selection is the expression
   // in that generic association. Otherwise, the result expression of the
   // generic selection is the expression in the default generic association."
-  unsigned ResultIndex =
-    CompatIndices.size() ? CompatIndices[0] : DefaultIndex;
+  unsigned ResultIndex = CompatIndices.size() ? CompatIndices[0] : DefaultIndex;
 
   if (ControllingExpr) {
     return GenericSelectionExpr::Create(
@@ -2127,7 +2117,7 @@ static SourceLocation getUDSuffixLoc(Sema &S, SourceLocation TokLoc,
 static ExprResult BuildCookedLiteralOperatorCall(Sema &S, Scope *Scope,
                                                  IdentifierInfo *UDSuffix,
                                                  SourceLocation UDSuffixLoc,
-                                                 ArrayRef<Expr*> Args,
+                                                 ArrayRef<Expr *> Args,
                                                  SourceLocation LitEndLoc) {
   assert(Args.size() <= 2 && "too many arguments for literal operator");
 
@@ -2139,7 +2129,7 @@ static ExprResult BuildCookedLiteralOperatorCall(Sema &S, Scope *Scope,
   }
 
   DeclarationName OpName =
-    S.Context.DeclarationNames.getCXXLiteralOperatorName(UDSuffix);
+      S.Context.DeclarationNames.getCXXLiteralOperatorName(UDSuffix);
   DeclarationNameInfo OpNameInfo(OpName, UDSuffixLoc);
   OpNameInfo.setCXXLiteralOperatorNameLoc(UDSuffixLoc);
 
@@ -2231,8 +2221,8 @@ Sema::ExpandFunctionLocalPredefinedMacros(ArrayRef<Token> Toks) {
   return ExpandedToks;
 }
 
-ExprResult
-Sema::ActOnStringLiteral(ArrayRef<Token> StringToks, Scope *UDLScope) {
+ExprResult Sema::ActOnStringLiteral(ArrayRef<Token> StringToks,
+                                    Scope *UDLScope) {
   assert(!StringToks.empty() && "Must have at least one string!");
 
   // StringToks needs backing storage as it doesn't hold array elements itself
@@ -2312,8 +2302,8 @@ Sema::ActOnStringLiteral(ArrayRef<Token> StringToks, Scope *UDLScope) {
   // We're building a user-defined literal.
   IdentifierInfo *UDSuffix = &Context.Idents.get(Literal.getUDSuffix());
   SourceLocation UDSuffixLoc =
-    getUDSuffixLoc(*this, StringTokLocs[Literal.getUDSuffixToken()],
-                   Literal.getUDSuffixOffset());
+      getUDSuffixLoc(*this, StringTokLocs[Literal.getUDSuffixToken()],
+                     Literal.getUDSuffixOffset());
 
   // Make sure we're allowed user-defined literals here.
   if (!UDLScope)
@@ -2324,13 +2314,11 @@ Sema::ActOnStringLiteral(ArrayRef<Token> StringToks, Scope *UDLScope) {
   QualType SizeType = Context.getSizeType();
 
   DeclarationName OpName =
-    Context.DeclarationNames.getCXXLiteralOperatorName(UDSuffix);
+      Context.DeclarationNames.getCXXLiteralOperatorName(UDSuffix);
   DeclarationNameInfo OpNameInfo(OpName, UDSuffixLoc);
   OpNameInfo.setCXXLiteralOperatorNameLoc(UDSuffixLoc);
 
-  QualType ArgTy[] = {
-    Context.getArrayDecayedType(StrTy), SizeType
-  };
+  QualType ArgTy[] = {Context.getArrayDecayedType(StrTy), SizeType};
 
   LookupResult R(*this, OpName, UDSuffixLoc, LookupOrdinaryName);
   switch (LookupLiteralOperator(UDLScope, R, ArgTy,
@@ -2340,9 +2328,9 @@ Sema::ActOnStringLiteral(ArrayRef<Token> StringToks, Scope *UDLScope) {
 
   case LOLR_Cooked: {
     llvm::APInt Len(Context.getIntWidth(SizeType), Literal.GetNumStringChars());
-    IntegerLiteral *LenArg = IntegerLiteral::Create(Context, Len, SizeType,
-                                                    StringTokLocs[0]);
-    Expr *Args[] = { Lit, LenArg };
+    IntegerLiteral *LenArg =
+        IntegerLiteral::Create(Context, Len, SizeType, StringTokLocs[0]);
+    Expr *Args[] = {Lit, LenArg};
 
     return BuildLiteralOperatorCall(R, OpNameInfo, Args, StringTokLocs.back());
   }
@@ -2364,7 +2352,8 @@ Sema::ActOnStringLiteral(ArrayRef<Token> StringToks, Scope *UDLScope) {
     llvm::APSInt Value(CharBits, CharIsUnsigned);
 
     TemplateArgument TypeArg(CharTy);
-    TemplateArgumentLocInfo TypeArgInfo(Context.getTrivialTypeSourceInfo(CharTy));
+    TemplateArgumentLocInfo TypeArgInfo(
+        Context.getTrivialTypeSourceInfo(CharTy));
     ExplicitArgs.addArgument(TemplateArgumentLoc(TypeArg, TypeArgInfo));
 
     SourceLocation Loc = StringTokLocs.back();
@@ -2385,10 +2374,9 @@ Sema::ActOnStringLiteral(ArrayRef<Token> StringToks, Scope *UDLScope) {
   llvm_unreachable("unexpected literal operator lookup result");
 }
 
-DeclRefExpr *
-Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
-                       SourceLocation Loc,
-                       const CXXScopeSpec *SS) {
+DeclRefExpr *Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
+                                    SourceLocation Loc,
+                                    const CXXScopeSpec *SS) {
   DeclarationNameInfo NameInfo(D->getDeclName(), Loc);
   return BuildDeclRefExpr(D, Ty, VK, NameInfo, SS);
 }
@@ -2519,11 +2507,10 @@ Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
   return E;
 }
 
-void
-Sema::DecomposeUnqualifiedId(const UnqualifiedId &Id,
-                             TemplateArgumentListInfo &Buffer,
-                             DeclarationNameInfo &NameInfo,
-                             const TemplateArgumentListInfo *&TemplateArgs) {
+void Sema::DecomposeUnqualifiedId(
+    const UnqualifiedId &Id, TemplateArgumentListInfo &Buffer,
+    DeclarationNameInfo &NameInfo,
+    const TemplateArgumentListInfo *&TemplateArgs) {
   if (Id.getKind() == UnqualifiedIdKind::IK_TemplateId) {
     Buffer.setLAngleLoc(Id.TemplateId->LAngleLoc);
     Buffer.setRAngleLoc(Id.TemplateId->RAngleLoc);
@@ -2680,15 +2667,14 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
                                  OverloadCandidateSet::CSK_Normal);
         OverloadCandidateSet::iterator Best;
         for (NamedDecl *CD : Corrected) {
-          if (FunctionTemplateDecl *FTD =
-                   dyn_cast<FunctionTemplateDecl>(CD))
-            AddTemplateOverloadCandidate(
-                FTD, DeclAccessPair::make(FTD, AS_none), ExplicitTemplateArgs,
-                Args, OCS);
+          if (FunctionTemplateDecl *FTD = dyn_cast<FunctionTemplateDecl>(CD))
+            AddTemplateOverloadCandidate(FTD,
+                                         DeclAccessPair::make(FTD, AS_none),
+                                         ExplicitTemplateArgs, Args, OCS);
           else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(CD))
             if (!ExplicitTemplateArgs || ExplicitTemplateArgs->size() == 0)
-              AddOverloadCandidate(FD, DeclAccessPair::make(FD, AS_none),
-                                   Args, OCS);
+              AddOverloadCandidate(FD, DeclAccessPair::make(FD, AS_none), Args,
+                                   OCS);
         }
         switch (OCS.BestViableFunction(*this, R.getNameLoc(), Best)) {
         case OR_Success:
@@ -2706,8 +2692,8 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
         CXXRecordDecl *Record =
             Corrected.getCorrectionSpecifier().getAsRecordDecl();
         if (!Record)
-          Record = cast<CXXRecordDecl>(
-              ND->getDeclContext()->getRedeclContext());
+          Record =
+              cast<CXXRecordDecl>(ND->getDeclContext()->getRedeclContext());
         R.setNamingClass(Record);
       }
 
@@ -2814,12 +2800,13 @@ recoverFromMSUnqualifiedLookup(Sema &S, ASTContext &Context,
       TemplateArgs);
 }
 
-ExprResult
-Sema::ActOnIdExpression(Scope *S, CXXScopeSpec &SS,
-                        SourceLocation TemplateKWLoc, UnqualifiedId &Id,
-                        bool HasTrailingLParen, bool IsAddressOfOperand,
-                        CorrectionCandidateCallback *CCC,
-                        bool IsInlineAsmIdentifier, Token *KeywordReplacement) {
+ExprResult Sema::ActOnIdExpression(Scope *S, CXXScopeSpec &SS,
+                                   SourceLocation TemplateKWLoc,
+                                   UnqualifiedId &Id, bool HasTrailingLParen,
+                                   bool IsAddressOfOperand,
+                                   CorrectionCandidateCallback *CCC,
+                                   bool IsInlineAsmIdentifier,
+                                   Token *KeywordReplacement) {
   assert(!(IsAddressOfOperand && HasTrailingLParen) &&
          "cannot be direct & operand and have a trailing lparen");
   if (SS.isInvalid())
@@ -2910,7 +2897,8 @@ Sema::ActOnIdExpression(Scope *S, CXXScopeSpec &SS,
   if (R.empty() && HasTrailingLParen && II &&
       getLangOpts().implicitFunctionsAllowed()) {
     NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *II, S);
-    if (D) R.addDecl(D);
+    if (D)
+      R.addDecl(D);
   }
 
   // Determine whether this name might be a candidate for
@@ -3036,7 +3024,7 @@ ExprResult Sema::BuildQualifiedDeclarationNameExpr(
       if (CD->isInvalidDecl() || CD->isBeingDefined())
         return ExprError();
     Diag(NameInfo.getLoc(), diag::err_no_member)
-      << NameInfo.getName() << DC << SS.getRange();
+        << NameInfo.getName() << DC << SS.getRange();
     return ExprError();
   }
 
@@ -3201,14 +3189,15 @@ ExprResult Sema::PerformObjectMemberConversion(Expr *From,
     // Otherwise build the appropriate casts.
     if (IsDerivedFrom(FromLoc, FromRecordType, QRecordType)) {
       CXXCastPath BasePath;
-      if (CheckDerivedToBaseConversion(FromRecordType, QRecordType,
-                                       FromLoc, FromRange, &BasePath))
+      if (CheckDerivedToBaseConversion(FromRecordType, QRecordType, FromLoc,
+                                       FromRange, &BasePath))
         return ExprError();
 
       if (PointerConversions)
         QType = Context.getPointerType(QType);
-      From = ImpCastExprToType(From, QType, CK_UncheckedDerivedToBase,
-                               VK, &BasePath).get();
+      From = ImpCastExprToType(From, QType, CK_UncheckedDerivedToBase, VK,
+                               &BasePath)
+                 .get();
 
       FromType = QType;
       FromRecordType = QRecordType;
@@ -3221,8 +3210,8 @@ ExprResult Sema::PerformObjectMemberConversion(Expr *From,
   }
 
   CXXCastPath BasePath;
-  if (CheckDerivedToBaseConversion(FromRecordType, DestRecordType,
-                                   FromLoc, FromRange, &BasePath,
+  if (CheckDerivedToBaseConversion(FromRecordType, DestRecordType, FromLoc,
+                                   FromRange, &BasePath,
                                    /*IgnoreAccess=*/true))
     return ExprError();
 
@@ -3288,7 +3277,6 @@ bool Sema::UseArgumentDependentLookup(const CXXScopeSpec &SS,
   return true;
 }
 
-
 /// Diagnoses obvious problems with the use of the given declaration
 /// as an expression.  This is only actually called for lookups that
 /// were not overloaded, and it doesn't promise that the declaration
@@ -3694,7 +3682,7 @@ ExprResult Sema::ActOnCharacterConstant(const Token &Tok, Scope *UDLScope) {
   else if (Literal.isUTF32())
     Ty = Context.Char32Ty; // U'x' -> char32_t in C11 and C++11.
   else if (!getLangOpts().CPlusPlus || Literal.isMultiChar())
-    Ty = Context.IntTy;   // 'x' -> int in C, 'wxyz' -> int in C++.
+    Ty = Context.IntTy; // 'x' -> int in C, 'wxyz' -> int in C++.
   else
     Ty = Context.CharTy; // 'x' -> char in C++;
                          // u8'x' -> char in C11-C17 and in C++ without char8_t.
@@ -3709,8 +3697,8 @@ ExprResult Sema::ActOnCharacterConstant(const Token &Tok, Scope *UDLScope) {
   else if (Literal.isUTF8())
     Kind = CharacterLiteralKind::UTF8;
 
-  Expr *Lit = new (Context) CharacterLiteral(Literal.getValue(), Kind, Ty,
-                                             Tok.getLocation());
+  Expr *Lit = new (Context)
+      CharacterLiteral(Literal.getValue(), Kind, Ty, Tok.getLocation());
 
   if (Literal.getUDSuffix().empty())
     return Lit;
@@ -3718,7 +3706,7 @@ ExprResult Sema::ActOnCharacterConstant(const Token &Tok, Scope *UDLScope) {
   // We're building a user-defined literal.
   IdentifierInfo *UDSuffix = &Context.Idents.get(Literal.getUDSuffix());
   SourceLocation UDSuffixLoc =
-    getUDSuffixLoc(*this, Tok.getLocation(), Literal.getUDSuffixOffset());
+      getUDSuffixLoc(*this, Tok.getLocation(), Literal.getUDSuffixOffset());
 
   // Make sure we're allowed user-defined literals here.
   if (!UDLScope)
@@ -3835,7 +3823,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
     // We're building a user-defined literal.
     const IdentifierInfo *UDSuffix = &Context.Idents.get(Literal.getUDSuffix());
     SourceLocation UDSuffixLoc =
-      getUDSuffixLoc(*this, Tok.getLocation(), Literal.getUDSuffixOffset());
+        getUDSuffixLoc(*this, Tok.getLocation(), Literal.getUDSuffixOffset());
 
     // Make sure we're allowed user-defined literals here.
     if (!UDLScope)
@@ -3855,7 +3843,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
     }
 
     DeclarationName OpName =
-      Context.DeclarationNames.getCXXLiteralOperatorName(UDSuffix);
+        Context.DeclarationNames.getCXXLiteralOperatorName(UDSuffix);
     DeclarationNameInfo OpNameInfo(OpName, UDSuffixLoc);
     OpNameInfo.setCXXLiteralOperatorNameLoc(UDSuffixLoc);
 
@@ -3949,7 +3937,8 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
       }
     }
 
-    if (Literal.isUnsigned) Ty = Context.getCorrespondingUnsignedType(Ty);
+    if (Literal.isUnsigned)
+      Ty = Context.getCorrespondingUnsignedType(Ty);
 
     bool isSigned = !Literal.isUnsigned;
     unsigned scale = Context.getFixedPointScale(Ty);
@@ -3973,7 +3962,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
                                               Tok.getLocation(), scale);
   } else if (Literal.isFloatingLiteral()) {
     QualType Ty;
-    if (Literal.isHalf){
+    if (Literal.isHalf) {
       if (getLangOpts().HLSL ||
           getOpenCLOptions().isAvailableOption("cl_khr_fp16", getLangOpts()))
         Ty = Context.HalfTy;
@@ -4145,7 +4134,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
         // Does it fit in a unsigned int?
         if (ResultVal.isIntN(IntSize)) {
           // Does it fit in a signed int?
-          if (!Literal.isUnsigned && ResultVal[IntSize-1] == 0)
+          if (!Literal.isUnsigned && ResultVal[IntSize - 1] == 0)
             Ty = Context.IntTy;
           else if (AllowUnsigned)
             Ty = Context.UnsignedIntTy;
@@ -4160,7 +4149,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
         // Does it fit in a unsigned long?
         if (ResultVal.isIntN(LongSize)) {
           // Does it fit in a signed long?
-          if (!Literal.isUnsigned && ResultVal[LongSize-1] == 0)
+          if (!Literal.isUnsigned && ResultVal[LongSize - 1] == 0)
             Ty = Context.LongTy;
           else if (AllowUnsigned)
             Ty = Context.UnsignedLongTy;
@@ -4193,8 +4182,9 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
           // Does it fit in a signed long long?
           // To be compatible with MSVC, hex integer literals ending with the
           // LL or i64 suffix are always signed in Microsoft mode.
-          if (!Literal.isUnsigned && (ResultVal[LongLongSize-1] == 0 ||
-              (getLangOpts().MSVCCompat && Literal.isLongLong)))
+          if (!Literal.isUnsigned &&
+              (ResultVal[LongLongSize - 1] == 0 ||
+               (getLangOpts().MSVCCompat && Literal.isLongLong)))
             Ty = Context.LongLongTy;
           else if (AllowUnsigned)
             Ty = Context.UnsignedLongLongTy;
@@ -4233,8 +4223,8 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
 
   // If this is an imaginary literal, create the ImaginaryLiteral wrapper.
   if (Literal.isImaginary) {
-    Res = new (Context) ImaginaryLiteral(Res,
-                                        Context.getComplexType(Res->getType()));
+    Res = new (Context)
+        ImaginaryLiteral(Res, Context.getComplexType(Res->getType()));
 
     // In C++, this is a GNU extension. In C, it's a C2y extension.
     unsigned DiagId;
@@ -4266,8 +4256,7 @@ static bool CheckVecStepTraitOperandType(Sema &S, QualType T,
   // Every built-in scalar type (OpenCL 1.1 6.1.1) is either an arithmetic
   // type (C99 6.2.5p18) or void.
   if (!(T->isArithmeticType() || T->isVoidType() || T->isVectorType())) {
-    S.Diag(Loc, diag::err_vecstep_non_scalar_vector_type)
-      << T << ArgRange;
+    S.Diag(Loc, diag::err_vecstep_non_scalar_vector_type) << T << ArgRange;
     return true;
   }
 
@@ -4282,8 +4271,7 @@ static bool CheckVectorElementsTraitOperandType(Sema &S, QualType T,
   // builtin_vectorelements supports both fixed-sized and scalable vectors.
   if (!T->isVectorType() && !T->isSizelessVectorType())
     return S.Diag(Loc, diag::err_builtin_non_vector_type)
-           << ""
-           << "__builtin_vectorelements" << T << ArgRange;
+           << "" << "__builtin_vectorelements" << T << ArgRange;
 
   if (auto *FD = dyn_cast<FunctionDecl>(S.CurContext)) {
     if (T->isSVESizelessBuiltinType()) {
@@ -4350,8 +4338,7 @@ static bool CheckObjCTraitOperandConstraints(Sema &S, QualType T,
   // runtime doesn't allow it.
   if (!S.LangOpts.ObjCRuntime.allowsSizeofAlignof() && T->isObjCObjectType()) {
     S.Diag(Loc, diag::err_sizeof_nonfragile_interface)
-      << T << (TraitKind == UETT_SizeOf)
-      << ArgRange;
+        << T << (TraitKind == UETT_SizeOf) << ArgRange;
     return true;
   }
 
@@ -4371,9 +4358,9 @@ static void warnOnSizeofOnArrayDecay(Sema &S, SourceLocation Loc, QualType T,
   if (!ICE || ICE->getCastKind() != CK_ArrayToPointerDecay)
     return;
 
-  S.Diag(Loc, diag::warn_sizeof_array_decay) << ICE->getSourceRange()
-                                             << ICE->getType()
-                                             << ICE->getSubExpr()->getType();
+  S.Diag(Loc, diag::warn_sizeof_array_decay)
+      << ICE->getSourceRange() << ICE->getType()
+      << ICE->getSubExpr()->getType();
 }
 
 bool Sema::CheckUnaryExprOrTypeTraitOperand(Expr *E,
@@ -4398,8 +4385,7 @@ bool Sema::CheckUnaryExprOrTypeTraitOperand(Expr *E,
   // used to build SFINAE gadgets.
   // FIXME: Should we consider instantiation-dependent operands to 'alignof'?
   if (IsUnevaluatedOperand && !inTemplateInstantiation() &&
-      !E->isInstantiationDependent() &&
-      !E->getType()->isVariableArrayType() &&
+      !E->isInstantiationDependent() && !E->getType()->isVariableArrayType() &&
       E->HasSideEffects(Context, false))
     Diag(E->getExprLoc(), diag::warn_side_effects_unevaluated_context);
 
@@ -4477,8 +4463,7 @@ bool Sema::CheckUnaryExprOrTypeTraitOperand(Expr *E,
         QualType OType = PVD->getOriginalType();
         QualType Type = PVD->getType();
         if (Type->isPointerType() && OType->isArrayType()) {
-          Diag(E->getExprLoc(), diag::warn_sizeof_array_param)
-            << Type << OType;
+          Diag(E->getExprLoc(), diag::warn_sizeof_array_param) << Type << OType;
           Diag(PVD->getLocation(), diag::note_declared_at);
         }
       }
@@ -4505,7 +4490,7 @@ static bool CheckAlignOfExpr(Sema &S, Expr *E, UnaryExprOrTypeTrait ExprKind) {
 
   if (E->getObjectKind() == OK_BitField) {
     S.Diag(E->getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield)
-       << 1 << E->getSourceRange();
+        << 1 << E->getSourceRange();
     return true;
   }
 
@@ -4539,7 +4524,7 @@ static bool CheckAlignOfExpr(Sema &S, Expr *E, UnaryExprOrTypeTrait ExprKind) {
     // definition if we can find a member of it.
     if (!FD->getParent()->isCompleteDefinition()) {
       S.Diag(E->getExprLoc(), diag::err_alignof_member_of_incomplete_type)
-        << E->getSourceRange();
+          << E->getSourceRange();
       return true;
     }
 
@@ -4823,9 +4808,8 @@ ExprResult Sema::CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo,
       ExprKind, TInfo, Context.getSizeType(), OpLoc, R.getEnd());
 }
 
-ExprResult
-Sema::CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
-                                     UnaryExprOrTypeTrait ExprKind) {
+ExprResult Sema::CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
+                                                UnaryExprOrTypeTrait ExprKind) {
   ExprResult PE = CheckPlaceholderExpr(E);
   if (PE.isInvalid())
     return ExprError();
@@ -4841,9 +4825,9 @@ Sema::CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
   } else if (ExprKind == UETT_VecStep) {
     isInvalid = CheckVecStepExpr(E);
   } else if (ExprKind == UETT_OpenMPRequiredSimdAlign) {
-      Diag(E->getExprLoc(), diag::err_openmp_default_simd_align_expr);
-      isInvalid = true;
-  } else if (E->refersToBitField()) {  // C99 6.5.3.4p1.
+    Diag(E->getExprLoc(), diag::err_openmp_default_simd_align_expr);
+    isInvalid = true;
+  } else if (E->refersToBitField()) { // C99 6.5.3.4p1.
     Diag(E->getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 0;
     isInvalid = true;
   } else if (ExprKind == UETT_VectorElements || ExprKind == UETT_SizeOf ||
@@ -4857,7 +4841,8 @@ Sema::CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
   if ((ExprKind == UETT_SizeOf || ExprKind == UETT_CountOf) &&
       E->getType()->isVariableArrayType()) {
     PE = TransformToPotentiallyEvaluated(E);
-    if (PE.isInvalid()) return ExprError();
+    if (PE.isInvalid())
+      return ExprError();
     E = PE.get();
   }
 
@@ -4866,16 +4851,17 @@ Sema::CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
       ExprKind, E, Context.getSizeType(), OpLoc, E->getSourceRange().getEnd());
 }
 
-ExprResult
-Sema::ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc,
-                                    UnaryExprOrTypeTrait ExprKind, bool IsType,
-                                    void *TyOrEx, SourceRange ArgRange) {
+ExprResult Sema::ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc,
+                                               UnaryExprOrTypeTrait ExprKind,
+                                               bool IsType, void *TyOrEx,
+                                               SourceRange ArgRange) {
   // If error parsing type, ignore.
-  if (!TyOrEx) return ExprError();
+  if (!TyOrEx)
+    return ExprError();
 
   if (IsType) {
     TypeSourceInfo *TInfo;
-    (void) GetTypeFromParser(ParsedType::getFromOpaquePtr(TyOrEx), &TInfo);
+    (void)GetTypeFromParser(ParsedType::getFromOpaquePtr(TyOrEx), &TInfo);
     return CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, ArgRange);
   }
 
@@ -4922,33 +4908,37 @@ static QualType CheckRealImagOperand(Sema &S, ExprResult &V, SourceLocation Loc,
 
   // Test for placeholders.
   ExprResult PR = S.CheckPlaceholderExpr(V.get());
-  if (PR.isInvalid()) return QualType();
+  if (PR.isInvalid())
+    return QualType();
   if (PR.get() != V.get()) {
     V = PR;
     return CheckRealImagOperand(S, V, Loc, IsReal);
   }
 
   // Reject anything else.
-  S.Diag(Loc, diag::err_realimag_invalid_type) << V.get()->getType()
-    << (IsReal ? "__real" : "__imag");
+  S.Diag(Loc, diag::err_realimag_invalid_type)
+      << V.get()->getType() << (IsReal ? "__real" : "__imag");
   return QualType();
 }
 
-
-
-ExprResult
-Sema::ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
-                          tok::TokenKind Kind, Expr *Input) {
+ExprResult Sema::ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
+                                     tok::TokenKind Kind, Expr *Input) {
   UnaryOperatorKind Opc;
   switch (Kind) {
-  default: llvm_unreachable("Unknown unary op!");
-  case tok::plusplus:   Opc = UO_PostInc; break;
-  case tok::minusminus: Opc = UO_PostDec; break;
+  default:
+    llvm_unreachable("Unknown unary op!");
+  case tok::plusplus:
+    Opc = UO_PostInc;
+    break;
+  case tok::minusminus:
+    Opc = UO_PostDec;
+    break;
   }
 
   // Since this might is a postfix expression, get rid of ParenListExprs.
   ExprResult Result = MaybeConvertParenListExprToParenExpr(S, Input);
-  if (Result.isInvalid()) return ExprError();
+  if (Result.isInvalid())
+    return ExprError();
   Input = Result.get();
 
   return BuildUnaryOp(S, OpLoc, Opc, Input);
@@ -4957,8 +4947,7 @@ Sema::ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
 /// Diagnose if arithmetic on the given ObjC pointer is illegal.
 ///
 /// \return true on error
-static bool checkArithmeticOnObjCPointer(Sema &S,
-                                         SourceLocation opLoc,
+static bool checkArithmeticOnObjCPointer(Sema &S, SourceLocation opLoc,
                                          Expr *op) {
   assert(op->getType()->isObjCObjectPointerType());
   if (S.LangOpts.ObjCRuntime.allowsPointerArithmetic() &&
@@ -4966,8 +4955,8 @@ static bool checkArithmeticOnObjCPointer(Sema &S,
     return false;
 
   S.Diag(opLoc, diag::err_arithmetic_nonfragile_interface)
-    << op->getType()->castAs<ObjCObjectPointerType>()->getPointeeType()
-    << op->getSourceRange();
+      << op->getType()->castAs<ObjCObjectPointerType>()->getPointeeType()
+      << op->getSourceRange();
   return true;
 }
 
@@ -5375,9 +5364,9 @@ void Sema::CheckSubscriptAccessOfNoDeref(const ArraySubscriptExpr *E) {
   }
 }
 
-ExprResult
-Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
-                                      Expr *Idx, SourceLocation RLoc) {
+ExprResult Sema::CreateBuiltinArraySubscriptExpr(Expr *Base,
+                                                 SourceLocation LLoc, Expr *Idx,
+                                                 SourceLocation RLoc) {
   Expr *LHSExp = Base;
   Expr *RHSExp = Idx;
 
@@ -5424,7 +5413,7 @@ Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
     IndexExpr = RHSExp;
     ResultType = PTy->getPointeeType();
   } else if (const ObjCObjectPointerType *PTy =
-               LHSTy->getAs<ObjCObjectPointerType>()) {
+                 LHSTy->getAs<ObjCObjectPointerType>()) {
     BaseExpr = LHSExp;
     IndexExpr = RHSExp;
 
@@ -5436,19 +5425,19 @@ Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
 
     ResultType = PTy->getPointeeType();
   } else if (const PointerType *PTy = RHSTy->getAs<PointerType>()) {
-     // Handle the uncommon case of "123[Ptr]".
+    // Handle the uncommon case of "123[Ptr]".
     BaseExpr = RHSExp;
     IndexExpr = LHSExp;
     ResultType = PTy->getPointeeType();
   } else if (const ObjCObjectPointerType *PTy =
-               RHSTy->getAs<ObjCObjectPointerType>()) {
-     // Handle the uncommon case of "123[Ptr]".
+                 RHSTy->getAs<ObjCObjectPointerType>()) {
+    // Handle the uncommon case of "123[Ptr]".
     BaseExpr = RHSExp;
     IndexExpr = LHSExp;
     ResultType = PTy->getPointeeType();
     if (!LangOpts.isSubscriptPointerArithmetic()) {
       Diag(LLoc, diag::err_subscript_nonfragile_interface)
-        << ResultType << BaseExpr->getSourceRange();
+          << ResultType << BaseExpr->getSourceRange();
       return ExprError();
     }
   } else if (LHSTy->isSubscriptableVectorType()) {
@@ -5492,7 +5481,8 @@ Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
     Diag(LHSExp->getBeginLoc(), diag::ext_subscript_non_lvalue)
         << LHSExp->getSourceRange();
     LHSExp = ImpCastExprToType(LHSExp, Context.getArrayDecayedType(LHSTy),
-                               CK_ArrayToPointerDecay).get();
+                               CK_ArrayToPointerDecay)
+                 .get();
     LHSTy = LHSExp->getType();
 
     BaseExpr = LHSExp;
@@ -5503,7 +5493,8 @@ Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
     Diag(RHSExp->getBeginLoc(), diag::ext_subscript_non_lvalue)
         << RHSExp->getSourceRange();
     RHSExp = ImpCastExprToType(RHSExp, Context.getArrayDecayedType(RHSTy),
-                               CK_ArrayToPointerDecay).get();
+                               CK_ArrayToPointerDecay)
+                 .get();
     RHSTy = RHSExp->getType();
 
     BaseExpr = RHSExp;
@@ -5511,7 +5502,7 @@ Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
     ResultType = RHSTy->castAs<PointerType>()->getPointeeType();
   } else {
     return ExprError(Diag(LLoc, diag::err_typecheck_subscript_value)
-       << LHSExp->getSourceRange() << RHSExp->getSourceRange());
+                     << LHSExp->getSourceRange() << RHSExp->getSourceRange());
   }
   // C99 6.5.2.1p1
   if (!IndexExpr->getType()->isIntegerType() && !IndexExpr->isTypeDependent())
@@ -5540,8 +5531,7 @@ Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
 
   if (ResultType->isVoidType() && !getLangOpts().CPlusPlus) {
     // GNU extension: subscripting on pointer to void
-    Diag(LLoc, diag::ext_gnu_subscript_void_type)
-      << BaseExpr->getSourceRange();
+    Diag(LLoc, diag::ext_gnu_subscript_void_type) << BaseExpr->getSourceRange();
 
     // C forbids expressions of unqualified void type from being l-values.
     // See IsCForbiddenLValueType.
@@ -6008,7 +5998,7 @@ class FunctionCallCCC final : public FunctionCallFilterCCC {
 private:
   const IdentifierInfo *const FunctionName;
 };
-}
+} // namespace
 
 static TypoCorrection TryTypoCorrectionForCall(Sema &S, Expr *Fn,
                                                FunctionDecl *FDecl,
@@ -6068,13 +6058,12 @@ static bool isParenthetizedAndQualifiedAddressOfExpr(Expr *Fn) {
   return false;
 }
 
-bool
-Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
-                              FunctionDecl *FDecl,
-                              const FunctionProtoType *Proto,
-                              ArrayRef<Expr *> Args,
-                              SourceLocation RParenLoc,
-                              bool IsExecConfig) {
+bool Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
+                                   FunctionDecl *FDecl,
+                                   const FunctionProtoType *Proto,
+                                   ArrayRef<Expr *> Args,
+                                   SourceLocation RParenLoc,
+                                   bool IsExecConfig) {
   // Bail out early if calling a builtin with custom typechecking.
   if (FDecl)
     if (unsigned ID = FDecl->getBuiltinID())
@@ -6092,9 +6081,9 @@ Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
   bool Invalid = false;
   unsigned MinArgs = FDecl ? FDecl->getMinRequiredArguments() : NumParams;
   unsigned FnKind = Fn->getType()->isBlockPointerType()
-                       ? 1 /* block */
-                       : (IsExecConfig ? 3 /* kernel function (exec config) */
-                                       : 0 /* function */);
+                        ? 1                 /* block */
+                        : (IsExecConfig ? 3 /* kernel function (exec config) */
+                                        : 0 /* function */);
 
   // If too few arguments are available (and we don't have default
   // arguments for the remaining parameters), don't make the call.
@@ -6233,12 +6222,12 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl,
 
       // Strip the unbridged-cast placeholder expression off, if applicable.
       bool CFAudited = false;
-      if (Arg->getType() == Context.ARCUnbridgedCastTy &&
-          FDecl && FDecl->hasAttr<CFAuditedTransferAttr>() &&
+      if (Arg->getType() == Context.ARCUnbridgedCastTy && FDecl &&
+          FDecl->hasAttr<CFAuditedTransferAttr>() &&
           (!Param || !Param->hasAttr<CFConsumedAttr>()))
         Arg = ObjC().stripARCUnbridgedCast(Arg);
-      else if (getLangOpts().ObjCAutoRefCount &&
-               FDecl && FDecl->hasAttr<CFAuditedTransferAttr>() &&
+      else if (getLangOpts().ObjCAutoRefCount && FDecl &&
+               FDecl->hasAttr<CFAuditedTransferAttr>() &&
                (!Param || !Param->hasAttr<CFConsumedAttr>()))
         CFAudited = true;
 
@@ -6316,7 +6305,7 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl,
         AllArgs.push_back(arg.get());
       }
 
-    // Otherwise do argument promotion, (C99 6.5.2.2p7).
+      // Otherwise do argument promotion, (C99 6.5.2.2p7).
     } else {
       for (Expr *A : Args.slice(ArgIx)) {
         ExprResult Arg = DefaultVariadicArgumentPromotion(A, CallType, FDecl);
@@ -6338,13 +6327,11 @@ static void DiagnoseCalleeStaticArrayParam(Sema &S, ParmVarDecl *PVD) {
     TL = DTL.getOriginalLoc();
   if (ArrayTypeLoc ATL = TL.getAs<ArrayTypeLoc>())
     S.Diag(PVD->getLocation(), diag::note_callee_static_array)
-      << ATL.getLocalSourceRange();
+        << ATL.getLocalSourceRange();
 }
 
-void
-Sema::CheckStaticArrayArgument(SourceLocation CallLoc,
-                               ParmVarDecl *Param,
-                               const Expr *ArgExpr) {
+void Sema::CheckStaticArrayArgument(SourceLocation CallLoc, ParmVarDecl *Param,
+                                    const Expr *ArgExpr) {
   // Static array parameters are not supported in C++.
   if (!Param || getLangOpts().CPlusPlus)
     return;
@@ -6355,8 +6342,7 @@ Sema::CheckStaticArrayArgument(SourceLocation CallLoc,
   if (!AT || AT->getSizeModifier() != ArraySizeModifier::Static)
     return;
 
-  if (ArgExpr->isNullPointerConstant(Context,
-                                     Expr::NPC_NeverValueDependent)) {
+  if (ArgExpr->isNullPointerConstant(Context, Expr::NPC_NeverValueDependent)) {
     Diag(CallLoc, diag::warn_null_arg) << ArgExpr->getSourceRange();
     DiagnoseCalleeStaticArrayParam(*this, Param);
     return;
@@ -6367,7 +6353,7 @@ Sema::CheckStaticArrayArgument(SourceLocation CallLoc,
     return;
 
   const ConstantArrayType *ArgCAT =
-    Context.getAsConstantArrayType(ArgExpr->IgnoreParenCasts()->getType());
+      Context.getAsConstantArrayType(ArgExpr->IgnoreParenCasts()->getType());
   if (!ArgCAT)
     return;
 
@@ -6403,23 +6389,21 @@ static ExprResult rebuildUnknownAnyFunction(Sema &S, Expr *fn);
 static bool isPlaceholderToRemoveAsArg(QualType type) {
   // Placeholders are never sugared.
   const BuiltinType *placeholder = dyn_cast<BuiltinType>(type);
-  if (!placeholder) return false;
+  if (!placeholder)
+    return false;
 
   switch (placeholder->getKind()) {
-  // Ignore all the non-placeholder types.
-#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
+    // Ignore all the non-placeholder types.
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)                   \
   case BuiltinType::Id:
 #include "clang/Basic/OpenCLImageTypes.def"
-#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
-  case BuiltinType::Id:
+#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) case BuiltinType::Id:
 #include "clang/Basic/OpenCLExtensionTypes.def"
-  // In practice we'll never use this, since all SVE types are sugared
-  // via TypedefTypes rather than exposed directly as BuiltinTypes.
-#define SVE_TYPE(Name, Id, SingletonId) \
-  case BuiltinType::Id:
+    // In practice we'll never use this, since all SVE types are sugared
+    // via TypedefTypes rather than exposed directly as BuiltinTypes.
+#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
 #include "clang/Basic/AArch64ACLETypes.def"
-#define PPC_VECTOR_TYPE(Name, Id, Size) \
-  case BuiltinType::Id:
+#define PPC_VECTOR_TYPE(Name, Id, Size) case BuiltinType::Id:
 #include "clang/Basic/PPCTypes.def"
 #define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
 #include "clang/Basic/RISCVVTypes.def"
@@ -6462,7 +6446,6 @@ static bool isPlaceholderToRemoveAsArg(QualType type) {
   case BuiltinType::OMPArrayShaping:
   case BuiltinType::OMPIterator:
     return true;
-
   }
   llvm_unreachable("bad builtin type kind");
 }
@@ -6474,8 +6457,10 @@ bool Sema::CheckArgsForPlaceholders(MultiExprArg args) {
   for (size_t i = 0, e = args.size(); i != e; i++) {
     if (isPlaceholderToRemoveAsArg(args[i]->getType())) {
       ExprResult result = CheckPlaceholderExpr(args[i]);
-      if (result.isInvalid()) hasInvalid = true;
-      else args[i] = result.get();
+      if (result.isInvalid())
+        hasInvalid = true;
+      else
+        args[i] = result.get();
     }
   }
   return hasInvalid;
@@ -6546,8 +6531,8 @@ static FunctionDecl *rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context,
 
   FunctionProtoType::ExtProtoInfo EPI;
   EPI.Variadic = FT->isVariadic();
-  QualType OverloadTy = Context.getFunctionType(FT->getReturnType(),
-                                                OverloadParams, EPI);
+  QualType OverloadTy =
+      Context.getFunctionType(FT->getReturnType(), OverloadParams, EPI);
   DeclContext *Parent = FDecl->getParent();
   FunctionDecl *OverloadDecl = FunctionDecl::Create(
       Context, Parent, FDecl->getLocation(), FDecl->getLocation(),
@@ -6555,14 +6540,14 @@ static FunctionDecl *rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context,
       /*TInfo=*/nullptr, SC_Extern, Sema->getCurFPFeatures().isFPConstrained(),
       false,
       /*hasPrototype=*/true);
-  SmallVector<ParmVarDecl*, 16> Params;
+  SmallVector<ParmVarDecl *, 16> Params;
   FT = cast<FunctionProtoType>(OverloadTy);
   for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
     QualType ParamType = FT->getParamType(i);
     ParmVarDecl *Parm =
         ParmVarDecl::Create(Context, OverloadDecl, SourceLocation(),
-                                SourceLocation(), nullptr, ParamType,
-                                /*TInfo=*/nullptr, SC_None, nullptr);
+                            SourceLocation(), nullptr, ParamType,
+                            /*TInfo=*/nullptr, SC_None, nullptr);
     Parm->setScopeInfo(0, i);
     Params.push_back(Parm);
   }
@@ -6668,7 +6653,6 @@ tryImplicitlyCaptureThisIfImplicitMemberFunctionAccessWithDependentArgs(
   if (!enclosingClassIsRelatedToClassInWhichMembersWereFound(UME, S))
     return;
 
-
   DeclContext *EnclosingFunctionCtx = S.CurContext->getParent()->getParent();
   // If the enclosing function is not dependent, then this lambda is
   // capture ready, so if we can capture this, do so.
@@ -6777,7 +6761,8 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc,
                                bool AllowRecovery) {
   // Since this might be a postfix expression, get rid of ParenListExprs.
   ExprResult Result = MaybeConvertParenListExprToParenExpr(Scope, Fn);
-  if (Result.isInvalid()) return ExprError();
+  if (Result.isInvalid())
+    return ExprError();
   Fn = Result.get();
 
   // The __builtin_amdgcn_is_invocable builtin is special, and will be resolved
@@ -6822,7 +6807,8 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc,
     }
     if (Fn->getType() == Context.PseudoObjectTy) {
       ExprResult result = CheckPlaceholderExpr(Fn);
-      if (result.isInvalid()) return ExprError();
+      if (result.isInvalid())
+        return ExprError();
       Fn = result.get();
     }
 
@@ -6860,7 +6846,8 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc,
 
     if (Fn->getType() == Context.UnknownAnyTy) {
       ExprResult result = rebuildUnknownAnyFunction(*this, Fn);
-      if (result.isInvalid()) return ExprError();
+      if (result.isInvalid())
+        return ExprError();
       Fn = result.get();
     }
 
@@ -6894,7 +6881,8 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc,
   // If we're directly calling a function, get the appropriate declaration.
   if (Fn->getType() == Context.UnknownAnyTy) {
     ExprResult result = rebuildUnknownAnyFunction(*this, Fn);
-    if (result.isInvalid()) return ExprError();
+    if (result.isInvalid())
+      return ExprError();
     Fn = result.get();
   }
 
@@ -6953,7 +6941,7 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc,
     // type.
     if (getLangOpts().HIP && FD && FD->getBuiltinID()) {
       for (unsigned Idx = 0; Idx < ArgExprs.size() && Idx < FD->param_size();
-          ++Idx) {
+           ++Idx) {
         ParmVarDecl *Param = FD->getParamDecl(Idx);
         if (!ArgExprs[Idx] || !Param || !Param->getType()->isPointerType() ||
             !ArgExprs[Idx]->getType()->isPointerType())
@@ -6966,10 +6954,14 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc,
 
         // Add address space cast if target address spaces are different
         bool NeedImplicitASC =
-          ParamAS != LangAS::Default &&       // Pointer params in generic AS don't need special handling.
-          ( ArgAS == LangAS::Default  ||      // We do allow implicit conversion from generic AS
-                                              // or from specific AS which has target AS matching that of Param.
-          getASTContext().getTargetAddressSpace(ArgAS) == getASTContext().getTargetAddressSpace(ParamAS));
+            ParamAS != LangAS::Default && // Pointer params in generic AS don't
+                                          // need special handling.
+            (ArgAS ==
+                 LangAS::Default || // We do allow implicit conversion from
+                                    // generic AS or from specific AS which has
+                                    // target AS matching that of Param.
+             getASTContext().getTargetAddressSpace(ArgAS) ==
+                 getASTContext().getTargetAddressSpace(ParamAS));
         if (!NeedImplicitASC)
           continue;
 
@@ -6986,9 +6978,8 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc,
         ArgPtQuals.setAddressSpace(ParamAS);
         auto NewArgPtTy =
             Context.getQualifiedType(ArgPtTy.getUnqualifiedType(), ArgPtQuals);
-        auto NewArgTy =
-            Context.getQualifiedType(Context.getPointerType(NewArgPtTy),
-                                     ArgTy.getQualifiers());
+        auto NewArgTy = Context.getQualifiedType(
+            Context.getPointerType(NewArgPtTy), ArgTy.getQualifiers());
 
         // Finally perform an implicit address space cast
         ArgExprs[Idx] = ImpCastExprToType(ArgExprs[Idx], NewArgTy,
@@ -7215,7 +7206,8 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
     if (Config) {
       // CUDA: Kernel calls must be to global functions
       if (FDecl && !FDecl->hasAttr<CUDAGlobalAttr>())
-        return ExprError(Diag(LParenLoc,diag::err_kern_call_not_global_function)
+        return ExprError(
+            Diag(LParenLoc, diag::err_kern_call_not_global_function)
             << FDecl << Fn->getSourceRange());
 
       // CUDA: Kernel function must have 'void' return type
@@ -7223,12 +7215,12 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
           !FuncT->getReturnType()->getAs<AutoType>() &&
           !FuncT->getReturnType()->isInstantiationDependentType())
         return ExprError(Diag(LParenLoc, diag::err_kern_type_not_void_return)
-            << Fn->getType() << Fn->getSourceRange());
+                         << Fn->getType() << Fn->getSourceRange());
     } else {
       // CUDA: Calls to global functions must be configured
       if (FDecl && FDecl->hasAttr<CUDAGlobalAttr>())
         return ExprError(Diag(LParenLoc, diag::err_global_call_not_config)
-            << FDecl << Fn->getSourceRange());
+                         << FDecl << Fn->getSourceRange());
     }
   }
 
@@ -7264,9 +7256,11 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
       const FunctionDecl *Def = nullptr;
       if (FDecl->hasBody(Def) && Args.size() != Def->param_size()) {
         Proto = Def->getType()->getAs<FunctionProtoType>();
-       if (!Proto || !(Proto->isVariadic() && Args.size() >= Def->param_size()))
+        if (!Proto ||
+            !(Proto->isVariadic() && Args.size() >= Def->param_size()))
           Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments)
-          << (Args.size() > Def->param_size()) << FDecl << Fn->getSourceRange();
+              << (Args.size() > Def->param_size()) << FDecl
+              << Fn->getSourceRange();
       }
 
       // If the function we're calling isn't a function prototype, but we have
@@ -7365,9 +7359,9 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
   return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall), FDecl);
 }
 
-ExprResult
-Sema::ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty,
-                           SourceLocation RParenLoc, Expr *InitExpr) {
+ExprResult Sema::ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty,
+                                      SourceLocation RParenLoc,
+                                      Expr *InitExpr) {
   assert(Ty && "ActOnCompoundLiteral(): missing type");
   assert(InitExpr && "ActOnCompoundLiteral(): missing expression");
 
@@ -7379,9 +7373,10 @@ Sema::ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty,
   return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, InitExpr);
 }
 
-ExprResult
-Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo,
-                               SourceLocation RParenLoc, Expr *LiteralExpr) {
+ExprResult Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc,
+                                          TypeSourceInfo *TInfo,
+                                          SourceLocation RParenLoc,
+                                          Expr *LiteralExpr) {
   QualType literalType = TInfo->getType();
 
   if (literalType->isArrayType()) {
@@ -7417,20 +7412,21 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo,
         return ExprError();
     }
   } else if (!literalType->isDependentType() &&
-             RequireCompleteType(LParenLoc, literalType,
-               diag::err_typecheck_decl_incomplete_type,
-               SourceRange(LParenLoc, LiteralExpr->getSourceRange().getEnd())))
+             RequireCompleteType(
+                 LParenLoc, literalType,
+                 diag::err_typecheck_decl_incomplete_type,
+                 SourceRange(LParenLoc,
+                             LiteralExpr->getSourceRange().getEnd())))
     return ExprError();
 
-  InitializedEntity Entity
-    = InitializedEntity::InitializeCompoundLiteralInit(TInfo);
-  InitializationKind Kind
-    = InitializationKind::CreateCStyleCast(LParenLoc,
-                                           SourceRange(LParenLoc, RParenLoc),
-                                           /*InitList=*/true);
+  InitializedEntity Entity =
+      InitializedEntity::InitializeCompoundLiteralInit(TInfo);
+  InitializationKind Kind = InitializationKind::CreateCStyleCast(
+      LParenLoc, SourceRange(LParenLoc, RParenLoc),
+      /*InitList=*/true);
   InitializationSequence InitSeq(*this, Entity, Kind, LiteralExpr);
-  ExprResult Result = InitSeq.Perform(*this, Entity, Kind, LiteralExpr,
-                                      &literalType);
+  ExprResult Result =
+      InitSeq.Perform(*this, Entity, Kind, LiteralExpr, &literalType);
   if (Result.isInvalid())
     return ExprError();
   LiteralExpr = Result.get();
@@ -7487,8 +7483,7 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo,
   auto *E = new (Context) CompoundLiteralExpr(LParenLoc, TInfo, literalType, VK,
                                               LiteralExpr, IsFileScope);
   if (IsFileScope) {
-    if (!LiteralExpr->isTypeDependent() &&
-        !LiteralExpr->isValueDependent() &&
+    if (!LiteralExpr->isTypeDependent() && !LiteralExpr->isValueDependent() &&
         !literalType->isDependentType()) // C99 6.5.2.5p3
       if (CheckForConstantInitializer(LiteralExpr))
         return ExprError();
@@ -7498,7 +7493,7 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo,
     //   "If the compound literal occurs inside the body of a function, the
     //   type name shall not be qualified by an address-space qualifier."
     Diag(LParenLoc, diag::err_compound_literal_with_address_space)
-      << SourceRange(LParenLoc, LiteralExpr->getSourceRange().getEnd());
+        << SourceRange(LParenLoc, LiteralExpr->getSourceRange().getEnd());
     return ExprError();
   }
 
@@ -7529,9 +7524,9 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo,
   return MaybeBindToTemporary(E);
 }
 
-ExprResult
-Sema::ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
-                    SourceLocation RBraceLoc) {
+ExprResult Sema::ActOnInitList(SourceLocation LBraceLoc,
+                               MultiExprArg InitArgList,
+                               SourceLocation RBraceLoc) {
   // Only produce each kind of designated initialization diagnostic once.
   SourceLocation FirstDesignator;
   bool DiagnosedArrayDesignator = false;
@@ -7551,14 +7546,14 @@ Sema::ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
       if (!DiagnosedNestedDesignator && DIE->size() > 1) {
         DiagnosedNestedDesignator = true;
         Diag(DIE->getBeginLoc(), diag::ext_designated_init_nested)
-          << DIE->getDesignatorsSourceRange();
+            << DIE->getDesignatorsSourceRange();
       }
 
       for (auto &Desig : DIE->designators()) {
         if (!Desig.isFieldDesignator() && !DiagnosedArrayDesignator) {
           DiagnosedArrayDesignator = true;
           Diag(Desig.getBeginLoc(), diag::ext_designated_init_array)
-            << Desig.getSourceRange();
+              << Desig.getSourceRange();
         }
       }
 
@@ -7566,18 +7561,18 @@ Sema::ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
           !isa<DesignatedInitExpr>(InitArgList[0])) {
         DiagnosedMixedDesignator = true;
         Diag(DIE->getBeginLoc(), diag::ext_designated_init_mixed)
-          << DIE->getSourceRange();
+            << DIE->getSourceRange();
         Diag(InitArgList[0]->getBeginLoc(), diag::note_designated_init_mixed)
-          << InitArgList[0]->getSourceRange();
+            << InitArgList[0]->getSourceRange();
       }
     } else if (getLangOpts().CPlusPlus && !DiagnosedMixedDesignator &&
                isa<DesignatedInitExpr>(InitArgList[0])) {
       DiagnosedMixedDesignator = true;
       auto *DIE = cast<DesignatedInitExpr>(InitArgList[0]);
       Diag(DIE->getBeginLoc(), diag::ext_designated_init_mixed)
-        << DIE->getSourceRange();
+          << DIE->getSourceRange();
       Diag(InitArgList[I]->getBeginLoc(), diag::note_designated_init_mixed)
-        << InitArgList[I]->getSourceRange();
+          << InitArgList[I]->getSourceRange();
     }
   }
 
@@ -7597,9 +7592,9 @@ Sema::ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
   return BuildInitList(LBraceLoc, InitArgList, RBraceLoc);
 }
 
-ExprResult
-Sema::BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
-                    SourceLocation RBraceLoc) {
+ExprResult Sema::BuildInitList(SourceLocation LBraceLoc,
+                               MultiExprArg InitArgList,
+                               SourceLocation RBraceLoc) {
   // Semantic analysis for initializers is done by ActOnDeclarator() and
   // CheckInitializer() - it requires knowledge of the object being initialized.
 
@@ -7611,7 +7606,8 @@ Sema::BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
 
       // Ignore failures; dropping the entire initializer list because
       // of one failure would be terrible for indexing/etc.
-      if (result.isInvalid()) continue;
+      if (result.isInvalid())
+        continue;
 
       InitArgList[I] = result.get();
     }
@@ -7628,7 +7624,8 @@ void Sema::maybeExtendBlockObject(ExprResult &E) {
   assert(E.get()->isPRValue());
 
   // Only do this in an r-value context.
-  if (!getLangOpts().ObjCAutoRefCount) return;
+  if (!getLangOpts().ObjCAutoRefCount)
+    return;
 
   E = ImplicitCastExpr::Create(
       Context, E.get()->getType(), CK_ARCExtendBlockObject, E.get(),
@@ -7664,7 +7661,8 @@ CastKind Sema::PrepareScalarCast(ExprResult &Src, QualType DestTy) {
     }
     case Type::STK_BlockPointer:
       return (SrcKind == Type::STK_BlockPointer
-                ? CK_BitCast : CK_AnyPointerToBlockPointerCast);
+                  ? CK_BitCast
+                  : CK_AnyPointerToBlockPointerCast);
     case Type::STK_ObjCObjectPointer:
       if (SrcKind == Type::STK_ObjCObjectPointer)
         return CK_BitCast;
@@ -7727,13 +7725,13 @@ CastKind Sema::PrepareScalarCast(ExprResult &Src, QualType DestTy) {
       return CK_IntegralToFloating;
     case Type::STK_IntegralComplex:
       Src = ImpCastExprToType(Src.get(),
-                      DestTy->castAs<ComplexType>()->getElementType(),
-                      CK_IntegralCast);
+                              DestTy->castAs<ComplexType>()->getElementType(),
+                              CK_IntegralCast);
       return CK_IntegralRealToComplex;
     case Type::STK_FloatingComplex:
       Src = ImpCastExprToType(Src.get(),
-                      DestTy->castAs<ComplexType>()->getElementType(),
-                      CK_IntegralToFloating);
+                              DestTy->castAs<ComplexType>()->getElementType(),
+                              CK_IntegralToFloating);
       return CK_FloatingRealToComplex;
     case Type::STK_MemberPointer:
       llvm_unreachable("member pointer type in C");
@@ -7855,7 +7853,8 @@ static bool breakDownVectorType(QualType type, uint64_t &len,
 
   // We allow lax conversion to and from non-vector types, but only if
   // they're real types (i.e. non-complex, non-pointer scalar types).
-  if (!type->isRealType()) return false;
+  if (!type->isRealType())
+    return false;
 
   len = 1;
   eltType = type;
@@ -7938,8 +7937,10 @@ bool Sema::areLaxCompatibleVectorTypes(QualType srcTy, QualType destTy) {
   // depend on them).  Most scalar OP ExtVector cases are handled by the
   // splat path anyway, which does what we want (convert, not bitcast).
   // What this rules out for ExtVectors is crazy things like char4*float.
-  if (srcTy->isScalarType() && destTy->isExtVectorType()) return false;
-  if (destTy->isScalarType() && srcTy->isExtVectorType()) return false;
+  if (srcTy->isScalarType() && destTy->isExtVectorType())
+    return false;
+  if (destTy->isScalarType() && srcTy->isExtVectorType())
+    return false;
 
   return areVectorTypesSameSize(srcTy, destTy);
 }
@@ -7965,7 +7966,7 @@ bool Sema::isLaxVectorConversion(QualType srcTy, QualType destTy) {
     // OK, integer (vector) -> integer (vector) bitcast.
     break;
 
-    case LangOptions::LaxVectorConversionKind::All:
+  case LangOptions::LaxVectorConversionKind::All:
     break;
   }
 
@@ -8000,14 +8001,14 @@ bool Sema::CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty,
   if (Ty->isVectorType() || Ty->isIntegralType(Context)) {
     if (!areLaxCompatibleVectorTypes(Ty, VectorTy))
       return Diag(R.getBegin(),
-                  Ty->isVectorType() ?
-                  diag::err_invalid_conversion_between_vectors :
-                  diag::err_invalid_conversion_between_vector_and_integer)
-        << VectorTy << Ty << R;
+                  Ty->isVectorType()
+                      ? diag::err_invalid_conversion_between_vectors
+                      : diag::err_invalid_conversion_between_vector_and_integer)
+             << VectorTy << Ty << R;
   } else
     return Diag(R.getBegin(),
                 diag::err_invalid_conversion_between_vector_and_scalar)
-      << VectorTy << Ty << R;
+           << VectorTy << Ty << R;
 
   Kind = CK_BitCast;
   return false;
@@ -8079,8 +8080,8 @@ ExprResult Sema::CheckExtVectorCast(SourceRange R, QualType DestTy,
         (getLangOpts().OpenCL &&
          !Context.hasSameUnqualifiedType(DestTy, SrcTy) &&
          !Context.areCompatibleVectorTypes(DestTy, SrcTy))) {
-      Diag(R.getBegin(),diag::err_invalid_conversion_between_ext_vectors)
-        << DestTy << SrcTy << R;
+      Diag(R.getBegin(), diag::err_invalid_conversion_between_ext_vectors)
+          << DestTy << SrcTy << R;
       return ExprError();
     }
     Kind = CK_BitCast;
@@ -8093,7 +8094,7 @@ ExprResult Sema::CheckExtVectorCast(SourceRange R, QualType DestTy,
   if (SrcTy->isPointerType())
     return Diag(R.getBegin(),
                 diag::err_invalid_conversion_between_vector_and_scalar)
-      << DestTy << SrcTy << R;
+           << DestTy << SrcTy << R;
 
   Kind = CK_VectorSplat;
   return prepareVectorSplat(DestTy, CastExpr);
@@ -8134,10 +8135,9 @@ static void CheckSufficientAllocSize(Sema &S, QualType DestType,
         << Size.getQuantity() << TargetType << LhsSize->getQuantity();
 }
 
-ExprResult
-Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
-                    Declarator &D, ParsedType &Ty,
-                    SourceLocation RParenLoc, Expr *CastExpr) {
+ExprResult Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
+                               Declarator &D, ParsedType &Ty,
+                               SourceLocation RParenLoc, Expr *CastExpr) {
   assert(!D.isInvalidType() && (CastExpr != nullptr) &&
          "ActOnCastExpr(): missing type or expr");
 
@@ -8161,8 +8161,9 @@ Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
   // i.e. all the elements are integer constants.
   ParenExpr *PE = dyn_cast<ParenExpr>(CastExpr);
   ParenListExpr *PLE = dyn_cast<ParenListExpr>(CastExpr);
-  if ((getLangOpts().AltiVec || getLangOpts().ZVector || getLangOpts().OpenCL)
-       && castType->isVectorType() && (PE || PLE)) {
+  if ((getLangOpts().AltiVec || getLangOpts().ZVector ||
+       getLangOpts().OpenCL) &&
+      castType->isVectorType() && (PE || PLE)) {
     if (PLE && PLE->getNumExprs() == 0) {
       Diag(PLE->getExprLoc(), diag::err_altivec_empty_initializer);
       return ExprError();
@@ -8171,8 +8172,7 @@ Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
       Expr *E = (PE ? PE->getSubExpr() : PLE->getExpr(0));
       if (!E->isTypeDependent() && !E->getType()->isVectorType())
         isVectorLiteral = true;
-    }
-    else
+    } else
       isVectorLiteral = true;
   }
 
@@ -8186,7 +8186,8 @@ Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
   // sequence of BinOp comma operators.
   if (isa<ParenListExpr>(CastExpr)) {
     ExprResult Result = MaybeConvertParenListExprToParenExpr(S, CastExpr);
-    if (Result.isInvalid()) return ExprError();
+    if (Result.isInvalid())
+      return ExprError();
     CastExpr = Result.get();
   }
 
@@ -8253,16 +8254,12 @@ ExprResult Sema::BuildVectorLiteral(SourceLocation LParenLoc,
       Literal = ImpCastExprToType(Literal.get(), ElemTy,
                                   PrepareScalarCast(Literal, ElemTy));
       return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.get());
-    }
-    else if (numExprs < numElems) {
-      Diag(E->getExprLoc(),
-           diag::err_incorrect_number_of_vector_initializers);
+    } else if (numExprs < numElems) {
+      Diag(E->getExprLoc(), diag::err_incorrect_number_of_vector_initializers);
       return ExprError();
-    }
-    else
+    } else
       initExprs.append(exprs, exprs + numExprs);
-  }
-  else {
+  } else {
     // For OpenCL, when the number of initializers is a single value,
     // it will be replicated to all components of the vector.
     if (getLangOpts().OpenCL && VTy->getVectorKind() == VectorKind::Generic &&
@@ -8287,14 +8284,14 @@ ExprResult Sema::BuildVectorLiteral(SourceLocation LParenLoc,
   }
   // FIXME: This means that pretty-printing the final AST will produce curly
   // braces instead of the original commas.
-  InitListExpr *initE = new (Context) InitListExpr(Context, LiteralLParenLoc,
-                                                   initExprs, LiteralRParenLoc);
+  InitListExpr *initE = new (Context)
+      InitListExpr(Context, LiteralLParenLoc, initExprs, LiteralRParenLoc);
   initE->setType(Ty);
   return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, initE);
 }
 
-ExprResult
-Sema::MaybeConvertParenListExprToParenExpr(Scope *S, Expr *OrigExpr) {
+ExprResult Sema::MaybeConvertParenListExprToParenExpr(Scope *S,
+                                                      Expr *OrigExpr) {
   ParenListExpr *E = dyn_cast<ParenListExpr>(OrigExpr);
   if (!E)
     return OrigExpr;
@@ -8302,16 +8299,16 @@ Sema::MaybeConvertParenListExprToParenExpr(Scope *S, Expr *OrigExpr) {
   ExprResult Result(E->getExpr(0));
 
   for (unsigned i = 1, e = E->getNumExprs(); i != e && !Result.isInvalid(); ++i)
-    Result = ActOnBinOp(S, E->getExprLoc(), tok::comma, Result.get(),
-                        E->getExpr(i));
+    Result =
+        ActOnBinOp(S, E->getExprLoc(), tok::comma, Result.get(), E->getExpr(i));
 
-  if (Result.isInvalid()) return ExprError();
+  if (Result.isInvalid())
+    return ExprError();
 
   return ActOnParenExpr(E->getLParenLoc(), E->getRParenLoc(), Result.get());
 }
 
-ExprResult Sema::ActOnParenListExpr(SourceLocation L,
-                                    SourceLocation R,
+ExprResult Sema::ActOnParenListExpr(SourceLocation L, SourceLocation R,
                                     MultiExprArg Val) {
   return ParenListExpr::Create(Context, L, Val, R);
 }
@@ -8329,16 +8326,14 @@ bool Sema::DiagnoseConditionalForNull(const Expr *LHSExpr, const Expr *RHSExpr,
                                       SourceLocation QuestionLoc) {
   const Expr *NullExpr = LHSExpr;
   const Expr *NonPointerExpr = RHSExpr;
-  Expr::NullPointerConstantKind NullKind =
-      NullExpr->isNullPointerConstant(Context,
-                                      Expr::NPC_ValueDependentIsNotNull);
+  Expr::NullPointerConstantKind NullKind = NullExpr->isNullPointerConstant(
+      Context, Expr::NPC_ValueDependentIsNotNull);
 
   if (NullKind == Expr::NPCK_NotNull) {
     NullExpr = RHSExpr;
     NonPointerExpr = LHSExpr;
-    NullKind =
-        NullExpr->isNullPointerConstant(Context,
-                                        Expr::NPC_ValueDependentIsNotNull);
+    NullKind = NullExpr->isNullPointerConstant(
+        Context, Expr::NPC_ValueDependentIsNotNull);
   }
 
   if (NullKind == Expr::NPCK_NotNull)
@@ -8371,15 +8366,16 @@ static bool checkCondition(Sema &S, const Expr *Cond,
   // OpenCL v1.1 s6.3.i says the condition cannot be a floating point type.
   if (S.getLangOpts().OpenCL && CondTy->isFloatingType()) {
     S.Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
-      << CondTy << Cond->getSourceRange();
+        << CondTy << Cond->getSourceRange();
     return true;
   }
 
   // C99 6.5.15p2
-  if (CondTy->isScalarType()) return false;
+  if (CondTy->isScalarType())
+    return false;
 
   S.Diag(QuestionLoc, diag::err_typecheck_cond_expect_scalar)
-    << CondTy << Cond->getSourceRange();
+      << CondTy << Cond->getSourceRange();
   return true;
 }
 
@@ -8389,7 +8385,7 @@ static bool checkConditionalNullPointer(Sema &S, ExprResult &NullExpr,
                                         QualType PointerTy) {
   if ((!PointerTy->isAnyPointerType() && !PointerTy->isBlockPointerType()) ||
       !NullExpr.get()->isNullPointerConstant(S.Context,
-                                            Expr::NPC_ValueDependentIsNull))
+                                             Expr::NPC_ValueDependentIsNull))
     return true;
 
   NullExpr = S.ImpCastExprToType(NullExpr.get(), PointerTy, CK_NullToPointer);
@@ -8451,7 +8447,8 @@ static QualType checkConditionalPointerCompatibility(Sema &S, ExprResult &LHS,
     return QualType();
   }
 
-  unsigned MergedCVRQual = lhQual.getCVRQualifiers() | rhQual.getCVRQualifiers();
+  unsigned MergedCVRQual =
+      lhQual.getCVRQualifiers() | rhQual.getCVRQualifiers();
   auto LHSCastKind = CK_BitCast, RHSCastKind = CK_BitCast;
   lhQual.removeCVRQualifiers();
   rhQual.removeCVRQualifiers();
@@ -8551,8 +8548,8 @@ static QualType checkConditionalBlockPointerCompatibility(Sema &S,
       return destType;
     }
     S.Diag(Loc, diag::err_typecheck_cond_incompatible_operands)
-      << LHSTy << RHSTy << LHS.get()->getSourceRange()
-      << RHS.get()->getSourceRange();
+        << LHSTy << RHSTy << LHS.get()->getSourceRange()
+        << RHS.get()->getSourceRange();
     return QualType();
   }
 
@@ -8561,10 +8558,8 @@ static QualType checkConditionalBlockPointerCompatibility(Sema &S,
 }
 
 /// Return the resulting type when the operands are both pointers.
-static QualType
-checkConditionalObjectPointersCompatibility(Sema &S, ExprResult &LHS,
-                                            ExprResult &RHS,
-                                            SourceLocation Loc) {
+static QualType checkConditionalObjectPointersCompatibility(
+    Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc) {
   // get the pointer types
   QualType LHSTy = LHS.get()->getType();
   QualType RHSTy = RHS.get()->getType();
@@ -8576,8 +8571,8 @@ checkConditionalObjectPointersCompatibility(Sema &S, ExprResult &LHS,
   // ignore qualifiers on void (C99 6.5.15p3, clause 6)
   if (lhptee->isVoidType() && rhptee->isIncompleteOrObjectType()) {
     // Figure out necessary qualifiers (C99 6.5.15p6)
-    QualType destPointee
-      = S.Context.getQualifiedType(lhptee, rhptee.getQualifiers());
+    QualType destPointee =
+        S.Context.getQualifiedType(lhptee, rhptee.getQualifiers());
     QualType destType = S.Context.getPointerType(destPointee);
     // Add qualifiers if necessary.
     LHS = S.ImpCastExprToType(LHS.get(), destType, CK_NoOp);
@@ -8586,8 +8581,8 @@ checkConditionalObjectPointersCompatibility(Sema &S, ExprResult &LHS,
     return destType;
   }
   if (rhptee->isVoidType() && lhptee->isIncompleteOrObjectType()) {
-    QualType destPointee
-      = S.Context.getQualifiedType(rhptee, lhptee.getQualifiers());
+    QualType destPointee =
+        S.Context.getQualifiedType(rhptee, lhptee.getQualifiers());
     QualType destType = S.Context.getPointerType(destPointee);
     // Add qualifiers if necessary.
     RHS = S.ImpCastExprToType(RHS.get(), destType, CK_NoOp);
@@ -8602,7 +8597,7 @@ checkConditionalObjectPointersCompatibility(Sema &S, ExprResult &LHS,
 /// Return false if the first expression is not an integer and the second
 /// expression is not a pointer, true otherwise.
 static bool checkPointerIntegerMismatch(Sema &S, ExprResult &Int,
-                                        Expr* PointerExpr, SourceLocation Loc,
+                                        Expr *PointerExpr, SourceLocation Loc,
                                         bool IsIntFirstExpr) {
   if (!PointerExpr->getType()->isPointerType() ||
       !Int.get()->getType()->isIntegerType())
@@ -8612,8 +8607,8 @@ static bool checkPointerIntegerMismatch(Sema &S, ExprResult &Int,
   Expr *Expr2 = IsIntFirstExpr ? PointerExpr : Int.get();
 
   S.Diag(Loc, diag::ext_typecheck_cond_pointer_integer_mismatch)
-    << Expr1->getType() << Expr2->getType()
-    << Expr1->getSourceRange() << Expr2->getSourceRange();
+      << Expr1->getType() << Expr2->getType() << Expr1->getSourceRange()
+      << Expr2->getSourceRange();
   Int = S.ImpCastExprToType(Int.get(), PointerExpr->getType(),
                             CK_IntegralToPointer);
   return true;
@@ -8644,19 +8639,19 @@ static QualType OpenCLArithmeticConversions(Sema &S, ExprResult &LHS,
   // For conversion purposes, we ignore any qualifiers.
   // For example, "const float" and "float" are equivalent.
   QualType LHSType =
-    S.Context.getCanonicalType(LHS.get()->getType()).getUnqualifiedType();
+      S.Context.getCanonicalType(LHS.get()->getType()).getUnqualifiedType();
   QualType RHSType =
-    S.Context.getCanonicalType(RHS.get()->getType()).getUnqualifiedType();
+      S.Context.getCanonicalType(RHS.get()->getType()).getUnqualifiedType();
 
   if (!LHSType->isIntegerType() && !LHSType->isRealFloatingType()) {
     S.Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
-      << LHSType << LHS.get()->getSourceRange();
+        << LHSType << LHS.get()->getSourceRange();
     return QualType();
   }
 
   if (!RHSType->isIntegerType() && !RHSType->isRealFloatingType()) {
     S.Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
-      << RHSType << RHS.get()->getSourceRange();
+        << RHSType << RHS.get()->getSourceRange();
     return QualType();
   }
 
@@ -8670,8 +8665,8 @@ static QualType OpenCLArithmeticConversions(Sema &S, ExprResult &LHS,
                                  /*IsCompAssign = */ false);
 
   // Finally, we have two differing integer types.
-  return handleIntegerConversion<doIntegralCast, doIntegralCast>
-  (S, LHS, RHS, LHSType, RHSType, /*IsCompAssign = */ false);
+  return handleIntegerConversion<doIntegralCast, doIntegralCast>(
+      S, LHS, RHS, LHSType, RHSType, /*IsCompAssign = */ false);
 }
 
 /// Convert scalar operands to a vector that matches the
@@ -8685,11 +8680,12 @@ static QualType OpenCLArithmeticConversions(Sema &S, ExprResult &LHS,
 /// into a vector of that type where the length matches the condition
 /// vector type. s6.11.6 requires that the element types of the result
 /// and the condition must have the same number of bits.
-static QualType
-OpenCLConvertScalarsToVectors(Sema &S, ExprResult &LHS, ExprResult &RHS,
-                              QualType CondTy, SourceLocation QuestionLoc) {
+static QualType OpenCLConvertScalarsToVectors(Sema &S, ExprResult &LHS,
+                                              ExprResult &RHS, QualType CondTy,
+                                              SourceLocation QuestionLoc) {
   QualType ResTy = OpenCLArithmeticConversions(S, LHS, RHS, QuestionLoc);
-  if (ResTy.isNull()) return QualType();
+  if (ResTy.isNull())
+    return QualType();
 
   const VectorType *CV = CondTy->getAs<VectorType>();
   assert(CV);
@@ -8699,8 +8695,8 @@ OpenCLConvertScalarsToVectors(Sema &S, ExprResult &LHS, ExprResult &RHS,
   QualType VectorTy = S.Context.getExtVectorType(ResTy, NumElements);
 
   // Ensure that all types have the same number of bits
-  if (S.Context.getTypeSize(CV->getElementType())
-      != S.Context.getTypeSize(ResTy)) {
+  if (S.Context.getTypeSize(CV->getElementType()) !=
+      S.Context.getTypeSize(ResTy)) {
     // Since VectorTy is created internally, it does not pretty print
     // with an OpenCL name. Instead, we just print a description.
     std::string EleTyName = ResTy.getUnqualifiedType().getAsString();
@@ -8708,7 +8704,7 @@ OpenCLConvertScalarsToVectors(Sema &S, ExprResult &LHS, ExprResult &RHS,
     llvm::raw_svector_ostream OS(Str);
     OS << "(vector of " << NumElements << " '" << EleTyName << "' values)";
     S.Diag(QuestionLoc, diag::err_conditional_vector_element_size)
-      << CondTy << OS.str();
+        << CondTy << OS.str();
     return QualType();
   }
 
@@ -8727,10 +8723,11 @@ static bool checkOpenCLConditionVector(Sema &S, Expr *Cond,
   const VectorType *CondTy = Cond->getType()->getAs<VectorType>();
   assert(CondTy);
   QualType EleTy = CondTy->getElementType();
-  if (EleTy->isIntegerType()) return false;
+  if (EleTy->isIntegerType())
+    return false;
 
   S.Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
-    << Cond->getType() << Cond->getSourceRange();
+      << Cond->getType() << Cond->getSourceRange();
   return true;
 }
 
@@ -8748,7 +8745,7 @@ static bool checkVectorResult(Sema &S, QualType CondTy, QualType VecResTy,
 
   if (CV->getNumElements() != RV->getNumElements()) {
     S.Diag(QuestionLoc, diag::err_conditional_vector_size)
-      << CondTy << VecResTy;
+        << CondTy << VecResTy;
     return true;
   }
 
@@ -8769,10 +8766,9 @@ static bool checkVectorResult(Sema &S, QualType CondTy, QualType VecResTy,
 /// Return the resulting type for the conditional operator in
 ///        OpenCL (aka "ternary selection operator", OpenCL v1.1
 ///        s6.3.i) when the condition is a vector type.
-static QualType
-OpenCLCheckVectorConditional(Sema &S, ExprResult &Cond,
-                             ExprResult &LHS, ExprResult &RHS,
-                             SourceLocation QuestionLoc) {
+static QualType OpenCLCheckVectorConditional(Sema &S, ExprResult &Cond,
+                                             ExprResult &LHS, ExprResult &RHS,
+                                             SourceLocation QuestionLoc) {
   Cond = S.DefaultFunctionArrayLvalueConversion(Cond.get());
   if (Cond.isInvalid())
     return QualType();
@@ -8833,11 +8829,13 @@ QualType Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS,
                                         SourceLocation QuestionLoc) {
 
   ExprResult LHSResult = CheckPlaceholderExpr(LHS.get());
-  if (!LHSResult.isUsable()) return QualType();
+  if (!LHSResult.isUsable())
+    return QualType();
   LHS = LHSResult;
 
   ExprResult RHSResult = CheckPlaceholderExpr(RHS.get());
-  if (!RHSResult.isUsable()) return QualType();
+  if (!RHSResult.isUsable())
+    return QualType();
   RHS = RHSResult;
 
   // C++ is sufficiently different to merit its own checker.
@@ -8896,16 +8894,16 @@ QualType Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS,
   // Diagnose attempts to convert between __ibm128, __float128 and long double
   // where such conversions currently can't be handled.
   if (unsupportedTypeConversion(*this, LHSTy, RHSTy)) {
-    Diag(QuestionLoc,
-         diag::err_typecheck_cond_incompatible_operands) << LHSTy << RHSTy
-      << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+    Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
+        << LHSTy << RHSTy << LHS.get()->getSourceRange()
+        << RHS.get()->getSourceRange();
     return QualType();
   }
 
   // OpenCL v2.0 s6.12.5 - Blocks cannot be used as expressions of the ternary
   // selection operator (?:).
-  if (getLangOpts().OpenCL &&
-      ((int)checkBlockType(*this, LHS.get()) | (int)checkBlockType(*this, RHS.get()))) {
+  if (getLangOpts().OpenCL && ((int)checkBlockType(*this, LHS.get()) |
+                               (int)checkBlockType(*this, RHS.get()))) {
     return QualType();
   }
 
@@ -8964,8 +8962,10 @@ QualType Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS,
 
   // C99 6.5.15p6 - "if one operand is a null pointer constant, the result has
   // the type of the other operand."
-  if (!checkConditionalNullPointer(*this, RHS, LHSTy)) return LHSTy;
-  if (!checkConditionalNullPointer(*this, LHS, RHSTy)) return RHSTy;
+  if (!checkConditionalNullPointer(*this, RHS, LHSTy))
+    return LHSTy;
+  if (!checkConditionalNullPointer(*this, LHS, RHSTy))
+    return RHSTy;
 
   // All objective-c pointer type analysis is done here.
   QualType compositeType =
@@ -8975,7 +8975,6 @@ QualType Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS,
   if (!compositeType.isNull())
     return compositeType;
 
-
   // Handle block pointer types.
   if (LHSTy->isBlockPointerType() || RHSTy->isBlockPointerType())
     return checkConditionalBlockPointerCompatibility(*this, LHS, RHS,
@@ -8989,10 +8988,10 @@ QualType Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS,
   // GCC compatibility: soften pointer/integer mismatch.  Note that
   // null pointers have been filtered out by this point.
   if (checkPointerIntegerMismatch(*this, LHS, RHS.get(), QuestionLoc,
-      /*IsIntFirstExpr=*/true))
+                                  /*IsIntFirstExpr=*/true))
     return RHSTy;
   if (checkPointerIntegerMismatch(*this, RHS, LHS.get(), QuestionLoc,
-      /*IsIntFirstExpr=*/false))
+                                  /*IsIntFirstExpr=*/false))
     return LHSTy;
 
   // Emit a better diagnostic if one of the expressions is a null pointer
@@ -9008,8 +9007,8 @@ QualType Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS,
 
   // Otherwise, the operands are not compatible.
   Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
-    << LHSTy << RHSTy << LHS.get()->getSourceRange()
-    << RHS.get()->getSourceRange();
+      << LHSTy << RHSTy << LHS.get()->getSourceRange()
+      << RHS.get()->getSourceRange();
   return QualType();
 }
 
@@ -9021,9 +9020,9 @@ static void SuggestParentheses(Sema &Self, SourceLocation Loc,
   SourceLocation EndLoc = Self.getLocForEndOfToken(ParenRange.getEnd());
   if (ParenRange.getBegin().isFileID() && ParenRange.getEnd().isFileID() &&
       EndLoc.isValid()) {
-    Self.Diag(Loc, Note)
-      << FixItHint::CreateInsertion(ParenRange.getBegin(), "(")
-      << FixItHint::CreateInsertion(EndLoc, ")");
+    Self.Diag(Loc, Note) << FixItHint::CreateInsertion(ParenRange.getBegin(),
+                                                       "(")
+                         << FixItHint::CreateInsertion(EndLoc, ")");
   } else {
     // We can't display the parentheses, so just show the bare note.
     Self.Diag(Loc, Note) << ParenRange;
@@ -9072,8 +9071,8 @@ static bool IsArithmeticBinaryExpr(const Expr *E, BinaryOperatorKind *Opcode,
     // Make sure this is really a binary operator that is safe to pass into
     // BinaryOperator::getOverloadedOpcode(), e.g. it's not a subscript op.
     OverloadedOperatorKind OO = Call->getOperator();
-    if (OO < OO_Plus || OO > OO_Arrow ||
-        OO == OO_PlusPlus || OO == OO_MinusMinus)
+    if (OO < OO_Plus || OO > OO_Arrow || OO == OO_PlusPlus ||
+        OO == OO_MinusMinus)
       return false;
 
     BinaryOperatorKind OpKind = BinaryOperator::getOverloadedOpcode(OO);
@@ -9129,9 +9128,8 @@ static void DiagnoseConditionalPrecedence(Sema &Self, SourceLocation OpLoc,
                         ? diag::warn_precedence_bitwise_conditional
                         : diag::warn_precedence_conditional;
 
-  Self.Diag(OpLoc, DiagID)
-      << Condition->getSourceRange()
-      << BinaryOperator::getOpcodeStr(CondOpcode);
+  Self.Diag(OpLoc, DiagID) << Condition->getSourceRange()
+                           << BinaryOperator::getOpcodeStr(CondOpcode);
 
   SuggestParentheses(
       Self, OpLoc,
@@ -9171,7 +9169,7 @@ static QualType computeConditionalNullability(QualType ResTy, bool IsBin,
       MergedKind = NullabilityKind::NonNull;
     else
       MergedKind = RHSKind;
-  // Compute nullability of a normal conditional expression.
+    // Compute nullability of a normal conditional expression.
   } else {
     if (LHSKind == NullabilityKind::Nullable ||
         RHSKind == NullabilityKind::Nullable)
@@ -9197,9 +9195,8 @@ static QualType computeConditionalNullability(QualType ResTy, bool IsBin,
 }
 
 ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc,
-                                    SourceLocation ColonLoc,
-                                    Expr *CondExpr, Expr *LHSExpr,
-                                    Expr *RHSExpr) {
+                                    SourceLocation ColonLoc, Expr *CondExpr,
+                                    Expr *LHSExpr, Expr *RHSExpr) {
   // If this is the gnu "x ?: y" extension, analyze the types as though the LHS
   // was the condition.
   OpaqueValueExpr *opaqueValue = nullptr;
@@ -9211,18 +9208,17 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc,
     // as Objective-C++'s dictionary subscripting syntax.
     if (commonExpr->hasPlaceholderType()) {
       ExprResult result = CheckPlaceholderExpr(commonExpr);
-      if (!result.isUsable()) return ExprError();
+      if (!result.isUsable())
+        return ExprError();
       commonExpr = result.get();
     }
     // We usually want to apply unary conversions *before* saving, except
     // in the special case of a C++ l-value conditional.
-    if (!(getLangOpts().CPlusPlus
-          && !commonExpr->isTypeDependent()
-          && commonExpr->getValueKind() == RHSExpr->getValueKind()
-          && commonExpr->isGLValue()
-          && commonExpr->isOrdinaryOrBitFieldObject()
-          && RHSExpr->isOrdinaryOrBitFieldObject()
-          && Context.hasSameType(commonExpr->getType(), RHSExpr->getType()))) {
+    if (!(getLangOpts().CPlusPlus && !commonExpr->isTypeDependent() &&
+          commonExpr->getValueKind() == RHSExpr->getValueKind() &&
+          commonExpr->isGLValue() && commonExpr->isOrdinaryOrBitFieldObject() &&
+          RHSExpr->isOrdinaryOrBitFieldObject() &&
+          Context.hasSameType(commonExpr->getType(), RHSExpr->getType()))) {
       ExprResult commonRes = UsualUnaryConversions(commonExpr);
       if (commonRes.isInvalid())
         return ExprError();
@@ -9239,11 +9235,9 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc,
       commonExpr = MatExpr.get();
     }
 
-    opaqueValue = new (Context) OpaqueValueExpr(commonExpr->getExprLoc(),
-                                                commonExpr->getType(),
-                                                commonExpr->getValueKind(),
-                                                commonExpr->getObjectKind(),
-                                                commonExpr);
+    opaqueValue = new (Context) OpaqueValueExpr(
+        commonExpr->getExprLoc(), commonExpr->getType(),
+        commonExpr->getValueKind(), commonExpr->getObjectKind(), commonExpr);
     LHSExpr = CondExpr = opaqueValue;
   }
 
@@ -9251,10 +9245,9 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc,
   ExprValueKind VK = VK_PRValue;
   ExprObjectKind OK = OK_Ordinary;
   ExprResult Cond = CondExpr, LHS = LHSExpr, RHS = RHSExpr;
-  QualType result = CheckConditionalOperands(Cond, LHS, RHS,
-                                             VK, OK, QuestionLoc);
-  if (result.isNull() || Cond.isInvalid() || LHS.isInvalid() ||
-      RHS.isInvalid())
+  QualType result =
+      CheckConditionalOperands(Cond, LHS, RHS, VK, OK, QuestionLoc);
+  if (result.isNull() || Cond.isInvalid() || LHS.isInvalid() || RHS.isInvalid())
     return ExprError();
 
   DiagnoseConditionalPrecedence(*this, QuestionLoc, Cond.get(), LHS.get(),
@@ -9262,8 +9255,8 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc,
 
   CheckBoolLikeConversion(Cond.get(), QuestionLoc);
 
-  result = computeConditionalNullability(result, commonExpr, LHSTy, RHSTy,
-                                         Context);
+  result =
+      computeConditionalNullability(result, commonExpr, LHSTy, RHSTy, Context);
 
   if (!commonExpr)
     return new (Context)
@@ -9437,9 +9430,9 @@ static AssignConvertType checkPointerTypesForAssignment(Sema &S,
     if (isa<PointerType>(lhptee) && isa<PointerType>(rhptee)) {
       do {
         std::tie(lhptee, lhq) =
-          cast<PointerType>(lhptee)->getPointeeType().split().asPair();
+            cast<PointerType>(lhptee)->getPointeeType().split().asPair();
         std::tie(rhptee, rhq) =
-          cast<PointerType>(rhptee)->getPointeeType().split().asPair();
+            cast<PointerType>(rhptee)->getPointeeType().split().asPair();
 
         // Inconsistent address spaces at this point is invalid, even if the
         // address spaces would be compatible.
@@ -10045,8 +10038,8 @@ static void ConstructTransparentUnion(Sema &S, ASTContext &C,
   // Build an initializer list that designates the appropriate member
   // of the transparent union.
   Expr *E = EResult.get();
-  InitListExpr *Initializer = new (C) InitListExpr(C, SourceLocation(),
-                                                   E, SourceLocation());
+  InitListExpr *Initializer =
+      new (C) InitListExpr(C, SourceLocation(), E, SourceLocation());
   Initializer->setType(UnionType);
   Initializer->setInitializedFieldInUnion(Field);
 
@@ -10089,8 +10082,7 @@ Sema::CheckTransparentUnionArgumentConstraints(QualType ArgType,
 
       if (RHS.get()->isNullPointerConstant(Context,
                                            Expr::NPC_ValueDependentIsNull)) {
-        RHS = ImpCastExprToType(RHS.get(), it->getType(),
-                                CK_NullToPointer);
+        RHS = ImpCastExprToType(RHS.get(), it->getType(), CK_NullToPointer);
         InitField = it;
         break;
       }
@@ -10148,13 +10140,12 @@ AssignConvertType Sema::CheckSingleAssignmentConstraints(QualType LHSType,
         RHS = PerformImplicitConversion(RHS.get(), LHSType.getUnqualifiedType(),
                                         AssignmentAction::Assigning);
       } else {
-        ImplicitConversionSequence ICS =
-            TryImplicitConversion(RHS.get(), LHSType.getUnqualifiedType(),
-                                  /*SuppressUserConversions=*/false,
-                                  AllowedExplicit::None,
-                                  /*InOverloadResolution=*/false,
-                                  /*CStyle=*/false,
-                                  /*AllowObjCWritebackConversion=*/false);
+        ImplicitConversionSequence ICS = TryImplicitConversion(
+            RHS.get(), LHSType.getUnqualifiedType(),
+            /*SuppressUserConversions=*/false, AllowedExplicit::None,
+            /*InOverloadResolution=*/false,
+            /*CStyle=*/false,
+            /*AllowObjCWritebackConversion=*/false);
         if (ICS.isFailure())
           return AssignConvertType::Incompatible;
         RHS = PerformImplicitConversion(RHS.get(), LHSType.getUnqualifiedType(),
@@ -10356,27 +10347,27 @@ struct OriginalOperand {
   Expr *Orig;
   NamedDecl *Conversion;
 };
-}
+} // namespace
 
 QualType Sema::InvalidOperands(SourceLocation Loc, ExprResult &LHS,
                                ExprResult &RHS) {
   OriginalOperand OrigLHS(LHS.get()), OrigRHS(RHS.get());
 
   Diag(Loc, diag::err_typecheck_invalid_operands)
-    << OrigLHS.getType() << OrigRHS.getType()
-    << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+      << OrigLHS.getType() << OrigRHS.getType() << LHS.get()->getSourceRange()
+      << RHS.get()->getSourceRange();
 
   // If a user-defined conversion was applied to either of the operands prior
   // to applying the built-in operator rules, tell the user about it.
   if (OrigLHS.Conversion) {
     Diag(OrigLHS.Conversion->getLocation(),
          diag::note_typecheck_invalid_operands_converted)
-      << 0 << LHS.get()->getType();
+        << 0 << LHS.get()->getType();
   }
   if (OrigRHS.Conversion) {
     Diag(OrigRHS.Conversion->getLocation(),
          diag::note_typecheck_invalid_operands_converted)
-      << 1 << RHS.get()->getType();
+        << 1 << RHS.get()->getType();
   }
 
   return QualType();
@@ -10419,10 +10410,8 @@ QualType Sema::InvalidLogicalVectorOperands(SourceLocation Loc, ExprResult &LHS,
 /// \param scalar - if non-null, actually perform the conversions
 /// \return true if the operation fails (but without diagnosing the failure)
 static bool tryVectorConvertAndSplat(Sema &S, ExprResult *scalar,
-                                     QualType scalarTy,
-                                     QualType vectorEltTy,
-                                     QualType vectorTy,
-                                     unsigned &DiagID) {
+                                     QualType scalarTy, QualType vectorEltTy,
+                                     QualType vectorTy, unsigned &DiagID) {
   // The conversion to apply to the scalar before splatting it,
   // if necessary.
   CastKind scalarCast = CK_NoOp;
@@ -10430,9 +10419,10 @@ static bool tryVectorConvertAndSplat(Sema &S, ExprResult *scalar,
   if (vectorEltTy->isBooleanType() && scalarTy->isIntegralType(S.Context)) {
     scalarCast = CK_IntegralToBoolean;
   } else if (vectorEltTy->isIntegralType(S.Context)) {
-    if (S.getLangOpts().OpenCL && (scalarTy->isRealFloatingType() ||
-        (scalarTy->isIntegerType() &&
-         S.Context.getIntegerTypeOrder(vectorEltTy, scalarTy) < 0))) {
+    if (S.getLangOpts().OpenCL &&
+        (scalarTy->isRealFloatingType() ||
+         (scalarTy->isIntegerType() &&
+          S.Context.getIntegerTypeOrder(vectorEltTy, scalarTy) < 0))) {
       DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
       return true;
     }
@@ -10447,8 +10437,7 @@ static bool tryVectorConvertAndSplat(Sema &S, ExprResult *scalar,
         return true;
       }
       scalarCast = CK_FloatingCast;
-    }
-    else if (scalarTy->isIntegralType(S.Context))
+    } else if (scalarTy->isIntegralType(S.Context))
       scalarCast = CK_IntegralToFloating;
     else
       return true;
@@ -10878,11 +10867,11 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
     if (!IsCompAssign) {
       *OtherExpr = ImpCastExprToType(OtherExpr->get(), VecType, CK_BitCast);
       return VecType;
-    // In a compound assignment, lhs += rhs, 'lhs' is a lvalue src, forbidding
-    // any implicit cast. Here, the 'rhs' should be implicit casted to 'lhs'
-    // type. Note that this is already done by non-compound assignments in
-    // CheckAssignmentConstraints. If it's a scalar type, only bitcast for
-    // <1 x T> -> T. The result is also a vector type.
+      // In a compound assignment, lhs += rhs, 'lhs' is a lvalue src, forbidding
+      // any implicit cast. Here, the 'rhs' should be implicit casted to 'lhs'
+      // type. Note that this is already done by non-compound assignments in
+      // CheckAssignmentConstraints. If it's a scalar type, only bitcast for
+      // <1 x T> -> T. The result is also a vector type.
     } else if (OtherType->isExtVectorType() || OtherType->isVectorType() ||
                (OtherType->isScalarType() && VT->getNumElements() == 1)) {
       ExprResult *RHSExpr = &RHS;
@@ -10897,8 +10886,8 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
   if ((!RHSVecType && !RHSType->isRealType()) ||
       (!LHSVecType && !LHSType->isRealType())) {
     Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
-      << LHSType << RHSType
-      << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+        << LHSType << RHSType << LHS.get()->getSourceRange()
+        << RHS.get()->getSourceRange();
     return QualType();
   }
 
@@ -10906,15 +10895,13 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
   // If the operands are of more than one vector type, then an error shall
   // occur. Implicit conversions between vector types are not permitted, per
   // section 6.2.1.
-  if (getLangOpts().OpenCL &&
-      RHSVecType && isa<ExtVectorType>(RHSVecType) &&
+  if (getLangOpts().OpenCL && RHSVecType && isa<ExtVectorType>(RHSVecType) &&
       LHSVecType && isa<ExtVectorType>(LHSVecType)) {
-    Diag(Loc, diag::err_opencl_implicit_vector_conversion) << LHSType
-                                                           << RHSType;
+    Diag(Loc, diag::err_opencl_implicit_vector_conversion)
+        << LHSType << RHSType;
     return QualType();
   }
 
-
   // If there is a vector type that is not a ExtVector and a scalar, we reach
   // this point if scalar could not be converted to the vector's element type
   // without truncation.
@@ -10923,17 +10910,15 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
     QualType Scalar = LHSVecType ? RHSType : LHSType;
     QualType Vector = LHSVecType ? LHSType : RHSType;
     unsigned ScalarOrVector = LHSVecType && RHSVecType ? 1 : 0;
-    Diag(Loc,
-         diag::err_typecheck_vector_not_convertable_implict_truncation)
+    Diag(Loc, diag::err_typecheck_vector_not_convertable_implict_truncation)
         << ScalarOrVector << Scalar << Vector;
 
     return QualType();
   }
 
   // Otherwise, use the generic diagnostic.
-  Diag(Loc, DiagID)
-    << LHSType << RHSType
-    << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+  Diag(Loc, DiagID) << LHSType << RHSType << LHS.get()->getSourceRange()
+                    << RHS.get()->getSourceRange();
   return QualType();
 }
 
@@ -11047,8 +11032,8 @@ static void checkArithmeticNull(Sema &S, ExprResult &LHS, ExprResult &RHS,
     return;
 
   S.Diag(Loc, diag::warn_null_in_comparison_operation)
-      << LHSNull /* LHS is NULL */ << NonNullType
-      << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+      << LHSNull /* LHS is NULL */ << NonNullType << LHS.get()->getSourceRange()
+      << RHS.get()->getSourceRange();
 }
 
 static void DetectPrecisionLossInComplexDivision(Sema &S, QualType DivisorTy,
@@ -11091,7 +11076,7 @@ static void DetectPrecisionLossInComplexDivision(Sema &S, QualType DivisorTy,
 }
 
 static void DiagnoseDivisionSizeofPointerOrArray(Sema &S, Expr *LHS, Expr *RHS,
-                                          SourceLocation Loc) {
+                                                 SourceLocation Loc) {
   const auto *LUE = dyn_cast<UnaryExprOrTypeTraitExpr>(LHS);
   const auto *RUE = dyn_cast<UnaryExprOrTypeTraitExpr>(RHS);
   if (!LUE || !RUE)
@@ -11138,7 +11123,7 @@ static void DiagnoseDivisionSizeofPointerOrArray(Sema &S, Expr *LHS, Expr *RHS,
   }
 }
 
-static void DiagnoseBadDivideOrRemainderValues(Sema& S, ExprResult &LHS,
+static void DiagnoseBadDivideOrRemainderValues(Sema &S, ExprResult &LHS,
                                                ExprResult &RHS,
                                                SourceLocation Loc, bool IsDiv) {
   // Check for division/remainder by zero.
@@ -11148,7 +11133,7 @@ static void DiagnoseBadDivideOrRemainderValues(Sema& S, ExprResult &LHS,
       RHSValue.Val.getInt() == 0)
     S.DiagRuntimeBehavior(Loc, RHS.get(),
                           S.PDiag(diag::warn_remainder_division_by_zero)
-                            << IsDiv << RHS.get()->getSourceRange());
+                              << IsDiv << RHS.get()->getSourceRange());
 }
 
 static void diagnoseScopedEnums(Sema &S, const SourceLocation Loc,
@@ -11235,8 +11220,8 @@ QualType Sema::CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS,
   return compType;
 }
 
-QualType Sema::CheckRemainderOperands(
-  ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign) {
+QualType Sema::CheckRemainderOperands(ExprResult &LHS, ExprResult &RHS,
+                                      SourceLocation Loc, bool IsCompAssign) {
   checkArithmeticNull(*this, LHS, RHS, Loc, /*IsCompare=*/false);
 
   // Note: This check is here to simplify the double exclusions of
@@ -11303,19 +11288,19 @@ QualType Sema::CheckRemainderOperands(
 static void diagnoseArithmeticOnTwoVoidPointers(Sema &S, SourceLocation Loc,
                                                 Expr *LHSExpr, Expr *RHSExpr) {
   S.Diag(Loc, S.getLangOpts().CPlusPlus
-                ? diag::err_typecheck_pointer_arith_void_type
-                : diag::ext_gnu_void_ptr)
-    << 1 /* two pointers */ << LHSExpr->getSourceRange()
-                            << RHSExpr->getSourceRange();
+                  ? diag::err_typecheck_pointer_arith_void_type
+                  : diag::ext_gnu_void_ptr)
+      << 1 /* two pointers */ << LHSExpr->getSourceRange()
+      << RHSExpr->getSourceRange();
 }
 
 /// Diagnose invalid arithmetic on a void pointer.
 static void diagnoseArithmeticOnVoidPointer(Sema &S, SourceLocation Loc,
                                             Expr *Pointer) {
   S.Diag(Loc, S.getLangOpts().CPlusPlus
-                ? diag::err_typecheck_pointer_arith_void_type
-                : diag::ext_gnu_void_ptr)
-    << 0 /* one pointer */ << Pointer->getSourceRange();
+                  ? diag::err_typecheck_pointer_arith_void_type
+                  : diag::ext_gnu_void_ptr)
+      << 0 /* one pointer */ << Pointer->getSourceRange();
 }
 
 /// Diagnose invalid arithmetic on a null pointer.
@@ -11326,11 +11311,10 @@ static void diagnoseArithmeticOnVoidPointer(Sema &S, SourceLocation Loc,
 static void diagnoseArithmeticOnNullPointer(Sema &S, SourceLocation Loc,
                                             Expr *Pointer, bool IsGNUIdiom) {
   if (IsGNUIdiom)
-    S.Diag(Loc, diag::warn_gnu_null_ptr_arith)
-      << Pointer->getSourceRange();
+    S.Diag(Loc, diag::warn_gnu_null_ptr_arith) << Pointer->getSourceRange();
   else
     S.Diag(Loc, diag::warn_pointer_arith_null_ptr)
-      << S.getLangOpts().CPlusPlus << Pointer->getSourceRange();
+        << S.getLangOpts().CPlusPlus << Pointer->getSourceRange();
 }
 
 /// Diagnose invalid subraction on a null pointer.
@@ -11357,14 +11341,15 @@ static void diagnoseArithmeticOnTwoFunctionPointers(Sema &S, SourceLocation Loc,
   assert(LHS->getType()->isAnyPointerType());
   assert(RHS->getType()->isAnyPointerType());
   S.Diag(Loc, S.getLangOpts().CPlusPlus
-                ? diag::err_typecheck_pointer_arith_function_type
-                : diag::ext_gnu_ptr_func_arith)
-    << 1 /* two pointers */ << LHS->getType()->getPointeeType()
-    // We only show the second type if it differs from the first.
-    << (unsigned)!S.Context.hasSameUnqualifiedType(LHS->getType(),
-                                                   RHS->getType())
-    << RHS->getType()->getPointeeType()
-    << LHS->getSourceRange() << RHS->getSourceRange();
+                  ? diag::err_typecheck_pointer_arith_function_type
+                  : diag::ext_gnu_ptr_func_arith)
+      << 1 /* two pointers */
+      << LHS->getType()->getPointeeType()
+      // We only show the second type if it differs from the first.
+      << (unsigned)!S.Context.hasSameUnqualifiedType(LHS->getType(),
+                                                     RHS->getType())
+      << RHS->getType()->getPointeeType() << LHS->getSourceRange()
+      << RHS->getSourceRange();
 }
 
 /// Diagnose invalid arithmetic on a function pointer.
@@ -11372,11 +11357,11 @@ static void diagnoseArithmeticOnFunctionPointer(Sema &S, SourceLocation Loc,
                                                 Expr *Pointer) {
   assert(Pointer->getType()->isAnyPointerType());
   S.Diag(Loc, S.getLangOpts().CPlusPlus
-                ? diag::err_typecheck_pointer_arith_function_type
-                : diag::ext_gnu_ptr_func_arith)
-    << 0 /* one pointer */ << Pointer->getType()->getPointeeType()
-    << 0 /* one pointer, so only one type */
-    << Pointer->getSourceRange();
+                  ? diag::err_typecheck_pointer_arith_function_type
+                  : diag::ext_gnu_ptr_func_arith)
+      << 0 /* one pointer */ << Pointer->getType()->getPointeeType()
+      << 0 /* one pointer, so only one type */
+      << Pointer->getSourceRange();
 }
 
 /// Emit error if Operand is incomplete pointer type
@@ -11410,7 +11395,8 @@ static bool checkArithmeticOpPointerOperand(Sema &S, SourceLocation Loc,
   if (const AtomicType *ResAtomicType = ResType->getAs<AtomicType>())
     ResType = ResAtomicType->getValueType();
 
-  if (!ResType->isAnyPointerType()) return true;
+  if (!ResType->isAnyPointerType())
+    return true;
 
   QualType PointeeTy = ResType->getPointeeType();
   if (PointeeTy->isVoidType()) {
@@ -11422,7 +11408,8 @@ static bool checkArithmeticOpPointerOperand(Sema &S, SourceLocation Loc,
     return !S.getLangOpts().CPlusPlus;
   }
 
-  if (checkArithmeticIncompletePointerType(S, Loc, Operand)) return false;
+  if (checkArithmeticIncompletePointerType(S, Loc, Operand))
+    return false;
 
   return true;
 }
@@ -11440,11 +11427,14 @@ static bool checkArithmeticBinOpPointerOperands(Sema &S, SourceLocation Loc,
                                                 Expr *LHSExpr, Expr *RHSExpr) {
   bool isLHSPointer = LHSExpr->getType()->isAnyPointerType();
   bool isRHSPointer = RHSExpr->getType()->isAnyPointerType();
-  if (!isLHSPointer && !isRHSPointer) return true;
+  if (!isLHSPointer && !isRHSPointer)
+    return true;
 
   QualType LHSPointeeTy, RHSPointeeTy;
-  if (isLHSPointer) LHSPointeeTy = LHSExpr->getType()->getPointeeType();
-  if (isRHSPointer) RHSPointeeTy = RHSExpr->getType()->getPointeeType();
+  if (isLHSPointer)
+    LHSPointeeTy = LHSExpr->getType()->getPointeeType();
+  if (isRHSPointer)
+    RHSPointeeTy = RHSExpr->getType()->getPointeeType();
 
   // if both are pointers check if operation is valid wrt address spaces
   if (isLHSPointer && isRHSPointer) {
@@ -11462,9 +11452,12 @@ static bool checkArithmeticBinOpPointerOperands(Sema &S, SourceLocation Loc,
   bool isLHSVoidPtr = isLHSPointer && LHSPointeeTy->isVoidType();
   bool isRHSVoidPtr = isRHSPointer && RHSPointeeTy->isVoidType();
   if (isLHSVoidPtr || isRHSVoidPtr) {
-    if (!isRHSVoidPtr) diagnoseArithmeticOnVoidPointer(S, Loc, LHSExpr);
-    else if (!isLHSVoidPtr) diagnoseArithmeticOnVoidPointer(S, Loc, RHSExpr);
-    else diagnoseArithmeticOnTwoVoidPointers(S, Loc, LHSExpr, RHSExpr);
+    if (!isRHSVoidPtr)
+      diagnoseArithmeticOnVoidPointer(S, Loc, LHSExpr);
+    else if (!isLHSVoidPtr)
+      diagnoseArithmeticOnVoidPointer(S, Loc, RHSExpr);
+    else
+      diagnoseArithmeticOnTwoVoidPointers(S, Loc, LHSExpr, RHSExpr);
 
     return !S.getLangOpts().CPlusPlus;
   }
@@ -11472,10 +11465,12 @@ static bool checkArithmeticBinOpPointerOperands(Sema &S, SourceLocation Loc,
   bool isLHSFuncPtr = isLHSPointer && LHSPointeeTy->isFunctionType();
   bool isRHSFuncPtr = isRHSPointer && RHSPointeeTy->isFunctionType();
   if (isLHSFuncPtr || isRHSFuncPtr) {
-    if (!isRHSFuncPtr) diagnoseArithmeticOnFunctionPointer(S, Loc, LHSExpr);
-    else if (!isLHSFuncPtr) diagnoseArithmeticOnFunctionPointer(S, Loc,
-                                                                RHSExpr);
-    else diagnoseArithmeticOnTwoFunctionPointers(S, Loc, LHSExpr, RHSExpr);
+    if (!isRHSFuncPtr)
+      diagnoseArithmeticOnFunctionPointer(S, Loc, LHSExpr);
+    else if (!isLHSFuncPtr)
+      diagnoseArithmeticOnFunctionPointer(S, Loc, RHSExpr);
+    else
+      diagnoseArithmeticOnTwoFunctionPointers(S, Loc, LHSExpr, RHSExpr);
 
     return !S.getLangOpts().CPlusPlus;
   }
@@ -11492,15 +11487,15 @@ static bool checkArithmeticBinOpPointerOperands(Sema &S, SourceLocation Loc,
 /// literal.
 static void diagnoseStringPlusInt(Sema &Self, SourceLocation OpLoc,
                                   Expr *LHSExpr, Expr *RHSExpr) {
-  StringLiteral* StrExpr = dyn_cast<StringLiteral>(LHSExpr->IgnoreImpCasts());
-  Expr* IndexExpr = RHSExpr;
+  StringLiteral *StrExpr = dyn_cast<StringLiteral>(LHSExpr->IgnoreImpCasts());
+  Expr *IndexExpr = RHSExpr;
   if (!StrExpr) {
     StrExpr = dyn_cast<StringLiteral>(RHSExpr->IgnoreImpCasts());
     IndexExpr = LHSExpr;
   }
 
-  bool IsStringPlusInt = StrExpr &&
-      IndexExpr->getType()->isIntegralOrUnscopedEnumerationType();
+  bool IsStringPlusInt =
+      StrExpr && IndexExpr->getType()->isIntegralOrUnscopedEnumerationType();
   if (!IsStringPlusInt || IndexExpr->isValueDependent())
     return;
 
@@ -11548,11 +11543,9 @@ static void diagnoseStringPlusChar(Sema &Self, SourceLocation OpLoc,
   SourceRange DiagRange(LHSExpr->getBeginLoc(), RHSExpr->getEndLoc());
 
   const QualType CharType = CharExpr->getType();
-  if (!CharType->isAnyCharacterType() &&
-      CharType->isIntegerType() &&
+  if (!CharType->isAnyCharacterType() && CharType->isIntegerType() &&
       llvm::isUIntN(Ctx.getCharWidth(), CharExpr->getValue())) {
-    Self.Diag(OpLoc, diag::warn_string_plus_char)
-        << DiagRange << Ctx.CharTy;
+    Self.Diag(OpLoc, diag::warn_string_plus_char) << DiagRange << Ctx.CharTy;
   } else {
     Self.Diag(OpLoc, diag::warn_string_plus_char)
         << DiagRange << CharExpr->getType();
@@ -11576,14 +11569,14 @@ static void diagnosePointerIncompatibility(Sema &S, SourceLocation Loc,
   assert(LHSExpr->getType()->isAnyPointerType());
   assert(RHSExpr->getType()->isAnyPointerType());
   S.Diag(Loc, diag::err_typecheck_sub_ptr_compatible)
-    << LHSExpr->getType() << RHSExpr->getType() << LHSExpr->getSourceRange()
-    << RHSExpr->getSourceRange();
+      << LHSExpr->getType() << RHSExpr->getType() << LHSExpr->getSourceRange()
+      << RHSExpr->getSourceRange();
 }
 
 // C99 6.5.6
 QualType Sema::CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS,
                                      SourceLocation Loc, BinaryOperatorKind Opc,
-                                     QualType* CompLHSTy) {
+                                     QualType *CompLHSTy) {
   checkArithmeticNull(*this, LHS, RHS, Loc, /*IsCompare=*/false);
 
   if (LHS.get()->getType()->isVectorType() ||
@@ -11594,7 +11587,8 @@ QualType Sema::CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS,
                             /*AllowBoolConversions*/ getLangOpts().ZVector,
                             /*AllowBooleanOperation*/ false,
                             /*ReportInvalid*/ true);
-    if (CompLHSTy) *CompLHSTy = compType;
+    if (CompLHSTy)
+      *CompLHSTy = compType;
     return compType;
   }
 
@@ -11630,7 +11624,8 @@ QualType Sema::CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS,
 
   // handle the common case first (both operands are arithmetic).
   if (!compType.isNull() && compType->isArithmeticType()) {
-    if (CompLHSTy) *CompLHSTy = compType;
+    if (CompLHSTy)
+      *CompLHSTy = compType;
     return compType;
   }
 
@@ -11665,10 +11660,9 @@ QualType Sema::CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS,
           Context, Expr::NPC_ValueDependentIsNotNull)) {
     // In C++ adding zero to a null pointer is defined.
     Expr::EvalResult KnownVal;
-    if (!getLangOpts().CPlusPlus ||
-        (!IExp->isValueDependent() &&
-         (!IExp->EvaluateAsInt(KnownVal, Context) ||
-          KnownVal.Val.getInt() != 0))) {
+    if (!getLangOpts().CPlusPlus || (!IExp->isValueDependent() &&
+                                     (!IExp->EvaluateAsInt(KnownVal, Context) ||
+                                      KnownVal.Val.getInt() != 0))) {
       // Check the conditions to see if this is the 'p = nullptr + n' idiom.
       bool IsGNUIdiom = BinaryOperator::isNullPointerArithmeticExtension(
           Context, BO_Add, PExp, IExp);
@@ -11721,7 +11715,8 @@ QualType Sema::CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS,
                             /*AllowBoolConversions*/ getLangOpts().ZVector,
                             /*AllowBooleanOperation*/ false,
                             /*ReportInvalid*/ true);
-    if (CompLHSTy) *CompLHSTy = compType;
+    if (CompLHSTy)
+      *CompLHSTy = compType;
     return compType;
   }
 
@@ -11753,7 +11748,8 @@ QualType Sema::CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS,
 
   // Handle the common case first (both operands are arithmetic).
   if (!compType.isNull() && compType->isArithmeticType()) {
-    if (CompLHSTy) *CompLHSTy = compType;
+    if (CompLHSTy)
+      *CompLHSTy = compType;
     return compType;
   }
 
@@ -11780,8 +11776,8 @@ QualType Sema::CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS,
       // Subtracting from a null pointer should produce a warning.
       // The last argument to the diagnose call says this doesn't match the
       // GNU int-to-pointer idiom.
-      if (LHS.get()->IgnoreParenCasts()->isNullPointerConstant(Context,
-                                           Expr::NPC_ValueDependentIsNotNull)) {
+      if (LHS.get()->IgnoreParenCasts()->isNullPointerConstant(
+              Context, Expr::NPC_ValueDependentIsNotNull)) {
         // In C++ adding zero to a null pointer is defined.
         Expr::EvalResult KnownVal;
         if (!getLangOpts().CPlusPlus ||
@@ -11796,16 +11792,17 @@ QualType Sema::CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS,
         return QualType();
 
       // Check array bounds for pointer arithemtic
-      CheckArrayAccess(LHS.get(), RHS.get(), /*ArraySubscriptExpr*/nullptr,
-                       /*AllowOnePastEnd*/true, /*IndexNegated*/true);
+      CheckArrayAccess(LHS.get(), RHS.get(), /*ArraySubscriptExpr*/ nullptr,
+                       /*AllowOnePastEnd*/ true, /*IndexNegated*/ true);
 
-      if (CompLHSTy) *CompLHSTy = LHS.get()->getType();
+      if (CompLHSTy)
+        *CompLHSTy = LHS.get()->getType();
       return LHS.get()->getType();
     }
 
     // Handle pointer-pointer subtractions.
-    if (const PointerType *RHSPTy
-          = RHS.get()->getType()->getAs<PointerType>()) {
+    if (const PointerType *RHSPTy =
+            RHS.get()->getType()->getAs<PointerType>()) {
       QualType rpointee = RHSPTy->getPointeeType();
 
       if (getLangOpts().CPlusPlus) {
@@ -11823,8 +11820,8 @@ QualType Sema::CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS,
         }
       }
 
-      if (!checkArithmeticBinOpPointerOperands(*this, Loc,
-                                               LHS.get(), RHS.get()))
+      if (!checkArithmeticBinOpPointerOperands(*this, Loc, LHS.get(),
+                                               RHS.get()))
         return QualType();
 
       bool LHSIsNullPtr = LHS.get()->IgnoreParenCasts()->isNullPointerConstant(
@@ -11844,13 +11841,14 @@ QualType Sema::CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS,
       if (!rpointee->isVoidType() && !rpointee->isFunctionType()) {
         CharUnits ElementSize = Context.getTypeSizeInChars(rpointee);
         if (ElementSize.isZero()) {
-          Diag(Loc,diag::warn_sub_ptr_zero_size_types)
-            << rpointee.getUnqualifiedType()
-            << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+          Diag(Loc, diag::warn_sub_ptr_zero_size_types)
+              << rpointee.getUnqualifiedType() << LHS.get()->getSourceRange()
+              << RHS.get()->getSourceRange();
         }
       }
 
-      if (CompLHSTy) *CompLHSTy = LHS.get()->getType();
+      if (CompLHSTy)
+        *CompLHSTy = LHS.get()->getType();
       return Context.getPointerDiffType();
     }
   }
@@ -11866,11 +11864,12 @@ static bool isScopedEnumerationType(QualType T) {
   return false;
 }
 
-static void DiagnoseBadShiftValues(Sema& S, ExprResult &LHS, ExprResult &RHS,
+static void DiagnoseBadShiftValues(Sema &S, ExprResult &LHS, ExprResult &RHS,
                                    SourceLocation Loc, BinaryOperatorKind Opc,
                                    QualType LHSType) {
-  // OpenCL 6.3j: shift values are effectively % word size of LHS (more defined),
-  // so skip remaining warnings as we don't want to modify values within Sema.
+  // OpenCL 6.3j: shift values are effectively % word size of LHS (more
+  // defined), so skip remaining warnings as we don't want to modify values
+  // within Sema.
   if (S.getLangOpts().OpenCL)
     return;
 
@@ -11958,8 +11957,8 @@ static void DiagnoseBadShiftValues(Sema& S, ExprResult &LHS, ExprResult &RHS,
   // turned off separately if needed.
   if (ResultBits - 1 == LeftSize) {
     S.Diag(Loc, diag::warn_shift_result_sets_sign_bit)
-        << HexResult << LHSType
-        << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+        << HexResult << LHSType << LHS.get()->getSourceRange()
+        << RHS.get()->getSourceRange();
     return;
   }
 
@@ -11977,18 +11976,20 @@ static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS,
   if ((S.LangOpts.OpenCL || S.LangOpts.ZVector) &&
       !LHS.get()->getType()->isVectorType()) {
     S.Diag(Loc, diag::err_shift_rhs_only_vector)
-      << RHS.get()->getType() << LHS.get()->getType()
-      << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+        << RHS.get()->getType() << LHS.get()->getType()
+        << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
     return QualType();
   }
 
   if (!IsCompAssign) {
     LHS = S.UsualUnaryConversions(LHS.get());
-    if (LHS.isInvalid()) return QualType();
+    if (LHS.isInvalid())
+      return QualType();
   }
 
   RHS = S.UsualUnaryConversions(RHS.get());
-  if (RHS.isInvalid()) return QualType();
+  if (RHS.isInvalid())
+    return QualType();
 
   QualType LHSType = LHS.get()->getType();
   // Note that LHS might be a scalar because the routine calls not only in
@@ -12013,13 +12014,13 @@ static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS,
   // The operands need to be integers.
   if (!LHSEleType->isIntegerType()) {
     S.Diag(Loc, diag::err_typecheck_expect_int)
-      << LHS.get()->getType() << LHS.get()->getSourceRange();
+        << LHS.get()->getType() << LHS.get()->getSourceRange();
     return QualType();
   }
 
   if (!RHSEleType->isIntegerType()) {
     S.Diag(Loc, diag::err_typecheck_expect_int)
-      << RHS.get()->getType() << RHS.get()->getSourceRange();
+        << RHS.get()->getType() << RHS.get()->getSourceRange();
     return QualType();
   }
 
@@ -12028,7 +12029,7 @@ static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS,
     if (IsCompAssign)
       return RHSType;
     if (LHSEleType != RHSEleType) {
-      LHS = S.ImpCastExprToType(LHS.get(),RHSEleType, CK_IntegralCast);
+      LHS = S.ImpCastExprToType(LHS.get(), RHSEleType, CK_IntegralCast);
       LHSEleType = RHSEleType;
     }
     QualType VecTy =
@@ -12041,8 +12042,8 @@ static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS,
     // that the number of elements is the same as LHS...
     if (RHSVecTy->getNumElements() != LHSVecTy->getNumElements()) {
       S.Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
-        << LHS.get()->getType() << RHS.get()->getType()
-        << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+          << LHS.get()->getType() << RHS.get()->getType()
+          << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
       return QualType();
     }
     if (!S.LangOpts.OpenCL && !S.LangOpts.ZVector) {
@@ -12058,7 +12059,7 @@ static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS,
   } else {
     // ...else expand RHS to match the number of elements in LHS.
     QualType VecTy =
-      S.Context.getExtVectorType(RHSEleType, LHSVecTy->getNumElements());
+        S.Context.getExtVectorType(RHSEleType, LHSVecTy->getNumElements());
     RHS = S.ImpCastExprToType(RHS.get(), VecTy, CK_VectorSplat);
   }
 
@@ -12193,7 +12194,8 @@ QualType Sema::CheckShiftOperands(ExprResult &LHS, ExprResult &RHS,
   if (LHS.isInvalid())
     return QualType();
   QualType LHSType = LHS.get()->getType();
-  if (IsCompAssign) LHS = OldLHS;
+  if (IsCompAssign)
+    LHS = OldLHS;
 
   // The RHS is simpler.
   RHS = UsualUnaryConversions(RHS.get());
@@ -12223,8 +12225,8 @@ static void diagnoseDistinctPointerComparison(Sema &S, SourceLocation Loc,
                                               bool IsError) {
   S.Diag(Loc, IsError ? diag::err_typecheck_comparison_of_distinct_pointers
                       : diag::ext_typecheck_comparison_of_distinct_pointers)
-    << LHS.get()->getType() << RHS.get()->getType()
-    << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+      << LHS.get()->getType() << RHS.get()->getType()
+      << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
 }
 
 /// Returns false if the pointers are converted to a composite type,
@@ -12249,7 +12251,7 @@ static bool convertPointersToCompositeType(Sema &S, SourceLocation Loc,
   if (T.isNull()) {
     if ((LHSType->isAnyPointerType() || LHSType->isMemberPointerType()) &&
         (RHSType->isAnyPointerType() || RHSType->isMemberPointerType()))
-      diagnoseDistinctPointerComparison(S, Loc, LHS, RHS, /*isError*/true);
+      diagnoseDistinctPointerComparison(S, Loc, LHS, RHS, /*isError*/ true);
     else
       S.InvalidOperands(Loc, LHS, RHS);
     return true;
@@ -12264,8 +12266,8 @@ static void diagnoseFunctionPointerToVoidComparison(Sema &S, SourceLocation Loc,
                                                     bool IsError) {
   S.Diag(Loc, IsError ? diag::err_typecheck_comparison_of_fptr_to_void
                       : diag::ext_typecheck_comparison_of_fptr_to_void)
-    << LHS.get()->getType() << RHS.get()->getType()
-    << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+      << LHS.get()->getType() << RHS.get()->getType()
+      << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
 }
 
 static bool isObjCObjectLiteral(ExprResult &E) {
@@ -12283,7 +12285,7 @@ static bool isObjCObjectLiteral(ExprResult &E) {
 
 static bool hasIsEqualMethod(Sema &S, const Expr *LHS, const Expr *RHS) {
   const ObjCObjectPointerType *Type =
-    LHS->getType()->getAs<ObjCObjectPointerType>();
+      LHS->getType()->getAs<ObjCObjectPointerType>();
 
   // If this is not actually an Objective-C object, bail out.
   if (!Type)
@@ -12330,7 +12332,7 @@ static bool hasIsEqualMethod(Sema &S, const Expr *LHS, const Expr *RHS) {
 
 static void diagnoseObjCLiteralComparison(Sema &S, SourceLocation Loc,
                                           ExprResult &LHS, ExprResult &RHS,
-                                          BinaryOperator::Opcode Opc){
+                                          BinaryOperator::Opcode Opc) {
   Expr *Literal;
   Expr *Other;
   if (isObjCObjectLiteral(LHS)) {
@@ -12358,22 +12360,22 @@ static void diagnoseObjCLiteralComparison(Sema &S, SourceLocation Loc,
 
   if (LiteralKind == SemaObjC::LK_String)
     S.Diag(Loc, diag::warn_objc_string_literal_comparison)
-      << Literal->getSourceRange();
+        << Literal->getSourceRange();
   else
     S.Diag(Loc, diag::warn_objc_literal_comparison)
-      << LiteralKind << Literal->getSourceRange();
+        << LiteralKind << Literal->getSourceRange();
 
   if (BinaryOperator::isEqualityOp(Opc) &&
       hasIsEqualMethod(S, LHS.get(), RHS.get())) {
     SourceLocation Start = LHS.get()->getBeginLoc();
     SourceLocation End = S.getLocForEndOfToken(RHS.get()->getEndLoc());
     CharSourceRange OpRange =
-      CharSourceRange::getCharRange(Loc, S.getLocForEndOfToken(Loc));
+        CharSourceRange::getCharRange(Loc, S.getLocForEndOfToken(Loc));
 
     S.Diag(Loc, diag::note_objc_literal_comparison_isequal)
-      << FixItHint::CreateInsertion(Start, Opc == BO_EQ ? "[" : "![")
-      << FixItHint::CreateReplacement(OpRange, " isEqual:")
-      << FixItHint::CreateInsertion(End, "]");
+        << FixItHint::CreateInsertion(Start, Opc == BO_EQ ? "[" : "![")
+        << FixItHint::CreateReplacement(OpRange, " isEqual:")
+        << FixItHint::CreateInsertion(End, "]");
   }
 }
 
@@ -12383,14 +12385,17 @@ static void diagnoseLogicalNotOnLHSofCheck(Sema &S, ExprResult &LHS,
                                            BinaryOperatorKind Opc) {
   // Check that left hand side is !something.
   UnaryOperator *UO = dyn_cast<UnaryOperator>(LHS.get()->IgnoreImpCasts());
-  if (!UO || UO->getOpcode() != UO_LNot) return;
+  if (!UO || UO->getOpcode() != UO_LNot)
+    return;
 
   // Only check if the right hand side is non-bool arithmetic type.
-  if (RHS.get()->isKnownToHaveBooleanValue()) return;
+  if (RHS.get()->isKnownToHaveBooleanValue())
+    return;
 
   // Make sure that the something in !something is not bool.
   Expr *SubExpr = UO->getSubExpr()->IgnoreImpCasts();
-  if (SubExpr->isKnownToHaveBooleanValue()) return;
+  if (SubExpr->isKnownToHaveBooleanValue())
+    return;
 
   // Emit warning.
   bool IsBitwiseOp = Opc == BO_And || Opc == BO_Or || Opc == BO_Xor;
@@ -12404,8 +12409,7 @@ static void diagnoseLogicalNotOnLHSofCheck(Sema &S, ExprResult &LHS,
   if (FirstClose.isInvalid())
     FirstOpen = SourceLocation();
   S.Diag(UO->getOperatorLoc(), diag::note_logical_not_fix)
-      << IsBitwiseOp
-      << FixItHint::CreateInsertion(FirstOpen, "(")
+      << IsBitwiseOp << FixItHint::CreateInsertion(FirstOpen, "(")
       << FixItHint::CreateInsertion(FirstClose, ")");
 
   // Second note suggests (!x) < y
@@ -12612,8 +12616,8 @@ static void diagnoseTautologicalComparison(Sema &S, SourceLocation Loc,
     LiteralStringStripped = LHSStripped;
   } else if ((isa<StringLiteral>(RHSStripped) ||
               isa<ObjCEncodeExpr>(RHSStripped)) &&
-             !LHSStripped->isNullPointerConstant(S.Context,
-                                          Expr::NPC_ValueDependentIsNull)) {
+             !LHSStripped->isNullPointerConstant(
+                 S.Context, Expr::NPC_ValueDependentIsNull)) {
     LiteralString = RHS;
     LiteralStringStripped = RHSStripped;
   }
@@ -12829,7 +12833,7 @@ void Sema::CheckPtrComparisonWithNullChar(ExprResult &E, ExprResult &NullE) {
   if (!E.get()->getType()->isAnyPointerType() &&
       E.get()->isNullPointerConstant(Context,
                                      Expr::NPC_ValueDependentIsNotNull) ==
-        Expr::NPCK_ZeroExpression) {
+          Expr::NPCK_ZeroExpression) {
     if (const auto *CL = dyn_cast<CharacterLiteral>(E.get())) {
       if (CL->getValue() == 0)
         Diag(E.get()->getExprLoc(), diag::warn_pointer_compare)
@@ -12837,14 +12841,14 @@ void Sema::CheckPtrComparisonWithNullChar(ExprResult &E, ExprResult &NullE) {
             << FixItHint::CreateReplacement(E.get()->getExprLoc(),
                                             NullValue ? "NULL" : "(void *)0");
     } else if (const auto *CE = dyn_cast<CStyleCastExpr>(E.get())) {
-        TypeSourceInfo *TI = CE->getTypeInfoAsWritten();
-        QualType T = Context.getCanonicalType(TI->getType()).getUnqualifiedType();
-        if (T == Context.CharTy)
-          Diag(E.get()->getExprLoc(), diag::warn_pointer_compare)
-              << NullValue
-              << FixItHint::CreateReplacement(E.get()->getExprLoc(),
-                                              NullValue ? "NULL" : "(void *)0");
-      }
+      TypeSourceInfo *TI = CE->getTypeInfoAsWritten();
+      QualType T = Context.getCanonicalType(TI->getType()).getUnqualifiedType();
+      if (T == Context.CharTy)
+        Diag(E.get()->getExprLoc(), diag::warn_pointer_compare)
+            << NullValue
+            << FixItHint::CreateReplacement(E.get()->getExprLoc(),
+                                            NullValue ? "NULL" : "(void *)0");
+    }
   }
 }
 
@@ -12946,8 +12950,8 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
         *CCT, Loc, ComparisonCategoryUsage::OperatorInExpression);
   };
 
-  if(LHSType->isMetaInfoType() && RHSType->isMetaInfoType()){
-    if(!BinaryOperator::isEqualityOp(Opc)) {
+  if (LHSType->isMetaInfoType() && RHSType->isMetaInfoType()) {
+    if (!BinaryOperator::isEqualityOp(Opc)) {
       return InvalidOperands(Loc, LHS, RHS);
     }
     return computeResultTy();
@@ -13028,9 +13032,9 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
     // All of the following pointer-related warnings are GCC extensions, except
     // when handling null pointer constants.
     QualType LCanPointeeTy =
-      LHSType->castAs<PointerType>()->getPointeeType().getCanonicalType();
+        LHSType->castAs<PointerType>()->getPointeeType().getCanonicalType();
     QualType RCanPointeeTy =
-      RHSType->castAs<PointerType>()->getPointeeType().getCanonicalType();
+        RHSType->castAs<PointerType>()->getPointeeType().getCanonicalType();
 
     // C99 6.5.9p2 and C99 6.5.8p2
     if (Context.typesAreCompatible(LCanPointeeTy.getUnqualifiedType(),
@@ -13049,13 +13053,15 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
     } else if (!IsRelational &&
                (LCanPointeeTy->isVoidType() || RCanPointeeTy->isVoidType())) {
       // Valid unless comparison between non-null pointer and function pointer
-      if ((LCanPointeeTy->isFunctionType() || RCanPointeeTy->isFunctionType())
-          && !LHSIsNull && !RHSIsNull)
+      if ((LCanPointeeTy->isFunctionType() ||
+           RCanPointeeTy->isFunctionType()) &&
+          !LHSIsNull && !RHSIsNull)
         diagnoseFunctionPointerToVoidComparison(*this, Loc, LHS, RHS,
-                                                /*isError*/false);
+                                                /*isError*/ false);
     } else {
       // Invalid
-      diagnoseDistinctPointerComparison(*this, Loc, LHS, RHS, /*isError*/false);
+      diagnoseDistinctPointerComparison(*this, Loc, LHS, RHS,
+                                        /*isError*/ false);
     }
     if (LCanPointeeTy != RCanPointeeTy) {
       // Treat NULL constant as a special case in OpenCL.
@@ -13070,8 +13076,8 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
       }
       LangAS AddrSpaceL = LCanPointeeTy.getAddressSpace();
       LangAS AddrSpaceR = RCanPointeeTy.getAddressSpace();
-      CastKind Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion
-                                               : CK_BitCast;
+      CastKind Kind =
+          AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
 
       const FunctionType *LFn = LCanPointeeTy->getAs<FunctionType>();
       const FunctionType *RFn = RCanPointeeTy->getAs<FunctionType>();
@@ -13088,7 +13094,6 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
     return computeResultTy();
   }
 
-
   // C++ [expr.eq]p4:
   //   Two operands of type std::nullptr_t or one operand of type
   //   std::nullptr_t and the other a null pointer constant compare
@@ -13183,34 +13188,36 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
     if (!LHSIsNull && !RHSIsNull &&
         !Context.typesAreCompatible(lpointee, rpointee)) {
       Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
-        << LHSType << RHSType << LHS.get()->getSourceRange()
-        << RHS.get()->getSourceRange();
+          << LHSType << RHSType << LHS.get()->getSourceRange()
+          << RHS.get()->getSourceRange();
     }
     RHS = ImpCastExprToType(RHS.get(), LHSType, CK_BitCast);
     return computeResultTy();
   }
 
   // Allow block pointers to be compared with null pointer constants.
-  if (!IsOrdered
-      && ((LHSType->isBlockPointerType() && RHSType->isPointerType())
-          || (LHSType->isPointerType() && RHSType->isBlockPointerType()))) {
+  if (!IsOrdered &&
+      ((LHSType->isBlockPointerType() && RHSType->isPointerType()) ||
+       (LHSType->isPointerType() && RHSType->isBlockPointerType()))) {
     if (!LHSIsNull && !RHSIsNull) {
-      if (!((RHSType->isPointerType() && RHSType->castAs<PointerType>()
-             ->getPointeeType()->isVoidType())
-            || (LHSType->isPointerType() && LHSType->castAs<PointerType>()
-                ->getPointeeType()->isVoidType())))
+      if (!((RHSType->isPointerType() &&
+             RHSType->castAs<PointerType>()->getPointeeType()->isVoidType()) ||
+            (LHSType->isPointerType() &&
+             LHSType->castAs<PointerType>()->getPointeeType()->isVoidType())))
         Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
-          << LHSType << RHSType << LHS.get()->getSourceRange()
-          << RHS.get()->getSourceRange();
+            << LHSType << RHSType << LHS.get()->getSourceRange()
+            << RHS.get()->getSourceRange();
     }
     if (LHSIsNull && !RHSIsNull)
       LHS = ImpCastExprToType(LHS.get(), RHSType,
-                              RHSType->isPointerType() ? CK_BitCast
-                                : CK_AnyPointerToBlockPointerCast);
+                              RHSType->isPointerType()
+                                  ? CK_BitCast
+                                  : CK_AnyPointerToBlockPointerCast);
     else
       RHS = ImpCastExprToType(RHS.get(), LHSType,
-                              LHSType->isPointerType() ? CK_BitCast
-                                : CK_AnyPointerToBlockPointerCast);
+                              LHSType->isPointerType()
+                                  ? CK_BitCast
+                                  : CK_AnyPointerToBlockPointerCast);
     return computeResultTy();
   }
 
@@ -13225,7 +13232,7 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
       if (!LPtrToVoid && !RPtrToVoid &&
           !Context.typesAreCompatible(LHSType, RHSType)) {
         diagnoseDistinctPointerComparison(*this, Loc, LHS, RHS,
-                                          /*isError*/false);
+                                          /*isError*/ false);
       }
       // FIXME: If LPtrToVoid, we should presumably convert the LHS rather than
       // the RHS, but we have test coverage for this behavior.
@@ -13235,18 +13242,17 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
         if (getLangOpts().ObjCAutoRefCount)
           ObjC().CheckObjCConversion(SourceRange(), RHSType, E,
                                      CheckedConversionKind::Implicit);
-        LHS = ImpCastExprToType(E, RHSType,
-                                RPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
-      }
-      else {
+        LHS = ImpCastExprToType(
+            E, RHSType, RPT ? CK_BitCast : CK_CPointerToObjCPointerCast);
+      } else {
         Expr *E = RHS.get();
         if (getLangOpts().ObjCAutoRefCount)
           ObjC().CheckObjCConversion(SourceRange(), LHSType, E,
                                      CheckedConversionKind::Implicit,
                                      /*Diagnose=*/true,
                                      /*DiagnoseCFAudited=*/false, Opc);
-        RHS = ImpCastExprToType(E, LHSType,
-                                LPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
+        RHS = ImpCastExprToType(
+            E, LHSType, LPT ? CK_BitCast : CK_CPointerToObjCPointerCast);
       }
       return computeResultTy();
     }
@@ -13254,7 +13260,7 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
         RHSType->isObjCObjectPointerType()) {
       if (!Context.areComparableObjCPointerTypes(LHSType, RHSType))
         diagnoseDistinctPointerComparison(*this, Loc, LHS, RHS,
-                                          /*isError*/false);
+                                          /*isError*/ false);
       if (isObjCObjectLiteral(LHS) || isObjCObjectLiteral(RHS))
         diagnoseObjCLiteralComparison(*this, Loc, LHS, RHS, Opc);
 
@@ -13290,8 +13296,9 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
       if (IsOrdered) {
         isError = getLangOpts().CPlusPlus;
         DiagID =
-          isError ? diag::err_typecheck_ordered_comparison_of_pointer_and_zero
-                  : diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
+            isError
+                ? diag::err_typecheck_ordered_comparison_of_pointer_and_zero
+                : diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
       }
     } else if (getLangOpts().CPlusPlus) {
       DiagID = diag::err_typecheck_comparison_of_pointer_integer;
@@ -13302,30 +13309,31 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
       DiagID = diag::ext_typecheck_comparison_of_pointer_integer;
 
     if (DiagID) {
-      Diag(Loc, DiagID)
-        << LHSType << RHSType << LHS.get()->getSourceRange()
-        << RHS.get()->getSourceRange();
+      Diag(Loc, DiagID) << LHSType << RHSType << LHS.get()->getSourceRange()
+                        << RHS.get()->getSourceRange();
       if (isError)
         return QualType();
     }
 
     if (LHSType->isIntegerType())
       LHS = ImpCastExprToType(LHS.get(), RHSType,
-                        LHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
+                              LHSIsNull ? CK_NullToPointer
+                                        : CK_IntegralToPointer);
     else
       RHS = ImpCastExprToType(RHS.get(), LHSType,
-                        RHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
+                              RHSIsNull ? CK_NullToPointer
+                                        : CK_IntegralToPointer);
     return computeResultTy();
   }
 
   // Handle block pointers.
-  if (!IsOrdered && RHSIsNull
-      && LHSType->isBlockPointerType() && RHSType->isIntegerType()) {
+  if (!IsOrdered && RHSIsNull && LHSType->isBlockPointerType() &&
+      RHSType->isIntegerType()) {
     RHS = ImpCastExprToType(RHS.get(), LHSType, CK_NullToPointer);
     return computeResultTy();
   }
-  if (!IsOrdered && LHSIsNull
-      && LHSType->isIntegerType() && RHSType->isBlockPointerType()) {
+  if (!IsOrdered && LHSIsNull && LHSType->isIntegerType() &&
+      RHSType->isBlockPointerType()) {
     LHS = ImpCastExprToType(LHS.get(), RHSType, CK_NullToPointer);
     return computeResultTy();
   }
@@ -13980,11 +13988,14 @@ inline QualType Sema::CheckLogicalOperands(ExprResult &LHS, ExprResult &RHS,
 
 static bool IsReadonlyMessage(Expr *E, Sema &S) {
   const MemberExpr *ME = dyn_cast<MemberExpr>(E);
-  if (!ME) return false;
-  if (!isa<FieldDecl>(ME->getMemberDecl())) return false;
+  if (!ME)
+    return false;
+  if (!isa<FieldDecl>(ME->getMemberDecl()))
+    return false;
   ObjCMessageExpr *Base = dyn_cast<ObjCMessageExpr>(
       ME->getBase()->IgnoreImplicit()->IgnoreParenImpCasts());
-  if (!Base) return false;
+  if (!Base)
+    return false;
   return Base->getMethodDecl() != nullptr;
 }
 
@@ -13998,8 +14009,10 @@ static NonConstCaptureKind isReferenceToNonConstCapture(Sema &S, Expr *E) {
 
   // Must be a reference to a declaration from an enclosing scope.
   DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E);
-  if (!DRE) return NCCK_None;
-  if (!DRE->refersToEnclosingVariableOrCapture()) return NCCK_None;
+  if (!DRE)
+    return NCCK_None;
+  if (!DRE->refersToEnclosingVariableOrCapture())
+    return NCCK_None;
 
   ValueDecl *Value = DRE->getDecl();
 
@@ -14138,8 +14151,8 @@ static void DiagnoseConstAssignment(Sema &S, const Expr *E,
     const FunctionDecl *FD = CE->getDirectCallee();
     if (FD && !IsTypeModifiable(FD->getReturnType(), IsDereference)) {
       if (!DiagnosticEmitted) {
-        S.Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
-                                                      << ConstFunction << FD;
+        S.Diag(Loc, diag::err_typecheck_assign_const)
+            << ExprRange << ConstFunction << FD;
         DiagnosticEmitted = true;
       }
       S.Diag(FD->getReturnTypeSourceRange().getBegin(),
@@ -14183,11 +14196,7 @@ static void DiagnoseConstAssignment(Sema &S, const Expr *E,
   S.Diag(Loc, diag::err_typecheck_assign_const) << ExprRange << ConstUnknown;
 }
 
-enum OriginalExprKind {
-  OEK_Variable,
-  OEK_Member,
-  OEK_LValue
-};
+enum OriginalExprKind { OEK_Variable, OEK_Member, OEK_LValue };
 
 static void DiagnoseRecursiveConstFields(Sema &S, const ValueDecl *VD,
                                          const RecordType *Ty,
@@ -14210,13 +14219,12 @@ static void DiagnoseRecursiveConstFields(Sema &S, const ValueDecl *VD,
       if (FieldTy.isConstQualified()) {
         if (!DiagnosticEmitted) {
           S.Diag(Loc, diag::err_typecheck_assign_const)
-              << Range << NestedConstMember << OEK << VD
-              << IsNested << Field;
+              << Range << NestedConstMember << OEK << VD << IsNested << Field;
           DiagnosticEmitted = true;
         }
         S.Diag(Field->getLocation(), diag::note_typecheck_assign_const)
-            << NestedConstMember << IsNested << Field
-            << FieldTy << Field->getSourceRange();
+            << NestedConstMember << IsNested << Field << FieldTy
+            << Field->getSourceRange();
       }
 
       // Then we append it to the list to check next in order.
@@ -14241,14 +14249,14 @@ static void DiagnoseRecursiveConstFields(Sema &S, const Expr *E,
   bool DiagEmitted = false;
 
   if (const MemberExpr *ME = dyn_cast<MemberExpr>(E))
-    DiagnoseRecursiveConstFields(S, ME->getMemberDecl(), RTy, Loc,
-            Range, OEK_Member, DiagEmitted);
+    DiagnoseRecursiveConstFields(S, ME->getMemberDecl(), RTy, Loc, Range,
+                                 OEK_Member, DiagEmitted);
   else if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
-    DiagnoseRecursiveConstFields(S, DRE->getDecl(), RTy, Loc,
-            Range, OEK_Variable, DiagEmitted);
+    DiagnoseRecursiveConstFields(S, DRE->getDecl(), RTy, Loc, Range,
+                                 OEK_Variable, DiagEmitted);
   else
-    DiagnoseRecursiveConstFields(S, nullptr, RTy, Loc,
-            Range, OEK_LValue, DiagEmitted);
+    DiagnoseRecursiveConstFields(S, nullptr, RTy, Loc, Range, OEK_LValue,
+                                 DiagEmitted);
   if (!DiagEmitted)
     DiagnoseConstAssignment(S, E, Loc);
 }
@@ -14261,8 +14269,7 @@ static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S) {
   S.CheckShadowingDeclModification(E, Loc);
 
   SourceLocation OrigLoc = Loc;
-  Expr::isModifiableLvalueResult IsLV = E->isModifiableLvalue(S.Context,
-                                                              &Loc);
+  Expr::isModifiableLvalueResult IsLV = E->isModifiableLvalue(S.Context, &Loc);
   if (IsLV == Expr::MLV_ClassTemporary && IsReadonlyMessage(E, S))
     IsLV = Expr::MLV_InvalidMessageExpression;
   if (IsLV == Expr::MLV_Valid)
@@ -14299,15 +14306,15 @@ static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S) {
           ObjCMethodDecl *method = S.getCurMethodDecl();
           if (method && var == method->getSelfDecl()) {
             DiagID = method->isClassMethod()
-              ? diag::err_typecheck_arc_assign_self_class_method
-              : diag::err_typecheck_arc_assign_self;
+                         ? diag::err_typecheck_arc_assign_self_class_method
+                         : diag::err_typecheck_arc_assign_self;
 
-          //  - Objective-C externally_retained attribute.
+            //  - Objective-C externally_retained attribute.
           } else if (var->hasAttr<ObjCExternallyRetainedAttr>() ||
                      isa<ParmVarDecl>(var)) {
             DiagID = diag::err_typecheck_arc_assign_externally_retained;
 
-          //  - fast enumeration variables
+            //  - fast enumeration variables
           } else {
             DiagID = diag::err_typecheck_arr_assign_enumeration;
           }
@@ -14358,8 +14365,9 @@ static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S) {
     break;
   case Expr::MLV_IncompleteType:
   case Expr::MLV_IncompleteVoidType:
-    return S.RequireCompleteType(Loc, E->getType(),
-             diag::err_typecheck_incomplete_type_not_modifiable_lvalue, E);
+    return S.RequireCompleteType(
+        Loc, E->getType(),
+        diag::err_typecheck_incomplete_type_not_modifiable_lvalue, E);
   case Expr::MLV_DuplicateVectorComponents:
     DiagID = diag::err_typecheck_duplicate_vector_components_not_mlvalue;
     break;
@@ -14387,8 +14395,7 @@ static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S) {
 }
 
 static void CheckIdentityFieldAssignment(Expr *LHSExpr, Expr *RHSExpr,
-                                         SourceLocation Loc,
-                                         Sema &Sema) {
+                                         SourceLocation Loc, Sema &Sema) {
   if (Sema.inTemplateInstantiation())
     return;
   if (Sema.isUnevaluatedContext())
@@ -14442,8 +14449,8 @@ QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS,
     return QualType();
 
   QualType LHSType = LHSExpr->getType();
-  QualType RHSType = CompoundType.isNull() ? RHS.get()->getType() :
-                                             CompoundType;
+  QualType RHSType =
+      CompoundType.isNull() ? RHS.get()->getType() : CompoundType;
 
   if (RHS.isUsable()) {
     // Even if this check fails don't return early to allow the best
@@ -14470,8 +14477,8 @@ QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS,
   if (getLangOpts().OpenCL &&
       !getOpenCLOptions().isAvailableOption("cl_khr_fp16", getLangOpts()) &&
       LHSType->isHalfType()) {
-    Diag(Loc, diag::err_opencl_half_load_store) << 1
-        << LHSType.getUnqualifiedType();
+    Diag(Loc, diag::err_opencl_half_load_store)
+        << 1 << LHSType.getUnqualifiedType();
     return QualType();
   }
 
@@ -14517,8 +14524,8 @@ QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS,
           Loc.getLocWithOffset(2) != UO->getSubExpr()->getBeginLoc() &&
           UO->getSubExpr()->getBeginLoc().isFileID()) {
         Diag(Loc, diag::warn_not_compound_assign)
-          << (UO->getOpcode() == UO_Plus ? "+" : "-")
-          << SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc());
+            << (UO->getOpcode() == UO_Plus ? "+" : "-")
+            << SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc());
       }
     }
 
@@ -14718,7 +14725,7 @@ static QualType CheckIncrementDecrementOperand(Sema &S, Expr *Op,
     // Increment of bool sets it to true, but is deprecated.
     S.Diag(OpLoc, S.getLangOpts().CPlusPlus17 ? diag::ext_increment_bool
                                               : diag::warn_increment_bool)
-      << Op->getSourceRange();
+        << Op->getSourceRange();
   } else if (S.getLangOpts().CPlusPlus && ResType->isEnumeralType()) {
     // Error on enum increments and decrements in C++ mode
     S.Diag(OpLoc, diag::err_increment_decrement_enum) << IsInc << ResType;
@@ -14744,9 +14751,10 @@ static QualType CheckIncrementDecrementOperand(Sema &S, Expr *Op,
         << IsInc << Op->getSourceRange();
   } else if (ResType->isPlaceholderType()) {
     ExprResult PR = S.CheckPlaceholderExpr(Op);
-    if (PR.isInvalid()) return QualType();
-    return CheckIncrementDecrementOperand(S, PR.get(), VK, OK, OpLoc,
-                                          IsInc, IsPrefix);
+    if (PR.isInvalid())
+      return QualType();
+    return CheckIncrementDecrementOperand(S, PR.get(), VK, OK, OpLoc, IsInc,
+                                          IsPrefix);
   } else if (S.getLangOpts().AltiVec && ResType->isVectorType()) {
     // OK! ( C/C++ Language Extensions for CBEA(Version 2.6) 10.3 )
   } else if (S.getLangOpts().ZVector && ResType->isVectorType() &&
@@ -14758,7 +14766,7 @@ static QualType CheckIncrementDecrementOperand(Sema &S, Expr *Op,
     // OpenCL V1.2 6.3 says dec/inc ops operate on integer vector types.
   } else {
     S.Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
-      << ResType << int(IsInc) << Op->getSourceRange();
+        << ResType << int(IsInc) << Op->getSourceRange();
     return QualType();
   }
   // At this point, we know we have a real, complex or pointer type.
@@ -14814,8 +14822,8 @@ static ValueDecl *getPrimaryDecl(Expr *E) {
   case Stmt::ArraySubscriptExprClass: {
     // FIXME: This code shouldn't be necessary!  We should catch the implicit
     // promotion of register arrays earlier.
-    Expr* Base = cast<ArraySubscriptExpr>(E)->getBase();
-    if (ImplicitCastExpr* ICE = dyn_cast<ImplicitCastExpr>(Base)) {
+    Expr *Base = cast<ArraySubscriptExpr>(E)->getBase();
+    if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Base)) {
       if (ICE->getSubExpr()->getType()->isArrayType())
         return getPrimaryDecl(ICE->getSubExpr());
     }
@@ -14824,7 +14832,7 @@ static ValueDecl *getPrimaryDecl(Expr *E) {
   case Stmt::UnaryOperatorClass: {
     UnaryOperator *UO = cast<UnaryOperator>(E);
 
-    switch(UO->getOpcode()) {
+    switch (UO->getOpcode()) {
     case UO_Real:
     case UO_Imag:
     case UO_Extension:
@@ -14859,8 +14867,8 @@ enum {
 /// Diagnose invalid operand for address of operations.
 ///
 /// \param Type The type of operand which cannot have its address taken.
-static void diagnoseAddressOfInvalidType(Sema &S, SourceLocation Loc,
-                                         Expr *E, unsigned Type) {
+static void diagnoseAddressOfInvalidType(Sema &S, SourceLocation Loc, Expr *E,
+                                         unsigned Type) {
   S.Diag(Loc, diag::err_typecheck_address_of) << Type << E->getSourceRange();
 }
 
@@ -14893,13 +14901,14 @@ bool Sema::CheckUseOfCXXMethodAsAddressOfOperand(SourceLocation OpLoc,
 }
 
 QualType Sema::CheckAddressOfOperand(ExprResult &OrigOp, SourceLocation OpLoc) {
-  if (const BuiltinType *PTy = OrigOp.get()->getType()->getAsPlaceholderType()){
+  if (const BuiltinType *PTy =
+          OrigOp.get()->getType()->getAsPlaceholderType()) {
     if (PTy->getKind() == BuiltinType::Overload) {
       Expr *E = OrigOp.get()->IgnoreParens();
       if (!isa<OverloadExpr>(E)) {
         assert(cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf);
         Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof_addrof_function)
-          << OrigOp.get()->getSourceRange();
+            << OrigOp.get()->getSourceRange();
         return QualType();
       }
 
@@ -14907,7 +14916,7 @@ QualType Sema::CheckAddressOfOperand(ExprResult &OrigOp, SourceLocation OpLoc) {
       if (isa<UnresolvedMemberExpr>(Ovl))
         if (!ResolveSingleFunctionTemplateSpecialization(Ovl)) {
           Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
-            << OrigOp.get()->getSourceRange();
+              << OrigOp.get()->getSourceRange();
           return QualType();
         }
 
@@ -14919,12 +14928,13 @@ QualType Sema::CheckAddressOfOperand(ExprResult &OrigOp, SourceLocation OpLoc) {
 
     if (PTy->getKind() == BuiltinType::BoundMember) {
       Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
-        << OrigOp.get()->getSourceRange();
+          << OrigOp.get()->getSourceRange();
       return QualType();
     }
 
     OrigOp = CheckPlaceholderExpr(OrigOp.get());
-    if (OrigOp.isInvalid()) return QualType();
+    if (OrigOp.isInvalid())
+      return QualType();
   }
 
   if (OrigOp.get()->isTypeDependent())
@@ -14941,7 +14951,7 @@ QualType Sema::CheckAddressOfOperand(ExprResult &OrigOp, SourceLocation OpLoc) {
   // depending on a vendor implementation. Thus preventing
   // taking an address of the capture to avoid invalid AS casts.
   if (LangOpts.OpenCL) {
-    auto* VarRef = dyn_cast<DeclRefExpr>(op);
+    auto *VarRef = dyn_cast<DeclRefExpr>(op);
     if (VarRef && VarRef->refersToEnclosingVariableOrCapture()) {
       Diag(op->getExprLoc(), diag::err_opencl_taking_address_capture);
       return QualType();
@@ -14950,7 +14960,7 @@ QualType Sema::CheckAddressOfOperand(ExprResult &OrigOp, SourceLocation OpLoc) {
 
   if (getLangOpts().C99) {
     // Implement C99-only parts of addressof rules.
-    if (UnaryOperator* uOp = dyn_cast<UnaryOperator>(op)) {
+    if (UnaryOperator *uOp = dyn_cast<UnaryOperator>(op)) {
       if (uOp->getOpcode() == UO_Deref)
         // Per C99 6.5.3.2, the address of a deref always returns a valid result
         // (assuming the deref expression is valid).
@@ -14988,7 +14998,7 @@ QualType Sema::CheckAddressOfOperand(ExprResult &OrigOp, SourceLocation OpLoc) {
     // If the underlying expression isn't a decl ref, give up.
     if (!isa<DeclRefExpr>(op)) {
       Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
-        << OrigOp.get()->getSourceRange();
+          << OrigOp.get()->getSourceRange();
       return QualType();
     }
     DeclRefExpr *DRE = cast<DeclRefExpr>(op);
@@ -15043,7 +15053,7 @@ QualType Sema::CheckAddressOfOperand(ExprResult &OrigOp, SourceLocation OpLoc) {
         AddressOfError = AO_Property_Expansion;
       } else {
         Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof)
-          << op->getType() << op->getSourceRange();
+            << op->getType() << op->getSourceRange();
         return QualType();
       }
     } else if (const auto *DRE = dyn_cast<DeclRefExpr>(op)) {
@@ -15066,8 +15076,7 @@ QualType Sema::CheckAddressOfOperand(ExprResult &OrigOp, SourceLocation OpLoc) {
     if (const VarDecl *vd = dyn_cast<VarDecl>(dcl)) {
       // in C++ it is not error to take address of a register
       // variable (c++03 7.1.1P3)
-      if (vd->getStorageClass() == SC_Register &&
-          !getLangOpts().CPlusPlus) {
+      if (vd->getStorageClass() == SC_Register && !getLangOpts().CPlusPlus) {
         AddressOfError = AO_Register_Variable;
       }
     } else if (isa<MSPropertyDecl>(dcl)) {
@@ -15091,7 +15100,7 @@ QualType Sema::CheckAddressOfOperand(ExprResult &OrigOp, SourceLocation OpLoc) {
           if (dcl->getType()->isReferenceType()) {
             Diag(OpLoc,
                  diag::err_cannot_form_pointer_to_member_of_reference_type)
-              << dcl->getDeclName() << dcl->getType();
+                << dcl->getDeclName() << dcl->getType();
             return QualType();
           }
 
@@ -15158,7 +15167,7 @@ static void RecordModifiableNonNullParam(Sema &S, const Expr *Exp) {
   const ParmVarDecl *Param = dyn_cast<ParmVarDecl>(D);
   if (!Param)
     return;
-  if (const FunctionDecl* FD = dyn_cast<FunctionDecl>(Param->getDeclContext()))
+  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(Param->getDeclContext()))
     if (!FD->hasAttr<NonNullAttr>() && !Param->hasAttr<NonNullAttr>())
       return;
   if (FunctionScopeInfo *FD = S.getCurFunction())
@@ -15178,27 +15187,26 @@ static QualType CheckIndirectionOperand(Sema &S, Expr *Op, ExprValueKind &VK,
 
   if (isa<CXXReinterpretCastExpr>(Op->IgnoreParens())) {
     QualType OpOrigType = Op->IgnoreParenCasts()->getType();
-    S.CheckCompatibleReinterpretCast(OpOrigType, OpTy, /*IsDereference*/true,
+    S.CheckCompatibleReinterpretCast(OpOrigType, OpTy, /*IsDereference*/ true,
                                      Op->getSourceRange());
   }
 
-  if (const PointerType *PT = OpTy->getAs<PointerType>())
-  {
+  if (const PointerType *PT = OpTy->getAs<PointerType>()) {
     Result = PT->getPointeeType();
-  }
-  else if (const ObjCObjectPointerType *OPT =
-             OpTy->getAs<ObjCObjectPointerType>())
+  } else if (const ObjCObjectPointerType *OPT =
+                 OpTy->getAs<ObjCObjectPointerType>())
     Result = OPT->getPointeeType();
   else {
     ExprResult PR = S.CheckPlaceholderExpr(Op);
-    if (PR.isInvalid()) return QualType();
+    if (PR.isInvalid())
+      return QualType();
     if (PR.get() != Op)
       return CheckIndirectionOperand(S, PR.get(), VK, OpLoc);
   }
 
   if (Result.isNull()) {
     S.Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer)
-      << OpTy << Op->getSourceRange();
+        << OpTy << Op->getSourceRange();
     return QualType();
   }
 
@@ -15228,60 +15236,150 @@ static QualType CheckIndirectionOperand(Sema &S, Expr *Op, ExprValueKind &VK,
 BinaryOperatorKind Sema::ConvertTokenKindToBinaryOpcode(tok::TokenKind Kind) {
   BinaryOperatorKind Opc;
   switch (Kind) {
-  default: llvm_unreachable("Unknown binop!");
-  case tok::periodstar:           Opc = BO_PtrMemD; break;
-  case tok::arrowstar:            Opc = BO_PtrMemI; break;
-  case tok::star:                 Opc = BO_Mul; break;
-  case tok::slash:                Opc = BO_Div; break;
-  case tok::percent:              Opc = BO_Rem; break;
-  case tok::plus:                 Opc = BO_Add; break;
-  case tok::minus:                Opc = BO_Sub; break;
-  case tok::lessless:             Opc = BO_Shl; break;
-  case tok::greatergreater:       Opc = BO_Shr; break;
-  case tok::lessequal:            Opc = BO_LE; break;
-  case tok::less:                 Opc = BO_LT; break;
-  case tok::greaterequal:         Opc = BO_GE; break;
-  case tok::greater:              Opc = BO_GT; break;
-  case tok::exclaimequal:         Opc = BO_NE; break;
-  case tok::equalequal:           Opc = BO_EQ; break;
-  case tok::spaceship:            Opc = BO_Cmp; break;
-  case tok::amp:                  Opc = BO_And; break;
-  case tok::caret:                Opc = BO_Xor; break;
-  case tok::pipe:                 Opc = BO_Or; break;
-  case tok::ampamp:               Opc = BO_LAnd; break;
-  case tok::pipepipe:             Opc = BO_LOr; break;
-  case tok::equal:                Opc = BO_Assign; break;
-  case tok::starequal:            Opc = BO_MulAssign; break;
-  case tok::slashequal:           Opc = BO_DivAssign; break;
-  case tok::percentequal:         Opc = BO_RemAssign; break;
-  case tok::plusequal:            Opc = BO_AddAssign; break;
-  case tok::minusequal:           Opc = BO_SubAssign; break;
-  case tok::lesslessequal:        Opc = BO_ShlAssign; break;
-  case tok::greatergreaterequal:  Opc = BO_ShrAssign; break;
-  case tok::ampequal:             Opc = BO_AndAssign; break;
-  case tok::caretequal:           Opc = BO_XorAssign; break;
-  case tok::pipeequal:            Opc = BO_OrAssign; break;
-  case tok::comma:                Opc = BO_Comma; break;
+  default:
+    llvm_unreachable("Unknown binop!");
+  case tok::periodstar:
+    Opc = BO_PtrMemD;
+    break;
+  case tok::arrowstar:
+    Opc = BO_PtrMemI;
+    break;
+  case tok::star:
+    Opc = BO_Mul;
+    break;
+  case tok::slash:
+    Opc = BO_Div;
+    break;
+  case tok::percent:
+    Opc = BO_Rem;
+    break;
+  case tok::plus:
+    Opc = BO_Add;
+    break;
+  case tok::minus:
+    Opc = BO_Sub;
+    break;
+  case tok::lessless:
+    Opc = BO_Shl;
+    break;
+  case tok::greatergreater:
+    Opc = BO_Shr;
+    break;
+  case tok::lessequal:
+    Opc = BO_LE;
+    break;
+  case tok::less:
+    Opc = BO_LT;
+    break;
+  case tok::greaterequal:
+    Opc = BO_GE;
+    break;
+  case tok::greater:
+    Opc = BO_GT;
+    break;
+  case tok::exclaimequal:
+    Opc = BO_NE;
+    break;
+  case tok::equalequal:
+    Opc = BO_EQ;
+    break;
+  case tok::spaceship:
+    Opc = BO_Cmp;
+    break;
+  case tok::amp:
+    Opc = BO_And;
+    break;
+  case tok::caret:
+    Opc = BO_Xor;
+    break;
+  case tok::pipe:
+    Opc = BO_Or;
+    break;
+  case tok::ampamp:
+    Opc = BO_LAnd;
+    break;
+  case tok::pipepipe:
+    Opc = BO_LOr;
+    break;
+  case tok::equal:
+    Opc = BO_Assign;
+    break;
+  case tok::starequal:
+    Opc = BO_MulAssign;
+    break;
+  case tok::slashequal:
+    Opc = BO_DivAssign;
+    break;
+  case tok::percentequal:
+    Opc = BO_RemAssign;
+    break;
+  case tok::plusequal:
+    Opc = BO_AddAssign;
+    break;
+  case tok::minusequal:
+    Opc = BO_SubAssign;
+    break;
+  case tok::lesslessequal:
+    Opc = BO_ShlAssign;
+    break;
+  case tok::greatergreaterequal:
+    Opc = BO_ShrAssign;
+    break;
+  case tok::ampequal:
+    Opc = BO_AndAssign;
+    break;
+  case tok::caretequal:
+    Opc = BO_XorAssign;
+    break;
+  case tok::pipeequal:
+    Opc = BO_OrAssign;
+    break;
+  case tok::comma:
+    Opc = BO_Comma;
+    break;
   }
   return Opc;
 }
 
-static inline UnaryOperatorKind ConvertTokenKindToUnaryOpcode(
-  tok::TokenKind Kind) {
+static inline UnaryOperatorKind
+ConvertTokenKindToUnaryOpcode(tok::TokenKind Kind) {
   UnaryOperatorKind Opc;
   switch (Kind) {
-  default: llvm_unreachable("Unknown unary op!");
-  case tok::plusplus:     Opc = UO_PreInc; break;
-  case tok::minusminus:   Opc = UO_PreDec; break;
-  case tok::amp:          Opc = UO_AddrOf; break;
-  case tok::star:         Opc = UO_Deref; break;
-  case tok::plus:         Opc = UO_Plus; break;
-  case tok::minus:        Opc = UO_Minus; break;
-  case tok::tilde:        Opc = UO_Not; break;
-  case tok::exclaim:      Opc = UO_LNot; break;
-  case tok::kw___real:    Opc = UO_Real; break;
-  case tok::kw___imag:    Opc = UO_Imag; break;
-  case tok::kw___extension__: Opc = UO_Extension; break;
+  default:
+    llvm_unreachable("Unknown unary op!");
+  case tok::plusplus:
+    Opc = UO_PreInc;
+    break;
+  case tok::minusminus:
+    Opc = UO_PreDec;
+    break;
+  case tok::amp:
+    Opc = UO_AddrOf;
+    break;
+  case tok::star:
+    Opc = UO_Deref;
+    break;
+  case tok::plus:
+    Opc = UO_Plus;
+    break;
+  case tok::minus:
+    Opc = UO_Minus;
+    break;
+  case tok::tilde:
+    Opc = UO_Not;
+    break;
+  case tok::exclaim:
+    Opc = UO_LNot;
+    break;
+  case tok::kw___real:
+    Opc = UO_Real;
+    break;
+  case tok::kw___imag:
+    Opc = UO_Imag;
+    break;
+  case tok::kw___extension__:
+    Opc = UO_Extension;
+    break;
   }
   return Opc;
 }
@@ -15334,14 +15432,13 @@ static void DiagnoseSelfAssignment(Sema &S, Expr *LHSExpr, Expr *RHSExpr,
   RHSExpr = RHSExpr->IgnoreParenImpCasts();
   const DeclRefExpr *LHSDeclRef = dyn_cast<DeclRefExpr>(LHSExpr);
   const DeclRefExpr *RHSDeclRef = dyn_cast<DeclRefExpr>(RHSExpr);
-  if (!LHSDeclRef || !RHSDeclRef ||
-      LHSDeclRef->getLocation().isMacroID() ||
+  if (!LHSDeclRef || !RHSDeclRef || LHSDeclRef->getLocation().isMacroID() ||
       RHSDeclRef->getLocation().isMacroID())
     return;
   const ValueDecl *LHSDecl =
-    cast<ValueDecl>(LHSDeclRef->getDecl()->getCanonicalDecl());
+      cast<ValueDecl>(LHSDeclRef->getDecl()->getCanonicalDecl());
   const ValueDecl *RHSDecl =
-    cast<ValueDecl>(RHSDeclRef->getDecl()->getCanonicalDecl());
+      cast<ValueDecl>(RHSDeclRef->getDecl()->getCanonicalDecl());
   if (LHSDecl != RHSDecl)
     return;
   if (LHSDecl->getType().isVolatileQualified())
@@ -15376,8 +15473,7 @@ static void checkObjCPointerIntrospection(Sema &S, ExprResult &L, ExprResult &R,
   if (LHS->IgnoreParenCasts()->getType()->isObjCObjectPointerType()) {
     ObjCPointerExpr = LHS;
     OtherExpr = RHS;
-  }
-  else if (RHS->IgnoreParenCasts()->getType()->isObjCObjectPointerType()) {
+  } else if (RHS->IgnoreParenCasts()->getType()->isObjCObjectPointerType()) {
     ObjCPointerExpr = RHS;
     OtherExpr = LHS;
   }
@@ -15400,8 +15496,7 @@ static void checkObjCPointerIntrospection(Sema &S, ExprResult &L, ExprResult &R,
         Diag = diag::warn_objc_pointer_masking_performSelector;
     }
 
-    S.Diag(OpLoc, Diag)
-      << ObjCPointerExpr->getSourceRange();
+    S.Diag(OpLoc, Diag) << ObjCPointerExpr->getSourceRange();
   }
 }
 
@@ -15488,7 +15583,7 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
   }
 
   ExprResult LHS = LHSExpr, RHS = RHSExpr;
-  QualType ResultTy;     // Result type of the binary operator.
+  QualType ResultTy; // Result type of the binary operator.
   // The following two variables are used for compound assignment operators
   QualType CompLHSTy;    // Type of LHS after promotions for computation
   QualType CompResultTy; // Type of computation result
@@ -15515,9 +15610,8 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
 
     // OpenCL special types - image, sampler, pipe, and blocks are to be used
     // only with a builtin functions and therefore should be disallowed here.
-    if (LHSTy->isImageType() || RHSTy->isImageType() ||
-        LHSTy->isSamplerT() || RHSTy->isSamplerT() ||
-        LHSTy->isPipeType() || RHSTy->isPipeType() ||
+    if (LHSTy->isImageType() || RHSTy->isImageType() || LHSTy->isSamplerT() ||
+        RHSTy->isSamplerT() || LHSTy->isPipeType() || RHSTy->isPipeType() ||
         LHSTy->isBlockPointerType() || RHSTy->isBlockPointerType()) {
       ResultTy = InvalidOperands(OpLoc, LHS, RHS);
       return ExprError();
@@ -15566,8 +15660,8 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
     break;
   case BO_PtrMemD:
   case BO_PtrMemI:
-    ResultTy = CheckPointerToMemberOperands(LHS, RHS, VK, OpLoc,
-                                            Opc == BO_PtrMemI);
+    ResultTy =
+        CheckPointerToMemberOperands(LHS, RHS, VK, OpLoc, Opc == BO_PtrMemI);
     break;
   case BO_Mul:
   case BO_Div:
@@ -15699,10 +15793,11 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
   CheckArrayAccess(LHS.get());
   CheckArrayAccess(RHS.get());
 
-  if (const ObjCIsaExpr *OISA = dyn_cast<ObjCIsaExpr>(LHS.get()->IgnoreParenCasts())) {
-    NamedDecl *ObjectSetClass = LookupSingleName(TUScope,
-                                                 &Context.Idents.get("object_setClass"),
-                                                 SourceLocation(), LookupOrdinaryName);
+  if (const ObjCIsaExpr *OISA =
+          dyn_cast<ObjCIsaExpr>(LHS.get()->IgnoreParenCasts())) {
+    NamedDecl *ObjectSetClass =
+        LookupSingleName(TUScope, &Context.Idents.get("object_setClass"),
+                         SourceLocation(), LookupOrdinaryName);
     if (ObjectSetClass && isa<ObjCIsaExpr>(LHS.get())) {
       SourceLocation RHSLocEnd = getLocForEndOfToken(RHS.get()->getEndLoc());
       Diag(LHS.get()->getExprLoc(), diag::warn_objc_isa_assign)
@@ -15711,12 +15806,10 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
           << FixItHint::CreateReplacement(SourceRange(OISA->getOpLoc(), OpLoc),
                                           ",")
           << FixItHint::CreateInsertion(RHSLocEnd, ")");
-    }
-    else
+    } else
       Diag(LHS.get()->getExprLoc(), diag::warn_objc_isa_assign);
-  }
-  else if (const ObjCIvarRefExpr *OIRE =
-           dyn_cast<ObjCIvarRefExpr>(LHS.get()->IgnoreParenCasts()))
+  } else if (const ObjCIvarRefExpr *OIRE =
+                 dyn_cast<ObjCIvarRefExpr>(LHS.get()->IgnoreParenCasts()))
     DiagnoseDirectIsaAccess(*this, OIRE, OpLoc, RHS.get());
 
   // Opc is not a compound assignment if CompResultTy is null.
@@ -15729,8 +15822,8 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
   }
 
   // Handle compound assignments.
-  if (getLangOpts().CPlusPlus && LHS.get()->getObjectKind() !=
-      OK_ObjCProperty) {
+  if (getLangOpts().CPlusPlus &&
+      LHS.get()->getObjectKind() != OK_ObjCProperty) {
     VK = VK_LValue;
     OK = LHS.get()->getObjectKind();
   }
@@ -15783,29 +15876,29 @@ static void DiagnoseBitwisePrecedence(Sema &Self, BinaryOperatorKind Opc,
           : SourceRange(LHSExpr->getBeginLoc(), RHSBO->getLHS()->getEndLoc());
 
   Self.Diag(OpLoc, diag::warn_precedence_bitwise_rel)
-    << DiagRange << BinaryOperator::getOpcodeStr(Opc) << OpStr;
+      << DiagRange << BinaryOperator::getOpcodeStr(Opc) << OpStr;
   SuggestParentheses(Self, OpLoc,
-    Self.PDiag(diag::note_precedence_silence) << OpStr,
-    (isLeftComp ? LHSExpr : RHSExpr)->getSourceRange());
+                     Self.PDiag(diag::note_precedence_silence) << OpStr,
+                     (isLeftComp ? LHSExpr : RHSExpr)->getSourceRange());
   SuggestParentheses(Self, OpLoc,
-    Self.PDiag(diag::note_precedence_bitwise_first)
-      << BinaryOperator::getOpcodeStr(Opc),
-    ParensRange);
+                     Self.PDiag(diag::note_precedence_bitwise_first)
+                         << BinaryOperator::getOpcodeStr(Opc),
+                     ParensRange);
 }
 
 /// It accepts a '&&' expr that is inside a '||' one.
 /// Emit a diagnostic together with a fixit hint that wraps the '&&' expression
 /// in parentheses.
-static void
-EmitDiagnosticForLogicalAndInLogicalOr(Sema &Self, SourceLocation OpLoc,
-                                       BinaryOperator *Bop) {
+static void EmitDiagnosticForLogicalAndInLogicalOr(Sema &Self,
+                                                   SourceLocation OpLoc,
+                                                   BinaryOperator *Bop) {
   assert(Bop->getOpcode() == BO_LAnd);
   Self.Diag(Bop->getOperatorLoc(), diag::warn_logical_and_in_logical_or)
       << Bop->getSourceRange() << OpLoc;
   SuggestParentheses(Self, Bop->getOperatorLoc(),
-    Self.PDiag(diag::note_precedence_silence)
-      << Bop->getOpcodeStr(),
-    Bop->getSourceRange());
+                     Self.PDiag(diag::note_precedence_silence)
+                         << Bop->getOpcodeStr(),
+                     Bop->getSourceRange());
 }
 
 /// Look for '&&' in the left hand of a '||' expr.
@@ -15850,12 +15943,12 @@ static void DiagnoseBitwiseOpInBitwiseOp(Sema &S, BinaryOperatorKind Opc,
   if (BinaryOperator *Bop = dyn_cast<BinaryOperator>(SubExpr)) {
     if (Bop->isBitwiseOp() && Bop->getOpcode() < Opc) {
       S.Diag(Bop->getOperatorLoc(), diag::warn_bitwise_op_in_bitwise_op)
-        << Bop->getOpcodeStr() << BinaryOperator::getOpcodeStr(Opc)
-        << Bop->getSourceRange() << OpLoc;
+          << Bop->getOpcodeStr() << BinaryOperator::getOpcodeStr(Opc)
+          << Bop->getSourceRange() << OpLoc;
       SuggestParentheses(S, Bop->getOperatorLoc(),
-        S.PDiag(diag::note_precedence_silence)
-          << Bop->getOpcodeStr(),
-        Bop->getSourceRange());
+                         S.PDiag(diag::note_precedence_silence)
+                             << Bop->getOpcodeStr(),
+                         Bop->getSourceRange());
     }
   }
 }
@@ -15868,14 +15961,14 @@ static void DiagnoseAdditionInShift(Sema &S, SourceLocation OpLoc,
       S.Diag(Bop->getOperatorLoc(), diag::warn_addition_in_bitshift)
           << Bop->getSourceRange() << OpLoc << Shift << Op;
       SuggestParentheses(S, Bop->getOperatorLoc(),
-          S.PDiag(diag::note_precedence_silence) << Op,
-          Bop->getSourceRange());
+                         S.PDiag(diag::note_precedence_silence) << Op,
+                         Bop->getSourceRange());
     }
   }
 }
 
-static void DiagnoseShiftCompare(Sema &S, SourceLocation OpLoc,
-                                 Expr *LHSExpr, Expr *RHSExpr) {
+static void DiagnoseShiftCompare(Sema &S, SourceLocation OpLoc, Expr *LHSExpr,
+                                 Expr *RHSExpr) {
   CXXOperatorCallExpr *OCE = dyn_cast<CXXOperatorCallExpr>(LHSExpr);
   if (!OCE)
     return;
@@ -15904,27 +15997,28 @@ static void DiagnoseShiftCompare(Sema &S, SourceLocation OpLoc,
 /// precedence.
 static void DiagnoseBinOpPrecedence(Sema &Self, BinaryOperatorKind Opc,
                                     SourceLocation OpLoc, Expr *LHSExpr,
-                                    Expr *RHSExpr){
+                                    Expr *RHSExpr) {
   // Diagnose "arg1 'bitwise' arg2 'eq' arg3".
   if (BinaryOperator::isBitwiseOp(Opc))
     DiagnoseBitwisePrecedence(Self, Opc, OpLoc, LHSExpr, RHSExpr);
 
   // Diagnose "arg1 & arg2 | arg3"
   if ((Opc == BO_Or || Opc == BO_Xor) &&
-      !OpLoc.isMacroID()/* Don't warn in macros. */) {
+      !OpLoc.isMacroID() /* Don't warn in macros. */) {
     DiagnoseBitwiseOpInBitwiseOp(Self, Opc, OpLoc, LHSExpr);
     DiagnoseBitwiseOpInBitwiseOp(Self, Opc, OpLoc, RHSExpr);
   }
 
   // Warn about arg1 || arg2 && arg3, as GCC 4.3+ does.
   // We don't warn for 'assert(a || b && "bad")' since this is safe.
-  if (Opc == BO_LOr && !OpLoc.isMacroID()/* Don't warn in macros. */) {
+  if (Opc == BO_LOr && !OpLoc.isMacroID() /* Don't warn in macros. */) {
     DiagnoseLogicalAndInLogicalOrLHS(Self, OpLoc, LHSExpr, RHSExpr);
     DiagnoseLogicalAndInLogicalOrRHS(Self, OpLoc, LHSExpr, RHSExpr);
   }
 
-  if ((Opc == BO_Shl && LHSExpr->getType()->isIntegralType(Self.getASTContext()))
-      || Opc == BO_Shr) {
+  if ((Opc == BO_Shl &&
+       LHSExpr->getType()->isIntegralType(Self.getASTContext())) ||
+      Opc == BO_Shr) {
     StringRef Shift = BinaryOperator::getOpcodeStr(Opc);
     DiagnoseAdditionInShift(Self, OpLoc, LHSExpr, Shift);
     DiagnoseAdditionInShift(Self, OpLoc, RHSExpr, Shift);
@@ -15937,8 +16031,7 @@ static void DiagnoseBinOpPrecedence(Sema &Self, BinaryOperatorKind Opc,
 }
 
 ExprResult Sema::ActOnBinOp(Scope *S, SourceLocation TokLoc,
-                            tok::TokenKind Kind,
-                            Expr *LHSExpr, Expr *RHSExpr) {
+                            tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr) {
   BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Kind);
   assert(LHSExpr && "ActOnBinOp(): missing left expression");
   assert(RHSExpr && "ActOnBinOp(): missing right expression");
@@ -15971,8 +16064,8 @@ void Sema::LookupBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc,
 
 /// Build an overloaded binary operator expression in the given scope.
 static ExprResult BuildOverloadedBinOp(Sema &S, Scope *Sc, SourceLocation OpLoc,
-                                       BinaryOperatorKind Opc,
-                                       Expr *LHS, Expr *RHS) {
+                                       BinaryOperatorKind Opc, Expr *LHS,
+                                       Expr *RHS) {
   switch (Opc) {
   case BO_Assign:
     // In the non-overloaded case, we warn about self-assignment (x = x) for
@@ -16033,7 +16126,8 @@ ExprResult Sema::BuildBinOp(Scope *S, SourceLocation OpLoc,
       // that an overload set can be dependently-typed, but it never
       // instantiates to having an overloadable type.
       ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
-      if (resolvedRHS.isInvalid()) return ExprError();
+      if (resolvedRHS.isInvalid())
+        return ExprError();
       RHSExpr = resolvedRHS.get();
 
       if (RHSExpr->isTypeDependent() ||
@@ -16064,7 +16158,8 @@ ExprResult Sema::BuildBinOp(Scope *S, SourceLocation OpLoc,
     }
 
     ExprResult LHS = CheckPlaceholderExpr(LHSExpr);
-    if (LHS.isInvalid()) return ExprError();
+    if (LHS.isInvalid())
+      return ExprError();
     LHSExpr = LHS.get();
   }
 
@@ -16088,7 +16183,8 @@ ExprResult Sema::BuildBinOp(Scope *S, SourceLocation OpLoc,
       return BuildOverloadedBinOp(*this, S, OpLoc, Opc, LHSExpr, RHSExpr);
 
     ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
-    if (!resolvedRHS.isUsable()) return ExprError();
+    if (!resolvedRHS.isUsable())
+      return ExprError();
     RHSExpr = resolvedRHS.get();
   }
 
@@ -16176,10 +16272,11 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc,
     QualType Ty = InputExpr->getType();
     // The only legal unary operation for atomics is '&'.
     if ((Opc != UO_AddrOf && Ty->isAtomicType()) ||
-    // OpenCL special types - image, sampler, pipe, and blocks are to be used
-    // only with a builtin functions and therefore should be disallowed here.
-        (Ty->isImageType() || Ty->isSamplerT() || Ty->isPipeType()
-        || Ty->isBlockPointerType())) {
+        // OpenCL special types - image, sampler, pipe, and blocks are to be
+        // used only with a builtin functions and therefore should be disallowed
+        // here.
+        (Ty->isImageType() || Ty->isSamplerT() || Ty->isPipeType() ||
+         Ty->isBlockPointerType())) {
       return ExprError(Diag(OpLoc, diag::err_typecheck_unary_expr)
                        << InputExpr->getType()
                        << Input.get()->getSourceRange());
@@ -16476,15 +16573,15 @@ ExprResult Sema::BuildUnaryOp(Scope *S, SourceLocation OpLoc,
 
     // & gets special logic for several kinds of placeholder.
     // The builtin code knows what to do.
-    if (Opc == UO_AddrOf &&
-        (pty->getKind() == BuiltinType::Overload ||
-         pty->getKind() == BuiltinType::UnknownAny ||
-         pty->getKind() == BuiltinType::BoundMember))
+    if (Opc == UO_AddrOf && (pty->getKind() == BuiltinType::Overload ||
+                             pty->getKind() == BuiltinType::UnknownAny ||
+                             pty->getKind() == BuiltinType::BoundMember))
       return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
 
     // Anything else needs to be handled now.
     ExprResult Result = CheckPlaceholderExpr(Input);
-    if (Result.isInvalid()) return ExprError();
+    if (Result.isInvalid())
+      return ExprError();
     Input = Result.get();
   }
 
@@ -16622,32 +16719,32 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc,
   // a struct/union/class.
   if (!Dependent && !ArgTy->isRecordType())
     return ExprError(Diag(BuiltinLoc, diag::err_offsetof_record_type)
-                       << ArgTy << TypeRange);
+                     << ArgTy << TypeRange);
 
   // Type must be complete per C99 7.17p3 because a declaring a variable
   // with an incomplete type would be ill-formed.
-  if (!Dependent
-      && RequireCompleteType(BuiltinLoc, ArgTy,
-                             diag::err_offsetof_incomplete_type, TypeRange))
+  if (!Dependent &&
+      RequireCompleteType(BuiltinLoc, ArgTy, diag::err_offsetof_incomplete_type,
+                          TypeRange))
     return ExprError();
 
   bool DidWarnAboutNonPOD = false;
   QualType CurrentType = ArgTy;
   SmallVector<OffsetOfNode, 4> Comps;
-  SmallVector<Expr*, 4> Exprs;
+  SmallVector<Expr *, 4> Exprs;
   for (const OffsetOfComponent &OC : Components) {
     if (OC.isBrackets) {
       // Offset of an array sub-field.  TODO: Should we allow vector elements?
       if (!CurrentType->isDependentType()) {
         const ArrayType *AT = Context.getAsArrayType(CurrentType);
-        if(!AT)
+        if (!AT)
           return ExprError(Diag(OC.LocEnd, diag::err_offsetof_array_type)
                            << CurrentType);
         CurrentType = AT->getElementType();
       } else
         CurrentType = Context.DependentTy;
 
-      ExprResult IdxRval = DefaultLvalueConversion(static_cast<Expr*>(OC.U.E));
+      ExprResult IdxRval = DefaultLvalueConversion(static_cast<Expr *>(OC.U.E));
       if (IdxRval.isInvalid())
         return ExprError();
       Expr *Idx = IdxRval.get();
@@ -16694,9 +16791,10 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc,
     //   If type is not a standard-layout class (Clause 9), the results are
     //   undefined.
     if (CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(RD)) {
-      bool IsSafe = LangOpts.CPlusPlus11? CRD->isStandardLayout() : CRD->isPOD();
-      unsigned DiagID =
-        LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
+      bool IsSafe =
+          LangOpts.CPlusPlus11 ? CRD->isStandardLayout() : CRD->isPOD();
+      unsigned DiagID = LangOpts.CPlusPlus11
+                            ? diag::ext_offsetof_non_standardlayout_type
                             : diag::ext_offsetof_non_pod_type;
 
       if (!IsSafe && !DidWarnAboutNonPOD && !isUnevaluatedContext()) {
@@ -16732,8 +16830,7 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc,
     // We diagnose this as an error.
     if (MemberDecl->isBitField()) {
       Diag(OC.LocEnd, diag::err_offsetof_bitfield)
-        << MemberDecl->getDeclName()
-        << SourceRange(BuiltinLoc, RParenLoc);
+          << MemberDecl->getDeclName() << SourceRange(BuiltinLoc, RParenLoc);
       Diag(MemberDecl->getLocation(), diag::note_bitfield_decl);
       return ExprError();
     }
@@ -16749,8 +16846,7 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc,
                       Context.getCanonicalTagType(Parent), Paths)) {
       if (Paths.getDetectedVirtual()) {
         Diag(OC.LocEnd, diag::err_offsetof_field_of_virtual_base)
-          << MemberDecl->getDeclName()
-          << SourceRange(BuiltinLoc, RParenLoc);
+            << MemberDecl->getDeclName() << SourceRange(BuiltinLoc, RParenLoc);
         return ExprError();
       }
 
@@ -16762,8 +16858,8 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc,
     if (IndirectMemberDecl) {
       for (auto *FI : IndirectMemberDecl->chain()) {
         assert(isa<FieldDecl>(FI));
-        Comps.push_back(OffsetOfNode(OC.LocStart,
-                                     cast<FieldDecl>(FI), OC.LocEnd));
+        Comps.push_back(
+            OffsetOfNode(OC.LocStart, cast<FieldDecl>(FI), OC.LocEnd));
       }
     } else
       Comps.push_back(OffsetOfNode(OC.LocStart, MemberDecl, OC.LocEnd));
@@ -16775,8 +16871,7 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc,
                               Comps, Exprs, RParenLoc);
 }
 
-ExprResult Sema::ActOnBuiltinOffsetOf(Scope *S,
-                                      SourceLocation BuiltinLoc,
+ExprResult Sema::ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc,
                                       SourceLocation TypeLoc,
                                       ParsedType ParsedArgTy,
                                       ArrayRef<OffsetOfComponent> Components,
@@ -16793,9 +16888,7 @@ ExprResult Sema::ActOnBuiltinOffsetOf(Scope *S,
   return BuildBuiltinOffsetOf(BuiltinLoc, ArgTInfo, Components, RParenLoc);
 }
 
-
-ExprResult Sema::ActOnChooseExpr(SourceLocation BuiltinLoc,
-                                 Expr *CondExpr,
+ExprResult Sema::ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr,
                                  Expr *LHSExpr, Expr *RHSExpr,
                                  SourceLocation RPLoc) {
   assert((CondExpr && LHSExpr && RHSExpr) && "Missing type argument(s)");
@@ -16881,8 +16974,8 @@ void Sema::ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
   // Look for an explicit signature in that function type.
   FunctionProtoTypeLoc ExplicitSignature;
 
-  if ((ExplicitSignature = Sig->getTypeLoc()
-                               .getAsAdjusted<FunctionProtoTypeLoc>())) {
+  if ((ExplicitSignature =
+           Sig->getTypeLoc().getAsAdjusted<FunctionProtoTypeLoc>())) {
 
     // Check whether that explicit signature was synthesized by
     // GetTypeForDeclarator.  If so, don't save that as part of the
@@ -16921,7 +17014,7 @@ void Sema::ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
   }
 
   // Push block parameters from the declarator if we had them.
-  SmallVector<ParmVarDecl*, 8> Params;
+  SmallVector<ParmVarDecl *, 8> Params;
   if (ExplicitSignature) {
     for (unsigned I = 0, E = ExplicitSignature.getNumParams(); I != E; ++I) {
       ParmVarDecl *Param = ExplicitSignature.getParam(I);
@@ -16934,8 +17027,8 @@ void Sema::ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
       Params.push_back(Param);
     }
 
-  // Fake up parameter variables if we have a typedef, like
-  //   ^ fntype { ... }
+    // Fake up parameter variables if we have a typedef, like
+    //   ^ fntype { ... }
   } else if (const FunctionProtoType *Fn = T->getAs<FunctionProtoType>()) {
     for (const auto &I : Fn->param_types()) {
       ParmVarDecl *Param = BuildParmVarDeclForTypedef(
@@ -16980,8 +17073,8 @@ void Sema::ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope) {
   PopFunctionScopeInfo();
 }
 
-ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
-                                    Stmt *Body, Scope *CurScope) {
+ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body,
+                                    Scope *CurScope) {
   // If blocks are disabled, emit an error.
   if (!LangOpts.Blocks)
     Diag(CaretLoc, diag::err_blocks_disable) << LangOpts.OpenCL;
@@ -17013,7 +17106,8 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
     const FunctionType *FTy = BSI->FunctionType->castAs<FunctionType>();
 
     FunctionType::ExtInfo Ext = FTy->getExtInfo();
-    if (NoReturn && !Ext.getNoReturn()) Ext = Ext.withNoReturn(true);
+    if (NoReturn && !Ext.getNoReturn())
+      Ext = Ext.withNoReturn(true);
 
     // Turn protoless block types into nullary block types.
     if (isa<FunctionNoProtoType>(FTy)) {
@@ -17027,7 +17121,7 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
                (!NoReturn || FTy->getNoReturnAttr())) {
       BlockTy = BSI->FunctionType;
 
-    // Otherwise, make the minimal modifications to the function type.
+      // Otherwise, make the minimal modifications to the function type.
     } else {
       const FunctionProtoType *FPT = cast<FunctionProtoType>(FTy);
       FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
@@ -17036,7 +17130,7 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
       BlockTy = Context.getFunctionType(RetTy, FPT->getParamTypes(), EPI);
     }
 
-  // If we don't have a function type, just build one from nothing.
+    // If we don't have a function type, just build one from nothing.
   } else {
     FunctionProtoType::ExtProtoInfo EPI;
     EPI.ExtInfo = FunctionType::ExtInfo().withNoReturn(NoReturn);
@@ -17047,8 +17141,7 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
   BlockTy = Context.getBlockPointerType(BlockTy);
 
   // If needed, diagnose invalid gotos and switches in the block.
-  if (getCurFunction()->NeedsScopeChecking() &&
-      !PP.isCodeCompletionEnabled())
+  if (getCurFunction()->NeedsScopeChecking() && !PP.isCodeCompletionEnabled())
     DiagnoseInvalidJumps(cast<CompoundStmt>(Body));
 
   BD->setBody(cast<CompoundStmt>(Body));
@@ -17123,9 +17216,9 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
         // Build a full-expression copy expression if initialization
         // succeeded and used a non-trivial constructor.  Recover from
         // errors by pretending that the copy isn't necessary.
-        if (!Result.isInvalid() &&
-            !cast<CXXConstructExpr>(Result.get())->getConstructor()
-                ->isTrivial()) {
+        if (!Result.isInvalid() && !cast<CXXConstructExpr>(Result.get())
+                                        ->getConstructor()
+                                        ->isTrivial()) {
           Result = MaybeCreateExprWithCleanups(Result);
           CopyExpr = Result.get();
         }
@@ -17182,9 +17275,8 @@ ExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty,
   return BuildVAArgExpr(BuiltinLoc, E, TInfo, RPLoc);
 }
 
-ExprResult Sema::BuildVAArgExpr(SourceLocation BuiltinLoc,
-                                Expr *E, TypeSourceInfo *TInfo,
-                                SourceLocation RPLoc) {
+ExprResult Sema::BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E,
+                                TypeSourceInfo *TInfo, SourceLocation RPLoc) {
   Expr *OrigExpr = E;
   bool IsMS = false;
 
@@ -17206,7 +17298,8 @@ ExprResult Sema::BuildVAArgExpr(SourceLocation BuiltinLoc,
   // as Microsoft ABI on an actual Microsoft platform, where
   // __builtin_ms_va_list and __builtin_va_list are the same.)
   if (!E->isTypeDependent() && Context.getTargetInfo().hasBuiltinMSVaList() &&
-      Context.getTargetInfo().getBuiltinVaListKind() != TargetInfo::CharPtrBuiltinVaList) {
+      Context.getTargetInfo().getBuiltinVaListKind() !=
+          TargetInfo::CharPtrBuiltinVaList) {
     QualType MSVaListType = Context.getBuiltinMSVaListType();
     if (Context.hasSameType(MSVaListType, E->getType())) {
       if (CheckForModifiableLvalue(E, BuiltinLoc, *this))
@@ -17259,19 +17352,17 @@ ExprResult Sema::BuildVAArgExpr(SourceLocation BuiltinLoc,
                             TInfo->getTypeLoc()))
       return ExprError();
 
-    if (RequireNonAbstractType(TInfo->getTypeLoc().getBeginLoc(),
-                               TInfo->getType(),
-                               diag::err_second_parameter_to_va_arg_abstract,
-                               TInfo->getTypeLoc()))
+    if (RequireNonAbstractType(
+            TInfo->getTypeLoc().getBeginLoc(), TInfo->getType(),
+            diag::err_second_parameter_to_va_arg_abstract, TInfo->getTypeLoc()))
       return ExprError();
 
     if (!TInfo->getType().isPODType(Context)) {
       Diag(TInfo->getTypeLoc().getBeginLoc(),
            TInfo->getType()->isObjCLifetimeType()
-             ? diag::warn_second_parameter_to_va_arg_ownership_qualified
-             : diag::warn_second_parameter_to_va_arg_not_pod)
-        << TInfo->getType()
-        << TInfo->getTypeLoc().getSourceRange();
+               ? diag::warn_second_parameter_to_va_arg_ownership_qualified
+               : diag::warn_second_parameter_to_va_arg_not_pod)
+          << TInfo->getType() << TInfo->getTypeLoc().getSourceRange();
     }
 
     if (TInfo->getType()->isArrayType()) {
@@ -17333,11 +17424,11 @@ ExprResult Sema::BuildVAArgExpr(SourceLocation BuiltinLoc,
     if (TInfo->getType()->isSpecificBuiltinType(BuiltinType::Float))
       PromoteType = Context.DoubleTy;
     if (!PromoteType.isNull())
-      DiagRuntimeBehavior(TInfo->getTypeLoc().getBeginLoc(), E,
-                  PDiag(diag::warn_second_parameter_to_va_arg_never_compatible)
-                          << TInfo->getType()
-                          << PromoteType
-                          << TInfo->getTypeLoc().getSourceRange());
+      DiagRuntimeBehavior(
+          TInfo->getTypeLoc().getBeginLoc(), E,
+          PDiag(diag::warn_second_parameter_to_va_arg_never_compatible)
+              << TInfo->getType() << PromoteType
+              << TInfo->getTypeLoc().getSourceRange());
   }
 
   QualType T = TInfo->getType().getNonLValueExprType(Context);
@@ -17500,10 +17591,9 @@ static bool maybeDiagnoseAssignmentToFunction(Sema &S, QualType DstType,
 }
 
 bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
-                                    SourceLocation Loc,
-                                    QualType DstType, QualType SrcType,
-                                    Expr *SrcExpr, AssignmentAction Action,
-                                    bool *Complained) {
+                                    SourceLocation Loc, QualType DstType,
+                                    QualType SrcType, Expr *SrcExpr,
+                                    AssignmentAction Action, bool *Complained) {
   if (Complained)
     *Complained = false;
 
@@ -17572,7 +17662,7 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
       DiagKind = diag::ext_typecheck_convert_incompatible_pointer;
     }
     CheckInferredResultType = DstType->isObjCObjectPointerType() &&
-      SrcType->isObjCObjectPointerType();
+                              SrcType->isObjCObjectPointerType();
     if (CheckInferredResultType) {
       SrcType = SrcType.getUnqualifiedType();
       DstType = DstType.getUnqualifiedType();
@@ -17599,7 +17689,8 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
     break;
   case AssignConvertType::IncompatiblePointerDiscardsQualifiers: {
     // Perform array-to-pointer decay if necessary.
-    if (SrcType->isArrayType()) SrcType = Context.getArrayDecayedType(SrcType);
+    if (SrcType->isArrayType())
+      SrcType = Context.getArrayDecayedType(SrcType);
 
     isInvalid = true;
 
@@ -17639,10 +17730,10 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
         IsStringLiteralToNonConstPointerConversion(SrcExpr, DstType))
       return false;
     if (getLangOpts().CPlusPlus) {
-      DiagKind =  diag::err_typecheck_convert_discards_qualifiers;
+      DiagKind = diag::err_typecheck_convert_discards_qualifiers;
       isInvalid = true;
     } else {
-      DiagKind =  diag::ext_typecheck_convert_discards_qualifiers;
+      DiagKind = diag::ext_typecheck_convert_discards_qualifiers;
     }
 
     break;
@@ -17669,24 +17760,23 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
   case AssignConvertType::IncompatibleObjCQualifiedId: {
     if (SrcType->isObjCQualifiedIdType()) {
       const ObjCObjectPointerType *srcOPT =
-                SrcType->castAs<ObjCObjectPointerType>();
+          SrcType->castAs<ObjCObjectPointerType>();
       for (auto *srcProto : srcOPT->quals()) {
         PDecl = srcProto;
         break;
       }
       if (const ObjCInterfaceType *IFaceT =
-            DstType->castAs<ObjCObjectPointerType>()->getInterfaceType())
+              DstType->castAs<ObjCObjectPointerType>()->getInterfaceType())
         IFace = IFaceT->getDecl();
-    }
-    else if (DstType->isObjCQualifiedIdType()) {
+    } else if (DstType->isObjCQualifiedIdType()) {
       const ObjCObjectPointerType *dstOPT =
-        DstType->castAs<ObjCObjectPointerType>();
+          DstType->castAs<ObjCObjectPointerType>();
       for (auto *dstProto : dstOPT->quals()) {
         PDecl = dstProto;
         break;
       }
       if (const ObjCInterfaceType *IFaceT =
-            SrcType->castAs<ObjCObjectPointerType>()->getInterfaceType())
+              SrcType->castAs<ObjCObjectPointerType>()->getInterfaceType())
         IFace = IFaceT->getDecl();
     }
     if (getLangOpts().CPlusPlus) {
@@ -17790,7 +17880,9 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
       FDiag << H;
   }
 
-  if (MayHaveConvFixit) { FDiag << (unsigned) (ConvHints.Kind); }
+  if (MayHaveConvFixit) {
+    FDiag << (unsigned)(ConvHints.Kind);
+  }
 
   if (MayHaveFunctionDiff)
     HandleFunctionTypeMismatch(FDiag, SecondType, FirstType);
@@ -17803,8 +17895,8 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
         << IFace << PDecl;
 
   if (SecondType == Context.OverloadTy)
-    NoteAllOverloadCandidates(OverloadExpr::find(SrcExpr).Expression,
-                              FirstType, /*TakingAddress=*/true);
+    NoteAllOverloadCandidates(OverloadExpr::find(SrcExpr).Expression, FirstType,
+                              /*TakingAddress=*/true);
 
   if (CheckInferredResultType)
     ObjC().EmitRelatedResultTypeNote(SrcExpr);
@@ -17818,8 +17910,7 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
   return isInvalid;
 }
 
-ExprResult Sema::VerifyIntegerConstantExpression(Expr *E,
-                                                 llvm::APSInt *Result,
+ExprResult Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
                                                  AllowFoldKind CanFold) {
   class SimpleICEDiagnoser : public VerifyICEDiagnoser {
   public:
@@ -17836,8 +17927,7 @@ ExprResult Sema::VerifyIntegerConstantExpression(Expr *E,
   return VerifyIntegerConstantExpression(E, Result, Diagnoser, CanFold);
 }
 
-ExprResult Sema::VerifyIntegerConstantExpression(Expr *E,
-                                                 llvm::APSInt *Result,
+ExprResult Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
                                                  unsigned DiagID,
                                                  AllowFoldKind CanFold) {
   class IDDiagnoser : public VerifyICEDiagnoser {
@@ -17845,7 +17935,7 @@ ExprResult Sema::VerifyIntegerConstantExpression(Expr *E,
 
   public:
     IDDiagnoser(unsigned DiagID)
-      : VerifyICEDiagnoser(DiagID == 0), DiagID(DiagID) { }
+        : VerifyICEDiagnoser(DiagID == 0), DiagID(DiagID) {}
 
     SemaDiagnosticBuilder diagnoseNotICE(Sema &S, SourceLocation Loc) override {
       return S.Diag(Loc, DiagID);
@@ -17866,10 +17956,9 @@ Sema::VerifyICEDiagnoser::diagnoseFold(Sema &S, SourceLocation Loc) {
   return S.Diag(Loc, diag::ext_expr_not_ice) << S.LangOpts.CPlusPlus;
 }
 
-ExprResult
-Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
-                                      VerifyICEDiagnoser &Diagnoser,
-                                      AllowFoldKind CanFold) {
+ExprResult Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
+                                                 VerifyICEDiagnoser &Diagnoser,
+                                                 AllowFoldKind CanFold) {
   SourceLocation DiagLoc = E->getBeginLoc();
 
   if (getLangOpts().CPlusPlus11) {
@@ -17881,6 +17970,7 @@ Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
     ExprResult Converted;
     class CXX11ConvertDiagnoser : public ICEConvertDiagnoser {
       VerifyICEDiagnoser &BaseDiagnoser;
+
     public:
       CXX11ConvertDiagnoser(VerifyICEDiagnoser &BaseDiagnoser)
           : ICEConvertDiagnoser(/*AllowScopedEnumerations*/ false,
@@ -17892,41 +17982,43 @@ Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
         return BaseDiagnoser.diagnoseNotICEType(S, Loc, T);
       }
 
-      SemaDiagnosticBuilder diagnoseIncomplete(
-          Sema &S, SourceLocation Loc, QualType T) override {
+      SemaDiagnosticBuilder diagnoseIncomplete(Sema &S, SourceLocation Loc,
+                                               QualType T) override {
         return S.Diag(Loc, diag::err_ice_incomplete_type) << T;
       }
 
-      SemaDiagnosticBuilder diagnoseExplicitConv(
-          Sema &S, SourceLocation Loc, QualType T, QualType ConvTy) override {
+      SemaDiagnosticBuilder diagnoseExplicitConv(Sema &S, SourceLocation Loc,
+                                                 QualType T,
+                                                 QualType ConvTy) override {
         return S.Diag(Loc, diag::err_ice_explicit_conversion) << T << ConvTy;
       }
 
-      SemaDiagnosticBuilder noteExplicitConv(
-          Sema &S, CXXConversionDecl *Conv, QualType ConvTy) override {
+      SemaDiagnosticBuilder noteExplicitConv(Sema &S, CXXConversionDecl *Conv,
+                                             QualType ConvTy) override {
         return S.Diag(Conv->getLocation(), diag::note_ice_conversion_here)
-                 << ConvTy->isEnumeralType() << ConvTy;
+               << ConvTy->isEnumeralType() << ConvTy;
       }
 
-      SemaDiagnosticBuilder diagnoseAmbiguous(
-          Sema &S, SourceLocation Loc, QualType T) override {
+      SemaDiagnosticBuilder diagnoseAmbiguous(Sema &S, SourceLocation Loc,
+                                              QualType T) override {
         return S.Diag(Loc, diag::err_ice_ambiguous_conversion) << T;
       }
 
-      SemaDiagnosticBuilder noteAmbiguous(
-          Sema &S, CXXConversionDecl *Conv, QualType ConvTy) override {
+      SemaDiagnosticBuilder noteAmbiguous(Sema &S, CXXConversionDecl *Conv,
+                                          QualType ConvTy) override {
         return S.Diag(Conv->getLocation(), diag::note_ice_conversion_here)
-                 << ConvTy->isEnumeralType() << ConvTy;
+               << ConvTy->isEnumeralType() << ConvTy;
       }
 
-      SemaDiagnosticBuilder diagnoseConversion(
-          Sema &S, SourceLocation Loc, QualType T, QualType ConvTy) override {
+      SemaDiagnosticBuilder diagnoseConversion(Sema &S, SourceLocation Loc,
+                                               QualType T,
+                                               QualType ConvTy) override {
         llvm_unreachable("conversion functions are permitted");
       }
     } ConvertDiagnoser(Diagnoser);
 
-    Converted = PerformContextualImplicitConversion(DiagLoc, E,
-                                                    ConvertDiagnoser);
+    Converted =
+        PerformContextualImplicitConversion(DiagLoc, E, ConvertDiagnoser);
     if (Converted.isInvalid())
       return Converted;
     E = Converted.get();
@@ -17969,7 +18061,7 @@ Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
     // the caret at its location rather than producing an essentially
     // redundant note.
     if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
-          diag::note_invalid_subexpr_in_const_expr) {
+                                 diag::note_invalid_subexpr_in_const_expr) {
       DiagLoc = Notes[0].first;
       Notes.clear();
     }
@@ -18016,8 +18108,8 @@ Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
   // If our only note is the usual "invalid subexpression" note, just point
   // the caret at its location rather than producing an essentially
   // redundant note.
-  if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
-        diag::note_invalid_subexpr_in_const_expr) {
+  if (Notes.size() == 1 &&
+      Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr) {
     DiagLoc = Notes[0].first;
     Notes.clear();
   }
@@ -18042,58 +18134,57 @@ Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
 }
 
 namespace {
-  // Handle the case where we conclude a expression which we speculatively
-  // considered to be unevaluated is actually evaluated.
-  class TransformToPE : public TreeTransform<TransformToPE> {
-    typedef TreeTransform<TransformToPE> BaseTransform;
+// Handle the case where we conclude a expression which we speculatively
+// considered to be unevaluated is actually evaluated.
+class TransformToPE : public TreeTransform<TransformToPE> {
+  typedef TreeTransform<TransformToPE> BaseTransform;
 
-  public:
-    TransformToPE(Sema &SemaRef) : BaseTransform(SemaRef) { }
+public:
+  TransformToPE(Sema &SemaRef) : BaseTransform(SemaRef) {}
 
-    // Make sure we redo semantic analysis
-    bool AlwaysRebuild() { return true; }
-    bool ReplacingOriginal() { return true; }
+  // Make sure we redo semantic analysis
+  bool AlwaysRebuild() { return true; }
+  bool ReplacingOriginal() { return true; }
 
-    // We need to special-case DeclRefExprs referring to FieldDecls which
-    // are not part of a member pointer formation; normal TreeTransforming
-    // doesn't catch this case because of the way we represent them in the AST.
-    // FIXME: This is a bit ugly; is it really the best way to handle this
-    // case?
-    //
-    // Error on DeclRefExprs referring to FieldDecls.
-    ExprResult TransformDeclRefExpr(DeclRefExpr *E) {
-      if (isa<FieldDecl>(E->getDecl()) &&
-          !SemaRef.isUnevaluatedContext())
-        return SemaRef.Diag(E->getLocation(),
-                            diag::err_invalid_non_static_member_use)
-            << E->getDecl() << E->getSourceRange();
+  // We need to special-case DeclRefExprs referring to FieldDecls which
+  // are not part of a member pointer formation; normal TreeTransforming
+  // doesn't catch this case because of the way we represent them in the AST.
+  // FIXME: This is a bit ugly; is it really the best way to handle this
+  // case?
+  //
+  // Error on DeclRefExprs referring to FieldDecls.
+  ExprResult TransformDeclRefExpr(DeclRefExpr *E) {
+    if (isa<FieldDecl>(E->getDecl()) && !SemaRef.isUnevaluatedContext())
+      return SemaRef.Diag(E->getLocation(),
+                          diag::err_invalid_non_static_member_use)
+             << E->getDecl() << E->getSourceRange();
 
-      return BaseTransform::TransformDeclRefExpr(E);
-    }
+    return BaseTransform::TransformDeclRefExpr(E);
+  }
 
-    // Exception: filter out member pointer formation
-    ExprResult TransformUnaryOperator(UnaryOperator *E) {
-      if (E->getOpcode() == UO_AddrOf && E->getType()->isMemberPointerType())
-        return E;
+  // Exception: filter out member pointer formation
+  ExprResult TransformUnaryOperator(UnaryOperator *E) {
+    if (E->getOpcode() == UO_AddrOf && E->getType()->isMemberPointerType())
+      return E;
 
-      return BaseTransform::TransformUnaryOperator(E);
-    }
+    return BaseTransform::TransformUnaryOperator(E);
+  }
 
-    // The body of a lambda-expression is in a separate expression evaluation
-    // context so never needs to be transformed.
-    // FIXME: Ideally we wouldn't transform the closure type either, and would
-    // just recreate the capture expressions and lambda expression.
-    StmtResult TransformLambdaBody(LambdaExpr *E, Stmt *Body) {
-      return SkipLambdaBody(E, Body);
-    }
-  };
-}
+  // The body of a lambda-expression is in a separate expression evaluation
+  // context so never needs to be transformed.
+  // FIXME: Ideally we wouldn't transform the closure type either, and would
+  // just recreate the capture expressions and lambda expression.
+  StmtResult TransformLambdaBody(LambdaExpr *E, Stmt *Body) {
+    return SkipLambdaBody(E, Body);
+  }
+};
+} // namespace
 
 ExprResult Sema::TransformToPotentiallyEvaluated(Expr *E) {
   assert(isUnevaluatedContext() &&
          "Should only transform unevaluated expressions");
   ExprEvalContexts.back().Context =
-      ExprEvalContexts[ExprEvalContexts.size()-2].Context;
+      ExprEvalContexts[ExprEvalContexts.size() - 2].Context;
   if (isUnevaluatedContext())
     return E;
   return TransformToPE(*this).TransformExpr(E);
@@ -18108,8 +18199,7 @@ TypeSourceInfo *Sema::TransformToPotentiallyEvaluated(TypeSourceInfo *TInfo) {
   return TransformToPE(*this).TransformType(TInfo);
 }
 
-void
-Sema::PushExpressionEvaluationContext(
+void Sema::PushExpressionEvaluationContext(
     ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl,
     ExpressionEvaluationContextRecord::ExpressionKind ExprContext) {
   ExprEvalContexts.emplace_back(NewContext, ExprCleanupObjects.size(), Cleanup,
@@ -18137,8 +18227,7 @@ Sema::PushExpressionEvaluationContext(
     std::swap(MaybeODRUseExprs, ExprEvalContexts.back().SavedMaybeODRUseExprs);
 }
 
-void
-Sema::PushExpressionEvaluationContext(
+void Sema::PushExpressionEvaluationContext(
     ExpressionEvaluationContext NewContext, ReuseLambdaContextDecl_t,
     ExpressionEvaluationContextRecord::ExpressionKind ExprContext) {
   Decl *ClosureContextDecl = ExprEvalContexts.back().ManglingContextDecl;
@@ -18407,7 +18496,7 @@ static void RemoveNestedImmediateInvocation(
                   SmallVector<Sema::ImmediateInvocationCandidate,
                               4>::reverse_iterator Current)
         : Base(SemaRef), DRSet(DR), IISet(II), CurrentII(Current) {}
-    void RemoveImmediateInvocation(ConstantExpr* E) {
+    void RemoveImmediateInvocation(ConstantExpr *E) {
       auto It = std::find_if(CurrentII, IISet.rend(),
                              [E](Sema::ImmediateInvocationCandidate Elem) {
                                return Elem.getPointer() == E;
@@ -18611,7 +18700,7 @@ HandleImmediateInvocations(Sema &SemaRef,
 }
 
 void Sema::PopExpressionEvaluationContext() {
-  ExpressionEvaluationContextRecord& Rec = ExprEvalContexts.back();
+  ExpressionEvaluationContextRecord &Rec = ExprEvalContexts.back();
   if (!Rec.Lambdas.empty()) {
     using ExpressionKind = ExpressionEvaluationContextRecord::ExpressionKind;
     if (!getLangOpts().CPlusPlus20 &&
@@ -18671,7 +18760,7 @@ void Sema::PopExpressionEvaluationContext() {
     Cleanup = Rec.ParentCleanup;
     CleanupVarDeclMarking();
     std::swap(MaybeODRUseExprs, Rec.SavedMaybeODRUseExprs);
-  // Otherwise, merge the contexts together.
+    // Otherwise, merge the contexts together.
   } else {
     Cleanup.mergeFrom(Rec.ParentCleanup);
     MaybeODRUseExprs.insert_range(Rec.SavedMaybeODRUseExprs);
@@ -18684,9 +18773,9 @@ void Sema::PopExpressionEvaluationContext() {
 }
 
 void Sema::DiscardCleanupsInEvaluationContext() {
-  ExprCleanupObjects.erase(
-         ExprCleanupObjects.begin() + ExprEvalContexts.back().NumCleanupObjects,
-         ExprCleanupObjects.end());
+  ExprCleanupObjects.erase(ExprCleanupObjects.begin() +
+                               ExprEvalContexts.back().NumCleanupObjects,
+                           ExprCleanupObjects.end());
   Cleanup.reset();
   MaybeODRUseExprs.clear();
 }
@@ -18707,27 +18796,27 @@ static bool isPotentiallyConstantEvaluatedContext(Sema &SemaRef) {
   /// C++2a [expr.const]p12:
   //   An expression or conversion is potentially constant evaluated if it is
   switch (SemaRef.ExprEvalContexts.back().Context) {
-    case Sema::ExpressionEvaluationContext::ConstantEvaluated:
-    case Sema::ExpressionEvaluationContext::ImmediateFunctionContext:
-
-      // -- a manifestly constant-evaluated expression,
-    case Sema::ExpressionEvaluationContext::PotentiallyEvaluated:
-    case Sema::ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed:
-    case Sema::ExpressionEvaluationContext::DiscardedStatement:
-      // -- a potentially-evaluated expression,
-    case Sema::ExpressionEvaluationContext::UnevaluatedList:
-      // -- an immediate subexpression of a braced-init-list,
-
-      // -- [FIXME] an expression of the form & cast-expression that occurs
-      //    within a templated entity
-      // -- a subexpression of one of the above that is not a subexpression of
-      // a nested unevaluated operand.
-      return true;
+  case Sema::ExpressionEvaluationContext::ConstantEvaluated:
+  case Sema::ExpressionEvaluationContext::ImmediateFunctionContext:
+
+    // -- a manifestly constant-evaluated expression,
+  case Sema::ExpressionEvaluationContext::PotentiallyEvaluated:
+  case Sema::ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed:
+  case Sema::ExpressionEvaluationContext::DiscardedStatement:
+    // -- a potentially-evaluated expression,
+  case Sema::ExpressionEvaluationContext::UnevaluatedList:
+    // -- an immediate subexpression of a braced-init-list,
+
+    // -- [FIXME] an expression of the form & cast-expression that occurs
+    //    within a templated entity
+    // -- a subexpression of one of the above that is not a subexpression of
+    // a nested unevaluated operand.
+    return true;
 
-    case Sema::ExpressionEvaluationContext::Unevaluated:
-    case Sema::ExpressionEvaluationContext::UnevaluatedAbstract:
-      // Expressions in this context are never evaluated.
-      return false;
+  case Sema::ExpressionEvaluationContext::Unevaluated:
+  case Sema::ExpressionEvaluationContext::UnevaluatedAbstract:
+    // Expressions in this context are never evaluated.
+    return false;
   }
   llvm_unreachable("Invalid context");
 }
@@ -19005,7 +19094,7 @@ void Sema::MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func,
           PointOfInstantiation = Loc;
           if (auto *MSI = Func->getMemberSpecializationInfo())
             MSI->setPointOfInstantiation(Loc);
-            // FIXME: Notify listener.
+          // FIXME: Notify listener.
           else
             Func->setTemplateSpecializationKind(TSK, PointOfInstantiation);
         } else if (TSK != TSK_ImplicitInstantiation) {
@@ -19098,8 +19187,7 @@ void Sema::MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func,
     if (!Func->isDefined() && !Func->isInAnotherModuleUnit()) {
       if (mightHaveNonExternalLinkage(Func))
         UndefinedButUsed.insert(std::make_pair(Func->getCanonicalDecl(), Loc));
-      else if (Func->getMostRecentDecl()->isInlined() &&
-               !LangOpts.GNUInline &&
+      else if (Func->getMostRecentDecl()->isInlined() && !LangOpts.GNUInline &&
                !Func->getMostRecentDecl()->hasAttr<GNUInlineAttr>())
         UndefinedButUsed.insert(std::make_pair(Func->getCanonicalDecl(), Loc));
       else if (isExternalWithNoLinkageType(Func))
@@ -19229,8 +19317,7 @@ static void diagnoseUncapturableValueReferenceOrBinding(Sema &S,
   //  If the parameter still belongs to the translation unit, then
   //  we're actually just using one parameter in the declaration of
   //  the next.
-  if (isa<ParmVarDecl>(var) &&
-      isa<TranslationUnitDecl>(VarDC))
+  if (isa<ParmVarDecl>(var) && isa<TranslationUnitDecl>(VarDC))
     return;
 
   // For C code, don't diagnose about capture if we're not actually in code
@@ -19255,9 +19342,8 @@ static void diagnoseUncapturableValueReferenceOrBinding(Sema &S,
   }
 
   S.Diag(loc, diag::err_reference_to_local_in_enclosing_context)
-    << var << ValueKind << ContextKind << VarDC;
-  S.Diag(var->getLocation(), diag::note_entity_declared_at)
-      << var;
+      << var << ValueKind << ContextKind << VarDC;
+  S.Diag(var->getLocation(), diag::note_entity_declared_at) << var;
 
   // FIXME: Add additional diagnostic info about class etc. which prevents
   // capture.
@@ -19421,8 +19507,7 @@ static bool captureInBlock(BlockScopeInfo *BSI, ValueDecl *Var,
   if (!Invalid &&
       CaptureType.getObjCLifetime() == Qualifiers::OCL_Autoreleasing) {
     if (BuildAndDiagnose) {
-      S.Diag(Loc, diag::err_arc_autoreleasing_capture)
-        << /*block*/ 0;
+      S.Diag(Loc, diag::err_arc_autoreleasing_capture) << /*block*/ 0;
       S.Diag(Var->getLocation(), diag::note_previous_decl) << Var;
       Invalid = true;
     } else {
@@ -19553,7 +19638,7 @@ static bool captureInLambda(LambdaScopeInfo *LSI, ValueDecl *Var,
     //   captured entity is a reference to a function, the
     //   corresponding data member is also a reference to a
     //   function. - end note ]
-    if (const ReferenceType *RefType = CaptureType->getAs<ReferenceType>()){
+    if (const ReferenceType *RefType = CaptureType->getAs<ReferenceType>()) {
       if (!RefType->getPointeeType()->isFunctionType())
         CaptureType = RefType->getPointeeType();
     }
@@ -19564,7 +19649,7 @@ static bool captureInLambda(LambdaScopeInfo *LSI, ValueDecl *Var,
       if (BuildAndDiagnose) {
         S.Diag(Loc, diag::err_arc_autoreleasing_capture) << /*lambda*/ 1;
         S.Diag(Var->getLocation(), diag::note_previous_decl)
-          << Var->getDeclName();
+            << Var->getDeclName();
         Invalid = true;
       } else {
         return false;
@@ -19751,7 +19836,8 @@ bool Sema::tryCaptureVariable(
   assert(VD && "Cannot capture a null variable");
 
   const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt
-      ? *FunctionScopeIndexToStopAt : FunctionScopes.size() - 1;
+                                              ? *FunctionScopeIndexToStopAt
+                                              : FunctionScopes.size() - 1;
   // We need to sync up the Declaration Context with the
   // FunctionScopeIndexToStopAt
   if (FunctionScopeIndexToStopAt) {
@@ -19836,7 +19922,7 @@ bool Sema::tryCaptureVariable(
       return true;
     }
 
-    FunctionScopeInfo  *FSI = FunctionScopes[FunctionScopesIndex];
+    FunctionScopeInfo *FSI = FunctionScopes[FunctionScopesIndex];
     CapturingScopeInfo *CSI = cast<CapturingScopeInfo>(FSI);
 
     // Check whether we've already captured it.
@@ -19984,13 +20070,13 @@ bool Sema::tryCaptureVariable(
   // If the variable had already been captured previously, we start capturing
   // at the lambda nested within that one.
   bool Invalid = false;
-  for (unsigned I = ++FunctionScopesIndex, N = MaxFunctionScopesIndex + 1; I != N;
-       ++I) {
+  for (unsigned I = ++FunctionScopesIndex, N = MaxFunctionScopesIndex + 1;
+       I != N; ++I) {
     CapturingScopeInfo *CSI = cast<CapturingScopeInfo>(FunctionScopes[I]);
 
-    // Certain capturing entities (lambdas, blocks etc.) are not allowed to capture
-    // certain types of variables (unnamed, variably modified types etc.)
-    // so check for eligibility.
+    // Certain capturing entities (lambdas, blocks etc.) are not allowed to
+    // capture certain types of variables (unnamed, variably modified types
+    // etc.) so check for eligibility.
     if (!Invalid)
       Invalid =
           !isVariableCapturable(CSI, Var, ExprLoc, BuildAndDiagnose, *this);
@@ -20001,10 +20087,12 @@ bool Sema::tryCaptureVariable(
       return true;
 
     if (BlockScopeInfo *BSI = dyn_cast<BlockScopeInfo>(CSI)) {
-      Invalid = !captureInBlock(BSI, Var, ExprLoc, BuildAndDiagnose, CaptureType,
-                               DeclRefType, Nested, *this, Invalid);
+      Invalid =
+          !captureInBlock(BSI, Var, ExprLoc, BuildAndDiagnose, CaptureType,
+                          DeclRefType, Nested, *this, Invalid);
       Nested = true;
-    } else if (CapturedRegionScopeInfo *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
+    } else if (CapturedRegionScopeInfo *RSI =
+                   dyn_cast<CapturedRegionScopeInfo>(CSI)) {
       Invalid = !captureInCapturedRegion(
           RSI, Var, ExprLoc, BuildAndDiagnose, CaptureType, DeclRefType, Nested,
           Kind, /*IsTopScope*/ I == N - 1, *this, Invalid);
@@ -20029,8 +20117,8 @@ bool Sema::tryCaptureVariable(ValueDecl *Var, SourceLocation Loc,
   QualType CaptureType;
   QualType DeclRefType;
   return tryCaptureVariable(Var, Loc, Kind, EllipsisLoc,
-                            /*BuildAndDiagnose=*/true, CaptureType,
-                            DeclRefType, nullptr);
+                            /*BuildAndDiagnose=*/true, CaptureType, DeclRefType,
+                            nullptr);
 }
 
 bool Sema::NeedToCaptureVariable(ValueDecl *Var, SourceLocation Loc) {
@@ -20064,23 +20152,24 @@ namespace {
 class CopiedTemplateArgs {
   bool HasArgs;
   TemplateArgumentListInfo TemplateArgStorage;
+
 public:
-  template<typename RefExpr>
+  template <typename RefExpr>
   CopiedTemplateArgs(RefExpr *E) : HasArgs(E->hasExplicitTemplateArgs()) {
     if (HasArgs)
       E->copyTemplateArgumentsInto(TemplateArgStorage);
   }
-  operator TemplateArgumentListInfo*()
+  operator TemplateArgumentListInfo *()
 #ifdef __has_cpp_attribute
 #if __has_cpp_attribute(clang::lifetimebound)
-  [[clang::lifetimebound]]
+      [[clang::lifetimebound]]
 #endif
 #endif
   {
     return HasArgs ? &TemplateArgStorage : nullptr;
   }
 };
-}
+} // namespace
 
 /// Walk the set of potential results of an expression and mark them all as
 /// non-odr-uses if they satisfy the side-conditions of the NonOdrUseReason.
@@ -20272,7 +20361,7 @@ static ExprResult rebuildPotentialResultsAsNonOdrUsed(Sema &S, Expr *E,
       if (!Sub.isUsable())
         return Sub;
       BO->setLHS(Sub.get());
-    //   -- If e is a comma expression, ...
+      //   -- If e is a comma expression, ...
     } else if (BO->getOpcode() == BO_Comma) {
       ExprResult Sub = Rebuild(RHS);
       if (!Sub.isUsable())
@@ -20469,8 +20558,8 @@ void Sema::CleanupVarDeclMarking() {
 
   for (Expr *E : LocalMaybeODRUseExprs) {
     if (auto *DRE = dyn_cast<DeclRefExpr>(E)) {
-      MarkVarDeclODRUsed(cast<VarDecl>(DRE->getDecl()),
-                         DRE->getLocation(), *this);
+      MarkVarDeclODRUsed(cast<VarDecl>(DRE->getDecl()), DRE->getLocation(),
+                         *this);
     } else if (auto *ME = dyn_cast<MemberExpr>(E)) {
       MarkVarDeclODRUsed(cast<VarDecl>(ME->getMemberDecl()), ME->getMemberLoc(),
                          *this);
@@ -20591,7 +20680,7 @@ static void DoMarkVarDeclReferenced(
         PointOfInstantiation = Loc;
         if (MSI)
           MSI->setPointOfInstantiation(PointOfInstantiation);
-          // FIXME: Notify listener.
+        // FIXME: Notify listener.
         else
           Var->setTemplateSpecializationKind(TSK, PointOfInstantiation);
       }
@@ -20617,8 +20706,8 @@ static void DoMarkVarDeclReferenced(
         else if (auto *ME = dyn_cast_or_null<MemberExpr>(E))
           ME->setMemberDecl(ME->getMemberDecl());
       } else if (FirstInstantiation) {
-        SemaRef.PendingInstantiations
-            .push_back(std::make_pair(Var, PointOfInstantiation));
+        SemaRef.PendingInstantiations.push_back(
+            std::make_pair(Var, PointOfInstantiation));
       } else {
         bool Inserted = false;
         for (auto &I : SemaRef.SavedPendingInstantiations) {
@@ -20640,8 +20729,8 @@ static void DoMarkVarDeclReferenced(
         // no direct way to avoid enqueueing the pending instantiation
         // multiple times.
         if (isa<VarTemplateSpecializationDecl>(Var) && !Inserted)
-          SemaRef.PendingInstantiations
-            .push_back(std::make_pair(Var, PointOfInstantiation));
+          SemaRef.PendingInstantiations.push_back(
+              std::make_pair(Var, PointOfInstantiation));
       }
     }
   }
@@ -20815,8 +20904,8 @@ MarkExprReferenced(Sema &SemaRef, SourceLocation Loc, Decl *D, Expr *E,
   if (!MD)
     return;
   // Only attempt to devirtualize if this is truly a virtual call.
-  bool IsVirtualCall = MD->isVirtual() &&
-                          ME->performsVirtualDispatch(SemaRef.getLangOpts());
+  bool IsVirtualCall =
+      MD->isVirtual() && ME->performsVirtualDispatch(SemaRef.getLangOpts());
   if (!IsVirtualCall)
     return;
 
@@ -20897,13 +20986,13 @@ void Sema::MarkAnyDeclReferenced(SourceLocation Loc, Decl *D,
 }
 
 namespace {
-  // Mark all of the declarations used by a type as referenced.
-  // FIXME: Not fully implemented yet! We need to have a better understanding
-  // of when we're entering a context we should not recurse into.
-  // FIXME: This is and EvaluatedExprMarker are more-or-less equivalent to
-  // TreeTransforms rebuilding the type in a new context. Rather than
-  // duplicating the TreeTransform logic, we should consider reusing it here.
-  // Currently that causes problems when rebuilding LambdaExprs.
+// Mark all of the declarations used by a type as referenced.
+// FIXME: Not fully implemented yet! We need to have a better understanding
+// of when we're entering a context we should not recurse into.
+// FIXME: This is and EvaluatedExprMarker are more-or-less equivalent to
+// TreeTransforms rebuilding the type in a new context. Rather than
+// duplicating the TreeTransform logic, we should consider reusing it here.
+// Currently that causes problems when rebuilding LambdaExprs.
 class MarkReferencedDecls : public DynamicRecursiveASTVisitor {
   Sema &S;
   SourceLocation Loc;
@@ -20913,7 +21002,7 @@ class MarkReferencedDecls : public DynamicRecursiveASTVisitor {
 
   bool TraverseTemplateArgument(const TemplateArgument &Arg) override;
 };
-}
+} // namespace
 
 bool MarkReferencedDecls::TraverseTemplateArgument(
     const TemplateArgument &Arg) {
@@ -20986,9 +21075,8 @@ class EvaluatedExprMarker : public UsedDeclVisitor<EvaluatedExprMarker> {
 };
 } // namespace
 
-void Sema::MarkDeclarationsReferencedInExpr(Expr *E,
-                                            bool SkipLocalVariables,
-                                            ArrayRef<const Expr*> StopAt) {
+void Sema::MarkDeclarationsReferencedInExpr(Expr *E, bool SkipLocalVariables,
+                                            ArrayRef<const Expr *> StopAt) {
   EvaluatedExprMarker(*this, SkipLocalVariables, StopAt).Visit(E);
 }
 
@@ -21045,7 +21133,7 @@ bool Sema::DiagIfReachable(SourceLocation Loc, ArrayRef<const Stmt *> Stmts,
 /// behavior of a program, such as passing a non-POD value through an ellipsis.
 /// Failure to do so will likely result in spurious diagnostics or failures
 /// during overload resolution or within sizeof/alignof/typeof/typeid.
-bool Sema::DiagRuntimeBehavior(SourceLocation Loc, ArrayRef<const Stmt*> Stmts,
+bool Sema::DiagRuntimeBehavior(SourceLocation Loc, ArrayRef<const Stmt *> Stmts,
                                const PartialDiagnostic &PD) {
 
   if (ExprEvalContexts.back().isDiscardedStatementContext())
@@ -21098,12 +21186,12 @@ bool Sema::CheckCallReturnType(QualType ReturnType, SourceLocation Loc,
 
   public:
     CallReturnIncompleteDiagnoser(FunctionDecl *FD, CallExpr *CE)
-      : FD(FD), CE(CE) { }
+        : FD(FD), CE(CE) {}
 
     void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
       if (!FD) {
         S.Diag(Loc, diag::err_call_incomplete_return)
-          << T << CE->getSourceRange();
+            << T << CE->getSourceRange();
         return;
       }
 
@@ -21135,8 +21223,8 @@ void Sema::DiagnoseAssignmentAsCondition(Expr *E) {
     IsOrAssign = Op->getOpcode() == BO_OrAssign;
 
     // Greylist some idioms by putting them into a warning subcategory.
-    if (ObjCMessageExpr *ME
-          = dyn_cast<ObjCMessageExpr>(Op->getRHS()->IgnoreParenCasts())) {
+    if (ObjCMessageExpr *ME =
+            dyn_cast<ObjCMessageExpr>(Op->getRHS()->IgnoreParenCasts())) {
       Selector Sel = ME->getSelector();
 
       // self = [<foo> init...]
@@ -21167,15 +21255,15 @@ void Sema::DiagnoseAssignmentAsCondition(Expr *E) {
   SourceLocation Open = E->getBeginLoc();
   SourceLocation Close = getLocForEndOfToken(E->getSourceRange().getEnd());
   Diag(Loc, diag::note_condition_assign_silence)
-        << FixItHint::CreateInsertion(Open, "(")
-        << FixItHint::CreateInsertion(Close, ")");
+      << FixItHint::CreateInsertion(Open, "(")
+      << FixItHint::CreateInsertion(Close, ")");
 
   if (IsOrAssign)
     Diag(Loc, diag::note_condition_or_assign_to_comparison)
-      << FixItHint::CreateReplacement(Loc, "!=");
+        << FixItHint::CreateReplacement(Loc, "!=");
   else
     Diag(Loc, diag::note_condition_assign_to_comparison)
-      << FixItHint::CreateReplacement(Loc, "==");
+        << FixItHint::CreateReplacement(Loc, "==");
 }
 
 void Sema::DiagnoseEqualityWithExtraParens(ParenExpr *ParenE) {
@@ -21193,17 +21281,17 @@ void Sema::DiagnoseEqualityWithExtraParens(ParenExpr *ParenE) {
 
   if (BinaryOperator *opE = dyn_cast<BinaryOperator>(E))
     if (opE->getOpcode() == BO_EQ &&
-        opE->getLHS()->IgnoreParenImpCasts()->isModifiableLvalue(Context)
-                                                           == Expr::MLV_Valid) {
+        opE->getLHS()->IgnoreParenImpCasts()->isModifiableLvalue(Context) ==
+            Expr::MLV_Valid) {
       SourceLocation Loc = opE->getOperatorLoc();
 
       Diag(Loc, diag::warn_equality_with_extra_parens) << E->getSourceRange();
       SourceRange ParenERange = ParenE->getSourceRange();
       Diag(Loc, diag::note_equality_comparison_silence)
-        << FixItHint::CreateRemoval(ParenERange.getBegin())
-        << FixItHint::CreateRemoval(ParenERange.getEnd());
+          << FixItHint::CreateRemoval(ParenERange.getBegin())
+          << FixItHint::CreateRemoval(ParenERange.getEnd());
       Diag(Loc, diag::note_equality_comparison_to_assign)
-        << FixItHint::CreateReplacement(Loc, "=");
+          << FixItHint::CreateReplacement(Loc, "=");
     }
 }
 
@@ -21214,7 +21302,8 @@ ExprResult Sema::CheckBooleanCondition(SourceLocation Loc, Expr *E,
     DiagnoseEqualityWithExtraParens(parenE);
 
   ExprResult result = CheckPlaceholderExpr(E);
-  if (result.isInvalid()) return ExprError();
+  if (result.isInvalid())
+    return ExprError();
   E = result.get();
 
   if (!E->isTypeDependent()) {
@@ -21232,7 +21321,7 @@ ExprResult Sema::CheckBooleanCondition(SourceLocation Loc, Expr *E,
     QualType T = E->getType();
     if (!T->isScalarType()) { // C99 6.8.4.1p1
       Diag(Loc, diag::err_typecheck_statement_requires_scalar)
-        << T << E->getSourceRange();
+          << T << E->getSourceRange();
       return ExprError();
     }
     CheckBoolLikeConversion(E, Loc);
@@ -21280,190 +21369,182 @@ Sema::ConditionResult Sema::ActOnCondition(Scope *S, SourceLocation Loc,
 }
 
 namespace {
-  /// A visitor for rebuilding a call to an __unknown_any expression
-  /// to have an appropriate type.
-  struct RebuildUnknownAnyFunction
+/// A visitor for rebuilding a call to an __unknown_any expression
+/// to have an appropriate type.
+struct RebuildUnknownAnyFunction
     : StmtVisitor<RebuildUnknownAnyFunction, ExprResult> {
 
-    Sema &S;
+  Sema &S;
 
-    RebuildUnknownAnyFunction(Sema &S) : S(S) {}
+  RebuildUnknownAnyFunction(Sema &S) : S(S) {}
 
-    ExprResult VisitStmt(Stmt *S) {
-      llvm_unreachable("unexpected statement!");
-    }
+  ExprResult VisitStmt(Stmt *S) { llvm_unreachable("unexpected statement!"); }
 
-    ExprResult VisitExpr(Expr *E) {
-      S.Diag(E->getExprLoc(), diag::err_unsupported_unknown_any_call)
+  ExprResult VisitExpr(Expr *E) {
+    S.Diag(E->getExprLoc(), diag::err_unsupported_unknown_any_call)
         << E->getSourceRange();
-      return ExprError();
-    }
+    return ExprError();
+  }
 
-    /// Rebuild an expression which simply semantically wraps another
-    /// expression which it shares the type and value kind of.
-    template <class T> ExprResult rebuildSugarExpr(T *E) {
-      ExprResult SubResult = Visit(E->getSubExpr());
-      if (SubResult.isInvalid()) return ExprError();
+  /// Rebuild an expression which simply semantically wraps another
+  /// expression which it shares the type and value kind of.
+  template <class T> ExprResult rebuildSugarExpr(T *E) {
+    ExprResult SubResult = Visit(E->getSubExpr());
+    if (SubResult.isInvalid())
+      return ExprError();
 
-      Expr *SubExpr = SubResult.get();
-      E->setSubExpr(SubExpr);
-      E->setType(SubExpr->getType());
-      E->setValueKind(SubExpr->getValueKind());
-      assert(E->getObjectKind() == OK_Ordinary);
-      return E;
-    }
+    Expr *SubExpr = SubResult.get();
+    E->setSubExpr(SubExpr);
+    E->setType(SubExpr->getType());
+    E->setValueKind(SubExpr->getValueKind());
+    assert(E->getObjectKind() == OK_Ordinary);
+    return E;
+  }
 
-    ExprResult VisitParenExpr(ParenExpr *E) {
-      return rebuildSugarExpr(E);
-    }
+  ExprResult VisitParenExpr(ParenExpr *E) { return rebuildSugarExpr(E); }
 
-    ExprResult VisitUnaryExtension(UnaryOperator *E) {
-      return rebuildSugarExpr(E);
-    }
+  ExprResult VisitUnaryExtension(UnaryOperator *E) {
+    return rebuildSugarExpr(E);
+  }
 
-    ExprResult VisitUnaryAddrOf(UnaryOperator *E) {
-      ExprResult SubResult = Visit(E->getSubExpr());
-      if (SubResult.isInvalid()) return ExprError();
+  ExprResult VisitUnaryAddrOf(UnaryOperator *E) {
+    ExprResult SubResult = Visit(E->getSubExpr());
+    if (SubResult.isInvalid())
+      return ExprError();
 
-      Expr *SubExpr = SubResult.get();
-      E->setSubExpr(SubExpr);
-      E->setType(S.Context.getPointerType(SubExpr->getType()));
-      assert(E->isPRValue());
-      assert(E->getObjectKind() == OK_Ordinary);
-      return E;
-    }
+    Expr *SubExpr = SubResult.get();
+    E->setSubExpr(SubExpr);
+    E->setType(S.Context.getPointerType(SubExpr->getType()));
+    assert(E->isPRValue());
+    assert(E->getObjectKind() == OK_Ordinary);
+    return E;
+  }
 
-    ExprResult resolveDecl(Expr *E, ValueDecl *VD) {
-      if (!isa<FunctionDecl>(VD)) return VisitExpr(E);
+  ExprResult resolveDecl(Expr *E, ValueDecl *VD) {
+    if (!isa<FunctionDecl>(VD))
+      return VisitExpr(E);
 
-      E->setType(VD->getType());
+    E->setType(VD->getType());
 
-      assert(E->isPRValue());
-      if (S.getLangOpts().CPlusPlus &&
-          !(isa<CXXMethodDecl>(VD) &&
-            cast<CXXMethodDecl>(VD)->isInstance()))
-        E->setValueKind(VK_LValue);
+    assert(E->isPRValue());
+    if (S.getLangOpts().CPlusPlus &&
+        !(isa<CXXMethodDecl>(VD) && cast<CXXMethodDecl>(VD)->isInstance()))
+      E->setValueKind(VK_LValue);
 
-      return E;
-    }
+    return E;
+  }
 
-    ExprResult VisitMemberExpr(MemberExpr *E) {
-      return resolveDecl(E, E->getMemberDecl());
-    }
+  ExprResult VisitMemberExpr(MemberExpr *E) {
+    return resolveDecl(E, E->getMemberDecl());
+  }
 
-    ExprResult VisitDeclRefExpr(DeclRefExpr *E) {
-      return resolveDecl(E, E->getDecl());
-    }
-  };
-}
+  ExprResult VisitDeclRefExpr(DeclRefExpr *E) {
+    return resolveDecl(E, E->getDecl());
+  }
+};
+} // namespace
 
 /// Given a function expression of unknown-any type, try to rebuild it
 /// to have a function type.
 static ExprResult rebuildUnknownAnyFunction(Sema &S, Expr *FunctionExpr) {
   ExprResult Result = RebuildUnknownAnyFunction(S).Visit(FunctionExpr);
-  if (Result.isInvalid()) return ExprError();
+  if (Result.isInvalid())
+    return ExprError();
   return S.DefaultFunctionArrayConversion(Result.get());
 }
 
 namespace {
-  /// A visitor for rebuilding an expression of type __unknown_anytype
-  /// into one which resolves the type directly on the referring
-  /// expression.  Strict preservation of the original source
-  /// structure is not a goal.
-  struct RebuildUnknownAnyExpr
-    : StmtVisitor<RebuildUnknownAnyExpr, ExprResult> {
+/// A visitor for rebuilding an expression of type __unknown_anytype
+/// into one which resolves the type directly on the referring
+/// expression.  Strict preservation of the original source
+/// structure is not a goal.
+struct RebuildUnknownAnyExpr : StmtVisitor<RebuildUnknownAnyExpr, ExprResult> {
 
-    Sema &S;
+  Sema &S;
 
-    /// The current destination type.
-    QualType DestType;
+  /// The current destination type.
+  QualType DestType;
 
-    RebuildUnknownAnyExpr(Sema &S, QualType CastType)
+  RebuildUnknownAnyExpr(Sema &S, QualType CastType)
       : S(S), DestType(CastType) {}
 
-    ExprResult VisitStmt(Stmt *S) {
-      llvm_unreachable("unexpected statement!");
-    }
+  ExprResult VisitStmt(Stmt *S) { llvm_unreachable("unexpected statement!"); }
 
-    ExprResult VisitExpr(Expr *E) {
-      S.Diag(E->getExprLoc(), diag::err_unsupported_unknown_any_expr)
+  ExprResult VisitExpr(Expr *E) {
+    S.Diag(E->getExprLoc(), diag::err_unsupported_unknown_any_expr)
         << E->getSourceRange();
-      return ExprError();
-    }
+    return ExprError();
+  }
 
-    ExprResult VisitCallExpr(CallExpr *E);
-    ExprResult VisitObjCMessageExpr(ObjCMessageExpr *E);
+  ExprResult VisitCallExpr(CallExpr *E);
+  ExprResult VisitObjCMessageExpr(ObjCMessageExpr *E);
 
-    /// Rebuild an expression which simply semantically wraps another
-    /// expression which it shares the type and value kind of.
-    template <class T> ExprResult rebuildSugarExpr(T *E) {
-      ExprResult SubResult = Visit(E->getSubExpr());
-      if (SubResult.isInvalid()) return ExprError();
-      Expr *SubExpr = SubResult.get();
-      E->setSubExpr(SubExpr);
-      E->setType(SubExpr->getType());
-      E->setValueKind(SubExpr->getValueKind());
-      assert(E->getObjectKind() == OK_Ordinary);
-      return E;
-    }
+  /// Rebuild an expression which simply semantically wraps another
+  /// expression which it shares the type and value kind of.
+  template <class T> ExprResult rebuildSugarExpr(T *E) {
+    ExprResult SubResult = Visit(E->getSubExpr());
+    if (SubResult.isInvalid())
+      return ExprError();
+    Expr *SubExpr = SubResult.get();
+    E->setSubExpr(SubExpr);
+    E->setType(SubExpr->getType());
+    E->setValueKind(SubExpr->getValueKind());
+    assert(E->getObjectKind() == OK_Ordinary);
+    return E;
+  }
 
-    ExprResult VisitParenExpr(ParenExpr *E) {
-      return rebuildSugarExpr(E);
-    }
+  ExprResult VisitParenExpr(ParenExpr *E) { return rebuildSugarExpr(E); }
 
-    ExprResult VisitUnaryExtension(UnaryOperator *E) {
-      return rebuildSugarExpr(E);
-    }
+  ExprResult VisitUnaryExtension(UnaryOperator *E) {
+    return rebuildSugarExpr(E);
+  }
 
-    ExprResult VisitUnaryAddrOf(UnaryOperator *E) {
-      const PointerType *Ptr = DestType->getAs<PointerType>();
-      if (!Ptr) {
-        S.Diag(E->getOperatorLoc(), diag::err_unknown_any_addrof)
+  ExprResult VisitUnaryAddrOf(UnaryOperator *E) {
+    const PointerType *Ptr = DestType->getAs<PointerType>();
+    if (!Ptr) {
+      S.Diag(E->getOperatorLoc(), diag::err_unknown_any_addrof)
           << E->getSourceRange();
-        return ExprError();
-      }
+      return ExprError();
+    }
 
-      if (isa<CallExpr>(E->getSubExpr())) {
-        S.Diag(E->getOperatorLoc(), diag::err_unknown_any_addrof_call)
+    if (isa<CallExpr>(E->getSubExpr())) {
+      S.Diag(E->getOperatorLoc(), diag::err_unknown_any_addrof_call)
           << E->getSourceRange();
-        return ExprError();
-      }
+      return ExprError();
+    }
 
-      assert(E->isPRValue());
-      assert(E->getObjectKind() == OK_Ordinary);
-      E->setType(DestType);
+    assert(E->isPRValue());
+    assert(E->getObjectKind() == OK_Ordinary);
+    E->setType(DestType);
 
-      // Build the sub-expression as if it were an object of the pointee type.
-      DestType = Ptr->getPointeeType();
-      ExprResult SubResult = Visit(E->getSubExpr());
-      if (SubResult.isInvalid()) return ExprError();
-      E->setSubExpr(SubResult.get());
-      return E;
-    }
+    // Build the sub-expression as if it were an object of the pointee type.
+    DestType = Ptr->getPointeeType();
+    ExprResult SubResult = Visit(E->getSubExpr());
+    if (SubResult.isInvalid())
+      return ExprError();
+    E->setSubExpr(SubResult.get());
+    return E;
+  }
 
-    ExprResult VisitImplicitCastExpr(ImplicitCastExpr *E);
+  ExprResult VisitImplicitCastExpr(ImplicitCastExpr *E);
 
-    ExprResult resolveDecl(Expr *E, ValueDecl *VD);
+  ExprResult resolveDecl(Expr *E, ValueDecl *VD);
 
-    ExprResult VisitMemberExpr(MemberExpr *E) {
-      return resolveDecl(E, E->getMemberDecl());
-    }
+  ExprResult VisitMemberExpr(MemberExpr *E) {
+    return resolveDecl(E, E->getMemberDecl());
+  }
 
-    ExprResult VisitDeclRefExpr(DeclRefExpr *E) {
-      return resolveDecl(E, E->getDecl());
-    }
-  };
-}
+  ExprResult VisitDeclRefExpr(DeclRefExpr *E) {
+    return resolveDecl(E, E->getDecl());
+  }
+};
+} // namespace
 
 /// Rebuilds a call expression which yielded __unknown_anytype.
 ExprResult RebuildUnknownAnyExpr::VisitCallExpr(CallExpr *E) {
   Expr *CalleeExpr = E->getCallee();
 
-  enum FnKind {
-    FK_MemberFunction,
-    FK_FunctionPointer,
-    FK_BlockPointer
-  };
+  enum FnKind { FK_MemberFunction, FK_FunctionPointer, FK_BlockPointer };
 
   FnKind Kind;
   QualType CalleeType = CalleeExpr->getType();
@@ -21487,8 +21568,7 @@ ExprResult RebuildUnknownAnyExpr::VisitCallExpr(CallExpr *E) {
     if (Kind == FK_BlockPointer)
       diagID = diag::err_block_returning_array_function;
 
-    S.Diag(E->getExprLoc(), diagID)
-      << DestType->isFunctionType() << DestType;
+    S.Diag(E->getExprLoc(), diagID) << DestType->isFunctionType() << DestType;
     return ExprError();
   }
 
@@ -21531,8 +21611,7 @@ ExprResult RebuildUnknownAnyExpr::VisitCallExpr(CallExpr *E) {
     DestType = S.Context.getFunctionType(DestType, ParamTypes,
                                          Proto->getExtProtoInfo());
   } else {
-    DestType = S.Context.getFunctionNoProtoType(DestType,
-                                                FnType->getExtInfo());
+    DestType = S.Context.getFunctionNoProtoType(DestType, FnType->getExtInfo());
   }
 
   // Rebuild the appropriate pointer-to-function type.
@@ -21552,7 +21631,8 @@ ExprResult RebuildUnknownAnyExpr::VisitCallExpr(CallExpr *E) {
 
   // Finally, we can recurse.
   ExprResult CalleeResult = Visit(CalleeExpr);
-  if (!CalleeResult.isUsable()) return ExprError();
+  if (!CalleeResult.isUsable())
+    return ExprError();
   E->setCallee(CalleeResult.get());
 
   // Bind a temporary if necessary.
@@ -21563,7 +21643,7 @@ ExprResult RebuildUnknownAnyExpr::VisitObjCMessageExpr(ObjCMessageExpr *E) {
   // Verify that this is a legal result type of a call.
   if (DestType->isArrayType() || DestType->isFunctionType()) {
     S.Diag(E->getExprLoc(), diag::err_func_returning_array_function)
-      << DestType->isFunctionType() << DestType;
+        << DestType->isFunctionType() << DestType;
     return ExprError();
   }
 
@@ -21592,7 +21672,8 @@ ExprResult RebuildUnknownAnyExpr::VisitImplicitCastExpr(ImplicitCastExpr *E) {
     DestType = DestType->castAs<PointerType>()->getPointeeType();
 
     ExprResult Result = Visit(E->getSubExpr());
-    if (!Result.isUsable()) return ExprError();
+    if (!Result.isUsable())
+      return ExprError();
 
     E->setSubExpr(Result.get());
     return E;
@@ -21608,7 +21689,8 @@ ExprResult RebuildUnknownAnyExpr::VisitImplicitCastExpr(ImplicitCastExpr *E) {
     DestType = S.Context.getLValueReferenceType(DestType);
 
     ExprResult Result = Visit(E->getSubExpr());
-    if (!Result.isUsable()) return ExprError();
+    if (!Result.isUsable())
+      return ExprError();
 
     E->setSubExpr(Result.get());
     return E;
@@ -21628,14 +21710,15 @@ ExprResult RebuildUnknownAnyExpr::resolveDecl(Expr *E, ValueDecl *VD) {
     if (const PointerType *Ptr = Type->getAs<PointerType>()) {
       DestType = Ptr->getPointeeType();
       ExprResult Result = resolveDecl(E, VD);
-      if (Result.isInvalid()) return ExprError();
+      if (Result.isInvalid())
+        return ExprError();
       return S.ImpCastExprToType(Result.get(), Type, CK_FunctionToPointerDecay,
                                  VK_PRValue);
     }
 
     if (!Type->isFunctionType()) {
       S.Diag(E->getExprLoc(), diag::err_unknown_any_function)
-        << VD << E->getSourceRange();
+          << VD << E->getSourceRange();
       return ExprError();
     }
     if (const FunctionProtoType *FT = Type->getAs<FunctionProtoType>()) {
@@ -21644,9 +21727,11 @@ ExprResult RebuildUnknownAnyExpr::resolveDecl(Expr *E, ValueDecl *VD) {
       // type. See the lengthy commentary in that routine.
       QualType FDT = FD->getType();
       const FunctionType *FnType = FDT->castAs<FunctionType>();
-      const FunctionProtoType *Proto = dyn_cast_or_null<FunctionProtoType>(FnType);
+      const FunctionProtoType *Proto =
+          dyn_cast_or_null<FunctionProtoType>(FnType);
       DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E);
-      if (DRE && Proto && Proto->getParamTypes().empty() && Proto->isVariadic()) {
+      if (DRE && Proto && Proto->getParamTypes().empty() &&
+          Proto->isVariadic()) {
         SourceLocation Loc = FD->getLocation();
         FunctionDecl *NewFD = FunctionDecl::Create(
             S.Context, FD->getDeclContext(), Loc, Loc,
@@ -21658,10 +21743,9 @@ ExprResult RebuildUnknownAnyExpr::resolveDecl(Expr *E, ValueDecl *VD) {
         if (FD->getQualifier())
           NewFD->setQualifierInfo(FD->getQualifierLoc());
 
-        SmallVector<ParmVarDecl*, 16> Params;
+        SmallVector<ParmVarDecl *, 16> Params;
         for (const auto &AI : FT->param_types()) {
-          ParmVarDecl *Param =
-            S.BuildParmVarDeclForTypedef(FD, Loc, AI);
+          ParmVarDecl *Param = S.BuildParmVarDeclForTypedef(FD, Loc, AI);
           Param->setScopeInfo(0, Params.size());
           Params.push_back(Param);
         }
@@ -21681,20 +21765,20 @@ ExprResult RebuildUnknownAnyExpr::resolveDecl(Expr *E, ValueDecl *VD) {
     if (!S.getLangOpts().CPlusPlus)
       ValueKind = VK_PRValue;
 
-  //  - variables
+    //  - variables
   } else if (isa<VarDecl>(VD)) {
     if (const ReferenceType *RefTy = Type->getAs<ReferenceType>()) {
       Type = RefTy->getPointeeType();
     } else if (Type->isFunctionType()) {
       S.Diag(E->getExprLoc(), diag::err_unknown_any_var_function_type)
-        << VD << E->getSourceRange();
+          << VD << E->getSourceRange();
       return ExprError();
     }
 
-  //  - nothing else
+    //  - nothing else
   } else {
     S.Diag(E->getExprLoc(), diag::err_unsupported_unknown_any_decl)
-      << VD << E->getSourceRange();
+        << VD << E->getSourceRange();
     return ExprError();
   }
 
@@ -21717,7 +21801,8 @@ ExprResult Sema::checkUnknownAnyCast(SourceRange TypeRange, QualType CastType,
 
   // Rewrite the casted expression from scratch.
   ExprResult result = RebuildUnknownAnyExpr(*this, CastType).Visit(CastExpr);
-  if (!result.isUsable()) return ExprError();
+  if (!result.isUsable())
+    return ExprError();
 
   CastExpr = result.get();
   VK = CastExpr->getValueKind();
@@ -21730,14 +21815,15 @@ ExprResult Sema::forceUnknownAnyToType(Expr *E, QualType ToType) {
   return RebuildUnknownAnyExpr(*this, ToType).Visit(E);
 }
 
-ExprResult Sema::checkUnknownAnyArg(SourceLocation callLoc,
-                                    Expr *arg, QualType &paramType) {
+ExprResult Sema::checkUnknownAnyArg(SourceLocation callLoc, Expr *arg,
+                                    QualType &paramType) {
   // If the syntactic form of the argument is not an explicit cast of
   // any sort, just do default argument promotion.
   ExplicitCastExpr *castArg = dyn_cast<ExplicitCastExpr>(arg->IgnoreParens());
   if (!castArg) {
     ExprResult result = DefaultArgumentPromotion(arg);
-    if (result.isInvalid()) return ExprError();
+    if (result.isInvalid())
+      return ExprError();
     paramType = result.get()->getType();
     return result;
   }
@@ -21748,8 +21834,8 @@ ExprResult Sema::checkUnknownAnyArg(SourceLocation callLoc,
 
   // Copy-initialize a parameter of that type.
   InitializedEntity entity =
-    InitializedEntity::InitializeParameter(Context, paramType,
-                                           /*consumed*/ false);
+      InitializedEntity::InitializeParameter(Context, paramType,
+                                             /*consumed*/ false);
   return PerformCopyInitialization(entity, callLoc, arg);
 }
 
@@ -21780,13 +21866,13 @@ static ExprResult diagnoseUnknownAnyExpr(Sema &S, Expr *E) {
     d = msg->getMethodDecl();
     if (!d) {
       S.Diag(loc, diag::err_uncasted_send_to_unknown_any_method)
-        << static_cast<unsigned>(msg->isClassMessage()) << msg->getSelector()
-        << orig->getSourceRange();
+          << static_cast<unsigned>(msg->isClassMessage()) << msg->getSelector()
+          << orig->getSourceRange();
       return ExprError();
     }
   } else {
     S.Diag(E->getExprLoc(), diag::err_unsupported_unknown_any_expr)
-      << E->getSourceRange();
+        << E->getSourceRange();
     return ExprError();
   }
 
@@ -21798,7 +21884,8 @@ static ExprResult diagnoseUnknownAnyExpr(Sema &S, Expr *E) {
 
 ExprResult Sema::CheckPlaceholderExpr(Expr *E) {
   const BuiltinType *placeholderType = E->getType()->getAsPlaceholderType();
-  if (!placeholderType) return E;
+  if (!placeholderType)
+    return E;
 
   switch (placeholderType->getKind()) {
   case BuiltinType::UnresolvedTemplate: {
@@ -21979,18 +22066,15 @@ ExprResult Sema::CheckPlaceholderExpr(Expr *E) {
   case BuiltinType::OMPIterator:
     return ExprError(Diag(E->getBeginLoc(), diag::err_omp_iterator_use));
 
-  // Everything else should be impossible.
-#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
+    // Everything else should be impossible.
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)                   \
   case BuiltinType::Id:
 #include "clang/Basic/OpenCLImageTypes.def"
-#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
-  case BuiltinType::Id:
+#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) case BuiltinType::Id:
 #include "clang/Basic/OpenCLExtensionTypes.def"
-#define SVE_TYPE(Name, Id, SingletonId) \
-  case BuiltinType::Id:
+#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
 #include "clang/Basic/AArch64ACLETypes.def"
-#define PPC_VECTOR_TYPE(Name, Id, Size) \
-  case BuiltinType::Id:
+#define PPC_VECTOR_TYPE(Name, Id, Size) case BuiltinType::Id:
 #include "clang/Basic/PPCTypes.def"
 #define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
 #include "clang/Basic/RISCVVTypes.def"
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 94a58870fa016..61aa1fc815b3d 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -90,33 +90,27 @@ static ExprResult CreateFunctionRefExpr(
                              CK_FunctionToPointerDecay);
 }
 
-static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
+static bool IsStandardConversion(Sema &S, Expr *From, QualType ToType,
                                  bool InOverloadResolution,
-                                 StandardConversionSequence &SCS,
-                                 bool CStyle,
+                                 StandardConversionSequence &SCS, bool CStyle,
                                  bool AllowObjCWritebackConversion);
 
-static bool IsTransparentUnionStandardConversion(Sema &S, Expr* From,
-                                                 QualType &ToType,
-                                                 bool InOverloadResolution,
-                                                 StandardConversionSequence &SCS,
-                                                 bool CStyle);
-static OverloadingResult
-IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
-                        UserDefinedConversionSequence& User,
-                        OverloadCandidateSet& Conversions,
-                        AllowedExplicit AllowExplicit,
-                        bool AllowObjCConversionOnExplicit);
+static bool IsTransparentUnionStandardConversion(
+    Sema &S, Expr *From, QualType &ToType, bool InOverloadResolution,
+    StandardConversionSequence &SCS, bool CStyle);
+static OverloadingResult IsUserDefinedConversion(
+    Sema &S, Expr *From, QualType ToType, UserDefinedConversionSequence &User,
+    OverloadCandidateSet &Conversions, AllowedExplicit AllowExplicit,
+    bool AllowObjCConversionOnExplicit);
 
 static ImplicitConversionSequence::CompareKind
 CompareStandardConversionSequences(Sema &S, SourceLocation Loc,
-                                   const StandardConversionSequence& SCS1,
-                                   const StandardConversionSequence& SCS2);
+                                   const StandardConversionSequence &SCS1,
+                                   const StandardConversionSequence &SCS2);
 
 static ImplicitConversionSequence::CompareKind
-CompareQualificationConversions(Sema &S,
-                                const StandardConversionSequence& SCS1,
-                                const StandardConversionSequence& SCS2);
+CompareQualificationConversions(Sema &S, const StandardConversionSequence &SCS1,
+                                const StandardConversionSequence &SCS2);
 
 static ImplicitConversionSequence::CompareKind
 CompareOverflowBehaviorConversions(Sema &S,
@@ -125,8 +119,8 @@ CompareOverflowBehaviorConversions(Sema &S,
 
 static ImplicitConversionSequence::CompareKind
 CompareDerivedToBaseConversions(Sema &S, SourceLocation Loc,
-                                const StandardConversionSequence& SCS1,
-                                const StandardConversionSequence& SCS2);
+                                const StandardConversionSequence &SCS1,
+                                const StandardConversionSequence &SCS2);
 
 /// GetConversionRank - Retrieve the implicit conversion rank
 /// corresponding to the given implicit conversion kind.
@@ -287,11 +281,10 @@ bool StandardConversionSequence::isPointerConversionToBool() const {
   // check for their presence as well as checking whether FromType is
   // a pointer.
   if (getToType(1)->isBooleanType() &&
-      (getFromType()->isPointerType() ||
-       getFromType()->isMemberPointerType() ||
+      (getFromType()->isPointerType() || getFromType()->isMemberPointerType() ||
        getFromType()->isObjCObjectPointerType() ||
-       getFromType()->isBlockPointerType() ||
-       First == ICK_Array_To_Pointer || First == ICK_Function_To_Pointer))
+       getFromType()->isBlockPointerType() || First == ICK_Array_To_Pointer ||
+       First == ICK_Function_To_Pointer))
     return true;
 
   return false;
@@ -301,9 +294,8 @@ bool StandardConversionSequence::isPointerConversionToBool() const {
 /// conversion is a conversion of a pointer to a void pointer. This is
 /// used as part of the ranking of standard conversion sequences (C++
 /// 13.3.3.2p4).
-bool
-StandardConversionSequence::
-isPointerConversionToVoidPointer(ASTContext& Context) const {
+bool StandardConversionSequence::isPointerConversionToVoidPointer(
+    ASTContext &Context) const {
   QualType FromType = getFromType();
   QualType ToType = getToType(1);
 
@@ -314,7 +306,7 @@ isPointerConversionToVoidPointer(ASTContext& Context) const {
     FromType = Context.getArrayDecayedType(FromType);
 
   if (Second == ICK_Pointer_Conversion && FromType->isAnyPointerType())
-    if (const PointerType* ToPtrType = ToType->getAs<PointerType>())
+    if (const PointerType *ToPtrType = ToType->getAs<PointerType>())
       return ToPtrType->getPointeeType()->isVoidType();
 
   return false;
@@ -707,42 +699,40 @@ void AmbiguousConversionSequence::construct() {
   new (&conversions()) ConversionSet();
 }
 
-void AmbiguousConversionSequence::destruct() {
-  conversions().~ConversionSet();
-}
+void AmbiguousConversionSequence::destruct() { conversions().~ConversionSet(); }
 
-void
-AmbiguousConversionSequence::copyFrom(const AmbiguousConversionSequence &O) {
+void AmbiguousConversionSequence::copyFrom(
+    const AmbiguousConversionSequence &O) {
   FromTypePtr = O.FromTypePtr;
   ToTypePtr = O.ToTypePtr;
   new (&conversions()) ConversionSet(O.conversions());
 }
 
 namespace {
-  // Structure used by DeductionFailureInfo to store
-  // template argument information.
-  struct DFIArguments {
-    TemplateArgument FirstArg;
-    TemplateArgument SecondArg;
-  };
-  // Structure used by DeductionFailureInfo to store
-  // template parameter and template argument information.
-  struct DFIParamWithArguments : DFIArguments {
-    TemplateParameter Param;
-  };
-  // Structure used by DeductionFailureInfo to store template argument
-  // information and the index of the problematic call argument.
-  struct DFIDeducedMismatchArgs : DFIArguments {
-    TemplateArgumentList *TemplateArgs;
-    unsigned CallArgIndex;
-  };
-  // Structure used by DeductionFailureInfo to store information about
-  // unsatisfied constraints.
-  struct CNSInfo {
-    TemplateArgumentList *TemplateArgs;
-    ConstraintSatisfaction Satisfaction;
-  };
-}
+// Structure used by DeductionFailureInfo to store
+// template argument information.
+struct DFIArguments {
+  TemplateArgument FirstArg;
+  TemplateArgument SecondArg;
+};
+// Structure used by DeductionFailureInfo to store
+// template parameter and template argument information.
+struct DFIParamWithArguments : DFIArguments {
+  TemplateParameter Param;
+};
+// Structure used by DeductionFailureInfo to store template argument
+// information and the index of the problematic call argument.
+struct DFIDeducedMismatchArgs : DFIArguments {
+  TemplateArgumentList *TemplateArgs;
+  unsigned CallArgIndex;
+};
+// Structure used by DeductionFailureInfo to store information about
+// unsatisfied constraints.
+struct CNSInfo {
+  TemplateArgumentList *TemplateArgs;
+  ConstraintSatisfaction Satisfaction;
+};
+} // namespace
 
 /// Convert from Sema's representation of template deduction information
 /// to the form used in overload-candidate information.
@@ -880,7 +870,7 @@ void DeductionFailureInfo::Destroy() {
 
 PartialDiagnosticAt *DeductionFailureInfo::getSFINAEDiagnostic() {
   if (HasDiagnostic)
-    return static_cast<PartialDiagnosticAt*>(static_cast<void*>(Diagnostic));
+    return static_cast<PartialDiagnosticAt *>(static_cast<void *>(Diagnostic));
   return nullptr;
 }
 
@@ -907,7 +897,7 @@ TemplateParameter DeductionFailureInfo::getTemplateParameter() {
   case TemplateDeductionResult::IncompletePack:
   case TemplateDeductionResult::Inconsistent:
   case TemplateDeductionResult::Underqualified:
-    return static_cast<DFIParamWithArguments*>(Data)->Param;
+    return static_cast<DFIParamWithArguments *>(Data)->Param;
 
   // Unhandled
   case TemplateDeductionResult::MiscellaneousDeductionFailure:
@@ -937,13 +927,13 @@ TemplateArgumentList *DeductionFailureInfo::getTemplateArgumentList() {
 
   case TemplateDeductionResult::DeducedMismatch:
   case TemplateDeductionResult::DeducedMismatchNested:
-    return static_cast<DFIDeducedMismatchArgs*>(Data)->TemplateArgs;
+    return static_cast<DFIDeducedMismatchArgs *>(Data)->TemplateArgs;
 
   case TemplateDeductionResult::SubstitutionFailure:
-    return static_cast<TemplateArgumentList*>(Data);
+    return static_cast<TemplateArgumentList *>(Data);
 
   case TemplateDeductionResult::ConstraintsNotSatisfied:
-    return static_cast<CNSInfo*>(Data)->TemplateArgs;
+    return static_cast<CNSInfo *>(Data)->TemplateArgs;
 
   // Unhandled
   case TemplateDeductionResult::MiscellaneousDeductionFailure:
@@ -975,7 +965,7 @@ const TemplateArgument *DeductionFailureInfo::getFirstArg() {
   case TemplateDeductionResult::DeducedMismatch:
   case TemplateDeductionResult::DeducedMismatchNested:
   case TemplateDeductionResult::NonDeducedMismatch:
-    return &static_cast<DFIArguments*>(Data)->FirstArg;
+    return &static_cast<DFIArguments *>(Data)->FirstArg;
 
   // Unhandled
   case TemplateDeductionResult::MiscellaneousDeductionFailure:
@@ -1007,7 +997,7 @@ const TemplateArgument *DeductionFailureInfo::getSecondArg() {
   case TemplateDeductionResult::DeducedMismatch:
   case TemplateDeductionResult::DeducedMismatchNested:
   case TemplateDeductionResult::NonDeducedMismatch:
-    return &static_cast<DFIArguments*>(Data)->SecondArg;
+    return &static_cast<DFIArguments *>(Data)->SecondArg;
 
   // Unhandled
   case TemplateDeductionResult::MiscellaneousDeductionFailure:
@@ -1022,7 +1012,7 @@ UnsignedOrNone DeductionFailureInfo::getCallArgIndex() {
   switch (static_cast<TemplateDeductionResult>(Result)) {
   case TemplateDeductionResult::DeducedMismatch:
   case TemplateDeductionResult::DeducedMismatchNested:
-    return static_cast<DFIDeducedMismatchArgs*>(Data)->CallArgIndex;
+    return static_cast<DFIDeducedMismatchArgs *>(Data)->CallArgIndex;
 
   default:
     return std::nullopt;
@@ -1146,28 +1136,29 @@ void OverloadCandidateSet::clear(CandidateSetKind CSK) {
 }
 
 namespace {
-  class UnbridgedCastsSet {
-    struct Entry {
-      Expr **Addr;
-      Expr *Saved;
-    };
-    SmallVector<Entry, 2> Entries;
+class UnbridgedCastsSet {
+  struct Entry {
+    Expr **Addr;
+    Expr *Saved;
+  };
+  SmallVector<Entry, 2> Entries;
 
-  public:
-    void save(Sema &S, Expr *&E) {
-      assert(E->hasPlaceholderType(BuiltinType::ARCUnbridgedCast));
-      Entry entry = { &E, E };
-      Entries.push_back(entry);
-      E = S.ObjC().stripARCUnbridgedCast(E);
-    }
+public:
+  void save(Sema &S, Expr *&E) {
+    assert(E->hasPlaceholderType(BuiltinType::ARCUnbridgedCast));
+    Entry entry = {&E, E};
+    Entries.push_back(entry);
+    E = S.ObjC().stripARCUnbridgedCast(E);
+  }
 
-    void restore() {
-      for (SmallVectorImpl<Entry>::iterator
-             i = Entries.begin(), e = Entries.end(); i != e; ++i)
-        *i->Addr = i->Saved;
-    }
-  };
-}
+  void restore() {
+    for (SmallVectorImpl<Entry>::iterator i = Entries.begin(),
+                                          e = Entries.end();
+         i != e; ++i)
+      *i->Addr = i->Saved;
+  }
+};
+} // namespace
 
 /// checkPlaceholderForOverload - Do any interesting placeholder-like
 /// preprocessing on the given expression.
@@ -1179,10 +1170,11 @@ namespace {
 static bool
 checkPlaceholderForOverload(Sema &S, Expr *&E,
                             UnbridgedCastsSet *unbridgedCasts = nullptr) {
-  if (const BuiltinType *placeholder =  E->getType()->getAsPlaceholderType()) {
+  if (const BuiltinType *placeholder = E->getType()->getAsPlaceholderType()) {
     // We can't handle overloaded expressions here because overload
     // resolution might reasonably tweak them.
-    if (placeholder->getKind() == BuiltinType::Overload) return false;
+    if (placeholder->getKind() == BuiltinType::Overload)
+      return false;
 
     // If the context potentially accepts unbridged ARC casts, strip
     // the unbridged cast and add it to the collection for later restoration.
@@ -1219,8 +1211,7 @@ static bool checkArgPlaceholdersForOverload(Sema &S, MultiExprArg Args,
 OverloadKind Sema::CheckOverload(Scope *S, FunctionDecl *New,
                                  const LookupResult &Old, NamedDecl *&Match,
                                  bool NewIsUsingDecl) {
-  for (LookupResult::iterator I = Old.begin(), E = Old.end();
-         I != E; ++I) {
+  for (LookupResult::iterator I = Old.begin(), E = Old.end(); I != E; ++I) {
     NamedDecl *OldD = *I;
 
     bool OldIsUsingDecl = false;
@@ -1229,7 +1220,8 @@ OverloadKind Sema::CheckOverload(Scope *S, FunctionDecl *New,
 
       // We can always introduce two using declarations into the same
       // context, even if they have identical signatures.
-      if (NewIsUsingDecl) continue;
+      if (NewIsUsingDecl)
+        continue;
 
       OldD = cast<UsingShadowDecl>(OldD)->getTargetDecl();
     }
@@ -1244,9 +1236,9 @@ OverloadKind Sema::CheckOverload(Scope *S, FunctionDecl *New,
     // Essentially, these rules are the normal rules, except that
     // function templates hide function templates with different
     // return types or template parameter lists.
-    bool UseMemberUsingDeclRules =
-      (OldIsUsingDecl || NewIsUsingDecl) && CurContext->isRecord() &&
-      !New->getFriendObjectKind();
+    bool UseMemberUsingDeclRules = (OldIsUsingDecl || NewIsUsingDecl) &&
+                                   CurContext->isRecord() &&
+                                   !New->getFriendObjectKind();
 
     if (FunctionDecl *OldF = OldD->getAsFunction()) {
       if (!IsOverload(New, OldF, UseMemberUsingDeclRules)) {
@@ -1317,7 +1309,7 @@ OverloadKind Sema::CheckOverload(Scope *S, FunctionDecl *New,
     LookupResult TemplateSpecResult(LookupResult::Temporary, Old);
     TemplateSpecResult.addAllDecls(Old);
     if (CheckFunctionTemplateSpecialization(New, nullptr, TemplateSpecResult,
-                                            /*QualifiedFriend*/true)) {
+                                            /*QualifiedFriend*/ true)) {
       New->setInvalidDecl();
       return OverloadKind::Overload;
     }
@@ -1598,10 +1590,10 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, FunctionDecl *New,
 
   // enable_if attributes are an order-sensitive part of the signature.
   for (specific_attr_iterator<EnableIfAttr>
-         NewI = New->specific_attr_begin<EnableIfAttr>(),
-         NewE = New->specific_attr_end<EnableIfAttr>(),
-         OldI = Old->specific_attr_begin<EnableIfAttr>(),
-         OldE = Old->specific_attr_end<EnableIfAttr>();
+           NewI = New->specific_attr_begin<EnableIfAttr>(),
+           NewE = New->specific_attr_end<EnableIfAttr>(),
+           OldI = Old->specific_attr_begin<EnableIfAttr>(),
+           OldE = Old->specific_attr_end<EnableIfAttr>();
        NewI != NewE || OldI != OldE; ++NewI, ++OldI) {
     if (NewI == NewE || OldI == OldE)
       return true;
@@ -1664,14 +1656,10 @@ bool Sema::IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD,
 ///
 /// Produces an implicit conversion sequence for when a standard conversion
 /// is not an option. See TryImplicitConversion for more information.
-static ImplicitConversionSequence
-TryUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
-                         bool SuppressUserConversions,
-                         AllowedExplicit AllowExplicit,
-                         bool InOverloadResolution,
-                         bool CStyle,
-                         bool AllowObjCWritebackConversion,
-                         bool AllowObjCConversionOnExplicit) {
+static ImplicitConversionSequence TryUserDefinedConversion(
+    Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions,
+    AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle,
+    bool AllowObjCWritebackConversion, bool AllowObjCConversionOnExplicit) {
   ImplicitConversionSequence ICS;
 
   if (SuppressUserConversions) {
@@ -1684,8 +1672,8 @@ TryUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
   // Attempt user-defined conversion.
   OverloadCandidateSet Conversions(From->getExprLoc(),
                                    OverloadCandidateSet::CSK_Normal);
-  switch (IsUserDefinedConversion(S, From, ToType, ICS.UserDefined,
-                                  Conversions, AllowExplicit,
+  switch (IsUserDefinedConversion(S, From, ToType, ICS.UserDefined, Conversions,
+                                  AllowExplicit,
                                   AllowObjCConversionOnExplicit)) {
   case OR_Success:
   case OR_Deleted:
@@ -1697,8 +1685,8 @@ TryUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
     //   given Conversion rank, in spite of the fact that a copy
     //   constructor (i.e., a user-defined conversion function) is
     //   called for those cases.
-    if (CXXConstructorDecl *Constructor
-          = dyn_cast<CXXConstructorDecl>(ICS.UserDefined.ConversionFunction)) {
+    if (CXXConstructorDecl *Constructor =
+            dyn_cast<CXXConstructorDecl>(ICS.UserDefined.ConversionFunction)) {
       QualType FromType;
       SourceLocation FromLoc;
       // C++11 [over.ics.list]p6, per DR2137:
@@ -1721,8 +1709,8 @@ TryUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
       }
       QualType FromCanon =
           S.Context.getCanonicalType(FromType.getUnqualifiedType());
-      QualType ToCanon
-        = S.Context.getCanonicalType(ToType).getUnqualifiedType();
+      QualType ToCanon =
+          S.Context.getCanonicalType(ToType).getUnqualifiedType();
       if ((FromCanon == ToCanon ||
            S.IsDerivedFrom(FromLoc, FromCanon, ToCanon))) {
         // Turn this into a "standard" conversion sequence, so that it
@@ -1787,17 +1775,13 @@ TryUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
 /// \param AllowObjCWritebackConversion Whether we allow the Objective-C
 /// writeback conversion, which allows __autoreleasing id* parameters to
 /// be initialized with __strong id* or __weak id* arguments.
-static ImplicitConversionSequence
-TryImplicitConversion(Sema &S, Expr *From, QualType ToType,
-                      bool SuppressUserConversions,
-                      AllowedExplicit AllowExplicit,
-                      bool InOverloadResolution,
-                      bool CStyle,
-                      bool AllowObjCWritebackConversion,
-                      bool AllowObjCConversionOnExplicit) {
+static ImplicitConversionSequence TryImplicitConversion(
+    Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions,
+    AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle,
+    bool AllowObjCWritebackConversion, bool AllowObjCConversionOnExplicit) {
   ImplicitConversionSequence ICS;
-  if (IsStandardConversion(S, From, ToType, InOverloadResolution,
-                           ICS.Standard, CStyle, AllowObjCWritebackConversion)){
+  if (IsStandardConversion(S, From, ToType, InOverloadResolution, ICS.Standard,
+                           CStyle, AllowObjCWritebackConversion)) {
     ICS.setStandard();
     return ICS;
   }
@@ -1873,13 +1857,10 @@ TryImplicitConversion(Sema &S, Expr *From, QualType ToType,
                                   AllowObjCConversionOnExplicit);
 }
 
-ImplicitConversionSequence
-Sema::TryImplicitConversion(Expr *From, QualType ToType,
-                            bool SuppressUserConversions,
-                            AllowedExplicit AllowExplicit,
-                            bool InOverloadResolution,
-                            bool CStyle,
-                            bool AllowObjCWritebackConversion) {
+ImplicitConversionSequence Sema::TryImplicitConversion(
+    Expr *From, QualType ToType, bool SuppressUserConversions,
+    AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle,
+    bool AllowObjCWritebackConversion) {
   return ::TryImplicitConversion(*this, From, ToType, SuppressUserConversions,
                                  AllowExplicit, InOverloadResolution, CStyle,
                                  AllowObjCWritebackConversion,
@@ -1931,7 +1912,8 @@ bool Sema::IsFunctionConversion(QualType FromType, QualType ToType) const {
   CanQualType CanTo = Context.getCanonicalType(ToType);
   CanQualType CanFrom = Context.getCanonicalType(FromType);
   Type::TypeClass TyClass = CanTo->getTypeClass();
-  if (TyClass != CanFrom->getTypeClass()) return false;
+  if (TyClass != CanFrom->getTypeClass())
+    return false;
   if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto) {
     if (TyClass == Type::Pointer) {
       CanTo = CanTo.castAs<PointerType>()->getPointeeType();
@@ -1953,7 +1935,8 @@ bool Sema::IsFunctionConversion(QualType FromType, QualType ToType) const {
     }
 
     TyClass = CanTo->getTypeClass();
-    if (TyClass != CanFrom->getTypeClass()) return false;
+    if (TyClass != CanFrom->getTypeClass())
+      return false;
     if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto)
       return false;
   }
@@ -1991,9 +1974,9 @@ bool Sema::IsFunctionConversion(QualType FromType, QualType ToType) const {
   if (FromFPT && ToFPT) {
     if (FromFPT->isNothrow() && !ToFPT->isNothrow()) {
       FromFn = cast<FunctionType>(
-          Context.getFunctionTypeWithExceptionSpec(QualType(FromFPT, 0),
-                                                   EST_None)
-                 .getTypePtr());
+          Context
+              .getFunctionTypeWithExceptionSpec(QualType(FromFPT, 0), EST_None)
+              .getTypePtr());
       Changed = true;
     }
 
@@ -2036,7 +2019,8 @@ bool Sema::IsFunctionConversion(QualType FromType, QualType ToType) const {
     return false;
 
   assert(QualType(FromFn, 0).isCanonical());
-  if (QualType(FromFn, 0) != CanTo) return false;
+  if (QualType(FromFn, 0) != CanTo)
+    return false;
 
   return true;
 }
@@ -2298,8 +2282,7 @@ static bool IsVectorConversion(Sema &S, QualType FromType, QualType ToType,
 
 static bool tryAtomicConversion(Sema &S, Expr *From, QualType ToType,
                                 bool InOverloadResolution,
-                                StandardConversionSequence &SCS,
-                                bool CStyle);
+                                StandardConversionSequence &SCS, bool CStyle);
 
 static bool tryOverflowBehaviorTypeConversion(Sema &S, Expr *From,
                                               QualType ToType,
@@ -2315,10 +2298,9 @@ static bool tryOverflowBehaviorTypeConversion(Sema &S, Expr *From,
 /// contain the standard conversion sequence required to perform this
 /// conversion and this routine will return true. Otherwise, this
 /// routine will return false and the value of SCS is unspecified.
-static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
+static bool IsStandardConversion(Sema &S, Expr *From, QualType ToType,
                                  bool InOverloadResolution,
-                                 StandardConversionSequence &SCS,
-                                 bool CStyle,
+                                 StandardConversionSequence &SCS, bool CStyle,
                                  bool AllowObjCWritebackConversion) {
   QualType FromType = From->getType();
 
@@ -2340,9 +2322,8 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
 
   if (FromType == S.Context.OverloadTy) {
     DeclAccessPair AccessPair;
-    if (FunctionDecl *Fn
-          = S.ResolveAddressOfOverloadedFunction(From, ToType, false,
-                                                 AccessPair)) {
+    if (FunctionDecl *Fn = S.ResolveAddressOfOverloadedFunction(
+            From, ToType, false, AccessPair)) {
       // We were able to resolve the address of the overloaded function,
       // so we can convert to the type of that function.
       FromType = Fn->getType();
@@ -2369,14 +2350,14 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
           !Method->isExplicitObjectMemberFunction()) {
         assert(isa<UnaryOperator>(From->IgnoreParens()) &&
                "Non-unary operator on non-static member address");
-        assert(cast<UnaryOperator>(From->IgnoreParens())->getOpcode()
-               == UO_AddrOf &&
+        assert(cast<UnaryOperator>(From->IgnoreParens())->getOpcode() ==
+                   UO_AddrOf &&
                "Non-address-of operator on non-static member address");
         FromType = S.Context.getMemberPointerType(
             FromType, /*Qualifier=*/std::nullopt, Method->getParent());
       } else if (isa<UnaryOperator>(From->IgnoreParens())) {
         assert(cast<UnaryOperator>(From->IgnoreParens())->getOpcode() ==
-               UO_AddrOf &&
+                   UO_AddrOf &&
                "Non-address-of operator for overloaded function expression");
         FromType = S.Context.getPointerType(FromType);
       }
@@ -2629,8 +2610,8 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
   //   a conversion. [...]
   QualType CanonFrom = S.Context.getCanonicalType(FromType);
   QualType CanonTo = S.Context.getCanonicalType(ToType);
-  if (CanonFrom.getLocalUnqualifiedType()
-                                     == CanonTo.getLocalUnqualifiedType() &&
+  if (CanonFrom.getLocalUnqualifiedType() ==
+          CanonTo.getLocalUnqualifiedType() &&
       CanonFrom.getLocalQualifiers() != CanonTo.getLocalQualifiers()) {
     FromType = ToType;
     CanonFrom = CanonTo;
@@ -2686,12 +2667,9 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
   return true;
 }
 
-static bool
-IsTransparentUnionStandardConversion(Sema &S, Expr* From,
-                                     QualType &ToType,
-                                     bool InOverloadResolution,
-                                     StandardConversionSequence &SCS,
-                                     bool CStyle) {
+static bool IsTransparentUnionStandardConversion(
+    Sema &S, Expr *From, QualType &ToType, bool InOverloadResolution,
+    StandardConversionSequence &SCS, bool CStyle) {
 
   const RecordType *UT = ToType->getAsUnionType();
   if (!UT)
@@ -2802,11 +2780,9 @@ bool Sema::IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType) {
 
     // The types we'll try to promote to, in the appropriate
     // order. Try each of these types.
-    QualType PromoteTypes[6] = {
-      Context.IntTy, Context.UnsignedIntTy,
-      Context.LongTy, Context.UnsignedLongTy ,
-      Context.LongLongTy, Context.UnsignedLongLongTy
-    };
+    QualType PromoteTypes[6] = {Context.IntTy,      Context.UnsignedIntTy,
+                                Context.LongTy,     Context.UnsignedLongTy,
+                                Context.LongLongTy, Context.UnsignedLongLongTy};
     for (int Idx = 0; Idx < 6; ++Idx) {
       uint64_t ToSize = Context.getTypeSize(PromoteTypes[Idx]);
       if (FromSize < ToSize ||
@@ -2904,7 +2880,7 @@ bool Sema::IsFloatingPointPromotion(QualType FromType, QualType ToType) {
 
       // Half can be promoted to float.
       if (!getLangOpts().NativeHalfType &&
-           FromBuiltin->getKind() == BuiltinType::Half &&
+          FromBuiltin->getKind() == BuiltinType::Half &&
           ToBuiltin->getKind() == BuiltinType::Float)
         return true;
     }
@@ -2923,8 +2899,8 @@ bool Sema::IsComplexPromotion(QualType FromType, QualType ToType) {
 
   return IsFloatingPointPromotion(FromComplex->getElementType(),
                                   ToComplex->getElementType()) ||
-    IsIntegralPromotion(nullptr, FromComplex->getElementType(),
-                        ToComplex->getElementType());
+         IsIntegralPromotion(nullptr, FromComplex->getElementType(),
+                             ToComplex->getElementType());
 }
 
 bool Sema::IsOverflowBehaviorTypePromotion(QualType FromType, QualType ToType) {
@@ -2970,9 +2946,8 @@ bool Sema::IsOverflowBehaviorTypeConversion(QualType FromType,
 /// the right set of qualifiers on its pointee.
 ///
 static QualType
-BuildSimilarlyQualifiedPointerType(const Type *FromPtr,
-                                   QualType ToPointee, QualType ToType,
-                                   ASTContext &Context,
+BuildSimilarlyQualifiedPointerType(const Type *FromPtr, QualType ToPointee,
+                                   QualType ToType, ASTContext &Context,
                                    bool StripObjCLifetime = false) {
   assert((FromPtr->getTypeClass() == Type::Pointer ||
           FromPtr->getTypeClass() == Type::ObjCObjectPointer) &&
@@ -2982,8 +2957,8 @@ BuildSimilarlyQualifiedPointerType(const Type *FromPtr,
   if (ToType->isObjCIdType() || ToType->isObjCQualifiedIdType())
     return ToType.getUnqualifiedType();
 
-  QualType CanonFromPointee
-    = Context.getCanonicalType(FromPtr->getPointeeType());
+  QualType CanonFromPointee =
+      Context.getCanonicalType(FromPtr->getPointeeType());
   QualType CanonToPointee = Context.getCanonicalType(ToPointee);
   Qualifiers Quals = CanonFromPointee.getQualifiers();
 
@@ -3004,8 +2979,8 @@ BuildSimilarlyQualifiedPointerType(const Type *FromPtr,
   }
 
   // Just build a canonical type that has the right qualifiers.
-  QualType QualifiedCanonToPointee
-    = Context.getQualifiedType(CanonToPointee.getLocalUnqualifiedType(), Quals);
+  QualType QualifiedCanonToPointee =
+      Context.getQualifiedType(CanonToPointee.getLocalUnqualifiedType(), Quals);
 
   if (isa<ObjCObjectPointerType>(ToType))
     return Context.getObjCObjectPointerType(QualifiedCanonToPointee);
@@ -3021,14 +2996,14 @@ static bool isNullPointerConstantForConversion(Expr *Expr,
       Expr->getType()->isIntegerType() && !Expr->getType()->isEnumeralType())
     return !InOverloadResolution;
 
-  return Expr->isNullPointerConstant(Context,
-                    InOverloadResolution? Expr::NPC_ValueDependentIsNotNull
-                                        : Expr::NPC_ValueDependentIsNull);
+  return Expr->isNullPointerConstant(
+      Context, InOverloadResolution ? Expr::NPC_ValueDependentIsNotNull
+                                    : Expr::NPC_ValueDependentIsNull);
 }
 
 bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
                                bool InOverloadResolution,
-                               QualType& ConvertedType,
+                               QualType &ConvertedType,
                                bool &IncompatibleObjC) {
   IncompatibleObjC = false;
   if (isObjCPointerConversion(FromType, ToType, ConvertedType,
@@ -3064,7 +3039,7 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
     return true;
   }
 
-  const PointerType* ToTypePtr = ToType->getAs<PointerType>();
+  const PointerType *ToTypePtr = ToType->getAs<PointerType>();
   if (!ToTypePtr)
     return false;
 
@@ -3100,19 +3075,17 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
   // 4.10p2).
   if (FromPointeeType->isIncompleteOrObjectType() &&
       ToPointeeType->isVoidType()) {
-    ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
-                                                       ToPointeeType,
-                                                       ToType, Context,
-                                                   /*StripObjCLifetime=*/true);
+    ConvertedType = BuildSimilarlyQualifiedPointerType(
+        FromTypePtr, ToPointeeType, ToType, Context,
+        /*StripObjCLifetime=*/true);
     return true;
   }
 
   // MSVC allows implicit function to void* type conversion.
   if (getLangOpts().MSVCCompat && FromPointeeType->isFunctionType() &&
       ToPointeeType->isVoidType()) {
-    ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
-                                                       ToPointeeType,
-                                                       ToType, Context);
+    ConvertedType = BuildSimilarlyQualifiedPointerType(
+        FromTypePtr, ToPointeeType, ToType, Context);
     return true;
   }
 
@@ -3120,9 +3093,8 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
   // conversion for compatible-but-not-identical pointee types.
   if (!getLangOpts().CPlusPlus &&
       Context.typesAreCompatible(FromPointeeType, ToPointeeType)) {
-    ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
-                                                       ToPointeeType,
-                                                       ToType, Context);
+    ConvertedType = BuildSimilarlyQualifiedPointerType(
+        FromTypePtr, ToPointeeType, ToType, Context);
     return true;
   }
 
@@ -3143,17 +3115,15 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
       ToPointeeType->isRecordType() &&
       !Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType) &&
       IsDerivedFrom(From->getBeginLoc(), FromPointeeType, ToPointeeType)) {
-    ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
-                                                       ToPointeeType,
-                                                       ToType, Context);
+    ConvertedType = BuildSimilarlyQualifiedPointerType(
+        FromTypePtr, ToPointeeType, ToType, Context);
     return true;
   }
 
   if (FromPointeeType->isVectorType() && ToPointeeType->isVectorType() &&
       Context.areCompatibleVectorTypes(FromPointeeType, ToPointeeType)) {
-    ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
-                                                       ToPointeeType,
-                                                       ToType, Context);
+    ConvertedType = BuildSimilarlyQualifiedPointerType(
+        FromTypePtr, ToPointeeType, ToType, Context);
     return true;
   }
 
@@ -3161,7 +3131,8 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
 }
 
 /// Adopt the given qualifiers for the given type.
-static QualType AdoptQualifiers(ASTContext &Context, QualType T, Qualifiers Qs){
+static QualType AdoptQualifiers(ASTContext &Context, QualType T,
+                                Qualifiers Qs) {
   Qualifiers TQs = T.getQualifiers();
 
   // Check whether qualifiers already match.
@@ -3175,7 +3146,7 @@ static QualType AdoptQualifiers(ASTContext &Context, QualType T, Qualifiers Qs){
 }
 
 bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
-                                   QualType& ConvertedType,
+                                   QualType &ConvertedType,
                                    bool &IncompatibleObjC) {
   if (!getLangOpts().ObjC)
     return false;
@@ -3184,10 +3155,10 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
   Qualifiers FromQualifiers = FromType.getQualifiers();
 
   // First, we handle all conversions on ObjC object pointer types.
-  const ObjCObjectPointerType* ToObjCPtr =
-    ToType->getAs<ObjCObjectPointerType>();
+  const ObjCObjectPointerType *ToObjCPtr =
+      ToType->getAs<ObjCObjectPointerType>();
   const ObjCObjectPointerType *FromObjCPtr =
-    FromType->getAs<ObjCObjectPointerType>();
+      FromType->getAs<ObjCObjectPointerType>();
 
   if (ToObjCPtr && FromObjCPtr) {
     // If the pointee types are the same (ignoring qualifications),
@@ -3198,15 +3169,14 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
 
     // Conversion between Objective-C pointers.
     if (Context.canAssignObjCInterfaces(ToObjCPtr, FromObjCPtr)) {
-      const ObjCInterfaceType* LHS = ToObjCPtr->getInterfaceType();
-      const ObjCInterfaceType* RHS = FromObjCPtr->getInterfaceType();
+      const ObjCInterfaceType *LHS = ToObjCPtr->getInterfaceType();
+      const ObjCInterfaceType *RHS = FromObjCPtr->getInterfaceType();
       if (getLangOpts().CPlusPlus && LHS && RHS &&
           !ToObjCPtr->getPointeeType().isAtLeastAsQualifiedAs(
               FromObjCPtr->getPointeeType(), getASTContext()))
         return false;
-      ConvertedType = BuildSimilarlyQualifiedPointerType(FromObjCPtr,
-                                                   ToObjCPtr->getPointeeType(),
-                                                         ToType, Context);
+      ConvertedType = BuildSimilarlyQualifiedPointerType(
+          FromObjCPtr, ToObjCPtr->getPointeeType(), ToType, Context);
       ConvertedType = AdoptQualifiers(Context, ConvertedType, FromQualifiers);
       return true;
     }
@@ -3216,9 +3186,8 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
       // interfaces, which is permitted. However, we're going to
       // complain about it.
       IncompatibleObjC = true;
-      ConvertedType = BuildSimilarlyQualifiedPointerType(FromObjCPtr,
-                                                   ToObjCPtr->getPointeeType(),
-                                                         ToType, Context);
+      ConvertedType = BuildSimilarlyQualifiedPointerType(
+          FromObjCPtr, ToObjCPtr->getPointeeType(), ToType, Context);
       ConvertedType = AdoptQualifiers(Context, ConvertedType, FromQualifiers);
       return true;
     }
@@ -3228,7 +3197,7 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
   if (const PointerType *ToCPtr = ToType->getAs<PointerType>())
     ToPointeeType = ToCPtr->getPointeeType();
   else if (const BlockPointerType *ToBlockPtr =
-            ToType->getAs<BlockPointerType>()) {
+               ToType->getAs<BlockPointerType>()) {
     // Objective C++: We're able to convert from a pointer to any object
     // to a block pointer type.
     if (FromObjCPtr && FromObjCPtr->isObjCBuiltinType()) {
@@ -3236,22 +3205,20 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
       return true;
     }
     ToPointeeType = ToBlockPtr->getPointeeType();
-  }
-  else if (FromType->getAs<BlockPointerType>() &&
-           ToObjCPtr && ToObjCPtr->isObjCBuiltinType()) {
+  } else if (FromType->getAs<BlockPointerType>() && ToObjCPtr &&
+             ToObjCPtr->isObjCBuiltinType()) {
     // Objective C++: We're able to convert from a block pointer type to a
     // pointer to any object.
     ConvertedType = AdoptQualifiers(Context, ToType, FromQualifiers);
     return true;
-  }
-  else
+  } else
     return false;
 
   QualType FromPointeeType;
   if (const PointerType *FromCPtr = FromType->getAs<PointerType>())
     FromPointeeType = FromCPtr->getPointeeType();
   else if (const BlockPointerType *FromBlockPtr =
-           FromType->getAs<BlockPointerType>())
+               FromType->getAs<BlockPointerType>())
     FromPointeeType = FromBlockPtr->getPointeeType();
   else
     return false;
@@ -3283,15 +3250,15 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
   // differences in the argument and result types are in Objective-C
   // pointer conversions. If so, we permit the conversion (but
   // complain about it).
-  const FunctionProtoType *FromFunctionType
-    = FromPointeeType->getAs<FunctionProtoType>();
-  const FunctionProtoType *ToFunctionType
-    = ToPointeeType->getAs<FunctionProtoType>();
+  const FunctionProtoType *FromFunctionType =
+      FromPointeeType->getAs<FunctionProtoType>();
+  const FunctionProtoType *ToFunctionType =
+      ToPointeeType->getAs<FunctionProtoType>();
   if (FromFunctionType && ToFunctionType) {
     // If the function types are exactly the same, this isn't an
     // Objective-C pointer conversion.
-    if (Context.getCanonicalType(FromPointeeType)
-          == Context.getCanonicalType(ToPointeeType))
+    if (Context.getCanonicalType(FromPointeeType) ==
+        Context.getCanonicalType(ToPointeeType))
       return false;
 
     // Perform the quick checks that will tell us whether these
@@ -3320,11 +3287,11 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
          ArgIdx != NumArgs; ++ArgIdx) {
       QualType FromArgType = FromFunctionType->getParamType(ArgIdx);
       QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
-      if (Context.getCanonicalType(FromArgType)
-            == Context.getCanonicalType(ToArgType)) {
+      if (Context.getCanonicalType(FromArgType) ==
+          Context.getCanonicalType(ToArgType)) {
         // Okay, the types match exactly. Nothing to do.
-      } else if (isObjCPointerConversion(FromArgType, ToArgType,
-                                         ConvertedType, IncompatibleObjC)) {
+      } else if (isObjCPointerConversion(FromArgType, ToArgType, ConvertedType,
+                                         IncompatibleObjC)) {
         // Okay, we have an Objective-C pointer conversion.
         HasObjCConversion = true;
       } else {
@@ -3346,17 +3313,16 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
 }
 
 bool Sema::IsBlockPointerConversion(QualType FromType, QualType ToType,
-                                    QualType& ConvertedType) {
+                                    QualType &ConvertedType) {
   QualType ToPointeeType;
-  if (const BlockPointerType *ToBlockPtr =
-        ToType->getAs<BlockPointerType>())
+  if (const BlockPointerType *ToBlockPtr = ToType->getAs<BlockPointerType>())
     ToPointeeType = ToBlockPtr->getPointeeType();
   else
     return false;
 
   QualType FromPointeeType;
   if (const BlockPointerType *FromBlockPtr =
-      FromType->getAs<BlockPointerType>())
+          FromType->getAs<BlockPointerType>())
     FromPointeeType = FromBlockPtr->getPointeeType();
   else
     return false;
@@ -3364,10 +3330,10 @@ bool Sema::IsBlockPointerConversion(QualType FromType, QualType ToType,
   // differences in the argument and result types are in Objective-C
   // pointer conversions. If so, we permit the conversion.
 
-  const FunctionProtoType *FromFunctionType
-    = FromPointeeType->getAs<FunctionProtoType>();
-  const FunctionProtoType *ToFunctionType
-    = ToPointeeType->getAs<FunctionProtoType>();
+  const FunctionProtoType *FromFunctionType =
+      FromPointeeType->getAs<FunctionProtoType>();
+  const FunctionProtoType *ToFunctionType =
+      ToPointeeType->getAs<FunctionProtoType>();
 
   if (!FromFunctionType || !ToFunctionType)
     return false;
@@ -3395,47 +3361,45 @@ bool Sema::IsBlockPointerConversion(QualType FromType, QualType ToType,
     QualType LHS = ToFunctionType->getReturnType();
     if ((!getLangOpts().CPlusPlus || !RHS->isRecordType()) &&
         !RHS.hasQualifiers() && LHS.hasQualifiers())
-       LHS = LHS.getUnqualifiedType();
-
-     if (Context.hasSameType(RHS,LHS)) {
-       // OK exact match.
-     } else if (isObjCPointerConversion(RHS, LHS,
-                                        ConvertedType, IncompatibleObjC)) {
-     if (IncompatibleObjC)
-       return false;
-     // Okay, we have an Objective-C pointer conversion.
-     }
-     else
-       return false;
-   }
-
-   // Check argument types.
-   for (unsigned ArgIdx = 0, NumArgs = FromFunctionType->getNumParams();
-        ArgIdx != NumArgs; ++ArgIdx) {
-     IncompatibleObjC = false;
-     QualType FromArgType = FromFunctionType->getParamType(ArgIdx);
-     QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
-     if (Context.hasSameType(FromArgType, ToArgType)) {
-       // Okay, the types match exactly. Nothing to do.
-     } else if (isObjCPointerConversion(ToArgType, FromArgType,
-                                        ConvertedType, IncompatibleObjC)) {
-       if (IncompatibleObjC)
-         return false;
-       // Okay, we have an Objective-C pointer conversion.
-     } else
-       // Argument types are too different. Abort.
-       return false;
-   }
-
-   SmallVector<FunctionProtoType::ExtParameterInfo, 4> NewParamInfos;
-   bool CanUseToFPT, CanUseFromFPT;
-   if (!Context.mergeExtParameterInfo(ToFunctionType, FromFunctionType,
-                                      CanUseToFPT, CanUseFromFPT,
-                                      NewParamInfos))
-     return false;
-
-   ConvertedType = ToType;
-   return true;
+      LHS = LHS.getUnqualifiedType();
+
+    if (Context.hasSameType(RHS, LHS)) {
+      // OK exact match.
+    } else if (isObjCPointerConversion(RHS, LHS, ConvertedType,
+                                       IncompatibleObjC)) {
+      if (IncompatibleObjC)
+        return false;
+      // Okay, we have an Objective-C pointer conversion.
+    } else
+      return false;
+  }
+
+  // Check argument types.
+  for (unsigned ArgIdx = 0, NumArgs = FromFunctionType->getNumParams();
+       ArgIdx != NumArgs; ++ArgIdx) {
+    IncompatibleObjC = false;
+    QualType FromArgType = FromFunctionType->getParamType(ArgIdx);
+    QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
+    if (Context.hasSameType(FromArgType, ToArgType)) {
+      // Okay, the types match exactly. Nothing to do.
+    } else if (isObjCPointerConversion(ToArgType, FromArgType, ConvertedType,
+                                       IncompatibleObjC)) {
+      if (IncompatibleObjC)
+        return false;
+      // Okay, we have an Objective-C pointer conversion.
+    } else
+      // Argument types are too different. Abort.
+      return false;
+  }
+
+  SmallVector<FunctionProtoType::ExtParameterInfo, 4> NewParamInfos;
+  bool CanUseToFPT, CanUseFromFPT;
+  if (!Context.mergeExtParameterInfo(ToFunctionType, FromFunctionType,
+                                     CanUseToFPT, CanUseFromFPT, NewParamInfos))
+    return false;
+
+  ConvertedType = ToType;
+  return true;
 }
 
 enum {
@@ -3621,10 +3585,8 @@ bool Sema::FunctionNonObjectParamTypesAreEqual(const FunctionDecl *OldFunction,
                                     ArgPos, Reversed);
 }
 
-bool Sema::CheckPointerConversion(Expr *From, QualType ToType,
-                                  CastKind &Kind,
-                                  CXXCastPath& BasePath,
-                                  bool IgnoreBaseAccess,
+bool Sema::CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind,
+                                  CXXCastPath &BasePath, bool IgnoreBaseAccess,
                                   bool Diagnose) {
   QualType FromType = From->getType();
   bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;
@@ -3637,15 +3599,15 @@ bool Sema::CheckPointerConversion(Expr *From, QualType ToType,
     if (Context.hasSameUnqualifiedType(From->getType(), Context.BoolTy))
       DiagRuntimeBehavior(From->getExprLoc(), From,
                           PDiag(diag::warn_impcast_bool_to_null_pointer)
-                            << ToType << From->getSourceRange());
+                              << ToType << From->getSourceRange());
     else if (!isUnevaluatedContext())
       Diag(From->getExprLoc(), diag::warn_non_literal_null_pointer)
-        << ToType << From->getSourceRange();
+          << ToType << From->getSourceRange();
   }
   if (const PointerType *ToPtrType = ToType->getAs<PointerType>()) {
     if (const PointerType *FromPtrType = FromType->getAs<PointerType>()) {
       QualType FromPointeeType = FromPtrType->getPointeeType(),
-               ToPointeeType   = ToPtrType->getPointeeType();
+               ToPointeeType = ToPtrType->getPointeeType();
 
       if (FromPointeeType->isRecordType() && ToPointeeType->isRecordType() &&
           !Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType)) {
@@ -3676,9 +3638,9 @@ bool Sema::CheckPointerConversion(Expr *From, QualType ToType,
       }
     }
   } else if (const ObjCObjectPointerType *ToPtrType =
-               ToType->getAs<ObjCObjectPointerType>()) {
+                 ToType->getAs<ObjCObjectPointerType>()) {
     if (const ObjCObjectPointerType *FromPtrType =
-          FromType->getAs<ObjCObjectPointerType>()) {
+            FromType->getAs<ObjCObjectPointerType>()) {
       // Objective-C++ conversions are always okay.
       // FIXME: We should have a different class of conversions for the
       // Objective-C++ implicit conversions.
@@ -3703,16 +3665,15 @@ bool Sema::CheckPointerConversion(Expr *From, QualType ToType,
 }
 
 bool Sema::IsMemberPointerConversion(Expr *From, QualType FromType,
-                                     QualType ToType,
-                                     bool InOverloadResolution,
+                                     QualType ToType, bool InOverloadResolution,
                                      QualType &ConvertedType) {
   const MemberPointerType *ToTypePtr = ToType->getAs<MemberPointerType>();
   if (!ToTypePtr)
     return false;
 
   // A null pointer constant can be converted to a member pointer (C++ 4.11p1)
-  if (From->isNullPointerConstant(Context,
-                    InOverloadResolution? Expr::NPC_ValueDependentIsNotNull
+  if (From->isNullPointerConstant(
+          Context, InOverloadResolution ? Expr::NPC_ValueDependentIsNotNull
                                         : Expr::NPC_ValueDependentIsNull)) {
     ConvertedType = ToType;
     return true;
@@ -3933,9 +3894,9 @@ static bool isQualificationConversionStep(QualType FromType, QualType ToType,
   return true;
 }
 
-bool
-Sema::IsQualificationConversion(QualType FromType, QualType ToType,
-                                bool CStyle, bool &ObjCLifetimeConversion) {
+bool Sema::IsQualificationConversion(QualType FromType, QualType ToType,
+                                     bool CStyle,
+                                     bool &ObjCLifetimeConversion) {
   FromType = Context.getCanonicalType(FromType);
   ToType = Context.getCanonicalType(ToType);
   ObjCLifetimeConversion = false;
@@ -3964,7 +3925,8 @@ Sema::IsQualificationConversion(QualType FromType, QualType ToType,
   // of times. If we unwrapped any pointers, and if FromType and
   // ToType have the same unqualified type (since we checked
   // qualifiers above), then this is a qualification conversion.
-  return UnwrappedAnyPointer && Context.hasSameUnqualifiedType(FromType,ToType);
+  return UnwrappedAnyPointer &&
+         Context.hasSameUnqualifiedType(FromType, ToType);
 }
 
 /// - Determine whether this is a conversion from a scalar type to an
@@ -3974,23 +3936,22 @@ Sema::IsQualificationConversion(QualType FromType, QualType ToType,
 /// sequence to finish the conversion.
 static bool tryAtomicConversion(Sema &S, Expr *From, QualType ToType,
                                 bool InOverloadResolution,
-                                StandardConversionSequence &SCS,
-                                bool CStyle) {
+                                StandardConversionSequence &SCS, bool CStyle) {
   const AtomicType *ToAtomic = ToType->getAs<AtomicType>();
   if (!ToAtomic)
     return false;
 
   StandardConversionSequence InnerSCS;
   if (!IsStandardConversion(S, From, ToAtomic->getValueType(),
-                            InOverloadResolution, InnerSCS,
-                            CStyle, /*AllowObjCWritebackConversion=*/false))
+                            InOverloadResolution, InnerSCS, CStyle,
+                            /*AllowObjCWritebackConversion=*/false))
     return false;
 
   SCS.Second = InnerSCS.Second;
   SCS.setToType(1, InnerSCS.getToType(1));
   SCS.Third = InnerSCS.Third;
-  SCS.QualificationIncludesObjCLifetime
-    = InnerSCS.QualificationIncludesObjCLifetime;
+  SCS.QualificationIncludesObjCLifetime =
+      InnerSCS.QualificationIncludesObjCLifetime;
   SCS.setToType(2, InnerSCS.getToType(2));
   return true;
 }
@@ -4036,12 +3997,10 @@ static bool isFirstArgumentCompatibleWithType(ASTContext &Context,
   return false;
 }
 
-static OverloadingResult
-IsInitializerListConstructorConversion(Sema &S, Expr *From, QualType ToType,
-                                       CXXRecordDecl *To,
-                                       UserDefinedConversionSequence &User,
-                                       OverloadCandidateSet &CandidateSet,
-                                       bool AllowExplicit) {
+static OverloadingResult IsInitializerListConstructorConversion(
+    Sema &S, Expr *From, QualType ToType, CXXRecordDecl *To,
+    UserDefinedConversionSequence &User, OverloadCandidateSet &CandidateSet,
+    bool AllowExplicit) {
   CandidateSet.clear(OverloadCandidateSet::CSK_InitByUserDefinedConversion);
   for (auto *D : S.LookupConstructors(To)) {
     auto Info = getConstructorInfo(D);
@@ -4109,12 +4068,10 @@ IsInitializerListConstructorConversion(Sema &S, Expr *From, QualType ToType,
 /// \param AllowObjCConversionOnExplicit true if the conversion should
 /// allow an extra Objective-C pointer conversion on uses of explicit
 /// constructors. Requires \c AllowExplicit to also be set.
-static OverloadingResult
-IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
-                        UserDefinedConversionSequence &User,
-                        OverloadCandidateSet &CandidateSet,
-                        AllowedExplicit AllowExplicit,
-                        bool AllowObjCConversionOnExplicit) {
+static OverloadingResult IsUserDefinedConversion(
+    Sema &S, Expr *From, QualType ToType, UserDefinedConversionSequence &User,
+    OverloadCandidateSet &CandidateSet, AllowedExplicit AllowExplicit,
+    bool AllowObjCConversionOnExplicit) {
   assert(AllowExplicit != AllowedExplicit::None ||
          !AllowObjCConversionOnExplicit);
   CandidateSet.clear(OverloadCandidateSet::CSK_InitByUserDefinedConversion);
@@ -4255,8 +4212,8 @@ IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
   case OR_Success:
   case OR_Deleted:
     // Record the standard conversion we used and the conversion function.
-    if (CXXConstructorDecl *Constructor
-          = dyn_cast<CXXConstructorDecl>(Best->Function)) {
+    if (CXXConstructorDecl *Constructor =
+            dyn_cast<CXXConstructorDecl>(Best->Function)) {
       // C++ [over.ics.user]p1:
       //   If the user-defined conversion is specified by a
       //   constructor (12.3.1), the initial standard conversion
@@ -4283,8 +4240,8 @@ IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
       User.After.setAllToTypes(ToType);
       return Result;
     }
-    if (CXXConversionDecl *Conversion
-                 = dyn_cast<CXXConversionDecl>(Best->Function)) {
+    if (CXXConversionDecl *Conversion =
+            dyn_cast<CXXConversionDecl>(Best->Function)) {
 
       assert(Best->HasFinalConversion);
 
@@ -4324,14 +4281,13 @@ IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
   llvm_unreachable("Invalid OverloadResult!");
 }
 
-bool
-Sema::DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType) {
+bool Sema::DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType) {
   ImplicitConversionSequence ICS;
   OverloadCandidateSet CandidateSet(From->getExprLoc(),
                                     OverloadCandidateSet::CSK_Normal);
   OverloadingResult OvResult =
-    IsUserDefinedConversion(*this, From, ToType, ICS.UserDefined,
-                            CandidateSet, AllowedExplicit::None, false);
+      IsUserDefinedConversion(*this, From, ToType, ICS.UserDefined,
+                              CandidateSet, AllowedExplicit::None, false);
 
   if (!(OvResult == OR_Ambiguous ||
         (OvResult == OR_No_Viable_Function && !CandidateSet.empty())))
@@ -4352,8 +4308,7 @@ Sema::DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType) {
           << false << From->getType() << From->getSourceRange() << ToType;
   }
 
-  CandidateSet.NoteCandidates(
-                              *this, From, Cands);
+  CandidateSet.NoteCandidates(*this, From, Cands);
   return true;
 }
 
@@ -4446,9 +4401,8 @@ static bool hasDeprecatedStringLiteralToCharPtrConversion(
 /// other or if they are indistinguishable (C++ 13.3.3.2).
 static ImplicitConversionSequence::CompareKind
 CompareImplicitConversionSequences(Sema &S, SourceLocation Loc,
-                                   const ImplicitConversionSequence& ICS1,
-                                   const ImplicitConversionSequence& ICS2)
-{
+                                   const ImplicitConversionSequence &ICS1,
+                                   const ImplicitConversionSequence &ICS2) {
   // (C++ 13.3.3.2p2): When comparing the basic forms of implicit
   // conversion sequences (as defined in 13.3.3.1)
   //   -- a standard conversion sequence (13.3.3.1.1) is a better
@@ -4556,8 +4510,8 @@ CompareImplicitConversionSequences(Sema &S, SourceLocation Loc,
   if (ICS1.isStandard())
     // Standard conversion sequence S1 is a better conversion sequence than
     // standard conversion sequence S2 if [...]
-    Result = CompareStandardConversionSequences(S, Loc,
-                                                ICS1.Standard, ICS2.Standard);
+    Result = CompareStandardConversionSequences(S, Loc, ICS1.Standard,
+                                                ICS2.Standard);
   else if (ICS1.isUserDefined()) {
     // With lazy template loading, it is possible to find non-canonical
     // FunctionDecls, depending on when redecl chains are completed. Make sure
@@ -4576,13 +4530,12 @@ CompareImplicitConversionSequences(Sema &S, SourceLocation Loc,
     // U1 is better than the second standard conversion sequence of
     // U2 (C++ 13.3.3.2p3).
     if (ConvFunc1 == ConvFunc2)
-      Result = CompareStandardConversionSequences(S, Loc,
-                                                  ICS1.UserDefined.After,
-                                                  ICS2.UserDefined.After);
+      Result = CompareStandardConversionSequences(
+          S, Loc, ICS1.UserDefined.After, ICS2.UserDefined.After);
     else
-      Result = compareConversionFunctions(S,
-                                          ICS1.UserDefined.ConversionFunction,
-                                          ICS2.UserDefined.ConversionFunction);
+      Result =
+          compareConversionFunctions(S, ICS1.UserDefined.ConversionFunction,
+                                     ICS2.UserDefined.ConversionFunction);
   }
 
   return Result;
@@ -4592,10 +4545,10 @@ CompareImplicitConversionSequences(Sema &S, SourceLocation Loc,
 // determine if one is a proper subset of the other.
 static ImplicitConversionSequence::CompareKind
 compareStandardConversionSubsets(ASTContext &Context,
-                                 const StandardConversionSequence& SCS1,
-                                 const StandardConversionSequence& SCS2) {
-  ImplicitConversionSequence::CompareKind Result
-    = ImplicitConversionSequence::Indistinguishable;
+                                 const StandardConversionSequence &SCS1,
+                                 const StandardConversionSequence &SCS2) {
+  ImplicitConversionSequence::CompareKind Result =
+      ImplicitConversionSequence::Indistinguishable;
 
   // the identity conversion sequence is considered to be a subsequence of
   // any non-identity conversion sequence
@@ -4615,19 +4568,20 @@ compareStandardConversionSubsets(ASTContext &Context,
     return ImplicitConversionSequence::Indistinguishable;
 
   if (SCS1.Third == SCS2.Third) {
-    return Context.hasSameType(SCS1.getToType(2), SCS2.getToType(2))? Result
-                             : ImplicitConversionSequence::Indistinguishable;
+    return Context.hasSameType(SCS1.getToType(2), SCS2.getToType(2))
+               ? Result
+               : ImplicitConversionSequence::Indistinguishable;
   }
 
   if (SCS1.Third == ICK_Identity)
     return Result == ImplicitConversionSequence::Worse
-             ? ImplicitConversionSequence::Indistinguishable
-             : ImplicitConversionSequence::Better;
+               ? ImplicitConversionSequence::Indistinguishable
+               : ImplicitConversionSequence::Better;
 
   if (SCS2.Third == ICK_Identity)
     return Result == ImplicitConversionSequence::Better
-             ? ImplicitConversionSequence::Indistinguishable
-             : ImplicitConversionSequence::Worse;
+               ? ImplicitConversionSequence::Indistinguishable
+               : ImplicitConversionSequence::Worse;
 
   return ImplicitConversionSequence::Indistinguishable;
 }
@@ -4692,9 +4646,8 @@ getFixedEnumPromtion(Sema &S, const StandardConversionSequence &SCS) {
 /// other or if they are indistinguishable (C++ 13.3.3.2p3).
 static ImplicitConversionSequence::CompareKind
 CompareStandardConversionSequences(Sema &S, SourceLocation Loc,
-                                   const StandardConversionSequence& SCS1,
-                                   const StandardConversionSequence& SCS2)
-{
+                                   const StandardConversionSequence &SCS1,
+                                   const StandardConversionSequence &SCS2) {
   // Standard conversion sequence S1 is a better conversion sequence
   // than standard conversion sequence S2 if (C++ 13.3.3.2p3):
 
@@ -4703,8 +4656,8 @@ CompareStandardConversionSequences(Sema &S, SourceLocation Loc,
   //     excluding any Lvalue Transformation; the identity conversion
   //     sequence is considered to be a subsequence of any
   //     non-identity conversion sequence) or, if not that,
-  if (ImplicitConversionSequence::CompareKind CK
-        = compareStandardConversionSubsets(S.Context, SCS1, SCS2))
+  if (ImplicitConversionSequence::CompareKind CK =
+          compareStandardConversionSubsets(S.Context, SCS1, SCS2))
     return CK;
 
   //  -- the rank of S1 is better than the rank of S2 (by the rules
@@ -4724,9 +4677,8 @@ CompareStandardConversionSequences(Sema &S, SourceLocation Loc,
   //   pointer to member, to bool is better than another conversion
   //   that is such a conversion.
   if (SCS1.isPointerConversionToBool() != SCS2.isPointerConversionToBool())
-    return SCS2.isPointerConversionToBool()
-             ? ImplicitConversionSequence::Better
-             : ImplicitConversionSequence::Worse;
+    return SCS2.isPointerConversionToBool() ? ImplicitConversionSequence::Better
+                                            : ImplicitConversionSequence::Worse;
 
   // C++14 [over.ics.rank]p4b2:
   // This is retroactively applied to C++11 by CWG 1601.
@@ -4748,10 +4700,8 @@ CompareStandardConversionSequences(Sema &S, SourceLocation Loc,
   //   conversion of B* to A* is better than conversion of B* to
   //   void*, and conversion of A* to void* is better than conversion
   //   of B* to void*.
-  bool SCS1ConvertsToVoid
-    = SCS1.isPointerConversionToVoidPointer(S.Context);
-  bool SCS2ConvertsToVoid
-    = SCS2.isPointerConversionToVoidPointer(S.Context);
+  bool SCS1ConvertsToVoid = SCS1.isPointerConversionToVoidPointer(S.Context);
+  bool SCS2ConvertsToVoid = SCS2.isPointerConversionToVoidPointer(S.Context);
   if (SCS1ConvertsToVoid != SCS2ConvertsToVoid) {
     // Exactly one of the conversion sequences is a conversion to
     // a void pointer; it's the worse conversion.
@@ -4760,8 +4710,8 @@ CompareStandardConversionSequences(Sema &S, SourceLocation Loc,
   } else if (!SCS1ConvertsToVoid && !SCS2ConvertsToVoid) {
     // Neither conversion sequence converts to a void pointer; compare
     // their derived-to-base conversions.
-    if (ImplicitConversionSequence::CompareKind DerivedCK
-          = CompareDerivedToBaseConversions(S, Loc, SCS1, SCS2))
+    if (ImplicitConversionSequence::CompareKind DerivedCK =
+            CompareDerivedToBaseConversions(S, Loc, SCS1, SCS2))
       return DerivedCK;
   } else if (SCS1ConvertsToVoid && SCS2ConvertsToVoid &&
              !S.Context.hasSameType(SCS1.getFromType(), SCS2.getFromType())) {
@@ -4788,18 +4738,18 @@ CompareStandardConversionSequences(Sema &S, SourceLocation Loc,
 
     // Objective-C++: If one interface is more specific than the
     // other, it is the better one.
-    const ObjCObjectPointerType* FromObjCPtr1
-      = FromType1->getAs<ObjCObjectPointerType>();
-    const ObjCObjectPointerType* FromObjCPtr2
-      = FromType2->getAs<ObjCObjectPointerType>();
+    const ObjCObjectPointerType *FromObjCPtr1 =
+        FromType1->getAs<ObjCObjectPointerType>();
+    const ObjCObjectPointerType *FromObjCPtr2 =
+        FromType2->getAs<ObjCObjectPointerType>();
     if (FromObjCPtr1 && FromObjCPtr2) {
-      bool AssignLeft = S.Context.canAssignObjCInterfaces(FromObjCPtr1,
-                                                          FromObjCPtr2);
-      bool AssignRight = S.Context.canAssignObjCInterfaces(FromObjCPtr2,
-                                                           FromObjCPtr1);
+      bool AssignLeft =
+          S.Context.canAssignObjCInterfaces(FromObjCPtr1, FromObjCPtr2);
+      bool AssignRight =
+          S.Context.canAssignObjCInterfaces(FromObjCPtr2, FromObjCPtr1);
       if (AssignLeft != AssignRight) {
-        return AssignLeft? ImplicitConversionSequence::Better
-                         : ImplicitConversionSequence::Worse;
+        return AssignLeft ? ImplicitConversionSequence::Better
+                          : ImplicitConversionSequence::Worse;
       }
     }
   }
@@ -4814,8 +4764,8 @@ CompareStandardConversionSequences(Sema &S, SourceLocation Loc,
 
   // Compare based on qualification conversions (C++ 13.3.3.2p3,
   // bullet 3).
-  if (ImplicitConversionSequence::CompareKind QualCK
-        = CompareQualificationConversions(S, SCS1, SCS2))
+  if (ImplicitConversionSequence::CompareKind QualCK =
+          CompareQualificationConversions(S, SCS1, SCS2))
     return QualCK;
 
   if (ImplicitConversionSequence::CompareKind ObtCK =
@@ -4840,10 +4790,10 @@ CompareStandardConversionSequences(Sema &S, SourceLocation Loc,
       // Objective-C++ ARC: If the references refer to objects with different
       // lifetimes, prefer bindings that don't change lifetime.
       if (SCS1.ObjCLifetimeConversionBinding !=
-                                          SCS2.ObjCLifetimeConversionBinding) {
+          SCS2.ObjCLifetimeConversionBinding) {
         return SCS1.ObjCLifetimeConversionBinding
-                                           ? ImplicitConversionSequence::Worse
-                                           : ImplicitConversionSequence::Better;
+                   ? ImplicitConversionSequence::Worse
+                   : ImplicitConversionSequence::Better;
       }
 
       // If the type is an array type, promote the element qualifiers to the
@@ -4957,9 +4907,8 @@ CompareOverflowBehaviorConversions(Sema &S,
 /// sequences to determine whether they can be ranked based on their
 /// qualification conversions (C++ 13.3.3.2p3 bullet 3).
 static ImplicitConversionSequence::CompareKind
-CompareQualificationConversions(Sema &S,
-                                const StandardConversionSequence& SCS1,
-                                const StandardConversionSequence& SCS2) {
+CompareQualificationConversions(Sema &S, const StandardConversionSequence &SCS1,
+                                const StandardConversionSequence &SCS2) {
   // C++ [over.ics.rank]p3:
   //  -- S1 and S2 differ only in their qualification conversion and
   //     yield similar types T1 and T2 (C++ 4.4), respectively, [...]
@@ -5027,8 +4976,8 @@ CompareQualificationConversions(Sema &S,
 /// conversions between Objective-C interface types.
 static ImplicitConversionSequence::CompareKind
 CompareDerivedToBaseConversions(Sema &S, SourceLocation Loc,
-                                const StandardConversionSequence& SCS1,
-                                const StandardConversionSequence& SCS2) {
+                                const StandardConversionSequence &SCS1,
+                                const StandardConversionSequence &SCS2) {
   QualType FromType1 = SCS1.getFromType();
   QualType ToType1 = SCS1.getToType(1);
   QualType FromType2 = SCS2.getFromType();
@@ -5084,28 +5033,26 @@ CompareDerivedToBaseConversions(Sema &S, SourceLocation Loc,
     }
   } else if (SCS1.Second == ICK_Pointer_Conversion &&
              SCS2.Second == ICK_Pointer_Conversion) {
-    const ObjCObjectPointerType *FromPtr1
-      = FromType1->getAs<ObjCObjectPointerType>();
-    const ObjCObjectPointerType *FromPtr2
-      = FromType2->getAs<ObjCObjectPointerType>();
-    const ObjCObjectPointerType *ToPtr1
-      = ToType1->getAs<ObjCObjectPointerType>();
-    const ObjCObjectPointerType *ToPtr2
-      = ToType2->getAs<ObjCObjectPointerType>();
+    const ObjCObjectPointerType *FromPtr1 =
+        FromType1->getAs<ObjCObjectPointerType>();
+    const ObjCObjectPointerType *FromPtr2 =
+        FromType2->getAs<ObjCObjectPointerType>();
+    const ObjCObjectPointerType *ToPtr1 =
+        ToType1->getAs<ObjCObjectPointerType>();
+    const ObjCObjectPointerType *ToPtr2 =
+        ToType2->getAs<ObjCObjectPointerType>();
 
     if (FromPtr1 && FromPtr2 && ToPtr1 && ToPtr2) {
       // Apply the same conversion ranking rules for Objective-C pointer types
       // that we do for C++ pointers to class types. However, we employ the
       // Objective-C pseudo-subtyping relationship used for assignment of
       // Objective-C pointer types.
-      bool FromAssignLeft
-        = S.Context.canAssignObjCInterfaces(FromPtr1, FromPtr2);
-      bool FromAssignRight
-        = S.Context.canAssignObjCInterfaces(FromPtr2, FromPtr1);
-      bool ToAssignLeft
-        = S.Context.canAssignObjCInterfaces(ToPtr1, ToPtr2);
-      bool ToAssignRight
-        = S.Context.canAssignObjCInterfaces(ToPtr2, ToPtr1);
+      bool FromAssignLeft =
+          S.Context.canAssignObjCInterfaces(FromPtr1, FromPtr2);
+      bool FromAssignRight =
+          S.Context.canAssignObjCInterfaces(FromPtr2, FromPtr1);
+      bool ToAssignLeft = S.Context.canAssignObjCInterfaces(ToPtr1, ToPtr2);
+      bool ToAssignRight = S.Context.canAssignObjCInterfaces(ToPtr2, ToPtr1);
 
       // A conversion to an a non-id object pointer type or qualified 'id'
       // type is better than a conversion to 'id'.
@@ -5156,15 +5103,15 @@ CompareDerivedToBaseConversions(Sema &S, SourceLocation Loc,
           } else if (IsSecondSame)
             return ImplicitConversionSequence::Worse;
         }
-        return ToAssignLeft? ImplicitConversionSequence::Worse
-                           : ImplicitConversionSequence::Better;
+        return ToAssignLeft ? ImplicitConversionSequence::Worse
+                            : ImplicitConversionSequence::Better;
       }
 
       //   -- "conversion of B* to A* is better than conversion of C* to A*,"
       if (S.Context.hasSameUnqualifiedType(ToType1, ToType2) &&
           (FromAssignLeft != FromAssignRight))
-        return FromAssignLeft? ImplicitConversionSequence::Better
-        : ImplicitConversionSequence::Worse;
+        return FromAssignLeft ? ImplicitConversionSequence::Better
+                              : ImplicitConversionSequence::Worse;
     }
   }
 
@@ -5236,11 +5183,11 @@ static QualType withoutUnaligned(ASTContext &Ctx, QualType T) {
 }
 
 Sema::ReferenceCompareResult
-Sema::CompareReferenceRelationship(SourceLocation Loc,
-                                   QualType OrigT1, QualType OrigT2,
+Sema::CompareReferenceRelationship(SourceLocation Loc, QualType OrigT1,
+                                   QualType OrigT2,
                                    ReferenceConversions *ConvOut) {
   assert(!OrigT1->isReferenceType() &&
-    "T1 must be the pointee type of the reference type");
+         "T1 must be the pointee type of the reference type");
   assert(!OrigT2->isReferenceType() && "T2 cannot be a reference type");
 
   QualType T1 = Context.getCanonicalType(OrigT1);
@@ -5329,11 +5276,10 @@ Sema::CompareReferenceRelationship(SourceLocation Loc,
 
 /// Look for a user-defined conversion to a value reference-compatible
 ///        with DeclType. Return true if something definite is found.
-static bool
-FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS,
-                         QualType DeclType, SourceLocation DeclLoc,
-                         Expr *Init, QualType T2, bool AllowRvalues,
-                         bool AllowExplicit) {
+static bool FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS,
+                                     QualType DeclType, SourceLocation DeclLoc,
+                                     Expr *Init, QualType T2, bool AllowRvalues,
+                                     bool AllowExplicit) {
   assert(T2->isRecordType() && "Can only find conversions of record types.");
   auto *T2RecordDecl = T2->castAsCXXRecordDecl();
   OverloadCandidateSet CandidateSet(
@@ -5345,8 +5291,7 @@ FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS,
     if (isa<UsingShadowDecl>(D))
       D = cast<UsingShadowDecl>(D)->getTargetDecl();
 
-    FunctionTemplateDecl *ConvTemplate
-      = dyn_cast<FunctionTemplateDecl>(D);
+    FunctionTemplateDecl *ConvTemplate = dyn_cast<FunctionTemplateDecl>(D);
     CXXConversionDecl *Conv;
     if (ConvTemplate)
       Conv = cast<CXXConversionDecl>(ConvTemplate->getTemplatedDecl());
@@ -5357,8 +5302,8 @@ FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS,
       // If we are initializing an rvalue reference, don't permit conversion
       // functions that return lvalues.
       if (!ConvTemplate && DeclType->isRValueReferenceType()) {
-        const ReferenceType *RefType
-          = Conv->getConversionType()->getAs<LValueReferenceType>();
+        const ReferenceType *RefType =
+            Conv->getConversionType()->getAs<LValueReferenceType>();
         if (RefType && !RefType->getPointeeType()->isFunctionType())
           continue;
       }
@@ -5378,10 +5323,9 @@ FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS,
       // is only acceptable if its referencee is a function type.
 
       const ReferenceType *RefType =
-        Conv->getConversionType()->getAs<ReferenceType>();
-      if (!RefType ||
-          (!RefType->isLValueReferenceType() &&
-           !RefType->getPointeeType()->isFunctionType()))
+          Conv->getConversionType()->getAs<ReferenceType>();
+      if (!RefType || (!RefType->isLValueReferenceType() &&
+                       !RefType->getPointeeType()->isFunctionType()))
         continue;
     }
 
@@ -5449,10 +5393,8 @@ FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS,
 /// Compute an implicit conversion sequence for reference
 /// initialization.
 static ImplicitConversionSequence
-TryReferenceInit(Sema &S, Expr *Init, QualType DeclType,
-                 SourceLocation DeclLoc,
-                 bool SuppressUserConversions,
-                 bool AllowExplicit) {
+TryReferenceInit(Sema &S, Expr *Init, QualType DeclType, SourceLocation DeclLoc,
+                 bool SuppressUserConversions, bool AllowExplicit) {
   assert(DeclType->isReferenceType() && "Reference init needs a reference");
 
   // Most paths end in a failed conversion.
@@ -5467,8 +5409,8 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType,
   // type of the resulting function.
   if (S.Context.getCanonicalType(T2) == S.Context.OverloadTy) {
     DeclAccessPair Found;
-    if (FunctionDecl *Fn = S.ResolveAddressOfOverloadedFunction(Init, DeclType,
-                                                                false, Found))
+    if (FunctionDecl *Fn =
+            S.ResolveAddressOfOverloadedFunction(Init, DeclType, false, Found))
       T2 = Fn->getType();
   }
 
@@ -5487,17 +5429,17 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType,
     // consider that when ordering reference-to-function bindings.
     ICS.Standard.Second = (RefConv & Sema::ReferenceConversions::DerivedToBase)
                               ? ICK_Derived_To_Base
-                              : (RefConv & Sema::ReferenceConversions::ObjC)
-                                    ? ICK_Compatible_Conversion
-                                    : ICK_Identity;
+                          : (RefConv & Sema::ReferenceConversions::ObjC)
+                              ? ICK_Compatible_Conversion
+                              : ICK_Identity;
     ICS.Standard.Dimension = ICK_Identity;
     // FIXME: As a speculative fix to a defect introduced by CWG2352, we rank
     // a reference binding that performs a non-top-level qualification
     // conversion as a qualification conversion, not as an identity conversion.
-    ICS.Standard.Third = (RefConv &
-                              Sema::ReferenceConversions::NestedQualification)
-                             ? ICK_Qualification
-                             : ICK_Identity;
+    ICS.Standard.Third =
+        (RefConv & Sema::ReferenceConversions::NestedQualification)
+            ? ICK_Qualification
+            : ICK_Identity;
     ICS.Standard.setFromType(T2);
     ICS.Standard.setToType(0, T2);
     ICS.Standard.setToType(1, T1);
@@ -5552,9 +5494,8 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType,
     if (!SuppressUserConversions && T2->isRecordType() &&
         S.isCompleteType(DeclLoc, T2) &&
         RefRelationship == Sema::Ref_Incompatible) {
-      if (FindConversionForRefInit(S, ICS, DeclType, DeclLoc,
-                                   Init, T2, /*AllowRvalues=*/false,
-                                   AllowExplicit))
+      if (FindConversionForRefInit(S, ICS, DeclType, DeclLoc, Init, T2,
+                                   /*AllowRvalues=*/false, AllowExplicit))
         return ICS;
     }
   }
@@ -5575,7 +5516,7 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType,
   if (RefRelationship == Sema::Ref_Compatible &&
       (InitCategory.isXValue() ||
        (InitCategory.isPRValue() &&
-          (T2->isRecordType() || T2->isArrayType())) ||
+        (T2->isRecordType() || T2->isArrayType())) ||
        (InitCategory.isLValue() && T2->isFunctionType()))) {
     // In C++11, this is always a direct binding. In C++98/03, it's a direct
     // binding unless we're binding to a class prvalue.
@@ -5599,9 +5540,8 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType,
   //          class subobject).
   if (!SuppressUserConversions && RefRelationship == Sema::Ref_Incompatible &&
       T2->isRecordType() && S.isCompleteType(DeclLoc, T2) &&
-      FindConversionForRefInit(S, ICS, DeclType, DeclLoc,
-                               Init, T2, /*AllowRvalues=*/true,
-                               AllowExplicit)) {
+      FindConversionForRefInit(S, ICS, DeclType, DeclLoc, Init, T2,
+                               /*AllowRvalues=*/true, AllowExplicit)) {
     // In the second case, if the reference is an rvalue reference
     // and the second standard conversion sequence of the
     // user-defined conversion sequence includes an lvalue-to-rvalue
@@ -5707,7 +5647,8 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType,
     ICS.UserDefined.After.IsLvalueReference = !isRValRef;
     ICS.UserDefined.After.BindsToFunctionLvalue = false;
     ICS.UserDefined.After.BindsToRvalue = !LValRefType;
-    ICS.UserDefined.After.BindsImplicitObjectArgumentWithoutRefQualifier = false;
+    ICS.UserDefined.After.BindsImplicitObjectArgumentWithoutRefQualifier =
+        false;
     ICS.UserDefined.After.ObjCLifetimeConversionBinding = false;
     ICS.UserDefined.After.FromBracedInitList = false;
   }
@@ -5717,8 +5658,7 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType,
 
 static ImplicitConversionSequence
 TryCopyInitialization(Sema &S, Expr *From, QualType ToType,
-                      bool SuppressUserConversions,
-                      bool InOverloadResolution,
+                      bool SuppressUserConversions, bool InOverloadResolution,
                       bool AllowObjCWritebackConversion,
                       bool AllowExplicit = false);
 
@@ -5726,8 +5666,7 @@ TryCopyInitialization(Sema &S, Expr *From, QualType ToType,
 /// initializer list From.
 static ImplicitConversionSequence
 TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
-                  bool SuppressUserConversions,
-                  bool InOverloadResolution,
+                  bool SuppressUserConversions, bool InOverloadResolution,
                   bool AllowObjCWritebackConversion) {
   // C++11 [over.ics.list]p1:
   //   When an argument is an initializer list, it is not an expression and
@@ -5774,10 +5713,9 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
       QualType InitType = From->getInit(0)->getType();
       if (S.Context.hasSameUnqualifiedType(InitType, ToType) ||
           S.IsDerivedFrom(From->getBeginLoc(), InitType, ToType))
-        return TryCopyInitialization(S, From->getInit(0), ToType,
-                                     SuppressUserConversions,
-                                     InOverloadResolution,
-                                     AllowObjCWritebackConversion);
+        return TryCopyInitialization(
+            S, From->getInit(0), ToType, SuppressUserConversions,
+            InOverloadResolution, AllowObjCWritebackConversion);
     }
 
     if (AT && S.IsStringInit(From->getInit(0), AT)) {
@@ -5902,11 +5840,10 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
   //   implicit conversion sequence is a user-defined conversion sequence.
   if (ToType->isRecordType() && !ToType->isAggregateType()) {
     // This function can deal with initializer lists.
-    return TryUserDefinedConversion(S, From, ToType, SuppressUserConversions,
-                                    AllowedExplicit::None,
-                                    InOverloadResolution, /*CStyle=*/false,
-                                    AllowObjCWritebackConversion,
-                                    /*AllowObjCConversionOnExplicit=*/false);
+    return TryUserDefinedConversion(
+        S, From, ToType, SuppressUserConversions, AllowedExplicit::None,
+        InOverloadResolution, /*CStyle=*/false, AllowObjCWritebackConversion,
+        /*AllowObjCConversionOnExplicit=*/false);
   }
 
   // C++14 [over.ics.list]p5:
@@ -5960,7 +5897,7 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
       if (S.Context.getCanonicalType(T2) == S.Context.OverloadTy) {
         DeclAccessPair Found;
         if (FunctionDecl *Fn = S.ResolveAddressOfOverloadedFunction(
-                                   Init, ToType, false, Found))
+                Init, ToType, false, Found))
           T2 = Fn->getType();
       }
 
@@ -5977,9 +5914,9 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
 
     // Otherwise, we bind the reference to a temporary created from the
     // initializer list.
-    Result = TryListConversion(S, From, T1, SuppressUserConversions,
-                               InOverloadResolution,
-                               AllowObjCWritebackConversion);
+    Result =
+        TryListConversion(S, From, T1, SuppressUserConversions,
+                          InOverloadResolution, AllowObjCWritebackConversion);
     if (Result.isFailure())
       return Result;
     assert(!Result.isEllipsis() &&
@@ -5988,8 +5925,8 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
     // Can we even bind to a temporary?
     if (ToType->isRValueReferenceType() ||
         (T1.isConstQualified() && !T1.isVolatileQualified())) {
-      StandardConversionSequence &SCS = Result.isStandard() ? Result.Standard :
-                                            Result.UserDefined.After;
+      StandardConversionSequence &SCS =
+          Result.isStandard() ? Result.Standard : Result.UserDefined.After;
       SCS.ReferenceBinding = true;
       SCS.IsLvalueReference = ToType->isLValueReferenceType();
       SCS.BindsToRvalue = true;
@@ -5999,8 +5936,7 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
       SCS.FromBracedInitList = false;
 
     } else
-      Result.setBad(BadConversionSequence::lvalue_ref_to_rvalue,
-                    From, ToType);
+      Result.setBad(BadConversionSequence::lvalue_ref_to_rvalue, From, ToType);
     return Result;
   }
 
@@ -6047,36 +5983,30 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
 /// do not permit any user-defined conversion sequences.
 static ImplicitConversionSequence
 TryCopyInitialization(Sema &S, Expr *From, QualType ToType,
-                      bool SuppressUserConversions,
-                      bool InOverloadResolution,
-                      bool AllowObjCWritebackConversion,
-                      bool AllowExplicit) {
+                      bool SuppressUserConversions, bool InOverloadResolution,
+                      bool AllowObjCWritebackConversion, bool AllowExplicit) {
   if (InitListExpr *FromInitList = dyn_cast<InitListExpr>(From))
     return TryListConversion(S, FromInitList, ToType, SuppressUserConversions,
-                             InOverloadResolution,AllowObjCWritebackConversion);
+                             InOverloadResolution,
+                             AllowObjCWritebackConversion);
 
   if (ToType->isReferenceType())
     return TryReferenceInit(S, From, ToType,
                             /*FIXME:*/ From->getBeginLoc(),
                             SuppressUserConversions, AllowExplicit);
 
-  return TryImplicitConversion(S, From, ToType,
-                               SuppressUserConversions,
-                               AllowedExplicit::None,
-                               InOverloadResolution,
-                               /*CStyle=*/false,
-                               AllowObjCWritebackConversion,
+  return TryImplicitConversion(S, From, ToType, SuppressUserConversions,
+                               AllowedExplicit::None, InOverloadResolution,
+                               /*CStyle=*/false, AllowObjCWritebackConversion,
                                /*AllowObjCConversionOnExplicit=*/false);
 }
 
 static bool TryCopyInitialization(const CanQualType FromQTy,
-                                  const CanQualType ToQTy,
-                                  Sema &S,
-                                  SourceLocation Loc,
-                                  ExprValueKind FromVK) {
+                                  const CanQualType ToQTy, Sema &S,
+                                  SourceLocation Loc, ExprValueKind FromVK) {
   OpaqueValueExpr TmpExpr(Loc, FromQTy, FromVK);
   ImplicitConversionSequence ICS =
-    TryCopyInitialization(S, &TmpExpr, ToQTy, true, true, false);
+      TryCopyInitialization(S, &TmpExpr, ToQTy, true, true, false);
 
   return !ICS.isBad();
 }
@@ -6168,8 +6098,8 @@ static ImplicitConversionSequence TryObjectArgumentInitialization(
           FromTypeCanon.getLocalCVRQualifiers() &&
       !ImplicitParamType.isAtLeastAsQualifiedAs(
           withoutUnaligned(S.Context, FromTypeCanon), S.getASTContext())) {
-    ICS.setBad(BadConversionSequence::bad_qualifiers,
-               FromType, ImplicitParamType);
+    ICS.setBad(BadConversionSequence::bad_qualifiers, FromType,
+               ImplicitParamType);
     return ICS;
   }
 
@@ -6178,8 +6108,8 @@ static ImplicitConversionSequence TryObjectArgumentInitialization(
     Qualifiers QualsFromType = FromTypeCanon.getQualifiers();
     if (!QualsImplicitParamType.isAddressSpaceSupersetOf(QualsFromType,
                                                          S.getASTContext())) {
-      ICS.setBad(BadConversionSequence::bad_qualifiers,
-                 FromType, ImplicitParamType);
+      ICS.setBad(BadConversionSequence::bad_qualifiers, FromType,
+                 ImplicitParamType);
       return ICS;
     }
   }
@@ -6193,8 +6123,8 @@ static ImplicitConversionSequence TryObjectArgumentInitialization(
   } else if (S.IsDerivedFrom(Loc, FromType, ClassType)) {
     SecondKind = ICK_Derived_To_Base;
   } else if (!Method->isExplicitObjectMemberFunction()) {
-    ICS.setBad(BadConversionSequence::unrelated_class,
-               FromType, ImplicitParamType);
+    ICS.setBad(BadConversionSequence::unrelated_class, FromType,
+               ImplicitParamType);
     return ICS;
   }
 
@@ -6235,8 +6165,8 @@ static ImplicitConversionSequence TryObjectArgumentInitialization(
   ICS.Standard.BindsToFunctionLvalue = false;
   ICS.Standard.BindsToRvalue = FromClassification.isRValue();
   ICS.Standard.FromBracedInitList = false;
-  ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier
-    = (Method->getRefQualifier() == RQ_None);
+  ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
+      (Method->getRefQualifier() == RQ_None);
   return ICS;
 }
 
@@ -6285,7 +6215,7 @@ ExprResult Sema::PerformImplicitObjectArgumentInitialization(
             << Method->getDeclName() << FromRecordType << (CVR - 1)
             << From->getSourceRange();
         Diag(Method->getLocation(), diag::note_previous_decl)
-          << Method->getDeclName();
+            << Method->getDeclName();
         return ExprError();
       }
       break;
@@ -6294,12 +6224,12 @@ ExprResult Sema::PerformImplicitObjectArgumentInitialization(
     case BadConversionSequence::lvalue_ref_to_rvalue:
     case BadConversionSequence::rvalue_ref_to_lvalue: {
       bool IsRValueQualified =
-        Method->getRefQualifier() == RefQualifierKind::RQ_RValue;
+          Method->getRefQualifier() == RefQualifierKind::RQ_RValue;
       Diag(From->getBeginLoc(), diag::err_member_function_call_bad_ref)
           << Method->getDeclName() << FromClassification.isRValue()
           << IsRValueQualified;
       Diag(Method->getLocation(), diag::note_previous_decl)
-        << Method->getDeclName();
+          << Method->getDeclName();
       return ExprError();
     }
 
@@ -6319,7 +6249,7 @@ ExprResult Sema::PerformImplicitObjectArgumentInitialization(
 
   if (ICS.Standard.Second == ICK_Derived_To_Base) {
     ExprResult FromRes =
-      PerformObjectMemberConversion(From, Qualifier, FoundDecl, Method);
+        PerformObjectMemberConversion(From, Qualifier, FoundDecl, Method);
     if (FromRes.isInvalid())
       return ExprError();
     From = FromRes.get();
@@ -6341,16 +6271,15 @@ ExprResult Sema::PerformImplicitObjectArgumentInitialization(
 
 /// TryContextuallyConvertToBool - Attempt to contextually convert the
 /// expression From to bool (C++0x [conv]p3).
-static ImplicitConversionSequence
-TryContextuallyConvertToBool(Sema &S, Expr *From) {
+static ImplicitConversionSequence TryContextuallyConvertToBool(Sema &S,
+                                                               Expr *From) {
   // C++ [dcl.init]/17.8:
   //   - Otherwise, if the initialization is direct-initialization, the source
   //     type is std::nullptr_t, and the destination type is bool, the initial
   //     value of the object being initialized is false.
   if (From->getType()->isNullPtrType())
-    return ImplicitConversionSequence::getNullptrToBool(From->getType(),
-                                                        S.Context.BoolTy,
-                                                        From->isGLValue());
+    return ImplicitConversionSequence::getNullptrToBool(
+        From->getType(), S.Context.BoolTy, From->isGLValue());
 
   // All other direct-initialization of bool is equivalent to an implicit
   // conversion to bool in which explicit conversions are permitted.
@@ -6748,15 +6677,14 @@ static ImplicitConversionSequence
 TryContextuallyConvertToObjCPointer(Sema &S, Expr *From) {
   // Do an implicit conversion to 'id'.
   QualType Ty = S.Context.getObjCIdType();
-  ImplicitConversionSequence ICS
-    = TryImplicitConversion(S, From, Ty,
-                            // FIXME: Are these flags correct?
-                            /*SuppressUserConversions=*/false,
-                            AllowedExplicit::Conversions,
-                            /*InOverloadResolution=*/false,
-                            /*CStyle=*/false,
-                            /*AllowObjCWritebackConversion=*/false,
-                            /*AllowObjCConversionOnExplicit=*/true);
+  ImplicitConversionSequence ICS = TryImplicitConversion(
+      S, From, Ty,
+      // FIXME: Are these flags correct?
+      /*SuppressUserConversions=*/false, AllowedExplicit::Conversions,
+      /*InOverloadResolution=*/false,
+      /*CStyle=*/false,
+      /*AllowObjCWritebackConversion=*/false,
+      /*AllowObjCConversionOnExplicit=*/true);
 
   // Strip off any final conversions to 'id'.
   switch (ICS.getKind()) {
@@ -6784,7 +6712,7 @@ ExprResult Sema::PerformContextuallyConvertToObjCPointer(Expr *From) {
 
   QualType Ty = Context.getObjCIdType();
   ImplicitConversionSequence ICS =
-    TryContextuallyConvertToObjCPointer(*this, From);
+      TryContextuallyConvertToObjCPointer(*this, From);
   if (!ICS.isBad())
     return PerformImplicitConversion(From, Ty, ICS,
                                      AssignmentAction::Converting);
@@ -7255,8 +7183,8 @@ void Sema::AddOverloadCandidate(
     ADLCallKind IsADLCandidate, ConversionSequenceList EarlyConversions,
     OverloadCandidateParamOrder PO, bool AggregateCandidateDeduction,
     bool StrictPackMatch) {
-  const FunctionProtoType *Proto
-    = dyn_cast<FunctionProtoType>(Function->getType()->getAs<FunctionType>());
+  const FunctionProtoType *Proto =
+      dyn_cast<FunctionProtoType>(Function->getType()->getAs<FunctionType>());
   assert(Proto && "Functions without a prototype cannot be overloaded");
   assert(!Function->getDescribedFunctionTemplate() &&
          "Use AddTemplateOverloadCandidate for function templates");
@@ -7558,13 +7486,13 @@ Sema::SelectBestMethod(Selector Sel, MultiExprArg Args, bool IsInstance,
         break;
       }
 
-      ImplicitConversionSequence ConversionState
-        = TryCopyInitialization(*this, argExpr, param->getType(),
-                                /*SuppressUserConversions*/false,
+      ImplicitConversionSequence ConversionState =
+          TryCopyInitialization(*this, argExpr, param->getType(),
+                                /*SuppressUserConversions*/ false,
                                 /*InOverloadResolution=*/true,
                                 /*AllowObjCWritebackConversion=*/
                                 getLangOpts().ObjCAutoRefCount,
-                                /*AllowExplicit*/false);
+                                /*AllowExplicit*/ false);
       // This function looks for a reasonably-exact match, so we consider
       // incompatible pointer conversions to be a failure here.
       if (ConversionState.isBad() ||
@@ -7673,8 +7601,7 @@ static bool convertArgsForAvailabilityChecks(
 }
 
 EnableIfAttr *Sema::CheckEnableIf(FunctionDecl *Function,
-                                  SourceLocation CallLoc,
-                                  ArrayRef<Expr *> Args,
+                                  SourceLocation CallLoc, ArrayRef<Expr *> Args,
                                   bool MissingImplicitThis) {
   auto EnableIfAttrs = Function->specific_attrs<EnableIfAttr>();
   if (EnableIfAttrs.begin() == EnableIfAttrs.end())
@@ -7785,7 +7712,8 @@ bool Sema::diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function,
         // EvaluateWithSubstitution only cares about the position of each
         // argument in the arg list, not the ParmVarDecl* it maps to.
         if (!DIA->getCond()->EvaluateWithSubstitution(
-                Result, Context, cast<FunctionDecl>(DIA->getParent()), Args, ThisArg))
+                Result, Context, cast<FunctionDecl>(DIA->getParent()), Args,
+                ThisArg))
           return false;
         return Result.isInt() && Result.getInt().getBoolValue();
       });
@@ -7794,8 +7722,7 @@ bool Sema::diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function,
 bool Sema::diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND,
                                                  SourceLocation Loc) {
   return diagnoseDiagnoseIfAttrsWith(
-      *this, ND, /*ArgDependent=*/false, Loc,
-      [&](const DiagnoseIfAttr *DIA) {
+      *this, ND, /*ArgDependent=*/false, Loc, [&](const DiagnoseIfAttr *DIA) {
         bool Result;
         return DIA->getCond()->EvaluateAsBooleanCondition(Result, Context) &&
                Result;
@@ -7858,10 +7785,9 @@ void Sema::AddFunctionCandidates(const UnresolvedSetImpl &Fns,
         FunctionArgs = Args.slice(1);
       }
       if (FunTmpl) {
-        AddTemplateOverloadCandidate(FunTmpl, F.getPair(),
-                                     ExplicitTemplateArgs, FunctionArgs,
-                                     CandidateSet, SuppressUserConversions,
-                                     PartialOverloading);
+        AddTemplateOverloadCandidate(
+            FunTmpl, F.getPair(), ExplicitTemplateArgs, FunctionArgs,
+            CandidateSet, SuppressUserConversions, PartialOverloading);
       } else {
         AddOverloadCandidate(FD, F.getPair(), FunctionArgs, CandidateSet,
                              SuppressUserConversions, PartialOverloading);
@@ -7903,8 +7829,8 @@ void Sema::AddMethodCandidate(
     OverloadCandidateSet &CandidateSet, bool SuppressUserConversions,
     bool PartialOverloading, ConversionSequenceList EarlyConversions,
     OverloadCandidateParamOrder PO, bool StrictPackMatch) {
-  const FunctionProtoType *Proto
-    = dyn_cast<FunctionProtoType>(Method->getType()->getAs<FunctionType>());
+  const FunctionProtoType *Proto =
+      dyn_cast<FunctionProtoType>(Method->getType()->getAs<FunctionType>());
   assert(Proto && "Methods without a prototype cannot be overloaded");
   assert(!isa<CXXConstructorDecl>(Method) &&
          "Use AddOverloadCandidate for constructors");
@@ -8054,12 +7980,11 @@ void Sema::AddMethodCandidate(
       } else {
         ParamType = Proto->getParamType(ArgIdx + ExplicitOffset);
       }
-      Candidate.Conversions[ConvIdx]
-        = TryCopyInitialization(*this, Args[ArgIdx], ParamType,
-                                SuppressUserConversions,
-                                /*InOverloadResolution=*/true,
-                                /*AllowObjCWritebackConversion=*/
-                                  getLangOpts().ObjCAutoRefCount);
+      Candidate.Conversions[ConvIdx] = TryCopyInitialization(
+          *this, Args[ArgIdx], ParamType, SuppressUserConversions,
+          /*InOverloadResolution=*/true,
+          /*AllowObjCWritebackConversion=*/
+          getLangOpts().ObjCAutoRefCount);
       if (Candidate.Conversions[ConvIdx].isBad()) {
         Candidate.Viable = false;
         Candidate.FailureKind = ovl_fail_bad_conversion;
@@ -8131,7 +8056,7 @@ static void AddMethodTemplateCandidateImmediately(
     Candidate.Function = Method;
     Candidate.Viable = false;
     Candidate.RewriteKind =
-      CandidateSet.getRewriteInfo().getRewriteKind(Candidate.Function, PO);
+        CandidateSet.getRewriteInfo().getRewriteKind(Candidate.Function, PO);
     Candidate.IsSurrogate = false;
     Candidate.TookAddressOfOverload =
         CandidateSet.getKind() ==
@@ -8254,7 +8179,7 @@ static void AddTemplateOverloadCandidateImmediately(
     Candidate.Function = FunctionTemplate->getTemplatedDecl();
     Candidate.Viable = false;
     Candidate.RewriteKind =
-      CandidateSet.getRewriteInfo().getRewriteKind(Candidate.Function, PO);
+        CandidateSet.getRewriteInfo().getRewriteKind(Candidate.Function, PO);
     Candidate.IsSurrogate = false;
     Candidate.IsADLCandidate = llvm::to_underlying(IsADLCandidate);
     // Ignore the object argument if there is one, since we don't have an object
@@ -8455,8 +8380,8 @@ bool Sema::CheckNonDependentConversions(
 /// Objective-C pointer to another.
 ///
 /// \returns true if the conversion is allowable, false otherwise.
-static bool isAllowableExplicitConversion(Sema &S,
-                                          QualType ConvType, QualType ToType,
+static bool isAllowableExplicitConversion(Sema &S, QualType ConvType,
+                                          QualType ToType,
                                           bool AllowObjCPointerConversion) {
   QualType ToNonRefType = ToType.getNonReferenceType();
 
@@ -8466,7 +8391,7 @@ static bool isAllowableExplicitConversion(Sema &S,
 
   // Allow qualification conversions.
   bool ObjCLifetimeConversion;
-  if (S.IsQualificationConversion(ConvType, ToNonRefType, /*CStyle*/false,
+  if (S.IsQualificationConversion(ConvType, ToNonRefType, /*CStyle*/ false,
                                   ObjCLifetimeConversion))
     return true;
 
@@ -8583,8 +8508,8 @@ void Sema::AddConversionCandidate(
   // We won't go through a user-defined type conversion function to convert a
   // derived to base as such conversions are given Conversion Rank. They only
   // go through a copy constructor. 13.3.3.1.2-p4 [over.ics.user]
-  QualType FromCanon
-    = Context.getCanonicalType(From->getType().getUnqualifiedType());
+  QualType FromCanon =
+      Context.getCanonicalType(From->getType().getUnqualifiedType());
   QualType ToCanon = Context.getCanonicalType(ToType).getUnqualifiedType();
   if (FromCanon == ToCanon ||
       IsDerivedFrom(CandidateSet.getLocation(), FromCanon, ToCanon)) {
@@ -8665,7 +8590,7 @@ void Sema::AddConversionCandidate(
 
   default:
     llvm_unreachable(
-           "Can only end up with a standard conversion sequence or failure");
+        "Can only end up with a standard conversion sequence or failure");
   }
 
   if (EnableIfAttr *FailedAttr =
@@ -8762,10 +8687,9 @@ void Sema::AddTemplateConversionCandidate(
 void Sema::AddSurrogateCandidate(CXXConversionDecl *Conversion,
                                  DeclAccessPair FoundDecl,
                                  CXXRecordDecl *ActingContext,
-                                 const FunctionProtoType *Proto,
-                                 Expr *Object,
+                                 const FunctionProtoType *Proto, Expr *Object,
                                  ArrayRef<Expr *> Args,
-                                 OverloadCandidateSet& CandidateSet) {
+                                 OverloadCandidateSet &CandidateSet) {
   if (!CandidateSet.isNewCandidate(Conversion))
     return;
 
@@ -8811,8 +8735,8 @@ void Sema::AddSurrogateCandidate(CXXConversionDecl *Conversion,
   Candidate.Conversions[0].UserDefined.HadMultipleCandidates = false;
   Candidate.Conversions[0].UserDefined.ConversionFunction = Conversion;
   Candidate.Conversions[0].UserDefined.FoundConversionFunction = FoundDecl;
-  Candidate.Conversions[0].UserDefined.After
-    = Candidate.Conversions[0].UserDefined.Before;
+  Candidate.Conversions[0].UserDefined.After =
+      Candidate.Conversions[0].UserDefined.Before;
   Candidate.Conversions[0].UserDefined.After.setAsIdentityConversion();
 
   // Find the
@@ -8845,12 +8769,12 @@ void Sema::AddSurrogateCandidate(CXXConversionDecl *Conversion,
       // (13.3.3.1) that converts that argument to the corresponding
       // parameter of F.
       QualType ParamType = Proto->getParamType(ArgIdx);
-      Candidate.Conversions[ArgIdx + 1]
-        = TryCopyInitialization(*this, Args[ArgIdx], ParamType,
+      Candidate.Conversions[ArgIdx + 1] =
+          TryCopyInitialization(*this, Args[ArgIdx], ParamType,
                                 /*SuppressUserConversions=*/false,
                                 /*InOverloadResolution=*/false,
                                 /*AllowObjCWritebackConversion=*/
-                                  getLangOpts().ObjCAutoRefCount);
+                                getLangOpts().ObjCAutoRefCount);
       if (Candidate.Conversions[ArgIdx + 1].isBad()) {
         Candidate.Viable = false;
         Candidate.FailureKind = ovl_fail_bad_conversion;
@@ -8979,7 +8903,7 @@ void Sema::AddMemberOperatorCandidates(OverloadedOperatorKind Op,
 }
 
 void Sema::AddBuiltinCandidate(QualType *ParamTys, ArrayRef<Expr *> Args,
-                               OverloadCandidateSet& CandidateSet,
+                               OverloadCandidateSet &CandidateSet,
                                bool IsAssignmentOperator,
                                unsigned NumContextualBoolArguments) {
   // Overload resolution is always an unevaluated context.
@@ -9012,15 +8936,15 @@ void Sema::AddBuiltinCandidate(QualType *ParamTys, ArrayRef<Expr *> Args,
     if (ArgIdx < NumContextualBoolArguments) {
       assert(ParamTys[ArgIdx] == Context.BoolTy &&
              "Contextual conversion to bool requires bool type");
-      Candidate.Conversions[ArgIdx]
-        = TryContextuallyConvertToBool(*this, Args[ArgIdx]);
+      Candidate.Conversions[ArgIdx] =
+          TryContextuallyConvertToBool(*this, Args[ArgIdx]);
     } else {
-      Candidate.Conversions[ArgIdx]
-        = TryCopyInitialization(*this, Args[ArgIdx], ParamTys[ArgIdx],
+      Candidate.Conversions[ArgIdx] =
+          TryCopyInitialization(*this, Args[ArgIdx], ParamTys[ArgIdx],
                                 ArgIdx == 0 && IsAssignmentOperator,
                                 /*InOverloadResolution=*/false,
                                 /*AllowObjCWritebackConversion=*/
-                                  getLangOpts().ObjCAutoRefCount);
+                                getLangOpts().ObjCAutoRefCount);
     }
     if (Candidate.Conversions[ArgIdx].isBad()) {
       Candidate.Viable = false;
@@ -9036,7 +8960,7 @@ namespace {
 /// candidate operator functions for built-in operators (C++
 /// [over.built]). The types are separated into pointer types and
 /// enumeration types.
-class BuiltinCandidateTypeSet  {
+class BuiltinCandidateTypeSet {
   /// TypeSet - A set of types.
   typedef llvm::SmallSetVector<QualType, 8> TypeSet;
 
@@ -9094,15 +9018,11 @@ class BuiltinCandidateTypeSet  {
   typedef TypeSet::iterator iterator;
 
   BuiltinCandidateTypeSet(Sema &SemaRef)
-    : HasNonRecordTypes(false),
-      HasArithmeticOrEnumeralTypes(false),
-      HasNullPtrType(false),
-      HasReflectionType(false),
-      SemaRef(SemaRef),
-      Context(SemaRef.Context) { }
-
-  void AddTypesConvertedFrom(QualType Ty,
-                             SourceLocation Loc,
+      : HasNonRecordTypes(false), HasArithmeticOrEnumeralTypes(false),
+        HasNullPtrType(false), HasReflectionType(false), SemaRef(SemaRef),
+        Context(SemaRef.Context) {}
+
+  void AddTypesConvertedFrom(QualType Ty, SourceLocation Loc,
                              bool AllowUserConversions,
                              bool AllowExplicitConversions,
                              const Qualifiers &VisibleTypeConversionsQuals);
@@ -9136,9 +9056,8 @@ class BuiltinCandidateTypeSet  {
 /// false otherwise.
 ///
 /// FIXME: what to do about extended qualifiers?
-bool
-BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(QualType Ty,
-                                             const Qualifiers &VisibleQuals) {
+bool BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(
+    QualType Ty, const Qualifiers &VisibleQuals) {
 
   // Insert this type.
   if (!PointerTypes.insert(Ty))
@@ -9167,10 +9086,12 @@ BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(QualType Ty,
   bool hasRestrict = VisibleQuals.hasRestrict();
 
   // Iterate through all strict supersets of BaseCVR.
-  for (unsigned CVR = BaseCVR+1; CVR <= Qualifiers::CVRMask; ++CVR) {
-    if ((CVR | BaseCVR) != CVR) continue;
+  for (unsigned CVR = BaseCVR + 1; CVR <= Qualifiers::CVRMask; ++CVR) {
+    if ((CVR | BaseCVR) != CVR)
+      continue;
     // Skip over volatile if no volatile found anywhere in the types.
-    if ((CVR & Qualifiers::Volatile) && !hasVolatile) continue;
+    if ((CVR & Qualifiers::Volatile) && !hasVolatile)
+      continue;
 
     // Skip over restrict if no restrict found anywhere in the types, or if
     // the type cannot be restrict-qualified.
@@ -9205,8 +9126,7 @@ BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(QualType Ty,
 /// false otherwise.
 ///
 /// FIXME: what to do about extended qualifiers?
-bool
-BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
+bool BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
     QualType Ty) {
   // Insert this type.
   if (!MemberPointerTypes.insert(Ty))
@@ -9227,8 +9147,9 @@ BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
   // Iterate through all strict supersets of the pointee type's CVR
   // qualifiers.
   unsigned BaseCVR = PointeeTy.getCVRQualifiers();
-  for (unsigned CVR = BaseCVR+1; CVR <= Qualifiers::CVRMask; ++CVR) {
-    if ((CVR | BaseCVR) != CVR) continue;
+  for (unsigned CVR = BaseCVR + 1; CVR <= Qualifiers::CVRMask; ++CVR) {
+    if ((CVR | BaseCVR) != CVR)
+      continue;
 
     QualType QPointeeTy = Context.getCVRQualifiedType(PointeeTy, CVR);
     MemberPointerTypes.insert(Context.getMemberPointerType(
@@ -9246,12 +9167,9 @@ BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
 /// functions of a class type, and AllowExplicitConversions if we
 /// should also include the explicit conversion functions of a class
 /// type.
-void
-BuiltinCandidateTypeSet::AddTypesConvertedFrom(QualType Ty,
-                                               SourceLocation Loc,
-                                               bool AllowUserConversions,
-                                               bool AllowExplicitConversions,
-                                               const Qualifiers &VisibleQuals) {
+void BuiltinCandidateTypeSet::AddTypesConvertedFrom(
+    QualType Ty, SourceLocation Loc, bool AllowUserConversions,
+    bool AllowExplicitConversions, const Qualifiers &VisibleQuals) {
   // Only deal with canonical types.
   Ty = Context.getCanonicalType(Ty);
 
@@ -9273,7 +9191,7 @@ BuiltinCandidateTypeSet::AddTypesConvertedFrom(QualType Ty,
 
   // Flag if we encounter an arithmetic type.
   HasArithmeticOrEnumeralTypes =
-    HasArithmeticOrEnumeralTypes || Ty->isArithmeticType();
+      HasArithmeticOrEnumeralTypes || Ty->isArithmeticType();
 
   if (Ty->isObjCIdType() || Ty->isObjCClassType())
     PointerTypes.insert(Ty);
@@ -9339,10 +9257,10 @@ static QualType AdjustAddressSpaceForBuiltinOperandType(Sema &S, QualType T,
 /// Helper function for AddBuiltinOperatorCandidates() that adds
 /// the volatile- and non-volatile-qualified assignment operators for the
 /// given type to the candidate set.
-static void AddBuiltinAssignmentOperatorCandidates(Sema &S,
-                                                   QualType T,
-                                                   ArrayRef<Expr *> Args,
-                                    OverloadCandidateSet &CandidateSet) {
+static void
+AddBuiltinAssignmentOperatorCandidates(Sema &S, QualType T,
+                                       ArrayRef<Expr *> Args,
+                                       OverloadCandidateSet &CandidateSet) {
   QualType ParamTypes[2];
 
   // T& operator=(T&, T)
@@ -9365,51 +9283,51 @@ static void AddBuiltinAssignmentOperatorCandidates(Sema &S,
 
 /// CollectVRQualifiers - This routine returns Volatile/Restrict qualifiers,
 /// if any, found in visible type conversion functions found in ArgExpr's type.
-static  Qualifiers CollectVRQualifiers(ASTContext &Context, Expr* ArgExpr) {
-    Qualifiers VRQuals;
-    CXXRecordDecl *ClassDecl;
-    if (const MemberPointerType *RHSMPType =
-            ArgExpr->getType()->getAs<MemberPointerType>())
-      ClassDecl = RHSMPType->getMostRecentCXXRecordDecl();
-    else
-      ClassDecl = ArgExpr->getType()->getAsCXXRecordDecl();
-    if (!ClassDecl) {
-      // Just to be safe, assume the worst case.
-      VRQuals.addVolatile();
-      VRQuals.addRestrict();
-      return VRQuals;
-    }
-    if (!ClassDecl->hasDefinition())
-      return VRQuals;
+static Qualifiers CollectVRQualifiers(ASTContext &Context, Expr *ArgExpr) {
+  Qualifiers VRQuals;
+  CXXRecordDecl *ClassDecl;
+  if (const MemberPointerType *RHSMPType =
+          ArgExpr->getType()->getAs<MemberPointerType>())
+    ClassDecl = RHSMPType->getMostRecentCXXRecordDecl();
+  else
+    ClassDecl = ArgExpr->getType()->getAsCXXRecordDecl();
+  if (!ClassDecl) {
+    // Just to be safe, assume the worst case.
+    VRQuals.addVolatile();
+    VRQuals.addRestrict();
+    return VRQuals;
+  }
+  if (!ClassDecl->hasDefinition())
+    return VRQuals;
 
-    for (NamedDecl *D : ClassDecl->getVisibleConversionFunctions()) {
-      if (isa<UsingShadowDecl>(D))
-        D = cast<UsingShadowDecl>(D)->getTargetDecl();
-      if (CXXConversionDecl *Conv = dyn_cast<CXXConversionDecl>(D)) {
-        QualType CanTy = Context.getCanonicalType(Conv->getConversionType());
-        if (const ReferenceType *ResTypeRef = CanTy->getAs<ReferenceType>())
-          CanTy = ResTypeRef->getPointeeType();
-        // Need to go down the pointer/mempointer chain and add qualifiers
-        // as see them.
-        bool done = false;
-        while (!done) {
-          if (CanTy.isRestrictQualified())
-            VRQuals.addRestrict();
-          if (const PointerType *ResTypePtr = CanTy->getAs<PointerType>())
-            CanTy = ResTypePtr->getPointeeType();
-          else if (const MemberPointerType *ResTypeMPtr =
-                CanTy->getAs<MemberPointerType>())
-            CanTy = ResTypeMPtr->getPointeeType();
-          else
-            done = true;
-          if (CanTy.isVolatileQualified())
-            VRQuals.addVolatile();
-          if (VRQuals.hasRestrict() && VRQuals.hasVolatile())
-            return VRQuals;
-        }
+  for (NamedDecl *D : ClassDecl->getVisibleConversionFunctions()) {
+    if (isa<UsingShadowDecl>(D))
+      D = cast<UsingShadowDecl>(D)->getTargetDecl();
+    if (CXXConversionDecl *Conv = dyn_cast<CXXConversionDecl>(D)) {
+      QualType CanTy = Context.getCanonicalType(Conv->getConversionType());
+      if (const ReferenceType *ResTypeRef = CanTy->getAs<ReferenceType>())
+        CanTy = ResTypeRef->getPointeeType();
+      // Need to go down the pointer/mempointer chain and add qualifiers
+      // as see them.
+      bool done = false;
+      while (!done) {
+        if (CanTy.isRestrictQualified())
+          VRQuals.addRestrict();
+        if (const PointerType *ResTypePtr = CanTy->getAs<PointerType>())
+          CanTy = ResTypePtr->getPointeeType();
+        else if (const MemberPointerType *ResTypeMPtr =
+                     CanTy->getAs<MemberPointerType>())
+          CanTy = ResTypeMPtr->getPointeeType();
+        else
+          done = true;
+        if (CanTy.isVolatileQualified())
+          VRQuals.addVolatile();
+        if (VRQuals.hasRestrict() && VRQuals.hasVolatile())
+          return VRQuals;
       }
     }
-    return VRQuals;
+  }
+  return VRQuals;
 }
 
 // Note: We're currently only handling qualifiers that are meaningful for the
@@ -9476,12 +9394,9 @@ class BuiltinOperatorOverloadBuilder {
   // Define some indices used to iterate over the arithmetic types in
   // ArithmeticTypes.  The "promoted arithmetic types" are the arithmetic
   // types are that preserved by promotion (C++ [over.built]p2).
-  unsigned FirstIntegralType,
-           LastIntegralType;
-  unsigned FirstPromotedIntegralType,
-           LastPromotedIntegralType;
-  unsigned FirstPromotedArithmeticType,
-           LastPromotedArithmeticType;
+  unsigned FirstIntegralType, LastIntegralType;
+  unsigned FirstPromotedIntegralType, LastPromotedIntegralType;
+  unsigned FirstPromotedArithmeticType, LastPromotedArithmeticType;
   unsigned NumArithmeticTypes;
 
   void InitArithmeticTypes() {
@@ -9556,12 +9471,9 @@ class BuiltinOperatorOverloadBuilder {
   /// Helper method to factor out the common pattern of adding overloads
   /// for '++' and '--' builtin operators.
   void addPlusPlusMinusMinusStyleOverloads(QualType CandidateTy,
-                                           bool HasVolatile,
-                                           bool HasRestrict) {
-    QualType ParamTypes[2] = {
-      S.Context.getLValueReferenceType(CandidateTy),
-      S.Context.IntTy
-    };
+                                           bool HasVolatile, bool HasRestrict) {
+    QualType ParamTypes[2] = {S.Context.getLValueReferenceType(CandidateTy),
+                              S.Context.IntTy};
 
     // Non-volatile version.
     S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);
@@ -9569,8 +9481,7 @@ class BuiltinOperatorOverloadBuilder {
     // Use a heuristic to reduce number of builtin candidates in the set:
     // add volatile version only if there are conversions to a volatile type.
     if (HasVolatile) {
-      ParamTypes[0] =
-        S.Context.getLValueReferenceType(
+      ParamTypes[0] = S.Context.getLValueReferenceType(
           S.Context.getVolatileType(CandidateTy));
       S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);
     }
@@ -9579,21 +9490,17 @@ class BuiltinOperatorOverloadBuilder {
     // and our candidate type is a non-restrict-qualified pointer.
     if (HasRestrict && CandidateTy->isAnyPointerType() &&
         !CandidateTy.isRestrictQualified()) {
-      ParamTypes[0]
-        = S.Context.getLValueReferenceType(
-            S.Context.getCVRQualifiedType(CandidateTy, Qualifiers::Restrict));
+      ParamTypes[0] = S.Context.getLValueReferenceType(
+          S.Context.getCVRQualifiedType(CandidateTy, Qualifiers::Restrict));
       S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);
 
       if (HasVolatile) {
-        ParamTypes[0]
-          = S.Context.getLValueReferenceType(
-              S.Context.getCVRQualifiedType(CandidateTy,
-                                            (Qualifiers::Volatile |
-                                             Qualifiers::Restrict)));
+        ParamTypes[0] =
+            S.Context.getLValueReferenceType(S.Context.getCVRQualifiedType(
+                CandidateTy, (Qualifiers::Volatile | Qualifiers::Restrict)));
         S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);
       }
     }
-
   }
 
   /// Helper to add an overload candidate for a binary builtin with types \p L
@@ -9605,17 +9512,16 @@ class BuiltinOperatorOverloadBuilder {
 
 public:
   BuiltinOperatorOverloadBuilder(
-    Sema &S, ArrayRef<Expr *> Args,
-    QualifiersAndAtomic VisibleTypeConversionsQuals,
-    bool HasArithmeticOrEnumeralCandidateType,
-    SmallVectorImpl<BuiltinCandidateTypeSet> &CandidateTypes,
-    OverloadCandidateSet &CandidateSet)
-    : S(S), Args(Args),
-      VisibleTypeConversionsQuals(VisibleTypeConversionsQuals),
-      HasArithmeticOrEnumeralCandidateType(
-        HasArithmeticOrEnumeralCandidateType),
-      CandidateTypes(CandidateTypes),
-      CandidateSet(CandidateSet) {
+      Sema &S, ArrayRef<Expr *> Args,
+      QualifiersAndAtomic VisibleTypeConversionsQuals,
+      bool HasArithmeticOrEnumeralCandidateType,
+      SmallVectorImpl<BuiltinCandidateTypeSet> &CandidateTypes,
+      OverloadCandidateSet &CandidateSet)
+      : S(S), Args(Args),
+        VisibleTypeConversionsQuals(VisibleTypeConversionsQuals),
+        HasArithmeticOrEnumeralCandidateType(
+            HasArithmeticOrEnumeralCandidateType),
+        CandidateTypes(CandidateTypes), CandidateSet(CandidateSet) {
 
     InitArithmeticTypes();
   }
@@ -9652,9 +9558,8 @@ class BuiltinOperatorOverloadBuilder {
           continue;
       }
       addPlusPlusMinusMinusStyleOverloads(
-        TypeOfT,
-        VisibleTypeConversionsQuals.hasVolatile(),
-        VisibleTypeConversionsQuals.hasRestrict());
+          TypeOfT, VisibleTypeConversionsQuals.hasVolatile(),
+          VisibleTypeConversionsQuals.hasRestrict());
     }
   }
 
@@ -9699,7 +9604,8 @@ class BuiltinOperatorOverloadBuilder {
       if (!PointeeTy->isObjectType() && !PointeeTy->isFunctionType())
         continue;
 
-      if (const FunctionProtoType *Proto =PointeeTy->getAs<FunctionProtoType>())
+      if (const FunctionProtoType *Proto =
+              PointeeTy->getAs<FunctionProtoType>())
         if (Proto->getMethodQuals() || Proto->getRefQualifier())
           continue;
 
@@ -9781,7 +9687,7 @@ class BuiltinOperatorOverloadBuilder {
       if (CandidateTypes[ArgIdx].hasNullPtrType()) {
         CanQualType NullPtrTy = S.Context.getCanonicalType(S.Context.NullPtrTy);
         if (AddedTypes.insert(NullPtrTy).second) {
-          QualType ParamTypes[2] = { NullPtrTy, NullPtrTy };
+          QualType ParamTypes[2] = {NullPtrTy, NullPtrTy};
           S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);
         }
       }
@@ -9789,7 +9695,7 @@ class BuiltinOperatorOverloadBuilder {
       if (CandidateTypes[ArgIdx].hasReflectionType()) {
         CanQualType InfoTy = S.Context.getCanonicalType(S.Context.MetaInfoTy);
         if (AddedTypes.insert(InfoTy).second) {
-          QualType ParamTypes[2] = { InfoTy, InfoTy };
+          QualType ParamTypes[2] = {InfoTy, InfoTy};
           S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);
         }
       }
@@ -9816,18 +9722,18 @@ class BuiltinOperatorOverloadBuilder {
     //   candidate.
     //
     // Note that in practice, this only affects enumeration types because there
-    // aren't any built-in candidates of record type, and a user-defined operator
-    // must have an operand of record or enumeration type. Also, the only other
-    // overloaded operator with enumeration arguments, operator=,
+    // aren't any built-in candidates of record type, and a user-defined
+    // operator must have an operand of record or enumeration type. Also, the
+    // only other overloaded operator with enumeration arguments, operator=,
     // cannot be overloaded for enumeration types, so this is the only place
     // where we must suppress candidates like this.
-    llvm::DenseSet<std::pair<CanQualType, CanQualType> >
-      UserDefinedBinaryOperators;
+    llvm::DenseSet<std::pair<CanQualType, CanQualType>>
+        UserDefinedBinaryOperators;
 
     for (unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
       if (!CandidateTypes[ArgIdx].enumeration_types().empty()) {
         for (OverloadCandidateSet::iterator C = CandidateSet.begin(),
-                                         CEnd = CandidateSet.end();
+                                            CEnd = CandidateSet.end();
              C != CEnd; ++C) {
           if (!C->Viable || !C->Function || C->Function->getNumParams() != 2)
             continue;
@@ -9853,8 +9759,8 @@ class BuiltinOperatorOverloadBuilder {
 
           // Add this operator to the set of known user-defined operators.
           UserDefinedBinaryOperators.insert(
-            std::make_pair(S.Context.getCanonicalType(FirstParamType),
-                           S.Context.getCanonicalType(SecondParamType)));
+              std::make_pair(S.Context.getCanonicalType(FirstParamType),
+                             S.Context.getCanonicalType(SecondParamType)));
         }
       }
     }
@@ -9879,8 +9785,8 @@ class BuiltinOperatorOverloadBuilder {
         // Don't add the same builtin candidate twice, or if a user defined
         // candidate exists.
         if (!AddedTypes.insert(CanonType).second ||
-            UserDefinedBinaryOperators.count(std::make_pair(CanonType,
-                                                            CanonType)))
+            UserDefinedBinaryOperators.count(
+                std::make_pair(CanonType, CanonType)))
           continue;
         QualType ParamTypes[2] = {EnumTy, EnumTy};
         S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);
@@ -9911,8 +9817,8 @@ class BuiltinOperatorOverloadBuilder {
 
     for (int Arg = 0; Arg < 2; ++Arg) {
       QualType AsymmetricParamTypes[2] = {
-        S.Context.getPointerDiffType(),
-        S.Context.getPointerDiffType(),
+          S.Context.getPointerDiffType(),
+          S.Context.getPointerDiffType(),
       };
       for (QualType PtrTy : CandidateTypes[Arg].pointer_types()) {
         QualType PointeeTy = PtrTy->getPointeeType();
@@ -9974,8 +9880,7 @@ class BuiltinOperatorOverloadBuilder {
          Left < LastPromotedArithmeticType; ++Left) {
       for (unsigned Right = FirstPromotedArithmeticType;
            Right < LastPromotedArithmeticType; ++Right) {
-        QualType LandR[2] = { ArithmeticTypes[Left],
-                              ArithmeticTypes[Right] };
+        QualType LandR[2] = {ArithmeticTypes[Left], ArithmeticTypes[Right]};
         S.AddBuiltinCandidate(LandR, Args, CandidateSet);
       }
     }
@@ -10067,8 +9972,7 @@ class BuiltinOperatorOverloadBuilder {
          Left < LastPromotedIntegralType; ++Left) {
       for (unsigned Right = FirstPromotedIntegralType;
            Right < LastPromotedIntegralType; ++Right) {
-        QualType LandR[2] = { ArithmeticTypes[Left],
-                              ArithmeticTypes[Right] };
+        QualType LandR[2] = {ArithmeticTypes[Left], ArithmeticTypes[Right]};
         S.AddBuiltinCandidate(LandR, Args, CandidateSet);
       }
     }
@@ -10135,7 +10039,7 @@ class BuiltinOperatorOverloadBuilder {
           isEqualOp ? PtrTy : S.Context.getPointerDiffType(),
       };
       S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet,
-                            /*IsAssignmentOperator=*/ isEqualOp);
+                            /*IsAssignmentOperator=*/isEqualOp);
 
       bool NeedVolatile = !PtrTy.isVolatileQualified() &&
                           VisibleTypeConversionsQuals.hasVolatile();
@@ -10314,7 +10218,7 @@ class BuiltinOperatorOverloadBuilder {
                           /*NumContextualBoolArguments=*/1);
   }
   void addAmpAmpOrPipePipeOverload() {
-    QualType ParamTypes[2] = { S.Context.BoolTy, S.Context.BoolTy };
+    QualType ParamTypes[2] = {S.Context.BoolTy, S.Context.BoolTy};
     S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet,
                           /*IsAssignmentOperator=*/false,
                           /*NumContextualBoolArguments=*/2);
@@ -10468,15 +10372,12 @@ void Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
   SmallVector<BuiltinCandidateTypeSet, 2> CandidateTypes;
   for (unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
     CandidateTypes.emplace_back(*this);
-    CandidateTypes[ArgIdx].AddTypesConvertedFrom(Args[ArgIdx]->getType(),
-                                                 OpLoc,
-                                                 true,
-                                                 (Op == OO_Exclaim ||
-                                                  Op == OO_AmpAmp ||
-                                                  Op == OO_PipePipe),
-                                                 VisibleTypeConversionsQuals);
-    HasNonRecordCandidateType = HasNonRecordCandidateType ||
-        CandidateTypes[ArgIdx].hasNonRecordTypes();
+    CandidateTypes[ArgIdx].AddTypesConvertedFrom(
+        Args[ArgIdx]->getType(), OpLoc, true,
+        (Op == OO_Exclaim || Op == OO_AmpAmp || Op == OO_PipePipe),
+        VisibleTypeConversionsQuals);
+    HasNonRecordCandidateType =
+        HasNonRecordCandidateType || CandidateTypes[ArgIdx].hasNonRecordTypes();
     HasArithmeticOrEnumeralCandidateType =
         HasArithmeticOrEnumeralCandidateType ||
         CandidateTypes[ArgIdx].hasArithmeticOrEnumeralTypes();
@@ -10492,10 +10393,9 @@ void Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
     return;
 
   // Setup an object to manage the common state for building overloads.
-  BuiltinOperatorOverloadBuilder OpBuilder(*this, Args,
-                                           VisibleTypeConversionsQuals,
-                                           HasArithmeticOrEnumeralCandidateType,
-                                           CandidateTypes, CandidateSet);
+  BuiltinOperatorOverloadBuilder OpBuilder(
+      *this, Args, VisibleTypeConversionsQuals,
+      HasArithmeticOrEnumeralCandidateType, CandidateTypes, CandidateSet);
 
   // Dispatch over the operation to add in only those overloads which apply.
   switch (Op) {
@@ -10509,7 +10409,7 @@ void Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
   case OO_Array_Delete:
   case OO_Call:
     llvm_unreachable(
-                    "Special operators don't use AddBuiltinOperatorCandidates");
+        "Special operators don't use AddBuiltinOperatorCandidates");
 
   case OO_Comma:
   case OO_Arrow:
@@ -10644,13 +10544,10 @@ void Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
   }
 }
 
-void
-Sema::AddArgumentDependentLookupCandidates(DeclarationName Name,
-                                           SourceLocation Loc,
-                                           ArrayRef<Expr *> Args,
-                                 TemplateArgumentListInfo *ExplicitTemplateArgs,
-                                           OverloadCandidateSet& CandidateSet,
-                                           bool PartialOverloading) {
+void Sema::AddArgumentDependentLookupCandidates(
+    DeclarationName Name, SourceLocation Loc, ArrayRef<Expr *> Args,
+    TemplateArgumentListInfo *ExplicitTemplateArgs,
+    OverloadCandidateSet &CandidateSet, bool PartialOverloading) {
   ADLResult Fns;
 
   // FIXME: This approach for uniquing ADL results (and removing
@@ -10667,7 +10564,7 @@ Sema::AddArgumentDependentLookupCandidates(DeclarationName Name,
 
   // Erase all of the candidates we already knew about.
   for (OverloadCandidateSet::iterator Cand = CandidateSet.begin(),
-                                   CandEnd = CandidateSet.end();
+                                      CandEnd = CandidateSet.end();
        Cand != CandEnd; ++Cand)
     if (Cand->Function) {
       FunctionDecl *Fn = Cand->Function;
@@ -11075,9 +10972,8 @@ bool clang::isBetterOverloadCandidate(
   //   conversion sequence than ICSi(F2), and then...
   bool HasWorseConversion = false;
   for (unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
-    switch (CompareImplicitConversionSequences(S, Loc,
-                                               Cand1.Conversions[ArgIdx],
-                                               Cand2.Conversions[ArgIdx])) {
+    switch (CompareImplicitConversionSequences(
+        S, Loc, Cand1.Conversions[ArgIdx], Cand2.Conversions[ArgIdx])) {
     case ImplicitConversionSequence::Better:
       // Cand1 has a better conversion sequence.
       HasBetterConversion = true;
@@ -11136,8 +11032,7 @@ bool clang::isBetterOverloadCandidate(
     ImplicitConversionSequence::CompareKind Result =
         compareConversionFunctions(S, Cand1.Function, Cand2.Function);
     if (Result == ImplicitConversionSequence::Indistinguishable)
-      Result = CompareStandardConversionSequences(S, Loc,
-                                                  Cand1.FinalConversion,
+      Result = CompareStandardConversionSequences(S, Loc, Cand1.FinalConversion,
                                                   Cand2.FinalConversion);
 
     if (Result != ImplicitConversionSequence::Indistinguishable)
@@ -11165,10 +11060,10 @@ bool clang::isBetterOverloadCandidate(
 
   //    -- F1 is a non-template function and F2 is a function template
   //       specialization, or, if not that,
-  bool Cand1IsSpecialization = Cand1.Function &&
-                               Cand1.Function->getPrimaryTemplate();
-  bool Cand2IsSpecialization = Cand2.Function &&
-                               Cand2.Function->getPrimaryTemplate();
+  bool Cand1IsSpecialization =
+      Cand1.Function && Cand1.Function->getPrimaryTemplate();
+  bool Cand2IsSpecialization =
+      Cand2.Function && Cand2.Function->getPrimaryTemplate();
   if (Cand1IsSpecialization != Cand2IsSpecialization)
     return Cand2IsSpecialization;
 
@@ -11331,8 +11226,8 @@ bool Sema::isEquivalentInternalLinkageDeclaration(const NamedDecl *A,
   // entity in different modules.
   if (!VA->getDeclContext()->getRedeclContext()->Equals(
           VB->getDeclContext()->getRedeclContext()) ||
-      getOwningModule(VA) == getOwningModule(VB) ||
-      VA->isExternallyVisible() || VB->isExternallyVisible())
+      getOwningModule(VA) == getOwningModule(VB) || VA->isExternallyVisible() ||
+      VB->isExternallyVisible())
     return false;
 
   // Check that the declarations appear to be equivalent.
@@ -11761,7 +11656,7 @@ void MaybeEmitInheritedConstructorNote(Sema &S, const Decl *FoundDecl) {
   if (const auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl))
     S.Diag(FoundDecl->getLocation(),
            diag::note_ovl_candidate_inherited_constructor)
-      << Shadow->getNominatedBaseClass();
+        << Shadow->getNominatedBaseClass();
 }
 
 } // end anonymous namespace
@@ -11970,14 +11865,14 @@ void Sema::NoteAllOverloadCandidates(Expr *OverloadedExpr, QualType DestType,
   OverloadExpr *OvlExpr = Ovl.Expression;
 
   for (UnresolvedSetIterator I = OvlExpr->decls_begin(),
-                            IEnd = OvlExpr->decls_end();
+                             IEnd = OvlExpr->decls_end();
        I != IEnd; ++I) {
     if (FunctionTemplateDecl *FunTmpl =
-                dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl()) ) {
+            dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl())) {
       NoteOverloadCandidate(*I, FunTmpl->getTemplatedDecl(), CRK_None, DestType,
                             TakingAddress);
-    } else if (FunctionDecl *Fun
-                      = dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()) ) {
+    } else if (FunctionDecl *Fun =
+                   dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl())) {
       NoteOverloadCandidate(*I, Fun, CRK_None, DestType, TakingAddress);
     }
   }
@@ -11987,11 +11882,8 @@ void Sema::NoteAllOverloadCandidates(Expr *OverloadedExpr, QualType DestType,
 /// "lead" diagnostic; it will be given two arguments, the source and
 /// target types of the conversion.
 void ImplicitConversionSequence::DiagnoseAmbiguousConversion(
-                                 Sema &S,
-                                 SourceLocation CaretLoc,
-                                 const PartialDiagnostic &PDiag) const {
-  S.Diag(CaretLoc, PDiag)
-    << Ambiguous.getFromType() << Ambiguous.getToType();
+    Sema &S, SourceLocation CaretLoc, const PartialDiagnostic &PDiag) const {
+  S.Diag(CaretLoc, PDiag) << Ambiguous.getFromType() << Ambiguous.getToType();
   unsigned CandsShown = 0;
   AmbiguousConversionSequence::const_iterator I, E;
   for (I = Ambiguous.begin(), E = Ambiguous.end(); I != E; ++I) {
@@ -12005,8 +11897,8 @@ void ImplicitConversionSequence::DiagnoseAmbiguousConversion(
     S.Diag(SourceLocation(), diag::note_ovl_too_many_candidates) << int(E - I);
 }
 
-static void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand,
-                                  unsigned I, bool TakingCandidateAddress) {
+static void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand, unsigned I,
+                                  bool TakingCandidateAddress) {
   const ImplicitConversionSequence &Conv = Cand->Conversions[I];
   assert(Conv.isBad());
   assert(Cand->Function && "for now, candidate must be a function");
@@ -12190,10 +12082,10 @@ static void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand,
                           FromPtrTy->getPointeeType()))
         BaseToDerivedConversion = 1;
     }
-  } else if (const ObjCObjectPointerType *FromPtrTy
-                                    = FromTy->getAs<ObjCObjectPointerType>()) {
-    if (const ObjCObjectPointerType *ToPtrTy
-                                        = ToTy->getAs<ObjCObjectPointerType>())
+  } else if (const ObjCObjectPointerType *FromPtrTy =
+                 FromTy->getAs<ObjCObjectPointerType>()) {
+    if (const ObjCObjectPointerType *ToPtrTy =
+            ToTy->getAs<ObjCObjectPointerType>())
       if (const ObjCInterfaceDecl *FromIface = FromPtrTy->getInterfaceDecl())
         if (const ObjCInterfaceDecl *ToIface = ToPtrTy->getInterfaceDecl())
           if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
@@ -12219,8 +12111,7 @@ static void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand,
     return;
   }
 
-  if (isa<ObjCObjectPointerType>(CFromTy) &&
-      isa<PointerType>(CToTy)) {
+  if (isa<ObjCObjectPointerType>(CFromTy) && isa<PointerType>(CToTy)) {
     Qualifiers FromQs = CFromTy.getQualifiers();
     Qualifiers ToQs = CToTy.getQualifiers();
     if (FromQs.getObjCLifetime() != ToQs.getObjCLifetime()) {
@@ -12256,7 +12147,7 @@ static void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand,
   if (!S.SourceMgr.isInSystemHeader(Fn->getLocation())) {
     // If we can fix the conversion, suggest the FixIts.
     for (const FixItHint &HI : Cand->Fix.Hints)
-        FDiag << HI;
+      FDiag << HI;
   }
 
   S.Diag(Fn->getLocation(), FDiag);
@@ -12303,9 +12194,9 @@ static void DiagnoseArityMismatch(Sema &S, NamedDecl *Found, Decl *D,
                                   unsigned NumFormalArgs,
                                   bool IsAddressOf = false) {
   assert(isa<FunctionDecl>(D) &&
-      "The templated declaration should at least be a function"
-      " when diagnosing bad template argument deduction due to too many"
-      " or too few arguments");
+         "The templated declaration should at least be a function"
+         " when diagnosing bad template argument deduction due to too many"
+         " or too few arguments");
 
   FunctionDecl *Fn = cast<FunctionDecl>(D);
 
@@ -12383,9 +12274,9 @@ static void DiagnoseBadDeduction(Sema &S, NamedDecl *Found, Decl *Templated,
                                  bool TakingCandidateAddress) {
   TemplateParameter Param = DeductionFailure.getTemplateParameter();
   NamedDecl *ParamD;
-  (ParamD = Param.dyn_cast<TemplateTypeParmDecl*>()) ||
-  (ParamD = Param.dyn_cast<NonTypeTemplateParmDecl*>()) ||
-  (ParamD = Param.dyn_cast<TemplateTemplateParmDecl*>());
+  (ParamD = Param.dyn_cast<TemplateTypeParmDecl *>()) ||
+      (ParamD = Param.dyn_cast<NonTypeTemplateParmDecl *>()) ||
+      (ParamD = Param.dyn_cast<TemplateTemplateParmDecl *>());
   switch (DeductionFailure.getResult()) {
   case TemplateDeductionResult::Success:
     llvm_unreachable(
@@ -12458,8 +12349,8 @@ static void DiagnoseBadDeduction(Sema &S, NamedDecl *Found, Decl *Templated,
       if (!T1.isNull() && !T2.isNull() && !S.Context.hasSameType(T1, T2)) {
         S.Diag(Templated->getLocation(),
                diag::note_ovl_candidate_inconsistent_deduction_types)
-          << ParamD->getDeclName() << *DeductionFailure.getFirstArg() << T1
-          << *DeductionFailure.getSecondArg() << T2;
+            << ParamD->getDeclName() << *DeductionFailure.getFirstArg() << T1
+            << *DeductionFailure.getSecondArg() << T2;
         MaybeEmitInheritedConstructorNote(S, Found);
         return;
       }
@@ -12497,8 +12388,8 @@ static void DiagnoseBadDeduction(Sema &S, NamedDecl *Found, Decl *Templated,
       int index = 0;
       if (TemplateTypeParmDecl *TTP = dyn_cast<TemplateTypeParmDecl>(ParamD))
         index = TTP->getIndex();
-      else if (NonTypeTemplateParmDecl *NTTP
-                                  = dyn_cast<NonTypeTemplateParmDecl>(ParamD))
+      else if (NonTypeTemplateParmDecl *NTTP =
+                   dyn_cast<NonTypeTemplateParmDecl>(ParamD))
         index = NTTP->getIndex();
       else
         index = cast<TemplateTemplateParmDecl>(ParamD)->getIndex();
@@ -12523,7 +12414,7 @@ static void DiagnoseBadDeduction(Sema &S, NamedDecl *Found, Decl *Templated,
         << TemplateArgString;
 
     S.DiagnoseUnsatisfiedConstraint(
-        static_cast<CNSInfo*>(DeductionFailure.Data)->Satisfaction);
+        static_cast<CNSInfo *>(DeductionFailure.Data)->Satisfaction);
     return;
   }
   case TemplateDeductionResult::TooManyArguments:
@@ -12552,20 +12443,20 @@ static void DiagnoseBadDeduction(Sema &S, NamedDecl *Found, Decl *Templated,
     // If this candidate was disabled by enable_if, say so.
     PartialDiagnosticAt *PDiag = DeductionFailure.getSFINAEDiagnostic();
     if (PDiag && PDiag->second.getDiagID() ==
-          diag::err_typename_nested_not_found_enable_if) {
+                     diag::err_typename_nested_not_found_enable_if) {
       // FIXME: Use the source range of the condition, and the fully-qualified
       //        name of the enable_if template. These are both present in PDiag.
       S.Diag(PDiag->first, diag::note_ovl_candidate_disabled_by_enable_if)
-        << "'enable_if'" << TemplateArgString;
+          << "'enable_if'" << TemplateArgString;
       return;
     }
 
     // We found a specific requirement that disabled the enable_if.
     if (PDiag && PDiag->second.getDiagID() ==
-        diag::err_typename_nested_not_found_requirement) {
+                     diag::err_typename_nested_not_found_requirement) {
       S.Diag(Templated->getLocation(),
              diag::note_ovl_candidate_disabled_by_requirement)
-        << PDiag->second.getStringArg(0) << TemplateArgString;
+          << PDiag->second.getStringArg(0) << TemplateArgString;
       return;
     }
 
@@ -12740,7 +12631,7 @@ static void DiagnoseBadTarget(Sema &S, OverloadCandidate *Cand) {
 static void DiagnoseFailedEnableIfAttr(Sema &S, OverloadCandidate *Cand) {
   assert(Cand->Function && "Candidate must be a function");
   FunctionDecl *Callee = Cand->Function;
-  EnableIfAttr *Attr = static_cast<EnableIfAttr*>(Cand->DeductionFailure.Data);
+  EnableIfAttr *Attr = static_cast<EnableIfAttr *>(Cand->DeductionFailure.Data);
 
   S.Diag(Callee->getLocation(),
          diag::note_ovl_candidate_disabled_by_function_cond_attr)
@@ -12776,8 +12667,7 @@ static void DiagnoseFailedExplicitSpec(Sema &S, OverloadCandidate *Cand) {
   if (FunctionDecl *Pattern = First->getTemplateInstantiationPattern())
     First = Pattern->getFirstDecl();
 
-  S.Diag(First->getLocation(),
-         diag::note_ovl_candidate_explicit)
+  S.Diag(First->getLocation(), diag::note_ovl_candidate_explicit)
       << Kind << (ES.getExpr() ? 1 : 0)
       << (ES.getExpr() ? ES.getExpr()->getSourceRange() : SourceRange());
 }
@@ -12838,8 +12728,7 @@ static void NoteImplicitDeductionGuide(Sema &S, FunctionDecl *Fn) {
 /// \param CtorDestAS Addr space of object being constructed (for ctor
 /// candidates only).
 static void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand,
-                                  unsigned NumArgs,
-                                  bool TakingCandidateAddress,
+                                  unsigned NumArgs, bool TakingCandidateAddress,
                                   LangAS CtorDestAS = LangAS::Default) {
   assert(Cand->Function && "Candidate must be a function");
   FunctionDecl *Fn = Cand->Function;
@@ -12898,12 +12787,11 @@ static void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand,
     return DiagnoseArityMismatch(S, Cand, NumArgs);
 
   case ovl_fail_bad_deduction:
-    return DiagnoseBadDeduction(S, Cand, NumArgs,
-                                TakingCandidateAddress);
+    return DiagnoseBadDeduction(S, Cand, NumArgs, TakingCandidateAddress);
 
   case ovl_fail_illegal_constructor: {
     S.Diag(Fn->getLocation(), diag::note_ovl_candidate_illegal_constructor)
-      << (Fn->getPrimaryTemplate() ? 1 : 0);
+        << (Fn->getPrimaryTemplate() ? 1 : 0);
     MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl);
     return;
   }
@@ -12950,8 +12838,8 @@ static void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand,
       return;
     S.Diag(Fn->getLocation(),
            diag::note_ovl_candidate_inherited_constructor_slice)
-      << (Fn->getPrimaryTemplate() ? 1 : 0)
-      << Fn->getParamDecl(0)->getType()->isRValueReferenceType();
+        << (Fn->getPrimaryTemplate() ? 1 : 0)
+        << Fn->getParamDecl(0)->getType()->isRValueReferenceType();
     MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl);
     return;
 
@@ -12996,11 +12884,11 @@ static void NoteSurrogateCandidate(Sema &S, OverloadCandidate *Cand) {
   bool isRValueReference = false;
   bool isPointer = false;
   if (const LValueReferenceType *FnTypeRef =
-        FnType->getAs<LValueReferenceType>()) {
+          FnType->getAs<LValueReferenceType>()) {
     FnType = FnTypeRef->getPointeeType();
     isLValueReference = true;
   } else if (const RValueReferenceType *FnTypeRef =
-               FnType->getAs<RValueReferenceType>()) {
+                 FnType->getAs<RValueReferenceType>()) {
     FnType = FnTypeRef->getPointeeType();
     isRValueReference = true;
   }
@@ -13011,9 +12899,12 @@ static void NoteSurrogateCandidate(Sema &S, OverloadCandidate *Cand) {
   // Desugar down to a function type.
   FnType = QualType(FnType->getAs<FunctionType>(), 0);
   // Reconstruct the pointer/reference as appropriate.
-  if (isPointer) FnType = S.Context.getPointerType(FnType);
-  if (isRValueReference) FnType = S.Context.getRValueReferenceType(FnType);
-  if (isLValueReference) FnType = S.Context.getLValueReferenceType(FnType);
+  if (isPointer)
+    FnType = S.Context.getPointerType(FnType);
+  if (isRValueReference)
+    FnType = S.Context.getRValueReferenceType(FnType);
+  if (isLValueReference)
+    FnType = S.Context.getLValueReferenceType(FnType);
 
   if (!Cand->Viable &&
       Cand->FailureKind == ovl_fail_constraints_not_satisfied) {
@@ -13051,8 +12942,10 @@ static void NoteBuiltinOperatorCandidate(Sema &S, StringRef Opc,
 static void NoteAmbiguousUserConversions(Sema &S, SourceLocation OpLoc,
                                          OverloadCandidate *Cand) {
   for (const ImplicitConversionSequence &ICS : Cand->Conversions) {
-    if (ICS.isBad()) break; // all meaningless after first invalid
-    if (!ICS.isAmbiguous()) continue;
+    if (ICS.isBad())
+      break; // all meaningless after first invalid
+    if (!ICS.isAmbiguous())
+      continue;
 
     ICS.DiagnoseAmbiguousConversion(
         S, OpLoc, S.PDiag(diag::note_ambiguous_type_conversion));
@@ -13135,14 +13028,15 @@ struct CompareOverloadCandidatesForDisplay {
     return static_cast<OverloadFailureKind>(C->FailureKind);
   }
 
-  bool operator()(const OverloadCandidate *L,
-                  const OverloadCandidate *R) {
+  bool operator()(const OverloadCandidate *L, const OverloadCandidate *R) {
     // Fast-path this check.
-    if (L == R) return false;
+    if (L == R)
+      return false;
 
     // Order first by viability.
     if (L->Viable) {
-      if (!R->Viable) return true;
+      if (!R->Viable)
+        return true;
 
       if (int Ord = CompareConversions(*L, *R))
         return Ord < 0;
@@ -13286,7 +13180,7 @@ struct CompareOverloadCandidatesForDisplay {
     return 0;
   }
 };
-}
+} // namespace
 
 /// CompleteNonViableCandidate - Normally, overload resolution only
 /// computes up to the first bad conversion. Produces the FixIt set if
@@ -13330,8 +13224,8 @@ CompleteNonViableCandidate(Sema &S, OverloadCandidate *Cand,
   bool Reversed = Cand->isReversed();
 
   if (Cand->IsSurrogate) {
-    QualType ConvType
-      = Cand->Surrogate->getConversionType().getNonReferenceType();
+    QualType ConvType =
+        Cand->Surrogate->getConversionType().getNonReferenceType();
     if (const PointerType *ConvPtrType = ConvType->getAs<PointerType>())
       ConvType = ConvPtrType->getPointeeType();
     ParamTypes = ConvType->castAs<FunctionProtoType>()->getParamTypes();
@@ -13369,12 +13263,11 @@ CompleteNonViableCandidate(Sema &S, OverloadCandidate *Cand,
         Cand->Conversions[ConvIdx].setAsIdentityConversion(
             Args[ArgIdx]->getType());
       else {
-        Cand->Conversions[ConvIdx] =
-            TryCopyInitialization(S, Args[ArgIdx], ParamTypes[ParamIdx],
-                                  SuppressUserConversions,
-                                  /*InOverloadResolution=*/true,
-                                  /*AllowObjCWritebackConversion=*/
-                                  S.getLangOpts().ObjCAutoRefCount);
+        Cand->Conversions[ConvIdx] = TryCopyInitialization(
+            S, Args[ArgIdx], ParamTypes[ParamIdx], SuppressUserConversions,
+            /*InOverloadResolution=*/true,
+            /*AllowObjCWritebackConversion=*/
+            S.getLangOpts().ObjCAutoRefCount);
         // Store the FixIt in the candidate if it exists.
         if (!Unfixable && Cand->Conversions[ConvIdx].isBad())
           Unfixable = !Cand->TryToFixBadConversion(ConvIdx, S);
@@ -13393,8 +13286,9 @@ SmallVector<OverloadCandidate *, 32> OverloadCandidateSet::CompleteCandidates(
 
   // Sort the candidates by viability and position.  Sorting directly would
   // be prohibitive, so we make a set of pointers and sort those.
-  SmallVector<OverloadCandidate*, 32> Cands;
-  if (OCD == OCD_AllCandidates) Cands.reserve(size());
+  SmallVector<OverloadCandidate *, 32> Cands;
+  if (OCD == OCD_AllCandidates)
+    Cands.reserve(size());
   for (iterator Cand = Candidates.begin(), LastCand = Candidates.end();
        Cand != LastCand; ++Cand) {
     if (!Filter(*Cand))
@@ -13568,7 +13462,7 @@ struct CompareTemplateSpecCandidatesForDisplay {
     return S.SourceMgr.isBeforeInTranslationUnit(LLoc, RLoc);
   }
 };
-}
+} // namespace
 
 /// Diagnose a template argument deduction failure.
 /// We are treating these failures as overload failures due to bad
@@ -13644,16 +13538,15 @@ void TemplateSpecCandidateSet::NoteCandidates(Sema &S, SourceLocation Loc) {
 QualType Sema::ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType) {
   QualType Ret = PossiblyAFunctionType;
   if (const PointerType *ToTypePtr =
-    PossiblyAFunctionType->getAs<PointerType>())
+          PossiblyAFunctionType->getAs<PointerType>())
     Ret = ToTypePtr->getPointeeType();
   else if (const ReferenceType *ToTypeRef =
-    PossiblyAFunctionType->getAs<ReferenceType>())
+               PossiblyAFunctionType->getAs<ReferenceType>())
     Ret = ToTypeRef->getPointeeType();
   else if (const MemberPointerType *MemTypePtr =
-    PossiblyAFunctionType->getAs<MemberPointerType>())
+               PossiblyAFunctionType->getAs<MemberPointerType>())
     Ret = MemTypePtr->getPointeeType();
-  Ret =
-    Context.getCanonicalType(Ret).getUnqualifiedType();
+  Ret = Context.getCanonicalType(Ret).getUnqualifiedType();
   return Ret;
 }
 
@@ -13676,14 +13569,14 @@ namespace {
 // A helper class to help with address of function resolution
 // - allows us to avoid passing around all those ugly parameters
 class AddressOfFunctionResolver {
-  Sema& S;
-  Expr* SourceExpr;
-  const QualType& TargetType;
+  Sema &S;
+  Expr *SourceExpr;
+  const QualType &TargetType;
   QualType TargetFunctionType; // Extracted function type from target type
 
   bool Complain;
-  //DeclAccessPair& ResultFunctionAccessPair;
-  ASTContext& Context;
+  // DeclAccessPair& ResultFunctionAccessPair;
+  ASTContext &Context;
 
   bool TargetTypeIsNonStaticMemberFunction;
   bool FoundNonTemplateFunction;
@@ -13693,7 +13586,7 @@ class AddressOfFunctionResolver {
   OverloadExpr::FindResult OvlExprInfo;
   OverloadExpr *OvlExpr;
   TemplateArgumentListInfo OvlExplicitTemplateArgs;
-  SmallVector<std::pair<DeclAccessPair, FunctionDecl*>, 4> Matches;
+  SmallVector<std::pair<DeclAccessPair, FunctionDecl *>, 4> Matches;
   TemplateSpecCandidateSet FailedCandidates;
 
 public:
@@ -13704,8 +13597,7 @@ class AddressOfFunctionResolver {
         TargetTypeIsNonStaticMemberFunction(
             !!TargetType->getAs<MemberPointerType>()),
         FoundNonTemplateFunction(false),
-        StaticMemberFunctionFromBoundPointer(false),
-        HasComplained(false),
+        StaticMemberFunctionFromBoundPointer(false), HasComplained(false),
         OvlExprInfo(OverloadExpr::find(SourceExpr)),
         OvlExpr(OvlExprInfo.Expression),
         FailedCandidates(OvlExpr->getNameLoc(), /*ForTakingAddress=*/true) {
@@ -13782,15 +13674,16 @@ class AddressOfFunctionResolver {
     // Same algorithm as overload resolution -- one pass to pick the "best",
     // another pass to be sure that nothing is better than the best.
     auto Best = Matches.begin();
-    for (auto I = Matches.begin()+1, E = Matches.end(); I != E; ++I)
+    for (auto I = Matches.begin() + 1, E = Matches.end(); I != E; ++I)
       if (isBetterCandidate(I->second, Best->second))
         Best = I;
 
     const FunctionDecl *BestFn = Best->second;
-    auto IsBestOrInferiorToBest = [this, BestFn](
-        const std::pair<DeclAccessPair, FunctionDecl *> &Pair) {
-      return BestFn == Pair.second || isBetterCandidate(BestFn, Pair.second);
-    };
+    auto IsBestOrInferiorToBest =
+        [this, BestFn](const std::pair<DeclAccessPair, FunctionDecl *> &Pair) {
+          return BestFn == Pair.second ||
+                 isBetterCandidate(BestFn, Pair.second);
+        };
 
     // Note: We explicitly leave Matches unmodified if there isn't a clear best
     // option, so we can potentially give the user a better error
@@ -13815,18 +13708,17 @@ class AddressOfFunctionResolver {
   }
 
   // return true if any matching specializations were found
-  bool AddMatchingTemplateFunction(FunctionTemplateDecl* FunctionTemplate,
-                                   const DeclAccessPair& CurAccessFunPair) {
-    if (CXXMethodDecl *Method
-              = dyn_cast<CXXMethodDecl>(FunctionTemplate->getTemplatedDecl())) {
+  bool AddMatchingTemplateFunction(FunctionTemplateDecl *FunctionTemplate,
+                                   const DeclAccessPair &CurAccessFunPair) {
+    if (CXXMethodDecl *Method =
+            dyn_cast<CXXMethodDecl>(FunctionTemplate->getTemplatedDecl())) {
       // Skip non-static function templates when converting to pointer, and
       // static when converting to member pointer.
       bool CanConvertToFunctionPointer =
           Method->isStatic() || Method->isExplicitObjectMemberFunction();
       if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
         return false;
-    }
-    else if (TargetTypeIsNonStaticMemberFunction)
+    } else if (TargetTypeIsNonStaticMemberFunction)
       return false;
 
     // C++ [over.over]p2:
@@ -13842,9 +13734,9 @@ class AddressOfFunctionResolver {
             Specialization, Info, /*IsAddressOfFunction*/ true);
         Result != TemplateDeductionResult::Success) {
       // Make a note of the failed deduction for diagnostics.
-      FailedCandidates.addCandidate()
-          .set(CurAccessFunPair, FunctionTemplate->getTemplatedDecl(),
-               MakeDeductionFailureInfo(Context, Result, Info));
+      FailedCandidates.addCandidate().set(
+          CurAccessFunPair, FunctionTemplate->getTemplatedDecl(),
+          MakeDeductionFailureInfo(Context, Result, Info));
       return false;
     }
 
@@ -13852,8 +13744,8 @@ class AddressOfFunctionResolver {
     // compatible pointer-to-function arguments that would be adjusted by ICS.
     // This function template specicalization works.
     assert(S.isSameOrCompatibleFunctionType(
-              Context.getCanonicalType(Specialization->getType()),
-              Context.getCanonicalType(TargetFunctionType)));
+        Context.getCanonicalType(Specialization->getType()),
+        Context.getCanonicalType(TargetFunctionType)));
 
     if (!S.checkAddressOfFunctionIsAvailable(Specialization))
       return false;
@@ -13862,8 +13754,8 @@ class AddressOfFunctionResolver {
     return true;
   }
 
-  bool AddMatchingNonTemplateFunction(NamedDecl* Fn,
-                                      const DeclAccessPair& CurAccessFunPair) {
+  bool AddMatchingNonTemplateFunction(NamedDecl *Fn,
+                                      const DeclAccessPair &CurAccessFunPair) {
     if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Fn)) {
       // Skip non-static functions when converting to pointer, and static
       // when converting to member pointer.
@@ -13871,8 +13763,7 @@ class AddressOfFunctionResolver {
           Method->isStatic() || Method->isExplicitObjectMemberFunction();
       if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
         return false;
-    }
-    else if (TargetTypeIsNonStaticMemberFunction)
+    } else if (TargetTypeIsNonStaticMemberFunction)
       return false;
 
     if (FunctionDecl *FunDecl = dyn_cast<FunctionDecl>(Fn)) {
@@ -13935,8 +13826,8 @@ class AddressOfFunctionResolver {
       //   Nonstatic member functions match targets of
       //   type "pointer-to-member-function."
       // Note that according to DR 247, the containing class does not matter.
-      if (FunctionTemplateDecl *FunctionTemplate
-                                        = dyn_cast<FunctionTemplateDecl>(Fn)) {
+      if (FunctionTemplateDecl *FunctionTemplate =
+              dyn_cast<FunctionTemplateDecl>(Fn)) {
         if (AddMatchingTemplateFunction(FunctionTemplate, I.getPair()))
           Ret = true;
       }
@@ -13988,7 +13879,7 @@ class AddressOfFunctionResolver {
   void EliminateAllTemplateMatches() {
     //   [...] any function template specializations in the set are
     //   eliminated if the set also contains a non-template function, [...]
-    for (unsigned I = 0, N = Matches.size(); I != N; ) {
+    for (unsigned I = 0, N = Matches.size(); I != N;) {
       if (Matches[I].second->getPrimaryTemplate() == nullptr)
         ++I;
       else {
@@ -14057,14 +13948,14 @@ class AddressOfFunctionResolver {
 
   bool IsInvalidFormOfPointerToMemberFunction() const {
     return TargetTypeIsNonStaticMemberFunction &&
-      !OvlExprInfo.HasFormOfMemberPointer;
+           !OvlExprInfo.HasFormOfMemberPointer;
   }
 
   void ComplainIsInvalidFormOfPointerToMemberFunction() const {
-      // TODO: Should we condition this on whether any functions might
-      // have matched, or is it more appropriate to do that in callers?
-      // TODO: a fixit wouldn't hurt.
-      S.Diag(OvlExpr->getNameLoc(), diag::err_addr_ovl_no_qualifier)
+    // TODO: Should we condition this on whether any functions might
+    // have matched, or is it more appropriate to do that in callers?
+    // TODO: a fixit wouldn't hurt.
+    S.Diag(OvlExpr->getNameLoc(), diag::err_addr_ovl_no_qualifier)
         << TargetType << OvlExpr->getSourceRange();
   }
 
@@ -14095,24 +13986,23 @@ class AddressOfFunctionResolver {
 
   int getNumMatches() const { return Matches.size(); }
 
-  FunctionDecl* getMatchingFunctionDecl() const {
-    if (Matches.size() != 1) return nullptr;
+  FunctionDecl *getMatchingFunctionDecl() const {
+    if (Matches.size() != 1)
+      return nullptr;
     return Matches[0].second;
   }
 
-  const DeclAccessPair* getMatchingFunctionAccessPair() const {
-    if (Matches.size() != 1) return nullptr;
+  const DeclAccessPair *getMatchingFunctionAccessPair() const {
+    if (Matches.size() != 1)
+      return nullptr;
     return &Matches[0].first;
   }
 };
-}
+} // namespace
 
-FunctionDecl *
-Sema::ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr,
-                                         QualType TargetType,
-                                         bool Complain,
-                                         DeclAccessPair &FoundResult,
-                                         bool *pHadMultipleCandidates) {
+FunctionDecl *Sema::ResolveAddressOfOverloadedFunction(
+    Expr *AddressOfExpr, QualType TargetType, bool Complain,
+    DeclAccessPair &FoundResult, bool *pHadMultipleCandidates) {
   assert(AddressOfExpr->getType() == Context.OverloadTy);
 
   AddressOfFunctionResolver Resolver(*this, AddressOfExpr, TargetType,
@@ -14125,8 +14015,7 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr,
       Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
     else
       Resolver.ComplainNoMatchesFound();
-  }
-  else if (NumMatches > 1 && ShouldComplain)
+  } else if (NumMatches > 1 && ShouldComplain)
     Resolver.ComplainMultipleMatchesFound();
   else if (NumMatches == 1) {
     Fn = Resolver.getMatchingFunctionDecl();
@@ -14287,8 +14176,8 @@ FunctionDecl *Sema::ResolveSingleFunctionTemplateSpecialization(
   // Look through all of the overloaded functions, searching for one
   // whose type matches exactly.
   FunctionDecl *Matched = nullptr;
-  for (UnresolvedSetIterator I = ovl->decls_begin(),
-         E = ovl->decls_end(); I != E; ++I) {
+  for (UnresolvedSetIterator I = ovl->decls_begin(), E = ovl->decls_end();
+       I != E; ++I) {
     // C++0x [temp.arg.explicit]p3:
     //   [...] In contexts where deduction is done and fails, or in contexts
     //   where deduction is not done, if a template argument list is
@@ -14333,15 +14222,15 @@ FunctionDecl *Sema::ResolveSingleFunctionTemplateSpecialization(
         continue;
       // Multiple matches; we can't resolve to a single declaration.
       if (Complain) {
-        Diag(ovl->getExprLoc(), diag::err_addr_ovl_ambiguous)
-          << ovl->getName();
+        Diag(ovl->getExprLoc(), diag::err_addr_ovl_ambiguous) << ovl->getName();
         NoteAllOverloadCandidates(ovl);
       }
       return nullptr;
     }
 
     Matched = Specialization;
-    if (FoundResult) *FoundResult = I.getPair();
+    if (FoundResult)
+      *FoundResult = I.getPair();
   }
 
   if (Matched &&
@@ -14362,7 +14251,7 @@ bool Sema::ResolveAndFixSingleFunctionTemplateSpecialization(
   DeclAccessPair found;
   ExprResult SingleFunctionExpression;
   if (FunctionDecl *fn = ResolveSingleFunctionTemplateSpecialization(
-                           ovl.Expression, /*complain*/ false, &found)) {
+          ovl.Expression, /*complain*/ false, &found)) {
     if (DiagnoseUseOfDecl(fn, SrcExpr.get()->getBeginLoc())) {
       SrcExpr = ExprError();
       return true;
@@ -14372,14 +14261,13 @@ bool Sema::ResolveAndFixSingleFunctionTemplateSpecialization(
     // resolving a form that's permitted to be a pointer to member.
     // Otherwise we'll end up making a bound member expression, which
     // is illegal in all the contexts we resolve like this.
-    if (!ovl.HasFormOfMemberPointer &&
-        isa<CXXMethodDecl>(fn) &&
+    if (!ovl.HasFormOfMemberPointer && isa<CXXMethodDecl>(fn) &&
         cast<CXXMethodDecl>(fn)->isInstance()) {
-      if (!complain) return false;
+      if (!complain)
+        return false;
 
-      Diag(ovl.Expression->getExprLoc(),
-           diag::err_bound_member_function)
-        << 0 << ovl.Expression->getSourceRange();
+      Diag(ovl.Expression->getExprLoc(), diag::err_bound_member_function)
+          << 0 << ovl.Expression->getSourceRange();
 
       // TODO: I believe we only end up here if there's a mix of
       // static and non-static candidates (otherwise the expression
@@ -14397,7 +14285,7 @@ bool Sema::ResolveAndFixSingleFunctionTemplateSpecialization(
     // If desired, do function-to-pointer decay.
     if (doFunctionPointerConversion) {
       SingleFunctionExpression =
-        DefaultFunctionArrayLvalueConversion(SingleFunctionExpression.get());
+          DefaultFunctionArrayLvalueConversion(SingleFunctionExpression.get());
       if (SingleFunctionExpression.isInvalid()) {
         SrcExpr = ExprError();
         return true;
@@ -14408,10 +14296,9 @@ bool Sema::ResolveAndFixSingleFunctionTemplateSpecialization(
   if (!SingleFunctionExpression.isUsable()) {
     if (complain) {
       Diag(OpRangeForComplaining.getBegin(), DiagIDForComplaining)
-        << ovl.Expression->getName()
-        << DestTypeForComplaining
-        << OpRangeForComplaining
-        << ovl.Expression->getQualifierLoc().getSourceRange();
+          << ovl.Expression->getName() << DestTypeForComplaining
+          << OpRangeForComplaining
+          << ovl.Expression->getQualifierLoc().getSourceRange();
       NoteAllOverloadCandidates(SrcExpr.get());
 
       SrcExpr = ExprError();
@@ -14426,13 +14313,12 @@ bool Sema::ResolveAndFixSingleFunctionTemplateSpecialization(
 }
 
 /// Add a single candidate to the overload set.
-static void AddOverloadedCallCandidate(Sema &S,
-                                       DeclAccessPair FoundDecl,
-                                 TemplateArgumentListInfo *ExplicitTemplateArgs,
-                                       ArrayRef<Expr *> Args,
-                                       OverloadCandidateSet &CandidateSet,
-                                       bool PartialOverloading,
-                                       bool KnownValid) {
+static void
+AddOverloadedCallCandidate(Sema &S, DeclAccessPair FoundDecl,
+                           TemplateArgumentListInfo *ExplicitTemplateArgs,
+                           ArrayRef<Expr *> Args,
+                           OverloadCandidateSet &CandidateSet,
+                           bool PartialOverloading, bool KnownValid) {
   NamedDecl *Callee = FoundDecl.getDecl();
   if (isa<UsingShadowDecl>(Callee))
     Callee = cast<UsingShadowDecl>(Callee)->getTargetDecl();
@@ -14452,12 +14338,11 @@ static void AddOverloadedCallCandidate(Sema &S,
     return;
   }
 
-  if (FunctionTemplateDecl *FuncTemplate
-      = dyn_cast<FunctionTemplateDecl>(Callee)) {
-    S.AddTemplateOverloadCandidate(FuncTemplate, FoundDecl,
-                                   ExplicitTemplateArgs, Args, CandidateSet,
-                                   /*SuppressUserConversions=*/false,
-                                   PartialOverloading);
+  if (FunctionTemplateDecl *FuncTemplate =
+          dyn_cast<FunctionTemplateDecl>(Callee)) {
+    S.AddTemplateOverloadCandidate(
+        FuncTemplate, FoundDecl, ExplicitTemplateArgs, Args, CandidateSet,
+        /*SuppressUserConversions=*/false, PartialOverloading);
     return;
   }
 
@@ -14489,7 +14374,8 @@ void Sema::AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
 
   if (ULE->requiresADL()) {
     for (UnresolvedLookupExpr::decls_iterator I = ULE->decls_begin(),
-           E = ULE->decls_end(); I != E; ++I) {
+                                              E = ULE->decls_end();
+         I != E; ++I) {
       assert(!(*I)->getDeclContext()->isRecord());
       assert(isa<UsingShadowDecl>(*I) ||
              !(*I)->getDeclContext()->isFunctionOrMethod());
@@ -14507,7 +14393,8 @@ void Sema::AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
   }
 
   for (UnresolvedLookupExpr::decls_iterator I = ULE->decls_begin(),
-         E = ULE->decls_end(); I != E; ++I)
+                                            E = ULE->decls_end();
+       I != E; ++I)
     AddOverloadedCallCandidate(*this, I.getPair(), ExplicitTemplateArgs, Args,
                                CandidateSet, PartialOverloading,
                                /*KnownValid*/ true);
@@ -14530,8 +14417,10 @@ void Sema::AddOverloadedCallCandidates(
 /// a different namespace.
 static bool canBeDeclaredInNamespace(const DeclarationName &Name) {
   switch (Name.getCXXOverloadedOperator()) {
-  case OO_New: case OO_Array_New:
-  case OO_Delete: case OO_Array_Delete:
+  case OO_New:
+  case OO_Array_New:
+  case OO_Delete:
+  case OO_Array_Delete:
     return false;
 
   default:
@@ -14595,15 +14484,15 @@ static bool DiagnoseTwoPhaseLookup(
       // declaring the function there instead.
       Sema::AssociatedNamespaceSet AssociatedNamespaces;
       Sema::AssociatedClassSet AssociatedClasses;
-      SemaRef.FindAssociatedClassesAndNamespaces(FnLoc, Args,
-                                                 AssociatedNamespaces,
-                                                 AssociatedClasses);
+      SemaRef.FindAssociatedClassesAndNamespaces(
+          FnLoc, Args, AssociatedNamespaces, AssociatedClasses);
       Sema::AssociatedNamespaceSet SuggestedNamespaces;
       if (canBeDeclaredInNamespace(R.getLookupName())) {
         DeclContext *Std = SemaRef.getStdNamespace();
         for (Sema::AssociatedNamespaceSet::iterator
-               it = AssociatedNamespaces.begin(),
-               end = AssociatedNamespaces.end(); it != end; ++it) {
+                 it = AssociatedNamespaces.begin(),
+                 end = AssociatedNamespaces.end();
+             it != end; ++it) {
           // Never suggest declaring a function within namespace 'std'.
           if (Std && Std->Encloses(*it))
             continue;
@@ -14620,22 +14509,22 @@ static bool DiagnoseTwoPhaseLookup(
       }
 
       SemaRef.Diag(R.getNameLoc(), diag::err_not_found_by_two_phase_lookup)
-        << R.getLookupName();
+          << R.getLookupName();
       if (SuggestedNamespaces.empty()) {
         SemaRef.Diag(Best->Function->getLocation(),
                      diag::note_not_found_by_two_phase_lookup)
-          << R.getLookupName() << 0;
+            << R.getLookupName() << 0;
       } else if (SuggestedNamespaces.size() == 1) {
         SemaRef.Diag(Best->Function->getLocation(),
                      diag::note_not_found_by_two_phase_lookup)
-          << R.getLookupName() << 1 << *SuggestedNamespaces.begin();
+            << R.getLookupName() << 1 << *SuggestedNamespaces.begin();
       } else {
         // FIXME: It would be useful to list the associated namespaces here,
         // but the diagnostics infrastructure doesn't provide a way to produce
         // a localized representation of a list of items.
         SemaRef.Diag(Best->Function->getLocation(),
                      diag::note_not_found_by_two_phase_lookup)
-          << R.getLookupName() << 2;
+            << R.getLookupName() << 2;
       }
 
       // Try to recover by calling this function.
@@ -14653,12 +14542,12 @@ static bool DiagnoseTwoPhaseLookup(
 /// was defined.
 ///
 /// Returns true if a viable candidate was found and a diagnostic was issued.
-static bool
-DiagnoseTwoPhaseOperatorLookup(Sema &SemaRef, OverloadedOperatorKind Op,
-                               SourceLocation OpLoc,
-                               ArrayRef<Expr *> Args) {
+static bool DiagnoseTwoPhaseOperatorLookup(Sema &SemaRef,
+                                           OverloadedOperatorKind Op,
+                                           SourceLocation OpLoc,
+                                           ArrayRef<Expr *> Args) {
   DeclarationName OpName =
-    SemaRef.Context.DeclarationNames.getCXXOperatorName(Op);
+      SemaRef.Context.DeclarationNames.getCXXOperatorName(Op);
   LookupResult R(SemaRef, OpName, OpLoc, Sema::LookupOperatorName);
   return DiagnoseTwoPhaseLookup(SemaRef, OpLoc, CXXScopeSpec(), R,
                                 OverloadCandidateSet::CSK_Operator,
@@ -14678,7 +14567,7 @@ class BuildRecoveryCallExprRAII {
 
   ~BuildRecoveryCallExprRAII() { SemaRef.IsBuildingRecoveryCallExpr = false; }
 };
-}
+} // namespace
 
 /// Attempts to recover from a call where no functions were found.
 ///
@@ -14689,10 +14578,8 @@ class BuildRecoveryCallExprRAII {
 ///    expected to diagnose as appropriate.
 static ExprResult
 BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
-                      UnresolvedLookupExpr *ULE,
-                      SourceLocation LParenLoc,
-                      MutableArrayRef<Expr *> Args,
-                      SourceLocation RParenLoc,
+                      UnresolvedLookupExpr *ULE, SourceLocation LParenLoc,
+                      MutableArrayRef<Expr *> Args, SourceLocation RParenLoc,
                       bool EmptyLookup, bool AllowTypoCorrection) {
   // Do not try to recover if it is already building a recovery call.
   // This stops infinite loops for template instantiations like
@@ -14781,10 +14668,8 @@ BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
                                RParenLoc);
 }
 
-bool Sema::buildOverloadedCallSet(Scope *S, Expr *Fn,
-                                  UnresolvedLookupExpr *ULE,
-                                  MultiExprArg Args,
-                                  SourceLocation RParenLoc,
+bool Sema::buildOverloadedCallSet(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE,
+                                  MultiExprArg Args, SourceLocation RParenLoc,
                                   OverloadCandidateSet *CandidateSet,
                                   ExprResult *Result) {
 #ifndef NDEBUG
@@ -14816,8 +14701,8 @@ bool Sema::buildOverloadedCallSet(Scope *S, Expr *Fn,
   // functions, including those from argument-dependent lookup.
   AddOverloadedCallCandidates(ULE, Args, *CandidateSet);
 
-  if (getLangOpts().MSVCCompat &&
-      CurContext->isDependentContext() && !isSFINAEContext() &&
+  if (getLangOpts().MSVCCompat && CurContext->isDependentContext() &&
+      !isSFINAEContext() &&
       (isa<FunctionDecl>(CurContext) || isa<CXXRecordDecl>(CurContext))) {
 
     OverloadCandidateSet::iterator Best;
@@ -14890,16 +14775,12 @@ static QualType chooseRecoveryType(OverloadCandidateSet &CS,
 /// FinishOverloadedCallExpr - given an OverloadCandidateSet, builds and returns
 /// the completed call expression. If overload resolution fails, emits
 /// diagnostics and returns ExprError()
-static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
-                                           UnresolvedLookupExpr *ULE,
-                                           SourceLocation LParenLoc,
-                                           MultiExprArg Args,
-                                           SourceLocation RParenLoc,
-                                           Expr *ExecConfig,
-                                           OverloadCandidateSet *CandidateSet,
-                                           OverloadCandidateSet::iterator *Best,
-                                           OverloadingResult OverloadResult,
-                                           bool AllowTypoCorrection) {
+static ExprResult FinishOverloadedCallExpr(
+    Sema &SemaRef, Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE,
+    SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc,
+    Expr *ExecConfig, OverloadCandidateSet *CandidateSet,
+    OverloadCandidateSet::iterator *Best, OverloadingResult OverloadResult,
+    bool AllowTypoCorrection) {
   switch (OverloadResult) {
   case OR_Success: {
     FunctionDecl *FDecl = (*Best)->Function;
@@ -14934,10 +14815,9 @@ static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
 
     // Try to recover by looking for viable functions which the user might
     // have meant to call.
-    ExprResult Recovery = BuildRecoveryCallExpr(SemaRef, S, Fn, ULE, LParenLoc,
-                                                Args, RParenLoc,
-                                                CandidateSet->empty(),
-                                                AllowTypoCorrection);
+    ExprResult Recovery =
+        BuildRecoveryCallExpr(SemaRef, S, Fn, ULE, LParenLoc, Args, RParenLoc,
+                              CandidateSet->empty(), AllowTypoCorrection);
     if (Recovery.isInvalid() || Recovery.isUsable())
       return Recovery;
 
@@ -14949,9 +14829,8 @@ static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
         continue;
       if (auto *DRE = dyn_cast<DeclRefExpr>(Arg->IgnoreParenImpCasts())) {
         auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl());
-        if (FD &&
-            !SemaRef.checkAddressOfFunctionIsAvailable(FD, /*Complain=*/true,
-                                                       Arg->getExprLoc()))
+        if (FD && !SemaRef.checkAddressOfFunctionIsAvailable(
+                      FD, /*Complain=*/true, Arg->getExprLoc()))
           return ExprError();
       }
     }
@@ -15010,14 +14889,10 @@ static void markUnaddressableCandidatesUnviable(Sema &S,
   }
 }
 
-ExprResult Sema::BuildOverloadedCallExpr(Scope *S, Expr *Fn,
-                                         UnresolvedLookupExpr *ULE,
-                                         SourceLocation LParenLoc,
-                                         MultiExprArg Args,
-                                         SourceLocation RParenLoc,
-                                         Expr *ExecConfig,
-                                         bool AllowTypoCorrection,
-                                         bool CalleesAddressIsTaken) {
+ExprResult Sema::BuildOverloadedCallExpr(
+    Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc,
+    MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig,
+    bool AllowTypoCorrection, bool CalleesAddressIsTaken) {
 
   OverloadCandidateSet::CandidateSetKind CSK =
       CalleesAddressIsTaken ? OverloadCandidateSet::CSK_AddressOfOverloadSet
@@ -15182,10 +15057,10 @@ ExprResult Sema::BuildCXXMemberCallExpr(Expr *E, NamedDecl *FoundDecl,
   return CheckForImmediateInvocation(CE, CE->getDirectCallee());
 }
 
-ExprResult
-Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
-                              const UnresolvedSetImpl &Fns,
-                              Expr *Input, bool PerformADL) {
+ExprResult Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc,
+                                         UnaryOperatorKind Opc,
+                                         const UnresolvedSetImpl &Fns,
+                                         Expr *Input, bool PerformADL) {
   OverloadedOperatorKind Op = UnaryOperator::getOverloadedOperator(Opc);
   assert(Op != OO_None && "Invalid opcode for overloaded unary operator");
   DeclarationName OpName = Context.DeclarationNames.getCXXOperatorName(Op);
@@ -15195,7 +15070,7 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
   if (checkPlaceholderForOverload(*this, Input))
     return ExprError();
 
-  Expr *Args[2] = { Input, nullptr };
+  Expr *Args[2] = {Input, nullptr};
   unsigned NumArgs = 1;
 
   // For post-increment and post-decrement, add the implicit '0' as
@@ -15203,8 +15078,8 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
   // post-decrement.
   if (Opc == UO_PostInc || Opc == UO_PostDec) {
     llvm::APSInt Zero(Context.getTypeSize(Context.IntTy), false);
-    Args[1] = IntegerLiteral::Create(Context, Zero, Context.IntTy,
-                                     SourceLocation());
+    Args[1] =
+        IntegerLiteral::Create(Context, Zero, Context.IntTy, SourceLocation());
     NumArgs = 2;
   }
 
@@ -15245,7 +15120,7 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
   // Add candidates from ADL.
   if (PerformADL) {
     AddArgumentDependentLookupCandidates(OpName, OpLoc, ArgsArray,
-                                         /*ExplicitTemplateArgs*/nullptr,
+                                         /*ExplicitTemplateArgs*/ nullptr,
                                          CandidateSet);
   }
 
@@ -15281,21 +15156,18 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
         Base = Input = InputInit.get();
       } else {
         // Convert the arguments.
-        ExprResult InputInit
-          = PerformCopyInitialization(InitializedEntity::InitializeParameter(
-                                                      Context,
-                                                      FnDecl->getParamDecl(0)),
-                                      SourceLocation(),
-                                      Input);
+        ExprResult InputInit =
+            PerformCopyInitialization(InitializedEntity::InitializeParameter(
+                                          Context, FnDecl->getParamDecl(0)),
+                                      SourceLocation(), Input);
         if (InputInit.isInvalid())
           return ExprError();
         Input = InputInit.get();
       }
 
       // Build the actual expression node.
-      ExprResult FnExpr = CreateFunctionRefExpr(*this, FnDecl, Best->FoundDecl,
-                                                Base, HadMultipleCandidates,
-                                                OpLoc);
+      ExprResult FnExpr = CreateFunctionRefExpr(
+          *this, FnDecl, Best->FoundDecl, Base, HadMultipleCandidates, OpLoc);
       if (FnExpr.isInvalid())
         return ExprError();
 
@@ -15346,10 +15218,10 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
 
   case OR_Ambiguous:
     CandidateSet.NoteCandidates(
-        PartialDiagnosticAt(OpLoc,
-                            PDiag(diag::err_ovl_ambiguous_oper_unary)
-                                << UnaryOperator::getOpcodeStr(Opc)
-                                << Input->getType() << Input->getSourceRange()),
+        PartialDiagnosticAt(OpLoc, PDiag(diag::err_ovl_ambiguous_oper_unary)
+                                       << UnaryOperator::getOpcodeStr(Opc)
+                                       << Input->getType()
+                                       << Input->getSourceRange()),
         *this, OCD_AmbiguousCandidates, ArgsArray,
         UnaryOperator::getOpcodeStr(Opc), OpLoc);
     return ExprError();
@@ -15454,8 +15326,8 @@ ExprResult Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
                                        Expr *RHS, bool PerformADL,
                                        bool AllowRewrittenCandidates,
                                        FunctionDecl *DefaultedFn) {
-  Expr *Args[2] = { LHS, RHS };
-  LHS=RHS=nullptr; // Please use only Args instead of LHS/RHS couple
+  Expr *Args[2] = {LHS, RHS};
+  LHS = RHS = nullptr; // Please use only Args instead of LHS/RHS couple
 
   if (!getLangOpts().CPlusPlus20)
     AllowRewrittenCandidates = false;
@@ -15541,374 +15413,369 @@ ExprResult Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
   // Perform overload resolution.
   OverloadCandidateSet::iterator Best;
   switch (CandidateSet.BestViableFunction(*this, OpLoc, Best)) {
-    case OR_Success: {
-      // We found a built-in operator or an overloaded operator.
-      FunctionDecl *FnDecl = Best->Function;
+  case OR_Success: {
+    // We found a built-in operator or an overloaded operator.
+    FunctionDecl *FnDecl = Best->Function;
 
-      bool IsReversed = Best->isReversed();
-      if (IsReversed)
-        std::swap(Args[0], Args[1]);
+    bool IsReversed = Best->isReversed();
+    if (IsReversed)
+      std::swap(Args[0], Args[1]);
 
-      if (FnDecl) {
+    if (FnDecl) {
 
-        if (FnDecl->isInvalidDecl())
-          return ExprError();
+      if (FnDecl->isInvalidDecl())
+        return ExprError();
 
-        Expr *Base = nullptr;
-        // We matched an overloaded operator. Build a call to that
-        // operator.
-
-        OverloadedOperatorKind ChosenOp =
-            FnDecl->getDeclName().getCXXOverloadedOperator();
-
-        // C++2a [over.match.oper]p9:
-        //   If a rewritten operator== candidate is selected by overload
-        //   resolution for an operator@, its return type shall be cv bool
-        if (Best->RewriteKind && ChosenOp == OO_EqualEqual &&
-            !FnDecl->getReturnType()->isBooleanType()) {
-          bool IsExtension =
-              FnDecl->getReturnType()->isIntegralOrUnscopedEnumerationType();
-          Diag(OpLoc, IsExtension ? diag::ext_ovl_rewrite_equalequal_not_bool
-                                  : diag::err_ovl_rewrite_equalequal_not_bool)
-              << FnDecl->getReturnType() << BinaryOperator::getOpcodeStr(Opc)
-              << Args[0]->getSourceRange() << Args[1]->getSourceRange();
-          Diag(FnDecl->getLocation(), diag::note_declared_at);
-          if (!IsExtension)
-            return ExprError();
-        }
+      Expr *Base = nullptr;
+      // We matched an overloaded operator. Build a call to that
+      // operator.
 
-        if (AllowRewrittenCandidates && !IsReversed &&
-            CandidateSet.getRewriteInfo().isReversible()) {
-          // We could have reversed this operator, but didn't. Check if some
-          // reversed form was a viable candidate, and if so, if it had a
-          // better conversion for either parameter. If so, this call is
-          // formally ambiguous, and allowing it is an extension.
-          llvm::SmallVector<FunctionDecl*, 4> AmbiguousWith;
-          for (OverloadCandidate &Cand : CandidateSet) {
-            if (Cand.Viable && Cand.Function && Cand.isReversed() &&
-                allowAmbiguity(Context, Cand.Function, FnDecl)) {
-              for (unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
-                if (CompareImplicitConversionSequences(
-                        *this, OpLoc, Cand.Conversions[ArgIdx],
-                        Best->Conversions[ArgIdx]) ==
-                    ImplicitConversionSequence::Better) {
-                  AmbiguousWith.push_back(Cand.Function);
-                  break;
-                }
-              }
-            }
-          }
+      OverloadedOperatorKind ChosenOp =
+          FnDecl->getDeclName().getCXXOverloadedOperator();
+
+      // C++2a [over.match.oper]p9:
+      //   If a rewritten operator== candidate is selected by overload
+      //   resolution for an operator@, its return type shall be cv bool
+      if (Best->RewriteKind && ChosenOp == OO_EqualEqual &&
+          !FnDecl->getReturnType()->isBooleanType()) {
+        bool IsExtension =
+            FnDecl->getReturnType()->isIntegralOrUnscopedEnumerationType();
+        Diag(OpLoc, IsExtension ? diag::ext_ovl_rewrite_equalequal_not_bool
+                                : diag::err_ovl_rewrite_equalequal_not_bool)
+            << FnDecl->getReturnType() << BinaryOperator::getOpcodeStr(Opc)
+            << Args[0]->getSourceRange() << Args[1]->getSourceRange();
+        Diag(FnDecl->getLocation(), diag::note_declared_at);
+        if (!IsExtension)
+          return ExprError();
+      }
 
-          if (!AmbiguousWith.empty()) {
-            bool AmbiguousWithSelf =
-                AmbiguousWith.size() == 1 &&
-                declaresSameEntity(AmbiguousWith.front(), FnDecl);
-            Diag(OpLoc, diag::ext_ovl_ambiguous_oper_binary_reversed)
-                << BinaryOperator::getOpcodeStr(Opc)
-                << Args[0]->getType() << Args[1]->getType() << AmbiguousWithSelf
-                << Args[0]->getSourceRange() << Args[1]->getSourceRange();
-            if (AmbiguousWithSelf) {
-              Diag(FnDecl->getLocation(),
-                   diag::note_ovl_ambiguous_oper_binary_reversed_self);
-              // Mark member== const or provide matching != to disallow reversed
-              // args. Eg.
-              // struct S { bool operator==(const S&); };
-              // S()==S();
-              if (auto *MD = dyn_cast<CXXMethodDecl>(FnDecl))
-                if (Op == OverloadedOperatorKind::OO_EqualEqual &&
-                    !MD->isConst() &&
-                    !MD->hasCXXExplicitFunctionObjectParameter() &&
-                    Context.hasSameUnqualifiedType(
-                        MD->getFunctionObjectParameterType(),
-                        MD->getParamDecl(0)->getType().getNonReferenceType()) &&
-                    Context.hasSameUnqualifiedType(
-                        MD->getFunctionObjectParameterType(),
-                        Args[0]->getType()) &&
-                    Context.hasSameUnqualifiedType(
-                        MD->getFunctionObjectParameterType(),
-                        Args[1]->getType()))
-                  Diag(FnDecl->getLocation(),
-                       diag::note_ovl_ambiguous_eqeq_reversed_self_non_const);
-            } else {
-              Diag(FnDecl->getLocation(),
-                   diag::note_ovl_ambiguous_oper_binary_selected_candidate);
-              for (auto *F : AmbiguousWith)
-                Diag(F->getLocation(),
-                     diag::note_ovl_ambiguous_oper_binary_reversed_candidate);
+      if (AllowRewrittenCandidates && !IsReversed &&
+          CandidateSet.getRewriteInfo().isReversible()) {
+        // We could have reversed this operator, but didn't. Check if some
+        // reversed form was a viable candidate, and if so, if it had a
+        // better conversion for either parameter. If so, this call is
+        // formally ambiguous, and allowing it is an extension.
+        llvm::SmallVector<FunctionDecl *, 4> AmbiguousWith;
+        for (OverloadCandidate &Cand : CandidateSet) {
+          if (Cand.Viable && Cand.Function && Cand.isReversed() &&
+              allowAmbiguity(Context, Cand.Function, FnDecl)) {
+            for (unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
+              if (CompareImplicitConversionSequences(
+                      *this, OpLoc, Cand.Conversions[ArgIdx],
+                      Best->Conversions[ArgIdx]) ==
+                  ImplicitConversionSequence::Better) {
+                AmbiguousWith.push_back(Cand.Function);
+                break;
+              }
             }
           }
         }
 
-        // Check for nonnull = nullable.
-        // This won't be caught in the arg's initialization: the parameter to
-        // the assignment operator is not marked nonnull.
-        if (Op == OO_Equal)
-          diagnoseNullableToNonnullConversion(Args[0]->getType(),
-                                              Args[1]->getType(), OpLoc);
-
-        // Convert the arguments.
-        if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
-          // Best->Access is only meaningful for class members.
-          CheckMemberOperatorAccess(OpLoc, Args[0], Args[1], Best->FoundDecl);
-
-          ExprResult Arg0, Arg1;
-          unsigned ParamIdx = 0;
-          if (Method->isExplicitObjectMemberFunction()) {
-            Arg0 = InitializeExplicitObjectArgument(*this, Args[0], FnDecl);
-            ParamIdx = 1;
+        if (!AmbiguousWith.empty()) {
+          bool AmbiguousWithSelf =
+              AmbiguousWith.size() == 1 &&
+              declaresSameEntity(AmbiguousWith.front(), FnDecl);
+          Diag(OpLoc, diag::ext_ovl_ambiguous_oper_binary_reversed)
+              << BinaryOperator::getOpcodeStr(Opc) << Args[0]->getType()
+              << Args[1]->getType() << AmbiguousWithSelf
+              << Args[0]->getSourceRange() << Args[1]->getSourceRange();
+          if (AmbiguousWithSelf) {
+            Diag(FnDecl->getLocation(),
+                 diag::note_ovl_ambiguous_oper_binary_reversed_self);
+            // Mark member== const or provide matching != to disallow reversed
+            // args. Eg.
+            // struct S { bool operator==(const S&); };
+            // S()==S();
+            if (auto *MD = dyn_cast<CXXMethodDecl>(FnDecl))
+              if (Op == OverloadedOperatorKind::OO_EqualEqual &&
+                  !MD->isConst() &&
+                  !MD->hasCXXExplicitFunctionObjectParameter() &&
+                  Context.hasSameUnqualifiedType(
+                      MD->getFunctionObjectParameterType(),
+                      MD->getParamDecl(0)->getType().getNonReferenceType()) &&
+                  Context.hasSameUnqualifiedType(
+                      MD->getFunctionObjectParameterType(),
+                      Args[0]->getType()) &&
+                  Context.hasSameUnqualifiedType(
+                      MD->getFunctionObjectParameterType(), Args[1]->getType()))
+                Diag(FnDecl->getLocation(),
+                     diag::note_ovl_ambiguous_eqeq_reversed_self_non_const);
           } else {
-            Arg0 = PerformImplicitObjectArgumentInitialization(
-                Args[0], /*Qualifier=*/std::nullopt, Best->FoundDecl, Method);
+            Diag(FnDecl->getLocation(),
+                 diag::note_ovl_ambiguous_oper_binary_selected_candidate);
+            for (auto *F : AmbiguousWith)
+              Diag(F->getLocation(),
+                   diag::note_ovl_ambiguous_oper_binary_reversed_candidate);
           }
-          Arg1 = PerformCopyInitialization(
-              InitializedEntity::InitializeParameter(
-                  Context, FnDecl->getParamDecl(ParamIdx)),
-              SourceLocation(), Args[1]);
-          if (Arg0.isInvalid() || Arg1.isInvalid())
-            return ExprError();
-
-          Base = Args[0] = Arg0.getAs<Expr>();
-          Args[1] = RHS = Arg1.getAs<Expr>();
-        } else {
-          // Convert the arguments.
-          ExprResult Arg0 = PerformCopyInitialization(
-            InitializedEntity::InitializeParameter(Context,
-                                                   FnDecl->getParamDecl(0)),
-            SourceLocation(), Args[0]);
-          if (Arg0.isInvalid())
-            return ExprError();
-
-          ExprResult Arg1 =
-            PerformCopyInitialization(
-              InitializedEntity::InitializeParameter(Context,
-                                                     FnDecl->getParamDecl(1)),
-              SourceLocation(), Args[1]);
-          if (Arg1.isInvalid())
-            return ExprError();
-          Args[0] = LHS = Arg0.getAs<Expr>();
-          Args[1] = RHS = Arg1.getAs<Expr>();
         }
+      }
 
-        // Build the actual expression node.
-        ExprResult FnExpr = CreateFunctionRefExpr(*this, FnDecl,
-                                                  Best->FoundDecl, Base,
-                                                  HadMultipleCandidates, OpLoc);
-        if (FnExpr.isInvalid())
-          return ExprError();
+      // Check for nonnull = nullable.
+      // This won't be caught in the arg's initialization: the parameter to
+      // the assignment operator is not marked nonnull.
+      if (Op == OO_Equal)
+        diagnoseNullableToNonnullConversion(Args[0]->getType(),
+                                            Args[1]->getType(), OpLoc);
+
+      // Convert the arguments.
+      if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
+        // Best->Access is only meaningful for class members.
+        CheckMemberOperatorAccess(OpLoc, Args[0], Args[1], Best->FoundDecl);
 
-        // Determine the result type.
-        QualType ResultTy = FnDecl->getReturnType();
-        ExprValueKind VK = Expr::getValueKindForType(ResultTy);
-        ResultTy = ResultTy.getNonLValueExprType(Context);
-
-        CallExpr *TheCall;
-        ArrayRef<const Expr *> ArgsArray(Args, 2);
-        const Expr *ImplicitThis = nullptr;
-
-        // We always create a CXXOperatorCallExpr, even for explicit object
-        // members; CodeGen should take care not to emit the this pointer.
-        TheCall = CXXOperatorCallExpr::Create(
-            Context, ChosenOp, FnExpr.get(), Args, ResultTy, VK, OpLoc,
-            CurFPFeatureOverrides(),
-            static_cast<CallExpr::ADLCallKind>(Best->IsADLCandidate));
-
-        if (const auto *Method = dyn_cast<CXXMethodDecl>(FnDecl);
-            Method && Method->isImplicitObjectMemberFunction()) {
-          // Cut off the implicit 'this'.
-          ImplicitThis = ArgsArray[0];
-          ArgsArray = ArgsArray.slice(1);
+        ExprResult Arg0, Arg1;
+        unsigned ParamIdx = 0;
+        if (Method->isExplicitObjectMemberFunction()) {
+          Arg0 = InitializeExplicitObjectArgument(*this, Args[0], FnDecl);
+          ParamIdx = 1;
+        } else {
+          Arg0 = PerformImplicitObjectArgumentInitialization(
+              Args[0], /*Qualifier=*/std::nullopt, Best->FoundDecl, Method);
         }
+        Arg1 = PerformCopyInitialization(
+            InitializedEntity::InitializeParameter(
+                Context, FnDecl->getParamDecl(ParamIdx)),
+            SourceLocation(), Args[1]);
+        if (Arg0.isInvalid() || Arg1.isInvalid())
+          return ExprError();
 
-        if (CheckCallReturnType(FnDecl->getReturnType(), OpLoc, TheCall,
-                                FnDecl))
+        Base = Args[0] = Arg0.getAs<Expr>();
+        Args[1] = RHS = Arg1.getAs<Expr>();
+      } else {
+        // Convert the arguments.
+        ExprResult Arg0 =
+            PerformCopyInitialization(InitializedEntity::InitializeParameter(
+                                          Context, FnDecl->getParamDecl(0)),
+                                      SourceLocation(), Args[0]);
+        if (Arg0.isInvalid())
           return ExprError();
 
-        if (Op == OO_Equal) {
-          // Check for a self move.
-          DiagnoseSelfMove(Args[0], Args[1], OpLoc);
-          // lifetime check.
-          checkAssignmentLifetime(
-              *this, AssignedEntity{Args[0], dyn_cast<CXXMethodDecl>(FnDecl)},
-              Args[1]);
-        }
-        if (ImplicitThis) {
-          QualType ThisType = Context.getPointerType(ImplicitThis->getType());
-          QualType ThisTypeFromDecl = Context.getPointerType(
-              cast<CXXMethodDecl>(FnDecl)->getFunctionObjectParameterType());
+        ExprResult Arg1 =
+            PerformCopyInitialization(InitializedEntity::InitializeParameter(
+                                          Context, FnDecl->getParamDecl(1)),
+                                      SourceLocation(), Args[1]);
+        if (Arg1.isInvalid())
+          return ExprError();
+        Args[0] = LHS = Arg0.getAs<Expr>();
+        Args[1] = RHS = Arg1.getAs<Expr>();
+      }
 
-          CheckArgAlignment(OpLoc, FnDecl, "'this'", ThisType,
-                            ThisTypeFromDecl);
-        }
+      // Build the actual expression node.
+      ExprResult FnExpr = CreateFunctionRefExpr(
+          *this, FnDecl, Best->FoundDecl, Base, HadMultipleCandidates, OpLoc);
+      if (FnExpr.isInvalid())
+        return ExprError();
 
-        checkCall(FnDecl, nullptr, ImplicitThis, ArgsArray,
-                  isa<CXXMethodDecl>(FnDecl), OpLoc, TheCall->getSourceRange(),
-                  VariadicCallType::DoesNotApply);
+      // Determine the result type.
+      QualType ResultTy = FnDecl->getReturnType();
+      ExprValueKind VK = Expr::getValueKindForType(ResultTy);
+      ResultTy = ResultTy.getNonLValueExprType(Context);
 
-        ExprResult R = MaybeBindToTemporary(TheCall);
-        if (R.isInvalid())
-          return ExprError();
+      CallExpr *TheCall;
+      ArrayRef<const Expr *> ArgsArray(Args, 2);
+      const Expr *ImplicitThis = nullptr;
 
-        R = CheckForImmediateInvocation(R, FnDecl);
-        if (R.isInvalid())
-          return ExprError();
+      // We always create a CXXOperatorCallExpr, even for explicit object
+      // members; CodeGen should take care not to emit the this pointer.
+      TheCall = CXXOperatorCallExpr::Create(
+          Context, ChosenOp, FnExpr.get(), Args, ResultTy, VK, OpLoc,
+          CurFPFeatureOverrides(),
+          static_cast<CallExpr::ADLCallKind>(Best->IsADLCandidate));
 
-        // For a rewritten candidate, we've already reversed the arguments
-        // if needed. Perform the rest of the rewrite now.
-        if ((Best->RewriteKind & CRK_DifferentOperator) ||
-            (Op == OO_Spaceship && IsReversed)) {
-          if (Op == OO_ExclaimEqual) {
-            assert(ChosenOp == OO_EqualEqual && "unexpected operator name");
-            R = CreateBuiltinUnaryOp(OpLoc, UO_LNot, R.get());
-          } else {
-            assert(ChosenOp == OO_Spaceship && "unexpected operator name");
-            llvm::APSInt Zero(Context.getTypeSize(Context.IntTy), false);
-            Expr *ZeroLiteral =
-                IntegerLiteral::Create(Context, Zero, Context.IntTy, OpLoc);
-
-            Sema::CodeSynthesisContext Ctx;
-            Ctx.Kind = Sema::CodeSynthesisContext::RewritingOperatorAsSpaceship;
-            Ctx.Entity = FnDecl;
-            pushCodeSynthesisContext(Ctx);
-
-            R = CreateOverloadedBinOp(
-                OpLoc, Opc, Fns, IsReversed ? ZeroLiteral : R.get(),
-                IsReversed ? R.get() : ZeroLiteral, /*PerformADL=*/true,
-                /*AllowRewrittenCandidates=*/false);
-
-            popCodeSynthesisContext();
-          }
-          if (R.isInvalid())
-            return ExprError();
-        } else {
-          assert(ChosenOp == Op && "unexpected operator name");
-        }
+      if (const auto *Method = dyn_cast<CXXMethodDecl>(FnDecl);
+          Method && Method->isImplicitObjectMemberFunction()) {
+        // Cut off the implicit 'this'.
+        ImplicitThis = ArgsArray[0];
+        ArgsArray = ArgsArray.slice(1);
+      }
 
-        // Make a note in the AST if we did any rewriting.
-        if (Best->RewriteKind != CRK_None)
-          R = new (Context) CXXRewrittenBinaryOperator(R.get(), IsReversed);
+      if (CheckCallReturnType(FnDecl->getReturnType(), OpLoc, TheCall, FnDecl))
+        return ExprError();
 
-        return R;
-      } else {
-        // We matched a built-in operator. Convert the arguments, then
-        // break out so that we will build the appropriate built-in
-        // operator node.
-        ExprResult ArgsRes0 = PerformImplicitConversion(
-            Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
-            AssignmentAction::Passing,
-            CheckedConversionKind::ForBuiltinOverloadedOp);
-        if (ArgsRes0.isInvalid())
-          return ExprError();
-        Args[0] = ArgsRes0.get();
+      if (Op == OO_Equal) {
+        // Check for a self move.
+        DiagnoseSelfMove(Args[0], Args[1], OpLoc);
+        // lifetime check.
+        checkAssignmentLifetime(
+            *this, AssignedEntity{Args[0], dyn_cast<CXXMethodDecl>(FnDecl)},
+            Args[1]);
+      }
+      if (ImplicitThis) {
+        QualType ThisType = Context.getPointerType(ImplicitThis->getType());
+        QualType ThisTypeFromDecl = Context.getPointerType(
+            cast<CXXMethodDecl>(FnDecl)->getFunctionObjectParameterType());
 
-        ExprResult ArgsRes1 = PerformImplicitConversion(
-            Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
-            AssignmentAction::Passing,
-            CheckedConversionKind::ForBuiltinOverloadedOp);
-        if (ArgsRes1.isInvalid())
-          return ExprError();
-        Args[1] = ArgsRes1.get();
-        break;
+        CheckArgAlignment(OpLoc, FnDecl, "'this'", ThisType, ThisTypeFromDecl);
       }
-    }
 
-    case OR_No_Viable_Function: {
-      // C++ [over.match.oper]p9:
-      //   If the operator is the operator , [...] and there are no
-      //   viable functions, then the operator is assumed to be the
-      //   built-in operator and interpreted according to clause 5.
-      if (Opc == BO_Comma)
-        break;
+      checkCall(FnDecl, nullptr, ImplicitThis, ArgsArray,
+                isa<CXXMethodDecl>(FnDecl), OpLoc, TheCall->getSourceRange(),
+                VariadicCallType::DoesNotApply);
 
-      // When defaulting an 'operator<=>', we can try to synthesize a three-way
-      // compare result using '==' and '<'.
-      if (DefaultedFn && Opc == BO_Cmp) {
-        ExprResult E = BuildSynthesizedThreeWayComparison(OpLoc, Fns, Args[0],
-                                                          Args[1], DefaultedFn);
-        if (E.isInvalid() || E.isUsable())
-          return E;
-      }
+      ExprResult R = MaybeBindToTemporary(TheCall);
+      if (R.isInvalid())
+        return ExprError();
 
-      // For class as left operand for assignment or compound assignment
-      // operator do not fall through to handling in built-in, but report that
-      // no overloaded assignment operator found
-      ExprResult Result = ExprError();
-      StringRef OpcStr = BinaryOperator::getOpcodeStr(Opc);
-      auto Cands = CandidateSet.CompleteCandidates(*this, OCD_AllCandidates,
-                                                   Args, OpLoc);
-      DeferDiagsRAII DDR(*this,
-                         CandidateSet.shouldDeferDiags(*this, Args, OpLoc));
-      if (Args[0]->getType()->isRecordType() &&
-          Opc >= BO_Assign && Opc <= BO_OrAssign) {
-        Diag(OpLoc,  diag::err_ovl_no_viable_oper)
-             << BinaryOperator::getOpcodeStr(Opc)
-             << Args[0]->getSourceRange() << Args[1]->getSourceRange();
-        if (Args[0]->getType()->isIncompleteType()) {
-          Diag(OpLoc, diag::note_assign_lhs_incomplete)
-            << Args[0]->getType()
-            << Args[0]->getSourceRange() << Args[1]->getSourceRange();
+      R = CheckForImmediateInvocation(R, FnDecl);
+      if (R.isInvalid())
+        return ExprError();
+
+      // For a rewritten candidate, we've already reversed the arguments
+      // if needed. Perform the rest of the rewrite now.
+      if ((Best->RewriteKind & CRK_DifferentOperator) ||
+          (Op == OO_Spaceship && IsReversed)) {
+        if (Op == OO_ExclaimEqual) {
+          assert(ChosenOp == OO_EqualEqual && "unexpected operator name");
+          R = CreateBuiltinUnaryOp(OpLoc, UO_LNot, R.get());
+        } else {
+          assert(ChosenOp == OO_Spaceship && "unexpected operator name");
+          llvm::APSInt Zero(Context.getTypeSize(Context.IntTy), false);
+          Expr *ZeroLiteral =
+              IntegerLiteral::Create(Context, Zero, Context.IntTy, OpLoc);
+
+          Sema::CodeSynthesisContext Ctx;
+          Ctx.Kind = Sema::CodeSynthesisContext::RewritingOperatorAsSpaceship;
+          Ctx.Entity = FnDecl;
+          pushCodeSynthesisContext(Ctx);
+
+          R = CreateOverloadedBinOp(
+              OpLoc, Opc, Fns, IsReversed ? ZeroLiteral : R.get(),
+              IsReversed ? R.get() : ZeroLiteral, /*PerformADL=*/true,
+              /*AllowRewrittenCandidates=*/false);
+
+          popCodeSynthesisContext();
         }
-      } else {
-        // This is an erroneous use of an operator which can be overloaded by
-        // a non-member function. Check for non-member operators which were
-        // defined too late to be candidates.
-        if (DiagnoseTwoPhaseOperatorLookup(*this, Op, OpLoc, Args))
-          // FIXME: Recover by calling the found function.
+        if (R.isInvalid())
           return ExprError();
+      } else {
+        assert(ChosenOp == Op && "unexpected operator name");
+      }
 
-        // No viable function; try to create a built-in operation, which will
-        // produce an error. Then, show the non-viable candidates.
-        Result = CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
+      // Make a note in the AST if we did any rewriting.
+      if (Best->RewriteKind != CRK_None)
+        R = new (Context) CXXRewrittenBinaryOperator(R.get(), IsReversed);
+
+      return R;
+    } else {
+      // We matched a built-in operator. Convert the arguments, then
+      // break out so that we will build the appropriate built-in
+      // operator node.
+      ExprResult ArgsRes0 = PerformImplicitConversion(
+          Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
+          AssignmentAction::Passing,
+          CheckedConversionKind::ForBuiltinOverloadedOp);
+      if (ArgsRes0.isInvalid())
+        return ExprError();
+      Args[0] = ArgsRes0.get();
+
+      ExprResult ArgsRes1 = PerformImplicitConversion(
+          Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
+          AssignmentAction::Passing,
+          CheckedConversionKind::ForBuiltinOverloadedOp);
+      if (ArgsRes1.isInvalid())
+        return ExprError();
+      Args[1] = ArgsRes1.get();
+      break;
+    }
+  }
+
+  case OR_No_Viable_Function: {
+    // C++ [over.match.oper]p9:
+    //   If the operator is the operator , [...] and there are no
+    //   viable functions, then the operator is assumed to be the
+    //   built-in operator and interpreted according to clause 5.
+    if (Opc == BO_Comma)
+      break;
+
+    // When defaulting an 'operator<=>', we can try to synthesize a three-way
+    // compare result using '==' and '<'.
+    if (DefaultedFn && Opc == BO_Cmp) {
+      ExprResult E = BuildSynthesizedThreeWayComparison(OpLoc, Fns, Args[0],
+                                                        Args[1], DefaultedFn);
+      if (E.isInvalid() || E.isUsable())
+        return E;
+    }
+
+    // For class as left operand for assignment or compound assignment
+    // operator do not fall through to handling in built-in, but report that
+    // no overloaded assignment operator found
+    ExprResult Result = ExprError();
+    StringRef OpcStr = BinaryOperator::getOpcodeStr(Opc);
+    auto Cands =
+        CandidateSet.CompleteCandidates(*this, OCD_AllCandidates, Args, OpLoc);
+    DeferDiagsRAII DDR(*this,
+                       CandidateSet.shouldDeferDiags(*this, Args, OpLoc));
+    if (Args[0]->getType()->isRecordType() && Opc >= BO_Assign &&
+        Opc <= BO_OrAssign) {
+      Diag(OpLoc, diag::err_ovl_no_viable_oper)
+          << BinaryOperator::getOpcodeStr(Opc) << Args[0]->getSourceRange()
+          << Args[1]->getSourceRange();
+      if (Args[0]->getType()->isIncompleteType()) {
+        Diag(OpLoc, diag::note_assign_lhs_incomplete)
+            << Args[0]->getType() << Args[0]->getSourceRange()
+            << Args[1]->getSourceRange();
       }
-      assert(Result.isInvalid() &&
-             "C++ binary operator overloading is missing candidates!");
-      CandidateSet.NoteCandidates(*this, Args, Cands, OpcStr, OpLoc);
-      return Result;
+    } else {
+      // This is an erroneous use of an operator which can be overloaded by
+      // a non-member function. Check for non-member operators which were
+      // defined too late to be candidates.
+      if (DiagnoseTwoPhaseOperatorLookup(*this, Op, OpLoc, Args))
+        // FIXME: Recover by calling the found function.
+        return ExprError();
+
+      // No viable function; try to create a built-in operation, which will
+      // produce an error. Then, show the non-viable candidates.
+      Result = CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
     }
+    assert(Result.isInvalid() &&
+           "C++ binary operator overloading is missing candidates!");
+    CandidateSet.NoteCandidates(*this, Args, Cands, OpcStr, OpLoc);
+    return Result;
+  }
 
-    case OR_Ambiguous:
-      CandidateSet.NoteCandidates(
-          PartialDiagnosticAt(OpLoc, PDiag(diag::err_ovl_ambiguous_oper_binary)
-                                         << BinaryOperator::getOpcodeStr(Opc)
-                                         << Args[0]->getType()
-                                         << Args[1]->getType()
-                                         << Args[0]->getSourceRange()
-                                         << Args[1]->getSourceRange()),
-          *this, OCD_AmbiguousCandidates, Args, BinaryOperator::getOpcodeStr(Opc),
-          OpLoc);
-      return ExprError();
+  case OR_Ambiguous:
+    CandidateSet.NoteCandidates(
+        PartialDiagnosticAt(OpLoc, PDiag(diag::err_ovl_ambiguous_oper_binary)
+                                       << BinaryOperator::getOpcodeStr(Opc)
+                                       << Args[0]->getType()
+                                       << Args[1]->getType()
+                                       << Args[0]->getSourceRange()
+                                       << Args[1]->getSourceRange()),
+        *this, OCD_AmbiguousCandidates, Args, BinaryOperator::getOpcodeStr(Opc),
+        OpLoc);
+    return ExprError();
 
-    case OR_Deleted: {
-      if (isImplicitlyDeleted(Best->Function)) {
-        FunctionDecl *DeletedFD = Best->Function;
-        DefaultedFunctionKind DFK = getDefaultedFunctionKind(DeletedFD);
-        if (DFK.isSpecialMember()) {
-          Diag(OpLoc, diag::err_ovl_deleted_special_oper)
-              << Args[0]->getType() << DFK.asSpecialMember();
-        } else {
-          assert(DFK.isComparison());
-          Diag(OpLoc, diag::err_ovl_deleted_comparison)
+  case OR_Deleted: {
+    if (isImplicitlyDeleted(Best->Function)) {
+      FunctionDecl *DeletedFD = Best->Function;
+      DefaultedFunctionKind DFK = getDefaultedFunctionKind(DeletedFD);
+      if (DFK.isSpecialMember()) {
+        Diag(OpLoc, diag::err_ovl_deleted_special_oper)
+            << Args[0]->getType() << DFK.asSpecialMember();
+      } else {
+        assert(DFK.isComparison());
+        Diag(OpLoc, diag::err_ovl_deleted_comparison)
             << Args[0]->getType() << DeletedFD;
-        }
-
-        // The user probably meant to call this special member. Just
-        // explain why it's deleted.
-        NoteDeletedFunction(DeletedFD);
-        return ExprError();
       }
 
-      StringLiteral *Msg = Best->Function->getDeletedMessage();
-      CandidateSet.NoteCandidates(
-          PartialDiagnosticAt(
-              OpLoc,
-              PDiag(diag::err_ovl_deleted_oper)
-                  << getOperatorSpelling(Best->Function->getDeclName()
-                                             .getCXXOverloadedOperator())
-                  << (Msg != nullptr) << (Msg ? Msg->getString() : StringRef())
-                  << Args[0]->getSourceRange() << Args[1]->getSourceRange()),
-          *this, OCD_AllCandidates, Args, BinaryOperator::getOpcodeStr(Opc),
-          OpLoc);
+      // The user probably meant to call this special member. Just
+      // explain why it's deleted.
+      NoteDeletedFunction(DeletedFD);
       return ExprError();
     }
+
+    StringLiteral *Msg = Best->Function->getDeletedMessage();
+    CandidateSet.NoteCandidates(
+        PartialDiagnosticAt(
+            OpLoc,
+            PDiag(diag::err_ovl_deleted_oper)
+                << getOperatorSpelling(
+                       Best->Function->getDeclName().getCXXOverloadedOperator())
+                << (Msg != nullptr) << (Msg ? Msg->getString() : StringRef())
+                << Args[0]->getSourceRange() << Args[1]->getSourceRange()),
+        *this, OCD_AllCandidates, Args, BinaryOperator::getOpcodeStr(Opc),
+        OpLoc);
+    return ExprError();
+  }
   }
 
   // We matched a built-in operator; build it.
@@ -15923,7 +15790,7 @@ ExprResult Sema::BuildSynthesizedThreeWayComparison(
   // If we're not producing a known comparison category type, we can't
   // synthesize a three-way comparison. Let the caller diagnose this.
   if (!Info)
-    return ExprResult((Expr*)nullptr);
+    return ExprResult((Expr *)nullptr);
 
   // If we ever want to perform this synthesis more generally, we will need to
   // apply the temporary materialization conversion to the operands.
@@ -15963,12 +15830,12 @@ ExprResult Sema::BuildSynthesizedThreeWayComparison(
   struct Comparison {
     ExprResult Cmp;
     ComparisonCategoryResult Result;
-  } Comparisons[4] =
-  { {Eq, Info->isStrong() ? ComparisonCategoryResult::Equal
-                          : ComparisonCategoryResult::Equivalent},
-    {Less, ComparisonCategoryResult::Less},
-    {Greater, ComparisonCategoryResult::Greater},
-    {ExprResult(), ComparisonCategoryResult::Unordered},
+  } Comparisons[4] = {
+      {Eq, Info->isStrong() ? ComparisonCategoryResult::Equal
+                            : ComparisonCategoryResult::Equivalent},
+      {Less, ComparisonCategoryResult::Less},
+      {Greater, ComparisonCategoryResult::Greater},
+      {ExprResult(), ComparisonCategoryResult::Unordered},
   };
 
   int I = Info->isPartial() ? 3 : 2;
@@ -15980,7 +15847,7 @@ ExprResult Sema::BuildSynthesizedThreeWayComparison(
     auto *VI = Info->lookupValueInfo(Comparisons[I].Result);
     // FIXME: Missing a constant for a comparison category. Diagnose this?
     if (!VI)
-      return ExprResult((Expr*)nullptr);
+      return ExprResult((Expr *)nullptr);
     ExprResult ThisResult =
         BuildDeclarationNameExpr(CXXScopeSpec(), DeclarationNameInfo(), VI->VD);
     if (ThisResult.isInvalid())
@@ -16104,136 +15971,134 @@ ExprResult Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,
   // Perform overload resolution.
   OverloadCandidateSet::iterator Best;
   switch (CandidateSet.BestViableFunction(*this, LLoc, Best)) {
-    case OR_Success: {
-      // We found a built-in operator or an overloaded operator.
-      FunctionDecl *FnDecl = Best->Function;
-
-      if (FnDecl) {
-        // We matched an overloaded operator. Build a call to that
-        // operator.
-
-        CheckMemberOperatorAccess(LLoc, Args[0], ArgExpr, Best->FoundDecl);
-
-        // Convert the arguments.
-        CXXMethodDecl *Method = cast<CXXMethodDecl>(FnDecl);
-        SmallVector<Expr *, 2> MethodArgs;
+  case OR_Success: {
+    // We found a built-in operator or an overloaded operator.
+    FunctionDecl *FnDecl = Best->Function;
 
-        // Initialize the object parameter.
-        if (Method->isExplicitObjectMemberFunction()) {
-          ExprResult Res =
-              InitializeExplicitObjectArgument(*this, Args[0], Method);
-          if (Res.isInvalid())
-            return ExprError();
-          Args[0] = Res.get();
-          ArgExpr = Args;
-        } else {
-          ExprResult Arg0 = PerformImplicitObjectArgumentInitialization(
-              Args[0], /*Qualifier=*/std::nullopt, Best->FoundDecl, Method);
-          if (Arg0.isInvalid())
-            return ExprError();
+    if (FnDecl) {
+      // We matched an overloaded operator. Build a call to that
+      // operator.
 
-          MethodArgs.push_back(Arg0.get());
-        }
+      CheckMemberOperatorAccess(LLoc, Args[0], ArgExpr, Best->FoundDecl);
 
-        bool IsError = PrepareArgumentsForCallToObjectOfClassType(
-            *this, MethodArgs, Method, ArgExpr, LLoc);
-        if (IsError)
+      // Convert the arguments.
+      CXXMethodDecl *Method = cast<CXXMethodDecl>(FnDecl);
+      SmallVector<Expr *, 2> MethodArgs;
+
+      // Initialize the object parameter.
+      if (Method->isExplicitObjectMemberFunction()) {
+        ExprResult Res =
+            InitializeExplicitObjectArgument(*this, Args[0], Method);
+        if (Res.isInvalid())
           return ExprError();
-
-        // Build the actual expression node.
-        DeclarationNameInfo OpLocInfo(OpName, LLoc);
-        OpLocInfo.setCXXOperatorNameRange(SourceRange(LLoc, RLoc));
-        ExprResult FnExpr = CreateFunctionRefExpr(
-            *this, FnDecl, Best->FoundDecl, Base, HadMultipleCandidates,
-            OpLocInfo.getLoc(), OpLocInfo.getInfo());
-        if (FnExpr.isInvalid())
+        Args[0] = Res.get();
+        ArgExpr = Args;
+      } else {
+        ExprResult Arg0 = PerformImplicitObjectArgumentInitialization(
+            Args[0], /*Qualifier=*/std::nullopt, Best->FoundDecl, Method);
+        if (Arg0.isInvalid())
           return ExprError();
 
-        // Determine the result type
-        QualType ResultTy = FnDecl->getReturnType();
-        ExprValueKind VK = Expr::getValueKindForType(ResultTy);
-        ResultTy = ResultTy.getNonLValueExprType(Context);
+        MethodArgs.push_back(Arg0.get());
+      }
 
-        CallExpr *TheCall = CXXOperatorCallExpr::Create(
-            Context, OO_Subscript, FnExpr.get(), MethodArgs, ResultTy, VK, RLoc,
-            CurFPFeatureOverrides());
+      bool IsError = PrepareArgumentsForCallToObjectOfClassType(
+          *this, MethodArgs, Method, ArgExpr, LLoc);
+      if (IsError)
+        return ExprError();
 
-        if (CheckCallReturnType(FnDecl->getReturnType(), LLoc, TheCall, FnDecl))
-          return ExprError();
+      // Build the actual expression node.
+      DeclarationNameInfo OpLocInfo(OpName, LLoc);
+      OpLocInfo.setCXXOperatorNameRange(SourceRange(LLoc, RLoc));
+      ExprResult FnExpr = CreateFunctionRefExpr(
+          *this, FnDecl, Best->FoundDecl, Base, HadMultipleCandidates,
+          OpLocInfo.getLoc(), OpLocInfo.getInfo());
+      if (FnExpr.isInvalid())
+        return ExprError();
 
-        if (CheckFunctionCall(Method, TheCall,
-                              Method->getType()->castAs<FunctionProtoType>()))
-          return ExprError();
+      // Determine the result type
+      QualType ResultTy = FnDecl->getReturnType();
+      ExprValueKind VK = Expr::getValueKindForType(ResultTy);
+      ResultTy = ResultTy.getNonLValueExprType(Context);
 
-        return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall),
-                                           FnDecl);
-      } else {
-        // We matched a built-in operator. Convert the arguments, then
-        // break out so that we will build the appropriate built-in
-        // operator node.
-        ExprResult ArgsRes0 = PerformImplicitConversion(
-            Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
-            AssignmentAction::Passing,
-            CheckedConversionKind::ForBuiltinOverloadedOp);
-        if (ArgsRes0.isInvalid())
-          return ExprError();
-        Args[0] = ArgsRes0.get();
+      CallExpr *TheCall = CXXOperatorCallExpr::Create(
+          Context, OO_Subscript, FnExpr.get(), MethodArgs, ResultTy, VK, RLoc,
+          CurFPFeatureOverrides());
 
-        ExprResult ArgsRes1 = PerformImplicitConversion(
-            Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
-            AssignmentAction::Passing,
-            CheckedConversionKind::ForBuiltinOverloadedOp);
-        if (ArgsRes1.isInvalid())
-          return ExprError();
-        Args[1] = ArgsRes1.get();
+      if (CheckCallReturnType(FnDecl->getReturnType(), LLoc, TheCall, FnDecl))
+        return ExprError();
 
-        break;
-      }
-    }
+      if (CheckFunctionCall(Method, TheCall,
+                            Method->getType()->castAs<FunctionProtoType>()))
+        return ExprError();
 
-    case OR_No_Viable_Function: {
-      PartialDiagnostic PD =
-          CandidateSet.empty()
-              ? (PDiag(diag::err_ovl_no_oper)
-                 << Args[0]->getType() << /*subscript*/ 0
-                 << Args[0]->getSourceRange() << Range)
-              : (PDiag(diag::err_ovl_no_viable_subscript)
-                 << Args[0]->getType() << Args[0]->getSourceRange() << Range);
-      CandidateSet.NoteCandidates(PartialDiagnosticAt(LLoc, PD), *this,
-                                  OCD_AllCandidates, ArgExpr, "[]", LLoc);
-      return ExprError();
+      return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall), FnDecl);
+    } else {
+      // We matched a built-in operator. Convert the arguments, then
+      // break out so that we will build the appropriate built-in
+      // operator node.
+      ExprResult ArgsRes0 = PerformImplicitConversion(
+          Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
+          AssignmentAction::Passing,
+          CheckedConversionKind::ForBuiltinOverloadedOp);
+      if (ArgsRes0.isInvalid())
+        return ExprError();
+      Args[0] = ArgsRes0.get();
+
+      ExprResult ArgsRes1 = PerformImplicitConversion(
+          Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
+          AssignmentAction::Passing,
+          CheckedConversionKind::ForBuiltinOverloadedOp);
+      if (ArgsRes1.isInvalid())
+        return ExprError();
+      Args[1] = ArgsRes1.get();
+
+      break;
     }
+  }
 
-    case OR_Ambiguous:
-      if (Args.size() == 2) {
-        CandidateSet.NoteCandidates(
-            PartialDiagnosticAt(
-                LLoc, PDiag(diag::err_ovl_ambiguous_oper_binary)
-                          << "[]" << Args[0]->getType() << Args[1]->getType()
-                          << Args[0]->getSourceRange() << Range),
-            *this, OCD_AmbiguousCandidates, Args, "[]", LLoc);
-      } else {
-        CandidateSet.NoteCandidates(
-            PartialDiagnosticAt(LLoc,
-                                PDiag(diag::err_ovl_ambiguous_subscript_call)
-                                    << Args[0]->getType()
-                                    << Args[0]->getSourceRange() << Range),
-            *this, OCD_AmbiguousCandidates, Args, "[]", LLoc);
-      }
-      return ExprError();
+  case OR_No_Viable_Function: {
+    PartialDiagnostic PD =
+        CandidateSet.empty()
+            ? (PDiag(diag::err_ovl_no_oper)
+               << Args[0]->getType() << /*subscript*/ 0
+               << Args[0]->getSourceRange() << Range)
+            : (PDiag(diag::err_ovl_no_viable_subscript)
+               << Args[0]->getType() << Args[0]->getSourceRange() << Range);
+    CandidateSet.NoteCandidates(PartialDiagnosticAt(LLoc, PD), *this,
+                                OCD_AllCandidates, ArgExpr, "[]", LLoc);
+    return ExprError();
+  }
 
-    case OR_Deleted: {
-      StringLiteral *Msg = Best->Function->getDeletedMessage();
+  case OR_Ambiguous:
+    if (Args.size() == 2) {
+      CandidateSet.NoteCandidates(
+          PartialDiagnosticAt(LLoc, PDiag(diag::err_ovl_ambiguous_oper_binary)
+                                        << "[]" << Args[0]->getType()
+                                        << Args[1]->getType()
+                                        << Args[0]->getSourceRange() << Range),
+          *this, OCD_AmbiguousCandidates, Args, "[]", LLoc);
+    } else {
       CandidateSet.NoteCandidates(
           PartialDiagnosticAt(LLoc,
-                              PDiag(diag::err_ovl_deleted_oper)
-                                  << "[]" << (Msg != nullptr)
-                                  << (Msg ? Msg->getString() : StringRef())
+                              PDiag(diag::err_ovl_ambiguous_subscript_call)
+                                  << Args[0]->getType()
                                   << Args[0]->getSourceRange() << Range),
-          *this, OCD_AllCandidates, Args, "[]", LLoc);
-      return ExprError();
-    }
+          *this, OCD_AmbiguousCandidates, Args, "[]", LLoc);
     }
+    return ExprError();
+
+  case OR_Deleted: {
+    StringLiteral *Msg = Best->Function->getDeletedMessage();
+    CandidateSet.NoteCandidates(
+        PartialDiagnosticAt(LLoc, PDiag(diag::err_ovl_deleted_oper)
+                                      << "[]" << (Msg != nullptr)
+                                      << (Msg ? Msg->getString() : StringRef())
+                                      << Args[0]->getSourceRange() << Range),
+        *this, OCD_AllCandidates, Args, "[]", LLoc);
+    return ExprError();
+  }
+  }
 
   // We matched a built-in operator; build it.
   return CreateBuiltinArraySubscriptExpr(Args[0], LLoc, Args[1], RLoc);
@@ -16258,7 +16123,7 @@ ExprResult Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
     assert(op->getOpcode() == BO_PtrMemD || op->getOpcode() == BO_PtrMemI);
 
     QualType fnType =
-      op->getRHS()->getType()->castAs<MemberPointerType>()->getPointeeType();
+        op->getRHS()->getType()->castAs<MemberPointerType>()->getPointeeType();
 
     const FunctionProtoType *proto = fnType->castAs<FunctionProtoType>();
     QualType resultType = proto->getCallResultType(Context);
@@ -16279,9 +16144,8 @@ ExprResult Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
     if (difference) {
       std::string qualsString = difference.getAsString();
       Diag(LParenLoc, diag::err_pointer_to_member_call_drops_quals)
-        << fnType.getUnqualifiedType()
-        << qualsString
-        << (qualsString.find(' ') == std::string::npos ? 1 : 2);
+          << fnType.getUnqualifiedType() << qualsString
+          << (qualsString.find(' ') == std::string::npos ? 1 : 2);
     }
 
     CXXMemberCallExpr *call = CXXMemberCallExpr::Create(
@@ -16336,9 +16200,9 @@ ExprResult Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
     Qualifier = UnresExpr->getQualifier();
 
     QualType ObjectType = UnresExpr->getBaseType();
-    Expr::Classification ObjectClassification
-      = UnresExpr->isArrow()? Expr::Classification::makeSimpleLValue()
-                            : UnresExpr->getBase()->Classify(Context);
+    Expr::Classification ObjectClassification =
+        UnresExpr->isArrow() ? Expr::Classification::makeSimpleLValue()
+                             : UnresExpr->getBase()->Classify(Context);
 
     // Add overload candidates
     OverloadCandidateSet CandidateSet(UnresExpr->getMemberLoc(),
@@ -16352,7 +16216,8 @@ ExprResult Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
     }
 
     for (UnresolvedMemberExpr::decls_iterator I = UnresExpr->decls_begin(),
-           E = UnresExpr->decls_end(); I != E; ++I) {
+                                              E = UnresExpr->decls_end();
+         I != E; ++I) {
 
       QualType ExplicitObjectType = ObjectType;
 
@@ -16508,8 +16373,7 @@ ExprResult Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
     return BuildRecoveryExpr(ResultType);
 
   // Convert the rest of the arguments
-  if (ConvertArgumentsForCall(TheCall, MemExpr, Method, Proto, Args,
-                              RParenLoc))
+  if (ConvertArgumentsForCall(TheCall, MemExpr, Method, Proto, Args, RParenLoc))
     return BuildRecoveryExpr(ResultType);
 
   DiagnoseSentinelCalls(Method, LParenLoc, Args);
@@ -16563,11 +16427,10 @@ ExprResult Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
                                      TheCall->getDirectCallee());
 }
 
-ExprResult
-Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,
-                                   SourceLocation LParenLoc,
-                                   MultiExprArg Args,
-                                   SourceLocation RParenLoc) {
+ExprResult Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,
+                                              SourceLocation LParenLoc,
+                                              MultiExprArg Args,
+                                              SourceLocation RParenLoc) {
   if (checkPlaceholderForOverload(*this, Obj))
     return ExprError();
   ExprResult Object = Obj;
@@ -16660,8 +16523,8 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,
       if (const PointerType *ConvPtrType = ConvType->getAs<PointerType>())
         ConvType = ConvPtrType->getPointeeType();
 
-      if (const FunctionProtoType *Proto = ConvType->getAs<FunctionProtoType>())
-      {
+      if (const FunctionProtoType *Proto =
+              ConvType->getAs<FunctionProtoType>()) {
         AddSurrogateCandidate(Conv, I.getPair(), ActingContext, Proto,
                               Object.get(), Args, CandidateSet);
       }
@@ -16726,16 +16589,15 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,
   if (Best->Function == nullptr) {
     // Since there is no function declaration, this is one of the
     // surrogate candidates. Dig out the conversion function.
-    CXXConversionDecl *Conv
-      = cast<CXXConversionDecl>(
-                         Best->Conversions[0].UserDefined.ConversionFunction);
+    CXXConversionDecl *Conv = cast<CXXConversionDecl>(
+        Best->Conversions[0].UserDefined.ConversionFunction);
 
     CheckMemberOperatorAccess(LParenLoc, Object.get(), nullptr,
                               Best->FoundDecl);
     if (DiagnoseUseOfDecl(Best->FoundDecl, LParenLoc))
       return ExprError();
     assert(Conv == Best->FoundDecl.getDecl() &&
-             "Found Decl & conversion-to-functionptr should be same, right?!");
+           "Found Decl & conversion-to-functionptr should be same, right?!");
     // We selected one of the surrogate functions that converts the
     // object parameter to a function pointer. Perform the conversion
     // on the object argument, then let BuildCallExpr finish the job.
@@ -16769,12 +16631,11 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,
   unsigned NumParams = Proto->getNumParams();
 
   DeclarationNameInfo OpLocInfo(
-               Context.DeclarationNames.getCXXOperatorName(OO_Call), LParenLoc);
+      Context.DeclarationNames.getCXXOperatorName(OO_Call), LParenLoc);
   OpLocInfo.setCXXOperatorNameRange(SourceRange(LParenLoc, RParenLoc));
-  ExprResult NewFn = CreateFunctionRefExpr(*this, Method, Best->FoundDecl,
-                                           Obj, HadMultipleCandidates,
-                                           OpLocInfo.getLoc(),
-                                           OpLocInfo.getInfo());
+  ExprResult NewFn = CreateFunctionRefExpr(
+      *this, Method, Best->FoundDecl, Obj, HadMultipleCandidates,
+      OpLocInfo.getLoc(), OpLocInfo.getInfo());
   if (NewFn.isInvalid())
     return true;
 
@@ -16852,7 +16713,7 @@ ExprResult Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base,
   //   the operator is selected as the best match function by the
   //   overload resolution mechanism (13.3).
   DeclarationName OpName =
-    Context.DeclarationNames.getCXXOperatorName(OO_Arrow);
+      Context.DeclarationNames.getCXXOperatorName(OO_Arrow);
   OverloadCandidateSet CandidateSet(Loc, OverloadCandidateSet::CSK_Operator);
 
   if (RequireCompleteType(Loc, Base->getType(),
@@ -16880,7 +16741,8 @@ ExprResult Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base,
     break;
 
   case OR_No_Viable_Function: {
-    auto Cands = CandidateSet.CompleteCandidates(*this, OCD_AllCandidates, Base);
+    auto Cands =
+        CandidateSet.CompleteCandidates(*this, OCD_AllCandidates, Base);
     if (CandidateSet.empty()) {
       QualType BaseType = Base->getType();
       if (NoArrowOperatorFound) {
@@ -16890,14 +16752,14 @@ ExprResult Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base,
         return ExprError();
       }
       Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
-        << BaseType << Base->getSourceRange();
+          << BaseType << Base->getSourceRange();
       if (BaseType->isRecordType() && !BaseType->isPointerType()) {
         Diag(OpLoc, diag::note_typecheck_member_reference_suggestion)
-          << FixItHint::CreateReplacement(OpLoc, ".");
+            << FixItHint::CreateReplacement(OpLoc, ".");
       }
     } else
       Diag(OpLoc, diag::err_ovl_no_viable_oper)
-        << "operator->" << Base->getSourceRange();
+          << "operator->" << Base->getSourceRange();
     CandidateSet.NoteCandidates(*this, Base, Cands);
     return ExprError();
   }
@@ -16964,11 +16826,10 @@ ExprResult Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base,
   return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall), Method);
 }
 
-ExprResult Sema::BuildLiteralOperatorCall(LookupResult &R,
-                                          DeclarationNameInfo &SuffixInfo,
-                                          ArrayRef<Expr*> Args,
-                                          SourceLocation LitEndLoc,
-                                       TemplateArgumentListInfo *TemplateArgs) {
+ExprResult
+Sema::BuildLiteralOperatorCall(LookupResult &R, DeclarationNameInfo &SuffixInfo,
+                               ArrayRef<Expr *> Args, SourceLocation LitEndLoc,
+                               TemplateArgumentListInfo *TemplateArgs) {
   SourceLocation UDSuffixLoc = SuffixInfo.getCXXLiteralOperatorNameLoc();
 
   OverloadCandidateSet CandidateSet(UDSuffixLoc,
@@ -17003,10 +16864,9 @@ ExprResult Sema::BuildLiteralOperatorCall(LookupResult &R,
   }
 
   FunctionDecl *FD = Best->Function;
-  ExprResult Fn = CreateFunctionRefExpr(*this, FD, Best->FoundDecl,
-                                        nullptr, HadMultipleCandidates,
-                                        SuffixInfo.getLoc(),
-                                        SuffixInfo.getInfo());
+  ExprResult Fn = CreateFunctionRefExpr(
+      *this, FD, Best->FoundDecl, nullptr, HadMultipleCandidates,
+      SuffixInfo.getLoc(), SuffixInfo.getInfo());
   if (Fn.isInvalid())
     return true;
 
@@ -17014,9 +16874,10 @@ ExprResult Sema::BuildLiteralOperatorCall(LookupResult &R,
   // that array-to-pointer decay is applied to string literals.
   Expr *ConvArgs[2];
   for (unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
-    ExprResult InputInit = PerformCopyInitialization(
-      InitializedEntity::InitializeParameter(Context, FD->getParamDecl(ArgIdx)),
-      SourceLocation(), Args[ArgIdx]);
+    ExprResult InputInit =
+        PerformCopyInitialization(InitializedEntity::InitializeParameter(
+                                      Context, FD->getParamDecl(ArgIdx)),
+                                  SourceLocation(), Args[ArgIdx]);
     if (InputInit.isInvalid())
       return true;
     ConvArgs[ArgIdx] = InputInit.get();
@@ -17039,24 +16900,20 @@ ExprResult Sema::BuildLiteralOperatorCall(LookupResult &R,
   return CheckForImmediateInvocation(MaybeBindToTemporary(UDL), FD);
 }
 
-Sema::ForRangeStatus
-Sema::BuildForRangeBeginEndCall(SourceLocation Loc,
-                                SourceLocation RangeLoc,
-                                const DeclarationNameInfo &NameInfo,
-                                LookupResult &MemberLookup,
-                                OverloadCandidateSet *CandidateSet,
-                                Expr *Range, ExprResult *CallExpr) {
+Sema::ForRangeStatus Sema::BuildForRangeBeginEndCall(
+    SourceLocation Loc, SourceLocation RangeLoc,
+    const DeclarationNameInfo &NameInfo, LookupResult &MemberLookup,
+    OverloadCandidateSet *CandidateSet, Expr *Range, ExprResult *CallExpr) {
   Scope *S = nullptr;
 
   CandidateSet->clear(OverloadCandidateSet::CSK_Normal);
   if (!MemberLookup.empty()) {
-    ExprResult MemberRef =
-        BuildMemberReferenceExpr(Range, Range->getType(), Loc,
-                                 /*IsPtr=*/false, CXXScopeSpec(),
-                                 /*TemplateKWLoc=*/SourceLocation(),
-                                 /*FirstQualifierInScope=*/nullptr,
-                                 MemberLookup,
-                                 /*TemplateArgs=*/nullptr, S);
+    ExprResult MemberRef = BuildMemberReferenceExpr(
+        Range, Range->getType(), Loc,
+        /*IsPtr=*/false, CXXScopeSpec(),
+        /*TemplateKWLoc=*/SourceLocation(),
+        /*FirstQualifierInScope=*/nullptr, MemberLookup,
+        /*TemplateArgs=*/nullptr, S);
     if (MemberRef.isInvalid()) {
       *CallExpr = ExprError();
       return FRS_DiagnosticIssued;
@@ -17074,8 +16931,8 @@ Sema::BuildForRangeBeginEndCall(SourceLocation Loc,
       return FRS_DiagnosticIssued;
     UnresolvedLookupExpr *Fn = cast<UnresolvedLookupExpr>(FnR.get());
 
-    bool CandidateSetError = buildOverloadedCallSet(S, Fn, Fn, Range, Loc,
-                                                    CandidateSet, CallExpr);
+    bool CandidateSetError =
+        buildOverloadedCallSet(S, Fn, Fn, Range, Loc, CandidateSet, CallExpr);
     if (CandidateSet->empty() || CandidateSetError) {
       *CallExpr = ExprError();
       return FRS_NoViableFunction;
@@ -17088,10 +16945,10 @@ Sema::BuildForRangeBeginEndCall(SourceLocation Loc,
       *CallExpr = ExprError();
       return FRS_NoViableFunction;
     }
-    *CallExpr = FinishOverloadedCallExpr(*this, S, Fn, Fn, Loc, Range,
-                                         Loc, nullptr, CandidateSet, &Best,
-                                         OverloadResult,
-                                         /*AllowTypoCorrection=*/false);
+    *CallExpr =
+        FinishOverloadedCallExpr(*this, S, Fn, Fn, Loc, Range, Loc, nullptr,
+                                 CandidateSet, &Best, OverloadResult,
+                                 /*AllowTypoCorrection=*/false);
     if (CallExpr->isInvalid() || OverloadResult != OR_Success) {
       *CallExpr = ExprError();
       return FRS_DiagnosticIssued;
@@ -17295,8 +17152,8 @@ ExprResult Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found,
     return BuildMemberExpr(
         Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(),
         MemExpr->getQualifierLoc(), MemExpr->getTemplateKeywordLoc(), Fn, Found,
-        /*HadMultipleCandidates=*/true, MemExpr->getMemberNameInfo(),
-        type, valueKind, OK_Ordinary, TemplateArgs);
+        /*HadMultipleCandidates=*/true, MemExpr->getMemberNameInfo(), type,
+        valueKind, OK_Ordinary, TemplateArgs);
   }
 
   llvm_unreachable("Invalid reference to overloaded function");

>From 9ed94d69ef1a014534afdbafee328c10148d4aec Mon Sep 17 00:00:00 2001
From: changkhothuychung <nhat7203 at gmail.com>
Date: Tue, 7 Apr 2026 14:19:49 -0400
Subject: [PATCH 03/23] update the builtintype bits

---
 clang/include/clang/AST/TypeBase.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/AST/TypeBase.h b/clang/include/clang/AST/TypeBase.h
index 71797b1c372ac..e3477c1cc0ef4 100644
--- a/clang/include/clang/AST/TypeBase.h
+++ b/clang/include/clang/AST/TypeBase.h
@@ -1962,7 +1962,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
     unsigned : NumTypeBits;
 
     /// The kind (BuiltinType::Kind) of builtin type this is.
-    static constexpr unsigned NumOfBuiltinTypeBits = 9;
+    static constexpr unsigned NumOfBuiltinTypeBits = 10;
     unsigned Kind : NumOfBuiltinTypeBits;
   };
 

>From 7b4ab812571cedb2c315433aa355d749116378f9 Mon Sep 17 00:00:00 2001
From: Nhat Nguyen <nhat7203 at gmail.com>
Date: Wed, 8 Apr 2026 12:11:22 -0400
Subject: [PATCH 04/23] Update clang/include/clang/Basic/TargetInfo.h

Co-authored-by: Timm Baeder <tbaeder at redhat.com>
---
 clang/include/clang/Basic/TargetInfo.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h
index de7e697a40cce..897bedc1f4de7 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -826,8 +826,9 @@ class TargetInfo : public TransferrableTargetInfo,
   unsigned getIbm128Align() const { return Ibm128Align; }
   const llvm::fltSemantics &getIbm128Format() const { return *Ibm128Format; }
 
-  /// getMetaInfoWidth/Align - Returns the size/align of std::meta::info.
+  /// Returns the size of std::meta::info.
   unsigned getMetaInfoWidth() const { return MetaInfoWidth; }
+  /// eturns the align of std::meta::info.
   unsigned getMetaInfoAlign() const { return MetaInfoAlign; }
 
   /// Return the mangled code of long double.

>From 516500740756f46c5ccbee403da9aaa239de8f76 Mon Sep 17 00:00:00 2001
From: changkhothuychung <nhat7203 at gmail.com>
Date: Wed, 8 Apr 2026 16:01:14 -0400
Subject: [PATCH 05/23] apply impl of reflection in bytecode interpreter

---
 clang/lib/AST/ByteCode/Compiler.cpp           | 18 ++++++
 clang/lib/AST/ByteCode/Compiler.h             |  1 +
 clang/lib/AST/ByteCode/Context.cpp            |  3 +
 clang/lib/AST/ByteCode/Descriptor.cpp         |  1 +
 clang/lib/AST/ByteCode/Disasm.cpp             |  2 +
 clang/lib/AST/ByteCode/Interp.h               |  6 ++
 .../lib/AST/ByteCode/InterpBuiltinBitCast.cpp |  2 +-
 clang/lib/AST/ByteCode/InterpStack.h          |  3 +
 clang/lib/AST/ByteCode/InterpState.cpp        |  1 +
 clang/lib/AST/ByteCode/Opcodes.td             |  9 ++-
 clang/lib/AST/ByteCode/PrimType.cpp           |  1 +
 clang/lib/AST/ByteCode/PrimType.h             |  6 ++
 clang/lib/AST/ByteCode/Program.cpp            |  1 +
 clang/lib/AST/ByteCode/Program.h              |  1 +
 clang/lib/AST/ByteCode/Reflect.h              | 61 +++++++++++++++++++
 15 files changed, 114 insertions(+), 2 deletions(-)
 create mode 100644 clang/lib/AST/ByteCode/Reflect.h

diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 9d2457a2f35cd..3755e54ebecfb 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -4242,6 +4242,21 @@ bool Compiler<Emitter>::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) {
   return this->emitError(E);
 }
 
+template <class Emitter>
+bool Compiler<Emitter>::VisitCXXReflectExpr(const CXXReflectExpr *E) {
+  if (DiscardResult)
+    return true;
+
+  switch (E->getKind()) {
+    case ReflectionKind::Type: {
+      APValue Result(ReflectionKind::Type, E->getOpaqueValue());
+      return this->emitReflectValue(E->getKind(), E->getOpaqueValue(), E);
+    }
+  }
+
+  return false;
+}
+
 template <class Emitter>
 bool Compiler<Emitter>::VisitExpressionTraitExpr(const ExpressionTraitExpr *E) {
   assert(Ctx.getLangOpts().CPlusPlus);
@@ -4735,6 +4750,8 @@ bool Compiler<Emitter>::visitZeroInitializer(PrimType T, QualType QT,
     auto Sem = Ctx.getASTContext().getFixedPointSemantics(E->getType());
     return this->emitConstFixedPoint(FixedPoint::zero(Sem), E);
   }
+  case PT_Reflect:
+    return this->emitReflectValue(ReflectionKind::Type, nullptr, E);
   }
   llvm_unreachable("unknown primitive type");
 }
@@ -4946,6 +4963,7 @@ bool Compiler<Emitter>::emitConst(T Value, PrimType Ty, const Expr *E) {
   case PT_IntAP:
   case PT_IntAPS:
   case PT_FixedPoint:
+  case PT_Reflect:
     llvm_unreachable("Invalid integral type");
     break;
   }
diff --git a/clang/lib/AST/ByteCode/Compiler.h b/clang/lib/AST/ByteCode/Compiler.h
index 4a70db89dba74..7ac767700ff2f 100644
--- a/clang/lib/AST/ByteCode/Compiler.h
+++ b/clang/lib/AST/ByteCode/Compiler.h
@@ -232,6 +232,7 @@ class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
   bool VisitCXXTypeidExpr(const CXXTypeidExpr *E);
   bool VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E);
   bool VisitObjCArrayLiteral(const ObjCArrayLiteral *E);
+  bool VisitCXXReflectExpr(const CXXReflectExpr *E);
 
   // Statements.
   bool visitCompoundStmt(const CompoundStmt *S);
diff --git a/clang/lib/AST/ByteCode/Context.cpp b/clang/lib/AST/ByteCode/Context.cpp
index 2b32161fceba0..4f92fabe9c81b 100644
--- a/clang/lib/AST/ByteCode/Context.cpp
+++ b/clang/lib/AST/ByteCode/Context.cpp
@@ -482,6 +482,9 @@ OptPrimType Context::classify(QualType T) const {
   if (T->isFixedPointType())
     return PT_FixedPoint;
 
+  if (T->isMetaInfoType())
+    return PT_Reflect;
+
   // Vector and complex types get here.
   return std::nullopt;
 }
diff --git a/clang/lib/AST/ByteCode/Descriptor.cpp b/clang/lib/AST/ByteCode/Descriptor.cpp
index 9cc79883474a0..65a51f69ea5bf 100644
--- a/clang/lib/AST/ByteCode/Descriptor.cpp
+++ b/clang/lib/AST/ByteCode/Descriptor.cpp
@@ -15,6 +15,7 @@
 #include "Pointer.h"
 #include "PrimType.h"
 #include "Record.h"
+#include "Reflect.h"
 #include "Source.h"
 #include "clang/AST/ExprCXX.h"
 
diff --git a/clang/lib/AST/ByteCode/Disasm.cpp b/clang/lib/AST/ByteCode/Disasm.cpp
index 6caa33261dad6..efbe4f5bd5beb 100644
--- a/clang/lib/AST/ByteCode/Disasm.cpp
+++ b/clang/lib/AST/ByteCode/Disasm.cpp
@@ -309,6 +309,8 @@ static const char *primTypeToString(PrimType T) {
     return "MemberPtr";
   case PT_FixedPoint:
     return "FixedPoint";
+  case PT_Reflect:
+    return "Reflect";
   }
   llvm_unreachable("Unhandled PrimType");
 }
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 2e7045b39c3db..647e2abe729df 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -16,6 +16,7 @@
 #include "../ExprConstShared.h"
 #include "BitcastBuffer.h"
 #include "Boolean.h"
+#include "Reflect.h"
 #include "DynamicAllocator.h"
 #include "FixedPoint.h"
 #include "Floating.h"
@@ -3732,6 +3733,11 @@ inline bool CheckDestruction(InterpState &S, CodePtr OpPC) {
   return CheckDestructor(S, OpPC, Ptr);
 }
 
+inline bool ReflectValue(InterpState &S, CodePtr OpPC, ReflectionKind Kind, const void *Operand) {
+  S.Stk.push<Reflect>(Kind, Operand);
+  return true;
+}
+
 //===----------------------------------------------------------------------===//
 // Read opcode arguments
 //===----------------------------------------------------------------------===//
diff --git a/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp b/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
index 4bd9c66fc9974..717f85a503f9f 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
@@ -474,7 +474,7 @@ using PrimTypeVariant =
                  Integral<8, false>, Integral<8, true>, Integral<16, false>,
                  Integral<16, true>, Integral<32, false>, Integral<32, true>,
                  Integral<64, false>, Integral<64, true>, IntegralAP<true>,
-                 IntegralAP<false>, Boolean, Floating>;
+                 IntegralAP<false>, Boolean, Floating, Reflect>;
 
 // NB: This implementation isn't exactly ideal, but:
 //   1) We can't just do a bitcast here since we need to be able to
diff --git a/clang/lib/AST/ByteCode/InterpStack.h b/clang/lib/AST/ByteCode/InterpStack.h
index c647dfa6d85ea..648638bf7084e 100644
--- a/clang/lib/AST/ByteCode/InterpStack.h
+++ b/clang/lib/AST/ByteCode/InterpStack.h
@@ -16,6 +16,7 @@
 #include "FixedPoint.h"
 #include "IntegralAP.h"
 #include "MemberPointer.h"
+#include "Reflect.h"
 #include "PrimType.h"
 
 namespace clang {
@@ -207,6 +208,8 @@ class InterpStack final {
       return PT_MemberPtr;
     else if constexpr (std::is_same_v<T, FixedPoint>)
       return PT_FixedPoint;
+    else if constexpr (std::is_same_v<T, Reflect>)
+      return PT_Reflect;
 
     llvm_unreachable("unknown type push()'ed into InterpStack");
   }
diff --git a/clang/lib/AST/ByteCode/InterpState.cpp b/clang/lib/AST/ByteCode/InterpState.cpp
index 2d6ed98e6b52c..f8288420da0fa 100644
--- a/clang/lib/AST/ByteCode/InterpState.cpp
+++ b/clang/lib/AST/ByteCode/InterpState.cpp
@@ -11,6 +11,7 @@
 #include "InterpStack.h"
 #include "Program.h"
 #include "State.h"
+#include "Reflect.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
 
diff --git a/clang/lib/AST/ByteCode/Opcodes.td b/clang/lib/AST/ByteCode/Opcodes.td
index 5e4d0ab2a84af..3e5699c6a93cc 100644
--- a/clang/lib/AST/ByteCode/Opcodes.td
+++ b/clang/lib/AST/ByteCode/Opcodes.td
@@ -31,6 +31,7 @@ def Float : Type;
 def Ptr : Type;
 def MemberPtr : Type;
 def FixedPoint : Type;
+def Reflect : Type;
 
 //===----------------------------------------------------------------------===//
 // Types transferred to the interpreter.
@@ -71,6 +72,8 @@ def ArgDesc : ArgType { let Name = "const Descriptor *"; }
 def ArgPrimType : ArgType { let Name = "PrimType"; }
 def ArgEnumDecl : ArgType { let Name = "const EnumDecl *"; }
 def ArgTypePtr : ArgType { let Name = "const Type *"; }
+def ArgVoidPtr : ArgType { let Name = "const void *"; }
+def ArgReflectionKind : ArgType { let Name = "ReflectionKind"; }
 
 //===----------------------------------------------------------------------===//
 // Classes of types instructions operate on.
@@ -121,7 +124,7 @@ def NonPtrTypeClass : TypeClass {
 }
 
 def AllTypeClass : TypeClass {
-  let Types = !listconcat(AluTypeClass.Types, PtrTypeClass.Types, FloatTypeClass.Types);
+  let Types = !listconcat(AluTypeClass.Types, PtrTypeClass.Types, FloatTypeClass.Types, [Reflect]);
 }
 
 def ComparableTypeClass : TypeClass {
@@ -344,6 +347,10 @@ def CastMemberPtrDerivedPop : Opcode {
   let Args = [ArgSint32, ArgRecordDecl];
 }
 
+def ReflectValue : Opcode {
+  let Args = [ArgReflectionKind, ArgVoidPtr];
+}
+
 def FinishInitPop : Opcode;
 def FinishInit : Opcode;
 def FinishInitActivate : Opcode;
diff --git a/clang/lib/AST/ByteCode/PrimType.cpp b/clang/lib/AST/ByteCode/PrimType.cpp
index b4c1fd0305540..6abc2c19faf97 100644
--- a/clang/lib/AST/ByteCode/PrimType.cpp
+++ b/clang/lib/AST/ByteCode/PrimType.cpp
@@ -8,6 +8,7 @@
 
 #include "PrimType.h"
 #include "Boolean.h"
+#include "Reflect.h"
 #include "FixedPoint.h"
 #include "Floating.h"
 #include "IntegralAP.h"
diff --git a/clang/lib/AST/ByteCode/PrimType.h b/clang/lib/AST/ByteCode/PrimType.h
index 2fa553b7b4a47..2329aeb9261ea 100644
--- a/clang/lib/AST/ByteCode/PrimType.h
+++ b/clang/lib/AST/ByteCode/PrimType.h
@@ -26,6 +26,7 @@ class Boolean;
 class Floating;
 class MemberPointer;
 class FixedPoint;
+class Reflect;
 template <bool Signed> class IntegralAP;
 template <unsigned Bits, bool Signed> class Integral;
 
@@ -46,6 +47,7 @@ enum PrimType : uint8_t {
   PT_Float = 12,
   PT_Ptr = 13,
   PT_MemberPtr = 14,
+  PT_Reflect = 15,
 };
 
 constexpr bool isIntegerOrBoolType(PrimType T) { return T <= PT_Bool; }
@@ -183,6 +185,9 @@ template <> struct PrimConv<PT_MemberPtr> {
 template <> struct PrimConv<PT_FixedPoint> {
   using T = FixedPoint;
 };
+template <> struct PrimConv<PT_Reflect> {
+  using T = Reflect;
+};
 
 /// Returns the size of a primitive type in bytes.
 size_t primSize(PrimType Type);
@@ -228,6 +233,7 @@ static inline bool aligned(const void *P) {
       TYPE_SWITCH_CASE(PT_Ptr, B)                                              \
       TYPE_SWITCH_CASE(PT_MemberPtr, B)                                        \
       TYPE_SWITCH_CASE(PT_FixedPoint, B)                                       \
+      TYPE_SWITCH_CASE(PT_Reflect, B)                                          \
     }                                                                          \
   } while (0)
 
diff --git a/clang/lib/AST/ByteCode/Program.cpp b/clang/lib/AST/ByteCode/Program.cpp
index 2ad5879b4e82a..8712a66610b46 100644
--- a/clang/lib/AST/ByteCode/Program.cpp
+++ b/clang/lib/AST/ByteCode/Program.cpp
@@ -10,6 +10,7 @@
 #include "Context.h"
 #include "Function.h"
 #include "Integral.h"
+#include "Reflect.h"
 #include "PrimType.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
diff --git a/clang/lib/AST/ByteCode/Program.h b/clang/lib/AST/ByteCode/Program.h
index 91126a51e8ddc..9433e7c89263f 100644
--- a/clang/lib/AST/ByteCode/Program.h
+++ b/clang/lib/AST/ByteCode/Program.h
@@ -16,6 +16,7 @@
 #include "Function.h"
 #include "Pointer.h"
 #include "PrimType.h"
+#include "Reflect.h"
 #include "Record.h"
 #include "Source.h"
 #include "llvm/ADT/DenseMap.h"
diff --git a/clang/lib/AST/ByteCode/Reflect.h b/clang/lib/AST/ByteCode/Reflect.h
new file mode 100644
index 0000000000000..aa1d61d4d0c7a
--- /dev/null
+++ b/clang/lib/AST/ByteCode/Reflect.h
@@ -0,0 +1,61 @@
+//===--- Boolean.h - Wrapper for boolean types for the VM -------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_AST_INTERP_REFLECT_H
+#define LLVM_CLANG_AST_INTERP_REFLECT_H
+
+#include "clang/AST/Reflection.h"
+#include "clang/AST/APValue.h"
+#include "clang/AST/ComparisonCategories.h"
+#include "llvm/ADT/APSInt.h"
+#include "llvm/Support/MathExtras.h"
+#include "llvm/Support/raw_ostream.h"
+#include <cstddef>
+#include <cstdint>
+
+namespace clang {
+namespace interp {
+
+class Reflect final {
+private:
+  ReflectionKind Kind;
+  const void *Operand;
+
+public:
+  Reflect() : Kind(ReflectionKind::Type), Operand(nullptr) {}
+  Reflect(ReflectionKind Kind, const void *Operand) : Kind(Kind), Operand(Operand) {}
+
+  ComparisonCategoryResult compare(const Reflect &RHS) const {
+    llvm::FoldingSetNodeID LID, RID;
+    APValue(Kind, Operand).Profile(LID);
+    APValue(RHS.Kind, RHS.Operand).Profile(RID);
+
+    if (LID == RID)
+      return ComparisonCategoryResult::Equal;
+    return ComparisonCategoryResult::Unordered;
+  }
+
+  void print(llvm::raw_ostream &OS) const {
+    OS << "Reflect(" << Kind << ", " << Operand << ")";
+  }
+  APValue toAPValue(const ASTContext &Ctx) const {
+    return APValue(Kind, Operand);
+  }
+
+
+};
+
+inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Reflect &R) {
+  R.print(OS);
+  return OS;
+}
+
+} // namespace interp
+} // namespace clang
+
+#endif

>From ef7bb368535745110245cb4a4403f11f0509e528 Mon Sep 17 00:00:00 2001
From: changkhothuychung <nhat7203 at gmail.com>
Date: Wed, 8 Apr 2026 16:01:53 -0400
Subject: [PATCH 06/23] some small changes

---
 clang/include/clang/AST/APValue.h    |  6 +++---
 clang/include/clang/AST/Reflection.h | 13 ++++++++++++-
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/AST/APValue.h b/clang/include/clang/AST/APValue.h
index d48155de208b6..0f4a2f5b5390c 100644
--- a/clang/include/clang/AST/APValue.h
+++ b/clang/include/clang/AST/APValue.h
@@ -318,7 +318,7 @@ class APValue {
     const AddrLabelExpr *RHSExpr;
   };
   struct ReflectionData {
-    const ReflectionKind OperandKind;
+    ReflectionKind OperandKind;
     const void *Operand;
   };
   struct MemberPointerData;
@@ -726,7 +726,7 @@ class APValue {
     return ((const ReflectionData *)(const char *)&Data)->OperandKind;
   }
 
-  const void *getOpaqueReflectionOperand() const {
+  const void *getReflectionOpaqueOperand() const {
     assert(isReflection() && "Invalid accessor");
     return ((const ReflectionData *)(const char *)&Data)->Operand;
   }
@@ -783,7 +783,7 @@ class APValue {
   void DestroyDataAndMakeUninit();
   void MakeReflection(ReflectionKind OperandKind, const void *Operand) {
     assert(isAbsent() && "Bad state change");
-    new ((void *)(char *)Data.buffer) ReflectionData(OperandKind, Operand);
+    new ((void *)(char *)Data.buffer) ReflectionData{OperandKind, Operand};
     Kind = Reflection;
   }
   void MakeInt() {
diff --git a/clang/include/clang/AST/Reflection.h b/clang/include/clang/AST/Reflection.h
index c50c20a0c5afc..37580e8167a91 100644
--- a/clang/include/clang/AST/Reflection.h
+++ b/clang/include/clang/AST/Reflection.h
@@ -12,11 +12,22 @@
 
 #ifndef LLVM_CLANG_AST_REFLECTION_H
 #define LLVM_CLANG_AST_REFLECTION_H
+
+#include "llvm/Support/raw_ostream.h"
+
 namespace clang {
 
 // TODO(Reflection): Add support for Template, Namespace and DeclRefExpr.
 enum class ReflectionKind { Type };
 
-} // namespace clang
+inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, ReflectionKind Kind) {
+  switch(Kind) {
+  case ReflectionKind::Type:
+    OS << "type";
+  }
 
+  return OS;
+}
+
+} // namespace clang
 #endif

>From c7660cab08d26ad85b3f259e60df4e1445869761 Mon Sep 17 00:00:00 2001
From: changkhothuychung <nhat7203 at gmail.com>
Date: Wed, 8 Apr 2026 16:03:24 -0400
Subject: [PATCH 07/23] update tests

---
 clang/lib/AST/APValue.cpp                                 | 4 ++--
 clang/test/{Parser => Sema}/reflection-meta-info.fail.cpp | 0
 clang/test/{Parser => Sema}/reflection-meta-info.pass.cpp | 4 ++++
 3 files changed, 6 insertions(+), 2 deletions(-)
 rename clang/test/{Parser => Sema}/reflection-meta-info.fail.cpp (100%)
 rename clang/test/{Parser => Sema}/reflection-meta-info.pass.cpp (93%)

diff --git a/clang/lib/AST/APValue.cpp b/clang/lib/AST/APValue.cpp
index 03b45bd3dc461..66dd3f82d3c15 100644
--- a/clang/lib/AST/APValue.cpp
+++ b/clang/lib/AST/APValue.cpp
@@ -375,7 +375,7 @@ APValue::APValue(const APValue &RHS)
     break;
   case Reflection:
     MakeReflection(RHS.getReflectionOperandKind(),
-                   RHS.getOpaqueReflectionOperand());
+                   RHS.getReflectionOpaqueOperand());
     break;
   }
 }
@@ -497,7 +497,7 @@ static void profileReflection(llvm::FoldingSetNodeID &ID, APValue V) {
   switch (V.getReflectionOperandKind()) {
   case ReflectionKind::Type: {
     const TypeSourceInfo *info =
-        static_cast<const TypeSourceInfo *>(V.getOpaqueReflectionOperand());
+        static_cast<const TypeSourceInfo *>(V.getReflectionOpaqueOperand());
     ID.AddPointer((info->getType().getCanonicalType().getAsOpaquePtr()));
     return;
   }
diff --git a/clang/test/Parser/reflection-meta-info.fail.cpp b/clang/test/Sema/reflection-meta-info.fail.cpp
similarity index 100%
rename from clang/test/Parser/reflection-meta-info.fail.cpp
rename to clang/test/Sema/reflection-meta-info.fail.cpp
diff --git a/clang/test/Parser/reflection-meta-info.pass.cpp b/clang/test/Sema/reflection-meta-info.pass.cpp
similarity index 93%
rename from clang/test/Parser/reflection-meta-info.pass.cpp
rename to clang/test/Sema/reflection-meta-info.pass.cpp
index 843227000bcec..d12c2c8c8620c 100644
--- a/clang/test/Parser/reflection-meta-info.pass.cpp
+++ b/clang/test/Sema/reflection-meta-info.pass.cpp
@@ -19,6 +19,7 @@ consteval void test()
     static_assert(__is_same(decltype(^^unsigned int), info));
     static_assert(__is_same(decltype(^^unsigned long), info));
     static_assert(__is_same(decltype(^^unsigned long long), info));
+    static_assert(__is_same(decltype(^^info), info));
 
     static_assert(__is_same(decltype(^^int), decltype(^^int)));
     static_assert(__is_same(decltype(^^int), decltype(^^float)));
@@ -36,4 +37,7 @@ consteval void test()
     static_assert(^^float != ^^int);
     static_assert(!(^^float == ^^int));
     static_assert(r == q);
+
+    int a;
+    static_assert(^^int == ^^decltype(a));
 }

>From edf25a358be7bac8c570bbed59a44e3ec6b9c528 Mon Sep 17 00:00:00 2001
From: changkhothuychung <nhat7203 at gmail.com>
Date: Wed, 8 Apr 2026 16:09:18 -0400
Subject: [PATCH 08/23] clang format

---
 clang/lib/AST/ByteCode/PrimType.cpp |  2 +-
 clang/lib/AST/ByteCode/Program.cpp  | 36 ++++++++++++++---------------
 clang/lib/AST/ByteCode/Program.h    |  2 +-
 clang/lib/AST/ByteCode/Reflect.h    |  7 +++---
 4 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/clang/lib/AST/ByteCode/PrimType.cpp b/clang/lib/AST/ByteCode/PrimType.cpp
index 6abc2c19faf97..3ec3044bd289b 100644
--- a/clang/lib/AST/ByteCode/PrimType.cpp
+++ b/clang/lib/AST/ByteCode/PrimType.cpp
@@ -8,12 +8,12 @@
 
 #include "PrimType.h"
 #include "Boolean.h"
-#include "Reflect.h"
 #include "FixedPoint.h"
 #include "Floating.h"
 #include "IntegralAP.h"
 #include "MemberPointer.h"
 #include "Pointer.h"
+#include "Reflect.h"
 
 using namespace clang;
 using namespace clang::interp;
diff --git a/clang/lib/AST/ByteCode/Program.cpp b/clang/lib/AST/ByteCode/Program.cpp
index 8712a66610b46..1cefa68dce884 100644
--- a/clang/lib/AST/ByteCode/Program.cpp
+++ b/clang/lib/AST/ByteCode/Program.cpp
@@ -10,8 +10,8 @@
 #include "Context.h"
 #include "Function.h"
 #include "Integral.h"
-#include "Reflect.h"
 #include "PrimType.h"
+#include "Reflect.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
@@ -426,17 +426,17 @@ Descriptor *Program::createDescriptor(const DeclTy &D, const Type *Ty,
         return allocateDescriptor(D, *T, MDSize, NumElems, IsConst, IsTemporary,
                                   IsMutable);
       }
-        // Arrays of composites. In this case, the array is a list of pointers,
-        // followed by the actual elements.
-        const Descriptor *ElemDesc = createDescriptor(
-            D, ElemTy.getTypePtr(), std::nullopt, IsConst, IsTemporary);
-        if (!ElemDesc)
-          return nullptr;
-        unsigned ElemSize = ElemDesc->getAllocSize() + sizeof(InlineDescriptor);
-        if (std::numeric_limits<unsigned>::max() / ElemSize <= NumElems)
-          return nullptr;
-        return allocateDescriptor(D, Ty, ElemDesc, MDSize, NumElems, IsConst,
-                                  IsTemporary, IsMutable);
+      // Arrays of composites. In this case, the array is a list of pointers,
+      // followed by the actual elements.
+      const Descriptor *ElemDesc = createDescriptor(
+          D, ElemTy.getTypePtr(), std::nullopt, IsConst, IsTemporary);
+      if (!ElemDesc)
+        return nullptr;
+      unsigned ElemSize = ElemDesc->getAllocSize() + sizeof(InlineDescriptor);
+      if (std::numeric_limits<unsigned>::max() / ElemSize <= NumElems)
+        return nullptr;
+      return allocateDescriptor(D, Ty, ElemDesc, MDSize, NumElems, IsConst,
+                                IsTemporary, IsMutable);
     }
 
     // Array of unknown bounds - cannot be accessed and pointer arithmetic
@@ -447,12 +447,12 @@ Descriptor *Program::createDescriptor(const DeclTy &D, const Type *Ty,
         return allocateDescriptor(D, *T, MDSize, IsConst, IsTemporary,
                                   Descriptor::UnknownSize{});
       }
-        const Descriptor *Desc = createDescriptor(
-            D, ElemTy.getTypePtr(), std::nullopt, IsConst, IsTemporary);
-        if (!Desc)
-          return nullptr;
-        return allocateDescriptor(D, Desc, MDSize, IsTemporary,
-                                  Descriptor::UnknownSize{});
+      const Descriptor *Desc = createDescriptor(
+          D, ElemTy.getTypePtr(), std::nullopt, IsConst, IsTemporary);
+      if (!Desc)
+        return nullptr;
+      return allocateDescriptor(D, Desc, MDSize, IsTemporary,
+                                Descriptor::UnknownSize{});
     }
   }
 
diff --git a/clang/lib/AST/ByteCode/Program.h b/clang/lib/AST/ByteCode/Program.h
index 9433e7c89263f..573579c76e01d 100644
--- a/clang/lib/AST/ByteCode/Program.h
+++ b/clang/lib/AST/ByteCode/Program.h
@@ -16,8 +16,8 @@
 #include "Function.h"
 #include "Pointer.h"
 #include "PrimType.h"
-#include "Reflect.h"
 #include "Record.h"
+#include "Reflect.h"
 #include "Source.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/Support/Allocator.h"
diff --git a/clang/lib/AST/ByteCode/Reflect.h b/clang/lib/AST/ByteCode/Reflect.h
index aa1d61d4d0c7a..05a3de7225487 100644
--- a/clang/lib/AST/ByteCode/Reflect.h
+++ b/clang/lib/AST/ByteCode/Reflect.h
@@ -9,9 +9,9 @@
 #ifndef LLVM_CLANG_AST_INTERP_REFLECT_H
 #define LLVM_CLANG_AST_INTERP_REFLECT_H
 
-#include "clang/AST/Reflection.h"
 #include "clang/AST/APValue.h"
 #include "clang/AST/ComparisonCategories.h"
+#include "clang/AST/Reflection.h"
 #include "llvm/ADT/APSInt.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/raw_ostream.h"
@@ -28,7 +28,8 @@ class Reflect final {
 
 public:
   Reflect() : Kind(ReflectionKind::Type), Operand(nullptr) {}
-  Reflect(ReflectionKind Kind, const void *Operand) : Kind(Kind), Operand(Operand) {}
+  Reflect(ReflectionKind Kind, const void *Operand)
+      : Kind(Kind), Operand(Operand) {}
 
   ComparisonCategoryResult compare(const Reflect &RHS) const {
     llvm::FoldingSetNodeID LID, RID;
@@ -46,8 +47,6 @@ class Reflect final {
   APValue toAPValue(const ASTContext &Ctx) const {
     return APValue(Kind, Operand);
   }
-
-
 };
 
 inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Reflect &R) {

>From 819ea4ea75d2641911aa5600ddefb0b97bd11c05 Mon Sep 17 00:00:00 2001
From: changkhothuychung <nhat7203 at gmail.com>
Date: Wed, 8 Apr 2026 16:14:11 -0400
Subject: [PATCH 09/23] clang format

---
 clang/include/clang/AST/Reflection.h   |  5 ++--
 clang/lib/AST/ByteCode/Compiler.cpp    | 40 +++++++++++++-------------
 clang/lib/AST/ByteCode/Interp.h        | 38 ++++++++++++------------
 clang/lib/AST/ByteCode/InterpStack.h   |  2 +-
 clang/lib/AST/ByteCode/InterpState.cpp |  2 +-
 5 files changed, 45 insertions(+), 42 deletions(-)

diff --git a/clang/include/clang/AST/Reflection.h b/clang/include/clang/AST/Reflection.h
index 37580e8167a91..a1bd781d39808 100644
--- a/clang/include/clang/AST/Reflection.h
+++ b/clang/include/clang/AST/Reflection.h
@@ -20,8 +20,9 @@ namespace clang {
 // TODO(Reflection): Add support for Template, Namespace and DeclRefExpr.
 enum class ReflectionKind { Type };
 
-inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, ReflectionKind Kind) {
-  switch(Kind) {
+inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
+                                     ReflectionKind Kind) {
+  switch (Kind) {
   case ReflectionKind::Type:
     OS << "type";
   }
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index 3755e54ebecfb..c2f48200a102e 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -4248,10 +4248,10 @@ bool Compiler<Emitter>::VisitCXXReflectExpr(const CXXReflectExpr *E) {
     return true;
 
   switch (E->getKind()) {
-    case ReflectionKind::Type: {
-      APValue Result(ReflectionKind::Type, E->getOpaqueValue());
-      return this->emitReflectValue(E->getKind(), E->getOpaqueValue(), E);
-    }
+  case ReflectionKind::Type: {
+    APValue Result(ReflectionKind::Type, E->getOpaqueValue());
+    return this->emitReflectValue(E->getKind(), E->getOpaqueValue(), E);
+  }
   }
 
   return false;
@@ -6173,28 +6173,28 @@ bool Compiler<Emitter>::visitWhileStmt(const WhileStmt *S) {
       return false;
   }
 
-    if (!this->visitBool(Cond))
-      return false;
+  if (!this->visitBool(Cond))
+    return false;
 
-    if (!this->maybeEmitDeferredVarInit(S->getConditionVariable()))
-      return false;
+  if (!this->maybeEmitDeferredVarInit(S->getConditionVariable()))
+    return false;
 
-    if (!this->jumpFalse(EndLabel, S))
-      return false;
+  if (!this->jumpFalse(EndLabel, S))
+    return false;
 
-    if (!this->visitStmt(Body))
-      return false;
+  if (!this->visitStmt(Body))
+    return false;
 
-    if (!CondScope.destroyLocals())
-      return false;
-    // } End of loop body.
+  if (!CondScope.destroyLocals())
+    return false;
+  // } End of loop body.
 
-    if (!this->jump(CondLabel, S))
-      return false;
-    this->fallthrough(EndLabel);
-    this->emitLabel(EndLabel);
+  if (!this->jump(CondLabel, S))
+    return false;
+  this->fallthrough(EndLabel);
+  this->emitLabel(EndLabel);
 
-    return CondScope.destroyLocals() && WholeLoopScope.destroyLocals();
+  return CondScope.destroyLocals() && WholeLoopScope.destroyLocals();
 }
 
 template <class Emitter> bool Compiler<Emitter>::visitDoStmt(const DoStmt *S) {
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 647e2abe729df..26a27183ca19c 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -16,7 +16,6 @@
 #include "../ExprConstShared.h"
 #include "BitcastBuffer.h"
 #include "Boolean.h"
-#include "Reflect.h"
 #include "DynamicAllocator.h"
 #include "FixedPoint.h"
 #include "Floating.h"
@@ -29,6 +28,7 @@
 #include "MemberPointer.h"
 #include "PrimType.h"
 #include "Program.h"
+#include "Reflect.h"
 #include "State.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Expr.h"
@@ -2914,9 +2914,9 @@ inline bool DoShift(InterpState &S, CodePtr OpPC, LT &LHS, RT &RHS,
 
     RHS = RHS.isMin() ? RT(APSInt::getMaxValue(RHS.bitWidth(), false)) : -RHS;
 
-    return DoShift<LT, RT,
-                   Dir == ShiftDir::Left ? ShiftDir::Right : ShiftDir::Left>(
-        S, OpPC, LHS, RHS, Result);
+    return DoShift < LT, RT,
+           Dir == ShiftDir::Left ? ShiftDir::Right
+                                 : ShiftDir::Left > (S, OpPC, LHS, RHS, Result);
   }
 
   if (!CheckShift<Dir>(S, OpPC, LHS, RHS, Bits))
@@ -2959,16 +2959,16 @@ inline bool DoShift(InterpState &S, CodePtr OpPC, LT &LHS, RT &RHS,
     return true;
   }
 
-    // Right shift.
-    if (Compare(RHS, RT::from(MaxShiftAmount, RHS.bitWidth())) ==
-        ComparisonCategoryResult::Greater) {
-      R = LT::AsUnsigned::from(-1);
-    } else {
-      // Do the shift on potentially signed LT, then convert to unsigned type.
-      LT A;
-      LT::shiftRight(LHS, LT::from(RHS, Bits), Bits, &A);
-      R = LT::AsUnsigned::from(A);
-    }
+  // Right shift.
+  if (Compare(RHS, RT::from(MaxShiftAmount, RHS.bitWidth())) ==
+      ComparisonCategoryResult::Greater) {
+    R = LT::AsUnsigned::from(-1);
+  } else {
+    // Do the shift on potentially signed LT, then convert to unsigned type.
+    LT A;
+    LT::shiftRight(LHS, LT::from(RHS, Bits), Bits, &A);
+    R = LT::AsUnsigned::from(A);
+  }
 
   S.Stk.push<LT>(LT::from(R));
   return true;
@@ -2993,9 +2993,10 @@ inline bool DoShiftAP(InterpState &S, CodePtr OpPC, const APSInt &LHS,
     S.CCEDiag(Loc, diag::note_constexpr_negative_shift) << RHS; //.toAPSInt();
     if (!S.noteUndefinedBehavior())
       return false;
-    return DoShiftAP<LT, RT,
-                     Dir == ShiftDir::Left ? ShiftDir::Right : ShiftDir::Left>(
-        S, OpPC, LHS, -RHS, Result);
+    return DoShiftAP < LT, RT,
+           Dir == ShiftDir::Left
+               ? ShiftDir::Right
+               : ShiftDir::Left > (S, OpPC, LHS, -RHS, Result);
   }
 
   if (!CheckShift<Dir>(S, OpPC, static_cast<LT>(LHS), static_cast<RT>(RHS),
@@ -3733,7 +3734,8 @@ inline bool CheckDestruction(InterpState &S, CodePtr OpPC) {
   return CheckDestructor(S, OpPC, Ptr);
 }
 
-inline bool ReflectValue(InterpState &S, CodePtr OpPC, ReflectionKind Kind, const void *Operand) {
+inline bool ReflectValue(InterpState &S, CodePtr OpPC, ReflectionKind Kind,
+                         const void *Operand) {
   S.Stk.push<Reflect>(Kind, Operand);
   return true;
 }
diff --git a/clang/lib/AST/ByteCode/InterpStack.h b/clang/lib/AST/ByteCode/InterpStack.h
index 648638bf7084e..9b8468a632d27 100644
--- a/clang/lib/AST/ByteCode/InterpStack.h
+++ b/clang/lib/AST/ByteCode/InterpStack.h
@@ -16,8 +16,8 @@
 #include "FixedPoint.h"
 #include "IntegralAP.h"
 #include "MemberPointer.h"
-#include "Reflect.h"
 #include "PrimType.h"
+#include "Reflect.h"
 
 namespace clang {
 namespace interp {
diff --git a/clang/lib/AST/ByteCode/InterpState.cpp b/clang/lib/AST/ByteCode/InterpState.cpp
index f8288420da0fa..578f32b3ae645 100644
--- a/clang/lib/AST/ByteCode/InterpState.cpp
+++ b/clang/lib/AST/ByteCode/InterpState.cpp
@@ -10,8 +10,8 @@
 #include "InterpFrame.h"
 #include "InterpStack.h"
 #include "Program.h"
-#include "State.h"
 #include "Reflect.h"
+#include "State.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
 

>From 3cb9ab2c1a5624c8bc620306487c163d25c7fcf5 Mon Sep 17 00:00:00 2001
From: changkhothuychung <nhat7203 at gmail.com>
Date: Wed, 8 Apr 2026 17:01:47 -0400
Subject: [PATCH 10/23] revert errornerous change

---
 clang/lib/AST/ByteCode/Interp.h | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 26a27183ca19c..73b0b6248a7ad 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -2914,9 +2914,9 @@ inline bool DoShift(InterpState &S, CodePtr OpPC, LT &LHS, RT &RHS,
 
     RHS = RHS.isMin() ? RT(APSInt::getMaxValue(RHS.bitWidth(), false)) : -RHS;
 
-    return DoShift < LT, RT,
-           Dir == ShiftDir::Left ? ShiftDir::Right
-                                 : ShiftDir::Left > (S, OpPC, LHS, RHS, Result);
+    return DoShift<LT, RT,
+                   Dir == ShiftDir::Left ? ShiftDir::Right : ShiftDir::Left>(
+        S, OpPC, LHS, RHS, Result);
   }
 
   if (!CheckShift<Dir>(S, OpPC, LHS, RHS, Bits))
@@ -2993,10 +2993,9 @@ inline bool DoShiftAP(InterpState &S, CodePtr OpPC, const APSInt &LHS,
     S.CCEDiag(Loc, diag::note_constexpr_negative_shift) << RHS; //.toAPSInt();
     if (!S.noteUndefinedBehavior())
       return false;
-    return DoShiftAP < LT, RT,
-           Dir == ShiftDir::Left
-               ? ShiftDir::Right
-               : ShiftDir::Left > (S, OpPC, LHS, -RHS, Result);
+    return DoShiftAP<LT, RT,
+                     Dir == ShiftDir::Left ? ShiftDir::Right : ShiftDir::Left>(
+        S, OpPC, LHS, -RHS, Result);
   }
 
   if (!CheckShift<Dir>(S, OpPC, static_cast<LT>(LHS), static_cast<RT>(RHS),

>From bc7a99488164e29783e16d566dc898831a3242f7 Mon Sep 17 00:00:00 2001
From: changkhothuychung <nhat7203 at gmail.com>
Date: Wed, 8 Apr 2026 17:06:48 -0400
Subject: [PATCH 11/23] revert clang format

---
 clang/include/clang/AST/APValue.h | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/clang/include/clang/AST/APValue.h b/clang/include/clang/AST/APValue.h
index 0f4a2f5b5390c..50013529d7ebd 100644
--- a/clang/include/clang/AST/APValue.h
+++ b/clang/include/clang/AST/APValue.h
@@ -28,18 +28,18 @@ namespace serialization {
 template <typename T> class BasicReaderBase;
 } // end namespace serialization
 
-class AddrLabelExpr;
-class ASTContext;
-class CharUnits;
-class CXXRecordDecl;
-class Decl;
-class DiagnosticBuilder;
-class Expr;
-class FieldDecl;
-struct PrintingPolicy;
-class Type;
-class ValueDecl;
-class QualType;
+  class AddrLabelExpr;
+  class ASTContext;
+  class CharUnits;
+  class CXXRecordDecl;
+  class Decl;
+  class DiagnosticBuilder;
+  class Expr;
+  class FieldDecl;
+  struct PrintingPolicy;
+  class Type;
+  class ValueDecl;
+  class QualType;
 
 /// Symbolic representation of typeid(T) for some type T.
 class TypeInfoLValue {

>From 22bcd2c8b2a2454260f31384555e8c58592cf6e5 Mon Sep 17 00:00:00 2001
From: changkhothuychung <nhat7203 at gmail.com>
Date: Wed, 8 Apr 2026 17:13:18 -0400
Subject: [PATCH 12/23] revert wrong clang format

---
 clang/include/clang/AST/APValue.h | 97 +++++++++++++++----------------
 1 file changed, 47 insertions(+), 50 deletions(-)

diff --git a/clang/include/clang/AST/APValue.h b/clang/include/clang/AST/APValue.h
index 50013529d7ebd..2492dd4847b3e 100644
--- a/clang/include/clang/AST/APValue.h
+++ b/clang/include/clang/AST/APValue.h
@@ -55,7 +55,7 @@ class TypeInfoLValue {
   const void *getOpaqueValue() const { return T; }
   static TypeInfoLValue getFromOpaqueValue(const void *Value) {
     TypeInfoLValue V;
-    V.T = reinterpret_cast<const Type *>(Value);
+    V.T = reinterpret_cast<const Type*>(Value);
     return V;
   }
 
@@ -89,10 +89,10 @@ class DynamicAllocLValue {
 
   static constexpr int NumLowBitsAvailable = 3;
 };
-} // namespace clang
+}
 
 namespace llvm {
-template <> struct PointerLikeTypeTraits<clang::TypeInfoLValue> {
+template<> struct PointerLikeTypeTraits<clang::TypeInfoLValue> {
   static const void *getAsVoidPointer(clang::TypeInfoLValue V) {
     return V.getOpaqueValue();
   }
@@ -104,7 +104,7 @@ template <> struct PointerLikeTypeTraits<clang::TypeInfoLValue> {
   static constexpr int NumLowBitsAvailable = 3;
 };
 
-template <> struct PointerLikeTypeTraits<clang::DynamicAllocLValue> {
+template<> struct PointerLikeTypeTraits<clang::DynamicAllocLValue> {
   static const void *getAsVoidPointer(clang::DynamicAllocLValue V) {
     return V.getOpaqueValue();
   }
@@ -114,7 +114,7 @@ template <> struct PointerLikeTypeTraits<clang::DynamicAllocLValue> {
   static constexpr int NumLowBitsAvailable =
       clang::DynamicAllocLValue::NumLowBitsAvailable;
 };
-} // namespace llvm
+}
 
 namespace clang {
 /// APValue - This class implements a discriminated union of [uninitialized]
@@ -124,7 +124,6 @@ class APValue {
   typedef llvm::APFixedPoint APFixedPoint;
   typedef llvm::APSInt APSInt;
   typedef llvm::APFloat APFloat;
-
 public:
   enum ValueKind {
     /// There is no such object (it's outside its lifetime).
@@ -314,20 +313,19 @@ class APValue {
     ~UnionData();
   };
   struct AddrLabelDiffData {
-    const AddrLabelExpr *LHSExpr;
-    const AddrLabelExpr *RHSExpr;
+    const AddrLabelExpr* LHSExpr;
+    const AddrLabelExpr* RHSExpr;
   };
   struct ReflectionData {
-    ReflectionKind OperandKind;
+    const ReflectionKind OperandKind;
     const void *Operand;
   };
   struct MemberPointerData;
 
   // We ensure elsewhere that Data is big enough for LV and MemberPointerData.
-  typedef llvm::AlignedCharArrayUnion<
-      void *, APSInt, APFloat, ComplexAPSInt, ComplexAPFloat, Vec, Mat, Arr,
-      StructData, UnionData, AddrLabelDiffData, ReflectionData>
-      DataType;
+  typedef llvm::AlignedCharArrayUnion<void *, APSInt, APFloat, ComplexAPSInt,
+                                      ComplexAPFloat, Vec, Mat, Arr, StructData,
+                                      UnionData, AddrLabelDiffData, ReflectionData> DataType;
   static const size_t DataSize = sizeof(DataType);
 
   DataType Data;
@@ -343,13 +341,11 @@ class APValue {
   APValue() : Kind(None), AllowConstexprUnknown(false) {}
   /// Creates an integer APValue holding the given value.
   explicit APValue(APSInt I) : Kind(None), AllowConstexprUnknown(false) {
-    MakeInt();
-    setInt(std::move(I));
+    MakeInt(); setInt(std::move(I));
   }
   /// Creates a float APValue holding the given value.
   explicit APValue(APFloat F) : Kind(None), AllowConstexprUnknown(false) {
-    MakeFloat();
-    setFloat(std::move(F));
+    MakeFloat(); setFloat(std::move(F));
   }
   /// Creates a fixed-point APValue holding the given value.
   explicit APValue(APFixedPoint FX) : Kind(None), AllowConstexprUnknown(false) {
@@ -359,8 +355,7 @@ class APValue {
   /// are read from \p E.
   explicit APValue(const APValue *E, unsigned N)
       : Kind(None), AllowConstexprUnknown(false) {
-    MakeVector();
-    setVector(E, N);
+    MakeVector(); setVector(E, N);
   }
   /// Creates a matrix APValue with given dimensions. The elements
   /// are read from \p E and assumed to be in row-major order.
@@ -372,13 +367,11 @@ class APValue {
   /// Creates an integer complex APValue with the given real and imaginary
   /// values.
   APValue(APSInt R, APSInt I) : Kind(None), AllowConstexprUnknown(false) {
-    MakeComplexInt();
-    setComplexInt(std::move(R), std::move(I));
+    MakeComplexInt(); setComplexInt(std::move(R), std::move(I));
   }
   /// Creates a float complex APValue with the given real and imaginary values.
   APValue(APFloat R, APFloat I) : Kind(None), AllowConstexprUnknown(false) {
-    MakeComplexFloat();
-    setComplexFloat(std::move(R), std::move(I));
+    MakeComplexFloat(); setComplexFloat(std::move(R), std::move(I));
   }
   APValue(const APValue &RHS);
   APValue(APValue &&RHS);
@@ -430,7 +423,8 @@ class APValue {
   /// Creates a new Reflection APValue.
   /// \param OperandKind The kind of reflection.
   /// \param Operand The entity being reflected.
-  APValue(ReflectionKind OperandKind, const void *Operand) : Kind(None) {
+  APValue(ReflectionKind OperandKind, const void *Operand)
+      : Kind(None) {
     MakeReflection(OperandKind, Operand);
   }
 
@@ -465,8 +459,7 @@ class APValue {
   /// \param RHSExpr The right-hand side of the difference.
   APValue(const AddrLabelExpr *LHSExpr, const AddrLabelExpr *RHSExpr)
       : Kind(None), AllowConstexprUnknown(false) {
-    MakeAddrLabelDiff();
-    setAddrLabelDiff(LHSExpr, RHSExpr);
+    MakeAddrLabelDiff(); setAddrLabelDiff(LHSExpr, RHSExpr);
   }
   static APValue IndeterminateValue() {
     APValue Result;
@@ -531,7 +524,9 @@ class APValue {
     assert(isInt() && "Invalid accessor");
     return *(APSInt *)(char *)&Data;
   }
-  const APSInt &getInt() const { return const_cast<APValue *>(this)->getInt(); }
+  const APSInt &getInt() const {
+    return const_cast<APValue*>(this)->getInt();
+  }
 
   /// Try to convert this value to an integral constant. This works if it's an
   /// integer, null pointer, or offset from a null pointer. Returns true on
@@ -544,7 +539,7 @@ class APValue {
     return *(APFloat *)(char *)&Data;
   }
   const APFloat &getFloat() const {
-    return const_cast<APValue *>(this)->getFloat();
+    return const_cast<APValue*>(this)->getFloat();
   }
 
   APFixedPoint &getFixedPoint() {
@@ -560,7 +555,7 @@ class APValue {
     return ((ComplexAPSInt *)(char *)&Data)->Real;
   }
   const APSInt &getComplexIntReal() const {
-    return const_cast<APValue *>(this)->getComplexIntReal();
+    return const_cast<APValue*>(this)->getComplexIntReal();
   }
 
   APSInt &getComplexIntImag() {
@@ -568,7 +563,7 @@ class APValue {
     return ((ComplexAPSInt *)(char *)&Data)->Imag;
   }
   const APSInt &getComplexIntImag() const {
-    return const_cast<APValue *>(this)->getComplexIntImag();
+    return const_cast<APValue*>(this)->getComplexIntImag();
   }
 
   APFloat &getComplexFloatReal() {
@@ -576,7 +571,7 @@ class APValue {
     return ((ComplexAPFloat *)(char *)&Data)->Real;
   }
   const APFloat &getComplexFloatReal() const {
-    return const_cast<APValue *>(this)->getComplexFloatReal();
+    return const_cast<APValue*>(this)->getComplexFloatReal();
   }
 
   APFloat &getComplexFloatImag() {
@@ -584,13 +579,13 @@ class APValue {
     return ((ComplexAPFloat *)(char *)&Data)->Imag;
   }
   const APFloat &getComplexFloatImag() const {
-    return const_cast<APValue *>(this)->getComplexFloatImag();
+    return const_cast<APValue*>(this)->getComplexFloatImag();
   }
 
   const LValueBase getLValueBase() const;
   CharUnits &getLValueOffset();
   const CharUnits &getLValueOffset() const {
-    return const_cast<APValue *>(this)->getLValueOffset();
+    return const_cast<APValue*>(this)->getLValueOffset();
   }
   bool isLValueOnePastTheEnd() const;
   bool hasLValuePath() const;
@@ -605,7 +600,7 @@ class APValue {
     return ((Vec *)(char *)&Data)->Elts[I];
   }
   const APValue &getVectorElt(unsigned I) const {
-    return const_cast<APValue *>(this)->getVectorElt(I);
+    return const_cast<APValue*>(this)->getVectorElt(I);
   }
   unsigned getVectorLength() const {
     assert(isVector() && "Invalid accessor");
@@ -649,7 +644,7 @@ class APValue {
     return ((Arr *)(char *)&Data)->Elts[I];
   }
   const APValue &getArrayInitializedElt(unsigned I) const {
-    return const_cast<APValue *>(this)->getArrayInitializedElt(I);
+    return const_cast<APValue*>(this)->getArrayInitializedElt(I);
   }
   bool hasArrayFiller() const {
     return getArrayInitializedElts() != getArraySize();
@@ -660,7 +655,7 @@ class APValue {
     return ((Arr *)(char *)&Data)->Elts[getArrayInitializedElts()];
   }
   const APValue &getArrayFiller() const {
-    return const_cast<APValue *>(this)->getArrayFiller();
+    return const_cast<APValue*>(this)->getArrayFiller();
   }
   unsigned getArrayInitializedElts() const {
     assert(isArray() && "Invalid accessor");
@@ -690,10 +685,10 @@ class APValue {
     return ((StructData *)(char *)&Data)->Elts[getStructNumBases() + i];
   }
   const APValue &getStructBase(unsigned i) const {
-    return const_cast<APValue *>(this)->getStructBase(i);
+    return const_cast<APValue*>(this)->getStructBase(i);
   }
   const APValue &getStructField(unsigned i) const {
-    return const_cast<APValue *>(this)->getStructField(i);
+    return const_cast<APValue*>(this)->getStructField(i);
   }
 
   const FieldDecl *getUnionField() const {
@@ -705,18 +700,18 @@ class APValue {
     return *((UnionData *)(char *)&Data)->Value;
   }
   const APValue &getUnionValue() const {
-    return const_cast<APValue *>(this)->getUnionValue();
+    return const_cast<APValue*>(this)->getUnionValue();
   }
 
   const ValueDecl *getMemberPointerDecl() const;
   bool isMemberPointerToDerivedMember() const;
-  ArrayRef<const CXXRecordDecl *> getMemberPointerPath() const;
+  ArrayRef<const CXXRecordDecl*> getMemberPointerPath() const;
 
-  const AddrLabelExpr *getAddrLabelDiffLHS() const {
+  const AddrLabelExpr* getAddrLabelDiffLHS() const {
     assert(isAddrLabelDiff() && "Invalid accessor");
     return ((const AddrLabelDiffData *)(const char *)&Data)->LHSExpr;
   }
-  const AddrLabelExpr *getAddrLabelDiffRHS() const {
+  const AddrLabelExpr* getAddrLabelDiffRHS() const {
     assert(isAddrLabelDiff() && "Invalid accessor");
     return ((const AddrLabelDiffData *)(const char *)&Data)->RHSExpr;
   }
@@ -726,7 +721,7 @@ class APValue {
     return ((const ReflectionData *)(const char *)&Data)->OperandKind;
   }
 
-  const void *getReflectionOpaqueOperand() const {
+  const void* getOpaqueReflectionOperand() const {
     assert(isReflection() && "Invalid accessor");
     return ((const ReflectionData *)(const char *)&Data)->Operand;
   }
@@ -773,17 +768,19 @@ class APValue {
                  ArrayRef<LValuePathEntry> Path, bool OnePastTheEnd,
                  bool IsNullPtr);
   void setUnion(const FieldDecl *Field, const APValue &Value);
-  void setAddrLabelDiff(const AddrLabelExpr *LHSExpr,
-                        const AddrLabelExpr *RHSExpr) {
+  void setAddrLabelDiff(const AddrLabelExpr* LHSExpr,
+                        const AddrLabelExpr* RHSExpr) {
     ((AddrLabelDiffData *)(char *)&Data)->LHSExpr = LHSExpr;
     ((AddrLabelDiffData *)(char *)&Data)->RHSExpr = RHSExpr;
   }
 
 private:
   void DestroyDataAndMakeUninit();
-  void MakeReflection(ReflectionKind OperandKind, const void *Operand) {
+  void MakeReflection(ReflectionKind OperandKind,
+                      const void *Operand) {
     assert(isAbsent() && "Bad state change");
-    new ((void *)(char *)Data.buffer) ReflectionData{OperandKind, Operand};
+    new ((void *)(char *)Data.buffer) ReflectionData(
+            OperandKind, Operand);
     Kind = Reflection;
   }
   void MakeInt() {
@@ -834,7 +831,7 @@ class APValue {
     Kind = Union;
   }
   void MakeMemberPointer(const ValueDecl *Member, bool IsDerivedMember,
-                         ArrayRef<const CXXRecordDecl *> Path);
+                         ArrayRef<const CXXRecordDecl*> Path);
   void MakeAddrLabelDiff() {
     assert(isAbsent() && "Bad state change");
     new ((void *)(char *)&Data) AddrLabelDiffData();
@@ -872,13 +869,13 @@ class APValue {
 } // end namespace clang.
 
 namespace llvm {
-template <> struct DenseMapInfo<clang::APValue::LValueBase> {
+template<> struct DenseMapInfo<clang::APValue::LValueBase> {
   static clang::APValue::LValueBase getEmptyKey();
   static clang::APValue::LValueBase getTombstoneKey();
   static unsigned getHashValue(const clang::APValue::LValueBase &Base);
   static bool isEqual(const clang::APValue::LValueBase &LHS,
                       const clang::APValue::LValueBase &RHS);
 };
-} // namespace llvm
+}
 
 #endif

>From c45266eb35f3e54db2f3beb09237775a38235f78 Mon Sep 17 00:00:00 2001
From: changkhothuychung <nhat7203 at gmail.com>
Date: Wed, 8 Apr 2026 17:14:42 -0400
Subject: [PATCH 13/23] update function name

---
 clang/include/clang/AST/APValue.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/AST/APValue.h b/clang/include/clang/AST/APValue.h
index 2492dd4847b3e..751ee12c9017d 100644
--- a/clang/include/clang/AST/APValue.h
+++ b/clang/include/clang/AST/APValue.h
@@ -721,7 +721,7 @@ class APValue {
     return ((const ReflectionData *)(const char *)&Data)->OperandKind;
   }
 
-  const void* getOpaqueReflectionOperand() const {
+  const void* getReflectionOpaqueOperand() const {
     assert(isReflection() && "Invalid accessor");
     return ((const ReflectionData *)(const char *)&Data)->Operand;
   }

>From a5c43cdaba19c56b86675743feef1fbae0884cfd Mon Sep 17 00:00:00 2001
From: changkhothuychung <nhat7203 at gmail.com>
Date: Wed, 8 Apr 2026 17:18:03 -0400
Subject: [PATCH 14/23] revert clang format

---
 clang/include/clang/AST/ExprCXX.h | 111 ++++++++++++++++--------------
 1 file changed, 61 insertions(+), 50 deletions(-)

diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h
index 6d55bb76b4e1c..824d96cb9dae1 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -497,10 +497,12 @@ class CXXDynamicCastExpr final
   friend class CastExpr;
   friend TrailingObjects;
 
-  static CXXDynamicCastExpr *
-  Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind,
-         Expr *Op, const CXXCastPath *Path, TypeSourceInfo *Written,
-         SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets);
+  static CXXDynamicCastExpr *Create(const ASTContext &Context, QualType T,
+                                    ExprValueKind VK, CastKind Kind, Expr *Op,
+                                    const CXXCastPath *Path,
+                                    TypeSourceInfo *Written, SourceLocation L,
+                                    SourceLocation RParenLoc,
+                                    SourceRange AngleBrackets);
 
   static CXXDynamicCastExpr *CreateEmpty(const ASTContext &Context,
                                          unsigned pathSize);
@@ -540,10 +542,12 @@ class CXXReinterpretCastExpr final
   friend class CastExpr;
   friend TrailingObjects;
 
-  static CXXReinterpretCastExpr *
-  Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind,
-         Expr *Op, const CXXCastPath *Path, TypeSourceInfo *WrittenTy,
-         SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets);
+  static CXXReinterpretCastExpr *Create(const ASTContext &Context, QualType T,
+                                        ExprValueKind VK, CastKind Kind,
+                                        Expr *Op, const CXXCastPath *Path,
+                                 TypeSourceInfo *WrittenTy, SourceLocation L,
+                                        SourceLocation RParenLoc,
+                                        SourceRange AngleBrackets);
   static CXXReinterpretCastExpr *CreateEmpty(const ASTContext &Context,
                                              unsigned pathSize);
 
@@ -692,7 +696,7 @@ class UserDefinedLiteral final : public CallExpr {
   /// removed).
   Expr *getCookedLiteral();
   const Expr *getCookedLiteral() const {
-    return const_cast<UserDefinedLiteral *>(this)->getCookedLiteral();
+    return const_cast<UserDefinedLiteral*>(this)->getCookedLiteral();
   }
 
   SourceLocation getBeginLoc() const {
@@ -811,8 +815,8 @@ class CXXStdInitializerListExpr : public Expr {
     setDependence(computeDependence(this));
   }
 
-  Expr *getSubExpr() { return static_cast<Expr *>(SubExpr); }
-  const Expr *getSubExpr() const { return static_cast<const Expr *>(SubExpr); }
+  Expr *getSubExpr() { return static_cast<Expr*>(SubExpr); }
+  const Expr *getSubExpr() const { return static_cast<const Expr*>(SubExpr); }
 
   SourceLocation getBeginLoc() const LLVM_READONLY {
     return SubExpr->getBeginLoc();
@@ -866,9 +870,9 @@ class CXXTypeidExpr : public Expr {
   CXXTypeidExpr(EmptyShell Empty, bool isExpr)
       : Expr(CXXTypeidExprClass, Empty) {
     if (isExpr)
-      Operand = (Expr *)nullptr;
+      Operand = (Expr*)nullptr;
     else
-      Operand = (TypeSourceInfo *)nullptr;
+      Operand = (TypeSourceInfo*)nullptr;
   }
 
   /// Determine whether this typeid has a type operand which is potentially
@@ -966,13 +970,13 @@ class MSPropertyRefExpr : public Expr {
     else if (QualifierLoc)
       return QualifierLoc.getBeginLoc();
     else
-      return MemberLoc;
+        return MemberLoc;
   }
 
   SourceLocation getEndLoc() const { return getMemberLoc(); }
 
   child_range children() {
-    return child_range((Stmt **)&BaseExpr, (Stmt **)&BaseExpr + 1);
+    return child_range((Stmt**)&BaseExpr, (Stmt**)&BaseExpr + 1);
   }
 
   const_child_range children() const {
@@ -1086,11 +1090,11 @@ class CXXUuidofExpr : public Expr {
   }
 
   CXXUuidofExpr(EmptyShell Empty, bool isExpr)
-      : Expr(CXXUuidofExprClass, Empty) {
+    : Expr(CXXUuidofExprClass, Empty) {
     if (isExpr)
-      Operand = (Expr *)nullptr;
+      Operand = (Expr*)nullptr;
     else
-      Operand = (TypeSourceInfo *)nullptr;
+      Operand = (TypeSourceInfo*)nullptr;
   }
 
   bool isTypeOperand() const { return isa<TypeSourceInfo *>(Operand); }
@@ -1467,7 +1471,9 @@ class CXXTemporary {
 
   const CXXDestructorDecl *getDestructor() const { return Destructor; }
 
-  void setDestructor(const CXXDestructorDecl *Dtor) { Destructor = Dtor; }
+  void setDestructor(const CXXDestructorDecl *Dtor) {
+    Destructor = Dtor;
+  }
 };
 
 /// Represents binding an expression to a temporary.
@@ -1502,7 +1508,7 @@ class CXXBindTemporaryExpr : public Expr {
       : Expr(CXXBindTemporaryExprClass, Empty) {}
 
   static CXXBindTemporaryExpr *Create(const ASTContext &C, CXXTemporary *Temp,
-                                      Expr *SubExpr);
+                                      Expr* SubExpr);
 
   CXXTemporary *getTemporary() { return Temp; }
   const CXXTemporary *getTemporary() const { return Temp; }
@@ -2208,7 +2214,9 @@ class CXXScalarValueInitExpr : public Expr {
   explicit CXXScalarValueInitExpr(EmptyShell Shell)
       : Expr(CXXScalarValueInitExprClass, Shell) {}
 
-  TypeSourceInfo *getTypeSourceInfo() const { return TypeInfo; }
+  TypeSourceInfo *getTypeSourceInfo() const {
+    return TypeInfo;
+  }
 
   SourceLocation getRParenLoc() const {
     return CXXScalarValueInitExprBits.RParenLoc;
@@ -2769,11 +2777,12 @@ class CXXPseudoDestructorExpr : public Expr {
   PseudoDestructorTypeStorage DestroyedType;
 
 public:
-  CXXPseudoDestructorExpr(const ASTContext &Context, Expr *Base, bool isArrow,
-                          SourceLocation OperatorLoc,
+  CXXPseudoDestructorExpr(const ASTContext &Context,
+                          Expr *Base, bool isArrow, SourceLocation OperatorLoc,
                           NestedNameSpecifierLoc QualifierLoc,
                           TypeSourceInfo *ScopeType,
-                          SourceLocation ColonColonLoc, SourceLocation TildeLoc,
+                          SourceLocation ColonColonLoc,
+                          SourceLocation TildeLoc,
                           PseudoDestructorTypeStorage DestroyedType);
 
   explicit CXXPseudoDestructorExpr(EmptyShell Shell)
@@ -2916,7 +2925,8 @@ class TypeTraitExpr final
   static TypeTraitExpr *Create(const ASTContext &C, QualType T,
                                SourceLocation Loc, TypeTrait Kind,
                                ArrayRef<TypeSourceInfo *> Args,
-                               SourceLocation RParenLoc, bool Value);
+                               SourceLocation RParenLoc,
+                               bool Value);
 
   static TypeTraitExpr *Create(const ASTContext &C, QualType T,
                                SourceLocation Loc, TypeTrait Kind,
@@ -3033,10 +3043,7 @@ class ArrayTypeTraitExpr : public Expr {
 
   TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; }
 
-  uint64_t getValue() const {
-    assert(!isTypeDependent());
-    return Value;
-  }
+  uint64_t getValue() const { assert(!isTypeDependent()); return Value; }
 
   Expr *getDimensionExpression() const { return Dimension; }
 
@@ -3069,7 +3076,7 @@ class ExpressionTraitExpr : public Expr {
   SourceLocation RParen;
 
   /// The expression being queried.
-  Expr *QueriedExpression = nullptr;
+  Expr* QueriedExpression = nullptr;
 
 public:
   friend class ASTStmtReader;
@@ -3803,7 +3810,7 @@ class CXXUnresolvedConstructExpr final
   arg_iterator arg_end() { return arg_begin() + getNumArgs(); }
   arg_range arguments() { return arg_range(arg_begin(), arg_end()); }
 
-  using const_arg_iterator = const Expr *const *;
+  using const_arg_iterator = const Expr* const *;
   using const_arg_range = llvm::iterator_range<const_arg_iterator>;
 
   const_arg_iterator arg_begin() const { return getTrailingObjects(); }
@@ -4413,7 +4420,9 @@ class PackExpansionExpr : public Expr {
   }
 
   // Iterators
-  child_range children() { return child_range(&Pattern, &Pattern + 1); }
+  child_range children() {
+    return child_range(&Pattern, &Pattern + 1);
+  }
 
   const_child_range children() const {
     return const_child_range(&Pattern, &Pattern + 1);
@@ -4516,7 +4525,9 @@ class SizeOfPackExpr final
   ///
   ///   template<typename ...Ts> using X = int[sizeof...(Ts)];
   ///   template<typename ...Us> void f(X<Us..., 1, 2, 3, Us...>);
-  bool isPartiallySubstituted() const { return isValueDependent() && Length; }
+  bool isPartiallySubstituted() const {
+    return isValueDependent() && Length;
+  }
 
   /// Get
   ArrayRef<TemplateArgument> getPartialArguments() const {
@@ -5045,8 +5056,8 @@ class CXXFoldExpr : public Expr {
   UnresolvedLookupExpr *getCallee() const {
     return static_cast<UnresolvedLookupExpr *>(SubExprs[SubExpr::Callee]);
   }
-  Expr *getLHS() const { return static_cast<Expr *>(SubExprs[SubExpr::LHS]); }
-  Expr *getRHS() const { return static_cast<Expr *>(SubExprs[SubExpr::RHS]); }
+  Expr *getLHS() const { return static_cast<Expr*>(SubExprs[SubExpr::LHS]); }
+  Expr *getRHS() const { return static_cast<Expr*>(SubExprs[SubExpr::RHS]); }
 
   /// Does this produce a right-associated sequence of operators?
   bool isRightFold() const {
@@ -5293,22 +5304,22 @@ class CoroutineSuspendExpr : public Expr {
   }
 
   Expr *getCommonExpr() const {
-    return static_cast<Expr *>(SubExprs[SubExpr::Common]);
+    return static_cast<Expr*>(SubExprs[SubExpr::Common]);
   }
 
   /// getOpaqueValue - Return the opaque value placeholder.
   OpaqueValueExpr *getOpaqueValue() const { return OpaqueValue; }
 
   Expr *getReadyExpr() const {
-    return static_cast<Expr *>(SubExprs[SubExpr::Ready]);
+    return static_cast<Expr*>(SubExprs[SubExpr::Ready]);
   }
 
   Expr *getSuspendExpr() const {
-    return static_cast<Expr *>(SubExprs[SubExpr::Suspend]);
+    return static_cast<Expr*>(SubExprs[SubExpr::Suspend]);
   }
 
   Expr *getResumeExpr() const {
-    return static_cast<Expr *>(SubExprs[SubExpr::Resume]);
+    return static_cast<Expr*>(SubExprs[SubExpr::Resume]);
   }
 
   // The syntactic operand written in the code
@@ -5498,18 +5509,18 @@ class BuiltinBitCastExpr final
 ///  - an id-expression.
 class CXXReflectExpr : public Expr {
 
-private:
-  // TODO(Reflection): add support for TemplateReference, NamespaceReference and
-  // DeclRefExpr
-  using operand_type = llvm::PointerUnion<const TypeSourceInfo *>;
 
-  SourceLocation CaretCaretLoc;
-  ReflectionKind Kind;
-  operand_type Operand;
+  private:
+    // TODO(Reflection): add support for TemplateReference, NamespaceReference and
+    // DeclRefExpr
+    using operand_type = llvm::PointerUnion<const TypeSourceInfo *>;
+
+    SourceLocation CaretCaretLoc;
+    ReflectionKind Kind;
+    operand_type Operand;
 
-  CXXReflectExpr(ASTContext &C, SourceLocation CaretCaretLoc,
-                 const TypeSourceInfo *TSI);
-  CXXReflectExpr(EmptyShell Empty);
+    CXXReflectExpr(ASTContext &C, SourceLocation CaretCaretLoc, const TypeSourceInfo *TSI);
+    CXXReflectExpr(EmptyShell Empty);
 
 public:
   static CXXReflectExpr *Create(ASTContext &C, SourceLocation OperatorLoc,
@@ -5532,7 +5543,7 @@ class CXXReflectExpr : public Expr {
   /// Returns location of the '^^'-operator.
   SourceLocation getOperatorLoc() const { return CaretCaretLoc; }
   ReflectionKind getKind() const { return Kind; }
-  const void *getOpaqueValue() const { return Operand.getOpaqueValue(); }
+  const void* getOpaqueValue() const { return Operand.getOpaqueValue(); }
 
   child_range children() {
     // TODO(Reflection)

>From afeec5010ca65d7524956d27dd435d4499d0d8e0 Mon Sep 17 00:00:00 2001
From: changkhothuychung <nhat7203 at gmail.com>
Date: Wed, 8 Apr 2026 17:47:20 -0400
Subject: [PATCH 15/23] revert wrong clang forma

---
 clang/include/clang/AST/APValue.h    |    6 +-
 clang/include/clang/AST/Reflection.h |   13 +-
 clang/lib/AST/APValue.cpp            |  120 +-
 clang/lib/AST/ExprConstant.cpp       | 3929 +++++++++++++-------------
 clang/lib/AST/Type.cpp               |    2 +-
 clang/lib/Sema/SemaExpr.cpp          | 2524 ++++++++---------
 clang/lib/Sema/SemaOverload.cpp      | 2729 +++++++++---------
 7 files changed, 4708 insertions(+), 4615 deletions(-)

diff --git a/clang/include/clang/AST/APValue.h b/clang/include/clang/AST/APValue.h
index 751ee12c9017d..94a94c0489ca4 100644
--- a/clang/include/clang/AST/APValue.h
+++ b/clang/include/clang/AST/APValue.h
@@ -716,7 +716,7 @@ class APValue {
     return ((const AddrLabelDiffData *)(const char *)&Data)->RHSExpr;
   }
 
-  const ReflectionKind getReflectionOperandKind() const {
+  ReflectionKind getReflectionOperandKind() const {
     assert(isReflection() && "Invalid accessor");
     return ((const ReflectionData *)(const char *)&Data)->OperandKind;
   }
@@ -779,8 +779,8 @@ class APValue {
   void MakeReflection(ReflectionKind OperandKind,
                       const void *Operand) {
     assert(isAbsent() && "Bad state change");
-    new ((void *)(char *)Data.buffer) ReflectionData(
-            OperandKind, Operand);
+    new ((void *)(char *)Data.buffer) ReflectionData{
+            OperandKind, Operand};
     Kind = Reflection;
   }
   void MakeInt() {
diff --git a/clang/include/clang/AST/Reflection.h b/clang/include/clang/AST/Reflection.h
index a1bd781d39808..03fdd7ff4fb4d 100644
--- a/clang/include/clang/AST/Reflection.h
+++ b/clang/include/clang/AST/Reflection.h
@@ -10,6 +10,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+
 #ifndef LLVM_CLANG_AST_REFLECTION_H
 #define LLVM_CLANG_AST_REFLECTION_H
 
@@ -18,11 +19,12 @@
 namespace clang {
 
 // TODO(Reflection): Add support for Template, Namespace and DeclRefExpr.
-enum class ReflectionKind { Type };
+enum class ReflectionKind {
+  Type
+};
 
-inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
-                                     ReflectionKind Kind) {
-  switch (Kind) {
+inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, ReflectionKind Kind) {
+  switch(Kind) {
   case ReflectionKind::Type:
     OS << "type";
   }
@@ -30,5 +32,6 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
   return OS;
 }
 
-} // namespace clang
+}
+
 #endif
diff --git a/clang/lib/AST/APValue.cpp b/clang/lib/AST/APValue.cpp
index 66dd3f82d3c15..6986dfee85478 100644
--- a/clang/lib/AST/APValue.cpp
+++ b/clang/lib/AST/APValue.cpp
@@ -61,9 +61,8 @@ APValue::LValueBase APValue::LValueBase::getTypeInfo(TypeInfoLValue LV,
 }
 
 QualType APValue::LValueBase::getType() const {
-  if (!*this)
-    return QualType();
-  if (const ValueDecl *D = dyn_cast<const ValueDecl *>()) {
+  if (!*this) return QualType();
+  if (const ValueDecl *D = dyn_cast<const ValueDecl*>()) {
     // FIXME: It's unclear where we're supposed to take the type from, and
     // this actually matters for arrays of unknown bound. Eg:
     //
@@ -86,7 +85,7 @@ QualType APValue::LValueBase::getType() const {
   if (is<DynamicAllocLValue>())
     return getDynamicAllocType();
 
-  const Expr *Base = get<const Expr *>();
+  const Expr *Base = get<const Expr*>();
 
   // For a materialized temporary, the type of the temporary we materialized
   // may not be the type of the expression.
@@ -95,8 +94,8 @@ QualType APValue::LValueBase::getType() const {
     SmallVector<const Expr *, 2> CommaLHSs;
     SmallVector<SubobjectAdjustment, 2> Adjustments;
     const Expr *Temp = MTE->getSubExpr();
-    const Expr *Inner =
-        Temp->skipRValueSubobjectAdjustments(CommaLHSs, Adjustments);
+    const Expr *Inner = Temp->skipRValueSubobjectAdjustments(CommaLHSs,
+                                                             Adjustments);
     // Keep any cv-qualifiers from the reference if we generated a temporary
     // for it directly. Otherwise use the type after adjustment.
     if (!Adjustments.empty())
@@ -143,7 +142,7 @@ bool operator==(const APValue::LValueBase &LHS,
   return LHS.Local.CallIndex == RHS.Local.CallIndex &&
          LHS.Local.Version == RHS.Local.Version;
 }
-} // namespace clang
+}
 
 APValue::LValuePathEntry::LValuePathEntry(BaseOrMemberType BaseOrMember) {
   if (const Decl *D = BaseOrMember.getPointer())
@@ -164,34 +163,38 @@ QualType APValue::LValuePathSerializationHelper::getType() {
 }
 
 namespace {
-struct LVBase {
-  APValue::LValueBase Base;
-  CharUnits Offset;
-  unsigned PathLength;
-  bool IsNullPtr : 1;
-  bool IsOnePastTheEnd : 1;
-};
-} // namespace
+  struct LVBase {
+    APValue::LValueBase Base;
+    CharUnits Offset;
+    unsigned PathLength;
+    bool IsNullPtr : 1;
+    bool IsOnePastTheEnd : 1;
+  };
+}
 
 void *APValue::LValueBase::getOpaqueValue() const {
   return Ptr.getOpaqueValue();
 }
 
-bool APValue::LValueBase::isNull() const { return Ptr.isNull(); }
+bool APValue::LValueBase::isNull() const {
+  return Ptr.isNull();
+}
 
-APValue::LValueBase::operator bool() const { return static_cast<bool>(Ptr); }
+APValue::LValueBase::operator bool () const {
+  return static_cast<bool>(Ptr);
+}
 
 clang::APValue::LValueBase
 llvm::DenseMapInfo<clang::APValue::LValueBase>::getEmptyKey() {
   clang::APValue::LValueBase B;
-  B.Ptr = DenseMapInfo<const ValueDecl *>::getEmptyKey();
+  B.Ptr = DenseMapInfo<const ValueDecl*>::getEmptyKey();
   return B;
 }
 
 clang::APValue::LValueBase
 llvm::DenseMapInfo<clang::APValue::LValueBase>::getTombstoneKey() {
   clang::APValue::LValueBase B;
-  B.Ptr = DenseMapInfo<const ValueDecl *>::getTombstoneKey();
+  B.Ptr = DenseMapInfo<const ValueDecl*>::getTombstoneKey();
   return B;
 }
 
@@ -202,7 +205,7 @@ llvm::hash_code hash_value(const APValue::LValueBase &Base) {
   return llvm::hash_combine(Base.getOpaqueValue(), Base.getCallIndex(),
                             Base.getVersion());
 }
-} // namespace clang
+}
 
 unsigned llvm::DenseMapInfo<clang::APValue::LValueBase>::getHashValue(
     const clang::APValue::LValueBase &Base) {
@@ -234,7 +237,7 @@ struct APValue::LV : LVBase {
     if (Length == PathLength)
       return;
     if (hasPathPtr())
-      delete[] PathPtr;
+      delete [] PathPtr;
     PathLength = Length;
     if (hasPathPtr())
       PathPtr = new LValuePathEntry[Length];
@@ -250,15 +253,15 @@ struct APValue::LV : LVBase {
 };
 
 namespace {
-struct MemberPointerBase {
-  llvm::PointerIntPair<const ValueDecl *, 1, bool> MemberAndIsDerivedMember;
-  unsigned PathLength;
-};
-} // namespace
+  struct MemberPointerBase {
+    llvm::PointerIntPair<const ValueDecl*, 1, bool> MemberAndIsDerivedMember;
+    unsigned PathLength;
+  };
+}
 
 struct APValue::MemberPointerData : MemberPointerBase {
   static const unsigned InlinePathSpace =
-      (DataSize - sizeof(MemberPointerBase)) / sizeof(const CXXRecordDecl *);
+      (DataSize - sizeof(MemberPointerBase)) / sizeof(const CXXRecordDecl*);
   typedef const CXXRecordDecl *PathElem;
   union {
     PathElem Path[InlinePathSpace];
@@ -272,7 +275,7 @@ struct APValue::MemberPointerData : MemberPointerBase {
     if (Length == PathLength)
       return;
     if (hasPathPtr())
-      delete[] PathPtr;
+      delete [] PathPtr;
     PathLength = Length;
     if (hasPathPtr())
       PathPtr = new PathElem[Length];
@@ -281,23 +284,29 @@ struct APValue::MemberPointerData : MemberPointerBase {
   bool hasPathPtr() const { return PathLength > InlinePathSpace; }
 
   PathElem *getPath() { return hasPathPtr() ? PathPtr : Path; }
-  const PathElem *getPath() const { return hasPathPtr() ? PathPtr : Path; }
+  const PathElem *getPath() const {
+    return hasPathPtr() ? PathPtr : Path;
+  }
 };
 
 // FIXME: Reduce the malloc traffic here.
 
-APValue::Arr::Arr(unsigned NumElts, unsigned Size)
-    : Elts(new APValue[NumElts + (NumElts != Size ? 1 : 0)]), NumElts(NumElts),
-      ArrSize(Size) {}
-APValue::Arr::~Arr() { delete[] Elts; }
+APValue::Arr::Arr(unsigned NumElts, unsigned Size) :
+  Elts(new APValue[NumElts + (NumElts != Size ? 1 : 0)]),
+  NumElts(NumElts), ArrSize(Size) {}
+APValue::Arr::~Arr() { delete [] Elts; }
 
-APValue::StructData::StructData(unsigned NumBases, unsigned NumFields)
-    : Elts(new APValue[NumBases + NumFields]), NumBases(NumBases),
-      NumFields(NumFields) {}
-APValue::StructData::~StructData() { delete[] Elts; }
+APValue::StructData::StructData(unsigned NumBases, unsigned NumFields) :
+  Elts(new APValue[NumBases+NumFields]),
+  NumBases(NumBases), NumFields(NumFields) {}
+APValue::StructData::~StructData() {
+  delete [] Elts;
+}
 
 APValue::UnionData::UnionData() : Field(nullptr), Value(new APValue) {}
-APValue::UnionData::~UnionData() { delete Value; }
+APValue::UnionData::~UnionData () {
+  delete Value;
+}
 
 APValue::APValue(const APValue &RHS)
     : Kind(None), AllowConstexprUnknown(RHS.AllowConstexprUnknown) {
@@ -374,8 +383,7 @@ APValue::APValue(const APValue &RHS)
     setAddrLabelDiff(RHS.getAddrLabelDiffLHS(), RHS.getAddrLabelDiffRHS());
     break;
   case Reflection:
-    MakeReflection(RHS.getReflectionOperandKind(),
-                   RHS.getReflectionOpaqueOperand());
+    MakeReflection(RHS.getReflectionOperandKind(), RHS.getReflectionOpaqueOperand());
     break;
   }
 }
@@ -495,12 +503,11 @@ static void profileIntValue(llvm::FoldingSetNodeID &ID, const llvm::APInt &V) {
 static void profileReflection(llvm::FoldingSetNodeID &ID, APValue V) {
   ID.AddInteger(static_cast<int>(V.getReflectionOperandKind()));
   switch (V.getReflectionOperandKind()) {
-  case ReflectionKind::Type: {
-    const TypeSourceInfo *info =
-        static_cast<const TypeSourceInfo *>(V.getReflectionOpaqueOperand());
-    ID.AddPointer((info->getType().getCanonicalType().getAsOpaquePtr()));
-    return;
-  }
+    case ReflectionKind::Type: {
+      const TypeSourceInfo* info = static_cast<const TypeSourceInfo*>(V.getReflectionOpaqueOperand());
+      ID.AddPointer((info->getType().getCanonicalType().getAsOpaquePtr()));
+      return;
+    }
     assert(false && "unknown or unimplemented reflection entities");
   }
 }
@@ -802,8 +809,8 @@ void APValue::printPretty(raw_ostream &Out, const PrintingPolicy &Policy,
     return;
   case APValue::LValue: {
     bool IsReference = Ty->isReferenceType();
-    QualType InnerTy =
-        IsReference ? Ty.getNonReferenceType() : Ty->getPointeeType();
+    QualType InnerTy
+      = IsReference ? Ty.getNonReferenceType() : Ty->getPointeeType();
     if (InnerTy.isNull())
       InnerTy = Ty;
 
@@ -839,17 +846,18 @@ void APValue::printPretty(raw_ostream &Out, const PrintingPolicy &Policy,
         Out << '&';
       }
 
-      if (const ValueDecl *VD = Base.dyn_cast<const ValueDecl *>())
+      if (const ValueDecl *VD = Base.dyn_cast<const ValueDecl*>())
         Out << *VD;
       else if (TypeInfoLValue TI = Base.dyn_cast<TypeInfoLValue>()) {
         TI.print(Out, Policy);
       } else if (DynamicAllocLValue DA = Base.dyn_cast<DynamicAllocLValue>()) {
-        Out << "{*new " << Base.getDynamicAllocType().stream(Policy) << "#"
+        Out << "{*new "
+            << Base.getDynamicAllocType().stream(Policy) << "#"
             << DA.getIndex() << "}";
       } else {
         assert(Base.get<const Expr *>() != nullptr &&
                "Expecting non-null Expr");
-        Base.get<const Expr *>()->printPretty(Out, nullptr, Policy);
+        Base.get<const Expr*>()->printPretty(Out, nullptr, Policy);
       }
 
       if (!O.isZero()) {
@@ -867,7 +875,7 @@ void APValue::printPretty(raw_ostream &Out, const PrintingPolicy &Policy,
       Out << "*(&";
 
     QualType ElemTy = Base.getType().getNonReferenceType();
-    if (const ValueDecl *VD = Base.dyn_cast<const ValueDecl *>()) {
+    if (const ValueDecl *VD = Base.dyn_cast<const ValueDecl*>()) {
       Out << *VD;
     } else if (TypeInfoLValue TI = Base.dyn_cast<TypeInfoLValue>()) {
       TI.print(Out, Policy);
@@ -875,7 +883,7 @@ void APValue::printPretty(raw_ostream &Out, const PrintingPolicy &Policy,
       Out << "{*new " << Base.getDynamicAllocType().stream(Policy) << "#"
           << DA.getIndex() << "}";
     } else {
-      const Expr *E = Base.get<const Expr *>();
+      const Expr *E = Base.get<const Expr*>();
       assert(E != nullptr && "Expecting non-null Expr");
       E->printPretty(Out, nullptr, Policy);
     }
@@ -965,8 +973,8 @@ void APValue::printPretty(raw_ostream &Out, const PrintingPolicy &Policy,
         Out << ", ";
       if (FI->isUnnamedBitField())
         continue;
-      getStructField(FI->getFieldIndex())
-          .printPretty(Out, Policy, FI->getType(), Ctx);
+      getStructField(FI->getFieldIndex()).
+        printPretty(Out, Policy, FI->getType(), Ctx);
       First = false;
     }
     Out << '}';
@@ -1122,7 +1130,7 @@ bool APValue::isMemberPointerToDerivedMember() const {
   return MPD.MemberAndIsDerivedMember.getInt();
 }
 
-ArrayRef<const CXXRecordDecl *> APValue::getMemberPointerPath() const {
+ArrayRef<const CXXRecordDecl*> APValue::getMemberPointerPath() const {
   assert(isMemberPointer() && "Invalid accessor");
   const MemberPointerData &MPD =
       *((const MemberPointerData *)(const char *)&Data);
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 752a3733f5a38..827710c01e73b 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -48,10 +48,10 @@
 #include "clang/AST/OSLog.h"
 #include "clang/AST/OptionalDiagnostic.h"
 #include "clang/AST/RecordLayout.h"
-#include "clang/AST/Reflection.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/AST/Type.h"
 #include "clang/AST/TypeLoc.h"
+#include "clang/AST/Reflection.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/DiagnosticSema.h"
 #include "clang/Basic/TargetBuiltins.h"
@@ -75,651 +75,667 @@
 
 using namespace clang;
 using llvm::APFixedPoint;
-using llvm::APFloat;
 using llvm::APInt;
 using llvm::APSInt;
+using llvm::APFloat;
 using llvm::FixedPointSemantics;
 
 namespace {
-struct LValue;
-class CallStackFrame;
-class EvalInfo;
+  struct LValue;
+  class CallStackFrame;
+  class EvalInfo;
 
-using SourceLocExprScopeGuard =
-    CurrentSourceLocExprScope::SourceLocExprScopeGuard;
+  using SourceLocExprScopeGuard =
+      CurrentSourceLocExprScope::SourceLocExprScopeGuard;
 
-static QualType getType(APValue::LValueBase B) { return B.getType(); }
+  static QualType getType(APValue::LValueBase B) {
+    return B.getType();
+  }
 
-/// Get an LValue path entry, which is known to not be an array index, as a
-/// field declaration.
-static const FieldDecl *getAsField(APValue::LValuePathEntry E) {
-  return dyn_cast_or_null<FieldDecl>(E.getAsBaseOrMember().getPointer());
-}
-/// Get an LValue path entry, which is known to not be an array index, as a
-/// base class declaration.
-static const CXXRecordDecl *getAsBaseClass(APValue::LValuePathEntry E) {
-  return dyn_cast_or_null<CXXRecordDecl>(E.getAsBaseOrMember().getPointer());
-}
-/// Determine whether this LValue path entry for a base class names a virtual
-/// base class.
-static bool isVirtualBaseClass(APValue::LValuePathEntry E) {
-  return E.getAsBaseOrMember().getInt();
-}
+  /// Get an LValue path entry, which is known to not be an array index, as a
+  /// field declaration.
+  static const FieldDecl *getAsField(APValue::LValuePathEntry E) {
+    return dyn_cast_or_null<FieldDecl>(E.getAsBaseOrMember().getPointer());
+  }
+  /// Get an LValue path entry, which is known to not be an array index, as a
+  /// base class declaration.
+  static const CXXRecordDecl *getAsBaseClass(APValue::LValuePathEntry E) {
+    return dyn_cast_or_null<CXXRecordDecl>(E.getAsBaseOrMember().getPointer());
+  }
+  /// Determine whether this LValue path entry for a base class names a virtual
+  /// base class.
+  static bool isVirtualBaseClass(APValue::LValuePathEntry E) {
+    return E.getAsBaseOrMember().getInt();
+  }
 
-/// Given an expression, determine the type used to store the result of
-/// evaluating that expression.
-static QualType getStorageType(const ASTContext &Ctx, const Expr *E) {
-  if (E->isPRValue())
-    return E->getType();
-  return Ctx.getLValueReferenceType(E->getType());
-}
+  /// Given an expression, determine the type used to store the result of
+  /// evaluating that expression.
+  static QualType getStorageType(const ASTContext &Ctx, const Expr *E) {
+    if (E->isPRValue())
+      return E->getType();
+    return Ctx.getLValueReferenceType(E->getType());
+  }
 
-/// Attempts to unwrap a CallExpr (with an alloc_size attribute) from an Expr.
-/// This will look through a single cast.
-///
-/// Returns null if we couldn't unwrap a function with alloc_size.
-static const CallExpr *tryUnwrapAllocSizeCall(const Expr *E) {
-  if (!E->getType()->isPointerType())
-    return nullptr;
+  /// Attempts to unwrap a CallExpr (with an alloc_size attribute) from an Expr.
+  /// This will look through a single cast.
+  ///
+  /// Returns null if we couldn't unwrap a function with alloc_size.
+  static const CallExpr *tryUnwrapAllocSizeCall(const Expr *E) {
+    if (!E->getType()->isPointerType())
+      return nullptr;
 
-  E = E->IgnoreParens();
-  // If we're doing a variable assignment from e.g. malloc(N), there will
-  // probably be a cast of some kind. In exotic cases, we might also see a
-  // top-level ExprWithCleanups. Ignore them either way.
-  if (const auto *FE = dyn_cast<FullExpr>(E))
-    E = FE->getSubExpr()->IgnoreParens();
+    E = E->IgnoreParens();
+    // If we're doing a variable assignment from e.g. malloc(N), there will
+    // probably be a cast of some kind. In exotic cases, we might also see a
+    // top-level ExprWithCleanups. Ignore them either way.
+    if (const auto *FE = dyn_cast<FullExpr>(E))
+      E = FE->getSubExpr()->IgnoreParens();
 
-  if (const auto *Cast = dyn_cast<CastExpr>(E))
-    E = Cast->getSubExpr()->IgnoreParens();
+    if (const auto *Cast = dyn_cast<CastExpr>(E))
+      E = Cast->getSubExpr()->IgnoreParens();
 
-  if (const auto *CE = dyn_cast<CallExpr>(E))
-    return CE->getCalleeAllocSizeAttr() ? CE : nullptr;
-  return nullptr;
-}
+    if (const auto *CE = dyn_cast<CallExpr>(E))
+      return CE->getCalleeAllocSizeAttr() ? CE : nullptr;
+    return nullptr;
+  }
 
-/// Determines whether or not the given Base contains a call to a function
-/// with the alloc_size attribute.
-static bool isBaseAnAllocSizeCall(APValue::LValueBase Base) {
-  const auto *E = Base.dyn_cast<const Expr *>();
-  return E && E->getType()->isPointerType() && tryUnwrapAllocSizeCall(E);
-}
+  /// Determines whether or not the given Base contains a call to a function
+  /// with the alloc_size attribute.
+  static bool isBaseAnAllocSizeCall(APValue::LValueBase Base) {
+    const auto *E = Base.dyn_cast<const Expr *>();
+    return E && E->getType()->isPointerType() && tryUnwrapAllocSizeCall(E);
+  }
 
-/// Determines whether the given kind of constant expression is only ever
-/// used for name mangling. If so, it's permitted to reference things that we
-/// can't generate code for (in particular, dllimported functions).
-static bool isForManglingOnly(ConstantExprKind Kind) {
-  switch (Kind) {
-  case ConstantExprKind::Normal:
-  case ConstantExprKind::ClassTemplateArgument:
-  case ConstantExprKind::ImmediateInvocation:
-    // Note that non-type template arguments of class type are emitted as
-    // template parameter objects.
-    return false;
+  /// Determines whether the given kind of constant expression is only ever
+  /// used for name mangling. If so, it's permitted to reference things that we
+  /// can't generate code for (in particular, dllimported functions).
+  static bool isForManglingOnly(ConstantExprKind Kind) {
+    switch (Kind) {
+    case ConstantExprKind::Normal:
+    case ConstantExprKind::ClassTemplateArgument:
+    case ConstantExprKind::ImmediateInvocation:
+      // Note that non-type template arguments of class type are emitted as
+      // template parameter objects.
+      return false;
 
-  case ConstantExprKind::NonClassTemplateArgument:
-    return true;
+    case ConstantExprKind::NonClassTemplateArgument:
+      return true;
+    }
+    llvm_unreachable("unknown ConstantExprKind");
   }
-  llvm_unreachable("unknown ConstantExprKind");
-}
 
-static bool isTemplateArgument(ConstantExprKind Kind) {
-  switch (Kind) {
-  case ConstantExprKind::Normal:
-  case ConstantExprKind::ImmediateInvocation:
-    return false;
+  static bool isTemplateArgument(ConstantExprKind Kind) {
+    switch (Kind) {
+    case ConstantExprKind::Normal:
+    case ConstantExprKind::ImmediateInvocation:
+      return false;
 
-  case ConstantExprKind::ClassTemplateArgument:
-  case ConstantExprKind::NonClassTemplateArgument:
-    return true;
-  }
-  llvm_unreachable("unknown ConstantExprKind");
-}
-
-/// The bound to claim that an array of unknown bound has.
-/// The value in MostDerivedArraySize is undefined in this case. So, set it
-/// to an arbitrary value that's likely to loudly break things if it's used.
-static const uint64_t AssumedSizeForUnsizedArray =
-    std::numeric_limits<uint64_t>::max() / 2;
-
-/// Determines if an LValue with the given LValueBase will have an unsized
-/// array in its designator.
-/// Find the path length and type of the most-derived subobject in the given
-/// path, and find the size of the containing array, if any.
-static unsigned
-findMostDerivedSubobject(const ASTContext &Ctx, APValue::LValueBase Base,
-                         ArrayRef<APValue::LValuePathEntry> Path,
-                         uint64_t &ArraySize, QualType &Type, bool &IsArray,
-                         bool &FirstEntryIsUnsizedArray) {
-  // This only accepts LValueBases from APValues, and APValues don't support
-  // arrays that lack size info.
-  assert(!isBaseAnAllocSizeCall(Base) &&
-         "Unsized arrays shouldn't appear here");
-  unsigned MostDerivedLength = 0;
-  // The type of Base is a reference type if the base is a constexpr-unknown
-  // variable. In that case, look through the reference type.
-  Type = getType(Base).getNonReferenceType();
-
-  for (unsigned I = 0, N = Path.size(); I != N; ++I) {
-    if (Type->isArrayType()) {
-      const ArrayType *AT = Ctx.getAsArrayType(Type);
-      Type = AT->getElementType();
-      MostDerivedLength = I + 1;
-      IsArray = true;
-
-      if (auto *CAT = dyn_cast<ConstantArrayType>(AT)) {
-        ArraySize = CAT->getZExtSize();
+    case ConstantExprKind::ClassTemplateArgument:
+    case ConstantExprKind::NonClassTemplateArgument:
+      return true;
+    }
+    llvm_unreachable("unknown ConstantExprKind");
+  }
+
+  /// The bound to claim that an array of unknown bound has.
+  /// The value in MostDerivedArraySize is undefined in this case. So, set it
+  /// to an arbitrary value that's likely to loudly break things if it's used.
+  static const uint64_t AssumedSizeForUnsizedArray =
+      std::numeric_limits<uint64_t>::max() / 2;
+
+  /// Determines if an LValue with the given LValueBase will have an unsized
+  /// array in its designator.
+  /// Find the path length and type of the most-derived subobject in the given
+  /// path, and find the size of the containing array, if any.
+  static unsigned
+  findMostDerivedSubobject(const ASTContext &Ctx, APValue::LValueBase Base,
+                           ArrayRef<APValue::LValuePathEntry> Path,
+                           uint64_t &ArraySize, QualType &Type, bool &IsArray,
+                           bool &FirstEntryIsUnsizedArray) {
+    // This only accepts LValueBases from APValues, and APValues don't support
+    // arrays that lack size info.
+    assert(!isBaseAnAllocSizeCall(Base) &&
+           "Unsized arrays shouldn't appear here");
+    unsigned MostDerivedLength = 0;
+    // The type of Base is a reference type if the base is a constexpr-unknown
+    // variable. In that case, look through the reference type.
+    Type = getType(Base).getNonReferenceType();
+
+    for (unsigned I = 0, N = Path.size(); I != N; ++I) {
+      if (Type->isArrayType()) {
+        const ArrayType *AT = Ctx.getAsArrayType(Type);
+        Type = AT->getElementType();
+        MostDerivedLength = I + 1;
+        IsArray = true;
+
+        if (auto *CAT = dyn_cast<ConstantArrayType>(AT)) {
+          ArraySize = CAT->getZExtSize();
+        } else {
+          assert(I == 0 && "unexpected unsized array designator");
+          FirstEntryIsUnsizedArray = true;
+          ArraySize = AssumedSizeForUnsizedArray;
+        }
+      } else if (Type->isAnyComplexType()) {
+        const ComplexType *CT = Type->castAs<ComplexType>();
+        Type = CT->getElementType();
+        ArraySize = 2;
+        MostDerivedLength = I + 1;
+        IsArray = true;
+      } else if (const auto *VT = Type->getAs<VectorType>()) {
+        Type = VT->getElementType();
+        ArraySize = VT->getNumElements();
+        MostDerivedLength = I + 1;
+        IsArray = true;
+      } else if (const FieldDecl *FD = getAsField(Path[I])) {
+        Type = FD->getType();
+        ArraySize = 0;
+        MostDerivedLength = I + 1;
+        IsArray = false;
       } else {
-        assert(I == 0 && "unexpected unsized array designator");
-        FirstEntryIsUnsizedArray = true;
-        ArraySize = AssumedSizeForUnsizedArray;
+        // Path[I] describes a base class.
+        ArraySize = 0;
+        IsArray = false;
+      }
+    }
+    return MostDerivedLength;
+  }
+
+  /// A path from a glvalue to a subobject of that glvalue.
+  struct SubobjectDesignator {
+    /// True if the subobject was named in a manner not supported by C++11. Such
+    /// lvalues can still be folded, but they are not core constant expressions
+    /// and we cannot perform lvalue-to-rvalue conversions on them.
+    LLVM_PREFERRED_TYPE(bool)
+    unsigned Invalid : 1;
+
+    /// Is this a pointer one past the end of an object?
+    LLVM_PREFERRED_TYPE(bool)
+    unsigned IsOnePastTheEnd : 1;
+
+    /// Indicator of whether the first entry is an unsized array.
+    LLVM_PREFERRED_TYPE(bool)
+    unsigned FirstEntryIsAnUnsizedArray : 1;
+
+    /// Indicator of whether the most-derived object is an array element.
+    LLVM_PREFERRED_TYPE(bool)
+    unsigned MostDerivedIsArrayElement : 1;
+
+    /// The length of the path to the most-derived object of which this is a
+    /// subobject.
+    unsigned MostDerivedPathLength : 28;
+
+    /// The size of the array of which the most-derived object is an element.
+    /// This will always be 0 if the most-derived object is not an array
+    /// element. 0 is not an indicator of whether or not the most-derived object
+    /// is an array, however, because 0-length arrays are allowed.
+    ///
+    /// If the current array is an unsized array, the value of this is
+    /// undefined.
+    uint64_t MostDerivedArraySize;
+    /// The type of the most derived object referred to by this address.
+    QualType MostDerivedType;
+
+    typedef APValue::LValuePathEntry PathEntry;
+
+    /// The entries on the path from the glvalue to the designated subobject.
+    SmallVector<PathEntry, 8> Entries;
+
+    SubobjectDesignator() : Invalid(true) {}
+
+    explicit SubobjectDesignator(QualType T)
+        : Invalid(false), IsOnePastTheEnd(false),
+          FirstEntryIsAnUnsizedArray(false), MostDerivedIsArrayElement(false),
+          MostDerivedPathLength(0), MostDerivedArraySize(0),
+          MostDerivedType(T.isNull() ? QualType() : T.getNonReferenceType()) {}
+
+    SubobjectDesignator(const ASTContext &Ctx, const APValue &V)
+        : Invalid(!V.isLValue() || !V.hasLValuePath()), IsOnePastTheEnd(false),
+          FirstEntryIsAnUnsizedArray(false), MostDerivedIsArrayElement(false),
+          MostDerivedPathLength(0), MostDerivedArraySize(0) {
+      assert(V.isLValue() && "Non-LValue used to make an LValue designator?");
+      if (!Invalid) {
+        IsOnePastTheEnd = V.isLValueOnePastTheEnd();
+        llvm::append_range(Entries, V.getLValuePath());
+        if (V.getLValueBase()) {
+          bool IsArray = false;
+          bool FirstIsUnsizedArray = false;
+          MostDerivedPathLength = findMostDerivedSubobject(
+              Ctx, V.getLValueBase(), V.getLValuePath(), MostDerivedArraySize,
+              MostDerivedType, IsArray, FirstIsUnsizedArray);
+          MostDerivedIsArrayElement = IsArray;
+          FirstEntryIsAnUnsizedArray = FirstIsUnsizedArray;
+        }
       }
-    } else if (Type->isAnyComplexType()) {
-      const ComplexType *CT = Type->castAs<ComplexType>();
-      Type = CT->getElementType();
-      ArraySize = 2;
-      MostDerivedLength = I + 1;
-      IsArray = true;
-    } else if (const auto *VT = Type->getAs<VectorType>()) {
-      Type = VT->getElementType();
-      ArraySize = VT->getNumElements();
-      MostDerivedLength = I + 1;
-      IsArray = true;
-    } else if (const FieldDecl *FD = getAsField(Path[I])) {
-      Type = FD->getType();
-      ArraySize = 0;
-      MostDerivedLength = I + 1;
-      IsArray = false;
-    } else {
-      // Path[I] describes a base class.
-      ArraySize = 0;
-      IsArray = false;
     }
-  }
-  return MostDerivedLength;
-}
-
-/// A path from a glvalue to a subobject of that glvalue.
-struct SubobjectDesignator {
-  /// True if the subobject was named in a manner not supported by C++11. Such
-  /// lvalues can still be folded, but they are not core constant expressions
-  /// and we cannot perform lvalue-to-rvalue conversions on them.
-  LLVM_PREFERRED_TYPE(bool)
-  unsigned Invalid : 1;
 
-  /// Is this a pointer one past the end of an object?
-  LLVM_PREFERRED_TYPE(bool)
-  unsigned IsOnePastTheEnd : 1;
+    void truncate(ASTContext &Ctx, APValue::LValueBase Base,
+                  unsigned NewLength) {
+      if (Invalid)
+        return;
 
-  /// Indicator of whether the first entry is an unsized array.
-  LLVM_PREFERRED_TYPE(bool)
-  unsigned FirstEntryIsAnUnsizedArray : 1;
+      assert(Base && "cannot truncate path for null pointer");
+      assert(NewLength <= Entries.size() && "not a truncation");
 
-  /// Indicator of whether the most-derived object is an array element.
-  LLVM_PREFERRED_TYPE(bool)
-  unsigned MostDerivedIsArrayElement : 1;
+      if (NewLength == Entries.size())
+        return;
+      Entries.resize(NewLength);
 
-  /// The length of the path to the most-derived object of which this is a
-  /// subobject.
-  unsigned MostDerivedPathLength : 28;
+      bool IsArray = false;
+      bool FirstIsUnsizedArray = false;
+      MostDerivedPathLength = findMostDerivedSubobject(
+          Ctx, Base, Entries, MostDerivedArraySize, MostDerivedType, IsArray,
+          FirstIsUnsizedArray);
+      MostDerivedIsArrayElement = IsArray;
+      FirstEntryIsAnUnsizedArray = FirstIsUnsizedArray;
+    }
 
-  /// The size of the array of which the most-derived object is an element.
-  /// This will always be 0 if the most-derived object is not an array
-  /// element. 0 is not an indicator of whether or not the most-derived object
-  /// is an array, however, because 0-length arrays are allowed.
-  ///
-  /// If the current array is an unsized array, the value of this is
-  /// undefined.
-  uint64_t MostDerivedArraySize;
-  /// The type of the most derived object referred to by this address.
-  QualType MostDerivedType;
-
-  typedef APValue::LValuePathEntry PathEntry;
-
-  /// The entries on the path from the glvalue to the designated subobject.
-  SmallVector<PathEntry, 8> Entries;
-
-  SubobjectDesignator() : Invalid(true) {}
-
-  explicit SubobjectDesignator(QualType T)
-      : Invalid(false), IsOnePastTheEnd(false),
-        FirstEntryIsAnUnsizedArray(false), MostDerivedIsArrayElement(false),
-        MostDerivedPathLength(0), MostDerivedArraySize(0),
-        MostDerivedType(T.isNull() ? QualType() : T.getNonReferenceType()) {}
-
-  SubobjectDesignator(const ASTContext &Ctx, const APValue &V)
-      : Invalid(!V.isLValue() || !V.hasLValuePath()), IsOnePastTheEnd(false),
-        FirstEntryIsAnUnsizedArray(false), MostDerivedIsArrayElement(false),
-        MostDerivedPathLength(0), MostDerivedArraySize(0) {
-    assert(V.isLValue() && "Non-LValue used to make an LValue designator?");
-    if (!Invalid) {
-      IsOnePastTheEnd = V.isLValueOnePastTheEnd();
-      llvm::append_range(Entries, V.getLValuePath());
-      if (V.getLValueBase()) {
-        bool IsArray = false;
-        bool FirstIsUnsizedArray = false;
-        MostDerivedPathLength = findMostDerivedSubobject(
-            Ctx, V.getLValueBase(), V.getLValuePath(), MostDerivedArraySize,
-            MostDerivedType, IsArray, FirstIsUnsizedArray);
-        MostDerivedIsArrayElement = IsArray;
-        FirstEntryIsAnUnsizedArray = FirstIsUnsizedArray;
-      }
+    void setInvalid() {
+      Invalid = true;
+      Entries.clear();
     }
-  }
 
-  void truncate(ASTContext &Ctx, APValue::LValueBase Base, unsigned NewLength) {
-    if (Invalid)
-      return;
+    /// Determine whether the most derived subobject is an array without a
+    /// known bound.
+    bool isMostDerivedAnUnsizedArray() const {
+      assert(!Invalid && "Calling this makes no sense on invalid designators");
+      return Entries.size() == 1 && FirstEntryIsAnUnsizedArray;
+    }
 
-    assert(Base && "cannot truncate path for null pointer");
-    assert(NewLength <= Entries.size() && "not a truncation");
+    /// Determine what the most derived array's size is. Results in an assertion
+    /// failure if the most derived array lacks a size.
+    uint64_t getMostDerivedArraySize() const {
+      assert(!isMostDerivedAnUnsizedArray() && "Unsized array has no size");
+      return MostDerivedArraySize;
+    }
 
-    if (NewLength == Entries.size())
-      return;
-    Entries.resize(NewLength);
+    /// Determine whether this is a one-past-the-end pointer.
+    bool isOnePastTheEnd() const {
+      assert(!Invalid);
+      if (IsOnePastTheEnd)
+        return true;
+      if (!isMostDerivedAnUnsizedArray() && MostDerivedIsArrayElement &&
+          Entries[MostDerivedPathLength - 1].getAsArrayIndex() ==
+              MostDerivedArraySize)
+        return true;
+      return false;
+    }
 
-    bool IsArray = false;
-    bool FirstIsUnsizedArray = false;
-    MostDerivedPathLength =
-        findMostDerivedSubobject(Ctx, Base, Entries, MostDerivedArraySize,
-                                 MostDerivedType, IsArray, FirstIsUnsizedArray);
-    MostDerivedIsArrayElement = IsArray;
-    FirstEntryIsAnUnsizedArray = FirstIsUnsizedArray;
-  }
+    /// Get the range of valid index adjustments in the form
+    ///   {maximum value that can be subtracted from this pointer,
+    ///    maximum value that can be added to this pointer}
+    std::pair<uint64_t, uint64_t> validIndexAdjustments() {
+      if (Invalid || isMostDerivedAnUnsizedArray())
+        return {0, 0};
 
-  void setInvalid() {
-    Invalid = true;
-    Entries.clear();
-  }
+      // [expr.add]p4: For the purposes of these operators, a pointer to a
+      // nonarray object behaves the same as a pointer to the first element of
+      // an array of length one with the type of the object as its element type.
+      bool IsArray = MostDerivedPathLength == Entries.size() &&
+                     MostDerivedIsArrayElement;
+      uint64_t ArrayIndex = IsArray ? Entries.back().getAsArrayIndex()
+                                    : (uint64_t)IsOnePastTheEnd;
+      uint64_t ArraySize =
+          IsArray ? getMostDerivedArraySize() : (uint64_t)1;
+      return {ArrayIndex, ArraySize - ArrayIndex};
+    }
 
-  /// Determine whether the most derived subobject is an array without a
-  /// known bound.
-  bool isMostDerivedAnUnsizedArray() const {
-    assert(!Invalid && "Calling this makes no sense on invalid designators");
-    return Entries.size() == 1 && FirstEntryIsAnUnsizedArray;
-  }
+    /// Check that this refers to a valid subobject.
+    bool isValidSubobject() const {
+      if (Invalid)
+        return false;
+      return !isOnePastTheEnd();
+    }
+    /// Check that this refers to a valid subobject, and if not, produce a
+    /// relevant diagnostic and set the designator as invalid.
+    bool checkSubobject(EvalInfo &Info, const Expr *E, CheckSubobjectKind CSK);
 
-  /// Determine what the most derived array's size is. Results in an assertion
-  /// failure if the most derived array lacks a size.
-  uint64_t getMostDerivedArraySize() const {
-    assert(!isMostDerivedAnUnsizedArray() && "Unsized array has no size");
-    return MostDerivedArraySize;
-  }
+    /// Get the type of the designated object.
+    QualType getType(ASTContext &Ctx) const {
+      assert(!Invalid && "invalid designator has no subobject type");
+      return MostDerivedPathLength == Entries.size()
+                 ? MostDerivedType
+                 : Ctx.getCanonicalTagType(getAsBaseClass(Entries.back()));
+    }
 
-  /// Determine whether this is a one-past-the-end pointer.
-  bool isOnePastTheEnd() const {
-    assert(!Invalid);
-    if (IsOnePastTheEnd)
-      return true;
-    if (!isMostDerivedAnUnsizedArray() && MostDerivedIsArrayElement &&
-        Entries[MostDerivedPathLength - 1].getAsArrayIndex() ==
-            MostDerivedArraySize)
-      return true;
-    return false;
-  }
+    /// Update this designator to refer to the first element within this array.
+    void addArrayUnchecked(const ConstantArrayType *CAT) {
+      Entries.push_back(PathEntry::ArrayIndex(0));
 
-  /// Get the range of valid index adjustments in the form
-  ///   {maximum value that can be subtracted from this pointer,
-  ///    maximum value that can be added to this pointer}
-  std::pair<uint64_t, uint64_t> validIndexAdjustments() {
-    if (Invalid || isMostDerivedAnUnsizedArray())
-      return {0, 0};
-
-    // [expr.add]p4: For the purposes of these operators, a pointer to a
-    // nonarray object behaves the same as a pointer to the first element of
-    // an array of length one with the type of the object as its element type.
-    bool IsArray =
-        MostDerivedPathLength == Entries.size() && MostDerivedIsArrayElement;
-    uint64_t ArrayIndex =
-        IsArray ? Entries.back().getAsArrayIndex() : (uint64_t)IsOnePastTheEnd;
-    uint64_t ArraySize = IsArray ? getMostDerivedArraySize() : (uint64_t)1;
-    return {ArrayIndex, ArraySize - ArrayIndex};
-  }
-
-  /// Check that this refers to a valid subobject.
-  bool isValidSubobject() const {
-    if (Invalid)
-      return false;
-    return !isOnePastTheEnd();
-  }
-  /// Check that this refers to a valid subobject, and if not, produce a
-  /// relevant diagnostic and set the designator as invalid.
-  bool checkSubobject(EvalInfo &Info, const Expr *E, CheckSubobjectKind CSK);
-
-  /// Get the type of the designated object.
-  QualType getType(ASTContext &Ctx) const {
-    assert(!Invalid && "invalid designator has no subobject type");
-    return MostDerivedPathLength == Entries.size()
-               ? MostDerivedType
-               : Ctx.getCanonicalTagType(getAsBaseClass(Entries.back()));
-  }
-
-  /// Update this designator to refer to the first element within this array.
-  void addArrayUnchecked(const ConstantArrayType *CAT) {
-    Entries.push_back(PathEntry::ArrayIndex(0));
-
-    // This is a most-derived object.
-    MostDerivedType = CAT->getElementType();
-    MostDerivedIsArrayElement = true;
-    MostDerivedArraySize = CAT->getZExtSize();
-    MostDerivedPathLength = Entries.size();
-  }
-  /// Update this designator to refer to the first element within the array of
-  /// elements of type T. This is an array of unknown size.
-  void addUnsizedArrayUnchecked(QualType ElemTy) {
-    Entries.push_back(PathEntry::ArrayIndex(0));
-
-    MostDerivedType = ElemTy;
-    MostDerivedIsArrayElement = true;
-    // The value in MostDerivedArraySize is undefined in this case. So, set it
-    // to an arbitrary value that's likely to loudly break things if it's
-    // used.
-    MostDerivedArraySize = AssumedSizeForUnsizedArray;
-    MostDerivedPathLength = Entries.size();
-  }
-  /// Update this designator to refer to the given base or member of this
-  /// object.
-  void addDeclUnchecked(const Decl *D, bool Virtual = false) {
-    Entries.push_back(APValue::BaseOrMemberType(D, Virtual));
-
-    // If this isn't a base class, it's a new most-derived object.
-    if (const FieldDecl *FD = dyn_cast<FieldDecl>(D)) {
-      MostDerivedType = FD->getType();
-      MostDerivedIsArrayElement = false;
-      MostDerivedArraySize = 0;
+      // This is a most-derived object.
+      MostDerivedType = CAT->getElementType();
+      MostDerivedIsArrayElement = true;
+      MostDerivedArraySize = CAT->getZExtSize();
       MostDerivedPathLength = Entries.size();
     }
-  }
-  /// Update this designator to refer to the given complex component.
-  void addComplexUnchecked(QualType EltTy, bool Imag) {
-    Entries.push_back(PathEntry::ArrayIndex(Imag));
+    /// Update this designator to refer to the first element within the array of
+    /// elements of type T. This is an array of unknown size.
+    void addUnsizedArrayUnchecked(QualType ElemTy) {
+      Entries.push_back(PathEntry::ArrayIndex(0));
+
+      MostDerivedType = ElemTy;
+      MostDerivedIsArrayElement = true;
+      // The value in MostDerivedArraySize is undefined in this case. So, set it
+      // to an arbitrary value that's likely to loudly break things if it's
+      // used.
+      MostDerivedArraySize = AssumedSizeForUnsizedArray;
+      MostDerivedPathLength = Entries.size();
+    }
+    /// Update this designator to refer to the given base or member of this
+    /// object.
+    void addDeclUnchecked(const Decl *D, bool Virtual = false) {
+      Entries.push_back(APValue::BaseOrMemberType(D, Virtual));
+
+      // If this isn't a base class, it's a new most-derived object.
+      if (const FieldDecl *FD = dyn_cast<FieldDecl>(D)) {
+        MostDerivedType = FD->getType();
+        MostDerivedIsArrayElement = false;
+        MostDerivedArraySize = 0;
+        MostDerivedPathLength = Entries.size();
+      }
+    }
+    /// Update this designator to refer to the given complex component.
+    void addComplexUnchecked(QualType EltTy, bool Imag) {
+      Entries.push_back(PathEntry::ArrayIndex(Imag));
 
-    // This is technically a most-derived object, though in practice this
-    // is unlikely to matter.
-    MostDerivedType = EltTy;
-    MostDerivedIsArrayElement = true;
-    MostDerivedArraySize = 2;
-    MostDerivedPathLength = Entries.size();
-  }
+      // This is technically a most-derived object, though in practice this
+      // is unlikely to matter.
+      MostDerivedType = EltTy;
+      MostDerivedIsArrayElement = true;
+      MostDerivedArraySize = 2;
+      MostDerivedPathLength = Entries.size();
+    }
 
-  void addVectorElementUnchecked(QualType EltTy, uint64_t Size, uint64_t Idx) {
-    Entries.push_back(PathEntry::ArrayIndex(Idx));
-    MostDerivedType = EltTy;
-    MostDerivedPathLength = Entries.size();
-    MostDerivedArraySize = 0;
-    MostDerivedIsArrayElement = false;
-  }
+    void addVectorElementUnchecked(QualType EltTy, uint64_t Size,
+                                   uint64_t Idx) {
+      Entries.push_back(PathEntry::ArrayIndex(Idx));
+      MostDerivedType = EltTy;
+      MostDerivedPathLength = Entries.size();
+      MostDerivedArraySize = 0;
+      MostDerivedIsArrayElement = false;
+    }
 
-  void diagnoseUnsizedArrayPointerArithmetic(EvalInfo &Info, const Expr *E);
-  void diagnosePointerArithmetic(EvalInfo &Info, const Expr *E,
-                                 const APSInt &N);
-  /// Add N to the address of this subobject.
-  void adjustIndex(EvalInfo &Info, const Expr *E, APSInt N, const LValue &LV);
-};
+    void diagnoseUnsizedArrayPointerArithmetic(EvalInfo &Info, const Expr *E);
+    void diagnosePointerArithmetic(EvalInfo &Info, const Expr *E,
+                                   const APSInt &N);
+    /// Add N to the address of this subobject.
+    void adjustIndex(EvalInfo &Info, const Expr *E, APSInt N, const LValue &LV);
+  };
 
-/// A scope at the end of which an object can need to be destroyed.
-enum class ScopeKind { Block, FullExpression, Call };
-
-/// A reference to a particular call and its arguments.
-struct CallRef {
-  CallRef() : OrigCallee(), CallIndex(0), Version() {}
-  CallRef(const FunctionDecl *Callee, unsigned CallIndex, unsigned Version)
-      : OrigCallee(Callee), CallIndex(CallIndex), Version(Version) {}
-
-  explicit operator bool() const { return OrigCallee; }
-
-  /// Get the parameter that the caller initialized, corresponding to the
-  /// given parameter in the callee.
-  const ParmVarDecl *getOrigParam(const ParmVarDecl *PVD) const {
-    return OrigCallee ? OrigCallee->getParamDecl(PVD->getFunctionScopeIndex())
-                      : PVD;
-  }
-
-  /// The callee at the point where the arguments were evaluated. This might
-  /// be different from the actual callee (a different redeclaration, or a
-  /// virtual override), but this function's parameters are the ones that
-  /// appear in the parameter map.
-  const FunctionDecl *OrigCallee;
-  /// The call index of the frame that holds the argument values.
-  unsigned CallIndex;
-  /// The version of the parameters corresponding to this call.
-  unsigned Version;
-};
+  /// A scope at the end of which an object can need to be destroyed.
+  enum class ScopeKind {
+    Block,
+    FullExpression,
+    Call
+  };
 
-/// A stack frame in the constexpr call stack.
-class CallStackFrame : public interp::Frame {
-public:
-  EvalInfo &Info;
+  /// A reference to a particular call and its arguments.
+  struct CallRef {
+    CallRef() : OrigCallee(), CallIndex(0), Version() {}
+    CallRef(const FunctionDecl *Callee, unsigned CallIndex, unsigned Version)
+        : OrigCallee(Callee), CallIndex(CallIndex), Version(Version) {}
+
+    explicit operator bool() const { return OrigCallee; }
+
+    /// Get the parameter that the caller initialized, corresponding to the
+    /// given parameter in the callee.
+    const ParmVarDecl *getOrigParam(const ParmVarDecl *PVD) const {
+      return OrigCallee ? OrigCallee->getParamDecl(PVD->getFunctionScopeIndex())
+                        : PVD;
+    }
+
+    /// The callee at the point where the arguments were evaluated. This might
+    /// be different from the actual callee (a different redeclaration, or a
+    /// virtual override), but this function's parameters are the ones that
+    /// appear in the parameter map.
+    const FunctionDecl *OrigCallee;
+    /// The call index of the frame that holds the argument values.
+    unsigned CallIndex;
+    /// The version of the parameters corresponding to this call.
+    unsigned Version;
+  };
 
-  /// Parent - The caller of this stack frame.
-  CallStackFrame *Caller;
+  /// A stack frame in the constexpr call stack.
+  class CallStackFrame : public interp::Frame {
+  public:
+    EvalInfo &Info;
 
-  /// Callee - The function which was called.
-  const FunctionDecl *Callee;
+    /// Parent - The caller of this stack frame.
+    CallStackFrame *Caller;
 
-  /// This - The binding for the this pointer in this call, if any.
-  const LValue *This;
+    /// Callee - The function which was called.
+    const FunctionDecl *Callee;
 
-  /// CallExpr - The syntactical structure of member function calls
-  const Expr *CallExpr;
+    /// This - The binding for the this pointer in this call, if any.
+    const LValue *This;
 
-  /// Information on how to find the arguments to this call. Our arguments
-  /// are stored in our parent's CallStackFrame, using the ParmVarDecl* as a
-  /// key and this value as the version.
-  CallRef Arguments;
+    /// CallExpr - The syntactical structure of member function calls
+    const Expr *CallExpr;
 
-  /// Source location information about the default argument or default
-  /// initializer expression we're evaluating, if any.
-  CurrentSourceLocExprScope CurSourceLocExprScope;
+    /// Information on how to find the arguments to this call. Our arguments
+    /// are stored in our parent's CallStackFrame, using the ParmVarDecl* as a
+    /// key and this value as the version.
+    CallRef Arguments;
 
-  // Note that we intentionally use std::map here so that references to
-  // values are stable.
-  typedef std::pair<const void *, unsigned> MapKeyTy;
-  typedef std::map<MapKeyTy, APValue> MapTy;
-  /// Temporaries - Temporary lvalues materialized within this stack frame.
-  MapTy Temporaries;
+    /// Source location information about the default argument or default
+    /// initializer expression we're evaluating, if any.
+    CurrentSourceLocExprScope CurSourceLocExprScope;
 
-  /// CallRange - The source range of the call expression for this call.
-  SourceRange CallRange;
+    // Note that we intentionally use std::map here so that references to
+    // values are stable.
+    typedef std::pair<const void *, unsigned> MapKeyTy;
+    typedef std::map<MapKeyTy, APValue> MapTy;
+    /// Temporaries - Temporary lvalues materialized within this stack frame.
+    MapTy Temporaries;
 
-  /// Index - The call index of this call.
-  unsigned Index;
+    /// CallRange - The source range of the call expression for this call.
+    SourceRange CallRange;
 
-  /// The stack of integers for tracking version numbers for temporaries.
-  SmallVector<unsigned, 2> TempVersionStack = {1};
-  unsigned CurTempVersion = TempVersionStack.back();
+    /// Index - The call index of this call.
+    unsigned Index;
 
-  unsigned getTempVersion() const { return TempVersionStack.back(); }
+    /// The stack of integers for tracking version numbers for temporaries.
+    SmallVector<unsigned, 2> TempVersionStack = {1};
+    unsigned CurTempVersion = TempVersionStack.back();
 
-  void pushTempVersion() { TempVersionStack.push_back(++CurTempVersion); }
+    unsigned getTempVersion() const { return TempVersionStack.back(); }
 
-  void popTempVersion() { TempVersionStack.pop_back(); }
+    void pushTempVersion() {
+      TempVersionStack.push_back(++CurTempVersion);
+    }
 
-  CallRef createCall(const FunctionDecl *Callee) {
-    return {Callee, Index, ++CurTempVersion};
-  }
+    void popTempVersion() {
+      TempVersionStack.pop_back();
+    }
 
-  // FIXME: Adding this to every 'CallStackFrame' may have a nontrivial impact
-  // on the overall stack usage of deeply-recursing constexpr evaluations.
-  // (We should cache this map rather than recomputing it repeatedly.)
-  // But let's try this and see how it goes; we can look into caching the map
-  // as a later change.
+    CallRef createCall(const FunctionDecl *Callee) {
+      return {Callee, Index, ++CurTempVersion};
+    }
 
-  /// LambdaCaptureFields - Mapping from captured variables/this to
-  /// corresponding data members in the closure class.
-  llvm::DenseMap<const ValueDecl *, FieldDecl *> LambdaCaptureFields;
-  FieldDecl *LambdaThisCaptureField = nullptr;
+    // FIXME: Adding this to every 'CallStackFrame' may have a nontrivial impact
+    // on the overall stack usage of deeply-recursing constexpr evaluations.
+    // (We should cache this map rather than recomputing it repeatedly.)
+    // But let's try this and see how it goes; we can look into caching the map
+    // as a later change.
 
-  CallStackFrame(EvalInfo &Info, SourceRange CallRange,
-                 const FunctionDecl *Callee, const LValue *This,
-                 const Expr *CallExpr, CallRef Arguments);
-  ~CallStackFrame();
+    /// LambdaCaptureFields - Mapping from captured variables/this to
+    /// corresponding data members in the closure class.
+    llvm::DenseMap<const ValueDecl *, FieldDecl *> LambdaCaptureFields;
+    FieldDecl *LambdaThisCaptureField = nullptr;
 
-  // Return the temporary for Key whose version number is Version.
-  APValue *getTemporary(const void *Key, unsigned Version) {
-    MapKeyTy KV(Key, Version);
-    auto LB = Temporaries.lower_bound(KV);
-    if (LB != Temporaries.end() && LB->first == KV)
-      return &LB->second;
-    return nullptr;
-  }
+    CallStackFrame(EvalInfo &Info, SourceRange CallRange,
+                   const FunctionDecl *Callee, const LValue *This,
+                   const Expr *CallExpr, CallRef Arguments);
+    ~CallStackFrame();
 
-  // Return the current temporary for Key in the map.
-  APValue *getCurrentTemporary(const void *Key) {
-    auto UB = Temporaries.upper_bound(MapKeyTy(Key, UINT_MAX));
-    if (UB != Temporaries.begin() && std::prev(UB)->first.first == Key)
-      return &std::prev(UB)->second;
-    return nullptr;
-  }
+    // Return the temporary for Key whose version number is Version.
+    APValue *getTemporary(const void *Key, unsigned Version) {
+      MapKeyTy KV(Key, Version);
+      auto LB = Temporaries.lower_bound(KV);
+      if (LB != Temporaries.end() && LB->first == KV)
+        return &LB->second;
+      return nullptr;
+    }
 
-  // Return the version number of the current temporary for Key.
-  unsigned getCurrentTemporaryVersion(const void *Key) const {
-    auto UB = Temporaries.upper_bound(MapKeyTy(Key, UINT_MAX));
-    if (UB != Temporaries.begin() && std::prev(UB)->first.first == Key)
-      return std::prev(UB)->first.second;
-    return 0;
-  }
+    // Return the current temporary for Key in the map.
+    APValue *getCurrentTemporary(const void *Key) {
+      auto UB = Temporaries.upper_bound(MapKeyTy(Key, UINT_MAX));
+      if (UB != Temporaries.begin() && std::prev(UB)->first.first == Key)
+        return &std::prev(UB)->second;
+      return nullptr;
+    }
 
-  /// Allocate storage for an object of type T in this stack frame.
-  /// Populates LV with a handle to the created object. Key identifies
-  /// the temporary within the stack frame, and must not be reused without
-  /// bumping the temporary version number.
-  template <typename KeyT>
-  APValue &createTemporary(const KeyT *Key, QualType T, ScopeKind Scope,
-                           LValue &LV);
+    // Return the version number of the current temporary for Key.
+    unsigned getCurrentTemporaryVersion(const void *Key) const {
+      auto UB = Temporaries.upper_bound(MapKeyTy(Key, UINT_MAX));
+      if (UB != Temporaries.begin() && std::prev(UB)->first.first == Key)
+        return std::prev(UB)->first.second;
+      return 0;
+    }
 
-  /// Allocate storage for a parameter of a function call made in this frame.
-  APValue &createParam(CallRef Args, const ParmVarDecl *PVD, LValue &LV);
+    /// Allocate storage for an object of type T in this stack frame.
+    /// Populates LV with a handle to the created object. Key identifies
+    /// the temporary within the stack frame, and must not be reused without
+    /// bumping the temporary version number.
+    template<typename KeyT>
+    APValue &createTemporary(const KeyT *Key, QualType T,
+                             ScopeKind Scope, LValue &LV);
 
-  void describe(llvm::raw_ostream &OS) const override;
+    /// Allocate storage for a parameter of a function call made in this frame.
+    APValue &createParam(CallRef Args, const ParmVarDecl *PVD, LValue &LV);
 
-  Frame *getCaller() const override { return Caller; }
-  SourceRange getCallRange() const override { return CallRange; }
-  const FunctionDecl *getCallee() const override { return Callee; }
+    void describe(llvm::raw_ostream &OS) const override;
 
-  bool isStdFunction() const {
-    for (const DeclContext *DC = Callee; DC; DC = DC->getParent())
-      if (DC->isStdNamespace())
-        return true;
-    return false;
-  }
+    Frame *getCaller() const override { return Caller; }
+    SourceRange getCallRange() const override { return CallRange; }
+    const FunctionDecl *getCallee() const override { return Callee; }
 
-  /// Whether we're in a context where [[msvc::constexpr]] evaluation is
-  /// permitted. See MSConstexprDocs for description of permitted contexts.
-  bool CanEvalMSConstexpr = false;
+    bool isStdFunction() const {
+      for (const DeclContext *DC = Callee; DC; DC = DC->getParent())
+        if (DC->isStdNamespace())
+          return true;
+      return false;
+    }
 
-private:
-  APValue &createLocal(APValue::LValueBase Base, const void *Key, QualType T,
-                       ScopeKind Scope);
-};
+    /// Whether we're in a context where [[msvc::constexpr]] evaluation is
+    /// permitted. See MSConstexprDocs for description of permitted contexts.
+    bool CanEvalMSConstexpr = false;
 
-/// Temporarily override 'this'.
-class ThisOverrideRAII {
-public:
-  ThisOverrideRAII(CallStackFrame &Frame, const LValue *NewThis, bool Enable)
-      : Frame(Frame), OldThis(Frame.This) {
-    if (Enable)
-      Frame.This = NewThis;
-  }
-  ~ThisOverrideRAII() { Frame.This = OldThis; }
+  private:
+    APValue &createLocal(APValue::LValueBase Base, const void *Key, QualType T,
+                         ScopeKind Scope);
+  };
 
-private:
-  CallStackFrame &Frame;
-  const LValue *OldThis;
-};
+  /// Temporarily override 'this'.
+  class ThisOverrideRAII {
+  public:
+    ThisOverrideRAII(CallStackFrame &Frame, const LValue *NewThis, bool Enable)
+        : Frame(Frame), OldThis(Frame.This) {
+      if (Enable)
+        Frame.This = NewThis;
+    }
+    ~ThisOverrideRAII() {
+      Frame.This = OldThis;
+    }
+  private:
+    CallStackFrame &Frame;
+    const LValue *OldThis;
+  };
 
-// A shorthand time trace scope struct, prints source range, for example
-// {"name":"EvaluateAsRValue","args":{"detail":"<test.cc:8:21, col:25>"}}}
-class ExprTimeTraceScope {
-public:
-  ExprTimeTraceScope(const Expr *E, const ASTContext &Ctx, StringRef Name)
-      : TimeScope(Name, [E, &Ctx] {
-          return E->getSourceRange().printToString(Ctx.getSourceManager());
-        }) {}
+  // A shorthand time trace scope struct, prints source range, for example
+  // {"name":"EvaluateAsRValue","args":{"detail":"<test.cc:8:21, col:25>"}}}
+  class ExprTimeTraceScope {
+  public:
+    ExprTimeTraceScope(const Expr *E, const ASTContext &Ctx, StringRef Name)
+        : TimeScope(Name, [E, &Ctx] {
+            return E->getSourceRange().printToString(Ctx.getSourceManager());
+          }) {}
 
-private:
-  llvm::TimeTraceScope TimeScope;
-};
+  private:
+    llvm::TimeTraceScope TimeScope;
+  };
 
-/// RAII object used to change the current ability of
-/// [[msvc::constexpr]] evaulation.
-struct MSConstexprContextRAII {
-  CallStackFrame &Frame;
-  bool OldValue;
-  explicit MSConstexprContextRAII(CallStackFrame &Frame, bool Value)
-      : Frame(Frame), OldValue(Frame.CanEvalMSConstexpr) {
-    Frame.CanEvalMSConstexpr = Value;
-  }
+  /// RAII object used to change the current ability of
+  /// [[msvc::constexpr]] evaulation.
+  struct MSConstexprContextRAII {
+    CallStackFrame &Frame;
+    bool OldValue;
+    explicit MSConstexprContextRAII(CallStackFrame &Frame, bool Value)
+        : Frame(Frame), OldValue(Frame.CanEvalMSConstexpr) {
+      Frame.CanEvalMSConstexpr = Value;
+    }
 
-  ~MSConstexprContextRAII() { Frame.CanEvalMSConstexpr = OldValue; }
-};
-} // namespace
+    ~MSConstexprContextRAII() { Frame.CanEvalMSConstexpr = OldValue; }
+  };
+}
 
-static bool HandleDestruction(EvalInfo &Info, const Expr *E, const LValue &This,
-                              QualType ThisType);
+static bool HandleDestruction(EvalInfo &Info, const Expr *E,
+                              const LValue &This, QualType ThisType);
 static bool HandleDestruction(EvalInfo &Info, SourceLocation Loc,
                               APValue::LValueBase LVBase, APValue &Value,
                               QualType T);
 
 namespace {
-/// A cleanup, and a flag indicating whether it is lifetime-extended.
-class Cleanup {
-  llvm::PointerIntPair<APValue *, 2, ScopeKind> Value;
-  APValue::LValueBase Base;
-  QualType T;
+  /// A cleanup, and a flag indicating whether it is lifetime-extended.
+  class Cleanup {
+    llvm::PointerIntPair<APValue*, 2, ScopeKind> Value;
+    APValue::LValueBase Base;
+    QualType T;
 
-public:
-  Cleanup(APValue *Val, APValue::LValueBase Base, QualType T, ScopeKind Scope)
-      : Value(Val, Scope), Base(Base), T(T) {}
-
-  /// Determine whether this cleanup should be performed at the end of the
-  /// given kind of scope.
-  bool isDestroyedAtEndOf(ScopeKind K) const {
-    return (int)Value.getInt() >= (int)K;
-  }
-  bool endLifetime(EvalInfo &Info, bool RunDestructors) {
-    if (RunDestructors) {
-      SourceLocation Loc;
-      if (const ValueDecl *VD = Base.dyn_cast<const ValueDecl *>())
-        Loc = VD->getLocation();
-      else if (const Expr *E = Base.dyn_cast<const Expr *>())
-        Loc = E->getExprLoc();
-      return HandleDestruction(Info, Loc, Base, *Value.getPointer(), T);
-    }
-    *Value.getPointer() = APValue();
-    return true;
-  }
+  public:
+    Cleanup(APValue *Val, APValue::LValueBase Base, QualType T,
+            ScopeKind Scope)
+        : Value(Val, Scope), Base(Base), T(T) {}
+
+    /// Determine whether this cleanup should be performed at the end of the
+    /// given kind of scope.
+    bool isDestroyedAtEndOf(ScopeKind K) const {
+      return (int)Value.getInt() >= (int)K;
+    }
+    bool endLifetime(EvalInfo &Info, bool RunDestructors) {
+      if (RunDestructors) {
+        SourceLocation Loc;
+        if (const ValueDecl *VD = Base.dyn_cast<const ValueDecl*>())
+          Loc = VD->getLocation();
+        else if (const Expr *E = Base.dyn_cast<const Expr*>())
+          Loc = E->getExprLoc();
+        return HandleDestruction(Info, Loc, Base, *Value.getPointer(), T);
+      }
+      *Value.getPointer() = APValue();
+      return true;
+    }
 
-  bool hasSideEffect() { return T.isDestructedType(); }
-};
+    bool hasSideEffect() {
+      return T.isDestructedType();
+    }
+  };
 
-/// A reference to an object whose construction we are currently evaluating.
-struct ObjectUnderConstruction {
-  APValue::LValueBase Base;
-  ArrayRef<APValue::LValuePathEntry> Path;
-  friend bool operator==(const ObjectUnderConstruction &LHS,
-                         const ObjectUnderConstruction &RHS) {
-    return LHS.Base == RHS.Base && LHS.Path == RHS.Path;
-  }
-  friend llvm::hash_code hash_value(const ObjectUnderConstruction &Obj) {
-    return llvm::hash_combine(Obj.Base, Obj.Path);
-  }
-};
-enum class ConstructionPhase {
-  None,
-  Bases,
-  AfterBases,
-  AfterFields,
-  Destroying,
-  DestroyingBases
-};
-} // namespace
+  /// A reference to an object whose construction we are currently evaluating.
+  struct ObjectUnderConstruction {
+    APValue::LValueBase Base;
+    ArrayRef<APValue::LValuePathEntry> Path;
+    friend bool operator==(const ObjectUnderConstruction &LHS,
+                           const ObjectUnderConstruction &RHS) {
+      return LHS.Base == RHS.Base && LHS.Path == RHS.Path;
+    }
+    friend llvm::hash_code hash_value(const ObjectUnderConstruction &Obj) {
+      return llvm::hash_combine(Obj.Base, Obj.Path);
+    }
+  };
+  enum class ConstructionPhase {
+    None,
+    Bases,
+    AfterBases,
+    AfterFields,
+    Destroying,
+    DestroyingBases
+  };
+}
 
 namespace llvm {
-template <> struct DenseMapInfo<ObjectUnderConstruction> {
+template<> struct DenseMapInfo<ObjectUnderConstruction> {
   using Base = DenseMapInfo<APValue::LValueBase>;
   static ObjectUnderConstruction getEmptyKey() {
-    return {Base::getEmptyKey(), {}};
-  }
+    return {Base::getEmptyKey(), {}}; }
   static ObjectUnderConstruction getTombstoneKey() {
     return {Base::getTombstoneKey(), {}};
   }
@@ -731,531 +747,541 @@ template <> struct DenseMapInfo<ObjectUnderConstruction> {
     return LHS == RHS;
   }
 };
-} // namespace llvm
+}
 
 namespace {
-/// A dynamically-allocated heap object.
-struct DynAlloc {
-  /// The value of this heap-allocated object.
-  APValue Value;
-  /// The allocating expression; used for diagnostics. Either a CXXNewExpr
-  /// or a CallExpr (the latter is for direct calls to operator new inside
-  /// std::allocator<T>::allocate).
-  const Expr *AllocExpr = nullptr;
-
-  enum Kind { New, ArrayNew, StdAllocator };
-
-  /// Get the kind of the allocation. This must match between allocation
-  /// and deallocation.
-  Kind getKind() const {
-    if (auto *NE = dyn_cast<CXXNewExpr>(AllocExpr))
-      return NE->isArray() ? ArrayNew : New;
-    assert(isa<CallExpr>(AllocExpr));
-    return StdAllocator;
-  }
-};
-
-struct DynAllocOrder {
-  bool operator()(DynamicAllocLValue L, DynamicAllocLValue R) const {
-    return L.getIndex() < R.getIndex();
-  }
-};
-
-/// EvalInfo - This is a private struct used by the evaluator to capture
-/// information about a subexpression as it is folded.  It retains information
-/// about the AST context, but also maintains information about the folded
-/// expression.
-///
-/// If an expression could be evaluated, it is still possible it is not a C
-/// "integer constant expression" or constant expression.  If not, this struct
-/// captures information about how and why not.
-///
-/// One bit of information passed *into* the request for constant folding
-/// indicates whether the subexpression is "evaluated" or not according to C
-/// rules.  For example, the RHS of (0 && foo()) is not evaluated.  We can
-/// evaluate the expression regardless of what the RHS is, but C only allows
-/// certain things in certain situations.
-class EvalInfo final : public interp::State {
-public:
-  /// CurrentCall - The top of the constexpr call stack.
-  CallStackFrame *CurrentCall;
-
-  /// CallStackDepth - The number of calls in the call stack right now.
-  unsigned CallStackDepth;
-
-  /// NextCallIndex - The next call index to assign.
-  unsigned NextCallIndex;
-
-  /// StepsLeft - The remaining number of evaluation steps we're permitted
-  /// to perform. This is essentially a limit for the number of statements
-  /// we will evaluate.
-  unsigned StepsLeft;
-
-  /// Enable the experimental new constant interpreter. If an expression is
-  /// not supported by the interpreter, an error is triggered.
-  bool EnableNewConstInterp;
-
-  /// BottomFrame - The frame in which evaluation started. This must be
-  /// initialized after CurrentCall and CallStackDepth.
-  CallStackFrame BottomFrame;
-
-  /// A stack of values whose lifetimes end at the end of some surrounding
-  /// evaluation frame.
-  llvm::SmallVector<Cleanup, 16> CleanupStack;
-
-  /// EvaluatingDecl - This is the declaration whose initializer is being
-  /// evaluated, if any.
-  APValue::LValueBase EvaluatingDecl;
+  /// A dynamically-allocated heap object.
+  struct DynAlloc {
+    /// The value of this heap-allocated object.
+    APValue Value;
+    /// The allocating expression; used for diagnostics. Either a CXXNewExpr
+    /// or a CallExpr (the latter is for direct calls to operator new inside
+    /// std::allocator<T>::allocate).
+    const Expr *AllocExpr = nullptr;
+
+    enum Kind {
+      New,
+      ArrayNew,
+      StdAllocator
+    };
 
-  enum class EvaluatingDeclKind {
-    None,
-    /// We're evaluating the construction of EvaluatingDecl.
-    Ctor,
-    /// We're evaluating the destruction of EvaluatingDecl.
-    Dtor,
-  };
-  EvaluatingDeclKind IsEvaluatingDecl = EvaluatingDeclKind::None;
-
-  /// EvaluatingDeclValue - This is the value being constructed for the
-  /// declaration whose initializer is being evaluated, if any.
-  APValue *EvaluatingDeclValue;
-
-  /// Stack of loops and 'switch' statements which we're currently
-  /// breaking/continuing; null entries are used to mark unlabeled
-  /// break/continue.
-  SmallVector<const Stmt *> BreakContinueStack;
-
-  /// Set of objects that are currently being constructed.
-  llvm::DenseMap<ObjectUnderConstruction, ConstructionPhase>
-      ObjectsUnderConstruction;
-
-  /// Current heap allocations, along with the location where each was
-  /// allocated. We use std::map here because we need stable addresses
-  /// for the stored APValues.
-  std::map<DynamicAllocLValue, DynAlloc, DynAllocOrder> HeapAllocs;
-
-  /// The number of heap allocations performed so far in this evaluation.
-  unsigned NumHeapAllocs = 0;
-
-  struct EvaluatingConstructorRAII {
-    EvalInfo &EI;
-    ObjectUnderConstruction Object;
-    bool DidInsert;
-    EvaluatingConstructorRAII(EvalInfo &EI, ObjectUnderConstruction Object,
-                              bool HasBases)
-        : EI(EI), Object(Object) {
-      DidInsert =
-          EI.ObjectsUnderConstruction
-              .insert({Object, HasBases ? ConstructionPhase::Bases
-                                        : ConstructionPhase::AfterBases})
-              .second;
-    }
-    void finishedConstructingBases() {
-      EI.ObjectsUnderConstruction[Object] = ConstructionPhase::AfterBases;
-    }
-    void finishedConstructingFields() {
-      EI.ObjectsUnderConstruction[Object] = ConstructionPhase::AfterFields;
-    }
-    ~EvaluatingConstructorRAII() {
-      if (DidInsert)
-        EI.ObjectsUnderConstruction.erase(Object);
+    /// Get the kind of the allocation. This must match between allocation
+    /// and deallocation.
+    Kind getKind() const {
+      if (auto *NE = dyn_cast<CXXNewExpr>(AllocExpr))
+        return NE->isArray() ? ArrayNew : New;
+      assert(isa<CallExpr>(AllocExpr));
+      return StdAllocator;
     }
   };
 
-  struct EvaluatingDestructorRAII {
-    EvalInfo &EI;
-    ObjectUnderConstruction Object;
-    bool DidInsert;
-    EvaluatingDestructorRAII(EvalInfo &EI, ObjectUnderConstruction Object)
-        : EI(EI), Object(Object) {
-      DidInsert = EI.ObjectsUnderConstruction
-                      .insert({Object, ConstructionPhase::Destroying})
-                      .second;
-    }
-    void startedDestroyingBases() {
-      EI.ObjectsUnderConstruction[Object] = ConstructionPhase::DestroyingBases;
-    }
-    ~EvaluatingDestructorRAII() {
-      if (DidInsert)
-        EI.ObjectsUnderConstruction.erase(Object);
+  struct DynAllocOrder {
+    bool operator()(DynamicAllocLValue L, DynamicAllocLValue R) const {
+      return L.getIndex() < R.getIndex();
     }
   };
 
-  ConstructionPhase
-  isEvaluatingCtorDtor(APValue::LValueBase Base,
-                       ArrayRef<APValue::LValuePathEntry> Path) {
-    return ObjectsUnderConstruction.lookup({Base, Path});
-  }
+  /// EvalInfo - This is a private struct used by the evaluator to capture
+  /// information about a subexpression as it is folded.  It retains information
+  /// about the AST context, but also maintains information about the folded
+  /// expression.
+  ///
+  /// If an expression could be evaluated, it is still possible it is not a C
+  /// "integer constant expression" or constant expression.  If not, this struct
+  /// captures information about how and why not.
+  ///
+  /// One bit of information passed *into* the request for constant folding
+  /// indicates whether the subexpression is "evaluated" or not according to C
+  /// rules.  For example, the RHS of (0 && foo()) is not evaluated.  We can
+  /// evaluate the expression regardless of what the RHS is, but C only allows
+  /// certain things in certain situations.
+  class EvalInfo final : public interp::State {
+  public:
+    /// CurrentCall - The top of the constexpr call stack.
+    CallStackFrame *CurrentCall;
+
+    /// CallStackDepth - The number of calls in the call stack right now.
+    unsigned CallStackDepth;
+
+    /// NextCallIndex - The next call index to assign.
+    unsigned NextCallIndex;
+
+    /// StepsLeft - The remaining number of evaluation steps we're permitted
+    /// to perform. This is essentially a limit for the number of statements
+    /// we will evaluate.
+    unsigned StepsLeft;
+
+    /// Enable the experimental new constant interpreter. If an expression is
+    /// not supported by the interpreter, an error is triggered.
+    bool EnableNewConstInterp;
+
+    /// BottomFrame - The frame in which evaluation started. This must be
+    /// initialized after CurrentCall and CallStackDepth.
+    CallStackFrame BottomFrame;
+
+    /// A stack of values whose lifetimes end at the end of some surrounding
+    /// evaluation frame.
+    llvm::SmallVector<Cleanup, 16> CleanupStack;
+
+    /// EvaluatingDecl - This is the declaration whose initializer is being
+    /// evaluated, if any.
+    APValue::LValueBase EvaluatingDecl;
+
+    enum class EvaluatingDeclKind {
+      None,
+      /// We're evaluating the construction of EvaluatingDecl.
+      Ctor,
+      /// We're evaluating the destruction of EvaluatingDecl.
+      Dtor,
+    };
+    EvaluatingDeclKind IsEvaluatingDecl = EvaluatingDeclKind::None;
+
+    /// EvaluatingDeclValue - This is the value being constructed for the
+    /// declaration whose initializer is being evaluated, if any.
+    APValue *EvaluatingDeclValue;
+
+    /// Stack of loops and 'switch' statements which we're currently
+    /// breaking/continuing; null entries are used to mark unlabeled
+    /// break/continue.
+    SmallVector<const Stmt *> BreakContinueStack;
+
+    /// Set of objects that are currently being constructed.
+    llvm::DenseMap<ObjectUnderConstruction, ConstructionPhase>
+        ObjectsUnderConstruction;
+
+    /// Current heap allocations, along with the location where each was
+    /// allocated. We use std::map here because we need stable addresses
+    /// for the stored APValues.
+    std::map<DynamicAllocLValue, DynAlloc, DynAllocOrder> HeapAllocs;
+
+    /// The number of heap allocations performed so far in this evaluation.
+    unsigned NumHeapAllocs = 0;
+
+    struct EvaluatingConstructorRAII {
+      EvalInfo &EI;
+      ObjectUnderConstruction Object;
+      bool DidInsert;
+      EvaluatingConstructorRAII(EvalInfo &EI, ObjectUnderConstruction Object,
+                                bool HasBases)
+          : EI(EI), Object(Object) {
+        DidInsert =
+            EI.ObjectsUnderConstruction
+                .insert({Object, HasBases ? ConstructionPhase::Bases
+                                          : ConstructionPhase::AfterBases})
+                .second;
+      }
+      void finishedConstructingBases() {
+        EI.ObjectsUnderConstruction[Object] = ConstructionPhase::AfterBases;
+      }
+      void finishedConstructingFields() {
+        EI.ObjectsUnderConstruction[Object] = ConstructionPhase::AfterFields;
+      }
+      ~EvaluatingConstructorRAII() {
+        if (DidInsert) EI.ObjectsUnderConstruction.erase(Object);
+      }
+    };
 
-  /// If we're currently speculatively evaluating, the outermost call stack
-  /// depth at which we can mutate state, otherwise 0.
-  unsigned SpeculativeEvaluationDepth = 0;
+    struct EvaluatingDestructorRAII {
+      EvalInfo &EI;
+      ObjectUnderConstruction Object;
+      bool DidInsert;
+      EvaluatingDestructorRAII(EvalInfo &EI, ObjectUnderConstruction Object)
+          : EI(EI), Object(Object) {
+        DidInsert = EI.ObjectsUnderConstruction
+                        .insert({Object, ConstructionPhase::Destroying})
+                        .second;
+      }
+      void startedDestroyingBases() {
+        EI.ObjectsUnderConstruction[Object] =
+            ConstructionPhase::DestroyingBases;
+      }
+      ~EvaluatingDestructorRAII() {
+        if (DidInsert)
+          EI.ObjectsUnderConstruction.erase(Object);
+      }
+    };
 
-  /// The current array initialization index, if we're performing array
-  /// initialization.
-  uint64_t ArrayInitIndex = -1;
+    ConstructionPhase
+    isEvaluatingCtorDtor(APValue::LValueBase Base,
+                         ArrayRef<APValue::LValuePathEntry> Path) {
+      return ObjectsUnderConstruction.lookup({Base, Path});
+    }
 
-  EvalInfo(const ASTContext &C, Expr::EvalStatus &S, EvaluationMode Mode)
-      : State(const_cast<ASTContext &>(C), S), CurrentCall(nullptr),
-        CallStackDepth(0), NextCallIndex(1),
-        StepsLeft(C.getLangOpts().ConstexprStepLimit),
-        EnableNewConstInterp(C.getLangOpts().EnableNewConstInterp),
-        BottomFrame(*this, SourceLocation(), /*Callee=*/nullptr,
-                    /*This=*/nullptr,
-                    /*CallExpr=*/nullptr, CallRef()),
-        EvaluatingDecl((const ValueDecl *)nullptr),
-        EvaluatingDeclValue(nullptr) {
-    EvalMode = Mode;
-  }
+    /// If we're currently speculatively evaluating, the outermost call stack
+    /// depth at which we can mutate state, otherwise 0.
+    unsigned SpeculativeEvaluationDepth = 0;
 
-  ~EvalInfo() { discardCleanups(); }
+    /// The current array initialization index, if we're performing array
+    /// initialization.
+    uint64_t ArrayInitIndex = -1;
 
-  void setEvaluatingDecl(APValue::LValueBase Base, APValue &Value,
-                         EvaluatingDeclKind EDK = EvaluatingDeclKind::Ctor) {
-    EvaluatingDecl = Base;
-    IsEvaluatingDecl = EDK;
-    EvaluatingDeclValue = &Value;
-  }
+    EvalInfo(const ASTContext &C, Expr::EvalStatus &S, EvaluationMode Mode)
+        : State(const_cast<ASTContext &>(C), S), CurrentCall(nullptr),
+          CallStackDepth(0), NextCallIndex(1),
+          StepsLeft(C.getLangOpts().ConstexprStepLimit),
+          EnableNewConstInterp(C.getLangOpts().EnableNewConstInterp),
+          BottomFrame(*this, SourceLocation(), /*Callee=*/nullptr,
+                      /*This=*/nullptr,
+                      /*CallExpr=*/nullptr, CallRef()),
+          EvaluatingDecl((const ValueDecl *)nullptr),
+          EvaluatingDeclValue(nullptr) {
+      EvalMode = Mode;
+    }
 
-  bool CheckCallLimit(SourceLocation Loc) {
-    // Don't perform any constexpr calls (other than the call we're checking)
-    // when checking a potential constant expression.
-    if (checkingPotentialConstantExpression() && CallStackDepth > 1)
-      return false;
-    if (NextCallIndex == 0) {
-      // NextCallIndex has wrapped around.
-      FFDiag(Loc, diag::note_constexpr_call_limit_exceeded);
-      return false;
+    ~EvalInfo() {
+      discardCleanups();
     }
-    if (CallStackDepth <= getLangOpts().ConstexprCallDepth)
-      return true;
-    FFDiag(Loc, diag::note_constexpr_depth_limit_exceeded)
-        << getLangOpts().ConstexprCallDepth;
-    return false;
-  }
 
-  bool CheckArraySize(SourceLocation Loc, unsigned BitWidth, uint64_t ElemCount,
-                      bool Diag) {
-    // FIXME: GH63562
-    // APValue stores array extents as unsigned,
-    // so anything that is greater that unsigned would overflow when
-    // constructing the array, we catch this here.
-    if (BitWidth > ConstantArrayType::getMaxSizeBits(Ctx) ||
-        ElemCount > uint64_t(std::numeric_limits<unsigned>::max())) {
-      if (Diag)
-        FFDiag(Loc, diag::note_constexpr_new_too_large) << ElemCount;
-      return false;
+    void setEvaluatingDecl(APValue::LValueBase Base, APValue &Value,
+                           EvaluatingDeclKind EDK = EvaluatingDeclKind::Ctor) {
+      EvaluatingDecl = Base;
+      IsEvaluatingDecl = EDK;
+      EvaluatingDeclValue = &Value;
     }
 
-    // FIXME: GH63562
-    // Arrays allocate an APValue per element.
-    // We use the number of constexpr steps as a proxy for the maximum size
-    // of arrays to avoid exhausting the system resources, as initialization
-    // of each element is likely to take some number of steps anyway.
-    uint64_t Limit = getLangOpts().ConstexprStepLimit;
-    if (Limit != 0 && ElemCount > Limit) {
-      if (Diag)
-        FFDiag(Loc, diag::note_constexpr_new_exceeds_limits)
-            << ElemCount << Limit;
+    bool CheckCallLimit(SourceLocation Loc) {
+      // Don't perform any constexpr calls (other than the call we're checking)
+      // when checking a potential constant expression.
+      if (checkingPotentialConstantExpression() && CallStackDepth > 1)
+        return false;
+      if (NextCallIndex == 0) {
+        // NextCallIndex has wrapped around.
+        FFDiag(Loc, diag::note_constexpr_call_limit_exceeded);
+        return false;
+      }
+      if (CallStackDepth <= getLangOpts().ConstexprCallDepth)
+        return true;
+      FFDiag(Loc, diag::note_constexpr_depth_limit_exceeded)
+        << getLangOpts().ConstexprCallDepth;
       return false;
     }
-    return true;
-  }
 
-  std::pair<CallStackFrame *, unsigned>
-  getCallFrameAndDepth(unsigned CallIndex) {
-    assert(CallIndex && "no call index in getCallFrameAndDepth");
-    // We will eventually hit BottomFrame, which has Index 1, so Frame can't
-    // be null in this loop.
-    unsigned Depth = CallStackDepth;
-    CallStackFrame *Frame = CurrentCall;
-    while (Frame->Index > CallIndex) {
-      Frame = Frame->Caller;
-      --Depth;
-    }
-    if (Frame->Index == CallIndex)
-      return {Frame, Depth};
-    return {nullptr, 0};
-  }
+    bool CheckArraySize(SourceLocation Loc, unsigned BitWidth,
+                        uint64_t ElemCount, bool Diag) {
+      // FIXME: GH63562
+      // APValue stores array extents as unsigned,
+      // so anything that is greater that unsigned would overflow when
+      // constructing the array, we catch this here.
+      if (BitWidth > ConstantArrayType::getMaxSizeBits(Ctx) ||
+          ElemCount > uint64_t(std::numeric_limits<unsigned>::max())) {
+        if (Diag)
+          FFDiag(Loc, diag::note_constexpr_new_too_large) << ElemCount;
+        return false;
+      }
 
-  bool nextStep(const Stmt *S) {
-    if (getLangOpts().ConstexprStepLimit == 0)
+      // FIXME: GH63562
+      // Arrays allocate an APValue per element.
+      // We use the number of constexpr steps as a proxy for the maximum size
+      // of arrays to avoid exhausting the system resources, as initialization
+      // of each element is likely to take some number of steps anyway.
+      uint64_t Limit = getLangOpts().ConstexprStepLimit;
+      if (Limit != 0 && ElemCount > Limit) {
+        if (Diag)
+          FFDiag(Loc, diag::note_constexpr_new_exceeds_limits)
+              << ElemCount << Limit;
+        return false;
+      }
       return true;
-
-    if (!StepsLeft) {
-      FFDiag(S->getBeginLoc(), diag::note_constexpr_step_limit_exceeded);
-      return false;
     }
-    --StepsLeft;
-    return true;
-  }
 
-  APValue *createHeapAlloc(const Expr *E, QualType T, LValue &LV);
-
-  std::optional<DynAlloc *> lookupDynamicAlloc(DynamicAllocLValue DA) {
-    std::optional<DynAlloc *> Result;
-    auto It = HeapAllocs.find(DA);
-    if (It != HeapAllocs.end())
-      Result = &It->second;
-    return Result;
-  }
+    std::pair<CallStackFrame *, unsigned>
+    getCallFrameAndDepth(unsigned CallIndex) {
+      assert(CallIndex && "no call index in getCallFrameAndDepth");
+      // We will eventually hit BottomFrame, which has Index 1, so Frame can't
+      // be null in this loop.
+      unsigned Depth = CallStackDepth;
+      CallStackFrame *Frame = CurrentCall;
+      while (Frame->Index > CallIndex) {
+        Frame = Frame->Caller;
+        --Depth;
+      }
+      if (Frame->Index == CallIndex)
+        return {Frame, Depth};
+      return {nullptr, 0};
+    }
 
-  /// Get the allocated storage for the given parameter of the given call.
-  APValue *getParamSlot(CallRef Call, const ParmVarDecl *PVD) {
-    CallStackFrame *Frame = getCallFrameAndDepth(Call.CallIndex).first;
-    return Frame ? Frame->getTemporary(Call.getOrigParam(PVD), Call.Version)
-                 : nullptr;
-  }
+    bool nextStep(const Stmt *S) {
+      if (getLangOpts().ConstexprStepLimit == 0)
+        return true;
 
-  /// Information about a stack frame for std::allocator<T>::[de]allocate.
-  struct StdAllocatorCaller {
-    unsigned FrameIndex;
-    QualType ElemType;
-    const Expr *Call;
-    explicit operator bool() const { return FrameIndex != 0; };
-  };
+      if (!StepsLeft) {
+        FFDiag(S->getBeginLoc(), diag::note_constexpr_step_limit_exceeded);
+        return false;
+      }
+      --StepsLeft;
+      return true;
+    }
 
-  StdAllocatorCaller getStdAllocatorCaller(StringRef FnName) const {
-    for (const CallStackFrame *Call = CurrentCall; Call != &BottomFrame;
-         Call = Call->Caller) {
-      const auto *MD = dyn_cast_or_null<CXXMethodDecl>(Call->Callee);
-      if (!MD)
-        continue;
-      const IdentifierInfo *FnII = MD->getIdentifier();
-      if (!FnII || !FnII->isStr(FnName))
-        continue;
+    APValue *createHeapAlloc(const Expr *E, QualType T, LValue &LV);
 
-      const auto *CTSD =
-          dyn_cast<ClassTemplateSpecializationDecl>(MD->getParent());
-      if (!CTSD)
-        continue;
+    std::optional<DynAlloc *> lookupDynamicAlloc(DynamicAllocLValue DA) {
+      std::optional<DynAlloc *> Result;
+      auto It = HeapAllocs.find(DA);
+      if (It != HeapAllocs.end())
+        Result = &It->second;
+      return Result;
+    }
 
-      const IdentifierInfo *ClassII = CTSD->getIdentifier();
-      const TemplateArgumentList &TAL = CTSD->getTemplateArgs();
-      if (CTSD->isInStdNamespace() && ClassII && ClassII->isStr("allocator") &&
-          TAL.size() >= 1 && TAL[0].getKind() == TemplateArgument::Type)
-        return {Call->Index, TAL[0].getAsType(), Call->CallExpr};
+    /// Get the allocated storage for the given parameter of the given call.
+    APValue *getParamSlot(CallRef Call, const ParmVarDecl *PVD) {
+      CallStackFrame *Frame = getCallFrameAndDepth(Call.CallIndex).first;
+      return Frame ? Frame->getTemporary(Call.getOrigParam(PVD), Call.Version)
+                   : nullptr;
     }
 
-    return {};
-  }
+    /// Information about a stack frame for std::allocator<T>::[de]allocate.
+    struct StdAllocatorCaller {
+      unsigned FrameIndex;
+      QualType ElemType;
+      const Expr *Call;
+      explicit operator bool() const { return FrameIndex != 0; };
+    };
 
-  void performLifetimeExtension() {
-    // Disable the cleanups for lifetime-extended temporaries.
-    llvm::erase_if(CleanupStack, [](Cleanup &C) {
-      return !C.isDestroyedAtEndOf(ScopeKind::FullExpression);
-    });
-  }
+    StdAllocatorCaller getStdAllocatorCaller(StringRef FnName) const {
+      for (const CallStackFrame *Call = CurrentCall; Call != &BottomFrame;
+           Call = Call->Caller) {
+        const auto *MD = dyn_cast_or_null<CXXMethodDecl>(Call->Callee);
+        if (!MD)
+          continue;
+        const IdentifierInfo *FnII = MD->getIdentifier();
+        if (!FnII || !FnII->isStr(FnName))
+          continue;
 
-  /// Throw away any remaining cleanups at the end of evaluation. If any
-  /// cleanups would have had a side-effect, note that as an unmodeled
-  /// side-effect and return false. Otherwise, return true.
-  bool discardCleanups() {
-    for (Cleanup &C : CleanupStack) {
-      if (C.hasSideEffect() && !noteSideEffect()) {
-        CleanupStack.clear();
-        return false;
+        const auto *CTSD =
+            dyn_cast<ClassTemplateSpecializationDecl>(MD->getParent());
+        if (!CTSD)
+          continue;
+
+        const IdentifierInfo *ClassII = CTSD->getIdentifier();
+        const TemplateArgumentList &TAL = CTSD->getTemplateArgs();
+        if (CTSD->isInStdNamespace() && ClassII &&
+            ClassII->isStr("allocator") && TAL.size() >= 1 &&
+            TAL[0].getKind() == TemplateArgument::Type)
+          return {Call->Index, TAL[0].getAsType(), Call->CallExpr};
       }
+
+      return {};
     }
-    CleanupStack.clear();
-    return true;
-  }
 
-private:
-  const interp::Frame *getCurrentFrame() override { return CurrentCall; }
-  const interp::Frame *getBottomFrame() const override { return &BottomFrame; }
+    void performLifetimeExtension() {
+      // Disable the cleanups for lifetime-extended temporaries.
+      llvm::erase_if(CleanupStack, [](Cleanup &C) {
+        return !C.isDestroyedAtEndOf(ScopeKind::FullExpression);
+      });
+    }
 
-  unsigned getCallStackDepth() override { return CallStackDepth; }
-  bool stepsLeft() const override { return StepsLeft > 0; }
+    /// Throw away any remaining cleanups at the end of evaluation. If any
+    /// cleanups would have had a side-effect, note that as an unmodeled
+    /// side-effect and return false. Otherwise, return true.
+    bool discardCleanups() {
+      for (Cleanup &C : CleanupStack) {
+        if (C.hasSideEffect() && !noteSideEffect()) {
+          CleanupStack.clear();
+          return false;
+        }
+      }
+      CleanupStack.clear();
+      return true;
+    }
 
-public:
-  /// Notes that we failed to evaluate an expression that other expressions
-  /// directly depend on, and determine if we should keep evaluating. This
-  /// should only be called if we actually intend to keep evaluating.
-  ///
-  /// Call noteSideEffect() instead if we may be able to ignore the value that
-  /// we failed to evaluate, e.g. if we failed to evaluate Foo() in:
-  ///
-  /// (Foo(), 1)      // use noteSideEffect
-  /// (Foo() || true) // use noteSideEffect
-  /// Foo() + 1       // use noteFailure
-  [[nodiscard]] bool noteFailure() {
-    // Failure when evaluating some expression often means there is some
-    // subexpression whose evaluation was skipped. Therefore, (because we
-    // don't track whether we skipped an expression when unwinding after an
-    // evaluation failure) every evaluation failure that bubbles up from a
-    // subexpression implies that a side-effect has potentially happened. We
-    // skip setting the HasSideEffects flag to true until we decide to
-    // continue evaluating after that point, which happens here.
-    bool KeepGoing = keepEvaluatingAfterFailure();
-    EvalStatus.HasSideEffects |= KeepGoing;
-    return KeepGoing;
-  }
-
-  class ArrayInitLoopIndex {
-    EvalInfo &Info;
-    uint64_t OuterIndex;
+  private:
+    const interp::Frame *getCurrentFrame() override { return CurrentCall; }
+    const interp::Frame *getBottomFrame() const override { return &BottomFrame; }
+
+    unsigned getCallStackDepth() override { return CallStackDepth; }
+    bool stepsLeft() const override { return StepsLeft > 0; }
 
   public:
-    ArrayInitLoopIndex(EvalInfo &Info)
-        : Info(Info), OuterIndex(Info.ArrayInitIndex) {
-      Info.ArrayInitIndex = 0;
-    }
-    ~ArrayInitLoopIndex() { Info.ArrayInitIndex = OuterIndex; }
+    /// Notes that we failed to evaluate an expression that other expressions
+    /// directly depend on, and determine if we should keep evaluating. This
+    /// should only be called if we actually intend to keep evaluating.
+    ///
+    /// Call noteSideEffect() instead if we may be able to ignore the value that
+    /// we failed to evaluate, e.g. if we failed to evaluate Foo() in:
+    ///
+    /// (Foo(), 1)      // use noteSideEffect
+    /// (Foo() || true) // use noteSideEffect
+    /// Foo() + 1       // use noteFailure
+    [[nodiscard]] bool noteFailure() {
+      // Failure when evaluating some expression often means there is some
+      // subexpression whose evaluation was skipped. Therefore, (because we
+      // don't track whether we skipped an expression when unwinding after an
+      // evaluation failure) every evaluation failure that bubbles up from a
+      // subexpression implies that a side-effect has potentially happened. We
+      // skip setting the HasSideEffects flag to true until we decide to
+      // continue evaluating after that point, which happens here.
+      bool KeepGoing = keepEvaluatingAfterFailure();
+      EvalStatus.HasSideEffects |= KeepGoing;
+      return KeepGoing;
+    }
+
+    class ArrayInitLoopIndex {
+      EvalInfo &Info;
+      uint64_t OuterIndex;
 
-    operator uint64_t &() { return Info.ArrayInitIndex; }
+    public:
+      ArrayInitLoopIndex(EvalInfo &Info)
+          : Info(Info), OuterIndex(Info.ArrayInitIndex) {
+        Info.ArrayInitIndex = 0;
+      }
+      ~ArrayInitLoopIndex() { Info.ArrayInitIndex = OuterIndex; }
+
+      operator uint64_t&() { return Info.ArrayInitIndex; }
+    };
   };
-};
 
-/// Object used to treat all foldable expressions as constant expressions.
-struct FoldConstant {
-  EvalInfo &Info;
-  bool Enabled;
-  bool HadNoPriorDiags;
-  EvaluationMode OldMode;
+  /// Object used to treat all foldable expressions as constant expressions.
+  struct FoldConstant {
+    EvalInfo &Info;
+    bool Enabled;
+    bool HadNoPriorDiags;
+    EvaluationMode OldMode;
 
-  explicit FoldConstant(EvalInfo &Info, bool Enabled)
-      : Info(Info), Enabled(Enabled),
-        HadNoPriorDiags(Info.EvalStatus.Diag && Info.EvalStatus.Diag->empty() &&
+    explicit FoldConstant(EvalInfo &Info, bool Enabled)
+      : Info(Info),
+        Enabled(Enabled),
+        HadNoPriorDiags(Info.EvalStatus.Diag &&
+                        Info.EvalStatus.Diag->empty() &&
                         !Info.EvalStatus.HasSideEffects),
         OldMode(Info.EvalMode) {
-    if (Enabled)
-      Info.EvalMode = EvaluationMode::ConstantFold;
-  }
-  void keepDiagnostics() { Enabled = false; }
-  ~FoldConstant() {
-    if (Enabled && HadNoPriorDiags && !Info.EvalStatus.Diag->empty() &&
-        !Info.EvalStatus.HasSideEffects)
-      Info.EvalStatus.Diag->clear();
-    Info.EvalMode = OldMode;
-  }
-};
-
-/// RAII object used to set the current evaluation mode to ignore
-/// side-effects.
-struct IgnoreSideEffectsRAII {
-  EvalInfo &Info;
-  EvaluationMode OldMode;
-  explicit IgnoreSideEffectsRAII(EvalInfo &Info)
-      : Info(Info), OldMode(Info.EvalMode) {
-    Info.EvalMode = EvaluationMode::IgnoreSideEffects;
-  }
+      if (Enabled)
+        Info.EvalMode = EvaluationMode::ConstantFold;
+    }
+    void keepDiagnostics() { Enabled = false; }
+    ~FoldConstant() {
+      if (Enabled && HadNoPriorDiags && !Info.EvalStatus.Diag->empty() &&
+          !Info.EvalStatus.HasSideEffects)
+        Info.EvalStatus.Diag->clear();
+      Info.EvalMode = OldMode;
+    }
+  };
 
-  ~IgnoreSideEffectsRAII() { Info.EvalMode = OldMode; }
-};
+  /// RAII object used to set the current evaluation mode to ignore
+  /// side-effects.
+  struct IgnoreSideEffectsRAII {
+    EvalInfo &Info;
+    EvaluationMode OldMode;
+    explicit IgnoreSideEffectsRAII(EvalInfo &Info)
+        : Info(Info), OldMode(Info.EvalMode) {
+      Info.EvalMode = EvaluationMode::IgnoreSideEffects;
+    }
 
-/// RAII object used to optionally suppress diagnostics and side-effects from
-/// a speculative evaluation.
-class SpeculativeEvaluationRAII {
-  EvalInfo *Info = nullptr;
-  Expr::EvalStatus OldStatus;
-  unsigned OldSpeculativeEvaluationDepth = 0;
+    ~IgnoreSideEffectsRAII() { Info.EvalMode = OldMode; }
+  };
 
-  void moveFromAndCancel(SpeculativeEvaluationRAII &&Other) {
-    Info = Other.Info;
-    OldStatus = Other.OldStatus;
-    OldSpeculativeEvaluationDepth = Other.OldSpeculativeEvaluationDepth;
-    Other.Info = nullptr;
-  }
+  /// RAII object used to optionally suppress diagnostics and side-effects from
+  /// a speculative evaluation.
+  class SpeculativeEvaluationRAII {
+    EvalInfo *Info = nullptr;
+    Expr::EvalStatus OldStatus;
+    unsigned OldSpeculativeEvaluationDepth = 0;
 
-  void maybeRestoreState() {
-    if (!Info)
-      return;
+    void moveFromAndCancel(SpeculativeEvaluationRAII &&Other) {
+      Info = Other.Info;
+      OldStatus = Other.OldStatus;
+      OldSpeculativeEvaluationDepth = Other.OldSpeculativeEvaluationDepth;
+      Other.Info = nullptr;
+    }
 
-    Info->EvalStatus = OldStatus;
-    Info->SpeculativeEvaluationDepth = OldSpeculativeEvaluationDepth;
-  }
+    void maybeRestoreState() {
+      if (!Info)
+        return;
 
-public:
-  SpeculativeEvaluationRAII() = default;
+      Info->EvalStatus = OldStatus;
+      Info->SpeculativeEvaluationDepth = OldSpeculativeEvaluationDepth;
+    }
 
-  SpeculativeEvaluationRAII(
-      EvalInfo &Info, SmallVectorImpl<PartialDiagnosticAt> *NewDiag = nullptr)
-      : Info(&Info), OldStatus(Info.EvalStatus),
-        OldSpeculativeEvaluationDepth(Info.SpeculativeEvaluationDepth) {
-    Info.EvalStatus.Diag = NewDiag;
-    Info.SpeculativeEvaluationDepth = Info.CallStackDepth + 1;
-  }
+  public:
+    SpeculativeEvaluationRAII() = default;
 
-  SpeculativeEvaluationRAII(const SpeculativeEvaluationRAII &Other) = delete;
-  SpeculativeEvaluationRAII(SpeculativeEvaluationRAII &&Other) {
-    moveFromAndCancel(std::move(Other));
-  }
+    SpeculativeEvaluationRAII(
+        EvalInfo &Info, SmallVectorImpl<PartialDiagnosticAt> *NewDiag = nullptr)
+        : Info(&Info), OldStatus(Info.EvalStatus),
+          OldSpeculativeEvaluationDepth(Info.SpeculativeEvaluationDepth) {
+      Info.EvalStatus.Diag = NewDiag;
+      Info.SpeculativeEvaluationDepth = Info.CallStackDepth + 1;
+    }
 
-  SpeculativeEvaluationRAII &operator=(SpeculativeEvaluationRAII &&Other) {
-    maybeRestoreState();
-    moveFromAndCancel(std::move(Other));
-    return *this;
-  }
+    SpeculativeEvaluationRAII(const SpeculativeEvaluationRAII &Other) = delete;
+    SpeculativeEvaluationRAII(SpeculativeEvaluationRAII &&Other) {
+      moveFromAndCancel(std::move(Other));
+    }
 
-  ~SpeculativeEvaluationRAII() { maybeRestoreState(); }
-};
+    SpeculativeEvaluationRAII &operator=(SpeculativeEvaluationRAII &&Other) {
+      maybeRestoreState();
+      moveFromAndCancel(std::move(Other));
+      return *this;
+    }
 
-/// RAII object wrapping a full-expression or block scope, and handling
-/// the ending of the lifetime of temporaries created within it.
-template <ScopeKind Kind> class ScopeRAII {
-  EvalInfo &Info;
-  unsigned OldStackSize;
+    ~SpeculativeEvaluationRAII() { maybeRestoreState(); }
+  };
 
-public:
-  ScopeRAII(EvalInfo &Info)
-      : Info(Info), OldStackSize(Info.CleanupStack.size()) {
-    // Push a new temporary version. This is needed to distinguish between
-    // temporaries created in different iterations of a loop.
-    Info.CurrentCall->pushTempVersion();
-  }
-  bool destroy(bool RunDestructors = true) {
-    bool OK = cleanup(Info, RunDestructors, OldStackSize);
-    OldStackSize = std::numeric_limits<unsigned>::max();
-    return OK;
-  }
-  ~ScopeRAII() {
-    if (OldStackSize != std::numeric_limits<unsigned>::max())
-      destroy(false);
-    // Body moved to a static method to encourage the compiler to inline away
-    // instances of this class.
-    Info.CurrentCall->popTempVersion();
-  }
+  /// RAII object wrapping a full-expression or block scope, and handling
+  /// the ending of the lifetime of temporaries created within it.
+  template<ScopeKind Kind>
+  class ScopeRAII {
+    EvalInfo &Info;
+    unsigned OldStackSize;
+  public:
+    ScopeRAII(EvalInfo &Info)
+        : Info(Info), OldStackSize(Info.CleanupStack.size()) {
+      // Push a new temporary version. This is needed to distinguish between
+      // temporaries created in different iterations of a loop.
+      Info.CurrentCall->pushTempVersion();
+    }
+    bool destroy(bool RunDestructors = true) {
+      bool OK = cleanup(Info, RunDestructors, OldStackSize);
+      OldStackSize = std::numeric_limits<unsigned>::max();
+      return OK;
+    }
+    ~ScopeRAII() {
+      if (OldStackSize != std::numeric_limits<unsigned>::max())
+        destroy(false);
+      // Body moved to a static method to encourage the compiler to inline away
+      // instances of this class.
+      Info.CurrentCall->popTempVersion();
+    }
+  private:
+    static bool cleanup(EvalInfo &Info, bool RunDestructors,
+                        unsigned OldStackSize) {
+      assert(OldStackSize <= Info.CleanupStack.size() &&
+             "running cleanups out of order?");
 
-private:
-  static bool cleanup(EvalInfo &Info, bool RunDestructors,
-                      unsigned OldStackSize) {
-    assert(OldStackSize <= Info.CleanupStack.size() &&
-           "running cleanups out of order?");
-
-    // Run all cleanups for a block scope, and non-lifetime-extended cleanups
-    // for a full-expression scope.
-    bool Success = true;
-    for (unsigned I = Info.CleanupStack.size(); I > OldStackSize; --I) {
-      if (Info.CleanupStack[I - 1].isDestroyedAtEndOf(Kind)) {
-        if (!Info.CleanupStack[I - 1].endLifetime(Info, RunDestructors)) {
-          Success = false;
-          break;
+      // Run all cleanups for a block scope, and non-lifetime-extended cleanups
+      // for a full-expression scope.
+      bool Success = true;
+      for (unsigned I = Info.CleanupStack.size(); I > OldStackSize; --I) {
+        if (Info.CleanupStack[I - 1].isDestroyedAtEndOf(Kind)) {
+          if (!Info.CleanupStack[I - 1].endLifetime(Info, RunDestructors)) {
+            Success = false;
+            break;
+          }
         }
       }
-    }
 
-    // Compact any retained cleanups.
-    auto NewEnd = Info.CleanupStack.begin() + OldStackSize;
-    if (Kind != ScopeKind::Block)
-      NewEnd = std::remove_if(NewEnd, Info.CleanupStack.end(), [](Cleanup &C) {
-        return C.isDestroyedAtEndOf(Kind);
-      });
-    Info.CleanupStack.erase(NewEnd, Info.CleanupStack.end());
-    return Success;
-  }
-};
-typedef ScopeRAII<ScopeKind::Block> BlockScopeRAII;
-typedef ScopeRAII<ScopeKind::FullExpression> FullExpressionRAII;
-typedef ScopeRAII<ScopeKind::Call> CallScopeRAII;
-} // namespace
+      // Compact any retained cleanups.
+      auto NewEnd = Info.CleanupStack.begin() + OldStackSize;
+      if (Kind != ScopeKind::Block)
+        NewEnd =
+            std::remove_if(NewEnd, Info.CleanupStack.end(), [](Cleanup &C) {
+              return C.isDestroyedAtEndOf(Kind);
+            });
+      Info.CleanupStack.erase(NewEnd, Info.CleanupStack.end());
+      return Success;
+    }
+  };
+  typedef ScopeRAII<ScopeKind::Block> BlockScopeRAII;
+  typedef ScopeRAII<ScopeKind::FullExpression> FullExpressionRAII;
+  typedef ScopeRAII<ScopeKind::Call> CallScopeRAII;
+}
 
 bool SubobjectDesignator::checkSubobject(EvalInfo &Info, const Expr *E,
                                          CheckSubobjectKind CSK) {
   if (Invalid)
     return false;
   if (isOnePastTheEnd()) {
-    Info.CCEDiag(E, diag::note_constexpr_past_end_subobject) << CSK;
+    Info.CCEDiag(E, diag::note_constexpr_past_end_subobject)
+      << CSK;
     setInvalid();
     return false;
   }
@@ -1279,9 +1305,11 @@ void SubobjectDesignator::diagnosePointerArithmetic(EvalInfo &Info,
   // the most derived array.
   if (MostDerivedPathLength == Entries.size() && MostDerivedIsArrayElement)
     Info.CCEDiag(E, diag::note_constexpr_array_index)
-        << N << /*array*/ 0 << static_cast<unsigned>(getMostDerivedArraySize());
+      << N << /*array*/ 0
+      << static_cast<unsigned>(getMostDerivedArraySize());
   else
-    Info.CCEDiag(E, diag::note_constexpr_array_index) << N << /*non-array*/ 1;
+    Info.CCEDiag(E, diag::note_constexpr_array_index)
+      << N << /*non-array*/ 1;
   setInvalid();
 }
 
@@ -1364,314 +1392,322 @@ static bool isValidIndeterminateAccess(AccessKinds AK) {
 }
 
 namespace {
-struct ComplexValue {
-private:
-  bool IsInt;
+  struct ComplexValue {
+  private:
+    bool IsInt;
 
-public:
-  APSInt IntReal, IntImag;
-  APFloat FloatReal, FloatImag;
+  public:
+    APSInt IntReal, IntImag;
+    APFloat FloatReal, FloatImag;
 
-  ComplexValue() : FloatReal(APFloat::Bogus()), FloatImag(APFloat::Bogus()) {}
+    ComplexValue() : FloatReal(APFloat::Bogus()), FloatImag(APFloat::Bogus()) {}
 
-  void makeComplexFloat() { IsInt = false; }
-  bool isComplexFloat() const { return !IsInt; }
-  APFloat &getComplexFloatReal() { return FloatReal; }
-  APFloat &getComplexFloatImag() { return FloatImag; }
+    void makeComplexFloat() { IsInt = false; }
+    bool isComplexFloat() const { return !IsInt; }
+    APFloat &getComplexFloatReal() { return FloatReal; }
+    APFloat &getComplexFloatImag() { return FloatImag; }
 
-  void makeComplexInt() { IsInt = true; }
-  bool isComplexInt() const { return IsInt; }
-  APSInt &getComplexIntReal() { return IntReal; }
-  APSInt &getComplexIntImag() { return IntImag; }
+    void makeComplexInt() { IsInt = true; }
+    bool isComplexInt() const { return IsInt; }
+    APSInt &getComplexIntReal() { return IntReal; }
+    APSInt &getComplexIntImag() { return IntImag; }
 
-  void moveInto(APValue &v) const {
-    if (isComplexFloat())
-      v = APValue(FloatReal, FloatImag);
-    else
-      v = APValue(IntReal, IntImag);
-  }
-  void setFrom(const APValue &v) {
-    assert(v.isComplexFloat() || v.isComplexInt());
-    if (v.isComplexFloat()) {
-      makeComplexFloat();
-      FloatReal = v.getComplexFloatReal();
-      FloatImag = v.getComplexFloatImag();
-    } else {
-      makeComplexInt();
-      IntReal = v.getComplexIntReal();
-      IntImag = v.getComplexIntImag();
+    void moveInto(APValue &v) const {
+      if (isComplexFloat())
+        v = APValue(FloatReal, FloatImag);
+      else
+        v = APValue(IntReal, IntImag);
+    }
+    void setFrom(const APValue &v) {
+      assert(v.isComplexFloat() || v.isComplexInt());
+      if (v.isComplexFloat()) {
+        makeComplexFloat();
+        FloatReal = v.getComplexFloatReal();
+        FloatImag = v.getComplexFloatImag();
+      } else {
+        makeComplexInt();
+        IntReal = v.getComplexIntReal();
+        IntImag = v.getComplexIntImag();
+      }
     }
-  }
-};
+  };
 
-struct LValue {
-  APValue::LValueBase Base;
-  CharUnits Offset;
-  SubobjectDesignator Designator;
-  bool IsNullPtr : 1;
-  bool InvalidBase : 1;
-  // P2280R4 track if we have an unknown reference or pointer.
-  bool AllowConstexprUnknown = false;
-
-  const APValue::LValueBase getLValueBase() const { return Base; }
-  bool allowConstexprUnknown() const { return AllowConstexprUnknown; }
-  CharUnits &getLValueOffset() { return Offset; }
-  const CharUnits &getLValueOffset() const { return Offset; }
-  SubobjectDesignator &getLValueDesignator() { return Designator; }
-  const SubobjectDesignator &getLValueDesignator() const { return Designator; }
-  bool isNullPointer() const { return IsNullPtr; }
-
-  unsigned getLValueCallIndex() const { return Base.getCallIndex(); }
-  unsigned getLValueVersion() const { return Base.getVersion(); }
-
-  void moveInto(APValue &V) const {
-    if (Designator.Invalid)
-      V = APValue(Base, Offset, APValue::NoLValuePath(), IsNullPtr);
-    else {
-      assert(!InvalidBase && "APValues can't handle invalid LValue bases");
-      V = APValue(Base, Offset, Designator.Entries, Designator.IsOnePastTheEnd,
-                  IsNullPtr);
+  struct LValue {
+    APValue::LValueBase Base;
+    CharUnits Offset;
+    SubobjectDesignator Designator;
+    bool IsNullPtr : 1;
+    bool InvalidBase : 1;
+    // P2280R4 track if we have an unknown reference or pointer.
+    bool AllowConstexprUnknown = false;
+
+    const APValue::LValueBase getLValueBase() const { return Base; }
+    bool allowConstexprUnknown() const { return AllowConstexprUnknown; }
+    CharUnits &getLValueOffset() { return Offset; }
+    const CharUnits &getLValueOffset() const { return Offset; }
+    SubobjectDesignator &getLValueDesignator() { return Designator; }
+    const SubobjectDesignator &getLValueDesignator() const { return Designator;}
+    bool isNullPointer() const { return IsNullPtr;}
+
+    unsigned getLValueCallIndex() const { return Base.getCallIndex(); }
+    unsigned getLValueVersion() const { return Base.getVersion(); }
+
+    void moveInto(APValue &V) const {
+      if (Designator.Invalid)
+        V = APValue(Base, Offset, APValue::NoLValuePath(), IsNullPtr);
+      else {
+        assert(!InvalidBase && "APValues can't handle invalid LValue bases");
+        V = APValue(Base, Offset, Designator.Entries,
+                    Designator.IsOnePastTheEnd, IsNullPtr);
+      }
+      if (AllowConstexprUnknown)
+        V.setConstexprUnknown();
+    }
+    void setFrom(const ASTContext &Ctx, const APValue &V) {
+      assert(V.isLValue() && "Setting LValue from a non-LValue?");
+      Base = V.getLValueBase();
+      Offset = V.getLValueOffset();
+      InvalidBase = false;
+      Designator = SubobjectDesignator(Ctx, V);
+      IsNullPtr = V.isNullPointer();
+      AllowConstexprUnknown = V.allowConstexprUnknown();
     }
-    if (AllowConstexprUnknown)
-      V.setConstexprUnknown();
-  }
-  void setFrom(const ASTContext &Ctx, const APValue &V) {
-    assert(V.isLValue() && "Setting LValue from a non-LValue?");
-    Base = V.getLValueBase();
-    Offset = V.getLValueOffset();
-    InvalidBase = false;
-    Designator = SubobjectDesignator(Ctx, V);
-    IsNullPtr = V.isNullPointer();
-    AllowConstexprUnknown = V.allowConstexprUnknown();
-  }
 
-  void set(APValue::LValueBase B, bool BInvalid = false) {
+    void set(APValue::LValueBase B, bool BInvalid = false) {
 #ifndef NDEBUG
-    // We only allow a few types of invalid bases. Enforce that here.
-    if (BInvalid) {
-      const auto *E = B.get<const Expr *>();
-      assert((isa<MemberExpr>(E) || tryUnwrapAllocSizeCall(E)) &&
-             "Unexpected type of invalid base");
-    }
+      // We only allow a few types of invalid bases. Enforce that here.
+      if (BInvalid) {
+        const auto *E = B.get<const Expr *>();
+        assert((isa<MemberExpr>(E) || tryUnwrapAllocSizeCall(E)) &&
+               "Unexpected type of invalid base");
+      }
 #endif
 
-    Base = B;
-    Offset = CharUnits::fromQuantity(0);
-    InvalidBase = BInvalid;
-    Designator = SubobjectDesignator(getType(B));
-    IsNullPtr = false;
-    AllowConstexprUnknown = false;
-  }
+      Base = B;
+      Offset = CharUnits::fromQuantity(0);
+      InvalidBase = BInvalid;
+      Designator = SubobjectDesignator(getType(B));
+      IsNullPtr = false;
+      AllowConstexprUnknown = false;
+    }
 
-  void setNull(ASTContext &Ctx, QualType PointerTy) {
-    Base = (const ValueDecl *)nullptr;
-    Offset = CharUnits::fromQuantity(Ctx.getTargetNullPointerValue(PointerTy));
-    InvalidBase = false;
-    Designator = SubobjectDesignator(PointerTy->getPointeeType());
-    IsNullPtr = true;
-    AllowConstexprUnknown = false;
-  }
+    void setNull(ASTContext &Ctx, QualType PointerTy) {
+      Base = (const ValueDecl *)nullptr;
+      Offset =
+          CharUnits::fromQuantity(Ctx.getTargetNullPointerValue(PointerTy));
+      InvalidBase = false;
+      Designator = SubobjectDesignator(PointerTy->getPointeeType());
+      IsNullPtr = true;
+      AllowConstexprUnknown = false;
+    }
 
-  void setInvalid(APValue::LValueBase B, unsigned I = 0) { set(B, true); }
+    void setInvalid(APValue::LValueBase B, unsigned I = 0) {
+      set(B, true);
+    }
 
-  std::string toString(ASTContext &Ctx, QualType T) const {
-    APValue Printable;
-    moveInto(Printable);
-    return Printable.getAsString(Ctx, T);
-  }
+    std::string toString(ASTContext &Ctx, QualType T) const {
+      APValue Printable;
+      moveInto(Printable);
+      return Printable.getAsString(Ctx, T);
+    }
 
-private:
-  // Check that this LValue is not based on a null pointer. If it is, produce
-  // a diagnostic and mark the designator as invalid.
-  template <typename GenDiagType>
-  bool checkNullPointerDiagnosingWith(const GenDiagType &GenDiag) {
-    if (Designator.Invalid)
-      return false;
-    if (IsNullPtr) {
-      GenDiag();
-      Designator.setInvalid();
-      return false;
+  private:
+    // Check that this LValue is not based on a null pointer. If it is, produce
+    // a diagnostic and mark the designator as invalid.
+    template <typename GenDiagType>
+    bool checkNullPointerDiagnosingWith(const GenDiagType &GenDiag) {
+      if (Designator.Invalid)
+        return false;
+      if (IsNullPtr) {
+        GenDiag();
+        Designator.setInvalid();
+        return false;
+      }
+      return true;
     }
-    return true;
-  }
 
-public:
-  bool checkNullPointer(EvalInfo &Info, const Expr *E, CheckSubobjectKind CSK) {
-    return checkNullPointerDiagnosingWith([&Info, E, CSK] {
-      Info.CCEDiag(E, diag::note_constexpr_null_subobject) << CSK;
-    });
-  }
+  public:
+    bool checkNullPointer(EvalInfo &Info, const Expr *E,
+                          CheckSubobjectKind CSK) {
+      return checkNullPointerDiagnosingWith([&Info, E, CSK] {
+        Info.CCEDiag(E, diag::note_constexpr_null_subobject) << CSK;
+      });
+    }
 
-  bool checkNullPointerForFoldAccess(EvalInfo &Info, const Expr *E,
-                                     AccessKinds AK) {
-    return checkNullPointerDiagnosingWith([&Info, E, AK] {
-      if (AK == AccessKinds::AK_Dereference)
-        Info.FFDiag(E, diag::note_constexpr_dereferencing_null);
-      else
-        Info.FFDiag(E, diag::note_constexpr_access_null) << AK;
-    });
-  }
+    bool checkNullPointerForFoldAccess(EvalInfo &Info, const Expr *E,
+                                       AccessKinds AK) {
+      return checkNullPointerDiagnosingWith([&Info, E, AK] {
+        if (AK == AccessKinds::AK_Dereference)
+          Info.FFDiag(E, diag::note_constexpr_dereferencing_null);
+        else
+          Info.FFDiag(E, diag::note_constexpr_access_null) << AK;
+      });
+    }
 
-  // Check this LValue refers to an object. If not, set the designator to be
-  // invalid and emit a diagnostic.
-  bool checkSubobject(EvalInfo &Info, const Expr *E, CheckSubobjectKind CSK) {
-    return (CSK == CSK_ArrayToPointer || checkNullPointer(Info, E, CSK)) &&
-           Designator.checkSubobject(Info, E, CSK);
-  }
+    // Check this LValue refers to an object. If not, set the designator to be
+    // invalid and emit a diagnostic.
+    bool checkSubobject(EvalInfo &Info, const Expr *E, CheckSubobjectKind CSK) {
+      return (CSK == CSK_ArrayToPointer || checkNullPointer(Info, E, CSK)) &&
+             Designator.checkSubobject(Info, E, CSK);
+    }
 
-  void addDecl(EvalInfo &Info, const Expr *E, const Decl *D,
-               bool Virtual = false) {
-    if (checkSubobject(Info, E, isa<FieldDecl>(D) ? CSK_Field : CSK_Base))
-      Designator.addDeclUnchecked(D, Virtual);
-  }
-  void addUnsizedArray(EvalInfo &Info, const Expr *E, QualType ElemTy) {
-    if (!Designator.Entries.empty()) {
-      Info.CCEDiag(E, diag::note_constexpr_unsupported_unsized_array);
-      Designator.setInvalid();
-      return;
+    void addDecl(EvalInfo &Info, const Expr *E,
+                 const Decl *D, bool Virtual = false) {
+      if (checkSubobject(Info, E, isa<FieldDecl>(D) ? CSK_Field : CSK_Base))
+        Designator.addDeclUnchecked(D, Virtual);
     }
-    if (checkSubobject(Info, E, CSK_ArrayToPointer)) {
-      assert(getType(Base).getNonReferenceType()->isPointerType() ||
-             getType(Base).getNonReferenceType()->isArrayType());
-      Designator.FirstEntryIsAnUnsizedArray = true;
-      Designator.addUnsizedArrayUnchecked(ElemTy);
+    void addUnsizedArray(EvalInfo &Info, const Expr *E, QualType ElemTy) {
+      if (!Designator.Entries.empty()) {
+        Info.CCEDiag(E, diag::note_constexpr_unsupported_unsized_array);
+        Designator.setInvalid();
+        return;
+      }
+      if (checkSubobject(Info, E, CSK_ArrayToPointer)) {
+        assert(getType(Base).getNonReferenceType()->isPointerType() ||
+               getType(Base).getNonReferenceType()->isArrayType());
+        Designator.FirstEntryIsAnUnsizedArray = true;
+        Designator.addUnsizedArrayUnchecked(ElemTy);
+      }
     }
-  }
-  void addArray(EvalInfo &Info, const Expr *E, const ConstantArrayType *CAT) {
-    if (checkSubobject(Info, E, CSK_ArrayToPointer))
-      Designator.addArrayUnchecked(CAT);
-  }
-  void addComplex(EvalInfo &Info, const Expr *E, QualType EltTy, bool Imag) {
-    if (checkSubobject(Info, E, Imag ? CSK_Imag : CSK_Real))
-      Designator.addComplexUnchecked(EltTy, Imag);
-  }
-  void addVectorElement(EvalInfo &Info, const Expr *E, QualType EltTy,
-                        uint64_t Size, uint64_t Idx) {
-    if (checkSubobject(Info, E, CSK_VectorElement))
-      Designator.addVectorElementUnchecked(EltTy, Size, Idx);
-  }
-  void clearIsNullPointer() { IsNullPtr = false; }
-  void adjustOffsetAndIndex(EvalInfo &Info, const Expr *E, const APSInt &Index,
-                            CharUnits ElementSize) {
-    // An index of 0 has no effect. (In C, adding 0 to a null pointer is UB,
-    // but we're not required to diagnose it and it's valid in C++.)
-    if (!Index)
-      return;
+    void addArray(EvalInfo &Info, const Expr *E, const ConstantArrayType *CAT) {
+      if (checkSubobject(Info, E, CSK_ArrayToPointer))
+        Designator.addArrayUnchecked(CAT);
+    }
+    void addComplex(EvalInfo &Info, const Expr *E, QualType EltTy, bool Imag) {
+      if (checkSubobject(Info, E, Imag ? CSK_Imag : CSK_Real))
+        Designator.addComplexUnchecked(EltTy, Imag);
+    }
+    void addVectorElement(EvalInfo &Info, const Expr *E, QualType EltTy,
+                          uint64_t Size, uint64_t Idx) {
+      if (checkSubobject(Info, E, CSK_VectorElement))
+        Designator.addVectorElementUnchecked(EltTy, Size, Idx);
+    }
+    void clearIsNullPointer() {
+      IsNullPtr = false;
+    }
+    void adjustOffsetAndIndex(EvalInfo &Info, const Expr *E,
+                              const APSInt &Index, CharUnits ElementSize) {
+      // An index of 0 has no effect. (In C, adding 0 to a null pointer is UB,
+      // but we're not required to diagnose it and it's valid in C++.)
+      if (!Index)
+        return;
 
-    // Compute the new offset in the appropriate width, wrapping at 64 bits.
-    // FIXME: When compiling for a 32-bit target, we should use 32-bit
-    // offsets.
-    uint64_t Offset64 = Offset.getQuantity();
-    uint64_t ElemSize64 = ElementSize.getQuantity();
-    uint64_t Index64 = Index.extOrTrunc(64).getZExtValue();
-    Offset = CharUnits::fromQuantity(Offset64 + ElemSize64 * Index64);
-
-    if (checkNullPointer(Info, E, CSK_ArrayIndex))
-      Designator.adjustIndex(Info, E, Index, *this);
-    clearIsNullPointer();
-  }
-  void adjustOffset(CharUnits N) {
-    Offset += N;
-    if (N.getQuantity())
-      clearIsNullPointer();
-  }
-};
+      // Compute the new offset in the appropriate width, wrapping at 64 bits.
+      // FIXME: When compiling for a 32-bit target, we should use 32-bit
+      // offsets.
+      uint64_t Offset64 = Offset.getQuantity();
+      uint64_t ElemSize64 = ElementSize.getQuantity();
+      uint64_t Index64 = Index.extOrTrunc(64).getZExtValue();
+      Offset = CharUnits::fromQuantity(Offset64 + ElemSize64 * Index64);
 
-struct MemberPtr {
-  MemberPtr() {}
-  explicit MemberPtr(const ValueDecl *Decl)
-      : DeclAndIsDerivedMember(Decl, false) {}
-
-  /// The member or (direct or indirect) field referred to by this member
-  /// pointer, or 0 if this is a null member pointer.
-  const ValueDecl *getDecl() const {
-    return DeclAndIsDerivedMember.getPointer();
-  }
-  /// Is this actually a member of some type derived from the relevant class?
-  bool isDerivedMember() const { return DeclAndIsDerivedMember.getInt(); }
-  /// Get the class which the declaration actually lives in.
-  const CXXRecordDecl *getContainingRecord() const {
-    return cast<CXXRecordDecl>(
-        DeclAndIsDerivedMember.getPointer()->getDeclContext());
-  }
-
-  void moveInto(APValue &V) const {
-    V = APValue(getDecl(), isDerivedMember(), Path);
-  }
-  void setFrom(const APValue &V) {
-    assert(V.isMemberPointer());
-    DeclAndIsDerivedMember.setPointer(V.getMemberPointerDecl());
-    DeclAndIsDerivedMember.setInt(V.isMemberPointerToDerivedMember());
-    Path.clear();
-    llvm::append_range(Path, V.getMemberPointerPath());
-  }
-
-  /// DeclAndIsDerivedMember - The member declaration, and a flag indicating
-  /// whether the member is a member of some class derived from the class type
-  /// of the member pointer.
-  llvm::PointerIntPair<const ValueDecl *, 1, bool> DeclAndIsDerivedMember;
-  /// Path - The path of base/derived classes from the member declaration's
-  /// class (exclusive) to the class type of the member pointer (inclusive).
-  SmallVector<const CXXRecordDecl *, 4> Path;
-
-  /// Perform a cast towards the class of the Decl (either up or down the
-  /// hierarchy).
-  bool castBack(const CXXRecordDecl *Class) {
-    assert(!Path.empty());
-    const CXXRecordDecl *Expected;
-    if (Path.size() >= 2)
-      Expected = Path[Path.size() - 2];
-    else
-      Expected = getContainingRecord();
-    if (Expected->getCanonicalDecl() != Class->getCanonicalDecl()) {
-      // C++11 [expr.static.cast]p12: In a conversion from (D::*) to (B::*),
-      // if B does not contain the original member and is not a base or
-      // derived class of the class containing the original member, the result
-      // of the cast is undefined.
-      // C++11 [conv.mem]p2 does not cover this case for a cast from (B::*) to
-      // (D::*). We consider that to be a language defect.
-      return false;
+      if (checkNullPointer(Info, E, CSK_ArrayIndex))
+        Designator.adjustIndex(Info, E, Index, *this);
+      clearIsNullPointer();
     }
-    Path.pop_back();
-    return true;
-  }
-  /// Perform a base-to-derived member pointer cast.
-  bool castToDerived(const CXXRecordDecl *Derived) {
-    if (!getDecl())
-      return true;
-    if (!isDerivedMember()) {
-      Path.push_back(Derived);
-      return true;
+    void adjustOffset(CharUnits N) {
+      Offset += N;
+      if (N.getQuantity())
+        clearIsNullPointer();
     }
-    if (!castBack(Derived))
-      return false;
-    if (Path.empty())
-      DeclAndIsDerivedMember.setInt(false);
-    return true;
-  }
-  /// Perform a derived-to-base member pointer cast.
-  bool castToBase(const CXXRecordDecl *Base) {
-    if (!getDecl())
+  };
+
+  struct MemberPtr {
+    MemberPtr() {}
+    explicit MemberPtr(const ValueDecl *Decl)
+        : DeclAndIsDerivedMember(Decl, false) {}
+
+    /// The member or (direct or indirect) field referred to by this member
+    /// pointer, or 0 if this is a null member pointer.
+    const ValueDecl *getDecl() const {
+      return DeclAndIsDerivedMember.getPointer();
+    }
+    /// Is this actually a member of some type derived from the relevant class?
+    bool isDerivedMember() const {
+      return DeclAndIsDerivedMember.getInt();
+    }
+    /// Get the class which the declaration actually lives in.
+    const CXXRecordDecl *getContainingRecord() const {
+      return cast<CXXRecordDecl>(
+          DeclAndIsDerivedMember.getPointer()->getDeclContext());
+    }
+
+    void moveInto(APValue &V) const {
+      V = APValue(getDecl(), isDerivedMember(), Path);
+    }
+    void setFrom(const APValue &V) {
+      assert(V.isMemberPointer());
+      DeclAndIsDerivedMember.setPointer(V.getMemberPointerDecl());
+      DeclAndIsDerivedMember.setInt(V.isMemberPointerToDerivedMember());
+      Path.clear();
+      llvm::append_range(Path, V.getMemberPointerPath());
+    }
+
+    /// DeclAndIsDerivedMember - The member declaration, and a flag indicating
+    /// whether the member is a member of some class derived from the class type
+    /// of the member pointer.
+    llvm::PointerIntPair<const ValueDecl*, 1, bool> DeclAndIsDerivedMember;
+    /// Path - The path of base/derived classes from the member declaration's
+    /// class (exclusive) to the class type of the member pointer (inclusive).
+    SmallVector<const CXXRecordDecl*, 4> Path;
+
+    /// Perform a cast towards the class of the Decl (either up or down the
+    /// hierarchy).
+    bool castBack(const CXXRecordDecl *Class) {
+      assert(!Path.empty());
+      const CXXRecordDecl *Expected;
+      if (Path.size() >= 2)
+        Expected = Path[Path.size() - 2];
+      else
+        Expected = getContainingRecord();
+      if (Expected->getCanonicalDecl() != Class->getCanonicalDecl()) {
+        // C++11 [expr.static.cast]p12: In a conversion from (D::*) to (B::*),
+        // if B does not contain the original member and is not a base or
+        // derived class of the class containing the original member, the result
+        // of the cast is undefined.
+        // C++11 [conv.mem]p2 does not cover this case for a cast from (B::*) to
+        // (D::*). We consider that to be a language defect.
+        return false;
+      }
+      Path.pop_back();
       return true;
-    if (Path.empty())
-      DeclAndIsDerivedMember.setInt(true);
-    if (isDerivedMember()) {
-      Path.push_back(Base);
+    }
+    /// Perform a base-to-derived member pointer cast.
+    bool castToDerived(const CXXRecordDecl *Derived) {
+      if (!getDecl())
+        return true;
+      if (!isDerivedMember()) {
+        Path.push_back(Derived);
+        return true;
+      }
+      if (!castBack(Derived))
+        return false;
+      if (Path.empty())
+        DeclAndIsDerivedMember.setInt(false);
       return true;
     }
-    return castBack(Base);
-  }
-};
+    /// Perform a derived-to-base member pointer cast.
+    bool castToBase(const CXXRecordDecl *Base) {
+      if (!getDecl())
+        return true;
+      if (Path.empty())
+        DeclAndIsDerivedMember.setInt(true);
+      if (isDerivedMember()) {
+        Path.push_back(Base);
+        return true;
+      }
+      return castBack(Base);
+    }
+  };
 
-/// Compare two member pointers, which are assumed to be of the same type.
-static bool operator==(const MemberPtr &LHS, const MemberPtr &RHS) {
-  if (!LHS.getDecl() || !RHS.getDecl())
-    return !LHS.getDecl() && !RHS.getDecl();
-  if (LHS.getDecl()->getCanonicalDecl() != RHS.getDecl()->getCanonicalDecl())
-    return false;
-  return LHS.Path == RHS.Path;
+  /// Compare two member pointers, which are assumed to be of the same type.
+  static bool operator==(const MemberPtr &LHS, const MemberPtr &RHS) {
+    if (!LHS.getDecl() || !RHS.getDecl())
+      return !LHS.getDecl() && !RHS.getDecl();
+    if (LHS.getDecl()->getCanonicalDecl() != RHS.getDecl()->getCanonicalDecl())
+      return false;
+    return LHS.Path == RHS.Path;
+  }
 }
-} // namespace
 
 void SubobjectDesignator::adjustIndex(EvalInfo &Info, const Expr *E, APSInt N,
                                       const LValue &LV) {
@@ -1722,8 +1758,9 @@ void SubobjectDesignator::adjustIndex(EvalInfo &Info, const Expr *E, APSInt N,
 }
 
 static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E);
-static bool EvaluateInPlace(APValue &Result, EvalInfo &Info, const LValue &This,
-                            const Expr *E, bool AllowNonLiteralTypes = false);
+static bool EvaluateInPlace(APValue &Result, EvalInfo &Info,
+                            const LValue &This, const Expr *E,
+                            bool AllowNonLiteralTypes = false);
 static bool EvaluateLValue(const Expr *E, LValue &Result, EvalInfo &Info,
                            bool InvalidBaseOK = false);
 static bool EvaluatePointer(const Expr *E, LValue &Result, EvalInfo &Info,
@@ -1766,7 +1803,7 @@ static void negateAsSigned(APSInt &Int) {
   Int = -Int;
 }
 
-template <typename KeyT>
+template<typename KeyT>
 APValue &CallStackFrame::createTemporary(const KeyT *Key, QualType T,
                                          ScopeKind Scope, LValue &LV) {
   unsigned Version = getTempVersion();
@@ -1841,9 +1878,9 @@ void CallStackFrame::describe(raw_ostream &Out) const {
       Object->printPretty(Out, /*Helper=*/nullptr, Info.Ctx.getPrintingPolicy(),
                           /*Indentation=*/0);
       if (Object->getType()->isPointerType())
-        Out << "->";
+          Out << "->";
       else
-        Out << ".";
+          Out << ".";
     } else if (const auto *OCE =
                    dyn_cast_if_present<CXXOperatorCallExpr>(CallExpr)) {
       OCE->getArg(0)->printPretty(Out, /*Helper=*/nullptr,
@@ -1914,7 +1951,7 @@ static bool IsGlobalLValue(APValue::LValueBase B) {
   if (!B)
     return true;
 
-  if (const ValueDecl *D = B.dyn_cast<const ValueDecl *>()) {
+  if (const ValueDecl *D = B.dyn_cast<const ValueDecl*>()) {
     // ... the address of an object with static storage duration,
     if (const VarDecl *VD = dyn_cast<VarDecl>(D))
       return VD->hasGlobalStorage();
@@ -1929,7 +1966,7 @@ static bool IsGlobalLValue(APValue::LValueBase B) {
   if (B.is<TypeInfoLValue>() || B.is<DynamicAllocLValue>())
     return true;
 
-  const Expr *E = B.get<const Expr *>();
+  const Expr *E = B.get<const Expr*>();
   switch (E->getStmtClass()) {
   default:
     return false;
@@ -1976,7 +2013,7 @@ static bool IsGlobalLValue(APValue::LValueBase B) {
 }
 
 static const ValueDecl *GetLValueBaseDecl(const LValue &LVal) {
-  return LVal.Base.dyn_cast<const ValueDecl *>();
+  return LVal.Base.dyn_cast<const ValueDecl*>();
 }
 
 // Information about an LValueBase that is some kind of string.
@@ -2093,7 +2130,8 @@ static bool HasSameBase(const LValue &A, const LValue &B) {
   if (!B.getLValueBase())
     return false;
 
-  if (A.getLValueBase().getOpaqueValue() != B.getLValueBase().getOpaqueValue())
+  if (A.getLValueBase().getOpaqueValue() !=
+      B.getLValueBase().getOpaqueValue())
     return false;
 
   return A.getLValueCallIndex() == B.getLValueCallIndex() &&
@@ -2102,7 +2140,7 @@ static bool HasSameBase(const LValue &A, const LValue &B) {
 
 static void NoteLValueLocation(EvalInfo &Info, APValue::LValueBase Base) {
   assert(Base && "no location for a null lvalue");
-  const ValueDecl *VD = Base.dyn_cast<const ValueDecl *>();
+  const ValueDecl *VD = Base.dyn_cast<const ValueDecl*>();
 
   // For a parameter, find the corresponding call stack frame (if it still
   // exists), and point at the parameter of the function definition we actually
@@ -2121,7 +2159,7 @@ static void NoteLValueLocation(EvalInfo &Info, APValue::LValueBase Base) {
 
   if (VD)
     Info.Note(VD->getLocation(), diag::note_declared_at);
-  else if (const Expr *E = Base.dyn_cast<const Expr *>())
+  else if (const Expr *E = Base.dyn_cast<const Expr*>())
     Info.Note(E->getExprLoc(), diag::note_constexpr_temporary_here);
   else if (DynamicAllocLValue DA = Base.dyn_cast<DynamicAllocLValue>()) {
     // FIXME: Produce a note for dangling pointers too.
@@ -2163,7 +2201,7 @@ static bool CheckLValueConstantExpression(EvalInfo &Info, SourceLocation Loc,
   const SubobjectDesignator &Designator = LVal.getLValueDesignator();
 
   const Expr *BaseE = Base.dyn_cast<const Expr *>();
-  const ValueDecl *BaseVD = Base.dyn_cast<const ValueDecl *>();
+  const ValueDecl *BaseVD = Base.dyn_cast<const ValueDecl*>();
 
   // Additional restrictions apply in a template argument. We only enforce the
   // C++20 restrictions here; additional syntactic and semantic restrictions
@@ -2325,7 +2363,7 @@ static bool CheckLValueConstantExpression(EvalInfo &Info, SourceLocation Loc,
   // Does this refer one past the end of some object?
   if (!Designator.Invalid && Designator.isOnePastTheEnd()) {
     Info.FFDiag(Loc, diag::note_constexpr_past_end, 1)
-        << !Designator.Entries.empty() << !!BaseVD << BaseVD;
+      << !Designator.Entries.empty() << !!BaseVD << BaseVD;
     NoteLValueLocation(Info, Base);
   }
 
@@ -2381,7 +2419,8 @@ static bool CheckLiteralType(EvalInfo &Info, const Expr *E,
 
   // Prvalue constant expressions must be of literal types.
   if (Info.getLangOpts().CPlusPlus11)
-    Info.FFDiag(E, diag::note_constexpr_nonliteral) << E->getType();
+    Info.FFDiag(E, diag::note_constexpr_nonliteral)
+      << E->getType();
   else
     Info.FFDiag(E, diag::note_invalid_subexpr_in_const_expr);
   return false;
@@ -2435,7 +2474,7 @@ static bool CheckEvaluationResult(CheckEvaluationResultKind CERK,
   }
   if (Value.isStruct()) {
     if (Type->isMetaInfoType())
-      return true;
+        return true;
     auto *RD = Type->castAsRecordDecl();
     if (const CXXRecordDecl *CD = dyn_cast<CXXRecordDecl>(RD)) {
       unsigned BaseIndex = 0;
@@ -2475,8 +2514,7 @@ static bool CheckEvaluationResult(CheckEvaluationResultKind CERK,
 
   if (Value.isMemberPointer() &&
       CERK == CheckEvaluationResultKind::ConstantExpression)
-    return CheckMemberPointerConstantExpression(Info, DiagLoc, Type, Value,
-                                                Kind);
+    return CheckMemberPointerConstantExpression(Info, DiagLoc, Type, Value, Kind);
 
   // Everything else is fine.
   return true;
@@ -2534,7 +2572,7 @@ static bool EvalPointerValueAsBool(const APValue &Value, bool &Result) {
   // We have a non-null base.  These are generally known to be true, but if it's
   // a weak declaration it can be null at runtime.
   Result = true;
-  const ValueDecl *Decl = Value.getLValueBase().dyn_cast<const ValueDecl *>();
+  const ValueDecl *Decl = Value.getLValueBase().dyn_cast<const ValueDecl*>();
   return !Decl || !Decl->isWeak();
 }
 
@@ -2591,9 +2629,9 @@ static bool EvaluateAsBooleanCondition(const Expr *E, bool &Result,
   return HandleConversionToBool(Val, Result);
 }
 
-template <typename T>
-static bool HandleOverflow(EvalInfo &Info, const Expr *E, const T &SrcValue,
-                           QualType DestType) {
+template<typename T>
+static bool HandleOverflow(EvalInfo &Info, const Expr *E,
+                           const T &SrcValue, QualType DestType) {
   Info.CCEDiag(E, diag::note_constexpr_overflow) << SrcValue << DestType;
   if (const auto *OBT = DestType->getAs<OverflowBehaviorType>();
       OBT && OBT->isTrapKind()) {
@@ -2611,8 +2649,8 @@ static bool HandleFloatToIntCast(EvalInfo &Info, const Expr *E,
 
   Result = APSInt(DestWidth, !DestSigned);
   bool ignored;
-  if (Value.convertToInteger(Result, llvm::APFloat::rmTowardZero, &ignored) &
-      APFloat::opInvalidOp)
+  if (Value.convertToInteger(Result, llvm::APFloat::rmTowardZero, &ignored)
+      & APFloat::opInvalidOp)
     return HandleOverflow(Info, E, Value, DestType);
   return true;
 }
@@ -2701,17 +2739,17 @@ static APSInt HandleIntToIntCast(EvalInfo &Info, const Expr *E,
 }
 
 static bool HandleIntToFloatCast(EvalInfo &Info, const Expr *E,
-                                 const FPOptions FPO, QualType SrcType,
-                                 const APSInt &Value, QualType DestType,
-                                 APFloat &Result) {
+                                 const FPOptions FPO,
+                                 QualType SrcType, const APSInt &Value,
+                                 QualType DestType, APFloat &Result) {
   Result = APFloat(Info.Ctx.getFloatTypeSemantics(DestType), 1);
   llvm::RoundingMode RM = getActiveRoundingMode(Info, E);
   APFloat::opStatus St = Result.convertFromAPInt(Value, Value.isSigned(), RM);
   return checkFloatingPointResult(Info, E, St);
 }
 
-static bool truncateBitfieldValue(EvalInfo &Info, const Expr *E, APValue &Value,
-                                  const FieldDecl *FD) {
+static bool truncateBitfieldValue(EvalInfo &Info, const Expr *E,
+                                  APValue &Value, const FieldDecl *FD) {
   assert(FD->isBitField() && "truncateBitfieldValue on non-bitfield");
 
   if (!Value.isInt()) {
@@ -2734,7 +2772,7 @@ static bool truncateBitfieldValue(EvalInfo &Info, const Expr *E, APValue &Value,
 /// Perform the given integer operation, which is known to need at most BitWidth
 /// bits, and check for overflow in the original type (if that type was not an
 /// unsigned type).
-template <typename Operation>
+template<typename Operation>
 static bool CheckedIntArithmetic(EvalInfo &Info, const Expr *E,
                                  const APSInt &LHS, const APSInt &RHS,
                                  unsigned BitWidth, Operation Op,
@@ -2776,15 +2814,9 @@ static bool handleIntIntBinOp(EvalInfo &Info, const BinaryOperator *E,
   case BO_Sub:
     return CheckedIntArithmetic(Info, E, LHS, RHS, LHS.getBitWidth() + 1,
                                 std::minus<APSInt>(), Result);
-  case BO_And:
-    Result = LHS & RHS;
-    return true;
-  case BO_Xor:
-    Result = LHS ^ RHS;
-    return true;
-  case BO_Or:
-    Result = LHS | RHS;
-    return true;
+  case BO_And: Result = LHS & RHS; return true;
+  case BO_Xor: Result = LHS ^ RHS; return true;
+  case BO_Or:  Result = LHS | RHS; return true;
   case BO_Div:
   case BO_Rem:
     if (RHS == 0) {
@@ -2804,7 +2836,7 @@ static bool handleIntIntBinOp(EvalInfo &Info, const BinaryOperator *E,
     if (Info.getLangOpts().OpenCL)
       // OpenCL 6.3j: shift values are effectively % word size of LHS.
       RHS &= APSInt(llvm::APInt(RHS.getBitWidth(),
-                                static_cast<uint64_t>(LHS.getBitWidth() - 1)),
+                    static_cast<uint64_t>(LHS.getBitWidth() - 1)),
                     RHS.isUnsigned());
     else if (RHS.isSigned() && RHS.isNegative()) {
       // During constant-folding, a negative shift is an opposite shift. Such
@@ -2818,10 +2850,10 @@ static bool handleIntIntBinOp(EvalInfo &Info, const BinaryOperator *E,
   shift_left:
     // C++11 [expr.shift]p1: Shift width must be less than the bit width of
     // the shifted type.
-    unsigned SA = (unsigned)RHS.getLimitedValue(LHS.getBitWidth() - 1);
+    unsigned SA = (unsigned) RHS.getLimitedValue(LHS.getBitWidth()-1);
     if (SA != RHS) {
       Info.CCEDiag(E, diag::note_constexpr_large_shift)
-          << RHS << E->getType() << LHS.getBitWidth();
+        << RHS << E->getType() << LHS.getBitWidth();
       if (!Info.noteUndefinedBehavior())
         return false;
     } else if (LHS.isSigned() && !Info.getLangOpts().CPlusPlus20) {
@@ -2846,7 +2878,7 @@ static bool handleIntIntBinOp(EvalInfo &Info, const BinaryOperator *E,
     if (Info.getLangOpts().OpenCL)
       // OpenCL 6.3j: shift values are effectively % word size of LHS.
       RHS &= APSInt(llvm::APInt(RHS.getBitWidth(),
-                                static_cast<uint64_t>(LHS.getBitWidth() - 1)),
+                    static_cast<uint64_t>(LHS.getBitWidth() - 1)),
                     RHS.isUnsigned());
     else if (RHS.isSigned() && RHS.isNegative()) {
       // During constant-folding, a negative shift is an opposite shift. Such a
@@ -2860,36 +2892,24 @@ static bool handleIntIntBinOp(EvalInfo &Info, const BinaryOperator *E,
   shift_right:
     // C++11 [expr.shift]p1: Shift width must be less than the bit width of the
     // shifted type.
-    unsigned SA = (unsigned)RHS.getLimitedValue(LHS.getBitWidth() - 1);
+    unsigned SA = (unsigned) RHS.getLimitedValue(LHS.getBitWidth()-1);
     if (SA != RHS) {
       Info.CCEDiag(E, diag::note_constexpr_large_shift)
-          << RHS << E->getType() << LHS.getBitWidth();
+        << RHS << E->getType() << LHS.getBitWidth();
       if (!Info.noteUndefinedBehavior())
-        return false;
-    }
-
-    Result = LHS >> SA;
-    return true;
-  }
-
-  case BO_LT:
-    Result = LHS < RHS;
-    return true;
-  case BO_GT:
-    Result = LHS > RHS;
-    return true;
-  case BO_LE:
-    Result = LHS <= RHS;
-    return true;
-  case BO_GE:
-    Result = LHS >= RHS;
-    return true;
-  case BO_EQ:
-    Result = LHS == RHS;
-    return true;
-  case BO_NE:
-    Result = LHS != RHS;
+        return false;
+    }
+
+    Result = LHS >> SA;
     return true;
+  }
+
+  case BO_LT: Result = LHS < RHS; return true;
+  case BO_GT: Result = LHS > RHS; return true;
+  case BO_LE: Result = LHS <= RHS; return true;
+  case BO_GE: Result = LHS >= RHS; return true;
+  case BO_EQ: Result = LHS == RHS; return true;
+  case BO_NE: Result = LHS != RHS; return true;
   case BO_Cmp:
     llvm_unreachable("BO_Cmp should be handled elsewhere");
   }
@@ -3107,8 +3127,7 @@ static bool CastToDerivedClass(EvalInfo &Info, const Expr *E, LValue &Result,
   // Truncate the path to the subobject, and remove any derived-to-base offsets.
   const RecordDecl *RD = TruncatedType;
   for (unsigned I = TruncatedElements, N = D.Entries.size(); I != N; ++I) {
-    if (RD->isInvalidDecl())
-      return false;
+    if (RD->isInvalidDecl()) return false;
     const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(RD);
     const CXXRecordDecl *Base = getAsBaseClass(D.Entries[I]);
     if (isVirtualBaseClass(D.Entries[I]))
@@ -3126,8 +3145,7 @@ static bool HandleLValueDirectBase(EvalInfo &Info, const Expr *E, LValue &Obj,
                                    const CXXRecordDecl *Base,
                                    const ASTRecordLayout *RL = nullptr) {
   if (!RL) {
-    if (Derived->isInvalidDecl())
-      return false;
+    if (Derived->isInvalidDecl()) return false;
     RL = &Info.Ctx.getASTRecordLayout(Derived);
   }
 
@@ -3158,8 +3176,7 @@ static bool HandleLValueBase(EvalInfo &Info, const Expr *E, LValue &Obj,
     return false;
 
   // Find the virtual base class.
-  if (DerivedDecl->isInvalidDecl())
-    return false;
+  if (DerivedDecl->isInvalidDecl()) return false;
   const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(DerivedDecl);
   Obj.addDecl(Info, E, BaseDecl, /*Virtual*/ true);
   Obj.getLValueOffset() += Layout.getVBaseClassOffset(BaseDecl);
@@ -3171,7 +3188,8 @@ static bool HandleLValueBasePath(EvalInfo &Info, const CastExpr *E,
   for (CastExpr::path_const_iterator PathI = E->path_begin(),
                                      PathE = E->path_end();
        PathI != PathE; ++PathI) {
-    if (!HandleLValueBase(Info, E, Result, Type->getAsCXXRecordDecl(), *PathI))
+    if (!HandleLValueBase(Info, E, Result, Type->getAsCXXRecordDecl(),
+                          *PathI))
       return false;
     Type = (*PathI)->getType();
   }
@@ -3199,8 +3217,7 @@ static bool HandleLValueMember(EvalInfo &Info, const Expr *E, LValue &LVal,
                                const FieldDecl *FD,
                                const ASTRecordLayout *RL = nullptr) {
   if (!RL) {
-    if (FD->getParent()->isInvalidDecl())
-      return false;
+    if (FD->getParent()->isInvalidDecl()) return false;
     RL = &Info.Ctx.getASTRecordLayout(FD->getParent());
   }
 
@@ -3395,7 +3412,8 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
         !Info.CurrentCall->Callee ||
         !Info.CurrentCall->Callee->Equals(VD->getDeclContext())) {
       if (Info.getLangOpts().CPlusPlus11) {
-        Info.FFDiag(E, diag::note_constexpr_function_param_value_unknown) << VD;
+        Info.FFDiag(E, diag::note_constexpr_function_param_value_unknown)
+            << VD;
         NoteLValueLocation(Info, Base);
       } else {
         Info.FFDiag(E);
@@ -3419,7 +3437,8 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
     // Don't diagnose during potential constant expression checking; an
     // initializer might be added later.
     if (!Info.checkingPotentialConstantExpression()) {
-      Info.FFDiag(E, diag::note_constexpr_var_init_unknown, 1) << VD;
+      Info.FFDiag(E, diag::note_constexpr_var_init_unknown, 1)
+        << VD;
       NoteLValueLocation(Info, Base);
     }
     return false;
@@ -3437,11 +3456,9 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
     // have been value-dependent too), so diagnose that.
     assert(!VD->mightBeUsableInConstantExpressions(Info.Ctx));
     if (!Info.checkingPotentialConstantExpression()) {
-      Info.FFDiag(E,
-                  Info.getLangOpts().CPlusPlus11
-                      ? diag::note_constexpr_ltor_non_constexpr
-                      : diag::note_constexpr_ltor_non_integral,
-                  1)
+      Info.FFDiag(E, Info.getLangOpts().CPlusPlus11
+                         ? diag::note_constexpr_ltor_non_constexpr
+                         : diag::note_constexpr_ltor_non_integral, 1)
           << VD << VD->getType();
       NoteLValueLocation(Info, Base);
     }
@@ -3505,8 +3522,7 @@ static unsigned getBaseIndex(const CXXRecordDecl *Derived,
   Base = Base->getCanonicalDecl();
   unsigned Index = 0;
   for (CXXRecordDecl::base_class_const_iterator I = Derived->bases_begin(),
-                                                E = Derived->bases_end();
-       I != E; ++I, ++Index) {
+         E = Derived->bases_end(); I != E; ++I, ++Index) {
     if (I->getType()->getAsCXXRecordDecl()->getCanonicalDecl() == Base)
       return Index;
   }
@@ -3531,7 +3547,8 @@ static APSInt extractStringLiteralCharacter(EvalInfo &Info, const Expr *Lit,
   if (auto PE = dyn_cast<PredefinedExpr>(Lit))
     Lit = PE->getFunctionName();
   const StringLiteral *S = cast<StringLiteral>(Lit);
-  const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(S->getType());
+  const ConstantArrayType *CAT =
+      Info.Ctx.getAsConstantArrayType(S->getType());
   assert(CAT && "string literal isn't an array");
   QualType CharType = CAT->getElementType();
   assert(CharType->isIntegerType() && "unexpected character type");
@@ -3556,8 +3573,8 @@ static void expandStringLiteral(EvalInfo &Info, const StringLiteral *S,
   assert(CharType->isIntegerType() && "unexpected character type");
 
   unsigned Elts = CAT->getZExtSize();
-  Result =
-      APValue(APValue::UninitArray(), std::min(S->getLength(), Elts), Elts);
+  Result = APValue(APValue::UninitArray(),
+                   std::min(S->getLength(), Elts), Elts);
   APSInt Value(Info.Ctx.getTypeSize(CharType),
                CharType->isUnsignedIntegerType());
   if (Result.hasArrayFiller())
@@ -3575,7 +3592,7 @@ static void expandArray(APValue &Array, unsigned Index) {
 
   // Always at least double the number of elements for which we store a value.
   unsigned OldElts = Array.getArrayInitializedElts();
-  unsigned NewElts = std::max(Index + 1, OldElts * 2);
+  unsigned NewElts = std::max(Index+1, OldElts * 2);
   NewElts = std::min(Size, std::max(NewElts, 8u));
 
   // Copy the data across.
@@ -4109,7 +4126,7 @@ struct CompleteObject {
     if (!Info.getLangOpts().CPlusPlus14 &&
         AK != AccessKinds::AK_IsWithinLifetime)
       return false;
-    return lifetimeStartedInEvaluation(Info, Base, /*MutableSubobject*/ true);
+    return lifetimeStartedInEvaluation(Info, Base, /*MutableSubobject*/true);
   }
 
   explicit operator bool() const { return !Type.isNull(); }
@@ -4156,8 +4173,7 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj,
 
   // Walk the designator's path to find the subobject.
   for (unsigned I = 0, N = Sub.Entries.size(); /**/; ++I) {
-    // Reading an indeterminate value is undefined, but assigning over one is
-    // OK.
+    // Reading an indeterminate value is undefined, but assigning over one is OK.
     if ((O->isAbsent() && !(handler.AccessKind == AK_Construct && I == N)) ||
         (O->isIndeterminate() &&
          !isValidIndeterminateAccess(handler.AccessKind))) {
@@ -4199,7 +4215,7 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj,
             DiagKind = 2;
             Loc = VolatileField->getLocation();
             Decl = VolatileField;
-          } else if (auto *VD = Obj.Base.dyn_cast<const ValueDecl *>()) {
+          } else if (auto *VD = Obj.Base.dyn_cast<const ValueDecl*>()) {
             DiagKind = 1;
             Loc = VD->getLocation();
             Decl = VD;
@@ -4232,8 +4248,8 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj,
         return false;
 
       // If we modified a bit-field, truncate it to the right width.
-      if (isModification(handler.AccessKind) && LastField &&
-          LastField->isBitField() &&
+      if (isModification(handler.AccessKind) &&
+          LastField && LastField->isBitField() &&
           !truncateBitfieldValue(Info, E, *O, LastField))
         return false;
 
@@ -4253,7 +4269,7 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj,
         // designator which points more than one past the end of the array.
         if (Info.getLangOpts().CPlusPlus11)
           Info.FFDiag(E, diag::note_constexpr_access_past_end)
-              << handler.AccessKind;
+            << handler.AccessKind;
         else
           Info.FFDiag(E);
         return handler.failed();
@@ -4278,7 +4294,7 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj,
       if (Index > 1) {
         if (Info.getLangOpts().CPlusPlus11)
           Info.FFDiag(E, diag::note_constexpr_access_past_end)
-              << handler.AccessKind;
+            << handler.AccessKind;
         else
           Info.FFDiag(E);
         return handler.failed();
@@ -4289,13 +4305,12 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj,
 
       assert(I == N - 1 && "extracting subobject of scalar?");
       if (O->isComplexInt()) {
-        return handler.found(
-            Index ? O->getComplexIntImag() : O->getComplexIntReal(), ObjType);
+        return handler.found(Index ? O->getComplexIntImag()
+                                   : O->getComplexIntReal(), ObjType);
       } else {
         assert(O->isComplexFloat());
         return handler.found(Index ? O->getComplexFloatImag()
-                                   : O->getComplexFloatReal(),
-                             ObjType);
+                                   : O->getComplexFloatReal(), ObjType);
       }
     } else if (const auto *VT = ObjType->getAs<VectorType>()) {
       uint64_t Index = Sub.Entries[I].getAsArrayIndex();
@@ -4331,7 +4346,7 @@ findSubobject(EvalInfo &Info, const Expr *E, const CompleteObject &Obj,
       if (Field->isMutable() &&
           !Obj.mayAccessMutableMembers(Info, handler.AccessKind)) {
         Info.FFDiag(E, diag::note_constexpr_access_mutable, 1)
-            << handler.AccessKind << Field;
+          << handler.AccessKind << Field;
         Info.Note(Field->getLocation(), diag::note_declared_at);
         return handler.failed();
       }
@@ -4464,8 +4479,9 @@ const AccessKinds ModifySubobjectHandler::AccessKind;
 /// Update the designated sub-object of an rvalue to the given value.
 static bool modifySubobject(EvalInfo &Info, const Expr *E,
                             const CompleteObject &Obj,
-                            const SubobjectDesignator &Sub, APValue &NewVal) {
-  ModifySubobjectHandler Handler = {Info, NewVal, E};
+                            const SubobjectDesignator &Sub,
+                            APValue &NewVal) {
+  ModifySubobjectHandler Handler = { Info, NewVal, E };
   return findSubobject(Info, E, Obj, Sub, Handler);
 }
 
@@ -4566,7 +4582,7 @@ static CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E,
   if (isFormalAccess(AK) && LValType.isVolatileQualified()) {
     if (Info.getLangOpts().CPlusPlus)
       Info.FFDiag(E, diag::note_constexpr_access_volatile_type)
-          << AK << LValType;
+        << AK << LValType;
     else
       Info.FFDiag(E);
     return CompleteObject();
@@ -4686,11 +4702,9 @@ static CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E,
         // folding of const floating-point types, in order to make static const
         // data members of such types (supported as an extension) more useful.
         if (Info.getLangOpts().CPlusPlus) {
-          Info.CCEDiag(E,
-                       Info.getLangOpts().CPlusPlus11
-                           ? diag::note_constexpr_ltor_non_constexpr
-                           : diag::note_constexpr_ltor_non_integral,
-                       1)
+          Info.CCEDiag(E, Info.getLangOpts().CPlusPlus11
+                              ? diag::note_constexpr_ltor_non_constexpr
+                              : diag::note_constexpr_ltor_non_integral, 1)
               << VD << BaseType;
           Info.Note(VD->getLocation(), diag::note_declared_at);
         } else {
@@ -4699,11 +4713,9 @@ static CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E,
       } else {
         // Never allow reading a non-const value.
         if (Info.getLangOpts().CPlusPlus) {
-          Info.FFDiag(E,
-                      Info.getLangOpts().CPlusPlus11
-                          ? diag::note_constexpr_ltor_non_constexpr
-                          : diag::note_constexpr_ltor_non_integral,
-                      1)
+          Info.FFDiag(E, Info.getLangOpts().CPlusPlus11
+                             ? diag::note_constexpr_ltor_non_constexpr
+                             : diag::note_constexpr_ltor_non_integral, 1)
               << VD << BaseType;
           Info.Note(VD->getLocation(), diag::note_declared_at);
         } else {
@@ -4742,7 +4754,7 @@ static CompleteObject findCompleteObject(EvalInfo &Info, const Expr *E,
   // When binding to a reference, the variable does not need to be
   // within its lifetime.
   else if (AK != clang::AK_Dereference) {
-    const Expr *Base = LVal.Base.dyn_cast<const Expr *>();
+    const Expr *Base = LVal.Base.dyn_cast<const Expr*>();
 
     if (!Frame) {
       if (const MaterializeTemporaryExpr *MTE =
@@ -4869,7 +4881,7 @@ handleLValueToRValueConversion(EvalInfo &Info, const Expr *Conv, QualType Type,
     return false;
 
   // Check for special cases where there is no existing APValue to look at.
-  const Expr *Base = LVal.Base.dyn_cast<const Expr *>();
+  const Expr *Base = LVal.Base.dyn_cast<const Expr*>();
 
   AccessKinds AK =
       WantObjectRepresentation ? AK_ReadObjectRepresentation : AK_Read;
@@ -5022,7 +5034,8 @@ struct CompoundAssignSubobjectHandler {
       Value = HandleIntToIntCast(Info, E, SubobjType, PromotedLHSType, LHS);
       return true;
     } else if (RHS.isFloat()) {
-      const FPOptions FPO = E->getFPFeaturesInEffect(Info.Ctx.getLangOpts());
+      const FPOptions FPO = E->getFPFeaturesInEffect(
+                                    Info.Ctx.getLangOpts());
       APFloat FValue(0.0);
       return HandleIntToFloatCast(Info, E, FPO, SubobjType, Value,
                                   PromotedLHSType, FValue) &&
@@ -5087,8 +5100,8 @@ static bool handleCompoundAssignment(EvalInfo &Info,
   }
 
   CompleteObject Obj = findCompleteObject(Info, E, AK_Assign, LVal, LValType);
-  CompoundAssignSubobjectHandler Handler = {Info, E, PromotedLValType, Opcode,
-                                            RVal};
+  CompoundAssignSubobjectHandler Handler = { Info, E, PromotedLValType, Opcode,
+                                             RVal };
   return Obj && findSubobject(Info, E, Obj, LVal.Designator, Handler);
 }
 
@@ -5125,15 +5138,13 @@ struct IncDecSubobjectHandler {
     case APValue::Float:
       return found(Subobj.getFloat(), SubobjType);
     case APValue::ComplexInt:
-      return found(
-          Subobj.getComplexIntReal(),
-          SubobjType->castAs<ComplexType>()->getElementType().withCVRQualifiers(
-              SubobjType.getCVRQualifiers()));
+      return found(Subobj.getComplexIntReal(),
+                   SubobjType->castAs<ComplexType>()->getElementType()
+                     .withCVRQualifiers(SubobjType.getCVRQualifiers()));
     case APValue::ComplexFloat:
-      return found(
-          Subobj.getComplexFloatReal(),
-          SubobjType->castAs<ComplexType>()->getElementType().withCVRQualifiers(
-              SubobjType.getCVRQualifiers()));
+      return found(Subobj.getComplexFloatReal(),
+                   SubobjType->castAs<ComplexType>()->getElementType()
+                     .withCVRQualifiers(SubobjType.getCVRQualifiers()));
     case APValue::LValue:
       return foundPointer(Subobj, SubobjType);
     default:
@@ -5153,8 +5164,7 @@ struct IncDecSubobjectHandler {
       return false;
     }
 
-    if (Old)
-      *Old = APValue(Value);
+    if (Old) *Old = APValue(Value);
 
     // bool arithmetic promotes to int, and the conversion back to bool
     // doesn't reduce mod 2^n, so special-case it.
@@ -5172,7 +5182,7 @@ struct IncDecSubobjectHandler {
 
       if (!WasNegative && Value.isNegative() && E->canOverflow() &&
           !SubobjType.isWrapType()) {
-        APSInt ActualValue(Value, /*IsUnsigned*/ true);
+        APSInt ActualValue(Value, /*IsUnsigned*/true);
         return HandleOverflow(Info, E, ActualValue, SubobjType);
       }
     } else {
@@ -5181,7 +5191,7 @@ struct IncDecSubobjectHandler {
       if (WasNegative && !Value.isNegative() && E->canOverflow() &&
           !SubobjType.isWrapType()) {
         unsigned BitWidth = Value.getBitWidth();
-        APSInt ActualValue(Value.sext(BitWidth + 1), /*IsUnsigned*/ false);
+        APSInt ActualValue(Value.sext(BitWidth + 1), /*IsUnsigned*/false);
         ActualValue.setBit(BitWidth);
         return HandleOverflow(Info, E, ActualValue, SubobjType);
       }
@@ -5192,8 +5202,7 @@ struct IncDecSubobjectHandler {
     if (!checkConst(SubobjType))
       return false;
 
-    if (Old)
-      *Old = APValue(Value);
+    if (Old) *Old = APValue(Value);
 
     APFloat One(Value.getSemantics(), 1);
     llvm::RoundingMode RM = getActiveRoundingMode(Info, E);
@@ -5275,7 +5284,8 @@ static bool EvaluateObjectArgument(EvalInfo &Info, const Expr *Object,
 /// \return The field or method declaration to which the member pointer refers,
 ///         or 0 if evaluation fails.
 static const ValueDecl *HandleMemberPointerAccess(EvalInfo &Info,
-                                                  QualType LVType, LValue &LV,
+                                                  QualType LVType,
+                                                  LValue &LV,
                                                   const Expr *RHS,
                                                   bool IncludeMember = true) {
   MemberPtr MemPtr;
@@ -5305,8 +5315,8 @@ static const ValueDecl *HandleMemberPointerAccess(EvalInfo &Info,
     unsigned PathLengthToMember =
         LV.Designator.Entries.size() - MemPtr.Path.size();
     for (unsigned I = 0, N = MemPtr.Path.size(); I != N; ++I) {
-      const CXXRecordDecl *LVDecl =
-          getAsBaseClass(LV.Designator.Entries[PathLengthToMember + I]);
+      const CXXRecordDecl *LVDecl = getAsBaseClass(
+          LV.Designator.Entries[PathLengthToMember + I]);
       const CXXRecordDecl *MPDecl = MemPtr.Path[I];
       if (LVDecl->getCanonicalDecl() != MPDecl->getCanonicalDecl()) {
         Info.FFDiag(RHS);
@@ -5365,7 +5375,7 @@ static const ValueDecl *HandleMemberPointerAccess(EvalInfo &Info,
       if (!HandleLValueMember(Info, RHS, LV, FD))
         return nullptr;
     } else if (const IndirectFieldDecl *IFD =
-                   dyn_cast<IndirectFieldDecl>(MemPtr.getDecl())) {
+                 dyn_cast<IndirectFieldDecl>(MemPtr.getDecl())) {
       if (!HandleLValueIndirectMember(Info, RHS, LV, IFD))
         return nullptr;
     } else {
@@ -5636,10 +5646,12 @@ struct TempVersionRAII {
     Frame.pushTempVersion();
   }
 
-  ~TempVersionRAII() { Frame.popTempVersion(); }
+  ~TempVersionRAII() {
+    Frame.popTempVersion();
+  }
 };
 
-} // namespace
+}
 
 static EvalStmtResult EvaluateStmt(StmtResult &Result, EvalInfo &Info,
                                    const Stmt *S,
@@ -5886,7 +5898,8 @@ static EvalStmtResult EvaluateStmt(StmtResult &Result, EvalInfo &Info,
         }
       }
 
-      EvalStmtResult ESR = EvaluateLoopBody(Result, Info, FS->getBody(), Case);
+      EvalStmtResult ESR =
+          EvaluateLoopBody(Result, Info, FS->getBody(), Case);
       if (ShouldPropagateBreakContinue(Info, FS, /*Scopes=*/{}, ESR))
         return ESR;
       if (ESR != ESR_Continue)
@@ -5977,9 +5990,10 @@ static EvalStmtResult EvaluateStmt(StmtResult &Result, EvalInfo &Info,
       // We know we returned, but we don't know what the value is.
       return ESR_Failed;
     }
-    if (RetExpr && !(Result.Slot ? EvaluateInPlace(Result.Value, Info,
-                                                   *Result.Slot, RetExpr)
-                                 : Evaluate(Result.Value, Info, RetExpr)))
+    if (RetExpr &&
+        !(Result.Slot
+              ? EvaluateInPlace(Result.Value, Info, *Result.Slot, RetExpr)
+              : Evaluate(Result.Value, Info, RetExpr)))
       return ESR_Failed;
     return Scope.destroy() ? ESR_Returned : ESR_Failed;
   }
@@ -6304,7 +6318,7 @@ static bool CheckTrivialDefaultConstructor(EvalInfo &Info, SourceLocation Loc,
       // FIXME: If DiagDecl is an implicitly-declared special member function,
       // we should be much more explicit about why it's not constexpr.
       Info.CCEDiag(Loc, diag::note_constexpr_invalid_function, 1)
-          << /*IsConstexpr*/ 0 << /*IsConstructor*/ 1 << CD;
+        << /*IsConstexpr*/0 << /*IsConstructor*/1 << CD;
       Info.Note(CD->getLocation(), diag::note_declared_at);
     } else {
       Info.CCEDiag(Loc, diag::note_invalid_subexpr_in_const_expr);
@@ -6348,7 +6362,7 @@ static bool CheckConstexprFunction(EvalInfo &Info, SourceLocation CallLoc,
   // Can we evaluate this function call?
   if (Definition && Body &&
       (Definition->isConstexpr() || (Info.CurrentCall->CanEvalMSConstexpr &&
-                                     Definition->hasAttr<MSConstexprAttr>())))
+                                        Definition->hasAttr<MSConstexprAttr>())))
     return true;
 
   const FunctionDecl *DiagDecl = Definition ? Definition : Declaration;
@@ -6381,10 +6395,10 @@ static bool CheckConstexprFunction(EvalInfo &Info, SourceLocation CallLoc,
     // it's not constexpr.
     if (CD && CD->isInheritingConstructor())
       Info.FFDiag(CallLoc, diag::note_constexpr_invalid_inhctor, 1)
-          << CD->getInheritedConstructor().getConstructor()->getParent();
+        << CD->getInheritedConstructor().getConstructor()->getParent();
     else
       Info.FFDiag(CallLoc, diag::note_constexpr_invalid_function, 1)
-          << DiagDecl->isConstexpr() << (bool)CD << DiagDecl;
+        << DiagDecl->isConstexpr() << (bool)CD << DiagDecl;
     Info.Note(DiagDecl->getLocation(), diag::note_declared_at);
   } else {
     Info.FFDiag(CallLoc, diag::note_invalid_subexpr_in_const_expr);
@@ -6467,8 +6481,8 @@ struct DynamicType {
 
 static const CXXRecordDecl *getBaseClassType(SubobjectDesignator &Designator,
                                              unsigned PathLength) {
-  assert(PathLength >= Designator.MostDerivedPathLength &&
-         PathLength <= Designator.Entries.size() && "invalid path length");
+  assert(PathLength >= Designator.MostDerivedPathLength && PathLength <=
+      Designator.Entries.size() && "invalid path length");
   return (PathLength == Designator.MostDerivedPathLength)
              ? Designator.MostDerivedType->getAsCXXRecordDecl()
              : getAsBaseClass(Designator.Entries[PathLength - 1]);
@@ -6672,7 +6686,7 @@ static bool HandleDynamicCast(EvalInfo &Info, const ExplicitCastExpr *E,
   assert(C && "dynamic_cast target is not void pointer nor class");
   CanQualType CQT = Info.Ctx.getCanonicalTagType(C);
 
-  auto RuntimeCheckFailed = [&](CXXBasePaths *Paths) {
+  auto RuntimeCheckFailed = [&] (CXXBasePaths *Paths) {
     // C++ [expr.dynamic.cast]p9:
     if (!E->isGLValue()) {
       //   The value of a failed cast to pointer type is the null pointer value
@@ -6796,7 +6810,7 @@ static bool MaybeHandleUnionActiveMemberChange(EvalInfo &Info,
   if (LHS.InvalidBase || LHS.Designator.Invalid)
     return false;
 
-  llvm::SmallVector<std::pair<unsigned, const FieldDecl *>, 4> UnionPathLengths;
+  llvm::SmallVector<std::pair<unsigned, const FieldDecl*>, 4> UnionPathLengths;
   // C++ [class.union]p5:
   //   define the set S(E) of subexpressions of E as follows:
   unsigned PathLength = LHS.Designator.Entries.size();
@@ -6822,9 +6836,9 @@ static bool MaybeHandleUnionActiveMemberChange(EvalInfo &Info,
 
       E = ME->getBase();
       --PathLength;
-      assert(declaresSameEntity(
-          FD,
-          LHS.Designator.Entries[PathLength].getAsBaseOrMember().getPointer()));
+      assert(declaresSameEntity(FD,
+                                LHS.Designator.Entries[PathLength]
+                                    .getAsBaseOrMember().getPointer()));
 
       //   -- If E is of the form A[B] and is interpreted as a built-in array
       //      subscripting operator, S(E) is [S(the array operand, if any)].
@@ -6857,11 +6871,10 @@ static bool MaybeHandleUnionActiveMemberChange(EvalInfo &Info,
         --PathLength;
         assert(declaresSameEntity(Elt->getType()->getAsCXXRecordDecl(),
                                   LHS.Designator.Entries[PathLength]
-                                      .getAsBaseOrMember()
-                                      .getPointer()));
+                                      .getAsBaseOrMember().getPointer()));
       }
 
-      //   -- Otherwise, S(E) is empty.
+    //   -- Otherwise, S(E) is empty.
     } else {
       break;
     }
@@ -6878,7 +6891,7 @@ static bool MaybeHandleUnionActiveMemberChange(EvalInfo &Info,
   if (!Obj)
     return false;
   for (std::pair<unsigned, const FieldDecl *> LengthAndField :
-       llvm::reverse(UnionPathLengths)) {
+           llvm::reverse(UnionPathLengths)) {
     // Form a designator for the union object.
     SubobjectDesignator D = LHS.Designator;
     D.truncate(Info.Ctx, LHS.Base, LengthAndField.first);
@@ -7108,11 +7121,10 @@ static bool HandleConstructorCall(const Expr *E, const LValue &This,
                        RD->getNumFields());
     else
       // A union starts with no active member.
-      Result = APValue((const FieldDecl *)nullptr);
+      Result = APValue((const FieldDecl*)nullptr);
   }
 
-  if (RD->isInvalidDecl())
-    return false;
+  if (RD->isInvalidDecl()) return false;
   const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(RD);
 
   // A scope for temporaries lifetime-extended by reference members.
@@ -7271,7 +7283,7 @@ static bool HandleConstructorCall(const Expr *E, const LValue &This,
 }
 
 static bool HandleConstructorCall(const Expr *E, const LValue &This,
-                                  ArrayRef<const Expr *> Args,
+                                  ArrayRef<const Expr*> Args,
                                   const CXXConstructorDecl *Definition,
                                   EvalInfo &Info, APValue &Result) {
   CallScopeRAII CallScope(Info);
@@ -7418,7 +7430,7 @@ static bool HandleDestructionImpl(EvalInfo &Info, SourceRange CallRange,
 
   // We don't have a good way to iterate fields in reverse, so collect all the
   // fields first and then walk them backwards.
-  SmallVector<FieldDecl *, 16> Fields(RD->fields());
+  SmallVector<FieldDecl*, 16> Fields(RD->fields());
   for (const FieldDecl *FD : llvm::reverse(Fields)) {
     if (FD->isUnnamedBitField())
       continue;
@@ -7480,12 +7492,12 @@ struct DestroyObjectHandler {
     return false;
   }
 };
-} // namespace
+}
 
 /// Perform a destructor or pseudo-destructor call on the given object, which
 /// might in general not be a complete object.
-static bool HandleDestruction(EvalInfo &Info, const Expr *E, const LValue &This,
-                              QualType ThisType) {
+static bool HandleDestruction(EvalInfo &Info, const Expr *E,
+                              const LValue &This, QualType ThisType) {
   CompleteObject Obj = findCompleteObject(Info, E, AK_Destroy, This, ThisType);
   DestroyObjectHandler Handler = {Info, E, This, AK_Destroy};
   return Obj && findSubobject(Info, E, Obj, This.Designator, Handler);
@@ -7689,8 +7701,8 @@ class BitCastBuffer {
 
 public:
   BitCastBuffer(CharUnits Width, bool TargetIsLittleEndian)
-      : Bytes(Width.getQuantity()), TargetIsLittleEndian(TargetIsLittleEndian) {
-  }
+      : Bytes(Width.getQuantity()),
+        TargetIsLittleEndian(TargetIsLittleEndian) {}
 
   [[nodiscard]] bool readObject(CharUnits Offset, CharUnits Width,
                                 SmallVectorImpl<unsigned char> &Output) const {
@@ -8013,7 +8025,8 @@ class BufferToAPValueConverter {
                          T->isSpecificBuiltinType(BuiltinType::Char_U));
       if (!IsStdByte && !IsUChar) {
         QualType DisplayType(EnumSugar ? (const Type *)EnumSugar : T, 0);
-        Info.FFDiag(BCE->getExprLoc(), diag::note_constexpr_bit_cast_indet_dest)
+        Info.FFDiag(BCE->getExprLoc(),
+                    diag::note_constexpr_bit_cast_indet_dest)
             << DisplayType << Info.Ctx.getLangOpts().CharIsSigned;
         return std::nullopt;
       }
@@ -8366,9 +8379,10 @@ static bool handleLValueToRValueBitCast(EvalInfo &Info, APValue &DestValue,
 }
 
 template <class Derived>
-class ExprEvaluatorBase : public ConstStmtVisitor<Derived, bool> {
+class ExprEvaluatorBase
+  : public ConstStmtVisitor<Derived, bool> {
 private:
-  Derived &getDerived() { return static_cast<Derived &>(*this); }
+  Derived &getDerived() { return static_cast<Derived&>(*this); }
   bool DerivedSuccess(const APValue &V, const Expr *E) {
     return getDerived().Success(V, E);
   }
@@ -8379,7 +8393,7 @@ class ExprEvaluatorBase : public ConstStmtVisitor<Derived, bool> {
   // Check whether a conditional operator with a non-constant condition is a
   // potential constant expression. If neither arm is a potential constant
   // expression, then the conditional operator is not either.
-  template <typename ConditionalOperator>
+  template<typename ConditionalOperator>
   void CheckPotentialConstantConditional(const ConditionalOperator *E) {
     assert(Info.checkingPotentialConstantExpression());
 
@@ -8403,7 +8417,8 @@ class ExprEvaluatorBase : public ConstStmtVisitor<Derived, bool> {
     Error(E, diag::note_constexpr_conditional_never_const);
   }
 
-  template <typename ConditionalOperator>
+
+  template<typename ConditionalOperator>
   bool HandleConditionalOperator(const ConditionalOperator *E) {
     bool BoolResult;
     if (!EvaluateAsBooleanCondition(E->getCond(), BoolResult, Info)) {
@@ -8457,7 +8472,9 @@ class ExprEvaluatorBase : public ConstStmtVisitor<Derived, bool> {
   bool VisitStmt(const Stmt *) {
     llvm_unreachable("Expression evaluator should not be called on stmts");
   }
-  bool VisitExpr(const Expr *E) { return Error(E); }
+  bool VisitExpr(const Expr *E) {
+    return Error(E);
+  }
 
   bool VisitEmbedExpr(const EmbedExpr *E) {
     const auto It = E->begin();
@@ -8474,25 +8491,18 @@ class ExprEvaluatorBase : public ConstStmtVisitor<Derived, bool> {
     return StmtVisitorTy::Visit(E->getSubExpr());
   }
 
-  bool VisitParenExpr(const ParenExpr *E) {
-    return StmtVisitorTy::Visit(E->getSubExpr());
-  }
-  bool VisitUnaryExtension(const UnaryOperator *E) {
-    return StmtVisitorTy::Visit(E->getSubExpr());
-  }
-  bool VisitUnaryPlus(const UnaryOperator *E) {
-    return StmtVisitorTy::Visit(E->getSubExpr());
-  }
-  bool VisitChooseExpr(const ChooseExpr *E) {
-    return StmtVisitorTy::Visit(E->getChosenSubExpr());
-  }
-  bool VisitGenericSelectionExpr(const GenericSelectionExpr *E) {
-    return StmtVisitorTy::Visit(E->getResultExpr());
-  }
-  bool
-  VisitSubstNonTypeTemplateParmExpr(const SubstNonTypeTemplateParmExpr *E) {
-    return StmtVisitorTy::Visit(E->getReplacement());
-  }
+  bool VisitParenExpr(const ParenExpr *E)
+    { return StmtVisitorTy::Visit(E->getSubExpr()); }
+  bool VisitUnaryExtension(const UnaryOperator *E)
+    { return StmtVisitorTy::Visit(E->getSubExpr()); }
+  bool VisitUnaryPlus(const UnaryOperator *E)
+    { return StmtVisitorTy::Visit(E->getSubExpr()); }
+  bool VisitChooseExpr(const ChooseExpr *E)
+    { return StmtVisitorTy::Visit(E->getChosenSubExpr()); }
+  bool VisitGenericSelectionExpr(const GenericSelectionExpr *E)
+    { return StmtVisitorTy::Visit(E->getResultExpr()); }
+  bool VisitSubstNonTypeTemplateParmExpr(const SubstNonTypeTemplateParmExpr *E)
+    { return StmtVisitorTy::Visit(E->getReplacement()); }
   bool VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *E) {
     TempVersionRAII RAII(*Info.CurrentCall);
     SourceLocExprScopeGuard Guard(E, Info.CurrentCall->CurSourceLocExprScope);
@@ -8521,16 +8531,16 @@ class ExprEvaluatorBase : public ConstStmtVisitor<Derived, bool> {
   bool VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *E) {
     CCEDiag(E, diag::note_constexpr_invalid_cast)
         << diag::ConstexprInvalidCastKind::Reinterpret;
-    return static_cast<Derived *>(this)->VisitCastExpr(E);
+    return static_cast<Derived*>(this)->VisitCastExpr(E);
   }
   bool VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *E) {
     if (!Info.Ctx.getLangOpts().CPlusPlus20)
       CCEDiag(E, diag::note_constexpr_invalid_cast)
           << diag::ConstexprInvalidCastKind::Dynamic;
-    return static_cast<Derived *>(this)->VisitCastExpr(E);
+    return static_cast<Derived*>(this)->VisitCastExpr(E);
   }
   bool VisitBuiltinBitCastExpr(const BuiltinBitCastExpr *E) {
-    return static_cast<Derived *>(this)->VisitCastExpr(E);
+    return static_cast<Derived*>(this)->VisitCastExpr(E);
   }
 
   bool VisitBinaryOperator(const BinaryOperator *E) {
@@ -8580,7 +8590,7 @@ class ExprEvaluatorBase : public ConstStmtVisitor<Derived, bool> {
     // side-effects. This is an important GNU extension. See GCC PR38377
     // for discussion.
     if (const CallExpr *CallCE =
-            dyn_cast<CallExpr>(E->getCond()->IgnoreParenCasts()))
+          dyn_cast<CallExpr>(E->getCond()->IgnoreParenCasts()))
       if (CallCE->getBuiltinCallee() == Builtin::BI__builtin_constant_p)
         IsBcpCall = true;
 
@@ -8654,7 +8664,7 @@ class ExprEvaluatorBase : public ConstStmtVisitor<Derived, bool> {
   }
 
   bool handleCallExpr(const CallExpr *E, APValue &Result,
-                      const LValue *ResultSlot) {
+                     const LValue *ResultSlot) {
     CallScopeRAII CallScope(Info);
 
     const Expr *Callee = E->getCallee()->IgnoreParens();
@@ -8716,7 +8726,7 @@ class ExprEvaluatorBase : public ConstStmtVisitor<Derived, bool> {
       // Don't call function pointers which have been cast to some other type.
       // Per DR (no number yet), the caller and callee can differ in noexcept.
       if (!Info.Ctx.hasSameFunctionTypeIgnoringExceptionSpec(
-              CalleeType->getPointeeType(), FD->getType())) {
+        CalleeType->getPointeeType(), FD->getType())) {
         return Error(E);
       }
 
@@ -8899,8 +8909,7 @@ class ExprEvaluatorBase : public ConstStmtVisitor<Derived, bool> {
     QualType BaseTy = E->getBase()->getType();
 
     const FieldDecl *FD = dyn_cast<FieldDecl>(E->getMemberDecl());
-    if (!FD)
-      return Error(E);
+    if (!FD) return Error(E);
     assert(!FD->getType()->isReferenceType() && "prvalue reference?");
     assert(BaseTy->castAsCanonical<RecordType>()->getDecl() ==
                FD->getParent()->getCanonicalDecl() &&
@@ -9057,7 +9066,7 @@ class ExprEvaluatorBase : public ConstStmtVisitor<Derived, bool> {
       }
 
       APValue ReturnValue;
-      StmtResult Result = {ReturnValue, nullptr};
+      StmtResult Result = { ReturnValue, nullptr };
       EvalStmtResult ESR = EvaluateStmt(Result, Info, *BI);
       if (ESR != ESR_Succeeded) {
         // FIXME: If the statement-expression terminated due to 'return',
@@ -9078,7 +9087,9 @@ class ExprEvaluatorBase : public ConstStmtVisitor<Derived, bool> {
   }
 
   /// Visit a value which is evaluated, but whose value is ignored.
-  void VisitIgnoredValue(const Expr *E) { EvaluateIgnoredValue(Info, E); }
+  void VisitIgnoredValue(const Expr *E) {
+    EvaluateIgnoredValue(Info, E);
+  }
 
   /// Potentially visit a MemberExpr's base expression.
   void VisitIgnoredBaseExpression(const Expr *E) {
@@ -9096,8 +9107,9 @@ class ExprEvaluatorBase : public ConstStmtVisitor<Derived, bool> {
 // Common base class for lvalue and temporary evaluation.
 //===----------------------------------------------------------------------===//
 namespace {
-template <class Derived>
-class LValueExprEvaluatorBase : public ExprEvaluatorBase<Derived> {
+template<class Derived>
+class LValueExprEvaluatorBase
+  : public ExprEvaluatorBase<Derived> {
 protected:
   LValue &Result;
   bool InvalidBaseOK;
@@ -9197,7 +9209,7 @@ class LValueExprEvaluatorBase : public ExprEvaluatorBase<Derived> {
     }
   }
 };
-} // namespace
+}
 
 //===----------------------------------------------------------------------===//
 // LValue Evaluation
@@ -9234,10 +9246,10 @@ class LValueExprEvaluatorBase : public ExprEvaluatorBase<Derived> {
 //===----------------------------------------------------------------------===//
 namespace {
 class LValueExprEvaluator
-    : public LValueExprEvaluatorBase<LValueExprEvaluator> {
+  : public LValueExprEvaluatorBase<LValueExprEvaluator> {
 public:
-  LValueExprEvaluator(EvalInfo &Info, LValue &Result, bool InvalidBaseOK)
-      : LValueExprEvaluatorBaseTy(Info, Result, InvalidBaseOK) {}
+  LValueExprEvaluator(EvalInfo &Info, LValue &Result, bool InvalidBaseOK) :
+    LValueExprEvaluatorBaseTy(Info, Result, InvalidBaseOK) {}
 
   bool VisitVarDecl(const Expr *E, const VarDecl *VD);
   bool VisitUnaryPreIncDec(const UnaryOperator *UO);
@@ -9354,8 +9366,7 @@ static bool EvaluateLValue(const Expr *E, LValue &Result, EvalInfo &Info,
                            bool InvalidBaseOK) {
   assert(!E->isValueDependent());
   assert(E->isGLValue() || E->getType()->isFunctionType() ||
-         E->getType()->isVoidType() ||
-         isa<ObjCSelectorExpr>(E->IgnoreParens()));
+         E->getType()->isVoidType() || isa<ObjCSelectorExpr>(E->IgnoreParens()));
   return LValueExprEvaluator(Info, Result, InvalidBaseOK).Visit(E);
 }
 
@@ -9537,8 +9548,8 @@ bool LValueExprEvaluator::VisitMaterializeTemporaryExpr(
   return true;
 }
 
-bool LValueExprEvaluator::VisitCompoundLiteralExpr(
-    const CompoundLiteralExpr *E) {
+bool
+LValueExprEvaluator::VisitCompoundLiteralExpr(const CompoundLiteralExpr *E) {
   assert((!Info.getLangOpts().CPlusPlus || E->isFileScope()) &&
          "lvalue compound literal in c++?");
   APValue *Lit;
@@ -9577,8 +9588,8 @@ bool LValueExprEvaluator::VisitCXXTypeidExpr(const CXXTypeidExpr *E) {
   } else {
     if (!Info.Ctx.getLangOpts().CPlusPlus20) {
       Info.CCEDiag(E, diag::note_constexpr_typeid_polymorphic)
-          << E->getExprOperand()->getType()
-          << E->getExprOperand()->getSourceRange();
+        << E->getExprOperand()->getType()
+        << E->getExprOperand()->getSourceRange();
     }
 
     if (!Visit(E->getExprOperand()))
@@ -9733,8 +9744,9 @@ bool LValueExprEvaluator::VisitUnaryPreIncDec(const UnaryOperator *UO) {
   if (!this->Visit(UO->getSubExpr()))
     return false;
 
-  return handleIncDec(this->Info, UO, Result, UO->getSubExpr()->getType(),
-                      UO->isIncrementOp(), nullptr);
+  return handleIncDec(
+      this->Info, UO, Result, UO->getSubExpr()->getType(),
+      UO->isIncrementOp(), nullptr);
 }
 
 bool LValueExprEvaluator::VisitCompoundAssignOperator(
@@ -9757,8 +9769,8 @@ bool LValueExprEvaluator::VisitCompoundAssignOperator(
     return false;
 
   return handleCompoundAssignment(
-      this->Info, CAO, Result, CAO->getLHS()->getType(),
-      CAO->getComputationLHSType(),
+      this->Info, CAO,
+      Result, CAO->getLHS()->getType(), CAO->getComputationLHSType(),
       CAO->getOpForCompoundAssignment(CAO->getOpcode()), RHS);
 }
 
@@ -9846,7 +9858,8 @@ static bool evaluateLValueAsAllocSize(EvalInfo &Info, APValue::LValueBase Base,
 }
 
 namespace {
-class PointerExprEvaluator : public ExprEvaluatorBase<PointerExprEvaluator> {
+class PointerExprEvaluator
+  : public ExprEvaluatorBase<PointerExprEvaluator> {
   LValue &Result;
   bool InvalidBaseOK;
 
@@ -9864,8 +9877,8 @@ class PointerExprEvaluator : public ExprEvaluatorBase<PointerExprEvaluator> {
   }
 
   bool visitNonBuiltinCallExpr(const CallExpr *E);
-
 public:
+
   PointerExprEvaluator(EvalInfo &info, LValue &Result, bool InvalidBaseOK)
       : ExprEvaluatorBaseTy(info), Result(Result),
         InvalidBaseOK(InvalidBaseOK) {}
@@ -9880,9 +9893,10 @@ class PointerExprEvaluator : public ExprEvaluatorBase<PointerExprEvaluator> {
   }
 
   bool VisitBinaryOperator(const BinaryOperator *E);
-  bool VisitCastExpr(const CastExpr *E);
+  bool VisitCastExpr(const CastExpr* E);
   bool VisitUnaryAddrOf(const UnaryOperator *E);
-  bool VisitObjCStringLiteral(const ObjCStringLiteral *E) { return Success(E); }
+  bool VisitObjCStringLiteral(const ObjCStringLiteral *E)
+      { return Success(E); }
   bool VisitObjCBoxedExpr(const ObjCBoxedExpr *E) {
     if (E->isExpressibleAsConstantInitializer())
       return Success(E);
@@ -9896,7 +9910,8 @@ class PointerExprEvaluator : public ExprEvaluatorBase<PointerExprEvaluator> {
   bool VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) {
     return E->isExpressibleAsConstantInitializer() ? Success(E) : Error(E);
   }
-  bool VisitAddrLabelExpr(const AddrLabelExpr *E) { return Success(E); }
+  bool VisitAddrLabelExpr(const AddrLabelExpr *E)
+      { return Success(E); }
   bool VisitCallExpr(const CallExpr *E);
   bool VisitBuiltinCallExpr(const CallExpr *E, unsigned BuiltinOp);
   bool VisitBlockExpr(const BlockExpr *E) {
@@ -9986,7 +10001,7 @@ class PointerExprEvaluator : public ExprEvaluatorBase<PointerExprEvaluator> {
 };
 } // end anonymous namespace
 
-static bool EvaluatePointer(const Expr *E, LValue &Result, EvalInfo &Info,
+static bool EvaluatePointer(const Expr* E, LValue& Result, EvalInfo &Info,
                             bool InvalidBaseOK) {
   assert(!E->isValueDependent());
   assert(E->isPRValue() && E->getType()->hasPointerRepresentation());
@@ -9994,7 +10009,8 @@ static bool EvaluatePointer(const Expr *E, LValue &Result, EvalInfo &Info,
 }
 
 bool PointerExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
-  if (E->getOpcode() != BO_Add && E->getOpcode() != BO_Sub)
+  if (E->getOpcode() != BO_Add &&
+      E->getOpcode() != BO_Sub)
     return ExprEvaluatorBaseTy::VisitBinaryOperator(E);
 
   const Expr *PExp = E->getLHS();
@@ -10116,10 +10132,9 @@ bool PointerExprEvaluator::VisitCastExpr(const CastExpr *E) {
 
     // Now figure out the necessary offset to add to the base LV to get from
     // the derived class to the base class.
-    return HandleLValueBasePath(
-        Info, E,
-        E->getSubExpr()->getType()->castAs<PointerType>()->getPointeeType(),
-        Result);
+    return HandleLValueBasePath(Info, E, E->getSubExpr()->getType()->
+                                  castAs<PointerType>()->getPointeeType(),
+                                Result);
 
   case CK_BaseToDerived:
     if (!Visit(E->getSubExpr()))
@@ -10445,7 +10460,8 @@ bool PointerExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
     if (!EvaluateInteger(E->getArg(1), Desired, Info))
       return false;
     uint64_t MaxLength = uint64_t(-1);
-    if (BuiltinOp != Builtin::BIstrchr && BuiltinOp != Builtin::BIwcschr &&
+    if (BuiltinOp != Builtin::BIstrchr &&
+        BuiltinOp != Builtin::BIwcschr &&
         BuiltinOp != Builtin::BI__builtin_strchr &&
         BuiltinOp != Builtin::BI__builtin_wcschr) {
       APSInt N;
@@ -10462,8 +10478,9 @@ bool PointerExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
     QualType CharTy = Result.Designator.getType(Info.Ctx);
     bool IsRawByte = BuiltinOp == Builtin::BImemchr ||
                      BuiltinOp == Builtin::BI__builtin_memchr;
-    assert(IsRawByte || Info.Ctx.hasSameUnqualifiedType(
-                            CharTy, E->getArg(0)->getType()->getPointeeType()));
+    assert(IsRawByte ||
+           Info.Ctx.hasSameUnqualifiedType(
+               CharTy, E->getArg(0)->getType()->getPointeeType()));
     // Pointers to const void may point to objects of incomplete type.
     if (IsRawByte && CharTy->isIncompleteType()) {
       Info.FFDiag(E, diag::note_constexpr_ltor_incomplete_type) << CharTy;
@@ -10614,7 +10631,7 @@ bool PointerExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
       llvm::APInt::udivrem(OrigN, TSize, N, Remainder);
       if (Remainder) {
         Info.FFDiag(E, diag::note_constexpr_memcpy_unsupported)
-            << Move << WChar << 0 << T << toString(OrigN, 10, /*Signed*/ false)
+            << Move << WChar << 0 << T << toString(OrigN, 10, /*Signed*/false)
             << (unsigned)TSize;
         return false;
       }
@@ -10628,7 +10645,7 @@ bool PointerExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
     if (N.ugt(RemainingSrcSize) || N.ugt(RemainingDestSize)) {
       Info.FFDiag(E, diag::note_constexpr_memcpy_unsupported)
           << Move << WChar << (N.ugt(RemainingSrcSize) ? 1 : 2) << T
-          << toString(N, 10, /*Signed*/ false);
+          << toString(N, 10, /*Signed*/false);
       return false;
     }
     uint64_t NElems = N.getZExtValue();
@@ -10824,7 +10841,8 @@ bool PointerExprEvaluator::VisitCXXNewExpr(const CXXNewExpr *E) {
     AllocType = Info.Ctx.getConstantArrayType(AllocType, ArrayBound, nullptr,
                                               ArraySizeModifier::Normal, 0);
   } else {
-    assert(!AllocType->isArrayType() && "array allocation with non-array new");
+    assert(!AllocType->isArrayType() &&
+           "array allocation with non-array new");
   }
 
   APValue *Val;
@@ -10927,15 +10945,15 @@ bool PointerExprEvaluator::VisitCXXNewExpr(const CXXNewExpr *E) {
 //===----------------------------------------------------------------------===//
 
 namespace {
-class ReflectionEvaluator : public ExprEvaluatorBase<ReflectionEvaluator> {
+class ReflectionEvaluator
+  : public ExprEvaluatorBase<ReflectionEvaluator> {
 
   using BaseType = ExprEvaluatorBase<ReflectionEvaluator>;
 
   APValue &Result;
-
 public:
   ReflectionEvaluator(EvalInfo &E, APValue &Result)
-      : ExprEvaluatorBaseTy(E), Result(Result) {}
+    : ExprEvaluatorBaseTy(E), Result(Result) {}
 
   bool Success(const APValue &V, const Expr *E) {
     Result = V;
@@ -10947,14 +10965,14 @@ class ReflectionEvaluator : public ExprEvaluatorBase<ReflectionEvaluator> {
 
 bool ReflectionEvaluator::VisitCXXReflectExpr(const CXXReflectExpr *E) {
   switch (E->getKind()) {
-  case ReflectionKind::Type: {
-    APValue Result(ReflectionKind::Type, E->getOpaqueValue());
-    return Success(Result, E);
-  }
+    case ReflectionKind::Type: {
+      APValue Result(ReflectionKind::Type, E->getOpaqueValue());
+      return Success(Result, E);
+    }
   }
   llvm_unreachable("invalid reflection");
 }
-} // end anonymous namespace
+}  // end anonymous namespace
 
 static bool EvaluateReflection(const Expr *E, APValue &Result, EvalInfo &Info) {
   assert(E->isPRValue() && E->getType()->isMetaInfoType());
@@ -10967,24 +10985,24 @@ static bool EvaluateReflection(const Expr *E, APValue &Result, EvalInfo &Info) {
 
 namespace {
 class MemberPointerExprEvaluator
-    : public ExprEvaluatorBase<MemberPointerExprEvaluator> {
+  : public ExprEvaluatorBase<MemberPointerExprEvaluator> {
   MemberPtr &Result;
 
   bool Success(const ValueDecl *D) {
     Result = MemberPtr(D);
     return true;
   }
-
 public:
+
   MemberPointerExprEvaluator(EvalInfo &Info, MemberPtr &Result)
-      : ExprEvaluatorBaseTy(Info), Result(Result) {}
+    : ExprEvaluatorBaseTy(Info), Result(Result) {}
 
   bool Success(const APValue &V, const Expr *E) {
     Result.setFrom(V);
     return true;
   }
   bool ZeroInitialization(const Expr *E) {
-    return Success((const ValueDecl *)nullptr);
+    return Success((const ValueDecl*)nullptr);
   }
 
   bool VisitCastExpr(const CastExpr *E);
@@ -11035,8 +11053,7 @@ bool MemberPointerExprEvaluator::VisitCastExpr(const CastExpr *E) {
     if (!Visit(E->getSubExpr()))
       return false;
     for (CastExpr::path_const_iterator PathI = E->path_begin(),
-                                       PathE = E->path_end();
-         PathI != PathE; ++PathI) {
+         PathE = E->path_end(); PathI != PathE; ++PathI) {
       assert(!(*PathI)->isVirtual() && "memptr cast through vbase");
       const CXXRecordDecl *Base = (*PathI)->getType()->getAsCXXRecordDecl();
       if (!Result.castToBase(Base))
@@ -11057,41 +11074,42 @@ bool MemberPointerExprEvaluator::VisitUnaryAddrOf(const UnaryOperator *E) {
 //===----------------------------------------------------------------------===//
 
 namespace {
-class RecordExprEvaluator : public ExprEvaluatorBase<RecordExprEvaluator> {
-  const LValue &This;
-  APValue &Result;
+  class RecordExprEvaluator
+  : public ExprEvaluatorBase<RecordExprEvaluator> {
+    const LValue &This;
+    APValue &Result;
+  public:
 
-public:
-  RecordExprEvaluator(EvalInfo &info, const LValue &This, APValue &Result)
+    RecordExprEvaluator(EvalInfo &info, const LValue &This, APValue &Result)
       : ExprEvaluatorBaseTy(info), This(This), Result(Result) {}
 
-  bool Success(const APValue &V, const Expr *E) {
-    Result = V;
-    return true;
-  }
-  bool ZeroInitialization(const Expr *E) {
-    return ZeroInitialization(E, E->getType());
-  }
-  bool ZeroInitialization(const Expr *E, QualType T);
+    bool Success(const APValue &V, const Expr *E) {
+      Result = V;
+      return true;
+    }
+    bool ZeroInitialization(const Expr *E) {
+      return ZeroInitialization(E, E->getType());
+    }
+    bool ZeroInitialization(const Expr *E, QualType T);
 
-  bool VisitCallExpr(const CallExpr *E) {
-    return handleCallExpr(E, Result, &This);
-  }
-  bool VisitCastExpr(const CastExpr *E);
-  bool VisitInitListExpr(const InitListExpr *E);
-  bool VisitCXXConstructExpr(const CXXConstructExpr *E) {
-    return VisitCXXConstructExpr(E, E->getType());
-  }
-  bool VisitLambdaExpr(const LambdaExpr *E);
-  bool VisitCXXInheritedCtorInitExpr(const CXXInheritedCtorInitExpr *E);
-  bool VisitCXXConstructExpr(const CXXConstructExpr *E, QualType T);
-  bool VisitCXXStdInitializerListExpr(const CXXStdInitializerListExpr *E);
-  bool VisitBinCmp(const BinaryOperator *E);
-  bool VisitCXXParenListInitExpr(const CXXParenListInitExpr *E);
-  bool VisitCXXParenListOrInitListExpr(const Expr *ExprToVisit,
-                                       ArrayRef<Expr *> Args);
-};
-} // namespace
+    bool VisitCallExpr(const CallExpr *E) {
+      return handleCallExpr(E, Result, &This);
+    }
+    bool VisitCastExpr(const CastExpr *E);
+    bool VisitInitListExpr(const InitListExpr *E);
+    bool VisitCXXConstructExpr(const CXXConstructExpr *E) {
+      return VisitCXXConstructExpr(E, E->getType());
+    }
+    bool VisitLambdaExpr(const LambdaExpr *E);
+    bool VisitCXXInheritedCtorInitExpr(const CXXInheritedCtorInitExpr *E);
+    bool VisitCXXConstructExpr(const CXXConstructExpr *E, QualType T);
+    bool VisitCXXStdInitializerListExpr(const CXXStdInitializerListExpr *E);
+    bool VisitBinCmp(const BinaryOperator *E);
+    bool VisitCXXParenListInitExpr(const CXXParenListInitExpr *E);
+    bool VisitCXXParenListOrInitListExpr(const Expr *ExprToVisit,
+                                         ArrayRef<Expr *> Args);
+  };
+}
 
 /// Perform zero-initialization on an object of non-union class type.
 /// C++11 [dcl.init]p5:
@@ -11108,15 +11126,13 @@ static bool HandleClassZeroInitialization(EvalInfo &Info, const Expr *E,
   Result = APValue(APValue::UninitStruct(), CD ? CD->getNumBases() : 0,
                    RD->getNumFields());
 
-  if (RD->isInvalidDecl())
-    return false;
+  if (RD->isInvalidDecl()) return false;
   const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(RD);
 
   if (CD) {
     unsigned Index = 0;
     for (CXXRecordDecl::base_class_const_iterator I = CD->bases_begin(),
-                                                  End = CD->bases_end();
-         I != End; ++I, ++Index) {
+           End = CD->bases_end(); I != End; ++I, ++Index) {
       const CXXRecordDecl *Base = I->getType()->getAsCXXRecordDecl();
       LValue Subobject = This;
       if (!HandleLValueDirectBase(Info, E, Subobject, CD, Base, &Layout))
@@ -11137,8 +11153,8 @@ static bool HandleClassZeroInitialization(EvalInfo &Info, const Expr *E,
       return false;
 
     ImplicitValueInitExpr VIE(I->getType());
-    if (!EvaluateInPlace(Result.getStructField(I->getFieldIndex()), Info,
-                         Subobject, &VIE))
+    if (!EvaluateInPlace(
+          Result.getStructField(I->getFieldIndex()), Info, Subobject, &VIE))
       return false;
   }
 
@@ -11147,8 +11163,7 @@ static bool HandleClassZeroInitialization(EvalInfo &Info, const Expr *E,
 
 bool RecordExprEvaluator::ZeroInitialization(const Expr *E, QualType T) {
   const auto *RD = T->castAsRecordDecl();
-  if (RD->isInvalidDecl())
-    return false;
+  if (RD->isInvalidDecl()) return false;
   if (RD->isUnion()) {
     // C++11 [dcl.init]p5: If T is a (possibly cv-qualified) union type, the
     // object's first non-static named data member is zero-initialized
@@ -11156,7 +11171,7 @@ bool RecordExprEvaluator::ZeroInitialization(const Expr *E, QualType T) {
     while (I != RD->field_end() && (*I)->isUnnamedBitField())
       ++I;
     if (I == RD->field_end()) {
-      Result = APValue((const FieldDecl *)nullptr);
+      Result = APValue((const FieldDecl*)nullptr);
       return true;
     }
 
@@ -11196,8 +11211,7 @@ bool RecordExprEvaluator::VisitCastExpr(const CastExpr *E) {
     APValue *Value = &DerivedObject;
     const CXXRecordDecl *RD = E->getSubExpr()->getType()->getAsCXXRecordDecl();
     for (CastExpr::path_const_iterator PathI = E->path_begin(),
-                                       PathE = E->path_end();
-         PathI != PathE; ++PathI) {
+         PathE = E->path_end(); PathI != PathE; ++PathI) {
       assert(!(*PathI)->isVirtual() && "record rvalue with virtual base");
       const CXXRecordDecl *Base = (*PathI)->getType()->getAsCXXRecordDecl();
       Value = &Value->getStructBase(getBaseIndex(RD, Base));
@@ -11254,8 +11268,7 @@ bool RecordExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
 bool RecordExprEvaluator::VisitCXXParenListOrInitListExpr(
     const Expr *ExprToVisit, ArrayRef<Expr *> Args) {
   const auto *RD = ExprToVisit->getType()->castAsRecordDecl();
-  if (RD->isInvalidDecl())
-    return false;
+  if (RD->isInvalidDecl()) return false;
   const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(RD);
   auto *CXXRD = dyn_cast<CXXRecordDecl>(RD);
 
@@ -11398,8 +11411,7 @@ bool RecordExprEvaluator::VisitCXXConstructExpr(const CXXConstructExpr *E,
   // Note that E's type is not necessarily the type of our class here; we might
   // be initializing an array element instead.
   const CXXConstructorDecl *FD = E->getConstructor();
-  if (FD->isInvalidDecl() || FD->getParent()->isInvalidDecl())
-    return false;
+  if (FD->isInvalidDecl() || FD->getParent()->isInvalidDecl()) return false;
 
   bool ZeroInit = E->requiresZeroInitialization();
   if (CheckTrivialDefaultConstructor(Info, E->getExprLoc(), FD, ZeroInit)) {
@@ -11434,8 +11446,9 @@ bool RecordExprEvaluator::VisitCXXConstructExpr(const CXXConstructExpr *E,
     return false;
 
   auto Args = ArrayRef(E->getArgs(), E->getNumArgs());
-  return HandleConstructorCall(
-      E, This, Args, cast<CXXConstructorDecl>(Definition), Info, Result);
+  return HandleConstructorCall(E, This, Args,
+                               cast<CXXConstructorDecl>(Definition), Info,
+                               Result);
 }
 
 bool RecordExprEvaluator::VisitCXXInheritedCtorInitExpr(
@@ -11521,7 +11534,7 @@ bool RecordExprEvaluator::VisitLambdaExpr(const LambdaExpr *E) {
          "The number of lambda capture initializers should equal the number of "
          "fields within the closure type");
 
-  Result = APValue(APValue::UninitStruct(), /*NumBases*/ 0, NumFields);
+  Result = APValue(APValue::UninitStruct(), /*NumBases*/0, NumFields);
   // Iterate through all the lambda's closure object's fields and initialize
   // them.
   auto *CaptureInitIt = E->capture_init_begin();
@@ -11552,8 +11565,8 @@ bool RecordExprEvaluator::VisitLambdaExpr(const LambdaExpr *E) {
   return Success;
 }
 
-static bool EvaluateRecord(const Expr *E, const LValue &This, APValue &Result,
-                           EvalInfo &Info) {
+static bool EvaluateRecord(const Expr *E, const LValue &This,
+                           APValue &Result, EvalInfo &Info) {
   assert(!E->isValueDependent());
   assert(E->isPRValue() && E->getType()->isRecordType() &&
          "can't evaluate expression as a record rvalue");
@@ -11569,10 +11582,10 @@ static bool EvaluateRecord(const Expr *E, const LValue &This, APValue &Result,
 //===----------------------------------------------------------------------===//
 namespace {
 class TemporaryExprEvaluator
-    : public LValueExprEvaluatorBase<TemporaryExprEvaluator> {
+  : public LValueExprEvaluatorBase<TemporaryExprEvaluator> {
 public:
-  TemporaryExprEvaluator(EvalInfo &Info, LValue &Result)
-      : LValueExprEvaluatorBaseTy(Info, Result, false) {}
+  TemporaryExprEvaluator(EvalInfo &Info, LValue &Result) :
+    LValueExprEvaluatorBaseTy(Info, Result, false) {}
 
   /// Visit an expression which constructs the value of this temporary.
   bool VisitConstructExpr(const Expr *E) {
@@ -11596,11 +11609,15 @@ class TemporaryExprEvaluator
   bool VisitCXXConstructExpr(const CXXConstructExpr *E) {
     return VisitConstructExpr(E);
   }
-  bool VisitCallExpr(const CallExpr *E) { return VisitConstructExpr(E); }
+  bool VisitCallExpr(const CallExpr *E) {
+    return VisitConstructExpr(E);
+  }
   bool VisitCXXStdInitializerListExpr(const CXXStdInitializerListExpr *E) {
     return VisitConstructExpr(E);
   }
-  bool VisitLambdaExpr(const LambdaExpr *E) { return VisitConstructExpr(E); }
+  bool VisitLambdaExpr(const LambdaExpr *E) {
+    return VisitConstructExpr(E);
+  }
 };
 } // end anonymous namespace
 
@@ -11616,42 +11633,44 @@ static bool EvaluateTemporary(const Expr *E, LValue &Result, EvalInfo &Info) {
 //===----------------------------------------------------------------------===//
 
 namespace {
-class VectorExprEvaluator : public ExprEvaluatorBase<VectorExprEvaluator> {
-  APValue &Result;
+  class VectorExprEvaluator
+  : public ExprEvaluatorBase<VectorExprEvaluator> {
+    APValue &Result;
+  public:
 
-public:
-  VectorExprEvaluator(EvalInfo &info, APValue &Result)
+    VectorExprEvaluator(EvalInfo &info, APValue &Result)
       : ExprEvaluatorBaseTy(info), Result(Result) {}
 
-  bool Success(ArrayRef<APValue> V, const Expr *E) {
-    assert(V.size() == E->getType()->castAs<VectorType>()->getNumElements());
-    // FIXME: remove this APValue copy.
-    Result = APValue(V.data(), V.size());
-    return true;
-  }
-  bool Success(const APValue &V, const Expr *E) {
-    assert(V.isVector());
-    Result = V;
-    return true;
-  }
-  bool ZeroInitialization(const Expr *E);
-
-  bool VisitUnaryReal(const UnaryOperator *E) { return Visit(E->getSubExpr()); }
-  bool VisitCastExpr(const CastExpr *E);
-  bool VisitInitListExpr(const InitListExpr *E);
-  bool VisitUnaryImag(const UnaryOperator *E);
-  bool VisitBinaryOperator(const BinaryOperator *E);
-  bool VisitUnaryOperator(const UnaryOperator *E);
-  bool VisitCallExpr(const CallExpr *E);
-  bool VisitConvertVectorExpr(const ConvertVectorExpr *E);
-  bool VisitShuffleVectorExpr(const ShuffleVectorExpr *E);
-
-  // FIXME: Missing: conditional operator (for GNU
-  //                 conditional select), ExtVectorElementExpr
-};
+    bool Success(ArrayRef<APValue> V, const Expr *E) {
+      assert(V.size() == E->getType()->castAs<VectorType>()->getNumElements());
+      // FIXME: remove this APValue copy.
+      Result = APValue(V.data(), V.size());
+      return true;
+    }
+    bool Success(const APValue &V, const Expr *E) {
+      assert(V.isVector());
+      Result = V;
+      return true;
+    }
+    bool ZeroInitialization(const Expr *E);
+
+    bool VisitUnaryReal(const UnaryOperator *E)
+      { return Visit(E->getSubExpr()); }
+    bool VisitCastExpr(const CastExpr* E);
+    bool VisitInitListExpr(const InitListExpr *E);
+    bool VisitUnaryImag(const UnaryOperator *E);
+    bool VisitBinaryOperator(const BinaryOperator *E);
+    bool VisitUnaryOperator(const UnaryOperator *E);
+    bool VisitCallExpr(const CallExpr *E);
+    bool VisitConvertVectorExpr(const ConvertVectorExpr *E);
+    bool VisitShuffleVectorExpr(const ShuffleVectorExpr *E);
+
+    // FIXME: Missing: conditional operator (for GNU
+    //                 conditional select), ExtVectorElementExpr
+  };
 } // end anonymous namespace
 
-static bool EvaluateVector(const Expr *E, APValue &Result, EvalInfo &Info) {
+static bool EvaluateVector(const Expr* E, APValue& Result, EvalInfo &Info) {
   assert(E->isPRValue() && E->getType()->isVectorType() &&
          "not a vector prvalue");
   return VectorExprEvaluator(Info, Result).Visit(E);
@@ -11781,7 +11800,8 @@ bool VectorExprEvaluator::VisitCastExpr(const CastExpr *E) {
   }
 }
 
-bool VectorExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
+bool
+VectorExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
   const VectorType *VT = E->getType()->castAs<VectorType>();
   unsigned NumInits = E->getNumInits();
   unsigned NumElements = VT->getNumElements();
@@ -11801,8 +11821,8 @@ bool VectorExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
   unsigned CountInits = 0, CountElts = 0;
   while (CountElts < NumElements) {
     // Handle nested vector initialization.
-    if (CountInits < NumInits &&
-        E->getInit(CountInits)->getType()->isVectorType()) {
+    if (CountInits < NumInits
+        && E->getInit(CountInits)->getType()->isVectorType()) {
       APValue v;
       if (!EvaluateVector(E->getInit(CountInits), v, Info))
         return Error(E);
@@ -11834,7 +11854,8 @@ bool VectorExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
   return Success(Elements, E);
 }
 
-bool VectorExprEvaluator::ZeroInitialization(const Expr *E) {
+bool
+VectorExprEvaluator::ZeroInitialization(const Expr *E) {
   const auto *VT = E->getType()->castAs<VectorType>();
   QualType EltTy = VT->getElementType();
   APValue ZeroElement;
@@ -14861,71 +14882,73 @@ bool MatrixExprEvaluator::VisitInitListExpr(const InitListExpr *E) {
 //===----------------------------------------------------------------------===//
 
 namespace {
-class ArrayExprEvaluator : public ExprEvaluatorBase<ArrayExprEvaluator> {
-  const LValue &This;
-  APValue &Result;
+  class ArrayExprEvaluator
+  : public ExprEvaluatorBase<ArrayExprEvaluator> {
+    const LValue &This;
+    APValue &Result;
+  public:
 
-public:
-  ArrayExprEvaluator(EvalInfo &Info, const LValue &This, APValue &Result)
+    ArrayExprEvaluator(EvalInfo &Info, const LValue &This, APValue &Result)
       : ExprEvaluatorBaseTy(Info), This(This), Result(Result) {}
 
-  bool Success(const APValue &V, const Expr *E) {
-    assert(V.isArray() && "expected array");
-    Result = V;
-    return true;
-  }
-
-  bool ZeroInitialization(const Expr *E) {
-    const ConstantArrayType *CAT =
-        Info.Ctx.getAsConstantArrayType(E->getType());
-    if (!CAT) {
-      if (E->getType()->isIncompleteArrayType()) {
-        // We can be asked to zero-initialize a flexible array member; this
-        // is represented as an ImplicitValueInitExpr of incomplete array
-        // type. In this case, the array has zero elements.
-        Result = APValue(APValue::UninitArray(), 0, 0);
-        return true;
-      }
-      // FIXME: We could handle VLAs here.
-      return Error(E);
+    bool Success(const APValue &V, const Expr *E) {
+      assert(V.isArray() && "expected array");
+      Result = V;
+      return true;
     }
 
-    Result = APValue(APValue::UninitArray(), 0, CAT->getZExtSize());
-    if (!Result.hasArrayFiller())
-      return true;
+    bool ZeroInitialization(const Expr *E) {
+      const ConstantArrayType *CAT =
+          Info.Ctx.getAsConstantArrayType(E->getType());
+      if (!CAT) {
+        if (E->getType()->isIncompleteArrayType()) {
+          // We can be asked to zero-initialize a flexible array member; this
+          // is represented as an ImplicitValueInitExpr of incomplete array
+          // type. In this case, the array has zero elements.
+          Result = APValue(APValue::UninitArray(), 0, 0);
+          return true;
+        }
+        // FIXME: We could handle VLAs here.
+        return Error(E);
+      }
 
-    // Zero-initialize all elements.
-    LValue Subobject = This;
-    Subobject.addArray(Info, E, CAT);
-    ImplicitValueInitExpr VIE(CAT->getElementType());
-    return EvaluateInPlace(Result.getArrayFiller(), Info, Subobject, &VIE);
-  }
+      Result = APValue(APValue::UninitArray(), 0, CAT->getZExtSize());
+      if (!Result.hasArrayFiller())
+        return true;
 
-  bool VisitCallExpr(const CallExpr *E) {
-    return handleCallExpr(E, Result, &This);
-  }
-  bool VisitCastExpr(const CastExpr *E);
-  bool VisitInitListExpr(const InitListExpr *E,
-                         QualType AllocType = QualType());
-  bool VisitArrayInitLoopExpr(const ArrayInitLoopExpr *E);
-  bool VisitCXXConstructExpr(const CXXConstructExpr *E);
-  bool VisitCXXConstructExpr(const CXXConstructExpr *E, const LValue &Subobject,
-                             APValue *Value, QualType Type);
-  bool VisitStringLiteral(const StringLiteral *E,
-                          QualType AllocType = QualType()) {
-    expandStringLiteral(Info, E, Result, AllocType);
-    return true;
-  }
-  bool VisitCXXParenListInitExpr(const CXXParenListInitExpr *E);
-  bool VisitCXXParenListOrInitListExpr(const Expr *ExprToVisit,
-                                       ArrayRef<Expr *> Args,
-                                       const Expr *ArrayFiller,
-                                       QualType AllocType = QualType());
-};
+      // Zero-initialize all elements.
+      LValue Subobject = This;
+      Subobject.addArray(Info, E, CAT);
+      ImplicitValueInitExpr VIE(CAT->getElementType());
+      return EvaluateInPlace(Result.getArrayFiller(), Info, Subobject, &VIE);
+    }
+
+    bool VisitCallExpr(const CallExpr *E) {
+      return handleCallExpr(E, Result, &This);
+    }
+    bool VisitCastExpr(const CastExpr *E);
+    bool VisitInitListExpr(const InitListExpr *E,
+                           QualType AllocType = QualType());
+    bool VisitArrayInitLoopExpr(const ArrayInitLoopExpr *E);
+    bool VisitCXXConstructExpr(const CXXConstructExpr *E);
+    bool VisitCXXConstructExpr(const CXXConstructExpr *E,
+                               const LValue &Subobject,
+                               APValue *Value, QualType Type);
+    bool VisitStringLiteral(const StringLiteral *E,
+                            QualType AllocType = QualType()) {
+      expandStringLiteral(Info, E, Result, AllocType);
+      return true;
+    }
+    bool VisitCXXParenListInitExpr(const CXXParenListInitExpr *E);
+    bool VisitCXXParenListOrInitListExpr(const Expr *ExprToVisit,
+                                         ArrayRef<Expr *> Args,
+                                         const Expr *ArrayFiller,
+                                         QualType AllocType = QualType());
+  };
 } // end anonymous namespace
 
-static bool EvaluateArray(const Expr *E, const LValue &This, APValue &Result,
-                          EvalInfo &Info) {
+static bool EvaluateArray(const Expr *E, const LValue &This,
+                          APValue &Result, EvalInfo &Info) {
   assert(!E->isValueDependent());
   assert(E->isPRValue() && E->getType()->isArrayType() &&
          "not an array prvalue");
@@ -15179,10 +15202,10 @@ bool ArrayExprEvaluator::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *E) {
     // array element, if any.
     FullExpressionRAII Scope(Info);
 
-    if (!EvaluateInPlace(Result.getArrayInitializedElt(Index), Info, Subobject,
-                         E->getSubExpr()) ||
-        !HandleLValueArrayAdjustment(Info, E, Subobject, CAT->getElementType(),
-                                     1)) {
+    if (!EvaluateInPlace(Result.getArrayInitializedElt(Index),
+                         Info, Subobject, E->getSubExpr()) ||
+        !HandleLValueArrayAdjustment(Info, E, Subobject,
+                                     CAT->getElementType(), 1)) {
       if (!Info.noteFailure())
         return false;
       Success = false;
@@ -15201,16 +15224,17 @@ bool ArrayExprEvaluator::VisitCXXConstructExpr(const CXXConstructExpr *E) {
 
 bool ArrayExprEvaluator::VisitCXXConstructExpr(const CXXConstructExpr *E,
                                                const LValue &Subobject,
-                                               APValue *Value, QualType Type) {
+                                               APValue *Value,
+                                               QualType Type) {
   bool HadZeroInit = Value->hasValue();
 
   if (const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(Type)) {
     unsigned FinalSize = CAT->getZExtSize();
 
     // Preserve the array filler if we had prior zero-initialization.
-    APValue Filler = HadZeroInit && Value->hasArrayFiller()
-                         ? Value->getArrayFiller()
-                         : APValue();
+    APValue Filler =
+      HadZeroInit && Value->hasArrayFiller() ? Value->getArrayFiller()
+                                             : APValue();
 
     *Value = APValue(APValue::UninitArray(), 0, FinalSize);
     if (FinalSize == 0)
@@ -15272,7 +15296,7 @@ bool ArrayExprEvaluator::VisitCXXConstructExpr(const CXXConstructExpr *E,
     return Error(E);
 
   return RecordExprEvaluator(Info, Subobject, *Value)
-      .VisitCXXConstructExpr(E, Type);
+             .VisitCXXConstructExpr(E, Type);
 }
 
 bool ArrayExprEvaluator::VisitCXXParenListInitExpr(
@@ -15293,9 +15317,9 @@ bool ArrayExprEvaluator::VisitCXXParenListInitExpr(
 //===----------------------------------------------------------------------===//
 
 namespace {
-class IntExprEvaluator : public ExprEvaluatorBase<IntExprEvaluator> {
+class IntExprEvaluator
+        : public ExprEvaluatorBase<IntExprEvaluator> {
   APValue &Result;
-
 public:
   IntExprEvaluator(EvalInfo &info, APValue &result)
       : ExprEvaluatorBaseTy(info), Result(result) {}
@@ -15321,7 +15345,7 @@ class IntExprEvaluator : public ExprEvaluatorBase<IntExprEvaluator> {
            "Invalid evaluation result.");
     Result = APValue(APSInt(I));
     Result.getInt().setIsUnsigned(
-        E->getType()->isUnsignedIntegerOrEnumerationType());
+                            E->getType()->isUnsignedIntegerOrEnumerationType());
     return true;
   }
   bool Success(const llvm::APInt &I, const Expr *E) {
@@ -15391,7 +15415,7 @@ class IntExprEvaluator : public ExprEvaluatorBase<IntExprEvaluator> {
   bool VisitOffsetOfExpr(const OffsetOfExpr *E);
   bool VisitUnaryOperator(const UnaryOperator *E);
 
-  bool VisitCastExpr(const CastExpr *E);
+  bool VisitCastExpr(const CastExpr* E);
   bool VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *E);
 
   bool VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *E) {
@@ -15413,7 +15437,9 @@ class IntExprEvaluator : public ExprEvaluatorBase<IntExprEvaluator> {
   }
 
   // Note, GNU defines __null as an integer, not a pointer.
-  bool VisitGNUNullExpr(const GNUNullExpr *E) { return ZeroInitialization(E); }
+  bool VisitGNUNullExpr(const GNUNullExpr *E) {
+    return ZeroInitialization(E);
+  }
 
   bool VisitTypeTraitExpr(const TypeTraitExpr *E) {
     if (E->isStoredAsBoolean())
@@ -15454,7 +15480,7 @@ class FixedPointExprEvaluator
     : public ExprEvaluatorBase<FixedPointExprEvaluator> {
   APValue &Result;
 
-public:
+ public:
   FixedPointExprEvaluator(EvalInfo &info, APValue &result)
       : ExprEvaluatorBaseTy(info), Result(result) {}
 
@@ -15480,7 +15506,9 @@ class FixedPointExprEvaluator
     return true;
   }
 
-  bool ZeroInitialization(const Expr *E) { return Success(0, E); }
+  bool ZeroInitialization(const Expr *E) {
+    return Success(0, E);
+  }
 
   //===--------------------------------------------------------------------===//
   //                            Visitor Methods
@@ -15567,14 +15595,14 @@ static bool EvaluateFixedPointOrInteger(const Expr *E, APFixedPoint &Result,
 /// Check whether the given declaration can be directly converted to an integral
 /// rvalue. If not, no diagnostic is produced; there are other things we can
 /// try.
-bool IntExprEvaluator::CheckReferencedDecl(const Expr *E, const Decl *D) {
+bool IntExprEvaluator::CheckReferencedDecl(const Expr* E, const Decl* D) {
   // Enums are integer constant exprs.
   if (const EnumConstantDecl *ECD = dyn_cast<EnumConstantDecl>(D)) {
     // Check for signedness/width mismatches between E type and ECD value.
-    bool SameSign = (ECD->getInitVal().isSigned() ==
-                     E->getType()->isSignedIntegerOrEnumerationType());
-    bool SameWidth =
-        (ECD->getInitVal().getBitWidth() == Info.Ctx.getIntWidth(E->getType()));
+    bool SameSign = (ECD->getInitVal().isSigned()
+                     == E->getType()->isSignedIntegerOrEnumerationType());
+    bool SameWidth = (ECD->getInitVal().getBitWidth()
+                      == Info.Ctx.getIntWidth(E->getType()));
     if (SameSign && SameWidth)
       return Success(ECD->getInitVal(), E);
     else {
@@ -15607,20 +15635,17 @@ GCCTypeClass EvaluateBuiltinClassifyType(QualType T,
 #include "clang/AST/TypeNodes.inc"
   case Type::Auto:
   case Type::DeducedTemplateSpecialization:
-    llvm_unreachable("unexpected non-canonical or dependent type");
+      llvm_unreachable("unexpected non-canonical or dependent type");
 
   case Type::Builtin:
-    switch (cast<BuiltinType>(CanTy)->getKind()) {
+      switch (cast<BuiltinType>(CanTy)->getKind()) {
 #define BUILTIN_TYPE(ID, SINGLETON_ID)
-#define SIGNED_TYPE(ID, SINGLETON_ID)                                          \
-  case BuiltinType::ID:                                                        \
-    return GCCTypeClass::Integer;
-#define FLOATING_TYPE(ID, SINGLETON_ID)                                        \
-  case BuiltinType::ID:                                                        \
-    return GCCTypeClass::RealFloat;
-#define PLACEHOLDER_TYPE(ID, SINGLETON_ID)                                     \
-  case BuiltinType::ID:                                                        \
-    break;
+#define SIGNED_TYPE(ID, SINGLETON_ID) \
+    case BuiltinType::ID: return GCCTypeClass::Integer;
+#define FLOATING_TYPE(ID, SINGLETON_ID) \
+    case BuiltinType::ID: return GCCTypeClass::RealFloat;
+#define PLACEHOLDER_TYPE(ID, SINGLETON_ID) \
+    case BuiltinType::ID: break;
 #include "clang/AST/BuiltinTypes.def"
     case BuiltinType::Void:
       return GCCTypeClass::Void;
@@ -15660,19 +15685,22 @@ GCCTypeClass EvaluateBuiltinClassifyType(QualType T,
     case BuiltinType::ObjCId:
     case BuiltinType::ObjCClass:
     case BuiltinType::ObjCSel:
-#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)                   \
-  case BuiltinType::Id:
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
+    case BuiltinType::Id:
 #include "clang/Basic/OpenCLImageTypes.def"
-#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) case BuiltinType::Id:
+#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
+    case BuiltinType::Id:
 #include "clang/Basic/OpenCLExtensionTypes.def"
     case BuiltinType::OCLSampler:
     case BuiltinType::OCLEvent:
     case BuiltinType::OCLClkEvent:
     case BuiltinType::OCLQueue:
     case BuiltinType::OCLReserveID:
-#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
+#define SVE_TYPE(Name, Id, SingletonId) \
+    case BuiltinType::Id:
 #include "clang/Basic/AArch64ACLETypes.def"
-#define PPC_VECTOR_TYPE(Name, Id, Size) case BuiltinType::Id:
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
+    case BuiltinType::Id:
 #include "clang/Basic/PPCTypes.def"
 #define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
 #include "clang/Basic/RISCVVTypes.def"
@@ -15748,8 +15776,8 @@ GCCTypeClass EvaluateBuiltinClassifyType(QualType T,
 
 /// EvaluateBuiltinClassifyType - Evaluate __builtin_classify_type the same way
 /// as GCC.
-static GCCTypeClass EvaluateBuiltinClassifyType(const CallExpr *E,
-                                                const LangOptions &LangOpts) {
+static GCCTypeClass
+EvaluateBuiltinClassifyType(const CallExpr *E, const LangOptions &LangOpts) {
   // If no argument was supplied, default to None. This isn't
   // ideal, however it is what gcc does.
   if (E->getNumArgs() == 0)
@@ -15837,10 +15865,10 @@ static bool EvaluateBuiltinConstantP(EvalInfo &Info, const Expr *Arg) {
 /// Retrieves the "underlying object type" of the given expression,
 /// as used by __builtin_object_size.
 static QualType getObjectType(APValue::LValueBase B) {
-  if (const ValueDecl *D = B.dyn_cast<const ValueDecl *>()) {
+  if (const ValueDecl *D = B.dyn_cast<const ValueDecl*>()) {
     if (const VarDecl *VD = dyn_cast<VarDecl>(D))
       return VD->getType();
-  } else if (const Expr *E = B.dyn_cast<const Expr *>()) {
+  } else if (const Expr *E = B.dyn_cast<const Expr*>()) {
     if (isa<CompoundLiteralExpr>(E))
       return E->getType();
   } else if (B.is<TypeInfoLValue>()) {
@@ -16635,18 +16663,10 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
       return false;
     unsigned Arg;
     switch (Val.getCategory()) {
-    case APFloat::fcNaN:
-      Arg = 0;
-      break;
-    case APFloat::fcInfinity:
-      Arg = 1;
-      break;
-    case APFloat::fcNormal:
-      Arg = Val.isDenormal() ? 3 : 2;
-      break;
-    case APFloat::fcZero:
-      Arg = 4;
-      break;
+    case APFloat::fcNaN: Arg = 0; break;
+    case APFloat::fcInfinity: Arg = 1; break;
+    case APFloat::fcNormal: Arg = Val.isDenormal() ? 3 : 2; break;
+    case APFloat::fcZero: Arg = 4; break;
     }
     return Visit(E->getArg(Arg));
   }
@@ -16952,7 +16972,8 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
       return false;
 
     uint64_t MaxLength = uint64_t(-1);
-    if (BuiltinOp != Builtin::BIstrcmp && BuiltinOp != Builtin::BIwcscmp &&
+    if (BuiltinOp != Builtin::BIstrcmp &&
+        BuiltinOp != Builtin::BIwcscmp &&
         BuiltinOp != Builtin::BI__builtin_strcmp &&
         BuiltinOp != Builtin::BI__builtin_wcscmp) {
       APSInt N;
@@ -17094,8 +17115,8 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
       }
     }
 
-    return BuiltinOp == Builtin::BI__atomic_always_lock_free ? Success(0, E)
-                                                             : Error(E);
+    return BuiltinOp == Builtin::BI__atomic_always_lock_free ?
+        Success(0, E) : Error(E);
   }
   case Builtin::BI__builtin_addcb:
   case Builtin::BI__builtin_addcs:
@@ -17190,7 +17211,7 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
       bool IsSigned = LHS.isSigned() || RHS.isSigned() ||
                       ResultType->isSignedIntegerOrEnumerationType();
       bool AllSigned = LHS.isSigned() && RHS.isSigned() &&
-                       ResultType->isSignedIntegerOrEnumerationType();
+                      ResultType->isSignedIntegerOrEnumerationType();
       uint64_t LHSSize = LHS.getBitWidth();
       uint64_t RHSSize = RHS.getBitWidth();
       uint64_t ResultSize = Info.Ctx.getTypeSize(ResultType);
@@ -17908,7 +17929,7 @@ class DataRecursiveIntBinOpEvaluator {
 
 public:
   DataRecursiveIntBinOpEvaluator(IntExprEvaluator &IntEval, APValue &Result)
-      : IntEval(IntEval), Info(IntEval.getEvalInfo()), FinalResult(Result) {}
+    : IntEval(IntEval), Info(IntEval.getEvalInfo()), FinalResult(Result) { }
 
   /// True if \param E is a binary operator that we are going to handle
   /// data recursively.
@@ -17927,8 +17948,7 @@ class DataRecursiveIntBinOpEvaluator {
     while (!Queue.empty())
       process(PrevResult);
 
-    if (PrevResult.Failed)
-      return false;
+    if (PrevResult.Failed) return false;
 
     FinalResult.swap(PrevResult.Val);
     return true;
@@ -17941,8 +17961,12 @@ class DataRecursiveIntBinOpEvaluator {
   bool Success(const APSInt &Value, const Expr *E, APValue &Result) {
     return IntEval.Success(Value, E, Result);
   }
-  bool Error(const Expr *E) { return IntEval.Error(E); }
-  bool Error(const Expr *E, diag::kind D) { return IntEval.Error(E, D); }
+  bool Error(const Expr *E) {
+    return IntEval.Error(E);
+  }
+  bool Error(const Expr *E, diag::kind D) {
+    return IntEval.Error(E, D);
+  }
 
   OptionalDiagnostic CCEDiag(const Expr *E, diag::kind D) {
     return Info.CCEDiag(E, D);
@@ -17965,17 +17989,17 @@ class DataRecursiveIntBinOpEvaluator {
 
   void enqueue(const Expr *E) {
     E = E->IgnoreParens();
-    Queue.resize(Queue.size() + 1);
+    Queue.resize(Queue.size()+1);
     Queue.back().E = E;
     Queue.back().Kind = Job::AnyExprKind;
   }
 };
 
-} // namespace
+}
 
-bool DataRecursiveIntBinOpEvaluator::VisitBinOpLHSOnly(EvalResult &LHSResult,
-                                                       const BinaryOperator *E,
-                                                       bool &SuppressRHSDiags) {
+bool DataRecursiveIntBinOpEvaluator::
+       VisitBinOpLHSOnly(EvalResult &LHSResult, const BinaryOperator *E,
+                         bool &SuppressRHSDiags) {
   if (E->getOpcode() == BO_Comma) {
     // Ignore LHS but note if we could not evaluate it.
     if (LHSResult.Failed)
@@ -18027,14 +18051,13 @@ static void addOrSubLValueAsInteger(APValue &LVal, const APSInt &Index,
   CharUnits &Offset = LVal.getLValueOffset();
   uint64_t Offset64 = Offset.getQuantity();
   uint64_t Index64 = Index.extOrTrunc(64).getZExtValue();
-  Offset =
-      CharUnits::fromQuantity(IsSub ? Offset64 - Index64 : Offset64 + Index64);
+  Offset = CharUnits::fromQuantity(IsSub ? Offset64 - Index64
+                                         : Offset64 + Index64);
 }
 
-bool DataRecursiveIntBinOpEvaluator::VisitBinOp(const EvalResult &LHSResult,
-                                                const EvalResult &RHSResult,
-                                                const BinaryOperator *E,
-                                                APValue &Result) {
+bool DataRecursiveIntBinOpEvaluator::
+       VisitBinOp(const EvalResult &LHSResult, const EvalResult &RHSResult,
+                  const BinaryOperator *E, APValue &Result) {
   if (E->getOpcode() == BO_Comma) {
     if (RHSResult.Failed)
       return false;
@@ -18083,9 +18106,10 @@ bool DataRecursiveIntBinOpEvaluator::VisitBinOp(const EvalResult &LHSResult,
   }
 
   // Handle cases like 4 + (unsigned long)&a
-  if (E->getOpcode() == BO_Add && RHSVal.isLValue() && LHSVal.isInt()) {
+  if (E->getOpcode() == BO_Add &&
+      RHSVal.isLValue() && LHSVal.isInt()) {
     Result = RHSVal;
-    addOrSubLValueAsInteger(Result, LHSVal.getInt(), /*IsSub*/ false);
+    addOrSubLValueAsInteger(Result, LHSVal.getInt(), /*IsSub*/false);
     return true;
   }
 
@@ -18094,8 +18118,8 @@ bool DataRecursiveIntBinOpEvaluator::VisitBinOp(const EvalResult &LHSResult,
     if (!LHSVal.getLValueOffset().isZero() ||
         !RHSVal.getLValueOffset().isZero())
       return false;
-    const Expr *LHSExpr = LHSVal.getLValueBase().dyn_cast<const Expr *>();
-    const Expr *RHSExpr = RHSVal.getLValueBase().dyn_cast<const Expr *>();
+    const Expr *LHSExpr = LHSVal.getLValueBase().dyn_cast<const Expr*>();
+    const Expr *RHSExpr = RHSVal.getLValueBase().dyn_cast<const Expr*>();
     if (!LHSExpr || !RHSExpr)
       return false;
     const AddrLabelExpr *LHSAddrExpr = dyn_cast<AddrLabelExpr>(LHSExpr);
@@ -18129,43 +18153,43 @@ void DataRecursiveIntBinOpEvaluator::process(EvalResult &Result) {
   Job &job = Queue.back();
 
   switch (job.Kind) {
-  case Job::AnyExprKind: {
-    if (const BinaryOperator *Bop = dyn_cast<BinaryOperator>(job.E)) {
-      if (shouldEnqueue(Bop)) {
-        job.Kind = Job::BinOpKind;
-        enqueue(Bop->getLHS());
-        return;
+    case Job::AnyExprKind: {
+      if (const BinaryOperator *Bop = dyn_cast<BinaryOperator>(job.E)) {
+        if (shouldEnqueue(Bop)) {
+          job.Kind = Job::BinOpKind;
+          enqueue(Bop->getLHS());
+          return;
+        }
       }
+
+      EvaluateExpr(job.E, Result);
+      Queue.pop_back();
+      return;
     }
 
-    EvaluateExpr(job.E, Result);
-    Queue.pop_back();
-    return;
-  }
+    case Job::BinOpKind: {
+      const BinaryOperator *Bop = cast<BinaryOperator>(job.E);
+      bool SuppressRHSDiags = false;
+      if (!VisitBinOpLHSOnly(Result, Bop, SuppressRHSDiags)) {
+        Queue.pop_back();
+        return;
+      }
+      if (SuppressRHSDiags)
+        job.startSpeculativeEval(Info);
+      job.LHSResult.swap(Result);
+      job.Kind = Job::BinOpVisitedLHSKind;
+      enqueue(Bop->getRHS());
+      return;
+    }
 
-  case Job::BinOpKind: {
-    const BinaryOperator *Bop = cast<BinaryOperator>(job.E);
-    bool SuppressRHSDiags = false;
-    if (!VisitBinOpLHSOnly(Result, Bop, SuppressRHSDiags)) {
+    case Job::BinOpVisitedLHSKind: {
+      const BinaryOperator *Bop = cast<BinaryOperator>(job.E);
+      EvalResult RHS;
+      RHS.swap(Result);
+      Result.Failed = !VisitBinOp(job.LHSResult, RHS, Bop, Result.Val);
       Queue.pop_back();
       return;
     }
-    if (SuppressRHSDiags)
-      job.startSpeculativeEval(Info);
-    job.LHSResult.swap(Result);
-    job.Kind = Job::BinOpVisitedLHSKind;
-    enqueue(Bop->getRHS());
-    return;
-  }
-
-  case Job::BinOpVisitedLHSKind: {
-    const BinaryOperator *Bop = cast<BinaryOperator>(job.E);
-    EvalResult RHS;
-    RHS.swap(Result);
-    Result.Failed = !VisitBinOp(job.LHSResult, RHS, Bop, Result.Val);
-    Queue.pop_back();
-    return;
-  }
   }
 
   llvm_unreachable("Invalid Job::Kind!");
@@ -18261,9 +18285,9 @@ EvaluateComparisonBinaryOperator(EvalInfo &Info, const BinaryOperator *E,
 
     if (LHS.isComplexFloat()) {
       APFloat::cmpResult CR_r =
-          LHS.getComplexFloatReal().compare(RHS.getComplexFloatReal());
+        LHS.getComplexFloatReal().compare(RHS.getComplexFloatReal());
       APFloat::cmpResult CR_i =
-          LHS.getComplexFloatImag().compare(RHS.getComplexFloatImag());
+        LHS.getComplexFloatImag().compare(RHS.getComplexFloatImag());
       bool IsEqual = CR_r == APFloat::cmpEqual && CR_i == APFloat::cmpEqual;
       return Success(IsEqual ? CmpResult::Equal : CmpResult::Unequal, E);
     } else {
@@ -18274,7 +18298,8 @@ EvaluateComparisonBinaryOperator(EvalInfo &Info, const BinaryOperator *E,
     }
   }
 
-  if (LHSTy->isRealFloatingType() && RHSTy->isRealFloatingType()) {
+  if (LHSTy->isRealFloatingType() &&
+      RHSTy->isRealFloatingType()) {
     APFloat RHS(0.0), LHS(0.0);
 
     bool LHSOK = EvaluateFloat(E->getRHS(), RHS, Info);
@@ -18286,7 +18311,8 @@ EvaluateComparisonBinaryOperator(EvalInfo &Info, const BinaryOperator *E,
 
     assert(E->isComparisonOp() && "Invalid binary operator!");
     llvm::APFloatBase::cmpResult APFloatCmpResult = LHS.compare(RHS);
-    if (!Info.InConstantContext && APFloatCmpResult == APFloat::cmpUnordered &&
+    if (!Info.InConstantContext &&
+        APFloatCmpResult == APFloat::cmpUnordered &&
         E->getFPFeaturesInEffect(Info.Ctx.getLangOpts()).isFPConstrained()) {
       // Note: Compares may raise invalid in some cases involving NaN or sNaN.
       Info.FFDiag(E, diag::note_constexpr_float_arithmetic_strict);
@@ -18326,7 +18352,7 @@ EvaluateComparisonBinaryOperator(EvalInfo &Info, const BinaryOperator *E,
       if (Info.checkingPotentialConstantExpression() &&
           (LHSValue.AllowConstexprUnknown || RHSValue.AllowConstexprUnknown))
         return false;
-      auto DiagComparison = [&](unsigned DiagID, bool Reversed = false) {
+      auto DiagComparison = [&] (unsigned DiagID, bool Reversed = false) {
         std::string LHS = LHSValue.toString(Info.Ctx, E->getLHS()->getType());
         std::string RHS = RHSValue.toString(Info.Ctx, E->getRHS()->getType());
         Info.FFDiag(E, DiagID)
@@ -18375,7 +18401,7 @@ EvaluateComparisonBinaryOperator(EvalInfo &Info, const BinaryOperator *E,
         return DiagComparison(diag::note_constexpr_pointer_comparison_past_end,
                               true);
       if (RHSValue.Base && RHSValue.Offset.isZero() &&
-          isOnePastTheEndOfCompleteObject(Info.Ctx, LHSValue))
+           isOnePastTheEndOfCompleteObject(Info.Ctx, LHSValue))
         return DiagComparison(diag::note_constexpr_pointer_comparison_past_end,
                               false);
       // We can't tell whether an object is at the same address as another
@@ -18621,7 +18647,8 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
     auto OnSuccess = [&](CmpResult CR, const BinaryOperator *E) {
       assert((CR != CmpResult::Unequal || E->isEqualityOp()) &&
              "should only produce Unequal for equality comparisons");
-      bool IsEqual = CR == CmpResult::Equal, IsLess = CR == CmpResult::Less,
+      bool IsEqual   = CR == CmpResult::Equal,
+           IsLess    = CR == CmpResult::Less,
            IsGreater = CR == CmpResult::Greater;
       auto Op = E->getOpcode();
       switch (Op) {
@@ -18754,8 +18781,8 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
 /// VisitUnaryExprOrTypeTraitExpr - Evaluate a sizeof, alignof or vec_step with
 /// a result as the expression's type.
 bool IntExprEvaluator::VisitUnaryExprOrTypeTraitExpr(
-    const UnaryExprOrTypeTraitExpr *E) {
-  switch (E->getKind()) {
+                                    const UnaryExprOrTypeTraitExpr *E) {
+  switch(E->getKind()) {
   case UETT_PreferredAlignOf:
   case UETT_AlignOf: {
     if (E->isArgumentType())
@@ -18806,11 +18833,11 @@ bool IntExprEvaluator::VisitUnaryExprOrTypeTraitExpr(
   }
   case UETT_OpenMPRequiredSimdAlign:
     assert(E->isArgumentType());
-    return Success(Info.Ctx
-                       .toCharUnitsFromBits(Info.Ctx.getOpenMPDefaultSimdAlign(
-                           E->getArgumentType()))
-                       .getQuantity(),
-                   E);
+    return Success(
+        Info.Ctx.toCharUnitsFromBits(
+                    Info.Ctx.getOpenMPDefaultSimdAlign(E->getArgumentType()))
+            .getQuantity(),
+        E);
   case UETT_VectorElements: {
     QualType Ty = E->getTypeOfArgument();
     // If the vector has a fixed size, we can determine the number of elements
@@ -18902,8 +18929,7 @@ bool IntExprEvaluator::VisitOffsetOfExpr(const OffsetOfExpr *OOE) {
       const auto *RD = CurrentType->getAsRecordDecl();
       if (!RD)
         return Error(OOE);
-      if (RD->isInvalidDecl())
-        return false;
+      if (RD->isInvalidDecl()) return false;
       const ASTRecordLayout &RL = Info.Ctx.getASTRecordLayout(RD);
       unsigned i = MemberDecl->getFieldIndex();
       assert(i < RL.getFieldCount() && "offsetof field in wrong type");
@@ -18924,8 +18950,7 @@ bool IntExprEvaluator::VisitOffsetOfExpr(const OffsetOfExpr *OOE) {
       const auto *RD = CurrentType->getAsCXXRecordDecl();
       if (!RD)
         return Error(OOE);
-      if (RD->isInvalidDecl())
-        return false;
+      if (RD->isInvalidDecl()) return false;
       const ASTRecordLayout &RL = Info.Ctx.getASTRecordLayout(RD);
 
       // Find the base class itself.
@@ -18959,8 +18984,7 @@ bool IntExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) {
   case UO_Minus: {
     if (!Visit(E->getSubExpr()))
       return false;
-    if (!Result.isInt())
-      return Error(E);
+    if (!Result.isInt()) return Error(E);
     const APSInt &Value = Result.getInt();
     if (Value.isSigned() && Value.isMinSignedValue() && E->canOverflow() &&
         !E->getType().isWrapType()) {
@@ -18980,8 +19004,7 @@ bool IntExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) {
   case UO_Not: {
     if (!Visit(E->getSubExpr()))
       return false;
-    if (!Result.isInt())
-      return Error(E);
+    if (!Result.isInt()) return Error(E);
     return Success(~Result.getInt(), E);
   }
   case UO_LNot: {
@@ -19150,8 +19173,8 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr *E) {
       }
     }
 
-    return Success(
-        HandleIntToIntCast(Info, E, DestType, SrcType, Result.getInt()), E);
+    return Success(HandleIntToIntCast(Info, E, DestType, SrcType,
+                                      Result.getInt()), E);
   }
 
   case CK_PointerToIntegral: {
@@ -19270,7 +19293,7 @@ bool IntExprEvaluator::VisitCXXNoexceptExpr(const CXXNoexceptExpr *E) {
 }
 
 bool IntExprEvaluator::VisitConceptSpecializationExpr(
-    const ConceptSpecializationExpr *E) {
+       const ConceptSpecializationExpr *E) {
   return Success(E->isSatisfied(), E);
 }
 
@@ -19280,29 +19303,28 @@ bool IntExprEvaluator::VisitRequiresExpr(const RequiresExpr *E) {
 
 bool FixedPointExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) {
   switch (E->getOpcode()) {
-  default:
-    // Invalid unary operators
-    return Error(E);
-  case UO_Plus:
-    // The result is just the value.
-    return Visit(E->getSubExpr());
-  case UO_Minus: {
-    if (!Visit(E->getSubExpr()))
-      return false;
-    if (!Result.isFixedPoint())
+    default:
+      // Invalid unary operators
       return Error(E);
-    bool Overflowed;
-    APFixedPoint Negated = Result.getFixedPoint().negate(&Overflowed);
-    if (Overflowed && !HandleOverflow(Info, E, Negated, E->getType()))
-      return false;
-    return Success(Negated, E);
-  }
-  case UO_LNot: {
-    bool bres;
-    if (!EvaluateAsBooleanCondition(E->getSubExpr(), bres, Info))
-      return false;
-    return Success(!bres, E);
-  }
+    case UO_Plus:
+      // The result is just the value.
+      return Visit(E->getSubExpr());
+    case UO_Minus: {
+      if (!Visit(E->getSubExpr())) return false;
+      if (!Result.isFixedPoint())
+        return Error(E);
+      bool Overflowed;
+      APFixedPoint Negated = Result.getFixedPoint().negate(&Overflowed);
+      if (Overflowed && !HandleOverflow(Info, E, Negated, E->getType()))
+        return false;
+      return Success(Negated, E);
+    }
+    case UO_LNot: {
+      bool bres;
+      if (!EvaluateAsBooleanCondition(E->getSubExpr(), bres, Info))
+        return false;
+      return Success(!bres, E);
+    }
   }
 }
 
@@ -19322,9 +19344,9 @@ bool FixedPointExprEvaluator::VisitCastExpr(const CastExpr *E) {
     APFixedPoint Result = Src.convert(DestFXSema, &Overflowed);
     if (Overflowed) {
       if (Info.checkingForUndefinedBehavior())
-        Info.Ctx.getDiagnostics().Report(
-            E->getExprLoc(), diag::warn_fixedpoint_constant_overflow)
-            << Result.toString() << E->getType();
+        Info.Ctx.getDiagnostics().Report(E->getExprLoc(),
+                                         diag::warn_fixedpoint_constant_overflow)
+          << Result.toString() << E->getType();
       if (!HandleOverflow(Info, E, Result, E->getType()))
         return false;
     }
@@ -19341,9 +19363,9 @@ bool FixedPointExprEvaluator::VisitCastExpr(const CastExpr *E) {
 
     if (Overflowed) {
       if (Info.checkingForUndefinedBehavior())
-        Info.Ctx.getDiagnostics().Report(
-            E->getExprLoc(), diag::warn_fixedpoint_constant_overflow)
-            << IntResult.toString() << E->getType();
+        Info.Ctx.getDiagnostics().Report(E->getExprLoc(),
+                                         diag::warn_fixedpoint_constant_overflow)
+          << IntResult.toString() << E->getType();
       if (!HandleOverflow(Info, E, IntResult, E->getType()))
         return false;
     }
@@ -19361,9 +19383,9 @@ bool FixedPointExprEvaluator::VisitCastExpr(const CastExpr *E) {
 
     if (Overflowed) {
       if (Info.checkingForUndefinedBehavior())
-        Info.Ctx.getDiagnostics().Report(
-            E->getExprLoc(), diag::warn_fixedpoint_constant_overflow)
-            << Result.toString() << E->getType();
+        Info.Ctx.getDiagnostics().Report(E->getExprLoc(),
+                                         diag::warn_fixedpoint_constant_overflow)
+          << Result.toString() << E->getType();
       if (!HandleOverflow(Info, E, Result, E->getType()))
         return false;
     }
@@ -19399,17 +19421,17 @@ bool FixedPointExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
   switch (E->getOpcode()) {
   case BO_Add: {
     Result = LHSFX.add(RHSFX, &OpOverflow)
-                 .convert(ResultFXSema, &ConversionOverflow);
+                  .convert(ResultFXSema, &ConversionOverflow);
     break;
   }
   case BO_Sub: {
     Result = LHSFX.sub(RHSFX, &OpOverflow)
-                 .convert(ResultFXSema, &ConversionOverflow);
+                  .convert(ResultFXSema, &ConversionOverflow);
     break;
   }
   case BO_Mul: {
     Result = LHSFX.mul(RHSFX, &OpOverflow)
-                 .convert(ResultFXSema, &ConversionOverflow);
+                  .convert(ResultFXSema, &ConversionOverflow);
     break;
   }
   case BO_Div: {
@@ -19418,7 +19440,7 @@ bool FixedPointExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
       return false;
     }
     Result = LHSFX.div(RHSFX, &OpOverflow)
-                 .convert(ResultFXSema, &ConversionOverflow);
+                  .convert(ResultFXSema, &ConversionOverflow);
     break;
   }
   case BO_Shl:
@@ -19451,7 +19473,7 @@ bool FixedPointExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
     if (Info.checkingForUndefinedBehavior())
       Info.Ctx.getDiagnostics().Report(E->getExprLoc(),
                                        diag::warn_fixedpoint_constant_overflow)
-          << Result.toString() << E->getType();
+        << Result.toString() << E->getType();
     if (!HandleOverflow(Info, E, Result, E->getType()))
       return false;
   }
@@ -19463,12 +19485,12 @@ bool FixedPointExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
 //===----------------------------------------------------------------------===//
 
 namespace {
-class FloatExprEvaluator : public ExprEvaluatorBase<FloatExprEvaluator> {
+class FloatExprEvaluator
+  : public ExprEvaluatorBase<FloatExprEvaluator> {
   APFloat &Result;
-
 public:
   FloatExprEvaluator(EvalInfo &info, APFloat &result)
-      : ExprEvaluatorBaseTy(info), Result(result) {}
+    : ExprEvaluatorBaseTy(info), Result(result) {}
 
   bool Success(const APValue &V, const Expr *e) {
     Result = V.getFloat();
@@ -19494,18 +19516,19 @@ class FloatExprEvaluator : public ExprEvaluatorBase<FloatExprEvaluator> {
 };
 } // end anonymous namespace
 
-static bool EvaluateFloat(const Expr *E, APFloat &Result, EvalInfo &Info) {
+static bool EvaluateFloat(const Expr* E, APFloat& Result, EvalInfo &Info) {
   assert(!E->isValueDependent());
   assert(E->isPRValue() && E->getType()->isRealFloatingType());
   return FloatExprEvaluator(Info, Result).Visit(E);
 }
 
-static bool TryEvaluateBuiltinNaN(const ASTContext &Context, QualType ResultTy,
-                                  const Expr *Arg, bool SNaN,
+static bool TryEvaluateBuiltinNaN(const ASTContext &Context,
+                                  QualType ResultTy,
+                                  const Expr *Arg,
+                                  bool SNaN,
                                   llvm::APFloat &Result) {
   const StringLiteral *S = dyn_cast<StringLiteral>(Arg->IgnoreParenCasts());
-  if (!S)
-    return false;
+  if (!S) return false;
 
   const llvm::fltSemantics &Sem = Context.getFloatTypeSemantics(ResultTy);
 
@@ -19556,7 +19579,7 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) {
   case Builtin::BI__builtin_inff16:
   case Builtin::BI__builtin_inff128: {
     const llvm::fltSemantics &Sem =
-        Info.Ctx.getFloatTypeSemantics(E->getType());
+      Info.Ctx.getFloatTypeSemantics(E->getType());
     Result = llvm::APFloat::getInf(Sem);
     return true;
   }
@@ -19566,8 +19589,8 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) {
   case Builtin::BI__builtin_nansl:
   case Builtin::BI__builtin_nansf16:
   case Builtin::BI__builtin_nansf128:
-    if (!TryEvaluateBuiltinNaN(Info.Ctx, E->getType(), E->getArg(0), true,
-                               Result))
+    if (!TryEvaluateBuiltinNaN(Info.Ctx, E->getType(), E->getArg(0),
+                               true, Result))
       return Error(E);
     return true;
 
@@ -19578,8 +19601,8 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) {
   case Builtin::BI__builtin_nanf128:
     // If this is __builtin_nan() turn this into a nan, otherwise we
     // can't constant fold it.
-    if (!TryEvaluateBuiltinNaN(Info.Ctx, E->getType(), E->getArg(0), false,
-                               Result))
+    if (!TryEvaluateBuiltinNaN(Info.Ctx, E->getType(), E->getArg(0),
+                               false, Result))
       return Error(E);
     return true;
 
@@ -19603,9 +19626,9 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) {
   case Builtin::BI__arithmetic_fence:
     return EvaluateFloat(E->getArg(0), Result, Info);
 
-    // FIXME: Builtin::BI__builtin_powi
-    // FIXME: Builtin::BI__builtin_powif
-    // FIXME: Builtin::BI__builtin_powil
+  // FIXME: Builtin::BI__builtin_powi
+  // FIXME: Builtin::BI__builtin_powif
+  // FIXME: Builtin::BI__builtin_powil
 
   case Builtin::BI__builtin_copysign:
   case Builtin::BI__builtin_copysignf:
@@ -19728,8 +19751,7 @@ bool FloatExprEvaluator::VisitUnaryImag(const UnaryOperator *E) {
 
 bool FloatExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) {
   switch (E->getOpcode()) {
-  default:
-    return Error(E);
+  default: return Error(E);
   case UO_Plus:
     return EvaluateFloat(E->getSubExpr(), Result, Info);
   case UO_Minus:
@@ -19761,7 +19783,7 @@ bool FloatExprEvaluator::VisitFloatingLiteral(const FloatingLiteral *E) {
 }
 
 bool FloatExprEvaluator::VisitCastExpr(const CastExpr *E) {
-  const Expr *SubExpr = E->getSubExpr();
+  const Expr* SubExpr = E->getSubExpr();
 
   switch (E->getCastKind()) {
   default:
@@ -19772,10 +19794,11 @@ bool FloatExprEvaluator::VisitCastExpr(const CastExpr *E) {
 
   case CK_IntegralToFloating: {
     APSInt IntResult;
-    const FPOptions FPO = E->getFPFeaturesInEffect(Info.Ctx.getLangOpts());
+    const FPOptions FPO = E->getFPFeaturesInEffect(
+                                  Info.Ctx.getLangOpts());
     return EvaluateInteger(SubExpr, IntResult, Info) &&
-           HandleIntToFloatCast(Info, E, FPO, SubExpr->getType(), IntResult,
-                                E->getType(), Result);
+           HandleIntToFloatCast(Info, E, FPO, SubExpr->getType(),
+                                IntResult, E->getType(), Result);
   }
 
   case CK_FixedPointToFloating: {
@@ -19838,12 +19861,13 @@ bool FloatExprEvaluator::VisitCastExpr(const CastExpr *E) {
 //===----------------------------------------------------------------------===//
 
 namespace {
-class ComplexExprEvaluator : public ExprEvaluatorBase<ComplexExprEvaluator> {
+class ComplexExprEvaluator
+  : public ExprEvaluatorBase<ComplexExprEvaluator> {
   ComplexValue &Result;
 
 public:
   ComplexExprEvaluator(EvalInfo &info, ComplexValue &Result)
-      : ExprEvaluatorBaseTy(info), Result(Result) {}
+    : ExprEvaluatorBaseTy(info), Result(Result) {}
 
   bool Success(const APValue &V, const Expr *e) {
     Result.setFrom(V);
@@ -19889,7 +19913,7 @@ bool ComplexExprEvaluator::ZeroInitialization(const Expr *E) {
 }
 
 bool ComplexExprEvaluator::VisitImaginaryLiteral(const ImaginaryLiteral *E) {
-  const Expr *SubExpr = E->getSubExpr();
+  const Expr* SubExpr = E->getSubExpr();
 
   if (SubExpr->getType()->isRealFloatingType()) {
     Result.makeComplexFloat();
@@ -20001,8 +20025,8 @@ bool ComplexExprEvaluator::VisitCastExpr(const CastExpr *E) {
       return false;
 
     QualType To = E->getType()->castAs<ComplexType>()->getElementType();
-    QualType From =
-        E->getSubExpr()->getType()->castAs<ComplexType>()->getElementType();
+    QualType From
+      = E->getSubExpr()->getType()->castAs<ComplexType>()->getElementType();
 
     return HandleFloatToFloatCast(Info, E, From, To, Result.FloatReal) &&
            HandleFloatToFloatCast(Info, E, From, To, Result.FloatImag);
@@ -20013,13 +20037,13 @@ bool ComplexExprEvaluator::VisitCastExpr(const CastExpr *E) {
       return false;
 
     QualType To = E->getType()->castAs<ComplexType>()->getElementType();
-    QualType From =
-        E->getSubExpr()->getType()->castAs<ComplexType>()->getElementType();
+    QualType From
+      = E->getSubExpr()->getType()->castAs<ComplexType>()->getElementType();
     Result.makeComplexInt();
-    return HandleFloatToIntCast(Info, E, From, Result.FloatReal, To,
-                                Result.IntReal) &&
-           HandleFloatToIntCast(Info, E, From, Result.FloatImag, To,
-                                Result.IntImag);
+    return HandleFloatToIntCast(Info, E, From, Result.FloatReal,
+                                To, Result.IntReal) &&
+           HandleFloatToIntCast(Info, E, From, Result.FloatImag,
+                                To, Result.IntImag);
   }
 
   case CK_IntegralRealToComplex: {
@@ -20037,8 +20061,8 @@ bool ComplexExprEvaluator::VisitCastExpr(const CastExpr *E) {
       return false;
 
     QualType To = E->getType()->castAs<ComplexType>()->getElementType();
-    QualType From =
-        E->getSubExpr()->getType()->castAs<ComplexType>()->getElementType();
+    QualType From
+      = E->getSubExpr()->getType()->castAs<ComplexType>()->getElementType();
 
     Result.IntReal = HandleIntToIntCast(Info, E, To, From, Result.IntReal);
     Result.IntImag = HandleIntToIntCast(Info, E, To, From, Result.IntImag);
@@ -20049,15 +20073,16 @@ bool ComplexExprEvaluator::VisitCastExpr(const CastExpr *E) {
     if (!Visit(E->getSubExpr()))
       return false;
 
-    const FPOptions FPO = E->getFPFeaturesInEffect(Info.Ctx.getLangOpts());
+    const FPOptions FPO = E->getFPFeaturesInEffect(
+                                  Info.Ctx.getLangOpts());
     QualType To = E->getType()->castAs<ComplexType>()->getElementType();
-    QualType From =
-        E->getSubExpr()->getType()->castAs<ComplexType>()->getElementType();
+    QualType From
+      = E->getSubExpr()->getType()->castAs<ComplexType>()->getElementType();
     Result.makeComplexFloat();
-    return HandleIntToFloatCast(Info, E, FPO, From, Result.IntReal, To,
-                                Result.FloatReal) &&
-           HandleIntToFloatCast(Info, E, FPO, From, Result.IntImag, To,
-                                Result.FloatImag);
+    return HandleIntToFloatCast(Info, E, FPO, From, Result.IntReal,
+                                To, Result.FloatReal) &&
+           HandleIntToFloatCast(Info, E, FPO, From, Result.IntImag,
+                                To, Result.FloatImag);
   }
   }
 
@@ -20321,8 +20346,7 @@ bool ComplexExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
   assert(!(LHSReal && RHSReal) &&
          "Cannot have both operands of a complex operation be real.");
   switch (E->getOpcode()) {
-  default:
-    return Error(E);
+  default: return Error(E);
   case BO_Add:
     if (Result.isComplexFloat()) {
       Result.getComplexFloatReal().add(RHS.getComplexFloatReal(),
@@ -20389,11 +20413,11 @@ bool ComplexExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
     } else {
       ComplexValue LHS = Result;
       Result.getComplexIntReal() =
-          (LHS.getComplexIntReal() * RHS.getComplexIntReal() -
-           LHS.getComplexIntImag() * RHS.getComplexIntImag());
+        (LHS.getComplexIntReal() * RHS.getComplexIntReal() -
+         LHS.getComplexIntImag() * RHS.getComplexIntImag());
       Result.getComplexIntImag() =
-          (LHS.getComplexIntReal() * RHS.getComplexIntImag() +
-           LHS.getComplexIntImag() * RHS.getComplexIntReal());
+        (LHS.getComplexIntReal() * RHS.getComplexIntImag() +
+         LHS.getComplexIntImag() * RHS.getComplexIntReal());
     }
     break;
   case BO_Div:
@@ -20427,18 +20451,16 @@ bool ComplexExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
     } else {
       ComplexValue LHS = Result;
       APSInt Den = RHS.getComplexIntReal() * RHS.getComplexIntReal() +
-                   RHS.getComplexIntImag() * RHS.getComplexIntImag();
+        RHS.getComplexIntImag() * RHS.getComplexIntImag();
       if (Den.isZero())
         return Error(E, diag::note_expr_divide_by_zero);
 
       Result.getComplexIntReal() =
-          (LHS.getComplexIntReal() * RHS.getComplexIntReal() +
-           LHS.getComplexIntImag() * RHS.getComplexIntImag()) /
-          Den;
+        (LHS.getComplexIntReal() * RHS.getComplexIntReal() +
+         LHS.getComplexIntImag() * RHS.getComplexIntImag()) / Den;
       Result.getComplexIntImag() =
-          (LHS.getComplexIntImag() * RHS.getComplexIntReal() -
-           LHS.getComplexIntReal() * RHS.getComplexIntImag()) /
-          Den;
+        (LHS.getComplexIntImag() * RHS.getComplexIntReal() -
+         LHS.getComplexIntReal() * RHS.getComplexIntImag()) / Den;
     }
     break;
   }
@@ -20463,7 +20485,8 @@ bool ComplexExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) {
     if (Result.isComplexFloat()) {
       Result.getComplexFloatReal().changeSign();
       Result.getComplexFloatImag().changeSign();
-    } else {
+    }
+    else {
       Result.getComplexIntReal() = -Result.getComplexIntReal();
       Result.getComplexIntImag() = -Result.getComplexIntImag();
     }
@@ -20521,10 +20544,10 @@ bool ComplexExprEvaluator::VisitCallExpr(const CallExpr *E) {
 //===----------------------------------------------------------------------===//
 
 namespace {
-class AtomicExprEvaluator : public ExprEvaluatorBase<AtomicExprEvaluator> {
+class AtomicExprEvaluator :
+    public ExprEvaluatorBase<AtomicExprEvaluator> {
   const LValue *This;
   APValue &Result;
-
 public:
   AtomicExprEvaluator(EvalInfo &Info, const LValue *This, APValue &Result)
       : ExprEvaluatorBaseTy(Info), This(This), Result(Result) {}
@@ -20571,7 +20594,8 @@ static bool EvaluateAtomic(const Expr *E, const LValue *This, APValue &Result,
 //===----------------------------------------------------------------------===//
 
 namespace {
-class VoidExprEvaluator : public ExprEvaluatorBase<VoidExprEvaluator> {
+class VoidExprEvaluator
+  : public ExprEvaluatorBase<VoidExprEvaluator> {
 public:
   VoidExprEvaluator(EvalInfo &Info) : ExprEvaluatorBaseTy(Info) {}
 
@@ -20716,7 +20740,7 @@ static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E) {
     if (!IntExprEvaluator(Info, Result).Visit(E))
       return false;
   } else if (T->isMetaInfoType()) {
-    if (!EvaluateReflection(E, Result, Info))
+    if(!EvaluateReflection(E, Result, Info))
       return false;
   } else if (T->hasPointerRepresentation()) {
     LValue LV;
@@ -20734,8 +20758,7 @@ static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E) {
       return false;
     C.moveInto(Result);
   } else if (T->isFixedPointType()) {
-    if (!FixedPointExprEvaluator(Info, Result).Visit(E))
-      return false;
+    if (!FixedPointExprEvaluator(Info, Result).Visit(E)) return false;
   } else if (T->isMemberPointerType()) {
     MemberPtr P;
     if (!EvaluateMemberPointer(E, P, Info))
@@ -20758,7 +20781,8 @@ static bool Evaluate(APValue &Result, EvalInfo &Info, const Expr *E) {
     Result = Value;
   } else if (T->isVoidType()) {
     if (!Info.getLangOpts().CPlusPlus11)
-      Info.CCEDiag(E, diag::note_constexpr_nonliteral) << E->getType();
+      Info.CCEDiag(E, diag::note_constexpr_nonliteral)
+        << E->getType();
     if (!EvaluateVoid(E, Info))
       return false;
   } else if (T->isAtomicType()) {
@@ -21111,7 +21135,7 @@ bool Expr::EvaluateAsConstantExpr(EvalResult &Result, const ASTContext &Ctx,
   // If we're evaluating a prvalue, fake up a MaterializeTemporaryExpr to
   // represent the result of the evaluation. CheckConstantExpression ensures
   // this doesn't escape.
-  MaterializeTemporaryExpr BaseMTE(T, const_cast<Expr *>(this), true);
+  MaterializeTemporaryExpr BaseMTE(T, const_cast<Expr*>(this), true);
   APValue::LValueBase Base(&BaseMTE);
   Info.setEvaluatingDecl(Base, Result.Val);
 
@@ -21348,13 +21372,13 @@ struct ICEDiag {
   ICEDiag(ICEKind IK, SourceLocation l) : Kind(IK), Loc(l) {}
 };
 
-} // namespace
+}
 
 static ICEDiag NoDiag() { return ICEDiag(IK_ICE, SourceLocation()); }
 
 static ICEDiag Worst(ICEDiag A, ICEDiag B) { return A.Kind >= B.Kind ? A : B; }
 
-static ICEDiag CheckEvalInICE(const Expr *E, const ASTContext &Ctx) {
+static ICEDiag CheckEvalInICE(const Expr* E, const ASTContext &Ctx) {
   Expr::EvalResult EVResult;
   Expr::EvalStatus Status;
   EvalInfo Info(Ctx, Status, EvaluationMode::ConstantExpression);
@@ -21367,7 +21391,7 @@ static ICEDiag CheckEvalInICE(const Expr *E, const ASTContext &Ctx) {
   return NoDiag();
 }
 
-static ICEDiag CheckICE(const Expr *E, const ASTContext &Ctx) {
+static ICEDiag CheckICE(const Expr* E, const ASTContext &Ctx) {
   assert(!E->isValueDependent() && "Should not see value dependent exprs!");
   if (!E->getType()->isIntegralOrEnumerationType())
     return ICEDiag(IK_NotICE, E->getBeginLoc());
@@ -21504,8 +21528,8 @@ static ICEDiag CheckICE(const Expr *E, const ASTContext &Ctx) {
     return CheckICE(cast<PackIndexingExpr>(E)->getSelectedExpr(), Ctx);
 
   case Expr::SubstNonTypeTemplateParmExprClass:
-    return CheckICE(cast<SubstNonTypeTemplateParmExpr>(E)->getReplacement(),
-                    Ctx);
+    return
+      CheckICE(cast<SubstNonTypeTemplateParmExpr>(E)->getReplacement(), Ctx);
 
   case Expr::ConstantExprClass:
     return CheckICE(cast<ConstantExpr>(E)->getSubExpr(), Ctx);
@@ -21598,7 +21622,7 @@ static ICEDiag CheckICE(const Expr *E, const ASTContext &Ctx) {
   }
   case Expr::UnaryExprOrTypeTraitExprClass: {
     const UnaryExprOrTypeTraitExpr *Exp = cast<UnaryExprOrTypeTraitExpr>(E);
-    if ((Exp->getKind() == UETT_SizeOf) &&
+    if ((Exp->getKind() ==  UETT_SizeOf) &&
         Exp->getTypeOfArgument()->isVariableArrayType())
       return ICEDiag(IK_NotICE, E->getBeginLoc());
     if (Exp->getKind() == UETT_CountOf) {
@@ -21661,7 +21685,8 @@ static ICEDiag CheckICE(const Expr *E, const ASTContext &Ctx) {
     case BO_Cmp: {
       ICEDiag LHSResult = CheckICE(Exp->getLHS(), Ctx);
       ICEDiag RHSResult = CheckICE(Exp->getRHS(), Ctx);
-      if (Exp->getOpcode() == BO_Div || Exp->getOpcode() == BO_Rem) {
+      if (Exp->getOpcode() == BO_Div ||
+          Exp->getOpcode() == BO_Rem) {
         // EvaluateAsRValue gives an error for undefined Div/Rem, so make sure
         // we don't evaluate one.
         if (LHSResult.Kind == IK_ICE && RHSResult.Kind == IK_ICE) {
@@ -21716,8 +21741,8 @@ static ICEDiag CheckICE(const Expr *E, const ASTContext &Ctx) {
   case Expr::ObjCBridgedCastExprClass: {
     const Expr *SubExpr = cast<CastExpr>(E)->getSubExpr();
     if (isa<ExplicitCastExpr>(E)) {
-      if (const FloatingLiteral *FL =
-              dyn_cast<FloatingLiteral>(SubExpr->IgnoreParenImpCasts())) {
+      if (const FloatingLiteral *FL
+            = dyn_cast<FloatingLiteral>(SubExpr->IgnoreParenImpCasts())) {
         unsigned DestWidth = Ctx.getIntWidth(E->getType());
         bool DestSigned = E->getType()->isSignedIntegerOrEnumerationType();
         APSInt IgnoredVal(DestWidth, !DestSigned);
@@ -21725,9 +21750,9 @@ static ICEDiag CheckICE(const Expr *E, const ASTContext &Ctx) {
         // If the value does not fit in the destination type, the behavior is
         // undefined, so we are not required to treat it as a constant
         // expression.
-        if (FL->getValue().convertToInteger(
-                IgnoredVal, llvm::APFloat::rmTowardZero, &Ignored) &
-            APFloat::opInvalidOp)
+        if (FL->getValue().convertToInteger(IgnoredVal,
+                                            llvm::APFloat::rmTowardZero,
+                                            &Ignored) & APFloat::opInvalidOp)
           return ICEDiag(IK_NotICE, E->getBeginLoc());
         return NoDiag();
       }
@@ -21747,16 +21772,12 @@ static ICEDiag CheckICE(const Expr *E, const ASTContext &Ctx) {
   case Expr::BinaryConditionalOperatorClass: {
     const BinaryConditionalOperator *Exp = cast<BinaryConditionalOperator>(E);
     ICEDiag CommonResult = CheckICE(Exp->getCommon(), Ctx);
-    if (CommonResult.Kind == IK_NotICE)
-      return CommonResult;
+    if (CommonResult.Kind == IK_NotICE) return CommonResult;
     ICEDiag FalseResult = CheckICE(Exp->getFalseExpr(), Ctx);
-    if (FalseResult.Kind == IK_NotICE)
-      return FalseResult;
-    if (CommonResult.Kind == IK_ICEIfUnevaluated)
-      return CommonResult;
+    if (FalseResult.Kind == IK_NotICE) return FalseResult;
+    if (CommonResult.Kind == IK_ICEIfUnevaluated) return CommonResult;
     if (FalseResult.Kind == IK_ICEIfUnevaluated &&
-        Exp->getCommon()->EvaluateKnownConstInt(Ctx) != 0)
-      return NoDiag();
+        Exp->getCommon()->EvaluateKnownConstInt(Ctx) != 0) return NoDiag();
     return FalseResult;
   }
   case Expr::ConditionalOperatorClass: {
@@ -21765,8 +21786,8 @@ static ICEDiag CheckICE(const Expr *E, const ASTContext &Ctx) {
     // then only the true side is actually considered in an integer constant
     // expression, and it is fully evaluated.  This is an important GNU
     // extension.  See GCC PR38377 for discussion.
-    if (const CallExpr *CallCE =
-            dyn_cast<CallExpr>(Exp->getCond()->IgnoreParenCasts()))
+    if (const CallExpr *CallCE
+        = dyn_cast<CallExpr>(Exp->getCond()->IgnoreParenCasts()))
       if (CallCE->getBuiltinCallee() == Builtin::BI__builtin_constant_p)
         return CheckEvalInICE(E, Ctx);
     ICEDiag CondResult = CheckICE(Exp->getCond(), Ctx);
@@ -21822,8 +21843,7 @@ static bool EvaluateCPlusPlus11IntegralConstantExpr(const ASTContext &Ctx,
   if (!Result.isInt())
     return false;
 
-  if (Value)
-    *Value = Result.getInt();
+  if (Value) *Value = Result.getInt();
   return true;
 }
 
@@ -21914,7 +21934,7 @@ bool Expr::isCXX11ConstantExpr(const ASTContext &Ctx, APValue *Result) const {
 
 bool Expr::EvaluateWithSubstitution(APValue &Value, ASTContext &Ctx,
                                     const FunctionDecl *Callee,
-                                    ArrayRef<const Expr *> Args,
+                                    ArrayRef<const Expr*> Args,
                                     const Expr *This) const {
   assert(!isValueDependent() &&
          "Expression evaluator can't be called on a dependent expression.");
@@ -21951,13 +21971,14 @@ bool Expr::EvaluateWithSubstitution(APValue &Value, ASTContext &Ctx,
   }
 
   CallRef Call = Info.CurrentCall->createCall(Callee);
-  for (ArrayRef<const Expr *>::iterator I = Args.begin(), E = Args.end();
+  for (ArrayRef<const Expr*>::iterator I = Args.begin(), E = Args.end();
        I != E; ++I) {
     unsigned Idx = I - Args.begin();
     if (Idx >= Callee->getNumParams())
       break;
     const ParmVarDecl *PVD = Callee->getParamDecl(Idx);
-    if ((*I)->isValueDependent() || !EvaluateCallArg(PVD, *I, Call, Info) ||
+    if ((*I)->isValueDependent() ||
+        !EvaluateCallArg(PVD, *I, Call, Info) ||
         Info.EvalStatus.HasSideEffects) {
       // If evaluation fails, throw away the argument entirely.
       if (APValue *Slot = Info.getParamSlot(Call, PVD))
@@ -21983,8 +22004,9 @@ bool Expr::EvaluateWithSubstitution(APValue &Value, ASTContext &Ctx,
          !Info.EvalStatus.HasSideEffects;
 }
 
-bool Expr::isPotentialConstantExpr(
-    const FunctionDecl *FD, SmallVectorImpl<PartialDiagnosticAt> &Diags) {
+bool Expr::isPotentialConstantExpr(const FunctionDecl *FD,
+                                   SmallVectorImpl<
+                                     PartialDiagnosticAt> &Diags) {
   // FIXME: It would be useful to check constexpr function templates, but at the
   // moment the constant expression evaluator cannot cope with the non-rigorous
   // ASTs which we build for dependent expressions.
@@ -22023,7 +22045,7 @@ bool Expr::isPotentialConstantExpr(
                                : Info.Ctx.IntTy);
   This.set({&VIE, Info.CurrentCall->Index});
 
-  ArrayRef<const Expr *> Args;
+  ArrayRef<const Expr*> Args;
 
   APValue Scratch;
   if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(FD)) {
@@ -22042,9 +22064,10 @@ bool Expr::isPotentialConstantExpr(
   return Diags.empty();
 }
 
-bool Expr::isPotentialConstantExprUnevaluated(
-    Expr *E, const FunctionDecl *FD,
-    SmallVectorImpl<PartialDiagnosticAt> &Diags) {
+bool Expr::isPotentialConstantExprUnevaluated(Expr *E,
+                                              const FunctionDecl *FD,
+                                              SmallVectorImpl<
+                                                PartialDiagnosticAt> &Diags) {
   assert(!E->isValueDependent() &&
          "Expression evaluator can't be called on a dependent expression.");
 
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 59b61e13772d1..e93397d149f0b 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -3119,7 +3119,7 @@ bool Type::isLiteralType(const ASTContext &Ctx) const {
   // -- std::meta::info is a scalar type
   // C++26 [basic.types]p10:
   // -- a scalar type is a literal type
-  if (isMetaInfoType())
+  if(isMetaInfoType())
     return true;
 
   // We treat _Atomic T as a literal type if T is a literal type.
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 7e53e0ad214ae..e1c86e56b5255 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -141,7 +141,7 @@ void Sema::NoteDeletedFunction(FunctionDecl *Decl) {
     return NoteDeletedInheritingConstructor(Ctor);
 
   Diag(Decl->getLocation(), diag::note_availability_specified_here)
-      << Decl << 1;
+    << Decl << 1;
 }
 
 /// Determine whether a FunctionDecl was ever declared with an
@@ -219,7 +219,7 @@ void Sema::MaybeSuggestAddingStaticToDecl(const FunctionDecl *Cur) {
   if (!hasAnyExplicitStorageClass(First)) {
     SourceLocation DeclBegin = First->getSourceRange().getBegin();
     Diag(DeclBegin, diag::note_convert_inline_to_static)
-        << Cur << FixItHint::CreateInsertion(DeclBegin, "static ");
+      << Cur << FixItHint::CreateInsertion(DeclBegin, "static ");
   }
 }
 
@@ -258,7 +258,7 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
   if (ParsingInitForAutoVars.count(D)) {
     if (isa<BindingDecl>(D)) {
       Diag(Loc, diag::err_binding_cannot_appear_in_own_initializer)
-          << D->getDeclName();
+        << D->getDeclName();
     } else {
       Diag(Loc, diag::err_auto_variable_cannot_appear_in_own_initializer)
           << diag::ParsingInitFor::Var << D->getDeclName()
@@ -300,7 +300,8 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
         // constraint expression, for example)
         return true;
       if (!Satisfaction.IsSatisfied) {
-        Diag(Loc, diag::err_reference_to_function_with_unsatisfied_constraints)
+        Diag(Loc,
+             diag::err_reference_to_function_with_unsatisfied_constraints)
             << D;
         DiagnoseUnsatisfiedConstraint(Satisfaction);
         return true;
@@ -315,6 +316,7 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
 
     if (getLangOpts().CUDA && !CUDA().CheckCall(Loc, FD))
       return true;
+
   }
 
   if (auto *Concept = dyn_cast<ConceptDecl>(D);
@@ -328,12 +330,12 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
           cast<CXXConstructorDecl>(MD)->isDefaultConstructor()) ||
          MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator())) {
       Diag(Loc, diag::warn_cxx17_compat_lambda_def_ctor_assign)
-          << !isa<CXXConstructorDecl>(MD);
+        << !isa<CXXConstructorDecl>(MD);
     }
   }
 
-  auto getReferencedObjCProp =
-      [](const NamedDecl *D) -> const ObjCPropertyDecl * {
+  auto getReferencedObjCProp = [](const NamedDecl *D) ->
+                                      const ObjCPropertyDecl * {
     if (const auto *MD = dyn_cast<ObjCMethodDecl>(D))
       return MD->findPropertyDecl();
     return nullptr;
@@ -342,7 +344,7 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
     if (diagnoseArgIndependentDiagnoseIfAttrs(ObjCPDecl, Loc))
       return true;
   } else if (diagnoseArgIndependentDiagnoseIfAttrs(D, Loc)) {
-    return true;
+      return true;
   }
 
   // [OpenMP 4.0], 2.15 declare reduction Directive, Restrictions
@@ -519,8 +521,7 @@ ExprResult Sema::DefaultFunctionArrayConversion(Expr *E, bool Diagnose) {
   // Handle any placeholder expressions which made it here.
   if (E->hasPlaceholderType()) {
     ExprResult result = CheckPlaceholderExpr(E);
-    if (result.isInvalid())
-      return ExprError();
+    if (result.isInvalid()) return ExprError();
     E = result.get();
   }
 
@@ -534,8 +535,7 @@ ExprResult Sema::DefaultFunctionArrayConversion(Expr *E, bool Diagnose) {
           return ExprError();
 
     E = ImpCastExprToType(E, Context.getPointerType(Ty),
-                          CK_FunctionToPointerDecay)
-            .get();
+                          CK_FunctionToPointerDecay).get();
   } else if (Ty->isArrayType()) {
     // In C90 mode, arrays only promote to pointers if the array expression is
     // an lvalue.  The relevant legalese is C90 6.2.2.1p3: "an lvalue that has
@@ -585,7 +585,8 @@ static void CheckForNullPointerDereference(Sema &S, Expr *E) {
 }
 
 static void DiagnoseDirectIsaAccess(Sema &S, const ObjCIvarRefExpr *OIRE,
-                                    SourceLocation AssignLoc, const Expr *RHS) {
+                                    SourceLocation AssignLoc,
+                                    const Expr* RHS) {
   const ObjCIvarDecl *IV = OIRE->getDecl();
   if (!IV)
     return;
@@ -603,12 +604,13 @@ static void DiagnoseDirectIsaAccess(Sema &S, const ObjCIvarRefExpr *OIRE,
     if (ObjCInterfaceDecl *IDecl = OTy->getInterface()) {
       ObjCInterfaceDecl *ClassDeclared = nullptr;
       ObjCIvarDecl *IV = IDecl->lookupInstanceVariable(Member, ClassDeclared);
-      if (!ClassDeclared->getSuperClass() &&
-          (*ClassDeclared->ivar_begin()) == IV) {
+      if (!ClassDeclared->getSuperClass()
+          && (*ClassDeclared->ivar_begin()) == IV) {
         if (RHS) {
-          NamedDecl *ObjectSetClass = S.LookupSingleName(
-              S.TUScope, &S.Context.Idents.get("object_setClass"),
-              SourceLocation(), S.LookupOrdinaryName);
+          NamedDecl *ObjectSetClass =
+            S.LookupSingleName(S.TUScope,
+                               &S.Context.Idents.get("object_setClass"),
+                               SourceLocation(), S.LookupOrdinaryName);
           if (ObjectSetClass) {
             SourceLocation RHSLocEnd = S.getLocForEndOfToken(RHS->getEndLoc());
             S.Diag(OIRE->getExprLoc(), diag::warn_objc_isa_assign)
@@ -617,12 +619,14 @@ static void DiagnoseDirectIsaAccess(Sema &S, const ObjCIvarRefExpr *OIRE,
                 << FixItHint::CreateReplacement(
                        SourceRange(OIRE->getOpLoc(), AssignLoc), ",")
                 << FixItHint::CreateInsertion(RHSLocEnd, ")");
-          } else
+          }
+          else
             S.Diag(OIRE->getLocation(), diag::warn_objc_isa_assign);
         } else {
-          NamedDecl *ObjectGetClass = S.LookupSingleName(
-              S.TUScope, &S.Context.Idents.get("object_getClass"),
-              SourceLocation(), S.LookupOrdinaryName);
+          NamedDecl *ObjectGetClass =
+            S.LookupSingleName(S.TUScope,
+                               &S.Context.Idents.get("object_getClass"),
+                               SourceLocation(), S.LookupOrdinaryName);
           if (ObjectGetClass)
             S.Diag(OIRE->getExprLoc(), diag::warn_objc_isa_use)
                 << FixItHint::CreateInsertion(OIRE->getBeginLoc(),
@@ -641,16 +645,14 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) {
   // Handle any placeholder expressions which made it here.
   if (E->hasPlaceholderType()) {
     ExprResult result = CheckPlaceholderExpr(E);
-    if (result.isInvalid())
-      return ExprError();
+    if (result.isInvalid()) return ExprError();
     E = result.get();
   }
 
   // C++ [conv.lval]p1:
   //   A glvalue of a non-function, non-array type T can be
   //   converted to a prvalue.
-  if (!E->isGLValue())
-    return E;
+  if (!E->isGLValue()) return E;
 
   QualType T = E->getType();
   assert(!T.isNull() && "r-value conversion on typeless expression?");
@@ -681,15 +683,16 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) {
   if (getLangOpts().OpenCL &&
       !getOpenCLOptions().isAvailableOption("cl_khr_fp16", getLangOpts()) &&
       T->isHalfType()) {
-    Diag(E->getExprLoc(), diag::err_opencl_half_load_store) << 0 << T;
+    Diag(E->getExprLoc(), diag::err_opencl_half_load_store)
+      << 0 << T;
     return ExprError();
   }
 
   CheckForNullPointerDereference(*this, E);
   if (const ObjCIsaExpr *OISA = dyn_cast<ObjCIsaExpr>(E->IgnoreParenCasts())) {
-    NamedDecl *ObjectGetClass =
-        LookupSingleName(TUScope, &Context.Idents.get("object_getClass"),
-                         SourceLocation(), LookupOrdinaryName);
+    NamedDecl *ObjectGetClass = LookupSingleName(TUScope,
+                                     &Context.Idents.get("object_getClass"),
+                                     SourceLocation(), LookupOrdinaryName);
     if (ObjectGetClass)
       Diag(E->getExprLoc(), diag::warn_objc_isa_use)
           << FixItHint::CreateInsertion(OISA->getBeginLoc(), "object_getClass(")
@@ -697,9 +700,10 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) {
                  SourceRange(OISA->getOpLoc(), OISA->getIsaMemberLoc()), ")");
     else
       Diag(E->getExprLoc(), diag::warn_objc_isa_use);
-  } else if (const ObjCIvarRefExpr *OIRE =
-                 dyn_cast<ObjCIvarRefExpr>(E->IgnoreParenCasts()))
-    DiagnoseDirectIsaAccess(*this, OIRE, SourceLocation(), /* Expr*/ nullptr);
+  }
+  else if (const ObjCIvarRefExpr *OIRE =
+            dyn_cast<ObjCIvarRefExpr>(E->IgnoreParenCasts()))
+    DiagnoseDirectIsaAccess(*this, OIRE, SourceLocation(), /* Expr*/nullptr);
 
   // C++ [conv.lval]p1:
   //   [...] If T is a non-class type, the type of the prvalue is the
@@ -723,8 +727,8 @@ ExprResult Sema::DefaultLvalueConversion(Expr *E) {
     return Res;
   E = Res.get();
 
-  // Loading a __weak object implicitly retains the value, so we need a cleanup
-  // to balance that.
+  // Loading a __weak object implicitly retains the value, so we need a cleanup to
+  // balance that.
   if (E->getType().getObjCLifetime() == Qualifiers::OCL_Weak)
     Cleanup.setExprNeedsCleanups(true);
 
@@ -933,8 +937,8 @@ ExprResult Sema::DefaultArgumentPromotion(Expr *E) {
   // potentially potentially evaluated contexts.
   if (getLangOpts().CPlusPlus && E->isGLValue() && !isUnevaluatedContext()) {
     ExprResult Temp = PerformCopyInitialization(
-        InitializedEntity::InitializeTemporary(E->getType()), E->getExprLoc(),
-        E);
+                       InitializedEntity::InitializeTemporary(E->getType()),
+                                                E->getExprLoc(), E);
     if (Temp.isInvalid())
       return ExprError();
     E = Temp.get();
@@ -1130,10 +1134,8 @@ static bool handleComplexIntegerToFloatConversion(Sema &S, ExprResult &IntExpr,
                                                   QualType IntTy,
                                                   QualType ComplexTy,
                                                   bool SkipCast) {
-  if (IntTy->isComplexType() || IntTy->isRealFloatingType())
-    return true;
-  if (SkipCast)
-    return false;
+  if (IntTy->isComplexType() || IntTy->isRealFloatingType()) return true;
+  if (SkipCast) return false;
   if (IntTy->isIntegerType()) {
     QualType fpTy = ComplexTy->castAs<ComplexType>()->getElementType();
     IntExpr = S.ImpCastExprToType(IntExpr.get(), fpTy, CK_IntegralToFloating);
@@ -1209,8 +1211,8 @@ static QualType handleIntToFloatConversion(Sema &S, ExprResult &FloatExpr,
   if (IntTy->isIntegerType()) {
     if (ConvertInt)
       // Convert intExpr to the lhs floating point type.
-      IntExpr =
-          S.ImpCastExprToType(IntExpr.get(), FloatTy, CK_IntegralToFloating);
+      IntExpr = S.ImpCastExprToType(IntExpr.get(), FloatTy,
+                                    CK_IntegralToFloating);
     return FloatTy;
   }
 
@@ -1225,17 +1227,17 @@ static QualType handleIntToFloatConversion(Sema &S, ExprResult &FloatExpr,
 
   // float -> _Complex float
   if (ConvertFloat)
-    FloatExpr =
-        S.ImpCastExprToType(FloatExpr.get(), result, CK_FloatingRealToComplex);
+    FloatExpr = S.ImpCastExprToType(FloatExpr.get(), result,
+                                    CK_FloatingRealToComplex);
 
   return result;
 }
 
 /// Handle arithmethic conversion with floating point types.  Helper
 /// function of UsualArithmeticConversions()
-static QualType handleFloatConversion(Sema &S, ExprResult &LHS, ExprResult &RHS,
-                                      QualType LHSType, QualType RHSType,
-                                      bool IsCompAssign) {
+static QualType handleFloatConversion(Sema &S, ExprResult &LHS,
+                                      ExprResult &RHS, QualType LHSType,
+                                      QualType RHSType, bool IsCompAssign) {
   bool LHSFloat = LHSType->isRealFloatingType();
   bool RHSFloat = RHSType->isRealFloatingType();
 
@@ -1272,11 +1274,11 @@ static QualType handleFloatConversion(Sema &S, ExprResult &LHS, ExprResult &RHS,
 
     return handleIntToFloatConversion(S, LHS, RHS, LHSType, RHSType,
                                       /*ConvertFloat=*/!IsCompAssign,
-                                      /*ConvertInt=*/true);
+                                      /*ConvertInt=*/ true);
   }
   assert(RHSFloat);
   return handleIntToFloatConversion(S, RHS, LHS, RHSType, LHSType,
-                                    /*ConvertFloat=*/true,
+                                    /*ConvertFloat=*/ true,
                                     /*ConvertInt=*/!IsCompAssign);
 }
 
@@ -1321,7 +1323,7 @@ ExprResult doComplexIntegralCast(Sema &S, Expr *op, QualType toType) {
   return S.ImpCastExprToType(op, S.Context.getComplexType(toType),
                              CK_IntegralComplexCast);
 }
-} // namespace
+}
 
 /// Handle integer arithmetic conversions.  Helper function of
 /// UsualArithmeticConversions()
@@ -1366,7 +1368,7 @@ static QualType handleIntegerConversion(Sema &S, ExprResult &LHS,
     // on most 32-bit systems).  Use the unsigned type corresponding
     // to the signed type.
     QualType result =
-        S.Context.getCorrespondingUnsignedType(LHSSigned ? LHSType : RHSType);
+      S.Context.getCorrespondingUnsignedType(LHSSigned ? LHSType : RHSType);
     RHS = (*doRHSCast)(S, RHS.get(), result);
     if (!IsCompAssign)
       LHS = (*doLHSCast)(S, LHS.get(), result);
@@ -1387,8 +1389,8 @@ static QualType handleComplexIntConversion(Sema &S, ExprResult &LHS,
     QualType LHSEltType = LHSComplexInt->getElementType();
     QualType RHSEltType = RHSComplexInt->getElementType();
     QualType ScalarType =
-        handleIntegerConversion<doComplexIntegralCast, doComplexIntegralCast>(
-            S, LHS, RHS, LHSEltType, RHSEltType, IsCompAssign);
+      handleIntegerConversion<doComplexIntegralCast, doComplexIntegralCast>
+        (S, LHS, RHS, LHSEltType, RHSEltType, IsCompAssign);
 
     return S.Context.getComplexType(ScalarType);
   }
@@ -1396,10 +1398,11 @@ static QualType handleComplexIntConversion(Sema &S, ExprResult &LHS,
   if (LHSComplexInt) {
     QualType LHSEltType = LHSComplexInt->getElementType();
     QualType ScalarType =
-        handleIntegerConversion<doComplexIntegralCast, doIntegralCast>(
-            S, LHS, RHS, LHSEltType, RHSType, IsCompAssign);
+      handleIntegerConversion<doComplexIntegralCast, doIntegralCast>
+        (S, LHS, RHS, LHSEltType, RHSType, IsCompAssign);
     QualType ComplexType = S.Context.getComplexType(ScalarType);
-    RHS = S.ImpCastExprToType(RHS.get(), ComplexType, CK_IntegralRealToComplex);
+    RHS = S.ImpCastExprToType(RHS.get(), ComplexType,
+                              CK_IntegralRealToComplex);
 
     return ComplexType;
   }
@@ -1408,12 +1411,13 @@ static QualType handleComplexIntConversion(Sema &S, ExprResult &LHS,
 
   QualType RHSEltType = RHSComplexInt->getElementType();
   QualType ScalarType =
-      handleIntegerConversion<doIntegralCast, doComplexIntegralCast>(
-          S, LHS, RHS, LHSType, RHSEltType, IsCompAssign);
+    handleIntegerConversion<doIntegralCast, doComplexIntegralCast>
+      (S, LHS, RHS, LHSType, RHSEltType, IsCompAssign);
   QualType ComplexType = S.Context.getComplexType(ScalarType);
 
   if (!IsCompAssign)
-    LHS = S.ImpCastExprToType(LHS.get(), ComplexType, CK_IntegralRealToComplex);
+    LHS = S.ImpCastExprToType(LHS.get(), ComplexType,
+                              CK_IntegralRealToComplex);
   return ComplexType;
 }
 
@@ -1784,6 +1788,7 @@ QualType Sema::UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS,
 //  Semantic Analysis for various Expression Types
 //===----------------------------------------------------------------------===//
 
+
 ExprResult Sema::ActOnGenericSelectionExpr(
     SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc,
     bool PredicateIsExpr, void *ControllingExprOrType,
@@ -1791,10 +1796,10 @@ ExprResult Sema::ActOnGenericSelectionExpr(
   unsigned NumAssocs = ArgTypes.size();
   assert(NumAssocs == ArgExprs.size());
 
-  TypeSourceInfo **Types = new TypeSourceInfo *[NumAssocs];
+  TypeSourceInfo **Types = new TypeSourceInfo*[NumAssocs];
   for (unsigned i = 0; i < NumAssocs; ++i) {
     if (ArgTypes[i])
-      (void)GetTypeFromParser(ArgTypes[i], &Types[i]);
+      (void) GetTypeFromParser(ArgTypes[i], &Types[i]);
     else
       Types[i] = nullptr;
   }
@@ -1812,7 +1817,7 @@ ExprResult Sema::ActOnGenericSelectionExpr(
   ExprResult ER = CreateGenericSelectionExpr(
       KeyLoc, DefaultLoc, RParenLoc, PredicateIsExpr, ControllingExprOrType,
       llvm::ArrayRef(Types, NumAssocs), ArgExprs);
-  delete[] Types;
+  delete [] Types;
   return ER;
 }
 
@@ -1961,17 +1966,19 @@ ExprResult Sema::CreateGenericSelectionExpr(
 
         // C11 6.5.1.1p2 "No two generic associations in the same generic
         // selection shall specify compatible types."
-        for (unsigned j = i + 1; j < NumAssocs; ++j)
+        for (unsigned j = i+1; j < NumAssocs; ++j)
           if (Types[j] && !Types[j]->getType()->isDependentType() &&
               areTypesCompatibleForGeneric(Context, Types[i]->getType(),
                                            Types[j]->getType())) {
             Diag(Types[j]->getTypeLoc().getBeginLoc(),
                  diag::err_assoc_compatible_types)
-                << Types[j]->getTypeLoc().getSourceRange()
-                << Types[j]->getType() << Types[i]->getType();
-            Diag(Types[i]->getTypeLoc().getBeginLoc(), diag::note_compat_assoc)
-                << Types[i]->getTypeLoc().getSourceRange()
-                << Types[i]->getType();
+              << Types[j]->getTypeLoc().getSourceRange()
+              << Types[j]->getType()
+              << Types[i]->getType();
+            Diag(Types[i]->getTypeLoc().getBeginLoc(),
+                 diag::note_compat_assoc)
+              << Types[i]->getTypeLoc().getSourceRange()
+              << Types[i]->getType();
             TypeErrorFound = true;
           }
       }
@@ -2040,8 +2047,10 @@ ExprResult Sema::CreateGenericSelectionExpr(
     Diag(SR.getBegin(), diag::err_generic_sel_multi_match)
         << SR << P.second << (unsigned)CompatIndices.size();
     for (unsigned I : CompatIndices) {
-      Diag(Types[I]->getTypeLoc().getBeginLoc(), diag::note_compat_assoc)
-          << Types[I]->getTypeLoc().getSourceRange() << Types[I]->getType();
+      Diag(Types[I]->getTypeLoc().getBeginLoc(),
+           diag::note_compat_assoc)
+        << Types[I]->getTypeLoc().getSourceRange()
+        << Types[I]->getType();
     }
     return ExprError();
   }
@@ -2062,7 +2071,8 @@ ExprResult Sema::CreateGenericSelectionExpr(
   // then the result expression of the generic selection is the expression
   // in that generic association. Otherwise, the result expression of the
   // generic selection is the expression in the default generic association."
-  unsigned ResultIndex = CompatIndices.size() ? CompatIndices[0] : DefaultIndex;
+  unsigned ResultIndex =
+    CompatIndices.size() ? CompatIndices[0] : DefaultIndex;
 
   if (ControllingExpr) {
     return GenericSelectionExpr::Create(
@@ -2117,7 +2127,7 @@ static SourceLocation getUDSuffixLoc(Sema &S, SourceLocation TokLoc,
 static ExprResult BuildCookedLiteralOperatorCall(Sema &S, Scope *Scope,
                                                  IdentifierInfo *UDSuffix,
                                                  SourceLocation UDSuffixLoc,
-                                                 ArrayRef<Expr *> Args,
+                                                 ArrayRef<Expr*> Args,
                                                  SourceLocation LitEndLoc) {
   assert(Args.size() <= 2 && "too many arguments for literal operator");
 
@@ -2129,7 +2139,7 @@ static ExprResult BuildCookedLiteralOperatorCall(Sema &S, Scope *Scope,
   }
 
   DeclarationName OpName =
-      S.Context.DeclarationNames.getCXXLiteralOperatorName(UDSuffix);
+    S.Context.DeclarationNames.getCXXLiteralOperatorName(UDSuffix);
   DeclarationNameInfo OpNameInfo(OpName, UDSuffixLoc);
   OpNameInfo.setCXXLiteralOperatorNameLoc(UDSuffixLoc);
 
@@ -2221,8 +2231,8 @@ Sema::ExpandFunctionLocalPredefinedMacros(ArrayRef<Token> Toks) {
   return ExpandedToks;
 }
 
-ExprResult Sema::ActOnStringLiteral(ArrayRef<Token> StringToks,
-                                    Scope *UDLScope) {
+ExprResult
+Sema::ActOnStringLiteral(ArrayRef<Token> StringToks, Scope *UDLScope) {
   assert(!StringToks.empty() && "Must have at least one string!");
 
   // StringToks needs backing storage as it doesn't hold array elements itself
@@ -2302,8 +2312,8 @@ ExprResult Sema::ActOnStringLiteral(ArrayRef<Token> StringToks,
   // We're building a user-defined literal.
   IdentifierInfo *UDSuffix = &Context.Idents.get(Literal.getUDSuffix());
   SourceLocation UDSuffixLoc =
-      getUDSuffixLoc(*this, StringTokLocs[Literal.getUDSuffixToken()],
-                     Literal.getUDSuffixOffset());
+    getUDSuffixLoc(*this, StringTokLocs[Literal.getUDSuffixToken()],
+                   Literal.getUDSuffixOffset());
 
   // Make sure we're allowed user-defined literals here.
   if (!UDLScope)
@@ -2314,11 +2324,13 @@ ExprResult Sema::ActOnStringLiteral(ArrayRef<Token> StringToks,
   QualType SizeType = Context.getSizeType();
 
   DeclarationName OpName =
-      Context.DeclarationNames.getCXXLiteralOperatorName(UDSuffix);
+    Context.DeclarationNames.getCXXLiteralOperatorName(UDSuffix);
   DeclarationNameInfo OpNameInfo(OpName, UDSuffixLoc);
   OpNameInfo.setCXXLiteralOperatorNameLoc(UDSuffixLoc);
 
-  QualType ArgTy[] = {Context.getArrayDecayedType(StrTy), SizeType};
+  QualType ArgTy[] = {
+    Context.getArrayDecayedType(StrTy), SizeType
+  };
 
   LookupResult R(*this, OpName, UDSuffixLoc, LookupOrdinaryName);
   switch (LookupLiteralOperator(UDLScope, R, ArgTy,
@@ -2328,9 +2340,9 @@ ExprResult Sema::ActOnStringLiteral(ArrayRef<Token> StringToks,
 
   case LOLR_Cooked: {
     llvm::APInt Len(Context.getIntWidth(SizeType), Literal.GetNumStringChars());
-    IntegerLiteral *LenArg =
-        IntegerLiteral::Create(Context, Len, SizeType, StringTokLocs[0]);
-    Expr *Args[] = {Lit, LenArg};
+    IntegerLiteral *LenArg = IntegerLiteral::Create(Context, Len, SizeType,
+                                                    StringTokLocs[0]);
+    Expr *Args[] = { Lit, LenArg };
 
     return BuildLiteralOperatorCall(R, OpNameInfo, Args, StringTokLocs.back());
   }
@@ -2352,8 +2364,7 @@ ExprResult Sema::ActOnStringLiteral(ArrayRef<Token> StringToks,
     llvm::APSInt Value(CharBits, CharIsUnsigned);
 
     TemplateArgument TypeArg(CharTy);
-    TemplateArgumentLocInfo TypeArgInfo(
-        Context.getTrivialTypeSourceInfo(CharTy));
+    TemplateArgumentLocInfo TypeArgInfo(Context.getTrivialTypeSourceInfo(CharTy));
     ExplicitArgs.addArgument(TemplateArgumentLoc(TypeArg, TypeArgInfo));
 
     SourceLocation Loc = StringTokLocs.back();
@@ -2374,9 +2385,10 @@ ExprResult Sema::ActOnStringLiteral(ArrayRef<Token> StringToks,
   llvm_unreachable("unexpected literal operator lookup result");
 }
 
-DeclRefExpr *Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
-                                    SourceLocation Loc,
-                                    const CXXScopeSpec *SS) {
+DeclRefExpr *
+Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
+                       SourceLocation Loc,
+                       const CXXScopeSpec *SS) {
   DeclarationNameInfo NameInfo(D->getDeclName(), Loc);
   return BuildDeclRefExpr(D, Ty, VK, NameInfo, SS);
 }
@@ -2507,10 +2519,11 @@ Sema::BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK,
   return E;
 }
 
-void Sema::DecomposeUnqualifiedId(
-    const UnqualifiedId &Id, TemplateArgumentListInfo &Buffer,
-    DeclarationNameInfo &NameInfo,
-    const TemplateArgumentListInfo *&TemplateArgs) {
+void
+Sema::DecomposeUnqualifiedId(const UnqualifiedId &Id,
+                             TemplateArgumentListInfo &Buffer,
+                             DeclarationNameInfo &NameInfo,
+                             const TemplateArgumentListInfo *&TemplateArgs) {
   if (Id.getKind() == UnqualifiedIdKind::IK_TemplateId) {
     Buffer.setLAngleLoc(Id.TemplateId->LAngleLoc);
     Buffer.setRAngleLoc(Id.TemplateId->RAngleLoc);
@@ -2667,14 +2680,15 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
                                  OverloadCandidateSet::CSK_Normal);
         OverloadCandidateSet::iterator Best;
         for (NamedDecl *CD : Corrected) {
-          if (FunctionTemplateDecl *FTD = dyn_cast<FunctionTemplateDecl>(CD))
-            AddTemplateOverloadCandidate(FTD,
-                                         DeclAccessPair::make(FTD, AS_none),
-                                         ExplicitTemplateArgs, Args, OCS);
+          if (FunctionTemplateDecl *FTD =
+                   dyn_cast<FunctionTemplateDecl>(CD))
+            AddTemplateOverloadCandidate(
+                FTD, DeclAccessPair::make(FTD, AS_none), ExplicitTemplateArgs,
+                Args, OCS);
           else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(CD))
             if (!ExplicitTemplateArgs || ExplicitTemplateArgs->size() == 0)
-              AddOverloadCandidate(FD, DeclAccessPair::make(FD, AS_none), Args,
-                                   OCS);
+              AddOverloadCandidate(FD, DeclAccessPair::make(FD, AS_none),
+                                   Args, OCS);
         }
         switch (OCS.BestViableFunction(*this, R.getNameLoc(), Best)) {
         case OR_Success:
@@ -2692,8 +2706,8 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
         CXXRecordDecl *Record =
             Corrected.getCorrectionSpecifier().getAsRecordDecl();
         if (!Record)
-          Record =
-              cast<CXXRecordDecl>(ND->getDeclContext()->getRedeclContext());
+          Record = cast<CXXRecordDecl>(
+              ND->getDeclContext()->getRedeclContext());
         R.setNamingClass(Record);
       }
 
@@ -2800,13 +2814,12 @@ recoverFromMSUnqualifiedLookup(Sema &S, ASTContext &Context,
       TemplateArgs);
 }
 
-ExprResult Sema::ActOnIdExpression(Scope *S, CXXScopeSpec &SS,
-                                   SourceLocation TemplateKWLoc,
-                                   UnqualifiedId &Id, bool HasTrailingLParen,
-                                   bool IsAddressOfOperand,
-                                   CorrectionCandidateCallback *CCC,
-                                   bool IsInlineAsmIdentifier,
-                                   Token *KeywordReplacement) {
+ExprResult
+Sema::ActOnIdExpression(Scope *S, CXXScopeSpec &SS,
+                        SourceLocation TemplateKWLoc, UnqualifiedId &Id,
+                        bool HasTrailingLParen, bool IsAddressOfOperand,
+                        CorrectionCandidateCallback *CCC,
+                        bool IsInlineAsmIdentifier, Token *KeywordReplacement) {
   assert(!(IsAddressOfOperand && HasTrailingLParen) &&
          "cannot be direct & operand and have a trailing lparen");
   if (SS.isInvalid())
@@ -2897,8 +2910,7 @@ ExprResult Sema::ActOnIdExpression(Scope *S, CXXScopeSpec &SS,
   if (R.empty() && HasTrailingLParen && II &&
       getLangOpts().implicitFunctionsAllowed()) {
     NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *II, S);
-    if (D)
-      R.addDecl(D);
+    if (D) R.addDecl(D);
   }
 
   // Determine whether this name might be a candidate for
@@ -3024,7 +3036,7 @@ ExprResult Sema::BuildQualifiedDeclarationNameExpr(
       if (CD->isInvalidDecl() || CD->isBeingDefined())
         return ExprError();
     Diag(NameInfo.getLoc(), diag::err_no_member)
-        << NameInfo.getName() << DC << SS.getRange();
+      << NameInfo.getName() << DC << SS.getRange();
     return ExprError();
   }
 
@@ -3189,15 +3201,14 @@ ExprResult Sema::PerformObjectMemberConversion(Expr *From,
     // Otherwise build the appropriate casts.
     if (IsDerivedFrom(FromLoc, FromRecordType, QRecordType)) {
       CXXCastPath BasePath;
-      if (CheckDerivedToBaseConversion(FromRecordType, QRecordType, FromLoc,
-                                       FromRange, &BasePath))
+      if (CheckDerivedToBaseConversion(FromRecordType, QRecordType,
+                                       FromLoc, FromRange, &BasePath))
         return ExprError();
 
       if (PointerConversions)
         QType = Context.getPointerType(QType);
-      From = ImpCastExprToType(From, QType, CK_UncheckedDerivedToBase, VK,
-                               &BasePath)
-                 .get();
+      From = ImpCastExprToType(From, QType, CK_UncheckedDerivedToBase,
+                               VK, &BasePath).get();
 
       FromType = QType;
       FromRecordType = QRecordType;
@@ -3210,8 +3221,8 @@ ExprResult Sema::PerformObjectMemberConversion(Expr *From,
   }
 
   CXXCastPath BasePath;
-  if (CheckDerivedToBaseConversion(FromRecordType, DestRecordType, FromLoc,
-                                   FromRange, &BasePath,
+  if (CheckDerivedToBaseConversion(FromRecordType, DestRecordType,
+                                   FromLoc, FromRange, &BasePath,
                                    /*IgnoreAccess=*/true))
     return ExprError();
 
@@ -3277,6 +3288,7 @@ bool Sema::UseArgumentDependentLookup(const CXXScopeSpec &SS,
   return true;
 }
 
+
 /// Diagnoses obvious problems with the use of the given declaration
 /// as an expression.  This is only actually called for lookups that
 /// were not overloaded, and it doesn't promise that the declaration
@@ -3682,7 +3694,7 @@ ExprResult Sema::ActOnCharacterConstant(const Token &Tok, Scope *UDLScope) {
   else if (Literal.isUTF32())
     Ty = Context.Char32Ty; // U'x' -> char32_t in C11 and C++11.
   else if (!getLangOpts().CPlusPlus || Literal.isMultiChar())
-    Ty = Context.IntTy; // 'x' -> int in C, 'wxyz' -> int in C++.
+    Ty = Context.IntTy;   // 'x' -> int in C, 'wxyz' -> int in C++.
   else
     Ty = Context.CharTy; // 'x' -> char in C++;
                          // u8'x' -> char in C11-C17 and in C++ without char8_t.
@@ -3697,8 +3709,8 @@ ExprResult Sema::ActOnCharacterConstant(const Token &Tok, Scope *UDLScope) {
   else if (Literal.isUTF8())
     Kind = CharacterLiteralKind::UTF8;
 
-  Expr *Lit = new (Context)
-      CharacterLiteral(Literal.getValue(), Kind, Ty, Tok.getLocation());
+  Expr *Lit = new (Context) CharacterLiteral(Literal.getValue(), Kind, Ty,
+                                             Tok.getLocation());
 
   if (Literal.getUDSuffix().empty())
     return Lit;
@@ -3706,7 +3718,7 @@ ExprResult Sema::ActOnCharacterConstant(const Token &Tok, Scope *UDLScope) {
   // We're building a user-defined literal.
   IdentifierInfo *UDSuffix = &Context.Idents.get(Literal.getUDSuffix());
   SourceLocation UDSuffixLoc =
-      getUDSuffixLoc(*this, Tok.getLocation(), Literal.getUDSuffixOffset());
+    getUDSuffixLoc(*this, Tok.getLocation(), Literal.getUDSuffixOffset());
 
   // Make sure we're allowed user-defined literals here.
   if (!UDLScope)
@@ -3823,7 +3835,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
     // We're building a user-defined literal.
     const IdentifierInfo *UDSuffix = &Context.Idents.get(Literal.getUDSuffix());
     SourceLocation UDSuffixLoc =
-        getUDSuffixLoc(*this, Tok.getLocation(), Literal.getUDSuffixOffset());
+      getUDSuffixLoc(*this, Tok.getLocation(), Literal.getUDSuffixOffset());
 
     // Make sure we're allowed user-defined literals here.
     if (!UDLScope)
@@ -3843,7 +3855,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
     }
 
     DeclarationName OpName =
-        Context.DeclarationNames.getCXXLiteralOperatorName(UDSuffix);
+      Context.DeclarationNames.getCXXLiteralOperatorName(UDSuffix);
     DeclarationNameInfo OpNameInfo(OpName, UDSuffixLoc);
     OpNameInfo.setCXXLiteralOperatorNameLoc(UDSuffixLoc);
 
@@ -3937,8 +3949,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
       }
     }
 
-    if (Literal.isUnsigned)
-      Ty = Context.getCorrespondingUnsignedType(Ty);
+    if (Literal.isUnsigned) Ty = Context.getCorrespondingUnsignedType(Ty);
 
     bool isSigned = !Literal.isUnsigned;
     unsigned scale = Context.getFixedPointScale(Ty);
@@ -3962,7 +3973,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
                                               Tok.getLocation(), scale);
   } else if (Literal.isFloatingLiteral()) {
     QualType Ty;
-    if (Literal.isHalf) {
+    if (Literal.isHalf){
       if (getLangOpts().HLSL ||
           getOpenCLOptions().isAvailableOption("cl_khr_fp16", getLangOpts()))
         Ty = Context.HalfTy;
@@ -4134,7 +4145,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
         // Does it fit in a unsigned int?
         if (ResultVal.isIntN(IntSize)) {
           // Does it fit in a signed int?
-          if (!Literal.isUnsigned && ResultVal[IntSize - 1] == 0)
+          if (!Literal.isUnsigned && ResultVal[IntSize-1] == 0)
             Ty = Context.IntTy;
           else if (AllowUnsigned)
             Ty = Context.UnsignedIntTy;
@@ -4149,7 +4160,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
         // Does it fit in a unsigned long?
         if (ResultVal.isIntN(LongSize)) {
           // Does it fit in a signed long?
-          if (!Literal.isUnsigned && ResultVal[LongSize - 1] == 0)
+          if (!Literal.isUnsigned && ResultVal[LongSize-1] == 0)
             Ty = Context.LongTy;
           else if (AllowUnsigned)
             Ty = Context.UnsignedLongTy;
@@ -4182,9 +4193,8 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
           // Does it fit in a signed long long?
           // To be compatible with MSVC, hex integer literals ending with the
           // LL or i64 suffix are always signed in Microsoft mode.
-          if (!Literal.isUnsigned &&
-              (ResultVal[LongLongSize - 1] == 0 ||
-               (getLangOpts().MSVCCompat && Literal.isLongLong)))
+          if (!Literal.isUnsigned && (ResultVal[LongLongSize-1] == 0 ||
+              (getLangOpts().MSVCCompat && Literal.isLongLong)))
             Ty = Context.LongLongTy;
           else if (AllowUnsigned)
             Ty = Context.UnsignedLongLongTy;
@@ -4223,8 +4233,8 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) {
 
   // If this is an imaginary literal, create the ImaginaryLiteral wrapper.
   if (Literal.isImaginary) {
-    Res = new (Context)
-        ImaginaryLiteral(Res, Context.getComplexType(Res->getType()));
+    Res = new (Context) ImaginaryLiteral(Res,
+                                        Context.getComplexType(Res->getType()));
 
     // In C++, this is a GNU extension. In C, it's a C2y extension.
     unsigned DiagId;
@@ -4256,7 +4266,8 @@ static bool CheckVecStepTraitOperandType(Sema &S, QualType T,
   // Every built-in scalar type (OpenCL 1.1 6.1.1) is either an arithmetic
   // type (C99 6.2.5p18) or void.
   if (!(T->isArithmeticType() || T->isVoidType() || T->isVectorType())) {
-    S.Diag(Loc, diag::err_vecstep_non_scalar_vector_type) << T << ArgRange;
+    S.Diag(Loc, diag::err_vecstep_non_scalar_vector_type)
+      << T << ArgRange;
     return true;
   }
 
@@ -4271,7 +4282,8 @@ static bool CheckVectorElementsTraitOperandType(Sema &S, QualType T,
   // builtin_vectorelements supports both fixed-sized and scalable vectors.
   if (!T->isVectorType() && !T->isSizelessVectorType())
     return S.Diag(Loc, diag::err_builtin_non_vector_type)
-           << "" << "__builtin_vectorelements" << T << ArgRange;
+           << ""
+           << "__builtin_vectorelements" << T << ArgRange;
 
   if (auto *FD = dyn_cast<FunctionDecl>(S.CurContext)) {
     if (T->isSVESizelessBuiltinType()) {
@@ -4338,7 +4350,8 @@ static bool CheckObjCTraitOperandConstraints(Sema &S, QualType T,
   // runtime doesn't allow it.
   if (!S.LangOpts.ObjCRuntime.allowsSizeofAlignof() && T->isObjCObjectType()) {
     S.Diag(Loc, diag::err_sizeof_nonfragile_interface)
-        << T << (TraitKind == UETT_SizeOf) << ArgRange;
+      << T << (TraitKind == UETT_SizeOf)
+      << ArgRange;
     return true;
   }
 
@@ -4358,9 +4371,9 @@ static void warnOnSizeofOnArrayDecay(Sema &S, SourceLocation Loc, QualType T,
   if (!ICE || ICE->getCastKind() != CK_ArrayToPointerDecay)
     return;
 
-  S.Diag(Loc, diag::warn_sizeof_array_decay)
-      << ICE->getSourceRange() << ICE->getType()
-      << ICE->getSubExpr()->getType();
+  S.Diag(Loc, diag::warn_sizeof_array_decay) << ICE->getSourceRange()
+                                             << ICE->getType()
+                                             << ICE->getSubExpr()->getType();
 }
 
 bool Sema::CheckUnaryExprOrTypeTraitOperand(Expr *E,
@@ -4385,7 +4398,8 @@ bool Sema::CheckUnaryExprOrTypeTraitOperand(Expr *E,
   // used to build SFINAE gadgets.
   // FIXME: Should we consider instantiation-dependent operands to 'alignof'?
   if (IsUnevaluatedOperand && !inTemplateInstantiation() &&
-      !E->isInstantiationDependent() && !E->getType()->isVariableArrayType() &&
+      !E->isInstantiationDependent() &&
+      !E->getType()->isVariableArrayType() &&
       E->HasSideEffects(Context, false))
     Diag(E->getExprLoc(), diag::warn_side_effects_unevaluated_context);
 
@@ -4463,7 +4477,8 @@ bool Sema::CheckUnaryExprOrTypeTraitOperand(Expr *E,
         QualType OType = PVD->getOriginalType();
         QualType Type = PVD->getType();
         if (Type->isPointerType() && OType->isArrayType()) {
-          Diag(E->getExprLoc(), diag::warn_sizeof_array_param) << Type << OType;
+          Diag(E->getExprLoc(), diag::warn_sizeof_array_param)
+            << Type << OType;
           Diag(PVD->getLocation(), diag::note_declared_at);
         }
       }
@@ -4490,7 +4505,7 @@ static bool CheckAlignOfExpr(Sema &S, Expr *E, UnaryExprOrTypeTrait ExprKind) {
 
   if (E->getObjectKind() == OK_BitField) {
     S.Diag(E->getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield)
-        << 1 << E->getSourceRange();
+       << 1 << E->getSourceRange();
     return true;
   }
 
@@ -4524,7 +4539,7 @@ static bool CheckAlignOfExpr(Sema &S, Expr *E, UnaryExprOrTypeTrait ExprKind) {
     // definition if we can find a member of it.
     if (!FD->getParent()->isCompleteDefinition()) {
       S.Diag(E->getExprLoc(), diag::err_alignof_member_of_incomplete_type)
-          << E->getSourceRange();
+        << E->getSourceRange();
       return true;
     }
 
@@ -4808,8 +4823,9 @@ ExprResult Sema::CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo,
       ExprKind, TInfo, Context.getSizeType(), OpLoc, R.getEnd());
 }
 
-ExprResult Sema::CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
-                                                UnaryExprOrTypeTrait ExprKind) {
+ExprResult
+Sema::CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
+                                     UnaryExprOrTypeTrait ExprKind) {
   ExprResult PE = CheckPlaceholderExpr(E);
   if (PE.isInvalid())
     return ExprError();
@@ -4825,9 +4841,9 @@ ExprResult Sema::CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
   } else if (ExprKind == UETT_VecStep) {
     isInvalid = CheckVecStepExpr(E);
   } else if (ExprKind == UETT_OpenMPRequiredSimdAlign) {
-    Diag(E->getExprLoc(), diag::err_openmp_default_simd_align_expr);
-    isInvalid = true;
-  } else if (E->refersToBitField()) { // C99 6.5.3.4p1.
+      Diag(E->getExprLoc(), diag::err_openmp_default_simd_align_expr);
+      isInvalid = true;
+  } else if (E->refersToBitField()) {  // C99 6.5.3.4p1.
     Diag(E->getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 0;
     isInvalid = true;
   } else if (ExprKind == UETT_VectorElements || ExprKind == UETT_SizeOf ||
@@ -4841,8 +4857,7 @@ ExprResult Sema::CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
   if ((ExprKind == UETT_SizeOf || ExprKind == UETT_CountOf) &&
       E->getType()->isVariableArrayType()) {
     PE = TransformToPotentiallyEvaluated(E);
-    if (PE.isInvalid())
-      return ExprError();
+    if (PE.isInvalid()) return ExprError();
     E = PE.get();
   }
 
@@ -4851,17 +4866,16 @@ ExprResult Sema::CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
       ExprKind, E, Context.getSizeType(), OpLoc, E->getSourceRange().getEnd());
 }
 
-ExprResult Sema::ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc,
-                                               UnaryExprOrTypeTrait ExprKind,
-                                               bool IsType, void *TyOrEx,
-                                               SourceRange ArgRange) {
+ExprResult
+Sema::ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc,
+                                    UnaryExprOrTypeTrait ExprKind, bool IsType,
+                                    void *TyOrEx, SourceRange ArgRange) {
   // If error parsing type, ignore.
-  if (!TyOrEx)
-    return ExprError();
+  if (!TyOrEx) return ExprError();
 
   if (IsType) {
     TypeSourceInfo *TInfo;
-    (void)GetTypeFromParser(ParsedType::getFromOpaquePtr(TyOrEx), &TInfo);
+    (void) GetTypeFromParser(ParsedType::getFromOpaquePtr(TyOrEx), &TInfo);
     return CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, ArgRange);
   }
 
@@ -4908,37 +4922,33 @@ static QualType CheckRealImagOperand(Sema &S, ExprResult &V, SourceLocation Loc,
 
   // Test for placeholders.
   ExprResult PR = S.CheckPlaceholderExpr(V.get());
-  if (PR.isInvalid())
-    return QualType();
+  if (PR.isInvalid()) return QualType();
   if (PR.get() != V.get()) {
     V = PR;
     return CheckRealImagOperand(S, V, Loc, IsReal);
   }
 
   // Reject anything else.
-  S.Diag(Loc, diag::err_realimag_invalid_type)
-      << V.get()->getType() << (IsReal ? "__real" : "__imag");
+  S.Diag(Loc, diag::err_realimag_invalid_type) << V.get()->getType()
+    << (IsReal ? "__real" : "__imag");
   return QualType();
 }
 
-ExprResult Sema::ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
-                                     tok::TokenKind Kind, Expr *Input) {
+
+
+ExprResult
+Sema::ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
+                          tok::TokenKind Kind, Expr *Input) {
   UnaryOperatorKind Opc;
   switch (Kind) {
-  default:
-    llvm_unreachable("Unknown unary op!");
-  case tok::plusplus:
-    Opc = UO_PostInc;
-    break;
-  case tok::minusminus:
-    Opc = UO_PostDec;
-    break;
+  default: llvm_unreachable("Unknown unary op!");
+  case tok::plusplus:   Opc = UO_PostInc; break;
+  case tok::minusminus: Opc = UO_PostDec; break;
   }
 
   // Since this might is a postfix expression, get rid of ParenListExprs.
   ExprResult Result = MaybeConvertParenListExprToParenExpr(S, Input);
-  if (Result.isInvalid())
-    return ExprError();
+  if (Result.isInvalid()) return ExprError();
   Input = Result.get();
 
   return BuildUnaryOp(S, OpLoc, Opc, Input);
@@ -4947,7 +4957,8 @@ ExprResult Sema::ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
 /// Diagnose if arithmetic on the given ObjC pointer is illegal.
 ///
 /// \return true on error
-static bool checkArithmeticOnObjCPointer(Sema &S, SourceLocation opLoc,
+static bool checkArithmeticOnObjCPointer(Sema &S,
+                                         SourceLocation opLoc,
                                          Expr *op) {
   assert(op->getType()->isObjCObjectPointerType());
   if (S.LangOpts.ObjCRuntime.allowsPointerArithmetic() &&
@@ -4955,8 +4966,8 @@ static bool checkArithmeticOnObjCPointer(Sema &S, SourceLocation opLoc,
     return false;
 
   S.Diag(opLoc, diag::err_arithmetic_nonfragile_interface)
-      << op->getType()->castAs<ObjCObjectPointerType>()->getPointeeType()
-      << op->getSourceRange();
+    << op->getType()->castAs<ObjCObjectPointerType>()->getPointeeType()
+    << op->getSourceRange();
   return true;
 }
 
@@ -5364,9 +5375,9 @@ void Sema::CheckSubscriptAccessOfNoDeref(const ArraySubscriptExpr *E) {
   }
 }
 
-ExprResult Sema::CreateBuiltinArraySubscriptExpr(Expr *Base,
-                                                 SourceLocation LLoc, Expr *Idx,
-                                                 SourceLocation RLoc) {
+ExprResult
+Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
+                                      Expr *Idx, SourceLocation RLoc) {
   Expr *LHSExp = Base;
   Expr *RHSExp = Idx;
 
@@ -5413,7 +5424,7 @@ ExprResult Sema::CreateBuiltinArraySubscriptExpr(Expr *Base,
     IndexExpr = RHSExp;
     ResultType = PTy->getPointeeType();
   } else if (const ObjCObjectPointerType *PTy =
-                 LHSTy->getAs<ObjCObjectPointerType>()) {
+               LHSTy->getAs<ObjCObjectPointerType>()) {
     BaseExpr = LHSExp;
     IndexExpr = RHSExp;
 
@@ -5425,19 +5436,19 @@ ExprResult Sema::CreateBuiltinArraySubscriptExpr(Expr *Base,
 
     ResultType = PTy->getPointeeType();
   } else if (const PointerType *PTy = RHSTy->getAs<PointerType>()) {
-    // Handle the uncommon case of "123[Ptr]".
+     // Handle the uncommon case of "123[Ptr]".
     BaseExpr = RHSExp;
     IndexExpr = LHSExp;
     ResultType = PTy->getPointeeType();
   } else if (const ObjCObjectPointerType *PTy =
-                 RHSTy->getAs<ObjCObjectPointerType>()) {
-    // Handle the uncommon case of "123[Ptr]".
+               RHSTy->getAs<ObjCObjectPointerType>()) {
+     // Handle the uncommon case of "123[Ptr]".
     BaseExpr = RHSExp;
     IndexExpr = LHSExp;
     ResultType = PTy->getPointeeType();
     if (!LangOpts.isSubscriptPointerArithmetic()) {
       Diag(LLoc, diag::err_subscript_nonfragile_interface)
-          << ResultType << BaseExpr->getSourceRange();
+        << ResultType << BaseExpr->getSourceRange();
       return ExprError();
     }
   } else if (LHSTy->isSubscriptableVectorType()) {
@@ -5481,8 +5492,7 @@ ExprResult Sema::CreateBuiltinArraySubscriptExpr(Expr *Base,
     Diag(LHSExp->getBeginLoc(), diag::ext_subscript_non_lvalue)
         << LHSExp->getSourceRange();
     LHSExp = ImpCastExprToType(LHSExp, Context.getArrayDecayedType(LHSTy),
-                               CK_ArrayToPointerDecay)
-                 .get();
+                               CK_ArrayToPointerDecay).get();
     LHSTy = LHSExp->getType();
 
     BaseExpr = LHSExp;
@@ -5493,8 +5503,7 @@ ExprResult Sema::CreateBuiltinArraySubscriptExpr(Expr *Base,
     Diag(RHSExp->getBeginLoc(), diag::ext_subscript_non_lvalue)
         << RHSExp->getSourceRange();
     RHSExp = ImpCastExprToType(RHSExp, Context.getArrayDecayedType(RHSTy),
-                               CK_ArrayToPointerDecay)
-                 .get();
+                               CK_ArrayToPointerDecay).get();
     RHSTy = RHSExp->getType();
 
     BaseExpr = RHSExp;
@@ -5502,7 +5511,7 @@ ExprResult Sema::CreateBuiltinArraySubscriptExpr(Expr *Base,
     ResultType = RHSTy->castAs<PointerType>()->getPointeeType();
   } else {
     return ExprError(Diag(LLoc, diag::err_typecheck_subscript_value)
-                     << LHSExp->getSourceRange() << RHSExp->getSourceRange());
+       << LHSExp->getSourceRange() << RHSExp->getSourceRange());
   }
   // C99 6.5.2.1p1
   if (!IndexExpr->getType()->isIntegerType() && !IndexExpr->isTypeDependent())
@@ -5531,7 +5540,8 @@ ExprResult Sema::CreateBuiltinArraySubscriptExpr(Expr *Base,
 
   if (ResultType->isVoidType() && !getLangOpts().CPlusPlus) {
     // GNU extension: subscripting on pointer to void
-    Diag(LLoc, diag::ext_gnu_subscript_void_type) << BaseExpr->getSourceRange();
+    Diag(LLoc, diag::ext_gnu_subscript_void_type)
+      << BaseExpr->getSourceRange();
 
     // C forbids expressions of unqualified void type from being l-values.
     // See IsCForbiddenLValueType.
@@ -5998,7 +6008,7 @@ class FunctionCallCCC final : public FunctionCallFilterCCC {
 private:
   const IdentifierInfo *const FunctionName;
 };
-} // namespace
+}
 
 static TypoCorrection TryTypoCorrectionForCall(Sema &S, Expr *Fn,
                                                FunctionDecl *FDecl,
@@ -6058,12 +6068,13 @@ static bool isParenthetizedAndQualifiedAddressOfExpr(Expr *Fn) {
   return false;
 }
 
-bool Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
-                                   FunctionDecl *FDecl,
-                                   const FunctionProtoType *Proto,
-                                   ArrayRef<Expr *> Args,
-                                   SourceLocation RParenLoc,
-                                   bool IsExecConfig) {
+bool
+Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
+                              FunctionDecl *FDecl,
+                              const FunctionProtoType *Proto,
+                              ArrayRef<Expr *> Args,
+                              SourceLocation RParenLoc,
+                              bool IsExecConfig) {
   // Bail out early if calling a builtin with custom typechecking.
   if (FDecl)
     if (unsigned ID = FDecl->getBuiltinID())
@@ -6081,9 +6092,9 @@ bool Sema::ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
   bool Invalid = false;
   unsigned MinArgs = FDecl ? FDecl->getMinRequiredArguments() : NumParams;
   unsigned FnKind = Fn->getType()->isBlockPointerType()
-                        ? 1                 /* block */
-                        : (IsExecConfig ? 3 /* kernel function (exec config) */
-                                        : 0 /* function */);
+                       ? 1 /* block */
+                       : (IsExecConfig ? 3 /* kernel function (exec config) */
+                                       : 0 /* function */);
 
   // If too few arguments are available (and we don't have default
   // arguments for the remaining parameters), don't make the call.
@@ -6222,12 +6233,12 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl,
 
       // Strip the unbridged-cast placeholder expression off, if applicable.
       bool CFAudited = false;
-      if (Arg->getType() == Context.ARCUnbridgedCastTy && FDecl &&
-          FDecl->hasAttr<CFAuditedTransferAttr>() &&
+      if (Arg->getType() == Context.ARCUnbridgedCastTy &&
+          FDecl && FDecl->hasAttr<CFAuditedTransferAttr>() &&
           (!Param || !Param->hasAttr<CFConsumedAttr>()))
         Arg = ObjC().stripARCUnbridgedCast(Arg);
-      else if (getLangOpts().ObjCAutoRefCount && FDecl &&
-               FDecl->hasAttr<CFAuditedTransferAttr>() &&
+      else if (getLangOpts().ObjCAutoRefCount &&
+               FDecl && FDecl->hasAttr<CFAuditedTransferAttr>() &&
                (!Param || !Param->hasAttr<CFConsumedAttr>()))
         CFAudited = true;
 
@@ -6305,7 +6316,7 @@ bool Sema::GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl,
         AllArgs.push_back(arg.get());
       }
 
-      // Otherwise do argument promotion, (C99 6.5.2.2p7).
+    // Otherwise do argument promotion, (C99 6.5.2.2p7).
     } else {
       for (Expr *A : Args.slice(ArgIx)) {
         ExprResult Arg = DefaultVariadicArgumentPromotion(A, CallType, FDecl);
@@ -6327,11 +6338,13 @@ static void DiagnoseCalleeStaticArrayParam(Sema &S, ParmVarDecl *PVD) {
     TL = DTL.getOriginalLoc();
   if (ArrayTypeLoc ATL = TL.getAs<ArrayTypeLoc>())
     S.Diag(PVD->getLocation(), diag::note_callee_static_array)
-        << ATL.getLocalSourceRange();
+      << ATL.getLocalSourceRange();
 }
 
-void Sema::CheckStaticArrayArgument(SourceLocation CallLoc, ParmVarDecl *Param,
-                                    const Expr *ArgExpr) {
+void
+Sema::CheckStaticArrayArgument(SourceLocation CallLoc,
+                               ParmVarDecl *Param,
+                               const Expr *ArgExpr) {
   // Static array parameters are not supported in C++.
   if (!Param || getLangOpts().CPlusPlus)
     return;
@@ -6342,7 +6355,8 @@ void Sema::CheckStaticArrayArgument(SourceLocation CallLoc, ParmVarDecl *Param,
   if (!AT || AT->getSizeModifier() != ArraySizeModifier::Static)
     return;
 
-  if (ArgExpr->isNullPointerConstant(Context, Expr::NPC_NeverValueDependent)) {
+  if (ArgExpr->isNullPointerConstant(Context,
+                                     Expr::NPC_NeverValueDependent)) {
     Diag(CallLoc, diag::warn_null_arg) << ArgExpr->getSourceRange();
     DiagnoseCalleeStaticArrayParam(*this, Param);
     return;
@@ -6353,7 +6367,7 @@ void Sema::CheckStaticArrayArgument(SourceLocation CallLoc, ParmVarDecl *Param,
     return;
 
   const ConstantArrayType *ArgCAT =
-      Context.getAsConstantArrayType(ArgExpr->IgnoreParenCasts()->getType());
+    Context.getAsConstantArrayType(ArgExpr->IgnoreParenCasts()->getType());
   if (!ArgCAT)
     return;
 
@@ -6389,21 +6403,23 @@ static ExprResult rebuildUnknownAnyFunction(Sema &S, Expr *fn);
 static bool isPlaceholderToRemoveAsArg(QualType type) {
   // Placeholders are never sugared.
   const BuiltinType *placeholder = dyn_cast<BuiltinType>(type);
-  if (!placeholder)
-    return false;
+  if (!placeholder) return false;
 
   switch (placeholder->getKind()) {
-    // Ignore all the non-placeholder types.
-#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)                   \
+  // Ignore all the non-placeholder types.
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
   case BuiltinType::Id:
 #include "clang/Basic/OpenCLImageTypes.def"
-#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) case BuiltinType::Id:
+#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
+  case BuiltinType::Id:
 #include "clang/Basic/OpenCLExtensionTypes.def"
-    // In practice we'll never use this, since all SVE types are sugared
-    // via TypedefTypes rather than exposed directly as BuiltinTypes.
-#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
+  // In practice we'll never use this, since all SVE types are sugared
+  // via TypedefTypes rather than exposed directly as BuiltinTypes.
+#define SVE_TYPE(Name, Id, SingletonId) \
+  case BuiltinType::Id:
 #include "clang/Basic/AArch64ACLETypes.def"
-#define PPC_VECTOR_TYPE(Name, Id, Size) case BuiltinType::Id:
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
+  case BuiltinType::Id:
 #include "clang/Basic/PPCTypes.def"
 #define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
 #include "clang/Basic/RISCVVTypes.def"
@@ -6446,6 +6462,7 @@ static bool isPlaceholderToRemoveAsArg(QualType type) {
   case BuiltinType::OMPArrayShaping:
   case BuiltinType::OMPIterator:
     return true;
+
   }
   llvm_unreachable("bad builtin type kind");
 }
@@ -6457,10 +6474,8 @@ bool Sema::CheckArgsForPlaceholders(MultiExprArg args) {
   for (size_t i = 0, e = args.size(); i != e; i++) {
     if (isPlaceholderToRemoveAsArg(args[i]->getType())) {
       ExprResult result = CheckPlaceholderExpr(args[i]);
-      if (result.isInvalid())
-        hasInvalid = true;
-      else
-        args[i] = result.get();
+      if (result.isInvalid()) hasInvalid = true;
+      else args[i] = result.get();
     }
   }
   return hasInvalid;
@@ -6531,8 +6546,8 @@ static FunctionDecl *rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context,
 
   FunctionProtoType::ExtProtoInfo EPI;
   EPI.Variadic = FT->isVariadic();
-  QualType OverloadTy =
-      Context.getFunctionType(FT->getReturnType(), OverloadParams, EPI);
+  QualType OverloadTy = Context.getFunctionType(FT->getReturnType(),
+                                                OverloadParams, EPI);
   DeclContext *Parent = FDecl->getParent();
   FunctionDecl *OverloadDecl = FunctionDecl::Create(
       Context, Parent, FDecl->getLocation(), FDecl->getLocation(),
@@ -6540,14 +6555,14 @@ static FunctionDecl *rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context,
       /*TInfo=*/nullptr, SC_Extern, Sema->getCurFPFeatures().isFPConstrained(),
       false,
       /*hasPrototype=*/true);
-  SmallVector<ParmVarDecl *, 16> Params;
+  SmallVector<ParmVarDecl*, 16> Params;
   FT = cast<FunctionProtoType>(OverloadTy);
   for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
     QualType ParamType = FT->getParamType(i);
     ParmVarDecl *Parm =
         ParmVarDecl::Create(Context, OverloadDecl, SourceLocation(),
-                            SourceLocation(), nullptr, ParamType,
-                            /*TInfo=*/nullptr, SC_None, nullptr);
+                                SourceLocation(), nullptr, ParamType,
+                                /*TInfo=*/nullptr, SC_None, nullptr);
     Parm->setScopeInfo(0, i);
     Params.push_back(Parm);
   }
@@ -6653,6 +6668,7 @@ tryImplicitlyCaptureThisIfImplicitMemberFunctionAccessWithDependentArgs(
   if (!enclosingClassIsRelatedToClassInWhichMembersWereFound(UME, S))
     return;
 
+
   DeclContext *EnclosingFunctionCtx = S.CurContext->getParent()->getParent();
   // If the enclosing function is not dependent, then this lambda is
   // capture ready, so if we can capture this, do so.
@@ -6761,8 +6777,7 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc,
                                bool AllowRecovery) {
   // Since this might be a postfix expression, get rid of ParenListExprs.
   ExprResult Result = MaybeConvertParenListExprToParenExpr(Scope, Fn);
-  if (Result.isInvalid())
-    return ExprError();
+  if (Result.isInvalid()) return ExprError();
   Fn = Result.get();
 
   // The __builtin_amdgcn_is_invocable builtin is special, and will be resolved
@@ -6807,8 +6822,7 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc,
     }
     if (Fn->getType() == Context.PseudoObjectTy) {
       ExprResult result = CheckPlaceholderExpr(Fn);
-      if (result.isInvalid())
-        return ExprError();
+      if (result.isInvalid()) return ExprError();
       Fn = result.get();
     }
 
@@ -6846,8 +6860,7 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc,
 
     if (Fn->getType() == Context.UnknownAnyTy) {
       ExprResult result = rebuildUnknownAnyFunction(*this, Fn);
-      if (result.isInvalid())
-        return ExprError();
+      if (result.isInvalid()) return ExprError();
       Fn = result.get();
     }
 
@@ -6881,8 +6894,7 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc,
   // If we're directly calling a function, get the appropriate declaration.
   if (Fn->getType() == Context.UnknownAnyTy) {
     ExprResult result = rebuildUnknownAnyFunction(*this, Fn);
-    if (result.isInvalid())
-      return ExprError();
+    if (result.isInvalid()) return ExprError();
     Fn = result.get();
   }
 
@@ -6941,7 +6953,7 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc,
     // type.
     if (getLangOpts().HIP && FD && FD->getBuiltinID()) {
       for (unsigned Idx = 0; Idx < ArgExprs.size() && Idx < FD->param_size();
-           ++Idx) {
+          ++Idx) {
         ParmVarDecl *Param = FD->getParamDecl(Idx);
         if (!ArgExprs[Idx] || !Param || !Param->getType()->isPointerType() ||
             !ArgExprs[Idx]->getType()->isPointerType())
@@ -6954,14 +6966,10 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc,
 
         // Add address space cast if target address spaces are different
         bool NeedImplicitASC =
-            ParamAS != LangAS::Default && // Pointer params in generic AS don't
-                                          // need special handling.
-            (ArgAS ==
-                 LangAS::Default || // We do allow implicit conversion from
-                                    // generic AS or from specific AS which has
-                                    // target AS matching that of Param.
-             getASTContext().getTargetAddressSpace(ArgAS) ==
-                 getASTContext().getTargetAddressSpace(ParamAS));
+          ParamAS != LangAS::Default &&       // Pointer params in generic AS don't need special handling.
+          ( ArgAS == LangAS::Default  ||      // We do allow implicit conversion from generic AS
+                                              // or from specific AS which has target AS matching that of Param.
+          getASTContext().getTargetAddressSpace(ArgAS) == getASTContext().getTargetAddressSpace(ParamAS));
         if (!NeedImplicitASC)
           continue;
 
@@ -6978,8 +6986,9 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation LParenLoc,
         ArgPtQuals.setAddressSpace(ParamAS);
         auto NewArgPtTy =
             Context.getQualifiedType(ArgPtTy.getUnqualifiedType(), ArgPtQuals);
-        auto NewArgTy = Context.getQualifiedType(
-            Context.getPointerType(NewArgPtTy), ArgTy.getQualifiers());
+        auto NewArgTy =
+            Context.getQualifiedType(Context.getPointerType(NewArgPtTy),
+                                     ArgTy.getQualifiers());
 
         // Finally perform an implicit address space cast
         ArgExprs[Idx] = ImpCastExprToType(ArgExprs[Idx], NewArgTy,
@@ -7206,8 +7215,7 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
     if (Config) {
       // CUDA: Kernel calls must be to global functions
       if (FDecl && !FDecl->hasAttr<CUDAGlobalAttr>())
-        return ExprError(
-            Diag(LParenLoc, diag::err_kern_call_not_global_function)
+        return ExprError(Diag(LParenLoc,diag::err_kern_call_not_global_function)
             << FDecl << Fn->getSourceRange());
 
       // CUDA: Kernel function must have 'void' return type
@@ -7215,12 +7223,12 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
           !FuncT->getReturnType()->getAs<AutoType>() &&
           !FuncT->getReturnType()->isInstantiationDependentType())
         return ExprError(Diag(LParenLoc, diag::err_kern_type_not_void_return)
-                         << Fn->getType() << Fn->getSourceRange());
+            << Fn->getType() << Fn->getSourceRange());
     } else {
       // CUDA: Calls to global functions must be configured
       if (FDecl && FDecl->hasAttr<CUDAGlobalAttr>())
         return ExprError(Diag(LParenLoc, diag::err_global_call_not_config)
-                         << FDecl << Fn->getSourceRange());
+            << FDecl << Fn->getSourceRange());
     }
   }
 
@@ -7256,11 +7264,9 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
       const FunctionDecl *Def = nullptr;
       if (FDecl->hasBody(Def) && Args.size() != Def->param_size()) {
         Proto = Def->getType()->getAs<FunctionProtoType>();
-        if (!Proto ||
-            !(Proto->isVariadic() && Args.size() >= Def->param_size()))
+       if (!Proto || !(Proto->isVariadic() && Args.size() >= Def->param_size()))
           Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments)
-              << (Args.size() > Def->param_size()) << FDecl
-              << Fn->getSourceRange();
+          << (Args.size() > Def->param_size()) << FDecl << Fn->getSourceRange();
       }
 
       // If the function we're calling isn't a function prototype, but we have
@@ -7359,9 +7365,9 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
   return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall), FDecl);
 }
 
-ExprResult Sema::ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty,
-                                      SourceLocation RParenLoc,
-                                      Expr *InitExpr) {
+ExprResult
+Sema::ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty,
+                           SourceLocation RParenLoc, Expr *InitExpr) {
   assert(Ty && "ActOnCompoundLiteral(): missing type");
   assert(InitExpr && "ActOnCompoundLiteral(): missing expression");
 
@@ -7373,10 +7379,9 @@ ExprResult Sema::ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty,
   return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, InitExpr);
 }
 
-ExprResult Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc,
-                                          TypeSourceInfo *TInfo,
-                                          SourceLocation RParenLoc,
-                                          Expr *LiteralExpr) {
+ExprResult
+Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo,
+                               SourceLocation RParenLoc, Expr *LiteralExpr) {
   QualType literalType = TInfo->getType();
 
   if (literalType->isArrayType()) {
@@ -7412,21 +7417,20 @@ ExprResult Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc,
         return ExprError();
     }
   } else if (!literalType->isDependentType() &&
-             RequireCompleteType(
-                 LParenLoc, literalType,
-                 diag::err_typecheck_decl_incomplete_type,
-                 SourceRange(LParenLoc,
-                             LiteralExpr->getSourceRange().getEnd())))
+             RequireCompleteType(LParenLoc, literalType,
+               diag::err_typecheck_decl_incomplete_type,
+               SourceRange(LParenLoc, LiteralExpr->getSourceRange().getEnd())))
     return ExprError();
 
-  InitializedEntity Entity =
-      InitializedEntity::InitializeCompoundLiteralInit(TInfo);
-  InitializationKind Kind = InitializationKind::CreateCStyleCast(
-      LParenLoc, SourceRange(LParenLoc, RParenLoc),
-      /*InitList=*/true);
+  InitializedEntity Entity
+    = InitializedEntity::InitializeCompoundLiteralInit(TInfo);
+  InitializationKind Kind
+    = InitializationKind::CreateCStyleCast(LParenLoc,
+                                           SourceRange(LParenLoc, RParenLoc),
+                                           /*InitList=*/true);
   InitializationSequence InitSeq(*this, Entity, Kind, LiteralExpr);
-  ExprResult Result =
-      InitSeq.Perform(*this, Entity, Kind, LiteralExpr, &literalType);
+  ExprResult Result = InitSeq.Perform(*this, Entity, Kind, LiteralExpr,
+                                      &literalType);
   if (Result.isInvalid())
     return ExprError();
   LiteralExpr = Result.get();
@@ -7483,7 +7487,8 @@ ExprResult Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc,
   auto *E = new (Context) CompoundLiteralExpr(LParenLoc, TInfo, literalType, VK,
                                               LiteralExpr, IsFileScope);
   if (IsFileScope) {
-    if (!LiteralExpr->isTypeDependent() && !LiteralExpr->isValueDependent() &&
+    if (!LiteralExpr->isTypeDependent() &&
+        !LiteralExpr->isValueDependent() &&
         !literalType->isDependentType()) // C99 6.5.2.5p3
       if (CheckForConstantInitializer(LiteralExpr))
         return ExprError();
@@ -7493,7 +7498,7 @@ ExprResult Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc,
     //   "If the compound literal occurs inside the body of a function, the
     //   type name shall not be qualified by an address-space qualifier."
     Diag(LParenLoc, diag::err_compound_literal_with_address_space)
-        << SourceRange(LParenLoc, LiteralExpr->getSourceRange().getEnd());
+      << SourceRange(LParenLoc, LiteralExpr->getSourceRange().getEnd());
     return ExprError();
   }
 
@@ -7524,9 +7529,9 @@ ExprResult Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc,
   return MaybeBindToTemporary(E);
 }
 
-ExprResult Sema::ActOnInitList(SourceLocation LBraceLoc,
-                               MultiExprArg InitArgList,
-                               SourceLocation RBraceLoc) {
+ExprResult
+Sema::ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
+                    SourceLocation RBraceLoc) {
   // Only produce each kind of designated initialization diagnostic once.
   SourceLocation FirstDesignator;
   bool DiagnosedArrayDesignator = false;
@@ -7546,14 +7551,14 @@ ExprResult Sema::ActOnInitList(SourceLocation LBraceLoc,
       if (!DiagnosedNestedDesignator && DIE->size() > 1) {
         DiagnosedNestedDesignator = true;
         Diag(DIE->getBeginLoc(), diag::ext_designated_init_nested)
-            << DIE->getDesignatorsSourceRange();
+          << DIE->getDesignatorsSourceRange();
       }
 
       for (auto &Desig : DIE->designators()) {
         if (!Desig.isFieldDesignator() && !DiagnosedArrayDesignator) {
           DiagnosedArrayDesignator = true;
           Diag(Desig.getBeginLoc(), diag::ext_designated_init_array)
-              << Desig.getSourceRange();
+            << Desig.getSourceRange();
         }
       }
 
@@ -7561,18 +7566,18 @@ ExprResult Sema::ActOnInitList(SourceLocation LBraceLoc,
           !isa<DesignatedInitExpr>(InitArgList[0])) {
         DiagnosedMixedDesignator = true;
         Diag(DIE->getBeginLoc(), diag::ext_designated_init_mixed)
-            << DIE->getSourceRange();
+          << DIE->getSourceRange();
         Diag(InitArgList[0]->getBeginLoc(), diag::note_designated_init_mixed)
-            << InitArgList[0]->getSourceRange();
+          << InitArgList[0]->getSourceRange();
       }
     } else if (getLangOpts().CPlusPlus && !DiagnosedMixedDesignator &&
                isa<DesignatedInitExpr>(InitArgList[0])) {
       DiagnosedMixedDesignator = true;
       auto *DIE = cast<DesignatedInitExpr>(InitArgList[0]);
       Diag(DIE->getBeginLoc(), diag::ext_designated_init_mixed)
-          << DIE->getSourceRange();
+        << DIE->getSourceRange();
       Diag(InitArgList[I]->getBeginLoc(), diag::note_designated_init_mixed)
-          << InitArgList[I]->getSourceRange();
+        << InitArgList[I]->getSourceRange();
     }
   }
 
@@ -7592,9 +7597,9 @@ ExprResult Sema::ActOnInitList(SourceLocation LBraceLoc,
   return BuildInitList(LBraceLoc, InitArgList, RBraceLoc);
 }
 
-ExprResult Sema::BuildInitList(SourceLocation LBraceLoc,
-                               MultiExprArg InitArgList,
-                               SourceLocation RBraceLoc) {
+ExprResult
+Sema::BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList,
+                    SourceLocation RBraceLoc) {
   // Semantic analysis for initializers is done by ActOnDeclarator() and
   // CheckInitializer() - it requires knowledge of the object being initialized.
 
@@ -7606,8 +7611,7 @@ ExprResult Sema::BuildInitList(SourceLocation LBraceLoc,
 
       // Ignore failures; dropping the entire initializer list because
       // of one failure would be terrible for indexing/etc.
-      if (result.isInvalid())
-        continue;
+      if (result.isInvalid()) continue;
 
       InitArgList[I] = result.get();
     }
@@ -7624,8 +7628,7 @@ void Sema::maybeExtendBlockObject(ExprResult &E) {
   assert(E.get()->isPRValue());
 
   // Only do this in an r-value context.
-  if (!getLangOpts().ObjCAutoRefCount)
-    return;
+  if (!getLangOpts().ObjCAutoRefCount) return;
 
   E = ImplicitCastExpr::Create(
       Context, E.get()->getType(), CK_ARCExtendBlockObject, E.get(),
@@ -7661,8 +7664,7 @@ CastKind Sema::PrepareScalarCast(ExprResult &Src, QualType DestTy) {
     }
     case Type::STK_BlockPointer:
       return (SrcKind == Type::STK_BlockPointer
-                  ? CK_BitCast
-                  : CK_AnyPointerToBlockPointerCast);
+                ? CK_BitCast : CK_AnyPointerToBlockPointerCast);
     case Type::STK_ObjCObjectPointer:
       if (SrcKind == Type::STK_ObjCObjectPointer)
         return CK_BitCast;
@@ -7725,13 +7727,13 @@ CastKind Sema::PrepareScalarCast(ExprResult &Src, QualType DestTy) {
       return CK_IntegralToFloating;
     case Type::STK_IntegralComplex:
       Src = ImpCastExprToType(Src.get(),
-                              DestTy->castAs<ComplexType>()->getElementType(),
-                              CK_IntegralCast);
+                      DestTy->castAs<ComplexType>()->getElementType(),
+                      CK_IntegralCast);
       return CK_IntegralRealToComplex;
     case Type::STK_FloatingComplex:
       Src = ImpCastExprToType(Src.get(),
-                              DestTy->castAs<ComplexType>()->getElementType(),
-                              CK_IntegralToFloating);
+                      DestTy->castAs<ComplexType>()->getElementType(),
+                      CK_IntegralToFloating);
       return CK_FloatingRealToComplex;
     case Type::STK_MemberPointer:
       llvm_unreachable("member pointer type in C");
@@ -7853,8 +7855,7 @@ static bool breakDownVectorType(QualType type, uint64_t &len,
 
   // We allow lax conversion to and from non-vector types, but only if
   // they're real types (i.e. non-complex, non-pointer scalar types).
-  if (!type->isRealType())
-    return false;
+  if (!type->isRealType()) return false;
 
   len = 1;
   eltType = type;
@@ -7937,10 +7938,8 @@ bool Sema::areLaxCompatibleVectorTypes(QualType srcTy, QualType destTy) {
   // depend on them).  Most scalar OP ExtVector cases are handled by the
   // splat path anyway, which does what we want (convert, not bitcast).
   // What this rules out for ExtVectors is crazy things like char4*float.
-  if (srcTy->isScalarType() && destTy->isExtVectorType())
-    return false;
-  if (destTy->isScalarType() && srcTy->isExtVectorType())
-    return false;
+  if (srcTy->isScalarType() && destTy->isExtVectorType()) return false;
+  if (destTy->isScalarType() && srcTy->isExtVectorType()) return false;
 
   return areVectorTypesSameSize(srcTy, destTy);
 }
@@ -7966,7 +7965,7 @@ bool Sema::isLaxVectorConversion(QualType srcTy, QualType destTy) {
     // OK, integer (vector) -> integer (vector) bitcast.
     break;
 
-  case LangOptions::LaxVectorConversionKind::All:
+    case LangOptions::LaxVectorConversionKind::All:
     break;
   }
 
@@ -8001,14 +8000,14 @@ bool Sema::CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty,
   if (Ty->isVectorType() || Ty->isIntegralType(Context)) {
     if (!areLaxCompatibleVectorTypes(Ty, VectorTy))
       return Diag(R.getBegin(),
-                  Ty->isVectorType()
-                      ? diag::err_invalid_conversion_between_vectors
-                      : diag::err_invalid_conversion_between_vector_and_integer)
-             << VectorTy << Ty << R;
+                  Ty->isVectorType() ?
+                  diag::err_invalid_conversion_between_vectors :
+                  diag::err_invalid_conversion_between_vector_and_integer)
+        << VectorTy << Ty << R;
   } else
     return Diag(R.getBegin(),
                 diag::err_invalid_conversion_between_vector_and_scalar)
-           << VectorTy << Ty << R;
+      << VectorTy << Ty << R;
 
   Kind = CK_BitCast;
   return false;
@@ -8080,8 +8079,8 @@ ExprResult Sema::CheckExtVectorCast(SourceRange R, QualType DestTy,
         (getLangOpts().OpenCL &&
          !Context.hasSameUnqualifiedType(DestTy, SrcTy) &&
          !Context.areCompatibleVectorTypes(DestTy, SrcTy))) {
-      Diag(R.getBegin(), diag::err_invalid_conversion_between_ext_vectors)
-          << DestTy << SrcTy << R;
+      Diag(R.getBegin(),diag::err_invalid_conversion_between_ext_vectors)
+        << DestTy << SrcTy << R;
       return ExprError();
     }
     Kind = CK_BitCast;
@@ -8094,7 +8093,7 @@ ExprResult Sema::CheckExtVectorCast(SourceRange R, QualType DestTy,
   if (SrcTy->isPointerType())
     return Diag(R.getBegin(),
                 diag::err_invalid_conversion_between_vector_and_scalar)
-           << DestTy << SrcTy << R;
+      << DestTy << SrcTy << R;
 
   Kind = CK_VectorSplat;
   return prepareVectorSplat(DestTy, CastExpr);
@@ -8135,9 +8134,10 @@ static void CheckSufficientAllocSize(Sema &S, QualType DestType,
         << Size.getQuantity() << TargetType << LhsSize->getQuantity();
 }
 
-ExprResult Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
-                               Declarator &D, ParsedType &Ty,
-                               SourceLocation RParenLoc, Expr *CastExpr) {
+ExprResult
+Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
+                    Declarator &D, ParsedType &Ty,
+                    SourceLocation RParenLoc, Expr *CastExpr) {
   assert(!D.isInvalidType() && (CastExpr != nullptr) &&
          "ActOnCastExpr(): missing type or expr");
 
@@ -8161,9 +8161,8 @@ ExprResult Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
   // i.e. all the elements are integer constants.
   ParenExpr *PE = dyn_cast<ParenExpr>(CastExpr);
   ParenListExpr *PLE = dyn_cast<ParenListExpr>(CastExpr);
-  if ((getLangOpts().AltiVec || getLangOpts().ZVector ||
-       getLangOpts().OpenCL) &&
-      castType->isVectorType() && (PE || PLE)) {
+  if ((getLangOpts().AltiVec || getLangOpts().ZVector || getLangOpts().OpenCL)
+       && castType->isVectorType() && (PE || PLE)) {
     if (PLE && PLE->getNumExprs() == 0) {
       Diag(PLE->getExprLoc(), diag::err_altivec_empty_initializer);
       return ExprError();
@@ -8172,7 +8171,8 @@ ExprResult Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
       Expr *E = (PE ? PE->getSubExpr() : PLE->getExpr(0));
       if (!E->isTypeDependent() && !E->getType()->isVectorType())
         isVectorLiteral = true;
-    } else
+    }
+    else
       isVectorLiteral = true;
   }
 
@@ -8186,8 +8186,7 @@ ExprResult Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
   // sequence of BinOp comma operators.
   if (isa<ParenListExpr>(CastExpr)) {
     ExprResult Result = MaybeConvertParenListExprToParenExpr(S, CastExpr);
-    if (Result.isInvalid())
-      return ExprError();
+    if (Result.isInvalid()) return ExprError();
     CastExpr = Result.get();
   }
 
@@ -8254,12 +8253,16 @@ ExprResult Sema::BuildVectorLiteral(SourceLocation LParenLoc,
       Literal = ImpCastExprToType(Literal.get(), ElemTy,
                                   PrepareScalarCast(Literal, ElemTy));
       return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.get());
-    } else if (numExprs < numElems) {
-      Diag(E->getExprLoc(), diag::err_incorrect_number_of_vector_initializers);
+    }
+    else if (numExprs < numElems) {
+      Diag(E->getExprLoc(),
+           diag::err_incorrect_number_of_vector_initializers);
       return ExprError();
-    } else
+    }
+    else
       initExprs.append(exprs, exprs + numExprs);
-  } else {
+  }
+  else {
     // For OpenCL, when the number of initializers is a single value,
     // it will be replicated to all components of the vector.
     if (getLangOpts().OpenCL && VTy->getVectorKind() == VectorKind::Generic &&
@@ -8284,14 +8287,14 @@ ExprResult Sema::BuildVectorLiteral(SourceLocation LParenLoc,
   }
   // FIXME: This means that pretty-printing the final AST will produce curly
   // braces instead of the original commas.
-  InitListExpr *initE = new (Context)
-      InitListExpr(Context, LiteralLParenLoc, initExprs, LiteralRParenLoc);
+  InitListExpr *initE = new (Context) InitListExpr(Context, LiteralLParenLoc,
+                                                   initExprs, LiteralRParenLoc);
   initE->setType(Ty);
   return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, initE);
 }
 
-ExprResult Sema::MaybeConvertParenListExprToParenExpr(Scope *S,
-                                                      Expr *OrigExpr) {
+ExprResult
+Sema::MaybeConvertParenListExprToParenExpr(Scope *S, Expr *OrigExpr) {
   ParenListExpr *E = dyn_cast<ParenListExpr>(OrigExpr);
   if (!E)
     return OrigExpr;
@@ -8299,16 +8302,16 @@ ExprResult Sema::MaybeConvertParenListExprToParenExpr(Scope *S,
   ExprResult Result(E->getExpr(0));
 
   for (unsigned i = 1, e = E->getNumExprs(); i != e && !Result.isInvalid(); ++i)
-    Result =
-        ActOnBinOp(S, E->getExprLoc(), tok::comma, Result.get(), E->getExpr(i));
+    Result = ActOnBinOp(S, E->getExprLoc(), tok::comma, Result.get(),
+                        E->getExpr(i));
 
-  if (Result.isInvalid())
-    return ExprError();
+  if (Result.isInvalid()) return ExprError();
 
   return ActOnParenExpr(E->getLParenLoc(), E->getRParenLoc(), Result.get());
 }
 
-ExprResult Sema::ActOnParenListExpr(SourceLocation L, SourceLocation R,
+ExprResult Sema::ActOnParenListExpr(SourceLocation L,
+                                    SourceLocation R,
                                     MultiExprArg Val) {
   return ParenListExpr::Create(Context, L, Val, R);
 }
@@ -8326,14 +8329,16 @@ bool Sema::DiagnoseConditionalForNull(const Expr *LHSExpr, const Expr *RHSExpr,
                                       SourceLocation QuestionLoc) {
   const Expr *NullExpr = LHSExpr;
   const Expr *NonPointerExpr = RHSExpr;
-  Expr::NullPointerConstantKind NullKind = NullExpr->isNullPointerConstant(
-      Context, Expr::NPC_ValueDependentIsNotNull);
+  Expr::NullPointerConstantKind NullKind =
+      NullExpr->isNullPointerConstant(Context,
+                                      Expr::NPC_ValueDependentIsNotNull);
 
   if (NullKind == Expr::NPCK_NotNull) {
     NullExpr = RHSExpr;
     NonPointerExpr = LHSExpr;
-    NullKind = NullExpr->isNullPointerConstant(
-        Context, Expr::NPC_ValueDependentIsNotNull);
+    NullKind =
+        NullExpr->isNullPointerConstant(Context,
+                                        Expr::NPC_ValueDependentIsNotNull);
   }
 
   if (NullKind == Expr::NPCK_NotNull)
@@ -8366,16 +8371,15 @@ static bool checkCondition(Sema &S, const Expr *Cond,
   // OpenCL v1.1 s6.3.i says the condition cannot be a floating point type.
   if (S.getLangOpts().OpenCL && CondTy->isFloatingType()) {
     S.Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
-        << CondTy << Cond->getSourceRange();
+      << CondTy << Cond->getSourceRange();
     return true;
   }
 
   // C99 6.5.15p2
-  if (CondTy->isScalarType())
-    return false;
+  if (CondTy->isScalarType()) return false;
 
   S.Diag(QuestionLoc, diag::err_typecheck_cond_expect_scalar)
-      << CondTy << Cond->getSourceRange();
+    << CondTy << Cond->getSourceRange();
   return true;
 }
 
@@ -8385,7 +8389,7 @@ static bool checkConditionalNullPointer(Sema &S, ExprResult &NullExpr,
                                         QualType PointerTy) {
   if ((!PointerTy->isAnyPointerType() && !PointerTy->isBlockPointerType()) ||
       !NullExpr.get()->isNullPointerConstant(S.Context,
-                                             Expr::NPC_ValueDependentIsNull))
+                                            Expr::NPC_ValueDependentIsNull))
     return true;
 
   NullExpr = S.ImpCastExprToType(NullExpr.get(), PointerTy, CK_NullToPointer);
@@ -8447,8 +8451,7 @@ static QualType checkConditionalPointerCompatibility(Sema &S, ExprResult &LHS,
     return QualType();
   }
 
-  unsigned MergedCVRQual =
-      lhQual.getCVRQualifiers() | rhQual.getCVRQualifiers();
+  unsigned MergedCVRQual = lhQual.getCVRQualifiers() | rhQual.getCVRQualifiers();
   auto LHSCastKind = CK_BitCast, RHSCastKind = CK_BitCast;
   lhQual.removeCVRQualifiers();
   rhQual.removeCVRQualifiers();
@@ -8548,8 +8551,8 @@ static QualType checkConditionalBlockPointerCompatibility(Sema &S,
       return destType;
     }
     S.Diag(Loc, diag::err_typecheck_cond_incompatible_operands)
-        << LHSTy << RHSTy << LHS.get()->getSourceRange()
-        << RHS.get()->getSourceRange();
+      << LHSTy << RHSTy << LHS.get()->getSourceRange()
+      << RHS.get()->getSourceRange();
     return QualType();
   }
 
@@ -8558,8 +8561,10 @@ static QualType checkConditionalBlockPointerCompatibility(Sema &S,
 }
 
 /// Return the resulting type when the operands are both pointers.
-static QualType checkConditionalObjectPointersCompatibility(
-    Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc) {
+static QualType
+checkConditionalObjectPointersCompatibility(Sema &S, ExprResult &LHS,
+                                            ExprResult &RHS,
+                                            SourceLocation Loc) {
   // get the pointer types
   QualType LHSTy = LHS.get()->getType();
   QualType RHSTy = RHS.get()->getType();
@@ -8571,8 +8576,8 @@ static QualType checkConditionalObjectPointersCompatibility(
   // ignore qualifiers on void (C99 6.5.15p3, clause 6)
   if (lhptee->isVoidType() && rhptee->isIncompleteOrObjectType()) {
     // Figure out necessary qualifiers (C99 6.5.15p6)
-    QualType destPointee =
-        S.Context.getQualifiedType(lhptee, rhptee.getQualifiers());
+    QualType destPointee
+      = S.Context.getQualifiedType(lhptee, rhptee.getQualifiers());
     QualType destType = S.Context.getPointerType(destPointee);
     // Add qualifiers if necessary.
     LHS = S.ImpCastExprToType(LHS.get(), destType, CK_NoOp);
@@ -8581,8 +8586,8 @@ static QualType checkConditionalObjectPointersCompatibility(
     return destType;
   }
   if (rhptee->isVoidType() && lhptee->isIncompleteOrObjectType()) {
-    QualType destPointee =
-        S.Context.getQualifiedType(rhptee, lhptee.getQualifiers());
+    QualType destPointee
+      = S.Context.getQualifiedType(rhptee, lhptee.getQualifiers());
     QualType destType = S.Context.getPointerType(destPointee);
     // Add qualifiers if necessary.
     RHS = S.ImpCastExprToType(RHS.get(), destType, CK_NoOp);
@@ -8597,7 +8602,7 @@ static QualType checkConditionalObjectPointersCompatibility(
 /// Return false if the first expression is not an integer and the second
 /// expression is not a pointer, true otherwise.
 static bool checkPointerIntegerMismatch(Sema &S, ExprResult &Int,
-                                        Expr *PointerExpr, SourceLocation Loc,
+                                        Expr* PointerExpr, SourceLocation Loc,
                                         bool IsIntFirstExpr) {
   if (!PointerExpr->getType()->isPointerType() ||
       !Int.get()->getType()->isIntegerType())
@@ -8607,8 +8612,8 @@ static bool checkPointerIntegerMismatch(Sema &S, ExprResult &Int,
   Expr *Expr2 = IsIntFirstExpr ? PointerExpr : Int.get();
 
   S.Diag(Loc, diag::ext_typecheck_cond_pointer_integer_mismatch)
-      << Expr1->getType() << Expr2->getType() << Expr1->getSourceRange()
-      << Expr2->getSourceRange();
+    << Expr1->getType() << Expr2->getType()
+    << Expr1->getSourceRange() << Expr2->getSourceRange();
   Int = S.ImpCastExprToType(Int.get(), PointerExpr->getType(),
                             CK_IntegralToPointer);
   return true;
@@ -8639,19 +8644,19 @@ static QualType OpenCLArithmeticConversions(Sema &S, ExprResult &LHS,
   // For conversion purposes, we ignore any qualifiers.
   // For example, "const float" and "float" are equivalent.
   QualType LHSType =
-      S.Context.getCanonicalType(LHS.get()->getType()).getUnqualifiedType();
+    S.Context.getCanonicalType(LHS.get()->getType()).getUnqualifiedType();
   QualType RHSType =
-      S.Context.getCanonicalType(RHS.get()->getType()).getUnqualifiedType();
+    S.Context.getCanonicalType(RHS.get()->getType()).getUnqualifiedType();
 
   if (!LHSType->isIntegerType() && !LHSType->isRealFloatingType()) {
     S.Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
-        << LHSType << LHS.get()->getSourceRange();
+      << LHSType << LHS.get()->getSourceRange();
     return QualType();
   }
 
   if (!RHSType->isIntegerType() && !RHSType->isRealFloatingType()) {
     S.Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
-        << RHSType << RHS.get()->getSourceRange();
+      << RHSType << RHS.get()->getSourceRange();
     return QualType();
   }
 
@@ -8665,8 +8670,8 @@ static QualType OpenCLArithmeticConversions(Sema &S, ExprResult &LHS,
                                  /*IsCompAssign = */ false);
 
   // Finally, we have two differing integer types.
-  return handleIntegerConversion<doIntegralCast, doIntegralCast>(
-      S, LHS, RHS, LHSType, RHSType, /*IsCompAssign = */ false);
+  return handleIntegerConversion<doIntegralCast, doIntegralCast>
+  (S, LHS, RHS, LHSType, RHSType, /*IsCompAssign = */ false);
 }
 
 /// Convert scalar operands to a vector that matches the
@@ -8680,12 +8685,11 @@ static QualType OpenCLArithmeticConversions(Sema &S, ExprResult &LHS,
 /// into a vector of that type where the length matches the condition
 /// vector type. s6.11.6 requires that the element types of the result
 /// and the condition must have the same number of bits.
-static QualType OpenCLConvertScalarsToVectors(Sema &S, ExprResult &LHS,
-                                              ExprResult &RHS, QualType CondTy,
-                                              SourceLocation QuestionLoc) {
+static QualType
+OpenCLConvertScalarsToVectors(Sema &S, ExprResult &LHS, ExprResult &RHS,
+                              QualType CondTy, SourceLocation QuestionLoc) {
   QualType ResTy = OpenCLArithmeticConversions(S, LHS, RHS, QuestionLoc);
-  if (ResTy.isNull())
-    return QualType();
+  if (ResTy.isNull()) return QualType();
 
   const VectorType *CV = CondTy->getAs<VectorType>();
   assert(CV);
@@ -8695,8 +8699,8 @@ static QualType OpenCLConvertScalarsToVectors(Sema &S, ExprResult &LHS,
   QualType VectorTy = S.Context.getExtVectorType(ResTy, NumElements);
 
   // Ensure that all types have the same number of bits
-  if (S.Context.getTypeSize(CV->getElementType()) !=
-      S.Context.getTypeSize(ResTy)) {
+  if (S.Context.getTypeSize(CV->getElementType())
+      != S.Context.getTypeSize(ResTy)) {
     // Since VectorTy is created internally, it does not pretty print
     // with an OpenCL name. Instead, we just print a description.
     std::string EleTyName = ResTy.getUnqualifiedType().getAsString();
@@ -8704,7 +8708,7 @@ static QualType OpenCLConvertScalarsToVectors(Sema &S, ExprResult &LHS,
     llvm::raw_svector_ostream OS(Str);
     OS << "(vector of " << NumElements << " '" << EleTyName << "' values)";
     S.Diag(QuestionLoc, diag::err_conditional_vector_element_size)
-        << CondTy << OS.str();
+      << CondTy << OS.str();
     return QualType();
   }
 
@@ -8723,11 +8727,10 @@ static bool checkOpenCLConditionVector(Sema &S, Expr *Cond,
   const VectorType *CondTy = Cond->getType()->getAs<VectorType>();
   assert(CondTy);
   QualType EleTy = CondTy->getElementType();
-  if (EleTy->isIntegerType())
-    return false;
+  if (EleTy->isIntegerType()) return false;
 
   S.Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
-      << Cond->getType() << Cond->getSourceRange();
+    << Cond->getType() << Cond->getSourceRange();
   return true;
 }
 
@@ -8745,7 +8748,7 @@ static bool checkVectorResult(Sema &S, QualType CondTy, QualType VecResTy,
 
   if (CV->getNumElements() != RV->getNumElements()) {
     S.Diag(QuestionLoc, diag::err_conditional_vector_size)
-        << CondTy << VecResTy;
+      << CondTy << VecResTy;
     return true;
   }
 
@@ -8766,9 +8769,10 @@ static bool checkVectorResult(Sema &S, QualType CondTy, QualType VecResTy,
 /// Return the resulting type for the conditional operator in
 ///        OpenCL (aka "ternary selection operator", OpenCL v1.1
 ///        s6.3.i) when the condition is a vector type.
-static QualType OpenCLCheckVectorConditional(Sema &S, ExprResult &Cond,
-                                             ExprResult &LHS, ExprResult &RHS,
-                                             SourceLocation QuestionLoc) {
+static QualType
+OpenCLCheckVectorConditional(Sema &S, ExprResult &Cond,
+                             ExprResult &LHS, ExprResult &RHS,
+                             SourceLocation QuestionLoc) {
   Cond = S.DefaultFunctionArrayLvalueConversion(Cond.get());
   if (Cond.isInvalid())
     return QualType();
@@ -8829,13 +8833,11 @@ QualType Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS,
                                         SourceLocation QuestionLoc) {
 
   ExprResult LHSResult = CheckPlaceholderExpr(LHS.get());
-  if (!LHSResult.isUsable())
-    return QualType();
+  if (!LHSResult.isUsable()) return QualType();
   LHS = LHSResult;
 
   ExprResult RHSResult = CheckPlaceholderExpr(RHS.get());
-  if (!RHSResult.isUsable())
-    return QualType();
+  if (!RHSResult.isUsable()) return QualType();
   RHS = RHSResult;
 
   // C++ is sufficiently different to merit its own checker.
@@ -8894,16 +8896,16 @@ QualType Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS,
   // Diagnose attempts to convert between __ibm128, __float128 and long double
   // where such conversions currently can't be handled.
   if (unsupportedTypeConversion(*this, LHSTy, RHSTy)) {
-    Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
-        << LHSTy << RHSTy << LHS.get()->getSourceRange()
-        << RHS.get()->getSourceRange();
+    Diag(QuestionLoc,
+         diag::err_typecheck_cond_incompatible_operands) << LHSTy << RHSTy
+      << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
     return QualType();
   }
 
   // OpenCL v2.0 s6.12.5 - Blocks cannot be used as expressions of the ternary
   // selection operator (?:).
-  if (getLangOpts().OpenCL && ((int)checkBlockType(*this, LHS.get()) |
-                               (int)checkBlockType(*this, RHS.get()))) {
+  if (getLangOpts().OpenCL &&
+      ((int)checkBlockType(*this, LHS.get()) | (int)checkBlockType(*this, RHS.get()))) {
     return QualType();
   }
 
@@ -8962,10 +8964,8 @@ QualType Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS,
 
   // C99 6.5.15p6 - "if one operand is a null pointer constant, the result has
   // the type of the other operand."
-  if (!checkConditionalNullPointer(*this, RHS, LHSTy))
-    return LHSTy;
-  if (!checkConditionalNullPointer(*this, LHS, RHSTy))
-    return RHSTy;
+  if (!checkConditionalNullPointer(*this, RHS, LHSTy)) return LHSTy;
+  if (!checkConditionalNullPointer(*this, LHS, RHSTy)) return RHSTy;
 
   // All objective-c pointer type analysis is done here.
   QualType compositeType =
@@ -8975,6 +8975,7 @@ QualType Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS,
   if (!compositeType.isNull())
     return compositeType;
 
+
   // Handle block pointer types.
   if (LHSTy->isBlockPointerType() || RHSTy->isBlockPointerType())
     return checkConditionalBlockPointerCompatibility(*this, LHS, RHS,
@@ -8988,10 +8989,10 @@ QualType Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS,
   // GCC compatibility: soften pointer/integer mismatch.  Note that
   // null pointers have been filtered out by this point.
   if (checkPointerIntegerMismatch(*this, LHS, RHS.get(), QuestionLoc,
-                                  /*IsIntFirstExpr=*/true))
+      /*IsIntFirstExpr=*/true))
     return RHSTy;
   if (checkPointerIntegerMismatch(*this, RHS, LHS.get(), QuestionLoc,
-                                  /*IsIntFirstExpr=*/false))
+      /*IsIntFirstExpr=*/false))
     return LHSTy;
 
   // Emit a better diagnostic if one of the expressions is a null pointer
@@ -9007,8 +9008,8 @@ QualType Sema::CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS,
 
   // Otherwise, the operands are not compatible.
   Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
-      << LHSTy << RHSTy << LHS.get()->getSourceRange()
-      << RHS.get()->getSourceRange();
+    << LHSTy << RHSTy << LHS.get()->getSourceRange()
+    << RHS.get()->getSourceRange();
   return QualType();
 }
 
@@ -9020,9 +9021,9 @@ static void SuggestParentheses(Sema &Self, SourceLocation Loc,
   SourceLocation EndLoc = Self.getLocForEndOfToken(ParenRange.getEnd());
   if (ParenRange.getBegin().isFileID() && ParenRange.getEnd().isFileID() &&
       EndLoc.isValid()) {
-    Self.Diag(Loc, Note) << FixItHint::CreateInsertion(ParenRange.getBegin(),
-                                                       "(")
-                         << FixItHint::CreateInsertion(EndLoc, ")");
+    Self.Diag(Loc, Note)
+      << FixItHint::CreateInsertion(ParenRange.getBegin(), "(")
+      << FixItHint::CreateInsertion(EndLoc, ")");
   } else {
     // We can't display the parentheses, so just show the bare note.
     Self.Diag(Loc, Note) << ParenRange;
@@ -9071,8 +9072,8 @@ static bool IsArithmeticBinaryExpr(const Expr *E, BinaryOperatorKind *Opcode,
     // Make sure this is really a binary operator that is safe to pass into
     // BinaryOperator::getOverloadedOpcode(), e.g. it's not a subscript op.
     OverloadedOperatorKind OO = Call->getOperator();
-    if (OO < OO_Plus || OO > OO_Arrow || OO == OO_PlusPlus ||
-        OO == OO_MinusMinus)
+    if (OO < OO_Plus || OO > OO_Arrow ||
+        OO == OO_PlusPlus || OO == OO_MinusMinus)
       return false;
 
     BinaryOperatorKind OpKind = BinaryOperator::getOverloadedOpcode(OO);
@@ -9128,8 +9129,9 @@ static void DiagnoseConditionalPrecedence(Sema &Self, SourceLocation OpLoc,
                         ? diag::warn_precedence_bitwise_conditional
                         : diag::warn_precedence_conditional;
 
-  Self.Diag(OpLoc, DiagID) << Condition->getSourceRange()
-                           << BinaryOperator::getOpcodeStr(CondOpcode);
+  Self.Diag(OpLoc, DiagID)
+      << Condition->getSourceRange()
+      << BinaryOperator::getOpcodeStr(CondOpcode);
 
   SuggestParentheses(
       Self, OpLoc,
@@ -9169,7 +9171,7 @@ static QualType computeConditionalNullability(QualType ResTy, bool IsBin,
       MergedKind = NullabilityKind::NonNull;
     else
       MergedKind = RHSKind;
-    // Compute nullability of a normal conditional expression.
+  // Compute nullability of a normal conditional expression.
   } else {
     if (LHSKind == NullabilityKind::Nullable ||
         RHSKind == NullabilityKind::Nullable)
@@ -9195,8 +9197,9 @@ static QualType computeConditionalNullability(QualType ResTy, bool IsBin,
 }
 
 ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc,
-                                    SourceLocation ColonLoc, Expr *CondExpr,
-                                    Expr *LHSExpr, Expr *RHSExpr) {
+                                    SourceLocation ColonLoc,
+                                    Expr *CondExpr, Expr *LHSExpr,
+                                    Expr *RHSExpr) {
   // If this is the gnu "x ?: y" extension, analyze the types as though the LHS
   // was the condition.
   OpaqueValueExpr *opaqueValue = nullptr;
@@ -9208,17 +9211,18 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc,
     // as Objective-C++'s dictionary subscripting syntax.
     if (commonExpr->hasPlaceholderType()) {
       ExprResult result = CheckPlaceholderExpr(commonExpr);
-      if (!result.isUsable())
-        return ExprError();
+      if (!result.isUsable()) return ExprError();
       commonExpr = result.get();
     }
     // We usually want to apply unary conversions *before* saving, except
     // in the special case of a C++ l-value conditional.
-    if (!(getLangOpts().CPlusPlus && !commonExpr->isTypeDependent() &&
-          commonExpr->getValueKind() == RHSExpr->getValueKind() &&
-          commonExpr->isGLValue() && commonExpr->isOrdinaryOrBitFieldObject() &&
-          RHSExpr->isOrdinaryOrBitFieldObject() &&
-          Context.hasSameType(commonExpr->getType(), RHSExpr->getType()))) {
+    if (!(getLangOpts().CPlusPlus
+          && !commonExpr->isTypeDependent()
+          && commonExpr->getValueKind() == RHSExpr->getValueKind()
+          && commonExpr->isGLValue()
+          && commonExpr->isOrdinaryOrBitFieldObject()
+          && RHSExpr->isOrdinaryOrBitFieldObject()
+          && Context.hasSameType(commonExpr->getType(), RHSExpr->getType()))) {
       ExprResult commonRes = UsualUnaryConversions(commonExpr);
       if (commonRes.isInvalid())
         return ExprError();
@@ -9235,9 +9239,11 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc,
       commonExpr = MatExpr.get();
     }
 
-    opaqueValue = new (Context) OpaqueValueExpr(
-        commonExpr->getExprLoc(), commonExpr->getType(),
-        commonExpr->getValueKind(), commonExpr->getObjectKind(), commonExpr);
+    opaqueValue = new (Context) OpaqueValueExpr(commonExpr->getExprLoc(),
+                                                commonExpr->getType(),
+                                                commonExpr->getValueKind(),
+                                                commonExpr->getObjectKind(),
+                                                commonExpr);
     LHSExpr = CondExpr = opaqueValue;
   }
 
@@ -9245,9 +9251,10 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc,
   ExprValueKind VK = VK_PRValue;
   ExprObjectKind OK = OK_Ordinary;
   ExprResult Cond = CondExpr, LHS = LHSExpr, RHS = RHSExpr;
-  QualType result =
-      CheckConditionalOperands(Cond, LHS, RHS, VK, OK, QuestionLoc);
-  if (result.isNull() || Cond.isInvalid() || LHS.isInvalid() || RHS.isInvalid())
+  QualType result = CheckConditionalOperands(Cond, LHS, RHS,
+                                             VK, OK, QuestionLoc);
+  if (result.isNull() || Cond.isInvalid() || LHS.isInvalid() ||
+      RHS.isInvalid())
     return ExprError();
 
   DiagnoseConditionalPrecedence(*this, QuestionLoc, Cond.get(), LHS.get(),
@@ -9255,8 +9262,8 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation QuestionLoc,
 
   CheckBoolLikeConversion(Cond.get(), QuestionLoc);
 
-  result =
-      computeConditionalNullability(result, commonExpr, LHSTy, RHSTy, Context);
+  result = computeConditionalNullability(result, commonExpr, LHSTy, RHSTy,
+                                         Context);
 
   if (!commonExpr)
     return new (Context)
@@ -9430,9 +9437,9 @@ static AssignConvertType checkPointerTypesForAssignment(Sema &S,
     if (isa<PointerType>(lhptee) && isa<PointerType>(rhptee)) {
       do {
         std::tie(lhptee, lhq) =
-            cast<PointerType>(lhptee)->getPointeeType().split().asPair();
+          cast<PointerType>(lhptee)->getPointeeType().split().asPair();
         std::tie(rhptee, rhq) =
-            cast<PointerType>(rhptee)->getPointeeType().split().asPair();
+          cast<PointerType>(rhptee)->getPointeeType().split().asPair();
 
         // Inconsistent address spaces at this point is invalid, even if the
         // address spaces would be compatible.
@@ -10038,8 +10045,8 @@ static void ConstructTransparentUnion(Sema &S, ASTContext &C,
   // Build an initializer list that designates the appropriate member
   // of the transparent union.
   Expr *E = EResult.get();
-  InitListExpr *Initializer =
-      new (C) InitListExpr(C, SourceLocation(), E, SourceLocation());
+  InitListExpr *Initializer = new (C) InitListExpr(C, SourceLocation(),
+                                                   E, SourceLocation());
   Initializer->setType(UnionType);
   Initializer->setInitializedFieldInUnion(Field);
 
@@ -10082,7 +10089,8 @@ Sema::CheckTransparentUnionArgumentConstraints(QualType ArgType,
 
       if (RHS.get()->isNullPointerConstant(Context,
                                            Expr::NPC_ValueDependentIsNull)) {
-        RHS = ImpCastExprToType(RHS.get(), it->getType(), CK_NullToPointer);
+        RHS = ImpCastExprToType(RHS.get(), it->getType(),
+                                CK_NullToPointer);
         InitField = it;
         break;
       }
@@ -10140,12 +10148,13 @@ AssignConvertType Sema::CheckSingleAssignmentConstraints(QualType LHSType,
         RHS = PerformImplicitConversion(RHS.get(), LHSType.getUnqualifiedType(),
                                         AssignmentAction::Assigning);
       } else {
-        ImplicitConversionSequence ICS = TryImplicitConversion(
-            RHS.get(), LHSType.getUnqualifiedType(),
-            /*SuppressUserConversions=*/false, AllowedExplicit::None,
-            /*InOverloadResolution=*/false,
-            /*CStyle=*/false,
-            /*AllowObjCWritebackConversion=*/false);
+        ImplicitConversionSequence ICS =
+            TryImplicitConversion(RHS.get(), LHSType.getUnqualifiedType(),
+                                  /*SuppressUserConversions=*/false,
+                                  AllowedExplicit::None,
+                                  /*InOverloadResolution=*/false,
+                                  /*CStyle=*/false,
+                                  /*AllowObjCWritebackConversion=*/false);
         if (ICS.isFailure())
           return AssignConvertType::Incompatible;
         RHS = PerformImplicitConversion(RHS.get(), LHSType.getUnqualifiedType(),
@@ -10347,27 +10356,27 @@ struct OriginalOperand {
   Expr *Orig;
   NamedDecl *Conversion;
 };
-} // namespace
+}
 
 QualType Sema::InvalidOperands(SourceLocation Loc, ExprResult &LHS,
                                ExprResult &RHS) {
   OriginalOperand OrigLHS(LHS.get()), OrigRHS(RHS.get());
 
   Diag(Loc, diag::err_typecheck_invalid_operands)
-      << OrigLHS.getType() << OrigRHS.getType() << LHS.get()->getSourceRange()
-      << RHS.get()->getSourceRange();
+    << OrigLHS.getType() << OrigRHS.getType()
+    << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
 
   // If a user-defined conversion was applied to either of the operands prior
   // to applying the built-in operator rules, tell the user about it.
   if (OrigLHS.Conversion) {
     Diag(OrigLHS.Conversion->getLocation(),
          diag::note_typecheck_invalid_operands_converted)
-        << 0 << LHS.get()->getType();
+      << 0 << LHS.get()->getType();
   }
   if (OrigRHS.Conversion) {
     Diag(OrigRHS.Conversion->getLocation(),
          diag::note_typecheck_invalid_operands_converted)
-        << 1 << RHS.get()->getType();
+      << 1 << RHS.get()->getType();
   }
 
   return QualType();
@@ -10410,8 +10419,10 @@ QualType Sema::InvalidLogicalVectorOperands(SourceLocation Loc, ExprResult &LHS,
 /// \param scalar - if non-null, actually perform the conversions
 /// \return true if the operation fails (but without diagnosing the failure)
 static bool tryVectorConvertAndSplat(Sema &S, ExprResult *scalar,
-                                     QualType scalarTy, QualType vectorEltTy,
-                                     QualType vectorTy, unsigned &DiagID) {
+                                     QualType scalarTy,
+                                     QualType vectorEltTy,
+                                     QualType vectorTy,
+                                     unsigned &DiagID) {
   // The conversion to apply to the scalar before splatting it,
   // if necessary.
   CastKind scalarCast = CK_NoOp;
@@ -10419,10 +10430,9 @@ static bool tryVectorConvertAndSplat(Sema &S, ExprResult *scalar,
   if (vectorEltTy->isBooleanType() && scalarTy->isIntegralType(S.Context)) {
     scalarCast = CK_IntegralToBoolean;
   } else if (vectorEltTy->isIntegralType(S.Context)) {
-    if (S.getLangOpts().OpenCL &&
-        (scalarTy->isRealFloatingType() ||
-         (scalarTy->isIntegerType() &&
-          S.Context.getIntegerTypeOrder(vectorEltTy, scalarTy) < 0))) {
+    if (S.getLangOpts().OpenCL && (scalarTy->isRealFloatingType() ||
+        (scalarTy->isIntegerType() &&
+         S.Context.getIntegerTypeOrder(vectorEltTy, scalarTy) < 0))) {
       DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
       return true;
     }
@@ -10437,7 +10447,8 @@ static bool tryVectorConvertAndSplat(Sema &S, ExprResult *scalar,
         return true;
       }
       scalarCast = CK_FloatingCast;
-    } else if (scalarTy->isIntegralType(S.Context))
+    }
+    else if (scalarTy->isIntegralType(S.Context))
       scalarCast = CK_IntegralToFloating;
     else
       return true;
@@ -10867,11 +10878,11 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
     if (!IsCompAssign) {
       *OtherExpr = ImpCastExprToType(OtherExpr->get(), VecType, CK_BitCast);
       return VecType;
-      // In a compound assignment, lhs += rhs, 'lhs' is a lvalue src, forbidding
-      // any implicit cast. Here, the 'rhs' should be implicit casted to 'lhs'
-      // type. Note that this is already done by non-compound assignments in
-      // CheckAssignmentConstraints. If it's a scalar type, only bitcast for
-      // <1 x T> -> T. The result is also a vector type.
+    // In a compound assignment, lhs += rhs, 'lhs' is a lvalue src, forbidding
+    // any implicit cast. Here, the 'rhs' should be implicit casted to 'lhs'
+    // type. Note that this is already done by non-compound assignments in
+    // CheckAssignmentConstraints. If it's a scalar type, only bitcast for
+    // <1 x T> -> T. The result is also a vector type.
     } else if (OtherType->isExtVectorType() || OtherType->isVectorType() ||
                (OtherType->isScalarType() && VT->getNumElements() == 1)) {
       ExprResult *RHSExpr = &RHS;
@@ -10886,8 +10897,8 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
   if ((!RHSVecType && !RHSType->isRealType()) ||
       (!LHSVecType && !LHSType->isRealType())) {
     Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
-        << LHSType << RHSType << LHS.get()->getSourceRange()
-        << RHS.get()->getSourceRange();
+      << LHSType << RHSType
+      << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
     return QualType();
   }
 
@@ -10895,13 +10906,15 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
   // If the operands are of more than one vector type, then an error shall
   // occur. Implicit conversions between vector types are not permitted, per
   // section 6.2.1.
-  if (getLangOpts().OpenCL && RHSVecType && isa<ExtVectorType>(RHSVecType) &&
+  if (getLangOpts().OpenCL &&
+      RHSVecType && isa<ExtVectorType>(RHSVecType) &&
       LHSVecType && isa<ExtVectorType>(LHSVecType)) {
-    Diag(Loc, diag::err_opencl_implicit_vector_conversion)
-        << LHSType << RHSType;
+    Diag(Loc, diag::err_opencl_implicit_vector_conversion) << LHSType
+                                                           << RHSType;
     return QualType();
   }
 
+
   // If there is a vector type that is not a ExtVector and a scalar, we reach
   // this point if scalar could not be converted to the vector's element type
   // without truncation.
@@ -10910,15 +10923,17 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
     QualType Scalar = LHSVecType ? RHSType : LHSType;
     QualType Vector = LHSVecType ? LHSType : RHSType;
     unsigned ScalarOrVector = LHSVecType && RHSVecType ? 1 : 0;
-    Diag(Loc, diag::err_typecheck_vector_not_convertable_implict_truncation)
+    Diag(Loc,
+         diag::err_typecheck_vector_not_convertable_implict_truncation)
         << ScalarOrVector << Scalar << Vector;
 
     return QualType();
   }
 
   // Otherwise, use the generic diagnostic.
-  Diag(Loc, DiagID) << LHSType << RHSType << LHS.get()->getSourceRange()
-                    << RHS.get()->getSourceRange();
+  Diag(Loc, DiagID)
+    << LHSType << RHSType
+    << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
   return QualType();
 }
 
@@ -11032,8 +11047,8 @@ static void checkArithmeticNull(Sema &S, ExprResult &LHS, ExprResult &RHS,
     return;
 
   S.Diag(Loc, diag::warn_null_in_comparison_operation)
-      << LHSNull /* LHS is NULL */ << NonNullType << LHS.get()->getSourceRange()
-      << RHS.get()->getSourceRange();
+      << LHSNull /* LHS is NULL */ << NonNullType
+      << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
 }
 
 static void DetectPrecisionLossInComplexDivision(Sema &S, QualType DivisorTy,
@@ -11076,7 +11091,7 @@ static void DetectPrecisionLossInComplexDivision(Sema &S, QualType DivisorTy,
 }
 
 static void DiagnoseDivisionSizeofPointerOrArray(Sema &S, Expr *LHS, Expr *RHS,
-                                                 SourceLocation Loc) {
+                                          SourceLocation Loc) {
   const auto *LUE = dyn_cast<UnaryExprOrTypeTraitExpr>(LHS);
   const auto *RUE = dyn_cast<UnaryExprOrTypeTraitExpr>(RHS);
   if (!LUE || !RUE)
@@ -11123,7 +11138,7 @@ static void DiagnoseDivisionSizeofPointerOrArray(Sema &S, Expr *LHS, Expr *RHS,
   }
 }
 
-static void DiagnoseBadDivideOrRemainderValues(Sema &S, ExprResult &LHS,
+static void DiagnoseBadDivideOrRemainderValues(Sema& S, ExprResult &LHS,
                                                ExprResult &RHS,
                                                SourceLocation Loc, bool IsDiv) {
   // Check for division/remainder by zero.
@@ -11133,7 +11148,7 @@ static void DiagnoseBadDivideOrRemainderValues(Sema &S, ExprResult &LHS,
       RHSValue.Val.getInt() == 0)
     S.DiagRuntimeBehavior(Loc, RHS.get(),
                           S.PDiag(diag::warn_remainder_division_by_zero)
-                              << IsDiv << RHS.get()->getSourceRange());
+                            << IsDiv << RHS.get()->getSourceRange());
 }
 
 static void diagnoseScopedEnums(Sema &S, const SourceLocation Loc,
@@ -11220,8 +11235,8 @@ QualType Sema::CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS,
   return compType;
 }
 
-QualType Sema::CheckRemainderOperands(ExprResult &LHS, ExprResult &RHS,
-                                      SourceLocation Loc, bool IsCompAssign) {
+QualType Sema::CheckRemainderOperands(
+  ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign) {
   checkArithmeticNull(*this, LHS, RHS, Loc, /*IsCompare=*/false);
 
   // Note: This check is here to simplify the double exclusions of
@@ -11288,19 +11303,19 @@ QualType Sema::CheckRemainderOperands(ExprResult &LHS, ExprResult &RHS,
 static void diagnoseArithmeticOnTwoVoidPointers(Sema &S, SourceLocation Loc,
                                                 Expr *LHSExpr, Expr *RHSExpr) {
   S.Diag(Loc, S.getLangOpts().CPlusPlus
-                  ? diag::err_typecheck_pointer_arith_void_type
-                  : diag::ext_gnu_void_ptr)
-      << 1 /* two pointers */ << LHSExpr->getSourceRange()
-      << RHSExpr->getSourceRange();
+                ? diag::err_typecheck_pointer_arith_void_type
+                : diag::ext_gnu_void_ptr)
+    << 1 /* two pointers */ << LHSExpr->getSourceRange()
+                            << RHSExpr->getSourceRange();
 }
 
 /// Diagnose invalid arithmetic on a void pointer.
 static void diagnoseArithmeticOnVoidPointer(Sema &S, SourceLocation Loc,
                                             Expr *Pointer) {
   S.Diag(Loc, S.getLangOpts().CPlusPlus
-                  ? diag::err_typecheck_pointer_arith_void_type
-                  : diag::ext_gnu_void_ptr)
-      << 0 /* one pointer */ << Pointer->getSourceRange();
+                ? diag::err_typecheck_pointer_arith_void_type
+                : diag::ext_gnu_void_ptr)
+    << 0 /* one pointer */ << Pointer->getSourceRange();
 }
 
 /// Diagnose invalid arithmetic on a null pointer.
@@ -11311,10 +11326,11 @@ static void diagnoseArithmeticOnVoidPointer(Sema &S, SourceLocation Loc,
 static void diagnoseArithmeticOnNullPointer(Sema &S, SourceLocation Loc,
                                             Expr *Pointer, bool IsGNUIdiom) {
   if (IsGNUIdiom)
-    S.Diag(Loc, diag::warn_gnu_null_ptr_arith) << Pointer->getSourceRange();
+    S.Diag(Loc, diag::warn_gnu_null_ptr_arith)
+      << Pointer->getSourceRange();
   else
     S.Diag(Loc, diag::warn_pointer_arith_null_ptr)
-        << S.getLangOpts().CPlusPlus << Pointer->getSourceRange();
+      << S.getLangOpts().CPlusPlus << Pointer->getSourceRange();
 }
 
 /// Diagnose invalid subraction on a null pointer.
@@ -11341,15 +11357,14 @@ static void diagnoseArithmeticOnTwoFunctionPointers(Sema &S, SourceLocation Loc,
   assert(LHS->getType()->isAnyPointerType());
   assert(RHS->getType()->isAnyPointerType());
   S.Diag(Loc, S.getLangOpts().CPlusPlus
-                  ? diag::err_typecheck_pointer_arith_function_type
-                  : diag::ext_gnu_ptr_func_arith)
-      << 1 /* two pointers */
-      << LHS->getType()->getPointeeType()
-      // We only show the second type if it differs from the first.
-      << (unsigned)!S.Context.hasSameUnqualifiedType(LHS->getType(),
-                                                     RHS->getType())
-      << RHS->getType()->getPointeeType() << LHS->getSourceRange()
-      << RHS->getSourceRange();
+                ? diag::err_typecheck_pointer_arith_function_type
+                : diag::ext_gnu_ptr_func_arith)
+    << 1 /* two pointers */ << LHS->getType()->getPointeeType()
+    // We only show the second type if it differs from the first.
+    << (unsigned)!S.Context.hasSameUnqualifiedType(LHS->getType(),
+                                                   RHS->getType())
+    << RHS->getType()->getPointeeType()
+    << LHS->getSourceRange() << RHS->getSourceRange();
 }
 
 /// Diagnose invalid arithmetic on a function pointer.
@@ -11357,11 +11372,11 @@ static void diagnoseArithmeticOnFunctionPointer(Sema &S, SourceLocation Loc,
                                                 Expr *Pointer) {
   assert(Pointer->getType()->isAnyPointerType());
   S.Diag(Loc, S.getLangOpts().CPlusPlus
-                  ? diag::err_typecheck_pointer_arith_function_type
-                  : diag::ext_gnu_ptr_func_arith)
-      << 0 /* one pointer */ << Pointer->getType()->getPointeeType()
-      << 0 /* one pointer, so only one type */
-      << Pointer->getSourceRange();
+                ? diag::err_typecheck_pointer_arith_function_type
+                : diag::ext_gnu_ptr_func_arith)
+    << 0 /* one pointer */ << Pointer->getType()->getPointeeType()
+    << 0 /* one pointer, so only one type */
+    << Pointer->getSourceRange();
 }
 
 /// Emit error if Operand is incomplete pointer type
@@ -11395,8 +11410,7 @@ static bool checkArithmeticOpPointerOperand(Sema &S, SourceLocation Loc,
   if (const AtomicType *ResAtomicType = ResType->getAs<AtomicType>())
     ResType = ResAtomicType->getValueType();
 
-  if (!ResType->isAnyPointerType())
-    return true;
+  if (!ResType->isAnyPointerType()) return true;
 
   QualType PointeeTy = ResType->getPointeeType();
   if (PointeeTy->isVoidType()) {
@@ -11408,8 +11422,7 @@ static bool checkArithmeticOpPointerOperand(Sema &S, SourceLocation Loc,
     return !S.getLangOpts().CPlusPlus;
   }
 
-  if (checkArithmeticIncompletePointerType(S, Loc, Operand))
-    return false;
+  if (checkArithmeticIncompletePointerType(S, Loc, Operand)) return false;
 
   return true;
 }
@@ -11427,14 +11440,11 @@ static bool checkArithmeticBinOpPointerOperands(Sema &S, SourceLocation Loc,
                                                 Expr *LHSExpr, Expr *RHSExpr) {
   bool isLHSPointer = LHSExpr->getType()->isAnyPointerType();
   bool isRHSPointer = RHSExpr->getType()->isAnyPointerType();
-  if (!isLHSPointer && !isRHSPointer)
-    return true;
+  if (!isLHSPointer && !isRHSPointer) return true;
 
   QualType LHSPointeeTy, RHSPointeeTy;
-  if (isLHSPointer)
-    LHSPointeeTy = LHSExpr->getType()->getPointeeType();
-  if (isRHSPointer)
-    RHSPointeeTy = RHSExpr->getType()->getPointeeType();
+  if (isLHSPointer) LHSPointeeTy = LHSExpr->getType()->getPointeeType();
+  if (isRHSPointer) RHSPointeeTy = RHSExpr->getType()->getPointeeType();
 
   // if both are pointers check if operation is valid wrt address spaces
   if (isLHSPointer && isRHSPointer) {
@@ -11452,12 +11462,9 @@ static bool checkArithmeticBinOpPointerOperands(Sema &S, SourceLocation Loc,
   bool isLHSVoidPtr = isLHSPointer && LHSPointeeTy->isVoidType();
   bool isRHSVoidPtr = isRHSPointer && RHSPointeeTy->isVoidType();
   if (isLHSVoidPtr || isRHSVoidPtr) {
-    if (!isRHSVoidPtr)
-      diagnoseArithmeticOnVoidPointer(S, Loc, LHSExpr);
-    else if (!isLHSVoidPtr)
-      diagnoseArithmeticOnVoidPointer(S, Loc, RHSExpr);
-    else
-      diagnoseArithmeticOnTwoVoidPointers(S, Loc, LHSExpr, RHSExpr);
+    if (!isRHSVoidPtr) diagnoseArithmeticOnVoidPointer(S, Loc, LHSExpr);
+    else if (!isLHSVoidPtr) diagnoseArithmeticOnVoidPointer(S, Loc, RHSExpr);
+    else diagnoseArithmeticOnTwoVoidPointers(S, Loc, LHSExpr, RHSExpr);
 
     return !S.getLangOpts().CPlusPlus;
   }
@@ -11465,12 +11472,10 @@ static bool checkArithmeticBinOpPointerOperands(Sema &S, SourceLocation Loc,
   bool isLHSFuncPtr = isLHSPointer && LHSPointeeTy->isFunctionType();
   bool isRHSFuncPtr = isRHSPointer && RHSPointeeTy->isFunctionType();
   if (isLHSFuncPtr || isRHSFuncPtr) {
-    if (!isRHSFuncPtr)
-      diagnoseArithmeticOnFunctionPointer(S, Loc, LHSExpr);
-    else if (!isLHSFuncPtr)
-      diagnoseArithmeticOnFunctionPointer(S, Loc, RHSExpr);
-    else
-      diagnoseArithmeticOnTwoFunctionPointers(S, Loc, LHSExpr, RHSExpr);
+    if (!isRHSFuncPtr) diagnoseArithmeticOnFunctionPointer(S, Loc, LHSExpr);
+    else if (!isLHSFuncPtr) diagnoseArithmeticOnFunctionPointer(S, Loc,
+                                                                RHSExpr);
+    else diagnoseArithmeticOnTwoFunctionPointers(S, Loc, LHSExpr, RHSExpr);
 
     return !S.getLangOpts().CPlusPlus;
   }
@@ -11487,15 +11492,15 @@ static bool checkArithmeticBinOpPointerOperands(Sema &S, SourceLocation Loc,
 /// literal.
 static void diagnoseStringPlusInt(Sema &Self, SourceLocation OpLoc,
                                   Expr *LHSExpr, Expr *RHSExpr) {
-  StringLiteral *StrExpr = dyn_cast<StringLiteral>(LHSExpr->IgnoreImpCasts());
-  Expr *IndexExpr = RHSExpr;
+  StringLiteral* StrExpr = dyn_cast<StringLiteral>(LHSExpr->IgnoreImpCasts());
+  Expr* IndexExpr = RHSExpr;
   if (!StrExpr) {
     StrExpr = dyn_cast<StringLiteral>(RHSExpr->IgnoreImpCasts());
     IndexExpr = LHSExpr;
   }
 
-  bool IsStringPlusInt =
-      StrExpr && IndexExpr->getType()->isIntegralOrUnscopedEnumerationType();
+  bool IsStringPlusInt = StrExpr &&
+      IndexExpr->getType()->isIntegralOrUnscopedEnumerationType();
   if (!IsStringPlusInt || IndexExpr->isValueDependent())
     return;
 
@@ -11543,9 +11548,11 @@ static void diagnoseStringPlusChar(Sema &Self, SourceLocation OpLoc,
   SourceRange DiagRange(LHSExpr->getBeginLoc(), RHSExpr->getEndLoc());
 
   const QualType CharType = CharExpr->getType();
-  if (!CharType->isAnyCharacterType() && CharType->isIntegerType() &&
+  if (!CharType->isAnyCharacterType() &&
+      CharType->isIntegerType() &&
       llvm::isUIntN(Ctx.getCharWidth(), CharExpr->getValue())) {
-    Self.Diag(OpLoc, diag::warn_string_plus_char) << DiagRange << Ctx.CharTy;
+    Self.Diag(OpLoc, diag::warn_string_plus_char)
+        << DiagRange << Ctx.CharTy;
   } else {
     Self.Diag(OpLoc, diag::warn_string_plus_char)
         << DiagRange << CharExpr->getType();
@@ -11569,14 +11576,14 @@ static void diagnosePointerIncompatibility(Sema &S, SourceLocation Loc,
   assert(LHSExpr->getType()->isAnyPointerType());
   assert(RHSExpr->getType()->isAnyPointerType());
   S.Diag(Loc, diag::err_typecheck_sub_ptr_compatible)
-      << LHSExpr->getType() << RHSExpr->getType() << LHSExpr->getSourceRange()
-      << RHSExpr->getSourceRange();
+    << LHSExpr->getType() << RHSExpr->getType() << LHSExpr->getSourceRange()
+    << RHSExpr->getSourceRange();
 }
 
 // C99 6.5.6
 QualType Sema::CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS,
                                      SourceLocation Loc, BinaryOperatorKind Opc,
-                                     QualType *CompLHSTy) {
+                                     QualType* CompLHSTy) {
   checkArithmeticNull(*this, LHS, RHS, Loc, /*IsCompare=*/false);
 
   if (LHS.get()->getType()->isVectorType() ||
@@ -11587,8 +11594,7 @@ QualType Sema::CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS,
                             /*AllowBoolConversions*/ getLangOpts().ZVector,
                             /*AllowBooleanOperation*/ false,
                             /*ReportInvalid*/ true);
-    if (CompLHSTy)
-      *CompLHSTy = compType;
+    if (CompLHSTy) *CompLHSTy = compType;
     return compType;
   }
 
@@ -11624,8 +11630,7 @@ QualType Sema::CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS,
 
   // handle the common case first (both operands are arithmetic).
   if (!compType.isNull() && compType->isArithmeticType()) {
-    if (CompLHSTy)
-      *CompLHSTy = compType;
+    if (CompLHSTy) *CompLHSTy = compType;
     return compType;
   }
 
@@ -11660,9 +11665,10 @@ QualType Sema::CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS,
           Context, Expr::NPC_ValueDependentIsNotNull)) {
     // In C++ adding zero to a null pointer is defined.
     Expr::EvalResult KnownVal;
-    if (!getLangOpts().CPlusPlus || (!IExp->isValueDependent() &&
-                                     (!IExp->EvaluateAsInt(KnownVal, Context) ||
-                                      KnownVal.Val.getInt() != 0))) {
+    if (!getLangOpts().CPlusPlus ||
+        (!IExp->isValueDependent() &&
+         (!IExp->EvaluateAsInt(KnownVal, Context) ||
+          KnownVal.Val.getInt() != 0))) {
       // Check the conditions to see if this is the 'p = nullptr + n' idiom.
       bool IsGNUIdiom = BinaryOperator::isNullPointerArithmeticExtension(
           Context, BO_Add, PExp, IExp);
@@ -11715,8 +11721,7 @@ QualType Sema::CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS,
                             /*AllowBoolConversions*/ getLangOpts().ZVector,
                             /*AllowBooleanOperation*/ false,
                             /*ReportInvalid*/ true);
-    if (CompLHSTy)
-      *CompLHSTy = compType;
+    if (CompLHSTy) *CompLHSTy = compType;
     return compType;
   }
 
@@ -11748,8 +11753,7 @@ QualType Sema::CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS,
 
   // Handle the common case first (both operands are arithmetic).
   if (!compType.isNull() && compType->isArithmeticType()) {
-    if (CompLHSTy)
-      *CompLHSTy = compType;
+    if (CompLHSTy) *CompLHSTy = compType;
     return compType;
   }
 
@@ -11776,8 +11780,8 @@ QualType Sema::CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS,
       // Subtracting from a null pointer should produce a warning.
       // The last argument to the diagnose call says this doesn't match the
       // GNU int-to-pointer idiom.
-      if (LHS.get()->IgnoreParenCasts()->isNullPointerConstant(
-              Context, Expr::NPC_ValueDependentIsNotNull)) {
+      if (LHS.get()->IgnoreParenCasts()->isNullPointerConstant(Context,
+                                           Expr::NPC_ValueDependentIsNotNull)) {
         // In C++ adding zero to a null pointer is defined.
         Expr::EvalResult KnownVal;
         if (!getLangOpts().CPlusPlus ||
@@ -11792,17 +11796,16 @@ QualType Sema::CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS,
         return QualType();
 
       // Check array bounds for pointer arithemtic
-      CheckArrayAccess(LHS.get(), RHS.get(), /*ArraySubscriptExpr*/ nullptr,
-                       /*AllowOnePastEnd*/ true, /*IndexNegated*/ true);
+      CheckArrayAccess(LHS.get(), RHS.get(), /*ArraySubscriptExpr*/nullptr,
+                       /*AllowOnePastEnd*/true, /*IndexNegated*/true);
 
-      if (CompLHSTy)
-        *CompLHSTy = LHS.get()->getType();
+      if (CompLHSTy) *CompLHSTy = LHS.get()->getType();
       return LHS.get()->getType();
     }
 
     // Handle pointer-pointer subtractions.
-    if (const PointerType *RHSPTy =
-            RHS.get()->getType()->getAs<PointerType>()) {
+    if (const PointerType *RHSPTy
+          = RHS.get()->getType()->getAs<PointerType>()) {
       QualType rpointee = RHSPTy->getPointeeType();
 
       if (getLangOpts().CPlusPlus) {
@@ -11820,8 +11823,8 @@ QualType Sema::CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS,
         }
       }
 
-      if (!checkArithmeticBinOpPointerOperands(*this, Loc, LHS.get(),
-                                               RHS.get()))
+      if (!checkArithmeticBinOpPointerOperands(*this, Loc,
+                                               LHS.get(), RHS.get()))
         return QualType();
 
       bool LHSIsNullPtr = LHS.get()->IgnoreParenCasts()->isNullPointerConstant(
@@ -11841,14 +11844,13 @@ QualType Sema::CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS,
       if (!rpointee->isVoidType() && !rpointee->isFunctionType()) {
         CharUnits ElementSize = Context.getTypeSizeInChars(rpointee);
         if (ElementSize.isZero()) {
-          Diag(Loc, diag::warn_sub_ptr_zero_size_types)
-              << rpointee.getUnqualifiedType() << LHS.get()->getSourceRange()
-              << RHS.get()->getSourceRange();
+          Diag(Loc,diag::warn_sub_ptr_zero_size_types)
+            << rpointee.getUnqualifiedType()
+            << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
         }
       }
 
-      if (CompLHSTy)
-        *CompLHSTy = LHS.get()->getType();
+      if (CompLHSTy) *CompLHSTy = LHS.get()->getType();
       return Context.getPointerDiffType();
     }
   }
@@ -11864,12 +11866,11 @@ static bool isScopedEnumerationType(QualType T) {
   return false;
 }
 
-static void DiagnoseBadShiftValues(Sema &S, ExprResult &LHS, ExprResult &RHS,
+static void DiagnoseBadShiftValues(Sema& S, ExprResult &LHS, ExprResult &RHS,
                                    SourceLocation Loc, BinaryOperatorKind Opc,
                                    QualType LHSType) {
-  // OpenCL 6.3j: shift values are effectively % word size of LHS (more
-  // defined), so skip remaining warnings as we don't want to modify values
-  // within Sema.
+  // OpenCL 6.3j: shift values are effectively % word size of LHS (more defined),
+  // so skip remaining warnings as we don't want to modify values within Sema.
   if (S.getLangOpts().OpenCL)
     return;
 
@@ -11957,8 +11958,8 @@ static void DiagnoseBadShiftValues(Sema &S, ExprResult &LHS, ExprResult &RHS,
   // turned off separately if needed.
   if (ResultBits - 1 == LeftSize) {
     S.Diag(Loc, diag::warn_shift_result_sets_sign_bit)
-        << HexResult << LHSType << LHS.get()->getSourceRange()
-        << RHS.get()->getSourceRange();
+        << HexResult << LHSType
+        << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
     return;
   }
 
@@ -11976,20 +11977,18 @@ static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS,
   if ((S.LangOpts.OpenCL || S.LangOpts.ZVector) &&
       !LHS.get()->getType()->isVectorType()) {
     S.Diag(Loc, diag::err_shift_rhs_only_vector)
-        << RHS.get()->getType() << LHS.get()->getType()
-        << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+      << RHS.get()->getType() << LHS.get()->getType()
+      << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
     return QualType();
   }
 
   if (!IsCompAssign) {
     LHS = S.UsualUnaryConversions(LHS.get());
-    if (LHS.isInvalid())
-      return QualType();
+    if (LHS.isInvalid()) return QualType();
   }
 
   RHS = S.UsualUnaryConversions(RHS.get());
-  if (RHS.isInvalid())
-    return QualType();
+  if (RHS.isInvalid()) return QualType();
 
   QualType LHSType = LHS.get()->getType();
   // Note that LHS might be a scalar because the routine calls not only in
@@ -12014,13 +12013,13 @@ static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS,
   // The operands need to be integers.
   if (!LHSEleType->isIntegerType()) {
     S.Diag(Loc, diag::err_typecheck_expect_int)
-        << LHS.get()->getType() << LHS.get()->getSourceRange();
+      << LHS.get()->getType() << LHS.get()->getSourceRange();
     return QualType();
   }
 
   if (!RHSEleType->isIntegerType()) {
     S.Diag(Loc, diag::err_typecheck_expect_int)
-        << RHS.get()->getType() << RHS.get()->getSourceRange();
+      << RHS.get()->getType() << RHS.get()->getSourceRange();
     return QualType();
   }
 
@@ -12029,7 +12028,7 @@ static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS,
     if (IsCompAssign)
       return RHSType;
     if (LHSEleType != RHSEleType) {
-      LHS = S.ImpCastExprToType(LHS.get(), RHSEleType, CK_IntegralCast);
+      LHS = S.ImpCastExprToType(LHS.get(),RHSEleType, CK_IntegralCast);
       LHSEleType = RHSEleType;
     }
     QualType VecTy =
@@ -12042,8 +12041,8 @@ static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS,
     // that the number of elements is the same as LHS...
     if (RHSVecTy->getNumElements() != LHSVecTy->getNumElements()) {
       S.Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
-          << LHS.get()->getType() << RHS.get()->getType()
-          << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+        << LHS.get()->getType() << RHS.get()->getType()
+        << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
       return QualType();
     }
     if (!S.LangOpts.OpenCL && !S.LangOpts.ZVector) {
@@ -12059,7 +12058,7 @@ static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS,
   } else {
     // ...else expand RHS to match the number of elements in LHS.
     QualType VecTy =
-        S.Context.getExtVectorType(RHSEleType, LHSVecTy->getNumElements());
+      S.Context.getExtVectorType(RHSEleType, LHSVecTy->getNumElements());
     RHS = S.ImpCastExprToType(RHS.get(), VecTy, CK_VectorSplat);
   }
 
@@ -12194,8 +12193,7 @@ QualType Sema::CheckShiftOperands(ExprResult &LHS, ExprResult &RHS,
   if (LHS.isInvalid())
     return QualType();
   QualType LHSType = LHS.get()->getType();
-  if (IsCompAssign)
-    LHS = OldLHS;
+  if (IsCompAssign) LHS = OldLHS;
 
   // The RHS is simpler.
   RHS = UsualUnaryConversions(RHS.get());
@@ -12225,8 +12223,8 @@ static void diagnoseDistinctPointerComparison(Sema &S, SourceLocation Loc,
                                               bool IsError) {
   S.Diag(Loc, IsError ? diag::err_typecheck_comparison_of_distinct_pointers
                       : diag::ext_typecheck_comparison_of_distinct_pointers)
-      << LHS.get()->getType() << RHS.get()->getType()
-      << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+    << LHS.get()->getType() << RHS.get()->getType()
+    << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
 }
 
 /// Returns false if the pointers are converted to a composite type,
@@ -12251,7 +12249,7 @@ static bool convertPointersToCompositeType(Sema &S, SourceLocation Loc,
   if (T.isNull()) {
     if ((LHSType->isAnyPointerType() || LHSType->isMemberPointerType()) &&
         (RHSType->isAnyPointerType() || RHSType->isMemberPointerType()))
-      diagnoseDistinctPointerComparison(S, Loc, LHS, RHS, /*isError*/ true);
+      diagnoseDistinctPointerComparison(S, Loc, LHS, RHS, /*isError*/true);
     else
       S.InvalidOperands(Loc, LHS, RHS);
     return true;
@@ -12266,8 +12264,8 @@ static void diagnoseFunctionPointerToVoidComparison(Sema &S, SourceLocation Loc,
                                                     bool IsError) {
   S.Diag(Loc, IsError ? diag::err_typecheck_comparison_of_fptr_to_void
                       : diag::ext_typecheck_comparison_of_fptr_to_void)
-      << LHS.get()->getType() << RHS.get()->getType()
-      << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
+    << LHS.get()->getType() << RHS.get()->getType()
+    << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
 }
 
 static bool isObjCObjectLiteral(ExprResult &E) {
@@ -12285,7 +12283,7 @@ static bool isObjCObjectLiteral(ExprResult &E) {
 
 static bool hasIsEqualMethod(Sema &S, const Expr *LHS, const Expr *RHS) {
   const ObjCObjectPointerType *Type =
-      LHS->getType()->getAs<ObjCObjectPointerType>();
+    LHS->getType()->getAs<ObjCObjectPointerType>();
 
   // If this is not actually an Objective-C object, bail out.
   if (!Type)
@@ -12332,7 +12330,7 @@ static bool hasIsEqualMethod(Sema &S, const Expr *LHS, const Expr *RHS) {
 
 static void diagnoseObjCLiteralComparison(Sema &S, SourceLocation Loc,
                                           ExprResult &LHS, ExprResult &RHS,
-                                          BinaryOperator::Opcode Opc) {
+                                          BinaryOperator::Opcode Opc){
   Expr *Literal;
   Expr *Other;
   if (isObjCObjectLiteral(LHS)) {
@@ -12360,22 +12358,22 @@ static void diagnoseObjCLiteralComparison(Sema &S, SourceLocation Loc,
 
   if (LiteralKind == SemaObjC::LK_String)
     S.Diag(Loc, diag::warn_objc_string_literal_comparison)
-        << Literal->getSourceRange();
+      << Literal->getSourceRange();
   else
     S.Diag(Loc, diag::warn_objc_literal_comparison)
-        << LiteralKind << Literal->getSourceRange();
+      << LiteralKind << Literal->getSourceRange();
 
   if (BinaryOperator::isEqualityOp(Opc) &&
       hasIsEqualMethod(S, LHS.get(), RHS.get())) {
     SourceLocation Start = LHS.get()->getBeginLoc();
     SourceLocation End = S.getLocForEndOfToken(RHS.get()->getEndLoc());
     CharSourceRange OpRange =
-        CharSourceRange::getCharRange(Loc, S.getLocForEndOfToken(Loc));
+      CharSourceRange::getCharRange(Loc, S.getLocForEndOfToken(Loc));
 
     S.Diag(Loc, diag::note_objc_literal_comparison_isequal)
-        << FixItHint::CreateInsertion(Start, Opc == BO_EQ ? "[" : "![")
-        << FixItHint::CreateReplacement(OpRange, " isEqual:")
-        << FixItHint::CreateInsertion(End, "]");
+      << FixItHint::CreateInsertion(Start, Opc == BO_EQ ? "[" : "![")
+      << FixItHint::CreateReplacement(OpRange, " isEqual:")
+      << FixItHint::CreateInsertion(End, "]");
   }
 }
 
@@ -12385,17 +12383,14 @@ static void diagnoseLogicalNotOnLHSofCheck(Sema &S, ExprResult &LHS,
                                            BinaryOperatorKind Opc) {
   // Check that left hand side is !something.
   UnaryOperator *UO = dyn_cast<UnaryOperator>(LHS.get()->IgnoreImpCasts());
-  if (!UO || UO->getOpcode() != UO_LNot)
-    return;
+  if (!UO || UO->getOpcode() != UO_LNot) return;
 
   // Only check if the right hand side is non-bool arithmetic type.
-  if (RHS.get()->isKnownToHaveBooleanValue())
-    return;
+  if (RHS.get()->isKnownToHaveBooleanValue()) return;
 
   // Make sure that the something in !something is not bool.
   Expr *SubExpr = UO->getSubExpr()->IgnoreImpCasts();
-  if (SubExpr->isKnownToHaveBooleanValue())
-    return;
+  if (SubExpr->isKnownToHaveBooleanValue()) return;
 
   // Emit warning.
   bool IsBitwiseOp = Opc == BO_And || Opc == BO_Or || Opc == BO_Xor;
@@ -12409,7 +12404,8 @@ static void diagnoseLogicalNotOnLHSofCheck(Sema &S, ExprResult &LHS,
   if (FirstClose.isInvalid())
     FirstOpen = SourceLocation();
   S.Diag(UO->getOperatorLoc(), diag::note_logical_not_fix)
-      << IsBitwiseOp << FixItHint::CreateInsertion(FirstOpen, "(")
+      << IsBitwiseOp
+      << FixItHint::CreateInsertion(FirstOpen, "(")
       << FixItHint::CreateInsertion(FirstClose, ")");
 
   // Second note suggests (!x) < y
@@ -12616,8 +12612,8 @@ static void diagnoseTautologicalComparison(Sema &S, SourceLocation Loc,
     LiteralStringStripped = LHSStripped;
   } else if ((isa<StringLiteral>(RHSStripped) ||
               isa<ObjCEncodeExpr>(RHSStripped)) &&
-             !LHSStripped->isNullPointerConstant(
-                 S.Context, Expr::NPC_ValueDependentIsNull)) {
+             !LHSStripped->isNullPointerConstant(S.Context,
+                                          Expr::NPC_ValueDependentIsNull)) {
     LiteralString = RHS;
     LiteralStringStripped = RHSStripped;
   }
@@ -12833,7 +12829,7 @@ void Sema::CheckPtrComparisonWithNullChar(ExprResult &E, ExprResult &NullE) {
   if (!E.get()->getType()->isAnyPointerType() &&
       E.get()->isNullPointerConstant(Context,
                                      Expr::NPC_ValueDependentIsNotNull) ==
-          Expr::NPCK_ZeroExpression) {
+        Expr::NPCK_ZeroExpression) {
     if (const auto *CL = dyn_cast<CharacterLiteral>(E.get())) {
       if (CL->getValue() == 0)
         Diag(E.get()->getExprLoc(), diag::warn_pointer_compare)
@@ -12841,14 +12837,14 @@ void Sema::CheckPtrComparisonWithNullChar(ExprResult &E, ExprResult &NullE) {
             << FixItHint::CreateReplacement(E.get()->getExprLoc(),
                                             NullValue ? "NULL" : "(void *)0");
     } else if (const auto *CE = dyn_cast<CStyleCastExpr>(E.get())) {
-      TypeSourceInfo *TI = CE->getTypeInfoAsWritten();
-      QualType T = Context.getCanonicalType(TI->getType()).getUnqualifiedType();
-      if (T == Context.CharTy)
-        Diag(E.get()->getExprLoc(), diag::warn_pointer_compare)
-            << NullValue
-            << FixItHint::CreateReplacement(E.get()->getExprLoc(),
-                                            NullValue ? "NULL" : "(void *)0");
-    }
+        TypeSourceInfo *TI = CE->getTypeInfoAsWritten();
+        QualType T = Context.getCanonicalType(TI->getType()).getUnqualifiedType();
+        if (T == Context.CharTy)
+          Diag(E.get()->getExprLoc(), diag::warn_pointer_compare)
+              << NullValue
+              << FixItHint::CreateReplacement(E.get()->getExprLoc(),
+                                              NullValue ? "NULL" : "(void *)0");
+      }
   }
 }
 
@@ -12950,8 +12946,8 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
         *CCT, Loc, ComparisonCategoryUsage::OperatorInExpression);
   };
 
-  if (LHSType->isMetaInfoType() && RHSType->isMetaInfoType()) {
-    if (!BinaryOperator::isEqualityOp(Opc)) {
+  if(LHSType->isMetaInfoType() && RHSType->isMetaInfoType()){
+    if(!BinaryOperator::isEqualityOp(Opc)) {
       return InvalidOperands(Loc, LHS, RHS);
     }
     return computeResultTy();
@@ -13032,9 +13028,9 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
     // All of the following pointer-related warnings are GCC extensions, except
     // when handling null pointer constants.
     QualType LCanPointeeTy =
-        LHSType->castAs<PointerType>()->getPointeeType().getCanonicalType();
+      LHSType->castAs<PointerType>()->getPointeeType().getCanonicalType();
     QualType RCanPointeeTy =
-        RHSType->castAs<PointerType>()->getPointeeType().getCanonicalType();
+      RHSType->castAs<PointerType>()->getPointeeType().getCanonicalType();
 
     // C99 6.5.9p2 and C99 6.5.8p2
     if (Context.typesAreCompatible(LCanPointeeTy.getUnqualifiedType(),
@@ -13053,15 +13049,13 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
     } else if (!IsRelational &&
                (LCanPointeeTy->isVoidType() || RCanPointeeTy->isVoidType())) {
       // Valid unless comparison between non-null pointer and function pointer
-      if ((LCanPointeeTy->isFunctionType() ||
-           RCanPointeeTy->isFunctionType()) &&
-          !LHSIsNull && !RHSIsNull)
+      if ((LCanPointeeTy->isFunctionType() || RCanPointeeTy->isFunctionType())
+          && !LHSIsNull && !RHSIsNull)
         diagnoseFunctionPointerToVoidComparison(*this, Loc, LHS, RHS,
-                                                /*isError*/ false);
+                                                /*isError*/false);
     } else {
       // Invalid
-      diagnoseDistinctPointerComparison(*this, Loc, LHS, RHS,
-                                        /*isError*/ false);
+      diagnoseDistinctPointerComparison(*this, Loc, LHS, RHS, /*isError*/false);
     }
     if (LCanPointeeTy != RCanPointeeTy) {
       // Treat NULL constant as a special case in OpenCL.
@@ -13076,8 +13070,8 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
       }
       LangAS AddrSpaceL = LCanPointeeTy.getAddressSpace();
       LangAS AddrSpaceR = RCanPointeeTy.getAddressSpace();
-      CastKind Kind =
-          AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
+      CastKind Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion
+                                               : CK_BitCast;
 
       const FunctionType *LFn = LCanPointeeTy->getAs<FunctionType>();
       const FunctionType *RFn = RCanPointeeTy->getAs<FunctionType>();
@@ -13094,6 +13088,7 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
     return computeResultTy();
   }
 
+
   // C++ [expr.eq]p4:
   //   Two operands of type std::nullptr_t or one operand of type
   //   std::nullptr_t and the other a null pointer constant compare
@@ -13188,36 +13183,34 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
     if (!LHSIsNull && !RHSIsNull &&
         !Context.typesAreCompatible(lpointee, rpointee)) {
       Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
-          << LHSType << RHSType << LHS.get()->getSourceRange()
-          << RHS.get()->getSourceRange();
+        << LHSType << RHSType << LHS.get()->getSourceRange()
+        << RHS.get()->getSourceRange();
     }
     RHS = ImpCastExprToType(RHS.get(), LHSType, CK_BitCast);
     return computeResultTy();
   }
 
   // Allow block pointers to be compared with null pointer constants.
-  if (!IsOrdered &&
-      ((LHSType->isBlockPointerType() && RHSType->isPointerType()) ||
-       (LHSType->isPointerType() && RHSType->isBlockPointerType()))) {
+  if (!IsOrdered
+      && ((LHSType->isBlockPointerType() && RHSType->isPointerType())
+          || (LHSType->isPointerType() && RHSType->isBlockPointerType()))) {
     if (!LHSIsNull && !RHSIsNull) {
-      if (!((RHSType->isPointerType() &&
-             RHSType->castAs<PointerType>()->getPointeeType()->isVoidType()) ||
-            (LHSType->isPointerType() &&
-             LHSType->castAs<PointerType>()->getPointeeType()->isVoidType())))
+      if (!((RHSType->isPointerType() && RHSType->castAs<PointerType>()
+             ->getPointeeType()->isVoidType())
+            || (LHSType->isPointerType() && LHSType->castAs<PointerType>()
+                ->getPointeeType()->isVoidType())))
         Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
-            << LHSType << RHSType << LHS.get()->getSourceRange()
-            << RHS.get()->getSourceRange();
+          << LHSType << RHSType << LHS.get()->getSourceRange()
+          << RHS.get()->getSourceRange();
     }
     if (LHSIsNull && !RHSIsNull)
       LHS = ImpCastExprToType(LHS.get(), RHSType,
-                              RHSType->isPointerType()
-                                  ? CK_BitCast
-                                  : CK_AnyPointerToBlockPointerCast);
+                              RHSType->isPointerType() ? CK_BitCast
+                                : CK_AnyPointerToBlockPointerCast);
     else
       RHS = ImpCastExprToType(RHS.get(), LHSType,
-                              LHSType->isPointerType()
-                                  ? CK_BitCast
-                                  : CK_AnyPointerToBlockPointerCast);
+                              LHSType->isPointerType() ? CK_BitCast
+                                : CK_AnyPointerToBlockPointerCast);
     return computeResultTy();
   }
 
@@ -13232,7 +13225,7 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
       if (!LPtrToVoid && !RPtrToVoid &&
           !Context.typesAreCompatible(LHSType, RHSType)) {
         diagnoseDistinctPointerComparison(*this, Loc, LHS, RHS,
-                                          /*isError*/ false);
+                                          /*isError*/false);
       }
       // FIXME: If LPtrToVoid, we should presumably convert the LHS rather than
       // the RHS, but we have test coverage for this behavior.
@@ -13242,17 +13235,18 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
         if (getLangOpts().ObjCAutoRefCount)
           ObjC().CheckObjCConversion(SourceRange(), RHSType, E,
                                      CheckedConversionKind::Implicit);
-        LHS = ImpCastExprToType(
-            E, RHSType, RPT ? CK_BitCast : CK_CPointerToObjCPointerCast);
-      } else {
+        LHS = ImpCastExprToType(E, RHSType,
+                                RPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
+      }
+      else {
         Expr *E = RHS.get();
         if (getLangOpts().ObjCAutoRefCount)
           ObjC().CheckObjCConversion(SourceRange(), LHSType, E,
                                      CheckedConversionKind::Implicit,
                                      /*Diagnose=*/true,
                                      /*DiagnoseCFAudited=*/false, Opc);
-        RHS = ImpCastExprToType(
-            E, LHSType, LPT ? CK_BitCast : CK_CPointerToObjCPointerCast);
+        RHS = ImpCastExprToType(E, LHSType,
+                                LPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
       }
       return computeResultTy();
     }
@@ -13260,7 +13254,7 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
         RHSType->isObjCObjectPointerType()) {
       if (!Context.areComparableObjCPointerTypes(LHSType, RHSType))
         diagnoseDistinctPointerComparison(*this, Loc, LHS, RHS,
-                                          /*isError*/ false);
+                                          /*isError*/false);
       if (isObjCObjectLiteral(LHS) || isObjCObjectLiteral(RHS))
         diagnoseObjCLiteralComparison(*this, Loc, LHS, RHS, Opc);
 
@@ -13296,9 +13290,8 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
       if (IsOrdered) {
         isError = getLangOpts().CPlusPlus;
         DiagID =
-            isError
-                ? diag::err_typecheck_ordered_comparison_of_pointer_and_zero
-                : diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
+          isError ? diag::err_typecheck_ordered_comparison_of_pointer_and_zero
+                  : diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
       }
     } else if (getLangOpts().CPlusPlus) {
       DiagID = diag::err_typecheck_comparison_of_pointer_integer;
@@ -13309,31 +13302,30 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
       DiagID = diag::ext_typecheck_comparison_of_pointer_integer;
 
     if (DiagID) {
-      Diag(Loc, DiagID) << LHSType << RHSType << LHS.get()->getSourceRange()
-                        << RHS.get()->getSourceRange();
+      Diag(Loc, DiagID)
+        << LHSType << RHSType << LHS.get()->getSourceRange()
+        << RHS.get()->getSourceRange();
       if (isError)
         return QualType();
     }
 
     if (LHSType->isIntegerType())
       LHS = ImpCastExprToType(LHS.get(), RHSType,
-                              LHSIsNull ? CK_NullToPointer
-                                        : CK_IntegralToPointer);
+                        LHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
     else
       RHS = ImpCastExprToType(RHS.get(), LHSType,
-                              RHSIsNull ? CK_NullToPointer
-                                        : CK_IntegralToPointer);
+                        RHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
     return computeResultTy();
   }
 
   // Handle block pointers.
-  if (!IsOrdered && RHSIsNull && LHSType->isBlockPointerType() &&
-      RHSType->isIntegerType()) {
+  if (!IsOrdered && RHSIsNull
+      && LHSType->isBlockPointerType() && RHSType->isIntegerType()) {
     RHS = ImpCastExprToType(RHS.get(), LHSType, CK_NullToPointer);
     return computeResultTy();
   }
-  if (!IsOrdered && LHSIsNull && LHSType->isIntegerType() &&
-      RHSType->isBlockPointerType()) {
+  if (!IsOrdered && LHSIsNull
+      && LHSType->isIntegerType() && RHSType->isBlockPointerType()) {
     LHS = ImpCastExprToType(LHS.get(), RHSType, CK_NullToPointer);
     return computeResultTy();
   }
@@ -13988,14 +13980,11 @@ inline QualType Sema::CheckLogicalOperands(ExprResult &LHS, ExprResult &RHS,
 
 static bool IsReadonlyMessage(Expr *E, Sema &S) {
   const MemberExpr *ME = dyn_cast<MemberExpr>(E);
-  if (!ME)
-    return false;
-  if (!isa<FieldDecl>(ME->getMemberDecl()))
-    return false;
+  if (!ME) return false;
+  if (!isa<FieldDecl>(ME->getMemberDecl())) return false;
   ObjCMessageExpr *Base = dyn_cast<ObjCMessageExpr>(
       ME->getBase()->IgnoreImplicit()->IgnoreParenImpCasts());
-  if (!Base)
-    return false;
+  if (!Base) return false;
   return Base->getMethodDecl() != nullptr;
 }
 
@@ -14009,10 +13998,8 @@ static NonConstCaptureKind isReferenceToNonConstCapture(Sema &S, Expr *E) {
 
   // Must be a reference to a declaration from an enclosing scope.
   DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E);
-  if (!DRE)
-    return NCCK_None;
-  if (!DRE->refersToEnclosingVariableOrCapture())
-    return NCCK_None;
+  if (!DRE) return NCCK_None;
+  if (!DRE->refersToEnclosingVariableOrCapture()) return NCCK_None;
 
   ValueDecl *Value = DRE->getDecl();
 
@@ -14151,8 +14138,8 @@ static void DiagnoseConstAssignment(Sema &S, const Expr *E,
     const FunctionDecl *FD = CE->getDirectCallee();
     if (FD && !IsTypeModifiable(FD->getReturnType(), IsDereference)) {
       if (!DiagnosticEmitted) {
-        S.Diag(Loc, diag::err_typecheck_assign_const)
-            << ExprRange << ConstFunction << FD;
+        S.Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
+                                                      << ConstFunction << FD;
         DiagnosticEmitted = true;
       }
       S.Diag(FD->getReturnTypeSourceRange().getBegin(),
@@ -14196,7 +14183,11 @@ static void DiagnoseConstAssignment(Sema &S, const Expr *E,
   S.Diag(Loc, diag::err_typecheck_assign_const) << ExprRange << ConstUnknown;
 }
 
-enum OriginalExprKind { OEK_Variable, OEK_Member, OEK_LValue };
+enum OriginalExprKind {
+  OEK_Variable,
+  OEK_Member,
+  OEK_LValue
+};
 
 static void DiagnoseRecursiveConstFields(Sema &S, const ValueDecl *VD,
                                          const RecordType *Ty,
@@ -14219,12 +14210,13 @@ static void DiagnoseRecursiveConstFields(Sema &S, const ValueDecl *VD,
       if (FieldTy.isConstQualified()) {
         if (!DiagnosticEmitted) {
           S.Diag(Loc, diag::err_typecheck_assign_const)
-              << Range << NestedConstMember << OEK << VD << IsNested << Field;
+              << Range << NestedConstMember << OEK << VD
+              << IsNested << Field;
           DiagnosticEmitted = true;
         }
         S.Diag(Field->getLocation(), diag::note_typecheck_assign_const)
-            << NestedConstMember << IsNested << Field << FieldTy
-            << Field->getSourceRange();
+            << NestedConstMember << IsNested << Field
+            << FieldTy << Field->getSourceRange();
       }
 
       // Then we append it to the list to check next in order.
@@ -14249,14 +14241,14 @@ static void DiagnoseRecursiveConstFields(Sema &S, const Expr *E,
   bool DiagEmitted = false;
 
   if (const MemberExpr *ME = dyn_cast<MemberExpr>(E))
-    DiagnoseRecursiveConstFields(S, ME->getMemberDecl(), RTy, Loc, Range,
-                                 OEK_Member, DiagEmitted);
+    DiagnoseRecursiveConstFields(S, ME->getMemberDecl(), RTy, Loc,
+            Range, OEK_Member, DiagEmitted);
   else if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
-    DiagnoseRecursiveConstFields(S, DRE->getDecl(), RTy, Loc, Range,
-                                 OEK_Variable, DiagEmitted);
+    DiagnoseRecursiveConstFields(S, DRE->getDecl(), RTy, Loc,
+            Range, OEK_Variable, DiagEmitted);
   else
-    DiagnoseRecursiveConstFields(S, nullptr, RTy, Loc, Range, OEK_LValue,
-                                 DiagEmitted);
+    DiagnoseRecursiveConstFields(S, nullptr, RTy, Loc,
+            Range, OEK_LValue, DiagEmitted);
   if (!DiagEmitted)
     DiagnoseConstAssignment(S, E, Loc);
 }
@@ -14269,7 +14261,8 @@ static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S) {
   S.CheckShadowingDeclModification(E, Loc);
 
   SourceLocation OrigLoc = Loc;
-  Expr::isModifiableLvalueResult IsLV = E->isModifiableLvalue(S.Context, &Loc);
+  Expr::isModifiableLvalueResult IsLV = E->isModifiableLvalue(S.Context,
+                                                              &Loc);
   if (IsLV == Expr::MLV_ClassTemporary && IsReadonlyMessage(E, S))
     IsLV = Expr::MLV_InvalidMessageExpression;
   if (IsLV == Expr::MLV_Valid)
@@ -14306,15 +14299,15 @@ static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S) {
           ObjCMethodDecl *method = S.getCurMethodDecl();
           if (method && var == method->getSelfDecl()) {
             DiagID = method->isClassMethod()
-                         ? diag::err_typecheck_arc_assign_self_class_method
-                         : diag::err_typecheck_arc_assign_self;
+              ? diag::err_typecheck_arc_assign_self_class_method
+              : diag::err_typecheck_arc_assign_self;
 
-            //  - Objective-C externally_retained attribute.
+          //  - Objective-C externally_retained attribute.
           } else if (var->hasAttr<ObjCExternallyRetainedAttr>() ||
                      isa<ParmVarDecl>(var)) {
             DiagID = diag::err_typecheck_arc_assign_externally_retained;
 
-            //  - fast enumeration variables
+          //  - fast enumeration variables
           } else {
             DiagID = diag::err_typecheck_arr_assign_enumeration;
           }
@@ -14365,9 +14358,8 @@ static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S) {
     break;
   case Expr::MLV_IncompleteType:
   case Expr::MLV_IncompleteVoidType:
-    return S.RequireCompleteType(
-        Loc, E->getType(),
-        diag::err_typecheck_incomplete_type_not_modifiable_lvalue, E);
+    return S.RequireCompleteType(Loc, E->getType(),
+             diag::err_typecheck_incomplete_type_not_modifiable_lvalue, E);
   case Expr::MLV_DuplicateVectorComponents:
     DiagID = diag::err_typecheck_duplicate_vector_components_not_mlvalue;
     break;
@@ -14395,7 +14387,8 @@ static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S) {
 }
 
 static void CheckIdentityFieldAssignment(Expr *LHSExpr, Expr *RHSExpr,
-                                         SourceLocation Loc, Sema &Sema) {
+                                         SourceLocation Loc,
+                                         Sema &Sema) {
   if (Sema.inTemplateInstantiation())
     return;
   if (Sema.isUnevaluatedContext())
@@ -14449,8 +14442,8 @@ QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS,
     return QualType();
 
   QualType LHSType = LHSExpr->getType();
-  QualType RHSType =
-      CompoundType.isNull() ? RHS.get()->getType() : CompoundType;
+  QualType RHSType = CompoundType.isNull() ? RHS.get()->getType() :
+                                             CompoundType;
 
   if (RHS.isUsable()) {
     // Even if this check fails don't return early to allow the best
@@ -14477,8 +14470,8 @@ QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS,
   if (getLangOpts().OpenCL &&
       !getOpenCLOptions().isAvailableOption("cl_khr_fp16", getLangOpts()) &&
       LHSType->isHalfType()) {
-    Diag(Loc, diag::err_opencl_half_load_store)
-        << 1 << LHSType.getUnqualifiedType();
+    Diag(Loc, diag::err_opencl_half_load_store) << 1
+        << LHSType.getUnqualifiedType();
     return QualType();
   }
 
@@ -14524,8 +14517,8 @@ QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS,
           Loc.getLocWithOffset(2) != UO->getSubExpr()->getBeginLoc() &&
           UO->getSubExpr()->getBeginLoc().isFileID()) {
         Diag(Loc, diag::warn_not_compound_assign)
-            << (UO->getOpcode() == UO_Plus ? "+" : "-")
-            << SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc());
+          << (UO->getOpcode() == UO_Plus ? "+" : "-")
+          << SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc());
       }
     }
 
@@ -14725,7 +14718,7 @@ static QualType CheckIncrementDecrementOperand(Sema &S, Expr *Op,
     // Increment of bool sets it to true, but is deprecated.
     S.Diag(OpLoc, S.getLangOpts().CPlusPlus17 ? diag::ext_increment_bool
                                               : diag::warn_increment_bool)
-        << Op->getSourceRange();
+      << Op->getSourceRange();
   } else if (S.getLangOpts().CPlusPlus && ResType->isEnumeralType()) {
     // Error on enum increments and decrements in C++ mode
     S.Diag(OpLoc, diag::err_increment_decrement_enum) << IsInc << ResType;
@@ -14751,10 +14744,9 @@ static QualType CheckIncrementDecrementOperand(Sema &S, Expr *Op,
         << IsInc << Op->getSourceRange();
   } else if (ResType->isPlaceholderType()) {
     ExprResult PR = S.CheckPlaceholderExpr(Op);
-    if (PR.isInvalid())
-      return QualType();
-    return CheckIncrementDecrementOperand(S, PR.get(), VK, OK, OpLoc, IsInc,
-                                          IsPrefix);
+    if (PR.isInvalid()) return QualType();
+    return CheckIncrementDecrementOperand(S, PR.get(), VK, OK, OpLoc,
+                                          IsInc, IsPrefix);
   } else if (S.getLangOpts().AltiVec && ResType->isVectorType()) {
     // OK! ( C/C++ Language Extensions for CBEA(Version 2.6) 10.3 )
   } else if (S.getLangOpts().ZVector && ResType->isVectorType() &&
@@ -14766,7 +14758,7 @@ static QualType CheckIncrementDecrementOperand(Sema &S, Expr *Op,
     // OpenCL V1.2 6.3 says dec/inc ops operate on integer vector types.
   } else {
     S.Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
-        << ResType << int(IsInc) << Op->getSourceRange();
+      << ResType << int(IsInc) << Op->getSourceRange();
     return QualType();
   }
   // At this point, we know we have a real, complex or pointer type.
@@ -14822,8 +14814,8 @@ static ValueDecl *getPrimaryDecl(Expr *E) {
   case Stmt::ArraySubscriptExprClass: {
     // FIXME: This code shouldn't be necessary!  We should catch the implicit
     // promotion of register arrays earlier.
-    Expr *Base = cast<ArraySubscriptExpr>(E)->getBase();
-    if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Base)) {
+    Expr* Base = cast<ArraySubscriptExpr>(E)->getBase();
+    if (ImplicitCastExpr* ICE = dyn_cast<ImplicitCastExpr>(Base)) {
       if (ICE->getSubExpr()->getType()->isArrayType())
         return getPrimaryDecl(ICE->getSubExpr());
     }
@@ -14832,7 +14824,7 @@ static ValueDecl *getPrimaryDecl(Expr *E) {
   case Stmt::UnaryOperatorClass: {
     UnaryOperator *UO = cast<UnaryOperator>(E);
 
-    switch (UO->getOpcode()) {
+    switch(UO->getOpcode()) {
     case UO_Real:
     case UO_Imag:
     case UO_Extension:
@@ -14867,8 +14859,8 @@ enum {
 /// Diagnose invalid operand for address of operations.
 ///
 /// \param Type The type of operand which cannot have its address taken.
-static void diagnoseAddressOfInvalidType(Sema &S, SourceLocation Loc, Expr *E,
-                                         unsigned Type) {
+static void diagnoseAddressOfInvalidType(Sema &S, SourceLocation Loc,
+                                         Expr *E, unsigned Type) {
   S.Diag(Loc, diag::err_typecheck_address_of) << Type << E->getSourceRange();
 }
 
@@ -14901,14 +14893,13 @@ bool Sema::CheckUseOfCXXMethodAsAddressOfOperand(SourceLocation OpLoc,
 }
 
 QualType Sema::CheckAddressOfOperand(ExprResult &OrigOp, SourceLocation OpLoc) {
-  if (const BuiltinType *PTy =
-          OrigOp.get()->getType()->getAsPlaceholderType()) {
+  if (const BuiltinType *PTy = OrigOp.get()->getType()->getAsPlaceholderType()){
     if (PTy->getKind() == BuiltinType::Overload) {
       Expr *E = OrigOp.get()->IgnoreParens();
       if (!isa<OverloadExpr>(E)) {
         assert(cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf);
         Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof_addrof_function)
-            << OrigOp.get()->getSourceRange();
+          << OrigOp.get()->getSourceRange();
         return QualType();
       }
 
@@ -14916,7 +14907,7 @@ QualType Sema::CheckAddressOfOperand(ExprResult &OrigOp, SourceLocation OpLoc) {
       if (isa<UnresolvedMemberExpr>(Ovl))
         if (!ResolveSingleFunctionTemplateSpecialization(Ovl)) {
           Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
-              << OrigOp.get()->getSourceRange();
+            << OrigOp.get()->getSourceRange();
           return QualType();
         }
 
@@ -14928,13 +14919,12 @@ QualType Sema::CheckAddressOfOperand(ExprResult &OrigOp, SourceLocation OpLoc) {
 
     if (PTy->getKind() == BuiltinType::BoundMember) {
       Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
-          << OrigOp.get()->getSourceRange();
+        << OrigOp.get()->getSourceRange();
       return QualType();
     }
 
     OrigOp = CheckPlaceholderExpr(OrigOp.get());
-    if (OrigOp.isInvalid())
-      return QualType();
+    if (OrigOp.isInvalid()) return QualType();
   }
 
   if (OrigOp.get()->isTypeDependent())
@@ -14951,7 +14941,7 @@ QualType Sema::CheckAddressOfOperand(ExprResult &OrigOp, SourceLocation OpLoc) {
   // depending on a vendor implementation. Thus preventing
   // taking an address of the capture to avoid invalid AS casts.
   if (LangOpts.OpenCL) {
-    auto *VarRef = dyn_cast<DeclRefExpr>(op);
+    auto* VarRef = dyn_cast<DeclRefExpr>(op);
     if (VarRef && VarRef->refersToEnclosingVariableOrCapture()) {
       Diag(op->getExprLoc(), diag::err_opencl_taking_address_capture);
       return QualType();
@@ -14960,7 +14950,7 @@ QualType Sema::CheckAddressOfOperand(ExprResult &OrigOp, SourceLocation OpLoc) {
 
   if (getLangOpts().C99) {
     // Implement C99-only parts of addressof rules.
-    if (UnaryOperator *uOp = dyn_cast<UnaryOperator>(op)) {
+    if (UnaryOperator* uOp = dyn_cast<UnaryOperator>(op)) {
       if (uOp->getOpcode() == UO_Deref)
         // Per C99 6.5.3.2, the address of a deref always returns a valid result
         // (assuming the deref expression is valid).
@@ -14998,7 +14988,7 @@ QualType Sema::CheckAddressOfOperand(ExprResult &OrigOp, SourceLocation OpLoc) {
     // If the underlying expression isn't a decl ref, give up.
     if (!isa<DeclRefExpr>(op)) {
       Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
-          << OrigOp.get()->getSourceRange();
+        << OrigOp.get()->getSourceRange();
       return QualType();
     }
     DeclRefExpr *DRE = cast<DeclRefExpr>(op);
@@ -15053,7 +15043,7 @@ QualType Sema::CheckAddressOfOperand(ExprResult &OrigOp, SourceLocation OpLoc) {
         AddressOfError = AO_Property_Expansion;
       } else {
         Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof)
-            << op->getType() << op->getSourceRange();
+          << op->getType() << op->getSourceRange();
         return QualType();
       }
     } else if (const auto *DRE = dyn_cast<DeclRefExpr>(op)) {
@@ -15076,7 +15066,8 @@ QualType Sema::CheckAddressOfOperand(ExprResult &OrigOp, SourceLocation OpLoc) {
     if (const VarDecl *vd = dyn_cast<VarDecl>(dcl)) {
       // in C++ it is not error to take address of a register
       // variable (c++03 7.1.1P3)
-      if (vd->getStorageClass() == SC_Register && !getLangOpts().CPlusPlus) {
+      if (vd->getStorageClass() == SC_Register &&
+          !getLangOpts().CPlusPlus) {
         AddressOfError = AO_Register_Variable;
       }
     } else if (isa<MSPropertyDecl>(dcl)) {
@@ -15100,7 +15091,7 @@ QualType Sema::CheckAddressOfOperand(ExprResult &OrigOp, SourceLocation OpLoc) {
           if (dcl->getType()->isReferenceType()) {
             Diag(OpLoc,
                  diag::err_cannot_form_pointer_to_member_of_reference_type)
-                << dcl->getDeclName() << dcl->getType();
+              << dcl->getDeclName() << dcl->getType();
             return QualType();
           }
 
@@ -15167,7 +15158,7 @@ static void RecordModifiableNonNullParam(Sema &S, const Expr *Exp) {
   const ParmVarDecl *Param = dyn_cast<ParmVarDecl>(D);
   if (!Param)
     return;
-  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(Param->getDeclContext()))
+  if (const FunctionDecl* FD = dyn_cast<FunctionDecl>(Param->getDeclContext()))
     if (!FD->hasAttr<NonNullAttr>() && !Param->hasAttr<NonNullAttr>())
       return;
   if (FunctionScopeInfo *FD = S.getCurFunction())
@@ -15187,26 +15178,27 @@ static QualType CheckIndirectionOperand(Sema &S, Expr *Op, ExprValueKind &VK,
 
   if (isa<CXXReinterpretCastExpr>(Op->IgnoreParens())) {
     QualType OpOrigType = Op->IgnoreParenCasts()->getType();
-    S.CheckCompatibleReinterpretCast(OpOrigType, OpTy, /*IsDereference*/ true,
+    S.CheckCompatibleReinterpretCast(OpOrigType, OpTy, /*IsDereference*/true,
                                      Op->getSourceRange());
   }
 
-  if (const PointerType *PT = OpTy->getAs<PointerType>()) {
+  if (const PointerType *PT = OpTy->getAs<PointerType>())
+  {
     Result = PT->getPointeeType();
-  } else if (const ObjCObjectPointerType *OPT =
-                 OpTy->getAs<ObjCObjectPointerType>())
+  }
+  else if (const ObjCObjectPointerType *OPT =
+             OpTy->getAs<ObjCObjectPointerType>())
     Result = OPT->getPointeeType();
   else {
     ExprResult PR = S.CheckPlaceholderExpr(Op);
-    if (PR.isInvalid())
-      return QualType();
+    if (PR.isInvalid()) return QualType();
     if (PR.get() != Op)
       return CheckIndirectionOperand(S, PR.get(), VK, OpLoc);
   }
 
   if (Result.isNull()) {
     S.Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer)
-        << OpTy << Op->getSourceRange();
+      << OpTy << Op->getSourceRange();
     return QualType();
   }
 
@@ -15236,150 +15228,60 @@ static QualType CheckIndirectionOperand(Sema &S, Expr *Op, ExprValueKind &VK,
 BinaryOperatorKind Sema::ConvertTokenKindToBinaryOpcode(tok::TokenKind Kind) {
   BinaryOperatorKind Opc;
   switch (Kind) {
-  default:
-    llvm_unreachable("Unknown binop!");
-  case tok::periodstar:
-    Opc = BO_PtrMemD;
-    break;
-  case tok::arrowstar:
-    Opc = BO_PtrMemI;
-    break;
-  case tok::star:
-    Opc = BO_Mul;
-    break;
-  case tok::slash:
-    Opc = BO_Div;
-    break;
-  case tok::percent:
-    Opc = BO_Rem;
-    break;
-  case tok::plus:
-    Opc = BO_Add;
-    break;
-  case tok::minus:
-    Opc = BO_Sub;
-    break;
-  case tok::lessless:
-    Opc = BO_Shl;
-    break;
-  case tok::greatergreater:
-    Opc = BO_Shr;
-    break;
-  case tok::lessequal:
-    Opc = BO_LE;
-    break;
-  case tok::less:
-    Opc = BO_LT;
-    break;
-  case tok::greaterequal:
-    Opc = BO_GE;
-    break;
-  case tok::greater:
-    Opc = BO_GT;
-    break;
-  case tok::exclaimequal:
-    Opc = BO_NE;
-    break;
-  case tok::equalequal:
-    Opc = BO_EQ;
-    break;
-  case tok::spaceship:
-    Opc = BO_Cmp;
-    break;
-  case tok::amp:
-    Opc = BO_And;
-    break;
-  case tok::caret:
-    Opc = BO_Xor;
-    break;
-  case tok::pipe:
-    Opc = BO_Or;
-    break;
-  case tok::ampamp:
-    Opc = BO_LAnd;
-    break;
-  case tok::pipepipe:
-    Opc = BO_LOr;
-    break;
-  case tok::equal:
-    Opc = BO_Assign;
-    break;
-  case tok::starequal:
-    Opc = BO_MulAssign;
-    break;
-  case tok::slashequal:
-    Opc = BO_DivAssign;
-    break;
-  case tok::percentequal:
-    Opc = BO_RemAssign;
-    break;
-  case tok::plusequal:
-    Opc = BO_AddAssign;
-    break;
-  case tok::minusequal:
-    Opc = BO_SubAssign;
-    break;
-  case tok::lesslessequal:
-    Opc = BO_ShlAssign;
-    break;
-  case tok::greatergreaterequal:
-    Opc = BO_ShrAssign;
-    break;
-  case tok::ampequal:
-    Opc = BO_AndAssign;
-    break;
-  case tok::caretequal:
-    Opc = BO_XorAssign;
-    break;
-  case tok::pipeequal:
-    Opc = BO_OrAssign;
-    break;
-  case tok::comma:
-    Opc = BO_Comma;
-    break;
+  default: llvm_unreachable("Unknown binop!");
+  case tok::periodstar:           Opc = BO_PtrMemD; break;
+  case tok::arrowstar:            Opc = BO_PtrMemI; break;
+  case tok::star:                 Opc = BO_Mul; break;
+  case tok::slash:                Opc = BO_Div; break;
+  case tok::percent:              Opc = BO_Rem; break;
+  case tok::plus:                 Opc = BO_Add; break;
+  case tok::minus:                Opc = BO_Sub; break;
+  case tok::lessless:             Opc = BO_Shl; break;
+  case tok::greatergreater:       Opc = BO_Shr; break;
+  case tok::lessequal:            Opc = BO_LE; break;
+  case tok::less:                 Opc = BO_LT; break;
+  case tok::greaterequal:         Opc = BO_GE; break;
+  case tok::greater:              Opc = BO_GT; break;
+  case tok::exclaimequal:         Opc = BO_NE; break;
+  case tok::equalequal:           Opc = BO_EQ; break;
+  case tok::spaceship:            Opc = BO_Cmp; break;
+  case tok::amp:                  Opc = BO_And; break;
+  case tok::caret:                Opc = BO_Xor; break;
+  case tok::pipe:                 Opc = BO_Or; break;
+  case tok::ampamp:               Opc = BO_LAnd; break;
+  case tok::pipepipe:             Opc = BO_LOr; break;
+  case tok::equal:                Opc = BO_Assign; break;
+  case tok::starequal:            Opc = BO_MulAssign; break;
+  case tok::slashequal:           Opc = BO_DivAssign; break;
+  case tok::percentequal:         Opc = BO_RemAssign; break;
+  case tok::plusequal:            Opc = BO_AddAssign; break;
+  case tok::minusequal:           Opc = BO_SubAssign; break;
+  case tok::lesslessequal:        Opc = BO_ShlAssign; break;
+  case tok::greatergreaterequal:  Opc = BO_ShrAssign; break;
+  case tok::ampequal:             Opc = BO_AndAssign; break;
+  case tok::caretequal:           Opc = BO_XorAssign; break;
+  case tok::pipeequal:            Opc = BO_OrAssign; break;
+  case tok::comma:                Opc = BO_Comma; break;
   }
   return Opc;
 }
 
-static inline UnaryOperatorKind
-ConvertTokenKindToUnaryOpcode(tok::TokenKind Kind) {
+static inline UnaryOperatorKind ConvertTokenKindToUnaryOpcode(
+  tok::TokenKind Kind) {
   UnaryOperatorKind Opc;
   switch (Kind) {
-  default:
-    llvm_unreachable("Unknown unary op!");
-  case tok::plusplus:
-    Opc = UO_PreInc;
-    break;
-  case tok::minusminus:
-    Opc = UO_PreDec;
-    break;
-  case tok::amp:
-    Opc = UO_AddrOf;
-    break;
-  case tok::star:
-    Opc = UO_Deref;
-    break;
-  case tok::plus:
-    Opc = UO_Plus;
-    break;
-  case tok::minus:
-    Opc = UO_Minus;
-    break;
-  case tok::tilde:
-    Opc = UO_Not;
-    break;
-  case tok::exclaim:
-    Opc = UO_LNot;
-    break;
-  case tok::kw___real:
-    Opc = UO_Real;
-    break;
-  case tok::kw___imag:
-    Opc = UO_Imag;
-    break;
-  case tok::kw___extension__:
-    Opc = UO_Extension;
-    break;
+  default: llvm_unreachable("Unknown unary op!");
+  case tok::plusplus:     Opc = UO_PreInc; break;
+  case tok::minusminus:   Opc = UO_PreDec; break;
+  case tok::amp:          Opc = UO_AddrOf; break;
+  case tok::star:         Opc = UO_Deref; break;
+  case tok::plus:         Opc = UO_Plus; break;
+  case tok::minus:        Opc = UO_Minus; break;
+  case tok::tilde:        Opc = UO_Not; break;
+  case tok::exclaim:      Opc = UO_LNot; break;
+  case tok::kw___real:    Opc = UO_Real; break;
+  case tok::kw___imag:    Opc = UO_Imag; break;
+  case tok::kw___extension__: Opc = UO_Extension; break;
   }
   return Opc;
 }
@@ -15432,13 +15334,14 @@ static void DiagnoseSelfAssignment(Sema &S, Expr *LHSExpr, Expr *RHSExpr,
   RHSExpr = RHSExpr->IgnoreParenImpCasts();
   const DeclRefExpr *LHSDeclRef = dyn_cast<DeclRefExpr>(LHSExpr);
   const DeclRefExpr *RHSDeclRef = dyn_cast<DeclRefExpr>(RHSExpr);
-  if (!LHSDeclRef || !RHSDeclRef || LHSDeclRef->getLocation().isMacroID() ||
+  if (!LHSDeclRef || !RHSDeclRef ||
+      LHSDeclRef->getLocation().isMacroID() ||
       RHSDeclRef->getLocation().isMacroID())
     return;
   const ValueDecl *LHSDecl =
-      cast<ValueDecl>(LHSDeclRef->getDecl()->getCanonicalDecl());
+    cast<ValueDecl>(LHSDeclRef->getDecl()->getCanonicalDecl());
   const ValueDecl *RHSDecl =
-      cast<ValueDecl>(RHSDeclRef->getDecl()->getCanonicalDecl());
+    cast<ValueDecl>(RHSDeclRef->getDecl()->getCanonicalDecl());
   if (LHSDecl != RHSDecl)
     return;
   if (LHSDecl->getType().isVolatileQualified())
@@ -15473,7 +15376,8 @@ static void checkObjCPointerIntrospection(Sema &S, ExprResult &L, ExprResult &R,
   if (LHS->IgnoreParenCasts()->getType()->isObjCObjectPointerType()) {
     ObjCPointerExpr = LHS;
     OtherExpr = RHS;
-  } else if (RHS->IgnoreParenCasts()->getType()->isObjCObjectPointerType()) {
+  }
+  else if (RHS->IgnoreParenCasts()->getType()->isObjCObjectPointerType()) {
     ObjCPointerExpr = RHS;
     OtherExpr = LHS;
   }
@@ -15496,7 +15400,8 @@ static void checkObjCPointerIntrospection(Sema &S, ExprResult &L, ExprResult &R,
         Diag = diag::warn_objc_pointer_masking_performSelector;
     }
 
-    S.Diag(OpLoc, Diag) << ObjCPointerExpr->getSourceRange();
+    S.Diag(OpLoc, Diag)
+      << ObjCPointerExpr->getSourceRange();
   }
 }
 
@@ -15583,7 +15488,7 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
   }
 
   ExprResult LHS = LHSExpr, RHS = RHSExpr;
-  QualType ResultTy; // Result type of the binary operator.
+  QualType ResultTy;     // Result type of the binary operator.
   // The following two variables are used for compound assignment operators
   QualType CompLHSTy;    // Type of LHS after promotions for computation
   QualType CompResultTy; // Type of computation result
@@ -15610,8 +15515,9 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
 
     // OpenCL special types - image, sampler, pipe, and blocks are to be used
     // only with a builtin functions and therefore should be disallowed here.
-    if (LHSTy->isImageType() || RHSTy->isImageType() || LHSTy->isSamplerT() ||
-        RHSTy->isSamplerT() || LHSTy->isPipeType() || RHSTy->isPipeType() ||
+    if (LHSTy->isImageType() || RHSTy->isImageType() ||
+        LHSTy->isSamplerT() || RHSTy->isSamplerT() ||
+        LHSTy->isPipeType() || RHSTy->isPipeType() ||
         LHSTy->isBlockPointerType() || RHSTy->isBlockPointerType()) {
       ResultTy = InvalidOperands(OpLoc, LHS, RHS);
       return ExprError();
@@ -15660,8 +15566,8 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
     break;
   case BO_PtrMemD:
   case BO_PtrMemI:
-    ResultTy =
-        CheckPointerToMemberOperands(LHS, RHS, VK, OpLoc, Opc == BO_PtrMemI);
+    ResultTy = CheckPointerToMemberOperands(LHS, RHS, VK, OpLoc,
+                                            Opc == BO_PtrMemI);
     break;
   case BO_Mul:
   case BO_Div:
@@ -15793,11 +15699,10 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
   CheckArrayAccess(LHS.get());
   CheckArrayAccess(RHS.get());
 
-  if (const ObjCIsaExpr *OISA =
-          dyn_cast<ObjCIsaExpr>(LHS.get()->IgnoreParenCasts())) {
-    NamedDecl *ObjectSetClass =
-        LookupSingleName(TUScope, &Context.Idents.get("object_setClass"),
-                         SourceLocation(), LookupOrdinaryName);
+  if (const ObjCIsaExpr *OISA = dyn_cast<ObjCIsaExpr>(LHS.get()->IgnoreParenCasts())) {
+    NamedDecl *ObjectSetClass = LookupSingleName(TUScope,
+                                                 &Context.Idents.get("object_setClass"),
+                                                 SourceLocation(), LookupOrdinaryName);
     if (ObjectSetClass && isa<ObjCIsaExpr>(LHS.get())) {
       SourceLocation RHSLocEnd = getLocForEndOfToken(RHS.get()->getEndLoc());
       Diag(LHS.get()->getExprLoc(), diag::warn_objc_isa_assign)
@@ -15806,10 +15711,12 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
           << FixItHint::CreateReplacement(SourceRange(OISA->getOpLoc(), OpLoc),
                                           ",")
           << FixItHint::CreateInsertion(RHSLocEnd, ")");
-    } else
+    }
+    else
       Diag(LHS.get()->getExprLoc(), diag::warn_objc_isa_assign);
-  } else if (const ObjCIvarRefExpr *OIRE =
-                 dyn_cast<ObjCIvarRefExpr>(LHS.get()->IgnoreParenCasts()))
+  }
+  else if (const ObjCIvarRefExpr *OIRE =
+           dyn_cast<ObjCIvarRefExpr>(LHS.get()->IgnoreParenCasts()))
     DiagnoseDirectIsaAccess(*this, OIRE, OpLoc, RHS.get());
 
   // Opc is not a compound assignment if CompResultTy is null.
@@ -15822,8 +15729,8 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
   }
 
   // Handle compound assignments.
-  if (getLangOpts().CPlusPlus &&
-      LHS.get()->getObjectKind() != OK_ObjCProperty) {
+  if (getLangOpts().CPlusPlus && LHS.get()->getObjectKind() !=
+      OK_ObjCProperty) {
     VK = VK_LValue;
     OK = LHS.get()->getObjectKind();
   }
@@ -15876,29 +15783,29 @@ static void DiagnoseBitwisePrecedence(Sema &Self, BinaryOperatorKind Opc,
           : SourceRange(LHSExpr->getBeginLoc(), RHSBO->getLHS()->getEndLoc());
 
   Self.Diag(OpLoc, diag::warn_precedence_bitwise_rel)
-      << DiagRange << BinaryOperator::getOpcodeStr(Opc) << OpStr;
+    << DiagRange << BinaryOperator::getOpcodeStr(Opc) << OpStr;
   SuggestParentheses(Self, OpLoc,
-                     Self.PDiag(diag::note_precedence_silence) << OpStr,
-                     (isLeftComp ? LHSExpr : RHSExpr)->getSourceRange());
+    Self.PDiag(diag::note_precedence_silence) << OpStr,
+    (isLeftComp ? LHSExpr : RHSExpr)->getSourceRange());
   SuggestParentheses(Self, OpLoc,
-                     Self.PDiag(diag::note_precedence_bitwise_first)
-                         << BinaryOperator::getOpcodeStr(Opc),
-                     ParensRange);
+    Self.PDiag(diag::note_precedence_bitwise_first)
+      << BinaryOperator::getOpcodeStr(Opc),
+    ParensRange);
 }
 
 /// It accepts a '&&' expr that is inside a '||' one.
 /// Emit a diagnostic together with a fixit hint that wraps the '&&' expression
 /// in parentheses.
-static void EmitDiagnosticForLogicalAndInLogicalOr(Sema &Self,
-                                                   SourceLocation OpLoc,
-                                                   BinaryOperator *Bop) {
+static void
+EmitDiagnosticForLogicalAndInLogicalOr(Sema &Self, SourceLocation OpLoc,
+                                       BinaryOperator *Bop) {
   assert(Bop->getOpcode() == BO_LAnd);
   Self.Diag(Bop->getOperatorLoc(), diag::warn_logical_and_in_logical_or)
       << Bop->getSourceRange() << OpLoc;
   SuggestParentheses(Self, Bop->getOperatorLoc(),
-                     Self.PDiag(diag::note_precedence_silence)
-                         << Bop->getOpcodeStr(),
-                     Bop->getSourceRange());
+    Self.PDiag(diag::note_precedence_silence)
+      << Bop->getOpcodeStr(),
+    Bop->getSourceRange());
 }
 
 /// Look for '&&' in the left hand of a '||' expr.
@@ -15943,12 +15850,12 @@ static void DiagnoseBitwiseOpInBitwiseOp(Sema &S, BinaryOperatorKind Opc,
   if (BinaryOperator *Bop = dyn_cast<BinaryOperator>(SubExpr)) {
     if (Bop->isBitwiseOp() && Bop->getOpcode() < Opc) {
       S.Diag(Bop->getOperatorLoc(), diag::warn_bitwise_op_in_bitwise_op)
-          << Bop->getOpcodeStr() << BinaryOperator::getOpcodeStr(Opc)
-          << Bop->getSourceRange() << OpLoc;
+        << Bop->getOpcodeStr() << BinaryOperator::getOpcodeStr(Opc)
+        << Bop->getSourceRange() << OpLoc;
       SuggestParentheses(S, Bop->getOperatorLoc(),
-                         S.PDiag(diag::note_precedence_silence)
-                             << Bop->getOpcodeStr(),
-                         Bop->getSourceRange());
+        S.PDiag(diag::note_precedence_silence)
+          << Bop->getOpcodeStr(),
+        Bop->getSourceRange());
     }
   }
 }
@@ -15961,14 +15868,14 @@ static void DiagnoseAdditionInShift(Sema &S, SourceLocation OpLoc,
       S.Diag(Bop->getOperatorLoc(), diag::warn_addition_in_bitshift)
           << Bop->getSourceRange() << OpLoc << Shift << Op;
       SuggestParentheses(S, Bop->getOperatorLoc(),
-                         S.PDiag(diag::note_precedence_silence) << Op,
-                         Bop->getSourceRange());
+          S.PDiag(diag::note_precedence_silence) << Op,
+          Bop->getSourceRange());
     }
   }
 }
 
-static void DiagnoseShiftCompare(Sema &S, SourceLocation OpLoc, Expr *LHSExpr,
-                                 Expr *RHSExpr) {
+static void DiagnoseShiftCompare(Sema &S, SourceLocation OpLoc,
+                                 Expr *LHSExpr, Expr *RHSExpr) {
   CXXOperatorCallExpr *OCE = dyn_cast<CXXOperatorCallExpr>(LHSExpr);
   if (!OCE)
     return;
@@ -15997,28 +15904,27 @@ static void DiagnoseShiftCompare(Sema &S, SourceLocation OpLoc, Expr *LHSExpr,
 /// precedence.
 static void DiagnoseBinOpPrecedence(Sema &Self, BinaryOperatorKind Opc,
                                     SourceLocation OpLoc, Expr *LHSExpr,
-                                    Expr *RHSExpr) {
+                                    Expr *RHSExpr){
   // Diagnose "arg1 'bitwise' arg2 'eq' arg3".
   if (BinaryOperator::isBitwiseOp(Opc))
     DiagnoseBitwisePrecedence(Self, Opc, OpLoc, LHSExpr, RHSExpr);
 
   // Diagnose "arg1 & arg2 | arg3"
   if ((Opc == BO_Or || Opc == BO_Xor) &&
-      !OpLoc.isMacroID() /* Don't warn in macros. */) {
+      !OpLoc.isMacroID()/* Don't warn in macros. */) {
     DiagnoseBitwiseOpInBitwiseOp(Self, Opc, OpLoc, LHSExpr);
     DiagnoseBitwiseOpInBitwiseOp(Self, Opc, OpLoc, RHSExpr);
   }
 
   // Warn about arg1 || arg2 && arg3, as GCC 4.3+ does.
   // We don't warn for 'assert(a || b && "bad")' since this is safe.
-  if (Opc == BO_LOr && !OpLoc.isMacroID() /* Don't warn in macros. */) {
+  if (Opc == BO_LOr && !OpLoc.isMacroID()/* Don't warn in macros. */) {
     DiagnoseLogicalAndInLogicalOrLHS(Self, OpLoc, LHSExpr, RHSExpr);
     DiagnoseLogicalAndInLogicalOrRHS(Self, OpLoc, LHSExpr, RHSExpr);
   }
 
-  if ((Opc == BO_Shl &&
-       LHSExpr->getType()->isIntegralType(Self.getASTContext())) ||
-      Opc == BO_Shr) {
+  if ((Opc == BO_Shl && LHSExpr->getType()->isIntegralType(Self.getASTContext()))
+      || Opc == BO_Shr) {
     StringRef Shift = BinaryOperator::getOpcodeStr(Opc);
     DiagnoseAdditionInShift(Self, OpLoc, LHSExpr, Shift);
     DiagnoseAdditionInShift(Self, OpLoc, RHSExpr, Shift);
@@ -16031,7 +15937,8 @@ static void DiagnoseBinOpPrecedence(Sema &Self, BinaryOperatorKind Opc,
 }
 
 ExprResult Sema::ActOnBinOp(Scope *S, SourceLocation TokLoc,
-                            tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr) {
+                            tok::TokenKind Kind,
+                            Expr *LHSExpr, Expr *RHSExpr) {
   BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Kind);
   assert(LHSExpr && "ActOnBinOp(): missing left expression");
   assert(RHSExpr && "ActOnBinOp(): missing right expression");
@@ -16064,8 +15971,8 @@ void Sema::LookupBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc,
 
 /// Build an overloaded binary operator expression in the given scope.
 static ExprResult BuildOverloadedBinOp(Sema &S, Scope *Sc, SourceLocation OpLoc,
-                                       BinaryOperatorKind Opc, Expr *LHS,
-                                       Expr *RHS) {
+                                       BinaryOperatorKind Opc,
+                                       Expr *LHS, Expr *RHS) {
   switch (Opc) {
   case BO_Assign:
     // In the non-overloaded case, we warn about self-assignment (x = x) for
@@ -16126,8 +16033,7 @@ ExprResult Sema::BuildBinOp(Scope *S, SourceLocation OpLoc,
       // that an overload set can be dependently-typed, but it never
       // instantiates to having an overloadable type.
       ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
-      if (resolvedRHS.isInvalid())
-        return ExprError();
+      if (resolvedRHS.isInvalid()) return ExprError();
       RHSExpr = resolvedRHS.get();
 
       if (RHSExpr->isTypeDependent() ||
@@ -16158,8 +16064,7 @@ ExprResult Sema::BuildBinOp(Scope *S, SourceLocation OpLoc,
     }
 
     ExprResult LHS = CheckPlaceholderExpr(LHSExpr);
-    if (LHS.isInvalid())
-      return ExprError();
+    if (LHS.isInvalid()) return ExprError();
     LHSExpr = LHS.get();
   }
 
@@ -16183,8 +16088,7 @@ ExprResult Sema::BuildBinOp(Scope *S, SourceLocation OpLoc,
       return BuildOverloadedBinOp(*this, S, OpLoc, Opc, LHSExpr, RHSExpr);
 
     ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
-    if (!resolvedRHS.isUsable())
-      return ExprError();
+    if (!resolvedRHS.isUsable()) return ExprError();
     RHSExpr = resolvedRHS.get();
   }
 
@@ -16272,11 +16176,10 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc,
     QualType Ty = InputExpr->getType();
     // The only legal unary operation for atomics is '&'.
     if ((Opc != UO_AddrOf && Ty->isAtomicType()) ||
-        // OpenCL special types - image, sampler, pipe, and blocks are to be
-        // used only with a builtin functions and therefore should be disallowed
-        // here.
-        (Ty->isImageType() || Ty->isSamplerT() || Ty->isPipeType() ||
-         Ty->isBlockPointerType())) {
+    // OpenCL special types - image, sampler, pipe, and blocks are to be used
+    // only with a builtin functions and therefore should be disallowed here.
+        (Ty->isImageType() || Ty->isSamplerT() || Ty->isPipeType()
+        || Ty->isBlockPointerType())) {
       return ExprError(Diag(OpLoc, diag::err_typecheck_unary_expr)
                        << InputExpr->getType()
                        << Input.get()->getSourceRange());
@@ -16573,15 +16476,15 @@ ExprResult Sema::BuildUnaryOp(Scope *S, SourceLocation OpLoc,
 
     // & gets special logic for several kinds of placeholder.
     // The builtin code knows what to do.
-    if (Opc == UO_AddrOf && (pty->getKind() == BuiltinType::Overload ||
-                             pty->getKind() == BuiltinType::UnknownAny ||
-                             pty->getKind() == BuiltinType::BoundMember))
+    if (Opc == UO_AddrOf &&
+        (pty->getKind() == BuiltinType::Overload ||
+         pty->getKind() == BuiltinType::UnknownAny ||
+         pty->getKind() == BuiltinType::BoundMember))
       return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
 
     // Anything else needs to be handled now.
     ExprResult Result = CheckPlaceholderExpr(Input);
-    if (Result.isInvalid())
-      return ExprError();
+    if (Result.isInvalid()) return ExprError();
     Input = Result.get();
   }
 
@@ -16719,32 +16622,32 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc,
   // a struct/union/class.
   if (!Dependent && !ArgTy->isRecordType())
     return ExprError(Diag(BuiltinLoc, diag::err_offsetof_record_type)
-                     << ArgTy << TypeRange);
+                       << ArgTy << TypeRange);
 
   // Type must be complete per C99 7.17p3 because a declaring a variable
   // with an incomplete type would be ill-formed.
-  if (!Dependent &&
-      RequireCompleteType(BuiltinLoc, ArgTy, diag::err_offsetof_incomplete_type,
-                          TypeRange))
+  if (!Dependent
+      && RequireCompleteType(BuiltinLoc, ArgTy,
+                             diag::err_offsetof_incomplete_type, TypeRange))
     return ExprError();
 
   bool DidWarnAboutNonPOD = false;
   QualType CurrentType = ArgTy;
   SmallVector<OffsetOfNode, 4> Comps;
-  SmallVector<Expr *, 4> Exprs;
+  SmallVector<Expr*, 4> Exprs;
   for (const OffsetOfComponent &OC : Components) {
     if (OC.isBrackets) {
       // Offset of an array sub-field.  TODO: Should we allow vector elements?
       if (!CurrentType->isDependentType()) {
         const ArrayType *AT = Context.getAsArrayType(CurrentType);
-        if (!AT)
+        if(!AT)
           return ExprError(Diag(OC.LocEnd, diag::err_offsetof_array_type)
                            << CurrentType);
         CurrentType = AT->getElementType();
       } else
         CurrentType = Context.DependentTy;
 
-      ExprResult IdxRval = DefaultLvalueConversion(static_cast<Expr *>(OC.U.E));
+      ExprResult IdxRval = DefaultLvalueConversion(static_cast<Expr*>(OC.U.E));
       if (IdxRval.isInvalid())
         return ExprError();
       Expr *Idx = IdxRval.get();
@@ -16791,10 +16694,9 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc,
     //   If type is not a standard-layout class (Clause 9), the results are
     //   undefined.
     if (CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(RD)) {
-      bool IsSafe =
-          LangOpts.CPlusPlus11 ? CRD->isStandardLayout() : CRD->isPOD();
-      unsigned DiagID = LangOpts.CPlusPlus11
-                            ? diag::ext_offsetof_non_standardlayout_type
+      bool IsSafe = LangOpts.CPlusPlus11? CRD->isStandardLayout() : CRD->isPOD();
+      unsigned DiagID =
+        LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
                             : diag::ext_offsetof_non_pod_type;
 
       if (!IsSafe && !DidWarnAboutNonPOD && !isUnevaluatedContext()) {
@@ -16830,7 +16732,8 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc,
     // We diagnose this as an error.
     if (MemberDecl->isBitField()) {
       Diag(OC.LocEnd, diag::err_offsetof_bitfield)
-          << MemberDecl->getDeclName() << SourceRange(BuiltinLoc, RParenLoc);
+        << MemberDecl->getDeclName()
+        << SourceRange(BuiltinLoc, RParenLoc);
       Diag(MemberDecl->getLocation(), diag::note_bitfield_decl);
       return ExprError();
     }
@@ -16846,7 +16749,8 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc,
                       Context.getCanonicalTagType(Parent), Paths)) {
       if (Paths.getDetectedVirtual()) {
         Diag(OC.LocEnd, diag::err_offsetof_field_of_virtual_base)
-            << MemberDecl->getDeclName() << SourceRange(BuiltinLoc, RParenLoc);
+          << MemberDecl->getDeclName()
+          << SourceRange(BuiltinLoc, RParenLoc);
         return ExprError();
       }
 
@@ -16858,8 +16762,8 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc,
     if (IndirectMemberDecl) {
       for (auto *FI : IndirectMemberDecl->chain()) {
         assert(isa<FieldDecl>(FI));
-        Comps.push_back(
-            OffsetOfNode(OC.LocStart, cast<FieldDecl>(FI), OC.LocEnd));
+        Comps.push_back(OffsetOfNode(OC.LocStart,
+                                     cast<FieldDecl>(FI), OC.LocEnd));
       }
     } else
       Comps.push_back(OffsetOfNode(OC.LocStart, MemberDecl, OC.LocEnd));
@@ -16871,7 +16775,8 @@ ExprResult Sema::BuildBuiltinOffsetOf(SourceLocation BuiltinLoc,
                               Comps, Exprs, RParenLoc);
 }
 
-ExprResult Sema::ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc,
+ExprResult Sema::ActOnBuiltinOffsetOf(Scope *S,
+                                      SourceLocation BuiltinLoc,
                                       SourceLocation TypeLoc,
                                       ParsedType ParsedArgTy,
                                       ArrayRef<OffsetOfComponent> Components,
@@ -16888,7 +16793,9 @@ ExprResult Sema::ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc,
   return BuildBuiltinOffsetOf(BuiltinLoc, ArgTInfo, Components, RParenLoc);
 }
 
-ExprResult Sema::ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr,
+
+ExprResult Sema::ActOnChooseExpr(SourceLocation BuiltinLoc,
+                                 Expr *CondExpr,
                                  Expr *LHSExpr, Expr *RHSExpr,
                                  SourceLocation RPLoc) {
   assert((CondExpr && LHSExpr && RHSExpr) && "Missing type argument(s)");
@@ -16974,8 +16881,8 @@ void Sema::ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
   // Look for an explicit signature in that function type.
   FunctionProtoTypeLoc ExplicitSignature;
 
-  if ((ExplicitSignature =
-           Sig->getTypeLoc().getAsAdjusted<FunctionProtoTypeLoc>())) {
+  if ((ExplicitSignature = Sig->getTypeLoc()
+                               .getAsAdjusted<FunctionProtoTypeLoc>())) {
 
     // Check whether that explicit signature was synthesized by
     // GetTypeForDeclarator.  If so, don't save that as part of the
@@ -17014,7 +16921,7 @@ void Sema::ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
   }
 
   // Push block parameters from the declarator if we had them.
-  SmallVector<ParmVarDecl *, 8> Params;
+  SmallVector<ParmVarDecl*, 8> Params;
   if (ExplicitSignature) {
     for (unsigned I = 0, E = ExplicitSignature.getNumParams(); I != E; ++I) {
       ParmVarDecl *Param = ExplicitSignature.getParam(I);
@@ -17027,8 +16934,8 @@ void Sema::ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo,
       Params.push_back(Param);
     }
 
-    // Fake up parameter variables if we have a typedef, like
-    //   ^ fntype { ... }
+  // Fake up parameter variables if we have a typedef, like
+  //   ^ fntype { ... }
   } else if (const FunctionProtoType *Fn = T->getAs<FunctionProtoType>()) {
     for (const auto &I : Fn->param_types()) {
       ParmVarDecl *Param = BuildParmVarDeclForTypedef(
@@ -17073,8 +16980,8 @@ void Sema::ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope) {
   PopFunctionScopeInfo();
 }
 
-ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body,
-                                    Scope *CurScope) {
+ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
+                                    Stmt *Body, Scope *CurScope) {
   // If blocks are disabled, emit an error.
   if (!LangOpts.Blocks)
     Diag(CaretLoc, diag::err_blocks_disable) << LangOpts.OpenCL;
@@ -17106,8 +17013,7 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body,
     const FunctionType *FTy = BSI->FunctionType->castAs<FunctionType>();
 
     FunctionType::ExtInfo Ext = FTy->getExtInfo();
-    if (NoReturn && !Ext.getNoReturn())
-      Ext = Ext.withNoReturn(true);
+    if (NoReturn && !Ext.getNoReturn()) Ext = Ext.withNoReturn(true);
 
     // Turn protoless block types into nullary block types.
     if (isa<FunctionNoProtoType>(FTy)) {
@@ -17121,7 +17027,7 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body,
                (!NoReturn || FTy->getNoReturnAttr())) {
       BlockTy = BSI->FunctionType;
 
-      // Otherwise, make the minimal modifications to the function type.
+    // Otherwise, make the minimal modifications to the function type.
     } else {
       const FunctionProtoType *FPT = cast<FunctionProtoType>(FTy);
       FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
@@ -17130,7 +17036,7 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body,
       BlockTy = Context.getFunctionType(RetTy, FPT->getParamTypes(), EPI);
     }
 
-    // If we don't have a function type, just build one from nothing.
+  // If we don't have a function type, just build one from nothing.
   } else {
     FunctionProtoType::ExtProtoInfo EPI;
     EPI.ExtInfo = FunctionType::ExtInfo().withNoReturn(NoReturn);
@@ -17141,7 +17047,8 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body,
   BlockTy = Context.getBlockPointerType(BlockTy);
 
   // If needed, diagnose invalid gotos and switches in the block.
-  if (getCurFunction()->NeedsScopeChecking() && !PP.isCodeCompletionEnabled())
+  if (getCurFunction()->NeedsScopeChecking() &&
+      !PP.isCodeCompletionEnabled())
     DiagnoseInvalidJumps(cast<CompoundStmt>(Body));
 
   BD->setBody(cast<CompoundStmt>(Body));
@@ -17216,9 +17123,9 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body,
         // Build a full-expression copy expression if initialization
         // succeeded and used a non-trivial constructor.  Recover from
         // errors by pretending that the copy isn't necessary.
-        if (!Result.isInvalid() && !cast<CXXConstructExpr>(Result.get())
-                                        ->getConstructor()
-                                        ->isTrivial()) {
+        if (!Result.isInvalid() &&
+            !cast<CXXConstructExpr>(Result.get())->getConstructor()
+                ->isTrivial()) {
           Result = MaybeCreateExprWithCleanups(Result);
           CopyExpr = Result.get();
         }
@@ -17275,8 +17182,9 @@ ExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty,
   return BuildVAArgExpr(BuiltinLoc, E, TInfo, RPLoc);
 }
 
-ExprResult Sema::BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E,
-                                TypeSourceInfo *TInfo, SourceLocation RPLoc) {
+ExprResult Sema::BuildVAArgExpr(SourceLocation BuiltinLoc,
+                                Expr *E, TypeSourceInfo *TInfo,
+                                SourceLocation RPLoc) {
   Expr *OrigExpr = E;
   bool IsMS = false;
 
@@ -17298,8 +17206,7 @@ ExprResult Sema::BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E,
   // as Microsoft ABI on an actual Microsoft platform, where
   // __builtin_ms_va_list and __builtin_va_list are the same.)
   if (!E->isTypeDependent() && Context.getTargetInfo().hasBuiltinMSVaList() &&
-      Context.getTargetInfo().getBuiltinVaListKind() !=
-          TargetInfo::CharPtrBuiltinVaList) {
+      Context.getTargetInfo().getBuiltinVaListKind() != TargetInfo::CharPtrBuiltinVaList) {
     QualType MSVaListType = Context.getBuiltinMSVaListType();
     if (Context.hasSameType(MSVaListType, E->getType())) {
       if (CheckForModifiableLvalue(E, BuiltinLoc, *this))
@@ -17352,17 +17259,19 @@ ExprResult Sema::BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E,
                             TInfo->getTypeLoc()))
       return ExprError();
 
-    if (RequireNonAbstractType(
-            TInfo->getTypeLoc().getBeginLoc(), TInfo->getType(),
-            diag::err_second_parameter_to_va_arg_abstract, TInfo->getTypeLoc()))
+    if (RequireNonAbstractType(TInfo->getTypeLoc().getBeginLoc(),
+                               TInfo->getType(),
+                               diag::err_second_parameter_to_va_arg_abstract,
+                               TInfo->getTypeLoc()))
       return ExprError();
 
     if (!TInfo->getType().isPODType(Context)) {
       Diag(TInfo->getTypeLoc().getBeginLoc(),
            TInfo->getType()->isObjCLifetimeType()
-               ? diag::warn_second_parameter_to_va_arg_ownership_qualified
-               : diag::warn_second_parameter_to_va_arg_not_pod)
-          << TInfo->getType() << TInfo->getTypeLoc().getSourceRange();
+             ? diag::warn_second_parameter_to_va_arg_ownership_qualified
+             : diag::warn_second_parameter_to_va_arg_not_pod)
+        << TInfo->getType()
+        << TInfo->getTypeLoc().getSourceRange();
     }
 
     if (TInfo->getType()->isArrayType()) {
@@ -17424,11 +17333,11 @@ ExprResult Sema::BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E,
     if (TInfo->getType()->isSpecificBuiltinType(BuiltinType::Float))
       PromoteType = Context.DoubleTy;
     if (!PromoteType.isNull())
-      DiagRuntimeBehavior(
-          TInfo->getTypeLoc().getBeginLoc(), E,
-          PDiag(diag::warn_second_parameter_to_va_arg_never_compatible)
-              << TInfo->getType() << PromoteType
-              << TInfo->getTypeLoc().getSourceRange());
+      DiagRuntimeBehavior(TInfo->getTypeLoc().getBeginLoc(), E,
+                  PDiag(diag::warn_second_parameter_to_va_arg_never_compatible)
+                          << TInfo->getType()
+                          << PromoteType
+                          << TInfo->getTypeLoc().getSourceRange());
   }
 
   QualType T = TInfo->getType().getNonLValueExprType(Context);
@@ -17591,9 +17500,10 @@ static bool maybeDiagnoseAssignmentToFunction(Sema &S, QualType DstType,
 }
 
 bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
-                                    SourceLocation Loc, QualType DstType,
-                                    QualType SrcType, Expr *SrcExpr,
-                                    AssignmentAction Action, bool *Complained) {
+                                    SourceLocation Loc,
+                                    QualType DstType, QualType SrcType,
+                                    Expr *SrcExpr, AssignmentAction Action,
+                                    bool *Complained) {
   if (Complained)
     *Complained = false;
 
@@ -17662,7 +17572,7 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
       DiagKind = diag::ext_typecheck_convert_incompatible_pointer;
     }
     CheckInferredResultType = DstType->isObjCObjectPointerType() &&
-                              SrcType->isObjCObjectPointerType();
+      SrcType->isObjCObjectPointerType();
     if (CheckInferredResultType) {
       SrcType = SrcType.getUnqualifiedType();
       DstType = DstType.getUnqualifiedType();
@@ -17689,8 +17599,7 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
     break;
   case AssignConvertType::IncompatiblePointerDiscardsQualifiers: {
     // Perform array-to-pointer decay if necessary.
-    if (SrcType->isArrayType())
-      SrcType = Context.getArrayDecayedType(SrcType);
+    if (SrcType->isArrayType()) SrcType = Context.getArrayDecayedType(SrcType);
 
     isInvalid = true;
 
@@ -17730,10 +17639,10 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
         IsStringLiteralToNonConstPointerConversion(SrcExpr, DstType))
       return false;
     if (getLangOpts().CPlusPlus) {
-      DiagKind = diag::err_typecheck_convert_discards_qualifiers;
+      DiagKind =  diag::err_typecheck_convert_discards_qualifiers;
       isInvalid = true;
     } else {
-      DiagKind = diag::ext_typecheck_convert_discards_qualifiers;
+      DiagKind =  diag::ext_typecheck_convert_discards_qualifiers;
     }
 
     break;
@@ -17760,23 +17669,24 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
   case AssignConvertType::IncompatibleObjCQualifiedId: {
     if (SrcType->isObjCQualifiedIdType()) {
       const ObjCObjectPointerType *srcOPT =
-          SrcType->castAs<ObjCObjectPointerType>();
+                SrcType->castAs<ObjCObjectPointerType>();
       for (auto *srcProto : srcOPT->quals()) {
         PDecl = srcProto;
         break;
       }
       if (const ObjCInterfaceType *IFaceT =
-              DstType->castAs<ObjCObjectPointerType>()->getInterfaceType())
+            DstType->castAs<ObjCObjectPointerType>()->getInterfaceType())
         IFace = IFaceT->getDecl();
-    } else if (DstType->isObjCQualifiedIdType()) {
+    }
+    else if (DstType->isObjCQualifiedIdType()) {
       const ObjCObjectPointerType *dstOPT =
-          DstType->castAs<ObjCObjectPointerType>();
+        DstType->castAs<ObjCObjectPointerType>();
       for (auto *dstProto : dstOPT->quals()) {
         PDecl = dstProto;
         break;
       }
       if (const ObjCInterfaceType *IFaceT =
-              SrcType->castAs<ObjCObjectPointerType>()->getInterfaceType())
+            SrcType->castAs<ObjCObjectPointerType>()->getInterfaceType())
         IFace = IFaceT->getDecl();
     }
     if (getLangOpts().CPlusPlus) {
@@ -17880,9 +17790,7 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
       FDiag << H;
   }
 
-  if (MayHaveConvFixit) {
-    FDiag << (unsigned)(ConvHints.Kind);
-  }
+  if (MayHaveConvFixit) { FDiag << (unsigned) (ConvHints.Kind); }
 
   if (MayHaveFunctionDiff)
     HandleFunctionTypeMismatch(FDiag, SecondType, FirstType);
@@ -17895,8 +17803,8 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
         << IFace << PDecl;
 
   if (SecondType == Context.OverloadTy)
-    NoteAllOverloadCandidates(OverloadExpr::find(SrcExpr).Expression, FirstType,
-                              /*TakingAddress=*/true);
+    NoteAllOverloadCandidates(OverloadExpr::find(SrcExpr).Expression,
+                              FirstType, /*TakingAddress=*/true);
 
   if (CheckInferredResultType)
     ObjC().EmitRelatedResultTypeNote(SrcExpr);
@@ -17910,7 +17818,8 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
   return isInvalid;
 }
 
-ExprResult Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
+ExprResult Sema::VerifyIntegerConstantExpression(Expr *E,
+                                                 llvm::APSInt *Result,
                                                  AllowFoldKind CanFold) {
   class SimpleICEDiagnoser : public VerifyICEDiagnoser {
   public:
@@ -17927,7 +17836,8 @@ ExprResult Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
   return VerifyIntegerConstantExpression(E, Result, Diagnoser, CanFold);
 }
 
-ExprResult Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
+ExprResult Sema::VerifyIntegerConstantExpression(Expr *E,
+                                                 llvm::APSInt *Result,
                                                  unsigned DiagID,
                                                  AllowFoldKind CanFold) {
   class IDDiagnoser : public VerifyICEDiagnoser {
@@ -17935,7 +17845,7 @@ ExprResult Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
 
   public:
     IDDiagnoser(unsigned DiagID)
-        : VerifyICEDiagnoser(DiagID == 0), DiagID(DiagID) {}
+      : VerifyICEDiagnoser(DiagID == 0), DiagID(DiagID) { }
 
     SemaDiagnosticBuilder diagnoseNotICE(Sema &S, SourceLocation Loc) override {
       return S.Diag(Loc, DiagID);
@@ -17956,9 +17866,10 @@ Sema::VerifyICEDiagnoser::diagnoseFold(Sema &S, SourceLocation Loc) {
   return S.Diag(Loc, diag::ext_expr_not_ice) << S.LangOpts.CPlusPlus;
 }
 
-ExprResult Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
-                                                 VerifyICEDiagnoser &Diagnoser,
-                                                 AllowFoldKind CanFold) {
+ExprResult
+Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
+                                      VerifyICEDiagnoser &Diagnoser,
+                                      AllowFoldKind CanFold) {
   SourceLocation DiagLoc = E->getBeginLoc();
 
   if (getLangOpts().CPlusPlus11) {
@@ -17970,7 +17881,6 @@ ExprResult Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
     ExprResult Converted;
     class CXX11ConvertDiagnoser : public ICEConvertDiagnoser {
       VerifyICEDiagnoser &BaseDiagnoser;
-
     public:
       CXX11ConvertDiagnoser(VerifyICEDiagnoser &BaseDiagnoser)
           : ICEConvertDiagnoser(/*AllowScopedEnumerations*/ false,
@@ -17982,43 +17892,41 @@ ExprResult Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
         return BaseDiagnoser.diagnoseNotICEType(S, Loc, T);
       }
 
-      SemaDiagnosticBuilder diagnoseIncomplete(Sema &S, SourceLocation Loc,
-                                               QualType T) override {
+      SemaDiagnosticBuilder diagnoseIncomplete(
+          Sema &S, SourceLocation Loc, QualType T) override {
         return S.Diag(Loc, diag::err_ice_incomplete_type) << T;
       }
 
-      SemaDiagnosticBuilder diagnoseExplicitConv(Sema &S, SourceLocation Loc,
-                                                 QualType T,
-                                                 QualType ConvTy) override {
+      SemaDiagnosticBuilder diagnoseExplicitConv(
+          Sema &S, SourceLocation Loc, QualType T, QualType ConvTy) override {
         return S.Diag(Loc, diag::err_ice_explicit_conversion) << T << ConvTy;
       }
 
-      SemaDiagnosticBuilder noteExplicitConv(Sema &S, CXXConversionDecl *Conv,
-                                             QualType ConvTy) override {
+      SemaDiagnosticBuilder noteExplicitConv(
+          Sema &S, CXXConversionDecl *Conv, QualType ConvTy) override {
         return S.Diag(Conv->getLocation(), diag::note_ice_conversion_here)
-               << ConvTy->isEnumeralType() << ConvTy;
+                 << ConvTy->isEnumeralType() << ConvTy;
       }
 
-      SemaDiagnosticBuilder diagnoseAmbiguous(Sema &S, SourceLocation Loc,
-                                              QualType T) override {
+      SemaDiagnosticBuilder diagnoseAmbiguous(
+          Sema &S, SourceLocation Loc, QualType T) override {
         return S.Diag(Loc, diag::err_ice_ambiguous_conversion) << T;
       }
 
-      SemaDiagnosticBuilder noteAmbiguous(Sema &S, CXXConversionDecl *Conv,
-                                          QualType ConvTy) override {
+      SemaDiagnosticBuilder noteAmbiguous(
+          Sema &S, CXXConversionDecl *Conv, QualType ConvTy) override {
         return S.Diag(Conv->getLocation(), diag::note_ice_conversion_here)
-               << ConvTy->isEnumeralType() << ConvTy;
+                 << ConvTy->isEnumeralType() << ConvTy;
       }
 
-      SemaDiagnosticBuilder diagnoseConversion(Sema &S, SourceLocation Loc,
-                                               QualType T,
-                                               QualType ConvTy) override {
+      SemaDiagnosticBuilder diagnoseConversion(
+          Sema &S, SourceLocation Loc, QualType T, QualType ConvTy) override {
         llvm_unreachable("conversion functions are permitted");
       }
     } ConvertDiagnoser(Diagnoser);
 
-    Converted =
-        PerformContextualImplicitConversion(DiagLoc, E, ConvertDiagnoser);
+    Converted = PerformContextualImplicitConversion(DiagLoc, E,
+                                                    ConvertDiagnoser);
     if (Converted.isInvalid())
       return Converted;
     E = Converted.get();
@@ -18061,7 +17969,7 @@ ExprResult Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
     // the caret at its location rather than producing an essentially
     // redundant note.
     if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
-                                 diag::note_invalid_subexpr_in_const_expr) {
+          diag::note_invalid_subexpr_in_const_expr) {
       DiagLoc = Notes[0].first;
       Notes.clear();
     }
@@ -18108,8 +18016,8 @@ ExprResult Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
   // If our only note is the usual "invalid subexpression" note, just point
   // the caret at its location rather than producing an essentially
   // redundant note.
-  if (Notes.size() == 1 &&
-      Notes[0].second.getDiagID() == diag::note_invalid_subexpr_in_const_expr) {
+  if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
+        diag::note_invalid_subexpr_in_const_expr) {
     DiagLoc = Notes[0].first;
     Notes.clear();
   }
@@ -18134,57 +18042,58 @@ ExprResult Sema::VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result,
 }
 
 namespace {
-// Handle the case where we conclude a expression which we speculatively
-// considered to be unevaluated is actually evaluated.
-class TransformToPE : public TreeTransform<TransformToPE> {
-  typedef TreeTransform<TransformToPE> BaseTransform;
+  // Handle the case where we conclude a expression which we speculatively
+  // considered to be unevaluated is actually evaluated.
+  class TransformToPE : public TreeTransform<TransformToPE> {
+    typedef TreeTransform<TransformToPE> BaseTransform;
 
-public:
-  TransformToPE(Sema &SemaRef) : BaseTransform(SemaRef) {}
+  public:
+    TransformToPE(Sema &SemaRef) : BaseTransform(SemaRef) { }
 
-  // Make sure we redo semantic analysis
-  bool AlwaysRebuild() { return true; }
-  bool ReplacingOriginal() { return true; }
+    // Make sure we redo semantic analysis
+    bool AlwaysRebuild() { return true; }
+    bool ReplacingOriginal() { return true; }
 
-  // We need to special-case DeclRefExprs referring to FieldDecls which
-  // are not part of a member pointer formation; normal TreeTransforming
-  // doesn't catch this case because of the way we represent them in the AST.
-  // FIXME: This is a bit ugly; is it really the best way to handle this
-  // case?
-  //
-  // Error on DeclRefExprs referring to FieldDecls.
-  ExprResult TransformDeclRefExpr(DeclRefExpr *E) {
-    if (isa<FieldDecl>(E->getDecl()) && !SemaRef.isUnevaluatedContext())
-      return SemaRef.Diag(E->getLocation(),
-                          diag::err_invalid_non_static_member_use)
-             << E->getDecl() << E->getSourceRange();
+    // We need to special-case DeclRefExprs referring to FieldDecls which
+    // are not part of a member pointer formation; normal TreeTransforming
+    // doesn't catch this case because of the way we represent them in the AST.
+    // FIXME: This is a bit ugly; is it really the best way to handle this
+    // case?
+    //
+    // Error on DeclRefExprs referring to FieldDecls.
+    ExprResult TransformDeclRefExpr(DeclRefExpr *E) {
+      if (isa<FieldDecl>(E->getDecl()) &&
+          !SemaRef.isUnevaluatedContext())
+        return SemaRef.Diag(E->getLocation(),
+                            diag::err_invalid_non_static_member_use)
+            << E->getDecl() << E->getSourceRange();
 
-    return BaseTransform::TransformDeclRefExpr(E);
-  }
+      return BaseTransform::TransformDeclRefExpr(E);
+    }
 
-  // Exception: filter out member pointer formation
-  ExprResult TransformUnaryOperator(UnaryOperator *E) {
-    if (E->getOpcode() == UO_AddrOf && E->getType()->isMemberPointerType())
-      return E;
+    // Exception: filter out member pointer formation
+    ExprResult TransformUnaryOperator(UnaryOperator *E) {
+      if (E->getOpcode() == UO_AddrOf && E->getType()->isMemberPointerType())
+        return E;
 
-    return BaseTransform::TransformUnaryOperator(E);
-  }
+      return BaseTransform::TransformUnaryOperator(E);
+    }
 
-  // The body of a lambda-expression is in a separate expression evaluation
-  // context so never needs to be transformed.
-  // FIXME: Ideally we wouldn't transform the closure type either, and would
-  // just recreate the capture expressions and lambda expression.
-  StmtResult TransformLambdaBody(LambdaExpr *E, Stmt *Body) {
-    return SkipLambdaBody(E, Body);
-  }
-};
-} // namespace
+    // The body of a lambda-expression is in a separate expression evaluation
+    // context so never needs to be transformed.
+    // FIXME: Ideally we wouldn't transform the closure type either, and would
+    // just recreate the capture expressions and lambda expression.
+    StmtResult TransformLambdaBody(LambdaExpr *E, Stmt *Body) {
+      return SkipLambdaBody(E, Body);
+    }
+  };
+}
 
 ExprResult Sema::TransformToPotentiallyEvaluated(Expr *E) {
   assert(isUnevaluatedContext() &&
          "Should only transform unevaluated expressions");
   ExprEvalContexts.back().Context =
-      ExprEvalContexts[ExprEvalContexts.size() - 2].Context;
+      ExprEvalContexts[ExprEvalContexts.size()-2].Context;
   if (isUnevaluatedContext())
     return E;
   return TransformToPE(*this).TransformExpr(E);
@@ -18199,7 +18108,8 @@ TypeSourceInfo *Sema::TransformToPotentiallyEvaluated(TypeSourceInfo *TInfo) {
   return TransformToPE(*this).TransformType(TInfo);
 }
 
-void Sema::PushExpressionEvaluationContext(
+void
+Sema::PushExpressionEvaluationContext(
     ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl,
     ExpressionEvaluationContextRecord::ExpressionKind ExprContext) {
   ExprEvalContexts.emplace_back(NewContext, ExprCleanupObjects.size(), Cleanup,
@@ -18227,7 +18137,8 @@ void Sema::PushExpressionEvaluationContext(
     std::swap(MaybeODRUseExprs, ExprEvalContexts.back().SavedMaybeODRUseExprs);
 }
 
-void Sema::PushExpressionEvaluationContext(
+void
+Sema::PushExpressionEvaluationContext(
     ExpressionEvaluationContext NewContext, ReuseLambdaContextDecl_t,
     ExpressionEvaluationContextRecord::ExpressionKind ExprContext) {
   Decl *ClosureContextDecl = ExprEvalContexts.back().ManglingContextDecl;
@@ -18496,7 +18407,7 @@ static void RemoveNestedImmediateInvocation(
                   SmallVector<Sema::ImmediateInvocationCandidate,
                               4>::reverse_iterator Current)
         : Base(SemaRef), DRSet(DR), IISet(II), CurrentII(Current) {}
-    void RemoveImmediateInvocation(ConstantExpr *E) {
+    void RemoveImmediateInvocation(ConstantExpr* E) {
       auto It = std::find_if(CurrentII, IISet.rend(),
                              [E](Sema::ImmediateInvocationCandidate Elem) {
                                return Elem.getPointer() == E;
@@ -18700,7 +18611,7 @@ HandleImmediateInvocations(Sema &SemaRef,
 }
 
 void Sema::PopExpressionEvaluationContext() {
-  ExpressionEvaluationContextRecord &Rec = ExprEvalContexts.back();
+  ExpressionEvaluationContextRecord& Rec = ExprEvalContexts.back();
   if (!Rec.Lambdas.empty()) {
     using ExpressionKind = ExpressionEvaluationContextRecord::ExpressionKind;
     if (!getLangOpts().CPlusPlus20 &&
@@ -18760,7 +18671,7 @@ void Sema::PopExpressionEvaluationContext() {
     Cleanup = Rec.ParentCleanup;
     CleanupVarDeclMarking();
     std::swap(MaybeODRUseExprs, Rec.SavedMaybeODRUseExprs);
-    // Otherwise, merge the contexts together.
+  // Otherwise, merge the contexts together.
   } else {
     Cleanup.mergeFrom(Rec.ParentCleanup);
     MaybeODRUseExprs.insert_range(Rec.SavedMaybeODRUseExprs);
@@ -18773,9 +18684,9 @@ void Sema::PopExpressionEvaluationContext() {
 }
 
 void Sema::DiscardCleanupsInEvaluationContext() {
-  ExprCleanupObjects.erase(ExprCleanupObjects.begin() +
-                               ExprEvalContexts.back().NumCleanupObjects,
-                           ExprCleanupObjects.end());
+  ExprCleanupObjects.erase(
+         ExprCleanupObjects.begin() + ExprEvalContexts.back().NumCleanupObjects,
+         ExprCleanupObjects.end());
   Cleanup.reset();
   MaybeODRUseExprs.clear();
 }
@@ -18796,27 +18707,27 @@ static bool isPotentiallyConstantEvaluatedContext(Sema &SemaRef) {
   /// C++2a [expr.const]p12:
   //   An expression or conversion is potentially constant evaluated if it is
   switch (SemaRef.ExprEvalContexts.back().Context) {
-  case Sema::ExpressionEvaluationContext::ConstantEvaluated:
-  case Sema::ExpressionEvaluationContext::ImmediateFunctionContext:
-
-    // -- a manifestly constant-evaluated expression,
-  case Sema::ExpressionEvaluationContext::PotentiallyEvaluated:
-  case Sema::ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed:
-  case Sema::ExpressionEvaluationContext::DiscardedStatement:
-    // -- a potentially-evaluated expression,
-  case Sema::ExpressionEvaluationContext::UnevaluatedList:
-    // -- an immediate subexpression of a braced-init-list,
-
-    // -- [FIXME] an expression of the form & cast-expression that occurs
-    //    within a templated entity
-    // -- a subexpression of one of the above that is not a subexpression of
-    // a nested unevaluated operand.
-    return true;
+    case Sema::ExpressionEvaluationContext::ConstantEvaluated:
+    case Sema::ExpressionEvaluationContext::ImmediateFunctionContext:
+
+      // -- a manifestly constant-evaluated expression,
+    case Sema::ExpressionEvaluationContext::PotentiallyEvaluated:
+    case Sema::ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed:
+    case Sema::ExpressionEvaluationContext::DiscardedStatement:
+      // -- a potentially-evaluated expression,
+    case Sema::ExpressionEvaluationContext::UnevaluatedList:
+      // -- an immediate subexpression of a braced-init-list,
+
+      // -- [FIXME] an expression of the form & cast-expression that occurs
+      //    within a templated entity
+      // -- a subexpression of one of the above that is not a subexpression of
+      // a nested unevaluated operand.
+      return true;
 
-  case Sema::ExpressionEvaluationContext::Unevaluated:
-  case Sema::ExpressionEvaluationContext::UnevaluatedAbstract:
-    // Expressions in this context are never evaluated.
-    return false;
+    case Sema::ExpressionEvaluationContext::Unevaluated:
+    case Sema::ExpressionEvaluationContext::UnevaluatedAbstract:
+      // Expressions in this context are never evaluated.
+      return false;
   }
   llvm_unreachable("Invalid context");
 }
@@ -19094,7 +19005,7 @@ void Sema::MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func,
           PointOfInstantiation = Loc;
           if (auto *MSI = Func->getMemberSpecializationInfo())
             MSI->setPointOfInstantiation(Loc);
-          // FIXME: Notify listener.
+            // FIXME: Notify listener.
           else
             Func->setTemplateSpecializationKind(TSK, PointOfInstantiation);
         } else if (TSK != TSK_ImplicitInstantiation) {
@@ -19187,7 +19098,8 @@ void Sema::MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func,
     if (!Func->isDefined() && !Func->isInAnotherModuleUnit()) {
       if (mightHaveNonExternalLinkage(Func))
         UndefinedButUsed.insert(std::make_pair(Func->getCanonicalDecl(), Loc));
-      else if (Func->getMostRecentDecl()->isInlined() && !LangOpts.GNUInline &&
+      else if (Func->getMostRecentDecl()->isInlined() &&
+               !LangOpts.GNUInline &&
                !Func->getMostRecentDecl()->hasAttr<GNUInlineAttr>())
         UndefinedButUsed.insert(std::make_pair(Func->getCanonicalDecl(), Loc));
       else if (isExternalWithNoLinkageType(Func))
@@ -19317,7 +19229,8 @@ static void diagnoseUncapturableValueReferenceOrBinding(Sema &S,
   //  If the parameter still belongs to the translation unit, then
   //  we're actually just using one parameter in the declaration of
   //  the next.
-  if (isa<ParmVarDecl>(var) && isa<TranslationUnitDecl>(VarDC))
+  if (isa<ParmVarDecl>(var) &&
+      isa<TranslationUnitDecl>(VarDC))
     return;
 
   // For C code, don't diagnose about capture if we're not actually in code
@@ -19342,8 +19255,9 @@ static void diagnoseUncapturableValueReferenceOrBinding(Sema &S,
   }
 
   S.Diag(loc, diag::err_reference_to_local_in_enclosing_context)
-      << var << ValueKind << ContextKind << VarDC;
-  S.Diag(var->getLocation(), diag::note_entity_declared_at) << var;
+    << var << ValueKind << ContextKind << VarDC;
+  S.Diag(var->getLocation(), diag::note_entity_declared_at)
+      << var;
 
   // FIXME: Add additional diagnostic info about class etc. which prevents
   // capture.
@@ -19507,7 +19421,8 @@ static bool captureInBlock(BlockScopeInfo *BSI, ValueDecl *Var,
   if (!Invalid &&
       CaptureType.getObjCLifetime() == Qualifiers::OCL_Autoreleasing) {
     if (BuildAndDiagnose) {
-      S.Diag(Loc, diag::err_arc_autoreleasing_capture) << /*block*/ 0;
+      S.Diag(Loc, diag::err_arc_autoreleasing_capture)
+        << /*block*/ 0;
       S.Diag(Var->getLocation(), diag::note_previous_decl) << Var;
       Invalid = true;
     } else {
@@ -19638,7 +19553,7 @@ static bool captureInLambda(LambdaScopeInfo *LSI, ValueDecl *Var,
     //   captured entity is a reference to a function, the
     //   corresponding data member is also a reference to a
     //   function. - end note ]
-    if (const ReferenceType *RefType = CaptureType->getAs<ReferenceType>()) {
+    if (const ReferenceType *RefType = CaptureType->getAs<ReferenceType>()){
       if (!RefType->getPointeeType()->isFunctionType())
         CaptureType = RefType->getPointeeType();
     }
@@ -19649,7 +19564,7 @@ static bool captureInLambda(LambdaScopeInfo *LSI, ValueDecl *Var,
       if (BuildAndDiagnose) {
         S.Diag(Loc, diag::err_arc_autoreleasing_capture) << /*lambda*/ 1;
         S.Diag(Var->getLocation(), diag::note_previous_decl)
-            << Var->getDeclName();
+          << Var->getDeclName();
         Invalid = true;
       } else {
         return false;
@@ -19836,8 +19751,7 @@ bool Sema::tryCaptureVariable(
   assert(VD && "Cannot capture a null variable");
 
   const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt
-                                              ? *FunctionScopeIndexToStopAt
-                                              : FunctionScopes.size() - 1;
+      ? *FunctionScopeIndexToStopAt : FunctionScopes.size() - 1;
   // We need to sync up the Declaration Context with the
   // FunctionScopeIndexToStopAt
   if (FunctionScopeIndexToStopAt) {
@@ -19922,7 +19836,7 @@ bool Sema::tryCaptureVariable(
       return true;
     }
 
-    FunctionScopeInfo *FSI = FunctionScopes[FunctionScopesIndex];
+    FunctionScopeInfo  *FSI = FunctionScopes[FunctionScopesIndex];
     CapturingScopeInfo *CSI = cast<CapturingScopeInfo>(FSI);
 
     // Check whether we've already captured it.
@@ -20070,13 +19984,13 @@ bool Sema::tryCaptureVariable(
   // If the variable had already been captured previously, we start capturing
   // at the lambda nested within that one.
   bool Invalid = false;
-  for (unsigned I = ++FunctionScopesIndex, N = MaxFunctionScopesIndex + 1;
-       I != N; ++I) {
+  for (unsigned I = ++FunctionScopesIndex, N = MaxFunctionScopesIndex + 1; I != N;
+       ++I) {
     CapturingScopeInfo *CSI = cast<CapturingScopeInfo>(FunctionScopes[I]);
 
-    // Certain capturing entities (lambdas, blocks etc.) are not allowed to
-    // capture certain types of variables (unnamed, variably modified types
-    // etc.) so check for eligibility.
+    // Certain capturing entities (lambdas, blocks etc.) are not allowed to capture
+    // certain types of variables (unnamed, variably modified types etc.)
+    // so check for eligibility.
     if (!Invalid)
       Invalid =
           !isVariableCapturable(CSI, Var, ExprLoc, BuildAndDiagnose, *this);
@@ -20087,12 +20001,10 @@ bool Sema::tryCaptureVariable(
       return true;
 
     if (BlockScopeInfo *BSI = dyn_cast<BlockScopeInfo>(CSI)) {
-      Invalid =
-          !captureInBlock(BSI, Var, ExprLoc, BuildAndDiagnose, CaptureType,
-                          DeclRefType, Nested, *this, Invalid);
+      Invalid = !captureInBlock(BSI, Var, ExprLoc, BuildAndDiagnose, CaptureType,
+                               DeclRefType, Nested, *this, Invalid);
       Nested = true;
-    } else if (CapturedRegionScopeInfo *RSI =
-                   dyn_cast<CapturedRegionScopeInfo>(CSI)) {
+    } else if (CapturedRegionScopeInfo *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
       Invalid = !captureInCapturedRegion(
           RSI, Var, ExprLoc, BuildAndDiagnose, CaptureType, DeclRefType, Nested,
           Kind, /*IsTopScope*/ I == N - 1, *this, Invalid);
@@ -20117,8 +20029,8 @@ bool Sema::tryCaptureVariable(ValueDecl *Var, SourceLocation Loc,
   QualType CaptureType;
   QualType DeclRefType;
   return tryCaptureVariable(Var, Loc, Kind, EllipsisLoc,
-                            /*BuildAndDiagnose=*/true, CaptureType, DeclRefType,
-                            nullptr);
+                            /*BuildAndDiagnose=*/true, CaptureType,
+                            DeclRefType, nullptr);
 }
 
 bool Sema::NeedToCaptureVariable(ValueDecl *Var, SourceLocation Loc) {
@@ -20152,24 +20064,23 @@ namespace {
 class CopiedTemplateArgs {
   bool HasArgs;
   TemplateArgumentListInfo TemplateArgStorage;
-
 public:
-  template <typename RefExpr>
+  template<typename RefExpr>
   CopiedTemplateArgs(RefExpr *E) : HasArgs(E->hasExplicitTemplateArgs()) {
     if (HasArgs)
       E->copyTemplateArgumentsInto(TemplateArgStorage);
   }
-  operator TemplateArgumentListInfo *()
+  operator TemplateArgumentListInfo*()
 #ifdef __has_cpp_attribute
 #if __has_cpp_attribute(clang::lifetimebound)
-      [[clang::lifetimebound]]
+  [[clang::lifetimebound]]
 #endif
 #endif
   {
     return HasArgs ? &TemplateArgStorage : nullptr;
   }
 };
-} // namespace
+}
 
 /// Walk the set of potential results of an expression and mark them all as
 /// non-odr-uses if they satisfy the side-conditions of the NonOdrUseReason.
@@ -20361,7 +20272,7 @@ static ExprResult rebuildPotentialResultsAsNonOdrUsed(Sema &S, Expr *E,
       if (!Sub.isUsable())
         return Sub;
       BO->setLHS(Sub.get());
-      //   -- If e is a comma expression, ...
+    //   -- If e is a comma expression, ...
     } else if (BO->getOpcode() == BO_Comma) {
       ExprResult Sub = Rebuild(RHS);
       if (!Sub.isUsable())
@@ -20558,8 +20469,8 @@ void Sema::CleanupVarDeclMarking() {
 
   for (Expr *E : LocalMaybeODRUseExprs) {
     if (auto *DRE = dyn_cast<DeclRefExpr>(E)) {
-      MarkVarDeclODRUsed(cast<VarDecl>(DRE->getDecl()), DRE->getLocation(),
-                         *this);
+      MarkVarDeclODRUsed(cast<VarDecl>(DRE->getDecl()),
+                         DRE->getLocation(), *this);
     } else if (auto *ME = dyn_cast<MemberExpr>(E)) {
       MarkVarDeclODRUsed(cast<VarDecl>(ME->getMemberDecl()), ME->getMemberLoc(),
                          *this);
@@ -20680,7 +20591,7 @@ static void DoMarkVarDeclReferenced(
         PointOfInstantiation = Loc;
         if (MSI)
           MSI->setPointOfInstantiation(PointOfInstantiation);
-        // FIXME: Notify listener.
+          // FIXME: Notify listener.
         else
           Var->setTemplateSpecializationKind(TSK, PointOfInstantiation);
       }
@@ -20706,8 +20617,8 @@ static void DoMarkVarDeclReferenced(
         else if (auto *ME = dyn_cast_or_null<MemberExpr>(E))
           ME->setMemberDecl(ME->getMemberDecl());
       } else if (FirstInstantiation) {
-        SemaRef.PendingInstantiations.push_back(
-            std::make_pair(Var, PointOfInstantiation));
+        SemaRef.PendingInstantiations
+            .push_back(std::make_pair(Var, PointOfInstantiation));
       } else {
         bool Inserted = false;
         for (auto &I : SemaRef.SavedPendingInstantiations) {
@@ -20729,8 +20640,8 @@ static void DoMarkVarDeclReferenced(
         // no direct way to avoid enqueueing the pending instantiation
         // multiple times.
         if (isa<VarTemplateSpecializationDecl>(Var) && !Inserted)
-          SemaRef.PendingInstantiations.push_back(
-              std::make_pair(Var, PointOfInstantiation));
+          SemaRef.PendingInstantiations
+            .push_back(std::make_pair(Var, PointOfInstantiation));
       }
     }
   }
@@ -20904,8 +20815,8 @@ MarkExprReferenced(Sema &SemaRef, SourceLocation Loc, Decl *D, Expr *E,
   if (!MD)
     return;
   // Only attempt to devirtualize if this is truly a virtual call.
-  bool IsVirtualCall =
-      MD->isVirtual() && ME->performsVirtualDispatch(SemaRef.getLangOpts());
+  bool IsVirtualCall = MD->isVirtual() &&
+                          ME->performsVirtualDispatch(SemaRef.getLangOpts());
   if (!IsVirtualCall)
     return;
 
@@ -20986,13 +20897,13 @@ void Sema::MarkAnyDeclReferenced(SourceLocation Loc, Decl *D,
 }
 
 namespace {
-// Mark all of the declarations used by a type as referenced.
-// FIXME: Not fully implemented yet! We need to have a better understanding
-// of when we're entering a context we should not recurse into.
-// FIXME: This is and EvaluatedExprMarker are more-or-less equivalent to
-// TreeTransforms rebuilding the type in a new context. Rather than
-// duplicating the TreeTransform logic, we should consider reusing it here.
-// Currently that causes problems when rebuilding LambdaExprs.
+  // Mark all of the declarations used by a type as referenced.
+  // FIXME: Not fully implemented yet! We need to have a better understanding
+  // of when we're entering a context we should not recurse into.
+  // FIXME: This is and EvaluatedExprMarker are more-or-less equivalent to
+  // TreeTransforms rebuilding the type in a new context. Rather than
+  // duplicating the TreeTransform logic, we should consider reusing it here.
+  // Currently that causes problems when rebuilding LambdaExprs.
 class MarkReferencedDecls : public DynamicRecursiveASTVisitor {
   Sema &S;
   SourceLocation Loc;
@@ -21002,7 +20913,7 @@ class MarkReferencedDecls : public DynamicRecursiveASTVisitor {
 
   bool TraverseTemplateArgument(const TemplateArgument &Arg) override;
 };
-} // namespace
+}
 
 bool MarkReferencedDecls::TraverseTemplateArgument(
     const TemplateArgument &Arg) {
@@ -21075,8 +20986,9 @@ class EvaluatedExprMarker : public UsedDeclVisitor<EvaluatedExprMarker> {
 };
 } // namespace
 
-void Sema::MarkDeclarationsReferencedInExpr(Expr *E, bool SkipLocalVariables,
-                                            ArrayRef<const Expr *> StopAt) {
+void Sema::MarkDeclarationsReferencedInExpr(Expr *E,
+                                            bool SkipLocalVariables,
+                                            ArrayRef<const Expr*> StopAt) {
   EvaluatedExprMarker(*this, SkipLocalVariables, StopAt).Visit(E);
 }
 
@@ -21133,7 +21045,7 @@ bool Sema::DiagIfReachable(SourceLocation Loc, ArrayRef<const Stmt *> Stmts,
 /// behavior of a program, such as passing a non-POD value through an ellipsis.
 /// Failure to do so will likely result in spurious diagnostics or failures
 /// during overload resolution or within sizeof/alignof/typeof/typeid.
-bool Sema::DiagRuntimeBehavior(SourceLocation Loc, ArrayRef<const Stmt *> Stmts,
+bool Sema::DiagRuntimeBehavior(SourceLocation Loc, ArrayRef<const Stmt*> Stmts,
                                const PartialDiagnostic &PD) {
 
   if (ExprEvalContexts.back().isDiscardedStatementContext())
@@ -21186,12 +21098,12 @@ bool Sema::CheckCallReturnType(QualType ReturnType, SourceLocation Loc,
 
   public:
     CallReturnIncompleteDiagnoser(FunctionDecl *FD, CallExpr *CE)
-        : FD(FD), CE(CE) {}
+      : FD(FD), CE(CE) { }
 
     void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
       if (!FD) {
         S.Diag(Loc, diag::err_call_incomplete_return)
-            << T << CE->getSourceRange();
+          << T << CE->getSourceRange();
         return;
       }
 
@@ -21223,8 +21135,8 @@ void Sema::DiagnoseAssignmentAsCondition(Expr *E) {
     IsOrAssign = Op->getOpcode() == BO_OrAssign;
 
     // Greylist some idioms by putting them into a warning subcategory.
-    if (ObjCMessageExpr *ME =
-            dyn_cast<ObjCMessageExpr>(Op->getRHS()->IgnoreParenCasts())) {
+    if (ObjCMessageExpr *ME
+          = dyn_cast<ObjCMessageExpr>(Op->getRHS()->IgnoreParenCasts())) {
       Selector Sel = ME->getSelector();
 
       // self = [<foo> init...]
@@ -21255,15 +21167,15 @@ void Sema::DiagnoseAssignmentAsCondition(Expr *E) {
   SourceLocation Open = E->getBeginLoc();
   SourceLocation Close = getLocForEndOfToken(E->getSourceRange().getEnd());
   Diag(Loc, diag::note_condition_assign_silence)
-      << FixItHint::CreateInsertion(Open, "(")
-      << FixItHint::CreateInsertion(Close, ")");
+        << FixItHint::CreateInsertion(Open, "(")
+        << FixItHint::CreateInsertion(Close, ")");
 
   if (IsOrAssign)
     Diag(Loc, diag::note_condition_or_assign_to_comparison)
-        << FixItHint::CreateReplacement(Loc, "!=");
+      << FixItHint::CreateReplacement(Loc, "!=");
   else
     Diag(Loc, diag::note_condition_assign_to_comparison)
-        << FixItHint::CreateReplacement(Loc, "==");
+      << FixItHint::CreateReplacement(Loc, "==");
 }
 
 void Sema::DiagnoseEqualityWithExtraParens(ParenExpr *ParenE) {
@@ -21281,17 +21193,17 @@ void Sema::DiagnoseEqualityWithExtraParens(ParenExpr *ParenE) {
 
   if (BinaryOperator *opE = dyn_cast<BinaryOperator>(E))
     if (opE->getOpcode() == BO_EQ &&
-        opE->getLHS()->IgnoreParenImpCasts()->isModifiableLvalue(Context) ==
-            Expr::MLV_Valid) {
+        opE->getLHS()->IgnoreParenImpCasts()->isModifiableLvalue(Context)
+                                                           == Expr::MLV_Valid) {
       SourceLocation Loc = opE->getOperatorLoc();
 
       Diag(Loc, diag::warn_equality_with_extra_parens) << E->getSourceRange();
       SourceRange ParenERange = ParenE->getSourceRange();
       Diag(Loc, diag::note_equality_comparison_silence)
-          << FixItHint::CreateRemoval(ParenERange.getBegin())
-          << FixItHint::CreateRemoval(ParenERange.getEnd());
+        << FixItHint::CreateRemoval(ParenERange.getBegin())
+        << FixItHint::CreateRemoval(ParenERange.getEnd());
       Diag(Loc, diag::note_equality_comparison_to_assign)
-          << FixItHint::CreateReplacement(Loc, "=");
+        << FixItHint::CreateReplacement(Loc, "=");
     }
 }
 
@@ -21302,8 +21214,7 @@ ExprResult Sema::CheckBooleanCondition(SourceLocation Loc, Expr *E,
     DiagnoseEqualityWithExtraParens(parenE);
 
   ExprResult result = CheckPlaceholderExpr(E);
-  if (result.isInvalid())
-    return ExprError();
+  if (result.isInvalid()) return ExprError();
   E = result.get();
 
   if (!E->isTypeDependent()) {
@@ -21321,7 +21232,7 @@ ExprResult Sema::CheckBooleanCondition(SourceLocation Loc, Expr *E,
     QualType T = E->getType();
     if (!T->isScalarType()) { // C99 6.8.4.1p1
       Diag(Loc, diag::err_typecheck_statement_requires_scalar)
-          << T << E->getSourceRange();
+        << T << E->getSourceRange();
       return ExprError();
     }
     CheckBoolLikeConversion(E, Loc);
@@ -21369,182 +21280,190 @@ Sema::ConditionResult Sema::ActOnCondition(Scope *S, SourceLocation Loc,
 }
 
 namespace {
-/// A visitor for rebuilding a call to an __unknown_any expression
-/// to have an appropriate type.
-struct RebuildUnknownAnyFunction
+  /// A visitor for rebuilding a call to an __unknown_any expression
+  /// to have an appropriate type.
+  struct RebuildUnknownAnyFunction
     : StmtVisitor<RebuildUnknownAnyFunction, ExprResult> {
 
-  Sema &S;
+    Sema &S;
 
-  RebuildUnknownAnyFunction(Sema &S) : S(S) {}
+    RebuildUnknownAnyFunction(Sema &S) : S(S) {}
 
-  ExprResult VisitStmt(Stmt *S) { llvm_unreachable("unexpected statement!"); }
+    ExprResult VisitStmt(Stmt *S) {
+      llvm_unreachable("unexpected statement!");
+    }
 
-  ExprResult VisitExpr(Expr *E) {
-    S.Diag(E->getExprLoc(), diag::err_unsupported_unknown_any_call)
+    ExprResult VisitExpr(Expr *E) {
+      S.Diag(E->getExprLoc(), diag::err_unsupported_unknown_any_call)
         << E->getSourceRange();
-    return ExprError();
-  }
-
-  /// Rebuild an expression which simply semantically wraps another
-  /// expression which it shares the type and value kind of.
-  template <class T> ExprResult rebuildSugarExpr(T *E) {
-    ExprResult SubResult = Visit(E->getSubExpr());
-    if (SubResult.isInvalid())
       return ExprError();
+    }
 
-    Expr *SubExpr = SubResult.get();
-    E->setSubExpr(SubExpr);
-    E->setType(SubExpr->getType());
-    E->setValueKind(SubExpr->getValueKind());
-    assert(E->getObjectKind() == OK_Ordinary);
-    return E;
-  }
+    /// Rebuild an expression which simply semantically wraps another
+    /// expression which it shares the type and value kind of.
+    template <class T> ExprResult rebuildSugarExpr(T *E) {
+      ExprResult SubResult = Visit(E->getSubExpr());
+      if (SubResult.isInvalid()) return ExprError();
 
-  ExprResult VisitParenExpr(ParenExpr *E) { return rebuildSugarExpr(E); }
+      Expr *SubExpr = SubResult.get();
+      E->setSubExpr(SubExpr);
+      E->setType(SubExpr->getType());
+      E->setValueKind(SubExpr->getValueKind());
+      assert(E->getObjectKind() == OK_Ordinary);
+      return E;
+    }
 
-  ExprResult VisitUnaryExtension(UnaryOperator *E) {
-    return rebuildSugarExpr(E);
-  }
+    ExprResult VisitParenExpr(ParenExpr *E) {
+      return rebuildSugarExpr(E);
+    }
 
-  ExprResult VisitUnaryAddrOf(UnaryOperator *E) {
-    ExprResult SubResult = Visit(E->getSubExpr());
-    if (SubResult.isInvalid())
-      return ExprError();
+    ExprResult VisitUnaryExtension(UnaryOperator *E) {
+      return rebuildSugarExpr(E);
+    }
 
-    Expr *SubExpr = SubResult.get();
-    E->setSubExpr(SubExpr);
-    E->setType(S.Context.getPointerType(SubExpr->getType()));
-    assert(E->isPRValue());
-    assert(E->getObjectKind() == OK_Ordinary);
-    return E;
-  }
+    ExprResult VisitUnaryAddrOf(UnaryOperator *E) {
+      ExprResult SubResult = Visit(E->getSubExpr());
+      if (SubResult.isInvalid()) return ExprError();
 
-  ExprResult resolveDecl(Expr *E, ValueDecl *VD) {
-    if (!isa<FunctionDecl>(VD))
-      return VisitExpr(E);
+      Expr *SubExpr = SubResult.get();
+      E->setSubExpr(SubExpr);
+      E->setType(S.Context.getPointerType(SubExpr->getType()));
+      assert(E->isPRValue());
+      assert(E->getObjectKind() == OK_Ordinary);
+      return E;
+    }
 
-    E->setType(VD->getType());
+    ExprResult resolveDecl(Expr *E, ValueDecl *VD) {
+      if (!isa<FunctionDecl>(VD)) return VisitExpr(E);
 
-    assert(E->isPRValue());
-    if (S.getLangOpts().CPlusPlus &&
-        !(isa<CXXMethodDecl>(VD) && cast<CXXMethodDecl>(VD)->isInstance()))
-      E->setValueKind(VK_LValue);
+      E->setType(VD->getType());
 
-    return E;
-  }
+      assert(E->isPRValue());
+      if (S.getLangOpts().CPlusPlus &&
+          !(isa<CXXMethodDecl>(VD) &&
+            cast<CXXMethodDecl>(VD)->isInstance()))
+        E->setValueKind(VK_LValue);
 
-  ExprResult VisitMemberExpr(MemberExpr *E) {
-    return resolveDecl(E, E->getMemberDecl());
-  }
+      return E;
+    }
 
-  ExprResult VisitDeclRefExpr(DeclRefExpr *E) {
-    return resolveDecl(E, E->getDecl());
-  }
-};
-} // namespace
+    ExprResult VisitMemberExpr(MemberExpr *E) {
+      return resolveDecl(E, E->getMemberDecl());
+    }
+
+    ExprResult VisitDeclRefExpr(DeclRefExpr *E) {
+      return resolveDecl(E, E->getDecl());
+    }
+  };
+}
 
 /// Given a function expression of unknown-any type, try to rebuild it
 /// to have a function type.
 static ExprResult rebuildUnknownAnyFunction(Sema &S, Expr *FunctionExpr) {
   ExprResult Result = RebuildUnknownAnyFunction(S).Visit(FunctionExpr);
-  if (Result.isInvalid())
-    return ExprError();
+  if (Result.isInvalid()) return ExprError();
   return S.DefaultFunctionArrayConversion(Result.get());
 }
 
 namespace {
-/// A visitor for rebuilding an expression of type __unknown_anytype
-/// into one which resolves the type directly on the referring
-/// expression.  Strict preservation of the original source
-/// structure is not a goal.
-struct RebuildUnknownAnyExpr : StmtVisitor<RebuildUnknownAnyExpr, ExprResult> {
+  /// A visitor for rebuilding an expression of type __unknown_anytype
+  /// into one which resolves the type directly on the referring
+  /// expression.  Strict preservation of the original source
+  /// structure is not a goal.
+  struct RebuildUnknownAnyExpr
+    : StmtVisitor<RebuildUnknownAnyExpr, ExprResult> {
 
-  Sema &S;
+    Sema &S;
 
-  /// The current destination type.
-  QualType DestType;
+    /// The current destination type.
+    QualType DestType;
 
-  RebuildUnknownAnyExpr(Sema &S, QualType CastType)
+    RebuildUnknownAnyExpr(Sema &S, QualType CastType)
       : S(S), DestType(CastType) {}
 
-  ExprResult VisitStmt(Stmt *S) { llvm_unreachable("unexpected statement!"); }
+    ExprResult VisitStmt(Stmt *S) {
+      llvm_unreachable("unexpected statement!");
+    }
 
-  ExprResult VisitExpr(Expr *E) {
-    S.Diag(E->getExprLoc(), diag::err_unsupported_unknown_any_expr)
+    ExprResult VisitExpr(Expr *E) {
+      S.Diag(E->getExprLoc(), diag::err_unsupported_unknown_any_expr)
         << E->getSourceRange();
-    return ExprError();
-  }
+      return ExprError();
+    }
 
-  ExprResult VisitCallExpr(CallExpr *E);
-  ExprResult VisitObjCMessageExpr(ObjCMessageExpr *E);
+    ExprResult VisitCallExpr(CallExpr *E);
+    ExprResult VisitObjCMessageExpr(ObjCMessageExpr *E);
 
-  /// Rebuild an expression which simply semantically wraps another
-  /// expression which it shares the type and value kind of.
-  template <class T> ExprResult rebuildSugarExpr(T *E) {
-    ExprResult SubResult = Visit(E->getSubExpr());
-    if (SubResult.isInvalid())
-      return ExprError();
-    Expr *SubExpr = SubResult.get();
-    E->setSubExpr(SubExpr);
-    E->setType(SubExpr->getType());
-    E->setValueKind(SubExpr->getValueKind());
-    assert(E->getObjectKind() == OK_Ordinary);
-    return E;
-  }
+    /// Rebuild an expression which simply semantically wraps another
+    /// expression which it shares the type and value kind of.
+    template <class T> ExprResult rebuildSugarExpr(T *E) {
+      ExprResult SubResult = Visit(E->getSubExpr());
+      if (SubResult.isInvalid()) return ExprError();
+      Expr *SubExpr = SubResult.get();
+      E->setSubExpr(SubExpr);
+      E->setType(SubExpr->getType());
+      E->setValueKind(SubExpr->getValueKind());
+      assert(E->getObjectKind() == OK_Ordinary);
+      return E;
+    }
 
-  ExprResult VisitParenExpr(ParenExpr *E) { return rebuildSugarExpr(E); }
+    ExprResult VisitParenExpr(ParenExpr *E) {
+      return rebuildSugarExpr(E);
+    }
 
-  ExprResult VisitUnaryExtension(UnaryOperator *E) {
-    return rebuildSugarExpr(E);
-  }
+    ExprResult VisitUnaryExtension(UnaryOperator *E) {
+      return rebuildSugarExpr(E);
+    }
 
-  ExprResult VisitUnaryAddrOf(UnaryOperator *E) {
-    const PointerType *Ptr = DestType->getAs<PointerType>();
-    if (!Ptr) {
-      S.Diag(E->getOperatorLoc(), diag::err_unknown_any_addrof)
+    ExprResult VisitUnaryAddrOf(UnaryOperator *E) {
+      const PointerType *Ptr = DestType->getAs<PointerType>();
+      if (!Ptr) {
+        S.Diag(E->getOperatorLoc(), diag::err_unknown_any_addrof)
           << E->getSourceRange();
-      return ExprError();
-    }
+        return ExprError();
+      }
 
-    if (isa<CallExpr>(E->getSubExpr())) {
-      S.Diag(E->getOperatorLoc(), diag::err_unknown_any_addrof_call)
+      if (isa<CallExpr>(E->getSubExpr())) {
+        S.Diag(E->getOperatorLoc(), diag::err_unknown_any_addrof_call)
           << E->getSourceRange();
-      return ExprError();
-    }
+        return ExprError();
+      }
 
-    assert(E->isPRValue());
-    assert(E->getObjectKind() == OK_Ordinary);
-    E->setType(DestType);
+      assert(E->isPRValue());
+      assert(E->getObjectKind() == OK_Ordinary);
+      E->setType(DestType);
 
-    // Build the sub-expression as if it were an object of the pointee type.
-    DestType = Ptr->getPointeeType();
-    ExprResult SubResult = Visit(E->getSubExpr());
-    if (SubResult.isInvalid())
-      return ExprError();
-    E->setSubExpr(SubResult.get());
-    return E;
-  }
+      // Build the sub-expression as if it were an object of the pointee type.
+      DestType = Ptr->getPointeeType();
+      ExprResult SubResult = Visit(E->getSubExpr());
+      if (SubResult.isInvalid()) return ExprError();
+      E->setSubExpr(SubResult.get());
+      return E;
+    }
 
-  ExprResult VisitImplicitCastExpr(ImplicitCastExpr *E);
+    ExprResult VisitImplicitCastExpr(ImplicitCastExpr *E);
 
-  ExprResult resolveDecl(Expr *E, ValueDecl *VD);
+    ExprResult resolveDecl(Expr *E, ValueDecl *VD);
 
-  ExprResult VisitMemberExpr(MemberExpr *E) {
-    return resolveDecl(E, E->getMemberDecl());
-  }
+    ExprResult VisitMemberExpr(MemberExpr *E) {
+      return resolveDecl(E, E->getMemberDecl());
+    }
 
-  ExprResult VisitDeclRefExpr(DeclRefExpr *E) {
-    return resolveDecl(E, E->getDecl());
-  }
-};
-} // namespace
+    ExprResult VisitDeclRefExpr(DeclRefExpr *E) {
+      return resolveDecl(E, E->getDecl());
+    }
+  };
+}
 
 /// Rebuilds a call expression which yielded __unknown_anytype.
 ExprResult RebuildUnknownAnyExpr::VisitCallExpr(CallExpr *E) {
   Expr *CalleeExpr = E->getCallee();
 
-  enum FnKind { FK_MemberFunction, FK_FunctionPointer, FK_BlockPointer };
+  enum FnKind {
+    FK_MemberFunction,
+    FK_FunctionPointer,
+    FK_BlockPointer
+  };
 
   FnKind Kind;
   QualType CalleeType = CalleeExpr->getType();
@@ -21568,7 +21487,8 @@ ExprResult RebuildUnknownAnyExpr::VisitCallExpr(CallExpr *E) {
     if (Kind == FK_BlockPointer)
       diagID = diag::err_block_returning_array_function;
 
-    S.Diag(E->getExprLoc(), diagID) << DestType->isFunctionType() << DestType;
+    S.Diag(E->getExprLoc(), diagID)
+      << DestType->isFunctionType() << DestType;
     return ExprError();
   }
 
@@ -21611,7 +21531,8 @@ ExprResult RebuildUnknownAnyExpr::VisitCallExpr(CallExpr *E) {
     DestType = S.Context.getFunctionType(DestType, ParamTypes,
                                          Proto->getExtProtoInfo());
   } else {
-    DestType = S.Context.getFunctionNoProtoType(DestType, FnType->getExtInfo());
+    DestType = S.Context.getFunctionNoProtoType(DestType,
+                                                FnType->getExtInfo());
   }
 
   // Rebuild the appropriate pointer-to-function type.
@@ -21631,8 +21552,7 @@ ExprResult RebuildUnknownAnyExpr::VisitCallExpr(CallExpr *E) {
 
   // Finally, we can recurse.
   ExprResult CalleeResult = Visit(CalleeExpr);
-  if (!CalleeResult.isUsable())
-    return ExprError();
+  if (!CalleeResult.isUsable()) return ExprError();
   E->setCallee(CalleeResult.get());
 
   // Bind a temporary if necessary.
@@ -21643,7 +21563,7 @@ ExprResult RebuildUnknownAnyExpr::VisitObjCMessageExpr(ObjCMessageExpr *E) {
   // Verify that this is a legal result type of a call.
   if (DestType->isArrayType() || DestType->isFunctionType()) {
     S.Diag(E->getExprLoc(), diag::err_func_returning_array_function)
-        << DestType->isFunctionType() << DestType;
+      << DestType->isFunctionType() << DestType;
     return ExprError();
   }
 
@@ -21672,8 +21592,7 @@ ExprResult RebuildUnknownAnyExpr::VisitImplicitCastExpr(ImplicitCastExpr *E) {
     DestType = DestType->castAs<PointerType>()->getPointeeType();
 
     ExprResult Result = Visit(E->getSubExpr());
-    if (!Result.isUsable())
-      return ExprError();
+    if (!Result.isUsable()) return ExprError();
 
     E->setSubExpr(Result.get());
     return E;
@@ -21689,8 +21608,7 @@ ExprResult RebuildUnknownAnyExpr::VisitImplicitCastExpr(ImplicitCastExpr *E) {
     DestType = S.Context.getLValueReferenceType(DestType);
 
     ExprResult Result = Visit(E->getSubExpr());
-    if (!Result.isUsable())
-      return ExprError();
+    if (!Result.isUsable()) return ExprError();
 
     E->setSubExpr(Result.get());
     return E;
@@ -21710,15 +21628,14 @@ ExprResult RebuildUnknownAnyExpr::resolveDecl(Expr *E, ValueDecl *VD) {
     if (const PointerType *Ptr = Type->getAs<PointerType>()) {
       DestType = Ptr->getPointeeType();
       ExprResult Result = resolveDecl(E, VD);
-      if (Result.isInvalid())
-        return ExprError();
+      if (Result.isInvalid()) return ExprError();
       return S.ImpCastExprToType(Result.get(), Type, CK_FunctionToPointerDecay,
                                  VK_PRValue);
     }
 
     if (!Type->isFunctionType()) {
       S.Diag(E->getExprLoc(), diag::err_unknown_any_function)
-          << VD << E->getSourceRange();
+        << VD << E->getSourceRange();
       return ExprError();
     }
     if (const FunctionProtoType *FT = Type->getAs<FunctionProtoType>()) {
@@ -21727,11 +21644,9 @@ ExprResult RebuildUnknownAnyExpr::resolveDecl(Expr *E, ValueDecl *VD) {
       // type. See the lengthy commentary in that routine.
       QualType FDT = FD->getType();
       const FunctionType *FnType = FDT->castAs<FunctionType>();
-      const FunctionProtoType *Proto =
-          dyn_cast_or_null<FunctionProtoType>(FnType);
+      const FunctionProtoType *Proto = dyn_cast_or_null<FunctionProtoType>(FnType);
       DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E);
-      if (DRE && Proto && Proto->getParamTypes().empty() &&
-          Proto->isVariadic()) {
+      if (DRE && Proto && Proto->getParamTypes().empty() && Proto->isVariadic()) {
         SourceLocation Loc = FD->getLocation();
         FunctionDecl *NewFD = FunctionDecl::Create(
             S.Context, FD->getDeclContext(), Loc, Loc,
@@ -21743,9 +21658,10 @@ ExprResult RebuildUnknownAnyExpr::resolveDecl(Expr *E, ValueDecl *VD) {
         if (FD->getQualifier())
           NewFD->setQualifierInfo(FD->getQualifierLoc());
 
-        SmallVector<ParmVarDecl *, 16> Params;
+        SmallVector<ParmVarDecl*, 16> Params;
         for (const auto &AI : FT->param_types()) {
-          ParmVarDecl *Param = S.BuildParmVarDeclForTypedef(FD, Loc, AI);
+          ParmVarDecl *Param =
+            S.BuildParmVarDeclForTypedef(FD, Loc, AI);
           Param->setScopeInfo(0, Params.size());
           Params.push_back(Param);
         }
@@ -21765,20 +21681,20 @@ ExprResult RebuildUnknownAnyExpr::resolveDecl(Expr *E, ValueDecl *VD) {
     if (!S.getLangOpts().CPlusPlus)
       ValueKind = VK_PRValue;
 
-    //  - variables
+  //  - variables
   } else if (isa<VarDecl>(VD)) {
     if (const ReferenceType *RefTy = Type->getAs<ReferenceType>()) {
       Type = RefTy->getPointeeType();
     } else if (Type->isFunctionType()) {
       S.Diag(E->getExprLoc(), diag::err_unknown_any_var_function_type)
-          << VD << E->getSourceRange();
+        << VD << E->getSourceRange();
       return ExprError();
     }
 
-    //  - nothing else
+  //  - nothing else
   } else {
     S.Diag(E->getExprLoc(), diag::err_unsupported_unknown_any_decl)
-        << VD << E->getSourceRange();
+      << VD << E->getSourceRange();
     return ExprError();
   }
 
@@ -21801,8 +21717,7 @@ ExprResult Sema::checkUnknownAnyCast(SourceRange TypeRange, QualType CastType,
 
   // Rewrite the casted expression from scratch.
   ExprResult result = RebuildUnknownAnyExpr(*this, CastType).Visit(CastExpr);
-  if (!result.isUsable())
-    return ExprError();
+  if (!result.isUsable()) return ExprError();
 
   CastExpr = result.get();
   VK = CastExpr->getValueKind();
@@ -21815,15 +21730,14 @@ ExprResult Sema::forceUnknownAnyToType(Expr *E, QualType ToType) {
   return RebuildUnknownAnyExpr(*this, ToType).Visit(E);
 }
 
-ExprResult Sema::checkUnknownAnyArg(SourceLocation callLoc, Expr *arg,
-                                    QualType &paramType) {
+ExprResult Sema::checkUnknownAnyArg(SourceLocation callLoc,
+                                    Expr *arg, QualType &paramType) {
   // If the syntactic form of the argument is not an explicit cast of
   // any sort, just do default argument promotion.
   ExplicitCastExpr *castArg = dyn_cast<ExplicitCastExpr>(arg->IgnoreParens());
   if (!castArg) {
     ExprResult result = DefaultArgumentPromotion(arg);
-    if (result.isInvalid())
-      return ExprError();
+    if (result.isInvalid()) return ExprError();
     paramType = result.get()->getType();
     return result;
   }
@@ -21834,8 +21748,8 @@ ExprResult Sema::checkUnknownAnyArg(SourceLocation callLoc, Expr *arg,
 
   // Copy-initialize a parameter of that type.
   InitializedEntity entity =
-      InitializedEntity::InitializeParameter(Context, paramType,
-                                             /*consumed*/ false);
+    InitializedEntity::InitializeParameter(Context, paramType,
+                                           /*consumed*/ false);
   return PerformCopyInitialization(entity, callLoc, arg);
 }
 
@@ -21866,13 +21780,13 @@ static ExprResult diagnoseUnknownAnyExpr(Sema &S, Expr *E) {
     d = msg->getMethodDecl();
     if (!d) {
       S.Diag(loc, diag::err_uncasted_send_to_unknown_any_method)
-          << static_cast<unsigned>(msg->isClassMessage()) << msg->getSelector()
-          << orig->getSourceRange();
+        << static_cast<unsigned>(msg->isClassMessage()) << msg->getSelector()
+        << orig->getSourceRange();
       return ExprError();
     }
   } else {
     S.Diag(E->getExprLoc(), diag::err_unsupported_unknown_any_expr)
-        << E->getSourceRange();
+      << E->getSourceRange();
     return ExprError();
   }
 
@@ -21884,8 +21798,7 @@ static ExprResult diagnoseUnknownAnyExpr(Sema &S, Expr *E) {
 
 ExprResult Sema::CheckPlaceholderExpr(Expr *E) {
   const BuiltinType *placeholderType = E->getType()->getAsPlaceholderType();
-  if (!placeholderType)
-    return E;
+  if (!placeholderType) return E;
 
   switch (placeholderType->getKind()) {
   case BuiltinType::UnresolvedTemplate: {
@@ -22066,15 +21979,18 @@ ExprResult Sema::CheckPlaceholderExpr(Expr *E) {
   case BuiltinType::OMPIterator:
     return ExprError(Diag(E->getBeginLoc(), diag::err_omp_iterator_use));
 
-    // Everything else should be impossible.
-#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)                   \
+  // Everything else should be impossible.
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
   case BuiltinType::Id:
 #include "clang/Basic/OpenCLImageTypes.def"
-#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) case BuiltinType::Id:
+#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
+  case BuiltinType::Id:
 #include "clang/Basic/OpenCLExtensionTypes.def"
-#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
+#define SVE_TYPE(Name, Id, SingletonId) \
+  case BuiltinType::Id:
 #include "clang/Basic/AArch64ACLETypes.def"
-#define PPC_VECTOR_TYPE(Name, Id, Size) case BuiltinType::Id:
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
+  case BuiltinType::Id:
 #include "clang/Basic/PPCTypes.def"
 #define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
 #include "clang/Basic/RISCVVTypes.def"
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 61aa1fc815b3d..94a58870fa016 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -90,27 +90,33 @@ static ExprResult CreateFunctionRefExpr(
                              CK_FunctionToPointerDecay);
 }
 
-static bool IsStandardConversion(Sema &S, Expr *From, QualType ToType,
+static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
                                  bool InOverloadResolution,
-                                 StandardConversionSequence &SCS, bool CStyle,
+                                 StandardConversionSequence &SCS,
+                                 bool CStyle,
                                  bool AllowObjCWritebackConversion);
 
-static bool IsTransparentUnionStandardConversion(
-    Sema &S, Expr *From, QualType &ToType, bool InOverloadResolution,
-    StandardConversionSequence &SCS, bool CStyle);
-static OverloadingResult IsUserDefinedConversion(
-    Sema &S, Expr *From, QualType ToType, UserDefinedConversionSequence &User,
-    OverloadCandidateSet &Conversions, AllowedExplicit AllowExplicit,
-    bool AllowObjCConversionOnExplicit);
+static bool IsTransparentUnionStandardConversion(Sema &S, Expr* From,
+                                                 QualType &ToType,
+                                                 bool InOverloadResolution,
+                                                 StandardConversionSequence &SCS,
+                                                 bool CStyle);
+static OverloadingResult
+IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
+                        UserDefinedConversionSequence& User,
+                        OverloadCandidateSet& Conversions,
+                        AllowedExplicit AllowExplicit,
+                        bool AllowObjCConversionOnExplicit);
 
 static ImplicitConversionSequence::CompareKind
 CompareStandardConversionSequences(Sema &S, SourceLocation Loc,
-                                   const StandardConversionSequence &SCS1,
-                                   const StandardConversionSequence &SCS2);
+                                   const StandardConversionSequence& SCS1,
+                                   const StandardConversionSequence& SCS2);
 
 static ImplicitConversionSequence::CompareKind
-CompareQualificationConversions(Sema &S, const StandardConversionSequence &SCS1,
-                                const StandardConversionSequence &SCS2);
+CompareQualificationConversions(Sema &S,
+                                const StandardConversionSequence& SCS1,
+                                const StandardConversionSequence& SCS2);
 
 static ImplicitConversionSequence::CompareKind
 CompareOverflowBehaviorConversions(Sema &S,
@@ -119,8 +125,8 @@ CompareOverflowBehaviorConversions(Sema &S,
 
 static ImplicitConversionSequence::CompareKind
 CompareDerivedToBaseConversions(Sema &S, SourceLocation Loc,
-                                const StandardConversionSequence &SCS1,
-                                const StandardConversionSequence &SCS2);
+                                const StandardConversionSequence& SCS1,
+                                const StandardConversionSequence& SCS2);
 
 /// GetConversionRank - Retrieve the implicit conversion rank
 /// corresponding to the given implicit conversion kind.
@@ -281,10 +287,11 @@ bool StandardConversionSequence::isPointerConversionToBool() const {
   // check for their presence as well as checking whether FromType is
   // a pointer.
   if (getToType(1)->isBooleanType() &&
-      (getFromType()->isPointerType() || getFromType()->isMemberPointerType() ||
+      (getFromType()->isPointerType() ||
+       getFromType()->isMemberPointerType() ||
        getFromType()->isObjCObjectPointerType() ||
-       getFromType()->isBlockPointerType() || First == ICK_Array_To_Pointer ||
-       First == ICK_Function_To_Pointer))
+       getFromType()->isBlockPointerType() ||
+       First == ICK_Array_To_Pointer || First == ICK_Function_To_Pointer))
     return true;
 
   return false;
@@ -294,8 +301,9 @@ bool StandardConversionSequence::isPointerConversionToBool() const {
 /// conversion is a conversion of a pointer to a void pointer. This is
 /// used as part of the ranking of standard conversion sequences (C++
 /// 13.3.3.2p4).
-bool StandardConversionSequence::isPointerConversionToVoidPointer(
-    ASTContext &Context) const {
+bool
+StandardConversionSequence::
+isPointerConversionToVoidPointer(ASTContext& Context) const {
   QualType FromType = getFromType();
   QualType ToType = getToType(1);
 
@@ -306,7 +314,7 @@ bool StandardConversionSequence::isPointerConversionToVoidPointer(
     FromType = Context.getArrayDecayedType(FromType);
 
   if (Second == ICK_Pointer_Conversion && FromType->isAnyPointerType())
-    if (const PointerType *ToPtrType = ToType->getAs<PointerType>())
+    if (const PointerType* ToPtrType = ToType->getAs<PointerType>())
       return ToPtrType->getPointeeType()->isVoidType();
 
   return false;
@@ -699,40 +707,42 @@ void AmbiguousConversionSequence::construct() {
   new (&conversions()) ConversionSet();
 }
 
-void AmbiguousConversionSequence::destruct() { conversions().~ConversionSet(); }
+void AmbiguousConversionSequence::destruct() {
+  conversions().~ConversionSet();
+}
 
-void AmbiguousConversionSequence::copyFrom(
-    const AmbiguousConversionSequence &O) {
+void
+AmbiguousConversionSequence::copyFrom(const AmbiguousConversionSequence &O) {
   FromTypePtr = O.FromTypePtr;
   ToTypePtr = O.ToTypePtr;
   new (&conversions()) ConversionSet(O.conversions());
 }
 
 namespace {
-// Structure used by DeductionFailureInfo to store
-// template argument information.
-struct DFIArguments {
-  TemplateArgument FirstArg;
-  TemplateArgument SecondArg;
-};
-// Structure used by DeductionFailureInfo to store
-// template parameter and template argument information.
-struct DFIParamWithArguments : DFIArguments {
-  TemplateParameter Param;
-};
-// Structure used by DeductionFailureInfo to store template argument
-// information and the index of the problematic call argument.
-struct DFIDeducedMismatchArgs : DFIArguments {
-  TemplateArgumentList *TemplateArgs;
-  unsigned CallArgIndex;
-};
-// Structure used by DeductionFailureInfo to store information about
-// unsatisfied constraints.
-struct CNSInfo {
-  TemplateArgumentList *TemplateArgs;
-  ConstraintSatisfaction Satisfaction;
-};
-} // namespace
+  // Structure used by DeductionFailureInfo to store
+  // template argument information.
+  struct DFIArguments {
+    TemplateArgument FirstArg;
+    TemplateArgument SecondArg;
+  };
+  // Structure used by DeductionFailureInfo to store
+  // template parameter and template argument information.
+  struct DFIParamWithArguments : DFIArguments {
+    TemplateParameter Param;
+  };
+  // Structure used by DeductionFailureInfo to store template argument
+  // information and the index of the problematic call argument.
+  struct DFIDeducedMismatchArgs : DFIArguments {
+    TemplateArgumentList *TemplateArgs;
+    unsigned CallArgIndex;
+  };
+  // Structure used by DeductionFailureInfo to store information about
+  // unsatisfied constraints.
+  struct CNSInfo {
+    TemplateArgumentList *TemplateArgs;
+    ConstraintSatisfaction Satisfaction;
+  };
+}
 
 /// Convert from Sema's representation of template deduction information
 /// to the form used in overload-candidate information.
@@ -870,7 +880,7 @@ void DeductionFailureInfo::Destroy() {
 
 PartialDiagnosticAt *DeductionFailureInfo::getSFINAEDiagnostic() {
   if (HasDiagnostic)
-    return static_cast<PartialDiagnosticAt *>(static_cast<void *>(Diagnostic));
+    return static_cast<PartialDiagnosticAt*>(static_cast<void*>(Diagnostic));
   return nullptr;
 }
 
@@ -897,7 +907,7 @@ TemplateParameter DeductionFailureInfo::getTemplateParameter() {
   case TemplateDeductionResult::IncompletePack:
   case TemplateDeductionResult::Inconsistent:
   case TemplateDeductionResult::Underqualified:
-    return static_cast<DFIParamWithArguments *>(Data)->Param;
+    return static_cast<DFIParamWithArguments*>(Data)->Param;
 
   // Unhandled
   case TemplateDeductionResult::MiscellaneousDeductionFailure:
@@ -927,13 +937,13 @@ TemplateArgumentList *DeductionFailureInfo::getTemplateArgumentList() {
 
   case TemplateDeductionResult::DeducedMismatch:
   case TemplateDeductionResult::DeducedMismatchNested:
-    return static_cast<DFIDeducedMismatchArgs *>(Data)->TemplateArgs;
+    return static_cast<DFIDeducedMismatchArgs*>(Data)->TemplateArgs;
 
   case TemplateDeductionResult::SubstitutionFailure:
-    return static_cast<TemplateArgumentList *>(Data);
+    return static_cast<TemplateArgumentList*>(Data);
 
   case TemplateDeductionResult::ConstraintsNotSatisfied:
-    return static_cast<CNSInfo *>(Data)->TemplateArgs;
+    return static_cast<CNSInfo*>(Data)->TemplateArgs;
 
   // Unhandled
   case TemplateDeductionResult::MiscellaneousDeductionFailure:
@@ -965,7 +975,7 @@ const TemplateArgument *DeductionFailureInfo::getFirstArg() {
   case TemplateDeductionResult::DeducedMismatch:
   case TemplateDeductionResult::DeducedMismatchNested:
   case TemplateDeductionResult::NonDeducedMismatch:
-    return &static_cast<DFIArguments *>(Data)->FirstArg;
+    return &static_cast<DFIArguments*>(Data)->FirstArg;
 
   // Unhandled
   case TemplateDeductionResult::MiscellaneousDeductionFailure:
@@ -997,7 +1007,7 @@ const TemplateArgument *DeductionFailureInfo::getSecondArg() {
   case TemplateDeductionResult::DeducedMismatch:
   case TemplateDeductionResult::DeducedMismatchNested:
   case TemplateDeductionResult::NonDeducedMismatch:
-    return &static_cast<DFIArguments *>(Data)->SecondArg;
+    return &static_cast<DFIArguments*>(Data)->SecondArg;
 
   // Unhandled
   case TemplateDeductionResult::MiscellaneousDeductionFailure:
@@ -1012,7 +1022,7 @@ UnsignedOrNone DeductionFailureInfo::getCallArgIndex() {
   switch (static_cast<TemplateDeductionResult>(Result)) {
   case TemplateDeductionResult::DeducedMismatch:
   case TemplateDeductionResult::DeducedMismatchNested:
-    return static_cast<DFIDeducedMismatchArgs *>(Data)->CallArgIndex;
+    return static_cast<DFIDeducedMismatchArgs*>(Data)->CallArgIndex;
 
   default:
     return std::nullopt;
@@ -1136,29 +1146,28 @@ void OverloadCandidateSet::clear(CandidateSetKind CSK) {
 }
 
 namespace {
-class UnbridgedCastsSet {
-  struct Entry {
-    Expr **Addr;
-    Expr *Saved;
-  };
-  SmallVector<Entry, 2> Entries;
+  class UnbridgedCastsSet {
+    struct Entry {
+      Expr **Addr;
+      Expr *Saved;
+    };
+    SmallVector<Entry, 2> Entries;
 
-public:
-  void save(Sema &S, Expr *&E) {
-    assert(E->hasPlaceholderType(BuiltinType::ARCUnbridgedCast));
-    Entry entry = {&E, E};
-    Entries.push_back(entry);
-    E = S.ObjC().stripARCUnbridgedCast(E);
-  }
+  public:
+    void save(Sema &S, Expr *&E) {
+      assert(E->hasPlaceholderType(BuiltinType::ARCUnbridgedCast));
+      Entry entry = { &E, E };
+      Entries.push_back(entry);
+      E = S.ObjC().stripARCUnbridgedCast(E);
+    }
 
-  void restore() {
-    for (SmallVectorImpl<Entry>::iterator i = Entries.begin(),
-                                          e = Entries.end();
-         i != e; ++i)
-      *i->Addr = i->Saved;
-  }
-};
-} // namespace
+    void restore() {
+      for (SmallVectorImpl<Entry>::iterator
+             i = Entries.begin(), e = Entries.end(); i != e; ++i)
+        *i->Addr = i->Saved;
+    }
+  };
+}
 
 /// checkPlaceholderForOverload - Do any interesting placeholder-like
 /// preprocessing on the given expression.
@@ -1170,11 +1179,10 @@ class UnbridgedCastsSet {
 static bool
 checkPlaceholderForOverload(Sema &S, Expr *&E,
                             UnbridgedCastsSet *unbridgedCasts = nullptr) {
-  if (const BuiltinType *placeholder = E->getType()->getAsPlaceholderType()) {
+  if (const BuiltinType *placeholder =  E->getType()->getAsPlaceholderType()) {
     // We can't handle overloaded expressions here because overload
     // resolution might reasonably tweak them.
-    if (placeholder->getKind() == BuiltinType::Overload)
-      return false;
+    if (placeholder->getKind() == BuiltinType::Overload) return false;
 
     // If the context potentially accepts unbridged ARC casts, strip
     // the unbridged cast and add it to the collection for later restoration.
@@ -1211,7 +1219,8 @@ static bool checkArgPlaceholdersForOverload(Sema &S, MultiExprArg Args,
 OverloadKind Sema::CheckOverload(Scope *S, FunctionDecl *New,
                                  const LookupResult &Old, NamedDecl *&Match,
                                  bool NewIsUsingDecl) {
-  for (LookupResult::iterator I = Old.begin(), E = Old.end(); I != E; ++I) {
+  for (LookupResult::iterator I = Old.begin(), E = Old.end();
+         I != E; ++I) {
     NamedDecl *OldD = *I;
 
     bool OldIsUsingDecl = false;
@@ -1220,8 +1229,7 @@ OverloadKind Sema::CheckOverload(Scope *S, FunctionDecl *New,
 
       // We can always introduce two using declarations into the same
       // context, even if they have identical signatures.
-      if (NewIsUsingDecl)
-        continue;
+      if (NewIsUsingDecl) continue;
 
       OldD = cast<UsingShadowDecl>(OldD)->getTargetDecl();
     }
@@ -1236,9 +1244,9 @@ OverloadKind Sema::CheckOverload(Scope *S, FunctionDecl *New,
     // Essentially, these rules are the normal rules, except that
     // function templates hide function templates with different
     // return types or template parameter lists.
-    bool UseMemberUsingDeclRules = (OldIsUsingDecl || NewIsUsingDecl) &&
-                                   CurContext->isRecord() &&
-                                   !New->getFriendObjectKind();
+    bool UseMemberUsingDeclRules =
+      (OldIsUsingDecl || NewIsUsingDecl) && CurContext->isRecord() &&
+      !New->getFriendObjectKind();
 
     if (FunctionDecl *OldF = OldD->getAsFunction()) {
       if (!IsOverload(New, OldF, UseMemberUsingDeclRules)) {
@@ -1309,7 +1317,7 @@ OverloadKind Sema::CheckOverload(Scope *S, FunctionDecl *New,
     LookupResult TemplateSpecResult(LookupResult::Temporary, Old);
     TemplateSpecResult.addAllDecls(Old);
     if (CheckFunctionTemplateSpecialization(New, nullptr, TemplateSpecResult,
-                                            /*QualifiedFriend*/ true)) {
+                                            /*QualifiedFriend*/true)) {
       New->setInvalidDecl();
       return OverloadKind::Overload;
     }
@@ -1590,10 +1598,10 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, FunctionDecl *New,
 
   // enable_if attributes are an order-sensitive part of the signature.
   for (specific_attr_iterator<EnableIfAttr>
-           NewI = New->specific_attr_begin<EnableIfAttr>(),
-           NewE = New->specific_attr_end<EnableIfAttr>(),
-           OldI = Old->specific_attr_begin<EnableIfAttr>(),
-           OldE = Old->specific_attr_end<EnableIfAttr>();
+         NewI = New->specific_attr_begin<EnableIfAttr>(),
+         NewE = New->specific_attr_end<EnableIfAttr>(),
+         OldI = Old->specific_attr_begin<EnableIfAttr>(),
+         OldE = Old->specific_attr_end<EnableIfAttr>();
        NewI != NewE || OldI != OldE; ++NewI, ++OldI) {
     if (NewI == NewE || OldI == OldE)
       return true;
@@ -1656,10 +1664,14 @@ bool Sema::IsOverride(FunctionDecl *MD, FunctionDecl *BaseMD,
 ///
 /// Produces an implicit conversion sequence for when a standard conversion
 /// is not an option. See TryImplicitConversion for more information.
-static ImplicitConversionSequence TryUserDefinedConversion(
-    Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions,
-    AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle,
-    bool AllowObjCWritebackConversion, bool AllowObjCConversionOnExplicit) {
+static ImplicitConversionSequence
+TryUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
+                         bool SuppressUserConversions,
+                         AllowedExplicit AllowExplicit,
+                         bool InOverloadResolution,
+                         bool CStyle,
+                         bool AllowObjCWritebackConversion,
+                         bool AllowObjCConversionOnExplicit) {
   ImplicitConversionSequence ICS;
 
   if (SuppressUserConversions) {
@@ -1672,8 +1684,8 @@ static ImplicitConversionSequence TryUserDefinedConversion(
   // Attempt user-defined conversion.
   OverloadCandidateSet Conversions(From->getExprLoc(),
                                    OverloadCandidateSet::CSK_Normal);
-  switch (IsUserDefinedConversion(S, From, ToType, ICS.UserDefined, Conversions,
-                                  AllowExplicit,
+  switch (IsUserDefinedConversion(S, From, ToType, ICS.UserDefined,
+                                  Conversions, AllowExplicit,
                                   AllowObjCConversionOnExplicit)) {
   case OR_Success:
   case OR_Deleted:
@@ -1685,8 +1697,8 @@ static ImplicitConversionSequence TryUserDefinedConversion(
     //   given Conversion rank, in spite of the fact that a copy
     //   constructor (i.e., a user-defined conversion function) is
     //   called for those cases.
-    if (CXXConstructorDecl *Constructor =
-            dyn_cast<CXXConstructorDecl>(ICS.UserDefined.ConversionFunction)) {
+    if (CXXConstructorDecl *Constructor
+          = dyn_cast<CXXConstructorDecl>(ICS.UserDefined.ConversionFunction)) {
       QualType FromType;
       SourceLocation FromLoc;
       // C++11 [over.ics.list]p6, per DR2137:
@@ -1709,8 +1721,8 @@ static ImplicitConversionSequence TryUserDefinedConversion(
       }
       QualType FromCanon =
           S.Context.getCanonicalType(FromType.getUnqualifiedType());
-      QualType ToCanon =
-          S.Context.getCanonicalType(ToType).getUnqualifiedType();
+      QualType ToCanon
+        = S.Context.getCanonicalType(ToType).getUnqualifiedType();
       if ((FromCanon == ToCanon ||
            S.IsDerivedFrom(FromLoc, FromCanon, ToCanon))) {
         // Turn this into a "standard" conversion sequence, so that it
@@ -1775,13 +1787,17 @@ static ImplicitConversionSequence TryUserDefinedConversion(
 /// \param AllowObjCWritebackConversion Whether we allow the Objective-C
 /// writeback conversion, which allows __autoreleasing id* parameters to
 /// be initialized with __strong id* or __weak id* arguments.
-static ImplicitConversionSequence TryImplicitConversion(
-    Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions,
-    AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle,
-    bool AllowObjCWritebackConversion, bool AllowObjCConversionOnExplicit) {
+static ImplicitConversionSequence
+TryImplicitConversion(Sema &S, Expr *From, QualType ToType,
+                      bool SuppressUserConversions,
+                      AllowedExplicit AllowExplicit,
+                      bool InOverloadResolution,
+                      bool CStyle,
+                      bool AllowObjCWritebackConversion,
+                      bool AllowObjCConversionOnExplicit) {
   ImplicitConversionSequence ICS;
-  if (IsStandardConversion(S, From, ToType, InOverloadResolution, ICS.Standard,
-                           CStyle, AllowObjCWritebackConversion)) {
+  if (IsStandardConversion(S, From, ToType, InOverloadResolution,
+                           ICS.Standard, CStyle, AllowObjCWritebackConversion)){
     ICS.setStandard();
     return ICS;
   }
@@ -1857,10 +1873,13 @@ static ImplicitConversionSequence TryImplicitConversion(
                                   AllowObjCConversionOnExplicit);
 }
 
-ImplicitConversionSequence Sema::TryImplicitConversion(
-    Expr *From, QualType ToType, bool SuppressUserConversions,
-    AllowedExplicit AllowExplicit, bool InOverloadResolution, bool CStyle,
-    bool AllowObjCWritebackConversion) {
+ImplicitConversionSequence
+Sema::TryImplicitConversion(Expr *From, QualType ToType,
+                            bool SuppressUserConversions,
+                            AllowedExplicit AllowExplicit,
+                            bool InOverloadResolution,
+                            bool CStyle,
+                            bool AllowObjCWritebackConversion) {
   return ::TryImplicitConversion(*this, From, ToType, SuppressUserConversions,
                                  AllowExplicit, InOverloadResolution, CStyle,
                                  AllowObjCWritebackConversion,
@@ -1912,8 +1931,7 @@ bool Sema::IsFunctionConversion(QualType FromType, QualType ToType) const {
   CanQualType CanTo = Context.getCanonicalType(ToType);
   CanQualType CanFrom = Context.getCanonicalType(FromType);
   Type::TypeClass TyClass = CanTo->getTypeClass();
-  if (TyClass != CanFrom->getTypeClass())
-    return false;
+  if (TyClass != CanFrom->getTypeClass()) return false;
   if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto) {
     if (TyClass == Type::Pointer) {
       CanTo = CanTo.castAs<PointerType>()->getPointeeType();
@@ -1935,8 +1953,7 @@ bool Sema::IsFunctionConversion(QualType FromType, QualType ToType) const {
     }
 
     TyClass = CanTo->getTypeClass();
-    if (TyClass != CanFrom->getTypeClass())
-      return false;
+    if (TyClass != CanFrom->getTypeClass()) return false;
     if (TyClass != Type::FunctionProto && TyClass != Type::FunctionNoProto)
       return false;
   }
@@ -1974,9 +1991,9 @@ bool Sema::IsFunctionConversion(QualType FromType, QualType ToType) const {
   if (FromFPT && ToFPT) {
     if (FromFPT->isNothrow() && !ToFPT->isNothrow()) {
       FromFn = cast<FunctionType>(
-          Context
-              .getFunctionTypeWithExceptionSpec(QualType(FromFPT, 0), EST_None)
-              .getTypePtr());
+          Context.getFunctionTypeWithExceptionSpec(QualType(FromFPT, 0),
+                                                   EST_None)
+                 .getTypePtr());
       Changed = true;
     }
 
@@ -2019,8 +2036,7 @@ bool Sema::IsFunctionConversion(QualType FromType, QualType ToType) const {
     return false;
 
   assert(QualType(FromFn, 0).isCanonical());
-  if (QualType(FromFn, 0) != CanTo)
-    return false;
+  if (QualType(FromFn, 0) != CanTo) return false;
 
   return true;
 }
@@ -2282,7 +2298,8 @@ static bool IsVectorConversion(Sema &S, QualType FromType, QualType ToType,
 
 static bool tryAtomicConversion(Sema &S, Expr *From, QualType ToType,
                                 bool InOverloadResolution,
-                                StandardConversionSequence &SCS, bool CStyle);
+                                StandardConversionSequence &SCS,
+                                bool CStyle);
 
 static bool tryOverflowBehaviorTypeConversion(Sema &S, Expr *From,
                                               QualType ToType,
@@ -2298,9 +2315,10 @@ static bool tryOverflowBehaviorTypeConversion(Sema &S, Expr *From,
 /// contain the standard conversion sequence required to perform this
 /// conversion and this routine will return true. Otherwise, this
 /// routine will return false and the value of SCS is unspecified.
-static bool IsStandardConversion(Sema &S, Expr *From, QualType ToType,
+static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType,
                                  bool InOverloadResolution,
-                                 StandardConversionSequence &SCS, bool CStyle,
+                                 StandardConversionSequence &SCS,
+                                 bool CStyle,
                                  bool AllowObjCWritebackConversion) {
   QualType FromType = From->getType();
 
@@ -2322,8 +2340,9 @@ static bool IsStandardConversion(Sema &S, Expr *From, QualType ToType,
 
   if (FromType == S.Context.OverloadTy) {
     DeclAccessPair AccessPair;
-    if (FunctionDecl *Fn = S.ResolveAddressOfOverloadedFunction(
-            From, ToType, false, AccessPair)) {
+    if (FunctionDecl *Fn
+          = S.ResolveAddressOfOverloadedFunction(From, ToType, false,
+                                                 AccessPair)) {
       // We were able to resolve the address of the overloaded function,
       // so we can convert to the type of that function.
       FromType = Fn->getType();
@@ -2350,14 +2369,14 @@ static bool IsStandardConversion(Sema &S, Expr *From, QualType ToType,
           !Method->isExplicitObjectMemberFunction()) {
         assert(isa<UnaryOperator>(From->IgnoreParens()) &&
                "Non-unary operator on non-static member address");
-        assert(cast<UnaryOperator>(From->IgnoreParens())->getOpcode() ==
-                   UO_AddrOf &&
+        assert(cast<UnaryOperator>(From->IgnoreParens())->getOpcode()
+               == UO_AddrOf &&
                "Non-address-of operator on non-static member address");
         FromType = S.Context.getMemberPointerType(
             FromType, /*Qualifier=*/std::nullopt, Method->getParent());
       } else if (isa<UnaryOperator>(From->IgnoreParens())) {
         assert(cast<UnaryOperator>(From->IgnoreParens())->getOpcode() ==
-                   UO_AddrOf &&
+               UO_AddrOf &&
                "Non-address-of operator for overloaded function expression");
         FromType = S.Context.getPointerType(FromType);
       }
@@ -2610,8 +2629,8 @@ static bool IsStandardConversion(Sema &S, Expr *From, QualType ToType,
   //   a conversion. [...]
   QualType CanonFrom = S.Context.getCanonicalType(FromType);
   QualType CanonTo = S.Context.getCanonicalType(ToType);
-  if (CanonFrom.getLocalUnqualifiedType() ==
-          CanonTo.getLocalUnqualifiedType() &&
+  if (CanonFrom.getLocalUnqualifiedType()
+                                     == CanonTo.getLocalUnqualifiedType() &&
       CanonFrom.getLocalQualifiers() != CanonTo.getLocalQualifiers()) {
     FromType = ToType;
     CanonFrom = CanonTo;
@@ -2667,9 +2686,12 @@ static bool IsStandardConversion(Sema &S, Expr *From, QualType ToType,
   return true;
 }
 
-static bool IsTransparentUnionStandardConversion(
-    Sema &S, Expr *From, QualType &ToType, bool InOverloadResolution,
-    StandardConversionSequence &SCS, bool CStyle) {
+static bool
+IsTransparentUnionStandardConversion(Sema &S, Expr* From,
+                                     QualType &ToType,
+                                     bool InOverloadResolution,
+                                     StandardConversionSequence &SCS,
+                                     bool CStyle) {
 
   const RecordType *UT = ToType->getAsUnionType();
   if (!UT)
@@ -2780,9 +2802,11 @@ bool Sema::IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType) {
 
     // The types we'll try to promote to, in the appropriate
     // order. Try each of these types.
-    QualType PromoteTypes[6] = {Context.IntTy,      Context.UnsignedIntTy,
-                                Context.LongTy,     Context.UnsignedLongTy,
-                                Context.LongLongTy, Context.UnsignedLongLongTy};
+    QualType PromoteTypes[6] = {
+      Context.IntTy, Context.UnsignedIntTy,
+      Context.LongTy, Context.UnsignedLongTy ,
+      Context.LongLongTy, Context.UnsignedLongLongTy
+    };
     for (int Idx = 0; Idx < 6; ++Idx) {
       uint64_t ToSize = Context.getTypeSize(PromoteTypes[Idx]);
       if (FromSize < ToSize ||
@@ -2880,7 +2904,7 @@ bool Sema::IsFloatingPointPromotion(QualType FromType, QualType ToType) {
 
       // Half can be promoted to float.
       if (!getLangOpts().NativeHalfType &&
-          FromBuiltin->getKind() == BuiltinType::Half &&
+           FromBuiltin->getKind() == BuiltinType::Half &&
           ToBuiltin->getKind() == BuiltinType::Float)
         return true;
     }
@@ -2899,8 +2923,8 @@ bool Sema::IsComplexPromotion(QualType FromType, QualType ToType) {
 
   return IsFloatingPointPromotion(FromComplex->getElementType(),
                                   ToComplex->getElementType()) ||
-         IsIntegralPromotion(nullptr, FromComplex->getElementType(),
-                             ToComplex->getElementType());
+    IsIntegralPromotion(nullptr, FromComplex->getElementType(),
+                        ToComplex->getElementType());
 }
 
 bool Sema::IsOverflowBehaviorTypePromotion(QualType FromType, QualType ToType) {
@@ -2946,8 +2970,9 @@ bool Sema::IsOverflowBehaviorTypeConversion(QualType FromType,
 /// the right set of qualifiers on its pointee.
 ///
 static QualType
-BuildSimilarlyQualifiedPointerType(const Type *FromPtr, QualType ToPointee,
-                                   QualType ToType, ASTContext &Context,
+BuildSimilarlyQualifiedPointerType(const Type *FromPtr,
+                                   QualType ToPointee, QualType ToType,
+                                   ASTContext &Context,
                                    bool StripObjCLifetime = false) {
   assert((FromPtr->getTypeClass() == Type::Pointer ||
           FromPtr->getTypeClass() == Type::ObjCObjectPointer) &&
@@ -2957,8 +2982,8 @@ BuildSimilarlyQualifiedPointerType(const Type *FromPtr, QualType ToPointee,
   if (ToType->isObjCIdType() || ToType->isObjCQualifiedIdType())
     return ToType.getUnqualifiedType();
 
-  QualType CanonFromPointee =
-      Context.getCanonicalType(FromPtr->getPointeeType());
+  QualType CanonFromPointee
+    = Context.getCanonicalType(FromPtr->getPointeeType());
   QualType CanonToPointee = Context.getCanonicalType(ToPointee);
   Qualifiers Quals = CanonFromPointee.getQualifiers();
 
@@ -2979,8 +3004,8 @@ BuildSimilarlyQualifiedPointerType(const Type *FromPtr, QualType ToPointee,
   }
 
   // Just build a canonical type that has the right qualifiers.
-  QualType QualifiedCanonToPointee =
-      Context.getQualifiedType(CanonToPointee.getLocalUnqualifiedType(), Quals);
+  QualType QualifiedCanonToPointee
+    = Context.getQualifiedType(CanonToPointee.getLocalUnqualifiedType(), Quals);
 
   if (isa<ObjCObjectPointerType>(ToType))
     return Context.getObjCObjectPointerType(QualifiedCanonToPointee);
@@ -2996,14 +3021,14 @@ static bool isNullPointerConstantForConversion(Expr *Expr,
       Expr->getType()->isIntegerType() && !Expr->getType()->isEnumeralType())
     return !InOverloadResolution;
 
-  return Expr->isNullPointerConstant(
-      Context, InOverloadResolution ? Expr::NPC_ValueDependentIsNotNull
-                                    : Expr::NPC_ValueDependentIsNull);
+  return Expr->isNullPointerConstant(Context,
+                    InOverloadResolution? Expr::NPC_ValueDependentIsNotNull
+                                        : Expr::NPC_ValueDependentIsNull);
 }
 
 bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
                                bool InOverloadResolution,
-                               QualType &ConvertedType,
+                               QualType& ConvertedType,
                                bool &IncompatibleObjC) {
   IncompatibleObjC = false;
   if (isObjCPointerConversion(FromType, ToType, ConvertedType,
@@ -3039,7 +3064,7 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
     return true;
   }
 
-  const PointerType *ToTypePtr = ToType->getAs<PointerType>();
+  const PointerType* ToTypePtr = ToType->getAs<PointerType>();
   if (!ToTypePtr)
     return false;
 
@@ -3075,17 +3100,19 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
   // 4.10p2).
   if (FromPointeeType->isIncompleteOrObjectType() &&
       ToPointeeType->isVoidType()) {
-    ConvertedType = BuildSimilarlyQualifiedPointerType(
-        FromTypePtr, ToPointeeType, ToType, Context,
-        /*StripObjCLifetime=*/true);
+    ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
+                                                       ToPointeeType,
+                                                       ToType, Context,
+                                                   /*StripObjCLifetime=*/true);
     return true;
   }
 
   // MSVC allows implicit function to void* type conversion.
   if (getLangOpts().MSVCCompat && FromPointeeType->isFunctionType() &&
       ToPointeeType->isVoidType()) {
-    ConvertedType = BuildSimilarlyQualifiedPointerType(
-        FromTypePtr, ToPointeeType, ToType, Context);
+    ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
+                                                       ToPointeeType,
+                                                       ToType, Context);
     return true;
   }
 
@@ -3093,8 +3120,9 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
   // conversion for compatible-but-not-identical pointee types.
   if (!getLangOpts().CPlusPlus &&
       Context.typesAreCompatible(FromPointeeType, ToPointeeType)) {
-    ConvertedType = BuildSimilarlyQualifiedPointerType(
-        FromTypePtr, ToPointeeType, ToType, Context);
+    ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
+                                                       ToPointeeType,
+                                                       ToType, Context);
     return true;
   }
 
@@ -3115,15 +3143,17 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
       ToPointeeType->isRecordType() &&
       !Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType) &&
       IsDerivedFrom(From->getBeginLoc(), FromPointeeType, ToPointeeType)) {
-    ConvertedType = BuildSimilarlyQualifiedPointerType(
-        FromTypePtr, ToPointeeType, ToType, Context);
+    ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
+                                                       ToPointeeType,
+                                                       ToType, Context);
     return true;
   }
 
   if (FromPointeeType->isVectorType() && ToPointeeType->isVectorType() &&
       Context.areCompatibleVectorTypes(FromPointeeType, ToPointeeType)) {
-    ConvertedType = BuildSimilarlyQualifiedPointerType(
-        FromTypePtr, ToPointeeType, ToType, Context);
+    ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
+                                                       ToPointeeType,
+                                                       ToType, Context);
     return true;
   }
 
@@ -3131,8 +3161,7 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
 }
 
 /// Adopt the given qualifiers for the given type.
-static QualType AdoptQualifiers(ASTContext &Context, QualType T,
-                                Qualifiers Qs) {
+static QualType AdoptQualifiers(ASTContext &Context, QualType T, Qualifiers Qs){
   Qualifiers TQs = T.getQualifiers();
 
   // Check whether qualifiers already match.
@@ -3146,7 +3175,7 @@ static QualType AdoptQualifiers(ASTContext &Context, QualType T,
 }
 
 bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
-                                   QualType &ConvertedType,
+                                   QualType& ConvertedType,
                                    bool &IncompatibleObjC) {
   if (!getLangOpts().ObjC)
     return false;
@@ -3155,10 +3184,10 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
   Qualifiers FromQualifiers = FromType.getQualifiers();
 
   // First, we handle all conversions on ObjC object pointer types.
-  const ObjCObjectPointerType *ToObjCPtr =
-      ToType->getAs<ObjCObjectPointerType>();
+  const ObjCObjectPointerType* ToObjCPtr =
+    ToType->getAs<ObjCObjectPointerType>();
   const ObjCObjectPointerType *FromObjCPtr =
-      FromType->getAs<ObjCObjectPointerType>();
+    FromType->getAs<ObjCObjectPointerType>();
 
   if (ToObjCPtr && FromObjCPtr) {
     // If the pointee types are the same (ignoring qualifications),
@@ -3169,14 +3198,15 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
 
     // Conversion between Objective-C pointers.
     if (Context.canAssignObjCInterfaces(ToObjCPtr, FromObjCPtr)) {
-      const ObjCInterfaceType *LHS = ToObjCPtr->getInterfaceType();
-      const ObjCInterfaceType *RHS = FromObjCPtr->getInterfaceType();
+      const ObjCInterfaceType* LHS = ToObjCPtr->getInterfaceType();
+      const ObjCInterfaceType* RHS = FromObjCPtr->getInterfaceType();
       if (getLangOpts().CPlusPlus && LHS && RHS &&
           !ToObjCPtr->getPointeeType().isAtLeastAsQualifiedAs(
               FromObjCPtr->getPointeeType(), getASTContext()))
         return false;
-      ConvertedType = BuildSimilarlyQualifiedPointerType(
-          FromObjCPtr, ToObjCPtr->getPointeeType(), ToType, Context);
+      ConvertedType = BuildSimilarlyQualifiedPointerType(FromObjCPtr,
+                                                   ToObjCPtr->getPointeeType(),
+                                                         ToType, Context);
       ConvertedType = AdoptQualifiers(Context, ConvertedType, FromQualifiers);
       return true;
     }
@@ -3186,8 +3216,9 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
       // interfaces, which is permitted. However, we're going to
       // complain about it.
       IncompatibleObjC = true;
-      ConvertedType = BuildSimilarlyQualifiedPointerType(
-          FromObjCPtr, ToObjCPtr->getPointeeType(), ToType, Context);
+      ConvertedType = BuildSimilarlyQualifiedPointerType(FromObjCPtr,
+                                                   ToObjCPtr->getPointeeType(),
+                                                         ToType, Context);
       ConvertedType = AdoptQualifiers(Context, ConvertedType, FromQualifiers);
       return true;
     }
@@ -3197,7 +3228,7 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
   if (const PointerType *ToCPtr = ToType->getAs<PointerType>())
     ToPointeeType = ToCPtr->getPointeeType();
   else if (const BlockPointerType *ToBlockPtr =
-               ToType->getAs<BlockPointerType>()) {
+            ToType->getAs<BlockPointerType>()) {
     // Objective C++: We're able to convert from a pointer to any object
     // to a block pointer type.
     if (FromObjCPtr && FromObjCPtr->isObjCBuiltinType()) {
@@ -3205,20 +3236,22 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
       return true;
     }
     ToPointeeType = ToBlockPtr->getPointeeType();
-  } else if (FromType->getAs<BlockPointerType>() && ToObjCPtr &&
-             ToObjCPtr->isObjCBuiltinType()) {
+  }
+  else if (FromType->getAs<BlockPointerType>() &&
+           ToObjCPtr && ToObjCPtr->isObjCBuiltinType()) {
     // Objective C++: We're able to convert from a block pointer type to a
     // pointer to any object.
     ConvertedType = AdoptQualifiers(Context, ToType, FromQualifiers);
     return true;
-  } else
+  }
+  else
     return false;
 
   QualType FromPointeeType;
   if (const PointerType *FromCPtr = FromType->getAs<PointerType>())
     FromPointeeType = FromCPtr->getPointeeType();
   else if (const BlockPointerType *FromBlockPtr =
-               FromType->getAs<BlockPointerType>())
+           FromType->getAs<BlockPointerType>())
     FromPointeeType = FromBlockPtr->getPointeeType();
   else
     return false;
@@ -3250,15 +3283,15 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
   // differences in the argument and result types are in Objective-C
   // pointer conversions. If so, we permit the conversion (but
   // complain about it).
-  const FunctionProtoType *FromFunctionType =
-      FromPointeeType->getAs<FunctionProtoType>();
-  const FunctionProtoType *ToFunctionType =
-      ToPointeeType->getAs<FunctionProtoType>();
+  const FunctionProtoType *FromFunctionType
+    = FromPointeeType->getAs<FunctionProtoType>();
+  const FunctionProtoType *ToFunctionType
+    = ToPointeeType->getAs<FunctionProtoType>();
   if (FromFunctionType && ToFunctionType) {
     // If the function types are exactly the same, this isn't an
     // Objective-C pointer conversion.
-    if (Context.getCanonicalType(FromPointeeType) ==
-        Context.getCanonicalType(ToPointeeType))
+    if (Context.getCanonicalType(FromPointeeType)
+          == Context.getCanonicalType(ToPointeeType))
       return false;
 
     // Perform the quick checks that will tell us whether these
@@ -3287,11 +3320,11 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
          ArgIdx != NumArgs; ++ArgIdx) {
       QualType FromArgType = FromFunctionType->getParamType(ArgIdx);
       QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
-      if (Context.getCanonicalType(FromArgType) ==
-          Context.getCanonicalType(ToArgType)) {
+      if (Context.getCanonicalType(FromArgType)
+            == Context.getCanonicalType(ToArgType)) {
         // Okay, the types match exactly. Nothing to do.
-      } else if (isObjCPointerConversion(FromArgType, ToArgType, ConvertedType,
-                                         IncompatibleObjC)) {
+      } else if (isObjCPointerConversion(FromArgType, ToArgType,
+                                         ConvertedType, IncompatibleObjC)) {
         // Okay, we have an Objective-C pointer conversion.
         HasObjCConversion = true;
       } else {
@@ -3313,16 +3346,17 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
 }
 
 bool Sema::IsBlockPointerConversion(QualType FromType, QualType ToType,
-                                    QualType &ConvertedType) {
+                                    QualType& ConvertedType) {
   QualType ToPointeeType;
-  if (const BlockPointerType *ToBlockPtr = ToType->getAs<BlockPointerType>())
+  if (const BlockPointerType *ToBlockPtr =
+        ToType->getAs<BlockPointerType>())
     ToPointeeType = ToBlockPtr->getPointeeType();
   else
     return false;
 
   QualType FromPointeeType;
   if (const BlockPointerType *FromBlockPtr =
-          FromType->getAs<BlockPointerType>())
+      FromType->getAs<BlockPointerType>())
     FromPointeeType = FromBlockPtr->getPointeeType();
   else
     return false;
@@ -3330,10 +3364,10 @@ bool Sema::IsBlockPointerConversion(QualType FromType, QualType ToType,
   // differences in the argument and result types are in Objective-C
   // pointer conversions. If so, we permit the conversion.
 
-  const FunctionProtoType *FromFunctionType =
-      FromPointeeType->getAs<FunctionProtoType>();
-  const FunctionProtoType *ToFunctionType =
-      ToPointeeType->getAs<FunctionProtoType>();
+  const FunctionProtoType *FromFunctionType
+    = FromPointeeType->getAs<FunctionProtoType>();
+  const FunctionProtoType *ToFunctionType
+    = ToPointeeType->getAs<FunctionProtoType>();
 
   if (!FromFunctionType || !ToFunctionType)
     return false;
@@ -3361,45 +3395,47 @@ bool Sema::IsBlockPointerConversion(QualType FromType, QualType ToType,
     QualType LHS = ToFunctionType->getReturnType();
     if ((!getLangOpts().CPlusPlus || !RHS->isRecordType()) &&
         !RHS.hasQualifiers() && LHS.hasQualifiers())
-      LHS = LHS.getUnqualifiedType();
-
-    if (Context.hasSameType(RHS, LHS)) {
-      // OK exact match.
-    } else if (isObjCPointerConversion(RHS, LHS, ConvertedType,
-                                       IncompatibleObjC)) {
-      if (IncompatibleObjC)
-        return false;
-      // Okay, we have an Objective-C pointer conversion.
-    } else
-      return false;
-  }
-
-  // Check argument types.
-  for (unsigned ArgIdx = 0, NumArgs = FromFunctionType->getNumParams();
-       ArgIdx != NumArgs; ++ArgIdx) {
-    IncompatibleObjC = false;
-    QualType FromArgType = FromFunctionType->getParamType(ArgIdx);
-    QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
-    if (Context.hasSameType(FromArgType, ToArgType)) {
-      // Okay, the types match exactly. Nothing to do.
-    } else if (isObjCPointerConversion(ToArgType, FromArgType, ConvertedType,
-                                       IncompatibleObjC)) {
-      if (IncompatibleObjC)
-        return false;
-      // Okay, we have an Objective-C pointer conversion.
-    } else
-      // Argument types are too different. Abort.
-      return false;
-  }
-
-  SmallVector<FunctionProtoType::ExtParameterInfo, 4> NewParamInfos;
-  bool CanUseToFPT, CanUseFromFPT;
-  if (!Context.mergeExtParameterInfo(ToFunctionType, FromFunctionType,
-                                     CanUseToFPT, CanUseFromFPT, NewParamInfos))
-    return false;
-
-  ConvertedType = ToType;
-  return true;
+       LHS = LHS.getUnqualifiedType();
+
+     if (Context.hasSameType(RHS,LHS)) {
+       // OK exact match.
+     } else if (isObjCPointerConversion(RHS, LHS,
+                                        ConvertedType, IncompatibleObjC)) {
+     if (IncompatibleObjC)
+       return false;
+     // Okay, we have an Objective-C pointer conversion.
+     }
+     else
+       return false;
+   }
+
+   // Check argument types.
+   for (unsigned ArgIdx = 0, NumArgs = FromFunctionType->getNumParams();
+        ArgIdx != NumArgs; ++ArgIdx) {
+     IncompatibleObjC = false;
+     QualType FromArgType = FromFunctionType->getParamType(ArgIdx);
+     QualType ToArgType = ToFunctionType->getParamType(ArgIdx);
+     if (Context.hasSameType(FromArgType, ToArgType)) {
+       // Okay, the types match exactly. Nothing to do.
+     } else if (isObjCPointerConversion(ToArgType, FromArgType,
+                                        ConvertedType, IncompatibleObjC)) {
+       if (IncompatibleObjC)
+         return false;
+       // Okay, we have an Objective-C pointer conversion.
+     } else
+       // Argument types are too different. Abort.
+       return false;
+   }
+
+   SmallVector<FunctionProtoType::ExtParameterInfo, 4> NewParamInfos;
+   bool CanUseToFPT, CanUseFromFPT;
+   if (!Context.mergeExtParameterInfo(ToFunctionType, FromFunctionType,
+                                      CanUseToFPT, CanUseFromFPT,
+                                      NewParamInfos))
+     return false;
+
+   ConvertedType = ToType;
+   return true;
 }
 
 enum {
@@ -3585,8 +3621,10 @@ bool Sema::FunctionNonObjectParamTypesAreEqual(const FunctionDecl *OldFunction,
                                     ArgPos, Reversed);
 }
 
-bool Sema::CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind,
-                                  CXXCastPath &BasePath, bool IgnoreBaseAccess,
+bool Sema::CheckPointerConversion(Expr *From, QualType ToType,
+                                  CastKind &Kind,
+                                  CXXCastPath& BasePath,
+                                  bool IgnoreBaseAccess,
                                   bool Diagnose) {
   QualType FromType = From->getType();
   bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;
@@ -3599,15 +3637,15 @@ bool Sema::CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind,
     if (Context.hasSameUnqualifiedType(From->getType(), Context.BoolTy))
       DiagRuntimeBehavior(From->getExprLoc(), From,
                           PDiag(diag::warn_impcast_bool_to_null_pointer)
-                              << ToType << From->getSourceRange());
+                            << ToType << From->getSourceRange());
     else if (!isUnevaluatedContext())
       Diag(From->getExprLoc(), diag::warn_non_literal_null_pointer)
-          << ToType << From->getSourceRange();
+        << ToType << From->getSourceRange();
   }
   if (const PointerType *ToPtrType = ToType->getAs<PointerType>()) {
     if (const PointerType *FromPtrType = FromType->getAs<PointerType>()) {
       QualType FromPointeeType = FromPtrType->getPointeeType(),
-               ToPointeeType = ToPtrType->getPointeeType();
+               ToPointeeType   = ToPtrType->getPointeeType();
 
       if (FromPointeeType->isRecordType() && ToPointeeType->isRecordType() &&
           !Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType)) {
@@ -3638,9 +3676,9 @@ bool Sema::CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind,
       }
     }
   } else if (const ObjCObjectPointerType *ToPtrType =
-                 ToType->getAs<ObjCObjectPointerType>()) {
+               ToType->getAs<ObjCObjectPointerType>()) {
     if (const ObjCObjectPointerType *FromPtrType =
-            FromType->getAs<ObjCObjectPointerType>()) {
+          FromType->getAs<ObjCObjectPointerType>()) {
       // Objective-C++ conversions are always okay.
       // FIXME: We should have a different class of conversions for the
       // Objective-C++ implicit conversions.
@@ -3665,15 +3703,16 @@ bool Sema::CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind,
 }
 
 bool Sema::IsMemberPointerConversion(Expr *From, QualType FromType,
-                                     QualType ToType, bool InOverloadResolution,
+                                     QualType ToType,
+                                     bool InOverloadResolution,
                                      QualType &ConvertedType) {
   const MemberPointerType *ToTypePtr = ToType->getAs<MemberPointerType>();
   if (!ToTypePtr)
     return false;
 
   // A null pointer constant can be converted to a member pointer (C++ 4.11p1)
-  if (From->isNullPointerConstant(
-          Context, InOverloadResolution ? Expr::NPC_ValueDependentIsNotNull
+  if (From->isNullPointerConstant(Context,
+                    InOverloadResolution? Expr::NPC_ValueDependentIsNotNull
                                         : Expr::NPC_ValueDependentIsNull)) {
     ConvertedType = ToType;
     return true;
@@ -3894,9 +3933,9 @@ static bool isQualificationConversionStep(QualType FromType, QualType ToType,
   return true;
 }
 
-bool Sema::IsQualificationConversion(QualType FromType, QualType ToType,
-                                     bool CStyle,
-                                     bool &ObjCLifetimeConversion) {
+bool
+Sema::IsQualificationConversion(QualType FromType, QualType ToType,
+                                bool CStyle, bool &ObjCLifetimeConversion) {
   FromType = Context.getCanonicalType(FromType);
   ToType = Context.getCanonicalType(ToType);
   ObjCLifetimeConversion = false;
@@ -3925,8 +3964,7 @@ bool Sema::IsQualificationConversion(QualType FromType, QualType ToType,
   // of times. If we unwrapped any pointers, and if FromType and
   // ToType have the same unqualified type (since we checked
   // qualifiers above), then this is a qualification conversion.
-  return UnwrappedAnyPointer &&
-         Context.hasSameUnqualifiedType(FromType, ToType);
+  return UnwrappedAnyPointer && Context.hasSameUnqualifiedType(FromType,ToType);
 }
 
 /// - Determine whether this is a conversion from a scalar type to an
@@ -3936,22 +3974,23 @@ bool Sema::IsQualificationConversion(QualType FromType, QualType ToType,
 /// sequence to finish the conversion.
 static bool tryAtomicConversion(Sema &S, Expr *From, QualType ToType,
                                 bool InOverloadResolution,
-                                StandardConversionSequence &SCS, bool CStyle) {
+                                StandardConversionSequence &SCS,
+                                bool CStyle) {
   const AtomicType *ToAtomic = ToType->getAs<AtomicType>();
   if (!ToAtomic)
     return false;
 
   StandardConversionSequence InnerSCS;
   if (!IsStandardConversion(S, From, ToAtomic->getValueType(),
-                            InOverloadResolution, InnerSCS, CStyle,
-                            /*AllowObjCWritebackConversion=*/false))
+                            InOverloadResolution, InnerSCS,
+                            CStyle, /*AllowObjCWritebackConversion=*/false))
     return false;
 
   SCS.Second = InnerSCS.Second;
   SCS.setToType(1, InnerSCS.getToType(1));
   SCS.Third = InnerSCS.Third;
-  SCS.QualificationIncludesObjCLifetime =
-      InnerSCS.QualificationIncludesObjCLifetime;
+  SCS.QualificationIncludesObjCLifetime
+    = InnerSCS.QualificationIncludesObjCLifetime;
   SCS.setToType(2, InnerSCS.getToType(2));
   return true;
 }
@@ -3997,10 +4036,12 @@ static bool isFirstArgumentCompatibleWithType(ASTContext &Context,
   return false;
 }
 
-static OverloadingResult IsInitializerListConstructorConversion(
-    Sema &S, Expr *From, QualType ToType, CXXRecordDecl *To,
-    UserDefinedConversionSequence &User, OverloadCandidateSet &CandidateSet,
-    bool AllowExplicit) {
+static OverloadingResult
+IsInitializerListConstructorConversion(Sema &S, Expr *From, QualType ToType,
+                                       CXXRecordDecl *To,
+                                       UserDefinedConversionSequence &User,
+                                       OverloadCandidateSet &CandidateSet,
+                                       bool AllowExplicit) {
   CandidateSet.clear(OverloadCandidateSet::CSK_InitByUserDefinedConversion);
   for (auto *D : S.LookupConstructors(To)) {
     auto Info = getConstructorInfo(D);
@@ -4068,10 +4109,12 @@ static OverloadingResult IsInitializerListConstructorConversion(
 /// \param AllowObjCConversionOnExplicit true if the conversion should
 /// allow an extra Objective-C pointer conversion on uses of explicit
 /// constructors. Requires \c AllowExplicit to also be set.
-static OverloadingResult IsUserDefinedConversion(
-    Sema &S, Expr *From, QualType ToType, UserDefinedConversionSequence &User,
-    OverloadCandidateSet &CandidateSet, AllowedExplicit AllowExplicit,
-    bool AllowObjCConversionOnExplicit) {
+static OverloadingResult
+IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
+                        UserDefinedConversionSequence &User,
+                        OverloadCandidateSet &CandidateSet,
+                        AllowedExplicit AllowExplicit,
+                        bool AllowObjCConversionOnExplicit) {
   assert(AllowExplicit != AllowedExplicit::None ||
          !AllowObjCConversionOnExplicit);
   CandidateSet.clear(OverloadCandidateSet::CSK_InitByUserDefinedConversion);
@@ -4212,8 +4255,8 @@ static OverloadingResult IsUserDefinedConversion(
   case OR_Success:
   case OR_Deleted:
     // Record the standard conversion we used and the conversion function.
-    if (CXXConstructorDecl *Constructor =
-            dyn_cast<CXXConstructorDecl>(Best->Function)) {
+    if (CXXConstructorDecl *Constructor
+          = dyn_cast<CXXConstructorDecl>(Best->Function)) {
       // C++ [over.ics.user]p1:
       //   If the user-defined conversion is specified by a
       //   constructor (12.3.1), the initial standard conversion
@@ -4240,8 +4283,8 @@ static OverloadingResult IsUserDefinedConversion(
       User.After.setAllToTypes(ToType);
       return Result;
     }
-    if (CXXConversionDecl *Conversion =
-            dyn_cast<CXXConversionDecl>(Best->Function)) {
+    if (CXXConversionDecl *Conversion
+                 = dyn_cast<CXXConversionDecl>(Best->Function)) {
 
       assert(Best->HasFinalConversion);
 
@@ -4281,13 +4324,14 @@ static OverloadingResult IsUserDefinedConversion(
   llvm_unreachable("Invalid OverloadResult!");
 }
 
-bool Sema::DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType) {
+bool
+Sema::DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType) {
   ImplicitConversionSequence ICS;
   OverloadCandidateSet CandidateSet(From->getExprLoc(),
                                     OverloadCandidateSet::CSK_Normal);
   OverloadingResult OvResult =
-      IsUserDefinedConversion(*this, From, ToType, ICS.UserDefined,
-                              CandidateSet, AllowedExplicit::None, false);
+    IsUserDefinedConversion(*this, From, ToType, ICS.UserDefined,
+                            CandidateSet, AllowedExplicit::None, false);
 
   if (!(OvResult == OR_Ambiguous ||
         (OvResult == OR_No_Viable_Function && !CandidateSet.empty())))
@@ -4308,7 +4352,8 @@ bool Sema::DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType) {
           << false << From->getType() << From->getSourceRange() << ToType;
   }
 
-  CandidateSet.NoteCandidates(*this, From, Cands);
+  CandidateSet.NoteCandidates(
+                              *this, From, Cands);
   return true;
 }
 
@@ -4401,8 +4446,9 @@ static bool hasDeprecatedStringLiteralToCharPtrConversion(
 /// other or if they are indistinguishable (C++ 13.3.3.2).
 static ImplicitConversionSequence::CompareKind
 CompareImplicitConversionSequences(Sema &S, SourceLocation Loc,
-                                   const ImplicitConversionSequence &ICS1,
-                                   const ImplicitConversionSequence &ICS2) {
+                                   const ImplicitConversionSequence& ICS1,
+                                   const ImplicitConversionSequence& ICS2)
+{
   // (C++ 13.3.3.2p2): When comparing the basic forms of implicit
   // conversion sequences (as defined in 13.3.3.1)
   //   -- a standard conversion sequence (13.3.3.1.1) is a better
@@ -4510,8 +4556,8 @@ CompareImplicitConversionSequences(Sema &S, SourceLocation Loc,
   if (ICS1.isStandard())
     // Standard conversion sequence S1 is a better conversion sequence than
     // standard conversion sequence S2 if [...]
-    Result = CompareStandardConversionSequences(S, Loc, ICS1.Standard,
-                                                ICS2.Standard);
+    Result = CompareStandardConversionSequences(S, Loc,
+                                                ICS1.Standard, ICS2.Standard);
   else if (ICS1.isUserDefined()) {
     // With lazy template loading, it is possible to find non-canonical
     // FunctionDecls, depending on when redecl chains are completed. Make sure
@@ -4530,12 +4576,13 @@ CompareImplicitConversionSequences(Sema &S, SourceLocation Loc,
     // U1 is better than the second standard conversion sequence of
     // U2 (C++ 13.3.3.2p3).
     if (ConvFunc1 == ConvFunc2)
-      Result = CompareStandardConversionSequences(
-          S, Loc, ICS1.UserDefined.After, ICS2.UserDefined.After);
+      Result = CompareStandardConversionSequences(S, Loc,
+                                                  ICS1.UserDefined.After,
+                                                  ICS2.UserDefined.After);
     else
-      Result =
-          compareConversionFunctions(S, ICS1.UserDefined.ConversionFunction,
-                                     ICS2.UserDefined.ConversionFunction);
+      Result = compareConversionFunctions(S,
+                                          ICS1.UserDefined.ConversionFunction,
+                                          ICS2.UserDefined.ConversionFunction);
   }
 
   return Result;
@@ -4545,10 +4592,10 @@ CompareImplicitConversionSequences(Sema &S, SourceLocation Loc,
 // determine if one is a proper subset of the other.
 static ImplicitConversionSequence::CompareKind
 compareStandardConversionSubsets(ASTContext &Context,
-                                 const StandardConversionSequence &SCS1,
-                                 const StandardConversionSequence &SCS2) {
-  ImplicitConversionSequence::CompareKind Result =
-      ImplicitConversionSequence::Indistinguishable;
+                                 const StandardConversionSequence& SCS1,
+                                 const StandardConversionSequence& SCS2) {
+  ImplicitConversionSequence::CompareKind Result
+    = ImplicitConversionSequence::Indistinguishable;
 
   // the identity conversion sequence is considered to be a subsequence of
   // any non-identity conversion sequence
@@ -4568,20 +4615,19 @@ compareStandardConversionSubsets(ASTContext &Context,
     return ImplicitConversionSequence::Indistinguishable;
 
   if (SCS1.Third == SCS2.Third) {
-    return Context.hasSameType(SCS1.getToType(2), SCS2.getToType(2))
-               ? Result
-               : ImplicitConversionSequence::Indistinguishable;
+    return Context.hasSameType(SCS1.getToType(2), SCS2.getToType(2))? Result
+                             : ImplicitConversionSequence::Indistinguishable;
   }
 
   if (SCS1.Third == ICK_Identity)
     return Result == ImplicitConversionSequence::Worse
-               ? ImplicitConversionSequence::Indistinguishable
-               : ImplicitConversionSequence::Better;
+             ? ImplicitConversionSequence::Indistinguishable
+             : ImplicitConversionSequence::Better;
 
   if (SCS2.Third == ICK_Identity)
     return Result == ImplicitConversionSequence::Better
-               ? ImplicitConversionSequence::Indistinguishable
-               : ImplicitConversionSequence::Worse;
+             ? ImplicitConversionSequence::Indistinguishable
+             : ImplicitConversionSequence::Worse;
 
   return ImplicitConversionSequence::Indistinguishable;
 }
@@ -4646,8 +4692,9 @@ getFixedEnumPromtion(Sema &S, const StandardConversionSequence &SCS) {
 /// other or if they are indistinguishable (C++ 13.3.3.2p3).
 static ImplicitConversionSequence::CompareKind
 CompareStandardConversionSequences(Sema &S, SourceLocation Loc,
-                                   const StandardConversionSequence &SCS1,
-                                   const StandardConversionSequence &SCS2) {
+                                   const StandardConversionSequence& SCS1,
+                                   const StandardConversionSequence& SCS2)
+{
   // Standard conversion sequence S1 is a better conversion sequence
   // than standard conversion sequence S2 if (C++ 13.3.3.2p3):
 
@@ -4656,8 +4703,8 @@ CompareStandardConversionSequences(Sema &S, SourceLocation Loc,
   //     excluding any Lvalue Transformation; the identity conversion
   //     sequence is considered to be a subsequence of any
   //     non-identity conversion sequence) or, if not that,
-  if (ImplicitConversionSequence::CompareKind CK =
-          compareStandardConversionSubsets(S.Context, SCS1, SCS2))
+  if (ImplicitConversionSequence::CompareKind CK
+        = compareStandardConversionSubsets(S.Context, SCS1, SCS2))
     return CK;
 
   //  -- the rank of S1 is better than the rank of S2 (by the rules
@@ -4677,8 +4724,9 @@ CompareStandardConversionSequences(Sema &S, SourceLocation Loc,
   //   pointer to member, to bool is better than another conversion
   //   that is such a conversion.
   if (SCS1.isPointerConversionToBool() != SCS2.isPointerConversionToBool())
-    return SCS2.isPointerConversionToBool() ? ImplicitConversionSequence::Better
-                                            : ImplicitConversionSequence::Worse;
+    return SCS2.isPointerConversionToBool()
+             ? ImplicitConversionSequence::Better
+             : ImplicitConversionSequence::Worse;
 
   // C++14 [over.ics.rank]p4b2:
   // This is retroactively applied to C++11 by CWG 1601.
@@ -4700,8 +4748,10 @@ CompareStandardConversionSequences(Sema &S, SourceLocation Loc,
   //   conversion of B* to A* is better than conversion of B* to
   //   void*, and conversion of A* to void* is better than conversion
   //   of B* to void*.
-  bool SCS1ConvertsToVoid = SCS1.isPointerConversionToVoidPointer(S.Context);
-  bool SCS2ConvertsToVoid = SCS2.isPointerConversionToVoidPointer(S.Context);
+  bool SCS1ConvertsToVoid
+    = SCS1.isPointerConversionToVoidPointer(S.Context);
+  bool SCS2ConvertsToVoid
+    = SCS2.isPointerConversionToVoidPointer(S.Context);
   if (SCS1ConvertsToVoid != SCS2ConvertsToVoid) {
     // Exactly one of the conversion sequences is a conversion to
     // a void pointer; it's the worse conversion.
@@ -4710,8 +4760,8 @@ CompareStandardConversionSequences(Sema &S, SourceLocation Loc,
   } else if (!SCS1ConvertsToVoid && !SCS2ConvertsToVoid) {
     // Neither conversion sequence converts to a void pointer; compare
     // their derived-to-base conversions.
-    if (ImplicitConversionSequence::CompareKind DerivedCK =
-            CompareDerivedToBaseConversions(S, Loc, SCS1, SCS2))
+    if (ImplicitConversionSequence::CompareKind DerivedCK
+          = CompareDerivedToBaseConversions(S, Loc, SCS1, SCS2))
       return DerivedCK;
   } else if (SCS1ConvertsToVoid && SCS2ConvertsToVoid &&
              !S.Context.hasSameType(SCS1.getFromType(), SCS2.getFromType())) {
@@ -4738,18 +4788,18 @@ CompareStandardConversionSequences(Sema &S, SourceLocation Loc,
 
     // Objective-C++: If one interface is more specific than the
     // other, it is the better one.
-    const ObjCObjectPointerType *FromObjCPtr1 =
-        FromType1->getAs<ObjCObjectPointerType>();
-    const ObjCObjectPointerType *FromObjCPtr2 =
-        FromType2->getAs<ObjCObjectPointerType>();
+    const ObjCObjectPointerType* FromObjCPtr1
+      = FromType1->getAs<ObjCObjectPointerType>();
+    const ObjCObjectPointerType* FromObjCPtr2
+      = FromType2->getAs<ObjCObjectPointerType>();
     if (FromObjCPtr1 && FromObjCPtr2) {
-      bool AssignLeft =
-          S.Context.canAssignObjCInterfaces(FromObjCPtr1, FromObjCPtr2);
-      bool AssignRight =
-          S.Context.canAssignObjCInterfaces(FromObjCPtr2, FromObjCPtr1);
+      bool AssignLeft = S.Context.canAssignObjCInterfaces(FromObjCPtr1,
+                                                          FromObjCPtr2);
+      bool AssignRight = S.Context.canAssignObjCInterfaces(FromObjCPtr2,
+                                                           FromObjCPtr1);
       if (AssignLeft != AssignRight) {
-        return AssignLeft ? ImplicitConversionSequence::Better
-                          : ImplicitConversionSequence::Worse;
+        return AssignLeft? ImplicitConversionSequence::Better
+                         : ImplicitConversionSequence::Worse;
       }
     }
   }
@@ -4764,8 +4814,8 @@ CompareStandardConversionSequences(Sema &S, SourceLocation Loc,
 
   // Compare based on qualification conversions (C++ 13.3.3.2p3,
   // bullet 3).
-  if (ImplicitConversionSequence::CompareKind QualCK =
-          CompareQualificationConversions(S, SCS1, SCS2))
+  if (ImplicitConversionSequence::CompareKind QualCK
+        = CompareQualificationConversions(S, SCS1, SCS2))
     return QualCK;
 
   if (ImplicitConversionSequence::CompareKind ObtCK =
@@ -4790,10 +4840,10 @@ CompareStandardConversionSequences(Sema &S, SourceLocation Loc,
       // Objective-C++ ARC: If the references refer to objects with different
       // lifetimes, prefer bindings that don't change lifetime.
       if (SCS1.ObjCLifetimeConversionBinding !=
-          SCS2.ObjCLifetimeConversionBinding) {
+                                          SCS2.ObjCLifetimeConversionBinding) {
         return SCS1.ObjCLifetimeConversionBinding
-                   ? ImplicitConversionSequence::Worse
-                   : ImplicitConversionSequence::Better;
+                                           ? ImplicitConversionSequence::Worse
+                                           : ImplicitConversionSequence::Better;
       }
 
       // If the type is an array type, promote the element qualifiers to the
@@ -4907,8 +4957,9 @@ CompareOverflowBehaviorConversions(Sema &S,
 /// sequences to determine whether they can be ranked based on their
 /// qualification conversions (C++ 13.3.3.2p3 bullet 3).
 static ImplicitConversionSequence::CompareKind
-CompareQualificationConversions(Sema &S, const StandardConversionSequence &SCS1,
-                                const StandardConversionSequence &SCS2) {
+CompareQualificationConversions(Sema &S,
+                                const StandardConversionSequence& SCS1,
+                                const StandardConversionSequence& SCS2) {
   // C++ [over.ics.rank]p3:
   //  -- S1 and S2 differ only in their qualification conversion and
   //     yield similar types T1 and T2 (C++ 4.4), respectively, [...]
@@ -4976,8 +5027,8 @@ CompareQualificationConversions(Sema &S, const StandardConversionSequence &SCS1,
 /// conversions between Objective-C interface types.
 static ImplicitConversionSequence::CompareKind
 CompareDerivedToBaseConversions(Sema &S, SourceLocation Loc,
-                                const StandardConversionSequence &SCS1,
-                                const StandardConversionSequence &SCS2) {
+                                const StandardConversionSequence& SCS1,
+                                const StandardConversionSequence& SCS2) {
   QualType FromType1 = SCS1.getFromType();
   QualType ToType1 = SCS1.getToType(1);
   QualType FromType2 = SCS2.getFromType();
@@ -5033,26 +5084,28 @@ CompareDerivedToBaseConversions(Sema &S, SourceLocation Loc,
     }
   } else if (SCS1.Second == ICK_Pointer_Conversion &&
              SCS2.Second == ICK_Pointer_Conversion) {
-    const ObjCObjectPointerType *FromPtr1 =
-        FromType1->getAs<ObjCObjectPointerType>();
-    const ObjCObjectPointerType *FromPtr2 =
-        FromType2->getAs<ObjCObjectPointerType>();
-    const ObjCObjectPointerType *ToPtr1 =
-        ToType1->getAs<ObjCObjectPointerType>();
-    const ObjCObjectPointerType *ToPtr2 =
-        ToType2->getAs<ObjCObjectPointerType>();
+    const ObjCObjectPointerType *FromPtr1
+      = FromType1->getAs<ObjCObjectPointerType>();
+    const ObjCObjectPointerType *FromPtr2
+      = FromType2->getAs<ObjCObjectPointerType>();
+    const ObjCObjectPointerType *ToPtr1
+      = ToType1->getAs<ObjCObjectPointerType>();
+    const ObjCObjectPointerType *ToPtr2
+      = ToType2->getAs<ObjCObjectPointerType>();
 
     if (FromPtr1 && FromPtr2 && ToPtr1 && ToPtr2) {
       // Apply the same conversion ranking rules for Objective-C pointer types
       // that we do for C++ pointers to class types. However, we employ the
       // Objective-C pseudo-subtyping relationship used for assignment of
       // Objective-C pointer types.
-      bool FromAssignLeft =
-          S.Context.canAssignObjCInterfaces(FromPtr1, FromPtr2);
-      bool FromAssignRight =
-          S.Context.canAssignObjCInterfaces(FromPtr2, FromPtr1);
-      bool ToAssignLeft = S.Context.canAssignObjCInterfaces(ToPtr1, ToPtr2);
-      bool ToAssignRight = S.Context.canAssignObjCInterfaces(ToPtr2, ToPtr1);
+      bool FromAssignLeft
+        = S.Context.canAssignObjCInterfaces(FromPtr1, FromPtr2);
+      bool FromAssignRight
+        = S.Context.canAssignObjCInterfaces(FromPtr2, FromPtr1);
+      bool ToAssignLeft
+        = S.Context.canAssignObjCInterfaces(ToPtr1, ToPtr2);
+      bool ToAssignRight
+        = S.Context.canAssignObjCInterfaces(ToPtr2, ToPtr1);
 
       // A conversion to an a non-id object pointer type or qualified 'id'
       // type is better than a conversion to 'id'.
@@ -5103,15 +5156,15 @@ CompareDerivedToBaseConversions(Sema &S, SourceLocation Loc,
           } else if (IsSecondSame)
             return ImplicitConversionSequence::Worse;
         }
-        return ToAssignLeft ? ImplicitConversionSequence::Worse
-                            : ImplicitConversionSequence::Better;
+        return ToAssignLeft? ImplicitConversionSequence::Worse
+                           : ImplicitConversionSequence::Better;
       }
 
       //   -- "conversion of B* to A* is better than conversion of C* to A*,"
       if (S.Context.hasSameUnqualifiedType(ToType1, ToType2) &&
           (FromAssignLeft != FromAssignRight))
-        return FromAssignLeft ? ImplicitConversionSequence::Better
-                              : ImplicitConversionSequence::Worse;
+        return FromAssignLeft? ImplicitConversionSequence::Better
+        : ImplicitConversionSequence::Worse;
     }
   }
 
@@ -5183,11 +5236,11 @@ static QualType withoutUnaligned(ASTContext &Ctx, QualType T) {
 }
 
 Sema::ReferenceCompareResult
-Sema::CompareReferenceRelationship(SourceLocation Loc, QualType OrigT1,
-                                   QualType OrigT2,
+Sema::CompareReferenceRelationship(SourceLocation Loc,
+                                   QualType OrigT1, QualType OrigT2,
                                    ReferenceConversions *ConvOut) {
   assert(!OrigT1->isReferenceType() &&
-         "T1 must be the pointee type of the reference type");
+    "T1 must be the pointee type of the reference type");
   assert(!OrigT2->isReferenceType() && "T2 cannot be a reference type");
 
   QualType T1 = Context.getCanonicalType(OrigT1);
@@ -5276,10 +5329,11 @@ Sema::CompareReferenceRelationship(SourceLocation Loc, QualType OrigT1,
 
 /// Look for a user-defined conversion to a value reference-compatible
 ///        with DeclType. Return true if something definite is found.
-static bool FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS,
-                                     QualType DeclType, SourceLocation DeclLoc,
-                                     Expr *Init, QualType T2, bool AllowRvalues,
-                                     bool AllowExplicit) {
+static bool
+FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS,
+                         QualType DeclType, SourceLocation DeclLoc,
+                         Expr *Init, QualType T2, bool AllowRvalues,
+                         bool AllowExplicit) {
   assert(T2->isRecordType() && "Can only find conversions of record types.");
   auto *T2RecordDecl = T2->castAsCXXRecordDecl();
   OverloadCandidateSet CandidateSet(
@@ -5291,7 +5345,8 @@ static bool FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS,
     if (isa<UsingShadowDecl>(D))
       D = cast<UsingShadowDecl>(D)->getTargetDecl();
 
-    FunctionTemplateDecl *ConvTemplate = dyn_cast<FunctionTemplateDecl>(D);
+    FunctionTemplateDecl *ConvTemplate
+      = dyn_cast<FunctionTemplateDecl>(D);
     CXXConversionDecl *Conv;
     if (ConvTemplate)
       Conv = cast<CXXConversionDecl>(ConvTemplate->getTemplatedDecl());
@@ -5302,8 +5357,8 @@ static bool FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS,
       // If we are initializing an rvalue reference, don't permit conversion
       // functions that return lvalues.
       if (!ConvTemplate && DeclType->isRValueReferenceType()) {
-        const ReferenceType *RefType =
-            Conv->getConversionType()->getAs<LValueReferenceType>();
+        const ReferenceType *RefType
+          = Conv->getConversionType()->getAs<LValueReferenceType>();
         if (RefType && !RefType->getPointeeType()->isFunctionType())
           continue;
       }
@@ -5323,9 +5378,10 @@ static bool FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS,
       // is only acceptable if its referencee is a function type.
 
       const ReferenceType *RefType =
-          Conv->getConversionType()->getAs<ReferenceType>();
-      if (!RefType || (!RefType->isLValueReferenceType() &&
-                       !RefType->getPointeeType()->isFunctionType()))
+        Conv->getConversionType()->getAs<ReferenceType>();
+      if (!RefType ||
+          (!RefType->isLValueReferenceType() &&
+           !RefType->getPointeeType()->isFunctionType()))
         continue;
     }
 
@@ -5393,8 +5449,10 @@ static bool FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS,
 /// Compute an implicit conversion sequence for reference
 /// initialization.
 static ImplicitConversionSequence
-TryReferenceInit(Sema &S, Expr *Init, QualType DeclType, SourceLocation DeclLoc,
-                 bool SuppressUserConversions, bool AllowExplicit) {
+TryReferenceInit(Sema &S, Expr *Init, QualType DeclType,
+                 SourceLocation DeclLoc,
+                 bool SuppressUserConversions,
+                 bool AllowExplicit) {
   assert(DeclType->isReferenceType() && "Reference init needs a reference");
 
   // Most paths end in a failed conversion.
@@ -5409,8 +5467,8 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType, SourceLocation DeclLoc,
   // type of the resulting function.
   if (S.Context.getCanonicalType(T2) == S.Context.OverloadTy) {
     DeclAccessPair Found;
-    if (FunctionDecl *Fn =
-            S.ResolveAddressOfOverloadedFunction(Init, DeclType, false, Found))
+    if (FunctionDecl *Fn = S.ResolveAddressOfOverloadedFunction(Init, DeclType,
+                                                                false, Found))
       T2 = Fn->getType();
   }
 
@@ -5429,17 +5487,17 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType, SourceLocation DeclLoc,
     // consider that when ordering reference-to-function bindings.
     ICS.Standard.Second = (RefConv & Sema::ReferenceConversions::DerivedToBase)
                               ? ICK_Derived_To_Base
-                          : (RefConv & Sema::ReferenceConversions::ObjC)
-                              ? ICK_Compatible_Conversion
-                              : ICK_Identity;
+                              : (RefConv & Sema::ReferenceConversions::ObjC)
+                                    ? ICK_Compatible_Conversion
+                                    : ICK_Identity;
     ICS.Standard.Dimension = ICK_Identity;
     // FIXME: As a speculative fix to a defect introduced by CWG2352, we rank
     // a reference binding that performs a non-top-level qualification
     // conversion as a qualification conversion, not as an identity conversion.
-    ICS.Standard.Third =
-        (RefConv & Sema::ReferenceConversions::NestedQualification)
-            ? ICK_Qualification
-            : ICK_Identity;
+    ICS.Standard.Third = (RefConv &
+                              Sema::ReferenceConversions::NestedQualification)
+                             ? ICK_Qualification
+                             : ICK_Identity;
     ICS.Standard.setFromType(T2);
     ICS.Standard.setToType(0, T2);
     ICS.Standard.setToType(1, T1);
@@ -5494,8 +5552,9 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType, SourceLocation DeclLoc,
     if (!SuppressUserConversions && T2->isRecordType() &&
         S.isCompleteType(DeclLoc, T2) &&
         RefRelationship == Sema::Ref_Incompatible) {
-      if (FindConversionForRefInit(S, ICS, DeclType, DeclLoc, Init, T2,
-                                   /*AllowRvalues=*/false, AllowExplicit))
+      if (FindConversionForRefInit(S, ICS, DeclType, DeclLoc,
+                                   Init, T2, /*AllowRvalues=*/false,
+                                   AllowExplicit))
         return ICS;
     }
   }
@@ -5516,7 +5575,7 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType, SourceLocation DeclLoc,
   if (RefRelationship == Sema::Ref_Compatible &&
       (InitCategory.isXValue() ||
        (InitCategory.isPRValue() &&
-        (T2->isRecordType() || T2->isArrayType())) ||
+          (T2->isRecordType() || T2->isArrayType())) ||
        (InitCategory.isLValue() && T2->isFunctionType()))) {
     // In C++11, this is always a direct binding. In C++98/03, it's a direct
     // binding unless we're binding to a class prvalue.
@@ -5540,8 +5599,9 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType, SourceLocation DeclLoc,
   //          class subobject).
   if (!SuppressUserConversions && RefRelationship == Sema::Ref_Incompatible &&
       T2->isRecordType() && S.isCompleteType(DeclLoc, T2) &&
-      FindConversionForRefInit(S, ICS, DeclType, DeclLoc, Init, T2,
-                               /*AllowRvalues=*/true, AllowExplicit)) {
+      FindConversionForRefInit(S, ICS, DeclType, DeclLoc,
+                               Init, T2, /*AllowRvalues=*/true,
+                               AllowExplicit)) {
     // In the second case, if the reference is an rvalue reference
     // and the second standard conversion sequence of the
     // user-defined conversion sequence includes an lvalue-to-rvalue
@@ -5647,8 +5707,7 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType, SourceLocation DeclLoc,
     ICS.UserDefined.After.IsLvalueReference = !isRValRef;
     ICS.UserDefined.After.BindsToFunctionLvalue = false;
     ICS.UserDefined.After.BindsToRvalue = !LValRefType;
-    ICS.UserDefined.After.BindsImplicitObjectArgumentWithoutRefQualifier =
-        false;
+    ICS.UserDefined.After.BindsImplicitObjectArgumentWithoutRefQualifier = false;
     ICS.UserDefined.After.ObjCLifetimeConversionBinding = false;
     ICS.UserDefined.After.FromBracedInitList = false;
   }
@@ -5658,7 +5717,8 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType, SourceLocation DeclLoc,
 
 static ImplicitConversionSequence
 TryCopyInitialization(Sema &S, Expr *From, QualType ToType,
-                      bool SuppressUserConversions, bool InOverloadResolution,
+                      bool SuppressUserConversions,
+                      bool InOverloadResolution,
                       bool AllowObjCWritebackConversion,
                       bool AllowExplicit = false);
 
@@ -5666,7 +5726,8 @@ TryCopyInitialization(Sema &S, Expr *From, QualType ToType,
 /// initializer list From.
 static ImplicitConversionSequence
 TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
-                  bool SuppressUserConversions, bool InOverloadResolution,
+                  bool SuppressUserConversions,
+                  bool InOverloadResolution,
                   bool AllowObjCWritebackConversion) {
   // C++11 [over.ics.list]p1:
   //   When an argument is an initializer list, it is not an expression and
@@ -5713,9 +5774,10 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
       QualType InitType = From->getInit(0)->getType();
       if (S.Context.hasSameUnqualifiedType(InitType, ToType) ||
           S.IsDerivedFrom(From->getBeginLoc(), InitType, ToType))
-        return TryCopyInitialization(
-            S, From->getInit(0), ToType, SuppressUserConversions,
-            InOverloadResolution, AllowObjCWritebackConversion);
+        return TryCopyInitialization(S, From->getInit(0), ToType,
+                                     SuppressUserConversions,
+                                     InOverloadResolution,
+                                     AllowObjCWritebackConversion);
     }
 
     if (AT && S.IsStringInit(From->getInit(0), AT)) {
@@ -5840,10 +5902,11 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
   //   implicit conversion sequence is a user-defined conversion sequence.
   if (ToType->isRecordType() && !ToType->isAggregateType()) {
     // This function can deal with initializer lists.
-    return TryUserDefinedConversion(
-        S, From, ToType, SuppressUserConversions, AllowedExplicit::None,
-        InOverloadResolution, /*CStyle=*/false, AllowObjCWritebackConversion,
-        /*AllowObjCConversionOnExplicit=*/false);
+    return TryUserDefinedConversion(S, From, ToType, SuppressUserConversions,
+                                    AllowedExplicit::None,
+                                    InOverloadResolution, /*CStyle=*/false,
+                                    AllowObjCWritebackConversion,
+                                    /*AllowObjCConversionOnExplicit=*/false);
   }
 
   // C++14 [over.ics.list]p5:
@@ -5897,7 +5960,7 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
       if (S.Context.getCanonicalType(T2) == S.Context.OverloadTy) {
         DeclAccessPair Found;
         if (FunctionDecl *Fn = S.ResolveAddressOfOverloadedFunction(
-                Init, ToType, false, Found))
+                                   Init, ToType, false, Found))
           T2 = Fn->getType();
       }
 
@@ -5914,9 +5977,9 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
 
     // Otherwise, we bind the reference to a temporary created from the
     // initializer list.
-    Result =
-        TryListConversion(S, From, T1, SuppressUserConversions,
-                          InOverloadResolution, AllowObjCWritebackConversion);
+    Result = TryListConversion(S, From, T1, SuppressUserConversions,
+                               InOverloadResolution,
+                               AllowObjCWritebackConversion);
     if (Result.isFailure())
       return Result;
     assert(!Result.isEllipsis() &&
@@ -5925,8 +5988,8 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
     // Can we even bind to a temporary?
     if (ToType->isRValueReferenceType() ||
         (T1.isConstQualified() && !T1.isVolatileQualified())) {
-      StandardConversionSequence &SCS =
-          Result.isStandard() ? Result.Standard : Result.UserDefined.After;
+      StandardConversionSequence &SCS = Result.isStandard() ? Result.Standard :
+                                            Result.UserDefined.After;
       SCS.ReferenceBinding = true;
       SCS.IsLvalueReference = ToType->isLValueReferenceType();
       SCS.BindsToRvalue = true;
@@ -5936,7 +5999,8 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
       SCS.FromBracedInitList = false;
 
     } else
-      Result.setBad(BadConversionSequence::lvalue_ref_to_rvalue, From, ToType);
+      Result.setBad(BadConversionSequence::lvalue_ref_to_rvalue,
+                    From, ToType);
     return Result;
   }
 
@@ -5983,30 +6047,36 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
 /// do not permit any user-defined conversion sequences.
 static ImplicitConversionSequence
 TryCopyInitialization(Sema &S, Expr *From, QualType ToType,
-                      bool SuppressUserConversions, bool InOverloadResolution,
-                      bool AllowObjCWritebackConversion, bool AllowExplicit) {
+                      bool SuppressUserConversions,
+                      bool InOverloadResolution,
+                      bool AllowObjCWritebackConversion,
+                      bool AllowExplicit) {
   if (InitListExpr *FromInitList = dyn_cast<InitListExpr>(From))
     return TryListConversion(S, FromInitList, ToType, SuppressUserConversions,
-                             InOverloadResolution,
-                             AllowObjCWritebackConversion);
+                             InOverloadResolution,AllowObjCWritebackConversion);
 
   if (ToType->isReferenceType())
     return TryReferenceInit(S, From, ToType,
                             /*FIXME:*/ From->getBeginLoc(),
                             SuppressUserConversions, AllowExplicit);
 
-  return TryImplicitConversion(S, From, ToType, SuppressUserConversions,
-                               AllowedExplicit::None, InOverloadResolution,
-                               /*CStyle=*/false, AllowObjCWritebackConversion,
+  return TryImplicitConversion(S, From, ToType,
+                               SuppressUserConversions,
+                               AllowedExplicit::None,
+                               InOverloadResolution,
+                               /*CStyle=*/false,
+                               AllowObjCWritebackConversion,
                                /*AllowObjCConversionOnExplicit=*/false);
 }
 
 static bool TryCopyInitialization(const CanQualType FromQTy,
-                                  const CanQualType ToQTy, Sema &S,
-                                  SourceLocation Loc, ExprValueKind FromVK) {
+                                  const CanQualType ToQTy,
+                                  Sema &S,
+                                  SourceLocation Loc,
+                                  ExprValueKind FromVK) {
   OpaqueValueExpr TmpExpr(Loc, FromQTy, FromVK);
   ImplicitConversionSequence ICS =
-      TryCopyInitialization(S, &TmpExpr, ToQTy, true, true, false);
+    TryCopyInitialization(S, &TmpExpr, ToQTy, true, true, false);
 
   return !ICS.isBad();
 }
@@ -6098,8 +6168,8 @@ static ImplicitConversionSequence TryObjectArgumentInitialization(
           FromTypeCanon.getLocalCVRQualifiers() &&
       !ImplicitParamType.isAtLeastAsQualifiedAs(
           withoutUnaligned(S.Context, FromTypeCanon), S.getASTContext())) {
-    ICS.setBad(BadConversionSequence::bad_qualifiers, FromType,
-               ImplicitParamType);
+    ICS.setBad(BadConversionSequence::bad_qualifiers,
+               FromType, ImplicitParamType);
     return ICS;
   }
 
@@ -6108,8 +6178,8 @@ static ImplicitConversionSequence TryObjectArgumentInitialization(
     Qualifiers QualsFromType = FromTypeCanon.getQualifiers();
     if (!QualsImplicitParamType.isAddressSpaceSupersetOf(QualsFromType,
                                                          S.getASTContext())) {
-      ICS.setBad(BadConversionSequence::bad_qualifiers, FromType,
-                 ImplicitParamType);
+      ICS.setBad(BadConversionSequence::bad_qualifiers,
+                 FromType, ImplicitParamType);
       return ICS;
     }
   }
@@ -6123,8 +6193,8 @@ static ImplicitConversionSequence TryObjectArgumentInitialization(
   } else if (S.IsDerivedFrom(Loc, FromType, ClassType)) {
     SecondKind = ICK_Derived_To_Base;
   } else if (!Method->isExplicitObjectMemberFunction()) {
-    ICS.setBad(BadConversionSequence::unrelated_class, FromType,
-               ImplicitParamType);
+    ICS.setBad(BadConversionSequence::unrelated_class,
+               FromType, ImplicitParamType);
     return ICS;
   }
 
@@ -6165,8 +6235,8 @@ static ImplicitConversionSequence TryObjectArgumentInitialization(
   ICS.Standard.BindsToFunctionLvalue = false;
   ICS.Standard.BindsToRvalue = FromClassification.isRValue();
   ICS.Standard.FromBracedInitList = false;
-  ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier =
-      (Method->getRefQualifier() == RQ_None);
+  ICS.Standard.BindsImplicitObjectArgumentWithoutRefQualifier
+    = (Method->getRefQualifier() == RQ_None);
   return ICS;
 }
 
@@ -6215,7 +6285,7 @@ ExprResult Sema::PerformImplicitObjectArgumentInitialization(
             << Method->getDeclName() << FromRecordType << (CVR - 1)
             << From->getSourceRange();
         Diag(Method->getLocation(), diag::note_previous_decl)
-            << Method->getDeclName();
+          << Method->getDeclName();
         return ExprError();
       }
       break;
@@ -6224,12 +6294,12 @@ ExprResult Sema::PerformImplicitObjectArgumentInitialization(
     case BadConversionSequence::lvalue_ref_to_rvalue:
     case BadConversionSequence::rvalue_ref_to_lvalue: {
       bool IsRValueQualified =
-          Method->getRefQualifier() == RefQualifierKind::RQ_RValue;
+        Method->getRefQualifier() == RefQualifierKind::RQ_RValue;
       Diag(From->getBeginLoc(), diag::err_member_function_call_bad_ref)
           << Method->getDeclName() << FromClassification.isRValue()
           << IsRValueQualified;
       Diag(Method->getLocation(), diag::note_previous_decl)
-          << Method->getDeclName();
+        << Method->getDeclName();
       return ExprError();
     }
 
@@ -6249,7 +6319,7 @@ ExprResult Sema::PerformImplicitObjectArgumentInitialization(
 
   if (ICS.Standard.Second == ICK_Derived_To_Base) {
     ExprResult FromRes =
-        PerformObjectMemberConversion(From, Qualifier, FoundDecl, Method);
+      PerformObjectMemberConversion(From, Qualifier, FoundDecl, Method);
     if (FromRes.isInvalid())
       return ExprError();
     From = FromRes.get();
@@ -6271,15 +6341,16 @@ ExprResult Sema::PerformImplicitObjectArgumentInitialization(
 
 /// TryContextuallyConvertToBool - Attempt to contextually convert the
 /// expression From to bool (C++0x [conv]p3).
-static ImplicitConversionSequence TryContextuallyConvertToBool(Sema &S,
-                                                               Expr *From) {
+static ImplicitConversionSequence
+TryContextuallyConvertToBool(Sema &S, Expr *From) {
   // C++ [dcl.init]/17.8:
   //   - Otherwise, if the initialization is direct-initialization, the source
   //     type is std::nullptr_t, and the destination type is bool, the initial
   //     value of the object being initialized is false.
   if (From->getType()->isNullPtrType())
-    return ImplicitConversionSequence::getNullptrToBool(
-        From->getType(), S.Context.BoolTy, From->isGLValue());
+    return ImplicitConversionSequence::getNullptrToBool(From->getType(),
+                                                        S.Context.BoolTy,
+                                                        From->isGLValue());
 
   // All other direct-initialization of bool is equivalent to an implicit
   // conversion to bool in which explicit conversions are permitted.
@@ -6677,14 +6748,15 @@ static ImplicitConversionSequence
 TryContextuallyConvertToObjCPointer(Sema &S, Expr *From) {
   // Do an implicit conversion to 'id'.
   QualType Ty = S.Context.getObjCIdType();
-  ImplicitConversionSequence ICS = TryImplicitConversion(
-      S, From, Ty,
-      // FIXME: Are these flags correct?
-      /*SuppressUserConversions=*/false, AllowedExplicit::Conversions,
-      /*InOverloadResolution=*/false,
-      /*CStyle=*/false,
-      /*AllowObjCWritebackConversion=*/false,
-      /*AllowObjCConversionOnExplicit=*/true);
+  ImplicitConversionSequence ICS
+    = TryImplicitConversion(S, From, Ty,
+                            // FIXME: Are these flags correct?
+                            /*SuppressUserConversions=*/false,
+                            AllowedExplicit::Conversions,
+                            /*InOverloadResolution=*/false,
+                            /*CStyle=*/false,
+                            /*AllowObjCWritebackConversion=*/false,
+                            /*AllowObjCConversionOnExplicit=*/true);
 
   // Strip off any final conversions to 'id'.
   switch (ICS.getKind()) {
@@ -6712,7 +6784,7 @@ ExprResult Sema::PerformContextuallyConvertToObjCPointer(Expr *From) {
 
   QualType Ty = Context.getObjCIdType();
   ImplicitConversionSequence ICS =
-      TryContextuallyConvertToObjCPointer(*this, From);
+    TryContextuallyConvertToObjCPointer(*this, From);
   if (!ICS.isBad())
     return PerformImplicitConversion(From, Ty, ICS,
                                      AssignmentAction::Converting);
@@ -7183,8 +7255,8 @@ void Sema::AddOverloadCandidate(
     ADLCallKind IsADLCandidate, ConversionSequenceList EarlyConversions,
     OverloadCandidateParamOrder PO, bool AggregateCandidateDeduction,
     bool StrictPackMatch) {
-  const FunctionProtoType *Proto =
-      dyn_cast<FunctionProtoType>(Function->getType()->getAs<FunctionType>());
+  const FunctionProtoType *Proto
+    = dyn_cast<FunctionProtoType>(Function->getType()->getAs<FunctionType>());
   assert(Proto && "Functions without a prototype cannot be overloaded");
   assert(!Function->getDescribedFunctionTemplate() &&
          "Use AddTemplateOverloadCandidate for function templates");
@@ -7486,13 +7558,13 @@ Sema::SelectBestMethod(Selector Sel, MultiExprArg Args, bool IsInstance,
         break;
       }
 
-      ImplicitConversionSequence ConversionState =
-          TryCopyInitialization(*this, argExpr, param->getType(),
-                                /*SuppressUserConversions*/ false,
+      ImplicitConversionSequence ConversionState
+        = TryCopyInitialization(*this, argExpr, param->getType(),
+                                /*SuppressUserConversions*/false,
                                 /*InOverloadResolution=*/true,
                                 /*AllowObjCWritebackConversion=*/
                                 getLangOpts().ObjCAutoRefCount,
-                                /*AllowExplicit*/ false);
+                                /*AllowExplicit*/false);
       // This function looks for a reasonably-exact match, so we consider
       // incompatible pointer conversions to be a failure here.
       if (ConversionState.isBad() ||
@@ -7601,7 +7673,8 @@ static bool convertArgsForAvailabilityChecks(
 }
 
 EnableIfAttr *Sema::CheckEnableIf(FunctionDecl *Function,
-                                  SourceLocation CallLoc, ArrayRef<Expr *> Args,
+                                  SourceLocation CallLoc,
+                                  ArrayRef<Expr *> Args,
                                   bool MissingImplicitThis) {
   auto EnableIfAttrs = Function->specific_attrs<EnableIfAttr>();
   if (EnableIfAttrs.begin() == EnableIfAttrs.end())
@@ -7712,8 +7785,7 @@ bool Sema::diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function,
         // EvaluateWithSubstitution only cares about the position of each
         // argument in the arg list, not the ParmVarDecl* it maps to.
         if (!DIA->getCond()->EvaluateWithSubstitution(
-                Result, Context, cast<FunctionDecl>(DIA->getParent()), Args,
-                ThisArg))
+                Result, Context, cast<FunctionDecl>(DIA->getParent()), Args, ThisArg))
           return false;
         return Result.isInt() && Result.getInt().getBoolValue();
       });
@@ -7722,7 +7794,8 @@ bool Sema::diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function,
 bool Sema::diagnoseArgIndependentDiagnoseIfAttrs(const NamedDecl *ND,
                                                  SourceLocation Loc) {
   return diagnoseDiagnoseIfAttrsWith(
-      *this, ND, /*ArgDependent=*/false, Loc, [&](const DiagnoseIfAttr *DIA) {
+      *this, ND, /*ArgDependent=*/false, Loc,
+      [&](const DiagnoseIfAttr *DIA) {
         bool Result;
         return DIA->getCond()->EvaluateAsBooleanCondition(Result, Context) &&
                Result;
@@ -7785,9 +7858,10 @@ void Sema::AddFunctionCandidates(const UnresolvedSetImpl &Fns,
         FunctionArgs = Args.slice(1);
       }
       if (FunTmpl) {
-        AddTemplateOverloadCandidate(
-            FunTmpl, F.getPair(), ExplicitTemplateArgs, FunctionArgs,
-            CandidateSet, SuppressUserConversions, PartialOverloading);
+        AddTemplateOverloadCandidate(FunTmpl, F.getPair(),
+                                     ExplicitTemplateArgs, FunctionArgs,
+                                     CandidateSet, SuppressUserConversions,
+                                     PartialOverloading);
       } else {
         AddOverloadCandidate(FD, F.getPair(), FunctionArgs, CandidateSet,
                              SuppressUserConversions, PartialOverloading);
@@ -7829,8 +7903,8 @@ void Sema::AddMethodCandidate(
     OverloadCandidateSet &CandidateSet, bool SuppressUserConversions,
     bool PartialOverloading, ConversionSequenceList EarlyConversions,
     OverloadCandidateParamOrder PO, bool StrictPackMatch) {
-  const FunctionProtoType *Proto =
-      dyn_cast<FunctionProtoType>(Method->getType()->getAs<FunctionType>());
+  const FunctionProtoType *Proto
+    = dyn_cast<FunctionProtoType>(Method->getType()->getAs<FunctionType>());
   assert(Proto && "Methods without a prototype cannot be overloaded");
   assert(!isa<CXXConstructorDecl>(Method) &&
          "Use AddOverloadCandidate for constructors");
@@ -7980,11 +8054,12 @@ void Sema::AddMethodCandidate(
       } else {
         ParamType = Proto->getParamType(ArgIdx + ExplicitOffset);
       }
-      Candidate.Conversions[ConvIdx] = TryCopyInitialization(
-          *this, Args[ArgIdx], ParamType, SuppressUserConversions,
-          /*InOverloadResolution=*/true,
-          /*AllowObjCWritebackConversion=*/
-          getLangOpts().ObjCAutoRefCount);
+      Candidate.Conversions[ConvIdx]
+        = TryCopyInitialization(*this, Args[ArgIdx], ParamType,
+                                SuppressUserConversions,
+                                /*InOverloadResolution=*/true,
+                                /*AllowObjCWritebackConversion=*/
+                                  getLangOpts().ObjCAutoRefCount);
       if (Candidate.Conversions[ConvIdx].isBad()) {
         Candidate.Viable = false;
         Candidate.FailureKind = ovl_fail_bad_conversion;
@@ -8056,7 +8131,7 @@ static void AddMethodTemplateCandidateImmediately(
     Candidate.Function = Method;
     Candidate.Viable = false;
     Candidate.RewriteKind =
-        CandidateSet.getRewriteInfo().getRewriteKind(Candidate.Function, PO);
+      CandidateSet.getRewriteInfo().getRewriteKind(Candidate.Function, PO);
     Candidate.IsSurrogate = false;
     Candidate.TookAddressOfOverload =
         CandidateSet.getKind() ==
@@ -8179,7 +8254,7 @@ static void AddTemplateOverloadCandidateImmediately(
     Candidate.Function = FunctionTemplate->getTemplatedDecl();
     Candidate.Viable = false;
     Candidate.RewriteKind =
-        CandidateSet.getRewriteInfo().getRewriteKind(Candidate.Function, PO);
+      CandidateSet.getRewriteInfo().getRewriteKind(Candidate.Function, PO);
     Candidate.IsSurrogate = false;
     Candidate.IsADLCandidate = llvm::to_underlying(IsADLCandidate);
     // Ignore the object argument if there is one, since we don't have an object
@@ -8380,8 +8455,8 @@ bool Sema::CheckNonDependentConversions(
 /// Objective-C pointer to another.
 ///
 /// \returns true if the conversion is allowable, false otherwise.
-static bool isAllowableExplicitConversion(Sema &S, QualType ConvType,
-                                          QualType ToType,
+static bool isAllowableExplicitConversion(Sema &S,
+                                          QualType ConvType, QualType ToType,
                                           bool AllowObjCPointerConversion) {
   QualType ToNonRefType = ToType.getNonReferenceType();
 
@@ -8391,7 +8466,7 @@ static bool isAllowableExplicitConversion(Sema &S, QualType ConvType,
 
   // Allow qualification conversions.
   bool ObjCLifetimeConversion;
-  if (S.IsQualificationConversion(ConvType, ToNonRefType, /*CStyle*/ false,
+  if (S.IsQualificationConversion(ConvType, ToNonRefType, /*CStyle*/false,
                                   ObjCLifetimeConversion))
     return true;
 
@@ -8508,8 +8583,8 @@ void Sema::AddConversionCandidate(
   // We won't go through a user-defined type conversion function to convert a
   // derived to base as such conversions are given Conversion Rank. They only
   // go through a copy constructor. 13.3.3.1.2-p4 [over.ics.user]
-  QualType FromCanon =
-      Context.getCanonicalType(From->getType().getUnqualifiedType());
+  QualType FromCanon
+    = Context.getCanonicalType(From->getType().getUnqualifiedType());
   QualType ToCanon = Context.getCanonicalType(ToType).getUnqualifiedType();
   if (FromCanon == ToCanon ||
       IsDerivedFrom(CandidateSet.getLocation(), FromCanon, ToCanon)) {
@@ -8590,7 +8665,7 @@ void Sema::AddConversionCandidate(
 
   default:
     llvm_unreachable(
-        "Can only end up with a standard conversion sequence or failure");
+           "Can only end up with a standard conversion sequence or failure");
   }
 
   if (EnableIfAttr *FailedAttr =
@@ -8687,9 +8762,10 @@ void Sema::AddTemplateConversionCandidate(
 void Sema::AddSurrogateCandidate(CXXConversionDecl *Conversion,
                                  DeclAccessPair FoundDecl,
                                  CXXRecordDecl *ActingContext,
-                                 const FunctionProtoType *Proto, Expr *Object,
+                                 const FunctionProtoType *Proto,
+                                 Expr *Object,
                                  ArrayRef<Expr *> Args,
-                                 OverloadCandidateSet &CandidateSet) {
+                                 OverloadCandidateSet& CandidateSet) {
   if (!CandidateSet.isNewCandidate(Conversion))
     return;
 
@@ -8735,8 +8811,8 @@ void Sema::AddSurrogateCandidate(CXXConversionDecl *Conversion,
   Candidate.Conversions[0].UserDefined.HadMultipleCandidates = false;
   Candidate.Conversions[0].UserDefined.ConversionFunction = Conversion;
   Candidate.Conversions[0].UserDefined.FoundConversionFunction = FoundDecl;
-  Candidate.Conversions[0].UserDefined.After =
-      Candidate.Conversions[0].UserDefined.Before;
+  Candidate.Conversions[0].UserDefined.After
+    = Candidate.Conversions[0].UserDefined.Before;
   Candidate.Conversions[0].UserDefined.After.setAsIdentityConversion();
 
   // Find the
@@ -8769,12 +8845,12 @@ void Sema::AddSurrogateCandidate(CXXConversionDecl *Conversion,
       // (13.3.3.1) that converts that argument to the corresponding
       // parameter of F.
       QualType ParamType = Proto->getParamType(ArgIdx);
-      Candidate.Conversions[ArgIdx + 1] =
-          TryCopyInitialization(*this, Args[ArgIdx], ParamType,
+      Candidate.Conversions[ArgIdx + 1]
+        = TryCopyInitialization(*this, Args[ArgIdx], ParamType,
                                 /*SuppressUserConversions=*/false,
                                 /*InOverloadResolution=*/false,
                                 /*AllowObjCWritebackConversion=*/
-                                getLangOpts().ObjCAutoRefCount);
+                                  getLangOpts().ObjCAutoRefCount);
       if (Candidate.Conversions[ArgIdx + 1].isBad()) {
         Candidate.Viable = false;
         Candidate.FailureKind = ovl_fail_bad_conversion;
@@ -8903,7 +8979,7 @@ void Sema::AddMemberOperatorCandidates(OverloadedOperatorKind Op,
 }
 
 void Sema::AddBuiltinCandidate(QualType *ParamTys, ArrayRef<Expr *> Args,
-                               OverloadCandidateSet &CandidateSet,
+                               OverloadCandidateSet& CandidateSet,
                                bool IsAssignmentOperator,
                                unsigned NumContextualBoolArguments) {
   // Overload resolution is always an unevaluated context.
@@ -8936,15 +9012,15 @@ void Sema::AddBuiltinCandidate(QualType *ParamTys, ArrayRef<Expr *> Args,
     if (ArgIdx < NumContextualBoolArguments) {
       assert(ParamTys[ArgIdx] == Context.BoolTy &&
              "Contextual conversion to bool requires bool type");
-      Candidate.Conversions[ArgIdx] =
-          TryContextuallyConvertToBool(*this, Args[ArgIdx]);
+      Candidate.Conversions[ArgIdx]
+        = TryContextuallyConvertToBool(*this, Args[ArgIdx]);
     } else {
-      Candidate.Conversions[ArgIdx] =
-          TryCopyInitialization(*this, Args[ArgIdx], ParamTys[ArgIdx],
+      Candidate.Conversions[ArgIdx]
+        = TryCopyInitialization(*this, Args[ArgIdx], ParamTys[ArgIdx],
                                 ArgIdx == 0 && IsAssignmentOperator,
                                 /*InOverloadResolution=*/false,
                                 /*AllowObjCWritebackConversion=*/
-                                getLangOpts().ObjCAutoRefCount);
+                                  getLangOpts().ObjCAutoRefCount);
     }
     if (Candidate.Conversions[ArgIdx].isBad()) {
       Candidate.Viable = false;
@@ -8960,7 +9036,7 @@ namespace {
 /// candidate operator functions for built-in operators (C++
 /// [over.built]). The types are separated into pointer types and
 /// enumeration types.
-class BuiltinCandidateTypeSet {
+class BuiltinCandidateTypeSet  {
   /// TypeSet - A set of types.
   typedef llvm::SmallSetVector<QualType, 8> TypeSet;
 
@@ -9018,11 +9094,15 @@ class BuiltinCandidateTypeSet {
   typedef TypeSet::iterator iterator;
 
   BuiltinCandidateTypeSet(Sema &SemaRef)
-      : HasNonRecordTypes(false), HasArithmeticOrEnumeralTypes(false),
-        HasNullPtrType(false), HasReflectionType(false), SemaRef(SemaRef),
-        Context(SemaRef.Context) {}
-
-  void AddTypesConvertedFrom(QualType Ty, SourceLocation Loc,
+    : HasNonRecordTypes(false),
+      HasArithmeticOrEnumeralTypes(false),
+      HasNullPtrType(false),
+      HasReflectionType(false),
+      SemaRef(SemaRef),
+      Context(SemaRef.Context) { }
+
+  void AddTypesConvertedFrom(QualType Ty,
+                             SourceLocation Loc,
                              bool AllowUserConversions,
                              bool AllowExplicitConversions,
                              const Qualifiers &VisibleTypeConversionsQuals);
@@ -9056,8 +9136,9 @@ class BuiltinCandidateTypeSet {
 /// false otherwise.
 ///
 /// FIXME: what to do about extended qualifiers?
-bool BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(
-    QualType Ty, const Qualifiers &VisibleQuals) {
+bool
+BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(QualType Ty,
+                                             const Qualifiers &VisibleQuals) {
 
   // Insert this type.
   if (!PointerTypes.insert(Ty))
@@ -9086,12 +9167,10 @@ bool BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(
   bool hasRestrict = VisibleQuals.hasRestrict();
 
   // Iterate through all strict supersets of BaseCVR.
-  for (unsigned CVR = BaseCVR + 1; CVR <= Qualifiers::CVRMask; ++CVR) {
-    if ((CVR | BaseCVR) != CVR)
-      continue;
+  for (unsigned CVR = BaseCVR+1; CVR <= Qualifiers::CVRMask; ++CVR) {
+    if ((CVR | BaseCVR) != CVR) continue;
     // Skip over volatile if no volatile found anywhere in the types.
-    if ((CVR & Qualifiers::Volatile) && !hasVolatile)
-      continue;
+    if ((CVR & Qualifiers::Volatile) && !hasVolatile) continue;
 
     // Skip over restrict if no restrict found anywhere in the types, or if
     // the type cannot be restrict-qualified.
@@ -9126,7 +9205,8 @@ bool BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(
 /// false otherwise.
 ///
 /// FIXME: what to do about extended qualifiers?
-bool BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
+bool
+BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
     QualType Ty) {
   // Insert this type.
   if (!MemberPointerTypes.insert(Ty))
@@ -9147,9 +9227,8 @@ bool BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
   // Iterate through all strict supersets of the pointee type's CVR
   // qualifiers.
   unsigned BaseCVR = PointeeTy.getCVRQualifiers();
-  for (unsigned CVR = BaseCVR + 1; CVR <= Qualifiers::CVRMask; ++CVR) {
-    if ((CVR | BaseCVR) != CVR)
-      continue;
+  for (unsigned CVR = BaseCVR+1; CVR <= Qualifiers::CVRMask; ++CVR) {
+    if ((CVR | BaseCVR) != CVR) continue;
 
     QualType QPointeeTy = Context.getCVRQualifiedType(PointeeTy, CVR);
     MemberPointerTypes.insert(Context.getMemberPointerType(
@@ -9167,9 +9246,12 @@ bool BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants(
 /// functions of a class type, and AllowExplicitConversions if we
 /// should also include the explicit conversion functions of a class
 /// type.
-void BuiltinCandidateTypeSet::AddTypesConvertedFrom(
-    QualType Ty, SourceLocation Loc, bool AllowUserConversions,
-    bool AllowExplicitConversions, const Qualifiers &VisibleQuals) {
+void
+BuiltinCandidateTypeSet::AddTypesConvertedFrom(QualType Ty,
+                                               SourceLocation Loc,
+                                               bool AllowUserConversions,
+                                               bool AllowExplicitConversions,
+                                               const Qualifiers &VisibleQuals) {
   // Only deal with canonical types.
   Ty = Context.getCanonicalType(Ty);
 
@@ -9191,7 +9273,7 @@ void BuiltinCandidateTypeSet::AddTypesConvertedFrom(
 
   // Flag if we encounter an arithmetic type.
   HasArithmeticOrEnumeralTypes =
-      HasArithmeticOrEnumeralTypes || Ty->isArithmeticType();
+    HasArithmeticOrEnumeralTypes || Ty->isArithmeticType();
 
   if (Ty->isObjCIdType() || Ty->isObjCClassType())
     PointerTypes.insert(Ty);
@@ -9257,10 +9339,10 @@ static QualType AdjustAddressSpaceForBuiltinOperandType(Sema &S, QualType T,
 /// Helper function for AddBuiltinOperatorCandidates() that adds
 /// the volatile- and non-volatile-qualified assignment operators for the
 /// given type to the candidate set.
-static void
-AddBuiltinAssignmentOperatorCandidates(Sema &S, QualType T,
-                                       ArrayRef<Expr *> Args,
-                                       OverloadCandidateSet &CandidateSet) {
+static void AddBuiltinAssignmentOperatorCandidates(Sema &S,
+                                                   QualType T,
+                                                   ArrayRef<Expr *> Args,
+                                    OverloadCandidateSet &CandidateSet) {
   QualType ParamTypes[2];
 
   // T& operator=(T&, T)
@@ -9283,51 +9365,51 @@ AddBuiltinAssignmentOperatorCandidates(Sema &S, QualType T,
 
 /// CollectVRQualifiers - This routine returns Volatile/Restrict qualifiers,
 /// if any, found in visible type conversion functions found in ArgExpr's type.
-static Qualifiers CollectVRQualifiers(ASTContext &Context, Expr *ArgExpr) {
-  Qualifiers VRQuals;
-  CXXRecordDecl *ClassDecl;
-  if (const MemberPointerType *RHSMPType =
-          ArgExpr->getType()->getAs<MemberPointerType>())
-    ClassDecl = RHSMPType->getMostRecentCXXRecordDecl();
-  else
-    ClassDecl = ArgExpr->getType()->getAsCXXRecordDecl();
-  if (!ClassDecl) {
-    // Just to be safe, assume the worst case.
-    VRQuals.addVolatile();
-    VRQuals.addRestrict();
-    return VRQuals;
-  }
-  if (!ClassDecl->hasDefinition())
-    return VRQuals;
+static  Qualifiers CollectVRQualifiers(ASTContext &Context, Expr* ArgExpr) {
+    Qualifiers VRQuals;
+    CXXRecordDecl *ClassDecl;
+    if (const MemberPointerType *RHSMPType =
+            ArgExpr->getType()->getAs<MemberPointerType>())
+      ClassDecl = RHSMPType->getMostRecentCXXRecordDecl();
+    else
+      ClassDecl = ArgExpr->getType()->getAsCXXRecordDecl();
+    if (!ClassDecl) {
+      // Just to be safe, assume the worst case.
+      VRQuals.addVolatile();
+      VRQuals.addRestrict();
+      return VRQuals;
+    }
+    if (!ClassDecl->hasDefinition())
+      return VRQuals;
 
-  for (NamedDecl *D : ClassDecl->getVisibleConversionFunctions()) {
-    if (isa<UsingShadowDecl>(D))
-      D = cast<UsingShadowDecl>(D)->getTargetDecl();
-    if (CXXConversionDecl *Conv = dyn_cast<CXXConversionDecl>(D)) {
-      QualType CanTy = Context.getCanonicalType(Conv->getConversionType());
-      if (const ReferenceType *ResTypeRef = CanTy->getAs<ReferenceType>())
-        CanTy = ResTypeRef->getPointeeType();
-      // Need to go down the pointer/mempointer chain and add qualifiers
-      // as see them.
-      bool done = false;
-      while (!done) {
-        if (CanTy.isRestrictQualified())
-          VRQuals.addRestrict();
-        if (const PointerType *ResTypePtr = CanTy->getAs<PointerType>())
-          CanTy = ResTypePtr->getPointeeType();
-        else if (const MemberPointerType *ResTypeMPtr =
-                     CanTy->getAs<MemberPointerType>())
-          CanTy = ResTypeMPtr->getPointeeType();
-        else
-          done = true;
-        if (CanTy.isVolatileQualified())
-          VRQuals.addVolatile();
-        if (VRQuals.hasRestrict() && VRQuals.hasVolatile())
-          return VRQuals;
+    for (NamedDecl *D : ClassDecl->getVisibleConversionFunctions()) {
+      if (isa<UsingShadowDecl>(D))
+        D = cast<UsingShadowDecl>(D)->getTargetDecl();
+      if (CXXConversionDecl *Conv = dyn_cast<CXXConversionDecl>(D)) {
+        QualType CanTy = Context.getCanonicalType(Conv->getConversionType());
+        if (const ReferenceType *ResTypeRef = CanTy->getAs<ReferenceType>())
+          CanTy = ResTypeRef->getPointeeType();
+        // Need to go down the pointer/mempointer chain and add qualifiers
+        // as see them.
+        bool done = false;
+        while (!done) {
+          if (CanTy.isRestrictQualified())
+            VRQuals.addRestrict();
+          if (const PointerType *ResTypePtr = CanTy->getAs<PointerType>())
+            CanTy = ResTypePtr->getPointeeType();
+          else if (const MemberPointerType *ResTypeMPtr =
+                CanTy->getAs<MemberPointerType>())
+            CanTy = ResTypeMPtr->getPointeeType();
+          else
+            done = true;
+          if (CanTy.isVolatileQualified())
+            VRQuals.addVolatile();
+          if (VRQuals.hasRestrict() && VRQuals.hasVolatile())
+            return VRQuals;
+        }
       }
     }
-  }
-  return VRQuals;
+    return VRQuals;
 }
 
 // Note: We're currently only handling qualifiers that are meaningful for the
@@ -9394,9 +9476,12 @@ class BuiltinOperatorOverloadBuilder {
   // Define some indices used to iterate over the arithmetic types in
   // ArithmeticTypes.  The "promoted arithmetic types" are the arithmetic
   // types are that preserved by promotion (C++ [over.built]p2).
-  unsigned FirstIntegralType, LastIntegralType;
-  unsigned FirstPromotedIntegralType, LastPromotedIntegralType;
-  unsigned FirstPromotedArithmeticType, LastPromotedArithmeticType;
+  unsigned FirstIntegralType,
+           LastIntegralType;
+  unsigned FirstPromotedIntegralType,
+           LastPromotedIntegralType;
+  unsigned FirstPromotedArithmeticType,
+           LastPromotedArithmeticType;
   unsigned NumArithmeticTypes;
 
   void InitArithmeticTypes() {
@@ -9471,9 +9556,12 @@ class BuiltinOperatorOverloadBuilder {
   /// Helper method to factor out the common pattern of adding overloads
   /// for '++' and '--' builtin operators.
   void addPlusPlusMinusMinusStyleOverloads(QualType CandidateTy,
-                                           bool HasVolatile, bool HasRestrict) {
-    QualType ParamTypes[2] = {S.Context.getLValueReferenceType(CandidateTy),
-                              S.Context.IntTy};
+                                           bool HasVolatile,
+                                           bool HasRestrict) {
+    QualType ParamTypes[2] = {
+      S.Context.getLValueReferenceType(CandidateTy),
+      S.Context.IntTy
+    };
 
     // Non-volatile version.
     S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);
@@ -9481,7 +9569,8 @@ class BuiltinOperatorOverloadBuilder {
     // Use a heuristic to reduce number of builtin candidates in the set:
     // add volatile version only if there are conversions to a volatile type.
     if (HasVolatile) {
-      ParamTypes[0] = S.Context.getLValueReferenceType(
+      ParamTypes[0] =
+        S.Context.getLValueReferenceType(
           S.Context.getVolatileType(CandidateTy));
       S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);
     }
@@ -9490,17 +9579,21 @@ class BuiltinOperatorOverloadBuilder {
     // and our candidate type is a non-restrict-qualified pointer.
     if (HasRestrict && CandidateTy->isAnyPointerType() &&
         !CandidateTy.isRestrictQualified()) {
-      ParamTypes[0] = S.Context.getLValueReferenceType(
-          S.Context.getCVRQualifiedType(CandidateTy, Qualifiers::Restrict));
+      ParamTypes[0]
+        = S.Context.getLValueReferenceType(
+            S.Context.getCVRQualifiedType(CandidateTy, Qualifiers::Restrict));
       S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);
 
       if (HasVolatile) {
-        ParamTypes[0] =
-            S.Context.getLValueReferenceType(S.Context.getCVRQualifiedType(
-                CandidateTy, (Qualifiers::Volatile | Qualifiers::Restrict)));
+        ParamTypes[0]
+          = S.Context.getLValueReferenceType(
+              S.Context.getCVRQualifiedType(CandidateTy,
+                                            (Qualifiers::Volatile |
+                                             Qualifiers::Restrict)));
         S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);
       }
     }
+
   }
 
   /// Helper to add an overload candidate for a binary builtin with types \p L
@@ -9512,16 +9605,17 @@ class BuiltinOperatorOverloadBuilder {
 
 public:
   BuiltinOperatorOverloadBuilder(
-      Sema &S, ArrayRef<Expr *> Args,
-      QualifiersAndAtomic VisibleTypeConversionsQuals,
-      bool HasArithmeticOrEnumeralCandidateType,
-      SmallVectorImpl<BuiltinCandidateTypeSet> &CandidateTypes,
-      OverloadCandidateSet &CandidateSet)
-      : S(S), Args(Args),
-        VisibleTypeConversionsQuals(VisibleTypeConversionsQuals),
-        HasArithmeticOrEnumeralCandidateType(
-            HasArithmeticOrEnumeralCandidateType),
-        CandidateTypes(CandidateTypes), CandidateSet(CandidateSet) {
+    Sema &S, ArrayRef<Expr *> Args,
+    QualifiersAndAtomic VisibleTypeConversionsQuals,
+    bool HasArithmeticOrEnumeralCandidateType,
+    SmallVectorImpl<BuiltinCandidateTypeSet> &CandidateTypes,
+    OverloadCandidateSet &CandidateSet)
+    : S(S), Args(Args),
+      VisibleTypeConversionsQuals(VisibleTypeConversionsQuals),
+      HasArithmeticOrEnumeralCandidateType(
+        HasArithmeticOrEnumeralCandidateType),
+      CandidateTypes(CandidateTypes),
+      CandidateSet(CandidateSet) {
 
     InitArithmeticTypes();
   }
@@ -9558,8 +9652,9 @@ class BuiltinOperatorOverloadBuilder {
           continue;
       }
       addPlusPlusMinusMinusStyleOverloads(
-          TypeOfT, VisibleTypeConversionsQuals.hasVolatile(),
-          VisibleTypeConversionsQuals.hasRestrict());
+        TypeOfT,
+        VisibleTypeConversionsQuals.hasVolatile(),
+        VisibleTypeConversionsQuals.hasRestrict());
     }
   }
 
@@ -9604,8 +9699,7 @@ class BuiltinOperatorOverloadBuilder {
       if (!PointeeTy->isObjectType() && !PointeeTy->isFunctionType())
         continue;
 
-      if (const FunctionProtoType *Proto =
-              PointeeTy->getAs<FunctionProtoType>())
+      if (const FunctionProtoType *Proto =PointeeTy->getAs<FunctionProtoType>())
         if (Proto->getMethodQuals() || Proto->getRefQualifier())
           continue;
 
@@ -9687,7 +9781,7 @@ class BuiltinOperatorOverloadBuilder {
       if (CandidateTypes[ArgIdx].hasNullPtrType()) {
         CanQualType NullPtrTy = S.Context.getCanonicalType(S.Context.NullPtrTy);
         if (AddedTypes.insert(NullPtrTy).second) {
-          QualType ParamTypes[2] = {NullPtrTy, NullPtrTy};
+          QualType ParamTypes[2] = { NullPtrTy, NullPtrTy };
           S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);
         }
       }
@@ -9695,7 +9789,7 @@ class BuiltinOperatorOverloadBuilder {
       if (CandidateTypes[ArgIdx].hasReflectionType()) {
         CanQualType InfoTy = S.Context.getCanonicalType(S.Context.MetaInfoTy);
         if (AddedTypes.insert(InfoTy).second) {
-          QualType ParamTypes[2] = {InfoTy, InfoTy};
+          QualType ParamTypes[2] = { InfoTy, InfoTy };
           S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);
         }
       }
@@ -9722,18 +9816,18 @@ class BuiltinOperatorOverloadBuilder {
     //   candidate.
     //
     // Note that in practice, this only affects enumeration types because there
-    // aren't any built-in candidates of record type, and a user-defined
-    // operator must have an operand of record or enumeration type. Also, the
-    // only other overloaded operator with enumeration arguments, operator=,
+    // aren't any built-in candidates of record type, and a user-defined operator
+    // must have an operand of record or enumeration type. Also, the only other
+    // overloaded operator with enumeration arguments, operator=,
     // cannot be overloaded for enumeration types, so this is the only place
     // where we must suppress candidates like this.
-    llvm::DenseSet<std::pair<CanQualType, CanQualType>>
-        UserDefinedBinaryOperators;
+    llvm::DenseSet<std::pair<CanQualType, CanQualType> >
+      UserDefinedBinaryOperators;
 
     for (unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
       if (!CandidateTypes[ArgIdx].enumeration_types().empty()) {
         for (OverloadCandidateSet::iterator C = CandidateSet.begin(),
-                                            CEnd = CandidateSet.end();
+                                         CEnd = CandidateSet.end();
              C != CEnd; ++C) {
           if (!C->Viable || !C->Function || C->Function->getNumParams() != 2)
             continue;
@@ -9759,8 +9853,8 @@ class BuiltinOperatorOverloadBuilder {
 
           // Add this operator to the set of known user-defined operators.
           UserDefinedBinaryOperators.insert(
-              std::make_pair(S.Context.getCanonicalType(FirstParamType),
-                             S.Context.getCanonicalType(SecondParamType)));
+            std::make_pair(S.Context.getCanonicalType(FirstParamType),
+                           S.Context.getCanonicalType(SecondParamType)));
         }
       }
     }
@@ -9785,8 +9879,8 @@ class BuiltinOperatorOverloadBuilder {
         // Don't add the same builtin candidate twice, or if a user defined
         // candidate exists.
         if (!AddedTypes.insert(CanonType).second ||
-            UserDefinedBinaryOperators.count(
-                std::make_pair(CanonType, CanonType)))
+            UserDefinedBinaryOperators.count(std::make_pair(CanonType,
+                                                            CanonType)))
           continue;
         QualType ParamTypes[2] = {EnumTy, EnumTy};
         S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet);
@@ -9817,8 +9911,8 @@ class BuiltinOperatorOverloadBuilder {
 
     for (int Arg = 0; Arg < 2; ++Arg) {
       QualType AsymmetricParamTypes[2] = {
-          S.Context.getPointerDiffType(),
-          S.Context.getPointerDiffType(),
+        S.Context.getPointerDiffType(),
+        S.Context.getPointerDiffType(),
       };
       for (QualType PtrTy : CandidateTypes[Arg].pointer_types()) {
         QualType PointeeTy = PtrTy->getPointeeType();
@@ -9880,7 +9974,8 @@ class BuiltinOperatorOverloadBuilder {
          Left < LastPromotedArithmeticType; ++Left) {
       for (unsigned Right = FirstPromotedArithmeticType;
            Right < LastPromotedArithmeticType; ++Right) {
-        QualType LandR[2] = {ArithmeticTypes[Left], ArithmeticTypes[Right]};
+        QualType LandR[2] = { ArithmeticTypes[Left],
+                              ArithmeticTypes[Right] };
         S.AddBuiltinCandidate(LandR, Args, CandidateSet);
       }
     }
@@ -9972,7 +10067,8 @@ class BuiltinOperatorOverloadBuilder {
          Left < LastPromotedIntegralType; ++Left) {
       for (unsigned Right = FirstPromotedIntegralType;
            Right < LastPromotedIntegralType; ++Right) {
-        QualType LandR[2] = {ArithmeticTypes[Left], ArithmeticTypes[Right]};
+        QualType LandR[2] = { ArithmeticTypes[Left],
+                              ArithmeticTypes[Right] };
         S.AddBuiltinCandidate(LandR, Args, CandidateSet);
       }
     }
@@ -10039,7 +10135,7 @@ class BuiltinOperatorOverloadBuilder {
           isEqualOp ? PtrTy : S.Context.getPointerDiffType(),
       };
       S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet,
-                            /*IsAssignmentOperator=*/isEqualOp);
+                            /*IsAssignmentOperator=*/ isEqualOp);
 
       bool NeedVolatile = !PtrTy.isVolatileQualified() &&
                           VisibleTypeConversionsQuals.hasVolatile();
@@ -10218,7 +10314,7 @@ class BuiltinOperatorOverloadBuilder {
                           /*NumContextualBoolArguments=*/1);
   }
   void addAmpAmpOrPipePipeOverload() {
-    QualType ParamTypes[2] = {S.Context.BoolTy, S.Context.BoolTy};
+    QualType ParamTypes[2] = { S.Context.BoolTy, S.Context.BoolTy };
     S.AddBuiltinCandidate(ParamTypes, Args, CandidateSet,
                           /*IsAssignmentOperator=*/false,
                           /*NumContextualBoolArguments=*/2);
@@ -10372,12 +10468,15 @@ void Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
   SmallVector<BuiltinCandidateTypeSet, 2> CandidateTypes;
   for (unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
     CandidateTypes.emplace_back(*this);
-    CandidateTypes[ArgIdx].AddTypesConvertedFrom(
-        Args[ArgIdx]->getType(), OpLoc, true,
-        (Op == OO_Exclaim || Op == OO_AmpAmp || Op == OO_PipePipe),
-        VisibleTypeConversionsQuals);
-    HasNonRecordCandidateType =
-        HasNonRecordCandidateType || CandidateTypes[ArgIdx].hasNonRecordTypes();
+    CandidateTypes[ArgIdx].AddTypesConvertedFrom(Args[ArgIdx]->getType(),
+                                                 OpLoc,
+                                                 true,
+                                                 (Op == OO_Exclaim ||
+                                                  Op == OO_AmpAmp ||
+                                                  Op == OO_PipePipe),
+                                                 VisibleTypeConversionsQuals);
+    HasNonRecordCandidateType = HasNonRecordCandidateType ||
+        CandidateTypes[ArgIdx].hasNonRecordTypes();
     HasArithmeticOrEnumeralCandidateType =
         HasArithmeticOrEnumeralCandidateType ||
         CandidateTypes[ArgIdx].hasArithmeticOrEnumeralTypes();
@@ -10393,9 +10492,10 @@ void Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
     return;
 
   // Setup an object to manage the common state for building overloads.
-  BuiltinOperatorOverloadBuilder OpBuilder(
-      *this, Args, VisibleTypeConversionsQuals,
-      HasArithmeticOrEnumeralCandidateType, CandidateTypes, CandidateSet);
+  BuiltinOperatorOverloadBuilder OpBuilder(*this, Args,
+                                           VisibleTypeConversionsQuals,
+                                           HasArithmeticOrEnumeralCandidateType,
+                                           CandidateTypes, CandidateSet);
 
   // Dispatch over the operation to add in only those overloads which apply.
   switch (Op) {
@@ -10409,7 +10509,7 @@ void Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
   case OO_Array_Delete:
   case OO_Call:
     llvm_unreachable(
-        "Special operators don't use AddBuiltinOperatorCandidates");
+                    "Special operators don't use AddBuiltinOperatorCandidates");
 
   case OO_Comma:
   case OO_Arrow:
@@ -10544,10 +10644,13 @@ void Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
   }
 }
 
-void Sema::AddArgumentDependentLookupCandidates(
-    DeclarationName Name, SourceLocation Loc, ArrayRef<Expr *> Args,
-    TemplateArgumentListInfo *ExplicitTemplateArgs,
-    OverloadCandidateSet &CandidateSet, bool PartialOverloading) {
+void
+Sema::AddArgumentDependentLookupCandidates(DeclarationName Name,
+                                           SourceLocation Loc,
+                                           ArrayRef<Expr *> Args,
+                                 TemplateArgumentListInfo *ExplicitTemplateArgs,
+                                           OverloadCandidateSet& CandidateSet,
+                                           bool PartialOverloading) {
   ADLResult Fns;
 
   // FIXME: This approach for uniquing ADL results (and removing
@@ -10564,7 +10667,7 @@ void Sema::AddArgumentDependentLookupCandidates(
 
   // Erase all of the candidates we already knew about.
   for (OverloadCandidateSet::iterator Cand = CandidateSet.begin(),
-                                      CandEnd = CandidateSet.end();
+                                   CandEnd = CandidateSet.end();
        Cand != CandEnd; ++Cand)
     if (Cand->Function) {
       FunctionDecl *Fn = Cand->Function;
@@ -10972,8 +11075,9 @@ bool clang::isBetterOverloadCandidate(
   //   conversion sequence than ICSi(F2), and then...
   bool HasWorseConversion = false;
   for (unsigned ArgIdx = StartArg; ArgIdx < NumArgs; ++ArgIdx) {
-    switch (CompareImplicitConversionSequences(
-        S, Loc, Cand1.Conversions[ArgIdx], Cand2.Conversions[ArgIdx])) {
+    switch (CompareImplicitConversionSequences(S, Loc,
+                                               Cand1.Conversions[ArgIdx],
+                                               Cand2.Conversions[ArgIdx])) {
     case ImplicitConversionSequence::Better:
       // Cand1 has a better conversion sequence.
       HasBetterConversion = true;
@@ -11032,7 +11136,8 @@ bool clang::isBetterOverloadCandidate(
     ImplicitConversionSequence::CompareKind Result =
         compareConversionFunctions(S, Cand1.Function, Cand2.Function);
     if (Result == ImplicitConversionSequence::Indistinguishable)
-      Result = CompareStandardConversionSequences(S, Loc, Cand1.FinalConversion,
+      Result = CompareStandardConversionSequences(S, Loc,
+                                                  Cand1.FinalConversion,
                                                   Cand2.FinalConversion);
 
     if (Result != ImplicitConversionSequence::Indistinguishable)
@@ -11060,10 +11165,10 @@ bool clang::isBetterOverloadCandidate(
 
   //    -- F1 is a non-template function and F2 is a function template
   //       specialization, or, if not that,
-  bool Cand1IsSpecialization =
-      Cand1.Function && Cand1.Function->getPrimaryTemplate();
-  bool Cand2IsSpecialization =
-      Cand2.Function && Cand2.Function->getPrimaryTemplate();
+  bool Cand1IsSpecialization = Cand1.Function &&
+                               Cand1.Function->getPrimaryTemplate();
+  bool Cand2IsSpecialization = Cand2.Function &&
+                               Cand2.Function->getPrimaryTemplate();
   if (Cand1IsSpecialization != Cand2IsSpecialization)
     return Cand2IsSpecialization;
 
@@ -11226,8 +11331,8 @@ bool Sema::isEquivalentInternalLinkageDeclaration(const NamedDecl *A,
   // entity in different modules.
   if (!VA->getDeclContext()->getRedeclContext()->Equals(
           VB->getDeclContext()->getRedeclContext()) ||
-      getOwningModule(VA) == getOwningModule(VB) || VA->isExternallyVisible() ||
-      VB->isExternallyVisible())
+      getOwningModule(VA) == getOwningModule(VB) ||
+      VA->isExternallyVisible() || VB->isExternallyVisible())
     return false;
 
   // Check that the declarations appear to be equivalent.
@@ -11656,7 +11761,7 @@ void MaybeEmitInheritedConstructorNote(Sema &S, const Decl *FoundDecl) {
   if (const auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl))
     S.Diag(FoundDecl->getLocation(),
            diag::note_ovl_candidate_inherited_constructor)
-        << Shadow->getNominatedBaseClass();
+      << Shadow->getNominatedBaseClass();
 }
 
 } // end anonymous namespace
@@ -11865,14 +11970,14 @@ void Sema::NoteAllOverloadCandidates(Expr *OverloadedExpr, QualType DestType,
   OverloadExpr *OvlExpr = Ovl.Expression;
 
   for (UnresolvedSetIterator I = OvlExpr->decls_begin(),
-                             IEnd = OvlExpr->decls_end();
+                            IEnd = OvlExpr->decls_end();
        I != IEnd; ++I) {
     if (FunctionTemplateDecl *FunTmpl =
-            dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl())) {
+                dyn_cast<FunctionTemplateDecl>((*I)->getUnderlyingDecl()) ) {
       NoteOverloadCandidate(*I, FunTmpl->getTemplatedDecl(), CRK_None, DestType,
                             TakingAddress);
-    } else if (FunctionDecl *Fun =
-                   dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl())) {
+    } else if (FunctionDecl *Fun
+                      = dyn_cast<FunctionDecl>((*I)->getUnderlyingDecl()) ) {
       NoteOverloadCandidate(*I, Fun, CRK_None, DestType, TakingAddress);
     }
   }
@@ -11882,8 +11987,11 @@ void Sema::NoteAllOverloadCandidates(Expr *OverloadedExpr, QualType DestType,
 /// "lead" diagnostic; it will be given two arguments, the source and
 /// target types of the conversion.
 void ImplicitConversionSequence::DiagnoseAmbiguousConversion(
-    Sema &S, SourceLocation CaretLoc, const PartialDiagnostic &PDiag) const {
-  S.Diag(CaretLoc, PDiag) << Ambiguous.getFromType() << Ambiguous.getToType();
+                                 Sema &S,
+                                 SourceLocation CaretLoc,
+                                 const PartialDiagnostic &PDiag) const {
+  S.Diag(CaretLoc, PDiag)
+    << Ambiguous.getFromType() << Ambiguous.getToType();
   unsigned CandsShown = 0;
   AmbiguousConversionSequence::const_iterator I, E;
   for (I = Ambiguous.begin(), E = Ambiguous.end(); I != E; ++I) {
@@ -11897,8 +12005,8 @@ void ImplicitConversionSequence::DiagnoseAmbiguousConversion(
     S.Diag(SourceLocation(), diag::note_ovl_too_many_candidates) << int(E - I);
 }
 
-static void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand, unsigned I,
-                                  bool TakingCandidateAddress) {
+static void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand,
+                                  unsigned I, bool TakingCandidateAddress) {
   const ImplicitConversionSequence &Conv = Cand->Conversions[I];
   assert(Conv.isBad());
   assert(Cand->Function && "for now, candidate must be a function");
@@ -12082,10 +12190,10 @@ static void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand, unsigned I,
                           FromPtrTy->getPointeeType()))
         BaseToDerivedConversion = 1;
     }
-  } else if (const ObjCObjectPointerType *FromPtrTy =
-                 FromTy->getAs<ObjCObjectPointerType>()) {
-    if (const ObjCObjectPointerType *ToPtrTy =
-            ToTy->getAs<ObjCObjectPointerType>())
+  } else if (const ObjCObjectPointerType *FromPtrTy
+                                    = FromTy->getAs<ObjCObjectPointerType>()) {
+    if (const ObjCObjectPointerType *ToPtrTy
+                                        = ToTy->getAs<ObjCObjectPointerType>())
       if (const ObjCInterfaceDecl *FromIface = FromPtrTy->getInterfaceDecl())
         if (const ObjCInterfaceDecl *ToIface = ToPtrTy->getInterfaceDecl())
           if (ToPtrTy->getPointeeType().isAtLeastAsQualifiedAs(
@@ -12111,7 +12219,8 @@ static void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand, unsigned I,
     return;
   }
 
-  if (isa<ObjCObjectPointerType>(CFromTy) && isa<PointerType>(CToTy)) {
+  if (isa<ObjCObjectPointerType>(CFromTy) &&
+      isa<PointerType>(CToTy)) {
     Qualifiers FromQs = CFromTy.getQualifiers();
     Qualifiers ToQs = CToTy.getQualifiers();
     if (FromQs.getObjCLifetime() != ToQs.getObjCLifetime()) {
@@ -12147,7 +12256,7 @@ static void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand, unsigned I,
   if (!S.SourceMgr.isInSystemHeader(Fn->getLocation())) {
     // If we can fix the conversion, suggest the FixIts.
     for (const FixItHint &HI : Cand->Fix.Hints)
-      FDiag << HI;
+        FDiag << HI;
   }
 
   S.Diag(Fn->getLocation(), FDiag);
@@ -12194,9 +12303,9 @@ static void DiagnoseArityMismatch(Sema &S, NamedDecl *Found, Decl *D,
                                   unsigned NumFormalArgs,
                                   bool IsAddressOf = false) {
   assert(isa<FunctionDecl>(D) &&
-         "The templated declaration should at least be a function"
-         " when diagnosing bad template argument deduction due to too many"
-         " or too few arguments");
+      "The templated declaration should at least be a function"
+      " when diagnosing bad template argument deduction due to too many"
+      " or too few arguments");
 
   FunctionDecl *Fn = cast<FunctionDecl>(D);
 
@@ -12274,9 +12383,9 @@ static void DiagnoseBadDeduction(Sema &S, NamedDecl *Found, Decl *Templated,
                                  bool TakingCandidateAddress) {
   TemplateParameter Param = DeductionFailure.getTemplateParameter();
   NamedDecl *ParamD;
-  (ParamD = Param.dyn_cast<TemplateTypeParmDecl *>()) ||
-      (ParamD = Param.dyn_cast<NonTypeTemplateParmDecl *>()) ||
-      (ParamD = Param.dyn_cast<TemplateTemplateParmDecl *>());
+  (ParamD = Param.dyn_cast<TemplateTypeParmDecl*>()) ||
+  (ParamD = Param.dyn_cast<NonTypeTemplateParmDecl*>()) ||
+  (ParamD = Param.dyn_cast<TemplateTemplateParmDecl*>());
   switch (DeductionFailure.getResult()) {
   case TemplateDeductionResult::Success:
     llvm_unreachable(
@@ -12349,8 +12458,8 @@ static void DiagnoseBadDeduction(Sema &S, NamedDecl *Found, Decl *Templated,
       if (!T1.isNull() && !T2.isNull() && !S.Context.hasSameType(T1, T2)) {
         S.Diag(Templated->getLocation(),
                diag::note_ovl_candidate_inconsistent_deduction_types)
-            << ParamD->getDeclName() << *DeductionFailure.getFirstArg() << T1
-            << *DeductionFailure.getSecondArg() << T2;
+          << ParamD->getDeclName() << *DeductionFailure.getFirstArg() << T1
+          << *DeductionFailure.getSecondArg() << T2;
         MaybeEmitInheritedConstructorNote(S, Found);
         return;
       }
@@ -12388,8 +12497,8 @@ static void DiagnoseBadDeduction(Sema &S, NamedDecl *Found, Decl *Templated,
       int index = 0;
       if (TemplateTypeParmDecl *TTP = dyn_cast<TemplateTypeParmDecl>(ParamD))
         index = TTP->getIndex();
-      else if (NonTypeTemplateParmDecl *NTTP =
-                   dyn_cast<NonTypeTemplateParmDecl>(ParamD))
+      else if (NonTypeTemplateParmDecl *NTTP
+                                  = dyn_cast<NonTypeTemplateParmDecl>(ParamD))
         index = NTTP->getIndex();
       else
         index = cast<TemplateTemplateParmDecl>(ParamD)->getIndex();
@@ -12414,7 +12523,7 @@ static void DiagnoseBadDeduction(Sema &S, NamedDecl *Found, Decl *Templated,
         << TemplateArgString;
 
     S.DiagnoseUnsatisfiedConstraint(
-        static_cast<CNSInfo *>(DeductionFailure.Data)->Satisfaction);
+        static_cast<CNSInfo*>(DeductionFailure.Data)->Satisfaction);
     return;
   }
   case TemplateDeductionResult::TooManyArguments:
@@ -12443,20 +12552,20 @@ static void DiagnoseBadDeduction(Sema &S, NamedDecl *Found, Decl *Templated,
     // If this candidate was disabled by enable_if, say so.
     PartialDiagnosticAt *PDiag = DeductionFailure.getSFINAEDiagnostic();
     if (PDiag && PDiag->second.getDiagID() ==
-                     diag::err_typename_nested_not_found_enable_if) {
+          diag::err_typename_nested_not_found_enable_if) {
       // FIXME: Use the source range of the condition, and the fully-qualified
       //        name of the enable_if template. These are both present in PDiag.
       S.Diag(PDiag->first, diag::note_ovl_candidate_disabled_by_enable_if)
-          << "'enable_if'" << TemplateArgString;
+        << "'enable_if'" << TemplateArgString;
       return;
     }
 
     // We found a specific requirement that disabled the enable_if.
     if (PDiag && PDiag->second.getDiagID() ==
-                     diag::err_typename_nested_not_found_requirement) {
+        diag::err_typename_nested_not_found_requirement) {
       S.Diag(Templated->getLocation(),
              diag::note_ovl_candidate_disabled_by_requirement)
-          << PDiag->second.getStringArg(0) << TemplateArgString;
+        << PDiag->second.getStringArg(0) << TemplateArgString;
       return;
     }
 
@@ -12631,7 +12740,7 @@ static void DiagnoseBadTarget(Sema &S, OverloadCandidate *Cand) {
 static void DiagnoseFailedEnableIfAttr(Sema &S, OverloadCandidate *Cand) {
   assert(Cand->Function && "Candidate must be a function");
   FunctionDecl *Callee = Cand->Function;
-  EnableIfAttr *Attr = static_cast<EnableIfAttr *>(Cand->DeductionFailure.Data);
+  EnableIfAttr *Attr = static_cast<EnableIfAttr*>(Cand->DeductionFailure.Data);
 
   S.Diag(Callee->getLocation(),
          diag::note_ovl_candidate_disabled_by_function_cond_attr)
@@ -12667,7 +12776,8 @@ static void DiagnoseFailedExplicitSpec(Sema &S, OverloadCandidate *Cand) {
   if (FunctionDecl *Pattern = First->getTemplateInstantiationPattern())
     First = Pattern->getFirstDecl();
 
-  S.Diag(First->getLocation(), diag::note_ovl_candidate_explicit)
+  S.Diag(First->getLocation(),
+         diag::note_ovl_candidate_explicit)
       << Kind << (ES.getExpr() ? 1 : 0)
       << (ES.getExpr() ? ES.getExpr()->getSourceRange() : SourceRange());
 }
@@ -12728,7 +12838,8 @@ static void NoteImplicitDeductionGuide(Sema &S, FunctionDecl *Fn) {
 /// \param CtorDestAS Addr space of object being constructed (for ctor
 /// candidates only).
 static void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand,
-                                  unsigned NumArgs, bool TakingCandidateAddress,
+                                  unsigned NumArgs,
+                                  bool TakingCandidateAddress,
                                   LangAS CtorDestAS = LangAS::Default) {
   assert(Cand->Function && "Candidate must be a function");
   FunctionDecl *Fn = Cand->Function;
@@ -12787,11 +12898,12 @@ static void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand,
     return DiagnoseArityMismatch(S, Cand, NumArgs);
 
   case ovl_fail_bad_deduction:
-    return DiagnoseBadDeduction(S, Cand, NumArgs, TakingCandidateAddress);
+    return DiagnoseBadDeduction(S, Cand, NumArgs,
+                                TakingCandidateAddress);
 
   case ovl_fail_illegal_constructor: {
     S.Diag(Fn->getLocation(), diag::note_ovl_candidate_illegal_constructor)
-        << (Fn->getPrimaryTemplate() ? 1 : 0);
+      << (Fn->getPrimaryTemplate() ? 1 : 0);
     MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl);
     return;
   }
@@ -12838,8 +12950,8 @@ static void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand,
       return;
     S.Diag(Fn->getLocation(),
            diag::note_ovl_candidate_inherited_constructor_slice)
-        << (Fn->getPrimaryTemplate() ? 1 : 0)
-        << Fn->getParamDecl(0)->getType()->isRValueReferenceType();
+      << (Fn->getPrimaryTemplate() ? 1 : 0)
+      << Fn->getParamDecl(0)->getType()->isRValueReferenceType();
     MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl);
     return;
 
@@ -12884,11 +12996,11 @@ static void NoteSurrogateCandidate(Sema &S, OverloadCandidate *Cand) {
   bool isRValueReference = false;
   bool isPointer = false;
   if (const LValueReferenceType *FnTypeRef =
-          FnType->getAs<LValueReferenceType>()) {
+        FnType->getAs<LValueReferenceType>()) {
     FnType = FnTypeRef->getPointeeType();
     isLValueReference = true;
   } else if (const RValueReferenceType *FnTypeRef =
-                 FnType->getAs<RValueReferenceType>()) {
+               FnType->getAs<RValueReferenceType>()) {
     FnType = FnTypeRef->getPointeeType();
     isRValueReference = true;
   }
@@ -12899,12 +13011,9 @@ static void NoteSurrogateCandidate(Sema &S, OverloadCandidate *Cand) {
   // Desugar down to a function type.
   FnType = QualType(FnType->getAs<FunctionType>(), 0);
   // Reconstruct the pointer/reference as appropriate.
-  if (isPointer)
-    FnType = S.Context.getPointerType(FnType);
-  if (isRValueReference)
-    FnType = S.Context.getRValueReferenceType(FnType);
-  if (isLValueReference)
-    FnType = S.Context.getLValueReferenceType(FnType);
+  if (isPointer) FnType = S.Context.getPointerType(FnType);
+  if (isRValueReference) FnType = S.Context.getRValueReferenceType(FnType);
+  if (isLValueReference) FnType = S.Context.getLValueReferenceType(FnType);
 
   if (!Cand->Viable &&
       Cand->FailureKind == ovl_fail_constraints_not_satisfied) {
@@ -12942,10 +13051,8 @@ static void NoteBuiltinOperatorCandidate(Sema &S, StringRef Opc,
 static void NoteAmbiguousUserConversions(Sema &S, SourceLocation OpLoc,
                                          OverloadCandidate *Cand) {
   for (const ImplicitConversionSequence &ICS : Cand->Conversions) {
-    if (ICS.isBad())
-      break; // all meaningless after first invalid
-    if (!ICS.isAmbiguous())
-      continue;
+    if (ICS.isBad()) break; // all meaningless after first invalid
+    if (!ICS.isAmbiguous()) continue;
 
     ICS.DiagnoseAmbiguousConversion(
         S, OpLoc, S.PDiag(diag::note_ambiguous_type_conversion));
@@ -13028,15 +13135,14 @@ struct CompareOverloadCandidatesForDisplay {
     return static_cast<OverloadFailureKind>(C->FailureKind);
   }
 
-  bool operator()(const OverloadCandidate *L, const OverloadCandidate *R) {
+  bool operator()(const OverloadCandidate *L,
+                  const OverloadCandidate *R) {
     // Fast-path this check.
-    if (L == R)
-      return false;
+    if (L == R) return false;
 
     // Order first by viability.
     if (L->Viable) {
-      if (!R->Viable)
-        return true;
+      if (!R->Viable) return true;
 
       if (int Ord = CompareConversions(*L, *R))
         return Ord < 0;
@@ -13180,7 +13286,7 @@ struct CompareOverloadCandidatesForDisplay {
     return 0;
   }
 };
-} // namespace
+}
 
 /// CompleteNonViableCandidate - Normally, overload resolution only
 /// computes up to the first bad conversion. Produces the FixIt set if
@@ -13224,8 +13330,8 @@ CompleteNonViableCandidate(Sema &S, OverloadCandidate *Cand,
   bool Reversed = Cand->isReversed();
 
   if (Cand->IsSurrogate) {
-    QualType ConvType =
-        Cand->Surrogate->getConversionType().getNonReferenceType();
+    QualType ConvType
+      = Cand->Surrogate->getConversionType().getNonReferenceType();
     if (const PointerType *ConvPtrType = ConvType->getAs<PointerType>())
       ConvType = ConvPtrType->getPointeeType();
     ParamTypes = ConvType->castAs<FunctionProtoType>()->getParamTypes();
@@ -13263,11 +13369,12 @@ CompleteNonViableCandidate(Sema &S, OverloadCandidate *Cand,
         Cand->Conversions[ConvIdx].setAsIdentityConversion(
             Args[ArgIdx]->getType());
       else {
-        Cand->Conversions[ConvIdx] = TryCopyInitialization(
-            S, Args[ArgIdx], ParamTypes[ParamIdx], SuppressUserConversions,
-            /*InOverloadResolution=*/true,
-            /*AllowObjCWritebackConversion=*/
-            S.getLangOpts().ObjCAutoRefCount);
+        Cand->Conversions[ConvIdx] =
+            TryCopyInitialization(S, Args[ArgIdx], ParamTypes[ParamIdx],
+                                  SuppressUserConversions,
+                                  /*InOverloadResolution=*/true,
+                                  /*AllowObjCWritebackConversion=*/
+                                  S.getLangOpts().ObjCAutoRefCount);
         // Store the FixIt in the candidate if it exists.
         if (!Unfixable && Cand->Conversions[ConvIdx].isBad())
           Unfixable = !Cand->TryToFixBadConversion(ConvIdx, S);
@@ -13286,9 +13393,8 @@ SmallVector<OverloadCandidate *, 32> OverloadCandidateSet::CompleteCandidates(
 
   // Sort the candidates by viability and position.  Sorting directly would
   // be prohibitive, so we make a set of pointers and sort those.
-  SmallVector<OverloadCandidate *, 32> Cands;
-  if (OCD == OCD_AllCandidates)
-    Cands.reserve(size());
+  SmallVector<OverloadCandidate*, 32> Cands;
+  if (OCD == OCD_AllCandidates) Cands.reserve(size());
   for (iterator Cand = Candidates.begin(), LastCand = Candidates.end();
        Cand != LastCand; ++Cand) {
     if (!Filter(*Cand))
@@ -13462,7 +13568,7 @@ struct CompareTemplateSpecCandidatesForDisplay {
     return S.SourceMgr.isBeforeInTranslationUnit(LLoc, RLoc);
   }
 };
-} // namespace
+}
 
 /// Diagnose a template argument deduction failure.
 /// We are treating these failures as overload failures due to bad
@@ -13538,15 +13644,16 @@ void TemplateSpecCandidateSet::NoteCandidates(Sema &S, SourceLocation Loc) {
 QualType Sema::ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType) {
   QualType Ret = PossiblyAFunctionType;
   if (const PointerType *ToTypePtr =
-          PossiblyAFunctionType->getAs<PointerType>())
+    PossiblyAFunctionType->getAs<PointerType>())
     Ret = ToTypePtr->getPointeeType();
   else if (const ReferenceType *ToTypeRef =
-               PossiblyAFunctionType->getAs<ReferenceType>())
+    PossiblyAFunctionType->getAs<ReferenceType>())
     Ret = ToTypeRef->getPointeeType();
   else if (const MemberPointerType *MemTypePtr =
-               PossiblyAFunctionType->getAs<MemberPointerType>())
+    PossiblyAFunctionType->getAs<MemberPointerType>())
     Ret = MemTypePtr->getPointeeType();
-  Ret = Context.getCanonicalType(Ret).getUnqualifiedType();
+  Ret =
+    Context.getCanonicalType(Ret).getUnqualifiedType();
   return Ret;
 }
 
@@ -13569,14 +13676,14 @@ namespace {
 // A helper class to help with address of function resolution
 // - allows us to avoid passing around all those ugly parameters
 class AddressOfFunctionResolver {
-  Sema &S;
-  Expr *SourceExpr;
-  const QualType &TargetType;
+  Sema& S;
+  Expr* SourceExpr;
+  const QualType& TargetType;
   QualType TargetFunctionType; // Extracted function type from target type
 
   bool Complain;
-  // DeclAccessPair& ResultFunctionAccessPair;
-  ASTContext &Context;
+  //DeclAccessPair& ResultFunctionAccessPair;
+  ASTContext& Context;
 
   bool TargetTypeIsNonStaticMemberFunction;
   bool FoundNonTemplateFunction;
@@ -13586,7 +13693,7 @@ class AddressOfFunctionResolver {
   OverloadExpr::FindResult OvlExprInfo;
   OverloadExpr *OvlExpr;
   TemplateArgumentListInfo OvlExplicitTemplateArgs;
-  SmallVector<std::pair<DeclAccessPair, FunctionDecl *>, 4> Matches;
+  SmallVector<std::pair<DeclAccessPair, FunctionDecl*>, 4> Matches;
   TemplateSpecCandidateSet FailedCandidates;
 
 public:
@@ -13597,7 +13704,8 @@ class AddressOfFunctionResolver {
         TargetTypeIsNonStaticMemberFunction(
             !!TargetType->getAs<MemberPointerType>()),
         FoundNonTemplateFunction(false),
-        StaticMemberFunctionFromBoundPointer(false), HasComplained(false),
+        StaticMemberFunctionFromBoundPointer(false),
+        HasComplained(false),
         OvlExprInfo(OverloadExpr::find(SourceExpr)),
         OvlExpr(OvlExprInfo.Expression),
         FailedCandidates(OvlExpr->getNameLoc(), /*ForTakingAddress=*/true) {
@@ -13674,16 +13782,15 @@ class AddressOfFunctionResolver {
     // Same algorithm as overload resolution -- one pass to pick the "best",
     // another pass to be sure that nothing is better than the best.
     auto Best = Matches.begin();
-    for (auto I = Matches.begin() + 1, E = Matches.end(); I != E; ++I)
+    for (auto I = Matches.begin()+1, E = Matches.end(); I != E; ++I)
       if (isBetterCandidate(I->second, Best->second))
         Best = I;
 
     const FunctionDecl *BestFn = Best->second;
-    auto IsBestOrInferiorToBest =
-        [this, BestFn](const std::pair<DeclAccessPair, FunctionDecl *> &Pair) {
-          return BestFn == Pair.second ||
-                 isBetterCandidate(BestFn, Pair.second);
-        };
+    auto IsBestOrInferiorToBest = [this, BestFn](
+        const std::pair<DeclAccessPair, FunctionDecl *> &Pair) {
+      return BestFn == Pair.second || isBetterCandidate(BestFn, Pair.second);
+    };
 
     // Note: We explicitly leave Matches unmodified if there isn't a clear best
     // option, so we can potentially give the user a better error
@@ -13708,17 +13815,18 @@ class AddressOfFunctionResolver {
   }
 
   // return true if any matching specializations were found
-  bool AddMatchingTemplateFunction(FunctionTemplateDecl *FunctionTemplate,
-                                   const DeclAccessPair &CurAccessFunPair) {
-    if (CXXMethodDecl *Method =
-            dyn_cast<CXXMethodDecl>(FunctionTemplate->getTemplatedDecl())) {
+  bool AddMatchingTemplateFunction(FunctionTemplateDecl* FunctionTemplate,
+                                   const DeclAccessPair& CurAccessFunPair) {
+    if (CXXMethodDecl *Method
+              = dyn_cast<CXXMethodDecl>(FunctionTemplate->getTemplatedDecl())) {
       // Skip non-static function templates when converting to pointer, and
       // static when converting to member pointer.
       bool CanConvertToFunctionPointer =
           Method->isStatic() || Method->isExplicitObjectMemberFunction();
       if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
         return false;
-    } else if (TargetTypeIsNonStaticMemberFunction)
+    }
+    else if (TargetTypeIsNonStaticMemberFunction)
       return false;
 
     // C++ [over.over]p2:
@@ -13734,9 +13842,9 @@ class AddressOfFunctionResolver {
             Specialization, Info, /*IsAddressOfFunction*/ true);
         Result != TemplateDeductionResult::Success) {
       // Make a note of the failed deduction for diagnostics.
-      FailedCandidates.addCandidate().set(
-          CurAccessFunPair, FunctionTemplate->getTemplatedDecl(),
-          MakeDeductionFailureInfo(Context, Result, Info));
+      FailedCandidates.addCandidate()
+          .set(CurAccessFunPair, FunctionTemplate->getTemplatedDecl(),
+               MakeDeductionFailureInfo(Context, Result, Info));
       return false;
     }
 
@@ -13744,8 +13852,8 @@ class AddressOfFunctionResolver {
     // compatible pointer-to-function arguments that would be adjusted by ICS.
     // This function template specicalization works.
     assert(S.isSameOrCompatibleFunctionType(
-        Context.getCanonicalType(Specialization->getType()),
-        Context.getCanonicalType(TargetFunctionType)));
+              Context.getCanonicalType(Specialization->getType()),
+              Context.getCanonicalType(TargetFunctionType)));
 
     if (!S.checkAddressOfFunctionIsAvailable(Specialization))
       return false;
@@ -13754,8 +13862,8 @@ class AddressOfFunctionResolver {
     return true;
   }
 
-  bool AddMatchingNonTemplateFunction(NamedDecl *Fn,
-                                      const DeclAccessPair &CurAccessFunPair) {
+  bool AddMatchingNonTemplateFunction(NamedDecl* Fn,
+                                      const DeclAccessPair& CurAccessFunPair) {
     if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Fn)) {
       // Skip non-static functions when converting to pointer, and static
       // when converting to member pointer.
@@ -13763,7 +13871,8 @@ class AddressOfFunctionResolver {
           Method->isStatic() || Method->isExplicitObjectMemberFunction();
       if (CanConvertToFunctionPointer == TargetTypeIsNonStaticMemberFunction)
         return false;
-    } else if (TargetTypeIsNonStaticMemberFunction)
+    }
+    else if (TargetTypeIsNonStaticMemberFunction)
       return false;
 
     if (FunctionDecl *FunDecl = dyn_cast<FunctionDecl>(Fn)) {
@@ -13826,8 +13935,8 @@ class AddressOfFunctionResolver {
       //   Nonstatic member functions match targets of
       //   type "pointer-to-member-function."
       // Note that according to DR 247, the containing class does not matter.
-      if (FunctionTemplateDecl *FunctionTemplate =
-              dyn_cast<FunctionTemplateDecl>(Fn)) {
+      if (FunctionTemplateDecl *FunctionTemplate
+                                        = dyn_cast<FunctionTemplateDecl>(Fn)) {
         if (AddMatchingTemplateFunction(FunctionTemplate, I.getPair()))
           Ret = true;
       }
@@ -13879,7 +13988,7 @@ class AddressOfFunctionResolver {
   void EliminateAllTemplateMatches() {
     //   [...] any function template specializations in the set are
     //   eliminated if the set also contains a non-template function, [...]
-    for (unsigned I = 0, N = Matches.size(); I != N;) {
+    for (unsigned I = 0, N = Matches.size(); I != N; ) {
       if (Matches[I].second->getPrimaryTemplate() == nullptr)
         ++I;
       else {
@@ -13948,14 +14057,14 @@ class AddressOfFunctionResolver {
 
   bool IsInvalidFormOfPointerToMemberFunction() const {
     return TargetTypeIsNonStaticMemberFunction &&
-           !OvlExprInfo.HasFormOfMemberPointer;
+      !OvlExprInfo.HasFormOfMemberPointer;
   }
 
   void ComplainIsInvalidFormOfPointerToMemberFunction() const {
-    // TODO: Should we condition this on whether any functions might
-    // have matched, or is it more appropriate to do that in callers?
-    // TODO: a fixit wouldn't hurt.
-    S.Diag(OvlExpr->getNameLoc(), diag::err_addr_ovl_no_qualifier)
+      // TODO: Should we condition this on whether any functions might
+      // have matched, or is it more appropriate to do that in callers?
+      // TODO: a fixit wouldn't hurt.
+      S.Diag(OvlExpr->getNameLoc(), diag::err_addr_ovl_no_qualifier)
         << TargetType << OvlExpr->getSourceRange();
   }
 
@@ -13986,23 +14095,24 @@ class AddressOfFunctionResolver {
 
   int getNumMatches() const { return Matches.size(); }
 
-  FunctionDecl *getMatchingFunctionDecl() const {
-    if (Matches.size() != 1)
-      return nullptr;
+  FunctionDecl* getMatchingFunctionDecl() const {
+    if (Matches.size() != 1) return nullptr;
     return Matches[0].second;
   }
 
-  const DeclAccessPair *getMatchingFunctionAccessPair() const {
-    if (Matches.size() != 1)
-      return nullptr;
+  const DeclAccessPair* getMatchingFunctionAccessPair() const {
+    if (Matches.size() != 1) return nullptr;
     return &Matches[0].first;
   }
 };
-} // namespace
+}
 
-FunctionDecl *Sema::ResolveAddressOfOverloadedFunction(
-    Expr *AddressOfExpr, QualType TargetType, bool Complain,
-    DeclAccessPair &FoundResult, bool *pHadMultipleCandidates) {
+FunctionDecl *
+Sema::ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr,
+                                         QualType TargetType,
+                                         bool Complain,
+                                         DeclAccessPair &FoundResult,
+                                         bool *pHadMultipleCandidates) {
   assert(AddressOfExpr->getType() == Context.OverloadTy);
 
   AddressOfFunctionResolver Resolver(*this, AddressOfExpr, TargetType,
@@ -14015,7 +14125,8 @@ FunctionDecl *Sema::ResolveAddressOfOverloadedFunction(
       Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
     else
       Resolver.ComplainNoMatchesFound();
-  } else if (NumMatches > 1 && ShouldComplain)
+  }
+  else if (NumMatches > 1 && ShouldComplain)
     Resolver.ComplainMultipleMatchesFound();
   else if (NumMatches == 1) {
     Fn = Resolver.getMatchingFunctionDecl();
@@ -14176,8 +14287,8 @@ FunctionDecl *Sema::ResolveSingleFunctionTemplateSpecialization(
   // Look through all of the overloaded functions, searching for one
   // whose type matches exactly.
   FunctionDecl *Matched = nullptr;
-  for (UnresolvedSetIterator I = ovl->decls_begin(), E = ovl->decls_end();
-       I != E; ++I) {
+  for (UnresolvedSetIterator I = ovl->decls_begin(),
+         E = ovl->decls_end(); I != E; ++I) {
     // C++0x [temp.arg.explicit]p3:
     //   [...] In contexts where deduction is done and fails, or in contexts
     //   where deduction is not done, if a template argument list is
@@ -14222,15 +14333,15 @@ FunctionDecl *Sema::ResolveSingleFunctionTemplateSpecialization(
         continue;
       // Multiple matches; we can't resolve to a single declaration.
       if (Complain) {
-        Diag(ovl->getExprLoc(), diag::err_addr_ovl_ambiguous) << ovl->getName();
+        Diag(ovl->getExprLoc(), diag::err_addr_ovl_ambiguous)
+          << ovl->getName();
         NoteAllOverloadCandidates(ovl);
       }
       return nullptr;
     }
 
     Matched = Specialization;
-    if (FoundResult)
-      *FoundResult = I.getPair();
+    if (FoundResult) *FoundResult = I.getPair();
   }
 
   if (Matched &&
@@ -14251,7 +14362,7 @@ bool Sema::ResolveAndFixSingleFunctionTemplateSpecialization(
   DeclAccessPair found;
   ExprResult SingleFunctionExpression;
   if (FunctionDecl *fn = ResolveSingleFunctionTemplateSpecialization(
-          ovl.Expression, /*complain*/ false, &found)) {
+                           ovl.Expression, /*complain*/ false, &found)) {
     if (DiagnoseUseOfDecl(fn, SrcExpr.get()->getBeginLoc())) {
       SrcExpr = ExprError();
       return true;
@@ -14261,13 +14372,14 @@ bool Sema::ResolveAndFixSingleFunctionTemplateSpecialization(
     // resolving a form that's permitted to be a pointer to member.
     // Otherwise we'll end up making a bound member expression, which
     // is illegal in all the contexts we resolve like this.
-    if (!ovl.HasFormOfMemberPointer && isa<CXXMethodDecl>(fn) &&
+    if (!ovl.HasFormOfMemberPointer &&
+        isa<CXXMethodDecl>(fn) &&
         cast<CXXMethodDecl>(fn)->isInstance()) {
-      if (!complain)
-        return false;
+      if (!complain) return false;
 
-      Diag(ovl.Expression->getExprLoc(), diag::err_bound_member_function)
-          << 0 << ovl.Expression->getSourceRange();
+      Diag(ovl.Expression->getExprLoc(),
+           diag::err_bound_member_function)
+        << 0 << ovl.Expression->getSourceRange();
 
       // TODO: I believe we only end up here if there's a mix of
       // static and non-static candidates (otherwise the expression
@@ -14285,7 +14397,7 @@ bool Sema::ResolveAndFixSingleFunctionTemplateSpecialization(
     // If desired, do function-to-pointer decay.
     if (doFunctionPointerConversion) {
       SingleFunctionExpression =
-          DefaultFunctionArrayLvalueConversion(SingleFunctionExpression.get());
+        DefaultFunctionArrayLvalueConversion(SingleFunctionExpression.get());
       if (SingleFunctionExpression.isInvalid()) {
         SrcExpr = ExprError();
         return true;
@@ -14296,9 +14408,10 @@ bool Sema::ResolveAndFixSingleFunctionTemplateSpecialization(
   if (!SingleFunctionExpression.isUsable()) {
     if (complain) {
       Diag(OpRangeForComplaining.getBegin(), DiagIDForComplaining)
-          << ovl.Expression->getName() << DestTypeForComplaining
-          << OpRangeForComplaining
-          << ovl.Expression->getQualifierLoc().getSourceRange();
+        << ovl.Expression->getName()
+        << DestTypeForComplaining
+        << OpRangeForComplaining
+        << ovl.Expression->getQualifierLoc().getSourceRange();
       NoteAllOverloadCandidates(SrcExpr.get());
 
       SrcExpr = ExprError();
@@ -14313,12 +14426,13 @@ bool Sema::ResolveAndFixSingleFunctionTemplateSpecialization(
 }
 
 /// Add a single candidate to the overload set.
-static void
-AddOverloadedCallCandidate(Sema &S, DeclAccessPair FoundDecl,
-                           TemplateArgumentListInfo *ExplicitTemplateArgs,
-                           ArrayRef<Expr *> Args,
-                           OverloadCandidateSet &CandidateSet,
-                           bool PartialOverloading, bool KnownValid) {
+static void AddOverloadedCallCandidate(Sema &S,
+                                       DeclAccessPair FoundDecl,
+                                 TemplateArgumentListInfo *ExplicitTemplateArgs,
+                                       ArrayRef<Expr *> Args,
+                                       OverloadCandidateSet &CandidateSet,
+                                       bool PartialOverloading,
+                                       bool KnownValid) {
   NamedDecl *Callee = FoundDecl.getDecl();
   if (isa<UsingShadowDecl>(Callee))
     Callee = cast<UsingShadowDecl>(Callee)->getTargetDecl();
@@ -14338,11 +14452,12 @@ AddOverloadedCallCandidate(Sema &S, DeclAccessPair FoundDecl,
     return;
   }
 
-  if (FunctionTemplateDecl *FuncTemplate =
-          dyn_cast<FunctionTemplateDecl>(Callee)) {
-    S.AddTemplateOverloadCandidate(
-        FuncTemplate, FoundDecl, ExplicitTemplateArgs, Args, CandidateSet,
-        /*SuppressUserConversions=*/false, PartialOverloading);
+  if (FunctionTemplateDecl *FuncTemplate
+      = dyn_cast<FunctionTemplateDecl>(Callee)) {
+    S.AddTemplateOverloadCandidate(FuncTemplate, FoundDecl,
+                                   ExplicitTemplateArgs, Args, CandidateSet,
+                                   /*SuppressUserConversions=*/false,
+                                   PartialOverloading);
     return;
   }
 
@@ -14374,8 +14489,7 @@ void Sema::AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
 
   if (ULE->requiresADL()) {
     for (UnresolvedLookupExpr::decls_iterator I = ULE->decls_begin(),
-                                              E = ULE->decls_end();
-         I != E; ++I) {
+           E = ULE->decls_end(); I != E; ++I) {
       assert(!(*I)->getDeclContext()->isRecord());
       assert(isa<UsingShadowDecl>(*I) ||
              !(*I)->getDeclContext()->isFunctionOrMethod());
@@ -14393,8 +14507,7 @@ void Sema::AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
   }
 
   for (UnresolvedLookupExpr::decls_iterator I = ULE->decls_begin(),
-                                            E = ULE->decls_end();
-       I != E; ++I)
+         E = ULE->decls_end(); I != E; ++I)
     AddOverloadedCallCandidate(*this, I.getPair(), ExplicitTemplateArgs, Args,
                                CandidateSet, PartialOverloading,
                                /*KnownValid*/ true);
@@ -14417,10 +14530,8 @@ void Sema::AddOverloadedCallCandidates(
 /// a different namespace.
 static bool canBeDeclaredInNamespace(const DeclarationName &Name) {
   switch (Name.getCXXOverloadedOperator()) {
-  case OO_New:
-  case OO_Array_New:
-  case OO_Delete:
-  case OO_Array_Delete:
+  case OO_New: case OO_Array_New:
+  case OO_Delete: case OO_Array_Delete:
     return false;
 
   default:
@@ -14484,15 +14595,15 @@ static bool DiagnoseTwoPhaseLookup(
       // declaring the function there instead.
       Sema::AssociatedNamespaceSet AssociatedNamespaces;
       Sema::AssociatedClassSet AssociatedClasses;
-      SemaRef.FindAssociatedClassesAndNamespaces(
-          FnLoc, Args, AssociatedNamespaces, AssociatedClasses);
+      SemaRef.FindAssociatedClassesAndNamespaces(FnLoc, Args,
+                                                 AssociatedNamespaces,
+                                                 AssociatedClasses);
       Sema::AssociatedNamespaceSet SuggestedNamespaces;
       if (canBeDeclaredInNamespace(R.getLookupName())) {
         DeclContext *Std = SemaRef.getStdNamespace();
         for (Sema::AssociatedNamespaceSet::iterator
-                 it = AssociatedNamespaces.begin(),
-                 end = AssociatedNamespaces.end();
-             it != end; ++it) {
+               it = AssociatedNamespaces.begin(),
+               end = AssociatedNamespaces.end(); it != end; ++it) {
           // Never suggest declaring a function within namespace 'std'.
           if (Std && Std->Encloses(*it))
             continue;
@@ -14509,22 +14620,22 @@ static bool DiagnoseTwoPhaseLookup(
       }
 
       SemaRef.Diag(R.getNameLoc(), diag::err_not_found_by_two_phase_lookup)
-          << R.getLookupName();
+        << R.getLookupName();
       if (SuggestedNamespaces.empty()) {
         SemaRef.Diag(Best->Function->getLocation(),
                      diag::note_not_found_by_two_phase_lookup)
-            << R.getLookupName() << 0;
+          << R.getLookupName() << 0;
       } else if (SuggestedNamespaces.size() == 1) {
         SemaRef.Diag(Best->Function->getLocation(),
                      diag::note_not_found_by_two_phase_lookup)
-            << R.getLookupName() << 1 << *SuggestedNamespaces.begin();
+          << R.getLookupName() << 1 << *SuggestedNamespaces.begin();
       } else {
         // FIXME: It would be useful to list the associated namespaces here,
         // but the diagnostics infrastructure doesn't provide a way to produce
         // a localized representation of a list of items.
         SemaRef.Diag(Best->Function->getLocation(),
                      diag::note_not_found_by_two_phase_lookup)
-            << R.getLookupName() << 2;
+          << R.getLookupName() << 2;
       }
 
       // Try to recover by calling this function.
@@ -14542,12 +14653,12 @@ static bool DiagnoseTwoPhaseLookup(
 /// was defined.
 ///
 /// Returns true if a viable candidate was found and a diagnostic was issued.
-static bool DiagnoseTwoPhaseOperatorLookup(Sema &SemaRef,
-                                           OverloadedOperatorKind Op,
-                                           SourceLocation OpLoc,
-                                           ArrayRef<Expr *> Args) {
+static bool
+DiagnoseTwoPhaseOperatorLookup(Sema &SemaRef, OverloadedOperatorKind Op,
+                               SourceLocation OpLoc,
+                               ArrayRef<Expr *> Args) {
   DeclarationName OpName =
-      SemaRef.Context.DeclarationNames.getCXXOperatorName(Op);
+    SemaRef.Context.DeclarationNames.getCXXOperatorName(Op);
   LookupResult R(SemaRef, OpName, OpLoc, Sema::LookupOperatorName);
   return DiagnoseTwoPhaseLookup(SemaRef, OpLoc, CXXScopeSpec(), R,
                                 OverloadCandidateSet::CSK_Operator,
@@ -14567,7 +14678,7 @@ class BuildRecoveryCallExprRAII {
 
   ~BuildRecoveryCallExprRAII() { SemaRef.IsBuildingRecoveryCallExpr = false; }
 };
-} // namespace
+}
 
 /// Attempts to recover from a call where no functions were found.
 ///
@@ -14578,8 +14689,10 @@ class BuildRecoveryCallExprRAII {
 ///    expected to diagnose as appropriate.
 static ExprResult
 BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
-                      UnresolvedLookupExpr *ULE, SourceLocation LParenLoc,
-                      MutableArrayRef<Expr *> Args, SourceLocation RParenLoc,
+                      UnresolvedLookupExpr *ULE,
+                      SourceLocation LParenLoc,
+                      MutableArrayRef<Expr *> Args,
+                      SourceLocation RParenLoc,
                       bool EmptyLookup, bool AllowTypoCorrection) {
   // Do not try to recover if it is already building a recovery call.
   // This stops infinite loops for template instantiations like
@@ -14668,8 +14781,10 @@ BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
                                RParenLoc);
 }
 
-bool Sema::buildOverloadedCallSet(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE,
-                                  MultiExprArg Args, SourceLocation RParenLoc,
+bool Sema::buildOverloadedCallSet(Scope *S, Expr *Fn,
+                                  UnresolvedLookupExpr *ULE,
+                                  MultiExprArg Args,
+                                  SourceLocation RParenLoc,
                                   OverloadCandidateSet *CandidateSet,
                                   ExprResult *Result) {
 #ifndef NDEBUG
@@ -14701,8 +14816,8 @@ bool Sema::buildOverloadedCallSet(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE,
   // functions, including those from argument-dependent lookup.
   AddOverloadedCallCandidates(ULE, Args, *CandidateSet);
 
-  if (getLangOpts().MSVCCompat && CurContext->isDependentContext() &&
-      !isSFINAEContext() &&
+  if (getLangOpts().MSVCCompat &&
+      CurContext->isDependentContext() && !isSFINAEContext() &&
       (isa<FunctionDecl>(CurContext) || isa<CXXRecordDecl>(CurContext))) {
 
     OverloadCandidateSet::iterator Best;
@@ -14775,12 +14890,16 @@ static QualType chooseRecoveryType(OverloadCandidateSet &CS,
 /// FinishOverloadedCallExpr - given an OverloadCandidateSet, builds and returns
 /// the completed call expression. If overload resolution fails, emits
 /// diagnostics and returns ExprError()
-static ExprResult FinishOverloadedCallExpr(
-    Sema &SemaRef, Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE,
-    SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc,
-    Expr *ExecConfig, OverloadCandidateSet *CandidateSet,
-    OverloadCandidateSet::iterator *Best, OverloadingResult OverloadResult,
-    bool AllowTypoCorrection) {
+static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
+                                           UnresolvedLookupExpr *ULE,
+                                           SourceLocation LParenLoc,
+                                           MultiExprArg Args,
+                                           SourceLocation RParenLoc,
+                                           Expr *ExecConfig,
+                                           OverloadCandidateSet *CandidateSet,
+                                           OverloadCandidateSet::iterator *Best,
+                                           OverloadingResult OverloadResult,
+                                           bool AllowTypoCorrection) {
   switch (OverloadResult) {
   case OR_Success: {
     FunctionDecl *FDecl = (*Best)->Function;
@@ -14815,9 +14934,10 @@ static ExprResult FinishOverloadedCallExpr(
 
     // Try to recover by looking for viable functions which the user might
     // have meant to call.
-    ExprResult Recovery =
-        BuildRecoveryCallExpr(SemaRef, S, Fn, ULE, LParenLoc, Args, RParenLoc,
-                              CandidateSet->empty(), AllowTypoCorrection);
+    ExprResult Recovery = BuildRecoveryCallExpr(SemaRef, S, Fn, ULE, LParenLoc,
+                                                Args, RParenLoc,
+                                                CandidateSet->empty(),
+                                                AllowTypoCorrection);
     if (Recovery.isInvalid() || Recovery.isUsable())
       return Recovery;
 
@@ -14829,8 +14949,9 @@ static ExprResult FinishOverloadedCallExpr(
         continue;
       if (auto *DRE = dyn_cast<DeclRefExpr>(Arg->IgnoreParenImpCasts())) {
         auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl());
-        if (FD && !SemaRef.checkAddressOfFunctionIsAvailable(
-                      FD, /*Complain=*/true, Arg->getExprLoc()))
+        if (FD &&
+            !SemaRef.checkAddressOfFunctionIsAvailable(FD, /*Complain=*/true,
+                                                       Arg->getExprLoc()))
           return ExprError();
       }
     }
@@ -14889,10 +15010,14 @@ static void markUnaddressableCandidatesUnviable(Sema &S,
   }
 }
 
-ExprResult Sema::BuildOverloadedCallExpr(
-    Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc,
-    MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig,
-    bool AllowTypoCorrection, bool CalleesAddressIsTaken) {
+ExprResult Sema::BuildOverloadedCallExpr(Scope *S, Expr *Fn,
+                                         UnresolvedLookupExpr *ULE,
+                                         SourceLocation LParenLoc,
+                                         MultiExprArg Args,
+                                         SourceLocation RParenLoc,
+                                         Expr *ExecConfig,
+                                         bool AllowTypoCorrection,
+                                         bool CalleesAddressIsTaken) {
 
   OverloadCandidateSet::CandidateSetKind CSK =
       CalleesAddressIsTaken ? OverloadCandidateSet::CSK_AddressOfOverloadSet
@@ -15057,10 +15182,10 @@ ExprResult Sema::BuildCXXMemberCallExpr(Expr *E, NamedDecl *FoundDecl,
   return CheckForImmediateInvocation(CE, CE->getDirectCallee());
 }
 
-ExprResult Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc,
-                                         UnaryOperatorKind Opc,
-                                         const UnresolvedSetImpl &Fns,
-                                         Expr *Input, bool PerformADL) {
+ExprResult
+Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
+                              const UnresolvedSetImpl &Fns,
+                              Expr *Input, bool PerformADL) {
   OverloadedOperatorKind Op = UnaryOperator::getOverloadedOperator(Opc);
   assert(Op != OO_None && "Invalid opcode for overloaded unary operator");
   DeclarationName OpName = Context.DeclarationNames.getCXXOperatorName(Op);
@@ -15070,7 +15195,7 @@ ExprResult Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc,
   if (checkPlaceholderForOverload(*this, Input))
     return ExprError();
 
-  Expr *Args[2] = {Input, nullptr};
+  Expr *Args[2] = { Input, nullptr };
   unsigned NumArgs = 1;
 
   // For post-increment and post-decrement, add the implicit '0' as
@@ -15078,8 +15203,8 @@ ExprResult Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc,
   // post-decrement.
   if (Opc == UO_PostInc || Opc == UO_PostDec) {
     llvm::APSInt Zero(Context.getTypeSize(Context.IntTy), false);
-    Args[1] =
-        IntegerLiteral::Create(Context, Zero, Context.IntTy, SourceLocation());
+    Args[1] = IntegerLiteral::Create(Context, Zero, Context.IntTy,
+                                     SourceLocation());
     NumArgs = 2;
   }
 
@@ -15120,7 +15245,7 @@ ExprResult Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc,
   // Add candidates from ADL.
   if (PerformADL) {
     AddArgumentDependentLookupCandidates(OpName, OpLoc, ArgsArray,
-                                         /*ExplicitTemplateArgs*/ nullptr,
+                                         /*ExplicitTemplateArgs*/nullptr,
                                          CandidateSet);
   }
 
@@ -15156,18 +15281,21 @@ ExprResult Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc,
         Base = Input = InputInit.get();
       } else {
         // Convert the arguments.
-        ExprResult InputInit =
-            PerformCopyInitialization(InitializedEntity::InitializeParameter(
-                                          Context, FnDecl->getParamDecl(0)),
-                                      SourceLocation(), Input);
+        ExprResult InputInit
+          = PerformCopyInitialization(InitializedEntity::InitializeParameter(
+                                                      Context,
+                                                      FnDecl->getParamDecl(0)),
+                                      SourceLocation(),
+                                      Input);
         if (InputInit.isInvalid())
           return ExprError();
         Input = InputInit.get();
       }
 
       // Build the actual expression node.
-      ExprResult FnExpr = CreateFunctionRefExpr(
-          *this, FnDecl, Best->FoundDecl, Base, HadMultipleCandidates, OpLoc);
+      ExprResult FnExpr = CreateFunctionRefExpr(*this, FnDecl, Best->FoundDecl,
+                                                Base, HadMultipleCandidates,
+                                                OpLoc);
       if (FnExpr.isInvalid())
         return ExprError();
 
@@ -15218,10 +15346,10 @@ ExprResult Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc,
 
   case OR_Ambiguous:
     CandidateSet.NoteCandidates(
-        PartialDiagnosticAt(OpLoc, PDiag(diag::err_ovl_ambiguous_oper_unary)
-                                       << UnaryOperator::getOpcodeStr(Opc)
-                                       << Input->getType()
-                                       << Input->getSourceRange()),
+        PartialDiagnosticAt(OpLoc,
+                            PDiag(diag::err_ovl_ambiguous_oper_unary)
+                                << UnaryOperator::getOpcodeStr(Opc)
+                                << Input->getType() << Input->getSourceRange()),
         *this, OCD_AmbiguousCandidates, ArgsArray,
         UnaryOperator::getOpcodeStr(Opc), OpLoc);
     return ExprError();
@@ -15326,8 +15454,8 @@ ExprResult Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
                                        Expr *RHS, bool PerformADL,
                                        bool AllowRewrittenCandidates,
                                        FunctionDecl *DefaultedFn) {
-  Expr *Args[2] = {LHS, RHS};
-  LHS = RHS = nullptr; // Please use only Args instead of LHS/RHS couple
+  Expr *Args[2] = { LHS, RHS };
+  LHS=RHS=nullptr; // Please use only Args instead of LHS/RHS couple
 
   if (!getLangOpts().CPlusPlus20)
     AllowRewrittenCandidates = false;
@@ -15413,369 +15541,374 @@ ExprResult Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
   // Perform overload resolution.
   OverloadCandidateSet::iterator Best;
   switch (CandidateSet.BestViableFunction(*this, OpLoc, Best)) {
-  case OR_Success: {
-    // We found a built-in operator or an overloaded operator.
-    FunctionDecl *FnDecl = Best->Function;
-
-    bool IsReversed = Best->isReversed();
-    if (IsReversed)
-      std::swap(Args[0], Args[1]);
+    case OR_Success: {
+      // We found a built-in operator or an overloaded operator.
+      FunctionDecl *FnDecl = Best->Function;
 
-    if (FnDecl) {
+      bool IsReversed = Best->isReversed();
+      if (IsReversed)
+        std::swap(Args[0], Args[1]);
 
-      if (FnDecl->isInvalidDecl())
-        return ExprError();
+      if (FnDecl) {
 
-      Expr *Base = nullptr;
-      // We matched an overloaded operator. Build a call to that
-      // operator.
-
-      OverloadedOperatorKind ChosenOp =
-          FnDecl->getDeclName().getCXXOverloadedOperator();
-
-      // C++2a [over.match.oper]p9:
-      //   If a rewritten operator== candidate is selected by overload
-      //   resolution for an operator@, its return type shall be cv bool
-      if (Best->RewriteKind && ChosenOp == OO_EqualEqual &&
-          !FnDecl->getReturnType()->isBooleanType()) {
-        bool IsExtension =
-            FnDecl->getReturnType()->isIntegralOrUnscopedEnumerationType();
-        Diag(OpLoc, IsExtension ? diag::ext_ovl_rewrite_equalequal_not_bool
-                                : diag::err_ovl_rewrite_equalequal_not_bool)
-            << FnDecl->getReturnType() << BinaryOperator::getOpcodeStr(Opc)
-            << Args[0]->getSourceRange() << Args[1]->getSourceRange();
-        Diag(FnDecl->getLocation(), diag::note_declared_at);
-        if (!IsExtension)
+        if (FnDecl->isInvalidDecl())
           return ExprError();
-      }
 
-      if (AllowRewrittenCandidates && !IsReversed &&
-          CandidateSet.getRewriteInfo().isReversible()) {
-        // We could have reversed this operator, but didn't. Check if some
-        // reversed form was a viable candidate, and if so, if it had a
-        // better conversion for either parameter. If so, this call is
-        // formally ambiguous, and allowing it is an extension.
-        llvm::SmallVector<FunctionDecl *, 4> AmbiguousWith;
-        for (OverloadCandidate &Cand : CandidateSet) {
-          if (Cand.Viable && Cand.Function && Cand.isReversed() &&
-              allowAmbiguity(Context, Cand.Function, FnDecl)) {
-            for (unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
-              if (CompareImplicitConversionSequences(
-                      *this, OpLoc, Cand.Conversions[ArgIdx],
-                      Best->Conversions[ArgIdx]) ==
-                  ImplicitConversionSequence::Better) {
-                AmbiguousWith.push_back(Cand.Function);
-                break;
+        Expr *Base = nullptr;
+        // We matched an overloaded operator. Build a call to that
+        // operator.
+
+        OverloadedOperatorKind ChosenOp =
+            FnDecl->getDeclName().getCXXOverloadedOperator();
+
+        // C++2a [over.match.oper]p9:
+        //   If a rewritten operator== candidate is selected by overload
+        //   resolution for an operator@, its return type shall be cv bool
+        if (Best->RewriteKind && ChosenOp == OO_EqualEqual &&
+            !FnDecl->getReturnType()->isBooleanType()) {
+          bool IsExtension =
+              FnDecl->getReturnType()->isIntegralOrUnscopedEnumerationType();
+          Diag(OpLoc, IsExtension ? diag::ext_ovl_rewrite_equalequal_not_bool
+                                  : diag::err_ovl_rewrite_equalequal_not_bool)
+              << FnDecl->getReturnType() << BinaryOperator::getOpcodeStr(Opc)
+              << Args[0]->getSourceRange() << Args[1]->getSourceRange();
+          Diag(FnDecl->getLocation(), diag::note_declared_at);
+          if (!IsExtension)
+            return ExprError();
+        }
+
+        if (AllowRewrittenCandidates && !IsReversed &&
+            CandidateSet.getRewriteInfo().isReversible()) {
+          // We could have reversed this operator, but didn't. Check if some
+          // reversed form was a viable candidate, and if so, if it had a
+          // better conversion for either parameter. If so, this call is
+          // formally ambiguous, and allowing it is an extension.
+          llvm::SmallVector<FunctionDecl*, 4> AmbiguousWith;
+          for (OverloadCandidate &Cand : CandidateSet) {
+            if (Cand.Viable && Cand.Function && Cand.isReversed() &&
+                allowAmbiguity(Context, Cand.Function, FnDecl)) {
+              for (unsigned ArgIdx = 0; ArgIdx < 2; ++ArgIdx) {
+                if (CompareImplicitConversionSequences(
+                        *this, OpLoc, Cand.Conversions[ArgIdx],
+                        Best->Conversions[ArgIdx]) ==
+                    ImplicitConversionSequence::Better) {
+                  AmbiguousWith.push_back(Cand.Function);
+                  break;
+                }
               }
             }
           }
-        }
 
-        if (!AmbiguousWith.empty()) {
-          bool AmbiguousWithSelf =
-              AmbiguousWith.size() == 1 &&
-              declaresSameEntity(AmbiguousWith.front(), FnDecl);
-          Diag(OpLoc, diag::ext_ovl_ambiguous_oper_binary_reversed)
-              << BinaryOperator::getOpcodeStr(Opc) << Args[0]->getType()
-              << Args[1]->getType() << AmbiguousWithSelf
-              << Args[0]->getSourceRange() << Args[1]->getSourceRange();
-          if (AmbiguousWithSelf) {
-            Diag(FnDecl->getLocation(),
-                 diag::note_ovl_ambiguous_oper_binary_reversed_self);
-            // Mark member== const or provide matching != to disallow reversed
-            // args. Eg.
-            // struct S { bool operator==(const S&); };
-            // S()==S();
-            if (auto *MD = dyn_cast<CXXMethodDecl>(FnDecl))
-              if (Op == OverloadedOperatorKind::OO_EqualEqual &&
-                  !MD->isConst() &&
-                  !MD->hasCXXExplicitFunctionObjectParameter() &&
-                  Context.hasSameUnqualifiedType(
-                      MD->getFunctionObjectParameterType(),
-                      MD->getParamDecl(0)->getType().getNonReferenceType()) &&
-                  Context.hasSameUnqualifiedType(
-                      MD->getFunctionObjectParameterType(),
-                      Args[0]->getType()) &&
-                  Context.hasSameUnqualifiedType(
-                      MD->getFunctionObjectParameterType(), Args[1]->getType()))
-                Diag(FnDecl->getLocation(),
-                     diag::note_ovl_ambiguous_eqeq_reversed_self_non_const);
-          } else {
-            Diag(FnDecl->getLocation(),
-                 diag::note_ovl_ambiguous_oper_binary_selected_candidate);
-            for (auto *F : AmbiguousWith)
-              Diag(F->getLocation(),
-                   diag::note_ovl_ambiguous_oper_binary_reversed_candidate);
+          if (!AmbiguousWith.empty()) {
+            bool AmbiguousWithSelf =
+                AmbiguousWith.size() == 1 &&
+                declaresSameEntity(AmbiguousWith.front(), FnDecl);
+            Diag(OpLoc, diag::ext_ovl_ambiguous_oper_binary_reversed)
+                << BinaryOperator::getOpcodeStr(Opc)
+                << Args[0]->getType() << Args[1]->getType() << AmbiguousWithSelf
+                << Args[0]->getSourceRange() << Args[1]->getSourceRange();
+            if (AmbiguousWithSelf) {
+              Diag(FnDecl->getLocation(),
+                   diag::note_ovl_ambiguous_oper_binary_reversed_self);
+              // Mark member== const or provide matching != to disallow reversed
+              // args. Eg.
+              // struct S { bool operator==(const S&); };
+              // S()==S();
+              if (auto *MD = dyn_cast<CXXMethodDecl>(FnDecl))
+                if (Op == OverloadedOperatorKind::OO_EqualEqual &&
+                    !MD->isConst() &&
+                    !MD->hasCXXExplicitFunctionObjectParameter() &&
+                    Context.hasSameUnqualifiedType(
+                        MD->getFunctionObjectParameterType(),
+                        MD->getParamDecl(0)->getType().getNonReferenceType()) &&
+                    Context.hasSameUnqualifiedType(
+                        MD->getFunctionObjectParameterType(),
+                        Args[0]->getType()) &&
+                    Context.hasSameUnqualifiedType(
+                        MD->getFunctionObjectParameterType(),
+                        Args[1]->getType()))
+                  Diag(FnDecl->getLocation(),
+                       diag::note_ovl_ambiguous_eqeq_reversed_self_non_const);
+            } else {
+              Diag(FnDecl->getLocation(),
+                   diag::note_ovl_ambiguous_oper_binary_selected_candidate);
+              for (auto *F : AmbiguousWith)
+                Diag(F->getLocation(),
+                     diag::note_ovl_ambiguous_oper_binary_reversed_candidate);
+            }
           }
         }
-      }
 
-      // Check for nonnull = nullable.
-      // This won't be caught in the arg's initialization: the parameter to
-      // the assignment operator is not marked nonnull.
-      if (Op == OO_Equal)
-        diagnoseNullableToNonnullConversion(Args[0]->getType(),
-                                            Args[1]->getType(), OpLoc);
+        // Check for nonnull = nullable.
+        // This won't be caught in the arg's initialization: the parameter to
+        // the assignment operator is not marked nonnull.
+        if (Op == OO_Equal)
+          diagnoseNullableToNonnullConversion(Args[0]->getType(),
+                                              Args[1]->getType(), OpLoc);
 
-      // Convert the arguments.
-      if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
-        // Best->Access is only meaningful for class members.
-        CheckMemberOperatorAccess(OpLoc, Args[0], Args[1], Best->FoundDecl);
-
-        ExprResult Arg0, Arg1;
-        unsigned ParamIdx = 0;
-        if (Method->isExplicitObjectMemberFunction()) {
-          Arg0 = InitializeExplicitObjectArgument(*this, Args[0], FnDecl);
-          ParamIdx = 1;
+        // Convert the arguments.
+        if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
+          // Best->Access is only meaningful for class members.
+          CheckMemberOperatorAccess(OpLoc, Args[0], Args[1], Best->FoundDecl);
+
+          ExprResult Arg0, Arg1;
+          unsigned ParamIdx = 0;
+          if (Method->isExplicitObjectMemberFunction()) {
+            Arg0 = InitializeExplicitObjectArgument(*this, Args[0], FnDecl);
+            ParamIdx = 1;
+          } else {
+            Arg0 = PerformImplicitObjectArgumentInitialization(
+                Args[0], /*Qualifier=*/std::nullopt, Best->FoundDecl, Method);
+          }
+          Arg1 = PerformCopyInitialization(
+              InitializedEntity::InitializeParameter(
+                  Context, FnDecl->getParamDecl(ParamIdx)),
+              SourceLocation(), Args[1]);
+          if (Arg0.isInvalid() || Arg1.isInvalid())
+            return ExprError();
+
+          Base = Args[0] = Arg0.getAs<Expr>();
+          Args[1] = RHS = Arg1.getAs<Expr>();
         } else {
-          Arg0 = PerformImplicitObjectArgumentInitialization(
-              Args[0], /*Qualifier=*/std::nullopt, Best->FoundDecl, Method);
+          // Convert the arguments.
+          ExprResult Arg0 = PerformCopyInitialization(
+            InitializedEntity::InitializeParameter(Context,
+                                                   FnDecl->getParamDecl(0)),
+            SourceLocation(), Args[0]);
+          if (Arg0.isInvalid())
+            return ExprError();
+
+          ExprResult Arg1 =
+            PerformCopyInitialization(
+              InitializedEntity::InitializeParameter(Context,
+                                                     FnDecl->getParamDecl(1)),
+              SourceLocation(), Args[1]);
+          if (Arg1.isInvalid())
+            return ExprError();
+          Args[0] = LHS = Arg0.getAs<Expr>();
+          Args[1] = RHS = Arg1.getAs<Expr>();
         }
-        Arg1 = PerformCopyInitialization(
-            InitializedEntity::InitializeParameter(
-                Context, FnDecl->getParamDecl(ParamIdx)),
-            SourceLocation(), Args[1]);
-        if (Arg0.isInvalid() || Arg1.isInvalid())
-          return ExprError();
-
-        Base = Args[0] = Arg0.getAs<Expr>();
-        Args[1] = RHS = Arg1.getAs<Expr>();
-      } else {
-        // Convert the arguments.
-        ExprResult Arg0 =
-            PerformCopyInitialization(InitializedEntity::InitializeParameter(
-                                          Context, FnDecl->getParamDecl(0)),
-                                      SourceLocation(), Args[0]);
-        if (Arg0.isInvalid())
-          return ExprError();
 
-        ExprResult Arg1 =
-            PerformCopyInitialization(InitializedEntity::InitializeParameter(
-                                          Context, FnDecl->getParamDecl(1)),
-                                      SourceLocation(), Args[1]);
-        if (Arg1.isInvalid())
+        // Build the actual expression node.
+        ExprResult FnExpr = CreateFunctionRefExpr(*this, FnDecl,
+                                                  Best->FoundDecl, Base,
+                                                  HadMultipleCandidates, OpLoc);
+        if (FnExpr.isInvalid())
           return ExprError();
-        Args[0] = LHS = Arg0.getAs<Expr>();
-        Args[1] = RHS = Arg1.getAs<Expr>();
-      }
 
-      // Build the actual expression node.
-      ExprResult FnExpr = CreateFunctionRefExpr(
-          *this, FnDecl, Best->FoundDecl, Base, HadMultipleCandidates, OpLoc);
-      if (FnExpr.isInvalid())
-        return ExprError();
-
-      // Determine the result type.
-      QualType ResultTy = FnDecl->getReturnType();
-      ExprValueKind VK = Expr::getValueKindForType(ResultTy);
-      ResultTy = ResultTy.getNonLValueExprType(Context);
-
-      CallExpr *TheCall;
-      ArrayRef<const Expr *> ArgsArray(Args, 2);
-      const Expr *ImplicitThis = nullptr;
-
-      // We always create a CXXOperatorCallExpr, even for explicit object
-      // members; CodeGen should take care not to emit the this pointer.
-      TheCall = CXXOperatorCallExpr::Create(
-          Context, ChosenOp, FnExpr.get(), Args, ResultTy, VK, OpLoc,
-          CurFPFeatureOverrides(),
-          static_cast<CallExpr::ADLCallKind>(Best->IsADLCandidate));
-
-      if (const auto *Method = dyn_cast<CXXMethodDecl>(FnDecl);
-          Method && Method->isImplicitObjectMemberFunction()) {
-        // Cut off the implicit 'this'.
-        ImplicitThis = ArgsArray[0];
-        ArgsArray = ArgsArray.slice(1);
-      }
+        // Determine the result type.
+        QualType ResultTy = FnDecl->getReturnType();
+        ExprValueKind VK = Expr::getValueKindForType(ResultTy);
+        ResultTy = ResultTy.getNonLValueExprType(Context);
+
+        CallExpr *TheCall;
+        ArrayRef<const Expr *> ArgsArray(Args, 2);
+        const Expr *ImplicitThis = nullptr;
+
+        // We always create a CXXOperatorCallExpr, even for explicit object
+        // members; CodeGen should take care not to emit the this pointer.
+        TheCall = CXXOperatorCallExpr::Create(
+            Context, ChosenOp, FnExpr.get(), Args, ResultTy, VK, OpLoc,
+            CurFPFeatureOverrides(),
+            static_cast<CallExpr::ADLCallKind>(Best->IsADLCandidate));
+
+        if (const auto *Method = dyn_cast<CXXMethodDecl>(FnDecl);
+            Method && Method->isImplicitObjectMemberFunction()) {
+          // Cut off the implicit 'this'.
+          ImplicitThis = ArgsArray[0];
+          ArgsArray = ArgsArray.slice(1);
+        }
 
-      if (CheckCallReturnType(FnDecl->getReturnType(), OpLoc, TheCall, FnDecl))
-        return ExprError();
+        if (CheckCallReturnType(FnDecl->getReturnType(), OpLoc, TheCall,
+                                FnDecl))
+          return ExprError();
 
-      if (Op == OO_Equal) {
-        // Check for a self move.
-        DiagnoseSelfMove(Args[0], Args[1], OpLoc);
-        // lifetime check.
-        checkAssignmentLifetime(
-            *this, AssignedEntity{Args[0], dyn_cast<CXXMethodDecl>(FnDecl)},
-            Args[1]);
-      }
-      if (ImplicitThis) {
-        QualType ThisType = Context.getPointerType(ImplicitThis->getType());
-        QualType ThisTypeFromDecl = Context.getPointerType(
-            cast<CXXMethodDecl>(FnDecl)->getFunctionObjectParameterType());
+        if (Op == OO_Equal) {
+          // Check for a self move.
+          DiagnoseSelfMove(Args[0], Args[1], OpLoc);
+          // lifetime check.
+          checkAssignmentLifetime(
+              *this, AssignedEntity{Args[0], dyn_cast<CXXMethodDecl>(FnDecl)},
+              Args[1]);
+        }
+        if (ImplicitThis) {
+          QualType ThisType = Context.getPointerType(ImplicitThis->getType());
+          QualType ThisTypeFromDecl = Context.getPointerType(
+              cast<CXXMethodDecl>(FnDecl)->getFunctionObjectParameterType());
 
-        CheckArgAlignment(OpLoc, FnDecl, "'this'", ThisType, ThisTypeFromDecl);
-      }
+          CheckArgAlignment(OpLoc, FnDecl, "'this'", ThisType,
+                            ThisTypeFromDecl);
+        }
 
-      checkCall(FnDecl, nullptr, ImplicitThis, ArgsArray,
-                isa<CXXMethodDecl>(FnDecl), OpLoc, TheCall->getSourceRange(),
-                VariadicCallType::DoesNotApply);
+        checkCall(FnDecl, nullptr, ImplicitThis, ArgsArray,
+                  isa<CXXMethodDecl>(FnDecl), OpLoc, TheCall->getSourceRange(),
+                  VariadicCallType::DoesNotApply);
 
-      ExprResult R = MaybeBindToTemporary(TheCall);
-      if (R.isInvalid())
-        return ExprError();
+        ExprResult R = MaybeBindToTemporary(TheCall);
+        if (R.isInvalid())
+          return ExprError();
 
-      R = CheckForImmediateInvocation(R, FnDecl);
-      if (R.isInvalid())
-        return ExprError();
+        R = CheckForImmediateInvocation(R, FnDecl);
+        if (R.isInvalid())
+          return ExprError();
 
-      // For a rewritten candidate, we've already reversed the arguments
-      // if needed. Perform the rest of the rewrite now.
-      if ((Best->RewriteKind & CRK_DifferentOperator) ||
-          (Op == OO_Spaceship && IsReversed)) {
-        if (Op == OO_ExclaimEqual) {
-          assert(ChosenOp == OO_EqualEqual && "unexpected operator name");
-          R = CreateBuiltinUnaryOp(OpLoc, UO_LNot, R.get());
+        // For a rewritten candidate, we've already reversed the arguments
+        // if needed. Perform the rest of the rewrite now.
+        if ((Best->RewriteKind & CRK_DifferentOperator) ||
+            (Op == OO_Spaceship && IsReversed)) {
+          if (Op == OO_ExclaimEqual) {
+            assert(ChosenOp == OO_EqualEqual && "unexpected operator name");
+            R = CreateBuiltinUnaryOp(OpLoc, UO_LNot, R.get());
+          } else {
+            assert(ChosenOp == OO_Spaceship && "unexpected operator name");
+            llvm::APSInt Zero(Context.getTypeSize(Context.IntTy), false);
+            Expr *ZeroLiteral =
+                IntegerLiteral::Create(Context, Zero, Context.IntTy, OpLoc);
+
+            Sema::CodeSynthesisContext Ctx;
+            Ctx.Kind = Sema::CodeSynthesisContext::RewritingOperatorAsSpaceship;
+            Ctx.Entity = FnDecl;
+            pushCodeSynthesisContext(Ctx);
+
+            R = CreateOverloadedBinOp(
+                OpLoc, Opc, Fns, IsReversed ? ZeroLiteral : R.get(),
+                IsReversed ? R.get() : ZeroLiteral, /*PerformADL=*/true,
+                /*AllowRewrittenCandidates=*/false);
+
+            popCodeSynthesisContext();
+          }
+          if (R.isInvalid())
+            return ExprError();
         } else {
-          assert(ChosenOp == OO_Spaceship && "unexpected operator name");
-          llvm::APSInt Zero(Context.getTypeSize(Context.IntTy), false);
-          Expr *ZeroLiteral =
-              IntegerLiteral::Create(Context, Zero, Context.IntTy, OpLoc);
-
-          Sema::CodeSynthesisContext Ctx;
-          Ctx.Kind = Sema::CodeSynthesisContext::RewritingOperatorAsSpaceship;
-          Ctx.Entity = FnDecl;
-          pushCodeSynthesisContext(Ctx);
-
-          R = CreateOverloadedBinOp(
-              OpLoc, Opc, Fns, IsReversed ? ZeroLiteral : R.get(),
-              IsReversed ? R.get() : ZeroLiteral, /*PerformADL=*/true,
-              /*AllowRewrittenCandidates=*/false);
-
-          popCodeSynthesisContext();
+          assert(ChosenOp == Op && "unexpected operator name");
         }
-        if (R.isInvalid())
-          return ExprError();
-      } else {
-        assert(ChosenOp == Op && "unexpected operator name");
-      }
 
-      // Make a note in the AST if we did any rewriting.
-      if (Best->RewriteKind != CRK_None)
-        R = new (Context) CXXRewrittenBinaryOperator(R.get(), IsReversed);
+        // Make a note in the AST if we did any rewriting.
+        if (Best->RewriteKind != CRK_None)
+          R = new (Context) CXXRewrittenBinaryOperator(R.get(), IsReversed);
 
-      return R;
-    } else {
-      // We matched a built-in operator. Convert the arguments, then
-      // break out so that we will build the appropriate built-in
-      // operator node.
-      ExprResult ArgsRes0 = PerformImplicitConversion(
-          Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
-          AssignmentAction::Passing,
-          CheckedConversionKind::ForBuiltinOverloadedOp);
-      if (ArgsRes0.isInvalid())
-        return ExprError();
-      Args[0] = ArgsRes0.get();
+        return R;
+      } else {
+        // We matched a built-in operator. Convert the arguments, then
+        // break out so that we will build the appropriate built-in
+        // operator node.
+        ExprResult ArgsRes0 = PerformImplicitConversion(
+            Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
+            AssignmentAction::Passing,
+            CheckedConversionKind::ForBuiltinOverloadedOp);
+        if (ArgsRes0.isInvalid())
+          return ExprError();
+        Args[0] = ArgsRes0.get();
 
-      ExprResult ArgsRes1 = PerformImplicitConversion(
-          Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
-          AssignmentAction::Passing,
-          CheckedConversionKind::ForBuiltinOverloadedOp);
-      if (ArgsRes1.isInvalid())
-        return ExprError();
-      Args[1] = ArgsRes1.get();
-      break;
+        ExprResult ArgsRes1 = PerformImplicitConversion(
+            Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
+            AssignmentAction::Passing,
+            CheckedConversionKind::ForBuiltinOverloadedOp);
+        if (ArgsRes1.isInvalid())
+          return ExprError();
+        Args[1] = ArgsRes1.get();
+        break;
+      }
     }
-  }
 
-  case OR_No_Viable_Function: {
-    // C++ [over.match.oper]p9:
-    //   If the operator is the operator , [...] and there are no
-    //   viable functions, then the operator is assumed to be the
-    //   built-in operator and interpreted according to clause 5.
-    if (Opc == BO_Comma)
-      break;
+    case OR_No_Viable_Function: {
+      // C++ [over.match.oper]p9:
+      //   If the operator is the operator , [...] and there are no
+      //   viable functions, then the operator is assumed to be the
+      //   built-in operator and interpreted according to clause 5.
+      if (Opc == BO_Comma)
+        break;
 
-    // When defaulting an 'operator<=>', we can try to synthesize a three-way
-    // compare result using '==' and '<'.
-    if (DefaultedFn && Opc == BO_Cmp) {
-      ExprResult E = BuildSynthesizedThreeWayComparison(OpLoc, Fns, Args[0],
-                                                        Args[1], DefaultedFn);
-      if (E.isInvalid() || E.isUsable())
-        return E;
-    }
-
-    // For class as left operand for assignment or compound assignment
-    // operator do not fall through to handling in built-in, but report that
-    // no overloaded assignment operator found
-    ExprResult Result = ExprError();
-    StringRef OpcStr = BinaryOperator::getOpcodeStr(Opc);
-    auto Cands =
-        CandidateSet.CompleteCandidates(*this, OCD_AllCandidates, Args, OpLoc);
-    DeferDiagsRAII DDR(*this,
-                       CandidateSet.shouldDeferDiags(*this, Args, OpLoc));
-    if (Args[0]->getType()->isRecordType() && Opc >= BO_Assign &&
-        Opc <= BO_OrAssign) {
-      Diag(OpLoc, diag::err_ovl_no_viable_oper)
-          << BinaryOperator::getOpcodeStr(Opc) << Args[0]->getSourceRange()
-          << Args[1]->getSourceRange();
-      if (Args[0]->getType()->isIncompleteType()) {
-        Diag(OpLoc, diag::note_assign_lhs_incomplete)
-            << Args[0]->getType() << Args[0]->getSourceRange()
-            << Args[1]->getSourceRange();
+      // When defaulting an 'operator<=>', we can try to synthesize a three-way
+      // compare result using '==' and '<'.
+      if (DefaultedFn && Opc == BO_Cmp) {
+        ExprResult E = BuildSynthesizedThreeWayComparison(OpLoc, Fns, Args[0],
+                                                          Args[1], DefaultedFn);
+        if (E.isInvalid() || E.isUsable())
+          return E;
       }
-    } else {
-      // This is an erroneous use of an operator which can be overloaded by
-      // a non-member function. Check for non-member operators which were
-      // defined too late to be candidates.
-      if (DiagnoseTwoPhaseOperatorLookup(*this, Op, OpLoc, Args))
-        // FIXME: Recover by calling the found function.
-        return ExprError();
 
-      // No viable function; try to create a built-in operation, which will
-      // produce an error. Then, show the non-viable candidates.
-      Result = CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
+      // For class as left operand for assignment or compound assignment
+      // operator do not fall through to handling in built-in, but report that
+      // no overloaded assignment operator found
+      ExprResult Result = ExprError();
+      StringRef OpcStr = BinaryOperator::getOpcodeStr(Opc);
+      auto Cands = CandidateSet.CompleteCandidates(*this, OCD_AllCandidates,
+                                                   Args, OpLoc);
+      DeferDiagsRAII DDR(*this,
+                         CandidateSet.shouldDeferDiags(*this, Args, OpLoc));
+      if (Args[0]->getType()->isRecordType() &&
+          Opc >= BO_Assign && Opc <= BO_OrAssign) {
+        Diag(OpLoc,  diag::err_ovl_no_viable_oper)
+             << BinaryOperator::getOpcodeStr(Opc)
+             << Args[0]->getSourceRange() << Args[1]->getSourceRange();
+        if (Args[0]->getType()->isIncompleteType()) {
+          Diag(OpLoc, diag::note_assign_lhs_incomplete)
+            << Args[0]->getType()
+            << Args[0]->getSourceRange() << Args[1]->getSourceRange();
+        }
+      } else {
+        // This is an erroneous use of an operator which can be overloaded by
+        // a non-member function. Check for non-member operators which were
+        // defined too late to be candidates.
+        if (DiagnoseTwoPhaseOperatorLookup(*this, Op, OpLoc, Args))
+          // FIXME: Recover by calling the found function.
+          return ExprError();
+
+        // No viable function; try to create a built-in operation, which will
+        // produce an error. Then, show the non-viable candidates.
+        Result = CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
+      }
+      assert(Result.isInvalid() &&
+             "C++ binary operator overloading is missing candidates!");
+      CandidateSet.NoteCandidates(*this, Args, Cands, OpcStr, OpLoc);
+      return Result;
     }
-    assert(Result.isInvalid() &&
-           "C++ binary operator overloading is missing candidates!");
-    CandidateSet.NoteCandidates(*this, Args, Cands, OpcStr, OpLoc);
-    return Result;
-  }
 
-  case OR_Ambiguous:
-    CandidateSet.NoteCandidates(
-        PartialDiagnosticAt(OpLoc, PDiag(diag::err_ovl_ambiguous_oper_binary)
-                                       << BinaryOperator::getOpcodeStr(Opc)
-                                       << Args[0]->getType()
-                                       << Args[1]->getType()
-                                       << Args[0]->getSourceRange()
-                                       << Args[1]->getSourceRange()),
-        *this, OCD_AmbiguousCandidates, Args, BinaryOperator::getOpcodeStr(Opc),
-        OpLoc);
-    return ExprError();
+    case OR_Ambiguous:
+      CandidateSet.NoteCandidates(
+          PartialDiagnosticAt(OpLoc, PDiag(diag::err_ovl_ambiguous_oper_binary)
+                                         << BinaryOperator::getOpcodeStr(Opc)
+                                         << Args[0]->getType()
+                                         << Args[1]->getType()
+                                         << Args[0]->getSourceRange()
+                                         << Args[1]->getSourceRange()),
+          *this, OCD_AmbiguousCandidates, Args, BinaryOperator::getOpcodeStr(Opc),
+          OpLoc);
+      return ExprError();
 
-  case OR_Deleted: {
-    if (isImplicitlyDeleted(Best->Function)) {
-      FunctionDecl *DeletedFD = Best->Function;
-      DefaultedFunctionKind DFK = getDefaultedFunctionKind(DeletedFD);
-      if (DFK.isSpecialMember()) {
-        Diag(OpLoc, diag::err_ovl_deleted_special_oper)
-            << Args[0]->getType() << DFK.asSpecialMember();
-      } else {
-        assert(DFK.isComparison());
-        Diag(OpLoc, diag::err_ovl_deleted_comparison)
+    case OR_Deleted: {
+      if (isImplicitlyDeleted(Best->Function)) {
+        FunctionDecl *DeletedFD = Best->Function;
+        DefaultedFunctionKind DFK = getDefaultedFunctionKind(DeletedFD);
+        if (DFK.isSpecialMember()) {
+          Diag(OpLoc, diag::err_ovl_deleted_special_oper)
+              << Args[0]->getType() << DFK.asSpecialMember();
+        } else {
+          assert(DFK.isComparison());
+          Diag(OpLoc, diag::err_ovl_deleted_comparison)
             << Args[0]->getType() << DeletedFD;
+        }
+
+        // The user probably meant to call this special member. Just
+        // explain why it's deleted.
+        NoteDeletedFunction(DeletedFD);
+        return ExprError();
       }
 
-      // The user probably meant to call this special member. Just
-      // explain why it's deleted.
-      NoteDeletedFunction(DeletedFD);
+      StringLiteral *Msg = Best->Function->getDeletedMessage();
+      CandidateSet.NoteCandidates(
+          PartialDiagnosticAt(
+              OpLoc,
+              PDiag(diag::err_ovl_deleted_oper)
+                  << getOperatorSpelling(Best->Function->getDeclName()
+                                             .getCXXOverloadedOperator())
+                  << (Msg != nullptr) << (Msg ? Msg->getString() : StringRef())
+                  << Args[0]->getSourceRange() << Args[1]->getSourceRange()),
+          *this, OCD_AllCandidates, Args, BinaryOperator::getOpcodeStr(Opc),
+          OpLoc);
       return ExprError();
     }
-
-    StringLiteral *Msg = Best->Function->getDeletedMessage();
-    CandidateSet.NoteCandidates(
-        PartialDiagnosticAt(
-            OpLoc,
-            PDiag(diag::err_ovl_deleted_oper)
-                << getOperatorSpelling(
-                       Best->Function->getDeclName().getCXXOverloadedOperator())
-                << (Msg != nullptr) << (Msg ? Msg->getString() : StringRef())
-                << Args[0]->getSourceRange() << Args[1]->getSourceRange()),
-        *this, OCD_AllCandidates, Args, BinaryOperator::getOpcodeStr(Opc),
-        OpLoc);
-    return ExprError();
-  }
   }
 
   // We matched a built-in operator; build it.
@@ -15790,7 +15923,7 @@ ExprResult Sema::BuildSynthesizedThreeWayComparison(
   // If we're not producing a known comparison category type, we can't
   // synthesize a three-way comparison. Let the caller diagnose this.
   if (!Info)
-    return ExprResult((Expr *)nullptr);
+    return ExprResult((Expr*)nullptr);
 
   // If we ever want to perform this synthesis more generally, we will need to
   // apply the temporary materialization conversion to the operands.
@@ -15830,12 +15963,12 @@ ExprResult Sema::BuildSynthesizedThreeWayComparison(
   struct Comparison {
     ExprResult Cmp;
     ComparisonCategoryResult Result;
-  } Comparisons[4] = {
-      {Eq, Info->isStrong() ? ComparisonCategoryResult::Equal
-                            : ComparisonCategoryResult::Equivalent},
-      {Less, ComparisonCategoryResult::Less},
-      {Greater, ComparisonCategoryResult::Greater},
-      {ExprResult(), ComparisonCategoryResult::Unordered},
+  } Comparisons[4] =
+  { {Eq, Info->isStrong() ? ComparisonCategoryResult::Equal
+                          : ComparisonCategoryResult::Equivalent},
+    {Less, ComparisonCategoryResult::Less},
+    {Greater, ComparisonCategoryResult::Greater},
+    {ExprResult(), ComparisonCategoryResult::Unordered},
   };
 
   int I = Info->isPartial() ? 3 : 2;
@@ -15847,7 +15980,7 @@ ExprResult Sema::BuildSynthesizedThreeWayComparison(
     auto *VI = Info->lookupValueInfo(Comparisons[I].Result);
     // FIXME: Missing a constant for a comparison category. Diagnose this?
     if (!VI)
-      return ExprResult((Expr *)nullptr);
+      return ExprResult((Expr*)nullptr);
     ExprResult ThisResult =
         BuildDeclarationNameExpr(CXXScopeSpec(), DeclarationNameInfo(), VI->VD);
     if (ThisResult.isInvalid())
@@ -15971,134 +16104,136 @@ ExprResult Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,
   // Perform overload resolution.
   OverloadCandidateSet::iterator Best;
   switch (CandidateSet.BestViableFunction(*this, LLoc, Best)) {
-  case OR_Success: {
-    // We found a built-in operator or an overloaded operator.
-    FunctionDecl *FnDecl = Best->Function;
+    case OR_Success: {
+      // We found a built-in operator or an overloaded operator.
+      FunctionDecl *FnDecl = Best->Function;
 
-    if (FnDecl) {
-      // We matched an overloaded operator. Build a call to that
-      // operator.
+      if (FnDecl) {
+        // We matched an overloaded operator. Build a call to that
+        // operator.
 
-      CheckMemberOperatorAccess(LLoc, Args[0], ArgExpr, Best->FoundDecl);
+        CheckMemberOperatorAccess(LLoc, Args[0], ArgExpr, Best->FoundDecl);
 
-      // Convert the arguments.
-      CXXMethodDecl *Method = cast<CXXMethodDecl>(FnDecl);
-      SmallVector<Expr *, 2> MethodArgs;
-
-      // Initialize the object parameter.
-      if (Method->isExplicitObjectMemberFunction()) {
-        ExprResult Res =
-            InitializeExplicitObjectArgument(*this, Args[0], Method);
-        if (Res.isInvalid())
-          return ExprError();
-        Args[0] = Res.get();
-        ArgExpr = Args;
-      } else {
-        ExprResult Arg0 = PerformImplicitObjectArgumentInitialization(
-            Args[0], /*Qualifier=*/std::nullopt, Best->FoundDecl, Method);
-        if (Arg0.isInvalid())
-          return ExprError();
+        // Convert the arguments.
+        CXXMethodDecl *Method = cast<CXXMethodDecl>(FnDecl);
+        SmallVector<Expr *, 2> MethodArgs;
 
-        MethodArgs.push_back(Arg0.get());
-      }
+        // Initialize the object parameter.
+        if (Method->isExplicitObjectMemberFunction()) {
+          ExprResult Res =
+              InitializeExplicitObjectArgument(*this, Args[0], Method);
+          if (Res.isInvalid())
+            return ExprError();
+          Args[0] = Res.get();
+          ArgExpr = Args;
+        } else {
+          ExprResult Arg0 = PerformImplicitObjectArgumentInitialization(
+              Args[0], /*Qualifier=*/std::nullopt, Best->FoundDecl, Method);
+          if (Arg0.isInvalid())
+            return ExprError();
 
-      bool IsError = PrepareArgumentsForCallToObjectOfClassType(
-          *this, MethodArgs, Method, ArgExpr, LLoc);
-      if (IsError)
-        return ExprError();
+          MethodArgs.push_back(Arg0.get());
+        }
 
-      // Build the actual expression node.
-      DeclarationNameInfo OpLocInfo(OpName, LLoc);
-      OpLocInfo.setCXXOperatorNameRange(SourceRange(LLoc, RLoc));
-      ExprResult FnExpr = CreateFunctionRefExpr(
-          *this, FnDecl, Best->FoundDecl, Base, HadMultipleCandidates,
-          OpLocInfo.getLoc(), OpLocInfo.getInfo());
-      if (FnExpr.isInvalid())
-        return ExprError();
+        bool IsError = PrepareArgumentsForCallToObjectOfClassType(
+            *this, MethodArgs, Method, ArgExpr, LLoc);
+        if (IsError)
+          return ExprError();
 
-      // Determine the result type
-      QualType ResultTy = FnDecl->getReturnType();
-      ExprValueKind VK = Expr::getValueKindForType(ResultTy);
-      ResultTy = ResultTy.getNonLValueExprType(Context);
+        // Build the actual expression node.
+        DeclarationNameInfo OpLocInfo(OpName, LLoc);
+        OpLocInfo.setCXXOperatorNameRange(SourceRange(LLoc, RLoc));
+        ExprResult FnExpr = CreateFunctionRefExpr(
+            *this, FnDecl, Best->FoundDecl, Base, HadMultipleCandidates,
+            OpLocInfo.getLoc(), OpLocInfo.getInfo());
+        if (FnExpr.isInvalid())
+          return ExprError();
 
-      CallExpr *TheCall = CXXOperatorCallExpr::Create(
-          Context, OO_Subscript, FnExpr.get(), MethodArgs, ResultTy, VK, RLoc,
-          CurFPFeatureOverrides());
+        // Determine the result type
+        QualType ResultTy = FnDecl->getReturnType();
+        ExprValueKind VK = Expr::getValueKindForType(ResultTy);
+        ResultTy = ResultTy.getNonLValueExprType(Context);
 
-      if (CheckCallReturnType(FnDecl->getReturnType(), LLoc, TheCall, FnDecl))
-        return ExprError();
+        CallExpr *TheCall = CXXOperatorCallExpr::Create(
+            Context, OO_Subscript, FnExpr.get(), MethodArgs, ResultTy, VK, RLoc,
+            CurFPFeatureOverrides());
 
-      if (CheckFunctionCall(Method, TheCall,
-                            Method->getType()->castAs<FunctionProtoType>()))
-        return ExprError();
+        if (CheckCallReturnType(FnDecl->getReturnType(), LLoc, TheCall, FnDecl))
+          return ExprError();
 
-      return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall), FnDecl);
-    } else {
-      // We matched a built-in operator. Convert the arguments, then
-      // break out so that we will build the appropriate built-in
-      // operator node.
-      ExprResult ArgsRes0 = PerformImplicitConversion(
-          Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
-          AssignmentAction::Passing,
-          CheckedConversionKind::ForBuiltinOverloadedOp);
-      if (ArgsRes0.isInvalid())
-        return ExprError();
-      Args[0] = ArgsRes0.get();
+        if (CheckFunctionCall(Method, TheCall,
+                              Method->getType()->castAs<FunctionProtoType>()))
+          return ExprError();
 
-      ExprResult ArgsRes1 = PerformImplicitConversion(
-          Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
-          AssignmentAction::Passing,
-          CheckedConversionKind::ForBuiltinOverloadedOp);
-      if (ArgsRes1.isInvalid())
-        return ExprError();
-      Args[1] = ArgsRes1.get();
+        return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall),
+                                           FnDecl);
+      } else {
+        // We matched a built-in operator. Convert the arguments, then
+        // break out so that we will build the appropriate built-in
+        // operator node.
+        ExprResult ArgsRes0 = PerformImplicitConversion(
+            Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
+            AssignmentAction::Passing,
+            CheckedConversionKind::ForBuiltinOverloadedOp);
+        if (ArgsRes0.isInvalid())
+          return ExprError();
+        Args[0] = ArgsRes0.get();
 
-      break;
+        ExprResult ArgsRes1 = PerformImplicitConversion(
+            Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
+            AssignmentAction::Passing,
+            CheckedConversionKind::ForBuiltinOverloadedOp);
+        if (ArgsRes1.isInvalid())
+          return ExprError();
+        Args[1] = ArgsRes1.get();
+
+        break;
+      }
     }
-  }
 
-  case OR_No_Viable_Function: {
-    PartialDiagnostic PD =
-        CandidateSet.empty()
-            ? (PDiag(diag::err_ovl_no_oper)
-               << Args[0]->getType() << /*subscript*/ 0
-               << Args[0]->getSourceRange() << Range)
-            : (PDiag(diag::err_ovl_no_viable_subscript)
-               << Args[0]->getType() << Args[0]->getSourceRange() << Range);
-    CandidateSet.NoteCandidates(PartialDiagnosticAt(LLoc, PD), *this,
-                                OCD_AllCandidates, ArgExpr, "[]", LLoc);
-    return ExprError();
-  }
+    case OR_No_Viable_Function: {
+      PartialDiagnostic PD =
+          CandidateSet.empty()
+              ? (PDiag(diag::err_ovl_no_oper)
+                 << Args[0]->getType() << /*subscript*/ 0
+                 << Args[0]->getSourceRange() << Range)
+              : (PDiag(diag::err_ovl_no_viable_subscript)
+                 << Args[0]->getType() << Args[0]->getSourceRange() << Range);
+      CandidateSet.NoteCandidates(PartialDiagnosticAt(LLoc, PD), *this,
+                                  OCD_AllCandidates, ArgExpr, "[]", LLoc);
+      return ExprError();
+    }
 
-  case OR_Ambiguous:
-    if (Args.size() == 2) {
-      CandidateSet.NoteCandidates(
-          PartialDiagnosticAt(LLoc, PDiag(diag::err_ovl_ambiguous_oper_binary)
-                                        << "[]" << Args[0]->getType()
-                                        << Args[1]->getType()
-                                        << Args[0]->getSourceRange() << Range),
-          *this, OCD_AmbiguousCandidates, Args, "[]", LLoc);
-    } else {
+    case OR_Ambiguous:
+      if (Args.size() == 2) {
+        CandidateSet.NoteCandidates(
+            PartialDiagnosticAt(
+                LLoc, PDiag(diag::err_ovl_ambiguous_oper_binary)
+                          << "[]" << Args[0]->getType() << Args[1]->getType()
+                          << Args[0]->getSourceRange() << Range),
+            *this, OCD_AmbiguousCandidates, Args, "[]", LLoc);
+      } else {
+        CandidateSet.NoteCandidates(
+            PartialDiagnosticAt(LLoc,
+                                PDiag(diag::err_ovl_ambiguous_subscript_call)
+                                    << Args[0]->getType()
+                                    << Args[0]->getSourceRange() << Range),
+            *this, OCD_AmbiguousCandidates, Args, "[]", LLoc);
+      }
+      return ExprError();
+
+    case OR_Deleted: {
+      StringLiteral *Msg = Best->Function->getDeletedMessage();
       CandidateSet.NoteCandidates(
           PartialDiagnosticAt(LLoc,
-                              PDiag(diag::err_ovl_ambiguous_subscript_call)
-                                  << Args[0]->getType()
+                              PDiag(diag::err_ovl_deleted_oper)
+                                  << "[]" << (Msg != nullptr)
+                                  << (Msg ? Msg->getString() : StringRef())
                                   << Args[0]->getSourceRange() << Range),
-          *this, OCD_AmbiguousCandidates, Args, "[]", LLoc);
+          *this, OCD_AllCandidates, Args, "[]", LLoc);
+      return ExprError();
+    }
     }
-    return ExprError();
-
-  case OR_Deleted: {
-    StringLiteral *Msg = Best->Function->getDeletedMessage();
-    CandidateSet.NoteCandidates(
-        PartialDiagnosticAt(LLoc, PDiag(diag::err_ovl_deleted_oper)
-                                      << "[]" << (Msg != nullptr)
-                                      << (Msg ? Msg->getString() : StringRef())
-                                      << Args[0]->getSourceRange() << Range),
-        *this, OCD_AllCandidates, Args, "[]", LLoc);
-    return ExprError();
-  }
-  }
 
   // We matched a built-in operator; build it.
   return CreateBuiltinArraySubscriptExpr(Args[0], LLoc, Args[1], RLoc);
@@ -16123,7 +16258,7 @@ ExprResult Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
     assert(op->getOpcode() == BO_PtrMemD || op->getOpcode() == BO_PtrMemI);
 
     QualType fnType =
-        op->getRHS()->getType()->castAs<MemberPointerType>()->getPointeeType();
+      op->getRHS()->getType()->castAs<MemberPointerType>()->getPointeeType();
 
     const FunctionProtoType *proto = fnType->castAs<FunctionProtoType>();
     QualType resultType = proto->getCallResultType(Context);
@@ -16144,8 +16279,9 @@ ExprResult Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
     if (difference) {
       std::string qualsString = difference.getAsString();
       Diag(LParenLoc, diag::err_pointer_to_member_call_drops_quals)
-          << fnType.getUnqualifiedType() << qualsString
-          << (qualsString.find(' ') == std::string::npos ? 1 : 2);
+        << fnType.getUnqualifiedType()
+        << qualsString
+        << (qualsString.find(' ') == std::string::npos ? 1 : 2);
     }
 
     CXXMemberCallExpr *call = CXXMemberCallExpr::Create(
@@ -16200,9 +16336,9 @@ ExprResult Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
     Qualifier = UnresExpr->getQualifier();
 
     QualType ObjectType = UnresExpr->getBaseType();
-    Expr::Classification ObjectClassification =
-        UnresExpr->isArrow() ? Expr::Classification::makeSimpleLValue()
-                             : UnresExpr->getBase()->Classify(Context);
+    Expr::Classification ObjectClassification
+      = UnresExpr->isArrow()? Expr::Classification::makeSimpleLValue()
+                            : UnresExpr->getBase()->Classify(Context);
 
     // Add overload candidates
     OverloadCandidateSet CandidateSet(UnresExpr->getMemberLoc(),
@@ -16216,8 +16352,7 @@ ExprResult Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
     }
 
     for (UnresolvedMemberExpr::decls_iterator I = UnresExpr->decls_begin(),
-                                              E = UnresExpr->decls_end();
-         I != E; ++I) {
+           E = UnresExpr->decls_end(); I != E; ++I) {
 
       QualType ExplicitObjectType = ObjectType;
 
@@ -16373,7 +16508,8 @@ ExprResult Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
     return BuildRecoveryExpr(ResultType);
 
   // Convert the rest of the arguments
-  if (ConvertArgumentsForCall(TheCall, MemExpr, Method, Proto, Args, RParenLoc))
+  if (ConvertArgumentsForCall(TheCall, MemExpr, Method, Proto, Args,
+                              RParenLoc))
     return BuildRecoveryExpr(ResultType);
 
   DiagnoseSentinelCalls(Method, LParenLoc, Args);
@@ -16427,10 +16563,11 @@ ExprResult Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
                                      TheCall->getDirectCallee());
 }
 
-ExprResult Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,
-                                              SourceLocation LParenLoc,
-                                              MultiExprArg Args,
-                                              SourceLocation RParenLoc) {
+ExprResult
+Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,
+                                   SourceLocation LParenLoc,
+                                   MultiExprArg Args,
+                                   SourceLocation RParenLoc) {
   if (checkPlaceholderForOverload(*this, Obj))
     return ExprError();
   ExprResult Object = Obj;
@@ -16523,8 +16660,8 @@ ExprResult Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,
       if (const PointerType *ConvPtrType = ConvType->getAs<PointerType>())
         ConvType = ConvPtrType->getPointeeType();
 
-      if (const FunctionProtoType *Proto =
-              ConvType->getAs<FunctionProtoType>()) {
+      if (const FunctionProtoType *Proto = ConvType->getAs<FunctionProtoType>())
+      {
         AddSurrogateCandidate(Conv, I.getPair(), ActingContext, Proto,
                               Object.get(), Args, CandidateSet);
       }
@@ -16589,15 +16726,16 @@ ExprResult Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,
   if (Best->Function == nullptr) {
     // Since there is no function declaration, this is one of the
     // surrogate candidates. Dig out the conversion function.
-    CXXConversionDecl *Conv = cast<CXXConversionDecl>(
-        Best->Conversions[0].UserDefined.ConversionFunction);
+    CXXConversionDecl *Conv
+      = cast<CXXConversionDecl>(
+                         Best->Conversions[0].UserDefined.ConversionFunction);
 
     CheckMemberOperatorAccess(LParenLoc, Object.get(), nullptr,
                               Best->FoundDecl);
     if (DiagnoseUseOfDecl(Best->FoundDecl, LParenLoc))
       return ExprError();
     assert(Conv == Best->FoundDecl.getDecl() &&
-           "Found Decl & conversion-to-functionptr should be same, right?!");
+             "Found Decl & conversion-to-functionptr should be same, right?!");
     // We selected one of the surrogate functions that converts the
     // object parameter to a function pointer. Perform the conversion
     // on the object argument, then let BuildCallExpr finish the job.
@@ -16631,11 +16769,12 @@ ExprResult Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,
   unsigned NumParams = Proto->getNumParams();
 
   DeclarationNameInfo OpLocInfo(
-      Context.DeclarationNames.getCXXOperatorName(OO_Call), LParenLoc);
+               Context.DeclarationNames.getCXXOperatorName(OO_Call), LParenLoc);
   OpLocInfo.setCXXOperatorNameRange(SourceRange(LParenLoc, RParenLoc));
-  ExprResult NewFn = CreateFunctionRefExpr(
-      *this, Method, Best->FoundDecl, Obj, HadMultipleCandidates,
-      OpLocInfo.getLoc(), OpLocInfo.getInfo());
+  ExprResult NewFn = CreateFunctionRefExpr(*this, Method, Best->FoundDecl,
+                                           Obj, HadMultipleCandidates,
+                                           OpLocInfo.getLoc(),
+                                           OpLocInfo.getInfo());
   if (NewFn.isInvalid())
     return true;
 
@@ -16713,7 +16852,7 @@ ExprResult Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base,
   //   the operator is selected as the best match function by the
   //   overload resolution mechanism (13.3).
   DeclarationName OpName =
-      Context.DeclarationNames.getCXXOperatorName(OO_Arrow);
+    Context.DeclarationNames.getCXXOperatorName(OO_Arrow);
   OverloadCandidateSet CandidateSet(Loc, OverloadCandidateSet::CSK_Operator);
 
   if (RequireCompleteType(Loc, Base->getType(),
@@ -16741,8 +16880,7 @@ ExprResult Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base,
     break;
 
   case OR_No_Viable_Function: {
-    auto Cands =
-        CandidateSet.CompleteCandidates(*this, OCD_AllCandidates, Base);
+    auto Cands = CandidateSet.CompleteCandidates(*this, OCD_AllCandidates, Base);
     if (CandidateSet.empty()) {
       QualType BaseType = Base->getType();
       if (NoArrowOperatorFound) {
@@ -16752,14 +16890,14 @@ ExprResult Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base,
         return ExprError();
       }
       Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
-          << BaseType << Base->getSourceRange();
+        << BaseType << Base->getSourceRange();
       if (BaseType->isRecordType() && !BaseType->isPointerType()) {
         Diag(OpLoc, diag::note_typecheck_member_reference_suggestion)
-            << FixItHint::CreateReplacement(OpLoc, ".");
+          << FixItHint::CreateReplacement(OpLoc, ".");
       }
     } else
       Diag(OpLoc, diag::err_ovl_no_viable_oper)
-          << "operator->" << Base->getSourceRange();
+        << "operator->" << Base->getSourceRange();
     CandidateSet.NoteCandidates(*this, Base, Cands);
     return ExprError();
   }
@@ -16826,10 +16964,11 @@ ExprResult Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base,
   return CheckForImmediateInvocation(MaybeBindToTemporary(TheCall), Method);
 }
 
-ExprResult
-Sema::BuildLiteralOperatorCall(LookupResult &R, DeclarationNameInfo &SuffixInfo,
-                               ArrayRef<Expr *> Args, SourceLocation LitEndLoc,
-                               TemplateArgumentListInfo *TemplateArgs) {
+ExprResult Sema::BuildLiteralOperatorCall(LookupResult &R,
+                                          DeclarationNameInfo &SuffixInfo,
+                                          ArrayRef<Expr*> Args,
+                                          SourceLocation LitEndLoc,
+                                       TemplateArgumentListInfo *TemplateArgs) {
   SourceLocation UDSuffixLoc = SuffixInfo.getCXXLiteralOperatorNameLoc();
 
   OverloadCandidateSet CandidateSet(UDSuffixLoc,
@@ -16864,9 +17003,10 @@ Sema::BuildLiteralOperatorCall(LookupResult &R, DeclarationNameInfo &SuffixInfo,
   }
 
   FunctionDecl *FD = Best->Function;
-  ExprResult Fn = CreateFunctionRefExpr(
-      *this, FD, Best->FoundDecl, nullptr, HadMultipleCandidates,
-      SuffixInfo.getLoc(), SuffixInfo.getInfo());
+  ExprResult Fn = CreateFunctionRefExpr(*this, FD, Best->FoundDecl,
+                                        nullptr, HadMultipleCandidates,
+                                        SuffixInfo.getLoc(),
+                                        SuffixInfo.getInfo());
   if (Fn.isInvalid())
     return true;
 
@@ -16874,10 +17014,9 @@ Sema::BuildLiteralOperatorCall(LookupResult &R, DeclarationNameInfo &SuffixInfo,
   // that array-to-pointer decay is applied to string literals.
   Expr *ConvArgs[2];
   for (unsigned ArgIdx = 0, N = Args.size(); ArgIdx != N; ++ArgIdx) {
-    ExprResult InputInit =
-        PerformCopyInitialization(InitializedEntity::InitializeParameter(
-                                      Context, FD->getParamDecl(ArgIdx)),
-                                  SourceLocation(), Args[ArgIdx]);
+    ExprResult InputInit = PerformCopyInitialization(
+      InitializedEntity::InitializeParameter(Context, FD->getParamDecl(ArgIdx)),
+      SourceLocation(), Args[ArgIdx]);
     if (InputInit.isInvalid())
       return true;
     ConvArgs[ArgIdx] = InputInit.get();
@@ -16900,20 +17039,24 @@ Sema::BuildLiteralOperatorCall(LookupResult &R, DeclarationNameInfo &SuffixInfo,
   return CheckForImmediateInvocation(MaybeBindToTemporary(UDL), FD);
 }
 
-Sema::ForRangeStatus Sema::BuildForRangeBeginEndCall(
-    SourceLocation Loc, SourceLocation RangeLoc,
-    const DeclarationNameInfo &NameInfo, LookupResult &MemberLookup,
-    OverloadCandidateSet *CandidateSet, Expr *Range, ExprResult *CallExpr) {
+Sema::ForRangeStatus
+Sema::BuildForRangeBeginEndCall(SourceLocation Loc,
+                                SourceLocation RangeLoc,
+                                const DeclarationNameInfo &NameInfo,
+                                LookupResult &MemberLookup,
+                                OverloadCandidateSet *CandidateSet,
+                                Expr *Range, ExprResult *CallExpr) {
   Scope *S = nullptr;
 
   CandidateSet->clear(OverloadCandidateSet::CSK_Normal);
   if (!MemberLookup.empty()) {
-    ExprResult MemberRef = BuildMemberReferenceExpr(
-        Range, Range->getType(), Loc,
-        /*IsPtr=*/false, CXXScopeSpec(),
-        /*TemplateKWLoc=*/SourceLocation(),
-        /*FirstQualifierInScope=*/nullptr, MemberLookup,
-        /*TemplateArgs=*/nullptr, S);
+    ExprResult MemberRef =
+        BuildMemberReferenceExpr(Range, Range->getType(), Loc,
+                                 /*IsPtr=*/false, CXXScopeSpec(),
+                                 /*TemplateKWLoc=*/SourceLocation(),
+                                 /*FirstQualifierInScope=*/nullptr,
+                                 MemberLookup,
+                                 /*TemplateArgs=*/nullptr, S);
     if (MemberRef.isInvalid()) {
       *CallExpr = ExprError();
       return FRS_DiagnosticIssued;
@@ -16931,8 +17074,8 @@ Sema::ForRangeStatus Sema::BuildForRangeBeginEndCall(
       return FRS_DiagnosticIssued;
     UnresolvedLookupExpr *Fn = cast<UnresolvedLookupExpr>(FnR.get());
 
-    bool CandidateSetError =
-        buildOverloadedCallSet(S, Fn, Fn, Range, Loc, CandidateSet, CallExpr);
+    bool CandidateSetError = buildOverloadedCallSet(S, Fn, Fn, Range, Loc,
+                                                    CandidateSet, CallExpr);
     if (CandidateSet->empty() || CandidateSetError) {
       *CallExpr = ExprError();
       return FRS_NoViableFunction;
@@ -16945,10 +17088,10 @@ Sema::ForRangeStatus Sema::BuildForRangeBeginEndCall(
       *CallExpr = ExprError();
       return FRS_NoViableFunction;
     }
-    *CallExpr =
-        FinishOverloadedCallExpr(*this, S, Fn, Fn, Loc, Range, Loc, nullptr,
-                                 CandidateSet, &Best, OverloadResult,
-                                 /*AllowTypoCorrection=*/false);
+    *CallExpr = FinishOverloadedCallExpr(*this, S, Fn, Fn, Loc, Range,
+                                         Loc, nullptr, CandidateSet, &Best,
+                                         OverloadResult,
+                                         /*AllowTypoCorrection=*/false);
     if (CallExpr->isInvalid() || OverloadResult != OR_Success) {
       *CallExpr = ExprError();
       return FRS_DiagnosticIssued;
@@ -17152,8 +17295,8 @@ ExprResult Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found,
     return BuildMemberExpr(
         Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(),
         MemExpr->getQualifierLoc(), MemExpr->getTemplateKeywordLoc(), Fn, Found,
-        /*HadMultipleCandidates=*/true, MemExpr->getMemberNameInfo(), type,
-        valueKind, OK_Ordinary, TemplateArgs);
+        /*HadMultipleCandidates=*/true, MemExpr->getMemberNameInfo(),
+        type, valueKind, OK_Ordinary, TemplateArgs);
   }
 
   llvm_unreachable("Invalid reference to overloaded function");

>From 0953ddbc607638cd699814e44d18904f60795f0f Mon Sep 17 00:00:00 2001
From: changkhothuychung <nhat7203 at gmail.com>
Date: Wed, 8 Apr 2026 18:02:04 -0400
Subject: [PATCH 16/23] revert clang format

---
 clang/lib/AST/ByteCode/Compiler.cpp | 40 ++++++++++++++---------------
 clang/lib/AST/ByteCode/Interp.h     | 25 +++++++++---------
 2 files changed, 32 insertions(+), 33 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index c2f48200a102e..3755e54ebecfb 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -4248,10 +4248,10 @@ bool Compiler<Emitter>::VisitCXXReflectExpr(const CXXReflectExpr *E) {
     return true;
 
   switch (E->getKind()) {
-  case ReflectionKind::Type: {
-    APValue Result(ReflectionKind::Type, E->getOpaqueValue());
-    return this->emitReflectValue(E->getKind(), E->getOpaqueValue(), E);
-  }
+    case ReflectionKind::Type: {
+      APValue Result(ReflectionKind::Type, E->getOpaqueValue());
+      return this->emitReflectValue(E->getKind(), E->getOpaqueValue(), E);
+    }
   }
 
   return false;
@@ -6173,28 +6173,28 @@ bool Compiler<Emitter>::visitWhileStmt(const WhileStmt *S) {
       return false;
   }
 
-  if (!this->visitBool(Cond))
-    return false;
+    if (!this->visitBool(Cond))
+      return false;
 
-  if (!this->maybeEmitDeferredVarInit(S->getConditionVariable()))
-    return false;
+    if (!this->maybeEmitDeferredVarInit(S->getConditionVariable()))
+      return false;
 
-  if (!this->jumpFalse(EndLabel, S))
-    return false;
+    if (!this->jumpFalse(EndLabel, S))
+      return false;
 
-  if (!this->visitStmt(Body))
-    return false;
+    if (!this->visitStmt(Body))
+      return false;
 
-  if (!CondScope.destroyLocals())
-    return false;
-  // } End of loop body.
+    if (!CondScope.destroyLocals())
+      return false;
+    // } End of loop body.
 
-  if (!this->jump(CondLabel, S))
-    return false;
-  this->fallthrough(EndLabel);
-  this->emitLabel(EndLabel);
+    if (!this->jump(CondLabel, S))
+      return false;
+    this->fallthrough(EndLabel);
+    this->emitLabel(EndLabel);
 
-  return CondScope.destroyLocals() && WholeLoopScope.destroyLocals();
+    return CondScope.destroyLocals() && WholeLoopScope.destroyLocals();
 }
 
 template <class Emitter> bool Compiler<Emitter>::visitDoStmt(const DoStmt *S) {
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 73b0b6248a7ad..647e2abe729df 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -16,6 +16,7 @@
 #include "../ExprConstShared.h"
 #include "BitcastBuffer.h"
 #include "Boolean.h"
+#include "Reflect.h"
 #include "DynamicAllocator.h"
 #include "FixedPoint.h"
 #include "Floating.h"
@@ -28,7 +29,6 @@
 #include "MemberPointer.h"
 #include "PrimType.h"
 #include "Program.h"
-#include "Reflect.h"
 #include "State.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Expr.h"
@@ -2959,16 +2959,16 @@ inline bool DoShift(InterpState &S, CodePtr OpPC, LT &LHS, RT &RHS,
     return true;
   }
 
-  // Right shift.
-  if (Compare(RHS, RT::from(MaxShiftAmount, RHS.bitWidth())) ==
-      ComparisonCategoryResult::Greater) {
-    R = LT::AsUnsigned::from(-1);
-  } else {
-    // Do the shift on potentially signed LT, then convert to unsigned type.
-    LT A;
-    LT::shiftRight(LHS, LT::from(RHS, Bits), Bits, &A);
-    R = LT::AsUnsigned::from(A);
-  }
+    // Right shift.
+    if (Compare(RHS, RT::from(MaxShiftAmount, RHS.bitWidth())) ==
+        ComparisonCategoryResult::Greater) {
+      R = LT::AsUnsigned::from(-1);
+    } else {
+      // Do the shift on potentially signed LT, then convert to unsigned type.
+      LT A;
+      LT::shiftRight(LHS, LT::from(RHS, Bits), Bits, &A);
+      R = LT::AsUnsigned::from(A);
+    }
 
   S.Stk.push<LT>(LT::from(R));
   return true;
@@ -3733,8 +3733,7 @@ inline bool CheckDestruction(InterpState &S, CodePtr OpPC) {
   return CheckDestructor(S, OpPC, Ptr);
 }
 
-inline bool ReflectValue(InterpState &S, CodePtr OpPC, ReflectionKind Kind,
-                         const void *Operand) {
+inline bool ReflectValue(InterpState &S, CodePtr OpPC, ReflectionKind Kind, const void *Operand) {
   S.Stk.push<Reflect>(Kind, Operand);
   return true;
 }

>From 8a4f22cf352a97e59c2d1b0c868d04abf7db929b Mon Sep 17 00:00:00 2001
From: Nhat Nguyen <nhat7203 at gmail.com>
Date: Thu, 9 Apr 2026 18:32:06 -0400
Subject: [PATCH 17/23] Update clang/lib/AST/Type.cpp

Co-authored-by: Sirraide <aeternalmail at gmail.com>
---
 clang/lib/AST/Type.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index e93397d149f0b..6c692f2f428c6 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -3498,7 +3498,7 @@ StringRef BuiltinType::getName(const PrintingPolicy &Policy) const {
   case ULongAccum:
     return "unsigned long _Accum";
   case BuiltinType::MetaInfo:
-    return "meta::info";
+    return "std::meta::info";
   case BuiltinType::ShortFract:
     return "short _Fract";
   case BuiltinType::Fract:

>From 5cc2375ebdc256763c4db693d8acb18343c28769 Mon Sep 17 00:00:00 2001
From: changkhothuychung <nhat7203 at gmail.com>
Date: Thu, 9 Apr 2026 19:09:35 -0400
Subject: [PATCH 18/23] follow gcc's value of alignof for meta::info

---
 clang/lib/Basic/TargetInfo.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index aece64157ce88..09090e1903355 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -127,7 +127,7 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : Triple(T) {
   Float128Align = 128;
   Ibm128Align = 128;
   MetaInfoWidth = 64;
-  MetaInfoAlign = 64;
+  MetaInfoAlign = 8;
   LargeArrayMinWidth = 0;
   LargeArrayAlign = 0;
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 0;

>From 271e24f02e5bbf5beef56d314c656258ec052ea5 Mon Sep 17 00:00:00 2001
From: changkhothuychung <nhat7203 at gmail.com>
Date: Mon, 13 Apr 2026 10:49:55 -0400
Subject: [PATCH 19/23] update test

---
 clang/test/Sema/reflection-meta-info.fail.cpp | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/clang/test/Sema/reflection-meta-info.fail.cpp b/clang/test/Sema/reflection-meta-info.fail.cpp
index 2eade98ea6c5d..8cdd4ffe739fa 100644
--- a/clang/test/Sema/reflection-meta-info.fail.cpp
+++ b/clang/test/Sema/reflection-meta-info.fail.cpp
@@ -2,20 +2,20 @@
 
 using info = decltype(^^int);
 
-struct X { int a; }; // expected-note {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'meta::info' to 'const X' for 1st argument}} \
-                     // expected-note {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'meta::info' to 'X' for 1st argument}} \
+struct X { int a; }; // expected-note {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'std::meta::info' to 'const X' for 1st argument}} \
+                     // expected-note {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'std::meta::info' to 'X' for 1st argument}} \
                      // expected-note {{candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided}}
 template <typename T = X, auto ptm = &X::a>
-constexpr auto ptmOp = ((T)(^^int)).*ptm; // expected-error {{no matching conversion for C-style cast from 'meta::info' to 'X'}}
+constexpr auto ptmOp = ((T)(^^int)).*ptm; // expected-error {{no matching conversion for C-style cast from 'std::meta::info' to 'X'}}
 constexpr auto var = ptmOp<>; // expected-note {{in instantiation of variable template specialization 'ptmOp' requested here}}
 
 consteval void test()
 {
-    (^^char)++; // expected-error {{cannot increment value of type 'meta::info'}}
-    (^^short)++; // expected-error {{cannot increment value of type 'meta::info'}}
-    (^^int)++; // expected-error {{cannot increment value of type 'meta::info'}}
+    (^^char)++; // expected-error {{cannot increment value of type 'std::meta::info'}}
+    (^^short)++; // expected-error {{cannot increment value of type 'std::meta::info'}}
+    (^^int)++; // expected-error {{cannot increment value of type 'std::meta::info'}}
 
-    (^^char)--; // expected-error {{cannot decrement value of type 'meta::info'}}
-    (^^short)--; // expected-error {{cannot decrement value of type 'meta::info'}}
-    (^^int)--; // expected-error {{cannot decrement value of type 'meta::info'}}
+    (^^char)--; // expected-error {{cannot decrement value of type 'std::meta::info'}}
+    (^^short)--; // expected-error {{cannot decrement value of type 'std::meta::info'}}
+    (^^int)--; // expected-error {{cannot decrement value of type 'std::meta::info'}}
 }

>From 4126bb962e14fdfce97c8ea2cc18f8bc7beedd77 Mon Sep 17 00:00:00 2001
From: changkhothuychung <nhat7203 at gmail.com>
Date: Mon, 13 Apr 2026 14:28:32 -0400
Subject: [PATCH 20/23] support for std::meta::info as NTTP argument

---
 clang/include/clang/AST/BuiltinTypes.def      |    6 +-
 clang/include/clang/AST/ExprCXX.h             |  113 +-
 clang/lib/AST/ExprCXX.cpp                     |    2 +-
 clang/lib/Sema/SemaTemplate.cpp               | 1299 +++++++-------
 clang/lib/Sema/SemaTemplateInstantiate.cpp    | 1556 ++++++++---------
 clang/test/Sema/reflection-meta-info.pass.cpp |   22 +-
 6 files changed, 1463 insertions(+), 1535 deletions(-)

diff --git a/clang/include/clang/AST/BuiltinTypes.def b/clang/include/clang/AST/BuiltinTypes.def
index 87a376a839cda..ee2f3f0365126 100644
--- a/clang/include/clang/AST/BuiltinTypes.def
+++ b/clang/include/clang/AST/BuiltinTypes.def
@@ -223,12 +223,12 @@ FLOATING_TYPE(Ibm128, Ibm128Ty)
 
 //===- Language-specific types --------------------------------------------===//
 
-// This is the type of C++0x 'nullptr'.
-BUILTIN_TYPE(NullPtr, NullPtrTy)
-
 // 'std::meta::info' in C++
 BUILTIN_TYPE(MetaInfo, MetaInfoTy)
 
+// This is the type of C++0x 'nullptr'.
+BUILTIN_TYPE(NullPtr, NullPtrTy)
+
 // The primitive Objective C 'id' type.  The user-visible 'id'
 // type is a typedef of an ObjCObjectPointerType to an
 // ObjCObjectType with this as its base.  In fact, this only ever
diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h
index 824d96cb9dae1..601d6b2aec3c2 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -497,12 +497,10 @@ class CXXDynamicCastExpr final
   friend class CastExpr;
   friend TrailingObjects;
 
-  static CXXDynamicCastExpr *Create(const ASTContext &Context, QualType T,
-                                    ExprValueKind VK, CastKind Kind, Expr *Op,
-                                    const CXXCastPath *Path,
-                                    TypeSourceInfo *Written, SourceLocation L,
-                                    SourceLocation RParenLoc,
-                                    SourceRange AngleBrackets);
+  static CXXDynamicCastExpr *
+  Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind,
+         Expr *Op, const CXXCastPath *Path, TypeSourceInfo *Written,
+         SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets);
 
   static CXXDynamicCastExpr *CreateEmpty(const ASTContext &Context,
                                          unsigned pathSize);
@@ -542,12 +540,10 @@ class CXXReinterpretCastExpr final
   friend class CastExpr;
   friend TrailingObjects;
 
-  static CXXReinterpretCastExpr *Create(const ASTContext &Context, QualType T,
-                                        ExprValueKind VK, CastKind Kind,
-                                        Expr *Op, const CXXCastPath *Path,
-                                 TypeSourceInfo *WrittenTy, SourceLocation L,
-                                        SourceLocation RParenLoc,
-                                        SourceRange AngleBrackets);
+  static CXXReinterpretCastExpr *
+  Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind,
+         Expr *Op, const CXXCastPath *Path, TypeSourceInfo *WrittenTy,
+         SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets);
   static CXXReinterpretCastExpr *CreateEmpty(const ASTContext &Context,
                                              unsigned pathSize);
 
@@ -696,7 +692,7 @@ class UserDefinedLiteral final : public CallExpr {
   /// removed).
   Expr *getCookedLiteral();
   const Expr *getCookedLiteral() const {
-    return const_cast<UserDefinedLiteral*>(this)->getCookedLiteral();
+    return const_cast<UserDefinedLiteral *>(this)->getCookedLiteral();
   }
 
   SourceLocation getBeginLoc() const {
@@ -815,8 +811,8 @@ class CXXStdInitializerListExpr : public Expr {
     setDependence(computeDependence(this));
   }
 
-  Expr *getSubExpr() { return static_cast<Expr*>(SubExpr); }
-  const Expr *getSubExpr() const { return static_cast<const Expr*>(SubExpr); }
+  Expr *getSubExpr() { return static_cast<Expr *>(SubExpr); }
+  const Expr *getSubExpr() const { return static_cast<const Expr *>(SubExpr); }
 
   SourceLocation getBeginLoc() const LLVM_READONLY {
     return SubExpr->getBeginLoc();
@@ -870,9 +866,9 @@ class CXXTypeidExpr : public Expr {
   CXXTypeidExpr(EmptyShell Empty, bool isExpr)
       : Expr(CXXTypeidExprClass, Empty) {
     if (isExpr)
-      Operand = (Expr*)nullptr;
+      Operand = (Expr *)nullptr;
     else
-      Operand = (TypeSourceInfo*)nullptr;
+      Operand = (TypeSourceInfo *)nullptr;
   }
 
   /// Determine whether this typeid has a type operand which is potentially
@@ -970,13 +966,13 @@ class MSPropertyRefExpr : public Expr {
     else if (QualifierLoc)
       return QualifierLoc.getBeginLoc();
     else
-        return MemberLoc;
+      return MemberLoc;
   }
 
   SourceLocation getEndLoc() const { return getMemberLoc(); }
 
   child_range children() {
-    return child_range((Stmt**)&BaseExpr, (Stmt**)&BaseExpr + 1);
+    return child_range((Stmt **)&BaseExpr, (Stmt **)&BaseExpr + 1);
   }
 
   const_child_range children() const {
@@ -1090,11 +1086,11 @@ class CXXUuidofExpr : public Expr {
   }
 
   CXXUuidofExpr(EmptyShell Empty, bool isExpr)
-    : Expr(CXXUuidofExprClass, Empty) {
+      : Expr(CXXUuidofExprClass, Empty) {
     if (isExpr)
-      Operand = (Expr*)nullptr;
+      Operand = (Expr *)nullptr;
     else
-      Operand = (TypeSourceInfo*)nullptr;
+      Operand = (TypeSourceInfo *)nullptr;
   }
 
   bool isTypeOperand() const { return isa<TypeSourceInfo *>(Operand); }
@@ -1471,9 +1467,7 @@ class CXXTemporary {
 
   const CXXDestructorDecl *getDestructor() const { return Destructor; }
 
-  void setDestructor(const CXXDestructorDecl *Dtor) {
-    Destructor = Dtor;
-  }
+  void setDestructor(const CXXDestructorDecl *Dtor) { Destructor = Dtor; }
 };
 
 /// Represents binding an expression to a temporary.
@@ -1508,7 +1502,7 @@ class CXXBindTemporaryExpr : public Expr {
       : Expr(CXXBindTemporaryExprClass, Empty) {}
 
   static CXXBindTemporaryExpr *Create(const ASTContext &C, CXXTemporary *Temp,
-                                      Expr* SubExpr);
+                                      Expr *SubExpr);
 
   CXXTemporary *getTemporary() { return Temp; }
   const CXXTemporary *getTemporary() const { return Temp; }
@@ -2214,9 +2208,7 @@ class CXXScalarValueInitExpr : public Expr {
   explicit CXXScalarValueInitExpr(EmptyShell Shell)
       : Expr(CXXScalarValueInitExprClass, Shell) {}
 
-  TypeSourceInfo *getTypeSourceInfo() const {
-    return TypeInfo;
-  }
+  TypeSourceInfo *getTypeSourceInfo() const { return TypeInfo; }
 
   SourceLocation getRParenLoc() const {
     return CXXScalarValueInitExprBits.RParenLoc;
@@ -2777,12 +2769,11 @@ class CXXPseudoDestructorExpr : public Expr {
   PseudoDestructorTypeStorage DestroyedType;
 
 public:
-  CXXPseudoDestructorExpr(const ASTContext &Context,
-                          Expr *Base, bool isArrow, SourceLocation OperatorLoc,
+  CXXPseudoDestructorExpr(const ASTContext &Context, Expr *Base, bool isArrow,
+                          SourceLocation OperatorLoc,
                           NestedNameSpecifierLoc QualifierLoc,
                           TypeSourceInfo *ScopeType,
-                          SourceLocation ColonColonLoc,
-                          SourceLocation TildeLoc,
+                          SourceLocation ColonColonLoc, SourceLocation TildeLoc,
                           PseudoDestructorTypeStorage DestroyedType);
 
   explicit CXXPseudoDestructorExpr(EmptyShell Shell)
@@ -2925,8 +2916,7 @@ class TypeTraitExpr final
   static TypeTraitExpr *Create(const ASTContext &C, QualType T,
                                SourceLocation Loc, TypeTrait Kind,
                                ArrayRef<TypeSourceInfo *> Args,
-                               SourceLocation RParenLoc,
-                               bool Value);
+                               SourceLocation RParenLoc, bool Value);
 
   static TypeTraitExpr *Create(const ASTContext &C, QualType T,
                                SourceLocation Loc, TypeTrait Kind,
@@ -3043,7 +3033,10 @@ class ArrayTypeTraitExpr : public Expr {
 
   TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; }
 
-  uint64_t getValue() const { assert(!isTypeDependent()); return Value; }
+  uint64_t getValue() const {
+    assert(!isTypeDependent());
+    return Value;
+  }
 
   Expr *getDimensionExpression() const { return Dimension; }
 
@@ -3076,7 +3069,7 @@ class ExpressionTraitExpr : public Expr {
   SourceLocation RParen;
 
   /// The expression being queried.
-  Expr* QueriedExpression = nullptr;
+  Expr *QueriedExpression = nullptr;
 
 public:
   friend class ASTStmtReader;
@@ -3810,7 +3803,7 @@ class CXXUnresolvedConstructExpr final
   arg_iterator arg_end() { return arg_begin() + getNumArgs(); }
   arg_range arguments() { return arg_range(arg_begin(), arg_end()); }
 
-  using const_arg_iterator = const Expr* const *;
+  using const_arg_iterator = const Expr *const *;
   using const_arg_range = llvm::iterator_range<const_arg_iterator>;
 
   const_arg_iterator arg_begin() const { return getTrailingObjects(); }
@@ -4420,9 +4413,7 @@ class PackExpansionExpr : public Expr {
   }
 
   // Iterators
-  child_range children() {
-    return child_range(&Pattern, &Pattern + 1);
-  }
+  child_range children() { return child_range(&Pattern, &Pattern + 1); }
 
   const_child_range children() const {
     return const_child_range(&Pattern, &Pattern + 1);
@@ -4525,9 +4516,7 @@ class SizeOfPackExpr final
   ///
   ///   template<typename ...Ts> using X = int[sizeof...(Ts)];
   ///   template<typename ...Us> void f(X<Us..., 1, 2, 3, Us...>);
-  bool isPartiallySubstituted() const {
-    return isValueDependent() && Length;
-  }
+  bool isPartiallySubstituted() const { return isValueDependent() && Length; }
 
   /// Get
   ArrayRef<TemplateArgument> getPartialArguments() const {
@@ -5056,8 +5045,8 @@ class CXXFoldExpr : public Expr {
   UnresolvedLookupExpr *getCallee() const {
     return static_cast<UnresolvedLookupExpr *>(SubExprs[SubExpr::Callee]);
   }
-  Expr *getLHS() const { return static_cast<Expr*>(SubExprs[SubExpr::LHS]); }
-  Expr *getRHS() const { return static_cast<Expr*>(SubExprs[SubExpr::RHS]); }
+  Expr *getLHS() const { return static_cast<Expr *>(SubExprs[SubExpr::LHS]); }
+  Expr *getRHS() const { return static_cast<Expr *>(SubExprs[SubExpr::RHS]); }
 
   /// Does this produce a right-associated sequence of operators?
   bool isRightFold() const {
@@ -5304,22 +5293,22 @@ class CoroutineSuspendExpr : public Expr {
   }
 
   Expr *getCommonExpr() const {
-    return static_cast<Expr*>(SubExprs[SubExpr::Common]);
+    return static_cast<Expr *>(SubExprs[SubExpr::Common]);
   }
 
   /// getOpaqueValue - Return the opaque value placeholder.
   OpaqueValueExpr *getOpaqueValue() const { return OpaqueValue; }
 
   Expr *getReadyExpr() const {
-    return static_cast<Expr*>(SubExprs[SubExpr::Ready]);
+    return static_cast<Expr *>(SubExprs[SubExpr::Ready]);
   }
 
   Expr *getSuspendExpr() const {
-    return static_cast<Expr*>(SubExprs[SubExpr::Suspend]);
+    return static_cast<Expr *>(SubExprs[SubExpr::Suspend]);
   }
 
   Expr *getResumeExpr() const {
-    return static_cast<Expr*>(SubExprs[SubExpr::Resume]);
+    return static_cast<Expr *>(SubExprs[SubExpr::Resume]);
   }
 
   // The syntactic operand written in the code
@@ -5509,22 +5498,22 @@ class BuiltinBitCastExpr final
 ///  - an id-expression.
 class CXXReflectExpr : public Expr {
 
+private:
+  // TODO(Reflection): add support for TemplateReference, NamespaceReference and
+  // DeclRefExpr
+  using operand_type = llvm::PointerUnion<const TypeSourceInfo *>;
 
-  private:
-    // TODO(Reflection): add support for TemplateReference, NamespaceReference and
-    // DeclRefExpr
-    using operand_type = llvm::PointerUnion<const TypeSourceInfo *>;
-
-    SourceLocation CaretCaretLoc;
-    ReflectionKind Kind;
-    operand_type Operand;
+  SourceLocation CaretCaretLoc;
+  ReflectionKind Kind;
+  operand_type Operand;
 
-    CXXReflectExpr(ASTContext &C, SourceLocation CaretCaretLoc, const TypeSourceInfo *TSI);
-    CXXReflectExpr(EmptyShell Empty);
+  CXXReflectExpr(ASTContext &C, SourceLocation CaretCaretLoc,
+                 const TypeSourceInfo *TSI);
+  CXXReflectExpr(EmptyShell Empty);
 
 public:
   static CXXReflectExpr *Create(ASTContext &C, SourceLocation OperatorLoc,
-                                TypeSourceInfo *TL);
+                                const TypeSourceInfo *TSI);
 
   static CXXReflectExpr *CreateEmpty(ASTContext &C);
 
@@ -5543,7 +5532,7 @@ class CXXReflectExpr : public Expr {
   /// Returns location of the '^^'-operator.
   SourceLocation getOperatorLoc() const { return CaretCaretLoc; }
   ReflectionKind getKind() const { return Kind; }
-  const void* getOpaqueValue() const { return Operand.getOpaqueValue(); }
+  const void *getOpaqueValue() const { return Operand.getOpaqueValue(); }
 
   child_range children() {
     // TODO(Reflection)
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index 7e641c8b040e0..26c6490fc8824 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -1948,7 +1948,7 @@ CXXReflectExpr::CXXReflectExpr(ASTContext &C, SourceLocation CaretCaretLoc,
 
 CXXReflectExpr *CXXReflectExpr::Create(ASTContext &C,
                                        SourceLocation CaretCaretLoc,
-                                       TypeSourceInfo *TSI) {
+                                       const TypeSourceInfo *TSI) {
   return new (C) CXXReflectExpr(C, CaretCaretLoc, TSI);
 }
 
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index aa72cb8fa2895..fb57b5d5e2e70 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -50,10 +50,11 @@ using namespace sema;
 
 // Exported for use by Parser.
 SourceRange
-clang::getTemplateParamsRange(TemplateParameterList const * const *Ps,
+clang::getTemplateParamsRange(TemplateParameterList const *const *Ps,
                               unsigned N) {
-  if (!N) return SourceRange();
-  return SourceRange(Ps[0]->getTemplateLoc(), Ps[N-1]->getRAngleLoc());
+  if (!N)
+    return SourceRange();
+  return SourceRange(Ps[0]->getTemplateLoc(), Ps[N - 1]->getRAngleLoc());
 }
 
 unsigned Sema::getTemplateDepth(Scope *S) const {
@@ -175,15 +176,11 @@ bool Sema::hasAnyAcceptableTemplateNames(LookupResult &R,
   return false;
 }
 
-TemplateNameKind Sema::isTemplateName(Scope *S,
-                                      CXXScopeSpec &SS,
-                                      bool hasTemplateKeyword,
-                                      const UnqualifiedId &Name,
-                                      ParsedType ObjectTypePtr,
-                                      bool EnteringContext,
-                                      TemplateTy &TemplateResult,
-                                      bool &MemberOfUnknownSpecialization,
-                                      bool Disambiguation) {
+TemplateNameKind
+Sema::isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword,
+                     const UnqualifiedId &Name, ParsedType ObjectTypePtr,
+                     bool EnteringContext, TemplateTy &TemplateResult,
+                     bool &MemberOfUnknownSpecialization, bool Disambiguation) {
   assert(getLangOpts().CPlusPlus && "No template names in C!");
 
   DeclarationName TName;
@@ -196,7 +193,7 @@ TemplateNameKind Sema::isTemplateName(Scope *S,
 
   case UnqualifiedIdKind::IK_OperatorFunctionId:
     TName = Context.DeclarationNames.getCXXOperatorName(
-                                              Name.OperatorFunctionId.Operator);
+        Name.OperatorFunctionId.Operator);
     break;
 
   case UnqualifiedIdKind::IK_LiteralOperatorId:
@@ -339,7 +336,8 @@ bool Sema::isDeductionGuideName(Scope *S, const IdentifierInfo &Name,
                          /*EnteringContext*/ false))
     return false;
 
-  if (R.empty()) return false;
+  if (R.empty())
+    return false;
   if (R.isAmbiguous()) {
     // FIXME: Diagnose an ambiguity if we find at least one template.
     R.suppressDiagnostics();
@@ -361,8 +359,7 @@ bool Sema::isDeductionGuideName(Scope *S, const IdentifierInfo &Name,
 }
 
 bool Sema::DiagnoseUnknownTemplateName(const IdentifierInfo &II,
-                                       SourceLocation IILoc,
-                                       Scope *S,
+                                       SourceLocation IILoc, Scope *S,
                                        const CXXScopeSpec *SS,
                                        TemplateTy &SuggestedTemplate,
                                        TemplateNameKind &SuggestedKind) {
@@ -542,8 +539,8 @@ bool Sema::LookupTemplateName(LookupResult &Found, Scope *S, CXXScopeSpec &SS,
           bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
                                   Name.getAsString() == CorrectedStr;
           diagnoseTypo(Corrected, PDiag(diag::err_no_member_template_suggest)
-                                    << Name << LookupCtx << DroppedSpecifier
-                                    << SS.getRange());
+                                      << Name << LookupCtx << DroppedSpecifier
+                                      << SS.getRange());
         } else {
           diagnoseTypo(Corrected, PDiag(diag::err_no_template_suggest) << Name);
         }
@@ -612,11 +609,10 @@ bool Sema::LookupTemplateName(LookupResult &Found, Scope *S, CXXScopeSpec &SS,
               OuterTemplate->getCanonicalDecl()) {
         Diag(Found.getNameLoc(),
              diag::ext_nested_name_member_ref_lookup_ambiguous)
-          << Found.getLookupName()
-          << ObjectType;
+            << Found.getLookupName() << ObjectType;
         Diag(Found.getRepresentativeDecl()->getLocation(),
              diag::note_ambig_member_ref_object_type)
-          << ObjectType;
+            << ObjectType;
         Diag(FoundOuter.getFoundDecl()->getLocation(),
              diag::note_ambig_member_ref_scope);
 
@@ -713,11 +709,13 @@ void Sema::diagnoseExprIntendedAsTemplateName(Scope *S, ExprResult TemplateName,
         diagnoseTypo(Corrected,
                      PDiag(diag::err_non_template_in_member_template_id_suggest)
                          << Name << LookupCtx << DroppedSpecifier
-                         << SS.getRange(), false);
+                         << SS.getRange(),
+                     false);
       } else {
         diagnoseTypo(Corrected,
                      PDiag(diag::err_non_template_in_template_id_suggest)
-                         << Name, false);
+                         << Name,
+                     false);
       }
       if (Found)
         Diag(Found->getLocation(),
@@ -727,17 +725,15 @@ void Sema::diagnoseExprIntendedAsTemplateName(Scope *S, ExprResult TemplateName,
   }
 
   Diag(NameInfo.getLoc(), diag::err_non_template_in_template_id)
-    << Name << SourceRange(Less, Greater);
+      << Name << SourceRange(Less, Greater);
   if (Found)
     Diag(Found->getLocation(), diag::note_non_template_in_template_id_found);
 }
 
-ExprResult
-Sema::ActOnDependentIdExpression(const CXXScopeSpec &SS,
-                                 SourceLocation TemplateKWLoc,
-                                 const DeclarationNameInfo &NameInfo,
-                                 bool isAddressOfOperand,
-                           const TemplateArgumentListInfo *TemplateArgs) {
+ExprResult Sema::ActOnDependentIdExpression(
+    const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
+    const DeclarationNameInfo &NameInfo, bool isAddressOfOperand,
+    const TemplateArgumentListInfo *TemplateArgs) {
   if (SS.isEmpty()) {
     // FIXME: This codepath is only used by dependent unqualified names
     // (e.g. a dependent conversion-function-id, or operator= once we support
@@ -845,10 +841,9 @@ bool Sema::DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation,
   if (TagDecl *TD = dyn_cast<TagDecl>(Instantiation))
     InstantiationTy = Context.getCanonicalTagType(TD);
   if (PatternDef) {
-    Diag(PointOfInstantiation,
-         diag::err_template_instantiate_within_definition)
-      << /*implicit|explicit*/(TSK != TSK_ImplicitInstantiation)
-      << InstantiationTy;
+    Diag(PointOfInstantiation, diag::err_template_instantiate_within_definition)
+        << /*implicit|explicit*/ (TSK != TSK_ImplicitInstantiation)
+        << InstantiationTy;
     // Not much point in noting the template declaration here, since
     // we're lexically inside it.
     Instantiation->setInvalidDecl();
@@ -856,39 +851,38 @@ bool Sema::DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation,
     if (isa<FunctionDecl>(Instantiation)) {
       Diag(PointOfInstantiation,
            diag::err_explicit_instantiation_undefined_member)
-        << /*member function*/ 1 << Instantiation->getDeclName()
-        << Instantiation->getDeclContext();
+          << /*member function*/ 1 << Instantiation->getDeclName()
+          << Instantiation->getDeclContext();
       Diag(Pattern->getLocation(), diag::note_explicit_instantiation_here);
     } else {
       assert(isa<TagDecl>(Instantiation) && "Must be a TagDecl!");
       Diag(PointOfInstantiation,
            diag::err_implicit_instantiate_member_undefined)
-        << InstantiationTy;
+          << InstantiationTy;
       Diag(Pattern->getLocation(), diag::note_member_declared_at);
     }
   } else {
     if (isa<FunctionDecl>(Instantiation)) {
       Diag(PointOfInstantiation,
            diag::err_explicit_instantiation_undefined_func_template)
-        << Pattern;
+          << Pattern;
       Diag(Pattern->getLocation(), diag::note_explicit_instantiation_here);
     } else if (isa<TagDecl>(Instantiation)) {
       Diag(PointOfInstantiation, diag::err_template_instantiate_undefined)
-        << (TSK != TSK_ImplicitInstantiation)
-        << InstantiationTy;
+          << (TSK != TSK_ImplicitInstantiation) << InstantiationTy;
       NoteTemplateLocation(*Pattern);
     } else {
       assert(isa<VarDecl>(Instantiation) && "Must be a VarDecl!");
       if (isa<VarTemplateSpecializationDecl>(Instantiation)) {
         Diag(PointOfInstantiation,
              diag::err_explicit_instantiation_undefined_var_template)
-          << Instantiation;
+            << Instantiation;
         Instantiation->setInvalidDecl();
       } else
         Diag(PointOfInstantiation,
              diag::err_explicit_instantiation_undefined_member)
-          << /*static data member*/ 2 << Instantiation->getDeclName()
-          << Instantiation->getDeclContext();
+            << /*static data member*/ 2 << Instantiation->getDeclName()
+            << Instantiation->getDeclContext();
       Diag(Pattern->getLocation(), diag::note_explicit_instantiation_here);
     }
   }
@@ -933,7 +927,7 @@ TemplateDecl *Sema::AdjustDeclIfTemplate(Decl *&D) {
 }
 
 ParsedTemplateArgument ParsedTemplateArgument::getTemplatePackExpansion(
-                                             SourceLocation EllipsisLoc) const {
+    SourceLocation EllipsisLoc) const {
   assert(Kind == Template &&
          "Only template template arguments can be pack expansions here");
   assert(getAsTemplate().get().containsUnexpandedParameterPack() &&
@@ -943,8 +937,8 @@ ParsedTemplateArgument ParsedTemplateArgument::getTemplatePackExpansion(
   return Result;
 }
 
-static TemplateArgumentLoc translateTemplateArgument(Sema &SemaRef,
-                                            const ParsedTemplateArgument &Arg) {
+static TemplateArgumentLoc
+translateTemplateArgument(Sema &SemaRef, const ParsedTemplateArgument &Arg) {
 
   switch (Arg.getKind()) {
   case ParsedTemplateArgument::Type: {
@@ -979,9 +973,9 @@ static TemplateArgumentLoc translateTemplateArgument(Sema &SemaRef,
 
 void Sema::translateTemplateArguments(const ASTTemplateArgsPtr &TemplateArgsIn,
                                       TemplateArgumentListInfo &TemplateArgs) {
- for (unsigned I = 0, Last = TemplateArgsIn.size(); I != Last; ++I)
-   TemplateArgs.addArgument(translateTemplateArgument(*this,
-                                                      TemplateArgsIn[I]));
+  for (unsigned I = 0, Last = TemplateArgsIn.size(); I != Last; ++I)
+    TemplateArgs.addArgument(
+        translateTemplateArgument(*this, TemplateArgsIn[I]));
 }
 
 static void maybeDiagnoseTemplateParameterShadow(Sema &SemaRef, Scope *S,
@@ -1033,24 +1027,19 @@ ParsedTemplateArgument Sema::ActOnTemplateTypeArgument(TypeResult ParsedType) {
                                 TInfo->getTypeLoc().getBeginLoc());
 }
 
-NamedDecl *Sema::ActOnTypeParameter(Scope *S, bool Typename,
-                                    SourceLocation EllipsisLoc,
-                                    SourceLocation KeyLoc,
-                                    IdentifierInfo *ParamName,
-                                    SourceLocation ParamNameLoc,
-                                    unsigned Depth, unsigned Position,
-                                    SourceLocation EqualLoc,
-                                    ParsedType DefaultArg,
-                                    bool HasTypeConstraint) {
+NamedDecl *
+Sema::ActOnTypeParameter(Scope *S, bool Typename, SourceLocation EllipsisLoc,
+                         SourceLocation KeyLoc, IdentifierInfo *ParamName,
+                         SourceLocation ParamNameLoc, unsigned Depth,
+                         unsigned Position, SourceLocation EqualLoc,
+                         ParsedType DefaultArg, bool HasTypeConstraint) {
   assert(S->isTemplateParamScope() &&
          "Template type parameter not in template parameter scope!");
 
   bool IsParameterPack = EllipsisLoc.isValid();
-  TemplateTypeParmDecl *Param
-    = TemplateTypeParmDecl::Create(Context, Context.getTranslationUnitDecl(),
-                                   KeyLoc, ParamNameLoc, Depth, Position,
-                                   ParamName, Typename, IsParameterPack,
-                                   HasTypeConstraint);
+  TemplateTypeParmDecl *Param = TemplateTypeParmDecl::Create(
+      Context, Context.getTranslationUnitDecl(), KeyLoc, ParamNameLoc, Depth,
+      Position, ParamName, Typename, IsParameterPack, HasTypeConstraint);
   Param->setAccess(AS_public);
 
   if (Param->isParameterPack())
@@ -1177,8 +1166,7 @@ bool Sema::BuildTypeConstraint(const CXXScopeSpec &SS,
 
   TemplateArgumentListInfo TemplateArgs;
   if (TypeConstr->LAngleLoc.isValid()) {
-    TemplateArgs =
-        makeTemplateArgumentListInfo(*this, *TypeConstr);
+    TemplateArgs = makeTemplateArgumentListInfo(*this, *TypeConstr);
 
     if (EllipsisLoc.isInvalid() && !AllowUnexpandedPack) {
       for (TemplateArgumentLoc Arg : TemplateArgs.arguments()) {
@@ -1204,8 +1192,8 @@ static ExprResult formImmediatelyDeclaredConstraint(
 
   TemplateArgumentListInfo ConstraintArgs;
   ConstraintArgs.addArgument(
-    S.getTrivialTemplateArgumentLoc(TemplateArgument(ConstrainedType),
-                                    /*NTTPType=*/QualType(), ParamNameLoc));
+      S.getTrivialTemplateArgumentLoc(TemplateArgument(ConstrainedType),
+                                      /*NTTPType=*/QualType(), ParamNameLoc));
 
   ConstraintArgs.setRAngleLoc(RAngleLoc);
   ConstraintArgs.setLAngleLoc(LAngleLoc);
@@ -1264,8 +1252,8 @@ bool Sema::AttachTypeConstraint(NestedNameSpecifierLoc NS,
   //     [...] If Q is of the form C<A1, ..., An>, then let E' be
   //     C<T, A1, ..., An>. Otherwise, let E' be C<T>. [...]
   const ASTTemplateArgumentListInfo *ArgsAsWritten =
-    TemplateArgs ? ASTTemplateArgumentListInfo::Create(Context,
-                                                       *TemplateArgs) : nullptr;
+      TemplateArgs ? ASTTemplateArgumentListInfo::Create(Context, *TemplateArgs)
+                   : nullptr;
 
   QualType ParamAsArgument(ConstrainedParameter->getTypeForDecl(), 0);
 
@@ -1440,8 +1428,7 @@ bool Sema::RequireStructuralType(QualType T, SourceLocation Loc) {
     }
 
     assert(Kind != -1 && "couldn't find reason why type is not structural");
-    Diag(SubLoc, diag::note_not_structural_subobject)
-        << T << Kind << SubType;
+    Diag(SubLoc, diag::note_not_structural_subobject) << T << Kind << SubType;
     T = SubType;
     RD = T->getAsCXXRecordDecl();
   }
@@ -1454,8 +1441,7 @@ QualType Sema::CheckNonTypeTemplateParameterType(QualType T,
   // We don't allow variably-modified types as the type of non-type template
   // parameters.
   if (T->isVariablyModifiedType()) {
-    Diag(Loc, diag::err_variably_modified_nontype_template_param)
-      << T;
+    Diag(Loc, diag::err_variably_modified_nontype_template_param) << T;
     return QualType();
   }
 
@@ -1516,10 +1502,10 @@ QualType Sema::CheckNonTypeTemplateParameterType(QualType T,
 }
 
 NamedDecl *Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
-                                          unsigned Depth,
-                                          unsigned Position,
-                                          SourceLocation EqualLoc,
-                                          Expr *Default) {
+                                               unsigned Depth,
+                                               unsigned Position,
+                                               SourceLocation EqualLoc,
+                                               Expr *Default) {
   TypeSourceInfo *TInfo = GetTypeForDeclarator(D);
 
   // Check that we have valid decl-specifiers specified.
@@ -1699,7 +1685,7 @@ NamedDecl *Sema::ActOnTemplateTemplateParameter(
 
   if (Params->size() == 0) {
     Diag(Param->getLocation(), diag::err_template_template_parm_no_parms)
-    << SourceRange(Params->getLAngleLoc(), Params->getRAngleLoc());
+        << SourceRange(Params->getLAngleLoc(), Params->getRAngleLoc());
     Invalid = true;
   }
 
@@ -1726,7 +1712,7 @@ NamedDecl *Sema::ActOnTemplateTemplateParameter(
     TemplateArgumentLoc DefaultArg = translateTemplateArgument(*this, Default);
     if (DefaultArg.getArgument().getAsTemplate().isNull()) {
       Diag(DefaultArg.getLocation(), diag::err_template_arg_not_valid_template)
-        << DefaultArg.getSourceRange();
+          << DefaultArg.getSourceRange();
       return Param;
     }
 
@@ -1739,9 +1725,9 @@ NamedDecl *Sema::ActOnTemplateTemplateParameter(
     }
 
     // Check for unexpanded parameter packs.
-    if (DiagnoseUnexpandedParameterPack(DefaultArg.getLocation(),
-                                        DefaultArg.getArgument().getAsTemplate(),
-                                        UPPC_DefaultArgument))
+    if (DiagnoseUnexpandedParameterPack(
+            DefaultArg.getLocation(), DefaultArg.getArgument().getAsTemplate(),
+            UPPC_DefaultArgument))
       return Param;
 
     Param->setDefaultArgument(Context, DefaultArg);
@@ -1857,14 +1843,10 @@ bool Sema::ConstraintExpressionDependsOnEnclosingTemplate(
   return Checker.getResult();
 }
 
-TemplateParameterList *
-Sema::ActOnTemplateParameterList(unsigned Depth,
-                                 SourceLocation ExportLoc,
-                                 SourceLocation TemplateLoc,
-                                 SourceLocation LAngleLoc,
-                                 ArrayRef<NamedDecl *> Params,
-                                 SourceLocation RAngleLoc,
-                                 Expr *RequiresClause) {
+TemplateParameterList *Sema::ActOnTemplateParameterList(
+    unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc,
+    SourceLocation LAngleLoc, ArrayRef<NamedDecl *> Params,
+    SourceLocation RAngleLoc, Expr *RequiresClause) {
   if (ExportLoc.isValid())
     Diag(ExportLoc, diag::warn_template_export_unsupported);
 
@@ -2039,12 +2021,11 @@ DeclResult Sema::CheckClassTemplate(
   if (!PrevClassTemplate && isa_and_nonnull<CXXRecordDecl>(PrevDecl) &&
       cast<CXXRecordDecl>(PrevDecl)->isInjectedClassName()) {
     PrevDecl = cast<CXXRecordDecl>(PrevDecl->getDeclContext());
-    PrevClassTemplate
-      = cast<CXXRecordDecl>(PrevDecl)->getDescribedClassTemplate();
+    PrevClassTemplate =
+        cast<CXXRecordDecl>(PrevDecl)->getDescribedClassTemplate();
     if (!PrevClassTemplate && isa<ClassTemplateSpecializationDecl>(PrevDecl)) {
-      PrevClassTemplate
-        = cast<ClassTemplateSpecializationDecl>(PrevDecl)
-            ->getSpecializedTemplate();
+      PrevClassTemplate = cast<ClassTemplateSpecializationDecl>(PrevDecl)
+                              ->getSpecializedTemplate();
     }
   }
 
@@ -2127,8 +2108,8 @@ DeclResult Sema::CheckClassTemplate(
     if (!isAcceptableTagRedeclaration(
             PrevRecordDecl, Kind, TUK == TagUseKind::Definition, KWLoc, Name)) {
       Diag(KWLoc, diag::err_use_with_wrong_tag)
-        << Name
-        << FixItHint::CreateReplacement(KWLoc, PrevRecordDecl->getKindName());
+          << Name
+          << FixItHint::CreateReplacement(KWLoc, PrevRecordDecl->getKindName());
       Diag(PrevRecordDecl->getLocation(), diag::note_previous_use);
       Kind = PrevRecordDecl->getTagKind();
     }
@@ -2229,10 +2210,9 @@ DeclResult Sema::CheckClassTemplate(
     AddMsStructLayoutForRecord(NewClass);
   }
 
-  ClassTemplateDecl *NewTemplate
-    = ClassTemplateDecl::Create(Context, SemanticContext, NameLoc,
-                                DeclarationName(Name), TemplateParams,
-                                NewClass);
+  ClassTemplateDecl *NewTemplate = ClassTemplateDecl::Create(
+      Context, SemanticContext, NameLoc, DeclarationName(Name), TemplateParams,
+      NewClass);
 
   if (ShouldAddRedecl)
     NewTemplate->setPreviousDecl(PrevClassTemplate);
@@ -2347,7 +2327,7 @@ static bool DiagnoseDefaultTemplateArgument(Sema &S,
     //   template-parameter-lists of the definition of a member of a
     //   class template that appears outside of the member's class.
     S.Diag(ParamLoc, diag::err_template_parameter_default_template_member)
-      << DefArgRange;
+        << DefArgRange;
     return true;
 
   case Sema::TPC_FriendClassTemplate:
@@ -2356,7 +2336,7 @@ static bool DiagnoseDefaultTemplateArgument(Sema &S,
     //   A default template-argument shall not be specified in a
     //   friend template declaration.
     S.Diag(ParamLoc, diag::err_template_parameter_default_friend_template)
-      << DefArgRange;
+        << DefArgRange;
     return true;
 
     // FIXME: C++0x [temp.param]p9 allows default template-arguments
@@ -2392,16 +2372,16 @@ static bool DiagnoseUnexpandedParameterPacks(Sema &S,
 
     if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(P)) {
       if (!NTTP->isParameterPack() &&
-          S.DiagnoseUnexpandedParameterPack(NTTP->getLocation(),
-                                            NTTP->getTypeSourceInfo(),
-                                      Sema::UPPC_NonTypeTemplateParameterType))
+          S.DiagnoseUnexpandedParameterPack(
+              NTTP->getLocation(), NTTP->getTypeSourceInfo(),
+              Sema::UPPC_NonTypeTemplateParameterType))
         return true;
 
       continue;
     }
 
-    if (TemplateTemplateParmDecl *InnerTTP
-                                        = dyn_cast<TemplateTemplateParmDecl>(P))
+    if (TemplateTemplateParmDecl *InnerTTP =
+            dyn_cast<TemplateTemplateParmDecl>(P))
       if (DiagnoseUnexpandedParameterPacks(S, InnerTTP))
         return true;
   }
@@ -2431,7 +2411,7 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
 
   bool RemoveDefaultArguments = false;
   for (TemplateParameterList::iterator NewParam = NewParams->begin(),
-                                    NewParamEnd = NewParams->end();
+                                       NewParamEnd = NewParams->end();
        NewParam != NewParamEnd; ++NewParam) {
     // Whether we've seen a duplicate default argument in the same translation
     // unit.
@@ -2451,8 +2431,8 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
     // Variable used to diagnose non-final parameter packs
     bool SawParameterPack = false;
 
-    if (TemplateTypeParmDecl *NewTypeParm
-          = dyn_cast<TemplateTypeParmDecl>(*NewParam)) {
+    if (TemplateTypeParmDecl *NewTypeParm =
+            dyn_cast<TemplateTypeParmDecl>(*NewParam)) {
       // Check the presence of a default argument here.
       if (NewTypeParm->hasDefaultArgument() &&
           DiagnoseDefaultTemplateArgument(
@@ -2461,8 +2441,8 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
         NewTypeParm->removeDefaultArgument();
 
       // Merge default arguments for template type parameters.
-      TemplateTypeParmDecl *OldTypeParm
-          = OldParams? cast<TemplateTypeParmDecl>(*OldParam) : nullptr;
+      TemplateTypeParmDecl *OldTypeParm =
+          OldParams ? cast<TemplateTypeParmDecl>(*OldParam) : nullptr;
       if (NewTypeParm->isParameterPack()) {
         assert(!NewTypeParm->hasDefaultArgument() &&
                "Parameter packs can't have a default argument!");
@@ -2493,8 +2473,8 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
         PreviousDefaultArgLoc = NewTypeParm->getDefaultArgumentLoc();
       } else if (SawDefaultArgument)
         MissingDefaultArg = true;
-    } else if (NonTypeTemplateParmDecl *NewNonTypeParm
-               = dyn_cast<NonTypeTemplateParmDecl>(*NewParam)) {
+    } else if (NonTypeTemplateParmDecl *NewNonTypeParm =
+                   dyn_cast<NonTypeTemplateParmDecl>(*NewParam)) {
       // Check for unexpanded parameter packs, except in a template template
       // parameter pack, as in those any unexpanded packs should be expanded
       // along with the parameter itself.
@@ -2516,8 +2496,8 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
       }
 
       // Merge default arguments for non-type template parameters
-      NonTypeTemplateParmDecl *OldNonTypeParm
-        = OldParams? cast<NonTypeTemplateParmDecl>(*OldParam) : nullptr;
+      NonTypeTemplateParmDecl *OldNonTypeParm =
+          OldParams ? cast<NonTypeTemplateParmDecl>(*OldParam) : nullptr;
       if (NewNonTypeParm->isParameterPack()) {
         assert(!NewNonTypeParm->hasDefaultArgument() &&
                "Parameter packs can't have a default argument!");
@@ -2549,8 +2529,8 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
       } else if (SawDefaultArgument)
         MissingDefaultArg = true;
     } else {
-      TemplateTemplateParmDecl *NewTemplateParm
-        = cast<TemplateTemplateParmDecl>(*NewParam);
+      TemplateTemplateParmDecl *NewTemplateParm =
+          cast<TemplateTemplateParmDecl>(*NewParam);
 
       // Check for unexpanded parameter packs, recursively.
       if (::DiagnoseUnexpandedParameterPacks(*this, NewTemplateParm)) {
@@ -2560,14 +2540,14 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
 
       // Check the presence of a default argument here.
       if (NewTemplateParm->hasDefaultArgument() &&
-          DiagnoseDefaultTemplateArgument(*this, TPC,
-                                          NewTemplateParm->getLocation(),
-                     NewTemplateParm->getDefaultArgument().getSourceRange()))
+          DiagnoseDefaultTemplateArgument(
+              *this, TPC, NewTemplateParm->getLocation(),
+              NewTemplateParm->getDefaultArgument().getSourceRange()))
         NewTemplateParm->removeDefaultArgument();
 
       // Merge default arguments for template template parameters
-      TemplateTemplateParmDecl *OldTemplateParm
-        = OldParams? cast<TemplateTemplateParmDecl>(*OldParam) : nullptr;
+      TemplateTemplateParmDecl *OldTemplateParm =
+          OldParams ? cast<TemplateTemplateParmDecl>(*OldParam) : nullptr;
       if (NewTemplateParm->isParameterPack()) {
         assert(!NewTemplateParm->hasDefaultArgument() &&
                "Parameter packs can't have a default argument!");
@@ -2593,12 +2573,12 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
         // Merge the default argument from the old declaration to the
         // new declaration.
         NewTemplateParm->setInheritedDefaultArgument(Context, OldTemplateParm);
-        PreviousDefaultArgLoc
-          = OldTemplateParm->getDefaultArgument().getLocation();
+        PreviousDefaultArgLoc =
+            OldTemplateParm->getDefaultArgument().getLocation();
       } else if (NewTemplateParm->hasDefaultArgument()) {
         SawDefaultArgument = true;
-        PreviousDefaultArgLoc
-          = NewTemplateParm->getDefaultArgument().getLocation();
+        PreviousDefaultArgLoc =
+            NewTemplateParm->getDefaultArgument().getLocation();
       } else if (SawDefaultArgument)
         MissingDefaultArg = true;
     }
@@ -2664,12 +2644,12 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
   // all of the default arguments.
   if (RemoveDefaultArguments) {
     for (TemplateParameterList::iterator NewParam = NewParams->begin(),
-                                      NewParamEnd = NewParams->end();
+                                         NewParamEnd = NewParams->end();
          NewParam != NewParamEnd; ++NewParam) {
       if (TemplateTypeParmDecl *TTP = dyn_cast<TemplateTypeParmDecl>(*NewParam))
         TTP->removeDefaultArgument();
-      else if (NonTypeTemplateParmDecl *NTTP
-                                = dyn_cast<NonTypeTemplateParmDecl>(*NewParam))
+      else if (NonTypeTemplateParmDecl *NTTP =
+                   dyn_cast<NonTypeTemplateParmDecl>(*NewParam))
         NTTP->removeDefaultArgument();
       else
         cast<TemplateTemplateParmDecl>(*NewParam)->removeDefaultArgument();
@@ -2705,7 +2685,7 @@ struct DependencyChecker : DynamicRecursiveASTVisitor {
     if (TemplateTypeParmDecl *PD = dyn_cast<TemplateTypeParmDecl>(ND)) {
       Depth = PD->getDepth();
     } else if (NonTypeTemplateParmDecl *PD =
-                 dyn_cast<NonTypeTemplateParmDecl>(ND)) {
+                   dyn_cast<NonTypeTemplateParmDecl>(ND)) {
       Depth = PD->getDepth();
     } else {
       Depth = cast<TemplateTemplateParmDecl>(ND)->getDepth();
@@ -2750,7 +2730,7 @@ struct DependencyChecker : DynamicRecursiveASTVisitor {
 
   bool TraverseTemplateName(TemplateName N) override {
     if (TemplateTemplateParmDecl *PD =
-          dyn_cast_or_null<TemplateTemplateParmDecl>(N.getAsTemplateDecl()))
+            dyn_cast_or_null<TemplateTemplateParmDecl>(N.getAsTemplateDecl()))
       if (Matches(PD->getDepth()))
         return false;
     return DynamicRecursiveASTVisitor::TraverseTemplateName(N);
@@ -2758,7 +2738,7 @@ struct DependencyChecker : DynamicRecursiveASTVisitor {
 
   bool VisitDeclRefExpr(DeclRefExpr *E) override {
     if (NonTypeTemplateParmDecl *PD =
-          dyn_cast<NonTypeTemplateParmDecl>(E->getDecl()))
+            dyn_cast<NonTypeTemplateParmDecl>(E->getDecl()))
       if (Matches(PD->getDepth(), E->getExprLoc()))
         return false;
     return DynamicRecursiveASTVisitor::VisitDeclRefExpr(E);
@@ -2797,12 +2777,12 @@ struct DependencyChecker : DynamicRecursiveASTVisitor {
 
 /// Determines whether a given type depends on the given parameter
 /// list.
-static bool
-DependsOnTemplateParameters(QualType T, TemplateParameterList *Params) {
+static bool DependsOnTemplateParameters(QualType T,
+                                        TemplateParameterList *Params) {
   if (!Params->size())
     return false;
 
-  DependencyChecker Checker(Params, /*IgnoreNonTypeDependent*/false);
+  DependencyChecker Checker(Params, /*IgnoreNonTypeDependent*/ false);
   Checker.TraverseType(T);
   return Checker.Match;
 }
@@ -2859,15 +2839,15 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
     // Retrieve the parent of a record type.
     if (CXXRecordDecl *Record = T->getAsCXXRecordDecl()) {
       // If this type is an explicit specialization, we're done.
-      if (ClassTemplateSpecializationDecl *Spec
-          = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
+      if (ClassTemplateSpecializationDecl *Spec =
+              dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
         if (!isa<ClassTemplatePartialSpecializationDecl>(Spec) &&
             Spec->getSpecializationKind() == TSK_ExplicitSpecialization) {
           ExplicitSpecLoc = Spec->getLocation();
           break;
         }
-      } else if (Record->getTemplateSpecializationKind()
-                                                == TSK_ExplicitSpecialization) {
+      } else if (Record->getTemplateSpecializationKind() ==
+                 TSK_ExplicitSpecialization) {
         ExplicitSpecLoc = Record->getLocation();
         break;
       }
@@ -2879,8 +2859,8 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
       continue;
     }
 
-    if (const TemplateSpecializationType *TST
-                                     = T->getAs<TemplateSpecializationType>()) {
+    if (const TemplateSpecializationType *TST =
+            T->getAs<TemplateSpecializationType>()) {
       TemplateName Name = TST->getTemplateName();
       if (const auto *DTS = Name.getAsDependentTemplateName()) {
         // Look one step prior in a dependent template specialization type.
@@ -2901,7 +2881,8 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
     }
 
     // Look one step prior in a dependent name type.
-    if (const DependentNameType *DependentName = T->getAs<DependentNameType>()){
+    if (const DependentNameType *DependentName =
+            T->getAs<DependentNameType>()) {
       if (NestedNameSpecifier NNS = DependentName->getQualifier();
           NNS.getKind() == NestedNameSpecifier::Kind::Type)
         T = QualType(NNS.getAsType(), 0);
@@ -2942,7 +2923,7 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
     if (SawNonEmptyTemplateParameterList) {
       if (!SuppressDiagnostic)
         Diag(DeclLoc, diag::err_specialize_member_of_template)
-          << !Recovery << Range;
+            << !Recovery << Range;
       Invalid = true;
       IsMemberSpecialization = false;
       return true;
@@ -2951,7 +2932,7 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
     return false;
   };
 
-  auto DiagnoseMissingExplicitSpecialization = [&] (SourceRange Range) {
+  auto DiagnoseMissingExplicitSpecialization = [&](SourceRange Range) {
     // Check that we can have an explicit specialization here.
     if (CheckExplicitSpecialization(Range, true))
       return true;
@@ -2965,8 +2946,8 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
 
     if (!SuppressDiagnostic)
       Diag(DeclLoc, diag::err_template_spec_needs_header)
-        << Range
-        << FixItHint::CreateInsertion(ExpectedTemplateLoc, "template<> ");
+          << Range
+          << FixItHint::CreateInsertion(ExpectedTemplateLoc, "template<> ");
     return false;
   };
 
@@ -2991,18 +2972,18 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
     //   member declaration shall be preceded by a template<> for each
     //   enclosing class template that is explicitly specialized.
     if (CXXRecordDecl *Record = T->getAsCXXRecordDecl()) {
-      if (ClassTemplatePartialSpecializationDecl *Partial
-            = dyn_cast<ClassTemplatePartialSpecializationDecl>(Record)) {
+      if (ClassTemplatePartialSpecializationDecl *Partial =
+              dyn_cast<ClassTemplatePartialSpecializationDecl>(Record)) {
         ExpectedTemplateParams = Partial->getTemplateParameters();
         NeedNonemptyTemplateHeader = true;
       } else if (Record->isDependentType()) {
         if (Record->getDescribedClassTemplate()) {
-          ExpectedTemplateParams = Record->getDescribedClassTemplate()
-                                                      ->getTemplateParameters();
+          ExpectedTemplateParams =
+              Record->getDescribedClassTemplate()->getTemplateParameters();
           NeedNonemptyTemplateHeader = true;
         }
-      } else if (ClassTemplateSpecializationDecl *Spec
-                     = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
+      } else if (ClassTemplateSpecializationDecl *Spec =
+                     dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
         // C++0x [temp.expl.spec]p4:
         //   Members of an explicitly specialized class template are defined
         //   in the same manner as members of normal classes, and not using
@@ -3012,8 +2993,8 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
         else
           continue;
       } else if (Record->getTemplateSpecializationKind()) {
-        if (Record->getTemplateSpecializationKind()
-                                                != TSK_ExplicitSpecialization &&
+        if (Record->getTemplateSpecializationKind() !=
+                TSK_ExplicitSpecialization &&
             TypeIdx == NumTypes - 1)
           IsMemberSpecialization = true;
 
@@ -3059,10 +3040,10 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
           if (!SuppressDiagnostic)
             Diag(ParamLists[ParamIdx]->getTemplateLoc(),
                  diag::err_template_param_list_matches_nontemplate)
-              << T
-              << SourceRange(ParamLists[ParamIdx]->getLAngleLoc(),
-                             ParamLists[ParamIdx]->getRAngleLoc())
-              << getRangeOfTypeInNestedNameSpecifier(Context, T, SS);
+                << T
+                << SourceRange(ParamLists[ParamIdx]->getLAngleLoc(),
+                               ParamLists[ParamIdx]->getRAngleLoc())
+                << getRangeOfTypeInNestedNameSpecifier(Context, T, SS);
           Invalid = true;
           return nullptr;
         }
@@ -3096,9 +3077,9 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
       if (ParamIdx < ParamLists.size()) {
         // Check the template parameter list, if we can.
         if (ExpectedTemplateParams &&
-            !TemplateParameterListsAreEqual(ParamLists[ParamIdx],
-                                            ExpectedTemplateParams,
-                                            !SuppressDiagnostic, TPL_TemplateMatch))
+            !TemplateParameterListsAreEqual(
+                ParamLists[ParamIdx], ExpectedTemplateParams,
+                !SuppressDiagnostic, TPL_TemplateMatch))
           Invalid = true;
 
         if (!Invalid &&
@@ -3112,8 +3093,7 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
 
       if (!SuppressDiagnostic)
         Diag(DeclLoc, diag::err_template_spec_needs_template_parameters)
-          << T
-          << getRangeOfTypeInNestedNameSpecifier(Context, T, SS);
+            << T << getRangeOfTypeInNestedNameSpecifier(Context, T, SS);
       Invalid = true;
       continue;
     }
@@ -3126,8 +3106,8 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
     if (TemplateId && !IsFriend) {
       // We don't have a template header for the declaration itself, but we
       // should.
-      DiagnoseMissingExplicitSpecialization(SourceRange(TemplateId->LAngleLoc,
-                                                        TemplateId->RAngleLoc));
+      DiagnoseMissingExplicitSpecialization(
+          SourceRange(TemplateId->LAngleLoc, TemplateId->RAngleLoc));
 
       // Fabricate an empty template parameter list for the invented header.
       return TemplateParameterList::Create(Context, SourceLocation(),
@@ -3163,7 +3143,7 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
         !SuppressDiagnostic)
       Diag(ExplicitSpecLoc,
            diag::note_explicit_template_spec_does_not_need_header)
-        << NestedTypes.back();
+          << NestedTypes.back();
 
     // We have a template parameter list with no corresponding scope, which
     // means that the resulting template declaration can't be instantiated
@@ -3192,23 +3172,21 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
 void Sema::NoteAllFoundTemplates(TemplateName Name) {
   if (TemplateDecl *Template = Name.getAsTemplateDecl()) {
     Diag(Template->getLocation(), diag::note_template_declared_here)
-        << (isa<FunctionTemplateDecl>(Template)
-                ? 0
-                : isa<ClassTemplateDecl>(Template)
-                      ? 1
-                      : isa<VarTemplateDecl>(Template)
-                            ? 2
-                            : isa<TypeAliasTemplateDecl>(Template) ? 3 : 4)
+        << (isa<FunctionTemplateDecl>(Template)    ? 0
+            : isa<ClassTemplateDecl>(Template)     ? 1
+            : isa<VarTemplateDecl>(Template)       ? 2
+            : isa<TypeAliasTemplateDecl>(Template) ? 3
+                                                   : 4)
         << Template->getDeclName();
     return;
   }
 
   if (OverloadedTemplateStorage *OST = Name.getAsOverloadedTemplate()) {
     for (OverloadedTemplateStorage::iterator I = OST->begin(),
-                                          IEnd = OST->end();
+                                             IEnd = OST->end();
          I != IEnd; ++I)
       Diag((*I)->getLocation(), diag::note_template_declared_here)
-        << 0 << (*I)->getDeclName();
+          << 0 << (*I)->getDeclName();
 
     return;
   }
@@ -3599,14 +3577,17 @@ static void collectConjunctionTerms(Expr *Clause,
 static Expr *lookThroughRangesV3Condition(Preprocessor &PP, Expr *Cond) {
   // Top-level '||'.
   auto *BinOp = dyn_cast<BinaryOperator>(Cond->IgnoreParenImpCasts());
-  if (!BinOp) return Cond;
+  if (!BinOp)
+    return Cond;
 
-  if (BinOp->getOpcode() != BO_LOr) return Cond;
+  if (BinOp->getOpcode() != BO_LOr)
+    return Cond;
 
   // With an inner '==' that has a literal on the right-hand side.
   Expr *LHS = BinOp->getLHS();
   auto *InnerBinOp = dyn_cast<BinaryOperator>(LHS->IgnoreParenImpCasts());
-  if (!InnerBinOp) return Cond;
+  if (!InnerBinOp)
+    return Cond;
 
   if (InnerBinOp->getOpcode() != BO_EQ ||
       !isa<IntegerLiteral>(InnerBinOp->getRHS()))
@@ -3616,7 +3597,8 @@ static Expr *lookThroughRangesV3Condition(Preprocessor &PP, Expr *Cond) {
   // CONCEPT_REQUIRES or CONCEPT_REQUIRES_, return the right-hand side
   // of the '||', which is the real, user-provided condition.
   SourceLocation Loc = InnerBinOp->getExprLoc();
-  if (!Loc.isMacroID()) return Cond;
+  if (!Loc.isMacroID())
+    return Cond;
 
   StringRef MacroName = PP.getImmediateMacroName(Loc);
   if (MacroName == "CONCEPT_REQUIRES" || MacroName == "CONCEPT_REQUIRES_")
@@ -3661,8 +3643,7 @@ class FailedBooleanConditionPrinterHelper : public PrinterHelper {
 
 } // end anonymous namespace
 
-std::pair<Expr *, std::string>
-Sema::findFailedBooleanCondition(Expr *Cond) {
+std::pair<Expr *, std::string> Sema::findFailedBooleanCondition(Expr *Cond) {
   Cond = lookThroughRangesV3Condition(PP, Cond);
 
   // Separate out all of the terms in a conjunction.
@@ -3682,11 +3663,10 @@ Sema::findFailedBooleanCondition(Expr *Cond) {
     // The initialization of the parameter from the argument is
     // a constant-evaluated context.
     EnterExpressionEvaluationContext ConstantEvaluated(
-      *this, Sema::ExpressionEvaluationContext::ConstantEvaluated);
+        *this, Sema::ExpressionEvaluationContext::ConstantEvaluated);
 
     bool Succeeded;
-    if (Term->EvaluateAsBooleanCondition(Succeeded, Context) &&
-        !Succeeded) {
+    if (Term->EvaluateAsBooleanCondition(Succeeded, Context) && !Succeeded) {
       FailedCond = TermAsWritten;
       break;
     }
@@ -3702,7 +3682,7 @@ Sema::findFailedBooleanCondition(Expr *Cond) {
     FailedBooleanConditionPrinterHelper Helper(Policy);
     FailedCond->printPretty(Out, &Helper, Policy, 0, "\n", nullptr);
   }
-  return { FailedCond, Description };
+  return {FailedCond, Description};
 }
 
 static TemplateName
@@ -3862,11 +3842,12 @@ QualType Sema::CheckTemplateIdType(ElaboratedTypeKeyword Keyword,
             Expr *FailedCond;
             std::string FailedDescription;
             std::tie(FailedCond, FailedDescription) =
-              findFailedBooleanCondition(TemplateArgs[0].getSourceExpression());
+                findFailedBooleanCondition(
+                    TemplateArgs[0].getSourceExpression());
 
             // Remove the old SFINAE diagnostic.
-            PartialDiagnosticAt OldDiag =
-              {SourceLocation(), PartialDiagnostic::NullDiagnostic()};
+            PartialDiagnosticAt OldDiag = {SourceLocation(),
+                                           PartialDiagnostic::NullDiagnostic()};
             DeductionInfo->takeSFINAEDiagnostic(OldDiag);
 
             // Add a new SFINAE diagnostic specifying which condition
@@ -3909,11 +3890,13 @@ QualType Sema::CheckTemplateIdType(ElaboratedTypeKeyword Keyword,
     if (isa<ClassTemplateDecl>(Template)) {
       for (DeclContext *Ctx = CurContext; Ctx; Ctx = Ctx->getLookupParent()) {
         // If we get out to a namespace, we're done.
-        if (Ctx->isFileContext()) break;
+        if (Ctx->isFileContext())
+          break;
 
         // If this isn't a record, keep looking.
         CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(Ctx);
-        if (!Record) continue;
+        if (!Record)
+          continue;
 
         // Look for one of the two cases with InjectedClassNameTypes
         // and check whether it's the same template.
@@ -4020,7 +4003,7 @@ TypeResult Sema::ActOnTemplateIdType(
     return true;
 
   if (!IsCtorOrDtorName && !IsClassName && SS.isSet()) {
-    DeclContext *LookupCtx = computeDeclContext(SS, /*EnteringContext*/false);
+    DeclContext *LookupCtx = computeDeclContext(SS, /*EnteringContext*/ false);
 
     // C++ [temp.res]p3:
     //   A qualified-id that refers to a type and in which the
@@ -4059,8 +4042,8 @@ TypeResult Sema::ActOnTemplateIdType(
            TemplateKWLoc.isInvalid()
                ? diag::err_out_of_line_qualified_id_type_names_constructor
                : diag::ext_out_of_line_qualified_id_type_names_constructor)
-        << TemplateII << 0 /*injected-class-name used as template name*/
-        << 1 /*if any keyword was present, it was 'template'*/;
+          << TemplateII << 0 /*injected-class-name used as template name*/
+          << 1 /*if any keyword was present, it was 'template'*/;
     }
   }
 
@@ -4082,16 +4065,11 @@ TypeResult Sema::ActOnTemplateIdType(
   return CreateParsedType(SpecTy, TLB.getTypeSourceInfo(Context, SpecTy));
 }
 
-TypeResult Sema::ActOnTagTemplateIdType(TagUseKind TUK,
-                                        TypeSpecifierType TagSpec,
-                                        SourceLocation TagLoc,
-                                        CXXScopeSpec &SS,
-                                        SourceLocation TemplateKWLoc,
-                                        TemplateTy TemplateD,
-                                        SourceLocation TemplateLoc,
-                                        SourceLocation LAngleLoc,
-                                        ASTTemplateArgsPtr TemplateArgsIn,
-                                        SourceLocation RAngleLoc) {
+TypeResult Sema::ActOnTagTemplateIdType(
+    TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc,
+    CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD,
+    SourceLocation TemplateLoc, SourceLocation LAngleLoc,
+    ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc) {
   if (SS.isInvalid())
     return TypeResult(true);
 
@@ -4101,8 +4079,8 @@ TypeResult Sema::ActOnTagTemplateIdType(TagUseKind TUK,
 
   // Determine the tag kind
   TagTypeKind TagKind = TypeWithKeyword::getTagTypeKindForTypeSpec(TagSpec);
-  ElaboratedTypeKeyword Keyword
-    = TypeWithKeyword::getKeywordForTagTypeKind(TagKind);
+  ElaboratedTypeKeyword Keyword =
+      TypeWithKeyword::getKeywordForTagTypeKind(TagKind);
 
   QualType Result =
       CheckTemplateIdType(Keyword, TemplateD.get(), TemplateLoc, TemplateArgs,
@@ -4120,8 +4098,9 @@ TypeResult Sema::ActOnTagTemplateIdType(TagUseKind TUK,
     if (!isAcceptableTagRedeclaration(D, TagKind, TUK == TagUseKind::Definition,
                                       TagLoc, Id)) {
       Diag(TagLoc, diag::err_use_with_wrong_tag)
-        << Result
-        << FixItHint::CreateReplacement(SourceRange(TagLoc), D->getKindName());
+          << Result
+          << FixItHint::CreateReplacement(SourceRange(TagLoc),
+                                          D->getKindName());
       Diag(D->getLocation(), diag::note_previous_use);
     }
   }
@@ -4158,8 +4137,8 @@ static bool isTemplateArgumentTemplateParameter(const TemplateArgument &Arg,
     QualType Type = Arg.getAsType();
     const TemplateTypeParmType *TPT =
         Arg.getAsType()->getAsCanonical<TemplateTypeParmType>();
-    return TPT && !Type.hasQualifiers() &&
-           TPT->getDepth() == Depth && TPT->getIndex() == Index;
+    return TPT && !Type.hasQualifiers() && TPT->getDepth() == Depth &&
+           TPT->getIndex() == Index;
   }
 
   case TemplateArgument::Expression: {
@@ -4218,7 +4197,7 @@ static bool isSameAsPrimaryTemplate(TemplateParameterList *Params,
   return true;
 }
 
-template<typename PartialSpecDecl>
+template <typename PartialSpecDecl>
 static void checkMoreSpecializedThanPrimary(Sema &S, PartialSpecDecl *Partial) {
   if (Partial->getDeclContext()->isDependentContext())
     return;
@@ -4242,7 +4221,7 @@ static void checkMoreSpecializedThanPrimary(Sema &S, PartialSpecDecl *Partial) {
     Diag.second.EmitToString(S.getDiagnostics(), SFINAEArgString);
     S.Diag(Diag.first,
            diag::note_partial_spec_not_more_specialized_than_primary)
-      << SFINAEArgString;
+        << SFINAEArgString;
   }
 
   S.NoteTemplateLocation(*Template);
@@ -4269,8 +4248,7 @@ noteNonDeducibleParameters(Sema &S, TemplateParameterList *TemplateParams,
   }
 }
 
-
-template<typename PartialSpecDecl>
+template <typename PartialSpecDecl>
 static void checkTemplatePartialSpecialization(Sema &S,
                                                PartialSpecDecl *Partial) {
   // C++1z [temp.class.spec]p8: (DR1495)
@@ -4293,10 +4271,10 @@ static void checkTemplatePartialSpecialization(Sema &S,
   if (!DeducibleParams.all()) {
     unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
     S.Diag(Partial->getLocation(), diag::ext_partial_specs_not_deducible)
-      << isa<VarTemplatePartialSpecializationDecl>(Partial)
-      << (NumNonDeducible > 1)
-      << SourceRange(Partial->getLocation(),
-                     Partial->getTemplateArgsAsWritten()->RAngleLoc);
+        << isa<VarTemplatePartialSpecializationDecl>(Partial)
+        << (NumNonDeducible > 1)
+        << SourceRange(Partial->getLocation(),
+                       Partial->getTemplateArgsAsWritten()->RAngleLoc);
     noteNonDeducibleParameters(S, TemplateParams, DeducibleParams);
   }
 }
@@ -4329,7 +4307,7 @@ void Sema::CheckDeductionGuideTemplate(FunctionTemplateDecl *TD) {
   if (!DeducibleParams.all()) {
     unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
     Diag(TD->getLocation(), diag::err_deduction_guide_template_not_deducible)
-      << (NumNonDeducible > 1);
+        << (NumNonDeducible > 1);
     noteNonDeducibleParameters(*this, TemplateParams, DeducibleParams);
   }
 }
@@ -4359,12 +4337,14 @@ DeclResult Sema::ActOnVarTemplateSpecialization(
     if (auto *OTS = Name.getAsOverloadedTemplate())
       FnTemplate = *OTS->begin();
     else
-      FnTemplate = dyn_cast_or_null<FunctionTemplateDecl>(Name.getAsTemplateDecl());
+      FnTemplate =
+          dyn_cast_or_null<FunctionTemplateDecl>(Name.getAsTemplateDecl());
     if (FnTemplate)
-      return Diag(D.getIdentifierLoc(), diag::err_var_spec_no_template_but_method)
-               << FnTemplate->getDeclName();
+      return Diag(D.getIdentifierLoc(),
+                  diag::err_var_spec_no_template_but_method)
+             << FnTemplate->getDeclName();
     return Diag(D.getIdentifierLoc(), diag::err_var_spec_no_template)
-             << IsPartialSpecialization;
+           << IsPartialSpecialization;
   }
 
   if (const auto *DSA = VarTemplate->getAttr<NoSpecializationsAttr>()) {
@@ -4717,9 +4697,8 @@ Sema::CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc,
       for (SmallVector<MatchResult, 4>::iterator P = Best + 1,
                                                  PEnd = Matched.end();
            P != PEnd; ++P) {
-        if (getMoreSpecializedPartialSpecialization(P->Partial, Best->Partial,
-                                                    PointOfInstantiation) ==
-            P->Partial)
+        if (getMoreSpecializedPartialSpecialization(
+                P->Partial, Best->Partial, PointOfInstantiation) == P->Partial)
           Best = P;
       }
 
@@ -4729,8 +4708,8 @@ Sema::CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc,
                                                  PEnd = Matched.end();
            P != PEnd; ++P) {
         if (P != Best && getMoreSpecializedPartialSpecialization(
-                             P->Partial, Best->Partial,
-                             PointOfInstantiation) != Best->Partial) {
+                             P->Partial, Best->Partial, PointOfInstantiation) !=
+                             Best->Partial) {
           AmbiguousPartialSpec = true;
           break;
         }
@@ -4844,7 +4823,7 @@ ExprResult Sema::CheckVarOrConceptTemplateTemplateId(
 void Sema::diagnoseMissingTemplateArguments(TemplateName Name,
                                             SourceLocation Loc) {
   Diag(Loc, diag::err_template_missing_args)
-    << (int)getTemplateNameKindForDiagnostics(Name) << Name;
+      << (int)getTemplateNameKindForDiagnostics(Name) << Name;
   if (TemplateDecl *TD = Name.getAsTemplateDecl()) {
     NoteTemplateLocation(*TD, TD->getTemplateParameters()->getSourceRange());
   }
@@ -4926,11 +4905,10 @@ ExprResult Sema::CheckConceptTemplateId(
       Context, CL, CSD, AreArgsDependent ? nullptr : &Satisfaction);
 }
 
-ExprResult Sema::BuildTemplateIdExpr(const CXXScopeSpec &SS,
-                                     SourceLocation TemplateKWLoc,
-                                     LookupResult &R,
-                                     bool RequiresADL,
-                                 const TemplateArgumentListInfo *TemplateArgs) {
+ExprResult
+Sema::BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
+                          LookupResult &R, bool RequiresADL,
+                          const TemplateArgumentListInfo *TemplateArgs) {
   // FIXME: Can we do any checking at this point? I guess we could check the
   // template arguments that we have against the template name, if the template
   // name refers to a single template. That's not a terribly common case,
@@ -5017,7 +4995,7 @@ ExprResult Sema::BuildQualifiedTemplateIdExpr(
   if (R.empty()) {
     DeclContext *DC = computeDeclContext(SS);
     Diag(NameInfo.getLoc(), diag::err_no_member)
-      << NameInfo.getName() << DC << SS.getRange();
+        << NameInfo.getName() << DC << SS.getRange();
     return ExprError();
   }
 
@@ -5029,20 +5007,17 @@ ExprResult Sema::BuildQualifiedTemplateIdExpr(
   return BuildTemplateIdExpr(SS, TemplateKWLoc, R, /*ADL=*/false, TemplateArgs);
 }
 
-TemplateNameKind Sema::ActOnTemplateName(Scope *S,
-                                         CXXScopeSpec &SS,
-                                         SourceLocation TemplateKWLoc,
-                                         const UnqualifiedId &Name,
-                                         ParsedType ObjectType,
-                                         bool EnteringContext,
-                                         TemplateTy &Result,
-                                         bool AllowInjectedClassName) {
+TemplateNameKind
+Sema::ActOnTemplateName(Scope *S, CXXScopeSpec &SS,
+                        SourceLocation TemplateKWLoc, const UnqualifiedId &Name,
+                        ParsedType ObjectType, bool EnteringContext,
+                        TemplateTy &Result, bool AllowInjectedClassName) {
   if (TemplateKWLoc.isValid() && S && !S->getTemplateParamParent())
     Diag(TemplateKWLoc,
-         getLangOpts().CPlusPlus11 ?
-           diag::warn_cxx98_compat_template_outside_of_template :
-           diag::ext_template_outside_of_template)
-      << FixItHint::CreateRemoval(TemplateKWLoc);
+         getLangOpts().CPlusPlus11
+             ? diag::warn_cxx98_compat_template_outside_of_template
+             : diag::ext_template_outside_of_template)
+        << FixItHint::CreateRemoval(TemplateKWLoc);
 
   if (SS.isInvalid())
     return TNK_Non_template;
@@ -5071,15 +5046,15 @@ TemplateNameKind Sema::ActOnTemplateName(Scope *S,
   // "template" keyword is now permitted). We follow the C++0x
   // rules, even in C++03 mode with a warning, retroactively applying the DR.
   bool MemberOfUnknownSpecialization;
-  TemplateNameKind TNK = isTemplateName(S, SS, TemplateKWLoc.isValid(), Name,
-                                        ObjectType, EnteringContext, Result,
-                                        MemberOfUnknownSpecialization);
+  TemplateNameKind TNK =
+      isTemplateName(S, SS, TemplateKWLoc.isValid(), Name, ObjectType,
+                     EnteringContext, Result, MemberOfUnknownSpecialization);
   if (TNK != TNK_Non_template) {
     // We resolved this to a (non-dependent) template name. Return it.
     auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
     if (!AllowInjectedClassName && SS.isNotEmpty() && LookupRD &&
-        Name.getKind() == UnqualifiedIdKind::IK_Identifier &&
-        Name.Identifier && LookupRD->getIdentifier() == Name.Identifier) {
+        Name.getKind() == UnqualifiedIdKind::IK_Identifier && Name.Identifier &&
+        LookupRD->getIdentifier() == Name.Identifier) {
       // C++14 [class.qual]p2:
       //   In a lookup in which function names are not ignored and the
       //   nested-name-specifier nominates a class C, if the name specified
@@ -5091,8 +5066,7 @@ TemplateNameKind Sema::ActOnTemplateName(Scope *S,
       // injected-class-name as naming the template.
       Diag(Name.getBeginLoc(),
            diag::ext_out_of_line_qualified_id_type_names_constructor)
-          << Name.Identifier
-          << 0 /*injected-class-name used as template name*/
+          << Name.Identifier << 0 /*injected-class-name used as template name*/
           << TemplateKWLoc.isValid();
     }
     return TNK;
@@ -5165,7 +5139,7 @@ bool Sema::CheckTemplateTypeArgument(
   TypeSourceInfo *TSI = nullptr;
 
   // Check template type parameter.
-  switch(Arg.getKind()) {
+  switch (Arg.getKind()) {
   case TemplateArgument::Type:
     // C++ [temp.arg.type]p1:
     //   A template-argument for a template-parameter which is a
@@ -5188,12 +5162,12 @@ bool Sema::CheckTemplateTypeArgument(
     CXXScopeSpec SS;
     DeclarationNameInfo NameInfo;
 
-   if (DependentScopeDeclRefExpr *ArgExpr =
-               dyn_cast<DependentScopeDeclRefExpr>(Arg.getAsExpr())) {
+    if (DependentScopeDeclRefExpr *ArgExpr =
+            dyn_cast<DependentScopeDeclRefExpr>(Arg.getAsExpr())) {
       SS.Adopt(ArgExpr->getQualifierLoc());
       NameInfo = ArgExpr->getNameInfo();
     } else if (CXXDependentScopeMemberExpr *ArgExpr =
-               dyn_cast<CXXDependentScopeMemberExpr>(Arg.getAsExpr())) {
+                   dyn_cast<CXXDependentScopeMemberExpr>(Arg.getAsExpr())) {
       if (ArgExpr->isImplicitAccess()) {
         SS.Adopt(ArgExpr->getQualifierLoc());
         NameInfo = ArgExpr->getMemberNameInfo();
@@ -5264,8 +5238,7 @@ bool Sema::CheckTemplateTypeArgument(
   // Objective-C ARC:
   //   If an explicitly-specified template argument type is a lifetime type
   //   with no lifetime qualifier, the __strong lifetime qualifier is inferred.
-  if (getLangOpts().ObjCAutoRefCount &&
-      ArgType->isObjCLifetimeType() &&
+  if (getLangOpts().ObjCAutoRefCount && ArgType->isObjCLifetimeType() &&
       !ArgType.getObjCLifetime()) {
     Qualifiers Qs;
     Qs.setObjCLifetime(Qualifiers::OCL_Strong);
@@ -5460,8 +5433,8 @@ TemplateArgumentLoc Sema::SubstDefaultTemplateArgumentIfAvailable(
     return Output;
   }
 
-  if (NonTypeTemplateParmDecl *NonTypeParm
-        = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
+  if (NonTypeTemplateParmDecl *NonTypeParm =
+          dyn_cast<NonTypeTemplateParmDecl>(Param)) {
     if (!hasReachableDefaultArgument(NonTypeParm))
       return TemplateArgumentLoc();
 
@@ -5474,8 +5447,8 @@ TemplateArgumentLoc Sema::SubstDefaultTemplateArgumentIfAvailable(
     return Output;
   }
 
-  TemplateTemplateParmDecl *TempTempParm
-    = cast<TemplateTemplateParmDecl>(Param);
+  TemplateTemplateParmDecl *TempTempParm =
+      cast<TemplateTemplateParmDecl>(Param);
   if (!hasReachableDefaultArgument(TempTempParm))
     return TemplateArgumentLoc();
 
@@ -5531,7 +5504,8 @@ bool Sema::CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &ArgLoc,
 
   const TemplateArgument &Arg = ArgLoc.getArgument();
   // Check non-type template parameters.
-  if (NonTypeTemplateParmDecl *NTTP =dyn_cast<NonTypeTemplateParmDecl>(Param)) {
+  if (NonTypeTemplateParmDecl *NTTP =
+          dyn_cast<NonTypeTemplateParmDecl>(Param)) {
     // Do substitution on the type of the non-type template parameter
     // with the template arguments we've seen thus far.  But if the
     // template has a dependent context then we cannot substitute yet.
@@ -5563,8 +5537,8 @@ bool Sema::CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &ArgLoc,
       // If that worked, check the non-type template parameter type
       // for validity.
       if (!NTTPType.isNull())
-        NTTPType = CheckNonTypeTemplateParameterType(NTTPType,
-                                                     NTTP->getLocation());
+        NTTPType =
+            CheckNonTypeTemplateParameterType(NTTPType, NTTP->getLocation());
       if (NTTPType.isNull())
         return true;
     }
@@ -5700,7 +5674,6 @@ bool Sema::CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &ArgLoc,
     return false;
   }
 
-
   // Check template template parameters.
   TemplateTemplateParmDecl *TempParm = cast<TemplateTemplateParmDecl>(Param);
 
@@ -5793,10 +5766,9 @@ bool Sema::CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &ArgLoc,
 }
 
 /// Diagnose a missing template argument.
-template<typename TemplateParmDecl>
+template <typename TemplateParmDecl>
 static bool diagnoseMissingArgument(Sema &S, SourceLocation Loc,
-                                    TemplateDecl *TD,
-                                    const TemplateParmDecl *D,
+                                    TemplateDecl *TD, const TemplateParmDecl *D,
                                     TemplateArgumentListInfo &Args) {
   // Dig out the most recent declaration of the template parameter; there may be
   // declarations of the template that are more recent than TD.
@@ -5806,12 +5778,12 @@ static bool diagnoseMissingArgument(Sema &S, SourceLocation Loc,
 
   // If there's a default argument that's not reachable, diagnose that we're
   // missing a module import.
-  llvm::SmallVector<Module*, 8> Modules;
+  llvm::SmallVector<Module *, 8> Modules;
   if (D->hasDefaultArgument() && !S.hasReachableDefaultArgument(D, &Modules)) {
     S.diagnoseMissingImport(Loc, cast<NamedDecl>(TD),
                             D->getDefaultArgumentLoc(), Modules,
                             Sema::MissingImportKind::DefaultArgument,
-                            /*Recover*/true);
+                            /*Recover*/ true);
     return true;
   }
 
@@ -5821,9 +5793,8 @@ static bool diagnoseMissingArgument(Sema &S, SourceLocation Loc,
   TemplateParameterList *Params = TD->getTemplateParameters();
 
   S.Diag(Loc, diag::err_template_arg_list_different_arity)
-    << /*not enough args*/0
-    << (int)S.getTemplateNameKindForDiagnostics(TemplateName(TD))
-    << TD;
+      << /*not enough args*/ 0
+      << (int)S.getTemplateNameKindForDiagnostics(TemplateName(TD)) << TD;
   S.NoteTemplateLocation(*TD, Params->getSourceRange());
   return true;
 }
@@ -5912,9 +5883,9 @@ bool Sema::CheckTemplateArgumentList(
       } else if (ArgIdx == NumArgs && !PartialTemplateArgs) {
         // Not enough arguments for this parameter pack.
         Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
-          << /*not enough args*/0
-          << (int)getTemplateNameKindForDiagnostics(TemplateName(Template))
-          << Template;
+            << /*not enough args*/ 0
+            << (int)getTemplateNameKindForDiagnostics(TemplateName(Template))
+            << Template;
         NoteTemplateLocation(*Template, Params->getSourceRange());
         return true;
       }
@@ -6167,7 +6138,7 @@ bool Sema::CheckTemplateArgumentList(
   // Complain and fail.
   if (ArgIdx < NumArgs) {
     Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
-        << /*too many args*/1
+        << /*too many args*/ 1
         << (int)getTemplateNameKindForDiagnostics(TemplateName(Template))
         << Template
         << SourceRange(NewArgs[ArgIdx].getLocation(), NewArgs.getRAngleLoc());
@@ -6218,58 +6189,56 @@ bool Sema::CheckTemplateArgumentList(
 }
 
 namespace {
-  class UnnamedLocalNoLinkageFinder
-    : public TypeVisitor<UnnamedLocalNoLinkageFinder, bool>
-  {
-    Sema &S;
-    SourceRange SR;
+class UnnamedLocalNoLinkageFinder
+    : public TypeVisitor<UnnamedLocalNoLinkageFinder, bool> {
+  Sema &S;
+  SourceRange SR;
 
-    typedef TypeVisitor<UnnamedLocalNoLinkageFinder, bool> inherited;
+  typedef TypeVisitor<UnnamedLocalNoLinkageFinder, bool> inherited;
 
-  public:
-    UnnamedLocalNoLinkageFinder(Sema &S, SourceRange SR) : S(S), SR(SR) { }
+public:
+  UnnamedLocalNoLinkageFinder(Sema &S, SourceRange SR) : S(S), SR(SR) {}
 
-    bool Visit(QualType T) {
-      return T.isNull() ? false : inherited::Visit(T.getTypePtr());
-    }
+  bool Visit(QualType T) {
+    return T.isNull() ? false : inherited::Visit(T.getTypePtr());
+  }
 
-#define TYPE(Class, Parent) \
-    bool Visit##Class##Type(const Class##Type *);
-#define ABSTRACT_TYPE(Class, Parent) \
-    bool Visit##Class##Type(const Class##Type *) { return false; }
-#define NON_CANONICAL_TYPE(Class, Parent) \
-    bool Visit##Class##Type(const Class##Type *) { return false; }
+#define TYPE(Class, Parent) bool Visit##Class##Type(const Class##Type *);
+#define ABSTRACT_TYPE(Class, Parent)                                           \
+  bool Visit##Class##Type(const Class##Type *) { return false; }
+#define NON_CANONICAL_TYPE(Class, Parent)                                      \
+  bool Visit##Class##Type(const Class##Type *) { return false; }
 #include "clang/AST/TypeNodes.inc"
 
-    bool VisitTagDecl(const TagDecl *Tag);
-    bool VisitNestedNameSpecifier(NestedNameSpecifier NNS);
-  };
+  bool VisitTagDecl(const TagDecl *Tag);
+  bool VisitNestedNameSpecifier(NestedNameSpecifier NNS);
+};
 } // end anonymous namespace
 
-bool UnnamedLocalNoLinkageFinder::VisitBuiltinType(const BuiltinType*) {
+bool UnnamedLocalNoLinkageFinder::VisitBuiltinType(const BuiltinType *) {
   return false;
 }
 
-bool UnnamedLocalNoLinkageFinder::VisitComplexType(const ComplexType* T) {
+bool UnnamedLocalNoLinkageFinder::VisitComplexType(const ComplexType *T) {
   return Visit(T->getElementType());
 }
 
-bool UnnamedLocalNoLinkageFinder::VisitPointerType(const PointerType* T) {
+bool UnnamedLocalNoLinkageFinder::VisitPointerType(const PointerType *T) {
   return Visit(T->getPointeeType());
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitBlockPointerType(
-                                                    const BlockPointerType* T) {
+    const BlockPointerType *T) {
   return Visit(T->getPointeeType());
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitLValueReferenceType(
-                                                const LValueReferenceType* T) {
+    const LValueReferenceType *T) {
   return Visit(T->getPointeeType());
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitRValueReferenceType(
-                                                const RValueReferenceType* T) {
+    const RValueReferenceType *T) {
   return Visit(T->getPointeeType());
 }
 
@@ -6283,27 +6252,27 @@ bool UnnamedLocalNoLinkageFinder::VisitMemberPointerType(
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitConstantArrayType(
-                                                  const ConstantArrayType* T) {
+    const ConstantArrayType *T) {
   return Visit(T->getElementType());
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitIncompleteArrayType(
-                                                 const IncompleteArrayType* T) {
+    const IncompleteArrayType *T) {
   return Visit(T->getElementType());
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitVariableArrayType(
-                                                   const VariableArrayType* T) {
+    const VariableArrayType *T) {
   return Visit(T->getElementType());
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedArrayType(
-                                            const DependentSizedArrayType* T) {
+    const DependentSizedArrayType *T) {
   return Visit(T->getElementType());
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedExtVectorType(
-                                         const DependentSizedExtVectorType* T) {
+    const DependentSizedExtVectorType *T) {
   return Visit(T->getElementType());
 }
 
@@ -6317,7 +6286,7 @@ bool UnnamedLocalNoLinkageFinder::VisitDependentAddressSpaceType(
   return Visit(T->getPointeeType());
 }
 
-bool UnnamedLocalNoLinkageFinder::VisitVectorType(const VectorType* T) {
+bool UnnamedLocalNoLinkageFinder::VisitVectorType(const VectorType *T) {
   return Visit(T->getElementType());
 }
 
@@ -6326,7 +6295,7 @@ bool UnnamedLocalNoLinkageFinder::VisitDependentVectorType(
   return Visit(T->getElementType());
 }
 
-bool UnnamedLocalNoLinkageFinder::VisitExtVectorType(const ExtVectorType* T) {
+bool UnnamedLocalNoLinkageFinder::VisitExtVectorType(const ExtVectorType *T) {
   return Visit(T->getElementType());
 }
 
@@ -6336,7 +6305,7 @@ bool UnnamedLocalNoLinkageFinder::VisitConstantMatrixType(
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitFunctionProtoType(
-                                                  const FunctionProtoType* T) {
+    const FunctionProtoType *T) {
   for (const auto &A : T->param_types()) {
     if (Visit(A))
       return true;
@@ -6346,24 +6315,24 @@ bool UnnamedLocalNoLinkageFinder::VisitFunctionProtoType(
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitFunctionNoProtoType(
-                                               const FunctionNoProtoType* T) {
+    const FunctionNoProtoType *T) {
   return Visit(T->getReturnType());
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitUnresolvedUsingType(
-                                                  const UnresolvedUsingType*) {
+    const UnresolvedUsingType *) {
   return false;
 }
 
-bool UnnamedLocalNoLinkageFinder::VisitTypeOfExprType(const TypeOfExprType*) {
+bool UnnamedLocalNoLinkageFinder::VisitTypeOfExprType(const TypeOfExprType *) {
   return false;
 }
 
-bool UnnamedLocalNoLinkageFinder::VisitTypeOfType(const TypeOfType* T) {
+bool UnnamedLocalNoLinkageFinder::VisitTypeOfType(const TypeOfType *T) {
   return Visit(T->getUnmodifiedType());
 }
 
-bool UnnamedLocalNoLinkageFinder::VisitDecltypeType(const DecltypeType*) {
+bool UnnamedLocalNoLinkageFinder::VisitDecltypeType(const DecltypeType *) {
   return false;
 }
 
@@ -6373,7 +6342,7 @@ bool UnnamedLocalNoLinkageFinder::VisitPackIndexingType(
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitUnaryTransformType(
-                                                    const UnaryTransformType*) {
+    const UnaryTransformType *) {
   return false;
 }
 
@@ -6386,21 +6355,21 @@ bool UnnamedLocalNoLinkageFinder::VisitDeducedTemplateSpecializationType(
   return Visit(T->getDeducedType());
 }
 
-bool UnnamedLocalNoLinkageFinder::VisitRecordType(const RecordType* T) {
+bool UnnamedLocalNoLinkageFinder::VisitRecordType(const RecordType *T) {
   return VisitTagDecl(T->getDecl()->getDefinitionOrSelf());
 }
 
-bool UnnamedLocalNoLinkageFinder::VisitEnumType(const EnumType* T) {
+bool UnnamedLocalNoLinkageFinder::VisitEnumType(const EnumType *T) {
   return VisitTagDecl(T->getDecl()->getDefinitionOrSelf());
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitTemplateTypeParmType(
-                                                 const TemplateTypeParmType*) {
+    const TemplateTypeParmType *) {
   return false;
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitSubstTemplateTypeParmPackType(
-                                        const SubstTemplateTypeParmPackType *) {
+    const SubstTemplateTypeParmPackType *) {
   return false;
 }
 
@@ -6410,22 +6379,22 @@ bool UnnamedLocalNoLinkageFinder::VisitSubstBuiltinTemplatePackType(
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitTemplateSpecializationType(
-                                            const TemplateSpecializationType*) {
+    const TemplateSpecializationType *) {
   return false;
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitInjectedClassNameType(
-                                              const InjectedClassNameType* T) {
+    const InjectedClassNameType *T) {
   return VisitTagDecl(T->getDecl()->getDefinitionOrSelf());
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitDependentNameType(
-                                                   const DependentNameType* T) {
+    const DependentNameType *T) {
   return VisitNestedNameSpecifier(T->getQualifier());
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitPackExpansionType(
-                                                   const PackExpansionType* T) {
+    const PackExpansionType *T) {
   return Visit(T->getPattern());
 }
 
@@ -6434,16 +6403,16 @@ bool UnnamedLocalNoLinkageFinder::VisitObjCObjectType(const ObjCObjectType *) {
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitObjCInterfaceType(
-                                                   const ObjCInterfaceType *) {
+    const ObjCInterfaceType *) {
   return false;
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitObjCObjectPointerType(
-                                                const ObjCObjectPointerType *) {
+    const ObjCObjectPointerType *) {
   return false;
 }
 
-bool UnnamedLocalNoLinkageFinder::VisitAtomicType(const AtomicType* T) {
+bool UnnamedLocalNoLinkageFinder::VisitAtomicType(const AtomicType *T) {
   return Visit(T->getValueType());
 }
 
@@ -6452,7 +6421,7 @@ bool UnnamedLocalNoLinkageFinder::VisitOverflowBehaviorType(
   return Visit(T->getUnderlyingType());
 }
 
-bool UnnamedLocalNoLinkageFinder::VisitPipeType(const PipeType* T) {
+bool UnnamedLocalNoLinkageFinder::VisitPipeType(const PipeType *T) {
   return false;
 }
 
@@ -6481,9 +6450,10 @@ bool UnnamedLocalNoLinkageFinder::VisitTagDecl(const TagDecl *Tag) {
 
   if (!Tag->hasNameForLinkage()) {
     S.Diag(SR.getBegin(),
-           S.getLangOpts().CPlusPlus11 ?
-             diag::warn_cxx98_compat_template_arg_unnamed_type :
-             diag::ext_template_arg_unnamed_type) << SR;
+           S.getLangOpts().CPlusPlus11
+               ? diag::warn_cxx98_compat_template_arg_unnamed_type
+               : diag::ext_template_arg_unnamed_type)
+        << SR;
     S.Diag(Tag->getLocation(), diag::note_template_unnamed_type_here);
     return true;
   }
@@ -6548,11 +6518,7 @@ bool Sema::CheckTemplateArgument(TypeSourceInfo *ArgInfo) {
   return false;
 }
 
-enum NullPointerValueKind {
-  NPV_NotNullPointer,
-  NPV_NullPointer,
-  NPV_Error
-};
+enum NullPointerValueKind { NPV_NotNullPointer, NPV_NullPointer, NPV_Error };
 
 /// Determine whether the given template argument is a null pointer
 /// value of the appropriate type.
@@ -6592,13 +6558,13 @@ isNullPointerValueTemplateArgument(Sema &S, NamedDecl *Param,
     // the caret at its location rather than producing an essentially
     // redundant note.
     if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
-        diag::note_invalid_subexpr_in_const_expr) {
+                                 diag::note_invalid_subexpr_in_const_expr) {
       DiagLoc = Notes[0].first;
       Notes.clear();
     }
 
     S.Diag(DiagLoc, diag::err_template_arg_not_address_constant)
-      << Arg->getType() << Arg->getSourceRange();
+        << Arg->getType() << Arg->getSourceRange();
     for (unsigned I = 0, N = Notes.size(); I != N; ++I)
       S.Diag(Notes[I].first, Notes[I].second);
 
@@ -6621,13 +6587,13 @@ isNullPointerValueTemplateArgument(Sema &S, NamedDecl *Param,
     bool ObjCLifetimeConversion;
     if (S.Context.hasSameUnqualifiedType(Arg->getType(), ParamType) ||
         S.IsQualificationConversion(Arg->getType(), ParamType, false,
-                                     ObjCLifetimeConversion))
+                                    ObjCLifetimeConversion))
       return NPV_NullPointer;
 
     // The types didn't match, but we know we got a null pointer; complain,
     // then recover as if the types were correct.
     S.Diag(Arg->getExprLoc(), diag::err_template_arg_wrongtype_null_constant)
-      << Arg->getType() << ParamType << Arg->getSourceRange();
+        << Arg->getType() << ParamType << Arg->getSourceRange();
     S.NoteTemplateParameterLocation(*Param);
     return NPV_NullPointer;
   }
@@ -6637,7 +6603,7 @@ isNullPointerValueTemplateArgument(Sema &S, NamedDecl *Param,
     // We could just return NPV_NotNullPointer, but we can print a better
     // message with the information we have here.
     S.Diag(Arg->getExprLoc(), diag::err_template_arg_invalid)
-      << EvalResult.Val.getAsString(S.Context, ParamType);
+        << EvalResult.Val.getAsString(S.Context, ParamType);
     S.NoteTemplateParameterLocation(*Param);
     return NPV_Error;
   }
@@ -6893,12 +6859,12 @@ static bool CheckTemplateArgumentAddressOfObjectOrFunction(
                : diag::ext_template_arg_object_internal)
         << !Func << Entity << Arg->getSourceRange();
     S.Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
-      << !Func;
+        << !Func;
   } else if (!Entity->hasLinkage()) {
     S.Diag(Arg->getBeginLoc(), diag::err_template_arg_object_no_linkage)
         << !Func << Entity << Arg->getSourceRange();
     S.Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
-      << !Func;
+        << !Func;
     return true;
   }
 
@@ -6927,14 +6893,13 @@ static bool CheckTemplateArgumentAddressOfObjectOrFunction(
     if (!S.Context.hasSameUnqualifiedType(Entity->getType(),
                                           ParamType.getNonReferenceType())) {
       S.Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
-        << ParamType;
+          << ParamType;
       S.NoteTemplateParameterLocation(*Param);
       return true;
     }
 
     S.Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
-      << ParamType
-      << FixItHint::CreateRemoval(AddrOpLoc);
+        << ParamType << FixItHint::CreateRemoval(AddrOpLoc);
     S.NoteTemplateParameterLocation(*Param);
 
     ArgType = Entity->getType();
@@ -6956,13 +6921,13 @@ static bool CheckTemplateArgumentAddressOfObjectOrFunction(
       ArgType = S.Context.getPointerType(Entity->getType());
       if (!S.Context.hasSameUnqualifiedType(ArgType, ParamType)) {
         S.Diag(Arg->getBeginLoc(), diag::err_template_arg_not_address_of)
-          << ParamType;
+            << ParamType;
         S.NoteTemplateParameterLocation(*Param);
         return true;
       }
 
       S.Diag(Arg->getBeginLoc(), diag::err_template_arg_not_address_of)
-        << ParamType << FixItHint::CreateInsertion(Arg->getBeginLoc(), "&");
+          << ParamType << FixItHint::CreateInsertion(Arg->getBeginLoc(), "&");
 
       S.NoteTemplateParameterLocation(*Param);
     }
@@ -7013,7 +6978,7 @@ static bool CheckTemplateArgumentPointerToMember(
   }
 
   while (SubstNonTypeTemplateParmExpr *subst =
-           dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
+             dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
     Arg = subst->getReplacement()->IgnoreImpCasts();
 
   // A pointer-to-member constant written &Class::member.
@@ -7156,7 +7121,7 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
       InitializedEntity Entity =
           InitializedEntity::InitializeTemplateParameter(ParamType, Param);
       InitializationKind Kind = InitializationKind::CreateForInit(
-          DeductionArg->getBeginLoc(), /*DirectInit*/false, DeductionArg);
+          DeductionArg->getBeginLoc(), /*DirectInit*/ false, DeductionArg);
       Expr *Inits[1] = {DeductionArg};
       ParamType =
           DeduceTemplateSpecializationFromInitializer(TSI, Entity, Kind, Inits);
@@ -7500,7 +7465,7 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
         QualType T;
 
       public:
-        TmplArgICEDiagnoser(QualType T) : T(T) { }
+        TmplArgICEDiagnoser(QualType T) : T(T) {}
 
         SemaDiagnosticBuilder diagnoseNotICE(Sema &S,
                                              SourceLocation Loc) override {
@@ -7608,32 +7573,33 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
 
   // Handle pointer-to-function, reference-to-function, and
   // pointer-to-member-function all in (roughly) the same way.
-  if (// -- For a non-type template-parameter of type pointer to
-      //    function, only the function-to-pointer conversion (4.3) is
-      //    applied. If the template-argument represents a set of
-      //    overloaded functions (or a pointer to such), the matching
-      //    function is selected from the set (13.4).
+  if ( // -- For a non-type template-parameter of type pointer to
+       //    function, only the function-to-pointer conversion (4.3) is
+       //    applied. If the template-argument represents a set of
+       //    overloaded functions (or a pointer to such), the matching
+       //    function is selected from the set (13.4).
       (ParamType->isPointerType() &&
        ParamType->castAs<PointerType>()->getPointeeType()->isFunctionType()) ||
       // -- For a non-type template-parameter of type reference to
       //    function, no conversions apply. If the template-argument
       //    represents a set of overloaded functions, the matching
       //    function is selected from the set (13.4).
-      (ParamType->isReferenceType() &&
-       ParamType->castAs<ReferenceType>()->getPointeeType()->isFunctionType()) ||
+      (ParamType->isReferenceType() && ParamType->castAs<ReferenceType>()
+                                           ->getPointeeType()
+                                           ->isFunctionType()) ||
       // -- For a non-type template-parameter of type pointer to
       //    member function, no conversions apply. If the
       //    template-argument represents a set of overloaded member
       //    functions, the matching member function is selected from
       //    the set (13.4).
       (ParamType->isMemberPointerType() &&
-       ParamType->castAs<MemberPointerType>()->getPointeeType()
-         ->isFunctionType())) {
+       ParamType->castAs<MemberPointerType>()
+           ->getPointeeType()
+           ->isFunctionType())) {
 
     if (Arg->getType() == Context.OverloadTy) {
-      if (FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg, ParamType,
-                                                                true,
-                                                                FoundResult)) {
+      if (FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(
+              Arg, ParamType, true, FoundResult)) {
         if (DiagnoseUseOfDecl(Fn, Arg->getBeginLoc()))
           return ExprError();
 
@@ -7685,10 +7651,8 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
            "Only object references allowed here");
 
     if (Arg->getType() == Context.OverloadTy) {
-      if (FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg,
-                                                 ParamRefType->getPointeeType(),
-                                                                true,
-                                                                FoundResult)) {
+      if (FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(
+              Arg, ParamRefType->getPointeeType(), true, FoundResult)) {
         if (DiagnoseUseOfDecl(Fn, Arg->getBeginLoc()))
           return ExprError();
         ExprResult Res = FixOverloadedFunctionReference(Arg, FoundResult, Fn);
@@ -7936,11 +7900,9 @@ ExprResult Sema::BuildExpressionFromDeclTemplateArgument(
   // parameter's type.
   if (Arg.getKind() == TemplateArgument::NullPtr) {
     return ImpCastExprToType(
-             new (Context) CXXNullPtrLiteralExpr(Context.NullPtrTy, Loc),
-                             ParamType,
-                             ParamType->getAs<MemberPointerType>()
-                               ? CK_NullToMemberPointer
-                               : CK_NullToPointer);
+        new (Context) CXXNullPtrLiteralExpr(Context.NullPtrTy, Loc), ParamType,
+        ParamType->getAs<MemberPointerType>() ? CK_NullToMemberPointer
+                                              : CK_NullToPointer);
   }
   assert(Arg.getKind() == TemplateArgument::Declaration &&
          "Only declaration template arguments permitted here");
@@ -8083,6 +8045,15 @@ static Expr *BuildExpressionFromIntegralTemplateArgumentValue(
   return E;
 }
 
+/// Construct a new reflect expression that refers to the given
+/// entity with the given source-location of the reflection operator.
+static ExprResult BuildExpressionFromReflection(Sema &S, const APValue &RV,
+                                                SourceLocation CaretCaretLoc) {
+  return CXXReflectExpr::Create(
+      S.Context, CaretCaretLoc,
+      static_cast<const TypeSourceInfo *>((RV.getReflectionOpaqueOperand())));
+}
+
 static Expr *BuildExpressionFromNonTypeTemplateArgumentValue(
     Sema &S, QualType T, const APValue &Val, SourceLocation Loc) {
   auto MakeInitList = [&](ArrayRef<Expr *> Elts) -> Expr * {
@@ -8147,7 +8118,7 @@ static Expr *BuildExpressionFromNonTypeTemplateArgumentValue(
   case APValue::Indeterminate:
     llvm_unreachable("Unexpected APValue kind.");
   case APValue::LValue:
-  case APValue::MemberPointer:
+  case APValue::MemberPointer: {
     // There isn't necessarily a valid equivalent source-level syntax for
     // these; in particular, a naive lowering might violate access control.
     // So for now we lower to a ConstantExpr holding the value, wrapped around
@@ -8161,6 +8132,9 @@ static Expr *BuildExpressionFromNonTypeTemplateArgumentValue(
     auto *OVE = new (S.Context) OpaqueValueExpr(Loc, T, VK);
     return ConstantExpr::Create(S.Context, OVE, Val);
   }
+  case APValue::Reflection:
+    return BuildExpressionFromReflection(S, Val, Loc).get();
+  }
   llvm_unreachable("Unhandled APValue::ValueKind enum");
 }
 
@@ -8208,10 +8182,9 @@ static bool MatchTemplateParameterKind(
         S.Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
         NextDiag = diag::note_template_param_different_kind;
       }
-      S.Diag(New->getLocation(), NextDiag)
-        << (Kind != Sema::TPL_TemplateMatch);
+      S.Diag(New->getLocation(), NextDiag) << (Kind != Sema::TPL_TemplateMatch);
       S.Diag(Old->getLocation(), diag::note_template_prev_declaration)
-        << (Kind != Sema::TPL_TemplateMatch);
+          << (Kind != Sema::TPL_TemplateMatch);
     }
 
     return false;
@@ -8225,18 +8198,17 @@ static bool MatchTemplateParameterKind(
     if (Complain) {
       unsigned NextDiag = diag::err_template_parameter_pack_non_pack;
       if (TemplateArgLoc.isValid()) {
-        S.Diag(TemplateArgLoc,
-             diag::err_template_arg_template_params_mismatch);
+        S.Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
         NextDiag = diag::note_template_parameter_pack_non_pack;
       }
 
-      unsigned ParamKind = isa<TemplateTypeParmDecl>(New)? 0
-                      : isa<NonTypeTemplateParmDecl>(New)? 1
-                      : 2;
+      unsigned ParamKind = isa<TemplateTypeParmDecl>(New)      ? 0
+                           : isa<NonTypeTemplateParmDecl>(New) ? 1
+                                                               : 2;
       S.Diag(New->getLocation(), NextDiag)
-        << ParamKind << New->isParameterPack();
+          << ParamKind << New->isParameterPack();
       S.Diag(Old->getLocation(), diag::note_template_parameter_pack_here)
-        << ParamKind << Old->isParameterPack();
+          << ParamKind << Old->isParameterPack();
     }
 
     return false;
@@ -8317,9 +8289,10 @@ static bool MatchTemplateParameterKind(
 
     auto Diagnose = [&] {
       S.Diag(NewC ? NewC->getBeginLoc() : New->getBeginLoc(),
-           diag::err_template_different_type_constraint);
+             diag::err_template_different_type_constraint);
       S.Diag(OldC ? OldC->getBeginLoc() : Old->getBeginLoc(),
-           diag::note_template_prev_declaration) << /*declaration*/0;
+             diag::note_template_prev_declaration)
+          << /*declaration*/ 0;
     };
 
     if (!NewC != !OldC) {
@@ -8343,24 +8316,20 @@ static bool MatchTemplateParameterKind(
 
 /// Diagnose a known arity mismatch when comparing template argument
 /// lists.
-static
-void DiagnoseTemplateParameterListArityMismatch(Sema &S,
-                                                TemplateParameterList *New,
-                                                TemplateParameterList *Old,
-                                      Sema::TemplateParameterListEqualKind Kind,
-                                                SourceLocation TemplateArgLoc) {
+static void DiagnoseTemplateParameterListArityMismatch(
+    Sema &S, TemplateParameterList *New, TemplateParameterList *Old,
+    Sema::TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc) {
   unsigned NextDiag = diag::err_template_param_list_different_arity;
   if (TemplateArgLoc.isValid()) {
     S.Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
     NextDiag = diag::note_template_param_list_different_arity;
   }
   S.Diag(New->getTemplateLoc(), NextDiag)
-    << (New->size() > Old->size())
-    << (Kind != Sema::TPL_TemplateMatch)
-    << SourceRange(New->getTemplateLoc(), New->getRAngleLoc());
+      << (New->size() > Old->size()) << (Kind != Sema::TPL_TemplateMatch)
+      << SourceRange(New->getTemplateLoc(), New->getRAngleLoc());
   S.Diag(Old->getTemplateLoc(), diag::note_template_prev_declaration)
-    << (Kind != Sema::TPL_TemplateMatch)
-    << SourceRange(Old->getTemplateLoc(), Old->getRAngleLoc());
+      << (Kind != Sema::TPL_TemplateMatch)
+      << SourceRange(Old->getTemplateLoc(), Old->getRAngleLoc());
 }
 
 bool Sema::TemplateParameterListsAreEqual(
@@ -8415,7 +8384,8 @@ bool Sema::TemplateParameterListsAreEqual(
       Diag(NewRC ? NewRC->getBeginLoc() : New->getTemplateLoc(),
            diag::err_template_different_requires_clause);
       Diag(OldRC ? OldRC->getBeginLoc() : Old->getTemplateLoc(),
-           diag::note_template_prev_declaration) << /*declaration*/0;
+           diag::note_template_prev_declaration)
+          << /*declaration*/ 0;
     };
 
     if (!NewRC != !OldRC) {
@@ -8437,8 +8407,8 @@ bool Sema::TemplateParameterListsAreEqual(
   return true;
 }
 
-bool
-Sema::CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams) {
+bool Sema::CheckTemplateDeclScope(Scope *S,
+                                  TemplateParameterList *TemplateParams) {
   if (!S)
     return false;
 
@@ -8479,7 +8449,7 @@ Sema::CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams) {
       if (RD->isLocalClass())
         return Diag(TemplateParams->getTemplateLoc(),
                     diag::err_template_inside_local_class)
-          << TemplateParams->getSourceRange();
+               << TemplateParams->getSourceRange();
       else
         return false;
     }
@@ -8487,7 +8457,7 @@ Sema::CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams) {
 
   return Diag(TemplateParams->getTemplateLoc(),
               diag::err_template_outside_namespace_or_class_scope)
-    << TemplateParams->getSourceRange();
+         << TemplateParams->getSourceRange();
 }
 
 /// Determine what kind of template specialization the given declaration
@@ -8530,8 +8500,7 @@ static TemplateSpecializationKind getTemplateSpecializationKind(Decl *D) {
 ///
 /// \returns true if there was an error that we cannot recover from, false
 /// otherwise.
-static bool CheckTemplateSpecializationScope(Sema &S,
-                                             NamedDecl *Specialized,
+static bool CheckTemplateSpecializationScope(Sema &S, NamedDecl *Specialized,
                                              NamedDecl *PrevDecl,
                                              SourceLocation Loc,
                                              bool IsPartialSpecialization) {
@@ -8539,7 +8508,7 @@ static bool CheckTemplateSpecializationScope(Sema &S,
   // various diagnostics emitted by this routine.
   int EntityKind = 0;
   if (isa<ClassTemplateDecl>(Specialized))
-    EntityKind = IsPartialSpecialization? 1 : 0;
+    EntityKind = IsPartialSpecialization ? 1 : 0;
   else if (isa<VarTemplateDecl>(Specialized))
     EntityKind = IsPartialSpecialization ? 3 : 2;
   else if (isa<FunctionTemplateDecl>(Specialized))
@@ -8554,7 +8523,7 @@ static bool CheckTemplateSpecializationScope(Sema &S,
     EntityKind = 8;
   else {
     S.Diag(Loc, diag::err_template_spec_unknown_kind)
-      << S.getLangOpts().CPlusPlus11;
+        << S.getLangOpts().CPlusPlus11;
     S.Diag(Specialized->getLocation(), diag::note_specialized_entity);
     return true;
   }
@@ -8563,8 +8532,7 @@ static bool CheckTemplateSpecializationScope(Sema &S,
   //   An explicit specialization may be declared in any scope in which
   //   the corresponding primary template may be defined.
   if (S.CurContext->getRedeclContext()->isFunctionOrMethod()) {
-    S.Diag(Loc, diag::err_template_spec_decl_function_scope)
-      << Specialized;
+    S.Diag(Loc, diag::err_template_spec_decl_function_scope) << Specialized;
     return true;
   }
 
@@ -8581,14 +8549,14 @@ static bool CheckTemplateSpecializationScope(Sema &S,
                             : DC->Equals(SpecializedContext))) {
     if (isa<TranslationUnitDecl>(SpecializedContext))
       S.Diag(Loc, diag::err_template_spec_redecl_global_scope)
-        << EntityKind << Specialized;
+          << EntityKind << Specialized;
     else {
       auto *ND = cast<NamedDecl>(SpecializedContext);
       int Diag = diag::err_template_spec_redecl_out_of_scope;
       if (S.getLangOpts().MicrosoftExt && !DC->isRecord())
         Diag = diag::ext_ms_template_spec_redecl_out_of_scope;
-      S.Diag(Loc, Diag) << EntityKind << Specialized
-                        << ND << isa<CXXRecordDecl>(ND);
+      S.Diag(Loc, Diag) << EntityKind << Specialized << ND
+                        << isa<CXXRecordDecl>(ND);
     }
 
     S.Diag(Specialized->getLocation(), diag::note_specialized_entity);
@@ -8605,7 +8573,7 @@ static bool CheckTemplateSpecializationScope(Sema &S,
 static SourceRange findTemplateParameterInType(unsigned Depth, Expr *E) {
   if (!E->isTypeDependent())
     return SourceLocation();
-  DependencyChecker Checker(Depth, /*IgnoreNonTypeDependent*/true);
+  DependencyChecker Checker(Depth, /*IgnoreNonTypeDependent*/ true);
   Checker.TraverseStmt(E);
   if (Checker.MatchLoc.isInvalid())
     return E->getSourceRange();
@@ -8615,7 +8583,7 @@ static SourceRange findTemplateParameterInType(unsigned Depth, Expr *E) {
 static SourceRange findTemplateParameter(unsigned Depth, TypeLoc TL) {
   if (!TL.getType()->isDependentType())
     return SourceLocation();
-  DependencyChecker Checker(Depth, /*IgnoreNonTypeDependent*/true);
+  DependencyChecker Checker(Depth, /*IgnoreNonTypeDependent*/ true);
   Checker.TraverseTypeLoc(TL);
   if (Checker.MatchLoc.isInvalid())
     return TL.getSourceRange();
@@ -8695,11 +8663,11 @@ static bool CheckNonTypeTemplatePartialSpecializationArgs(
                diag::err_dependent_non_type_arg_in_partial_spec);
         S.Diag(ParamUseRange.getBegin(),
                diag::note_dependent_non_type_default_arg_in_partial_spec)
-          << ParamUseRange;
+            << ParamUseRange;
       } else {
         S.Diag(ParamUseRange.getBegin(),
                diag::err_dependent_non_type_arg_in_partial_spec)
-          << ParamUseRange;
+            << ParamUseRange;
       }
       return true;
     }
@@ -8729,8 +8697,8 @@ bool Sema::CheckTemplatePartialSpecializationArgs(
   TemplateParameterList *TemplateParams =
       PrimaryTemplate->getTemplateParameters();
   for (unsigned I = 0, N = TemplateParams->size(); I != N; ++I) {
-    NonTypeTemplateParmDecl *Param
-      = dyn_cast<NonTypeTemplateParmDecl>(TemplateParams->getParam(I));
+    NonTypeTemplateParmDecl *Param =
+        dyn_cast<NonTypeTemplateParmDecl>(TemplateParams->getParam(I));
     if (!Param)
       continue;
 
@@ -8756,13 +8724,13 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
 
   // Find the class template we're specializing
   TemplateName Name = TemplateId.Template.get();
-  ClassTemplateDecl *ClassTemplate
-    = dyn_cast_or_null<ClassTemplateDecl>(Name.getAsTemplateDecl());
+  ClassTemplateDecl *ClassTemplate =
+      dyn_cast_or_null<ClassTemplateDecl>(Name.getAsTemplateDecl());
 
   if (!ClassTemplate) {
     Diag(TemplateNameLoc, diag::err_not_class_template_specialization)
-      << (Name.getAsTemplateDecl() &&
-          isa<TemplateTemplateParmDecl>(Name.getAsTemplateDecl()));
+        << (Name.getAsTemplateDecl() &&
+            isa<TemplateTemplateParmDecl>(Name.getAsTemplateDecl()));
     return true;
   }
 
@@ -8816,7 +8784,7 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
 
     if (TUK == TagUseKind::Friend) {
       Diag(KWLoc, diag::err_partial_specialization_friend)
-        << SourceRange(LAngleLoc, RAngleLoc);
+          << SourceRange(LAngleLoc, RAngleLoc);
       return true;
     }
 
@@ -8831,8 +8799,8 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
                diag::err_default_arg_in_partial_spec);
           TTP->removeDefaultArgument();
         }
-      } else if (NonTypeTemplateParmDecl *NTTP
-                   = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
+      } else if (NonTypeTemplateParmDecl *NTTP =
+                     dyn_cast<NonTypeTemplateParmDecl>(Param)) {
         if (NTTP->hasDefaultArgument()) {
           Diag(NTTP->getDefaultArgumentLoc(),
                diag::err_default_arg_in_partial_spec)
@@ -8844,7 +8812,7 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
         if (TTP->hasDefaultArgument()) {
           Diag(TTP->getDefaultArgument().getLocation(),
                diag::err_default_arg_in_partial_spec)
-            << TTP->getDefaultArgument().getSourceRange();
+              << TTP->getDefaultArgument().getSourceRange();
           TTP->removeDefaultArgument();
         }
       }
@@ -8852,10 +8820,10 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
   } else if (TemplateParams) {
     if (TUK == TagUseKind::Friend)
       Diag(KWLoc, diag::err_template_spec_friend)
-        << FixItHint::CreateRemoval(
-                                SourceRange(TemplateParams->getTemplateLoc(),
-                                            TemplateParams->getRAngleLoc()))
-        << SourceRange(LAngleLoc, RAngleLoc);
+          << FixItHint::CreateRemoval(
+                 SourceRange(TemplateParams->getTemplateLoc(),
+                             TemplateParams->getRAngleLoc()))
+          << SourceRange(LAngleLoc, RAngleLoc);
   } else {
     assert(TUK == TagUseKind::Friend &&
            "should have a 'template<>' for this decl");
@@ -8870,9 +8838,9 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
                                     TUK == TagUseKind::Definition, KWLoc,
                                     ClassTemplate->getIdentifier())) {
     Diag(KWLoc, diag::err_use_with_wrong_tag)
-      << ClassTemplate
-      << FixItHint::CreateReplacement(KWLoc,
-                            ClassTemplate->getTemplatedDecl()->getKindName());
+        << ClassTemplate
+        << FixItHint::CreateReplacement(
+               KWLoc, ClassTemplate->getTemplatedDecl()->getKindName());
     Diag(ClassTemplate->getTemplatedDecl()->getLocation(),
          diag::note_previous_use);
     Kind = ClassTemplate->getTemplatedDecl()->getTagKind();
@@ -8913,7 +8881,7 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
         !TemplateSpecializationType::anyDependentTemplateArguments(
             TemplateArgs, CTAI.CanonicalConverted)) {
       Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
-        << ClassTemplate->getDeclName();
+          << ClassTemplate->getDeclName();
       isPartialSpecialization = false;
       Invalid = true;
     }
@@ -9032,8 +9000,8 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
 
       Diag(PrevDecl->getPointOfInstantiation(),
            diag::note_instantiation_required_here)
-        << (PrevDecl->getTemplateSpecializationKind()
-                                                != TSK_ImplicitInstantiation);
+          << (PrevDecl->getTemplateSpecializationKind() !=
+              TSK_ImplicitInstantiation);
       return true;
     }
   }
@@ -9076,8 +9044,8 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
 
   if (ModulePrivateLoc.isValid())
     Diag(Specialization->getLocation(), diag::err_module_private_specialization)
-      << (isPartialSpecialization? 1 : 0)
-      << FixItHint::CreateRemoval(ModulePrivateLoc);
+        << (isPartialSpecialization ? 1 : 0)
+        << FixItHint::CreateRemoval(ModulePrivateLoc);
 
   // C++ [temp.expl.spec]p9:
   //   A template explicit specialization is in the scope of the
@@ -9108,10 +9076,9 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
     // actually wrote the specialization, rather than formatting the
     // name based on the "canonical" representation used to store the
     // template arguments in the specialization.
-    FriendDecl *Friend = FriendDecl::Create(Context, CurContext,
-                                            TemplateNameLoc,
-                                            WrittenTy,
-                                            /*FIXME:*/KWLoc);
+    FriendDecl *Friend =
+        FriendDecl::Create(Context, CurContext, TemplateNameLoc, WrittenTy,
+                           /*FIXME:*/ KWLoc);
     Friend->setAccess(AS_public);
     CurContext->addDecl(Friend);
   } else {
@@ -9129,9 +9096,8 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
   return Specialization;
 }
 
-Decl *Sema::ActOnTemplateDeclarator(Scope *S,
-                              MultiTemplateParamsArg TemplateParameterLists,
-                                    Declarator &D) {
+Decl *Sema::ActOnTemplateDeclarator(
+    Scope *S, MultiTemplateParamsArg TemplateParameterLists, Declarator &D) {
   Decl *NewDecl = HandleDeclarator(S, D, TemplateParameterLists);
   ActOnDocumentableDecl(NewDecl);
   return NewDecl;
@@ -9144,7 +9110,7 @@ ConceptDecl *Sema::ActOnStartConceptDefinition(
 
   if (!DC->getRedeclContext()->isFileContext()) {
     Diag(NameLoc,
-      diag::err_concept_decls_may_only_appear_in_global_namespace_scope);
+         diag::err_concept_decls_may_only_appear_in_global_namespace_scope);
     return nullptr;
   }
 
@@ -9253,7 +9219,8 @@ void Sema::CheckConceptRedefinition(ConceptDecl *NewDecl,
   if (Previous.empty())
     return;
 
-  auto *OldConcept = dyn_cast<ConceptDecl>(Previous.getRepresentativeDecl()->getUnderlyingDecl());
+  auto *OldConcept = dyn_cast<ConceptDecl>(
+      Previous.getRepresentativeDecl()->getUnderlyingDecl());
   if (!OldConcept) {
     auto *Old = Previous.getRepresentativeDecl();
     Diag(NewDecl->getLocation(), diag::err_redefinition_different_kind)
@@ -9313,8 +9280,9 @@ static void StripImplicitInstantiation(NamedDecl *D, bool MinGW) {
 
 /// Compute the diagnostic location for an explicit instantiation
 //  declaration or definition.
-static SourceLocation DiagLocForExplicitInstantiation(
-    NamedDecl* D, SourceLocation PointOfInstantiation) {
+static SourceLocation
+DiagLocForExplicitInstantiation(NamedDecl *D,
+                                SourceLocation PointOfInstantiation) {
   // Explicit instantiations following a specialization have no effect and
   // hence no PointOfInstantiation. In that case, walk decl backwards
   // until a valid name loc is found.
@@ -9328,13 +9296,10 @@ static SourceLocation DiagLocForExplicitInstantiation(
   return PrevDiagLoc;
 }
 
-bool
-Sema::CheckSpecializationInstantiationRedecl(SourceLocation NewLoc,
-                                             TemplateSpecializationKind NewTSK,
-                                             NamedDecl *PrevDecl,
-                                             TemplateSpecializationKind PrevTSK,
-                                        SourceLocation PrevPointOfInstantiation,
-                                             bool &HasNoEffect) {
+bool Sema::CheckSpecializationInstantiationRedecl(
+    SourceLocation NewLoc, TemplateSpecializationKind NewTSK,
+    NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK,
+    SourceLocation PrevPointOfInstantiation, bool &HasNoEffect) {
   HasNoEffect = false;
 
   switch (NewTSK) {
@@ -9383,10 +9348,9 @@ Sema::CheckSpecializationInstantiationRedecl(SourceLocation NewLoc,
           return false;
       }
 
-      Diag(NewLoc, diag::err_specialization_after_instantiation)
-        << PrevDecl;
+      Diag(NewLoc, diag::err_specialization_after_instantiation) << PrevDecl;
       Diag(PrevPointOfInstantiation, diag::note_instantiation_required_here)
-        << (PrevTSK != TSK_ImplicitInstantiation);
+          << (PrevTSK != TSK_ImplicitInstantiation);
 
       return true;
     }
@@ -9447,7 +9411,7 @@ Sema::CheckSpecializationInstantiationRedecl(SourceLocation NewLoc,
       //   an explicit specialization for that template, the explicit
       //   instantiation has no effect.
       Diag(NewLoc, diag::warn_explicit_instantiation_after_specialization)
-        << PrevDecl;
+          << PrevDecl;
       Diag(PrevDecl->getLocation(),
            diag::note_previous_template_specialization);
       HasNoEffect = true;
@@ -9548,14 +9512,14 @@ bool Sema::CheckFunctionTemplateSpecialization(
       ConvertedTemplateArgs;
 
   DeclContext *FDLookupContext = FD->getDeclContext()->getRedeclContext();
-  for (LookupResult::iterator I = Previous.begin(), E = Previous.end();
-         I != E; ++I) {
+  for (LookupResult::iterator I = Previous.begin(), E = Previous.end(); I != E;
+       ++I) {
     NamedDecl *Ovl = (*I)->getUnderlyingDecl();
     if (FunctionTemplateDecl *FunTmpl = dyn_cast<FunctionTemplateDecl>(Ovl)) {
       // Only consider templates found within the same semantic lookup scope as
       // FD.
       if (!FDLookupContext->InEnclosingNamespaceSetOf(
-                                Ovl->getDeclContext()->getRedeclContext()))
+              Ovl->getDeclContext()->getRedeclContext()))
         continue;
 
       QualType FT = FD->getType();
@@ -9702,8 +9666,8 @@ bool Sema::CheckFunctionTemplateSpecialization(
       !ResolveExceptionSpec(FD->getLocation(), SpecializationFPT))
     return true;
 
-  FunctionTemplateSpecializationInfo *SpecInfo
-    = Specialization->getTemplateSpecializationInfo();
+  FunctionTemplateSpecializationInfo *SpecInfo =
+      Specialization->getTemplateSpecializationInfo();
   assert(SpecInfo && "Function template specialization info missing?");
 
   // Note: do not overwrite location info if previous template
@@ -9729,11 +9693,9 @@ bool Sema::CheckFunctionTemplateSpecialization(
   bool isFriend = (FD->getFriendObjectKind() != Decl::FOK_None);
 
   // Check the scope of this explicit specialization.
-  if (!isFriend &&
-      CheckTemplateSpecializationScope(*this,
-                                       Specialization->getPrimaryTemplate(),
-                                       Specialization, FD->getLocation(),
-                                       false))
+  if (!isFriend && CheckTemplateSpecializationScope(
+                       *this, Specialization->getPrimaryTemplate(),
+                       Specialization, FD->getLocation(), false))
     return true;
 
   // C++ [temp.expl.spec]p6:
@@ -9744,12 +9706,10 @@ bool Sema::CheckFunctionTemplateSpecialization(
   //   use occurs; no diagnostic is required.
   bool HasNoEffect = false;
   if (!isFriend &&
-      CheckSpecializationInstantiationRedecl(FD->getLocation(),
-                                             TSK_ExplicitSpecialization,
-                                             Specialization,
-                                   SpecInfo->getTemplateSpecializationKind(),
-                                         SpecInfo->getPointOfInstantiation(),
-                                             HasNoEffect))
+      CheckSpecializationInstantiationRedecl(
+          FD->getLocation(), TSK_ExplicitSpecialization, Specialization,
+          SpecInfo->getTemplateSpecializationKind(),
+          SpecInfo->getPointOfInstantiation(), HasNoEffect))
     return true;
 
   // Mark the prior declaration as an explicit specialization, so that later
@@ -9806,8 +9766,8 @@ bool Sema::CheckFunctionTemplateSpecialization(
   return false;
 }
 
-bool
-Sema::CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous) {
+bool Sema::CheckMemberSpecialization(NamedDecl *Member,
+                                     LookupResult &Previous) {
   assert(!Member->isTemplateDecl() && !Member->getDescribedTemplate() &&
          "Only for non-template members");
 
@@ -9941,12 +9901,12 @@ Sema::CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous) {
     // Preserve instantiation information.
     if (InstantiatedFrom && isa<CXXMethodDecl>(Member)) {
       cast<CXXMethodDecl>(Member)->setInstantiationOfMemberFunction(
-                                      cast<CXXMethodDecl>(InstantiatedFrom),
-        cast<CXXMethodDecl>(Instantiation)->getTemplateSpecializationKind());
+          cast<CXXMethodDecl>(InstantiatedFrom),
+          cast<CXXMethodDecl>(Instantiation)->getTemplateSpecializationKind());
     } else if (InstantiatedFrom && isa<CXXRecordDecl>(Member)) {
       cast<CXXRecordDecl>(Member)->setInstantiationOfMemberClass(
-                                      cast<CXXRecordDecl>(InstantiatedFrom),
-        cast<CXXRecordDecl>(Instantiation)->getTemplateSpecializationKind());
+          cast<CXXRecordDecl>(InstantiatedFrom),
+          cast<CXXRecordDecl>(Instantiation)->getTemplateSpecializationKind());
     }
 
     Previous.clear();
@@ -9957,7 +9917,7 @@ Sema::CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous) {
   // Make sure that this is a specialization of a member.
   if (!InstantiatedFrom) {
     Diag(Member->getLocation(), diag::err_spec_member_not_instantiated)
-      << Member;
+        << Member;
     Diag(Instantiation->getLocation(), diag::note_specialized_decl);
     return true;
   }
@@ -9971,19 +9931,15 @@ Sema::CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous) {
   assert(MSInfo && "Member specialization info missing?");
 
   bool HasNoEffect = false;
-  if (CheckSpecializationInstantiationRedecl(Member->getLocation(),
-                                             TSK_ExplicitSpecialization,
-                                             Instantiation,
-                                     MSInfo->getTemplateSpecializationKind(),
-                                           MSInfo->getPointOfInstantiation(),
-                                             HasNoEffect))
+  if (CheckSpecializationInstantiationRedecl(
+          Member->getLocation(), TSK_ExplicitSpecialization, Instantiation,
+          MSInfo->getTemplateSpecializationKind(),
+          MSInfo->getPointOfInstantiation(), HasNoEffect))
     return true;
 
   // Check the scope of this explicit specialization.
-  if (CheckTemplateSpecializationScope(*this,
-                                       InstantiatedFrom,
-                                       Instantiation, Member->getLocation(),
-                                       false))
+  if (CheckTemplateSpecializationScope(*this, InstantiatedFrom, Instantiation,
+                                       Member->getLocation(), false))
     return true;
 
   // Note that this member specialization is an "instantiation of" the
@@ -9991,7 +9947,7 @@ Sema::CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous) {
   if (auto *MemberFunction = dyn_cast<FunctionDecl>(Member)) {
     FunctionDecl *InstantiationFunction = cast<FunctionDecl>(Instantiation);
     if (InstantiationFunction->getTemplateSpecializationKind() ==
-          TSK_ImplicitInstantiation) {
+        TSK_ImplicitInstantiation) {
       // Explicit specializations of member functions of class templates do not
       // inherit '=delete' from the member function they are specializing.
       if (InstantiationFunction->isDeleted()) {
@@ -10012,8 +9968,8 @@ Sema::CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous) {
     MemberClass->setInstantiationOfMemberClass(
         cast<CXXRecordDecl>(InstantiatedFrom), TSK_ExplicitSpecialization);
   } else if (auto *MemberEnum = dyn_cast<EnumDecl>(Member)) {
-    MemberEnum->setInstantiationOfMemberEnum(
-        cast<EnumDecl>(InstantiatedFrom), TSK_ExplicitSpecialization);
+    MemberEnum->setInstantiationOfMemberEnum(cast<EnumDecl>(InstantiatedFrom),
+                                             TSK_ExplicitSpecialization);
   } else {
     llvm_unreachable("unknown member specialization kind");
   }
@@ -10030,7 +9986,7 @@ Sema::CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous) {
 ///
 /// \param OrigD The member declaration instantiated from the template.
 /// \param Loc The location of the explicit specialization of the member.
-template<typename DeclT>
+template <typename DeclT>
 static void completeMemberSpecializationImpl(Sema &S, DeclT *OrigD,
                                              SourceLocation Loc) {
   if (OrigD->getTemplateSpecializationKind() != TSK_ImplicitInstantiation)
@@ -10068,12 +10024,12 @@ void Sema::CompleteMemberSpecialization(NamedDecl *Member,
 static bool CheckExplicitInstantiationScope(Sema &S, NamedDecl *D,
                                             SourceLocation InstLoc,
                                             bool WasQualifiedName) {
-  DeclContext *OrigContext= D->getDeclContext()->getEnclosingNamespaceContext();
+  DeclContext *OrigContext =
+      D->getDeclContext()->getEnclosingNamespaceContext();
   DeclContext *CurContext = S.CurContext->getRedeclContext();
 
   if (CurContext->isRecord()) {
-    S.Diag(InstLoc, diag::err_explicit_instantiation_in_class)
-      << D;
+    S.Diag(InstLoc, diag::err_explicit_instantiation_in_class) << D;
     return true;
   }
 
@@ -10095,23 +10051,23 @@ static bool CheckExplicitInstantiationScope(Sema &S, NamedDecl *D,
 
   if (NamespaceDecl *NS = dyn_cast<NamespaceDecl>(OrigContext)) {
     if (WasQualifiedName)
-      S.Diag(InstLoc,
-             S.getLangOpts().CPlusPlus11?
-               diag::err_explicit_instantiation_out_of_scope :
-               diag::warn_explicit_instantiation_out_of_scope_0x)
-        << D << NS;
+      S.Diag(InstLoc, S.getLangOpts().CPlusPlus11
+                          ? diag::err_explicit_instantiation_out_of_scope
+                          : diag::warn_explicit_instantiation_out_of_scope_0x)
+          << D << NS;
     else
-      S.Diag(InstLoc,
-             S.getLangOpts().CPlusPlus11?
-               diag::err_explicit_instantiation_unqualified_wrong_namespace :
-               diag::warn_explicit_instantiation_unqualified_wrong_namespace_0x)
-        << D << NS;
+      S.Diag(
+          InstLoc,
+          S.getLangOpts().CPlusPlus11
+              ? diag::err_explicit_instantiation_unqualified_wrong_namespace
+              : diag::
+                    warn_explicit_instantiation_unqualified_wrong_namespace_0x)
+          << D << NS;
   } else
-    S.Diag(InstLoc,
-           S.getLangOpts().CPlusPlus11?
-             diag::err_explicit_instantiation_must_be_global :
-             diag::warn_explicit_instantiation_must_be_global_0x)
-      << D;
+    S.Diag(InstLoc, S.getLangOpts().CPlusPlus11
+                        ? diag::err_explicit_instantiation_must_be_global
+                        : diag::warn_explicit_instantiation_must_be_global_0x)
+        << D;
   S.Diag(D->getLocation(), diag::note_explicit_instantiation_here);
   return false;
 }
@@ -10207,13 +10163,13 @@ DeclResult Sema::ActOnExplicitInstantiation(
     return true;
   }
 
-  if (!isAcceptableTagRedeclaration(ClassTemplate->getTemplatedDecl(),
-                                    Kind, /*isDefinition*/false, KWLoc,
+  if (!isAcceptableTagRedeclaration(ClassTemplate->getTemplatedDecl(), Kind,
+                                    /*isDefinition*/ false, KWLoc,
                                     ClassTemplate->getIdentifier())) {
     Diag(KWLoc, diag::err_use_with_wrong_tag)
-      << ClassTemplate
-      << FixItHint::CreateReplacement(KWLoc,
-                            ClassTemplate->getTemplatedDecl()->getKindName());
+        << ClassTemplate
+        << FixItHint::CreateReplacement(
+               KWLoc, ClassTemplate->getTemplatedDecl()->getKindName());
     Diag(ClassTemplate->getTemplatedDecl()->getLocation(),
          diag::note_previous_use);
     Kind = ClassTemplate->getTemplatedDecl()->getTagKind();
@@ -10289,8 +10245,8 @@ DeclResult Sema::ActOnExplicitInstantiation(
   ClassTemplateSpecializationDecl *PrevDecl =
       ClassTemplate->findSpecialization(CTAI.CanonicalConverted, InsertPos);
 
-  TemplateSpecializationKind PrevDecl_TSK
-    = PrevDecl ? PrevDecl->getTemplateSpecializationKind() : TSK_Undeclared;
+  TemplateSpecializationKind PrevDecl_TSK =
+      PrevDecl ? PrevDecl->getTemplateSpecializationKind() : TSK_Undeclared;
 
   if (TSK == TSK_ExplicitInstantiationDefinition && PrevDecl != nullptr &&
       Context.getTargetInfo().getTriple().isOSCygMing()) {
@@ -10329,10 +10285,9 @@ DeclResult Sema::ActOnExplicitInstantiation(
 
   bool HasNoEffect = false;
   if (PrevDecl) {
-    if (CheckSpecializationInstantiationRedecl(TemplateNameLoc, TSK,
-                                               PrevDecl, PrevDecl_TSK,
-                                            PrevDecl->getPointOfInstantiation(),
-                                               HasNoEffect))
+    if (CheckSpecializationInstantiationRedecl(
+            TemplateNameLoc, TSK, PrevDecl, PrevDecl_TSK,
+            PrevDecl->getPointOfInstantiation(), HasNoEffect))
       return PrevDecl;
 
     // Even though HasNoEffect == true means that this explicit instantiation
@@ -10413,9 +10368,9 @@ DeclResult Sema::ActOnExplicitInstantiation(
   //
   // This check comes when we actually try to perform the
   // instantiation.
-  ClassTemplateSpecializationDecl *Def
-    = cast_or_null<ClassTemplateSpecializationDecl>(
-                                              Specialization->getDefinition());
+  ClassTemplateSpecializationDecl *Def =
+      cast_or_null<ClassTemplateSpecializationDecl>(
+          Specialization->getDefinition());
   if (!Def)
     InstantiateClassTemplateSpecialization(TemplateNameLoc, Specialization, TSK,
                                            /*Complain=*/true,
@@ -10427,7 +10382,7 @@ DeclResult Sema::ActOnExplicitInstantiation(
 
   // Instantiate the members of this class template specialization.
   Def = cast_or_null<ClassTemplateSpecializationDecl>(
-                                       Specialization->getDefinition());
+      Specialization->getDefinition());
   if (Def) {
     TemplateSpecializationKind Old_TSK = Def->getTemplateSpecializationKind();
     // Fix a TSK_ExplicitInstantiationDeclaration followed by a
@@ -10511,7 +10466,8 @@ Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
                false, TypeResult(), /*IsTypeSpecifier*/ false,
                /*IsTemplateParamOrArg*/ false, /*OOK=*/OffsetOfKind::Outside)
           .get();
-  assert(!IsDependent && "explicit instantiation of dependent name not yet handled");
+  assert(!IsDependent &&
+         "explicit instantiation of dependent name not yet handled");
 
   if (!TagD)
     return true;
@@ -10539,55 +10495,50 @@ Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
   // C++98 has the same restriction, just worded differently.
   if (!ScopeSpecifierHasTemplateId(SS))
     Diag(TemplateLoc, diag::ext_explicit_instantiation_without_qualified_id)
-      << Record << SS.getRange();
+        << Record << SS.getRange();
 
   // C++0x [temp.explicit]p2:
   //   There are two forms of explicit instantiation: an explicit instantiation
   //   definition and an explicit instantiation declaration. An explicit
   //   instantiation declaration begins with the extern keyword. [...]
-  TemplateSpecializationKind TSK
-    = ExternLoc.isInvalid()? TSK_ExplicitInstantiationDefinition
-                           : TSK_ExplicitInstantiationDeclaration;
+  TemplateSpecializationKind TSK = ExternLoc.isInvalid()
+                                       ? TSK_ExplicitInstantiationDefinition
+                                       : TSK_ExplicitInstantiationDeclaration;
 
   CheckExplicitInstantiation(*this, Record, NameLoc, true, TSK);
 
   // Verify that it is okay to explicitly instantiate here.
-  CXXRecordDecl *PrevDecl
-    = cast_or_null<CXXRecordDecl>(Record->getPreviousDecl());
+  CXXRecordDecl *PrevDecl =
+      cast_or_null<CXXRecordDecl>(Record->getPreviousDecl());
   if (!PrevDecl && Record->getDefinition())
     PrevDecl = Record;
   if (PrevDecl) {
     MemberSpecializationInfo *MSInfo = PrevDecl->getMemberSpecializationInfo();
     bool HasNoEffect = false;
     assert(MSInfo && "No member specialization information?");
-    if (CheckSpecializationInstantiationRedecl(TemplateLoc, TSK,
-                                               PrevDecl,
-                                        MSInfo->getTemplateSpecializationKind(),
-                                             MSInfo->getPointOfInstantiation(),
-                                               HasNoEffect))
+    if (CheckSpecializationInstantiationRedecl(
+            TemplateLoc, TSK, PrevDecl, MSInfo->getTemplateSpecializationKind(),
+            MSInfo->getPointOfInstantiation(), HasNoEffect))
       return true;
     if (HasNoEffect)
       return TagD;
   }
 
-  CXXRecordDecl *RecordDef
-    = cast_or_null<CXXRecordDecl>(Record->getDefinition());
+  CXXRecordDecl *RecordDef =
+      cast_or_null<CXXRecordDecl>(Record->getDefinition());
   if (!RecordDef) {
     // C++ [temp.explicit]p3:
     //   A definition of a member class of a class template shall be in scope
     //   at the point of an explicit instantiation of the member class.
-    CXXRecordDecl *Def
-      = cast_or_null<CXXRecordDecl>(Pattern->getDefinition());
+    CXXRecordDecl *Def = cast_or_null<CXXRecordDecl>(Pattern->getDefinition());
     if (!Def) {
       Diag(TemplateLoc, diag::err_explicit_instantiation_undefined_member)
-        << 0 << Record->getDeclName() << Record->getDeclContext();
-      Diag(Pattern->getLocation(), diag::note_forward_declaration)
-        << Pattern;
+          << 0 << Record->getDeclName() << Record->getDeclContext();
+      Diag(Pattern->getLocation(), diag::note_forward_declaration) << Pattern;
       return true;
     } else {
       if (InstantiateClass(NameLoc, Record, Def,
-                           getTemplateInstantiationArgs(Record),
-                           TSK))
+                           getTemplateInstantiationArgs(Record), TSK))
         return true;
 
       RecordDef = cast_or_null<CXXRecordDecl>(Record->getDefinition());
@@ -10610,8 +10561,7 @@ Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
   return TagD;
 }
 
-DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
-                                            SourceLocation ExternLoc,
+DeclResult Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
                                             SourceLocation TemplateLoc,
                                             Declarator &D) {
   // Explicit instantiations always require a name.
@@ -10641,13 +10591,13 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
   //   instantiation (14.7.2) directive.
   if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef) {
     Diag(D.getIdentifierLoc(), diag::err_explicit_instantiation_of_typedef)
-      << Name;
+        << Name;
     return true;
-  } else if (D.getDeclSpec().getStorageClassSpec()
-                                                != DeclSpec::SCS_unspecified) {
+  } else if (D.getDeclSpec().getStorageClassSpec() !=
+             DeclSpec::SCS_unspecified) {
     // Complain about then remove the storage class specifier.
     Diag(D.getIdentifierLoc(), diag::err_explicit_instantiation_storage_class)
-      << FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc());
+        << FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc());
 
     D.getMutableDeclSpec().ClearStorageClassSpecs();
   }
@@ -10659,10 +10609,10 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
   // well.
   if (D.getDeclSpec().isInlineSpecified())
     Diag(D.getDeclSpec().getInlineSpecLoc(),
-         getLangOpts().CPlusPlus11 ?
-           diag::err_explicit_instantiation_inline :
-           diag::warn_explicit_instantiation_inline_0x)
-      << FixItHint::CreateRemoval(D.getDeclSpec().getInlineSpecLoc());
+         getLangOpts().CPlusPlus11
+             ? diag::err_explicit_instantiation_inline
+             : diag::warn_explicit_instantiation_inline_0x)
+        << FixItHint::CreateRemoval(D.getDeclSpec().getInlineSpecLoc());
   if (D.getDeclSpec().hasConstexprSpecifier() && R->isFunctionType())
     // FIXME: Add a fix-it to remove the 'constexpr' and add a 'const' if one is
     // not already specified.
@@ -10681,9 +10631,9 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
   //   There are two forms of explicit instantiation: an explicit instantiation
   //   definition and an explicit instantiation declaration. An explicit
   //   instantiation declaration begins with the extern keyword. [...]
-  TemplateSpecializationKind TSK
-    = ExternLoc.isInvalid()? TSK_ExplicitInstantiationDefinition
-                           : TSK_ExplicitInstantiationDeclaration;
+  TemplateSpecializationKind TSK = ExternLoc.isInvalid()
+                                       ? TSK_ExplicitInstantiationDefinition
+                                       : TSK_ExplicitInstantiationDeclaration;
 
   LookupResult Previous(*this, NameInfo, LookupOrdinaryName);
   LookupParsedName(Previous, S, &D.getCXXScopeSpec(),
@@ -10743,7 +10693,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
         //   in the declaration shall be a template-id.
         Diag(D.getIdentifierLoc(),
              diag::err_explicit_instantiation_without_template_id)
-          << PrevTemplate;
+            << PrevTemplate;
         Diag(PrevTemplate->getLocation(),
              diag::note_explicit_instantiation_here);
         return true;
@@ -10785,7 +10735,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
     if (!ScopeSpecifierHasTemplateId(D.getCXXScopeSpec()) && !PrevTemplate)
       Diag(D.getIdentifierLoc(),
            diag::ext_explicit_instantiation_without_qualified_id)
-        << Prev << D.getCXXScopeSpec().getRange();
+          << Prev << D.getCXXScopeSpec().getRange();
 
     CheckExplicitInstantiation(*this, Prev, D.getIdentifierLoc(), true, TSK);
 
@@ -10825,7 +10775,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
     }
 
     // FIXME: Create an ExplicitInstantiation node?
-    return (Decl*) nullptr;
+    return (Decl *)nullptr;
   }
 
   // If the declarator is a template-id, translate the parser's template
@@ -10852,7 +10802,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
     if (!HasExplicitTemplateArgs) {
       if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Prev)) {
         QualType Adjusted = adjustCCAndNoReturn(R, Method->getType(),
-                                                /*AdjustExceptionSpec*/true);
+                                                /*AdjustExceptionSpec*/ true);
         if (Context.hasSameUnqualifiedType(Method->getType(), Adjusted)) {
           if (Method->getPrimaryTemplate()) {
             TemplateMatches.addDecl(Method, P.getAccess());
@@ -10952,7 +10902,8 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
     if (Result == TemplateMatches.end())
       return true;
 
-    // Ignore access control bits, we don't need them for redeclaration checking.
+    // Ignore access control bits, we don't need them for redeclaration
+    // checking.
     Specialization = cast<FunctionDecl>(*Result);
   }
 
@@ -10982,9 +10933,9 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
   if (Specialization->getTemplateSpecializationKind() == TSK_Undeclared) {
     Diag(D.getIdentifierLoc(),
          diag::err_explicit_instantiation_member_function_not_instantiated)
-      << Specialization
-      << (Specialization->getTemplateSpecializationKind() ==
-          TSK_ExplicitSpecialization);
+        << Specialization
+        << (Specialization->getTemplateSpecializationKind() ==
+            TSK_ExplicitSpecialization);
     Diag(Specialization->getLocation(), diag::note_explicit_instantiation_here);
     return true;
   }
@@ -10995,17 +10946,16 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
 
   if (PrevDecl) {
     bool HasNoEffect = false;
-    if (CheckSpecializationInstantiationRedecl(D.getIdentifierLoc(), TSK,
-                                               PrevDecl,
-                                     PrevDecl->getTemplateSpecializationKind(),
-                                          PrevDecl->getPointOfInstantiation(),
-                                               HasNoEffect))
+    if (CheckSpecializationInstantiationRedecl(
+            D.getIdentifierLoc(), TSK, PrevDecl,
+            PrevDecl->getTemplateSpecializationKind(),
+            PrevDecl->getPointOfInstantiation(), HasNoEffect))
       return true;
 
     // FIXME: We may still want to build some representation of this
     // explicit specialization.
     if (HasNoEffect)
-      return (Decl*) nullptr;
+      return (Decl *)nullptr;
   }
 
   // HACK: libc++ has a bug where it attempts to explicitly instantiate the
@@ -11019,7 +10969,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
     if (auto *RD = dyn_cast<CXXRecordDecl>(Specialization->getDeclContext()))
       if (RD->getIdentifier() && RD->getIdentifier()->isStr("valarray") &&
           RD->isInStdNamespace())
-        return (Decl*) nullptr;
+        return (Decl *)nullptr;
   }
 
   ProcessDeclAttributeList(S, Specialization, D.getDeclSpec().getAttributes());
@@ -11054,7 +11004,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
       !ScopeSpecifierHasTemplateId(D.getCXXScopeSpec()))
     Diag(D.getIdentifierLoc(),
          diag::ext_explicit_instantiation_without_qualified_id)
-    << Specialization << D.getCXXScopeSpec().getRange();
+        << Specialization << D.getCXXScopeSpec().getRange();
 
   CheckExplicitInstantiation(
       *this,
@@ -11063,7 +11013,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
       D.getIdentifierLoc(), D.getCXXScopeSpec().isSet(), TSK);
 
   // FIXME: Create some kind of ExplicitInstantiationDecl here.
-  return (Decl*) nullptr;
+  return (Decl *)nullptr;
 }
 
 TypeResult Sema::ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
@@ -11144,8 +11094,9 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
     if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
       Diag(TemplateIILoc,
            diag::ext_out_of_line_qualified_id_type_names_constructor)
-        << TemplateII << 0 /*injected-class-name used as template name*/
-        << (TemplateKWLoc.isValid() ? 1 : 0 /*'template'/'typename' keyword*/);
+          << TemplateII << 0 /*injected-class-name used as template name*/
+          << (TemplateKWLoc.isValid() ? 1
+                                      : 0 /*'template'/'typename' keyword*/);
     }
   }
 
@@ -11163,8 +11114,8 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
 
   // Provide source-location information for the template specialization type.
   TypeLocBuilder Builder;
-  TemplateSpecializationTypeLoc SpecTL
-    = Builder.push<TemplateSpecializationTypeLoc>(T);
+  TemplateSpecializationTypeLoc SpecTL =
+      Builder.push<TemplateSpecializationTypeLoc>(T);
   SpecTL.set(TypenameLoc, SS.getWithLocInContext(Context), TemplateKWLoc,
              TemplateIILoc, TemplateArgs);
   TypeSourceInfo *TSI = Builder.getTypeSourceInfo(Context, T);
@@ -11192,13 +11143,13 @@ static bool isEnableIf(NestedNameSpecifierLoc NNS, const IdentifierInfo &II,
 
   // ... which names a complete class template declaration...
   const TemplateDecl *EnableIfDecl =
-    EnableIfTST->getTemplateName().getAsTemplateDecl();
+      EnableIfTST->getTemplateName().getAsTemplateDecl();
   if (!EnableIfDecl || EnableIfTST->isIncompleteType())
     return false;
 
   // ... called "enable_if".
   const IdentifierInfo *EnableIfII =
-    EnableIfDecl->getDeclName().getAsIdentifierInfo();
+      EnableIfDecl->getDeclName().getAsIdentifierInfo();
   if (!EnableIfII || !EnableIfII->isStr("enable_if"))
     return false;
 
@@ -11207,8 +11158,8 @@ static bool isEnableIf(NestedNameSpecifierLoc NNS, const IdentifierInfo &II,
 
   // Dig out the condition.
   Cond = nullptr;
-  if (EnableIfTSTLoc.getArgLoc(0).getArgument().getKind()
-        != TemplateArgument::Expression)
+  if (EnableIfTSTLoc.getArgLoc(0).getArgument().getKind() !=
+      TemplateArgument::Expression)
     return true;
 
   Cond = EnableIfTSTLoc.getArgLoc(0).getSourceExpression();
@@ -11220,14 +11171,11 @@ static bool isEnableIf(NestedNameSpecifierLoc NNS, const IdentifierInfo &II,
   return true;
 }
 
-QualType
-Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
-                        SourceLocation KeywordLoc,
-                        NestedNameSpecifierLoc QualifierLoc,
-                        const IdentifierInfo &II,
-                        SourceLocation IILoc,
-                        TypeSourceInfo **TSI,
-                        bool DeducedTSTContext) {
+QualType Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
+                                 SourceLocation KeywordLoc,
+                                 NestedNameSpecifierLoc QualifierLoc,
+                                 const IdentifierInfo &II, SourceLocation IILoc,
+                                 TypeSourceInfo **TSI, bool DeducedTSTContext) {
   QualType T = CheckTypenameType(Keyword, KeywordLoc, QualifierLoc, II, IILoc,
                                  DeducedTSTContext);
   if (T.isNull())
@@ -11265,12 +11213,11 @@ Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
 
 /// Build the type that describes a C++ typename specifier,
 /// e.g., "typename T::type".
-QualType
-Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
-                        SourceLocation KeywordLoc,
-                        NestedNameSpecifierLoc QualifierLoc,
-                        const IdentifierInfo &II,
-                        SourceLocation IILoc, bool DeducedTSTContext) {
+QualType Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
+                                 SourceLocation KeywordLoc,
+                                 NestedNameSpecifierLoc QualifierLoc,
+                                 const IdentifierInfo &II, SourceLocation IILoc,
+                                 bool DeducedTSTContext) {
   assert((Keyword != ElaboratedTypeKeyword::None) == KeywordLoc.isValid());
 
   CXXScopeSpec SS;
@@ -11283,9 +11230,8 @@ Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
       // If the nested-name-specifier is dependent and couldn't be
       // resolved to a type, build a typename type.
       assert(QualifierLoc.getNestedNameSpecifier().isDependent());
-      return Context.getDependentNameType(Keyword,
-                                          QualifierLoc.getNestedNameSpecifier(),
-                                          &II);
+      return Context.getDependentNameType(
+          Keyword, QualifierLoc.getNestedNameSpecifier(), &II);
     }
 
     // If the nested-name-specifier refers to the current instantiation,
@@ -11319,23 +11265,21 @@ Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
         Expr *FailedCond;
         std::string FailedDescription;
         std::tie(FailedCond, FailedDescription) =
-          findFailedBooleanCondition(Cond);
+            findFailedBooleanCondition(Cond);
 
         Diag(FailedCond->getExprLoc(),
              diag::err_typename_nested_not_found_requirement)
-          << FailedDescription
-          << FailedCond->getSourceRange();
+            << FailedDescription << FailedCond->getSourceRange();
         return QualType();
       }
 
-      Diag(CondRange.getBegin(),
-           diag::err_typename_nested_not_found_enable_if)
+      Diag(CondRange.getBegin(), diag::err_typename_nested_not_found_enable_if)
           << Ctx << CondRange;
       return QualType();
     }
 
-    DiagID = Ctx ? diag::err_typename_nested_not_found
-                 : diag::err_unknown_typename;
+    DiagID =
+        Ctx ? diag::err_typename_nested_not_found : diag::err_unknown_typename;
     break;
   }
 
@@ -11345,12 +11289,12 @@ Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
     SourceRange FullRange(KeywordLoc.isValid() ? KeywordLoc : SS.getBeginLoc(),
                           IILoc);
     Diag(IILoc, diag::err_typename_refers_to_using_value_decl)
-      << Name << Ctx << FullRange;
-    if (UnresolvedUsingValueDecl *Using
-          = dyn_cast<UnresolvedUsingValueDecl>(Result.getRepresentativeDecl())){
+        << Name << Ctx << FullRange;
+    if (UnresolvedUsingValueDecl *Using = dyn_cast<UnresolvedUsingValueDecl>(
+            Result.getRepresentativeDecl())) {
       SourceLocation Loc = Using->getQualifierLoc().getBeginLoc();
       Diag(Loc, diag::note_using_value_decl_missing_typename)
-        << FixItHint::CreateInsertion(Loc, "typename ");
+          << FixItHint::CreateInsertion(Loc, "typename ");
     }
   }
     // Fall through to create a dependent typename type, from which we can
@@ -11359,9 +11303,8 @@ Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
 
   case LookupResultKind::NotFoundInCurrentInstantiation:
     // Okay, it's a member of an unknown instantiation.
-    return Context.getDependentNameType(Keyword,
-                                        QualifierLoc.getNestedNameSpecifier(),
-                                        &II);
+    return Context.getDependentNameType(
+        Keyword, QualifierLoc.getNestedNameSpecifier(), &II);
 
   case LookupResultKind::Found:
     // FXIME: Missing support for UsingShadowDecl on this path?
@@ -11410,7 +11353,7 @@ Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
                 << QualType(Qualifier.getAsType(), 0);
           else
             Diag(IILoc, diag::err_deduced_tst)
-              << (int)getTemplateNameKindForDiagnostics(TemplateName(TD));
+                << (int)getTemplateNameKindForDiagnostics(TemplateName(TD));
           NoteTemplateLocation(*TD);
           return QualType();
         }
@@ -11423,14 +11366,14 @@ Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
       }
     }
 
-    DiagID = Ctx ? diag::err_typename_nested_not_type
-                 : diag::err_typename_not_type;
+    DiagID =
+        Ctx ? diag::err_typename_nested_not_type : diag::err_typename_not_type;
     Referenced = Result.getFoundDecl();
     break;
 
   case LookupResultKind::FoundOverloaded:
-    DiagID = Ctx ? diag::err_typename_nested_not_type
-                 : diag::err_typename_not_type;
+    DiagID =
+        Ctx ? diag::err_typename_nested_not_type : diag::err_typename_not_type;
     Referenced = *Result.begin();
     break;
 
@@ -11447,57 +11390,55 @@ Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
   else
     Diag(IILoc, DiagID) << FullRange << Name;
   if (Referenced)
-    Diag(Referenced->getLocation(),
-         Ctx ? diag::note_typename_member_refers_here
-             : diag::note_typename_refers_here)
-      << Name;
+    Diag(Referenced->getLocation(), Ctx ? diag::note_typename_member_refers_here
+                                        : diag::note_typename_refers_here)
+        << Name;
   return QualType();
 }
 
 namespace {
-  // See Sema::RebuildTypeInCurrentInstantiation
-  class CurrentInstantiationRebuilder
+// See Sema::RebuildTypeInCurrentInstantiation
+class CurrentInstantiationRebuilder
     : public TreeTransform<CurrentInstantiationRebuilder> {
-    SourceLocation Loc;
-    DeclarationName Entity;
+  SourceLocation Loc;
+  DeclarationName Entity;
 
-  public:
-    typedef TreeTransform<CurrentInstantiationRebuilder> inherited;
+public:
+  typedef TreeTransform<CurrentInstantiationRebuilder> inherited;
 
-    CurrentInstantiationRebuilder(Sema &SemaRef,
-                                  SourceLocation Loc,
-                                  DeclarationName Entity)
-    : TreeTransform<CurrentInstantiationRebuilder>(SemaRef),
-      Loc(Loc), Entity(Entity) { }
+  CurrentInstantiationRebuilder(Sema &SemaRef, SourceLocation Loc,
+                                DeclarationName Entity)
+      : TreeTransform<CurrentInstantiationRebuilder>(SemaRef), Loc(Loc),
+        Entity(Entity) {}
 
-    /// Determine whether the given type \p T has already been
-    /// transformed.
-    ///
-    /// For the purposes of type reconstruction, a type has already been
-    /// transformed if it is NULL or if it is not dependent.
-    bool AlreadyTransformed(QualType T) {
-      return T.isNull() || !T->isInstantiationDependentType();
-    }
+  /// Determine whether the given type \p T has already been
+  /// transformed.
+  ///
+  /// For the purposes of type reconstruction, a type has already been
+  /// transformed if it is NULL or if it is not dependent.
+  bool AlreadyTransformed(QualType T) {
+    return T.isNull() || !T->isInstantiationDependentType();
+  }
 
-    /// Returns the location of the entity whose type is being
-    /// rebuilt.
-    SourceLocation getBaseLocation() { return Loc; }
+  /// Returns the location of the entity whose type is being
+  /// rebuilt.
+  SourceLocation getBaseLocation() { return Loc; }
 
-    /// Returns the name of the entity whose type is being rebuilt.
-    DeclarationName getBaseEntity() { return Entity; }
+  /// Returns the name of the entity whose type is being rebuilt.
+  DeclarationName getBaseEntity() { return Entity; }
 
-    /// Sets the "base" location and entity when that
-    /// information is known based on another transformation.
-    void setBase(SourceLocation Loc, DeclarationName Entity) {
-      this->Loc = Loc;
-      this->Entity = Entity;
-    }
+  /// Sets the "base" location and entity when that
+  /// information is known based on another transformation.
+  void setBase(SourceLocation Loc, DeclarationName Entity) {
+    this->Loc = Loc;
+    this->Entity = Entity;
+  }
 
-    ExprResult TransformLambdaExpr(LambdaExpr *E) {
-      // Lambdas never need to be transformed.
-      return E;
-    }
-  };
+  ExprResult TransformLambdaExpr(LambdaExpr *E) {
+    // Lambdas never need to be transformed.
+    return E;
+  }
+};
 } // end anonymous namespace
 
 TypeSourceInfo *Sema::RebuildTypeInCurrentInstantiation(TypeSourceInfo *T,
@@ -11523,8 +11464,8 @@ bool Sema::RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS) {
   NestedNameSpecifierLoc QualifierLoc = SS.getWithLocInContext(Context);
   CurrentInstantiationRebuilder Rebuilder(*this, SS.getRange().getBegin(),
                                           DeclarationName());
-  NestedNameSpecifierLoc Rebuilt
-    = Rebuilder.TransformNestedNameSpecifierLoc(QualifierLoc);
+  NestedNameSpecifierLoc Rebuilt =
+      Rebuilder.TransformNestedNameSpecifierLoc(QualifierLoc);
   if (!Rebuilt)
     return true;
 
@@ -11533,7 +11474,7 @@ bool Sema::RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS) {
 }
 
 bool Sema::RebuildTemplateParamsInCurrentInstantiation(
-                                               TemplateParameterList *Params) {
+    TemplateParameterList *Params) {
   for (unsigned I = 0, N = Params->size(); I != N; ++I) {
     Decl *Param = Params->getParam(I);
 
@@ -11542,10 +11483,10 @@ bool Sema::RebuildTemplateParamsInCurrentInstantiation(
       continue;
 
     // Rebuild the template parameter list of a template template parameter.
-    if (TemplateTemplateParmDecl *TTP
-        = dyn_cast<TemplateTemplateParmDecl>(Param)) {
+    if (TemplateTemplateParmDecl *TTP =
+            dyn_cast<TemplateTemplateParmDecl>(Param)) {
       if (RebuildTemplateParamsInCurrentInstantiation(
-            TTP->getTemplateParameters()))
+              TTP->getTemplateParameters()))
         return true;
 
       continue;
@@ -11553,10 +11494,8 @@ bool Sema::RebuildTemplateParamsInCurrentInstantiation(
 
     // Rebuild the type of a non-type template parameter.
     NonTypeTemplateParmDecl *NTTP = cast<NonTypeTemplateParmDecl>(Param);
-    TypeSourceInfo *NewTSI
-      = RebuildTypeInCurrentInstantiation(NTTP->getTypeSourceInfo(),
-                                          NTTP->getLocation(),
-                                          NTTP->getDeclName());
+    TypeSourceInfo *NewTSI = RebuildTypeInCurrentInstantiation(
+        NTTP->getTypeSourceInfo(), NTTP->getLocation(), NTTP->getDeclName());
     if (!NewTSI)
       return true;
 
@@ -11740,8 +11679,7 @@ class ExplicitSpecializationVisibilityChecker {
   // We don't need to go any deeper than that, as the instantiation of the
   // surrounding class / etc is not triggered by whatever triggered this
   // instantiation, and thus should be checked elsewhere.
-  template<typename SpecDecl>
-  void checkImpl(SpecDecl *Spec) {
+  template <typename SpecDecl> void checkImpl(SpecDecl *Spec) {
     bool IsHiddenExplicitSpecialization = false;
     TemplateSpecializationKind SpecKind = Spec->getTemplateSpecializationKind();
     // Some invalid friend declarations are written as specializations but are
@@ -11799,8 +11737,7 @@ class ExplicitSpecializationVisibilityChecker {
 
   void checkInstantiated(EnumDecl *FD) {}
 
-  template<typename TemplDecl>
-  void checkTemplate(TemplDecl *TD) {
+  template <typename TemplDecl> void checkTemplate(TemplDecl *TD) {
     if (TD->isMemberSpecialization()) {
       if (!CheckMemberSpecialization(TD))
         diagnose(TD->getMostRecentDecl(), false);
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 34ed5dffa11b4..036b1578d6a3e 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -652,17 +652,16 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
 Sema::InstantiatingTemplate::InstantiatingTemplate(
     Sema &SemaRef, SourceLocation PointOfInstantiation, FunctionDecl *Entity,
     ExceptionSpecification, SourceRange InstantiationRange)
-    : InstantiatingTemplate(
-          SemaRef, CodeSynthesisContext::ExceptionSpecInstantiation,
-          PointOfInstantiation, InstantiationRange, Entity) {}
+    : InstantiatingTemplate(SemaRef,
+                            CodeSynthesisContext::ExceptionSpecInstantiation,
+                            PointOfInstantiation, InstantiationRange, Entity) {}
 
 Sema::InstantiatingTemplate::InstantiatingTemplate(
     Sema &SemaRef, SourceLocation PointOfInstantiation, TemplateParameter Param,
     TemplateDecl *Template, ArrayRef<TemplateArgument> TemplateArgs,
     SourceRange InstantiationRange)
     : InstantiatingTemplate(
-          SemaRef,
-          CodeSynthesisContext::DefaultTemplateArgumentInstantiation,
+          SemaRef, CodeSynthesisContext::DefaultTemplateArgumentInstantiation,
           PointOfInstantiation, InstantiationRange, getAsNamedDecl(Param),
           Template, TemplateArgs) {}
 
@@ -709,8 +708,7 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
     Sema &SemaRef, SourceLocation PointOfInstantiation, ParmVarDecl *Param,
     ArrayRef<TemplateArgument> TemplateArgs, SourceRange InstantiationRange)
     : InstantiatingTemplate(
-          SemaRef,
-          CodeSynthesisContext::DefaultFunctionArgumentInstantiation,
+          SemaRef, CodeSynthesisContext::DefaultFunctionArgumentInstantiation,
           PointOfInstantiation, InstantiationRange, Param, nullptr,
           TemplateArgs) {}
 
@@ -719,8 +717,7 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
     NonTypeTemplateParmDecl *Param, ArrayRef<TemplateArgument> TemplateArgs,
     SourceRange InstantiationRange)
     : InstantiatingTemplate(
-          SemaRef,
-          CodeSynthesisContext::PriorTemplateArgumentSubstitution,
+          SemaRef, CodeSynthesisContext::PriorTemplateArgumentSubstitution,
           PointOfInstantiation, InstantiationRange, Param, Template,
           TemplateArgs) {}
 
@@ -729,8 +726,7 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
     TemplateTemplateParmDecl *Param, ArrayRef<TemplateArgument> TemplateArgs,
     SourceRange InstantiationRange)
     : InstantiatingTemplate(
-          SemaRef,
-          CodeSynthesisContext::PriorTemplateArgumentSubstitution,
+          SemaRef, CodeSynthesisContext::PriorTemplateArgumentSubstitution,
           PointOfInstantiation, InstantiationRange, Param, Template,
           TemplateArgs) {}
 
@@ -778,13 +774,12 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
           /*Template=*/nullptr, /*TemplateArgs=*/{}) {}
 
 Sema::InstantiatingTemplate::InstantiatingTemplate(
-    Sema &SemaRef, SourceLocation PointOfInstantiation,
-    ConstraintsCheck, NamedDecl *Template,
-    ArrayRef<TemplateArgument> TemplateArgs, SourceRange InstantiationRange)
-    : InstantiatingTemplate(
-          SemaRef, CodeSynthesisContext::ConstraintsCheck,
-          PointOfInstantiation, InstantiationRange, Template, nullptr,
-          TemplateArgs) {}
+    Sema &SemaRef, SourceLocation PointOfInstantiation, ConstraintsCheck,
+    NamedDecl *Template, ArrayRef<TemplateArgument> TemplateArgs,
+    SourceRange InstantiationRange)
+    : InstantiatingTemplate(SemaRef, CodeSynthesisContext::ConstraintsCheck,
+                            PointOfInstantiation, InstantiationRange, Template,
+                            nullptr, TemplateArgs) {}
 
 Sema::InstantiatingTemplate::InstantiatingTemplate(
     Sema &SemaRef, SourceLocation PointOfInstantiation, ConstraintSubstitution,
@@ -794,9 +789,8 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
           PointOfInstantiation, InstantiationRange, Template, nullptr, {}) {}
 
 Sema::InstantiatingTemplate::InstantiatingTemplate(
-    Sema &SemaRef, SourceLocation PointOfInstantiation,
-    ConstraintNormalization, NamedDecl *Template,
-    SourceRange InstantiationRange)
+    Sema &SemaRef, SourceLocation PointOfInstantiation, ConstraintNormalization,
+    NamedDecl *Template, SourceRange InstantiationRange)
     : InstantiatingTemplate(
           SemaRef, CodeSynthesisContext::ConstraintNormalization,
           PointOfInstantiation, InstantiationRange, Template) {}
@@ -812,9 +806,9 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
 Sema::InstantiatingTemplate::InstantiatingTemplate(
     Sema &SemaRef, SourceLocation PointOfInstantiation, TemplateDecl *Entity,
     BuildingDeductionGuidesTag, SourceRange InstantiationRange)
-    : InstantiatingTemplate(
-          SemaRef, CodeSynthesisContext::BuildingDeductionGuides,
-          PointOfInstantiation, InstantiationRange, Entity) {}
+    : InstantiatingTemplate(SemaRef,
+                            CodeSynthesisContext::BuildingDeductionGuides,
+                            PointOfInstantiation, InstantiationRange, Entity) {}
 
 Sema::InstantiatingTemplate::InstantiatingTemplate(
     Sema &SemaRef, SourceLocation ArgLoc, PartialOrderingTTP,
@@ -869,8 +863,7 @@ void Sema::popCodeSynthesisContext() {
 
   // If we've left the code synthesis context for the current context stack,
   // stop remembering that we've emitted that stack.
-  if (CodeSynthesisContexts.size() ==
-      LastEmittedCodeSynthesisContextDepth)
+  if (CodeSynthesisContexts.size() == LastEmittedCodeSynthesisContextDepth)
     LastEmittedCodeSynthesisContextDepth = 0;
 
   CodeSynthesisContexts.pop_back();
@@ -931,10 +924,9 @@ void Sema::PrintInstantiationStack(InstantiationContextDiagFuncRef DiagFunc) {
   // FIXME: In all of these cases, we need to show the template arguments
   unsigned InstantiationIdx = 0;
   for (SmallVectorImpl<CodeSynthesisContext>::reverse_iterator
-         Active = CodeSynthesisContexts.rbegin(),
-         ActiveEnd = CodeSynthesisContexts.rend();
-       Active != ActiveEnd;
-       ++Active, ++InstantiationIdx) {
+           Active = CodeSynthesisContexts.rbegin(),
+           ActiveEnd = CodeSynthesisContexts.rend();
+       Active != ActiveEnd; ++Active, ++InstantiationIdx) {
     // Skip this instantiation?
     if (InstantiationIdx >= SkipStart && InstantiationIdx < SkipEnd) {
       if (InstantiationIdx == SkipStart) {
@@ -1076,8 +1068,8 @@ void Sema::PrintInstantiationStack(InstantiationContextDiagFuncRef DiagFunc) {
         TemplateParams = Template->getTemplateParameters();
       else
         TemplateParams =
-          cast<ClassTemplatePartialSpecializationDecl>(Active->Template)
-                                                      ->getTemplateParameters();
+            cast<ClassTemplatePartialSpecializationDecl>(Active->Template)
+                ->getTemplateParameters();
       DiagFunc(Active->PointOfInstantiation,
                PDiag(diag::note_prior_template_arg_substitution)
                    << isa<TemplateTemplateParmDecl>(Parm) << Name
@@ -1094,8 +1086,8 @@ void Sema::PrintInstantiationStack(InstantiationContextDiagFuncRef DiagFunc) {
         TemplateParams = Template->getTemplateParameters();
       else
         TemplateParams =
-          cast<ClassTemplatePartialSpecializationDecl>(Active->Template)
-                                                      ->getTemplateParameters();
+            cast<ClassTemplatePartialSpecializationDecl>(Active->Template)
+                ->getTemplateParameters();
 
       DiagFunc(Active->PointOfInstantiation,
                PDiag(diag::note_template_default_arg_checking)
@@ -1317,553 +1309,552 @@ void Sema::PrintInstantiationStack(InstantiationContextDiagFuncRef DiagFunc) {
 //===----------------------------------------------------------------------===/
 namespace {
 
-  class TemplateInstantiator : public TreeTransform<TemplateInstantiator> {
-    const MultiLevelTemplateArgumentList &TemplateArgs;
-    SourceLocation Loc;
-    DeclarationName Entity;
-    // Whether to evaluate the C++20 constraints or simply substitute into them.
-    bool EvaluateConstraints = true;
-    // Whether Substitution was Incomplete, that is, we tried to substitute in
-    // any user provided template arguments which were null.
-    bool IsIncomplete = false;
-    // Whether an incomplete substituion should be treated as an error.
-    bool BailOutOnIncomplete;
-
-    // CWG2770: Function parameters should be instantiated when they are
-    // needed by a satisfaction check of an atomic constraint or
-    // (recursively) by another function parameter.
-    bool maybeInstantiateFunctionParameterToScope(ParmVarDecl *OldParm);
-
-  public:
-    typedef TreeTransform<TemplateInstantiator> inherited;
-
-    TemplateInstantiator(Sema &SemaRef,
-                         const MultiLevelTemplateArgumentList &TemplateArgs,
-                         SourceLocation Loc, DeclarationName Entity,
-                         bool BailOutOnIncomplete = false)
-        : inherited(SemaRef), TemplateArgs(TemplateArgs), Loc(Loc),
-          Entity(Entity), BailOutOnIncomplete(BailOutOnIncomplete) {}
-
-    void setEvaluateConstraints(bool B) {
-      EvaluateConstraints = B;
-    }
-    bool getEvaluateConstraints() {
-      return EvaluateConstraints;
-    }
-
-    inline static struct ForParameterMappingSubstitution_t {
-    } ForParameterMappingSubstitution;
-
-    TemplateInstantiator(ForParameterMappingSubstitution_t, Sema &SemaRef,
-                         SourceLocation Loc,
-                         const MultiLevelTemplateArgumentList &TemplateArgs)
-        : inherited(SemaRef), TemplateArgs(TemplateArgs), Loc(Loc),
-          BailOutOnIncomplete(false) {}
-
-    /// Determine whether the given type \p T has already been
-    /// transformed.
-    ///
-    /// For the purposes of template instantiation, a type has already been
-    /// transformed if it is NULL or if it is not dependent.
-    bool AlreadyTransformed(QualType T);
+class TemplateInstantiator : public TreeTransform<TemplateInstantiator> {
+  const MultiLevelTemplateArgumentList &TemplateArgs;
+  SourceLocation Loc;
+  DeclarationName Entity;
+  // Whether to evaluate the C++20 constraints or simply substitute into them.
+  bool EvaluateConstraints = true;
+  // Whether Substitution was Incomplete, that is, we tried to substitute in
+  // any user provided template arguments which were null.
+  bool IsIncomplete = false;
+  // Whether an incomplete substituion should be treated as an error.
+  bool BailOutOnIncomplete;
+
+  // CWG2770: Function parameters should be instantiated when they are
+  // needed by a satisfaction check of an atomic constraint or
+  // (recursively) by another function parameter.
+  bool maybeInstantiateFunctionParameterToScope(ParmVarDecl *OldParm);
+
+public:
+  typedef TreeTransform<TemplateInstantiator> inherited;
+
+  TemplateInstantiator(Sema &SemaRef,
+                       const MultiLevelTemplateArgumentList &TemplateArgs,
+                       SourceLocation Loc, DeclarationName Entity,
+                       bool BailOutOnIncomplete = false)
+      : inherited(SemaRef), TemplateArgs(TemplateArgs), Loc(Loc),
+        Entity(Entity), BailOutOnIncomplete(BailOutOnIncomplete) {}
+
+  void setEvaluateConstraints(bool B) { EvaluateConstraints = B; }
+  bool getEvaluateConstraints() { return EvaluateConstraints; }
+
+  inline static struct ForParameterMappingSubstitution_t {
+  } ForParameterMappingSubstitution;
+
+  TemplateInstantiator(ForParameterMappingSubstitution_t, Sema &SemaRef,
+                       SourceLocation Loc,
+                       const MultiLevelTemplateArgumentList &TemplateArgs)
+      : inherited(SemaRef), TemplateArgs(TemplateArgs), Loc(Loc),
+        BailOutOnIncomplete(false) {}
+
+  /// Determine whether the given type \p T has already been
+  /// transformed.
+  ///
+  /// For the purposes of template instantiation, a type has already been
+  /// transformed if it is NULL or if it is not dependent.
+  bool AlreadyTransformed(QualType T);
+
+  /// Returns the location of the entity being instantiated, if known.
+  SourceLocation getBaseLocation() { return Loc; }
+
+  /// Returns the name of the entity being instantiated, if any.
+  DeclarationName getBaseEntity() { return Entity; }
+
+  /// Returns whether any substitution so far was incomplete.
+  bool getIsIncomplete() const { return IsIncomplete; }
+
+  /// Sets the "base" location and entity when that
+  /// information is known based on another transformation.
+  void setBase(SourceLocation Loc, DeclarationName Entity) {
+    this->Loc = Loc;
+    this->Entity = Entity;
+  }
 
-    /// Returns the location of the entity being instantiated, if known.
-    SourceLocation getBaseLocation() { return Loc; }
+  unsigned TransformTemplateDepth(unsigned Depth) {
+    return TemplateArgs.getNewDepth(Depth);
+  }
 
-    /// Returns the name of the entity being instantiated, if any.
-    DeclarationName getBaseEntity() { return Entity; }
+  bool TryExpandParameterPacks(SourceLocation EllipsisLoc,
+                               SourceRange PatternRange,
+                               ArrayRef<UnexpandedParameterPack> Unexpanded,
+                               bool FailOnPackProducingTemplates,
+                               bool &ShouldExpand, bool &RetainExpansion,
+                               UnsignedOrNone &NumExpansions) {
+    if (SemaRef.CurrentInstantiationScope &&
+        (SemaRef.inConstraintSubstitution() ||
+         SemaRef.inParameterMappingSubstitution())) {
+      for (UnexpandedParameterPack ParmPack : Unexpanded) {
+        NamedDecl *VD = ParmPack.first.dyn_cast<NamedDecl *>();
+        if (auto *PVD = dyn_cast_if_present<ParmVarDecl>(VD);
+            PVD && maybeInstantiateFunctionParameterToScope(PVD))
+          return true;
+      }
+    }
 
-    /// Returns whether any substitution so far was incomplete.
-    bool getIsIncomplete() const { return IsIncomplete; }
+    return getSema().CheckParameterPacksForExpansion(
+        EllipsisLoc, PatternRange, Unexpanded, TemplateArgs,
+        FailOnPackProducingTemplates, ShouldExpand, RetainExpansion,
+        NumExpansions);
+  }
 
-    /// Sets the "base" location and entity when that
-    /// information is known based on another transformation.
-    void setBase(SourceLocation Loc, DeclarationName Entity) {
-      this->Loc = Loc;
-      this->Entity = Entity;
-    }
+  void ExpandingFunctionParameterPack(ParmVarDecl *Pack) {
+    SemaRef.CurrentInstantiationScope->MakeInstantiatedLocalArgPack(Pack);
+  }
 
-    unsigned TransformTemplateDepth(unsigned Depth) {
-      return TemplateArgs.getNewDepth(Depth);
+  TemplateArgument ForgetPartiallySubstitutedPack() {
+    TemplateArgument Result;
+    if (NamedDecl *PartialPack =
+            SemaRef.CurrentInstantiationScope->getPartiallySubstitutedPack()) {
+      MultiLevelTemplateArgumentList &TemplateArgs =
+          const_cast<MultiLevelTemplateArgumentList &>(this->TemplateArgs);
+      unsigned Depth, Index;
+      std::tie(Depth, Index) = getDepthAndIndex(PartialPack);
+      if (TemplateArgs.hasTemplateArgument(Depth, Index)) {
+        Result = TemplateArgs(Depth, Index);
+        TemplateArgs.setArgument(Depth, Index, TemplateArgument());
+      } else {
+        IsIncomplete = true;
+        if (BailOutOnIncomplete)
+          return TemplateArgument();
+      }
     }
 
-    bool TryExpandParameterPacks(SourceLocation EllipsisLoc,
-                                 SourceRange PatternRange,
-                                 ArrayRef<UnexpandedParameterPack> Unexpanded,
-                                 bool FailOnPackProducingTemplates,
-                                 bool &ShouldExpand, bool &RetainExpansion,
-                                 UnsignedOrNone &NumExpansions) {
-      if (SemaRef.CurrentInstantiationScope &&
-          (SemaRef.inConstraintSubstitution() ||
-           SemaRef.inParameterMappingSubstitution())) {
-        for (UnexpandedParameterPack ParmPack : Unexpanded) {
-          NamedDecl *VD = ParmPack.first.dyn_cast<NamedDecl *>();
-          if (auto *PVD = dyn_cast_if_present<ParmVarDecl>(VD);
-              PVD && maybeInstantiateFunctionParameterToScope(PVD))
-            return true;
-        }
-      }
+    return Result;
+  }
 
-      return getSema().CheckParameterPacksForExpansion(
-          EllipsisLoc, PatternRange, Unexpanded, TemplateArgs,
-          FailOnPackProducingTemplates, ShouldExpand, RetainExpansion,
-          NumExpansions);
-    }
+  void RememberPartiallySubstitutedPack(TemplateArgument Arg) {
+    if (Arg.isNull())
+      return;
 
-    void ExpandingFunctionParameterPack(ParmVarDecl *Pack) {
-      SemaRef.CurrentInstantiationScope->MakeInstantiatedLocalArgPack(Pack);
+    if (NamedDecl *PartialPack =
+            SemaRef.CurrentInstantiationScope->getPartiallySubstitutedPack()) {
+      MultiLevelTemplateArgumentList &TemplateArgs =
+          const_cast<MultiLevelTemplateArgumentList &>(this->TemplateArgs);
+      unsigned Depth, Index;
+      std::tie(Depth, Index) = getDepthAndIndex(PartialPack);
+      TemplateArgs.setArgument(Depth, Index, Arg);
     }
+  }
 
-    TemplateArgument ForgetPartiallySubstitutedPack() {
-      TemplateArgument Result;
-      if (NamedDecl *PartialPack = SemaRef.CurrentInstantiationScope
-                                       ->getPartiallySubstitutedPack()) {
-        MultiLevelTemplateArgumentList &TemplateArgs =
-            const_cast<MultiLevelTemplateArgumentList &>(this->TemplateArgs);
-        unsigned Depth, Index;
-        std::tie(Depth, Index) = getDepthAndIndex(PartialPack);
-        if (TemplateArgs.hasTemplateArgument(Depth, Index)) {
-          Result = TemplateArgs(Depth, Index);
-          TemplateArgs.setArgument(Depth, Index, TemplateArgument());
-        } else {
-          IsIncomplete = true;
-          if (BailOutOnIncomplete)
-            return TemplateArgument();
-        }
-      }
+  MultiLevelTemplateArgumentList ForgetSubstitution() {
+    MultiLevelTemplateArgumentList New;
+    New.addOuterRetainedLevels(this->TemplateArgs.getNumLevels());
 
-      return Result;
-    }
+    MultiLevelTemplateArgumentList Old =
+        const_cast<MultiLevelTemplateArgumentList &>(this->TemplateArgs);
+    const_cast<MultiLevelTemplateArgumentList &>(this->TemplateArgs) =
+        std::move(New);
+    return Old;
+  }
 
-    void RememberPartiallySubstitutedPack(TemplateArgument Arg) {
-      if (Arg.isNull())
-        return;
-
-      if (NamedDecl *PartialPack = SemaRef.CurrentInstantiationScope
-                                       ->getPartiallySubstitutedPack()) {
-        MultiLevelTemplateArgumentList &TemplateArgs =
-            const_cast<MultiLevelTemplateArgumentList &>(this->TemplateArgs);
-        unsigned Depth, Index;
-        std::tie(Depth, Index) = getDepthAndIndex(PartialPack);
-        TemplateArgs.setArgument(Depth, Index, Arg);
-      }
-    }
+  void RememberSubstitution(MultiLevelTemplateArgumentList Old) {
+    const_cast<MultiLevelTemplateArgumentList &>(this->TemplateArgs) =
+        std::move(Old);
+  }
 
-    MultiLevelTemplateArgumentList ForgetSubstitution() {
-      MultiLevelTemplateArgumentList New;
-      New.addOuterRetainedLevels(this->TemplateArgs.getNumLevels());
+  TemplateArgument
+  getTemplateArgumentPackPatternForRewrite(const TemplateArgument &TA) {
+    if (TA.getKind() != TemplateArgument::Pack)
+      return TA;
+    if (SemaRef.ArgPackSubstIndex)
+      return SemaRef.getPackSubstitutedTemplateArgument(TA);
+    assert(TA.pack_size() == 1 && TA.pack_begin()->isPackExpansion() &&
+           "unexpected pack arguments in template rewrite");
+    TemplateArgument Arg = *TA.pack_begin();
+    if (Arg.isPackExpansion())
+      Arg = Arg.getPackExpansionPattern();
+    return Arg;
+  }
 
-      MultiLevelTemplateArgumentList Old =
-          const_cast<MultiLevelTemplateArgumentList &>(this->TemplateArgs);
-      const_cast<MultiLevelTemplateArgumentList &>(this->TemplateArgs) =
-          std::move(New);
-      return Old;
-    }
+  /// Transform the given declaration by instantiating a reference to
+  /// this declaration.
+  Decl *TransformDecl(SourceLocation Loc, Decl *D);
 
-    void RememberSubstitution(MultiLevelTemplateArgumentList Old) {
-      const_cast<MultiLevelTemplateArgumentList &>(this->TemplateArgs) =
-          std::move(Old);
-    }
+  void transformAttrs(Decl *Old, Decl *New) {
+    SemaRef.InstantiateAttrs(TemplateArgs, Old, New);
+  }
 
-    TemplateArgument
-    getTemplateArgumentPackPatternForRewrite(const TemplateArgument &TA) {
-      if (TA.getKind() != TemplateArgument::Pack)
-        return TA;
-      if (SemaRef.ArgPackSubstIndex)
-        return SemaRef.getPackSubstitutedTemplateArgument(TA);
-      assert(TA.pack_size() == 1 && TA.pack_begin()->isPackExpansion() &&
-             "unexpected pack arguments in template rewrite");
-      TemplateArgument Arg = *TA.pack_begin();
-      if (Arg.isPackExpansion())
-        Arg = Arg.getPackExpansionPattern();
-      return Arg;
+  void transformedLocalDecl(Decl *Old, ArrayRef<Decl *> NewDecls) {
+    if (Old->isParameterPack() &&
+        (NewDecls.size() != 1 || !NewDecls.front()->isParameterPack())) {
+      SemaRef.CurrentInstantiationScope->MakeInstantiatedLocalArgPack(Old);
+      for (auto *New : NewDecls)
+        SemaRef.CurrentInstantiationScope->InstantiatedLocalPackArg(
+            Old, cast<VarDecl>(New));
+      return;
     }
 
-    /// Transform the given declaration by instantiating a reference to
-    /// this declaration.
-    Decl *TransformDecl(SourceLocation Loc, Decl *D);
-
-    void transformAttrs(Decl *Old, Decl *New) {
-      SemaRef.InstantiateAttrs(TemplateArgs, Old, New);
+    assert(NewDecls.size() == 1 &&
+           "should only have multiple expansions for a pack");
+    Decl *New = NewDecls.front();
+
+    // If we've instantiated the call operator of a lambda or the call
+    // operator template of a generic lambda, update the "instantiation of"
+    // information.
+    auto *NewMD = dyn_cast<CXXMethodDecl>(New);
+    if (NewMD && isLambdaCallOperator(NewMD)) {
+      auto *OldMD = dyn_cast<CXXMethodDecl>(Old);
+      if (auto *NewTD = NewMD->getDescribedFunctionTemplate())
+        NewTD->setInstantiatedFromMemberTemplate(
+            OldMD->getDescribedFunctionTemplate());
+      else
+        NewMD->setInstantiationOfMemberFunction(OldMD,
+                                                TSK_ImplicitInstantiation);
     }
 
-    void transformedLocalDecl(Decl *Old, ArrayRef<Decl *> NewDecls) {
-      if (Old->isParameterPack() &&
-          (NewDecls.size() != 1 || !NewDecls.front()->isParameterPack())) {
-        SemaRef.CurrentInstantiationScope->MakeInstantiatedLocalArgPack(Old);
-        for (auto *New : NewDecls)
-          SemaRef.CurrentInstantiationScope->InstantiatedLocalPackArg(
-              Old, cast<VarDecl>(New));
-        return;
-      }
+    SemaRef.CurrentInstantiationScope->InstantiatedLocal(Old, New);
 
-      assert(NewDecls.size() == 1 &&
-             "should only have multiple expansions for a pack");
-      Decl *New = NewDecls.front();
-
-      // If we've instantiated the call operator of a lambda or the call
-      // operator template of a generic lambda, update the "instantiation of"
-      // information.
-      auto *NewMD = dyn_cast<CXXMethodDecl>(New);
-      if (NewMD && isLambdaCallOperator(NewMD)) {
-        auto *OldMD = dyn_cast<CXXMethodDecl>(Old);
-        if (auto *NewTD = NewMD->getDescribedFunctionTemplate())
-          NewTD->setInstantiatedFromMemberTemplate(
-              OldMD->getDescribedFunctionTemplate());
-        else
-          NewMD->setInstantiationOfMemberFunction(OldMD,
-                                                  TSK_ImplicitInstantiation);
-      }
+    // We recreated a local declaration, but not by instantiating it. There
+    // may be pending dependent diagnostics to produce.
+    if (auto *DC = dyn_cast<DeclContext>(Old);
+        DC && DC->isDependentContext() && DC->isFunctionOrMethod())
+      SemaRef.PerformDependentDiagnostics(DC, TemplateArgs);
+  }
 
-      SemaRef.CurrentInstantiationScope->InstantiatedLocal(Old, New);
+  /// Transform the definition of the given declaration by
+  /// instantiating it.
+  Decl *TransformDefinition(SourceLocation Loc, Decl *D);
 
-      // We recreated a local declaration, but not by instantiating it. There
-      // may be pending dependent diagnostics to produce.
-      if (auto *DC = dyn_cast<DeclContext>(Old);
-          DC && DC->isDependentContext() && DC->isFunctionOrMethod())
-        SemaRef.PerformDependentDiagnostics(DC, TemplateArgs);
-    }
+  /// Transform the first qualifier within a scope by instantiating the
+  /// declaration.
+  NamedDecl *TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc);
 
-    /// Transform the definition of the given declaration by
-    /// instantiating it.
-    Decl *TransformDefinition(SourceLocation Loc, Decl *D);
-
-    /// Transform the first qualifier within a scope by instantiating the
-    /// declaration.
-    NamedDecl *TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc);
-
-    bool TransformExceptionSpec(SourceLocation Loc,
-                                FunctionProtoType::ExceptionSpecInfo &ESI,
-                                SmallVectorImpl<QualType> &Exceptions,
-                                bool &Changed);
-
-    /// Rebuild the exception declaration and register the declaration
-    /// as an instantiated local.
-    VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl,
-                                  TypeSourceInfo *Declarator,
-                                  SourceLocation StartLoc,
-                                  SourceLocation NameLoc,
-                                  IdentifierInfo *Name);
-
-    /// Rebuild the Objective-C exception declaration and register the
-    /// declaration as an instantiated local.
-    VarDecl *RebuildObjCExceptionDecl(VarDecl *ExceptionDecl,
-                                      TypeSourceInfo *TSInfo, QualType T);
-
-    TemplateName
-    TransformTemplateName(NestedNameSpecifierLoc &QualifierLoc,
-                          SourceLocation TemplateKWLoc, TemplateName Name,
-                          SourceLocation NameLoc,
-                          QualType ObjectType = QualType(),
-                          NamedDecl *FirstQualifierInScope = nullptr,
-                          bool AllowInjectedClassName = false);
-
-    const AnnotateAttr *TransformAnnotateAttr(const AnnotateAttr *AA);
-    const CXXAssumeAttr *TransformCXXAssumeAttr(const CXXAssumeAttr *AA);
-    const LoopHintAttr *TransformLoopHintAttr(const LoopHintAttr *LH);
-    const NoInlineAttr *TransformStmtNoInlineAttr(const Stmt *OrigS,
-                                                  const Stmt *InstS,
-                                                  const NoInlineAttr *A);
-    const AlwaysInlineAttr *
-    TransformStmtAlwaysInlineAttr(const Stmt *OrigS, const Stmt *InstS,
-                                  const AlwaysInlineAttr *A);
-    const CodeAlignAttr *TransformCodeAlignAttr(const CodeAlignAttr *CA);
-    const OpenACCRoutineDeclAttr *
-    TransformOpenACCRoutineDeclAttr(const OpenACCRoutineDeclAttr *A);
-    ExprResult TransformPredefinedExpr(PredefinedExpr *E);
-    ExprResult TransformDeclRefExpr(DeclRefExpr *E);
-    ExprResult TransformCXXDefaultArgExpr(CXXDefaultArgExpr *E);
-
-    ExprResult TransformTemplateParmRefExpr(DeclRefExpr *E,
-                                            NonTypeTemplateParmDecl *D);
-
-    /// Rebuild a DeclRefExpr for a VarDecl reference.
-    ExprResult RebuildVarDeclRefExpr(ValueDecl *PD, SourceLocation Loc);
-
-    /// Transform a reference to a function or init-capture parameter pack.
-    ExprResult TransformFunctionParmPackRefExpr(DeclRefExpr *E, ValueDecl *PD);
-
-    /// Transform a FunctionParmPackExpr which was built when we couldn't
-    /// expand a function parameter pack reference which refers to an expanded
-    /// pack.
-    ExprResult TransformFunctionParmPackExpr(FunctionParmPackExpr *E);
-
-    QualType TransformFunctionProtoType(TypeLocBuilder &TLB,
-                                        FunctionProtoTypeLoc TL) {
-      // Call the base version; it will forward to our overridden version below.
-      return inherited::TransformFunctionProtoType(TLB, TL);
-    }
+  bool TransformExceptionSpec(SourceLocation Loc,
+                              FunctionProtoType::ExceptionSpecInfo &ESI,
+                              SmallVectorImpl<QualType> &Exceptions,
+                              bool &Changed);
+
+  /// Rebuild the exception declaration and register the declaration
+  /// as an instantiated local.
+  VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl,
+                                TypeSourceInfo *Declarator,
+                                SourceLocation StartLoc, SourceLocation NameLoc,
+                                IdentifierInfo *Name);
+
+  /// Rebuild the Objective-C exception declaration and register the
+  /// declaration as an instantiated local.
+  VarDecl *RebuildObjCExceptionDecl(VarDecl *ExceptionDecl,
+                                    TypeSourceInfo *TSInfo, QualType T);
+
+  TemplateName TransformTemplateName(NestedNameSpecifierLoc &QualifierLoc,
+                                     SourceLocation TemplateKWLoc,
+                                     TemplateName Name, SourceLocation NameLoc,
+                                     QualType ObjectType = QualType(),
+                                     NamedDecl *FirstQualifierInScope = nullptr,
+                                     bool AllowInjectedClassName = false);
+
+  const AnnotateAttr *TransformAnnotateAttr(const AnnotateAttr *AA);
+  const CXXAssumeAttr *TransformCXXAssumeAttr(const CXXAssumeAttr *AA);
+  const LoopHintAttr *TransformLoopHintAttr(const LoopHintAttr *LH);
+  const NoInlineAttr *TransformStmtNoInlineAttr(const Stmt *OrigS,
+                                                const Stmt *InstS,
+                                                const NoInlineAttr *A);
+  const AlwaysInlineAttr *
+  TransformStmtAlwaysInlineAttr(const Stmt *OrigS, const Stmt *InstS,
+                                const AlwaysInlineAttr *A);
+  const CodeAlignAttr *TransformCodeAlignAttr(const CodeAlignAttr *CA);
+  const OpenACCRoutineDeclAttr *
+  TransformOpenACCRoutineDeclAttr(const OpenACCRoutineDeclAttr *A);
+  ExprResult TransformPredefinedExpr(PredefinedExpr *E);
+  ExprResult TransformDeclRefExpr(DeclRefExpr *E);
+  ExprResult TransformCXXReflectExpr(CXXReflectExpr *E);
+  ExprResult TransformCXXDefaultArgExpr(CXXDefaultArgExpr *E);
+
+  ExprResult TransformTemplateParmRefExpr(DeclRefExpr *E,
+                                          NonTypeTemplateParmDecl *D);
+
+  /// Rebuild a DeclRefExpr for a VarDecl reference.
+  ExprResult RebuildVarDeclRefExpr(ValueDecl *PD, SourceLocation Loc);
+
+  /// Transform a reference to a function or init-capture parameter pack.
+  ExprResult TransformFunctionParmPackRefExpr(DeclRefExpr *E, ValueDecl *PD);
+
+  /// Transform a FunctionParmPackExpr which was built when we couldn't
+  /// expand a function parameter pack reference which refers to an expanded
+  /// pack.
+  ExprResult TransformFunctionParmPackExpr(FunctionParmPackExpr *E);
+
+  QualType TransformFunctionProtoType(TypeLocBuilder &TLB,
+                                      FunctionProtoTypeLoc TL) {
+    // Call the base version; it will forward to our overridden version below.
+    return inherited::TransformFunctionProtoType(TLB, TL);
+  }
 
-    QualType TransformTagType(TypeLocBuilder &TLB, TagTypeLoc TL) {
-      auto Type = inherited::TransformTagType(TLB, TL);
-      if (!Type.isNull())
-        return Type;
-      // Special case for transforming a deduction guide, we return a
-      // transformed TemplateSpecializationType.
-      // FIXME: Why is this hack necessary?
-      if (const auto *ICNT = dyn_cast<InjectedClassNameType>(TL.getTypePtr());
-          ICNT && SemaRef.CodeSynthesisContexts.back().Kind ==
-                      Sema::CodeSynthesisContext::BuildingDeductionGuides) {
-        Type = inherited::TransformType(
-            ICNT->getDecl()->getCanonicalTemplateSpecializationType(
-                SemaRef.Context));
-        TLB.pushTrivial(SemaRef.Context, Type, TL.getNameLoc());
-      }
+  QualType TransformTagType(TypeLocBuilder &TLB, TagTypeLoc TL) {
+    auto Type = inherited::TransformTagType(TLB, TL);
+    if (!Type.isNull())
       return Type;
+    // Special case for transforming a deduction guide, we return a
+    // transformed TemplateSpecializationType.
+    // FIXME: Why is this hack necessary?
+    if (const auto *ICNT = dyn_cast<InjectedClassNameType>(TL.getTypePtr());
+        ICNT && SemaRef.CodeSynthesisContexts.back().Kind ==
+                    Sema::CodeSynthesisContext::BuildingDeductionGuides) {
+      Type = inherited::TransformType(
+          ICNT->getDecl()->getCanonicalTemplateSpecializationType(
+              SemaRef.Context));
+      TLB.pushTrivial(SemaRef.Context, Type, TL.getNameLoc());
     }
-    // Override the default version to handle a rewrite-template-arg-pack case
-    // for building a deduction guide.
-    bool TransformTemplateArgument(const TemplateArgumentLoc &Input,
-                                   TemplateArgumentLoc &Output,
-                                   bool Uneval = false) {
-      const TemplateArgument &Arg = Input.getArgument();
-      std::vector<TemplateArgument> TArgs;
-      switch (Arg.getKind()) {
-      case TemplateArgument::Pack:
-        assert(SemaRef.CodeSynthesisContexts.empty() ||
-               SemaRef.CodeSynthesisContexts.back().Kind ==
-                   Sema::CodeSynthesisContext::BuildingDeductionGuides);
-        // Literally rewrite the template argument pack, instead of unpacking
-        // it.
-        for (auto &pack : Arg.getPackAsArray()) {
-          TemplateArgumentLoc Input = SemaRef.getTrivialTemplateArgumentLoc(
-              pack, QualType(), SourceLocation{});
-          TemplateArgumentLoc Output;
-          if (TransformTemplateArgument(Input, Output, Uneval))
-            return true; // fails
-          TArgs.push_back(Output.getArgument());
-        }
-        Output = SemaRef.getTrivialTemplateArgumentLoc(
-            TemplateArgument(llvm::ArrayRef(TArgs).copy(SemaRef.Context)),
-            QualType(), SourceLocation{});
-        return false;
-      default:
-        break;
+    return Type;
+  }
+  // Override the default version to handle a rewrite-template-arg-pack case
+  // for building a deduction guide.
+  bool TransformTemplateArgument(const TemplateArgumentLoc &Input,
+                                 TemplateArgumentLoc &Output,
+                                 bool Uneval = false) {
+    const TemplateArgument &Arg = Input.getArgument();
+    std::vector<TemplateArgument> TArgs;
+    switch (Arg.getKind()) {
+    case TemplateArgument::Pack:
+      assert(SemaRef.CodeSynthesisContexts.empty() ||
+             SemaRef.CodeSynthesisContexts.back().Kind ==
+                 Sema::CodeSynthesisContext::BuildingDeductionGuides);
+      // Literally rewrite the template argument pack, instead of unpacking
+      // it.
+      for (auto &pack : Arg.getPackAsArray()) {
+        TemplateArgumentLoc Input = SemaRef.getTrivialTemplateArgumentLoc(
+            pack, QualType(), SourceLocation{});
+        TemplateArgumentLoc Output;
+        if (TransformTemplateArgument(Input, Output, Uneval))
+          return true; // fails
+        TArgs.push_back(Output.getArgument());
       }
-      return inherited::TransformTemplateArgument(Input, Output, Uneval);
+      Output = SemaRef.getTrivialTemplateArgumentLoc(
+          TemplateArgument(llvm::ArrayRef(TArgs).copy(SemaRef.Context)),
+          QualType(), SourceLocation{});
+      return false;
+    default:
+      break;
     }
+    return inherited::TransformTemplateArgument(Input, Output, Uneval);
+  }
 
-    using TreeTransform::TransformTemplateSpecializationType;
-    QualType
-    TransformTemplateSpecializationType(TypeLocBuilder &TLB,
-                                        TemplateSpecializationTypeLoc TL) {
-      auto *T = TL.getTypePtr();
-      if (!getSema().ArgPackSubstIndex || !T->isSugared() ||
-          !isPackProducingBuiltinTemplateName(T->getTemplateName()))
-        return TreeTransform::TransformTemplateSpecializationType(TLB, TL);
-      // Look through sugar to get to the SubstBuiltinTemplatePackType that we
-      // need to substitute into.
-
-      // `TransformType` code below will handle picking the element from a pack
-      // with the index `ArgPackSubstIndex`.
-      // FIXME: add ability to represent sugarred type for N-th element of a
-      // builtin pack and produce the sugar here.
-      QualType R = TransformType(T->desugar());
-      TLB.pushTrivial(getSema().getASTContext(), R, TL.getBeginLoc());
-      return R;
-    }
+  using TreeTransform::TransformTemplateSpecializationType;
+  QualType
+  TransformTemplateSpecializationType(TypeLocBuilder &TLB,
+                                      TemplateSpecializationTypeLoc TL) {
+    auto *T = TL.getTypePtr();
+    if (!getSema().ArgPackSubstIndex || !T->isSugared() ||
+        !isPackProducingBuiltinTemplateName(T->getTemplateName()))
+      return TreeTransform::TransformTemplateSpecializationType(TLB, TL);
+    // Look through sugar to get to the SubstBuiltinTemplatePackType that we
+    // need to substitute into.
+
+    // `TransformType` code below will handle picking the element from a pack
+    // with the index `ArgPackSubstIndex`.
+    // FIXME: add ability to represent sugarred type for N-th element of a
+    // builtin pack and produce the sugar here.
+    QualType R = TransformType(T->desugar());
+    TLB.pushTrivial(getSema().getASTContext(), R, TL.getBeginLoc());
+    return R;
+  }
 
-    UnsignedOrNone ComputeSizeOfPackExprWithoutSubstitution(
-        ArrayRef<TemplateArgument> PackArgs) {
-      // Don't do this when rewriting template parameters for CTAD:
-      //   1) The heuristic needs the unpacked Subst* nodes to figure out the
-      //   expanded size, but this never applies since Subst* nodes are not
-      //   created in rewrite scenarios.
-      //
-      //   2) The heuristic substitutes into the pattern with pack expansion
-      //   suppressed, which does not meet the requirements for argument
-      //   rewriting when template arguments include a non-pack matching against
-      //   a pack, particularly when rewriting an alias CTAD.
-      if (TemplateArgs.isRewrite())
-        return std::nullopt;
-
-      return inherited::ComputeSizeOfPackExprWithoutSubstitution(PackArgs);
-    }
+  UnsignedOrNone ComputeSizeOfPackExprWithoutSubstitution(
+      ArrayRef<TemplateArgument> PackArgs) {
+    // Don't do this when rewriting template parameters for CTAD:
+    //   1) The heuristic needs the unpacked Subst* nodes to figure out the
+    //   expanded size, but this never applies since Subst* nodes are not
+    //   created in rewrite scenarios.
+    //
+    //   2) The heuristic substitutes into the pattern with pack expansion
+    //   suppressed, which does not meet the requirements for argument
+    //   rewriting when template arguments include a non-pack matching against
+    //   a pack, particularly when rewriting an alias CTAD.
+    if (TemplateArgs.isRewrite())
+      return std::nullopt;
+
+    return inherited::ComputeSizeOfPackExprWithoutSubstitution(PackArgs);
+  }
 
-    template<typename Fn>
-    QualType TransformFunctionProtoType(TypeLocBuilder &TLB,
-                                        FunctionProtoTypeLoc TL,
-                                        CXXRecordDecl *ThisContext,
-                                        Qualifiers ThisTypeQuals,
-                                        Fn TransformExceptionSpec);
-
-    ParmVarDecl *TransformFunctionTypeParam(ParmVarDecl *OldParm,
-                                            int indexAdjustment,
-                                            UnsignedOrNone NumExpansions,
-                                            bool ExpectParameterPack);
-
-    using inherited::TransformTemplateTypeParmType;
-    /// Transforms a template type parameter type by performing
-    /// substitution of the corresponding template type argument.
-    QualType TransformTemplateTypeParmType(TypeLocBuilder &TLB,
-                                           TemplateTypeParmTypeLoc TL,
-                                           bool SuppressObjCLifetime);
-
-    QualType BuildSubstTemplateTypeParmType(
-        TypeLocBuilder &TLB, bool SuppressObjCLifetime, bool Final,
-        Decl *AssociatedDecl, unsigned Index, UnsignedOrNone PackIndex,
-        TemplateArgument Arg, SourceLocation NameLoc);
-
-    /// Transforms an already-substituted template type parameter pack
-    /// into either itself (if we aren't substituting into its pack expansion)
-    /// or the appropriate substituted argument.
-    using inherited::TransformSubstTemplateTypeParmPackType;
-    QualType
-    TransformSubstTemplateTypeParmPackType(TypeLocBuilder &TLB,
-                                           SubstTemplateTypeParmPackTypeLoc TL,
-                                           bool SuppressObjCLifetime);
-    QualType
-    TransformSubstBuiltinTemplatePackType(TypeLocBuilder &TLB,
-                                          SubstBuiltinTemplatePackTypeLoc TL);
-
-    CXXRecordDecl::LambdaDependencyKind
-    ComputeLambdaDependency(LambdaScopeInfo *LSI) {
-      if (auto TypeAlias =
-              TemplateInstArgsHelpers::getEnclosingTypeAliasTemplateDecl(
-                  getSema());
-          TypeAlias && TemplateInstArgsHelpers::isLambdaEnclosedByTypeAliasDecl(
-                           LSI->CallOperator, TypeAlias.PrimaryTypeAliasDecl)) {
-        unsigned TypeAliasDeclDepth = TypeAlias.Template->getTemplateDepth();
-        if (TypeAliasDeclDepth >= TemplateArgs.getNumSubstitutedLevels())
+  template <typename Fn>
+  QualType TransformFunctionProtoType(TypeLocBuilder &TLB,
+                                      FunctionProtoTypeLoc TL,
+                                      CXXRecordDecl *ThisContext,
+                                      Qualifiers ThisTypeQuals,
+                                      Fn TransformExceptionSpec);
+
+  ParmVarDecl *TransformFunctionTypeParam(ParmVarDecl *OldParm,
+                                          int indexAdjustment,
+                                          UnsignedOrNone NumExpansions,
+                                          bool ExpectParameterPack);
+
+  using inherited::TransformTemplateTypeParmType;
+  /// Transforms a template type parameter type by performing
+  /// substitution of the corresponding template type argument.
+  QualType TransformTemplateTypeParmType(TypeLocBuilder &TLB,
+                                         TemplateTypeParmTypeLoc TL,
+                                         bool SuppressObjCLifetime);
+
+  QualType BuildSubstTemplateTypeParmType(TypeLocBuilder &TLB,
+                                          bool SuppressObjCLifetime, bool Final,
+                                          Decl *AssociatedDecl, unsigned Index,
+                                          UnsignedOrNone PackIndex,
+                                          TemplateArgument Arg,
+                                          SourceLocation NameLoc);
+
+  /// Transforms an already-substituted template type parameter pack
+  /// into either itself (if we aren't substituting into its pack expansion)
+  /// or the appropriate substituted argument.
+  using inherited::TransformSubstTemplateTypeParmPackType;
+  QualType
+  TransformSubstTemplateTypeParmPackType(TypeLocBuilder &TLB,
+                                         SubstTemplateTypeParmPackTypeLoc TL,
+                                         bool SuppressObjCLifetime);
+  QualType
+  TransformSubstBuiltinTemplatePackType(TypeLocBuilder &TLB,
+                                        SubstBuiltinTemplatePackTypeLoc TL);
+
+  CXXRecordDecl::LambdaDependencyKind
+  ComputeLambdaDependency(LambdaScopeInfo *LSI) {
+    if (auto TypeAlias =
+            TemplateInstArgsHelpers::getEnclosingTypeAliasTemplateDecl(
+                getSema());
+        TypeAlias && TemplateInstArgsHelpers::isLambdaEnclosedByTypeAliasDecl(
+                         LSI->CallOperator, TypeAlias.PrimaryTypeAliasDecl)) {
+      unsigned TypeAliasDeclDepth = TypeAlias.Template->getTemplateDepth();
+      if (TypeAliasDeclDepth >= TemplateArgs.getNumSubstitutedLevels())
+        return CXXRecordDecl::LambdaDependencyKind::LDK_AlwaysDependent;
+      for (const TemplateArgument &TA : TypeAlias.AssociatedTemplateArguments)
+        if (TA.isDependent())
           return CXXRecordDecl::LambdaDependencyKind::LDK_AlwaysDependent;
-        for (const TemplateArgument &TA : TypeAlias.AssociatedTemplateArguments)
-          if (TA.isDependent())
-            return CXXRecordDecl::LambdaDependencyKind::LDK_AlwaysDependent;
-      }
-      return inherited::ComputeLambdaDependency(LSI);
     }
+    return inherited::ComputeLambdaDependency(LSI);
+  }
 
-    ExprResult TransformLambdaExpr(LambdaExpr *E) {
-      // Do not rebuild lambdas to avoid creating a new type.
-      // Lambdas have already been processed inside their eval contexts.
-      if (SemaRef.RebuildingImmediateInvocation)
-        return E;
-      LocalInstantiationScope Scope(SemaRef, /*CombineWithOuterScope=*/true,
-                                    /*InstantiatingLambdaOrBlock=*/true);
-      Sema::ConstraintEvalRAII<TemplateInstantiator> RAII(*this);
+  ExprResult TransformLambdaExpr(LambdaExpr *E) {
+    // Do not rebuild lambdas to avoid creating a new type.
+    // Lambdas have already been processed inside their eval contexts.
+    if (SemaRef.RebuildingImmediateInvocation)
+      return E;
+    LocalInstantiationScope Scope(SemaRef, /*CombineWithOuterScope=*/true,
+                                  /*InstantiatingLambdaOrBlock=*/true);
+    Sema::ConstraintEvalRAII<TemplateInstantiator> RAII(*this);
 
-      return inherited::TransformLambdaExpr(E);
-    }
+    return inherited::TransformLambdaExpr(E);
+  }
 
-    ExprResult TransformBlockExpr(BlockExpr *E) {
-      LocalInstantiationScope Scope(SemaRef, /*CombineWithOuterScope=*/true,
-                                    /*InstantiatingLambdaOrBlock=*/true);
-      return inherited::TransformBlockExpr(E);
-    }
+  ExprResult TransformBlockExpr(BlockExpr *E) {
+    LocalInstantiationScope Scope(SemaRef, /*CombineWithOuterScope=*/true,
+                                  /*InstantiatingLambdaOrBlock=*/true);
+    return inherited::TransformBlockExpr(E);
+  }
 
-    ExprResult RebuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc,
-                                 LambdaScopeInfo *LSI) {
-      CXXMethodDecl *MD = LSI->CallOperator;
-      for (ParmVarDecl *PVD : MD->parameters()) {
-        assert(PVD && "null in a parameter list");
-        if (!PVD->hasDefaultArg())
-          continue;
-        Expr *UninstExpr = PVD->getUninstantiatedDefaultArg();
-        // FIXME: Obtain the source location for the '=' token.
-        SourceLocation EqualLoc = UninstExpr->getBeginLoc();
-        if (SemaRef.SubstDefaultArgument(EqualLoc, PVD, TemplateArgs)) {
-          // If substitution fails, the default argument is set to a
-          // RecoveryExpr that wraps the uninstantiated default argument so
-          // that downstream diagnostics are omitted.
-          ExprResult ErrorResult = SemaRef.CreateRecoveryExpr(
-              UninstExpr->getBeginLoc(), UninstExpr->getEndLoc(), {UninstExpr},
-              UninstExpr->getType());
-          if (ErrorResult.isUsable())
-            PVD->setDefaultArg(ErrorResult.get());
-        }
+  ExprResult RebuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc,
+                               LambdaScopeInfo *LSI) {
+    CXXMethodDecl *MD = LSI->CallOperator;
+    for (ParmVarDecl *PVD : MD->parameters()) {
+      assert(PVD && "null in a parameter list");
+      if (!PVD->hasDefaultArg())
+        continue;
+      Expr *UninstExpr = PVD->getUninstantiatedDefaultArg();
+      // FIXME: Obtain the source location for the '=' token.
+      SourceLocation EqualLoc = UninstExpr->getBeginLoc();
+      if (SemaRef.SubstDefaultArgument(EqualLoc, PVD, TemplateArgs)) {
+        // If substitution fails, the default argument is set to a
+        // RecoveryExpr that wraps the uninstantiated default argument so
+        // that downstream diagnostics are omitted.
+        ExprResult ErrorResult = SemaRef.CreateRecoveryExpr(
+            UninstExpr->getBeginLoc(), UninstExpr->getEndLoc(), {UninstExpr},
+            UninstExpr->getType());
+        if (ErrorResult.isUsable())
+          PVD->setDefaultArg(ErrorResult.get());
       }
-      return inherited::RebuildLambdaExpr(StartLoc, EndLoc, LSI);
     }
+    return inherited::RebuildLambdaExpr(StartLoc, EndLoc, LSI);
+  }
 
-    StmtResult TransformLambdaBody(LambdaExpr *E, Stmt *Body) {
-      // Currently, we instantiate the body when instantiating the lambda
-      // expression. However, `EvaluateConstraints` is disabled during the
-      // instantiation of the lambda expression, causing the instantiation
-      // failure of the return type requirement in the body. If p0588r1 is fully
-      // implemented, the body will be lazily instantiated, and this problem
-      // will not occur. Here, `EvaluateConstraints` is temporarily set to
-      // `true` to temporarily fix this issue.
-      // FIXME: This temporary fix can be removed after fully implementing
-      // p0588r1.
-      llvm::SaveAndRestore _(EvaluateConstraints, true);
-      return inherited::TransformLambdaBody(E, Body);
-    }
+  StmtResult TransformLambdaBody(LambdaExpr *E, Stmt *Body) {
+    // Currently, we instantiate the body when instantiating the lambda
+    // expression. However, `EvaluateConstraints` is disabled during the
+    // instantiation of the lambda expression, causing the instantiation
+    // failure of the return type requirement in the body. If p0588r1 is fully
+    // implemented, the body will be lazily instantiated, and this problem
+    // will not occur. Here, `EvaluateConstraints` is temporarily set to
+    // `true` to temporarily fix this issue.
+    // FIXME: This temporary fix can be removed after fully implementing
+    // p0588r1.
+    llvm::SaveAndRestore _(EvaluateConstraints, true);
+    return inherited::TransformLambdaBody(E, Body);
+  }
 
-    ExprResult TransformRequiresExpr(RequiresExpr *E) {
-      LocalInstantiationScope Scope(SemaRef, /*CombineWithOuterScope=*/true);
-      ExprResult TransReq = inherited::TransformRequiresExpr(E);
-      if (TransReq.isInvalid())
-        return TransReq;
-      assert(TransReq.get() != E &&
-             "Do not change value of isSatisfied for the existing expression. "
-             "Create a new expression instead.");
-      if (E->getBody()->isDependentContext()) {
-        Sema::SFINAETrap Trap(SemaRef);
-        // We recreate the RequiresExpr body, but not by instantiating it.
-        // Produce pending diagnostics for dependent access check.
-        SemaRef.PerformDependentDiagnostics(E->getBody(), TemplateArgs);
-        // FIXME: Store SFINAE diagnostics in RequiresExpr for diagnosis.
-        if (Trap.hasErrorOccurred())
-          TransReq.getAs<RequiresExpr>()->setSatisfied(false);
-      }
+  ExprResult TransformRequiresExpr(RequiresExpr *E) {
+    LocalInstantiationScope Scope(SemaRef, /*CombineWithOuterScope=*/true);
+    ExprResult TransReq = inherited::TransformRequiresExpr(E);
+    if (TransReq.isInvalid())
       return TransReq;
+    assert(TransReq.get() != E &&
+           "Do not change value of isSatisfied for the existing expression. "
+           "Create a new expression instead.");
+    if (E->getBody()->isDependentContext()) {
+      Sema::SFINAETrap Trap(SemaRef);
+      // We recreate the RequiresExpr body, but not by instantiating it.
+      // Produce pending diagnostics for dependent access check.
+      SemaRef.PerformDependentDiagnostics(E->getBody(), TemplateArgs);
+      // FIXME: Store SFINAE diagnostics in RequiresExpr for diagnosis.
+      if (Trap.hasErrorOccurred())
+        TransReq.getAs<RequiresExpr>()->setSatisfied(false);
     }
+    return TransReq;
+  }
 
-    bool TransformRequiresExprRequirements(
-        ArrayRef<concepts::Requirement *> Reqs,
-        SmallVectorImpl<concepts::Requirement *> &Transformed) {
-      bool SatisfactionDetermined = false;
-      for (concepts::Requirement *Req : Reqs) {
-        concepts::Requirement *TransReq = nullptr;
-        if (!SatisfactionDetermined) {
-          if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
-            TransReq = TransformTypeRequirement(TypeReq);
-          else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
-            TransReq = TransformExprRequirement(ExprReq);
-          else
-            TransReq = TransformNestedRequirement(
-                cast<concepts::NestedRequirement>(Req));
-          if (!TransReq)
-            return true;
-          if (!TransReq->isDependent() && !TransReq->isSatisfied())
-            // [expr.prim.req]p6
-            //   [...]  The substitution and semantic constraint checking
-            //   proceeds in lexical order and stops when a condition that
-            //   determines the result of the requires-expression is
-            //   encountered. [..]
-            SatisfactionDetermined = true;
-        } else
-          TransReq = Req;
-        Transformed.push_back(TransReq);
-      }
-      return false;
+  bool TransformRequiresExprRequirements(
+      ArrayRef<concepts::Requirement *> Reqs,
+      SmallVectorImpl<concepts::Requirement *> &Transformed) {
+    bool SatisfactionDetermined = false;
+    for (concepts::Requirement *Req : Reqs) {
+      concepts::Requirement *TransReq = nullptr;
+      if (!SatisfactionDetermined) {
+        if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
+          TransReq = TransformTypeRequirement(TypeReq);
+        else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
+          TransReq = TransformExprRequirement(ExprReq);
+        else
+          TransReq = TransformNestedRequirement(
+              cast<concepts::NestedRequirement>(Req));
+        if (!TransReq)
+          return true;
+        if (!TransReq->isDependent() && !TransReq->isSatisfied())
+          // [expr.prim.req]p6
+          //   [...]  The substitution and semantic constraint checking
+          //   proceeds in lexical order and stops when a condition that
+          //   determines the result of the requires-expression is
+          //   encountered. [..]
+          SatisfactionDetermined = true;
+      } else
+        TransReq = Req;
+      Transformed.push_back(TransReq);
     }
+    return false;
+  }
 
-    TemplateParameterList *TransformTemplateParameterList(
-                              TemplateParameterList *OrigTPL)  {
-      if (!OrigTPL || !OrigTPL->size()) return OrigTPL;
-
-      DeclContext *Owner = OrigTPL->getParam(0)->getDeclContext();
-      TemplateDeclInstantiator  DeclInstantiator(getSema(),
-                        /* DeclContext *Owner */ Owner, TemplateArgs);
-      DeclInstantiator.setEvaluateConstraints(EvaluateConstraints);
-      return DeclInstantiator.SubstTemplateParams(OrigTPL);
-    }
+  TemplateParameterList *
+  TransformTemplateParameterList(TemplateParameterList *OrigTPL) {
+    if (!OrigTPL || !OrigTPL->size())
+      return OrigTPL;
+
+    DeclContext *Owner = OrigTPL->getParam(0)->getDeclContext();
+    TemplateDeclInstantiator DeclInstantiator(getSema(),
+                                              /* DeclContext *Owner */ Owner,
+                                              TemplateArgs);
+    DeclInstantiator.setEvaluateConstraints(EvaluateConstraints);
+    return DeclInstantiator.SubstTemplateParams(OrigTPL);
+  }
 
-    concepts::TypeRequirement *
-    TransformTypeRequirement(concepts::TypeRequirement *Req);
-    concepts::ExprRequirement *
-    TransformExprRequirement(concepts::ExprRequirement *Req);
-    concepts::NestedRequirement *
-    TransformNestedRequirement(concepts::NestedRequirement *Req);
-    ExprResult TransformRequiresTypeParams(
-        SourceLocation KWLoc, SourceLocation RBraceLoc, const RequiresExpr *RE,
-        RequiresExprBodyDecl *Body, ArrayRef<ParmVarDecl *> Params,
-        SmallVectorImpl<QualType> &PTypes,
-        SmallVectorImpl<ParmVarDecl *> &TransParams,
-        Sema::ExtParameterInfoBuilder &PInfos);
-  };
-}
+  concepts::TypeRequirement *
+  TransformTypeRequirement(concepts::TypeRequirement *Req);
+  concepts::ExprRequirement *
+  TransformExprRequirement(concepts::ExprRequirement *Req);
+  concepts::NestedRequirement *
+  TransformNestedRequirement(concepts::NestedRequirement *Req);
+  ExprResult TransformRequiresTypeParams(
+      SourceLocation KWLoc, SourceLocation RBraceLoc, const RequiresExpr *RE,
+      RequiresExprBodyDecl *Body, ArrayRef<ParmVarDecl *> Params,
+      SmallVectorImpl<QualType> &PTypes,
+      SmallVectorImpl<ParmVarDecl *> &TransParams,
+      Sema::ExtParameterInfoBuilder &PInfos);
+};
+} // namespace
 
 bool TemplateInstantiator::AlreadyTransformed(QualType T) {
   if (T.isNull())
@@ -1989,8 +1980,8 @@ TemplateInstantiator::TransformFirstQualifierInScope(NamedDecl *D,
   // If the first part of the nested-name-specifier was a template type
   // parameter, instantiate that type parameter down to a tag type.
   if (TemplateTypeParmDecl *TTPD = dyn_cast_or_null<TemplateTypeParmDecl>(D)) {
-    const TemplateTypeParmType *TTP
-      = cast<TemplateTypeParmType>(getSema().Context.getTypeDeclType(TTPD));
+    const TemplateTypeParmType *TTP =
+        cast<TemplateTypeParmType>(getSema().Context.getTypeDeclType(TTPD));
 
     if (TTP->getDepth() < TemplateArgs.getNumLevels()) {
       // FIXME: This needs testing w/ member access expressions.
@@ -2022,12 +2013,11 @@ TemplateInstantiator::TransformFirstQualifierInScope(NamedDecl *D,
   return cast_or_null<NamedDecl>(TransformDecl(Loc, D));
 }
 
-VarDecl *
-TemplateInstantiator::RebuildExceptionDecl(VarDecl *ExceptionDecl,
-                                           TypeSourceInfo *Declarator,
-                                           SourceLocation StartLoc,
-                                           SourceLocation NameLoc,
-                                           IdentifierInfo *Name) {
+VarDecl *TemplateInstantiator::RebuildExceptionDecl(VarDecl *ExceptionDecl,
+                                                    TypeSourceInfo *Declarator,
+                                                    SourceLocation StartLoc,
+                                                    SourceLocation NameLoc,
+                                                    IdentifierInfo *Name) {
   VarDecl *Var = inherited::RebuildExceptionDecl(ExceptionDecl, Declarator,
                                                  StartLoc, NameLoc, Name);
   if (Var)
@@ -2100,8 +2090,8 @@ TemplateName TemplateInstantiator::TransformTemplateName(
     }
   }
 
-  if (SubstTemplateTemplateParmPackStorage *SubstPack
-      = Name.getAsSubstTemplateTemplateParmPack()) {
+  if (SubstTemplateTemplateParmPackStorage *SubstPack =
+          Name.getAsSubstTemplateTemplateParmPack()) {
     if (!getSema().ArgPackSubstIndex)
       return Name;
 
@@ -2118,17 +2108,15 @@ TemplateName TemplateInstantiator::TransformTemplateName(
       FirstQualifierInScope, AllowInjectedClassName);
 }
 
-ExprResult
-TemplateInstantiator::TransformPredefinedExpr(PredefinedExpr *E) {
+ExprResult TemplateInstantiator::TransformPredefinedExpr(PredefinedExpr *E) {
   if (!E->isTypeDependent())
     return E;
 
   return getSema().BuildPredefinedExpr(E->getLocation(), E->getIdentKind());
 }
 
-ExprResult
-TemplateInstantiator::TransformTemplateParmRefExpr(DeclRefExpr *E,
-                                               NonTypeTemplateParmDecl *NTTP) {
+ExprResult TemplateInstantiator::TransformTemplateParmRefExpr(
+    DeclRefExpr *E, NonTypeTemplateParmDecl *NTTP) {
   // If the corresponding template argument is NULL or non-existent, it's
   // because we are performing instantiation from explicitly-specified
   // template arguments in a function template, but there were some
@@ -2156,16 +2144,14 @@ TemplateInstantiator::TransformTemplateParmRefExpr(DeclRefExpr *E,
       TemplateArgs.getAssociatedDecl(NTTP->getDepth());
   UnsignedOrNone PackIndex = std::nullopt;
   if (NTTP->isParameterPack()) {
-    assert(Arg.getKind() == TemplateArgument::Pack &&
-           "Missing argument pack");
+    assert(Arg.getKind() == TemplateArgument::Pack && "Missing argument pack");
 
     if (!getSema().ArgPackSubstIndex) {
       // We have an argument pack, but we can't select a particular argument
       // out of it yet. Therefore, we'll build an expression to hold on to that
       // argument pack.
-      QualType TargetType = SemaRef.SubstType(NTTP->getType(), TemplateArgs,
-                                              E->getLocation(),
-                                              NTTP->getDeclName());
+      QualType TargetType = SemaRef.SubstType(
+          NTTP->getType(), TemplateArgs, E->getLocation(), NTTP->getDeclName());
       if (TargetType.isNull())
         return ExprError();
 
@@ -2303,8 +2289,8 @@ TemplateInstantiator::TransformFunctionParmPackExpr(FunctionParmPackExpr *E) {
   // parameters in the instantiation of the function decl.
   SmallVector<ValueDecl *, 8> Vars;
   Vars.reserve(E->getNumExpansions());
-  for (FunctionParmPackExpr::iterator I = E->begin(), End = E->end();
-       I != End; ++I) {
+  for (FunctionParmPackExpr::iterator I = E->begin(), End = E->end(); I != End;
+       ++I) {
     ValueDecl *D = cast_or_null<ValueDecl>(TransformDecl(E->getExprLoc(), *I));
     if (!D)
       return ExprError();
@@ -2322,8 +2308,8 @@ ExprResult
 TemplateInstantiator::TransformFunctionParmPackRefExpr(DeclRefExpr *E,
                                                        ValueDecl *PD) {
   typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack;
-  llvm::PointerUnion<Decl *, DeclArgumentPack *> *Found
-    = getSema().CurrentInstantiationScope->findInstantiationOf(PD);
+  llvm::PointerUnion<Decl *, DeclArgumentPack *> *Found =
+      getSema().CurrentInstantiationScope->findInstantiationOf(PD);
   assert(Found && "no instantiation for parameter pack");
 
   Decl *TransformedDecl;
@@ -2350,8 +2336,7 @@ TemplateInstantiator::TransformFunctionParmPackRefExpr(DeclRefExpr *E,
                                E->getExprLoc());
 }
 
-ExprResult
-TemplateInstantiator::TransformDeclRefExpr(DeclRefExpr *E) {
+ExprResult TemplateInstantiator::TransformDeclRefExpr(DeclRefExpr *E) {
   NamedDecl *D = E->getDecl();
 
   // Handle references to non-type template parameters and non-type template
@@ -2372,22 +2357,38 @@ TemplateInstantiator::TransformDeclRefExpr(DeclRefExpr *E) {
   return inherited::TransformDeclRefExpr(E);
 }
 
-ExprResult TemplateInstantiator::TransformCXXDefaultArgExpr(
-    CXXDefaultArgExpr *E) {
-  assert(!cast<FunctionDecl>(E->getParam()->getDeclContext())->
-             getDescribedFunctionTemplate() &&
+ExprResult TemplateInstantiator::TransformCXXReflectExpr(CXXReflectExpr *E) {
+
+  // TODO(reflection): add support for NamespaceReference, TemplateReference and
+  // DeclRefExpr
+  switch (E->getKind()) {
+  case ReflectionKind::Type: {
+    TypeSourceInfo *NewT = getDerived().TransformType(
+        static_cast<TypeSourceInfo *>(const_cast<void *>(E->getOpaqueValue())));
+    if (!NewT)
+      return ExprError();
+    return getSema().BuildCXXReflectExpr(E->getOperatorLoc(), NewT);
+  }
+  }
+
+  llvm_unreachable("unknown or unimplemented reflection entity kind");
+  return ExprError();
+}
+
+ExprResult
+TemplateInstantiator::TransformCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
+  assert(!cast<FunctionDecl>(E->getParam()->getDeclContext())
+              ->getDescribedFunctionTemplate() &&
          "Default arg expressions are never formed in dependent cases.");
   return SemaRef.BuildCXXDefaultArgExpr(
       E->getUsedLocation(), cast<FunctionDecl>(E->getParam()->getDeclContext()),
       E->getParam());
 }
 
-template<typename Fn>
-QualType TemplateInstantiator::TransformFunctionProtoType(TypeLocBuilder &TLB,
-                                 FunctionProtoTypeLoc TL,
-                                 CXXRecordDecl *ThisContext,
-                                 Qualifiers ThisTypeQuals,
-                                 Fn TransformExceptionSpec) {
+template <typename Fn>
+QualType TemplateInstantiator::TransformFunctionProtoType(
+    TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext,
+    Qualifiers ThisTypeQuals, Fn TransformExceptionSpec) {
   // If this is a lambda or block, the transformation MUST be done in the
   // CurrentInstantiationScope since it introduces a mapping of
   // the original to the newly created transformed parameters.
@@ -2458,8 +2459,8 @@ TemplateInstantiator::TransformTemplateTypeParmType(TypeLocBuilder &TLB,
       if (BailOutOnIncomplete)
         return QualType();
 
-      TemplateTypeParmTypeLoc NewTL
-        = TLB.push<TemplateTypeParmTypeLoc>(TL.getType());
+      TemplateTypeParmTypeLoc NewTL =
+          TLB.push<TemplateTypeParmTypeLoc>(TL.getType());
       NewTL.setNameLoc(TL.getNameLoc());
       return TL.getType();
     }
@@ -2497,8 +2498,8 @@ TemplateInstantiator::TransformTemplateTypeParmType(TypeLocBuilder &TLB,
         // pack for later substitution.
         QualType Result = getSema().Context.getSubstTemplateTypeParmPackType(
             AssociatedDecl, T->getIndex(), Final, Arg);
-        SubstTemplateTypeParmPackTypeLoc NewTL
-          = TLB.push<SubstTemplateTypeParmPackTypeLoc>(Result);
+        SubstTemplateTypeParmPackTypeLoc NewTL =
+            TLB.push<SubstTemplateTypeParmPackTypeLoc>(Result);
         NewTL.setNameLoc(TL.getNameLoc());
         return Result;
       }
@@ -2639,8 +2640,7 @@ TemplateInstantiator::TransformTypeRequirement(concepts::TypeRequirement *Req) {
     return Req;
   if (Req->isSubstitutionFailure()) {
     if (AlwaysRebuild())
-      return RebuildTypeRequirement(
-              Req->getSubstitutionDiagnostic());
+      return RebuildTypeRequirement(Req->getSubstitutionDiagnostic());
     return Req;
   }
 
@@ -2653,9 +2653,9 @@ TemplateInstantiator::TransformTypeRequirement(concepts::TypeRequirement *Req) {
     return nullptr;
   TypeSourceInfo *TransType = TransformType(Req->getType());
   if (!TransType || Trap.hasErrorOccurred())
-    return RebuildTypeRequirement(createSubstDiag(SemaRef, Info,
-        [&] (llvm::raw_ostream& OS) {
-            Req->getType()->getType().print(OS, SemaRef.getPrintingPolicy());
+    return RebuildTypeRequirement(
+        createSubstDiag(SemaRef, Info, [&](llvm::raw_ostream &OS) {
+          Req->getType()->getType().print(OS, SemaRef.getPrintingPolicy());
         }));
   return RebuildTypeRequirement(TransType);
 }
@@ -2706,10 +2706,11 @@ TemplateInstantiator::TransformExprRequirement(concepts::ExprRequirement *Req) {
       return nullptr;
     TemplateParameterList *TPL = TransformTemplateParameterList(OrigTPL);
     if (!TPL || Trap.hasErrorOccurred())
-      TransRetReq.emplace(createSubstDiag(SemaRef, Info,
-          [&] (llvm::raw_ostream& OS) {
-              RetReq.getTypeConstraint()->getImmediatelyDeclaredConstraint()
-                  ->printPretty(OS, nullptr, SemaRef.getPrintingPolicy());
+      TransRetReq.emplace(
+          createSubstDiag(SemaRef, Info, [&](llvm::raw_ostream &OS) {
+            RetReq.getTypeConstraint()
+                ->getImmediatelyDeclaredConstraint()
+                ->printPretty(OS, nullptr, SemaRef.getPrintingPolicy());
           }));
     else {
       TPLInst.Clear();
@@ -2725,8 +2726,7 @@ TemplateInstantiator::TransformExprRequirement(concepts::ExprRequirement *Req) {
       Req->isSimple(), Req->getNoexceptLoc(), std::move(*TransRetReq));
 }
 
-concepts::NestedRequirement *
-TemplateInstantiator::TransformNestedRequirement(
+concepts::NestedRequirement *TemplateInstantiator::TransformNestedRequirement(
     concepts::NestedRequirement *Req) {
 
   ASTContext &C = SemaRef.Context;
@@ -2798,8 +2798,7 @@ TemplateInstantiator::TransformNestedRequirement(
 
 TypeSourceInfo *Sema::SubstType(TypeSourceInfo *T,
                                 const MultiLevelTemplateArgumentList &Args,
-                                SourceLocation Loc,
-                                DeclarationName Entity,
+                                SourceLocation Loc, DeclarationName Entity,
                                 bool AllowDeducedTST) {
   assert(!CodeSynthesisContexts.empty() &&
          "Cannot perform an instantiation without some context on the "
@@ -2816,8 +2815,7 @@ TypeSourceInfo *Sema::SubstType(TypeSourceInfo *T,
 
 TypeSourceInfo *Sema::SubstType(TypeLoc TL,
                                 const MultiLevelTemplateArgumentList &Args,
-                                SourceLocation Loc,
-                                DeclarationName Entity) {
+                                SourceLocation Loc, DeclarationName Entity) {
   assert(!CodeSynthesisContexts.empty() &&
          "Cannot perform an instantiation without some context on the "
          "instantiation stack");
@@ -2879,7 +2877,8 @@ static bool NeedsInstantiationAsFunctionType(TypeSourceInfo *T) {
   FunctionProtoTypeLoc FP = TL.castAs<FunctionProtoTypeLoc>();
   for (ParmVarDecl *P : FP.getParams()) {
     // This must be synthesized from a typedef.
-    if (!P) continue;
+    if (!P)
+      continue;
 
     // If there are any parameters, a new TypeSourceInfo that refers to the
     // instantiated parameters must be built.
@@ -2889,13 +2888,10 @@ static bool NeedsInstantiationAsFunctionType(TypeSourceInfo *T) {
   return false;
 }
 
-TypeSourceInfo *Sema::SubstFunctionDeclType(TypeSourceInfo *T,
-                                const MultiLevelTemplateArgumentList &Args,
-                                SourceLocation Loc,
-                                DeclarationName Entity,
-                                CXXRecordDecl *ThisContext,
-                                Qualifiers ThisTypeQuals,
-                                bool EvaluateConstraints) {
+TypeSourceInfo *Sema::SubstFunctionDeclType(
+    TypeSourceInfo *T, const MultiLevelTemplateArgumentList &Args,
+    SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext,
+    Qualifiers ThisTypeQuals, bool EvaluateConstraints) {
   assert(!CodeSynthesisContexts.empty() &&
          "Cannot perform an instantiation without some context on the "
          "instantiation stack");
@@ -2922,8 +2918,9 @@ TypeSourceInfo *Sema::SubstFunctionDeclType(TypeSourceInfo *T,
     // instead of rebuilding the function type again later.
     Result = Instantiator.TransformFunctionProtoType(
         TLB, Proto, ThisContext, ThisTypeQuals,
-        [](FunctionProtoType::ExceptionSpecInfo &ESI,
-           bool &Changed) { return false; });
+        [](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
+          return false;
+        });
   } else {
     Result = Instantiator.TransformType(TLB, TL);
   }
@@ -2961,85 +2958,85 @@ void Sema::SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto,
 
 namespace {
 
-  struct GetContainedInventedTypeParmVisitor :
-    public TypeVisitor<GetContainedInventedTypeParmVisitor,
-                       TemplateTypeParmDecl *> {
-    using TypeVisitor<GetContainedInventedTypeParmVisitor,
-                      TemplateTypeParmDecl *>::Visit;
+struct GetContainedInventedTypeParmVisitor
+    : public TypeVisitor<GetContainedInventedTypeParmVisitor,
+                         TemplateTypeParmDecl *> {
+  using TypeVisitor<GetContainedInventedTypeParmVisitor,
+                    TemplateTypeParmDecl *>::Visit;
 
-    TemplateTypeParmDecl *Visit(QualType T) {
-      if (T.isNull())
-        return nullptr;
-      return Visit(T.getTypePtr());
-    }
-    // The deduced type itself.
-    TemplateTypeParmDecl *VisitTemplateTypeParmType(
-        const TemplateTypeParmType *T) {
-      if (!T->getDecl() || !T->getDecl()->isImplicit())
-        return nullptr;
-      return T->getDecl();
-    }
+  TemplateTypeParmDecl *Visit(QualType T) {
+    if (T.isNull())
+      return nullptr;
+    return Visit(T.getTypePtr());
+  }
+  // The deduced type itself.
+  TemplateTypeParmDecl *
+  VisitTemplateTypeParmType(const TemplateTypeParmType *T) {
+    if (!T->getDecl() || !T->getDecl()->isImplicit())
+      return nullptr;
+    return T->getDecl();
+  }
 
-    // Only these types can contain 'auto' types, and subsequently be replaced
-    // by references to invented parameters.
+  // Only these types can contain 'auto' types, and subsequently be replaced
+  // by references to invented parameters.
 
-    TemplateTypeParmDecl *VisitPointerType(const PointerType *T) {
-      return Visit(T->getPointeeType());
-    }
+  TemplateTypeParmDecl *VisitPointerType(const PointerType *T) {
+    return Visit(T->getPointeeType());
+  }
 
-    TemplateTypeParmDecl *VisitBlockPointerType(const BlockPointerType *T) {
-      return Visit(T->getPointeeType());
-    }
+  TemplateTypeParmDecl *VisitBlockPointerType(const BlockPointerType *T) {
+    return Visit(T->getPointeeType());
+  }
 
-    TemplateTypeParmDecl *VisitReferenceType(const ReferenceType *T) {
-      return Visit(T->getPointeeTypeAsWritten());
-    }
+  TemplateTypeParmDecl *VisitReferenceType(const ReferenceType *T) {
+    return Visit(T->getPointeeTypeAsWritten());
+  }
 
-    TemplateTypeParmDecl *VisitMemberPointerType(const MemberPointerType *T) {
-      return Visit(T->getPointeeType());
-    }
+  TemplateTypeParmDecl *VisitMemberPointerType(const MemberPointerType *T) {
+    return Visit(T->getPointeeType());
+  }
 
-    TemplateTypeParmDecl *VisitArrayType(const ArrayType *T) {
-      return Visit(T->getElementType());
-    }
+  TemplateTypeParmDecl *VisitArrayType(const ArrayType *T) {
+    return Visit(T->getElementType());
+  }
 
-    TemplateTypeParmDecl *VisitDependentSizedExtVectorType(
-      const DependentSizedExtVectorType *T) {
-      return Visit(T->getElementType());
-    }
+  TemplateTypeParmDecl *
+  VisitDependentSizedExtVectorType(const DependentSizedExtVectorType *T) {
+    return Visit(T->getElementType());
+  }
 
-    TemplateTypeParmDecl *VisitVectorType(const VectorType *T) {
-      return Visit(T->getElementType());
-    }
+  TemplateTypeParmDecl *VisitVectorType(const VectorType *T) {
+    return Visit(T->getElementType());
+  }
 
-    TemplateTypeParmDecl *VisitFunctionProtoType(const FunctionProtoType *T) {
-      return VisitFunctionType(T);
-    }
+  TemplateTypeParmDecl *VisitFunctionProtoType(const FunctionProtoType *T) {
+    return VisitFunctionType(T);
+  }
 
-    TemplateTypeParmDecl *VisitFunctionType(const FunctionType *T) {
-      return Visit(T->getReturnType());
-    }
+  TemplateTypeParmDecl *VisitFunctionType(const FunctionType *T) {
+    return Visit(T->getReturnType());
+  }
 
-    TemplateTypeParmDecl *VisitParenType(const ParenType *T) {
-      return Visit(T->getInnerType());
-    }
+  TemplateTypeParmDecl *VisitParenType(const ParenType *T) {
+    return Visit(T->getInnerType());
+  }
 
-    TemplateTypeParmDecl *VisitAttributedType(const AttributedType *T) {
-      return Visit(T->getModifiedType());
-    }
+  TemplateTypeParmDecl *VisitAttributedType(const AttributedType *T) {
+    return Visit(T->getModifiedType());
+  }
 
-    TemplateTypeParmDecl *VisitMacroQualifiedType(const MacroQualifiedType *T) {
-      return Visit(T->getUnderlyingType());
-    }
+  TemplateTypeParmDecl *VisitMacroQualifiedType(const MacroQualifiedType *T) {
+    return Visit(T->getUnderlyingType());
+  }
 
-    TemplateTypeParmDecl *VisitAdjustedType(const AdjustedType *T) {
-      return Visit(T->getOriginalType());
-    }
+  TemplateTypeParmDecl *VisitAdjustedType(const AdjustedType *T) {
+    return Visit(T->getOriginalType());
+  }
 
-    TemplateTypeParmDecl *VisitPackExpansionType(const PackExpansionType *T) {
-      return Visit(T->getPattern());
-    }
-  };
+  TemplateTypeParmDecl *VisitPackExpansionType(const PackExpansionType *T) {
+    return Visit(T->getPattern());
+  }
+};
 
 } // namespace
 
@@ -3216,10 +3213,8 @@ bool Sema::SubstParmTypes(
 }
 
 bool Sema::SubstDefaultArgument(
-    SourceLocation Loc,
-    ParmVarDecl *Param,
-    const MultiLevelTemplateArgumentList &TemplateArgs,
-    bool ForCallExpr) {
+    SourceLocation Loc, ParmVarDecl *Param,
+    const MultiLevelTemplateArgumentList &TemplateArgs, bool ForCallExpr) {
   FunctionDecl *FD = cast<FunctionDecl>(Param->getDeclContext());
   Expr *PatternExpr = Param->getUninstantiatedDefaultArg();
 
@@ -3270,8 +3265,8 @@ bool Sema::SubstDefaultArgument(
 
   if (ForCallExpr) {
     // Check the expression as an initializer for the parameter.
-    InitializedEntity Entity
-      = InitializedEntity::InitializeParameter(Context, Param);
+    InitializedEntity Entity =
+        InitializedEntity::InitializeParameter(Context, Param);
     InitializationKind Kind = InitializationKind::CreateCopy(
         Param->getLocation(),
         /*FIXME:EqualLoc*/ PatternExpr->getBeginLoc());
@@ -3291,7 +3286,7 @@ bool Sema::SubstDefaultArgument(
     Result = ConvertParamDefaultArgument(Param, Result.getAs<Expr>(), EqualLoc);
   }
   if (Result.isInvalid())
-      return true;
+    return true;
 
   // Remember the instantiated default argument.
   Param->setDefaultArg(Result.getAs<Expr>());
@@ -3365,12 +3360,11 @@ PreparePackForExpansion(Sema &S, const CXXBaseSpecifier &Base,
   return false;
 }
 
-bool
-Sema::SubstBaseSpecifiers(CXXRecordDecl *Instantiation,
-                          CXXRecordDecl *Pattern,
-                          const MultiLevelTemplateArgumentList &TemplateArgs) {
+bool Sema::SubstBaseSpecifiers(
+    CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
+    const MultiLevelTemplateArgumentList &TemplateArgs) {
   bool Invalid = false;
-  SmallVector<CXXBaseSpecifier*, 4> InstantiatedBases;
+  SmallVector<CXXBaseSpecifier *, 4> InstantiatedBases;
   for (const auto &Base : Pattern->bases()) {
     if (!Base.getType()->isDependentType()) {
       if (const CXXRecordDecl *RD = Base.getType()->getAsCXXRecordDecl()) {
@@ -3428,10 +3422,9 @@ Sema::SubstBaseSpecifiers(CXXRecordDecl *Instantiation,
           SubstType(BaseTypeLoc, *ArgsForSubst,
                     Base.getSourceRange().getBegin(), DeclarationName());
     } else {
-      BaseTypeLoc = SubstType(Base.getTypeSourceInfo(),
-                              TemplateArgs,
-                              Base.getSourceRange().getBegin(),
-                              DeclarationName());
+      BaseTypeLoc =
+          SubstType(Base.getTypeSourceInfo(), TemplateArgs,
+                    Base.getSourceRange().getBegin(), DeclarationName());
     }
 
     if (!BaseTypeLoc) {
@@ -3439,13 +3432,9 @@ Sema::SubstBaseSpecifiers(CXXRecordDecl *Instantiation,
       continue;
     }
 
-    if (CXXBaseSpecifier *InstantiatedBase
-          = CheckBaseSpecifier(Instantiation,
-                               Base.getSourceRange(),
-                               Base.isVirtual(),
-                               Base.getAccessSpecifierAsWritten(),
-                               BaseTypeLoc,
-                               EllipsisLoc))
+    if (CXXBaseSpecifier *InstantiatedBase = CheckBaseSpecifier(
+            Instantiation, Base.getSourceRange(), Base.isVirtual(),
+            Base.getAccessSpecifierAsWritten(), BaseTypeLoc, EllipsisLoc))
       InstantiatedBases.push_back(InstantiatedBase);
     else
       Invalid = true;
@@ -3459,14 +3448,15 @@ Sema::SubstBaseSpecifiers(CXXRecordDecl *Instantiation,
 
 // Defined via #include from SemaTemplateInstantiateDecl.cpp
 namespace clang {
-  namespace sema {
-    Attr *instantiateTemplateAttribute(const Attr *At, ASTContext &C, Sema &S,
-                            const MultiLevelTemplateArgumentList &TemplateArgs);
-    Attr *instantiateTemplateAttributeForDecl(
-        const Attr *At, ASTContext &C, Sema &S,
-        const MultiLevelTemplateArgumentList &TemplateArgs);
-  }
-}
+namespace sema {
+Attr *instantiateTemplateAttribute(
+    const Attr *At, ASTContext &C, Sema &S,
+    const MultiLevelTemplateArgumentList &TemplateArgs);
+Attr *instantiateTemplateAttributeForDecl(
+    const Attr *At, ASTContext &C, Sema &S,
+    const MultiLevelTemplateArgumentList &TemplateArgs);
+} // namespace sema
+} // namespace clang
 
 bool Sema::InstantiateClass(SourceLocation PointOfInstantiation,
                             CXXRecordDecl *Instantiation,
@@ -3488,11 +3478,12 @@ bool Sema::InstantiateClassImpl(
     CXXRecordDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs,
     TemplateSpecializationKind TSK, bool Complain) {
 
-  CXXRecordDecl *PatternDef
-    = cast_or_null<CXXRecordDecl>(Pattern->getDefinition());
-  if (DiagnoseUninstantiableTemplate(PointOfInstantiation, Instantiation,
-                                Instantiation->getInstantiatedFromMemberClass(),
-                                     Pattern, PatternDef, TSK, Complain))
+  CXXRecordDecl *PatternDef =
+      cast_or_null<CXXRecordDecl>(Pattern->getDefinition());
+  if (DiagnoseUninstantiableTemplate(
+          PointOfInstantiation, Instantiation,
+          Instantiation->getInstantiatedFromMemberClass(), Pattern, PatternDef,
+          TSK, Complain))
     return true;
 
   llvm::TimeTraceScope TimeScope("InstantiateClass", [&]() {
@@ -3511,12 +3502,12 @@ bool Sema::InstantiateClassImpl(
   Pattern = PatternDef;
 
   // Record the point of instantiation.
-  if (MemberSpecializationInfo *MSInfo
-        = Instantiation->getMemberSpecializationInfo()) {
+  if (MemberSpecializationInfo *MSInfo =
+          Instantiation->getMemberSpecializationInfo()) {
     MSInfo->setTemplateSpecializationKind(TSK);
     MSInfo->setPointOfInstantiation(PointOfInstantiation);
-  } else if (ClassTemplateSpecializationDecl *Spec
-        = dyn_cast<ClassTemplateSpecializationDecl>(Instantiation)) {
+  } else if (ClassTemplateSpecializationDecl *Spec =
+                 dyn_cast<ClassTemplateSpecializationDecl>(Instantiation)) {
     Spec->setTemplateSpecializationKind(TSK);
     Spec->setPointOfInstantiation(PointOfInstantiation);
   }
@@ -3537,7 +3528,8 @@ bool Sema::InstantiateClassImpl(
   // If this is an instantiation of a local class, merge this local
   // instantiation scope with the enclosing scope. Otherwise, every
   // instantiation of a class has its own local instantiation scope.
-  bool MergeWithParentScope = !Instantiation->isDefinedOutsideFunctionOrMethod();
+  bool MergeWithParentScope =
+      !Instantiation->isDefinedOutsideFunctionOrMethod();
   LocalInstantiationScope Scope(*this, MergeWithParentScope);
 
   // Some class state isn't processed immediately but delayed till class
@@ -3565,7 +3557,7 @@ bool Sema::InstantiateClassImpl(
 
   TemplateDeclInstantiator Instantiator(*this, Instantiation, TemplateArgs);
   Instantiator.setEvaluateConstraints(false);
-  SmallVector<Decl*, 4> Fields;
+  SmallVector<Decl *, 4> Fields;
   // Delay instantiation of late parsed attributes.
   LateInstantiatedAttrVec LateAttrs;
   Instantiator.enableLateAttributeInstantiation(&LateAttrs);
@@ -3608,7 +3600,8 @@ bool Sema::InstantiateClassImpl(
         // Record a point of instantiation for this implicit instantiation.
         if (TSK == TSK_ImplicitInstantiation && !Enum->isScoped() &&
             Enum->isCompleteDefinition()) {
-          MemberSpecializationInfo *MSInfo =Enum->getMemberSpecializationInfo();
+          MemberSpecializationInfo *MSInfo =
+              Enum->getMemberSpecializationInfo();
           assert(MSInfo && "no spec info for member enum specialization");
           MSInfo->setTemplateSpecializationKind(TSK_ImplicitInstantiation);
           MSInfo->setPointOfInstantiation(PointOfInstantiation);
@@ -3650,7 +3643,8 @@ bool Sema::InstantiateClassImpl(
   // Instantiate late parsed attributes, and attach them to their decls.
   // See Sema::InstantiateAttrs
   for (LateInstantiatedAttrVec::iterator I = LateAttrs.begin(),
-       E = LateAttrs.end(); I != E; ++I) {
+                                         E = LateAttrs.end();
+       I != E; ++I) {
     assert(CurrentInstantiationScope == Instantiator.getStartingScope());
     CurrentInstantiationScope = I->Scope;
 
@@ -3661,7 +3655,7 @@ bool Sema::InstantiateClassImpl(
                                ND->isCXXInstanceMember());
 
     Attr *NewAttr =
-      instantiateTemplateAttribute(I->TmplAttr, Context, *this, TemplateArgs);
+        instantiateTemplateAttribute(I->TmplAttr, Context, *this, TemplateArgs);
     if (NewAttr)
       I->NewDecl->addAttr(NewAttr);
     LocalInstantiationScope::deleteScopes(I->Scope,
@@ -3688,8 +3682,8 @@ bool Sema::InstantiateClassImpl(
     // Instantiate any out-of-line class template partial
     // specializations now.
     for (TemplateDeclInstantiator::delayed_partial_spec_iterator
-              P = Instantiator.delayed_partial_spec_begin(),
-           PEnd = Instantiator.delayed_partial_spec_end();
+             P = Instantiator.delayed_partial_spec_begin(),
+             PEnd = Instantiator.delayed_partial_spec_end();
          P != PEnd; ++P) {
       if (!Instantiator.InstantiateClassTemplatePartialSpecialization(
               P->first, P->second)) {
@@ -3701,8 +3695,8 @@ bool Sema::InstantiateClassImpl(
     // Instantiate any out-of-line variable template partial
     // specializations now.
     for (TemplateDeclInstantiator::delayed_var_partial_spec_iterator
-              P = Instantiator.delayed_var_partial_spec_begin(),
-           PEnd = Instantiator.delayed_var_partial_spec_end();
+             P = Instantiator.delayed_var_partial_spec_begin(),
+             PEnd = Instantiator.delayed_var_partial_spec_end();
          P != PEnd; ++P) {
       if (!Instantiator.InstantiateVarTemplatePartialSpecialization(
               P->first, P->second)) {
@@ -3743,15 +3737,16 @@ bool Sema::InstantiateEnum(SourceLocation PointOfInstantiation,
 #endif
 
   EnumDecl *PatternDef = Pattern->getDefinition();
-  if (DiagnoseUninstantiableTemplate(PointOfInstantiation, Instantiation,
-                                 Instantiation->getInstantiatedFromMemberEnum(),
-                                     Pattern, PatternDef, TSK,/*Complain*/true))
+  if (DiagnoseUninstantiableTemplate(
+          PointOfInstantiation, Instantiation,
+          Instantiation->getInstantiatedFromMemberEnum(), Pattern, PatternDef,
+          TSK, /*Complain*/ true))
     return true;
   Pattern = PatternDef;
 
   // Record the point of instantiation.
-  if (MemberSpecializationInfo *MSInfo
-        = Instantiation->getMemberSpecializationInfo()) {
+  if (MemberSpecializationInfo *MSInfo =
+          Instantiation->getMemberSpecializationInfo()) {
     MSInfo->setTemplateSpecializationKind(TSK);
     MSInfo->setPointOfInstantiation(PointOfInstantiation);
   }
@@ -3773,7 +3768,7 @@ bool Sema::InstantiateEnum(SourceLocation PointOfInstantiation,
   EnterExpressionEvaluationContext EvalContext(
       *this, Sema::ExpressionEvaluationContext::PotentiallyEvaluated);
 
-  LocalInstantiationScope Scope(*this, /*MergeWithParentScope*/true);
+  LocalInstantiationScope Scope(*this, /*MergeWithParentScope*/ true);
 
   // Pull attributes from the pattern onto the instantiation.
   InstantiateAttrs(TemplateArgs, Pattern, Instantiation);
@@ -3857,13 +3852,13 @@ bool Sema::InstantiateInClassInitializer(
 }
 
 namespace {
-  /// A partial specialization whose template arguments have matched
-  /// a given template-id.
-  struct PartialSpecMatchResult {
-    ClassTemplatePartialSpecializationDecl *Partial;
-    TemplateArgumentList *Args;
-  };
-}
+/// A partial specialization whose template arguments have matched
+/// a given template-id.
+struct PartialSpecMatchResult {
+  ClassTemplatePartialSpecializationDecl *Partial;
+  TemplateArgumentList *Args;
+};
+} // namespace
 
 bool Sema::usesPartialOrExplicitSpecialization(
     SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec) {
@@ -3982,7 +3977,7 @@ static ActionResult<CXXRecordDecl *> getPatternForClassTemplateSpecialization(
         //      specializations, then the use of the class template is
         //      ambiguous and the program is ill-formed.
         for (SmallVectorImpl<MatchResult>::iterator P = Best + 1,
-                                                 PEnd = Matched.end();
+                                                    PEnd = Matched.end();
              P != PEnd; ++P) {
           if (S.getMoreSpecializedPartialSpecialization(
                   P->Partial, Best->Partial, PointOfInstantiation) ==
@@ -3994,7 +3989,7 @@ static ActionResult<CXXRecordDecl *> getPatternForClassTemplateSpecialization(
         // the others.
         bool Ambiguous = false;
         for (SmallVectorImpl<MatchResult>::iterator P = Matched.begin(),
-                                                 PEnd = Matched.end();
+                                                    PEnd = Matched.end();
              P != PEnd; ++P) {
           if (P != Best && S.getMoreSpecializedPartialSpecialization(
                                P->Partial, Best->Partial,
@@ -4014,7 +4009,7 @@ static ActionResult<CXXRecordDecl *> getPatternForClassTemplateSpecialization(
 
           // Print the matching partial specializations.
           for (SmallVectorImpl<MatchResult>::iterator P = Matched.begin(),
-                                                   PEnd = Matched.end();
+                                                      PEnd = Matched.end();
                P != PEnd; ++P)
             S.Diag(P->Partial->getLocation(), diag::note_partial_spec_match)
                 << S.getTemplateArgumentBindingsText(
@@ -4105,11 +4100,10 @@ bool Sema::InstantiateClassTemplateSpecialization(
   return Err;
 }
 
-void
-Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation,
-                              CXXRecordDecl *Instantiation,
-                        const MultiLevelTemplateArgumentList &TemplateArgs,
-                              TemplateSpecializationKind TSK) {
+void Sema::InstantiateClassMembers(
+    SourceLocation PointOfInstantiation, CXXRecordDecl *Instantiation,
+    const MultiLevelTemplateArgumentList &TemplateArgs,
+    TemplateSpecializationKind TSK) {
   // FIXME: We need to notify the ASTMutationListener that we did all of these
   // things, in case we have an explicit instantiation definition in a PCM, a
   // module, or preamble, and the declaration is in an imported AST.
@@ -4178,15 +4172,14 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation,
 
         MemberSpecializationInfo *MSInfo = Var->getMemberSpecializationInfo();
         assert(MSInfo && "No member specialization information?");
-        if (MSInfo->getTemplateSpecializationKind()
-                                                 == TSK_ExplicitSpecialization)
+        if (MSInfo->getTemplateSpecializationKind() ==
+            TSK_ExplicitSpecialization)
           continue;
 
-        if (CheckSpecializationInstantiationRedecl(PointOfInstantiation, TSK,
-                                                   Var,
-                                        MSInfo->getTemplateSpecializationKind(),
-                                              MSInfo->getPointOfInstantiation(),
-                                                   SuppressNew) ||
+        if (CheckSpecializationInstantiationRedecl(
+                PointOfInstantiation, TSK, Var,
+                MSInfo->getTemplateSpecializationKind(),
+                MSInfo->getPointOfInstantiation(), SuppressNew) ||
             SuppressNew)
           continue;
 
@@ -4222,8 +4215,7 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation,
       MemberSpecializationInfo *MSInfo = Record->getMemberSpecializationInfo();
       assert(MSInfo && "No member specialization information?");
 
-      if (MSInfo->getTemplateSpecializationKind()
-                                                == TSK_ExplicitSpecialization)
+      if (MSInfo->getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
         continue;
 
       if (Context.getTargetInfo().getTriple().isOSWindows() &&
@@ -4237,11 +4229,10 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation,
         continue;
       }
 
-      if (CheckSpecializationInstantiationRedecl(PointOfInstantiation, TSK,
-                                                 Record,
-                                        MSInfo->getTemplateSpecializationKind(),
-                                              MSInfo->getPointOfInstantiation(),
-                                                 SuppressNew) ||
+      if (CheckSpecializationInstantiationRedecl(
+              PointOfInstantiation, TSK, Record,
+              MSInfo->getTemplateSpecializationKind(),
+              MSInfo->getPointOfInstantiation(), SuppressNew) ||
           SuppressNew)
         continue;
 
@@ -4264,8 +4255,7 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation,
           continue;
         }
 
-        InstantiateClass(PointOfInstantiation, Record, Pattern,
-                         TemplateArgs,
+        InstantiateClass(PointOfInstantiation, Record, Pattern, TemplateArgs,
                          TSK);
       } else {
         if (TSK == TSK_ExplicitInstantiationDefinition &&
@@ -4284,14 +4274,13 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation,
       MemberSpecializationInfo *MSInfo = Enum->getMemberSpecializationInfo();
       assert(MSInfo && "No member specialization information?");
 
-      if (MSInfo->getTemplateSpecializationKind()
-            == TSK_ExplicitSpecialization)
+      if (MSInfo->getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
         continue;
 
       if (CheckSpecializationInstantiationRedecl(
-            PointOfInstantiation, TSK, Enum,
-            MSInfo->getTemplateSpecializationKind(),
-            MSInfo->getPointOfInstantiation(), SuppressNew) ||
+              PointOfInstantiation, TSK, Enum,
+              MSInfo->getTemplateSpecializationKind(),
+              MSInfo->getPointOfInstantiation(), SuppressNew) ||
           SuppressNew)
         continue;
 
@@ -4331,11 +4320,10 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation,
   }
 }
 
-void
-Sema::InstantiateClassTemplateSpecializationMembers(
-                                           SourceLocation PointOfInstantiation,
-                            ClassTemplateSpecializationDecl *ClassTemplateSpec,
-                                               TemplateSpecializationKind TSK) {
+void Sema::InstantiateClassTemplateSpecializationMembers(
+    SourceLocation PointOfInstantiation,
+    ClassTemplateSpecializationDecl *ClassTemplateSpec,
+    TemplateSpecializationKind TSK) {
   // C++0x [temp.explicit]p7:
   //   An explicit instantiation that names a class template
   //   specialization is an explicit instantion of the same kind
@@ -4345,17 +4333,15 @@ Sema::InstantiateClassTemplateSpecializationMembers(
   //   containing the explicit instantiation, except as described
   //   below.
   InstantiateClassMembers(PointOfInstantiation, ClassTemplateSpec,
-                          getTemplateInstantiationArgs(ClassTemplateSpec),
-                          TSK);
+                          getTemplateInstantiationArgs(ClassTemplateSpec), TSK);
 }
 
-StmtResult
-Sema::SubstStmt(Stmt *S, const MultiLevelTemplateArgumentList &TemplateArgs) {
+StmtResult Sema::SubstStmt(Stmt *S,
+                           const MultiLevelTemplateArgumentList &TemplateArgs) {
   if (!S)
     return S;
 
-  TemplateInstantiator Instantiator(*this, TemplateArgs,
-                                    SourceLocation(),
+  TemplateInstantiator Instantiator(*this, TemplateArgs, SourceLocation(),
                                     DeclarationName());
   return Instantiator.TransformStmt(S);
 }
@@ -4388,13 +4374,12 @@ bool Sema::SubstTemplateArgumentsInParameterMapping(
   return Instantiator.TransformTemplateArguments(Args.begin(), Args.end(), Out);
 }
 
-ExprResult
-Sema::SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs) {
+ExprResult Sema::SubstExpr(Expr *E,
+                           const MultiLevelTemplateArgumentList &TemplateArgs) {
   if (!E)
     return E;
 
-  TemplateInstantiator Instantiator(*this, TemplateArgs,
-                                    SourceLocation(),
+  TemplateInstantiator Instantiator(*this, TemplateArgs, SourceLocation(),
                                     DeclarationName());
   return Instantiator.TransformExpr(E);
 }
@@ -4572,9 +4557,10 @@ ExprResult Sema::SubstConceptTemplateArguments(
   return Res;
 }
 
-ExprResult Sema::SubstInitializer(Expr *Init,
-                          const MultiLevelTemplateArgumentList &TemplateArgs,
-                          bool CXXDirectInit) {
+ExprResult
+Sema::SubstInitializer(Expr *Init,
+                       const MultiLevelTemplateArgumentList &TemplateArgs,
+                       bool CXXDirectInit) {
   TemplateInstantiator Instantiator(*this, TemplateArgs, SourceLocation(),
                                     DeclarationName());
   return Instantiator.TransformInitializer(Init, CXXDirectInit);
@@ -4586,16 +4572,15 @@ bool Sema::SubstExprs(ArrayRef<Expr *> Exprs, bool IsCall,
   if (Exprs.empty())
     return false;
 
-  TemplateInstantiator Instantiator(*this, TemplateArgs,
-                                    SourceLocation(),
+  TemplateInstantiator Instantiator(*this, TemplateArgs, SourceLocation(),
                                     DeclarationName());
-  return Instantiator.TransformExprs(Exprs.data(), Exprs.size(),
-                                     IsCall, Outputs);
+  return Instantiator.TransformExprs(Exprs.data(), Exprs.size(), IsCall,
+                                     Outputs);
 }
 
-NestedNameSpecifierLoc
-Sema::SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
-                        const MultiLevelTemplateArgumentList &TemplateArgs) {
+NestedNameSpecifierLoc Sema::SubstNestedNameSpecifierLoc(
+    NestedNameSpecifierLoc NNS,
+    const MultiLevelTemplateArgumentList &TemplateArgs) {
   if (!NNS)
     return NestedNameSpecifierLoc();
 
@@ -4604,9 +4589,9 @@ Sema::SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
   return Instantiator.TransformNestedNameSpecifierLoc(NNS);
 }
 
-DeclarationNameInfo
-Sema::SubstDeclarationNameInfo(const DeclarationNameInfo &NameInfo,
-                         const MultiLevelTemplateArgumentList &TemplateArgs) {
+DeclarationNameInfo Sema::SubstDeclarationNameInfo(
+    const DeclarationNameInfo &NameInfo,
+    const MultiLevelTemplateArgumentList &TemplateArgs) {
   TemplateInstantiator Instantiator(*this, TemplateArgs, NameInfo.getLoc(),
                                     NameInfo.getName());
   return Instantiator.TransformDeclarationNameInfo(NameInfo);
@@ -4754,13 +4739,13 @@ bool LocalInstantiationScope::isLocalPackExpansion(const Decl *D) {
   return false;
 }
 
-void LocalInstantiationScope::SetPartiallySubstitutedPack(NamedDecl *Pack,
-                                          const TemplateArgument *ExplicitArgs,
-                                                    unsigned NumExplicitArgs) {
+void LocalInstantiationScope::SetPartiallySubstitutedPack(
+    NamedDecl *Pack, const TemplateArgument *ExplicitArgs,
+    unsigned NumExplicitArgs) {
   assert((!PartiallySubstitutedPack || PartiallySubstitutedPack == Pack) &&
          "Already have a partially-substituted pack");
-  assert((!PartiallySubstitutedPack
-          || NumArgsInPartiallySubstitutedPack == NumExplicitArgs) &&
+  assert((!PartiallySubstitutedPack ||
+          NumArgsInPartiallySubstitutedPack == NumExplicitArgs) &&
          "Wrong number of arguments in partially-substituted pack");
   PartiallySubstitutedPack = Pack;
   ArgsInPartiallySubstitutedPack = ExplicitArgs;
@@ -4768,8 +4753,7 @@ void LocalInstantiationScope::SetPartiallySubstitutedPack(NamedDecl *Pack,
 }
 
 NamedDecl *LocalInstantiationScope::getPartiallySubstitutedPack(
-                                         const TemplateArgument **ExplicitArgs,
-                                              unsigned *NumExplicitArgs) const {
+    const TemplateArgument **ExplicitArgs, unsigned *NumExplicitArgs) const {
   if (ExplicitArgs)
     *ExplicitArgs = nullptr;
   if (NumExplicitArgs)
diff --git a/clang/test/Sema/reflection-meta-info.pass.cpp b/clang/test/Sema/reflection-meta-info.pass.cpp
index d12c2c8c8620c..62922d84e057f 100644
--- a/clang/test/Sema/reflection-meta-info.pass.cpp
+++ b/clang/test/Sema/reflection-meta-info.pass.cpp
@@ -2,10 +2,20 @@
 
 using info = decltype(^^int);
 
+template <auto R>
+consteval auto f1() {
+  return R;
+}
+
+template <decltype(^^int) R>
+consteval auto f2() {
+  return R;
+}
+
 consteval void test()
 {
     constexpr auto r = ^^int;
-    constexpr auto q = ^^int;
+    constexpr auto q = ^^float;
 
     static_assert(__is_same(decltype(^^int), info));
     static_assert(__is_same(decltype(^^float), info));
@@ -27,16 +37,24 @@ consteval void test()
     static_assert(__is_same(decltype(^^double), decltype(^^float)));
 
     static_assert(!__is_same(decltype(^^int), int));
+    static_assert(__is_scalar(info));
+
+    static_assert(f1< ^^int >() == ^^int);
+    static_assert(f1< ^^float>() != ^^int);
+
+    static_assert(f2<r>() == ^^int);
+    static_assert(f2<^^float>() != ^^int);
 
     static_assert(sizeof(^^int) == sizeof(^^float));
     static_assert(sizeof(^^int) == 8);
+    static_assert(alignof(^^int) == 1);
 
 
     static_assert(^^int == ^^int);
     static_assert(^^int != ^^float);
     static_assert(^^float != ^^int);
     static_assert(!(^^float == ^^int));
-    static_assert(r == q);
+    static_assert(r != q);
 
     int a;
     static_assert(^^int == ^^decltype(a));

>From 5a934e593b8d09cf77b4f0ba081464d8939dd24d Mon Sep 17 00:00:00 2001
From: changkhothuychung <nhat7203 at gmail.com>
Date: Mon, 13 Apr 2026 17:52:30 -0400
Subject: [PATCH 21/23] some cleanup

---
 clang/lib/Sema/SemaTemplate.cpp            | 1299 ++++++++--------
 clang/lib/Sema/SemaTemplateInstantiate.cpp | 1556 ++++++++++----------
 2 files changed, 1467 insertions(+), 1388 deletions(-)

diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index fb57b5d5e2e70..aa72cb8fa2895 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -50,11 +50,10 @@ using namespace sema;
 
 // Exported for use by Parser.
 SourceRange
-clang::getTemplateParamsRange(TemplateParameterList const *const *Ps,
+clang::getTemplateParamsRange(TemplateParameterList const * const *Ps,
                               unsigned N) {
-  if (!N)
-    return SourceRange();
-  return SourceRange(Ps[0]->getTemplateLoc(), Ps[N - 1]->getRAngleLoc());
+  if (!N) return SourceRange();
+  return SourceRange(Ps[0]->getTemplateLoc(), Ps[N-1]->getRAngleLoc());
 }
 
 unsigned Sema::getTemplateDepth(Scope *S) const {
@@ -176,11 +175,15 @@ bool Sema::hasAnyAcceptableTemplateNames(LookupResult &R,
   return false;
 }
 
-TemplateNameKind
-Sema::isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword,
-                     const UnqualifiedId &Name, ParsedType ObjectTypePtr,
-                     bool EnteringContext, TemplateTy &TemplateResult,
-                     bool &MemberOfUnknownSpecialization, bool Disambiguation) {
+TemplateNameKind Sema::isTemplateName(Scope *S,
+                                      CXXScopeSpec &SS,
+                                      bool hasTemplateKeyword,
+                                      const UnqualifiedId &Name,
+                                      ParsedType ObjectTypePtr,
+                                      bool EnteringContext,
+                                      TemplateTy &TemplateResult,
+                                      bool &MemberOfUnknownSpecialization,
+                                      bool Disambiguation) {
   assert(getLangOpts().CPlusPlus && "No template names in C!");
 
   DeclarationName TName;
@@ -193,7 +196,7 @@ Sema::isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword,
 
   case UnqualifiedIdKind::IK_OperatorFunctionId:
     TName = Context.DeclarationNames.getCXXOperatorName(
-        Name.OperatorFunctionId.Operator);
+                                              Name.OperatorFunctionId.Operator);
     break;
 
   case UnqualifiedIdKind::IK_LiteralOperatorId:
@@ -336,8 +339,7 @@ bool Sema::isDeductionGuideName(Scope *S, const IdentifierInfo &Name,
                          /*EnteringContext*/ false))
     return false;
 
-  if (R.empty())
-    return false;
+  if (R.empty()) return false;
   if (R.isAmbiguous()) {
     // FIXME: Diagnose an ambiguity if we find at least one template.
     R.suppressDiagnostics();
@@ -359,7 +361,8 @@ bool Sema::isDeductionGuideName(Scope *S, const IdentifierInfo &Name,
 }
 
 bool Sema::DiagnoseUnknownTemplateName(const IdentifierInfo &II,
-                                       SourceLocation IILoc, Scope *S,
+                                       SourceLocation IILoc,
+                                       Scope *S,
                                        const CXXScopeSpec *SS,
                                        TemplateTy &SuggestedTemplate,
                                        TemplateNameKind &SuggestedKind) {
@@ -539,8 +542,8 @@ bool Sema::LookupTemplateName(LookupResult &Found, Scope *S, CXXScopeSpec &SS,
           bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
                                   Name.getAsString() == CorrectedStr;
           diagnoseTypo(Corrected, PDiag(diag::err_no_member_template_suggest)
-                                      << Name << LookupCtx << DroppedSpecifier
-                                      << SS.getRange());
+                                    << Name << LookupCtx << DroppedSpecifier
+                                    << SS.getRange());
         } else {
           diagnoseTypo(Corrected, PDiag(diag::err_no_template_suggest) << Name);
         }
@@ -609,10 +612,11 @@ bool Sema::LookupTemplateName(LookupResult &Found, Scope *S, CXXScopeSpec &SS,
               OuterTemplate->getCanonicalDecl()) {
         Diag(Found.getNameLoc(),
              diag::ext_nested_name_member_ref_lookup_ambiguous)
-            << Found.getLookupName() << ObjectType;
+          << Found.getLookupName()
+          << ObjectType;
         Diag(Found.getRepresentativeDecl()->getLocation(),
              diag::note_ambig_member_ref_object_type)
-            << ObjectType;
+          << ObjectType;
         Diag(FoundOuter.getFoundDecl()->getLocation(),
              diag::note_ambig_member_ref_scope);
 
@@ -709,13 +713,11 @@ void Sema::diagnoseExprIntendedAsTemplateName(Scope *S, ExprResult TemplateName,
         diagnoseTypo(Corrected,
                      PDiag(diag::err_non_template_in_member_template_id_suggest)
                          << Name << LookupCtx << DroppedSpecifier
-                         << SS.getRange(),
-                     false);
+                         << SS.getRange(), false);
       } else {
         diagnoseTypo(Corrected,
                      PDiag(diag::err_non_template_in_template_id_suggest)
-                         << Name,
-                     false);
+                         << Name, false);
       }
       if (Found)
         Diag(Found->getLocation(),
@@ -725,15 +727,17 @@ void Sema::diagnoseExprIntendedAsTemplateName(Scope *S, ExprResult TemplateName,
   }
 
   Diag(NameInfo.getLoc(), diag::err_non_template_in_template_id)
-      << Name << SourceRange(Less, Greater);
+    << Name << SourceRange(Less, Greater);
   if (Found)
     Diag(Found->getLocation(), diag::note_non_template_in_template_id_found);
 }
 
-ExprResult Sema::ActOnDependentIdExpression(
-    const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
-    const DeclarationNameInfo &NameInfo, bool isAddressOfOperand,
-    const TemplateArgumentListInfo *TemplateArgs) {
+ExprResult
+Sema::ActOnDependentIdExpression(const CXXScopeSpec &SS,
+                                 SourceLocation TemplateKWLoc,
+                                 const DeclarationNameInfo &NameInfo,
+                                 bool isAddressOfOperand,
+                           const TemplateArgumentListInfo *TemplateArgs) {
   if (SS.isEmpty()) {
     // FIXME: This codepath is only used by dependent unqualified names
     // (e.g. a dependent conversion-function-id, or operator= once we support
@@ -841,9 +845,10 @@ bool Sema::DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation,
   if (TagDecl *TD = dyn_cast<TagDecl>(Instantiation))
     InstantiationTy = Context.getCanonicalTagType(TD);
   if (PatternDef) {
-    Diag(PointOfInstantiation, diag::err_template_instantiate_within_definition)
-        << /*implicit|explicit*/ (TSK != TSK_ImplicitInstantiation)
-        << InstantiationTy;
+    Diag(PointOfInstantiation,
+         diag::err_template_instantiate_within_definition)
+      << /*implicit|explicit*/(TSK != TSK_ImplicitInstantiation)
+      << InstantiationTy;
     // Not much point in noting the template declaration here, since
     // we're lexically inside it.
     Instantiation->setInvalidDecl();
@@ -851,38 +856,39 @@ bool Sema::DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation,
     if (isa<FunctionDecl>(Instantiation)) {
       Diag(PointOfInstantiation,
            diag::err_explicit_instantiation_undefined_member)
-          << /*member function*/ 1 << Instantiation->getDeclName()
-          << Instantiation->getDeclContext();
+        << /*member function*/ 1 << Instantiation->getDeclName()
+        << Instantiation->getDeclContext();
       Diag(Pattern->getLocation(), diag::note_explicit_instantiation_here);
     } else {
       assert(isa<TagDecl>(Instantiation) && "Must be a TagDecl!");
       Diag(PointOfInstantiation,
            diag::err_implicit_instantiate_member_undefined)
-          << InstantiationTy;
+        << InstantiationTy;
       Diag(Pattern->getLocation(), diag::note_member_declared_at);
     }
   } else {
     if (isa<FunctionDecl>(Instantiation)) {
       Diag(PointOfInstantiation,
            diag::err_explicit_instantiation_undefined_func_template)
-          << Pattern;
+        << Pattern;
       Diag(Pattern->getLocation(), diag::note_explicit_instantiation_here);
     } else if (isa<TagDecl>(Instantiation)) {
       Diag(PointOfInstantiation, diag::err_template_instantiate_undefined)
-          << (TSK != TSK_ImplicitInstantiation) << InstantiationTy;
+        << (TSK != TSK_ImplicitInstantiation)
+        << InstantiationTy;
       NoteTemplateLocation(*Pattern);
     } else {
       assert(isa<VarDecl>(Instantiation) && "Must be a VarDecl!");
       if (isa<VarTemplateSpecializationDecl>(Instantiation)) {
         Diag(PointOfInstantiation,
              diag::err_explicit_instantiation_undefined_var_template)
-            << Instantiation;
+          << Instantiation;
         Instantiation->setInvalidDecl();
       } else
         Diag(PointOfInstantiation,
              diag::err_explicit_instantiation_undefined_member)
-            << /*static data member*/ 2 << Instantiation->getDeclName()
-            << Instantiation->getDeclContext();
+          << /*static data member*/ 2 << Instantiation->getDeclName()
+          << Instantiation->getDeclContext();
       Diag(Pattern->getLocation(), diag::note_explicit_instantiation_here);
     }
   }
@@ -927,7 +933,7 @@ TemplateDecl *Sema::AdjustDeclIfTemplate(Decl *&D) {
 }
 
 ParsedTemplateArgument ParsedTemplateArgument::getTemplatePackExpansion(
-    SourceLocation EllipsisLoc) const {
+                                             SourceLocation EllipsisLoc) const {
   assert(Kind == Template &&
          "Only template template arguments can be pack expansions here");
   assert(getAsTemplate().get().containsUnexpandedParameterPack() &&
@@ -937,8 +943,8 @@ ParsedTemplateArgument ParsedTemplateArgument::getTemplatePackExpansion(
   return Result;
 }
 
-static TemplateArgumentLoc
-translateTemplateArgument(Sema &SemaRef, const ParsedTemplateArgument &Arg) {
+static TemplateArgumentLoc translateTemplateArgument(Sema &SemaRef,
+                                            const ParsedTemplateArgument &Arg) {
 
   switch (Arg.getKind()) {
   case ParsedTemplateArgument::Type: {
@@ -973,9 +979,9 @@ translateTemplateArgument(Sema &SemaRef, const ParsedTemplateArgument &Arg) {
 
 void Sema::translateTemplateArguments(const ASTTemplateArgsPtr &TemplateArgsIn,
                                       TemplateArgumentListInfo &TemplateArgs) {
-  for (unsigned I = 0, Last = TemplateArgsIn.size(); I != Last; ++I)
-    TemplateArgs.addArgument(
-        translateTemplateArgument(*this, TemplateArgsIn[I]));
+ for (unsigned I = 0, Last = TemplateArgsIn.size(); I != Last; ++I)
+   TemplateArgs.addArgument(translateTemplateArgument(*this,
+                                                      TemplateArgsIn[I]));
 }
 
 static void maybeDiagnoseTemplateParameterShadow(Sema &SemaRef, Scope *S,
@@ -1027,19 +1033,24 @@ ParsedTemplateArgument Sema::ActOnTemplateTypeArgument(TypeResult ParsedType) {
                                 TInfo->getTypeLoc().getBeginLoc());
 }
 
-NamedDecl *
-Sema::ActOnTypeParameter(Scope *S, bool Typename, SourceLocation EllipsisLoc,
-                         SourceLocation KeyLoc, IdentifierInfo *ParamName,
-                         SourceLocation ParamNameLoc, unsigned Depth,
-                         unsigned Position, SourceLocation EqualLoc,
-                         ParsedType DefaultArg, bool HasTypeConstraint) {
+NamedDecl *Sema::ActOnTypeParameter(Scope *S, bool Typename,
+                                    SourceLocation EllipsisLoc,
+                                    SourceLocation KeyLoc,
+                                    IdentifierInfo *ParamName,
+                                    SourceLocation ParamNameLoc,
+                                    unsigned Depth, unsigned Position,
+                                    SourceLocation EqualLoc,
+                                    ParsedType DefaultArg,
+                                    bool HasTypeConstraint) {
   assert(S->isTemplateParamScope() &&
          "Template type parameter not in template parameter scope!");
 
   bool IsParameterPack = EllipsisLoc.isValid();
-  TemplateTypeParmDecl *Param = TemplateTypeParmDecl::Create(
-      Context, Context.getTranslationUnitDecl(), KeyLoc, ParamNameLoc, Depth,
-      Position, ParamName, Typename, IsParameterPack, HasTypeConstraint);
+  TemplateTypeParmDecl *Param
+    = TemplateTypeParmDecl::Create(Context, Context.getTranslationUnitDecl(),
+                                   KeyLoc, ParamNameLoc, Depth, Position,
+                                   ParamName, Typename, IsParameterPack,
+                                   HasTypeConstraint);
   Param->setAccess(AS_public);
 
   if (Param->isParameterPack())
@@ -1166,7 +1177,8 @@ bool Sema::BuildTypeConstraint(const CXXScopeSpec &SS,
 
   TemplateArgumentListInfo TemplateArgs;
   if (TypeConstr->LAngleLoc.isValid()) {
-    TemplateArgs = makeTemplateArgumentListInfo(*this, *TypeConstr);
+    TemplateArgs =
+        makeTemplateArgumentListInfo(*this, *TypeConstr);
 
     if (EllipsisLoc.isInvalid() && !AllowUnexpandedPack) {
       for (TemplateArgumentLoc Arg : TemplateArgs.arguments()) {
@@ -1192,8 +1204,8 @@ static ExprResult formImmediatelyDeclaredConstraint(
 
   TemplateArgumentListInfo ConstraintArgs;
   ConstraintArgs.addArgument(
-      S.getTrivialTemplateArgumentLoc(TemplateArgument(ConstrainedType),
-                                      /*NTTPType=*/QualType(), ParamNameLoc));
+    S.getTrivialTemplateArgumentLoc(TemplateArgument(ConstrainedType),
+                                    /*NTTPType=*/QualType(), ParamNameLoc));
 
   ConstraintArgs.setRAngleLoc(RAngleLoc);
   ConstraintArgs.setLAngleLoc(LAngleLoc);
@@ -1252,8 +1264,8 @@ bool Sema::AttachTypeConstraint(NestedNameSpecifierLoc NS,
   //     [...] If Q is of the form C<A1, ..., An>, then let E' be
   //     C<T, A1, ..., An>. Otherwise, let E' be C<T>. [...]
   const ASTTemplateArgumentListInfo *ArgsAsWritten =
-      TemplateArgs ? ASTTemplateArgumentListInfo::Create(Context, *TemplateArgs)
-                   : nullptr;
+    TemplateArgs ? ASTTemplateArgumentListInfo::Create(Context,
+                                                       *TemplateArgs) : nullptr;
 
   QualType ParamAsArgument(ConstrainedParameter->getTypeForDecl(), 0);
 
@@ -1428,7 +1440,8 @@ bool Sema::RequireStructuralType(QualType T, SourceLocation Loc) {
     }
 
     assert(Kind != -1 && "couldn't find reason why type is not structural");
-    Diag(SubLoc, diag::note_not_structural_subobject) << T << Kind << SubType;
+    Diag(SubLoc, diag::note_not_structural_subobject)
+        << T << Kind << SubType;
     T = SubType;
     RD = T->getAsCXXRecordDecl();
   }
@@ -1441,7 +1454,8 @@ QualType Sema::CheckNonTypeTemplateParameterType(QualType T,
   // We don't allow variably-modified types as the type of non-type template
   // parameters.
   if (T->isVariablyModifiedType()) {
-    Diag(Loc, diag::err_variably_modified_nontype_template_param) << T;
+    Diag(Loc, diag::err_variably_modified_nontype_template_param)
+      << T;
     return QualType();
   }
 
@@ -1502,10 +1516,10 @@ QualType Sema::CheckNonTypeTemplateParameterType(QualType T,
 }
 
 NamedDecl *Sema::ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
-                                               unsigned Depth,
-                                               unsigned Position,
-                                               SourceLocation EqualLoc,
-                                               Expr *Default) {
+                                          unsigned Depth,
+                                          unsigned Position,
+                                          SourceLocation EqualLoc,
+                                          Expr *Default) {
   TypeSourceInfo *TInfo = GetTypeForDeclarator(D);
 
   // Check that we have valid decl-specifiers specified.
@@ -1685,7 +1699,7 @@ NamedDecl *Sema::ActOnTemplateTemplateParameter(
 
   if (Params->size() == 0) {
     Diag(Param->getLocation(), diag::err_template_template_parm_no_parms)
-        << SourceRange(Params->getLAngleLoc(), Params->getRAngleLoc());
+    << SourceRange(Params->getLAngleLoc(), Params->getRAngleLoc());
     Invalid = true;
   }
 
@@ -1712,7 +1726,7 @@ NamedDecl *Sema::ActOnTemplateTemplateParameter(
     TemplateArgumentLoc DefaultArg = translateTemplateArgument(*this, Default);
     if (DefaultArg.getArgument().getAsTemplate().isNull()) {
       Diag(DefaultArg.getLocation(), diag::err_template_arg_not_valid_template)
-          << DefaultArg.getSourceRange();
+        << DefaultArg.getSourceRange();
       return Param;
     }
 
@@ -1725,9 +1739,9 @@ NamedDecl *Sema::ActOnTemplateTemplateParameter(
     }
 
     // Check for unexpanded parameter packs.
-    if (DiagnoseUnexpandedParameterPack(
-            DefaultArg.getLocation(), DefaultArg.getArgument().getAsTemplate(),
-            UPPC_DefaultArgument))
+    if (DiagnoseUnexpandedParameterPack(DefaultArg.getLocation(),
+                                        DefaultArg.getArgument().getAsTemplate(),
+                                        UPPC_DefaultArgument))
       return Param;
 
     Param->setDefaultArgument(Context, DefaultArg);
@@ -1843,10 +1857,14 @@ bool Sema::ConstraintExpressionDependsOnEnclosingTemplate(
   return Checker.getResult();
 }
 
-TemplateParameterList *Sema::ActOnTemplateParameterList(
-    unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc,
-    SourceLocation LAngleLoc, ArrayRef<NamedDecl *> Params,
-    SourceLocation RAngleLoc, Expr *RequiresClause) {
+TemplateParameterList *
+Sema::ActOnTemplateParameterList(unsigned Depth,
+                                 SourceLocation ExportLoc,
+                                 SourceLocation TemplateLoc,
+                                 SourceLocation LAngleLoc,
+                                 ArrayRef<NamedDecl *> Params,
+                                 SourceLocation RAngleLoc,
+                                 Expr *RequiresClause) {
   if (ExportLoc.isValid())
     Diag(ExportLoc, diag::warn_template_export_unsupported);
 
@@ -2021,11 +2039,12 @@ DeclResult Sema::CheckClassTemplate(
   if (!PrevClassTemplate && isa_and_nonnull<CXXRecordDecl>(PrevDecl) &&
       cast<CXXRecordDecl>(PrevDecl)->isInjectedClassName()) {
     PrevDecl = cast<CXXRecordDecl>(PrevDecl->getDeclContext());
-    PrevClassTemplate =
-        cast<CXXRecordDecl>(PrevDecl)->getDescribedClassTemplate();
+    PrevClassTemplate
+      = cast<CXXRecordDecl>(PrevDecl)->getDescribedClassTemplate();
     if (!PrevClassTemplate && isa<ClassTemplateSpecializationDecl>(PrevDecl)) {
-      PrevClassTemplate = cast<ClassTemplateSpecializationDecl>(PrevDecl)
-                              ->getSpecializedTemplate();
+      PrevClassTemplate
+        = cast<ClassTemplateSpecializationDecl>(PrevDecl)
+            ->getSpecializedTemplate();
     }
   }
 
@@ -2108,8 +2127,8 @@ DeclResult Sema::CheckClassTemplate(
     if (!isAcceptableTagRedeclaration(
             PrevRecordDecl, Kind, TUK == TagUseKind::Definition, KWLoc, Name)) {
       Diag(KWLoc, diag::err_use_with_wrong_tag)
-          << Name
-          << FixItHint::CreateReplacement(KWLoc, PrevRecordDecl->getKindName());
+        << Name
+        << FixItHint::CreateReplacement(KWLoc, PrevRecordDecl->getKindName());
       Diag(PrevRecordDecl->getLocation(), diag::note_previous_use);
       Kind = PrevRecordDecl->getTagKind();
     }
@@ -2210,9 +2229,10 @@ DeclResult Sema::CheckClassTemplate(
     AddMsStructLayoutForRecord(NewClass);
   }
 
-  ClassTemplateDecl *NewTemplate = ClassTemplateDecl::Create(
-      Context, SemanticContext, NameLoc, DeclarationName(Name), TemplateParams,
-      NewClass);
+  ClassTemplateDecl *NewTemplate
+    = ClassTemplateDecl::Create(Context, SemanticContext, NameLoc,
+                                DeclarationName(Name), TemplateParams,
+                                NewClass);
 
   if (ShouldAddRedecl)
     NewTemplate->setPreviousDecl(PrevClassTemplate);
@@ -2327,7 +2347,7 @@ static bool DiagnoseDefaultTemplateArgument(Sema &S,
     //   template-parameter-lists of the definition of a member of a
     //   class template that appears outside of the member's class.
     S.Diag(ParamLoc, diag::err_template_parameter_default_template_member)
-        << DefArgRange;
+      << DefArgRange;
     return true;
 
   case Sema::TPC_FriendClassTemplate:
@@ -2336,7 +2356,7 @@ static bool DiagnoseDefaultTemplateArgument(Sema &S,
     //   A default template-argument shall not be specified in a
     //   friend template declaration.
     S.Diag(ParamLoc, diag::err_template_parameter_default_friend_template)
-        << DefArgRange;
+      << DefArgRange;
     return true;
 
     // FIXME: C++0x [temp.param]p9 allows default template-arguments
@@ -2372,16 +2392,16 @@ static bool DiagnoseUnexpandedParameterPacks(Sema &S,
 
     if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(P)) {
       if (!NTTP->isParameterPack() &&
-          S.DiagnoseUnexpandedParameterPack(
-              NTTP->getLocation(), NTTP->getTypeSourceInfo(),
-              Sema::UPPC_NonTypeTemplateParameterType))
+          S.DiagnoseUnexpandedParameterPack(NTTP->getLocation(),
+                                            NTTP->getTypeSourceInfo(),
+                                      Sema::UPPC_NonTypeTemplateParameterType))
         return true;
 
       continue;
     }
 
-    if (TemplateTemplateParmDecl *InnerTTP =
-            dyn_cast<TemplateTemplateParmDecl>(P))
+    if (TemplateTemplateParmDecl *InnerTTP
+                                        = dyn_cast<TemplateTemplateParmDecl>(P))
       if (DiagnoseUnexpandedParameterPacks(S, InnerTTP))
         return true;
   }
@@ -2411,7 +2431,7 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
 
   bool RemoveDefaultArguments = false;
   for (TemplateParameterList::iterator NewParam = NewParams->begin(),
-                                       NewParamEnd = NewParams->end();
+                                    NewParamEnd = NewParams->end();
        NewParam != NewParamEnd; ++NewParam) {
     // Whether we've seen a duplicate default argument in the same translation
     // unit.
@@ -2431,8 +2451,8 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
     // Variable used to diagnose non-final parameter packs
     bool SawParameterPack = false;
 
-    if (TemplateTypeParmDecl *NewTypeParm =
-            dyn_cast<TemplateTypeParmDecl>(*NewParam)) {
+    if (TemplateTypeParmDecl *NewTypeParm
+          = dyn_cast<TemplateTypeParmDecl>(*NewParam)) {
       // Check the presence of a default argument here.
       if (NewTypeParm->hasDefaultArgument() &&
           DiagnoseDefaultTemplateArgument(
@@ -2441,8 +2461,8 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
         NewTypeParm->removeDefaultArgument();
 
       // Merge default arguments for template type parameters.
-      TemplateTypeParmDecl *OldTypeParm =
-          OldParams ? cast<TemplateTypeParmDecl>(*OldParam) : nullptr;
+      TemplateTypeParmDecl *OldTypeParm
+          = OldParams? cast<TemplateTypeParmDecl>(*OldParam) : nullptr;
       if (NewTypeParm->isParameterPack()) {
         assert(!NewTypeParm->hasDefaultArgument() &&
                "Parameter packs can't have a default argument!");
@@ -2473,8 +2493,8 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
         PreviousDefaultArgLoc = NewTypeParm->getDefaultArgumentLoc();
       } else if (SawDefaultArgument)
         MissingDefaultArg = true;
-    } else if (NonTypeTemplateParmDecl *NewNonTypeParm =
-                   dyn_cast<NonTypeTemplateParmDecl>(*NewParam)) {
+    } else if (NonTypeTemplateParmDecl *NewNonTypeParm
+               = dyn_cast<NonTypeTemplateParmDecl>(*NewParam)) {
       // Check for unexpanded parameter packs, except in a template template
       // parameter pack, as in those any unexpanded packs should be expanded
       // along with the parameter itself.
@@ -2496,8 +2516,8 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
       }
 
       // Merge default arguments for non-type template parameters
-      NonTypeTemplateParmDecl *OldNonTypeParm =
-          OldParams ? cast<NonTypeTemplateParmDecl>(*OldParam) : nullptr;
+      NonTypeTemplateParmDecl *OldNonTypeParm
+        = OldParams? cast<NonTypeTemplateParmDecl>(*OldParam) : nullptr;
       if (NewNonTypeParm->isParameterPack()) {
         assert(!NewNonTypeParm->hasDefaultArgument() &&
                "Parameter packs can't have a default argument!");
@@ -2529,8 +2549,8 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
       } else if (SawDefaultArgument)
         MissingDefaultArg = true;
     } else {
-      TemplateTemplateParmDecl *NewTemplateParm =
-          cast<TemplateTemplateParmDecl>(*NewParam);
+      TemplateTemplateParmDecl *NewTemplateParm
+        = cast<TemplateTemplateParmDecl>(*NewParam);
 
       // Check for unexpanded parameter packs, recursively.
       if (::DiagnoseUnexpandedParameterPacks(*this, NewTemplateParm)) {
@@ -2540,14 +2560,14 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
 
       // Check the presence of a default argument here.
       if (NewTemplateParm->hasDefaultArgument() &&
-          DiagnoseDefaultTemplateArgument(
-              *this, TPC, NewTemplateParm->getLocation(),
-              NewTemplateParm->getDefaultArgument().getSourceRange()))
+          DiagnoseDefaultTemplateArgument(*this, TPC,
+                                          NewTemplateParm->getLocation(),
+                     NewTemplateParm->getDefaultArgument().getSourceRange()))
         NewTemplateParm->removeDefaultArgument();
 
       // Merge default arguments for template template parameters
-      TemplateTemplateParmDecl *OldTemplateParm =
-          OldParams ? cast<TemplateTemplateParmDecl>(*OldParam) : nullptr;
+      TemplateTemplateParmDecl *OldTemplateParm
+        = OldParams? cast<TemplateTemplateParmDecl>(*OldParam) : nullptr;
       if (NewTemplateParm->isParameterPack()) {
         assert(!NewTemplateParm->hasDefaultArgument() &&
                "Parameter packs can't have a default argument!");
@@ -2573,12 +2593,12 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
         // Merge the default argument from the old declaration to the
         // new declaration.
         NewTemplateParm->setInheritedDefaultArgument(Context, OldTemplateParm);
-        PreviousDefaultArgLoc =
-            OldTemplateParm->getDefaultArgument().getLocation();
+        PreviousDefaultArgLoc
+          = OldTemplateParm->getDefaultArgument().getLocation();
       } else if (NewTemplateParm->hasDefaultArgument()) {
         SawDefaultArgument = true;
-        PreviousDefaultArgLoc =
-            NewTemplateParm->getDefaultArgument().getLocation();
+        PreviousDefaultArgLoc
+          = NewTemplateParm->getDefaultArgument().getLocation();
       } else if (SawDefaultArgument)
         MissingDefaultArg = true;
     }
@@ -2644,12 +2664,12 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams,
   // all of the default arguments.
   if (RemoveDefaultArguments) {
     for (TemplateParameterList::iterator NewParam = NewParams->begin(),
-                                         NewParamEnd = NewParams->end();
+                                      NewParamEnd = NewParams->end();
          NewParam != NewParamEnd; ++NewParam) {
       if (TemplateTypeParmDecl *TTP = dyn_cast<TemplateTypeParmDecl>(*NewParam))
         TTP->removeDefaultArgument();
-      else if (NonTypeTemplateParmDecl *NTTP =
-                   dyn_cast<NonTypeTemplateParmDecl>(*NewParam))
+      else if (NonTypeTemplateParmDecl *NTTP
+                                = dyn_cast<NonTypeTemplateParmDecl>(*NewParam))
         NTTP->removeDefaultArgument();
       else
         cast<TemplateTemplateParmDecl>(*NewParam)->removeDefaultArgument();
@@ -2685,7 +2705,7 @@ struct DependencyChecker : DynamicRecursiveASTVisitor {
     if (TemplateTypeParmDecl *PD = dyn_cast<TemplateTypeParmDecl>(ND)) {
       Depth = PD->getDepth();
     } else if (NonTypeTemplateParmDecl *PD =
-                   dyn_cast<NonTypeTemplateParmDecl>(ND)) {
+                 dyn_cast<NonTypeTemplateParmDecl>(ND)) {
       Depth = PD->getDepth();
     } else {
       Depth = cast<TemplateTemplateParmDecl>(ND)->getDepth();
@@ -2730,7 +2750,7 @@ struct DependencyChecker : DynamicRecursiveASTVisitor {
 
   bool TraverseTemplateName(TemplateName N) override {
     if (TemplateTemplateParmDecl *PD =
-            dyn_cast_or_null<TemplateTemplateParmDecl>(N.getAsTemplateDecl()))
+          dyn_cast_or_null<TemplateTemplateParmDecl>(N.getAsTemplateDecl()))
       if (Matches(PD->getDepth()))
         return false;
     return DynamicRecursiveASTVisitor::TraverseTemplateName(N);
@@ -2738,7 +2758,7 @@ struct DependencyChecker : DynamicRecursiveASTVisitor {
 
   bool VisitDeclRefExpr(DeclRefExpr *E) override {
     if (NonTypeTemplateParmDecl *PD =
-            dyn_cast<NonTypeTemplateParmDecl>(E->getDecl()))
+          dyn_cast<NonTypeTemplateParmDecl>(E->getDecl()))
       if (Matches(PD->getDepth(), E->getExprLoc()))
         return false;
     return DynamicRecursiveASTVisitor::VisitDeclRefExpr(E);
@@ -2777,12 +2797,12 @@ struct DependencyChecker : DynamicRecursiveASTVisitor {
 
 /// Determines whether a given type depends on the given parameter
 /// list.
-static bool DependsOnTemplateParameters(QualType T,
-                                        TemplateParameterList *Params) {
+static bool
+DependsOnTemplateParameters(QualType T, TemplateParameterList *Params) {
   if (!Params->size())
     return false;
 
-  DependencyChecker Checker(Params, /*IgnoreNonTypeDependent*/ false);
+  DependencyChecker Checker(Params, /*IgnoreNonTypeDependent*/false);
   Checker.TraverseType(T);
   return Checker.Match;
 }
@@ -2839,15 +2859,15 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
     // Retrieve the parent of a record type.
     if (CXXRecordDecl *Record = T->getAsCXXRecordDecl()) {
       // If this type is an explicit specialization, we're done.
-      if (ClassTemplateSpecializationDecl *Spec =
-              dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
+      if (ClassTemplateSpecializationDecl *Spec
+          = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
         if (!isa<ClassTemplatePartialSpecializationDecl>(Spec) &&
             Spec->getSpecializationKind() == TSK_ExplicitSpecialization) {
           ExplicitSpecLoc = Spec->getLocation();
           break;
         }
-      } else if (Record->getTemplateSpecializationKind() ==
-                 TSK_ExplicitSpecialization) {
+      } else if (Record->getTemplateSpecializationKind()
+                                                == TSK_ExplicitSpecialization) {
         ExplicitSpecLoc = Record->getLocation();
         break;
       }
@@ -2859,8 +2879,8 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
       continue;
     }
 
-    if (const TemplateSpecializationType *TST =
-            T->getAs<TemplateSpecializationType>()) {
+    if (const TemplateSpecializationType *TST
+                                     = T->getAs<TemplateSpecializationType>()) {
       TemplateName Name = TST->getTemplateName();
       if (const auto *DTS = Name.getAsDependentTemplateName()) {
         // Look one step prior in a dependent template specialization type.
@@ -2881,8 +2901,7 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
     }
 
     // Look one step prior in a dependent name type.
-    if (const DependentNameType *DependentName =
-            T->getAs<DependentNameType>()) {
+    if (const DependentNameType *DependentName = T->getAs<DependentNameType>()){
       if (NestedNameSpecifier NNS = DependentName->getQualifier();
           NNS.getKind() == NestedNameSpecifier::Kind::Type)
         T = QualType(NNS.getAsType(), 0);
@@ -2923,7 +2942,7 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
     if (SawNonEmptyTemplateParameterList) {
       if (!SuppressDiagnostic)
         Diag(DeclLoc, diag::err_specialize_member_of_template)
-            << !Recovery << Range;
+          << !Recovery << Range;
       Invalid = true;
       IsMemberSpecialization = false;
       return true;
@@ -2932,7 +2951,7 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
     return false;
   };
 
-  auto DiagnoseMissingExplicitSpecialization = [&](SourceRange Range) {
+  auto DiagnoseMissingExplicitSpecialization = [&] (SourceRange Range) {
     // Check that we can have an explicit specialization here.
     if (CheckExplicitSpecialization(Range, true))
       return true;
@@ -2946,8 +2965,8 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
 
     if (!SuppressDiagnostic)
       Diag(DeclLoc, diag::err_template_spec_needs_header)
-          << Range
-          << FixItHint::CreateInsertion(ExpectedTemplateLoc, "template<> ");
+        << Range
+        << FixItHint::CreateInsertion(ExpectedTemplateLoc, "template<> ");
     return false;
   };
 
@@ -2972,18 +2991,18 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
     //   member declaration shall be preceded by a template<> for each
     //   enclosing class template that is explicitly specialized.
     if (CXXRecordDecl *Record = T->getAsCXXRecordDecl()) {
-      if (ClassTemplatePartialSpecializationDecl *Partial =
-              dyn_cast<ClassTemplatePartialSpecializationDecl>(Record)) {
+      if (ClassTemplatePartialSpecializationDecl *Partial
+            = dyn_cast<ClassTemplatePartialSpecializationDecl>(Record)) {
         ExpectedTemplateParams = Partial->getTemplateParameters();
         NeedNonemptyTemplateHeader = true;
       } else if (Record->isDependentType()) {
         if (Record->getDescribedClassTemplate()) {
-          ExpectedTemplateParams =
-              Record->getDescribedClassTemplate()->getTemplateParameters();
+          ExpectedTemplateParams = Record->getDescribedClassTemplate()
+                                                      ->getTemplateParameters();
           NeedNonemptyTemplateHeader = true;
         }
-      } else if (ClassTemplateSpecializationDecl *Spec =
-                     dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
+      } else if (ClassTemplateSpecializationDecl *Spec
+                     = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
         // C++0x [temp.expl.spec]p4:
         //   Members of an explicitly specialized class template are defined
         //   in the same manner as members of normal classes, and not using
@@ -2993,8 +3012,8 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
         else
           continue;
       } else if (Record->getTemplateSpecializationKind()) {
-        if (Record->getTemplateSpecializationKind() !=
-                TSK_ExplicitSpecialization &&
+        if (Record->getTemplateSpecializationKind()
+                                                != TSK_ExplicitSpecialization &&
             TypeIdx == NumTypes - 1)
           IsMemberSpecialization = true;
 
@@ -3040,10 +3059,10 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
           if (!SuppressDiagnostic)
             Diag(ParamLists[ParamIdx]->getTemplateLoc(),
                  diag::err_template_param_list_matches_nontemplate)
-                << T
-                << SourceRange(ParamLists[ParamIdx]->getLAngleLoc(),
-                               ParamLists[ParamIdx]->getRAngleLoc())
-                << getRangeOfTypeInNestedNameSpecifier(Context, T, SS);
+              << T
+              << SourceRange(ParamLists[ParamIdx]->getLAngleLoc(),
+                             ParamLists[ParamIdx]->getRAngleLoc())
+              << getRangeOfTypeInNestedNameSpecifier(Context, T, SS);
           Invalid = true;
           return nullptr;
         }
@@ -3077,9 +3096,9 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
       if (ParamIdx < ParamLists.size()) {
         // Check the template parameter list, if we can.
         if (ExpectedTemplateParams &&
-            !TemplateParameterListsAreEqual(
-                ParamLists[ParamIdx], ExpectedTemplateParams,
-                !SuppressDiagnostic, TPL_TemplateMatch))
+            !TemplateParameterListsAreEqual(ParamLists[ParamIdx],
+                                            ExpectedTemplateParams,
+                                            !SuppressDiagnostic, TPL_TemplateMatch))
           Invalid = true;
 
         if (!Invalid &&
@@ -3093,7 +3112,8 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
 
       if (!SuppressDiagnostic)
         Diag(DeclLoc, diag::err_template_spec_needs_template_parameters)
-            << T << getRangeOfTypeInNestedNameSpecifier(Context, T, SS);
+          << T
+          << getRangeOfTypeInNestedNameSpecifier(Context, T, SS);
       Invalid = true;
       continue;
     }
@@ -3106,8 +3126,8 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
     if (TemplateId && !IsFriend) {
       // We don't have a template header for the declaration itself, but we
       // should.
-      DiagnoseMissingExplicitSpecialization(
-          SourceRange(TemplateId->LAngleLoc, TemplateId->RAngleLoc));
+      DiagnoseMissingExplicitSpecialization(SourceRange(TemplateId->LAngleLoc,
+                                                        TemplateId->RAngleLoc));
 
       // Fabricate an empty template parameter list for the invented header.
       return TemplateParameterList::Create(Context, SourceLocation(),
@@ -3143,7 +3163,7 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
         !SuppressDiagnostic)
       Diag(ExplicitSpecLoc,
            diag::note_explicit_template_spec_does_not_need_header)
-          << NestedTypes.back();
+        << NestedTypes.back();
 
     // We have a template parameter list with no corresponding scope, which
     // means that the resulting template declaration can't be instantiated
@@ -3172,21 +3192,23 @@ TemplateParameterList *Sema::MatchTemplateParametersToScopeSpecifier(
 void Sema::NoteAllFoundTemplates(TemplateName Name) {
   if (TemplateDecl *Template = Name.getAsTemplateDecl()) {
     Diag(Template->getLocation(), diag::note_template_declared_here)
-        << (isa<FunctionTemplateDecl>(Template)    ? 0
-            : isa<ClassTemplateDecl>(Template)     ? 1
-            : isa<VarTemplateDecl>(Template)       ? 2
-            : isa<TypeAliasTemplateDecl>(Template) ? 3
-                                                   : 4)
+        << (isa<FunctionTemplateDecl>(Template)
+                ? 0
+                : isa<ClassTemplateDecl>(Template)
+                      ? 1
+                      : isa<VarTemplateDecl>(Template)
+                            ? 2
+                            : isa<TypeAliasTemplateDecl>(Template) ? 3 : 4)
         << Template->getDeclName();
     return;
   }
 
   if (OverloadedTemplateStorage *OST = Name.getAsOverloadedTemplate()) {
     for (OverloadedTemplateStorage::iterator I = OST->begin(),
-                                             IEnd = OST->end();
+                                          IEnd = OST->end();
          I != IEnd; ++I)
       Diag((*I)->getLocation(), diag::note_template_declared_here)
-          << 0 << (*I)->getDeclName();
+        << 0 << (*I)->getDeclName();
 
     return;
   }
@@ -3577,17 +3599,14 @@ static void collectConjunctionTerms(Expr *Clause,
 static Expr *lookThroughRangesV3Condition(Preprocessor &PP, Expr *Cond) {
   // Top-level '||'.
   auto *BinOp = dyn_cast<BinaryOperator>(Cond->IgnoreParenImpCasts());
-  if (!BinOp)
-    return Cond;
+  if (!BinOp) return Cond;
 
-  if (BinOp->getOpcode() != BO_LOr)
-    return Cond;
+  if (BinOp->getOpcode() != BO_LOr) return Cond;
 
   // With an inner '==' that has a literal on the right-hand side.
   Expr *LHS = BinOp->getLHS();
   auto *InnerBinOp = dyn_cast<BinaryOperator>(LHS->IgnoreParenImpCasts());
-  if (!InnerBinOp)
-    return Cond;
+  if (!InnerBinOp) return Cond;
 
   if (InnerBinOp->getOpcode() != BO_EQ ||
       !isa<IntegerLiteral>(InnerBinOp->getRHS()))
@@ -3597,8 +3616,7 @@ static Expr *lookThroughRangesV3Condition(Preprocessor &PP, Expr *Cond) {
   // CONCEPT_REQUIRES or CONCEPT_REQUIRES_, return the right-hand side
   // of the '||', which is the real, user-provided condition.
   SourceLocation Loc = InnerBinOp->getExprLoc();
-  if (!Loc.isMacroID())
-    return Cond;
+  if (!Loc.isMacroID()) return Cond;
 
   StringRef MacroName = PP.getImmediateMacroName(Loc);
   if (MacroName == "CONCEPT_REQUIRES" || MacroName == "CONCEPT_REQUIRES_")
@@ -3643,7 +3661,8 @@ class FailedBooleanConditionPrinterHelper : public PrinterHelper {
 
 } // end anonymous namespace
 
-std::pair<Expr *, std::string> Sema::findFailedBooleanCondition(Expr *Cond) {
+std::pair<Expr *, std::string>
+Sema::findFailedBooleanCondition(Expr *Cond) {
   Cond = lookThroughRangesV3Condition(PP, Cond);
 
   // Separate out all of the terms in a conjunction.
@@ -3663,10 +3682,11 @@ std::pair<Expr *, std::string> Sema::findFailedBooleanCondition(Expr *Cond) {
     // The initialization of the parameter from the argument is
     // a constant-evaluated context.
     EnterExpressionEvaluationContext ConstantEvaluated(
-        *this, Sema::ExpressionEvaluationContext::ConstantEvaluated);
+      *this, Sema::ExpressionEvaluationContext::ConstantEvaluated);
 
     bool Succeeded;
-    if (Term->EvaluateAsBooleanCondition(Succeeded, Context) && !Succeeded) {
+    if (Term->EvaluateAsBooleanCondition(Succeeded, Context) &&
+        !Succeeded) {
       FailedCond = TermAsWritten;
       break;
     }
@@ -3682,7 +3702,7 @@ std::pair<Expr *, std::string> Sema::findFailedBooleanCondition(Expr *Cond) {
     FailedBooleanConditionPrinterHelper Helper(Policy);
     FailedCond->printPretty(Out, &Helper, Policy, 0, "\n", nullptr);
   }
-  return {FailedCond, Description};
+  return { FailedCond, Description };
 }
 
 static TemplateName
@@ -3842,12 +3862,11 @@ QualType Sema::CheckTemplateIdType(ElaboratedTypeKeyword Keyword,
             Expr *FailedCond;
             std::string FailedDescription;
             std::tie(FailedCond, FailedDescription) =
-                findFailedBooleanCondition(
-                    TemplateArgs[0].getSourceExpression());
+              findFailedBooleanCondition(TemplateArgs[0].getSourceExpression());
 
             // Remove the old SFINAE diagnostic.
-            PartialDiagnosticAt OldDiag = {SourceLocation(),
-                                           PartialDiagnostic::NullDiagnostic()};
+            PartialDiagnosticAt OldDiag =
+              {SourceLocation(), PartialDiagnostic::NullDiagnostic()};
             DeductionInfo->takeSFINAEDiagnostic(OldDiag);
 
             // Add a new SFINAE diagnostic specifying which condition
@@ -3890,13 +3909,11 @@ QualType Sema::CheckTemplateIdType(ElaboratedTypeKeyword Keyword,
     if (isa<ClassTemplateDecl>(Template)) {
       for (DeclContext *Ctx = CurContext; Ctx; Ctx = Ctx->getLookupParent()) {
         // If we get out to a namespace, we're done.
-        if (Ctx->isFileContext())
-          break;
+        if (Ctx->isFileContext()) break;
 
         // If this isn't a record, keep looking.
         CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(Ctx);
-        if (!Record)
-          continue;
+        if (!Record) continue;
 
         // Look for one of the two cases with InjectedClassNameTypes
         // and check whether it's the same template.
@@ -4003,7 +4020,7 @@ TypeResult Sema::ActOnTemplateIdType(
     return true;
 
   if (!IsCtorOrDtorName && !IsClassName && SS.isSet()) {
-    DeclContext *LookupCtx = computeDeclContext(SS, /*EnteringContext*/ false);
+    DeclContext *LookupCtx = computeDeclContext(SS, /*EnteringContext*/false);
 
     // C++ [temp.res]p3:
     //   A qualified-id that refers to a type and in which the
@@ -4042,8 +4059,8 @@ TypeResult Sema::ActOnTemplateIdType(
            TemplateKWLoc.isInvalid()
                ? diag::err_out_of_line_qualified_id_type_names_constructor
                : diag::ext_out_of_line_qualified_id_type_names_constructor)
-          << TemplateII << 0 /*injected-class-name used as template name*/
-          << 1 /*if any keyword was present, it was 'template'*/;
+        << TemplateII << 0 /*injected-class-name used as template name*/
+        << 1 /*if any keyword was present, it was 'template'*/;
     }
   }
 
@@ -4065,11 +4082,16 @@ TypeResult Sema::ActOnTemplateIdType(
   return CreateParsedType(SpecTy, TLB.getTypeSourceInfo(Context, SpecTy));
 }
 
-TypeResult Sema::ActOnTagTemplateIdType(
-    TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc,
-    CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD,
-    SourceLocation TemplateLoc, SourceLocation LAngleLoc,
-    ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc) {
+TypeResult Sema::ActOnTagTemplateIdType(TagUseKind TUK,
+                                        TypeSpecifierType TagSpec,
+                                        SourceLocation TagLoc,
+                                        CXXScopeSpec &SS,
+                                        SourceLocation TemplateKWLoc,
+                                        TemplateTy TemplateD,
+                                        SourceLocation TemplateLoc,
+                                        SourceLocation LAngleLoc,
+                                        ASTTemplateArgsPtr TemplateArgsIn,
+                                        SourceLocation RAngleLoc) {
   if (SS.isInvalid())
     return TypeResult(true);
 
@@ -4079,8 +4101,8 @@ TypeResult Sema::ActOnTagTemplateIdType(
 
   // Determine the tag kind
   TagTypeKind TagKind = TypeWithKeyword::getTagTypeKindForTypeSpec(TagSpec);
-  ElaboratedTypeKeyword Keyword =
-      TypeWithKeyword::getKeywordForTagTypeKind(TagKind);
+  ElaboratedTypeKeyword Keyword
+    = TypeWithKeyword::getKeywordForTagTypeKind(TagKind);
 
   QualType Result =
       CheckTemplateIdType(Keyword, TemplateD.get(), TemplateLoc, TemplateArgs,
@@ -4098,9 +4120,8 @@ TypeResult Sema::ActOnTagTemplateIdType(
     if (!isAcceptableTagRedeclaration(D, TagKind, TUK == TagUseKind::Definition,
                                       TagLoc, Id)) {
       Diag(TagLoc, diag::err_use_with_wrong_tag)
-          << Result
-          << FixItHint::CreateReplacement(SourceRange(TagLoc),
-                                          D->getKindName());
+        << Result
+        << FixItHint::CreateReplacement(SourceRange(TagLoc), D->getKindName());
       Diag(D->getLocation(), diag::note_previous_use);
     }
   }
@@ -4137,8 +4158,8 @@ static bool isTemplateArgumentTemplateParameter(const TemplateArgument &Arg,
     QualType Type = Arg.getAsType();
     const TemplateTypeParmType *TPT =
         Arg.getAsType()->getAsCanonical<TemplateTypeParmType>();
-    return TPT && !Type.hasQualifiers() && TPT->getDepth() == Depth &&
-           TPT->getIndex() == Index;
+    return TPT && !Type.hasQualifiers() &&
+           TPT->getDepth() == Depth && TPT->getIndex() == Index;
   }
 
   case TemplateArgument::Expression: {
@@ -4197,7 +4218,7 @@ static bool isSameAsPrimaryTemplate(TemplateParameterList *Params,
   return true;
 }
 
-template <typename PartialSpecDecl>
+template<typename PartialSpecDecl>
 static void checkMoreSpecializedThanPrimary(Sema &S, PartialSpecDecl *Partial) {
   if (Partial->getDeclContext()->isDependentContext())
     return;
@@ -4221,7 +4242,7 @@ static void checkMoreSpecializedThanPrimary(Sema &S, PartialSpecDecl *Partial) {
     Diag.second.EmitToString(S.getDiagnostics(), SFINAEArgString);
     S.Diag(Diag.first,
            diag::note_partial_spec_not_more_specialized_than_primary)
-        << SFINAEArgString;
+      << SFINAEArgString;
   }
 
   S.NoteTemplateLocation(*Template);
@@ -4248,7 +4269,8 @@ noteNonDeducibleParameters(Sema &S, TemplateParameterList *TemplateParams,
   }
 }
 
-template <typename PartialSpecDecl>
+
+template<typename PartialSpecDecl>
 static void checkTemplatePartialSpecialization(Sema &S,
                                                PartialSpecDecl *Partial) {
   // C++1z [temp.class.spec]p8: (DR1495)
@@ -4271,10 +4293,10 @@ static void checkTemplatePartialSpecialization(Sema &S,
   if (!DeducibleParams.all()) {
     unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
     S.Diag(Partial->getLocation(), diag::ext_partial_specs_not_deducible)
-        << isa<VarTemplatePartialSpecializationDecl>(Partial)
-        << (NumNonDeducible > 1)
-        << SourceRange(Partial->getLocation(),
-                       Partial->getTemplateArgsAsWritten()->RAngleLoc);
+      << isa<VarTemplatePartialSpecializationDecl>(Partial)
+      << (NumNonDeducible > 1)
+      << SourceRange(Partial->getLocation(),
+                     Partial->getTemplateArgsAsWritten()->RAngleLoc);
     noteNonDeducibleParameters(S, TemplateParams, DeducibleParams);
   }
 }
@@ -4307,7 +4329,7 @@ void Sema::CheckDeductionGuideTemplate(FunctionTemplateDecl *TD) {
   if (!DeducibleParams.all()) {
     unsigned NumNonDeducible = DeducibleParams.size() - DeducibleParams.count();
     Diag(TD->getLocation(), diag::err_deduction_guide_template_not_deducible)
-        << (NumNonDeducible > 1);
+      << (NumNonDeducible > 1);
     noteNonDeducibleParameters(*this, TemplateParams, DeducibleParams);
   }
 }
@@ -4337,14 +4359,12 @@ DeclResult Sema::ActOnVarTemplateSpecialization(
     if (auto *OTS = Name.getAsOverloadedTemplate())
       FnTemplate = *OTS->begin();
     else
-      FnTemplate =
-          dyn_cast_or_null<FunctionTemplateDecl>(Name.getAsTemplateDecl());
+      FnTemplate = dyn_cast_or_null<FunctionTemplateDecl>(Name.getAsTemplateDecl());
     if (FnTemplate)
-      return Diag(D.getIdentifierLoc(),
-                  diag::err_var_spec_no_template_but_method)
-             << FnTemplate->getDeclName();
+      return Diag(D.getIdentifierLoc(), diag::err_var_spec_no_template_but_method)
+               << FnTemplate->getDeclName();
     return Diag(D.getIdentifierLoc(), diag::err_var_spec_no_template)
-           << IsPartialSpecialization;
+             << IsPartialSpecialization;
   }
 
   if (const auto *DSA = VarTemplate->getAttr<NoSpecializationsAttr>()) {
@@ -4697,8 +4717,9 @@ Sema::CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc,
       for (SmallVector<MatchResult, 4>::iterator P = Best + 1,
                                                  PEnd = Matched.end();
            P != PEnd; ++P) {
-        if (getMoreSpecializedPartialSpecialization(
-                P->Partial, Best->Partial, PointOfInstantiation) == P->Partial)
+        if (getMoreSpecializedPartialSpecialization(P->Partial, Best->Partial,
+                                                    PointOfInstantiation) ==
+            P->Partial)
           Best = P;
       }
 
@@ -4708,8 +4729,8 @@ Sema::CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc,
                                                  PEnd = Matched.end();
            P != PEnd; ++P) {
         if (P != Best && getMoreSpecializedPartialSpecialization(
-                             P->Partial, Best->Partial, PointOfInstantiation) !=
-                             Best->Partial) {
+                             P->Partial, Best->Partial,
+                             PointOfInstantiation) != Best->Partial) {
           AmbiguousPartialSpec = true;
           break;
         }
@@ -4823,7 +4844,7 @@ ExprResult Sema::CheckVarOrConceptTemplateTemplateId(
 void Sema::diagnoseMissingTemplateArguments(TemplateName Name,
                                             SourceLocation Loc) {
   Diag(Loc, diag::err_template_missing_args)
-      << (int)getTemplateNameKindForDiagnostics(Name) << Name;
+    << (int)getTemplateNameKindForDiagnostics(Name) << Name;
   if (TemplateDecl *TD = Name.getAsTemplateDecl()) {
     NoteTemplateLocation(*TD, TD->getTemplateParameters()->getSourceRange());
   }
@@ -4905,10 +4926,11 @@ ExprResult Sema::CheckConceptTemplateId(
       Context, CL, CSD, AreArgsDependent ? nullptr : &Satisfaction);
 }
 
-ExprResult
-Sema::BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
-                          LookupResult &R, bool RequiresADL,
-                          const TemplateArgumentListInfo *TemplateArgs) {
+ExprResult Sema::BuildTemplateIdExpr(const CXXScopeSpec &SS,
+                                     SourceLocation TemplateKWLoc,
+                                     LookupResult &R,
+                                     bool RequiresADL,
+                                 const TemplateArgumentListInfo *TemplateArgs) {
   // FIXME: Can we do any checking at this point? I guess we could check the
   // template arguments that we have against the template name, if the template
   // name refers to a single template. That's not a terribly common case,
@@ -4995,7 +5017,7 @@ ExprResult Sema::BuildQualifiedTemplateIdExpr(
   if (R.empty()) {
     DeclContext *DC = computeDeclContext(SS);
     Diag(NameInfo.getLoc(), diag::err_no_member)
-        << NameInfo.getName() << DC << SS.getRange();
+      << NameInfo.getName() << DC << SS.getRange();
     return ExprError();
   }
 
@@ -5007,17 +5029,20 @@ ExprResult Sema::BuildQualifiedTemplateIdExpr(
   return BuildTemplateIdExpr(SS, TemplateKWLoc, R, /*ADL=*/false, TemplateArgs);
 }
 
-TemplateNameKind
-Sema::ActOnTemplateName(Scope *S, CXXScopeSpec &SS,
-                        SourceLocation TemplateKWLoc, const UnqualifiedId &Name,
-                        ParsedType ObjectType, bool EnteringContext,
-                        TemplateTy &Result, bool AllowInjectedClassName) {
+TemplateNameKind Sema::ActOnTemplateName(Scope *S,
+                                         CXXScopeSpec &SS,
+                                         SourceLocation TemplateKWLoc,
+                                         const UnqualifiedId &Name,
+                                         ParsedType ObjectType,
+                                         bool EnteringContext,
+                                         TemplateTy &Result,
+                                         bool AllowInjectedClassName) {
   if (TemplateKWLoc.isValid() && S && !S->getTemplateParamParent())
     Diag(TemplateKWLoc,
-         getLangOpts().CPlusPlus11
-             ? diag::warn_cxx98_compat_template_outside_of_template
-             : diag::ext_template_outside_of_template)
-        << FixItHint::CreateRemoval(TemplateKWLoc);
+         getLangOpts().CPlusPlus11 ?
+           diag::warn_cxx98_compat_template_outside_of_template :
+           diag::ext_template_outside_of_template)
+      << FixItHint::CreateRemoval(TemplateKWLoc);
 
   if (SS.isInvalid())
     return TNK_Non_template;
@@ -5046,15 +5071,15 @@ Sema::ActOnTemplateName(Scope *S, CXXScopeSpec &SS,
   // "template" keyword is now permitted). We follow the C++0x
   // rules, even in C++03 mode with a warning, retroactively applying the DR.
   bool MemberOfUnknownSpecialization;
-  TemplateNameKind TNK =
-      isTemplateName(S, SS, TemplateKWLoc.isValid(), Name, ObjectType,
-                     EnteringContext, Result, MemberOfUnknownSpecialization);
+  TemplateNameKind TNK = isTemplateName(S, SS, TemplateKWLoc.isValid(), Name,
+                                        ObjectType, EnteringContext, Result,
+                                        MemberOfUnknownSpecialization);
   if (TNK != TNK_Non_template) {
     // We resolved this to a (non-dependent) template name. Return it.
     auto *LookupRD = dyn_cast_or_null<CXXRecordDecl>(LookupCtx);
     if (!AllowInjectedClassName && SS.isNotEmpty() && LookupRD &&
-        Name.getKind() == UnqualifiedIdKind::IK_Identifier && Name.Identifier &&
-        LookupRD->getIdentifier() == Name.Identifier) {
+        Name.getKind() == UnqualifiedIdKind::IK_Identifier &&
+        Name.Identifier && LookupRD->getIdentifier() == Name.Identifier) {
       // C++14 [class.qual]p2:
       //   In a lookup in which function names are not ignored and the
       //   nested-name-specifier nominates a class C, if the name specified
@@ -5066,7 +5091,8 @@ Sema::ActOnTemplateName(Scope *S, CXXScopeSpec &SS,
       // injected-class-name as naming the template.
       Diag(Name.getBeginLoc(),
            diag::ext_out_of_line_qualified_id_type_names_constructor)
-          << Name.Identifier << 0 /*injected-class-name used as template name*/
+          << Name.Identifier
+          << 0 /*injected-class-name used as template name*/
           << TemplateKWLoc.isValid();
     }
     return TNK;
@@ -5139,7 +5165,7 @@ bool Sema::CheckTemplateTypeArgument(
   TypeSourceInfo *TSI = nullptr;
 
   // Check template type parameter.
-  switch (Arg.getKind()) {
+  switch(Arg.getKind()) {
   case TemplateArgument::Type:
     // C++ [temp.arg.type]p1:
     //   A template-argument for a template-parameter which is a
@@ -5162,12 +5188,12 @@ bool Sema::CheckTemplateTypeArgument(
     CXXScopeSpec SS;
     DeclarationNameInfo NameInfo;
 
-    if (DependentScopeDeclRefExpr *ArgExpr =
-            dyn_cast<DependentScopeDeclRefExpr>(Arg.getAsExpr())) {
+   if (DependentScopeDeclRefExpr *ArgExpr =
+               dyn_cast<DependentScopeDeclRefExpr>(Arg.getAsExpr())) {
       SS.Adopt(ArgExpr->getQualifierLoc());
       NameInfo = ArgExpr->getNameInfo();
     } else if (CXXDependentScopeMemberExpr *ArgExpr =
-                   dyn_cast<CXXDependentScopeMemberExpr>(Arg.getAsExpr())) {
+               dyn_cast<CXXDependentScopeMemberExpr>(Arg.getAsExpr())) {
       if (ArgExpr->isImplicitAccess()) {
         SS.Adopt(ArgExpr->getQualifierLoc());
         NameInfo = ArgExpr->getMemberNameInfo();
@@ -5238,7 +5264,8 @@ bool Sema::CheckTemplateTypeArgument(
   // Objective-C ARC:
   //   If an explicitly-specified template argument type is a lifetime type
   //   with no lifetime qualifier, the __strong lifetime qualifier is inferred.
-  if (getLangOpts().ObjCAutoRefCount && ArgType->isObjCLifetimeType() &&
+  if (getLangOpts().ObjCAutoRefCount &&
+      ArgType->isObjCLifetimeType() &&
       !ArgType.getObjCLifetime()) {
     Qualifiers Qs;
     Qs.setObjCLifetime(Qualifiers::OCL_Strong);
@@ -5433,8 +5460,8 @@ TemplateArgumentLoc Sema::SubstDefaultTemplateArgumentIfAvailable(
     return Output;
   }
 
-  if (NonTypeTemplateParmDecl *NonTypeParm =
-          dyn_cast<NonTypeTemplateParmDecl>(Param)) {
+  if (NonTypeTemplateParmDecl *NonTypeParm
+        = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
     if (!hasReachableDefaultArgument(NonTypeParm))
       return TemplateArgumentLoc();
 
@@ -5447,8 +5474,8 @@ TemplateArgumentLoc Sema::SubstDefaultTemplateArgumentIfAvailable(
     return Output;
   }
 
-  TemplateTemplateParmDecl *TempTempParm =
-      cast<TemplateTemplateParmDecl>(Param);
+  TemplateTemplateParmDecl *TempTempParm
+    = cast<TemplateTemplateParmDecl>(Param);
   if (!hasReachableDefaultArgument(TempTempParm))
     return TemplateArgumentLoc();
 
@@ -5504,8 +5531,7 @@ bool Sema::CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &ArgLoc,
 
   const TemplateArgument &Arg = ArgLoc.getArgument();
   // Check non-type template parameters.
-  if (NonTypeTemplateParmDecl *NTTP =
-          dyn_cast<NonTypeTemplateParmDecl>(Param)) {
+  if (NonTypeTemplateParmDecl *NTTP =dyn_cast<NonTypeTemplateParmDecl>(Param)) {
     // Do substitution on the type of the non-type template parameter
     // with the template arguments we've seen thus far.  But if the
     // template has a dependent context then we cannot substitute yet.
@@ -5537,8 +5563,8 @@ bool Sema::CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &ArgLoc,
       // If that worked, check the non-type template parameter type
       // for validity.
       if (!NTTPType.isNull())
-        NTTPType =
-            CheckNonTypeTemplateParameterType(NTTPType, NTTP->getLocation());
+        NTTPType = CheckNonTypeTemplateParameterType(NTTPType,
+                                                     NTTP->getLocation());
       if (NTTPType.isNull())
         return true;
     }
@@ -5674,6 +5700,7 @@ bool Sema::CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &ArgLoc,
     return false;
   }
 
+
   // Check template template parameters.
   TemplateTemplateParmDecl *TempParm = cast<TemplateTemplateParmDecl>(Param);
 
@@ -5766,9 +5793,10 @@ bool Sema::CheckTemplateArgument(NamedDecl *Param, TemplateArgumentLoc &ArgLoc,
 }
 
 /// Diagnose a missing template argument.
-template <typename TemplateParmDecl>
+template<typename TemplateParmDecl>
 static bool diagnoseMissingArgument(Sema &S, SourceLocation Loc,
-                                    TemplateDecl *TD, const TemplateParmDecl *D,
+                                    TemplateDecl *TD,
+                                    const TemplateParmDecl *D,
                                     TemplateArgumentListInfo &Args) {
   // Dig out the most recent declaration of the template parameter; there may be
   // declarations of the template that are more recent than TD.
@@ -5778,12 +5806,12 @@ static bool diagnoseMissingArgument(Sema &S, SourceLocation Loc,
 
   // If there's a default argument that's not reachable, diagnose that we're
   // missing a module import.
-  llvm::SmallVector<Module *, 8> Modules;
+  llvm::SmallVector<Module*, 8> Modules;
   if (D->hasDefaultArgument() && !S.hasReachableDefaultArgument(D, &Modules)) {
     S.diagnoseMissingImport(Loc, cast<NamedDecl>(TD),
                             D->getDefaultArgumentLoc(), Modules,
                             Sema::MissingImportKind::DefaultArgument,
-                            /*Recover*/ true);
+                            /*Recover*/true);
     return true;
   }
 
@@ -5793,8 +5821,9 @@ static bool diagnoseMissingArgument(Sema &S, SourceLocation Loc,
   TemplateParameterList *Params = TD->getTemplateParameters();
 
   S.Diag(Loc, diag::err_template_arg_list_different_arity)
-      << /*not enough args*/ 0
-      << (int)S.getTemplateNameKindForDiagnostics(TemplateName(TD)) << TD;
+    << /*not enough args*/0
+    << (int)S.getTemplateNameKindForDiagnostics(TemplateName(TD))
+    << TD;
   S.NoteTemplateLocation(*TD, Params->getSourceRange());
   return true;
 }
@@ -5883,9 +5912,9 @@ bool Sema::CheckTemplateArgumentList(
       } else if (ArgIdx == NumArgs && !PartialTemplateArgs) {
         // Not enough arguments for this parameter pack.
         Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
-            << /*not enough args*/ 0
-            << (int)getTemplateNameKindForDiagnostics(TemplateName(Template))
-            << Template;
+          << /*not enough args*/0
+          << (int)getTemplateNameKindForDiagnostics(TemplateName(Template))
+          << Template;
         NoteTemplateLocation(*Template, Params->getSourceRange());
         return true;
       }
@@ -6138,7 +6167,7 @@ bool Sema::CheckTemplateArgumentList(
   // Complain and fail.
   if (ArgIdx < NumArgs) {
     Diag(TemplateLoc, diag::err_template_arg_list_different_arity)
-        << /*too many args*/ 1
+        << /*too many args*/1
         << (int)getTemplateNameKindForDiagnostics(TemplateName(Template))
         << Template
         << SourceRange(NewArgs[ArgIdx].getLocation(), NewArgs.getRAngleLoc());
@@ -6189,56 +6218,58 @@ bool Sema::CheckTemplateArgumentList(
 }
 
 namespace {
-class UnnamedLocalNoLinkageFinder
-    : public TypeVisitor<UnnamedLocalNoLinkageFinder, bool> {
-  Sema &S;
-  SourceRange SR;
+  class UnnamedLocalNoLinkageFinder
+    : public TypeVisitor<UnnamedLocalNoLinkageFinder, bool>
+  {
+    Sema &S;
+    SourceRange SR;
 
-  typedef TypeVisitor<UnnamedLocalNoLinkageFinder, bool> inherited;
+    typedef TypeVisitor<UnnamedLocalNoLinkageFinder, bool> inherited;
 
-public:
-  UnnamedLocalNoLinkageFinder(Sema &S, SourceRange SR) : S(S), SR(SR) {}
+  public:
+    UnnamedLocalNoLinkageFinder(Sema &S, SourceRange SR) : S(S), SR(SR) { }
 
-  bool Visit(QualType T) {
-    return T.isNull() ? false : inherited::Visit(T.getTypePtr());
-  }
+    bool Visit(QualType T) {
+      return T.isNull() ? false : inherited::Visit(T.getTypePtr());
+    }
 
-#define TYPE(Class, Parent) bool Visit##Class##Type(const Class##Type *);
-#define ABSTRACT_TYPE(Class, Parent)                                           \
-  bool Visit##Class##Type(const Class##Type *) { return false; }
-#define NON_CANONICAL_TYPE(Class, Parent)                                      \
-  bool Visit##Class##Type(const Class##Type *) { return false; }
+#define TYPE(Class, Parent) \
+    bool Visit##Class##Type(const Class##Type *);
+#define ABSTRACT_TYPE(Class, Parent) \
+    bool Visit##Class##Type(const Class##Type *) { return false; }
+#define NON_CANONICAL_TYPE(Class, Parent) \
+    bool Visit##Class##Type(const Class##Type *) { return false; }
 #include "clang/AST/TypeNodes.inc"
 
-  bool VisitTagDecl(const TagDecl *Tag);
-  bool VisitNestedNameSpecifier(NestedNameSpecifier NNS);
-};
+    bool VisitTagDecl(const TagDecl *Tag);
+    bool VisitNestedNameSpecifier(NestedNameSpecifier NNS);
+  };
 } // end anonymous namespace
 
-bool UnnamedLocalNoLinkageFinder::VisitBuiltinType(const BuiltinType *) {
+bool UnnamedLocalNoLinkageFinder::VisitBuiltinType(const BuiltinType*) {
   return false;
 }
 
-bool UnnamedLocalNoLinkageFinder::VisitComplexType(const ComplexType *T) {
+bool UnnamedLocalNoLinkageFinder::VisitComplexType(const ComplexType* T) {
   return Visit(T->getElementType());
 }
 
-bool UnnamedLocalNoLinkageFinder::VisitPointerType(const PointerType *T) {
+bool UnnamedLocalNoLinkageFinder::VisitPointerType(const PointerType* T) {
   return Visit(T->getPointeeType());
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitBlockPointerType(
-    const BlockPointerType *T) {
+                                                    const BlockPointerType* T) {
   return Visit(T->getPointeeType());
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitLValueReferenceType(
-    const LValueReferenceType *T) {
+                                                const LValueReferenceType* T) {
   return Visit(T->getPointeeType());
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitRValueReferenceType(
-    const RValueReferenceType *T) {
+                                                const RValueReferenceType* T) {
   return Visit(T->getPointeeType());
 }
 
@@ -6252,27 +6283,27 @@ bool UnnamedLocalNoLinkageFinder::VisitMemberPointerType(
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitConstantArrayType(
-    const ConstantArrayType *T) {
+                                                  const ConstantArrayType* T) {
   return Visit(T->getElementType());
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitIncompleteArrayType(
-    const IncompleteArrayType *T) {
+                                                 const IncompleteArrayType* T) {
   return Visit(T->getElementType());
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitVariableArrayType(
-    const VariableArrayType *T) {
+                                                   const VariableArrayType* T) {
   return Visit(T->getElementType());
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedArrayType(
-    const DependentSizedArrayType *T) {
+                                            const DependentSizedArrayType* T) {
   return Visit(T->getElementType());
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitDependentSizedExtVectorType(
-    const DependentSizedExtVectorType *T) {
+                                         const DependentSizedExtVectorType* T) {
   return Visit(T->getElementType());
 }
 
@@ -6286,7 +6317,7 @@ bool UnnamedLocalNoLinkageFinder::VisitDependentAddressSpaceType(
   return Visit(T->getPointeeType());
 }
 
-bool UnnamedLocalNoLinkageFinder::VisitVectorType(const VectorType *T) {
+bool UnnamedLocalNoLinkageFinder::VisitVectorType(const VectorType* T) {
   return Visit(T->getElementType());
 }
 
@@ -6295,7 +6326,7 @@ bool UnnamedLocalNoLinkageFinder::VisitDependentVectorType(
   return Visit(T->getElementType());
 }
 
-bool UnnamedLocalNoLinkageFinder::VisitExtVectorType(const ExtVectorType *T) {
+bool UnnamedLocalNoLinkageFinder::VisitExtVectorType(const ExtVectorType* T) {
   return Visit(T->getElementType());
 }
 
@@ -6305,7 +6336,7 @@ bool UnnamedLocalNoLinkageFinder::VisitConstantMatrixType(
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitFunctionProtoType(
-    const FunctionProtoType *T) {
+                                                  const FunctionProtoType* T) {
   for (const auto &A : T->param_types()) {
     if (Visit(A))
       return true;
@@ -6315,24 +6346,24 @@ bool UnnamedLocalNoLinkageFinder::VisitFunctionProtoType(
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitFunctionNoProtoType(
-    const FunctionNoProtoType *T) {
+                                               const FunctionNoProtoType* T) {
   return Visit(T->getReturnType());
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitUnresolvedUsingType(
-    const UnresolvedUsingType *) {
+                                                  const UnresolvedUsingType*) {
   return false;
 }
 
-bool UnnamedLocalNoLinkageFinder::VisitTypeOfExprType(const TypeOfExprType *) {
+bool UnnamedLocalNoLinkageFinder::VisitTypeOfExprType(const TypeOfExprType*) {
   return false;
 }
 
-bool UnnamedLocalNoLinkageFinder::VisitTypeOfType(const TypeOfType *T) {
+bool UnnamedLocalNoLinkageFinder::VisitTypeOfType(const TypeOfType* T) {
   return Visit(T->getUnmodifiedType());
 }
 
-bool UnnamedLocalNoLinkageFinder::VisitDecltypeType(const DecltypeType *) {
+bool UnnamedLocalNoLinkageFinder::VisitDecltypeType(const DecltypeType*) {
   return false;
 }
 
@@ -6342,7 +6373,7 @@ bool UnnamedLocalNoLinkageFinder::VisitPackIndexingType(
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitUnaryTransformType(
-    const UnaryTransformType *) {
+                                                    const UnaryTransformType*) {
   return false;
 }
 
@@ -6355,21 +6386,21 @@ bool UnnamedLocalNoLinkageFinder::VisitDeducedTemplateSpecializationType(
   return Visit(T->getDeducedType());
 }
 
-bool UnnamedLocalNoLinkageFinder::VisitRecordType(const RecordType *T) {
+bool UnnamedLocalNoLinkageFinder::VisitRecordType(const RecordType* T) {
   return VisitTagDecl(T->getDecl()->getDefinitionOrSelf());
 }
 
-bool UnnamedLocalNoLinkageFinder::VisitEnumType(const EnumType *T) {
+bool UnnamedLocalNoLinkageFinder::VisitEnumType(const EnumType* T) {
   return VisitTagDecl(T->getDecl()->getDefinitionOrSelf());
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitTemplateTypeParmType(
-    const TemplateTypeParmType *) {
+                                                 const TemplateTypeParmType*) {
   return false;
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitSubstTemplateTypeParmPackType(
-    const SubstTemplateTypeParmPackType *) {
+                                        const SubstTemplateTypeParmPackType *) {
   return false;
 }
 
@@ -6379,22 +6410,22 @@ bool UnnamedLocalNoLinkageFinder::VisitSubstBuiltinTemplatePackType(
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitTemplateSpecializationType(
-    const TemplateSpecializationType *) {
+                                            const TemplateSpecializationType*) {
   return false;
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitInjectedClassNameType(
-    const InjectedClassNameType *T) {
+                                              const InjectedClassNameType* T) {
   return VisitTagDecl(T->getDecl()->getDefinitionOrSelf());
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitDependentNameType(
-    const DependentNameType *T) {
+                                                   const DependentNameType* T) {
   return VisitNestedNameSpecifier(T->getQualifier());
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitPackExpansionType(
-    const PackExpansionType *T) {
+                                                   const PackExpansionType* T) {
   return Visit(T->getPattern());
 }
 
@@ -6403,16 +6434,16 @@ bool UnnamedLocalNoLinkageFinder::VisitObjCObjectType(const ObjCObjectType *) {
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitObjCInterfaceType(
-    const ObjCInterfaceType *) {
+                                                   const ObjCInterfaceType *) {
   return false;
 }
 
 bool UnnamedLocalNoLinkageFinder::VisitObjCObjectPointerType(
-    const ObjCObjectPointerType *) {
+                                                const ObjCObjectPointerType *) {
   return false;
 }
 
-bool UnnamedLocalNoLinkageFinder::VisitAtomicType(const AtomicType *T) {
+bool UnnamedLocalNoLinkageFinder::VisitAtomicType(const AtomicType* T) {
   return Visit(T->getValueType());
 }
 
@@ -6421,7 +6452,7 @@ bool UnnamedLocalNoLinkageFinder::VisitOverflowBehaviorType(
   return Visit(T->getUnderlyingType());
 }
 
-bool UnnamedLocalNoLinkageFinder::VisitPipeType(const PipeType *T) {
+bool UnnamedLocalNoLinkageFinder::VisitPipeType(const PipeType* T) {
   return false;
 }
 
@@ -6450,10 +6481,9 @@ bool UnnamedLocalNoLinkageFinder::VisitTagDecl(const TagDecl *Tag) {
 
   if (!Tag->hasNameForLinkage()) {
     S.Diag(SR.getBegin(),
-           S.getLangOpts().CPlusPlus11
-               ? diag::warn_cxx98_compat_template_arg_unnamed_type
-               : diag::ext_template_arg_unnamed_type)
-        << SR;
+           S.getLangOpts().CPlusPlus11 ?
+             diag::warn_cxx98_compat_template_arg_unnamed_type :
+             diag::ext_template_arg_unnamed_type) << SR;
     S.Diag(Tag->getLocation(), diag::note_template_unnamed_type_here);
     return true;
   }
@@ -6518,7 +6548,11 @@ bool Sema::CheckTemplateArgument(TypeSourceInfo *ArgInfo) {
   return false;
 }
 
-enum NullPointerValueKind { NPV_NotNullPointer, NPV_NullPointer, NPV_Error };
+enum NullPointerValueKind {
+  NPV_NotNullPointer,
+  NPV_NullPointer,
+  NPV_Error
+};
 
 /// Determine whether the given template argument is a null pointer
 /// value of the appropriate type.
@@ -6558,13 +6592,13 @@ isNullPointerValueTemplateArgument(Sema &S, NamedDecl *Param,
     // the caret at its location rather than producing an essentially
     // redundant note.
     if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
-                                 diag::note_invalid_subexpr_in_const_expr) {
+        diag::note_invalid_subexpr_in_const_expr) {
       DiagLoc = Notes[0].first;
       Notes.clear();
     }
 
     S.Diag(DiagLoc, diag::err_template_arg_not_address_constant)
-        << Arg->getType() << Arg->getSourceRange();
+      << Arg->getType() << Arg->getSourceRange();
     for (unsigned I = 0, N = Notes.size(); I != N; ++I)
       S.Diag(Notes[I].first, Notes[I].second);
 
@@ -6587,13 +6621,13 @@ isNullPointerValueTemplateArgument(Sema &S, NamedDecl *Param,
     bool ObjCLifetimeConversion;
     if (S.Context.hasSameUnqualifiedType(Arg->getType(), ParamType) ||
         S.IsQualificationConversion(Arg->getType(), ParamType, false,
-                                    ObjCLifetimeConversion))
+                                     ObjCLifetimeConversion))
       return NPV_NullPointer;
 
     // The types didn't match, but we know we got a null pointer; complain,
     // then recover as if the types were correct.
     S.Diag(Arg->getExprLoc(), diag::err_template_arg_wrongtype_null_constant)
-        << Arg->getType() << ParamType << Arg->getSourceRange();
+      << Arg->getType() << ParamType << Arg->getSourceRange();
     S.NoteTemplateParameterLocation(*Param);
     return NPV_NullPointer;
   }
@@ -6603,7 +6637,7 @@ isNullPointerValueTemplateArgument(Sema &S, NamedDecl *Param,
     // We could just return NPV_NotNullPointer, but we can print a better
     // message with the information we have here.
     S.Diag(Arg->getExprLoc(), diag::err_template_arg_invalid)
-        << EvalResult.Val.getAsString(S.Context, ParamType);
+      << EvalResult.Val.getAsString(S.Context, ParamType);
     S.NoteTemplateParameterLocation(*Param);
     return NPV_Error;
   }
@@ -6859,12 +6893,12 @@ static bool CheckTemplateArgumentAddressOfObjectOrFunction(
                : diag::ext_template_arg_object_internal)
         << !Func << Entity << Arg->getSourceRange();
     S.Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
-        << !Func;
+      << !Func;
   } else if (!Entity->hasLinkage()) {
     S.Diag(Arg->getBeginLoc(), diag::err_template_arg_object_no_linkage)
         << !Func << Entity << Arg->getSourceRange();
     S.Diag(Entity->getLocation(), diag::note_template_arg_internal_object)
-        << !Func;
+      << !Func;
     return true;
   }
 
@@ -6893,13 +6927,14 @@ static bool CheckTemplateArgumentAddressOfObjectOrFunction(
     if (!S.Context.hasSameUnqualifiedType(Entity->getType(),
                                           ParamType.getNonReferenceType())) {
       S.Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
-          << ParamType;
+        << ParamType;
       S.NoteTemplateParameterLocation(*Param);
       return true;
     }
 
     S.Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
-        << ParamType << FixItHint::CreateRemoval(AddrOpLoc);
+      << ParamType
+      << FixItHint::CreateRemoval(AddrOpLoc);
     S.NoteTemplateParameterLocation(*Param);
 
     ArgType = Entity->getType();
@@ -6921,13 +6956,13 @@ static bool CheckTemplateArgumentAddressOfObjectOrFunction(
       ArgType = S.Context.getPointerType(Entity->getType());
       if (!S.Context.hasSameUnqualifiedType(ArgType, ParamType)) {
         S.Diag(Arg->getBeginLoc(), diag::err_template_arg_not_address_of)
-            << ParamType;
+          << ParamType;
         S.NoteTemplateParameterLocation(*Param);
         return true;
       }
 
       S.Diag(Arg->getBeginLoc(), diag::err_template_arg_not_address_of)
-          << ParamType << FixItHint::CreateInsertion(Arg->getBeginLoc(), "&");
+        << ParamType << FixItHint::CreateInsertion(Arg->getBeginLoc(), "&");
 
       S.NoteTemplateParameterLocation(*Param);
     }
@@ -6978,7 +7013,7 @@ static bool CheckTemplateArgumentPointerToMember(
   }
 
   while (SubstNonTypeTemplateParmExpr *subst =
-             dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
+           dyn_cast<SubstNonTypeTemplateParmExpr>(Arg))
     Arg = subst->getReplacement()->IgnoreImpCasts();
 
   // A pointer-to-member constant written &Class::member.
@@ -7121,7 +7156,7 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
       InitializedEntity Entity =
           InitializedEntity::InitializeTemplateParameter(ParamType, Param);
       InitializationKind Kind = InitializationKind::CreateForInit(
-          DeductionArg->getBeginLoc(), /*DirectInit*/ false, DeductionArg);
+          DeductionArg->getBeginLoc(), /*DirectInit*/false, DeductionArg);
       Expr *Inits[1] = {DeductionArg};
       ParamType =
           DeduceTemplateSpecializationFromInitializer(TSI, Entity, Kind, Inits);
@@ -7465,7 +7500,7 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
         QualType T;
 
       public:
-        TmplArgICEDiagnoser(QualType T) : T(T) {}
+        TmplArgICEDiagnoser(QualType T) : T(T) { }
 
         SemaDiagnosticBuilder diagnoseNotICE(Sema &S,
                                              SourceLocation Loc) override {
@@ -7573,33 +7608,32 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
 
   // Handle pointer-to-function, reference-to-function, and
   // pointer-to-member-function all in (roughly) the same way.
-  if ( // -- For a non-type template-parameter of type pointer to
-       //    function, only the function-to-pointer conversion (4.3) is
-       //    applied. If the template-argument represents a set of
-       //    overloaded functions (or a pointer to such), the matching
-       //    function is selected from the set (13.4).
+  if (// -- For a non-type template-parameter of type pointer to
+      //    function, only the function-to-pointer conversion (4.3) is
+      //    applied. If the template-argument represents a set of
+      //    overloaded functions (or a pointer to such), the matching
+      //    function is selected from the set (13.4).
       (ParamType->isPointerType() &&
        ParamType->castAs<PointerType>()->getPointeeType()->isFunctionType()) ||
       // -- For a non-type template-parameter of type reference to
       //    function, no conversions apply. If the template-argument
       //    represents a set of overloaded functions, the matching
       //    function is selected from the set (13.4).
-      (ParamType->isReferenceType() && ParamType->castAs<ReferenceType>()
-                                           ->getPointeeType()
-                                           ->isFunctionType()) ||
+      (ParamType->isReferenceType() &&
+       ParamType->castAs<ReferenceType>()->getPointeeType()->isFunctionType()) ||
       // -- For a non-type template-parameter of type pointer to
       //    member function, no conversions apply. If the
       //    template-argument represents a set of overloaded member
       //    functions, the matching member function is selected from
       //    the set (13.4).
       (ParamType->isMemberPointerType() &&
-       ParamType->castAs<MemberPointerType>()
-           ->getPointeeType()
-           ->isFunctionType())) {
+       ParamType->castAs<MemberPointerType>()->getPointeeType()
+         ->isFunctionType())) {
 
     if (Arg->getType() == Context.OverloadTy) {
-      if (FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(
-              Arg, ParamType, true, FoundResult)) {
+      if (FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg, ParamType,
+                                                                true,
+                                                                FoundResult)) {
         if (DiagnoseUseOfDecl(Fn, Arg->getBeginLoc()))
           return ExprError();
 
@@ -7651,8 +7685,10 @@ ExprResult Sema::CheckTemplateArgument(NamedDecl *Param, QualType ParamType,
            "Only object references allowed here");
 
     if (Arg->getType() == Context.OverloadTy) {
-      if (FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(
-              Arg, ParamRefType->getPointeeType(), true, FoundResult)) {
+      if (FunctionDecl *Fn = ResolveAddressOfOverloadedFunction(Arg,
+                                                 ParamRefType->getPointeeType(),
+                                                                true,
+                                                                FoundResult)) {
         if (DiagnoseUseOfDecl(Fn, Arg->getBeginLoc()))
           return ExprError();
         ExprResult Res = FixOverloadedFunctionReference(Arg, FoundResult, Fn);
@@ -7900,9 +7936,11 @@ ExprResult Sema::BuildExpressionFromDeclTemplateArgument(
   // parameter's type.
   if (Arg.getKind() == TemplateArgument::NullPtr) {
     return ImpCastExprToType(
-        new (Context) CXXNullPtrLiteralExpr(Context.NullPtrTy, Loc), ParamType,
-        ParamType->getAs<MemberPointerType>() ? CK_NullToMemberPointer
-                                              : CK_NullToPointer);
+             new (Context) CXXNullPtrLiteralExpr(Context.NullPtrTy, Loc),
+                             ParamType,
+                             ParamType->getAs<MemberPointerType>()
+                               ? CK_NullToMemberPointer
+                               : CK_NullToPointer);
   }
   assert(Arg.getKind() == TemplateArgument::Declaration &&
          "Only declaration template arguments permitted here");
@@ -8045,15 +8083,6 @@ static Expr *BuildExpressionFromIntegralTemplateArgumentValue(
   return E;
 }
 
-/// Construct a new reflect expression that refers to the given
-/// entity with the given source-location of the reflection operator.
-static ExprResult BuildExpressionFromReflection(Sema &S, const APValue &RV,
-                                                SourceLocation CaretCaretLoc) {
-  return CXXReflectExpr::Create(
-      S.Context, CaretCaretLoc,
-      static_cast<const TypeSourceInfo *>((RV.getReflectionOpaqueOperand())));
-}
-
 static Expr *BuildExpressionFromNonTypeTemplateArgumentValue(
     Sema &S, QualType T, const APValue &Val, SourceLocation Loc) {
   auto MakeInitList = [&](ArrayRef<Expr *> Elts) -> Expr * {
@@ -8118,7 +8147,7 @@ static Expr *BuildExpressionFromNonTypeTemplateArgumentValue(
   case APValue::Indeterminate:
     llvm_unreachable("Unexpected APValue kind.");
   case APValue::LValue:
-  case APValue::MemberPointer: {
+  case APValue::MemberPointer:
     // There isn't necessarily a valid equivalent source-level syntax for
     // these; in particular, a naive lowering might violate access control.
     // So for now we lower to a ConstantExpr holding the value, wrapped around
@@ -8132,9 +8161,6 @@ static Expr *BuildExpressionFromNonTypeTemplateArgumentValue(
     auto *OVE = new (S.Context) OpaqueValueExpr(Loc, T, VK);
     return ConstantExpr::Create(S.Context, OVE, Val);
   }
-  case APValue::Reflection:
-    return BuildExpressionFromReflection(S, Val, Loc).get();
-  }
   llvm_unreachable("Unhandled APValue::ValueKind enum");
 }
 
@@ -8182,9 +8208,10 @@ static bool MatchTemplateParameterKind(
         S.Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
         NextDiag = diag::note_template_param_different_kind;
       }
-      S.Diag(New->getLocation(), NextDiag) << (Kind != Sema::TPL_TemplateMatch);
+      S.Diag(New->getLocation(), NextDiag)
+        << (Kind != Sema::TPL_TemplateMatch);
       S.Diag(Old->getLocation(), diag::note_template_prev_declaration)
-          << (Kind != Sema::TPL_TemplateMatch);
+        << (Kind != Sema::TPL_TemplateMatch);
     }
 
     return false;
@@ -8198,17 +8225,18 @@ static bool MatchTemplateParameterKind(
     if (Complain) {
       unsigned NextDiag = diag::err_template_parameter_pack_non_pack;
       if (TemplateArgLoc.isValid()) {
-        S.Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
+        S.Diag(TemplateArgLoc,
+             diag::err_template_arg_template_params_mismatch);
         NextDiag = diag::note_template_parameter_pack_non_pack;
       }
 
-      unsigned ParamKind = isa<TemplateTypeParmDecl>(New)      ? 0
-                           : isa<NonTypeTemplateParmDecl>(New) ? 1
-                                                               : 2;
+      unsigned ParamKind = isa<TemplateTypeParmDecl>(New)? 0
+                      : isa<NonTypeTemplateParmDecl>(New)? 1
+                      : 2;
       S.Diag(New->getLocation(), NextDiag)
-          << ParamKind << New->isParameterPack();
+        << ParamKind << New->isParameterPack();
       S.Diag(Old->getLocation(), diag::note_template_parameter_pack_here)
-          << ParamKind << Old->isParameterPack();
+        << ParamKind << Old->isParameterPack();
     }
 
     return false;
@@ -8289,10 +8317,9 @@ static bool MatchTemplateParameterKind(
 
     auto Diagnose = [&] {
       S.Diag(NewC ? NewC->getBeginLoc() : New->getBeginLoc(),
-             diag::err_template_different_type_constraint);
+           diag::err_template_different_type_constraint);
       S.Diag(OldC ? OldC->getBeginLoc() : Old->getBeginLoc(),
-             diag::note_template_prev_declaration)
-          << /*declaration*/ 0;
+           diag::note_template_prev_declaration) << /*declaration*/0;
     };
 
     if (!NewC != !OldC) {
@@ -8316,20 +8343,24 @@ static bool MatchTemplateParameterKind(
 
 /// Diagnose a known arity mismatch when comparing template argument
 /// lists.
-static void DiagnoseTemplateParameterListArityMismatch(
-    Sema &S, TemplateParameterList *New, TemplateParameterList *Old,
-    Sema::TemplateParameterListEqualKind Kind, SourceLocation TemplateArgLoc) {
+static
+void DiagnoseTemplateParameterListArityMismatch(Sema &S,
+                                                TemplateParameterList *New,
+                                                TemplateParameterList *Old,
+                                      Sema::TemplateParameterListEqualKind Kind,
+                                                SourceLocation TemplateArgLoc) {
   unsigned NextDiag = diag::err_template_param_list_different_arity;
   if (TemplateArgLoc.isValid()) {
     S.Diag(TemplateArgLoc, diag::err_template_arg_template_params_mismatch);
     NextDiag = diag::note_template_param_list_different_arity;
   }
   S.Diag(New->getTemplateLoc(), NextDiag)
-      << (New->size() > Old->size()) << (Kind != Sema::TPL_TemplateMatch)
-      << SourceRange(New->getTemplateLoc(), New->getRAngleLoc());
+    << (New->size() > Old->size())
+    << (Kind != Sema::TPL_TemplateMatch)
+    << SourceRange(New->getTemplateLoc(), New->getRAngleLoc());
   S.Diag(Old->getTemplateLoc(), diag::note_template_prev_declaration)
-      << (Kind != Sema::TPL_TemplateMatch)
-      << SourceRange(Old->getTemplateLoc(), Old->getRAngleLoc());
+    << (Kind != Sema::TPL_TemplateMatch)
+    << SourceRange(Old->getTemplateLoc(), Old->getRAngleLoc());
 }
 
 bool Sema::TemplateParameterListsAreEqual(
@@ -8384,8 +8415,7 @@ bool Sema::TemplateParameterListsAreEqual(
       Diag(NewRC ? NewRC->getBeginLoc() : New->getTemplateLoc(),
            diag::err_template_different_requires_clause);
       Diag(OldRC ? OldRC->getBeginLoc() : Old->getTemplateLoc(),
-           diag::note_template_prev_declaration)
-          << /*declaration*/ 0;
+           diag::note_template_prev_declaration) << /*declaration*/0;
     };
 
     if (!NewRC != !OldRC) {
@@ -8407,8 +8437,8 @@ bool Sema::TemplateParameterListsAreEqual(
   return true;
 }
 
-bool Sema::CheckTemplateDeclScope(Scope *S,
-                                  TemplateParameterList *TemplateParams) {
+bool
+Sema::CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams) {
   if (!S)
     return false;
 
@@ -8449,7 +8479,7 @@ bool Sema::CheckTemplateDeclScope(Scope *S,
       if (RD->isLocalClass())
         return Diag(TemplateParams->getTemplateLoc(),
                     diag::err_template_inside_local_class)
-               << TemplateParams->getSourceRange();
+          << TemplateParams->getSourceRange();
       else
         return false;
     }
@@ -8457,7 +8487,7 @@ bool Sema::CheckTemplateDeclScope(Scope *S,
 
   return Diag(TemplateParams->getTemplateLoc(),
               diag::err_template_outside_namespace_or_class_scope)
-         << TemplateParams->getSourceRange();
+    << TemplateParams->getSourceRange();
 }
 
 /// Determine what kind of template specialization the given declaration
@@ -8500,7 +8530,8 @@ static TemplateSpecializationKind getTemplateSpecializationKind(Decl *D) {
 ///
 /// \returns true if there was an error that we cannot recover from, false
 /// otherwise.
-static bool CheckTemplateSpecializationScope(Sema &S, NamedDecl *Specialized,
+static bool CheckTemplateSpecializationScope(Sema &S,
+                                             NamedDecl *Specialized,
                                              NamedDecl *PrevDecl,
                                              SourceLocation Loc,
                                              bool IsPartialSpecialization) {
@@ -8508,7 +8539,7 @@ static bool CheckTemplateSpecializationScope(Sema &S, NamedDecl *Specialized,
   // various diagnostics emitted by this routine.
   int EntityKind = 0;
   if (isa<ClassTemplateDecl>(Specialized))
-    EntityKind = IsPartialSpecialization ? 1 : 0;
+    EntityKind = IsPartialSpecialization? 1 : 0;
   else if (isa<VarTemplateDecl>(Specialized))
     EntityKind = IsPartialSpecialization ? 3 : 2;
   else if (isa<FunctionTemplateDecl>(Specialized))
@@ -8523,7 +8554,7 @@ static bool CheckTemplateSpecializationScope(Sema &S, NamedDecl *Specialized,
     EntityKind = 8;
   else {
     S.Diag(Loc, diag::err_template_spec_unknown_kind)
-        << S.getLangOpts().CPlusPlus11;
+      << S.getLangOpts().CPlusPlus11;
     S.Diag(Specialized->getLocation(), diag::note_specialized_entity);
     return true;
   }
@@ -8532,7 +8563,8 @@ static bool CheckTemplateSpecializationScope(Sema &S, NamedDecl *Specialized,
   //   An explicit specialization may be declared in any scope in which
   //   the corresponding primary template may be defined.
   if (S.CurContext->getRedeclContext()->isFunctionOrMethod()) {
-    S.Diag(Loc, diag::err_template_spec_decl_function_scope) << Specialized;
+    S.Diag(Loc, diag::err_template_spec_decl_function_scope)
+      << Specialized;
     return true;
   }
 
@@ -8549,14 +8581,14 @@ static bool CheckTemplateSpecializationScope(Sema &S, NamedDecl *Specialized,
                             : DC->Equals(SpecializedContext))) {
     if (isa<TranslationUnitDecl>(SpecializedContext))
       S.Diag(Loc, diag::err_template_spec_redecl_global_scope)
-          << EntityKind << Specialized;
+        << EntityKind << Specialized;
     else {
       auto *ND = cast<NamedDecl>(SpecializedContext);
       int Diag = diag::err_template_spec_redecl_out_of_scope;
       if (S.getLangOpts().MicrosoftExt && !DC->isRecord())
         Diag = diag::ext_ms_template_spec_redecl_out_of_scope;
-      S.Diag(Loc, Diag) << EntityKind << Specialized << ND
-                        << isa<CXXRecordDecl>(ND);
+      S.Diag(Loc, Diag) << EntityKind << Specialized
+                        << ND << isa<CXXRecordDecl>(ND);
     }
 
     S.Diag(Specialized->getLocation(), diag::note_specialized_entity);
@@ -8573,7 +8605,7 @@ static bool CheckTemplateSpecializationScope(Sema &S, NamedDecl *Specialized,
 static SourceRange findTemplateParameterInType(unsigned Depth, Expr *E) {
   if (!E->isTypeDependent())
     return SourceLocation();
-  DependencyChecker Checker(Depth, /*IgnoreNonTypeDependent*/ true);
+  DependencyChecker Checker(Depth, /*IgnoreNonTypeDependent*/true);
   Checker.TraverseStmt(E);
   if (Checker.MatchLoc.isInvalid())
     return E->getSourceRange();
@@ -8583,7 +8615,7 @@ static SourceRange findTemplateParameterInType(unsigned Depth, Expr *E) {
 static SourceRange findTemplateParameter(unsigned Depth, TypeLoc TL) {
   if (!TL.getType()->isDependentType())
     return SourceLocation();
-  DependencyChecker Checker(Depth, /*IgnoreNonTypeDependent*/ true);
+  DependencyChecker Checker(Depth, /*IgnoreNonTypeDependent*/true);
   Checker.TraverseTypeLoc(TL);
   if (Checker.MatchLoc.isInvalid())
     return TL.getSourceRange();
@@ -8663,11 +8695,11 @@ static bool CheckNonTypeTemplatePartialSpecializationArgs(
                diag::err_dependent_non_type_arg_in_partial_spec);
         S.Diag(ParamUseRange.getBegin(),
                diag::note_dependent_non_type_default_arg_in_partial_spec)
-            << ParamUseRange;
+          << ParamUseRange;
       } else {
         S.Diag(ParamUseRange.getBegin(),
                diag::err_dependent_non_type_arg_in_partial_spec)
-            << ParamUseRange;
+          << ParamUseRange;
       }
       return true;
     }
@@ -8697,8 +8729,8 @@ bool Sema::CheckTemplatePartialSpecializationArgs(
   TemplateParameterList *TemplateParams =
       PrimaryTemplate->getTemplateParameters();
   for (unsigned I = 0, N = TemplateParams->size(); I != N; ++I) {
-    NonTypeTemplateParmDecl *Param =
-        dyn_cast<NonTypeTemplateParmDecl>(TemplateParams->getParam(I));
+    NonTypeTemplateParmDecl *Param
+      = dyn_cast<NonTypeTemplateParmDecl>(TemplateParams->getParam(I));
     if (!Param)
       continue;
 
@@ -8724,13 +8756,13 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
 
   // Find the class template we're specializing
   TemplateName Name = TemplateId.Template.get();
-  ClassTemplateDecl *ClassTemplate =
-      dyn_cast_or_null<ClassTemplateDecl>(Name.getAsTemplateDecl());
+  ClassTemplateDecl *ClassTemplate
+    = dyn_cast_or_null<ClassTemplateDecl>(Name.getAsTemplateDecl());
 
   if (!ClassTemplate) {
     Diag(TemplateNameLoc, diag::err_not_class_template_specialization)
-        << (Name.getAsTemplateDecl() &&
-            isa<TemplateTemplateParmDecl>(Name.getAsTemplateDecl()));
+      << (Name.getAsTemplateDecl() &&
+          isa<TemplateTemplateParmDecl>(Name.getAsTemplateDecl()));
     return true;
   }
 
@@ -8784,7 +8816,7 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
 
     if (TUK == TagUseKind::Friend) {
       Diag(KWLoc, diag::err_partial_specialization_friend)
-          << SourceRange(LAngleLoc, RAngleLoc);
+        << SourceRange(LAngleLoc, RAngleLoc);
       return true;
     }
 
@@ -8799,8 +8831,8 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
                diag::err_default_arg_in_partial_spec);
           TTP->removeDefaultArgument();
         }
-      } else if (NonTypeTemplateParmDecl *NTTP =
-                     dyn_cast<NonTypeTemplateParmDecl>(Param)) {
+      } else if (NonTypeTemplateParmDecl *NTTP
+                   = dyn_cast<NonTypeTemplateParmDecl>(Param)) {
         if (NTTP->hasDefaultArgument()) {
           Diag(NTTP->getDefaultArgumentLoc(),
                diag::err_default_arg_in_partial_spec)
@@ -8812,7 +8844,7 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
         if (TTP->hasDefaultArgument()) {
           Diag(TTP->getDefaultArgument().getLocation(),
                diag::err_default_arg_in_partial_spec)
-              << TTP->getDefaultArgument().getSourceRange();
+            << TTP->getDefaultArgument().getSourceRange();
           TTP->removeDefaultArgument();
         }
       }
@@ -8820,10 +8852,10 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
   } else if (TemplateParams) {
     if (TUK == TagUseKind::Friend)
       Diag(KWLoc, diag::err_template_spec_friend)
-          << FixItHint::CreateRemoval(
-                 SourceRange(TemplateParams->getTemplateLoc(),
-                             TemplateParams->getRAngleLoc()))
-          << SourceRange(LAngleLoc, RAngleLoc);
+        << FixItHint::CreateRemoval(
+                                SourceRange(TemplateParams->getTemplateLoc(),
+                                            TemplateParams->getRAngleLoc()))
+        << SourceRange(LAngleLoc, RAngleLoc);
   } else {
     assert(TUK == TagUseKind::Friend &&
            "should have a 'template<>' for this decl");
@@ -8838,9 +8870,9 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
                                     TUK == TagUseKind::Definition, KWLoc,
                                     ClassTemplate->getIdentifier())) {
     Diag(KWLoc, diag::err_use_with_wrong_tag)
-        << ClassTemplate
-        << FixItHint::CreateReplacement(
-               KWLoc, ClassTemplate->getTemplatedDecl()->getKindName());
+      << ClassTemplate
+      << FixItHint::CreateReplacement(KWLoc,
+                            ClassTemplate->getTemplatedDecl()->getKindName());
     Diag(ClassTemplate->getTemplatedDecl()->getLocation(),
          diag::note_previous_use);
     Kind = ClassTemplate->getTemplatedDecl()->getTagKind();
@@ -8881,7 +8913,7 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
         !TemplateSpecializationType::anyDependentTemplateArguments(
             TemplateArgs, CTAI.CanonicalConverted)) {
       Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
-          << ClassTemplate->getDeclName();
+        << ClassTemplate->getDeclName();
       isPartialSpecialization = false;
       Invalid = true;
     }
@@ -9000,8 +9032,8 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
 
       Diag(PrevDecl->getPointOfInstantiation(),
            diag::note_instantiation_required_here)
-          << (PrevDecl->getTemplateSpecializationKind() !=
-              TSK_ImplicitInstantiation);
+        << (PrevDecl->getTemplateSpecializationKind()
+                                                != TSK_ImplicitInstantiation);
       return true;
     }
   }
@@ -9044,8 +9076,8 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
 
   if (ModulePrivateLoc.isValid())
     Diag(Specialization->getLocation(), diag::err_module_private_specialization)
-        << (isPartialSpecialization ? 1 : 0)
-        << FixItHint::CreateRemoval(ModulePrivateLoc);
+      << (isPartialSpecialization? 1 : 0)
+      << FixItHint::CreateRemoval(ModulePrivateLoc);
 
   // C++ [temp.expl.spec]p9:
   //   A template explicit specialization is in the scope of the
@@ -9076,9 +9108,10 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
     // actually wrote the specialization, rather than formatting the
     // name based on the "canonical" representation used to store the
     // template arguments in the specialization.
-    FriendDecl *Friend =
-        FriendDecl::Create(Context, CurContext, TemplateNameLoc, WrittenTy,
-                           /*FIXME:*/ KWLoc);
+    FriendDecl *Friend = FriendDecl::Create(Context, CurContext,
+                                            TemplateNameLoc,
+                                            WrittenTy,
+                                            /*FIXME:*/KWLoc);
     Friend->setAccess(AS_public);
     CurContext->addDecl(Friend);
   } else {
@@ -9096,8 +9129,9 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
   return Specialization;
 }
 
-Decl *Sema::ActOnTemplateDeclarator(
-    Scope *S, MultiTemplateParamsArg TemplateParameterLists, Declarator &D) {
+Decl *Sema::ActOnTemplateDeclarator(Scope *S,
+                              MultiTemplateParamsArg TemplateParameterLists,
+                                    Declarator &D) {
   Decl *NewDecl = HandleDeclarator(S, D, TemplateParameterLists);
   ActOnDocumentableDecl(NewDecl);
   return NewDecl;
@@ -9110,7 +9144,7 @@ ConceptDecl *Sema::ActOnStartConceptDefinition(
 
   if (!DC->getRedeclContext()->isFileContext()) {
     Diag(NameLoc,
-         diag::err_concept_decls_may_only_appear_in_global_namespace_scope);
+      diag::err_concept_decls_may_only_appear_in_global_namespace_scope);
     return nullptr;
   }
 
@@ -9219,8 +9253,7 @@ void Sema::CheckConceptRedefinition(ConceptDecl *NewDecl,
   if (Previous.empty())
     return;
 
-  auto *OldConcept = dyn_cast<ConceptDecl>(
-      Previous.getRepresentativeDecl()->getUnderlyingDecl());
+  auto *OldConcept = dyn_cast<ConceptDecl>(Previous.getRepresentativeDecl()->getUnderlyingDecl());
   if (!OldConcept) {
     auto *Old = Previous.getRepresentativeDecl();
     Diag(NewDecl->getLocation(), diag::err_redefinition_different_kind)
@@ -9280,9 +9313,8 @@ static void StripImplicitInstantiation(NamedDecl *D, bool MinGW) {
 
 /// Compute the diagnostic location for an explicit instantiation
 //  declaration or definition.
-static SourceLocation
-DiagLocForExplicitInstantiation(NamedDecl *D,
-                                SourceLocation PointOfInstantiation) {
+static SourceLocation DiagLocForExplicitInstantiation(
+    NamedDecl* D, SourceLocation PointOfInstantiation) {
   // Explicit instantiations following a specialization have no effect and
   // hence no PointOfInstantiation. In that case, walk decl backwards
   // until a valid name loc is found.
@@ -9296,10 +9328,13 @@ DiagLocForExplicitInstantiation(NamedDecl *D,
   return PrevDiagLoc;
 }
 
-bool Sema::CheckSpecializationInstantiationRedecl(
-    SourceLocation NewLoc, TemplateSpecializationKind NewTSK,
-    NamedDecl *PrevDecl, TemplateSpecializationKind PrevTSK,
-    SourceLocation PrevPointOfInstantiation, bool &HasNoEffect) {
+bool
+Sema::CheckSpecializationInstantiationRedecl(SourceLocation NewLoc,
+                                             TemplateSpecializationKind NewTSK,
+                                             NamedDecl *PrevDecl,
+                                             TemplateSpecializationKind PrevTSK,
+                                        SourceLocation PrevPointOfInstantiation,
+                                             bool &HasNoEffect) {
   HasNoEffect = false;
 
   switch (NewTSK) {
@@ -9348,9 +9383,10 @@ bool Sema::CheckSpecializationInstantiationRedecl(
           return false;
       }
 
-      Diag(NewLoc, diag::err_specialization_after_instantiation) << PrevDecl;
+      Diag(NewLoc, diag::err_specialization_after_instantiation)
+        << PrevDecl;
       Diag(PrevPointOfInstantiation, diag::note_instantiation_required_here)
-          << (PrevTSK != TSK_ImplicitInstantiation);
+        << (PrevTSK != TSK_ImplicitInstantiation);
 
       return true;
     }
@@ -9411,7 +9447,7 @@ bool Sema::CheckSpecializationInstantiationRedecl(
       //   an explicit specialization for that template, the explicit
       //   instantiation has no effect.
       Diag(NewLoc, diag::warn_explicit_instantiation_after_specialization)
-          << PrevDecl;
+        << PrevDecl;
       Diag(PrevDecl->getLocation(),
            diag::note_previous_template_specialization);
       HasNoEffect = true;
@@ -9512,14 +9548,14 @@ bool Sema::CheckFunctionTemplateSpecialization(
       ConvertedTemplateArgs;
 
   DeclContext *FDLookupContext = FD->getDeclContext()->getRedeclContext();
-  for (LookupResult::iterator I = Previous.begin(), E = Previous.end(); I != E;
-       ++I) {
+  for (LookupResult::iterator I = Previous.begin(), E = Previous.end();
+         I != E; ++I) {
     NamedDecl *Ovl = (*I)->getUnderlyingDecl();
     if (FunctionTemplateDecl *FunTmpl = dyn_cast<FunctionTemplateDecl>(Ovl)) {
       // Only consider templates found within the same semantic lookup scope as
       // FD.
       if (!FDLookupContext->InEnclosingNamespaceSetOf(
-              Ovl->getDeclContext()->getRedeclContext()))
+                                Ovl->getDeclContext()->getRedeclContext()))
         continue;
 
       QualType FT = FD->getType();
@@ -9666,8 +9702,8 @@ bool Sema::CheckFunctionTemplateSpecialization(
       !ResolveExceptionSpec(FD->getLocation(), SpecializationFPT))
     return true;
 
-  FunctionTemplateSpecializationInfo *SpecInfo =
-      Specialization->getTemplateSpecializationInfo();
+  FunctionTemplateSpecializationInfo *SpecInfo
+    = Specialization->getTemplateSpecializationInfo();
   assert(SpecInfo && "Function template specialization info missing?");
 
   // Note: do not overwrite location info if previous template
@@ -9693,9 +9729,11 @@ bool Sema::CheckFunctionTemplateSpecialization(
   bool isFriend = (FD->getFriendObjectKind() != Decl::FOK_None);
 
   // Check the scope of this explicit specialization.
-  if (!isFriend && CheckTemplateSpecializationScope(
-                       *this, Specialization->getPrimaryTemplate(),
-                       Specialization, FD->getLocation(), false))
+  if (!isFriend &&
+      CheckTemplateSpecializationScope(*this,
+                                       Specialization->getPrimaryTemplate(),
+                                       Specialization, FD->getLocation(),
+                                       false))
     return true;
 
   // C++ [temp.expl.spec]p6:
@@ -9706,10 +9744,12 @@ bool Sema::CheckFunctionTemplateSpecialization(
   //   use occurs; no diagnostic is required.
   bool HasNoEffect = false;
   if (!isFriend &&
-      CheckSpecializationInstantiationRedecl(
-          FD->getLocation(), TSK_ExplicitSpecialization, Specialization,
-          SpecInfo->getTemplateSpecializationKind(),
-          SpecInfo->getPointOfInstantiation(), HasNoEffect))
+      CheckSpecializationInstantiationRedecl(FD->getLocation(),
+                                             TSK_ExplicitSpecialization,
+                                             Specialization,
+                                   SpecInfo->getTemplateSpecializationKind(),
+                                         SpecInfo->getPointOfInstantiation(),
+                                             HasNoEffect))
     return true;
 
   // Mark the prior declaration as an explicit specialization, so that later
@@ -9766,8 +9806,8 @@ bool Sema::CheckFunctionTemplateSpecialization(
   return false;
 }
 
-bool Sema::CheckMemberSpecialization(NamedDecl *Member,
-                                     LookupResult &Previous) {
+bool
+Sema::CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous) {
   assert(!Member->isTemplateDecl() && !Member->getDescribedTemplate() &&
          "Only for non-template members");
 
@@ -9901,12 +9941,12 @@ bool Sema::CheckMemberSpecialization(NamedDecl *Member,
     // Preserve instantiation information.
     if (InstantiatedFrom && isa<CXXMethodDecl>(Member)) {
       cast<CXXMethodDecl>(Member)->setInstantiationOfMemberFunction(
-          cast<CXXMethodDecl>(InstantiatedFrom),
-          cast<CXXMethodDecl>(Instantiation)->getTemplateSpecializationKind());
+                                      cast<CXXMethodDecl>(InstantiatedFrom),
+        cast<CXXMethodDecl>(Instantiation)->getTemplateSpecializationKind());
     } else if (InstantiatedFrom && isa<CXXRecordDecl>(Member)) {
       cast<CXXRecordDecl>(Member)->setInstantiationOfMemberClass(
-          cast<CXXRecordDecl>(InstantiatedFrom),
-          cast<CXXRecordDecl>(Instantiation)->getTemplateSpecializationKind());
+                                      cast<CXXRecordDecl>(InstantiatedFrom),
+        cast<CXXRecordDecl>(Instantiation)->getTemplateSpecializationKind());
     }
 
     Previous.clear();
@@ -9917,7 +9957,7 @@ bool Sema::CheckMemberSpecialization(NamedDecl *Member,
   // Make sure that this is a specialization of a member.
   if (!InstantiatedFrom) {
     Diag(Member->getLocation(), diag::err_spec_member_not_instantiated)
-        << Member;
+      << Member;
     Diag(Instantiation->getLocation(), diag::note_specialized_decl);
     return true;
   }
@@ -9931,15 +9971,19 @@ bool Sema::CheckMemberSpecialization(NamedDecl *Member,
   assert(MSInfo && "Member specialization info missing?");
 
   bool HasNoEffect = false;
-  if (CheckSpecializationInstantiationRedecl(
-          Member->getLocation(), TSK_ExplicitSpecialization, Instantiation,
-          MSInfo->getTemplateSpecializationKind(),
-          MSInfo->getPointOfInstantiation(), HasNoEffect))
+  if (CheckSpecializationInstantiationRedecl(Member->getLocation(),
+                                             TSK_ExplicitSpecialization,
+                                             Instantiation,
+                                     MSInfo->getTemplateSpecializationKind(),
+                                           MSInfo->getPointOfInstantiation(),
+                                             HasNoEffect))
     return true;
 
   // Check the scope of this explicit specialization.
-  if (CheckTemplateSpecializationScope(*this, InstantiatedFrom, Instantiation,
-                                       Member->getLocation(), false))
+  if (CheckTemplateSpecializationScope(*this,
+                                       InstantiatedFrom,
+                                       Instantiation, Member->getLocation(),
+                                       false))
     return true;
 
   // Note that this member specialization is an "instantiation of" the
@@ -9947,7 +9991,7 @@ bool Sema::CheckMemberSpecialization(NamedDecl *Member,
   if (auto *MemberFunction = dyn_cast<FunctionDecl>(Member)) {
     FunctionDecl *InstantiationFunction = cast<FunctionDecl>(Instantiation);
     if (InstantiationFunction->getTemplateSpecializationKind() ==
-        TSK_ImplicitInstantiation) {
+          TSK_ImplicitInstantiation) {
       // Explicit specializations of member functions of class templates do not
       // inherit '=delete' from the member function they are specializing.
       if (InstantiationFunction->isDeleted()) {
@@ -9968,8 +10012,8 @@ bool Sema::CheckMemberSpecialization(NamedDecl *Member,
     MemberClass->setInstantiationOfMemberClass(
         cast<CXXRecordDecl>(InstantiatedFrom), TSK_ExplicitSpecialization);
   } else if (auto *MemberEnum = dyn_cast<EnumDecl>(Member)) {
-    MemberEnum->setInstantiationOfMemberEnum(cast<EnumDecl>(InstantiatedFrom),
-                                             TSK_ExplicitSpecialization);
+    MemberEnum->setInstantiationOfMemberEnum(
+        cast<EnumDecl>(InstantiatedFrom), TSK_ExplicitSpecialization);
   } else {
     llvm_unreachable("unknown member specialization kind");
   }
@@ -9986,7 +10030,7 @@ bool Sema::CheckMemberSpecialization(NamedDecl *Member,
 ///
 /// \param OrigD The member declaration instantiated from the template.
 /// \param Loc The location of the explicit specialization of the member.
-template <typename DeclT>
+template<typename DeclT>
 static void completeMemberSpecializationImpl(Sema &S, DeclT *OrigD,
                                              SourceLocation Loc) {
   if (OrigD->getTemplateSpecializationKind() != TSK_ImplicitInstantiation)
@@ -10024,12 +10068,12 @@ void Sema::CompleteMemberSpecialization(NamedDecl *Member,
 static bool CheckExplicitInstantiationScope(Sema &S, NamedDecl *D,
                                             SourceLocation InstLoc,
                                             bool WasQualifiedName) {
-  DeclContext *OrigContext =
-      D->getDeclContext()->getEnclosingNamespaceContext();
+  DeclContext *OrigContext= D->getDeclContext()->getEnclosingNamespaceContext();
   DeclContext *CurContext = S.CurContext->getRedeclContext();
 
   if (CurContext->isRecord()) {
-    S.Diag(InstLoc, diag::err_explicit_instantiation_in_class) << D;
+    S.Diag(InstLoc, diag::err_explicit_instantiation_in_class)
+      << D;
     return true;
   }
 
@@ -10051,23 +10095,23 @@ static bool CheckExplicitInstantiationScope(Sema &S, NamedDecl *D,
 
   if (NamespaceDecl *NS = dyn_cast<NamespaceDecl>(OrigContext)) {
     if (WasQualifiedName)
-      S.Diag(InstLoc, S.getLangOpts().CPlusPlus11
-                          ? diag::err_explicit_instantiation_out_of_scope
-                          : diag::warn_explicit_instantiation_out_of_scope_0x)
-          << D << NS;
+      S.Diag(InstLoc,
+             S.getLangOpts().CPlusPlus11?
+               diag::err_explicit_instantiation_out_of_scope :
+               diag::warn_explicit_instantiation_out_of_scope_0x)
+        << D << NS;
     else
-      S.Diag(
-          InstLoc,
-          S.getLangOpts().CPlusPlus11
-              ? diag::err_explicit_instantiation_unqualified_wrong_namespace
-              : diag::
-                    warn_explicit_instantiation_unqualified_wrong_namespace_0x)
-          << D << NS;
+      S.Diag(InstLoc,
+             S.getLangOpts().CPlusPlus11?
+               diag::err_explicit_instantiation_unqualified_wrong_namespace :
+               diag::warn_explicit_instantiation_unqualified_wrong_namespace_0x)
+        << D << NS;
   } else
-    S.Diag(InstLoc, S.getLangOpts().CPlusPlus11
-                        ? diag::err_explicit_instantiation_must_be_global
-                        : diag::warn_explicit_instantiation_must_be_global_0x)
-        << D;
+    S.Diag(InstLoc,
+           S.getLangOpts().CPlusPlus11?
+             diag::err_explicit_instantiation_must_be_global :
+             diag::warn_explicit_instantiation_must_be_global_0x)
+      << D;
   S.Diag(D->getLocation(), diag::note_explicit_instantiation_here);
   return false;
 }
@@ -10163,13 +10207,13 @@ DeclResult Sema::ActOnExplicitInstantiation(
     return true;
   }
 
-  if (!isAcceptableTagRedeclaration(ClassTemplate->getTemplatedDecl(), Kind,
-                                    /*isDefinition*/ false, KWLoc,
+  if (!isAcceptableTagRedeclaration(ClassTemplate->getTemplatedDecl(),
+                                    Kind, /*isDefinition*/false, KWLoc,
                                     ClassTemplate->getIdentifier())) {
     Diag(KWLoc, diag::err_use_with_wrong_tag)
-        << ClassTemplate
-        << FixItHint::CreateReplacement(
-               KWLoc, ClassTemplate->getTemplatedDecl()->getKindName());
+      << ClassTemplate
+      << FixItHint::CreateReplacement(KWLoc,
+                            ClassTemplate->getTemplatedDecl()->getKindName());
     Diag(ClassTemplate->getTemplatedDecl()->getLocation(),
          diag::note_previous_use);
     Kind = ClassTemplate->getTemplatedDecl()->getTagKind();
@@ -10245,8 +10289,8 @@ DeclResult Sema::ActOnExplicitInstantiation(
   ClassTemplateSpecializationDecl *PrevDecl =
       ClassTemplate->findSpecialization(CTAI.CanonicalConverted, InsertPos);
 
-  TemplateSpecializationKind PrevDecl_TSK =
-      PrevDecl ? PrevDecl->getTemplateSpecializationKind() : TSK_Undeclared;
+  TemplateSpecializationKind PrevDecl_TSK
+    = PrevDecl ? PrevDecl->getTemplateSpecializationKind() : TSK_Undeclared;
 
   if (TSK == TSK_ExplicitInstantiationDefinition && PrevDecl != nullptr &&
       Context.getTargetInfo().getTriple().isOSCygMing()) {
@@ -10285,9 +10329,10 @@ DeclResult Sema::ActOnExplicitInstantiation(
 
   bool HasNoEffect = false;
   if (PrevDecl) {
-    if (CheckSpecializationInstantiationRedecl(
-            TemplateNameLoc, TSK, PrevDecl, PrevDecl_TSK,
-            PrevDecl->getPointOfInstantiation(), HasNoEffect))
+    if (CheckSpecializationInstantiationRedecl(TemplateNameLoc, TSK,
+                                               PrevDecl, PrevDecl_TSK,
+                                            PrevDecl->getPointOfInstantiation(),
+                                               HasNoEffect))
       return PrevDecl;
 
     // Even though HasNoEffect == true means that this explicit instantiation
@@ -10368,9 +10413,9 @@ DeclResult Sema::ActOnExplicitInstantiation(
   //
   // This check comes when we actually try to perform the
   // instantiation.
-  ClassTemplateSpecializationDecl *Def =
-      cast_or_null<ClassTemplateSpecializationDecl>(
-          Specialization->getDefinition());
+  ClassTemplateSpecializationDecl *Def
+    = cast_or_null<ClassTemplateSpecializationDecl>(
+                                              Specialization->getDefinition());
   if (!Def)
     InstantiateClassTemplateSpecialization(TemplateNameLoc, Specialization, TSK,
                                            /*Complain=*/true,
@@ -10382,7 +10427,7 @@ DeclResult Sema::ActOnExplicitInstantiation(
 
   // Instantiate the members of this class template specialization.
   Def = cast_or_null<ClassTemplateSpecializationDecl>(
-      Specialization->getDefinition());
+                                       Specialization->getDefinition());
   if (Def) {
     TemplateSpecializationKind Old_TSK = Def->getTemplateSpecializationKind();
     // Fix a TSK_ExplicitInstantiationDeclaration followed by a
@@ -10466,8 +10511,7 @@ Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
                false, TypeResult(), /*IsTypeSpecifier*/ false,
                /*IsTemplateParamOrArg*/ false, /*OOK=*/OffsetOfKind::Outside)
           .get();
-  assert(!IsDependent &&
-         "explicit instantiation of dependent name not yet handled");
+  assert(!IsDependent && "explicit instantiation of dependent name not yet handled");
 
   if (!TagD)
     return true;
@@ -10495,50 +10539,55 @@ Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
   // C++98 has the same restriction, just worded differently.
   if (!ScopeSpecifierHasTemplateId(SS))
     Diag(TemplateLoc, diag::ext_explicit_instantiation_without_qualified_id)
-        << Record << SS.getRange();
+      << Record << SS.getRange();
 
   // C++0x [temp.explicit]p2:
   //   There are two forms of explicit instantiation: an explicit instantiation
   //   definition and an explicit instantiation declaration. An explicit
   //   instantiation declaration begins with the extern keyword. [...]
-  TemplateSpecializationKind TSK = ExternLoc.isInvalid()
-                                       ? TSK_ExplicitInstantiationDefinition
-                                       : TSK_ExplicitInstantiationDeclaration;
+  TemplateSpecializationKind TSK
+    = ExternLoc.isInvalid()? TSK_ExplicitInstantiationDefinition
+                           : TSK_ExplicitInstantiationDeclaration;
 
   CheckExplicitInstantiation(*this, Record, NameLoc, true, TSK);
 
   // Verify that it is okay to explicitly instantiate here.
-  CXXRecordDecl *PrevDecl =
-      cast_or_null<CXXRecordDecl>(Record->getPreviousDecl());
+  CXXRecordDecl *PrevDecl
+    = cast_or_null<CXXRecordDecl>(Record->getPreviousDecl());
   if (!PrevDecl && Record->getDefinition())
     PrevDecl = Record;
   if (PrevDecl) {
     MemberSpecializationInfo *MSInfo = PrevDecl->getMemberSpecializationInfo();
     bool HasNoEffect = false;
     assert(MSInfo && "No member specialization information?");
-    if (CheckSpecializationInstantiationRedecl(
-            TemplateLoc, TSK, PrevDecl, MSInfo->getTemplateSpecializationKind(),
-            MSInfo->getPointOfInstantiation(), HasNoEffect))
+    if (CheckSpecializationInstantiationRedecl(TemplateLoc, TSK,
+                                               PrevDecl,
+                                        MSInfo->getTemplateSpecializationKind(),
+                                             MSInfo->getPointOfInstantiation(),
+                                               HasNoEffect))
       return true;
     if (HasNoEffect)
       return TagD;
   }
 
-  CXXRecordDecl *RecordDef =
-      cast_or_null<CXXRecordDecl>(Record->getDefinition());
+  CXXRecordDecl *RecordDef
+    = cast_or_null<CXXRecordDecl>(Record->getDefinition());
   if (!RecordDef) {
     // C++ [temp.explicit]p3:
     //   A definition of a member class of a class template shall be in scope
     //   at the point of an explicit instantiation of the member class.
-    CXXRecordDecl *Def = cast_or_null<CXXRecordDecl>(Pattern->getDefinition());
+    CXXRecordDecl *Def
+      = cast_or_null<CXXRecordDecl>(Pattern->getDefinition());
     if (!Def) {
       Diag(TemplateLoc, diag::err_explicit_instantiation_undefined_member)
-          << 0 << Record->getDeclName() << Record->getDeclContext();
-      Diag(Pattern->getLocation(), diag::note_forward_declaration) << Pattern;
+        << 0 << Record->getDeclName() << Record->getDeclContext();
+      Diag(Pattern->getLocation(), diag::note_forward_declaration)
+        << Pattern;
       return true;
     } else {
       if (InstantiateClass(NameLoc, Record, Def,
-                           getTemplateInstantiationArgs(Record), TSK))
+                           getTemplateInstantiationArgs(Record),
+                           TSK))
         return true;
 
       RecordDef = cast_or_null<CXXRecordDecl>(Record->getDefinition());
@@ -10561,7 +10610,8 @@ Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
   return TagD;
 }
 
-DeclResult Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
+DeclResult Sema::ActOnExplicitInstantiation(Scope *S,
+                                            SourceLocation ExternLoc,
                                             SourceLocation TemplateLoc,
                                             Declarator &D) {
   // Explicit instantiations always require a name.
@@ -10591,13 +10641,13 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
   //   instantiation (14.7.2) directive.
   if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_typedef) {
     Diag(D.getIdentifierLoc(), diag::err_explicit_instantiation_of_typedef)
-        << Name;
+      << Name;
     return true;
-  } else if (D.getDeclSpec().getStorageClassSpec() !=
-             DeclSpec::SCS_unspecified) {
+  } else if (D.getDeclSpec().getStorageClassSpec()
+                                                != DeclSpec::SCS_unspecified) {
     // Complain about then remove the storage class specifier.
     Diag(D.getIdentifierLoc(), diag::err_explicit_instantiation_storage_class)
-        << FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc());
+      << FixItHint::CreateRemoval(D.getDeclSpec().getStorageClassSpecLoc());
 
     D.getMutableDeclSpec().ClearStorageClassSpecs();
   }
@@ -10609,10 +10659,10 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
   // well.
   if (D.getDeclSpec().isInlineSpecified())
     Diag(D.getDeclSpec().getInlineSpecLoc(),
-         getLangOpts().CPlusPlus11
-             ? diag::err_explicit_instantiation_inline
-             : diag::warn_explicit_instantiation_inline_0x)
-        << FixItHint::CreateRemoval(D.getDeclSpec().getInlineSpecLoc());
+         getLangOpts().CPlusPlus11 ?
+           diag::err_explicit_instantiation_inline :
+           diag::warn_explicit_instantiation_inline_0x)
+      << FixItHint::CreateRemoval(D.getDeclSpec().getInlineSpecLoc());
   if (D.getDeclSpec().hasConstexprSpecifier() && R->isFunctionType())
     // FIXME: Add a fix-it to remove the 'constexpr' and add a 'const' if one is
     // not already specified.
@@ -10631,9 +10681,9 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
   //   There are two forms of explicit instantiation: an explicit instantiation
   //   definition and an explicit instantiation declaration. An explicit
   //   instantiation declaration begins with the extern keyword. [...]
-  TemplateSpecializationKind TSK = ExternLoc.isInvalid()
-                                       ? TSK_ExplicitInstantiationDefinition
-                                       : TSK_ExplicitInstantiationDeclaration;
+  TemplateSpecializationKind TSK
+    = ExternLoc.isInvalid()? TSK_ExplicitInstantiationDefinition
+                           : TSK_ExplicitInstantiationDeclaration;
 
   LookupResult Previous(*this, NameInfo, LookupOrdinaryName);
   LookupParsedName(Previous, S, &D.getCXXScopeSpec(),
@@ -10693,7 +10743,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
         //   in the declaration shall be a template-id.
         Diag(D.getIdentifierLoc(),
              diag::err_explicit_instantiation_without_template_id)
-            << PrevTemplate;
+          << PrevTemplate;
         Diag(PrevTemplate->getLocation(),
              diag::note_explicit_instantiation_here);
         return true;
@@ -10735,7 +10785,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
     if (!ScopeSpecifierHasTemplateId(D.getCXXScopeSpec()) && !PrevTemplate)
       Diag(D.getIdentifierLoc(),
            diag::ext_explicit_instantiation_without_qualified_id)
-          << Prev << D.getCXXScopeSpec().getRange();
+        << Prev << D.getCXXScopeSpec().getRange();
 
     CheckExplicitInstantiation(*this, Prev, D.getIdentifierLoc(), true, TSK);
 
@@ -10775,7 +10825,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
     }
 
     // FIXME: Create an ExplicitInstantiation node?
-    return (Decl *)nullptr;
+    return (Decl*) nullptr;
   }
 
   // If the declarator is a template-id, translate the parser's template
@@ -10802,7 +10852,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
     if (!HasExplicitTemplateArgs) {
       if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Prev)) {
         QualType Adjusted = adjustCCAndNoReturn(R, Method->getType(),
-                                                /*AdjustExceptionSpec*/ true);
+                                                /*AdjustExceptionSpec*/true);
         if (Context.hasSameUnqualifiedType(Method->getType(), Adjusted)) {
           if (Method->getPrimaryTemplate()) {
             TemplateMatches.addDecl(Method, P.getAccess());
@@ -10902,8 +10952,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
     if (Result == TemplateMatches.end())
       return true;
 
-    // Ignore access control bits, we don't need them for redeclaration
-    // checking.
+    // Ignore access control bits, we don't need them for redeclaration checking.
     Specialization = cast<FunctionDecl>(*Result);
   }
 
@@ -10933,9 +10982,9 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
   if (Specialization->getTemplateSpecializationKind() == TSK_Undeclared) {
     Diag(D.getIdentifierLoc(),
          diag::err_explicit_instantiation_member_function_not_instantiated)
-        << Specialization
-        << (Specialization->getTemplateSpecializationKind() ==
-            TSK_ExplicitSpecialization);
+      << Specialization
+      << (Specialization->getTemplateSpecializationKind() ==
+          TSK_ExplicitSpecialization);
     Diag(Specialization->getLocation(), diag::note_explicit_instantiation_here);
     return true;
   }
@@ -10946,16 +10995,17 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
 
   if (PrevDecl) {
     bool HasNoEffect = false;
-    if (CheckSpecializationInstantiationRedecl(
-            D.getIdentifierLoc(), TSK, PrevDecl,
-            PrevDecl->getTemplateSpecializationKind(),
-            PrevDecl->getPointOfInstantiation(), HasNoEffect))
+    if (CheckSpecializationInstantiationRedecl(D.getIdentifierLoc(), TSK,
+                                               PrevDecl,
+                                     PrevDecl->getTemplateSpecializationKind(),
+                                          PrevDecl->getPointOfInstantiation(),
+                                               HasNoEffect))
       return true;
 
     // FIXME: We may still want to build some representation of this
     // explicit specialization.
     if (HasNoEffect)
-      return (Decl *)nullptr;
+      return (Decl*) nullptr;
   }
 
   // HACK: libc++ has a bug where it attempts to explicitly instantiate the
@@ -10969,7 +11019,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
     if (auto *RD = dyn_cast<CXXRecordDecl>(Specialization->getDeclContext()))
       if (RD->getIdentifier() && RD->getIdentifier()->isStr("valarray") &&
           RD->isInStdNamespace())
-        return (Decl *)nullptr;
+        return (Decl*) nullptr;
   }
 
   ProcessDeclAttributeList(S, Specialization, D.getDeclSpec().getAttributes());
@@ -11004,7 +11054,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
       !ScopeSpecifierHasTemplateId(D.getCXXScopeSpec()))
     Diag(D.getIdentifierLoc(),
          diag::ext_explicit_instantiation_without_qualified_id)
-        << Specialization << D.getCXXScopeSpec().getRange();
+    << Specialization << D.getCXXScopeSpec().getRange();
 
   CheckExplicitInstantiation(
       *this,
@@ -11013,7 +11063,7 @@ DeclResult Sema::ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc,
       D.getIdentifierLoc(), D.getCXXScopeSpec().isSet(), TSK);
 
   // FIXME: Create some kind of ExplicitInstantiationDecl here.
-  return (Decl *)nullptr;
+  return (Decl*) nullptr;
 }
 
 TypeResult Sema::ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
@@ -11094,9 +11144,8 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
     if (LookupRD && LookupRD->getIdentifier() == TemplateII) {
       Diag(TemplateIILoc,
            diag::ext_out_of_line_qualified_id_type_names_constructor)
-          << TemplateII << 0 /*injected-class-name used as template name*/
-          << (TemplateKWLoc.isValid() ? 1
-                                      : 0 /*'template'/'typename' keyword*/);
+        << TemplateII << 0 /*injected-class-name used as template name*/
+        << (TemplateKWLoc.isValid() ? 1 : 0 /*'template'/'typename' keyword*/);
     }
   }
 
@@ -11114,8 +11163,8 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
 
   // Provide source-location information for the template specialization type.
   TypeLocBuilder Builder;
-  TemplateSpecializationTypeLoc SpecTL =
-      Builder.push<TemplateSpecializationTypeLoc>(T);
+  TemplateSpecializationTypeLoc SpecTL
+    = Builder.push<TemplateSpecializationTypeLoc>(T);
   SpecTL.set(TypenameLoc, SS.getWithLocInContext(Context), TemplateKWLoc,
              TemplateIILoc, TemplateArgs);
   TypeSourceInfo *TSI = Builder.getTypeSourceInfo(Context, T);
@@ -11143,13 +11192,13 @@ static bool isEnableIf(NestedNameSpecifierLoc NNS, const IdentifierInfo &II,
 
   // ... which names a complete class template declaration...
   const TemplateDecl *EnableIfDecl =
-      EnableIfTST->getTemplateName().getAsTemplateDecl();
+    EnableIfTST->getTemplateName().getAsTemplateDecl();
   if (!EnableIfDecl || EnableIfTST->isIncompleteType())
     return false;
 
   // ... called "enable_if".
   const IdentifierInfo *EnableIfII =
-      EnableIfDecl->getDeclName().getAsIdentifierInfo();
+    EnableIfDecl->getDeclName().getAsIdentifierInfo();
   if (!EnableIfII || !EnableIfII->isStr("enable_if"))
     return false;
 
@@ -11158,8 +11207,8 @@ static bool isEnableIf(NestedNameSpecifierLoc NNS, const IdentifierInfo &II,
 
   // Dig out the condition.
   Cond = nullptr;
-  if (EnableIfTSTLoc.getArgLoc(0).getArgument().getKind() !=
-      TemplateArgument::Expression)
+  if (EnableIfTSTLoc.getArgLoc(0).getArgument().getKind()
+        != TemplateArgument::Expression)
     return true;
 
   Cond = EnableIfTSTLoc.getArgLoc(0).getSourceExpression();
@@ -11171,11 +11220,14 @@ static bool isEnableIf(NestedNameSpecifierLoc NNS, const IdentifierInfo &II,
   return true;
 }
 
-QualType Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
-                                 SourceLocation KeywordLoc,
-                                 NestedNameSpecifierLoc QualifierLoc,
-                                 const IdentifierInfo &II, SourceLocation IILoc,
-                                 TypeSourceInfo **TSI, bool DeducedTSTContext) {
+QualType
+Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
+                        SourceLocation KeywordLoc,
+                        NestedNameSpecifierLoc QualifierLoc,
+                        const IdentifierInfo &II,
+                        SourceLocation IILoc,
+                        TypeSourceInfo **TSI,
+                        bool DeducedTSTContext) {
   QualType T = CheckTypenameType(Keyword, KeywordLoc, QualifierLoc, II, IILoc,
                                  DeducedTSTContext);
   if (T.isNull())
@@ -11213,11 +11265,12 @@ QualType Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
 
 /// Build the type that describes a C++ typename specifier,
 /// e.g., "typename T::type".
-QualType Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
-                                 SourceLocation KeywordLoc,
-                                 NestedNameSpecifierLoc QualifierLoc,
-                                 const IdentifierInfo &II, SourceLocation IILoc,
-                                 bool DeducedTSTContext) {
+QualType
+Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
+                        SourceLocation KeywordLoc,
+                        NestedNameSpecifierLoc QualifierLoc,
+                        const IdentifierInfo &II,
+                        SourceLocation IILoc, bool DeducedTSTContext) {
   assert((Keyword != ElaboratedTypeKeyword::None) == KeywordLoc.isValid());
 
   CXXScopeSpec SS;
@@ -11230,8 +11283,9 @@ QualType Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
       // If the nested-name-specifier is dependent and couldn't be
       // resolved to a type, build a typename type.
       assert(QualifierLoc.getNestedNameSpecifier().isDependent());
-      return Context.getDependentNameType(
-          Keyword, QualifierLoc.getNestedNameSpecifier(), &II);
+      return Context.getDependentNameType(Keyword,
+                                          QualifierLoc.getNestedNameSpecifier(),
+                                          &II);
     }
 
     // If the nested-name-specifier refers to the current instantiation,
@@ -11265,21 +11319,23 @@ QualType Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
         Expr *FailedCond;
         std::string FailedDescription;
         std::tie(FailedCond, FailedDescription) =
-            findFailedBooleanCondition(Cond);
+          findFailedBooleanCondition(Cond);
 
         Diag(FailedCond->getExprLoc(),
              diag::err_typename_nested_not_found_requirement)
-            << FailedDescription << FailedCond->getSourceRange();
+          << FailedDescription
+          << FailedCond->getSourceRange();
         return QualType();
       }
 
-      Diag(CondRange.getBegin(), diag::err_typename_nested_not_found_enable_if)
+      Diag(CondRange.getBegin(),
+           diag::err_typename_nested_not_found_enable_if)
           << Ctx << CondRange;
       return QualType();
     }
 
-    DiagID =
-        Ctx ? diag::err_typename_nested_not_found : diag::err_unknown_typename;
+    DiagID = Ctx ? diag::err_typename_nested_not_found
+                 : diag::err_unknown_typename;
     break;
   }
 
@@ -11289,12 +11345,12 @@ QualType Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
     SourceRange FullRange(KeywordLoc.isValid() ? KeywordLoc : SS.getBeginLoc(),
                           IILoc);
     Diag(IILoc, diag::err_typename_refers_to_using_value_decl)
-        << Name << Ctx << FullRange;
-    if (UnresolvedUsingValueDecl *Using = dyn_cast<UnresolvedUsingValueDecl>(
-            Result.getRepresentativeDecl())) {
+      << Name << Ctx << FullRange;
+    if (UnresolvedUsingValueDecl *Using
+          = dyn_cast<UnresolvedUsingValueDecl>(Result.getRepresentativeDecl())){
       SourceLocation Loc = Using->getQualifierLoc().getBeginLoc();
       Diag(Loc, diag::note_using_value_decl_missing_typename)
-          << FixItHint::CreateInsertion(Loc, "typename ");
+        << FixItHint::CreateInsertion(Loc, "typename ");
     }
   }
     // Fall through to create a dependent typename type, from which we can
@@ -11303,8 +11359,9 @@ QualType Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
 
   case LookupResultKind::NotFoundInCurrentInstantiation:
     // Okay, it's a member of an unknown instantiation.
-    return Context.getDependentNameType(
-        Keyword, QualifierLoc.getNestedNameSpecifier(), &II);
+    return Context.getDependentNameType(Keyword,
+                                        QualifierLoc.getNestedNameSpecifier(),
+                                        &II);
 
   case LookupResultKind::Found:
     // FXIME: Missing support for UsingShadowDecl on this path?
@@ -11353,7 +11410,7 @@ QualType Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
                 << QualType(Qualifier.getAsType(), 0);
           else
             Diag(IILoc, diag::err_deduced_tst)
-                << (int)getTemplateNameKindForDiagnostics(TemplateName(TD));
+              << (int)getTemplateNameKindForDiagnostics(TemplateName(TD));
           NoteTemplateLocation(*TD);
           return QualType();
         }
@@ -11366,14 +11423,14 @@ QualType Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
       }
     }
 
-    DiagID =
-        Ctx ? diag::err_typename_nested_not_type : diag::err_typename_not_type;
+    DiagID = Ctx ? diag::err_typename_nested_not_type
+                 : diag::err_typename_not_type;
     Referenced = Result.getFoundDecl();
     break;
 
   case LookupResultKind::FoundOverloaded:
-    DiagID =
-        Ctx ? diag::err_typename_nested_not_type : diag::err_typename_not_type;
+    DiagID = Ctx ? diag::err_typename_nested_not_type
+                 : diag::err_typename_not_type;
     Referenced = *Result.begin();
     break;
 
@@ -11390,55 +11447,57 @@ QualType Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
   else
     Diag(IILoc, DiagID) << FullRange << Name;
   if (Referenced)
-    Diag(Referenced->getLocation(), Ctx ? diag::note_typename_member_refers_here
-                                        : diag::note_typename_refers_here)
-        << Name;
+    Diag(Referenced->getLocation(),
+         Ctx ? diag::note_typename_member_refers_here
+             : diag::note_typename_refers_here)
+      << Name;
   return QualType();
 }
 
 namespace {
-// See Sema::RebuildTypeInCurrentInstantiation
-class CurrentInstantiationRebuilder
+  // See Sema::RebuildTypeInCurrentInstantiation
+  class CurrentInstantiationRebuilder
     : public TreeTransform<CurrentInstantiationRebuilder> {
-  SourceLocation Loc;
-  DeclarationName Entity;
+    SourceLocation Loc;
+    DeclarationName Entity;
 
-public:
-  typedef TreeTransform<CurrentInstantiationRebuilder> inherited;
+  public:
+    typedef TreeTransform<CurrentInstantiationRebuilder> inherited;
 
-  CurrentInstantiationRebuilder(Sema &SemaRef, SourceLocation Loc,
-                                DeclarationName Entity)
-      : TreeTransform<CurrentInstantiationRebuilder>(SemaRef), Loc(Loc),
-        Entity(Entity) {}
+    CurrentInstantiationRebuilder(Sema &SemaRef,
+                                  SourceLocation Loc,
+                                  DeclarationName Entity)
+    : TreeTransform<CurrentInstantiationRebuilder>(SemaRef),
+      Loc(Loc), Entity(Entity) { }
 
-  /// Determine whether the given type \p T has already been
-  /// transformed.
-  ///
-  /// For the purposes of type reconstruction, a type has already been
-  /// transformed if it is NULL or if it is not dependent.
-  bool AlreadyTransformed(QualType T) {
-    return T.isNull() || !T->isInstantiationDependentType();
-  }
+    /// Determine whether the given type \p T has already been
+    /// transformed.
+    ///
+    /// For the purposes of type reconstruction, a type has already been
+    /// transformed if it is NULL or if it is not dependent.
+    bool AlreadyTransformed(QualType T) {
+      return T.isNull() || !T->isInstantiationDependentType();
+    }
 
-  /// Returns the location of the entity whose type is being
-  /// rebuilt.
-  SourceLocation getBaseLocation() { return Loc; }
+    /// Returns the location of the entity whose type is being
+    /// rebuilt.
+    SourceLocation getBaseLocation() { return Loc; }
 
-  /// Returns the name of the entity whose type is being rebuilt.
-  DeclarationName getBaseEntity() { return Entity; }
+    /// Returns the name of the entity whose type is being rebuilt.
+    DeclarationName getBaseEntity() { return Entity; }
 
-  /// Sets the "base" location and entity when that
-  /// information is known based on another transformation.
-  void setBase(SourceLocation Loc, DeclarationName Entity) {
-    this->Loc = Loc;
-    this->Entity = Entity;
-  }
+    /// Sets the "base" location and entity when that
+    /// information is known based on another transformation.
+    void setBase(SourceLocation Loc, DeclarationName Entity) {
+      this->Loc = Loc;
+      this->Entity = Entity;
+    }
 
-  ExprResult TransformLambdaExpr(LambdaExpr *E) {
-    // Lambdas never need to be transformed.
-    return E;
-  }
-};
+    ExprResult TransformLambdaExpr(LambdaExpr *E) {
+      // Lambdas never need to be transformed.
+      return E;
+    }
+  };
 } // end anonymous namespace
 
 TypeSourceInfo *Sema::RebuildTypeInCurrentInstantiation(TypeSourceInfo *T,
@@ -11464,8 +11523,8 @@ bool Sema::RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS) {
   NestedNameSpecifierLoc QualifierLoc = SS.getWithLocInContext(Context);
   CurrentInstantiationRebuilder Rebuilder(*this, SS.getRange().getBegin(),
                                           DeclarationName());
-  NestedNameSpecifierLoc Rebuilt =
-      Rebuilder.TransformNestedNameSpecifierLoc(QualifierLoc);
+  NestedNameSpecifierLoc Rebuilt
+    = Rebuilder.TransformNestedNameSpecifierLoc(QualifierLoc);
   if (!Rebuilt)
     return true;
 
@@ -11474,7 +11533,7 @@ bool Sema::RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS) {
 }
 
 bool Sema::RebuildTemplateParamsInCurrentInstantiation(
-    TemplateParameterList *Params) {
+                                               TemplateParameterList *Params) {
   for (unsigned I = 0, N = Params->size(); I != N; ++I) {
     Decl *Param = Params->getParam(I);
 
@@ -11483,10 +11542,10 @@ bool Sema::RebuildTemplateParamsInCurrentInstantiation(
       continue;
 
     // Rebuild the template parameter list of a template template parameter.
-    if (TemplateTemplateParmDecl *TTP =
-            dyn_cast<TemplateTemplateParmDecl>(Param)) {
+    if (TemplateTemplateParmDecl *TTP
+        = dyn_cast<TemplateTemplateParmDecl>(Param)) {
       if (RebuildTemplateParamsInCurrentInstantiation(
-              TTP->getTemplateParameters()))
+            TTP->getTemplateParameters()))
         return true;
 
       continue;
@@ -11494,8 +11553,10 @@ bool Sema::RebuildTemplateParamsInCurrentInstantiation(
 
     // Rebuild the type of a non-type template parameter.
     NonTypeTemplateParmDecl *NTTP = cast<NonTypeTemplateParmDecl>(Param);
-    TypeSourceInfo *NewTSI = RebuildTypeInCurrentInstantiation(
-        NTTP->getTypeSourceInfo(), NTTP->getLocation(), NTTP->getDeclName());
+    TypeSourceInfo *NewTSI
+      = RebuildTypeInCurrentInstantiation(NTTP->getTypeSourceInfo(),
+                                          NTTP->getLocation(),
+                                          NTTP->getDeclName());
     if (!NewTSI)
       return true;
 
@@ -11679,7 +11740,8 @@ class ExplicitSpecializationVisibilityChecker {
   // We don't need to go any deeper than that, as the instantiation of the
   // surrounding class / etc is not triggered by whatever triggered this
   // instantiation, and thus should be checked elsewhere.
-  template <typename SpecDecl> void checkImpl(SpecDecl *Spec) {
+  template<typename SpecDecl>
+  void checkImpl(SpecDecl *Spec) {
     bool IsHiddenExplicitSpecialization = false;
     TemplateSpecializationKind SpecKind = Spec->getTemplateSpecializationKind();
     // Some invalid friend declarations are written as specializations but are
@@ -11737,7 +11799,8 @@ class ExplicitSpecializationVisibilityChecker {
 
   void checkInstantiated(EnumDecl *FD) {}
 
-  template <typename TemplDecl> void checkTemplate(TemplDecl *TD) {
+  template<typename TemplDecl>
+  void checkTemplate(TemplDecl *TD) {
     if (TD->isMemberSpecialization()) {
       if (!CheckMemberSpecialization(TD))
         diagnose(TD->getMostRecentDecl(), false);
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 036b1578d6a3e..34ed5dffa11b4 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -652,16 +652,17 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
 Sema::InstantiatingTemplate::InstantiatingTemplate(
     Sema &SemaRef, SourceLocation PointOfInstantiation, FunctionDecl *Entity,
     ExceptionSpecification, SourceRange InstantiationRange)
-    : InstantiatingTemplate(SemaRef,
-                            CodeSynthesisContext::ExceptionSpecInstantiation,
-                            PointOfInstantiation, InstantiationRange, Entity) {}
+    : InstantiatingTemplate(
+          SemaRef, CodeSynthesisContext::ExceptionSpecInstantiation,
+          PointOfInstantiation, InstantiationRange, Entity) {}
 
 Sema::InstantiatingTemplate::InstantiatingTemplate(
     Sema &SemaRef, SourceLocation PointOfInstantiation, TemplateParameter Param,
     TemplateDecl *Template, ArrayRef<TemplateArgument> TemplateArgs,
     SourceRange InstantiationRange)
     : InstantiatingTemplate(
-          SemaRef, CodeSynthesisContext::DefaultTemplateArgumentInstantiation,
+          SemaRef,
+          CodeSynthesisContext::DefaultTemplateArgumentInstantiation,
           PointOfInstantiation, InstantiationRange, getAsNamedDecl(Param),
           Template, TemplateArgs) {}
 
@@ -708,7 +709,8 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
     Sema &SemaRef, SourceLocation PointOfInstantiation, ParmVarDecl *Param,
     ArrayRef<TemplateArgument> TemplateArgs, SourceRange InstantiationRange)
     : InstantiatingTemplate(
-          SemaRef, CodeSynthesisContext::DefaultFunctionArgumentInstantiation,
+          SemaRef,
+          CodeSynthesisContext::DefaultFunctionArgumentInstantiation,
           PointOfInstantiation, InstantiationRange, Param, nullptr,
           TemplateArgs) {}
 
@@ -717,7 +719,8 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
     NonTypeTemplateParmDecl *Param, ArrayRef<TemplateArgument> TemplateArgs,
     SourceRange InstantiationRange)
     : InstantiatingTemplate(
-          SemaRef, CodeSynthesisContext::PriorTemplateArgumentSubstitution,
+          SemaRef,
+          CodeSynthesisContext::PriorTemplateArgumentSubstitution,
           PointOfInstantiation, InstantiationRange, Param, Template,
           TemplateArgs) {}
 
@@ -726,7 +729,8 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
     TemplateTemplateParmDecl *Param, ArrayRef<TemplateArgument> TemplateArgs,
     SourceRange InstantiationRange)
     : InstantiatingTemplate(
-          SemaRef, CodeSynthesisContext::PriorTemplateArgumentSubstitution,
+          SemaRef,
+          CodeSynthesisContext::PriorTemplateArgumentSubstitution,
           PointOfInstantiation, InstantiationRange, Param, Template,
           TemplateArgs) {}
 
@@ -774,12 +778,13 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
           /*Template=*/nullptr, /*TemplateArgs=*/{}) {}
 
 Sema::InstantiatingTemplate::InstantiatingTemplate(
-    Sema &SemaRef, SourceLocation PointOfInstantiation, ConstraintsCheck,
-    NamedDecl *Template, ArrayRef<TemplateArgument> TemplateArgs,
-    SourceRange InstantiationRange)
-    : InstantiatingTemplate(SemaRef, CodeSynthesisContext::ConstraintsCheck,
-                            PointOfInstantiation, InstantiationRange, Template,
-                            nullptr, TemplateArgs) {}
+    Sema &SemaRef, SourceLocation PointOfInstantiation,
+    ConstraintsCheck, NamedDecl *Template,
+    ArrayRef<TemplateArgument> TemplateArgs, SourceRange InstantiationRange)
+    : InstantiatingTemplate(
+          SemaRef, CodeSynthesisContext::ConstraintsCheck,
+          PointOfInstantiation, InstantiationRange, Template, nullptr,
+          TemplateArgs) {}
 
 Sema::InstantiatingTemplate::InstantiatingTemplate(
     Sema &SemaRef, SourceLocation PointOfInstantiation, ConstraintSubstitution,
@@ -789,8 +794,9 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
           PointOfInstantiation, InstantiationRange, Template, nullptr, {}) {}
 
 Sema::InstantiatingTemplate::InstantiatingTemplate(
-    Sema &SemaRef, SourceLocation PointOfInstantiation, ConstraintNormalization,
-    NamedDecl *Template, SourceRange InstantiationRange)
+    Sema &SemaRef, SourceLocation PointOfInstantiation,
+    ConstraintNormalization, NamedDecl *Template,
+    SourceRange InstantiationRange)
     : InstantiatingTemplate(
           SemaRef, CodeSynthesisContext::ConstraintNormalization,
           PointOfInstantiation, InstantiationRange, Template) {}
@@ -806,9 +812,9 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
 Sema::InstantiatingTemplate::InstantiatingTemplate(
     Sema &SemaRef, SourceLocation PointOfInstantiation, TemplateDecl *Entity,
     BuildingDeductionGuidesTag, SourceRange InstantiationRange)
-    : InstantiatingTemplate(SemaRef,
-                            CodeSynthesisContext::BuildingDeductionGuides,
-                            PointOfInstantiation, InstantiationRange, Entity) {}
+    : InstantiatingTemplate(
+          SemaRef, CodeSynthesisContext::BuildingDeductionGuides,
+          PointOfInstantiation, InstantiationRange, Entity) {}
 
 Sema::InstantiatingTemplate::InstantiatingTemplate(
     Sema &SemaRef, SourceLocation ArgLoc, PartialOrderingTTP,
@@ -863,7 +869,8 @@ void Sema::popCodeSynthesisContext() {
 
   // If we've left the code synthesis context for the current context stack,
   // stop remembering that we've emitted that stack.
-  if (CodeSynthesisContexts.size() == LastEmittedCodeSynthesisContextDepth)
+  if (CodeSynthesisContexts.size() ==
+      LastEmittedCodeSynthesisContextDepth)
     LastEmittedCodeSynthesisContextDepth = 0;
 
   CodeSynthesisContexts.pop_back();
@@ -924,9 +931,10 @@ void Sema::PrintInstantiationStack(InstantiationContextDiagFuncRef DiagFunc) {
   // FIXME: In all of these cases, we need to show the template arguments
   unsigned InstantiationIdx = 0;
   for (SmallVectorImpl<CodeSynthesisContext>::reverse_iterator
-           Active = CodeSynthesisContexts.rbegin(),
-           ActiveEnd = CodeSynthesisContexts.rend();
-       Active != ActiveEnd; ++Active, ++InstantiationIdx) {
+         Active = CodeSynthesisContexts.rbegin(),
+         ActiveEnd = CodeSynthesisContexts.rend();
+       Active != ActiveEnd;
+       ++Active, ++InstantiationIdx) {
     // Skip this instantiation?
     if (InstantiationIdx >= SkipStart && InstantiationIdx < SkipEnd) {
       if (InstantiationIdx == SkipStart) {
@@ -1068,8 +1076,8 @@ void Sema::PrintInstantiationStack(InstantiationContextDiagFuncRef DiagFunc) {
         TemplateParams = Template->getTemplateParameters();
       else
         TemplateParams =
-            cast<ClassTemplatePartialSpecializationDecl>(Active->Template)
-                ->getTemplateParameters();
+          cast<ClassTemplatePartialSpecializationDecl>(Active->Template)
+                                                      ->getTemplateParameters();
       DiagFunc(Active->PointOfInstantiation,
                PDiag(diag::note_prior_template_arg_substitution)
                    << isa<TemplateTemplateParmDecl>(Parm) << Name
@@ -1086,8 +1094,8 @@ void Sema::PrintInstantiationStack(InstantiationContextDiagFuncRef DiagFunc) {
         TemplateParams = Template->getTemplateParameters();
       else
         TemplateParams =
-            cast<ClassTemplatePartialSpecializationDecl>(Active->Template)
-                ->getTemplateParameters();
+          cast<ClassTemplatePartialSpecializationDecl>(Active->Template)
+                                                      ->getTemplateParameters();
 
       DiagFunc(Active->PointOfInstantiation,
                PDiag(diag::note_template_default_arg_checking)
@@ -1309,552 +1317,553 @@ void Sema::PrintInstantiationStack(InstantiationContextDiagFuncRef DiagFunc) {
 //===----------------------------------------------------------------------===/
 namespace {
 
-class TemplateInstantiator : public TreeTransform<TemplateInstantiator> {
-  const MultiLevelTemplateArgumentList &TemplateArgs;
-  SourceLocation Loc;
-  DeclarationName Entity;
-  // Whether to evaluate the C++20 constraints or simply substitute into them.
-  bool EvaluateConstraints = true;
-  // Whether Substitution was Incomplete, that is, we tried to substitute in
-  // any user provided template arguments which were null.
-  bool IsIncomplete = false;
-  // Whether an incomplete substituion should be treated as an error.
-  bool BailOutOnIncomplete;
-
-  // CWG2770: Function parameters should be instantiated when they are
-  // needed by a satisfaction check of an atomic constraint or
-  // (recursively) by another function parameter.
-  bool maybeInstantiateFunctionParameterToScope(ParmVarDecl *OldParm);
-
-public:
-  typedef TreeTransform<TemplateInstantiator> inherited;
-
-  TemplateInstantiator(Sema &SemaRef,
-                       const MultiLevelTemplateArgumentList &TemplateArgs,
-                       SourceLocation Loc, DeclarationName Entity,
-                       bool BailOutOnIncomplete = false)
-      : inherited(SemaRef), TemplateArgs(TemplateArgs), Loc(Loc),
-        Entity(Entity), BailOutOnIncomplete(BailOutOnIncomplete) {}
-
-  void setEvaluateConstraints(bool B) { EvaluateConstraints = B; }
-  bool getEvaluateConstraints() { return EvaluateConstraints; }
-
-  inline static struct ForParameterMappingSubstitution_t {
-  } ForParameterMappingSubstitution;
-
-  TemplateInstantiator(ForParameterMappingSubstitution_t, Sema &SemaRef,
-                       SourceLocation Loc,
-                       const MultiLevelTemplateArgumentList &TemplateArgs)
-      : inherited(SemaRef), TemplateArgs(TemplateArgs), Loc(Loc),
-        BailOutOnIncomplete(false) {}
-
-  /// Determine whether the given type \p T has already been
-  /// transformed.
-  ///
-  /// For the purposes of template instantiation, a type has already been
-  /// transformed if it is NULL or if it is not dependent.
-  bool AlreadyTransformed(QualType T);
-
-  /// Returns the location of the entity being instantiated, if known.
-  SourceLocation getBaseLocation() { return Loc; }
-
-  /// Returns the name of the entity being instantiated, if any.
-  DeclarationName getBaseEntity() { return Entity; }
-
-  /// Returns whether any substitution so far was incomplete.
-  bool getIsIncomplete() const { return IsIncomplete; }
-
-  /// Sets the "base" location and entity when that
-  /// information is known based on another transformation.
-  void setBase(SourceLocation Loc, DeclarationName Entity) {
-    this->Loc = Loc;
-    this->Entity = Entity;
-  }
-
-  unsigned TransformTemplateDepth(unsigned Depth) {
-    return TemplateArgs.getNewDepth(Depth);
-  }
+  class TemplateInstantiator : public TreeTransform<TemplateInstantiator> {
+    const MultiLevelTemplateArgumentList &TemplateArgs;
+    SourceLocation Loc;
+    DeclarationName Entity;
+    // Whether to evaluate the C++20 constraints or simply substitute into them.
+    bool EvaluateConstraints = true;
+    // Whether Substitution was Incomplete, that is, we tried to substitute in
+    // any user provided template arguments which were null.
+    bool IsIncomplete = false;
+    // Whether an incomplete substituion should be treated as an error.
+    bool BailOutOnIncomplete;
+
+    // CWG2770: Function parameters should be instantiated when they are
+    // needed by a satisfaction check of an atomic constraint or
+    // (recursively) by another function parameter.
+    bool maybeInstantiateFunctionParameterToScope(ParmVarDecl *OldParm);
+
+  public:
+    typedef TreeTransform<TemplateInstantiator> inherited;
+
+    TemplateInstantiator(Sema &SemaRef,
+                         const MultiLevelTemplateArgumentList &TemplateArgs,
+                         SourceLocation Loc, DeclarationName Entity,
+                         bool BailOutOnIncomplete = false)
+        : inherited(SemaRef), TemplateArgs(TemplateArgs), Loc(Loc),
+          Entity(Entity), BailOutOnIncomplete(BailOutOnIncomplete) {}
 
-  bool TryExpandParameterPacks(SourceLocation EllipsisLoc,
-                               SourceRange PatternRange,
-                               ArrayRef<UnexpandedParameterPack> Unexpanded,
-                               bool FailOnPackProducingTemplates,
-                               bool &ShouldExpand, bool &RetainExpansion,
-                               UnsignedOrNone &NumExpansions) {
-    if (SemaRef.CurrentInstantiationScope &&
-        (SemaRef.inConstraintSubstitution() ||
-         SemaRef.inParameterMappingSubstitution())) {
-      for (UnexpandedParameterPack ParmPack : Unexpanded) {
-        NamedDecl *VD = ParmPack.first.dyn_cast<NamedDecl *>();
-        if (auto *PVD = dyn_cast_if_present<ParmVarDecl>(VD);
-            PVD && maybeInstantiateFunctionParameterToScope(PVD))
-          return true;
-      }
+    void setEvaluateConstraints(bool B) {
+      EvaluateConstraints = B;
+    }
+    bool getEvaluateConstraints() {
+      return EvaluateConstraints;
     }
 
-    return getSema().CheckParameterPacksForExpansion(
-        EllipsisLoc, PatternRange, Unexpanded, TemplateArgs,
-        FailOnPackProducingTemplates, ShouldExpand, RetainExpansion,
-        NumExpansions);
-  }
+    inline static struct ForParameterMappingSubstitution_t {
+    } ForParameterMappingSubstitution;
 
-  void ExpandingFunctionParameterPack(ParmVarDecl *Pack) {
-    SemaRef.CurrentInstantiationScope->MakeInstantiatedLocalArgPack(Pack);
-  }
+    TemplateInstantiator(ForParameterMappingSubstitution_t, Sema &SemaRef,
+                         SourceLocation Loc,
+                         const MultiLevelTemplateArgumentList &TemplateArgs)
+        : inherited(SemaRef), TemplateArgs(TemplateArgs), Loc(Loc),
+          BailOutOnIncomplete(false) {}
 
-  TemplateArgument ForgetPartiallySubstitutedPack() {
-    TemplateArgument Result;
-    if (NamedDecl *PartialPack =
-            SemaRef.CurrentInstantiationScope->getPartiallySubstitutedPack()) {
-      MultiLevelTemplateArgumentList &TemplateArgs =
-          const_cast<MultiLevelTemplateArgumentList &>(this->TemplateArgs);
-      unsigned Depth, Index;
-      std::tie(Depth, Index) = getDepthAndIndex(PartialPack);
-      if (TemplateArgs.hasTemplateArgument(Depth, Index)) {
-        Result = TemplateArgs(Depth, Index);
-        TemplateArgs.setArgument(Depth, Index, TemplateArgument());
-      } else {
-        IsIncomplete = true;
-        if (BailOutOnIncomplete)
-          return TemplateArgument();
-      }
+    /// Determine whether the given type \p T has already been
+    /// transformed.
+    ///
+    /// For the purposes of template instantiation, a type has already been
+    /// transformed if it is NULL or if it is not dependent.
+    bool AlreadyTransformed(QualType T);
+
+    /// Returns the location of the entity being instantiated, if known.
+    SourceLocation getBaseLocation() { return Loc; }
+
+    /// Returns the name of the entity being instantiated, if any.
+    DeclarationName getBaseEntity() { return Entity; }
+
+    /// Returns whether any substitution so far was incomplete.
+    bool getIsIncomplete() const { return IsIncomplete; }
+
+    /// Sets the "base" location and entity when that
+    /// information is known based on another transformation.
+    void setBase(SourceLocation Loc, DeclarationName Entity) {
+      this->Loc = Loc;
+      this->Entity = Entity;
     }
 
-    return Result;
-  }
+    unsigned TransformTemplateDepth(unsigned Depth) {
+      return TemplateArgs.getNewDepth(Depth);
+    }
 
-  void RememberPartiallySubstitutedPack(TemplateArgument Arg) {
-    if (Arg.isNull())
-      return;
+    bool TryExpandParameterPacks(SourceLocation EllipsisLoc,
+                                 SourceRange PatternRange,
+                                 ArrayRef<UnexpandedParameterPack> Unexpanded,
+                                 bool FailOnPackProducingTemplates,
+                                 bool &ShouldExpand, bool &RetainExpansion,
+                                 UnsignedOrNone &NumExpansions) {
+      if (SemaRef.CurrentInstantiationScope &&
+          (SemaRef.inConstraintSubstitution() ||
+           SemaRef.inParameterMappingSubstitution())) {
+        for (UnexpandedParameterPack ParmPack : Unexpanded) {
+          NamedDecl *VD = ParmPack.first.dyn_cast<NamedDecl *>();
+          if (auto *PVD = dyn_cast_if_present<ParmVarDecl>(VD);
+              PVD && maybeInstantiateFunctionParameterToScope(PVD))
+            return true;
+        }
+      }
 
-    if (NamedDecl *PartialPack =
-            SemaRef.CurrentInstantiationScope->getPartiallySubstitutedPack()) {
-      MultiLevelTemplateArgumentList &TemplateArgs =
-          const_cast<MultiLevelTemplateArgumentList &>(this->TemplateArgs);
-      unsigned Depth, Index;
-      std::tie(Depth, Index) = getDepthAndIndex(PartialPack);
-      TemplateArgs.setArgument(Depth, Index, Arg);
+      return getSema().CheckParameterPacksForExpansion(
+          EllipsisLoc, PatternRange, Unexpanded, TemplateArgs,
+          FailOnPackProducingTemplates, ShouldExpand, RetainExpansion,
+          NumExpansions);
     }
-  }
 
-  MultiLevelTemplateArgumentList ForgetSubstitution() {
-    MultiLevelTemplateArgumentList New;
-    New.addOuterRetainedLevels(this->TemplateArgs.getNumLevels());
+    void ExpandingFunctionParameterPack(ParmVarDecl *Pack) {
+      SemaRef.CurrentInstantiationScope->MakeInstantiatedLocalArgPack(Pack);
+    }
 
-    MultiLevelTemplateArgumentList Old =
-        const_cast<MultiLevelTemplateArgumentList &>(this->TemplateArgs);
-    const_cast<MultiLevelTemplateArgumentList &>(this->TemplateArgs) =
-        std::move(New);
-    return Old;
-  }
+    TemplateArgument ForgetPartiallySubstitutedPack() {
+      TemplateArgument Result;
+      if (NamedDecl *PartialPack = SemaRef.CurrentInstantiationScope
+                                       ->getPartiallySubstitutedPack()) {
+        MultiLevelTemplateArgumentList &TemplateArgs =
+            const_cast<MultiLevelTemplateArgumentList &>(this->TemplateArgs);
+        unsigned Depth, Index;
+        std::tie(Depth, Index) = getDepthAndIndex(PartialPack);
+        if (TemplateArgs.hasTemplateArgument(Depth, Index)) {
+          Result = TemplateArgs(Depth, Index);
+          TemplateArgs.setArgument(Depth, Index, TemplateArgument());
+        } else {
+          IsIncomplete = true;
+          if (BailOutOnIncomplete)
+            return TemplateArgument();
+        }
+      }
 
-  void RememberSubstitution(MultiLevelTemplateArgumentList Old) {
-    const_cast<MultiLevelTemplateArgumentList &>(this->TemplateArgs) =
-        std::move(Old);
-  }
+      return Result;
+    }
 
-  TemplateArgument
-  getTemplateArgumentPackPatternForRewrite(const TemplateArgument &TA) {
-    if (TA.getKind() != TemplateArgument::Pack)
-      return TA;
-    if (SemaRef.ArgPackSubstIndex)
-      return SemaRef.getPackSubstitutedTemplateArgument(TA);
-    assert(TA.pack_size() == 1 && TA.pack_begin()->isPackExpansion() &&
-           "unexpected pack arguments in template rewrite");
-    TemplateArgument Arg = *TA.pack_begin();
-    if (Arg.isPackExpansion())
-      Arg = Arg.getPackExpansionPattern();
-    return Arg;
-  }
+    void RememberPartiallySubstitutedPack(TemplateArgument Arg) {
+      if (Arg.isNull())
+        return;
+
+      if (NamedDecl *PartialPack = SemaRef.CurrentInstantiationScope
+                                       ->getPartiallySubstitutedPack()) {
+        MultiLevelTemplateArgumentList &TemplateArgs =
+            const_cast<MultiLevelTemplateArgumentList &>(this->TemplateArgs);
+        unsigned Depth, Index;
+        std::tie(Depth, Index) = getDepthAndIndex(PartialPack);
+        TemplateArgs.setArgument(Depth, Index, Arg);
+      }
+    }
 
-  /// Transform the given declaration by instantiating a reference to
-  /// this declaration.
-  Decl *TransformDecl(SourceLocation Loc, Decl *D);
+    MultiLevelTemplateArgumentList ForgetSubstitution() {
+      MultiLevelTemplateArgumentList New;
+      New.addOuterRetainedLevels(this->TemplateArgs.getNumLevels());
 
-  void transformAttrs(Decl *Old, Decl *New) {
-    SemaRef.InstantiateAttrs(TemplateArgs, Old, New);
-  }
+      MultiLevelTemplateArgumentList Old =
+          const_cast<MultiLevelTemplateArgumentList &>(this->TemplateArgs);
+      const_cast<MultiLevelTemplateArgumentList &>(this->TemplateArgs) =
+          std::move(New);
+      return Old;
+    }
 
-  void transformedLocalDecl(Decl *Old, ArrayRef<Decl *> NewDecls) {
-    if (Old->isParameterPack() &&
-        (NewDecls.size() != 1 || !NewDecls.front()->isParameterPack())) {
-      SemaRef.CurrentInstantiationScope->MakeInstantiatedLocalArgPack(Old);
-      for (auto *New : NewDecls)
-        SemaRef.CurrentInstantiationScope->InstantiatedLocalPackArg(
-            Old, cast<VarDecl>(New));
-      return;
+    void RememberSubstitution(MultiLevelTemplateArgumentList Old) {
+      const_cast<MultiLevelTemplateArgumentList &>(this->TemplateArgs) =
+          std::move(Old);
     }
 
-    assert(NewDecls.size() == 1 &&
-           "should only have multiple expansions for a pack");
-    Decl *New = NewDecls.front();
-
-    // If we've instantiated the call operator of a lambda or the call
-    // operator template of a generic lambda, update the "instantiation of"
-    // information.
-    auto *NewMD = dyn_cast<CXXMethodDecl>(New);
-    if (NewMD && isLambdaCallOperator(NewMD)) {
-      auto *OldMD = dyn_cast<CXXMethodDecl>(Old);
-      if (auto *NewTD = NewMD->getDescribedFunctionTemplate())
-        NewTD->setInstantiatedFromMemberTemplate(
-            OldMD->getDescribedFunctionTemplate());
-      else
-        NewMD->setInstantiationOfMemberFunction(OldMD,
-                                                TSK_ImplicitInstantiation);
+    TemplateArgument
+    getTemplateArgumentPackPatternForRewrite(const TemplateArgument &TA) {
+      if (TA.getKind() != TemplateArgument::Pack)
+        return TA;
+      if (SemaRef.ArgPackSubstIndex)
+        return SemaRef.getPackSubstitutedTemplateArgument(TA);
+      assert(TA.pack_size() == 1 && TA.pack_begin()->isPackExpansion() &&
+             "unexpected pack arguments in template rewrite");
+      TemplateArgument Arg = *TA.pack_begin();
+      if (Arg.isPackExpansion())
+        Arg = Arg.getPackExpansionPattern();
+      return Arg;
     }
 
-    SemaRef.CurrentInstantiationScope->InstantiatedLocal(Old, New);
+    /// Transform the given declaration by instantiating a reference to
+    /// this declaration.
+    Decl *TransformDecl(SourceLocation Loc, Decl *D);
 
-    // We recreated a local declaration, but not by instantiating it. There
-    // may be pending dependent diagnostics to produce.
-    if (auto *DC = dyn_cast<DeclContext>(Old);
-        DC && DC->isDependentContext() && DC->isFunctionOrMethod())
-      SemaRef.PerformDependentDiagnostics(DC, TemplateArgs);
-  }
+    void transformAttrs(Decl *Old, Decl *New) {
+      SemaRef.InstantiateAttrs(TemplateArgs, Old, New);
+    }
+
+    void transformedLocalDecl(Decl *Old, ArrayRef<Decl *> NewDecls) {
+      if (Old->isParameterPack() &&
+          (NewDecls.size() != 1 || !NewDecls.front()->isParameterPack())) {
+        SemaRef.CurrentInstantiationScope->MakeInstantiatedLocalArgPack(Old);
+        for (auto *New : NewDecls)
+          SemaRef.CurrentInstantiationScope->InstantiatedLocalPackArg(
+              Old, cast<VarDecl>(New));
+        return;
+      }
 
-  /// Transform the definition of the given declaration by
-  /// instantiating it.
-  Decl *TransformDefinition(SourceLocation Loc, Decl *D);
+      assert(NewDecls.size() == 1 &&
+             "should only have multiple expansions for a pack");
+      Decl *New = NewDecls.front();
+
+      // If we've instantiated the call operator of a lambda or the call
+      // operator template of a generic lambda, update the "instantiation of"
+      // information.
+      auto *NewMD = dyn_cast<CXXMethodDecl>(New);
+      if (NewMD && isLambdaCallOperator(NewMD)) {
+        auto *OldMD = dyn_cast<CXXMethodDecl>(Old);
+        if (auto *NewTD = NewMD->getDescribedFunctionTemplate())
+          NewTD->setInstantiatedFromMemberTemplate(
+              OldMD->getDescribedFunctionTemplate());
+        else
+          NewMD->setInstantiationOfMemberFunction(OldMD,
+                                                  TSK_ImplicitInstantiation);
+      }
 
-  /// Transform the first qualifier within a scope by instantiating the
-  /// declaration.
-  NamedDecl *TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc);
+      SemaRef.CurrentInstantiationScope->InstantiatedLocal(Old, New);
 
-  bool TransformExceptionSpec(SourceLocation Loc,
-                              FunctionProtoType::ExceptionSpecInfo &ESI,
-                              SmallVectorImpl<QualType> &Exceptions,
-                              bool &Changed);
-
-  /// Rebuild the exception declaration and register the declaration
-  /// as an instantiated local.
-  VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl,
-                                TypeSourceInfo *Declarator,
-                                SourceLocation StartLoc, SourceLocation NameLoc,
-                                IdentifierInfo *Name);
-
-  /// Rebuild the Objective-C exception declaration and register the
-  /// declaration as an instantiated local.
-  VarDecl *RebuildObjCExceptionDecl(VarDecl *ExceptionDecl,
-                                    TypeSourceInfo *TSInfo, QualType T);
-
-  TemplateName TransformTemplateName(NestedNameSpecifierLoc &QualifierLoc,
-                                     SourceLocation TemplateKWLoc,
-                                     TemplateName Name, SourceLocation NameLoc,
-                                     QualType ObjectType = QualType(),
-                                     NamedDecl *FirstQualifierInScope = nullptr,
-                                     bool AllowInjectedClassName = false);
-
-  const AnnotateAttr *TransformAnnotateAttr(const AnnotateAttr *AA);
-  const CXXAssumeAttr *TransformCXXAssumeAttr(const CXXAssumeAttr *AA);
-  const LoopHintAttr *TransformLoopHintAttr(const LoopHintAttr *LH);
-  const NoInlineAttr *TransformStmtNoInlineAttr(const Stmt *OrigS,
-                                                const Stmt *InstS,
-                                                const NoInlineAttr *A);
-  const AlwaysInlineAttr *
-  TransformStmtAlwaysInlineAttr(const Stmt *OrigS, const Stmt *InstS,
-                                const AlwaysInlineAttr *A);
-  const CodeAlignAttr *TransformCodeAlignAttr(const CodeAlignAttr *CA);
-  const OpenACCRoutineDeclAttr *
-  TransformOpenACCRoutineDeclAttr(const OpenACCRoutineDeclAttr *A);
-  ExprResult TransformPredefinedExpr(PredefinedExpr *E);
-  ExprResult TransformDeclRefExpr(DeclRefExpr *E);
-  ExprResult TransformCXXReflectExpr(CXXReflectExpr *E);
-  ExprResult TransformCXXDefaultArgExpr(CXXDefaultArgExpr *E);
-
-  ExprResult TransformTemplateParmRefExpr(DeclRefExpr *E,
-                                          NonTypeTemplateParmDecl *D);
-
-  /// Rebuild a DeclRefExpr for a VarDecl reference.
-  ExprResult RebuildVarDeclRefExpr(ValueDecl *PD, SourceLocation Loc);
-
-  /// Transform a reference to a function or init-capture parameter pack.
-  ExprResult TransformFunctionParmPackRefExpr(DeclRefExpr *E, ValueDecl *PD);
-
-  /// Transform a FunctionParmPackExpr which was built when we couldn't
-  /// expand a function parameter pack reference which refers to an expanded
-  /// pack.
-  ExprResult TransformFunctionParmPackExpr(FunctionParmPackExpr *E);
-
-  QualType TransformFunctionProtoType(TypeLocBuilder &TLB,
-                                      FunctionProtoTypeLoc TL) {
-    // Call the base version; it will forward to our overridden version below.
-    return inherited::TransformFunctionProtoType(TLB, TL);
-  }
+      // We recreated a local declaration, but not by instantiating it. There
+      // may be pending dependent diagnostics to produce.
+      if (auto *DC = dyn_cast<DeclContext>(Old);
+          DC && DC->isDependentContext() && DC->isFunctionOrMethod())
+        SemaRef.PerformDependentDiagnostics(DC, TemplateArgs);
+    }
+
+    /// Transform the definition of the given declaration by
+    /// instantiating it.
+    Decl *TransformDefinition(SourceLocation Loc, Decl *D);
+
+    /// Transform the first qualifier within a scope by instantiating the
+    /// declaration.
+    NamedDecl *TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc);
+
+    bool TransformExceptionSpec(SourceLocation Loc,
+                                FunctionProtoType::ExceptionSpecInfo &ESI,
+                                SmallVectorImpl<QualType> &Exceptions,
+                                bool &Changed);
+
+    /// Rebuild the exception declaration and register the declaration
+    /// as an instantiated local.
+    VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl,
+                                  TypeSourceInfo *Declarator,
+                                  SourceLocation StartLoc,
+                                  SourceLocation NameLoc,
+                                  IdentifierInfo *Name);
+
+    /// Rebuild the Objective-C exception declaration and register the
+    /// declaration as an instantiated local.
+    VarDecl *RebuildObjCExceptionDecl(VarDecl *ExceptionDecl,
+                                      TypeSourceInfo *TSInfo, QualType T);
+
+    TemplateName
+    TransformTemplateName(NestedNameSpecifierLoc &QualifierLoc,
+                          SourceLocation TemplateKWLoc, TemplateName Name,
+                          SourceLocation NameLoc,
+                          QualType ObjectType = QualType(),
+                          NamedDecl *FirstQualifierInScope = nullptr,
+                          bool AllowInjectedClassName = false);
+
+    const AnnotateAttr *TransformAnnotateAttr(const AnnotateAttr *AA);
+    const CXXAssumeAttr *TransformCXXAssumeAttr(const CXXAssumeAttr *AA);
+    const LoopHintAttr *TransformLoopHintAttr(const LoopHintAttr *LH);
+    const NoInlineAttr *TransformStmtNoInlineAttr(const Stmt *OrigS,
+                                                  const Stmt *InstS,
+                                                  const NoInlineAttr *A);
+    const AlwaysInlineAttr *
+    TransformStmtAlwaysInlineAttr(const Stmt *OrigS, const Stmt *InstS,
+                                  const AlwaysInlineAttr *A);
+    const CodeAlignAttr *TransformCodeAlignAttr(const CodeAlignAttr *CA);
+    const OpenACCRoutineDeclAttr *
+    TransformOpenACCRoutineDeclAttr(const OpenACCRoutineDeclAttr *A);
+    ExprResult TransformPredefinedExpr(PredefinedExpr *E);
+    ExprResult TransformDeclRefExpr(DeclRefExpr *E);
+    ExprResult TransformCXXDefaultArgExpr(CXXDefaultArgExpr *E);
+
+    ExprResult TransformTemplateParmRefExpr(DeclRefExpr *E,
+                                            NonTypeTemplateParmDecl *D);
+
+    /// Rebuild a DeclRefExpr for a VarDecl reference.
+    ExprResult RebuildVarDeclRefExpr(ValueDecl *PD, SourceLocation Loc);
+
+    /// Transform a reference to a function or init-capture parameter pack.
+    ExprResult TransformFunctionParmPackRefExpr(DeclRefExpr *E, ValueDecl *PD);
+
+    /// Transform a FunctionParmPackExpr which was built when we couldn't
+    /// expand a function parameter pack reference which refers to an expanded
+    /// pack.
+    ExprResult TransformFunctionParmPackExpr(FunctionParmPackExpr *E);
+
+    QualType TransformFunctionProtoType(TypeLocBuilder &TLB,
+                                        FunctionProtoTypeLoc TL) {
+      // Call the base version; it will forward to our overridden version below.
+      return inherited::TransformFunctionProtoType(TLB, TL);
+    }
 
-  QualType TransformTagType(TypeLocBuilder &TLB, TagTypeLoc TL) {
-    auto Type = inherited::TransformTagType(TLB, TL);
-    if (!Type.isNull())
+    QualType TransformTagType(TypeLocBuilder &TLB, TagTypeLoc TL) {
+      auto Type = inherited::TransformTagType(TLB, TL);
+      if (!Type.isNull())
+        return Type;
+      // Special case for transforming a deduction guide, we return a
+      // transformed TemplateSpecializationType.
+      // FIXME: Why is this hack necessary?
+      if (const auto *ICNT = dyn_cast<InjectedClassNameType>(TL.getTypePtr());
+          ICNT && SemaRef.CodeSynthesisContexts.back().Kind ==
+                      Sema::CodeSynthesisContext::BuildingDeductionGuides) {
+        Type = inherited::TransformType(
+            ICNT->getDecl()->getCanonicalTemplateSpecializationType(
+                SemaRef.Context));
+        TLB.pushTrivial(SemaRef.Context, Type, TL.getNameLoc());
+      }
       return Type;
-    // Special case for transforming a deduction guide, we return a
-    // transformed TemplateSpecializationType.
-    // FIXME: Why is this hack necessary?
-    if (const auto *ICNT = dyn_cast<InjectedClassNameType>(TL.getTypePtr());
-        ICNT && SemaRef.CodeSynthesisContexts.back().Kind ==
-                    Sema::CodeSynthesisContext::BuildingDeductionGuides) {
-      Type = inherited::TransformType(
-          ICNT->getDecl()->getCanonicalTemplateSpecializationType(
-              SemaRef.Context));
-      TLB.pushTrivial(SemaRef.Context, Type, TL.getNameLoc());
     }
-    return Type;
-  }
-  // Override the default version to handle a rewrite-template-arg-pack case
-  // for building a deduction guide.
-  bool TransformTemplateArgument(const TemplateArgumentLoc &Input,
-                                 TemplateArgumentLoc &Output,
-                                 bool Uneval = false) {
-    const TemplateArgument &Arg = Input.getArgument();
-    std::vector<TemplateArgument> TArgs;
-    switch (Arg.getKind()) {
-    case TemplateArgument::Pack:
-      assert(SemaRef.CodeSynthesisContexts.empty() ||
-             SemaRef.CodeSynthesisContexts.back().Kind ==
-                 Sema::CodeSynthesisContext::BuildingDeductionGuides);
-      // Literally rewrite the template argument pack, instead of unpacking
-      // it.
-      for (auto &pack : Arg.getPackAsArray()) {
-        TemplateArgumentLoc Input = SemaRef.getTrivialTemplateArgumentLoc(
-            pack, QualType(), SourceLocation{});
-        TemplateArgumentLoc Output;
-        if (TransformTemplateArgument(Input, Output, Uneval))
-          return true; // fails
-        TArgs.push_back(Output.getArgument());
+    // Override the default version to handle a rewrite-template-arg-pack case
+    // for building a deduction guide.
+    bool TransformTemplateArgument(const TemplateArgumentLoc &Input,
+                                   TemplateArgumentLoc &Output,
+                                   bool Uneval = false) {
+      const TemplateArgument &Arg = Input.getArgument();
+      std::vector<TemplateArgument> TArgs;
+      switch (Arg.getKind()) {
+      case TemplateArgument::Pack:
+        assert(SemaRef.CodeSynthesisContexts.empty() ||
+               SemaRef.CodeSynthesisContexts.back().Kind ==
+                   Sema::CodeSynthesisContext::BuildingDeductionGuides);
+        // Literally rewrite the template argument pack, instead of unpacking
+        // it.
+        for (auto &pack : Arg.getPackAsArray()) {
+          TemplateArgumentLoc Input = SemaRef.getTrivialTemplateArgumentLoc(
+              pack, QualType(), SourceLocation{});
+          TemplateArgumentLoc Output;
+          if (TransformTemplateArgument(Input, Output, Uneval))
+            return true; // fails
+          TArgs.push_back(Output.getArgument());
+        }
+        Output = SemaRef.getTrivialTemplateArgumentLoc(
+            TemplateArgument(llvm::ArrayRef(TArgs).copy(SemaRef.Context)),
+            QualType(), SourceLocation{});
+        return false;
+      default:
+        break;
       }
-      Output = SemaRef.getTrivialTemplateArgumentLoc(
-          TemplateArgument(llvm::ArrayRef(TArgs).copy(SemaRef.Context)),
-          QualType(), SourceLocation{});
-      return false;
-    default:
-      break;
+      return inherited::TransformTemplateArgument(Input, Output, Uneval);
     }
-    return inherited::TransformTemplateArgument(Input, Output, Uneval);
-  }
 
-  using TreeTransform::TransformTemplateSpecializationType;
-  QualType
-  TransformTemplateSpecializationType(TypeLocBuilder &TLB,
-                                      TemplateSpecializationTypeLoc TL) {
-    auto *T = TL.getTypePtr();
-    if (!getSema().ArgPackSubstIndex || !T->isSugared() ||
-        !isPackProducingBuiltinTemplateName(T->getTemplateName()))
-      return TreeTransform::TransformTemplateSpecializationType(TLB, TL);
-    // Look through sugar to get to the SubstBuiltinTemplatePackType that we
-    // need to substitute into.
-
-    // `TransformType` code below will handle picking the element from a pack
-    // with the index `ArgPackSubstIndex`.
-    // FIXME: add ability to represent sugarred type for N-th element of a
-    // builtin pack and produce the sugar here.
-    QualType R = TransformType(T->desugar());
-    TLB.pushTrivial(getSema().getASTContext(), R, TL.getBeginLoc());
-    return R;
-  }
+    using TreeTransform::TransformTemplateSpecializationType;
+    QualType
+    TransformTemplateSpecializationType(TypeLocBuilder &TLB,
+                                        TemplateSpecializationTypeLoc TL) {
+      auto *T = TL.getTypePtr();
+      if (!getSema().ArgPackSubstIndex || !T->isSugared() ||
+          !isPackProducingBuiltinTemplateName(T->getTemplateName()))
+        return TreeTransform::TransformTemplateSpecializationType(TLB, TL);
+      // Look through sugar to get to the SubstBuiltinTemplatePackType that we
+      // need to substitute into.
+
+      // `TransformType` code below will handle picking the element from a pack
+      // with the index `ArgPackSubstIndex`.
+      // FIXME: add ability to represent sugarred type for N-th element of a
+      // builtin pack and produce the sugar here.
+      QualType R = TransformType(T->desugar());
+      TLB.pushTrivial(getSema().getASTContext(), R, TL.getBeginLoc());
+      return R;
+    }
 
-  UnsignedOrNone ComputeSizeOfPackExprWithoutSubstitution(
-      ArrayRef<TemplateArgument> PackArgs) {
-    // Don't do this when rewriting template parameters for CTAD:
-    //   1) The heuristic needs the unpacked Subst* nodes to figure out the
-    //   expanded size, but this never applies since Subst* nodes are not
-    //   created in rewrite scenarios.
-    //
-    //   2) The heuristic substitutes into the pattern with pack expansion
-    //   suppressed, which does not meet the requirements for argument
-    //   rewriting when template arguments include a non-pack matching against
-    //   a pack, particularly when rewriting an alias CTAD.
-    if (TemplateArgs.isRewrite())
-      return std::nullopt;
-
-    return inherited::ComputeSizeOfPackExprWithoutSubstitution(PackArgs);
-  }
+    UnsignedOrNone ComputeSizeOfPackExprWithoutSubstitution(
+        ArrayRef<TemplateArgument> PackArgs) {
+      // Don't do this when rewriting template parameters for CTAD:
+      //   1) The heuristic needs the unpacked Subst* nodes to figure out the
+      //   expanded size, but this never applies since Subst* nodes are not
+      //   created in rewrite scenarios.
+      //
+      //   2) The heuristic substitutes into the pattern with pack expansion
+      //   suppressed, which does not meet the requirements for argument
+      //   rewriting when template arguments include a non-pack matching against
+      //   a pack, particularly when rewriting an alias CTAD.
+      if (TemplateArgs.isRewrite())
+        return std::nullopt;
+
+      return inherited::ComputeSizeOfPackExprWithoutSubstitution(PackArgs);
+    }
 
-  template <typename Fn>
-  QualType TransformFunctionProtoType(TypeLocBuilder &TLB,
-                                      FunctionProtoTypeLoc TL,
-                                      CXXRecordDecl *ThisContext,
-                                      Qualifiers ThisTypeQuals,
-                                      Fn TransformExceptionSpec);
-
-  ParmVarDecl *TransformFunctionTypeParam(ParmVarDecl *OldParm,
-                                          int indexAdjustment,
-                                          UnsignedOrNone NumExpansions,
-                                          bool ExpectParameterPack);
-
-  using inherited::TransformTemplateTypeParmType;
-  /// Transforms a template type parameter type by performing
-  /// substitution of the corresponding template type argument.
-  QualType TransformTemplateTypeParmType(TypeLocBuilder &TLB,
-                                         TemplateTypeParmTypeLoc TL,
-                                         bool SuppressObjCLifetime);
-
-  QualType BuildSubstTemplateTypeParmType(TypeLocBuilder &TLB,
-                                          bool SuppressObjCLifetime, bool Final,
-                                          Decl *AssociatedDecl, unsigned Index,
-                                          UnsignedOrNone PackIndex,
-                                          TemplateArgument Arg,
-                                          SourceLocation NameLoc);
-
-  /// Transforms an already-substituted template type parameter pack
-  /// into either itself (if we aren't substituting into its pack expansion)
-  /// or the appropriate substituted argument.
-  using inherited::TransformSubstTemplateTypeParmPackType;
-  QualType
-  TransformSubstTemplateTypeParmPackType(TypeLocBuilder &TLB,
-                                         SubstTemplateTypeParmPackTypeLoc TL,
-                                         bool SuppressObjCLifetime);
-  QualType
-  TransformSubstBuiltinTemplatePackType(TypeLocBuilder &TLB,
-                                        SubstBuiltinTemplatePackTypeLoc TL);
-
-  CXXRecordDecl::LambdaDependencyKind
-  ComputeLambdaDependency(LambdaScopeInfo *LSI) {
-    if (auto TypeAlias =
-            TemplateInstArgsHelpers::getEnclosingTypeAliasTemplateDecl(
-                getSema());
-        TypeAlias && TemplateInstArgsHelpers::isLambdaEnclosedByTypeAliasDecl(
-                         LSI->CallOperator, TypeAlias.PrimaryTypeAliasDecl)) {
-      unsigned TypeAliasDeclDepth = TypeAlias.Template->getTemplateDepth();
-      if (TypeAliasDeclDepth >= TemplateArgs.getNumSubstitutedLevels())
-        return CXXRecordDecl::LambdaDependencyKind::LDK_AlwaysDependent;
-      for (const TemplateArgument &TA : TypeAlias.AssociatedTemplateArguments)
-        if (TA.isDependent())
+    template<typename Fn>
+    QualType TransformFunctionProtoType(TypeLocBuilder &TLB,
+                                        FunctionProtoTypeLoc TL,
+                                        CXXRecordDecl *ThisContext,
+                                        Qualifiers ThisTypeQuals,
+                                        Fn TransformExceptionSpec);
+
+    ParmVarDecl *TransformFunctionTypeParam(ParmVarDecl *OldParm,
+                                            int indexAdjustment,
+                                            UnsignedOrNone NumExpansions,
+                                            bool ExpectParameterPack);
+
+    using inherited::TransformTemplateTypeParmType;
+    /// Transforms a template type parameter type by performing
+    /// substitution of the corresponding template type argument.
+    QualType TransformTemplateTypeParmType(TypeLocBuilder &TLB,
+                                           TemplateTypeParmTypeLoc TL,
+                                           bool SuppressObjCLifetime);
+
+    QualType BuildSubstTemplateTypeParmType(
+        TypeLocBuilder &TLB, bool SuppressObjCLifetime, bool Final,
+        Decl *AssociatedDecl, unsigned Index, UnsignedOrNone PackIndex,
+        TemplateArgument Arg, SourceLocation NameLoc);
+
+    /// Transforms an already-substituted template type parameter pack
+    /// into either itself (if we aren't substituting into its pack expansion)
+    /// or the appropriate substituted argument.
+    using inherited::TransformSubstTemplateTypeParmPackType;
+    QualType
+    TransformSubstTemplateTypeParmPackType(TypeLocBuilder &TLB,
+                                           SubstTemplateTypeParmPackTypeLoc TL,
+                                           bool SuppressObjCLifetime);
+    QualType
+    TransformSubstBuiltinTemplatePackType(TypeLocBuilder &TLB,
+                                          SubstBuiltinTemplatePackTypeLoc TL);
+
+    CXXRecordDecl::LambdaDependencyKind
+    ComputeLambdaDependency(LambdaScopeInfo *LSI) {
+      if (auto TypeAlias =
+              TemplateInstArgsHelpers::getEnclosingTypeAliasTemplateDecl(
+                  getSema());
+          TypeAlias && TemplateInstArgsHelpers::isLambdaEnclosedByTypeAliasDecl(
+                           LSI->CallOperator, TypeAlias.PrimaryTypeAliasDecl)) {
+        unsigned TypeAliasDeclDepth = TypeAlias.Template->getTemplateDepth();
+        if (TypeAliasDeclDepth >= TemplateArgs.getNumSubstitutedLevels())
           return CXXRecordDecl::LambdaDependencyKind::LDK_AlwaysDependent;
+        for (const TemplateArgument &TA : TypeAlias.AssociatedTemplateArguments)
+          if (TA.isDependent())
+            return CXXRecordDecl::LambdaDependencyKind::LDK_AlwaysDependent;
+      }
+      return inherited::ComputeLambdaDependency(LSI);
     }
-    return inherited::ComputeLambdaDependency(LSI);
-  }
 
-  ExprResult TransformLambdaExpr(LambdaExpr *E) {
-    // Do not rebuild lambdas to avoid creating a new type.
-    // Lambdas have already been processed inside their eval contexts.
-    if (SemaRef.RebuildingImmediateInvocation)
-      return E;
-    LocalInstantiationScope Scope(SemaRef, /*CombineWithOuterScope=*/true,
-                                  /*InstantiatingLambdaOrBlock=*/true);
-    Sema::ConstraintEvalRAII<TemplateInstantiator> RAII(*this);
+    ExprResult TransformLambdaExpr(LambdaExpr *E) {
+      // Do not rebuild lambdas to avoid creating a new type.
+      // Lambdas have already been processed inside their eval contexts.
+      if (SemaRef.RebuildingImmediateInvocation)
+        return E;
+      LocalInstantiationScope Scope(SemaRef, /*CombineWithOuterScope=*/true,
+                                    /*InstantiatingLambdaOrBlock=*/true);
+      Sema::ConstraintEvalRAII<TemplateInstantiator> RAII(*this);
 
-    return inherited::TransformLambdaExpr(E);
-  }
+      return inherited::TransformLambdaExpr(E);
+    }
 
-  ExprResult TransformBlockExpr(BlockExpr *E) {
-    LocalInstantiationScope Scope(SemaRef, /*CombineWithOuterScope=*/true,
-                                  /*InstantiatingLambdaOrBlock=*/true);
-    return inherited::TransformBlockExpr(E);
-  }
+    ExprResult TransformBlockExpr(BlockExpr *E) {
+      LocalInstantiationScope Scope(SemaRef, /*CombineWithOuterScope=*/true,
+                                    /*InstantiatingLambdaOrBlock=*/true);
+      return inherited::TransformBlockExpr(E);
+    }
 
-  ExprResult RebuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc,
-                               LambdaScopeInfo *LSI) {
-    CXXMethodDecl *MD = LSI->CallOperator;
-    for (ParmVarDecl *PVD : MD->parameters()) {
-      assert(PVD && "null in a parameter list");
-      if (!PVD->hasDefaultArg())
-        continue;
-      Expr *UninstExpr = PVD->getUninstantiatedDefaultArg();
-      // FIXME: Obtain the source location for the '=' token.
-      SourceLocation EqualLoc = UninstExpr->getBeginLoc();
-      if (SemaRef.SubstDefaultArgument(EqualLoc, PVD, TemplateArgs)) {
-        // If substitution fails, the default argument is set to a
-        // RecoveryExpr that wraps the uninstantiated default argument so
-        // that downstream diagnostics are omitted.
-        ExprResult ErrorResult = SemaRef.CreateRecoveryExpr(
-            UninstExpr->getBeginLoc(), UninstExpr->getEndLoc(), {UninstExpr},
-            UninstExpr->getType());
-        if (ErrorResult.isUsable())
-          PVD->setDefaultArg(ErrorResult.get());
+    ExprResult RebuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc,
+                                 LambdaScopeInfo *LSI) {
+      CXXMethodDecl *MD = LSI->CallOperator;
+      for (ParmVarDecl *PVD : MD->parameters()) {
+        assert(PVD && "null in a parameter list");
+        if (!PVD->hasDefaultArg())
+          continue;
+        Expr *UninstExpr = PVD->getUninstantiatedDefaultArg();
+        // FIXME: Obtain the source location for the '=' token.
+        SourceLocation EqualLoc = UninstExpr->getBeginLoc();
+        if (SemaRef.SubstDefaultArgument(EqualLoc, PVD, TemplateArgs)) {
+          // If substitution fails, the default argument is set to a
+          // RecoveryExpr that wraps the uninstantiated default argument so
+          // that downstream diagnostics are omitted.
+          ExprResult ErrorResult = SemaRef.CreateRecoveryExpr(
+              UninstExpr->getBeginLoc(), UninstExpr->getEndLoc(), {UninstExpr},
+              UninstExpr->getType());
+          if (ErrorResult.isUsable())
+            PVD->setDefaultArg(ErrorResult.get());
+        }
       }
+      return inherited::RebuildLambdaExpr(StartLoc, EndLoc, LSI);
     }
-    return inherited::RebuildLambdaExpr(StartLoc, EndLoc, LSI);
-  }
 
-  StmtResult TransformLambdaBody(LambdaExpr *E, Stmt *Body) {
-    // Currently, we instantiate the body when instantiating the lambda
-    // expression. However, `EvaluateConstraints` is disabled during the
-    // instantiation of the lambda expression, causing the instantiation
-    // failure of the return type requirement in the body. If p0588r1 is fully
-    // implemented, the body will be lazily instantiated, and this problem
-    // will not occur. Here, `EvaluateConstraints` is temporarily set to
-    // `true` to temporarily fix this issue.
-    // FIXME: This temporary fix can be removed after fully implementing
-    // p0588r1.
-    llvm::SaveAndRestore _(EvaluateConstraints, true);
-    return inherited::TransformLambdaBody(E, Body);
-  }
+    StmtResult TransformLambdaBody(LambdaExpr *E, Stmt *Body) {
+      // Currently, we instantiate the body when instantiating the lambda
+      // expression. However, `EvaluateConstraints` is disabled during the
+      // instantiation of the lambda expression, causing the instantiation
+      // failure of the return type requirement in the body. If p0588r1 is fully
+      // implemented, the body will be lazily instantiated, and this problem
+      // will not occur. Here, `EvaluateConstraints` is temporarily set to
+      // `true` to temporarily fix this issue.
+      // FIXME: This temporary fix can be removed after fully implementing
+      // p0588r1.
+      llvm::SaveAndRestore _(EvaluateConstraints, true);
+      return inherited::TransformLambdaBody(E, Body);
+    }
 
-  ExprResult TransformRequiresExpr(RequiresExpr *E) {
-    LocalInstantiationScope Scope(SemaRef, /*CombineWithOuterScope=*/true);
-    ExprResult TransReq = inherited::TransformRequiresExpr(E);
-    if (TransReq.isInvalid())
+    ExprResult TransformRequiresExpr(RequiresExpr *E) {
+      LocalInstantiationScope Scope(SemaRef, /*CombineWithOuterScope=*/true);
+      ExprResult TransReq = inherited::TransformRequiresExpr(E);
+      if (TransReq.isInvalid())
+        return TransReq;
+      assert(TransReq.get() != E &&
+             "Do not change value of isSatisfied for the existing expression. "
+             "Create a new expression instead.");
+      if (E->getBody()->isDependentContext()) {
+        Sema::SFINAETrap Trap(SemaRef);
+        // We recreate the RequiresExpr body, but not by instantiating it.
+        // Produce pending diagnostics for dependent access check.
+        SemaRef.PerformDependentDiagnostics(E->getBody(), TemplateArgs);
+        // FIXME: Store SFINAE diagnostics in RequiresExpr for diagnosis.
+        if (Trap.hasErrorOccurred())
+          TransReq.getAs<RequiresExpr>()->setSatisfied(false);
+      }
       return TransReq;
-    assert(TransReq.get() != E &&
-           "Do not change value of isSatisfied for the existing expression. "
-           "Create a new expression instead.");
-    if (E->getBody()->isDependentContext()) {
-      Sema::SFINAETrap Trap(SemaRef);
-      // We recreate the RequiresExpr body, but not by instantiating it.
-      // Produce pending diagnostics for dependent access check.
-      SemaRef.PerformDependentDiagnostics(E->getBody(), TemplateArgs);
-      // FIXME: Store SFINAE diagnostics in RequiresExpr for diagnosis.
-      if (Trap.hasErrorOccurred())
-        TransReq.getAs<RequiresExpr>()->setSatisfied(false);
     }
-    return TransReq;
-  }
 
-  bool TransformRequiresExprRequirements(
-      ArrayRef<concepts::Requirement *> Reqs,
-      SmallVectorImpl<concepts::Requirement *> &Transformed) {
-    bool SatisfactionDetermined = false;
-    for (concepts::Requirement *Req : Reqs) {
-      concepts::Requirement *TransReq = nullptr;
-      if (!SatisfactionDetermined) {
-        if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
-          TransReq = TransformTypeRequirement(TypeReq);
-        else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
-          TransReq = TransformExprRequirement(ExprReq);
-        else
-          TransReq = TransformNestedRequirement(
-              cast<concepts::NestedRequirement>(Req));
-        if (!TransReq)
-          return true;
-        if (!TransReq->isDependent() && !TransReq->isSatisfied())
-          // [expr.prim.req]p6
-          //   [...]  The substitution and semantic constraint checking
-          //   proceeds in lexical order and stops when a condition that
-          //   determines the result of the requires-expression is
-          //   encountered. [..]
-          SatisfactionDetermined = true;
-      } else
-        TransReq = Req;
-      Transformed.push_back(TransReq);
+    bool TransformRequiresExprRequirements(
+        ArrayRef<concepts::Requirement *> Reqs,
+        SmallVectorImpl<concepts::Requirement *> &Transformed) {
+      bool SatisfactionDetermined = false;
+      for (concepts::Requirement *Req : Reqs) {
+        concepts::Requirement *TransReq = nullptr;
+        if (!SatisfactionDetermined) {
+          if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
+            TransReq = TransformTypeRequirement(TypeReq);
+          else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
+            TransReq = TransformExprRequirement(ExprReq);
+          else
+            TransReq = TransformNestedRequirement(
+                cast<concepts::NestedRequirement>(Req));
+          if (!TransReq)
+            return true;
+          if (!TransReq->isDependent() && !TransReq->isSatisfied())
+            // [expr.prim.req]p6
+            //   [...]  The substitution and semantic constraint checking
+            //   proceeds in lexical order and stops when a condition that
+            //   determines the result of the requires-expression is
+            //   encountered. [..]
+            SatisfactionDetermined = true;
+        } else
+          TransReq = Req;
+        Transformed.push_back(TransReq);
+      }
+      return false;
     }
-    return false;
-  }
 
-  TemplateParameterList *
-  TransformTemplateParameterList(TemplateParameterList *OrigTPL) {
-    if (!OrigTPL || !OrigTPL->size())
-      return OrigTPL;
-
-    DeclContext *Owner = OrigTPL->getParam(0)->getDeclContext();
-    TemplateDeclInstantiator DeclInstantiator(getSema(),
-                                              /* DeclContext *Owner */ Owner,
-                                              TemplateArgs);
-    DeclInstantiator.setEvaluateConstraints(EvaluateConstraints);
-    return DeclInstantiator.SubstTemplateParams(OrigTPL);
-  }
+    TemplateParameterList *TransformTemplateParameterList(
+                              TemplateParameterList *OrigTPL)  {
+      if (!OrigTPL || !OrigTPL->size()) return OrigTPL;
 
-  concepts::TypeRequirement *
-  TransformTypeRequirement(concepts::TypeRequirement *Req);
-  concepts::ExprRequirement *
-  TransformExprRequirement(concepts::ExprRequirement *Req);
-  concepts::NestedRequirement *
-  TransformNestedRequirement(concepts::NestedRequirement *Req);
-  ExprResult TransformRequiresTypeParams(
-      SourceLocation KWLoc, SourceLocation RBraceLoc, const RequiresExpr *RE,
-      RequiresExprBodyDecl *Body, ArrayRef<ParmVarDecl *> Params,
-      SmallVectorImpl<QualType> &PTypes,
-      SmallVectorImpl<ParmVarDecl *> &TransParams,
-      Sema::ExtParameterInfoBuilder &PInfos);
-};
-} // namespace
+      DeclContext *Owner = OrigTPL->getParam(0)->getDeclContext();
+      TemplateDeclInstantiator  DeclInstantiator(getSema(),
+                        /* DeclContext *Owner */ Owner, TemplateArgs);
+      DeclInstantiator.setEvaluateConstraints(EvaluateConstraints);
+      return DeclInstantiator.SubstTemplateParams(OrigTPL);
+    }
+
+    concepts::TypeRequirement *
+    TransformTypeRequirement(concepts::TypeRequirement *Req);
+    concepts::ExprRequirement *
+    TransformExprRequirement(concepts::ExprRequirement *Req);
+    concepts::NestedRequirement *
+    TransformNestedRequirement(concepts::NestedRequirement *Req);
+    ExprResult TransformRequiresTypeParams(
+        SourceLocation KWLoc, SourceLocation RBraceLoc, const RequiresExpr *RE,
+        RequiresExprBodyDecl *Body, ArrayRef<ParmVarDecl *> Params,
+        SmallVectorImpl<QualType> &PTypes,
+        SmallVectorImpl<ParmVarDecl *> &TransParams,
+        Sema::ExtParameterInfoBuilder &PInfos);
+  };
+}
 
 bool TemplateInstantiator::AlreadyTransformed(QualType T) {
   if (T.isNull())
@@ -1980,8 +1989,8 @@ TemplateInstantiator::TransformFirstQualifierInScope(NamedDecl *D,
   // If the first part of the nested-name-specifier was a template type
   // parameter, instantiate that type parameter down to a tag type.
   if (TemplateTypeParmDecl *TTPD = dyn_cast_or_null<TemplateTypeParmDecl>(D)) {
-    const TemplateTypeParmType *TTP =
-        cast<TemplateTypeParmType>(getSema().Context.getTypeDeclType(TTPD));
+    const TemplateTypeParmType *TTP
+      = cast<TemplateTypeParmType>(getSema().Context.getTypeDeclType(TTPD));
 
     if (TTP->getDepth() < TemplateArgs.getNumLevels()) {
       // FIXME: This needs testing w/ member access expressions.
@@ -2013,11 +2022,12 @@ TemplateInstantiator::TransformFirstQualifierInScope(NamedDecl *D,
   return cast_or_null<NamedDecl>(TransformDecl(Loc, D));
 }
 
-VarDecl *TemplateInstantiator::RebuildExceptionDecl(VarDecl *ExceptionDecl,
-                                                    TypeSourceInfo *Declarator,
-                                                    SourceLocation StartLoc,
-                                                    SourceLocation NameLoc,
-                                                    IdentifierInfo *Name) {
+VarDecl *
+TemplateInstantiator::RebuildExceptionDecl(VarDecl *ExceptionDecl,
+                                           TypeSourceInfo *Declarator,
+                                           SourceLocation StartLoc,
+                                           SourceLocation NameLoc,
+                                           IdentifierInfo *Name) {
   VarDecl *Var = inherited::RebuildExceptionDecl(ExceptionDecl, Declarator,
                                                  StartLoc, NameLoc, Name);
   if (Var)
@@ -2090,8 +2100,8 @@ TemplateName TemplateInstantiator::TransformTemplateName(
     }
   }
 
-  if (SubstTemplateTemplateParmPackStorage *SubstPack =
-          Name.getAsSubstTemplateTemplateParmPack()) {
+  if (SubstTemplateTemplateParmPackStorage *SubstPack
+      = Name.getAsSubstTemplateTemplateParmPack()) {
     if (!getSema().ArgPackSubstIndex)
       return Name;
 
@@ -2108,15 +2118,17 @@ TemplateName TemplateInstantiator::TransformTemplateName(
       FirstQualifierInScope, AllowInjectedClassName);
 }
 
-ExprResult TemplateInstantiator::TransformPredefinedExpr(PredefinedExpr *E) {
+ExprResult
+TemplateInstantiator::TransformPredefinedExpr(PredefinedExpr *E) {
   if (!E->isTypeDependent())
     return E;
 
   return getSema().BuildPredefinedExpr(E->getLocation(), E->getIdentKind());
 }
 
-ExprResult TemplateInstantiator::TransformTemplateParmRefExpr(
-    DeclRefExpr *E, NonTypeTemplateParmDecl *NTTP) {
+ExprResult
+TemplateInstantiator::TransformTemplateParmRefExpr(DeclRefExpr *E,
+                                               NonTypeTemplateParmDecl *NTTP) {
   // If the corresponding template argument is NULL or non-existent, it's
   // because we are performing instantiation from explicitly-specified
   // template arguments in a function template, but there were some
@@ -2144,14 +2156,16 @@ ExprResult TemplateInstantiator::TransformTemplateParmRefExpr(
       TemplateArgs.getAssociatedDecl(NTTP->getDepth());
   UnsignedOrNone PackIndex = std::nullopt;
   if (NTTP->isParameterPack()) {
-    assert(Arg.getKind() == TemplateArgument::Pack && "Missing argument pack");
+    assert(Arg.getKind() == TemplateArgument::Pack &&
+           "Missing argument pack");
 
     if (!getSema().ArgPackSubstIndex) {
       // We have an argument pack, but we can't select a particular argument
       // out of it yet. Therefore, we'll build an expression to hold on to that
       // argument pack.
-      QualType TargetType = SemaRef.SubstType(
-          NTTP->getType(), TemplateArgs, E->getLocation(), NTTP->getDeclName());
+      QualType TargetType = SemaRef.SubstType(NTTP->getType(), TemplateArgs,
+                                              E->getLocation(),
+                                              NTTP->getDeclName());
       if (TargetType.isNull())
         return ExprError();
 
@@ -2289,8 +2303,8 @@ TemplateInstantiator::TransformFunctionParmPackExpr(FunctionParmPackExpr *E) {
   // parameters in the instantiation of the function decl.
   SmallVector<ValueDecl *, 8> Vars;
   Vars.reserve(E->getNumExpansions());
-  for (FunctionParmPackExpr::iterator I = E->begin(), End = E->end(); I != End;
-       ++I) {
+  for (FunctionParmPackExpr::iterator I = E->begin(), End = E->end();
+       I != End; ++I) {
     ValueDecl *D = cast_or_null<ValueDecl>(TransformDecl(E->getExprLoc(), *I));
     if (!D)
       return ExprError();
@@ -2308,8 +2322,8 @@ ExprResult
 TemplateInstantiator::TransformFunctionParmPackRefExpr(DeclRefExpr *E,
                                                        ValueDecl *PD) {
   typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack;
-  llvm::PointerUnion<Decl *, DeclArgumentPack *> *Found =
-      getSema().CurrentInstantiationScope->findInstantiationOf(PD);
+  llvm::PointerUnion<Decl *, DeclArgumentPack *> *Found
+    = getSema().CurrentInstantiationScope->findInstantiationOf(PD);
   assert(Found && "no instantiation for parameter pack");
 
   Decl *TransformedDecl;
@@ -2336,7 +2350,8 @@ TemplateInstantiator::TransformFunctionParmPackRefExpr(DeclRefExpr *E,
                                E->getExprLoc());
 }
 
-ExprResult TemplateInstantiator::TransformDeclRefExpr(DeclRefExpr *E) {
+ExprResult
+TemplateInstantiator::TransformDeclRefExpr(DeclRefExpr *E) {
   NamedDecl *D = E->getDecl();
 
   // Handle references to non-type template parameters and non-type template
@@ -2357,38 +2372,22 @@ ExprResult TemplateInstantiator::TransformDeclRefExpr(DeclRefExpr *E) {
   return inherited::TransformDeclRefExpr(E);
 }
 
-ExprResult TemplateInstantiator::TransformCXXReflectExpr(CXXReflectExpr *E) {
-
-  // TODO(reflection): add support for NamespaceReference, TemplateReference and
-  // DeclRefExpr
-  switch (E->getKind()) {
-  case ReflectionKind::Type: {
-    TypeSourceInfo *NewT = getDerived().TransformType(
-        static_cast<TypeSourceInfo *>(const_cast<void *>(E->getOpaqueValue())));
-    if (!NewT)
-      return ExprError();
-    return getSema().BuildCXXReflectExpr(E->getOperatorLoc(), NewT);
-  }
-  }
-
-  llvm_unreachable("unknown or unimplemented reflection entity kind");
-  return ExprError();
-}
-
-ExprResult
-TemplateInstantiator::TransformCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
-  assert(!cast<FunctionDecl>(E->getParam()->getDeclContext())
-              ->getDescribedFunctionTemplate() &&
+ExprResult TemplateInstantiator::TransformCXXDefaultArgExpr(
+    CXXDefaultArgExpr *E) {
+  assert(!cast<FunctionDecl>(E->getParam()->getDeclContext())->
+             getDescribedFunctionTemplate() &&
          "Default arg expressions are never formed in dependent cases.");
   return SemaRef.BuildCXXDefaultArgExpr(
       E->getUsedLocation(), cast<FunctionDecl>(E->getParam()->getDeclContext()),
       E->getParam());
 }
 
-template <typename Fn>
-QualType TemplateInstantiator::TransformFunctionProtoType(
-    TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext,
-    Qualifiers ThisTypeQuals, Fn TransformExceptionSpec) {
+template<typename Fn>
+QualType TemplateInstantiator::TransformFunctionProtoType(TypeLocBuilder &TLB,
+                                 FunctionProtoTypeLoc TL,
+                                 CXXRecordDecl *ThisContext,
+                                 Qualifiers ThisTypeQuals,
+                                 Fn TransformExceptionSpec) {
   // If this is a lambda or block, the transformation MUST be done in the
   // CurrentInstantiationScope since it introduces a mapping of
   // the original to the newly created transformed parameters.
@@ -2459,8 +2458,8 @@ TemplateInstantiator::TransformTemplateTypeParmType(TypeLocBuilder &TLB,
       if (BailOutOnIncomplete)
         return QualType();
 
-      TemplateTypeParmTypeLoc NewTL =
-          TLB.push<TemplateTypeParmTypeLoc>(TL.getType());
+      TemplateTypeParmTypeLoc NewTL
+        = TLB.push<TemplateTypeParmTypeLoc>(TL.getType());
       NewTL.setNameLoc(TL.getNameLoc());
       return TL.getType();
     }
@@ -2498,8 +2497,8 @@ TemplateInstantiator::TransformTemplateTypeParmType(TypeLocBuilder &TLB,
         // pack for later substitution.
         QualType Result = getSema().Context.getSubstTemplateTypeParmPackType(
             AssociatedDecl, T->getIndex(), Final, Arg);
-        SubstTemplateTypeParmPackTypeLoc NewTL =
-            TLB.push<SubstTemplateTypeParmPackTypeLoc>(Result);
+        SubstTemplateTypeParmPackTypeLoc NewTL
+          = TLB.push<SubstTemplateTypeParmPackTypeLoc>(Result);
         NewTL.setNameLoc(TL.getNameLoc());
         return Result;
       }
@@ -2640,7 +2639,8 @@ TemplateInstantiator::TransformTypeRequirement(concepts::TypeRequirement *Req) {
     return Req;
   if (Req->isSubstitutionFailure()) {
     if (AlwaysRebuild())
-      return RebuildTypeRequirement(Req->getSubstitutionDiagnostic());
+      return RebuildTypeRequirement(
+              Req->getSubstitutionDiagnostic());
     return Req;
   }
 
@@ -2653,9 +2653,9 @@ TemplateInstantiator::TransformTypeRequirement(concepts::TypeRequirement *Req) {
     return nullptr;
   TypeSourceInfo *TransType = TransformType(Req->getType());
   if (!TransType || Trap.hasErrorOccurred())
-    return RebuildTypeRequirement(
-        createSubstDiag(SemaRef, Info, [&](llvm::raw_ostream &OS) {
-          Req->getType()->getType().print(OS, SemaRef.getPrintingPolicy());
+    return RebuildTypeRequirement(createSubstDiag(SemaRef, Info,
+        [&] (llvm::raw_ostream& OS) {
+            Req->getType()->getType().print(OS, SemaRef.getPrintingPolicy());
         }));
   return RebuildTypeRequirement(TransType);
 }
@@ -2706,11 +2706,10 @@ TemplateInstantiator::TransformExprRequirement(concepts::ExprRequirement *Req) {
       return nullptr;
     TemplateParameterList *TPL = TransformTemplateParameterList(OrigTPL);
     if (!TPL || Trap.hasErrorOccurred())
-      TransRetReq.emplace(
-          createSubstDiag(SemaRef, Info, [&](llvm::raw_ostream &OS) {
-            RetReq.getTypeConstraint()
-                ->getImmediatelyDeclaredConstraint()
-                ->printPretty(OS, nullptr, SemaRef.getPrintingPolicy());
+      TransRetReq.emplace(createSubstDiag(SemaRef, Info,
+          [&] (llvm::raw_ostream& OS) {
+              RetReq.getTypeConstraint()->getImmediatelyDeclaredConstraint()
+                  ->printPretty(OS, nullptr, SemaRef.getPrintingPolicy());
           }));
     else {
       TPLInst.Clear();
@@ -2726,7 +2725,8 @@ TemplateInstantiator::TransformExprRequirement(concepts::ExprRequirement *Req) {
       Req->isSimple(), Req->getNoexceptLoc(), std::move(*TransRetReq));
 }
 
-concepts::NestedRequirement *TemplateInstantiator::TransformNestedRequirement(
+concepts::NestedRequirement *
+TemplateInstantiator::TransformNestedRequirement(
     concepts::NestedRequirement *Req) {
 
   ASTContext &C = SemaRef.Context;
@@ -2798,7 +2798,8 @@ concepts::NestedRequirement *TemplateInstantiator::TransformNestedRequirement(
 
 TypeSourceInfo *Sema::SubstType(TypeSourceInfo *T,
                                 const MultiLevelTemplateArgumentList &Args,
-                                SourceLocation Loc, DeclarationName Entity,
+                                SourceLocation Loc,
+                                DeclarationName Entity,
                                 bool AllowDeducedTST) {
   assert(!CodeSynthesisContexts.empty() &&
          "Cannot perform an instantiation without some context on the "
@@ -2815,7 +2816,8 @@ TypeSourceInfo *Sema::SubstType(TypeSourceInfo *T,
 
 TypeSourceInfo *Sema::SubstType(TypeLoc TL,
                                 const MultiLevelTemplateArgumentList &Args,
-                                SourceLocation Loc, DeclarationName Entity) {
+                                SourceLocation Loc,
+                                DeclarationName Entity) {
   assert(!CodeSynthesisContexts.empty() &&
          "Cannot perform an instantiation without some context on the "
          "instantiation stack");
@@ -2877,8 +2879,7 @@ static bool NeedsInstantiationAsFunctionType(TypeSourceInfo *T) {
   FunctionProtoTypeLoc FP = TL.castAs<FunctionProtoTypeLoc>();
   for (ParmVarDecl *P : FP.getParams()) {
     // This must be synthesized from a typedef.
-    if (!P)
-      continue;
+    if (!P) continue;
 
     // If there are any parameters, a new TypeSourceInfo that refers to the
     // instantiated parameters must be built.
@@ -2888,10 +2889,13 @@ static bool NeedsInstantiationAsFunctionType(TypeSourceInfo *T) {
   return false;
 }
 
-TypeSourceInfo *Sema::SubstFunctionDeclType(
-    TypeSourceInfo *T, const MultiLevelTemplateArgumentList &Args,
-    SourceLocation Loc, DeclarationName Entity, CXXRecordDecl *ThisContext,
-    Qualifiers ThisTypeQuals, bool EvaluateConstraints) {
+TypeSourceInfo *Sema::SubstFunctionDeclType(TypeSourceInfo *T,
+                                const MultiLevelTemplateArgumentList &Args,
+                                SourceLocation Loc,
+                                DeclarationName Entity,
+                                CXXRecordDecl *ThisContext,
+                                Qualifiers ThisTypeQuals,
+                                bool EvaluateConstraints) {
   assert(!CodeSynthesisContexts.empty() &&
          "Cannot perform an instantiation without some context on the "
          "instantiation stack");
@@ -2918,9 +2922,8 @@ TypeSourceInfo *Sema::SubstFunctionDeclType(
     // instead of rebuilding the function type again later.
     Result = Instantiator.TransformFunctionProtoType(
         TLB, Proto, ThisContext, ThisTypeQuals,
-        [](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
-          return false;
-        });
+        [](FunctionProtoType::ExceptionSpecInfo &ESI,
+           bool &Changed) { return false; });
   } else {
     Result = Instantiator.TransformType(TLB, TL);
   }
@@ -2958,85 +2961,85 @@ void Sema::SubstExceptionSpec(FunctionDecl *New, const FunctionProtoType *Proto,
 
 namespace {
 
-struct GetContainedInventedTypeParmVisitor
-    : public TypeVisitor<GetContainedInventedTypeParmVisitor,
-                         TemplateTypeParmDecl *> {
-  using TypeVisitor<GetContainedInventedTypeParmVisitor,
-                    TemplateTypeParmDecl *>::Visit;
+  struct GetContainedInventedTypeParmVisitor :
+    public TypeVisitor<GetContainedInventedTypeParmVisitor,
+                       TemplateTypeParmDecl *> {
+    using TypeVisitor<GetContainedInventedTypeParmVisitor,
+                      TemplateTypeParmDecl *>::Visit;
 
-  TemplateTypeParmDecl *Visit(QualType T) {
-    if (T.isNull())
-      return nullptr;
-    return Visit(T.getTypePtr());
-  }
-  // The deduced type itself.
-  TemplateTypeParmDecl *
-  VisitTemplateTypeParmType(const TemplateTypeParmType *T) {
-    if (!T->getDecl() || !T->getDecl()->isImplicit())
-      return nullptr;
-    return T->getDecl();
-  }
+    TemplateTypeParmDecl *Visit(QualType T) {
+      if (T.isNull())
+        return nullptr;
+      return Visit(T.getTypePtr());
+    }
+    // The deduced type itself.
+    TemplateTypeParmDecl *VisitTemplateTypeParmType(
+        const TemplateTypeParmType *T) {
+      if (!T->getDecl() || !T->getDecl()->isImplicit())
+        return nullptr;
+      return T->getDecl();
+    }
 
-  // Only these types can contain 'auto' types, and subsequently be replaced
-  // by references to invented parameters.
+    // Only these types can contain 'auto' types, and subsequently be replaced
+    // by references to invented parameters.
 
-  TemplateTypeParmDecl *VisitPointerType(const PointerType *T) {
-    return Visit(T->getPointeeType());
-  }
+    TemplateTypeParmDecl *VisitPointerType(const PointerType *T) {
+      return Visit(T->getPointeeType());
+    }
 
-  TemplateTypeParmDecl *VisitBlockPointerType(const BlockPointerType *T) {
-    return Visit(T->getPointeeType());
-  }
+    TemplateTypeParmDecl *VisitBlockPointerType(const BlockPointerType *T) {
+      return Visit(T->getPointeeType());
+    }
 
-  TemplateTypeParmDecl *VisitReferenceType(const ReferenceType *T) {
-    return Visit(T->getPointeeTypeAsWritten());
-  }
+    TemplateTypeParmDecl *VisitReferenceType(const ReferenceType *T) {
+      return Visit(T->getPointeeTypeAsWritten());
+    }
 
-  TemplateTypeParmDecl *VisitMemberPointerType(const MemberPointerType *T) {
-    return Visit(T->getPointeeType());
-  }
+    TemplateTypeParmDecl *VisitMemberPointerType(const MemberPointerType *T) {
+      return Visit(T->getPointeeType());
+    }
 
-  TemplateTypeParmDecl *VisitArrayType(const ArrayType *T) {
-    return Visit(T->getElementType());
-  }
+    TemplateTypeParmDecl *VisitArrayType(const ArrayType *T) {
+      return Visit(T->getElementType());
+    }
 
-  TemplateTypeParmDecl *
-  VisitDependentSizedExtVectorType(const DependentSizedExtVectorType *T) {
-    return Visit(T->getElementType());
-  }
+    TemplateTypeParmDecl *VisitDependentSizedExtVectorType(
+      const DependentSizedExtVectorType *T) {
+      return Visit(T->getElementType());
+    }
 
-  TemplateTypeParmDecl *VisitVectorType(const VectorType *T) {
-    return Visit(T->getElementType());
-  }
+    TemplateTypeParmDecl *VisitVectorType(const VectorType *T) {
+      return Visit(T->getElementType());
+    }
 
-  TemplateTypeParmDecl *VisitFunctionProtoType(const FunctionProtoType *T) {
-    return VisitFunctionType(T);
-  }
+    TemplateTypeParmDecl *VisitFunctionProtoType(const FunctionProtoType *T) {
+      return VisitFunctionType(T);
+    }
 
-  TemplateTypeParmDecl *VisitFunctionType(const FunctionType *T) {
-    return Visit(T->getReturnType());
-  }
+    TemplateTypeParmDecl *VisitFunctionType(const FunctionType *T) {
+      return Visit(T->getReturnType());
+    }
 
-  TemplateTypeParmDecl *VisitParenType(const ParenType *T) {
-    return Visit(T->getInnerType());
-  }
+    TemplateTypeParmDecl *VisitParenType(const ParenType *T) {
+      return Visit(T->getInnerType());
+    }
 
-  TemplateTypeParmDecl *VisitAttributedType(const AttributedType *T) {
-    return Visit(T->getModifiedType());
-  }
+    TemplateTypeParmDecl *VisitAttributedType(const AttributedType *T) {
+      return Visit(T->getModifiedType());
+    }
 
-  TemplateTypeParmDecl *VisitMacroQualifiedType(const MacroQualifiedType *T) {
-    return Visit(T->getUnderlyingType());
-  }
+    TemplateTypeParmDecl *VisitMacroQualifiedType(const MacroQualifiedType *T) {
+      return Visit(T->getUnderlyingType());
+    }
 
-  TemplateTypeParmDecl *VisitAdjustedType(const AdjustedType *T) {
-    return Visit(T->getOriginalType());
-  }
+    TemplateTypeParmDecl *VisitAdjustedType(const AdjustedType *T) {
+      return Visit(T->getOriginalType());
+    }
 
-  TemplateTypeParmDecl *VisitPackExpansionType(const PackExpansionType *T) {
-    return Visit(T->getPattern());
-  }
-};
+    TemplateTypeParmDecl *VisitPackExpansionType(const PackExpansionType *T) {
+      return Visit(T->getPattern());
+    }
+  };
 
 } // namespace
 
@@ -3213,8 +3216,10 @@ bool Sema::SubstParmTypes(
 }
 
 bool Sema::SubstDefaultArgument(
-    SourceLocation Loc, ParmVarDecl *Param,
-    const MultiLevelTemplateArgumentList &TemplateArgs, bool ForCallExpr) {
+    SourceLocation Loc,
+    ParmVarDecl *Param,
+    const MultiLevelTemplateArgumentList &TemplateArgs,
+    bool ForCallExpr) {
   FunctionDecl *FD = cast<FunctionDecl>(Param->getDeclContext());
   Expr *PatternExpr = Param->getUninstantiatedDefaultArg();
 
@@ -3265,8 +3270,8 @@ bool Sema::SubstDefaultArgument(
 
   if (ForCallExpr) {
     // Check the expression as an initializer for the parameter.
-    InitializedEntity Entity =
-        InitializedEntity::InitializeParameter(Context, Param);
+    InitializedEntity Entity
+      = InitializedEntity::InitializeParameter(Context, Param);
     InitializationKind Kind = InitializationKind::CreateCopy(
         Param->getLocation(),
         /*FIXME:EqualLoc*/ PatternExpr->getBeginLoc());
@@ -3286,7 +3291,7 @@ bool Sema::SubstDefaultArgument(
     Result = ConvertParamDefaultArgument(Param, Result.getAs<Expr>(), EqualLoc);
   }
   if (Result.isInvalid())
-    return true;
+      return true;
 
   // Remember the instantiated default argument.
   Param->setDefaultArg(Result.getAs<Expr>());
@@ -3360,11 +3365,12 @@ PreparePackForExpansion(Sema &S, const CXXBaseSpecifier &Base,
   return false;
 }
 
-bool Sema::SubstBaseSpecifiers(
-    CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
-    const MultiLevelTemplateArgumentList &TemplateArgs) {
+bool
+Sema::SubstBaseSpecifiers(CXXRecordDecl *Instantiation,
+                          CXXRecordDecl *Pattern,
+                          const MultiLevelTemplateArgumentList &TemplateArgs) {
   bool Invalid = false;
-  SmallVector<CXXBaseSpecifier *, 4> InstantiatedBases;
+  SmallVector<CXXBaseSpecifier*, 4> InstantiatedBases;
   for (const auto &Base : Pattern->bases()) {
     if (!Base.getType()->isDependentType()) {
       if (const CXXRecordDecl *RD = Base.getType()->getAsCXXRecordDecl()) {
@@ -3422,9 +3428,10 @@ bool Sema::SubstBaseSpecifiers(
           SubstType(BaseTypeLoc, *ArgsForSubst,
                     Base.getSourceRange().getBegin(), DeclarationName());
     } else {
-      BaseTypeLoc =
-          SubstType(Base.getTypeSourceInfo(), TemplateArgs,
-                    Base.getSourceRange().getBegin(), DeclarationName());
+      BaseTypeLoc = SubstType(Base.getTypeSourceInfo(),
+                              TemplateArgs,
+                              Base.getSourceRange().getBegin(),
+                              DeclarationName());
     }
 
     if (!BaseTypeLoc) {
@@ -3432,9 +3439,13 @@ bool Sema::SubstBaseSpecifiers(
       continue;
     }
 
-    if (CXXBaseSpecifier *InstantiatedBase = CheckBaseSpecifier(
-            Instantiation, Base.getSourceRange(), Base.isVirtual(),
-            Base.getAccessSpecifierAsWritten(), BaseTypeLoc, EllipsisLoc))
+    if (CXXBaseSpecifier *InstantiatedBase
+          = CheckBaseSpecifier(Instantiation,
+                               Base.getSourceRange(),
+                               Base.isVirtual(),
+                               Base.getAccessSpecifierAsWritten(),
+                               BaseTypeLoc,
+                               EllipsisLoc))
       InstantiatedBases.push_back(InstantiatedBase);
     else
       Invalid = true;
@@ -3448,15 +3459,14 @@ bool Sema::SubstBaseSpecifiers(
 
 // Defined via #include from SemaTemplateInstantiateDecl.cpp
 namespace clang {
-namespace sema {
-Attr *instantiateTemplateAttribute(
-    const Attr *At, ASTContext &C, Sema &S,
-    const MultiLevelTemplateArgumentList &TemplateArgs);
-Attr *instantiateTemplateAttributeForDecl(
-    const Attr *At, ASTContext &C, Sema &S,
-    const MultiLevelTemplateArgumentList &TemplateArgs);
-} // namespace sema
-} // namespace clang
+  namespace sema {
+    Attr *instantiateTemplateAttribute(const Attr *At, ASTContext &C, Sema &S,
+                            const MultiLevelTemplateArgumentList &TemplateArgs);
+    Attr *instantiateTemplateAttributeForDecl(
+        const Attr *At, ASTContext &C, Sema &S,
+        const MultiLevelTemplateArgumentList &TemplateArgs);
+  }
+}
 
 bool Sema::InstantiateClass(SourceLocation PointOfInstantiation,
                             CXXRecordDecl *Instantiation,
@@ -3478,12 +3488,11 @@ bool Sema::InstantiateClassImpl(
     CXXRecordDecl *Pattern, const MultiLevelTemplateArgumentList &TemplateArgs,
     TemplateSpecializationKind TSK, bool Complain) {
 
-  CXXRecordDecl *PatternDef =
-      cast_or_null<CXXRecordDecl>(Pattern->getDefinition());
-  if (DiagnoseUninstantiableTemplate(
-          PointOfInstantiation, Instantiation,
-          Instantiation->getInstantiatedFromMemberClass(), Pattern, PatternDef,
-          TSK, Complain))
+  CXXRecordDecl *PatternDef
+    = cast_or_null<CXXRecordDecl>(Pattern->getDefinition());
+  if (DiagnoseUninstantiableTemplate(PointOfInstantiation, Instantiation,
+                                Instantiation->getInstantiatedFromMemberClass(),
+                                     Pattern, PatternDef, TSK, Complain))
     return true;
 
   llvm::TimeTraceScope TimeScope("InstantiateClass", [&]() {
@@ -3502,12 +3511,12 @@ bool Sema::InstantiateClassImpl(
   Pattern = PatternDef;
 
   // Record the point of instantiation.
-  if (MemberSpecializationInfo *MSInfo =
-          Instantiation->getMemberSpecializationInfo()) {
+  if (MemberSpecializationInfo *MSInfo
+        = Instantiation->getMemberSpecializationInfo()) {
     MSInfo->setTemplateSpecializationKind(TSK);
     MSInfo->setPointOfInstantiation(PointOfInstantiation);
-  } else if (ClassTemplateSpecializationDecl *Spec =
-                 dyn_cast<ClassTemplateSpecializationDecl>(Instantiation)) {
+  } else if (ClassTemplateSpecializationDecl *Spec
+        = dyn_cast<ClassTemplateSpecializationDecl>(Instantiation)) {
     Spec->setTemplateSpecializationKind(TSK);
     Spec->setPointOfInstantiation(PointOfInstantiation);
   }
@@ -3528,8 +3537,7 @@ bool Sema::InstantiateClassImpl(
   // If this is an instantiation of a local class, merge this local
   // instantiation scope with the enclosing scope. Otherwise, every
   // instantiation of a class has its own local instantiation scope.
-  bool MergeWithParentScope =
-      !Instantiation->isDefinedOutsideFunctionOrMethod();
+  bool MergeWithParentScope = !Instantiation->isDefinedOutsideFunctionOrMethod();
   LocalInstantiationScope Scope(*this, MergeWithParentScope);
 
   // Some class state isn't processed immediately but delayed till class
@@ -3557,7 +3565,7 @@ bool Sema::InstantiateClassImpl(
 
   TemplateDeclInstantiator Instantiator(*this, Instantiation, TemplateArgs);
   Instantiator.setEvaluateConstraints(false);
-  SmallVector<Decl *, 4> Fields;
+  SmallVector<Decl*, 4> Fields;
   // Delay instantiation of late parsed attributes.
   LateInstantiatedAttrVec LateAttrs;
   Instantiator.enableLateAttributeInstantiation(&LateAttrs);
@@ -3600,8 +3608,7 @@ bool Sema::InstantiateClassImpl(
         // Record a point of instantiation for this implicit instantiation.
         if (TSK == TSK_ImplicitInstantiation && !Enum->isScoped() &&
             Enum->isCompleteDefinition()) {
-          MemberSpecializationInfo *MSInfo =
-              Enum->getMemberSpecializationInfo();
+          MemberSpecializationInfo *MSInfo =Enum->getMemberSpecializationInfo();
           assert(MSInfo && "no spec info for member enum specialization");
           MSInfo->setTemplateSpecializationKind(TSK_ImplicitInstantiation);
           MSInfo->setPointOfInstantiation(PointOfInstantiation);
@@ -3643,8 +3650,7 @@ bool Sema::InstantiateClassImpl(
   // Instantiate late parsed attributes, and attach them to their decls.
   // See Sema::InstantiateAttrs
   for (LateInstantiatedAttrVec::iterator I = LateAttrs.begin(),
-                                         E = LateAttrs.end();
-       I != E; ++I) {
+       E = LateAttrs.end(); I != E; ++I) {
     assert(CurrentInstantiationScope == Instantiator.getStartingScope());
     CurrentInstantiationScope = I->Scope;
 
@@ -3655,7 +3661,7 @@ bool Sema::InstantiateClassImpl(
                                ND->isCXXInstanceMember());
 
     Attr *NewAttr =
-        instantiateTemplateAttribute(I->TmplAttr, Context, *this, TemplateArgs);
+      instantiateTemplateAttribute(I->TmplAttr, Context, *this, TemplateArgs);
     if (NewAttr)
       I->NewDecl->addAttr(NewAttr);
     LocalInstantiationScope::deleteScopes(I->Scope,
@@ -3682,8 +3688,8 @@ bool Sema::InstantiateClassImpl(
     // Instantiate any out-of-line class template partial
     // specializations now.
     for (TemplateDeclInstantiator::delayed_partial_spec_iterator
-             P = Instantiator.delayed_partial_spec_begin(),
-             PEnd = Instantiator.delayed_partial_spec_end();
+              P = Instantiator.delayed_partial_spec_begin(),
+           PEnd = Instantiator.delayed_partial_spec_end();
          P != PEnd; ++P) {
       if (!Instantiator.InstantiateClassTemplatePartialSpecialization(
               P->first, P->second)) {
@@ -3695,8 +3701,8 @@ bool Sema::InstantiateClassImpl(
     // Instantiate any out-of-line variable template partial
     // specializations now.
     for (TemplateDeclInstantiator::delayed_var_partial_spec_iterator
-             P = Instantiator.delayed_var_partial_spec_begin(),
-             PEnd = Instantiator.delayed_var_partial_spec_end();
+              P = Instantiator.delayed_var_partial_spec_begin(),
+           PEnd = Instantiator.delayed_var_partial_spec_end();
          P != PEnd; ++P) {
       if (!Instantiator.InstantiateVarTemplatePartialSpecialization(
               P->first, P->second)) {
@@ -3737,16 +3743,15 @@ bool Sema::InstantiateEnum(SourceLocation PointOfInstantiation,
 #endif
 
   EnumDecl *PatternDef = Pattern->getDefinition();
-  if (DiagnoseUninstantiableTemplate(
-          PointOfInstantiation, Instantiation,
-          Instantiation->getInstantiatedFromMemberEnum(), Pattern, PatternDef,
-          TSK, /*Complain*/ true))
+  if (DiagnoseUninstantiableTemplate(PointOfInstantiation, Instantiation,
+                                 Instantiation->getInstantiatedFromMemberEnum(),
+                                     Pattern, PatternDef, TSK,/*Complain*/true))
     return true;
   Pattern = PatternDef;
 
   // Record the point of instantiation.
-  if (MemberSpecializationInfo *MSInfo =
-          Instantiation->getMemberSpecializationInfo()) {
+  if (MemberSpecializationInfo *MSInfo
+        = Instantiation->getMemberSpecializationInfo()) {
     MSInfo->setTemplateSpecializationKind(TSK);
     MSInfo->setPointOfInstantiation(PointOfInstantiation);
   }
@@ -3768,7 +3773,7 @@ bool Sema::InstantiateEnum(SourceLocation PointOfInstantiation,
   EnterExpressionEvaluationContext EvalContext(
       *this, Sema::ExpressionEvaluationContext::PotentiallyEvaluated);
 
-  LocalInstantiationScope Scope(*this, /*MergeWithParentScope*/ true);
+  LocalInstantiationScope Scope(*this, /*MergeWithParentScope*/true);
 
   // Pull attributes from the pattern onto the instantiation.
   InstantiateAttrs(TemplateArgs, Pattern, Instantiation);
@@ -3852,13 +3857,13 @@ bool Sema::InstantiateInClassInitializer(
 }
 
 namespace {
-/// A partial specialization whose template arguments have matched
-/// a given template-id.
-struct PartialSpecMatchResult {
-  ClassTemplatePartialSpecializationDecl *Partial;
-  TemplateArgumentList *Args;
-};
-} // namespace
+  /// A partial specialization whose template arguments have matched
+  /// a given template-id.
+  struct PartialSpecMatchResult {
+    ClassTemplatePartialSpecializationDecl *Partial;
+    TemplateArgumentList *Args;
+  };
+}
 
 bool Sema::usesPartialOrExplicitSpecialization(
     SourceLocation Loc, ClassTemplateSpecializationDecl *ClassTemplateSpec) {
@@ -3977,7 +3982,7 @@ static ActionResult<CXXRecordDecl *> getPatternForClassTemplateSpecialization(
         //      specializations, then the use of the class template is
         //      ambiguous and the program is ill-formed.
         for (SmallVectorImpl<MatchResult>::iterator P = Best + 1,
-                                                    PEnd = Matched.end();
+                                                 PEnd = Matched.end();
              P != PEnd; ++P) {
           if (S.getMoreSpecializedPartialSpecialization(
                   P->Partial, Best->Partial, PointOfInstantiation) ==
@@ -3989,7 +3994,7 @@ static ActionResult<CXXRecordDecl *> getPatternForClassTemplateSpecialization(
         // the others.
         bool Ambiguous = false;
         for (SmallVectorImpl<MatchResult>::iterator P = Matched.begin(),
-                                                    PEnd = Matched.end();
+                                                 PEnd = Matched.end();
              P != PEnd; ++P) {
           if (P != Best && S.getMoreSpecializedPartialSpecialization(
                                P->Partial, Best->Partial,
@@ -4009,7 +4014,7 @@ static ActionResult<CXXRecordDecl *> getPatternForClassTemplateSpecialization(
 
           // Print the matching partial specializations.
           for (SmallVectorImpl<MatchResult>::iterator P = Matched.begin(),
-                                                      PEnd = Matched.end();
+                                                   PEnd = Matched.end();
                P != PEnd; ++P)
             S.Diag(P->Partial->getLocation(), diag::note_partial_spec_match)
                 << S.getTemplateArgumentBindingsText(
@@ -4100,10 +4105,11 @@ bool Sema::InstantiateClassTemplateSpecialization(
   return Err;
 }
 
-void Sema::InstantiateClassMembers(
-    SourceLocation PointOfInstantiation, CXXRecordDecl *Instantiation,
-    const MultiLevelTemplateArgumentList &TemplateArgs,
-    TemplateSpecializationKind TSK) {
+void
+Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation,
+                              CXXRecordDecl *Instantiation,
+                        const MultiLevelTemplateArgumentList &TemplateArgs,
+                              TemplateSpecializationKind TSK) {
   // FIXME: We need to notify the ASTMutationListener that we did all of these
   // things, in case we have an explicit instantiation definition in a PCM, a
   // module, or preamble, and the declaration is in an imported AST.
@@ -4172,14 +4178,15 @@ void Sema::InstantiateClassMembers(
 
         MemberSpecializationInfo *MSInfo = Var->getMemberSpecializationInfo();
         assert(MSInfo && "No member specialization information?");
-        if (MSInfo->getTemplateSpecializationKind() ==
-            TSK_ExplicitSpecialization)
+        if (MSInfo->getTemplateSpecializationKind()
+                                                 == TSK_ExplicitSpecialization)
           continue;
 
-        if (CheckSpecializationInstantiationRedecl(
-                PointOfInstantiation, TSK, Var,
-                MSInfo->getTemplateSpecializationKind(),
-                MSInfo->getPointOfInstantiation(), SuppressNew) ||
+        if (CheckSpecializationInstantiationRedecl(PointOfInstantiation, TSK,
+                                                   Var,
+                                        MSInfo->getTemplateSpecializationKind(),
+                                              MSInfo->getPointOfInstantiation(),
+                                                   SuppressNew) ||
             SuppressNew)
           continue;
 
@@ -4215,7 +4222,8 @@ void Sema::InstantiateClassMembers(
       MemberSpecializationInfo *MSInfo = Record->getMemberSpecializationInfo();
       assert(MSInfo && "No member specialization information?");
 
-      if (MSInfo->getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
+      if (MSInfo->getTemplateSpecializationKind()
+                                                == TSK_ExplicitSpecialization)
         continue;
 
       if (Context.getTargetInfo().getTriple().isOSWindows() &&
@@ -4229,10 +4237,11 @@ void Sema::InstantiateClassMembers(
         continue;
       }
 
-      if (CheckSpecializationInstantiationRedecl(
-              PointOfInstantiation, TSK, Record,
-              MSInfo->getTemplateSpecializationKind(),
-              MSInfo->getPointOfInstantiation(), SuppressNew) ||
+      if (CheckSpecializationInstantiationRedecl(PointOfInstantiation, TSK,
+                                                 Record,
+                                        MSInfo->getTemplateSpecializationKind(),
+                                              MSInfo->getPointOfInstantiation(),
+                                                 SuppressNew) ||
           SuppressNew)
         continue;
 
@@ -4255,7 +4264,8 @@ void Sema::InstantiateClassMembers(
           continue;
         }
 
-        InstantiateClass(PointOfInstantiation, Record, Pattern, TemplateArgs,
+        InstantiateClass(PointOfInstantiation, Record, Pattern,
+                         TemplateArgs,
                          TSK);
       } else {
         if (TSK == TSK_ExplicitInstantiationDefinition &&
@@ -4274,13 +4284,14 @@ void Sema::InstantiateClassMembers(
       MemberSpecializationInfo *MSInfo = Enum->getMemberSpecializationInfo();
       assert(MSInfo && "No member specialization information?");
 
-      if (MSInfo->getTemplateSpecializationKind() == TSK_ExplicitSpecialization)
+      if (MSInfo->getTemplateSpecializationKind()
+            == TSK_ExplicitSpecialization)
         continue;
 
       if (CheckSpecializationInstantiationRedecl(
-              PointOfInstantiation, TSK, Enum,
-              MSInfo->getTemplateSpecializationKind(),
-              MSInfo->getPointOfInstantiation(), SuppressNew) ||
+            PointOfInstantiation, TSK, Enum,
+            MSInfo->getTemplateSpecializationKind(),
+            MSInfo->getPointOfInstantiation(), SuppressNew) ||
           SuppressNew)
         continue;
 
@@ -4320,10 +4331,11 @@ void Sema::InstantiateClassMembers(
   }
 }
 
-void Sema::InstantiateClassTemplateSpecializationMembers(
-    SourceLocation PointOfInstantiation,
-    ClassTemplateSpecializationDecl *ClassTemplateSpec,
-    TemplateSpecializationKind TSK) {
+void
+Sema::InstantiateClassTemplateSpecializationMembers(
+                                           SourceLocation PointOfInstantiation,
+                            ClassTemplateSpecializationDecl *ClassTemplateSpec,
+                                               TemplateSpecializationKind TSK) {
   // C++0x [temp.explicit]p7:
   //   An explicit instantiation that names a class template
   //   specialization is an explicit instantion of the same kind
@@ -4333,15 +4345,17 @@ void Sema::InstantiateClassTemplateSpecializationMembers(
   //   containing the explicit instantiation, except as described
   //   below.
   InstantiateClassMembers(PointOfInstantiation, ClassTemplateSpec,
-                          getTemplateInstantiationArgs(ClassTemplateSpec), TSK);
+                          getTemplateInstantiationArgs(ClassTemplateSpec),
+                          TSK);
 }
 
-StmtResult Sema::SubstStmt(Stmt *S,
-                           const MultiLevelTemplateArgumentList &TemplateArgs) {
+StmtResult
+Sema::SubstStmt(Stmt *S, const MultiLevelTemplateArgumentList &TemplateArgs) {
   if (!S)
     return S;
 
-  TemplateInstantiator Instantiator(*this, TemplateArgs, SourceLocation(),
+  TemplateInstantiator Instantiator(*this, TemplateArgs,
+                                    SourceLocation(),
                                     DeclarationName());
   return Instantiator.TransformStmt(S);
 }
@@ -4374,12 +4388,13 @@ bool Sema::SubstTemplateArgumentsInParameterMapping(
   return Instantiator.TransformTemplateArguments(Args.begin(), Args.end(), Out);
 }
 
-ExprResult Sema::SubstExpr(Expr *E,
-                           const MultiLevelTemplateArgumentList &TemplateArgs) {
+ExprResult
+Sema::SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs) {
   if (!E)
     return E;
 
-  TemplateInstantiator Instantiator(*this, TemplateArgs, SourceLocation(),
+  TemplateInstantiator Instantiator(*this, TemplateArgs,
+                                    SourceLocation(),
                                     DeclarationName());
   return Instantiator.TransformExpr(E);
 }
@@ -4557,10 +4572,9 @@ ExprResult Sema::SubstConceptTemplateArguments(
   return Res;
 }
 
-ExprResult
-Sema::SubstInitializer(Expr *Init,
-                       const MultiLevelTemplateArgumentList &TemplateArgs,
-                       bool CXXDirectInit) {
+ExprResult Sema::SubstInitializer(Expr *Init,
+                          const MultiLevelTemplateArgumentList &TemplateArgs,
+                          bool CXXDirectInit) {
   TemplateInstantiator Instantiator(*this, TemplateArgs, SourceLocation(),
                                     DeclarationName());
   return Instantiator.TransformInitializer(Init, CXXDirectInit);
@@ -4572,15 +4586,16 @@ bool Sema::SubstExprs(ArrayRef<Expr *> Exprs, bool IsCall,
   if (Exprs.empty())
     return false;
 
-  TemplateInstantiator Instantiator(*this, TemplateArgs, SourceLocation(),
+  TemplateInstantiator Instantiator(*this, TemplateArgs,
+                                    SourceLocation(),
                                     DeclarationName());
-  return Instantiator.TransformExprs(Exprs.data(), Exprs.size(), IsCall,
-                                     Outputs);
+  return Instantiator.TransformExprs(Exprs.data(), Exprs.size(),
+                                     IsCall, Outputs);
 }
 
-NestedNameSpecifierLoc Sema::SubstNestedNameSpecifierLoc(
-    NestedNameSpecifierLoc NNS,
-    const MultiLevelTemplateArgumentList &TemplateArgs) {
+NestedNameSpecifierLoc
+Sema::SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
+                        const MultiLevelTemplateArgumentList &TemplateArgs) {
   if (!NNS)
     return NestedNameSpecifierLoc();
 
@@ -4589,9 +4604,9 @@ NestedNameSpecifierLoc Sema::SubstNestedNameSpecifierLoc(
   return Instantiator.TransformNestedNameSpecifierLoc(NNS);
 }
 
-DeclarationNameInfo Sema::SubstDeclarationNameInfo(
-    const DeclarationNameInfo &NameInfo,
-    const MultiLevelTemplateArgumentList &TemplateArgs) {
+DeclarationNameInfo
+Sema::SubstDeclarationNameInfo(const DeclarationNameInfo &NameInfo,
+                         const MultiLevelTemplateArgumentList &TemplateArgs) {
   TemplateInstantiator Instantiator(*this, TemplateArgs, NameInfo.getLoc(),
                                     NameInfo.getName());
   return Instantiator.TransformDeclarationNameInfo(NameInfo);
@@ -4739,13 +4754,13 @@ bool LocalInstantiationScope::isLocalPackExpansion(const Decl *D) {
   return false;
 }
 
-void LocalInstantiationScope::SetPartiallySubstitutedPack(
-    NamedDecl *Pack, const TemplateArgument *ExplicitArgs,
-    unsigned NumExplicitArgs) {
+void LocalInstantiationScope::SetPartiallySubstitutedPack(NamedDecl *Pack,
+                                          const TemplateArgument *ExplicitArgs,
+                                                    unsigned NumExplicitArgs) {
   assert((!PartiallySubstitutedPack || PartiallySubstitutedPack == Pack) &&
          "Already have a partially-substituted pack");
-  assert((!PartiallySubstitutedPack ||
-          NumArgsInPartiallySubstitutedPack == NumExplicitArgs) &&
+  assert((!PartiallySubstitutedPack
+          || NumArgsInPartiallySubstitutedPack == NumExplicitArgs) &&
          "Wrong number of arguments in partially-substituted pack");
   PartiallySubstitutedPack = Pack;
   ArgsInPartiallySubstitutedPack = ExplicitArgs;
@@ -4753,7 +4768,8 @@ void LocalInstantiationScope::SetPartiallySubstitutedPack(
 }
 
 NamedDecl *LocalInstantiationScope::getPartiallySubstitutedPack(
-    const TemplateArgument **ExplicitArgs, unsigned *NumExplicitArgs) const {
+                                         const TemplateArgument **ExplicitArgs,
+                                              unsigned *NumExplicitArgs) const {
   if (ExplicitArgs)
     *ExplicitArgs = nullptr;
   if (NumExplicitArgs)

>From 8a4dc74e04c0f9bbb94018e9b7748b7f064cb1f8 Mon Sep 17 00:00:00 2001
From: changkhothuychung <nhat7203 at gmail.com>
Date: Mon, 13 Apr 2026 17:53:33 -0400
Subject: [PATCH 22/23] cleanup

---
 clang/lib/Sema/SemaTemplate.cpp | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index aa72cb8fa2895..1868b0123cfa4 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -8083,6 +8083,15 @@ static Expr *BuildExpressionFromIntegralTemplateArgumentValue(
   return E;
 }
 
+/// Construct a new reflect expression that refers to the given
+/// entity with the given source-location of the reflection operator.
+static ExprResult BuildExpressionFromReflection(Sema &S, const APValue &RV,
+                                                SourceLocation CaretCaretLoc) {
+  return CXXReflectExpr::Create(
+      S.Context, CaretCaretLoc,
+      static_cast<const TypeSourceInfo *>((RV.getReflectionOpaqueOperand())));
+}
+
 static Expr *BuildExpressionFromNonTypeTemplateArgumentValue(
     Sema &S, QualType T, const APValue &Val, SourceLocation Loc) {
   auto MakeInitList = [&](ArrayRef<Expr *> Elts) -> Expr * {
@@ -8147,7 +8156,7 @@ static Expr *BuildExpressionFromNonTypeTemplateArgumentValue(
   case APValue::Indeterminate:
     llvm_unreachable("Unexpected APValue kind.");
   case APValue::LValue:
-  case APValue::MemberPointer:
+  case APValue::MemberPointer: {
     // There isn't necessarily a valid equivalent source-level syntax for
     // these; in particular, a naive lowering might violate access control.
     // So for now we lower to a ConstantExpr holding the value, wrapped around
@@ -8161,6 +8170,9 @@ static Expr *BuildExpressionFromNonTypeTemplateArgumentValue(
     auto *OVE = new (S.Context) OpaqueValueExpr(Loc, T, VK);
     return ConstantExpr::Create(S.Context, OVE, Val);
   }
+  case APValue::Reflection:
+    return BuildExpressionFromReflection(S, Val, Loc).get();
+  }
   llvm_unreachable("Unhandled APValue::ValueKind enum");
 }
 

>From b1bc173442c300348b1ebcfb45046b8ea22bc2a5 Mon Sep 17 00:00:00 2001
From: changkhothuychung <nhat7203 at gmail.com>
Date: Mon, 13 Apr 2026 17:54:16 -0400
Subject: [PATCH 23/23] use type for sizeof/alignof instead of expression

---
 clang/test/Sema/reflection-meta-info.pass.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/test/Sema/reflection-meta-info.pass.cpp b/clang/test/Sema/reflection-meta-info.pass.cpp
index 62922d84e057f..7be1d46924a78 100644
--- a/clang/test/Sema/reflection-meta-info.pass.cpp
+++ b/clang/test/Sema/reflection-meta-info.pass.cpp
@@ -45,9 +45,9 @@ consteval void test()
     static_assert(f2<r>() == ^^int);
     static_assert(f2<^^float>() != ^^int);
 
-    static_assert(sizeof(^^int) == sizeof(^^float));
-    static_assert(sizeof(^^int) == 8);
-    static_assert(alignof(^^int) == 1);
+    static_assert(sizeof(info) == 8);
+    static_assert(alignof(info) == 1);
+    static_assert(sizeof(decltype(^^int)) == sizeof(decltype(^^float)));
 
 
     static_assert(^^int == ^^int);



More information about the cfe-commits mailing list