Lines Matching refs:S

218 static bool checkUInt32Argument(Sema &S, const AttrInfo &AI, const Expr *Expr,  in checkUInt32Argument()  argument
223 !(I = Expr->getIntegerConstantExpr(S.Context))) { in checkUInt32Argument()
225 S.Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type) in checkUInt32Argument()
229 S.Diag(getAttrLoc(AI), diag::err_attribute_argument_type) in checkUInt32Argument()
235 S.Diag(Expr->getExprLoc(), diag::err_ice_too_large) in checkUInt32Argument()
241 S.Diag(getAttrLoc(AI), diag::err_attribute_requires_positive_integer) in checkUInt32Argument()
254 static bool checkPositiveIntArgument(Sema &S, const AttrInfo &AI, const Expr *Expr, in checkPositiveIntArgument() argument
257 if (!checkUInt32Argument(S, AI, Expr, UVal, Idx)) in checkPositiveIntArgument()
263 S.Diag(Expr->getExprLoc(), diag::err_ice_too_large) in checkPositiveIntArgument()
275 static bool checkAttrMutualExclusion(Sema &S, Decl *D, const ParsedAttr &AL) { in checkAttrMutualExclusion() argument
277 S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) in checkAttrMutualExclusion()
280 S.Diag(A->getLocation(), diag::note_conflicting_attribute); in checkAttrMutualExclusion()
287 static bool checkAttrMutualExclusion(Sema &S, Decl *D, const Attr &AL) { in checkAttrMutualExclusion() argument
289 S.Diag(AL.getLocation(), diag::err_attributes_are_not_compatible) in checkAttrMutualExclusion()
292 S.Diag(A->getLocation(), diag::note_conflicting_attribute); in checkAttrMutualExclusion()
304 Sema &S, const Decl *D, const AttrInfo &AI, unsigned AttrArgNum, in checkFunctionOrMethodParameterIndex() argument
318 !(IdxInt = IdxExpr->getIntegerConstantExpr(S.Context))) { in checkFunctionOrMethodParameterIndex()
319 S.Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type) in checkFunctionOrMethodParameterIndex()
327 S.Diag(getAttrLoc(AI), diag::err_attribute_argument_out_of_bounds) in checkFunctionOrMethodParameterIndex()
333 S.Diag(getAttrLoc(AI), diag::err_attribute_invalid_implicit_this_argument) in checkFunctionOrMethodParameterIndex()
401 static void handleSimpleAttribute(Sema &S, Decl *D, in handleSimpleAttribute() argument
403 D->addAttr(::new (S.Context) AttrType(S.Context, CI)); in handleSimpleAttribute()
425 static void handleSimpleAttributeOrDiagnose(Sema &S, Decl *D, in handleSimpleAttributeOrDiagnose() argument
430 Sema::SemaDiagnosticBuilder DB = S.Diag(D->getBeginLoc(), DiagID); in handleSimpleAttributeOrDiagnose()
434 handleSimpleAttribute<AttrType>(S, D, CI); in handleSimpleAttributeOrDiagnose()
446 static bool threadSafetyCheckIsSmartPointer(Sema &S, const RecordType* RT) { in threadSafetyCheckIsSmartPointer() argument
447 auto IsOverloadedOperatorPresent = [&S](const RecordDecl *Record, in threadSafetyCheckIsSmartPointer()
450 Record->lookup(S.Context.DeclarationNames.getCXXOperatorName(Op)); in threadSafetyCheckIsSmartPointer()
482 static bool threadSafetyCheckIsPointer(Sema &S, const Decl *D, in threadSafetyCheckIsPointer() argument
496 if (threadSafetyCheckIsSmartPointer(S, RT)) in threadSafetyCheckIsPointer()
500 S.Diag(AL.getLoc(), diag::warn_thread_attribute_decl_not_pointer) << AL << QT; in threadSafetyCheckIsPointer()
533 static bool checkRecordTypeForCapability(Sema &S, QualType Ty) { in checkRecordTypeForCapability() argument
545 if (threadSafetyCheckIsSmartPointer(S, RT)) in checkRecordTypeForCapability()
563 static bool typeHasCapability(Sema &S, QualType Ty) { in typeHasCapability() argument
567 if (checkRecordTypeForCapability(S, Ty)) in typeHasCapability()
573 static bool isCapabilityExpr(Sema &S, const Expr *Ex) { in isCapabilityExpr() argument
580 return isCapabilityExpr(S, E->getSubExpr()); in isCapabilityExpr()
582 return isCapabilityExpr(S, E->getSubExpr()); in isCapabilityExpr()
586 return isCapabilityExpr(S, E->getSubExpr()); in isCapabilityExpr()
590 return isCapabilityExpr(S, E->getLHS()) && in isCapabilityExpr()
591 isCapabilityExpr(S, E->getRHS()); in isCapabilityExpr()
595 return typeHasCapability(S, Ex->getType()); in isCapabilityExpr()
603 static void checkAttrArgsAreCapabilityObjs(Sema &S, Decl *D, in checkAttrArgsAreCapabilityObjs() argument
618 S.Diag(AL.getLoc(), in checkAttrArgsAreCapabilityObjs()
622 S.Diag(AL.getLoc(), diag::warn_thread_attribute_not_on_non_static_member) in checkAttrArgsAreCapabilityObjs()
647 S.Diag(AL.getLoc(), diag::warn_thread_attribute_ignored) << AL; in checkAttrArgsAreCapabilityObjs()
675 S.Diag(AL.getLoc(), in checkAttrArgsAreCapabilityObjs()
688 if (!typeHasCapability(S, ArgTy) && !isCapabilityExpr(S, ArgExp)) in checkAttrArgsAreCapabilityObjs()
689 S.Diag(AL.getLoc(), diag::warn_thread_attribute_argument_not_lockable) in checkAttrArgsAreCapabilityObjs()
700 static void handlePtGuardedVarAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handlePtGuardedVarAttr() argument
701 if (!threadSafetyCheckIsPointer(S, D, AL)) in handlePtGuardedVarAttr()
704 D->addAttr(::new (S.Context) PtGuardedVarAttr(S.Context, AL)); in handlePtGuardedVarAttr()
707 static bool checkGuardedByAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, in checkGuardedByAttrCommon() argument
711 checkAttrArgsAreCapabilityObjs(S, D, AL, Args); in checkGuardedByAttrCommon()
721 static void handleGuardedByAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleGuardedByAttr() argument
723 if (!checkGuardedByAttrCommon(S, D, AL, Arg)) in handleGuardedByAttr()
726 D->addAttr(::new (S.Context) GuardedByAttr(S.Context, AL, Arg)); in handleGuardedByAttr()
729 static void handlePtGuardedByAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handlePtGuardedByAttr() argument
731 if (!checkGuardedByAttrCommon(S, D, AL, Arg)) in handlePtGuardedByAttr()
734 if (!threadSafetyCheckIsPointer(S, D, AL)) in handlePtGuardedByAttr()
737 D->addAttr(::new (S.Context) PtGuardedByAttr(S.Context, AL, Arg)); in handlePtGuardedByAttr()
740 static bool checkAcquireOrderAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, in checkAcquireOrderAttrCommon() argument
742 if (!AL.checkAtLeastNumArgs(S, 1)) in checkAcquireOrderAttrCommon()
747 if (!QT->isDependentType() && !typeHasCapability(S, QT)) { in checkAcquireOrderAttrCommon()
748 S.Diag(AL.getLoc(), diag::warn_thread_attribute_decl_not_lockable) << AL; in checkAcquireOrderAttrCommon()
753 checkAttrArgsAreCapabilityObjs(S, D, AL, Args); in checkAcquireOrderAttrCommon()
760 static void handleAcquiredAfterAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAcquiredAfterAttr() argument
762 if (!checkAcquireOrderAttrCommon(S, D, AL, Args)) in handleAcquiredAfterAttr()
766 D->addAttr(::new (S.Context) in handleAcquiredAfterAttr()
767 AcquiredAfterAttr(S.Context, AL, StartArg, Args.size())); in handleAcquiredAfterAttr()
770 static void handleAcquiredBeforeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAcquiredBeforeAttr() argument
772 if (!checkAcquireOrderAttrCommon(S, D, AL, Args)) in handleAcquiredBeforeAttr()
776 D->addAttr(::new (S.Context) in handleAcquiredBeforeAttr()
777 AcquiredBeforeAttr(S.Context, AL, StartArg, Args.size())); in handleAcquiredBeforeAttr()
780 static bool checkLockFunAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, in checkLockFunAttrCommon() argument
784 checkAttrArgsAreCapabilityObjs(S, D, AL, Args, 0, /*ParamIdxOk=*/true); in checkLockFunAttrCommon()
789 static void handleAssertSharedLockAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAssertSharedLockAttr() argument
791 if (!checkLockFunAttrCommon(S, D, AL, Args)) in handleAssertSharedLockAttr()
796 D->addAttr(::new (S.Context) in handleAssertSharedLockAttr()
797 AssertSharedLockAttr(S.Context, AL, StartArg, Size)); in handleAssertSharedLockAttr()
800 static void handleAssertExclusiveLockAttr(Sema &S, Decl *D, in handleAssertExclusiveLockAttr() argument
803 if (!checkLockFunAttrCommon(S, D, AL, Args)) in handleAssertExclusiveLockAttr()
808 D->addAttr(::new (S.Context) in handleAssertExclusiveLockAttr()
809 AssertExclusiveLockAttr(S.Context, AL, StartArg, Size)); in handleAssertExclusiveLockAttr()
818 static bool checkParamIsIntegerType(Sema &S, const Decl *D, const AttrInfo &AI, in checkParamIsIntegerType() argument
823 if (!checkFunctionOrMethodParameterIndex(S, D, AI, AttrArgNo + 1, AttrArg, in checkParamIsIntegerType()
830 S.Diag(SrcLoc, diag::err_attribute_integers_only) in checkParamIsIntegerType()
837 static void handleAllocSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAllocSizeAttr() argument
838 if (!AL.checkAtLeastNumArgs(S, 1) || !AL.checkAtMostNumArgs(S, 2)) in handleAllocSizeAttr()
845 S.Diag(AL.getLoc(), diag::warn_attribute_return_pointers_only) << AL; in handleAllocSizeAttr()
852 if (!checkPositiveIntArgument(S, AL, SizeExpr, SizeArgNoVal, /*Idx=*/1)) in handleAllocSizeAttr()
854 if (!checkParamIsIntegerType(S, D, AL, /*AttrArgNo=*/0)) in handleAllocSizeAttr()
863 if (!checkPositiveIntArgument(S, AL, NumberExpr, Val, /*Idx=*/2)) in handleAllocSizeAttr()
865 if (!checkParamIsIntegerType(S, D, AL, /*AttrArgNo=*/1)) in handleAllocSizeAttr()
870 D->addAttr(::new (S.Context) in handleAllocSizeAttr()
871 AllocSizeAttr(S.Context, AL, SizeArgNo, NumberArgNo)); in handleAllocSizeAttr()
874 static bool checkTryLockFunAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, in checkTryLockFunAttrCommon() argument
876 if (!AL.checkAtLeastNumArgs(S, 1)) in checkTryLockFunAttrCommon()
880 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) in checkTryLockFunAttrCommon()
886 checkAttrArgsAreCapabilityObjs(S, D, AL, Args, 1); in checkTryLockFunAttrCommon()
891 static void handleSharedTrylockFunctionAttr(Sema &S, Decl *D, in handleSharedTrylockFunctionAttr() argument
894 if (!checkTryLockFunAttrCommon(S, D, AL, Args)) in handleSharedTrylockFunctionAttr()
897 D->addAttr(::new (S.Context) SharedTrylockFunctionAttr( in handleSharedTrylockFunctionAttr()
898 S.Context, AL, AL.getArgAsExpr(0), Args.data(), Args.size())); in handleSharedTrylockFunctionAttr()
901 static void handleExclusiveTrylockFunctionAttr(Sema &S, Decl *D, in handleExclusiveTrylockFunctionAttr() argument
904 if (!checkTryLockFunAttrCommon(S, D, AL, Args)) in handleExclusiveTrylockFunctionAttr()
907 D->addAttr(::new (S.Context) ExclusiveTrylockFunctionAttr( in handleExclusiveTrylockFunctionAttr()
908 S.Context, AL, AL.getArgAsExpr(0), Args.data(), Args.size())); in handleExclusiveTrylockFunctionAttr()
911 static void handleLockReturnedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleLockReturnedAttr() argument
914 checkAttrArgsAreCapabilityObjs(S, D, AL, Args); in handleLockReturnedAttr()
919 D->addAttr(::new (S.Context) LockReturnedAttr(S.Context, AL, Args[0])); in handleLockReturnedAttr()
922 static void handleLocksExcludedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleLocksExcludedAttr() argument
923 if (!AL.checkAtLeastNumArgs(S, 1)) in handleLocksExcludedAttr()
928 checkAttrArgsAreCapabilityObjs(S, D, AL, Args); in handleLocksExcludedAttr()
934 D->addAttr(::new (S.Context) in handleLocksExcludedAttr()
935 LocksExcludedAttr(S.Context, AL, StartArg, Size)); in handleLocksExcludedAttr()
938 static bool checkFunctionConditionAttr(Sema &S, Decl *D, const ParsedAttr &AL, in checkFunctionConditionAttr() argument
942 ExprResult Converted = S.PerformContextuallyConvertToBool(Cond); in checkFunctionConditionAttr()
948 if (!S.checkStringLiteralArgumentAttr(AL, 1, Msg)) in checkFunctionConditionAttr()
958 S.Diag(AL.getLoc(), diag::err_attr_cond_never_constant_expr) << AL; in checkFunctionConditionAttr()
960 S.Diag(PDiag.first, PDiag.second); in checkFunctionConditionAttr()
966 static void handleEnableIfAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleEnableIfAttr() argument
967 S.Diag(AL.getLoc(), diag::ext_clang_enable_if); in handleEnableIfAttr()
971 if (checkFunctionConditionAttr(S, D, AL, Cond, Msg)) in handleEnableIfAttr()
972 D->addAttr(::new (S.Context) EnableIfAttr(S.Context, AL, Cond, Msg)); in handleEnableIfAttr()
975 static void handleErrorAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleErrorAttr() argument
977 if (!S.checkStringLiteralArgumentAttr(AL, 0, NewUserDiagnostic)) in handleErrorAttr()
979 if (ErrorAttr *EA = S.mergeErrorAttr(D, AL, NewUserDiagnostic)) in handleErrorAttr()
1029 static void handleDiagnoseAsBuiltinAttr(Sema &S, Decl *D, in handleDiagnoseAsBuiltinAttr() argument
1035 S.Diag(AL.getLoc(), diag::err_attribute_no_member_function) << AL; in handleDiagnoseAsBuiltinAttr()
1047 S.Diag(Loc, diag::err_attribute_argument_n_type) << AL << Index << T; in handleDiagnoseAsBuiltinAttr()
1065 S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments_for) in handleDiagnoseAsBuiltinAttr()
1081 if (!checkUInt32Argument(S, AL, IndexExpr, Index, I + 1, false)) in handleDiagnoseAsBuiltinAttr()
1085 S.Diag(AL.getLoc(), diag::err_attribute_bounds_for_function) in handleDiagnoseAsBuiltinAttr()
1095 S.Diag(IndexExpr->getBeginLoc(), diag::err_attribute_parameter_types) in handleDiagnoseAsBuiltinAttr()
1103 D->addAttr(::new (S.Context) DiagnoseAsBuiltinAttr( in handleDiagnoseAsBuiltinAttr()
1104 S.Context, AL, AttrFD, Indices.data(), Indices.size())); in handleDiagnoseAsBuiltinAttr()
1107 static void handleDiagnoseIfAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleDiagnoseIfAttr() argument
1108 S.Diag(AL.getLoc(), diag::ext_clang_diagnose_if); in handleDiagnoseIfAttr()
1112 if (!checkFunctionConditionAttr(S, D, AL, Cond, Msg)) in handleDiagnoseIfAttr()
1116 if (!S.checkStringLiteralArgumentAttr(AL, 2, DiagTypeStr)) in handleDiagnoseIfAttr()
1121 S.Diag(AL.getArgAsExpr(2)->getBeginLoc(), in handleDiagnoseIfAttr()
1129 D->addAttr(::new (S.Context) DiagnoseIfAttr( in handleDiagnoseIfAttr()
1130 S.Context, AL, Cond, Msg, DiagType, ArgDependent, cast<NamedDecl>(D))); in handleDiagnoseIfAttr()
1133 static void handleNoBuiltinAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNoBuiltinAttr() argument
1157 if (!S.checkStringLiteralArgumentAttr(AL, I, BuiltinName, &LiteralLoc)) in handleNoBuiltinAttr()
1163 S.Diag(LiteralLoc, diag::warn_attribute_no_builtin_invalid_builtin_name) in handleNoBuiltinAttr()
1173 S.Diag(D->getLocation(), in handleNoBuiltinAttr()
1179 D->addAttr(::new (S.Context) in handleNoBuiltinAttr()
1180 NoBuiltinAttr(S.Context, AL, Names.data(), Names.size())); in handleNoBuiltinAttr()
1183 static void handlePassObjectSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handlePassObjectSizeAttr() argument
1185 S.Diag(D->getBeginLoc(), diag::err_attribute_only_once_per_parameter) << AL; in handlePassObjectSizeAttr()
1191 if (!checkUInt32Argument(S, AL, E, Type, /*Idx=*/1)) in handlePassObjectSizeAttr()
1198 S.Diag(E->getBeginLoc(), diag::err_attribute_argument_out_of_range) in handlePassObjectSizeAttr()
1208 S.Diag(D->getBeginLoc(), diag::err_attribute_pointers_only) << AL << 1; in handlePassObjectSizeAttr()
1212 D->addAttr(::new (S.Context) PassObjectSizeAttr(S.Context, AL, (int)Type)); in handlePassObjectSizeAttr()
1215 static void handleConsumableAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleConsumableAttr() argument
1222 S.Diag(IL->Loc, diag::warn_attribute_type_not_supported) << AL in handleConsumableAttr()
1227 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleConsumableAttr()
1232 D->addAttr(::new (S.Context) ConsumableAttr(S.Context, AL, DefaultState)); in handleConsumableAttr()
1235 static bool checkForConsumableClass(Sema &S, const CXXMethodDecl *MD, in checkForConsumableClass() argument
1241 S.Diag(AL.getLoc(), diag::warn_attr_on_unconsumable_class) << RD; in checkForConsumableClass()
1250 static void handleCallableWhenAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCallableWhenAttr() argument
1251 if (!AL.checkAtLeastNumArgs(S, 1)) in handleCallableWhenAttr()
1254 if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), AL)) in handleCallableWhenAttr()
1268 if (!S.checkStringLiteralArgumentAttr(AL, ArgIndex, StateString, &Loc)) in handleCallableWhenAttr()
1274 S.Diag(Loc, diag::warn_attribute_type_not_supported) << AL << StateString; in handleCallableWhenAttr()
1281 D->addAttr(::new (S.Context) in handleCallableWhenAttr()
1282 CallableWhenAttr(S.Context, AL, States.data(), States.size())); in handleCallableWhenAttr()
1285 static void handleParamTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleParamTypestateAttr() argument
1294 S.Diag(Ident->Loc, diag::warn_attribute_type_not_supported) in handleParamTypestateAttr()
1299 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleParamTypestateAttr()
1316 D->addAttr(::new (S.Context) ParamTypestateAttr(S.Context, AL, ParamState)); in handleParamTypestateAttr()
1319 static void handleReturnTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleReturnTypestateAttr() argument
1326 S.Diag(IL->Loc, diag::warn_attribute_type_not_supported) << AL in handleReturnTypestateAttr()
1331 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleReturnTypestateAttr()
1361 D->addAttr(::new (S.Context) ReturnTypestateAttr(S.Context, AL, ReturnState)); in handleReturnTypestateAttr()
1364 static void handleSetTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSetTypestateAttr() argument
1365 if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), AL)) in handleSetTypestateAttr()
1373 S.Diag(Ident->Loc, diag::warn_attribute_type_not_supported) << AL in handleSetTypestateAttr()
1378 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleSetTypestateAttr()
1383 D->addAttr(::new (S.Context) SetTypestateAttr(S.Context, AL, NewState)); in handleSetTypestateAttr()
1386 static void handleTestTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleTestTypestateAttr() argument
1387 if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), AL)) in handleTestTypestateAttr()
1395 S.Diag(Ident->Loc, diag::warn_attribute_type_not_supported) << AL in handleTestTypestateAttr()
1400 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleTestTypestateAttr()
1405 D->addAttr(::new (S.Context) TestTypestateAttr(S.Context, AL, TestState)); in handleTestTypestateAttr()
1408 static void handleExtVectorTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleExtVectorTypeAttr() argument
1410 S.ExtVectorDecls.push_back(cast<TypedefNameDecl>(D)); in handleExtVectorTypeAttr()
1413 static void handlePackedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handlePackedAttr() argument
1415 TD->addAttr(::new (S.Context) PackedAttr(S.Context, AL)); in handlePackedAttr()
1420 S.Context.getTypeAlign(FD->getType()) <= 8); in handlePackedAttr()
1422 if (S.getASTContext().getTargetInfo().getTriple().isPS()) { in handlePackedAttr()
1425 S.Diag(AL.getLoc(), diag::warn_attribute_ignored_for_field_of_type) in handlePackedAttr()
1428 FD->addAttr(::new (S.Context) PackedAttr(S.Context, AL)); in handlePackedAttr()
1432 S.Diag(AL.getLoc(), diag::warn_attribute_packed_for_bitfield); in handlePackedAttr()
1434 FD->addAttr(::new (S.Context) PackedAttr(S.Context, AL)); in handlePackedAttr()
1438 S.Diag(AL.getLoc(), diag::warn_attribute_ignored) << AL; in handlePackedAttr()
1441 static void handlePreferredName(Sema &S, Decl *D, const ParsedAttr &AL) { in handlePreferredName() argument
1448 QualType T = S.GetTypeFromParser(PT, &TSI); in handlePreferredName()
1450 TSI = S.Context.getTrivialTypeSourceInfo(T, AL.getLoc()); in handlePreferredName()
1466 D->addAttr(::new (S.Context) PreferredNameAttr(S.Context, AL, TSI)); in handlePreferredName()
1471 S.Diag(AL.getLoc(), diag::err_attribute_preferred_name_arg_invalid) in handlePreferredName()
1474 S.Diag(TT->getDecl()->getLocation(), diag::note_entity_declared_at) in handlePreferredName()
1478 static bool checkIBOutletCommon(Sema &S, Decl *D, const ParsedAttr &AL) { in checkIBOutletCommon() argument
1484 S.Diag(AL.getLoc(), diag::warn_iboutlet_object_type) in checkIBOutletCommon()
1491 S.Diag(AL.getLoc(), diag::warn_iboutlet_object_type) in checkIBOutletCommon()
1497 S.Diag(AL.getLoc(), diag::warn_attribute_iboutlet) << AL; in checkIBOutletCommon()
1504 static void handleIBOutlet(Sema &S, Decl *D, const ParsedAttr &AL) { in handleIBOutlet() argument
1505 if (!checkIBOutletCommon(S, D, AL)) in handleIBOutlet()
1508 D->addAttr(::new (S.Context) IBOutletAttr(S.Context, AL)); in handleIBOutlet()
1511 static void handleIBOutletCollection(Sema &S, Decl *D, const ParsedAttr &AL) { in handleIBOutletCollection() argument
1515 S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1; in handleIBOutletCollection()
1519 if (!checkIBOutletCommon(S, D, AL)) in handleIBOutletCollection()
1527 PT = S.getTypeName(S.Context.Idents.get("NSObject"), AL.getLoc(), in handleIBOutletCollection()
1528 S.getScopeForContext(D->getDeclContext()->getParent())); in handleIBOutletCollection()
1530 S.Diag(AL.getLoc(), diag::err_iboutletcollection_type) << "NSObject"; in handleIBOutletCollection()
1536 QualType QT = S.GetTypeFromParser(PT, &QTLoc); in handleIBOutletCollection()
1538 QTLoc = S.Context.getTrivialTypeSourceInfo(QT, AL.getLoc()); in handleIBOutletCollection()
1545 S.Diag(AL.getLoc(), in handleIBOutletCollection()
1551 D->addAttr(::new (S.Context) IBOutletCollectionAttr(S.Context, AL, QTLoc)); in handleIBOutletCollection()
1578 static bool attrNonNullArgCheck(Sema &S, QualType T, const ParsedAttr &AL, in attrNonNullArgCheck() argument
1582 if (!S.isValidPointerAttrType(T)) { in attrNonNullArgCheck()
1584 S.Diag(AL.getLoc(), diag::warn_attribute_return_pointers_only) in attrNonNullArgCheck()
1587 S.Diag(AL.getLoc(), diag::warn_attribute_pointers_only) in attrNonNullArgCheck()
1594 static void handleNonNullAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNonNullAttr() argument
1599 if (!checkFunctionOrMethodParameterIndex(S, D, AL, I + 1, Ex, Idx)) in handleNonNullAttr()
1605 S, getFunctionOrMethodParamType(D, Idx.getASTIndex()), AL, in handleNonNullAttr()
1618 !S.inTemplateInstantiation()) { in handleNonNullAttr()
1623 if (T->isDependentType() || S.isValidPointerAttrType(T)) in handleNonNullAttr()
1628 S.Diag(AL.getLoc(), diag::warn_attribute_nonnull_no_pointers); in handleNonNullAttr()
1634 D->addAttr(::new (S.Context) NonNullAttr(S.Context, AL, Start, Size)); in handleNonNullAttr()
1637 static void handleNonNullAttrParameter(Sema &S, ParmVarDecl *D, in handleNonNullAttrParameter() argument
1641 handleNonNullAttr(S, D, AL); in handleNonNullAttrParameter()
1643 S.Diag(AL.getLoc(), diag::warn_attribute_nonnull_parm_no_args) in handleNonNullAttrParameter()
1650 if (!attrNonNullArgCheck(S, D->getType(), AL, SourceRange(), in handleNonNullAttrParameter()
1654 D->addAttr(::new (S.Context) NonNullAttr(S.Context, AL, nullptr, 0)); in handleNonNullAttrParameter()
1657 static void handleReturnsNonNullAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleReturnsNonNullAttr() argument
1660 if (!attrNonNullArgCheck(S, ResultType, AL, SourceRange(), SR, in handleReturnsNonNullAttr()
1664 D->addAttr(::new (S.Context) ReturnsNonNullAttr(S.Context, AL)); in handleReturnsNonNullAttr()
1667 static void handleNoEscapeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNoEscapeAttr() argument
1673 if (!S.isValidPointerAttrType(T, /* RefOkay */ true)) { in handleNoEscapeAttr()
1674 S.Diag(AL.getLoc(), diag::warn_attribute_pointers_only) in handleNoEscapeAttr()
1679 D->addAttr(::new (S.Context) NoEscapeAttr(S.Context, AL)); in handleNoEscapeAttr()
1682 static void handleAssumeAlignedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAssumeAlignedAttr() argument
1685 S.AddAssumeAlignedAttr(D, AL, E, OE); in handleAssumeAlignedAttr()
1688 static void handleAllocAlignAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAllocAlignAttr() argument
1689 S.AddAllocAlignAttr(D, AL, AL.getArgAsExpr(0)); in handleAllocAlignAttr()
1774 static void checkAssumptionAttr(Sema &S, SourceLocation Loc, in checkAssumptionAttr() argument
1791 S.Diag(Loc, diag::warn_assume_attribute_string_unknown_suggested) in checkAssumptionAttr()
1794 S.Diag(Loc, diag::warn_assume_attribute_string_unknown) << AssumptionStr; in checkAssumptionAttr()
1797 static void handleAssumumptionAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAssumumptionAttr() argument
1801 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &AttrStrLoc)) in handleAssumumptionAttr()
1804 checkAssumptionAttr(S, AttrStrLoc, Str); in handleAssumumptionAttr()
1806 D->addAttr(::new (S.Context) AssumptionAttr(S.Context, AL, Str)); in handleAssumumptionAttr()
1820 static void handleOwnershipAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleOwnershipAttr() argument
1830 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) in handleOwnershipAttr()
1837 OwnershipAttr(S.Context, AL, nullptr, nullptr, 0).getOwnKind(); in handleOwnershipAttr()
1844 S.Diag(AL.getLoc(), diag::err_attribute_too_few_arguments) << AL << 2; in handleOwnershipAttr()
1850 S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) << AL << 1; in handleOwnershipAttr()
1860 Module = &S.PP.getIdentifierTable().get(ModuleName); in handleOwnershipAttr()
1867 if (!checkFunctionOrMethodParameterIndex(S, D, AL, i, Ex, Idx)) in handleOwnershipAttr()
1885 S.Diag(AL.getLoc(), diag::err_ownership_type) << AL << Err in handleOwnershipAttr()
1895 S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) in handleOwnershipAttr()
1905 S.Diag(I->getLocation(), diag::err_ownership_returns_index_mismatch) in handleOwnershipAttr()
1908 S.Diag(AL.getLoc(), diag::note_ownership_returns_index_mismatch) in handleOwnershipAttr()
1920 D->addAttr(::new (S.Context) in handleOwnershipAttr()
1921 OwnershipAttr(S.Context, AL, Module, Start, Size)); in handleOwnershipAttr()
1924 static void handleWeakRefAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleWeakRefAttr() argument
1927 S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1; in handleWeakRefAttr()
1943 S.Diag(AL.getLoc(), diag::err_attribute_weakref_not_global_context) in handleWeakRefAttr()
1974 if (AL.getNumArgs() && S.checkStringLiteralArgumentAttr(AL, 0, Str)) in handleWeakRefAttr()
1977 D->addAttr(::new (S.Context) AliasAttr(S.Context, AL, Str)); in handleWeakRefAttr()
1979 D->addAttr(::new (S.Context) WeakRefAttr(S.Context, AL)); in handleWeakRefAttr()
1982 static void handleIFuncAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleIFuncAttr() argument
1984 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str)) in handleIFuncAttr()
1990 S.Diag(AL.getLoc(), diag::err_alias_is_definition) << FD << 1; in handleIFuncAttr()
1994 D->addAttr(::new (S.Context) IFuncAttr(S.Context, AL, Str)); in handleIFuncAttr()
1997 static void handleAliasAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAliasAttr() argument
1999 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str)) in handleAliasAttr()
2002 if (S.Context.getTargetInfo().getTriple().isOSDarwin()) { in handleAliasAttr()
2003 S.Diag(AL.getLoc(), diag::err_alias_not_supported_on_darwin); in handleAliasAttr()
2007 if (S.Context.getTargetInfo().getTriple().isNVPTX()) { in handleAliasAttr()
2009 ToCudaVersion(S.Context.getTargetInfo().getSDKVersion()); in handleAliasAttr()
2011 S.Diag(AL.getLoc(), diag::err_alias_not_supported_on_nvptx); in handleAliasAttr()
2017 S.Diag(AL.getLoc(), diag::err_alias_is_definition) << FD << 0; in handleAliasAttr()
2023 S.Diag(AL.getLoc(), diag::err_alias_is_definition) << VD << 0; in handleAliasAttr()
2029 if (!S.LangOpts.CPlusPlus) { in handleAliasAttr()
2032 const DeclarationNameInfo target(&S.Context.Idents.get(Str), AL.getLoc()); in handleAliasAttr()
2033 LookupResult LR(S, target, Sema::LookupOrdinaryName); in handleAliasAttr()
2034 if (S.LookupQualifiedName(LR, S.getCurLexicalContext())) in handleAliasAttr()
2036 ND->markUsed(S.Context); in handleAliasAttr()
2039 D->addAttr(::new (S.Context) AliasAttr(S.Context, AL, Str)); in handleAliasAttr()
2042 static void handleTLSModelAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleTLSModelAttr() argument
2046 if (!S.checkStringLiteralArgumentAttr(AL, 0, Model, &LiteralLoc)) in handleTLSModelAttr()
2052 S.Diag(LiteralLoc, diag::err_attr_tlsmodel_arg); in handleTLSModelAttr()
2056 if (S.Context.getTargetInfo().getTriple().isOSAIX() && in handleTLSModelAttr()
2058 S.Diag(LiteralLoc, diag::err_aix_attr_unsupported_tls_model) << Model; in handleTLSModelAttr()
2062 D->addAttr(::new (S.Context) TLSModelAttr(S.Context, AL, Model)); in handleTLSModelAttr()
2065 static void handleRestrictAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleRestrictAttr() argument
2068 D->addAttr(::new (S.Context) RestrictAttr(S.Context, AL)); in handleRestrictAttr()
2072 S.Diag(AL.getLoc(), diag::warn_attribute_return_pointers_only) in handleRestrictAttr()
2076 static void handleCPUSpecificAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCPUSpecificAttr() argument
2080 if (checkAttrMutualExclusion<CPUSpecificAttr>(S, D, AL)) in handleCPUSpecificAttr()
2084 S.Diag(AL.getLoc(), diag::err_disallowed_duplicate_attribute) << AL; in handleCPUSpecificAttr()
2085 S.Diag(Other->getLocation(), diag::note_conflicting_attribute); in handleCPUSpecificAttr()
2089 if (checkAttrMutualExclusion<CPUDispatchAttr>(S, D, AL)) in handleCPUSpecificAttr()
2093 S.Diag(AL.getLoc(), diag::err_disallowed_duplicate_attribute) << AL; in handleCPUSpecificAttr()
2094 S.Diag(Other->getLocation(), diag::note_conflicting_attribute); in handleCPUSpecificAttr()
2103 S.Diag(AL.getLoc(), diag::err_attribute_dll_lambda) << AL; in handleCPUSpecificAttr()
2108 if (!AL.checkAtLeastNumArgs(S, 1)) in handleCPUSpecificAttr()
2114 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleCPUSpecificAttr()
2122 if (!S.Context.getTargetInfo().validateCPUSpecificCPUDispatch(CPUName)) { in handleCPUSpecificAttr()
2123 S.Diag(CPUArg->Loc, diag::err_invalid_cpu_specific_dispatch_value) in handleCPUSpecificAttr()
2128 const TargetInfo &Target = S.Context.getTargetInfo(); in handleCPUSpecificAttr()
2133 S.Diag(AL.getLoc(), diag::warn_multiversion_duplicate_entries); in handleCPUSpecificAttr()
2141 D->addAttr(::new (S.Context) in handleCPUSpecificAttr()
2142 CPUSpecificAttr(S.Context, AL, CPUs.data(), CPUs.size())); in handleCPUSpecificAttr()
2144 D->addAttr(::new (S.Context) in handleCPUSpecificAttr()
2145 CPUDispatchAttr(S.Context, AL, CPUs.data(), CPUs.size())); in handleCPUSpecificAttr()
2148 static void handleCommonAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCommonAttr() argument
2149 if (S.LangOpts.CPlusPlus) { in handleCommonAttr()
2150 S.Diag(AL.getLoc(), diag::err_attribute_not_supported_in_lang) in handleCommonAttr()
2155 D->addAttr(::new (S.Context) CommonAttr(S.Context, AL)); in handleCommonAttr()
2158 static void handleCmseNSEntryAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCmseNSEntryAttr() argument
2159 if (S.LangOpts.CPlusPlus && !D->getDeclContext()->isExternCContext()) { in handleCmseNSEntryAttr()
2160 S.Diag(AL.getLoc(), diag::err_attribute_not_clinkage) << AL; in handleCmseNSEntryAttr()
2166 S.Diag(AL.getLoc(), diag::warn_attribute_cmse_entry_static); in handleCmseNSEntryAttr()
2170 D->addAttr(::new (S.Context) CmseNSEntryAttr(S.Context, AL)); in handleCmseNSEntryAttr()
2173 static void handleNakedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNakedAttr() argument
2175 const auto &Triple = S.getASTContext().getTargetInfo().getTriple(); in handleNakedAttr()
2179 S.Diag(AL.getLoc(), diag::err_attribute_not_supported_on_arch) in handleNakedAttr()
2186 if (S.getLangOpts().MSVCCompat && isa<CXXMethodDecl>(D)) { in handleNakedAttr()
2187 S.Diag(AL.getLoc(), diag::err_attribute_wrong_decl_type_str) in handleNakedAttr()
2193 D->addAttr(::new (S.Context) NakedAttr(S.Context, AL)); in handleNakedAttr()
2196 static void handleNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &Attrs) { in handleNoReturnAttr() argument
2200 S.Diag(Attrs.getLoc(), diag::warn_attribute_wrong_decl_type) in handleNoReturnAttr()
2206 D->addAttr(::new (S.Context) NoReturnAttr(S.Context, Attrs)); in handleNoReturnAttr()
2209 static void handleStandardNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &A) { in handleStandardNoReturnAttr() argument
2215 if (!S.getLangOpts().CPlusPlus && in handleStandardNoReturnAttr()
2218 S.getSourceManager().isInSystemMacro(A.getLoc()))) in handleStandardNoReturnAttr()
2219 S.Diag(A.getLoc(), diag::warn_deprecated_noreturn_spelling) << A.getRange(); in handleStandardNoReturnAttr()
2221 D->addAttr(::new (S.Context) CXX11NoReturnAttr(S.Context, A)); in handleStandardNoReturnAttr()
2224 static void handleNoCfCheckAttr(Sema &S, Decl *D, const ParsedAttr &Attrs) { in handleNoCfCheckAttr() argument
2225 if (!S.getLangOpts().CFProtectionBranch) in handleNoCfCheckAttr()
2226 S.Diag(Attrs.getLoc(), diag::warn_nocf_check_attribute_ignored); in handleNoCfCheckAttr()
2228 handleSimpleAttribute<AnyX86NoCfCheckAttr>(S, D, Attrs); in handleNoCfCheckAttr()
2254 static void handleAnalyzerNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAnalyzerNoReturnAttr() argument
2262 S.Diag(AL.getLoc(), AL.isStandardAttributeSyntax() in handleAnalyzerNoReturnAttr()
2271 D->addAttr(::new (S.Context) AnalyzerNoReturnAttr(S.Context, AL)); in handleAnalyzerNoReturnAttr()
2275 static void handleVecReturnAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleVecReturnAttr() argument
2301 S.Diag(AL.getLoc(), diag::err_repeat_attribute) << A; in handleVecReturnAttr()
2309 S.Diag(AL.getLoc(), diag::err_attribute_vecreturn_only_vector_member); in handleVecReturnAttr()
2314 S.Diag(AL.getLoc(), diag::err_attribute_vecreturn_only_pod_record); in handleVecReturnAttr()
2320 S.Diag(AL.getLoc(), diag::err_attribute_vecreturn_only_vector_member); in handleVecReturnAttr()
2326 D->addAttr(::new (S.Context) VecReturnAttr(S.Context, AL)); in handleVecReturnAttr()
2329 static void handleDependencyAttr(Sema &S, Scope *Scope, Decl *D, in handleDependencyAttr() argument
2335 S.Diag(AL.getLoc(), in handleDependencyAttr()
2341 D->addAttr(::new (S.Context) CarriesDependencyAttr(S.Context, AL)); in handleDependencyAttr()
2344 static void handleUnusedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleUnusedAttr() argument
2349 if (!S.getLangOpts().CPlusPlus17 && IsCXX17Attr) in handleUnusedAttr()
2350 S.Diag(AL.getLoc(), diag::ext_cxx17_attr) << AL; in handleUnusedAttr()
2352 D->addAttr(::new (S.Context) UnusedAttr(S.Context, AL)); in handleUnusedAttr()
2355 static void handleConstructorAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleConstructorAttr() argument
2357 if (S.getLangOpts().HLSL && AL.getNumArgs()) { in handleConstructorAttr()
2358 S.Diag(AL.getLoc(), diag::err_hlsl_init_priority_unsupported); in handleConstructorAttr()
2362 !checkUInt32Argument(S, AL, AL.getArgAsExpr(0), priority)) in handleConstructorAttr()
2365 D->addAttr(::new (S.Context) ConstructorAttr(S.Context, AL, priority)); in handleConstructorAttr()
2368 static void handleDestructorAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleDestructorAttr() argument
2371 !checkUInt32Argument(S, AL, AL.getArgAsExpr(0), priority)) in handleDestructorAttr()
2374 D->addAttr(::new (S.Context) DestructorAttr(S.Context, AL, priority)); in handleDestructorAttr()
2378 static void handleAttrWithMessage(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAttrWithMessage() argument
2381 if (AL.getNumArgs() == 1 && !S.checkStringLiteralArgumentAttr(AL, 0, Str)) in handleAttrWithMessage()
2384 D->addAttr(::new (S.Context) AttrTy(S.Context, AL, Str)); in handleAttrWithMessage()
2387 static void handleObjCSuppresProtocolAttr(Sema &S, Decl *D, in handleObjCSuppresProtocolAttr() argument
2390 S.Diag(AL.getLoc(), diag::err_objc_attr_protocol_requires_definition) in handleObjCSuppresProtocolAttr()
2395 D->addAttr(::new (S.Context) ObjCExplicitProtocolImplAttr(S.Context, AL)); in handleObjCSuppresProtocolAttr()
2398 static bool checkAvailabilityAttr(Sema &S, SourceRange Range, in checkAvailabilityAttr() argument
2412 S.Diag(Range.getBegin(), diag::warn_availability_version_ordering) in checkAvailabilityAttr()
2420 S.Diag(Range.getBegin(), diag::warn_availability_version_ordering) in checkAvailabilityAttr()
2428 S.Diag(Range.getBegin(), diag::warn_availability_version_ordering) in checkAvailabilityAttr()
2619 static void handleAvailabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAvailabilityAttr() argument
2622 S.Diag(AL.getRange().getBegin(), diag::warn_deprecated_ignored_on_using) in handleAvailabilityAttr()
2627 if (!AL.checkExactlyNumArgs(S, 1)) in handleAvailabilityAttr()
2633 S.Diag(Platform->Loc, diag::warn_availability_unknown_platform) in handleAvailabilityAttr()
2656 S.Diag(AL.getLoc(), in handleAvailabilityAttr()
2666 S.Diag(AL.getLoc(), diag::warn_availability_fuchsia_unavailable_minor); in handleAvailabilityAttr()
2674 AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr( in handleAvailabilityAttr()
2683 if (S.Context.getTargetInfo().getTriple().isWatchOS()) { in handleAvailabilityAttr()
2686 NewII = &S.Context.Idents.get("watchos"); in handleAvailabilityAttr()
2688 NewII = &S.Context.Idents.get("watchos_app_extension"); in handleAvailabilityAttr()
2691 const auto *SDKInfo = S.getDarwinSDKInfoForAvailabilityChecking(); in handleAvailabilityAttr()
2730 AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr( in handleAvailabilityAttr()
2738 } else if (S.Context.getTargetInfo().getTriple().isTvOS()) { in handleAvailabilityAttr()
2743 NewII = &S.Context.Idents.get("tvos"); in handleAvailabilityAttr()
2745 NewII = &S.Context.Idents.get("tvos_app_extension"); in handleAvailabilityAttr()
2748 const auto *SDKInfo = S.getDarwinSDKInfoForAvailabilityChecking(); in handleAvailabilityAttr()
2772 AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr( in handleAvailabilityAttr()
2780 } else if (S.Context.getTargetInfo().getTriple().getOS() == in handleAvailabilityAttr()
2782 S.Context.getTargetInfo().getTriple().isMacCatalystEnvironment()) { in handleAvailabilityAttr()
2784 return S.getDarwinSDKInfoForAvailabilityChecking(AL.getRange().getBegin(), in handleAvailabilityAttr()
2791 NewII = &S.Context.Idents.get("maccatalyst"); in handleAvailabilityAttr()
2793 NewII = &S.Context.Idents.get("maccatalyst_app_extension"); in handleAvailabilityAttr()
2803 AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr( in handleAvailabilityAttr()
2822 NewII = &S.Context.Idents.get("maccatalyst"); in handleAvailabilityAttr()
2845 AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr( in handleAvailabilityAttr()
2861 static void handleExternalSourceSymbolAttr(Sema &S, Decl *D, in handleExternalSourceSymbolAttr() argument
2863 if (!AL.checkAtLeastNumArgs(S, 1) || !AL.checkAtMostNumArgs(S, 4)) in handleExternalSourceSymbolAttr()
2877 D->addAttr(::new (S.Context) ExternalSourceSymbolAttr( in handleExternalSourceSymbolAttr()
2878 S.Context, AL, Language, DefinedIn, IsGeneratedDeclaration, USR)); in handleExternalSourceSymbolAttr()
2882 static T *mergeVisibilityAttr(Sema &S, Decl *D, const AttributeCommonInfo &CI, in mergeVisibilityAttr() argument
2889 S.Diag(existingAttr->getLocation(), diag::err_mismatched_visibility); in mergeVisibilityAttr()
2890 S.Diag(CI.getLoc(), diag::note_previous_attribute); in mergeVisibilityAttr()
2893 return ::new (S.Context) T(S.Context, CI, value); in mergeVisibilityAttr()
2908 static void handleVisibilityAttr(Sema &S, Decl *D, const ParsedAttr &AL, in handleVisibilityAttr() argument
2912 S.Diag(AL.getRange().getBegin(), diag::warn_attribute_ignored) << AL; in handleVisibilityAttr()
2919 S.Diag(AL.getRange().getBegin(), diag::err_attribute_wrong_decl_type) in handleVisibilityAttr()
2927 if (!S.checkStringLiteralArgumentAttr(AL, 0, TypeStr, &LiteralLoc)) in handleVisibilityAttr()
2932 S.Diag(LiteralLoc, diag::warn_attribute_type_not_supported) << AL in handleVisibilityAttr()
2940 !S.Context.getTargetInfo().hasProtectedVisibility()) { in handleVisibilityAttr()
2941 S.Diag(AL.getLoc(), diag::warn_attribute_protected_visibility); in handleVisibilityAttr()
2947 newAttr = S.mergeTypeVisibilityAttr( in handleVisibilityAttr()
2950 newAttr = S.mergeVisibilityAttr(D, AL, type); in handleVisibilityAttr()
2956 static void handleObjCDirectAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleObjCDirectAttr() argument
2959 S.Diag(AL.getLoc(), diag::err_objc_direct_on_protocol) << false; in handleObjCDirectAttr()
2963 if (S.getLangOpts().ObjCRuntime.allowsDirectDispatch()) { in handleObjCDirectAttr()
2964 handleSimpleAttribute<ObjCDirectAttr>(S, D, AL); in handleObjCDirectAttr()
2966 S.Diag(AL.getLoc(), diag::warn_objc_direct_ignored) << AL; in handleObjCDirectAttr()
2970 static void handleObjCDirectMembersAttr(Sema &S, Decl *D, in handleObjCDirectMembersAttr() argument
2972 if (S.getLangOpts().ObjCRuntime.allowsDirectDispatch()) { in handleObjCDirectMembersAttr()
2973 handleSimpleAttribute<ObjCDirectMembersAttr>(S, D, AL); in handleObjCDirectMembersAttr()
2975 S.Diag(AL.getLoc(), diag::warn_objc_direct_ignored) << AL; in handleObjCDirectMembersAttr()
2979 static void handleObjCMethodFamilyAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleObjCMethodFamilyAttr() argument
2982 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) in handleObjCMethodFamilyAttr()
2990 S.Diag(IL->Loc, diag::warn_attribute_type_not_supported) << AL << IL->Ident; in handleObjCMethodFamilyAttr()
2996 S.Diag(M->getLocation(), diag::err_init_method_bad_return_type) in handleObjCMethodFamilyAttr()
3002 D->addAttr(new (S.Context) ObjCMethodFamilyAttr(S.Context, AL, F)); in handleObjCMethodFamilyAttr()
3005 static void handleObjCNSObject(Sema &S, Decl *D, const ParsedAttr &AL) { in handleObjCNSObject() argument
3009 S.Diag(TD->getLocation(), diag::err_nsobject_attribute); in handleObjCNSObject()
3016 S.Diag(PD->getLocation(), diag::err_nsobject_attribute); in handleObjCNSObject()
3027 S.Diag(D->getLocation(), diag::warn_nsobject_attribute); in handleObjCNSObject()
3029 D->addAttr(::new (S.Context) ObjCNSObjectAttr(S.Context, AL)); in handleObjCNSObject()
3032 static void handleObjCIndependentClass(Sema &S, Decl *D, const ParsedAttr &AL) { in handleObjCIndependentClass() argument
3036 S.Diag(TD->getLocation(), diag::warn_ptr_independentclass_attribute); in handleObjCIndependentClass()
3040 S.Diag(D->getLocation(), diag::warn_independentclass_attribute); in handleObjCIndependentClass()
3043 D->addAttr(::new (S.Context) ObjCIndependentClassAttr(S.Context, AL)); in handleObjCIndependentClass()
3046 static void handleBlocksAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleBlocksAttr() argument
3048 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) in handleBlocksAttr()
3056 S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) << AL << II; in handleBlocksAttr()
3060 D->addAttr(::new (S.Context) BlocksAttr(S.Context, AL, type)); in handleBlocksAttr()
3063 static void handleSentinelAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSentinelAttr() argument
3068 if (E->isTypeDependent() || !(Idx = E->getIntegerConstantExpr(S.Context))) { in handleSentinelAttr()
3069 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) in handleSentinelAttr()
3075 S.Diag(AL.getLoc(), diag::err_attribute_sentinel_less_than_zero) in handleSentinelAttr()
3087 if (E->isTypeDependent() || !(Idx = E->getIntegerConstantExpr(S.Context))) { in handleSentinelAttr()
3088 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) in handleSentinelAttr()
3097 S.Diag(AL.getLoc(), diag::err_attribute_sentinel_not_zero_or_one) in handleSentinelAttr()
3106 S.Diag(AL.getLoc(), diag::warn_attribute_sentinel_named_arguments); in handleSentinelAttr()
3111 S.Diag(AL.getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0; in handleSentinelAttr()
3116 S.Diag(AL.getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0; in handleSentinelAttr()
3121 S.Diag(AL.getLoc(), diag::warn_attribute_sentinel_not_variadic) << 1; in handleSentinelAttr()
3134 S.Diag(AL.getLoc(), diag::warn_attribute_sentinel_not_variadic) << m; in handleSentinelAttr()
3138 S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type) in handleSentinelAttr()
3144 S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type) in handleSentinelAttr()
3149 D->addAttr(::new (S.Context) SentinelAttr(S.Context, AL, sentinel, nullPos)); in handleSentinelAttr()
3152 static void handleWarnUnusedResult(Sema &S, Decl *D, const ParsedAttr &AL) { in handleWarnUnusedResult() argument
3156 S.Diag(AL.getLoc(), diag::warn_attribute_void_function_method) << AL << 0; in handleWarnUnusedResult()
3161 S.Diag(AL.getLoc(), diag::warn_attribute_void_function_method) << AL << 1; in handleWarnUnusedResult()
3170 S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type_str) in handleWarnUnusedResult()
3179 const LangOptions &LO = S.getLangOpts(); in handleWarnUnusedResult()
3182 S.Diag(AL.getLoc(), diag::ext_cxx20_attr) << AL; in handleWarnUnusedResult()
3188 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, nullptr)) in handleWarnUnusedResult()
3191 S.Diag(AL.getLoc(), diag::ext_cxx17_attr) << AL; in handleWarnUnusedResult()
3197 S.Diag(AL.getLoc(), diag::warn_unused_result_typedef_unsupported_spelling) in handleWarnUnusedResult()
3202 D->addAttr(::new (S.Context) WarnUnusedResultAttr(S.Context, AL, Str)); in handleWarnUnusedResult()
3205 static void handleWeakImportAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleWeakImportAttr() argument
3210 S.Diag(AL.getLoc(), diag::warn_attribute_invalid_on_definition) in handleWeakImportAttr()
3213 (S.Context.getTargetInfo().getTriple().isOSDarwin() && in handleWeakImportAttr()
3217 S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type) in handleWeakImportAttr()
3223 D->addAttr(::new (S.Context) WeakImportAttr(S.Context, AL)); in handleWeakImportAttr()
3228 static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { in handleWorkGroupSize() argument
3232 if (!checkUInt32Argument(S, AL, E, WGSize[i], i, in handleWorkGroupSize()
3236 S.Diag(AL.getLoc(), diag::err_attribute_argument_is_zero) in handleWorkGroupSize()
3246 S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; in handleWorkGroupSize()
3248 D->addAttr(::new (S.Context) in handleWorkGroupSize()
3249 WorkGroupAttr(S.Context, AL, WGSize[0], WGSize[1], WGSize[2])); in handleWorkGroupSize()
3253 static void handleSubGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSubGroupSize() argument
3256 if (!checkUInt32Argument(S, AL, E, SGSize)) in handleSubGroupSize()
3259 S.Diag(AL.getLoc(), diag::err_attribute_argument_is_zero) in handleSubGroupSize()
3267 S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; in handleSubGroupSize()
3269 D->addAttr(::new (S.Context) in handleSubGroupSize()
3270 OpenCLIntelReqdSubGroupSizeAttr(S.Context, AL, SGSize)); in handleSubGroupSize()
3273 static void handleVecTypeHint(Sema &S, Decl *D, const ParsedAttr &AL) { in handleVecTypeHint() argument
3275 S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1; in handleVecTypeHint()
3280 QualType ParmType = S.GetTypeFromParser(AL.getTypeArg(), &ParmTSI); in handleVecTypeHint()
3285 !ParmType->isIntegralType(S.getASTContext()))) { in handleVecTypeHint()
3286 S.Diag(AL.getLoc(), diag::err_attribute_invalid_argument) << 2 << AL; in handleVecTypeHint()
3291 if (!S.Context.hasSameType(A->getTypeHint(), ParmType)) { in handleVecTypeHint()
3292 S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; in handleVecTypeHint()
3297 D->addAttr(::new (S.Context) VecTypeHintAttr(S.Context, AL, ParmTSI)); in handleVecTypeHint()
3350 static void handleSectionAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSectionAttr() argument
3355 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &LiteralLoc)) in handleSectionAttr()
3358 if (!S.checkSectionName(LiteralLoc, Str)) in handleSectionAttr()
3361 SectionAttr *NewAttr = S.mergeSectionAttr(D, AL, Str); in handleSectionAttr()
3366 S.UnifySection(NewAttr->getName(), in handleSectionAttr()
3372 static void handleCodeModelAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCodeModelAttr() argument
3376 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &LiteralLoc)) in handleCodeModelAttr()
3381 S.Diag(LiteralLoc, diag::err_attr_codemodel_arg) << Str; in handleCodeModelAttr()
3385 D->addAttr(::new (S.Context) CodeModelAttr(S.Context, AL, CM)); in handleCodeModelAttr()
3390 static bool checkCodeSegName(Sema &S, SourceLocation LiteralLoc, in checkCodeSegName() argument
3392 if (llvm::Error E = S.isValidSectionSpecifier(CodeSegName)) { in checkCodeSegName()
3393 S.Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target) in checkCodeSegName()
3420 static void handleCodeSegAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCodeSegAttr() argument
3423 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &LiteralLoc)) in handleCodeSegAttr()
3425 if (!checkCodeSegName(S, LiteralLoc, Str)) in handleCodeSegAttr()
3429 S.Diag(AL.getLoc(), in handleCodeSegAttr()
3437 if (CodeSegAttr *CSA = S.mergeCodeSegAttr(D, AL, Str)) in handleCodeSegAttr()
3525 static void handleTargetVersionAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleTargetVersionAttr() argument
3529 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &LiteralLoc) || in handleTargetVersionAttr()
3530 S.checkTargetVersionAttr(LiteralLoc, Str, isDefault)) in handleTargetVersionAttr()
3535 ::new (S.Context) TargetVersionAttr(S.Context, AL, Str); in handleTargetVersionAttr()
3540 static void handleTargetAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleTargetAttr() argument
3543 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &LiteralLoc) || in handleTargetAttr()
3544 S.checkTargetAttr(LiteralLoc, Str)) in handleTargetAttr()
3547 TargetAttr *NewAttr = ::new (S.Context) TargetAttr(S.Context, AL, Str); in handleTargetAttr()
3648 static void handleTargetClonesAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleTargetClonesAttr() argument
3649 if (S.Context.getTargetInfo().getTriple().isAArch64() && in handleTargetClonesAttr()
3650 !S.Context.getTargetInfo().hasFeature("fmv")) in handleTargetClonesAttr()
3656 S.Diag(AL.getLoc(), diag::err_disallowed_duplicate_attribute) << AL; in handleTargetClonesAttr()
3657 S.Diag(Other->getLocation(), diag::note_conflicting_attribute); in handleTargetClonesAttr()
3660 if (checkAttrMutualExclusion<TargetClonesAttr>(S, D, AL)) in handleTargetClonesAttr()
3670 if (!S.checkStringLiteralArgumentAttr(AL, I, CurStr, &LiteralLoc) || in handleTargetClonesAttr()
3671 S.checkTargetClonesAttrString( in handleTargetClonesAttr()
3681 S.Diag(AL.getLoc(), diag::warn_target_clone_mixed_values); in handleTargetClonesAttr()
3683 if (S.Context.getTargetInfo().getTriple().isAArch64() && !HasDefault) { in handleTargetClonesAttr()
3690 S.Diag(AL.getLoc(), diag::err_target_clone_must_have_default); in handleTargetClonesAttr()
3698 S.Diag(D->getLocation(), diag::err_multiversion_doesnt_support) in handleTargetClonesAttr()
3706 if (S.Context.getTargetInfo().getTriple().isAArch64() && !HasNotDefault) in handleTargetClonesAttr()
3710 TargetClonesAttr *NewAttr = ::new (S.Context) in handleTargetClonesAttr()
3711 TargetClonesAttr(S.Context, AL, Strings.data(), Strings.size()); in handleTargetClonesAttr()
3715 static void handleMinVectorWidthAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleMinVectorWidthAttr() argument
3718 if (!checkUInt32Argument(S, AL, E, VecWidth)) { in handleMinVectorWidthAttr()
3725 S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; in handleMinVectorWidthAttr()
3729 D->addAttr(::new (S.Context) MinVectorWidthAttr(S.Context, AL, VecWidth)); in handleMinVectorWidthAttr()
3732 static void handleCleanupAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCleanupAttr() argument
3742 S.Diag(Loc, diag::warn_cleanup_ext); in handleCleanupAttr()
3746 S.Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 1 in handleCleanupAttr()
3752 S.Diag(Loc, diag::warn_cleanup_ext); in handleCleanupAttr()
3753 FD = S.ResolveSingleFunctionTemplateSpecialization(ULE, true); in handleCleanupAttr()
3756 S.Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 2 in handleCleanupAttr()
3758 if (ULE->getType() == S.Context.OverloadTy) in handleCleanupAttr()
3759 S.NoteAllOverloadCandidates(ULE); in handleCleanupAttr()
3763 S.Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 0; in handleCleanupAttr()
3768 S.Diag(Loc, diag::err_attribute_cleanup_func_must_take_one_arg) in handleCleanupAttr()
3775 QualType Ty = S.Context.getPointerType(cast<VarDecl>(D)->getType()); in handleCleanupAttr()
3777 if (S.CheckAssignmentConstraints(FD->getParamDecl(0)->getLocation(), in handleCleanupAttr()
3779 S.Diag(Loc, diag::err_attribute_cleanup_func_arg_incompatible_type) in handleCleanupAttr()
3784 D->addAttr(::new (S.Context) CleanupAttr(S.Context, AL, FD)); in handleCleanupAttr()
3787 static void handleEnumExtensibilityAttr(Sema &S, Decl *D, in handleEnumExtensibilityAttr() argument
3790 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) in handleEnumExtensibilityAttr()
3799 S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) << AL << II; in handleEnumExtensibilityAttr()
3803 D->addAttr(::new (S.Context) in handleEnumExtensibilityAttr()
3804 EnumExtensibilityAttr(S.Context, AL, ExtensibilityKind)); in handleEnumExtensibilityAttr()
3809 static void handleFormatArgAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleFormatArgAttr() argument
3812 if (!checkFunctionOrMethodParameterIndex(S, D, AL, 1, IdxExpr, Idx)) in handleFormatArgAttr()
3818 bool NotNSStringTy = !isNSStringType(Ty, S.Context); in handleFormatArgAttr()
3820 !isCFStringType(Ty, S.Context) && in handleFormatArgAttr()
3823 S.Diag(AL.getLoc(), diag::err_format_attribute_not) in handleFormatArgAttr()
3829 auto Instancetype = S.Context.getObjCInstanceTypeDecl()->getTypeForDecl(); in handleFormatArgAttr()
3833 Ty = S.Context.getObjCObjectPointerType( in handleFormatArgAttr()
3835 if (!isNSStringType(Ty, S.Context, /*AllowNSAttributedString=*/true) && in handleFormatArgAttr()
3836 !isCFStringType(Ty, S.Context) && in handleFormatArgAttr()
3839 S.Diag(AL.getLoc(), diag::err_format_attribute_result_not) in handleFormatArgAttr()
3845 D->addAttr(::new (S.Context) FormatArgAttr(S.Context, AL, Idx)); in handleFormatArgAttr()
3880 static void handleInitPriorityAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleInitPriorityAttr() argument
3881 if (!S.getLangOpts().CPlusPlus) { in handleInitPriorityAttr()
3882 S.Diag(AL.getLoc(), diag::warn_attribute_ignored) << AL; in handleInitPriorityAttr()
3886 if (S.getLangOpts().HLSL) { in handleInitPriorityAttr()
3887 S.Diag(AL.getLoc(), diag::err_hlsl_init_priority_unsupported); in handleInitPriorityAttr()
3891 if (S.getCurFunctionOrMethodDecl()) { in handleInitPriorityAttr()
3892 S.Diag(AL.getLoc(), diag::err_init_priority_object_attr); in handleInitPriorityAttr()
3897 if (S.Context.getAsArrayType(T)) in handleInitPriorityAttr()
3898 T = S.Context.getBaseElementType(T); in handleInitPriorityAttr()
3900 S.Diag(AL.getLoc(), diag::err_init_priority_object_attr); in handleInitPriorityAttr()
3907 if (!checkUInt32Argument(S, AL, E, prioritynum)) { in handleInitPriorityAttr()
3916 !S.getSourceManager().isInSystemHeader(AL.getLoc())) { in handleInitPriorityAttr()
3917 S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_range) in handleInitPriorityAttr()
3922 D->addAttr(::new (S.Context) InitPriorityAttr(S.Context, AL, prioritynum)); in handleInitPriorityAttr()
3971 static void handleFormatAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleFormatAttr() argument
3973 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) in handleFormatAttr()
3988 II = &S.Context.Idents.get(Format); in handleFormatAttr()
3998 S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) in handleFormatAttr()
4006 if (!checkUInt32Argument(S, AL, IdxExpr, Idx, 2)) in handleFormatAttr()
4010 S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds) in handleFormatAttr()
4020 S.Diag(AL.getLoc(), in handleFormatAttr()
4031 if (!isNSStringType(Ty, S.Context, true) && in handleFormatAttr()
4032 !isCFStringType(Ty, S.Context) && in handleFormatAttr()
4035 S.Diag(AL.getLoc(), diag::err_format_attribute_not) in handleFormatAttr()
4043 if (!checkUInt32Argument(S, AL, FirstArgExpr, FirstArg, 3)) in handleFormatAttr()
4051 S.Diag(AL.getLoc(), diag::err_format_strftime_third_parameter) in handleFormatAttr()
4060 S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds) in handleFormatAttr()
4068 S.Diag(D->getLocation(), diag::warn_gcc_requires_variadic_function) << AL; in handleFormatAttr()
4073 S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds) in handleFormatAttr()
4080 FormatAttr *NewAttr = S.mergeFormatAttr(D, AL, II, Idx, FirstArg); in handleFormatAttr()
4086 static void handleCallbackAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCallbackAttr() argument
4089 S.Diag(AL.getLoc(), diag::err_callback_attribute_no_callee) in handleCallbackAttr()
4120 S.Diag(AL.getLoc(), diag::err_callback_attribute_argument_unknown) in handleCallbackAttr()
4131 if (!checkUInt32Argument(S, AL, IdxExpr, (uint32_t &)ArgIdx, I + 1, in handleCallbackAttr()
4133 S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds) in handleCallbackAttr()
4140 S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds) in handleCallbackAttr()
4151 S.Diag(AL.getLoc(), diag::err_callback_implicit_this_not_available) in handleCallbackAttr()
4169 S.Diag(AL.getLoc(), diag::err_callback_attribute_invalid_callee) in handleCallbackAttr()
4180 S.Diag(AL.getLoc(), diag::err_callback_callee_no_function_type) in handleCallbackAttr()
4192 S.Diag(AL.getLoc(), diag::err_callback_callee_no_function_type) in handleCallbackAttr()
4198 S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) in handleCallbackAttr()
4204 S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) in handleCallbackAttr()
4210 S.Diag(AL.getLoc(), diag::err_callback_callee_is_variadic) << AL.getRange(); in handleCallbackAttr()
4216 S.Diag(AL.getLoc(), diag::err_callback_attribute_multiple) << AL.getRange(); in handleCallbackAttr()
4220 D->addAttr(::new (S.Context) CallbackAttr( in handleCallbackAttr()
4221 S.Context, AL, EncodingIndices.data(), EncodingIndices.size())); in handleCallbackAttr()
4232 static void handleCalledOnceAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCalledOnceAttr() argument
4237 S.Diag(AL.getLoc(), diag::err_called_once_attribute_wrong_type); in handleCalledOnceAttr()
4241 D->addAttr(::new (S.Context) CalledOnceAttr(S.Context, AL)); in handleCalledOnceAttr()
4244 static void handleTransparentUnionAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleTransparentUnionAttr() argument
4254 S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type) in handleTransparentUnionAttr()
4261 S.Diag(AL.getLoc(), in handleTransparentUnionAttr()
4269 S.Diag(AL.getLoc(), diag::warn_transparent_union_attribute_zero_fields); in handleTransparentUnionAttr()
4276 S.Diag(FirstField->getLocation(), in handleTransparentUnionAttr()
4284 uint64_t FirstSize = S.Context.getTypeSize(FirstType); in handleTransparentUnionAttr()
4285 uint64_t FirstAlign = S.Context.getTypeAlign(FirstType); in handleTransparentUnionAttr()
4295 if (S.Context.getTypeSize(FieldType) != FirstSize || in handleTransparentUnionAttr()
4296 S.Context.getTypeAlign(FieldType) > FirstAlign) { in handleTransparentUnionAttr()
4298 bool isSize = S.Context.getTypeSize(FieldType) != FirstSize; in handleTransparentUnionAttr()
4299 unsigned FieldBits = isSize ? S.Context.getTypeSize(FieldType) in handleTransparentUnionAttr()
4300 : S.Context.getTypeAlign(FieldType); in handleTransparentUnionAttr()
4301 S.Diag(Field->getLocation(), in handleTransparentUnionAttr()
4305 S.Diag(FirstField->getLocation(), in handleTransparentUnionAttr()
4312 RD->addAttr(::new (S.Context) TransparentUnionAttr(S.Context, AL)); in handleTransparentUnionAttr()
4324 static void handleAnnotateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAnnotateAttr() argument
4328 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str)) in handleAnnotateAttr()
4338 S.AddAnnotationAttr(D, AL, Str, Args); in handleAnnotateAttr()
4341 static void handleAlignValueAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAlignValueAttr() argument
4342 S.AddAlignValueAttr(D, AL, AL.getArgAsExpr(0)); in handleAlignValueAttr()
4385 static void handleAlignedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAlignedAttr() argument
4389 (void)S.GetTypeFromParser( in handleAlignedAttr()
4393 S.Diag(AL.getEllipsisLoc(), in handleAlignedAttr()
4399 S.DiagnoseUnexpandedParameterPack(TInfo->getTypeLoc().getBeginLoc(), in handleAlignedAttr()
4403 S.AddAlignedAttr(D, AL, TInfo, AL.isPackExpansion()); in handleAlignedAttr()
4409 S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1; in handleAlignedAttr()
4414 D->addAttr(::new (S.Context) AlignedAttr(S.Context, AL, true, nullptr)); in handleAlignedAttr()
4420 S.Diag(AL.getEllipsisLoc(), in handleAlignedAttr()
4425 if (!AL.isPackExpansion() && S.DiagnoseUnexpandedParameterPack(E)) in handleAlignedAttr()
4428 S.AddAlignedAttr(D, AL, E, AL.isPackExpansion()); in handleAlignedAttr()
4447 static bool validateAlignasAppliedType(Sema &S, Decl *D, in validateAlignasAppliedType() argument
4465 return S.Diag(AttrLoc, diag::err_attribute_wrong_decl_type) in validateAlignasAppliedType()
4471 return S.Diag(AttrLoc, diag::err_alignas_attribute_wrong_decl_type) in validateAlignasAppliedType()
4687 static void parseModeAttrArg(Sema &S, StringRef Str, unsigned &DestWidth, in parseModeAttrArg() argument
4737 DestWidth = S.Context.getTargetInfo().getRegisterWidth(); in parseModeAttrArg()
4739 DestWidth = S.Context.getTargetInfo().getCharWidth(); in parseModeAttrArg()
4743 DestWidth = S.Context.getTargetInfo().getPointerWidth(LangAS::Default); in parseModeAttrArg()
4747 DestWidth = S.Context.getTargetInfo().getUnwindWordWidth(); in parseModeAttrArg()
4758 static void handleModeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleModeAttr() argument
4762 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleModeAttr()
4769 S.AddModeAttr(D, AL, Name); in handleModeAttr()
4915 static void handleNoDebugAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNoDebugAttr() argument
4916 D->addAttr(::new (S.Context) NoDebugAttr(S.Context, AL)); in handleNoDebugAttr()
5025 static void handleAlwaysInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAlwaysInlineAttr() argument
5027 S.mergeAlwaysInlineAttr(D, AL, AL.getAttrName())) in handleAlwaysInlineAttr()
5031 static void handleMinSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleMinSizeAttr() argument
5032 if (MinSizeAttr *MinSize = S.mergeMinSizeAttr(D, AL)) in handleMinSizeAttr()
5036 static void handleOptimizeNoneAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleOptimizeNoneAttr() argument
5037 if (OptimizeNoneAttr *Optnone = S.mergeOptimizeNoneAttr(D, AL)) in handleOptimizeNoneAttr()
5041 static void handleConstantAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleConstantAttr() argument
5044 S.Diag(AL.getLoc(), diag::err_cuda_nonstatic_constdev); in handleConstantAttr()
5054 D->addAttr(::new (S.Context) CUDAConstantAttr(S.Context, AL)); in handleConstantAttr()
5057 static void handleSharedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSharedAttr() argument
5061 if (!S.getLangOpts().GPURelocatableDeviceCode && VD->hasExternalStorage() && in handleSharedAttr()
5063 S.Diag(AL.getLoc(), diag::err_cuda_extern_shared) << VD; in handleSharedAttr()
5066 if (S.getLangOpts().CUDA && VD->hasLocalStorage() && in handleSharedAttr()
5067 S.CUDADiagIfHostCode(AL.getLoc(), diag::err_cuda_host_shared) in handleSharedAttr()
5068 << S.CurrentCUDATarget()) in handleSharedAttr()
5070 D->addAttr(::new (S.Context) CUDASharedAttr(S.Context, AL)); in handleSharedAttr()
5073 static void handleGlobalAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleGlobalAttr() argument
5079 S.Diag(FD->getTypeSpecStartLoc(), diag::err_kern_type_not_void_return) in handleGlobalAttr()
5087 S.Diag(Method->getBeginLoc(), diag::err_kern_is_nonstatic_method) in handleGlobalAttr()
5091 S.Diag(Method->getBeginLoc(), diag::warn_kern_is_method) << Method; in handleGlobalAttr()
5094 if (FD->isInlineSpecified() && !S.getLangOpts().CUDAIsDevice) in handleGlobalAttr()
5095 S.Diag(FD->getBeginLoc(), diag::warn_kern_is_inline) << FD; in handleGlobalAttr()
5098 D->addAttr(::new (S.Context) NVPTXKernelAttr(S.Context, AL)); in handleGlobalAttr()
5100 D->addAttr(::new (S.Context) CUDAGlobalAttr(S.Context, AL)); in handleGlobalAttr()
5105 if (S.LangOpts.HIP && !S.LangOpts.CUDAIsDevice) in handleGlobalAttr()
5106 D->addAttr(NoDebugAttr::CreateImplicit(S.Context)); in handleGlobalAttr()
5109 static void handleDeviceAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleDeviceAttr() argument
5112 S.Diag(AL.getLoc(), diag::err_cuda_nonstatic_constdev); in handleDeviceAttr()
5122 D->addAttr(::new (S.Context) CUDADeviceAttr(S.Context, AL)); in handleDeviceAttr()
5125 static void handleManagedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleManagedAttr() argument
5128 S.Diag(AL.getLoc(), diag::err_cuda_nonstatic_constdev); in handleManagedAttr()
5133 D->addAttr(::new (S.Context) HIPManagedAttr(S.Context, AL)); in handleManagedAttr()
5135 D->addAttr(CUDADeviceAttr::CreateImplicit(S.Context)); in handleManagedAttr()
5138 static void handleGNUInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleGNUInlineAttr() argument
5141 S.Diag(AL.getLoc(), diag::warn_gnu_inline_attribute_requires_inline); in handleGNUInlineAttr()
5145 if (S.LangOpts.CPlusPlus && Fn->getStorageClass() != SC_Extern) in handleGNUInlineAttr()
5146 S.Diag(AL.getLoc(), diag::warn_gnu_inline_cplusplus_without_extern); in handleGNUInlineAttr()
5148 D->addAttr(::new (S.Context) GNUInlineAttr(S.Context, AL)); in handleGNUInlineAttr()
5151 static void handleCallConvAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCallConvAttr() argument
5157 if (S.CheckCallingConvAttr(AL, CC, /*FD*/ nullptr, in handleCallConvAttr()
5158 S.IdentifyCUDATarget(dyn_cast<FunctionDecl>(D)))) in handleCallConvAttr()
5162 S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type) in handleCallConvAttr()
5169 D->addAttr(::new (S.Context) FastCallAttr(S.Context, AL)); in handleCallConvAttr()
5172 D->addAttr(::new (S.Context) StdCallAttr(S.Context, AL)); in handleCallConvAttr()
5175 D->addAttr(::new (S.Context) ThisCallAttr(S.Context, AL)); in handleCallConvAttr()
5178 D->addAttr(::new (S.Context) CDeclAttr(S.Context, AL)); in handleCallConvAttr()
5181 D->addAttr(::new (S.Context) PascalAttr(S.Context, AL)); in handleCallConvAttr()
5184 D->addAttr(::new (S.Context) SwiftCallAttr(S.Context, AL)); in handleCallConvAttr()
5187 D->addAttr(::new (S.Context) SwiftAsyncCallAttr(S.Context, AL)); in handleCallConvAttr()
5190 D->addAttr(::new (S.Context) VectorCallAttr(S.Context, AL)); in handleCallConvAttr()
5193 D->addAttr(::new (S.Context) MSABIAttr(S.Context, AL)); in handleCallConvAttr()
5196 D->addAttr(::new (S.Context) SysVABIAttr(S.Context, AL)); in handleCallConvAttr()
5199 D->addAttr(::new (S.Context) RegCallAttr(S.Context, AL)); in handleCallConvAttr()
5214 D->addAttr(::new (S.Context) PcsAttr(S.Context, AL, PCS)); in handleCallConvAttr()
5218 D->addAttr(::new (S.Context) AArch64VectorPcsAttr(S.Context, AL)); in handleCallConvAttr()
5221 D->addAttr(::new (S.Context) AArch64SVEPcsAttr(S.Context, AL)); in handleCallConvAttr()
5224 D->addAttr(::new (S.Context) AMDGPUKernelCallAttr(S.Context, AL)); in handleCallConvAttr()
5227 D->addAttr(::new (S.Context) IntelOclBiccAttr(S.Context, AL)); in handleCallConvAttr()
5230 D->addAttr(::new (S.Context) PreserveMostAttr(S.Context, AL)); in handleCallConvAttr()
5233 D->addAttr(::new (S.Context) PreserveAllAttr(S.Context, AL)); in handleCallConvAttr()
5236 D->addAttr(::new (S.Context) M68kRTDAttr(S.Context, AL)); in handleCallConvAttr()
5243 static void handleSuppressAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSuppressAttr() argument
5246 if (!AL.checkAtLeastNumArgs(S, 1)) in handleSuppressAttr()
5250 S.Diag(AL.getLoc(), diag::err_attribute_wrong_decl_type_str) in handleSuppressAttr()
5259 if (!S.checkStringLiteralArgumentAttr(AL, I, RuleName, nullptr)) in handleSuppressAttr()
5264 D->addAttr(::new (S.Context) in handleSuppressAttr()
5265 SuppressAttr(S.Context, AL, DiagnosticIdentifiers.data(), in handleSuppressAttr()
5269 static void handleLifetimeCategoryAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleLifetimeCategoryAttr() argument
5273 ParmType = S.GetTypeFromParser(AL.getTypeArg(), &DerefTypeLoc); in handleLifetimeCategoryAttr()
5282 S.Diag(AL.getLoc(), diag::err_attribute_invalid_argument) in handleLifetimeCategoryAttr()
5295 if (checkAttrMutualExclusion<PointerAttr>(S, D, AL)) in handleLifetimeCategoryAttr()
5302 S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) in handleLifetimeCategoryAttr()
5306 S.Diag(OAttr->getLocation(), diag::note_conflicting_attribute); in handleLifetimeCategoryAttr()
5311 Redecl->addAttr(::new (S.Context) OwnerAttr(S.Context, AL, DerefTypeLoc)); in handleLifetimeCategoryAttr()
5314 if (checkAttrMutualExclusion<OwnerAttr>(S, D, AL)) in handleLifetimeCategoryAttr()
5321 S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) in handleLifetimeCategoryAttr()
5325 S.Diag(PAttr->getLocation(), diag::note_conflicting_attribute); in handleLifetimeCategoryAttr()
5330 Redecl->addAttr(::new (S.Context) in handleLifetimeCategoryAttr()
5331 PointerAttr(S.Context, AL, DerefTypeLoc)); in handleLifetimeCategoryAttr()
5336 static void handleRandomizeLayoutAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleRandomizeLayoutAttr() argument
5337 if (checkAttrMutualExclusion<NoRandomizeLayoutAttr>(S, D, AL)) in handleRandomizeLayoutAttr()
5340 D->addAttr(::new (S.Context) RandomizeLayoutAttr(S.Context, AL)); in handleRandomizeLayoutAttr()
5343 static void handleNoRandomizeLayoutAttr(Sema &S, Decl *D, in handleNoRandomizeLayoutAttr() argument
5345 if (checkAttrMutualExclusion<RandomizeLayoutAttr>(S, D, AL)) in handleNoRandomizeLayoutAttr()
5348 D->addAttr(::new (S.Context) NoRandomizeLayoutAttr(S.Context, AL)); in handleNoRandomizeLayoutAttr()
5656 static Expr *makeLaunchBoundsArgExpr(Sema &S, Expr *E, in makeLaunchBoundsArgExpr() argument
5659 if (S.DiagnoseUnexpandedParameterPack(E)) in makeLaunchBoundsArgExpr()
5668 if (!(I = E->getIntegerConstantExpr(S.Context))) { in makeLaunchBoundsArgExpr()
5669 S.Diag(E->getExprLoc(), diag::err_attribute_argument_n_type) in makeLaunchBoundsArgExpr()
5675 S.Diag(E->getExprLoc(), diag::err_ice_too_large) in makeLaunchBoundsArgExpr()
5680 S.Diag(E->getExprLoc(), diag::warn_attribute_argument_n_negative) in makeLaunchBoundsArgExpr()
5685 S.Context, S.Context.getConstType(S.Context.IntTy), /*consume*/ false); in makeLaunchBoundsArgExpr()
5686 ExprResult ValArg = S.PerformCopyInitialization(Entity, SourceLocation(), E); in makeLaunchBoundsArgExpr()
5733 static void handleLaunchBoundsAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleLaunchBoundsAttr() argument
5734 if (!AL.checkAtLeastNumArgs(S, 1) || !AL.checkAtMostNumArgs(S, 3)) in handleLaunchBoundsAttr()
5737 S.AddLaunchBoundsAttr(D, AL, AL.getArgAsExpr(0), in handleLaunchBoundsAttr()
5742 static void handleArgumentWithTypeTagAttr(Sema &S, Decl *D, in handleArgumentWithTypeTagAttr() argument
5745 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) in handleArgumentWithTypeTagAttr()
5751 if (!checkFunctionOrMethodParameterIndex(S, D, AL, 2, AL.getArgAsExpr(1), in handleArgumentWithTypeTagAttr()
5756 if (!checkFunctionOrMethodParameterIndex(S, D, AL, 3, AL.getArgAsExpr(2), in handleArgumentWithTypeTagAttr()
5766 S.Diag(AL.getLoc(), diag::err_attribute_pointers_only) << AL << 0; in handleArgumentWithTypeTagAttr()
5769 D->addAttr(::new (S.Context) ArgumentWithTypeTagAttr( in handleArgumentWithTypeTagAttr()
5770 S.Context, AL, AL.getArgAsIdent(0)->Ident, ArgumentIdx, TypeTagIdx, in handleArgumentWithTypeTagAttr()
5774 static void handleTypeTagForDatatypeAttr(Sema &S, Decl *D, in handleTypeTagForDatatypeAttr() argument
5777 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) in handleTypeTagForDatatypeAttr()
5782 if (!AL.checkExactlyNumArgs(S, 1)) in handleTypeTagForDatatypeAttr()
5786 S.Diag(AL.getLoc(), diag::err_attribute_wrong_decl_type) in handleTypeTagForDatatypeAttr()
5793 S.GetTypeFromParser(AL.getMatchingCType(), &MatchingCTypeLoc); in handleTypeTagForDatatypeAttr()
5796 D->addAttr(::new (S.Context) TypeTagForDatatypeAttr( in handleTypeTagForDatatypeAttr()
5797 S.Context, AL, PointerKind, MatchingCTypeLoc, AL.getLayoutCompatible(), in handleTypeTagForDatatypeAttr()
5801 static void handleXRayLogArgsAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleXRayLogArgsAttr() argument
5804 if (!checkFunctionOrMethodParameterIndex(S, D, AL, 1, AL.getArgAsExpr(0), in handleXRayLogArgsAttr()
5810 D->addAttr(::new (S.Context) in handleXRayLogArgsAttr()
5811 XRayLogArgsAttr(S.Context, AL, ArgCount.getSourceIndex())); in handleXRayLogArgsAttr()
5814 static void handlePatchableFunctionEntryAttr(Sema &S, Decl *D, in handlePatchableFunctionEntryAttr() argument
5817 if (!checkUInt32Argument(S, AL, AL.getArgAsExpr(0), Count, 0, true)) in handlePatchableFunctionEntryAttr()
5821 if (!checkUInt32Argument(S, AL, Arg, Offset, 1, true)) in handlePatchableFunctionEntryAttr()
5824 S.Diag(getAttrLoc(AL), diag::err_attribute_argument_out_of_range) in handlePatchableFunctionEntryAttr()
5829 D->addAttr(::new (S.Context) in handlePatchableFunctionEntryAttr()
5830 PatchableFunctionEntryAttr(S.Context, AL, Count, Offset)); in handlePatchableFunctionEntryAttr()
5889 static void handleArmBuiltinAliasAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleArmBuiltinAliasAttr() argument
5891 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) in handleArmBuiltinAliasAttr()
5900 bool IsAArch64 = S.Context.getTargetInfo().getTriple().isAArch64(); in handleArmBuiltinAliasAttr()
5901 if ((IsAArch64 && !ArmSveAliasValid(S.Context, BuiltinID, AliasName) && in handleArmBuiltinAliasAttr()
5902 !ArmSmeAliasValid(S.Context, BuiltinID, AliasName)) || in handleArmBuiltinAliasAttr()
5905 S.Diag(AL.getLoc(), diag::err_attribute_arm_builtin_alias); in handleArmBuiltinAliasAttr()
5909 D->addAttr(::new (S.Context) ArmBuiltinAliasAttr(S.Context, AL, Ident)); in handleArmBuiltinAliasAttr()
5917 static void handleBuiltinAliasAttr(Sema &S, Decl *D, in handleBuiltinAliasAttr() argument
5920 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) in handleBuiltinAliasAttr()
5929 bool IsAArch64 = S.Context.getTargetInfo().getTriple().isAArch64(); in handleBuiltinAliasAttr()
5930 bool IsARM = S.Context.getTargetInfo().getTriple().isARM(); in handleBuiltinAliasAttr()
5931 bool IsRISCV = S.Context.getTargetInfo().getTriple().isRISCV(); in handleBuiltinAliasAttr()
5932 bool IsHLSL = S.Context.getLangOpts().HLSL; in handleBuiltinAliasAttr()
5933 if ((IsAArch64 && !ArmSveAliasValid(S.Context, BuiltinID, AliasName)) || in handleBuiltinAliasAttr()
5938 S.Diag(AL.getLoc(), diag::err_attribute_builtin_alias) << AL; in handleBuiltinAliasAttr()
5942 D->addAttr(::new (S.Context) BuiltinAliasAttr(S.Context, AL, Ident)); in handleBuiltinAliasAttr()
5945 static void handlePreferredTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handlePreferredTypeAttr() argument
5947 S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1; in handlePreferredTypeAttr()
5952 QualType QT = S.GetTypeFromParser(AL.getTypeArg(), &ParmTSI); in handlePreferredTypeAttr()
5954 S.RequireCompleteType(ParmTSI->getTypeLoc().getBeginLoc(), QT, in handlePreferredTypeAttr()
5957 D->addAttr(::new (S.Context) PreferredTypeAttr(S.Context, AL, ParmTSI)); in handlePreferredTypeAttr()
6061 static void handleXReturnsXRetainedAttr(Sema &S, Decl *D, in handleXReturnsXRetainedAttr() argument
6068 } else if (S.getLangOpts().ObjCAutoRefCount && hasDeclarator(D) && in handleXReturnsXRetainedAttr()
6083 S.Diag(D->getBeginLoc(), diag::warn_ns_attribute_wrong_parameter_type) in handleXReturnsXRetainedAttr()
6106 S.Diag(D->getBeginLoc(), diag::warn_attribute_wrong_decl_type) in handleXReturnsXRetainedAttr()
6147 S.Diag(D->getBeginLoc(), diag::warn_ns_attribute_wrong_parameter_type) in handleXReturnsXRetainedAttr()
6160 S.Diag(D->getBeginLoc(), diag::warn_ns_attribute_wrong_return_type) in handleXReturnsXRetainedAttr()
6170 handleSimpleAttribute<NSReturnsAutoreleasedAttr>(S, D, AL); in handleXReturnsXRetainedAttr()
6173 handleSimpleAttribute<CFReturnsNotRetainedAttr>(S, D, AL); in handleXReturnsXRetainedAttr()
6176 handleSimpleAttribute<NSReturnsNotRetainedAttr>(S, D, AL); in handleXReturnsXRetainedAttr()
6179 handleSimpleAttribute<CFReturnsRetainedAttr>(S, D, AL); in handleXReturnsXRetainedAttr()
6182 handleSimpleAttribute<NSReturnsRetainedAttr>(S, D, AL); in handleXReturnsXRetainedAttr()
6185 handleSimpleAttribute<OSReturnsRetainedAttr>(S, D, AL); in handleXReturnsXRetainedAttr()
6188 handleSimpleAttribute<OSReturnsNotRetainedAttr>(S, D, AL); in handleXReturnsXRetainedAttr()
6193 static void handleObjCReturnsInnerPointerAttr(Sema &S, Decl *D, in handleObjCReturnsInnerPointerAttr() argument
6207 S.Diag(D->getBeginLoc(), diag::warn_ns_attribute_wrong_return_type) in handleObjCReturnsInnerPointerAttr()
6216 D->addAttr(::new (S.Context) ObjCReturnsInnerPointerAttr(S.Context, Attrs)); in handleObjCReturnsInnerPointerAttr()
6219 static void handleObjCRequiresSuperAttr(Sema &S, Decl *D, in handleObjCRequiresSuperAttr() argument
6225 S.Diag(D->getBeginLoc(), diag::warn_objc_requires_super_protocol) << Attrs in handleObjCRequiresSuperAttr()
6227 S.Diag(PDecl->getLocation(), diag::note_protocol_decl); in handleObjCRequiresSuperAttr()
6231 S.Diag(D->getBeginLoc(), diag::warn_objc_requires_super_protocol) << Attrs in handleObjCRequiresSuperAttr()
6236 D->addAttr(::new (S.Context) ObjCRequiresSuperAttr(S.Context, Attrs)); in handleObjCRequiresSuperAttr()
6239 static void handleNSErrorDomain(Sema &S, Decl *D, const ParsedAttr &Attr) { in handleNSErrorDomain() argument
6241 S.Diag(D->getBeginLoc(), diag::err_nserrordomain_invalid_decl) << 0; in handleNSErrorDomain()
6253 S.Diag(Loc, diag::err_nserrordomain_invalid_decl) << 0; in handleNSErrorDomain()
6258 LookupResult Result(S, DeclarationName(IdentLoc->Ident), SourceLocation(), in handleNSErrorDomain()
6260 if (!S.LookupName(Result, S.TUScope) || !Result.getAsSingle<VarDecl>()) { in handleNSErrorDomain()
6261 S.Diag(IdentLoc->Loc, diag::err_nserrordomain_invalid_decl) in handleNSErrorDomain()
6266 D->addAttr(::new (S.Context) in handleNSErrorDomain()
6267 NSErrorDomainAttr(S.Context, Attr, IdentLoc->Ident)); in handleNSErrorDomain()
6270 static void handleObjCBridgeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleObjCBridgeAttr() argument
6274 S.Diag(D->getBeginLoc(), diag::err_objc_attr_not_id) << AL << 0; in handleObjCBridgeAttr()
6281 S.Diag(AL.getLoc(), diag::err_objc_attr_typedef_not_id) << AL; in handleObjCBridgeAttr()
6288 S.Diag(AL.getLoc(), diag::err_objc_attr_typedef_not_void_pointer); in handleObjCBridgeAttr()
6293 D->addAttr(::new (S.Context) ObjCBridgeAttr(S.Context, AL, Parm->Ident)); in handleObjCBridgeAttr()
6296 static void handleObjCBridgeMutableAttr(Sema &S, Decl *D, in handleObjCBridgeMutableAttr() argument
6301 S.Diag(D->getBeginLoc(), diag::err_objc_attr_not_id) << AL << 0; in handleObjCBridgeMutableAttr()
6305 D->addAttr(::new (S.Context) in handleObjCBridgeMutableAttr()
6306 ObjCBridgeMutableAttr(S.Context, AL, Parm->Ident)); in handleObjCBridgeMutableAttr()
6309 static void handleObjCBridgeRelatedAttr(Sema &S, Decl *D, in handleObjCBridgeRelatedAttr() argument
6314 S.Diag(D->getBeginLoc(), diag::err_objc_attr_not_id) << AL << 0; in handleObjCBridgeRelatedAttr()
6321 D->addAttr(::new (S.Context) ObjCBridgeRelatedAttr( in handleObjCBridgeRelatedAttr()
6322 S.Context, AL, RelatedClass, ClassMethod, InstanceMethod)); in handleObjCBridgeRelatedAttr()
6325 static void handleObjCDesignatedInitializer(Sema &S, Decl *D, in handleObjCDesignatedInitializer() argument
6334 S.Diag(D->getLocation(), diag::err_designated_init_attr_non_init); in handleObjCDesignatedInitializer()
6348 D->addAttr(::new (S.Context) ObjCDesignatedInitializerAttr(S.Context, AL)); in handleObjCDesignatedInitializer()
6351 static void handleObjCRuntimeName(Sema &S, Decl *D, const ParsedAttr &AL) { in handleObjCRuntimeName() argument
6353 if (!S.checkStringLiteralArgumentAttr(AL, 0, MetaDataName)) in handleObjCRuntimeName()
6355 D->addAttr(::new (S.Context) in handleObjCRuntimeName()
6356 ObjCRuntimeNameAttr(S.Context, AL, MetaDataName)); in handleObjCRuntimeName()
6363 static void handleObjCBoxable(Sema &S, Decl *D, const ParsedAttr &AL) { in handleObjCBoxable() argument
6374 ::new (S.Context) ObjCBoxableAttr(S.Context, AL); in handleObjCBoxable()
6379 if (ASTMutationListener *L = S.getASTMutationListener()) in handleObjCBoxable()
6385 static void handleObjCOwnershipAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleObjCOwnershipAttr() argument
6389 S.Diag(D->getBeginLoc(), diag::err_attribute_wrong_decl_type) in handleObjCOwnershipAttr()
6394 static void handleObjCPreciseLifetimeAttr(Sema &S, Decl *D, in handleObjCPreciseLifetimeAttr() argument
6401 S.Diag(AL.getLoc(), diag::err_objc_precise_lifetime_bad_type) in handleObjCPreciseLifetimeAttr()
6425 S.Diag(AL.getLoc(), diag::warn_objc_precise_lifetime_meaningless) in handleObjCPreciseLifetimeAttr()
6430 D->addAttr(::new (S.Context) ObjCPreciseLifetimeAttr(S.Context, AL)); in handleObjCPreciseLifetimeAttr()
6433 static void handleSwiftAttrAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSwiftAttrAttr() argument
6437 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str)) in handleSwiftAttrAttr()
6440 D->addAttr(::new (S.Context) SwiftAttrAttr(S.Context, AL, Str)); in handleSwiftAttrAttr()
6443 static void handleSwiftBridge(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSwiftBridge() argument
6447 if (!S.checkStringLiteralArgumentAttr(AL, 0, BT)) in handleSwiftBridge()
6454 S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; in handleSwiftBridge()
6458 D->addAttr(::new (S.Context) SwiftBridgeAttr(S.Context, AL, BT)); in handleSwiftBridge()
6461 static bool isErrorParameter(Sema &S, QualType QT) { in isErrorParameter() argument
6471 if (ID->getIdentifier() == S.getNSErrorIdent()) in isErrorParameter()
6477 if (S.isCFError(RT->getDecl())) in isErrorParameter()
6483 static void handleSwiftError(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSwiftError() argument
6484 auto hasErrorParameter = [](Sema &S, Decl *D, const ParsedAttr &AL) -> bool { in handleSwiftError() argument
6486 if (isErrorParameter(S, getFunctionOrMethodParamType(D, I))) in handleSwiftError()
6490 S.Diag(AL.getLoc(), diag::err_attr_swift_error_no_error_parameter) in handleSwiftError()
6495 auto hasPointerResult = [](Sema &S, Decl *D, const ParsedAttr &AL) -> bool { in handleSwiftError() argument
6503 S.Diag(AL.getLoc(), diag::err_attr_swift_error_return_type) in handleSwiftError()
6509 auto hasIntegerResult = [](Sema &S, Decl *D, const ParsedAttr &AL) -> bool { in handleSwiftError() argument
6511 if (RT->isIntegralType(S.Context)) in handleSwiftError()
6514 S.Diag(AL.getLoc(), diag::err_attr_swift_error_return_type) in handleSwiftError()
6527 S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) in handleSwiftError()
6538 if (!hasErrorParameter(S, D, AL)) in handleSwiftError()
6543 if (!hasErrorParameter(S, D, AL) || !hasPointerResult(S, D, AL)) in handleSwiftError()
6549 if (!hasErrorParameter(S, D, AL) || !hasIntegerResult(S, D, AL)) in handleSwiftError()
6554 D->addAttr(::new (S.Context) SwiftErrorAttr(S.Context, AL, Convention)); in handleSwiftError()
6557 static void checkSwiftAsyncErrorBlock(Sema &S, Decl *D, in checkSwiftAsyncErrorBlock() argument
6562 S.Diag(AsyncAttr->getLocation(), in checkSwiftAsyncErrorBlock()
6586 S.Diag(ErrorAttr->getLocation(), in checkSwiftAsyncErrorBlock()
6591 if (!ErrorParam->isIntegralType(S.Context)) { in checkSwiftAsyncErrorBlock()
6596 S.Diag(ErrorAttr->getLocation(), diag::err_swift_async_error_non_integral) in checkSwiftAsyncErrorBlock()
6608 if (ID->getIdentifier() == S.getNSErrorIdent()) { in checkSwiftAsyncErrorBlock()
6617 if (S.isCFError(RT->getDecl())) { in checkSwiftAsyncErrorBlock()
6626 S.Diag(ErrorAttr->getLocation(), in checkSwiftAsyncErrorBlock()
6638 static void handleSwiftAsyncError(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSwiftAsyncError() argument
6643 S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) in handleSwiftAsyncError()
6652 if (!AL.checkExactlyNumArgs(S, 2)) in handleSwiftAsyncError()
6656 if (!checkUInt32Argument(S, AL, IdxExpr, ParamIdx)) in handleSwiftAsyncError()
6662 if (!AL.checkExactlyNumArgs(S, 1)) in handleSwiftAsyncError()
6669 ::new (S.Context) SwiftAsyncErrorAttr(S.Context, AL, ConvKind, ParamIdx); in handleSwiftAsyncError()
6673 checkSwiftAsyncErrorBlock(S, D, ErrorAttr, AsyncAttr); in handleSwiftAsyncError()
6685 validateSwiftFunctionName(Sema &S, const ParsedAttr &AL, SourceLocation Loc, in validateSwiftFunctionName() argument
6702 S.Diag(Loc, diag::warn_attr_swift_name_function) << AL; in validateSwiftFunctionName()
6718 S.Diag(Loc, diag::warn_attr_swift_name_invalid_identifier) in validateSwiftFunctionName()
6726 S.Diag(Loc, diag::warn_attr_swift_name_invalid_identifier) in validateSwiftFunctionName()
6734 S.Diag(Loc, diag::warn_attr_swift_name_subscript_invalid_parameter) in validateSwiftFunctionName()
6740 S.Diag(Loc, diag::warn_attr_swift_name_missing_parameters) << AL; in validateSwiftFunctionName()
6750 S.Diag(Loc, diag::warn_attr_swift_name_subscript_invalid_parameter) in validateSwiftFunctionName()
6756 S.Diag(Loc, diag::warn_attr_swift_name_setter_parameters) << AL; in validateSwiftFunctionName()
6764 S.Diag(Loc, diag::warn_attr_swift_name_function) << AL; in validateSwiftFunctionName()
6776 S.Diag(Loc, diag::warn_attr_swift_name_invalid_identifier) in validateSwiftFunctionName()
6786 S.Diag(Loc, diag::warn_attr_swift_name_multiple_selfs) << AL; in validateSwiftFunctionName()
6807 S.Diag(Loc, diag::warn_attr_swift_name_subscript_invalid_parameter) in validateSwiftFunctionName()
6831 S.Diag(Loc, ParamDiag) << AL; in validateSwiftFunctionName()
6839 S.Diag(Loc, diag::warn_attr_swift_name_subscript_setter_no_newValue) in validateSwiftFunctionName()
6844 S.Diag(Loc, diag::warn_attr_swift_name_subscript_setter_multiple_newValues) in validateSwiftFunctionName()
6851 S.Diag(Loc, diag::warn_attr_swift_name_subscript_getter_newValue) in validateSwiftFunctionName()
6859 S.Diag(Loc, ParamDiag) << AL; in validateSwiftFunctionName()
6962 static void handleSwiftName(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSwiftName() argument
6965 if (!S.checkStringLiteralArgumentAttr(AL, 0, Name, &Loc)) in handleSwiftName()
6968 if (!S.DiagnoseSwiftName(D, Name, Loc, AL, /*IsAsync=*/false)) in handleSwiftName()
6971 D->addAttr(::new (S.Context) SwiftNameAttr(S.Context, AL, Name)); in handleSwiftName()
6974 static void handleSwiftAsyncName(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSwiftAsyncName() argument
6977 if (!S.checkStringLiteralArgumentAttr(AL, 0, Name, &Loc)) in handleSwiftAsyncName()
6980 if (!S.DiagnoseSwiftName(D, Name, Loc, AL, /*IsAsync=*/true)) in handleSwiftAsyncName()
6983 D->addAttr(::new (S.Context) SwiftAsyncNameAttr(S.Context, AL, Name)); in handleSwiftAsyncName()
6986 static void handleSwiftNewType(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSwiftNewType() argument
6988 if (!AL.checkExactlyNumArgs(S, 1)) in handleSwiftNewType()
6992 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleSwiftNewType()
7000 S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) << AL << II; in handleSwiftNewType()
7005 S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type_str) in handleSwiftNewType()
7010 D->addAttr(::new (S.Context) SwiftNewTypeAttr(S.Context, AL, Kind)); in handleSwiftNewType()
7013 static void handleSwiftAsyncAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSwiftAsyncAttr() argument
7015 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) in handleSwiftAsyncAttr()
7023 S.Diag(AL.getLoc(), diag::err_swift_async_no_access) << AL << II; in handleSwiftAsyncAttr()
7030 if (!AL.checkExactlyNumArgs(S, 1)) in handleSwiftAsyncAttr()
7034 if (!AL.checkExactlyNumArgs(S, 2)) in handleSwiftAsyncAttr()
7038 if (!checkFunctionOrMethodParameterIndex(S, D, AL, 2, HandlerIdx, Idx)) in handleSwiftAsyncAttr()
7045 S.Diag(CompletionBlock->getLocation(), in handleSwiftAsyncAttr()
7053 S.Diag(CompletionBlock->getLocation(), in handleSwiftAsyncAttr()
7061 ::new (S.Context) SwiftAsyncAttr(S.Context, AL, Kind, Idx); in handleSwiftAsyncAttr()
7065 checkSwiftAsyncErrorBlock(S, D, ErrorAttr, AsyncAttr); in handleSwiftAsyncAttr()
7087 static void handleUuidAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleUuidAttr() argument
7088 if (!S.LangOpts.CPlusPlus) { in handleUuidAttr()
7089 S.Diag(AL.getLoc(), diag::err_attribute_not_supported_in_lang) in handleUuidAttr()
7096 if (!S.checkStringLiteralArgumentAttr(AL, 0, OrigStrRef, &LiteralLoc)) in handleUuidAttr()
7107 S.Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid); in handleUuidAttr()
7114 S.Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid); in handleUuidAttr()
7118 S.Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid); in handleUuidAttr()
7131 MSGuidDecl *Guid = S.Context.getMSGuidDecl(Parsed); in handleUuidAttr()
7140 S.Diag(AL.getLoc(), diag::warn_atl_uuid_deprecated); in handleUuidAttr()
7142 UuidAttr *UA = S.mergeUuidAttr(D, AL, OrigStrRef, Guid); in handleUuidAttr()
7147 static void handleHLSLNumThreadsAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleHLSLNumThreadsAttr() argument
7149 S.Context.getTargetInfo().getTriple().getOSVersion(); in handleHLSLNumThreadsAttr()
7161 if (!checkUInt32Argument(S, AL, AL.getArgAsExpr(0), X)) in handleHLSLNumThreadsAttr()
7164 S.Diag(AL.getArgAsExpr(0)->getExprLoc(), in handleHLSLNumThreadsAttr()
7169 if (!checkUInt32Argument(S, AL, AL.getArgAsExpr(1), Y)) in handleHLSLNumThreadsAttr()
7172 S.Diag(AL.getArgAsExpr(1)->getExprLoc(), in handleHLSLNumThreadsAttr()
7177 if (!checkUInt32Argument(S, AL, AL.getArgAsExpr(2), Z)) in handleHLSLNumThreadsAttr()
7180 S.Diag(AL.getArgAsExpr(2)->getExprLoc(), in handleHLSLNumThreadsAttr()
7186 S.Diag(AL.getLoc(), diag::err_hlsl_numthreads_invalid) << ThreadMax; in handleHLSLNumThreadsAttr()
7190 HLSLNumThreadsAttr *NewAttr = S.mergeHLSLNumThreadsAttr(D, AL, X, Y, Z); in handleHLSLNumThreadsAttr()
7216 static void handleHLSLSV_DispatchThreadIDAttr(Sema &S, Decl *D, in handleHLSLSV_DispatchThreadIDAttr() argument
7221 S.Diag(AL.getLoc(), diag::err_hlsl_attr_invalid_ast_node) in handleHLSLSV_DispatchThreadIDAttr()
7228 S.Diag(AL.getLoc(), diag::err_hlsl_attr_invalid_type) in handleHLSLSV_DispatchThreadIDAttr()
7233 D->addAttr(::new (S.Context) HLSLSV_DispatchThreadIDAttr(S.Context, AL)); in handleHLSLSV_DispatchThreadIDAttr()
7236 static void handleHLSLShaderAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleHLSLShaderAttr() argument
7239 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &ArgLoc)) in handleHLSLShaderAttr()
7244 S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) in handleHLSLShaderAttr()
7251 HLSLShaderAttr *NewAttr = S.mergeHLSLShaderAttr(D, AL, ShaderType); in handleHLSLShaderAttr()
7269 static void handleHLSLResourceBindingAttr(Sema &S, Decl *D, in handleHLSLResourceBindingAttr() argument
7275 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleHLSLResourceBindingAttr()
7288 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleHLSLResourceBindingAttr()
7309 S.Diag(ArgLoc, diag::err_hlsl_unsupported_register_type) in handleHLSLResourceBindingAttr()
7317 S.Diag(ArgLoc, diag::err_hlsl_unsupported_register_number); in handleHLSLResourceBindingAttr()
7323 S.Diag(SpaceArgLoc, diag::err_hlsl_expected_space) << Space; in handleHLSLResourceBindingAttr()
7329 S.Diag(SpaceArgLoc, diag::err_hlsl_expected_space) << Space; in handleHLSLResourceBindingAttr()
7336 HLSLResourceBindingAttr::Create(S.getASTContext(), Slot, Space, AL); in handleHLSLResourceBindingAttr()
7341 static void handleHLSLParamModifierAttr(Sema &S, Decl *D, in handleHLSLParamModifierAttr() argument
7343 HLSLParamModifierAttr *NewAttr = S.mergeHLSLParamModifierAttr( in handleHLSLParamModifierAttr()
7371 static void handleMSInheritanceAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleMSInheritanceAttr() argument
7372 if (!S.LangOpts.CPlusPlus) { in handleMSInheritanceAttr()
7373 S.Diag(AL.getLoc(), diag::err_attribute_not_supported_in_lang) in handleMSInheritanceAttr()
7377 MSInheritanceAttr *IA = S.mergeMSInheritanceAttr( in handleMSInheritanceAttr()
7381 S.Consumer.AssignInheritanceModel(cast<CXXRecordDecl>(D)); in handleMSInheritanceAttr()
7385 static void handleDeclspecThreadAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleDeclspecThreadAttr() argument
7387 if (!S.Context.getTargetInfo().isTLSSupported()) { in handleDeclspecThreadAttr()
7388 S.Diag(AL.getLoc(), diag::err_thread_unsupported); in handleDeclspecThreadAttr()
7392 S.Diag(AL.getLoc(), diag::err_declspec_thread_on_thread_variable); in handleDeclspecThreadAttr()
7396 S.Diag(AL.getLoc(), diag::err_thread_non_global) << "__declspec(thread)"; in handleDeclspecThreadAttr()
7399 D->addAttr(::new (S.Context) ThreadAttr(S.Context, AL)); in handleDeclspecThreadAttr()
7402 static void handleMSConstexprAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleMSConstexprAttr() argument
7403 if (!S.getLangOpts().isCompatibleWithMSVC(LangOptions::MSVC2022_3)) { in handleMSConstexprAttr()
7404 S.Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored) in handleMSConstexprAttr()
7410 S.Diag(AL.getLoc(), diag::err_ms_constexpr_cannot_be_applied) in handleMSConstexprAttr()
7415 if (!S.getLangOpts().CPlusPlus20 && MD->isVirtual()) { in handleMSConstexprAttr()
7416 S.Diag(AL.getLoc(), diag::err_ms_constexpr_cannot_be_applied) in handleMSConstexprAttr()
7421 D->addAttr(::new (S.Context) MSConstexprAttr(S.Context, AL)); in handleMSConstexprAttr()
7424 static void handleAbiTagAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAbiTagAttr() argument
7428 if (!S.checkStringLiteralArgumentAttr(AL, I, Tag)) in handleAbiTagAttr()
7435 S.Diag(AL.getLoc(), diag::warn_attr_abi_tag_namespace) << 0; in handleAbiTagAttr()
7439 S.Diag(AL.getLoc(), diag::warn_attr_abi_tag_namespace) << 1; in handleAbiTagAttr()
7444 } else if (!AL.checkAtLeastNumArgs(S, 1)) in handleAbiTagAttr()
7451 D->addAttr(::new (S.Context) in handleAbiTagAttr()
7452 AbiTagAttr(S.Context, AL, Tags.data(), Tags.size())); in handleAbiTagAttr()
7455 static void handleARMInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleARMInterruptAttr() argument
7458 S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) << AL << 1; in handleARMInterruptAttr()
7467 else if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &ArgLoc)) in handleARMInterruptAttr()
7472 S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) << AL << Str in handleARMInterruptAttr()
7477 D->addAttr(::new (S.Context) ARMInterruptAttr(S.Context, AL, Kind)); in handleARMInterruptAttr()
7480 static void handleMSP430InterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleMSP430InterruptAttr() argument
7484 S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type) in handleMSP430InterruptAttr()
7490 S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) in handleMSP430InterruptAttr()
7496 S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) in handleMSP430InterruptAttr()
7502 if (!AL.checkExactlyNumArgs(S, 1)) in handleMSP430InterruptAttr()
7506 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleMSP430InterruptAttr()
7513 if (!(NumParams = NumParamsExpr->getIntegerConstantExpr(S.Context))) { in handleMSP430InterruptAttr()
7514 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleMSP430InterruptAttr()
7522 S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds) in handleMSP430InterruptAttr()
7528 D->addAttr(::new (S.Context) MSP430InterruptAttr(S.Context, AL, Num)); in handleMSP430InterruptAttr()
7529 D->addAttr(UsedAttr::CreateImplicit(S.Context)); in handleMSP430InterruptAttr()
7532 static void handleMipsInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleMipsInterruptAttr() argument
7535 S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) << AL << 1; in handleMipsInterruptAttr()
7544 else if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &ArgLoc)) in handleMipsInterruptAttr()
7557 S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type) in handleMipsInterruptAttr()
7563 S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) in handleMipsInterruptAttr()
7569 S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) in handleMipsInterruptAttr()
7576 if (checkAttrMutualExclusion<Mips16Attr>(S, D, AL)) in handleMipsInterruptAttr()
7581 S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) in handleMipsInterruptAttr()
7586 D->addAttr(::new (S.Context) MipsInterruptAttr(S.Context, AL, Kind)); in handleMipsInterruptAttr()
7589 static void handleM68kInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleM68kInterruptAttr() argument
7590 if (!AL.checkExactlyNumArgs(S, 1)) in handleM68kInterruptAttr()
7594 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleM68kInterruptAttr()
7602 auto MaybeNumParams = NumParamsExpr->getIntegerConstantExpr(S.Context); in handleM68kInterruptAttr()
7604 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleM68kInterruptAttr()
7612 S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds) in handleM68kInterruptAttr()
7618 D->addAttr(::new (S.Context) M68kInterruptAttr(S.Context, AL, Num)); in handleM68kInterruptAttr()
7619 D->addAttr(UsedAttr::CreateImplicit(S.Context)); in handleM68kInterruptAttr()
7622 static void handleAnyX86InterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAnyX86InterruptAttr() argument
7632 S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type) in handleAnyX86InterruptAttr()
7639 S.Diag(getFunctionOrMethodResultSourceRange(D).getBegin(), in handleAnyX86InterruptAttr()
7641 << (S.Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86 in handleAnyX86InterruptAttr()
7650 S.Diag(D->getBeginLoc(), diag::err_anyx86_interrupt_attribute) in handleAnyX86InterruptAttr()
7651 << (S.Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86 in handleAnyX86InterruptAttr()
7659 S.Diag(getFunctionOrMethodParamRange(D, 0).getBegin(), in handleAnyX86InterruptAttr()
7661 << (S.Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86 in handleAnyX86InterruptAttr()
7669 S.Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86_64 in handleAnyX86InterruptAttr()
7674 S.Context.getTypeSize(getFunctionOrMethodParamType(D, 1)) != TypeSize)) { in handleAnyX86InterruptAttr()
7675 S.Diag(getFunctionOrMethodParamRange(D, 1).getBegin(), in handleAnyX86InterruptAttr()
7677 << (S.Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86 in handleAnyX86InterruptAttr()
7680 << 3 << S.Context.getIntTypeForBitwidth(TypeSize, /*Signed=*/false); in handleAnyX86InterruptAttr()
7683 D->addAttr(::new (S.Context) AnyX86InterruptAttr(S.Context, AL)); in handleAnyX86InterruptAttr()
7684 D->addAttr(UsedAttr::CreateImplicit(S.Context)); in handleAnyX86InterruptAttr()
7687 static void handleAVRInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAVRInterruptAttr() argument
7689 S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type) in handleAVRInterruptAttr()
7694 if (!AL.checkExactlyNumArgs(S, 0)) in handleAVRInterruptAttr()
7697 handleSimpleAttribute<AVRInterruptAttr>(S, D, AL); in handleAVRInterruptAttr()
7700 static void handleAVRSignalAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAVRSignalAttr() argument
7702 S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type) in handleAVRSignalAttr()
7707 if (!AL.checkExactlyNumArgs(S, 0)) in handleAVRSignalAttr()
7710 handleSimpleAttribute<AVRSignalAttr>(S, D, AL); in handleAVRSignalAttr()
7713 static void handleBPFPreserveAIRecord(Sema &S, RecordDecl *RD) { in handleBPFPreserveAIRecord() argument
7719 D->addAttr(BPFPreserveAccessIndexAttr::CreateImplicit(S.Context)); in handleBPFPreserveAIRecord()
7721 handleBPFPreserveAIRecord(S, Rec); in handleBPFPreserveAIRecord()
7725 static void handleBPFPreserveAccessIndexAttr(Sema &S, Decl *D, in handleBPFPreserveAccessIndexAttr() argument
7728 handleBPFPreserveAIRecord(S, Rec); in handleBPFPreserveAccessIndexAttr()
7729 Rec->addAttr(::new (S.Context) BPFPreserveAccessIndexAttr(S.Context, AL)); in handleBPFPreserveAccessIndexAttr()
7740 static void handleBTFDeclTagAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleBTFDeclTagAttr() argument
7742 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str)) in handleBTFDeclTagAttr()
7747 D->addAttr(::new (S.Context) BTFDeclTagAttr(S.Context, AL, Str)); in handleBTFDeclTagAttr()
7756 static void handleWebAssemblyExportNameAttr(Sema &S, Decl *D, in handleWebAssemblyExportNameAttr() argument
7759 S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type) in handleWebAssemblyExportNameAttr()
7766 S.Diag(D->getLocation(), diag::err_alias_is_definition) << FD << 0; in handleWebAssemblyExportNameAttr()
7772 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &ArgLoc)) in handleWebAssemblyExportNameAttr()
7775 D->addAttr(::new (S.Context) WebAssemblyExportNameAttr(S.Context, AL, Str)); in handleWebAssemblyExportNameAttr()
7776 D->addAttr(UsedAttr::CreateImplicit(S.Context)); in handleWebAssemblyExportNameAttr()
7820 handleWebAssemblyImportModuleAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleWebAssemblyImportModuleAttr() argument
7825 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &ArgLoc)) in handleWebAssemblyImportModuleAttr()
7828 S.Diag(AL.getLoc(), diag::warn_import_on_definition) << 0; in handleWebAssemblyImportModuleAttr()
7832 FD->addAttr(::new (S.Context) in handleWebAssemblyImportModuleAttr()
7833 WebAssemblyImportModuleAttr(S.Context, AL, Str)); in handleWebAssemblyImportModuleAttr()
7837 handleWebAssemblyImportNameAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleWebAssemblyImportNameAttr() argument
7842 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &ArgLoc)) in handleWebAssemblyImportNameAttr()
7845 S.Diag(AL.getLoc(), diag::warn_import_on_definition) << 1; in handleWebAssemblyImportNameAttr()
7849 FD->addAttr(::new (S.Context) WebAssemblyImportNameAttr(S.Context, AL, Str)); in handleWebAssemblyImportNameAttr()
7852 static void handleRISCVInterruptAttr(Sema &S, Decl *D, in handleRISCVInterruptAttr() argument
7856 S.Diag(AL.getRange().getBegin(), in handleRISCVInterruptAttr()
7858 S.Diag(A->getLocation(), diag::note_riscv_repeated_interrupt_attribute); in handleRISCVInterruptAttr()
7863 if (!AL.checkAtMostNumArgs(S, 1)) in handleRISCVInterruptAttr()
7872 else if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &ArgLoc)) in handleRISCVInterruptAttr()
7883 S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type) in handleRISCVInterruptAttr()
7889 S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) in handleRISCVInterruptAttr()
7895 S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) in handleRISCVInterruptAttr()
7902 S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) << AL << Str in handleRISCVInterruptAttr()
7907 D->addAttr(::new (S.Context) RISCVInterruptAttr(S.Context, AL, Kind)); in handleRISCVInterruptAttr()
7910 static void handleInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleInterruptAttr() argument
7912 switch (S.Context.getTargetInfo().getTriple().getArch()) { in handleInterruptAttr()
7914 handleMSP430InterruptAttr(S, D, AL); in handleInterruptAttr()
7918 handleMipsInterruptAttr(S, D, AL); in handleInterruptAttr()
7921 handleM68kInterruptAttr(S, D, AL); in handleInterruptAttr()
7925 handleAnyX86InterruptAttr(S, D, AL); in handleInterruptAttr()
7928 handleAVRInterruptAttr(S, D, AL); in handleInterruptAttr()
7932 handleRISCVInterruptAttr(S, D, AL); in handleInterruptAttr()
7935 handleARMInterruptAttr(S, D, AL); in handleInterruptAttr()
7941 checkAMDGPUFlatWorkGroupSizeArguments(Sema &S, Expr *MinExpr, Expr *MaxExpr, in checkAMDGPUFlatWorkGroupSizeArguments() argument
7949 if (!checkUInt32Argument(S, Attr, MinExpr, Min, 0)) in checkAMDGPUFlatWorkGroupSizeArguments()
7953 if (!checkUInt32Argument(S, Attr, MaxExpr, Max, 1)) in checkAMDGPUFlatWorkGroupSizeArguments()
7957 S.Diag(Attr.getLocation(), diag::err_attribute_argument_invalid) in checkAMDGPUFlatWorkGroupSizeArguments()
7962 S.Diag(Attr.getLocation(), diag::err_attribute_argument_invalid) in checkAMDGPUFlatWorkGroupSizeArguments()
7988 static void handleAMDGPUFlatWorkGroupSizeAttr(Sema &S, Decl *D, in handleAMDGPUFlatWorkGroupSizeAttr() argument
7993 S.addAMDGPUFlatWorkGroupSizeAttr(D, AL, MinExpr, MaxExpr); in handleAMDGPUFlatWorkGroupSizeAttr()
7996 static bool checkAMDGPUWavesPerEUArguments(Sema &S, Expr *MinExpr, in checkAMDGPUWavesPerEUArguments() argument
7999 if (S.DiagnoseUnexpandedParameterPack(MinExpr) || in checkAMDGPUWavesPerEUArguments()
8000 (MaxExpr && S.DiagnoseUnexpandedParameterPack(MaxExpr))) in checkAMDGPUWavesPerEUArguments()
8009 if (!checkUInt32Argument(S, Attr, MinExpr, Min, 0)) in checkAMDGPUWavesPerEUArguments()
8013 if (MaxExpr && !checkUInt32Argument(S, Attr, MaxExpr, Max, 1)) in checkAMDGPUWavesPerEUArguments()
8017 S.Diag(Attr.getLocation(), diag::err_attribute_argument_invalid) in checkAMDGPUWavesPerEUArguments()
8022 S.Diag(Attr.getLocation(), diag::err_attribute_argument_invalid) in checkAMDGPUWavesPerEUArguments()
8047 static void handleAMDGPUWavesPerEUAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAMDGPUWavesPerEUAttr() argument
8048 if (!AL.checkAtLeastNumArgs(S, 1) || !AL.checkAtMostNumArgs(S, 2)) in handleAMDGPUWavesPerEUAttr()
8054 S.addAMDGPUWavesPerEUAttr(D, AL, MinExpr, MaxExpr); in handleAMDGPUWavesPerEUAttr()
8057 static void handleAMDGPUNumSGPRAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAMDGPUNumSGPRAttr() argument
8060 if (!checkUInt32Argument(S, AL, NumSGPRExpr, NumSGPR)) in handleAMDGPUNumSGPRAttr()
8063 D->addAttr(::new (S.Context) AMDGPUNumSGPRAttr(S.Context, AL, NumSGPR)); in handleAMDGPUNumSGPRAttr()
8066 static void handleAMDGPUNumVGPRAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAMDGPUNumVGPRAttr() argument
8069 if (!checkUInt32Argument(S, AL, NumVGPRExpr, NumVGPR)) in handleAMDGPUNumVGPRAttr()
8072 D->addAttr(::new (S.Context) AMDGPUNumVGPRAttr(S.Context, AL, NumVGPR)); in handleAMDGPUNumVGPRAttr()
8075 static void handleX86ForceAlignArgPointerAttr(Sema &S, Decl *D, in handleX86ForceAlignArgPointerAttr() argument
8090 S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type) in handleX86ForceAlignArgPointerAttr()
8095 D->addAttr(::new (S.Context) X86ForceAlignArgPointerAttr(S.Context, AL)); in handleX86ForceAlignArgPointerAttr()
8098 static void handleLayoutVersion(Sema &S, Decl *D, const ParsedAttr &AL) { in handleLayoutVersion() argument
8101 if (!checkUInt32Argument(S, AL, AL.getArgAsExpr(0), Version)) in handleLayoutVersion()
8106 S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds) in handleLayoutVersion()
8116 D->addAttr(::new (S.Context) LayoutVersionAttr(S.Context, AL, Version)); in handleLayoutVersion()
8145 static void handleDLLAttr(Sema &S, Decl *D, const ParsedAttr &A) { in handleDLLAttr() argument
8147 (S.Context.getTargetInfo().shouldDLLImportComdatSymbols())) { in handleDLLAttr()
8148 S.Diag(A.getRange().getBegin(), diag::warn_attribute_ignored) << A; in handleDLLAttr()
8154 !(S.Context.getTargetInfo().shouldDLLImportComdatSymbols())) { in handleDLLAttr()
8156 S.Diag(A.getRange().getBegin(), diag::warn_attribute_ignored_on_inline) in handleDLLAttr()
8163 if ((S.Context.getTargetInfo().shouldDLLImportComdatSymbols()) && in handleDLLAttr()
8165 S.Diag(A.getRange().getBegin(), diag::err_attribute_dll_lambda) << A; in handleDLLAttr()
8171 ? (Attr *)S.mergeDLLExportAttr(D, A) in handleDLLAttr()
8172 : (Attr *)S.mergeDLLImportAttr(D, A); in handleDLLAttr()
8212 static void handleCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCapabilityAttr() argument
8224 !S.checkStringLiteralArgumentAttr(AL, 0, N, &LiteralLoc)) in handleCapabilityAttr()
8227 D->addAttr(::new (S.Context) CapabilityAttr(S.Context, AL, N)); in handleCapabilityAttr()
8230 static void handleAssertCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAssertCapabilityAttr() argument
8232 if (!checkLockFunAttrCommon(S, D, AL, Args)) in handleAssertCapabilityAttr()
8235 D->addAttr(::new (S.Context) in handleAssertCapabilityAttr()
8236 AssertCapabilityAttr(S.Context, AL, Args.data(), Args.size())); in handleAssertCapabilityAttr()
8239 static void handleAcquireCapabilityAttr(Sema &S, Decl *D, in handleAcquireCapabilityAttr() argument
8242 if (!checkLockFunAttrCommon(S, D, AL, Args)) in handleAcquireCapabilityAttr()
8245 D->addAttr(::new (S.Context) AcquireCapabilityAttr(S.Context, AL, Args.data(), in handleAcquireCapabilityAttr()
8249 static void handleTryAcquireCapabilityAttr(Sema &S, Decl *D, in handleTryAcquireCapabilityAttr() argument
8252 if (!checkTryLockFunAttrCommon(S, D, AL, Args)) in handleTryAcquireCapabilityAttr()
8255 D->addAttr(::new (S.Context) TryAcquireCapabilityAttr( in handleTryAcquireCapabilityAttr()
8256 S.Context, AL, AL.getArgAsExpr(0), Args.data(), Args.size())); in handleTryAcquireCapabilityAttr()
8259 static void handleReleaseCapabilityAttr(Sema &S, Decl *D, in handleReleaseCapabilityAttr() argument
8263 checkAttrArgsAreCapabilityObjs(S, D, AL, Args, 0, true); in handleReleaseCapabilityAttr()
8265 D->addAttr(::new (S.Context) ReleaseCapabilityAttr(S.Context, AL, Args.data(), in handleReleaseCapabilityAttr()
8269 static void handleRequiresCapabilityAttr(Sema &S, Decl *D, in handleRequiresCapabilityAttr() argument
8271 if (!AL.checkAtLeastNumArgs(S, 1)) in handleRequiresCapabilityAttr()
8276 checkAttrArgsAreCapabilityObjs(S, D, AL, Args); in handleRequiresCapabilityAttr()
8280 RequiresCapabilityAttr *RCA = ::new (S.Context) in handleRequiresCapabilityAttr()
8281 RequiresCapabilityAttr(S.Context, AL, Args.data(), Args.size()); in handleRequiresCapabilityAttr()
8286 static void handleDeprecatedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleDeprecatedAttr() argument
8289 S.Diag(AL.getLoc(), diag::warn_deprecated_anonymous_namespace); in handleDeprecatedAttr()
8297 S.Diag(AL.getRange().getBegin(), diag::warn_deprecated_ignored_on_using) in handleDeprecatedAttr()
8305 !S.checkStringLiteralArgumentAttr(AL, 0, Str)) in handleDeprecatedAttr()
8310 AL.checkAtMostNumArgs(S, 1); in handleDeprecatedAttr()
8312 !S.checkStringLiteralArgumentAttr(AL, 1, Replacement)) in handleDeprecatedAttr()
8315 if (!S.getLangOpts().CPlusPlus14 && AL.isCXX11Attribute() && !AL.isGNUScope()) in handleDeprecatedAttr()
8316 S.Diag(AL.getLoc(), diag::ext_cxx14_attr) << AL; in handleDeprecatedAttr()
8318 D->addAttr(::new (S.Context) DeprecatedAttr(S.Context, AL, Str, Replacement)); in handleDeprecatedAttr()
8322 if (const auto *S = dyn_cast<VarDecl>(D)) in isGlobalVar() local
8323 return S->hasGlobalStorage(); in isGlobalVar()
8332 static void handleNoSanitizeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNoSanitizeAttr() argument
8333 if (!AL.checkAtLeastNumArgs(S, 1)) in handleNoSanitizeAttr()
8342 if (!S.checkStringLiteralArgumentAttr(AL, I, SanitizerName, &LiteralLoc)) in handleNoSanitizeAttr()
8348 S.Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << SanitizerName; in handleNoSanitizeAttr()
8350 S.Diag(D->getLocation(), diag::warn_attribute_type_not_supported_global) in handleNoSanitizeAttr()
8355 D->addAttr(::new (S.Context) NoSanitizeAttr(S.Context, AL, Sanitizers.data(), in handleNoSanitizeAttr()
8359 static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D, in handleNoSanitizeSpecificAttr() argument
8369 S.Diag(D->getLocation(), diag::err_attribute_wrong_decl_type) in handleNoSanitizeSpecificAttr()
8386 D->addAttr(::new (S.Context) in handleNoSanitizeSpecificAttr()
8387 NoSanitizeAttr(S.Context, Info, &SanitizerName, 1)); in handleNoSanitizeSpecificAttr()
8390 static void handleInternalLinkageAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleInternalLinkageAttr() argument
8391 if (InternalLinkageAttr *Internal = S.mergeInternalLinkageAttr(D, AL)) in handleInternalLinkageAttr()
8395 static void handleOpenCLNoSVMAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleOpenCLNoSVMAttr() argument
8396 if (S.LangOpts.getOpenCLCompatibleVersion() < 200) in handleOpenCLNoSVMAttr()
8397 S.Diag(AL.getLoc(), diag::err_attribute_requires_opencl_version) in handleOpenCLNoSVMAttr()
8400 S.Diag(AL.getLoc(), diag::warn_opencl_attr_deprecated_ignored) in handleOpenCLNoSVMAttr()
8401 << AL << S.LangOpts.getOpenCLVersionString(); in handleOpenCLNoSVMAttr()
8404 static void handleOpenCLAccessAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleOpenCLAccessAttr() argument
8412 S.Diag(AL.getLoc(), diag::warn_duplicate_declspec) in handleOpenCLAccessAttr()
8415 S.Diag(AL.getLoc(), diag::err_opencl_multiple_access_qualifiers) in handleOpenCLAccessAttr()
8435 (S.getLangOpts().getOpenCLCompatibleVersion() < 200) || in handleOpenCLAccessAttr()
8436 (S.getLangOpts().getOpenCLCompatibleVersion() == 300 && in handleOpenCLAccessAttr()
8437 !S.getOpenCLOptions().isSupported("__opencl_c_read_write_images", in handleOpenCLAccessAttr()
8438 S.getLangOpts())); in handleOpenCLAccessAttr()
8440 S.Diag(AL.getLoc(), diag::err_opencl_invalid_read_write) in handleOpenCLAccessAttr()
8448 D->addAttr(::new (S.Context) OpenCLAccessAttr(S.Context, AL)); in handleOpenCLAccessAttr()
8451 static void handleZeroCallUsedRegsAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleZeroCallUsedRegsAttr() argument
8455 if (!S.checkStringLiteralArgumentAttr(AL, 0, KindStr, &LiteralLoc)) in handleZeroCallUsedRegsAttr()
8460 S.Diag(LiteralLoc, diag::warn_attribute_type_not_supported) in handleZeroCallUsedRegsAttr()
8466 D->addAttr(ZeroCallUsedRegsAttr::Create(S.Context, Kind, AL)); in handleZeroCallUsedRegsAttr()
8469 static void handleCountedByAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCountedByAttr() argument
8471 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleCountedByAttr()
8478 ::new (S.Context) CountedByAttr(S.Context, AL, IL->Ident); in handleCountedByAttr()
8500 bool Sema::CheckCountedByAttr(Scope *S, const FieldDecl *FD) { in CheckCountedByAttr() argument
8533 LookupName(MemResult, S); in CheckCountedByAttr()
8550 LookupName(OrdResult, S); in CheckCountedByAttr()
8569 return DiagnoseEmptyLookup(S, SS, MemResult, Filter, nullptr, std::nullopt, in CheckCountedByAttr()
8598 static void handleFunctionReturnThunksAttr(Sema &S, Decl *D, in handleFunctionReturnThunksAttr() argument
8602 if (!S.checkStringLiteralArgumentAttr(AL, 0, KindStr, &LiteralLoc)) in handleFunctionReturnThunksAttr()
8607 S.Diag(LiteralLoc, diag::warn_attribute_type_not_supported) in handleFunctionReturnThunksAttr()
8615 D->addAttr(FunctionReturnThunksAttr::Create(S.Context, Kind, AL)); in handleFunctionReturnThunksAttr()
8618 static void handleAvailableOnlyInDefaultEvalMethod(Sema &S, Decl *D, in handleAvailableOnlyInDefaultEvalMethod() argument
8621 handleSimpleAttribute<AvailableOnlyInDefaultEvalMethodAttr>(S, D, AL); in handleAvailableOnlyInDefaultEvalMethod()
8624 static void handleNoMergeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNoMergeAttr() argument
8627 S.Diag(AL.getLoc(), diag::warn_attribute_ignored_non_function_pointer) in handleNoMergeAttr()
8631 D->addAttr(NoMergeAttr::Create(S.Context, AL)); in handleNoMergeAttr()
8634 static void handleNoUniqueAddressAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNoUniqueAddressAttr() argument
8635 D->addAttr(NoUniqueAddressAttr::Create(S.Context, AL)); in handleNoUniqueAddressAttr()
8638 static void handleSYCLKernelAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSYCLKernelAttr() argument
8647 S.Diag(FT->getLocation(), diag::warn_sycl_kernel_num_of_template_params); in handleSYCLKernelAttr()
8655 S.Diag(FT->getLocation(), in handleSYCLKernelAttr()
8663 S.Diag(FT->getLocation(), diag::warn_sycl_kernel_num_of_function_params); in handleSYCLKernelAttr()
8670 S.Diag(FT->getLocation(), diag::warn_sycl_kernel_return_type); in handleSYCLKernelAttr()
8674 handleSimpleAttribute<SYCLKernelAttr>(S, D, AL); in handleSYCLKernelAttr()
8677 static void handleDestroyAttr(Sema &S, Decl *D, const ParsedAttr &A) { in handleDestroyAttr() argument
8679 S.Diag(D->getLocation(), diag::err_destroy_attr_on_non_static_var) in handleDestroyAttr()
8685 handleSimpleAttribute<AlwaysDestroyAttr>(S, D, A); in handleDestroyAttr()
8687 handleSimpleAttribute<NoDestroyAttr>(S, D, A); in handleDestroyAttr()
8690 static void handleUninitializedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleUninitializedAttr() argument
8693 D->addAttr(::new (S.Context) UninitializedAttr(S.Context, AL)); in handleUninitializedAttr()
8696 static bool tryMakeVariablePseudoStrong(Sema &S, VarDecl *VD, in tryMakeVariablePseudoStrong() argument
8701 S.Diag(VD->getBeginLoc(), diag::warn_ignored_objc_externally_retained) in tryMakeVariablePseudoStrong()
8719 S.Diag(VD->getBeginLoc(), diag::warn_ignored_objc_externally_retained) in tryMakeVariablePseudoStrong()
8733 static void handleObjCExternallyRetainedAttr(Sema &S, Decl *D, in handleObjCExternallyRetainedAttr() argument
8738 S.Diag(D->getBeginLoc(), diag::warn_ignored_objc_externally_retained) in handleObjCExternallyRetainedAttr()
8743 if (!tryMakeVariablePseudoStrong(S, VD, /*DiagnoseFailure=*/true)) in handleObjCExternallyRetainedAttr()
8746 handleSimpleAttribute<ObjCExternallyRetainedAttr>(S, D, AL); in handleObjCExternallyRetainedAttr()
8766 tryMakeVariablePseudoStrong(S, PVD, /*DiagnoseFailure=*/false); in handleObjCExternallyRetainedAttr()
8768 handleSimpleAttribute<ObjCExternallyRetainedAttr>(S, D, AL); in handleObjCExternallyRetainedAttr()
8771 static void handleMIGServerRoutineAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleMIGServerRoutineAttr() argument
8783 if (!IsKernReturnT || T.getCanonicalType() != S.getASTContext().IntTy) { in handleMIGServerRoutineAttr()
8784 S.Diag(D->getBeginLoc(), in handleMIGServerRoutineAttr()
8790 handleSimpleAttribute<MIGServerRoutineAttr>(S, D, AL); in handleMIGServerRoutineAttr()
8793 static void handleMSAllocatorAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleMSAllocatorAttr() argument
8798 S.Diag(AL.getLoc(), diag::warn_declspec_allocator_nonpointer) in handleMSAllocatorAttr()
8804 handleSimpleAttribute<MSAllocatorAttr>(S, D, AL); in handleMSAllocatorAttr()
8807 static void handleAcquireHandleAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAcquireHandleAttr() argument
8813 S.Diag(AL.getLoc(), diag::err_attribute_output_parameter) in handleAcquireHandleAttr()
8819 if (!S.checkStringLiteralArgumentAttr(AL, 0, Argument)) in handleAcquireHandleAttr()
8821 D->addAttr(AcquireHandleAttr::Create(S.Context, Argument, AL)); in handleAcquireHandleAttr()
8825 static void handleHandleAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleHandleAttr() argument
8827 if (!S.checkStringLiteralArgumentAttr(AL, 0, Argument)) in handleHandleAttr()
8829 D->addAttr(Attr::Create(S.Context, Argument, AL)); in handleHandleAttr()
8833 static void handleUnsafeBufferUsage(Sema &S, Decl *D, const ParsedAttr &AL) { in handleUnsafeBufferUsage() argument
8834 D->addAttr(Attr::Create(S.Context, AL)); in handleUnsafeBufferUsage()
8837 static void handleCFGuardAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCFGuardAttr() argument
8841 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleCFGuardAttr()
8849 S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) << AL << II; in handleCFGuardAttr()
8853 D->addAttr(::new (S.Context) CFGuardAttr(S.Context, AL, Arg)); in handleCFGuardAttr()
8868 static void handleEnforceTCBAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleEnforceTCBAttr() argument
8870 if (!S.checkStringLiteralArgumentAttr(AL, 0, Argument)) in handleEnforceTCBAttr()
8878 S.Diag(AL.getLoc(), diag::err_tcb_conflicting_attributes) in handleEnforceTCBAttr()
8889 D->addAttr(AttrTy::Create(S.Context, Argument, AL)); in handleEnforceTCBAttr()
8893 static AttrTy *mergeEnforceTCBAttrImpl(Sema &S, Decl *D, const AttrTy &AL) { in mergeEnforceTCBAttrImpl() argument
8898 S.Diag(ConflictingAttr->getLoc(), diag::err_tcb_conflicting_attributes) in mergeEnforceTCBAttrImpl()
8903 S.Diag(AL.getLoc(), diag::note_conflicting_attribute); in mergeEnforceTCBAttrImpl()
8910 ASTContext &Context = S.getASTContext(); in mergeEnforceTCBAttrImpl()
8961 Sema &S, const ParsedAttr &AL, const FunctionProtoType *FPT, in checkArmNewAttrMutualExclusion() argument
8967 S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) in checkArmNewAttrMutualExclusion()
8983 static void handleArmNewAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleArmNewAttr() argument
8985 S.Diag(AL.getLoc(), diag::err_missing_arm_state) << AL; in handleArmNewAttr()
8992 for (StringRef S : ExistingAttr->newArgs()) in handleArmNewAttr() local
8993 NewState.push_back(S); in handleArmNewAttr()
9001 if (!S.checkStringLiteralArgumentAttr(AL, I, StateName, &LiteralLoc)) in handleArmNewAttr()
9009 S.Diag(LiteralLoc, diag::err_unknown_arm_state) << StateName; in handleArmNewAttr()
9022 checkArmNewAttrMutualExclusion(S, AL, FPT, ZAState, "za")) in handleArmNewAttr()
9027 checkArmNewAttrMutualExclusion(S, AL, FPT, ZT0State, "zt0")) in handleArmNewAttr()
9032 D->addAttr(::new (S.Context) in handleArmNewAttr()
9033 ArmNewAttr(S.Context, AL, NewState.data(), NewState.size())); in handleArmNewAttr()
9040 ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL, in ProcessDeclAttribute() argument
9054 !AL.existsInTarget(S.Context.getTargetInfo())) { in ProcessDeclAttribute()
9055 S.Diag(AL.getLoc(), in ProcessDeclAttribute()
9069 if (S.checkCommonAttributeFeatures(D, AL, MustDelayArgs)) in ProcessDeclAttribute()
9073 AL.handleAttrWithDelayedArgs(S, D); in ProcessDeclAttribute()
9079 if (AL.getInfo().handleDeclAttribute(S, D, AL) != ParsedAttrInfo::NotHandled) in ProcessDeclAttribute()
9108 S.Diag(AL.getLoc(), diag::warn_type_attribute_deprecated_on_decl) in ProcessDeclAttribute()
9151 S.Diag(AL.getLoc(), diag::err_attribute_invalid_on_decl) in ProcessDeclAttribute()
9155 handleInterruptAttr(S, D, AL); in ProcessDeclAttribute()
9158 handleX86ForceAlignArgPointerAttr(S, D, AL); in ProcessDeclAttribute()
9161 handleSimpleAttribute<ReadOnlyPlacementAttr>(S, D, AL); in ProcessDeclAttribute()
9165 handleDLLAttr(S, D, AL); in ProcessDeclAttribute()
9168 handleAMDGPUFlatWorkGroupSizeAttr(S, D, AL); in ProcessDeclAttribute()
9171 handleAMDGPUWavesPerEUAttr(S, D, AL); in ProcessDeclAttribute()
9174 handleAMDGPUNumSGPRAttr(S, D, AL); in ProcessDeclAttribute()
9177 handleAMDGPUNumVGPRAttr(S, D, AL); in ProcessDeclAttribute()
9180 handleAVRSignalAttr(S, D, AL); in ProcessDeclAttribute()
9183 handleBPFPreserveAccessIndexAttr(S, D, AL); in ProcessDeclAttribute()
9186 handleSimpleAttribute<BPFPreserveStaticOffsetAttr>(S, D, AL); in ProcessDeclAttribute()
9189 handleBTFDeclTagAttr(S, D, AL); in ProcessDeclAttribute()
9192 handleWebAssemblyExportNameAttr(S, D, AL); in ProcessDeclAttribute()
9195 handleWebAssemblyImportModuleAttr(S, D, AL); in ProcessDeclAttribute()
9198 handleWebAssemblyImportNameAttr(S, D, AL); in ProcessDeclAttribute()
9201 handleIBOutlet(S, D, AL); in ProcessDeclAttribute()
9204 handleIBOutletCollection(S, D, AL); in ProcessDeclAttribute()
9207 handleIFuncAttr(S, D, AL); in ProcessDeclAttribute()
9210 handleAliasAttr(S, D, AL); in ProcessDeclAttribute()
9213 handleAlignedAttr(S, D, AL); in ProcessDeclAttribute()
9216 handleAlignValueAttr(S, D, AL); in ProcessDeclAttribute()
9219 handleAllocSizeAttr(S, D, AL); in ProcessDeclAttribute()
9222 handleAlwaysInlineAttr(S, D, AL); in ProcessDeclAttribute()
9225 handleAnalyzerNoReturnAttr(S, D, AL); in ProcessDeclAttribute()
9228 handleTLSModelAttr(S, D, AL); in ProcessDeclAttribute()
9231 handleAnnotateAttr(S, D, AL); in ProcessDeclAttribute()
9234 handleAvailabilityAttr(S, D, AL); in ProcessDeclAttribute()
9237 handleDependencyAttr(S, scope, D, AL); in ProcessDeclAttribute()
9241 handleCPUSpecificAttr(S, D, AL); in ProcessDeclAttribute()
9244 handleCommonAttr(S, D, AL); in ProcessDeclAttribute()
9247 handleConstantAttr(S, D, AL); in ProcessDeclAttribute()
9250 handlePassObjectSizeAttr(S, D, AL); in ProcessDeclAttribute()
9253 handleConstructorAttr(S, D, AL); in ProcessDeclAttribute()
9256 handleDeprecatedAttr(S, D, AL); in ProcessDeclAttribute()
9259 handleDestructorAttr(S, D, AL); in ProcessDeclAttribute()
9262 handleEnableIfAttr(S, D, AL); in ProcessDeclAttribute()
9265 handleErrorAttr(S, D, AL); in ProcessDeclAttribute()
9268 handleDiagnoseIfAttr(S, D, AL); in ProcessDeclAttribute()
9271 handleDiagnoseAsBuiltinAttr(S, D, AL); in ProcessDeclAttribute()
9274 handleNoBuiltinAttr(S, D, AL); in ProcessDeclAttribute()
9277 handleExtVectorTypeAttr(S, D, AL); in ProcessDeclAttribute()
9280 handleExternalSourceSymbolAttr(S, D, AL); in ProcessDeclAttribute()
9283 handleMinSizeAttr(S, D, AL); in ProcessDeclAttribute()
9286 handleOptimizeNoneAttr(S, D, AL); in ProcessDeclAttribute()
9289 handleEnumExtensibilityAttr(S, D, AL); in ProcessDeclAttribute()
9292 handleSYCLKernelAttr(S, D, AL); in ProcessDeclAttribute()
9295 handleSimpleAttribute<SYCLSpecialClassAttr>(S, D, AL); in ProcessDeclAttribute()
9298 handleFormatAttr(S, D, AL); in ProcessDeclAttribute()
9301 handleFormatArgAttr(S, D, AL); in ProcessDeclAttribute()
9304 handleCallbackAttr(S, D, AL); in ProcessDeclAttribute()
9307 handleCalledOnceAttr(S, D, AL); in ProcessDeclAttribute()
9311 handleGlobalAttr(S, D, AL); in ProcessDeclAttribute()
9314 handleDeviceAttr(S, D, AL); in ProcessDeclAttribute()
9317 handleManagedAttr(S, D, AL); in ProcessDeclAttribute()
9320 handleGNUInlineAttr(S, D, AL); in ProcessDeclAttribute()
9323 handleLaunchBoundsAttr(S, D, AL); in ProcessDeclAttribute()
9326 handleRestrictAttr(S, D, AL); in ProcessDeclAttribute()
9329 handleModeAttr(S, D, AL); in ProcessDeclAttribute()
9333 handleNonNullAttrParameter(S, PVD, AL); in ProcessDeclAttribute()
9335 handleNonNullAttr(S, D, AL); in ProcessDeclAttribute()
9338 handleReturnsNonNullAttr(S, D, AL); in ProcessDeclAttribute()
9341 handleNoEscapeAttr(S, D, AL); in ProcessDeclAttribute()
9344 handleSimpleAttribute<MaybeUndefAttr>(S, D, AL); in ProcessDeclAttribute()
9347 handleAssumeAlignedAttr(S, D, AL); in ProcessDeclAttribute()
9350 handleAllocAlignAttr(S, D, AL); in ProcessDeclAttribute()
9353 handleOwnershipAttr(S, D, AL); in ProcessDeclAttribute()
9356 handleNakedAttr(S, D, AL); in ProcessDeclAttribute()
9359 handleNoReturnAttr(S, D, AL); in ProcessDeclAttribute()
9362 handleStandardNoReturnAttr(S, D, AL); in ProcessDeclAttribute()
9365 handleNoCfCheckAttr(S, D, AL); in ProcessDeclAttribute()
9369 handleSimpleAttribute<NoThrowAttr>(S, D, AL); in ProcessDeclAttribute()
9372 handleSharedAttr(S, D, AL); in ProcessDeclAttribute()
9375 handleVecReturnAttr(S, D, AL); in ProcessDeclAttribute()
9378 handleObjCOwnershipAttr(S, D, AL); in ProcessDeclAttribute()
9381 handleObjCPreciseLifetimeAttr(S, D, AL); in ProcessDeclAttribute()
9384 handleObjCReturnsInnerPointerAttr(S, D, AL); in ProcessDeclAttribute()
9387 handleObjCRequiresSuperAttr(S, D, AL); in ProcessDeclAttribute()
9390 handleObjCBridgeAttr(S, D, AL); in ProcessDeclAttribute()
9393 handleObjCBridgeMutableAttr(S, D, AL); in ProcessDeclAttribute()
9396 handleObjCBridgeRelatedAttr(S, D, AL); in ProcessDeclAttribute()
9399 handleObjCDesignatedInitializer(S, D, AL); in ProcessDeclAttribute()
9402 handleObjCRuntimeName(S, D, AL); in ProcessDeclAttribute()
9405 handleObjCBoxable(S, D, AL); in ProcessDeclAttribute()
9408 handleNSErrorDomain(S, D, AL); in ProcessDeclAttribute()
9413 S.AddXConsumedAttr(D, AL, parsedAttrToRetainOwnershipKind(AL), in ProcessDeclAttribute()
9418 S, D, AL, isValidOSObjectOutParameter(D), in ProcessDeclAttribute()
9424 S, D, AL, isValidOSObjectOutParameter(D), in ProcessDeclAttribute()
9435 handleXReturnsXRetainedAttr(S, D, AL); in ProcessDeclAttribute()
9438 handleWorkGroupSize<WorkGroupSizeHintAttr>(S, D, AL); in ProcessDeclAttribute()
9441 handleWorkGroupSize<ReqdWorkGroupSizeAttr>(S, D, AL); in ProcessDeclAttribute()
9444 handleSubGroupSize(S, D, AL); in ProcessDeclAttribute()
9447 handleVecTypeHint(S, D, AL); in ProcessDeclAttribute()
9450 handleInitPriorityAttr(S, D, AL); in ProcessDeclAttribute()
9453 handlePackedAttr(S, D, AL); in ProcessDeclAttribute()
9456 handlePreferredName(S, D, AL); in ProcessDeclAttribute()
9459 handleSectionAttr(S, D, AL); in ProcessDeclAttribute()
9462 handleCodeModelAttr(S, D, AL); in ProcessDeclAttribute()
9465 handleRandomizeLayoutAttr(S, D, AL); in ProcessDeclAttribute()
9468 handleNoRandomizeLayoutAttr(S, D, AL); in ProcessDeclAttribute()
9471 handleCodeSegAttr(S, D, AL); in ProcessDeclAttribute()
9474 handleTargetAttr(S, D, AL); in ProcessDeclAttribute()
9477 handleTargetVersionAttr(S, D, AL); in ProcessDeclAttribute()
9480 handleTargetClonesAttr(S, D, AL); in ProcessDeclAttribute()
9483 handleMinVectorWidthAttr(S, D, AL); in ProcessDeclAttribute()
9486 handleAttrWithMessage<UnavailableAttr>(S, D, AL); in ProcessDeclAttribute()
9489 handleAssumumptionAttr(S, D, AL); in ProcessDeclAttribute()
9492 handleObjCDirectAttr(S, D, AL); in ProcessDeclAttribute()
9495 handleObjCDirectMembersAttr(S, D, AL); in ProcessDeclAttribute()
9496 handleSimpleAttribute<ObjCDirectMembersAttr>(S, D, AL); in ProcessDeclAttribute()
9499 handleObjCSuppresProtocolAttr(S, D, AL); in ProcessDeclAttribute()
9502 handleUnusedAttr(S, D, AL); in ProcessDeclAttribute()
9505 handleVisibilityAttr(S, D, AL, false); in ProcessDeclAttribute()
9508 handleVisibilityAttr(S, D, AL, true); in ProcessDeclAttribute()
9511 handleWarnUnusedResult(S, D, AL); in ProcessDeclAttribute()
9514 handleWeakRefAttr(S, D, AL); in ProcessDeclAttribute()
9517 handleWeakImportAttr(S, D, AL); in ProcessDeclAttribute()
9520 handleTransparentUnionAttr(S, D, AL); in ProcessDeclAttribute()
9523 handleObjCMethodFamilyAttr(S, D, AL); in ProcessDeclAttribute()
9526 handleObjCNSObject(S, D, AL); in ProcessDeclAttribute()
9529 handleObjCIndependentClass(S, D, AL); in ProcessDeclAttribute()
9532 handleBlocksAttr(S, D, AL); in ProcessDeclAttribute()
9535 handleSentinelAttr(S, D, AL); in ProcessDeclAttribute()
9538 handleCleanupAttr(S, D, AL); in ProcessDeclAttribute()
9541 handleNoDebugAttr(S, D, AL); in ProcessDeclAttribute()
9544 handleCmseNSEntryAttr(S, D, AL); in ProcessDeclAttribute()
9565 handleCallConvAttr(S, D, AL); in ProcessDeclAttribute()
9568 handleSuppressAttr(S, D, AL); in ProcessDeclAttribute()
9572 handleLifetimeCategoryAttr(S, D, AL); in ProcessDeclAttribute()
9575 handleOpenCLAccessAttr(S, D, AL); in ProcessDeclAttribute()
9578 handleOpenCLNoSVMAttr(S, D, AL); in ProcessDeclAttribute()
9581 S.AddParameterABIAttr(D, AL, ParameterABI::SwiftContext); in ProcessDeclAttribute()
9584 S.AddParameterABIAttr(D, AL, ParameterABI::SwiftAsyncContext); in ProcessDeclAttribute()
9587 S.AddParameterABIAttr(D, AL, ParameterABI::SwiftErrorResult); in ProcessDeclAttribute()
9590 S.AddParameterABIAttr(D, AL, ParameterABI::SwiftIndirectResult); in ProcessDeclAttribute()
9593 handleInternalLinkageAttr(S, D, AL); in ProcessDeclAttribute()
9596 handleZeroCallUsedRegsAttr(S, D, AL); in ProcessDeclAttribute()
9599 handleFunctionReturnThunksAttr(S, D, AL); in ProcessDeclAttribute()
9602 handleNoMergeAttr(S, D, AL); in ProcessDeclAttribute()
9605 handleNoUniqueAddressAttr(S, D, AL); in ProcessDeclAttribute()
9609 handleAvailableOnlyInDefaultEvalMethod(S, D, AL); in ProcessDeclAttribute()
9613 handleCountedByAttr(S, D, AL); in ProcessDeclAttribute()
9618 handleLayoutVersion(S, D, AL); in ProcessDeclAttribute()
9621 handleUuidAttr(S, D, AL); in ProcessDeclAttribute()
9624 handleMSInheritanceAttr(S, D, AL); in ProcessDeclAttribute()
9627 handleDeclspecThreadAttr(S, D, AL); in ProcessDeclAttribute()
9630 handleMSConstexprAttr(S, D, AL); in ProcessDeclAttribute()
9635 handleHLSLNumThreadsAttr(S, D, AL); in ProcessDeclAttribute()
9638 handleSimpleAttribute<HLSLSV_GroupIndexAttr>(S, D, AL); in ProcessDeclAttribute()
9641 handleHLSLSV_DispatchThreadIDAttr(S, D, AL); in ProcessDeclAttribute()
9644 handleHLSLShaderAttr(S, D, AL); in ProcessDeclAttribute()
9647 handleHLSLResourceBindingAttr(S, D, AL); in ProcessDeclAttribute()
9650 handleHLSLParamModifierAttr(S, D, AL); in ProcessDeclAttribute()
9654 handleAbiTagAttr(S, D, AL); in ProcessDeclAttribute()
9657 handleCFGuardAttr(S, D, AL); in ProcessDeclAttribute()
9662 handleAssertExclusiveLockAttr(S, D, AL); in ProcessDeclAttribute()
9665 handleAssertSharedLockAttr(S, D, AL); in ProcessDeclAttribute()
9668 handlePtGuardedVarAttr(S, D, AL); in ProcessDeclAttribute()
9671 handleNoSanitizeAttr(S, D, AL); in ProcessDeclAttribute()
9674 handleNoSanitizeSpecificAttr(S, D, AL); in ProcessDeclAttribute()
9677 handleGuardedByAttr(S, D, AL); in ProcessDeclAttribute()
9680 handlePtGuardedByAttr(S, D, AL); in ProcessDeclAttribute()
9683 handleExclusiveTrylockFunctionAttr(S, D, AL); in ProcessDeclAttribute()
9686 handleLockReturnedAttr(S, D, AL); in ProcessDeclAttribute()
9689 handleLocksExcludedAttr(S, D, AL); in ProcessDeclAttribute()
9692 handleSharedTrylockFunctionAttr(S, D, AL); in ProcessDeclAttribute()
9695 handleAcquiredBeforeAttr(S, D, AL); in ProcessDeclAttribute()
9698 handleAcquiredAfterAttr(S, D, AL); in ProcessDeclAttribute()
9704 handleCapabilityAttr(S, D, AL); in ProcessDeclAttribute()
9707 handleRequiresCapabilityAttr(S, D, AL); in ProcessDeclAttribute()
9711 handleAssertCapabilityAttr(S, D, AL); in ProcessDeclAttribute()
9714 handleAcquireCapabilityAttr(S, D, AL); in ProcessDeclAttribute()
9717 handleReleaseCapabilityAttr(S, D, AL); in ProcessDeclAttribute()
9720 handleTryAcquireCapabilityAttr(S, D, AL); in ProcessDeclAttribute()
9725 handleConsumableAttr(S, D, AL); in ProcessDeclAttribute()
9728 handleCallableWhenAttr(S, D, AL); in ProcessDeclAttribute()
9731 handleParamTypestateAttr(S, D, AL); in ProcessDeclAttribute()
9734 handleReturnTypestateAttr(S, D, AL); in ProcessDeclAttribute()
9737 handleSetTypestateAttr(S, D, AL); in ProcessDeclAttribute()
9740 handleTestTypestateAttr(S, D, AL); in ProcessDeclAttribute()
9745 handleArgumentWithTypeTagAttr(S, D, AL); in ProcessDeclAttribute()
9748 handleTypeTagForDatatypeAttr(S, D, AL); in ProcessDeclAttribute()
9753 handleSwiftAsyncName(S, D, AL); in ProcessDeclAttribute()
9756 handleSwiftAttrAttr(S, D, AL); in ProcessDeclAttribute()
9759 handleSwiftBridge(S, D, AL); in ProcessDeclAttribute()
9762 handleSwiftError(S, D, AL); in ProcessDeclAttribute()
9765 handleSwiftName(S, D, AL); in ProcessDeclAttribute()
9768 handleSwiftNewType(S, D, AL); in ProcessDeclAttribute()
9771 handleSwiftAsyncAttr(S, D, AL); in ProcessDeclAttribute()
9774 handleSwiftAsyncError(S, D, AL); in ProcessDeclAttribute()
9779 handleXRayLogArgsAttr(S, D, AL); in ProcessDeclAttribute()
9783 handlePatchableFunctionEntryAttr(S, D, AL); in ProcessDeclAttribute()
9788 handleDestroyAttr(S, D, AL); in ProcessDeclAttribute()
9792 handleUninitializedAttr(S, D, AL); in ProcessDeclAttribute()
9796 handleObjCExternallyRetainedAttr(S, D, AL); in ProcessDeclAttribute()
9800 handleMIGServerRoutineAttr(S, D, AL); in ProcessDeclAttribute()
9804 handleMSAllocatorAttr(S, D, AL); in ProcessDeclAttribute()
9808 handleArmBuiltinAliasAttr(S, D, AL); in ProcessDeclAttribute()
9812 handleSimpleAttribute<ArmLocallyStreamingAttr>(S, D, AL); in ProcessDeclAttribute()
9816 handleArmNewAttr(S, D, AL); in ProcessDeclAttribute()
9820 handleAcquireHandleAttr(S, D, AL); in ProcessDeclAttribute()
9824 handleHandleAttr<ReleaseHandleAttr>(S, D, AL); in ProcessDeclAttribute()
9828 handleUnsafeBufferUsage<UnsafeBufferUsageAttr>(S, D, AL); in ProcessDeclAttribute()
9832 handleHandleAttr<UseHandleAttr>(S, D, AL); in ProcessDeclAttribute()
9836 handleEnforceTCBAttr<EnforceTCBAttr, EnforceTCBLeafAttr>(S, D, AL); in ProcessDeclAttribute()
9840 handleEnforceTCBAttr<EnforceTCBLeafAttr, EnforceTCBAttr>(S, D, AL); in ProcessDeclAttribute()
9844 handleBuiltinAliasAttr(S, D, AL); in ProcessDeclAttribute()
9848 handlePreferredTypeAttr(S, D, AL); in ProcessDeclAttribute()
9852 handleSimpleAttribute<UsingIfExistsAttr>(S, D, AL); in ProcessDeclAttribute()
9860 Scope *S, Decl *D, const ParsedAttributesView &AttrList, in ProcessDeclAttributeList() argument
9866 ProcessDeclAttribute(*this, S, D, AL, Options); in ProcessDeclAttributeList()
9966 static void checkUnusedDeclAttributes(Sema &S, const ParsedAttributesView &A) { in checkUnusedDeclAttributes() argument
9975 S.Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored) in checkUnusedDeclAttributes()
9978 S.Diag(AL.getLoc(), diag::warn_attribute_not_on_decl) << AL in checkUnusedDeclAttributes()
10043 void Sema::DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W) { in DeclApplyPragmaWeak() argument
10057 PushOnScopeChains(NewD, S); in DeclApplyPragmaWeak()
10064 void Sema::ProcessPragmaWeak(Scope *S, Decl *D) { in ProcessPragmaWeak() argument
10084 DeclApplyPragmaWeak(S, ND, W); in ProcessPragmaWeak()
10094 void Sema::ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD) { in ProcessDeclAttributes() argument
10112 ProcessDeclAttributeList(S, D, NonSlidingAttrs); in ProcessDeclAttributes()
10116 ProcessDeclAttributeList(S, D, PD.getDeclSpec().getAttributes(), in ProcessDeclAttributes()
10127 ProcessDeclAttributeList(S, D, PD.getTypeObject(i).getAttrs(), in ProcessDeclAttributes()
10134 ProcessDeclAttributeList(S, D, PD.getAttributes()); in ProcessDeclAttributes()
10137 AddPragmaAttributes(S, D); in ProcessDeclAttributes()
10143 static bool isForbiddenTypeAllowed(Sema &S, Decl *D, in isForbiddenTypeAllowed() argument
10167 if (S.Context.getSourceManager().isInSystemHeader(D->getLocation())) { in isForbiddenTypeAllowed()
10178 static void handleDelayedForbiddenType(Sema &S, DelayedDiagnostic &DD, in handleDelayedForbiddenType() argument
10181 if (D && isForbiddenTypeAllowed(S, D, DD, Reason)) { in handleDelayedForbiddenType()
10183 D->addAttr(UnavailableAttr::CreateImplicit(S.Context, "", Reason, DD.Loc)); in handleDelayedForbiddenType()
10186 if (S.getLangOpts().ObjCAutoRefCount) in handleDelayedForbiddenType()
10198 S.Diag(DD.Loc, DD.getForbiddenTypeDiagnostic()) in handleDelayedForbiddenType()