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);
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
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)
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;
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
441 if (Result.isInvalid())
444 Element = Result.get();
449 else if (
StringLiteral *String = dyn_cast<StringLiteral>(OrigElement)) {
450 if (String->isAscii()) {
456 if (Result.isInvalid())
459 Element = Result.get();
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()) {
485 diag::warn_concatenated_nsarray_literal)
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()) {
602 BoxedType = NSNumberPointer;
604 if (!ET->getDecl()->isComplete()) {
605 Diag(Loc, diag::err_objc_incomplete_boxed_expression_type)
611 ET->getDecl()->getIntegerType());
612 BoxedType = NSNumberPointer;
613 }
else if (ValueType->isObjCBoxableRecordType()) {
631 if (!ValueWithBytesObjCTypeMethod) {
639 BoxingMethod = NSValueDecl->lookupClassMethod(ValueWithBytesObjCType);
640 if (!BoxingMethod && getLangOpts().DebuggerObjCLiteral) {
647 ValueWithBytesObjCType,
668 Params.push_back(bytes);
678 Params.push_back(type);
685 ValueWithBytesObjCType, BoxingMethod))
688 ValueWithBytesObjCTypeMethod = BoxingMethod;
691 if (!ValueType.isTriviallyCopyableType(
Context)) {
692 Diag(Loc, diag::err_objc_non_trivially_copyable_boxed_expression_type)
697 BoxingMethod = ValueWithBytesObjCTypeMethod;
698 BoxedType = NSValuePointer;
702 Diag(Loc, diag::err_objc_illegal_boxed_expression_type)
707 DiagnoseUseOfDecl(BoxingMethod, Loc);
710 if (ValueType->isObjCBoxableRecordType()) {
712 ConvertedValueExpr = PerformCopyInitialization(IE, ValueExpr->
getExprLoc(),
719 ConvertedValueExpr = PerformCopyInitialization(IE,
SourceLocation(),
725 ValueExpr = ConvertedValueExpr.
get();
730 return MaybeBindToTemporary(BoxedExpr);
739 assert(!LangOpts.isSubscriptPointerArithmetic());
744 "base or index cannot have dependent type here");
751 IndexExpr = Result.
get();
754 Result = DefaultLvalueConversion(BaseExpr);
757 BaseExpr = Result.
get();
762 getterMethod, setterMethod, RB);
778 if (!ArrayWithObjectsMethod) {
782 if (!Method && getLangOpts().DebuggerObjCLiteral) {
799 Params.push_back(objects);
807 Params.push_back(cnt);
822 diag::note_objc_literal_method_param)
829 if (!Method->
parameters()[1]->getType()->isIntegerType()) {
833 diag::note_objc_literal_method_param)
841 ArrayWithObjectsMethod = Method;
844 QualType ObjectsType = ArrayWithObjectsMethod->parameters()[0]->getType();
849 Expr **ElementsBuffer = Elements.data();
850 for (
unsigned I = 0, N = Elements.size();
I != N; ++
I) {
857 ElementsBuffer[
I] = Converted.
get();
864 return MaybeBindToTemporary(
866 ArrayWithObjectsMethod, SR));
873 if (!NSDictionaryDecl) {
876 if (!NSDictionaryDecl) {
884 if (!DictionaryWithObjectsMethod) {
885 Selector Sel = NSAPIObj->getNSDictionarySelector(
887 ObjCMethodDecl *Method = NSDictionaryDecl->lookupClassMethod(Sel);
888 if (!Method && getLangOpts().DebuggerObjCLiteral) {
907 Params.push_back(objects);
915 Params.push_back(keys);
923 Params.push_back(cnt);
939 diag::note_objc_literal_method_param)
953 if (QIDNSCopying.isNull()) {
967 if (!QIDNSCopying.isNull())
976 diag::note_objc_literal_method_param)
984 QualType CountType = Method->parameters()[2]->getType();
988 Diag(Method->parameters()[2]->getLocation(),
989 diag::note_objc_literal_method_param)
996 DictionaryWithObjectsMethod = Method;
999 QualType ValuesT = DictionaryWithObjectsMethod->parameters()[0]->getType();
1001 QualType KeysT = DictionaryWithObjectsMethod->parameters()[1]->getType();
1006 bool HasPackExpansions =
false;
1020 Element.Key = Key.
get();
1021 Element.Value = Value.
get();
1023 if (Element.EllipsisLoc.isInvalid())
1026 if (!Element.Key->containsUnexpandedParameterPack() &&
1027 !Element.Value->containsUnexpandedParameterPack()) {
1028 Diag(Element.EllipsisLoc,
1029 diag::err_pack_expansion_without_parameter_packs)
1031 Element.Value->getLocEnd());
1035 HasPackExpansions =
true;
1042 Context, Elements, HasPackExpansions, Ty,
1043 DictionaryWithObjectsMethod, SR));
1057 diag::err_incomplete_type_objc_at_encode,
1064 if (!NotEncodedT.
isNull())
1065 Diag(AtLoc, diag::warn_incomplete_encoded_type)
1066 << EncodedType << NotEncodedT;
1103 bool Warned =
false;
1106 if (MatchingMethodDecl == Method ||
1114 S.
Diag(AtLoc, diag::warn_multiple_selectors)
1120 S.
Diag(MatchingMethodDecl->
getLocation(), diag::note_method_declared_at)
1131 bool WarnMultipleSelectors) {
1132 if (!WarnMultipleSelectors ||
1135 bool Warned =
false;
1136 for (Sema::GlobalMethodPool::iterator b = S.
MethodPool.begin(),
1141 Method, InstMethList))
1147 Method, ClsMethList) || Warned)
1157 bool WarnMultipleSelectors) {
1165 Selector MatchedSel = OM->getSelector();
1168 Diag(SelLoc, diag::warn_undeclared_selector_with_typo)
1169 << Sel << MatchedSel
1173 Diag(SelLoc, diag::warn_undeclared_selector) << Sel;
1176 WarnMultipleSelectors);
1192 Diag(AtLoc, diag::err_arc_illegal_selector) <<
1221 Diag(ProtoLoc, diag::err_undeclared_protocol) << ProtocolId;
1277 bool isClassMessage,
1278 bool isSuperMessage) {
1279 assert(Method &&
"Must have a method");
1314 if (isSuperMessage) {
1317 return transferNullability(
1336 return transferNullability(ReceiverType);
1341 bool isClassMessage,
1342 bool isSuperMessage) {
1354 unsigned receiverNullabilityIdx = 0;
1356 receiverNullabilityIdx = 1 + static_cast<unsigned>(*nullability);
1358 unsigned resultNullabilityIdx = 0;
1360 resultNullabilityIdx = 1 + static_cast<unsigned>(*nullability);
1364 static const uint8_t
None = 0;
1365 static const uint8_t
NonNull = 1;
1368 static const uint8_t nullabilityMap[4][4] = {
1376 unsigned newResultNullabilityIdx
1377 = nullabilityMap[receiverNullabilityIdx][resultNullabilityIdx];
1378 if (newResultNullabilityIdx == resultNullabilityIdx)
1384 if (
auto attributed = dyn_cast<AttributedType>(resultType.
getTypePtr())) {
1385 resultType = attributed->getModifiedType();
1392 if (newResultNullabilityIdx > 0) {
1397 resultType, resultType);
1416 dyn_cast<ObjCCategoryImplDecl>(impl)) {
1417 iface = catImpl->getCategoryDecl();
1419 iface = impl->getClassInterface();
1429 for (
unsigned i = 0, e = overrides.size(); i != e; ++i) {
1450 SourceRange range = overridden->getReturnTypeSourceRange();
1453 loc = overridden->getLocation();
1454 Diag(loc, diag::note_related_result_type_explicit)
1498 bool isClassMessage,
bool isSuperMessage,
1503 if (!SelectorLocs.empty() && SelectorLocs.front().isValid())
1504 SelLoc = SelectorLocs.front();
1510 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
1511 if (Args[i]->isTypeDependent())
1523 Args[i] = result.
get();
1528 DiagID = diag::err_arc_method_not_found;
1530 DiagID = isClassMessage ? diag::warn_class_method_not_found
1531 : diag::warn_inst_method_not_found;
1536 DiagID = diag::err_method_not_found_with_typo;
1538 DiagID = isClassMessage ? diag::warn_class_method_not_found_with_typo
1539 : diag::warn_instance_method_not_found_with_typo;
1541 SourceRange SelectorRange(SelectorLocs.front(), SelectorLocs.back());
1543 Diag(SelLoc, DiagID)
1544 << Sel<< isClassMessage << MatchedSel
1547 Diag(SelLoc, DiagID) << Sel<< isClassMessage << MatchedSel;
1550 Diag(SelLoc, DiagID)
1551 << Sel << isClassMessage <<
SourceRange(SelectorLocs.front(),
1552 SelectorLocs.back());
1557 Diag(ThisClass->getLocation(), diag::note_receiver_class_declared);
1559 if (ThisClass->lookupClassMethod(Sel))
1560 Diag(RecRange.
getBegin(),diag::note_receiver_expr_here)
1562 ThisClass->getNameAsString());
1588 if (Args.size() < NumNamedArgs) {
1589 Diag(SelLoc, diag::err_typecheck_call_too_few_args)
1590 << 2 << NumNamedArgs << static_cast<unsigned>(Args.size());
1598 bool IsError =
false;
1599 for (
unsigned i = 0; i < NumNamedArgs; i++) {
1601 if (Args[i]->isTypeDependent())
1604 Expr *argExpr = Args[i];
1607 assert(argExpr &&
"CheckMessageArgumentTypes(): missing expression");
1612 !param->
hasAttr<CFConsumedAttr>())
1623 Args[i] = argE.
get();
1641 diag::err_call_incomplete_argument, argExpr))
1656 Args[i]->getType()->isBlockPointerType() &&
1660 Args[i] = arg.
get();
1667 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
1668 if (Args[i]->isTypeDependent())
1674 Args[i] = Arg.
get();
1678 if (Args.size() != NumNamedArgs) {
1679 Diag(Args[NumNamedArgs]->getLocStart(),
1680 diag::err_typecheck_call_too_many_args)
1681 << 2 << NumNamedArgs << static_cast<unsigned>(Args.size())
1684 Args.back()->getLocEnd());
1691 IsError |= CheckObjCMethodCall(
1692 Method, SelLoc, makeArrayRef(Args.data(), Args.size()));
1705 if (!method)
return false;
1708 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(receiver))
1720 if (
ObjCMethodDecl *method = iface->lookupMethod(sel, isInstance))
1725 if (
ObjCMethodDecl *method = iface->lookupPrivateMethod(sel, isInstance))
1730 for (
const auto *
I : objType->
quals())
1744 for (
const auto *PROTO : OPT->
quals()) {
1745 if ((MD = PROTO->lookupMethod(Sel, Instance))) {
1765 Diag(MemberLoc, diag::err_invalid_property_name)
1775 diag::err_property_not_found_forward_class,
1776 MemberName, BaseRange))
1794 for (
const auto *
I : OPT->
quals())
1804 SuperLoc, SuperType);
1855 if (Setter && Setter->isImplicit() && Setter->isPropertyAccessor() &&
1863 diag::warn_property_access_suggest)
1864 << MemberName <<
QualType(OPT, 0) << PDecl->getName()
1869 if (Getter || Setter) {
1885 llvm::make_unique<DeclFilterCCC<ObjCPropertyDecl>>(),
1892 Corrected.isKeyword() ?
nullptr : Corrected.getFoundDecl();
1893 if (ChosenDecl && isa<ObjCPropertyDecl>(ChosenDecl))
1894 if (cast<ObjCPropertyDecl>(ChosenDecl)->isClassProperty()) {
1897 Diag(MemberLoc, diag::err_class_property_found) << MemberName
1905 << MemberName <<
QualType(OPT, 0));
1907 TypoResult, MemberLoc,
1908 SuperLoc, SuperType, Super);
1918 diag::err_property_not_as_forward_class,
1919 MemberName, BaseExpr))
1923 diag::err_ivar_access_using_property_syntax_suggest)
1924 << MemberName <<
QualType(OPT, 0) << Ivar->getDeclName()
1929 Diag(MemberLoc, diag::err_property_not_found)
1932 Diag(Setter->getLocation(), diag::note_getter_unavailable)
1951 if (receiverNamePtr->
isStr(
"super")) {
1953 if (
auto classDecl = CurMethod->getClassInterface()) {
1954 SuperType =
QualType(classDecl->getSuperClassType(), 0);
1955 if (CurMethod->isInstanceMethod()) {
1956 if (SuperType.
isNull()) {
1958 Diag(receiverNameLoc, diag::err_root_class_cannot_use_super)
1959 << CurMethod->getClassInterface()->getIdentifier();
1969 receiverNameLoc, T,
true);
1980 Diag(receiverNameLoc, diag::err_expected_either) << tok::identifier
1990 GetterSel = PD->getGetterName();
1991 SetterSel = PD->getSetterName();
2026 if (Getter || Setter) {
2035 propertyNameLoc, receiverNameLoc, IFace);
2037 return ExprError(
Diag(propertyNameLoc, diag::err_property_not_found)
2051 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
2063 bool HasTrailingDot,
2065 ReceiverType =
nullptr;
2083 if (!Method->getClassInterface()) {
2089 if (Method->getClassInterface()->lookupInstanceVariable(Name,
2134 if (Corrected.isKeyword()) {
2138 PDiag(diag::err_unknown_receiver_suggest) << Name);
2145 PDiag(diag::err_unknown_receiver_suggest) << Name);
2167 Diag(SuperLoc, diag::err_invalid_receiver_to_message_super);
2173 Diag(SuperLoc, diag::err_no_super_class_message)
2179 if (SuperTy.isNull()) {
2181 Diag(SuperLoc, diag::err_root_class_cannot_use_super)
2197 LBracLoc, SelectorLocs, RBracLoc, Args);
2204 SuperLoc, Sel,
nullptr,
2205 LBracLoc, SelectorLocs, RBracLoc, Args);
2209 bool isSuperReceiver,
2215 if (!ReceiverType.
isNull())
2220 Sel, Method, Loc, Loc, Loc, Args,
2234 if (refactor(Msg,*S.
NSAPIObj, ECommit)) {
2243 switch (Edit.
Kind) {
2271 bool IsClassObjectCall) {
2281 if (!IsClassObjectCall) {
2283 if (!OPT || !OPT->getInterfaceDecl())
2286 OPT->getInterfaceDecl()->lookupInstanceMethod(SE->getSelector());
2289 OPT->getInterfaceDecl()->lookupPrivateMethod(SE->getSelector());
2294 ImpliedMethod = IT->getDecl()->lookupClassMethod(SE->getSelector());
2297 IT->getDecl()->lookupPrivateClassMethod(SE->getSelector());
2304 S.
Diag(Loc, diag::warn_objc_unsafe_perform_selector)
2310 diag::note_objc_unsafe_perform_selector_method_declared_here)
2321 Expr **Args,
unsigned NumArgs) {
2323 bool Format =
false;
2337 if (!Format || NumArgs <= Idx)
2340 Expr *FormatExpr = Args[Idx];
2345 S.
Diag(FormatExpr->
getExprLoc(), diag::warn_objc_cdirective_format_string)
2395 Diag(Loc, diag::err_missing_open_square_message_send)
2400 if (!SelectorLocs.empty() && SelectorLocs.front().isValid())
2401 SelLoc = SelectorLocs.front();
2408 unsigned NumArgs = ArgsIn.size();
2409 Expr **Args = ArgsIn.data();
2410 assert(SuperLoc.
isInvalid() &&
"Message to super with dependent type");
2413 SelectorLocs,
nullptr, makeArrayRef(Args, NumArgs), RBracLoc,
2420 if (!ClassType || !(Class = ClassType->
getInterface())) {
2421 Diag(Loc, diag::err_invalid_receiver_class_message)
2425 assert(Class &&
"We don't know which class we're messaging?");
2436 ? diag::err_arc_receiver_forward_class
2437 : diag::warn_receiver_forward_class),
2461 unsigned NumArgs = ArgsIn.size();
2462 Expr **Args = ArgsIn.data();
2466 SuperLoc.
isValid(), LBracLoc, RBracLoc,
2473 diag::err_illegal_message_expr_incomplete_type))
2482 Diag(Loc, diag::warn_direct_initialize_call);
2490 Diag(Loc, diag::warn_direct_super_initialize_call);
2493 Diag(CurMeth->getLocation(), diag::note_method_declared_at)
2494 << CurMeth->getDeclName();
2506 ReceiverType, Sel, SelectorLocs,
2507 Method, makeArrayRef(Args, NumArgs),
2508 RBracLoc, isImplicit);
2511 ReceiverTypeInfo, Sel, SelectorLocs,
2512 Method, makeArrayRef(Args, NumArgs),
2513 RBracLoc, isImplicit);
2519 ReceiverType,
true);
2535 if (ReceiverType.
isNull())
2538 if (!ReceiverTypeInfo)
2543 nullptr, LBracLoc, SelectorLocs, RBracLoc,
2555 Sel, Method, Loc, Loc, Loc, Args,
2566 if (
const auto *RootClass = dyn_cast_or_null<ObjCInterfaceDecl>(
2570 if (
P->getCanonicalDecl() == Protocol->getCanonicalDecl())
2615 assert((Receiver || SuperLoc.
isValid()) &&
"If the Receiver is null, the "
2616 "SuperLoc must be valid so we can "
2624 if (!SelectorLocs.empty() && SelectorLocs.front().isValid())
2625 SelLoc = SelectorLocs.front();
2630 Diag(Loc, diag::err_missing_open_square_message_send)
2645 Receiver = Result.
get();
2651 unsigned NumArgs = ArgsIn.size();
2652 Expr **Args = ArgsIn.data();
2653 assert(SuperLoc.
isInvalid() &&
"Message to super with dependent type");
2656 SelectorLocs,
nullptr, makeArrayRef(Args, NumArgs),
2657 RBracLoc, isImplicit);
2665 Receiver = Result.
get();
2666 ReceiverType = Receiver->
getType();
2679 Diag(Loc, diag::warn_bad_receiver_type)
2684 CK_CPointerToObjCPointerCast).
get();
2689 CastKind Kind = IsNull ? CK_NullToPointer : CK_IntegralToPointer;
2693 ReceiverType = Receiver->
getType();
2697 diag::err_incomplete_receiver_type))
2702 Receiver = result.
get();
2703 ReceiverType = Receiver->
getType();
2724 if (!Methods.empty()) {
2727 Method = Methods[0];
2731 Method = BestMethod;
2735 receiverIsIdLike, Methods))
2753 Diag(SelLoc, diag::warn_instance_method_on_class_found)
2763 Method = ClassDecl->lookupClassMethod(Sel);
2766 Method = ClassDecl->lookupPrivateClassMethod(Sel);
2780 if (!Methods.empty()) {
2783 Method = Methods[0];
2789 if (
ID->getSuperClass())
2790 Diag(SelLoc, diag::warn_root_inst_method_not_found)
2798 Method = BestMethod;
2820 ClassDecl = OCIType->getInterfaceDecl();
2829 ? diag::err_arc_receiver_forward_instance
2830 : diag::warn_receiver_forward_instance,
2836 forwardClass = OCIType->getInterfaceDecl();
2838 : SuperLoc, diag::note_receiver_is_id);
2853 Diag(SelLoc, diag::err_arc_may_not_respond)
2854 << OCIType->getPointeeType() << Sel << RecRange
2855 <<
SourceRange(SelectorLocs.front(), SelectorLocs.back());
2859 if (!Method && (!Receiver || !
isSelfExpr(Receiver))) {
2863 if (OCIType->qual_empty()) {
2868 if (!Methods.empty()) {
2871 Method = Methods[0];
2876 Method = BestMethod;
2883 if (Method && !forwardClass)
2884 Diag(SelLoc, diag::warn_maynot_respond)
2885 << OCIType->getInterfaceDecl()->getIdentifier()
2894 Diag(Loc, diag::err_bad_receiver_type)
2905 if (DIFunctionScopeInfo &&
2908 bool isDesignatedInitChain =
false;
2915 if (!
ID->declaresOrInheritsDesignatedInitializers() ||
2916 ID->isDesignatedInitializer(Sel)) {
2917 isDesignatedInitChain =
true;
2923 if (!isDesignatedInitChain) {
2927 assert(isDesignated && InitMethod);
2930 diag::warn_objc_designated_init_non_designated_init_call :
2931 diag::warn_objc_designated_init_non_super_designated_init_call);
2933 diag::note_objc_designated_init_marked_here);
2937 if (DIFunctionScopeInfo &&
2941 Diag(SelLoc, diag::warn_objc_secondary_init_super_init_call);
2948 unsigned NumArgs = ArgsIn.size();
2949 Expr **Args = ArgsIn.data();
2955 Sel, SelectorLocs, Method,
2956 ClassMessage, SuperLoc.
isValid(),
2957 LBracLoc, RBracLoc, RecRange, ReturnType, VK))
2962 diag::err_illegal_message_expr_incomplete_type))
2990 Diag(SelLoc, diag::err_arc_illegal_explicit_message)
2995 if (Method && NumArgs >= 1) {
2996 if (
const auto *SelExp =
2997 dyn_cast<ObjCSelectorExpr>(Args[0]->IgnoreParens())) {
2998 Selector ArgSel = SelExp->getSelector();
3001 SelExp->getSourceRange());
3005 SelExp->getSourceRange());
3008 switch (SelFamily) {
3015 if (!SelMethod->
hasAttr<NSReturnsNotRetainedAttr>()) {
3018 diag::err_arc_perform_selector_retains);
3025 if (SelMethod->
hasAttr<NSReturnsRetainedAttr>()) {
3028 diag::err_arc_perform_selector_retains);
3037 Diag(SelLoc, diag::warn_arc_perform_selector_leaks);
3038 Diag(Args[0]->getExprLoc(), diag::note_used_here);
3052 ReceiverType, Sel, SelectorLocs, Method,
3053 makeArrayRef(Args, NumArgs), RBracLoc,
3057 Receiver, Sel, SelectorLocs, Method,
3058 makeArrayRef(Args, NumArgs), RBracLoc,
3064 bool IsClassObjectCall = ClassMessage;
3071 if (OPT->getObjectType()->isObjCClass()) {
3073 IsClassObjectCall =
true;
3081 ReceiverType, IsClassObjectCall);
3105 if (!isImplicit && Method) {
3118 CheckObjCCircularContainer(Result);
3148 if (isa<ParenListExpr>(Receiver)) {
3151 Receiver = Result.
get();
3163 nullptr, LBracLoc, SelectorLocs,
3197 bool isIndirect =
false;
3216 type =
QualType(array->getElementType()->getBaseElementTypeUnsafe(), 0);
3251 if (left == right)
return left;
3252 if (left == ACC_bottom)
return right;
3253 if (right == ACC_bottom)
return left;
3259 class ARCCastChecker :
public StmtVisitor<ARCCastChecker, ACCResult> {
3275 : Context(Context), SourceClass(source), TargetClass(target),
3276 Diagnose(diagnose) {}
3306 case CK_NullToPointer:
3310 case CK_LValueToRValue:
3312 case CK_CPointerToObjCPointerCast:
3313 case CK_BlockPointerToObjCPointerCast:
3314 case CK_AnyPointerToBlockPointerCast:
3329 return Visit(e->
getRHS());
3335 if (left == ACC_invalid)
return ACC_invalid;
3365 return ACC_plusZero;
3375 if (
ACCResult result = checkCallToFunction(fn))
3378 return super::VisitCallExpr(e);
3390 if (fn->
hasAttr<CFReturnsNotRetainedAttr>())
3391 return ACC_plusZero;
3396 if (fn->
hasAttr<CFReturnsRetainedAttr>())
3397 return Diagnose ? ACC_plusOne
3402 if (builtinID == Builtin::BI__builtin___CFStringMakeConstantString)
3406 if (!fn->
hasAttr<CFAuditedTransferAttr>())
3411 return Diagnose ? ACC_plusOne
3414 return ACC_plusZero;
3427 return checkCallToMethod(method);
3431 if (!method)
return ACC_invalid;
3440 if (method->
hasAttr<CFReturnsNotRetainedAttr>())
3441 return ACC_plusZero;
3445 if (method->
hasAttr<CFReturnsRetainedAttr>())
3457 return ACC_plusZero;
3478 const char *bridgeKeyword,
3479 const char *CFBridgeName) {
3494 NCE->getAngleBrackets().getEnd());
3498 char PrevChar = *SM.
getCharacterData(range.getBegin().getLocWithOffset(-1));
3502 BridgeCall += CFBridgeName;
3509 castedE = CCE->getSubExpr();
3520 BridgeCall += CFBridgeName;
3522 if (isa<ParenExpr>(castedE)) {
3540 std::string castCode =
"(";
3541 castCode += bridgeKeyword;
3545 NCE->getAngleBrackets().getEnd());
3549 std::string castCode =
"(";
3550 castCode += bridgeKeyword;
3555 if (isa<ParenExpr>(castedE)) {
3569 template <
typename T>
3577 return RD->getAttr<T>();
3585 TDNDecl = TD->getDecl();
3586 if (ObjCBridgeRelatedAttr *ObjCBAttr =
3587 getObjCBridgeAttr<ObjCBridgeRelatedAttr>(TD))
3604 UnavailableAttr::IR_ARCForbiddenConversion))
3617 unsigned srcKind = 0;
3639 S.
Diag(loc, diag::err_arc_cast_requires_bridge)
3649 ARCCastChecker(S.
Context, exprACTC, castACTC,
true).Visit(castExpr);
3650 assert(CreateRule != ACC_bottom &&
"This cast should already be accepted.");
3651 if (CreateRule != ACC_plusOne)
3655 : S.
Diag(noteLoc, diag::note_arc_cstyle_bridge);
3658 castType, castExpr, realCast,
"__bridge ",
3661 if (CreateRule != ACC_plusZero)
3665 S.
Diag(noteLoc, diag::note_arc_cstyle_bridge_transfer) << castExprType :
3667 diag::note_arc_bridge_transfer)
3668 << castExprType << br;
3671 castType, castExpr, realCast,
"__bridge_transfer ",
3672 br ?
"CFBridgingRelease" :
nullptr);
3681 S.
Diag(loc, diag::err_arc_cast_requires_bridge)
3690 ARCCastChecker(S.
Context, exprACTC, castACTC,
true).Visit(castExpr);
3691 assert(CreateRule != ACC_bottom &&
"This cast should already be accepted.");
3692 if (CreateRule != ACC_plusOne)
3696 : S.
Diag(noteLoc, diag::note_arc_cstyle_bridge);
3698 castType, castExpr, realCast,
"__bridge ",
3701 if (CreateRule != ACC_plusZero)
3705 S.
Diag(noteLoc, diag::note_arc_cstyle_bridge_retained) << castType :
3707 diag::note_arc_bridge_retained)
3711 castType, castExpr, realCast,
"__bridge_retained ",
3712 br ?
"CFBridgingRetain" :
nullptr);
3718 S.
Diag(loc, diag::err_arc_mismatched_cast)
3720 << srcKind << castExprType << castType
3724 template <
typename TB>
3726 bool &HadTheAttribute,
bool warn) {
3728 HadTheAttribute =
false;
3731 if (TB *ObjCBAttr = getObjCBridgeAttr<TB>(TD)) {
3733 HadTheAttribute =
true;
3734 if (Parm->isStr(
"id"))
3743 if (Target && isa<ObjCInterfaceDecl>(Target)) {
3748 = InterfacePointerType->getObjectType()->getInterface();
3749 if ((CastClass == ExprClass) ||
3758 castType, ExprClass)))
3766 << T << Target->
getName() << castType;
3774 S.
Diag(castExpr->
getLocStart(), diag::err_objc_cf_bridged_not_interface)
3775 << castExpr->
getType() << Parm;
3789 template <
typename TB>
3791 bool &HadTheAttribute,
bool warn) {
3793 HadTheAttribute =
false;
3796 if (TB *ObjCBAttr = getObjCBridgeAttr<TB>(TD)) {
3798 HadTheAttribute =
true;
3799 if (Parm->isStr(
"id"))
3808 if (Target && isa<ObjCInterfaceDecl>(Target)) {
3813 = InterfacePointerType->getObjectType()->getInterface();
3814 if ((CastClass == ExprClass) ||
3825 castExpr->
getType(), CastClass)))
3833 << castExpr->
getType() << castType;
3841 S.
Diag(castExpr->
getLocStart(), diag::err_objc_ns_bridged_invalid_cfobject)
3842 << castExpr->
getType() << castType;
3862 bool HasObjCBridgeAttr;
3863 bool ObjCBridgeAttrWillNotWarn =
3864 CheckObjCBridgeNSCast<ObjCBridgeAttr>(*
this, castType,
castExpr, HasObjCBridgeAttr,
3866 if (ObjCBridgeAttrWillNotWarn && HasObjCBridgeAttr)
3868 bool HasObjCBridgeMutableAttr;
3869 bool ObjCBridgeMutableAttrWillNotWarn =
3870 CheckObjCBridgeNSCast<ObjCBridgeMutableAttr>(*
this, castType,
castExpr,
3871 HasObjCBridgeMutableAttr,
false);
3872 if (ObjCBridgeMutableAttrWillNotWarn && HasObjCBridgeMutableAttr)
3875 if (HasObjCBridgeAttr)
3876 CheckObjCBridgeNSCast<ObjCBridgeAttr>(*
this, castType,
castExpr, HasObjCBridgeAttr,
3878 else if (HasObjCBridgeMutableAttr)
3879 CheckObjCBridgeNSCast<ObjCBridgeMutableAttr>(*
this, castType,
castExpr,
3880 HasObjCBridgeMutableAttr,
true);
3883 bool HasObjCBridgeAttr;
3884 bool ObjCBridgeAttrWillNotWarn =
3885 CheckObjCBridgeCFCast<ObjCBridgeAttr>(*
this, castType,
castExpr, HasObjCBridgeAttr,
3887 if (ObjCBridgeAttrWillNotWarn && HasObjCBridgeAttr)
3889 bool HasObjCBridgeMutableAttr;
3890 bool ObjCBridgeMutableAttrWillNotWarn =
3891 CheckObjCBridgeCFCast<ObjCBridgeMutableAttr>(*
this, castType,
castExpr,
3892 HasObjCBridgeMutableAttr,
false);
3893 if (ObjCBridgeMutableAttrWillNotWarn && HasObjCBridgeMutableAttr)
3896 if (HasObjCBridgeAttr)
3897 CheckObjCBridgeCFCast<ObjCBridgeAttr>(*
this, castType,
castExpr, HasObjCBridgeAttr,
3899 else if (HasObjCBridgeMutableAttr)
3900 CheckObjCBridgeCFCast<ObjCBridgeMutableAttr>(*
this, castType,
castExpr,
3901 HasObjCBridgeMutableAttr,
true);
3908 if (PRE->isExplicitProperty()) {
3910 SrcType = PDecl->getType();
3912 else if (PRE->isImplicitProperty()) {
3914 SrcType = Getter->getReturnType();
3937 : CK_CPointerToObjCPointerCast;
3949 bool CfToNs,
bool Diagnose) {
3950 QualType T = CfToNs ? SrcType : DestType;
3966 Diag(Loc, diag::err_objc_bridged_related_invalid_class) << RCId
3967 << SrcType << DestType;
3973 if (Target && isa<ObjCInterfaceDecl>(Target))
3974 RelatedClass = cast<ObjCInterfaceDecl>(Target);
3977 Diag(Loc, diag::err_objc_bridged_related_invalid_class_name) << RCId
3978 << SrcType << DestType;
3987 if (CfToNs && CMId) {
3992 Diag(Loc, diag::err_objc_bridged_related_known_method)
3993 << SrcType << DestType << Sel <<
false;
4001 if (!CfToNs && IMId) {
4003 InstanceMethod = RelatedClass->
lookupMethod(Sel,
true);
4004 if (!InstanceMethod) {
4006 Diag(Loc, diag::err_objc_bridged_related_known_method)
4007 << SrcType << DestType << Sel <<
true;
4019 Expr *&SrcExpr,
bool Diagnose) {
4024 if (!CfToNs && !NsToCf)
4032 ClassMethod, InstanceMethod, TDNDecl,
4040 std::string ExpressionString =
"[";
4042 ExpressionString +=
" ";
4046 Diag(Loc, diag::err_objc_bridged_related_known_method)
4047 << SrcType << DestType << ClassMethod->
getSelector() <<
false
4055 Expr *args[] = { SrcExpr };
4060 SrcExpr = msg.
get();
4067 if (InstanceMethod) {
4069 std::string ExpressionString;
4076 ExpressionString =
".";
4077 ExpressionString += PDecl->getNameAsString();
4078 Diag(Loc, diag::err_objc_bridged_related_known_method)
4079 << SrcType << DestType << InstanceMethod->
getSelector() <<
true
4082 if (ExpressionString.empty()) {
4084 ExpressionString =
" ";
4086 ExpressionString +=
"]";
4088 Diag(Loc, diag::err_objc_bridged_related_known_method)
4089 << SrcType << DestType << InstanceMethod->
getSelector() <<
true
4100 InstanceMethod,
None);
4101 SrcExpr = msg.get();
4112 bool Diagnose,
bool DiagnoseCFAudited,
4124 if (exprACTC == castACTC) {
4129 castType != castExprType) {
4135 if (
const ParenType *PT = dyn_cast<ParenType>(DT))
4136 QDT = PT->desugar();
4137 else if (
const TypeOfType *TP = dyn_cast<TypeOfType>(DT))
4138 QDT = TP->desugar();
4139 else if (
const AttributedType *AT = dyn_cast<AttributedType>(DT))
4140 QDT = AT->desugar();
4141 if (QDT != castType &&
4146 Diag(loc, diag::err_arc_nolifetime_behavior);
4175 switch (ARCCastChecker(
Context, exprACTC, castACTC,
false).Visit(castExpr)) {
4215 (Opc == BO_NE || Opc == BO_EQ))) {
4218 castExpr, exprACTC, CCK);
4237 castType =
cast->getTypeAsWritten();
4240 castRange =
cast->getTypeInfoAsWritten()->getTypeLoc().getSourceRange();
4241 castType =
cast->getTypeAsWritten();
4244 llvm_unreachable(
"Unexpected ImplicitCastExpr");
4262 if (
ParenExpr *pe = dyn_cast<ParenExpr>(e)) {
4265 }
else if (
UnaryOperator *uo = dyn_cast<UnaryOperator>(e)) {
4266 assert(uo->getOpcode() == UO_Extension);
4269 sub->getValueKind(), sub->getObjectKind(),
4270 uo->getOperatorLoc());
4272 assert(!gse->isResultDependent());
4274 unsigned n = gse->getNumAssocs();
4277 for (
unsigned i = 0; i != n; ++i) {
4278 subTypes[i] = gse->getAssocTypeSourceInfo(i);
4279 Expr *sub = gse->getAssocExpr(i);
4280 if (i == gse->getResultIndex())
4286 gse->getControllingExpr(),
4288 gse->getDefaultLoc(),
4289 gse->getRParenLoc(),
4290 gse->containsUnexpandedParameterPack(),
4291 gse->getResultIndex());
4293 assert(isa<ImplicitCastExpr>(e) &&
"bad form of unbridged cast!");
4294 return cast<ImplicitCastExpr>(e)->getSubExpr();
4304 if (isa<ObjCObjectPointerType>(canCastType) &&
4310 return !ObjI->isArcWeakrefUnavailable();
4323 if (ice->getCastKind() == CK_ARCReclaimReturnedObject)
4324 return ice->getSubExpr();
4336 SubExpr = SubResult.
get();
4343 bool MustConsume =
false;
4350 : CK_CPointerToObjCPointerCast);
4357 Diag(BridgeKeywordLoc, diag::err_arc_bridge_cast_wrong_kind)
4364 Diag(BridgeKeywordLoc, diag::note_arc_bridge)
4366 Diag(BridgeKeywordLoc, diag::note_arc_bridge_transfer)
4369 br ?
"CFBridgingRelease "
4370 :
"__bridge_transfer ");
4394 CK_ARCProduceObject,
4400 Diag(BridgeKeywordLoc, diag::err_arc_bridge_cast_wrong_kind)
4408 Diag(BridgeKeywordLoc, diag::note_arc_bridge)
4410 Diag(BridgeKeywordLoc, diag::note_arc_bridge_retained)
4413 br ?
"CFBridgingRetain " :
"__bridge_retained");
4420 Diag(LParenLoc, diag::err_arc_bridge_cast_incompatible)
4421 << FromType << T << Kind
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...
Stmt - This represents one statement.
NullabilityKind
Describes the nullability of a particular type.
static void diagnoseObjCARCConversion(Sema &S, SourceRange castRange, QualType castType, ARCConversionTypeClass castACTC, Expr *castExpr, Expr *realCast, ARCConversionTypeClass exprACTC, Sema::CheckedConversionKind CCK)
ARCConversionResult CheckObjCConversion(SourceRange castRange, QualType castType, Expr *&op, CheckedConversionKind CCK, bool Diagnose=true, bool DiagnoseCFAudited=false, BinaryOperatorKind Opc=BO_PtrMemD)
Checks for invalid conversions and casts between retainable pointers and other pointer kinds for ARC ...
Bridging via __bridge, which does nothing but reinterpret the bits.
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
static InitializedEntity InitializeParameter(ASTContext &Context, const ParmVarDecl *Parm)
Create the initialization entity for a parameter.
QualType getUnderlyingType() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
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'.
SourceLocation getLocStart() const LLVM_READONLY
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.
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...
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)
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...
bool isExtVectorType() const
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)
SourceLocation getLocEnd() const LLVM_READONLY
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.
DeclContext * getDeclContext()
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)
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.
SourceLocation getLocStart() const LLVM_READONLY
There is no lifetime qualification on this type.
static bool isMethodDeclaredInRootProtocol(Sema &S, const ObjCMethodDecl *M)
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...
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 isVectorType() const
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
Source range that this declaration covers.
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 isInvalidDecl() const
bool ObjCIsSecondaryInit
True when this is an initializer method not marked as a designated initializer within a class that ha...
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
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.
static void checkFoundationAPI(Sema &S, SourceLocation Loc, const ObjCMethodDecl *Method, ArrayRef< Expr * > Args, QualType ReceiverType, bool IsClassObjectCall)
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...
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
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
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
ExprResult BuildInstanceMessageImplicit(Expr *Receiver, QualType ReceiverType, SourceLocation Loc, Selector Sel, ObjCMethodDecl *Method, MultiExprArg Args)
StringLiteral - This represents a string literal expression, e.g.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
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.
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)
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...
DefinitionKind hasDefinition(ASTContext &) const
Check whether this variable is defined in this translation unit.
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.
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
SourceLocation getLocStart() const LLVM_READONLY
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