:
SemaBase(S), NSNumberDecl(nullptr), NSValueDecl(nullptr),
31NSStringDecl(nullptr), StringWithUTF8StringMethod(nullptr),
32ValueWithBytesObjCTypeMethod(nullptr), NSArrayDecl(nullptr),
33ArrayWithObjectsMethod(nullptr), NSDictionaryDecl(nullptr),
34DictionaryWithObjectsMethod(nullptr) {}
48 if(!DS->isSingleDecl())
50diag::err_toomany_element_decls));
52 VarDecl*
D= dyn_cast<VarDecl>(DS->getSingleDecl());
53 if(!
D||
D->isInvalidDecl())
56FirstType =
D->getType();
60 if(!
D->hasLocalStorage())
62 Diag(
D->getLocation(), diag::err_non_local_variable_decl_in_for));
68 Expr*DeducedInit = &OpaqueId;
72 D->getTypeSourceInfo()->getTypeLoc(), DeducedInit, FirstType, Info);
76 if(FirstType.
isNull()) {
81 D->setType(FirstType);
85 D->getTypeSourceInfo()->getTypeLoc().getBeginLoc();
86 Diag(
Loc, diag::warn_auto_var_is_id) <<
D->getDeclName();
94 Diag(
First->getBeginLoc(), diag::err_selector_element_not_lvalue)
95<<
First->getSourceRange());
97FirstType =
static_cast<Expr*
>(
First)->getType();
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());
118 nullptr, ForLoc, RParenLoc);
130collection = result.
get();
140collection = result.
get();
147 return Diag(forLoc, diag::err_collection_expr_type)
160diag::err_arc_collection_forward,
165}
else if(iface || !objectType->
qual_empty()) {
167&Context.Idents.get(
"countByEnumeratingWithState"),
168&Context.Idents.get(
"objects"), &Context.Idents.get(
"count")};
169 Selectorselector = Context.Selectors.getSelector(3, &selectorIdents[0]);
187 Diag(forLoc, diag::warn_collection_expr_type)
211 VarDecl*Var = cast_or_null<VarDecl>(Parm);
228 Diag(AtLoc, diag::err_objc_exceptions_disabled) <<
"@try";
233 Diag(AtLoc, diag::err_mixing_cxx_try_seh_try) << 1;
238 unsignedNumCatchStmts = CatchStmts.size();
240NumCatchStmts, Finally);
262 return StmtError(
Diag(AtLoc, diag::err_objc_throw_expects_object)
273 Diag(AtLoc, diag::err_objc_exceptions_disabled) <<
"@throw";
278 Scope*AtCatchParent = CurScope;
280AtCatchParent = AtCatchParent->
getParent();
282 return StmtError(
Diag(AtLoc, diag::err_rethrow_used_outside_catch));
292operand = result.
get();
296 if(!
type->isDependentType() && !
type->isObjCObjectPointerType()) {
301diag::err_incomplete_receiver_type))
302 return Diag(atLoc, diag::err_objc_synchronized_expects_object)
310 return Diag(atLoc, diag::err_objc_synchronized_expects_object)
313operand = result.
get();
315 return Diag(atLoc, diag::err_objc_synchronized_expects_object)
347Context.ObjCBuiltinIdTy, {},
369ObjCObjectTL.setProtocolLAngleLoc(lAngleLoc);
370ObjCObjectTL.setProtocolRAngleLoc(rAngleLoc);
371 for(
unsignedi = 0, n = protocols.size(); i != n; ++i)
372ObjCObjectTL.setProtocolLoc(i, protocolLocs[i]);
392BaseTypeInfo = Context.getTrivialTypeSourceInfo(
T,
Loc);
396 for(
unsignedi = 0, n = TypeArgs.size(); i != n; ++i) {
400ActualTypeArgInfos.clear();
404assert(TypeArgInfo &&
"No type source info?");
405ActualTypeArgInfos.push_back(TypeArgInfo);
411TypeArgsLAngleLoc, ActualTypeArgInfos, TypeArgsRAngleLoc,
415ProtocolLocs, ProtocolRAngleLoc,
431ResultTL = ObjCObjectPointerTL.getPointeeLoc();
436 if(OTPTL.getNumProtocols() > 0) {
437assert(OTPTL.getNumProtocols() == Protocols.size());
438OTPTL.setProtocolLAngleLoc(ProtocolLAngleLoc);
439OTPTL.setProtocolRAngleLoc(ProtocolRAngleLoc);
440 for(
unsignedi = 0, n = Protocols.size(); i != n; ++i)
441OTPTL.setProtocolLoc(i, ProtocolLocs[i]);
451 if(ObjCObjectTL.getNumTypeArgs() > 0) {
452assert(ObjCObjectTL.getNumTypeArgs() == ActualTypeArgInfos.size());
453ObjCObjectTL.setTypeArgsLAngleLoc(TypeArgsLAngleLoc);
454ObjCObjectTL.setTypeArgsRAngleLoc(TypeArgsRAngleLoc);
455 for(
unsignedi = 0, n = ActualTypeArgInfos.size(); i != n; ++i)
456ObjCObjectTL.setTypeArgTInfo(i, ActualTypeArgInfos[i]);
463 if(ObjCObjectTL.getNumProtocols() > 0) {
464assert(ObjCObjectTL.getNumProtocols() == Protocols.size());
465ObjCObjectTL.setProtocolLAngleLoc(ProtocolLAngleLoc);
466ObjCObjectTL.setProtocolRAngleLoc(ProtocolRAngleLoc);
467 for(
unsignedi = 0, n = Protocols.size(); i != n; ++i)
468ObjCObjectTL.setProtocolLoc(i, ProtocolLocs[i]);
475ObjCObjectTL.setHasBaseTypeAsWritten(
true);
476 if(ObjCObjectTL.getType() ==
T)
477ObjCObjectTL.getBaseLoc().initializeFullCopy(BaseTypeInfo->
getTypeLoc());
479ObjCObjectTL.getBaseLoc().initialize(Context,
Loc);
492 if(!Protocols.empty()) {
494 Result= Context.applyObjCProtocolQualifiers(
Result, Protocols, HasError);
497<<
SourceRange(ProtocolLAngleLoc, ProtocolRAngleLoc);
501 if(FailOnError &&
Result.isNull())
515 if(!objcObjectType || !objcObjectType->getInterface()) {
516S.
Diag(loc, diag::err_objc_type_args_non_class) <<
type<< typeArgsRange;
527S.
Diag(loc, diag::err_objc_type_args_non_parameterized_class)
537 if(objcObjectType->isSpecialized()) {
538S.
Diag(loc, diag::err_objc_type_args_specialized_class)
549 unsignednumTypeParams = typeParams->
size();
550 boolanyPackExpansions =
false;
551 for(
unsignedi = 0, n = typeArgs.size(); i != n; ++i) {
559 booldiagnosed =
false;
562rangeToRemove =
attr.getLocalSourceRange();
563 if(
attr.getTypePtr()->getImmediateNullability()) {
564typeArg =
attr.getTypePtr()->getModifiedType();
566diag::err_objc_type_arg_explicit_nullability)
574 if(!rebuilding && !diagnosed) {
575S.
Diag(qual.getBeginLoc(), diag::err_objc_type_arg_qualified)
584finalTypeArgs.push_back(typeArg);
587anyPackExpansions =
true;
591 if(!anyPackExpansions) {
592 if(i < numTypeParams) {
593typeParam = typeParams->
begin()[i];
596S.
Diag(loc, diag::err_objc_type_args_wrong_arity)
599S.
Diag(objcClass->
getLocation(), diag::note_previous_decl) << objcClass;
614assert(anyPackExpansions &&
"Too many arguments?");
623 if(typeArgObjC->isObjCIdType()) {
626 if(boundObjC->isObjCIdType())
635diag::err_objc_type_arg_does_not_match_bound)
652assert(anyPackExpansions &&
"Too many arguments?");
663diag::err_objc_type_arg_does_not_match_bound)
686diag::err_objc_type_arg_not_id_compatible)
696 if(!anyPackExpansions && finalTypeArgs.size() != numTypeParams) {
697S.
Diag(loc, diag::err_objc_type_args_wrong_arity)
698<< (typeArgs.size() < typeParams->
size()) << objcClass->
getDeclName()
700S.
Diag(objcClass->
getLocation(), diag::note_previous_decl) << objcClass;
717 boolFailOnError,
boolRebuilding) {
720 if(!TypeArgs.empty()) {
723 SourceRange(TypeArgsLAngleLoc, TypeArgsRAngleLoc),
724FailOnError, Rebuilding);
725 if(FailOnError &&
Result.isNull())
729 if(!Protocols.empty()) {
731 Result= Context.applyObjCProtocolQualifiers(
Result, Protocols, HasError);
733 Diag(
Loc, diag::err_invalid_protocol_qualifiers)
734<<
SourceRange(ProtocolLAngleLoc, ProtocolRAngleLoc);
738 if(FailOnError &&
Result.isNull())
747 QualType T= Context.getObjCInstanceType();
756structRetainCycleOwner {
757VarDecl *Variable =
nullptr;
762RetainCycleOwner() =
default;
764 voidsetLocsFrom(Expr *e) {
765 Loc= e->getExprLoc();
766 Range= e->getSourceRange();
781owner.Variable = var;
783owner.setLocsFrom(ref);
791 switch(
cast->getCastKind()) {
793 caseCK_LValueBitCast:
794 caseCK_LValueToRValue:
795 caseCK_ARCReclaimReturnedObject:
796e =
cast->getSubExpr();
813 if(ref->isFreeIvar())
814owner.setLocsFrom(ref);
815owner.Indirect =
true;
819 if(
DeclRefExpr*ref = dyn_cast<DeclRefExpr>(e)) {
820 VarDecl*var = dyn_cast<VarDecl>(ref->getDecl());
826 if(
MemberExpr*member = dyn_cast<MemberExpr>(e)) {
827 if(member->isArrow())
831e = member->getBase();
838pseudo->getSyntacticForm()->IgnoreParens());
844 if(!property->isRetaining() &&
845!(property->getPropertyIvarDecl() &&
846property->getPropertyIvarDecl()->getType().getObjCLifetime() ==
850owner.Indirect =
true;
859e =
const_cast<Expr*
>(
860cast<OpaqueValueExpr>(pre->
getBase())->getSourceExpr());
872structFindCaptureVisitor : EvaluatedExprVisitor<FindCaptureVisitor> {
877FindCaptureVisitor(ASTContext &Context, VarDecl *variable)
878: EvaluatedExprVisitor<FindCaptureVisitor>(Context), Variable(variable) {}
880 voidVisitDeclRefExpr(DeclRefExpr *ref) {
881 if(ref->getDecl() == Variable && !Capturer)
885 voidVisitObjCIvarRefExpr(ObjCIvarRefExpr *ref) {
888Visit(ref->getBase());
889 if(Capturer && ref->isFreeIvar())
893 voidVisitBlockExpr(BlockExpr *block) {
895 if(block->getBlockDecl()->capturesVariable(Variable))
896Visit(block->getBlockDecl()->getBody());
899 voidVisitOpaqueValueExpr(OpaqueValueExpr *OVE) {
902 if(OVE->getSourceExpr())
903Visit(OVE->getSourceExpr());
906 voidVisitBinaryOperator(BinaryOperator *BinOp) {
907 if(!Variable || VarWillBeReased || BinOp->getOpcode() != BO_Assign)
909Expr *LHS = BinOp->getLHS();
910 if(
constDeclRefExpr *DRE = dyn_cast_or_null<DeclRefExpr>(LHS)) {
911 if(DRE->getDecl() != Variable)
913 if(Expr *RHS = BinOp->getRHS()) {
914RHS = RHS->IgnoreParenCasts();
915std::optional<llvm::APSInt>
Value;
917(RHS && (
Value= RHS->getIntegerConstantExpr(Context)) &&
929assert(owner.Variable && owner.Loc.isValid());
936 if(
Cmd.isUnarySelector() &&
Cmd.getNameForSlot(0) ==
"copy") {
937e = ME->getInstanceReceiver();
942}
else if(
CallExpr*CE = dyn_cast<CallExpr>(e)) {
943 if(CE->getNumArgs() == 1) {
944 FunctionDecl*Fn = dyn_cast_or_null<FunctionDecl>(CE->getCalleeDecl());
947 if(FnI && FnI->
isStr(
"_Block_copy")) {
954 BlockExpr*block = dyn_cast<BlockExpr>(e);
958FindCaptureVisitor visitor(S.
Context, owner.Variable);
960 returnvisitor.VarWillBeReased ? nullptr : visitor.Capturer;
964RetainCycleOwner &owner) {
966assert(owner.Variable && owner.Loc.isValid());
970S.
Diag(owner.Loc, diag::note_arc_retain_cycle_owner)
971<< owner.Indirect << owner.Range;
981str = str.ltrim(
'_');
982 if(str.starts_with(
"set"))
984 else if(str.starts_with(
"add")) {
986 if(sel.
getNumArgs() == 1 && str.starts_with(
"addOperationWithBlock"))
997staticstd::optional<int>
999 boolIsMutableArray = S.NSAPIObj->isSubclassOfNSClass(
1001 if(!IsMutableArray) {
1002 returnstd::nullopt;
1005 SelectorSel = Message->getSelector();
1007std::optional<NSAPI::NSArrayMethodKind> MKOpt =
1008S.NSAPIObj->getNSArrayMethodKind(Sel);
1010 returnstd::nullopt;
1024 returnstd::nullopt;
1027 returnstd::nullopt;
1030staticstd::optional<int>
1032 boolIsMutableDictionary = S.NSAPIObj->isSubclassOfNSClass(
1034 if(!IsMutableDictionary) {
1035 returnstd::nullopt;
1038 SelectorSel = Message->getSelector();
1040std::optional<NSAPI::NSDictionaryMethodKind> MKOpt =
1041S.NSAPIObj->getNSDictionaryMethodKind(Sel);
1043 returnstd::nullopt;
1055 returnstd::nullopt;
1058 returnstd::nullopt;
1063 boolIsMutableSet = S.NSAPIObj->isSubclassOfNSClass(
1066 boolIsMutableOrderedSet = S.NSAPIObj->isSubclassOfNSClass(
1068 if(!IsMutableSet && !IsMutableOrderedSet) {
1069 returnstd::nullopt;
1072 SelectorSel = Message->getSelector();
1074std::optional<NSAPI::NSSetMethodKind> MKOpt =
1075S.NSAPIObj->getNSSetMethodKind(Sel);
1077 returnstd::nullopt;
1092 returnstd::nullopt;
1096 if(!Message->isInstanceMessage()) {
1100std::optional<int> ArgOpt;
1108 intArgIndex = *ArgOpt;
1110 Expr*Arg = Message->getArg(ArgIndex)->IgnoreImpCasts();
1116 if(
DeclRefExpr*ArgRE = dyn_cast<DeclRefExpr>(Arg)) {
1117 if(ArgRE->isObjCSelfExpr()) {
1118 Diag(Message->getSourceRange().getBegin(),
1119diag::warn_objc_circular_container)
1120<< ArgRE->getDecl() << StringRef(
"'super'");
1124 Expr*Receiver = Message->getInstanceReceiver()->IgnoreImpCasts();
1130 if(
DeclRefExpr*ReceiverRE = dyn_cast<DeclRefExpr>(Receiver)) {
1131 if(
DeclRefExpr*ArgRE = dyn_cast<DeclRefExpr>(Arg)) {
1132 if(ReceiverRE->getDecl() == ArgRE->getDecl()) {
1134 Diag(Message->getSourceRange().getBegin(),
1135diag::warn_objc_circular_container)
1137 if(!ArgRE->isObjCSelfExpr()) {
1139diag::note_objc_circular_container_declared_here)
1144}
else if(
ObjCIvarRefExpr*IvarRE = dyn_cast<ObjCIvarRefExpr>(Receiver)) {
1146 if(IvarRE->getDecl() == IvarArgRE->getDecl()) {
1148 Diag(Message->getSourceRange().getBegin(),
1149diag::warn_objc_circular_container)
1152diag::note_objc_circular_container_declared_here)
1167RetainCycleOwner owner;
1180 for(
unsignedi = 0, e = msg->
getNumArgs(); i != e; ++i) {
1183 if(MD && MD->
parameters()[i]->hasAttr<NoEscapeAttr>())
1192RetainCycleOwner owner;
1201RetainCycleOwner Owner;
1222 if(!Literal || !Literal->isOrdinary()) {
1223 Diag(Arg->
getBeginLoc(), diag::err_cfstring_literal_not_string_constant)
1228 if(Literal->containsNonAsciiOrNull()) {
1229StringRef String = Literal->getString();
1230 unsignedNumBytes = String.size();
1232 constllvm::UTF8 *FromPtr = (
constllvm::UTF8 *)String.data();
1233llvm::UTF16 *ToPtr = &ToBuf[0];
1235llvm::ConversionResult
Result=
1236llvm::ConvertUTF8toUTF16(&FromPtr, FromPtr + NumBytes, &ToPtr,
1237ToPtr + NumBytes, llvm::strictConversion);
1239 if(
Result!= llvm::conversionOK)
1264DC = CatD->getClassInterface();
1273 returnIdent_NSError;
1279 "The next DeclContext should be lexically contained in the current one.");
1306 returncast_or_null<ObjCProtocolDecl>(
D);
1322Context.hasSameUnqualifiedType(FromType, ToType))
1363 boolIncompatibleObjC;
1364 if(Context.typesAreCompatible(FromPointee, ToPointee))
1365FromPointee = ToPointee;
1372FromPointee = Context.getQualifiedType(FromPointee, FromQuals);
1373ConvertedType = Context.getPointerType(FromPointee);
1395 if(isa<StringLiteral>(IndexExpr))
1399 Diag(FromE->
getExprLoc(), diag::err_objc_subscript_type_conversion) <<
T;
1405diag::err_objc_index_incomplete_class_type,
1411 intNoIntegrals = 0, NoObjCIdPointers = 0;
1415->getVisibleConversionFunctions()) {
1417dyn_cast<CXXConversionDecl>(
D->getUnderlyingDecl())) {
1418 QualTypeCT = Conversion->getConversionType().getNonReferenceType();
1421ConversionDecls.push_back(Conversion);
1424ConversionDecls.push_back(Conversion);
1428 if(NoIntegrals == 1 && NoObjCIdPointers == 0)
1430 if(NoIntegrals == 0 && NoObjCIdPointers == 1)
1432 if(NoIntegrals == 0 && NoObjCIdPointers == 0) {
1434 Diag(FromE->
getExprLoc(), diag::err_objc_subscript_type_conversion)
1438 Diag(FromE->
getExprLoc(), diag::err_objc_multiple_subscript_type_conversion)
1440 for(
unsigned inti = 0; i < ConversionDecls.size(); i++)
1441 Diag(ConversionDecls[i]->getLocation(),
1442diag::note_conv_function_declared_at);
1452 if(!
Loc.isValid())
1456 if(
D->hasAttr<CFAuditedTransferAttr>() ||
1457 D->hasAttr<CFUnknownTransferAttr>())
1462 D->addAttr(CFAuditedTransferAttr::CreateImplicit(Context, Info));
1476 if(
autobridgeAttr = RD->
getAttr<ObjCBridgeAttr>())
1477bridgedType = bridgeAttr->getBridgedType();
1478 else if(
autobridgeAttr = RD->
getAttr<ObjCBridgeMutableAttr>())
1479bridgedType = bridgeAttr->getBridgedType();
1501 if(AllowNSAttributedString &&
1529 if(
const auto*VD = dyn_cast<ObjCIvarDecl>(
D)) {
1531S.
Diag(AL.
getLoc(), diag::warn_iboutlet_object_type)
1532<< AL << VD->getType() << 0;
1535}
else if(
const auto*PD = dyn_cast<ObjCPropertyDecl>(
D)) {
1537S.
Diag(AL.
getLoc(), diag::warn_iboutlet_object_type)
1538<< AL << PD->getType() << 1;
1542S.
Diag(AL.
getLoc(), diag::warn_attribute_iboutlet) << AL;
1561 Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
1574Context.Idents.get(
"NSObject"), AL.
getLoc(),
1577 Diag(AL.
getLoc(), diag::err_iboutletcollection_type) <<
"NSObject";
1585QTLoc = Context.getTrivialTypeSourceInfo(QT, AL.
getLoc());
1593? diag::err_iboutletcollection_builtintype
1594: diag::err_iboutletcollection_type)
1599 D->addAttr(::new (Context) IBOutletCollectionAttr(Context, AL, QTLoc));
1603 if(!cast<ObjCProtocolDecl>(
D)->isThisDeclarationADefinition()) {
1604 Diag(AL.
getLoc(), diag::err_objc_attr_protocol_requires_definition)
1615 if(isa<ObjCProtocolDecl>(
D->getDeclContext())) {
1616 Diag(AL.
getLoc(), diag::err_objc_direct_on_protocol) <<
false;
1621handleSimpleAttribute<ObjCDirectAttr>(*
this,
D, AL);
1623 Diag(AL.
getLoc(), diag::warn_objc_direct_ignored) << AL;
1629handleSimpleAttribute<ObjCDirectMembersAttr>(*
this,
D, AL);
1631 Diag(AL.
getLoc(), diag::warn_objc_direct_ignored) << AL;
1636 const auto*M = cast<ObjCMethodDecl>(
D);
1638 Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
1644ObjCMethodFamilyAttr::FamilyKind F;
1645 if(!ObjCMethodFamilyAttr::ConvertStrToFamilyKind(IL->
Ident->
getName(), F)) {
1646 Diag(IL->
Loc, diag::warn_attribute_type_not_supported) << AL << IL->
Ident;
1650 if(F == ObjCMethodFamilyAttr::OMF_init &&
1651!M->getReturnType()->isObjCObjectPointerType()) {
1652 Diag(M->getLocation(), diag::err_init_method_bad_return_type)
1653<< M->getReturnType();
1663 if(
const auto*TD = dyn_cast<TypedefNameDecl>(
D)) {
1666 Diag(TD->getLocation(), diag::err_nsobject_attribute);
1669}
else if(
const auto*PD = dyn_cast<ObjCPropertyDecl>(
D)) {
1672 Diag(PD->getLocation(), diag::err_nsobject_attribute);
1682 Diag(
D->getLocation(), diag::warn_nsobject_attribute);
1688 if(
const auto*TD = dyn_cast<TypedefNameDecl>(
D)) {
1691 Diag(TD->getLocation(), diag::warn_ptr_independentclass_attribute);
1695 Diag(
D->getLocation(), diag::warn_independentclass_attribute);
1704 Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
1710BlocksAttr::BlockType
type;
1711 if(!BlocksAttr::ConvertStrToBlockType(II->
getName(),
type)) {
1712 Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
1742 boolIsTemplateInstantiation) {
1746handleSimpleAttributeOrDiagnose<OSConsumedAttr>(
1748diag::warn_ns_attribute_wrong_parameter_type,
1749CI.
getRange(),
"os_consumed",
1);
1752handleSimpleAttributeOrDiagnose<NSConsumedAttr>(
1759((IsTemplateInstantiation &&
getLangOpts().ObjCAutoRefCount)
1760? diag::err_ns_attribute_wrong_parameter_type
1761: diag::warn_ns_attribute_wrong_parameter_type),
1762CI.
getRange(),
"ns_consumed",
0);
1765handleSimpleAttributeOrDiagnose<CFConsumedAttr>(
1767diag::warn_ns_attribute_wrong_parameter_type,
1768CI.
getRange(),
"cf_consumed",
1);
1776 caseParsedAttr::AT_CFConsumed:
1777 caseParsedAttr::AT_CFReturnsRetained:
1778 caseParsedAttr::AT_CFReturnsNotRetained:
1780 caseParsedAttr::AT_OSConsumesThis:
1781 caseParsedAttr::AT_OSConsumed:
1782 caseParsedAttr::AT_OSReturnsRetained:
1783 caseParsedAttr::AT_OSReturnsNotRetained:
1784 caseParsedAttr::AT_OSReturnsRetainedOnZero:
1785 caseParsedAttr::AT_OSReturnsRetainedOnNonZero:
1787 caseParsedAttr::AT_NSConsumesSelf:
1788 caseParsedAttr::AT_NSConsumed:
1789 caseParsedAttr::AT_NSReturnsRetained:
1790 caseParsedAttr::AT_NSReturnsNotRetained:
1791 caseParsedAttr::AT_NSReturnsAutoreleased:
1794llvm_unreachable(
"Wrong argument supplied");
1803 Diag(
Loc, diag::warn_ns_attribute_wrong_return_type)
1804<<
"'ns_returns_retained'"<< 0 << 0;
1810 const auto*PVD = dyn_cast<ParmVarDecl>(
D);
1822 if(
const auto*MD = dyn_cast<ObjCMethodDecl>(
D)) {
1823ReturnType = MD->getReturnType();
1825(AL.
getKind() == ParsedAttr::AT_NSReturnsRetained)) {
1827}
else if(
const auto*PD = dyn_cast<ObjCPropertyDecl>(
D)) {
1828ReturnType = PD->getType();
1829}
else if(
const auto*FD = dyn_cast<FunctionDecl>(
D)) {
1830ReturnType = FD->getReturnType();
1831}
else if(
const auto*Param = dyn_cast<ParmVarDecl>(
D)) {
1838 if(ReturnType.
isNull()) {
1839 Diag(
D->getBeginLoc(), diag::warn_ns_attribute_wrong_parameter_type)
1840<< AL << DiagID << AL.
getRange();
1849llvm_unreachable(
"invalid ownership attribute");
1850 caseParsedAttr::AT_NSReturnsRetained:
1851 caseParsedAttr::AT_NSReturnsAutoreleased:
1852 caseParsedAttr::AT_NSReturnsNotRetained:
1856 caseParsedAttr::AT_OSReturnsRetained:
1857 caseParsedAttr::AT_OSReturnsNotRetained:
1858 caseParsedAttr::AT_CFReturnsRetained:
1859 caseParsedAttr::AT_CFReturnsNotRetained:
1863 Diag(
D->getBeginLoc(), diag::warn_attribute_wrong_decl_type)
1865<< ExpectedDeclKind;
1871 unsignedParmDiagID = 2;
1874llvm_unreachable(
"invalid ownership attribute");
1875 caseParsedAttr::AT_NSReturnsRetained:
1880 caseParsedAttr::AT_NSReturnsAutoreleased:
1881 caseParsedAttr::AT_NSReturnsNotRetained:
1886 caseParsedAttr::AT_CFReturnsRetained:
1887 caseParsedAttr::AT_CFReturnsNotRetained:
1892 caseParsedAttr::AT_OSReturnsRetained:
1893 caseParsedAttr::AT_OSReturnsNotRetained:
1904 if(isa<ParmVarDecl>(
D)) {
1905 Diag(
D->getBeginLoc(), diag::warn_ns_attribute_wrong_parameter_type)
1906<< AL << ParmDiagID << AL.
getRange();
1910 if(isa<ObjCMethodDecl>(
D))
1911SubjectKind = Method;
1912 else if(isa<ObjCPropertyDecl>(
D))
1914 Diag(
D->getBeginLoc(), diag::warn_ns_attribute_wrong_return_type)
1915<< AL << SubjectKind << Cf << AL.
getRange();
1922llvm_unreachable(
"invalid ownership attribute");
1923 caseParsedAttr::AT_NSReturnsAutoreleased:
1924handleSimpleAttribute<NSReturnsAutoreleasedAttr>(*
this,
D, AL);
1926 caseParsedAttr::AT_CFReturnsNotRetained:
1927handleSimpleAttribute<CFReturnsNotRetainedAttr>(*
this,
D, AL);
1929 caseParsedAttr::AT_NSReturnsNotRetained:
1930handleSimpleAttribute<NSReturnsNotRetainedAttr>(*
this,
D, AL);
1932 caseParsedAttr::AT_CFReturnsRetained:
1933handleSimpleAttribute<CFReturnsRetainedAttr>(*
this,
D, AL);
1935 caseParsedAttr::AT_NSReturnsRetained:
1936handleSimpleAttribute<NSReturnsRetainedAttr>(*
this,
D, AL);
1938 caseParsedAttr::AT_OSReturnsRetained:
1939handleSimpleAttribute<OSReturnsRetainedAttr>(*
this,
D, AL);
1941 caseParsedAttr::AT_OSReturnsNotRetained:
1942handleSimpleAttribute<OSReturnsNotRetainedAttr>(*
this,
D, AL);
1948 const intEP_ObjCMethod = 1;
1949 const intEP_ObjCProperty = 2;
1953 if(isa<ObjCMethodDecl>(
D))
1954resultType = cast<ObjCMethodDecl>(
D)->getReturnType();
1956resultType = cast<ObjCPropertyDecl>(
D)->getType();
1960 Diag(
D->getBeginLoc(), diag::warn_ns_attribute_wrong_return_type)
1962<< (isa<ObjCMethodDecl>(
D) ? EP_ObjCMethod : EP_ObjCProperty)
1974 const auto*Method = cast<ObjCMethodDecl>(
D);
1977 if(
const auto*PDecl = dyn_cast_if_present<ObjCProtocolDecl>(DC)) {
1978 Diag(
D->getBeginLoc(), diag::warn_objc_requires_super_protocol)
1980 Diag(PDecl->getLocation(), diag::note_protocol_decl);
1984 Diag(
D->getBeginLoc(), diag::warn_objc_requires_super_protocol)
1994 if(!isa<TagDecl>(
D)) {
1995 Diag(
D->getBeginLoc(), diag::err_nserrordomain_invalid_decl) << 0;
2000 Attr.isArgIdent(0) ?
Attr.getArgAsIdent(0) :
nullptr;
2001 if(!IdentLoc || !IdentLoc->
Ident) {
2004 if(
Attr.isArgExpr(0) &&
Attr.getArgAsExpr(0))
2005 Loc=
Attr.getArgAsExpr(0)->getBeginLoc();
2007 Diag(
Loc, diag::err_nserrordomain_invalid_decl) << 0;
2017 Diag(IdentLoc->
Loc, diag::err_nserrordomain_invalid_decl)
2018<< 1 << IdentLoc->
Ident;
2030 Diag(
D->getBeginLoc(), diag::err_objc_attr_not_id) << AL << 0;
2035 if(
const auto*TD = dyn_cast<TypedefNameDecl>(
D)) {
2037 Diag(AL.
getLoc(), diag::err_objc_attr_typedef_not_id) << AL;
2044 Diag(AL.
getLoc(), diag::err_objc_attr_typedef_not_void_pointer);
2057 Diag(
D->getBeginLoc(), diag::err_objc_attr_not_id) << AL << 0;
2068 if(!RelatedClass) {
2069 Diag(
D->getBeginLoc(), diag::err_objc_attr_not_id) << AL << 0;
2077 getASTContext(), AL, RelatedClass, ClassMethod, InstanceMethod));
2085 if(!isa<ObjCInterfaceDecl>(Ctx) &&
2086!(isa<ObjCCategoryDecl>(Ctx) &&
2087cast<ObjCCategoryDecl>(Ctx)->IsClassExtension())) {
2088 Diag(
D->getLocation(), diag::err_designated_init_attr_non_init);
2093 if(
auto*CatDecl = dyn_cast<ObjCCategoryDecl>(Ctx))
2094IFace = CatDecl->getClassInterface();
2096IFace = cast<ObjCInterfaceDecl>(Ctx);
2107StringRef MetaDataName;
2119 boolnotify =
false;
2121 auto*RD = dyn_cast<RecordDecl>(
D);
2122 if(RD && RD->getDefinition()) {
2123RD = RD->getDefinition();
2128ObjCBoxableAttr *BoxableAttr =
2130RD->addAttr(BoxableAttr);
2135L->AddedAttributeToRecord(BoxableAttr, RD);
2144 Diag(
D->getBeginLoc(), diag::err_attribute_wrong_decl_type)
2150 const auto*VD = cast<ValueDecl>(
D);
2154 Diag(AL.
getLoc(), diag::err_objc_precise_lifetime_bad_type) << QT;
2168 "didn't infer lifetime for non-dependent type?");
2177 Diag(AL.
getLoc(), diag::warn_objc_precise_lifetime_meaningless)
2187 boolDiagnoseFailure) {
2190 if(DiagnoseFailure) {
2191S.
Diag(VD->
getBeginLoc(), diag::warn_ignored_objc_externally_retained)
2208 if(DiagnoseFailure) {
2209S.
Diag(VD->
getBeginLoc(), diag::warn_ignored_objc_externally_retained)
2224 if(
auto*VD = dyn_cast<VarDecl>(
D)) {
2225assert(!isa<ParmVarDecl>(VD) &&
"should be diagnosed automatically");
2226 if(!VD->hasLocalStorage()) {
2227 Diag(
D->getBeginLoc(), diag::warn_ignored_objc_externally_retained) << 0;
2234handleSimpleAttribute<ObjCExternallyRetainedAttr>(*
this,
D, AL);
2240 unsignedNumParams =
2242 for(
unsignedI = 0; I != NumParams; ++I) {
2256handleSimpleAttribute<ObjCExternallyRetainedAttr>(*
this,
D, AL);
2275 boolFormat =
false;
2287 if(!Format || NumArgs <= Idx)
2289 const Expr*FormatExpr = Args[Idx];
2290 if(
const CStyleCastExpr*CSCE = dyn_cast<CStyleCastExpr>(FormatExpr))
2291FormatExpr = CSCE->getSubExpr();
2301 Diag(FormatExpr->
getExprLoc(), diag::warn_objc_cdirective_format_string)
2316 if(
const auto*OVE = dyn_cast<OpaqueValueExpr>(Ignored))
2317Ignored = OVE->getSourceExpr();
2318 boolNeedsParens = isa<AbstractConditionalOperator>(Ignored) ||
2319isa<BinaryOperator>(Ignored) ||
2320isa<CXXOperatorCallExpr>(Ignored);
2331 Expr*Element,
unsignedElementKind) {
2333 if(
autoICE = dyn_cast<ImplicitCastExpr>(Element)) {
2334 if(ICE->getCastKind() == CK_BitCast &&
2336Element = ICE->getSubExpr();
2339 QualTypeElementType = Element->getType();
2344S.
Diag(Element->getBeginLoc(), diag::warn_objc_collection_literal_element)
2345<< ElementType << ElementKind << TargetElementType
2346<< Element->getSourceRange();
2349 if(
autoArrayLiteral = dyn_cast<ObjCArrayLiteral>(Element))
2351 else if(
autoDictionaryLiteral = dyn_cast<ObjCDictionaryLiteral>(Element))
2366 if(TargetObjCPtr->isUnspecialized() ||
2367TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl() !=
2372 if(TypeArgs.size() != 1)
2375 QualTypeTargetElementType = TypeArgs[0];
2376 for(
unsignedI = 0, N = ArrayLiteral->
getNumElements(); I != N; ++I) {
2391 if(TargetObjCPtr->isUnspecialized() ||
2392TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl() !=
2397 if(TypeArgs.size() != 2)
2400 QualTypeTargetKeyType = TypeArgs[0];
2401 QualTypeTargetObjectType = TypeArgs[1];
2402 for(
unsignedI = 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 ...
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 * 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.
bool isInvalidDecl() const
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
SourceLocation getLocation() const
The name of a declaration.
SourceLocation getBeginLoc() const LLVM_READONLY
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.
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.
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
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
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
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 a class type in Objective C.
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface.
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 pack expansion of types.
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
std::pair< IdentifierInfo *, SourceLocation > getPragmaARCCFCodeAuditedInfo() const
The location of the currently-active #pragma clang arc_cf_code_audited begin.
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
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.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
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.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
ASTContext & getASTContext() const
const LangOptions & getLangOpts() const
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)
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 handleSuppresProtocolAttr(Decl *D, const ParsedAttr &AL)
StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, MultiStmtArg Catch, Stmt *Finally)
void handleOwnershipAttr(Decl *D, const ParsedAttr &AL)
bool isSignedCharBool(QualType Ty)
void handleBlocksAttr(Decl *D, const ParsedAttr &AL)
StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
void ActOnObjCContainerFinishDefinition()
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.
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)
void adornBoolConversionDiagWithTernaryFixit(Expr *SourceExpr, const Sema::SemaDiagnosticBuilder &Builder)
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)
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.
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
ExprResult PerformContextuallyConvertToObjCPointer(Expr *From)
PerformContextuallyConvertToObjCPointer - Perform a contextual conversion of the expression From to a...
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupObjCProtocolName
Look up the name of an Objective-C protocol.
bool FormatStringHasSArg(const StringLiteral *FExpr)
static bool getFormatStringInfo(const FormatAttr *Format, bool IsCXXMember, bool IsVariadic, FormatStringInfo *FSI)
Given a FunctionDecl's FormatAttr, attempts to populate the FomatStringInfo parameter with the Format...
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Look up a name, looking for a single declaration.
static FormatStringType GetFormatStringType(const FormatAttr *Format)
bool isObjCPointerConversion(QualType FromType, QualType ToType, QualType &ConvertedType, bool &IncompatibleObjC)
isObjCPointerConversion - Determines whether this is an Objective-C pointer conversion.
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
DeclContext * getCurLexicalContext() const
sema::FunctionScopeInfo * getCurFunction() const
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.
ExprResult DefaultLvalueConversion(Expr *E)
void CheckTCBEnforcement(const SourceLocation CallExprLoc, const NamedDecl *Callee)
Enforce the bounds of a TCB CheckTCBEnforcement - Enforces that every function in a named TCB only di...
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
@ Compatible
Compatible - the types are compatible according to the standard.
DeclContext * OriginalLexicalContext
Generally null except when we temporarily switch decl contexts, like in.
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
void setFunctionHasBranchProtectedScope()
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type.
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
void DiagnoseAutoDeductionFailure(const VarDecl *VDecl, const Expr *Init)
TemplateDeductionResult DeduceAutoType(TypeLoc AutoTypeLoc, Expr *Initializer, QualType &Result, sema::TemplateDeductionInfo &Info, bool DependentDeduction=false, bool IgnoreConstraints=false, TemplateSpecCandidateSet *FailedTSC=nullptr)
Deduce the type for an auto type-specifier (C++11 [dcl.spec.auto]p6)
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
bool checkStringLiteralArgumentAttr(const AttributeCommonInfo &CI, const Expr *E, StringRef &Str, SourceLocation *ArgLocation=nullptr)
Check if the argument E is a ASCII string literal.
ASTMutationListener * getASTMutationListener() const
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
void checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto, const Expr *ThisArg, ArrayRef< const Expr * > Args, bool IsMemberFunction, SourceLocation Loc, SourceRange Range, VariadicCallType CallType)
Handles the checks for format strings, non-POD arguments to vararg functions, NULL arguments passed t...
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.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isBlockPointerType() const
bool isVoidPointerType() const
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 isCARCBridgableType() const
Determine whether the given type T is a "bridgeable" C type.
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 isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isObjCObjectPointerType() const
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.
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 AstTypeMatcher< PointerType > pointerType
Matches pointer types, but does not match Objective-C object pointer types.
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
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.
AttributeDeclKind
These constants match the enumerated choices of warn_attribute_wrong_decl_type and err_attribute_wron...
@ ExpectedFunctionMethodOrParameter
@ ExpectedFunctionOrMethod
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'.
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.
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)
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.
const FunctionProtoType * T
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)
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)
static std::optional< int > GetNSMutableArrayArgumentIndex(SemaObjC &S, ObjCMessageExpr *Message)
Wraps an identifier and optional source location for the identifier.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4