28 #include "llvm/ADT/SmallString.h"
30 using namespace clang;
32 using llvm::makeArrayRef;
43 if (Strings.size() != 1) {
48 for (
Expr *
E : Strings) {
49 S = cast<StringLiteral>(
E);
54 << S->getSourceRange();
68 assert(CAT &&
"String literal not of constant array type!");
73 false, StrTy, &StrLocs[0],
77 return BuildObjCStringLiteral(AtLocs[0], S);
82 if (CheckObjCString(S))
92 }
else if (getLangOpts().NoConstantCFStrings) {
94 std::string StringClass(getLangOpts().ObjCConstantStringClass);
96 if (StringClass.empty())
101 NamedDecl *IF = LookupSingleName(TUScope, NSIdent, AtLoc,
110 Diag(S->
getLocStart(), diag::err_no_nsconstant_string_class) << NSIdent
111 << S->getSourceRange();
116 NamedDecl *IF = LookupSingleName(TUScope, NSIdent, AtLoc,
151 S.
Diag(Loc, diag::err_undeclared_boxing_method) << Sel << Class->
getName();
158 S.
Diag(Loc, diag::err_objc_literal_method_sig)
160 S.
Diag(Method->getLocation(), diag::note_objc_literal_method_return)
171 switch (LiteralKind) {
189 llvm_unreachable(
"LiteralKind can't be converted into a ClassKind");
201 S.
Diag(Loc, diag::err_undeclared_objc_literal_class)
202 << II->
getName() << LiteralKind;
205 S.
Diag(Loc, diag::err_undeclared_objc_literal_class)
206 << Decl->
getName() << LiteralKind;
207 S.
Diag(Decl->getLocation(), diag::note_forward_class);
246 S.
NSAPIObj->getNSNumberFactoryMethodKind(NumberType);
250 S.
Diag(Loc, diag::err_invalid_nsnumber_type)
283 if (!Method && S.
getLangOpts().DebuggerObjCLiteral) {
320 switch (Char->getKind()) {
352 ExprResult ConvertedNumber = PerformCopyInitialization(Entity,
357 Number = ConvertedNumber.
get();
360 return MaybeBindToTemporary(
370 Inner = ActOnCXXBoolLiteral(ValueLoc, Value? tok::kw_true : tok::kw_false);
374 Inner = ActOnIntegerConstant(ValueLoc, Value? 1 : 0);
376 CK_IntegralToBoolean);
379 return BuildObjCNumericLiteral(AtLoc, Inner.
get());
386 bool ArrayLiteral =
false) {
394 Element = Result.
get();
407 return Seq.Perform(S, Entity, Kind, Element);
410 Expr *OrigElement = Element;
416 Element = Result.
get();
421 bool Recovered =
false;
424 if (isa<IntegerLiteral>(OrigElement) ||
425 isa<CharacterLiteral>(OrigElement) ||
426 isa<FloatingLiteral>(OrigElement) ||
427 isa<ObjCBoolLiteralExpr>(OrigElement) ||
428 isa<CXXBoolLiteralExpr>(OrigElement)) {
429 if (S.
NSAPIObj->getNSNumberFactoryMethodKind(OrigElement->
getType())) {
430 int Which = isa<CharacterLiteral>(OrigElement) ? 1
431 : (isa<CXXBoolLiteralExpr>(OrigElement) ||
432 isa<ObjCBoolLiteralExpr>(OrigElement)) ? 2
435 S.
Diag(OrigElement->getLocStart(), diag::err_box_literal_collection)
436 << Which << OrigElement->getSourceRange()
441 if (Result.isInvalid())
444 Element = Result.get();
449 else if (
StringLiteral *String = dyn_cast<StringLiteral>(OrigElement)) {
450 if (String->isAscii()) {
451 S.
Diag(OrigElement->getLocStart(), diag::err_box_literal_collection)
452 << 0 << OrigElement->getSourceRange()
456 if (Result.isInvalid())
459 Element = Result.get();
465 S.
Diag(Element->getLocStart(), diag::err_invalid_collection_element)
472 dyn_cast<ObjCStringLiteral>(OrigElement)) {
474 unsigned numConcat = SL->getNumConcatenated();
477 bool hasMacro =
false;
478 for (
unsigned i = 0; i < numConcat ; ++i)
479 if (SL->getStrTokenLoc(i).isMacroID()) {
484 S.
Diag(Element->getLocStart(),
485 diag::warn_concatenated_nsarray_literal)
496 Element->getLocStart(), Element);
508 ExprResult RValue = DefaultFunctionArrayLvalueConversion(ValueExpr);
513 ValueExpr = RValue.
get();
529 if (!StringWithUTF8StringMethod) {
534 BoxingMethod = NSStringDecl->lookupClassMethod(stringWithUTF8String);
535 if (!BoxingMethod && getLangOpts().DebuggerObjCLiteral) {
540 NSStringPointer, ReturnTInfo, NSStringDecl,
559 stringWithUTF8String, BoxingMethod))
562 StringWithUTF8StringMethod = BoxingMethod;
565 BoxingMethod = StringWithUTF8StringMethod;
566 BoxedType = NSStringPointer;
568 }
else if (ValueType->isBuiltinType()) {
576 dyn_cast<CharacterLiteral>(ValueExpr->
IgnoreParens())) {
579 switch (Char->getKind()) {
598 CheckForIntOverflow(ValueExpr);
603 BoxedType = NSNumberPointer;
605 if (!ET->getDecl()->isComplete()) {
606 Diag(Loc, diag::err_objc_incomplete_boxed_expression_type)
607 << ValueType << ValueExpr->getSourceRange();
612 ET->getDecl()->getIntegerType());
613 BoxedType = NSNumberPointer;
614 }
else if (ValueType->isObjCBoxableRecordType()) {
632 if (!ValueWithBytesObjCTypeMethod) {
640 BoxingMethod = NSValueDecl->lookupClassMethod(ValueWithBytesObjCType);
641 if (!BoxingMethod && getLangOpts().DebuggerObjCLiteral) {
648 ValueWithBytesObjCType,
669 Params.push_back(bytes);
679 Params.push_back(type);
686 ValueWithBytesObjCType, BoxingMethod))
689 ValueWithBytesObjCTypeMethod = BoxingMethod;
692 if (!ValueType.isTriviallyCopyableType(
Context)) {
693 Diag(Loc, diag::err_objc_non_trivially_copyable_boxed_expression_type)
694 << ValueType << ValueExpr->getSourceRange();
698 BoxingMethod = ValueWithBytesObjCTypeMethod;
699 BoxedType = NSValuePointer;
703 Diag(Loc, diag::err_objc_illegal_boxed_expression_type)
704 << ValueType << ValueExpr->getSourceRange();
708 DiagnoseUseOfDecl(BoxingMethod, Loc);
711 if (ValueType->isObjCBoxableRecordType()) {
713 ConvertedValueExpr = PerformCopyInitialization(IE, ValueExpr->
getExprLoc(),
720 ConvertedValueExpr = PerformCopyInitialization(IE,
SourceLocation(),
726 ValueExpr = ConvertedValueExpr.
get();
731 return MaybeBindToTemporary(BoxedExpr);
740 assert(!LangOpts.isSubscriptPointerArithmetic());
745 "base or index cannot have dependent type here");
752 IndexExpr = Result.
get();
755 Result = DefaultLvalueConversion(BaseExpr);
758 BaseExpr = Result.
get();
763 getterMethod, setterMethod, RB);
779 if (!ArrayWithObjectsMethod) {
783 if (!Method && getLangOpts().DebuggerObjCLiteral) {
800 Params.push_back(objects);
808 Params.push_back(cnt);
823 diag::note_objc_literal_method_param)
830 if (!Method->
parameters()[1]->getType()->isIntegerType()) {
834 diag::note_objc_literal_method_param)
842 ArrayWithObjectsMethod = Method;
845 QualType ObjectsType = ArrayWithObjectsMethod->parameters()[0]->getType();
850 Expr **ElementsBuffer = Elements.data();
851 for (
unsigned I = 0, N = Elements.size();
I != N; ++
I) {
858 ElementsBuffer[
I] = Converted.
get();
865 return MaybeBindToTemporary(
867 ArrayWithObjectsMethod, SR));
874 if (!NSDictionaryDecl) {
877 if (!NSDictionaryDecl) {
885 if (!DictionaryWithObjectsMethod) {
886 Selector Sel = NSAPIObj->getNSDictionarySelector(
888 ObjCMethodDecl *Method = NSDictionaryDecl->lookupClassMethod(Sel);
889 if (!Method && getLangOpts().DebuggerObjCLiteral) {
908 Params.push_back(objects);
916 Params.push_back(keys);
924 Params.push_back(cnt);
940 diag::note_objc_literal_method_param)
954 if (QIDNSCopying.isNull()) {
968 if (!QIDNSCopying.isNull())
977 diag::note_objc_literal_method_param)
985 QualType CountType = Method->parameters()[2]->getType();
989 Diag(Method->parameters()[2]->getLocation(),
990 diag::note_objc_literal_method_param)
997 DictionaryWithObjectsMethod = Method;
1000 QualType ValuesT = DictionaryWithObjectsMethod->parameters()[0]->getType();
1002 QualType KeysT = DictionaryWithObjectsMethod->parameters()[1]->getType();
1007 bool HasPackExpansions =
false;
1021 Element.Key = Key.
get();
1022 Element.Value = Value.
get();
1024 if (Element.EllipsisLoc.isInvalid())
1027 if (!Element.Key->containsUnexpandedParameterPack() &&
1028 !Element.Value->containsUnexpandedParameterPack()) {
1029 Diag(Element.EllipsisLoc,
1030 diag::err_pack_expansion_without_parameter_packs)
1032 Element.Value->getLocEnd());
1036 HasPackExpansions =
true;
1043 Context, Elements, HasPackExpansions, Ty,
1044 DictionaryWithObjectsMethod, SR));
1058 diag::err_incomplete_type_objc_at_encode,
1065 if (!NotEncodedT.
isNull())
1066 Diag(AtLoc, diag::warn_incomplete_encoded_type)
1067 << EncodedType << NotEncodedT;
1104 bool Warned =
false;
1107 if (MatchingMethodDecl == Method ||
1108 isa<ObjCImplDecl>(MatchingMethodDecl->getDeclContext()) ||
1115 S.
Diag(AtLoc, diag::warning_multiple_selectors)
1118 S.
Diag(Method->getLocation(), diag::note_method_declared_at)
1121 S.
Diag(MatchingMethodDecl->getLocation(), diag::note_method_declared_at)
1132 bool WarnMultipleSelectors) {
1133 if (!WarnMultipleSelectors ||
1136 bool Warned =
false;
1142 Method, InstMethList))
1148 Method, ClsMethList) || Warned)
1158 bool WarnMultipleSelectors) {
1166 Selector MatchedSel = OM->getSelector();
1169 Diag(SelLoc, diag::warn_undeclared_selector_with_typo)
1170 << Sel << MatchedSel
1174 Diag(SelLoc, diag::warn_undeclared_selector) << Sel;
1177 WarnMultipleSelectors);
1193 Diag(AtLoc, diag::err_arc_illegal_selector) <<
1222 Diag(ProtoLoc, diag::err_undeclared_protocol) << ProtocolId;
1278 bool isClassMessage,
1279 bool isSuperMessage) {
1280 assert(Method &&
"Must have a method");
1315 if (isSuperMessage) {
1318 return transferNullability(
1337 return transferNullability(ReceiverType);
1342 bool isClassMessage,
1343 bool isSuperMessage) {
1355 unsigned receiverNullabilityIdx = 0;
1357 receiverNullabilityIdx = 1 + static_cast<unsigned>(*nullability);
1359 unsigned resultNullabilityIdx = 0;
1361 resultNullabilityIdx = 1 + static_cast<unsigned>(*nullability);
1365 static const uint8_t
None = 0;
1366 static const uint8_t
NonNull = 1;
1369 static const uint8_t nullabilityMap[4][4] = {
1377 unsigned newResultNullabilityIdx
1378 = nullabilityMap[receiverNullabilityIdx][resultNullabilityIdx];
1379 if (newResultNullabilityIdx == resultNullabilityIdx)
1385 if (
auto attributed = dyn_cast<AttributedType>(resultType.
getTypePtr())) {
1386 resultType = attributed->getModifiedType();
1393 if (newResultNullabilityIdx > 0) {
1398 resultType, resultType);
1414 dyn_cast<ObjCImplDecl>(MD->getDeclContext())) {
1417 dyn_cast<ObjCCategoryImplDecl>(impl)) {
1418 iface = catImpl->getCategoryDecl();
1420 iface = impl->getClassInterface();
1430 for (
unsigned i = 0, e = overrides.size(); i != e; ++i) {
1451 SourceRange range = overridden->getReturnTypeSourceRange();
1454 loc = overridden->getLocation();
1455 Diag(loc, diag::note_related_result_type_explicit)
1463 Diag(MD->getLocation(), diag::note_related_result_type_family)
1489 Diag(Method->getLocation(), diag::note_related_result_type_inferred)
1499 bool isClassMessage,
bool isSuperMessage,
1504 if (!SelectorLocs.empty() && SelectorLocs.front().isValid())
1505 SelLoc = SelectorLocs.front();
1511 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
1512 if (Args[i]->isTypeDependent())
1524 Args[i] = result.
get();
1529 DiagID = diag::err_arc_method_not_found;
1531 DiagID = isClassMessage ? diag::warn_class_method_not_found
1532 : diag::warn_inst_method_not_found;
1535 if (OMD && !OMD->isInvalidDecl()) {
1537 DiagID = diag::error_method_not_found_with_typo;
1539 DiagID = isClassMessage ? diag::warn_class_method_not_found_with_typo
1540 : diag::warn_instance_method_not_found_with_typo;
1542 SourceRange SelectorRange(SelectorLocs.front(), SelectorLocs.back());
1544 Diag(SelLoc, DiagID)
1545 << Sel<< isClassMessage << MatchedSel
1548 Diag(SelLoc, DiagID) << Sel<< isClassMessage << MatchedSel;
1551 Diag(SelLoc, DiagID)
1552 << Sel << isClassMessage <<
SourceRange(SelectorLocs.front(),
1553 SelectorLocs.back());
1558 Diag(ThisClass->getLocation(), diag::note_receiver_class_declared);
1560 if (ThisClass->lookupClassMethod(Sel))
1561 Diag(RecRange.
getBegin(),diag::note_receiver_expr_here)
1563 ThisClass->getNameAsString());
1589 if (Args.size() < NumNamedArgs) {
1590 Diag(SelLoc, diag::err_typecheck_call_too_few_args)
1591 << 2 << NumNamedArgs << static_cast<unsigned>(Args.size());
1599 bool IsError =
false;
1600 for (
unsigned i = 0; i < NumNamedArgs; i++) {
1602 if (Args[i]->isTypeDependent())
1605 Expr *argExpr = Args[i];
1608 assert(argExpr &&
"CheckMessageArgumentTypes(): missing expression");
1613 !param->hasAttr<CFConsumedAttr>())
1624 Args[i] = argE.
get();
1642 diag::err_call_incomplete_argument, argExpr))
1657 Args[i]->getType()->isBlockPointerType() &&
1661 Args[i] = arg.
get();
1668 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
1669 if (Args[i]->isTypeDependent())
1675 Args[i] = Arg.
get();
1679 if (Args.size() != NumNamedArgs) {
1680 Diag(Args[NumNamedArgs]->getLocStart(),
1681 diag::err_typecheck_call_too_many_args)
1682 << 2 << NumNamedArgs << static_cast<unsigned>(Args.size())
1685 Args.back()->getLocEnd());
1692 IsError |= CheckObjCMethodCall(
1693 Method, SelLoc, makeArrayRef(Args.data(), Args.size()));
1706 if (!method)
return false;
1709 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(receiver))
1721 if (
ObjCMethodDecl *method = iface->lookupMethod(sel, isInstance))
1726 if (
ObjCMethodDecl *method = iface->lookupPrivateMethod(sel, isInstance))
1731 for (
const auto *
I : objType->
quals())
1745 for (
const auto *PROTO : OPT->
quals()) {
1746 if ((MD = PROTO->lookupMethod(Sel, Instance))) {
1766 Diag(MemberLoc, diag::err_invalid_property_name)
1774 : BaseExpr->getSourceRange();
1776 diag::err_property_not_found_forward_class,
1777 MemberName, BaseRange))
1795 for (
const auto *
I : OPT->
quals())
1805 SuperLoc, SuperType);
1856 if (Setter && Setter->isImplicit() && Setter->isPropertyAccessor() &&
1864 diag::warn_property_access_suggest)
1865 << MemberName <<
QualType(OPT, 0) << PDecl->getName()
1870 if (Getter || Setter) {
1886 llvm::make_unique<DeclFilterCCC<ObjCPropertyDecl>>(),
1893 Corrected.isKeyword() ?
nullptr : Corrected.getFoundDecl();
1894 if (ChosenDecl && isa<ObjCPropertyDecl>(ChosenDecl))
1895 if (cast<ObjCPropertyDecl>(ChosenDecl)->isClassProperty()) {
1898 Diag(MemberLoc, diag::err_class_property_found) << MemberName
1906 << MemberName <<
QualType(OPT, 0));
1908 TypoResult, MemberLoc,
1909 SuperLoc, SuperType, Super);
1919 diag::err_property_not_as_forward_class,
1920 MemberName, BaseExpr))
1924 diag::err_ivar_access_using_property_syntax_suggest)
1925 << MemberName <<
QualType(OPT, 0) << Ivar->getDeclName()
1930 Diag(MemberLoc, diag::err_property_not_found)
1933 Diag(Setter->getLocation(), diag::note_getter_unavailable)
1934 << MemberName << BaseExpr->getSourceRange();
1952 if (receiverNamePtr->
isStr(
"super")) {
1954 if (
auto classDecl = CurMethod->getClassInterface()) {
1955 SuperType =
QualType(classDecl->getSuperClassType(), 0);
1956 if (CurMethod->isInstanceMethod()) {
1957 if (SuperType.
isNull()) {
1959 Diag(receiverNameLoc, diag::error_root_class_cannot_use_super)
1960 << CurMethod->getClassInterface()->getIdentifier();
1970 receiverNameLoc, T,
true);
1981 Diag(receiverNameLoc, diag::err_expected_either) << tok::identifier
2021 if (Getter || Setter) {
2030 propertyNameLoc, receiverNameLoc, IFace);
2032 return ExprError(
Diag(propertyNameLoc, diag::err_property_not_found)
2046 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
2058 bool HasTrailingDot,
2060 ReceiverType =
nullptr;
2078 if (!Method->getClassInterface()) {
2084 if (Method->getClassInterface()->lookupInstanceVariable(Name,
2129 if (Corrected.isKeyword()) {
2133 PDiag(diag::err_unknown_receiver_suggest) << Name);
2140 PDiag(diag::err_unknown_receiver_suggest) << Name);
2162 Diag(SuperLoc, diag::err_invalid_receiver_to_message_super);
2168 Diag(SuperLoc, diag::error_no_super_class_message)
2174 if (SuperTy.isNull()) {
2176 Diag(SuperLoc, diag::error_root_class_cannot_use_super)
2192 LBracLoc, SelectorLocs, RBracLoc, Args);
2199 SuperLoc, Sel,
nullptr,
2200 LBracLoc, SelectorLocs, RBracLoc, Args);
2204 bool isSuperReceiver,
2210 if (!ReceiverType.
isNull())
2215 Sel, Method, Loc, Loc, Loc, Args,
2229 if (refactor(Msg,*S.
NSAPIObj, ECommit)) {
2238 switch (Edit.
Kind) {
2271 bool Format =
false;
2278 for (
const auto *
I : Method->specific_attrs<FormatAttr>()) {
2285 if (!Format || NumArgs <= Idx)
2288 Expr *FormatExpr = Args[Idx];
2293 S.
Diag(FormatExpr->
getExprLoc(), diag::warn_objc_cdirective_format_string)
2296 S.
Diag(Method->getLocation(), diag::note_method_declared_at)
2343 Diag(Loc, diag::err_missing_open_square_message_send)
2348 if (!SelectorLocs.empty() && SelectorLocs.front().isValid())
2349 SelLoc = SelectorLocs.front();
2356 unsigned NumArgs = ArgsIn.size();
2357 Expr **Args = ArgsIn.data();
2358 assert(SuperLoc.
isInvalid() &&
"Message to super with dependent type");
2361 SelectorLocs,
nullptr, makeArrayRef(Args, NumArgs), RBracLoc,
2368 if (!ClassType || !(Class = ClassType->
getInterface())) {
2369 Diag(Loc, diag::err_invalid_receiver_class_message)
2373 assert(Class &&
"We don't know which class we're messaging?");
2384 ? diag::err_arc_receiver_forward_class
2385 : diag::warn_receiver_forward_class),
2391 Diag(Method->getLocation(), diag::note_method_sent_forward_class)
2409 unsigned NumArgs = ArgsIn.size();
2410 Expr **Args = ArgsIn.data();
2414 SuperLoc.
isValid(), LBracLoc, RBracLoc,
2421 diag::err_illegal_message_expr_incomplete_type))
2430 Diag(Loc, diag::warn_direct_initialize_call);
2431 Diag(Method->getLocation(), diag::note_method_declared_at)
2438 Diag(Loc, diag::warn_direct_super_initialize_call);
2439 Diag(Method->getLocation(), diag::note_method_declared_at)
2441 Diag(CurMeth->getLocation(), diag::note_method_declared_at)
2442 << CurMeth->getDeclName();
2454 ReceiverType, Sel, SelectorLocs,
2455 Method, makeArrayRef(Args, NumArgs),
2456 RBracLoc, isImplicit);
2459 ReceiverTypeInfo, Sel, SelectorLocs,
2460 Method, makeArrayRef(Args, NumArgs),
2461 RBracLoc, isImplicit);
2480 if (ReceiverType.
isNull())
2483 if (!ReceiverTypeInfo)
2488 nullptr, LBracLoc, SelectorLocs, RBracLoc,
2500 Sel, Method, Loc, Loc, Loc, Args,
2545 SuperLoc.
isValid()? SuperLoc : Receiver->getSourceRange();
2547 if (!SelectorLocs.empty() && SelectorLocs.front().isValid())
2548 SelLoc = SelectorLocs.front();
2553 Diag(Loc, diag::err_missing_open_square_message_send)
2568 Receiver = Result.
get();
2574 unsigned NumArgs = ArgsIn.size();
2575 Expr **Args = ArgsIn.data();
2576 assert(SuperLoc.
isInvalid() &&
"Message to super with dependent type");
2579 SelectorLocs,
nullptr, makeArrayRef(Args, NumArgs),
2580 RBracLoc, isImplicit);
2588 Receiver = Result.
get();
2589 ReceiverType = Receiver->
getType();
2602 Diag(Loc, diag::warn_bad_receiver_type)
2604 << Receiver->getSourceRange();
2607 CK_CPointerToObjCPointerCast).
get();
2612 CastKind Kind = IsNull ? CK_NullToPointer : CK_IntegralToPointer;
2616 ReceiverType = Receiver->
getType();
2620 diag::err_incomplete_receiver_type))
2625 Receiver = result.
get();
2626 ReceiverType = Receiver->
getType();
2647 if (!Methods.empty()) {
2650 Method = Methods[0];
2654 Method = BestMethod;
2658 receiverIsIdLike, Methods))
2676 Diag(SelLoc, diag::warn_instance_method_on_class_found)
2678 Diag(Method->getLocation(), diag::note_method_declared_at)
2686 Method = ClassDecl->lookupClassMethod(Sel);
2689 Method = ClassDecl->lookupPrivateClassMethod(Sel);
2703 if (!Methods.empty()) {
2706 Method = Methods[0];
2711 dyn_cast<ObjCInterfaceDecl>(Method->getDeclContext())) {
2712 if (
ID->getSuperClass())
2713 Diag(SelLoc, diag::warn_root_inst_method_not_found)
2721 Method = BestMethod;
2743 ClassDecl = OCIType->getInterfaceDecl();
2752 ? diag::err_arc_receiver_forward_instance
2753 : diag::warn_receiver_forward_instance,
2754 Receiver? Receiver->getSourceRange()
2759 forwardClass = OCIType->getInterfaceDecl();
2760 Diag(Receiver ? Receiver->getLocStart()
2761 : SuperLoc, diag::note_receiver_is_id);
2776 Diag(SelLoc, diag::err_arc_may_not_respond)
2777 << OCIType->getPointeeType() << Sel << RecRange
2778 <<
SourceRange(SelectorLocs.front(), SelectorLocs.back());
2782 if (!Method && (!Receiver || !
isSelfExpr(Receiver))) {
2786 if (OCIType->qual_empty()) {
2791 if (!Methods.empty()) {
2794 Method = Methods[0];
2799 Method = BestMethod;
2806 if (Method && !forwardClass)
2807 Diag(SelLoc, diag::warn_maynot_respond)
2808 << OCIType->getInterfaceDecl()->getIdentifier()
2817 Diag(Loc, diag::err_bad_receiver_type)
2818 << ReceiverType << Receiver->getSourceRange();
2828 if (DIFunctionScopeInfo &&
2831 bool isDesignatedInitChain =
false;
2838 if (!
ID->declaresOrInheritsDesignatedInitializers() ||
2839 ID->isDesignatedInitializer(Sel)) {
2840 isDesignatedInitChain =
true;
2846 if (!isDesignatedInitChain) {
2850 assert(isDesignated && InitMethod);
2853 diag::warn_objc_designated_init_non_designated_init_call :
2854 diag::warn_objc_designated_init_non_super_designated_init_call);
2855 Diag(InitMethod->getLocation(),
2856 diag::note_objc_designated_init_marked_here);
2860 if (DIFunctionScopeInfo &&
2864 Diag(SelLoc, diag::warn_objc_secondary_init_super_init_call);
2871 unsigned NumArgs = ArgsIn.size();
2872 Expr **Args = ArgsIn.data();
2878 Sel, SelectorLocs, Method,
2879 ClassMessage, SuperLoc.
isValid(),
2880 LBracLoc, RBracLoc, RecRange, ReturnType, VK))
2885 diag::err_illegal_message_expr_incomplete_type))
2913 Diag(SelLoc, diag::err_arc_illegal_explicit_message)
2918 if (Method && NumArgs >= 1) {
2920 Selector ArgSel = SelExp->getSelector();
2923 SelExp->getSourceRange());
2927 SelExp->getSourceRange());
2930 switch (SelFamily) {
2938 if (!SelMethod->hasAttr<NSReturnsNotRetainedAttr>()) {
2941 diag::err_arc_perform_selector_retains);
2942 Diag(SelMethod->getLocation(), diag::note_method_declared_at)
2948 if (SelMethod->hasAttr<NSReturnsRetainedAttr>()) {
2951 diag::err_arc_perform_selector_retains);
2952 Diag(SelMethod->getLocation(), diag::note_method_declared_at)
2960 Diag(SelLoc, diag::warn_arc_perform_selector_leaks);
2961 Diag(Args[0]->getExprLoc(), diag::note_used_here);
2975 ReceiverType, Sel, SelectorLocs, Method,
2976 makeArrayRef(Args, NumArgs), RBracLoc,
2980 Receiver, Sel, SelectorLocs, Method,
2981 makeArrayRef(Args, NumArgs), RBracLoc,
3006 if (!isImplicit && Method) {
3019 CheckObjCCircularContainer(Result);
3049 if (isa<ParenListExpr>(Receiver)) {
3052 Receiver = Result.
get();
3064 nullptr, LBracLoc, SelectorLocs,
3098 bool isIndirect =
false;
3117 type =
QualType(array->getElementType()->getBaseElementTypeUnsafe(), 0);
3152 if (left == right)
return left;
3153 if (left == ACC_bottom)
return right;
3154 if (right == ACC_bottom)
return left;
3160 class ARCCastChecker :
public StmtVisitor<ARCCastChecker, ACCResult> {
3176 : Context(Context), SourceClass(source), TargetClass(target),
3177 Diagnose(diagnose) {}
3207 case CK_NullToPointer:
3211 case CK_LValueToRValue:
3213 case CK_CPointerToObjCPointerCast:
3214 case CK_BlockPointerToObjCPointerCast:
3215 case CK_AnyPointerToBlockPointerCast:
3230 return Visit(e->
getRHS());
3236 if (left == ACC_invalid)
return ACC_invalid;
3266 return ACC_plusZero;
3276 if (
ACCResult result = checkCallToFunction(fn))
3279 return super::VisitCallExpr(e);
3291 if (fn->hasAttr<CFReturnsNotRetainedAttr>())
3292 return ACC_plusZero;
3297 if (fn->hasAttr<CFReturnsRetainedAttr>())
3298 return Diagnose ? ACC_plusOne
3303 if (builtinID == Builtin::BI__builtin___CFStringMakeConstantString)
3307 if (!fn->hasAttr<CFAuditedTransferAttr>())
3312 return Diagnose ? ACC_plusOne
3315 return ACC_plusZero;
3328 return checkCallToMethod(method);
3332 if (!method)
return ACC_invalid;
3341 if (method->hasAttr<CFReturnsNotRetainedAttr>())
3342 return ACC_plusZero;
3346 if (method->hasAttr<CFReturnsRetainedAttr>())
3358 return ACC_plusZero;
3379 const char *bridgeKeyword,
3380 const char *CFBridgeName) {
3395 NCE->getAngleBrackets().getEnd());
3399 char PrevChar = *SM.
getCharacterData(range.getBegin().getLocWithOffset(-1));
3403 BridgeCall += CFBridgeName;
3410 castedE = CCE->getSubExpr();
3421 BridgeCall += CFBridgeName;
3423 if (isa<ParenExpr>(castedE)) {
3441 std::string castCode =
"(";
3442 castCode += bridgeKeyword;
3446 NCE->getAngleBrackets().getEnd());
3450 std::string castCode =
"(";
3451 castCode += bridgeKeyword;
3456 if (isa<ParenExpr>(castedE)) {
3470 template <
typename T>
3478 return RD->getAttr<T>();
3486 TDNDecl = TD->getDecl();
3487 if (ObjCBridgeRelatedAttr *ObjCBAttr =
3488 getObjCBridgeAttr<ObjCBridgeRelatedAttr>(TD))
3505 UnavailableAttr::IR_ARCForbiddenConversion))
3518 unsigned srcKind = 0;
3540 S.
Diag(loc, diag::err_arc_cast_requires_bridge)
3547 << castExpr->getSourceRange();
3550 ARCCastChecker(S.
Context, exprACTC, castACTC,
true).Visit(castExpr);
3551 assert(CreateRule != ACC_bottom &&
"This cast should already be accepted.");
3552 if (CreateRule != ACC_plusOne)
3556 : S.
Diag(noteLoc, diag::note_arc_cstyle_bridge);
3559 castType, castExpr, realCast,
"__bridge ",
3562 if (CreateRule != ACC_plusZero)
3566 S.
Diag(noteLoc, diag::note_arc_cstyle_bridge_transfer) << castExprType :
3568 diag::note_arc_bridge_transfer)
3569 << castExprType << br;
3572 castType, castExpr, realCast,
"__bridge_transfer ",
3573 br ?
"CFBridgingRelease" :
nullptr);
3582 S.
Diag(loc, diag::err_arc_cast_requires_bridge)
3589 << castExpr->getSourceRange();
3591 ARCCastChecker(S.
Context, exprACTC, castACTC,
true).Visit(castExpr);
3592 assert(CreateRule != ACC_bottom &&
"This cast should already be accepted.");
3593 if (CreateRule != ACC_plusOne)
3597 : S.
Diag(noteLoc, diag::note_arc_cstyle_bridge);
3599 castType, castExpr, realCast,
"__bridge ",
3602 if (CreateRule != ACC_plusZero)
3606 S.
Diag(noteLoc, diag::note_arc_cstyle_bridge_retained) << castType :
3608 diag::note_arc_bridge_retained)
3612 castType, castExpr, realCast,
"__bridge_retained ",
3613 br ?
"CFBridgingRetain" :
nullptr);
3619 S.
Diag(loc, diag::err_arc_mismatched_cast)
3621 << srcKind << castExprType << castType
3622 << castRange << castExpr->getSourceRange();
3625 template <
typename TB>
3627 bool &HadTheAttribute,
bool warn) {
3629 HadTheAttribute =
false;
3632 if (TB *ObjCBAttr = getObjCBridgeAttr<TB>(TD)) {
3634 HadTheAttribute =
true;
3635 if (Parm->isStr(
"id"))
3644 if (Target && isa<ObjCInterfaceDecl>(Target)) {
3649 = InterfacePointerType->getObjectType()->getInterface();
3650 if ((CastClass == ExprClass) ||
3654 S.
Diag(castExpr->getLocStart(), diag::warn_objc_invalid_bridge)
3659 castType, ExprClass)))
3666 S.
Diag(castExpr->getLocStart(), diag::warn_objc_invalid_bridge)
3667 << T << Target->
getName() << castType;
3669 S.
Diag(Target->getLocStart(), diag::note_declared_at);
3675 S.
Diag(castExpr->getLocStart(), diag::err_objc_cf_bridged_not_interface)
3676 << castExpr->
getType() << Parm;
3679 S.
Diag(Target->getLocStart(), diag::note_declared_at);
3690 template <
typename TB>
3692 bool &HadTheAttribute,
bool warn) {
3694 HadTheAttribute =
false;
3697 if (TB *ObjCBAttr = getObjCBridgeAttr<TB>(TD)) {
3699 HadTheAttribute =
true;
3700 if (Parm->isStr(
"id"))
3709 if (Target && isa<ObjCInterfaceDecl>(Target)) {
3714 = InterfacePointerType->getObjectType()->getInterface();
3715 if ((CastClass == ExprClass) ||
3719 S.
Diag(castExpr->getLocStart(), diag::warn_objc_invalid_bridge_to_cf)
3726 castExpr->
getType(), CastClass)))
3733 S.
Diag(castExpr->getLocStart(), diag::warn_objc_invalid_bridge_to_cf)
3734 << castExpr->
getType() << castType;
3736 S.
Diag(Target->getLocStart(), diag::note_declared_at);
3742 S.
Diag(castExpr->getLocStart(), diag::err_objc_ns_bridged_invalid_cfobject)
3743 << castExpr->
getType() << castType;
3746 S.
Diag(Target->getLocStart(), diag::note_declared_at);
3763 bool HasObjCBridgeAttr;
3764 bool ObjCBridgeAttrWillNotWarn =
3765 CheckObjCBridgeNSCast<ObjCBridgeAttr>(*
this, castType,
castExpr, HasObjCBridgeAttr,
3767 if (ObjCBridgeAttrWillNotWarn && HasObjCBridgeAttr)
3769 bool HasObjCBridgeMutableAttr;
3770 bool ObjCBridgeMutableAttrWillNotWarn =
3771 CheckObjCBridgeNSCast<ObjCBridgeMutableAttr>(*
this, castType,
castExpr,
3772 HasObjCBridgeMutableAttr,
false);
3773 if (ObjCBridgeMutableAttrWillNotWarn && HasObjCBridgeMutableAttr)
3776 if (HasObjCBridgeAttr)
3777 CheckObjCBridgeNSCast<ObjCBridgeAttr>(*
this, castType,
castExpr, HasObjCBridgeAttr,
3779 else if (HasObjCBridgeMutableAttr)
3780 CheckObjCBridgeNSCast<ObjCBridgeMutableAttr>(*
this, castType,
castExpr,
3781 HasObjCBridgeMutableAttr,
true);
3784 bool HasObjCBridgeAttr;
3785 bool ObjCBridgeAttrWillNotWarn =
3786 CheckObjCBridgeCFCast<ObjCBridgeAttr>(*
this, castType,
castExpr, HasObjCBridgeAttr,
3788 if (ObjCBridgeAttrWillNotWarn && HasObjCBridgeAttr)
3790 bool HasObjCBridgeMutableAttr;
3791 bool ObjCBridgeMutableAttrWillNotWarn =
3792 CheckObjCBridgeCFCast<ObjCBridgeMutableAttr>(*
this, castType,
castExpr,
3793 HasObjCBridgeMutableAttr,
false);
3794 if (ObjCBridgeMutableAttrWillNotWarn && HasObjCBridgeMutableAttr)
3797 if (HasObjCBridgeAttr)
3798 CheckObjCBridgeCFCast<ObjCBridgeAttr>(*
this, castType,
castExpr, HasObjCBridgeAttr,
3800 else if (HasObjCBridgeMutableAttr)
3801 CheckObjCBridgeCFCast<ObjCBridgeMutableAttr>(*
this, castType,
castExpr,
3802 HasObjCBridgeMutableAttr,
true);
3809 if (PRE->isExplicitProperty()) {
3811 SrcType = PDecl->getType();
3813 else if (PRE->isImplicitProperty()) {
3815 SrcType = Getter->getReturnType();
3838 : CK_CPointerToObjCPointerCast;
3850 bool CfToNs,
bool Diagnose) {
3851 QualType T = CfToNs ? SrcType : DestType;
3867 Diag(Loc, diag::err_objc_bridged_related_invalid_class) << RCId
3868 << SrcType << DestType;
3874 if (Target && isa<ObjCInterfaceDecl>(Target))
3875 RelatedClass = cast<ObjCInterfaceDecl>(Target);
3878 Diag(Loc, diag::err_objc_bridged_related_invalid_class_name) << RCId
3879 << SrcType << DestType;
3882 Diag(Target->getLocStart(), diag::note_declared_at);
3888 if (CfToNs && CMId) {
3893 Diag(Loc, diag::err_objc_bridged_related_known_method)
3894 << SrcType << DestType << Sel <<
false;
3902 if (!CfToNs && IMId) {
3904 InstanceMethod = RelatedClass->
lookupMethod(Sel,
true);
3905 if (!InstanceMethod) {
3907 Diag(Loc, diag::err_objc_bridged_related_known_method)
3908 << SrcType << DestType << Sel <<
true;
3920 Expr *&SrcExpr,
bool Diagnose) {
3925 if (!CfToNs && !NsToCf)
3933 ClassMethod, InstanceMethod, TDNDecl,
3941 std::string ExpressionString =
"[";
3943 ExpressionString +=
" ";
3947 Diag(Loc, diag::err_objc_bridged_related_known_method)
3948 << SrcType << DestType << ClassMethod->
getSelector() <<
false
3951 Diag(RelatedClass->getLocStart(), diag::note_declared_at);
3956 Expr *args[] = { SrcExpr };
3958 ClassMethod->getLocation(),
3961 SrcExpr = msg.
get();
3968 if (InstanceMethod) {
3970 std::string ExpressionString;
3977 ExpressionString =
".";
3978 ExpressionString += PDecl->getNameAsString();
3979 Diag(Loc, diag::err_objc_bridged_related_known_method)
3980 << SrcType << DestType << InstanceMethod->
getSelector() <<
true
3983 if (ExpressionString.empty()) {
3985 ExpressionString =
" ";
3987 ExpressionString +=
"]";
3989 Diag(Loc, diag::err_objc_bridged_related_known_method)
3990 << SrcType << DestType << InstanceMethod->
getSelector() <<
true
3994 Diag(RelatedClass->getLocStart(), diag::note_declared_at);
3999 InstanceMethod->getLocation(),
4001 InstanceMethod,
None);
4002 SrcExpr = msg.get();
4014 bool DiagnoseCFAudited,
4026 if (exprACTC == castACTC) {
4031 castType != castExprType) {
4037 if (
const ParenType *PT = dyn_cast<ParenType>(DT))
4038 QDT = PT->desugar();
4039 else if (
const TypeOfType *TP = dyn_cast<TypeOfType>(DT))
4040 QDT = TP->desugar();
4041 else if (
const AttributedType *AT = dyn_cast<AttributedType>(DT))
4042 QDT = AT->desugar();
4043 if (QDT != castType &&
4048 Diag(loc, diag::err_arc_nolifetime_behavior);
4072 switch (ARCCastChecker(
Context, exprACTC, castACTC,
false).Visit(castExpr)) {
4112 (Opc == BO_NE || Opc == BO_EQ))) {
4115 castExpr, exprACTC, CCK);
4134 castType =
cast->getTypeAsWritten();
4137 castRange =
cast->getTypeInfoAsWritten()->getTypeLoc().getSourceRange();
4138 castType =
cast->getTypeAsWritten();
4141 castType =
cast->getType();
4160 if (
ParenExpr *pe = dyn_cast<ParenExpr>(e)) {
4163 }
else if (
UnaryOperator *uo = dyn_cast<UnaryOperator>(e)) {
4164 assert(uo->getOpcode() == UO_Extension);
4167 sub->getValueKind(), sub->getObjectKind(),
4168 uo->getOperatorLoc());
4170 assert(!gse->isResultDependent());
4172 unsigned n = gse->getNumAssocs();
4175 for (
unsigned i = 0; i != n; ++i) {
4176 subTypes[i] = gse->getAssocTypeSourceInfo(i);
4177 Expr *sub = gse->getAssocExpr(i);
4178 if (i == gse->getResultIndex())
4184 gse->getControllingExpr(),
4186 gse->getDefaultLoc(),
4187 gse->getRParenLoc(),
4188 gse->containsUnexpandedParameterPack(),
4189 gse->getResultIndex());
4191 assert(isa<ImplicitCastExpr>(e) &&
"bad form of unbridged cast!");
4192 return cast<ImplicitCastExpr>(e)->getSubExpr();
4202 if (isa<ObjCObjectPointerType>(canCastType) &&
4208 return !ObjI->isArcWeakrefUnavailable();
4221 if (ice->getCastKind() == CK_ARCReclaimReturnedObject)
4222 return ice->getSubExpr();
4234 SubExpr = SubResult.
get();
4241 bool MustConsume =
false;
4248 : CK_CPointerToObjCPointerCast);
4255 Diag(BridgeKeywordLoc, diag::err_arc_bridge_cast_wrong_kind)
4260 << SubExpr->getSourceRange()
4262 Diag(BridgeKeywordLoc, diag::note_arc_bridge)
4264 Diag(BridgeKeywordLoc, diag::note_arc_bridge_transfer)
4267 br ?
"CFBridgingRelease "
4268 :
"__bridge_transfer ");
4292 CK_ARCProduceObject,
4298 Diag(BridgeKeywordLoc, diag::err_arc_bridge_cast_wrong_kind)
4303 << SubExpr->getSourceRange()
4306 Diag(BridgeKeywordLoc, diag::note_arc_bridge)
4308 Diag(BridgeKeywordLoc, diag::note_arc_bridge_retained)
4311 br ?
"CFBridgingRetain " :
"__bridge_retained");
4318 Diag(LParenLoc, diag::err_arc_bridge_cast_incompatible)
4319 << FromType << T << Kind
4320 << SubExpr->getSourceRange()
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...
void setMethodParams(ASTContext &C, ArrayRef< ParmVarDecl * > Params, ArrayRef< SourceLocation > SelLocs=llvm::None)
Sets the method's parameters and selector source locations.
bool hasDefinition() const
Determine whether this class has been defined.
tokloc_iterator tokloc_begin() const
Defines the clang::ASTContext interface.
ObjCMethodDecl * lookupPrivateClassMethod(const Selector &Sel)
SourceLocation getEnd() const
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
CastKind getCastKind() const
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
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'.
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
Smart pointer class that efficiently represents Objective-C method names.
SelectorTable & getSelectorTable()
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
ImplementationControl getImplementationControl() const
Simple class containing the result of Sema::CorrectTypo.
ObjCMethodFamily getMethodFamily() 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.
ObjCMethodDecl * getCategoryClassMethod(Selector Sel) const
void* might be a normal C type, or it might a CF type.
DeclContext * getFunctionLevelDeclContext()
void getOverriddenMethods(SmallVectorImpl< const ObjCMethodDecl * > &Overridden) const
Return overridden methods for the given Method.
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()
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
const LangOptions & getLangOpts() const
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
ObjCMessageKind
Describes the kind of message expression indicated by a message send that starts with an identifier...
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)
Bridging via __bridge, which does nothing but reinterpret the bits.
ObjCMethodDecl * LookupMethodInObjectType(Selector Sel, QualType Ty, bool IsInstance)
LookupMethodInType - Look up a method in an ObjCObjectType.
static bool CheckObjCBridgeNSCast(Sema &S, QualType castType, Expr *castExpr, bool &HadTheAttribute, bool warn)
tokloc_iterator tokloc_end() const
void addConst()
Add the const type qualifier to this QualType.
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
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.
bool isRecordType() const
QualType getUnderlyingType() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs, ArrayRef< Expr * > Strings)
const char * getCharacterData(SourceLocation SL, bool *Invalid=nullptr) const
Return a pointer to the start of the specified location in the appropriate spelling MemoryBuffer...
static bool HelperToDiagnoseMismatchedMethodsInGlobalPool(Sema &S, SourceLocation AtLoc, SourceLocation LParenLoc, SourceLocation RParenLoc, ObjCMethodDecl *Method, ObjCMethodList &MethList)
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
QualType substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
Substitute type arguments for the Objective-C type parameters used in the subject type...
ExprResult DefaultArgumentPromotion(Expr *E)
DefaultArgumentPromotion (C99 6.5.2.2p6).
ParenExpr - This represents a parethesized expression, e.g.
std::string getAsString() const
ExprResult forceUnknownAnyToType(Expr *E, QualType ToType)
Force an expression with unknown-type to an expression of the given type.
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
ObjCStringFormatFamily getStringFormatFamily() const
The base class of the type hierarchy.
bool isObjCQualifiedClassType() const
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.
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
A container of type source information.
SourceLocation getLocStart() const LLVM_READONLY
bool isBlockPointerType() const
static StringLiteral * Create(const ASTContext &C, StringRef Str, StringKind Kind, bool Pascal, QualType Ty, const SourceLocation *Loc, unsigned NumStrs)
This is the "fully general" constructor that allows representation of strings formed from multiple co...
const ObjCObjectPointerType * getAsObjCQualifiedClassType() const
const ObjCPropertyDecl * findPropertyDecl(bool CheckOverrides=true) const
Returns the property associated with this method's selector.
void setDelegateInitCall(bool isDelegate)
ObjCMethodDecl * getMethod(Selector Sel, bool isInstance, bool AllowHidden=false) 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...
VarDecl - An instance of this class is created to represent a variable declaration or definition...
bool isExplicitProperty() const
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
DiagnosticsEngine & Diags
ObjCMethodDecl * tryCaptureObjCSelf(SourceLocation Loc)
Try to capture an implicit reference to 'self'.
ObjCMethodDecl - Represents an instance or class method declaration.
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)
unsigned param_size() const
bool tryCaptureVariable(VarDecl *Var, SourceLocation Loc, TryCaptureKind Kind, SourceLocation EllipsisLoc, bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const unsigned *const FunctionScopeIndexToStopAt)
Try to capture the given variable.
ParmVarDecl - Represents a parameter to a function.
bool isObjCRetainableType() const
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
QualType withConst() const
Retrieves a version of this type with const applied.
Expr * IgnoreImpCasts() LLVM_READONLY
IgnoreImpCasts - Skip past any implicit casts which might surround this expression.
RecordDecl - Represents a struct/union/class.
The message is a class message, and the identifier is a type name.
ExprResult UsualUnaryConversions(Expr *E)
UsualUnaryConversions - Performs various conversions that are common to most operators (C99 6...
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.
unsigned getIndexTypeCVRQualifiers() const
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
An element in an Objective-C dictionary literal.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Represents a class type in Objective C.
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.
bool isIdentifier() const
Predicate functions for querying what type of name this is.
static ObjCArrayLiteral * Create(const ASTContext &C, ArrayRef< Expr * > Elements, QualType T, ObjCMethodDecl *Method, SourceRange SR)
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
bool isCommitable() const
QualType getReturnType() const
void diagnoseARCUnbridgedCast(Expr *e)
Given that we saw an expression with the ARCUnbridgedCastTy placeholder type, complain bitterly...
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 PerformContextuallyConvertToObjCPointer(Expr *From)
PerformContextuallyConvertToObjCPointer - Perform a contextual conversion of the expression From to a...
ExprResult ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals.
static ObjCBridgeRelatedAttr * ObjCBridgeRelatedAttrFromType(QualType T, TypedefNameDecl *&TDNDecl)
bool isNull() const
Determine whether this is the empty selector.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
void CheckObjCBridgeRelatedCast(QualType castType, Expr *castExpr)
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
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...
ObjCMethodDecl * LookupFactoryMethodInGlobalPool(Selector Sel, SourceRange R, bool receiverIdOrClass=false)
LookupFactoryMethodInGlobalPool - Returns the method and warns if there are multiple signatures...
StorageClass getStorageClass() const
Returns the storage class as written in the source.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Values of this type can be null.
QualType getObjCNSStringType() const
bool checkInitMethod(ObjCMethodDecl *method, QualType receiverTypeIfCall)
Check whether the given method, which must be in the 'init' family, is a valid member of that family...
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.
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
static ObjCInterfaceDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id, ObjCTypeParamList *typeParamList, ObjCInterfaceDecl *PrevDecl, SourceLocation ClassLoc=SourceLocation(), bool isInternal=false)
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
ExprResult MaybeConvertParenListExprToParenExpr(Scope *S, Expr *ME)
This is not an AltiVec-style cast or or C++ direct-initialization, so turn the ParenListExpr into a s...
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...
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
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.
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
TypeDecl - Represents a declaration of a type.
A builtin binary operation expression such as "x + y" or "x <= y".
Selector getSelector() const
CanQualType PseudoObjectTy
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface...
CheckedConversionKind
The kind of conversion being performed.
std::string getNameAsString() const
getNameAsString - Get a human-readable name for the declaration, even if it is one of the special kin...
bool isDesignatedInitializerForTheInterface(const ObjCMethodDecl **InitMethod=nullptr) const
Returns true if the method selector resolves to a designated initializer in the class's interface...
const ObjCObjectType * getAsObjCInterfaceType() const
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
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 ObjCMethodDecl * SelectorsForTypoCorrection(Selector Sel, QualType ObjectType=QualType())
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.
ObjCInterfaceDecl * NSNumberDecl
The declaration of the Objective-C NSNumber class.
ExprResult BuildObjCDictionaryLiteral(SourceRange SR, MutableArrayRef< ObjCDictionaryElement > Elements)
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
Represents an ObjC class declaration.
bool CollectMultipleMethodsInGlobalPool(Selector Sel, SmallVectorImpl< ObjCMethodDecl * > &Methods, bool InstanceFirst, bool CheckTheOther, const ObjCObjectType *TypeBound=nullptr)
Returns instance or factory methods in global method pool for given selector.
Bridging via __bridge_transfer, which transfers ownership of an Objective-C pointer into ARC...
ObjCMethodDecl * getMethod() const
detail::InMemoryDirectory::const_iterator I
ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, QualType ¶mType)
Type-check an expression that's being passed to an __unknown_anytype parameter.
const LangOptions & LangOpts
edit_iterator edit_begin() const
ObjCMethodDecl * lookupPrivateMethod(const Selector &Sel, bool Instance=true) const
Lookup a method in the classes implementation hierarchy.
bool isKnownName(StringRef name)
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
static bool isAnyRetainable(ARCConversionTypeClass ACTC)
ConditionalOperator - The ?: ternary operator.
Sema - This implements semantic analysis and AST building for C.
RecordDecl * getMostRecentDecl()
Expr * getFalseExpr() const
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
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.
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...
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
SourceLocation getLocStart() const LLVM_READONLY
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this 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)
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
void recordUseOfWeak(const ExprT *E, bool IsRead=true)
Record that a weak object was accessed.
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.
bool CheckMessageArgumentTypes(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.
sema::FunctionScopeInfo * getEnclosingFunction() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isUnarySelector() const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
const ObjCMethodDecl * getMethodDecl() const
Expr - This represents one expression.
StringRef getName() const
Return the actual identifier string.
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 isImplicitlyDeclared=false, bool isDefined=false, ImplementationControl impControl=None, bool HasRelatedResultType=false)
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)
unsigned getNumArgs() const
static Kind getNullabilityAttrKind(NullabilityKind kind)
Retrieve the attribute kind corresponding to the given nullability kind.
bool isObjCClassType() const
The message is an instance message.
static bool isAnyCLike(ARCConversionTypeClass ACTC)
static ARCConversionTypeClass classifyTypeForARCConversion(QualType type)
static QualType stripObjCInstanceType(ASTContext &Context, QualType T)
TranslationUnitDecl * getTranslationUnitDecl() const
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
Defines the clang::Preprocessor interface.
ObjCMethodDecl * getImplicitPropertyGetter() const
ObjCMethodDecl * lookupInstanceMethod(Selector Sel) const
Lookup an instance method for a given selector.
ObjCMethodDecl * lookupClassMethod(Selector Sel) const
Lookup a class method for a given selector.
ObjCSelectorExpr used for @selector in Objective-C.
Decl * getNonClosureAncestor()
Find the nearest non-closure ancestor of this context, i.e.
ImplicitParamDecl * getSelfDecl() const
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
static ObjCDictionaryLiteral * Create(const ASTContext &C, ArrayRef< ObjCDictionaryElement > VK, bool HasPackExpansions, QualType T, ObjCMethodDecl *method, SourceRange SR)
QualType NSNumberPointer
Pointer to NSNumber type (NSNumber *).
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
Defines the clang::TypeLoc interface and its subclasses.
bool isObjCIdType() const
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.
Expr * getSubExpr() const
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
bool hasRelatedResultType() const
Determine whether this method has a result type that is related to the message receiver's type...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isInstanceMethod() const
ObjCMessageKind getObjCMessageKind(Scope *S, IdentifierInfo *Name, SourceLocation NameLoc, bool IsSuper, bool HasTrailingDot, ParsedType &ReceiverType)
QualType getObjCIdType() const
Represents the Objective-CC id type.
An expression that sends a message to the given Objective-C object or class.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
CharSourceRange getInsertFromRange(SourceManager &SM) const
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
bool rewriteObjCRedundantCallWithLiteral(const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit)
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
bool CheckTollFreeBridgeStaticCast(QualType castType, Expr *castExpr, CastKind &Kind)
The result type of a method or function.
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.
QualType getObjCConstantStringInterface() const
Expr * getTrueExpr() const
QualType getWideCharType() const
Return the type of wide characters.
edit_iterator edit_end() const
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
void AddFixItHint(const FixItHint &Hint) const
ArrayRef< ParmVarDecl * > parameters() const
ExprResult ParseObjCProtocolExpression(IdentifierInfo *ProtocolName, SourceLocation AtLoc, SourceLocation ProtoLoc, SourceLocation LParenLoc, SourceLocation ProtoIdLoc, SourceLocation RParenLoc)
ParseObjCProtocolExpression - Build protocol expression for @protocol.
There is no lifetime qualification on this type.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor...
SelectorTable & Selectors
bool QIdProtocolsAdoptObjCObjectProtocols(QualType QT, ObjCInterfaceDecl *IDecl)
QIdProtocolsAdoptObjCObjectProtocols - Checks that protocols in QT's qualified-id protocol list adopt...
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Encodes a location in the source.
Sugar for parentheses used when specifying types.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
const TemplateArgument * iterator
Represents typeof(type), a GCC extension.
Interfaces are the core concept in Objective-C for object oriented design.
void checkRetainCycles(ObjCMessageExpr *msg)
checkRetainCycles - Check whether an Objective-C message send might create an obvious retain cycle...
bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr, bool Diagnose=true)
bool isValid() const
Return true if this is a valid SourceLocation object.
ExprResult ActOnClassMessage(Scope *S, ParsedType Receiver, Selector Sel, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args)
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 makeUnavailableInSystemHeader(SourceLocation loc, UnavailableAttr::ImplicitReason reason)
makeUnavailableInSystemHeader - There is an error in the current context.
IdentifierTable & getIdentifierTable()
bool ObjCWarnForNoDesignatedInitChain
This starts true for a method marked as designated initializer and will be set to false if there is a...
SmallVectorImpl< Edit >::const_iterator edit_iterator
QualType withConst() const
bool isObjCClassOrClassKindOfType() const
Whether the type is Objective-C 'Class' or a __kindof type of an Class type, e.g., __kindof Class <NSCopying>.
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
ExprResult BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements)
ExprResult DefaultLvalueConversion(Expr *E)
bool CheckObjCARCUnavailableWeakConversion(QualType castType, QualType ExprType)
bool isLiteral(TokenKind K)
Return true if this is a "literal" kind, like a numeric constant, string, etc.
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
Name lookup found an unresolvable value declaration and cannot yet complete.
The message is sent to 'super'.
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
bool isPropertyAccessor() const
ObjCProtocolExpr used for protocol expression in Objective-C.
Describes the kind of initialization being performed, along with location information for tokens rela...
ExprResult ActOnClassPropertyRefExpr(IdentifierInfo &receiverName, IdentifierInfo &propertyName, SourceLocation receiverNameLoc, SourceLocation propertyNameLoc)
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.
std::string getAsString() const
Derive the full selector name (e.g.
TypedefNameDecl * getDecl() const
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=NotForRedeclaration)
Find the protocol with the given name, if any.
SourceLocation getBegin() const
QualType getReturnType() const
const T * castAs() const
Member-template castAs<specific type>.
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.
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.
No entity found met the criteria.
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
bool ObjCIsDesignatedInit
True when this is a method marked as a designated initializer.
bool ObjCShouldCallSuper
A flag that is set when parsing a method that must call super's implementation, such as -dealloc...
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...
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
sema::FunctionScopeInfo * getCurFunction() 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
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
ExprResult ParseObjCSelectorExpression(Selector Sel, SourceLocation AtLoc, SourceLocation SelLoc, SourceLocation LParenLoc, SourceLocation RParenLoc, bool WarnMultipleSelectors)
ParseObjCSelectorExpression - Build selector expression for @selector.
MutableArrayRef< Expr * > MultiExprArg
QualType getType() const
Return the type wrapped by this type source info.
static Expr * maybeUndoReclaimObject(Expr *e)
Look for an ObjCReclaimReturnedObject cast and destroy it.
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;...
QualType getPointeeType() const
QualType getObjCSelType() const
Retrieve the type that corresponds to the predefined Objective-C 'SEL' type.
Represents a C11 generic selection.
void maybeExtendBlockObject(ExprResult &E)
Do an explicit extend of the given block pointer if we're in ARC.
bool isSuperClassOf(const ObjCInterfaceDecl *I) const
isSuperClassOf - Return true if this class is the specified class or is a super class of the specifie...
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
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.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
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)
CharSourceRange getFileRange(SourceManager &SM) const
bool AreMultipleMethodsInGlobalPool(Selector Sel, ObjCMethodDecl *BestMethod, SourceRange R, bool receiverIdOrClass, SmallVectorImpl< ObjCMethodDecl * > &Methods)
ExprResult BuildObjCStringLiteral(SourceLocation AtLoc, StringLiteral *S)
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)
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
static void addFixitForObjCARCConversion(Sema &S, DiagnosticBuilder &DiagB, Sema::CheckedConversionKind CCK, SourceLocation afterLParen, QualType castType, Expr *castExpr, Expr *realCast, const char *bridgeKeyword, const char *CFBridgeName)
bool ObjCIsSecondaryInit
True when this is an initializer method not marked as a designated initializer within a class that ha...
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
DeclarationName - The name of a declaration.
QualType getObjCProtoType() const
Retrieve the type of the Objective-C Protocol class.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
bool hasDefinition() const
Determine whether this protocol has a definition.
U cast(CodeGen::Address addr)
StringRef getString() const
Selector getSelector() const
bool ObjCWarnForNoInitDelegation
This starts true for a secondary initializer method and will be set to false if there is an invocatio...
detail::InMemoryDirectory::const_iterator E
ObjCMethodFamily getMethodFamily() const
Derive the conventional family of this method.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
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.
DeclClass * getCorrectionDeclAs() const
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
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.
ObjCMethodDecl * LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R, bool receiverIdOrClass=false)
LookupInstanceMethodInGlobalPool - Returns the method and warns if there are multiple signatures...
Name lookup found a single declaration that met the criteria.
bool isInObjcMethodScope() const
isInObjcMethodScope - Return true if this scope is, or is contained in, an Objective-C method body...
ObjCMethodDecl * getGetterMethodDecl() const
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).
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...
SourceManager & getSourceManager() const
const T * getAs() const
Member-template getAs<specific type>'.
CanQualType UnsignedLongTy
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface...
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...
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
Ignore parentheses and lvalue casts.
Base for LValueReferenceType and RValueReferenceType.
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.
void setExprNeedsCleanups(bool SideEffects)
ObjCPropertyDecl * getExplicitProperty() const
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, ArrayRef< Expr * > Args)
DiagnoseSentinelCalls - This routine checks whether a call or message-send is to a declaration with t...
SourceManager & getSourceManager()
static bool isIdentifierBodyChar(char c, const LangOptions &LangOpts)
Returns true if the given character could appear in an identifier.
static NSAPI::NSClassIdKindKind ClassKindFromLiteralKind(Sema::ObjCLiteralKind LiteralKind)
Maps ObjCLiteralKind to NSClassIdKindKind.
ObjCInterfaceDecl * getObjCInterfaceDecl(IdentifierInfo *&Id, SourceLocation IdLoc, bool TypoCorrection=false)
Look for an Objective-C class in the translation unit.
Reading or writing from this object requires a barrier call.
No particular method family.
const internal::VariadicDynCastAllOfMatcher< Stmt, CastExpr > castExpr
Matches any cast nodes of Clang's AST.
void setObjCNSStringType(QualType T)
An attributed type is a type to which a type attribute has been applied.
ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, FunctionDecl *FDecl)
DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but will create a trap if the resul...
Describes the sequence of initializations required to initialize a given object or reference with a s...
bool isCARCBridgableType() const
Determine whether the given type T is a "bridgeable" C type.
BoundNodesTreeBuilder *const Builder
ExprResult ActOnInstanceMessage(Scope *S, Expr *Receiver, Selector Sel, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args)
bool isObjCObjectPointerType() 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.
ArraySizeModifier getSizeModifier() const
static bool CheckObjCBridgeCFCast(Sema &S, QualType castType, Expr *castExpr, bool &HadTheAttribute, bool warn)
Selector RespondsToSelectorSel
will hold 'respondsToSelector:'
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
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)
LookupResultKind getResultKind() const
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]).
a linked list of methods with the same selector name but different signatures.
ObjCInterfaceDecl * getSuperClass() const
QualType getMessageSendResultType(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.
QualType getSendResultType() const
Determine the type of an expression that sends a message to this function.
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.
TranslationUnitDecl - The top declaration context.
static bool ValidateObjCLiteralInterfaceDecl(Sema &S, ObjCInterfaceDecl *Decl, SourceLocation Loc, Sema::ObjCLiteralKind LiteralKind)
Validates ObjCInterfaceDecl availability.
A reference to a declared variable, function, enum, etc.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
QualType getElementType() 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.
bool isObjCARCBridgableType() const
Determine whether the given type T is a "bridgable" Objective-C type, which is either an Objective-C ...
A trivial tuple used to represent a source range.
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
static void DiagnoseMismatchedSelectors(Sema &S, SourceLocation AtLoc, ObjCMethodDecl *Method, SourceLocation LParenLoc, SourceLocation RParenLoc, bool WarnMultipleSelectors)
NamedDecl - This represents a decl with a name.
ObjCMethodList * getNext() const
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 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...
ARCConversionResult CheckObjCARCConversion(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...
bool isConstQualified() const
Determine whether this type is const-qualified.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
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.
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
void setType(QualType newType)
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
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.
const ObjCObjectType * getSuperClassType() const
Retrieve the superclass type.
static void checkCocoaAPI(Sema &S, const ObjCMessageExpr *Msg)
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const ObjCObjectPointerType * getAsObjCQualifiedIdType() const
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
bool isPointerType() const