Lines Matching refs:Attr
175 static unsigned getNumAttributeArgs(const AttributeList &Attr) {
177 return Attr.getNumArgs() + Attr.hasParsedType();
181 static bool checkAttributeNumArgsImpl(Sema &S, const AttributeList &Attr,
184 if (Comp(getNumAttributeArgs(Attr), Num)) {
185 S.Diag(Attr.getLoc(), Diag) << Attr.getName() << Num;
194 static bool checkAttributeNumArgs(Sema &S, const AttributeList &Attr,
196 return checkAttributeNumArgsImpl(S, Attr, Num,
203 static bool checkAttributeAtLeastNumArgs(Sema &S, const AttributeList &Attr,
205 return checkAttributeNumArgsImpl(S, Attr, Num,
212 static bool checkAttributeAtMostNumArgs(Sema &S, const AttributeList &Attr,
214 return checkAttributeNumArgsImpl(S, Attr, Num,
221 static bool checkUInt32Argument(Sema &S, const AttributeList &Attr,
228 S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type)
229 << Attr.getName() << Idx << AANT_ArgumentIntegerConstant
232 S.Diag(Attr.getLoc(), diag::err_attribute_argument_type)
233 << Attr.getName() << AANT_ArgumentIntegerConstant
267 const AttributeList &Attr,
284 S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type)
285 << Attr.getName() << AttrArgNum << AANT_ArgumentIntegerConstant
292 S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_bounds)
293 << Attr.getName() << AttrArgNum << IdxExpr->getSourceRange();
299 S.Diag(Attr.getLoc(),
301 << Attr.getName() << IdxExpr->getSourceRange();
310 /// \brief Check if the argument \p ArgNum of \p Attr is a ASCII string literal.
314 bool Sema::checkStringLiteralArgumentAttr(const AttributeList &Attr,
318 if (Attr.isArgIdent(ArgNum)) {
319 IdentifierLoc *Loc = Attr.getArgAsIdent(ArgNum);
321 << Attr.getName() << AANT_ArgumentString
331 Expr *ArgExpr = Attr.getArgAsExpr(ArgNum);
338 << Attr.getName() << AANT_ArgumentString;
350 const AttributeList &Attr) {
351 D->addAttr(::new (S.Context) AttrType(Attr.getRange(), S.Context,
352 Attr.getAttributeSpellingListIndex()));
357 const AttributeList &Attr) {
358 handleSimpleAttribute<AttrType>(S, D, Attr);
366 const AttributeList &Attr) {
367 if (checkAttrMutualExclusion<IncompatibleAttrType>(S, D, Attr.getRange(),
368 Attr.getName()))
371 Attr);
401 const AttributeList &Attr) {
418 S.Diag(Attr.getLoc(), diag::warn_thread_attribute_decl_not_pointer)
419 << Attr.getName() << QT;
522 const AttributeList &Attr,
526 for (unsigned Idx = Sidx; Idx < Attr.getNumArgs(); ++Idx) {
527 Expr *ArgExp = Attr.getArgAsExpr(Idx);
546 S.Diag(Attr.getLoc(), diag::warn_thread_attribute_ignored) <<
547 Attr.getName();
575 S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_range)
576 << Attr.getName() << Idx + 1 << NumParams;
588 S.Diag(Attr.getLoc(), diag::warn_thread_attribute_argument_not_lockable)
589 << Attr.getName() << ArgTy;
600 const AttributeList &Attr) {
601 if (!threadSafetyCheckIsPointer(S, D, Attr))
605 PtGuardedVarAttr(Attr.getRange(), S.Context,
606 Attr.getAttributeSpellingListIndex()));
610 const AttributeList &Attr,
614 checkAttrArgsAreCapabilityObjs(S, D, Attr, Args);
624 static void handleGuardedByAttr(Sema &S, Decl *D, const AttributeList &Attr) {
626 if (!checkGuardedByAttrCommon(S, D, Attr, Arg))
629 D->addAttr(::new (S.Context) GuardedByAttr(Attr.getRange(), S.Context, Arg,
630 Attr.getAttributeSpellingListIndex()));
634 const AttributeList &Attr) {
636 if (!checkGuardedByAttrCommon(S, D, Attr, Arg))
639 if (!threadSafetyCheckIsPointer(S, D, Attr))
642 D->addAttr(::new (S.Context) PtGuardedByAttr(Attr.getRange(),
644 Attr.getAttributeSpellingListIndex()));
648 const AttributeList &Attr,
650 if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
656 S.Diag(Attr.getLoc(), diag::warn_thread_attribute_decl_not_lockable)
657 << Attr.getName();
662 checkAttrArgsAreCapabilityObjs(S, D, Attr, Args);
670 const AttributeList &Attr) {
672 if (!checkAcquireOrderAttrCommon(S, D, Attr, Args))
677 AcquiredAfterAttr(Attr.getRange(), S.Context,
679 Attr.getAttributeSpellingListIndex()));
683 const AttributeList &Attr) {
685 if (!checkAcquireOrderAttrCommon(S, D, Attr, Args))
690 AcquiredBeforeAttr(Attr.getRange(), S.Context,
692 Attr.getAttributeSpellingListIndex()));
696 const AttributeList &Attr,
700 checkAttrArgsAreCapabilityObjs(S, D, Attr, Args, 0, /*ParamIdxOk=*/true);
706 const AttributeList &Attr) {
708 if (!checkLockFunAttrCommon(S, D, Attr, Args))
714 AssertSharedLockAttr(Attr.getRange(), S.Context, StartArg, Size,
715 Attr.getAttributeSpellingListIndex()));
719 const AttributeList &Attr) {
721 if (!checkLockFunAttrCommon(S, D, Attr, Args))
727 AssertExclusiveLockAttr(Attr.getRange(), S.Context,
729 Attr.getAttributeSpellingListIndex()));
734 const AttributeList &Attr,
736 if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
739 if (!isIntOrBool(Attr.getArgAsExpr(0))) {
740 S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type)
741 << Attr.getName() << 1 << AANT_ArgumentIntOrBool;
746 checkAttrArgsAreCapabilityObjs(S, D, Attr, Args, 1);
752 const AttributeList &Attr) {
754 if (!checkTryLockFunAttrCommon(S, D, Attr, Args))
758 SharedTrylockFunctionAttr(Attr.getRange(), S.Context,
759 Attr.getArgAsExpr(0),
761 Attr.getAttributeSpellingListIndex()));
765 const AttributeList &Attr) {
767 if (!checkTryLockFunAttrCommon(S, D, Attr, Args))
771 Attr.getRange(), S.Context, Attr.getArgAsExpr(0), Args.data(),
772 Args.size(), Attr.getAttributeSpellingListIndex()));
776 const AttributeList &Attr) {
779 checkAttrArgsAreCapabilityObjs(S, D, Attr, Args);
785 LockReturnedAttr(Attr.getRange(), S.Context, Args[0],
786 Attr.getAttributeSpellingListIndex()));
790 const AttributeList &Attr) {
791 if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
796 checkAttrArgsAreCapabilityObjs(S, D, Attr, Args);
803 LocksExcludedAttr(Attr.getRange(), S.Context, StartArg, Size,
804 Attr.getAttributeSpellingListIndex()));
807 static void handleEnableIfAttr(Sema &S, Decl *D, const AttributeList &Attr) {
808 S.Diag(Attr.getLoc(), diag::ext_clang_enable_if);
810 Expr *Cond = Attr.getArgAsExpr(0);
819 if (!S.checkStringLiteralArgumentAttr(Attr, 1, Msg))
826 S.Diag(Attr.getLoc(), diag::err_enable_if_never_constant_expr);
833 EnableIfAttr(Attr.getRange(), S.Context, Cond, Msg,
834 Attr.getAttributeSpellingListIndex()));
838 const AttributeList &Attr) {
841 << Attr.getName();
845 Expr *E = Attr.getArgAsExpr(0);
847 if (!checkUInt32Argument(S, Attr, E, Type, /*Idx=*/1))
855 << Attr.getName() << 0 << 3 << E->getSourceRange();
865 << Attr.getName() << 1;
870 PassObjectSizeAttr(Attr.getRange(), S.Context, (int)Type,
871 Attr.getAttributeSpellingListIndex()));
874 static void handleConsumableAttr(Sema &S, Decl *D, const AttributeList &Attr) {
877 if (Attr.isArgIdent(0)) {
878 IdentifierLoc *IL = Attr.getArgAsIdent(0);
882 << Attr.getName() << IL->Ident;
886 S.Diag(Attr.getLoc(), diag::err_attribute_argument_type)
887 << Attr.getName() << AANT_ArgumentIdentifier;
892 ConsumableAttr(Attr.getRange(), S.Context, DefaultState,
893 Attr.getAttributeSpellingListIndex()));
897 const AttributeList &Attr) {
903 S.Diag(Attr.getLoc(), diag::warn_attr_on_unconsumable_class) <<
914 const AttributeList &Attr) {
915 if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
918 if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), Attr))
922 for (unsigned ArgIndex = 0; ArgIndex < Attr.getNumArgs(); ++ArgIndex) {
927 if (Attr.isArgIdent(ArgIndex)) {
928 IdentifierLoc *Ident = Attr.getArgAsIdent(ArgIndex);
932 if (!S.checkStringLiteralArgumentAttr(Attr, ArgIndex, StateString, &Loc))
939 << Attr.getName() << StateString;
947 CallableWhenAttr(Attr.getRange(), S.Context, States.data(),
948 States.size(), Attr.getAttributeSpellingListIndex()));
952 const AttributeList &Attr) {
955 if (Attr.isArgIdent(0)) {
956 IdentifierLoc *Ident = Attr.getArgAsIdent(0);
962 << Attr.getName() << StateString;
966 S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) <<
967 Attr.getName() << AANT_ArgumentIdentifier;
978 // S.Diag(Attr.getLoc(), diag::warn_return_state_for_unconsumable_type) <<
984 ParamTypestateAttr(Attr.getRange(), S.Context, ParamState,
985 Attr.getAttributeSpellingListIndex()));
989 const AttributeList &Attr) {
992 if (Attr.isArgIdent(0)) {
993 IdentifierLoc *IL = Attr.getArgAsIdent(0);
997 << Attr.getName() << IL->Ident;
1001 S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) <<
1002 Attr.getName() << AANT_ArgumentIdentifier;
1026 // S.Diag(Attr.getLoc(), diag::warn_return_state_for_unconsumable_type) <<
1032 ReturnTypestateAttr(Attr.getRange(), S.Context, ReturnState,
1033 Attr.getAttributeSpellingListIndex()));
1036 static void handleSetTypestateAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1037 if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), Attr))
1041 if (Attr.isArgIdent(0)) {
1042 IdentifierLoc *Ident = Attr.getArgAsIdent(0);
1046 << Attr.getName() << Param;
1050 S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) <<
1051 Attr.getName() << AANT_ArgumentIdentifier;
1056 SetTypestateAttr(Attr.getRange(), S.Context, NewState,
1057 Attr.getAttributeSpellingListIndex()));
1061 const AttributeList &Attr) {
1062 if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), Attr))
1066 if (Attr.isArgIdent(0)) {
1067 IdentifierLoc *Ident = Attr.getArgAsIdent(0);
1071 << Attr.getName() << Param;
1075 S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) <<
1076 Attr.getName() << AANT_ArgumentIdentifier;
1081 TestTypestateAttr(Attr.getRange(), S.Context, TestState,
1082 Attr.getAttributeSpellingListIndex()));
1086 const AttributeList &Attr) {
1091 static void handlePackedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1093 TD->addAttr(::new (S.Context) PackedAttr(Attr.getRange(), S.Context,
1094 Attr.getAttributeSpellingListIndex()));
1100 S.Diag(Attr.getLoc(), diag::warn_attribute_packed_for_bitfield);
1103 Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
1105 S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
1108 static bool checkIBOutletCommon(Sema &S, Decl *D, const AttributeList &Attr) {
1114 S.Diag(Attr.getLoc(), diag::warn_iboutlet_object_type)
1115 << Attr.getName() << VD->getType() << 0;
1121 S.Diag(Attr.getLoc(), diag::warn_iboutlet_object_type)
1122 << Attr.getName() << PD->getType() << 1;
1127 S.Diag(Attr.getLoc(), diag::warn_attribute_iboutlet) << Attr.getName();
1134 static void handleIBOutlet(Sema &S, Decl *D, const AttributeList &Attr) {
1135 if (!checkIBOutletCommon(S, D, Attr))
1139 IBOutletAttr(Attr.getRange(), S.Context,
1140 Attr.getAttributeSpellingListIndex()));
1144 const AttributeList &Attr) {
1147 if (Attr.getNumArgs() > 1) {
1148 S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
1149 << Attr.getName() << 1;
1153 if (!checkIBOutletCommon(S, D, Attr))
1158 if (Attr.hasParsedType())
1159 PT = Attr.getTypeArg();
1161 PT = S.getTypeName(S.Context.Idents.get("NSObject"), Attr.getLoc(),
1164 S.Diag(Attr.getLoc(), diag::err_iboutletcollection_type) << "NSObject";
1172 QTLoc = S.Context.getTrivialTypeSourceInfo(QT, Attr.getLoc());
1179 S.Diag(Attr.getLoc(),
1186 IBOutletCollectionAttr(Attr.getRange(), S.Context, QTLoc,
1187 Attr.getAttributeSpellingListIndex()));
1214 static bool attrNonNullArgCheck(Sema &S, QualType T, const AttributeList &Attr,
1220 S.Diag(Attr.getLoc(), diag::warn_attribute_return_pointers_only)
1221 << Attr.getName() << AttrParmRange << TypeRange;
1223 S.Diag(Attr.getLoc(), diag::warn_attribute_pointers_only)
1224 << Attr.getName() << AttrParmRange << TypeRange << 0;
1230 static void handleNonNullAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1232 for (unsigned I = 0; I < Attr.getNumArgs(); ++I) {
1233 Expr *Ex = Attr.getArgAsExpr(I);
1235 if (!checkFunctionOrMethodParameterIndex(S, D, Attr, I + 1, Ex, Idx))
1240 !attrNonNullArgCheck(S, getFunctionOrMethodParamType(D, Idx), Attr,
1252 if (NonNullArgs.empty() && Attr.getLoc().isFileID() &&
1263 S.Diag(Attr.getLoc(), diag::warn_attribute_nonnull_no_pointers);
1270 NonNullAttr(Attr.getRange(), S.Context, Start, Size,
1271 Attr.getAttributeSpellingListIndex()));
1275 const AttributeList &Attr) {
1276 if (Attr.getNumArgs() > 0) {
1278 handleNonNullAttr(S, D, Attr);
1280 S.Diag(Attr.getLoc(), diag::warn_attribute_nonnull_parm_no_args)
1287 if (!attrNonNullArgCheck(S, D->getType(), Attr, SourceRange(),
1292 NonNullAttr(Attr.getRange(), S.Context, nullptr, 0,
1293 Attr.getAttributeSpellingListIndex()));
1297 const AttributeList &Attr) {
1300 if (!attrNonNullArgCheck(S, ResultType, Attr, SourceRange(), SR,
1305 ReturnsNonNullAttr(Attr.getRange(), S.Context,
1306 Attr.getAttributeSpellingListIndex()));
1310 const AttributeList &Attr) {
1311 Expr *E = Attr.getArgAsExpr(0),
1312 *OE = Attr.getNumArgs() > 1 ? Attr.getArgAsExpr(1) : nullptr;
1313 S.AddAssumeAlignedAttr(Attr.getRange(), D, E, OE,
1314 Attr.getAttributeSpellingListIndex());
1488 static void handleWeakRefAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1490 if (Attr.getNumArgs() > 1) {
1491 S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
1492 << Attr.getName() << 1;
1510 S.Diag(Attr.getLoc(), diag::err_attribute_weakref_not_global_context)
1541 if (Attr.getNumArgs() && S.checkStringLiteralArgumentAttr(Attr, 0, Str))
1544 D->addAttr(::new (S.Context) AliasAttr(Attr.getRange(), S.Context, Str,
1545 Attr.getAttributeSpellingListIndex()));
1548 WeakRefAttr(Attr.getRange(), S.Context,
1549 Attr.getAttributeSpellingListIndex()));
1552 static void handleIFuncAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1554 if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str))
1560 S.Diag(Attr.getLoc(), diag::err_alias_is_definition) << FD << 1;
1566 S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
1570 D->addAttr(::new (S.Context) IFuncAttr(Attr.getRange(), S.Context, Str,
1571 Attr.getAttributeSpellingListIndex()));
1574 static void handleAliasAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1576 if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str))
1580 S.Diag(Attr.getLoc(), diag::err_alias_not_supported_on_darwin);
1584 S.Diag(Attr.getLoc(), diag::err_alias_not_supported_on_nvptx);
1590 S.Diag(Attr.getLoc(), diag::err_alias_is_definition) << FD << 0;
1596 S.Diag(Attr.getLoc(), diag::err_alias_is_definition) << VD << 0;
1603 D->addAttr(::new (S.Context) AliasAttr(Attr.getRange(), S.Context, Str,
1604 Attr.getAttributeSpellingListIndex()));
1607 static void handleColdAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1608 if (checkAttrMutualExclusion<HotAttr>(S, D, Attr.getRange(), Attr.getName()))
1611 D->addAttr(::new (S.Context) ColdAttr(Attr.getRange(), S.Context,
1612 Attr.getAttributeSpellingListIndex()));
1615 static void handleHotAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1616 if (checkAttrMutualExclusion<ColdAttr>(S, D, Attr.getRange(), Attr.getName()))
1619 D->addAttr(::new (S.Context) HotAttr(Attr.getRange(), S.Context,
1620 Attr.getAttributeSpellingListIndex()));
1624 const AttributeList &Attr) {
1628 if (!S.checkStringLiteralArgumentAttr(Attr, 0, Model, &LiteralLoc))
1639 TLSModelAttr(Attr.getRange(), S.Context, Model,
1640 Attr.getAttributeSpellingListIndex()));
1643 static void handleRestrictAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1647 Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
1651 S.Diag(Attr.getLoc(), diag::warn_attribute_return_pointers_only)
1652 << Attr.getName() << getFunctionOrMethodResultSourceRange(D);
1655 static void handleCommonAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1657 S.Diag(Attr.getLoc(), diag::err_attribute_not_supported_in_lang)
1658 << Attr.getName() << AttributeLangSupport::Cpp;
1662 if (CommonAttr *CA = S.mergeCommonAttr(D, Attr.getRange(), Attr.getName(),
1663 Attr.getAttributeSpellingListIndex()))
1667 static void handleNakedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1668 if (checkAttrMutualExclusion<DisableTailCallsAttr>(S, D, Attr.getRange(),
1669 Attr.getName()))
1672 D->addAttr(::new (S.Context) NakedAttr(Attr.getRange(), S.Context,
1673 Attr.getAttributeSpellingListIndex()));
1676 static void handleNoReturnAttr(Sema &S, Decl *D, const AttributeList &attr) {
1679 if (S.CheckNoReturnAttr(attr)) return;
1682 S.Diag(attr.getLoc(), diag::warn_attribute_wrong_decl_type)
1683 << attr.getName() << ExpectedFunctionOrMethod;
1688 NoReturnAttr(attr.getRange(), S.Context,
1689 attr.getAttributeSpellingListIndex()));
1692 bool Sema::CheckNoReturnAttr(const AttributeList &attr) {
1693 if (!checkAttributeNumArgs(*this, attr, 0)) {
1694 attr.setInvalid();
1702 const AttributeList &Attr) {
1710 S.Diag(Attr.getLoc(),
1711 Attr.isCXX11Attribute() ? diag::err_attribute_wrong_decl_type
1713 << Attr.getName() << ExpectedFunctionMethodOrBlock;
1719 AnalyzerNoReturnAttr(Attr.getRange(), S.Context,
1720 Attr.getAttributeSpellingListIndex()));
1724 static void handleVecReturnAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1749 S.Diag(Attr.getLoc(), diag::err_repeat_attribute) << A;
1757 S.Diag(Attr.getLoc(), diag::err_attribute_vecreturn_only_vector_member);
1762 S.Diag(Attr.getLoc(), diag::err_attribute_vecreturn_only_pod_record);
1768 S.Diag(Attr.getLoc(), diag::err_attribute_vecreturn_only_vector_member);
1775 VecReturnAttr(Attr.getRange(), S.Context,
1776 Attr.getAttributeSpellingListIndex()));
1780 const AttributeList &Attr) {
1785 S.Diag(Attr.getLoc(),
1792 Attr.getRange(), S.Context,
1793 Attr.getAttributeSpellingListIndex()));
1797 const AttributeList &Attr) {
1798 if (checkAttrMutualExclusion<AlwaysInlineAttr>(S, D, Attr.getRange(),
1799 Attr.getName()))
1803 Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
1807 const AttributeList &Attr) {
1808 if (checkAttrMutualExclusion<NakedAttr>(S, D, Attr.getRange(),
1809 Attr.getName()))
1813 Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
1816 static void handleUsedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1819 S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
1823 S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
1824 << Attr.getName() << ExpectedVariableOrFunction;
1829 UsedAttr(Attr.getRange(), S.Context,
1830 Attr.getAttributeSpellingListIndex()));
1833 Attr) {
1834 bool IsCXX1zAttr = Attr.isCXX11Attribute() && !Attr.getScopeName();
1838 // member per [dcl.attr.unused]p2.
1840 S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
1841 << Attr.getName() << ExpectedForMaybeUnused;
1849 S.Diag(Attr.getLoc(), diag::ext_cxx1z_attr) << Attr.getName();
1852 Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
1855 static void handleConstructorAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1857 if (Attr.getNumArgs() &&
1858 !checkUInt32Argument(S, Attr, Attr.getArgAsExpr(0), priority))
1862 ConstructorAttr(Attr.getRange(), S.Context, priority,
1863 Attr.getAttributeSpellingListIndex()));
1866 static void handleDestructorAttr(Sema &S, Decl *D, const AttributeList &Attr) {
1868 if (Attr.getNumArgs() &&
1869 !checkUInt32Argument(S, Attr, Attr.getArgAsExpr(0), priority))
1873 DestructorAttr(Attr.getRange(), S.Context, priority,
1874 Attr.getAttributeSpellingListIndex()));
1879 const AttributeList &Attr) {
1882 if (Attr.getNumArgs() == 1 && !S.checkStringLiteralArgumentAttr(Attr, 0, Str))
1885 D->addAttr(::new (S.Context) AttrTy(Attr.getRange(), S.Context, Str,
1886 Attr.getAttributeSpellingListIndex()));
1890 const AttributeList &Attr) {
1892 S.Diag(Attr.getLoc(), diag::err_objc_attr_protocol_requires_definition)
1893 << Attr.getName() << Attr.getRange();
1898 ObjCExplicitProtocolImplAttr(Attr.getRange(), S.Context,
1899 Attr.getAttributeSpellingListIndex()));
2124 const AttributeList &Attr) {
2125 if (!checkAttributeNumArgs(S, Attr, 1))
2127 IdentifierLoc *Platform = Attr.getArgAsIdent(0);
2128 unsigned Index = Attr.getAttributeSpellingListIndex();
2137 S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
2141 AvailabilityChange Introduced = Attr.getAvailabilityIntroduced();
2142 AvailabilityChange Deprecated = Attr.getAvailabilityDeprecated();
2143 AvailabilityChange Obsoleted = Attr.getAvailabilityObsoleted();
2144 bool IsUnavailable = Attr.getUnavailableLoc().isValid();
2145 bool IsStrict = Attr.getStrictLoc().isValid();
2148 dyn_cast_or_null<StringLiteral>(Attr.getMessageExpr()))
2152 dyn_cast_or_null<StringLiteral>(Attr.getReplacementExpr()))
2155 AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr(ND, Attr.getRange(), II,
2200 Attr.getRange(),
2225 Attr.getRange(),
2272 static void handleVisibilityAttr(Sema &S, Decl *D, const AttributeList &Attr,
2276 S.Diag(Attr.getRange().getBegin(), diag::warn_attribute_ignored)
2277 << Attr.getName();
2286 S.Diag(Attr.getRange().getBegin(), diag::err_attribute_wrong_decl_type)
2287 << Attr.getName() << ExpectedTypeOrNamespace;
2294 if (!S.checkStringLiteralArgumentAttr(Attr, 0, TypeStr, &LiteralLoc))
2300 << Attr.getName() << TypeStr;
2308 S.Diag(Attr.getLoc(), diag::warn_attribute_protected_visibility);
2312 unsigned Index = Attr.getAttributeSpellingListIndex();
2313 clang::Attr *newAttr;
2315 newAttr = S.mergeTypeVisibilityAttr(D, Attr.getRange(),
2319 newAttr = S.mergeVisibilityAttr(D, Attr.getRange(), type, Index);
2326 const AttributeList &Attr) {
2328 if (!Attr.isArgIdent(0)) {
2329 S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type)
2330 << Attr.getName() << 1 << AANT_ArgumentIdentifier;
2334 IdentifierLoc *IL = Attr.getArgAsIdent(0);
2337 S.Diag(IL->Loc, diag::warn_attribute_type_not_supported) << Attr.getName()
2350 method->addAttr(new (S.Context) ObjCMethodFamilyAttr(Attr.getRange(),
2352 Attr.getAttributeSpellingListIndex()));
2355 static void handleObjCNSObject(Sema &S, Decl *D, const AttributeList &Attr) {
2380 ObjCNSObjectAttr(Attr.getRange(), S.Context,
2381 Attr.getAttributeSpellingListIndex()));
2384 static void handleObjCIndependentClass(Sema &S, Decl *D, const AttributeList &Attr) {
2396 ObjCIndependentClassAttr(Attr.getRange(), S.Context,
2397 Attr.getAttributeSpellingListIndex()));
2400 static void handleBlocksAttr(Sema &S, Decl *D, const AttributeList &Attr) {
2401 if (!Attr.isArgIdent(0)) {
2402 S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type)
2403 << Attr.getName() << 1 << AANT_ArgumentIdentifier;
2407 IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
2410 S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported)
2411 << Attr.getName() << II;
2416 BlocksAttr(Attr.getRange(), S.Context, type,
2417 Attr.getAttributeSpellingListIndex()));
2420 static void handleSentinelAttr(Sema &S, Decl *D, const AttributeList &Attr) {
2422 if (Attr.getNumArgs() > 0) {
2423 Expr *E = Attr.getArgAsExpr(0);
2427 S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type)
2428 << Attr.getName() << 1 << AANT_ArgumentIntegerConstant
2434 S.Diag(Attr.getLoc(), diag::err_attribute_sentinel_less_than_zero)
2443 if (Attr.getNumArgs() > 1) {
2444 Expr *E = Attr.getArgAsExpr(1);
2448 S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type)
2449 << Attr.getName() << 2 << AANT_ArgumentIntegerConstant
2458 S.Diag(Attr.getLoc(), diag::err_attribute_sentinel_not_zero_or_one)
2467 S.Diag(Attr.getLoc(), diag::warn_attribute_sentinel_named_arguments);
2472 S.Diag(Attr.getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
2477 S.Diag(Attr.getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
2482 S.Diag(Attr.getLoc(), diag::warn_attribute_sentinel_not_variadic) << 1;
2493 S.Diag(Attr.getLoc(), diag::warn_attribute_sentinel_not_variadic) << m;
2497 S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
2498 << Attr.getName() << ExpectedFunctionMethodOrBlock;
2502 S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
2503 << Attr.getName() << ExpectedFunctionMethodOrBlock;
2507 SentinelAttr(Attr.getRange(), S.Context, sentinel, nullPos,
2508 Attr.getAttributeSpellingListIndex()));
2511 static void handleWarnUnusedResult(Sema &S, Decl *D, const AttributeList &Attr) {
2514 S.Diag(Attr.getLoc(), diag::warn_attribute_void_function_method)
2515 << Attr.getName() << 0;
2520 S.Diag(Attr.getLoc(), diag::warn_attribute_void_function_method)
2521 << Attr.getName() << 1;
2527 if (!S.getLangOpts().CPlusPlus1z && Attr.isCXX11Attribute() &&
2528 !Attr.getScopeName())
2529 S.Diag(Attr.getLoc(), diag::ext_cxx1z_attr) << Attr.getName();
2532 WarnUnusedResultAttr(Attr.getRange(), S.Context,
2533 Attr.getAttributeSpellingListIndex()));
2536 static void handleWeakImportAttr(Sema &S, Decl *D, const AttributeList &Attr) {
2541 S.Diag(Attr.getLoc(), diag::warn_attribute_invalid_on_definition)
2548 S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
2549 << Attr.getName() << ExpectedVariableOrFunction;
2555 WeakImportAttr(Attr.getRange(), S.Context,
2556 Attr.getAttributeSpellingListIndex()));
2562 const AttributeList &Attr) {
2565 const Expr *E = Attr.getArgAsExpr(i);
2566 if (!checkUInt32Argument(S, Attr, E, WGSize[i], i))
2569 S.Diag(Attr.getLoc(), diag::err_attribute_argument_is_zero)
2570 << Attr.getName() << E->getSourceRange();
2579 S.Diag(Attr.getLoc(), diag::warn_duplicate_attribute) << Attr.getName();
2581 D->addAttr(::new (S.Context) WorkGroupAttr(Attr.getRange(), S.Context,
2583 Attr.getAttributeSpellingListIndex()));
2586 static void handleVecTypeHint(Sema &S, Decl *D, const AttributeList &Attr) {
2587 if (!Attr.hasParsedType()) {
2588 S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
2589 << Attr.getName() << 1;
2594 QualType ParmType = S.GetTypeFromParser(Attr.getTypeArg(), &ParmTSI);
2600 S.Diag(Attr.getLoc(), diag::err_attribute_argument_vec_type_hint)
2607 S.Diag(Attr.getLoc(), diag::warn_duplicate_attribute) << Attr.getName();
2612 D->addAttr(::new (S.Context) VecTypeHintAttr(Attr.getLoc(), S.Context,
2614 Attr.getAttributeSpellingListIndex()));
2640 static void handleSectionAttr(Sema &S, Decl *D, const AttributeList &Attr) {
2645 if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str, &LiteralLoc))
2659 unsigned Index = Attr.getAttributeSpellingListIndex();
2660 SectionAttr *NewAttr = S.mergeSectionAttr(D, Attr.getRange(), Str, Index);
2675 static void handleTargetAttr(Sema &S, Decl *D, const AttributeList &Attr) {
2678 if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str, &LiteralLoc))
2681 unsigned Index = Attr.getAttributeSpellingListIndex();
2683 Attr.getRange(), S.Context, Str, Index);
2687 static void handleCleanupAttr(Sema &S, Decl *D, const AttributeList &Attr) {
2690 S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
2694 Expr *E = Attr.getArgAsExpr(0);
2746 CleanupAttr(Attr.getRange(), S.Context, FD,
2747 Attr.getAttributeSpellingListIndex()));
2752 static void handleFormatArgAttr(Sema &S, Decl *D, const AttributeList &Attr) {
2753 Expr *IdxExpr = Attr.getArgAsExpr(0);
2755 if (!checkFunctionOrMethodParameterIndex(S, D, Attr, 1, IdxExpr, Idx))
2766 S.Diag(Attr.getLoc(), diag::err_format_attribute_not)
2776 S.Diag(Attr.getLoc(), diag::err_format_attribute_result_not)
2789 FormatArgAttr(Attr.getRange(), S.Context, Val.getZExtValue(),
2790 Attr.getAttributeSpellingListIndex()));
2825 const AttributeList &Attr) {
2827 S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
2832 S.Diag(Attr.getLoc(), diag::err_init_priority_object_attr);
2833 Attr.setInvalid();
2840 S.Diag(Attr.getLoc(), diag::err_init_priority_object_attr);
2841 Attr.setInvalid();
2845 Expr *E = Attr.getArgAsExpr(0);
2847 if (!checkUInt32Argument(S, Attr, E, prioritynum)) {
2848 Attr.setInvalid();
2853 S.Diag(Attr.getLoc(), diag::err_attribute_argument_outof_range)
2854 << E->getSourceRange() << Attr.getName() << 101 << 65535;
2855 Attr.setInvalid();
2859 InitPriorityAttr(Attr.getRange(), S.Context, prioritynum,
2860 Attr.getAttributeSpellingListIndex()));
2886 static void handleFormatAttr(Sema &S, Decl *D, const AttributeList &Attr) {
2887 if (!Attr.isArgIdent(0)) {
2888 S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type)
2889 << Attr.getName() << 1 << AANT_ArgumentIdentifier;
2898 IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
2913 S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported)
2914 << Attr.getName() << II->getName();
2919 Expr *IdxExpr = Attr.getArgAsExpr(1);
2921 if (!checkUInt32Argument(S, Attr, IdxExpr, Idx, 2))
2925 S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_bounds)
2926 << Attr.getName() << 2 << IdxExpr->getSourceRange();
2935 S.Diag(Attr.getLoc(),
2948 S.Diag(Attr.getLoc(), diag::err_format_attribute_not)
2957 S.Diag(Attr.getLoc(), diag::err_format_attribute_not)
2964 S.Diag(Attr.getLoc(), diag::err_format_attribute_not)
2971 Expr *FirstArgExpr = Attr.getArgAsExpr(2);
2973 if (!checkUInt32Argument(S, Attr, FirstArgExpr, FirstArg, 3))
2990 S.Diag(Attr.getLoc(), diag::err_format_strftime_third_parameter)
2996 S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_bounds)
2997 << Attr.getName() << 3 << FirstArgExpr->getSourceRange();
3001 FormatAttr *NewAttr = S.mergeFormatAttr(D, Attr.getRange(), II,
3003 Attr.getAttributeSpellingListIndex());
3009 const AttributeList &Attr) {
3019 S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
3020 << Attr.getName() << ExpectedUnion;
3025 S.Diag(Attr.getLoc(),
3033 S.Diag(Attr.getLoc(), diag::warn_transparent_union_attribute_zero_fields);
3073 TransparentUnionAttr(Attr.getRange(), S.Context,
3074 Attr.getAttributeSpellingListIndex()));
3077 static void handleAnnotateAttr(Sema &S, Decl *D, const AttributeList &Attr) {
3081 if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str))
3091 AnnotateAttr(Attr.getRange(), S.Context, Str,
3092 Attr.getAttributeSpellingListIndex()));
3096 const AttributeList &Attr) {
3097 S.AddAlignValueAttr(Attr.getRange(), D, Attr.getArgAsExpr(0),
3098 Attr.getAttributeSpellingListIndex());
3146 static void handleAlignedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
3148 if (Attr.getNumArgs() > 1) {
3149 S.Diag(Attr
3150 << Attr.getName() << 1;
3154 if (Attr.getNumArgs() == 0) {
3155 D->addAttr(::new (S.Context) AlignedAttr(Attr.getRange(), S.Context,
3156 true, nullptr, Attr.getAttributeSpellingListIndex()));
3160 Expr *E = Attr.getArgAsExpr(0);
3161 if (Attr.isPackExpansion() && !E->containsUnexpandedParameterPack()) {
3162 S.Diag(Attr.getEllipsisLoc(),
3167 if (!Attr.isPackExpansion() && S.DiagnoseUnexpandedParameterPack(E))
3173 S.Diag(Attr.getLoc(), diag::err_alignment_dependent_typedef_name)
3180 S.AddAlignedAttr(Attr.getRange(), D, E, Attr.getAttributeSpellingListIndex(),
3181 Attr.isPackExpansion());
3234 // FIXME: Cache the number on the Attr object?
3289 // FIXME: Cache the number on the Attr object if non-dependent?
3425 static void handleModeAttr(Sema &S, Decl *D, const AttributeList &Attr) {
3428 if (!Attr.isArgIdent(0)) {
3429 S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) << Attr.getName()
3434 IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
3436 S.AddModeAttr(Attr.getRange(), D, Name, Attr.getAttributeSpellingListIndex());
3581 static void handleNoDebugAttr(Sema &S, Decl *D, const AttributeList &Attr) {
3583 NoDebugAttr(Attr.getRange(), S.Context,
3584 Attr.getAttributeSpellingListIndex()));
3674 const AttributeList &Attr) {
3675 if (checkAttrMutualExclusion<NotTailCalledAttr>(S, D, Attr.getRange(),
3676 Attr.getName()))
3680 D, Attr.getRange(), Attr.getName(),
3681 Attr.getAttributeSpellingListIndex()))
3685 static void handleMinSizeAttr(Sema &S, Decl *D, const AttributeList &Attr) {
3687 D, Attr.getRange(), Attr.getAttributeSpellingListIndex()))
3692 const AttributeList &Attr) {
3694 D, Attr.getRange(), Attr.getAttributeSpellingListIndex()))
3698 static void handleGlobalAttr(Sema &S, Decl *D, const AttributeList &Attr) {
3699 if (checkAttrMutualExclusion<CUDADeviceAttr>(S, D, Attr.getRange(),
3700 Attr.getName()) ||
3701 checkAttrMutualExclusion<CUDAHostAttr>(S, D, Attr.getRange(),
3702 Attr.getName())) {
3727 CUDAGlobalAttr(Attr.getRange(), S.Context,
3728 Attr.getAttributeSpellingListIndex()));
3731 static void handleGNUInlineAttr(Sema &S, Decl *D, const AttributeList &Attr) {
3734 S.Diag(Attr.getLoc(), diag::warn_gnu_inline_attribute_requires_inline);
3739 GNUInlineAttr(Attr.getRange(), S.Context,
3740 Attr.getAttributeSpellingListIndex()));
3743 static void handleCallConvAttr(Sema &S, Decl *D, const AttributeList &Attr) {
3746 // Diagnostic is emitted elsewhere: here we store the (valid) Attr
3749 if (S.CheckCallingConvAttr(Attr, CC, /*FD*/nullptr))
3753 S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
3754 << Attr.getName() << ExpectedFunctionOrMethod;
3758 switch (Attr.getKind()) {
3761 FastCallAttr(Attr.getRange(), S.Context,
3762 Attr.getAttributeSpellingListIndex()));
3766 StdCallAttr(Attr.getRange(), S.Context,
3767 Attr.getAttributeSpellingListIndex()));
3771 ThisCallAttr(Attr.getRange(), S.Context,
3772 Attr.getAttributeSpellingListIndex()));
3776 CDeclAttr(Attr.getRange(), S.Context,
3777 Attr.getAttributeSpellingListIndex()));
3781 PascalAttr(Attr.getRange(), S.Context,
3782 Attr.getAttributeSpellingListIndex()));
3786 SwiftCallAttr(Attr.getRange(), S.Context,
3787 Attr.getAttributeSpellingListIndex()));
3791 VectorCallAttr(Attr.getRange(), S.Context,
3792 Attr.getAttributeSpellingListIndex()));
3796 MSABIAttr(Attr.getRange(), S.Context,
3797 Attr.getAttributeSpellingListIndex()));
3801 SysVABIAttr(Attr.getRange(), S.Context,
3802 Attr.getAttributeSpellingListIndex()));
3818 PcsAttr(Attr.getRange(), S.Context, PCS,
3819 Attr.getAttributeSpellingListIndex()));
3824 IntelOclBiccAttr(Attr.getRange(), S.Context,
3825 Attr.getAttributeSpellingListIndex()));
3829 Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
3833 Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
3840 bool Sema::CheckCallingConvAttr(const AttributeList &attr, CallingConv &CC,
3842 if (attr.isInvalid())
3845 if (attr.hasProcessingCache()) {
3846 CC = (CallingConv) attr.getProcessingCache();
3850 unsigned ReqArgs = attr.getKind() == AttributeList::AT_Pcs ? 1 : 0;
3851 if (!checkAttributeNumArgs(*this, attr, ReqArgs)) {
3852 attr.setInvalid();
3857 switch (attr.getKind()) {
3875 if (!checkStringLiteralArgumentAttr(attr, 0, StrRef)) {
3876 attr.setInvalid();
3887 attr.setInvalid();
3888 Diag(attr.getLoc(), diag::err_invalid_pcs);
3901 Diag(attr.getLoc(), diag::warn_cconv_ignored) << attr.getName();
3913 attr.setProcessingCache((unsigned) CC);
3950 static void handleParameterABIAttr(Sema &S, Decl *D, const AttributeList &attr,
3952 S.AddParameterABIAttr(attr.getRange(), D, abi,
3953 attr.getAttributeSpellingListIndex());
4009 bool Sema::CheckRegparmAttr(const AttributeList &Attr, unsigned &numParams) {
4010 if (Attr.isInvalid())
4013 if (!checkAttributeNumArgs(*this, Attr, 1)) {
4014 Attr.setInvalid();
4019 Expr *NumParamsExpr = Attr.getArgAsExpr(0);
4020 if (!checkUInt32Argument(*this, Attr, NumParamsExpr, NP)) {
4021 Attr.setInvalid();
4026 Diag(Attr.getLoc(), diag::err_attribute_regparm_wrong_platform)
4028 Attr.setInvalid();
4034 Diag(Attr.getLoc(), diag::err_attribute_regparm_invalid_number)
4036 Attr.setInvalid();
4048 const CUDALaunchBoundsAttr &Attr,
4061 << &Attr << Idx << AANT_ArgumentIntegerConstant << E->getSourceRange();
4072 << &Attr << Idx << E->getSourceRange();
4103 const AttributeList &Attr) {
4104 if (!checkAttributeAtLeastNumArgs(S, Attr, 1) ||
4105 !checkAttributeAtMostNumArgs(S, Attr, 2))
4108 S.AddLaunchBoundsAttr(Attr.getRange(), D, Attr.getArgAsExpr(0),
4109 Attr.getNumArgs() > 1 ? Attr.getArgAsExpr(1) : nullptr,
4110 Attr.getAttributeSpellingListIndex());
4114 const AttributeList &Attr) {
4115 if (!Attr.isArgIdent(0)) {
4116 S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type)
4117 << Attr.getName() << /* arg num = */ 1 << AANT_ArgumentIdentifier;
4121 if (!checkAttributeNumArgs(S, Attr, 3))
4124 IdentifierInfo *ArgumentKind = Attr.getArgAsIdent(0)->Ident;
4127 S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type)
4128 << Attr.getName() << ExpectedFunctionOrMethod;
4133 if (!checkFunctionOrMethodParameterIndex(S, D, Attr, 2, Attr.getArgAsExpr(1),
4138 if (!checkFunctionOrMethodParameterIndex(S, D, Attr, 3, Attr.getArgAsExpr(2),
4142 bool IsPointer = (Attr.getName()->getName() == "pointer_with_type_tag");
4147 S.Diag(Attr.getLoc(), diag::err_attribute_pointers_only)
4148 << Attr.getName() << 0;
4153 ArgumentWithTypeTagAttr(Attr.getRange(), S.Context, ArgumentKind,
4155 Attr.getAttributeSpellingListIndex()));
4159 const AttributeList &Attr) {
4160 if (!Attr.isArgIdent(0)) {
4161 S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type)
4162 << Attr.getName() << 1 << AANT_ArgumentIdentifier;
4166 if (!checkAttributeNumArgs(S, Attr, 1))
4170 S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type)
4171 << Attr.getName() << ExpectedVariable;
4175 IdentifierInfo *PointerKind = Attr.getArgAsIdent(0)->Ident;
4177 S.GetTypeFromParser(Attr.getMatchingCType(), &MatchingCTypeLoc);
4181 TypeTagForDatatypeAttr(Attr.getRange(), S.Context, PointerKind,
4183 Attr.getLayoutCompatible(),
4184 Attr.getMustBeNull(),
4185 Attr.getAttributeSpellingListIndex()));
4209 static void handleNSConsumedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
4210 S.AddNSConsumedAttr(Attr.getRange(), D, Attr.getAttributeSpellingListIndex(),
4211 Attr.getKind() == AttributeList::AT_NSConsumed,
4252 const AttributeList &Attr) {
4258 (Attr.getKind() == AttributeList::AT_NSReturnsRetained))
4268 << Attr.getName() << /*pointer-to-CF*/2
4269 << Attr.getRange();
4274 switch (Attr.getKind()) {
4288 << Attr.getRange() << Attr.getName() << ExpectedDeclKind;
4294 switch (Attr.getKind()) {
4317 << Attr.getName() << /*pointer-to-CF*/2
4318 << Attr.getRange();
4331 << Attr.getName() << SubjectKind << cf
4332 << Attr.getRange();
4337 switch (Attr.getKind()) {
4342 Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
4346 Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
4350 Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
4354 Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
4358 Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
4364 const AttributeList &attr) {
4368 SourceLocation loc = attr.getLoc();
4379 << attr.getName()
4388 attr.getRange(), S.Context, attr.getAttributeSpellingListIndex()));
4392 const AttributeList &attr) {
4398 << attr.getName() << 0;
4404 << attr.getName() << 1;
4409 ObjCRequiresSuperAttr(attr.getRange(), S.Context,
4410 attr.getAttributeSpellingListIndex()));
4414 const AttributeList &Attr) {
4415 if (checkAttrMutualExclusion<CFUnknownTransferAttr>(S, D, Attr.getRange(),
4416 Attr.getName()))
4420 CFAuditedTransferAttr(Attr.getRange(), S.Context,
4421 Attr.getAttributeSpellingListIndex()));
4425 const AttributeList &Attr) {
4426 if (checkAttrMutualExclusion<CFAuditedTransferAttr>(S, D, Attr.getRange(),
4427 Attr.getName()))
4431 CFUnknownTransferAttr(Attr.getRange(), S.Context,
4432 Attr.getAttributeSpellingListIndex()));
4436 const AttributeList &Attr) {
4437 IdentifierLoc * Parm = Attr.isArgIdent(0) ? Attr.getArgAsIdent(0) : nullptr;
4440 S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << Attr.getName() << 0;
4447 S.Diag(Attr.getLoc(), diag::err_objc_attr_typedef_not_id)
4448 << Attr.getName();
4455 S.Diag(Attr.getLoc(), diag::err_objc_attr_typedef_not_void_pointer);
4461 ObjCBridgeAttr(Attr.getRange(), S.Context, Parm->Ident,
4462 Attr.getAttributeSpellingListIndex()));
4466 const AttributeList &Attr) {
4467 IdentifierLoc * Parm = Attr.isArgIdent(0) ? Attr.getArgAsIdent(0) : nullptr;
4470 S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << Attr.getName() << 0;
4475 ObjCBridgeMutableAttr(Attr.getRange(), S.Context, Parm->Ident,
4476 Attr.getAttributeSpellingListIndex()));
4480 const AttributeList &Attr) {
4482 Attr.isArgIdent(0) ? Attr.getArgAsIdent(0)->Ident : nullptr;
4484 S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << Attr.getName() << 0;
4488 Attr.getArgAsIdent(1) ? Attr.getArgAsIdent(1)->Ident : nullptr;
4490 Attr.getArgAsIdent(2) ? Attr.getArgAsIdent(2)->Ident : nullptr;
4492 ObjCBridgeRelatedAttr(Attr.getRange(), S.Context, RelatedClass,
4494 Attr.getAttributeSpellingListIndex()));
4498 const AttributeList &Attr) {
4511 ObjCDesignatedInitializerAttr(Attr.getRange(), S.Context,
4512 Attr.getAttributeSpellingListIndex()));
4516 Attr) {
4518 if (!S.checkStringLiteralArgumentAttr(Attr, 0, MetaDataName))
4521 ObjCRuntimeNameAttr(Attr.getRange(), S.Context,
4523 Attr.getAttributeSpellingListIndex()));
4530 static void handleObjCBoxable(Sema &S, Decl *D, const AttributeList &Attr) {
4541 ObjCBoxableAttr(Attr.getRange(), S.Context,
4542 Attr.getAttributeSpellingListIndex());
4554 const AttributeList &Attr) {
4558 << Attr.getRange() << Attr.getName() << ExpectedVariable;
4562 const AttributeList &Attr) {
4568 S.Diag(Attr.getLoc(), diag::err_objc_precise_lifetime_bad_type)
4592 S.Diag(Attr.getLoc(), diag::warn_objc_precise_lifetime_meaningless)
4598 ObjCPreciseLifetimeAttr(Attr.getRange(), S.Context,
4599 Attr.getAttributeSpellingListIndex()));
4606 static void handleUuidAttr(Sema &S, Decl *D, const AttributeList &Attr) {
4608 S.Diag(Attr.getLoc(), diag::err_attribute_not_supported_in_lang)
4609 << Attr.getName() << AttributeLangSupport::C;
4614 S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
4615 << Attr.getName() << ExpectedClass;
4621 if (!S.checkStringLiteralArgumentAttr(Attr, 0, StrRef, &LiteralLoc))
4647 D->addAttr(::new (S.Context) UuidAttr(Attr.getRange(), S.Context, StrRef,
4648 Attr.getAttributeSpellingListIndex()));
4651 static void handleMSInheritanceAttr(Sema &S, Decl *D, const AttributeList &Attr) {
4653 S.Diag(Attr.getLoc(), diag::err_attribute_not_supported_in_lang)
4654 << Attr.getName() << AttributeLangSupport::C;
4658 D, Attr.getRange(), /*BestCase=*/true,
4659 Attr.getAttributeSpellingListIndex(),
4660 (MSInheritanceAttr::Spelling)Attr.getSemanticSpelling());
4668 const AttributeList &Attr) {
4671 S.Diag(Attr.getLoc(), diag::err_thread_unsupported);
4675 S.Diag(Attr.getLoc(), diag::err_declspec_thread_on_thread_variable);
4679 S.Diag(Attr.getLoc(), diag::err_thread_non_global) << "__declspec(thread)";
4683 Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
4686 static void handleAbiTagAttr(Sema &S, Decl *D, const AttributeList &Attr) {
4688 for (unsigned I = 0, E = Attr.getNumArgs(); I != E; ++I) {
4690 if (!S.checkStringLiteralArgumentAttr(Attr, I, Tag))
4697 S.Diag(Attr.getLoc(), diag::warn_attr_abi_tag_namespace) << 0;
4701 S.Diag(Attr.getLoc(), diag::warn_attr_abi_tag_namespace) << 1;
4704 if (Attr.getNumArgs() == 0)
4706 } else if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
4714 AbiTagAttr(Attr.getRange(), S.Context, Tags.data(), Tags.size(),
4715 Attr.getAttributeSpellingListIndex()));
4719 const AttributeList &Attr) {
4721 if (Attr.getNumArgs() > 1) {
4722 S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments)
4723 << Attr.getName() << 1;
4730 if (Attr.getNumArgs() == 0)
4732 else if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str, &ArgLoc))
4737 S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported)
4738 << Attr.getName() << Str << ArgLoc;
4742 unsigned Index = Attr.getAttributeSpellingListIndex();
4744 ARMInterruptAttr(Attr.getLoc(), S.Context, Kind, Index));
4748 const AttributeList &Attr) {
4749 if (!checkAttributeNumArgs(S, Attr, 1))
4752 if (!Attr.isArgExpr(0)) {
4753 S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) << Attr.getName()
4760 Expr *NumParamsExpr = static_cast<Expr *>(Attr.getArgAsExpr(0));
4763 S.Diag(Attr.getLoc(), diag::err_attribute_argument_type)
4764 << Attr.getName() << AANT_ArgumentIntegerConstant
4771 S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_bounds)
4772 << Attr.getName() << (int)NumParams.getSExtValue()
4778 MSP430InterruptAttr(Attr.getLoc(), S.Context, Num,
4779 Attr.getAttributeSpellingListIndex()));
4784 const AttributeList &Attr) {
4786 if (Attr.getNumArgs() > 1) {
4787 S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments)
4788 << Attr.getName() << 1;
4795 if (Attr.getNumArgs() == 0)
4797 else if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str, &ArgLoc))
4827 if (checkAttrMutualExclusion<Mips16Attr>(S, D, Attr.getRange(),
4828 Attr.getName()))
4833 S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported)
4834 << Attr.getName() << "'" + std::string(Str) + "'";
4839 Attr.getLoc(), S.Context, Kind, Attr.getAttributeSpellingListIndex()));
4843 const AttributeList &Attr) {
4853 S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
4854 << Attr.getName() << ExpectedFunctionWithProtoType;
4904 Attr.getLoc(), S.Context, Attr.getAttributeSpellingListIndex()));
4908 static void handleInterruptAttr(Sema &S, Decl *D, const AttributeList &Attr) {
4912 handleMSP430InterruptAttr(S, D, Attr);
4916 handleMipsInterruptAttr(S, D, Attr);
4920 handleAnyX86InterruptAttr(S, D, Attr);
4923 handleARMInterruptAttr(S, D, Attr);
4929 const AttributeList &Attr) {
4931 Expr *NumRegsExpr = static_cast<Expr *>(Attr.getArgAsExpr(0));
4932 if (!checkUInt32Argument(S, Attr, NumRegsExpr, NumRegs))
4936 AMDGPUNumVGPRAttr(Attr.getLoc(), S.Context,
4938 Attr.getAttributeSpellingListIndex()));
4942 const AttributeList &Attr) {
4944 Expr *NumRegsExpr = static_cast<Expr *>(Attr.getArgAsExpr(0));
4945 if (!checkUInt32Argument(S, Attr, NumRegsExpr, NumRegs))
4949 AMDGPUNumSGPRAttr(Attr.getLoc(), S.Context,
4951 Attr.getAttributeSpellingListIndex()));
4955 const AttributeList& Attr) {
4969 S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
4970 << Attr.getName() << /* function */0;
4975 X86ForceAlignArgPointerAttr(Attr.getRange(), S.Context,
4976 Attr.getAttributeSpellingListIndex()));
4979 static void handleLayoutVersion(Sema &S, Decl *D, const AttributeList &Attr) {
4981 Expr *VersionExpr = static_cast<Expr *>(Attr.getArgAsExpr(0));
4982 if (!checkUInt32Argument(S, Attr, Attr
4987 S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_bounds)
4988 << Attr.getName() << Version << VersionExpr->getSourceRange();
4993 LayoutVersionAttr(Attr.getRange(), S.Context, Version,
4994 Attr.getAttributeSpellingListIndex()));
5050 Attr *NewAttr = A.getKind() == AttributeList::AT_DLLExport
5051 ? (Attr *)S.mergeDLLExportAttr(D, A.getRange(), Index)
5052 : (Attr *)S.mergeDLLImportAttr(D, A.getRange(), Index);
5093 static void handleCapabilityAttr(Sema &S, Decl *D, const AttributeList &Attr) {
5104 if (Attr.getKind() == AttributeList::AT_Capability &&
5105 !S.checkStringLiteralArgumentAttr(Attr, 0, N, &LiteralLoc))
5113 D->addAttr(::new (S.Context) CapabilityAttr(Attr.getRange(), S.Context, N,
5114 Attr.getAttributeSpellingListIndex()));
5118 const AttributeList &Attr) {
5119 D->addAttr(::new (S.Context) AssertCapabilityAttr(Attr.getRange(), S.Context,
5120 Attr.getArgAsExpr(0),
5121 Attr.getAttributeSpellingListIndex()));
5125 const AttributeList &Attr) {
5127 if (!checkLockFunAttrCommon(S, D, Attr, Args))
5130 D->addAttr(::new (S.Context) AcquireCapabilityAttr(Attr.getRange(),
5133 Attr.getAttributeSpellingListIndex()));
5137 const AttributeList &Attr) {
5139 if (!checkTryLockFunAttrCommon(S, D, Attr, Args))
5142 D->addAttr(::new (S.Context) TryAcquireCapabilityAttr(Attr.getRange(),
5144 Attr.getArgAsExpr(0),
5147 Attr.getAttributeSpellingListIndex()));
5151 const AttributeList &Attr) {
5154 checkAttrArgsAreCapabilityObjs(S, D, Attr, Args, 0, true);
5157 Attr.getRange(), S.Context, Args.data(), Args.size(),
5158 Attr.getAttributeSpellingListIndex()));
5162 const AttributeList &Attr) {
5163 if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
5168 checkAttrArgsAreCapabilityObjs(S, D, Attr, Args);
5173 RequiresCapabilityAttr(Attr.getRange(), S.Context, Args.data(),
5174 Args.size(), Attr.getAttributeSpellingListIndex());
5179 static void handleDeprecatedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
5182 S.Diag(Attr.getLoc(), diag::warn_deprecated_anonymous_namespace);
5192 if (Attr.isArgExpr(0) && Attr.getArgAsExpr(0) &&
5193 !S.checkStringLiteralArgumentAttr(Attr, 0, Str))
5197 if (Attr.isDeclspecAttribute() || Attr.isCXX11Attribute())
5198 checkAttributeAtMostNumArgs(S, Attr, 1);
5199 else if (Attr.isArgExpr(1) && Attr.getArgAsExpr(1) &&
5200 !S.checkStringLiteralArgumentAttr(Attr, 1, Replacement))
5204 if (Attr.isCXX11Attribute() &&
5205 !(Attr.hasScope() && Attr.getScopeName()->isStr("gnu")))
5206 S.Diag(Attr.getLoc(), diag::ext_cxx14_attr) << Attr.getName();
5208 D->addAttr(::new (S.Context) DeprecatedAttr(Attr.getRange(), S.Context, Str,
5210 Attr.getAttributeSpellingListIndex()));
5213 static void handleNoSanitizeAttr(Sema &S, Decl *D, const AttributeList &Attr) {
5214 if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
5219 for (unsigned I = 0, E = Attr.getNumArgs(); I != E; ++I) {
5223 if (!S.checkStringLiteralArgumentAttr(Attr, I, SanitizerName, &LiteralLoc))
5233 Attr.getRange(), S.Context, Sanitizers.data(), Sanitizers.size(),
5234 Attr.getAttributeSpellingListIndex()));
5238 const AttributeList &Attr) {
5239 StringRef AttrName = Attr.getName()->getName();
5248 NoSanitizeAttr(Attr.getRange(), S.Context, &SanitizerName, 1,
5249 Attr.getAttributeSpellingListIndex()));
5253 const AttributeList &Attr) {
5255 S.mergeInternalLinkageAttr(D, Attr.getRange(), Attr.getName(),
5256 Attr.getAttributeSpellingListIndex()))
5260 static void handleOpenCLNoSVMAttr(Sema &S, Decl *D, const AttributeList &Attr) {
5262 S.Diag(Attr.getLoc(), diag::err_attribute_requires_opencl_version)
5263 << Attr.getName() << "2.0" << 0;
5265 S.Diag(Attr.getLoc(), diag::warn_opencl_attr_deprecated_ignored)
5266 << Attr.getName() << "2.0";
5273 const AttributeList &Attr) {
5279 if (Attr.hasCustomParsing() ||
5280 Attr.getKind() == AttributeList::UnknownAttribute)
5285 if (!Attr.diagnoseLangOpts(S))
5288 if (Attr.getMinArgs() == Attr.getMaxArgs()) {
5291 if (!checkAttributeNumArgs(S, Attr, Attr.getMinArgs()))
5295 if (Attr.getMinArgs() &&
5296 !checkAttributeAtLeastNumArgs(S, Attr, Attr.getMinArgs()))
5298 else if (!Attr.hasVariadicArg() && Attr.getMaxArgs() &&
5299 !checkAttributeAtMostNumArgs(S, Attr, Attr.getMaxArgs()))
5304 if (!Attr.diagnoseAppertainsTo(S, D))
5311 const AttributeList &Attr) {
5317 S.Diag(Attr.getLoc(), diag::err_opencl_multiple_access_qualifiers)
5330 if (Attr.getName()->getName().find("read_write") != StringRef::npos) {
5332 S.Diag(Attr.getLoc(), diag::err_opencl_invalid_read_write)
5333 << Attr.getName() << PDecl->getType() << DeclTy->isImageType();
5341 Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
5352 const AttributeList &Attr,
5354 if (Attr.isInvalid() || Attr.getKind() == AttributeList::IgnoredAttribute)
5359 if (Attr.isCXX11Attribute() && !IncludeCXX11Attributes)
5365 if (Attr.getKind() == AttributeList::UnknownAttribute ||
5366 !Attr.existsInTarget(S.Context.getTargetInfo())) {
5367 S.Diag(Attr.getLoc(), Attr.isDeclspecAttribute()
5370 << Attr.getName();
5374 if (handleCommonAttributeFeatures(S, scope, D, Attr))
5377 switch (Attr.getKind()) {
5379 if (!Attr.isStmtAttr()) {
5381 assert(Attr.isTypeAttr() && "Non-type attribute not handled");
5384 S.Diag(Attr.getLoc(), diag::err_stmt_attribute_invalid_on_decl)
5385 << Attr.getName() << D->getLocation();
5388 handleInterruptAttr(S, D, Attr);
5391 handleX86ForceAlignArgPointerAttr(S, D, Attr);
5395 handleDLLAttr(S, D, Attr);
5399 Attr);
5402 handleSimpleAttribute<NoMips16Attr>(S, D, Attr);
5405 handleAMDGPUNumVGPRAttr(S, D, Attr);
5408 handleAMDGPUNumSGPRAttr(S, D, Attr);
5411 handleSimpleAttribute<IBActionAttr>(S, D, Attr);
5414 handleIBOutlet(S, D, Attr);
5417 handleIBOutletCollection(S, D, Attr);
5420 handleIFuncAttr(S, D, Attr);
5423 handleAliasAttr(S, D, Attr);
5426 handleAlignedAttr(S, D, Attr);
5429 handleAlignValueAttr(S, D, Attr);
5432 handleAlwaysInlineAttr(S, D, Attr);
5435 handleAnalyzerNoReturnAttr(S, D, Attr);
5438 handleTLSModelAttr(S, D, Attr);
5441 handleAnnotateAttr(S, D, Attr);
5444 handleAvailabilityAttr(S, D, Attr);
5447 handleDependencyAttr(S, scope, D, Attr);
5450 handleCommonAttr(S, D, Attr);
5454 Attr);
5457 handlePassObjectSizeAttr(S, D, Attr);
5460 handleConstructorAttr(S, D, Attr);
5463 handleSimpleAttribute<CXX11NoReturnAttr>(S, D, Attr);
5466 handleDeprecatedAttr(S, D, Attr);
5469 handleDestructorAttr(S, D, Attr);
5472 handleEnableIfAttr(S, D, Attr);
5475 handleExtVectorTypeAttr(S, scope, D, Attr);
5478 handleMinSizeAttr(S, D, Attr);
5481 handleOptimizeNoneAttr(S, D, Attr);
5484 handleSimpleAttribute<FlagEnumAttr>(S, D, Attr);
5487 handleSimpleAttribute<FlattenAttr>(S, D, Attr);
5490 handleFormatAttr(S, D, Attr);
5493 handleFormatArgAttr(S, D, Attr);
5496 handleGlobalAttr(S, D, Attr);
5500 Attr);
5504 Attr);
5507 handleGNUInlineAttr(S, D, Attr);
5510 handleLaunchBoundsAttr(S, D, Attr);
5513 handleRestrictAttr(S, D, Attr);
5516 handleSimpleAttribute<MayAliasAttr>(S, D, Attr);
5519 handleModeAttr(S, D, Attr);
5522 handleSimpleAttribute<NoAliasAttr>(S, D, Attr);
5525 handleSimpleAttribute<NoCommonAttr>(S, D, Attr);
5528 handleSimpleAttribute<NoSplitStackAttr>(S, D, Attr);
5532 handleNonNullAttrParameter(S, PVD, Attr);
5534 handleNonNullAttr(S, D, Attr);
5537 handleReturnsNonNullAttr(S, D, Attr);
5540 handleAssumeAlignedAttr(S, D, Attr);
5543 handleSimpleAttribute<OverloadableAttr>(S, D, Attr);
5546 handleOwnershipAttr(S, D, Attr);
5549 handleColdAttr(S, D, Attr);
5552 handleHotAttr(S, D, Attr);
5555 handleNakedAttr(S, D, Attr);
5558 handleNoReturnAttr(S, D, Attr);
5561 handleSimpleAttribute<NoThrowAttr>(S, D, Attr);
5565 Attr);
5568 handleVecReturnAttr(S, D, Attr);
5571 handleObjCOwnershipAttr(S, D, Attr);
5574 handleObjCPreciseLifetimeAttr(S, D, Attr);
5577 handleObjCReturnsInnerPointerAttr(S, D, Attr);
5580 handleObjCRequiresSuperAttr(S, D, Attr);
5583 handleObjCBridgeAttr(S, scope, D, Attr);
5586 handleObjCBridgeMutableAttr(S, scope, D, Attr);
5589 handleObjCBridgeRelatedAttr(S, scope, D, Attr);
5592 handleObjCDesignatedInitializer(S, D, Attr);
5595 handleObjCRuntimeName(S, D, Attr);
5598 handleSimpleAttribute<ObjCRuntimeVisibleAttr>(S, D, Attr);
5601 handleObjCBoxable(S, D, Attr);
5604 handleCFAuditedTransferAttr(S, D, Attr);
5607 handleCFUnknownTransferAttr(S, D, Attr);
5611 handleNSConsumedAttr(S, D, Attr);
5614 handleSimpleAttribute<NSConsumesSelfAttr>(S, D, Attr);
5621 handleNSReturnsRetainedAttr(S, D, Attr);
5624 handleWorkGroupSize<WorkGroupSizeHintAttr>(S, D, Attr);
5627 handleWorkGroupSize<ReqdWorkGroupSizeAttr>(S, D, Attr);
5630 handleVecTypeHint(S, D, Attr);
5633 handleInitPriorityAttr(S, D, Attr);
5636 handlePackedAttr(S, D, Attr);
5639 handleSectionAttr(S, D, Attr);
5642 handleTargetAttr(S, D, Attr);
5645 handleAttrWithMessage<UnavailableAttr>(S, D, Attr);
5648 handleSimpleAttribute<ArcWeakrefUnavailableAttr>(S, D, Attr);
5651 handleSimpleAttribute<ObjCRootClassAttr>(S, D, Attr);
5654 handleObjCSuppresProtocolAttr(S, D, Attr);
5657 handleSimpleAttribute<ObjCRequiresPropertyDefsAttr>(S, D, Attr);
5660 handleUnusedAttr(S, D, Attr);
5663 handleSimpleAttribute<ReturnsTwiceAttr>(S, D, Attr);
5666 handleNotTailCalledAttr(S, D, Attr);
5669 handleDisableTailCallsAttr(S, D, Attr);
5672 handleUsedAttr(S, D, Attr);
5675 handleVisibilityAttr(S, D, Attr, false);
5678 handleVisibilityAttr(S, D, Attr, true);
5681 handleSimpleAttribute<WarnUnusedAttr>(S, D, Attr);
5684 handleWarnUnusedResult(S, D, Attr);
5687 handleSimpleAttribute<WeakAttr>(S, D, Attr);
5690 handleWeakRefAttr(S, D, Attr);
5693 handleWeakImportAttr(S, D, Attr);
5696 handleTransparentUnionAttr(S, D, Attr);
5699 handleSimpleAttribute<ObjCExceptionAttr>(S, D, Attr);
5702 handleObjCMethodFamilyAttr(S, D, Attr);
5705 handleObjCNSObject(S, D, Attr);
5708 handleObjCIndependentClass(S, D, Attr);
5711 handleBlocksAttr(S, D, Attr);
5714 handleSentinelAttr(S, D, Attr);
5717 handleSimpleAttribute<ConstAttr>(S, D, Attr);
5720 handleSimpleAttribute<PureAttr>(S, D, Attr);
5723 handleCleanupAttr(S, D, Attr);
5726 handleNoDebugAttr(S, D, Attr);
5729 handleSimpleAttribute<NoDuplicateAttr>(S, D, Attr);
5732 handleSimpleAttribute<NoInlineAttr>(S, D, Attr);
5735 handleSimpleAttribute<NoInstrumentFunctionAttr>(S, D, Attr);
5750 handleCallConvAttr(S, D, Attr);
5753 handleSimpleAttribute<OpenCLKernelAttr>(S, D, Attr);
5756 handleOpenCLAccessAttr(S, D, Attr);
5759 handleOpenCLNoSVMAttr(S, D, Attr);
5762 handleParameterABIAttr(S, D, Attr, ParameterABI::SwiftContext);
5765 handleParameterABIAttr(S, D, Attr, ParameterABI::SwiftErrorResult);
5768 handleParameterABIAttr(S, D, Attr, ParameterABI::SwiftIndirectResult);
5771 handleInternalLinkageAttr(S, D, Attr);
5774 handleSimpleAttribute<LTOVisibilityPublicAttr>(S, D, Attr);
5779 handleSimpleAttribute<EmptyBasesAttr>(S, D, Attr);
5782 handleLayoutVersion(S, D, Attr);
5785 handleSimpleAttribute<MSNoVTableAttr>(S, D, Attr);
5788 handleSimpleAttribute<MSStructAttr>(S, D, Attr);
5791 handleUuidAttr(S, D, Attr);
5794 handleMSInheritanceAttr(S, D, Attr);
5797 handleSimpleAttribute<SelectAnyAttr>(S, D, Attr);
5800 handleDeclspecThreadAttr(S, D, Attr);
5804 handleAbiTagAttr(S, D, Attr);
5809 handleAssertExclusiveLockAttr(S, D, Attr);
5812 handleAssertSharedLockAttr(S, D, Attr);
5815 handleSimpleAttribute<GuardedVarAttr>(S, D, Attr);
5818 handlePtGuardedVarAttr(S, D, Attr);
5821 handleSimpleAttribute<ScopedLockableAttr>(S, D, Attr);
5824 handleNoSanitizeAttr(S, D, Attr);
5827 handleNoSanitizeSpecificAttr(S, D, Attr);
5830 handleSimpleAttribute<NoThreadSafetyAnalysisAttr>(S, D, Attr);
5833 handleGuardedByAttr(S, D, Attr);
5836 handlePtGuardedByAttr(S, D, Attr);
5839 handleExclusiveTrylockFunctionAttr(S, D, Attr);
5842 handleLockReturnedAttr(S, D, Attr);
5845 handleLocksExcludedAttr(S, D, Attr);
5848 handleSharedTrylockFunctionAttr(S, D, Attr);
5851 handleAcquiredBeforeAttr(S, D, Attr);
5854 handleAcquiredAfterAttr(S, D, Attr);
5860 handleCapabilityAttr(S, D, Attr);
5863 handleRequiresCapabilityAttr(S, D, Attr);
5867 handleAssertCapabilityAttr(S, D, Attr);
5870 handleAcquireCapabilityAttr(S, D, Attr);
5873 handleReleaseCapabilityAttr(S, D, Attr);
5876 handleTryAcquireCapabilityAttr(S, D, Attr);
5881 handleConsumableAttr(S, D, Attr);
5884 handleSimpleAttribute<ConsumableAutoCastAttr>(S, D, Attr);
5887 handleSimpleAttribute<ConsumableSetOnReadAttr>(S, D, Attr);
5890 handleCallableWhenAttr(S, D, Attr);
5893 handleParamTypestateAttr(S, D, Attr);
5896 handleReturnTypestateAttr(S, D, Attr);
5899 handleSetTypestateAttr(S, D, Attr);
5902 handleTestTypestateAttr(S, D, Attr);
5907 handleArgumentWithTypeTagAttr(S, D, Attr);
5910 Attr);
5913 handleSimpleAttribute<RenderScriptKernelAttr>(S, D, Attr);
5917 handleSimpleAttribute<XRayInstrumentAttr>(S, D, Attr);
5947 if (Attr *A = D->getAttr<ReqdWorkGroupSizeAttr>()) {
5952 } else if (Attr *A = D->getAttr<WorkGroupSizeHintAttr>()) {
5955 } else if (Attr *A = D->getAttr<VecTypeHintAttr>()) {
5958 } else if (Attr *A = D->getAttr<AMDGPUNumVGPRAttr>()) {
5962 } else if (Attr *A = D->getAttr<AMDGPUNumSGPRAttr>()) {
6288 if (auto attr = D->getAttr<UnavailableAttr>()) {
6289 if (attr->isImplicit() && attr->getImplicitReason()) {
6298 switch (attr->getImplicitReason()) {
6344 if (auto attr = D->getAttr<DeprecatedAttr>())
6345 Replacement = attr->getReplacement();
6346 if (auto attr = getAttrForPlatform(S.Context, D))
6347 Replacement = attr->getReplacement();