Lines Matching defs:D

207 static bool threadSafetyCheckIsPointer(Sema &S, const Decl *D,
209 const auto *VD = cast<ValueDecl>(D);
328 static void checkAttrArgsAreCapabilityObjs(Sema &S, Decl *D,
337 const auto *MD = dyn_cast<const CXXMethodDecl>(D);
392 const auto *FD = dyn_cast<FunctionDecl>(D);
425 static void handlePtGuardedVarAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
426 if (!threadSafetyCheckIsPointer(S, D, AL))
429 D->addAttr(::new (S.Context) PtGuardedVarAttr(S.Context, AL));
432 static bool checkGuardedByAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL,
436 checkAttrArgsAreCapabilityObjs(S, D, AL, Args);
446 static void handleGuardedByAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
448 if (!checkGuardedByAttrCommon(S, D, AL, Arg))
451 D->addAttr(::new (S.Context) GuardedByAttr(S.Context, AL, Arg));
454 static void handlePtGuardedByAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
456 if (!checkGuardedByAttrCommon(S, D, AL, Arg))
459 if (!threadSafetyCheckIsPointer(S, D, AL))
462 D->addAttr(::new (S.Context) PtGuardedByAttr(S.Context, AL, Arg));
465 static bool checkAcquireOrderAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL,
471 QualType QT = cast<ValueDecl>(D)->getType();
478 checkAttrArgsAreCapabilityObjs(S, D, AL, Args);
485 static void handleAcquiredAfterAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
487 if (!checkAcquireOrderAttrCommon(S, D, AL, Args))
491 D->addAttr(::new (S.Context)
495 static void handleAcquiredBeforeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
497 if (!checkAcquireOrderAttrCommon(S, D, AL, Args))
501 D->addAttr(::new (S.Context)
505 static bool checkLockFunAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL,
509 checkAttrArgsAreCapabilityObjs(S, D, AL, Args, 0, /*ParamIdxOk=*/true);
514 static void handleAssertSharedLockAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
516 if (!checkLockFunAttrCommon(S, D, AL, Args))
521 D->addAttr(::new (S.Context)
525 static void handleAssertExclusiveLockAttr(Sema &S, Decl *D,
528 if (!checkLockFunAttrCommon(S, D, AL, Args))
533 D->addAttr(::new (S.Context)
543 static bool checkParamIsIntegerType(Sema &S, const Decl *D, const AttrInfo &AI,
548 if (!S.checkFunctionOrMethodParameterIndex(D, AI, AttrArgNo + 1, AttrArg,
552 QualType ParamTy = getFunctionOrMethodParamType(D, Idx.getASTIndex());
556 << AI << getFunctionOrMethodParamRange(D, Idx.getASTIndex());
562 static void handleAllocSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
566 assert(isFuncOrMethodForAttrSubject(D) && hasFunctionProto(D));
568 QualType RetTy = getFunctionOrMethodResultType(D);
579 if (!checkParamIsIntegerType(S, D, AL, /*AttrArgNo=*/0))
581 ParamIdx SizeArgNo(SizeArgNoVal, D);
590 if (!checkParamIsIntegerType(S, D, AL, /*AttrArgNo=*/1))
592 NumberArgNo = ParamIdx(Val, D);
595 D->addAttr(::new (S.Context)
599 static bool checkTryLockFunAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL,
611 checkAttrArgsAreCapabilityObjs(S, D, AL, Args, 1);
616 static void handleSharedTrylockFunctionAttr(Sema &S, Decl *D,
619 if (!checkTryLockFunAttrCommon(S, D, AL, Args))
622 D->addAttr(::new (S.Context) SharedTrylockFunctionAttr(
626 static void handleExclusiveTrylockFunctionAttr(Sema &S, Decl *D,
629 if (!checkTryLockFunAttrCommon(S, D, AL, Args))
632 D->addAttr(::new (S.Context) ExclusiveTrylockFunctionAttr(
636 static void handleLockReturnedAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
639 checkAttrArgsAreCapabilityObjs(S, D, AL, Args);
644 D->addAttr(::new (S.Context) LockReturnedAttr(S.Context, AL, Args[0]));
647 static void handleLocksExcludedAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
653 checkAttrArgsAreCapabilityObjs(S, D, AL, Args);
659 D->addAttr(::new (S.Context)
663 static bool checkFunctionConditionAttr(Sema &S, Decl *D, const ParsedAttr &AL,
680 if (isa<FunctionDecl>(D) && !Cond->isValueDependent() &&
681 !Expr::isPotentialConstantExprUnevaluated(Cond, cast<FunctionDecl>(D),
691 static void handleEnableIfAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
696 if (checkFunctionConditionAttr(S, D, AL, Cond, Msg))
697 D->addAttr(::new (S.Context) EnableIfAttr(S.Context, AL, Cond, Msg));
700 static void handleErrorAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
704 if (ErrorAttr *EA = S.mergeErrorAttr(D, AL, NewUserDiagnostic))
705 D->addAttr(EA);
708 static void handleExcludeFromExplicitInstantiationAttr(Sema &S, Decl *D,
710 const auto *PD = isa<CXXRecordDecl>(D)
711 ? cast<DeclContext>(D)
712 : D->getDeclContext()->getRedeclContext();
716 << AL << /*IsMember=*/!isa<CXXRecordDecl>(D);
719 D->addAttr(::new (S.Context)
769 static void handleDiagnoseAsBuiltinAttr(Sema &S, Decl *D,
771 const auto *DeclFD = cast<FunctionDecl>(D);
843 D->addAttr(::new (S.Context) DiagnoseAsBuiltinAttr(
847 static void handleDiagnoseIfAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
852 if (!checkFunctionConditionAttr(S, D, AL, Cond, Msg))
867 if (const auto *FD = dyn_cast<FunctionDecl>(D))
869 D->addAttr(::new (S.Context) DiagnoseIfAttr(
870 S.Context, AL, Cond, Msg, DiagType, ArgDependent, cast<NamedDecl>(D)));
873 static void handleNoBuiltinAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
886 if (const auto *NBA = D->getAttr<NoBuiltinAttr>())
913 S.Diag(D->getLocation(),
917 if (D->hasAttr<NoBuiltinAttr>())
918 D->dropAttr<NoBuiltinAttr>();
919 D->addAttr(::new (S.Context)
923 static void handlePassObjectSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
924 if (D->hasAttr<PassObjectSizeAttr>()) {
925 S.Diag(D->getBeginLoc(), diag::err_attribute_only_once_per_parameter) << AL;
945 // At this point, we have no clue if `D` belongs to a function declaration or
947 if (!cast<ParmVarDecl>(D)->getType()->isPointerType()) {
948 S.Diag(D->getBeginLoc(), diag::err_attribute_pointers_only) << AL << 1;
952 D->addAttr(::new (S.Context) PassObjectSizeAttr(S.Context, AL, (int)Type));
955 static void handleConsumableAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
972 D->addAttr(::new (S.Context) ConsumableAttr(S.Context, AL, DefaultState));
990 static void handleCallableWhenAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
994 if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), AL))
1021 D->addAttr(::new (S.Context)
1025 static void handleParamTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1047 //QualType ReturnType = cast<ParmVarDecl>(D)->getType();
1056 D->addAttr(::new (S.Context) ParamTypestateAttr(S.Context, AL, ParamState));
1059 static void handleReturnTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1081 // if (const ParmVarDecl *Param = dyn_cast<ParmVarDecl>(D)) {
1085 // dyn_cast<CXXConstructorDecl>(D)) {
1090 // ReturnType = cast<FunctionDecl>(D)->getCallResultType();
1101 D->addAttr(::new (S.Context) ReturnTypestateAttr(S.Context, AL, ReturnState));
1104 static void handleSetTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1105 if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), AL))
1123 D->addAttr(::new (S.Context) SetTypestateAttr(S.Context, AL, NewState));
1126 static void handleTestTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1127 if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), AL))
1145 D->addAttr(::new (S.Context) TestTypestateAttr(S.Context, AL, TestState));
1148 static void handleExtVectorTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1150 S.ExtVectorDecls.push_back(cast<TypedefNameDecl>(D));
1153 static void handlePackedAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1154 if (auto *TD = dyn_cast<TagDecl>(D))
1156 else if (auto *FD = dyn_cast<FieldDecl>(D)) {
1181 static void handlePreferredName(Sema &S, Decl *D, const ParsedAttr &AL) {
1182 auto *RD = cast<CXXRecordDecl>(D);
1206 D->addAttr(::new (S.Context) PreferredNameAttr(S.Context, AL, TSI));
1258 static void handleNonNullAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1263 if (!S.checkFunctionOrMethodParameterIndex(D, AL, I + 1, Ex, Idx))
1267 if (Idx.getASTIndex() < getFunctionOrMethodNumParams(D) &&
1269 S, getFunctionOrMethodParamType(D, Idx.getASTIndex()), AL,
1271 getFunctionOrMethodParamRange(D, Idx.getASTIndex())))
1283 bool AnyPointers = isFunctionOrMethodVariadic(D);
1284 for (unsigned I = 0, E = getFunctionOrMethodNumParams(D);
1286 QualType T = getFunctionOrMethodParamType(D, I);
1298 D->addAttr(::new (S.Context) NonNullAttr(S.Context, AL, Start, Size));
1301 static void handleNonNullAttrParameter(Sema &S, ParmVarDecl *D,
1304 if (D->getFunctionType()) {
1305 handleNonNullAttr(S, D, AL);
1308 << D->getSourceRange();
1314 if (!attrNonNullArgCheck(S, D->getType(), AL, SourceRange(),
1315 D->getSourceRange()))
1318 D->addAttr(::new (S.Context) NonNullAttr(S.Context, AL, nullptr, 0));
1321 static void handleReturnsNonNullAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1322 QualType ResultType = getFunctionOrMethodResultType(D);
1323 SourceRange SR = getFunctionOrMethodResultSourceRange(D);
1328 D->addAttr(::new (S.Context) ReturnsNonNullAttr(S.Context, AL));
1331 static void handleNoEscapeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1332 if (D->isInvalidDecl())
1336 QualType T = cast<ParmVarDecl>(D)->getType();
1343 D->addAttr(::new (S.Context) NoEscapeAttr(S.Context, AL));
1346 static void handleAssumeAlignedAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1349 S.AddAssumeAlignedAttr(D, AL, E, OE);
1352 static void handleAllocAlignAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1353 S.AddAllocAlignAttr(D, AL, AL.getArgAsExpr(0));
1356 void Sema::AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
1358 QualType ResultType = getFunctionOrMethodResultType(D);
1359 SourceRange SR = getFunctionOrMethodResultSourceRange(D);
1402 D->addAttr(::new (Context) AssumeAlignedAttr(Context, CI, E, OE));
1405 void Sema::AddAllocAlignAttr(Decl *D, const AttributeCommonInfo &CI,
1407 QualType ResultType = getFunctionOrMethodResultType(D);
1415 << &TmpAttr << CI.getRange() << getFunctionOrMethodResultSourceRange(D);
1420 const auto *FuncDecl = cast<FunctionDecl>(D);
1425 QualType Ty = getFunctionOrMethodParamType(D, Idx.getASTIndex());
1434 D->addAttr(::new (Context) AllocAlignAttr(Context, CI, Idx));
1448 static void handleOwnershipAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1495 if (!S.checkFunctionOrMethodParameterIndex(D, AL, i, Ex, Idx))
1499 QualType T = getFunctionOrMethodParamType(D, Idx.getASTIndex());
1519 for (const auto *I : D->specific_attrs<OwnershipAttr>()) {
1548 D->addAttr(::new (S.Context)
1552 static void handleWeakRefAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1569 const DeclContext *Ctx = D->getDeclContext()->getRedeclContext();
1572 << cast<NamedDecl>(D);
1605 D->addAttr(::new (S.Context) AliasAttr(S.Context, AL, Str));
1607 D->addAttr(::new (S.Context) WeakRefAttr(S.Context, AL));
1614 static void markUsedForAliasOrIfunc(Sema &S, Decl *D, const ParsedAttr &AL,
1642 static void handleIFuncAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1648 const auto *FD = cast<FunctionDecl>(D);
1654 markUsedForAliasOrIfunc(S, D, AL, Str);
1655 D->addAttr(::new (S.Context) IFuncAttr(S.Context, AL, Str));
1658 static void handleAliasAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1676 if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
1682 const auto *VD = cast<VarDecl>(D);
1689 markUsedForAliasOrIfunc(S, D, AL, Str);
1690 D->addAttr(::new (S.Context) AliasAttr(S.Context, AL, Str));
1693 static void handleTLSModelAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1707 D->addAttr(::new (S.Context) TLSModelAttr(S.Context, AL, Model));
1710 static void handleRestrictAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1711 QualType ResultType = getFunctionOrMethodResultType(D);
1713 D->addAttr(::new (S.Context) RestrictAttr(S.Context, AL));
1718 << AL << getFunctionOrMethodResultSourceRange(D);
1721 static void handleCPUSpecificAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1725 if (checkAttrMutualExclusion<CPUSpecificAttr>(S, D, AL))
1728 if (const auto *Other = D->getAttr<CPUDispatchAttr>()) {
1734 if (checkAttrMutualExclusion<CPUDispatchAttr>(S, D, AL))
1737 if (const auto *Other = D->getAttr<CPUSpecificAttr>()) {
1744 FunctionDecl *FD = cast<FunctionDecl>(D);
1746 if (const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
1786 D->addAttr(::new (S.Context)
1789 D->addAttr(::new (S.Context)
1793 static void handleCommonAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1800 D->addAttr(::new (S.Context) CommonAttr(S.Context, AL));
1803 static void handleNakedAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1816 if (S.getLangOpts().MSVCCompat && isa<CXXMethodDecl>(D)) {
1823 D->addAttr(::new (S.Context) NakedAttr(S.Context, AL));
1826 static void handleNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &Attrs) {
1827 if (hasDeclarator(D)) return;
1829 if (!isa<ObjCMethodDecl>(D)) {
1836 D->addAttr(::new (S.Context) NoReturnAttr(S.Context, Attrs));
1839 static void handleStandardNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &A) {
1851 D->addAttr(::new (S.Context) CXX11NoReturnAttr(S.Context, A));
1854 static void handleNoCfCheckAttr(Sema &S, Decl *D, const ParsedAttr &Attrs) {
1858 handleSimpleAttribute<AnyX86NoCfCheckAttr>(S, D, Attrs);
1884 static void handleAnalyzerNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1888 if (!isFunctionOrMethodOrBlockForAttrSubject(D)) {
1889 ValueDecl *VD = dyn_cast<ValueDecl>(D);
1901 D->addAttr(::new (S.Context) AnalyzerNoReturnAttr(S.Context, AL));
1905 static void handleVecReturnAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1930 if (VecReturnAttr *A = D->getAttr<VecReturnAttr>()) {
1935 const auto *R = cast<RecordDecl>(D);
1956 D->addAttr(::new (S.Context) VecReturnAttr(S.Context, AL));
1959 static void handleDependencyAttr(Sema &S, Scope *Scope, Decl *D,
1961 if (isa<ParmVarDecl>(D)) {
1971 D->addAttr(::new (S.Context) CarriesDependencyAttr(S.Context, AL));
1974 static void handleUnusedAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1982 D->addAttr(::new (S.Context) UnusedAttr(S.Context, AL));
1985 static void handleConstructorAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
1995 D->addAttr(::new (S.Context) ConstructorAttr(S.Context, AL, priority));
1998 static void handleDestructorAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
2004 D->addAttr(::new (S.Context) DestructorAttr(S.Context, AL, priority));
2008 static void handleAttrWithMessage(Sema &S, Decl *D, const ParsedAttr &AL) {
2014 D->addAttr(::new (S.Context) AttrTy(S.Context, AL, Str));
2075 NamedDecl *D, const AttributeCommonInfo &CI, IdentifierInfo *Platform,
2098 if (D->hasAttrs()) {
2099 AttrVec &Attrs = D->getAttrs();
2244 static void handleAvailabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
2246 D)) {
2261 auto *ND = dyn_cast<NamedDecl>(D);
2325 D->addAttr(NewAttr);
2382 D->addAttr(NewAttr);
2424 D->addAttr(NewAttr);
2457 D->addAttr(NewAttr);
2501 D->addAttr(NewAttr);
2508 static void handleExternalSourceSymbolAttr(Sema &S, Decl *D,
2524 D->addAttr(::new (S.Context) ExternalSourceSymbolAttr(
2529 static T *mergeVisibilityAttr(Sema &S, Decl *D, const AttributeCommonInfo &CI,
2531 T *existingAttr = D->getAttr<T>();
2538 D->dropAttr<T>();
2543 VisibilityAttr *Sema::mergeVisibilityAttr(Decl *D,
2546 return ::mergeVisibilityAttr<VisibilityAttr>(*this, D, CI, Vis);
2550 Sema::mergeTypeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI,
2552 return ::mergeVisibilityAttr<TypeVisibilityAttr>(*this, D, CI, Vis);
2555 static void handleVisibilityAttr(Sema &S, Decl *D, const ParsedAttr &AL,
2558 if (isa<TypedefNameDecl>(D)) {
2564 if (isTypeVisibility && !(isa<TagDecl>(D) || isa<ObjCInterfaceDecl>(D) ||
2565 isa<NamespaceDecl>(D))) {
2595 D, AL, (TypeVisibilityAttr::VisibilityType)type);
2597 newAttr = S.mergeVisibilityAttr(D, AL, type);
2600 D->addAttr(newAttr);
2603 static void handleSentinelAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
2643 if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
2654 } else if (const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
2659 } else if (const auto *BD = dyn_cast<BlockDecl>(D)) {
2664 } else if (const auto *V = dyn_cast<VarDecl>(D)) {
2668 ? D->getFunctionType()
2689 D->addAttr(::new (S.Context) SentinelAttr(S.Context, AL, sentinel, nullPos));
2692 static void handleWarnUnusedResult(Sema &S, Decl *D, const ParsedAttr &AL) {
2693 if (D->getFunctionType() &&
2694 D->getFunctionType()->getReturnType()->isVoidType() &&
2695 !isa<CXXConstructorDecl>(D)) {
2699 if (const auto *MD = dyn_cast<ObjCMethodDecl>(D))
2709 if (isa<VarDecl>(D))
2736 isa<TypedefNameDecl>(D)) {
2742 D->addAttr(::new (S.Context) WarnUnusedResultAttr(S.Context, AL, Str));
2745 static void handleWeakImportAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
2748 if (!D->canBeWeakImported(isDef)) {
2752 else if (isa<ObjCPropertyDecl>(D) || isa<ObjCMethodDecl>(D) ||
2754 (isa<ObjCInterfaceDecl>(D) || isa<EnumDecl>(D)))) {
2763 D->addAttr(::new (S.Context) WeakImportAttr(S.Context, AL));
2768 static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) {
2782 WorkGroupAttr *Existing = D->getAttr<WorkGroupAttr>();
2788 D->addAttr(::new (S.Context)
2792 static void handleVecTypeHint(Sema &S, Decl *D, const ParsedAttr &AL) {
2809 if (VecTypeHintAttr *A = D->getAttr<VecTypeHintAttr>()) {
2816 D->addAttr(::new (S.Context) VecTypeHintAttr(S.Context, AL, ParmTSI));
2819 SectionAttr *Sema::mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI,
2823 if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
2828 if (SectionAttr *ExistingAttr = D->getAttr<SectionAttr>()) {
2860 static void handleSectionAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
2871 SectionAttr *NewAttr = S.mergeSectionAttr(D, AL, Str);
2873 D->addAttr(NewAttr);
2875 ObjCPropertyDecl>(D))
2878 cast<NamedDecl>(D));
2882 static void handleCodeModelAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
2895 D->addAttr(::new (S.Context) CodeModelAttr(S.Context, AL, CM));
2911 CodeSegAttr *Sema::mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI,
2915 if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
2919 if (const auto *ExistingAttr = D->getAttr<CodeSegAttr>()) {
2930 static void handleCodeSegAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
2937 if (const auto *ExistingAttr = D->getAttr<CodeSegAttr>()) {
2945 D->dropAttr<CodeSegAttr>();
2947 if (CodeSegAttr *CSA = S.mergeCodeSegAttr(D, AL, Str))
2948 D->addAttr(CSA);
3012 bool Sema::checkTargetVersionAttr(SourceLocation LiteralLoc, Decl *D,
3030 static void handleTargetVersionAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
3034 S.checkTargetVersionAttr(LiteralLoc, D, Str))
3038 D->addAttr(NewAttr);
3041 static void handleTargetAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
3049 D->addAttr(NewAttr);
3054 Decl *D, bool &HasDefault, bool &HasCommas, bool &HasNotDefault,
3149 static void handleTargetClonesAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
3156 if (const auto *Other = D->getAttr<TargetClonesAttr>()) {
3161 if (checkAttrMutualExclusion<TargetClonesAttr>(S, D, AL))
3174 cast<StringLiteral>(AL.getArgAsExpr(I)->IgnoreParenCasts()), D,
3197 if (const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
3199 S.Diag(D->getLocation(), diag::err_multiversion_doesnt_support)
3210 cast<FunctionDecl>(D)->setIsMultiVersion();
3213 D->addAttr(NewAttr);
3216 static void handleMinVectorWidthAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
3224 MinVectorWidthAttr *Existing = D->getAttr<MinVectorWidthAttr>();
3230 D->addAttr(::new (S.Context) MinVectorWidthAttr(S.Context, AL, VecWidth));
3233 static void handleCleanupAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
3276 QualType Ty = S.Context.getPointerType(cast<VarDecl>(D)->getType());
3284 VarDecl *VD = cast<VarDecl>(D);
3309 D->addAttr(::new (S.Context) CleanupAttr(S.Context, AL, FD));
3312 static void handleEnumExtensibilityAttr(Sema &S, Decl *D,
3328 D->addAttr(::new (S.Context)
3334 static void handleFormatArgAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
3337 if (!S.checkFunctionOrMethodParameterIndex(D, AL, 1, IdxExpr, Idx))
3341 QualType Ty = getFunctionOrMethodParamType(D, Idx.getASTIndex());
3348 << IdxExpr->getSourceRange() << getFunctionOrMethodParamRange(D, 0);
3351 Ty = getFunctionOrMethodResultType(D);
3355 if (auto *OMD = dyn_cast<ObjCMethodDecl>(D))
3365 << IdxExpr->getSourceRange() << getFunctionOrMethodParamRange(D, 0);
3369 D->addAttr(::new (S.Context) FormatArgAttr(S.Context, AL, Idx));
3404 static void handleInitPriorityAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
3420 QualType T = cast<VarDecl>(D)->getType();
3446 D->addAttr(::new (S.Context) InitPriorityAttr(S.Context, AL, prioritynum));
3449 ErrorAttr *Sema::mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI,
3451 if (const auto *EA = D->getAttr<ErrorAttr>()) {
3469 D->dropAttr<ErrorAttr>();
3474 FormatAttr *Sema::mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI,
3478 for (auto *F : D->specific_attrs<FormatAttr>()) {
3495 static void handleFormatAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
3504 bool HasImplicitThisParam = isInstanceMethod(D);
3505 unsigned NumArgs = getFunctionOrMethodNumParams(D) + HasImplicitThisParam;
3553 QualType Ty = getFunctionOrMethodParamType(D, ArgIdx);
3559 << IdxExpr->getSourceRange() << getFunctionOrMethodParamRange(D, ArgIdx);
3578 } else if (isFunctionOrMethodVariadic(D)) {
3591 S.Diag(D->getLocation(), diag::warn_gcc_requires_variadic_function) << AL;
3603 FormatAttr *NewAttr = S.mergeFormatAttr(D, AL, II, Idx, FirstArg);
3605 D->addAttr(NewAttr);
3609 static void handleCallbackAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
3617 bool HasImplicitThisParam = isInstanceMethod(D);
3618 int32_t NumArgs = getFunctionOrMethodNumParams(D);
3620 FunctionDecl *FD = D->getAsFunction();
3700 getFunctionOrMethodParamType(D, CalleeIdx - HasImplicitThisParam)
3738 if (D->hasAttr<CallbackAttr>()) {
3743 D->addAttr(::new (S.Context) CallbackAttr(
3755 static void handleCalledOnceAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
3757 QualType T = cast<ParmVarDecl>(D)->getType();
3764 D->addAttr(::new (S.Context) CalledOnceAttr(S.Context, AL));
3767 static void handleTransparentUnionAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
3770 const auto *TD = dyn_cast<TypedefNameDecl>(D);
3774 RD = dyn_cast<RecordDecl>(D);
3838 void Sema::AddAnnotationAttr(Decl *D, const AttributeCommonInfo &CI,
3843 D->addAttr(Attr);
3847 static void handleAnnotateAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
3861 S.AddAnnotationAttr(D, AL, Str, Args);
3864 static void handleAlignValueAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
3865 S.AddAlignValueAttr(D, AL, AL.getArgAsExpr(0));
3868 void Sema::AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E) {
3873 if (const auto *TD = dyn_cast<TypedefNameDecl>(D))
3875 else if (const auto *VD = dyn_cast<ValueDecl>(D))
3883 << &TmpAttr << T << D->getSourceRange();
3900 D->addAttr(::new (Context) AlignValueAttr(Context, CI, ICE.get()));
3905 D->addAttr(::new (Context) AlignValueAttr(Context, CI, E));
3908 static void handleAlignedAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
3926 S.AddAlignedAttr(D, AL, TInfo, AL.isPackExpansion());
3937 D->addAttr(::new (S.Context) AlignedAttr(S.Context, AL, true, nullptr));
3951 S.AddAlignedAttr(D, AL, E, AL.isPackExpansion());
3970 static bool validateAlignasAppliedType(Sema &S, Decl *D,
3974 if (isa<ParmVarDecl>(D)) {
3976 } else if (const auto *VD = dyn_cast<VarDecl>(D)) {
3981 } else if (const auto *FD = dyn_cast<FieldDecl>(D)) {
3984 } else if (const auto *ED = dyn_cast<EnumDecl>(D)) {
3987 } else if (!isa<TagDecl>(D)) {
4000 void Sema::AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E,
4007 validateAlignasAppliedType(*this, D, TmpAttr, AttrLoc))
4014 if (const auto *TND = dyn_cast<TypedefNameDecl>(D)) {
4025 D->addAttr(AA);
4059 const auto *VD = dyn_cast<VarDecl>(D);
4087 D->addAttr(AA);
4090 void Sema::AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI,
4097 validateAlignasAppliedType(*this, D, TmpAttr, AttrLoc))
4104 if (const auto *TND = dyn_cast<TypedefNameDecl>(D)) {
4114 D->addAttr(AA);
4118 const auto *VD = dyn_cast<VarDecl>(D);
4135 D->addAttr(AA);
4138 void Sema::CheckAlignasUnderalignment(Decl *D) {
4139 assert(D->hasAttrs() && "no attributes on decl");
4142 if (const auto *VD = dyn_cast<ValueDecl>(D)) {
4145 UnderlyingTy = DiagTy = Context.getTagDeclType(cast<TagDecl>(D));
4146 if (const auto *ED = dyn_cast<EnumDecl>(D))
4159 for (auto *I : D->specific_attrs<AlignedAttr>()) {
4228 case 'D':
4281 static void handleModeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
4292 S.AddModeAttr(D, AL, Name);
4295 void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo &CI,
4340 if (const auto *TD = dyn_cast<TypedefNameDecl>(D))
4342 else if (const auto *ED = dyn_cast<EnumDecl>(D)) {
4349 OldTy = cast<ValueDecl>(D)->getType();
4352 D->addAttr(::new (Context) ModeAttr(Context, CI, Name));
4365 if ((isa<EnumDecl>(D) || OldElemTy->getAs<EnumType>()) &&
4430 if (auto *TD = dyn_cast<TypedefNameDecl>(D))
4432 else if (auto *ED = dyn_cast<EnumDecl>(D))
4435 cast<ValueDecl>(D)->setType(NewTy);
4437 D->addAttr(::new (Context) ModeAttr(Context, CI, Name));
4440 static void handleNoDebugAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
4441 D->addAttr(::new (S.Context) NoDebugAttr(S.Context, AL));
4444 AlwaysInlineAttr *Sema::mergeAlwaysInlineAttr(Decl *D,
4447 if (OptimizeNoneAttr *Optnone = D->getAttr<OptimizeNoneAttr>()) {
4453 if (D->hasAttr<AlwaysInlineAttr>())
4459 InternalLinkageAttr *Sema::mergeInternalLinkageAttr(Decl *D,
4461 if (const auto *VD = dyn_cast<VarDecl>(D)) {
4481 Sema::mergeInternalLinkageAttr(Decl *D, const InternalLinkageAttr &AL) {
4482 if (const auto *VD = dyn_cast<VarDecl>(D)) {
4502 MinSizeAttr *Sema::mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI) {
4503 if (OptimizeNoneAttr *Optnone = D->getAttr<OptimizeNoneAttr>()) {
4509 if (D->hasAttr<MinSizeAttr>())
4515 OptimizeNoneAttr *Sema::mergeOptimizeNoneAttr(Decl *D,
4517 if (AlwaysInlineAttr *Inline = D->getAttr<AlwaysInlineAttr>()) {
4520 D->dropAttr<AlwaysInlineAttr>();
4522 if (MinSizeAttr *MinSize = D->getAttr<MinSizeAttr>()) {
4525 D->dropAttr<MinSizeAttr>();
4528 if (D->hasAttr<OptimizeNoneAttr>())
4534 static void handleAlwaysInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
4536 S.mergeAlwaysInlineAttr(D, AL, AL.getAttrName()))
4537 D->addAttr(Inline);
4540 static void handleMinSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
4541 if (MinSizeAttr *MinSize = S.mergeMinSizeAttr(D, AL))
4542 D->addAttr(MinSize);
4545 static void handleOptimizeNoneAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
4546 if (OptimizeNoneAttr *Optnone = S.mergeOptimizeNoneAttr(D, AL))
4547 D->addAttr(Optnone);
4550 static void handleConstantAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
4551 const auto *VD = cast<VarDecl>(D);
4558 if (auto *A = D->getAttr<CUDAConstantAttr>()) {
4561 D->dropAttr<CUDAConstantAttr>();
4563 D->addAttr(::new (S.Context) CUDAConstantAttr(S.Context, AL));
4566 static void handleSharedAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
4567 const auto *VD = cast<VarDecl>(D);
4579 D->addAttr(::new (S.Context) CUDASharedAttr(S.Context, AL));
4582 static void handleGlobalAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
4583 const auto *FD = cast<FunctionDecl>(D);
4607 D->addAttr(::new (S.Context) NVPTXKernelAttr(S.Context, AL));
4609 D->addAttr(::new (S.Context) CUDAGlobalAttr(S.Context, AL));
4615 D->addAttr(NoDebugAttr::CreateImplicit(S.Context));
4618 static void handleDeviceAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
4619 if (const auto *VD = dyn_cast<VarDecl>(D)) {
4626 if (auto *A = D->getAttr<CUDADeviceAttr>()) {
4629 D->dropAttr<CUDADeviceAttr>();
4631 D->addAttr(::new (S.Context) CUDADeviceAttr(S.Context, AL));
4634 static void handleManagedAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
4635 if (const auto *VD = dyn_cast<VarDecl>(D)) {
4641 if (!D->hasAttr<HIPManagedAttr>())
4642 D->addAttr(::new (S.Context) HIPManagedAttr(S.Context, AL));
4643 if (!D->hasAttr<CUDADeviceAttr>())
4644 D->addAttr(CUDADeviceAttr::CreateImplicit(S.Context));
4647 static void handleGNUInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
4648 const auto *Fn = cast<FunctionDecl>(D);
4657 D->addAttr(::new (S.Context) GNUInlineAttr(S.Context, AL));
4660 static void handleCallConvAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
4661 if (hasDeclarator(D)) return;
4668 S.CUDA().IdentifyTarget(dyn_cast<FunctionDecl>(D))))
4671 if (!isa<ObjCMethodDecl>(D)) {
4679 D->addAttr(::new (S.Context) FastCallAttr(S.Context, AL));
4682 D->addAttr(::new (S.Context) StdCallAttr(S.Context, AL));
4685 D->addAttr(::new (S.Context) ThisCallAttr(S.Context, AL));
4688 D->addAttr(::new (S.Context) CDeclAttr(S.Context, AL));
4691 D->addAttr(::new (S.Context) PascalAttr(S.Context, AL));
4694 D->addAttr(::new (S.Context) SwiftCallAttr(S.Context, AL));
4697 D->addAttr(::new (S.Context) SwiftAsyncCallAttr(S.Context, AL));
4700 D->addAttr(::new (S.Context) VectorCallAttr(S.Context, AL));
4703 D->addAttr(::new (S.Context) MSABIAttr(S.Context, AL));
4706 D->addAttr(::new (S.Context) SysVABIAttr(S.Context, AL));
4709 D->addAttr(::new (S.Context) RegCallAttr(S.Context, AL));
4724 D->addAttr(::new (S.Context) PcsAttr(S.Context, AL, PCS));
4728 D->addAttr(::new (S.Context) AArch64VectorPcsAttr(S.Context, AL));
4731 D->addAttr(::new (S.Context) AArch64SVEPcsAttr(S.Context, AL));
4734 D->addAttr(::new (S.Context) AMDGPUKernelCallAttr(S.Context, AL));
4737 D->addAttr(::new (S.Context) IntelOclBiccAttr(S.Context, AL));
4740 D->addAttr(::new (S.Context) PreserveMostAttr(S.Context, AL));
4743 D->addAttr(::new (S.Context) PreserveAllAttr(S.Context, AL));
4746 D->addAttr(::new (S.Context) M68kRTDAttr(S.Context, AL));
4749 D->addAttr(::new (S.Context) PreserveNoneAttr(S.Context, AL));
4752 D->addAttr(::new (S.Context) RISCVVectorCCAttr(S.Context, AL));
4759 static void handleSuppressAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
4775 D->addAttr(::new (S.Context)
4780 static void handleLifetimeCategoryAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
4804 D = D->getCanonicalDecl();
4806 if (checkAttrMutualExclusion<PointerAttr>(S, D, AL))
4808 if (const auto *OAttr = D->getAttr<OwnerAttr>()) {
4821 for (Decl *Redecl : D->redecls()) {
4825 if (checkAttrMutualExclusion<OwnerAttr>(S, D, AL))
4827 if (const auto *PAttr = D->getAttr<PointerAttr>()) {
4840 for (Decl *Redecl : D->redecls()) {
4847 static void handleRandomizeLayoutAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
4848 if (checkAttrMutualExclusion<NoRandomizeLayoutAttr>(S, D, AL))
4850 if (!D->hasAttr<RandomizeLayoutAttr>())
4851 D->addAttr(::new (S.Context) RandomizeLayoutAttr(S.Context, AL));
4854 static void handleNoRandomizeLayoutAttr(Sema &S, Decl *D,
4856 if (checkAttrMutualExclusion<RandomizeLayoutAttr>(S, D, AL))
4858 if (!D->hasAttr<NoRandomizeLayoutAttr>())
4859 D->addAttr(::new (S.Context) NoRandomizeLayoutAttr(S.Context, AL));
5153 void Sema::AddLaunchBoundsAttr(Decl *D, const AttributeCommonInfo &CI,
5157 D->addAttr(Attr);
5160 static void handleLaunchBoundsAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5164 S.AddLaunchBoundsAttr(D, AL, AL.getArgAsExpr(0),
5169 static void handleArgumentWithTypeTagAttr(Sema &S, Decl *D,
5178 if (!S.checkFunctionOrMethodParameterIndex(D, AL, 2, AL.getArgAsExpr(1),
5183 if (!S.checkFunctionOrMethodParameterIndex(D, AL, 3, AL.getArgAsExpr(2),
5191 if (ArgumentIdxAST >= getFunctionOrMethodNumParams(D) ||
5192 !getFunctionOrMethodParamType(D, ArgumentIdxAST)->isPointerType())
5196 D->addAttr(::new (S.Context) ArgumentWithTypeTagAttr(
5201 static void handleTypeTagForDatatypeAttr(Sema &S, Decl *D,
5212 if (!isa<VarDecl>(D)) {
5223 D->addAttr(::new (S.Context) TypeTagForDatatypeAttr(
5228 static void handleXRayLogArgsAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5231 if (!S.checkFunctionOrMethodParameterIndex(D, AL, 1, AL.getArgAsExpr(0),
5237 D->addAttr(::new (S.Context)
5241 static void handlePatchableFunctionEntryAttr(Sema &S, Decl *D,
5260 D->addAttr(::new (S.Context)
5264 static void handleBuiltinAliasAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5273 StringRef AliasName = cast<FunctionDecl>(D)->getIdentifier()->getName();
5288 D->addAttr(::new (S.Context) BuiltinAliasAttr(S.Context, AL, Ident));
5291 static void handleNullableTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5295 if (auto *CRD = dyn_cast<CXXRecordDecl>(D);
5302 handleSimpleAttribute<TypeNullableAttr>(S, D, AL);
5305 static void handlePreferredTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5317 D->addAttr(::new (S.Context) PreferredTypeAttr(S.Context, AL, ParmTSI));
5324 UuidAttr *Sema::mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI,
5326 if (const auto *UA = D->getAttr<UuidAttr>()) {
5332 D->dropAttr<UuidAttr>();
5339 static void handleUuidAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5394 UuidAttr *UA = S.mergeUuidAttr(D, AL, OrigStrRef, Guid);
5396 D->addAttr(UA);
5399 static void handleMSInheritanceAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5406 D, AL, /*BestCase=*/true, (MSInheritanceModel)AL.getSemanticSpelling());
5408 D->addAttr(IA);
5409 S.Consumer.AssignInheritanceModel(cast<CXXRecordDecl>(D));
5413 static void handleDeclspecThreadAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5414 const auto *VD = cast<VarDecl>(D);
5427 D->addAttr(::new (S.Context) ThreadAttr(S.Context, AL));
5430 static void handleMSConstexprAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5436 auto *FD = cast<FunctionDecl>(D);
5449 D->addAttr(::new (S.Context) MSConstexprAttr(S.Context, AL));
5452 static void handleAbiTagAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5461 if (const auto *NS = dyn_cast<NamespaceDecl>(D)) {
5479 D->addAttr(::new (S.Context)
5483 static bool hasBTFDeclTagAttr(Decl *D, StringRef Tag) {
5484 for (const auto *I : D->specific_attrs<BTFDeclTagAttr>()) {
5491 static void handleBTFDeclTagAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5495 if (hasBTFDeclTagAttr(D, Str))
5498 D->addAttr(::new (S.Context) BTFDeclTagAttr(S.Context, AL, Str));
5501 BTFDeclTagAttr *Sema::mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL) {
5502 if (hasBTFDeclTagAttr(D, AL.getBTFDeclTag()))
5507 static void handleInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5511 S.MSP430().handleInterruptAttr(D, AL);
5515 S.MIPS().handleInterruptAttr(D, AL);
5518 S.M68k().handleInterruptAttr(D, AL);
5522 S.X86().handleAnyInterruptAttr(D, AL);
5525 S.AVR().handleInterruptAttr(D, AL);
5529 S.RISCV().handleInterruptAttr(D, AL);
5532 S.ARM().handleInterruptAttr(D, AL);
5537 static void handleLayoutVersion(Sema &S, Decl *D, const ParsedAttr &AL) {
5555 D->addAttr(::new (S.Context) LayoutVersionAttr(S.Context, AL, Version));
5558 DLLImportAttr *Sema::mergeDLLImportAttr(Decl *D,
5560 if (D->hasAttr<DLLExportAttr>()) {
5565 if (D->hasAttr<DLLImportAttr>())
5571 DLLExportAttr *Sema::mergeDLLExportAttr(Decl *D,
5573 if (DLLImportAttr *Import = D->getAttr<DLLImportAttr>()) {
5575 D->dropAttr<DLLImportAttr>();
5578 if (D->hasAttr<DLLExportAttr>())
5584 static void handleDLLAttr(Sema &S, Decl *D, const ParsedAttr &A) {
5585 if (isa<ClassTemplatePartialSpecializationDecl>(D) &&
5591 if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
5601 if (const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
5610 ? (Attr *)S.mergeDLLExportAttr(D, A)
5611 : (Attr *)S.mergeDLLImportAttr(D, A);
5613 D->addAttr(NewAttr);
5617 Sema::mergeMSInheritanceAttr(Decl *D, const AttributeCommonInfo &CI,
5620 if (MSInheritanceAttr *IA = D->getAttr<MSInheritanceAttr>()) {
5626 D->dropAttr<MSInheritanceAttr>();
5629 auto *RD = cast<CXXRecordDecl>(D);
5651 static void handleCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5666 D->addAttr(::new (S.Context) CapabilityAttr(S.Context, AL, N));
5669 static void handleAssertCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5671 if (!checkLockFunAttrCommon(S, D, AL, Args))
5674 D->addAttr(::new (S.Context)
5678 static void handleAcquireCapabilityAttr(Sema &S, Decl *D,
5681 if (!checkLockFunAttrCommon(S, D, AL, Args))
5684 D->addAttr(::new (S.Context) AcquireCapabilityAttr(S.Context, AL, Args.data(),
5688 static void handleTryAcquireCapabilityAttr(Sema &S, Decl *D,
5691 if (!checkTryLockFunAttrCommon(S, D, AL, Args))
5694 D->addAttr(::new (S.Context) TryAcquireCapabilityAttr(
5698 static void handleReleaseCapabilityAttr(Sema &S, Decl *D,
5702 checkAttrArgsAreCapabilityObjs(S, D, AL, Args, 0, true);
5704 D->addAttr(::new (S.Context) ReleaseCapabilityAttr(S.Context, AL, Args.data(),
5708 static void handleRequiresCapabilityAttr(Sema &S, Decl *D,
5715 checkAttrArgsAreCapabilityObjs(S, D, AL, Args);
5722 D->addAttr(RCA);
5725 static void handleDeprecatedAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5726 if (const auto *NSD = dyn_cast<NamespaceDecl>(D)) {
5735 UnresolvedUsingValueDecl>(D)) {
5757 D->addAttr(::new (S.Context) DeprecatedAttr(S.Context, AL, Str, Replacement));
5760 static bool isGlobalVar(const Decl *D) {
5761 if (const auto *S = dyn_cast<VarDecl>(D))
5771 static void handleNoSanitizeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5788 else if (isGlobalVar(D) && !isSanitizerAttributeAllowedOnGlobals(SanitizerName))
5789 S.Diag(D->getLocation(), diag::warn_attribute_type_not_supported_global)
5794 D->addAttr(::new (S.Context) NoSanitizeAttr(S.Context, AL, Sanitizers.data(),
5798 static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D,
5807 if (isGlobalVar(D) && SanitizerName != "address")
5808 S.Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
5825 D->addAttr(::new (S.Context)
5829 static void handleInternalLinkageAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5830 if (InternalLinkageAttr *Internal = S.mergeInternalLinkageAttr(D, AL))
5831 D->addAttr(Internal);
5834 static void handleZeroCallUsedRegsAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5848 D->dropAttr<ZeroCallUsedRegsAttr>();
5849 D->addAttr(ZeroCallUsedRegsAttr::Create(S.Context, Kind, AL));
5852 static void handleCountedByAttrField(Sema &S, Decl *D, const ParsedAttr &AL) {
5853 auto *FD = dyn_cast<FieldDecl>(D);
5892 static void handleFunctionReturnThunksAttr(Sema &S, Decl *D,
5908 D->dropAttr<FunctionReturnThunksAttr>();
5909 D->addAttr(FunctionReturnThunksAttr::Create(S.Context, Kind, AL));
5912 static void handleAvailableOnlyInDefaultEvalMethod(Sema &S, Decl *D,
5914 assert(isa<TypedefNameDecl>(D) && "This attribute only applies to a typedef");
5915 handleSimpleAttribute<AvailableOnlyInDefaultEvalMethodAttr>(S, D, AL);
5918 static void handleNoMergeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5919 auto *VDecl = dyn_cast<VarDecl>(D);
5925 D->addAttr(NoMergeAttr::Create(S.Context, AL));
5928 static void handleNoUniqueAddressAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5929 D->addAttr(NoUniqueAddressAttr::Create(S.Context, AL));
5932 static void handleDestroyAttr(Sema &S, Decl *D, const ParsedAttr &A) {
5933 if (!cast<VarDecl>(D)->hasGlobalStorage()) {
5934 S.Diag(D->getLocation(), diag::err_destroy_attr_on_non_static_var)
5940 handleSimpleAttribute<AlwaysDestroyAttr>(S, D, A);
5942 handleSimpleAttribute<NoDestroyAttr>(S, D, A);
5945 static void handleUninitializedAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5946 assert(cast<VarDecl>(D)->getStorageDuration() == SD_Automatic &&
5948 D->addAttr(::new (S.Context) UninitializedAttr(S.Context, AL));
5951 static void handleMIGServerRoutineAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5956 if (!isa<BlockDecl>(D)) {
5957 QualType T = getFunctionOrMethodResultType(D);
5964 S.Diag(D->getBeginLoc(),
5970 handleSimpleAttribute<MIGServerRoutineAttr>(S, D, AL);
5973 static void handleMSAllocatorAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5975 if (auto *FD = dyn_cast<FunctionDecl>(D)) {
5984 handleSimpleAttribute<MSAllocatorAttr>(S, D, AL);
5987 static void handleAcquireHandleAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
5991 if (const auto *PVD = dyn_cast<ParmVarDecl>(D)) {
6001 D->addAttr(AcquireHandleAttr::Create(S.Context, Argument, AL));
6005 static void handleHandleAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
6009 D->addAttr(Attr::Create(S.Context, Argument, AL));
6013 static void handleUnsafeBufferUsage(Sema &S, Decl *D, const ParsedAttr &AL) {
6014 D->addAttr(Attr::Create(S.Context, AL));
6017 static void handleCFGuardAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
6033 D->addAttr(::new (S.Context) CFGuardAttr(S.Context, AL, Arg));
6038 static const AttrTy *findEnforceTCBAttrByName(Decl *D, StringRef Name) {
6039 auto Attrs = D->specific_attrs<AttrTy>();
6048 static void handleEnforceTCBAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
6055 findEnforceTCBAttrByName<ConflictingAttrTy>(D, Argument)) {
6065 D->dropAttr<EnforceTCBAttr>();
6069 D->addAttr(AttrTy::Create(S.Context, Argument, AL));
6073 static AttrTy *mergeEnforceTCBAttrImpl(Sema &S, Decl *D, const AttrTy &AL) {
6077 findEnforceTCBAttrByName<ConflictingAttrTy>(D, TCBName)) {
6086 D->dropAttr<EnforceTCBAttr>();
6094 EnforceTCBAttr *Sema::mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL) {
6096 *this, D, AL);
6100 Decl *D, const EnforceTCBLeafAttr &AL) {
6102 *this, D, AL);
6105 static void handleVTablePointerAuthentication(Sema &S, Decl *D,
6107 CXXRecordDecl *Decl = cast<CXXRecordDecl>(D);
6120 if (D->getAttr<VTablePointerAuthenticationAttr>()) {
6254 ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL,
6289 if (S.checkCommonAttributeFeatures(D, AL, MustDelayArgs))
6293 AL.handleAttrWithDelayedArgs(S, D);
6299 if (AL.getInfo().handleDeclAttribute(S, D, AL) != ParsedAttrInfo::NotHandled)
6323 isa<DeclaratorDecl, TypeAliasDecl>(D)) {
6329 << AL << D->getLocation();
6372 << AL << AL.isRegularKeywordAttribute() << D->getLocation();
6375 handleInterruptAttr(S, D, AL);
6378 S.X86().handleForceAlignArgPointerAttr(D, AL);
6381 handleSimpleAttribute<ReadOnlyPlacementAttr>(S, D, AL);
6385 handleDLLAttr(S, D, AL);
6388 S.AMDGPU().handleAMDGPUFlatWorkGroupSizeAttr(D, AL);
6391 S.AMDGPU().handleAMDGPUWavesPerEUAttr(D, AL);
6394 S.AMDGPU().handleAMDGPUNumSGPRAttr(D, AL);
6397 S.AMDGPU().handleAMDGPUNumVGPRAttr(D, AL);
6400 S.AMDGPU().handleAMDGPUMaxNumWorkGroupsAttr(D, AL);
6403 S.AVR().handleSignalAttr(D, AL);
6406 S.BPF().handlePreserveAccessIndexAttr(D, AL);
6409 handleSimpleAttribute<BPFPreserveStaticOffsetAttr>(S, D, AL);
6412 handleBTFDeclTagAttr(S, D, AL);
6415 S.Wasm().handleWebAssemblyExportNameAttr(D, AL);
6418 S.Wasm().handleWebAssemblyImportModuleAttr(D, AL);
6421 S.Wasm().handleWebAssemblyImportNameAttr(D, AL);
6424 S.ObjC().handleIBOutlet(D, AL);
6427 S.ObjC().handleIBOutletCollection(D, AL);
6430 handleIFuncAttr(S, D, AL);
6433 handleAliasAttr(S, D, AL);
6436 handleAlignedAttr(S, D, AL);
6439 handleAlignValueAttr(S, D, AL);
6442 handleAllocSizeAttr(S, D, AL);
6445 handleAlwaysInlineAttr(S, D, AL);
6448 handleAnalyzerNoReturnAttr(S, D, AL);
6451 handleTLSModelAttr(S, D, AL);
6454 handleAnnotateAttr(S, D, AL);
6457 handleAvailabilityAttr(S, D, AL);
6460 handleDependencyAttr(S, scope, D, AL);
6464 handleCPUSpecificAttr(S, D, AL);
6467 handleCommonAttr(S, D, AL);
6470 handleConstantAttr(S, D, AL);
6473 handlePassObjectSizeAttr(S, D, AL);
6476 handleConstructorAttr(S, D, AL);
6479 handleDeprecatedAttr(S, D, AL);
6482 handleDestructorAttr(S, D, AL);
6485 handleEnableIfAttr(S, D, AL);
6488 handleErrorAttr(S, D, AL);
6491 handleExcludeFromExplicitInstantiationAttr(S, D, AL);
6494 handleDiagnoseIfAttr(S, D, AL);
6497 handleDiagnoseAsBuiltinAttr(S, D, AL);
6500 handleNoBuiltinAttr(S, D, AL);
6503 handleExtVectorTypeAttr(S, D, AL);
6506 handleExternalSourceSymbolAttr(S, D, AL);
6509 handleMinSizeAttr(S, D, AL);
6512 handleOptimizeNoneAttr(S, D, AL);
6515 handleEnumExtensibilityAttr(S, D, AL);
6518 S.SYCL().handleKernelAttr(D, AL);
6521 handleSimpleAttribute<SYCLSpecialClassAttr>(S, D, AL);
6524 handleFormatAttr(S, D, AL);
6527 handleFormatArgAttr(S, D, AL);
6530 handleCallbackAttr(S, D, AL);
6533 handleCalledOnceAttr(S, D, AL);
6537 handleGlobalAttr(S, D, AL);
6540 handleDeviceAttr(S, D, AL);
6543 handleManagedAttr(S, D, AL);
6546 handleGNUInlineAttr(S, D, AL);
6549 handleLaunchBoundsAttr(S, D, AL);
6552 handleRestrictAttr(S, D, AL);
6555 handleModeAttr(S, D, AL);
6558 if (auto *PVD = dyn_cast<ParmVarDecl>(D))
6561 handleNonNullAttr(S, D, AL);
6564 handleReturnsNonNullAttr(S, D, AL);
6567 handleNoEscapeAttr(S, D, AL);
6570 handleSimpleAttribute<MaybeUndefAttr>(S, D, AL);
6573 handleAssumeAlignedAttr(S, D, AL);
6576 handleAllocAlignAttr(S, D, AL);
6579 handleOwnershipAttr(S, D, AL);
6582 handleNakedAttr(S, D, AL);
6585 handleNoReturnAttr(S, D, AL);
6588 handleStandardNoReturnAttr(S, D, AL);
6591 handleNoCfCheckAttr(S, D, AL);
6595 handleSimpleAttribute<NoThrowAttr>(S, D, AL);
6598 handleSharedAttr(S, D, AL);
6601 handleVecReturnAttr(S, D, AL);
6604 S.ObjC().handleOwnershipAttr(D, AL);
6607 S.ObjC().handlePreciseLifetimeAttr(D, AL);
6610 S.ObjC().handleReturnsInnerPointerAttr(D, AL);
6613 S.ObjC().handleRequiresSuperAttr(D, AL);
6616 S.ObjC().handleBridgeAttr(D, AL);
6619 S.ObjC().handleBridgeMutableAttr(D, AL);
6622 S.ObjC().handleBridgeRelatedAttr(D, AL);
6625 S.ObjC().handleDesignatedInitializer(D, AL);
6628 S.ObjC().handleRuntimeName(D, AL);
6631 S.ObjC().handleBoxable(D, AL);
6634 S.ObjC().handleNSErrorDomain(D, AL);
6639 S.ObjC().AddXConsumedAttr(D, AL,
6645 S, D, AL, S.ObjC().isValidOSObjectOutParameter(D),
6651 S, D, AL, S.ObjC().isValidOSObjectOutParameter(D),
6662 S.ObjC().handleXReturnsXRetainedAttr(D, AL);
6665 handleWorkGroupSize<WorkGroupSizeHintAttr>(S, D, AL);
6668 handleWorkGroupSize<ReqdWorkGroupSizeAttr>(S, D, AL);
6671 S.OpenCL().handleSubGroupSize(D, AL);
6674 handleVecTypeHint(S, D, AL);
6677 handleInitPriorityAttr(S, D, AL);
6680 handlePackedAttr(S, D, AL);
6683 handlePreferredName(S, D, AL);
6686 handleSectionAttr(S, D, AL);
6689 handleCodeModelAttr(S, D, AL);
6692 handleRandomizeLayoutAttr(S, D, AL);
6695 handleNoRandomizeLayoutAttr(S, D, AL);
6698 handleCodeSegAttr(S, D, AL);
6701 handleTargetAttr(S, D, AL);
6704 handleTargetVersionAttr(S, D, AL);
6707 handleTargetClonesAttr(S, D, AL);
6710 handleMinVectorWidthAttr(S, D, AL);
6713 handleAttrWithMessage<UnavailableAttr>(S, D, AL);
6716 S.OpenMP().handleOMPAssumeAttr(D, AL);
6719 S.ObjC().handleDirectAttr(D, AL);
6722 S.ObjC().handleDirectMembersAttr(D, AL);
6723 handleSimpleAttribute<ObjCDirectMembersAttr>(S, D, AL);
6726 S.ObjC().handleSuppresProtocolAttr(D, AL);
6729 handleUnusedAttr(S, D, AL);
6732 handleVisibilityAttr(S, D, AL, false);
6735 handleVisibilityAttr(S, D, AL, true);
6738 handleWarnUnusedResult(S, D, AL);
6741 handleWeakRefAttr(S, D, AL);
6744 handleWeakImportAttr(S, D, AL);
6747 handleTransparentUnionAttr(S, D, AL);
6750 S.ObjC().handleMethodFamilyAttr(D, AL);
6753 S.ObjC().handleNSObject(D, AL);
6756 S.ObjC().handleIndependentClass(D, AL);
6759 S.ObjC().handleBlocksAttr(D, AL);
6762 handleSentinelAttr(S, D, AL);
6765 handleCleanupAttr(S, D, AL);
6768 handleNoDebugAttr(S, D, AL);
6771 S.ARM().handleCmseNSEntryAttr(D, AL);
6794 handleCallConvAttr(S, D, AL);
6797 handleSuppressAttr(S, D, AL);
6801 handleLifetimeCategoryAttr(S, D, AL);
6804 S.OpenCL().handleAccessAttr(D, AL);
6807 S.OpenCL().handleNoSVMAttr(D, AL);
6810 S.Swift().AddParameterABIAttr(D, AL, ParameterABI::SwiftContext);
6813 S.Swift().AddParameterABIAttr(D, AL, ParameterABI::SwiftAsyncContext);
6816 S.Swift().AddParameterABIAttr(D, AL, ParameterABI::SwiftErrorResult);
6819 S.Swift().AddParameterABIAttr(D, AL, ParameterABI::SwiftIndirectResult);
6822 handleInternalLinkageAttr(S, D, AL);
6825 handleZeroCallUsedRegsAttr(S, D, AL);
6828 handleFunctionReturnThunksAttr(S, D, AL);
6831 handleNoMergeAttr(S, D, AL);
6834 handleNoUniqueAddressAttr(S, D, AL);
6838 handleAvailableOnlyInDefaultEvalMethod(S, D, AL);
6845 handleCountedByAttrField(S, D, AL);
6850 handleLayoutVersion(S, D, AL);
6853 handleUuidAttr(S, D, AL);
6856 handleMSInheritanceAttr(S, D, AL);
6859 handleDeclspecThreadAttr(S, D, AL);
6862 handleMSConstexprAttr(S, D, AL);
6865 handleSimpleAttribute<HybridPatchableAttr>(S, D, AL);
6870 S.HLSL().handleNumThreadsAttr(D, AL);
6873 handleSimpleAttribute<HLSLSV_GroupIndexAttr>(S, D, AL);
6876 S.HLSL().handleSV_DispatchThreadIDAttr(D, AL);
6879 S.HLSL().handlePackOffsetAttr(D, AL);
6882 S.HLSL().handleShaderAttr(D, AL);
6885 S.HLSL().handleResourceBindingAttr(D, AL);
6888 S.HLSL().handleResourceClassAttr(D, AL);
6891 S.HLSL().handleParamModifierAttr(D, AL);
6895 handleAbiTagAttr(S, D, AL);
6898 handleCFGuardAttr(S, D, AL);
6903 handleAssertExclusiveLockAttr(S, D, AL);
6906 handleAssertSharedLockAttr(S, D, AL);
6909 handlePtGuardedVarAttr(S, D, AL);
6912 handleNoSanitizeAttr(S, D, AL);
6915 handleNoSanitizeSpecificAttr(S, D, AL);
6918 handleGuardedByAttr(S, D, AL);
6921 handlePtGuardedByAttr(S, D, AL);
6924 handleExclusiveTrylockFunctionAttr(S, D, AL);
6927 handleLockReturnedAttr(S, D, AL);
6930 handleLocksExcludedAttr(S, D, AL);
6933 handleSharedTrylockFunctionAttr(S, D, AL);
6936 handleAcquiredBeforeAttr(S, D, AL);
6939 handleAcquiredAfterAttr(S, D, AL);
6945 handleCapabilityAttr(S, D, AL);
6948 handleRequiresCapabilityAttr(S, D, AL);
6952 handleAssertCapabilityAttr(S, D, AL);
6955 handleAcquireCapabilityAttr(S, D, AL);
6958 handleReleaseCapabilityAttr(S, D, AL);
6961 handleTryAcquireCapabilityAttr(S, D, AL);
6966 handleConsumableAttr(S, D, AL);
6969 handleCallableWhenAttr(S, D, AL);
6972 handleParamTypestateAttr(S, D, AL);
6975 handleReturnTypestateAttr(S, D, AL);
6978 handleSetTypestateAttr(S, D, AL);
6981 handleTestTypestateAttr(S, D, AL);
6986 handleArgumentWithTypeTagAttr(S, D, AL);
6989 handleTypeTagForDatatypeAttr(S, D, AL);
6994 S.Swift().handleAsyncName(D, AL);
6997 S.Swift().handleAttrAttr(D, AL);
7000 S.Swift().handleBridge(D, AL);
7003 S.Swift().handleError(D, AL);
7006 S.Swift().handleName(D, AL);
7009 S.Swift().handleNewType(D, AL);
7012 S.Swift().handleAsyncAttr(D, AL);
7015 S.Swift().handleAsyncError(D, AL);
7020 handleXRayLogArgsAttr(S, D, AL);
7024 handlePatchableFunctionEntryAttr(S, D, AL);
7029 handleDestroyAttr(S, D, AL);
7033 handleUninitializedAttr(S, D, AL);
7037 S.ObjC().handleExternallyRetainedAttr(D, AL);
7041 handleMIGServerRoutineAttr(S, D, AL);
7045 handleMSAllocatorAttr(S, D, AL);
7049 S.ARM().handleBuiltinAliasAttr(D, AL);
7053 handleSimpleAttribute<ArmLocallyStreamingAttr>(S, D, AL);
7057 S.ARM().handleNewAttr(D, AL);
7061 handleAcquireHandleAttr(S, D, AL);
7065 handleHandleAttr<ReleaseHandleAttr>(S, D, AL);
7069 handleUnsafeBufferUsage<UnsafeBufferUsageAttr>(S, D, AL);
7073 handleHandleAttr<UseHandleAttr>(S, D, AL);
7077 handleEnforceTCBAttr<EnforceTCBAttr, EnforceTCBLeafAttr>(S, D, AL);
7081 handleEnforceTCBAttr<EnforceTCBLeafAttr, EnforceTCBAttr>(S, D, AL);
7085 handleBuiltinAliasAttr(S, D, AL);
7089 handlePreferredTypeAttr(S, D, AL);
7093 handleSimpleAttribute<UsingIfExistsAttr>(S, D, AL);
7097 handleNullableTypeAttr(S, D, AL);
7101 handleVTablePointerAuthentication(S, D, AL);
7107 Scope *S, Decl *D, const ParsedAttributesView &AttrList,
7113 ProcessDeclAttribute(*this, S, D, AL, Options);
7119 if (D->hasAttr<WeakRefAttr>() && !D->hasAttr<AliasAttr>()) {
7121 << cast<NamedDecl>(D);
7122 D->dropAttr<WeakRefAttr>();
7130 if (!D->hasAttr<OpenCLKernelAttr>()) {
7132 if (const auto *A = D->getAttr<ReqdWorkGroupSizeAttr>()) {
7135 Diag(D->getLocation(), diag::err_opencl_kernel_attr) << A;
7136 D->setInvalidDecl();
7137 } else if (const auto *A = D->getAttr<WorkGroupSizeHintAttr>()) {
7138 Diag(D->getLocation(), diag::err_opencl_kernel_attr) << A;
7139 D->setInvalidDecl();
7140 } else if (const auto *A = D->getAttr<VecTypeHintAttr>()) {
7141 Diag(D->getLocation(), diag::err_opencl_kernel_attr) << A;
7142 D->setInvalidDecl();
7143 } else if (const auto *A = D->getAttr<OpenCLIntelReqdSubGroupSizeAttr>()) {
7144 Diag(D->getLocation(), diag::err_opencl_kernel_attr) << A;
7145 D->setInvalidDecl();
7146 } else if (!D->hasAttr<CUDAGlobalAttr>()) {
7147 if (const auto *A = D->getAttr<AMDGPUFlatWorkGroupSizeAttr>()) {
7148 Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
7150 D->setInvalidDecl();
7151 } else if (const auto *A = D->getAttr<AMDGPUWavesPerEUAttr>()) {
7152 Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
7154 D->setInvalidDecl();
7155 } else if (const auto *A = D->getAttr<AMDGPUNumSGPRAttr>()) {
7156 Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
7158 D->setInvalidDecl();
7159 } else if (const auto *A = D->getAttr<AMDGPUNumVGPRAttr>()) {
7160 Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
7162 D->setInvalidDecl();
7167 // Do this check after processing D's attributes because the attribute
7172 if (D->hasAttr<ObjCDesignatedInitializerAttr>() &&
7173 cast<ObjCMethodDecl>(D)->getMethodFamily() != OMF_init) {
7174 Diag(D->getLocation(), diag::err_designated_init_attr_non_init);
7175 D->dropAttr<ObjCDesignatedInitializerAttr>();
7179 void Sema::ProcessDeclAttributeDelayed(Decl *D,
7183 handleTransparentUnionAttr(*this, D, AL);
7189 if (D && D->hasAttr<BPFPreserveAccessIndexAttr>())
7190 BPF().handlePreserveAIRecord(cast<RecordDecl>(D));
7227 void Sema::checkUnusedDeclAttributes(Declarator &D) {
7228 ::checkUnusedDeclAttributes(*this, D.getDeclarationAttributes());
7229 ::checkUnusedDeclAttributes(*this, D.getDeclSpec().getAttributes());
7230 ::checkUnusedDeclAttributes(*this, D.getAttributes());
7231 for (unsigned i = 0, e = D.getNumTypeObjects(); i != e; ++i)
7232 ::checkUnusedDeclAttributes(*this, D.getTypeObject(i).getAttrs());
7300 void Sema::ProcessPragmaWeak(Scope *S, Decl *D) {
7307 if (auto *VD = dyn_cast<VarDecl>(D))
7310 if (auto *FD = dyn_cast<FunctionDecl>(D))
7328 /// it, apply them to D. This is a bit tricky because PD can have attributes
7330 void Sema::ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD) {
7348 AL.diagnoseAppertainsTo(*this, D);
7353 ProcessDeclAttributeList(S, D, NonSlidingAttrs, Options);
7368 // int *__attr__(x)** D;
7371 ProcessDeclAttributeList(S, D, PD.getTypeObject(i).getAttrs(),
7378 ProcessDeclAttributeList(S, D, PD.getAttributes());
7381 AddPragmaAttributes(S, D);
7384 ProcessAPINotes(D);
7390 static bool isForbiddenTypeAllowed(Sema &S, Decl *D,
7396 if (!isa<FieldDecl>(D) && !isa<ObjCPropertyDecl>(D) &&
7397 !isa<FunctionDecl>(D))
7405 if ((isa<ObjCIvarDecl>(D) || isa<ObjCPropertyDecl>(D))) {
7414 if (S.Context.getSourceManager().isInSystemHeader(D->getLocation())) {
7426 Decl *D) {
7428 if (D && isForbiddenTypeAllowed(S, D, DD, Reason)) {
7430 D->addAttr(UnavailableAttr::CreateImplicit(S.Context, "", Reason, DD.Loc));
7434 if (const auto *FD = dyn_cast<FunctionDecl>(D)) {