<div dir="ltr"><div>FYI: This patch should to be merged into the clang 3.8.0 branch.<br></div><div><br></div><div>Thank you!</div><div>George</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 13, 2016 at 3:36 PM, George Burgess IV via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: gbiv<br>
Date: Wed Jan 13 17:36:34 2016<br>
New Revision: 257710<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=257710&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=257710&view=rev</a><br>
Log:<br>
[Sema] Suppress diags in overload resolution.<br>
<br>
We were emitting diagnostics from our shiny new C-only overload<br>
resolution mode. This patch attempts to silence all such diagnostics.<br>
<br>
This fixes PR26085.<br>
Differential Revision: <a href="http://reviews.llvm.org/D16159" rel="noreferrer" target="_blank">http://reviews.llvm.org/D16159</a><br>
<br>
Added:<br>
    cfe/trunk/test/SemaObjC/ovl-check.m<br>
Modified:<br>
    cfe/trunk/include/clang/Sema/Sema.h<br>
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp<br>
    cfe/trunk/lib/Sema/SemaExpr.cpp<br>
    cfe/trunk/lib/Sema/SemaExprObjC.cpp<br>
    cfe/trunk/lib/Sema/SemaOverload.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Sema/Sema.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=257710&r1=257709&r2=257710&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=257710&r1=257709&r2=257710&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Sema/Sema.h (original)<br>
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Jan 13 17:36:34 2016<br>
@@ -2229,7 +2229,8 @@ public:<br>
   bool CheckPointerConversion(Expr *From, QualType ToType,<br>
                               CastKind &Kind,<br>
                               CXXCastPath& BasePath,<br>
-                              bool IgnoreBaseAccess);<br>
+                              bool IgnoreBaseAccess,<br>
+                              bool Diagnose = true);<br>
   bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType,<br>
                                  bool InOverloadResolution,<br>
                                  QualType &ConvertedType);<br>
@@ -5388,7 +5389,8 @@ public:<br>
                                     unsigned AmbigiousBaseConvID,<br>
                                     SourceLocation Loc, SourceRange Range,<br>
                                     DeclarationName Name,<br>
-                                    CXXCastPath *BasePath);<br>
+                                    CXXCastPath *BasePath,<br>
+                                    bool IgnoreAccess = false);<br>
<br>
   std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);<br>
<br>
@@ -7514,14 +7516,15 @@ public:<br>
                                         ObjCMethodDecl *&ClassMethod,<br>
                                         ObjCMethodDecl *&InstanceMethod,<br>
                                         TypedefNameDecl *&TDNDecl,<br>
-                                        bool CfToNs);<br>
-<br>
+                                        bool CfToNs, bool Diagnose = true);<br>
+<br>
   bool CheckObjCBridgeRelatedConversions(SourceLocation Loc,<br>
                                          QualType DestType, QualType SrcType,<br>
-                                         Expr *&SrcExpr);<br>
-<br>
-  bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr);<br>
-<br>
+                                         Expr *&SrcExpr, bool Diagnose = true);<br>
+<br>
+  bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr,<br>
+                                          bool Diagnose = true);<br>
+<br>
   bool checkInitMethod(ObjCMethodDecl *method, QualType receiverTypeIfCall);<br>
<br>
   /// \brief Check whether the given new method is a valid override of the<br>
@@ -8613,6 +8616,7 @@ public:<br>
   ARCConversionResult CheckObjCARCConversion(SourceRange castRange,<br>
                                              QualType castType, Expr *&op,<br>
                                              CheckedConversionKind CCK,<br>
+                                             bool Diagnose = true,<br>
                                              bool DiagnoseCFAudited = false,<br>
                                              BinaryOperatorKind Opc = BO_PtrMemD<br>
                                              );<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=257710&r1=257709&r2=257710&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=257710&r1=257709&r2=257710&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Jan 13 17:36:34 2016<br>
@@ -1742,13 +1742,18 @@ void Sema::BuildBasePathArray(const CXXB<br>
 /// otherwise. Loc is the location where this routine should point to<br>
 /// if there is an error, and Range is the source range to highlight<br>
 /// if there is an error.<br>
+///<br>
+/// If either InaccessibleBaseID or AmbigiousBaseConvID are 0, then the<br>
+/// diagnostic for the respective type of error will be suppressed, but the<br>
+/// check for ill-formed code will still be performed.<br>
 bool<br>
 Sema::CheckDerivedToBaseConversion(QualType Derived, QualType Base,<br>
                                    unsigned InaccessibleBaseID,<br>
                                    unsigned AmbigiousBaseConvID,<br>
                                    SourceLocation Loc, SourceRange Range,<br>
                                    DeclarationName Name,<br>
-                                   CXXCastPath *BasePath) {<br>
+                                   CXXCastPath *BasePath,<br>
+                                   bool IgnoreAccess) {<br>
   // First, determine whether the path from Derived to Base is<br>
   // ambiguous. This is slightly more expensive than checking whether<br>
   // the Derived to Base conversion exists, because here we need to<br>
@@ -1761,7 +1766,7 @@ Sema::CheckDerivedToBaseConversion(QualT<br>
   (void)DerivationOkay;<br>
<br>
   if (!Paths.isAmbiguous(Context.getCanonicalType(Base).getUnqualifiedType())) {<br>
-    if (InaccessibleBaseID) {<br>
+    if (!IgnoreAccess) {<br>
       // Check that the base class can be accessed.<br>
       switch (CheckBaseClassAccess(Loc, Base, Derived, Paths.front(),<br>
                                    InaccessibleBaseID)) {<br>
@@ -1810,12 +1815,10 @@ Sema::CheckDerivedToBaseConversion(QualT<br>
                                    SourceLocation Loc, SourceRange Range,<br>
                                    CXXCastPath *BasePath,<br>
                                    bool IgnoreAccess) {<br>
-  return CheckDerivedToBaseConversion(Derived, Base,<br>
-                                      IgnoreAccess ? 0<br>
-                                       : diag::err_upcast_to_inaccessible_base,<br>
-                                      diag::err_ambiguous_derived_to_base_conv,<br>
-                                      Loc, Range, DeclarationName(),<br>
-                                      BasePath);<br>
+  return CheckDerivedToBaseConversion(<br>
+      Derived, Base, diag::err_upcast_to_inaccessible_base,<br>
+      diag::err_ambiguous_derived_to_base_conv, Loc, Range, DeclarationName(),<br>
+      BasePath, IgnoreAccess);<br>
 }<br>
<br>
<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=257710&r1=257709&r2=257710&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=257710&r1=257709&r2=257710&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Jan 13 17:36:34 2016<br>
@@ -7354,11 +7354,14 @@ Sema::CheckSingleAssignmentConstraints(Q<br>
        LHSType->isBlockPointerType()) &&<br>
       RHS.get()->isNullPointerConstant(Context,<br>
                                        Expr::NPC_ValueDependentIsNull)) {<br>
-    CastKind Kind;<br>
-    CXXCastPath Path;<br>
-    CheckPointerConversion(RHS.get(), LHSType, Kind, Path, false);<br>
-    if (ConvertRHS)<br>
-      RHS = ImpCastExprToType(RHS.get(), LHSType, Kind, VK_RValue, &Path);<br>
+    if (Diagnose || ConvertRHS) {<br>
+      CastKind Kind;<br>
+      CXXCastPath Path;<br>
+      CheckPointerConversion(RHS.get(), LHSType, Kind, Path,<br>
+                             /*IgnoreBaseAccess=*/false, Diagnose);<br>
+      if (ConvertRHS)<br>
+        RHS = ImpCastExprToType(RHS.get(), LHSType, Kind, VK_RValue, &Path);<br>
+    }<br>
     return Compatible;<br>
   }<br>
<br>
@@ -7376,8 +7379,8 @@ Sema::CheckSingleAssignmentConstraints(Q<br>
   }<br>
<br>
   Expr *PRE = RHS.get()->IgnoreParenCasts();<br>
-  if (ObjCProtocolExpr *OPE = dyn_cast<ObjCProtocolExpr>(PRE)) {<br>
-    ObjCProtocolDecl *PDecl = OPE->getProtocol();<br>
+  if (Diagnose && isa<ObjCProtocolExpr>(PRE)) {<br>
+    ObjCProtocolDecl *PDecl = cast<ObjCProtocolExpr>(PRE)->getProtocol();<br>
     if (PDecl && !PDecl->hasDefinition()) {<br>
       Diag(PRE->getExprLoc(), diag::warn_atprotocol_protocol) << PDecl->getName();<br>
       Diag(PDecl->getLocation(), diag::note_entity_declared_at) << PDecl;<br>
@@ -7399,11 +7402,11 @@ Sema::CheckSingleAssignmentConstraints(Q<br>
     Expr *E = RHS.get();<br>
     if (getLangOpts().ObjCAutoRefCount)<br>
       CheckObjCARCConversion(SourceRange(), Ty, E, CCK_ImplicitConversion,<br>
-                             DiagnoseCFAudited);<br>
+                             Diagnose, DiagnoseCFAudited);<br>
     if (getLangOpts().ObjC1 &&<br>
-        (CheckObjCBridgeRelatedConversions(E->getLocStart(),<br>
-                                          LHSType, E->getType(), E) ||<br>
-         ConversionToObjCStringLiteralCheck(LHSType, E))) {<br>
+        (CheckObjCBridgeRelatedConversions(E->getLocStart(), LHSType,<br>
+                                           E->getType(), E, Diagnose) ||<br>
+         ConversionToObjCStringLiteralCheck(LHSType, E, Diagnose))) {<br>
       RHS = E;<br>
       return Compatible;<br>
     }<br>
@@ -8961,8 +8964,9 @@ QualType Sema::CheckCompareOperands(Expr<br>
       else {<br>
         Expr *E = RHS.get();<br>
         if (getLangOpts().ObjCAutoRefCount)<br>
-          CheckObjCARCConversion(SourceRange(), LHSType, E, CCK_ImplicitConversion, false,<br>
-                                 Opc);<br>
+          CheckObjCARCConversion(SourceRange(), LHSType, E,<br>
+                                 CCK_ImplicitConversion, /*Diagnose=*/true,<br>
+                                 /*DiagnoseCFAudited=*/false, Opc);<br>
         RHS = ImpCastExprToType(E, LHSType,<br>
                                 LPT ? CK_BitCast :CK_CPointerToObjCPointerCast);<br>
       }<br>
@@ -11830,8 +11834,8 @@ ExprResult Sema::ActOnGNUNullExpr(Source<br>
   return new (Context) GNUNullExpr(Ty, TokenLoc);<br>
 }<br>
<br>
-bool<br>
-Sema::ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&Exp) {<br>
+bool Sema::ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&Exp,<br>
+                                              bool Diagnose) {<br>
   if (!getLangOpts().ObjC1)<br>
     return false;<br>
<br>
@@ -11857,8 +11861,9 @@ Sema::ConversionToObjCStringLiteralCheck<br>
   StringLiteral *SL = dyn_cast<StringLiteral>(SrcExpr);<br>
   if (!SL || !SL->isAscii())<br>
     return false;<br>
-  Diag(SL->getLocStart(), diag::err_missing_atsign_prefix)<br>
-    << FixItHint::CreateInsertion(SL->getLocStart(), "@");<br>
+  if (Diagnose)<br>
+    Diag(SL->getLocStart(), diag::err_missing_atsign_prefix)<br>
+      << FixItHint::CreateInsertion(SL->getLocStart(), "@");<br>
   Exp = BuildObjCStringLiteral(SL->getLocStart(), SL).get();<br>
   return true;<br>
 }<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=257710&r1=257709&r2=257710&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=257710&r1=257709&r2=257710&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Wed Jan 13 17:36:34 2016<br>
@@ -3816,7 +3816,7 @@ bool Sema::checkObjCBridgeRelatedCompone<br>
                                             ObjCMethodDecl *&ClassMethod,<br>
                                             ObjCMethodDecl *&InstanceMethod,<br>
                                             TypedefNameDecl *&TDNDecl,<br>
-                                            bool CfToNs) {<br>
+                                            bool CfToNs, bool Diagnose) {<br>
   QualType T = CfToNs ? SrcType : DestType;<br>
   ObjCBridgeRelatedAttr *ObjCBAttr = ObjCBridgeRelatedAttrFromType(T, TDNDecl);<br>
   if (!ObjCBAttr)<br>
@@ -3832,20 +3832,24 @@ bool Sema::checkObjCBridgeRelatedCompone<br>
   LookupResult R(*this, DeclarationName(RCId), SourceLocation(),<br>
                  Sema::LookupOrdinaryName);<br>
   if (!LookupName(R, TUScope)) {<br>
-    Diag(Loc, diag::err_objc_bridged_related_invalid_class) << RCId<br>
-          << SrcType << DestType;<br>
-    Diag(TDNDecl->getLocStart(), diag::note_declared_at);<br>
+    if (Diagnose) {<br>
+      Diag(Loc, diag::err_objc_bridged_related_invalid_class) << RCId<br>
+            << SrcType << DestType;<br>
+      Diag(TDNDecl->getLocStart(), diag::note_declared_at);<br>
+    }<br>
     return false;<br>
   }<br>
   Target = R.getFoundDecl();<br>
   if (Target && isa<ObjCInterfaceDecl>(Target))<br>
     RelatedClass = cast<ObjCInterfaceDecl>(Target);<br>
   else {<br>
-    Diag(Loc, diag::err_objc_bridged_related_invalid_class_name) << RCId<br>
-          << SrcType << DestType;<br>
-    Diag(TDNDecl->getLocStart(), diag::note_declared_at);<br>
-    if (Target)<br>
-      Diag(Target->getLocStart(), diag::note_declared_at);<br>
+    if (Diagnose) {<br>
+      Diag(Loc, diag::err_objc_bridged_related_invalid_class_name) << RCId<br>
+            << SrcType << DestType;<br>
+      Diag(TDNDecl->getLocStart(), diag::note_declared_at);<br>
+      if (Target)<br>
+        Diag(Target->getLocStart(), diag::note_declared_at);<br>
+    }<br>
     return false;<br>
   }<br>
<br>
@@ -3854,9 +3858,11 @@ bool Sema::checkObjCBridgeRelatedCompone<br>
     Selector Sel = Context.Selectors.getUnarySelector(CMId);<br>
     ClassMethod = RelatedClass->lookupMethod(Sel, false);<br>
     if (!ClassMethod) {<br>
-      Diag(Loc, diag::err_objc_bridged_related_known_method)<br>
-            << SrcType << DestType << Sel << false;<br>
-      Diag(TDNDecl->getLocStart(), diag::note_declared_at);<br>
+      if (Diagnose) {<br>
+        Diag(Loc, diag::err_objc_bridged_related_known_method)<br>
+              << SrcType << DestType << Sel << false;<br>
+        Diag(TDNDecl->getLocStart(), diag::note_declared_at);<br>
+      }<br>
       return false;<br>
     }<br>
   }<br>
@@ -3866,9 +3872,11 @@ bool Sema::checkObjCBridgeRelatedCompone<br>
     Selector Sel = Context.Selectors.getNullarySelector(IMId);<br>
     InstanceMethod = RelatedClass->lookupMethod(Sel, true);<br>
     if (!InstanceMethod) {<br>
-      Diag(Loc, diag::err_objc_bridged_related_known_method)<br>
-            << SrcType << DestType << Sel << true;<br>
-      Diag(TDNDecl->getLocStart(), diag::note_declared_at);<br>
+      if (Diagnose) {<br>
+        Diag(Loc, diag::err_objc_bridged_related_known_method)<br>
+              << SrcType << DestType << Sel << true;<br>
+        Diag(TDNDecl->getLocStart(), diag::note_declared_at);<br>
+      }<br>
       return false;<br>
     }<br>
   }<br>
@@ -3878,7 +3886,7 @@ bool Sema::checkObjCBridgeRelatedCompone<br>
 bool<br>
 Sema::CheckObjCBridgeRelatedConversions(SourceLocation Loc,<br>
                                         QualType DestType, QualType SrcType,<br>
-                                        Expr *&SrcExpr) {<br>
+                                        Expr *&SrcExpr, bool Diagnose) {<br>
   ARCConversionTypeClass rhsExprACTC = classifyTypeForARCConversion(SrcType);<br>
   ARCConversionTypeClass lhsExprACTC = classifyTypeForARCConversion(DestType);<br>
   bool CfToNs = (rhsExprACTC == ACTC_coreFoundation && lhsExprACTC == ACTC_retainable);<br>
@@ -3891,27 +3899,29 @@ Sema::CheckObjCBridgeRelatedConversions(<br>
   ObjCMethodDecl *InstanceMethod = nullptr;<br>
   TypedefNameDecl *TDNDecl = nullptr;<br>
   if (!checkObjCBridgeRelatedComponents(Loc, DestType, SrcType, RelatedClass,<br>
-                                        ClassMethod, InstanceMethod, TDNDecl, CfToNs))<br>
+                                        ClassMethod, InstanceMethod, TDNDecl,<br>
+                                        CfToNs, Diagnose))<br>
     return false;<br>
<br>
   if (CfToNs) {<br>
     // Implicit conversion from CF to ObjC object is needed.<br>
     if (ClassMethod) {<br>
-      std::string ExpressionString = "[";<br>
-      ExpressionString += RelatedClass->getNameAsString();<br>
-      ExpressionString += " ";<br>
-      ExpressionString += ClassMethod->getSelector().getAsString();<br>
-      SourceLocation SrcExprEndLoc = getLocForEndOfToken(SrcExpr->getLocEnd());<br>
-      // Provide a fixit: [RelatedClass ClassMethod SrcExpr]<br>
-      Diag(Loc, diag::err_objc_bridged_related_known_method)<br>
-        << SrcType << DestType << ClassMethod->getSelector() << false<br>
-        << FixItHint::CreateInsertion(SrcExpr->getLocStart(), ExpressionString)<br>
-        << FixItHint::CreateInsertion(SrcExprEndLoc, "]");<br>
-      Diag(RelatedClass->getLocStart(), diag::note_declared_at);<br>
-      Diag(TDNDecl->getLocStart(), diag::note_declared_at);<br>
+      if (Diagnose) {<br>
+        std::string ExpressionString = "[";<br>
+        ExpressionString += RelatedClass->getNameAsString();<br>
+        ExpressionString += " ";<br>
+        ExpressionString += ClassMethod->getSelector().getAsString();<br>
+        SourceLocation SrcExprEndLoc = getLocForEndOfToken(SrcExpr->getLocEnd());<br>
+        // Provide a fixit: [RelatedClass ClassMethod SrcExpr]<br>
+        Diag(Loc, diag::err_objc_bridged_related_known_method)<br>
+          << SrcType << DestType << ClassMethod->getSelector() << false<br>
+          << FixItHint::CreateInsertion(SrcExpr->getLocStart(), ExpressionString)<br>
+          << FixItHint::CreateInsertion(SrcExprEndLoc, "]");<br>
+        Diag(RelatedClass->getLocStart(), diag::note_declared_at);<br>
+        Diag(TDNDecl->getLocStart(), diag::note_declared_at);<br>
+      }<br>
<br>
-      QualType receiverType =<br>
-        Context.getObjCInterfaceType(RelatedClass);<br>
+      QualType receiverType = Context.getObjCInterfaceType(RelatedClass);<br>
       // Argument.<br>
       Expr *args[] = { SrcExpr };<br>
       ExprResult msg = BuildClassMessageImplicit(receiverType, false,<br>
@@ -3925,30 +3935,34 @@ Sema::CheckObjCBridgeRelatedConversions(<br>
   else {<br>
     // Implicit conversion from ObjC type to CF object is needed.<br>
     if (InstanceMethod) {<br>
-      std::string ExpressionString;<br>
-      SourceLocation SrcExprEndLoc = getLocForEndOfToken(SrcExpr->getLocEnd());<br>
-      if (InstanceMethod->isPropertyAccessor())<br>
-        if (const ObjCPropertyDecl *PDecl = InstanceMethod->findPropertyDecl()) {<br>
-          // fixit: ObjectExpr.propertyname when it is  aproperty accessor.<br>
-          ExpressionString = ".";<br>
-          ExpressionString += PDecl->getNameAsString();<br>
+      if (Diagnose) {<br>
+        std::string ExpressionString;<br>
+        SourceLocation SrcExprEndLoc =<br>
+            getLocForEndOfToken(SrcExpr->getLocEnd());<br>
+        if (InstanceMethod->isPropertyAccessor())<br>
+          if (const ObjCPropertyDecl *PDecl =<br>
+                  InstanceMethod->findPropertyDecl()) {<br>
+            // fixit: ObjectExpr.propertyname when it is  aproperty accessor.<br>
+            ExpressionString = ".";<br>
+            ExpressionString += PDecl->getNameAsString();<br>
+            Diag(Loc, diag::err_objc_bridged_related_known_method)<br>
+                << SrcType << DestType << InstanceMethod->getSelector() << true<br>
+                << FixItHint::CreateInsertion(SrcExprEndLoc, ExpressionString);<br>
+          }<br>
+        if (ExpressionString.empty()) {<br>
+          // Provide a fixit: [ObjectExpr InstanceMethod]<br>
+          ExpressionString = " ";<br>
+          ExpressionString += InstanceMethod->getSelector().getAsString();<br>
+          ExpressionString += "]";<br>
+<br>
           Diag(Loc, diag::err_objc_bridged_related_known_method)<br>
-          << SrcType << DestType << InstanceMethod->getSelector() << true<br>
-          << FixItHint::CreateInsertion(SrcExprEndLoc, ExpressionString);<br>
+              << SrcType << DestType << InstanceMethod->getSelector() << true<br>
+              << FixItHint::CreateInsertion(SrcExpr->getLocStart(), "[")<br>
+              << FixItHint::CreateInsertion(SrcExprEndLoc, ExpressionString);<br>
         }<br>
-      if (ExpressionString.empty()) {<br>
-        // Provide a fixit: [ObjectExpr InstanceMethod]<br>
-        ExpressionString = " ";<br>
-        ExpressionString += InstanceMethod->getSelector().getAsString();<br>
-        ExpressionString += "]";<br>
-<br>
-        Diag(Loc, diag::err_objc_bridged_related_known_method)<br>
-        << SrcType << DestType << InstanceMethod->getSelector() << true<br>
-        << FixItHint::CreateInsertion(SrcExpr->getLocStart(), "[")<br>
-        << FixItHint::CreateInsertion(SrcExprEndLoc, ExpressionString);<br>
+        Diag(RelatedClass->getLocStart(), diag::note_declared_at);<br>
+        Diag(TDNDecl->getLocStart(), diag::note_declared_at);<br>
       }<br>
-      Diag(RelatedClass->getLocStart(), diag::note_declared_at);<br>
-      Diag(TDNDecl->getLocStart(), diag::note_declared_at);<br>
<br>
       ExprResult msg =<br>
         BuildInstanceMessageImplicit(SrcExpr, SrcType,<br>
@@ -3965,6 +3979,7 @@ Sema::CheckObjCBridgeRelatedConversions(<br>
 Sema::ARCConversionResult<br>
 Sema::CheckObjCARCConversion(SourceRange castRange, QualType castType,<br>
                              Expr *&castExpr, CheckedConversionKind CCK,<br>
+                             bool Diagnose,<br>
                              bool DiagnoseCFAudited,<br>
                              BinaryOperatorKind Opc) {<br>
   QualType castExprType = castExpr->getType();<br>
@@ -3980,9 +3995,9 @@ Sema::CheckObjCARCConversion(SourceRange<br>
   if (exprACTC == castACTC) {<br>
     // check for viablity and report error if casting an rvalue to a<br>
     // life-time qualifier.<br>
-    if ((castACTC == ACTC_retainable) &&<br>
+    if (Diagnose && castACTC == ACTC_retainable &&<br>
         (CCK == CCK_CStyleCast || CCK == CCK_OtherCast) &&<br>
-        (castType != castExprType)) {<br>
+        castType != castExprType) {<br>
       const Type *DT = castType.getTypePtr();<br>
       QualType QDT = castType;<br>
       // We desugar some types but not others. We ignore those<br>
@@ -4051,19 +4066,20 @@ Sema::CheckObjCARCConversion(SourceRange<br>
   // to 'NSString *'. Let caller issue a normal mismatched diagnostic with<br>
   // suitable fix-it.<br>
   if (castACTC == ACTC_retainable && exprACTC == ACTC_none &&<br>
-      ConversionToObjCStringLiteralCheck(castType, castExpr))<br>
+      ConversionToObjCStringLiteralCheck(castType, castExpr, Diagnose))<br>
     return ACR_okay;<br>
<br>
   // Do not issue "bridge cast" diagnostic when implicit casting<br>
   // a retainable object to a CF type parameter belonging to an audited<br>
   // CF API function. Let caller issue a normal type mismatched diagnostic<br>
   // instead.<br>
-  if (!DiagnoseCFAudited || exprACTC != ACTC_retainable ||<br>
-      castACTC != ACTC_coreFoundation)<br>
+  if (Diagnose &&<br>
+      (!DiagnoseCFAudited || exprACTC != ACTC_retainable ||<br>
+        castACTC != ACTC_coreFoundation))<br>
     if (!(exprACTC == ACTC_voidPtr && castACTC == ACTC_retainable &&<br>
           (Opc == BO_NE || Opc == BO_EQ)))<br>
-      diagnoseObjCARCConversion(*this, castRange, castType, castACTC,<br>
-                                castExpr, castExpr, exprACTC, CCK);<br>
+      diagnoseObjCARCConversion(*this, castRange, castType, castACTC, castExpr,<br>
+                                castExpr, exprACTC, CCK);<br>
   return ACR_okay;<br>
 }<br>
<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=257710&r1=257709&r2=257710&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=257710&r1=257709&r2=257710&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Jan 13 17:36:34 2016<br>
@@ -2687,15 +2687,16 @@ bool Sema::FunctionParamTypesAreEqual(co<br>
 bool Sema::CheckPointerConversion(Expr *From, QualType ToType,<br>
                                   CastKind &Kind,<br>
                                   CXXCastPath& BasePath,<br>
-                                  bool IgnoreBaseAccess) {<br>
+                                  bool IgnoreBaseAccess,<br>
+                                  bool Diagnose) {<br>
   QualType FromType = From->getType();<br>
   bool IsCStyleOrFunctionalCast = IgnoreBaseAccess;<br>
<br>
   Kind = CK_BitCast;<br>
<br>
-  if (!IsCStyleOrFunctionalCast && !FromType->isAnyPointerType() &&<br>
+  if (Diagnose && !IsCStyleOrFunctionalCast && !FromType->isAnyPointerType() &&<br>
       From->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNotNull) ==<br>
-      Expr::NPCK_ZeroExpression) {<br>
+          Expr::NPCK_ZeroExpression) {<br>
     if (Context.hasSameUnqualifiedType(From->getType(), Context.BoolTy))<br>
       DiagRuntimeBehavior(From->getExprLoc(), From,<br>
                           PDiag(diag::warn_impcast_bool_to_null_pointer)<br>
@@ -2713,18 +2714,24 @@ bool Sema::CheckPointerConversion(Expr *<br>
           !Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType)) {<br>
         // We must have a derived-to-base conversion. Check an<br>
         // ambiguous or inaccessible conversion.<br>
-        if (CheckDerivedToBaseConversion(FromPointeeType, ToPointeeType,<br>
-                                         From->getExprLoc(),<br>
-                                         From->getSourceRange(), &BasePath,<br>
-                                         IgnoreBaseAccess))<br>
+        unsigned InaccessibleID = 0;<br>
+        unsigned AmbigiousID = 0;<br>
+        if (Diagnose) {<br>
+          InaccessibleID = diag::err_upcast_to_inaccessible_base;<br>
+          AmbigiousID = diag::err_ambiguous_derived_to_base_conv;<br>
+        }<br>
+        if (CheckDerivedToBaseConversion(<br>
+                FromPointeeType, ToPointeeType, InaccessibleID, AmbigiousID,<br>
+                From->getExprLoc(), From->getSourceRange(), DeclarationName(),<br>
+                &BasePath, IgnoreBaseAccess))<br>
           return true;<br>
<br>
         // The conversion was successful.<br>
         Kind = CK_DerivedToBase;<br>
       }<br>
<br>
-      if (!IsCStyleOrFunctionalCast && FromPointeeType->isFunctionType() &&<br>
-          ToPointeeType->isVoidType()) {<br>
+      if (Diagnose && !IsCStyleOrFunctionalCast &&<br>
+          FromPointeeType->isFunctionType() && ToPointeeType->isVoidType()) {<br>
         assert(getLangOpts().MSVCCompat &&<br>
                "this should only be possible with MSVCCompat!");<br>
         Diag(From->getExprLoc(), diag::ext_ms_impcast_fn_obj)<br>
<br>
Added: cfe/trunk/test/SemaObjC/ovl-check.m<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/ovl-check.m?rev=257710&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/ovl-check.m?rev=257710&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/SemaObjC/ovl-check.m (added)<br>
+++ cfe/trunk/test/SemaObjC/ovl-check.m Wed Jan 13 17:36:34 2016<br>
@@ -0,0 +1,55 @@<br>
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -verify %s -fobjc-arc<br>
+//<br>
+// These tests exist as a means to help ensure that diagnostics aren't printed<br>
+// in overload resolution in ObjC.<br>
+<br>
+struct Type1 { int a; };<br>
+@interface Iface1 @end<br>
+<br>
+@interface NeverCalled<br>
+- (void) test:(struct Type1 *)arg;<br>
+@end<br>
+<br>
+@interface TakesIface1<br>
+- (void) test:(Iface1 *)arg;<br>
+@end<br>
+<br>
+// PR26085, rdar://problem/24111333<br>
+void testTakesIface1(id x, Iface1 *arg) {<br>
+  // This should resolve silently to `TakesIface1`.<br>
+  [x test:arg];<br>
+}<br>
+<br>
+@class NSString;<br>
+@interface NeverCalledv2<br>
+- (void) testStr:(NSString *)arg;<br>
+@end<br>
+<br>
+@interface TakesVanillaConstChar<br>
+- (void) testStr:(const void *)a;<br>
+@end<br>
+<br>
+// Not called out explicitly by PR26085, but related.<br>
+void testTakesNSString(id x) {<br>
+  // Overload resolution should not emit a diagnostic about needing to add an<br>
+  // '@' before "someStringLiteral".<br>
+  [x testStr:"someStringLiteral"];<br>
+}<br>
+<br>
+typedef const void *CFTypeRef;<br>
+id CreateSomething();<br>
+<br>
+@interface NeverCalledv3<br>
+- (void) testCFTypeRef:(struct Type1 *)arg;<br>
+@end<br>
+<br>
+@interface TakesCFTypeRef<br>
+- (void) testCFTypeRef:(CFTypeRef)arg;<br>
+@end<br>
+<br>
+// Not called out explicitly by PR26085, but related.<br>
+void testTakesCFTypeRef(id x) {<br>
+  // Overload resolution should occur silently, select the CFTypeRef overload,<br>
+  // and produce a single complaint. (with notes)<br>
+  [x testCFTypeRef:CreateSomething()]; // expected-error{{implicit conversion of Objective-C pointer type 'id' to C pointer type 'CFTypeRef'}} expected-note{{use __bridge}} expected-note{{use __bridge_retained}}<br>
+}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>