summaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExprObjC.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2013-12-16 22:54:37 +0000
committerFariborz Jahanian <fjahanian@apple.com>2013-12-16 22:54:37 +0000
commitbfa7a3ffd11a5f1bdd45e7b203a33b41a75da0ea (patch)
treea9ee17e8820b9f4c59070c74feb155a9e763e23b /lib/Sema/SemaExprObjC.cpp
parentdb087c6586d01bf2c4b3215c5c5475bfd6c322e5 (diff)
downloadclang-bfa7a3ffd11a5f1bdd45e7b203a33b41a75da0ea.tar.gz
clang-bfa7a3ffd11a5f1bdd45e7b203a33b41a75da0ea.tar.bz2
clang-bfa7a3ffd11a5f1bdd45e7b203a33b41a75da0ea.tar.xz
ObjectiveC. Further improvements of use
of objc_bridge_related attribute; eliminate unnecessary diagnostics which is issued elsewhere, fixit now produces a valid AST tree per convention. This results in some simplification in handling of this attribute as well. // rdar://15499111 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197436 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprObjC.cpp')
-rw-r--r--lib/Sema/SemaExprObjC.cpp38
1 files changed, 25 insertions, 13 deletions
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index 9211772a01..905c080e47 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -3431,7 +3431,7 @@ bool Sema::checkObjCBridgeRelatedComponents(SourceLocation Loc,
bool
Sema::CheckObjCBridgeRelatedConversions(SourceLocation Loc,
QualType DestType, QualType SrcType,
- Expr *SrcExpr) {
+ Expr *&SrcExpr) {
ARCConversionTypeClass rhsExprACTC = classifyTypeForARCConversion(SrcType);
ARCConversionTypeClass lhsExprACTC = classifyTypeForARCConversion(DestType);
bool CfToNs = (rhsExprACTC == ACTC_coreFoundation && lhsExprACTC == ACTC_retainable);
@@ -3460,12 +3460,20 @@ Sema::CheckObjCBridgeRelatedConversions(SourceLocation Loc,
<< SrcType << DestType << ClassMethod->getSelector() << false
<< FixItHint::CreateInsertion(SrcExpr->getLocStart(), ExpressionString)
<< FixItHint::CreateInsertion(SrcExprEndLoc, "]");
+ Diag(RelatedClass->getLocStart(), diag::note_declared_at);
+ Diag(TDNDecl->getLocStart(), diag::note_declared_at);
+
+ QualType receiverType =
+ Context.getObjCInterfaceType(RelatedClass);
+ // Argument.
+ Expr *args[] = { SrcExpr };
+ ExprResult msg = BuildClassMessageImplicit(receiverType, false,
+ ClassMethod->getLocation(),
+ ClassMethod->getSelector(), ClassMethod,
+ MultiExprArg(args, 1));
+ SrcExpr = msg.take();
+ return true;
}
- else
- Diag(Loc, diag::err_objc_bridged_related_unknown_method)
- << SrcType << DestType;
- Diag(RelatedClass->getLocStart(), diag::note_declared_at);
- Diag(TDNDecl->getLocStart(), diag::note_declared_at);
}
else {
// Implicit conversion from ObjC type to CF object is needed.
@@ -3492,15 +3500,19 @@ Sema::CheckObjCBridgeRelatedConversions(SourceLocation Loc,
<< FixItHint::CreateInsertion(SrcExpr->getLocStart(), "[")
<< FixItHint::CreateInsertion(SrcExprEndLoc, ExpressionString);
}
+ Diag(RelatedClass->getLocStart(), diag::note_declared_at);
+ Diag(TDNDecl->getLocStart(), diag::note_declared_at);
+
+ ExprResult msg =
+ BuildInstanceMessageImplicit(SrcExpr, SrcType,
+ InstanceMethod->getLocation(),
+ InstanceMethod->getSelector(),
+ InstanceMethod, None);
+ SrcExpr = msg.take();
+ return true;
}
- else
- Diag(Loc, diag::err_objc_bridged_related_unknown_method)
- << SrcType << DestType;
- Diag(RelatedClass->getLocStart(), diag::note_declared_at);
- Diag(TDNDecl->getLocStart(), diag::note_declared_at);
}
-
- return true;
+ return false;
}
Sema::ARCConversionResult