28 #include "llvm/ADT/SmallString.h" 29 #include "llvm/Support/ConvertUTF.h" 31 using namespace clang;
33 using llvm::makeArrayRef;
44 if (Strings.size() != 1) {
49 for (
Expr *E : Strings) {
50 S = cast<StringLiteral>(E);
69 assert(CAT &&
"String literal not of constant array type!");
74 false, StrTy, &StrLocs[0],
78 return BuildObjCStringLiteral(AtLocs[0], S);
83 if (CheckObjCString(S))
93 }
else if (getLangOpts().NoConstantCFStrings) {
95 std::string StringClass(getLangOpts().ObjCConstantStringClass);
97 if (StringClass.empty())
98 NSIdent = &Context.
Idents.
get(
"NSConstantString");
100 NSIdent = &Context.
Idents.
get(StringClass);
102 NamedDecl *IF = LookupSingleName(TUScope, NSIdent, AtLoc,
117 NamedDecl *IF = LookupSingleName(TUScope, NSIdent, AtLoc,
152 S.
Diag(Loc, diag::err_undeclared_boxing_method) << Sel << Class->
getName();
159 S.
Diag(Loc, diag::err_objc_literal_method_sig)
172 switch (LiteralKind) {
190 llvm_unreachable(
"LiteralKind can't be converted into a ClassKind");
202 S.
Diag(Loc, diag::err_undeclared_objc_literal_class)
203 << II->
getName() << LiteralKind;
206 S.
Diag(Loc, diag::err_undeclared_objc_literal_class)
207 << Decl->
getName() << LiteralKind;
247 S.
NSAPIObj->getNSNumberFactoryMethodKind(NumberType);
251 S.
Diag(Loc, diag::err_invalid_nsnumber_type)
284 if (!Method && S.
getLangOpts().DebuggerObjCLiteral) {
322 switch (Char->getKind()) {
325 NumberType = Context.
CharTy;
354 ExprResult ConvertedNumber = PerformCopyInitialization(Entity,
359 Number = ConvertedNumber.
get();
362 return MaybeBindToTemporary(
372 Inner = ActOnCXXBoolLiteral(ValueLoc, Value? tok::kw_true : tok::kw_false);
376 Inner = ActOnIntegerConstant(ValueLoc, Value? 1 : 0);
377 Inner = ImpCastExprToType(Inner.
get(), Context.
BoolTy,
378 CK_IntegralToBoolean);
381 return BuildObjCNumericLiteral(AtLoc, Inner.
get());
388 bool ArrayLiteral =
false) {
396 Element = Result.
get();
408 return Seq.Perform(S, Entity, Kind, Element);
411 Expr *OrigElement = Element;
417 Element = Result.
get();
422 bool Recovered =
false;
425 if (isa<IntegerLiteral>(OrigElement) ||
426 isa<CharacterLiteral>(OrigElement) ||
427 isa<FloatingLiteral>(OrigElement) ||
428 isa<ObjCBoolLiteralExpr>(OrigElement) ||
429 isa<CXXBoolLiteralExpr>(OrigElement)) {
430 if (S.
NSAPIObj->getNSNumberFactoryMethodKind(OrigElement->
getType())) {
431 int Which = isa<CharacterLiteral>(OrigElement) ? 1
432 : (isa<CXXBoolLiteralExpr>(OrigElement) ||
433 isa<ObjCBoolLiteralExpr>(OrigElement)) ? 2
442 if (Result.isInvalid())
445 Element = Result.get();
450 else if (
StringLiteral *String = dyn_cast<StringLiteral>(OrigElement)) {
451 if (String->isAscii()) {
457 if (Result.isInvalid())
460 Element = Result.get();
473 dyn_cast<ObjCStringLiteral>(OrigElement)) {
475 unsigned numConcat = SL->getNumConcatenated();
478 bool hasMacro =
false;
479 for (
unsigned i = 0; i < numConcat ; ++i)
480 if (SL->getStrTokenLoc(i).isMacroID()) {
486 diag::warn_concatenated_nsarray_literal)
509 ExprResult RValue = DefaultFunctionArrayLvalueConversion(ValueExpr);
514 ValueExpr = RValue.
get();
532 if (
auto *CE = dyn_cast<ImplicitCastExpr>(ValueExpr))
533 if (CE->getCastKind() == CK_ArrayToPointerDecay)
535 dyn_cast<StringLiteral>(CE->getSubExpr()->IgnoreParens())) {
536 assert((SL->isAscii() || SL->isUTF8()) &&
537 "unexpected character encoding");
538 StringRef Str = SL->getString();
539 const llvm::UTF8 *StrBegin = Str.bytes_begin();
540 const llvm::UTF8 *StrEnd = Str.bytes_end();
542 if (llvm::isLegalUTF8String(&StrBegin, StrEnd)) {
546 NSStringPointer, NSStringPointer);
547 return new (Context)
ObjCBoxedExpr(CE, BoxedType,
nullptr, SR);
550 Diag(SL->getBeginLoc(), diag::warn_objc_boxing_invalid_utf8_string)
551 << NSStringPointer << SL->getSourceRange();
554 if (!StringWithUTF8StringMethod) {
559 BoxingMethod = NSStringDecl->lookupClassMethod(stringWithUTF8String);
560 if (!BoxingMethod && getLangOpts().DebuggerObjCLiteral) {
565 NSStringPointer, ReturnTInfo, NSStringDecl,
585 stringWithUTF8String, BoxingMethod))
588 StringWithUTF8StringMethod = BoxingMethod;
591 BoxingMethod = StringWithUTF8StringMethod;
592 BoxedType = NSStringPointer;
601 }
else if (ValueType->isBuiltinType()) {
609 dyn_cast<CharacterLiteral>(ValueExpr->
IgnoreParens())) {
612 switch (Char->getKind()) {
615 ValueType = Context.
CharTy;
635 BoxedType = NSNumberPointer;
637 if (!ET->getDecl()->isComplete()) {
638 Diag(Loc, diag::err_objc_incomplete_boxed_expression_type)
644 ET->getDecl()->getIntegerType());
645 BoxedType = NSNumberPointer;
646 }
else if (ValueType->isObjCBoxableRecordType()) {
664 if (!ValueWithBytesObjCTypeMethod) {
672 BoxingMethod = NSValueDecl->lookupClassMethod(ValueWithBytesObjCType);
673 if (!BoxingMethod && getLangOpts().DebuggerObjCLiteral) {
678 NSValuePointer, ReturnTInfo, NSValueDecl,
696 Params.push_back(bytes);
706 Params.push_back(type);
713 ValueWithBytesObjCType, BoxingMethod))
716 ValueWithBytesObjCTypeMethod = BoxingMethod;
719 if (!ValueType.isTriviallyCopyableType(Context)) {
720 Diag(Loc, diag::err_objc_non_trivially_copyable_boxed_expression_type)
725 BoxingMethod = ValueWithBytesObjCTypeMethod;
726 BoxedType = NSValuePointer;
730 Diag(Loc, diag::err_objc_illegal_boxed_expression_type)
735 DiagnoseUseOfDecl(BoxingMethod, Loc);
738 if (ValueType->isObjCBoxableRecordType()) {
740 ConvertedValueExpr = PerformCopyInitialization(IE, ValueExpr->
getExprLoc(),
747 ConvertedValueExpr = PerformCopyInitialization(IE,
SourceLocation(),
753 ValueExpr = ConvertedValueExpr.
get();
758 return MaybeBindToTemporary(BoxedExpr);
767 assert(!LangOpts.isSubscriptPointerArithmetic());
772 "base or index cannot have dependent type here");
776 ExprResult Result = CheckPlaceholderExpr(IndexExpr);
779 IndexExpr = Result.
get();
782 Result = DefaultLvalueConversion(BaseExpr);
785 BaseExpr = Result.
get();
790 getterMethod, setterMethod, RB);
806 if (!ArrayWithObjectsMethod) {
810 if (!Method && getLangOpts().DebuggerObjCLiteral) {
827 Params.push_back(objects);
835 Params.push_back(cnt);
850 diag::note_objc_literal_method_param)
857 if (!Method->
parameters()[1]->getType()->isIntegerType()) {
861 diag::note_objc_literal_method_param)
869 ArrayWithObjectsMethod = Method;
872 QualType ObjectsType = ArrayWithObjectsMethod->parameters()[0]->getType();
877 Expr **ElementsBuffer = Elements.data();
878 for (
unsigned I = 0, N = Elements.size(); I != N; ++I) {
885 ElementsBuffer[I] = Converted.
get();
892 return MaybeBindToTemporary(
894 ArrayWithObjectsMethod, SR));
901 if (!NSDictionaryDecl) {
904 if (!NSDictionaryDecl) {
912 if (!DictionaryWithObjectsMethod) {
913 Selector Sel = NSAPIObj->getNSDictionarySelector(
915 ObjCMethodDecl *Method = NSDictionaryDecl->lookupClassMethod(Sel);
916 if (!Method && getLangOpts().DebuggerObjCLiteral) {
933 Params.push_back(objects);
941 Params.push_back(keys);
949 Params.push_back(cnt);
965 diag::note_objc_literal_method_param)
979 if (QIDNSCopying.isNull()) {
993 if (!QIDNSCopying.isNull())
1002 diag::note_objc_literal_method_param)
1015 diag::note_objc_literal_method_param)
1022 DictionaryWithObjectsMethod = Method;
1025 QualType ValuesT = DictionaryWithObjectsMethod->parameters()[0]->getType();
1027 QualType KeysT = DictionaryWithObjectsMethod->parameters()[1]->getType();
1032 bool HasPackExpansions =
false;
1046 Element.Key = Key.
get();
1047 Element.Value = Value.
get();
1049 if (Element.EllipsisLoc.isInvalid())
1052 if (!Element.Key->containsUnexpandedParameterPack() &&
1053 !Element.Value->containsUnexpandedParameterPack()) {
1054 Diag(Element.EllipsisLoc,
1055 diag::err_pack_expansion_without_parameter_packs)
1057 Element.Value->getEndLoc());
1061 HasPackExpansions =
true;
1068 Context, Elements, HasPackExpansions, Ty,
1069 DictionaryWithObjectsMethod, SR));
1082 if (RequireCompleteType(AtLoc, EncodedType,
1083 diag::err_incomplete_type_objc_at_encode,
1090 if (!NotEncodedT.
isNull())
1091 Diag(AtLoc, diag::warn_incomplete_encoded_type)
1092 << EncodedType << NotEncodedT;
1099 return new (Context)
ObjCEncodeExpr(StrTy, EncodedTypeInfo, AtLoc, RParenLoc);
1109 QualType EncodedType = GetTypeFromParser(ty, &TInfo);
1112 getLocForEndOfToken(LParenLoc));
1114 return BuildObjCEncodeExpression(AtLoc, TInfo, RParenLoc);
1124 bool Warned =
false;
1127 if (MatchingMethodDecl == Method ||
1135 S.
Diag(AtLoc, diag::warn_multiple_selectors)
1141 S.
Diag(MatchingMethodDecl->
getLocation(), diag::note_method_declared_at)
1152 bool WarnMultipleSelectors) {
1153 if (!WarnMultipleSelectors ||
1156 bool Warned =
false;
1157 for (Sema::GlobalMethodPool::iterator b = S.
MethodPool.begin(),
1162 Method, InstMethList))
1168 Method, ClsMethList) || Warned)
1189 for (Sema::GlobalMethodPool::iterator b = S.
MethodPool.begin(),
1207 bool WarnMultipleSelectors) {
1211 Method = LookupFactoryMethodInGlobalPool(Sel,
1214 if (
const ObjCMethodDecl *OM = SelectorsForTypoCorrection(Sel)) {
1215 Selector MatchedSel = OM->getSelector();
1218 Diag(SelLoc, diag::warn_undeclared_selector_with_typo)
1219 << Sel << MatchedSel
1223 Diag(SelLoc, diag::warn_undeclared_selector) << Sel;
1228 WarnMultipleSelectors);
1230 Diag(AtLoc, diag::err_direct_selector_expression)
1239 !getSourceManager().isInSystemHeader(Method->
getLocation()))
1240 ReferencedSelectors.insert(std::make_pair(Sel, AtLoc));
1244 if (getLangOpts().ObjCAutoRefCount) {
1251 Diag(AtLoc, diag::err_arc_illegal_selector) <<
1280 Diag(ProtoLoc, diag::err_undeclared_protocol) << ProtocolId;
1284 Diag(ProtoLoc, diag::err_atprotocol_protocol) << PDecl;
1294 return new (Context)
ObjCProtocolExpr(Ty, PDecl, AtLoc, ProtoIdLoc, RParenLoc);
1340 bool isClassMessage,
1341 bool isSuperMessage) {
1342 assert(Method &&
"Must have a method");
1377 if (isSuperMessage) {
1380 return transferNullability(
1399 return transferNullability(ReceiverType);
1405 bool isClassMessage,
1406 bool isSuperMessage) {
1414 if (isClassMessage) {
1426 cast<ImplicitParamDecl>(
1428 ->getDeclContext());
1435 NewResultType, NewResultType);
1436 return NewResultType;
1448 unsigned receiverNullabilityIdx = 0;
1450 receiverNullabilityIdx = 1 + static_cast<unsigned>(*nullability);
1452 unsigned resultNullabilityIdx = 0;
1454 resultNullabilityIdx = 1 + static_cast<unsigned>(*nullability);
1458 static const uint8_t None = 0;
1459 static const uint8_t
NonNull = 1;
1462 static const uint8_t nullabilityMap[4][4] = {
1464 { None, None, Nullable, None },
1465 { None, NonNull, Nullable, Unspecified },
1466 { Nullable, Nullable, Nullable, Nullable },
1467 { None, Unspecified, Nullable, Unspecified }
1470 unsigned newResultNullabilityIdx
1471 = nullabilityMap[receiverNullabilityIdx][resultNullabilityIdx];
1472 if (newResultNullabilityIdx == resultNullabilityIdx)
1478 if (
auto attributed = dyn_cast<AttributedType>(resultType.
getTypePtr())) {
1479 resultType = attributed->getModifiedType();
1486 if (newResultNullabilityIdx > 0) {
1491 resultType, resultType);
1510 dyn_cast<ObjCCategoryImplDecl>(impl)) {
1511 iface = catImpl->getCategoryDecl();
1513 iface = impl->getClassInterface();
1523 for (
unsigned i = 0, e = overrides.size(); i != e; ++i) {
1547 loc = overridden->getLocation();
1548 Diag(loc, diag::note_related_result_type_explicit)
1594 if (!SelectorLocs.empty() && SelectorLocs.front().isValid())
1595 SelLoc = SelectorLocs.front();
1601 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
1602 if (Args[i]->isTypeDependent())
1606 if (getLangOpts().DebuggerSupport) {
1608 result = checkUnknownAnyArg(SelLoc, Args[i], paramTy);
1610 result = DefaultArgumentPromotion(Args[i]);
1614 Args[i] = result.
get();
1618 if (getLangOpts().ObjCAutoRefCount)
1619 DiagID = diag::err_arc_method_not_found;
1621 DiagID = isClassMessage ? diag::warn_class_method_not_found
1622 : diag::warn_inst_method_not_found;
1623 if (!getLangOpts().DebuggerSupport) {
1624 const ObjCMethodDecl *OMD = SelectorsForTypoCorrection(Sel, ReceiverType);
1626 if (getLangOpts().ObjCAutoRefCount)
1627 DiagID = diag::err_method_not_found_with_typo;
1629 DiagID = isClassMessage ? diag::warn_class_method_not_found_with_typo
1630 : diag::warn_instance_method_not_found_with_typo;
1632 SourceRange SelectorRange(SelectorLocs.front(), SelectorLocs.back());
1634 Diag(SelLoc, DiagID)
1635 << Sel<< isClassMessage << MatchedSel
1638 Diag(SelLoc, DiagID) << Sel<< isClassMessage << MatchedSel;
1641 Diag(SelLoc, DiagID)
1642 << Sel << isClassMessage <<
SourceRange(SelectorLocs.front(),
1643 SelectorLocs.back());
1647 Diag(ThisClass->getLocation(), diag::note_receiver_class_declared);
1649 if (ThisClass->lookupClassMethod(Sel))
1650 Diag(RecRange.
getBegin(), diag::note_receiver_expr_here)
1652 ThisClass->getNameAsString());
1659 if (getLangOpts().DebuggerSupport) {
1668 ReturnType = getMessageSendResultType(Receiver, ReceiverType, Method,
1669 isClassMessage, isSuperMessage);
1678 if (Args.size() < NumNamedArgs) {
1679 Diag(SelLoc, diag::err_typecheck_call_too_few_args)
1680 << 2 << NumNamedArgs << static_cast<unsigned>(Args.size());
1688 bool IsError =
false;
1689 for (
unsigned i = 0; i < NumNamedArgs; i++) {
1691 if (Args[i]->isTypeDependent())
1694 Expr *argExpr = Args[i];
1697 assert(argExpr &&
"CheckMessageArgumentTypes(): missing expression");
1699 if (param->
hasAttr<NoEscapeAttr>())
1700 if (
auto *BE = dyn_cast<BlockExpr>(
1702 BE->getBlockDecl()->setDoesNotEscape();
1707 !param->
hasAttr<CFConsumedAttr>())
1708 argExpr = stripARCUnbridgedCast(argExpr);
1714 ExprResult argE = checkUnknownAnyArg(SelLoc, argExpr, paramType);
1718 Args[i] = argE.
get();
1736 diag::err_call_incomplete_argument, argExpr))
1751 Args[i]->getType()->isBlockPointerType() &&
1754 maybeExtendBlockObject(arg);
1755 Args[i] = arg.
get();
1762 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
1763 if (Args[i]->isTypeDependent())
1766 ExprResult Arg = DefaultVariadicArgumentPromotion(Args[i], VariadicMethod,
1769 Args[i] = Arg.
get();
1773 if (Args.size() != NumNamedArgs) {
1774 Diag(Args[NumNamedArgs]->getBeginLoc(),
1775 diag::err_typecheck_call_too_many_args)
1776 << 2 << NumNamedArgs << static_cast<unsigned>(Args.size())
1779 Args.back()->getEndLoc());
1783 DiagnoseSentinelCalls(Method, SelLoc, Args);
1786 IsError |= CheckObjCMethodCall(
1787 Method, SelLoc, makeArrayRef(Args.data(), Args.size()));
1795 dyn_cast_or_null<ObjCMethodDecl>(CurContext->getNonClosureAncestor());
1796 return isSelfExpr(RExpr, Method);
1800 if (!method)
return false;
1803 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(receiver))
1815 if (
ObjCMethodDecl *method = iface->lookupMethod(sel, isInstance))
1820 if (
ObjCMethodDecl *method = iface->lookupPrivateMethod(sel, isInstance))
1825 for (
const auto *I : objType->
quals())
1839 for (
const auto *PROTO : OPT->
quals()) {
1840 if ((MD = PROTO->lookupMethod(Sel, Instance))) {
1860 Diag(MemberLoc, diag::err_invalid_property_name)
1870 diag::err_property_not_found_forward_class,
1871 MemberName, BaseRange))
1877 if (DiagnoseUseOfDecl(PD, MemberLoc))
1880 return new (Context)
1884 return new (Context)
1889 for (
const auto *I : OPT->
quals())
1893 if (DiagnoseUseOfDecl(PD, MemberLoc))
1899 SuperLoc, SuperType);
1901 return new (Context)
1911 Selector Sel = PP.getSelectorTable().getNullarySelector(Member);
1916 Getter = LookupMethodInQualifiedType(Sel, OPT,
true);
1924 if (DiagnoseUseOfDecl(Getter, MemberLoc))
1931 PP.getSelectorTable(), Member);
1936 Setter = LookupMethodInQualifiedType(SetterSel, OPT,
true);
1944 if (Setter && DiagnoseUseOfDecl(Setter, MemberLoc))
1950 if (Setter && Setter->isImplicit() && Setter->isPropertyAccessor() &&
1958 diag::warn_property_access_suggest)
1959 << MemberName <<
QualType(OPT, 0) << PDecl->getName()
1964 if (Getter || Setter) {
1966 return new (Context)
1970 return new (Context)
1980 nullptr,
nullptr, CCC, CTK_ErrorRecovery, IFace,
false, OPT)) {
1986 Corrected.isKeyword() ? nullptr : Corrected.getFoundDecl();
1987 if (ChosenDecl && isa<ObjCPropertyDecl>(ChosenDecl))
1988 if (cast<ObjCPropertyDecl>(ChosenDecl)->isClassProperty()) {
1991 Diag(MemberLoc, diag::err_class_property_found) << MemberName
1998 diagnoseTypo(Corrected, PDiag(diag::err_property_not_found_suggest)
1999 << MemberName <<
QualType(OPT, 0));
2000 return HandleExprPropertyRefExpr(OPT, BaseExpr, OpLoc,
2001 TypoResult, MemberLoc,
2002 SuperLoc, SuperType, Super);
2007 IFace->lookupInstanceVariable(Member, ClassDeclared)) {
2011 if (RequireCompleteType(MemberLoc, OBJPT->getPointeeType(),
2012 diag::err_property_not_as_forward_class,
2013 MemberName, BaseExpr))
2017 diag::err_ivar_access_using_property_syntax_suggest)
2018 << MemberName <<
QualType(OPT, 0) << Ivar->getDeclName()
2023 Diag(MemberLoc, diag::err_property_not_found)
2026 Diag(Setter->getLocation(), diag::note_getter_unavailable)
2045 if (receiverNamePtr->
isStr(
"super")) {
2046 if (
ObjCMethodDecl *CurMethod = tryCaptureObjCSelf(receiverNameLoc)) {
2047 if (
auto classDecl = CurMethod->getClassInterface()) {
2048 SuperType =
QualType(classDecl->getSuperClassType(), 0);
2049 if (CurMethod->isInstanceMethod()) {
2050 if (SuperType.
isNull()) {
2052 Diag(receiverNameLoc, diag::err_root_class_cannot_use_super)
2053 << CurMethod->getClassInterface()->getIdentifier();
2063 receiverNameLoc, T,
true);
2074 Diag(receiverNameLoc, diag::err_expected_either) << tok::identifier
2084 GetterSel = PD->getGetterName();
2085 SetterSel = PD->getSetterName();
2087 GetterSel = PP.getSelectorTable().getNullarySelector(&propertyName);
2089 PP.getIdentifierTable(), PP.getSelectorTable(), &propertyName);
2102 if (DiagnoseUseOfDecl(Getter, propertyNameLoc))
2117 if (Setter && DiagnoseUseOfDecl(Setter, propertyNameLoc))
2120 if (Getter || Setter) {
2122 return new (Context)
2129 propertyNameLoc, receiverNameLoc, IFace);
2131 return ExprError(
Diag(propertyNameLoc, diag::err_property_not_found)
2145 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
2150 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
2151 return std::make_unique<ObjCInterfaceOrSuperCCC>(*this);
2161 bool HasTrailingDot,
2163 ReceiverType =
nullptr;
2169 return HasTrailingDot? ObjCInstanceMessage : ObjCSuperMessage;
2171 LookupResult Result(*
this, Name, NameLoc, LookupOrdinaryName);
2172 LookupName(Result, S);
2181 if (!Method->getClassInterface()) {
2183 return ObjCInstanceMessage;
2187 if (Method->getClassInterface()->lookupInstanceVariable(Name,
2189 return ObjCInstanceMessage;
2200 return ObjCInstanceMessage;
2206 return ObjCInstanceMessage;
2215 DiagnoseUseOfDecl(
Type, NameLoc);
2218 return ObjCInstanceMessage;
2223 ReceiverType = CreateParsedType(T, TSInfo);
2224 return ObjCClassMessage;
2228 ObjCInterfaceOrSuperCCC CCC(getCurMethodDecl());
2231 CTK_ErrorRecovery,
nullptr,
false,
nullptr,
false)) {
2232 if (Corrected.isKeyword()) {
2235 diagnoseTypo(Corrected,
2236 PDiag(diag::err_unknown_receiver_suggest) << Name);
2237 return ObjCSuperMessage;
2242 diagnoseTypo(Corrected,
2243 PDiag(diag::err_unknown_receiver_suggest) << Name);
2246 ReceiverType = CreateParsedType(T, TSInfo);
2247 return ObjCClassMessage;
2252 return ObjCInstanceMessage;
2265 Diag(SuperLoc, diag::err_invalid_receiver_to_message_super);
2271 Diag(SuperLoc, diag::err_no_super_class_message)
2277 if (SuperTy.isNull()) {
2279 Diag(SuperLoc, diag::err_root_class_cannot_use_super)
2287 getCurFunction()->ObjCShouldCallSuper =
false;
2293 return BuildInstanceMessage(
nullptr, SuperTy, SuperLoc,
2295 LBracLoc, SelectorLocs, RBracLoc, Args);
2300 return BuildClassMessage(
nullptr,
2302 SuperLoc, Sel,
nullptr,
2303 LBracLoc, SelectorLocs, RBracLoc, Args);
2307 bool isSuperReceiver,
2313 if (!ReceiverType.
isNull())
2316 return BuildClassMessage(receiverTypeInfo, ReceiverType,
2318 Sel, Method, Loc, Loc, Loc, Args,
2332 if (refactor(Msg,*S.
NSAPIObj, ECommit)) {
2341 switch (Edit.
Kind) {
2369 bool IsClassObjectCall) {
2379 if (!IsClassObjectCall) {
2381 if (!OPT || !OPT->getInterfaceDecl())
2384 OPT->getInterfaceDecl()->lookupInstanceMethod(SE->getSelector());
2387 OPT->getInterfaceDecl()->lookupPrivateMethod(SE->getSelector());
2392 ImpliedMethod = IT->getDecl()->lookupClassMethod(SE->getSelector());
2395 IT->getDecl()->lookupPrivateClassMethod(SE->getSelector());
2401 S.
Diag(Loc, diag::warn_objc_unsafe_perform_selector)
2407 diag::note_objc_unsafe_perform_selector_method_declared_here)
2418 Expr **Args,
unsigned NumArgs) {
2420 bool Format =
false;
2434 if (!Format || NumArgs <= Idx)
2437 Expr *FormatExpr = Args[Idx];
2442 S.
Diag(FormatExpr->
getExprLoc(), diag::warn_objc_cdirective_format_string)
2492 Diag(Loc, diag::err_missing_open_square_message_send)
2497 if (!SelectorLocs.empty() && SelectorLocs.front().isValid())
2498 SelectorSlotLocs = SelectorLocs;
2500 SelectorSlotLocs = Loc;
2506 unsigned NumArgs = ArgsIn.size();
2507 Expr **Args = ArgsIn.data();
2508 assert(SuperLoc.
isInvalid() &&
"Message to super with dependent type");
2510 Context, ReceiverType,
VK_RValue, LBracLoc, ReceiverTypeInfo, Sel,
2511 SelectorLocs,
nullptr, makeArrayRef(Args, NumArgs), RBracLoc,
2518 if (!ClassType || !(Class = ClassType->
getInterface())) {
2519 Diag(Loc, diag::err_invalid_receiver_class_message)
2523 assert(Class &&
"We don't know which class we're messaging?");
2526 (void)DiagnoseUseOfDecl(Class, SelectorSlotLocs);
2533 (getLangOpts().ObjCAutoRefCount
2534 ? diag::err_arc_receiver_forward_class
2535 : diag::warn_receiver_forward_class),
2538 Method = LookupFactoryMethodInGlobalPool(Sel,
2540 if (Method && !getLangOpts().ObjCAutoRefCount)
2551 if (Method && DiagnoseUseOfDecl(Method, SelectorSlotLocs,
2552 nullptr,
false,
false, Class))
2560 unsigned NumArgs = ArgsIn.size();
2561 Expr **Args = ArgsIn.data();
2562 if (CheckMessageArgumentTypes(
nullptr, ReceiverType,
2564 Method,
true, SuperLoc.
isValid(), LBracLoc,
2570 diag::err_illegal_message_expr_incomplete_type))
2579 Diag(Loc, diag::warn_direct_initialize_call);
2587 Diag(Loc, diag::warn_direct_super_initialize_call);
2590 Diag(CurMeth->getLocation(), diag::note_method_declared_at)
2591 << CurMeth->getDeclName();
2603 ReceiverType, Sel, SelectorLocs,
2604 Method, makeArrayRef(Args, NumArgs),
2605 RBracLoc, isImplicit);
2608 ReceiverTypeInfo, Sel, SelectorLocs,
2609 Method, makeArrayRef(Args, NumArgs),
2610 RBracLoc, isImplicit);
2616 ReceiverType,
true);
2617 return MaybeBindToTemporary(Result);
2631 QualType ReceiverType = GetTypeFromParser(Receiver, &ReceiverTypeInfo);
2632 if (ReceiverType.
isNull())
2635 if (!ReceiverTypeInfo)
2638 return BuildClassMessage(ReceiverTypeInfo, ReceiverType,
2640 nullptr, LBracLoc, SelectorLocs, RBracLoc,
2650 return BuildInstanceMessage(Receiver, ReceiverType,
2652 Sel, Method, Loc, Loc, Loc, Args,
2663 if (
const auto *RootClass = dyn_cast_or_null<ObjCInterfaceDecl>(
2667 if (
P->getCanonicalDecl() == Protocol->getCanonicalDecl())
2712 assert((Receiver || SuperLoc.
isValid()) &&
"If the Receiver is null, the " 2713 "SuperLoc must be valid so we can " 2721 if (!SelectorLocs.empty() && SelectorLocs.front().isValid())
2722 SelectorSlotLocs = SelectorLocs;
2724 SelectorSlotLocs = Loc;
2728 Diag(Loc, diag::err_missing_open_square_message_send)
2739 Result = forceUnknownAnyToType(Receiver, Context.
getObjCIdType());
2741 Result = CheckPlaceholderExpr(Receiver);
2743 Receiver = Result.
get();
2749 unsigned NumArgs = ArgsIn.size();
2750 Expr **Args = ArgsIn.data();
2751 assert(SuperLoc.
isInvalid() &&
"Message to super with dependent type");
2754 SelectorLocs,
nullptr, makeArrayRef(Args, NumArgs),
2755 RBracLoc, isImplicit);
2760 ExprResult Result = DefaultFunctionArrayLvalueConversion(Receiver);
2763 Receiver = Result.
get();
2764 ReceiverType = Receiver->
getType();
2771 }
else if (!getLangOpts().ObjCAutoRefCount &&
2777 Diag(Loc, diag::warn_bad_receiver_type)
2781 Receiver = ImpCastExprToType(Receiver, Context.
getObjCIdType(),
2782 CK_CPointerToObjCPointerCast).
get();
2787 CastKind Kind = IsNull ? CK_NullToPointer : CK_IntegralToPointer;
2788 Receiver = ImpCastExprToType(Receiver, Context.
getObjCIdType(),
2791 ReceiverType = Receiver->
getType();
2794 if (RequireCompleteType(Loc, Receiver->
getType(),
2795 diag::err_incomplete_receiver_type))
2798 ExprResult result = PerformContextuallyConvertToObjCPointer(Receiver);
2800 Receiver = result.
get();
2801 ReceiverType = Receiver->
getType();
2820 CollectMultipleMethodsInGlobalPool(Sel, Methods,
true,
2822 if (!Methods.empty()) {
2825 Method = Methods[0];
2829 Method = BestMethod;
2831 if (!AreMultipleMethodsInGlobalPool(Sel, Method,
2833 receiverIsIdLike, Methods))
2834 DiagnoseUseOfDecl(Method, SelectorSlotLocs);
2846 Method = LookupMethodInQualifiedType(Sel, QClassTy,
false);
2848 Method = LookupMethodInQualifiedType(Sel, QClassTy,
true);
2851 Diag(SelLoc, diag::warn_instance_method_on_class_found)
2864 Method = ClassDecl->lookupClassMethod(Sel);
2867 Method = ClassDecl->lookupPrivateClassMethod(Sel);
2869 if (Method && DiagnoseUseOfDecl(Method, SelectorSlotLocs))
2875 if (!Receiver || !isSelfExpr(Receiver)) {
2879 CollectMultipleMethodsInGlobalPool(Sel, Methods,
2882 if (!Methods.empty()) {
2885 Method = Methods[0];
2891 if (
ID->getSuperClass())
2892 Diag(SelLoc, diag::warn_root_inst_method_not_found)
2900 Method = BestMethod;
2914 Method = LookupMethodInQualifiedType(Sel, QIdTy,
true);
2916 Method = LookupMethodInQualifiedType(Sel, QIdTy,
false);
2917 if (Method && DiagnoseUseOfDecl(Method, SelectorSlotLocs))
2922 ClassDecl = OCIType->getInterfaceDecl();
2929 if (RequireCompleteType(Loc, OCIType->getPointeeType(),
2930 getLangOpts().ObjCAutoRefCount
2931 ? diag::err_arc_receiver_forward_instance
2932 : diag::warn_receiver_forward_instance,
2935 if (getLangOpts().ObjCAutoRefCount)
2938 forwardClass = OCIType->getInterfaceDecl();
2940 diag::note_receiver_is_id);
2948 Method = LookupMethodInQualifiedType(Sel, OCIType,
true);
2954 if (!Method && getLangOpts().ObjCAutoRefCount) {
2955 Diag(SelLoc, diag::err_arc_may_not_respond)
2956 << OCIType->getPointeeType() << Sel << RecRange
2957 <<
SourceRange(SelectorLocs.front(), SelectorLocs.back());
2961 if (!Method && (!Receiver || !isSelfExpr(Receiver))) {
2965 if (OCIType->qual_empty()) {
2967 CollectMultipleMethodsInGlobalPool(Sel, Methods,
2970 if (!Methods.empty()) {
2973 Method = Methods[0];
2978 Method = BestMethod;
2980 AreMultipleMethodsInGlobalPool(Sel, Method,
2985 if (Method && !forwardClass)
2986 Diag(SelLoc, diag::warn_maynot_respond)
2987 << OCIType->getInterfaceDecl()->getIdentifier()
2992 if (Method && DiagnoseUseOfDecl(Method, SelectorSlotLocs, forwardClass))
2996 Diag(Loc, diag::err_bad_receiver_type)
3005 ? getEnclosingFunction() :
nullptr;
3010 diag::err_messaging_unqualified_id_with_direct_method);
3017 diag::err_messaging_class_with_direct_method);
3023 Diag(SuperLoc, diag::err_messaging_super_with_direct_method);
3027 }
else if (ReceiverType->
isObjCIdType() && !isImplicit) {
3028 Diag(Receiver->
getExprLoc(), diag::warn_messaging_unqualified_id);
3031 if (DIFunctionScopeInfo &&
3033 (SuperLoc.
isValid() || isSelfExpr(Receiver))) {
3034 bool isDesignatedInitChain =
false;
3041 if (!
ID->declaresOrInheritsDesignatedInitializers() ||
3042 ID->isDesignatedInitializer(Sel)) {
3043 isDesignatedInitChain =
true;
3049 if (!isDesignatedInitChain) {
3053 assert(isDesignated && InitMethod);
3056 diag::warn_objc_designated_init_non_designated_init_call :
3057 diag::warn_objc_designated_init_non_super_designated_init_call);
3059 diag::note_objc_designated_init_marked_here);
3063 if (DIFunctionScopeInfo &&
3065 (SuperLoc.
isValid() || isSelfExpr(Receiver))) {
3067 Diag(SelLoc, diag::warn_objc_secondary_init_super_init_call);
3074 unsigned NumArgs = ArgsIn.size();
3075 Expr **Args = ArgsIn.data();
3080 if (CheckMessageArgumentTypes(Receiver, ReceiverType,
3082 Method, ClassMessage, SuperLoc.
isValid(),
3083 LBracLoc, RBracLoc, RecRange, ReturnType, VK))
3088 diag::err_illegal_message_expr_incomplete_type))
3093 if (getLangOpts().ObjCAutoRefCount) {
3099 checkInitMethod(Method, ReceiverType);
3117 Diag(SelLoc, diag::err_arc_illegal_explicit_message)
3122 if (Method && NumArgs >= 1) {
3123 if (
const auto *SelExp =
3124 dyn_cast<ObjCSelectorExpr>(Args[0]->IgnoreParens())) {
3125 Selector ArgSel = SelExp->getSelector();
3127 LookupInstanceMethodInGlobalPool(ArgSel,
3128 SelExp->getSourceRange());
3131 LookupFactoryMethodInGlobalPool(ArgSel,
3132 SelExp->getSourceRange());
3135 switch (SelFamily) {
3142 if (!SelMethod->
hasAttr<NSReturnsNotRetainedAttr>()) {
3145 diag::err_arc_perform_selector_retains);
3152 if (SelMethod->
hasAttr<NSReturnsRetainedAttr>()) {
3155 diag::err_arc_perform_selector_retains);
3164 Diag(SelLoc, diag::warn_arc_perform_selector_leaks);
3165 Diag(Args[0]->getExprLoc(), diag::note_used_here);
3179 ReceiverType, Sel, SelectorLocs, Method,
3180 makeArrayRef(Args, NumArgs), RBracLoc,
3184 Receiver, Sel, SelectorLocs, Method,
3185 makeArrayRef(Args, NumArgs), RBracLoc,
3191 bool IsClassObjectCall = ClassMessage;
3196 if (Receiver && isSelfExpr(Receiver)) {
3198 if (OPT->getObjectType()->isObjCClass()) {
3199 if (
const auto *CurMeth = getCurMethodDecl()) {
3200 IsClassObjectCall =
true;
3208 ReceiverType, IsClassObjectCall);
3211 if (getLangOpts().ObjCAutoRefCount) {
3214 (SuperLoc.
isValid() || isSelfExpr(Receiver))) {
3228 checkRetainCycles(Result);
3231 if (getLangOpts().ObjCWeak) {
3232 if (!isImplicit && Method) {
3238 if (IsWeak && !isUnevaluatedContext() &&
3239 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, LBracLoc))
3240 getCurFunction()->recordUseOfWeak(Result, Prop);
3245 CheckObjCCircularContainer(Result);
3247 return MaybeBindToTemporary(Result);
3275 if (isa<ParenListExpr>(Receiver)) {
3276 ExprResult Result = MaybeConvertParenListExprToParenExpr(S, Receiver);
3278 Receiver = Result.
get();
3281 if (RespondsToSelectorSel.isNull()) {
3285 if (Sel == RespondsToSelectorSel)
3288 return BuildInstanceMessage(Receiver, Receiver->
getType(),
3290 nullptr, LBracLoc, SelectorLocs,
3324 bool isIndirect =
false;
3343 type =
QualType(array->getElementType()->getBaseElementTypeUnsafe(), 0);
3378 if (left == right)
return left;
3379 if (left == ACC_bottom)
return right;
3380 if (right == ACC_bottom)
return left;
3386 class ARCCastChecker :
public StmtVisitor<ARCCastChecker, ACCResult> {
3402 : Context(Context), SourceClass(source), TargetClass(target),
3403 Diagnose(diagnose) {}
3433 case CK_NullToPointer:
3437 case CK_LValueToRValue:
3439 case CK_CPointerToObjCPointerCast:
3440 case CK_BlockPointerToObjCPointerCast:
3441 case CK_AnyPointerToBlockPointerCast:
3456 return Visit(e->
getRHS());
3462 if (left == ACC_invalid)
return ACC_invalid;
3492 return ACC_plusZero;
3502 if (
ACCResult result = checkCallToFunction(fn))
3505 return super::VisitCallExpr(e);
3517 if (fn->
hasAttr<CFReturnsNotRetainedAttr>())
3518 return ACC_plusZero;
3523 if (fn->
hasAttr<CFReturnsRetainedAttr>())
3524 return Diagnose ? ACC_plusOne
3529 if (builtinID == Builtin::BI__builtin___CFStringMakeConstantString)
3533 if (!fn->
hasAttr<CFAuditedTransferAttr>())
3538 return Diagnose ? ACC_plusOne
3541 return ACC_plusZero;
3554 return checkCallToMethod(method);
3558 if (!method)
return ACC_invalid;
3567 if (method->
hasAttr<CFReturnsNotRetainedAttr>())
3568 return ACC_plusZero;
3572 if (method->
hasAttr<CFReturnsRetainedAttr>())
3584 return ACC_plusZero;
3595 return LookupName(R, TUScope,
false);
3605 const char *bridgeKeyword,
3606 const char *CFBridgeName) {
3622 NCE->getAngleBrackets().getEnd());
3630 BridgeCall += CFBridgeName;
3637 castedE = CCE->getSubExpr();
3648 BridgeCall += CFBridgeName;
3650 if (isa<ParenExpr>(castedE)) {
3668 std::string castCode =
"(";
3669 castCode += bridgeKeyword;
3673 NCE->getAngleBrackets().getEnd());
3677 std::string castCode =
"(";
3678 castCode += bridgeKeyword;
3683 if (isa<ParenExpr>(castedE)) {
3697 template <
typename T>
3705 return RD->getAttr<T>();
3713 TDNDecl = TD->getDecl();
3714 if (ObjCBridgeRelatedAttr *ObjCBAttr =
3715 getObjCBridgeAttr<ObjCBridgeRelatedAttr>(TD))
3732 UnavailableAttr::IR_ARCForbiddenConversion))
3745 unsigned srcKind = 0;
3769 S.
Diag(loc, diag::err_arc_cast_requires_bridge)
3779 ARCCastChecker(S.
Context, exprACTC, castACTC,
true).Visit(castExpr);
3780 assert(CreateRule != ACC_bottom &&
"This cast should already be accepted.");
3781 if (CreateRule != ACC_plusOne)
3785 : S.
Diag(noteLoc, diag::note_arc_cstyle_bridge);
3788 castType, castExpr, realCast,
"__bridge ",
3791 if (CreateRule != ACC_plusZero)
3795 S.
Diag(noteLoc, diag::note_arc_cstyle_bridge_transfer) << castExprType :
3797 diag::note_arc_bridge_transfer)
3798 << castExprType << br;
3801 castType, castExpr, realCast,
"__bridge_transfer ",
3802 br ?
"CFBridgingRelease" :
nullptr);
3811 S.
Diag(loc, diag::err_arc_cast_requires_bridge)
3820 ARCCastChecker(S.
Context, exprACTC, castACTC,
true).Visit(castExpr);
3821 assert(CreateRule != ACC_bottom &&
"This cast should already be accepted.");
3822 if (CreateRule != ACC_plusOne)
3826 : S.
Diag(noteLoc, diag::note_arc_cstyle_bridge);
3828 castType, castExpr, realCast,
"__bridge ",
3831 if (CreateRule != ACC_plusZero)
3835 S.
Diag(noteLoc, diag::note_arc_cstyle_bridge_retained) << castType :
3837 diag::note_arc_bridge_retained)
3841 castType, castExpr, realCast,
"__bridge_retained ",
3842 br ?
"CFBridgingRetain" :
nullptr);
3848 S.
Diag(loc, diag::err_arc_mismatched_cast)
3850 << srcKind << castExprType << castType
3854 template <
typename TB>
3856 bool &HadTheAttribute,
bool warn) {
3858 HadTheAttribute =
false;
3861 if (TB *ObjCBAttr = getObjCBridgeAttr<TB>(TD)) {
3863 HadTheAttribute =
true;
3864 if (Parm->isStr(
"id"))
3873 if (Target && isa<ObjCInterfaceDecl>(Target)) {
3878 = InterfacePointerType->getObjectType()->getInterface();
3879 if ((CastClass == ExprClass) ||
3888 castType, ExprClass)))
3896 << T << Target->
getName() << castType;
3905 diag::err_objc_cf_bridged_not_interface)
3906 << castExpr->
getType() << Parm;
3920 template <
typename TB>
3922 bool &HadTheAttribute,
bool warn) {
3924 HadTheAttribute =
false;
3927 if (TB *ObjCBAttr = getObjCBridgeAttr<TB>(TD)) {
3929 HadTheAttribute =
true;
3930 if (Parm->isStr(
"id"))
3939 if (Target && isa<ObjCInterfaceDecl>(Target)) {
3944 = InterfacePointerType->getObjectType()->getInterface();
3945 if ((CastClass == ExprClass) ||
3950 diag::warn_objc_invalid_bridge_to_cf)
3957 castExpr->
getType(), CastClass)))
3965 diag::warn_objc_invalid_bridge_to_cf)
3966 << castExpr->
getType() << castType;
3975 diag::err_objc_ns_bridged_invalid_cfobject)
3976 << castExpr->
getType() << castType;
3990 if (!getLangOpts().ObjC)
3996 bool HasObjCBridgeAttr;
3997 bool ObjCBridgeAttrWillNotWarn =
3998 CheckObjCBridgeNSCast<ObjCBridgeAttr>(*
this, castType,
castExpr, HasObjCBridgeAttr,
4000 if (ObjCBridgeAttrWillNotWarn && HasObjCBridgeAttr)
4002 bool HasObjCBridgeMutableAttr;
4003 bool ObjCBridgeMutableAttrWillNotWarn =
4004 CheckObjCBridgeNSCast<ObjCBridgeMutableAttr>(*
this, castType,
castExpr,
4005 HasObjCBridgeMutableAttr,
false);
4006 if (ObjCBridgeMutableAttrWillNotWarn && HasObjCBridgeMutableAttr)
4009 if (HasObjCBridgeAttr)
4010 CheckObjCBridgeNSCast<ObjCBridgeAttr>(*
this, castType,
castExpr, HasObjCBridgeAttr,
4012 else if (HasObjCBridgeMutableAttr)
4013 CheckObjCBridgeNSCast<ObjCBridgeMutableAttr>(*
this, castType,
castExpr,
4014 HasObjCBridgeMutableAttr,
true);
4017 bool HasObjCBridgeAttr;
4018 bool ObjCBridgeAttrWillNotWarn =
4019 CheckObjCBridgeCFCast<ObjCBridgeAttr>(*
this, castType,
castExpr, HasObjCBridgeAttr,
4021 if (ObjCBridgeAttrWillNotWarn && HasObjCBridgeAttr)
4023 bool HasObjCBridgeMutableAttr;
4024 bool ObjCBridgeMutableAttrWillNotWarn =
4025 CheckObjCBridgeCFCast<ObjCBridgeMutableAttr>(*
this, castType,
castExpr,
4026 HasObjCBridgeMutableAttr,
false);
4027 if (ObjCBridgeMutableAttrWillNotWarn && HasObjCBridgeMutableAttr)
4030 if (HasObjCBridgeAttr)
4031 CheckObjCBridgeCFCast<ObjCBridgeAttr>(*
this, castType,
castExpr, HasObjCBridgeAttr,
4033 else if (HasObjCBridgeMutableAttr)
4034 CheckObjCBridgeCFCast<ObjCBridgeMutableAttr>(*
this, castType,
castExpr,
4035 HasObjCBridgeMutableAttr,
true);
4042 if (PRE->isExplicitProperty()) {
4044 SrcType = PDecl->getType();
4046 else if (PRE->isImplicitProperty()) {
4048 SrcType = Getter->getReturnType();
4056 CheckObjCBridgeRelatedConversions(castExpr->
getBeginLoc(), castType, SrcType,
4062 if (!getLangOpts().ObjC)
4069 CheckTollFreeBridgeCast(castType, castExpr);
4071 : CK_CPointerToObjCPointerCast;
4083 bool CfToNs,
bool Diagnose) {
4084 QualType T = CfToNs ? SrcType : DestType;
4098 if (!LookupName(R, TUScope)) {
4100 Diag(Loc, diag::err_objc_bridged_related_invalid_class) << RCId
4101 << SrcType << DestType;
4107 if (Target && isa<ObjCInterfaceDecl>(Target))
4108 RelatedClass = cast<ObjCInterfaceDecl>(Target);
4111 Diag(Loc, diag::err_objc_bridged_related_invalid_class_name) << RCId
4112 << SrcType << DestType;
4121 if (CfToNs && CMId) {
4126 Diag(Loc, diag::err_objc_bridged_related_known_method)
4127 << SrcType << DestType << Sel <<
false;
4135 if (!CfToNs && IMId) {
4137 InstanceMethod = RelatedClass->
lookupMethod(Sel,
true);
4138 if (!InstanceMethod) {
4140 Diag(Loc, diag::err_objc_bridged_related_known_method)
4141 << SrcType << DestType << Sel <<
true;
4153 Expr *&SrcExpr,
bool Diagnose) {
4158 if (!CfToNs && !NsToCf)
4165 if (!checkObjCBridgeRelatedComponents(Loc, DestType, SrcType, RelatedClass,
4166 ClassMethod, InstanceMethod, TDNDecl,
4174 std::string ExpressionString =
"[";
4176 ExpressionString +=
" ";
4179 getLocForEndOfToken(SrcExpr->
getEndLoc());
4181 Diag(Loc, diag::err_objc_bridged_related_known_method)
4182 << SrcType << DestType << ClassMethod->
getSelector() <<
false 4191 Expr *args[] = { SrcExpr };
4192 ExprResult msg = BuildClassMessageImplicit(receiverType,
false,
4196 SrcExpr = msg.
get();
4203 if (InstanceMethod) {
4205 std::string ExpressionString;
4207 getLocForEndOfToken(SrcExpr->
getEndLoc());
4212 ExpressionString =
".";
4213 ExpressionString += PDecl->getNameAsString();
4214 Diag(Loc, diag::err_objc_bridged_related_known_method)
4215 << SrcType << DestType << InstanceMethod->
getSelector() <<
true 4218 if (ExpressionString.empty()) {
4220 ExpressionString =
" ";
4222 ExpressionString +=
"]";
4224 Diag(Loc, diag::err_objc_bridged_related_known_method)
4225 << SrcType << DestType << InstanceMethod->
getSelector() <<
true 4233 BuildInstanceMessageImplicit(SrcExpr, SrcType,
4236 InstanceMethod, None);
4237 SrcExpr = msg.get();
4248 bool Diagnose,
bool DiagnoseCFAudited,
4260 if (exprACTC == castACTC) {
4264 (CCK == CCK_CStyleCast || CCK == CCK_OtherCast) &&
4265 castType != castExprType) {
4271 if (
const ParenType *PT = dyn_cast<ParenType>(DT))
4272 QDT = PT->desugar();
4273 else if (
const TypeOfType *TP = dyn_cast<TypeOfType>(DT))
4274 QDT = TP->desugar();
4275 else if (
const AttributedType *AT = dyn_cast<AttributedType>(DT))
4276 QDT = AT->desugar();
4277 if (QDT != castType &&
4282 Diag(loc, diag::err_arc_nolifetime_behavior);
4292 if (!getLangOpts().ObjCAutoRefCount)
4311 switch (ARCCastChecker(Context, exprACTC, castACTC,
false).Visit(castExpr)) {
4326 Cleanup.setExprNeedsCleanups(
true);
4334 return ACR_unbridged;
4340 ConversionToObjCStringLiteralCheck(castType, castExpr, Diagnose))
4350 (Opc == BO_NE || Opc == BO_EQ))) {
4353 castExpr, exprACTC, CCK);
4372 castType =
cast->getTypeAsWritten();
4373 CCK = CCK_CStyleCast;
4375 castRange =
cast->getTypeInfoAsWritten()->getTypeLoc().getSourceRange();
4376 castType =
cast->getTypeAsWritten();
4377 CCK = CCK_OtherCast;
4379 llvm_unreachable(
"Unexpected ImplicitCastExpr");
4397 if (
ParenExpr *pe = dyn_cast<ParenExpr>(e)) {
4398 Expr *sub = stripARCUnbridgedCast(pe->getSubExpr());
4399 return new (Context)
ParenExpr(pe->getLParen(), pe->getRParen(), sub);
4400 }
else if (
UnaryOperator *uo = dyn_cast<UnaryOperator>(e)) {
4401 assert(uo->getOpcode() == UO_Extension);
4402 Expr *sub = stripARCUnbridgedCast(uo->getSubExpr());
4403 return new (Context)
4404 UnaryOperator(sub, UO_Extension, sub->getType(), sub->getValueKind(),
4405 sub->getObjectKind(), uo->getOperatorLoc(),
false);
4407 assert(!gse->isResultDependent());
4409 unsigned n = gse->getNumAssocs();
4412 subExprs.reserve(n);
4413 subTypes.reserve(n);
4415 subTypes.push_back(assoc.getTypeSourceInfo());
4416 Expr *sub = assoc.getAssociationExpr();
4417 if (assoc.isSelected())
4418 sub = stripARCUnbridgedCast(sub);
4419 subExprs.push_back(sub);
4423 Context, gse->getGenericLoc(), gse->getControllingExpr(), subTypes,
4424 subExprs, gse->getDefaultLoc(), gse->getRParenLoc(),
4425 gse->containsUnexpandedParameterPack(), gse->getResultIndex());
4427 assert(isa<ImplicitCastExpr>(e) &&
"bad form of unbridged cast!");
4428 return cast<ImplicitCastExpr>(e)->getSubExpr();
4438 if (isa<ObjCObjectPointerType>(canCastType) &&
4444 return !ObjI->isArcWeakrefUnavailable();
4451 Expr *curExpr = e, *prevExpr =
nullptr;
4456 if (
auto *pe = dyn_cast<ParenExpr>(curExpr)) {
4458 curExpr = pe->getSubExpr();
4462 if (
auto *ce = dyn_cast<CastExpr>(curExpr)) {
4463 if (
auto *ice = dyn_cast<ImplicitCastExpr>(ce))
4464 if (ice->getCastKind() == CK_ARCReclaimReturnedObject) {
4466 return ice->getSubExpr();
4467 if (
auto *pe = dyn_cast<ParenExpr>(prevExpr))
4468 pe->setSubExpr(ice->getSubExpr());
4470 cast<CastExpr>(prevExpr)->setSubExpr(ice->getSubExpr());
4475 curExpr = ce->getSubExpr();
4491 ExprResult SubResult = UsualUnaryConversions(SubExpr);
4493 SubExpr = SubResult.
get();
4500 bool MustConsume =
false;
4507 : CK_CPointerToObjCPointerCast);
4513 bool br = isKnownName(
"CFBridgingRelease");
4514 Diag(BridgeKeywordLoc, diag::err_arc_bridge_cast_wrong_kind)
4521 Diag(BridgeKeywordLoc, diag::note_arc_bridge)
4523 Diag(BridgeKeywordLoc, diag::note_arc_bridge_transfer)
4526 br ?
"CFBridgingRelease " 4527 :
"__bridge_transfer ");
4551 CK_ARCProduceObject,
4556 bool br = isKnownName(
"CFBridgingRetain");
4557 Diag(BridgeKeywordLoc, diag::err_arc_bridge_cast_wrong_kind)
4565 Diag(BridgeKeywordLoc, diag::note_arc_bridge)
4567 Diag(BridgeKeywordLoc, diag::note_arc_bridge_retained)
4570 br ?
"CFBridgingRetain " :
"__bridge_retained");
4577 Diag(LParenLoc, diag::err_arc_bridge_cast_incompatible)
4578 << FromType << T << Kind
4589 Cleanup.setExprNeedsCleanups(
true);
4605 QualType T = GetTypeFromParser(Type, &TSInfo);
4607 CheckTollFreeBridgeCast(T, SubExpr);
4610 return BuildObjCBridgedCast(LParenLoc, Kind, BridgeKeywordLoc, TSInfo,
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
ObjCMethodDecl * LookupMethodInQualifiedType(Selector Sel, const ObjCObjectPointerType *OPT, bool IsInstance)
LookupMethodInQualifiedType - Lookups up a method in protocol qualifier list of a qualified objective...
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Defines the clang::ASTContext interface.
ObjCMethodDecl * lookupPrivateClassMethod(const Selector &Sel)
bool hasDefinition() const
Determine whether this class has been defined.
QualType withConst() const
Retrieves a version of this type with const applied.
bool isClassMethod() const
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
Represents a function declaration or definition.
Name lookup found a set of overloaded functions that met the criteria.
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.
bool isSelfExpr(Expr *RExpr)
Private Helper predicate to check for 'self'.
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
static ObjCArrayLiteral * Create(const ASTContext &C, ArrayRef< Expr *> Elements, QualType T, ObjCMethodDecl *Method, SourceRange SR)
Smart pointer class that efficiently represents Objective-C method names.
QualType getObjCIdType() const
Represents the Objective-CC id type.
static void checkFoundationAPI(Sema &S, SourceLocation Loc, const ObjCMethodDecl *Method, ArrayRef< Expr *> Args, QualType ReceiverType, bool IsClassObjectCall)
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
A (possibly-)qualified type.
bool isBlockPointerType() const
QualType substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
Substitute type arguments for the Objective-C type parameters used in the subject type...
Simple class containing the result of Sema::CorrectTypo.
unsigned param_size() const
Selector getSelector() const
ObjCInterfaceDecl * getClassInterface()
ExprResult ActOnSuperMessage(Scope *S, SourceLocation SuperLoc, Selector Sel, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args)
A cast other than a C-style cast.
void* might be a normal C type, or it might a CF type.
void AddFixItHint(const FixItHint &Hint) const
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
ObjCBridgeCastKind
The kind of bridging performed by the Objective-C bridge cast.
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
CompoundStmt * getSubStmt()
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
ObjCMessageKind
Describes the kind of message expression indicated by a message send that starts with an identifier...
Stmt - This represents one statement.
NullabilityKind
Describes the nullability of a particular type.
static void diagnoseObjCARCConversion(Sema &S, SourceRange castRange, QualType castType, ARCConversionTypeClass castACTC, Expr *castExpr, Expr *realCast, ARCConversionTypeClass exprACTC, Sema::CheckedConversionKind CCK)
bool isObjCClassOrClassKindOfType() const
Whether the type is Objective-C 'Class' or a __kindof type of an Class type, e.g., __kindof Class <NSCopying>.
ARCConversionResult CheckObjCConversion(SourceRange castRange, QualType castType, Expr *&op, CheckedConversionKind CCK, bool Diagnose=true, bool DiagnoseCFAudited=false, BinaryOperatorKind Opc=BO_PtrMemD)
Checks for invalid conversions and casts between retainable pointers and other pointer kinds for ARC ...
Bridging via __bridge, which does nothing but reinterpret the bits.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
ObjCMethodDecl * LookupMethodInObjectType(Selector Sel, QualType Ty, bool IsInstance)
LookupMethodInType - Look up a method in an ObjCObjectType.
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
static bool CheckObjCBridgeNSCast(Sema &S, QualType castType, Expr *castExpr, bool &HadTheAttribute, bool warn)
bool isObjCARCBridgableType() const
Determine whether the given type T is a "bridgable" Objective-C type, which is either an Objective-C ...
bool isRecordType() const
static InitializedEntity InitializeParameter(ASTContext &Context, const ParmVarDecl *Parm)
Create the initialization entity for a parameter.
const ObjCObjectType * getAsObjCInterfaceType() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
SourceLocation getBeginLoc() const LLVM_READONLY
static bool HelperToDiagnoseMismatchedMethodsInGlobalPool(Sema &S, SourceLocation AtLoc, SourceLocation LParenLoc, SourceLocation RParenLoc, ObjCMethodDecl *Method, ObjCMethodList &MethList)
SmallVectorImpl< Edit >::const_iterator edit_iterator
bool isExtVectorType() const
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
static ObjCMethodDecl * Create(ASTContext &C, SourceLocation beginLoc, SourceLocation endLoc, Selector SelInfo, QualType T, TypeSourceInfo *ReturnTInfo, DeclContext *contextDecl, bool isInstance=true, bool isVariadic=false, bool isPropertyAccessor=false, bool isSynthesizedAccessorStub=false, bool isImplicitlyDeclared=false, bool isDefined=false, ImplementationControl impControl=None, bool HasRelatedResultType=false)
ParenExpr - This represents a parethesized expression, e.g.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
const char * getCharacterData(SourceLocation SL, bool *Invalid=nullptr) const
Return a pointer to the start of the specified location in the appropriate spelling MemoryBuffer...
The base class of the type hierarchy.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
static void RemoveSelectorFromWarningCache(Sema &S, Expr *Arg)
Represents an array type, per C99 6.7.5.2 - Array Declarators.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
ExprResult ActOnObjCBridgedCast(Scope *S, SourceLocation LParenLoc, ObjCBridgeCastKind Kind, SourceLocation BridgeKeywordLoc, ParsedType Type, SourceLocation RParenLoc, Expr *SubExpr)
static FixItHint CreateInsertionFromRange(SourceLocation InsertionLoc, CharSourceRange FromRange, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code from FromRange at a specific location...
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
QualType withConst() const
A container of type source information.
bool isCARCBridgableType() const
Determine whether the given type T is a "bridgeable" C type.
ObjCMethodDecl * getMethod() const
QualType getMessageSendResultType(const Expr *Receiver, QualType ReceiverType, ObjCMethodDecl *Method, bool isClassMessage, bool isSuperMessage)
Determine the result of a message send expression based on the type of the receiver, the method expected to receive the message, and the form of the message send.
void setDelegateInitCall(bool isDelegate)
QualType getElementType() const
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
Retains information about a function, method, or block that is currently being parsed.
An Objective-C array/dictionary subscripting which reads an object or writes at the subscripted array...
Represents a variable declaration or definition.
QualType getReturnType() const
DiagnosticsEngine & Diags
ObjCMethodDecl * tryCaptureObjCSelf(SourceLocation Loc)
Try to capture an implicit reference to 'self'.
const T * getAs() const
Member-template getAs<specific type>'.
bool isInObjcMethodScope() const
isInObjcMethodScope - Return true if this scope is, or is contained in, an Objective-C method body...
ObjCMethodDecl - Represents an instance or class method declaration.
DeclClass * getCorrectionDeclAs() const
bool isInvalidDecl() const
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
static const ObjCMethodDecl * findExplicitInstancetypeDeclarer(const ObjCMethodDecl *MD, QualType instancetype)
Look for an ObjC method whose result type exactly matches the given type.
llvm::MapVector< Selector, SourceLocation > ReferencedSelectors
Method selectors used in a @selector expression.
static StringRef bytes(const std::vector< T, Allocator > &v)
Represents a parameter to a function.
ObjCPropertyDecl * getExplicitProperty() const
bool canHaveNullability(bool ResultIfUnknown=true) const
Determine whether the given type can have a nullability specifier applied to it, i.e., if it is any kind of pointer type.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Represents a struct/union/class.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Selector getUnarySelector(IdentifierInfo *ID)
One of these records is kept for each identifier that is lexed.
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
bool isObjCIdOrObjectKindOfType(const ASTContext &ctx, const ObjCObjectType *&bound) const
Whether the type is Objective-C 'id' or a __kindof type of an object type, e.g., __kindof NSView * or...
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
Expr * getFalseExpr() const
An element in an Objective-C dictionary literal.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Represents a class type in Objective C.
edit_iterator edit_end() const
ObjCMethodDecl * lookupInstanceMethod(Selector Sel) const
Lookup an instance method for a given selector.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
void setObjCConstantStringInterface(ObjCInterfaceDecl *Decl)
ObjCMethodFamily
A family of Objective-C methods.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
bool isExplicitProperty() const
SourceLocation getBeginLoc() const LLVM_READONLY
bool isObjCIdType() const
void diagnoseARCUnbridgedCast(Expr *e)
Given that we saw an expression with the ARCUnbridgedCastTy placeholder type, complain bitterly...
static ObjCMessageExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, SourceLocation LBracLoc, SourceLocation SuperLoc, bool IsInstanceSuper, QualType SuperType, Selector Sel, ArrayRef< SourceLocation > SelLocs, ObjCMethodDecl *Method, ArrayRef< Expr *> Args, SourceLocation RBracLoc, bool isImplicit)
Create a message send to super.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
const ObjCObjectPointerType * getAsObjCQualifiedIdType() const
bool CheckObjCBridgeRelatedConversions(SourceLocation Loc, QualType DestType, QualType SrcType, Expr *&SrcExpr, bool Diagnose=true)
ExprResult BuildClassMessageImplicit(QualType ReceiverType, bool isSuperReceiver, SourceLocation Loc, Selector Sel, ObjCMethodDecl *Method, MultiExprArg Args)
ExprResult ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals.
LookupResultKind getResultKind() const
static ObjCBridgeRelatedAttr * ObjCBridgeRelatedAttrFromType(QualType T, TypedefNameDecl *&TDNDecl)
bool isObjCQualifiedClassType() const
void CheckObjCBridgeRelatedCast(QualType castType, Expr *castExpr)
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
bool ObjCObjectAdoptsQTypeProtocols(QualType QT, ObjCInterfaceDecl *Decl)
ObjCObjectAdoptsQTypeProtocols - Checks that protocols in IC's protocol list adopt all protocols in Q...
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Values of this type can be null.
bool isUnarySelector() const
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
static void DiagnoseDirectSelectorsExpr(Sema &S, SourceLocation AtLoc, Selector Sel, bool &onlyDirect)
bool isDirectMethod() const
True if the method is tagged as objc_direct.
static Selector constructSetterSelector(IdentifierTable &Idents, SelectorTable &SelTable, const IdentifierInfo *Name)
Return the default setter selector for the given identifier.
bool followsCreateRule(const FunctionDecl *FD)
Selector getNullarySelector(IdentifierInfo *ID)
Represents the results of name lookup.
static ObjCInterfaceDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id, ObjCTypeParamList *typeParamList, ObjCInterfaceDecl *PrevDecl, SourceLocation ClassLoc=SourceLocation(), bool isInternal=false)
ObjCContainerDecl - Represents a container for method declarations.
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
ExprResult BuildObjCNumericLiteral(SourceLocation AtLoc, Expr *Number)
BuildObjCNumericLiteral - builds an ObjCBoxedExpr AST node for the numeric literal expression...
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
static void applyCocoaAPICheck(Sema &S, const ObjCMessageExpr *Msg, unsigned DiagID, bool(*refactor)(const ObjCMessageExpr *, const NSAPI &, edit::Commit &))
Whether values of this type can be null is (explicitly) unspecified.
QualType getObjCNSStringType() const
SourceLocation getBeginLoc() const LLVM_READONLY
const ObjCObjectPointerType * getAsObjCQualifiedClassType() const
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
Represents a declaration of a type.
A builtin binary operation expression such as "x + y" or "x <= y".
CanQualType PseudoObjectTy
tokloc_iterator tokloc_end() const
A conversion for an operand of a builtin overloaded operator.
CheckedConversionKind
The kind of conversion being performed.
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
ObjCStringLiteral, used for Objective-C string literals i.e.
Values of this type can never be null.
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
Scope - A scope is a transient data structure that is used while parsing the program.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
void getOverriddenMethods(SmallVectorImpl< const ObjCMethodDecl *> &Overridden) const
Return overridden methods for the given Method.
ObjCMethodDecl * lookupClassMethod(Selector Sel) const
Lookup a class method for a given selector.
void CheckTollFreeBridgeCast(QualType castType, Expr *castExpr)
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Represents an Objective-C protocol declaration.
AssociationTy< false > Association
const internal::VariadicDynCastAllOfMatcher< Stmt, CastExpr > castExpr
Matches any cast nodes of Clang's AST.
ObjCInterfaceDecl * NSNumberDecl
The declaration of the Objective-C NSNumber class.
const LangOptions & getLangOpts() const
ExprResult BuildObjCDictionaryLiteral(SourceRange SR, MutableArrayRef< ObjCDictionaryElement > Elements)
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
Represents an ObjC class declaration.
Bridging via __bridge_transfer, which transfers ownership of an Objective-C pointer into ARC...
QualType getReturnType() const
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface...
QualType getObjCProtoType() const
Retrieve the type of the Objective-C Protocol class.
void setMethodParams(ASTContext &C, ArrayRef< ParmVarDecl *> Params, ArrayRef< SourceLocation > SelLocs=llvm::None)
Sets the method's parameters and selector source locations.
const LangOptions & LangOpts
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point...
bool isObjCSelfExpr() const
Check if this expression is the ObjC 'self' implicit parameter.
bool isKnownName(StringRef name)
ObjCMethodDecl * getCategoryClassMethod(Selector Sel) const
static bool isAnyRetainable(ARCConversionTypeClass ACTC)
ConditionalOperator - The ?: ternary operator.
Sema - This implements semantic analysis and AST building for C.
RecordDecl * getMostRecentDecl()
StringRef getString() const
CharSourceRange getFileRange(SourceManager &SM) const
void EmitRelatedResultTypeNoteForReturn(QualType destType)
Given that we had incompatible pointer types in a return statement, check whether we're in a method w...
A little helper class used to produce diagnostics.
const ObjCObjectType * getSuperClassType() const
Retrieve the superclass type.
ExprResult BuildObjCBridgedCast(SourceLocation LParenLoc, ObjCBridgeCastKind Kind, SourceLocation BridgeKeywordLoc, TypeSourceInfo *TSInfo, Expr *SubExpr)
CastKind
CastKind - The kind of operation required for a conversion.
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 ObjCInterfaceDecl * LookupObjCInterfaceDeclForLiteral(Sema &S, SourceLocation Loc, Sema::ObjCLiteralKind LiteralKind)
Looks up ObjCInterfaceDecl of a given NSClassIdKindKind.
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
bool hasDefinition() const
Determine whether this protocol has a definition.
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
static StringLiteral * Create(const ASTContext &Ctx, StringRef Str, StringKind Kind, bool Pascal, QualType Ty, const SourceLocation *Loc, unsigned NumConcatenated)
This is the "fully general" constructor that allows representation of strings formed from multiple co...
ObjCStringFormatFamily getStringFormatFamily() const
This represents one expression.
ObjCMethodList * getNext() const
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Expr * stripARCUnbridgedCast(Expr *e)
stripARCUnbridgedCast - Given an expression of ARCUnbridgedCast type, remove the placeholder cast...
bool checkObjCBridgeRelatedComponents(SourceLocation Loc, QualType DestType, QualType SrcType, ObjCInterfaceDecl *&RelatedClass, ObjCMethodDecl *&ClassMethod, ObjCMethodDecl *&InstanceMethod, TypedefNameDecl *&TDNDecl, bool CfToNs, bool Diagnose=true)
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
static Kind getNullabilityAttrKind(NullabilityKind kind)
Retrieve the attribute kind corresponding to the given nullability kind.
const T * castAs() const
Member-template castAs<specific type>.
static bool isAnyCLike(ARCConversionTypeClass ACTC)
bool isObjCRetainableType() const
static ARCConversionTypeClass classifyTypeForARCConversion(QualType type)
static QualType stripObjCInstanceType(ASTContext &Context, QualType T)
bool CheckMessageArgumentTypes(const Expr *Receiver, QualType ReceiverType, MultiExprArg Args, Selector Sel, ArrayRef< SourceLocation > SelectorLocs, ObjCMethodDecl *Method, bool isClassMessage, bool isSuperMessage, SourceLocation lbrac, SourceLocation rbrac, SourceRange RecRange, QualType &ReturnType, ExprValueKind &VK)
CheckMessageArgumentTypes - Check types in an Obj-C message send.
bool hasRelatedResultType() const
Determine whether this method has a result type that is related to the message receiver's type...
Defines the clang::Preprocessor interface.
bool isObjCClassType() const
DeclContext * getDeclContext()
edit_iterator edit_begin() const
ObjCInterfaceDecl * getSuperClass() const
ObjCSelectorExpr used for @selector in Objective-C.
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
static ObjCDictionaryLiteral * Create(const ASTContext &C, ArrayRef< ObjCDictionaryElement > VK, bool HasPackExpansions, QualType T, ObjCMethodDecl *method, SourceRange SR)
QualType NSNumberPointer
Pointer to NSNumber type (NSNumber *).
Defines the clang::TypeLoc interface and its subclasses.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
static Optional< NullabilityKind > stripOuterNullability(QualType &T)
Strip off the top-level nullability annotation on the given type, if it's there.
DefinitionKind hasDefinition(ASTContext &) const
Check whether this variable is defined in this translation unit.
bool isIdentifier() const
Predicate functions for querying what type of name this is.
ObjCMessageKind getObjCMessageKind(Scope *S, IdentifierInfo *Name, SourceLocation NameLoc, bool IsSuper, bool HasTrailingDot, ParsedType &ReceiverType)
An expression that sends a message to the given Objective-C object or class.
ObjCMethodDecl * getImplicitPropertyGetter() const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
SourceLocation getEnd() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
bool isInstanceMethod() const
ArraySizeModifier getSizeModifier() const
bool rewriteObjCRedundantCallWithLiteral(const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit)
unsigned getNumArgs() const
Selector getSelector() const
bool CheckTollFreeBridgeStaticCast(QualType castType, Expr *castExpr, CastKind &Kind)
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr.cast]), which uses the syntax (Type)expr.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
ImplicitParamDecl * getSelfDecl() const
SourceLocation getEndLoc() const LLVM_READONLY
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType)
bool isConstQualified() const
Determine whether this type is const-qualified.
ExprResult ParseObjCProtocolExpression(IdentifierInfo *ProtocolName, SourceLocation AtLoc, SourceLocation ProtoLoc, SourceLocation LParenLoc, SourceLocation ProtoIdLoc, SourceLocation RParenLoc)
ParseObjCProtocolExpression - Build protocol expression for @protocol.
QualType getWideCharType() const
Return the type of wide characters.
There is no lifetime qualification on this type.
static bool isMethodDeclaredInRootProtocol(Sema &S, const ObjCMethodDecl *M)
std::string getAsString() const
Derive the full selector name (e.g.
SelectorTable & Selectors
bool QIdProtocolsAdoptObjCObjectProtocols(QualType QT, ObjCInterfaceDecl *IDecl)
QIdProtocolsAdoptObjCObjectProtocols - Checks that protocols in QT's qualified-id protocol list adopt...
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
ObjCMethodFamily getMethodFamily() const
Derive the conventional family of this method.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
Encodes a location in the source.
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
Sugar for parentheses used when specifying types.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
Expr * getSubExpr() const
Represents typeof(type), a GCC extension.
Interfaces are the core concept in Objective-C for object oriented design.
static bool Ret(InterpState &S, CodePtr &PC, APValue &Result)
CastKind getCastKind() const
std::string getNameAsString() const
Get a human-readable name for the declaration, even if it is one of the special kinds of names (C++ c...
ObjCMethodFamily getMethodFamily() const
MutableArrayRef< Expr * > MultiExprArg
ExprResult ActOnClassMessage(Scope *S, ParsedType Receiver, Selector Sel, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args)
bool makeUnavailableInSystemHeader(SourceLocation loc, UnavailableAttr::ImplicitReason reason)
makeUnavailableInSystemHeader - There is an error in the current context.
QualType getObjCSelType() const
Retrieve the type that corresponds to the predefined Objective-C 'SEL' type.
bool ObjCWarnForNoDesignatedInitChain
This starts true for a method marked as designated initializer and will be set to false if there is a...
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
ExprResult BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements)
ExprResult DefaultLvalueConversion(Expr *E)
static void HelperToDiagnoseDirectSelectorsExpr(Sema &S, SourceLocation AtLoc, Selector Sel, ObjCMethodList &MethList, bool &onlyDirect)
bool CheckObjCARCUnavailableWeakConversion(QualType castType, QualType ExprType)
bool isLiteral(TokenKind K)
Return true if this is a "literal" kind, like a numeric constant, string, etc.
Name lookup found an unresolvable value declaration and cannot yet complete.
static bool isCast(CheckedConversionKind CCK)
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
ObjCProtocolExpr used for protocol expression in Objective-C.
Describes the kind of initialization being performed, along with location information for tokens rela...
SourceLocation getBeginLoc() const LLVM_READONLY
ExprResult ActOnClassPropertyRefExpr(IdentifierInfo &receiverName, IdentifierInfo &propertyName, SourceLocation receiverNameLoc, SourceLocation propertyNameLoc)
bool isObjCObjectPointerType() const
static ExprResult CheckObjCCollectionLiteralElement(Sema &S, Expr *Element, QualType T, bool ArrayLiteral=false)
Check that the given expression is a valid element of an Objective-C collection literal.
bool FormatStringHasSArg(const StringLiteral *FExpr)
Represents one property declaration in an Objective-C interface.
ExprResult BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, QualType ReceiverType, SourceLocation SuperLoc, Selector Sel, ObjCMethodDecl *Method, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args, bool isImplicit=false)
Build an Objective-C class message expression.
bool isSuperClassOf(const ObjCInterfaceDecl *I) const
isSuperClassOf - Return true if this class is the specified class or is a super class of the specifie...
No entity found met the criteria.
bool ObjCIsDesignatedInit
True when this is a method marked as a designated initializer.
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...
const ObjCMethodDecl * getMethodDecl() const
bool isVectorType() const
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
ObjCBoxedExpr - used for generalized expression boxing.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
ExprResult ParseObjCSelectorExpression(Selector Sel, SourceLocation AtLoc, SourceLocation SelLoc, SourceLocation LParenLoc, SourceLocation RParenLoc, bool WarnMultipleSelectors)
ParseObjCSelectorExpression - Build selector expression for @selector.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
static Expr * maybeUndoReclaimObject(Expr *e)
Look for an ObjCReclaimReturnedObject cast and destroy it.
bool isDesignatedInitializerForTheInterface(const ObjCMethodDecl **InitMethod=nullptr) const
Returns true if the method selector resolves to a designated initializer in the class's interface...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
QualType getObjCInstanceType()
Retrieve the Objective-C "instancetype" type, if already known; otherwise, returns a NULL type;...
Represents a C11 generic selection.
StringRef getName() const
Return the actual identifier string.
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers...
Base class for declarations which introduce a typedef-name.
Expr * getResultExpr()
Return the result-bearing expression, or null if there is none.
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
CanQualType ObjCBuiltinIdTy
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
tokloc_iterator tokloc_begin() const
ObjCMethodDecl * lookupPrivateMethod(const Selector &Sel, bool Instance=true) const
Lookup a method in the classes implementation hierarchy.
ExprResult BuildObjCStringLiteral(SourceLocation AtLoc, StringLiteral *S)
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
ObjCMethodDecl * NSNumberLiteralMethods[NSAPI::NumNSNumberLiteralMethods]
The Objective-C NSNumber methods used to create NSNumber literals.
static bool GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx)
bool isCommitable() const
static void addFixitForObjCARCConversion(Sema &S, DiagnosticBuilder &DiagB, Sema::CheckedConversionKind CCK, SourceLocation afterLParen, QualType castType, Expr *castExpr, Expr *realCast, const char *bridgeKeyword, const char *CFBridgeName)
CharSourceRange getInsertFromRange(SourceManager &SM) const
bool ObjCIsSecondaryInit
True when this is an initializer method not marked as a designated initializer within a class that ha...
QualType getUnderlyingType() const
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
static GenericSelectionExpr * Create(const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo *> AssocTypes, ArrayRef< Expr *> AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
Create a non-result-dependent generic selection expression.
The name of a declaration.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
U cast(CodeGen::Address addr)
bool ObjCWarnForNoInitDelegation
This starts true for a secondary initializer method and will be set to false if there is an invocatio...
ExplicitCastExpr - An explicit cast written in the source code.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Bridging via __bridge_retain, which makes an ARC object available as a +1 C pointer.
ACCResult
A result from the cast checker.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
ExprResult BuildInstanceMessage(Expr *Receiver, QualType ReceiverType, SourceLocation SuperLoc, Selector Sel, ObjCMethodDecl *Method, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args, bool isImplicit=false)
Build an Objective-C instance message expression.
Represents a pointer to an Objective C object.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
Name lookup found a single declaration that met the criteria.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
ExprResult BuildObjCEncodeExpression(SourceLocation AtLoc, TypeSourceInfo *EncodedTypeInfo, SourceLocation RParenLoc)
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...
unsigned getIndexTypeCVRQualifiers() const
QualType getStringLiteralArrayType(QualType EltTy, unsigned Length) const
Return a type for a constant array for a string literal of the specified element type and length...
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface...
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
CanQualType UnsignedLongTy
ObjCEncodeExpr, used for @encode in Objective-C.
Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV)
Can create any sort of selector.
ExprResult BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr)
BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the '@' prefixed parenthesized expression...
void getObjCEncodingForType(QualType T, std::string &S, const FieldDecl *Field=nullptr, QualType *NotEncodedT=nullptr) const
Emit the Objective-CC type encoding for the given type T into S.
ExprResult HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, Expr *BaseExpr, SourceLocation OpLoc, DeclarationName MemberName, SourceLocation MemberLoc, SourceLocation SuperLoc, QualType SuperType, bool Super)
HandleExprPropertyRefExpr - Handle foo.bar where foo is a pointer to an objective C interface...
Expr * IgnoreParenLValueCasts() LLVM_READONLY
Skip past any parentheses and lvalue casts which might surround this expression until reaching a fixe...
Base for LValueReferenceType and RValueReferenceType.
Simple template class for restricting typo correction candidates to ones having a single Decl* of the...
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc, SourceLocation EncodeLoc, SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc)
Optional< ArrayRef< QualType > > getObjCSubstitutions(const DeclContext *dc) const
Retrieve the set of substitutions required when accessing a member of the Objective-C receiver type t...
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
ObjCMethodDecl * lookupMethod(Selector Sel, bool isInstance, bool shallowCategoryLookup=false, bool followSuper=true, const ObjCCategoryDecl *C=nullptr) const
lookupMethod - This method returns an instance/class method by looking in the class, its categories, and its super classes (using a linear search).
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
QualType getObjCConstantStringInterface() const
SourceManager & getSourceManager()
static bool isIdentifierBodyChar(char c, const LangOptions &LangOpts)
Returns true if the given character could appear in an identifier.
ImplementationControl getImplementationControl() const
static NSAPI::NSClassIdKindKind ClassKindFromLiteralKind(Sema::ObjCLiteralKind LiteralKind)
Maps ObjCLiteralKind to NSClassIdKindKind.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
TypedefNameDecl * getDecl() const
Reading or writing from this object requires a barrier call.
No particular method family.
void setObjCNSStringType(QualType T)
An attributed type is a type to which a type attribute has been applied.
const ObjCPropertyDecl * findPropertyDecl(bool CheckOverrides=true) const
Returns the property associated with this method's selector.
TranslationUnitDecl * getTranslationUnitDecl() const
Describes the sequence of initializations required to initialize a given object or reference with a s...
ExprResult ActOnInstanceMessage(Scope *S, Expr *Receiver, Selector Sel, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args)
Expr * getTrueExpr() const
bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method, const ObjCMethodDecl *PrevMethod, MethodMatchStrategy strategy=MMS_strict)
MatchTwoMethodDeclarations - Checks if two methods' type match and returns true, or false...
The parameter type of a method or function.
ObjCIvarDecl - Represents an ObjC instance variable.
static bool CheckObjCBridgeCFCast(Sema &S, QualType castType, Expr *castExpr, bool &HadTheAttribute, bool warn)
QualType getSendResultType() const
Determine the type of an expression that sends a message to this function.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
static T * getObjCBridgeAttr(const TypedefType *TD)
SourceManager & getSourceManager() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
ExprResult BuildInstanceMessageImplicit(Expr *Receiver, QualType ReceiverType, SourceLocation Loc, Selector Sel, ObjCMethodDecl *Method, MultiExprArg Args)
StringLiteral - This represents a string literal expression, e.g.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
SourceLocation getBeginLoc() const LLVM_READONLY
a linked list of methods with the same selector name but different signatures.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
void EmitRelatedResultTypeNote(const Expr *E)
If the given expression involves a message send to a method with a related result type...
Abstract class common to all of the C++ "named"/"keyword" casts.
The top declaration context.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
static bool ValidateObjCLiteralInterfaceDecl(Sema &S, ObjCInterfaceDecl *Decl, SourceLocation Loc, Sema::ObjCLiteralKind LiteralKind)
Validates ObjCInterfaceDecl availability.
A reference to a declared variable, function, enum, etc.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
bool isPointerType() const
SourceManager & SourceMgr
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
An l-value expression is a reference to an object with independent storage.
A trivial tuple used to represent a source range.
ObjCMethodDecl * getMethod(Selector Sel, bool isInstance, bool AllowHidden=false) const
ObjCMethodDecl * getGetterMethodDecl() const
static void DiagnoseMismatchedSelectors(Sema &S, SourceLocation AtLoc, ObjCMethodDecl *Method, SourceLocation LParenLoc, SourceLocation RParenLoc, bool WarnMultipleSelectors)
This represents a decl that may have a name.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
ExprResult BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr, Expr *IndexExpr, ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod)
Build an ObjC subscript pseudo-object expression, given that that's supported by the runtime...
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...
bool isPropertyAccessor() const
Expr * IgnoreParenNoopCasts(const ASTContext &Ctx) LLVM_READONLY
Skip past any parenthese and casts which do not change the value (including ptr->int casts of the sam...
static bool isObjCNSObjectType(QualType Ty)
Return true if this is an NSObject object with its NSObject attribute set.
Describes an entity that is being initialized.
void setType(QualType newType)
SourceLocation getBegin() const
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
This class handles loading and caching of source files into memory.
Represents the canonical version of C arrays with a specified constant size.
Defines enum values for all the target-independent builtin functions.
static void checkCocoaAPI(Sema &S, const ObjCMessageExpr *Msg)
SourceLocation getLocation() const
QualType getType() const
Return the type wrapped by this type source info.
ArrayRef< ParmVarDecl * > parameters() const
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point...
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs, ArrayRef< Expr *> Strings)
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.