28 #include "llvm/ADT/SmallString.h"
30 using namespace clang;
32 using llvm::makeArrayRef;
43 if (Strings.size() != 1) {
48 for (
Expr *
E : Strings) {
49 S = cast<StringLiteral>(
E);
54 << S->getSourceRange();
68 assert(CAT &&
"String literal not of constant array type!");
73 false, StrTy, &StrLocs[0],
77 return BuildObjCStringLiteral(AtLocs[0], S);
82 if (CheckObjCString(S))
92 }
else if (getLangOpts().NoConstantCFStrings) {
94 std::string StringClass(getLangOpts().ObjCConstantStringClass);
96 if (StringClass.empty())
101 NamedDecl *IF = LookupSingleName(TUScope, NSIdent, AtLoc,
110 Diag(S->
getLocStart(), diag::err_no_nsconstant_string_class) << NSIdent
111 << S->getSourceRange();
116 NamedDecl *IF = LookupSingleName(TUScope, NSIdent, AtLoc,
151 S.
Diag(Loc, diag::err_undeclared_boxing_method) << Sel << Class->
getName();
158 S.
Diag(Loc, diag::err_objc_literal_method_sig)
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);
379 return BuildObjCNumericLiteral(AtLoc, Inner.
get());
386 bool ArrayLiteral =
false) {
394 Element = Result.
get();
407 return Seq.Perform(S, Entity, Kind, Element);
410 Expr *OrigElement = Element;
416 Element = Result.
get();
421 bool Recovered =
false;
424 if (isa<IntegerLiteral>(OrigElement) ||
425 isa<CharacterLiteral>(OrigElement) ||
426 isa<FloatingLiteral>(OrigElement) ||
427 isa<ObjCBoolLiteralExpr>(OrigElement) ||
428 isa<CXXBoolLiteralExpr>(OrigElement)) {
429 if (S.
NSAPIObj->getNSNumberFactoryMethodKind(OrigElement->
getType())) {
430 int Which = isa<CharacterLiteral>(OrigElement) ? 1
431 : (isa<CXXBoolLiteralExpr>(OrigElement) ||
432 isa<ObjCBoolLiteralExpr>(OrigElement)) ? 2
435 S.
Diag(OrigElement->getLocStart(), diag::err_box_literal_collection)
436 << Which << OrigElement->getSourceRange()
441 if (Result.isInvalid())
444 Element = Result.get();
449 else if (
StringLiteral *String = dyn_cast<StringLiteral>(OrigElement)) {
450 if (String->isAscii()) {
451 S.
Diag(OrigElement->getLocStart(), diag::err_box_literal_collection)
452 << 0 << OrigElement->getSourceRange()
456 if (Result.isInvalid())
459 Element = Result.get();
465 S.
Diag(Element->getLocStart(), diag::err_invalid_collection_element)
472 dyn_cast<ObjCStringLiteral>(OrigElement)) {
474 unsigned numConcat = SL->getNumConcatenated();
477 bool hasMacro =
false;
478 for (
unsigned i = 0; i < numConcat ; ++i)
479 if (SL->getStrTokenLoc(i).isMacroID()) {
484 S.
Diag(Element->getLocStart(),
485 diag::warn_concatenated_nsarray_literal)
496 Element->getLocStart(), Element);
508 ExprResult RValue = DefaultFunctionArrayLvalueConversion(ValueExpr);
513 ValueExpr = RValue.
get();
529 if (!StringWithUTF8StringMethod) {
534 BoxingMethod = NSStringDecl->lookupClassMethod(stringWithUTF8String);
535 if (!BoxingMethod && getLangOpts().DebuggerObjCLiteral) {
540 NSStringPointer, ReturnTInfo, NSStringDecl,
559 stringWithUTF8String, BoxingMethod))
562 StringWithUTF8StringMethod = BoxingMethod;
565 BoxingMethod = StringWithUTF8StringMethod;
566 BoxedType = NSStringPointer;
568 }
else if (ValueType->isBuiltinType()) {
576 dyn_cast<CharacterLiteral>(ValueExpr->
IgnoreParens())) {
579 switch (Char->getKind()) {
598 CheckForIntOverflow(ValueExpr);
603 BoxedType = NSNumberPointer;
605 if (!ET->getDecl()->isComplete()) {
606 Diag(Loc, diag::err_objc_incomplete_boxed_expression_type)
607 << ValueType << ValueExpr->getSourceRange();
612 ET->getDecl()->getIntegerType());
613 BoxedType = NSNumberPointer;
614 }
else if (ValueType->isObjCBoxableRecordType()) {
632 if (!ValueWithBytesObjCTypeMethod) {
640 BoxingMethod = NSValueDecl->lookupClassMethod(ValueWithBytesObjCType);
641 if (!BoxingMethod && getLangOpts().DebuggerObjCLiteral) {
648 ValueWithBytesObjCType,
669 Params.push_back(bytes);
679 Params.push_back(type);
686 ValueWithBytesObjCType, BoxingMethod))
689 ValueWithBytesObjCTypeMethod = BoxingMethod;
692 if (!ValueType.isTriviallyCopyableType(
Context)) {
693 Diag(Loc, diag::err_objc_non_trivially_copyable_boxed_expression_type)
694 << ValueType << ValueExpr->getSourceRange();
698 BoxingMethod = ValueWithBytesObjCTypeMethod;
699 BoxedType = NSValuePointer;
703 Diag(Loc, diag::err_objc_illegal_boxed_expression_type)
704 << ValueType << ValueExpr->getSourceRange();
708 DiagnoseUseOfDecl(BoxingMethod, Loc);
711 if (ValueType->isObjCBoxableRecordType()) {
713 ConvertedValueExpr = PerformCopyInitialization(IE, ValueExpr->
getExprLoc(),
720 ConvertedValueExpr = PerformCopyInitialization(IE,
SourceLocation(),
726 ValueExpr = ConvertedValueExpr.
get();
731 return MaybeBindToTemporary(BoxedExpr);
740 assert(!LangOpts.isSubscriptPointerArithmetic());
745 "base or index cannot have dependent type here");
752 IndexExpr = Result.
get();
755 Result = DefaultLvalueConversion(BaseExpr);
758 BaseExpr = Result.
get();
763 getterMethod, setterMethod, RB);
779 if (!ArrayWithObjectsMethod) {
783 if (!Method && getLangOpts().DebuggerObjCLiteral) {
800 Params.push_back(objects);
808 Params.push_back(cnt);
823 diag::note_objc_literal_method_param)
830 if (!Method->
parameters()[1]->getType()->isIntegerType()) {
834 diag::note_objc_literal_method_param)
842 ArrayWithObjectsMethod = Method;
845 QualType ObjectsType = ArrayWithObjectsMethod->parameters()[0]->getType();
850 Expr **ElementsBuffer = Elements.data();
851 for (
unsigned I = 0, N = Elements.size();
I != N; ++
I) {
858 ElementsBuffer[
I] = Converted.
get();
865 return MaybeBindToTemporary(
867 ArrayWithObjectsMethod, SR));
874 if (!NSDictionaryDecl) {
877 if (!NSDictionaryDecl) {
885 if (!DictionaryWithObjectsMethod) {
886 Selector Sel = NSAPIObj->getNSDictionarySelector(
888 ObjCMethodDecl *Method = NSDictionaryDecl->lookupClassMethod(Sel);
889 if (!Method && getLangOpts().DebuggerObjCLiteral) {
908 Params.push_back(objects);
916 Params.push_back(keys);
924 Params.push_back(cnt);
940 diag::note_objc_literal_method_param)
954 if (QIDNSCopying.isNull()) {
968 if (!QIDNSCopying.isNull())
977 diag::note_objc_literal_method_param)
985 QualType CountType = Method->parameters()[2]->getType();
989 Diag(Method->parameters()[2]->getLocation(),
990 diag::note_objc_literal_method_param)
997 DictionaryWithObjectsMethod = Method;
1000 QualType ValuesT = DictionaryWithObjectsMethod->parameters()[0]->getType();
1002 QualType KeysT = DictionaryWithObjectsMethod->parameters()[1]->getType();
1007 bool HasPackExpansions =
false;
1021 Element.Key = Key.
get();
1022 Element.Value = Value.
get();
1024 if (Element.EllipsisLoc.isInvalid())
1027 if (!Element.Key->containsUnexpandedParameterPack() &&
1028 !Element.Value->containsUnexpandedParameterPack()) {
1029 Diag(Element.EllipsisLoc,
1030 diag::err_pack_expansion_without_parameter_packs)
1032 Element.Value->getLocEnd());
1036 HasPackExpansions =
true;
1044 Context, Elements, HasPackExpansions, Ty,
1045 DictionaryWithObjectsMethod, SR));
1059 diag::err_incomplete_type_objc_at_encode,
1066 if (!NotEncodedT.
isNull())
1067 Diag(AtLoc, diag::warn_incomplete_encoded_type)
1068 << EncodedType << NotEncodedT;
1105 bool Warned =
false;
1108 if (MatchingMethodDecl == Method ||
1116 S.
Diag(AtLoc, diag::warning_multiple_selectors)
1122 S.
Diag(MatchingMethodDecl->
getLocation(), diag::note_method_declared_at)
1133 bool WarnMultipleSelectors) {
1134 if (!WarnMultipleSelectors ||
1137 bool Warned =
false;
1143 Method, InstMethList))
1149 Method, ClsMethList) || Warned)
1159 bool WarnMultipleSelectors) {
1167 Selector MatchedSel = OM->getSelector();
1170 Diag(SelLoc, diag::warn_undeclared_selector_with_typo)
1171 << Sel << MatchedSel
1175 Diag(SelLoc, diag::warn_undeclared_selector) << Sel;
1178 WarnMultipleSelectors);
1194 Diag(AtLoc, diag::err_arc_illegal_selector) <<
1223 Diag(ProtoLoc, diag::err_undeclared_protocol) << ProtocolId;
1279 bool isClassMessage,
1280 bool isSuperMessage) {
1281 assert(Method &&
"Must have a method");
1316 if (isSuperMessage) {
1319 return transferNullability(
1338 return transferNullability(ReceiverType);
1343 bool isClassMessage,
1344 bool isSuperMessage) {
1356 unsigned receiverNullabilityIdx = 0;
1358 receiverNullabilityIdx = 1 + static_cast<unsigned>(*nullability);
1360 unsigned resultNullabilityIdx = 0;
1362 resultNullabilityIdx = 1 + static_cast<unsigned>(*nullability);
1366 static const uint8_t
None = 0;
1367 static const uint8_t
NonNull = 1;
1370 static const uint8_t nullabilityMap[4][4] = {
1378 unsigned newResultNullabilityIdx
1379 = nullabilityMap[receiverNullabilityIdx][resultNullabilityIdx];
1380 if (newResultNullabilityIdx == resultNullabilityIdx)
1386 if (
auto attributed = dyn_cast<AttributedType>(resultType.
getTypePtr())) {
1387 resultType = attributed->getModifiedType();
1394 if (newResultNullabilityIdx > 0) {
1399 resultType, resultType);
1418 dyn_cast<ObjCCategoryImplDecl>(impl)) {
1419 iface = catImpl->getCategoryDecl();
1421 iface = impl->getClassInterface();
1431 for (
unsigned i = 0, e = overrides.size(); i != e; ++i) {
1452 SourceRange range = overridden->getReturnTypeSourceRange();
1455 loc = overridden->getLocation();
1456 Diag(loc, diag::note_related_result_type_explicit)
1500 bool isClassMessage,
bool isSuperMessage,
1505 if (!SelectorLocs.empty() && SelectorLocs.front().isValid())
1506 SelLoc = SelectorLocs.front();
1512 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
1513 if (Args[i]->isTypeDependent())
1525 Args[i] = result.
get();
1530 DiagID = diag::err_arc_method_not_found;
1532 DiagID = isClassMessage ? diag::warn_class_method_not_found
1533 : diag::warn_inst_method_not_found;
1538 DiagID = diag::error_method_not_found_with_typo;
1540 DiagID = isClassMessage ? diag::warn_class_method_not_found_with_typo
1541 : diag::warn_instance_method_not_found_with_typo;
1543 SourceRange SelectorRange(SelectorLocs.front(), SelectorLocs.back());
1545 Diag(SelLoc, DiagID)
1546 << Sel<< isClassMessage << MatchedSel
1549 Diag(SelLoc, DiagID) << Sel<< isClassMessage << MatchedSel;
1552 Diag(SelLoc, DiagID)
1553 << Sel << isClassMessage <<
SourceRange(SelectorLocs.front(),
1554 SelectorLocs.back());
1559 Diag(ThisClass->getLocation(), diag::note_receiver_class_declared);
1561 if (ThisClass->lookupClassMethod(Sel))
1562 Diag(RecRange.
getBegin(),diag::note_receiver_expr_here)
1564 ThisClass->getNameAsString());
1590 if (Args.size() < NumNamedArgs) {
1591 Diag(SelLoc, diag::err_typecheck_call_too_few_args)
1592 << 2 << NumNamedArgs << static_cast<unsigned>(Args.size());
1600 bool IsError =
false;
1601 for (
unsigned i = 0; i < NumNamedArgs; i++) {
1603 if (Args[i]->isTypeDependent())
1606 Expr *argExpr = Args[i];
1609 assert(argExpr &&
"CheckMessageArgumentTypes(): missing expression");
1614 !param->
hasAttr<CFConsumedAttr>())
1625 Args[i] = argE.
get();
1643 diag::err_call_incomplete_argument, argExpr))
1658 Args[i]->getType()->isBlockPointerType() &&
1662 Args[i] = arg.
get();
1669 for (
unsigned i = NumNamedArgs, e = Args.size(); i < e; ++i) {
1670 if (Args[i]->isTypeDependent())
1676 Args[i] = Arg.
get();
1680 if (Args.size() != NumNamedArgs) {
1681 Diag(Args[NumNamedArgs]->getLocStart(),
1682 diag::err_typecheck_call_too_many_args)
1683 << 2 << NumNamedArgs << static_cast<unsigned>(Args.size())
1686 Args.back()->getLocEnd());
1693 IsError |= CheckObjCMethodCall(
1694 Method, SelLoc, makeArrayRef(Args.data(), Args.size()));
1707 if (!method)
return false;
1710 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(receiver))
1722 if (
ObjCMethodDecl *method = iface->lookupMethod(sel, isInstance))
1727 if (
ObjCMethodDecl *method = iface->lookupPrivateMethod(sel, isInstance))
1732 for (
const auto *
I : objType->
quals())
1746 for (
const auto *PROTO : OPT->
quals()) {
1747 if ((MD = PROTO->lookupMethod(Sel, Instance))) {
1767 Diag(MemberLoc, diag::err_invalid_property_name)
1775 : BaseExpr->getSourceRange();
1777 diag::err_property_not_found_forward_class,
1778 MemberName, BaseRange))
1795 for (
const auto *
I : OPT->
quals())
1804 SuperLoc, SuperType);
1855 if (Setter && Setter->isImplicit() && Setter->isPropertyAccessor()
1862 diag::warn_property_access_suggest)
1863 << MemberName <<
QualType(OPT, 0) << PDecl->getName()
1868 if (Getter || Setter) {
1884 llvm::make_unique<DeclFilterCCC<ObjCPropertyDecl>>(),
1887 << MemberName <<
QualType(OPT, 0));
1890 TypoResult, MemberLoc,
1891 SuperLoc, SuperType, Super);
1900 diag::err_property_not_as_forward_class,
1901 MemberName, BaseExpr))
1905 diag::err_ivar_access_using_property_syntax_suggest)
1906 << MemberName <<
QualType(OPT, 0) << Ivar->getDeclName()
1911 Diag(MemberLoc, diag::err_property_not_found)
1914 Diag(Setter->getLocation(), diag::note_getter_unavailable)
1915 << MemberName << BaseExpr->getSourceRange();
1935 if (receiverNamePtr->
isStr(
"super")) {
1937 if (
auto classDecl = CurMethod->getClassInterface()) {
1938 SuperType =
QualType(classDecl->getSuperClassType(), 0);
1939 if (CurMethod->isInstanceMethod()) {
1940 if (SuperType.
isNull()) {
1942 Diag(receiverNameLoc, diag::error_root_class_cannot_use_super)
1943 << CurMethod->getClassInterface()->getIdentifier();
1953 receiverNameLoc, T,
true);
1964 Diag(receiverNameLoc, diag::err_expected_either) << tok::identifier
2004 if (Getter || Setter) {
2013 propertyNameLoc, receiverNameLoc, IFace);
2015 return ExprError(
Diag(propertyNameLoc, diag::err_property_not_found)
2029 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
2041 bool HasTrailingDot,
2061 if (!Method->getClassInterface()) {
2067 if (Method->getClassInterface()->lookupInstanceVariable(Name,
2112 if (Corrected.isKeyword()) {
2116 PDiag(diag::err_unknown_receiver_suggest) << Name);
2123 PDiag(diag::err_unknown_receiver_suggest) << Name);
2145 Diag(SuperLoc, diag::err_invalid_receiver_to_message_super);
2151 Diag(SuperLoc, diag::error_no_super_class_message)
2157 if (SuperTy.isNull()) {
2159 Diag(SuperLoc, diag::error_root_class_cannot_use_super)
2175 LBracLoc, SelectorLocs, RBracLoc, Args);
2182 SuperLoc, Sel,
nullptr,
2183 LBracLoc, SelectorLocs, RBracLoc, Args);
2188 bool isSuperReceiver,
2194 if (!ReceiverType.
isNull())
2199 Sel, Method, Loc, Loc, Loc, Args,
2214 if (refactor(Msg,*S.
NSAPIObj, ECommit)) {
2223 switch (Edit.
Kind) {
2256 bool Format =
false;
2270 if (!Format || NumArgs <= Idx)
2273 Expr *FormatExpr = Args[Idx];
2278 S.
Diag(FormatExpr->
getExprLoc(), diag::warn_objc_cdirective_format_string)
2328 Diag(Loc, diag::err_missing_open_square_message_send)
2333 if (!SelectorLocs.empty() && SelectorLocs.front().isValid())
2334 SelLoc = SelectorLocs.front();
2341 unsigned NumArgs = ArgsIn.size();
2342 Expr **Args = ArgsIn.data();
2343 assert(SuperLoc.
isInvalid() &&
"Message to super with dependent type");
2346 SelectorLocs,
nullptr, makeArrayRef(Args, NumArgs), RBracLoc,
2353 if (!ClassType || !(Class = ClassType->
getInterface())) {
2354 Diag(Loc, diag::err_invalid_receiver_class_message)
2358 assert(Class &&
"We don't know which class we're messaging?");
2369 ? diag::err_arc_receiver_forward_class
2370 : diag::warn_receiver_forward_class),
2394 unsigned NumArgs = ArgsIn.size();
2395 Expr **Args = ArgsIn.data();
2399 SuperLoc.
isValid(), LBracLoc, RBracLoc,
2406 diag::err_illegal_message_expr_incomplete_type))
2415 Diag(Loc, diag::warn_direct_initialize_call);
2423 Diag(Loc, diag::warn_direct_super_initialize_call);
2426 Diag(CurMeth->getLocation(), diag::note_method_declared_at)
2427 << CurMeth->getDeclName();
2439 ReceiverType, Sel, SelectorLocs,
2440 Method, makeArrayRef(Args, NumArgs),
2441 RBracLoc, isImplicit);
2444 ReceiverTypeInfo, Sel, SelectorLocs,
2445 Method, makeArrayRef(Args, NumArgs),
2446 RBracLoc, isImplicit);
2465 if (ReceiverType.
isNull())
2469 if (!ReceiverTypeInfo)
2474 nullptr, LBracLoc, SelectorLocs, RBracLoc,
2486 Sel, Method, Loc, Loc, Loc, Args,
2531 SuperLoc.
isValid()? SuperLoc : Receiver->getSourceRange();
2533 if (!SelectorLocs.empty() && SelectorLocs.front().isValid())
2534 SelLoc = SelectorLocs.front();
2539 Diag(Loc, diag::err_missing_open_square_message_send)
2554 Receiver = Result.
get();
2560 unsigned NumArgs = ArgsIn.size();
2561 Expr **Args = ArgsIn.data();
2562 assert(SuperLoc.
isInvalid() &&
"Message to super with dependent type");
2565 SelectorLocs,
nullptr, makeArrayRef(Args, NumArgs),
2566 RBracLoc, isImplicit);
2574 Receiver = Result.
get();
2575 ReceiverType = Receiver->
getType();
2588 Diag(Loc, diag::warn_bad_receiver_type)
2590 << Receiver->getSourceRange();
2602 ReceiverType = Receiver->
getType();
2606 diag::err_incomplete_receiver_type))
2611 Receiver = result.
get();
2612 ReceiverType = Receiver->
getType();
2641 Method = BestMethod;
2644 receiverIsIdLike)) {
2663 Diag(SelLoc, diag::warn_instance_method_on_class_found)
2673 Method = ClassDecl->lookupClassMethod(Sel);
2676 Method = ClassDecl->lookupPrivateClassMethod(Sel);
2694 if (
ID->getSuperClass())
2695 Diag(SelLoc, diag::warn_root_inst_method_not_found)
2702 Method = BestMethod;
2723 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 UnavailableAttr::IR_ARCForbiddenConversion))
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();
3819 bool CfToNs,
bool Diagnose) {
3820 QualType T = CfToNs ? SrcType : DestType;
3836 Diag(Loc, diag::err_objc_bridged_related_invalid_class) << RCId
3837 << SrcType << DestType;
3843 if (Target && isa<ObjCInterfaceDecl>(Target))
3844 RelatedClass = cast<ObjCInterfaceDecl>(Target);
3847 Diag(Loc, diag::err_objc_bridged_related_invalid_class_name) << RCId
3848 << SrcType << DestType;
3857 if (CfToNs && CMId) {
3862 Diag(Loc, diag::err_objc_bridged_related_known_method)
3863 << SrcType << DestType << Sel <<
false;
3871 if (!CfToNs && IMId) {
3873 InstanceMethod = RelatedClass->
lookupMethod(Sel,
true);
3874 if (!InstanceMethod) {
3876 Diag(Loc, diag::err_objc_bridged_related_known_method)
3877 << SrcType << DestType << Sel <<
true;
3889 Expr *&SrcExpr,
bool Diagnose) {
3894 if (!CfToNs && !NsToCf)
3902 ClassMethod, InstanceMethod, TDNDecl,
3910 std::string ExpressionString =
"[";
3912 ExpressionString +=
" ";
3916 Diag(Loc, diag::err_objc_bridged_related_known_method)
3917 << SrcType << DestType << ClassMethod->
getSelector() <<
false
3926 Expr *args[] = { SrcExpr };
3931 SrcExpr = msg.
get();
3937 if (InstanceMethod) {
3939 std::string ExpressionString;
3946 ExpressionString =
".";
3947 ExpressionString += PDecl->getNameAsString();
3948 Diag(Loc, diag::err_objc_bridged_related_known_method)
3949 << SrcType << DestType << InstanceMethod->
getSelector() <<
true
3952 if (ExpressionString.empty()) {
3954 ExpressionString =
" ";
3956 ExpressionString +=
"]";
3958 Diag(Loc, diag::err_objc_bridged_related_known_method)
3959 << SrcType << DestType << InstanceMethod->
getSelector() <<
true
3971 InstanceMethod,
None);
3972 SrcExpr = msg.
get();
3983 bool DiagnoseCFAudited,
3995 if (exprACTC == castACTC) {
4000 castType != castExprType) {
4006 if (
const ParenType *PT = dyn_cast<ParenType>(DT))
4007 QDT = PT->desugar();
4008 else if (
const TypeOfType *TP = dyn_cast<TypeOfType>(DT))
4009 QDT = TP->desugar();
4010 else if (
const AttributedType *AT = dyn_cast<AttributedType>(DT))
4011 QDT = AT->desugar();
4012 if (QDT != castType &&
4017 Diag(loc, diag::err_arc_nolifetime_behavior);
4039 switch (ARCCastChecker(
Context, exprACTC, castACTC,
false).Visit(castExpr)) {
4082 castExpr, exprACTC, CCK);
4099 castType =
cast->getTypeAsWritten();
4102 castRange =
cast->getTypeInfoAsWritten()->getTypeLoc().getSourceRange();
4103 castType =
cast->getTypeAsWritten();
4106 castType =
cast->getType();
4125 if (
ParenExpr *pe = dyn_cast<ParenExpr>(e)) {
4128 }
else if (
UnaryOperator *uo = dyn_cast<UnaryOperator>(e)) {
4132 sub->getValueKind(), sub->getObjectKind(),
4133 uo->getOperatorLoc());
4135 assert(!gse->isResultDependent());
4137 unsigned n = gse->getNumAssocs();
4140 for (
unsigned i = 0; i != n; ++i) {
4141 subTypes[i] = gse->getAssocTypeSourceInfo(i);
4142 Expr *sub = gse->getAssocExpr(i);
4143 if (i == gse->getResultIndex())
4149 gse->getControllingExpr(),
4151 gse->getDefaultLoc(),
4152 gse->getRParenLoc(),
4153 gse->containsUnexpandedParameterPack(),
4154 gse->getResultIndex());
4156 assert(isa<ImplicitCastExpr>(e) &&
"bad form of unbridged cast!");
4157 return cast<ImplicitCastExpr>(e)->getSubExpr();
4167 if (isa<ObjCObjectPointerType>(canCastType) &&
4173 return !ObjI->isArcWeakrefUnavailable();
4187 return ice->getSubExpr();
4199 SubExpr = SubResult.
get();
4206 bool MustConsume =
false;
4220 Diag(BridgeKeywordLoc, diag::err_arc_bridge_cast_wrong_kind)
4225 << SubExpr->getSourceRange()
4227 Diag(BridgeKeywordLoc, diag::note_arc_bridge)
4229 Diag(BridgeKeywordLoc, diag::note_arc_bridge_transfer)
4232 br ?
"CFBridgingRelease "
4233 :
"__bridge_transfer ");
4263 Diag(BridgeKeywordLoc, diag::err_arc_bridge_cast_wrong_kind)
4268 << SubExpr->getSourceRange()
4271 Diag(BridgeKeywordLoc, diag::note_arc_bridge)
4273 Diag(BridgeKeywordLoc, diag::note_arc_bridge_retained)
4276 br ?
"CFBridgingRetain " :
"__bridge_retained");
4283 Diag(LParenLoc, diag::err_arc_bridge_cast_incompatible)
4284 << FromType << T << Kind
4285 << SubExpr->getSourceRange()
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
ObjCMethodDecl * LookupMethodInQualifiedType(Selector Sel, const ObjCObjectPointerType *OPT, bool IsInstance)
LookupMethodInQualifiedType - Lookups up a method in protocol qualifier list of a qualified objective...
void setMethodParams(ASTContext &C, ArrayRef< ParmVarDecl * > Params, ArrayRef< SourceLocation > SelLocs=llvm::None)
Sets the method's parameters and selector source locations.
bool hasDefinition() const
Determine whether this class has been defined.
tokloc_iterator tokloc_begin() const
Defines the clang::ASTContext interface.
ObjCMethodDecl * lookupPrivateClassMethod(const Selector &Sel)
SourceLocation getEnd() const
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
CastKind getCastKind() const
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
CK_LValueToRValue - A conversion which causes the extraction of an r-value from the operand gl-value...
Name lookup found a set of overloaded functions that met the criteria.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
bool isSelfExpr(Expr *RExpr)
Private Helper predicate to check for 'self'.
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
Smart pointer class that efficiently represents Objective-C method names.
SelectorTable & getSelectorTable()
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
ImplementationControl getImplementationControl() const
Simple class containing the result of Sema::CorrectTypo.
ObjCMethodFamily getMethodFamily() const
ObjCInterfaceDecl * getClassInterface()
ExprResult ActOnSuperMessage(Scope *S, SourceLocation SuperLoc, Selector Sel, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args)
A cast other than a C-style cast.
ObjCMethodDecl * getCategoryClassMethod(Selector Sel) const
void* might be a normal C type, or it might a CF type.
DeclContext * getFunctionLevelDeclContext()
void getOverriddenMethods(SmallVectorImpl< const ObjCMethodDecl * > &Overridden) const
Return overridden methods for the given Method.
ObjCBridgeCastKind
The kind of bridging performed by the Objective-C bridge cast.
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
CompoundStmt * getSubStmt()
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
const LangOptions & getLangOpts() const
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
ObjCMessageKind
Describes the kind of message expression indicated by a message send that starts with an identifier...
NullabilityKind
Describes the nullability of a particular type.
static void diagnoseObjCARCConversion(Sema &S, SourceRange castRange, QualType castType, ARCConversionTypeClass castACTC, Expr *castExpr, Expr *realCast, ARCConversionTypeClass exprACTC, Sema::CheckedConversionKind CCK)
Bridging via __bridge, which does nothing but reinterpret the bits.
ObjCMethodDecl * LookupMethodInObjectType(Selector Sel, QualType Ty, bool IsInstance)
LookupMethodInType - Look up a method in an ObjCObjectType.
static bool CheckObjCBridgeNSCast(Sema &S, QualType castType, Expr *castExpr, bool &HadTheAttribute, bool warn)
tokloc_iterator tokloc_end() const
void addConst()
Add the const type qualifier to this QualType.
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
static ObjCMessageExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, SourceLocation LBracLoc, SourceLocation SuperLoc, bool IsInstanceSuper, QualType SuperType, Selector Sel, ArrayRef< SourceLocation > SelLocs, ObjCMethodDecl *Method, ArrayRef< Expr * > Args, SourceLocation RBracLoc, bool isImplicit)
Create a message send to super.
bool isRecordType() const
QualType getUnderlyingType() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
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
[ARC] Consumes a retainable object pointer that has just been produced, e.g.
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.
DiagnosticsEngine & Diags
ObjCMethodDecl * tryCaptureObjCSelf(SourceLocation Loc)
Try to capture an implicit reference to 'self'.
ObjCMethodDecl - Represents an instance or class method declaration.
CK_Dependent - A conversion which cannot yet be analyzed because either the expression or target type...
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...
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
An element in an Objective-C dictionary literal.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Represents a class type in Objective C.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
void setObjCConstantStringInterface(ObjCInterfaceDecl *Decl)
ObjCMethodFamily
A family of Objective-C methods.
bool isIdentifier() const
Predicate functions for querying what type of name this is.
static ObjCArrayLiteral * Create(const ASTContext &C, ArrayRef< Expr * > Elements, QualType T, ObjCMethodDecl *Method, SourceRange SR)
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
bool isCommitable() const
QualType getReturnType() const
void diagnoseARCUnbridgedCast(Expr *e)
Given that we saw an expression with the ARCUnbridgedCastTy placeholder type, complain bitterly...
bool CheckObjCBridgeRelatedConversions(SourceLocation Loc, QualType DestType, QualType SrcType, Expr *&SrcExpr, bool Diagnose=true)
ExprResult BuildClassMessageImplicit(QualType ReceiverType, bool isSuperReceiver, SourceLocation Loc, Selector Sel, ObjCMethodDecl *Method, MultiExprArg Args)
ExprResult PerformContextuallyConvertToObjCPointer(Expr *From)
PerformContextuallyConvertToObjCPointer - Perform a contextual conversion of the expression From to a...
ExprResult ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals.
static ObjCBridgeRelatedAttr * ObjCBridgeRelatedAttrFromType(QualType T, TypedefNameDecl *&TDNDecl)
bool isNull() const
Determine whether this is the empty selector.
CK_NullToPointer - Null pointer constant to pointer, ObjC pointer, or block pointer.
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...
CK_IntegralToPointer - Integral to pointer.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Values of this type can be null.
QualType getObjCNSStringType() const
CK_IntegralToBoolean - Integral to boolean.
bool checkInitMethod(ObjCMethodDecl *method, QualType receiverTypeIfCall)
Check whether the given method, which must be in the 'init' family, is a valid member of that family...
static Selector constructSetterSelector(IdentifierTable &Idents, SelectorTable &SelTable, const IdentifierInfo *Name)
Return the default setter selector for the given identifier.
bool followsCreateRule(const FunctionDecl *FD)
Selector getNullarySelector(IdentifierInfo *ID)
Represents the results of name lookup.
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
static ObjCInterfaceDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id, ObjCTypeParamList *typeParamList, ObjCInterfaceDecl *PrevDecl, SourceLocation ClassLoc=SourceLocation(), bool isInternal=false)
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
ExprResult MaybeConvertParenListExprToParenExpr(Scope *S, Expr *ME)
This is not an AltiVec-style cast or or C++ direct-initialization, so turn the ParenListExpr into a s...
ObjCContainerDecl - Represents a container for method declarations.
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
ExprResult BuildObjCNumericLiteral(SourceLocation AtLoc, Expr *Number)
BuildObjCNumericLiteral - builds an ObjCBoxedExpr AST node for the numeric literal expression...
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
static void applyCocoaAPICheck(Sema &S, const ObjCMessageExpr *Msg, unsigned DiagID, bool(*refactor)(const ObjCMessageExpr *, const NSAPI &, edit::Commit &))
Whether values of this type can be null is (explicitly) unspecified.
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
TypeDecl - Represents a declaration of a type.
A builtin binary operation expression such as "x + y" or "x <= y".
Selector getSelector() const
CanQualType PseudoObjectTy
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface...
CheckedConversionKind
The kind of conversion being performed.
std::string getNameAsString() const
getNameAsString - Get a human-readable name for the declaration, even if it is one of the special kin...
bool isDesignatedInitializerForTheInterface(const ObjCMethodDecl **InitMethod=nullptr) const
Returns true if the method selector resolves to a designated initializer in the class's interface...
const ObjCObjectType * getAsObjCInterfaceType() const
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
ObjCStringLiteral, used for Objective-C string literals i.e.
Values of this type can never be null.
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
Scope - A scope is a transient data structure that is used while parsing the program.
const ObjCMethodDecl * SelectorsForTypoCorrection(Selector Sel, QualType ObjectType=QualType())
void CheckTollFreeBridgeCast(QualType castType, Expr *castExpr)
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Represents an Objective-C protocol declaration.
ObjCInterfaceDecl * NSNumberDecl
The declaration of the Objective-C NSNumber class.
ExprResult BuildObjCDictionaryLiteral(SourceRange SR, MutableArrayRef< ObjCDictionaryElement > Elements)
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
Represents an ObjC class declaration.
Bridging via __bridge_transfer, which transfers ownership of an Objective-C pointer into ARC...
ObjCMethodDecl * getMethod() const
detail::InMemoryDirectory::const_iterator I
ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, QualType ¶mType)
Type-check an expression that's being passed to an __unknown_anytype parameter.
bool ExprNeedsCleanups
ExprNeedsCleanups - True if the current evaluation context requires cleanups to be run at its conclus...
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
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
CK_AnyPointerToBlockPointerCast - Casting any non-block pointer to a block pointer.
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)
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
ID
Defines the set of possible language-specific address spaces.
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...
CK_BitCast - A conversion which causes a bit pattern of one type to be reinterpreted as a bit pattern...
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)
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
bool CheckTollFreeBridgeStaticCast(QualType castType, Expr *castExpr, CastKind &Kind)
The result type of a method or function.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr.cast]), which uses the syntax (Type)expr.
QualType getObjCConstantStringInterface() const
Expr * getTrueExpr() const
QualType getWideCharType() const
Return the type of wide characters.
edit_iterator edit_end() const
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
void AddFixItHint(const FixItHint &Hint) const
ArrayRef< ParmVarDecl * > parameters() const
CK_CPointerToObjCPointerCast - Casting a C pointer kind to an Objective-C pointer.
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)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor...
SelectorTable & Selectors
bool QIdProtocolsAdoptObjCObjectProtocols(QualType QT, ObjCInterfaceDecl *IDecl)
QIdProtocolsAdoptObjCObjectProtocols - Checks that protocols in QT's qualified-id protocol list adopt...
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Encodes a location in the source.
Sugar for parentheses used when specifying types.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
const TemplateArgument * iterator
Represents typeof(type), a GCC extension.
Interfaces are the core concept in Objective-C for object oriented design.
void checkRetainCycles(ObjCMessageExpr *msg)
checkRetainCycles - Check whether an Objective-C message send might create an obvious retain cycle...
bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr, bool Diagnose=true)
bool isValid() const
Return true if this is a valid SourceLocation object.
ExprResult ActOnClassMessage(Scope *S, ParsedType Receiver, Selector Sel, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args)
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
bool makeUnavailableInSystemHeader(SourceLocation loc, UnavailableAttr::ImplicitReason reason)
makeUnavailableInSystemHeader - There is an error in the current context.
IdentifierTable & getIdentifierTable()
bool ObjCWarnForNoDesignatedInitChain
This starts true for a method marked as designated initializer and will be set to false if there is a...
SmallVectorImpl< Edit >::const_iterator edit_iterator
QualType withConst() const
bool isObjCClassOrClassKindOfType() const
Whether the type is Objective-C 'Class' or a __kindof type of an Class type, e.g., __kindof Class <NSCopying>.
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
ExprResult BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements)
ExprResult DefaultLvalueConversion(Expr *E)
bool CheckObjCARCUnavailableWeakConversion(QualType castType, QualType ExprType)
bool isLiteral(TokenKind K)
Return true if this is a "literal" kind, like a numeric constant, string, etc.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
Name lookup found an unresolvable value declaration and cannot yet complete.
The message is sent to 'super'.
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
bool isPropertyAccessor() const
ObjCProtocolExpr used for protocol expression in Objective-C.
Describes the kind of initialization being performed, along with location information for tokens rela...
ExprResult ActOnClassPropertyRefExpr(IdentifierInfo &receiverName, IdentifierInfo &propertyName, SourceLocation receiverNameLoc, SourceLocation propertyNameLoc)
static ExprResult CheckObjCCollectionLiteralElement(Sema &S, Expr *Element, QualType T, bool ArrayLiteral=false)
Check that the given expression is a valid element of an Objective-C collection literal.
bool FormatStringHasSArg(const StringLiteral *FExpr)
Represents one property declaration in an Objective-C interface.
std::string getAsString() const
Derive the full selector name (e.g.
TypedefNameDecl * getDecl() const
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=NotForRedeclaration)
Find the protocol with the given name, if any.
SourceLocation getBegin() const
QualType getReturnType() const
const T * castAs() const
Member-template castAs<specific type>.
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
ExprResult BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, QualType ReceiverType, SourceLocation SuperLoc, Selector Sel, ObjCMethodDecl *Method, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args, bool isImplicit=false)
Build an Objective-C class message expression.
No entity found met the criteria.
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
bool ObjCIsDesignatedInit
True when this is a method marked as a designated initializer.
bool ObjCShouldCallSuper
A flag that is set when parsing a method that must call super's implementation, such as -dealloc...
static QualType getBaseMessageSendResultType(Sema &S, QualType ReceiverType, ObjCMethodDecl *Method, bool isClassMessage, bool isSuperMessage)
Determine the result type of a message send based on the receiver type, method, and the kind of messa...
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
sema::FunctionScopeInfo * getCurFunction() const
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
ObjCBoxedExpr - used for generalized expression boxing.
SourceRange getSourceRange() const override LLVM_READONLY
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
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
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...
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
DeclarationName - The name of a declaration.
QualType getObjCProtoType() const
Retrieve the type of the Objective-C Protocol class.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
bool hasDefinition() const
Determine whether this protocol has a definition.
U cast(CodeGen::Address addr)
StringRef getString() const
Selector getSelector() const
bool ObjCWarnForNoInitDelegation
This starts true for a secondary initializer method and will be set to false if there is an invocatio...
CK_BlockPointerToObjCPointerCast - Casting a block pointer to an ObjC pointer.
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
[ARC] Reclaim a retainable object pointer object that may have been produced and autoreleased as part...
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.
[ARC] Produces a retainable object pointer so that it may be consumed, e.g.
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.
ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId) const
FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...
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.
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
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.
CK_NoOp - A conversion which does not affect the type other than (possibly) adding qualifiers...
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...
ARCConversionResult CheckObjCARCConversion(SourceRange castRange, QualType castType, Expr *&op, CheckedConversionKind CCK, bool Diagnose=true, bool DiagnoseCFAudited=false, BinaryOperatorKind Opc=BO_PtrMemD)
Checks for invalid conversions and casts between retainable pointers and other pointer kinds...
bool isConstQualified() const
Determine whether this type is const-qualified.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
static bool isObjCNSObjectType(QualType Ty)
Return true if this is an NSObject object with its NSObject attribute set.
Describes an entity that is being initialized.
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
void setType(QualType newType)
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
bool isIntegralType(ASTContext &Ctx) const
Determine whether this type is an integral type.
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