clang 8.0.0

Functions
RewriteObjCFoundationAPI.cpp File Reference
`#include "clang/Edit/Rewriters.h"`
`#include "clang/AST/ASTContext.h"`
`#include "clang/AST/ExprCXX.h"`
`#include "clang/AST/ExprObjC.h"`
`#include "clang/AST/NSAPI.h"`
`#include "clang/AST/ParentMap.h"`
`#include "clang/Edit/Commit.h"`
`#include "clang/Lex/Lexer.h"`
Include dependency graph for RewriteObjCFoundationAPI.cpp:

Go to the source code of this file.

## Functions
static bool | checkForLiteralCreation (const ObjCMessageExpr *Msg, IdentifierInfo *&ClassId, const LangOptions &LangOpts)
static const ObjCInterfaceDecl * | maybeAdjustInterfaceForSubscriptingCheck (const ObjCInterfaceDecl *IFace, const Expr *Receiver, ASTContext &Ctx)
| Check for classes that accept 'objectForKey:' (or the other selectors that the migrator handles) but return their instances as 'id', resulting in the compiler resolving 'objectForKey:' as the method from NSDictionary. More...
static bool | canRewriteToSubscriptSyntax (const ObjCInterfaceDecl *&IFace, const ObjCMessageExpr *Msg, ASTContext &Ctx, Selector subscriptSel)
static bool | subscriptOperatorNeedsParens (const Expr *FullExpr)
static void | maybePutParensOnReceiver (const Expr *Receiver, Commit &commit)
static bool | rewriteToSubscriptGetCommon (const ObjCMessageExpr *Msg, Commit &commit)
static bool | rewriteToArraySubscriptGet (const ObjCInterfaceDecl *IFace, const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit)
static bool | rewriteToDictionarySubscriptGet (const ObjCInterfaceDecl *IFace, const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit)
static bool | rewriteToArraySubscriptSet (const ObjCInterfaceDecl *IFace, const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit)
static bool | rewriteToDictionarySubscriptSet (const ObjCInterfaceDecl *IFace, const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit)
static bool | rewriteToArrayLiteral (const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit, const ParentMap *PMap)
static bool | rewriteToDictionaryLiteral (const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit)
static bool | rewriteToNumberLiteral (const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit)
static bool | rewriteToNumericBoxedExpression (const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit)
static bool | rewriteToStringBoxedExpression (const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit)
static bool | shouldNotRewriteImmediateMessageArgs (const ObjCMessageExpr *Msg, const NSAPI &NS)
| Returns true if the immediate message arguments of `Msg` should not be rewritten because it will interfere with the rewrite of the parent message expression. More...
static void | objectifyExpr (const Expr *E, Commit &commit)
| Adds an explicit cast to 'id' if the type is not objc object. More...
static bool | getNSArrayObjects (const Expr *E, const NSAPI &NS, SmallVectorImpl< const Expr *> &Objs)
| If `Msg` is an NSArray creation message or literal, this gets the objects that were used to create it. More...
static bool | rewriteToCharLiteral (const ObjCMessageExpr *Msg, const CharacterLiteral *Arg, const NSAPI &NS, Commit &commit)
static bool | rewriteToBoolLiteral (const ObjCMessageExpr *Msg, const Expr *Arg, const NSAPI &NS, Commit &commit)
static bool | getLiteralInfo (SourceRange literalRange, bool isFloat, bool isIntZero, ASTContext &Ctx, LiteralInfo &Info)
static bool | castOperatorNeedsParens (const Expr *FullExpr)
static bool | isEnumConstant (const Expr *E)
static bool | doRewriteToUTF8StringBoxedExpressionHelper (const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit)

## Function Documentation

## ◆ canRewriteToSubscriptSyntax()

static bool canRewriteToSubscriptSyntax | ( | const ObjCInterfaceDecl *& | IFace,
|  | const ObjCMessageExpr * | Msg,
|  | ASTContext & | Ctx,
|  | Selector | subscriptSel
| ) |  |
| static

Definition at line 156 of file RewriteObjCFoundationAPI.cpp.

References clang::ObjCMessageExpr::getInstanceReceiver(), clang::ObjCInterfaceDecl::lookupInstanceMethod(), maybeAdjustInterfaceForSubscriptingCheck(), and subscriptOperatorNeedsParens().

Referenced by rewriteToArraySubscriptGet(), rewriteToArraySubscriptSet(), rewriteToDictionarySubscriptGet(), and rewriteToDictionarySubscriptSet().

## ◆ castOperatorNeedsParens()

static bool castOperatorNeedsParens | ( | const Expr * | FullExpr | ) |
| static

Definition at line 914 of file RewriteObjCFoundationAPI.cpp.

References clang::Expr::IgnoreImpCasts().

Referenced by objectifyExpr().

## ◆ checkForLiteralCreation()

static bool checkForLiteralCreation | ( | const ObjCMessageExpr * | Msg,
|  | IdentifierInfo *& | ClassId,
|  | const LangOptions & | LangOpts
| ) |  |
| static

Definition at line 26 of file RewriteObjCFoundationAPI.cpp.

References clang::ObjCMessageExpr::Class, clang::NamedDecl::getIdentifier(), clang::ObjCMessageExpr::getInstanceReceiver(), clang::ObjCMessageExpr::getMethodDecl(), clang::ObjCMessageExpr::getReceiverInterface(), clang::ObjCMessageExpr::getReceiverKind(), clang::Expr::IgnoreParenImpCasts(), clang::ObjCMessageExpr::Instance, clang::ObjCMessageExpr::isImplicit(), and clang::OMF_alloc.

Referenced by getNSArrayObjects(), clang::edit::rewriteObjCRedundantCallWithLiteral(), clang::edit::rewriteToObjCLiteralSyntax(), and shouldNotRewriteImmediateMessageArgs().

## ◆ doRewriteToUTF8StringBoxedExpressionHelper()

static bool doRewriteToUTF8StringBoxedExpressionHelper | ( | const ObjCMessageExpr * | Msg,
|  | const NSAPI & | NS,
|  | Commit & | commit
| ) |  |
| static

Definition at line 1119 of file RewriteObjCFoundationAPI.cpp.

References clang::ASTContext::CharTy, clang::ObjCMessageExpr::getArg(), clang::ASTContext::getArrayDecayedType(), clang::Type::getAs(), clang::NSAPI::getASTContext(), clang::SourceRange::getBegin(), clang::Type::getPointeeType(), clang::Stmt::getSourceRange(), clang::Expr::getType(), clang::ASTContext::hasSameUnqualifiedType(), clang::Expr::IgnoreImpCasts(), clang::Expr::IgnoreParens(), clang::edit::Commit::insert(), clang::edit::Commit::insertBefore(), clang::edit::Commit::insertWrap(), clang::Type::isArrayType(), clang::Expr::isTypeDependent(), and clang::edit::Commit::replaceWithInner().

Referenced by rewriteToStringBoxedExpression().

## ◆ getLiteralInfo()

static bool getLiteralInfo | ( | SourceRange | literalRange,
|  | bool | isFloat,
|  | bool | isIntZero,
|  | ASTContext & | Ctx,
|  | LiteralInfo & | Info
| ) |  |
| static

Definition at line 683 of file RewriteObjCFoundationAPI.cpp.

References clang::SourceRange::getBegin(), clang::CharSourceRange::getCharRange(), clang::SourceRange::getEnd(), clang::ASTContext::getLangOpts(), clang::ASTContext::getSourceManager(), clang::Lexer::getSourceText(), clang::CharSourceRange::getTokenRange(), clang::ast_matchers::has, clang::if(), clang::SourceLocation::isMacroID(), and clang::comments::tok::text.

Referenced by rewriteToNumberLiteral().

## ◆ getNSArrayObjects()

static bool getNSArrayObjects | ( | const Expr * | E,
|  | const NSAPI & | NS,
|  | SmallVectorImpl< const Expr *> & | Objs
| ) |  |
| static

If `Msg` is an NSArray creation message or literal, this gets the objects that were used to create it.

Returns
  true if it is an NSArray and we got objects, or false otherwise.

Definition at line 440 of file RewriteObjCFoundationAPI.cpp.

References checkForLiteralCreation(), clang::NSAPI::ClassId_NSArray, clang::ObjCMessageExpr::getArg(), clang::NSAPI::getASTContext(), clang::ASTContext::getLangOpts(), clang::NSAPI::getNSArraySelector(), clang::NSAPI::getNSClassId(), clang::ObjCMessageExpr::getNumArgs(), clang::ObjCMessageExpr::getSelector(), clang::Expr::IgnoreParenCasts(), clang::ASTContext::isSentinelNullExpr(), clang::NSAPI::NSArr_array, clang::NSAPI::NSArr_arrayWithObject, clang::NSAPI::NSArr_arrayWithObjects, and clang::NSAPI::NSArr_initWithObjects.

Referenced by rewriteToDictionaryLiteral(), and shouldNotRewriteImmediateMessageArgs().

## ◆ isEnumConstant()

static bool isEnumConstant | ( | const Expr * | E | ) |
| static

Definition at line 968 of file RewriteObjCFoundationAPI.cpp.

References clang::Expr::IgnoreParenImpCasts().

Referenced by rewriteToNumericBoxedExpression().

## ◆ maybeAdjustInterfaceForSubscriptingCheck()

static const ObjCInterfaceDecl* maybeAdjustInterfaceForSubscriptingCheck | ( | const ObjCInterfaceDecl * | IFace,
|  | const Expr * | Receiver,
|  | ASTContext & | Ctx
| ) |  |
| static

Check for classes that accept 'objectForKey:' (or the other selectors that the migrator handles) but return their instances as 'id', resulting in the compiler resolving 'objectForKey:' as the method from NSDictionary.

When checking if we can convert to subscripting syntax, check whether the receiver is a result of a class method from a hardcoded list of such classes. In such a case return the specific class as the interface of the receiver.

FIXME: Remove this when these classes start using 'instancetype'.

Definition at line 109 of file RewriteObjCFoundationAPI.cpp.

References clang::ObjCMessageExpr::Class, clang::Type::getAs(), clang::ObjCMessageExpr::getClassReceiver(), clang::ObjCObjectType::getInterface(), clang::NamedDecl::getName(), clang::ObjCMessageExpr::getReceiverKind(), clang::ObjCMessageExpr::getSuperType(), clang::Expr::getType(), clang::QualType::getUnqualifiedType(), clang::Expr::IgnoreParenCasts(), clang::ObjCMessageExpr::Instance, clang::QualType::isNull(), clang::ASTContext::isObjCIdType(), clang::ObjCMessageExpr::SuperClass, and clang::ObjCMessageExpr::SuperInstance.

Referenced by canRewriteToSubscriptSyntax().

## ◆ maybePutParensOnReceiver()

static void maybePutParensOnReceiver | ( | const Expr * | Receiver,
|  | Commit & | commit
| ) |  |
| static

Definition at line 174 of file RewriteObjCFoundationAPI.cpp.

References clang::Stmt::getSourceRange(), clang::edit::Commit::insertWrap(), and subscriptOperatorNeedsParens().

Referenced by rewriteToArraySubscriptSet(), rewriteToDictionarySubscriptSet(), and rewriteToSubscriptGetCommon().

## ◆ objectifyExpr()

static void objectifyExpr | ( | const Expr * | E,
|  | Commit & | commit
| ) |  |
| static

Adds an explicit cast to 'id' if the type is not objc object.

Definition at line 943 of file RewriteObjCFoundationAPI.cpp.

References castOperatorNeedsParens(), clang::SourceRange::getBegin(), clang::Stmt::getSourceRange(), clang::Expr::getType(), clang::edit::Commit::insertBefore(), clang::edit::Commit::insertWrap(), clang::Type::isObjCObjectPointerType(), and clang::Type::isPointerType().

Referenced by rewriteToArrayLiteral(), rewriteToDictionaryLiteral(), and clang::edit::rewriteToObjCLiteralSyntax().

## ◆ rewriteToArrayLiteral()

static bool rewriteToArrayLiteral | ( | const ObjCMessageExpr * | Msg,
|  | const NSAPI & | NS,
|  | Commit & | commit,
|  | const ParentMap * | PMap
| ) |  |
| static

Definition at line 378 of file RewriteObjCFoundationAPI.cpp.

References clang::ObjCMessageExpr::getArg(), clang::NSAPI::getASTContext(), clang::Stmt::getBeginLoc(), clang::NSAPI::getNSArraySelector(), clang::ObjCMessageExpr::getNumArgs(), clang::ParentMap::getParentIgnoreParenCasts(), clang::ObjCMessageExpr::getSelector(), clang::Stmt::getSourceRange(), clang::edit::Commit::insertWrap(), clang::ASTContext::isSentinelNullExpr(), clang::NSAPI::NSArr_array, clang::NSAPI::NSArr_arrayWithObject, clang::NSAPI::NSArr_arrayWithObjects, clang::NSAPI::NSArr_initWithObjects, objectifyExpr(), clang::edit::Commit::replace(), clang::edit::Commit::replaceWithInner(), and shouldNotRewriteImmediateMessageArgs().

Referenced by clang::edit::rewriteToObjCLiteralSyntax(), and clang::edit::rewriteToObjCSubscriptSyntax().

## ◆ rewriteToArraySubscriptGet()

static bool rewriteToArraySubscriptGet | ( | const ObjCInterfaceDecl * | IFace,
|  | const ObjCMessageExpr * | Msg,
|  | const NSAPI & | NS,
|  | Commit & | commit
| ) |  |
| static

Definition at line 203 of file RewriteObjCFoundationAPI.cpp.

References canRewriteToSubscriptSyntax(), clang::NSAPI::getASTContext(), clang::NSAPI::getObjectAtIndexedSubscriptSelector(), and rewriteToSubscriptGetCommon().

Referenced by clang::edit::rewriteToObjCSubscriptSyntax().

## ◆ rewriteToArraySubscriptSet()

static bool rewriteToArraySubscriptSet | ( | const ObjCInterfaceDecl * | IFace,
|  | const ObjCMessageExpr * | Msg,
|  | const NSAPI & | NS,
|  | Commit & | commit
| ) |  |
| static

Definition at line 223 of file RewriteObjCFoundationAPI.cpp.

References canRewriteToSubscriptSyntax(), clang::ObjCMessageExpr::getArg(), clang::NSAPI::getASTContext(), clang::SourceRange::getBegin(), clang::CharSourceRange::getCharRange(), clang::SourceRange::getEnd(), clang::ObjCMessageExpr::getInstanceReceiver(), clang::ObjCMessageExpr::getNumArgs(), clang::NSAPI::getSetObjectAtIndexedSubscriptSelector(), clang::Stmt::getSourceRange(), clang::CharSourceRange::getTokenRange(), clang::edit::Commit::insertWrap(), maybePutParensOnReceiver(), and clang::edit::Commit::replaceWithInner().

Referenced by clang::edit::rewriteToObjCSubscriptSyntax().

## ◆ rewriteToBoolLiteral()

static bool rewriteToBoolLiteral | ( | const ObjCMessageExpr * | Msg,
|  | const Expr * | Arg,
|  | const NSAPI & | NS,
|  | Commit & | commit
| ) |  |
| static

Definition at line 659 of file RewriteObjCFoundationAPI.cpp.

References clang::SourceRange::getBegin(), clang::ObjCMessageExpr::getSelector(), clang::Stmt::getSourceRange(), clang::edit::Commit::insert(), clang::NSAPI::isNSNumberLiteralSelector(), clang::NSAPI::NSNumberWithBool, clang::edit::Commit::replaceWithInner(), and rewriteToNumericBoxedExpression().

Referenced by rewriteToNumberLiteral().

## ◆ rewriteToCharLiteral()

static bool rewriteToCharLiteral | ( | const ObjCMessageExpr * | Msg,
|  | const CharacterLiteral * | Arg,
|  | const NSAPI & | NS,
|  | Commit & | commit
| ) |  |
| static

Definition at line 643 of file RewriteObjCFoundationAPI.cpp.

References clang::CharacterLiteral::Ascii, clang::SourceRange::getBegin(), clang::CharacterLiteral::getKind(), clang::ObjCMessageExpr::getSelector(), clang::Stmt::getSourceRange(), clang::edit::Commit::insert(), clang::NSAPI::isNSNumberLiteralSelector(), clang::NSAPI::NSNumberWithChar, clang::edit::Commit::replaceWithInner(), and rewriteToNumericBoxedExpression().

Referenced by rewriteToNumberLiteral().

## ◆ rewriteToDictionaryLiteral()

static bool rewriteToDictionaryLiteral | ( | const ObjCMessageExpr * | Msg,
|  | const NSAPI & | NS,
|  | Commit & | commit
| ) |  |
| static

Definition at line 490 of file RewriteObjCFoundationAPI.cpp.

References clang::ObjCMessageExpr::getArg(), clang::NSAPI::getASTContext(), clang::SourceRange::getBegin(), clang::Stmt::getBeginLoc(), clang::CharSourceRange::getCharRange(), clang::SourceRange::getEnd(), clang::Stmt::getEndLoc(), getNSArrayObjects(), clang::NSAPI::getNSDictionarySelector(), clang::ObjCMessageExpr::getNumArgs(), clang::ObjCMessageExpr::getSelector(), clang::Stmt::getSourceRange(), clang::CharSourceRange::getTokenRange(), clang::edit::Commit::insertAfterToken(), clang::edit::Commit::insertBefore(), clang::edit::Commit::insertFromRange(), clang::edit::Commit::insertWrap(), clang::ASTContext::isSentinelNullExpr(), clang::NSAPI::NSDict_dictionary, clang::NSAPI::NSDict_dictionaryWithObjectForKey, clang::NSAPI::NSDict_dictionaryWithObjectsAndKeys, clang::NSAPI::NSDict_dictionaryWithObjectsForKeys, clang::NSAPI::NSDict_initWithObjectsAndKeys, clang::NSAPI::NSDict_initWithObjectsForKeys, objectifyExpr(), clang::edit::Commit::remove(), clang::edit::Commit::replace(), and clang::edit::Commit::replaceWithInner().

Referenced by clang::edit::rewriteToObjCLiteralSyntax(), and clang::edit::rewriteToObjCSubscriptSyntax().

## ◆ rewriteToDictionarySubscriptGet()

static bool rewriteToDictionarySubscriptGet | ( | const ObjCInterfaceDecl * | IFace,
|  | const ObjCMessageExpr * | Msg,
|  | const NSAPI & | NS,
|  | Commit & | commit
| ) |  |
| static

Definition at line 213 of file RewriteObjCFoundationAPI.cpp.

References canRewriteToSubscriptSyntax(), clang::NSAPI::getASTContext(), clang::NSAPI::getObjectForKeyedSubscriptSelector(), and rewriteToSubscriptGetCommon().

Referenced by clang::edit::rewriteToObjCSubscriptSyntax().

## ◆ rewriteToDictionarySubscriptSet()

static bool rewriteToDictionarySubscriptSet | ( | const ObjCInterfaceDecl * | IFace,
|  | const ObjCMessageExpr * | Msg,
|  | const NSAPI & | NS,
|  | Commit & | commit
| ) |  |
| static

Definition at line 257 of file RewriteObjCFoundationAPI.cpp.

References canRewriteToSubscriptSyntax(), clang::ObjCMessageExpr::getArg(), clang::NSAPI::getASTContext(), clang::SourceRange::getBegin(), clang::CharSourceRange::getCharRange(), clang::SourceRange::getEnd(), clang::ObjCMessageExpr::getInstanceReceiver(), clang::ObjCMessageExpr::getNumArgs(), clang::NSAPI::getSetObjectForKeyedSubscriptSelector(), clang::Stmt::getSourceRange(), clang::CharSourceRange::getTokenRange(), clang::edit::Commit::insertBefore(), clang::edit::Commit::insertFromRange(), maybePutParensOnReceiver(), and clang::edit::Commit::replaceWithInner().

Referenced by clang::edit::rewriteToObjCSubscriptSyntax().

## ◆ rewriteToNumberLiteral()

static bool rewriteToNumberLiteral | ( | const ObjCMessageExpr * | Msg,
|  | const NSAPI & | NS,
|  | Commit & | commit
| ) |  |
| static

Definition at line 753 of file RewriteObjCFoundationAPI.cpp.

References clang::ObjCMessageExpr::getArg(), clang::NSAPI::getASTContext(), clang::SourceRange::getBegin(), getLiteralInfo(), clang::NSAPI::getNSNumberLiteralMethodKind(), clang::ObjCMessageExpr::getNumArgs(), clang::ObjCMessageExpr::getSelector(), clang::Stmt::getSourceRange(), clang::CharSourceRange::getTokenRange(), clang::Expr::getType(), clang::ASTContext::hasSameType(), clang::Expr::IgnoreParenImpCasts(), clang::edit::Commit::insert(), clang::Type::isFloatingType(), clang::SourceLocation::isMacroID(), clang::NSAPI::NSNumberWithBool, clang::NSAPI::NSNumberWithChar, clang::NSAPI::NSNumberWithDouble, clang::NSAPI::NSNumberWithFloat, clang::NSAPI::NSNumberWithInt, clang::NSAPI::NSNumberWithInteger, clang::NSAPI::NSNumberWithLong, clang::NSAPI::NSNumberWithLongLong, clang::NSAPI::NSNumberWithShort, clang::NSAPI::NSNumberWithUnsignedChar, clang::NSAPI::NSNumberWithUnsignedInt, clang::NSAPI::NSNumberWithUnsignedInteger, clang::NSAPI::NSNumberWithUnsignedLong, clang::NSAPI::NSNumberWithUnsignedLongLong, clang::NSAPI::NSNumberWithUnsignedShort, clang::edit::Commit::replaceWithInner(), rewriteToBoolLiteral(), rewriteToCharLiteral(), and rewriteToNumericBoxedExpression().

Referenced by clang::edit::rewriteToObjCLiteralSyntax(), and clang::edit::rewriteToObjCSubscriptSyntax().

## ◆ rewriteToNumericBoxedExpression()

static bool rewriteToNumericBoxedExpression | ( | const ObjCMessageExpr * | Msg,
|  | const NSAPI & | NS,
|  | Commit & | commit
| ) |  |
| static

Definition at line 976 of file RewriteObjCFoundationAPI.cpp.

References clang::ObjCMessageExpr::getArg(), clang::Type::getAs(), clang::NSAPI::getASTContext(), clang::SourceRange::getBegin(), clang::DiagnosticsEngine::getCustomDiagID(), clang::ASTContext::getDiagnostics(), clang::Expr::getExprLoc(), clang::NSAPI::getNSNumberLiteralMethodKind(), clang::ObjCMessageExpr::getNumArgs(), clang::ObjCMessageExpr::getSelector(), clang::Stmt::getSourceRange(), clang::Expr::getType(), clang::ASTContext::getTypeSize(), clang::Expr::IgnoreImpCasts(), clang::edit::Commit::insertBefore(), clang::edit::Commit::insertWrap(), clang::ASTContext::IntTy, clang::Type::isBooleanType(), isEnumConstant(), clang::Type::isSignedIntegerType(), clang::Expr::isTypeDependent(), clang::NSAPI::NSNumberWithBool, clang::NSAPI::NSNumberWithInteger, clang::NSAPI::NSNumberWithUnsignedInteger, clang::edit::Commit::replaceWithInner(), clang::DiagnosticsEngine::Report(), and clang::DiagnosticsEngine::Warning.

Referenced by rewriteToBoolLiteral(), rewriteToCharLiteral(), rewriteToNumberLiteral(), and clang::edit::rewriteToObjCSubscriptSyntax().

## ◆ rewriteToStringBoxedExpression()

static bool rewriteToStringBoxedExpression | ( | const ObjCMessageExpr * | Msg,
|  | const NSAPI & | NS,
|  | Commit & | commit
| ) |  |
| static

Definition at line 1158 of file RewriteObjCFoundationAPI.cpp.

References doRewriteToUTF8StringBoxedExpressionHelper(), clang::ObjCMessageExpr::getArg(), clang::NSAPI::getNSStringSelector(), clang::ObjCMessageExpr::getNumArgs(), clang::ObjCMessageExpr::getSelector(), clang::NSAPI::isNSASCIIStringEncodingConstant(), clang::NSAPI::isNSUTF8StringEncodingConstant(), clang::NSAPI::NSStr_initWithUTF8String, clang::NSAPI::NSStr_stringWithCString, clang::NSAPI::NSStr_stringWithCStringEncoding, and clang::NSAPI::NSStr_stringWithUTF8String.

Referenced by clang::edit::rewriteToObjCLiteralSyntax(), and clang::edit::rewriteToObjCSubscriptSyntax().

## ◆ rewriteToSubscriptGetCommon()

static bool rewriteToSubscriptGetCommon | ( | const ObjCMessageExpr * | Msg,
|  | Commit & | commit
| ) |  |
| static

Definition at line 181 of file RewriteObjCFoundationAPI.cpp.

References clang::ObjCMessageExpr::getArg(), clang::SourceRange::getBegin(), clang::CharSourceRange::getCharRange(), clang::SourceRange::getEnd(), clang::ObjCMessageExpr::getInstanceReceiver(), clang::ObjCMessageExpr::getNumArgs(), clang::Stmt::getSourceRange(), clang::CharSourceRange::getTokenRange(), clang::edit::Commit::insertWrap(), maybePutParensOnReceiver(), and clang::edit::Commit::replaceWithInner().

Referenced by rewriteToArraySubscriptGet(), and rewriteToDictionarySubscriptGet().

## ◆ shouldNotRewriteImmediateMessageArgs()

static bool shouldNotRewriteImmediateMessageArgs | ( | const ObjCMessageExpr * | Msg,
|  | const NSAPI & | NS
| ) |  |
| static

Returns true if the immediate message arguments of `Msg` should not be rewritten because it will interfere with the rewrite of the parent message expression.

e.g.

[NSDictionary dictionaryWithObjects:
[NSArray arrayWithObjects:@"1", @"2", nil]
forKeys:[NSArray arrayWithObjects:@"A", @"B", nil]];

It will return true for this because we are going to rewrite this directly to a dictionary literal without any array literals.

Definition at line 603 of file RewriteObjCFoundationAPI.cpp.

References checkForLiteralCreation(), clang::NSAPI::ClassId_NSDictionary, clang::ObjCMessageExpr::getArg(), clang::NSAPI::getASTContext(), clang::ASTContext::getLangOpts(), getNSArrayObjects(), clang::NSAPI::getNSClassId(), clang::NSAPI::getNSDictionarySelector(), clang::ObjCMessageExpr::getNumArgs(), clang::ObjCMessageExpr::getSelector(), clang::NSAPI::NSDict_dictionaryWithObjectsForKeys, and clang::NSAPI::NSDict_initWithObjectsForKeys.

Referenced by rewriteToArrayLiteral(), and clang::edit::rewriteToObjCLiteralSyntax().

## ◆ subscriptOperatorNeedsParens()

static bool subscriptOperatorNeedsParens | ( | const Expr * | FullExpr | ) |
| static

Definition at line 892 of file RewriteObjCFoundationAPI.cpp.

References clang::Expr::IgnoreImpCasts().

Referenced by clang::arcmt::ObjCMigrateAction::BeginInvocation(), canRewriteToSubscriptSyntax(), and maybePutParensOnReceiver().