Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Feb 2017 21:35:01 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org
Subject:   svn commit: r313058 - in vendor/clang/dist: include/clang/AST include/clang/Basic include/clang/Sema lib/AST lib/CodeGen lib/Sema test/CodeGenCXX test/CodeGenObjC test/Sema test/Sema/Inputs test/Se...
Message-ID:  <201702012135.v11LZ1XP099890@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Wed Feb  1 21:35:00 2017
New Revision: 313058
URL: https://svnweb.freebsd.org/changeset/base/313058

Log:
  Vendor import of clang release_40 branch r293807:
  https://llvm.org/svn/llvm-project/cfe/branches/release_40@293807

Added:
  vendor/clang/dist/test/CodeGenObjC/block-ptr-type-crash.m
  vendor/clang/dist/test/Sema/Inputs/diagnose-if-warn-system-header.h   (contents, props changed)
Modified:
  vendor/clang/dist/include/clang/AST/Type.h
  vendor/clang/dist/include/clang/Basic/DiagnosticSemaKinds.td
  vendor/clang/dist/include/clang/Sema/Overload.h
  vendor/clang/dist/include/clang/Sema/Sema.h
  vendor/clang/dist/lib/AST/ExprConstant.cpp
  vendor/clang/dist/lib/CodeGen/CodeGenTypes.cpp
  vendor/clang/dist/lib/Sema/SemaChecking.cpp
  vendor/clang/dist/lib/Sema/SemaExpr.cpp
  vendor/clang/dist/lib/Sema/SemaExprCXX.cpp
  vendor/clang/dist/lib/Sema/SemaLookup.cpp
  vendor/clang/dist/lib/Sema/SemaOverload.cpp
  vendor/clang/dist/lib/Sema/SemaTemplateInstantiateDecl.cpp
  vendor/clang/dist/lib/Sema/TreeTransform.h
  vendor/clang/dist/test/CodeGenCXX/microsoft-abi-default-cc.cpp
  vendor/clang/dist/test/CodeGenObjC/encode-test.m
  vendor/clang/dist/test/Sema/diagnose_if.c
  vendor/clang/dist/test/SemaCXX/destructor.cpp
  vendor/clang/dist/test/SemaCXX/diagnose_if.cpp

Modified: vendor/clang/dist/include/clang/AST/Type.h
==============================================================================
--- vendor/clang/dist/include/clang/AST/Type.h	Wed Feb  1 21:34:55 2017	(r313057)
+++ vendor/clang/dist/include/clang/AST/Type.h	Wed Feb  1 21:35:00 2017	(r313058)
@@ -3827,13 +3827,13 @@ private:
 
   friend class ASTContext; // creates these
 
-  AttributedType(QualType canon, Kind attrKind,
-                 QualType modified, QualType equivalent)
-    : Type(Attributed, canon, canon->isDependentType(),
-           canon->isInstantiationDependentType(),
-           canon->isVariablyModifiedType(),
-           canon->containsUnexpandedParameterPack()),
-      ModifiedType(modified), EquivalentType(equivalent) {
+  AttributedType(QualType canon, Kind attrKind, QualType modified,
+                 QualType equivalent)
+      : Type(Attributed, canon, equivalent->isDependentType(),
+             equivalent->isInstantiationDependentType(),
+             equivalent->isVariablyModifiedType(),
+             equivalent->containsUnexpandedParameterPack()),
+        ModifiedType(modified), EquivalentType(equivalent) {
     AttributedTypeBits.AttrKind = attrKind;
   }
 

Modified: vendor/clang/dist/include/clang/Basic/DiagnosticSemaKinds.td
==============================================================================
--- vendor/clang/dist/include/clang/Basic/DiagnosticSemaKinds.td	Wed Feb  1 21:34:55 2017	(r313057)
+++ vendor/clang/dist/include/clang/Basic/DiagnosticSemaKinds.td	Wed Feb  1 21:35:00 2017	(r313058)
@@ -3373,7 +3373,8 @@ def note_ovl_candidate_has_pass_object_s
     "candidate address cannot be taken because parameter %0 has "
     "pass_object_size attribute">;
 def err_diagnose_if_succeeded : Error<"%0">;
-def warn_diagnose_if_succeeded : Warning<"%0">, InGroup<UserDefinedWarnings>;
+def warn_diagnose_if_succeeded : Warning<"%0">, InGroup<UserDefinedWarnings>,
+    ShowInSystemHeader;
 def note_ovl_candidate_disabled_by_function_cond_attr : Note<
     "candidate disabled: %0">;
 def note_ovl_candidate_disabled_by_extension : Note<

Modified: vendor/clang/dist/include/clang/Sema/Overload.h
==============================================================================
--- vendor/clang/dist/include/clang/Sema/Overload.h	Wed Feb  1 21:34:55 2017	(r313057)
+++ vendor/clang/dist/include/clang/Sema/Overload.h	Wed Feb  1 21:35:00 2017	(r313058)
@@ -675,26 +675,6 @@ namespace clang {
     /// to be used while performing partial ordering of function templates.
     unsigned ExplicitCallArguments;
 
-    /// The number of diagnose_if attributes that this overload triggered.
-    /// If any of the triggered attributes are errors, this won't count
-    /// diagnose_if warnings.
-    unsigned NumTriggeredDiagnoseIfs = 0;
-
-    /// Basically a TinyPtrVector<DiagnoseIfAttr *> that doesn't own the vector:
-    /// If NumTriggeredDiagnoseIfs is 0 or 1, this is a DiagnoseIfAttr *,
-    /// otherwise it's a pointer to an array of `NumTriggeredDiagnoseIfs`
-    /// DiagnoseIfAttr *s.
-    llvm::PointerUnion<DiagnoseIfAttr *, DiagnoseIfAttr **> DiagnoseIfInfo;
-
-    /// Gets an ArrayRef for the data at DiagnoseIfInfo. Note that this may give
-    /// you a pointer into DiagnoseIfInfo.
-    ArrayRef<DiagnoseIfAttr *> getDiagnoseIfInfo() const {
-      auto *Ptr = NumTriggeredDiagnoseIfs <= 1
-                      ? DiagnoseIfInfo.getAddrOfPtr1()
-                      : DiagnoseIfInfo.get<DiagnoseIfAttr **>();
-      return {Ptr, NumTriggeredDiagnoseIfs};
-    }
-
     union {
       DeductionFailureInfo DeductionFailure;
       
@@ -759,9 +739,8 @@ namespace clang {
     SmallVector<OverloadCandidate, 16> Candidates;
     llvm::SmallPtrSet<Decl *, 16> Functions;
 
-    // Allocator for ConversionSequenceLists and DiagnoseIfAttr* arrays.
-    // We store the first few of each of these inline to avoid allocation for
-    // small sets.
+    // Allocator for ConversionSequenceLists. We store the first few of these
+    // inline to avoid allocation for small sets.
     llvm::BumpPtrAllocator SlabAllocator;
 
     SourceLocation Loc;
@@ -776,6 +755,8 @@ namespace clang {
     /// from the slab allocator.
     /// FIXME: It would probably be nice to have a SmallBumpPtrAllocator
     /// instead.
+    /// FIXME: Now that this only allocates ImplicitConversionSequences, do we
+    /// want to un-generalize this?
     template <typename T>
     T *slabAllocate(unsigned N) {
       // It's simpler if this doesn't need to consider alignment.
@@ -809,11 +790,6 @@ namespace clang {
     SourceLocation getLocation() const { return Loc; }
     CandidateSetKind getKind() const { return Kind; }
 
-    /// Make a DiagnoseIfAttr* array in a block of memory that will live for
-    /// as long as this OverloadCandidateSet. Returns a pointer to the start
-    /// of that array.
-    DiagnoseIfAttr **addDiagnoseIfComplaints(ArrayRef<DiagnoseIfAttr *> CA);
-
     /// \brief Determine when this overload candidate will be new to the
     /// overload set.
     bool isNewCandidate(Decl *F) {

Modified: vendor/clang/dist/include/clang/Sema/Sema.h
==============================================================================
--- vendor/clang/dist/include/clang/Sema/Sema.h	Wed Feb  1 21:34:55 2017	(r313057)
+++ vendor/clang/dist/include/clang/Sema/Sema.h	Wed Feb  1 21:35:00 2017	(r313058)
@@ -2532,14 +2532,14 @@ public:
   void AddMethodCandidate(DeclAccessPair FoundDecl,
                           QualType ObjectType,
                           Expr::Classification ObjectClassification,
-                          Expr *ThisArg, ArrayRef<Expr *> Args,
+                          ArrayRef<Expr *> Args,
                           OverloadCandidateSet& CandidateSet,
                           bool SuppressUserConversion = false);
   void AddMethodCandidate(CXXMethodDecl *Method,
                           DeclAccessPair FoundDecl,
                           CXXRecordDecl *ActingContext, QualType ObjectType,
                           Expr::Classification ObjectClassification,
-                          Expr *ThisArg, ArrayRef<Expr *> Args,
+                          ArrayRef<Expr *> Args,
                           OverloadCandidateSet& CandidateSet,
                           bool SuppressUserConversions = false,
                           bool PartialOverloading = false,
@@ -2550,7 +2550,6 @@ public:
                                  TemplateArgumentListInfo *ExplicitTemplateArgs,
                                   QualType ObjectType,
                                   Expr::Classification ObjectClassification,
-                                  Expr *ThisArg,
                                   ArrayRef<Expr *> Args,
                                   OverloadCandidateSet& CandidateSet,
                                   bool SuppressUserConversions = false,
@@ -2624,37 +2623,27 @@ public:
   EnableIfAttr *CheckEnableIf(FunctionDecl *Function, ArrayRef<Expr *> Args,
                               bool MissingImplicitThis = false);
 
-  /// Check the diagnose_if attributes on the given function. Returns the
-  /// first succesful fatal attribute, or null if calling Function(Args) isn't
-  /// an error.
-  ///
-  /// This only considers ArgDependent DiagnoseIfAttrs.
-  ///
-  /// This will populate Nonfatal with all non-error DiagnoseIfAttrs that
-  /// succeed. If this function returns non-null, the contents of Nonfatal are
-  /// unspecified.
-  DiagnoseIfAttr *
-  checkArgDependentDiagnoseIf(FunctionDecl *Function, ArrayRef<Expr *> Args,
-                              SmallVectorImpl<DiagnoseIfAttr *> &Nonfatal,
-                              bool MissingImplicitThis = false,
-                              Expr *ThisArg = nullptr);
-
-  /// Check the diagnose_if expressions on the given function. Returns the
-  /// first succesful fatal attribute, or null if using Function isn't
-  /// an error.
-  ///
-  /// This ignores all ArgDependent DiagnoseIfAttrs.
-  ///
-  /// This will populate Nonfatal with all non-error DiagnoseIfAttrs that
-  /// succeed. If this function returns non-null, the contents of Nonfatal are
-  /// unspecified.
-  DiagnoseIfAttr *
-  checkArgIndependentDiagnoseIf(FunctionDecl *Function,
-                                SmallVectorImpl<DiagnoseIfAttr *> &Nonfatal);
-
-  /// Emits the diagnostic contained in the given DiagnoseIfAttr at Loc. Also
-  /// emits a note about the location of said attribute.
-  void emitDiagnoseIfDiagnostic(SourceLocation Loc, const DiagnoseIfAttr *DIA);
+  /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
+  /// non-ArgDependent DiagnoseIfAttrs.
+  ///
+  /// Argument-dependent diagnose_if attributes should be checked each time a
+  /// function is used as a direct callee of a function call.
+  ///
+  /// Returns true if any errors were emitted.
+  bool diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function,
+                                           const Expr *ThisArg,
+                                           ArrayRef<const Expr *> Args,
+                                           SourceLocation Loc);
+
+  /// Emit diagnostics for the diagnose_if attributes on Function, ignoring any
+  /// ArgDependent DiagnoseIfAttrs.
+  ///
+  /// Argument-independent diagnose_if attributes should be checked on every use
+  /// of a function.
+  ///
+  /// Returns true if any errors were emitted.
+  bool diagnoseArgIndependentDiagnoseIfAttrs(const FunctionDecl *Function,
+                                             SourceLocation Loc);
 
   /// Returns whether the given function's address can be taken or not,
   /// optionally emitting a diagnostic if the address can't be taken.
@@ -9914,8 +9903,8 @@ private:
                             SourceLocation Loc);
 
   void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
-                 ArrayRef<const Expr *> Args, bool IsMemberFunction,
-                 SourceLocation Loc, SourceRange Range,
+                 const Expr *ThisArg, ArrayRef<const Expr *> Args,
+                 bool IsMemberFunction, SourceLocation Loc, SourceRange Range,
                  VariadicCallType CallType);
 
   bool CheckObjCString(Expr *Arg);

Modified: vendor/clang/dist/lib/AST/ExprConstant.cpp
==============================================================================
--- vendor/clang/dist/lib/AST/ExprConstant.cpp	Wed Feb  1 21:34:55 2017	(r313057)
+++ vendor/clang/dist/lib/AST/ExprConstant.cpp	Wed Feb  1 21:35:00 2017	(r313058)
@@ -2362,7 +2362,14 @@ static unsigned getBaseIndex(const CXXRe
 /// Extract the value of a character from a string literal.
 static APSInt extractStringLiteralCharacter(EvalInfo &Info, const Expr *Lit,
                                             uint64_t Index) {
-  // FIXME: Support ObjCEncodeExpr, MakeStringConstant
+  // FIXME: Support MakeStringConstant
+  if (const auto *ObjCEnc = dyn_cast<ObjCEncodeExpr>(Lit)) {
+    std::string Str;
+    Info.Ctx.getObjCEncodingForType(ObjCEnc->getEncodedType(), Str);
+    assert(Index <= Str.size() && "Index too large");
+    return APSInt::getUnsigned(Str.c_str()[Index]);
+  }
+
   if (auto PE = dyn_cast<PredefinedExpr>(Lit))
     Lit = PE->getFunctionName();
   const StringLiteral *S = cast<StringLiteral>(Lit);

Modified: vendor/clang/dist/lib/CodeGen/CodeGenTypes.cpp
==============================================================================
--- vendor/clang/dist/lib/CodeGen/CodeGenTypes.cpp	Wed Feb  1 21:34:55 2017	(r313057)
+++ vendor/clang/dist/lib/CodeGen/CodeGenTypes.cpp	Wed Feb  1 21:35:00 2017	(r313058)
@@ -737,7 +737,7 @@ CodeGenTypes::getCGRecordLayout(const Re
 }
 
 bool CodeGenTypes::isPointerZeroInitializable(QualType T) {
-  assert (T->isAnyPointerType() && "Invalid type");
+  assert((T->isAnyPointerType() || T->isBlockPointerType()) && "Invalid type");
   return isZeroInitializable(T);
 }
 

Modified: vendor/clang/dist/lib/Sema/SemaChecking.cpp
==============================================================================
--- vendor/clang/dist/lib/Sema/SemaChecking.cpp	Wed Feb  1 21:34:55 2017	(r313057)
+++ vendor/clang/dist/lib/Sema/SemaChecking.cpp	Wed Feb  1 21:35:00 2017	(r313058)
@@ -2426,11 +2426,12 @@ static void CheckNonNullArguments(Sema &
 }
 
 /// Handles the checks for format strings, non-POD arguments to vararg
-/// functions, and NULL arguments passed to non-NULL parameters.
+/// functions, NULL arguments passed to non-NULL parameters, and diagnose_if
+/// attributes.
 void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
-                     ArrayRef<const Expr *> Args, bool IsMemberFunction,
-                     SourceLocation Loc, SourceRange Range,
-                     VariadicCallType CallType) {
+                     const Expr *ThisArg, ArrayRef<const Expr *> Args,
+                     bool IsMemberFunction, SourceLocation Loc,
+                     SourceRange Range, VariadicCallType CallType) {
   // FIXME: We should check as much as we can in the template definition.
   if (CurContext->isDependentContext())
     return;
@@ -2477,6 +2478,9 @@ void Sema::checkCall(NamedDecl *FDecl, c
         CheckArgumentWithTypeTag(I, Args.data());
     }
   }
+
+  if (FD)
+    diagnoseArgDependentDiagnoseIfAttrs(FD, ThisArg, Args, Loc);
 }
 
 /// CheckConstructorCall - Check a constructor call for correctness and safety
@@ -2487,8 +2491,8 @@ void Sema::CheckConstructorCall(Function
                                 SourceLocation Loc) {
   VariadicCallType CallType =
     Proto->isVariadic() ? VariadicConstructor : VariadicDoesNotApply;
-  checkCall(FDecl, Proto, Args, /*IsMemberFunction=*/true, Loc, SourceRange(), 
-            CallType);
+  checkCall(FDecl, Proto, /*ThisArg=*/nullptr, Args, /*IsMemberFunction=*/true,
+            Loc, SourceRange(), CallType);
 }
 
 /// CheckFunctionCall - Check a direct function call for various correctness
@@ -2503,14 +2507,20 @@ bool Sema::CheckFunctionCall(FunctionDec
                                                   TheCall->getCallee());
   Expr** Args = TheCall->getArgs();
   unsigned NumArgs = TheCall->getNumArgs();
+
+  Expr *ImplicitThis = nullptr;
   if (IsMemberOperatorCall) {
     // If this is a call to a member operator, hide the first argument
     // from checkCall.
     // FIXME: Our choice of AST representation here is less than ideal.
+    ImplicitThis = Args[0];
     ++Args;
     --NumArgs;
-  }
-  checkCall(FDecl, Proto, llvm::makeArrayRef(Args, NumArgs), 
+  } else if (IsMemberFunction)
+    ImplicitThis =
+        cast<CXXMemberCallExpr>(TheCall)->getImplicitObjectArgument();
+
+  checkCall(FDecl, Proto, ImplicitThis, llvm::makeArrayRef(Args, NumArgs),
             IsMemberFunction, TheCall->getRParenLoc(),
             TheCall->getCallee()->getSourceRange(), CallType);
 
@@ -2546,8 +2556,8 @@ bool Sema::CheckObjCMethodCall(ObjCMetho
   VariadicCallType CallType =
       Method->isVariadic() ? VariadicMethod : VariadicDoesNotApply;
 
-  checkCall(Method, nullptr, Args,
-            /*IsMemberFunction=*/false, lbrac, Method->getSourceRange(), 
+  checkCall(Method, nullptr, /*ThisArg=*/nullptr, Args,
+            /*IsMemberFunction=*/false, lbrac, Method->getSourceRange(),
             CallType);
 
   return false;
@@ -2576,7 +2586,7 @@ bool Sema::CheckPointerCall(NamedDecl *N
     CallType = VariadicFunction;
   }
 
-  checkCall(NDecl, Proto,
+  checkCall(NDecl, Proto, /*ThisArg=*/nullptr,
             llvm::makeArrayRef(TheCall->getArgs(), TheCall->getNumArgs()),
             /*IsMemberFunction=*/false, TheCall->getRParenLoc(),
             TheCall->getCallee()->getSourceRange(), CallType);
@@ -2589,7 +2599,7 @@ bool Sema::CheckPointerCall(NamedDecl *N
 bool Sema::CheckOtherCall(CallExpr *TheCall, const FunctionProtoType *Proto) {
   VariadicCallType CallType = getVariadicCallType(/*FDecl=*/nullptr, Proto,
                                                   TheCall->getCallee());
-  checkCall(/*FDecl=*/nullptr, Proto,
+  checkCall(/*FDecl=*/nullptr, Proto, /*ThisArg=*/nullptr,
             llvm::makeArrayRef(TheCall->getArgs(), TheCall->getNumArgs()),
             /*IsMemberFunction=*/false, TheCall->getRParenLoc(),
             TheCall->getCallee()->getSourceRange(), CallType);

Modified: vendor/clang/dist/lib/Sema/SemaExpr.cpp
==============================================================================
--- vendor/clang/dist/lib/Sema/SemaExpr.cpp	Wed Feb  1 21:34:55 2017	(r313057)
+++ vendor/clang/dist/lib/Sema/SemaExpr.cpp	Wed Feb  1 21:35:00 2017	(r313058)
@@ -342,7 +342,6 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *
   }
 
   // See if this is a deleted function.
-  SmallVector<DiagnoseIfAttr *, 4> DiagnoseIfWarnings;
   if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
     if (FD->isDeleted()) {
       auto *Ctor = dyn_cast<CXXConstructorDecl>(FD);
@@ -365,11 +364,8 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *
     if (getLangOpts().CUDA && !CheckCUDACall(Loc, FD))
       return true;
 
-    if (const DiagnoseIfAttr *A =
-            checkArgIndependentDiagnoseIf(FD, DiagnoseIfWarnings)) {
-      emitDiagnoseIfDiagnostic(Loc, A);
+    if (diagnoseArgIndependentDiagnoseIfAttrs(FD, Loc))
       return true;
-    }
   }
 
   // [OpenMP 4.0], 2.15 declare reduction Directive, Restrictions
@@ -385,9 +381,6 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *
     return true;
   }
 
-  for (const auto *W : DiagnoseIfWarnings)
-    emitDiagnoseIfDiagnostic(Loc, W);
-
   DiagnoseAvailabilityOfDecl(*this, D, Loc, UnknownObjCClass,
                              ObjCPropertyAccess);
 
@@ -5189,16 +5182,6 @@ static void checkDirectCallValidity(Sema
         << Attr->getCond()->getSourceRange() << Attr->getMessage();
     return;
   }
-
-  SmallVector<DiagnoseIfAttr *, 4> Nonfatal;
-  if (const DiagnoseIfAttr *Attr = S.checkArgDependentDiagnoseIf(
-          Callee, ArgExprs, Nonfatal, /*MissingImplicitThis=*/true)) {
-    S.emitDiagnoseIfDiagnostic(Fn->getLocStart(), Attr);
-    return;
-  }
-
-  for (const auto *W : Nonfatal)
-    S.emitDiagnoseIfDiagnostic(Fn->getLocStart(), W);
 }
 
 /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.

Modified: vendor/clang/dist/lib/Sema/SemaExprCXX.cpp
==============================================================================
--- vendor/clang/dist/lib/Sema/SemaExprCXX.cpp	Wed Feb  1 21:34:55 2017	(r313057)
+++ vendor/clang/dist/lib/Sema/SemaExprCXX.cpp	Wed Feb  1 21:35:00 2017	(r313058)
@@ -6712,6 +6712,11 @@ ExprResult Sema::BuildCXXMemberCallExpr(
   CXXMemberCallExpr *CE =
     new (Context) CXXMemberCallExpr(Context, ME, None, ResultType, VK,
                                     Exp.get()->getLocEnd());
+
+  if (CheckFunctionCall(Method, CE,
+                        Method->getType()->castAs<FunctionProtoType>()))
+    return ExprError();
+
   return CE;
 }
 

Modified: vendor/clang/dist/lib/Sema/SemaLookup.cpp
==============================================================================
--- vendor/clang/dist/lib/Sema/SemaLookup.cpp	Wed Feb  1 21:34:55 2017	(r313057)
+++ vendor/clang/dist/lib/Sema/SemaLookup.cpp	Wed Feb  1 21:35:00 2017	(r313058)
@@ -2960,7 +2960,6 @@ Sema::SpecialMemberOverloadResult *Sema:
     if (CXXMethodDecl *M = dyn_cast<CXXMethodDecl>(Cand->getUnderlyingDecl())) {
       if (SM == CXXCopyAssignment || SM == CXXMoveAssignment)
         AddMethodCandidate(M, Cand, RD, ThisTy, Classification,
-                           /*ThisArg=*/nullptr,
                            llvm::makeArrayRef(&Arg, NumArgs), OCS, true);
       else if (CtorInfo)
         AddOverloadCandidate(CtorInfo.Constructor, CtorInfo.FoundDecl,
@@ -2973,7 +2972,7 @@ Sema::SpecialMemberOverloadResult *Sema:
       if (SM == CXXCopyAssignment || SM == CXXMoveAssignment)
         AddMethodTemplateCandidate(
             Tmpl, Cand, RD, nullptr, ThisTy, Classification,
-            /*ThisArg=*/nullptr, llvm::makeArrayRef(&Arg, NumArgs), OCS, true);
+            llvm::makeArrayRef(&Arg, NumArgs), OCS, true);
       else if (CtorInfo)
         AddTemplateOverloadCandidate(
             CtorInfo.ConstructorTmpl, CtorInfo.FoundDecl, nullptr,

Modified: vendor/clang/dist/lib/Sema/SemaOverload.cpp
==============================================================================
--- vendor/clang/dist/lib/Sema/SemaOverload.cpp	Wed Feb  1 21:34:55 2017	(r313057)
+++ vendor/clang/dist/lib/Sema/SemaOverload.cpp	Wed Feb  1 21:35:00 2017	(r313058)
@@ -839,20 +839,12 @@ void OverloadCandidateSet::destroyCandid
 
 void OverloadCandidateSet::clear() {
   destroyCandidates();
-  // DiagnoseIfAttrs are just pointers, so we don't need to destroy them.
   SlabAllocator.Reset();
   NumInlineBytesUsed = 0;
   Candidates.clear();
   Functions.clear();
 }
 
-DiagnoseIfAttr **
-OverloadCandidateSet::addDiagnoseIfComplaints(ArrayRef<DiagnoseIfAttr *> CA) {
-  auto *DIA = slabAllocate<DiagnoseIfAttr *>(CA.size());
-  std::uninitialized_copy(CA.begin(), CA.end(), DIA);
-  return DIA;
-}
-
 namespace {
   class UnbridgedCastsSet {
     struct Entry {
@@ -5831,28 +5823,6 @@ static bool IsAcceptableNonMemberOperato
   return false;
 }
 
-static void initDiagnoseIfComplaint(Sema &S, OverloadCandidateSet &CandidateSet,
-                                    OverloadCandidate &Candidate,
-                                    FunctionDecl *Function,
-                                    ArrayRef<Expr *> Args,
-                                    bool MissingImplicitThis = false,
-                                    Expr *ExplicitThis = nullptr) {
-  SmallVector<DiagnoseIfAttr *, 8> Results;
-  if (DiagnoseIfAttr *DIA = S.checkArgDependentDiagnoseIf(
-          Function, Args, Results, MissingImplicitThis, ExplicitThis)) {
-    Results.clear();
-    Results.push_back(DIA);
-  }
-
-  Candidate.NumTriggeredDiagnoseIfs = Results.size();
-  if (Results.empty())
-    Candidate.DiagnoseIfInfo = nullptr;
-  else if (Results.size() == 1)
-    Candidate.DiagnoseIfInfo = Results[0];
-  else
-    Candidate.DiagnoseIfInfo = CandidateSet.addDiagnoseIfComplaints(Results);
-}
-
 /// AddOverloadCandidate - Adds the given function to the set of
 /// candidate functions, using the given function call arguments.  If
 /// @p SuppressUserConversions, then don't allow user-defined
@@ -5886,10 +5856,9 @@ Sema::AddOverloadCandidate(FunctionDecl 
       // object argument (C++ [over.call.func]p3), and the acting context
       // is irrelevant.
       AddMethodCandidate(Method, FoundDecl, Method->getParent(), QualType(),
-                         Expr::Classification::makeSimpleLValue(),
-                         /*ThisArg=*/nullptr, Args, CandidateSet,
-                         SuppressUserConversions, PartialOverloading,
-                         EarlyConversions);
+                         Expr::Classification::makeSimpleLValue(), Args,
+                         CandidateSet, SuppressUserConversions,
+                         PartialOverloading, EarlyConversions);
       return;
     }
     // We treat a constructor like a non-member function, since its object
@@ -6050,8 +6019,6 @@ Sema::AddOverloadCandidate(FunctionDecl 
     Candidate.FailureKind = ovl_fail_ext_disabled;
     return;
   }
-
-  initDiagnoseIfComplaint(*this, CandidateSet, Candidate, Function, Args);
 }
 
 ObjCMethodDecl *
@@ -6260,85 +6227,73 @@ EnableIfAttr *Sema::CheckEnableIf(Functi
   return nullptr;
 }
 
-static bool gatherDiagnoseIfAttrs(FunctionDecl *Function, bool ArgDependent,
-                                  SmallVectorImpl<DiagnoseIfAttr *> &Errors,
-                                  SmallVectorImpl<DiagnoseIfAttr *> &Nonfatal) {
-  for (auto *DIA : Function->specific_attrs<DiagnoseIfAttr>())
-    if (ArgDependent == DIA->getArgDependent()) {
-      if (DIA->isError())
-        Errors.push_back(DIA);
-      else
-        Nonfatal.push_back(DIA);
-    }
-
-  return !Errors.empty() || !Nonfatal.empty();
-}
-
 template <typename CheckFn>
-static DiagnoseIfAttr *
-checkDiagnoseIfAttrsWith(const SmallVectorImpl<DiagnoseIfAttr *> &Errors,
-                         SmallVectorImpl<DiagnoseIfAttr *> &Nonfatal,
-                         CheckFn &&IsSuccessful) {
+static bool diagnoseDiagnoseIfAttrsWith(Sema &S, const FunctionDecl *FD,
+                                        bool ArgDependent, SourceLocation Loc,
+                                        CheckFn &&IsSuccessful) {
+  SmallVector<const DiagnoseIfAttr *, 8> Attrs;
+  for (const auto *DIA : FD->specific_attrs<DiagnoseIfAttr>()) {
+    if (ArgDependent == DIA->getArgDependent())
+      Attrs.push_back(DIA);
+  }
+
+  // Common case: No diagnose_if attributes, so we can quit early.
+  if (Attrs.empty())
+    return false;
+
+  auto WarningBegin = std::stable_partition(
+      Attrs.begin(), Attrs.end(),
+      [](const DiagnoseIfAttr *DIA) { return DIA->isError(); });
+
   // Note that diagnose_if attributes are late-parsed, so they appear in the
   // correct order (unlike enable_if attributes).
-  auto ErrAttr = llvm::find_if(Errors, IsSuccessful);
-  if (ErrAttr != Errors.end())
-    return *ErrAttr;
-
-  llvm::erase_if(Nonfatal, [&](DiagnoseIfAttr *A) { return !IsSuccessful(A); });
-  return nullptr;
-}
-
-DiagnoseIfAttr *
-Sema::checkArgDependentDiagnoseIf(FunctionDecl *Function, ArrayRef<Expr *> Args,
-                                  SmallVectorImpl<DiagnoseIfAttr *> &Nonfatal,
-                                  bool MissingImplicitThis,
-                                  Expr *ThisArg) {
-  SmallVector<DiagnoseIfAttr *, 4> Errors;
-  if (!gatherDiagnoseIfAttrs(Function, /*ArgDependent=*/true, Errors, Nonfatal))
-    return nullptr;
+  auto ErrAttr = llvm::find_if(llvm::make_range(Attrs.begin(), WarningBegin),
+                               IsSuccessful);
+  if (ErrAttr != WarningBegin) {
+    const DiagnoseIfAttr *DIA = *ErrAttr;
+    S.Diag(Loc, diag::err_diagnose_if_succeeded) << DIA->getMessage();
+    S.Diag(DIA->getLocation(), diag::note_from_diagnose_if)
+        << DIA->getParent() << DIA->getCond()->getSourceRange();
+    return true;
+  }
 
-  SFINAETrap Trap(*this);
-  SmallVector<Expr *, 16> ConvertedArgs;
-  Expr *ConvertedThis;
-  if (!convertArgsForAvailabilityChecks(*this, Function, ThisArg, Args, Trap,
-                                        MissingImplicitThis, ConvertedThis,
-                                        ConvertedArgs))
-    return nullptr;
+  for (const auto *DIA : llvm::make_range(WarningBegin, Attrs.end()))
+    if (IsSuccessful(DIA)) {
+      S.Diag(Loc, diag::warn_diagnose_if_succeeded) << DIA->getMessage();
+      S.Diag(DIA->getLocation(), diag::note_from_diagnose_if)
+          << DIA->getParent() << DIA->getCond()->getSourceRange();
+    }
 
-  return checkDiagnoseIfAttrsWith(Errors, Nonfatal, [&](DiagnoseIfAttr *DIA) {
-    APValue Result;
-    // It's sane to use the same ConvertedArgs for any redecl of this function,
-    // since 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, DIA->getParent(), ConvertedArgs, ConvertedThis))
-      return false;
-    return Result.isInt() && Result.getInt().getBoolValue();
-  });
+  return false;
 }
 
-DiagnoseIfAttr *Sema::checkArgIndependentDiagnoseIf(
-    FunctionDecl *Function, SmallVectorImpl<DiagnoseIfAttr *> &Nonfatal) {
-  SmallVector<DiagnoseIfAttr *, 4> Errors;
-  if (!gatherDiagnoseIfAttrs(Function, /*ArgDependent=*/false, Errors,
-                             Nonfatal))
-    return nullptr;
-
-  return checkDiagnoseIfAttrsWith(Errors, Nonfatal, [&](DiagnoseIfAttr *DIA) {
-    bool Result;
-    return DIA->getCond()->EvaluateAsBooleanCondition(Result, Context) &&
-           Result;
-  });
+bool Sema::diagnoseArgDependentDiagnoseIfAttrs(const FunctionDecl *Function,
+                                               const Expr *ThisArg,
+                                               ArrayRef<const Expr *> Args,
+                                               SourceLocation Loc) {
+  return diagnoseDiagnoseIfAttrsWith(
+      *this, Function, /*ArgDependent=*/true, Loc,
+      [&](const DiagnoseIfAttr *DIA) {
+        APValue Result;
+        // It's sane to use the same Args for any redecl of this function, since
+        // 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, DIA->getParent(), Args, ThisArg))
+          return false;
+        return Result.isInt() && Result.getInt().getBoolValue();
+      });
 }
 
-void Sema::emitDiagnoseIfDiagnostic(SourceLocation Loc,
-                                    const DiagnoseIfAttr *DIA) {
-  auto Code = DIA->isError() ? diag::err_diagnose_if_succeeded
-                             : diag::warn_diagnose_if_succeeded;
-  Diag(Loc, Code) << DIA->getMessage();
-  Diag(DIA->getLocation(), diag::note_from_diagnose_if)
-      << DIA->getParent() << DIA->getCond()->getSourceRange();
+bool Sema::diagnoseArgIndependentDiagnoseIfAttrs(const FunctionDecl *Function,
+                                                 SourceLocation Loc) {
+  return diagnoseDiagnoseIfAttrsWith(
+      *this, Function, /*ArgDependent=*/false, Loc,
+      [&](const DiagnoseIfAttr *DIA) {
+        bool Result;
+        return DIA->getCond()->EvaluateAsBooleanCondition(Result, Context) &&
+               Result;
+      });
 }
 
 /// \brief Add all of the function declarations in the given function set to
@@ -6356,8 +6311,8 @@ void Sema::AddFunctionCandidates(const U
         AddMethodCandidate(cast<CXXMethodDecl>(FD), F.getPair(),
                            cast<CXXMethodDecl>(FD)->getParent(),
                            Args[0]->getType(), Args[0]->Classify(Context),
-                           Args[0], Args.slice(1), CandidateSet,
-                           SuppressUserConversions, PartialOverloading);
+                           Args.slice(1), CandidateSet, SuppressUserConversions,
+                           PartialOverloading);
       else
         AddOverloadCandidate(FD, F.getPair(), Args, CandidateSet,
                              SuppressUserConversions, PartialOverloading);
@@ -6369,7 +6324,7 @@ void Sema::AddFunctionCandidates(const U
             FunTmpl, F.getPair(),
             cast<CXXRecordDecl>(FunTmpl->getDeclContext()),
             ExplicitTemplateArgs, Args[0]->getType(),
-            Args[0]->Classify(Context), Args[0], Args.slice(1), CandidateSet,
+            Args[0]->Classify(Context), Args.slice(1), CandidateSet,
             SuppressUserConversions, PartialOverloading);
       else
         AddTemplateOverloadCandidate(FunTmpl, F.getPair(),
@@ -6385,7 +6340,6 @@ void Sema::AddFunctionCandidates(const U
 void Sema::AddMethodCandidate(DeclAccessPair FoundDecl,
                               QualType ObjectType,
                               Expr::Classification ObjectClassification,
-                              Expr *ThisArg,
                               ArrayRef<Expr *> Args,
                               OverloadCandidateSet& CandidateSet,
                               bool SuppressUserConversions) {
@@ -6399,15 +6353,13 @@ void Sema::AddMethodCandidate(DeclAccess
     assert(isa<CXXMethodDecl>(TD->getTemplatedDecl()) &&
            "Expected a member function template");
     AddMethodTemplateCandidate(TD, FoundDecl, ActingContext,
-                               /*ExplicitArgs*/ nullptr,
-                               ObjectType, ObjectClassification,
-                               ThisArg, Args, CandidateSet,
+                               /*ExplicitArgs*/ nullptr, ObjectType,
+                               ObjectClassification, Args, CandidateSet,
                                SuppressUserConversions);
   } else {
     AddMethodCandidate(cast<CXXMethodDecl>(Decl), FoundDecl, ActingContext,
-                       ObjectType, ObjectClassification,
-                       ThisArg, Args,
-                       CandidateSet, SuppressUserConversions);
+                       ObjectType, ObjectClassification, Args, CandidateSet,
+                       SuppressUserConversions);
   }
 }
 
@@ -6422,7 +6374,7 @@ void
 Sema::AddMethodCandidate(CXXMethodDecl *Method, DeclAccessPair FoundDecl,
                          CXXRecordDecl *ActingContext, QualType ObjectType,
                          Expr::Classification ObjectClassification,
-                         Expr *ThisArg, ArrayRef<Expr *> Args,
+                         ArrayRef<Expr *> Args,
                          OverloadCandidateSet &CandidateSet,
                          bool SuppressUserConversions,
                          bool PartialOverloading,
@@ -6544,9 +6496,6 @@ Sema::AddMethodCandidate(CXXMethodDecl *
     Candidate.DeductionFailure.Data = FailedAttr;
     return;
   }
-
-  initDiagnoseIfComplaint(*this, CandidateSet, Candidate, Method, Args,
-                          /*MissingImplicitThis=*/!ThisArg, ThisArg);
 }
 
 /// \brief Add a C++ member function template as a candidate to the candidate
@@ -6559,7 +6508,6 @@ Sema::AddMethodTemplateCandidate(Functio
                                  TemplateArgumentListInfo *ExplicitTemplateArgs,
                                  QualType ObjectType,
                                  Expr::Classification ObjectClassification,
-                                 Expr *ThisArg,
                                  ArrayRef<Expr *> Args,
                                  OverloadCandidateSet& CandidateSet,
                                  bool SuppressUserConversions,
@@ -6613,9 +6561,9 @@ Sema::AddMethodTemplateCandidate(Functio
   assert(isa<CXXMethodDecl>(Specialization) &&
          "Specialization is not a member function?");
   AddMethodCandidate(cast<CXXMethodDecl>(Specialization), FoundDecl,
-                     ActingContext, ObjectType, ObjectClassification,
-                     /*ThisArg=*/ThisArg, Args, CandidateSet,
-                     SuppressUserConversions, PartialOverloading, Conversions);
+                     ActingContext, ObjectType, ObjectClassification, Args,
+                     CandidateSet, SuppressUserConversions, PartialOverloading,
+                     Conversions);
 }
 
 /// \brief Add a C++ function template specialization as a candidate
@@ -6942,8 +6890,6 @@ Sema::AddConversionCandidate(CXXConversi
     Candidate.DeductionFailure.Data = FailedAttr;
     return;
   }
-
-  initDiagnoseIfComplaint(*this, CandidateSet, Candidate, Conversion, None, false, From);
 }
 
 /// \brief Adds a conversion function template specialization
@@ -7096,8 +7042,6 @@ void Sema::AddSurrogateCandidate(CXXConv
     Candidate.DeductionFailure.Data = FailedAttr;
     return;
   }
-
-  initDiagnoseIfComplaint(*this, CandidateSet, Candidate, Conversion, None);
 }
 
 /// \brief Add overload candidates for overloaded operators that are
@@ -7146,7 +7090,7 @@ void Sema::AddMemberOperatorCandidates(O
          Oper != OperEnd;
          ++Oper)
       AddMethodCandidate(Oper.getPair(), Args[0]->getType(),
-                         Args[0]->Classify(Context), Args[0], Args.slice(1),
+                         Args[0]->Classify(Context), Args.slice(1),
                          CandidateSet, /*SuppressUserConversions=*/false);
   }
 }
@@ -9178,17 +9122,6 @@ void Sema::diagnoseEquivalentInternalLin
   }
 }
 
-static bool isCandidateUnavailableDueToDiagnoseIf(const OverloadCandidate &OC) {
-  ArrayRef<DiagnoseIfAttr *> Info = OC.getDiagnoseIfInfo();
-  if (!Info.empty() && Info[0]->isError())
-    return true;
-
-  assert(llvm::all_of(Info,
-                      [](const DiagnoseIfAttr *A) { return !A->isError(); }) &&
-         "DiagnoseIf info shouldn't have mixed warnings and errors.");
-  return false;
-}
-
 /// \brief Computes the best viable function (C++ 13.3.3)
 /// within an overload candidate set.
 ///
@@ -9267,19 +9200,13 @@ OverloadCandidateSet::BestViableFunction
   // Best is the best viable function.
   if (Best->Function &&
       (Best->Function->isDeleted() ||
-       S.isFunctionConsideredUnavailable(Best->Function) ||
-       isCandidateUnavailableDueToDiagnoseIf(*Best)))
+       S.isFunctionConsideredUnavailable(Best->Function)))
     return OR_Deleted;
 
   if (!EquivalentCands.empty())
     S.diagnoseEquivalentInternalLinkageDeclarations(Loc, Best->Function,
                                                     EquivalentCands);
 
-  for (const auto *W : Best->getDiagnoseIfInfo()) {
-    assert(W->isWarning() && "Errors should've been caught earlier!");
-    S.emitDiagnoseIfDiagnostic(Loc, W);
-  }
-
   return OR_Success;
 }
 
@@ -10162,14 +10089,6 @@ static void NoteFunctionCandidate(Sema &
       MaybeEmitInheritedConstructorNote(S, Cand->FoundDecl);
       return;
     }
-    if (isCandidateUnavailableDueToDiagnoseIf(*Cand)) {
-      auto *A = Cand->DiagnoseIfInfo.get<DiagnoseIfAttr *>();
-      assert(A->isError() && "Non-error diagnose_if disables a candidate?");
-      S.Diag(Cand->Function->getLocation(),
-             diag::note_ovl_candidate_disabled_by_function_cond_attr)
-          << A->getCond()->getSourceRange() << A->getMessage();
-      return;
-    }
 
     // We don't really have anything else to say about viable candidates.
     S.NoteOverloadCandidate(Cand->FoundDecl, Fn);
@@ -12113,6 +12032,10 @@ Sema::CreateOverloadedUnaryOp(SourceLoca
       if (CheckCallReturnType(FnDecl->getReturnType(), OpLoc, TheCall, FnDecl))
         return ExprError();
 
+      if (CheckFunctionCall(FnDecl, TheCall,
+                            FnDecl->getType()->castAs<FunctionProtoType>()))
+        return ExprError();
+
       return MaybeBindToTemporary(TheCall);
     } else {
       // We matched a built-in operator. Convert the arguments, then
@@ -12343,16 +12266,20 @@ Sema::CreateOverloadedBinOp(SourceLocati
           return ExprError();
 
         ArrayRef<const Expr *> ArgsArray(Args, 2);
+        const Expr *ImplicitThis = nullptr;
         // Cut off the implicit 'this'.
-        if (isa<CXXMethodDecl>(FnDecl))
+        if (isa<CXXMethodDecl>(FnDecl)) {
+          ImplicitThis = ArgsArray[0];
           ArgsArray = ArgsArray.slice(1);
+        }
 
         // Check for a self move.
         if (Op == OO_Equal)
           DiagnoseSelfMove(Args[0], Args[1], OpLoc);
 
-        checkCall(FnDecl, nullptr, ArgsArray, isa<CXXMethodDecl>(FnDecl), OpLoc, 
-                  TheCall->getSourceRange(), VariadicDoesNotApply);
+        checkCall(FnDecl, nullptr, ImplicitThis, ArgsArray,
+                  isa<CXXMethodDecl>(FnDecl), OpLoc, TheCall->getSourceRange(),
+                  VariadicDoesNotApply);
 
         return MaybeBindToTemporary(TheCall);
       } else {
@@ -12561,6 +12488,10 @@ Sema::CreateOverloadedArraySubscriptExpr
         if (CheckCallReturnType(FnDecl->getReturnType(), LLoc, TheCall, FnDecl))
           return ExprError();
 
+        if (CheckFunctionCall(Method, TheCall,
+                              Method->getType()->castAs<FunctionProtoType>()))
+          return ExprError();
+
         return MaybeBindToTemporary(TheCall);
       } else {
         // We matched a built-in operator. Convert the arguments, then
@@ -12727,16 +12658,6 @@ Sema::BuildCallToMemberFunction(Scope *S
       TemplateArgs = &TemplateArgsBuffer;
     }
 
-    // Poor-programmer's Lazy<Expr *>; isImplicitAccess requires stripping
-    // parens/casts, which would be nice to avoid potentially doing multiple
-    // times.
-    llvm::Optional<Expr *> UnresolvedBase;
-    auto GetUnresolvedBase = [&] {
-      if (!UnresolvedBase.hasValue())
-        UnresolvedBase =
-          UnresExpr->isImplicitAccess() ? nullptr : UnresExpr->getBase();
-      return *UnresolvedBase;
-    };
     for (UnresolvedMemberExpr::decls_iterator I = UnresExpr->decls_begin(),
            E = UnresExpr->decls_end(); I != E; ++I) {
 
@@ -12757,14 +12678,12 @@ Sema::BuildCallToMemberFunction(Scope *S
           continue;
 
         AddMethodCandidate(Method, I.getPair(), ActingDC, ObjectType,
-                           ObjectClassification,
-                           /*ThisArg=*/GetUnresolvedBase(), Args, CandidateSet,
+                           ObjectClassification, Args, CandidateSet,
                            /*SuppressUserConversions=*/false);
       } else {
         AddMethodTemplateCandidate(
             cast<FunctionTemplateDecl>(Func), I.getPair(), ActingDC,
-            TemplateArgs, ObjectType, ObjectClassification,
-            /*ThisArg=*/GetUnresolvedBase(), Args, CandidateSet,
+            TemplateArgs, ObjectType, ObjectClassification, Args, CandidateSet,
             /*SuppressUsedConversions=*/false);
       }
     }
@@ -12882,16 +12801,6 @@ Sema::BuildCallToMemberFunction(Scope *S
           << Attr->getCond()->getSourceRange() << Attr->getMessage();
       return ExprError();
     }
-
-    SmallVector<DiagnoseIfAttr *, 4> Nonfatal;
-    if (const DiagnoseIfAttr *Attr = checkArgDependentDiagnoseIf(
-            Method, Args, Nonfatal, false, MemE->getBase())) {
-      emitDiagnoseIfDiagnostic(MemE->getMemberLoc(), Attr);
-      return ExprError();
-    }
-
-    for (const auto *Attr : Nonfatal)
-      emitDiagnoseIfDiagnostic(MemE->getMemberLoc(), Attr);
   }
 
   if ((isa<CXXConstructorDecl>(CurContext) || 
@@ -12970,9 +12879,8 @@ Sema::BuildCallToObjectOfClassType(Scope
   for (LookupResult::iterator Oper = R.begin(), OperEnd = R.end();
        Oper != OperEnd; ++Oper) {
     AddMethodCandidate(Oper.getPair(), Object.get()->getType(),
-                       Object.get()->Classify(Context),
-                       Object.get(), Args, CandidateSet,
-                       /*SuppressUserConversions=*/ false);
+                       Object.get()->Classify(Context), Args, CandidateSet,
+                       /*SuppressUserConversions=*/false);
   }
 
   // C++ [over.call.object]p2:
@@ -13247,8 +13155,7 @@ Sema::BuildOverloadedArrowExpr(Scope *S,
   for (LookupResult::iterator Oper = R.begin(), OperEnd = R.end();
        Oper != OperEnd; ++Oper) {
     AddMethodCandidate(Oper.getPair(), Base->getType(), Base->Classify(Context),
-                       Base, None, CandidateSet,
-                       /*SuppressUserConversions=*/false);
+                       None, CandidateSet, /*SuppressUserConversions=*/false);
   }
 
   bool HadMultipleCandidates = (CandidateSet.size() > 1);
@@ -13322,7 +13229,11 @@ Sema::BuildOverloadedArrowExpr(Scope *S,
                                       Base, ResultTy, VK, OpLoc, false);
 
   if (CheckCallReturnType(Method->getReturnType(), OpLoc, TheCall, Method))
-          return ExprError();
+    return ExprError();
+
+  if (CheckFunctionCall(Method, TheCall,
+                        Method->getType()->castAs<FunctionProtoType>()))
+    return ExprError();
 
   return MaybeBindToTemporary(TheCall);
 }

Modified: vendor/clang/dist/lib/Sema/SemaTemplateInstantiateDecl.cpp
==============================================================================
--- vendor/clang/dist/lib/Sema/SemaTemplateInstantiateDecl.cpp	Wed Feb  1 21:34:55 2017	(r313057)
+++ vendor/clang/dist/lib/Sema/SemaTemplateInstantiateDecl.cpp	Wed Feb  1 21:35:00 2017	(r313058)
@@ -4996,8 +4996,12 @@ NamedDecl *Sema::FindInstantiatedDecl(So
     NamedDecl *Result = nullptr;
     // FIXME: If the name is a dependent name, this lookup won't necessarily
     // find it. Does that ever matter?
-    if (D->getDeclName()) {
-      DeclContext::lookup_result Found = ParentDC->lookup(D->getDeclName());
+    if (auto Name = D->getDeclName()) {
+      DeclarationNameInfo NameInfo(Name, D->getLocation());
+      Name = SubstDeclarationNameInfo(NameInfo, TemplateArgs).getName();
+      if (!Name)
+        return nullptr;
+      DeclContext::lookup_result Found = ParentDC->lookup(Name);
       Result = findInstantiationOf(Context, D, Found.begin(), Found.end());
     } else {
       // Since we don't have a name for the entity we're looking for,

Modified: vendor/clang/dist/lib/Sema/TreeTransform.h
==============================================================================
--- vendor/clang/dist/lib/Sema/TreeTransform.h	Wed Feb  1 21:34:55 2017	(r313057)
+++ vendor/clang/dist/lib/Sema/TreeTransform.h	Wed Feb  1 21:35:00 2017	(r313058)
@@ -8818,12 +8818,18 @@ TreeTransform<Derived>::TransformMemberE
   // base (and therefore couldn't do the check) and a
   // nested-name-qualifier (and therefore could do the lookup).
   NamedDecl *FirstQualifierInScope = nullptr;
+  DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
+  if (MemberNameInfo.getName()) {
+    MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
+    if (!MemberNameInfo.getName())
+      return ExprError();
+  }
 
   return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
                                         E->isArrow(),
                                         QualifierLoc,
                                         TemplateKWLoc,
-                                        E->getMemberNameInfo(),
+                                        MemberNameInfo,
                                         Member,
                                         FoundDecl,
                                         (E->hasExplicitTemplateArgs()

Modified: vendor/clang/dist/test/CodeGenCXX/microsoft-abi-default-cc.cpp
==============================================================================
--- vendor/clang/dist/test/CodeGenCXX/microsoft-abi-default-cc.cpp	Wed Feb  1 21:34:55 2017	(r313057)
+++ vendor/clang/dist/test/CodeGenCXX/microsoft-abi-default-cc.cpp	Wed Feb  1 21:35:00 2017	(r313058)
@@ -45,3 +45,12 @@ void __cdecl static_baz() {}
 void static_qux() {}
 // GCABI-LABEL: define void @_Z10static_quxv
 // MSABI: define void @"\01?static_qux@@YAXXZ"
+
+namespace PR31656 {
+template <int I>
+void __cdecl callee(int args[I]);
+// GCABI-LABEL: declare void @_ZN7PR316566calleeILi1EEEvPi(
+// MSABI: declare void @"\01??$callee@$00@PR31656@@YAXQAH@Z"(
+
+void caller() { callee<1>(0); }
+}

Added: vendor/clang/dist/test/CodeGenObjC/block-ptr-type-crash.m
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/clang/dist/test/CodeGenObjC/block-ptr-type-crash.m	Wed Feb  1 21:35:00 2017	(r313058)
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -Wno-objc-root-class -fblocks -o /dev/null -triple x86_64-- -emit-llvm %s
+// REQUIRES: asserts
+// Verify there is no assertion.
+
+// rdar://30111891
+
+typedef unsigned long long uint64_t;
+typedef enum AnEnum : uint64_t AnEnum;
+enum AnEnum: uint64_t {
+    AnEnumA
+};
+
+typedef void (^BlockType)();
+@interface MyClass
+@end
+@implementation MyClass
+- (void)_doStuff {
+  struct {
+    int identifier;
+    AnEnum type;
+    BlockType handler;
+  } var = {
+    "hello",
+    AnEnumA,
+    ((void *)0)

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201702012135.v11LZ1XP099890>