;
42 if(LangOpts.ObjCAutoRefCount) {
70 if((isa<ObjCStringLiteral>(Arg) &&
75(isa<ObjCArrayLiteral>(Arg) &&
80(isa<ObjCDictionaryLiteral>(Arg) &&
110 const Expr*Receiver,
112assert(IFace && Receiver);
149 if(OID->
getName() ==
"NSMapTable"||
150OID->
getName() ==
"NSLocale")
166 if(!MD->isUnavailable())
394commit.
replace(MsgRange,
"@[]");
416 for(
unsignedi = 0, e = Msg->
getNumArgs() - 1; i != e; ++i)
420commit.
replace(MsgRange,
"@[]");
462 if(Msg->getNumArgs() != 1)
464Objs.push_back(Msg->getArg(0));
470 if(Msg->getNumArgs() == 0)
472 const Expr*SentinelExpr = Msg->getArg(Msg->getNumArgs() - 1);
476 for(
unsignedi = 0, e = Msg->getNumArgs() - 1; i != e; ++i)
477Objs.push_back(Msg->getArg(i));
482 for(
unsignedi = 0, e = ArrLit->getNumElements(); i != e; ++i)
483Objs.push_back(ArrLit->getElement(i));
498commit.
replace(MsgRange,
"@{}");
528 unsignedSentinelIdx = Msg->
getNumArgs() - 1;
529 const Expr*SentinelExpr = Msg->
getArg(SentinelIdx);
534commit.
replace(MsgRange,
"@{}");
538 for(
unsignedi = 0; i < SentinelIdx; i += 2) {
574 if(Vals.size() != Keys.size())
578commit.
replace(MsgRange,
"@{}");
582 for(
unsignedi = 0, n = Vals.size(); i < n; ++i) {
594 SourceRangeArgRange(Keys.front()->getBeginLoc(), Keys.back()->getEndLoc());
630 if(Vals.size() != Keys.size())
646 if(Arg->
getKind() != CharacterLiteralKind::Ascii)
677StringRef
U, F, L, LL;
684 boolisFloat,
boolisIntZero,
695std::optional<bool> UpperU, UpperL;
696 boolUpperF =
false;
699 static bool has(StringRef suff, StringRef &text) {
700 returntext.consume_back(suff);
705 if(Suff::has(
"u", text)) {
707}
else if(Suff::has(
"U", text)) {
709}
else if(Suff::has(
"ll", text)) {
711}
else if(Suff::has(
"LL", text)) {
713}
else if(Suff::has(
"l", text)) {
715}
else if(Suff::has(
"L", text)) {
717}
else if(isFloat && Suff::has(
"f", text)) {
719}
else if(isFloat && Suff::has(
"F", text)) {
725 if(!UpperU && !UpperL)
726UpperU = UpperL =
true;
727 else if(UpperU && !UpperL)
729 else if(UpperL && !UpperU)
732Info.U = *UpperU ?
"U":
"u";
733Info.L = *UpperL ?
"L":
"l";
734Info.LL = *UpperL ?
"LL":
"ll";
735Info.F = UpperF ?
"F":
"f";
737Info.Hex = Info.Octal =
false;
738 if(text.starts_with(
"0x"))
740 else if(!isFloat && !isIntZero && text.starts_with(
"0"))
744Info.WithoutSuffRange =
762 const Expr*literalE = Arg;
763 if(
const UnaryOperator*UOE = dyn_cast<UnaryOperator>(literalE)) {
764 if(UOE->getOpcode() == UO_Plus || UOE->getOpcode() == UO_Minus)
765literalE = UOE->getSubExpr();
770 if(!isa<IntegerLiteral>(literalE) && !isa<FloatingLiteral>(literalE))
775std::optional<NSAPI::NSNumberLiteralMethodKind> MKOpt =
781 boolCallIsUnsigned =
false, CallIsLong =
false, CallIsLongLong =
false;
782 boolCallIsFloating =
false, CallIsDouble =
false;
795CallIsUnsigned =
true;
802CallIsUnsigned =
true;
809CallIsUnsigned =
true;
812CallIsLongLong =
true;
816CallIsDouble =
true;
819CallIsFloating =
true;
843 if(LitIsFloat && !CallIsFloating)
851 boolisIntZero =
false;
852 if(
const IntegerLiteral*IntE = dyn_cast<IntegerLiteral>(literalE))
853isIntZero = !IntE->getValue().getBoolValue();
854 if(!
getLiteralInfo(ArgRange, LitIsFloat, isIntZero, Ctx, LitInfo))
858 if(!LitIsFloat && CallIsFloating && (LitInfo.Hex || LitInfo.Octal))
865LitInfo.WithoutSuffRange);
866commit.
insert(LitB,
"@");
868 if(!LitIsFloat && CallIsFloating)
869commit.
insert(LitE,
".0");
871 if(CallIsFloating) {
873commit.
insert(LitE, LitInfo.F);
876commit.
insert(LitE, LitInfo.U);
879commit.
insert(LitE, LitInfo.L);
880 else if(CallIsLongLong)
881commit.
insert(LitE, LitInfo.LL);
890 if(isa<ArraySubscriptExpr>(
Expr) ||
891isa<CallExpr>(
Expr) ||
892isa<DeclRefExpr>(
Expr) ||
893isa<CXXNamedCastExpr>(
Expr) ||
894isa<CXXConstructExpr>(
Expr) ||
895isa<CXXThisExpr>(
Expr) ||
896isa<CXXTypeidExpr>(
Expr) ||
897isa<CXXUnresolvedConstructExpr>(
Expr) ||
898isa<ObjCMessageExpr>(
Expr) ||
899isa<ObjCPropertyRefExpr>(
Expr) ||
900isa<ObjCProtocolExpr>(
Expr) ||
901isa<MemberExpr>(
Expr) ||
902isa<ObjCIvarRefExpr>(
Expr) ||
904isa<ParenListExpr>(
Expr) ||
905isa<SizeOfPackExpr>(
Expr))
912 if(isa<ArraySubscriptExpr>(
Expr) ||
913isa<CallExpr>(
Expr) ||
914isa<DeclRefExpr>(
Expr) ||
915isa<CastExpr>(
Expr) ||
916isa<CXXNewExpr>(
Expr) ||
917isa<CXXConstructExpr>(
Expr) ||
918isa<CXXDeleteExpr>(
Expr) ||
919isa<CXXNoexceptExpr>(
Expr) ||
920isa<CXXPseudoDestructorExpr>(
Expr) ||
921isa<CXXScalarValueInitExpr>(
Expr) ||
922isa<CXXThisExpr>(
Expr) ||
923isa<CXXTypeidExpr>(
Expr) ||
924isa<CXXUnresolvedConstructExpr>(
Expr) ||
925isa<ObjCMessageExpr>(
Expr) ||
926isa<ObjCPropertyRefExpr>(
Expr) ||
927isa<ObjCProtocolExpr>(
Expr) ||
928isa<MemberExpr>(
Expr) ||
929isa<ObjCIvarRefExpr>(
Expr) ||
931isa<ParenListExpr>(
Expr) ||
932isa<SizeOfPackExpr>(
Expr) ||
933isa<UnaryOperator>(
Expr))
945 if(ICE->getCastKind() != CK_CPointerToObjCPointerCast)
966 if(
const ValueDecl*VD = DRE->getDecl())
967 returnisa<EnumConstantDecl>(VD);
983std::optional<NSAPI::NSNumberLiteralMethodKind> MKOpt =
995 boolisTruncated = FinalTySize < OrigTySize;
996 boolneedsCast =
false;
999 switch(ICE->getCastKind()) {
1000 caseCK_LValueToRValue:
1002 caseCK_UserDefinedConversion:
1003 caseCK_HLSLArrayRValue:
1006 caseCK_IntegralCast: {
1025 caseCK_PointerToBoolean:
1026 caseCK_IntegralToBoolean:
1027 caseCK_IntegralToFloating:
1028 caseCK_FloatingToIntegral:
1029 caseCK_FloatingToBoolean:
1030 caseCK_FloatingCast:
1031 caseCK_FloatingComplexToReal:
1032 caseCK_FloatingComplexToBoolean:
1033 caseCK_IntegralComplexToReal:
1034 caseCK_IntegralComplexToBoolean:
1035 caseCK_AtomicToNonAtomic:
1036 caseCK_AddressSpaceConversion:
1042 caseCK_LValueBitCast:
1043 caseCK_LValueToRValueBitCast:
1044 caseCK_BaseToDerived:
1045 caseCK_DerivedToBase:
1046 caseCK_UncheckedDerivedToBase:
1049 caseCK_ArrayToPointerDecay:
1050 caseCK_FunctionToPointerDecay:
1051 caseCK_NullToPointer:
1052 caseCK_NullToMemberPointer:
1053 caseCK_BaseToDerivedMemberPointer:
1054 caseCK_DerivedToBaseMemberPointer:
1055 caseCK_MemberPointerToBoolean:
1056 caseCK_ReinterpretMemberPointer:
1057 caseCK_ConstructorConversion:
1058 caseCK_IntegralToPointer:
1059 caseCK_PointerToIntegral:
1061 caseCK_VectorSplat:
1062 caseCK_CPointerToObjCPointerCast:
1063 caseCK_BlockPointerToObjCPointerCast:
1064 caseCK_AnyPointerToBlockPointerCast:
1065 caseCK_ObjCObjectLValueCast:
1066 caseCK_FloatingRealToComplex:
1067 caseCK_FloatingComplexCast:
1068 caseCK_FloatingComplexToIntegralComplex:
1069 caseCK_IntegralRealToComplex:
1070 caseCK_IntegralComplexCast:
1071 caseCK_IntegralComplexToFloatingComplex:
1072 caseCK_ARCProduceObject:
1073 caseCK_ARCConsumeObject:
1074 caseCK_ARCReclaimReturnedObject:
1075 caseCK_ARCExtendBlockObject:
1076 caseCK_NonAtomicToAtomic:
1077 caseCK_CopyAndAutoreleaseBlockObject:
1078 caseCK_BuiltinFnToFnPtr:
1079 caseCK_ZeroToOCLOpaqueType:
1080 caseCK_IntToOCLSampler:
1084 caseCK_BooleanToSignedIntegral:
1085llvm_unreachable(
"OpenCL-specific cast in Objective-C?");
1087 caseCK_HLSLVectorTruncation:
1088llvm_unreachable(
"HLSL-specific cast in Objective-C?");
1091 caseCK_FloatingToFixedPoint:
1092 caseCK_FixedPointToFloating:
1093 caseCK_FixedPointCast:
1094 caseCK_FixedPointToBoolean:
1095 caseCK_FixedPointToIntegral:
1096 caseCK_IntegralToFixedPoint:
1097llvm_unreachable(
"Fixed point types are disabled for Objective-C");
1105 "converting to boxing syntax requires casting %0 to %1");
1114 if(isa<ParenExpr>(OrigArg) || isa<IntegerLiteral>(OrigArg))
1141StrE = dyn_cast<StringLiteral>(OrigArg->
IgnoreParens())) {
1143commit.
insert(StrE->getBeginLoc(),
"@");
1153 if(isa<ParenExpr>(OrigArg) || isa<IntegerLiteral>(OrigArg))
Defines the clang::ASTContext interface.
Defines the clang::Expr interface and subclasses for C++ expressions.
static bool isEnumConstant(const Expr *E)
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 interf...
static bool rewriteToCharLiteral(const ObjCMessageExpr *Msg, const CharacterLiteral *Arg, const NSAPI &NS, Commit &commit)
static bool rewriteToDictionarySubscriptGet(const ObjCInterfaceDecl *IFace, const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit)
static void maybePutParensOnReceiver(const Expr *Receiver, Commit &commit)
static bool rewriteToBoolLiteral(const ObjCMessageExpr *Msg, const Expr *Arg, const NSAPI &NS, Commit &commit)
static bool rewriteToArrayLiteral(const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit, const ParentMap *PMap)
static bool subscriptOperatorNeedsParens(const Expr *FullExpr)
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 ...
static bool rewriteToDictionaryLiteral(const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit)
static bool castOperatorNeedsParens(const Expr *FullExpr)
static bool rewriteToNumericBoxedExpression(const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit)
static bool rewriteToNumberLiteral(const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit)
static bool rewriteToStringBoxedExpression(const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit)
static bool rewriteToSubscriptGetCommon(const ObjCMessageExpr *Msg, Commit &commit)
static bool rewriteToDictionarySubscriptSet(const ObjCInterfaceDecl *IFace, const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit)
static bool doRewriteToUTF8StringBoxedExpressionHelper(const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit)
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.
static bool canRewriteToSubscriptSyntax(const ObjCInterfaceDecl *&IFace, const ObjCMessageExpr *Msg, ASTContext &Ctx, Selector subscriptSel)
static bool getLiteralInfo(SourceRange literalRange, bool isFloat, bool isIntZero, ASTContext &Ctx, LiteralInfo &Info)
static void objectifyExpr(const Expr *E, Commit &commit)
Adds an explicit cast to 'id' if the type is not objc object.
static bool rewriteToArraySubscriptGet(const ObjCInterfaceDecl *IFace, const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit)
static bool checkForLiteralCreation(const ObjCMessageExpr *Msg, IdentifierInfo *&ClassId, const LangOptions &LangOpts)
static bool rewriteToArraySubscriptSet(const ObjCInterfaceDecl *IFace, const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceManager & getSourceManager()
bool isObjCIdType(QualType T) const
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
const LangOptions & getLangOpts() const
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
const ObjCInterfaceDecl * getObjContainingInterface(const NamedDecl *ND) const
Returns the Objective-C interface that ND belongs to if it is an Objective-C method/property/ivar etc...
DiagnosticsEngine & getDiagnostics() const
bool isSentinelNullExpr(const Expr *E)
A boolean literal, per ([C++ lex.bool] Boolean literals).
Represents a character-granular source range.
static CharSourceRange getCharRange(SourceRange R)
static CharSourceRange getTokenRange(SourceRange R)
CharacterLiteralKind getKind() const
A reference to a declared variable, function, enum, etc.
Concrete class used by the front-end to report problems and issues.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
This represents one expression.
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
FullExpr - Represents a "full-expression" node.
One of these records is kept for each identifier that is lexed.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
std::optional< NSNumberLiteralMethodKind > getNSNumberLiteralMethodKind(Selector Sel) const
Return NSNumberLiteralMethodKind if Sel is such a selector.
Selector getObjectAtIndexedSubscriptSelector() const
Returns selector for "objectAtIndexedSubscript:".
@ NSStr_initWithUTF8String
@ NSStr_stringWithCString
@ NSStr_stringWithCStringEncoding
@ NSStr_stringWithUTF8String
Selector getSetObjectAtIndexedSubscriptSelector() const
Returns selector for "setObject:atIndexedSubscript".
Selector getNSDictionarySelector(NSDictionaryMethodKind MK) const
The Objective-C NSDictionary selectors.
Selector getObjectForKeyedSubscriptSelector() const
Returns selector for "objectForKeyedSubscript:".
@ NSDict_dictionaryWithObjectsForKeys
@ NSDict_dictionaryWithDictionary
@ NSMutableDict_setObjectForKey
@ NSDict_initWithObjectsForKeys
@ NSDict_dictionaryWithObjectForKey
@ NSDict_initWithDictionary
@ NSDict_initWithObjectsAndKeys
@ NSDict_dictionaryWithObjectsAndKeys
Selector getNSArraySelector(NSArrayMethodKind MK) const
The Objective-C NSArray selectors.
@ NSMutableArr_replaceObjectAtIndex
bool isNSUTF8StringEncodingConstant(const Expr *E) const
Returns true if the expression.
bool isNSNumberLiteralSelector(NSNumberLiteralMethodKind MK, Selector Sel) const
Selector getSetObjectForKeyedSubscriptSelector() const
Returns selector for "setObject:forKeyedSubscript".
ASTContext & getASTContext() const
NSNumberLiteralMethodKind
Enumerates the NSNumber methods used to generate literals.
@ NSNumberWithUnsignedChar
@ NSNumberWithUnsignedLongLong
@ NSNumberWithUnsignedInt
@ NSNumberWithUnsignedLong
@ NSNumberWithUnsignedInteger
@ NSNumberWithUnsignedShort
Selector getNSStringSelector(NSStringMethodKind MK) const
The Objective-C NSString selectors.
bool isNSASCIIStringEncodingConstant(const Expr *E) const
Returns true if the expression.
IdentifierInfo * getNSClassId(NSClassIdKindKind K) const
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp,...
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Represents an ObjC class declaration.
ObjCMethodDecl * lookupInstanceMethod(Selector Sel) const
Lookup an instance method for a given selector.
An expression that sends a message to the given Objective-C object or class.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
bool isImplicit() const
Indicates whether the message send was implicitly generated by the implementation.
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
Selector getSelector() const
@ SuperInstance
The receiver is the instance of the superclass object.
@ Instance
The receiver is an object instance.
@ SuperClass
The receiver is a superclass.
@ Class
The receiver is a class.
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
ObjCInterfaceDecl * getReceiverInterface() const
Retrieve the Objective-C interface to which this message is being directed, if known.
QualType getSuperType() const
Retrieve the type referred to by 'super'.
const ObjCMethodDecl * getMethodDecl() const
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
unsigned getNumArgs() const
Return the number of actual arguments in this message, not counting the receiver.
ObjCMethodDecl - Represents an instance or class method declaration.
Represents a class type in Objective C.
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface.
Stmt * getParentIgnoreParenCasts(Stmt *) const
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Smart pointer class that efficiently represents Objective-C method names.
Encodes a location in the source.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteral - This represents a string literal expression, e.g.
bool isBooleanType() const
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
bool isPointerType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isObjCObjectPointerType() const
bool isFloatingType() const
const T * getAs() const
Member-template getAs<specific type>'.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
bool replaceWithInner(CharSourceRange range, CharSourceRange innerRange)
bool insertWrap(StringRef before, CharSourceRange range, StringRef after)
bool insertFromRange(SourceLocation loc, CharSourceRange range, bool afterToken=false, bool beforePreviousInsertions=false)
bool insert(SourceLocation loc, StringRef text, bool afterToken=false, bool beforePreviousInsertions=false)
bool insertAfterToken(SourceLocation loc, StringRef text, bool beforePreviousInsertions=false)
bool remove(CharSourceRange range)
bool insertBefore(SourceLocation loc, StringRef text)
bool replace(CharSourceRange range, StringRef text)
const internal::ArgumentAdaptingMatcherFunc< internal::HasMatcher > has
Matches AST nodes that have child AST nodes that match the provided matcher.
bool rewriteObjCRedundantCallWithLiteral(const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit)
bool rewriteToObjCLiteralSyntax(const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit, const ParentMap *PMap)
bool rewriteToObjCSubscriptSyntax(const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit)
EditGenerator edit(ASTEdit E)
Generates a single (specified) edit.
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4