Lines Matching refs:Msg

26 static bool checkForLiteralCreation(const ObjCMessageExpr *Msg,  in checkForLiteralCreation()  argument
29 if (!Msg || Msg->isImplicit() || !Msg->getMethodDecl()) in checkForLiteralCreation()
32 const ObjCInterfaceDecl *Receiver = Msg->getReceiverInterface(); in checkForLiteralCreation()
37 if (Msg->getReceiverKind() == ObjCMessageExpr::Class) in checkForLiteralCreation()
43 if (Msg->getReceiverKind() == ObjCMessageExpr::Instance) { in checkForLiteralCreation()
45 Msg->getInstanceReceiver()->IgnoreParenImpCasts())) { in checkForLiteralCreation()
59 bool edit::rewriteObjCRedundantCallWithLiteral(const ObjCMessageExpr *Msg, in rewriteObjCRedundantCallWithLiteral() argument
62 if (!checkForLiteralCreation(Msg, II, NS.getASTContext().getLangOpts())) in rewriteObjCRedundantCallWithLiteral()
64 if (Msg->getNumArgs() != 1) in rewriteObjCRedundantCallWithLiteral()
67 const Expr *Arg = Msg->getArg(0)->IgnoreParenImpCasts(); in rewriteObjCRedundantCallWithLiteral()
68 Selector Sel = Msg->getSelector(); in rewriteObjCRedundantCallWithLiteral()
86 commit.replaceWithInner(Msg->getSourceRange(), in rewriteObjCRedundantCallWithLiteral()
87 Msg->getArg(0)->getSourceRange()); in rewriteObjCRedundantCallWithLiteral()
157 const ObjCMessageExpr *Msg, in canRewriteToSubscriptSyntax() argument
160 const Expr *Rec = Msg->getInstanceReceiver(); in canRewriteToSubscriptSyntax()
181 static bool rewriteToSubscriptGetCommon(const ObjCMessageExpr *Msg, in rewriteToSubscriptGetCommon() argument
183 if (Msg->getNumArgs() != 1) in rewriteToSubscriptGetCommon()
185 const Expr *Rec = Msg->getInstanceReceiver(); in rewriteToSubscriptGetCommon()
189 SourceRange MsgRange = Msg->getSourceRange(); in rewriteToSubscriptGetCommon()
191 SourceRange ArgRange = Msg->getArg(0)->getSourceRange(); in rewriteToSubscriptGetCommon()
204 const ObjCMessageExpr *Msg, in rewriteToArraySubscriptGet() argument
207 if (!canRewriteToSubscriptSyntax(IFace, Msg, NS.getASTContext(), in rewriteToArraySubscriptGet()
210 return rewriteToSubscriptGetCommon(Msg, commit); in rewriteToArraySubscriptGet()
214 const ObjCMessageExpr *Msg, in rewriteToDictionarySubscriptGet() argument
217 if (!canRewriteToSubscriptSyntax(IFace, Msg, NS.getASTContext(), in rewriteToDictionarySubscriptGet()
220 return rewriteToSubscriptGetCommon(Msg, commit); in rewriteToDictionarySubscriptGet()
224 const ObjCMessageExpr *Msg, in rewriteToArraySubscriptSet() argument
227 if (!canRewriteToSubscriptSyntax(IFace, Msg, NS.getASTContext(), in rewriteToArraySubscriptSet()
231 if (Msg->getNumArgs() != 2) in rewriteToArraySubscriptSet()
233 const Expr *Rec = Msg->getInstanceReceiver(); in rewriteToArraySubscriptSet()
237 SourceRange MsgRange = Msg->getSourceRange(); in rewriteToArraySubscriptSet()
239 SourceRange Arg0Range = Msg->getArg(0)->getSourceRange(); in rewriteToArraySubscriptSet()
240 SourceRange Arg1Range = Msg->getArg(1)->getSourceRange(); in rewriteToArraySubscriptSet()
258 const ObjCMessageExpr *Msg, in rewriteToDictionarySubscriptSet() argument
261 if (!canRewriteToSubscriptSyntax(IFace, Msg, NS.getASTContext(), in rewriteToDictionarySubscriptSet()
265 if (Msg->getNumArgs() != 2) in rewriteToDictionarySubscriptSet()
267 const Expr *Rec = Msg->getInstanceReceiver(); in rewriteToDictionarySubscriptSet()
271 SourceRange MsgRange = Msg->getSourceRange(); in rewriteToDictionarySubscriptSet()
273 SourceRange Arg0Range = Msg->getArg(0)->getSourceRange(); in rewriteToDictionarySubscriptSet()
274 SourceRange Arg1Range = Msg->getArg(1)->getSourceRange(); in rewriteToDictionarySubscriptSet()
290 bool edit::rewriteToObjCSubscriptSyntax(const ObjCMessageExpr *Msg, in rewriteToObjCSubscriptSyntax() argument
292 if (!Msg || Msg->isImplicit() || in rewriteToObjCSubscriptSyntax()
293 Msg->getReceiverKind() != ObjCMessageExpr::Instance) in rewriteToObjCSubscriptSyntax()
295 const ObjCMethodDecl *Method = Msg->getMethodDecl(); in rewriteToObjCSubscriptSyntax()
303 Selector Sel = Msg->getSelector(); in rewriteToObjCSubscriptSyntax()
306 return rewriteToArraySubscriptGet(IFace, Msg, NS, commit); in rewriteToObjCSubscriptSyntax()
309 return rewriteToDictionarySubscriptGet(IFace, Msg, NS, commit); in rewriteToObjCSubscriptSyntax()
311 if (Msg->getNumArgs() != 2) in rewriteToObjCSubscriptSyntax()
315 return rewriteToArraySubscriptSet(IFace, Msg, NS, commit); in rewriteToObjCSubscriptSyntax()
318 return rewriteToDictionarySubscriptSet(IFace, Msg, NS, commit); in rewriteToObjCSubscriptSyntax()
327 static bool rewriteToArrayLiteral(const ObjCMessageExpr *Msg,
330 static bool rewriteToDictionaryLiteral(const ObjCMessageExpr *Msg,
332 static bool rewriteToNumberLiteral(const ObjCMessageExpr *Msg,
334 static bool rewriteToNumericBoxedExpression(const ObjCMessageExpr *Msg,
336 static bool rewriteToStringBoxedExpression(const ObjCMessageExpr *Msg,
339 bool edit::rewriteToObjCLiteralSyntax(const ObjCMessageExpr *Msg, in rewriteToObjCLiteralSyntax() argument
343 if (!checkForLiteralCreation(Msg, II, NS.getASTContext().getLangOpts())) in rewriteToObjCLiteralSyntax()
347 return rewriteToArrayLiteral(Msg, NS, commit, PMap); in rewriteToObjCLiteralSyntax()
349 return rewriteToDictionaryLiteral(Msg, NS, commit); in rewriteToObjCLiteralSyntax()
351 return rewriteToNumberLiteral(Msg, NS, commit); in rewriteToObjCLiteralSyntax()
353 return rewriteToStringBoxedExpression(Msg, NS, commit); in rewriteToObjCLiteralSyntax()
368 static bool shouldNotRewriteImmediateMessageArgs(const ObjCMessageExpr *Msg,
378 static bool rewriteToArrayLiteral(const ObjCMessageExpr *Msg, in rewriteToArrayLiteral() argument
383 dyn_cast_or_null<ObjCMessageExpr>(PMap->getParentIgnoreParenCasts(Msg)); in rewriteToArrayLiteral()
388 Selector Sel = Msg->getSelector(); in rewriteToArrayLiteral()
389 SourceRange MsgRange = Msg->getSourceRange(); in rewriteToArrayLiteral()
392 if (Msg->getNumArgs() != 0) in rewriteToArrayLiteral()
399 if (Msg->getNumArgs() != 1) in rewriteToArrayLiteral()
401 objectifyExpr(Msg->getArg(0), commit); in rewriteToArrayLiteral()
402 SourceRange ArgRange = Msg->getArg(0)->getSourceRange(); in rewriteToArrayLiteral()
410 if (Msg->getNumArgs() == 0) in rewriteToArrayLiteral()
412 const Expr *SentinelExpr = Msg->getArg(Msg->getNumArgs() - 1); in rewriteToArrayLiteral()
416 for (unsigned i = 0, e = Msg->getNumArgs() - 1; i != e; ++i) in rewriteToArrayLiteral()
417 objectifyExpr(Msg->getArg(i), commit); in rewriteToArrayLiteral()
419 if (Msg->getNumArgs() == 1) { in rewriteToArrayLiteral()
423 SourceRange ArgRange(Msg->getArg(0)->getBeginLoc(), in rewriteToArrayLiteral()
424 Msg->getArg(Msg->getNumArgs() - 2)->getEndLoc()); in rewriteToArrayLiteral()
449 if (const ObjCMessageExpr *Msg = dyn_cast<ObjCMessageExpr>(E)) { in getNSArrayObjects() local
451 if (!checkForLiteralCreation(Msg, Cls, NS.getASTContext().getLangOpts())) in getNSArrayObjects()
457 Selector Sel = Msg->getSelector(); in getNSArrayObjects()
462 if (Msg->getNumArgs() != 1) in getNSArrayObjects()
464 Objs.push_back(Msg->getArg(0)); in getNSArrayObjects()
470 if (Msg->getNumArgs() == 0) in getNSArrayObjects()
472 const Expr *SentinelExpr = Msg->getArg(Msg->getNumArgs() - 1); in getNSArrayObjects()
476 for (unsigned i = 0, e = Msg->getNumArgs() - 1; i != e; ++i) in getNSArrayObjects()
477 Objs.push_back(Msg->getArg(i)); in getNSArrayObjects()
490 static bool rewriteToDictionaryLiteral(const ObjCMessageExpr *Msg, in rewriteToDictionaryLiteral() argument
492 Selector Sel = Msg->getSelector(); in rewriteToDictionaryLiteral()
493 SourceRange MsgRange = Msg->getSourceRange(); in rewriteToDictionaryLiteral()
496 if (Msg->getNumArgs() != 0) in rewriteToDictionaryLiteral()
504 if (Msg->getNumArgs() != 2) in rewriteToDictionaryLiteral()
507 objectifyExpr(Msg->getArg(0), commit); in rewriteToDictionaryLiteral()
508 objectifyExpr(Msg->getArg(1), commit); in rewriteToDictionaryLiteral()
510 SourceRange ValRange = Msg->getArg(0)->getSourceRange(); in rewriteToDictionaryLiteral()
511 SourceRange KeyRange = Msg->getArg(1)->getSourceRange(); in rewriteToDictionaryLiteral()
526 if (Msg->getNumArgs() % 2 != 1) in rewriteToDictionaryLiteral()
528 unsigned SentinelIdx = Msg->getNumArgs() - 1; in rewriteToDictionaryLiteral()
529 const Expr *SentinelExpr = Msg->getArg(SentinelIdx); in rewriteToDictionaryLiteral()
533 if (Msg->getNumArgs() == 1) { in rewriteToDictionaryLiteral()
539 objectifyExpr(Msg->getArg(i), commit); in rewriteToDictionaryLiteral()
540 objectifyExpr(Msg->getArg(i+1), commit); in rewriteToDictionaryLiteral()
542 SourceRange ValRange = Msg->getArg(i)->getSourceRange(); in rewriteToDictionaryLiteral()
543 SourceRange KeyRange = Msg->getArg(i+1)->getSourceRange(); in rewriteToDictionaryLiteral()
553 SourceRange ArgRange(Msg->getArg(1)->getBeginLoc(), in rewriteToDictionaryLiteral()
554 Msg->getArg(SentinelIdx - 1)->getEndLoc()); in rewriteToDictionaryLiteral()
563 if (Msg->getNumArgs() != 2) in rewriteToDictionaryLiteral()
567 if (!getNSArrayObjects(Msg->getArg(0), NS, Vals)) in rewriteToDictionaryLiteral()
571 if (!getNSArrayObjects(Msg->getArg(1), NS, Keys)) in rewriteToDictionaryLiteral()
603 static bool shouldNotRewriteImmediateMessageArgs(const ObjCMessageExpr *Msg, in shouldNotRewriteImmediateMessageArgs() argument
605 if (!Msg) in shouldNotRewriteImmediateMessageArgs()
609 if (!checkForLiteralCreation(Msg, II, NS.getASTContext().getLangOpts())) in shouldNotRewriteImmediateMessageArgs()
615 Selector Sel = Msg->getSelector(); in shouldNotRewriteImmediateMessageArgs()
619 if (Msg->getNumArgs() != 2) in shouldNotRewriteImmediateMessageArgs()
623 if (!getNSArrayObjects(Msg->getArg(0), NS, Vals)) in shouldNotRewriteImmediateMessageArgs()
627 if (!getNSArrayObjects(Msg->getArg(1), NS, Keys)) in shouldNotRewriteImmediateMessageArgs()
643 static bool rewriteToCharLiteral(const ObjCMessageExpr *Msg, in rewriteToCharLiteral() argument
649 Msg->getSelector())) { in rewriteToCharLiteral()
651 commit.replaceWithInner(Msg->getSourceRange(), ArgRange); in rewriteToCharLiteral()
656 return rewriteToNumericBoxedExpression(Msg, NS, commit); in rewriteToCharLiteral()
659 static bool rewriteToBoolLiteral(const ObjCMessageExpr *Msg, in rewriteToBoolLiteral() argument
663 Msg->getSelector())) { in rewriteToBoolLiteral()
665 commit.replaceWithInner(Msg->getSourceRange(), ArgRange); in rewriteToBoolLiteral()
670 return rewriteToNumericBoxedExpression(Msg, NS, commit); in rewriteToBoolLiteral()
749 static bool rewriteToNumberLiteral(const ObjCMessageExpr *Msg, in rewriteToNumberLiteral() argument
751 if (Msg->getNumArgs() != 1) in rewriteToNumberLiteral()
754 const Expr *Arg = Msg->getArg(0)->IgnoreParenImpCasts(); in rewriteToNumberLiteral()
756 return rewriteToCharLiteral(Msg, CharE, NS, commit); in rewriteToNumberLiteral()
758 return rewriteToBoolLiteral(Msg, BE, NS, commit); in rewriteToNumberLiteral()
760 return rewriteToBoolLiteral(Msg, BE, NS, commit); in rewriteToNumberLiteral()
771 return rewriteToNumericBoxedExpression(Msg, NS, commit); in rewriteToNumberLiteral()
774 Selector Sel = Msg->getSelector(); in rewriteToNumberLiteral()
791 return rewriteToNumericBoxedExpression(Msg, NS, commit); in rewriteToNumberLiteral()
825 QualType CallTy = Msg->getArg(0)->getType(); in rewriteToNumberLiteral()
829 commit.replaceWithInner(Msg->getSourceRange(), ArgRange); in rewriteToNumberLiteral()
837 return rewriteToNumericBoxedExpression(Msg, NS, commit); in rewriteToNumberLiteral()
844 return rewriteToNumericBoxedExpression(Msg, NS, commit); in rewriteToNumberLiteral()
855 return rewriteToNumericBoxedExpression(Msg, NS, commit); in rewriteToNumberLiteral()
859 return rewriteToNumericBoxedExpression(Msg, NS, commit); in rewriteToNumberLiteral()
864 commit.replaceWithInner(CharSourceRange::getTokenRange(Msg->getSourceRange()), in rewriteToNumberLiteral()
972 static bool rewriteToNumericBoxedExpression(const ObjCMessageExpr *Msg, in rewriteToNumericBoxedExpression() argument
974 if (Msg->getNumArgs() != 1) in rewriteToNumericBoxedExpression()
977 const Expr *Arg = Msg->getArg(0); in rewriteToNumericBoxedExpression()
982 Selector Sel = Msg->getSelector(); in rewriteToNumericBoxedExpression()
1106 Diags.Report(Msg->getExprLoc(), diagID) << OrigTy << FinalTy in rewriteToNumericBoxedExpression()
1107 << Msg->getSourceRange(); in rewriteToNumericBoxedExpression()
1112 commit.replaceWithInner(Msg->getSourceRange(), ArgRange); in rewriteToNumericBoxedExpression()
1127 const ObjCMessageExpr *Msg, in doRewriteToUTF8StringBoxedExpressionHelper() argument
1129 const Expr *Arg = Msg->getArg(0); in doRewriteToUTF8StringBoxedExpressionHelper()
1142 commit.replaceWithInner(Msg->getSourceRange(), StrE->getSourceRange()); in doRewriteToUTF8StringBoxedExpressionHelper()
1151 commit.replaceWithInner(Msg->getSourceRange(), ArgRange); in doRewriteToUTF8StringBoxedExpressionHelper()
1165 static bool rewriteToStringBoxedExpression(const ObjCMessageExpr *Msg, in rewriteToStringBoxedExpression() argument
1167 Selector Sel = Msg->getSelector(); in rewriteToStringBoxedExpression()
1172 if (Msg->getNumArgs() != 1) in rewriteToStringBoxedExpression()
1174 return doRewriteToUTF8StringBoxedExpressionHelper(Msg, NS, commit); in rewriteToStringBoxedExpression()
1178 if (Msg->getNumArgs() != 2) in rewriteToStringBoxedExpression()
1181 const Expr *encodingArg = Msg->getArg(1); in rewriteToStringBoxedExpression()
1184 return doRewriteToUTF8StringBoxedExpressionHelper(Msg, NS, commit); in rewriteToStringBoxedExpression()