28 #include "llvm/ADT/SmallString.h"
30 using namespace clang;
32 using llvm::makeArrayRef;
36 unsigned NumStrings) {
46 if (NumStrings != 1) {
51 for (
unsigned i = 0; i != NumStrings; ++i) {
57 << S->getSourceRange();
71 assert(CAT &&
"String literal not of constant array type!");
76 false, StrTy, &StrLocs[0],
80 return BuildObjCStringLiteral(AtLocs[0], S);
85 if (CheckObjCString(S))
95 }
else if (getLangOpts().NoConstantCFStrings) {
97 std::string StringClass(getLangOpts().ObjCConstantStringClass);
99 if (StringClass.empty())
104 NamedDecl *IF = LookupSingleName(TUScope, NSIdent, AtLoc,
113 Diag(S->
getLocStart(), diag::err_no_nsconstant_string_class) << NSIdent
114 << S->getSourceRange();
119 NamedDecl *IF = LookupSingleName(TUScope, NSIdent, AtLoc,
154 S.
Diag(Loc, diag::err_undeclared_boxing_method) << Sel << Class->
getName();
161 S.
Diag(Loc, diag::err_objc_literal_method_sig)
178 S.
NSAPIObj->getNSNumberFactoryMethodKind(NumberType);
182 S.
Diag(Loc, diag::err_invalid_nsnumber_type)
204 S.
NSNumberDecl = dyn_cast_or_null<ObjCInterfaceDecl>(IF);
215 S.
Diag(Loc, diag::err_undeclared_nsnumber);
219 S.
Diag(Loc, diag::err_undeclared_nsnumber);
232 if (!Method && S.
getLangOpts().DebuggerObjCLiteral) {
269 switch (Char->getKind()) {
300 ExprResult ConvertedNumber = PerformCopyInitialization(Entity,
305 Number = ConvertedNumber.
get();
308 return MaybeBindToTemporary(
318 Inner = ActOnCXXBoolLiteral(ValueLoc, Value? tok::kw_true : tok::kw_false);
322 Inner = ActOnIntegerConstant(ValueLoc, Value? 1 : 0);
327 return BuildObjCNumericLiteral(AtLoc, Inner.
get());
334 bool ArrayLiteral =
false) {
342 Element = Result.
get();
355 return Seq.Perform(S, Entity, Kind, Element);
358 Expr *OrigElement = Element;
364 Element = Result.
get();
369 bool Recovered =
false;
372 if (isa<IntegerLiteral>(OrigElement) ||
373 isa<CharacterLiteral>(OrigElement) ||
374 isa<FloatingLiteral>(OrigElement) ||
375 isa<ObjCBoolLiteralExpr>(OrigElement) ||
376 isa<CXXBoolLiteralExpr>(OrigElement)) {
377 if (S.
NSAPIObj->getNSNumberFactoryMethodKind(OrigElement->
getType())) {
378 int Which = isa<CharacterLiteral>(OrigElement) ? 1
379 : (isa<CXXBoolLiteralExpr>(OrigElement) ||
380 isa<ObjCBoolLiteralExpr>(OrigElement)) ? 2
383 S.
Diag(OrigElement->getLocStart(), diag::err_box_literal_collection)
384 << Which << OrigElement->getSourceRange()
389 if (Result.isInvalid())
392 Element = Result.get();
397 else if (
StringLiteral *String = dyn_cast<StringLiteral>(OrigElement)) {
398 if (String->isAscii()) {
399 S.
Diag(OrigElement->getLocStart(), diag::err_box_literal_collection)
400 << 0 << OrigElement->getSourceRange()
404 if (Result.isInvalid())
407 Element = Result.get();
413 S.
Diag(Element->getLocStart(), diag::err_invalid_collection_element)
420 dyn_cast<ObjCStringLiteral>(OrigElement)) {
422 unsigned numConcat = SL->getNumConcatenated();
425 bool hasMacro =
false;
426 for (
unsigned i = 0; i < numConcat ; ++i)
427 if (SL->getStrTokenLoc(i).isMacroID()) {
432 S.
Diag(Element->getLocStart(),
433 diag::warn_concatenated_nsarray_literal)
444 Element->getLocStart(), Element);
456 ExprResult RValue = DefaultFunctionArrayLvalueConversion(ValueExpr);
460 ValueExpr = RValue.
get();
471 NSStringDecl = dyn_cast_or_null<ObjCInterfaceDecl>(Decl);
473 if (getLangOpts().DebuggerObjCLiteral) {
485 }
else if (!NSStringDecl->hasDefinition()) {
489 assert(NSStringDecl &&
"NSStringDecl should not be NULL");
494 if (!StringWithUTF8StringMethod) {
499 BoxingMethod = NSStringDecl->lookupClassMethod(stringWithUTF8String);
500 if (!BoxingMethod && getLangOpts().DebuggerObjCLiteral) {
505 NSStringPointer, ReturnTInfo, NSStringDecl,
524 stringWithUTF8String, BoxingMethod))
527 StringWithUTF8StringMethod = BoxingMethod;
530 BoxingMethod = StringWithUTF8StringMethod;
531 BoxedType = NSStringPointer;
533 }
else if (ValueType->isBuiltinType()) {
541 dyn_cast<CharacterLiteral>(ValueExpr->
IgnoreParens())) {
544 switch (Char->getKind()) {
562 CheckForIntOverflow(ValueExpr);
567 BoxedType = NSNumberPointer;
569 if (!ET->getDecl()->isComplete()) {
570 Diag(SR.
getBegin(), diag::err_objc_incomplete_boxed_expression_type)
571 << ValueType << ValueExpr->getSourceRange();
576 ET->getDecl()->getIntegerType());
577 BoxedType = NSNumberPointer;
578 }
else if (ValueType->isObjCBoxableRecordType()) {
587 NamedDecl *IF = LookupSingleName(TUScope, NSValueId,
589 NSValueDecl = dyn_cast_or_null<ObjCInterfaceDecl>(IF);
591 if (getLangOpts().DebuggerObjCLiteral) {
603 }
else if (!NSValueDecl->hasDefinition()) {
613 if (!ValueWithBytesObjCTypeMethod) {
621 BoxingMethod = NSValueDecl->lookupClassMethod(ValueWithBytesObjCType);
622 if (!BoxingMethod && getLangOpts().DebuggerObjCLiteral) {
629 ValueWithBytesObjCType,
650 Params.push_back(bytes);
660 Params.push_back(type);
667 ValueWithBytesObjCType, BoxingMethod))
670 ValueWithBytesObjCTypeMethod = BoxingMethod;
673 if (!ValueType.isTriviallyCopyableType(
Context)) {
675 diag::err_objc_non_trivially_copyable_boxed_expression_type)
676 << ValueType << ValueExpr->getSourceRange();
680 BoxingMethod = ValueWithBytesObjCTypeMethod;
681 BoxedType = NSValuePointer;
685 Diag(SR.
getBegin(), diag::err_objc_illegal_boxed_expression_type)
686 << ValueType << ValueExpr->getSourceRange();
690 DiagnoseUseOfDecl(BoxingMethod, SR.
getBegin());
693 if (ValueType->isObjCBoxableRecordType()) {
695 ConvertedValueExpr = PerformCopyInitialization(IE, ValueExpr->
getExprLoc(),
702 ConvertedValueExpr = PerformCopyInitialization(IE,
SourceLocation(),
706 if (ConvertedValueExpr.isInvalid())
708 ValueExpr = ConvertedValueExpr.get();
713 return MaybeBindToTemporary(BoxedExpr);
722 assert(!LangOpts.isSubscriptPointerArithmetic());
727 "base or index cannot have dependent type here");
734 IndexExpr = Result.
get();
737 Result = DefaultLvalueConversion(BaseExpr);
740 BaseExpr = Result.
get();
751 NamedDecl *IF = LookupSingleName(TUScope,
755 NSArrayDecl = dyn_cast_or_null<ObjCInterfaceDecl>(IF);
756 if (!NSArrayDecl && getLangOpts().DebuggerObjCLiteral)
771 if (!ArrayWithObjectsMethod) {
775 if (!Method && getLangOpts().DebuggerObjCLiteral) {
792 Params.push_back(objects);
800 Params.push_back(cnt);
815 diag::note_objc_literal_method_param)
822 if (!Method->
parameters()[1]->getType()->isIntegerType()) {
826 diag::note_objc_literal_method_param)
834 ArrayWithObjectsMethod = Method;
837 QualType ObjectsType = ArrayWithObjectsMethod->parameters()[0]->getType();
842 Expr **ElementsBuffer = Elements.data();
843 for (
unsigned I = 0, N = Elements.size(); I != N; ++I) {
850 ElementsBuffer[I] = Converted.
get();
857 return MaybeBindToTemporary(
859 ArrayWithObjectsMethod, SR));
864 unsigned NumElements) {
866 if (!NSDictionaryDecl) {
867 NamedDecl *IF = LookupSingleName(TUScope,
870 NSDictionaryDecl = dyn_cast_or_null<ObjCInterfaceDecl>(IF);
871 if (!NSDictionaryDecl && getLangOpts().DebuggerObjCLiteral)
878 if (!NSDictionaryDecl) {
887 if (!DictionaryWithObjectsMethod) {
888 Selector Sel = NSAPIObj->getNSDictionarySelector(
890 ObjCMethodDecl *Method = NSDictionaryDecl->lookupClassMethod(Sel);
891 if (!Method && getLangOpts().DebuggerObjCLiteral) {
910 Params.push_back(objects);
918 Params.push_back(keys);
926 Params.push_back(cnt);
942 diag::note_objc_literal_method_param)
956 if (QIDNSCopying.isNull()) {
970 if (!QIDNSCopying.isNull())
979 diag::note_objc_literal_method_param)
987 QualType CountType = Method->parameters()[2]->getType();
991 Diag(Method->parameters()[2]->getLocation(),
992 diag::note_objc_literal_method_param)
999 DictionaryWithObjectsMethod = Method;
1002 QualType ValuesT = DictionaryWithObjectsMethod->parameters()[0]->getType();
1004 QualType KeysT = DictionaryWithObjectsMethod->parameters()[1]->getType();
1009 bool HasPackExpansions =
false;
1010 for (
unsigned I = 0, N = NumElements; I != N; ++I) {
1023 Elements[I].Key = Key.
get();
1024 Elements[I].Value = Value.
get();
1026 if (Elements[I].EllipsisLoc.isInvalid())
1029 if (!Elements[I].Key->containsUnexpandedParameterPack() &&
1030 !Elements[I].Value->containsUnexpandedParameterPack()) {
1031 Diag(Elements[I].EllipsisLoc,
1032 diag::err_pack_expansion_without_parameter_packs)
1034 Elements[I].Value->getLocEnd());
1038 HasPackExpansions =
true;
1046 Context, makeArrayRef(Elements, NumElements), HasPackExpansions, Ty,
1047 DictionaryWithObjectsMethod, SR));
1061 diag::err_incomplete_type_objc_at_encode,
1068 if (!NotEncodedT.
isNull())
1069 Diag(AtLoc, diag::warn_incomplete_encoded_type)
1070 << EncodedType << NotEncodedT;
1107 bool Warned =
false;
1110 if (MatchingMethodDecl == Method ||
1118 S.
Diag(AtLoc, diag::warning_multiple_selectors)
1124 S.
Diag(MatchingMethodDecl->
getLocation(), diag::note_method_declared_at)
1135 bool WarnMultipleSelectors) {
1136 if (!WarnMultipleSelectors ||
1139 bool Warned =
false;
1140 for (Sema::GlobalMethodPool::iterator b = S.
MethodPool.begin(),
1145 Method, InstMethList))
1151 Method, ClsMethList) || Warned)
1161 bool WarnMultipleSelectors) {
1169 Selector MatchedSel = OM->getSelector();
1172 Diag(SelLoc, diag::warn_undeclared_selector_with_typo)
1173 << Sel << MatchedSel
1177 Diag(SelLoc, diag::warn_undeclared_selector) << Sel;
1180 WarnMultipleSelectors);
1196 Diag(AtLoc, diag::err_arc_illegal_selector) <<
1225 Diag(ProtoLoc, diag::err_undeclared_protocol) << ProtocolId;
1281 bool isClassMessage,
1282 bool isSuperMessage) {
1283 assert(Method &&
"Must have a method");
1318 if (isSuperMessage) {
1321 return transferNullability(
1340 return transferNullability(ReceiverType);
1345 bool isClassMessage,
1346 bool isSuperMessage) {
1358 unsigned receiverNullabilityIdx = 0;
1360 receiverNullabilityIdx = 1 + static_cast<unsigned>(*nullability);
1362 unsigned resultNullabilityIdx = 0;
1364 resultNullabilityIdx = 1 + static_cast<unsigned>(*nullability);
1368 static const uint8_t
None = 0;
1369 static const uint8_t
NonNull = 1;
1372 static const uint8_t nullabilityMap[4][4] = {
1380 unsigned newResultNullabilityIdx
1381 = nullabilityMap[receiverNullabilityIdx][resultNullabilityIdx];
1382 if (newResultNullabilityIdx == resultNullabilityIdx)
1388 if (
auto attributed = dyn_cast<AttributedType>(resultType.
getTypePtr())) {
1389 resultType = attributed->getModifiedType();
1396 if (newResultNullabilityIdx > 0) {
1401 resultType, resultType);
1420 dyn_cast<ObjCCategoryImplDecl>(impl)) {
1421 iface = catImpl->getCategoryDecl();
1423 iface = impl->getClassInterface();
1433 for (
unsigned i = 0, e = overrides.size(); i != e; ++i) {
1454 SourceRange range = overridden->getReturnTypeSourceRange();
1457 loc = overridden->getLocation();
1458 Diag(loc, diag::note_related_result_type_explicit)
1502 bool isClassMessage,
bool isSuperMessage,
1507 if (!SelectorLocs.empty() && SelectorLocs.front().isValid())
1508 SelLoc = SelectorLocs.front();
1514 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
1515 if (Args[i]->isTypeDependent())
1527 Args[i] = result.
get();
1532 DiagID = diag::err_arc_method_not_found;
1534 DiagID = isClassMessage ? diag::warn_class_method_not_found
1535 : diag::warn_inst_method_not_found;
1540 DiagID = diag::error_method_not_found_with_typo;
1542 DiagID = isClassMessage ? diag::warn_class_method_not_found_with_typo
1543 : diag::warn_instance_method_not_found_with_typo;
1545 SourceRange SelectorRange(SelectorLocs.front(), SelectorLocs.back());
1547 Diag(SelLoc, DiagID)
1548 << Sel<< isClassMessage << MatchedSel
1551 Diag(SelLoc, DiagID) << Sel<< isClassMessage << MatchedSel;
1554 Diag(SelLoc, DiagID)
1555 << Sel << isClassMessage <<
SourceRange(SelectorLocs.front(),
1556 SelectorLocs.back());
1561 Diag(ThisClass->getLocation(), diag::note_receiver_class_declared);
1563 if (ThisClass->lookupClassMethod(Sel))
1564 Diag(RecRange.
getBegin(),diag::note_receiver_expr_here)
1566 ThisClass->getNameAsString());
1592 if (Args.size() < NumNamedArgs) {
1593 Diag(SelLoc, diag::err_typecheck_call_too_few_args)
1594 << 2 << NumNamedArgs << static_cast<unsigned>(Args.size());
1602 bool IsError =
false;
1603 for (
unsigned i = 0; i < NumNamedArgs; i++) {
1605 if (Args[i]->isTypeDependent())
1608 Expr *argExpr = Args[i];
1611 assert(argExpr &&
"CheckMessageArgumentTypes(): missing expression");
1616 !param->
hasAttr<CFConsumedAttr>())
1627 Args[i] = argE.
get();
1645 diag::err_call_incomplete_argument, argExpr))
1663 Args[i] = arg.
get();
1670 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
1671 if (Args[i]->isTypeDependent())
1677 Args[i] = Arg.
get();
1681 if (Args.size() != NumNamedArgs) {
1682 Diag(Args[NumNamedArgs]->getLocStart(),
1683 diag::err_typecheck_call_too_many_args)
1684 << 2 << NumNamedArgs << static_cast<unsigned>(Args.size())
1687 Args.back()->getLocEnd());
1694 IsError |= CheckObjCMethodCall(
1695 Method, SelLoc, makeArrayRef(Args.data(), Args.size()));
1708 if (!method)
return false;
1711 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(receiver))
1723 if (
ObjCMethodDecl *method = iface->lookupMethod(sel, isInstance))
1728 if (
ObjCMethodDecl *method = iface->lookupPrivateMethod(sel, isInstance))
1733 for (
const auto *I : objType->
quals())
1747 for (
const auto *PROTO : OPT->
quals()) {
1748 if ((MD = PROTO->lookupMethod(Sel, Instance))) {
1768 Diag(MemberLoc, diag::err_invalid_property_name)
1776 : BaseExpr->getSourceRange();
1778 diag::err_property_not_found_forward_class,
1779 MemberName, BaseRange))
1797 for (
const auto *I : OPT->
quals())
1806 SuperLoc, SuperType);
1857 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>>(),
1889 << MemberName <<
QualType(OPT, 0));
1892 TypoResult, MemberLoc,
1893 SuperLoc, SuperType, Super);
1902 diag::err_property_not_as_forward_class,
1903 MemberName, BaseExpr))
1907 diag::err_ivar_access_using_property_syntax_suggest)
1908 << MemberName <<
QualType(OPT, 0) << Ivar->getDeclName()
1913 Diag(MemberLoc, diag::err_property_not_found)
1916 Diag(Setter->getLocation(), diag::note_getter_unavailable)
1917 << MemberName << BaseExpr->getSourceRange();
1937 if (receiverNamePtr->
isStr(
"super")) {
1939 if (
auto classDecl = CurMethod->getClassInterface()) {
1940 SuperType =
QualType(classDecl->getSuperClassType(), 0);
1941 if (CurMethod->isInstanceMethod()) {
1942 if (SuperType.
isNull()) {
1944 Diag(receiverNameLoc, diag::error_root_class_cannot_use_super)
1945 << CurMethod->getClassInterface()->getIdentifier();
1955 receiverNameLoc, T,
true);
1966 Diag(receiverNameLoc, diag::err_expected_either) << tok::identifier
2006 if (Getter || Setter) {
2015 propertyNameLoc, receiverNameLoc, IFace);
2017 return ExprError(
Diag(propertyNameLoc, diag::err_property_not_found)
2031 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
2043 bool HasTrailingDot,
2063 if (!Method->getClassInterface()) {
2069 if (Method->getClassInterface()->lookupInstanceVariable(Name,
2114 if (Corrected.isKeyword()) {
2118 PDiag(diag::err_unknown_receiver_suggest) << Name);
2125 PDiag(diag::err_unknown_receiver_suggest) << Name);
2147 Diag(SuperLoc, diag::err_invalid_receiver_to_message_super);
2153 Diag(SuperLoc, diag::error_no_super_class_message)
2159 if (SuperTy.isNull()) {
2161 Diag(SuperLoc, diag::error_root_class_cannot_use_super)
2177 LBracLoc, SelectorLocs, RBracLoc, Args);
2184 SuperLoc, Sel,
nullptr,
2185 LBracLoc, SelectorLocs, RBracLoc, Args);
2190 bool isSuperReceiver,
2196 if (!ReceiverType.
isNull())
2201 Sel, Method, Loc, Loc, Loc, Args,
2216 if (refactor(Msg,*S.
NSAPIObj, ECommit)) {
2225 switch (Edit.
Kind) {
2256 Expr **Args,
unsigned NumArgs) {
2258 bool Format =
false;
2272 if (!Format || NumArgs <= Idx)
2275 Expr *FormatExpr = Args[Idx];
2280 S.
Diag(FormatExpr->
getExprLoc(), diag::warn_objc_cdirective_format_string)
2330 Diag(Loc, diag::err_missing_open_square_message_send)
2335 if (!SelectorLocs.empty() && SelectorLocs.front().isValid())
2336 SelLoc = SelectorLocs.front();
2343 unsigned NumArgs = ArgsIn.size();
2344 Expr **Args = ArgsIn.data();
2345 assert(SuperLoc.
isInvalid() &&
"Message to super with dependent type");
2348 SelectorLocs,
nullptr, makeArrayRef(Args, NumArgs), RBracLoc,
2355 if (!ClassType || !(Class = ClassType->
getInterface())) {
2356 Diag(Loc, diag::err_invalid_receiver_class_message)
2360 assert(Class &&
"We don't know which class we're messaging?");
2371 ? diag::err_arc_receiver_forward_class
2372 : diag::warn_receiver_forward_class),
2396 unsigned NumArgs = ArgsIn.size();
2397 Expr **Args = ArgsIn.data();
2401 SuperLoc.
isValid(), LBracLoc, RBracLoc,
2408 diag::err_illegal_message_expr_incomplete_type))
2417 Diag(Loc, diag::warn_direct_initialize_call);
2425 Diag(Loc, diag::warn_direct_super_initialize_call);
2428 Diag(CurMeth->getLocation(), diag::note_method_declared_at)
2429 << CurMeth->getDeclName();
2441 ReceiverType, Sel, SelectorLocs,
2442 Method, makeArrayRef(Args, NumArgs),
2443 RBracLoc, isImplicit);
2446 ReceiverTypeInfo, Sel, SelectorLocs,
2447 Method, makeArrayRef(Args, NumArgs),
2448 RBracLoc, isImplicit);
2467 if (ReceiverType.
isNull())
2471 if (!ReceiverTypeInfo)
2476 nullptr, LBracLoc, SelectorLocs, RBracLoc,
2488 Sel, Method, Loc, Loc, Loc, Args,
2533 SuperLoc.
isValid()? SuperLoc : Receiver->getSourceRange();
2535 if (!SelectorLocs.empty() && SelectorLocs.front().isValid())
2536 SelLoc = SelectorLocs.front();
2541 Diag(Loc, diag::err_missing_open_square_message_send)
2556 Receiver = Result.
get();
2562 unsigned NumArgs = ArgsIn.size();
2563 Expr **Args = ArgsIn.data();
2564 assert(SuperLoc.
isInvalid() &&
"Message to super with dependent type");
2567 SelectorLocs,
nullptr, makeArrayRef(Args, NumArgs),
2568 RBracLoc, isImplicit);
2576 Receiver = Result.
get();
2577 ReceiverType = Receiver->
getType();
2590 Diag(Loc, diag::warn_bad_receiver_type)
2592 << Receiver->getSourceRange();
2604 ReceiverType = Receiver->
getType();
2608 diag::err_incomplete_receiver_type))
2613 Receiver = result.
get();
2614 ReceiverType = Receiver->
getType();
2643 Method = BestMethod;
2646 receiverIsIdLike)) {
2665 Diag(SelLoc, diag::warn_instance_method_on_class_found)
2675 Method = ClassDecl->lookupClassMethod(Sel);
2678 Method = ClassDecl->lookupPrivateClassMethod(Sel);
2696 if (
ID->getSuperClass())
2697 Diag(SelLoc, diag::warn_root_inst_method_not_found)
2704 Method = BestMethod;
2725 ClassDecl = OCIType->getInterfaceDecl();
2732 ? diag::err_arc_receiver_forward_instance
2733 : diag::warn_receiver_forward_instance,
2734 Receiver? Receiver->getSourceRange()
2739 forwardClass = OCIType->getInterfaceDecl();
2740 Diag(Receiver ? Receiver->getLocStart()
2741 : SuperLoc, diag::note_receiver_is_id);
2756 Diag(SelLoc, diag::err_arc_may_not_respond)
2757 << OCIType->getPointeeType() << Sel << RecRange
2758 <<
SourceRange(SelectorLocs.front(), SelectorLocs.back());
2762 if (!Method && (!Receiver || !
isSelfExpr(Receiver))) {
2766 if (OCIType->qual_empty()) {
2770 if (
auto BestMethod =
2772 Method = BestMethod;
2777 if (Method && !forwardClass)
2778 Diag(SelLoc, diag::warn_maynot_respond)
2779 << OCIType->getInterfaceDecl()->getIdentifier()
2788 Diag(Loc, diag::err_bad_receiver_type)
2789 << ReceiverType << Receiver->getSourceRange();
2799 if (DIFunctionScopeInfo &&
2802 bool isDesignatedInitChain =
false;
2809 if (!
ID->declaresOrInheritsDesignatedInitializers() ||
2810 ID->isDesignatedInitializer(Sel)) {
2811 isDesignatedInitChain =
true;
2817 if (!isDesignatedInitChain) {
2821 assert(isDesignated && InitMethod);
2824 diag::warn_objc_designated_init_non_designated_init_call :
2825 diag::warn_objc_designated_init_non_super_designated_init_call);
2827 diag::note_objc_designated_init_marked_here);
2831 if (DIFunctionScopeInfo &&
2835 Diag(SelLoc, diag::warn_objc_secondary_init_super_init_call);
2842 unsigned NumArgs = ArgsIn.size();
2843 Expr **Args = ArgsIn.data();
2849 Sel, SelectorLocs, Method,
2850 ClassMessage, SuperLoc.
isValid(),
2851 LBracLoc, RBracLoc, RecRange, ReturnType, VK))
2856 diag::err_illegal_message_expr_incomplete_type))
2884 Diag(SelLoc, diag::err_arc_illegal_explicit_message)
2889 if (Method && NumArgs >= 1) {
2891 Selector ArgSel = SelExp->getSelector();
2894 SelExp->getSourceRange());
2898 SelExp->getSourceRange());
2901 switch (SelFamily) {
2909 if (!SelMethod->
hasAttr<NSReturnsNotRetainedAttr>()) {
2912 diag::err_arc_perform_selector_retains);
2919 if (SelMethod->
hasAttr<NSReturnsRetainedAttr>()) {
2922 diag::err_arc_perform_selector_retains);
2931 Diag(SelLoc, diag::warn_arc_perform_selector_leaks);
2932 Diag(Args[0]->getExprLoc(), diag::note_used_here);
2946 ReceiverType, Sel, SelectorLocs, Method,
2947 makeArrayRef(Args, NumArgs), RBracLoc,
2951 Receiver, Sel, SelectorLocs, Method,
2952 makeArrayRef(Args, NumArgs), RBracLoc,
2977 if (!isImplicit && Method) {
2990 CheckObjCCircularContainer(Result);
3020 if (isa<ParenListExpr>(Receiver)) {
3023 Receiver = Result.
get();
3035 nullptr, LBracLoc, SelectorLocs,
3067 bool isIndirect =
false;
3086 type =
QualType(array->getElementType()->getBaseElementTypeUnsafe(), 0);
3121 if (left == right)
return left;
3122 if (left == ACC_bottom)
return right;
3123 if (right == ACC_bottom)
return left;
3129 class ARCCastChecker :
public StmtVisitor<ARCCastChecker, ACCResult> {
3145 : Context(Context), SourceClass(source), TargetClass(target),
3146 Diagnose(diagnose) {}
3199 return Visit(e->
getRHS());
3205 if (left == ACC_invalid)
return ACC_invalid;
3235 return ACC_plusZero;
3245 if (
ACCResult result = checkCallToFunction(fn))
3248 return super::VisitCallExpr(e);
3260 if (fn->
hasAttr<CFReturnsNotRetainedAttr>())
3261 return ACC_plusZero;
3266 if (fn->
hasAttr<CFReturnsRetainedAttr>())
3267 return Diagnose ? ACC_plusOne
3272 if (builtinID == Builtin::BI__builtin___CFStringMakeConstantString)
3276 if (!fn->
hasAttr<CFAuditedTransferAttr>())
3281 return Diagnose ? ACC_plusOne
3284 return ACC_plusZero;
3297 return checkCallToMethod(method);
3301 if (!method)
return ACC_invalid;
3310 if (method->
hasAttr<CFReturnsNotRetainedAttr>())
3311 return ACC_plusZero;
3315 if (method->
hasAttr<CFReturnsRetainedAttr>())
3327 return ACC_plusZero;
3348 const char *bridgeKeyword,
3349 const char *CFBridgeName) {
3364 NCE->getAngleBrackets().getEnd());
3368 char PrevChar = *SM.
getCharacterData(range.getBegin().getLocWithOffset(-1));
3372 BridgeCall += CFBridgeName;
3379 castedE = CCE->getSubExpr();
3390 BridgeCall += CFBridgeName;
3392 if (isa<ParenExpr>(castedE)) {
3410 std::string castCode =
"(";
3411 castCode += bridgeKeyword;
3415 NCE->getAngleBrackets().getEnd());
3419 std::string castCode =
"(";
3420 castCode += bridgeKeyword;
3425 if (isa<ParenExpr>(castedE)) {
3439 template <
typename T>
3447 return RD->getAttr<T>();
3455 TDNDecl = TD->getDecl();
3456 if (ObjCBridgeRelatedAttr *ObjCBAttr =
3457 getObjCBridgeAttr<ObjCBridgeRelatedAttr>(TD))
3474 "converts between Objective-C and C pointers in -fobjc-arc"))
3485 unsigned srcKind = 0;
3507 S.
Diag(loc, diag::err_arc_cast_requires_bridge)
3514 << castExpr->getSourceRange();
3517 ARCCastChecker(S.
Context, exprACTC, castACTC,
true).Visit(castExpr);
3518 assert(CreateRule != ACC_bottom &&
"This cast should already be accepted.");
3519 if (CreateRule != ACC_plusOne)
3523 : S.
Diag(noteLoc, diag::note_arc_cstyle_bridge);
3526 castType, castExpr, realCast,
"__bridge ",
3529 if (CreateRule != ACC_plusZero)
3533 S.
Diag(noteLoc, diag::note_arc_cstyle_bridge_transfer) << castExprType :
3535 diag::note_arc_bridge_transfer)
3536 << castExprType << br;
3539 castType, castExpr, realCast,
"__bridge_transfer ",
3540 br ?
"CFBridgingRelease" :
nullptr);
3549 S.
Diag(loc, diag::err_arc_cast_requires_bridge)
3556 << castExpr->getSourceRange();
3558 ARCCastChecker(S.
Context, exprACTC, castACTC,
true).Visit(castExpr);
3559 assert(CreateRule != ACC_bottom &&
"This cast should already be accepted.");
3560 if (CreateRule != ACC_plusOne)
3564 : S.
Diag(noteLoc, diag::note_arc_cstyle_bridge);
3566 castType, castExpr, realCast,
"__bridge ",
3569 if (CreateRule != ACC_plusZero)
3573 S.
Diag(noteLoc, diag::note_arc_cstyle_bridge_retained) << castType :
3575 diag::note_arc_bridge_retained)
3579 castType, castExpr, realCast,
"__bridge_retained ",
3580 br ?
"CFBridgingRetain" :
nullptr);
3586 S.
Diag(loc, diag::err_arc_mismatched_cast)
3588 << srcKind << castExprType << castType
3589 << castRange << castExpr->getSourceRange();
3592 template <
typename TB>
3594 bool &HadTheAttribute,
bool warn) {
3596 HadTheAttribute =
false;
3599 if (TB *ObjCBAttr = getObjCBridgeAttr<TB>(TD)) {
3601 HadTheAttribute =
true;
3602 if (Parm->isStr(
"id"))
3611 if (Target && isa<ObjCInterfaceDecl>(Target)) {
3616 = InterfacePointerType->getObjectType()->getInterface();
3617 if ((CastClass == ExprClass) ||
3621 S.
Diag(castExpr->getLocStart(), diag::warn_objc_invalid_bridge)
3626 castType, ExprClass)))
3633 S.
Diag(castExpr->getLocStart(), diag::warn_objc_invalid_bridge)
3634 << T << Target->
getName() << castType;
3642 S.
Diag(castExpr->getLocStart(), diag::err_objc_cf_bridged_not_interface)
3643 << castExpr->
getType() << Parm;
3657 template <
typename TB>
3659 bool &HadTheAttribute,
bool warn) {
3661 HadTheAttribute =
false;
3664 if (TB *ObjCBAttr = getObjCBridgeAttr<TB>(TD)) {
3666 HadTheAttribute =
true;
3667 if (Parm->isStr(
"id"))
3676 if (Target && isa<ObjCInterfaceDecl>(Target)) {
3681 = InterfacePointerType->getObjectType()->getInterface();
3682 if ((CastClass == ExprClass) ||
3686 S.
Diag(castExpr->getLocStart(), diag::warn_objc_invalid_bridge_to_cf)
3693 castExpr->
getType(), CastClass)))
3700 S.
Diag(castExpr->getLocStart(), diag::warn_objc_invalid_bridge_to_cf)
3701 << castExpr->
getType() << castType;
3709 S.
Diag(castExpr->getLocStart(), diag::err_objc_ns_bridged_invalid_cfobject)
3710 << castExpr->
getType() << castType;
3730 bool HasObjCBridgeAttr;
3731 bool ObjCBridgeAttrWillNotWarn =
3732 CheckObjCBridgeNSCast<ObjCBridgeAttr>(*
this, castType,
castExpr, HasObjCBridgeAttr,
3734 if (ObjCBridgeAttrWillNotWarn && HasObjCBridgeAttr)
3736 bool HasObjCBridgeMutableAttr;
3737 bool ObjCBridgeMutableAttrWillNotWarn =
3738 CheckObjCBridgeNSCast<ObjCBridgeMutableAttr>(*
this, castType,
castExpr,
3739 HasObjCBridgeMutableAttr,
false);
3740 if (ObjCBridgeMutableAttrWillNotWarn && HasObjCBridgeMutableAttr)
3743 if (HasObjCBridgeAttr)
3744 CheckObjCBridgeNSCast<ObjCBridgeAttr>(*
this, castType,
castExpr, HasObjCBridgeAttr,
3746 else if (HasObjCBridgeMutableAttr)
3747 CheckObjCBridgeNSCast<ObjCBridgeMutableAttr>(*
this, castType,
castExpr,
3748 HasObjCBridgeMutableAttr,
true);
3751 bool HasObjCBridgeAttr;
3752 bool ObjCBridgeAttrWillNotWarn =
3753 CheckObjCBridgeCFCast<ObjCBridgeAttr>(*
this, castType,
castExpr, HasObjCBridgeAttr,
3755 if (ObjCBridgeAttrWillNotWarn && HasObjCBridgeAttr)
3757 bool HasObjCBridgeMutableAttr;
3758 bool ObjCBridgeMutableAttrWillNotWarn =
3759 CheckObjCBridgeCFCast<ObjCBridgeMutableAttr>(*
this, castType,
castExpr,
3760 HasObjCBridgeMutableAttr,
false);
3761 if (ObjCBridgeMutableAttrWillNotWarn && HasObjCBridgeMutableAttr)
3764 if (HasObjCBridgeAttr)
3765 CheckObjCBridgeCFCast<ObjCBridgeAttr>(*
this, castType,
castExpr, HasObjCBridgeAttr,
3767 else if (HasObjCBridgeMutableAttr)
3768 CheckObjCBridgeCFCast<ObjCBridgeMutableAttr>(*
this, castType,
castExpr,
3769 HasObjCBridgeMutableAttr,
true);
3776 if (PRE->isExplicitProperty()) {
3778 SrcType = PDecl->getType();
3780 else if (PRE->isImplicitProperty()) {
3782 SrcType = Getter->getReturnType();
3820 QualType T = CfToNs ? SrcType : DestType;
3835 Diag(Loc, diag::err_objc_bridged_related_invalid_class) << RCId
3836 << SrcType << DestType;
3841 if (Target && isa<ObjCInterfaceDecl>(Target))
3842 RelatedClass = cast<ObjCInterfaceDecl>(Target);
3844 Diag(Loc, diag::err_objc_bridged_related_invalid_class_name) << RCId
3845 << SrcType << DestType;
3853 if (CfToNs && CMId) {
3857 Diag(Loc, diag::err_objc_bridged_related_known_method)
3858 << SrcType << DestType << Sel <<
false;
3865 if (!CfToNs && IMId) {
3867 InstanceMethod = RelatedClass->
lookupMethod(Sel,
true);
3868 if (!InstanceMethod) {
3869 Diag(Loc, diag::err_objc_bridged_related_known_method)
3870 << SrcType << DestType << Sel <<
true;
3886 if (!CfToNs && !NsToCf)
3894 ClassMethod, InstanceMethod, TDNDecl, CfToNs))
3900 std::string ExpressionString =
"[";
3902 ExpressionString +=
" ";
3906 Diag(Loc, diag::err_objc_bridged_related_known_method)
3907 << SrcType << DestType << ClassMethod->
getSelector() <<
false
3916 Expr *args[] = { SrcExpr };
3921 SrcExpr = msg.
get();
3927 if (InstanceMethod) {
3928 std::string ExpressionString;
3933 ExpressionString =
".";
3934 ExpressionString += PDecl->getNameAsString();
3935 Diag(Loc, diag::err_objc_bridged_related_known_method)
3936 << SrcType << DestType << InstanceMethod->
getSelector() <<
true
3939 if (ExpressionString.empty()) {
3941 ExpressionString =
" ";
3943 ExpressionString +=
"]";
3945 Diag(Loc, diag::err_objc_bridged_related_known_method)
3946 << SrcType << DestType << InstanceMethod->
getSelector() <<
true
3957 InstanceMethod,
None);
3958 SrcExpr = msg.get();
3968 bool DiagnoseCFAudited,
3980 if (exprACTC == castACTC) {
3985 (castType != castExprType)) {
3991 if (
const ParenType *PT = dyn_cast<ParenType>(DT))
3992 QDT = PT->desugar();
3993 else if (
const TypeOfType *TP = dyn_cast<TypeOfType>(DT))
3994 QDT = TP->desugar();
3995 else if (
const AttributedType *AT = dyn_cast<AttributedType>(DT))
3996 QDT = AT->desugar();
3997 if (QDT != castType &&
4002 Diag(loc, diag::err_arc_nolifetime_behavior);
4024 switch (ARCCastChecker(
Context, exprACTC, castACTC,
false).Visit(castExpr)) {
4066 castExpr, castExpr, exprACTC, CCK);
4082 castRange =
SourceRange(cast->getLParenLoc(), cast->getRParenLoc());
4083 castType = cast->getTypeAsWritten();
4085 }
else if (
ExplicitCastExpr *cast = dyn_cast<ExplicitCastExpr>(realCast)) {
4086 castRange = cast->getTypeInfoAsWritten()->getTypeLoc().getSourceRange();
4087 castType = cast->getTypeAsWritten();
4090 castType = cast->getType();
4109 if (
ParenExpr *pe = dyn_cast<ParenExpr>(e)) {
4112 }
else if (
UnaryOperator *uo = dyn_cast<UnaryOperator>(e)) {
4116 sub->getValueKind(), sub->getObjectKind(),
4117 uo->getOperatorLoc());
4119 assert(!gse->isResultDependent());
4121 unsigned n = gse->getNumAssocs();
4124 for (
unsigned i = 0; i != n; ++i) {
4125 subTypes[i] = gse->getAssocTypeSourceInfo(i);
4126 Expr *sub = gse->getAssocExpr(i);
4127 if (i == gse->getResultIndex())
4133 gse->getControllingExpr(),
4135 gse->getDefaultLoc(),
4136 gse->getRParenLoc(),
4137 gse->containsUnexpandedParameterPack(),
4138 gse->getResultIndex());
4140 assert(isa<ImplicitCastExpr>(e) &&
"bad form of unbridged cast!");
4141 return cast<ImplicitCastExpr>(e)->getSubExpr();
4151 if (isa<ObjCObjectPointerType>(canCastType) &&
4157 return !ObjI->isArcWeakrefUnavailable();
4171 return ice->getSubExpr();
4183 SubExpr = SubResult.
get();
4190 bool MustConsume =
false;
4204 Diag(BridgeKeywordLoc, diag::err_arc_bridge_cast_wrong_kind)
4209 << SubExpr->getSourceRange()
4211 Diag(BridgeKeywordLoc, diag::note_arc_bridge)
4213 Diag(BridgeKeywordLoc, diag::note_arc_bridge_transfer)
4216 br ?
"CFBridgingRelease "
4217 :
"__bridge_transfer ");
4247 Diag(BridgeKeywordLoc, diag::err_arc_bridge_cast_wrong_kind)
4252 << SubExpr->getSourceRange()
4255 Diag(BridgeKeywordLoc, diag::note_arc_bridge)
4257 Diag(BridgeKeywordLoc, diag::note_arc_bridge_retained)
4260 br ?
"CFBridgingRetain " :
"__bridge_retained");
4267 Diag(LParenLoc, diag::err_arc_bridge_cast_incompatible)
4268 << FromType << T << Kind
4269 << SubExpr->getSourceRange()
ObjCMethodDecl * LookupMethodInQualifiedType(Selector Sel, const ObjCObjectPointerType *OPT, bool IsInstance)
void setMethodParams(ASTContext &C, ArrayRef< ParmVarDecl * > Params, ArrayRef< SourceLocation > SelLocs=llvm::None)
Sets the method's parameters and selector source locations. If the method is implicit (not coming fro...
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
getDecl - Get the declaration of this interface.
CastKind getCastKind() const
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
Smart pointer class that efficiently represents Objective-C method names.
SelectorTable & getSelectorTable()
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.
CompoundStmt * getSubStmt()
IdentifierInfo * getIdentifier() const
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()
addConst - add the specified 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.
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)
QualType substObjCTypeArgs(ASTContext &ctx, ArrayRef< QualType > typeArgs, ObjCSubstitutionContext context) const
ExprResult DefaultArgumentPromotion(Expr *E)
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
ObjCStringFormatFamily getStringFormatFamily() const
bool isObjCQualifiedClassType() const
ExprResult BuildObjCDictionaryLiteral(SourceRange SR, ObjCDictionaryElement *Elements, unsigned NumElements)
static void RemoveSelectorFromWarningCache(Sema &S, Expr *Arg)
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...
static ExprValueKind getValueKindForType(QualType T)
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)
const ObjCObjectPointerType * getAsObjCQualifiedClassType() const
[ARC] Consumes a retainable object pointer that has just been produced, e.g. as the return value of a...
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.
bool isExplicitProperty() const
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
DiagnosticsEngine & Diags
ObjCMethodDecl * tryCaptureObjCSelf(SourceLocation Loc)
Try to capture an implicit reference to 'self'.
ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs, Expr **Strings, unsigned NumStrings)
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
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
QualType withConst() const
Retrieves a version of this type with const applied. Note that this does not always yield a canonical...
Expr * IgnoreImpCasts() LLVM_READONLY
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
The message is a class message, and the identifier is a type name.
ExprResult UsualUnaryConversions(Expr *E)
Selector getUnarySelector(IdentifierInfo *ID)
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...
OpaquePtr< QualType > ParsedType
An element in an Objective-C dictionary literal.
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)
ExprResult BuildClassMessageImplicit(QualType ReceiverType, bool isSuperReceiver, SourceLocation Loc, Selector Sel, ObjCMethodDecl *Method, MultiExprArg Args)
ExprResult PerformContextuallyConvertToObjCPointer(Expr *From)
ExprResult ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals.
static ObjCBridgeRelatedAttr * ObjCBridgeRelatedAttrFromType(QualType T, TypedefNameDecl *&TDNDecl)
bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr)
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)
ObjCMethodDecl * LookupFactoryMethodInGlobalPool(Selector Sel, SourceRange R, bool receiverIdOrClass=false)
StorageClass getStorageClass() const
Returns the storage class as written in the source. For the computed linkage of symbol, see getLinkage.
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)
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)
ObjCMethodDecl * getCurMethodDecl()
ExprResult BuildObjCNumericLiteral(SourceLocation AtLoc, Expr *Number)
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 &))
GlobalMethodPool MethodPool
A builtin binary operation expression such as "x + y" or "x <= y".
Selector getSelector() const
CanQualType PseudoObjectTy
ObjCInterfaceDecl * getInterface() const
CheckedConversionKind
The kind of conversion being performed.
std::string getNameAsString() const
bool isDesignatedInitializerForTheInterface(const ObjCMethodDecl **InitMethod=nullptr) const
const ObjCObjectType * getAsObjCInterfaceType() const
Expr * IgnoreParenCasts() LLVM_READONLY
Values of this type can never be null.
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
const ObjCMethodDecl * SelectorsForTypoCorrection(Selector Sel, QualType ObjectType=QualType())
static ObjCSubscriptRefExpr * Create(const ASTContext &C, Expr *base, Expr *key, QualType T, ObjCMethodDecl *getMethod, ObjCMethodDecl *setMethod, SourceLocation RB)
void CheckTollFreeBridgeCast(QualType castType, Expr *castExpr)
Represents an Objective-C protocol declaration.
ObjCInterfaceDecl * NSNumberDecl
The declaration of the Objective-C NSNumber class.
Represents an ObjC class declaration.
Bridging via __bridge_transfer, which transfers ownership of an Objective-C pointer into ARC...
ObjCMethodDecl * getMethod() const
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)
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID)
Lookup a property by name in the specified DeclContext.
const ArrayType * getAsArrayTypeUnsafe() const
static bool isAnyRetainable(ARCConversionTypeClass ACTC)
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
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
SourceLocation getLocStart() const LLVM_READONLY
Qualifiers::ObjCLifetime getObjCLifetime() const
getObjCLifetime - 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 ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
void recordUseOfWeak(const ExprT *E, bool IsRead=true)
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)
sema::FunctionScopeInfo * getEnclosingFunction() const
ID
Defines the set of possible language-specific address spaces.
QualType getPointeeType() const
bool isUnarySelector() const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
const ObjCMethodDecl * getMethodDecl() const
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)
unsigned getNumArgs() const
static Kind getNullabilityAttrKind(NullabilityKind 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. Asserts that one was found.
bool CheckObjCBridgeRelatedConversions(SourceLocation Loc, QualType DestType, QualType SrcType, Expr *&SrcExpr)
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.
DeclContext * getDeclContext()
ObjCSelectorExpr used for @selector in Objective-C.
Decl * getNonClosureAncestor()
Find the nearest non-closure ancestor of this context, i.e. the innermost semantic parent of this con...
ImplicitParamDecl * getSelfDecl() const
ExprResult CheckPlaceholderExpr(Expr *E)
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
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)
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
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.
CharSourceRange getInsertFromRange(SourceManager &SM) const
DeclarationName getDeclName() const
bool rewriteObjCRedundantCallWithLiteral(const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit)
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. Return null if the results were absent...
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E)
QualType getObjCConstantStringInterface() const
Expr * getTrueExpr() const
QualType getWideCharType() const
Return the type of wide characters. In C++, this returns the unique wchar_t type. In C99...
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.
SourceLocation getLocStart() const LLVM_READONLY
There is no lifetime qualification on this type.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
ExprResult MaybeBindToTemporary(Expr *E)
SelectorTable & Selectors
bool QIdProtocolsAdoptObjCObjectProtocols(QualType QT, ObjCInterfaceDecl *IDecl)
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
const Type * getTypePtr() const
TypeOfType (GCC extension).
void checkRetainCycles(ObjCMessageExpr *msg)
Check a message send to see if it's likely to cause a retain cycle.
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.
IdentifierTable & getIdentifierTable()
bool ObjCWarnForNoDesignatedInitChain
SmallVectorImpl< Edit >::const_iterator edit_iterator
QualType withConst() const
bool isObjCClassOrClassKindOfType() const
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.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
Name lookup found an unresolvable value declaration and cannot yet complete. This only happens in C++...
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
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. "foo:bar:") and return it as an std::string.
TypedefNameDecl * getDecl() const
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=NotForRedeclaration)
Find the protocol with the given name, if any.
SourceLocation getBegin() const
QualType getReturnType() const
bool isTypeDependent() const
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.
static QualType getBaseMessageSendResultType(Sema &S, QualType ReceiverType, ObjCMethodDecl *Method, bool isClassMessage, bool isSuperMessage)
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
sema::FunctionScopeInfo * getCurFunction() const
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
bool AreMultipleMethodsInGlobalPool(Selector Sel, ObjCMethodDecl *BestMethod, SourceRange R, bool receiverIdOrClass)
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
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
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
ExprResult BuildObjCStringLiteral(SourceLocation AtLoc, StringLiteral *S)
ObjCMethodDecl * NSNumberLiteralMethods[NSAPI::NumNSNumberLiteralMethods]
The Objective-C NSNumber methods used to create NSNumber literals.
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)
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 isInvalidDecl() const
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
const ObjCInterfaceType * getInterfaceType() const
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
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.
StringRef getString() const
Selector getSelector() const
bool ObjCWarnForNoInitDelegation
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 ...
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
[ARC] Reclaim a retainable object pointer object that may have been produced and autoreleased as part...
Expr * IgnoreParenImpCasts() LLVM_READONLY
QualType getPointeeType() const
QualType getNonReferenceType() 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.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
ObjCMethodDecl * LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R, bool receiverIdOrClass=false)
Name lookup found a single declaration that met the criteria. getFoundDecl() will return this declara...
bool isInObjcMethodScope() const
ObjCMethodDecl * getGetterMethodDecl() const
ObjCMethodDecl * lookupMethod(Selector Sel, bool isInstance, bool shallowCategoryLookup=false, bool followSuper=true, const ObjCCategoryDecl *C=nullptr) const
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
CanQualType UnsignedLongTy
ObjCInterfaceDecl * getInterfaceDecl() const
Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV)
Can create any sort of selector.
[ARC] Produces a retainable object pointer so that it may be consumed, e.g. by being passed to a cons...
ExprResult BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr)
ExprResult HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, Expr *BaseExpr, SourceLocation OpLoc, DeclarationName MemberName, SourceLocation MemberLoc, SourceLocation SuperLoc, QualType SuperType, bool Super)
Expr * IgnoreParenLValueCasts() LLVM_READONLY
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId) const
bool checkObjCBridgeRelatedComponents(SourceLocation Loc, QualType DestType, QualType SrcType, ObjCInterfaceDecl *&RelatedClass, ObjCMethodDecl *&ClassMethod, ObjCMethodDecl *&InstanceMethod, TypedefNameDecl *&TDNDecl, bool CfToNs)
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.
ObjCPropertyDecl * getExplicitProperty() const
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, ArrayRef< Expr * > Args)
SourceManager & getSourceManager()
static bool isIdentifierBodyChar(char c, const LangOptions &LangOpts)
Returns true if the given character could appear in an identifier.
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)
ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, FunctionDecl *FDecl)
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
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)
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
The parameter type of a method or function.
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...
ARCConversionResult CheckObjCARCConversion(SourceRange castRange, QualType castType, Expr *&op, CheckedConversionKind CCK, bool DiagnoseCFAudited=false, BinaryOperatorKind Opc=BO_PtrMemD)
Checks for invalid conversions and casts between retainable pointers and other pointer kinds...
static T * getObjCBridgeAttr(const TypedefType *TD)
LookupResultKind getResultKind() const
ExprResult BuildInstanceMessageImplicit(Expr *Receiver, QualType ReceiverType, SourceLocation Loc, Selector Sel, ObjCMethodDecl *Method, MultiExprArg Args)
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. This replaces the type par...
void EmitRelatedResultTypeNote(const Expr *E)
If the given expression involves a message send to a method with a related result type...
bool makeUnavailableInSystemHeader(SourceLocation loc, StringRef message)
Abstract class common to all of the C++ "named"/"keyword" casts.
A reference to a declared variable, function, enum, etc. [C99 6.5.1p2].
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()
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.
SourceLocation getLocation() const
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)
ObjCMethodList * getNext() const
ExprResult BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr, Expr *IndexExpr, ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod)
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
bool isConstQualified() const
Determine whether this type is const-qualified.
bool isNull() const
isNull - 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
bool isIntegralType(ASTContext &Ctx) const
Determine whether this type is an integral type.
This class handles loading and caching of source files into memory.
const ObjCObjectType * getSuperClassType() const
Retrieve the superclass type.
static void checkCocoaAPI(Sema &S, const ObjCMessageExpr *Msg)
bool isIntegerType() const
const ObjCObjectPointerType * getAsObjCQualifiedIdType() const
Expr * IgnoreParens() LLVM_READONLY
bool isPointerType() const