Lines Matching refs:S

96 static bool checkPositiveIntArgument(Sema &S, const AttrInfo &AI, const Expr *Expr,  in checkPositiveIntArgument()  argument
99 if (!S.checkUInt32Argument(AI, Expr, UVal, Idx)) in checkPositiveIntArgument()
105 S.Diag(Expr->getExprLoc(), diag::err_ice_too_large) in checkPositiveIntArgument()
171 static bool threadSafetyCheckIsSmartPointer(Sema &S, const RecordType* RT) { in threadSafetyCheckIsSmartPointer() argument
172 auto IsOverloadedOperatorPresent = [&S](const RecordDecl *Record, in threadSafetyCheckIsSmartPointer()
175 Record->lookup(S.Context.DeclarationNames.getCXXOperatorName(Op)); in threadSafetyCheckIsSmartPointer()
207 static bool threadSafetyCheckIsPointer(Sema &S, const Decl *D, in threadSafetyCheckIsPointer() argument
221 if (threadSafetyCheckIsSmartPointer(S, RT)) in threadSafetyCheckIsPointer()
225 S.Diag(AL.getLoc(), diag::warn_thread_attribute_decl_not_pointer) << AL << QT; in threadSafetyCheckIsPointer()
258 static bool checkRecordTypeForCapability(Sema &S, QualType Ty) { in checkRecordTypeForCapability() argument
270 if (threadSafetyCheckIsSmartPointer(S, RT)) in checkRecordTypeForCapability()
288 static bool typeHasCapability(Sema &S, QualType Ty) { in typeHasCapability() argument
292 if (checkRecordTypeForCapability(S, Ty)) in typeHasCapability()
298 static bool isCapabilityExpr(Sema &S, const Expr *Ex) { in isCapabilityExpr() argument
305 return isCapabilityExpr(S, E->getSubExpr()); in isCapabilityExpr()
307 return isCapabilityExpr(S, E->getSubExpr()); in isCapabilityExpr()
311 return isCapabilityExpr(S, E->getSubExpr()); in isCapabilityExpr()
315 return isCapabilityExpr(S, E->getLHS()) && in isCapabilityExpr()
316 isCapabilityExpr(S, E->getRHS()); in isCapabilityExpr()
320 return typeHasCapability(S, Ex->getType()); in isCapabilityExpr()
328 static void checkAttrArgsAreCapabilityObjs(Sema &S, Decl *D, in checkAttrArgsAreCapabilityObjs() argument
343 S.Diag(AL.getLoc(), in checkAttrArgsAreCapabilityObjs()
347 S.Diag(AL.getLoc(), diag::warn_thread_attribute_not_on_non_static_member) in checkAttrArgsAreCapabilityObjs()
372 S.Diag(AL.getLoc(), diag::warn_thread_attribute_ignored) << AL; in checkAttrArgsAreCapabilityObjs()
400 S.Diag(AL.getLoc(), in checkAttrArgsAreCapabilityObjs()
413 if (!typeHasCapability(S, ArgTy) && !isCapabilityExpr(S, ArgExp)) in checkAttrArgsAreCapabilityObjs()
414 S.Diag(AL.getLoc(), diag::warn_thread_attribute_argument_not_lockable) in checkAttrArgsAreCapabilityObjs()
425 static void handlePtGuardedVarAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handlePtGuardedVarAttr() argument
426 if (!threadSafetyCheckIsPointer(S, D, AL)) in handlePtGuardedVarAttr()
429 D->addAttr(::new (S.Context) PtGuardedVarAttr(S.Context, AL)); in handlePtGuardedVarAttr()
432 static bool checkGuardedByAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, in checkGuardedByAttrCommon() argument
436 checkAttrArgsAreCapabilityObjs(S, D, AL, Args); in checkGuardedByAttrCommon()
446 static void handleGuardedByAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleGuardedByAttr() argument
448 if (!checkGuardedByAttrCommon(S, D, AL, Arg)) in handleGuardedByAttr()
451 D->addAttr(::new (S.Context) GuardedByAttr(S.Context, AL, Arg)); in handleGuardedByAttr()
454 static void handlePtGuardedByAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handlePtGuardedByAttr() argument
456 if (!checkGuardedByAttrCommon(S, D, AL, Arg)) in handlePtGuardedByAttr()
459 if (!threadSafetyCheckIsPointer(S, D, AL)) in handlePtGuardedByAttr()
462 D->addAttr(::new (S.Context) PtGuardedByAttr(S.Context, AL, Arg)); in handlePtGuardedByAttr()
465 static bool checkAcquireOrderAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, in checkAcquireOrderAttrCommon() argument
467 if (!AL.checkAtLeastNumArgs(S, 1)) in checkAcquireOrderAttrCommon()
472 if (!QT->isDependentType() && !typeHasCapability(S, QT)) { in checkAcquireOrderAttrCommon()
473 S.Diag(AL.getLoc(), diag::warn_thread_attribute_decl_not_lockable) << AL; in checkAcquireOrderAttrCommon()
478 checkAttrArgsAreCapabilityObjs(S, D, AL, Args); in checkAcquireOrderAttrCommon()
485 static void handleAcquiredAfterAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAcquiredAfterAttr() argument
487 if (!checkAcquireOrderAttrCommon(S, D, AL, Args)) in handleAcquiredAfterAttr()
491 D->addAttr(::new (S.Context) in handleAcquiredAfterAttr()
492 AcquiredAfterAttr(S.Context, AL, StartArg, Args.size())); in handleAcquiredAfterAttr()
495 static void handleAcquiredBeforeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAcquiredBeforeAttr() argument
497 if (!checkAcquireOrderAttrCommon(S, D, AL, Args)) in handleAcquiredBeforeAttr()
501 D->addAttr(::new (S.Context) in handleAcquiredBeforeAttr()
502 AcquiredBeforeAttr(S.Context, AL, StartArg, Args.size())); in handleAcquiredBeforeAttr()
505 static bool checkLockFunAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, in checkLockFunAttrCommon() argument
509 checkAttrArgsAreCapabilityObjs(S, D, AL, Args, 0, /*ParamIdxOk=*/true); in checkLockFunAttrCommon()
514 static void handleAssertSharedLockAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAssertSharedLockAttr() argument
516 if (!checkLockFunAttrCommon(S, D, AL, Args)) in handleAssertSharedLockAttr()
521 D->addAttr(::new (S.Context) in handleAssertSharedLockAttr()
522 AssertSharedLockAttr(S.Context, AL, StartArg, Size)); in handleAssertSharedLockAttr()
525 static void handleAssertExclusiveLockAttr(Sema &S, Decl *D, in handleAssertExclusiveLockAttr() argument
528 if (!checkLockFunAttrCommon(S, D, AL, Args)) in handleAssertExclusiveLockAttr()
533 D->addAttr(::new (S.Context) in handleAssertExclusiveLockAttr()
534 AssertExclusiveLockAttr(S.Context, AL, StartArg, Size)); in handleAssertExclusiveLockAttr()
543 static bool checkParamIsIntegerType(Sema &S, const Decl *D, const AttrInfo &AI, in checkParamIsIntegerType() argument
548 if (!S.checkFunctionOrMethodParameterIndex(D, AI, AttrArgNo + 1, AttrArg, in checkParamIsIntegerType()
555 S.Diag(SrcLoc, diag::err_attribute_integers_only) in checkParamIsIntegerType()
562 static void handleAllocSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAllocSizeAttr() argument
563 if (!AL.checkAtLeastNumArgs(S, 1) || !AL.checkAtMostNumArgs(S, 2)) in handleAllocSizeAttr()
570 S.Diag(AL.getLoc(), diag::warn_attribute_return_pointers_only) << AL; in handleAllocSizeAttr()
577 if (!checkPositiveIntArgument(S, AL, SizeExpr, SizeArgNoVal, /*Idx=*/1)) in handleAllocSizeAttr()
579 if (!checkParamIsIntegerType(S, D, AL, /*AttrArgNo=*/0)) in handleAllocSizeAttr()
588 if (!checkPositiveIntArgument(S, AL, NumberExpr, Val, /*Idx=*/2)) in handleAllocSizeAttr()
590 if (!checkParamIsIntegerType(S, D, AL, /*AttrArgNo=*/1)) in handleAllocSizeAttr()
595 D->addAttr(::new (S.Context) in handleAllocSizeAttr()
596 AllocSizeAttr(S.Context, AL, SizeArgNo, NumberArgNo)); in handleAllocSizeAttr()
599 static bool checkTryLockFunAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, in checkTryLockFunAttrCommon() argument
601 if (!AL.checkAtLeastNumArgs(S, 1)) in checkTryLockFunAttrCommon()
605 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) in checkTryLockFunAttrCommon()
611 checkAttrArgsAreCapabilityObjs(S, D, AL, Args, 1); in checkTryLockFunAttrCommon()
616 static void handleSharedTrylockFunctionAttr(Sema &S, Decl *D, in handleSharedTrylockFunctionAttr() argument
619 if (!checkTryLockFunAttrCommon(S, D, AL, Args)) in handleSharedTrylockFunctionAttr()
622 D->addAttr(::new (S.Context) SharedTrylockFunctionAttr( in handleSharedTrylockFunctionAttr()
623 S.Context, AL, AL.getArgAsExpr(0), Args.data(), Args.size())); in handleSharedTrylockFunctionAttr()
626 static void handleExclusiveTrylockFunctionAttr(Sema &S, Decl *D, in handleExclusiveTrylockFunctionAttr() argument
629 if (!checkTryLockFunAttrCommon(S, D, AL, Args)) in handleExclusiveTrylockFunctionAttr()
632 D->addAttr(::new (S.Context) ExclusiveTrylockFunctionAttr( in handleExclusiveTrylockFunctionAttr()
633 S.Context, AL, AL.getArgAsExpr(0), Args.data(), Args.size())); in handleExclusiveTrylockFunctionAttr()
636 static void handleLockReturnedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleLockReturnedAttr() argument
639 checkAttrArgsAreCapabilityObjs(S, D, AL, Args); in handleLockReturnedAttr()
644 D->addAttr(::new (S.Context) LockReturnedAttr(S.Context, AL, Args[0])); in handleLockReturnedAttr()
647 static void handleLocksExcludedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleLocksExcludedAttr() argument
648 if (!AL.checkAtLeastNumArgs(S, 1)) in handleLocksExcludedAttr()
653 checkAttrArgsAreCapabilityObjs(S, D, AL, Args); in handleLocksExcludedAttr()
659 D->addAttr(::new (S.Context) in handleLocksExcludedAttr()
660 LocksExcludedAttr(S.Context, AL, StartArg, Size)); in handleLocksExcludedAttr()
663 static bool checkFunctionConditionAttr(Sema &S, Decl *D, const ParsedAttr &AL, in checkFunctionConditionAttr() argument
667 ExprResult Converted = S.PerformContextuallyConvertToBool(Cond); in checkFunctionConditionAttr()
673 if (!S.checkStringLiteralArgumentAttr(AL, 1, Msg)) in checkFunctionConditionAttr()
683 S.Diag(AL.getLoc(), diag::err_attr_cond_never_constant_expr) << AL; in checkFunctionConditionAttr()
685 S.Diag(PDiag.first, PDiag.second); in checkFunctionConditionAttr()
691 static void handleEnableIfAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleEnableIfAttr() argument
692 S.Diag(AL.getLoc(), diag::ext_clang_enable_if); in handleEnableIfAttr()
696 if (checkFunctionConditionAttr(S, D, AL, Cond, Msg)) in handleEnableIfAttr()
697 D->addAttr(::new (S.Context) EnableIfAttr(S.Context, AL, Cond, Msg)); in handleEnableIfAttr()
700 static void handleErrorAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleErrorAttr() argument
702 if (!S.checkStringLiteralArgumentAttr(AL, 0, NewUserDiagnostic)) in handleErrorAttr()
704 if (ErrorAttr *EA = S.mergeErrorAttr(D, AL, NewUserDiagnostic)) in handleErrorAttr()
708 static void handleExcludeFromExplicitInstantiationAttr(Sema &S, Decl *D, in handleExcludeFromExplicitInstantiationAttr() argument
714 S.Diag(AL.getLoc(), in handleExcludeFromExplicitInstantiationAttr()
719 D->addAttr(::new (S.Context) in handleExcludeFromExplicitInstantiationAttr()
720 ExcludeFromExplicitInstantiationAttr(S.Context, AL)); in handleExcludeFromExplicitInstantiationAttr()
769 static void handleDiagnoseAsBuiltinAttr(Sema &S, Decl *D, in handleDiagnoseAsBuiltinAttr() argument
775 S.Diag(AL.getLoc(), diag::err_attribute_no_member_function) << AL; in handleDiagnoseAsBuiltinAttr()
787 S.Diag(Loc, diag::err_attribute_argument_n_type) << AL << Index << T; in handleDiagnoseAsBuiltinAttr()
805 S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments_for) in handleDiagnoseAsBuiltinAttr()
821 if (!S.checkUInt32Argument(AL, IndexExpr, Index, I + 1, false)) in handleDiagnoseAsBuiltinAttr()
825 S.Diag(AL.getLoc(), diag::err_attribute_bounds_for_function) in handleDiagnoseAsBuiltinAttr()
835 S.Diag(IndexExpr->getBeginLoc(), diag::err_attribute_parameter_types) in handleDiagnoseAsBuiltinAttr()
843 D->addAttr(::new (S.Context) DiagnoseAsBuiltinAttr( in handleDiagnoseAsBuiltinAttr()
844 S.Context, AL, AttrFD, Indices.data(), Indices.size())); in handleDiagnoseAsBuiltinAttr()
847 static void handleDiagnoseIfAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleDiagnoseIfAttr() argument
848 S.Diag(AL.getLoc(), diag::ext_clang_diagnose_if); in handleDiagnoseIfAttr()
852 if (!checkFunctionConditionAttr(S, D, AL, Cond, Msg)) in handleDiagnoseIfAttr()
856 if (!S.checkStringLiteralArgumentAttr(AL, 2, DiagTypeStr)) in handleDiagnoseIfAttr()
861 S.Diag(AL.getArgAsExpr(2)->getBeginLoc(), in handleDiagnoseIfAttr()
869 D->addAttr(::new (S.Context) DiagnoseIfAttr( in handleDiagnoseIfAttr()
870 S.Context, AL, Cond, Msg, DiagType, ArgDependent, cast<NamedDecl>(D))); in handleDiagnoseIfAttr()
873 static void handleNoBuiltinAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNoBuiltinAttr() argument
897 if (!S.checkStringLiteralArgumentAttr(AL, I, BuiltinName, &LiteralLoc)) in handleNoBuiltinAttr()
903 S.Diag(LiteralLoc, diag::warn_attribute_no_builtin_invalid_builtin_name) in handleNoBuiltinAttr()
913 S.Diag(D->getLocation(), in handleNoBuiltinAttr()
919 D->addAttr(::new (S.Context) in handleNoBuiltinAttr()
920 NoBuiltinAttr(S.Context, AL, Names.data(), Names.size())); in handleNoBuiltinAttr()
923 static void handlePassObjectSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handlePassObjectSizeAttr() argument
925 S.Diag(D->getBeginLoc(), diag::err_attribute_only_once_per_parameter) << AL; in handlePassObjectSizeAttr()
931 if (!S.checkUInt32Argument(AL, E, Type, /*Idx=*/1)) in handlePassObjectSizeAttr()
938 S.Diag(E->getBeginLoc(), diag::err_attribute_argument_out_of_range) in handlePassObjectSizeAttr()
948 S.Diag(D->getBeginLoc(), diag::err_attribute_pointers_only) << AL << 1; in handlePassObjectSizeAttr()
952 D->addAttr(::new (S.Context) PassObjectSizeAttr(S.Context, AL, (int)Type)); in handlePassObjectSizeAttr()
955 static void handleConsumableAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleConsumableAttr() argument
962 S.Diag(IL->Loc, diag::warn_attribute_type_not_supported) << AL in handleConsumableAttr()
967 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleConsumableAttr()
972 D->addAttr(::new (S.Context) ConsumableAttr(S.Context, AL, DefaultState)); in handleConsumableAttr()
975 static bool checkForConsumableClass(Sema &S, const CXXMethodDecl *MD, in checkForConsumableClass() argument
981 S.Diag(AL.getLoc(), diag::warn_attr_on_unconsumable_class) << RD; in checkForConsumableClass()
990 static void handleCallableWhenAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCallableWhenAttr() argument
991 if (!AL.checkAtLeastNumArgs(S, 1)) in handleCallableWhenAttr()
994 if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), AL)) in handleCallableWhenAttr()
1008 if (!S.checkStringLiteralArgumentAttr(AL, ArgIndex, StateString, &Loc)) in handleCallableWhenAttr()
1014 S.Diag(Loc, diag::warn_attribute_type_not_supported) << AL << StateString; in handleCallableWhenAttr()
1021 D->addAttr(::new (S.Context) in handleCallableWhenAttr()
1022 CallableWhenAttr(S.Context, AL, States.data(), States.size())); in handleCallableWhenAttr()
1025 static void handleParamTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleParamTypestateAttr() argument
1034 S.Diag(Ident->Loc, diag::warn_attribute_type_not_supported) in handleParamTypestateAttr()
1039 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleParamTypestateAttr()
1056 D->addAttr(::new (S.Context) ParamTypestateAttr(S.Context, AL, ParamState)); in handleParamTypestateAttr()
1059 static void handleReturnTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleReturnTypestateAttr() argument
1066 S.Diag(IL->Loc, diag::warn_attribute_type_not_supported) << AL in handleReturnTypestateAttr()
1071 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleReturnTypestateAttr()
1101 D->addAttr(::new (S.Context) ReturnTypestateAttr(S.Context, AL, ReturnState)); in handleReturnTypestateAttr()
1104 static void handleSetTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSetTypestateAttr() argument
1105 if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), AL)) in handleSetTypestateAttr()
1113 S.Diag(Ident->Loc, diag::warn_attribute_type_not_supported) << AL in handleSetTypestateAttr()
1118 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleSetTypestateAttr()
1123 D->addAttr(::new (S.Context) SetTypestateAttr(S.Context, AL, NewState)); in handleSetTypestateAttr()
1126 static void handleTestTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleTestTypestateAttr() argument
1127 if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), AL)) in handleTestTypestateAttr()
1135 S.Diag(Ident->Loc, diag::warn_attribute_type_not_supported) << AL in handleTestTypestateAttr()
1140 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleTestTypestateAttr()
1145 D->addAttr(::new (S.Context) TestTypestateAttr(S.Context, AL, TestState)); in handleTestTypestateAttr()
1148 static void handleExtVectorTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleExtVectorTypeAttr() argument
1150 S.ExtVectorDecls.push_back(cast<TypedefNameDecl>(D)); in handleExtVectorTypeAttr()
1153 static void handlePackedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handlePackedAttr() argument
1155 TD->addAttr(::new (S.Context) PackedAttr(S.Context, AL)); in handlePackedAttr()
1160 S.Context.getTypeAlign(FD->getType()) <= 8); in handlePackedAttr()
1162 if (S.getASTContext().getTargetInfo().getTriple().isPS()) { in handlePackedAttr()
1165 S.Diag(AL.getLoc(), diag::warn_attribute_ignored_for_field_of_type) in handlePackedAttr()
1168 FD->addAttr(::new (S.Context) PackedAttr(S.Context, AL)); in handlePackedAttr()
1172 S.Diag(AL.getLoc(), diag::warn_attribute_packed_for_bitfield); in handlePackedAttr()
1174 FD->addAttr(::new (S.Context) PackedAttr(S.Context, AL)); in handlePackedAttr()
1178 S.Diag(AL.getLoc(), diag::warn_attribute_ignored) << AL; in handlePackedAttr()
1181 static void handlePreferredName(Sema &S, Decl *D, const ParsedAttr &AL) { in handlePreferredName() argument
1188 QualType T = S.GetTypeFromParser(PT, &TSI); in handlePreferredName()
1190 TSI = S.Context.getTrivialTypeSourceInfo(T, AL.getLoc()); in handlePreferredName()
1206 D->addAttr(::new (S.Context) PreferredNameAttr(S.Context, AL, TSI)); in handlePreferredName()
1211 S.Diag(AL.getLoc(), diag::err_attribute_preferred_name_arg_invalid) in handlePreferredName()
1214 S.Diag(TT->getDecl()->getLocation(), diag::note_entity_declared_at) in handlePreferredName()
1242 static bool attrNonNullArgCheck(Sema &S, QualType T, const ParsedAttr &AL, in attrNonNullArgCheck() argument
1246 if (!S.isValidPointerAttrType(T)) { in attrNonNullArgCheck()
1248 S.Diag(AL.getLoc(), diag::warn_attribute_return_pointers_only) in attrNonNullArgCheck()
1251 S.Diag(AL.getLoc(), diag::warn_attribute_pointers_only) in attrNonNullArgCheck()
1258 static void handleNonNullAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNonNullAttr() argument
1263 if (!S.checkFunctionOrMethodParameterIndex(D, AL, I + 1, Ex, Idx)) in handleNonNullAttr()
1269 S, getFunctionOrMethodParamType(D, Idx.getASTIndex()), AL, in handleNonNullAttr()
1282 !S.inTemplateInstantiation()) { in handleNonNullAttr()
1287 if (T->isDependentType() || S.isValidPointerAttrType(T)) in handleNonNullAttr()
1292 S.Diag(AL.getLoc(), diag::warn_attribute_nonnull_no_pointers); in handleNonNullAttr()
1298 D->addAttr(::new (S.Context) NonNullAttr(S.Context, AL, Start, Size)); in handleNonNullAttr()
1301 static void handleNonNullAttrParameter(Sema &S, ParmVarDecl *D, in handleNonNullAttrParameter() argument
1305 handleNonNullAttr(S, D, AL); in handleNonNullAttrParameter()
1307 S.Diag(AL.getLoc(), diag::warn_attribute_nonnull_parm_no_args) in handleNonNullAttrParameter()
1314 if (!attrNonNullArgCheck(S, D->getType(), AL, SourceRange(), in handleNonNullAttrParameter()
1318 D->addAttr(::new (S.Context) NonNullAttr(S.Context, AL, nullptr, 0)); in handleNonNullAttrParameter()
1321 static void handleReturnsNonNullAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleReturnsNonNullAttr() argument
1324 if (!attrNonNullArgCheck(S, ResultType, AL, SourceRange(), SR, in handleReturnsNonNullAttr()
1328 D->addAttr(::new (S.Context) ReturnsNonNullAttr(S.Context, AL)); in handleReturnsNonNullAttr()
1331 static void handleNoEscapeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNoEscapeAttr() argument
1337 if (!S.isValidPointerAttrType(T, /* RefOkay */ true)) { in handleNoEscapeAttr()
1338 S.Diag(AL.getLoc(), diag::warn_attribute_pointers_only) in handleNoEscapeAttr()
1343 D->addAttr(::new (S.Context) NoEscapeAttr(S.Context, AL)); in handleNoEscapeAttr()
1346 static void handleAssumeAlignedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAssumeAlignedAttr() argument
1349 S.AddAssumeAlignedAttr(D, AL, E, OE); in handleAssumeAlignedAttr()
1352 static void handleAllocAlignAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAllocAlignAttr() argument
1353 S.AddAllocAlignAttr(D, AL, AL.getArgAsExpr(0)); in handleAllocAlignAttr()
1448 static void handleOwnershipAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleOwnershipAttr() argument
1458 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) in handleOwnershipAttr()
1465 OwnershipAttr(S.Context, AL, nullptr, nullptr, 0).getOwnKind(); in handleOwnershipAttr()
1472 S.Diag(AL.getLoc(), diag::err_attribute_too_few_arguments) << AL << 2; in handleOwnershipAttr()
1478 S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) << AL << 1; in handleOwnershipAttr()
1488 Module = &S.PP.getIdentifierTable().get(ModuleName); in handleOwnershipAttr()
1495 if (!S.checkFunctionOrMethodParameterIndex(D, AL, i, Ex, Idx)) in handleOwnershipAttr()
1513 S.Diag(AL.getLoc(), diag::err_ownership_type) << AL << Err in handleOwnershipAttr()
1523 S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) in handleOwnershipAttr()
1533 S.Diag(I->getLocation(), diag::err_ownership_returns_index_mismatch) in handleOwnershipAttr()
1536 S.Diag(AL.getLoc(), diag::note_ownership_returns_index_mismatch) in handleOwnershipAttr()
1548 D->addAttr(::new (S.Context) in handleOwnershipAttr()
1549 OwnershipAttr(S.Context, AL, Module, Start, Size)); in handleOwnershipAttr()
1552 static void handleWeakRefAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleWeakRefAttr() argument
1555 S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1; in handleWeakRefAttr()
1571 S.Diag(AL.getLoc(), diag::err_attribute_weakref_not_global_context) in handleWeakRefAttr()
1602 if (AL.getNumArgs() && S.checkStringLiteralArgumentAttr(AL, 0, Str)) in handleWeakRefAttr()
1605 D->addAttr(::new (S.Context) AliasAttr(S.Context, AL, Str)); in handleWeakRefAttr()
1607 D->addAttr(::new (S.Context) WeakRefAttr(S.Context, AL)); in handleWeakRefAttr()
1614 static void markUsedForAliasOrIfunc(Sema &S, Decl *D, const ParsedAttr &AL, in markUsedForAliasOrIfunc() argument
1617 if (S.getASTContext().getCXXABIKind() != TargetCXXABI::Microsoft) in markUsedForAliasOrIfunc()
1619 std::unique_ptr<MangleContext> MC(S.Context.createMangleContext()); in markUsedForAliasOrIfunc()
1623 &S.Context.Idents.get(Demangled ? Demangled.get() : Str), AL.getLoc()); in markUsedForAliasOrIfunc()
1624 LookupResult LR(S, Target, Sema::LookupOrdinaryName); in markUsedForAliasOrIfunc()
1625 if (S.LookupName(LR, S.TUScope)) { in markUsedForAliasOrIfunc()
1637 ND->markUsed(S.Context); in markUsedForAliasOrIfunc()
1642 static void handleIFuncAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleIFuncAttr() argument
1644 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str)) in handleIFuncAttr()
1650 S.Diag(AL.getLoc(), diag::err_alias_is_definition) << FD << 1; in handleIFuncAttr()
1654 markUsedForAliasOrIfunc(S, D, AL, Str); in handleIFuncAttr()
1655 D->addAttr(::new (S.Context) IFuncAttr(S.Context, AL, Str)); in handleIFuncAttr()
1658 static void handleAliasAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAliasAttr() argument
1660 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str)) in handleAliasAttr()
1663 if (S.Context.getTargetInfo().getTriple().isOSDarwin()) { in handleAliasAttr()
1664 S.Diag(AL.getLoc(), diag::err_alias_not_supported_on_darwin); in handleAliasAttr()
1668 if (S.Context.getTargetInfo().getTriple().isNVPTX()) { in handleAliasAttr()
1670 ToCudaVersion(S.Context.getTargetInfo().getSDKVersion()); in handleAliasAttr()
1672 S.Diag(AL.getLoc(), diag::err_alias_not_supported_on_nvptx); in handleAliasAttr()
1678 S.Diag(AL.getLoc(), diag::err_alias_is_definition) << FD << 0; in handleAliasAttr()
1684 S.Diag(AL.getLoc(), diag::err_alias_is_definition) << VD << 0; in handleAliasAttr()
1689 markUsedForAliasOrIfunc(S, D, AL, Str); in handleAliasAttr()
1690 D->addAttr(::new (S.Context) AliasAttr(S.Context, AL, Str)); in handleAliasAttr()
1693 static void handleTLSModelAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleTLSModelAttr() argument
1697 if (!S.checkStringLiteralArgumentAttr(AL, 0, Model, &LiteralLoc)) in handleTLSModelAttr()
1703 S.Diag(LiteralLoc, diag::err_attr_tlsmodel_arg); in handleTLSModelAttr()
1707 D->addAttr(::new (S.Context) TLSModelAttr(S.Context, AL, Model)); in handleTLSModelAttr()
1710 static void handleRestrictAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleRestrictAttr() argument
1713 D->addAttr(::new (S.Context) RestrictAttr(S.Context, AL)); in handleRestrictAttr()
1717 S.Diag(AL.getLoc(), diag::warn_attribute_return_pointers_only) in handleRestrictAttr()
1721 static void handleCPUSpecificAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCPUSpecificAttr() argument
1725 if (checkAttrMutualExclusion<CPUSpecificAttr>(S, D, AL)) in handleCPUSpecificAttr()
1729 S.Diag(AL.getLoc(), diag::err_disallowed_duplicate_attribute) << AL; in handleCPUSpecificAttr()
1730 S.Diag(Other->getLocation(), diag::note_conflicting_attribute); in handleCPUSpecificAttr()
1734 if (checkAttrMutualExclusion<CPUDispatchAttr>(S, D, AL)) in handleCPUSpecificAttr()
1738 S.Diag(AL.getLoc(), diag::err_disallowed_duplicate_attribute) << AL; in handleCPUSpecificAttr()
1739 S.Diag(Other->getLocation(), diag::note_conflicting_attribute); in handleCPUSpecificAttr()
1748 S.Diag(AL.getLoc(), diag::err_attribute_dll_lambda) << AL; in handleCPUSpecificAttr()
1753 if (!AL.checkAtLeastNumArgs(S, 1)) in handleCPUSpecificAttr()
1759 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleCPUSpecificAttr()
1767 if (!S.Context.getTargetInfo().validateCPUSpecificCPUDispatch(CPUName)) { in handleCPUSpecificAttr()
1768 S.Diag(CPUArg->Loc, diag::err_invalid_cpu_specific_dispatch_value) in handleCPUSpecificAttr()
1773 const TargetInfo &Target = S.Context.getTargetInfo(); in handleCPUSpecificAttr()
1778 S.Diag(AL.getLoc(), diag::warn_multiversion_duplicate_entries); in handleCPUSpecificAttr()
1786 D->addAttr(::new (S.Context) in handleCPUSpecificAttr()
1787 CPUSpecificAttr(S.Context, AL, CPUs.data(), CPUs.size())); in handleCPUSpecificAttr()
1789 D->addAttr(::new (S.Context) in handleCPUSpecificAttr()
1790 CPUDispatchAttr(S.Context, AL, CPUs.data(), CPUs.size())); in handleCPUSpecificAttr()
1793 static void handleCommonAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCommonAttr() argument
1794 if (S.LangOpts.CPlusPlus) { in handleCommonAttr()
1795 S.Diag(AL.getLoc(), diag::err_attribute_not_supported_in_lang) in handleCommonAttr()
1800 D->addAttr(::new (S.Context) CommonAttr(S.Context, AL)); in handleCommonAttr()
1803 static void handleNakedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNakedAttr() argument
1805 const auto &Triple = S.getASTContext().getTargetInfo().getTriple(); in handleNakedAttr()
1809 S.Diag(AL.getLoc(), diag::err_attribute_not_supported_on_arch) in handleNakedAttr()
1816 if (S.getLangOpts().MSVCCompat && isa<CXXMethodDecl>(D)) { in handleNakedAttr()
1817 S.Diag(AL.getLoc(), diag::err_attribute_wrong_decl_type_str) in handleNakedAttr()
1823 D->addAttr(::new (S.Context) NakedAttr(S.Context, AL)); in handleNakedAttr()
1826 static void handleNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &Attrs) { in handleNoReturnAttr() argument
1830 S.Diag(Attrs.getLoc(), diag::warn_attribute_wrong_decl_type) in handleNoReturnAttr()
1836 D->addAttr(::new (S.Context) NoReturnAttr(S.Context, Attrs)); in handleNoReturnAttr()
1839 static void handleStandardNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &A) { in handleStandardNoReturnAttr() argument
1845 if (!S.getLangOpts().CPlusPlus && in handleStandardNoReturnAttr()
1848 S.getSourceManager().isInSystemMacro(A.getLoc()))) in handleStandardNoReturnAttr()
1849 S.Diag(A.getLoc(), diag::warn_deprecated_noreturn_spelling) << A.getRange(); in handleStandardNoReturnAttr()
1851 D->addAttr(::new (S.Context) CXX11NoReturnAttr(S.Context, A)); in handleStandardNoReturnAttr()
1854 static void handleNoCfCheckAttr(Sema &S, Decl *D, const ParsedAttr &Attrs) { in handleNoCfCheckAttr() argument
1855 if (!S.getLangOpts().CFProtectionBranch) in handleNoCfCheckAttr()
1856 S.Diag(Attrs.getLoc(), diag::warn_nocf_check_attribute_ignored); in handleNoCfCheckAttr()
1858 handleSimpleAttribute<AnyX86NoCfCheckAttr>(S, D, Attrs); in handleNoCfCheckAttr()
1884 static void handleAnalyzerNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAnalyzerNoReturnAttr() argument
1892 S.Diag(AL.getLoc(), AL.isStandardAttributeSyntax() in handleAnalyzerNoReturnAttr()
1901 D->addAttr(::new (S.Context) AnalyzerNoReturnAttr(S.Context, AL)); in handleAnalyzerNoReturnAttr()
1905 static void handleVecReturnAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleVecReturnAttr() argument
1931 S.Diag(AL.getLoc(), diag::err_repeat_attribute) << A; in handleVecReturnAttr()
1939 S.Diag(AL.getLoc(), diag::err_attribute_vecreturn_only_vector_member); in handleVecReturnAttr()
1944 S.Diag(AL.getLoc(), diag::err_attribute_vecreturn_only_pod_record); in handleVecReturnAttr()
1950 S.Diag(AL.getLoc(), diag::err_attribute_vecreturn_only_vector_member); in handleVecReturnAttr()
1956 D->addAttr(::new (S.Context) VecReturnAttr(S.Context, AL)); in handleVecReturnAttr()
1959 static void handleDependencyAttr(Sema &S, Scope *Scope, Decl *D, in handleDependencyAttr() argument
1965 S.Diag(AL.getLoc(), in handleDependencyAttr()
1971 D->addAttr(::new (S.Context) CarriesDependencyAttr(S.Context, AL)); in handleDependencyAttr()
1974 static void handleUnusedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleUnusedAttr() argument
1979 if (!S.getLangOpts().CPlusPlus17 && IsCXX17Attr) in handleUnusedAttr()
1980 S.Diag(AL.getLoc(), diag::ext_cxx17_attr) << AL; in handleUnusedAttr()
1982 D->addAttr(::new (S.Context) UnusedAttr(S.Context, AL)); in handleUnusedAttr()
1985 static void handleConstructorAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleConstructorAttr() argument
1987 if (S.getLangOpts().HLSL && AL.getNumArgs()) { in handleConstructorAttr()
1988 S.Diag(AL.getLoc(), diag::err_hlsl_init_priority_unsupported); in handleConstructorAttr()
1992 !S.checkUInt32Argument(AL, AL.getArgAsExpr(0), priority)) in handleConstructorAttr()
1995 D->addAttr(::new (S.Context) ConstructorAttr(S.Context, AL, priority)); in handleConstructorAttr()
1998 static void handleDestructorAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleDestructorAttr() argument
2001 !S.checkUInt32Argument(AL, AL.getArgAsExpr(0), priority)) in handleDestructorAttr()
2004 D->addAttr(::new (S.Context) DestructorAttr(S.Context, AL, priority)); in handleDestructorAttr()
2008 static void handleAttrWithMessage(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAttrWithMessage() argument
2011 if (AL.getNumArgs() == 1 && !S.checkStringLiteralArgumentAttr(AL, 0, Str)) in handleAttrWithMessage()
2014 D->addAttr(::new (S.Context) AttrTy(S.Context, AL, Str)); in handleAttrWithMessage()
2017 static bool checkAvailabilityAttr(Sema &S, SourceRange Range, in checkAvailabilityAttr() argument
2031 S.Diag(Range.getBegin(), diag::warn_availability_version_ordering) in checkAvailabilityAttr()
2039 S.Diag(Range.getBegin(), diag::warn_availability_version_ordering) in checkAvailabilityAttr()
2047 S.Diag(Range.getBegin(), diag::warn_availability_version_ordering) in checkAvailabilityAttr()
2244 static void handleAvailabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAvailabilityAttr() argument
2247 S.Diag(AL.getRange().getBegin(), diag::warn_deprecated_ignored_on_using) in handleAvailabilityAttr()
2252 if (!AL.checkExactlyNumArgs(S, 1)) in handleAvailabilityAttr()
2258 S.Diag(Platform->Loc, diag::warn_availability_unknown_platform) in handleAvailabilityAttr()
2281 S.Diag(AL.getLoc(), in handleAvailabilityAttr()
2291 S.Diag(AL.getLoc(), diag::warn_availability_fuchsia_unavailable_minor); in handleAvailabilityAttr()
2296 if (S.getLangOpts().HLSL && IsStrict) in handleAvailabilityAttr()
2297 S.Diag(AL.getStrictLoc(), diag::err_availability_unexpected_parameter) in handleAvailabilityAttr()
2307 if (S.getLangOpts().HLSL) { in handleAvailabilityAttr()
2312 S.Diag(EnvironmentLoc->Loc, diag::warn_availability_unknown_environment) in handleAvailabilityAttr()
2315 S.Diag(EnvironmentLoc->Loc, diag::err_availability_unexpected_parameter) in handleAvailabilityAttr()
2320 AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr( in handleAvailabilityAttr()
2329 if (S.Context.getTargetInfo().getTriple().isWatchOS()) { in handleAvailabilityAttr()
2332 NewII = &S.Context.Idents.get("watchos"); in handleAvailabilityAttr()
2334 NewII = &S.Context.Idents.get("watchos_app_extension"); in handleAvailabilityAttr()
2337 const auto *SDKInfo = S.getDarwinSDKInfoForAvailabilityChecking(); in handleAvailabilityAttr()
2376 AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr( in handleAvailabilityAttr()
2384 } else if (S.Context.getTargetInfo().getTriple().isTvOS()) { in handleAvailabilityAttr()
2389 NewII = &S.Context.Idents.get("tvos"); in handleAvailabilityAttr()
2391 NewII = &S.Context.Idents.get("tvos_app_extension"); in handleAvailabilityAttr()
2394 const auto *SDKInfo = S.getDarwinSDKInfoForAvailabilityChecking(); in handleAvailabilityAttr()
2418 AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr( in handleAvailabilityAttr()
2426 } else if (S.Context.getTargetInfo().getTriple().getOS() == in handleAvailabilityAttr()
2428 S.Context.getTargetInfo().getTriple().isMacCatalystEnvironment()) { in handleAvailabilityAttr()
2430 return S.getDarwinSDKInfoForAvailabilityChecking(AL.getRange().getBegin(), in handleAvailabilityAttr()
2437 NewII = &S.Context.Idents.get("maccatalyst"); in handleAvailabilityAttr()
2439 NewII = &S.Context.Idents.get("maccatalyst_app_extension"); in handleAvailabilityAttr()
2449 AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr( in handleAvailabilityAttr()
2468 NewII = &S.Context.Idents.get("maccatalyst"); in handleAvailabilityAttr()
2491 AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr( in handleAvailabilityAttr()
2508 static void handleExternalSourceSymbolAttr(Sema &S, Decl *D, in handleExternalSourceSymbolAttr() argument
2510 if (!AL.checkAtLeastNumArgs(S, 1) || !AL.checkAtMostNumArgs(S, 4)) in handleExternalSourceSymbolAttr()
2524 D->addAttr(::new (S.Context) ExternalSourceSymbolAttr( in handleExternalSourceSymbolAttr()
2525 S.Context, AL, Language, DefinedIn, IsGeneratedDeclaration, USR)); in handleExternalSourceSymbolAttr()
2529 static T *mergeVisibilityAttr(Sema &S, Decl *D, const AttributeCommonInfo &CI, in mergeVisibilityAttr() argument
2536 S.Diag(existingAttr->getLocation(), diag::err_mismatched_visibility); in mergeVisibilityAttr()
2537 S.Diag(CI.getLoc(), diag::note_previous_attribute); in mergeVisibilityAttr()
2540 return ::new (S.Context) T(S.Context, CI, value); in mergeVisibilityAttr()
2555 static void handleVisibilityAttr(Sema &S, Decl *D, const ParsedAttr &AL, in handleVisibilityAttr() argument
2559 S.Diag(AL.getRange().getBegin(), diag::warn_attribute_ignored) << AL; in handleVisibilityAttr()
2566 S.Diag(AL.getRange().getBegin(), diag::err_attribute_wrong_decl_type) in handleVisibilityAttr()
2574 if (!S.checkStringLiteralArgumentAttr(AL, 0, TypeStr, &LiteralLoc)) in handleVisibilityAttr()
2579 S.Diag(LiteralLoc, diag::warn_attribute_type_not_supported) << AL in handleVisibilityAttr()
2587 !S.Context.getTargetInfo().hasProtectedVisibility()) { in handleVisibilityAttr()
2588 S.Diag(AL.getLoc(), diag::warn_attribute_protected_visibility); in handleVisibilityAttr()
2594 newAttr = S.mergeTypeVisibilityAttr( in handleVisibilityAttr()
2597 newAttr = S.mergeVisibilityAttr(D, AL, type); in handleVisibilityAttr()
2603 static void handleSentinelAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSentinelAttr() argument
2608 if (E->isTypeDependent() || !(Idx = E->getIntegerConstantExpr(S.Context))) { in handleSentinelAttr()
2609 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) in handleSentinelAttr()
2615 S.Diag(AL.getLoc(), diag::err_attribute_sentinel_less_than_zero) in handleSentinelAttr()
2627 if (E->isTypeDependent() || !(Idx = E->getIntegerConstantExpr(S.Context))) { in handleSentinelAttr()
2628 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) in handleSentinelAttr()
2637 S.Diag(AL.getLoc(), diag::err_attribute_sentinel_not_zero_or_one) in handleSentinelAttr()
2646 S.Diag(AL.getLoc(), diag::warn_attribute_sentinel_named_arguments); in handleSentinelAttr()
2651 S.Diag(AL.getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0; in handleSentinelAttr()
2656 S.Diag(AL.getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0; in handleSentinelAttr()
2661 S.Diag(AL.getLoc(), diag::warn_attribute_sentinel_not_variadic) << 1; in handleSentinelAttr()
2674 S.Diag(AL.getLoc(), diag::warn_attribute_sentinel_not_variadic) << m; in handleSentinelAttr()
2678 S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type) in handleSentinelAttr()
2684 S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type) in handleSentinelAttr()
2689 D->addAttr(::new (S.Context) SentinelAttr(S.Context, AL, sentinel, nullPos)); in handleSentinelAttr()
2692 static void handleWarnUnusedResult(Sema &S, Decl *D, const ParsedAttr &AL) { in handleWarnUnusedResult() argument
2696 S.Diag(AL.getLoc(), diag::warn_attribute_void_function_method) << AL << 0; in handleWarnUnusedResult()
2701 S.Diag(AL.getLoc(), diag::warn_attribute_void_function_method) << AL << 1; in handleWarnUnusedResult()
2710 S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type_str) in handleWarnUnusedResult()
2719 const LangOptions &LO = S.getLangOpts(); in handleWarnUnusedResult()
2722 S.Diag(AL.getLoc(), diag::ext_cxx20_attr) << AL; in handleWarnUnusedResult()
2728 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, nullptr)) in handleWarnUnusedResult()
2731 S.Diag(AL.getLoc(), diag::ext_cxx17_attr) << AL; in handleWarnUnusedResult()
2737 S.Diag(AL.getLoc(), diag::warn_unused_result_typedef_unsupported_spelling) in handleWarnUnusedResult()
2742 D->addAttr(::new (S.Context) WarnUnusedResultAttr(S.Context, AL, Str)); in handleWarnUnusedResult()
2745 static void handleWeakImportAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleWeakImportAttr() argument
2750 S.Diag(AL.getLoc(), diag::warn_attribute_invalid_on_definition) in handleWeakImportAttr()
2753 (S.Context.getTargetInfo().getTriple().isOSDarwin() && in handleWeakImportAttr()
2757 S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type) in handleWeakImportAttr()
2763 D->addAttr(::new (S.Context) WeakImportAttr(S.Context, AL)); in handleWeakImportAttr()
2768 static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { in handleWorkGroupSize() argument
2772 if (!S.checkUInt32Argument(AL, E, WGSize[i], i, in handleWorkGroupSize()
2776 S.Diag(AL.getLoc(), diag::err_attribute_argument_is_zero) in handleWorkGroupSize()
2786 S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; in handleWorkGroupSize()
2788 D->addAttr(::new (S.Context) in handleWorkGroupSize()
2789 WorkGroupAttr(S.Context, AL, WGSize[0], WGSize[1], WGSize[2])); in handleWorkGroupSize()
2792 static void handleVecTypeHint(Sema &S, Decl *D, const ParsedAttr &AL) { in handleVecTypeHint() argument
2794 S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1; in handleVecTypeHint()
2799 QualType ParmType = S.GetTypeFromParser(AL.getTypeArg(), &ParmTSI); in handleVecTypeHint()
2804 !ParmType->isIntegralType(S.getASTContext()))) { in handleVecTypeHint()
2805 S.Diag(AL.getLoc(), diag::err_attribute_invalid_argument) << 2 << AL; in handleVecTypeHint()
2810 if (!S.Context.hasSameType(A->getTypeHint(), ParmType)) { in handleVecTypeHint()
2811 S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; in handleVecTypeHint()
2816 D->addAttr(::new (S.Context) VecTypeHintAttr(S.Context, AL, ParmTSI)); in handleVecTypeHint()
2860 static void handleSectionAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSectionAttr() argument
2865 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &LiteralLoc)) in handleSectionAttr()
2868 if (!S.checkSectionName(LiteralLoc, Str)) in handleSectionAttr()
2871 SectionAttr *NewAttr = S.mergeSectionAttr(D, AL, Str); in handleSectionAttr()
2876 S.UnifySection(NewAttr->getName(), in handleSectionAttr()
2882 static void handleCodeModelAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCodeModelAttr() argument
2886 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &LiteralLoc)) in handleCodeModelAttr()
2891 S.Diag(LiteralLoc, diag::err_attr_codemodel_arg) << Str; in handleCodeModelAttr()
2895 D->addAttr(::new (S.Context) CodeModelAttr(S.Context, AL, CM)); in handleCodeModelAttr()
2900 static bool checkCodeSegName(Sema &S, SourceLocation LiteralLoc, in checkCodeSegName() argument
2902 if (llvm::Error E = S.isValidSectionSpecifier(CodeSegName)) { in checkCodeSegName()
2903 S.Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target) in checkCodeSegName()
2930 static void handleCodeSegAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCodeSegAttr() argument
2933 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &LiteralLoc)) in handleCodeSegAttr()
2935 if (!checkCodeSegName(S, LiteralLoc, Str)) in handleCodeSegAttr()
2939 S.Diag(AL.getLoc(), in handleCodeSegAttr()
2947 if (CodeSegAttr *CSA = S.mergeCodeSegAttr(D, AL, Str)) in handleCodeSegAttr()
3030 static void handleTargetVersionAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleTargetVersionAttr() argument
3033 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &LiteralLoc) || in handleTargetVersionAttr()
3034 S.checkTargetVersionAttr(LiteralLoc, D, Str)) in handleTargetVersionAttr()
3037 ::new (S.Context) TargetVersionAttr(S.Context, AL, Str); in handleTargetVersionAttr()
3041 static void handleTargetAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleTargetAttr() argument
3044 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &LiteralLoc) || in handleTargetAttr()
3045 S.checkTargetAttr(LiteralLoc, Str)) in handleTargetAttr()
3048 TargetAttr *NewAttr = ::new (S.Context) TargetAttr(S.Context, AL, Str); in handleTargetAttr()
3149 static void handleTargetClonesAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleTargetClonesAttr() argument
3150 if (S.Context.getTargetInfo().getTriple().isAArch64() && in handleTargetClonesAttr()
3151 !S.Context.getTargetInfo().hasFeature("fmv")) in handleTargetClonesAttr()
3157 S.Diag(AL.getLoc(), diag::err_disallowed_duplicate_attribute) << AL; in handleTargetClonesAttr()
3158 S.Diag(Other->getLocation(), diag::note_conflicting_attribute); in handleTargetClonesAttr()
3161 if (checkAttrMutualExclusion<TargetClonesAttr>(S, D, AL)) in handleTargetClonesAttr()
3171 if (!S.checkStringLiteralArgumentAttr(AL, I, CurStr, &LiteralLoc) || in handleTargetClonesAttr()
3172 S.checkTargetClonesAttrString( in handleTargetClonesAttr()
3182 S.Diag(AL.getLoc(), diag::warn_target_clone_mixed_values); in handleTargetClonesAttr()
3184 if (S.Context.getTargetInfo().getTriple().isAArch64() && !HasDefault) { in handleTargetClonesAttr()
3191 S.Diag(AL.getLoc(), diag::err_target_clone_must_have_default); in handleTargetClonesAttr()
3199 S.Diag(D->getLocation(), diag::err_multiversion_doesnt_support) in handleTargetClonesAttr()
3207 if (S.Context.getTargetInfo().getTriple().isAArch64() && !HasNotDefault) in handleTargetClonesAttr()
3211 TargetClonesAttr *NewAttr = ::new (S.Context) in handleTargetClonesAttr()
3212 TargetClonesAttr(S.Context, AL, Strings.data(), Strings.size()); in handleTargetClonesAttr()
3216 static void handleMinVectorWidthAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleMinVectorWidthAttr() argument
3219 if (!S.checkUInt32Argument(AL, E, VecWidth)) { in handleMinVectorWidthAttr()
3226 S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL; in handleMinVectorWidthAttr()
3230 D->addAttr(::new (S.Context) MinVectorWidthAttr(S.Context, AL, VecWidth)); in handleMinVectorWidthAttr()
3233 static void handleCleanupAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCleanupAttr() argument
3243 S.Diag(Loc, diag::warn_cleanup_ext); in handleCleanupAttr()
3247 S.Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 1 in handleCleanupAttr()
3253 S.Diag(Loc, diag::warn_cleanup_ext); in handleCleanupAttr()
3254 FD = S.ResolveSingleFunctionTemplateSpecialization(ULE, true); in handleCleanupAttr()
3257 S.Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 2 in handleCleanupAttr()
3259 if (ULE->getType() == S.Context.OverloadTy) in handleCleanupAttr()
3260 S.NoteAllOverloadCandidates(ULE); in handleCleanupAttr()
3264 S.Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 0; in handleCleanupAttr()
3269 S.Diag(Loc, diag::err_attribute_cleanup_func_must_take_one_arg) in handleCleanupAttr()
3276 QualType Ty = S.Context.getPointerType(cast<VarDecl>(D)->getType()); in handleCleanupAttr()
3278 if (S.CheckAssignmentConstraints(FD->getParamDecl(0)->getLocation(), in handleCleanupAttr()
3280 S.Diag(Loc, diag::err_attribute_cleanup_func_arg_incompatible_type) in handleCleanupAttr()
3288 S.Context, NestedNameSpecifierLoc{}, FD->getLocation(), VD, false, in handleCleanupAttr()
3295 S.Context, VariableReference, UnaryOperatorKind::UO_AddrOf, in handleCleanupAttr()
3296 S.Context.getPointerType(VD->getType()), VK_PRValue, OK_Ordinary, Loc, in handleCleanupAttr()
3301 CallExpr::Create(S.Context, E, ArrayRef{AddressOfVariable}, in handleCleanupAttr()
3302 S.Context.VoidTy, VK_PRValue, Loc, FPOptionsOverride{}); in handleCleanupAttr()
3304 if (S.CheckFunctionCall(FD, FunctionCallExpression, in handleCleanupAttr()
3309 D->addAttr(::new (S.Context) CleanupAttr(S.Context, AL, FD)); in handleCleanupAttr()
3312 static void handleEnumExtensibilityAttr(Sema &S, Decl *D, in handleEnumExtensibilityAttr() argument
3315 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) in handleEnumExtensibilityAttr()
3324 S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) << AL << II; in handleEnumExtensibilityAttr()
3328 D->addAttr(::new (S.Context) in handleEnumExtensibilityAttr()
3329 EnumExtensibilityAttr(S.Context, AL, ExtensibilityKind)); in handleEnumExtensibilityAttr()
3334 static void handleFormatArgAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleFormatArgAttr() argument
3337 if (!S.checkFunctionOrMethodParameterIndex(D, AL, 1, IdxExpr, Idx)) in handleFormatArgAttr()
3343 bool NotNSStringTy = !S.ObjC().isNSStringType(Ty); in handleFormatArgAttr()
3344 if (NotNSStringTy && !S.ObjC().isCFStringType(Ty) && in handleFormatArgAttr()
3347 S.Diag(AL.getLoc(), diag::err_format_attribute_not) in handleFormatArgAttr()
3353 auto Instancetype = S.Context.getObjCInstanceTypeDecl()->getTypeForDecl(); in handleFormatArgAttr()
3357 Ty = S.Context.getObjCObjectPointerType( in handleFormatArgAttr()
3359 if (!S.ObjC().isNSStringType(Ty, /*AllowNSAttributedString=*/true) && in handleFormatArgAttr()
3360 !S.ObjC().isCFStringType(Ty) && in handleFormatArgAttr()
3363 S.Diag(AL.getLoc(), diag::err_format_attribute_result_not) in handleFormatArgAttr()
3369 D->addAttr(::new (S.Context) FormatArgAttr(S.Context, AL, Idx)); in handleFormatArgAttr()
3404 static void handleInitPriorityAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleInitPriorityAttr() argument
3405 if (!S.getLangOpts().CPlusPlus) { in handleInitPriorityAttr()
3406 S.Diag(AL.getLoc(), diag::warn_attribute_ignored) << AL; in handleInitPriorityAttr()
3410 if (S.getLangOpts().HLSL) { in handleInitPriorityAttr()
3411 S.Diag(AL.getLoc(), diag::err_hlsl_init_priority_unsupported); in handleInitPriorityAttr()
3415 if (S.getCurFunctionOrMethodDecl()) { in handleInitPriorityAttr()
3416 S.Diag(AL.getLoc(), diag::err_init_priority_object_attr); in handleInitPriorityAttr()
3421 if (S.Context.getAsArrayType(T)) in handleInitPriorityAttr()
3422 T = S.Context.getBaseElementType(T); in handleInitPriorityAttr()
3424 S.Diag(AL.getLoc(), diag::err_init_priority_object_attr); in handleInitPriorityAttr()
3431 if (!S.checkUInt32Argument(AL, E, prioritynum)) { in handleInitPriorityAttr()
3440 !S.getSourceManager().isInSystemHeader(AL.getLoc())) { in handleInitPriorityAttr()
3441 S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_range) in handleInitPriorityAttr()
3446 D->addAttr(::new (S.Context) InitPriorityAttr(S.Context, AL, prioritynum)); in handleInitPriorityAttr()
3495 static void handleFormatAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleFormatAttr() argument
3497 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) in handleFormatAttr()
3512 II = &S.Context.Idents.get(Format); in handleFormatAttr()
3522 S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) in handleFormatAttr()
3530 if (!S.checkUInt32Argument(AL, IdxExpr, Idx, 2)) in handleFormatAttr()
3534 S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds) in handleFormatAttr()
3544 S.Diag(AL.getLoc(), in handleFormatAttr()
3555 if (!S.ObjC().isNSStringType(Ty, true) && !S.ObjC().isCFStringType(Ty) && in handleFormatAttr()
3558 S.Diag(AL.getLoc(), diag::err_format_attribute_not) in handleFormatAttr()
3566 if (!S.checkUInt32Argument(AL, FirstArgExpr, FirstArg, 3)) in handleFormatAttr()
3574 S.Diag(AL.getLoc(), diag::err_format_strftime_third_parameter) in handleFormatAttr()
3583 S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds) in handleFormatAttr()
3591 S.Diag(D->getLocation(), diag::warn_gcc_requires_variadic_function) << AL; in handleFormatAttr()
3596 S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds) in handleFormatAttr()
3603 FormatAttr *NewAttr = S.mergeFormatAttr(D, AL, II, Idx, FirstArg); in handleFormatAttr()
3609 static void handleCallbackAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCallbackAttr() argument
3612 S.Diag(AL.getLoc(), diag::err_callback_attribute_no_callee) in handleCallbackAttr()
3643 S.Diag(AL.getLoc(), diag::err_callback_attribute_argument_unknown) in handleCallbackAttr()
3654 if (!S.checkUInt32Argument(AL, IdxExpr, (uint32_t &)ArgIdx, I + 1, in handleCallbackAttr()
3656 S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds) in handleCallbackAttr()
3663 S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds) in handleCallbackAttr()
3674 S.Diag(AL.getLoc(), diag::err_callback_implicit_this_not_available) in handleCallbackAttr()
3692 S.Diag(AL.getLoc(), diag::err_callback_attribute_invalid_callee) in handleCallbackAttr()
3703 S.Diag(AL.getLoc(), diag::err_callback_callee_no_function_type) in handleCallbackAttr()
3715 S.Diag(AL.getLoc(), diag::err_callback_callee_no_function_type) in handleCallbackAttr()
3721 S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) in handleCallbackAttr()
3727 S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) in handleCallbackAttr()
3733 S.Diag(AL.getLoc(), diag::err_callback_callee_is_variadic) << AL.getRange(); in handleCallbackAttr()
3739 S.Diag(AL.getLoc(), diag::err_callback_attribute_multiple) << AL.getRange(); in handleCallbackAttr()
3743 D->addAttr(::new (S.Context) CallbackAttr( in handleCallbackAttr()
3744 S.Context, AL, EncodingIndices.data(), EncodingIndices.size())); in handleCallbackAttr()
3755 static void handleCalledOnceAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCalledOnceAttr() argument
3760 S.Diag(AL.getLoc(), diag::err_called_once_attribute_wrong_type); in handleCalledOnceAttr()
3764 D->addAttr(::new (S.Context) CalledOnceAttr(S.Context, AL)); in handleCalledOnceAttr()
3767 static void handleTransparentUnionAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleTransparentUnionAttr() argument
3777 S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type) in handleTransparentUnionAttr()
3784 S.Diag(AL.getLoc(), in handleTransparentUnionAttr()
3792 S.Diag(AL.getLoc(), diag::warn_transparent_union_attribute_zero_fields); in handleTransparentUnionAttr()
3799 S.Diag(FirstField->getLocation(), in handleTransparentUnionAttr()
3807 uint64_t FirstSize = S.Context.getTypeSize(FirstType); in handleTransparentUnionAttr()
3808 uint64_t FirstAlign = S.Context.getTypeAlign(FirstType); in handleTransparentUnionAttr()
3818 if (S.Context.getTypeSize(FieldType) != FirstSize || in handleTransparentUnionAttr()
3819 S.Context.getTypeAlign(FieldType) > FirstAlign) { in handleTransparentUnionAttr()
3821 bool isSize = S.Context.getTypeSize(FieldType) != FirstSize; in handleTransparentUnionAttr()
3822 unsigned FieldBits = isSize ? S.Context.getTypeSize(FieldType) in handleTransparentUnionAttr()
3823 : S.Context.getTypeAlign(FieldType); in handleTransparentUnionAttr()
3824 S.Diag(Field->getLocation(), in handleTransparentUnionAttr()
3828 S.Diag(FirstField->getLocation(), in handleTransparentUnionAttr()
3835 RD->addAttr(::new (S.Context) TransparentUnionAttr(S.Context, AL)); in handleTransparentUnionAttr()
3847 static void handleAnnotateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAnnotateAttr() argument
3851 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str)) in handleAnnotateAttr()
3861 S.AddAnnotationAttr(D, AL, Str, Args); in handleAnnotateAttr()
3864 static void handleAlignValueAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAlignValueAttr() argument
3865 S.AddAlignValueAttr(D, AL, AL.getArgAsExpr(0)); in handleAlignValueAttr()
3908 static void handleAlignedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAlignedAttr() argument
3912 (void)S.GetTypeFromParser( in handleAlignedAttr()
3916 S.Diag(AL.getEllipsisLoc(), in handleAlignedAttr()
3922 S.DiagnoseUnexpandedParameterPack(TInfo->getTypeLoc().getBeginLoc(), in handleAlignedAttr()
3926 S.AddAlignedAttr(D, AL, TInfo, AL.isPackExpansion()); in handleAlignedAttr()
3932 S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1; in handleAlignedAttr()
3937 D->addAttr(::new (S.Context) AlignedAttr(S.Context, AL, true, nullptr)); in handleAlignedAttr()
3943 S.Diag(AL.getEllipsisLoc(), in handleAlignedAttr()
3948 if (!AL.isPackExpansion() && S.DiagnoseUnexpandedParameterPack(E)) in handleAlignedAttr()
3951 S.AddAlignedAttr(D, AL, E, AL.isPackExpansion()); in handleAlignedAttr()
3970 static bool validateAlignasAppliedType(Sema &S, Decl *D, in validateAlignasAppliedType() argument
3988 return S.Diag(AttrLoc, diag::err_attribute_wrong_decl_type) in validateAlignasAppliedType()
3994 return S.Diag(AttrLoc, diag::err_alignas_attribute_wrong_decl_type) in validateAlignasAppliedType()
4210 static void parseModeAttrArg(Sema &S, StringRef Str, unsigned &DestWidth, in parseModeAttrArg() argument
4260 DestWidth = S.Context.getTargetInfo().getRegisterWidth(); in parseModeAttrArg()
4262 DestWidth = S.Context.getTargetInfo().getCharWidth(); in parseModeAttrArg()
4266 DestWidth = S.Context.getTargetInfo().getPointerWidth(LangAS::Default); in parseModeAttrArg()
4270 DestWidth = S.Context.getTargetInfo().getUnwindWordWidth(); in parseModeAttrArg()
4281 static void handleModeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleModeAttr() argument
4285 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleModeAttr()
4292 S.AddModeAttr(D, AL, Name); in handleModeAttr()
4440 static void handleNoDebugAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNoDebugAttr() argument
4441 D->addAttr(::new (S.Context) NoDebugAttr(S.Context, AL)); in handleNoDebugAttr()
4534 static void handleAlwaysInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAlwaysInlineAttr() argument
4536 S.mergeAlwaysInlineAttr(D, AL, AL.getAttrName())) in handleAlwaysInlineAttr()
4540 static void handleMinSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleMinSizeAttr() argument
4541 if (MinSizeAttr *MinSize = S.mergeMinSizeAttr(D, AL)) in handleMinSizeAttr()
4545 static void handleOptimizeNoneAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleOptimizeNoneAttr() argument
4546 if (OptimizeNoneAttr *Optnone = S.mergeOptimizeNoneAttr(D, AL)) in handleOptimizeNoneAttr()
4550 static void handleConstantAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleConstantAttr() argument
4553 S.Diag(AL.getLoc(), diag::err_cuda_nonstatic_constdev); in handleConstantAttr()
4563 D->addAttr(::new (S.Context) CUDAConstantAttr(S.Context, AL)); in handleConstantAttr()
4566 static void handleSharedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSharedAttr() argument
4570 if (!S.getLangOpts().GPURelocatableDeviceCode && VD->hasExternalStorage() && in handleSharedAttr()
4572 S.Diag(AL.getLoc(), diag::err_cuda_extern_shared) << VD; in handleSharedAttr()
4575 if (S.getLangOpts().CUDA && VD->hasLocalStorage() && in handleSharedAttr()
4576 S.CUDA().DiagIfHostCode(AL.getLoc(), diag::err_cuda_host_shared) in handleSharedAttr()
4577 << llvm::to_underlying(S.CUDA().CurrentTarget())) in handleSharedAttr()
4579 D->addAttr(::new (S.Context) CUDASharedAttr(S.Context, AL)); in handleSharedAttr()
4582 static void handleGlobalAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleGlobalAttr() argument
4588 S.Diag(FD->getTypeSpecStartLoc(), diag::err_kern_type_not_void_return) in handleGlobalAttr()
4596 S.Diag(Method->getBeginLoc(), diag::err_kern_is_nonstatic_method) in handleGlobalAttr()
4600 S.Diag(Method->getBeginLoc(), diag::warn_kern_is_method) << Method; in handleGlobalAttr()
4603 if (FD->isInlineSpecified() && !S.getLangOpts().CUDAIsDevice) in handleGlobalAttr()
4604 S.Diag(FD->getBeginLoc(), diag::warn_kern_is_inline) << FD; in handleGlobalAttr()
4607 D->addAttr(::new (S.Context) NVPTXKernelAttr(S.Context, AL)); in handleGlobalAttr()
4609 D->addAttr(::new (S.Context) CUDAGlobalAttr(S.Context, AL)); in handleGlobalAttr()
4614 if (S.LangOpts.HIP && !S.LangOpts.CUDAIsDevice) in handleGlobalAttr()
4615 D->addAttr(NoDebugAttr::CreateImplicit(S.Context)); in handleGlobalAttr()
4618 static void handleDeviceAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleDeviceAttr() argument
4621 S.Diag(AL.getLoc(), diag::err_cuda_nonstatic_constdev); in handleDeviceAttr()
4631 D->addAttr(::new (S.Context) CUDADeviceAttr(S.Context, AL)); in handleDeviceAttr()
4634 static void handleManagedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleManagedAttr() argument
4637 S.Diag(AL.getLoc(), diag::err_cuda_nonstatic_constdev); in handleManagedAttr()
4642 D->addAttr(::new (S.Context) HIPManagedAttr(S.Context, AL)); in handleManagedAttr()
4644 D->addAttr(CUDADeviceAttr::CreateImplicit(S.Context)); in handleManagedAttr()
4647 static void handleGNUInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleGNUInlineAttr() argument
4650 S.Diag(AL.getLoc(), diag::warn_gnu_inline_attribute_requires_inline); in handleGNUInlineAttr()
4654 if (S.LangOpts.CPlusPlus && Fn->getStorageClass() != SC_Extern) in handleGNUInlineAttr()
4655 S.Diag(AL.getLoc(), diag::warn_gnu_inline_cplusplus_without_extern); in handleGNUInlineAttr()
4657 D->addAttr(::new (S.Context) GNUInlineAttr(S.Context, AL)); in handleGNUInlineAttr()
4660 static void handleCallConvAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCallConvAttr() argument
4666 if (S.CheckCallingConvAttr( in handleCallConvAttr()
4668 S.CUDA().IdentifyTarget(dyn_cast<FunctionDecl>(D)))) in handleCallConvAttr()
4672 S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type) in handleCallConvAttr()
4679 D->addAttr(::new (S.Context) FastCallAttr(S.Context, AL)); in handleCallConvAttr()
4682 D->addAttr(::new (S.Context) StdCallAttr(S.Context, AL)); in handleCallConvAttr()
4685 D->addAttr(::new (S.Context) ThisCallAttr(S.Context, AL)); in handleCallConvAttr()
4688 D->addAttr(::new (S.Context) CDeclAttr(S.Context, AL)); in handleCallConvAttr()
4691 D->addAttr(::new (S.Context) PascalAttr(S.Context, AL)); in handleCallConvAttr()
4694 D->addAttr(::new (S.Context) SwiftCallAttr(S.Context, AL)); in handleCallConvAttr()
4697 D->addAttr(::new (S.Context) SwiftAsyncCallAttr(S.Context, AL)); in handleCallConvAttr()
4700 D->addAttr(::new (S.Context) VectorCallAttr(S.Context, AL)); in handleCallConvAttr()
4703 D->addAttr(::new (S.Context) MSABIAttr(S.Context, AL)); in handleCallConvAttr()
4706 D->addAttr(::new (S.Context) SysVABIAttr(S.Context, AL)); in handleCallConvAttr()
4709 D->addAttr(::new (S.Context) RegCallAttr(S.Context, AL)); in handleCallConvAttr()
4724 D->addAttr(::new (S.Context) PcsAttr(S.Context, AL, PCS)); in handleCallConvAttr()
4728 D->addAttr(::new (S.Context) AArch64VectorPcsAttr(S.Context, AL)); in handleCallConvAttr()
4731 D->addAttr(::new (S.Context) AArch64SVEPcsAttr(S.Context, AL)); in handleCallConvAttr()
4734 D->addAttr(::new (S.Context) AMDGPUKernelCallAttr(S.Context, AL)); in handleCallConvAttr()
4737 D->addAttr(::new (S.Context) IntelOclBiccAttr(S.Context, AL)); in handleCallConvAttr()
4740 D->addAttr(::new (S.Context) PreserveMostAttr(S.Context, AL)); in handleCallConvAttr()
4743 D->addAttr(::new (S.Context) PreserveAllAttr(S.Context, AL)); in handleCallConvAttr()
4746 D->addAttr(::new (S.Context) M68kRTDAttr(S.Context, AL)); in handleCallConvAttr()
4749 D->addAttr(::new (S.Context) PreserveNoneAttr(S.Context, AL)); in handleCallConvAttr()
4752 D->addAttr(::new (S.Context) RISCVVectorCCAttr(S.Context, AL)); in handleCallConvAttr()
4759 static void handleSuppressAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSuppressAttr() argument
4762 if (!AL.checkAtLeastNumArgs(S, 1)) in handleSuppressAttr()
4770 if (!S.checkStringLiteralArgumentAttr(AL, I, RuleName, nullptr)) in handleSuppressAttr()
4775 D->addAttr(::new (S.Context) in handleSuppressAttr()
4776 SuppressAttr(S.Context, AL, DiagnosticIdentifiers.data(), in handleSuppressAttr()
4780 static void handleLifetimeCategoryAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleLifetimeCategoryAttr() argument
4784 ParmType = S.GetTypeFromParser(AL.getTypeArg(), &DerefTypeLoc); in handleLifetimeCategoryAttr()
4793 S.Diag(AL.getLoc(), diag::err_attribute_invalid_argument) in handleLifetimeCategoryAttr()
4806 if (checkAttrMutualExclusion<PointerAttr>(S, D, AL)) in handleLifetimeCategoryAttr()
4813 S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) in handleLifetimeCategoryAttr()
4817 S.Diag(OAttr->getLocation(), diag::note_conflicting_attribute); in handleLifetimeCategoryAttr()
4822 Redecl->addAttr(::new (S.Context) OwnerAttr(S.Context, AL, DerefTypeLoc)); in handleLifetimeCategoryAttr()
4825 if (checkAttrMutualExclusion<OwnerAttr>(S, D, AL)) in handleLifetimeCategoryAttr()
4832 S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) in handleLifetimeCategoryAttr()
4836 S.Diag(PAttr->getLocation(), diag::note_conflicting_attribute); in handleLifetimeCategoryAttr()
4841 Redecl->addAttr(::new (S.Context) in handleLifetimeCategoryAttr()
4842 PointerAttr(S.Context, AL, DerefTypeLoc)); in handleLifetimeCategoryAttr()
4847 static void handleRandomizeLayoutAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleRandomizeLayoutAttr() argument
4848 if (checkAttrMutualExclusion<NoRandomizeLayoutAttr>(S, D, AL)) in handleRandomizeLayoutAttr()
4851 D->addAttr(::new (S.Context) RandomizeLayoutAttr(S.Context, AL)); in handleRandomizeLayoutAttr()
4854 static void handleNoRandomizeLayoutAttr(Sema &S, Decl *D, in handleNoRandomizeLayoutAttr() argument
4856 if (checkAttrMutualExclusion<RandomizeLayoutAttr>(S, D, AL)) in handleNoRandomizeLayoutAttr()
4859 D->addAttr(::new (S.Context) NoRandomizeLayoutAttr(S.Context, AL)); in handleNoRandomizeLayoutAttr()
5083 static Expr *makeLaunchBoundsArgExpr(Sema &S, Expr *E, in makeLaunchBoundsArgExpr() argument
5086 if (S.DiagnoseUnexpandedParameterPack(E)) in makeLaunchBoundsArgExpr()
5095 if (!(I = E->getIntegerConstantExpr(S.Context))) { in makeLaunchBoundsArgExpr()
5096 S.Diag(E->getExprLoc(), diag::err_attribute_argument_n_type) in makeLaunchBoundsArgExpr()
5102 S.Diag(E->getExprLoc(), diag::err_ice_too_large) in makeLaunchBoundsArgExpr()
5107 S.Diag(E->getExprLoc(), diag::warn_attribute_argument_n_negative) in makeLaunchBoundsArgExpr()
5112 S.Context, S.Context.getConstType(S.Context.IntTy), /*consume*/ false); in makeLaunchBoundsArgExpr()
5113 ExprResult ValArg = S.PerformCopyInitialization(Entity, SourceLocation(), E); in makeLaunchBoundsArgExpr()
5160 static void handleLaunchBoundsAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleLaunchBoundsAttr() argument
5161 if (!AL.checkAtLeastNumArgs(S, 1) || !AL.checkAtMostNumArgs(S, 3)) in handleLaunchBoundsAttr()
5164 S.AddLaunchBoundsAttr(D, AL, AL.getArgAsExpr(0), in handleLaunchBoundsAttr()
5169 static void handleArgumentWithTypeTagAttr(Sema &S, Decl *D, in handleArgumentWithTypeTagAttr() argument
5172 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) in handleArgumentWithTypeTagAttr()
5178 if (!S.checkFunctionOrMethodParameterIndex(D, AL, 2, AL.getArgAsExpr(1), in handleArgumentWithTypeTagAttr()
5183 if (!S.checkFunctionOrMethodParameterIndex(D, AL, 3, AL.getArgAsExpr(2), in handleArgumentWithTypeTagAttr()
5193 S.Diag(AL.getLoc(), diag::err_attribute_pointers_only) << AL << 0; in handleArgumentWithTypeTagAttr()
5196 D->addAttr(::new (S.Context) ArgumentWithTypeTagAttr( in handleArgumentWithTypeTagAttr()
5197 S.Context, AL, AL.getArgAsIdent(0)->Ident, ArgumentIdx, TypeTagIdx, in handleArgumentWithTypeTagAttr()
5201 static void handleTypeTagForDatatypeAttr(Sema &S, Decl *D, in handleTypeTagForDatatypeAttr() argument
5204 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) in handleTypeTagForDatatypeAttr()
5209 if (!AL.checkExactlyNumArgs(S, 1)) in handleTypeTagForDatatypeAttr()
5213 S.Diag(AL.getLoc(), diag::err_attribute_wrong_decl_type) in handleTypeTagForDatatypeAttr()
5220 S.GetTypeFromParser(AL.getMatchingCType(), &MatchingCTypeLoc); in handleTypeTagForDatatypeAttr()
5223 D->addAttr(::new (S.Context) TypeTagForDatatypeAttr( in handleTypeTagForDatatypeAttr()
5224 S.Context, AL, PointerKind, MatchingCTypeLoc, AL.getLayoutCompatible(), in handleTypeTagForDatatypeAttr()
5228 static void handleXRayLogArgsAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleXRayLogArgsAttr() argument
5231 if (!S.checkFunctionOrMethodParameterIndex(D, AL, 1, AL.getArgAsExpr(0), in handleXRayLogArgsAttr()
5237 D->addAttr(::new (S.Context) in handleXRayLogArgsAttr()
5238 XRayLogArgsAttr(S.Context, AL, ArgCount.getSourceIndex())); in handleXRayLogArgsAttr()
5241 static void handlePatchableFunctionEntryAttr(Sema &S, Decl *D, in handlePatchableFunctionEntryAttr() argument
5243 if (S.Context.getTargetInfo().getTriple().isOSAIX()) { in handlePatchableFunctionEntryAttr()
5244 S.Diag(AL.getLoc(), diag::err_aix_attr_unsupported) << AL; in handlePatchableFunctionEntryAttr()
5248 if (!S.checkUInt32Argument(AL, AL.getArgAsExpr(0), Count, 0, true)) in handlePatchableFunctionEntryAttr()
5252 if (!S.checkUInt32Argument(AL, Arg, Offset, 1, true)) in handlePatchableFunctionEntryAttr()
5255 S.Diag(S.getAttrLoc(AL), diag::err_attribute_argument_out_of_range) in handlePatchableFunctionEntryAttr()
5260 D->addAttr(::new (S.Context) in handlePatchableFunctionEntryAttr()
5261 PatchableFunctionEntryAttr(S.Context, AL, Count, Offset)); in handlePatchableFunctionEntryAttr()
5264 static void handleBuiltinAliasAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleBuiltinAliasAttr() argument
5266 S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type) in handleBuiltinAliasAttr()
5275 bool IsAArch64 = S.Context.getTargetInfo().getTriple().isAArch64(); in handleBuiltinAliasAttr()
5276 bool IsARM = S.Context.getTargetInfo().getTriple().isARM(); in handleBuiltinAliasAttr()
5277 bool IsRISCV = S.Context.getTargetInfo().getTriple().isRISCV(); in handleBuiltinAliasAttr()
5278 bool IsHLSL = S.Context.getLangOpts().HLSL; in handleBuiltinAliasAttr()
5279 if ((IsAArch64 && !S.ARM().SveAliasValid(BuiltinID, AliasName)) || in handleBuiltinAliasAttr()
5280 (IsARM && !S.ARM().MveAliasValid(BuiltinID, AliasName) && in handleBuiltinAliasAttr()
5281 !S.ARM().CdeAliasValid(BuiltinID, AliasName)) || in handleBuiltinAliasAttr()
5282 (IsRISCV && !S.RISCV().isAliasValid(BuiltinID, AliasName)) || in handleBuiltinAliasAttr()
5284 S.Diag(AL.getLoc(), diag::err_attribute_builtin_alias) << AL; in handleBuiltinAliasAttr()
5288 D->addAttr(::new (S.Context) BuiltinAliasAttr(S.Context, AL, Ident)); in handleBuiltinAliasAttr()
5291 static void handleNullableTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNullableTypeAttr() argument
5297 S.Diag(AL.getRange().getBegin(), diag::err_attribute_wrong_decl_type_str) in handleNullableTypeAttr()
5302 handleSimpleAttribute<TypeNullableAttr>(S, D, AL); in handleNullableTypeAttr()
5305 static void handlePreferredTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handlePreferredTypeAttr() argument
5307 S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1; in handlePreferredTypeAttr()
5312 QualType QT = S.GetTypeFromParser(AL.getTypeArg(), &ParmTSI); in handlePreferredTypeAttr()
5314 S.RequireCompleteType(ParmTSI->getTypeLoc().getBeginLoc(), QT, in handlePreferredTypeAttr()
5317 D->addAttr(::new (S.Context) PreferredTypeAttr(S.Context, AL, ParmTSI)); in handlePreferredTypeAttr()
5339 static void handleUuidAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleUuidAttr() argument
5340 if (!S.LangOpts.CPlusPlus) { in handleUuidAttr()
5341 S.Diag(AL.getLoc(), diag::err_attribute_not_supported_in_lang) in handleUuidAttr()
5348 if (!S.checkStringLiteralArgumentAttr(AL, 0, OrigStrRef, &LiteralLoc)) in handleUuidAttr()
5359 S.Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid); in handleUuidAttr()
5366 S.Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid); in handleUuidAttr()
5370 S.Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid); in handleUuidAttr()
5383 MSGuidDecl *Guid = S.Context.getMSGuidDecl(Parsed); in handleUuidAttr()
5392 S.Diag(AL.getLoc(), diag::warn_atl_uuid_deprecated); in handleUuidAttr()
5394 UuidAttr *UA = S.mergeUuidAttr(D, AL, OrigStrRef, Guid); in handleUuidAttr()
5399 static void handleMSInheritanceAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleMSInheritanceAttr() argument
5400 if (!S.LangOpts.CPlusPlus) { in handleMSInheritanceAttr()
5401 S.Diag(AL.getLoc(), diag::err_attribute_not_supported_in_lang) in handleMSInheritanceAttr()
5405 MSInheritanceAttr *IA = S.mergeMSInheritanceAttr( in handleMSInheritanceAttr()
5409 S.Consumer.AssignInheritanceModel(cast<CXXRecordDecl>(D)); in handleMSInheritanceAttr()
5413 static void handleDeclspecThreadAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleDeclspecThreadAttr() argument
5415 if (!S.Context.getTargetInfo().isTLSSupported()) { in handleDeclspecThreadAttr()
5416 S.Diag(AL.getLoc(), diag::err_thread_unsupported); in handleDeclspecThreadAttr()
5420 S.Diag(AL.getLoc(), diag::err_declspec_thread_on_thread_variable); in handleDeclspecThreadAttr()
5424 S.Diag(AL.getLoc(), diag::err_thread_non_global) << "__declspec(thread)"; in handleDeclspecThreadAttr()
5427 D->addAttr(::new (S.Context) ThreadAttr(S.Context, AL)); in handleDeclspecThreadAttr()
5430 static void handleMSConstexprAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleMSConstexprAttr() argument
5431 if (!S.getLangOpts().isCompatibleWithMSVC(LangOptions::MSVC2022_3)) { in handleMSConstexprAttr()
5432 S.Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored) in handleMSConstexprAttr()
5438 S.Diag(AL.getLoc(), diag::err_ms_constexpr_cannot_be_applied) in handleMSConstexprAttr()
5443 if (!S.getLangOpts().CPlusPlus20 && MD->isVirtual()) { in handleMSConstexprAttr()
5444 S.Diag(AL.getLoc(), diag::err_ms_constexpr_cannot_be_applied) in handleMSConstexprAttr()
5449 D->addAttr(::new (S.Context) MSConstexprAttr(S.Context, AL)); in handleMSConstexprAttr()
5452 static void handleAbiTagAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAbiTagAttr() argument
5456 if (!S.checkStringLiteralArgumentAttr(AL, I, Tag)) in handleAbiTagAttr()
5463 S.Diag(AL.getLoc(), diag::warn_attr_abi_tag_namespace) << 0; in handleAbiTagAttr()
5467 S.Diag(AL.getLoc(), diag::warn_attr_abi_tag_namespace) << 1; in handleAbiTagAttr()
5472 } else if (!AL.checkAtLeastNumArgs(S, 1)) in handleAbiTagAttr()
5479 D->addAttr(::new (S.Context) in handleAbiTagAttr()
5480 AbiTagAttr(S.Context, AL, Tags.data(), Tags.size())); in handleAbiTagAttr()
5491 static void handleBTFDeclTagAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleBTFDeclTagAttr() argument
5493 if (!S.checkStringLiteralArgumentAttr(AL, 0, Str)) in handleBTFDeclTagAttr()
5498 D->addAttr(::new (S.Context) BTFDeclTagAttr(S.Context, AL, Str)); in handleBTFDeclTagAttr()
5507 static void handleInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleInterruptAttr() argument
5509 switch (S.Context.getTargetInfo().getTriple().getArch()) { in handleInterruptAttr()
5511 S.MSP430().handleInterruptAttr(D, AL); in handleInterruptAttr()
5515 S.MIPS().handleInterruptAttr(D, AL); in handleInterruptAttr()
5518 S.M68k().handleInterruptAttr(D, AL); in handleInterruptAttr()
5522 S.X86().handleAnyInterruptAttr(D, AL); in handleInterruptAttr()
5525 S.AVR().handleInterruptAttr(D, AL); in handleInterruptAttr()
5529 S.RISCV().handleInterruptAttr(D, AL); in handleInterruptAttr()
5532 S.ARM().handleInterruptAttr(D, AL); in handleInterruptAttr()
5537 static void handleLayoutVersion(Sema &S, Decl *D, const ParsedAttr &AL) { in handleLayoutVersion() argument
5540 if (!S.checkUInt32Argument(AL, AL.getArgAsExpr(0), Version)) in handleLayoutVersion()
5545 S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds) in handleLayoutVersion()
5555 D->addAttr(::new (S.Context) LayoutVersionAttr(S.Context, AL, Version)); in handleLayoutVersion()
5584 static void handleDLLAttr(Sema &S, Decl *D, const ParsedAttr &A) { in handleDLLAttr() argument
5586 (S.Context.getTargetInfo().shouldDLLImportComdatSymbols())) { in handleDLLAttr()
5587 S.Diag(A.getRange().getBegin(), diag::warn_attribute_ignored) << A; in handleDLLAttr()
5593 !(S.Context.getTargetInfo().shouldDLLImportComdatSymbols())) { in handleDLLAttr()
5595 S.Diag(A.getRange().getBegin(), diag::warn_attribute_ignored_on_inline) in handleDLLAttr()
5602 if ((S.Context.getTargetInfo().shouldDLLImportComdatSymbols()) && in handleDLLAttr()
5604 S.Diag(A.getRange().getBegin(), diag::err_attribute_dll_lambda) << A; in handleDLLAttr()
5610 ? (Attr *)S.mergeDLLExportAttr(D, A) in handleDLLAttr()
5611 : (Attr *)S.mergeDLLImportAttr(D, A); in handleDLLAttr()
5651 static void handleCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCapabilityAttr() argument
5663 !S.checkStringLiteralArgumentAttr(AL, 0, N, &LiteralLoc)) in handleCapabilityAttr()
5666 D->addAttr(::new (S.Context) CapabilityAttr(S.Context, AL, N)); in handleCapabilityAttr()
5669 static void handleAssertCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAssertCapabilityAttr() argument
5671 if (!checkLockFunAttrCommon(S, D, AL, Args)) in handleAssertCapabilityAttr()
5674 D->addAttr(::new (S.Context) in handleAssertCapabilityAttr()
5675 AssertCapabilityAttr(S.Context, AL, Args.data(), Args.size())); in handleAssertCapabilityAttr()
5678 static void handleAcquireCapabilityAttr(Sema &S, Decl *D, in handleAcquireCapabilityAttr() argument
5681 if (!checkLockFunAttrCommon(S, D, AL, Args)) in handleAcquireCapabilityAttr()
5684 D->addAttr(::new (S.Context) AcquireCapabilityAttr(S.Context, AL, Args.data(), in handleAcquireCapabilityAttr()
5688 static void handleTryAcquireCapabilityAttr(Sema &S, Decl *D, in handleTryAcquireCapabilityAttr() argument
5691 if (!checkTryLockFunAttrCommon(S, D, AL, Args)) in handleTryAcquireCapabilityAttr()
5694 D->addAttr(::new (S.Context) TryAcquireCapabilityAttr( in handleTryAcquireCapabilityAttr()
5695 S.Context, AL, AL.getArgAsExpr(0), Args.data(), Args.size())); in handleTryAcquireCapabilityAttr()
5698 static void handleReleaseCapabilityAttr(Sema &S, Decl *D, in handleReleaseCapabilityAttr() argument
5702 checkAttrArgsAreCapabilityObjs(S, D, AL, Args, 0, true); in handleReleaseCapabilityAttr()
5704 D->addAttr(::new (S.Context) ReleaseCapabilityAttr(S.Context, AL, Args.data(), in handleReleaseCapabilityAttr()
5708 static void handleRequiresCapabilityAttr(Sema &S, Decl *D, in handleRequiresCapabilityAttr() argument
5710 if (!AL.checkAtLeastNumArgs(S, 1)) in handleRequiresCapabilityAttr()
5715 checkAttrArgsAreCapabilityObjs(S, D, AL, Args); in handleRequiresCapabilityAttr()
5719 RequiresCapabilityAttr *RCA = ::new (S.Context) in handleRequiresCapabilityAttr()
5720 RequiresCapabilityAttr(S.Context, AL, Args.data(), Args.size()); in handleRequiresCapabilityAttr()
5725 static void handleDeprecatedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleDeprecatedAttr() argument
5728 S.Diag(AL.getLoc(), diag::warn_deprecated_anonymous_namespace); in handleDeprecatedAttr()
5736 S.Diag(AL.getRange().getBegin(), diag::warn_deprecated_ignored_on_using) in handleDeprecatedAttr()
5744 !S.checkStringLiteralArgumentAttr(AL, 0, Str)) in handleDeprecatedAttr()
5749 AL.checkAtMostNumArgs(S, 1); in handleDeprecatedAttr()
5751 !S.checkStringLiteralArgumentAttr(AL, 1, Replacement)) in handleDeprecatedAttr()
5754 if (!S.getLangOpts().CPlusPlus14 && AL.isCXX11Attribute() && !AL.isGNUScope()) in handleDeprecatedAttr()
5755 S.Diag(AL.getLoc(), diag::ext_cxx14_attr) << AL; in handleDeprecatedAttr()
5757 D->addAttr(::new (S.Context) DeprecatedAttr(S.Context, AL, Str, Replacement)); in handleDeprecatedAttr()
5761 if (const auto *S = dyn_cast<VarDecl>(D)) in isGlobalVar() local
5762 return S->hasGlobalStorage(); in isGlobalVar()
5771 static void handleNoSanitizeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNoSanitizeAttr() argument
5772 if (!AL.checkAtLeastNumArgs(S, 1)) in handleNoSanitizeAttr()
5781 if (!S.checkStringLiteralArgumentAttr(AL, I, SanitizerName, &LiteralLoc)) in handleNoSanitizeAttr()
5787 S.Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << SanitizerName; in handleNoSanitizeAttr()
5789 S.Diag(D->getLocation(), diag::warn_attribute_type_not_supported_global) in handleNoSanitizeAttr()
5794 D->addAttr(::new (S.Context) NoSanitizeAttr(S.Context, AL, Sanitizers.data(), in handleNoSanitizeAttr()
5798 static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D, in handleNoSanitizeSpecificAttr() argument
5808 S.Diag(D->getLocation(), diag::err_attribute_wrong_decl_type) in handleNoSanitizeSpecificAttr()
5825 D->addAttr(::new (S.Context) in handleNoSanitizeSpecificAttr()
5826 NoSanitizeAttr(S.Context, Info, &SanitizerName, 1)); in handleNoSanitizeSpecificAttr()
5829 static void handleInternalLinkageAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleInternalLinkageAttr() argument
5830 if (InternalLinkageAttr *Internal = S.mergeInternalLinkageAttr(D, AL)) in handleInternalLinkageAttr()
5834 static void handleZeroCallUsedRegsAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleZeroCallUsedRegsAttr() argument
5838 if (!S.checkStringLiteralArgumentAttr(AL, 0, KindStr, &LiteralLoc)) in handleZeroCallUsedRegsAttr()
5843 S.Diag(LiteralLoc, diag::warn_attribute_type_not_supported) in handleZeroCallUsedRegsAttr()
5849 D->addAttr(ZeroCallUsedRegsAttr::Create(S.Context, Kind, AL)); in handleZeroCallUsedRegsAttr()
5852 static void handleCountedByAttrField(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCountedByAttrField() argument
5884 if (S.CheckCountedByAttrOnField(FD, CountExpr, Decls, CountInBytes, OrNull)) in handleCountedByAttrField()
5887 QualType CAT = S.BuildCountAttributedArrayOrPointerType( in handleCountedByAttrField()
5892 static void handleFunctionReturnThunksAttr(Sema &S, Decl *D, in handleFunctionReturnThunksAttr() argument
5896 if (!S.checkStringLiteralArgumentAttr(AL, 0, KindStr, &LiteralLoc)) in handleFunctionReturnThunksAttr()
5901 S.Diag(LiteralLoc, diag::warn_attribute_type_not_supported) in handleFunctionReturnThunksAttr()
5909 D->addAttr(FunctionReturnThunksAttr::Create(S.Context, Kind, AL)); in handleFunctionReturnThunksAttr()
5912 static void handleAvailableOnlyInDefaultEvalMethod(Sema &S, Decl *D, in handleAvailableOnlyInDefaultEvalMethod() argument
5915 handleSimpleAttribute<AvailableOnlyInDefaultEvalMethodAttr>(S, D, AL); in handleAvailableOnlyInDefaultEvalMethod()
5918 static void handleNoMergeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNoMergeAttr() argument
5921 S.Diag(AL.getLoc(), diag::warn_attribute_ignored_non_function_pointer) in handleNoMergeAttr()
5925 D->addAttr(NoMergeAttr::Create(S.Context, AL)); in handleNoMergeAttr()
5928 static void handleNoUniqueAddressAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNoUniqueAddressAttr() argument
5929 D->addAttr(NoUniqueAddressAttr::Create(S.Context, AL)); in handleNoUniqueAddressAttr()
5932 static void handleDestroyAttr(Sema &S, Decl *D, const ParsedAttr &A) { in handleDestroyAttr() argument
5934 S.Diag(D->getLocation(), diag::err_destroy_attr_on_non_static_var) in handleDestroyAttr()
5940 handleSimpleAttribute<AlwaysDestroyAttr>(S, D, A); in handleDestroyAttr()
5942 handleSimpleAttribute<NoDestroyAttr>(S, D, A); in handleDestroyAttr()
5945 static void handleUninitializedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleUninitializedAttr() argument
5948 D->addAttr(::new (S.Context) UninitializedAttr(S.Context, AL)); in handleUninitializedAttr()
5951 static void handleMIGServerRoutineAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleMIGServerRoutineAttr() argument
5963 if (!IsKernReturnT || T.getCanonicalType() != S.getASTContext().IntTy) { in handleMIGServerRoutineAttr()
5964 S.Diag(D->getBeginLoc(), in handleMIGServerRoutineAttr()
5970 handleSimpleAttribute<MIGServerRoutineAttr>(S, D, AL); in handleMIGServerRoutineAttr()
5973 static void handleMSAllocatorAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleMSAllocatorAttr() argument
5978 S.Diag(AL.getLoc(), diag::warn_declspec_allocator_nonpointer) in handleMSAllocatorAttr()
5984 handleSimpleAttribute<MSAllocatorAttr>(S, D, AL); in handleMSAllocatorAttr()
5987 static void handleAcquireHandleAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAcquireHandleAttr() argument
5993 S.Diag(AL.getLoc(), diag::err_attribute_output_parameter) in handleAcquireHandleAttr()
5999 if (!S.checkStringLiteralArgumentAttr(AL, 0, Argument)) in handleAcquireHandleAttr()
6001 D->addAttr(AcquireHandleAttr::Create(S.Context, Argument, AL)); in handleAcquireHandleAttr()
6005 static void handleHandleAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleHandleAttr() argument
6007 if (!S.checkStringLiteralArgumentAttr(AL, 0, Argument)) in handleHandleAttr()
6009 D->addAttr(Attr::Create(S.Context, Argument, AL)); in handleHandleAttr()
6013 static void handleUnsafeBufferUsage(Sema &S, Decl *D, const ParsedAttr &AL) { in handleUnsafeBufferUsage() argument
6014 D->addAttr(Attr::Create(S.Context, AL)); in handleUnsafeBufferUsage()
6017 static void handleCFGuardAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCFGuardAttr() argument
6021 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleCFGuardAttr()
6029 S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) << AL << II; in handleCFGuardAttr()
6033 D->addAttr(::new (S.Context) CFGuardAttr(S.Context, AL, Arg)); in handleCFGuardAttr()
6048 static void handleEnforceTCBAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleEnforceTCBAttr() argument
6050 if (!S.checkStringLiteralArgumentAttr(AL, 0, Argument)) in handleEnforceTCBAttr()
6058 S.Diag(AL.getLoc(), diag::err_tcb_conflicting_attributes) in handleEnforceTCBAttr()
6069 D->addAttr(AttrTy::Create(S.Context, Argument, AL)); in handleEnforceTCBAttr()
6073 static AttrTy *mergeEnforceTCBAttrImpl(Sema &S, Decl *D, const AttrTy &AL) { in mergeEnforceTCBAttrImpl() argument
6078 S.Diag(ConflictingAttr->getLoc(), diag::err_tcb_conflicting_attributes) in mergeEnforceTCBAttrImpl()
6083 S.Diag(AL.getLoc(), diag::note_conflicting_attribute); in mergeEnforceTCBAttrImpl()
6090 ASTContext &Context = S.getASTContext(); in mergeEnforceTCBAttrImpl()
6105 static void handleVTablePointerAuthentication(Sema &S, Decl *D, in handleVTablePointerAuthentication() argument
6110 S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) << AL << 4; in handleVTablePointerAuthentication()
6115 S.Diag(AL.getLoc(), diag::err_attribute_too_few_arguments) << AL; in handleVTablePointerAuthentication()
6121 S.Diag(AL.getLoc(), diag::err_duplicated_vtable_pointer_auth) << Decl; in handleVTablePointerAuthentication()
6130 S.Diag(IL->Loc, diag::err_invalid_authentication_key) << IL->Ident; in handleVTablePointerAuthentication()
6134 !S.getLangOpts().PointerAuthCalls) { in handleVTablePointerAuthentication()
6135 S.Diag(AL.getLoc(), diag::err_no_default_vtable_pointer_auth) << 0; in handleVTablePointerAuthentication()
6139 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleVTablePointerAuthentication()
6152 S.Diag(IL->Loc, diag::err_invalid_address_discrimination) << IL->Ident; in handleVTablePointerAuthentication()
6157 !S.getLangOpts().PointerAuthCalls) { in handleVTablePointerAuthentication()
6158 S.Diag(IL->Loc, diag::err_no_default_vtable_pointer_auth) << 1; in handleVTablePointerAuthentication()
6162 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleVTablePointerAuthentication()
6174 S.Diag(IL->Loc, diag::err_invalid_extra_discrimination) << IL->Ident; in handleVTablePointerAuthentication()
6178 !S.getLangOpts().PointerAuthCalls) { in handleVTablePointerAuthentication()
6179 S.Diag(AL.getLoc(), diag::err_no_default_vtable_pointer_auth) << 2; in handleVTablePointerAuthentication()
6183 S.Diag(AL.getLoc(), diag::err_attribute_argument_type) in handleVTablePointerAuthentication()
6191 S.Diag(AL.getLoc(), diag::err_missing_custom_discrimination) << AL << 4; in handleVTablePointerAuthentication()
6196 S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) << AL << 4; in handleVTablePointerAuthentication()
6200 if (!AL.isArgExpr(3) || !S.checkUInt32Argument(AL, AL.getArgAsExpr(3), in handleVTablePointerAuthentication()
6202 S.Diag(AL.getLoc(), diag::err_invalid_custom_discrimination); in handleVTablePointerAuthentication()
6206 S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) << AL << 3; in handleVTablePointerAuthentication()
6210 Decl->addAttr(::new (S.Context) VTablePointerAuthenticationAttr( in handleVTablePointerAuthentication()
6211 S.Context, AL, KeyType, AddressDiversityMode, ED, in handleVTablePointerAuthentication()
6254 ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL, in ProcessDeclAttribute() argument
6265 if ((S.getLangOpts().CPlusPlus ? AL.isCXX11Attribute() in ProcessDeclAttribute()
6274 !AL.existsInTarget(S.Context.getTargetInfo())) { in ProcessDeclAttribute()
6275 S.Diag(AL.getLoc(), in ProcessDeclAttribute()
6289 if (S.checkCommonAttributeFeatures(D, AL, MustDelayArgs)) in ProcessDeclAttribute()
6293 AL.handleAttrWithDelayedArgs(S, D); in ProcessDeclAttribute()
6299 if (AL.getInfo().handleDeclAttribute(S, D, AL) != ParsedAttrInfo::NotHandled) in ProcessDeclAttribute()
6328 S.Diag(AL.getLoc(), diag::warn_type_attribute_deprecated_on_decl) in ProcessDeclAttribute()
6371 S.Diag(AL.getLoc(), diag::err_attribute_invalid_on_decl) in ProcessDeclAttribute()
6375 handleInterruptAttr(S, D, AL); in ProcessDeclAttribute()
6378 S.X86().handleForceAlignArgPointerAttr(D, AL); in ProcessDeclAttribute()
6381 handleSimpleAttribute<ReadOnlyPlacementAttr>(S, D, AL); in ProcessDeclAttribute()
6385 handleDLLAttr(S, D, AL); in ProcessDeclAttribute()
6388 S.AMDGPU().handleAMDGPUFlatWorkGroupSizeAttr(D, AL); in ProcessDeclAttribute()
6391 S.AMDGPU().handleAMDGPUWavesPerEUAttr(D, AL); in ProcessDeclAttribute()
6394 S.AMDGPU().handleAMDGPUNumSGPRAttr(D, AL); in ProcessDeclAttribute()
6397 S.AMDGPU().handleAMDGPUNumVGPRAttr(D, AL); in ProcessDeclAttribute()
6400 S.AMDGPU().handleAMDGPUMaxNumWorkGroupsAttr(D, AL); in ProcessDeclAttribute()
6403 S.AVR().handleSignalAttr(D, AL); in ProcessDeclAttribute()
6406 S.BPF().handlePreserveAccessIndexAttr(D, AL); in ProcessDeclAttribute()
6409 handleSimpleAttribute<BPFPreserveStaticOffsetAttr>(S, D, AL); in ProcessDeclAttribute()
6412 handleBTFDeclTagAttr(S, D, AL); in ProcessDeclAttribute()
6415 S.Wasm().handleWebAssemblyExportNameAttr(D, AL); in ProcessDeclAttribute()
6418 S.Wasm().handleWebAssemblyImportModuleAttr(D, AL); in ProcessDeclAttribute()
6421 S.Wasm().handleWebAssemblyImportNameAttr(D, AL); in ProcessDeclAttribute()
6424 S.ObjC().handleIBOutlet(D, AL); in ProcessDeclAttribute()
6427 S.ObjC().handleIBOutletCollection(D, AL); in ProcessDeclAttribute()
6430 handleIFuncAttr(S, D, AL); in ProcessDeclAttribute()
6433 handleAliasAttr(S, D, AL); in ProcessDeclAttribute()
6436 handleAlignedAttr(S, D, AL); in ProcessDeclAttribute()
6439 handleAlignValueAttr(S, D, AL); in ProcessDeclAttribute()
6442 handleAllocSizeAttr(S, D, AL); in ProcessDeclAttribute()
6445 handleAlwaysInlineAttr(S, D, AL); in ProcessDeclAttribute()
6448 handleAnalyzerNoReturnAttr(S, D, AL); in ProcessDeclAttribute()
6451 handleTLSModelAttr(S, D, AL); in ProcessDeclAttribute()
6454 handleAnnotateAttr(S, D, AL); in ProcessDeclAttribute()
6457 handleAvailabilityAttr(S, D, AL); in ProcessDeclAttribute()
6460 handleDependencyAttr(S, scope, D, AL); in ProcessDeclAttribute()
6464 handleCPUSpecificAttr(S, D, AL); in ProcessDeclAttribute()
6467 handleCommonAttr(S, D, AL); in ProcessDeclAttribute()
6470 handleConstantAttr(S, D, AL); in ProcessDeclAttribute()
6473 handlePassObjectSizeAttr(S, D, AL); in ProcessDeclAttribute()
6476 handleConstructorAttr(S, D, AL); in ProcessDeclAttribute()
6479 handleDeprecatedAttr(S, D, AL); in ProcessDeclAttribute()
6482 handleDestructorAttr(S, D, AL); in ProcessDeclAttribute()
6485 handleEnableIfAttr(S, D, AL); in ProcessDeclAttribute()
6488 handleErrorAttr(S, D, AL); in ProcessDeclAttribute()
6491 handleExcludeFromExplicitInstantiationAttr(S, D, AL); in ProcessDeclAttribute()
6494 handleDiagnoseIfAttr(S, D, AL); in ProcessDeclAttribute()
6497 handleDiagnoseAsBuiltinAttr(S, D, AL); in ProcessDeclAttribute()
6500 handleNoBuiltinAttr(S, D, AL); in ProcessDeclAttribute()
6503 handleExtVectorTypeAttr(S, D, AL); in ProcessDeclAttribute()
6506 handleExternalSourceSymbolAttr(S, D, AL); in ProcessDeclAttribute()
6509 handleMinSizeAttr(S, D, AL); in ProcessDeclAttribute()
6512 handleOptimizeNoneAttr(S, D, AL); in ProcessDeclAttribute()
6515 handleEnumExtensibilityAttr(S, D, AL); in ProcessDeclAttribute()
6518 S.SYCL().handleKernelAttr(D, AL); in ProcessDeclAttribute()
6521 handleSimpleAttribute<SYCLSpecialClassAttr>(S, D, AL); in ProcessDeclAttribute()
6524 handleFormatAttr(S, D, AL); in ProcessDeclAttribute()
6527 handleFormatArgAttr(S, D, AL); in ProcessDeclAttribute()
6530 handleCallbackAttr(S, D, AL); in ProcessDeclAttribute()
6533 handleCalledOnceAttr(S, D, AL); in ProcessDeclAttribute()
6537 handleGlobalAttr(S, D, AL); in ProcessDeclAttribute()
6540 handleDeviceAttr(S, D, AL); in ProcessDeclAttribute()
6543 handleManagedAttr(S, D, AL); in ProcessDeclAttribute()
6546 handleGNUInlineAttr(S, D, AL); in ProcessDeclAttribute()
6549 handleLaunchBoundsAttr(S, D, AL); in ProcessDeclAttribute()
6552 handleRestrictAttr(S, D, AL); in ProcessDeclAttribute()
6555 handleModeAttr(S, D, AL); in ProcessDeclAttribute()
6559 handleNonNullAttrParameter(S, PVD, AL); in ProcessDeclAttribute()
6561 handleNonNullAttr(S, D, AL); in ProcessDeclAttribute()
6564 handleReturnsNonNullAttr(S, D, AL); in ProcessDeclAttribute()
6567 handleNoEscapeAttr(S, D, AL); in ProcessDeclAttribute()
6570 handleSimpleAttribute<MaybeUndefAttr>(S, D, AL); in ProcessDeclAttribute()
6573 handleAssumeAlignedAttr(S, D, AL); in ProcessDeclAttribute()
6576 handleAllocAlignAttr(S, D, AL); in ProcessDeclAttribute()
6579 handleOwnershipAttr(S, D, AL); in ProcessDeclAttribute()
6582 handleNakedAttr(S, D, AL); in ProcessDeclAttribute()
6585 handleNoReturnAttr(S, D, AL); in ProcessDeclAttribute()
6588 handleStandardNoReturnAttr(S, D, AL); in ProcessDeclAttribute()
6591 handleNoCfCheckAttr(S, D, AL); in ProcessDeclAttribute()
6595 handleSimpleAttribute<NoThrowAttr>(S, D, AL); in ProcessDeclAttribute()
6598 handleSharedAttr(S, D, AL); in ProcessDeclAttribute()
6601 handleVecReturnAttr(S, D, AL); in ProcessDeclAttribute()
6604 S.ObjC().handleOwnershipAttr(D, AL); in ProcessDeclAttribute()
6607 S.ObjC().handlePreciseLifetimeAttr(D, AL); in ProcessDeclAttribute()
6610 S.ObjC().handleReturnsInnerPointerAttr(D, AL); in ProcessDeclAttribute()
6613 S.ObjC().handleRequiresSuperAttr(D, AL); in ProcessDeclAttribute()
6616 S.ObjC().handleBridgeAttr(D, AL); in ProcessDeclAttribute()
6619 S.ObjC().handleBridgeMutableAttr(D, AL); in ProcessDeclAttribute()
6622 S.ObjC().handleBridgeRelatedAttr(D, AL); in ProcessDeclAttribute()
6625 S.ObjC().handleDesignatedInitializer(D, AL); in ProcessDeclAttribute()
6628 S.ObjC().handleRuntimeName(D, AL); in ProcessDeclAttribute()
6631 S.ObjC().handleBoxable(D, AL); in ProcessDeclAttribute()
6634 S.ObjC().handleNSErrorDomain(D, AL); in ProcessDeclAttribute()
6639 S.ObjC().AddXConsumedAttr(D, AL, in ProcessDeclAttribute()
6640 S.ObjC().parsedAttrToRetainOwnershipKind(AL), in ProcessDeclAttribute()
6645 S, D, AL, S.ObjC().isValidOSObjectOutParameter(D), in ProcessDeclAttribute()
6651 S, D, AL, S.ObjC().isValidOSObjectOutParameter(D), in ProcessDeclAttribute()
6662 S.ObjC().handleXReturnsXRetainedAttr(D, AL); in ProcessDeclAttribute()
6665 handleWorkGroupSize<WorkGroupSizeHintAttr>(S, D, AL); in ProcessDeclAttribute()
6668 handleWorkGroupSize<ReqdWorkGroupSizeAttr>(S, D, AL); in ProcessDeclAttribute()
6671 S.OpenCL().handleSubGroupSize(D, AL); in ProcessDeclAttribute()
6674 handleVecTypeHint(S, D, AL); in ProcessDeclAttribute()
6677 handleInitPriorityAttr(S, D, AL); in ProcessDeclAttribute()
6680 handlePackedAttr(S, D, AL); in ProcessDeclAttribute()
6683 handlePreferredName(S, D, AL); in ProcessDeclAttribute()
6686 handleSectionAttr(S, D, AL); in ProcessDeclAttribute()
6689 handleCodeModelAttr(S, D, AL); in ProcessDeclAttribute()
6692 handleRandomizeLayoutAttr(S, D, AL); in ProcessDeclAttribute()
6695 handleNoRandomizeLayoutAttr(S, D, AL); in ProcessDeclAttribute()
6698 handleCodeSegAttr(S, D, AL); in ProcessDeclAttribute()
6701 handleTargetAttr(S, D, AL); in ProcessDeclAttribute()
6704 handleTargetVersionAttr(S, D, AL); in ProcessDeclAttribute()
6707 handleTargetClonesAttr(S, D, AL); in ProcessDeclAttribute()
6710 handleMinVectorWidthAttr(S, D, AL); in ProcessDeclAttribute()
6713 handleAttrWithMessage<UnavailableAttr>(S, D, AL); in ProcessDeclAttribute()
6716 S.OpenMP().handleOMPAssumeAttr(D, AL); in ProcessDeclAttribute()
6719 S.ObjC().handleDirectAttr(D, AL); in ProcessDeclAttribute()
6722 S.ObjC().handleDirectMembersAttr(D, AL); in ProcessDeclAttribute()
6723 handleSimpleAttribute<ObjCDirectMembersAttr>(S, D, AL); in ProcessDeclAttribute()
6726 S.ObjC().handleSuppresProtocolAttr(D, AL); in ProcessDeclAttribute()
6729 handleUnusedAttr(S, D, AL); in ProcessDeclAttribute()
6732 handleVisibilityAttr(S, D, AL, false); in ProcessDeclAttribute()
6735 handleVisibilityAttr(S, D, AL, true); in ProcessDeclAttribute()
6738 handleWarnUnusedResult(S, D, AL); in ProcessDeclAttribute()
6741 handleWeakRefAttr(S, D, AL); in ProcessDeclAttribute()
6744 handleWeakImportAttr(S, D, AL); in ProcessDeclAttribute()
6747 handleTransparentUnionAttr(S, D, AL); in ProcessDeclAttribute()
6750 S.ObjC().handleMethodFamilyAttr(D, AL); in ProcessDeclAttribute()
6753 S.ObjC().handleNSObject(D, AL); in ProcessDeclAttribute()
6756 S.ObjC().handleIndependentClass(D, AL); in ProcessDeclAttribute()
6759 S.ObjC().handleBlocksAttr(D, AL); in ProcessDeclAttribute()
6762 handleSentinelAttr(S, D, AL); in ProcessDeclAttribute()
6765 handleCleanupAttr(S, D, AL); in ProcessDeclAttribute()
6768 handleNoDebugAttr(S, D, AL); in ProcessDeclAttribute()
6771 S.ARM().handleCmseNSEntryAttr(D, AL); in ProcessDeclAttribute()
6794 handleCallConvAttr(S, D, AL); in ProcessDeclAttribute()
6797 handleSuppressAttr(S, D, AL); in ProcessDeclAttribute()
6801 handleLifetimeCategoryAttr(S, D, AL); in ProcessDeclAttribute()
6804 S.OpenCL().handleAccessAttr(D, AL); in ProcessDeclAttribute()
6807 S.OpenCL().handleNoSVMAttr(D, AL); in ProcessDeclAttribute()
6810 S.Swift().AddParameterABIAttr(D, AL, ParameterABI::SwiftContext); in ProcessDeclAttribute()
6813 S.Swift().AddParameterABIAttr(D, AL, ParameterABI::SwiftAsyncContext); in ProcessDeclAttribute()
6816 S.Swift().AddParameterABIAttr(D, AL, ParameterABI::SwiftErrorResult); in ProcessDeclAttribute()
6819 S.Swift().AddParameterABIAttr(D, AL, ParameterABI::SwiftIndirectResult); in ProcessDeclAttribute()
6822 handleInternalLinkageAttr(S, D, AL); in ProcessDeclAttribute()
6825 handleZeroCallUsedRegsAttr(S, D, AL); in ProcessDeclAttribute()
6828 handleFunctionReturnThunksAttr(S, D, AL); in ProcessDeclAttribute()
6831 handleNoMergeAttr(S, D, AL); in ProcessDeclAttribute()
6834 handleNoUniqueAddressAttr(S, D, AL); in ProcessDeclAttribute()
6838 handleAvailableOnlyInDefaultEvalMethod(S, D, AL); in ProcessDeclAttribute()
6845 handleCountedByAttrField(S, D, AL); in ProcessDeclAttribute()
6850 handleLayoutVersion(S, D, AL); in ProcessDeclAttribute()
6853 handleUuidAttr(S, D, AL); in ProcessDeclAttribute()
6856 handleMSInheritanceAttr(S, D, AL); in ProcessDeclAttribute()
6859 handleDeclspecThreadAttr(S, D, AL); in ProcessDeclAttribute()
6862 handleMSConstexprAttr(S, D, AL); in ProcessDeclAttribute()
6865 handleSimpleAttribute<HybridPatchableAttr>(S, D, AL); in ProcessDeclAttribute()
6870 S.HLSL().handleNumThreadsAttr(D, AL); in ProcessDeclAttribute()
6873 handleSimpleAttribute<HLSLSV_GroupIndexAttr>(S, D, AL); in ProcessDeclAttribute()
6876 S.HLSL().handleSV_DispatchThreadIDAttr(D, AL); in ProcessDeclAttribute()
6879 S.HLSL().handlePackOffsetAttr(D, AL); in ProcessDeclAttribute()
6882 S.HLSL().handleShaderAttr(D, AL); in ProcessDeclAttribute()
6885 S.HLSL().handleResourceBindingAttr(D, AL); in ProcessDeclAttribute()
6888 S.HLSL().handleResourceClassAttr(D, AL); in ProcessDeclAttribute()
6891 S.HLSL().handleParamModifierAttr(D, AL); in ProcessDeclAttribute()
6895 handleAbiTagAttr(S, D, AL); in ProcessDeclAttribute()
6898 handleCFGuardAttr(S, D, AL); in ProcessDeclAttribute()
6903 handleAssertExclusiveLockAttr(S, D, AL); in ProcessDeclAttribute()
6906 handleAssertSharedLockAttr(S, D, AL); in ProcessDeclAttribute()
6909 handlePtGuardedVarAttr(S, D, AL); in ProcessDeclAttribute()
6912 handleNoSanitizeAttr(S, D, AL); in ProcessDeclAttribute()
6915 handleNoSanitizeSpecificAttr(S, D, AL); in ProcessDeclAttribute()
6918 handleGuardedByAttr(S, D, AL); in ProcessDeclAttribute()
6921 handlePtGuardedByAttr(S, D, AL); in ProcessDeclAttribute()
6924 handleExclusiveTrylockFunctionAttr(S, D, AL); in ProcessDeclAttribute()
6927 handleLockReturnedAttr(S, D, AL); in ProcessDeclAttribute()
6930 handleLocksExcludedAttr(S, D, AL); in ProcessDeclAttribute()
6933 handleSharedTrylockFunctionAttr(S, D, AL); in ProcessDeclAttribute()
6936 handleAcquiredBeforeAttr(S, D, AL); in ProcessDeclAttribute()
6939 handleAcquiredAfterAttr(S, D, AL); in ProcessDeclAttribute()
6945 handleCapabilityAttr(S, D, AL); in ProcessDeclAttribute()
6948 handleRequiresCapabilityAttr(S, D, AL); in ProcessDeclAttribute()
6952 handleAssertCapabilityAttr(S, D, AL); in ProcessDeclAttribute()
6955 handleAcquireCapabilityAttr(S, D, AL); in ProcessDeclAttribute()
6958 handleReleaseCapabilityAttr(S, D, AL); in ProcessDeclAttribute()
6961 handleTryAcquireCapabilityAttr(S, D, AL); in ProcessDeclAttribute()
6966 handleConsumableAttr(S, D, AL); in ProcessDeclAttribute()
6969 handleCallableWhenAttr(S, D, AL); in ProcessDeclAttribute()
6972 handleParamTypestateAttr(S, D, AL); in ProcessDeclAttribute()
6975 handleReturnTypestateAttr(S, D, AL); in ProcessDeclAttribute()
6978 handleSetTypestateAttr(S, D, AL); in ProcessDeclAttribute()
6981 handleTestTypestateAttr(S, D, AL); in ProcessDeclAttribute()
6986 handleArgumentWithTypeTagAttr(S, D, AL); in ProcessDeclAttribute()
6989 handleTypeTagForDatatypeAttr(S, D, AL); in ProcessDeclAttribute()
6994 S.Swift().handleAsyncName(D, AL); in ProcessDeclAttribute()
6997 S.Swift().handleAttrAttr(D, AL); in ProcessDeclAttribute()
7000 S.Swift().handleBridge(D, AL); in ProcessDeclAttribute()
7003 S.Swift().handleError(D, AL); in ProcessDeclAttribute()
7006 S.Swift().handleName(D, AL); in ProcessDeclAttribute()
7009 S.Swift().handleNewType(D, AL); in ProcessDeclAttribute()
7012 S.Swift().handleAsyncAttr(D, AL); in ProcessDeclAttribute()
7015 S.Swift().handleAsyncError(D, AL); in ProcessDeclAttribute()
7020 handleXRayLogArgsAttr(S, D, AL); in ProcessDeclAttribute()
7024 handlePatchableFunctionEntryAttr(S, D, AL); in ProcessDeclAttribute()
7029 handleDestroyAttr(S, D, AL); in ProcessDeclAttribute()
7033 handleUninitializedAttr(S, D, AL); in ProcessDeclAttribute()
7037 S.ObjC().handleExternallyRetainedAttr(D, AL); in ProcessDeclAttribute()
7041 handleMIGServerRoutineAttr(S, D, AL); in ProcessDeclAttribute()
7045 handleMSAllocatorAttr(S, D, AL); in ProcessDeclAttribute()
7049 S.ARM().handleBuiltinAliasAttr(D, AL); in ProcessDeclAttribute()
7053 handleSimpleAttribute<ArmLocallyStreamingAttr>(S, D, AL); in ProcessDeclAttribute()
7057 S.ARM().handleNewAttr(D, AL); in ProcessDeclAttribute()
7061 handleAcquireHandleAttr(S, D, AL); in ProcessDeclAttribute()
7065 handleHandleAttr<ReleaseHandleAttr>(S, D, AL); in ProcessDeclAttribute()
7069 handleUnsafeBufferUsage<UnsafeBufferUsageAttr>(S, D, AL); in ProcessDeclAttribute()
7073 handleHandleAttr<UseHandleAttr>(S, D, AL); in ProcessDeclAttribute()
7077 handleEnforceTCBAttr<EnforceTCBAttr, EnforceTCBLeafAttr>(S, D, AL); in ProcessDeclAttribute()
7081 handleEnforceTCBAttr<EnforceTCBLeafAttr, EnforceTCBAttr>(S, D, AL); in ProcessDeclAttribute()
7085 handleBuiltinAliasAttr(S, D, AL); in ProcessDeclAttribute()
7089 handlePreferredTypeAttr(S, D, AL); in ProcessDeclAttribute()
7093 handleSimpleAttribute<UsingIfExistsAttr>(S, D, AL); in ProcessDeclAttribute()
7097 handleNullableTypeAttr(S, D, AL); in ProcessDeclAttribute()
7101 handleVTablePointerAuthentication(S, D, AL); in ProcessDeclAttribute()
7107 Scope *S, Decl *D, const ParsedAttributesView &AttrList, in ProcessDeclAttributeList() argument
7113 ProcessDeclAttribute(*this, S, D, AL, Options); in ProcessDeclAttributeList()
7209 static void checkUnusedDeclAttributes(Sema &S, const ParsedAttributesView &A) { in checkUnusedDeclAttributes() argument
7218 S.Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored) in checkUnusedDeclAttributes()
7221 S.Diag(AL.getLoc(), diag::warn_attribute_not_on_decl) << AL in checkUnusedDeclAttributes()
7279 void Sema::DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W) { in DeclApplyPragmaWeak() argument
7293 PushOnScopeChains(NewD, S); in DeclApplyPragmaWeak()
7300 void Sema::ProcessPragmaWeak(Scope *S, Decl *D) { in ProcessPragmaWeak() argument
7320 DeclApplyPragmaWeak(S, ND, W); in ProcessPragmaWeak()
7330 void Sema::ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD) { in ProcessDeclAttributes() argument
7353 ProcessDeclAttributeList(S, D, NonSlidingAttrs, Options); in ProcessDeclAttributes()
7371 ProcessDeclAttributeList(S, D, PD.getTypeObject(i).getAttrs(), in ProcessDeclAttributes()
7378 ProcessDeclAttributeList(S, D, PD.getAttributes()); in ProcessDeclAttributes()
7381 AddPragmaAttributes(S, D); in ProcessDeclAttributes()
7390 static bool isForbiddenTypeAllowed(Sema &S, Decl *D, in isForbiddenTypeAllowed() argument
7414 if (S.Context.getSourceManager().isInSystemHeader(D->getLocation())) { in isForbiddenTypeAllowed()
7425 static void handleDelayedForbiddenType(Sema &S, DelayedDiagnostic &DD, in handleDelayedForbiddenType() argument
7428 if (D && isForbiddenTypeAllowed(S, D, DD, Reason)) { in handleDelayedForbiddenType()
7430 D->addAttr(UnavailableAttr::CreateImplicit(S.Context, "", Reason, DD.Loc)); in handleDelayedForbiddenType()
7433 if (S.getLangOpts().ObjCAutoRefCount) in handleDelayedForbiddenType()
7445 S.Diag(DD.Loc, DD.getForbiddenTypeDiagnostic()) in handleDelayedForbiddenType()