diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-02-25 20:51:14 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-02-25 20:51:14 +0000 |
commit | 5e24f2a4ad3a3623349f058e99c7c71e1c8d705f (patch) | |
tree | 70a005e914da63da479f7b63b05e9bb44e5eebbd /lib/Sema/SemaOverload.cpp | |
parent | 00cf3cc2718671aa48e8da264a523b0058a8591e (diff) |
Sprinkle optional text of the "unavailable' attribute
where ever such attribute causes an error diagnostic.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126509 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 56322d9583..8d03285ee4 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -7701,21 +7701,12 @@ Sema::BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, case OR_Deleted: { - llvm::StringRef Message; - if (const UnavailableAttr *UA = - Best->Function->getAttr<UnavailableAttr>()) - Message = UA->getMessage(); - - if (Message.empty()) - Diag(Fn->getSourceRange().getBegin(), diag::err_ovl_deleted_call) - << Best->Function->isDeleted() - << ULE->getName() - << Fn->getSourceRange(); - else - Diag(Fn->getSourceRange().getBegin(), diag::err_ovl_unavailable_call) - << ULE->getName() - << Message - << Fn->getSourceRange(); + Diag(Fn->getSourceRange().getBegin(), diag::err_ovl_deleted_call) + << Best->Function->isDeleted() + << ULE->getName() + << Best->Function->getMessageUnavailableAttr( + !Best->Function->isDeleted()) + << Fn->getSourceRange(); CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, NumArgs); } break; @@ -7897,6 +7888,8 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn, Diag(OpLoc, diag::err_ovl_deleted_oper) << Best->Function->isDeleted() << UnaryOperator::getOpcodeStr(Opc) + << Best->Function->getMessageUnavailableAttr( + !Best->Function->isDeleted()) << Input->getSourceRange(); CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, NumArgs); return ExprError(); @@ -8165,6 +8158,8 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, Diag(OpLoc, diag::err_ovl_deleted_oper) << Best->Function->isDeleted() << BinaryOperator::getOpcodeStr(Opc) + << Best->Function->getMessageUnavailableAttr( + !Best->Function->isDeleted()) << Args[0]->getSourceRange() << Args[1]->getSourceRange(); CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, 2); return ExprError(); @@ -8313,6 +8308,8 @@ Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, case OR_Deleted: Diag(LLoc, diag::err_ovl_deleted_oper) << Best->Function->isDeleted() << "[]" + << Best->Function->getMessageUnavailableAttr( + !Best->Function->isDeleted()) << Args[0]->getSourceRange() << Args[1]->getSourceRange(); CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, 2, "[]", LLoc); @@ -8429,7 +8426,10 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE, case OR_Deleted: Diag(UnresExpr->getMemberLoc(), diag::err_ovl_deleted_member_call) << Best->Function->isDeleted() - << DeclName << MemExprE->getSourceRange(); + << DeclName + << Best->Function->getMessageUnavailableAttr( + !Best->Function->isDeleted()) + << MemExprE->getSourceRange(); CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, NumArgs); // FIXME: Leaking incoming expressions! return ExprError(); @@ -8601,7 +8601,10 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object, Diag(Object->getSourceRange().getBegin(), diag::err_ovl_deleted_object_call) << Best->Function->isDeleted() - << Object->getType() << Object->getSourceRange(); + << Object->getType() + << Best->Function->getMessageUnavailableAttr( + !Best->Function->isDeleted()) + << Object->getSourceRange(); CandidateSet.NoteCandidates(*this, OCD_AllCandidates, Args, NumArgs); break; } @@ -8807,7 +8810,10 @@ Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc) { case OR_Deleted: Diag(OpLoc, diag::err_ovl_deleted_oper) << Best->Function->isDeleted() - << "->" << Base->getSourceRange(); + << "->" + << Best->Function->getMessageUnavailableAttr( + !Best->Function->isDeleted()) + << Base->getSourceRange(); CandidateSet.NoteCandidates(*this, OCD_AllCandidates, &Base, 1); return ExprError(); } |