Lines Matching refs:D

68 static bool isFunctionOrMethod(const Decl *D) {  in isFunctionOrMethod()  argument
69 return (D->getFunctionType() != nullptr) || isa<ObjCMethodDecl>(D); in isFunctionOrMethod()
74 static bool isFunctionOrMethodOrBlock(const Decl *D) { in isFunctionOrMethodOrBlock() argument
75 return isFunctionOrMethod(D) || isa<BlockDecl>(D); in isFunctionOrMethodOrBlock()
80 static bool hasDeclarator(const Decl *D) { in hasDeclarator() argument
82 return isa<DeclaratorDecl>(D) || isa<BlockDecl>(D) || isa<TypedefNameDecl>(D) || in hasDeclarator()
83 isa<ObjCPropertyDecl>(D); in hasDeclarator()
89 static bool hasFunctionProto(const Decl *D) { in hasFunctionProto() argument
90 if (const FunctionType *FnTy = D->getFunctionType()) in hasFunctionProto()
92 return isa<ObjCMethodDecl>(D) || isa<BlockDecl>(D); in hasFunctionProto()
98 static unsigned getFunctionOrMethodNumParams(const Decl *D) { in getFunctionOrMethodNumParams() argument
99 if (const FunctionType *FnTy = D->getFunctionType()) in getFunctionOrMethodNumParams()
101 if (const auto *BD = dyn_cast<BlockDecl>(D)) in getFunctionOrMethodNumParams()
103 return cast<ObjCMethodDecl>(D)->param_size(); in getFunctionOrMethodNumParams()
106 static const ParmVarDecl *getFunctionOrMethodParam(const Decl *D, in getFunctionOrMethodParam() argument
108 if (const auto *FD = dyn_cast<FunctionDecl>(D)) in getFunctionOrMethodParam()
110 if (const auto *MD = dyn_cast<ObjCMethodDecl>(D)) in getFunctionOrMethodParam()
112 if (const auto *BD = dyn_cast<BlockDecl>(D)) in getFunctionOrMethodParam()
117 static QualType getFunctionOrMethodParamType(const Decl *D, unsigned Idx) { in getFunctionOrMethodParamType() argument
118 if (const FunctionType *FnTy = D->getFunctionType()) in getFunctionOrMethodParamType()
120 if (const auto *BD = dyn_cast<BlockDecl>(D)) in getFunctionOrMethodParamType()
123 return cast<ObjCMethodDecl>(D)->parameters()[Idx]->getType(); in getFunctionOrMethodParamType()
126 static SourceRange getFunctionOrMethodParamRange(const Decl *D, unsigned Idx) { in getFunctionOrMethodParamRange() argument
127 if (auto *PVD = getFunctionOrMethodParam(D, Idx)) in getFunctionOrMethodParamRange()
132 static QualType getFunctionOrMethodResultType(const Decl *D) { in getFunctionOrMethodResultType() argument
133 if (const FunctionType *FnTy = D->getFunctionType()) in getFunctionOrMethodResultType()
135 return cast<ObjCMethodDecl>(D)->getReturnType(); in getFunctionOrMethodResultType()
138 static SourceRange getFunctionOrMethodResultSourceRange(const Decl *D) { in getFunctionOrMethodResultSourceRange() argument
139 if (const auto *FD = dyn_cast<FunctionDecl>(D)) in getFunctionOrMethodResultSourceRange()
141 if (const auto *MD = dyn_cast<ObjCMethodDecl>(D)) in getFunctionOrMethodResultSourceRange()
146 static bool isFunctionOrMethodVariadic(const Decl *D) { in isFunctionOrMethodVariadic() argument
147 if (const FunctionType *FnTy = D->getFunctionType()) in isFunctionOrMethodVariadic()
149 if (const auto *BD = dyn_cast<BlockDecl>(D)) in isFunctionOrMethodVariadic()
151 return cast<ObjCMethodDecl>(D)->isVariadic(); in isFunctionOrMethodVariadic()
154 static bool isInstanceMethod(const Decl *D) { in isInstanceMethod() argument
155 if (const auto *MethodDecl = dyn_cast<CXXMethodDecl>(D)) in isInstanceMethod()
273 static bool checkAttrMutualExclusion(Sema &S, Decl *D, const ParsedAttr &AL) { in checkAttrMutualExclusion() argument
274 if (const auto *A = D->getAttr<AttrTy>()) { in checkAttrMutualExclusion()
283 static bool checkAttrMutualExclusion(Sema &S, Decl *D, const Attr &AL) { in checkAttrMutualExclusion() argument
284 if (const auto *A = D->getAttr<AttrTy>()) { in checkAttrMutualExclusion()
299 Sema &S, const Decl *D, const AttrInfo &AI, unsigned AttrArgNum, in checkFunctionOrMethodParameterIndex() argument
301 assert(isFunctionOrMethodOrBlock(D)); in checkFunctionOrMethodParameterIndex()
305 bool HP = hasFunctionProto(D); in checkFunctionOrMethodParameterIndex()
306 bool HasImplicitThisParam = isInstanceMethod(D); in checkFunctionOrMethodParameterIndex()
307 bool IV = HP && isFunctionOrMethodVariadic(D); in checkFunctionOrMethodParameterIndex()
309 (HP ? getFunctionOrMethodNumParams(D) : 0) + HasImplicitThisParam; in checkFunctionOrMethodParameterIndex()
334 Idx = ParamIdx(IdxSource, D); in checkFunctionOrMethodParameterIndex()
386 static void handleSimpleAttribute(Sema &S, Decl *D, in handleSimpleAttribute() argument
388 D->addAttr(::new (S.Context) AttrType(S.Context, CI)); in handleSimpleAttribute()
410 static void handleSimpleAttributeOrDiagnose(Sema &S, Decl *D, in handleSimpleAttributeOrDiagnose() argument
415 Sema::SemaDiagnosticBuilder DB = S.Diag(D->getBeginLoc(), DiagID); in handleSimpleAttributeOrDiagnose()
419 handleSimpleAttribute<AttrType>(S, D, CI); in handleSimpleAttributeOrDiagnose()
467 static bool threadSafetyCheckIsPointer(Sema &S, const Decl *D, in threadSafetyCheckIsPointer() argument
469 const auto *VD = cast<ValueDecl>(D); in threadSafetyCheckIsPointer()
588 static void checkAttrArgsAreCapabilityObjs(Sema &S, Decl *D, in checkAttrArgsAreCapabilityObjs() argument
597 const auto *MD = dyn_cast<const CXXMethodDecl>(D); in checkAttrArgsAreCapabilityObjs()
652 const auto *FD = dyn_cast<FunctionDecl>(D); in checkAttrArgsAreCapabilityObjs()
685 static void handlePtGuardedVarAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handlePtGuardedVarAttr() argument
686 if (!threadSafetyCheckIsPointer(S, D, AL)) in handlePtGuardedVarAttr()
689 D->addAttr(::new (S.Context) PtGuardedVarAttr(S.Context, AL)); in handlePtGuardedVarAttr()
692 static bool checkGuardedByAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, in checkGuardedByAttrCommon() argument
696 checkAttrArgsAreCapabilityObjs(S, D, AL, Args); in checkGuardedByAttrCommon()
706 static void handleGuardedByAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleGuardedByAttr() argument
708 if (!checkGuardedByAttrCommon(S, D, AL, Arg)) in handleGuardedByAttr()
711 D->addAttr(::new (S.Context) GuardedByAttr(S.Context, AL, Arg)); in handleGuardedByAttr()
714 static void handlePtGuardedByAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handlePtGuardedByAttr() argument
716 if (!checkGuardedByAttrCommon(S, D, AL, Arg)) in handlePtGuardedByAttr()
719 if (!threadSafetyCheckIsPointer(S, D, AL)) in handlePtGuardedByAttr()
722 D->addAttr(::new (S.Context) PtGuardedByAttr(S.Context, AL, Arg)); in handlePtGuardedByAttr()
725 static bool checkAcquireOrderAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, in checkAcquireOrderAttrCommon() argument
731 QualType QT = cast<ValueDecl>(D)->getType(); in checkAcquireOrderAttrCommon()
738 checkAttrArgsAreCapabilityObjs(S, D, AL, Args); in checkAcquireOrderAttrCommon()
745 static void handleAcquiredAfterAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAcquiredAfterAttr() argument
747 if (!checkAcquireOrderAttrCommon(S, D, AL, Args)) in handleAcquiredAfterAttr()
751 D->addAttr(::new (S.Context) in handleAcquiredAfterAttr()
755 static void handleAcquiredBeforeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAcquiredBeforeAttr() argument
757 if (!checkAcquireOrderAttrCommon(S, D, AL, Args)) in handleAcquiredBeforeAttr()
761 D->addAttr(::new (S.Context) in handleAcquiredBeforeAttr()
765 static bool checkLockFunAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, in checkLockFunAttrCommon() argument
769 checkAttrArgsAreCapabilityObjs(S, D, AL, Args, 0, /*ParamIdxOk=*/true); in checkLockFunAttrCommon()
774 static void handleAssertSharedLockAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAssertSharedLockAttr() argument
776 if (!checkLockFunAttrCommon(S, D, AL, Args)) in handleAssertSharedLockAttr()
781 D->addAttr(::new (S.Context) in handleAssertSharedLockAttr()
785 static void handleAssertExclusiveLockAttr(Sema &S, Decl *D, in handleAssertExclusiveLockAttr() argument
788 if (!checkLockFunAttrCommon(S, D, AL, Args)) in handleAssertExclusiveLockAttr()
793 D->addAttr(::new (S.Context) in handleAssertExclusiveLockAttr()
803 static bool checkParamIsIntegerType(Sema &S, const Decl *D, const AttrInfo &AI, in checkParamIsIntegerType() argument
808 if (!checkFunctionOrMethodParameterIndex(S, D, AI, AttrArgNo + 1, AttrArg, in checkParamIsIntegerType()
812 QualType ParamTy = getFunctionOrMethodParamType(D, Idx.getASTIndex()); in checkParamIsIntegerType()
816 << AI << getFunctionOrMethodParamRange(D, Idx.getASTIndex()); in checkParamIsIntegerType()
822 static void handleAllocSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAllocSizeAttr() argument
826 assert(isFunctionOrMethod(D) && hasFunctionProto(D)); in handleAllocSizeAttr()
828 QualType RetTy = getFunctionOrMethodResultType(D); in handleAllocSizeAttr()
839 if (!checkParamIsIntegerType(S, D, AL, /*AttrArgNo=*/0)) in handleAllocSizeAttr()
841 ParamIdx SizeArgNo(SizeArgNoVal, D); in handleAllocSizeAttr()
850 if (!checkParamIsIntegerType(S, D, AL, /*AttrArgNo=*/1)) in handleAllocSizeAttr()
852 NumberArgNo = ParamIdx(Val, D); in handleAllocSizeAttr()
855 D->addAttr(::new (S.Context) in handleAllocSizeAttr()
859 static bool checkTryLockFunAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, in checkTryLockFunAttrCommon() argument
871 checkAttrArgsAreCapabilityObjs(S, D, AL, Args, 1); in checkTryLockFunAttrCommon()
876 static void handleSharedTrylockFunctionAttr(Sema &S, Decl *D, in handleSharedTrylockFunctionAttr() argument
879 if (!checkTryLockFunAttrCommon(S, D, AL, Args)) in handleSharedTrylockFunctionAttr()
882 D->addAttr(::new (S.Context) SharedTrylockFunctionAttr( in handleSharedTrylockFunctionAttr()
886 static void handleExclusiveTrylockFunctionAttr(Sema &S, Decl *D, in handleExclusiveTrylockFunctionAttr() argument
889 if (!checkTryLockFunAttrCommon(S, D, AL, Args)) in handleExclusiveTrylockFunctionAttr()
892 D->addAttr(::new (S.Context) ExclusiveTrylockFunctionAttr( in handleExclusiveTrylockFunctionAttr()
896 static void handleLockReturnedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleLockReturnedAttr() argument
899 checkAttrArgsAreCapabilityObjs(S, D, AL, Args); in handleLockReturnedAttr()
904 D->addAttr(::new (S.Context) LockReturnedAttr(S.Context, AL, Args[0])); in handleLockReturnedAttr()
907 static void handleLocksExcludedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleLocksExcludedAttr() argument
913 checkAttrArgsAreCapabilityObjs(S, D, AL, Args); in handleLocksExcludedAttr()
919 D->addAttr(::new (S.Context) in handleLocksExcludedAttr()
923 static bool checkFunctionConditionAttr(Sema &S, Decl *D, const ParsedAttr &AL, in checkFunctionConditionAttr() argument
940 if (isa<FunctionDecl>(D) && !Cond->isValueDependent() && in checkFunctionConditionAttr()
941 !Expr::isPotentialConstantExprUnevaluated(Cond, cast<FunctionDecl>(D), in checkFunctionConditionAttr()
951 static void handleEnableIfAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleEnableIfAttr() argument
956 if (checkFunctionConditionAttr(S, D, AL, Cond, Msg)) in handleEnableIfAttr()
957 D->addAttr(::new (S.Context) EnableIfAttr(S.Context, AL, Cond, Msg)); in handleEnableIfAttr()
960 static void handleErrorAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleErrorAttr() argument
964 if (ErrorAttr *EA = S.mergeErrorAttr(D, AL, NewUserDiagnostic)) in handleErrorAttr()
965 D->addAttr(EA); in handleErrorAttr()
1014 static void handleDiagnoseAsBuiltinAttr(Sema &S, Decl *D, in handleDiagnoseAsBuiltinAttr() argument
1016 const auto *DeclFD = cast<FunctionDecl>(D); in handleDiagnoseAsBuiltinAttr()
1088 D->addAttr(::new (S.Context) DiagnoseAsBuiltinAttr( in handleDiagnoseAsBuiltinAttr()
1092 static void handleDiagnoseIfAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleDiagnoseIfAttr() argument
1097 if (!checkFunctionConditionAttr(S, D, AL, Cond, Msg)) in handleDiagnoseIfAttr()
1112 if (const auto *FD = dyn_cast<FunctionDecl>(D)) in handleDiagnoseIfAttr()
1114 D->addAttr(::new (S.Context) DiagnoseIfAttr( in handleDiagnoseIfAttr()
1115 S.Context, AL, Cond, Msg, DiagType, ArgDependent, cast<NamedDecl>(D))); in handleDiagnoseIfAttr()
1118 static void handleNoBuiltinAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNoBuiltinAttr() argument
1131 if (const auto *NBA = D->getAttr<NoBuiltinAttr>()) in handleNoBuiltinAttr()
1158 S.Diag(D->getLocation(), in handleNoBuiltinAttr()
1162 if (D->hasAttr<NoBuiltinAttr>()) in handleNoBuiltinAttr()
1163 D->dropAttr<NoBuiltinAttr>(); in handleNoBuiltinAttr()
1164 D->addAttr(::new (S.Context) in handleNoBuiltinAttr()
1168 static void handlePassObjectSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handlePassObjectSizeAttr() argument
1169 if (D->hasAttr<PassObjectSizeAttr>()) { in handlePassObjectSizeAttr()
1170 S.Diag(D->getBeginLoc(), diag::err_attribute_only_once_per_parameter) << AL; in handlePassObjectSizeAttr()
1192 if (!cast<ParmVarDecl>(D)->getType()->isPointerType()) { in handlePassObjectSizeAttr()
1193 S.Diag(D->getBeginLoc(), diag::err_attribute_pointers_only) << AL << 1; in handlePassObjectSizeAttr()
1197 D->addAttr(::new (S.Context) PassObjectSizeAttr(S.Context, AL, (int)Type)); in handlePassObjectSizeAttr()
1200 static void handleConsumableAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleConsumableAttr() argument
1217 D->addAttr(::new (S.Context) ConsumableAttr(S.Context, AL, DefaultState)); in handleConsumableAttr()
1235 static void handleCallableWhenAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCallableWhenAttr() argument
1239 if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), AL)) in handleCallableWhenAttr()
1266 D->addAttr(::new (S.Context) in handleCallableWhenAttr()
1270 static void handleParamTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleParamTypestateAttr() argument
1301 D->addAttr(::new (S.Context) ParamTypestateAttr(S.Context, AL, ParamState)); in handleParamTypestateAttr()
1304 static void handleReturnTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleReturnTypestateAttr() argument
1346 D->addAttr(::new (S.Context) ReturnTypestateAttr(S.Context, AL, ReturnState)); in handleReturnTypestateAttr()
1349 static void handleSetTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSetTypestateAttr() argument
1350 if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), AL)) in handleSetTypestateAttr()
1368 D->addAttr(::new (S.Context) SetTypestateAttr(S.Context, AL, NewState)); in handleSetTypestateAttr()
1371 static void handleTestTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleTestTypestateAttr() argument
1372 if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), AL)) in handleTestTypestateAttr()
1390 D->addAttr(::new (S.Context) TestTypestateAttr(S.Context, AL, TestState)); in handleTestTypestateAttr()
1393 static void handleExtVectorTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleExtVectorTypeAttr() argument
1395 S.ExtVectorDecls.push_back(cast<TypedefNameDecl>(D)); in handleExtVectorTypeAttr()
1398 static void handlePackedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handlePackedAttr() argument
1399 if (auto *TD = dyn_cast<TagDecl>(D)) in handlePackedAttr()
1401 else if (auto *FD = dyn_cast<FieldDecl>(D)) { in handlePackedAttr()
1426 static void handlePreferredName(Sema &S, Decl *D, const ParsedAttr &AL) { in handlePreferredName() argument
1427 auto *RD = cast<CXXRecordDecl>(D); in handlePreferredName()
1451 D->addAttr(::new (S.Context) PreferredNameAttr(S.Context, AL, TSI)); in handlePreferredName()
1463 static bool checkIBOutletCommon(Sema &S, Decl *D, const ParsedAttr &AL) { in checkIBOutletCommon() argument
1467 if (const auto *VD = dyn_cast<ObjCIvarDecl>(D)) { in checkIBOutletCommon()
1474 else if (const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) { in checkIBOutletCommon()
1489 static void handleIBOutlet(Sema &S, Decl *D, const ParsedAttr &AL) { in handleIBOutlet() argument
1490 if (!checkIBOutletCommon(S, D, AL)) in handleIBOutlet()
1493 D->addAttr(::new (S.Context) IBOutletAttr(S.Context, AL)); in handleIBOutlet()
1496 static void handleIBOutletCollection(Sema &S, Decl *D, const ParsedAttr &AL) { in handleIBOutletCollection() argument
1504 if (!checkIBOutletCommon(S, D, AL)) in handleIBOutletCollection()
1513 S.getScopeForContext(D->getDeclContext()->getParent())); in handleIBOutletCollection()
1536 D->addAttr(::new (S.Context) IBOutletCollectionAttr(S.Context, AL, QTLoc)); in handleIBOutletCollection()
1579 static void handleNonNullAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNonNullAttr() argument
1584 if (!checkFunctionOrMethodParameterIndex(S, D, AL, I + 1, Ex, Idx)) in handleNonNullAttr()
1588 if (Idx.getASTIndex() < getFunctionOrMethodNumParams(D) && in handleNonNullAttr()
1590 S, getFunctionOrMethodParamType(D, Idx.getASTIndex()), AL, in handleNonNullAttr()
1592 getFunctionOrMethodParamRange(D, Idx.getASTIndex()))) in handleNonNullAttr()
1604 bool AnyPointers = isFunctionOrMethodVariadic(D); in handleNonNullAttr()
1605 for (unsigned I = 0, E = getFunctionOrMethodNumParams(D); in handleNonNullAttr()
1607 QualType T = getFunctionOrMethodParamType(D, I); in handleNonNullAttr()
1619 D->addAttr(::new (S.Context) NonNullAttr(S.Context, AL, Start, Size)); in handleNonNullAttr()
1622 static void handleNonNullAttrParameter(Sema &S, ParmVarDecl *D, in handleNonNullAttrParameter() argument
1625 if (D->getFunctionType()) { in handleNonNullAttrParameter()
1626 handleNonNullAttr(S, D, AL); in handleNonNullAttrParameter()
1629 << D->getSourceRange(); in handleNonNullAttrParameter()
1635 if (!attrNonNullArgCheck(S, D->getType(), AL, SourceRange(), in handleNonNullAttrParameter()
1636 D->getSourceRange())) in handleNonNullAttrParameter()
1639 D->addAttr(::new (S.Context) NonNullAttr(S.Context, AL, nullptr, 0)); in handleNonNullAttrParameter()
1642 static void handleReturnsNonNullAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleReturnsNonNullAttr() argument
1643 QualType ResultType = getFunctionOrMethodResultType(D); in handleReturnsNonNullAttr()
1644 SourceRange SR = getFunctionOrMethodResultSourceRange(D); in handleReturnsNonNullAttr()
1649 D->addAttr(::new (S.Context) ReturnsNonNullAttr(S.Context, AL)); in handleReturnsNonNullAttr()
1652 static void handleNoEscapeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNoEscapeAttr() argument
1653 if (D->isInvalidDecl()) in handleNoEscapeAttr()
1657 QualType T = cast<ParmVarDecl>(D)->getType(); in handleNoEscapeAttr()
1664 D->addAttr(::new (S.Context) NoEscapeAttr(S.Context, AL)); in handleNoEscapeAttr()
1667 static void handleAssumeAlignedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAssumeAlignedAttr() argument
1670 S.AddAssumeAlignedAttr(D, AL, E, OE); in handleAssumeAlignedAttr()
1673 static void handleAllocAlignAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAllocAlignAttr() argument
1674 S.AddAllocAlignAttr(D, AL, AL.getArgAsExpr(0)); in handleAllocAlignAttr()
1677 void Sema::AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, in AddAssumeAlignedAttr() argument
1679 QualType ResultType = getFunctionOrMethodResultType(D); in AddAssumeAlignedAttr()
1680 SourceRange SR = getFunctionOrMethodResultSourceRange(D); in AddAssumeAlignedAttr()
1723 D->addAttr(::new (Context) AssumeAlignedAttr(Context, CI, E, OE)); in AddAssumeAlignedAttr()
1726 void Sema::AddAllocAlignAttr(Decl *D, const AttributeCommonInfo &CI, in AddAllocAlignAttr() argument
1728 QualType ResultType = getFunctionOrMethodResultType(D); in AddAllocAlignAttr()
1736 << &TmpAttr << CI.getRange() << getFunctionOrMethodResultSourceRange(D); in AddAllocAlignAttr()
1741 const auto *FuncDecl = cast<FunctionDecl>(D); in AddAllocAlignAttr()
1746 QualType Ty = getFunctionOrMethodParamType(D, Idx.getASTIndex()); in AddAllocAlignAttr()
1755 D->addAttr(::new (Context) AllocAlignAttr(Context, CI, Idx)); in AddAllocAlignAttr()
1782 static void handleAssumumptionAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAssumumptionAttr() argument
1791 D->addAttr(::new (S.Context) AssumptionAttr(S.Context, AL, Str)); in handleAssumumptionAttr()
1805 static void handleOwnershipAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleOwnershipAttr() argument
1852 if (!checkFunctionOrMethodParameterIndex(S, D, AL, i, Ex, Idx)) in handleOwnershipAttr()
1856 QualType T = getFunctionOrMethodParamType(D, Idx.getASTIndex()); in handleOwnershipAttr()
1876 for (const auto *I : D->specific_attrs<OwnershipAttr>()) { in handleOwnershipAttr()
1903 D->addAttr(::new (S.Context) in handleOwnershipAttr()
1907 static void handleWeakRefAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleWeakRefAttr() argument
1924 const DeclContext *Ctx = D->getDeclContext()->getRedeclContext(); in handleWeakRefAttr()
1927 << cast<NamedDecl>(D); in handleWeakRefAttr()
1960 D->addAttr(::new (S.Context) AliasAttr(S.Context, AL, Str)); in handleWeakRefAttr()
1962 D->addAttr(::new (S.Context) WeakRefAttr(S.Context, AL)); in handleWeakRefAttr()
1965 static void handleIFuncAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleIFuncAttr() argument
1971 const auto *FD = cast<FunctionDecl>(D); in handleIFuncAttr()
1977 D->addAttr(::new (S.Context) IFuncAttr(S.Context, AL, Str)); in handleIFuncAttr()
1980 static void handleAliasAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAliasAttr() argument
1994 if (const auto *FD = dyn_cast<FunctionDecl>(D)) { in handleAliasAttr()
2000 const auto *VD = cast<VarDecl>(D); in handleAliasAttr()
2018 D->addAttr(::new (S.Context) AliasAttr(S.Context, AL, Str)); in handleAliasAttr()
2021 static void handleTLSModelAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleTLSModelAttr() argument
2041 D->addAttr(::new (S.Context) TLSModelAttr(S.Context, AL, Model)); in handleTLSModelAttr()
2044 static void handleRestrictAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleRestrictAttr() argument
2045 QualType ResultType = getFunctionOrMethodResultType(D); in handleRestrictAttr()
2047 D->addAttr(::new (S.Context) RestrictAttr(S.Context, AL)); in handleRestrictAttr()
2052 << AL << getFunctionOrMethodResultSourceRange(D); in handleRestrictAttr()
2055 static void handleCPUSpecificAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCPUSpecificAttr() argument
2059 if (checkAttrMutualExclusion<CPUSpecificAttr>(S, D, AL)) in handleCPUSpecificAttr()
2062 if (const auto *Other = D->getAttr<CPUDispatchAttr>()) { in handleCPUSpecificAttr()
2068 if (checkAttrMutualExclusion<CPUDispatchAttr>(S, D, AL)) in handleCPUSpecificAttr()
2071 if (const auto *Other = D->getAttr<CPUSpecificAttr>()) { in handleCPUSpecificAttr()
2078 FunctionDecl *FD = cast<FunctionDecl>(D); in handleCPUSpecificAttr()
2080 if (const auto *MD = dyn_cast<CXXMethodDecl>(D)) { in handleCPUSpecificAttr()
2120 D->addAttr(::new (S.Context) in handleCPUSpecificAttr()
2123 D->addAttr(::new (S.Context) in handleCPUSpecificAttr()
2127 static void handleCommonAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCommonAttr() argument
2134 D->addAttr(::new (S.Context) CommonAttr(S.Context, AL)); in handleCommonAttr()
2137 static void handleCmseNSEntryAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCmseNSEntryAttr() argument
2138 if (S.LangOpts.CPlusPlus && !D->getDeclContext()->isExternCContext()) { in handleCmseNSEntryAttr()
2143 const auto *FD = cast<FunctionDecl>(D); in handleCmseNSEntryAttr()
2149 D->addAttr(::new (S.Context) CmseNSEntryAttr(S.Context, AL)); in handleCmseNSEntryAttr()
2152 static void handleNakedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNakedAttr() argument
2165 if (S.getLangOpts().MSVCCompat && isa<CXXMethodDecl>(D)) { in handleNakedAttr()
2172 D->addAttr(::new (S.Context) NakedAttr(S.Context, AL)); in handleNakedAttr()
2175 static void handleNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &Attrs) { in handleNoReturnAttr() argument
2176 if (hasDeclarator(D)) return; in handleNoReturnAttr()
2178 if (!isa<ObjCMethodDecl>(D)) { in handleNoReturnAttr()
2184 D->addAttr(::new (S.Context) NoReturnAttr(S.Context, Attrs)); in handleNoReturnAttr()
2187 static void handleStandardNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &A) { in handleStandardNoReturnAttr() argument
2199 D->addAttr(::new (S.Context) CXX11NoReturnAttr(S.Context, A)); in handleStandardNoReturnAttr()
2202 static void handleNoCfCheckAttr(Sema &S, Decl *D, const ParsedAttr &Attrs) { in handleNoCfCheckAttr() argument
2206 handleSimpleAttribute<AnyX86NoCfCheckAttr>(S, D, Attrs); in handleNoCfCheckAttr()
2230 static void handleAnalyzerNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAnalyzerNoReturnAttr() argument
2234 if (!isFunctionOrMethodOrBlock(D)) { in handleAnalyzerNoReturnAttr()
2235 ValueDecl *VD = dyn_cast<ValueDecl>(D); in handleAnalyzerNoReturnAttr()
2246 D->addAttr(::new (S.Context) AnalyzerNoReturnAttr(S.Context, AL)); in handleAnalyzerNoReturnAttr()
2250 static void handleVecReturnAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleVecReturnAttr() argument
2275 if (VecReturnAttr *A = D->getAttr<VecReturnAttr>()) { in handleVecReturnAttr()
2280 const auto *R = cast<RecordDecl>(D); in handleVecReturnAttr()
2301 D->addAttr(::new (S.Context) VecReturnAttr(S.Context, AL)); in handleVecReturnAttr()
2304 static void handleDependencyAttr(Sema &S, Scope *Scope, Decl *D, in handleDependencyAttr() argument
2306 if (isa<ParmVarDecl>(D)) { in handleDependencyAttr()
2316 D->addAttr(::new (S.Context) CarriesDependencyAttr(S.Context, AL)); in handleDependencyAttr()
2319 static void handleUnusedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleUnusedAttr() argument
2327 D->addAttr(::new (S.Context) UnusedAttr(S.Context, AL)); in handleUnusedAttr()
2330 static void handleConstructorAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleConstructorAttr() argument
2336 D->addAttr(::new (S.Context) ConstructorAttr(S.Context, AL, priority)); in handleConstructorAttr()
2339 static void handleDestructorAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleDestructorAttr() argument
2345 D->addAttr(::new (S.Context) DestructorAttr(S.Context, AL, priority)); in handleDestructorAttr()
2349 static void handleAttrWithMessage(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAttrWithMessage() argument
2355 D->addAttr(::new (S.Context) AttrTy(S.Context, AL, Str)); in handleAttrWithMessage()
2358 static void handleObjCSuppresProtocolAttr(Sema &S, Decl *D, in handleObjCSuppresProtocolAttr() argument
2360 if (!cast<ObjCProtocolDecl>(D)->isThisDeclarationADefinition()) { in handleObjCSuppresProtocolAttr()
2366 D->addAttr(::new (S.Context) ObjCExplicitProtocolImplAttr(S.Context, AL)); in handleObjCSuppresProtocolAttr()
2427 NamedDecl *D, const AttributeCommonInfo &CI, IdentifierInfo *Platform, in mergeAvailabilityAttr() argument
2450 if (D->hasAttrs()) { in mergeAvailabilityAttr()
2451 AttrVec &Attrs = D->getAttrs(); in mergeAvailabilityAttr()
2590 static void handleAvailabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAvailabilityAttr() argument
2592 D)) { in handleAvailabilityAttr()
2607 auto *ND = dyn_cast<NamedDecl>(D); in handleAvailabilityAttr()
2649 D->addAttr(NewAttr); in handleAvailabilityAttr()
2706 D->addAttr(NewAttr); in handleAvailabilityAttr()
2748 D->addAttr(NewAttr); in handleAvailabilityAttr()
2781 D->addAttr(NewAttr); in handleAvailabilityAttr()
2823 D->addAttr(NewAttr); in handleAvailabilityAttr()
2830 static void handleExternalSourceSymbolAttr(Sema &S, Decl *D, in handleExternalSourceSymbolAttr() argument
2843 D->addAttr(::new (S.Context) ExternalSourceSymbolAttr( in handleExternalSourceSymbolAttr()
2848 static T *mergeVisibilityAttr(Sema &S, Decl *D, const AttributeCommonInfo &CI, in mergeVisibilityAttr() argument
2850 T *existingAttr = D->getAttr<T>(); in mergeVisibilityAttr()
2857 D->dropAttr<T>(); in mergeVisibilityAttr()
2862 VisibilityAttr *Sema::mergeVisibilityAttr(Decl *D, in mergeVisibilityAttr() argument
2865 return ::mergeVisibilityAttr<VisibilityAttr>(*this, D, CI, Vis); in mergeVisibilityAttr()
2869 Sema::mergeTypeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, in mergeTypeVisibilityAttr() argument
2871 return ::mergeVisibilityAttr<TypeVisibilityAttr>(*this, D, CI, Vis); in mergeTypeVisibilityAttr()
2874 static void handleVisibilityAttr(Sema &S, Decl *D, const ParsedAttr &AL, in handleVisibilityAttr() argument
2877 if (isa<TypedefNameDecl>(D)) { in handleVisibilityAttr()
2884 !(isa<TagDecl>(D) || in handleVisibilityAttr()
2885 isa<ObjCInterfaceDecl>(D) || in handleVisibilityAttr()
2886 isa<NamespaceDecl>(D))) { in handleVisibilityAttr()
2916 D, AL, (TypeVisibilityAttr::VisibilityType)type); in handleVisibilityAttr()
2918 newAttr = S.mergeVisibilityAttr(D, AL, type); in handleVisibilityAttr()
2921 D->addAttr(newAttr); in handleVisibilityAttr()
2924 static void handleObjCDirectAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleObjCDirectAttr() argument
2926 if (isa<ObjCProtocolDecl>(D->getDeclContext())) { in handleObjCDirectAttr()
2932 handleSimpleAttribute<ObjCDirectAttr>(S, D, AL); in handleObjCDirectAttr()
2938 static void handleObjCDirectMembersAttr(Sema &S, Decl *D, in handleObjCDirectMembersAttr() argument
2941 handleSimpleAttribute<ObjCDirectMembersAttr>(S, D, AL); in handleObjCDirectMembersAttr()
2947 static void handleObjCMethodFamilyAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleObjCMethodFamilyAttr() argument
2948 const auto *M = cast<ObjCMethodDecl>(D); in handleObjCMethodFamilyAttr()
2970 D->addAttr(new (S.Context) ObjCMethodFamilyAttr(S.Context, AL, F)); in handleObjCMethodFamilyAttr()
2973 static void handleObjCNSObject(Sema &S, Decl *D, const ParsedAttr &AL) { in handleObjCNSObject() argument
2974 if (const auto *TD = dyn_cast<TypedefNameDecl>(D)) { in handleObjCNSObject()
2981 else if (const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) { in handleObjCNSObject()
2995 S.Diag(D->getLocation(), diag::warn_nsobject_attribute); in handleObjCNSObject()
2997 D->addAttr(::new (S.Context) ObjCNSObjectAttr(S.Context, AL)); in handleObjCNSObject()
3000 static void handleObjCIndependentClass(Sema &S, Decl *D, const ParsedAttr &AL) { in handleObjCIndependentClass() argument
3001 if (const auto *TD = dyn_cast<TypedefNameDecl>(D)) { in handleObjCIndependentClass()
3008 S.Diag(D->getLocation(), diag::warn_independentclass_attribute); in handleObjCIndependentClass()
3011 D->addAttr(::new (S.Context) ObjCIndependentClassAttr(S.Context, AL)); in handleObjCIndependentClass()
3014 static void handleBlocksAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleBlocksAttr() argument
3028 D->addAttr(::new (S.Context) BlocksAttr(S.Context, AL, type)); in handleBlocksAttr()
3031 static void handleSentinelAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSentinelAttr() argument
3071 if (const auto *FD = dyn_cast<FunctionDecl>(D)) { in handleSentinelAttr()
3082 } else if (const auto *MD = dyn_cast<ObjCMethodDecl>(D)) { in handleSentinelAttr()
3087 } else if (const auto *BD = dyn_cast<BlockDecl>(D)) { in handleSentinelAttr()
3092 } else if (const auto *V = dyn_cast<VarDecl>(D)) { in handleSentinelAttr()
3096 ? D->getFunctionType() in handleSentinelAttr()
3115 D->addAttr(::new (S.Context) SentinelAttr(S.Context, AL, sentinel, nullPos)); in handleSentinelAttr()
3118 static void handleWarnUnusedResult(Sema &S, Decl *D, const ParsedAttr &AL) { in handleWarnUnusedResult() argument
3119 if (D->getFunctionType() && in handleWarnUnusedResult()
3120 D->getFunctionType()->getReturnType()->isVoidType() && in handleWarnUnusedResult()
3121 !isa<CXXConstructorDecl>(D)) { in handleWarnUnusedResult()
3125 if (const auto *MD = dyn_cast<ObjCMethodDecl>(D)) in handleWarnUnusedResult()
3135 if (isa<VarDecl>(D)) in handleWarnUnusedResult()
3161 isa<TypedefNameDecl>(D)) { in handleWarnUnusedResult()
3167 D->addAttr(::new (S.Context) WarnUnusedResultAttr(S.Context, AL, Str)); in handleWarnUnusedResult()
3170 static void handleWeakImportAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleWeakImportAttr() argument
3173 if (!D->canBeWeakImported(isDef)) { in handleWeakImportAttr()
3177 else if (isa<ObjCPropertyDecl>(D) || isa<ObjCMethodDecl>(D) || in handleWeakImportAttr()
3179 (isa<ObjCInterfaceDecl>(D) || isa<EnumDecl>(D)))) { in handleWeakImportAttr()
3188 D->addAttr(::new (S.Context) WeakImportAttr(S.Context, AL)); in handleWeakImportAttr()
3193 static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { in handleWorkGroupSize() argument
3207 WorkGroupAttr *Existing = D->getAttr<WorkGroupAttr>(); in handleWorkGroupSize()
3213 D->addAttr(::new (S.Context) in handleWorkGroupSize()
3218 static void handleSubGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSubGroupSize() argument
3230 D->getAttr<OpenCLIntelReqdSubGroupSizeAttr>(); in handleSubGroupSize()
3234 D->addAttr(::new (S.Context) in handleSubGroupSize()
3238 static void handleVecTypeHint(Sema &S, Decl *D, const ParsedAttr &AL) { in handleVecTypeHint() argument
3255 if (VecTypeHintAttr *A = D->getAttr<VecTypeHintAttr>()) { in handleVecTypeHint()
3262 D->addAttr(::new (S.Context) VecTypeHintAttr(S.Context, AL, ParmTSI)); in handleVecTypeHint()
3265 SectionAttr *Sema::mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI, in mergeSectionAttr() argument
3269 if (const auto *FD = dyn_cast<FunctionDecl>(D)) { in mergeSectionAttr()
3274 if (SectionAttr *ExistingAttr = D->getAttr<SectionAttr>()) { in mergeSectionAttr()
3315 static void handleSectionAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSectionAttr() argument
3326 SectionAttr *NewAttr = S.mergeSectionAttr(D, AL, Str); in handleSectionAttr()
3328 D->addAttr(NewAttr); in handleSectionAttr()
3330 ObjCPropertyDecl>(D)) in handleSectionAttr()
3333 cast<NamedDecl>(D)); in handleSectionAttr()
3350 CodeSegAttr *Sema::mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI, in mergeCodeSegAttr() argument
3354 if (const auto *FD = dyn_cast<FunctionDecl>(D)) { in mergeCodeSegAttr()
3358 if (const auto *ExistingAttr = D->getAttr<CodeSegAttr>()) { in mergeCodeSegAttr()
3369 static void handleCodeSegAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCodeSegAttr() argument
3376 if (const auto *ExistingAttr = D->getAttr<CodeSegAttr>()) { in handleCodeSegAttr()
3384 D->dropAttr<CodeSegAttr>(); in handleCodeSegAttr()
3386 if (CodeSegAttr *CSA = S.mergeCodeSegAttr(D, AL, Str)) in handleCodeSegAttr()
3387 D->addAttr(CSA); in handleCodeSegAttr()
3451 static void handleTargetAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleTargetAttr() argument
3459 D->addAttr(NewAttr); in handleTargetAttr()
3513 static void handleTargetClonesAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleTargetClonesAttr() argument
3516 if (const auto *Other = D->getAttr<TargetClonesAttr>()) { in handleTargetClonesAttr()
3521 if (checkAttrMutualExclusion<TargetClonesAttr>(S, D, AL)) in handleTargetClonesAttr()
3548 if (const auto *MD = dyn_cast<CXXMethodDecl>(D)) { in handleTargetClonesAttr()
3550 S.Diag(D->getLocation(), diag::err_multiversion_doesnt_support) in handleTargetClonesAttr()
3557 cast<FunctionDecl>(D)->setIsMultiVersion(); in handleTargetClonesAttr()
3560 D->addAttr(NewAttr); in handleTargetClonesAttr()
3563 static void handleMinVectorWidthAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleMinVectorWidthAttr() argument
3571 MinVectorWidthAttr *Existing = D->getAttr<MinVectorWidthAttr>(); in handleMinVectorWidthAttr()
3577 D->addAttr(::new (S.Context) MinVectorWidthAttr(S.Context, AL, VecWidth)); in handleMinVectorWidthAttr()
3580 static void handleCleanupAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCleanupAttr() argument
3623 QualType Ty = S.Context.getPointerType(cast<VarDecl>(D)->getType()); in handleCleanupAttr()
3632 D->addAttr(::new (S.Context) CleanupAttr(S.Context, AL, FD)); in handleCleanupAttr()
3635 static void handleEnumExtensibilityAttr(Sema &S, Decl *D, in handleEnumExtensibilityAttr() argument
3651 D->addAttr(::new (S.Context) in handleEnumExtensibilityAttr()
3657 static void handleFormatArgAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleFormatArgAttr() argument
3660 if (!checkFunctionOrMethodParameterIndex(S, D, AL, 1, IdxExpr, Idx)) in handleFormatArgAttr()
3664 QualType Ty = getFunctionOrMethodParamType(D, Idx.getASTIndex()); in handleFormatArgAttr()
3672 << IdxExpr->getSourceRange() << getFunctionOrMethodParamRange(D, 0); in handleFormatArgAttr()
3675 Ty = getFunctionOrMethodResultType(D); in handleFormatArgAttr()
3679 if (auto *OMD = dyn_cast<ObjCMethodDecl>(D)) in handleFormatArgAttr()
3689 << IdxExpr->getSourceRange() << getFunctionOrMethodParamRange(D, 0); in handleFormatArgAttr()
3693 D->addAttr(::new (S.Context) FormatArgAttr(S.Context, AL, Idx)); in handleFormatArgAttr()
3728 static void handleInitPriorityAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleInitPriorityAttr() argument
3739 QualType T = cast<VarDecl>(D)->getType(); in handleInitPriorityAttr()
3765 D->addAttr(::new (S.Context) InitPriorityAttr(S.Context, AL, prioritynum)); in handleInitPriorityAttr()
3768 ErrorAttr *Sema::mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI, in mergeErrorAttr() argument
3770 if (const auto *EA = D->getAttr<ErrorAttr>()) { in mergeErrorAttr()
3786 D->dropAttr<ErrorAttr>(); in mergeErrorAttr()
3791 FormatAttr *Sema::mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI, in mergeFormatAttr() argument
3795 for (auto *F : D->specific_attrs<FormatAttr>()) { in mergeFormatAttr()
3812 static void handleFormatAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleFormatAttr() argument
3821 bool HasImplicitThisParam = isInstanceMethod(D); in handleFormatAttr()
3822 unsigned NumArgs = getFunctionOrMethodNumParams(D) + HasImplicitThisParam; in handleFormatAttr()
3870 QualType Ty = getFunctionOrMethodParamType(D, ArgIdx); in handleFormatAttr()
3877 << IdxExpr->getSourceRange() << getFunctionOrMethodParamRange(D, ArgIdx); in handleFormatAttr()
3889 if (isFunctionOrMethodVariadic(D)) in handleFormatAttr()
3892 S.Diag(D->getLocation(), diag::warn_gcc_requires_variadic_function) << AL; in handleFormatAttr()
3910 FormatAttr *NewAttr = S.mergeFormatAttr(D, AL, II, Idx, FirstArg); in handleFormatAttr()
3912 D->addAttr(NewAttr); in handleFormatAttr()
3916 static void handleCallbackAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCallbackAttr() argument
3924 bool HasImplicitThisParam = isInstanceMethod(D); in handleCallbackAttr()
3925 int32_t NumArgs = getFunctionOrMethodNumParams(D); in handleCallbackAttr()
3927 FunctionDecl *FD = D->getAsFunction(); in handleCallbackAttr()
4007 getFunctionOrMethodParamType(D, CalleeIdx - HasImplicitThisParam) in handleCallbackAttr()
4045 if (D->hasAttr<CallbackAttr>()) { in handleCallbackAttr()
4050 D->addAttr(::new (S.Context) CallbackAttr( in handleCallbackAttr()
4062 static void handleCalledOnceAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCalledOnceAttr() argument
4064 QualType T = cast<ParmVarDecl>(D)->getType(); in handleCalledOnceAttr()
4071 D->addAttr(::new (S.Context) CalledOnceAttr(S.Context, AL)); in handleCalledOnceAttr()
4074 static void handleTransparentUnionAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleTransparentUnionAttr() argument
4077 const auto *TD = dyn_cast<TypedefNameDecl>(D); in handleTransparentUnionAttr()
4081 RD = dyn_cast<RecordDecl>(D); in handleTransparentUnionAttr()
4145 void Sema::AddAnnotationAttr(Decl *D, const AttributeCommonInfo &CI, in AddAnnotationAttr() argument
4150 D->addAttr(Attr); in AddAnnotationAttr()
4154 static void handleAnnotateAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAnnotateAttr() argument
4168 S.AddAnnotationAttr(D, AL, Str, Args); in handleAnnotateAttr()
4171 static void handleAlignValueAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAlignValueAttr() argument
4172 S.AddAlignValueAttr(D, AL, AL.getArgAsExpr(0)); in handleAlignValueAttr()
4175 void Sema::AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E) { in AddAlignValueAttr() argument
4180 if (const auto *TD = dyn_cast<TypedefNameDecl>(D)) in AddAlignValueAttr()
4182 else if (const auto *VD = dyn_cast<ValueDecl>(D)) in AddAlignValueAttr()
4190 << &TmpAttr << T << D->getSourceRange(); in AddAlignValueAttr()
4207 D->addAttr(::new (Context) AlignValueAttr(Context, CI, ICE.get())); in AddAlignValueAttr()
4212 D->addAttr(::new (Context) AlignValueAttr(Context, CI, E)); in AddAlignValueAttr()
4215 static void handleAlignedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAlignedAttr() argument
4223 D->addAttr(::new (S.Context) AlignedAttr(S.Context, AL, true, nullptr)); in handleAlignedAttr()
4237 S.AddAlignedAttr(D, AL, E, AL.isPackExpansion()); in handleAlignedAttr()
4240 void Sema::AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, in AddAlignedAttr() argument
4262 if (isa<ParmVarDecl>(D)) { in AddAlignedAttr()
4264 } else if (const auto *VD = dyn_cast<VarDecl>(D)) { in AddAlignedAttr()
4269 } else if (const auto *FD = dyn_cast<FieldDecl>(D)) { in AddAlignedAttr()
4272 } else if (const auto *ED = dyn_cast<EnumDecl>(D)) { in AddAlignedAttr()
4275 } else if (!isa<TagDecl>(D)) { in AddAlignedAttr()
4292 if (const auto *TND = dyn_cast<TypedefNameDecl>(D)) { in AddAlignedAttr()
4303 D->addAttr(AA); in AddAlignedAttr()
4337 const auto *VD = dyn_cast<VarDecl>(D); in AddAlignedAttr()
4363 D->addAttr(AA); in AddAlignedAttr()
4366 void Sema::AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, in AddAlignedAttr() argument
4372 D->addAttr(AA); in AddAlignedAttr()
4375 void Sema::CheckAlignasUnderalignment(Decl *D) { in CheckAlignasUnderalignment() argument
4376 assert(D->hasAttrs() && "no attributes on decl"); in CheckAlignasUnderalignment()
4379 if (const auto *VD = dyn_cast<ValueDecl>(D)) { in CheckAlignasUnderalignment()
4382 UnderlyingTy = DiagTy = Context.getTagDeclType(cast<TagDecl>(D)); in CheckAlignasUnderalignment()
4383 if (const auto *ED = dyn_cast<EnumDecl>(D)) in CheckAlignasUnderalignment()
4396 for (auto *I : D->specific_attrs<AlignedAttr>()) { in CheckAlignasUnderalignment()
4518 static void handleModeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleModeAttr() argument
4529 S.AddModeAttr(D, AL, Name); in handleModeAttr()
4532 void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo &CI, in AddModeAttr() argument
4577 if (const auto *TD = dyn_cast<TypedefNameDecl>(D)) in AddModeAttr()
4579 else if (const auto *ED = dyn_cast<EnumDecl>(D)) { in AddModeAttr()
4586 OldTy = cast<ValueDecl>(D)->getType(); in AddModeAttr()
4589 D->addAttr(::new (Context) ModeAttr(Context, CI, Name)); in AddModeAttr()
4602 if ((isa<EnumDecl>(D) || OldElemTy->getAs<EnumType>()) && in AddModeAttr()
4665 if (auto *TD = dyn_cast<TypedefNameDecl>(D)) in AddModeAttr()
4667 else if (auto *ED = dyn_cast<EnumDecl>(D)) in AddModeAttr()
4670 cast<ValueDecl>(D)->setType(NewTy); in AddModeAttr()
4672 D->addAttr(::new (Context) ModeAttr(Context, CI, Name)); in AddModeAttr()
4675 static void handleNoDebugAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNoDebugAttr() argument
4676 D->addAttr(::new (S.Context) NoDebugAttr(S.Context, AL)); in handleNoDebugAttr()
4679 AlwaysInlineAttr *Sema::mergeAlwaysInlineAttr(Decl *D, in mergeAlwaysInlineAttr() argument
4682 if (OptimizeNoneAttr *Optnone = D->getAttr<OptimizeNoneAttr>()) { in mergeAlwaysInlineAttr()
4688 if (D->hasAttr<AlwaysInlineAttr>()) in mergeAlwaysInlineAttr()
4694 InternalLinkageAttr *Sema::mergeInternalLinkageAttr(Decl *D, in mergeInternalLinkageAttr() argument
4696 if (const auto *VD = dyn_cast<VarDecl>(D)) { in mergeInternalLinkageAttr()
4715 Sema::mergeInternalLinkageAttr(Decl *D, const InternalLinkageAttr &AL) { in mergeInternalLinkageAttr() argument
4716 if (const auto *VD = dyn_cast<VarDecl>(D)) { in mergeInternalLinkageAttr()
4735 MinSizeAttr *Sema::mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI) { in mergeMinSizeAttr() argument
4736 if (OptimizeNoneAttr *Optnone = D->getAttr<OptimizeNoneAttr>()) { in mergeMinSizeAttr()
4742 if (D->hasAttr<MinSizeAttr>()) in mergeMinSizeAttr()
4748 SwiftNameAttr *Sema::mergeSwiftNameAttr(Decl *D, const SwiftNameAttr &SNA, in mergeSwiftNameAttr() argument
4750 if (const auto *PrevSNA = D->getAttr<SwiftNameAttr>()) { in mergeSwiftNameAttr()
4757 D->dropAttr<SwiftNameAttr>(); in mergeSwiftNameAttr()
4762 OptimizeNoneAttr *Sema::mergeOptimizeNoneAttr(Decl *D, in mergeOptimizeNoneAttr() argument
4764 if (AlwaysInlineAttr *Inline = D->getAttr<AlwaysInlineAttr>()) { in mergeOptimizeNoneAttr()
4767 D->dropAttr<AlwaysInlineAttr>(); in mergeOptimizeNoneAttr()
4769 if (MinSizeAttr *MinSize = D->getAttr<MinSizeAttr>()) { in mergeOptimizeNoneAttr()
4772 D->dropAttr<MinSizeAttr>(); in mergeOptimizeNoneAttr()
4775 if (D->hasAttr<OptimizeNoneAttr>()) in mergeOptimizeNoneAttr()
4781 static void handleAlwaysInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAlwaysInlineAttr() argument
4783 S.mergeAlwaysInlineAttr(D, AL, AL.getAttrName())) in handleAlwaysInlineAttr()
4784 D->addAttr(Inline); in handleAlwaysInlineAttr()
4787 static void handleMinSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleMinSizeAttr() argument
4788 if (MinSizeAttr *MinSize = S.mergeMinSizeAttr(D, AL)) in handleMinSizeAttr()
4789 D->addAttr(MinSize); in handleMinSizeAttr()
4792 static void handleOptimizeNoneAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleOptimizeNoneAttr() argument
4793 if (OptimizeNoneAttr *Optnone = S.mergeOptimizeNoneAttr(D, AL)) in handleOptimizeNoneAttr()
4794 D->addAttr(Optnone); in handleOptimizeNoneAttr()
4797 static void handleConstantAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleConstantAttr() argument
4798 const auto *VD = cast<VarDecl>(D); in handleConstantAttr()
4805 if (auto *A = D->getAttr<CUDAConstantAttr>()) { in handleConstantAttr()
4808 D->dropAttr<CUDAConstantAttr>(); in handleConstantAttr()
4810 D->addAttr(::new (S.Context) CUDAConstantAttr(S.Context, AL)); in handleConstantAttr()
4813 static void handleSharedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSharedAttr() argument
4814 const auto *VD = cast<VarDecl>(D); in handleSharedAttr()
4826 D->addAttr(::new (S.Context) CUDASharedAttr(S.Context, AL)); in handleSharedAttr()
4829 static void handleGlobalAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleGlobalAttr() argument
4830 const auto *FD = cast<FunctionDecl>(D); in handleGlobalAttr()
4853 D->addAttr(::new (S.Context) CUDAGlobalAttr(S.Context, AL)); in handleGlobalAttr()
4859 D->addAttr(NoDebugAttr::CreateImplicit(S.Context)); in handleGlobalAttr()
4862 static void handleDeviceAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleDeviceAttr() argument
4863 if (const auto *VD = dyn_cast<VarDecl>(D)) { in handleDeviceAttr()
4870 if (auto *A = D->getAttr<CUDADeviceAttr>()) { in handleDeviceAttr()
4873 D->dropAttr<CUDADeviceAttr>(); in handleDeviceAttr()
4875 D->addAttr(::new (S.Context) CUDADeviceAttr(S.Context, AL)); in handleDeviceAttr()
4878 static void handleManagedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleManagedAttr() argument
4879 if (const auto *VD = dyn_cast<VarDecl>(D)) { in handleManagedAttr()
4885 if (!D->hasAttr<HIPManagedAttr>()) in handleManagedAttr()
4886 D->addAttr(::new (S.Context) HIPManagedAttr(S.Context, AL)); in handleManagedAttr()
4887 if (!D->hasAttr<CUDADeviceAttr>()) in handleManagedAttr()
4888 D->addAttr(CUDADeviceAttr::CreateImplicit(S.Context)); in handleManagedAttr()
4891 static void handleGNUInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleGNUInlineAttr() argument
4892 const auto *Fn = cast<FunctionDecl>(D); in handleGNUInlineAttr()
4901 D->addAttr(::new (S.Context) GNUInlineAttr(S.Context, AL)); in handleGNUInlineAttr()
4904 static void handleCallConvAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCallConvAttr() argument
4905 if (hasDeclarator(D)) return; in handleCallConvAttr()
4913 if (!isa<ObjCMethodDecl>(D)) { in handleCallConvAttr()
4921 D->addAttr(::new (S.Context) FastCallAttr(S.Context, AL)); in handleCallConvAttr()
4924 D->addAttr(::new (S.Context) StdCallAttr(S.Context, AL)); in handleCallConvAttr()
4927 D->addAttr(::new (S.Context) ThisCallAttr(S.Context, AL)); in handleCallConvAttr()
4930 D->addAttr(::new (S.Context) CDeclAttr(S.Context, AL)); in handleCallConvAttr()
4933 D->addAttr(::new (S.Context) PascalAttr(S.Context, AL)); in handleCallConvAttr()
4936 D->addAttr(::new (S.Context) SwiftCallAttr(S.Context, AL)); in handleCallConvAttr()
4939 D->addAttr(::new (S.Context) SwiftAsyncCallAttr(S.Context, AL)); in handleCallConvAttr()
4942 D->addAttr(::new (S.Context) VectorCallAttr(S.Context, AL)); in handleCallConvAttr()
4945 D->addAttr(::new (S.Context) MSABIAttr(S.Context, AL)); in handleCallConvAttr()
4948 D->addAttr(::new (S.Context) SysVABIAttr(S.Context, AL)); in handleCallConvAttr()
4951 D->addAttr(::new (S.Context) RegCallAttr(S.Context, AL)); in handleCallConvAttr()
4966 D->addAttr(::new (S.Context) PcsAttr(S.Context, AL, PCS)); in handleCallConvAttr()
4970 D->addAttr(::new (S.Context) AArch64VectorPcsAttr(S.Context, AL)); in handleCallConvAttr()
4973 D->addAttr(::new (S.Context) AArch64SVEPcsAttr(S.Context, AL)); in handleCallConvAttr()
4976 D->addAttr(::new (S.Context) AMDGPUKernelCallAttr(S.Context, AL)); in handleCallConvAttr()
4979 D->addAttr(::new (S.Context) IntelOclBiccAttr(S.Context, AL)); in handleCallConvAttr()
4982 D->addAttr(::new (S.Context) PreserveMostAttr(S.Context, AL)); in handleCallConvAttr()
4985 D->addAttr(::new (S.Context) PreserveAllAttr(S.Context, AL)); in handleCallConvAttr()
4992 static void handleSuppressAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSuppressAttr() argument
5007 D->addAttr(::new (S.Context) in handleSuppressAttr()
5012 static void handleLifetimeCategoryAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleLifetimeCategoryAttr() argument
5036 D = D->getCanonicalDecl(); in handleLifetimeCategoryAttr()
5038 if (checkAttrMutualExclusion<PointerAttr>(S, D, AL)) in handleLifetimeCategoryAttr()
5040 if (const auto *OAttr = D->getAttr<OwnerAttr>()) { in handleLifetimeCategoryAttr()
5051 for (Decl *Redecl : D->redecls()) { in handleLifetimeCategoryAttr()
5055 if (checkAttrMutualExclusion<OwnerAttr>(S, D, AL)) in handleLifetimeCategoryAttr()
5057 if (const auto *PAttr = D->getAttr<PointerAttr>()) { in handleLifetimeCategoryAttr()
5068 for (Decl *Redecl : D->redecls()) { in handleLifetimeCategoryAttr()
5075 static void handleRandomizeLayoutAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleRandomizeLayoutAttr() argument
5076 if (checkAttrMutualExclusion<NoRandomizeLayoutAttr>(S, D, AL)) in handleRandomizeLayoutAttr()
5078 if (!D->hasAttr<RandomizeLayoutAttr>()) in handleRandomizeLayoutAttr()
5079 D->addAttr(::new (S.Context) RandomizeLayoutAttr(S.Context, AL)); in handleRandomizeLayoutAttr()
5082 static void handleNoRandomizeLayoutAttr(Sema &S, Decl *D, in handleNoRandomizeLayoutAttr() argument
5084 if (checkAttrMutualExclusion<RandomizeLayoutAttr>(S, D, AL)) in handleNoRandomizeLayoutAttr()
5086 if (!D->hasAttr<NoRandomizeLayoutAttr>()) in handleNoRandomizeLayoutAttr()
5087 D->addAttr(::new (S.Context) NoRandomizeLayoutAttr(S.Context, AL)); in handleNoRandomizeLayoutAttr()
5287 void Sema::AddParameterABIAttr(Decl *D, const AttributeCommonInfo &CI, in AddParameterABIAttr() argument
5290 QualType type = cast<ParmVarDecl>(D)->getType(); in AddParameterABIAttr()
5292 if (auto existingAttr = D->getAttr<ParameterABIAttr>()) { in AddParameterABIAttr()
5310 D->addAttr(::new (Context) SwiftContextAttr(Context, CI)); in AddParameterABIAttr()
5318 D->addAttr(::new (Context) SwiftAsyncContextAttr(Context, CI)); in AddParameterABIAttr()
5326 D->addAttr(::new (Context) SwiftErrorResultAttr(Context, CI)); in AddParameterABIAttr()
5334 D->addAttr(::new (Context) SwiftIndirectResultAttr(Context, CI)); in AddParameterABIAttr()
5417 void Sema::AddLaunchBoundsAttr(Decl *D, const AttributeCommonInfo &CI, in AddLaunchBoundsAttr() argument
5430 D->addAttr(::new (Context) in AddLaunchBoundsAttr()
5434 static void handleLaunchBoundsAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleLaunchBoundsAttr() argument
5438 S.AddLaunchBoundsAttr(D, AL, AL.getArgAsExpr(0), in handleLaunchBoundsAttr()
5442 static void handleArgumentWithTypeTagAttr(Sema &S, Decl *D, in handleArgumentWithTypeTagAttr() argument
5451 if (!checkFunctionOrMethodParameterIndex(S, D, AL, 2, AL.getArgAsExpr(1), in handleArgumentWithTypeTagAttr()
5456 if (!checkFunctionOrMethodParameterIndex(S, D, AL, 3, AL.getArgAsExpr(2), in handleArgumentWithTypeTagAttr()
5464 if (ArgumentIdxAST >= getFunctionOrMethodNumParams(D) || in handleArgumentWithTypeTagAttr()
5465 !getFunctionOrMethodParamType(D, ArgumentIdxAST)->isPointerType()) in handleArgumentWithTypeTagAttr()
5469 D->addAttr(::new (S.Context) ArgumentWithTypeTagAttr( in handleArgumentWithTypeTagAttr()
5474 static void handleTypeTagForDatatypeAttr(Sema &S, Decl *D, in handleTypeTagForDatatypeAttr() argument
5485 if (!isa<VarDecl>(D)) { in handleTypeTagForDatatypeAttr()
5496 D->addAttr(::new (S.Context) TypeTagForDatatypeAttr( in handleTypeTagForDatatypeAttr()
5501 static void handleXRayLogArgsAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleXRayLogArgsAttr() argument
5504 if (!checkFunctionOrMethodParameterIndex(S, D, AL, 1, AL.getArgAsExpr(0), in handleXRayLogArgsAttr()
5510 D->addAttr(::new (S.Context) in handleXRayLogArgsAttr()
5514 static void handlePatchableFunctionEntryAttr(Sema &S, Decl *D, in handlePatchableFunctionEntryAttr() argument
5529 D->addAttr(::new (S.Context) in handlePatchableFunctionEntryAttr()
5581 static void handleArmBuiltinAliasAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleArmBuiltinAliasAttr() argument
5590 StringRef AliasName = cast<FunctionDecl>(D)->getIdentifier()->getName(); in handleArmBuiltinAliasAttr()
5600 D->addAttr(::new (S.Context) ArmBuiltinAliasAttr(S.Context, AL, Ident)); in handleArmBuiltinAliasAttr()
5608 static void handleBuiltinAliasAttr(Sema &S, Decl *D, in handleBuiltinAliasAttr() argument
5618 StringRef AliasName = cast<FunctionDecl>(D)->getIdentifier()->getName(); in handleBuiltinAliasAttr()
5633 D->addAttr(::new (S.Context) BuiltinAliasAttr(S.Context, AL, Ident)); in handleBuiltinAliasAttr()
5660 void Sema::AddXConsumedAttr(Decl *D, const AttributeCommonInfo &CI, in AddXConsumedAttr() argument
5663 ValueDecl *VD = cast<ValueDecl>(D); in AddXConsumedAttr()
5728 static bool isValidOSObjectOutParameter(const Decl *D) { in isValidOSObjectOutParameter() argument
5729 const auto *PVD = dyn_cast<ParmVarDecl>(D); in isValidOSObjectOutParameter()
5737 static void handleXReturnsXRetainedAttr(Sema &S, Decl *D, in handleXReturnsXRetainedAttr() argument
5742 if (const auto *MD = dyn_cast<ObjCMethodDecl>(D)) { in handleXReturnsXRetainedAttr()
5744 } else if (S.getLangOpts().ObjCAutoRefCount && hasDeclarator(D) && in handleXReturnsXRetainedAttr()
5747 } else if (const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) { in handleXReturnsXRetainedAttr()
5749 } else if (const auto *FD = dyn_cast<FunctionDecl>(D)) { in handleXReturnsXRetainedAttr()
5751 } else if (const auto *Param = dyn_cast<ParmVarDecl>(D)) { in handleXReturnsXRetainedAttr()
5759 S.Diag(D->getBeginLoc(), diag::warn_ns_attribute_wrong_parameter_type) in handleXReturnsXRetainedAttr()
5782 S.Diag(D->getBeginLoc(), diag::warn_attribute_wrong_decl_type) in handleXReturnsXRetainedAttr()
5821 if (isa<ParmVarDecl>(D)) { in handleXReturnsXRetainedAttr()
5822 S.Diag(D->getBeginLoc(), diag::warn_ns_attribute_wrong_parameter_type) in handleXReturnsXRetainedAttr()
5831 if (isa<ObjCMethodDecl>(D)) in handleXReturnsXRetainedAttr()
5833 else if (isa<ObjCPropertyDecl>(D)) in handleXReturnsXRetainedAttr()
5835 S.Diag(D->getBeginLoc(), diag::warn_ns_attribute_wrong_return_type) in handleXReturnsXRetainedAttr()
5845 handleSimpleAttribute<NSReturnsAutoreleasedAttr>(S, D, AL); in handleXReturnsXRetainedAttr()
5848 handleSimpleAttribute<CFReturnsNotRetainedAttr>(S, D, AL); in handleXReturnsXRetainedAttr()
5851 handleSimpleAttribute<NSReturnsNotRetainedAttr>(S, D, AL); in handleXReturnsXRetainedAttr()
5854 handleSimpleAttribute<CFReturnsRetainedAttr>(S, D, AL); in handleXReturnsXRetainedAttr()
5857 handleSimpleAttribute<NSReturnsRetainedAttr>(S, D, AL); in handleXReturnsXRetainedAttr()
5860 handleSimpleAttribute<OSReturnsRetainedAttr>(S, D, AL); in handleXReturnsXRetainedAttr()
5863 handleSimpleAttribute<OSReturnsNotRetainedAttr>(S, D, AL); in handleXReturnsXRetainedAttr()
5868 static void handleObjCReturnsInnerPointerAttr(Sema &S, Decl *D, in handleObjCReturnsInnerPointerAttr() argument
5875 if (isa<ObjCMethodDecl>(D)) in handleObjCReturnsInnerPointerAttr()
5876 resultType = cast<ObjCMethodDecl>(D)->getReturnType(); in handleObjCReturnsInnerPointerAttr()
5878 resultType = cast<ObjCPropertyDecl>(D)->getType(); in handleObjCReturnsInnerPointerAttr()
5882 S.Diag(D->getBeginLoc(), diag::warn_ns_attribute_wrong_return_type) in handleObjCReturnsInnerPointerAttr()
5884 << (isa<ObjCMethodDecl>(D) ? EP_ObjCMethod : EP_ObjCProperty) in handleObjCReturnsInnerPointerAttr()
5891 D->addAttr(::new (S.Context) ObjCReturnsInnerPointerAttr(S.Context, Attrs)); in handleObjCReturnsInnerPointerAttr()
5894 static void handleObjCRequiresSuperAttr(Sema &S, Decl *D, in handleObjCRequiresSuperAttr() argument
5896 const auto *Method = cast<ObjCMethodDecl>(D); in handleObjCRequiresSuperAttr()
5900 S.Diag(D->getBeginLoc(), diag::warn_objc_requires_super_protocol) << Attrs in handleObjCRequiresSuperAttr()
5906 S.Diag(D->getBeginLoc(), diag::warn_objc_requires_super_protocol) << Attrs in handleObjCRequiresSuperAttr()
5911 D->addAttr(::new (S.Context) ObjCRequiresSuperAttr(S.Context, Attrs)); in handleObjCRequiresSuperAttr()
5914 static void handleNSErrorDomain(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNSErrorDomain() argument
5936 D->addAttr(::new (S.Context) NSErrorDomainAttr(S.Context, AL, VD)); in handleNSErrorDomain()
5939 static void handleObjCBridgeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleObjCBridgeAttr() argument
5943 S.Diag(D->getBeginLoc(), diag::err_objc_attr_not_id) << AL << 0; in handleObjCBridgeAttr()
5948 if (const auto *TD = dyn_cast<TypedefNameDecl>(D)) { in handleObjCBridgeAttr()
5962 D->addAttr(::new (S.Context) ObjCBridgeAttr(S.Context, AL, Parm->Ident)); in handleObjCBridgeAttr()
5965 static void handleObjCBridgeMutableAttr(Sema &S, Decl *D, in handleObjCBridgeMutableAttr() argument
5970 S.Diag(D->getBeginLoc(), diag::err_objc_attr_not_id) << AL << 0; in handleObjCBridgeMutableAttr()
5974 D->addAttr(::new (S.Context) in handleObjCBridgeMutableAttr()
5978 static void handleObjCBridgeRelatedAttr(Sema &S, Decl *D, in handleObjCBridgeRelatedAttr() argument
5983 S.Diag(D->getBeginLoc(), diag::err_objc_attr_not_id) << AL << 0; in handleObjCBridgeRelatedAttr()
5990 D->addAttr(::new (S.Context) ObjCBridgeRelatedAttr( in handleObjCBridgeRelatedAttr()
5994 static void handleObjCDesignatedInitializer(Sema &S, Decl *D, in handleObjCDesignatedInitializer() argument
5996 DeclContext *Ctx = D->getDeclContext(); in handleObjCDesignatedInitializer()
6003 S.Diag(D->getLocation(), diag::err_designated_init_attr_non_init); in handleObjCDesignatedInitializer()
6017 D->addAttr(::new (S.Context) ObjCDesignatedInitializerAttr(S.Context, AL)); in handleObjCDesignatedInitializer()
6020 static void handleObjCRuntimeName(Sema &S, Decl *D, const ParsedAttr &AL) { in handleObjCRuntimeName() argument
6024 D->addAttr(::new (S.Context) in handleObjCRuntimeName()
6032 static void handleObjCBoxable(Sema &S, Decl *D, const ParsedAttr &AL) { in handleObjCBoxable() argument
6035 auto *RD = dyn_cast<RecordDecl>(D); in handleObjCBoxable()
6054 static void handleObjCOwnershipAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleObjCOwnershipAttr() argument
6055 if (hasDeclarator(D)) return; in handleObjCOwnershipAttr()
6057 S.Diag(D->getBeginLoc(), diag::err_attribute_wrong_decl_type) in handleObjCOwnershipAttr()
6061 static void handleObjCPreciseLifetimeAttr(Sema &S, Decl *D, in handleObjCPreciseLifetimeAttr() argument
6063 const auto *VD = cast<ValueDecl>(D); in handleObjCPreciseLifetimeAttr()
6097 D->addAttr(::new (S.Context) ObjCPreciseLifetimeAttr(S.Context, AL)); in handleObjCPreciseLifetimeAttr()
6100 static void handleSwiftAttrAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSwiftAttrAttr() argument
6107 D->addAttr(::new (S.Context) SwiftAttrAttr(S.Context, AL, Str)); in handleSwiftAttrAttr()
6110 static void handleSwiftBridge(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSwiftBridge() argument
6119 if (const auto *Other = D->getAttr<SwiftBridgeAttr>()) { in handleSwiftBridge()
6125 D->addAttr(::new (S.Context) SwiftBridgeAttr(S.Context, AL, BT)); in handleSwiftBridge()
6150 static void handleSwiftError(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSwiftError() argument
6151 auto hasErrorParameter = [](Sema &S, Decl *D, const ParsedAttr &AL) -> bool { in handleSwiftError() argument
6152 for (unsigned I = 0, E = getFunctionOrMethodNumParams(D); I != E; ++I) { in handleSwiftError()
6153 if (isErrorParameter(S, getFunctionOrMethodParamType(D, I))) in handleSwiftError()
6158 << AL << isa<ObjCMethodDecl>(D); in handleSwiftError()
6162 auto hasPointerResult = [](Sema &S, Decl *D, const ParsedAttr &AL) -> bool { in handleSwiftError() argument
6166 QualType RT = getFunctionOrMethodResultType(D); in handleSwiftError()
6171 << AL << AL.getArgAsIdent(0)->Ident->getName() << isa<ObjCMethodDecl>(D) in handleSwiftError()
6176 auto hasIntegerResult = [](Sema &S, Decl *D, const ParsedAttr &AL) -> bool { in handleSwiftError() argument
6177 QualType RT = getFunctionOrMethodResultType(D); in handleSwiftError()
6182 << AL << AL.getArgAsIdent(0)->Ident->getName() << isa<ObjCMethodDecl>(D) in handleSwiftError()
6187 if (D->isInvalidDecl()) in handleSwiftError()
6205 if (!hasErrorParameter(S, D, AL)) in handleSwiftError()
6210 if (!hasErrorParameter(S, D, AL) || !hasPointerResult(S, D, AL)) in handleSwiftError()
6216 if (!hasErrorParameter(S, D, AL) || !hasIntegerResult(S, D, AL)) in handleSwiftError()
6221 D->addAttr(::new (S.Context) SwiftErrorAttr(S.Context, AL, Convention)); in handleSwiftError()
6224 static void checkSwiftAsyncErrorBlock(Sema &S, Decl *D, in checkSwiftAsyncErrorBlock() argument
6231 << AsyncAttr << isa<ObjCMethodDecl>(D); in checkSwiftAsyncErrorBlock()
6237 D, AsyncAttr->getCompletionHandlerIndex().getASTIndex()); in checkSwiftAsyncErrorBlock()
6295 << ErrorAttr << isa<ObjCMethodDecl>(D); in checkSwiftAsyncErrorBlock()
6305 static void handleSwiftAsyncError(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSwiftAsyncError() argument
6337 D->addAttr(ErrorAttr); in handleSwiftAsyncError()
6339 if (auto *AsyncAttr = D->getAttr<SwiftAsyncAttr>()) in handleSwiftAsyncError()
6340 checkSwiftAsyncErrorBlock(S, D, ErrorAttr, AsyncAttr); in handleSwiftAsyncError()
6535 bool Sema::DiagnoseSwiftName(Decl *D, StringRef Name, SourceLocation Loc, in DiagnoseSwiftName() argument
6537 if (isa<ObjCMethodDecl>(D) || isa<FunctionDecl>(D)) { in DiagnoseSwiftName()
6541 if (const auto *Method = dyn_cast<ObjCMethodDecl>(D)) { in DiagnoseSwiftName()
6545 const auto *F = cast<FunctionDecl>(D); in DiagnoseSwiftName()
6561 << AL << isa<ObjCMethodDecl>(D); in DiagnoseSwiftName()
6599 } else if ((isa<EnumConstantDecl>(D) || isa<ObjCProtocolDecl>(D) || in DiagnoseSwiftName()
6600 isa<ObjCInterfaceDecl>(D) || isa<ObjCPropertyDecl>(D) || in DiagnoseSwiftName()
6601 isa<VarDecl>(D) || isa<TypedefNameDecl>(D) || isa<TagDecl>(D) || in DiagnoseSwiftName()
6602 isa<IndirectFieldDecl>(D) || isa<FieldDecl>(D)) && in DiagnoseSwiftName()
6628 static void handleSwiftName(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSwiftName() argument
6634 if (!S.DiagnoseSwiftName(D, Name, Loc, AL, /*IsAsync=*/false)) in handleSwiftName()
6637 D->addAttr(::new (S.Context) SwiftNameAttr(S.Context, AL, Name)); in handleSwiftName()
6640 static void handleSwiftAsyncName(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSwiftAsyncName() argument
6646 if (!S.DiagnoseSwiftName(D, Name, Loc, AL, /*IsAsync=*/true)) in handleSwiftAsyncName()
6649 D->addAttr(::new (S.Context) SwiftAsyncNameAttr(S.Context, AL, Name)); in handleSwiftAsyncName()
6652 static void handleSwiftNewType(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSwiftNewType() argument
6670 if (!isa<TypedefNameDecl>(D)) { in handleSwiftNewType()
6676 D->addAttr(::new (S.Context) SwiftNewTypeAttr(S.Context, AL, Kind)); in handleSwiftNewType()
6679 static void handleSwiftAsyncAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSwiftAsyncAttr() argument
6704 if (!checkFunctionOrMethodParameterIndex(S, D, AL, 2, HandlerIdx, Idx)) in handleSwiftAsyncAttr()
6708 getFunctionOrMethodParam(D, Idx.getASTIndex()); in handleSwiftAsyncAttr()
6728 D->addAttr(AsyncAttr); in handleSwiftAsyncAttr()
6730 if (auto *ErrorAttr = D->getAttr<SwiftAsyncErrorAttr>()) in handleSwiftAsyncAttr()
6731 checkSwiftAsyncErrorBlock(S, D, ErrorAttr, AsyncAttr); in handleSwiftAsyncAttr()
6738 UuidAttr *Sema::mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI, in mergeUuidAttr() argument
6740 if (const auto *UA = D->getAttr<UuidAttr>()) { in mergeUuidAttr()
6746 D->dropAttr<UuidAttr>(); in mergeUuidAttr()
6753 static void handleUuidAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleUuidAttr() argument
6808 UuidAttr *UA = S.mergeUuidAttr(D, AL, OrigStrRef, Guid); in handleUuidAttr()
6810 D->addAttr(UA); in handleUuidAttr()
6813 static void handleHLSLNumThreadsAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleHLSLNumThreadsAttr() argument
6868 HLSLNumThreadsAttr *NewAttr = S.mergeHLSLNumThreadsAttr(D, AL, X, Y, Z); in handleHLSLNumThreadsAttr()
6870 D->addAttr(NewAttr); in handleHLSLNumThreadsAttr()
6873 HLSLNumThreadsAttr *Sema::mergeHLSLNumThreadsAttr(Decl *D, in mergeHLSLNumThreadsAttr() argument
6876 if (HLSLNumThreadsAttr *NT = D->getAttr<HLSLNumThreadsAttr>()) { in mergeHLSLNumThreadsAttr()
6886 static void handleHLSLSVGroupIndexAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleHLSLSVGroupIndexAttr() argument
6898 D->addAttr(::new (S.Context) HLSLSV_GroupIndexAttr(S.Context, AL)); in handleHLSLSVGroupIndexAttr()
6901 static void handleHLSLShaderAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleHLSLShaderAttr() argument
6916 HLSLShaderAttr *NewAttr = S.mergeHLSLShaderAttr(D, AL, ShaderType); in handleHLSLShaderAttr()
6918 D->addAttr(NewAttr); in handleHLSLShaderAttr()
6922 Sema::mergeHLSLShaderAttr(Decl *D, const AttributeCommonInfo &AL, in mergeHLSLShaderAttr() argument
6924 if (HLSLShaderAttr *NT = D->getAttr<HLSLShaderAttr>()) { in mergeHLSLShaderAttr()
6934 static void handleMSInheritanceAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleMSInheritanceAttr() argument
6941 D, AL, /*BestCase=*/true, (MSInheritanceModel)AL.getSemanticSpelling()); in handleMSInheritanceAttr()
6943 D->addAttr(IA); in handleMSInheritanceAttr()
6944 S.Consumer.AssignInheritanceModel(cast<CXXRecordDecl>(D)); in handleMSInheritanceAttr()
6948 static void handleDeclspecThreadAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleDeclspecThreadAttr() argument
6949 const auto *VD = cast<VarDecl>(D); in handleDeclspecThreadAttr()
6962 D->addAttr(::new (S.Context) ThreadAttr(S.Context, AL)); in handleDeclspecThreadAttr()
6965 static void handleAbiTagAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAbiTagAttr() argument
6974 if (const auto *NS = dyn_cast<NamespaceDecl>(D)) { in handleAbiTagAttr()
6992 D->addAttr(::new (S.Context) in handleAbiTagAttr()
6996 static void handleARMInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleARMInterruptAttr() argument
7018 D->addAttr(::new (S.Context) ARMInterruptAttr(S.Context, AL, Kind)); in handleARMInterruptAttr()
7021 static void handleMSP430InterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleMSP430InterruptAttr() argument
7024 if (!isFunctionOrMethod(D)) { in handleMSP430InterruptAttr()
7025 S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type) in handleMSP430InterruptAttr()
7030 if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) { in handleMSP430InterruptAttr()
7031 S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) in handleMSP430InterruptAttr()
7036 if (!getFunctionOrMethodResultType(D)->isVoidType()) { in handleMSP430InterruptAttr()
7037 S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) in handleMSP430InterruptAttr()
7069 D->addAttr(::new (S.Context) MSP430InterruptAttr(S.Context, AL, Num)); in handleMSP430InterruptAttr()
7070 D->addAttr(UsedAttr::CreateImplicit(S.Context)); in handleMSP430InterruptAttr()
7073 static void handleMipsInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleMipsInterruptAttr() argument
7097 if (!isFunctionOrMethod(D)) { in handleMipsInterruptAttr()
7098 S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type) in handleMipsInterruptAttr()
7103 if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) { in handleMipsInterruptAttr()
7104 S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) in handleMipsInterruptAttr()
7109 if (!getFunctionOrMethodResultType(D)->isVoidType()) { in handleMipsInterruptAttr()
7110 S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) in handleMipsInterruptAttr()
7117 if (checkAttrMutualExclusion<Mips16Attr>(S, D, AL)) in handleMipsInterruptAttr()
7127 D->addAttr(::new (S.Context) MipsInterruptAttr(S.Context, AL, Kind)); in handleMipsInterruptAttr()
7130 static void handleM68kInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleM68kInterruptAttr() argument
7159 D->addAttr(::new (S.Context) M68kInterruptAttr(S.Context, AL, Num)); in handleM68kInterruptAttr()
7160 D->addAttr(UsedAttr::CreateImplicit(S.Context)); in handleM68kInterruptAttr()
7163 static void handleAnyX86InterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAnyX86InterruptAttr() argument
7170 if (!isFunctionOrMethod(D) || !hasFunctionProto(D) || isInstanceMethod(D) || in handleAnyX86InterruptAttr()
7172 cast<NamedDecl>(D)->getDeclName().getCXXOverloadedOperator())) { in handleAnyX86InterruptAttr()
7178 if (!getFunctionOrMethodResultType(D)->isVoidType()) { in handleAnyX86InterruptAttr()
7179 S.Diag(getFunctionOrMethodResultSourceRange(D).getBegin(), in handleAnyX86InterruptAttr()
7188 unsigned NumParams = getFunctionOrMethodNumParams(D); in handleAnyX86InterruptAttr()
7190 S.Diag(D->getBeginLoc(), diag::err_anyx86_interrupt_attribute) in handleAnyX86InterruptAttr()
7198 if (!getFunctionOrMethodParamType(D, 0)->isPointerType()) { in handleAnyX86InterruptAttr()
7199 S.Diag(getFunctionOrMethodParamRange(D, 0).getBegin(), in handleAnyX86InterruptAttr()
7213 (!getFunctionOrMethodParamType(D, 1)->isUnsignedIntegerType() || in handleAnyX86InterruptAttr()
7214 S.Context.getTypeSize(getFunctionOrMethodParamType(D, 1)) != TypeSize)) { in handleAnyX86InterruptAttr()
7215 S.Diag(getFunctionOrMethodParamRange(D, 1).getBegin(), in handleAnyX86InterruptAttr()
7223 D->addAttr(::new (S.Context) AnyX86InterruptAttr(S.Context, AL)); in handleAnyX86InterruptAttr()
7224 D->addAttr(UsedAttr::CreateImplicit(S.Context)); in handleAnyX86InterruptAttr()
7227 static void handleAVRInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAVRInterruptAttr() argument
7228 if (!isFunctionOrMethod(D)) { in handleAVRInterruptAttr()
7229 S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type) in handleAVRInterruptAttr()
7237 handleSimpleAttribute<AVRInterruptAttr>(S, D, AL); in handleAVRInterruptAttr()
7240 static void handleAVRSignalAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAVRSignalAttr() argument
7241 if (!isFunctionOrMethod(D)) { in handleAVRSignalAttr()
7242 S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type) in handleAVRSignalAttr()
7250 handleSimpleAttribute<AVRSignalAttr>(S, D, AL); in handleAVRSignalAttr()
7255 for (auto D : RD->decls()) { in handleBPFPreserveAIRecord() local
7256 if (D->hasAttr<BPFPreserveAccessIndexAttr>()) in handleBPFPreserveAIRecord()
7259 D->addAttr(BPFPreserveAccessIndexAttr::CreateImplicit(S.Context)); in handleBPFPreserveAIRecord()
7260 if (auto *Rec = dyn_cast<RecordDecl>(D)) in handleBPFPreserveAIRecord()
7265 static void handleBPFPreserveAccessIndexAttr(Sema &S, Decl *D, in handleBPFPreserveAccessIndexAttr() argument
7267 auto *Rec = cast<RecordDecl>(D); in handleBPFPreserveAccessIndexAttr()
7272 static bool hasBTFDeclTagAttr(Decl *D, StringRef Tag) { in hasBTFDeclTagAttr() argument
7273 for (const auto *I : D->specific_attrs<BTFDeclTagAttr>()) { in hasBTFDeclTagAttr()
7280 static void handleBTFDeclTagAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleBTFDeclTagAttr() argument
7284 if (hasBTFDeclTagAttr(D, Str)) in handleBTFDeclTagAttr()
7287 D->addAttr(::new (S.Context) BTFDeclTagAttr(S.Context, AL, Str)); in handleBTFDeclTagAttr()
7290 BTFDeclTagAttr *Sema::mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL) { in mergeBTFDeclTagAttr() argument
7291 if (hasBTFDeclTagAttr(D, AL.getBTFDeclTag())) in mergeBTFDeclTagAttr()
7296 static void handleWebAssemblyExportNameAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleWebAssemblyExportNameAttr() argument
7297 if (!isFunctionOrMethod(D)) { in handleWebAssemblyExportNameAttr()
7298 S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type) in handleWebAssemblyExportNameAttr()
7303 auto *FD = cast<FunctionDecl>(D); in handleWebAssemblyExportNameAttr()
7305 S.Diag(D->getLocation(), diag::err_alias_is_definition) << FD << 0; in handleWebAssemblyExportNameAttr()
7314 D->addAttr(::new (S.Context) WebAssemblyExportNameAttr(S.Context, AL, Str)); in handleWebAssemblyExportNameAttr()
7315 D->addAttr(UsedAttr::CreateImplicit(S.Context)); in handleWebAssemblyExportNameAttr()
7319 Sema::mergeImportModuleAttr(Decl *D, const WebAssemblyImportModuleAttr &AL) { in mergeImportModuleAttr() argument
7320 auto *FD = cast<FunctionDecl>(D); in mergeImportModuleAttr()
7339 Sema::mergeImportNameAttr(Decl *D, const WebAssemblyImportNameAttr &AL) { in mergeImportNameAttr() argument
7340 auto *FD = cast<FunctionDecl>(D); in mergeImportNameAttr()
7359 handleWebAssemblyImportModuleAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleWebAssemblyImportModuleAttr() argument
7360 auto *FD = cast<FunctionDecl>(D); in handleWebAssemblyImportModuleAttr()
7376 handleWebAssemblyImportNameAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleWebAssemblyImportNameAttr() argument
7377 auto *FD = cast<FunctionDecl>(D); in handleWebAssemblyImportNameAttr()
7391 static void handleRISCVInterruptAttr(Sema &S, Decl *D, in handleRISCVInterruptAttr() argument
7394 if (const auto *A = D->getAttr<RISCVInterruptAttr>()) { in handleRISCVInterruptAttr()
7421 if (D->getFunctionType() == nullptr) { in handleRISCVInterruptAttr()
7422 S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type) in handleRISCVInterruptAttr()
7427 if (hasFunctionProto(D) && getFunctionOrMethodNumParams(D) != 0) { in handleRISCVInterruptAttr()
7428 S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) in handleRISCVInterruptAttr()
7433 if (!getFunctionOrMethodResultType(D)->isVoidType()) { in handleRISCVInterruptAttr()
7434 S.Diag(D->getLocation(), diag::warn_interrupt_attribute_invalid) in handleRISCVInterruptAttr()
7446 D->addAttr(::new (S.Context) RISCVInterruptAttr(S.Context, AL, Kind)); in handleRISCVInterruptAttr()
7449 static void handleInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleInterruptAttr() argument
7453 handleMSP430InterruptAttr(S, D, AL); in handleInterruptAttr()
7457 handleMipsInterruptAttr(S, D, AL); in handleInterruptAttr()
7460 handleM68kInterruptAttr(S, D, AL); in handleInterruptAttr()
7464 handleAnyX86InterruptAttr(S, D, AL); in handleInterruptAttr()
7467 handleAVRInterruptAttr(S, D, AL); in handleInterruptAttr()
7471 handleRISCVInterruptAttr(S, D, AL); in handleInterruptAttr()
7474 handleARMInterruptAttr(S, D, AL); in handleInterruptAttr()
7509 void Sema::addAMDGPUFlatWorkGroupSizeAttr(Decl *D, in addAMDGPUFlatWorkGroupSizeAttr() argument
7517 D->addAttr(::new (Context) in addAMDGPUFlatWorkGroupSizeAttr()
7521 static void handleAMDGPUFlatWorkGroupSizeAttr(Sema &S, Decl *D, in handleAMDGPUFlatWorkGroupSizeAttr() argument
7526 S.addAMDGPUFlatWorkGroupSizeAttr(D, AL, MinExpr, MaxExpr); in handleAMDGPUFlatWorkGroupSizeAttr()
7563 void Sema::addAMDGPUWavesPerEUAttr(Decl *D, const AttributeCommonInfo &CI, in addAMDGPUWavesPerEUAttr() argument
7570 D->addAttr(::new (Context) in addAMDGPUWavesPerEUAttr()
7574 static void handleAMDGPUWavesPerEUAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAMDGPUWavesPerEUAttr() argument
7581 S.addAMDGPUWavesPerEUAttr(D, AL, MinExpr, MaxExpr); in handleAMDGPUWavesPerEUAttr()
7584 static void handleAMDGPUNumSGPRAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAMDGPUNumSGPRAttr() argument
7590 D->addAttr(::new (S.Context) AMDGPUNumSGPRAttr(S.Context, AL, NumSGPR)); in handleAMDGPUNumSGPRAttr()
7593 static void handleAMDGPUNumVGPRAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAMDGPUNumVGPRAttr() argument
7599 D->addAttr(::new (S.Context) AMDGPUNumVGPRAttr(S.Context, AL, NumVGPR)); in handleAMDGPUNumVGPRAttr()
7602 static void handleX86ForceAlignArgPointerAttr(Sema &S, Decl *D, in handleX86ForceAlignArgPointerAttr() argument
7607 const auto *VD = dyn_cast<ValueDecl>(D); in handleX86ForceAlignArgPointerAttr()
7611 const auto *TD = dyn_cast<TypedefNameDecl>(D); in handleX86ForceAlignArgPointerAttr()
7616 if (!isa<FunctionDecl>(D)) { in handleX86ForceAlignArgPointerAttr()
7622 D->addAttr(::new (S.Context) X86ForceAlignArgPointerAttr(S.Context, AL)); in handleX86ForceAlignArgPointerAttr()
7625 static void handleLayoutVersion(Sema &S, Decl *D, const ParsedAttr &AL) { in handleLayoutVersion() argument
7643 D->addAttr(::new (S.Context) LayoutVersionAttr(S.Context, AL, Version)); in handleLayoutVersion()
7646 DLLImportAttr *Sema::mergeDLLImportAttr(Decl *D, in mergeDLLImportAttr() argument
7648 if (D->hasAttr<DLLExportAttr>()) { in mergeDLLImportAttr()
7653 if (D->hasAttr<DLLImportAttr>()) in mergeDLLImportAttr()
7659 DLLExportAttr *Sema::mergeDLLExportAttr(Decl *D, in mergeDLLExportAttr() argument
7661 if (DLLImportAttr *Import = D->getAttr<DLLImportAttr>()) { in mergeDLLExportAttr()
7663 D->dropAttr<DLLImportAttr>(); in mergeDLLExportAttr()
7666 if (D->hasAttr<DLLExportAttr>()) in mergeDLLExportAttr()
7672 static void handleDLLAttr(Sema &S, Decl *D, const ParsedAttr &A) { in handleDLLAttr() argument
7673 if (isa<ClassTemplatePartialSpecializationDecl>(D) && in handleDLLAttr()
7679 if (const auto *FD = dyn_cast<FunctionDecl>(D)) { in handleDLLAttr()
7689 if (const auto *MD = dyn_cast<CXXMethodDecl>(D)) { in handleDLLAttr()
7698 ? (Attr *)S.mergeDLLExportAttr(D, A) in handleDLLAttr()
7699 : (Attr *)S.mergeDLLImportAttr(D, A); in handleDLLAttr()
7701 D->addAttr(NewAttr); in handleDLLAttr()
7705 Sema::mergeMSInheritanceAttr(Decl *D, const AttributeCommonInfo &CI, in mergeMSInheritanceAttr() argument
7708 if (MSInheritanceAttr *IA = D->getAttr<MSInheritanceAttr>()) { in mergeMSInheritanceAttr()
7714 D->dropAttr<MSInheritanceAttr>(); in mergeMSInheritanceAttr()
7717 auto *RD = cast<CXXRecordDecl>(D); in mergeMSInheritanceAttr()
7739 static void handleCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCapabilityAttr() argument
7754 D->addAttr(::new (S.Context) CapabilityAttr(S.Context, AL, N)); in handleCapabilityAttr()
7757 static void handleAssertCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAssertCapabilityAttr() argument
7759 if (!checkLockFunAttrCommon(S, D, AL, Args)) in handleAssertCapabilityAttr()
7762 D->addAttr(::new (S.Context) in handleAssertCapabilityAttr()
7766 static void handleAcquireCapabilityAttr(Sema &S, Decl *D, in handleAcquireCapabilityAttr() argument
7769 if (!checkLockFunAttrCommon(S, D, AL, Args)) in handleAcquireCapabilityAttr()
7772 D->addAttr(::new (S.Context) AcquireCapabilityAttr(S.Context, AL, Args.data(), in handleAcquireCapabilityAttr()
7776 static void handleTryAcquireCapabilityAttr(Sema &S, Decl *D, in handleTryAcquireCapabilityAttr() argument
7779 if (!checkTryLockFunAttrCommon(S, D, AL, Args)) in handleTryAcquireCapabilityAttr()
7782 D->addAttr(::new (S.Context) TryAcquireCapabilityAttr( in handleTryAcquireCapabilityAttr()
7786 static void handleReleaseCapabilityAttr(Sema &S, Decl *D, in handleReleaseCapabilityAttr() argument
7790 checkAttrArgsAreCapabilityObjs(S, D, AL, Args, 0, true); in handleReleaseCapabilityAttr()
7792 D->addAttr(::new (S.Context) ReleaseCapabilityAttr(S.Context, AL, Args.data(), in handleReleaseCapabilityAttr()
7796 static void handleRequiresCapabilityAttr(Sema &S, Decl *D, in handleRequiresCapabilityAttr() argument
7803 checkAttrArgsAreCapabilityObjs(S, D, AL, Args); in handleRequiresCapabilityAttr()
7810 D->addAttr(RCA); in handleRequiresCapabilityAttr()
7813 static void handleDeprecatedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleDeprecatedAttr() argument
7814 if (const auto *NSD = dyn_cast<NamespaceDecl>(D)) { in handleDeprecatedAttr()
7823 UnresolvedUsingValueDecl>(D)) { in handleDeprecatedAttr()
7845 D->addAttr(::new (S.Context) DeprecatedAttr(S.Context, AL, Str, Replacement)); in handleDeprecatedAttr()
7848 static bool isGlobalVar(const Decl *D) { in isGlobalVar() argument
7849 if (const auto *S = dyn_cast<VarDecl>(D)) in isGlobalVar()
7859 static void handleNoSanitizeAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleNoSanitizeAttr() argument
7876 else if (isGlobalVar(D) && !isSanitizerAttributeAllowedOnGlobals(SanitizerName)) in handleNoSanitizeAttr()
7877 S.Diag(D->getLocation(), diag::err_attribute_wrong_decl_type) in handleNoSanitizeAttr()
7882 D->addAttr(::new (S.Context) NoSanitizeAttr(S.Context, AL, Sanitizers.data(), in handleNoSanitizeAttr()
7886 static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D, in handleNoSanitizeSpecificAttr() argument
7895 if (isGlobalVar(D) && SanitizerName != "address") in handleNoSanitizeSpecificAttr()
7896 S.Diag(D->getLocation(), diag::err_attribute_wrong_decl_type) in handleNoSanitizeSpecificAttr()
7913 D->addAttr(::new (S.Context) in handleNoSanitizeSpecificAttr()
7917 static void handleInternalLinkageAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleInternalLinkageAttr() argument
7918 if (InternalLinkageAttr *Internal = S.mergeInternalLinkageAttr(D, AL)) in handleInternalLinkageAttr()
7919 D->addAttr(Internal); in handleInternalLinkageAttr()
7922 static void handleOpenCLNoSVMAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleOpenCLNoSVMAttr() argument
7931 static void handleOpenCLAccessAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleOpenCLAccessAttr() argument
7932 if (D->isInvalidDecl()) in handleOpenCLAccessAttr()
7936 if (D->hasAttr<OpenCLAccessAttr>()) { in handleOpenCLAccessAttr()
7937 if (D->getAttr<OpenCLAccessAttr>()->getSemanticSpelling() == in handleOpenCLAccessAttr()
7943 << D->getSourceRange(); in handleOpenCLAccessAttr()
7944 D->setInvalidDecl(true); in handleOpenCLAccessAttr()
7958 if (const auto *PDecl = dyn_cast<ParmVarDecl>(D)) { in handleOpenCLAccessAttr()
7969 D->setInvalidDecl(true); in handleOpenCLAccessAttr()
7975 D->addAttr(::new (S.Context) OpenCLAccessAttr(S.Context, AL)); in handleOpenCLAccessAttr()
7978 static void handleZeroCallUsedRegsAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleZeroCallUsedRegsAttr() argument
7992 D->dropAttr<ZeroCallUsedRegsAttr>(); in handleZeroCallUsedRegsAttr()
7993 D->addAttr(ZeroCallUsedRegsAttr::Create(S.Context, Kind, AL)); in handleZeroCallUsedRegsAttr()
7996 static void handleFunctionReturnThunksAttr(Sema &S, Decl *D, in handleFunctionReturnThunksAttr() argument
8012 D->dropAttr<FunctionReturnThunksAttr>(); in handleFunctionReturnThunksAttr()
8013 D->addAttr(FunctionReturnThunksAttr::Create(S.Context, Kind, AL)); in handleFunctionReturnThunksAttr()
8016 static void handleSYCLKernelAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleSYCLKernelAttr() argument
8018 const auto *FD = cast<FunctionDecl>(D); in handleSYCLKernelAttr()
8040 if (getFunctionOrMethodNumParams(D) != 1) { in handleSYCLKernelAttr()
8046 QualType RetTy = getFunctionOrMethodResultType(D); in handleSYCLKernelAttr()
8052 handleSimpleAttribute<SYCLKernelAttr>(S, D, AL); in handleSYCLKernelAttr()
8055 static void handleDestroyAttr(Sema &S, Decl *D, const ParsedAttr &A) { in handleDestroyAttr() argument
8056 if (!cast<VarDecl>(D)->hasGlobalStorage()) { in handleDestroyAttr()
8057 S.Diag(D->getLocation(), diag::err_destroy_attr_on_non_static_var) in handleDestroyAttr()
8063 handleSimpleAttribute<AlwaysDestroyAttr>(S, D, A); in handleDestroyAttr()
8065 handleSimpleAttribute<NoDestroyAttr>(S, D, A); in handleDestroyAttr()
8068 static void handleUninitializedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleUninitializedAttr() argument
8069 assert(cast<VarDecl>(D)->getStorageDuration() == SD_Automatic && in handleUninitializedAttr()
8071 D->addAttr(::new (S.Context) UninitializedAttr(S.Context, AL)); in handleUninitializedAttr()
8111 static void handleObjCExternallyRetainedAttr(Sema &S, Decl *D, in handleObjCExternallyRetainedAttr() argument
8113 if (auto *VD = dyn_cast<VarDecl>(D)) { in handleObjCExternallyRetainedAttr()
8116 S.Diag(D->getBeginLoc(), diag::warn_ignored_objc_externally_retained) in handleObjCExternallyRetainedAttr()
8124 handleSimpleAttribute<ObjCExternallyRetainedAttr>(S, D, AL); in handleObjCExternallyRetainedAttr()
8131 hasFunctionProto(D) ? getFunctionOrMethodNumParams(D) : 0; in handleObjCExternallyRetainedAttr()
8133 auto *PVD = const_cast<ParmVarDecl *>(getFunctionOrMethodParam(D, I)); in handleObjCExternallyRetainedAttr()
8146 handleSimpleAttribute<ObjCExternallyRetainedAttr>(S, D, AL); in handleObjCExternallyRetainedAttr()
8149 static void handleMIGServerRoutineAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleMIGServerRoutineAttr() argument
8154 if (!isa<BlockDecl>(D)) { in handleMIGServerRoutineAttr()
8155 QualType T = getFunctionOrMethodResultType(D); in handleMIGServerRoutineAttr()
8162 S.Diag(D->getBeginLoc(), in handleMIGServerRoutineAttr()
8168 handleSimpleAttribute<MIGServerRoutineAttr>(S, D, AL); in handleMIGServerRoutineAttr()
8171 static void handleMSAllocatorAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleMSAllocatorAttr() argument
8173 if (auto *FD = dyn_cast<FunctionDecl>(D)) { in handleMSAllocatorAttr()
8182 handleSimpleAttribute<MSAllocatorAttr>(S, D, AL); in handleMSAllocatorAttr()
8185 static void handleAcquireHandleAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleAcquireHandleAttr() argument
8189 if (const auto *PVD = dyn_cast<ParmVarDecl>(D)) { in handleAcquireHandleAttr()
8199 D->addAttr(AcquireHandleAttr::Create(S.Context, Argument, AL)); in handleAcquireHandleAttr()
8203 static void handleHandleAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleHandleAttr() argument
8207 D->addAttr(Attr::Create(S.Context, Argument, AL)); in handleHandleAttr()
8210 static void handleCFGuardAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleCFGuardAttr() argument
8226 D->addAttr(::new (S.Context) CFGuardAttr(S.Context, AL, Arg)); in handleCFGuardAttr()
8231 static const AttrTy *findEnforceTCBAttrByName(Decl *D, StringRef Name) { in findEnforceTCBAttrByName() argument
8232 auto Attrs = D->specific_attrs<AttrTy>(); in findEnforceTCBAttrByName()
8241 static void handleEnforceTCBAttr(Sema &S, Decl *D, const ParsedAttr &AL) { in handleEnforceTCBAttr() argument
8248 findEnforceTCBAttrByName<ConflictingAttrTy>(D, Argument)) { in handleEnforceTCBAttr()
8258 D->dropAttr<EnforceTCBAttr>(); in handleEnforceTCBAttr()
8262 D->addAttr(AttrTy::Create(S.Context, Argument, AL)); in handleEnforceTCBAttr()
8266 static AttrTy *mergeEnforceTCBAttrImpl(Sema &S, Decl *D, const AttrTy &AL) { in mergeEnforceTCBAttrImpl() argument
8270 findEnforceTCBAttrByName<ConflictingAttrTy>(D, TCBName)) { in mergeEnforceTCBAttrImpl()
8279 D->dropAttr<EnforceTCBAttr>(); in mergeEnforceTCBAttrImpl()
8287 EnforceTCBAttr *Sema::mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL) { in mergeEnforceTCBAttr() argument
8289 *this, D, AL); in mergeEnforceTCBAttr()
8293 Decl *D, const EnforceTCBLeafAttr &AL) { in mergeEnforceTCBLeafAttr() argument
8295 *this, D, AL); in mergeEnforceTCBLeafAttr()
8337 ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL, in ProcessDeclAttribute() argument
8370 if (S.checkCommonAttributeFeatures(D, AL, MustDelayArgs)) in ProcessDeclAttribute()
8374 AL.handleAttrWithDelayedArgs(S, D); in ProcessDeclAttribute()
8380 if (AL.getInfo().handleDeclAttribute(S, D, AL) != ParsedAttrInfo::NotHandled) in ProcessDeclAttribute()
8404 isa<DeclaratorDecl, TypeAliasDecl>(D)) { in ProcessDeclAttribute()
8410 << AL << D->getLocation(); in ProcessDeclAttribute()
8453 << AL << D->getLocation(); in ProcessDeclAttribute()
8456 handleInterruptAttr(S, D, AL); in ProcessDeclAttribute()
8459 handleX86ForceAlignArgPointerAttr(S, D, AL); in ProcessDeclAttribute()
8463 handleDLLAttr(S, D, AL); in ProcessDeclAttribute()
8466 handleAMDGPUFlatWorkGroupSizeAttr(S, D, AL); in ProcessDeclAttribute()
8469 handleAMDGPUWavesPerEUAttr(S, D, AL); in ProcessDeclAttribute()
8472 handleAMDGPUNumSGPRAttr(S, D, AL); in ProcessDeclAttribute()
8475 handleAMDGPUNumVGPRAttr(S, D, AL); in ProcessDeclAttribute()
8478 handleAVRSignalAttr(S, D, AL); in ProcessDeclAttribute()
8481 handleBPFPreserveAccessIndexAttr(S, D, AL); in ProcessDeclAttribute()
8484 handleBTFDeclTagAttr(S, D, AL); in ProcessDeclAttribute()
8487 handleWebAssemblyExportNameAttr(S, D, AL); in ProcessDeclAttribute()
8490 handleWebAssemblyImportModuleAttr(S, D, AL); in ProcessDeclAttribute()
8493 handleWebAssemblyImportNameAttr(S, D, AL); in ProcessDeclAttribute()
8496 handleIBOutlet(S, D, AL); in ProcessDeclAttribute()
8499 handleIBOutletCollection(S, D, AL); in ProcessDeclAttribute()
8502 handleIFuncAttr(S, D, AL); in ProcessDeclAttribute()
8505 handleAliasAttr(S, D, AL); in ProcessDeclAttribute()
8508 handleAlignedAttr(S, D, AL); in ProcessDeclAttribute()
8511 handleAlignValueAttr(S, D, AL); in ProcessDeclAttribute()
8514 handleAllocSizeAttr(S, D, AL); in ProcessDeclAttribute()
8517 handleAlwaysInlineAttr(S, D, AL); in ProcessDeclAttribute()
8520 handleAnalyzerNoReturnAttr(S, D, AL); in ProcessDeclAttribute()
8523 handleTLSModelAttr(S, D, AL); in ProcessDeclAttribute()
8526 handleAnnotateAttr(S, D, AL); in ProcessDeclAttribute()
8529 handleAvailabilityAttr(S, D, AL); in ProcessDeclAttribute()
8532 handleDependencyAttr(S, scope, D, AL); in ProcessDeclAttribute()
8536 handleCPUSpecificAttr(S, D, AL); in ProcessDeclAttribute()
8539 handleCommonAttr(S, D, AL); in ProcessDeclAttribute()
8542 handleConstantAttr(S, D, AL); in ProcessDeclAttribute()
8545 handlePassObjectSizeAttr(S, D, AL); in ProcessDeclAttribute()
8548 handleConstructorAttr(S, D, AL); in ProcessDeclAttribute()
8551 handleDeprecatedAttr(S, D, AL); in ProcessDeclAttribute()
8554 handleDestructorAttr(S, D, AL); in ProcessDeclAttribute()
8557 handleEnableIfAttr(S, D, AL); in ProcessDeclAttribute()
8560 handleErrorAttr(S, D, AL); in ProcessDeclAttribute()
8563 handleDiagnoseIfAttr(S, D, AL); in ProcessDeclAttribute()
8566 handleDiagnoseAsBuiltinAttr(S, D, AL); in ProcessDeclAttribute()
8569 handleNoBuiltinAttr(S, D, AL); in ProcessDeclAttribute()
8572 handleExtVectorTypeAttr(S, D, AL); in ProcessDeclAttribute()
8575 handleExternalSourceSymbolAttr(S, D, AL); in ProcessDeclAttribute()
8578 handleMinSizeAttr(S, D, AL); in ProcessDeclAttribute()
8581 handleOptimizeNoneAttr(S, D, AL); in ProcessDeclAttribute()
8584 handleEnumExtensibilityAttr(S, D, AL); in ProcessDeclAttribute()
8587 handleSYCLKernelAttr(S, D, AL); in ProcessDeclAttribute()
8590 handleSimpleAttribute<SYCLSpecialClassAttr>(S, D, AL); in ProcessDeclAttribute()
8593 handleFormatAttr(S, D, AL); in ProcessDeclAttribute()
8596 handleFormatArgAttr(S, D, AL); in ProcessDeclAttribute()
8599 handleCallbackAttr(S, D, AL); in ProcessDeclAttribute()
8602 handleCalledOnceAttr(S, D, AL); in ProcessDeclAttribute()
8605 handleGlobalAttr(S, D, AL); in ProcessDeclAttribute()
8608 handleDeviceAttr(S, D, AL); in ProcessDeclAttribute()
8611 handleManagedAttr(S, D, AL); in ProcessDeclAttribute()
8614 handleGNUInlineAttr(S, D, AL); in ProcessDeclAttribute()
8617 handleLaunchBoundsAttr(S, D, AL); in ProcessDeclAttribute()
8620 handleRestrictAttr(S, D, AL); in ProcessDeclAttribute()
8623 handleModeAttr(S, D, AL); in ProcessDeclAttribute()
8626 if (auto *PVD = dyn_cast<ParmVarDecl>(D)) in ProcessDeclAttribute()
8629 handleNonNullAttr(S, D, AL); in ProcessDeclAttribute()
8632 handleReturnsNonNullAttr(S, D, AL); in ProcessDeclAttribute()
8635 handleNoEscapeAttr(S, D, AL); in ProcessDeclAttribute()
8638 handleAssumeAlignedAttr(S, D, AL); in ProcessDeclAttribute()
8641 handleAllocAlignAttr(S, D, AL); in ProcessDeclAttribute()
8644 handleOwnershipAttr(S, D, AL); in ProcessDeclAttribute()
8647 handleNakedAttr(S, D, AL); in ProcessDeclAttribute()
8650 handleNoReturnAttr(S, D, AL); in ProcessDeclAttribute()
8653 handleStandardNoReturnAttr(S, D, AL); in ProcessDeclAttribute()
8656 handleNoCfCheckAttr(S, D, AL); in ProcessDeclAttribute()
8660 handleSimpleAttribute<NoThrowAttr>(S, D, AL); in ProcessDeclAttribute()
8663 handleSharedAttr(S, D, AL); in ProcessDeclAttribute()
8666 handleVecReturnAttr(S, D, AL); in ProcessDeclAttribute()
8669 handleObjCOwnershipAttr(S, D, AL); in ProcessDeclAttribute()
8672 handleObjCPreciseLifetimeAttr(S, D, AL); in ProcessDeclAttribute()
8675 handleObjCReturnsInnerPointerAttr(S, D, AL); in ProcessDeclAttribute()
8678 handleObjCRequiresSuperAttr(S, D, AL); in ProcessDeclAttribute()
8681 handleObjCBridgeAttr(S, D, AL); in ProcessDeclAttribute()
8684 handleObjCBridgeMutableAttr(S, D, AL); in ProcessDeclAttribute()
8687 handleObjCBridgeRelatedAttr(S, D, AL); in ProcessDeclAttribute()
8690 handleObjCDesignatedInitializer(S, D, AL); in ProcessDeclAttribute()
8693 handleObjCRuntimeName(S, D, AL); in ProcessDeclAttribute()
8696 handleObjCBoxable(S, D, AL); in ProcessDeclAttribute()
8699 handleNSErrorDomain(S, D, AL); in ProcessDeclAttribute()
8704 S.AddXConsumedAttr(D, AL, parsedAttrToRetainOwnershipKind(AL), in ProcessDeclAttribute()
8709 S, D, AL, isValidOSObjectOutParameter(D), in ProcessDeclAttribute()
8715 S, D, AL, isValidOSObjectOutParameter(D), in ProcessDeclAttribute()
8726 handleXReturnsXRetainedAttr(S, D, AL); in ProcessDeclAttribute()
8729 handleWorkGroupSize<WorkGroupSizeHintAttr>(S, D, AL); in ProcessDeclAttribute()
8732 handleWorkGroupSize<ReqdWorkGroupSizeAttr>(S, D, AL); in ProcessDeclAttribute()
8735 handleSubGroupSize(S, D, AL); in ProcessDeclAttribute()
8738 handleVecTypeHint(S, D, AL); in ProcessDeclAttribute()
8741 handleInitPriorityAttr(S, D, AL); in ProcessDeclAttribute()
8744 handlePackedAttr(S, D, AL); in ProcessDeclAttribute()
8747 handlePreferredName(S, D, AL); in ProcessDeclAttribute()
8750 handleSectionAttr(S, D, AL); in ProcessDeclAttribute()
8753 handleRandomizeLayoutAttr(S, D, AL); in ProcessDeclAttribute()
8756 handleNoRandomizeLayoutAttr(S, D, AL); in ProcessDeclAttribute()
8759 handleCodeSegAttr(S, D, AL); in ProcessDeclAttribute()
8762 handleTargetAttr(S, D, AL); in ProcessDeclAttribute()
8765 handleTargetClonesAttr(S, D, AL); in ProcessDeclAttribute()
8768 handleMinVectorWidthAttr(S, D, AL); in ProcessDeclAttribute()
8771 handleAttrWithMessage<UnavailableAttr>(S, D, AL); in ProcessDeclAttribute()
8774 handleAssumumptionAttr(S, D, AL); in ProcessDeclAttribute()
8777 handleObjCDirectAttr(S, D, AL); in ProcessDeclAttribute()
8780 handleObjCDirectMembersAttr(S, D, AL); in ProcessDeclAttribute()
8781 handleSimpleAttribute<ObjCDirectMembersAttr>(S, D, AL); in ProcessDeclAttribute()
8784 handleObjCSuppresProtocolAttr(S, D, AL); in ProcessDeclAttribute()
8787 handleUnusedAttr(S, D, AL); in ProcessDeclAttribute()
8790 handleVisibilityAttr(S, D, AL, false); in ProcessDeclAttribute()
8793 handleVisibilityAttr(S, D, AL, true); in ProcessDeclAttribute()
8796 handleWarnUnusedResult(S, D, AL); in ProcessDeclAttribute()
8799 handleWeakRefAttr(S, D, AL); in ProcessDeclAttribute()
8802 handleWeakImportAttr(S, D, AL); in ProcessDeclAttribute()
8805 handleTransparentUnionAttr(S, D, AL); in ProcessDeclAttribute()
8808 handleObjCMethodFamilyAttr(S, D, AL); in ProcessDeclAttribute()
8811 handleObjCNSObject(S, D, AL); in ProcessDeclAttribute()
8814 handleObjCIndependentClass(S, D, AL); in ProcessDeclAttribute()
8817 handleBlocksAttr(S, D, AL); in ProcessDeclAttribute()
8820 handleSentinelAttr(S, D, AL); in ProcessDeclAttribute()
8823 handleCleanupAttr(S, D, AL); in ProcessDeclAttribute()
8826 handleNoDebugAttr(S, D, AL); in ProcessDeclAttribute()
8829 handleCmseNSEntryAttr(S, D, AL); in ProcessDeclAttribute()
8849 handleCallConvAttr(S, D, AL); in ProcessDeclAttribute()
8852 handleSuppressAttr(S, D, AL); in ProcessDeclAttribute()
8856 handleLifetimeCategoryAttr(S, D, AL); in ProcessDeclAttribute()
8859 handleOpenCLAccessAttr(S, D, AL); in ProcessDeclAttribute()
8862 handleOpenCLNoSVMAttr(S, D, AL); in ProcessDeclAttribute()
8865 S.AddParameterABIAttr(D, AL, ParameterABI::SwiftContext); in ProcessDeclAttribute()
8868 S.AddParameterABIAttr(D, AL, ParameterABI::SwiftAsyncContext); in ProcessDeclAttribute()
8871 S.AddParameterABIAttr(D, AL, ParameterABI::SwiftErrorResult); in ProcessDeclAttribute()
8874 S.AddParameterABIAttr(D, AL, ParameterABI::SwiftIndirectResult); in ProcessDeclAttribute()
8877 handleInternalLinkageAttr(S, D, AL); in ProcessDeclAttribute()
8880 handleZeroCallUsedRegsAttr(S, D, AL); in ProcessDeclAttribute()
8883 handleFunctionReturnThunksAttr(S, D, AL); in ProcessDeclAttribute()
8888 handleLayoutVersion(S, D, AL); in ProcessDeclAttribute()
8891 handleUuidAttr(S, D, AL); in ProcessDeclAttribute()
8894 handleMSInheritanceAttr(S, D, AL); in ProcessDeclAttribute()
8897 handleDeclspecThreadAttr(S, D, AL); in ProcessDeclAttribute()
8902 handleHLSLNumThreadsAttr(S, D, AL); in ProcessDeclAttribute()
8905 handleHLSLSVGroupIndexAttr(S, D, AL); in ProcessDeclAttribute()
8908 handleHLSLShaderAttr(S, D, AL); in ProcessDeclAttribute()
8912 handleAbiTagAttr(S, D, AL); in ProcessDeclAttribute()
8915 handleCFGuardAttr(S, D, AL); in ProcessDeclAttribute()
8920 handleAssertExclusiveLockAttr(S, D, AL); in ProcessDeclAttribute()
8923 handleAssertSharedLockAttr(S, D, AL); in ProcessDeclAttribute()
8926 handlePtGuardedVarAttr(S, D, AL); in ProcessDeclAttribute()
8929 handleNoSanitizeAttr(S, D, AL); in ProcessDeclAttribute()
8932 handleNoSanitizeSpecificAttr(S, D, AL); in ProcessDeclAttribute()
8935 handleGuardedByAttr(S, D, AL); in ProcessDeclAttribute()
8938 handlePtGuardedByAttr(S, D, AL); in ProcessDeclAttribute()
8941 handleExclusiveTrylockFunctionAttr(S, D, AL); in ProcessDeclAttribute()
8944 handleLockReturnedAttr(S, D, AL); in ProcessDeclAttribute()
8947 handleLocksExcludedAttr(S, D, AL); in ProcessDeclAttribute()
8950 handleSharedTrylockFunctionAttr(S, D, AL); in ProcessDeclAttribute()
8953 handleAcquiredBeforeAttr(S, D, AL); in ProcessDeclAttribute()
8956 handleAcquiredAfterAttr(S, D, AL); in ProcessDeclAttribute()
8962 handleCapabilityAttr(S, D, AL); in ProcessDeclAttribute()
8965 handleRequiresCapabilityAttr(S, D, AL); in ProcessDeclAttribute()
8969 handleAssertCapabilityAttr(S, D, AL); in ProcessDeclAttribute()
8972 handleAcquireCapabilityAttr(S, D, AL); in ProcessDeclAttribute()
8975 handleReleaseCapabilityAttr(S, D, AL); in ProcessDeclAttribute()
8978 handleTryAcquireCapabilityAttr(S, D, AL); in ProcessDeclAttribute()
8983 handleConsumableAttr(S, D, AL); in ProcessDeclAttribute()
8986 handleCallableWhenAttr(S, D, AL); in ProcessDeclAttribute()
8989 handleParamTypestateAttr(S, D, AL); in ProcessDeclAttribute()
8992 handleReturnTypestateAttr(S, D, AL); in ProcessDeclAttribute()
8995 handleSetTypestateAttr(S, D, AL); in ProcessDeclAttribute()
8998 handleTestTypestateAttr(S, D, AL); in ProcessDeclAttribute()
9003 handleArgumentWithTypeTagAttr(S, D, AL); in ProcessDeclAttribute()
9006 handleTypeTagForDatatypeAttr(S, D, AL); in ProcessDeclAttribute()
9011 handleSwiftAsyncName(S, D, AL); in ProcessDeclAttribute()
9014 handleSwiftAttrAttr(S, D, AL); in ProcessDeclAttribute()
9017 handleSwiftBridge(S, D, AL); in ProcessDeclAttribute()
9020 handleSwiftError(S, D, AL); in ProcessDeclAttribute()
9023 handleSwiftName(S, D, AL); in ProcessDeclAttribute()
9026 handleSwiftNewType(S, D, AL); in ProcessDeclAttribute()
9029 handleSwiftAsyncAttr(S, D, AL); in ProcessDeclAttribute()
9032 handleSwiftAsyncError(S, D, AL); in ProcessDeclAttribute()
9037 handleXRayLogArgsAttr(S, D, AL); in ProcessDeclAttribute()
9041 handlePatchableFunctionEntryAttr(S, D, AL); in ProcessDeclAttribute()
9046 handleDestroyAttr(S, D, AL); in ProcessDeclAttribute()
9050 handleUninitializedAttr(S, D, AL); in ProcessDeclAttribute()
9054 handleObjCExternallyRetainedAttr(S, D, AL); in ProcessDeclAttribute()
9058 handleMIGServerRoutineAttr(S, D, AL); in ProcessDeclAttribute()
9062 handleMSAllocatorAttr(S, D, AL); in ProcessDeclAttribute()
9066 handleArmBuiltinAliasAttr(S, D, AL); in ProcessDeclAttribute()
9070 handleAcquireHandleAttr(S, D, AL); in ProcessDeclAttribute()
9074 handleHandleAttr<ReleaseHandleAttr>(S, D, AL); in ProcessDeclAttribute()
9078 handleHandleAttr<UseHandleAttr>(S, D, AL); in ProcessDeclAttribute()
9082 handleEnforceTCBAttr<EnforceTCBAttr, EnforceTCBLeafAttr>(S, D, AL); in ProcessDeclAttribute()
9086 handleEnforceTCBAttr<EnforceTCBLeafAttr, EnforceTCBAttr>(S, D, AL); in ProcessDeclAttribute()
9090 handleBuiltinAliasAttr(S, D, AL); in ProcessDeclAttribute()
9094 handleSimpleAttribute<UsingIfExistsAttr>(S, D, AL); in ProcessDeclAttribute()
9102 Scope *S, Decl *D, const ParsedAttributesView &AttrList, in ProcessDeclAttributeList() argument
9108 ProcessDeclAttribute(*this, S, D, AL, Options); in ProcessDeclAttributeList()
9114 if (D->hasAttr<WeakRefAttr>() && !D->hasAttr<AliasAttr>()) { in ProcessDeclAttributeList()
9116 << cast<NamedDecl>(D); in ProcessDeclAttributeList()
9117 D->dropAttr<WeakRefAttr>(); in ProcessDeclAttributeList()
9125 if (!D->hasAttr<OpenCLKernelAttr>()) { in ProcessDeclAttributeList()
9127 if (const auto *A = D->getAttr<ReqdWorkGroupSizeAttr>()) { in ProcessDeclAttributeList()
9130 Diag(D->getLocation(), diag::err_opencl_kernel_attr) << A; in ProcessDeclAttributeList()
9131 D->setInvalidDecl(); in ProcessDeclAttributeList()
9132 } else if (const auto *A = D->getAttr<WorkGroupSizeHintAttr>()) { in ProcessDeclAttributeList()
9133 Diag(D->getLocation(), diag::err_opencl_kernel_attr) << A; in ProcessDeclAttributeList()
9134 D->setInvalidDecl(); in ProcessDeclAttributeList()
9135 } else if (const auto *A = D->getAttr<VecTypeHintAttr>()) { in ProcessDeclAttributeList()
9136 Diag(D->getLocation(), diag::err_opencl_kernel_attr) << A; in ProcessDeclAttributeList()
9137 D->setInvalidDecl(); in ProcessDeclAttributeList()
9138 } else if (const auto *A = D->getAttr<OpenCLIntelReqdSubGroupSizeAttr>()) { in ProcessDeclAttributeList()
9139 Diag(D->getLocation(), diag::err_opencl_kernel_attr) << A; in ProcessDeclAttributeList()
9140 D->setInvalidDecl(); in ProcessDeclAttributeList()
9141 } else if (!D->hasAttr<CUDAGlobalAttr>()) { in ProcessDeclAttributeList()
9142 if (const auto *A = D->getAttr<AMDGPUFlatWorkGroupSizeAttr>()) { in ProcessDeclAttributeList()
9143 Diag(D->getLocation(), diag::err_attribute_wrong_decl_type) in ProcessDeclAttributeList()
9145 D->setInvalidDecl(); in ProcessDeclAttributeList()
9146 } else if (const auto *A = D->getAttr<AMDGPUWavesPerEUAttr>()) { in ProcessDeclAttributeList()
9147 Diag(D->getLocation(), diag::err_attribute_wrong_decl_type) in ProcessDeclAttributeList()
9149 D->setInvalidDecl(); in ProcessDeclAttributeList()
9150 } else if (const auto *A = D->getAttr<AMDGPUNumSGPRAttr>()) { in ProcessDeclAttributeList()
9151 Diag(D->getLocation(), diag::err_attribute_wrong_decl_type) in ProcessDeclAttributeList()
9153 D->setInvalidDecl(); in ProcessDeclAttributeList()
9154 } else if (const auto *A = D->getAttr<AMDGPUNumVGPRAttr>()) { in ProcessDeclAttributeList()
9155 Diag(D->getLocation(), diag::err_attribute_wrong_decl_type) in ProcessDeclAttributeList()
9157 D->setInvalidDecl(); in ProcessDeclAttributeList()
9167 if (D->hasAttr<ObjCDesignatedInitializerAttr>() && in ProcessDeclAttributeList()
9168 cast<ObjCMethodDecl>(D)->getMethodFamily() != OMF_init) { in ProcessDeclAttributeList()
9169 Diag(D->getLocation(), diag::err_designated_init_attr_non_init); in ProcessDeclAttributeList()
9170 D->dropAttr<ObjCDesignatedInitializerAttr>(); in ProcessDeclAttributeList()
9176 void Sema::ProcessDeclAttributeDelayed(Decl *D, in ProcessDeclAttributeDelayed() argument
9180 handleTransparentUnionAttr(*this, D, AL); in ProcessDeclAttributeDelayed()
9186 if (D && D->hasAttr<BPFPreserveAccessIndexAttr>()) in ProcessDeclAttributeDelayed()
9187 handleBPFPreserveAIRecord(*this, cast<RecordDecl>(D)); in ProcessDeclAttributeDelayed()
9229 void Sema::checkUnusedDeclAttributes(Declarator &D) { in checkUnusedDeclAttributes() argument
9230 ::checkUnusedDeclAttributes(*this, D.getDeclarationAttributes()); in checkUnusedDeclAttributes()
9231 ::checkUnusedDeclAttributes(*this, D.getDeclSpec().getAttributes()); in checkUnusedDeclAttributes()
9232 ::checkUnusedDeclAttributes(*this, D.getAttributes()); in checkUnusedDeclAttributes()
9233 for (unsigned i = 0, e = D.getNumTypeObjects(); i != e; ++i) in checkUnusedDeclAttributes()
9234 ::checkUnusedDeclAttributes(*this, D.getTypeObject(i).getAttrs()); in checkUnusedDeclAttributes()
9308 void Sema::ProcessPragmaWeak(Scope *S, Decl *D) { in ProcessPragmaWeak() argument
9315 if (auto *VD = dyn_cast<VarDecl>(D)) in ProcessPragmaWeak()
9318 if (auto *FD = dyn_cast<FunctionDecl>(D)) in ProcessPragmaWeak()
9338 void Sema::ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD) { in ProcessDeclAttributes() argument
9351 AL.diagnoseAppertainsTo(*this, D); in ProcessDeclAttributes()
9356 ProcessDeclAttributeList(S, D, NonSlidingAttrs); in ProcessDeclAttributes()
9360 ProcessDeclAttributeList(S, D, PD.getDeclSpec().getAttributes(), in ProcessDeclAttributes()
9371 ProcessDeclAttributeList(S, D, PD.getTypeObject(i).getAttrs(), in ProcessDeclAttributes()
9378 ProcessDeclAttributeList(S, D, PD.getAttributes()); in ProcessDeclAttributes()
9381 AddPragmaAttributes(S, D); in ProcessDeclAttributes()
9387 static bool isForbiddenTypeAllowed(Sema &S, Decl *D, in isForbiddenTypeAllowed() argument
9393 if (!isa<FieldDecl>(D) && !isa<ObjCPropertyDecl>(D) && in isForbiddenTypeAllowed()
9394 !isa<FunctionDecl>(D)) in isForbiddenTypeAllowed()
9402 if ((isa<ObjCIvarDecl>(D) || isa<ObjCPropertyDecl>(D))) { in isForbiddenTypeAllowed()
9411 if (S.Context.getSourceManager().isInSystemHeader(D->getLocation())) { in isForbiddenTypeAllowed()
9423 Decl *D) { in handleDelayedForbiddenType() argument
9425 if (D && isForbiddenTypeAllowed(S, D, DD, Reason)) { in handleDelayedForbiddenType()
9427 D->addAttr(UnavailableAttr::CreateImplicit(S.Context, "", Reason, DD.Loc)); in handleDelayedForbiddenType()
9431 if (const auto *FD = dyn_cast<FunctionDecl>(D)) { in handleDelayedForbiddenType()