bool IsInstanceSuper,
QualType SuperType,
Selector Sel,
- SourceLocation SelLoc,
+ ArrayRef<SourceLocation> SelLocs,
ObjCMethodDecl *Method,
Expr **Args, unsigned NumArgs,
SourceLocation RBracLoc) {
NumArgs * sizeof(Expr *);
void *Mem = Context.Allocate(Size, llvm::AlignOf<ObjCMessageExpr>::Alignment);
return new (Mem) ObjCMessageExpr(T, VK, LBracLoc, SuperLoc, IsInstanceSuper,
- SuperType, Sel, SelLoc, Method, Args,NumArgs,
- RBracLoc);
+ SuperType, Sel, SelLocs.front(), Method,
+ Args, NumArgs, RBracLoc);
}
ObjCMessageExpr *ObjCMessageExpr::Create(ASTContext &Context, QualType T,
SourceLocation LBracLoc,
TypeSourceInfo *Receiver,
Selector Sel,
- SourceLocation SelLoc,
+ ArrayRef<SourceLocation> SelLocs,
ObjCMethodDecl *Method,
Expr **Args, unsigned NumArgs,
SourceLocation RBracLoc) {
unsigned Size = sizeof(ObjCMessageExpr) + sizeof(void *) +
NumArgs * sizeof(Expr *);
void *Mem = Context.Allocate(Size, llvm::AlignOf<ObjCMessageExpr>::Alignment);
- return new (Mem) ObjCMessageExpr(T, VK, LBracLoc, Receiver, Sel, SelLoc,
+ return new (Mem) ObjCMessageExpr(T, VK, LBracLoc, Receiver, Sel,
+ SelLocs.front(),
Method, Args, NumArgs, RBracLoc);
}
SourceLocation LBracLoc,
Expr *Receiver,
Selector Sel,
- SourceLocation SelLoc,
+ ArrayRef<SourceLocation> SelLocs,
ObjCMethodDecl *Method,
Expr **Args, unsigned NumArgs,
SourceLocation RBracLoc) {
unsigned Size = sizeof(ObjCMessageExpr) + sizeof(void *) +
NumArgs * sizeof(Expr *);
void *Mem = Context.Allocate(Size, llvm::AlignOf<ObjCMessageExpr>::Alignment);
- return new (Mem) ObjCMessageExpr(T, VK, LBracLoc, Receiver, Sel, SelLoc,
+ return new (Mem) ObjCMessageExpr(T, VK, LBracLoc, Receiver, Sel,
+ SelLocs.front(),
Method, Args, NumArgs, RBracLoc);
}
SourceLocation Loc;
IdentifierInfo *selIdent = ParseObjCSelectorPiece(Loc);
- SourceLocation SelectorLoc = Loc;
-
SmallVector<IdentifierInfo *, 12> KeyIdents;
+ SmallVector<SourceLocation, 12> KeyLocs;
ExprVector KeyExprs(Actions);
if (Tok.is(tok::colon)) {
while (1) {
// Each iteration parses a single keyword argument.
KeyIdents.push_back(selIdent);
+ KeyLocs.push_back(Loc);
if (Tok.isNot(tok::colon)) {
Diag(Tok, diag::err_expected_colon);
SourceLocation RBracLoc = ConsumeBracket(); // consume ']'
unsigned nKeys = KeyIdents.size();
- if (nKeys == 0)
+ if (nKeys == 0) {
KeyIdents.push_back(selIdent);
+ KeyLocs.push_back(Loc);
+ }
Selector Sel = PP.getSelectorTable().getSelector(nKeys, &KeyIdents[0]);
if (SuperLoc.isValid())
return Actions.ActOnSuperMessage(getCurScope(), SuperLoc, Sel,
- LBracLoc, SelectorLoc, RBracLoc,
+ LBracLoc, KeyLocs, RBracLoc,
MultiExprArg(Actions,
KeyExprs.take(),
KeyExprs.size()));
else if (ReceiverType)
return Actions.ActOnClassMessage(getCurScope(), ReceiverType, Sel,
- LBracLoc, SelectorLoc, RBracLoc,
+ LBracLoc, KeyLocs, RBracLoc,
MultiExprArg(Actions,
KeyExprs.take(),
KeyExprs.size()));
return Actions.ActOnInstanceMessage(getCurScope(), ReceiverExpr, Sel,
- LBracLoc, SelectorLoc, RBracLoc,
+ LBracLoc, KeyLocs, RBracLoc,
MultiExprArg(Actions,
KeyExprs.take(),
KeyExprs.size()));
SourceLocation SuperLoc,
Selector Sel,
SourceLocation LBracLoc,
- SourceLocation SelectorLoc,
+ ArrayRef<SourceLocation> SelectorLocs,
SourceLocation RBracLoc,
MultiExprArg Args) {
// Determine whether we are inside a method or not.
SuperTy = Context.getObjCObjectPointerType(SuperTy);
return BuildInstanceMessage(0, SuperTy, SuperLoc,
Sel, /*Method=*/0,
- LBracLoc, SelectorLoc, RBracLoc, move(Args));
+ LBracLoc, SelectorLocs, RBracLoc, move(Args));
}
// Since we are in a class method, this is a class message to
return BuildClassMessage(/*ReceiverTypeInfo=*/0,
Context.getObjCInterfaceType(Super),
SuperLoc, Sel, /*Method=*/0,
- LBracLoc, SelectorLoc, RBracLoc, move(Args));
+ LBracLoc, SelectorLocs, RBracLoc, move(Args));
}
/// \brief Build an Objective-C class message expression.
Selector Sel,
ObjCMethodDecl *Method,
SourceLocation LBracLoc,
- SourceLocation SelectorLoc,
+ ArrayRef<SourceLocation> SelectorLocs,
SourceLocation RBracLoc,
MultiExprArg ArgsIn) {
SourceLocation Loc = SuperLoc.isValid()? SuperLoc
assert(SuperLoc.isInvalid() && "Message to super with dependent type");
return Owned(ObjCMessageExpr::Create(Context, ReceiverType,
VK_RValue, LBracLoc, ReceiverTypeInfo,
- Sel, SelectorLoc, /*Method=*/0,
+ Sel, SelectorLocs, /*Method=*/0,
Args, NumArgs, RBracLoc));
}
if (SuperLoc.isValid())
Result = ObjCMessageExpr::Create(Context, ReturnType, VK, LBracLoc,
SuperLoc, /*IsInstanceSuper=*/false,
- ReceiverType, Sel, SelectorLoc,
+ ReceiverType, Sel, SelectorLocs,
Method, Args, NumArgs, RBracLoc);
else
Result = ObjCMessageExpr::Create(Context, ReturnType, VK, LBracLoc,
- ReceiverTypeInfo, Sel, SelectorLoc,
+ ReceiverTypeInfo, Sel, SelectorLocs,
Method, Args, NumArgs, RBracLoc);
return MaybeBindToTemporary(Result);
}
ParsedType Receiver,
Selector Sel,
SourceLocation LBracLoc,
- SourceLocation SelectorLoc,
+ ArrayRef<SourceLocation> SelectorLocs,
SourceLocation RBracLoc,
MultiExprArg Args) {
TypeSourceInfo *ReceiverTypeInfo;
return BuildClassMessage(ReceiverTypeInfo, ReceiverType,
/*SuperLoc=*/SourceLocation(), Sel, /*Method=*/0,
- LBracLoc, SelectorLoc, RBracLoc, move(Args));
+ LBracLoc, SelectorLocs, RBracLoc, move(Args));
}
/// \brief Build an Objective-C instance message expression.
Selector Sel,
ObjCMethodDecl *Method,
SourceLocation LBracLoc,
- SourceLocation SelectorLoc,
+ ArrayRef<SourceLocation> SelectorLocs,
SourceLocation RBracLoc,
MultiExprArg ArgsIn) {
// The location of the receiver.
assert(SuperLoc.isInvalid() && "Message to super with dependent type");
return Owned(ObjCMessageExpr::Create(Context, Context.DependentTy,
VK_RValue, LBracLoc, Receiver, Sel,
- SelectorLoc, /*Method=*/0,
+ SelectorLocs, /*Method=*/0,
Args, NumArgs, RBracLoc));
}
Sel,
Method,
LBracLoc,
- SelectorLoc,
+ SelectorLocs,
RBracLoc,
move(ArgsIn));
} else {
diag::err_illegal_message_expr_incomplete_type))
return ExprError();
+ SourceLocation SelLoc = SelectorLocs.front();
+
// In ARC, forbid the user from sending messages to
// retain/release/autorelease/dealloc/retainCount explicitly.
if (getLangOptions().ObjCAutoRefCount) {
case OMF_autorelease:
case OMF_retainCount:
Diag(Loc, diag::err_arc_illegal_explicit_message)
- << Sel << SelectorLoc;
+ << Sel << SelLoc;
break;
case OMF_performSelector:
// Issue error, unless ns_returns_not_retained.
if (!SelMethod->hasAttr<NSReturnsNotRetainedAttr>()) {
// selector names a +1 method
- Diag(SelectorLoc,
+ Diag(SelLoc,
diag::err_arc_perform_selector_retains);
Diag(SelMethod->getLocation(), diag::note_method_declared_at);
}
// +0 call. OK. unless ns_returns_retained.
if (SelMethod->hasAttr<NSReturnsRetainedAttr>()) {
// selector names a +1 method
- Diag(SelectorLoc,
+ Diag(SelLoc,
diag::err_arc_perform_selector_retains);
Diag(SelMethod->getLocation(), diag::note_method_declared_at);
}
}
} else {
// error (may leak).
- Diag(SelectorLoc, diag::warn_arc_perform_selector_leaks);
+ Diag(SelLoc, diag::warn_arc_perform_selector_leaks);
Diag(Args[0]->getExprLoc(), diag::note_used_here);
}
}
if (SuperLoc.isValid())
Result = ObjCMessageExpr::Create(Context, ReturnType, VK, LBracLoc,
SuperLoc, /*IsInstanceSuper=*/true,
- ReceiverType, Sel, SelectorLoc, Method,
+ ReceiverType, Sel, SelectorLocs, Method,
Args, NumArgs, RBracLoc);
else
Result = ObjCMessageExpr::Create(Context, ReturnType, VK, LBracLoc,
- Receiver, Sel, SelectorLoc, Method,
+ Receiver, Sel, SelectorLocs, Method,
Args, NumArgs, RBracLoc);
if (getLangOptions().ObjCAutoRefCount) {
Expr *Receiver,
Selector Sel,
SourceLocation LBracLoc,
- SourceLocation SelectorLoc,
+ ArrayRef<SourceLocation> SelectorLocs,
SourceLocation RBracLoc,
MultiExprArg Args) {
if (!Receiver)
return BuildInstanceMessage(Receiver, Receiver->getType(),
/*SuperLoc=*/SourceLocation(), Sel, /*Method=*/0,
- LBracLoc, SelectorLoc, RBracLoc, move(Args));
+ LBracLoc, SelectorLocs, RBracLoc, move(Args));
}
enum ARCConversionTypeClass {