diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2013-07-31 21:40:51 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2013-07-31 21:40:51 +0000 |
commit | 25eef19b48548a0f0e34961a4c0b59e380ac7149 (patch) | |
tree | 78b276027f2762633bd3d1e733e4169a7b8f5099 | |
parent | 753663ccce3d0abe100a76f13684ca09f092c723 (diff) | |
download | bcm5719-llvm-25eef19b48548a0f0e34961a4c0b59e380ac7149.tar.gz bcm5719-llvm-25eef19b48548a0f0e34961a4c0b59e380ac7149.zip |
ObjectiveC ARC: Do not issue bridge cast diagnostic when
passing a retainable object arg to a CF audited function
expecting a CF object type. Issue a normal type mismatch
diagnostic. This is wip // rdar://14569171
llvm-svn: 187532
-rw-r--r-- | clang/include/clang/Sema/Sema.h | 6 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExprObjC.cpp | 13 | ||||
-rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 3 |
4 files changed, 20 insertions, 8 deletions
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index 6d712ed633e..c72388e039a 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -7045,7 +7045,8 @@ public: // this routine performs the default function/array converions. AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, - bool Diagnose = true); + bool Diagnose = true, + bool DiagnoseCFAudited = false); // \brief If the lhs type is a transparent union, check whether we // can initialize the transparent union with the given expression. @@ -7224,7 +7225,8 @@ public: /// retainable pointers and other pointer kinds. ARCConversionResult CheckObjCARCConversion(SourceRange castRange, QualType castType, Expr *&op, - CheckedConversionKind CCK); + CheckedConversionKind CCK, + bool DiagnoseCFAudited = false); Expr *stripARCUnbridgedCast(Expr *e); void diagnoseARCUnbridgedCast(Expr *e); diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index b321ad1172b..c687f192931 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -6379,7 +6379,8 @@ Sema::CheckTransparentUnionArgumentConstraints(QualType ArgType, Sema::AssignConvertType Sema::CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, - bool Diagnose) { + bool Diagnose, + bool DiagnoseCFAudited) { if (getLangOpts().CPlusPlus) { if (!LHSType->isRecordType() && !LHSType->isAtomicType()) { // C++ 5.17p3: If the left operand is not of class type, the @@ -6456,7 +6457,8 @@ Sema::CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, QualType Ty = LHSType.getNonLValueExprType(Context); Expr *E = RHS.take(); if (getLangOpts().ObjCAutoRefCount) - CheckObjCARCConversion(SourceRange(), Ty, E, CCK_ImplicitConversion); + CheckObjCARCConversion(SourceRange(), Ty, E, CCK_ImplicitConversion, + DiagnoseCFAudited); RHS = ImpCastExprToType(E, Ty, Kind); } return result; diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp index 2944422c555..de0daca4b8b 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -3157,7 +3157,8 @@ diagnoseObjCARCConversion(Sema &S, SourceRange castRange, Sema::ARCConversionResult Sema::CheckObjCARCConversion(SourceRange castRange, QualType castType, - Expr *&castExpr, CheckedConversionKind CCK) { + Expr *&castExpr, CheckedConversionKind CCK, + bool DiagnoseCFAudited) { QualType castExprType = castExpr->getType(); // For the purposes of the classification, we assume reference types @@ -3238,8 +3239,14 @@ Sema::CheckObjCARCConversion(SourceRange castRange, QualType castType, CCK != CCK_ImplicitConversion) return ACR_unbridged; - diagnoseObjCARCConversion(*this, castRange, castType, castACTC, - castExpr, castExpr, exprACTC, CCK); + // Do not issue "bridge cast" diagnostic when implicit casting + // a retainable object to a CF type parameter belonging to an audited + // CF API function. Let caller issue a normal type mismatched diagnostic + // instead. + if (!DiagnoseCFAudited || exprACTC != ACTC_retainable || + castACTC != ACTC_coreFoundation) + diagnoseObjCARCConversion(*this, castRange, castType, castACTC, + castExpr, castExpr, exprACTC, CCK); return ACR_okay; } diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 27087675f6f..b718f4fa86c 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -5979,7 +5979,8 @@ InitializationSequence::Perform(Sema &S, QualType SourceType = CurInit.get()->getType(); ExprResult Result = CurInit; Sema::AssignConvertType ConvTy = - S.CheckSingleAssignmentConstraints(Step->Type, Result); + S.CheckSingleAssignmentConstraints(Step->Type, Result, true, + Entity.getKind() == InitializedEntity::EK_Parameter_CF_Audited); if (Result.isInvalid()) return ExprError(); CurInit = Result; |