25#include "llvm/Support/ConvertUTF.h"
40 SemaRef.setFunctionHasBranchProtectedScope();
48 if (!DS->isSingleDecl())
50 diag::err_toomany_element_decls));
52 VarDecl *D = dyn_cast<VarDecl>(DS->getSingleDecl());
68 Expr *DeducedInit = &OpaqueId;
75 SemaRef.DiagnoseAutoDeductionFailure(D, DeducedInit);
83 if (!
SemaRef.inTemplateInstantiation()) {
94 Diag(
First->getBeginLoc(), diag::err_selector_element_not_lvalue)
95 <<
First->getSourceRange());
99 Diag(ForLoc, diag::err_selector_element_const_type)
100 << FirstType <<
First->getSourceRange();
105 return StmtError(
Diag(ForLoc, diag::err_selector_element_type)
106 << FirstType <<
First->getSourceRange());
112 CollectionExprResult =
SemaRef.ActOnFinishFullExpr(CollectionExprResult.
get(),
118 nullptr, ForLoc, RParenLoc);
135 collection = result.
get();
142 return Diag(forLoc, diag::err_collection_expr_type)
155 diag::err_arc_collection_forward,
160 }
else if (iface || !objectType->qual_empty()) {
162 &Context.Idents.get(
"countByEnumeratingWithState"),
163 &Context.Idents.get(
"objects"), &Context.Idents.get(
"count")};
164 Selector selector = Context.Selectors.getSelector(3, &selectorIdents[0]);
182 Diag(forLoc, diag::warn_collection_expr_type)
206 VarDecl *Var = cast_or_null<VarDecl>(Parm);
223 Diag(AtLoc, diag::err_objc_exceptions_disabled) <<
"@try";
228 Diag(AtLoc, diag::err_mixing_cxx_try_seh_try) << 1;
233 unsigned NumCatchStmts = CatchStmts.size();
235 NumCatchStmts, Finally);
257 return StmtError(
Diag(AtLoc, diag::err_objc_throw_expects_object)
268 Diag(AtLoc, diag::err_objc_exceptions_disabled) <<
"@throw";
273 Scope *AtCatchParent = CurScope;
275 AtCatchParent = AtCatchParent->
getParent();
277 return StmtError(
Diag(AtLoc, diag::err_rethrow_used_outside_catch));
287 operand = result.
get();
291 if (!
type->isDependentType() && !
type->isObjCObjectPointerType()) {
296 diag::err_incomplete_receiver_type))
297 return Diag(atLoc, diag::err_objc_synchronized_expects_object)
301 SemaRef.PerformContextuallyConvertToObjCPointer(operand);
305 return Diag(atLoc, diag::err_objc_synchronized_expects_object)
308 operand = result.
get();
310 return Diag(atLoc, diag::err_objc_synchronized_expects_object)
317 return SemaRef.ActOnFinishFullExpr(operand,
false);
325 SemaRef.setFunctionHasBranchProtectedScope();
332 SemaRef.setFunctionHasBranchProtectedScope();
342 Context.ObjCBuiltinIdTy, {},
364 ObjCObjectTL.setProtocolLAngleLoc(lAngleLoc);
365 ObjCObjectTL.setProtocolRAngleLoc(rAngleLoc);
366 for (
unsigned i = 0, n = protocols.size(); i != n; ++i)
367 ObjCObjectTL.setProtocolLoc(i, protocolLocs[i]);
387 BaseTypeInfo = Context.getTrivialTypeSourceInfo(T, Loc);
391 for (
unsigned i = 0, n = TypeArgs.size(); i != n; ++i) {
393 QualType TypeArg =
SemaRef.GetTypeFromParser(TypeArgs[i], &TypeArgInfo);
395 ActualTypeArgInfos.clear();
399 assert(TypeArgInfo &&
"No type source info?");
400 ActualTypeArgInfos.push_back(TypeArgInfo);
406 TypeArgsLAngleLoc, ActualTypeArgInfos, TypeArgsRAngleLoc,
410 ProtocolLocs, ProtocolRAngleLoc,
426 ResultTL = ObjCObjectPointerTL.getPointeeLoc();
431 if (OTPTL.getNumProtocols() > 0) {
432 assert(OTPTL.getNumProtocols() == Protocols.size());
433 OTPTL.setProtocolLAngleLoc(ProtocolLAngleLoc);
434 OTPTL.setProtocolRAngleLoc(ProtocolRAngleLoc);
435 for (
unsigned i = 0, n = Protocols.size(); i != n; ++i)
436 OTPTL.setProtocolLoc(i, ProtocolLocs[i]);
446 if (ObjCObjectTL.getNumTypeArgs() > 0) {
447 assert(ObjCObjectTL.getNumTypeArgs() == ActualTypeArgInfos.size());
448 ObjCObjectTL.setTypeArgsLAngleLoc(TypeArgsLAngleLoc);
449 ObjCObjectTL.setTypeArgsRAngleLoc(TypeArgsRAngleLoc);
450 for (
unsigned i = 0, n = ActualTypeArgInfos.size(); i != n; ++i)
451 ObjCObjectTL.setTypeArgTInfo(i, ActualTypeArgInfos[i]);
458 if (ObjCObjectTL.getNumProtocols() > 0) {
459 assert(ObjCObjectTL.getNumProtocols() == Protocols.size());
460 ObjCObjectTL.setProtocolLAngleLoc(ProtocolLAngleLoc);
461 ObjCObjectTL.setProtocolRAngleLoc(ProtocolRAngleLoc);
462 for (
unsigned i = 0, n = Protocols.size(); i != n; ++i)
463 ObjCObjectTL.setProtocolLoc(i, ProtocolLocs[i]);
471 if (ObjCObjectTL.getType() == T)
472 ObjCObjectTL.getBaseLoc().initializeFullCopy(BaseTypeInfo->
getTypeLoc());
474 ObjCObjectTL.getBaseLoc().initialize(Context, Loc);
487 if (!Protocols.empty()) {
489 Result = Context.applyObjCProtocolQualifiers(
Result, Protocols, HasError);
492 <<
SourceRange(ProtocolLAngleLoc, ProtocolRAngleLoc);
496 if (FailOnError &&
Result.isNull())
510 if (!objcObjectType || !objcObjectType->getInterface()) {
511 S.
Diag(loc, diag::err_objc_type_args_non_class) <<
type << typeArgsRange;
522 S.
Diag(loc, diag::err_objc_type_args_non_parameterized_class)
532 if (objcObjectType->isSpecialized()) {
533 S.
Diag(loc, diag::err_objc_type_args_specialized_class)
544 unsigned numTypeParams = typeParams->
size();
545 bool anyPackExpansions =
false;
546 for (
unsigned i = 0, n = typeArgs.size(); i != n; ++i) {
554 bool diagnosed =
false;
557 rangeToRemove =
attr.getLocalSourceRange();
558 if (
attr.getTypePtr()->getImmediateNullability()) {
559 typeArg =
attr.getTypePtr()->getModifiedType();
561 diag::err_objc_type_arg_explicit_nullability)
569 if (!rebuilding && !diagnosed) {
570 S.
Diag(qual.getBeginLoc(), diag::err_objc_type_arg_qualified)
579 finalTypeArgs.push_back(typeArg);
581 if (typeArg->
getAs<PackExpansionType>())
582 anyPackExpansions =
true;
586 if (!anyPackExpansions) {
587 if (i < numTypeParams) {
588 typeParam = typeParams->
begin()[i];
591 S.
Diag(loc, diag::err_objc_type_args_wrong_arity)
594 S.
Diag(objcClass->
getLocation(), diag::note_previous_decl) << objcClass;
609 assert(anyPackExpansions &&
"Too many arguments?");
618 if (typeArgObjC->isObjCIdType()) {
621 if (boundObjC->isObjCIdType())
630 diag::err_objc_type_arg_does_not_match_bound)
647 assert(anyPackExpansions &&
"Too many arguments?");
658 diag::err_objc_type_arg_does_not_match_bound)
681 diag::err_objc_type_arg_not_id_compatible)
691 if (!anyPackExpansions && finalTypeArgs.size() != numTypeParams) {
692 S.
Diag(loc, diag::err_objc_type_args_wrong_arity)
694 << (
unsigned)finalTypeArgs.size() << numTypeParams;
695 S.
Diag(objcClass->
getLocation(), diag::note_previous_decl) << objcClass;
712 bool FailOnError,
bool Rebuilding) {
715 if (!TypeArgs.empty()) {
719 FailOnError, Rebuilding);
720 if (FailOnError &&
Result.isNull())
724 if (!Protocols.empty()) {
726 Result = Context.applyObjCProtocolQualifiers(
Result, Protocols, HasError);
728 Diag(Loc, diag::err_invalid_protocol_qualifiers)
729 <<
SourceRange(ProtocolLAngleLoc, ProtocolRAngleLoc);
733 if (FailOnError &&
Result.isNull())
742 QualType T = Context.getObjCInstanceType();
744 return SemaRef.CreateParsedType(T, TInfo);
751struct RetainCycleOwner {
755 bool Indirect =
false;
757 RetainCycleOwner() =
default;
759 void setLocsFrom(
Expr *e) {
776 owner.Variable = var;
778 owner.setLocsFrom(ref);
786 switch (
cast->getCastKind()) {
788 case CK_LValueBitCast:
789 case CK_LValueToRValue:
790 case CK_ARCReclaimReturnedObject:
791 e =
cast->getSubExpr();
808 if (ref->isFreeIvar())
809 owner.setLocsFrom(ref);
810 owner.Indirect =
true;
815 VarDecl *var = dyn_cast<VarDecl>(ref->getDecl());
821 if (
MemberExpr *member = dyn_cast<MemberExpr>(e)) {
822 if (member->isArrow())
826 e = member->getBase();
833 pseudo->getSyntacticForm()->IgnoreParens());
839 if (!property->isRetaining() &&
840 !(property->getPropertyIvarDecl() &&
841 property->getPropertyIvarDecl()->getType().getObjCLifetime() ==
845 owner.Indirect =
true;
854 e =
const_cast<Expr *
>(
867struct FindCaptureVisitor : EvaluatedExprVisitor<FindCaptureVisitor> {
869 Expr *Capturer =
nullptr;
870 bool VarWillBeReased =
false;
872 FindCaptureVisitor(
ASTContext &Context, VarDecl *variable)
873 : EvaluatedExprVisitor<FindCaptureVisitor>(Context), Variable(variable) {}
875 void VisitDeclRefExpr(DeclRefExpr *ref) {
876 if (ref->getDecl() == Variable && !Capturer)
880 void VisitObjCIvarRefExpr(ObjCIvarRefExpr *ref) {
883 Visit(ref->getBase());
884 if (Capturer && ref->isFreeIvar())
888 void VisitBlockExpr(BlockExpr *block) {
890 if (block->getBlockDecl()->capturesVariable(Variable))
891 Visit(block->getBlockDecl()->getBody());
894 void VisitOpaqueValueExpr(OpaqueValueExpr *OVE) {
897 if (OVE->getSourceExpr())
898 Visit(OVE->getSourceExpr());
901 void VisitBinaryOperator(BinaryOperator *BinOp) {
902 if (!Variable || VarWillBeReased || BinOp->getOpcode() != BO_Assign)
904 Expr *LHS = BinOp->getLHS();
905 if (
const DeclRefExpr *DRE = dyn_cast_or_null<DeclRefExpr>(LHS)) {
906 if (DRE->getDecl() != Variable)
908 if (Expr *RHS = BinOp->getRHS()) {
909 RHS = RHS->IgnoreParenCasts();
910 std::optional<llvm::APSInt>
Value;
912 (RHS && (
Value = RHS->getIntegerConstantExpr(Context)) &&
924 assert(owner.Variable && owner.Loc.
isValid());
932 e = ME->getInstanceReceiver();
937 }
else if (
CallExpr *CE = dyn_cast<CallExpr>(e)) {
938 if (CE->getNumArgs() == 1) {
939 FunctionDecl *Fn = dyn_cast_or_null<FunctionDecl>(CE->getCalleeDecl());
942 if (FnI && FnI->
isStr(
"_Block_copy")) {
949 BlockExpr *block = dyn_cast<BlockExpr>(e);
953 FindCaptureVisitor visitor(S.
Context, owner.Variable);
955 return visitor.VarWillBeReased ?
nullptr : visitor.Capturer;
959 RetainCycleOwner &owner) {
961 assert(owner.Variable && owner.Loc.
isValid());
965 S.
Diag(owner.Loc, diag::note_arc_retain_cycle_owner)
966 << owner.Indirect << owner.Range;
976 str = str.ltrim(
'_');
977 if (str.starts_with(
"set"))
979 else if (str.starts_with(
"add")) {
981 if (sel.
getNumArgs() == 1 && str.starts_with(
"addOperationWithBlock"))
992static std::optional<int>
994 bool IsMutableArray = S.
NSAPIObj->isSubclassOfNSClass(
996 if (!IsMutableArray) {
1000 Selector Sel = Message->getSelector();
1002 std::optional<NSAPI::NSArrayMethodKind> MKOpt =
1003 S.
NSAPIObj->getNSArrayMethodKind(Sel);
1005 return std::nullopt;
1019 return std::nullopt;
1022 return std::nullopt;
1025static std::optional<int>
1027 bool IsMutableDictionary = S.
NSAPIObj->isSubclassOfNSClass(
1029 if (!IsMutableDictionary) {
1030 return std::nullopt;
1033 Selector Sel = Message->getSelector();
1035 std::optional<NSAPI::NSDictionaryMethodKind> MKOpt =
1036 S.
NSAPIObj->getNSDictionaryMethodKind(Sel);
1038 return std::nullopt;
1050 return std::nullopt;
1053 return std::nullopt;
1058 bool IsMutableSet = S.
NSAPIObj->isSubclassOfNSClass(
1061 bool IsMutableOrderedSet = S.
NSAPIObj->isSubclassOfNSClass(
1063 if (!IsMutableSet && !IsMutableOrderedSet) {
1064 return std::nullopt;
1067 Selector Sel = Message->getSelector();
1069 std::optional<NSAPI::NSSetMethodKind> MKOpt =
1070 S.
NSAPIObj->getNSSetMethodKind(Sel);
1072 return std::nullopt;
1087 return std::nullopt;
1091 if (!Message->isInstanceMessage()) {
1095 std::optional<int> ArgOpt;
1103 int ArgIndex = *ArgOpt;
1105 Expr *Arg = Message->getArg(ArgIndex)->IgnoreImpCasts();
1111 if (
DeclRefExpr *ArgRE = dyn_cast<DeclRefExpr>(Arg)) {
1112 if (ArgRE->isObjCSelfExpr()) {
1113 Diag(Message->getSourceRange().getBegin(),
1114 diag::warn_objc_circular_container)
1115 << ArgRE->getDecl() << StringRef(
"'super'");
1119 Expr *Receiver = Message->getInstanceReceiver()->IgnoreImpCasts();
1125 if (
DeclRefExpr *ReceiverRE = dyn_cast<DeclRefExpr>(Receiver)) {
1126 if (
DeclRefExpr *ArgRE = dyn_cast<DeclRefExpr>(Arg)) {
1127 if (ReceiverRE->getDecl() == ArgRE->getDecl()) {
1129 Diag(Message->getSourceRange().getBegin(),
1130 diag::warn_objc_circular_container)
1132 if (!ArgRE->isObjCSelfExpr()) {
1134 diag::note_objc_circular_container_declared_here)
1139 }
else if (
ObjCIvarRefExpr *IvarRE = dyn_cast<ObjCIvarRefExpr>(Receiver)) {
1141 if (IvarRE->getDecl() == IvarArgRE->getDecl()) {
1143 Diag(Message->getSourceRange().getBegin(),
1144 diag::warn_objc_circular_container)
1147 diag::note_objc_circular_container_declared_here)
1162 RetainCycleOwner owner;
1168 owner.Variable =
SemaRef.getCurMethodDecl()->getSelfDecl();
1175 for (
unsigned i = 0, e = msg->
getNumArgs(); i != e; ++i) {
1178 if (MD && MD->
parameters()[i]->hasAttr<NoEscapeAttr>())
1187 RetainCycleOwner owner;
1196 RetainCycleOwner Owner;
1217 if (!Literal || !Literal->isOrdinary()) {
1218 Diag(Arg->
getBeginLoc(), diag::err_cfstring_literal_not_string_constant)
1223 if (Literal->containsNonAsciiOrNull()) {
1224 StringRef String = Literal->getString();
1225 unsigned NumBytes = String.size();
1227 const llvm::UTF8 *FromPtr = (
const llvm::UTF8 *)String.data();
1228 llvm::UTF16 *ToPtr = &ToBuf[0];
1230 llvm::ConversionResult
Result =
1231 llvm::ConvertUTF8toUTF16(&FromPtr, FromPtr + NumBytes, &ToPtr,
1232 ToPtr + NumBytes, llvm::strictConversion);
1234 if (
Result != llvm::conversionOK)
1248 false, lbrac,
Method->getSourceRange(),
1260 DC = CatD->getClassInterface();
1267 Ident_NSError =
SemaRef.PP.getIdentifierInfo(
"NSError");
1269 return Ident_NSError;
1275 "The next DeclContext should be lexically contained in the current one.");
1286 assert(ObjCCtx ==
SemaRef.CurContext &&
"Mismatch of container contexts");
1287 SemaRef.OriginalLexicalContext = ObjCCtx;
1293 SemaRef.OriginalLexicalContext =
nullptr;
1302 return cast_or_null<ObjCProtocolDecl>(D);
1318 Context.hasSameUnqualifiedType(FromType, ToType))
1359 bool IncompatibleObjC;
1360 if (Context.typesAreCompatible(FromPointee, ToPointee))
1361 FromPointee = ToPointee;
1362 else if (!
SemaRef.isObjCPointerConversion(FromPointee, ToPointee, FromPointee,
1368 FromPointee = Context.getQualifiedType(FromPointee, FromQuals);
1369 ConvertedType = Context.getPointerType(FromPointee);
1378 if (T->isIntegralOrEnumerationType())
1383 const RecordType *RecordTy = T->getAsCanonical<RecordType>();
1384 if (!RecordTy && (T->isObjCObjectPointerType() || T->isVoidPointerType()))
1395 Diag(FromE->
getExprLoc(), diag::err_objc_subscript_type_conversion) << T;
1401 diag::err_objc_index_incomplete_class_type,
1407 int NoIntegrals = 0, NoObjCIdPointers = 0;
1411 ->getDefinitionOrSelf()
1412 ->getVisibleConversionFunctions()) {
1414 dyn_cast<CXXConversionDecl>(D->getUnderlyingDecl())) {
1415 QualType CT = Conversion->getConversionType().getNonReferenceType();
1418 ConversionDecls.push_back(Conversion);
1421 ConversionDecls.push_back(Conversion);
1425 if (NoIntegrals == 1 && NoObjCIdPointers == 0)
1427 if (NoIntegrals == 0 && NoObjCIdPointers == 1)
1429 if (NoIntegrals == 0 && NoObjCIdPointers == 0) {
1431 Diag(FromE->
getExprLoc(), diag::err_objc_subscript_type_conversion)
1435 Diag(FromE->
getExprLoc(), diag::err_objc_multiple_subscript_type_conversion)
1437 for (
unsigned int i = 0; i < ConversionDecls.size(); i++)
1438 Diag(ConversionDecls[i]->getLocation(),
1439 diag::note_conv_function_declared_at);
1446 auto IdLoc =
SemaRef.PP.getPragmaARCCFCodeAuditedInfo();
1447 if (!IdLoc.getLoc().isValid())
1451 if (D->
hasAttr<CFAuditedTransferAttr>() ||
1452 D->
hasAttr<CFUnknownTransferAttr>())
1458 D->
addAttr(CFAuditedTransferAttr::CreateImplicit(Context, Info));
1472 if (
auto bridgeAttr = RD->
getAttr<ObjCBridgeAttr>())
1473 bridgedType = bridgeAttr->getBridgedType();
1474 else if (
auto bridgeAttr = RD->
getAttr<ObjCBridgeMutableAttr>())
1475 bridgedType = bridgeAttr->getBridgedType();
1497 if (AllowNSAttributedString &&
1498 ClsName == &
getASTContext().Idents.get(
"NSAttributedString"))
1525 if (
const auto *VD = dyn_cast<ObjCIvarDecl>(D)) {
1527 S.
Diag(AL.
getLoc(), diag::warn_iboutlet_object_type)
1528 << AL << VD->getType() << 0;
1531 }
else if (
const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
1533 S.
Diag(AL.
getLoc(), diag::warn_iboutlet_object_type)
1534 << AL << PD->getType() << 1;
1538 S.
Diag(AL.
getLoc(), diag::warn_attribute_iboutlet) << AL;
1557 Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
1570 Context.Idents.get(
"NSObject"), AL.
getLoc(),
1573 Diag(AL.
getLoc(), diag::err_iboutletcollection_type) <<
"NSObject";
1581 QTLoc = Context.getTrivialTypeSourceInfo(QT, AL.
getLoc());
1589 ? diag::err_iboutletcollection_builtintype
1590 : diag::err_iboutletcollection_type)
1595 D->
addAttr(::new (Context) IBOutletCollectionAttr(Context, AL, QTLoc));
1600 Diag(AL.
getLoc(), diag::err_objc_attr_protocol_requires_definition)
1612 Diag(AL.
getLoc(), diag::err_objc_direct_on_protocol) <<
false;
1619 Diag(AL.
getLoc(), diag::warn_objc_direct_ignored) << AL;
1627 Diag(AL.
getLoc(), diag::warn_objc_direct_ignored) << AL;
1634 Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
1640 ObjCMethodFamilyAttr::FamilyKind F;
1641 if (!ObjCMethodFamilyAttr::ConvertStrToFamilyKind(
1643 Diag(IL->
getLoc(), diag::warn_attribute_type_not_supported)
1648 if (F == ObjCMethodFamilyAttr::OMF_init &&
1649 !M->getReturnType()->isObjCObjectPointerType()) {
1650 Diag(M->getLocation(), diag::err_init_method_bad_return_type)
1651 << M->getReturnType();
1661 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
1662 QualType T = TD->getUnderlyingType();
1663 if (!T->isCARCBridgableType()) {
1664 Diag(TD->getLocation(), diag::err_nsobject_attribute);
1667 }
else if (
const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
1669 if (!T->isCARCBridgableType()) {
1670 Diag(PD->getLocation(), diag::err_nsobject_attribute);
1686 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
1687 QualType T = TD->getUnderlyingType();
1688 if (!T->isObjCObjectPointerType()) {
1689 Diag(TD->getLocation(), diag::warn_ptr_independentclass_attribute);
1702 Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
1708 BlocksAttr::BlockType
type;
1709 if (!BlocksAttr::ConvertStrToBlockType(II->
getName(),
type)) {
1710 Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
1714 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
1716 Diag(AL.
getLoc(), diag::err_block_not_allowed_on)
1717 << diag::NotAllowedBlockVarReason::RegisterVariable;
1721 if (!VD->hasLocalStorage()) {
1722 if (VD->isStaticLocal())
1723 Diag(AL.
getLoc(), diag::err_block_not_allowed_on)
1724 << diag::NotAllowedBlockVarReason::StaticLocalVariable;
1725 else if (VD->isStaticDataMember())
1726 Diag(AL.
getLoc(), diag::err_block_not_allowed_on)
1727 << diag::NotAllowedBlockVarReason::CppStaticDataMember;
1729 Diag(AL.
getLoc(), diag::err_block_not_allowed_on)
1730 << diag::NotAllowedBlockVarReason::NonlocalVariable;
1736 Diag(AL.
getLoc(), diag::err_block_not_allowed_on)
1737 << diag::NotAllowedBlockVarReason::ObjCInstanceVariable;
1767 bool IsTemplateInstantiation) {
1773 diag::warn_ns_attribute_wrong_parameter_type,
1784 ((IsTemplateInstantiation &&
getLangOpts().ObjCAutoRefCount)
1785 ? diag::err_ns_attribute_wrong_parameter_type
1786 : diag::warn_ns_attribute_wrong_parameter_type),
1792 diag::warn_ns_attribute_wrong_parameter_type,
1801 case ParsedAttr::AT_CFConsumed:
1802 case ParsedAttr::AT_CFReturnsRetained:
1803 case ParsedAttr::AT_CFReturnsNotRetained:
1805 case ParsedAttr::AT_OSConsumesThis:
1806 case ParsedAttr::AT_OSConsumed:
1807 case ParsedAttr::AT_OSReturnsRetained:
1808 case ParsedAttr::AT_OSReturnsNotRetained:
1809 case ParsedAttr::AT_OSReturnsRetainedOnZero:
1810 case ParsedAttr::AT_OSReturnsRetainedOnNonZero:
1812 case ParsedAttr::AT_NSConsumesSelf:
1813 case ParsedAttr::AT_NSConsumed:
1814 case ParsedAttr::AT_NSReturnsRetained:
1815 case ParsedAttr::AT_NSReturnsNotRetained:
1816 case ParsedAttr::AT_NSReturnsAutoreleased:
1819 llvm_unreachable(
"Wrong argument supplied");
1828 Diag(Loc, diag::warn_ns_attribute_wrong_return_type)
1829 <<
"'ns_returns_retained'" << 0 << 0;
1835 const auto *PVD = dyn_cast<ParmVarDecl>(D);
1847 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
1848 ReturnType = MD->getReturnType();
1850 (AL.
getKind() == ParsedAttr::AT_NSReturnsRetained)) {
1852 }
else if (
const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
1853 ReturnType = PD->getType();
1854 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
1855 ReturnType = FD->getReturnType();
1856 }
else if (
const auto *Param = dyn_cast<ParmVarDecl>(D)) {
1863 if (ReturnType.
isNull()) {
1874 llvm_unreachable(
"invalid ownership attribute");
1875 case ParsedAttr::AT_NSReturnsRetained:
1876 case ParsedAttr::AT_NSReturnsAutoreleased:
1877 case ParsedAttr::AT_NSReturnsNotRetained:
1881 case ParsedAttr::AT_OSReturnsRetained:
1882 case ParsedAttr::AT_OSReturnsNotRetained:
1883 case ParsedAttr::AT_CFReturnsRetained:
1884 case ParsedAttr::AT_CFReturnsNotRetained:
1890 << ExpectedDeclKind;
1896 unsigned ParmDiagID = 2;
1899 llvm_unreachable(
"invalid ownership attribute");
1900 case ParsedAttr::AT_NSReturnsRetained:
1905 case ParsedAttr::AT_NSReturnsAutoreleased:
1906 case ParsedAttr::AT_NSReturnsNotRetained:
1911 case ParsedAttr::AT_CFReturnsRetained:
1912 case ParsedAttr::AT_CFReturnsNotRetained:
1917 case ParsedAttr::AT_OSReturnsRetained:
1918 case ParsedAttr::AT_OSReturnsNotRetained:
1931 << AL << ParmDiagID << AL.
getRange();
1940 << AL << SubjectKind << Cf << AL.
getRange();
1947 llvm_unreachable(
"invalid ownership attribute");
1948 case ParsedAttr::AT_NSReturnsAutoreleased:
1951 case ParsedAttr::AT_CFReturnsNotRetained:
1954 case ParsedAttr::AT_NSReturnsNotRetained:
1957 case ParsedAttr::AT_CFReturnsRetained:
1960 case ParsedAttr::AT_NSReturnsRetained:
1963 case ParsedAttr::AT_OSReturnsRetained:
1966 case ParsedAttr::AT_OSReturnsNotRetained:
1973 const int EP_ObjCMethod = 1;
1974 const int EP_ObjCProperty = 2;
2002 if (
const auto *PDecl = dyn_cast_if_present<ObjCProtocolDecl>(DC)) {
2005 Diag(PDecl->getLocation(), diag::note_protocol_decl);
2025 Attr.isArgIdent(0) ?
Attr.getArgAsIdent(0) :
nullptr;
2029 if (
Attr.isArgExpr(0) &&
Attr.getArgAsExpr(0))
2030 Loc =
Attr.getArgAsExpr(0)->getBeginLoc();
2032 Diag(Loc, diag::err_nserrordomain_invalid_decl) << 0;
2042 Diag(IdentLoc->
getLoc(), diag::err_nserrordomain_invalid_decl)
2060 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
2062 Diag(AL.
getLoc(), diag::err_objc_attr_typedef_not_id) << AL;
2067 QualType T = TD->getUnderlyingType();
2068 if (!T->isVoidPointerType()) {
2069 Diag(AL.
getLoc(), diag::err_objc_attr_typedef_not_void_pointer);
2093 if (!RelatedClass) {
2102 getASTContext(), AL, RelatedClass, ClassMethod, InstanceMethod));
2118 if (
auto *CatDecl = dyn_cast<ObjCCategoryDecl>(Ctx))
2119 IFace = CatDecl->getClassInterface();
2132 StringRef MetaDataName;
2133 if (!
SemaRef.checkStringLiteralArgumentAttr(AL, 0, MetaDataName))
2144 bool notify =
false;
2146 auto *RD = dyn_cast<RecordDecl>(D);
2147 if (RD && RD->getDefinition()) {
2148 RD = RD->getDefinition();
2153 ObjCBoxableAttr *BoxableAttr =
2155 RD->addAttr(BoxableAttr);
2160 L->AddedAttributeToRecord(BoxableAttr, RD);
2179 Diag(AL.
getLoc(), diag::err_objc_precise_lifetime_bad_type) << QT;
2193 "didn't infer lifetime for non-dependent type?");
2202 Diag(AL.
getLoc(), diag::warn_objc_precise_lifetime_meaningless)
2212 bool DiagnoseFailure) {
2215 if (DiagnoseFailure) {
2216 S.
Diag(VD->
getBeginLoc(), diag::warn_ignored_objc_externally_retained)
2233 if (DiagnoseFailure) {
2234 S.
Diag(VD->
getBeginLoc(), diag::warn_ignored_objc_externally_retained)
2249 if (
auto *VD = dyn_cast<VarDecl>(D)) {
2251 if (!VD->hasLocalStorage()) {
2252 Diag(D->
getBeginLoc(), diag::warn_ignored_objc_externally_retained) << 0;
2265 unsigned NumParams =
2267 for (
unsigned I = 0; I != NumParams; ++I) {
2287 SemaRef.getFormatStringInfo(Format->getFormatIdx(), Format->getFirstArg(),
2288 false,
true, &FSI)) {
2301 bool Format =
false;
2313 if (!Format || NumArgs <= Idx)
2315 const Expr *FormatExpr = Args[Idx];
2316 if (
const CStyleCastExpr *CSCE = dyn_cast<CStyleCastExpr>(FormatExpr))
2317 FormatExpr = CSCE->getSubExpr();
2326 if (
SemaRef.FormatStringHasSArg(FormatString)) {
2327 Diag(FormatExpr->
getExprLoc(), diag::warn_objc_cdirective_format_string)
2342 if (
const auto *OVE = dyn_cast<OpaqueValueExpr>(Ignored))
2343 Ignored = OVE->getSourceExpr();
2357 Expr *Element,
unsigned ElementKind) {
2359 if (
auto ICE = dyn_cast<ImplicitCastExpr>(Element)) {
2360 if (ICE->getCastKind() == CK_BitCast &&
2362 Element = ICE->getSubExpr();
2369 TargetElementType, ElementResult,
false,
false))) {
2370 S.
Diag(Element->
getBeginLoc(), diag::warn_objc_collection_literal_element)
2371 << ElementType << ElementKind << TargetElementType
2375 if (
auto ArrayLiteral = dyn_cast<ObjCArrayLiteral>(Element))
2377 else if (
auto DictionaryLiteral = dyn_cast<ObjCDictionaryLiteral>(Element))
2392 if (TargetObjCPtr->isUnspecialized() ||
2393 TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl() !=
2398 if (TypeArgs.size() != 1)
2401 QualType TargetElementType = TypeArgs[0];
2402 for (
unsigned I = 0, N = ArrayLiteral->
getNumElements(); I != N; ++I) {
2417 if (TargetObjCPtr->isUnspecialized() ||
2418 TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl() !=
2423 if (TypeArgs.size() != 2)
2426 QualType TargetKeyType = TypeArgs[0];
2427 QualType TargetObjectType = TypeArgs[1];
2428 for (
unsigned I = 0, N = DictionaryLiteral->
getNumElements(); I != N; ++I) {
Defines the clang::Preprocessor interface.
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs.
This file declares semantic analysis for Objective-C.
Defines the Objective-C statement AST node classes.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Attr - This represents one attribute.
SourceRange getRange() const
bool isRegularKeywordAttribute() const
SourceLocation getLoc() const
Type source information for an attributed type.
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
bool capturesVariable(const VarDecl *var) const
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
const BlockDecl * getBlockDecl() const
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr....
Represents a C++ conversion function within a class.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
A reference to a declared variable, function, enum, etc.
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Decl - This represents one declaration (or definition), e.g.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool isInvalidDecl() const
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
SourceLocation getLocation() const
DeclContext * getDeclContext()
SourceLocation getBeginLoc() const LLVM_READONLY
The name of a declaration.
SourceLocation getBeginLoc() const LLVM_READONLY
TypeSourceInfo * getTypeSourceInfo() const
This represents one expression.
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language.
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
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.
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Represents a function declaration or definition.
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
StringRef getName() const
Return the actual identifier string.
A simple pair of identifier info and location.
SourceLocation getLoc() const
IdentifierInfo * getIdentifierInfo() const
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
Represents the results of name lookup.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
@ ClassId_NSMutableOrderedSet
@ ClassId_NSMutableDictionary
NSSetMethodKind
Enumerates the NSMutableSet/NSOrderedSet methods used to apply some checks.
@ NSOrderedSet_setObjectAtIndex
@ NSOrderedSet_replaceObjectAtIndexWithObject
@ NSOrderedSet_setObjectAtIndexedSubscript
@ NSOrderedSet_insertObjectAtIndex
NSDictionaryMethodKind
Enumerates the NSDictionary/NSMutableDictionary methods used to generate literals and to apply some c...
@ NSMutableDict_setValueForKey
@ NSMutableDict_setObjectForKey
@ NSMutableDict_setObjectForKeyedSubscript
NSArrayMethodKind
Enumerates the NSArray/NSMutableArray methods used to generate literals and to apply some checks.
@ NSMutableArr_setObjectAtIndexedSubscript
@ NSMutableArr_insertObjectAtIndex
@ NSMutableArr_replaceObjectAtIndex
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
ObjCStringFormatFamily getObjCFStringFormattingFamily() const
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp,...
Expr * getElement(unsigned Index)
getElement - Return the Element at the specified index.
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c array literal.
Represents Objective-C's @catch statement.
Represents Objective-C's @finally statement.
Represents Objective-C's @synchronized statement.
Represents Objective-C's @throw statement.
static ObjCAtTryStmt * Create(const ASTContext &Context, SourceLocation atTryLoc, Stmt *atTryStmt, Stmt **CatchStmts, unsigned NumCatchStmts, Stmt *atFinallyStmt)
Represents Objective-C's @autoreleasepool Statement.
ObjCCategoryDecl - Represents a category declaration.
ObjCContainerDecl - Represents a container for method declarations.
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
Represents Objective-C's collection statement.
Represents an ObjC class declaration.
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
ObjCMethodDecl * lookupInstanceMethod(Selector Sel) const
Lookup an instance method for a given selector.
ObjCMethodDecl * lookupPrivateMethod(const Selector &Sel, bool Instance=true) const
Lookup a method in the classes implementation hierarchy.
void setHasDesignatedInitializers()
Indicate that this interface decl contains at least one initializer marked with the 'objc_designated_...
ObjCIvarDecl - Represents an ObjC instance variable.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
An expression that sends a message to the given Objective-C object or class.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
SourceLocation getSuperLoc() const
Retrieve the location of the 'super' keyword for a class or instance message to 'super',...
Selector getSelector() const
@ SuperInstance
The receiver is the instance of the superclass object.
@ Instance
The receiver is an object instance.
bool isInstanceMessage() const
Determine whether this is an instance message to either a computed object or to super.
const ObjCMethodDecl * getMethodDecl() const
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
unsigned getNumArgs() const
Return the number of actual arguments in this message, not counting the receiver.
ObjCMethodDecl - Represents an instance or class method declaration.
ImplicitParamDecl * getSelfDecl() const
ArrayRef< ParmVarDecl * > parameters() const
Wraps an ObjCPointerType with source location information.
void setStarLoc(SourceLocation Loc)
Represents a pointer to an Objective C object.
ArrayRef< QualType > getTypeArgs() const
Retrieve the type arguments for this type.
void setHasBaseTypeAsWritten(bool HasBaseType)
Represents one property declaration in an Objective-C interface.
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
ObjCPropertyDecl * getExplicitProperty() const
const Expr * getBase() const
bool isImplicitProperty() const
SourceLocation getLocation() const
bool isSuperReceiver() const
Represents an Objective-C protocol declaration.
The basic abstraction for the target Objective-C runtime.
bool allowsDirectDispatch() const
Does this runtime supports direct dispatch.
ObjCStringLiteral, used for Objective-C string literals i.e.
Represents the declaration of an Objective-C type parameter.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
unsigned size() const
Determine the number of type parameters in this list.
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Represents a parameter to a function.
ParsedAttr - Represents a syntactic attribute.
IdentifierLoc * getArgAsIdent(unsigned Arg) const
bool hasParsedType() const
const ParsedType & getTypeArg() const
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this attribute.
bool isArgIdent(unsigned Arg) const
bool isUsedAsTypeAttr() const
AttributeCommonInfo::Kind getKind() const
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
A (possibly-)qualified type.
QualType withConst() const
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
bool isConstQualified() const
Determine whether this type is const-qualified.
The collection of all-type qualifiers we support.
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
bool compatiblyIncludes(Qualifiers other, const ASTContext &Ctx) const
Determines if these qualifiers compatibly include another set.
ObjCLifetime getObjCLifetime() const
Qualifiers withoutObjCLifetime() const
std::string getAsString() const
void setObjCLifetime(ObjCLifetime type)
Represents a struct/union/class.
Scope - A scope is a transient data structure that is used while parsing the program.
bool isAtCatchScope() const
isAtCatchScope - Return true if this scope is @catch.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
Smart pointer class that efficiently represents Objective-C method names.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
bool isUnarySelector() const
unsigned getNumArgs() const
A generic diagnostic builder for errors which may or may not be deferred.
ASTContext & getASTContext() const
const LangOptions & getLangOpts() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
bool isCFError(RecordDecl *D)
void ActOnObjCReenterContainerContext(ObjCContainerDecl *ObjCCtx)
void ActOnObjCTemporaryExitContainerContext(ObjCContainerDecl *ObjCCtx)
Invoked when we must temporarily exit the objective-c container scope for parsing/looking-up C constr...
void handleRuntimeName(Decl *D, const ParsedAttr &AL)
void handleNSObject(Decl *D, const ParsedAttr &AL)
bool isValidOSObjectOutParameter(const Decl *D)
ObjCMethodDecl * ValueWithBytesObjCTypeMethod
The declaration of the valueWithBytes:objCType: method.
StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, Stmt *First, Expr *collection, SourceLocation RParenLoc)
StmtResult FinishObjCForCollectionStmt(Stmt *ForCollection, Stmt *Body)
FinishObjCForCollectionStmt - Attach the body to a objective-C foreach statement.
void handleNSErrorDomain(Decl *D, const ParsedAttr &Attr)
void handleXReturnsXRetainedAttr(Decl *D, const ParsedAttr &AL)
QualType BuildObjCTypeParamType(const ObjCTypeParamDecl *Decl, SourceLocation ProtocolLAngleLoc, ArrayRef< ObjCProtocolDecl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc, bool FailOnError=false)
Build an Objective-C type parameter type.
TypeResult actOnObjCTypeArgsAndProtocolQualifiers(Scope *S, SourceLocation Loc, ParsedType BaseType, SourceLocation TypeArgsLAngleLoc, ArrayRef< ParsedType > TypeArgs, SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc, ArrayRef< Decl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc)
Build a specialized and/or protocol-qualified Objective-C type.
void checkArrayLiteral(QualType TargetType, ObjCArrayLiteral *ArrayLiteral)
Check an Objective-C array literal being converted to the given target type.
void handleExternallyRetainedAttr(Decl *D, const ParsedAttr &AL)
ObjCSubscriptKind CheckSubscriptingKind(Expr *FromE)
CheckSubscriptingKind - This routine decide what type of indexing represented by "FromE" is being don...
IdentifierInfo * getNSErrorIdent()
Retrieve the identifier "NSError".
StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SynchExpr, Stmt *SynchBody)
ParsedType ActOnObjCInstanceType(SourceLocation Loc)
The parser has parsed the context-sensitive type 'instancetype' in an Objective-C message declaration...
void handleMethodFamilyAttr(Decl *D, const ParsedAttr &AL)
void handleIndependentClass(Decl *D, const ParsedAttr &AL)
ObjCInterfaceDecl * NSArrayDecl
The declaration of the Objective-C NSArray class.
RecordDecl * CFError
The struct behind the CFErrorRef pointer.
void handleIBOutlet(Decl *D, const ParsedAttr &AL)
void handleReturnsInnerPointerAttr(Decl *D, const ParsedAttr &Attrs)
bool isObjCWritebackConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
Determine whether this is an Objective-C writeback conversion, used for parameter passing when perfor...
void CheckObjCCircularContainer(ObjCMessageExpr *Message)
Check whether receiver is mutable ObjC container which attempts to add itself into the container.
void adornBoolConversionDiagWithTernaryFixit(const Expr *SourceExpr, const Sema::SemaDiagnosticBuilder &Builder)
void handleSuppresProtocolAttr(Decl *D, const ParsedAttr &AL)
ObjCInterfaceDecl * NSNumberDecl
The declaration of the Objective-C NSNumber class.
StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, MultiStmtArg Catch, Stmt *Finally)
void handleOwnershipAttr(Decl *D, const ParsedAttr &AL)
ObjCInterfaceDecl * NSValueDecl
The declaration of the Objective-C NSValue class.
bool isSignedCharBool(QualType Ty)
void handleBlocksAttr(Decl *D, const ParsedAttr &AL)
ObjCInterfaceDecl * NSStringDecl
The declaration of the Objective-C NSString class.
StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
void ActOnObjCContainerFinishDefinition()
ObjCMethodDecl * StringWithUTF8StringMethod
The declaration of the stringWithUTF8String: method.
TypeResult actOnObjCProtocolQualifierType(SourceLocation lAngleLoc, ArrayRef< Decl * > protocols, ArrayRef< SourceLocation > protocolLocs, SourceLocation rAngleLoc)
Build a an Objective-C protocol-qualified 'id' type where no base type was specified.
StmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw)
void handleBridgeMutableAttr(Decl *D, const ParsedAttr &AL)
Sema::RetainOwnershipKind parsedAttrToRetainOwnershipKind(const ParsedAttr &AL)
void handleRequiresSuperAttr(Decl *D, const ParsedAttr &Attrs)
ObjCInterfaceDecl * NSDictionaryDecl
The declaration of the Objective-C NSDictionary class.
ObjCMethodDecl * ArrayWithObjectsMethod
The declaration of the arrayWithObjects:count: method.
bool CheckObjCString(Expr *Arg)
CheckObjCString - Checks that the argument to the builtin CFString constructor is correct Note: It mi...
QualType BuildObjCObjectType(QualType BaseType, SourceLocation Loc, SourceLocation TypeArgsLAngleLoc, ArrayRef< TypeSourceInfo * > TypeArgs, SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc, ArrayRef< ObjCProtocolDecl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc, bool FailOnError, bool Rebuilding)
Build an Objective-C object pointer type.
ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *operand)
void AddXConsumedAttr(Decl *D, const AttributeCommonInfo &CI, Sema::RetainOwnershipKind K, bool IsTemplateInstantiation)
const DeclContext * getCurObjCLexicalContext() const
void handleDesignatedInitializer(Decl *D, const ParsedAttr &AL)
void handleBridgeRelatedAttr(Decl *D, const ParsedAttr &AL)
void handleIBOutletCollection(Decl *D, const ParsedAttr &AL)
ObjCMethodDecl * DictionaryWithObjectsMethod
The declaration of the dictionaryWithObjects:forKeys:count: method.
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Find the protocol with the given name, if any.
void DiagnoseCStringFormatDirectiveInCFAPI(const NamedDecl *FDecl, Expr **Args, unsigned NumArgs)
Diagnose use of s directive in an NSString which is being passed as formatting string to formatting m...
bool isCFStringType(QualType T)
void handleDirectAttr(Decl *D, const ParsedAttr &AL)
StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw, Scope *CurScope)
void checkRetainCycles(ObjCMessageExpr *msg)
checkRetainCycles - Check whether an Objective-C message send might create an obvious retain cycle.
StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParen, Decl *Parm, Stmt *Body)
bool isNSStringType(QualType T, bool AllowNSAttributedString=false)
bool GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx)
ExprResult CheckObjCForCollectionOperand(SourceLocation forLoc, Expr *collection)
void AddCFAuditedAttribute(Decl *D)
AddCFAuditedAttribute - Check whether we're currently within '#pragma clang arc_cf_code_audited' and,...
void checkDictionaryLiteral(QualType TargetType, ObjCDictionaryLiteral *DictionaryLiteral)
Check an Objective-C dictionary literal being converted to the given target type.
void handleBoxable(Decl *D, const ParsedAttr &AL)
bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type)
ObjCMethodDecl * LookupMethodInQualifiedType(Selector Sel, const ObjCObjectPointerType *OPT, bool IsInstance)
LookupMethodInQualifiedType - Lookups up a method in protocol qualifier list of a qualified objective...
StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
void handleDirectMembersAttr(Decl *D, const ParsedAttr &AL)
bool CheckObjCMethodCall(ObjCMethodDecl *Method, SourceLocation loc, ArrayRef< const Expr * > Args)
void handleBridgeAttr(Decl *D, const ParsedAttr &AL)
void handlePreciseLifetimeAttr(Decl *D, const ParsedAttr &AL)
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
void ActOnObjCContainerStartDefinition(ObjCContainerDecl *IDecl)
Sema - This implements semantic analysis and AST building for C.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupObjCProtocolName
Look up the name of an Objective-C protocol.
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
Check assignment constraints for an assignment of RHS to LHSType.
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
bool IsAssignConvertCompatible(AssignConvertType ConvTy)
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteral - This represents a string literal expression, e.g.
StringRef getString() const
TagKind getTagKind() const
Base wrapper for a particular "section" of type source info.
TypeLoc findExplicitQualifierLoc() const
Find a type with the location of an explicit type qualifier.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
bool isBlockPointerType() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isPointerType() const
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isObjCNSObjectType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isObjCIdType() const
bool isObjCObjectType() const
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const
Return the implicit lifetime for this type, which must not be dependent.
bool isObjCObjectPointerType() const
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
const T * getAs() const
Member-template getAs<specific type>'.
bool isObjCRetainableType() const
QualType getUnderlyingType() const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
Represents a variable declaration or definition.
void setARCPseudoStrong(bool PS)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
Retains information about a function, method, or block that is currently being parsed.
void setHasObjCTry(SourceLocation TryLoc)
SourceLocation FirstSEHTryLoc
First SEH '__try' statement in the current function.
Provides information about an attempted template argument deduction, whose success or failure was des...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const AstTypeMatcher< PointerType > pointerType
The JSON file list parser is used to communicate input to InstallAPI.
static void checkCollectionLiteralElement(Sema &S, QualType TargetElementType, Expr *Element, unsigned ElementKind)
Check a single element within a collection literal against the target element type.
bool isa(CodeGen::Address addr)
AttributeDeclKind
These constants match the enumerated choices of warn_attribute_wrong_decl_type and err_attribute_wron...
@ ExpectedFunctionMethodOrParameter
@ ExpectedFunctionOrMethod
void handleSimpleAttributeOrDiagnose(SemaBase &S, Decl *D, const AttributeCommonInfo &CI, bool PassesCheck, unsigned DiagID, DiagnosticArgs &&...ExtraArgs)
Add an attribute AttrType to declaration D, provided that PassesCheck is true.
bool hasDeclarator(const Decl *D)
Return true if the given decl has a declarator that should have been processed by Sema::GetTypeForDec...
static bool isValidSubjectOfOSAttribute(QualType QT)
static void diagnoseRetainCycle(Sema &S, Expr *capturer, RetainCycleOwner &owner)
const ParmVarDecl * getFunctionOrMethodParam(const Decl *D, unsigned Idx)
static bool isSetterLikeSelector(Selector sel)
Check for a keyword selector that starts with the word 'add' or 'set'.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
static Expr * findCapturingExpr(Sema &S, Expr *e, RetainCycleOwner &owner)
Check whether the given argument is a block which captures a variable.
static bool considerVariable(VarDecl *var, Expr *ref, RetainCycleOwner &owner)
Consider whether capturing the given variable can possibly lead to a retain cycle.
static std::optional< int > GetNSMutableDictionaryArgumentIndex(SemaObjC &S, ObjCMessageExpr *Message)
@ AANT_ArgumentIdentifier
@ Property
The type of a property.
@ Result
The result type of a method or function.
ActionResult< ParsedType > TypeResult
static bool checkIBOutletCommon(Sema &S, Decl *D, const ParsedAttr &AL)
LLVM_READONLY bool isLowercase(unsigned char c)
Return true if this character is a lowercase ASCII letter: [a-z].
@ Struct
The "struct" keyword.
static QualType applyObjCTypeArgs(Sema &S, SourceLocation loc, QualType type, ArrayRef< TypeSourceInfo * > typeArgs, SourceRange typeArgsRange, bool failOnError, bool rebuilding)
Apply Objective-C type arguments to the given type.
static bool isValidSubjectOfNSAttribute(QualType QT)
void handleSimpleAttribute(SemaBase &S, Decl *D, const AttributeCommonInfo &CI)
Applies the given attribute to the Decl without performing any additional semantic checking.
static bool isValidSubjectOfCFAttribute(QualType QT)
static std::optional< int > GetNSSetArgumentIndex(SemaObjC &S, ObjCMessageExpr *Message)
static bool tryMakeVariablePseudoStrong(Sema &S, VarDecl *VD, bool DiagnoseFailure)
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
static bool isValidSubjectOfNSReturnsRetainedAttribute(QualType QT)
bool hasFunctionProto(const Decl *D)
hasFunctionProto - Return true if the given decl has a argument information.
static bool findRetainCycleOwner(Sema &S, Expr *e, RetainCycleOwner &owner)
MutableArrayRef< Stmt * > MultiStmtArg
unsigned getFunctionOrMethodNumParams(const Decl *D)
getFunctionOrMethodNumParams - Return number of function or method parameters.
TemplateDeductionResult
Describes the result of template argument deduction.
@ Success
Template argument deduction was successful.
@ AlreadyDiagnosed
Some error which was already diagnosed.
U cast(CodeGen::Address addr)
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
ActionResult< Expr * > ExprResult
ActionResult< Stmt * > StmtResult
static std::optional< int > GetNSMutableArrayArgumentIndex(SemaObjC &S, ObjCMessageExpr *Message)