28#include "llvm/ADT/SmallString.h"
29#include "llvm/Support/ConvertUTF.h"
45 if (Strings.size() != 1) {
50 for (
Expr *E : Strings) {
51 S = cast<StringLiteral>(E);
54 if (!S->isOrdinary()) {
55 Diag(S->getBeginLoc(), diag::err_cfstring_literal_not_string_constant)
56 << S->getSourceRange();
61 StrBuf += S->getString();
64 StrLocs.append(S->tokloc_begin(), S->tokloc_end());
70 assert(CAT &&
"String literal not of constant array type!");
72 CAT->
getElementType(), llvm::APInt(32, StrBuf.size() + 1),
nullptr,
75 false, StrTy, &StrLocs[0],
84 if (CheckObjCString(S))
96 std::string StringClass(
getLangOpts().ObjCConstantStringClass);
98 if (StringClass.empty())
112 Diag(S->getBeginLoc(), diag::err_no_nsconstant_string_class)
113 << NSIdent << S->getSourceRange();
153 S.
Diag(Loc, diag::err_undeclared_boxing_method) << Sel << Class->getName();
160 S.
Diag(Loc, diag::err_objc_literal_method_sig)
173 switch (LiteralKind) {
191 llvm_unreachable(
"LiteralKind can't be converted into a ClassKind");
203 S.
Diag(Loc, diag::err_undeclared_objc_literal_class)
204 << II->
getName() << LiteralKind;
206 }
else if (!
Decl->hasDefinition() && !S.
getLangOpts().DebuggerObjCLiteral) {
207 S.
Diag(Loc, diag::err_undeclared_objc_literal_class)
208 <<
Decl->getName() << LiteralKind;
245 bool isLiteral =
false,
247 std::optional<NSAPI::NSNumberLiteralMethodKind> Kind =
248 S.
NSAPIObj->getNSNumberFactoryMethodKind(NumberType);
252 S.
Diag(Loc, diag::err_invalid_nsnumber_type)
285 if (!Method && S.
getLangOpts().DebuggerObjCLiteral) {
323 switch (Char->getKind()) {
360 Number = ConvertedNumber.
get();
379 CK_IntegralToBoolean);
389 bool ArrayLiteral =
false) {
409 return Seq.
Perform(S, Entity, Kind, Element);
412 Expr *OrigElement = Element;
423 bool Recovered =
false;
426 if (isa<IntegerLiteral>(OrigElement) ||
427 isa<CharacterLiteral>(OrigElement) ||
428 isa<FloatingLiteral>(OrigElement) ||
429 isa<ObjCBoolLiteralExpr>(OrigElement) ||
430 isa<CXXBoolLiteralExpr>(OrigElement)) {
431 if (S.
NSAPIObj->getNSNumberFactoryMethodKind(OrigElement->
getType())) {
432 int Which = isa<CharacterLiteral>(OrigElement) ? 1
433 : (isa<CXXBoolLiteralExpr>(OrigElement) ||
434 isa<ObjCBoolLiteralExpr>(OrigElement)) ? 2
451 else if (
StringLiteral *String = dyn_cast<StringLiteral>(OrigElement)) {
452 if (String->isOrdinary()) {
474 dyn_cast<ObjCStringLiteral>(OrigElement)) {
476 unsigned numConcat = SL->getNumConcatenated();
479 bool hasMacro =
false;
480 for (
unsigned i = 0; i < numConcat ; ++i)
481 if (SL->getStrTokenLoc(i).isMacroID()) {
487 diag::warn_concatenated_nsarray_literal)
515 ValueExpr = RValue.
get();
533 if (
auto *CE = dyn_cast<ImplicitCastExpr>(ValueExpr))
534 if (CE->getCastKind() == CK_ArrayToPointerDecay)
536 dyn_cast<StringLiteral>(CE->getSubExpr()->IgnoreParens())) {
537 assert((SL->isOrdinary() || SL->isUTF8()) &&
538 "unexpected character encoding");
539 StringRef Str = SL->getString();
540 const llvm::UTF8 *StrBegin = Str.bytes_begin();
541 const llvm::UTF8 *StrEnd = Str.bytes_end();
543 if (llvm::isLegalUTF8String(&StrBegin, StrEnd)) {
551 Diag(SL->getBeginLoc(), diag::warn_objc_boxing_invalid_utf8_string)
561 if (!BoxingMethod &&
getLangOpts().DebuggerObjCLiteral) {
586 stringWithUTF8String, BoxingMethod))
595 std::optional<NullabilityKind> Nullability =
610 dyn_cast<CharacterLiteral>(ValueExpr->
IgnoreParens())) {
613 switch (Char->getKind()) {
638 if (!ET->getDecl()->isComplete()) {
639 Diag(Loc, diag::err_objc_incomplete_boxed_expression_type)
645 ET->getDecl()->getIntegerType());
674 if (!BoxingMethod &&
getLangOpts().DebuggerObjCLiteral) {
697 Params.push_back(
bytes);
707 Params.push_back(
type);
714 ValueWithBytesObjCType, BoxingMethod))
721 Diag(Loc, diag::err_objc_non_trivially_copyable_boxed_expression_type)
731 Diag(Loc, diag::err_objc_illegal_boxed_expression_type)
754 ValueExpr = ConvertedValueExpr.
get();
773 "base or index cannot have dependent type here");
791 getterMethod, setterMethod, RB);
811 if (!Method &&
getLangOpts().DebuggerObjCLiteral) {
828 Params.push_back(objects);
836 Params.push_back(cnt);
851 diag::note_objc_literal_method_param)
858 if (!Method->
parameters()[1]->getType()->isIntegerType()) {
862 diag::note_objc_literal_method_param)
878 Expr **ElementsBuffer = Elements.data();
879 for (
unsigned I = 0, N = Elements.size(); I != N; ++I) {
886 ElementsBuffer[I] = Converted.
get();
903 if (Literal->isValueDependent() || Literal->isTypeDependent())
909 struct APSIntCompare {
910 bool operator()(
const llvm::APSInt &LHS,
const llvm::APSInt &RHS)
const {
911 return llvm::APSInt::compareValues(LHS, RHS) < 0;
915 llvm::DenseMap<StringRef, SourceLocation> StringKeys;
916 std::map<llvm::APSInt, SourceLocation, APSIntCompare> IntegralKeys;
918 auto checkOneKey = [&](
auto &Map,
const auto &Key,
SourceLocation Loc) {
919 auto Pair = Map.insert({Key, Loc});
921 S.
Diag(Loc, diag::warn_nsdictionary_duplicate_key);
922 S.
Diag(Pair.first->second, diag::note_nsdictionary_duplicate_key_here);
926 for (
unsigned Idx = 0, End = Literal->getNumElements(); Idx != End; ++Idx) {
927 Expr *Key = Literal->getKeyValueElement(Idx).Key->IgnoreParenImpCasts();
929 if (
auto *StrLit = dyn_cast<ObjCStringLiteral>(Key)) {
930 StringRef Bytes = StrLit->getString()->getBytes();
932 checkOneKey(StringKeys, Bytes, Loc);
935 if (
auto *BE = dyn_cast<ObjCBoxedExpr>(Key)) {
936 Expr *Boxed = BE->getSubExpr();
941 checkOneKey(StringKeys, Str->getBytes(), Loc);
948 checkOneKey(IntegralKeys,
Result.Val.getInt(), Loc);
973 if (!Method &&
getLangOpts().DebuggerObjCLiteral) {
990 Params.push_back(objects);
998 Params.push_back(keys);
1006 Params.push_back(cnt);
1022 diag::note_objc_literal_method_param)
1056 diag::note_objc_literal_method_param)
1064 QualType CountType = Method->parameters()[2]->getType();
1068 Diag(Method->parameters()[2]->getLocation(),
1069 diag::note_objc_literal_method_param)
1079 QualType ValuesT = DictionaryWithObjectsMethod->parameters()[0]->getType();
1081 QualType KeysT = DictionaryWithObjectsMethod->parameters()[1]->getType();
1086 bool HasPackExpansions =
false;
1097 if (
Value.isInvalid())
1100 Element.Key = Key.
get();
1101 Element.Value =
Value.get();
1103 if (Element.EllipsisLoc.isInvalid())
1106 if (!Element.Key->containsUnexpandedParameterPack() &&
1107 !Element.Value->containsUnexpandedParameterPack()) {
1108 Diag(Element.EllipsisLoc,
1109 diag::err_pack_expansion_without_parameter_packs)
1111 Element.Value->getEndLoc());
1115 HasPackExpansions =
true;
1123 DictionaryWithObjectsMethod, SR);
1125 return MaybeBindToTemporary(Literal);
1139 diag::err_incomplete_type_objc_at_encode,
1146 if (!NotEncodedT.
isNull())
1147 Diag(AtLoc, diag::warn_incomplete_encoded_type)
1148 << EncodedType << NotEncodedT;
1180 bool Warned =
false;
1183 if (MatchingMethodDecl == Method ||
1191 S.
Diag(AtLoc, diag::warn_multiple_selectors)
1197 S.
Diag(MatchingMethodDecl->
getLocation(), diag::note_method_declared_at)
1208 bool WarnMultipleSelectors) {
1209 if (!WarnMultipleSelectors ||
1212 bool Warned =
false;
1218 Method, InstMethList))
1224 Method, ClsMethList) || Warned)
1240 assert(Method->
getSelector() == Sel &&
"Method with wrong selector in method list");
1243 DirectMethod = Method;
1248 return DirectMethod;
1263 S, Sel, Iter->second.first, onlyDirect, anyDirect);
1265 S, Sel, Iter->second.second, onlyDirect, anyDirect);
1267 return DirectInstance ? DirectInstance : DirectClass;
1296 bool WarnMultipleSelectors) {
1304 Selector MatchedSel = OM->getSelector();
1307 Diag(SelLoc, diag::warn_undeclared_selector_with_typo)
1308 << Sel << MatchedSel
1312 Diag(SelLoc, diag::warn_undeclared_selector) << Sel;
1315 WarnMultipleSelectors);
1317 bool onlyDirect =
true;
1318 bool anyDirect =
false;
1323 Diag(AtLoc, diag::err_direct_selector_expression)
1327 }
else if (anyDirect) {
1332 if (LikelyTargetMethod && LikelyTargetMethod->
isDirectMethod()) {
1333 Diag(AtLoc, diag::warn_potentially_direct_selector_expression) << Sel;
1335 diag::note_direct_method_declared_at)
1337 }
else if (!LikelyTargetMethod) {
1340 Diag(AtLoc, diag::warn_strict_potentially_direct_selector_expression)
1343 diag::note_direct_method_declared_at)
1363 Diag(AtLoc, diag::err_arc_illegal_selector) <<
1392 Diag(ProtoLoc, diag::err_undeclared_protocol) << ProtocolId;
1396 Diag(ProtoLoc, diag::err_objc_non_runtime_protocol_in_protocol_expr)
1399 Diag(ProtoLoc, diag::err_atprotocol_protocol) << PDecl;
1455 bool isClassMessage,
1456 bool isSuperMessage) {
1457 assert(Method &&
"Must have a method");
1467 if (
auto nullability =
1492 if (isSuperMessage) {
1495 return transferNullability(
1514 return transferNullability(ReceiverType);
1520 bool isClassMessage,
1521 bool isSuperMessage) {
1529 if (isClassMessage) {
1541 cast<ImplicitParamDecl>(
1543 ->getDeclContext());
1550 NewResultType, NewResultType);
1551 return NewResultType;
1563 unsigned receiverNullabilityIdx = 0;
1564 if (std::optional<NullabilityKind> nullability =
1568 receiverNullabilityIdx = 1 +
static_cast<unsigned>(*nullability);
1571 unsigned resultNullabilityIdx = 0;
1572 if (std::optional<NullabilityKind> nullability =
1576 resultNullabilityIdx = 1 +
static_cast<unsigned>(*nullability);
1581 static const uint8_t
None = 0;
1582 static const uint8_t
NonNull = 1;
1585 static const uint8_t nullabilityMap[4][4] = {
1593 unsigned newResultNullabilityIdx
1594 = nullabilityMap[receiverNullabilityIdx][resultNullabilityIdx];
1595 if (newResultNullabilityIdx == resultNullabilityIdx)
1601 if (
auto attributed = dyn_cast<AttributedType>(resultType.
getTypePtr())) {
1602 resultType = attributed->getModifiedType();
1609 if (newResultNullabilityIdx > 0) {
1614 resultType, resultType);
1633 dyn_cast<ObjCCategoryImplDecl>(impl)) {
1634 iface = catImpl->getCategoryDecl();
1636 iface = impl->getClassInterface();
1646 for (
unsigned i = 0, e = overrides.size(); i != e; ++i) {
1667 SourceRange range = overridden->getReturnTypeSourceRange();
1670 loc = overridden->getLocation();
1671 Diag(loc, diag::note_related_result_type_explicit)
1717 if (!SelectorLocs.empty() && SelectorLocs.front().isValid())
1718 SelLoc = SelectorLocs.front();
1724 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
1725 if (Args[i]->isTypeDependent())
1737 Args[i] = result.
get();
1742 DiagID = diag::err_arc_method_not_found;
1744 DiagID = isClassMessage ? diag::warn_class_method_not_found
1745 : diag::warn_inst_method_not_found;
1750 DiagID = diag::err_method_not_found_with_typo;
1752 DiagID = isClassMessage ? diag::warn_class_method_not_found_with_typo
1753 : diag::warn_instance_method_not_found_with_typo;
1755 SourceRange SelectorRange(SelectorLocs.front(), SelectorLocs.back());
1757 Diag(SelLoc, DiagID)
1758 << Sel<< isClassMessage << MatchedSel
1761 Diag(SelLoc, DiagID) << Sel<< isClassMessage << MatchedSel;
1764 Diag(SelLoc, DiagID)
1765 << Sel << isClassMessage <<
SourceRange(SelectorLocs.front(),
1766 SelectorLocs.back());
1770 Diag(ThisClass->getLocation(), diag::note_receiver_class_declared);
1772 if (ThisClass->lookupClassMethod(Sel))
1773 Diag(RecRange.
getBegin(), diag::note_receiver_expr_here)
1775 ThisClass->getNameAsString());
1792 isClassMessage, isSuperMessage);
1801 if (Args.size() < NumNamedArgs) {
1802 Diag(SelLoc, diag::err_typecheck_call_too_few_args)
1803 << 2 << NumNamedArgs << static_cast<unsigned>(Args.size());
1809 std::optional<ArrayRef<QualType>> typeArgs =
1811 bool IsError =
false;
1812 for (
unsigned i = 0; i < NumNamedArgs; i++) {
1814 if (Args[i]->isTypeDependent())
1817 Expr *argExpr = Args[i];
1820 assert(argExpr &&
"CheckMessageArgumentTypes(): missing expression");
1822 if (param->
hasAttr<NoEscapeAttr>() &&
1824 if (
auto *BE = dyn_cast<BlockExpr>(
1826 BE->getBlockDecl()->setDoesNotEscape();
1831 !param->
hasAttr<CFConsumedAttr>())
1842 Args[i] = argE.
get();
1860 diag::err_call_incomplete_argument, argExpr))
1875 Args[i]->getType()->isBlockPointerType() &&
1879 Args[i] = arg.get();
1886 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
1887 if (Args[i]->isTypeDependent())
1893 Args[i] = Arg.
get();
1897 if (Args.size() != NumNamedArgs) {
1898 Diag(Args[NumNamedArgs]->getBeginLoc(),
1899 diag::err_typecheck_call_too_many_args)
1900 << 2 << NumNamedArgs << static_cast<unsigned>(Args.size())
1903 Args.back()->getEndLoc());
1911 CheckObjCMethodCall(Method, SelLoc,
ArrayRef(Args.data(), Args.size()));
1924 if (!method)
return false;
1927 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(receiver))
1939 if (
ObjCMethodDecl *method = iface->lookupMethod(sel, isInstance))
1944 if (
ObjCMethodDecl *method = iface->lookupPrivateMethod(sel, isInstance))
1949 for (
const auto *I : objType->
quals())
1963 for (
const auto *PROTO : OPT->
quals()) {
1964 if ((MD = PROTO->lookupMethod(Sel, Instance))) {
1984 Diag(MemberLoc, diag::err_invalid_property_name)
1994 diag::err_property_not_found_forward_class,
1995 MemberName, BaseRange))
2013 for (
const auto *I : OPT->
quals())
2023 SuperLoc, SuperType);
2080 if (!(PDecl->getPropertyAttributes() &
2083 diag::warn_property_access_suggest)
2084 << MemberName <<
QualType(OPT, 0) << PDecl->getName()
2089 if (Getter || Setter) {
2111 Corrected.isKeyword() ? nullptr : Corrected.getFoundDecl();
2112 if (ChosenDecl && isa<ObjCPropertyDecl>(ChosenDecl))
2113 if (cast<ObjCPropertyDecl>(ChosenDecl)->isClassProperty()) {
2116 Diag(MemberLoc, diag::err_class_property_found) << MemberName
2124 << MemberName <<
QualType(OPT, 0));
2126 TypoResult, MemberLoc,
2127 SuperLoc, SuperType, Super);
2137 diag::err_property_not_as_forward_class,
2138 MemberName, BaseExpr))
2142 diag::err_ivar_access_using_property_syntax_suggest)
2143 << MemberName <<
QualType(OPT, 0) << Ivar->getDeclName()
2148 Diag(MemberLoc, diag::err_property_not_found)
2170 if (receiverNamePtr->
isStr(
"super")) {
2172 if (
auto classDecl = CurMethod->getClassInterface()) {
2173 SuperType =
QualType(classDecl->getSuperClassType(), 0);
2174 if (CurMethod->isInstanceMethod()) {
2175 if (SuperType.
isNull()) {
2177 Diag(receiverNameLoc, diag::err_root_class_cannot_use_super)
2178 << CurMethod->getClassInterface()->getIdentifier();
2188 receiverNameLoc, T,
true);
2199 Diag(receiverNameLoc, diag::err_expected_either) << tok::identifier
2209 GetterSel = PD->getGetterName();
2210 SetterSel = PD->getSetterName();
2245 if (Getter || Setter) {
2254 propertyNameLoc, receiverNameLoc, IFace);
2256 return ExprError(
Diag(propertyNameLoc, diag::err_property_not_found)
2270 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
2275 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
2276 return std::make_unique<ObjCInterfaceOrSuperCCC>(*
this);
2286 bool HasTrailingDot,
2288 ReceiverType =
nullptr;
2293 if (IsSuper && S->isInObjcMethodScope())
2299 switch (
Result.getResultKind()) {
2324 Result.suppressDiagnostics();
2355 Result.getLookupNameInfo(),
Result.getLookupKind(), S,
nullptr, CCC,
2357 if (Corrected.isKeyword()) {
2361 PDiag(diag::err_unknown_receiver_suggest) << Name);
2368 PDiag(diag::err_unknown_receiver_suggest) << Name);
2390 Diag(SuperLoc, diag::err_invalid_receiver_to_message_super);
2396 Diag(SuperLoc, diag::err_no_super_class_message)
2401 QualType SuperTy(Class->getSuperClassType(), 0);
2404 Diag(SuperLoc, diag::err_root_class_cannot_use_super)
2405 << Class->getIdentifier();
2420 LBracLoc, SelectorLocs, RBracLoc, Args);
2427 SuperLoc, Sel,
nullptr,
2428 LBracLoc, SelectorLocs, RBracLoc, Args);
2432 bool isSuperReceiver,
2438 if (!ReceiverType.
isNull())
2443 Sel, Method, Loc, Loc, Loc, Args,
2457 if (refactor(Msg,*S.
NSAPIObj, ECommit)) {
2458 auto Builder = S.
Diag(MsgLoc, DiagID)
2466 switch (Edit.
Kind) {
2473 Builder.AddFixItHint(
2494 bool IsClassObjectCall) {
2500 const auto *SE = dyn_cast<ObjCSelectorExpr>(Args[0]->IgnoreParens());
2504 if (!IsClassObjectCall) {
2506 if (!OPT || !OPT->getInterfaceDecl())
2509 OPT->getInterfaceDecl()->lookupInstanceMethod(SE->getSelector());
2512 OPT->getInterfaceDecl()->lookupPrivateMethod(SE->getSelector());
2517 ImpliedMethod = IT->getDecl()->lookupClassMethod(SE->getSelector());
2520 IT->getDecl()->lookupPrivateClassMethod(SE->getSelector());
2525 if (Ret->isRecordType() || Ret->isVectorType() || Ret->isExtVectorType()) {
2526 S.
Diag(Loc, diag::warn_objc_unsafe_perform_selector)
2528 << (!Ret->isRecordType()
2530 : Ret->isUnionType() ? 1 : 0);
2532 diag::note_objc_unsafe_perform_selector_method_declared_here)
2543 Expr **Args,
unsigned NumArgs) {
2545 bool Format =
false;
2559 if (!Format || NumArgs <= Idx)
2562 Expr *FormatExpr = Args[Idx];
2567 S.
Diag(FormatExpr->
getExprLoc(), diag::warn_objc_cdirective_format_string)
2617 Diag(Loc, diag::err_missing_open_square_message_send)
2622 if (!SelectorLocs.empty() && SelectorLocs.front().isValid())
2623 SelectorSlotLocs = SelectorLocs;
2625 SelectorSlotLocs = Loc;
2631 unsigned NumArgs = ArgsIn.size();
2632 Expr **Args = ArgsIn.data();
2633 assert(SuperLoc.
isInvalid() &&
"Message to super with dependent type");
2635 ReceiverTypeInfo, Sel, SelectorLocs,
2637 RBracLoc, isImplicit);
2643 if (!ClassType || !(Class = ClassType->
getInterface())) {
2644 Diag(Loc, diag::err_invalid_receiver_class_message)
2648 assert(Class &&
"We don't know which class we're messaging?");
2659 ? diag::err_arc_receiver_forward_class
2660 : diag::warn_receiver_forward_class),
2670 Method = Class->lookupClassMethod(Sel);
2674 Method = Class->lookupPrivateClassMethod(Sel);
2677 nullptr,
false,
false, Class))
2685 unsigned NumArgs = ArgsIn.size();
2686 Expr **Args = ArgsIn.data();
2689 Method,
true, SuperLoc.
isValid(), LBracLoc,
2695 diag::err_illegal_message_expr_incomplete_type))
2699 Diag(SuperLoc, diag::err_messaging_super_with_direct_method)
2714 Diag(Loc, diag::warn_direct_initialize_call);
2722 Diag(Loc, diag::warn_direct_super_initialize_call);
2725 Diag(CurMeth->getLocation(), diag::note_method_declared_at)
2726 << CurMeth->getDeclName();
2737 Context, ReturnType, VK, LBracLoc, SuperLoc,
false,
2738 ReceiverType, Sel, SelectorLocs, Method,
ArrayRef(Args, NumArgs),
2739 RBracLoc, isImplicit);
2742 Context, ReturnType, VK, LBracLoc, ReceiverTypeInfo, Sel, SelectorLocs,
2743 Method,
ArrayRef(Args, NumArgs), RBracLoc, isImplicit);
2749 ReceiverType,
true);
2765 if (ReceiverType.
isNull())
2768 if (!ReceiverTypeInfo)
2773 nullptr, LBracLoc, SelectorLocs, RBracLoc,
2785 Sel, Method, Loc, Loc, Loc, Args,
2792 const auto *Protocol = dyn_cast<ObjCProtocolDecl>(M->
getDeclContext());
2796 if (
const auto *RootClass = dyn_cast_or_null<ObjCInterfaceDecl>(
2800 if (
P->getCanonicalDecl() == Protocol->getCanonicalDecl())
2845 assert((Receiver || SuperLoc.
isValid()) &&
"If the Receiver is null, the "
2846 "SuperLoc must be valid so we can "
2854 if (!SelectorLocs.empty() && SelectorLocs.front().isValid())
2855 SelectorSlotLocs = SelectorLocs;
2857 SelectorSlotLocs = Loc;
2861 Diag(Loc, diag::err_missing_open_square_message_send)
2882 unsigned NumArgs = ArgsIn.size();
2883 Expr **Args = ArgsIn.data();
2884 assert(SuperLoc.
isInvalid() &&
"Message to super with dependent type");
2887 SelectorLocs,
nullptr,
ArrayRef(Args, NumArgs), RBracLoc,
2897 ReceiverType = Receiver->
getType();
2910 Diag(Loc, diag::warn_bad_receiver_type) << ReceiverType << RecRange;
2913 CK_CPointerToObjCPointerCast).
get();
2918 CastKind Kind =
IsNull ? CK_NullToPointer : CK_IntegralToPointer;
2922 ReceiverType = Receiver->
getType();
2926 diag::err_incomplete_receiver_type))
2931 Receiver = result.
get();
2932 ReceiverType = Receiver->
getType();
2953 if (!Methods.empty()) {
2956 Method = Methods[0];
2960 Method = BestMethod;
2964 receiverIsIdLike, Methods))
2982 Diag(SelLoc, diag::warn_instance_method_on_class_found)
2995 Method = ClassDecl->lookupClassMethod(Sel);
2998 Method = ClassDecl->lookupPrivateClassMethod(Sel);
3013 if (!Methods.empty()) {
3016 Method = Methods[0];
3022 if (ID->getSuperClass())
3023 Diag(SelLoc, diag::warn_root_inst_method_not_found)
3031 Method = BestMethod;
3053 ClassDecl = OCIType->getInterfaceDecl();
3062 ? diag::err_arc_receiver_forward_instance
3063 : diag::warn_receiver_forward_instance,
3068 forwardClass = OCIType->getInterfaceDecl();
3070 diag::note_receiver_is_id);
3085 Diag(SelLoc, diag::err_arc_may_not_respond)
3086 << OCIType->getPointeeType() << Sel << RecRange
3087 <<
SourceRange(SelectorLocs.front(), SelectorLocs.back());
3091 if (!Method && (!Receiver || !
isSelfExpr(Receiver))) {
3095 if (OCIType->qual_empty()) {
3100 if (!Methods.empty()) {
3103 Method = Methods[0];
3108 Method = BestMethod;
3115 if (Method && !forwardClass)
3116 Diag(SelLoc, diag::warn_maynot_respond)
3117 << OCIType->getInterfaceDecl()->getIdentifier()
3126 Diag(Loc, diag::err_bad_receiver_type) << ReceiverType << RecRange;
3139 diag::err_messaging_unqualified_id_with_direct_method);
3151 diag::err_messaging_class_with_direct_method);
3164 Diag(SuperLoc, diag::err_messaging_super_with_direct_method);
3175 }
else if (ReceiverType->
isObjCIdType() && !isImplicit) {
3176 Diag(Receiver->
getExprLoc(), diag::warn_messaging_unqualified_id);
3179 if (DIFunctionScopeInfo &&
3182 bool isDesignatedInitChain =
false;
3189 if (!ID->declaresOrInheritsDesignatedInitializers() ||
3190 ID->isDesignatedInitializer(Sel)) {
3191 isDesignatedInitChain =
true;
3197 if (!isDesignatedInitChain) {
3201 assert(isDesignated && InitMethod);
3204 diag::warn_objc_designated_init_non_designated_init_call :
3205 diag::warn_objc_designated_init_non_super_designated_init_call);
3207 diag::note_objc_designated_init_marked_here);
3211 if (DIFunctionScopeInfo &&
3215 Diag(SelLoc, diag::warn_objc_secondary_init_super_init_call);
3222 unsigned NumArgs = ArgsIn.size();
3223 Expr **Args = ArgsIn.data();
3230 Method, ClassMessage, SuperLoc.
isValid(),
3231 LBracLoc, RBracLoc, RecRange, ReturnType, VK))
3236 diag::err_illegal_message_expr_incomplete_type))
3265 Diag(SelLoc, diag::err_arc_illegal_explicit_message)
3270 if (Method && NumArgs >= 1) {
3271 if (
const auto *SelExp =
3272 dyn_cast<ObjCSelectorExpr>(Args[0]->IgnoreParens())) {
3273 Selector ArgSel = SelExp->getSelector();
3276 SelExp->getSourceRange());
3280 SelExp->getSourceRange());
3283 switch (SelFamily) {
3290 if (!SelMethod->
hasAttr<NSReturnsNotRetainedAttr>()) {
3293 diag::err_arc_perform_selector_retains);
3300 if (SelMethod->
hasAttr<NSReturnsRetainedAttr>()) {
3303 diag::err_arc_perform_selector_retains);
3312 Diag(SelLoc, diag::warn_arc_perform_selector_leaks);
3313 Diag(Args[0]->getExprLoc(), diag::note_used_here);
3326 Context, ReturnType, VK, LBracLoc, SuperLoc,
true,
3327 ReceiverType, Sel, SelectorLocs, Method,
ArrayRef(Args, NumArgs),
3328 RBracLoc, isImplicit);
3331 Context, ReturnType, VK, LBracLoc, Receiver, Sel, SelectorLocs, Method,
3332 ArrayRef(Args, NumArgs), RBracLoc, isImplicit);
3337 bool IsClassObjectCall = ClassMessage;
3344 if (OPT->getObjectType()->isObjCClass()) {
3346 IsClassObjectCall =
true;
3354 ReceiverType, IsClassObjectCall);
3367 Result->setDelegateInitCall(
true);
3378 if (!isImplicit && Method) {
3391 CheckObjCCircularContainer(
Result);
3421 if (isa<ParenListExpr>(Receiver)) {
3436 nullptr, LBracLoc, SelectorLocs,
3470 bool isIndirect =
false;
3474 type = ref->getPointeeType();
3481 type = ptr->getPointeeType();
3488 }
else if (
const ArrayType *array =
type->getAsArrayTypeUnsafe()) {
3489 type =
QualType(array->getElementType()->getBaseElementTypeUnsafe(), 0);
3497 if (
type->isObjCARCBridgableType())
3502 if (
type->isObjCARCBridgableType())
3523 ACCResult merge(ACCResult left, ACCResult right) {
3524 if (left == right)
return left;
3525 if (left == ACC_bottom)
return right;
3526 if (right == ACC_bottom)
return left;
3532 class ARCCastChecker :
public StmtVisitor<ARCCastChecker, ACCResult> {
3542 return type->isCARCBridgableType();
3548 : Context(Context), SourceClass(source), TargetClass(target),
3549 Diagnose(diagnose) {}
3552 ACCResult Visit(
Expr *e) {
3556 ACCResult VisitStmt(
Stmt *
s) {
3561 ACCResult VisitExpr(
Expr *e) {
3577 ACCResult VisitCastExpr(
CastExpr *e) {
3579 case CK_NullToPointer:
3583 case CK_LValueToRValue:
3585 case CK_CPointerToObjCPointerCast:
3586 case CK_BlockPointerToObjCPointerCast:
3587 case CK_AnyPointerToBlockPointerCast:
3602 return Visit(e->
getRHS());
3608 if (left == ACC_invalid)
return ACC_invalid;
3619 ACCResult VisitStmtExpr(
StmtExpr *e) {
3638 return ACC_plusZero;
3646 ACCResult VisitCallExpr(
CallExpr *e) {
3648 if (ACCResult result = checkCallToFunction(fn))
3651 return super::VisitCallExpr(e);
3663 if (fn->
hasAttr<CFReturnsNotRetainedAttr>())
3664 return ACC_plusZero;
3669 if (fn->
hasAttr<CFReturnsRetainedAttr>())
3670 return Diagnose ? ACC_plusOne
3675 if (builtinID == Builtin::BI__builtin___CFStringMakeConstantString)
3679 if (!fn->
hasAttr<CFAuditedTransferAttr>())
3684 return Diagnose ? ACC_plusOne
3687 return ACC_plusZero;
3700 return checkCallToMethod(method);
3704 if (!method)
return ACC_invalid;
3713 if (method->
hasAttr<CFReturnsNotRetainedAttr>())
3714 return ACC_plusZero;
3718 if (method->
hasAttr<CFReturnsRetainedAttr>())
3730 return ACC_plusZero;
3744template <
typename DiagBuilderT>
3748 Expr *realCast,
const char *bridgeKeyword,
const char *CFBridgeName) {
3764 NCE->getAngleBrackets().getEnd());
3768 char PrevChar = *
SM.getCharacterData(range.getBegin().getLocWithOffset(-1));
3772 BridgeCall += CFBridgeName;
3779 castedE = CCE->getSubExpr();
3786 char PrevChar = *
SM.getCharacterData(range.getBegin().getLocWithOffset(-1));
3790 BridgeCall += CFBridgeName;
3792 if (isa<ParenExpr>(castedE)) {
3810 std::string castCode =
"(";
3811 castCode += bridgeKeyword;
3815 NCE->getAngleBrackets().getEnd());
3819 std::string castCode =
"(";
3820 castCode += bridgeKeyword;
3825 if (isa<ParenExpr>(castedE)) {
3839template <
typename T>
3846 for (
auto *Redecl : RT->getDecl()->getMostRecentDecl()->redecls()) {
3847 if (
auto *
attr = Redecl->getAttr<T>())
3858 TDNDecl = TD->getDecl();
3859 if (ObjCBridgeRelatedAttr *ObjCBAttr =
3860 getObjCBridgeAttr<ObjCBridgeRelatedAttr>(TD))
3877 UnavailableAttr::IR_ARCForbiddenConversion))
3890 unsigned srcKind = 0;
3914 S.
Diag(loc, diag::err_arc_cast_requires_bridge)
3923 ACCResult CreateRule =
3925 assert(CreateRule != ACC_bottom &&
"This cast should already be accepted.");
3926 if (CreateRule != ACC_plusOne)
3929 ? S.
Diag(noteLoc, diag::note_arc_bridge)
3930 : S.
Diag(noteLoc, diag::note_arc_cstyle_bridge);
3933 castType,
castExpr, realCast,
"__bridge ",
3936 if (CreateRule != ACC_plusZero)
3939 ? S.
Diag(noteLoc, diag::note_arc_cstyle_bridge_transfer)
3942 diag::note_arc_bridge_transfer)
3943 << castExprType << br;
3946 castType,
castExpr, realCast,
"__bridge_transfer ",
3947 br ?
"CFBridgingRelease" :
nullptr);
3956 S.
Diag(loc, diag::err_arc_cast_requires_bridge)
3964 ACCResult CreateRule =
3966 assert(CreateRule != ACC_bottom &&
"This cast should already be accepted.");
3967 if (CreateRule != ACC_plusOne)
3970 ? S.
Diag(noteLoc, diag::note_arc_bridge)
3971 : S.
Diag(noteLoc, diag::note_arc_cstyle_bridge);
3973 castType,
castExpr, realCast,
"__bridge ",
3976 if (CreateRule != ACC_plusZero)
3979 ? S.
Diag(noteLoc, diag::note_arc_cstyle_bridge_retained)
3982 diag::note_arc_bridge_retained)
3986 castType,
castExpr, realCast,
"__bridge_retained ",
3987 br ?
"CFBridgingRetain" :
nullptr);
3993 S.
Diag(loc, diag::err_arc_mismatched_cast)
3995 << srcKind << castExprType << castType
3996 << castRange <<
castExpr->getSourceRange();
3999template <
typename TB>
4001 bool &HadTheAttribute,
bool warn) {
4003 HadTheAttribute =
false;
4006 if (TB *ObjCBAttr = getObjCBridgeAttr<TB>(TD)) {
4008 HadTheAttribute =
true;
4009 if (Parm->isStr(
"id"))
4022 = InterfacePointerType->getObjectType()->getInterface();
4023 if ((CastClass == ExprClass) ||
4027 S.
Diag(
castExpr->getBeginLoc(), diag::warn_objc_invalid_bridge)
4032 castType, ExprClass)))
4039 S.
Diag(
castExpr->getBeginLoc(), diag::warn_objc_invalid_bridge)
4040 << T <<
Target->getName() << castType;
4042 S.
Diag(
Target->getBeginLoc(), diag::note_declared_at);
4049 diag::err_objc_cf_bridged_not_interface)
4062template <
typename TB>
4064 bool &HadTheAttribute,
bool warn) {
4066 HadTheAttribute =
false;
4069 if (TB *ObjCBAttr = getObjCBridgeAttr<TB>(TD)) {
4071 HadTheAttribute =
true;
4072 if (Parm->isStr(
"id"))
4084 castExpr->getType()->getAsObjCInterfacePointerType()) {
4086 = InterfacePointerType->getObjectType()->getInterface();
4087 if ((CastClass == ExprClass) ||
4092 diag::warn_objc_invalid_bridge_to_cf)
4093 <<
castExpr->getType()->getPointeeType() << T;
4097 }
else if (
castExpr->getType()->isObjCIdType() ||
4107 diag::warn_objc_invalid_bridge_to_cf)
4108 <<
castExpr->getType() << castType;
4110 S.
Diag(
Target->getBeginLoc(), diag::note_declared_at);
4117 diag::err_objc_ns_bridged_invalid_cfobject)
4118 <<
castExpr->getType() << castType;
4121 S.
Diag(
Target->getBeginLoc(), diag::note_declared_at);
4138 bool HasObjCBridgeAttr;
4139 bool ObjCBridgeAttrWillNotWarn =
4140 CheckObjCBridgeNSCast<ObjCBridgeAttr>(*
this, castType,
castExpr, HasObjCBridgeAttr,
4142 if (ObjCBridgeAttrWillNotWarn && HasObjCBridgeAttr)
4144 bool HasObjCBridgeMutableAttr;
4145 bool ObjCBridgeMutableAttrWillNotWarn =
4146 CheckObjCBridgeNSCast<ObjCBridgeMutableAttr>(*
this, castType,
castExpr,
4147 HasObjCBridgeMutableAttr,
false);
4148 if (ObjCBridgeMutableAttrWillNotWarn && HasObjCBridgeMutableAttr)
4151 if (HasObjCBridgeAttr)
4152 CheckObjCBridgeNSCast<ObjCBridgeAttr>(*
this, castType,
castExpr, HasObjCBridgeAttr,
4154 else if (HasObjCBridgeMutableAttr)
4155 CheckObjCBridgeNSCast<ObjCBridgeMutableAttr>(*
this, castType,
castExpr,
4156 HasObjCBridgeMutableAttr,
true);
4159 bool HasObjCBridgeAttr;
4160 bool ObjCBridgeAttrWillNotWarn =
4161 CheckObjCBridgeCFCast<ObjCBridgeAttr>(*
this, castType,
castExpr, HasObjCBridgeAttr,
4163 if (ObjCBridgeAttrWillNotWarn && HasObjCBridgeAttr)
4165 bool HasObjCBridgeMutableAttr;
4166 bool ObjCBridgeMutableAttrWillNotWarn =
4167 CheckObjCBridgeCFCast<ObjCBridgeMutableAttr>(*
this, castType,
castExpr,
4168 HasObjCBridgeMutableAttr,
false);
4169 if (ObjCBridgeMutableAttrWillNotWarn && HasObjCBridgeMutableAttr)
4172 if (HasObjCBridgeAttr)
4173 CheckObjCBridgeCFCast<ObjCBridgeAttr>(*
this, castType,
castExpr, HasObjCBridgeAttr,
4175 else if (HasObjCBridgeMutableAttr)
4176 CheckObjCBridgeCFCast<ObjCBridgeMutableAttr>(*
this, castType,
castExpr,
4177 HasObjCBridgeMutableAttr,
true);
4184 if (PRE->isExplicitProperty()) {
4186 SrcType = PDecl->getType();
4188 else if (PRE->isImplicitProperty()) {
4190 SrcType = Getter->getReturnType();
4213 : CK_CPointerToObjCPointerCast;
4225 bool CfToNs,
bool Diagnose) {
4226 QualType T = CfToNs ? SrcType : DestType;
4242 Diag(Loc, diag::err_objc_bridged_related_invalid_class) << RCId
4243 << SrcType << DestType;
4250 RelatedClass = cast<ObjCInterfaceDecl>(
Target);
4253 Diag(Loc, diag::err_objc_bridged_related_invalid_class_name) << RCId
4254 << SrcType << DestType;
4257 Diag(
Target->getBeginLoc(), diag::note_declared_at);
4263 if (CfToNs && CMId) {
4268 Diag(Loc, diag::err_objc_bridged_related_known_method)
4269 << SrcType << DestType << Sel <<
false;
4277 if (!CfToNs && IMId) {
4279 InstanceMethod = RelatedClass->
lookupMethod(Sel,
true);
4280 if (!InstanceMethod) {
4282 Diag(Loc, diag::err_objc_bridged_related_known_method)
4283 << SrcType << DestType << Sel <<
true;
4295 Expr *&SrcExpr,
bool Diagnose) {
4300 if (!CfToNs && !NsToCf)
4308 ClassMethod, InstanceMethod, TDNDecl,
4316 std::string ExpressionString =
"[";
4318 ExpressionString +=
" ";
4319 ExpressionString += ClassMethod->getSelector().getAsString();
4323 Diag(Loc, diag::err_objc_bridged_related_known_method)
4324 << SrcType << DestType << ClassMethod->getSelector() <<
false
4333 Expr *args[] = { SrcExpr };
4335 ClassMethod->getLocation(),
4336 ClassMethod->getSelector(), ClassMethod,
4338 SrcExpr = msg.
get();
4345 if (InstanceMethod) {
4347 std::string ExpressionString;
4350 if (InstanceMethod->isPropertyAccessor())
4352 InstanceMethod->findPropertyDecl()) {
4354 ExpressionString =
".";
4355 ExpressionString += PDecl->getNameAsString();
4356 Diag(Loc, diag::err_objc_bridged_related_known_method)
4357 << SrcType << DestType << InstanceMethod->getSelector() <<
true
4360 if (ExpressionString.empty()) {
4362 ExpressionString =
" ";
4363 ExpressionString += InstanceMethod->getSelector().getAsString();
4364 ExpressionString +=
"]";
4366 Diag(Loc, diag::err_objc_bridged_related_known_method)
4367 << SrcType << DestType << InstanceMethod->getSelector() <<
true
4375 SrcExpr, SrcType, InstanceMethod->getLocation(),
4376 InstanceMethod->getSelector(), InstanceMethod, std::nullopt);
4377 SrcExpr = msg.
get();
4388 bool Diagnose,
bool DiagnoseCFAudited,
4400 if (exprACTC == castACTC) {
4405 castType != castExprType) {
4411 if (
const ParenType *PT = dyn_cast<ParenType>(DT))
4412 QDT = PT->desugar();
4413 else if (
const TypeOfType *TP = dyn_cast<TypeOfType>(DT))
4414 QDT = TP->desugar();
4415 else if (
const AttributedType *AT = dyn_cast<AttributedType>(DT))
4416 QDT = AT->desugar();
4417 if (QDT != castType &&
4422 Diag(loc, diag::err_arc_nolifetime_behavior);
4456 switch (ARCCastChecker(
Context, exprACTC, castACTC,
false).Visit(
castExpr)) {
4469 CK_ARCConsumeObject,
castExpr,
nullptr,
4495 (Opc == BO_NE || Opc == BO_EQ))) {
4517 castType =
cast->getTypeAsWritten();
4520 castRange =
cast->getTypeInfoAsWritten()->getTypeLoc().getSourceRange();
4521 castType =
cast->getTypeAsWritten();
4524 llvm_unreachable(
"Unexpected ImplicitCastExpr");
4542 if (
ParenExpr *pe = dyn_cast<ParenExpr>(e)) {
4545 }
else if (
UnaryOperator *uo = dyn_cast<UnaryOperator>(e)) {
4546 assert(uo->getOpcode() == UO_Extension);
4550 uo->getOperatorLoc(),
false,
4553 assert(!gse->isResultDependent());
4555 unsigned n = gse->getNumAssocs();
4558 subExprs.reserve(n);
4559 subTypes.reserve(n);
4561 subTypes.push_back(assoc.getTypeSourceInfo());
4562 Expr *sub = assoc.getAssociationExpr();
4563 if (assoc.isSelected())
4565 subExprs.push_back(sub);
4569 Context, gse->getGenericLoc(), gse->getControllingExpr(), subTypes,
4570 subExprs, gse->getDefaultLoc(), gse->getRParenLoc(),
4571 gse->containsUnexpandedParameterPack(), gse->getResultIndex());
4573 assert(isa<ImplicitCastExpr>(e) &&
"bad form of unbridged cast!");
4574 return cast<ImplicitCastExpr>(e)->getSubExpr();
4584 if (isa<ObjCObjectPointerType>(canCastType) &&
4590 return !ObjI->isArcWeakrefUnavailable();
4597 Expr *curExpr = e, *prevExpr =
nullptr;
4602 if (
auto *pe = dyn_cast<ParenExpr>(curExpr)) {
4604 curExpr = pe->getSubExpr();
4608 if (
auto *ce = dyn_cast<CastExpr>(curExpr)) {
4609 if (
auto *ice = dyn_cast<ImplicitCastExpr>(ce))
4610 if (ice->getCastKind() == CK_ARCReclaimReturnedObject) {
4612 return ice->getSubExpr();
4613 if (
auto *pe = dyn_cast<ParenExpr>(prevExpr))
4614 pe->setSubExpr(ice->getSubExpr());
4616 cast<CastExpr>(prevExpr)->setSubExpr(ice->getSubExpr());
4621 curExpr = ce->getSubExpr();
4639 SubExpr = SubResult.
get();
4646 bool MustConsume =
false;
4653 : CK_CPointerToObjCPointerCast);
4660 Diag(BridgeKeywordLoc, diag::err_arc_bridge_cast_wrong_kind)
4667 Diag(BridgeKeywordLoc, diag::note_arc_bridge)
4669 Diag(BridgeKeywordLoc, diag::note_arc_bridge_transfer)
4672 br ?
"CFBridgingRelease "
4673 :
"__bridge_transfer ");
4703 Diag(BridgeKeywordLoc, diag::err_arc_bridge_cast_wrong_kind)
4711 Diag(BridgeKeywordLoc, diag::note_arc_bridge)
4713 Diag(BridgeKeywordLoc, diag::note_arc_bridge_retained)
4716 br ?
"CFBridgingRetain " :
"__bridge_retained");
4723 Diag(LParenLoc, diag::err_arc_bridge_cast_incompatible)
4724 << FromType << T << Kind
Defines the clang::ASTContext interface.
static StringRef bytes(const std::vector< T, Allocator > &v)
Defines enum values for all the target-independent builtin functions.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Defines the clang::Preprocessor interface.
static bool CheckObjCBridgeNSCast(Sema &S, QualType castType, Expr *castExpr, bool &HadTheAttribute, bool warn)
static QualType stripObjCInstanceType(ASTContext &Context, QualType T)
static void diagnoseObjCARCConversion(Sema &S, SourceRange castRange, QualType castType, ARCConversionTypeClass castACTC, Expr *castExpr, Expr *realCast, ARCConversionTypeClass exprACTC, Sema::CheckedConversionKind CCK)
static ObjCMethodDecl * findMethodInCurrentClass(Sema &S, Selector Sel)
static void checkCocoaAPI(Sema &S, const ObjCMessageExpr *Msg)
static ObjCMethodDecl * getNSNumberFactoryMethod(Sema &S, SourceLocation Loc, QualType NumberType, bool isLiteral=false, SourceRange R=SourceRange())
Retrieve the NSNumber factory method that should be used to create an Objective-C literal for the giv...
static ObjCMethodDecl * LookupDirectMethodInGlobalPool(Sema &S, Selector Sel, bool &onlyDirect, bool &anyDirect)
static Expr * maybeUndoReclaimObject(Expr *e)
Look for an ObjCReclaimReturnedObject cast and destroy it.
static bool CheckObjCBridgeCFCast(Sema &S, QualType castType, Expr *castExpr, bool &HadTheAttribute, bool warn)
static void CheckObjCDictionaryLiteralDuplicateKeys(Sema &S, ObjCDictionaryLiteral *Literal)
Check for duplicate keys in an ObjC dictionary literal.
static NSAPI::NSClassIdKindKind ClassKindFromLiteralKind(Sema::ObjCLiteralKind LiteralKind)
Maps ObjCLiteralKind to NSClassIdKindKind.
static bool isAnyCLike(ARCConversionTypeClass ACTC)
static void RemoveSelectorFromWarningCache(Sema &S, Expr *Arg)
static void DiagnoseMismatchedSelectors(Sema &S, SourceLocation AtLoc, ObjCMethodDecl *Method, SourceLocation LParenLoc, SourceLocation RParenLoc, bool WarnMultipleSelectors)
static bool HelperToDiagnoseMismatchedMethodsInGlobalPool(Sema &S, SourceLocation AtLoc, SourceLocation LParenLoc, SourceLocation RParenLoc, ObjCMethodDecl *Method, ObjCMethodList &MethList)
static void applyCocoaAPICheck(Sema &S, const ObjCMessageExpr *Msg, unsigned DiagID, bool(*refactor)(const ObjCMessageExpr *, const NSAPI &, edit::Commit &))
static ObjCMethodDecl * LookupDirectMethodInMethodList(Sema &S, Selector Sel, ObjCMethodList &MethList, bool &onlyDirect, bool &anyDirect)
static ObjCBridgeRelatedAttr * ObjCBridgeRelatedAttrFromType(QualType T, TypedefNameDecl *&TDNDecl)
static T * getObjCBridgeAttr(const TypedefType *TD)
static ARCConversionTypeClass classifyTypeForARCConversion(QualType type)
static bool isAnyRetainable(ARCConversionTypeClass ACTC)
@ ACTC_voidPtr
void* might be a normal C type, or it might a CF type.
@ ACTC_retainable
id, void (^)()
@ ACTC_coreFoundation
struct A*
@ ACTC_indirectRetainable
id*, id***, void (^*)(),
@ ACTC_none
int, void, struct A
static QualType getBaseMessageSendResultType(Sema &S, QualType ReceiverType, ObjCMethodDecl *Method, bool isClassMessage, bool isSuperMessage)
Determine the result type of a message send based on the receiver type, method, and the kind of messa...
static const ObjCMethodDecl * findExplicitInstancetypeDeclarer(const ObjCMethodDecl *MD, QualType instancetype)
Look for an ObjC method whose result type exactly matches the given type.
static void DiagnoseCStringFormatDirectiveInObjCAPI(Sema &S, ObjCMethodDecl *Method, Selector Sel, Expr **Args, unsigned NumArgs)
Diagnose use of s directive in an NSString which is being passed as formatting string to formatting m...
static bool isMethodDeclaredInRootProtocol(Sema &S, const ObjCMethodDecl *M)
static void addFixitForObjCARCConversion(Sema &S, DiagBuilderT &DiagB, Sema::CheckedConversionKind CCK, SourceLocation afterLParen, QualType castType, Expr *castExpr, Expr *realCast, const char *bridgeKeyword, const char *CFBridgeName)
static bool validateBoxingMethod(Sema &S, SourceLocation Loc, const ObjCInterfaceDecl *Class, Selector Sel, const ObjCMethodDecl *Method)
Emits an error if the given method does not exist, or if the return type is not an Objective-C object...
static bool ValidateObjCLiteralInterfaceDecl(Sema &S, ObjCInterfaceDecl *Decl, SourceLocation Loc, Sema::ObjCLiteralKind LiteralKind)
Validates ObjCInterfaceDecl availability.
static ObjCInterfaceDecl * LookupObjCInterfaceDeclForLiteral(Sema &S, SourceLocation Loc, Sema::ObjCLiteralKind LiteralKind)
Looks up ObjCInterfaceDecl of a given NSClassIdKindKind.