Lines Matching refs:Msg
25 static bool checkForLiteralCreation(const ObjCMessageExpr *Msg, in checkForLiteralCreation() argument
28 if (!Msg || Msg->isImplicit() || !Msg->getMethodDecl()) in checkForLiteralCreation()
31 const ObjCInterfaceDecl *Receiver = Msg->getReceiverInterface(); in checkForLiteralCreation()
36 if (Msg->getReceiverKind() == ObjCMessageExpr::Class) in checkForLiteralCreation()
42 if (Msg->getReceiverKind() == ObjCMessageExpr::Instance) { in checkForLiteralCreation()
44 Msg->getInstanceReceiver()->IgnoreParenImpCasts())) { in checkForLiteralCreation()
58 bool edit::rewriteObjCRedundantCallWithLiteral(const ObjCMessageExpr *Msg, in rewriteObjCRedundantCallWithLiteral() argument
61 if (!checkForLiteralCreation(Msg, II, NS.getASTContext().getLangOpts())) in rewriteObjCRedundantCallWithLiteral()
63 if (Msg->getNumArgs() != 1) in rewriteObjCRedundantCallWithLiteral()
66 const Expr *Arg = Msg->getArg(0)->IgnoreParenImpCasts(); in rewriteObjCRedundantCallWithLiteral()
67 Selector Sel = Msg->getSelector(); in rewriteObjCRedundantCallWithLiteral()
85 commit.replaceWithInner(Msg->getSourceRange(), in rewriteObjCRedundantCallWithLiteral()
86 Msg->getArg(0)->getSourceRange()); in rewriteObjCRedundantCallWithLiteral()
156 const ObjCMessageExpr *Msg, in canRewriteToSubscriptSyntax() argument
159 const Expr *Rec = Msg->getInstanceReceiver(); in canRewriteToSubscriptSyntax()
180 static bool rewriteToSubscriptGetCommon(const ObjCMessageExpr *Msg, in rewriteToSubscriptGetCommon() argument
182 if (Msg->getNumArgs() != 1) in rewriteToSubscriptGetCommon()
184 const Expr *Rec = Msg->getInstanceReceiver(); in rewriteToSubscriptGetCommon()
188 SourceRange MsgRange = Msg->getSourceRange(); in rewriteToSubscriptGetCommon()
190 SourceRange ArgRange = Msg->getArg(0)->getSourceRange(); in rewriteToSubscriptGetCommon()
203 const ObjCMessageExpr *Msg, in rewriteToArraySubscriptGet() argument
206 if (!canRewriteToSubscriptSyntax(IFace, Msg, NS.getASTContext(), in rewriteToArraySubscriptGet()
209 return rewriteToSubscriptGetCommon(Msg, commit); in rewriteToArraySubscriptGet()
213 const ObjCMessageExpr *Msg, in rewriteToDictionarySubscriptGet() argument
216 if (!canRewriteToSubscriptSyntax(IFace, Msg, NS.getASTContext(), in rewriteToDictionarySubscriptGet()
219 return rewriteToSubscriptGetCommon(Msg, commit); in rewriteToDictionarySubscriptGet()
223 const ObjCMessageExpr *Msg, in rewriteToArraySubscriptSet() argument
226 if (!canRewriteToSubscriptSyntax(IFace, Msg, NS.getASTContext(), in rewriteToArraySubscriptSet()
230 if (Msg->getNumArgs() != 2) in rewriteToArraySubscriptSet()
232 const Expr *Rec = Msg->getInstanceReceiver(); in rewriteToArraySubscriptSet()
236 SourceRange MsgRange = Msg->getSourceRange(); in rewriteToArraySubscriptSet()
238 SourceRange Arg0Range = Msg->getArg(0)->getSourceRange(); in rewriteToArraySubscriptSet()
239 SourceRange Arg1Range = Msg->getArg(1)->getSourceRange(); in rewriteToArraySubscriptSet()
257 const ObjCMessageExpr *Msg, in rewriteToDictionarySubscriptSet() argument
260 if (!canRewriteToSubscriptSyntax(IFace, Msg, NS.getASTContext(), in rewriteToDictionarySubscriptSet()
264 if (Msg->getNumArgs() != 2) in rewriteToDictionarySubscriptSet()
266 const Expr *Rec = Msg->getInstanceReceiver(); in rewriteToDictionarySubscriptSet()
270 SourceRange MsgRange = Msg->getSourceRange(); in rewriteToDictionarySubscriptSet()
272 SourceRange Arg0Range = Msg->getArg(0)->getSourceRange(); in rewriteToDictionarySubscriptSet()
273 SourceRange Arg1Range = Msg->getArg(1)->getSourceRange(); in rewriteToDictionarySubscriptSet()
289 bool edit::rewriteToObjCSubscriptSyntax(const ObjCMessageExpr *Msg, in rewriteToObjCSubscriptSyntax() argument
291 if (!Msg || Msg->isImplicit() || in rewriteToObjCSubscriptSyntax()
292 Msg->getReceiverKind() != ObjCMessageExpr::Instance) in rewriteToObjCSubscriptSyntax()
294 const ObjCMethodDecl *Method = Msg->getMethodDecl(); in rewriteToObjCSubscriptSyntax()
302 Selector Sel = Msg->getSelector(); in rewriteToObjCSubscriptSyntax()
305 return rewriteToArraySubscriptGet(IFace, Msg, NS, commit); in rewriteToObjCSubscriptSyntax()
308 return rewriteToDictionarySubscriptGet(IFace, Msg, NS, commit); in rewriteToObjCSubscriptSyntax()
310 if (Msg->getNumArgs() != 2) in rewriteToObjCSubscriptSyntax()
314 return rewriteToArraySubscriptSet(IFace, Msg, NS, commit); in rewriteToObjCSubscriptSyntax()
317 return rewriteToDictionarySubscriptSet(IFace, Msg, NS, commit); in rewriteToObjCSubscriptSyntax()
326 static bool rewriteToArrayLiteral(const ObjCMessageExpr *Msg,
329 static bool rewriteToDictionaryLiteral(const ObjCMessageExpr *Msg,
331 static bool rewriteToNumberLiteral(const ObjCMessageExpr *Msg,
333 static bool rewriteToNumericBoxedExpression(const ObjCMessageExpr *Msg,
335 static bool rewriteToStringBoxedExpression(const ObjCMessageExpr *Msg,
338 bool edit::rewriteToObjCLiteralSyntax(const ObjCMessageExpr *Msg, in rewriteToObjCLiteralSyntax() argument
342 if (!checkForLiteralCreation(Msg, II, NS.getASTContext().getLangOpts())) in rewriteToObjCLiteralSyntax()
346 return rewriteToArrayLiteral(Msg, NS, commit, PMap); in rewriteToObjCLiteralSyntax()
348 return rewriteToDictionaryLiteral(Msg, NS, commit); in rewriteToObjCLiteralSyntax()
350 return rewriteToNumberLiteral(Msg, NS, commit); in rewriteToObjCLiteralSyntax()
352 return rewriteToStringBoxedExpression(Msg, NS, commit); in rewriteToObjCLiteralSyntax()
367 static bool shouldNotRewriteImmediateMessageArgs(const ObjCMessageExpr *Msg,
377 static bool rewriteToArrayLiteral(const ObjCMessageExpr *Msg, in rewriteToArrayLiteral() argument
382 dyn_cast_or_null<ObjCMessageExpr>(PMap->getParentIgnoreParenCasts(Msg)); in rewriteToArrayLiteral()
387 Selector Sel = Msg->getSelector(); in rewriteToArrayLiteral()
388 SourceRange MsgRange = Msg->getSourceRange(); in rewriteToArrayLiteral()
391 if (Msg->getNumArgs() != 0) in rewriteToArrayLiteral()
398 if (Msg->getNumArgs() != 1) in rewriteToArrayLiteral()
400 objectifyExpr(Msg->getArg(0), commit); in rewriteToArrayLiteral()
401 SourceRange ArgRange = Msg->getArg(0)->getSourceRange(); in rewriteToArrayLiteral()
409 if (Msg->getNumArgs() == 0) in rewriteToArrayLiteral()
411 const Expr *SentinelExpr = Msg->getArg(Msg->getNumArgs() - 1); in rewriteToArrayLiteral()
415 for (unsigned i = 0, e = Msg->getNumArgs() - 1; i != e; ++i) in rewriteToArrayLiteral()
416 objectifyExpr(Msg->getArg(i), commit); in rewriteToArrayLiteral()
418 if (Msg->getNumArgs() == 1) { in rewriteToArrayLiteral()
422 SourceRange ArgRange(Msg->getArg(0)->getBeginLoc(), in rewriteToArrayLiteral()
423 Msg->getArg(Msg->getNumArgs() - 2)->getEndLoc()); in rewriteToArrayLiteral()
448 if (const ObjCMessageExpr *Msg = dyn_cast<ObjCMessageExpr>(E)) { in getNSArrayObjects() local
450 if (!checkForLiteralCreation(Msg, Cls, NS.getASTContext().getLangOpts())) in getNSArrayObjects()
456 Selector Sel = Msg->getSelector(); in getNSArrayObjects()
461 if (Msg->getNumArgs() != 1) in getNSArrayObjects()
463 Objs.push_back(Msg->getArg(0)); in getNSArrayObjects()
469 if (Msg->getNumArgs() == 0) in getNSArrayObjects()
471 const Expr *SentinelExpr = Msg->getArg(Msg->getNumArgs() - 1); in getNSArrayObjects()
475 for (unsigned i = 0, e = Msg->getNumArgs() - 1; i != e; ++i) in getNSArrayObjects()
476 Objs.push_back(Msg->getArg(i)); in getNSArrayObjects()
489 static bool rewriteToDictionaryLiteral(const ObjCMessageExpr *Msg, in rewriteToDictionaryLiteral() argument
491 Selector Sel = Msg->getSelector(); in rewriteToDictionaryLiteral()
492 SourceRange MsgRange = Msg->getSourceRange(); in rewriteToDictionaryLiteral()
495 if (Msg->getNumArgs() != 0) in rewriteToDictionaryLiteral()
503 if (Msg->getNumArgs() != 2) in rewriteToDictionaryLiteral()
506 objectifyExpr(Msg->getArg(0), commit); in rewriteToDictionaryLiteral()
507 objectifyExpr(Msg->getArg(1), commit); in rewriteToDictionaryLiteral()
509 SourceRange ValRange = Msg->getArg(0)->getSourceRange(); in rewriteToDictionaryLiteral()
510 SourceRange KeyRange = Msg->getArg(1)->getSourceRange(); in rewriteToDictionaryLiteral()
525 if (Msg->getNumArgs() % 2 != 1) in rewriteToDictionaryLiteral()
527 unsigned SentinelIdx = Msg->getNumArgs() - 1; in rewriteToDictionaryLiteral()
528 const Expr *SentinelExpr = Msg->getArg(SentinelIdx); in rewriteToDictionaryLiteral()
532 if (Msg->getNumArgs() == 1) { in rewriteToDictionaryLiteral()
538 objectifyExpr(Msg->getArg(i), commit); in rewriteToDictionaryLiteral()
539 objectifyExpr(Msg->getArg(i+1), commit); in rewriteToDictionaryLiteral()
541 SourceRange ValRange = Msg->getArg(i)->getSourceRange(); in rewriteToDictionaryLiteral()
542 SourceRange KeyRange = Msg->getArg(i+1)->getSourceRange(); in rewriteToDictionaryLiteral()
552 SourceRange ArgRange(Msg->getArg(1)->getBeginLoc(), in rewriteToDictionaryLiteral()
553 Msg->getArg(SentinelIdx - 1)->getEndLoc()); in rewriteToDictionaryLiteral()
562 if (Msg->getNumArgs() != 2) in rewriteToDictionaryLiteral()
566 if (!getNSArrayObjects(Msg->getArg(0), NS, Vals)) in rewriteToDictionaryLiteral()
570 if (!getNSArrayObjects(Msg->getArg(1), NS, Keys)) in rewriteToDictionaryLiteral()
602 static bool shouldNotRewriteImmediateMessageArgs(const ObjCMessageExpr *Msg, in shouldNotRewriteImmediateMessageArgs() argument
604 if (!Msg) in shouldNotRewriteImmediateMessageArgs()
608 if (!checkForLiteralCreation(Msg, II, NS.getASTContext().getLangOpts())) in shouldNotRewriteImmediateMessageArgs()
614 Selector Sel = Msg->getSelector(); in shouldNotRewriteImmediateMessageArgs()
618 if (Msg->getNumArgs() != 2) in shouldNotRewriteImmediateMessageArgs()
622 if (!getNSArrayObjects(Msg->getArg(0), NS, Vals)) in shouldNotRewriteImmediateMessageArgs()
626 if (!getNSArrayObjects(Msg->getArg(1), NS, Keys)) in shouldNotRewriteImmediateMessageArgs()
642 static bool rewriteToCharLiteral(const ObjCMessageExpr *Msg, in rewriteToCharLiteral() argument
648 Msg->getSelector())) { in rewriteToCharLiteral()
650 commit.replaceWithInner(Msg->getSourceRange(), ArgRange); in rewriteToCharLiteral()
655 return rewriteToNumericBoxedExpression(Msg, NS, commit); in rewriteToCharLiteral()
658 static bool rewriteToBoolLiteral(const ObjCMessageExpr *Msg, in rewriteToBoolLiteral() argument
662 Msg->getSelector())) { in rewriteToBoolLiteral()
664 commit.replaceWithInner(Msg->getSourceRange(), ArgRange); in rewriteToBoolLiteral()
669 return rewriteToNumericBoxedExpression(Msg, NS, commit); in rewriteToBoolLiteral()
752 static bool rewriteToNumberLiteral(const ObjCMessageExpr *Msg, in rewriteToNumberLiteral() argument
754 if (Msg->getNumArgs() != 1) in rewriteToNumberLiteral()
757 const Expr *Arg = Msg->getArg(0)->IgnoreParenImpCasts(); in rewriteToNumberLiteral()
759 return rewriteToCharLiteral(Msg, CharE, NS, commit); in rewriteToNumberLiteral()
761 return rewriteToBoolLiteral(Msg, BE, NS, commit); in rewriteToNumberLiteral()
763 return rewriteToBoolLiteral(Msg, BE, NS, commit); in rewriteToNumberLiteral()
774 return rewriteToNumericBoxedExpression(Msg, NS, commit); in rewriteToNumberLiteral()
777 Selector Sel = Msg->getSelector(); in rewriteToNumberLiteral()
794 return rewriteToNumericBoxedExpression(Msg, NS, commit); in rewriteToNumberLiteral()
828 QualType CallTy = Msg->getArg(0)->getType(); in rewriteToNumberLiteral()
832 commit.replaceWithInner(Msg->getSourceRange(), ArgRange); in rewriteToNumberLiteral()
840 return rewriteToNumericBoxedExpression(Msg, NS, commit); in rewriteToNumberLiteral()
847 return rewriteToNumericBoxedExpression(Msg, NS, commit); in rewriteToNumberLiteral()
858 return rewriteToNumericBoxedExpression(Msg, NS, commit); in rewriteToNumberLiteral()
862 return rewriteToNumericBoxedExpression(Msg, NS, commit); in rewriteToNumberLiteral()
867 commit.replaceWithInner(CharSourceRange::getTokenRange(Msg->getSourceRange()), in rewriteToNumberLiteral()
975 static bool rewriteToNumericBoxedExpression(const ObjCMessageExpr *Msg, in rewriteToNumericBoxedExpression() argument
977 if (Msg->getNumArgs() != 1) in rewriteToNumericBoxedExpression()
980 const Expr *Arg = Msg->getArg(0); in rewriteToNumericBoxedExpression()
985 Selector Sel = Msg->getSelector(); in rewriteToNumericBoxedExpression()
1104 Diags.Report(Msg->getExprLoc(), diagID) << OrigTy << FinalTy in rewriteToNumericBoxedExpression()
1105 << Msg->getSourceRange(); in rewriteToNumericBoxedExpression()
1110 commit.replaceWithInner(Msg->getSourceRange(), ArgRange); in rewriteToNumericBoxedExpression()
1125 const ObjCMessageExpr *Msg, in doRewriteToUTF8StringBoxedExpressionHelper() argument
1127 const Expr *Arg = Msg->getArg(0); in doRewriteToUTF8StringBoxedExpressionHelper()
1140 commit.replaceWithInner(Msg->getSourceRange(), StrE->getSourceRange()); in doRewriteToUTF8StringBoxedExpressionHelper()
1149 commit.replaceWithInner(Msg->getSourceRange(), ArgRange); in doRewriteToUTF8StringBoxedExpressionHelper()
1163 static bool rewriteToStringBoxedExpression(const ObjCMessageExpr *Msg, in rewriteToStringBoxedExpression() argument
1165 Selector Sel = Msg->getSelector(); in rewriteToStringBoxedExpression()
1170 if (Msg->getNumArgs() != 1) in rewriteToStringBoxedExpression()
1172 return doRewriteToUTF8StringBoxedExpressionHelper(Msg, NS, commit); in rewriteToStringBoxedExpression()
1176 if (Msg->getNumArgs() != 2) in rewriteToStringBoxedExpression()
1179 const Expr *encodingArg = Msg->getArg(1); in rewriteToStringBoxedExpression()
1182 return doRewriteToUTF8StringBoxedExpressionHelper(Msg, NS, commit); in rewriteToStringBoxedExpression()