48 #include "llvm/ADT/STLExtras.h"
49 #include "llvm/ADT/STLForwardCompat.h"
50 #include "llvm/ADT/StringExtras.h"
51 #include "llvm/Demangle/Demangle.h"
52 #include "llvm/IR/Assumptions.h"
53 #include "llvm/MC/MCSectionMachO.h"
54 #include "llvm/Support/Error.h"
55 #include "llvm/Support/MathExtras.h"
56 #include "llvm/Support/raw_ostream.h"
57 #include "llvm/TargetParser/Triple.h"
60 using namespace clang;
92 return isa<DeclaratorDecl>(D) || isa<BlockDecl>(D) || isa<TypedefNameDecl>(D) ||
93 isa<ObjCPropertyDecl>(D);
101 return isa<FunctionProtoType>(FnTy);
102 return isa<ObjCMethodDecl>(D) || isa<BlockDecl>(D);
110 return cast<FunctionProtoType>(FnTy)->getNumParams();
111 if (
const auto *BD = dyn_cast<BlockDecl>(D))
112 return BD->getNumParams();
113 return cast<ObjCMethodDecl>(D)->param_size();
118 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
119 return FD->getParamDecl(Idx);
120 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
121 return MD->getParamDecl(Idx);
122 if (
const auto *BD = dyn_cast<BlockDecl>(D))
123 return BD->getParamDecl(Idx);
129 return cast<FunctionProtoType>(FnTy)->getParamType(Idx);
130 if (
const auto *BD = dyn_cast<BlockDecl>(D))
131 return BD->getParamDecl(Idx)->getType();
133 return cast<ObjCMethodDecl>(D)->parameters()[Idx]->getType();
138 return PVD->getSourceRange();
144 return FnTy->getReturnType();
145 return cast<ObjCMethodDecl>(D)->getReturnType();
149 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
150 return FD->getReturnTypeSourceRange();
151 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
152 return MD->getReturnTypeSourceRange();
158 return cast<FunctionProtoType>(FnTy)->isVariadic();
159 if (
const auto *BD = dyn_cast<BlockDecl>(D))
160 return BD->isVariadic();
161 return cast<ObjCMethodDecl>(D)->isVariadic();
165 if (
const auto *MethodDecl = dyn_cast<CXXMethodDecl>(D))
166 return MethodDecl->isInstance();
171 bool AllowNSAttributedString =
false) {
182 if (AllowNSAttributedString &&
183 ClsName == &Ctx.
Idents.
get(
"NSAttributedString"))
186 return ClsName == &Ctx.
Idents.
get(
"NSString") ||
187 ClsName == &Ctx.
Idents.
get(
"NSMutableString");
213 template <
typename AttrInfo>
214 static std::enable_if_t<std::is_base_of_v<Attr, AttrInfo>,
SourceLocation>
216 return AL.getLocation();
225 template <
typename AttrInfo>
227 uint32_t &Val,
unsigned Idx =
UINT_MAX,
228 bool StrictlyUnsigned =
false) {
242 if (!I->isIntN(32)) {
244 <<
toString(*I, 10,
false) << 32 << 1;
248 if (StrictlyUnsigned && I->isSigned() && I->isNegative()) {
249 S.
Diag(
getAttrLoc(AI), diag::err_attribute_requires_positive_integer)
254 Val = (uint32_t)I->getZExtValue();
261 template <
typename AttrInfo>
263 int &Val,
unsigned Idx =
UINT_MAX) {
272 <<
toString(I, 10,
false) << 32 << 0;
282 template <
typename AttrTy>
285 if (
const auto *A = D->
getAttr<AttrTy>()) {
286 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
289 S.
Diag(A->getLocation(), diag::note_conflicting_attribute);
295 template <
typename AttrTy>
297 if (
const auto *A = D->
getAttr<AttrTy>()) {
301 S.
Diag(A->getLocation(), diag::note_conflicting_attribute);
309 assert((!NewName.empty() || !NewScope.empty()) &&
310 "Deprecated attribute with no new scope or name?");
311 Diag(A.
getLoc(), diag::warn_attribute_spelling_deprecated)
315 std::string NewFullName;
316 if (NewScope.empty() && !NewName.empty()) {
323 }
else if (NewName.empty() && !NewScope.empty()) {
329 NewFullName = (NewScope +
"::" + NewName).str();
333 Diag(A.
getLoc(), diag::note_spelling_suggestion)
334 <<
"'" + NewFullName +
"'" << Fix;
340 if (A.
getKind() == ParsedAttr::AT_SYCLIntelInitiationInterval &&
342 DiagnoseDeprecatedAttribute(A,
"intel",
"initiation_interval");
351 DiagnoseDeprecatedAttribute(A,
"sycl", NewName);
365 Diag(A.
getLoc(), diag::warn_attribute_spelling_deprecated)
367 Diag(A.
getLoc(), diag::note_spelling_suggestion)
377 Diag(A.
getLoc(), diag::ext_sycl_2020_attr_spelling) << A;
386 template <
typename AttrInfo>
387 static bool checkFunctionOrMethodParameterIndex(
388 Sema &S,
const Decl *D,
const AttrInfo &AI,
unsigned AttrArgNum,
389 const Expr *IdxExpr,
ParamIdx &Idx,
bool CanIndexImplicitThis =
false) {
400 std::optional<llvm::APSInt> IdxInt;
409 unsigned IdxSource = IdxInt->getLimitedValue(
UINT_MAX);
410 if (IdxSource < 1 || (!IV && IdxSource > NumParams)) {
411 S.
Diag(
getAttrLoc(AI), diag::err_attribute_argument_out_of_bounds)
415 if (HasImplicitThisParam && !CanIndexImplicitThis) {
416 if (IdxSource == 1) {
417 S.
Diag(
getAttrLoc(AI), diag::err_attribute_invalid_implicit_this_argument)
431 const Expr *E, StringRef &Str,
457 Diag(
Loc->Loc, diag::err_attribute_argument_type)
461 Str =
Loc->Ident->getName();
463 *ArgLocation =
Loc->Loc;
479 return checkStringLiteralArgumentAttr(AL, ArgExpr, Str, ArgLocation);
484 template <
typename AttrType>
485 static void handleSimpleAttribute(
Sema &S,
Decl *D,
490 template <
typename... DiagnosticArgs>
491 static const Sema::SemaDiagnosticBuilder&
492 appendDiagnostics(
const Sema::SemaDiagnosticBuilder &Bldr) {
496 template <
typename T,
typename... DiagnosticArgs>
497 static const Sema::SemaDiagnosticBuilder&
498 appendDiagnostics(
const Sema::SemaDiagnosticBuilder &Bldr,
T &&ExtraArg,
499 DiagnosticArgs &&... ExtraArgs) {
500 return appendDiagnostics(Bldr << std::forward<T>(ExtraArg),
501 std::forward<DiagnosticArgs>(ExtraArgs)...);
508 template <
typename AttrType,
typename... DiagnosticArgs>
509 static void handleSimpleAttributeOrDiagnose(
Sema &S,
Decl *D,
511 bool PassesCheck,
unsigned DiagID,
512 DiagnosticArgs &&... ExtraArgs) {
515 appendDiagnostics(DB, std::forward<DiagnosticArgs>(ExtraArgs)...);
518 handleSimpleAttribute<AttrType>(S, D, CI);
522 static bool isIntOrBool(
Expr *Exp) {
530 static bool threadSafetyCheckIsSmartPointer(
Sema &S,
const RecordType* RT) {
535 return !Result.empty();
539 bool foundStarOperator = IsOverloadedOperatorPresent(
Record, OO_Star);
540 bool foundArrowOperator = IsOverloadedOperatorPresent(
Record, OO_Arrow);
541 if (foundStarOperator && foundArrowOperator)
548 for (
const auto &BaseSpecifier :
CXXRecord->bases()) {
549 if (!foundStarOperator)
550 foundStarOperator = IsOverloadedOperatorPresent(
551 BaseSpecifier.getType()->getAsRecordDecl(), OO_Star);
552 if (!foundArrowOperator)
553 foundArrowOperator = IsOverloadedOperatorPresent(
554 BaseSpecifier.getType()->getAsRecordDecl(), OO_Arrow);
557 if (foundStarOperator && foundArrowOperator)
566 static bool threadSafetyCheckIsPointer(
Sema &S,
const Decl *D,
568 const auto *VD = cast<ValueDecl>(D);
580 if (threadSafetyCheckIsSmartPointer(S, RT))
584 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_decl_not_pointer) << AL << QT;
601 template <
typename AttrType>
602 static bool checkRecordDeclForAttr(
const RecordDecl *RD) {
608 if (
const auto *CRD = dyn_cast<CXXRecordDecl>(RD)) {
610 return !Base->hasAttr<AttrType>();
617 static bool checkRecordTypeForCapability(
Sema &S,
QualType Ty) {
629 if (threadSafetyCheckIsSmartPointer(S, RT))
632 return checkRecordDeclForAttr<CapabilityAttr>(RT->
getDecl());
635 static bool checkTypedefTypeForCapability(
QualType Ty) {
644 return TN->
hasAttr<CapabilityAttr>();
648 if (checkTypedefTypeForCapability(Ty))
651 if (checkRecordTypeForCapability(S, Ty))
657 static bool isCapabilityExpr(
Sema &S,
const Expr *Ex) {
663 if (
const auto *E = dyn_cast<CastExpr>(Ex))
664 return isCapabilityExpr(S, E->getSubExpr());
665 else if (
const auto *E = dyn_cast<ParenExpr>(Ex))
666 return isCapabilityExpr(S, E->getSubExpr());
667 else if (
const auto *E = dyn_cast<UnaryOperator>(Ex)) {
668 if (E->getOpcode() == UO_LNot || E->getOpcode() == UO_AddrOf ||
669 E->getOpcode() == UO_Deref)
670 return isCapabilityExpr(S, E->getSubExpr());
672 }
else if (
const auto *E = dyn_cast<BinaryOperator>(Ex)) {
673 if (E->getOpcode() == BO_LAnd || E->getOpcode() == BO_LOr)
674 return isCapabilityExpr(S, E->getLHS()) &&
675 isCapabilityExpr(S, E->getRHS());
679 return typeHasCapability(S, Ex->
getType());
687 static void checkAttrArgsAreCapabilityObjs(
Sema &S,
Decl *D,
691 bool ParamIdxOk =
false) {
696 const auto *MD = dyn_cast<const CXXMethodDecl>(D);
697 if (MD && !MD->isStatic()) {
700 if (!checkRecordDeclForAttr<CapabilityAttr>(RD) &&
701 !checkRecordDeclForAttr<ScopedLockableAttr>(RD))
703 diag::warn_thread_attribute_not_on_capability_member)
704 << AL << MD->getParent();
706 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_not_on_non_static_member)
711 for (
unsigned Idx = Sidx; Idx < AL.
getNumArgs(); ++Idx) {
716 Args.push_back(ArgExp);
720 if (
const auto *StrLit = dyn_cast<StringLiteral>(ArgExp)) {
721 if (StrLit->getLength() == 0 ||
722 (StrLit->isOrdinary() && StrLit->getString() ==
"*")) {
725 Args.push_back(ArgExp);
731 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_ignored) << AL;
732 Args.push_back(ArgExp);
740 if (
const auto *UOp = dyn_cast<UnaryOperator>(ArgExp))
741 if (UOp->getOpcode() == UO_AddrOf)
742 if (
const auto *DRE = dyn_cast<DeclRefExpr>(UOp->getSubExpr()))
743 if (DRE->getDecl()->isCXXInstanceMember())
744 ArgTy = DRE->getDecl()->getType();
750 if(!RT && ParamIdxOk) {
751 const auto *FD = dyn_cast<FunctionDecl>(D);
752 const auto *IL = dyn_cast<IntegerLiteral>(ArgExp);
754 unsigned int NumParams = FD->getNumParams();
756 uint64_t ParamIdxFromOne = ArgValue.getZExtValue();
757 uint64_t ParamIdxFromZero = ParamIdxFromOne - 1;
758 if (!ArgValue.isStrictlyPositive() || ParamIdxFromOne > NumParams) {
760 diag::err_attribute_argument_out_of_bounds_extra_info)
761 << AL << Idx + 1 << NumParams;
764 ArgTy = FD->getParamDecl(ParamIdxFromZero)->getType();
772 if (!typeHasCapability(S, ArgTy) && !isCapabilityExpr(S, ArgExp))
773 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_argument_not_lockable)
776 Args.push_back(ArgExp);
785 if (!threadSafetyCheckIsPointer(S, D, AL))
795 checkAttrArgsAreCapabilityObjs(S, D, AL, Args);
796 unsigned Size = Args.size();
807 if (!checkGuardedByAttrCommon(S, D, AL, Arg))
815 if (!checkGuardedByAttrCommon(S, D, AL, Arg))
818 if (!threadSafetyCheckIsPointer(S, D, AL))
830 QualType QT = cast<ValueDecl>(D)->getType();
832 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_decl_not_lockable) << AL;
837 checkAttrArgsAreCapabilityObjs(S, D, AL, Args);
846 if (!checkAcquireOrderAttrCommon(S, D, AL, Args))
849 Expr **StartArg = &Args[0];
851 AcquiredAfterAttr(S.
Context, AL, StartArg, Args.size()));
856 if (!checkAcquireOrderAttrCommon(S, D, AL, Args))
859 Expr **StartArg = &Args[0];
861 AcquiredBeforeAttr(S.
Context, AL, StartArg, Args.size()));
868 checkAttrArgsAreCapabilityObjs(S, D, AL, Args, 0,
true);
875 if (!checkLockFunAttrCommon(S, D, AL, Args))
878 unsigned Size = Args.size();
879 Expr **StartArg =
Size == 0 ? nullptr : &Args[0];
881 AssertSharedLockAttr(S.
Context, AL, StartArg, Size));
884 static void handleAssertExclusiveLockAttr(
Sema &S,
Decl *D,
887 if (!checkLockFunAttrCommon(S, D, AL, Args))
890 unsigned Size = Args.size();
891 Expr **StartArg =
Size == 0 ? nullptr : &Args[0];
893 AssertExclusiveLockAttr(S.
Context, AL, StartArg, Size));
901 template <
typename AttrInfo>
902 static bool checkParamIsIntegerType(
Sema &S,
const Decl *D,
const AttrInfo &AI,
903 unsigned AttrArgNo) {
904 assert(AI.isArgExpr(AttrArgNo) &&
"Expected expression argument");
905 Expr *AttrArg = AI.getArgAsExpr(AttrArgNo);
907 if (!checkFunctionOrMethodParameterIndex(S, D, AI, AttrArgNo + 1, AttrArg,
914 S.
Diag(SrcLoc, diag::err_attribute_integers_only)
929 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only) << AL;
938 if (!checkParamIsIntegerType(S, D, AL, 0))
940 ParamIdx SizeArgNo(SizeArgNoVal, D);
949 if (!checkParamIsIntegerType(S, D, AL, 1))
955 AllocSizeAttr(S.
Context, AL, SizeArgNo, NumberArgNo));
964 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
970 checkAttrArgsAreCapabilityObjs(S, D, AL, Args, 1);
975 static void handleSharedTrylockFunctionAttr(
Sema &S,
Decl *D,
978 if (!checkTryLockFunAttrCommon(S, D, AL, Args))
985 static void handleExclusiveTrylockFunctionAttr(
Sema &S,
Decl *D,
988 if (!checkTryLockFunAttrCommon(S, D, AL, Args))
998 checkAttrArgsAreCapabilityObjs(S, D, AL, Args);
999 unsigned Size = Args.size();
1012 checkAttrArgsAreCapabilityObjs(S, D, AL, Args);
1013 unsigned Size = Args.size();
1016 Expr **StartArg = &Args[0];
1019 LocksExcludedAttr(S.
Context, AL, StartArg, Size));
1023 Expr *&Cond, StringRef &Msg) {
1029 Cond = Converted.
get();
1036 Msg =
"<no message provided>";
1042 S.
Diag(AL.
getLoc(), diag::err_attr_cond_never_constant_expr) << AL;
1044 S.
Diag(PDiag.first, PDiag.second);
1051 S.
Diag(AL.
getLoc(), diag::ext_clang_enable_if);
1055 if (checkFunctionConditionAttr(S, D, AL, Cond, Msg))
1060 StringRef NewUserDiagnostic;
1067 static void handleExcludeFromExplicitInstantiationAttr(
Sema &S,
Decl *D,
1069 const auto *PD = isa<CXXRecordDecl>(D)
1070 ? cast<DeclContext>(D)
1071 : D->getDeclContext()->getRedeclContext();
1072 if (
const auto *RD = dyn_cast<CXXRecordDecl>(PD); RD && RD->
isLocalClass()) {
1074 diag::warn_attribute_exclude_from_explicit_instantiation_local_class)
1075 << AL << !isa<CXXRecordDecl>(D);
1079 ExcludeFromExplicitInstantiationAttr(S.
Context, AL));
1085 class ArgumentDependenceChecker
1096 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD))
1099 ClassType =
nullptr;
1104 bool referencesArgs(
Expr *E) {
1112 "`this` doesn't refer to the enclosing class?");
1118 if (
const auto *PVD = dyn_cast<ParmVarDecl>(DRE->
getDecl()))
1119 if (Parms.count(PVD)) {
1128 static void handleDiagnoseAsBuiltinAttr(
Sema &S,
Decl *D,
1130 const auto *DeclFD = cast<FunctionDecl>(D);
1132 if (
const auto *MethodDecl = dyn_cast<CXXMethodDecl>(DeclFD))
1133 if (!MethodDecl->isStatic()) {
1134 S.
Diag(AL.
getLoc(), diag::err_attribute_no_member_function) << AL;
1146 S.
Diag(
Loc, diag::err_attribute_argument_n_type) << AL << Index <<
T;
1152 auto *F = dyn_cast_if_present<DeclRefExpr>(AL.
getArgAsExpr(0));
1155 return dyn_cast_if_present<FunctionDecl>(F->getFoundDecl());
1164 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments_for)
1171 for (
unsigned I = 1; I < AL.
getNumArgs(); ++I) {
1183 if (Index > DeclFD->getNumParams()) {
1184 S.
Diag(AL.
getLoc(), diag::err_attribute_bounds_for_function)
1185 << AL << Index << DeclFD << DeclFD->getNumParams();
1190 QualType T2 = DeclFD->getParamDecl(Index - 1)->getType();
1195 << AL << Index << DeclFD << T2 << I << AttrFD << T1;
1199 Indices.push_back(Index - 1);
1203 S.
Context, AL, AttrFD, Indices.data(), Indices.size()));
1207 S.
Diag(AL.
getLoc(), diag::ext_clang_diagnose_if);
1211 if (!checkFunctionConditionAttr(S, D, AL, Cond, Msg))
1214 StringRef DiagTypeStr;
1218 DiagnoseIfAttr::DiagnosticType DiagType;
1219 if (!DiagnoseIfAttr::ConvertStrToDiagnosticType(DiagTypeStr, DiagType)) {
1221 diag::err_diagnose_if_invalid_diagnostic_type);
1225 bool ArgDependent =
false;
1226 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
1227 ArgDependent = ArgumentDependenceChecker(FD).referencesArgs(Cond);
1229 S.
Context, AL, Cond, Msg, DiagType, ArgDependent, cast<NamedDecl>(D)));
1233 static constexpr
const StringRef kWildcard =
"*";
1236 bool HasWildcard =
false;
1238 const auto AddBuiltinName = [&Names, &HasWildcard](StringRef Name) {
1239 if (Name == kWildcard)
1241 Names.push_back(Name);
1245 if (
const auto *NBA = D->
getAttr<NoBuiltinAttr>())
1246 for (StringRef BuiltinName : NBA->builtinNames())
1247 AddBuiltinName(BuiltinName);
1251 AddBuiltinName(kWildcard);
1253 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
1254 StringRef BuiltinName;
1260 AddBuiltinName(BuiltinName);
1262 S.
Diag(LiteralLoc, diag::warn_attribute_no_builtin_invalid_builtin_name)
1263 << BuiltinName << AL;
1268 Names.erase(std::unique(Names.begin(), Names.end()), Names.end());
1271 if (HasWildcard && Names.size() > 1)
1273 diag::err_attribute_no_builtin_wildcard_or_builtin_name)
1276 if (D->
hasAttr<NoBuiltinAttr>())
1279 NoBuiltinAttr(S.
Context, AL, Names.data(), Names.size()));
1283 if (D->
hasAttr<PassObjectSizeAttr>()) {
1284 S.
Diag(D->
getBeginLoc(), diag::err_attribute_only_once_per_parameter) << AL;
1306 if (!cast<ParmVarDecl>(D)->getType()->isPointerType()) {
1307 S.
Diag(D->
getBeginLoc(), diag::err_attribute_pointers_only) << AL << 1;
1319 if (!ConsumableAttr::ConvertStrToConsumedState(IL->
Ident->
getName(),
1321 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported) << AL
1326 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1339 if (!RD->
hasAttr<ConsumableAttr>()) {
1340 S.
Diag(AL.
getLoc(), diag::warn_attr_on_unconsumable_class) << RD;
1353 if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), AL))
1357 for (
unsigned ArgIndex = 0; ArgIndex < AL.
getNumArgs(); ++ArgIndex) {
1360 StringRef StateString;
1371 if (!CallableWhenAttr::ConvertStrToConsumedState(StateString,
1373 S.
Diag(
Loc, diag::warn_attribute_type_not_supported) << AL << StateString;
1377 States.push_back(CallableState);
1381 CallableWhenAttr(S.
Context, AL, States.data(), States.size()));
1391 if (!ParamTypestateAttr::ConvertStrToConsumedState(StateString,
1393 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported)
1394 << AL << StateString;
1398 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1423 if (!ReturnTypestateAttr::ConvertStrToConsumedState(IL->
Ident->
getName(),
1425 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported) << AL
1430 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1464 if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), AL))
1471 if (!SetTypestateAttr::ConvertStrToConsumedState(Param, NewState)) {
1472 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported) << AL
1477 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1486 if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), AL))
1493 if (!TestTypestateAttr::ConvertStrToConsumedState(Param, TestState)) {
1494 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported) << AL
1499 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1513 if (
auto *TD = dyn_cast<TagDecl>(D))
1515 else if (
auto *FD = dyn_cast<FieldDecl>(D)) {
1522 if (BitfieldByteAligned)
1524 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored_for_field_of_type)
1530 if (BitfieldByteAligned)
1531 S.
Diag(AL.
getLoc(), diag::warn_attribute_packed_for_bitfield);
1537 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored) << AL;
1541 auto *RD = cast<CXXRecordDecl>(D);
1543 assert(CTD &&
"attribute does not appertain to this declaration");
1554 if (
const auto *CTSD = dyn_cast_if_present<ClassTemplateSpecializationDecl>(
1556 Template = CTSD->getSpecializedTemplate();
1558 while (TST && TST->isTypeAlias())
1561 Template = TST->getTemplateName().getAsTemplateDecl();
1570 S.
Diag(AL.
getLoc(), diag::err_attribute_preferred_name_arg_invalid)
1573 S.
Diag(TT->getDecl()->getLocation(), diag::note_entity_declared_at)
1581 if (
const auto *VD = dyn_cast<ObjCIvarDecl>(D)) {
1583 S.
Diag(AL.
getLoc(), diag::warn_iboutlet_object_type)
1584 << AL << VD->getType() << 0;
1588 else if (
const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
1590 S.
Diag(AL.
getLoc(), diag::warn_iboutlet_object_type)
1591 << AL << PD->getType() << 1;
1596 S.
Diag(AL.
getLoc(), diag::warn_attribute_iboutlet) << AL;
1604 if (!checkIBOutletCommon(S, D, AL))
1614 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
1618 if (!checkIBOutletCommon(S, D, AL))
1629 S.
Diag(AL.
getLoc(), diag::err_iboutletcollection_type) <<
"NSObject";
1645 QT->
isBuiltinType() ? diag::err_iboutletcollection_builtintype
1646 : diag::err_iboutletcollection_type) << QT;
1658 T =
T.getNonReferenceType();
1664 if (UT && UT->getDecl()->hasAttr<TransparentUnionAttr>()) {
1666 for (
const auto *I : UD->
fields()) {
1680 bool isReturnValue =
false) {
1683 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only)
1684 << AL << AttrParmRange << TypeRange;
1686 S.
Diag(AL.
getLoc(), diag::warn_attribute_pointers_only)
1687 << AL << AttrParmRange << TypeRange << 0;
1695 for (
unsigned I = 0; I < AL.
getNumArgs(); ++I) {
1698 if (!checkFunctionOrMethodParameterIndex(S, D, AL, I + 1, Ex, Idx))
1703 !attrNonNullArgCheck(
1709 NonNullArgs.push_back(Idx);
1720 I != E && !AnyPointers; ++I) {
1727 S.
Diag(AL.
getLoc(), diag::warn_attribute_nonnull_no_pointers);
1730 ParamIdx *Start = NonNullArgs.data();
1731 unsigned Size = NonNullArgs.size();
1732 llvm::array_pod_sort(Start, Start + Size);
1740 handleNonNullAttr(S, D, AL);
1742 S.
Diag(AL.
getLoc(), diag::warn_attribute_nonnull_parm_no_args)
1759 if (!attrNonNullArgCheck(S, ResultType, AL,
SourceRange(), SR,
1771 QualType T = cast<ParmVarDecl>(D)->getType();
1773 S.
Diag(AL.
getLoc(), diag::warn_attribute_pointers_only)
1796 AssumeAlignedAttr TmpAttr(Context, CI, E, OE);
1799 if (!isValidPointerAttrType(ResultType,
true)) {
1800 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
1801 << &TmpAttr << TmpAttr.getRange() << SR;
1809 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1813 Diag(AttrLoc, diag::err_attribute_argument_type)
1819 if (!I->isPowerOf2()) {
1820 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
1826 Diag(CI.
getLoc(), diag::warn_assume_aligned_too_great)
1831 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1837 D->
addAttr(::
new (Context) AssumeAlignedAttr(Context, CI, E, OE));
1844 AllocAlignAttr TmpAttr(Context, CI,
ParamIdx());
1848 !isValidPointerAttrType(ResultType,
true)) {
1849 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
1855 const auto *FuncDecl = cast<FunctionDecl>(D);
1856 if (!checkFunctionOrMethodParameterIndex(*
this, FuncDecl, TmpAttr,
1865 << FuncDecl->getParamDecl(Idx.
getASTIndex())->getSourceRange();
1869 D->
addAttr(::
new (Context) AllocAlignAttr(Context, CI, Idx));
1874 StringRef AssumptionStr) {
1875 if (llvm::KnownAssumptionStrings.count(AssumptionStr))
1878 unsigned BestEditDistance = 3;
1879 StringRef Suggestion;
1880 for (
const auto &KnownAssumptionIt : llvm::KnownAssumptionStrings) {
1881 unsigned EditDistance =
1882 AssumptionStr.edit_distance(KnownAssumptionIt.getKey());
1883 if (EditDistance < BestEditDistance) {
1884 Suggestion = KnownAssumptionIt.getKey();
1885 BestEditDistance = EditDistance;
1889 if (!Suggestion.empty())
1890 S.
Diag(
Loc, diag::warn_omp_assume_attribute_string_unknown_suggested)
1891 << AssumptionStr << Suggestion;
1893 S.
Diag(
Loc, diag::warn_omp_assume_attribute_string_unknown)
1904 checkOMPAssumeAttr(S, AttrStrLoc, Str);
1912 if (AttrName.size() > 4 && AttrName.starts_with(
"__") &&
1913 AttrName.ends_with(
"__")) {
1914 AttrName = AttrName.drop_front(2).drop_back(2);
1930 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
1936 OwnershipAttr::OwnershipKind K =
1937 OwnershipAttr(S.
Context, AL,
nullptr,
nullptr, 0).getOwnKind();
1941 case OwnershipAttr::Takes:
1942 case OwnershipAttr::Holds:
1944 S.
Diag(AL.
getLoc(), diag::err_attribute_too_few_arguments) << AL << 2;
1948 case OwnershipAttr::Returns:
1950 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 1;
1958 StringRef ModuleName =
Module->getName();
1964 for (
unsigned i = 1; i < AL.
getNumArgs(); ++i) {
1967 if (!checkFunctionOrMethodParameterIndex(S, D, AL, i, Ex, Idx))
1974 case OwnershipAttr::Takes:
1975 case OwnershipAttr::Holds:
1979 case OwnershipAttr::Returns:
1985 S.
Diag(AL.
getLoc(), diag::err_ownership_type) << AL << Err
1994 if (I->getOwnKind() != K && llvm::is_contained(I->args(), Idx)) {
1995 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
1998 I->isRegularKeywordAttribute());
2000 }
else if (K == OwnershipAttr::Returns &&
2001 I->getOwnKind() == OwnershipAttr::Returns) {
2004 if (!llvm::is_contained(I->args(), Idx)) {
2005 S.
Diag(I->getLocation(), diag::err_ownership_returns_index_mismatch)
2006 << I->args_begin()->getSourceIndex();
2008 S.
Diag(AL.
getLoc(), diag::note_ownership_returns_index_mismatch)
2014 OwnershipArgs.push_back(Idx);
2017 ParamIdx *Start = OwnershipArgs.data();
2018 unsigned Size = OwnershipArgs.size();
2019 llvm::array_pod_sort(Start, Start + Size);
2027 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
2043 S.
Diag(AL.
getLoc(), diag::err_attribute_weakref_not_global_context)
2044 << cast<NamedDecl>(D);
2088 std::unique_ptr<char, llvm::FreeDeleter> Demangled;
2090 Demangled.reset(llvm::itaniumDemangle(Str,
false));
2099 if (!isa<FunctionDecl>(ND) && !isa<VarDecl>(ND))
2101 if (MC->shouldMangleDeclName(ND)) {
2102 llvm::raw_svector_ostream Out(Name);
2106 Name = ND->getIdentifier()->getName();
2120 const auto *FD = cast<FunctionDecl>(D);
2122 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << FD << 1;
2126 markUsedForAliasOrIfunc(S, D, AL, Str);
2136 S.
Diag(AL.
getLoc(), diag::err_alias_not_supported_on_darwin);
2144 S.
Diag(AL.
getLoc(), diag::err_alias_not_supported_on_nvptx);
2148 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
2150 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << FD << 0;
2154 const auto *VD = cast<VarDecl>(D);
2155 if (VD->isThisDeclarationADefinition() && VD->isExternallyVisible()) {
2156 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << VD << 0;
2161 markUsedForAliasOrIfunc(S, D, AL, Str);
2173 if (Model !=
"global-dynamic" && Model !=
"local-dynamic"
2174 && Model !=
"initial-exec" && Model !=
"local-exec") {
2175 S.
Diag(LiteralLoc, diag::err_attr_tlsmodel_arg);
2189 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only)
2197 if (checkAttrMutualExclusion<CPUSpecificAttr>(S, D, AL))
2200 if (
const auto *Other = D->
getAttr<CPUDispatchAttr>()) {
2201 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
2202 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
2205 }
else if (AL.
getParsedKind() == ParsedAttr::AT_CPUSpecific) {
2206 if (checkAttrMutualExclusion<CPUDispatchAttr>(S, D, AL))
2209 if (
const auto *Other = D->
getAttr<CPUSpecificAttr>()) {
2210 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
2211 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
2218 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
2220 S.
Diag(AL.
getLoc(), diag::err_attribute_dll_lambda) << AL;
2231 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
2240 S.
Diag(CPUArg->
Loc, diag::err_invalid_cpu_specific_dispatch_value)
2241 << CPUName << (AL.
getKind() == ParsedAttr::AT_CPUDispatch);
2247 return Target.CPUSpecificManglingCharacter(CPUName) ==
2250 S.
Diag(AL.
getLoc(), diag::warn_multiversion_duplicate_entries);
2253 CPUs.push_back(CPUArg->
Ident);
2257 if (AL.
getKind() == ParsedAttr::AT_CPUSpecific)
2259 CPUSpecificAttr(S.
Context, AL, CPUs.data(), CPUs.size()));
2262 CPUDispatchAttr(S.
Context, AL, CPUs.data(), CPUs.size()));
2267 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
2277 S.
Diag(AL.
getLoc(), diag::err_attribute_not_clinkage) << AL;
2281 const auto *FD = cast<FunctionDecl>(D);
2283 S.
Diag(AL.
getLoc(), diag::warn_attribute_cmse_entry_static);
2293 const auto &Arch = Triple.getArch();
2294 if (Arch != llvm::Triple::x86 &&
2295 (Arch != llvm::Triple::arm && Arch != llvm::Triple::thumb)) {
2296 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_on_arch)
2297 << AL << Triple.getArchName();
2303 if (S.
getLangOpts().MSVCCompat && isa<CXXMethodDecl>(D)) {
2304 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_decl_type_str)
2316 if (!isa<ObjCMethodDecl>(D)) {
2317 S.
Diag(Attrs.
getLoc(), diag::warn_attribute_wrong_decl_type)
2343 S.
Diag(Attrs.
getLoc(), diag::warn_nocf_check_attribute_ignored);
2345 handleSimpleAttribute<AnyX86NoCfCheckAttr>(S, D, Attrs);
2364 ? diag::err_keyword_not_supported_on_target
2365 : diag::warn_unknown_attribute_ignored)
2383 ? diag::err_attribute_wrong_decl_type
2384 : diag::warn_attribute_wrong_decl_type)
2420 if (VecReturnAttr *A = D->
getAttr<VecReturnAttr>()) {
2421 S.
Diag(AL.
getLoc(), diag::err_repeat_attribute) << A;
2425 const auto *R = cast<RecordDecl>(D);
2428 if (!isa<CXXRecordDecl>(R)) {
2429 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
2433 if (!cast<CXXRecordDecl>(R)->isPOD()) {
2434 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_pod_record);
2438 for (
const auto *I : R->fields()) {
2439 if ((count == 1) || !I->getType()->isVectorType()) {
2440 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
2451 if (isa<ParmVarDecl>(D)) {
2456 diag::err_carries_dependency_param_not_function_decl);
2470 S.
Diag(AL.
getLoc(), diag::ext_cxx17_attr) << AL;
2476 uint32_t priority = ConstructorAttr::DefaultPriority;
2478 S.
Diag(AL.
getLoc(), diag::err_hlsl_init_priority_unsupported);
2489 uint32_t priority = DestructorAttr::DefaultPriority;
2497 template <
typename AttrTy>
2507 static void handleObjCSuppresProtocolAttr(
Sema &S,
Decl *D,
2509 if (!cast<ObjCProtocolDecl>(D)->isThisDeclarationADefinition()) {
2510 S.
Diag(AL.
getLoc(), diag::err_objc_attr_protocol_requires_definition)
2520 VersionTuple Introduced,
2522 VersionTuple Obsoleted) {
2523 StringRef PlatformName
2524 = AvailabilityAttr::getPrettyPlatformName(Platform->
getName());
2525 if (PlatformName.empty())
2526 PlatformName = Platform->
getName();
2530 if (!Introduced.empty() && !
Deprecated.empty() &&
2533 << 1 << PlatformName <<
Deprecated.getAsString()
2534 << 0 << Introduced.getAsString();
2538 if (!Introduced.empty() && !Obsoleted.empty() &&
2539 !(Introduced <= Obsoleted)) {
2541 << 2 << PlatformName << Obsoleted.getAsString()
2542 << 0 << Introduced.getAsString();
2546 if (!
Deprecated.empty() && !Obsoleted.empty() &&
2549 << 2 << PlatformName << Obsoleted.getAsString()
2561 static bool versionsMatch(
const VersionTuple &
X,
const VersionTuple &Y,
2562 bool BeforeIsOkay) {
2563 if (
X.empty() || Y.empty())
2569 if (BeforeIsOkay &&
X < Y)
2577 bool Implicit, VersionTuple Introduced, VersionTuple
Deprecated,
2578 VersionTuple Obsoleted,
bool IsUnavailable, StringRef Message,
2579 bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK,
2581 VersionTuple MergedIntroduced = Introduced;
2583 VersionTuple MergedObsoleted = Obsoleted;
2584 bool FoundAny =
false;
2585 bool OverrideOrImpl =
false;
2588 case AMK_Redeclaration:
2589 OverrideOrImpl =
false;
2593 case AMK_ProtocolImplementation:
2594 case AMK_OptionalProtocolImplementation:
2595 OverrideOrImpl =
true;
2601 for (
unsigned i = 0, e = Attrs.size(); i != e;) {
2602 const auto *OldAA = dyn_cast<AvailabilityAttr>(Attrs[i]);
2609 if (OldPlatform != Platform) {
2615 if (OldEnvironment != Environment) {
2623 if (OldAA->getPriority() <
Priority)
2629 if (OldAA->getPriority() >
Priority) {
2630 Attrs.erase(Attrs.begin() + i);
2636 VersionTuple OldIntroduced = OldAA->getIntroduced();
2637 VersionTuple OldDeprecated = OldAA->getDeprecated();
2638 VersionTuple OldObsoleted = OldAA->getObsoleted();
2639 bool OldIsUnavailable = OldAA->getUnavailable();
2641 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl) ||
2644 !(OldIsUnavailable == IsUnavailable ||
2645 (OverrideOrImpl && !OldIsUnavailable && IsUnavailable))) {
2646 if (OverrideOrImpl) {
2648 VersionTuple FirstVersion;
2649 VersionTuple SecondVersion;
2650 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl)) {
2652 FirstVersion = OldIntroduced;
2653 SecondVersion = Introduced;
2657 SecondVersion = OldDeprecated;
2658 }
else if (!
versionsMatch(Obsoleted, OldObsoleted, OverrideOrImpl)) {
2660 FirstVersion = Obsoleted;
2661 SecondVersion = OldObsoleted;
2665 Diag(OldAA->getLocation(),
2666 diag::warn_mismatched_availability_override_unavail)
2667 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2668 << (AMK == AMK_Override);
2669 }
else if (Which != 1 && AMK == AMK_OptionalProtocolImplementation) {
2678 Diag(OldAA->getLocation(),
2679 diag::warn_mismatched_availability_override)
2681 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2682 << FirstVersion.getAsString() << SecondVersion.getAsString()
2683 << (AMK == AMK_Override);
2685 if (AMK == AMK_Override)
2686 Diag(CI.
getLoc(), diag::note_overridden_method);
2688 Diag(CI.
getLoc(), diag::note_protocol_method);
2690 Diag(OldAA->getLocation(), diag::warn_mismatched_availability);
2691 Diag(CI.
getLoc(), diag::note_previous_attribute);
2694 Attrs.erase(Attrs.begin() + i);
2699 VersionTuple MergedIntroduced2 = MergedIntroduced;
2700 VersionTuple MergedDeprecated2 = MergedDeprecated;
2701 VersionTuple MergedObsoleted2 = MergedObsoleted;
2703 if (MergedIntroduced2.empty())
2704 MergedIntroduced2 = OldIntroduced;
2705 if (MergedDeprecated2.empty())
2706 MergedDeprecated2 = OldDeprecated;
2707 if (MergedObsoleted2.empty())
2708 MergedObsoleted2 = OldObsoleted;
2710 if (checkAvailabilityAttr(*
this, OldAA->getRange(), Platform,
2711 MergedIntroduced2, MergedDeprecated2,
2712 MergedObsoleted2)) {
2713 Attrs.erase(Attrs.begin() + i);
2718 MergedIntroduced = MergedIntroduced2;
2719 MergedDeprecated = MergedDeprecated2;
2720 MergedObsoleted = MergedObsoleted2;
2726 MergedIntroduced == Introduced &&
2728 MergedObsoleted == Obsoleted)
2733 if (!checkAvailabilityAttr(*
this, CI.
getRange(), Platform, MergedIntroduced,
2734 MergedDeprecated, MergedObsoleted) &&
2736 auto *Avail = ::new (Context) AvailabilityAttr(
2737 Context, CI, Platform, Introduced,
Deprecated, Obsoleted, IsUnavailable,
2738 Message, IsStrict, Replacement,
Priority, Environment);
2739 Avail->setImplicit(Implicit);
2746 if (isa<UsingDecl, UnresolvedUsingTypenameDecl, UnresolvedUsingValueDecl>(
2758 if (AvailabilityAttr::getPrettyPlatformName(II->
getName()).empty())
2759 S.
Diag(Platform->
Loc, diag::warn_availability_unknown_platform)
2762 auto *ND = dyn_cast<NamedDecl>(D);
2772 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getMessageExpr()))
2773 Str = SE->getString();
2774 StringRef Replacement;
2775 if (
const auto *SE =
2777 Replacement = SE->getString();
2779 if (II->
isStr(
"swift")) {
2783 diag::warn_availability_swift_unavailable_deprecated_only);
2788 if (II->
isStr(
"fuchsia")) {
2789 std::optional<unsigned>
Min,
Sub;
2790 if ((Min = Introduced.
Version.getMinor()) ||
2791 (Sub = Introduced.
Version.getSubminor())) {
2792 S.
Diag(AL.
getLoc(), diag::warn_availability_fuchsia_unavailable_minor);
2807 if (EnvironmentLoc) {
2809 IIEnvironment = EnvironmentLoc->
Ident;
2810 if (AvailabilityAttr::getEnvironmentType(
2812 llvm::Triple::EnvironmentType::UnknownEnvironment)
2813 S.
Diag(EnvironmentLoc->
Loc, diag::warn_availability_unknown_environment)
2814 << EnvironmentLoc->
Ident;
2816 S.
Diag(EnvironmentLoc->
Loc, diag::err_availability_unexpected_parameter)
2817 <<
"environment" << 1;
2823 Obsoleted.
Version, IsUnavailable, Str, IsStrict, Replacement,
2834 else if (II->
getName() ==
"ios_app_extension")
2839 const auto *IOSToWatchOSMapping =
2844 auto adjustWatchOSVersion =
2845 [IOSToWatchOSMapping](VersionTuple Version) -> VersionTuple {
2846 if (Version.empty())
2848 auto MinimumWatchOSVersion = VersionTuple(2, 0);
2850 if (IOSToWatchOSMapping) {
2851 if (
auto MappedVersion = IOSToWatchOSMapping->map(
2852 Version, MinimumWatchOSVersion, std::nullopt)) {
2853 return *MappedVersion;
2857 auto Major = Version.getMajor();
2858 auto NewMajor = Major >= 9 ? Major - 7 : 0;
2859 if (NewMajor >= 2) {
2860 if (Version.getMinor()) {
2861 if (Version.getSubminor())
2862 return VersionTuple(NewMajor, *Version.getMinor(),
2863 *Version.getSubminor());
2865 return VersionTuple(NewMajor, *Version.getMinor());
2867 return VersionTuple(NewMajor);
2870 return MinimumWatchOSVersion;
2873 auto NewIntroduced = adjustWatchOSVersion(Introduced.
Version);
2874 auto NewDeprecated = adjustWatchOSVersion(
Deprecated.Version);
2875 auto NewObsoleted = adjustWatchOSVersion(Obsoleted.
Version);
2878 ND, AL, NewII,
true , NewIntroduced, NewDeprecated,
2879 NewObsoleted, IsUnavailable, Str, IsStrict, Replacement,
2891 else if (II->
getName() ==
"ios_app_extension")
2896 const auto *IOSToTvOSMapping =
2901 auto AdjustTvOSVersion =
2902 [IOSToTvOSMapping](VersionTuple Version) -> VersionTuple {
2903 if (Version.empty())
2906 if (IOSToTvOSMapping) {
2907 if (
auto MappedVersion = IOSToTvOSMapping->map(
2908 Version, VersionTuple(0, 0), std::nullopt)) {
2909 return *MappedVersion;
2915 auto NewIntroduced = AdjustTvOSVersion(Introduced.
Version);
2916 auto NewDeprecated = AdjustTvOSVersion(
Deprecated.Version);
2917 auto NewObsoleted = AdjustTvOSVersion(Obsoleted.
Version);
2920 ND, AL, NewII,
true , NewIntroduced, NewDeprecated,
2921 NewObsoleted, IsUnavailable, Str, IsStrict, Replacement,
2928 llvm::Triple::IOS &&
2930 auto GetSDKInfo = [&]() {
2939 else if (II->
getName() ==
"ios_app_extension")
2942 auto MinMacCatalystVersion = [](
const VersionTuple &
V) {
2945 if (
V.getMajor() < 13 ||
2946 (
V.getMajor() == 13 &&
V.getMinor() && *
V.getMinor() < 1))
2947 return VersionTuple(13, 1);
2951 ND, AL, NewII,
true ,
2952 MinMacCatalystVersion(Introduced.
Version),
2954 MinMacCatalystVersion(Obsoleted.
Version), IsUnavailable, Str,
2959 }
else if (II->
getName() ==
"macos" && GetSDKInfo() &&
2961 !Obsoleted.
Version.empty())) {
2962 if (
const auto *MacOStoMacCatalystMapping =
2963 GetSDKInfo()->getVersionMapping(
2970 auto RemapMacOSVersion =
2971 [&](
const VersionTuple &
V) -> std::optional<VersionTuple> {
2973 return std::nullopt;
2975 if (
V.getMajor() == 100000)
2976 return VersionTuple(100000);
2978 return MacOStoMacCatalystMapping->map(
V, VersionTuple(13, 1),
2981 std::optional<VersionTuple> NewIntroduced =
2982 RemapMacOSVersion(Introduced.
Version),
2986 RemapMacOSVersion(Obsoleted.
Version);
2987 if (NewIntroduced || NewDeprecated || NewObsoleted) {
2988 auto VersionOrEmptyVersion =
2989 [](
const std::optional<VersionTuple> &
V) -> VersionTuple {
2990 return V ? *
V : VersionTuple();
2993 ND, AL, NewII,
true ,
2994 VersionOrEmptyVersion(NewIntroduced),
2995 VersionOrEmptyVersion(NewDeprecated),
2996 VersionOrEmptyVersion(NewObsoleted),
false, Str,
3009 static void handleExternalSourceSymbolAttr(
Sema &S,
Decl *D,
3015 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(0)))
3017 StringRef DefinedIn;
3018 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(1)))
3019 DefinedIn = SE->getString();
3020 bool IsGeneratedDeclaration = AL.
getArgAsIdent(2) !=
nullptr;
3022 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(3)))
3023 USR = SE->getString();
3031 typename T::VisibilityType value) {
3034 typename T::VisibilityType existingValue = existingAttr->
getVisibility();
3035 if (existingValue == value)
3037 S.
Diag(existingAttr->getLocation(), diag::err_mismatched_visibility);
3038 S.
Diag(CI.
getLoc(), diag::note_previous_attribute);
3041 return ::new (S.
Context)
T(S.Context, CI, value);
3044 VisibilityAttr *
Sema::mergeVisibilityAttr(
Decl *D,
3046 VisibilityAttr::VisibilityType Vis) {
3047 return ::mergeVisibilityAttr<VisibilityAttr>(*
this, D, CI, Vis);
3050 TypeVisibilityAttr *
3052 TypeVisibilityAttr::VisibilityType Vis) {
3053 return ::mergeVisibilityAttr<TypeVisibilityAttr>(*
this, D, CI, Vis);
3057 bool isTypeVisibility) {
3059 if (isa<TypedefNameDecl>(D)) {
3065 if (isTypeVisibility && !(isa<TagDecl>(D) || isa<ObjCInterfaceDecl>(D) ||
3066 isa<NamespaceDecl>(D))) {
3078 VisibilityAttr::VisibilityType
type;
3079 if (!VisibilityAttr::ConvertStrToVisibilityType(TypeStr,
type)) {
3080 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported) << AL
3087 if (
type == VisibilityAttr::Protected &&
3089 S.
Diag(AL.
getLoc(), diag::warn_attribute_protected_visibility);
3090 type = VisibilityAttr::Default;
3094 if (isTypeVisibility) {
3096 D, AL, (TypeVisibilityAttr::VisibilityType)
type);
3107 S.
Diag(AL.
getLoc(), diag::err_objc_direct_on_protocol) <<
false;
3112 handleSimpleAttribute<ObjCDirectAttr>(S, D, AL);
3114 S.
Diag(AL.
getLoc(), diag::warn_objc_direct_ignored) << AL;
3118 static void handleObjCDirectMembersAttr(
Sema &S,
Decl *D,
3121 handleSimpleAttribute<ObjCDirectMembersAttr>(S, D, AL);
3123 S.
Diag(AL.
getLoc(), diag::warn_objc_direct_ignored) << AL;
3128 const auto *M = cast<ObjCMethodDecl>(D);
3130 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3136 ObjCMethodFamilyAttr::FamilyKind F;
3137 if (!ObjCMethodFamilyAttr::ConvertStrToFamilyKind(IL->
Ident->
getName(), F)) {
3138 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported) << AL << IL->
Ident;
3143 !M->getReturnType()->isObjCObjectPointerType()) {
3144 S.
Diag(M->getLocation(), diag::err_init_method_bad_return_type)
3145 << M->getReturnType();
3154 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
3157 S.
Diag(TD->getLocation(), diag::err_nsobject_attribute);
3161 else if (
const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
3164 S.
Diag(PD->getLocation(), diag::err_nsobject_attribute);
3181 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
3184 S.
Diag(TD->getLocation(), diag::warn_ptr_independentclass_attribute);
3196 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3202 BlocksAttr::BlockType
type;
3203 if (!BlocksAttr::ConvertStrToBlockType(II->
getName(),
type)) {
3204 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
3212 unsigned sentinel = (
unsigned)SentinelAttr::DefaultSentinel;
3217 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3222 if (Idx->isSigned() && Idx->isNegative()) {
3223 S.
Diag(AL.
getLoc(), diag::err_attribute_sentinel_less_than_zero)
3228 sentinel = Idx->getZExtValue();
3231 unsigned nullPos = (
unsigned)SentinelAttr::DefaultNullPos;
3236 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3240 nullPos = Idx->getZExtValue();
3242 if ((Idx->isSigned() && Idx->isNegative()) || nullPos > 1) {
3245 S.
Diag(AL.
getLoc(), diag::err_attribute_sentinel_not_zero_or_one)
3251 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
3253 if (isa<FunctionNoProtoType>(FT)) {
3254 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_named_arguments);
3258 if (!cast<FunctionProtoType>(FT)->isVariadic()) {
3259 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
3262 }
else if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
3264 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
3267 }
else if (
const auto *BD = dyn_cast<BlockDecl>(D)) {
3268 if (!BD->isVariadic()) {
3269 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 1;
3272 }
else if (
const auto *
V = dyn_cast<VarDecl>(D)) {
3280 if (!cast<FunctionProtoType>(FT)->isVariadic()) {
3282 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << m;
3286 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
3292 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
3303 !isa<CXXConstructorDecl>(D)) {
3304 S.
Diag(AL.
getLoc(), diag::warn_attribute_void_function_method) << AL << 0;
3307 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
3309 S.
Diag(AL.
getLoc(), diag::warn_attribute_void_function_method) << AL << 1;
3317 if (isa<VarDecl>(D))
3318 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type_str)
3320 <<
"functions, classes, or enumerations";
3329 if (LO.CPlusPlus && !LO.CPlusPlus20)
3330 S.
Diag(AL.
getLoc(), diag::ext_cxx20_attr) << AL;
3338 }
else if (LO.CPlusPlus && !LO.CPlusPlus17)
3339 S.
Diag(AL.
getLoc(), diag::ext_cxx17_attr) << AL;
3344 isa<TypedefNameDecl>(D)) {
3345 S.
Diag(AL.
getLoc(), diag::warn_unused_result_typedef_unsupported_spelling)
3358 S.
Diag(AL.
getLoc(), diag::warn_attribute_invalid_on_definition)
3360 else if (isa<ObjCPropertyDecl>(D) || isa<ObjCMethodDecl>(D) ||
3362 (isa<ObjCInterfaceDecl>(D) || isa<EnumDecl>(D)))) {
3365 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
3375 template <
typename WorkGroupAttr>
3381 for (
unsigned i = 0; i < 3; ++i) {
3386 if (WGSize[i] == 0) {
3387 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_is_zero)
3393 WorkGroupAttr *Existing = D->
getAttr<WorkGroupAttr>();
3394 if (Existing && !(Existing->getXDim() == WGSize[0] &&
3395 Existing->getYDim() == WGSize[1] &&
3396 Existing->getZDim() == WGSize[2]))
3397 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3400 WorkGroupAttr(S.
Context, AL, WGSize[0], WGSize[1], WGSize[2]));
3407 static DupArgResult AreArgValuesIdentical(
const Expr *LHS,
const Expr *RHS) {
3411 return DupArgResult::Same;
3415 return DupArgResult::Different;
3419 const auto *LHSCE = dyn_cast<ConstantExpr>(LHS);
3420 const auto *RHSCE = dyn_cast<ConstantExpr>(RHS);
3421 if (!LHSCE || !RHSCE)
3425 return LHSCE->getResultAsAPSInt() == RHSCE->getResultAsAPSInt()
3426 ? DupArgResult::Same
3427 : DupArgResult::Different;
3433 const Expr *LHSZDim,
const Expr *RHSXDim,
3434 const Expr *RHSYDim,
const Expr *RHSZDim) {
3435 DupArgResult Results[] = {AreArgValuesIdentical(LHSXDim, RHSXDim),
3436 AreArgValuesIdentical(LHSYDim, RHSYDim),
3437 AreArgValuesIdentical(LHSZDim, RHSZDim)};
3438 return llvm::is_contained(Results, DupArgResult::Different);
3444 const Expr *LHSZDim,
const Expr *RHSXDim,
3445 const Expr *RHSYDim,
const Expr *RHSZDim) {
3446 DupArgResult Results[] = {AreArgValuesIdentical(LHSXDim, RHSXDim),
3447 AreArgValuesIdentical(LHSYDim, RHSYDim),
3448 AreArgValuesIdentical(LHSZDim, RHSZDim)};
3449 return llvm::all_of(Results,
3450 [](DupArgResult
V) {
return V == DupArgResult::Same; });
3457 auto CheckAndConvertArg = [&](
Expr *E) -> std::optional<Expr *> {
3461 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
3463 return std::nullopt;
3468 Diag(E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
3470 return std::nullopt;
3479 std::optional<Expr *> XDimConvert = CheckAndConvertArg(XDim);
3480 std::optional<Expr *> YDimConvert = CheckAndConvertArg(YDim);
3481 std::optional<Expr *> ZDimConvert = CheckAndConvertArg(ZDim);
3482 if (!XDimConvert || !YDimConvert || !ZDimConvert)
3484 XDim = XDimConvert.value();
3485 YDim = YDimConvert.value();
3486 ZDim = ZDimConvert.value();
3490 if (
const auto *Existing = D->
getAttr<SYCLWorkGroupSizeHintAttr>()) {
3493 if (AnyWorkGroupSizesDiffer(XDim, YDim, ZDim, Existing->getXDim(),
3494 Existing->getYDim(), Existing->getZDim())) {
3495 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << CI;
3496 Diag(Existing->getLoc(), diag::note_previous_attribute);
3502 if (AllWorkGroupSizesSame(XDim, YDim, ZDim, Existing->getXDim(),
3503 Existing->getYDim(), Existing->getZDim()))
3508 SYCLWorkGroupSizeHintAttr(Context, CI, XDim, YDim, ZDim));
3511 SYCLWorkGroupSizeHintAttr *
3513 const SYCLWorkGroupSizeHintAttr &A) {
3515 if (
const auto *DeclAttr = D->
getAttr<SYCLWorkGroupSizeHintAttr>()) {
3518 if (AnyWorkGroupSizesDiffer(DeclAttr->getXDim(), DeclAttr->getYDim(),
3519 DeclAttr->getZDim(), A.getXDim(), A.getYDim(),
3521 Diag(DeclAttr->getLoc(), diag::warn_duplicate_attribute) << &A;
3522 Diag(A.getLoc(), diag::note_previous_attribute);
3528 if (AllWorkGroupSizesSame(DeclAttr->getXDim(), DeclAttr->getYDim(),
3529 DeclAttr->getZDim(), A.getXDim(), A.getYDim(),
3533 return ::new (Context) SYCLWorkGroupSizeHintAttr(Context, A, A.getXDim(),
3534 A.getYDim(), A.getZDim());
3538 static void handleSYCLWorkGroupSizeHint(
Sema &S,
Decl *D,
3560 handleSYCLWorkGroupSizeHint(S, D, AL);
3562 handleWorkGroupSize<WorkGroupSizeHintAttr>(S, D, AL);
3576 static bool InvalidWorkGroupSizeAttrs(
Sema &S,
const Expr *MGValue,
3577 const Expr *XDim,
const Expr *YDim,
3580 const auto *MGValueExpr = dyn_cast<ConstantExpr>(MGValue);
3581 const auto *XDimExpr = dyn_cast<ConstantExpr>(XDim);
3583 if (!MGValueExpr || !XDimExpr)
3589 const auto *YDimExpr = dyn_cast_or_null<ConstantExpr>(YDim);
3590 const auto *ZDimExpr = dyn_cast_or_null<ConstantExpr>(ZDim);
3592 if ((!YDimExpr && YDim) || (!ZDimExpr && ZDim))
3598 return (MGValueExpr->getResultAsAPSInt() == 0 &&
3599 (XDimExpr->getResultAsAPSInt() != 1 ||
3600 (YDimExpr && YDimExpr->getResultAsAPSInt() != 1) ||
3601 (ZDimExpr && ZDimExpr->getResultAsAPSInt() != 1)));
3621 const Expr *RWGSXDim,
const Expr *RWGSYDim,
const Expr *RWGSZDim,
3622 const Expr *MWGSXDim,
const Expr *MWGSYDim,
const Expr *MWGSZDim) {
3624 const auto *RWGSXDimExpr = dyn_cast<ConstantExpr>(RWGSXDim);
3625 const auto *MWGSXDimExpr = dyn_cast<ConstantExpr>(MWGSXDim);
3626 const auto *MWGSYDimExpr = dyn_cast<ConstantExpr>(MWGSYDim);
3627 const auto *MWGSZDimExpr = dyn_cast<ConstantExpr>(MWGSZDim);
3629 if (!RWGSXDimExpr || !MWGSXDimExpr || !MWGSYDimExpr || !MWGSZDimExpr)
3635 const auto *RWGSYDimExpr = dyn_cast_or_null<ConstantExpr>(RWGSYDim);
3636 const auto *RWGSZDimExpr = dyn_cast_or_null<ConstantExpr>(RWGSZDim);
3638 if ((!RWGSYDimExpr && RWGSYDim) || (!RWGSZDimExpr && RWGSZDim))
3648 if (getLangOpts().SYCLIsDevice && RWGSYDim)
3649 std::swap(FirstRWGDimExpr, RWGSZDim ? ThirdRWGDimExpr : SecondRWGDimExpr);
3653 bool CheckFirstArgument =
3655 MWGSZDimExpr->getResultAsAPSInt().getZExtValue();
3657 bool CheckSecondArgument =
3659 MWGSYDimExpr->getResultAsAPSInt().getZExtValue();
3661 bool CheckThirdArgument =
3663 MWGSXDimExpr->getResultAsAPSInt().getZExtValue();
3665 return CheckFirstArgument || CheckSecondArgument || CheckThirdArgument;
3674 auto CheckAndConvertArg = [&](
Expr *E) ->
Expr * {
3678 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
3685 Diag(E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
3695 XDim = CheckAndConvertArg(XDim);
3696 YDim = CheckAndConvertArg(YDim);
3697 ZDim = CheckAndConvertArg(ZDim);
3698 if (!XDim || !YDim || !ZDim)
3708 if (
const auto *DeclAttr = D->
getAttr<SYCLReqdWorkGroupSizeAttr>()) {
3709 if (CheckMaxAllowedWorkGroupSize(DeclAttr->getXDim(), DeclAttr->getYDim(),
3710 DeclAttr->getZDim(), XDim, YDim, ZDim)) {
3711 Diag(CI.
getLoc(), diag::err_conflicting_sycl_function_attributes)
3713 Diag(DeclAttr->getLoc(), diag::note_conflicting_attribute);
3721 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelMaxGlobalWorkDimAttr>()) {
3722 if (InvalidWorkGroupSizeAttrs(*
this, DeclAttr->getValue(), XDim, YDim,
3724 Diag(CI.
getLoc(), diag::err_sycl_x_y_z_arguments_must_be_one)
3732 if (
const auto *Existing = D->
getAttr<SYCLIntelMaxWorkGroupSizeAttr>()) {
3735 if (AnyWorkGroupSizesDiffer(XDim, YDim, ZDim, Existing->getXDim(),
3736 Existing->getYDim(), Existing->getZDim())) {
3737 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << CI;
3738 Diag(Existing->getLoc(), diag::note_previous_attribute);
3744 if (AllWorkGroupSizesSame(XDim, YDim, ZDim, Existing->getXDim(),
3745 Existing->getYDim(), Existing->getZDim()))
3750 SYCLIntelMaxWorkGroupSizeAttr(Context, CI, XDim, YDim, ZDim));
3754 Decl *D,
const SYCLIntelMaxWorkGroupSizeAttr &A) {
3756 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelMaxWorkGroupSizeAttr>()) {
3759 if (AnyWorkGroupSizesDiffer(DeclAttr->getXDim(), DeclAttr->getYDim(),
3760 DeclAttr->getZDim(), A.getXDim(), A.getYDim(),
3762 Diag(DeclAttr->getLoc(), diag::warn_duplicate_attribute) << &A;
3763 Diag(A.getLoc(), diag::note_previous_attribute);
3769 if (AllWorkGroupSizesSame(DeclAttr->getXDim(), DeclAttr->getYDim(),
3770 DeclAttr->getZDim(), A.getXDim(), A.getYDim(),
3782 if (
const auto *DeclAttr = D->
getAttr<SYCLReqdWorkGroupSizeAttr>()) {
3783 if (CheckMaxAllowedWorkGroupSize(DeclAttr->getXDim(), DeclAttr->getYDim(),
3784 DeclAttr->getZDim(), A.getXDim(),
3785 A.getYDim(), A.getZDim())) {
3786 Diag(DeclAttr->getLoc(), diag::err_conflicting_sycl_function_attributes)
3788 Diag(A.getLoc(), diag::note_conflicting_attribute);
3796 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelMaxGlobalWorkDimAttr>()) {
3797 if (InvalidWorkGroupSizeAttrs(*
this, DeclAttr->getValue(), A.getXDim(),
3798 A.getYDim(), A.getZDim())) {
3799 Diag(A.getLoc(), diag::err_sycl_x_y_z_arguments_must_be_one)
3805 return ::new (Context) SYCLIntelMaxWorkGroupSizeAttr(
3806 Context, A, A.getXDim(), A.getYDim(), A.getZDim());
3810 static void handleSYCLIntelMaxWorkGroupSize(
Sema &S,
Decl *D,
3817 static void handleSYCLIntelMinWorkGroupsPerComputeUnit(
Sema &S,
Decl *D,
3824 handleSYCLIntelMaxWorkGroupsPerMultiprocessor(
Sema &S,
Decl *D,
3843 static bool CheckWorkGroupSize(
Sema &S,
const Expr *NSWIValue,
3844 const Expr *RWGSXDim,
const Expr *RWGSYDim,
3845 const Expr *RWGSZDim) {
3847 const auto *NSWIValueExpr = dyn_cast<ConstantExpr>(NSWIValue);
3848 const auto *RWGSXDimExpr = dyn_cast<ConstantExpr>(RWGSXDim);
3850 if (!NSWIValueExpr || !RWGSXDimExpr)
3856 const auto *RWGSYDimExpr = dyn_cast_or_null<ConstantExpr>(RWGSYDim);
3857 const auto *RWGSZDimExpr = dyn_cast_or_null<ConstantExpr>(RWGSZDim);
3859 if ((!RWGSYDimExpr && RWGSYDim) || (!RWGSZDimExpr && RWGSZDim))
3864 RWGSZDim ? RWGSZDimExpr : (RWGSYDim ? RWGSYDimExpr : RWGSXDimExpr);
3870 return WorkGroupSize % NSWIValueExpr->getResultAsAPSInt().getZExtValue() != 0;
3877 auto CheckAndConvertArg = [&](
Expr *E) -> std::optional<Expr *> {
3881 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
3883 return std::nullopt;
3888 Diag(E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
3890 return std::nullopt;
3898 std::optional<Expr *> XDimConvert = CheckAndConvertArg(XDim);
3899 std::optional<Expr *> YDimConvert = CheckAndConvertArg(YDim);
3900 std::optional<Expr *> ZDimConvert = CheckAndConvertArg(ZDim);
3901 if (!XDimConvert || !YDimConvert || !ZDimConvert)
3903 XDim = XDimConvert.value();
3904 YDim = YDimConvert.value();
3905 ZDim = ZDimConvert.value();
3910 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelMaxGlobalWorkDimAttr>()) {
3911 if (InvalidWorkGroupSizeAttrs(*
this, DeclAttr->getValue(), XDim, YDim,
3913 Diag(CI.
getLoc(), diag::err_sycl_x_y_z_arguments_must_be_one)
3925 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelMaxWorkGroupSizeAttr>()) {
3926 if (CheckMaxAllowedWorkGroupSize(XDim, YDim, ZDim, DeclAttr->getXDim(),
3927 DeclAttr->getYDim(),
3928 DeclAttr->getZDim())) {
3929 Diag(CI.
getLoc(), diag::err_conflicting_sycl_function_attributes)
3931 Diag(DeclAttr->getLoc(), diag::note_conflicting_attribute);
3940 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelNumSimdWorkItemsAttr>()) {
3941 if (CheckWorkGroupSize(*
this, DeclAttr->getValue(), XDim, YDim, ZDim)) {
3942 Diag(DeclAttr->getLoc(), diag::err_sycl_num_kernel_wrong_reqd_wg_size)
3944 Diag(CI.getLoc(), diag::note_conflicting_attribute);
3951 if (
const auto *Existing = D->
getAttr<SYCLReqdWorkGroupSizeAttr>()) {
3954 if (AnyWorkGroupSizesDiffer(XDim, YDim, ZDim, Existing->getXDim(),
3955 Existing->getYDim(), Existing->getZDim())) {
3956 Diag(CI.
getLoc(), diag::err_duplicate_attribute) << CI;
3957 Diag(Existing->getLoc(), diag::note_previous_attribute);
3964 if (AllWorkGroupSizesSame(XDim, YDim, ZDim, Existing->getXDim(),
3965 Existing->getYDim(), Existing->getZDim()))
3970 SYCLReqdWorkGroupSizeAttr(Context, CI, XDim, YDim, ZDim));
3973 SYCLReqdWorkGroupSizeAttr *
3975 const SYCLReqdWorkGroupSizeAttr &A) {
3979 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelMaxGlobalWorkDimAttr>()) {
3980 if (InvalidWorkGroupSizeAttrs(*
this, DeclAttr->getValue(), A.getXDim(),
3981 A.getYDim(), A.getZDim())) {
3982 Diag(A.getLoc(), diag::err_sycl_x_y_z_arguments_must_be_one)
3995 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelMaxWorkGroupSizeAttr>()) {
3996 if (CheckMaxAllowedWorkGroupSize(A.getXDim(), A.getYDim(), A.getZDim(),
3997 DeclAttr->getXDim(), DeclAttr->getYDim(),
3998 DeclAttr->getZDim())) {
3999 Diag(DeclAttr->getLoc(), diag::err_conflicting_sycl_function_attributes)
4001 Diag(A.getLoc(), diag::note_conflicting_attribute);
4010 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelNumSimdWorkItemsAttr>()) {
4011 if (CheckWorkGroupSize(*
this, DeclAttr->getValue(), A.getXDim(),
4012 A.getYDim(), A.getZDim())) {
4013 Diag(DeclAttr->getLoc(), diag::err_sycl_num_kernel_wrong_reqd_wg_size)
4015 Diag(A.getLoc(), diag::note_conflicting_attribute);
4021 if (
const auto *DeclAttr = D->
getAttr<SYCLReqdWorkGroupSizeAttr>()) {
4024 if (AnyWorkGroupSizesDiffer(DeclAttr->getXDim(), DeclAttr->getYDim(),
4025 DeclAttr->getZDim(), A.getXDim(), A.getYDim(),
4027 Diag(DeclAttr->getLoc(), diag::err_duplicate_attribute) << &A;
4028 Diag(A.getLoc(), diag::note_previous_attribute);
4035 if (AllWorkGroupSizesSame(DeclAttr->getXDim(), DeclAttr->getYDim(),
4036 DeclAttr->getZDim(), A.getXDim(), A.getYDim(),
4041 return ::new (Context) SYCLReqdWorkGroupSizeAttr(Context, A, A.getXDim(),
4042 A.getYDim(), A.getZDim());
4050 if ((AL.
getKind() == ParsedAttr::AT_ReqdWorkGroupSize &&
4052 SYCLReqdWorkGroupSizeAttr::CXX11_cl_reqd_work_group_size) ||
4069 handleSYCLReqdWorkGroupSize(S, D, AL);
4071 handleWorkGroupSize<ReqdWorkGroupSizeAttr>(S, D, AL);
4081 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
4088 Diag(E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
4093 if (TI.getTriple().isNVPTX() && ArgVal != 32)
4095 << ArgVal.getSExtValue() << TI.getTriple().getArchName() << 32;
4096 if (TI.getTriple().isAMDGPU()) {
4097 const auto HasWaveFrontSize64 =
4098 TI.getTargetOpts().FeatureMap[
"wavefrontsize64"];
4099 const auto HasWaveFrontSize32 =
4100 TI.getTargetOpts().FeatureMap[
"wavefrontsize32"];
4105 const auto SupportedWaveFrontSize =
4106 HasWaveFrontSize64 && !HasWaveFrontSize32 ? 64 : 32;
4107 if (ArgVal != SupportedWaveFrontSize)
4109 << ArgVal.getSExtValue() << TI.getTriple().getArchName()
4110 << SupportedWaveFrontSize;
4115 if (
const auto *DeclAttr = D->
getAttr<IntelReqdSubGroupSizeAttr>()) {
4119 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
4120 if (ArgVal != DeclExpr->getResultAsAPSInt()) {
4121 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << CI;
4122 Diag(DeclAttr->getLoc(), diag::note_previous_attribute);
4130 D->
addAttr(::
new (Context) IntelReqdSubGroupSizeAttr(Context, CI, E));
4133 IntelReqdSubGroupSizeAttr *
4135 const IntelReqdSubGroupSizeAttr &A) {
4138 if (
const auto *DeclAttr = D->
getAttr<IntelReqdSubGroupSizeAttr>()) {
4139 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
4140 if (
const auto *MergeExpr = dyn_cast<ConstantExpr>(A.getValue())) {
4141 if (DeclExpr->getResultAsAPSInt() != MergeExpr->getResultAsAPSInt()) {
4142 Diag(DeclAttr->getLoc(), diag::warn_duplicate_attribute) << &A;
4143 Diag(A.getLoc(), diag::note_previous_attribute);
4151 return ::new (Context) IntelReqdSubGroupSizeAttr(Context, A, A.getValue());
4154 static void handleIntelReqdSubGroupSize(
Sema &S,
Decl *D,
4162 IntelNamedSubGroupSizeAttr *
4164 const IntelNamedSubGroupSizeAttr &A) {
4167 if (
const auto *DeclAttr = D->
getAttr<IntelNamedSubGroupSizeAttr>()) {
4168 if (DeclAttr->getType() != A.getType()) {
4169 Diag(DeclAttr->getLoc(), diag::warn_duplicate_attribute) << &A;
4170 Diag(A.getLoc(), diag::note_previous_attribute);
4175 return IntelNamedSubGroupSizeAttr::Create(Context, A.getType(), A);
4178 static void handleIntelNamedSubGroupSize(
Sema &S,
Decl *D,
4190 IntelNamedSubGroupSizeAttr::SubGroupSizeType SizeType;
4191 if (!IntelNamedSubGroupSizeAttr::ConvertStrToSubGroupSizeType(SizeStr,
4193 S.
Diag(
Loc, diag::warn_attribute_type_not_supported) << AL << SizeStr;
4196 D->
addAttr(IntelNamedSubGroupSizeAttr::Create(S.
Context, SizeType, AL));
4207 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
4214 Diag(E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
4221 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelNumSimdWorkItemsAttr>()) {
4225 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
4226 if (ArgVal != DeclExpr->getResultAsAPSInt()) {
4227 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << CI;
4228 Diag(DeclAttr->getLoc(), diag::note_previous_attribute);
4239 if (
const auto *DeclAttr = D->
getAttr<SYCLReqdWorkGroupSizeAttr>()) {
4240 if (CheckWorkGroupSize(*
this, E, DeclAttr->getXDim(), DeclAttr->getYDim(),
4241 DeclAttr->getZDim())) {
4242 Diag(CI.
getLoc(), diag::err_sycl_num_kernel_wrong_reqd_wg_size)
4244 Diag(DeclAttr->getLoc(), diag::note_conflicting_attribute);
4250 D->
addAttr(::
new (Context) SYCLIntelNumSimdWorkItemsAttr(Context, CI, E));
4254 Decl *D,
const SYCLIntelNumSimdWorkItemsAttr &A) {
4257 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelNumSimdWorkItemsAttr>()) {
4258 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
4259 if (
const auto *MergeExpr = dyn_cast<ConstantExpr>(A.getValue())) {
4260 if (DeclExpr->getResultAsAPSInt() != MergeExpr->getResultAsAPSInt()) {
4261 Diag(DeclAttr->getLoc(), diag::warn_duplicate_attribute) << &A;
4262 Diag(A.getLoc(), diag::note_previous_attribute);
4274 if (
const auto *DeclAttr = D->
getAttr<SYCLReqdWorkGroupSizeAttr>()) {
4275 if (CheckWorkGroupSize(*
this, A.getValue(), DeclAttr->getXDim(),
4276 DeclAttr->getYDim(), DeclAttr->getZDim())) {
4277 Diag(A.getLoc(), diag::err_sycl_num_kernel_wrong_reqd_wg_size)
4279 Diag(DeclAttr->getLoc(), diag::note_conflicting_attribute);
4284 return ::new (Context)
4285 SYCLIntelNumSimdWorkItemsAttr(Context, A, A.getValue());
4288 static void handleSYCLIntelNumSimdWorkItemsAttr(
Sema &S,
Decl *D,
4295 static void handleSYCLIntelUseStallEnableClustersAttr(
Sema &S,
Decl *D,
4298 SYCLIntelUseStallEnableClustersAttr(S.
Context, A));
4310 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
4316 Diag(E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
4322 if (
const auto *DeclAttr =
4323 D->
getAttr<SYCLIntelInitiationIntervalAttr>()) {
4327 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getNExpr())) {
4328 if (ArgVal != DeclExpr->getResultAsAPSInt()) {
4329 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << CI;
4330 Diag(DeclAttr->getLoc(), diag::note_previous_attribute);
4339 SYCLIntelInitiationIntervalAttr(Context, CI, E));
4342 SYCLIntelInitiationIntervalAttr *
4344 Decl *D,
const SYCLIntelInitiationIntervalAttr &A) {
4347 if (
const auto *DeclAttr =
4348 D->
getAttr<SYCLIntelInitiationIntervalAttr>()) {
4349 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getNExpr())) {
4350 if (
const auto *MergeExpr = dyn_cast<ConstantExpr>(A.getNExpr())) {
4351 if (DeclExpr->getResultAsAPSInt() != MergeExpr->getResultAsAPSInt()) {
4352 Diag(DeclAttr->getLoc(), diag::warn_duplicate_attribute) << &A;
4353 Diag(A.getLoc(), diag::note_previous_attribute);
4361 return ::new (Context)
4362 SYCLIntelInitiationIntervalAttr(Context, A, A.getNExpr());
4381 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
4388 Diag(E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
4394 if (
const auto *DeclAttr =
4395 D->
getAttr<SYCLIntelSchedulerTargetFmaxMhzAttr>()) {
4399 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
4400 if (ArgVal != DeclExpr->getResultAsAPSInt()) {
4401 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << CI;
4402 Diag(DeclAttr->getLoc(), diag::note_previous_attribute);
4411 SYCLIntelSchedulerTargetFmaxMhzAttr(Context, CI, E));
4414 SYCLIntelSchedulerTargetFmaxMhzAttr *
4416 Decl *D,
const SYCLIntelSchedulerTargetFmaxMhzAttr &A) {
4419 if (
const auto *DeclAttr =
4420 D->
getAttr<SYCLIntelSchedulerTargetFmaxMhzAttr>()) {
4421 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
4422 if (
const auto *MergeExpr = dyn_cast<ConstantExpr>(A.getValue())) {
4423 if (DeclExpr->getResultAsAPSInt() != MergeExpr->getResultAsAPSInt()) {
4424 Diag(DeclAttr->getLoc(), diag::warn_duplicate_attribute) << &A;
4425 Diag(A.getLoc(), diag::note_previous_attribute);
4433 return ::new (Context)
4434 SYCLIntelSchedulerTargetFmaxMhzAttr(Context, A, A.getValue());
4437 static void handleSYCLIntelSchedulerTargetFmaxMhzAttr(
Sema &S,
Decl *D,
4448 enum class OneArgResult {
Unknown, EqualToOne, NotEqualToOne };
4449 static OneArgResult AreAllArgsOne(
const Expr *Args[],
size_t Count) {
4451 for (
size_t Idx = 0; Idx < Count; ++Idx) {
4452 const Expr *Arg = Args[Idx];
4455 return OneArgResult::EqualToOne;
4456 const auto *CE = dyn_cast<ConstantExpr>(Args[Idx]);
4459 if (CE->getResultAsAPSInt() != 1)
4460 return OneArgResult::NotEqualToOne;
4462 return OneArgResult::EqualToOne;
4468 template <
typename AttrTy>
4469 static bool checkWorkGroupSizeAttrExpr(
Sema &S,
Decl *D,
4471 if (
const auto *A = D->
getAttr<AttrTy>()) {
4472 const Expr *Args[3] = {A->getXDim(), A->getYDim(), A->getZDim()};
4473 if (OneArgResult::NotEqualToOne == AreAllArgsOne(Args, 3)) {
4474 S.
Diag(A->getLocation(), diag::err_sycl_x_y_z_arguments_must_be_one)
4490 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
4496 if (ArgVal < 0 || ArgVal > 3) {
4504 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelMaxGlobalWorkDimAttr>()) {
4508 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
4509 if (ArgVal != DeclExpr->getResultAsAPSInt()) {
4510 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << CI;
4511 Diag(DeclAttr->getLoc(), diag::note_previous_attribute);
4523 if (checkWorkGroupSizeAttrExpr<SYCLIntelMaxWorkGroupSizeAttr>(*
this, D,
4525 checkWorkGroupSizeAttrExpr<SYCLReqdWorkGroupSizeAttr>(*
this, D, CI))
4530 D->
addAttr(::
new (Context) SYCLIntelMaxGlobalWorkDimAttr(Context, CI, E));
4537 if (!I.isIntN(32)) {
4543 if (I.isSigned() && I.isNegative()) {
4544 S.
Diag(E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
4565 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
4568 if (!check32BitInt(E, *
this, ArgVal, CI))
4574 if (
const auto *DeclAttr =
4575 D->
getAttr<SYCLIntelMinWorkGroupsPerComputeUnitAttr>()) {
4579 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
4580 if (ArgVal != DeclExpr->getResultAsAPSInt()) {
4581 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << CI;
4582 Diag(DeclAttr->getLoc(), diag::note_previous_attribute);
4591 SYCLIntelMinWorkGroupsPerComputeUnitAttr(Context, CI, E));
4597 llvm_unreachable(
"getCudaArch is only valid for NVPTX triple");
4625 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
4628 if (!check32BitInt(E, *
this, ArgVal, CI))
4634 if (
const auto *DeclAttr =
4635 D->
getAttr<SYCLIntelMaxWorkGroupsPerMultiprocessorAttr>()) {
4639 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
4640 if (ArgVal != DeclExpr->getResultAsAPSInt()) {
4641 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << CI;
4642 Diag(DeclAttr->getLoc(), diag::note_previous_attribute);
4651 SYCLIntelMaxWorkGroupsPerMultiprocessorAttr(Context, CI, E));
4655 Decl *D,
const SYCLIntelMaxGlobalWorkDimAttr &A) {
4658 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelMaxGlobalWorkDimAttr>()) {
4659 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
4660 if (
const auto *MergeExpr = dyn_cast<ConstantExpr>(A.getValue())) {
4661 if (DeclExpr->getResultAsAPSInt() != MergeExpr->getResultAsAPSInt()) {
4662 Diag(DeclAttr->getLoc(), diag::warn_duplicate_attribute) << &A;
4663 Diag(A.getLoc(), diag::note_previous_attribute);
4675 const auto *MergeExpr = dyn_cast<ConstantExpr>(A.getValue());
4676 if (MergeExpr && MergeExpr->getResultAsAPSInt() == 0) {
4677 if (checkWorkGroupSizeAttrExpr<SYCLIntelMaxWorkGroupSizeAttr>(*
this, D,
4679 checkWorkGroupSizeAttrExpr<SYCLReqdWorkGroupSizeAttr>(*
this, D, A))
4683 return ::new (Context)
4684 SYCLIntelMaxGlobalWorkDimAttr(Context, A, A.getValue());
4687 static void handleSYCLIntelMaxGlobalWorkDimAttr(
Sema &S,
Decl *D,
4693 SYCLIntelMinWorkGroupsPerComputeUnitAttr *
4695 Decl *D,
const SYCLIntelMinWorkGroupsPerComputeUnitAttr &A) {
4698 if (
const auto *DeclAttr =
4699 D->
getAttr<SYCLIntelMinWorkGroupsPerComputeUnitAttr>()) {
4700 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
4701 if (
const auto *MergeExpr = dyn_cast<ConstantExpr>(A.getValue())) {
4702 if (DeclExpr->getResultAsAPSInt() != MergeExpr->getResultAsAPSInt()) {
4703 Diag(DeclAttr->getLoc(), diag::warn_duplicate_attribute) << &A;
4704 Diag(A.getLoc(), diag::note_previous_attribute);
4712 return ::new (Context)
4713 SYCLIntelMinWorkGroupsPerComputeUnitAttr(Context, A, A.getValue());
4716 SYCLIntelMaxWorkGroupsPerMultiprocessorAttr *
4718 Decl *D,
const SYCLIntelMaxWorkGroupsPerMultiprocessorAttr &A) {
4721 if (
const auto *DeclAttr =
4722 D->
getAttr<SYCLIntelMaxWorkGroupsPerMultiprocessorAttr>()) {
4723 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
4724 if (
const auto *MergeExpr = dyn_cast<ConstantExpr>(A.getValue())) {
4725 if (DeclExpr->getResultAsAPSInt() != MergeExpr->getResultAsAPSInt()) {
4726 Diag(DeclAttr->getLoc(), diag::warn_duplicate_attribute) << &A;
4727 Diag(A.getLoc(), diag::note_previous_attribute);
4735 return ::new (Context)
4736 SYCLIntelMaxWorkGroupsPerMultiprocessorAttr(Context, A, A.getValue());
4747 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
4754 Diag(E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
4760 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelLoopFuseAttr>()) {
4765 if (DeclAttr->getAttributeSpellingListIndex() !=
4767 Diag(CI.
getLoc(), diag::err_attributes_are_not_compatible)
4769 Diag(DeclAttr->getLocation(), diag::note_conflicting_attribute);
4775 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
4776 if (ArgVal != DeclExpr->getResultAsAPSInt()) {
4777 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << CI;
4778 Diag(DeclAttr->getLoc(), diag::note_previous_attribute);
4786 D->
addAttr(::
new (Context) SYCLIntelLoopFuseAttr(Context, CI, E));
4789 SYCLIntelLoopFuseAttr *
4793 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelLoopFuseAttr>()) {
4798 if (DeclAttr->getAttributeSpellingListIndex() !=
4799 A.getAttributeSpellingListIndex()) {
4800 Diag(A.getLoc(), diag::err_attributes_are_not_compatible)
4801 << &A << DeclAttr << A.isRegularKeywordAttribute();
4802 Diag(DeclAttr->getLoc(), diag::note_conflicting_attribute);
4805 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
4806 if (
const auto *MergeExpr = dyn_cast<ConstantExpr>(A.getValue())) {
4807 if (DeclExpr->getResultAsAPSInt() != MergeExpr->getResultAsAPSInt()) {
4808 Diag(DeclAttr->getLoc(), diag::warn_duplicate_attribute) << &A;
4809 Diag(A.getLoc(), diag::note_previous_attribute);
4817 return ::new (Context) SYCLIntelLoopFuseAttr(Context, A, A.getValue());
4834 S.
Diag(AL.
getLoc(), diag::warn_attribute_deprecated_ignored) << AL;
4842 S.
Diag(AL.
getLoc(), diag::ext_sycl_2020_attr_spelling) << AL;
4845 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
4851 assert(ParmTSI &&
"no type source info for attribute argument");
4856 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_argument) << 2 << AL;
4860 if (VecTypeHintAttr *A = D->
getAttr<VecTypeHintAttr>()) {
4862 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
4874 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
4879 if (SectionAttr *ExistingAttr = D->
getAttr<SectionAttr>()) {
4880 if (ExistingAttr->getName() == Name)
4882 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section)
4884 Diag(CI.
getLoc(), diag::note_previous_attribute);
4887 return ::new (Context) SectionAttr(Context, CI, Name);
4901 return llvm::Error::success();
4904 StringRef Segment, Section;
4905 unsigned TAA, StubSize;
4907 return llvm::MCSectionMachO::ParseSectionSpecifier(SecName, Segment, Section,
4908 TAA, HasTAA, StubSize);
4912 if (llvm::Error E = isValidSectionSpecifier(SecName)) {
4913 Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
4938 cast<NamedDecl>(D));
4949 llvm::CodeModel::Model CM;
4950 if (!CodeModelAttr::ConvertStrToModel(Str, CM)) {
4951 S.
Diag(LiteralLoc, diag::err_attr_codemodel_arg) << Str;
4961 StringRef CodeSegName) {
4963 S.
Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
4975 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
4979 if (
const auto *ExistingAttr = D->
getAttr<CodeSegAttr>()) {
4980 if (ExistingAttr->getName() == Name)
4982 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section)
4984 Diag(CI.
getLoc(), diag::note_previous_attribute);
4987 return ::new (Context) CodeSegAttr(Context, CI, Name);
4995 if (!checkCodeSegName(S, LiteralLoc, Str))
4997 if (
const auto *ExistingAttr = D->
getAttr<CodeSegAttr>()) {
4998 if (!ExistingAttr->isImplicit()) {
5000 ExistingAttr->getName() == Str
5001 ? diag::warn_duplicate_codeseg_attribute
5002 : diag::err_conflicting_codeseg_attribute);
5015 enum SecondParam {
None, CPU, Tune };
5017 if (AttrStr.contains(
"fpmath="))
5018 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
5023 AttrStr.contains(
"tune="))
5024 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
5030 if (!ParsedAttrs.
CPU.empty() &&
5032 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
5035 if (!ParsedAttrs.
Tune.empty() &&
5037 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
5042 return Diag(LiteralLoc, diag::err_duplicate_target_attribute)
5046 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
5049 for (
const auto &Feature : ParsedAttrs.
Features) {
5050 auto CurFeature = StringRef(Feature).drop_front();
5052 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
5062 if (DiagMsg.empty())
5063 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
5065 return Diag(LiteralLoc, diag::err_invalid_branch_protection_spec)
5068 if (!DiagMsg.empty())
5069 Diag(LiteralLoc, diag::warn_unsupported_branch_protection_spec) << DiagMsg;
5076 StringRef &AttrStr,
bool &isDefault) {
5078 enum SecondParam {
None };
5080 if (AttrStr.trim() ==
"default")
5083 AttrStr.split(Features,
"+");
5084 for (
auto &CurFeature : Features) {
5085 CurFeature = CurFeature.trim();
5086 if (CurFeature ==
"default")
5089 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
5094 return Diag(LiteralLoc, diag::err_sme_streaming_cannot_be_multiversioned);
5101 bool isDefault =
false;
5107 TargetVersionAttr *NewAttr =
5108 ::new (S.
Context) TargetVersionAttr(S.Context, AL, Str);
5109 D->addAttr(NewAttr);
5120 TargetAttr *NewAttr = ::new (S.
Context) TargetAttr(S.Context, AL, Str);
5121 D->addAttr(NewAttr);
5124 bool Sema::checkTargetClonesAttrString(
5126 Decl *D,
bool &HasDefault,
bool &HasCommas,
bool &HasNotDefault,
5129 enum SecondParam {
None, CPU, Tune };
5131 HasCommas = HasCommas || Str.contains(
',');
5134 if (Str.size() == 0)
5135 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
5138 std::pair<StringRef, StringRef> Parts = {{}, Str};
5139 while (!Parts.second.empty()) {
5140 Parts = Parts.second.split(
',');
5141 StringRef Cur = Parts.first.trim();
5143 Literal->getLocationOfByte(Cur.data() -
Literal->getString().data(),
5144 getSourceManager(), getLangOpts(), TInfo);
5146 bool DefaultIsDupe =
false;
5147 bool HasCodeGenImpact =
false;
5149 return Diag(CurLoc, diag::warn_unsupported_target_attribute)
5154 if (Cur ==
"default") {
5155 DefaultIsDupe = HasDefault;
5157 if (llvm::is_contained(StringsBuffer, Cur) || DefaultIsDupe)
5158 Diag(CurLoc, diag::warn_target_clone_duplicate_options);
5160 StringsBuffer.push_back(Cur);
5162 std::pair<StringRef, StringRef> CurParts = {{}, Cur};
5164 while (!CurParts.second.empty()) {
5165 CurParts = CurParts.second.split(
'+');
5166 StringRef CurFeature = CurParts.first.trim();
5168 Diag(CurLoc, diag::warn_unsupported_target_attribute)
5173 HasCodeGenImpact =
true;
5174 CurFeatures.push_back(CurFeature);
5177 llvm::sort(CurFeatures);
5179 for (
auto &CurFeat : CurFeatures) {
5182 Res.append(CurFeat);
5184 if (llvm::is_contained(StringsBuffer, Res) || DefaultIsDupe)
5185 Diag(CurLoc, diag::warn_target_clone_duplicate_options);
5186 else if (!HasCodeGenImpact)
5189 Diag(CurLoc, diag::warn_target_clone_no_impact_options);
5190 else if (!Res.empty()) {
5191 StringsBuffer.push_back(Res);
5192 HasNotDefault =
true;
5197 return Diag(LiteralLoc,
5198 diag::err_sme_streaming_cannot_be_multiversioned);
5201 if (Cur.starts_with(
"arch=")) {
5203 Cur.drop_front(
sizeof(
"arch=") - 1)))
5204 return Diag(CurLoc, diag::warn_unsupported_target_attribute)
5205 <<
Unsupported << CPU << Cur.drop_front(
sizeof(
"arch=") - 1)
5207 }
else if (Cur ==
"default") {
5208 DefaultIsDupe = HasDefault;
5211 return Diag(CurLoc, diag::warn_unsupported_target_attribute)
5213 if (llvm::is_contained(StringsBuffer, Cur) || DefaultIsDupe)
5214 Diag(CurLoc, diag::warn_target_clone_duplicate_options);
5216 StringsBuffer.push_back(Cur);
5220 if (Str.rtrim().ends_with(
","))
5221 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
5233 if (
const auto *Other = D->
getAttr<TargetClonesAttr>()) {
5234 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
5235 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
5238 if (checkAttrMutualExclusion<TargetClonesAttr>(S, D, AL))
5243 bool HasCommas =
false, HasDefault =
false, HasNotDefault =
false;
5245 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
5252 HasDefault, HasCommas, HasNotDefault, StringsBuffer))
5256 for (
auto &SmallStr : StringsBuffer)
5257 Strings.push_back(SmallStr.str());
5260 S.
Diag(AL.
getLoc(), diag::warn_target_clone_mixed_values);
5265 Strings.push_back(
"default");
5269 S.
Diag(AL.
getLoc(), diag::err_target_clone_must_have_default);
5275 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
5288 cast<FunctionDecl>(D)->setIsMultiVersion();
5289 TargetClonesAttr *NewAttr = ::new (S.
Context)
5290 TargetClonesAttr(S.Context, AL, Strings.data(), Strings.size());
5291 D->addAttr(NewAttr);
5295 Expr *E = AL.getArgAsExpr(0);
5302 MinVectorWidthAttr *Existing = D->getAttr<MinVectorWidthAttr>();
5303 if (Existing && Existing->getVectorWidth() != VecWidth) {
5304 S.
Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL;
5308 D->addAttr(::
new (S.
Context) MinVectorWidthAttr(S.
Context, AL, VecWidth));
5319 if (
auto *DRE = dyn_cast<DeclRefExpr>(E)) {
5321 S.
Diag(
Loc, diag::warn_cleanup_ext);
5322 FD = dyn_cast<FunctionDecl>(DRE->
getDecl());
5325 S.
Diag(
Loc, diag::err_attribute_cleanup_arg_not_function) << 1
5329 }
else if (
auto *ULE = dyn_cast<UnresolvedLookupExpr>(E)) {
5330 if (ULE->hasExplicitTemplateArgs())
5331 S.
Diag(
Loc, diag::warn_cleanup_ext);
5333 NI = ULE->getNameInfo();
5335 S.
Diag(
Loc, diag::err_attribute_cleanup_arg_not_function) << 2
5342 S.
Diag(
Loc, diag::err_attribute_cleanup_arg_not_function) << 0;
5347 S.
Diag(
Loc, diag::err_attribute_cleanup_func_must_take_one_arg)
5358 S.
Diag(
Loc, diag::err_attribute_cleanup_func_arg_incompatible_type)
5359 << NI.
getName() << ParamTy << Ty;
5362 VarDecl *VD = cast<VarDecl>(D);
5373 S.
Context, VariableReference, UnaryOperatorKind::UO_AddrOf,
5390 static void handleEnumExtensibilityAttr(
Sema &S,
Decl *D,
5393 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
5400 if (!EnumExtensibilityAttr::ConvertStrToKind(II->
getName(),
5401 ExtensibilityKind)) {
5402 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
5407 EnumExtensibilityAttr(S.
Context, AL, ExtensibilityKind));
5415 if (!checkFunctionOrMethodParameterIndex(S, D, AL, 1, IdxExpr, Idx))
5422 if (NotNSStringTy &&
5426 S.
Diag(AL.
getLoc(), diag::err_format_attribute_not)
5434 if (
auto *OMD = dyn_cast<ObjCMethodDecl>(D))
5435 if (
auto *Interface = OMD->getClassInterface())
5442 S.
Diag(AL.
getLoc(), diag::err_format_attribute_result_not)
5443 << (NotNSStringTy ?
"string type" :
"NSString")
5451 enum FormatAttrKind {
5462 static FormatAttrKind getFormatAttrKind(StringRef Format) {
5463 return llvm::StringSwitch<FormatAttrKind>(Format)
5465 .Case(
"NSString", NSStringFormat)
5466 .Case(
"CFString", CFStringFormat)
5467 .Case(
"strftime", StrftimeFormat)
5470 .Cases(
"scanf",
"printf",
"printf0",
"strfmon", SupportedFormat)
5471 .Cases(
"cmn_err",
"vcmn_err",
"zcmn_err", SupportedFormat)
5472 .Case(
"kprintf", SupportedFormat)
5473 .Case(
"freebsd_kprintf", SupportedFormat)
5474 .Case(
"os_trace", SupportedFormat)
5475 .Case(
"os_log", SupportedFormat)
5477 .Cases(
"gcc_diag",
"gcc_cdiag",
"gcc_cxxdiag",
"gcc_tdiag", IgnoredFormat)
5478 .Default(InvalidFormat);
5485 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored) << AL;
5490 S.
Diag(AL.
getLoc(), diag::err_hlsl_init_priority_unsupported);
5495 S.
Diag(AL.
getLoc(), diag::err_init_priority_object_attr);
5499 QualType T = cast<VarDecl>(D)->getType();
5503 S.
Diag(AL.
getLoc(), diag::err_init_priority_object_attr);
5509 uint32_t prioritynum;
5518 if ((prioritynum < 101 || prioritynum > 65535) &&
5520 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_range)
5529 StringRef NewUserDiagnostic) {
5530 if (
const auto *EA = D->
getAttr<ErrorAttr>()) {
5532 assert((NewAttr ==
"error" || NewAttr ==
"warning") &&
5533 "unexpected normalized full name");
5534 bool Match = (EA->isError() && NewAttr ==
"error") ||
5535 (EA->isWarning() && NewAttr ==
"warning");
5537 Diag(EA->getLocation(), diag::err_attributes_are_not_compatible)
5540 EA->isRegularKeywordAttribute());
5541 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
5544 if (EA->getUserDiagnostic() != NewUserDiagnostic) {
5545 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << EA;
5546 Diag(EA->getLoc(), diag::note_previous_attribute);
5550 return ::new (Context) ErrorAttr(Context, CI, NewUserDiagnostic);
5558 if (F->getType() == Format &&
5559 F->getFormatIdx() == FormatIdx &&
5560 F->getFirstArg() == FirstArg) {
5563 if (F->getLocation().isInvalid())
5569 return ::new (Context) FormatAttr(Context, CI, Format, FormatIdx, FirstArg);
5576 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
5587 StringRef Format = II->
getName();
5595 FormatAttrKind
Kind = getFormatAttrKind(Format);
5597 if (
Kind == IgnoredFormat)
5600 if (
Kind == InvalidFormat) {
5601 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
5612 if (Idx < 1 || Idx > NumArgs) {
5613 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
5619 unsigned ArgIdx = Idx - 1;
5621 if (HasImplicitThisParam) {
5624 diag::err_format_attribute_implicit_this_format_string)
5638 S.
Diag(AL.
getLoc(), diag::err_format_attribute_not)
5650 if (FirstArg != 0) {
5651 if (
Kind == StrftimeFormat) {
5654 S.
Diag(AL.
getLoc(), diag::err_format_strftime_third_parameter)
5662 if (FirstArg != NumArgs + 1) {
5663 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
5666 std::to_string(NumArgs + 1));
5671 S.
Diag(D->
getLocation(), diag::warn_gcc_requires_variadic_function) << AL;
5672 if (FirstArg <= Idx) {
5676 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
5692 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_no_callee)
5701 assert(FD &&
"Expected a function declaration!");
5703 llvm::StringMap<int> NameIdxMapping;
5704 NameIdxMapping[
"__"] = -1;
5706 NameIdxMapping[
"this"] = 0;
5710 NameIdxMapping[PVD->getName()] = Idx++;
5712 auto UnknownName = NameIdxMapping.end();
5715 for (
unsigned I = 0, E = AL.
getNumArgs(); I < E; ++I) {
5721 auto It = NameIdxMapping.find(IdLoc->
Ident->
getName());
5722 if (It == UnknownName) {
5723 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_argument_unknown)
5729 ArgIdx = It->second;
5736 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
5742 if (ArgIdx < -1 || ArgIdx > NumArgs) {
5743 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
5750 llvm_unreachable(
"Unexpected ParsedAttr argument type!");
5753 if (ArgIdx == 0 && !HasImplicitThisParam) {
5754 S.
Diag(AL.
getLoc(), diag::err_callback_implicit_this_not_available)
5761 if (!HasImplicitThisParam && ArgIdx > 0)
5764 EncodingIndices.push_back(ArgIdx);
5767 int CalleeIdx = EncodingIndices.front();
5771 if (CalleeIdx < (
int)HasImplicitThisParam) {
5772 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_invalid_callee)
5779 const Type *CalleeType =
5783 S.
Diag(AL.
getLoc(), diag::err_callback_callee_no_function_type)
5788 const Type *CalleeFnType =
5793 const auto *CalleeFnProtoType = dyn_cast<FunctionProtoType>(CalleeFnType);
5794 if (!CalleeFnProtoType) {
5795 S.
Diag(AL.
getLoc(), diag::err_callback_callee_no_function_type)
5800 if (CalleeFnProtoType->getNumParams() > EncodingIndices.size() - 1) {
5801 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments)
5802 << AL << (
unsigned)(EncodingIndices.size() - 1);
5806 if (CalleeFnProtoType->getNumParams() < EncodingIndices.size() - 1) {
5807 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments)
5808 << AL << (
unsigned)(EncodingIndices.size() - 1);
5812 if (CalleeFnProtoType->isVariadic()) {
5818 if (D->
hasAttr<CallbackAttr>()) {
5824 S.
Context, AL, EncodingIndices.data(), EncodingIndices.size()));
5827 static bool isFunctionLike(
const Type &
T) {
5837 QualType T = cast<ParmVarDecl>(D)->getType();
5839 if (!isFunctionLike(*
T)) {
5840 S.
Diag(AL.
getLoc(), diag::err_called_once_attribute_wrong_type);
5850 const auto *TD = dyn_cast<TypedefNameDecl>(D);
5851 if (TD && TD->getUnderlyingType()->isUnionType())
5852 RD = TD->getUnderlyingType()->getAsUnionType()->getDecl();
5854 RD = dyn_cast<RecordDecl>(D);
5857 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
5865 diag::warn_transparent_union_attribute_not_definition);
5871 if (Field == FieldEnd) {
5872 S.
Diag(AL.
getLoc(), diag::warn_transparent_union_attribute_zero_fields);
5880 diag::warn_transparent_union_attribute_floating)
5905 diag::warn_transparent_union_attribute_field_size_align)
5906 << isSize << *
Field << FieldBits;
5907 unsigned FirstBits = isSize ? FirstSize : FirstAlign;
5909 diag::note_transparent_union_first_field_size_align)
5910 << isSize << FirstBits;
5920 auto *
Attr = AnnotateAttr::Create(Context, Str, Args.data(), Args.size(), CI);
5921 if (ConstantFoldAttrArgs(
5936 for (
unsigned Idx = 1; Idx < AL.
getNumArgs(); Idx++) {
5949 AlignValueAttr TmpAttr(Context, CI, E);
5953 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D))
5954 T = TD->getUnderlyingType();
5955 else if (
const auto *VD = dyn_cast<ValueDecl>(D))
5958 llvm_unreachable(
"Unknown decl type for align_value");
5962 Diag(AttrLoc, diag::warn_attribute_pointer_or_reference_only)
5969 ExprResult ICE = VerifyIntegerConstantExpression(
5970 E, &Alignment, diag::err_align_value_attribute_argument_not_int);
5974 if (!Alignment.isPowerOf2()) {
5975 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
5980 D->
addAttr(::
new (Context) AlignValueAttr(Context, CI, ICE.
get()));
5985 D->
addAttr(::
new (Context) AlignValueAttr(Context, CI, E));
5997 diag::err_pack_expansion_without_parameter_packs);
6012 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
6024 diag::err_pack_expansion_without_parameter_packs);
6050 static bool validateAlignasAppliedType(
Sema &S,
Decl *D,
6051 const AlignedAttr &
Attr,
6054 if (isa<ParmVarDecl>(D)) {
6056 }
else if (
const auto *VD = dyn_cast<VarDecl>(D)) {
6061 }
else if (
const auto *FD = dyn_cast<FieldDecl>(D)) {
6062 if (FD->isBitField())
6064 }
else if (
const auto *ED = dyn_cast<EnumDecl>(D)) {
6065 if (ED->getLangOpts().CPlusPlus)
6067 }
else if (!isa<TagDecl>(D)) {
6068 return S.
Diag(AttrLoc, diag::err_attribute_wrong_decl_type)
6073 if (DiagKind != -1) {
6074 return S.
Diag(AttrLoc, diag::err_alignas_attribute_wrong_decl_type)
6075 << &
Attr << DiagKind;
6081 bool IsPackExpansion) {
6082 AlignedAttr TmpAttr(Context, CI,
true, E);
6086 if (TmpAttr.isAlignas() &&
6087 validateAlignasAppliedType(*
this, D, TmpAttr, AttrLoc))
6094 if (
const auto *TND = dyn_cast<TypedefNameDecl>(D)) {
6095 if (!TND->getUnderlyingType()->isDependentType()) {
6096 Diag(AttrLoc, diag::err_alignment_dependent_typedef_name)
6103 AlignedAttr *AA = ::new (Context) AlignedAttr(Context, CI,
true, E);
6104 AA->setPackExpansion(IsPackExpansion);
6111 ExprResult ICE = VerifyIntegerConstantExpression(
6112 E, &Alignment, diag::err_aligned_attribute_argument_not_int);
6119 if (Alignment > MaximumAlignment) {
6120 Diag(AttrLoc, diag::err_attribute_aligned_too_great)
6125 uint64_t AlignVal = Alignment.getZExtValue();
6131 if (!(TmpAttr.isAlignas() && !Alignment)) {
6132 if (!llvm::isPowerOf2_64(AlignVal)) {
6133 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
6139 const auto *VD = dyn_cast<VarDecl>(D);
6141 unsigned MaxTLSAlign =
6144 if (MaxTLSAlign && AlignVal > MaxTLSAlign &&
6147 << (
unsigned)AlignVal << VD << MaxTLSAlign;
6163 AlignedAttr *AA = ::new (Context) AlignedAttr(Context, CI,
true, ICE.
get());
6164 AA->setPackExpansion(IsPackExpansion);
6165 AA->setCachedAlignmentValue(
6166 static_cast<unsigned>(AlignVal * Context.
getCharWidth()));
6172 AlignedAttr TmpAttr(Context, CI,
false, TS);
6176 if (TmpAttr.isAlignas() &&
6177 validateAlignasAppliedType(*
this, D, TmpAttr, AttrLoc))
6184 if (
const auto *TND = dyn_cast<TypedefNameDecl>(D)) {
6185 if (!TND->getUnderlyingType()->isDependentType()) {
6186 Diag(AttrLoc, diag::err_alignment_dependent_typedef_name)
6192 AlignedAttr *AA = ::new (Context) AlignedAttr(Context, CI,
false, TS);
6193 AA->setPackExpansion(IsPackExpansion);
6198 const auto *VD = dyn_cast<VarDecl>(D);
6199 unsigned AlignVal = TmpAttr.getAlignment(Context);
6212 AlignedAttr *AA = ::new (Context) AlignedAttr(Context, CI,
false, TS);
6213 AA->setPackExpansion(IsPackExpansion);
6214 AA->setCachedAlignmentValue(AlignVal);
6219 assert(D->
hasAttrs() &&
"no attributes on decl");
6222 if (
const auto *VD = dyn_cast<ValueDecl>(D)) {
6223 UnderlyingTy = DiagTy = VD->
getType();
6225 UnderlyingTy = DiagTy = Context.
getTagDeclType(cast<TagDecl>(D));
6226 if (
const auto *ED = dyn_cast<EnumDecl>(D))
6227 UnderlyingTy = ED->getIntegerType();
6236 AlignedAttr *AlignasAttr =
nullptr;
6237 AlignedAttr *LastAlignedAttr =
nullptr;
6240 if (I->isAlignmentDependent())
6244 Align =
std::max(Align, I->getAlignment(Context));
6245 LastAlignedAttr = I;
6249 Diag(LastAlignedAttr->getLocation(), diag::err_attribute_sizeless_type)
6250 << LastAlignedAttr << DiagTy;
6251 }
else if (AlignasAttr && Align) {
6254 if (NaturalAlign > RequestedAlign)
6255 Diag(AlignasAttr->getLocation(), diag::err_alignas_underaligned)
6290 static void parseModeAttrArg(
Sema &S, StringRef Str,
unsigned &DestWidth,
6291 bool &IntegerMode,
bool &ComplexMode,
6294 ComplexMode =
false;
6296 switch (Str.size()) {
6316 DestWidth = Str[1] ==
'I' ? 0 : 128;
6324 DestWidth = Str[1] ==
'I' ? 0 : 128;
6327 if (Str[1] ==
'F') {
6328 IntegerMode =
false;
6329 }
else if (Str[1] ==
'C') {
6330 IntegerMode =
false;
6332 }
else if (Str[1] !=
'I') {
6341 else if (Str ==
"byte")
6345 if (Str ==
"pointer")
6349 if (Str ==
"unwind_word")
6365 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
6377 StringRef Str = Name->getName();
6381 unsigned DestWidth = 0;
6382 bool IntegerMode =
true;
6383 bool ComplexMode =
false;
6386 if (Str.size() >= 4 && Str[0] ==
'V') {
6388 size_t StrSize = Str.size();
6389 size_t VectorStringLength = 0;
6390 while ((VectorStringLength + 1) < StrSize &&
6391 isdigit(Str[VectorStringLength + 1]))
6392 ++VectorStringLength;
6393 if (VectorStringLength &&
6394 !Str.substr(1, VectorStringLength).getAsInteger(10, VectorSize) &&
6395 VectorSize.isPowerOf2()) {
6396 parseModeAttrArg(*
this, Str.substr(VectorStringLength + 1), DestWidth,
6397 IntegerMode, ComplexMode, ExplicitType);
6399 if (!InInstantiation)
6400 Diag(AttrLoc, diag::warn_vector_mode_deprecated);
6407 parseModeAttrArg(*
this, Str, DestWidth, IntegerMode, ComplexMode,
6415 Diag(AttrLoc, diag::err_machine_mode) << 0 << Name;
6420 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D))
6421 OldTy = TD->getUnderlyingType();
6422 else if (
const auto *ED = dyn_cast<EnumDecl>(D)) {
6425 OldTy = ED->getIntegerType();
6427 OldTy = Context.
IntTy;
6429 OldTy = cast<ValueDecl>(D)->getType();
6432 D->
addAttr(::
new (Context) ModeAttr(Context, CI, Name));
6440 OldElemTy = VT->getElementType();
6446 VectorSize.getBoolValue()) {
6447 Diag(AttrLoc, diag::err_enum_mode_vector_type) << Name << CI.
getRange();
6455 !IntegralOrAnyEnumType)
6456 Diag(AttrLoc, diag::err_mode_not_primitive);
6457 else if (IntegerMode) {
6458 if (!IntegralOrAnyEnumType)
6459 Diag(AttrLoc, diag::err_mode_wrong_type);
6460 }
else if (ComplexMode) {
6462 Diag(AttrLoc, diag::err_mode_wrong_type);
6465 Diag(AttrLoc, diag::err_mode_wrong_type);
6476 if (NewElemTy.
isNull()) {
6478 if (!(DestWidth == 128 && getLangOpts().CUDAIsDevice))
6479 Diag(AttrLoc, diag::err_machine_mode) << 1 << Name;
6488 if (VectorSize.getBoolValue()) {
6489 NewTy = Context.
getVectorType(NewTy, VectorSize.getZExtValue(),
6494 Diag(AttrLoc, diag::err_complex_mode_vector_type);
6497 unsigned NumElements = Context.
getTypeSize(OldElemTy) *
6498 OldVT->getNumElements() /
6501 Context.
getVectorType(NewElemTy, NumElements, OldVT->getVectorKind());
6505 Diag(AttrLoc, diag::err_mode_wrong_type);
6510 if (
auto *TD = dyn_cast<TypedefNameDecl>(D))
6511 TD->setModedTypeSourceInfo(TD->getTypeSourceInfo(), NewTy);
6512 else if (
auto *ED = dyn_cast<EnumDecl>(D))
6513 ED->setIntegerType(NewTy);
6515 cast<ValueDecl>(D)->setType(NewTy);
6517 D->
addAttr(::
new (Context) ModeAttr(Context, CI, Name));
6527 if (OptimizeNoneAttr *Optnone = D->
getAttr<OptimizeNoneAttr>()) {
6528 Diag(CI.
getLoc(), diag::warn_attribute_ignored) << Ident;
6529 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
6533 if (D->
hasAttr<AlwaysInlineAttr>())
6536 return ::new (Context) AlwaysInlineAttr(Context, CI);
6541 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
6544 if (VD->
getKind() != Decl::Var) {
6545 Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
6558 return ::new (Context) InternalLinkageAttr(Context, AL);
6560 InternalLinkageAttr *
6562 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
6565 if (VD->
getKind() != Decl::Var) {
6566 Diag(AL.getLocation(), diag::warn_attribute_wrong_decl_type)
6567 << &AL << AL.isRegularKeywordAttribute()
6579 return ::new (Context) InternalLinkageAttr(Context, AL);
6583 if (OptimizeNoneAttr *Optnone = D->
getAttr<OptimizeNoneAttr>()) {
6584 Diag(CI.
getLoc(), diag::warn_attribute_ignored) <<
"'minsize'";
6585 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
6589 if (D->
hasAttr<MinSizeAttr>())
6592 return ::new (Context) MinSizeAttr(Context, CI);
6597 if (
const auto *PrevSNA = D->
getAttr<SwiftNameAttr>()) {
6598 if (PrevSNA->getName() != Name && !PrevSNA->isImplicit()) {
6599 Diag(PrevSNA->getLocation(), diag::err_attributes_are_not_compatible)
6601 << (PrevSNA->isRegularKeywordAttribute() ||
6602 SNA.isRegularKeywordAttribute());
6603 Diag(SNA.getLoc(), diag::note_conflicting_attribute);
6608 return ::new (Context) SwiftNameAttr(Context, SNA, Name);
6613 if (AlwaysInlineAttr *Inline = D->
getAttr<AlwaysInlineAttr>()) {
6614 Diag(Inline->getLocation(), diag::warn_attribute_ignored) << Inline;
6615 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
6618 if (MinSizeAttr *MinSize = D->
getAttr<MinSizeAttr>()) {
6619 Diag(MinSize->getLocation(), diag::warn_attribute_ignored) << MinSize;
6620 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
6624 if (D->
hasAttr<OptimizeNoneAttr>())
6627 return ::new (Context) OptimizeNoneAttr(Context, CI);
6631 if (AlwaysInlineAttr *Inline =
6647 auto *ND = cast<NamedDecl>(D);
6648 if (!ND->isExternallyVisible()) {
6649 S.
Diag(AL.
getLoc(), diag::err_sycl_attribute_internal_decl)
6650 << AL << !isa<FunctionDecl>(ND);
6654 if (
auto *VD = dyn_cast<VarDecl>(D)) {
6661 S.
Diag(AL.
getLoc(), diag::err_sycl_attribute_not_device_global) << AL;
6666 handleSimpleAttribute<SYCLDeviceAttr>(S, D, AL);
6669 static void handleSYCLDeviceIndirectlyCallableAttr(
Sema &S,
Decl *D,
6671 auto *FD = cast<FunctionDecl>(D);
6673 S.
Diag(AL.
getLoc(), diag::err_sycl_attribute_internal_decl)
6679 handleSimpleAttribute<SYCLDeviceIndirectlyCallableAttr>(S, D, AL);
6684 S.
Diag(AL.
getLoc(), diag::err_attribute_only_system_header) << AL;
6688 handleSimpleAttribute<SYCLGlobalVarAttr>(S, D, AL);
6709 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
6714 if (ArgVal != 8 && ArgVal != 16 && ArgVal != 32) {
6715 Diag(E->
getExprLoc(), diag::err_sycl_esimd_vectorize_unsupported_value)
6722 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelESimdVectorizeAttr>()) {
6726 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
6727 if (ArgVal != DeclExpr->getResultAsAPSInt()) {
6728 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << CI;
6729 Diag(DeclAttr->getLoc(), diag::note_previous_attribute);
6737 D->
addAttr(::
new (Context) SYCLIntelESimdVectorizeAttr(Context, CI, E));
6740 SYCLIntelESimdVectorizeAttr *
6742 const SYCLIntelESimdVectorizeAttr &A) {
6745 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelESimdVectorizeAttr>()) {
6746 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
6747 if (
const auto *MergeExpr = dyn_cast<ConstantExpr>(A.getValue())) {
6748 if (DeclExpr->getResultAsAPSInt() != MergeExpr->getResultAsAPSInt()) {
6749 Diag(DeclAttr->getLoc(), diag::warn_duplicate_attribute) << &A;
6750 Diag(A.getLoc(), diag::note_previous_attribute);
6757 return ::new (Context) SYCLIntelESimdVectorizeAttr(Context, A, A.getValue());
6760 static void handleSYCLIntelESimdVectorizeAttr(
Sema &S,
Decl *D,
6769 const auto *VD = cast<VarDecl>(D);
6771 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
6776 if (
auto *A = D->
getAttr<CUDAConstantAttr>()) {
6777 if (!A->isImplicit())
6785 const auto *VD = cast<VarDecl>(D);
6789 !isa<IncompleteArrayType>(VD->
getType())) {
6790 S.
Diag(AL.
getLoc(), diag::err_cuda_extern_shared) << VD;
6801 const auto *FD = cast<FunctionDecl>(D);
6812 if (
const auto *Method = dyn_cast<CXXMethodDecl>(FD)) {
6813 if (Method->isInstance()) {
6814 S.
Diag(Method->getBeginLoc(), diag::err_kern_is_nonstatic_method)
6818 S.
Diag(Method->getBeginLoc(), diag::warn_kern_is_method) << Method;
6824 if (AL.
getKind() == ParsedAttr::AT_NVPTXKernel)
6837 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
6839 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
6844 if (
auto *A = D->
getAttr<CUDADeviceAttr>()) {
6845 if (!A->isImplicit())
6853 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
6855 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
6859 if (!D->
hasAttr<HIPManagedAttr>())
6861 if (!D->
hasAttr<CUDADeviceAttr>())
6866 const auto *Fn = cast<FunctionDecl>(D);
6867 if (!Fn->isInlineSpecified()) {
6868 S.
Diag(AL.
getLoc(), diag::warn_gnu_inline_attribute_requires_inline);
6873 S.
Diag(AL.
getLoc(), diag::warn_gnu_inline_cplusplus_without_extern);
6889 if (!isa<ObjCMethodDecl>(D)) {
6890 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
6896 case ParsedAttr::AT_FastCall:
6899 case ParsedAttr::AT_StdCall:
6902 case ParsedAttr::AT_ThisCall:
6905 case ParsedAttr::AT_CDecl:
6908 case ParsedAttr::AT_Pascal:
6911 case ParsedAttr::AT_SwiftCall:
6914 case ParsedAttr::AT_SwiftAsyncCall:
6917 case ParsedAttr::AT_VectorCall:
6920 case ParsedAttr::AT_MSABI:
6923 case ParsedAttr::AT_SysVABI:
6926 case ParsedAttr::AT_RegCall:
6929 case ParsedAttr::AT_Pcs: {
6930 PcsAttr::PCSType PCS;
6933 PCS = PcsAttr::AAPCS;
6936 PCS = PcsAttr::AAPCS_VFP;
6939 llvm_unreachable(
"unexpected calling convention in pcs attribute");
6945 case ParsedAttr::AT_AArch64VectorPcs:
6948 case ParsedAttr::AT_AArch64SVEPcs:
6951 case ParsedAttr::AT_AMDGPUKernelCall:
6954 case ParsedAttr::AT_IntelOclBicc:
6957 case ParsedAttr::AT_PreserveMost:
6960 case ParsedAttr::AT_PreserveAll:
6963 case ParsedAttr::AT_M68kRTD:
6966 case ParsedAttr::AT_PreserveNone:
6969 case ParsedAttr::AT_RISCVVectorCC:
6973 llvm_unreachable(
"unexpected attribute kind");
6984 std::vector<StringRef> DiagnosticIdentifiers;
6985 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
6991 DiagnosticIdentifiers.push_back(RuleName);
6994 SuppressAttr(S.
Context, AL, DiagnosticIdentifiers.data(),
6995 DiagnosticIdentifiers.size()));
7004 unsigned SelectIdx = ~0
U;
7010 if (SelectIdx != ~0
U) {
7011 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_argument)
7023 if (AL.
getKind() == ParsedAttr::AT_Owner) {
7024 if (checkAttrMutualExclusion<PointerAttr>(S, D, AL))
7026 if (
const auto *OAttr = D->
getAttr<OwnerAttr>()) {
7027 const Type *ExistingDerefType = OAttr->getDerefTypeLoc()
7028 ? OAttr->getDerefType().getTypePtr()
7031 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
7034 OAttr->isRegularKeywordAttribute());
7035 S.
Diag(OAttr->getLocation(), diag::note_conflicting_attribute);
7040 Redecl->addAttr(::
new (S.
Context) OwnerAttr(S.
Context, AL, DerefTypeLoc));
7043 if (checkAttrMutualExclusion<OwnerAttr>(S, D, AL))
7045 if (
const auto *PAttr = D->
getAttr<PointerAttr>()) {
7046 const Type *ExistingDerefType = PAttr->getDerefTypeLoc()
7047 ? PAttr->getDerefType().getTypePtr()
7050 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
7053 PAttr->isRegularKeywordAttribute());
7054 S.
Diag(PAttr->getLocation(), diag::note_conflicting_attribute);
7059 Redecl->addAttr(::
new (S.
Context)
7060 PointerAttr(S.
Context, AL, DerefTypeLoc));
7066 if (checkAttrMutualExclusion<NoRandomizeLayoutAttr>(S, D, AL))
7068 if (!D->
hasAttr<RandomizeLayoutAttr>())
7072 static void handleNoRandomizeLayoutAttr(
Sema &S,
Decl *D,
7074 if (checkAttrMutualExclusion<RandomizeLayoutAttr>(S, D, AL))
7076 if (!D->
hasAttr<NoRandomizeLayoutAttr>())
7091 unsigned ReqArgs = Attrs.
getKind() == ParsedAttr::AT_Pcs ? 1 : 0;
7100 case ParsedAttr::AT_CDecl:
7103 case ParsedAttr::AT_FastCall:
7106 case ParsedAttr::AT_StdCall:
7109 case ParsedAttr::AT_ThisCall:
7112 case ParsedAttr::AT_Pascal:
7115 case ParsedAttr::AT_SwiftCall:
7118 case ParsedAttr::AT_SwiftAsyncCall:
7121 case ParsedAttr::AT_VectorCall:
7124 case ParsedAttr::AT_AArch64VectorPcs:
7127 case ParsedAttr::AT_AArch64SVEPcs:
7130 case ParsedAttr::AT_AMDGPUKernelCall:
7133 case ParsedAttr::AT_RegCall:
7136 case ParsedAttr::AT_MSABI:
7140 case ParsedAttr::AT_SysVABI:
7144 case ParsedAttr::AT_Pcs: {
7146 if (!checkStringLiteralArgumentAttr(Attrs, 0, StrRef)) {
7150 if (StrRef ==
"aapcs") {
7153 }
else if (StrRef ==
"aapcs-vfp") {
7162 case ParsedAttr::AT_IntelOclBicc:
7165 case ParsedAttr::AT_PreserveMost:
7168 case ParsedAttr::AT_PreserveAll:
7171 case ParsedAttr::AT_M68kRTD:
7174 case ParsedAttr::AT_PreserveNone:
7177 case ParsedAttr::AT_RISCVVectorCC:
7180 default: llvm_unreachable(
"unexpected attribute kind");
7188 if (LangOpts.CUDA) {
7191 auto CudaTarget = FD ?
CUDA().IdentifyTarget(FD) : CFT;
7192 bool CheckHost =
false, CheckDevice =
false;
7193 switch (CudaTarget) {
7206 llvm_unreachable(
"unexpected cuda target");
7208 auto *HostTI = LangOpts.CUDAIsDevice ? Aux : &TI;
7209 auto *DeviceTI = LangOpts.CUDAIsDevice ? &TI : Aux;
7210 if (CheckHost && HostTI)
7213 A = DeviceTI->checkCallingConvention(CC);
7231 Diag(Attrs.
getLoc(), diag::error_cconv_unsupported)
7232 << Attrs << (
int)CallingConventionIgnoredReason::ForThisTarget;
7236 Diag(Attrs.
getLoc(), diag::warn_cconv_unsupported)
7237 << Attrs << (
int)CallingConventionIgnoredReason::ForThisTarget;
7241 bool IsCXXMethod =
false, IsVariadic =
false;
7256 static bool isValidSwiftContextType(
QualType Ty) {
7263 static bool isValidSwiftIndirectResultType(
QualType Ty) {
7275 static bool isValidSwiftErrorResultType(
QualType Ty) {
7285 return isValidSwiftContextType(Ty);
7294 if (existingAttr->getABI() != abi) {
7295 Diag(CI.
getLoc(), diag::err_attributes_are_not_compatible)
7298 existingAttr->isRegularKeywordAttribute());
7299 Diag(existingAttr->getLocation(), diag::note_conflicting_attribute);
7306 llvm_unreachable(
"explicit attribute for ordinary parameter ABI?");
7309 if (!isValidSwiftContextType(
type)) {
7310 Diag(CI.
getLoc(), diag::err_swift_abi_parameter_wrong_type)
7313 D->
addAttr(::
new (Context) SwiftContextAttr(Context, CI));
7317 if (!isValidSwiftContextType(
type)) {
7318 Diag(CI.
getLoc(), diag::err_swift_abi_parameter_wrong_type)
7321 D->
addAttr(::
new (Context) SwiftAsyncContextAttr(Context, CI));
7325 if (!isValidSwiftErrorResultType(
type)) {
7326 Diag(CI.
getLoc(), diag::err_swift_abi_parameter_wrong_type)
7329 D->
addAttr(::
new (Context) SwiftErrorResultAttr(Context, CI));
7333 if (!isValidSwiftIndirectResultType(
type)) {
7334 Diag(CI.
getLoc(), diag::err_swift_abi_parameter_wrong_type)
7337 D->
addAttr(::
new (Context) SwiftIndirectResultAttr(Context, CI));
7340 llvm_unreachable(
"bad parameter ABI attribute");
7362 Diag(AL.
getLoc(), diag::err_attribute_regparm_wrong_platform)
7370 Diag(AL.
getLoc(), diag::err_attribute_regparm_invalid_number)
7384 const CUDALaunchBoundsAttr &AL,
7385 const unsigned Idx) {
7401 if (!I->isIntN(32)) {
7403 <<
toString(*I, 10,
false) << 32 << 1;
7407 S.
Diag(E->
getExprLoc(), diag::warn_attribute_argument_n_negative)
7415 "Unexpected PerformCopyInitialization() failure.");
7420 CUDALaunchBoundsAttr *
7422 Expr *MinBlocks,
Expr *MaxBlocks) {
7423 CUDALaunchBoundsAttr TmpAttr(Context, CI, MaxThreads, MinBlocks, MaxBlocks);
7424 MaxThreads = makeLaunchBoundsArgExpr(*
this, MaxThreads, TmpAttr, 0);
7429 MinBlocks = makeLaunchBoundsArgExpr(*
this, MinBlocks, TmpAttr, 1);
7441 MaxBlocks =
nullptr;
7443 MaxBlocks = makeLaunchBoundsArgExpr(*
this, MaxBlocks, TmpAttr, 2);
7449 return ::new (Context)
7450 CUDALaunchBoundsAttr(Context, CI, MaxThreads, MinBlocks, MaxBlocks);
7456 if (
auto *
Attr = CreateLaunchBoundsAttr(CI, MaxThreads, MinBlocks, MaxBlocks))
7469 static void handleArgumentWithTypeTagAttr(
Sema &S,
Decl *D,
7472 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
7478 if (!checkFunctionOrMethodParameterIndex(S, D, AL, 2, AL.
getArgAsExpr(1),
7483 if (!checkFunctionOrMethodParameterIndex(S, D, AL, 3, AL.
getArgAsExpr(2),
7490 unsigned ArgumentIdxAST = ArgumentIdx.
getASTIndex();
7493 S.
Diag(AL.
getLoc(), diag::err_attribute_pointers_only) << AL << 0;
7501 static void handleTypeTagForDatatypeAttr(
Sema &S,
Decl *D,
7504 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
7512 if (!isa<VarDecl>(D)) {
7513 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_decl_type)
7521 assert(MatchingCTypeLoc &&
"no type source info for attribute argument");
7529 template <
typename AttrType>
7530 static bool checkForDuplicateAttribute(
Sema &S,
Decl *D,
7533 auto *A = D->
getAttr<AttrType>();
7534 if (A && !A->isImplicit()) {
7535 S.
Diag(
Attr.
getLoc(), diag::warn_duplicate_attribute_exact) << A;
7543 static bool CheckValidFPGAMemoryAttributesVar(
Sema &S,
Decl *D) {
7544 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
7545 if (!(isa<FieldDecl>(D) ||
7546 (VD->
getKind() != Decl::ImplicitParam &&
7547 VD->
getKind() != Decl::NonTypeTemplateParm &&
7567 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
7574 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelNoGlobalWorkOffsetAttr>()) {
7578 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
7579 if (ArgVal != DeclExpr->getResultAsAPSInt()) {
7580 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << CI;
7581 Diag(DeclAttr->getLoc(), diag::note_previous_attribute);
7589 D->
addAttr(::
new (Context) SYCLIntelNoGlobalWorkOffsetAttr(Context, CI, E));
7593 Decl *D,
const SYCLIntelNoGlobalWorkOffsetAttr &A) {
7596 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelNoGlobalWorkOffsetAttr>()) {
7597 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
7598 if (
const auto *MergeExpr = dyn_cast<ConstantExpr>(A.getValue())) {
7599 if (DeclExpr->getResultAsAPSInt() != MergeExpr->getResultAsAPSInt()) {
7600 Diag(DeclAttr->getLoc(), diag::warn_duplicate_attribute) << &A;
7601 Diag(A.getLoc(), diag::note_previous_attribute);
7608 return ::new (Context)
7609 SYCLIntelNoGlobalWorkOffsetAttr(Context, A, A.getValue());
7612 static void handleSYCLIntelNoGlobalWorkOffsetAttr(
Sema &S,
Decl *D,
7624 static void handleSYCLIntelSinglePumpAttr(
Sema &S,
Decl *D,
7629 if (
const auto *ExistingAttr = D->
getAttr<SYCLIntelSinglePumpAttr>()) {
7630 if (ExistingAttr && !ExistingAttr->isImplicit()) {
7631 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute_exact) << &AL;
7632 S.
Diag(ExistingAttr->getLoc(), diag::note_previous_attribute);
7641 ((D->
getKind() == Decl::ParmVar) ||
7642 CheckValidFPGAMemoryAttributesVar(S, D))) {
7643 S.
Diag(AL.
getLoc(), diag::err_fpga_attribute_incorrect_variable)
7650 if (!D->
hasAttr<SYCLIntelMemoryAttr>())
7651 D->
addAttr(SYCLIntelMemoryAttr::CreateImplicit(
7652 S.
Context, SYCLIntelMemoryAttr::Default));
7658 static void handleSYCLIntelDoublePumpAttr(
Sema &S,
Decl *D,
7663 if (
const auto *ExistingAttr = D->
getAttr<SYCLIntelDoublePumpAttr>()) {
7664 if (ExistingAttr && !ExistingAttr->isImplicit()) {
7665 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute_exact) << &AL;
7666 S.
Diag(ExistingAttr->getLoc(), diag::note_previous_attribute);
7675 ((D->
getKind() == Decl::ParmVar) ||
7676 CheckValidFPGAMemoryAttributesVar(S, D))) {
7677 S.
Diag(AL.
getLoc(), diag::err_fpga_attribute_incorrect_variable)
7684 if (!D->
hasAttr<SYCLIntelMemoryAttr>())
7685 D->
addAttr(SYCLIntelMemoryAttr::CreateImplicit(
7686 S.
Context, SYCLIntelMemoryAttr::Default));
7694 SYCLIntelMemoryAttr::MemoryKind
Kind;
7696 Kind = SYCLIntelMemoryAttr::Default;
7702 !SYCLIntelMemoryAttr::ConvertStrToMemoryKind(Str,
Kind)) {
7704 SYCLIntelMemoryAttr::generateValidStrings(ValidStrings);
7705 S.
Diag(AL.
getLoc(), diag::err_intel_fpga_memory_arg_invalid)
7706 << AL << ValidStrings;
7711 if (
auto *MA = D->
getAttr<SYCLIntelMemoryAttr>()) {
7714 if (!MA->isImplicit()) {
7715 if (MA->getKind() !=
Kind) {
7716 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << &AL;
7717 S.
Diag(MA->getLocation(), diag::note_previous_attribute);
7723 D->
dropAttr<SYCLIntelMemoryAttr>();
7730 CheckValidFPGAMemoryAttributesVar(S, D)) {
7731 S.
Diag(AL.
getLoc(), diag::err_fpga_attribute_incorrect_variable)
7741 static void handleSYCLIntelRegisterAttr(
Sema &S,
Decl *D,
7747 if (
const auto *ExistingAttr = D->
getAttr<SYCLIntelRegisterAttr>()) {
7748 if (ExistingAttr && !ExistingAttr->isImplicit()) {
7749 S.
Diag(A.
getLoc(), diag::warn_duplicate_attribute_exact) << &A;
7750 S.
Diag(ExistingAttr->getLoc(), diag::note_previous_attribute);
7759 ((D->
getKind() == Decl::ParmVar) ||
7760 CheckValidFPGAMemoryAttributesVar(S, D))) {
7761 S.
Diag(A.
getLoc(), diag::err_fpga_attribute_incorrect_variable)
7782 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
7789 Diag(E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
7795 if (!ArgVal.isPowerOf2()) {
7796 Diag(E->
getExprLoc(), diag::err_attribute_argument_not_power_of_two)
7805 CheckValidFPGAMemoryAttributesVar(*
this, D)) {
7806 Diag(CI.
getLoc(), diag::err_fpga_attribute_incorrect_variable)
7813 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelBankWidthAttr>()) {
7817 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
7818 if (ArgVal != DeclExpr->getResultAsAPSInt()) {
7819 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << CI;
7820 Diag(DeclAttr->getLoc(), diag::note_previous_attribute);
7830 if (!D->
hasAttr<SYCLIntelMemoryAttr>())
7831 D->
addAttr(SYCLIntelMemoryAttr::CreateImplicit(
7832 Context, SYCLIntelMemoryAttr::Default));
7834 D->
addAttr(::
new (Context) SYCLIntelBankWidthAttr(Context, CI, E));
7837 SYCLIntelBankWidthAttr *
7841 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelBankWidthAttr>()) {
7842 const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue());
7843 const auto *MergeExpr = dyn_cast<ConstantExpr>(A.getValue());
7844 if (DeclExpr && MergeExpr &&
7845 DeclExpr->getResultAsAPSInt() != MergeExpr->getResultAsAPSInt()) {
7846 Diag(DeclAttr->getLoc(), diag::warn_duplicate_attribute) << &A;
7847 Diag(A.getLoc(), diag::note_previous_attribute);
7852 return ::new (Context) SYCLIntelBankWidthAttr(Context, A, A.getValue());
7855 static void handleSYCLIntelBankWidthAttr(
Sema &S,
Decl *D,
7867 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
7874 Diag(E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
7880 if (!ArgVal.isPowerOf2()) {
7881 Diag(E->
getExprLoc(), diag::err_attribute_argument_not_power_of_two)
7887 if (
auto *BBA = D->
getAttr<SYCLIntelBankBitsAttr>()) {
7888 unsigned NumBankBits = BBA->args_size();
7889 if (NumBankBits != ArgVal.ceilLogBase2()) {
7890 Diag(E->
getExprLoc(), diag::err_bankbits_numbanks_conflicting) << CI;
7899 CheckValidFPGAMemoryAttributesVar(*
this, D)) {
7900 Diag(CI.
getLoc(), diag::err_fpga_attribute_incorrect_variable)
7907 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelNumBanksAttr>()) {
7911 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
7912 if (ArgVal != DeclExpr->getResultAsAPSInt()) {
7913 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << CI;
7914 Diag(DeclAttr->getLoc(), diag::note_previous_attribute);
7924 if (!D->
hasAttr<SYCLIntelMemoryAttr>())
7925 D->
addAttr(SYCLIntelMemoryAttr::CreateImplicit(
7926 Context, SYCLIntelMemoryAttr::Default));
7929 if (
auto *NBA = D->
getAttr<SYCLIntelNumBanksAttr>()) {
7930 if (NBA->isImplicit())
7931 D->
dropAttr<SYCLIntelNumBanksAttr>();
7934 D->
addAttr(::
new (Context) SYCLIntelNumBanksAttr(Context, CI, E));
7937 SYCLIntelNumBanksAttr *
7941 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelNumBanksAttr>()) {
7942 const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue());
7943 const auto *MergeExpr = dyn_cast<ConstantExpr>(A.getValue());
7944 if (DeclExpr && MergeExpr &&
7945 DeclExpr->getResultAsAPSInt() != MergeExpr->getResultAsAPSInt()) {
7946 Diag(DeclAttr->getLoc(), diag::warn_duplicate_attribute) << &A;
7947 Diag(A.getLoc(), diag::note_previous_attribute);
7952 return ::new (Context) SYCLIntelNumBanksAttr(Context, A, A.getValue());
7959 static void handleIntelSimpleDualPortAttr(
Sema &S,
Decl *D,
7964 if (
const auto *ExistingAttr = D->
getAttr<SYCLIntelSimpleDualPortAttr>()) {
7965 if (ExistingAttr && !ExistingAttr->isImplicit()) {
7966 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute_exact) << &AL;
7967 S.
Diag(ExistingAttr->getLoc(), diag::note_previous_attribute);
7976 CheckValidFPGAMemoryAttributesVar(S, D)) {
7977 S.
Diag(AL.
getLoc(), diag::err_fpga_attribute_incorrect_variable)
7982 if (!D->
hasAttr<SYCLIntelMemoryAttr>())
7983 D->
addAttr(SYCLIntelMemoryAttr::CreateImplicit(
7984 S.
Context, SYCLIntelMemoryAttr::Default));
7987 SYCLIntelSimpleDualPortAttr(S.
Context, AL));
7997 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
8003 Diag(E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
8012 CheckValidFPGAMemoryAttributesVar(*
this, D)) {
8013 Diag(CI.
getLoc(), diag::err_fpga_attribute_incorrect_variable)
8020 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelMaxReplicatesAttr>()) {
8024 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
8025 if (ArgVal != DeclExpr->getResultAsAPSInt()) {
8026 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << CI;
8027 Diag(DeclAttr->getLoc(), diag::note_previous_attribute);
8037 if (!D->
hasAttr<SYCLIntelMemoryAttr>())
8038 D->
addAttr(SYCLIntelMemoryAttr::CreateImplicit(
8039 Context, SYCLIntelMemoryAttr::Default));
8041 D->
addAttr(::
new (Context) SYCLIntelMaxReplicatesAttr(Context, CI, E));
8044 SYCLIntelMaxReplicatesAttr *
8046 const SYCLIntelMaxReplicatesAttr &A) {
8049 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelMaxReplicatesAttr>()) {
8050 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
8051 if (
const auto *MergeExpr = dyn_cast<ConstantExpr>(A.getValue())) {
8052 if (DeclExpr->getResultAsAPSInt() != MergeExpr->getResultAsAPSInt()) {
8053 Diag(DeclAttr->getLoc(), diag::warn_duplicate_attribute) << &A;
8054 Diag(A.getLoc(), diag::note_previous_attribute);
8062 return ::new (Context) SYCLIntelMaxReplicatesAttr(Context, A, A.getValue());
8065 static void handleSYCLIntelMaxReplicatesAttr(
Sema &S,
Decl *D,
8076 for (
int I = 0; I < 2; I++) {
8081 if (I == 1 && Str !=
"depth" && Str !=
"width") {
8082 S.
Diag(AL.
getLoc(), diag::err_intel_fpga_merge_dir_invalid) << AL;
8085 Results.push_back(Str);
8091 if (
const auto *Existing = D->
getAttr<SYCLIntelMergeAttr>()) {
8092 if (Existing && !(Existing->getName() == Results[0] &&
8093 Existing->getDirection() == Results[1])) {
8094 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
8095 S.
Diag(Existing->getLoc(), diag::note_previous_attribute);
8105 ((D->
getKind() == Decl::ParmVar) ||
8106 CheckValidFPGAMemoryAttributesVar(S, D))) {
8107 S.
Diag(AL.
getLoc(), diag::err_fpga_attribute_incorrect_variable)
8112 if (!D->
hasAttr<SYCLIntelMemoryAttr>())
8113 D->
addAttr(SYCLIntelMemoryAttr::CreateImplicit(
8114 S.
Context, SYCLIntelMemoryAttr::Default));
8117 SYCLIntelMergeAttr(S.
Context, AL, Results[0], Results[1]));
8129 checkForDuplicateAttribute<SYCLIntelBankBitsAttr>(S, D, A);
8135 for (
unsigned I = 0; I < A.
getNumArgs(); ++I) {
8143 Expr **Exprs,
unsigned Size) {
8144 SYCLIntelBankBitsAttr TmpAttr(Context, CI, Exprs, Size);
8147 bool ListIsValueDep =
false;
8148 for (
auto *E : TmpAttr.args()) {
8156 if (!
Value.isNonNegative()) {
8157 Diag(E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
8164 Values.push_back(
Value.getExtValue());
8168 if (!ListIsValueDep && Values.size() > 1) {
8169 bool ListIsAscending = Values[0] < Values[1];
8170 for (
int I = 0, E = Values.size() - 1; I < E; ++I) {
8171 if (Values[I + 1] != Values[I] + (ListIsAscending ? 1 : -1)) {
8172 Diag(CI.
getLoc(), diag::err_bankbits_non_consecutive) << &TmpAttr;
8179 if (
auto *NBA = D->
getAttr<SYCLIntelNumBanksAttr>()) {
8180 Expr *E = NBA->getValue();
8185 if (Args.size() !=
Value.ceilLogBase2()) {
8186 Diag(TmpAttr.getLoc(), diag::err_bankbits_numbanks_conflicting);
8191 llvm::APInt Num(32, (
unsigned)(1 << Args.size()));
8194 D->
addAttr(SYCLIntelNumBanksAttr::CreateImplicit(Context, NBE));
8201 CheckValidFPGAMemoryAttributesVar(*
this, D)) {
8202 Diag(CI.
getLoc(), diag::err_fpga_attribute_incorrect_variable)
8207 if (!D->
hasAttr<SYCLIntelMemoryAttr>())
8208 D->
addAttr(SYCLIntelMemoryAttr::CreateImplicit(
8209 Context, SYCLIntelMemoryAttr::Default));
8212 SYCLIntelBankBitsAttr(Context, CI, Args.data(), Args.size()));
8222 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
8228 Diag(E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
8236 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
8238 (!(isa<FieldDecl>(D) ||
8239 (VD->
getKind() != Decl::ImplicitParam &&
8240 VD->
getKind() != Decl::NonTypeTemplateParm &&
8241 VD->
getKind() != Decl::ParmVar &&
8243 SYCL().isTypeDecoratedWithDeclAttribute<SYCLDeviceGlobalAttr>(
8245 Diag(CI.
getLoc(), diag::err_fpga_attribute_invalid_decl) << CI;
8252 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelPrivateCopiesAttr>()) {
8256 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
8257 if (ArgVal != DeclExpr->getResultAsAPSInt()) {
8258 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << CI;
8259 Diag(DeclAttr->getLoc(), diag::note_previous_attribute);
8269 if (!D->
hasAttr<SYCLIntelMemoryAttr>())
8270 D->
addAttr(SYCLIntelMemoryAttr::CreateImplicit(
8271 Context, SYCLIntelMemoryAttr::Default));
8273 D->
addAttr(::
new (Context) SYCLIntelPrivateCopiesAttr(Context, CI, E));
8276 static void handleSYCLIntelPrivateCopiesAttr(
Sema &S,
Decl *D,
8289 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
8295 if (ArgVal < 0 || ArgVal > 1) {
8296 Diag(E->
getBeginLoc(), diag::err_attribute_argument_is_not_valid) << CI;
8304 CheckValidFPGAMemoryAttributesVar(*
this, D)) {
8305 Diag(CI.
getLoc(), diag::err_fpga_attribute_incorrect_variable)
8312 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelForcePow2DepthAttr>()) {
8316 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
8317 if (ArgVal != DeclExpr->getResultAsAPSInt()) {
8318 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << CI;
8319 Diag(DeclAttr->getLoc(), diag::note_previous_attribute);
8329 if (!D->
hasAttr<SYCLIntelMemoryAttr>())
8330 D->
addAttr(SYCLIntelMemoryAttr::CreateImplicit(
8331 Context, SYCLIntelMemoryAttr::Default));
8333 D->
addAttr(::
new (Context) SYCLIntelForcePow2DepthAttr(Context, CI, E));
8336 SYCLIntelForcePow2DepthAttr *
8338 const SYCLIntelForcePow2DepthAttr &A) {
8341 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelForcePow2DepthAttr>()) {
8342 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getValue())) {
8343 if (
const auto *MergeExpr = dyn_cast<ConstantExpr>(A.getValue())) {
8344 if (DeclExpr->getResultAsAPSInt() != MergeExpr->getResultAsAPSInt()) {
8345 Diag(DeclAttr->getLoc(), diag::warn_duplicate_attribute) << &A;
8346 Diag(A.getLoc(), diag::note_previous_attribute);
8354 return ::new (Context) SYCLIntelForcePow2DepthAttr(Context, A, A.getValue());
8357 static void handleSYCLIntelForcePow2DepthAttr(
Sema &S,
Decl *D,
8365 if (!checkFunctionOrMethodParameterIndex(S, D, AL, 1, AL.
getArgAsExpr(0),
8375 static void handlePatchableFunctionEntryAttr(
Sema &S,
Decl *D,
8377 uint32_t Count = 0,
Offset = 0;
8385 S.
Diag(
getAttrLoc(AL), diag::err_attribute_argument_out_of_range)
8396 VarDecl *VD = cast<VarDecl>(D);
8402 Diag(CI.
getLoc(), diag::err_attribute_wrong_decl_type_str)
8404 <<
"SYCL pipe storage declaration";
8413 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
8420 Diag(E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
8427 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelPipeIOAttr>()) {
8431 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getID())) {
8432 if (ArgVal != DeclExpr->getResultAsAPSInt()) {
8433 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << CI;
8434 Diag(DeclAttr->getLoc(), diag::note_previous_attribute);
8442 D->
addAttr(::
new (Context) SYCLIntelPipeIOAttr(Context, CI, E));
8445 SYCLIntelPipeIOAttr *
8449 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelPipeIOAttr>()) {
8450 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getID())) {
8451 if (
const auto *MergeExpr = dyn_cast<ConstantExpr>(A.getID())) {
8452 if (DeclExpr->getResultAsAPSInt() != MergeExpr->getResultAsAPSInt()) {
8453 Diag(DeclAttr->getLoc(), diag::err_disallowed_duplicate_attribute)
8455 Diag(A.getLoc(), diag::note_conflicting_attribute);
8463 return ::new (Context) SYCLIntelPipeIOAttr(Context, A, A.getID());
8472 Decl *D,
const SYCLIntelMaxConcurrencyAttr &A) {
8475 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelMaxConcurrencyAttr>()) {
8476 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getNExpr())) {
8477 if (
const auto *MergeExpr = dyn_cast<ConstantExpr>(A.getNExpr())) {
8478 if (DeclExpr->getResultAsAPSInt() != MergeExpr->getResultAsAPSInt()) {
8479 Diag(DeclAttr->getLoc(), diag::warn_duplicate_attribute) << &A;
8480 Diag(A.getLoc(), diag::note_previous_attribute);
8488 return ::new (Context) SYCLIntelMaxConcurrencyAttr(Context, A, A.getNExpr());
8496 ExprResult Res = VerifyIntegerConstantExpression(E, &ArgVal);
8503 Diag(E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
8510 if (
const auto *DeclAttr = D->
getAttr<SYCLIntelMaxConcurrencyAttr>()) {
8514 if (
const auto *DeclExpr = dyn_cast<ConstantExpr>(DeclAttr->getNExpr())) {
8515 if (ArgVal != DeclExpr->getResultAsAPSInt()) {
8516 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << CI;
8517 Diag(DeclAttr->getLoc(), diag::note_previous_attribute);
8525 D->
addAttr(::
new (Context) SYCLIntelMaxConcurrencyAttr(Context, CI, E));
8536 static bool checkAddIRAttributesFilterListExpr(
Expr *FilterListArg,
Sema &S,
8538 const auto *FilterListE = cast<InitListExpr>(FilterListArg);
8539 for (
const Expr *FilterElemE : FilterListE->inits())
8540 if (!isa<StringLiteral>(FilterElemE))
8541 return S.
Diag(FilterElemE->getBeginLoc(),
8542 diag::err_sycl_add_ir_attribute_invalid_filter)
8548 static bool isAddIRAttributesValidStringType(
QualType T) {
8552 ? cast<ArrayType>(
T.getTypePtr())->getElementType()
8559 static bool checkAddIRAttributesNameExpr(
Expr *NameArg,
Sema &S,
8562 if (isAddIRAttributesValidStringType(NameArg->
getType()))
8566 diag::err_sycl_add_ir_attribute_invalid_name)
8572 static bool checkAddIRAttributesValueExpr(
Expr *ValArg,
Sema &S,
8575 if (isAddIRAttributesValidStringType(ValType) || ValType->
isNullPtrType() ||
8580 diag::err_sycl_add_ir_attribute_invalid_value)
8586 static bool evaluateAddIRAttributesArgs(
Expr **Args,
size_t ArgsSize,
Sema &S,
8591 bool HasFilter = ArgsSize && isa<InitListExpr>(Args[0]);
8592 if (HasFilter && checkAddIRAttributesFilterListExpr(Args[0], S, CI))
8596 bool HasDependentArg =
false;
8597 for (
unsigned I = HasFilter; I < ArgsSize; I++) {
8600 if (isa<InitListExpr>(E))
8602 diag::err_sycl_add_ir_attr_filter_list_invalid_arg)
8606 HasDependentArg =
true;
8615 for (
auto &Note : Notes)
8624 if (!HasDependentArg && ArgsSize && (ArgsSize - HasFilter) & 1)
8625 return S.
Diag(CI.
getLoc(), diag::err_sycl_add_ir_attribute_must_have_pairs)
8630 unsigned MidArg = (ArgsSize - HasFilter) / 2 + HasFilter;
8631 if (!HasDependentArg) {
8632 for (
unsigned I = HasFilter; I < ArgsSize; ++I) {
8633 if ((I < MidArg && checkAddIRAttributesNameExpr(Args[I], S, CI)) ||
8634 (I >= MidArg && checkAddIRAttributesValueExpr(Args[I], S, CI)))
8641 static bool hasDependentExpr(
Expr **Exprs,
const size_t ExprsSize) {
8642 return std::any_of(Exprs, Exprs + ExprsSize, [](
const Expr *E) {
8647 static bool hasSameSYCLAddIRAttributes(
8648 const SmallVector<std::pair<std::string, std::string>, 4> &LAttrs,
8649 const SmallVector<std::pair<std::string, std::string>, 4> &RAttrs) {
8650 std::set<std::pair<std::string, std::string>> LNameValSet{LAttrs.begin(),
8652 std::set<std::pair<std::string, std::string>> RNameValSet{RAttrs.begin(),
8654 return LNameValSet == RNameValSet;
8657 template <
typename AddIRAttrT>
8658 static bool checkSYCLAddIRAttributesMergeability(
const AddIRAttrT &NewAttr,
8659 const AddIRAttrT &ExistingAttr,
8664 if (!hasDependentExpr(NewAttr.args_begin(), NewAttr.args_size()) &&
8665 !hasDependentExpr(ExistingAttr.args_begin(), ExistingAttr.args_size()) &&
8666 (NewAttr.getAttributeFilter() != ExistingAttr.getAttributeFilter() ||
8667 !hasSameSYCLAddIRAttributes(
8668 NewAttr.getAttributeNameValuePairs(Context),
8669 ExistingAttr.getAttributeNameValuePairs(Context)))) {
8670 S.
Diag(ExistingAttr.getLoc(), diag::err_duplicate_attribute) << &NewAttr;
8671 S.
Diag(NewAttr.getLoc(), diag::note_conflicting_attribute);
8678 const auto *AddIRFuncAttr = D->
getAttr<SYCLAddIRAttributesFunctionAttr>();
8683 if (!AddIRFuncAttr ||
8684 hasDependentExpr(AddIRFuncAttr->args_begin(), AddIRFuncAttr->args_size()))
8689 size_t NumArgsWithoutFilter =
8690 AddIRFuncAttr->args_size() - (AddIRFuncAttr->hasFilterList() ? 1 : 0);
8691 if (NumArgsWithoutFilter == 0)
8697 if (NumArgsWithoutFilter == 2) {
8698 auto NameValuePairs = AddIRFuncAttr->getAttributeNameValuePairs(Context);
8699 if (NameValuePairs.size() > 0 &&
8700 NameValuePairs[0].first ==
"sycl-single-task")
8705 for (
const auto *
Attr : std::vector<AttributeCommonInfo *>{
8706 D->
getAttr<SYCLReqdWorkGroupSizeAttr>(),
8707 D->
getAttr<IntelReqdSubGroupSizeAttr>(),
8708 D->
getAttr<SYCLWorkGroupSizeHintAttr>(),
8709 D->
getAttr<SYCLDeviceHasAttr>()})
8711 Diag(
Attr->
getLoc(), diag::warn_sycl_old_and_new_kernel_attributes)
8716 Decl *D,
const SYCLAddIRAttributesFunctionAttr &A) {
8717 if (
const auto *ExistingAttr =
8718 D->
getAttr<SYCLAddIRAttributesFunctionAttr>()) {
8719 checkSYCLAddIRAttributesMergeability(A, *ExistingAttr, *
this);
8722 return A.clone(Context);
8728 if (
const auto *FuncD = dyn_cast<FunctionDecl>(D)) {
8729 if (FuncD->isDefaulted()) {
8730 Diag(CI.
getLoc(), diag::err_disallow_attribute_on_func) << CI << 0;
8733 if (FuncD->isDeleted()) {
8734 Diag(CI.
getLoc(), diag::err_disallow_attribute_on_func) << CI << 1;
8739 auto *
Attr = SYCLAddIRAttributesFunctionAttr::Create(Context, Args.data(),
8741 if (evaluateAddIRAttributesArgs(
Attr->args_begin(),
Attr->args_size(), *
this,
8753 if (D->
hasAttr<SYCLDeviceAttr>())
8759 if (hasDependentExpr(
Attr->args_begin(),
Attr->args_size()))
8763 Attr->getFilteredAttributeNameValuePairs(Context);
8765 for (
const auto &[Key,
Value] : Pairs) {
8766 if (Key ==
"indirectly-callable") {
8767 D->
addAttr(SYCLDeviceAttr::CreateImplicit(Context));
8773 static void handleSYCLAddIRAttributesFunctionAttr(
Sema &S,
Decl *D,
8777 for (
unsigned I = 0; I < A.
getNumArgs(); I++) {
8785 SYCLAddIRAttributesKernelParameterAttr *
8787 Decl *D,
const SYCLAddIRAttributesKernelParameterAttr &A) {
8788 if (
const auto *ExistingAttr =
8789 D->
getAttr<SYCLAddIRAttributesKernelParameterAttr>()) {
8790 checkSYCLAddIRAttributesMergeability(A, *ExistingAttr, *
this);
8793 return A.clone(Context);
8798 auto *
Attr = SYCLAddIRAttributesKernelParameterAttr::Create(
8799 Context, Args.data(), Args.size(), CI);
8800 if (evaluateAddIRAttributesArgs(
Attr->args_begin(),
Attr->args_size(), *
this,
8806 static void handleSYCLAddIRAttributesKernelParameterAttr(
Sema &S,
Decl *D,
8810 for (
unsigned I = 0; I < A.
getNumArgs(); I++) {
8818 SYCLAddIRAttributesGlobalVariableAttr *
8820 Decl *D,
const SYCLAddIRAttributesGlobalVariableAttr &A) {
8821 if (
const auto *ExistingAttr =
8822 D->
getAttr<SYCLAddIRAttributesGlobalVariableAttr>()) {
8823 checkSYCLAddIRAttributesMergeability(A, *ExistingAttr, *
this);
8826 return A.clone(Context);
8831 auto *
Attr = SYCLAddIRAttributesGlobalVariableAttr::Create(
8832 Context, Args.data(), Args.size(), CI);
8833 if (evaluateAddIRAttributesArgs(
Attr->args_begin(),
Attr->args_size(), *
this,
8839 static void handleSYCLAddIRAttributesGlobalVariableAttr(
Sema &S,
Decl *D,
8843 for (
unsigned I = 0; I < A.
getNumArgs(); I++) {
8852 Decl *D,
const SYCLAddIRAnnotationsMemberAttr &A) {
8853 if (
const auto *ExistingAttr = D->
getAttr<SYCLAddIRAnnotationsMemberAttr>()) {
8854 checkSYCLAddIRAttributesMergeability(A, *ExistingAttr, *
this);
8857 return A.clone(Context);
8863 auto *
Attr = SYCLAddIRAnnotationsMemberAttr::Create(Context, Args.data(),
8865 if (evaluateAddIRAttributesArgs(
Attr->args_begin(),
Attr->args_size(), *
this,
8871 static void handleSYCLAddIRAnnotationsMemberAttr(
Sema &S,
Decl *D,
8875 for (
unsigned I = 0; I < A.
getNumArgs(); I++) {
8884 struct IntrinToName {
8891 static bool ArmBuiltinAliasValid(
unsigned BuiltinID, StringRef AliasName,
8893 const char *IntrinNames) {
8894 AliasName.consume_front(
"__arm_");
8895 const IntrinToName *It =
8896 llvm::lower_bound(Map, BuiltinID, [](
const IntrinToName &L,
unsigned Id) {
8899 if (It == Map.end() || It->Id != BuiltinID)
8901 StringRef FullName(&IntrinNames[It->FullName]);
8902 if (AliasName == FullName)
8904 if (It->ShortName == -1)
8906 StringRef ShortName(&IntrinNames[It->ShortName]);
8907 return AliasName == ShortName;
8910 static bool ArmMveAliasValid(
unsigned BuiltinID, StringRef AliasName) {
8911 #include "clang/Basic/arm_mve_builtin_aliases.inc"
8915 return ArmBuiltinAliasValid(BuiltinID, AliasName, Map, IntrinNames);
8918 static bool ArmCdeAliasValid(
unsigned BuiltinID, StringRef AliasName) {
8919 #include "clang/Basic/arm_cde_builtin_aliases.inc"
8920 return ArmBuiltinAliasValid(BuiltinID, AliasName, Map, IntrinNames);
8923 static bool ArmSveAliasValid(
ASTContext &Context,
unsigned BuiltinID,
8924 StringRef AliasName) {
8931 static bool ArmSmeAliasValid(
ASTContext &Context,
unsigned BuiltinID,
8932 StringRef AliasName) {
8941 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
8948 StringRef AliasName = cast<FunctionDecl>(D)->getIdentifier()->getName();
8951 if ((IsAArch64 && !ArmSveAliasValid(S.
Context, BuiltinID, AliasName) &&
8952 !ArmSmeAliasValid(S.
Context, BuiltinID, AliasName)) ||
8953 (!IsAArch64 && !ArmMveAliasValid(BuiltinID, AliasName) &&
8954 !ArmCdeAliasValid(BuiltinID, AliasName))) {
8955 S.
Diag(AL.
getLoc(), diag::err_attribute_arm_builtin_alias);
8962 static bool RISCVAliasValid(
unsigned BuiltinID, StringRef AliasName) {
8967 static bool SYCLAliasValid(
ASTContext &Context,
unsigned BuiltinID) {
8968 constexpr llvm::StringLiteral Prefix =
"__builtin_intel_sycl";
8972 static void handleBuiltinAliasAttr(
Sema &S,
Decl *D,
8975 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
8982 StringRef AliasName = cast<FunctionDecl>(D)->getIdentifier()->getName();
8989 if ((IsAArch64 && !ArmSveAliasValid(S.
Context, BuiltinID, AliasName)) ||
8990 (IsARM && !ArmMveAliasValid(BuiltinID, AliasName) &&
8991 !ArmCdeAliasValid(BuiltinID, AliasName)) ||
8992 (IsRISCV && !RISCVAliasValid(BuiltinID, AliasName)) ||
8993 (IsSYCL && !SYCLAliasValid(S.
Context, BuiltinID)) ||
8994 (!IsAArch64 && !IsARM && !IsRISCV && !IsHLSL && !IsSYCL)) {
8995 S.
Diag(AL.
getLoc(), diag::err_attribute_builtin_alias) << AL;
9006 if (
auto *CRD = dyn_cast<CXXRecordDecl>(D);
9007 !CRD || !(CRD->isClass() || CRD->isStruct())) {
9013 handleSimpleAttribute<TypeNullableAttr>(S, D, AL);
9018 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
9024 assert(ParmTSI &&
"no type source info for attribute argument");
9026 diag::err_incomplete_type);
9034 static bool isValidSubjectOfNSReturnsRetainedAttribute(
QualType QT) {
9038 static bool isValidSubjectOfNSAttribute(
QualType QT) {
9043 static bool isValidSubjectOfCFAttribute(
QualType QT) {
9045 isValidSubjectOfNSAttribute(QT);
9048 static bool isValidSubjectOfOSAttribute(
QualType QT) {
9056 RetainOwnershipKind K,
9057 bool IsTemplateInstantiation) {
9061 handleSimpleAttributeOrDiagnose<OSConsumedAttr>(
9062 *
this, VD, CI, isValidSubjectOfOSAttribute(VD->
getType()),
9063 diag::warn_ns_attribute_wrong_parameter_type,
9066 case RetainOwnershipKind::NS:
9067 handleSimpleAttributeOrDiagnose<NSConsumedAttr>(
9068 *
this, VD, CI, isValidSubjectOfNSAttribute(VD->
getType()),
9074 ((IsTemplateInstantiation && getLangOpts().ObjCAutoRefCount)
9075 ? diag::err_ns_attribute_wrong_parameter_type
9076 : diag::warn_ns_attribute_wrong_parameter_type),
9079 case RetainOwnershipKind::CF:
9080 handleSimpleAttributeOrDiagnose<CFConsumedAttr>(
9081 *
this, VD, CI, isValidSubjectOfCFAttribute(VD->
getType()),
9082 diag::warn_ns_attribute_wrong_parameter_type,
9089 parsedAttrToRetainOwnershipKind(
const ParsedAttr &AL) {
9091 case ParsedAttr::AT_CFConsumed:
9092 case ParsedAttr::AT_CFReturnsRetained:
9093 case ParsedAttr::AT_CFReturnsNotRetained:
9095 case ParsedAttr::AT_OSConsumesThis:
9096 case ParsedAttr::AT_OSConsumed:
9097 case ParsedAttr::AT_OSReturnsRetained:
9098 case ParsedAttr::AT_OSReturnsNotRetained:
9099 case ParsedAttr::AT_OSReturnsRetainedOnZero:
9100 case ParsedAttr::AT_OSReturnsRetainedOnNonZero:
9102 case ParsedAttr::AT_NSConsumesSelf:
9103 case ParsedAttr::AT_NSConsumed:
9104 case ParsedAttr::AT_NSReturnsRetained:
9105 case ParsedAttr::AT_NSReturnsNotRetained:
9106 case ParsedAttr::AT_NSReturnsAutoreleased:
9109 llvm_unreachable(
"Wrong argument supplied");
9114 if (isValidSubjectOfNSReturnsRetainedAttribute(QT))
9117 Diag(
Loc, diag::warn_ns_attribute_wrong_return_type)
9118 <<
"'ns_returns_retained'" << 0 << 0;
9123 static bool isValidOSObjectOutParameter(
const Decl *D) {
9124 const auto *PVD = dyn_cast<ParmVarDecl>(D);
9129 return !PT.
isNull() && isValidSubjectOfOSAttribute(PT);
9132 static void handleXReturnsXRetainedAttr(
Sema &S,
Decl *D,
9137 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
9140 (AL.
getKind() == ParsedAttr::AT_NSReturnsRetained)) {
9142 }
else if (
const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
9143 ReturnType = PD->getType();
9144 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
9146 }
else if (
const auto *Param = dyn_cast<ParmVarDecl>(D)) {
9153 if (ReturnType.
isNull()) {
9154 S.
Diag(D->
getBeginLoc(), diag::warn_ns_attribute_wrong_parameter_type)
9163 default: llvm_unreachable(
"invalid ownership attribute");
9164 case ParsedAttr::AT_NSReturnsRetained:
9165 case ParsedAttr::AT_NSReturnsAutoreleased:
9166 case ParsedAttr::AT_NSReturnsNotRetained:
9170 case ParsedAttr::AT_OSReturnsRetained:
9171 case ParsedAttr::AT_OSReturnsNotRetained:
9172 case ParsedAttr::AT_CFReturnsRetained:
9173 case ParsedAttr::AT_CFReturnsNotRetained:
9179 << ExpectedDeclKind;
9185 unsigned ParmDiagID = 2;
9187 default: llvm_unreachable(
"invalid ownership attribute");
9188 case ParsedAttr::AT_NSReturnsRetained:
9189 TypeOK = isValidSubjectOfNSReturnsRetainedAttribute(ReturnType);
9193 case ParsedAttr::AT_NSReturnsAutoreleased:
9194 case ParsedAttr::AT_NSReturnsNotRetained:
9195 TypeOK = isValidSubjectOfNSAttribute(ReturnType);
9199 case ParsedAttr::AT_CFReturnsRetained:
9200 case ParsedAttr::AT_CFReturnsNotRetained:
9201 TypeOK = isValidSubjectOfCFAttribute(ReturnType);
9205 case ParsedAttr::AT_OSReturnsRetained:
9206 case ParsedAttr::AT_OSReturnsNotRetained:
9207 TypeOK = isValidSubjectOfOSAttribute(ReturnType);
9217 if (isa<ParmVarDecl>(D)) {
9218 S.
Diag(D->
getBeginLoc(), diag::warn_ns_attribute_wrong_parameter_type)
9219 << AL << ParmDiagID << AL.
getRange();
9227 if (isa<ObjCMethodDecl>(D))
9228 SubjectKind = Method;
9229 else if (isa<ObjCPropertyDecl>(D))
9232 << AL << SubjectKind << Cf << AL.
getRange();
9239 llvm_unreachable(
"invalid ownership attribute");
9240 case ParsedAttr::AT_NSReturnsAutoreleased:
9241 handleSimpleAttribute<NSReturnsAutoreleasedAttr>(S, D, AL);
9243 case ParsedAttr::AT_CFReturnsNotRetained:
9244 handleSimpleAttribute<CFReturnsNotRetainedAttr>(S, D, AL);
9246 case ParsedAttr::AT_NSReturnsNotRetained:
9247 handleSimpleAttribute<NSReturnsNotRetainedAttr>(S, D, AL);
9249 case ParsedAttr::AT_CFReturnsRetained:
9250 handleSimpleAttribute<CFReturnsRetainedAttr>(S, D, AL);
9252 case ParsedAttr::AT_NSReturnsRetained:
9253 handleSimpleAttribute<NSReturnsRetainedAttr>(S, D, AL);
9255 case ParsedAttr::AT_OSReturnsRetained:
9256 handleSimpleAttribute<OSReturnsRetainedAttr>(S, D, AL);
9258 case ParsedAttr::AT_OSReturnsNotRetained:
9259 handleSimpleAttribute<OSReturnsNotRetainedAttr>(S, D, AL);
9264 static void handleObjCReturnsInnerPointerAttr(
Sema &S,
Decl *D,
9266 const int EP_ObjCMethod = 1;
9267 const int EP_ObjCProperty = 2;
9271 if (isa<ObjCMethodDecl>(D))
9272 resultType = cast<ObjCMethodDecl>(D)->getReturnType();
9274 resultType = cast<ObjCPropertyDecl>(D)->getType();
9280 << (isa<ObjCMethodDecl>(D) ? EP_ObjCMethod : EP_ObjCProperty)
9290 static void handleObjCRequiresSuperAttr(
Sema &S,
Decl *D,
9292 const auto *Method = cast<ObjCMethodDecl>(D);
9295 if (
const auto *PDecl = dyn_cast_if_present<ObjCProtocolDecl>(DC)) {
9296 S.
Diag(D->
getBeginLoc(), diag::warn_objc_requires_super_protocol) << Attrs
9298 S.
Diag(PDecl->getLocation(), diag::note_protocol_decl);
9302 S.
Diag(D->
getBeginLoc(), diag::warn_objc_requires_super_protocol) << Attrs
9311 if (!isa<TagDecl>(D)) {
9317 Attr.isArgIdent(0) ?
Attr.getArgAsIdent(0) :
nullptr;
9318 if (!IdentLoc || !IdentLoc->
Ident) {
9321 if (
Attr.isArgExpr(0) &&
Attr.getArgAsExpr(0))
9322 Loc =
Attr.getArgAsExpr(0)->getBeginLoc();
9324 S.
Diag(
Loc, diag::err_nserrordomain_invalid_decl) << 0;
9330 Sema::LookupNameKind::LookupOrdinaryName);
9332 S.
Diag(IdentLoc->
Loc, diag::err_nserrordomain_invalid_decl)
9333 << 1 << IdentLoc->
Ident;
9350 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
9352 S.
Diag(AL.
getLoc(), diag::err_objc_attr_typedef_not_id) << AL;
9359 S.
Diag(AL.
getLoc(), diag::err_objc_attr_typedef_not_void_pointer);
9367 static void handleObjCBridgeMutableAttr(
Sema &S,
Decl *D,
9380 static void handleObjCBridgeRelatedAttr(
Sema &S,
Decl *D,
9384 if (!RelatedClass) {
9393 S.
Context, AL, RelatedClass, ClassMethod, InstanceMethod));
9396 static void handleObjCDesignatedInitializer(
Sema &S,
Decl *D,
9402 if (!isa<ObjCInterfaceDecl>(Ctx) &&
9403 !(isa<ObjCCategoryDecl>(Ctx) &&
9404 cast<ObjCCategoryDecl>(Ctx)->IsClassExtension())) {
9410 if (
auto *CatDecl = dyn_cast<ObjCCategoryDecl>(Ctx))
9411 IFace = CatDecl->getClassInterface();
9413 IFace = cast<ObjCInterfaceDecl>(Ctx);
9423 StringRef MetaDataName;
9427 ObjCRuntimeNameAttr(S.
Context, AL, MetaDataName));
9435 bool notify =
false;
9437 auto *RD = dyn_cast<RecordDecl>(D);
9444 ObjCBoxableAttr *BoxableAttr =
9445 ::new (S.
Context) ObjCBoxableAttr(S.Context, AL);
9446 RD->addAttr(BoxableAttr);
9451 L->AddedAttributeToRecord(BoxableAttr, RD);
9465 static void handleObjCPreciseLifetimeAttr(
Sema &S,
Decl *D,
9467 const auto *VD = cast<ValueDecl>(D);
9472 S.
Diag(AL.
getLoc(), diag::err_objc_precise_lifetime_bad_type)
9487 "didn't infer lifetime for non-dependent type?");
9496 S.
Diag(AL.
getLoc(), diag::warn_objc_precise_lifetime_meaningless)
9523 if (
const auto *Other = D->
getAttr<SwiftBridgeAttr>()) {
9524 if (
Other->getSwiftType() != BT)
9525 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
9541 if (
const auto *
ID = OPT->getInterfaceDecl())
9561 S.
Diag(AL.
getLoc(), diag::err_attr_swift_error_no_error_parameter)
9562 << AL << isa<ObjCMethodDecl>(D);
9574 S.
Diag(AL.
getLoc(), diag::err_attr_swift_error_return_type)
9585 S.
Diag(AL.
getLoc(), diag::err_attr_swift_error_return_type)
9591 if (D->isInvalidDecl())
9595 SwiftErrorAttr::ConventionKind Convention;
9596 if (!SwiftErrorAttr::ConvertStrToConventionKind(
Loc->Ident->getName(),
9598 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
9599 << AL <<
Loc->Ident;
9603 switch (Convention) {
9608 case SwiftErrorAttr::NonNullError:
9609 if (!hasErrorParameter(S, D, AL))
9613 case SwiftErrorAttr::NullResult:
9614 if (!hasErrorParameter(S, D, AL) || !hasPointerResult(S, D, AL))
9618 case SwiftErrorAttr::NonZeroResult:
9619 case SwiftErrorAttr::ZeroResult:
9620 if (!hasErrorParameter(S, D, AL) || !hasIntegerResult(S, D, AL))
9625 D->addAttr(::
new (S.
Context) SwiftErrorAttr(S.
Context, AL, Convention));
9628 static void checkSwiftAsyncErrorBlock(
Sema &S,
Decl *D,
9629 const SwiftAsyncErrorAttr *ErrorAttr,
9630 const SwiftAsyncAttr *AsyncAttr) {
9633 S.
Diag(AsyncAttr->getLocation(),
9634 diag::err_swift_async_error_without_swift_async)
9635 << AsyncAttr << isa<ObjCMethodDecl>(D);
9641 D, AsyncAttr->getCompletionHandlerIndex().getASTIndex());
9644 const auto *FuncTy = HandlerParam->
getType()
9650 BlockParams = FuncTy->getParamTypes();
9652 switch (ErrorAttr->getConvention()) {
9653 case SwiftAsyncErrorAttr::ZeroArgument:
9654 case SwiftAsyncErrorAttr::NonZeroArgument: {
9655 uint32_t
ParamIdx = ErrorAttr->getHandlerParamIdx();
9657 S.
Diag(ErrorAttr->getLocation(),
9658 diag::err_attribute_argument_out_of_bounds) << ErrorAttr << 2;
9664 ErrorAttr->getConvention() == SwiftAsyncErrorAttr::ZeroArgument
9666 :
"nonzero_argument";
9667 S.
Diag(ErrorAttr->getLocation(), diag::err_swift_async_error_non_integral)
9668 << ErrorAttr << ConvStr <<
ParamIdx << ErrorParam;
9673 case SwiftAsyncErrorAttr::NonNullError: {
9674 bool AnyErrorParams =
false;
9675 for (
QualType Param : BlockParams) {
9678 if (
const auto *
ID = ObjCPtrTy->getInterfaceDecl()) {
9680 AnyErrorParams =
true;
9686 if (
const auto *PtrTy = Param->getAs<
PointerType>()) {
9687 if (
const auto *RT = PtrTy->getPointeeType()->getAs<
RecordType>()) {
9689 AnyErrorParams =
true;
9696 if (!AnyErrorParams) {
9697 S.
Diag(ErrorAttr->getLocation(),
9698 diag::err_swift_async_error_no_error_parameter)
9699 << ErrorAttr << isa<ObjCMethodDecl>(D);
9711 SwiftAsyncErrorAttr::ConventionKind ConvKind;
9712 if (!SwiftAsyncErrorAttr::ConvertStrToConventionKind(IDLoc->
Ident->
getName(),
9714 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
9715 << AL << IDLoc->
Ident;
9721 case SwiftAsyncErrorAttr::ZeroArgument:
9722 case SwiftAsyncErrorAttr::NonZeroArgument: {
9731 case SwiftAsyncErrorAttr::NonNullError:
9740 ::new (S.
Context) SwiftAsyncErrorAttr(S.Context, AL, ConvKind,
ParamIdx);
9741 D->addAttr(ErrorAttr);
9743 if (auto *AsyncAttr = D->getAttr<SwiftAsyncAttr>())
9744 checkSwiftAsyncErrorBlock(S, D, ErrorAttr, AsyncAttr);
9757 StringRef Name,
unsigned &SwiftParamCount,
9758 bool &IsSingleParamInit) {
9759 SwiftParamCount = 0;
9760 IsSingleParamInit =
false;
9763 bool IsGetter =
false, IsSetter =
false;
9764 if (Name.consume_front(
"getter:"))
9766 else if (Name.consume_front(
"setter:"))
9769 if (Name.back() !=
')') {
9770 S.
Diag(
Loc, diag::warn_attr_swift_name_function) << AL;
9774 bool IsMember =
false;
9777 std::tie(BaseName, Parameters) = Name.split(
'(');
9781 std::tie(ContextName, BaseName) = BaseName.split(
'.');
9782 if (BaseName.empty()) {
9783 BaseName = ContextName;
9784 ContextName = StringRef();
9786 S.
Diag(
Loc, diag::warn_attr_swift_name_invalid_identifier)
9794 S.
Diag(
Loc, diag::warn_attr_swift_name_invalid_identifier)
9799 bool IsSubscript = BaseName ==
"subscript";
9801 if (IsSubscript && !IsGetter && !IsSetter) {
9802 S.
Diag(
Loc, diag::warn_attr_swift_name_subscript_invalid_parameter)
9808 S.
Diag(
Loc, diag::warn_attr_swift_name_missing_parameters) << AL;
9812 assert(
Parameters.back() ==
')' &&
"expected ')'");
9818 S.
Diag(
Loc, diag::warn_attr_swift_name_subscript_invalid_parameter)
9824 S.
Diag(
Loc, diag::warn_attr_swift_name_setter_parameters) << AL;
9832 S.
Diag(
Loc, diag::warn_attr_swift_name_function) << AL;
9836 StringRef CurrentParam;
9837 std::optional<unsigned> SelfLocation;
9838 unsigned NewValueCount = 0;
9839 std::optional<unsigned> NewValueLocation;
9841 std::tie(CurrentParam, Parameters) =
Parameters.split(
':');
9844 S.
Diag(
Loc, diag::warn_attr_swift_name_invalid_identifier)
9849 if (IsMember && CurrentParam ==
"self") {
9854 S.
Diag(
Loc, diag::warn_attr_swift_name_multiple_selfs) << AL;
9859 SelfLocation = SwiftParamCount;
9860 }
else if (CurrentParam ==
"newValue") {
9867 NewValueLocation = SwiftParamCount;
9874 if (IsSubscript && !SelfLocation) {
9875 S.
Diag(
Loc, diag::warn_attr_swift_name_subscript_invalid_parameter)
9881 SwiftParamCount == 1 && BaseName ==
"init" && CurrentParam !=
"_";
9884 if (IsGetter || IsSetter) {
9886 unsigned NumExpectedParams = IsGetter ? 0 : 1;
9887 unsigned ParamDiag =
9888 IsGetter ? diag::warn_attr_swift_name_getter_parameters
9889 : diag::warn_attr_swift_name_setter_parameters;
9893 ++NumExpectedParams;
9898 if (SwiftParamCount < NumExpectedParams) {
9906 if (!NewValueLocation) {
9907 S.
Diag(
Loc, diag::warn_attr_swift_name_subscript_setter_no_newValue)
9911 if (NewValueCount > 1) {
9912 S.
Diag(
Loc, diag::warn_attr_swift_name_subscript_setter_multiple_newValues)
9918 if (NewValueLocation) {
9919 S.
Diag(
Loc, diag::warn_attr_swift_name_subscript_getter_newValue)
9926 if (SwiftParamCount != NumExpectedParams) {
9938 if (isa<ObjCMethodDecl>(D) || isa<FunctionDecl>(D)) {
9940 unsigned ParamCount;
9942 if (
const auto *Method = dyn_cast<ObjCMethodDecl>(D)) {
9943 ParamCount = Method->getSelector().getNumArgs();
9944 Params = Method->parameters().slice(0, ParamCount);
9946 const auto *F = cast<FunctionDecl>(D);
9948 ParamCount = F->getNumParams();
9949 Params = F->parameters();
9951 if (!F->hasWrittenPrototype()) {
9952 Diag(
Loc, diag::warn_attribute_wrong_decl_type)
9961 if (ParamCount == 0) {
9962 Diag(
Loc, diag::warn_attr_swift_name_decl_missing_params)
9963 << AL << isa<ObjCMethodDecl>(D);
9969 unsigned SwiftParamCount;
9970 bool IsSingleParamInit;
9971 if (!validateSwiftFunctionName(*
this, AL,
Loc, Name,
9972 SwiftParamCount, IsSingleParamInit))
9975 bool ParamCountValid;
9976 if (SwiftParamCount == ParamCount) {
9977 ParamCountValid =
true;
9978 }
else if (SwiftParamCount > ParamCount) {
9979 ParamCountValid = IsSingleParamInit && ParamCount == 0;
9984 unsigned MaybeOutParamCount =
9985 llvm::count_if(Params, [](
const ParmVarDecl *Param) ->
bool {
9992 ParamCountValid = SwiftParamCount + MaybeOutParamCount >= ParamCount;
9995 if (!ParamCountValid) {
9996 Diag(
Loc, diag::warn_attr_swift_name_num_params)
9997 << (SwiftParamCount > ParamCount) << AL << ParamCount
10001 }
else if ((isa<EnumConstantDecl>(D) || isa<ObjCProtocolDecl>(D) ||
10002 isa<ObjCInterfaceDecl>(D) || isa<ObjCPropertyDecl>(D) ||
10003 isa<VarDecl>(D) || isa<TypedefNameDecl>(D) || isa<TagDecl>(D) ||
10004 isa<IndirectFieldDecl>(D) || isa<FieldDecl>(D)) &&
10006 StringRef ContextName, BaseName;
10008 std::tie(ContextName, BaseName) = Name.split(
'.');
10009 if (BaseName.empty()) {
10010 BaseName = ContextName;
10011 ContextName = StringRef();
10013 Diag(
Loc, diag::warn_attr_swift_name_invalid_identifier) << AL
10019 Diag(
Loc, diag::warn_attr_swift_name_invalid_identifier) << AL
10024 Diag(
Loc, diag::warn_attr_swift_name_decl_kind) << AL;
10060 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
10065 SwiftNewTypeAttr::NewtypeKind
Kind;
10067 if (!SwiftNewTypeAttr::ConvertStrToNewtypeKind(II->
getName(),
Kind)) {
10068 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
10072 if (!isa<TypedefNameDecl>(D)) {
10073 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type_str)
10083 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
10090 if (!SwiftAsyncAttr::ConvertStrToKind(II->
getName(),
Kind)) {
10091 S.
Diag(AL.
getLoc(), diag::err_swift_async_no_access) << AL << II;
10106 if (!checkFunctionOrMethodParameterIndex(S, D, AL, 2, HandlerIdx, Idx))
10114 diag::err_swift_async_bad_block_type)
10115 << CompletionBlock->
getType();
10122 diag::err_swift_async_bad_block_type)
10123 << CompletionBlock->
getType();
10129 ::new (S.
Context) SwiftAsyncAttr(S.Context, AL,
Kind, Idx);
10130 D->addAttr(AsyncAttr);
10132 if (auto *ErrorAttr = D->getAttr<SwiftAsyncErrorAttr>())
10133 checkSwiftAsyncErrorBlock(S, D, ErrorAttr, AsyncAttr);
10141 StringRef UuidAsWritten,
MSGuidDecl *GuidDecl) {
10142 if (
const auto *UA = D->getAttr<UuidAttr>()) {
10145 if (!UA->getGuid().empty()) {
10146 Diag(UA->getLocation(), diag::err_mismatched_uuid);
10147 Diag(CI.getLoc(), diag::note_previous_uuid);
10148 D->dropAttr<UuidAttr>();
10152 return ::new (Context) UuidAttr(Context, CI, UuidAsWritten, GuidDecl);
10157 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
10162 StringRef OrigStrRef;
10169 StringRef StrRef = OrigStrRef;
10170 if (StrRef.size() == 38 && StrRef.front() ==
'{' && StrRef.back() ==
'}')
10171 StrRef = StrRef.drop_front().drop_back();
10174 if (StrRef.size() != 36) {
10175 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
10179 for (
unsigned i = 0; i < 36; ++i) {
10180 if (i == 8 || i == 13 || i == 18 || i == 23) {
10181 if (StrRef[i] !=
'-') {
10182 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
10186 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
10193 StrRef.substr(0, 8).getAsInteger(16, Parsed.
Part1);
10194 StrRef.substr(9, 4).getAsInteger(16, Parsed.
Part2);
10195 StrRef.substr(14, 4).getAsInteger(16, Parsed.
Part3);
10196 for (
unsigned i = 0; i != 8; ++i)
10197 StrRef.substr(19 + 2 * i + (i >= 2 ? 1 : 0), 2)
10198 .getAsInteger(16, Parsed.
Part4And5[i]);
10208 S.
Diag(AL.
getLoc(), diag::warn_atl_uuid_deprecated);
10216 llvm::VersionTuple SMVersion =
10218 uint32_t ZMax = 1024;
10219 uint32_t ThreadMax = 1024;
10220 if (SMVersion.getMajor() <= 4) {
10223 }
else if (SMVersion.getMajor() == 5) {
10233 diag::err_hlsl_numthreads_argument_oor) << 0 << 1024;
10241 diag::err_hlsl_numthreads_argument_oor) << 1 << 1024;
10249 diag::err_hlsl_numthreads_argument_oor) << 2 << ZMax;
10253 if (
X * Y * Z > ThreadMax) {
10254 S.
Diag(AL.
getLoc(), diag::err_hlsl_numthreads_invalid) << ThreadMax;
10263 static bool isLegalTypeForHLSLSV_DispatchThreadID(
QualType T) {
10267 return VT->getNumElements() <= 3;
10271 static void handleHLSLSV_DispatchThreadIDAttr(
Sema &S,
Decl *D,
10275 if (isa<FieldDecl>(D)) {
10276 S.
Diag(AL.
getLoc(), diag::err_hlsl_attr_invalid_ast_node)
10277 << AL <<
"parameter";
10281 auto *VD = cast<ValueDecl>(D);
10282 if (!isLegalTypeForHLSLSV_DispatchThreadID(VD->
getType())) {
10283 S.
Diag(AL.
getLoc(), diag::err_hlsl_attr_invalid_type)
10284 << AL <<
"uint/uint2/uint3";
10292 if (!isa<VarDecl>(D) || !isa<HLSLBufferDecl>(D->
getDeclContext())) {
10293 S.
Diag(AL.
getLoc(), diag::err_hlsl_attr_invalid_ast_node)
10294 << AL <<
"shader constant in a constant buffer";
10298 uint32_t SubComponent;
10301 uint32_t Component;
10305 QualType T = cast<VarDecl>(D)->getType().getCanonicalType();
10313 if (IsAggregateTy || Size > 128) {
10314 S.
Diag(AL.
getLoc(), diag::err_hlsl_packoffset_cross_reg_boundary);
10318 if ((Component * 32 + Size) > 128) {
10319 S.
Diag(AL.
getLoc(), diag::err_hlsl_packoffset_cross_reg_boundary);
10324 EltTy = VT->getElementType();
10326 if (Align > 32 && Component == 1) {
10329 S.
Diag(AL.
getLoc(), diag::err_hlsl_packoffset_alignment_mismatch)
10337 HLSLPackOffsetAttr(S.
Context, AL, SubComponent, Component));
10346 HLSLShaderAttr::ShaderType ShaderType;
10347 if (!HLSLShaderAttr::ConvertStrToShaderType(Str, ShaderType)) {
10348 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
10349 << AL << Str << ArgLoc;
10360 static void handleHLSLResourceBindingAttr(
Sema &S,
Decl *D,
10362 StringRef Space =
"space0";
10363 StringRef Slot =
"";
10366 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
10372 StringRef Str =
Loc->Ident->getName();
10379 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
10385 Space =
Loc->Ident->getName();
10386 SpaceArgLoc =
Loc->Loc;
10392 if (!Slot.empty()) {
10400 S.
Diag(ArgLoc, diag::err_hlsl_unsupported_register_type)
10401 << Slot.substr(0, 1);
10405 StringRef SlotNum = Slot.substr(1);
10407 if (SlotNum.getAsInteger(10, Num)) {
10408 S.
Diag(ArgLoc, diag::err_hlsl_unsupported_register_number);
10413 if (!Space.starts_with(
"space")) {
10414 S.
Diag(SpaceArgLoc, diag::err_hlsl_expected_space) << Space;
10417 StringRef SpaceNum = Space.substr(5);
10419 if (SpaceNum.getAsInteger(10, Num)) {
10420 S.
Diag(SpaceArgLoc, diag::err_hlsl_expected_space) << Space;
10426 HLSLResourceBindingAttr *NewAttr =
10427 HLSLResourceBindingAttr::Create(S.
getASTContext(), Slot, Space, AL);
10432 static void handleHLSLParamModifierAttr(
Sema &S,
Decl *D,
10443 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
10456 const auto *VD = cast<VarDecl>(D);
10458 S.
Diag(AL.
getLoc(), diag::err_thread_unsupported);
10462 S.
Diag(AL.
getLoc(), diag::err_declspec_thread_on_thread_variable);
10465 if (VD->hasLocalStorage()) {
10466 S.
Diag(AL.
getLoc(), diag::err_thread_non_global) <<
"__declspec(thread)";
10474 S.
Diag(AL.
getLoc(), diag::warn_unknown_attribute_ignored)
10478 auto *FD = cast<FunctionDecl>(D);
10480 S.
Diag(AL.
getLoc(), diag::err_ms_constexpr_cannot_be_applied)
10484 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
10486 S.
Diag(AL.
getLoc(), diag::err_ms_constexpr_cannot_be_applied)
10496 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
10500 Tags.push_back(Tag);
10503 if (
const auto *NS = dyn_cast<NamespaceDecl>(D)) {
10504 if (!NS->isInline()) {
10505 S.
Diag(AL.
getLoc(), diag::warn_attr_abi_tag_namespace) << 0;
10508 if (NS->isAnonymousNamespace()) {
10509 S.
Diag(AL.
getLoc(), diag::warn_attr_abi_tag_namespace) << 1;
10513 Tags.push_back(NS->getName());
10519 Tags.erase(std::unique(Tags.begin(), Tags.end()), Tags.end());
10522 AbiTagAttr(S.
Context, AL, Tags.data(), Tags.size()));
10528 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 1;
10540 ARMInterruptAttr::InterruptType
Kind;
10541 if (!ARMInterruptAttr::ConvertStrToInterruptType(Str,
Kind)) {
10542 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << Str
10576 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
10582 std::optional<llvm::APSInt> NumParams =
llvm::APSInt(32);
10584 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
10590 unsigned Num = NumParams->getLimitedValue(255);
10592 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
10593 << AL << (
int)NumParams->getSExtValue()
10605 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 1;
10646 if (checkAttrMutualExclusion<Mips16Attr>(S, D, AL))
10649 MipsInterruptAttr::InterruptType
Kind;
10650 if (!MipsInterruptAttr::ConvertStrToInterruptType(Str,
Kind)) {
10651 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
10652 << AL <<
"'" + std::string(Str) +
"'";
10664 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
10673 if (!MaybeNumParams) {
10674 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
10680 unsigned Num = MaybeNumParams->getLimitedValue(255);
10681 if ((Num & 1) || Num > 30) {
10682 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
10683 << AL << (
int)MaybeNumParams->getSExtValue()
10701 cast<NamedDecl>(D)->getDeclName().getCXXOverloadedOperator())) {
10702 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
10710 diag::err_anyx86_interrupt_attribute)
10719 if (NumParams < 1 || NumParams > 2) {
10730 diag::err_anyx86_interrupt_attribute)
10738 unsigned TypeSize =
10742 if (NumParams == 2 &&
10746 diag::err_anyx86_interrupt_attribute)
10767 handleSimpleAttribute<AVRInterruptAttr>(S, D, AL);
10780 handleSimpleAttribute<AVRSignalAttr>(S, D, AL);
10783 static void handleBPFPreserveAIRecord(
Sema &S,
RecordDecl *RD) {
10785 for (
auto *D : RD->
decls()) {
10786 if (D->
hasAttr<BPFPreserveAccessIndexAttr>())
10789 D->
addAttr(BPFPreserveAccessIndexAttr::CreateImplicit(S.
Context));
10790 if (
auto *Rec = dyn_cast<RecordDecl>(D))
10791 handleBPFPreserveAIRecord(S, Rec);
10795 static void handleBPFPreserveAccessIndexAttr(
Sema &S,
Decl *D,
10797 auto *Rec = cast<RecordDecl>(D);
10798 handleBPFPreserveAIRecord(S, Rec);
10799 Rec->addAttr(::
new (S.
Context) BPFPreserveAccessIndexAttr(S.
Context, AL));
10802 static bool hasBTFDeclTagAttr(
Decl *D, StringRef Tag) {
10804 if (I->getBTFDeclTag() == Tag)
10814 if (hasBTFDeclTagAttr(D, Str))
10821 if (hasBTFDeclTagAttr(D, AL.getBTFDeclTag()))
10823 return ::new (Context) BTFDeclTagAttr(Context, AL, AL.getBTFDeclTag());
10826 static void handleWebAssemblyExportNameAttr(
Sema &S,
Decl *D,
10834 auto *FD = cast<FunctionDecl>(D);
10849 WebAssemblyImportModuleAttr *
10851 auto *FD = cast<FunctionDecl>(D);
10853 if (
const auto *ExistingAttr = FD->
getAttr<WebAssemblyImportModuleAttr>()) {
10854 if (ExistingAttr->getImportModule() == AL.getImportModule())
10856 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_import) << 0
10857 << ExistingAttr->getImportModule() << AL.getImportModule();
10858 Diag(AL.getLoc(), diag::note_previous_attribute);
10862 Diag(AL.getLoc(), diag::warn_import_on_definition) << 0;
10865 return ::new (Context) WebAssemblyImportModuleAttr(Context, AL,
10866 AL.getImportModule());
10869 WebAssemblyImportNameAttr *
10871 auto *FD = cast<FunctionDecl>(D);
10873 if (
const auto *ExistingAttr = FD->
getAttr<WebAssemblyImportNameAttr>()) {
10874 if (ExistingAttr->getImportName() == AL.getImportName())
10876 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_import) << 1
10877 << ExistingAttr->getImportName() << AL.getImportName();
10878 Diag(AL.getLoc(), diag::note_previous_attribute);
10882 Diag(AL.getLoc(), diag::warn_import_on_definition) << 1;
10885 return ::new (Context) WebAssemblyImportNameAttr(Context, AL,
10886 AL.getImportName());
10891 auto *FD = cast<FunctionDecl>(D);
10898 S.
Diag(AL.
getLoc(), diag::warn_import_on_definition) << 0;
10903 WebAssemblyImportModuleAttr(S.
Context, AL, Str));
10908 auto *FD = cast<FunctionDecl>(D);
10915 S.
Diag(AL.
getLoc(), diag::warn_import_on_definition) << 1;
10922 static void handleRISCVInterruptAttr(
Sema &S,
Decl *D,
10925 if (
const auto *A = D->
getAttr<RISCVInterruptAttr>()) {
10927 diag::warn_riscv_repeated_interrupt_attribute);
10928 S.
Diag(A->getLocation(), diag::note_riscv_repeated_interrupt_attribute);
10970 RISCVInterruptAttr::InterruptType
Kind;
10971 if (!RISCVInterruptAttr::ConvertStrToInterruptType(Str,
Kind)) {
10972 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << Str
10983 case llvm::Triple::msp430:
10984 handleMSP430InterruptAttr(S, D, AL);
10986 case llvm::Triple::mipsel:
10987 case llvm::Triple::mips:
10988 handleMipsInterruptAttr(S, D, AL);
10990 case llvm::Triple::m68k:
10991 handleM68kInterruptAttr(S, D, AL);
10993 case llvm::Triple::x86:
10994 case llvm::Triple::x86_64:
10995 handleAnyX86InterruptAttr(S, D, AL);
10997 case llvm::Triple::avr:
10998 handleAVRInterruptAttr(S, D, AL);
11000 case llvm::Triple::riscv32:
11001 case llvm::Triple::riscv64:
11002 handleRISCVInterruptAttr(S, D, AL);
11005 handleARMInterruptAttr(S, D, AL);
11011 checkAMDGPUFlatWorkGroupSizeArguments(
Sema &S,
Expr *MinExpr,
Expr *MaxExpr,
11012 const AMDGPUFlatWorkGroupSizeAttr &
Attr) {
11026 if (Min == 0 && Max != 0) {
11040 AMDGPUFlatWorkGroupSizeAttr *
11043 AMDGPUFlatWorkGroupSizeAttr TmpAttr(Context, CI, MinExpr, MaxExpr);
11045 if (checkAMDGPUFlatWorkGroupSizeArguments(*
this, MinExpr, MaxExpr, TmpAttr))
11047 return ::new (Context)
11048 AMDGPUFlatWorkGroupSizeAttr(Context, CI, MinExpr, MaxExpr);
11054 if (
auto *
Attr = CreateAMDGPUFlatWorkGroupSizeAttr(CI, MinExpr, MaxExpr))
11058 static void handleAMDGPUFlatWorkGroupSizeAttr(
Sema &S,
Decl *D,
11066 static bool checkAMDGPUWavesPerEUArguments(
Sema &S,
Expr *MinExpr,
11068 const AMDGPUWavesPerEUAttr &
Attr) {
11086 if (Min == 0 && Max != 0) {
11091 if (Max != 0 && Min > Max) {
11100 AMDGPUWavesPerEUAttr *
11103 AMDGPUWavesPerEUAttr TmpAttr(Context, CI, MinExpr, MaxExpr);
11105 if (checkAMDGPUWavesPerEUArguments(*
this, MinExpr, MaxExpr, TmpAttr))
11108 return ::new (Context) AMDGPUWavesPerEUAttr(Context, CI, MinExpr, MaxExpr);
11113 if (
auto *
Attr = CreateAMDGPUWavesPerEUAttr(CI, MinExpr, MaxExpr))
11128 uint32_t NumSGPR = 0;
11137 uint32_t NumVGPR = 0;
11146 checkAMDGPUMaxNumWorkGroupsArguments(
Sema &S,
Expr *XExpr,
Expr *YExpr,
11148 const AMDGPUMaxNumWorkGroupsAttr &
Attr) {
11160 uint32_t NumWG = 0;
11161 Expr *Exprs[3] = {XExpr, YExpr, ZExpr};
11162 for (
int i = 0; i < 3; i++) {
11178 AMDGPUMaxNumWorkGroupsAttr *
11181 AMDGPUMaxNumWorkGroupsAttr TmpAttr(Context, CI, XExpr, YExpr, ZExpr);
11183 if (checkAMDGPUMaxNumWorkGroupsArguments(*
this, XExpr, YExpr, ZExpr, TmpAttr))
11186 return ::new (Context)
11187 AMDGPUMaxNumWorkGroupsAttr(Context, CI, XExpr, YExpr, ZExpr);
11193 if (
auto *
Attr = CreateAMDGPUMaxNumWorkGroupsAttr(CI, XExpr, YExpr, ZExpr))
11197 static void handleAMDGPUMaxNumWorkGroupsAttr(
Sema &S,
Decl *D,
11204 static void handleX86ForceAlignArgPointerAttr(
Sema &S,
Decl *D,
11209 const auto *VD = dyn_cast<ValueDecl>(D);
11213 const auto *TD = dyn_cast<TypedefNameDecl>(D);
11214 if (TD && (TD->getUnderlyingType()->isFunctionPointerType() ||
11215 TD->getUnderlyingType()->isFunctionType()))
11218 if (!isa<FunctionDecl>(D)) {
11219 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
11235 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
11250 if (D->
hasAttr<DLLExportAttr>()) {
11251 Diag(CI.
getLoc(), diag::warn_attribute_ignored) <<
"'dllimport'";
11255 if (D->
hasAttr<DLLImportAttr>())
11258 return ::new (Context) DLLImportAttr(Context, CI);
11263 if (DLLImportAttr *Import = D->
getAttr<DLLImportAttr>()) {
11268 if (D->
hasAttr<DLLExportAttr>())
11271 return ::new (Context) DLLExportAttr(Context, CI);
11275 if (isa<ClassTemplatePartialSpecializationDecl>(D) &&
11281 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
11291 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
11299 Attr *NewAttr = A.
getKind() == ParsedAttr::AT_DLLExport
11306 MSInheritanceAttr *
11310 if (MSInheritanceAttr *IA = D->
getAttr<MSInheritanceAttr>()) {
11311 if (IA->getInheritanceModel() == Model)
11313 Diag(IA->getLocation(), diag::err_mismatched_ms_inheritance)
11315 Diag(CI.
getLoc(), diag::note_previous_ms_inheritance);
11319 auto *RD = cast<CXXRecordDecl>(D);
11320 if (RD->hasDefinition()) {
11321 if (checkMSInheritanceAttrOnDefinition(RD, CI.
getRange(), BestCase,
11326 if (isa<ClassTemplatePartialSpecializationDecl>(RD)) {
11327 Diag(CI.
getLoc(), diag::warn_ignored_ms_inheritance)
11331 if (RD->getDescribedClassTemplate()) {
11332 Diag(CI.
getLoc(), diag::warn_ignored_ms_inheritance)
11338 return ::new (Context) MSInheritanceAttr(Context, CI, BestCase);
11350 StringRef N(
"mutex");
11352 if (AL.
getKind() == ParsedAttr::AT_Capability &&
11361 if (!checkLockFunAttrCommon(S, D, AL, Args))
11365 AssertCapabilityAttr(S.
Context, AL, Args.data(), Args.size()));
11368 static void handleAcquireCapabilityAttr(
Sema &S,
Decl *D,
11371 if (!checkLockFunAttrCommon(S, D, AL, Args))
11378 static void handleTryAcquireCapabilityAttr(
Sema &S,
Decl *D,
11381 if (!checkTryLockFunAttrCommon(S, D, AL, Args))
11388 static void handleReleaseCapabilityAttr(
Sema &S,
Decl *D,
11392 checkAttrArgsAreCapabilityObjs(S, D, AL, Args, 0,
true);
11398 static void handleRequiresCapabilityAttr(
Sema &S,
Decl *D,
11405 checkAttrArgsAreCapabilityObjs(S, D, AL, Args);
11409 RequiresCapabilityAttr *RCA = ::new (S.
Context)
11410 RequiresCapabilityAttr(S.Context, AL, Args.data(), Args.size());
11416 if (
const auto *NSD = dyn_cast<NamespaceDecl>(D)) {
11417 if (NSD->isAnonymousNamespace()) {
11418 S.
Diag(AL.getLoc(), diag::warn_deprecated_anonymous_namespace);
11426 S.
Diag(AL.getRange().getBegin(), diag::warn_deprecated_ignored_on_using)
11432 StringRef Str, Replacement;
11433 if (AL.isArgExpr(0) && AL.getArgAsExpr(0) &&
11438 if (AL.isDeclspecAttribute() || AL.isStandardAttributeSyntax())
11439 AL.checkAtMostNumArgs(S, 1);
11440 else if (AL.isArgExpr(1) && AL.getArgAsExpr(1) &&
11444 if (!S.
getLangOpts().CPlusPlus14 && AL.isCXX11Attribute() && !AL.isGNUScope())
11445 S.
Diag(AL.getLoc(), diag::ext_cxx14_attr) << AL;
11447 D->addAttr(::
new (S.
Context) DeprecatedAttr(S.
Context, AL, Str, Replacement));
11451 if (
const auto *S = dyn_cast<VarDecl>(D))
11452 return S->hasGlobalStorage();
11456 static bool isSanitizerAttributeAllowedOnGlobals(StringRef Sanitizer) {
11457 return Sanitizer ==
"address" || Sanitizer ==
"hwaddress" ||
11458 Sanitizer ==
"memtag";
11465 std::vector<StringRef> Sanitizers;
11467 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
11468 StringRef SanitizerName;
11476 SanitizerName !=
"coverage")
11477 S.
Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << SanitizerName;
11478 else if (
isGlobalVar(D) && !isSanitizerAttributeAllowedOnGlobals(SanitizerName))
11479 S.
Diag(D->
getLocation(), diag::warn_attribute_type_not_supported_global)
11480 << AL << SanitizerName;
11481 Sanitizers.push_back(SanitizerName);
11485 Sanitizers.size()));
11488 static void handleNoSanitizeSpecificAttr(
Sema &S,
Decl *D,
11492 StringRef SanitizerName = llvm::StringSwitch<StringRef>(AttrName)
11493 .Case(
"no_address_safety_analysis",
"address")
11494 .Case(
"no_sanitize_address",
"address")
11495 .Case(
"no_sanitize_thread",
"thread")
11496 .Case(
"no_sanitize_memory",
"memory");
11497 if (
isGlobalVar(D) && SanitizerName !=
"address")
11509 unsigned TranslatedSpellingIndex = 0;
11511 TranslatedSpellingIndex = 1;
11516 NoSanitizeAttr(S.
Context, Info, &SanitizerName, 1));
11526 S.
Diag(AL.
getLoc(), diag::err_attribute_requires_opencl_version)
11527 << AL <<
"2.0" << 1;
11529 S.
Diag(AL.
getLoc(), diag::warn_opencl_attr_deprecated_ignored)
11538 if (D->
hasAttr<OpenCLAccessAttr>()) {
11539 if (D->
getAttr<OpenCLAccessAttr>()->getSemanticSpelling() ==
11541 S.
Diag(AL.
getLoc(), diag::warn_duplicate_declspec)
11544 S.
Diag(AL.
getLoc(), diag::err_opencl_multiple_access_qualifiers)
11560 if (
const auto *PDecl = dyn_cast<ParmVarDecl>(D)) {
11561 const Type *
DeclTy = PDecl->getType().getCanonicalType().getTypePtr();
11563 bool ReadWriteImagesUnsupported =
11568 if (ReadWriteImagesUnsupported ||
DeclTy->isPipeType()) {
11569 S.
Diag(AL.
getLoc(), diag::err_opencl_invalid_read_write)
11570 << AL << PDecl->getType() <<
DeclTy->isImageType();
11587 ZeroCallUsedRegsAttr::ZeroCallUsedRegsKind
Kind;
11588 if (!ZeroCallUsedRegsAttr::ConvertStrToZeroCallUsedRegsKind(KindStr,
Kind)) {
11589 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported)
11594 D->
dropAttr<ZeroCallUsedRegsAttr>();
11624 S.
Diag(E->
getBeginLoc(), diag::err_counted_by_attr_argument_not_integer)
11633 StrictFlexArraysLevel,
true)) {
11637 diag::err_counted_by_attr_not_on_flexible_array_member)
11642 auto *DRE = dyn_cast<DeclRefExpr>(E);
11645 diag::err_counted_by_attr_only_support_simple_decl_reference)
11650 auto *CountDecl = DRE->
getDecl();
11651 FieldDecl *CountFD = dyn_cast<FieldDecl>(CountDecl);
11652 if (
auto *IFD = dyn_cast<IndirectFieldDecl>(CountDecl)) {
11653 CountFD = IFD->getAnonField();
11659 S.
Diag(CountDecl->getBeginLoc(),
11660 diag::note_flexible_array_counted_by_attr_field)
11661 << CountDecl << CountDecl->getSourceRange();
11667 S.
Diag(CountFD->
getBeginLoc(), diag::err_counted_by_attr_refer_to_union)
11674 auto *RD = GetEnclosingNamedOrTopAnonRecord(FD);
11675 auto *CountRD = GetEnclosingNamedOrTopAnonRecord(CountFD);
11677 if (RD != CountRD) {
11679 diag::err_flexible_array_count_not_in_same_struct)
11682 diag::note_flexible_array_counted_by_attr_field)
11693 auto *FD = dyn_cast<FieldDecl>(D);
11701 if (CheckCountExpr(S, FD, CountExpr, Decls))
11708 static void handleFunctionReturnThunksAttr(
Sema &S,
Decl *D,
11716 if (!FunctionReturnThunksAttr::ConvertStrToKind(KindStr,
Kind)) {
11717 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported)
11724 D->
dropAttr<FunctionReturnThunksAttr>();
11728 bool isDeviceAspectType(
const QualType Ty) {
11734 return Attr->getType() == SYCLTypeAttr::aspect;
11740 const SYCLDeviceHasAttr &A) {
11741 if (
const auto *ExistingAttr = D->
getAttr<SYCLDeviceHasAttr>()) {
11742 Diag(ExistingAttr->getLoc(), diag::warn_duplicate_attribute_exact) << &A;
11743 Diag(A.getLoc(), diag::note_previous_attribute);
11748 for (
auto *E : A.aspects())
11750 return ::new (Context)
11751 SYCLDeviceHasAttr(Context, A, Args.data(), Args.size());
11755 Expr **Exprs,
unsigned Size) {
11757 SYCLDeviceHasAttr TmpAttr(Context, CI, Exprs, Size);
11759 for (
auto *E : TmpAttr.aspects())
11760 if (!isa<PackExpansionExpr>(E) && !isDeviceAspectType(E->
getType()))
11761 Diag(E->
getExprLoc(), diag::err_sycl_invalid_aspect_argument) << CI;
11763 if (
const auto *ExistingAttr = D->
getAttr<SYCLDeviceHasAttr>()) {
11764 Diag(CI.
getLoc(), diag::warn_duplicate_attribute_exact) << CI;
11765 Diag(ExistingAttr->getLoc(), diag::note_previous_attribute);
11769 D->
addAttr(::
new (Context) SYCLDeviceHasAttr(Context, CI, Exprs, Size));
11779 for (
unsigned I = 0; I < A.
getNumArgs(); ++I)
11785 SYCLUsesAspectsAttr *
11787 if (
const auto *ExistingAttr = D->
getAttr<SYCLUsesAspectsAttr>()) {
11788 Diag(ExistingAttr->getLoc(), diag::warn_duplicate_attribute_exact) << &A;
11789 Diag(A.getLoc(), diag::note_previous_attribute);
11794 for (
auto *E : A.aspects())
11796 return ::new (Context)
11797 SYCLUsesAspectsAttr(Context, A, Args.data(), Args.size());
11801 Expr **Exprs,
unsigned Size) {
11803 SYCLUsesAspectsAttr TmpAttr(Context, CI, Exprs, Size);
11805 for (
auto *E : TmpAttr.aspects())
11806 if (!isDeviceAspectType(E->
getType()))
11807 Diag(E->
getExprLoc(), diag::err_sycl_invalid_aspect_argument) << CI;
11809 if (
const auto *ExistingAttr = D->
getAttr<SYCLUsesAspectsAttr>()) {
11810 Diag(CI.
getLoc(), diag::warn_duplicate_attribute_exact) << CI;
11811 Diag(ExistingAttr->getLoc(), diag::note_previous_attribute);
11815 D->
addAttr(::
new (Context) SYCLUsesAspectsAttr(Context, CI, Exprs, Size));
11825 for (
unsigned I = 0; I < A.
getNumArgs(); ++I)
11831 static void handleAvailableOnlyInDefaultEvalMethod(
Sema &S,
Decl *D,
11833 assert(isa<TypedefNameDecl>(D) &&
"This attribute only applies to a typedef");
11834 handleSimpleAttribute<AvailableOnlyInDefaultEvalMethodAttr>(S, D, AL);
11838 auto *VDecl = dyn_cast<VarDecl>(D);
11839 if (VDecl && !VDecl->isFunctionPointerType()) {
11840 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored_non_function_pointer)
11853 const auto *FD = cast<FunctionDecl>(D);
11855 assert(FT &&
"Function template is expected");
11860 if (TL->
size() < 2) {
11861 S.
Diag(FT->
getLocation(), diag::warn_sycl_kernel_num_of_template_params);
11866 for (
unsigned I = 0; I < 2 && I < TL->
size(); ++I) {
11868 if (isa<NonTypeTemplateParmDecl>(TParam)) {
11870 diag::warn_sycl_kernel_invalid_template_param_type);
11877 S.
Diag(FT->
getLocation(), diag::warn_sycl_kernel_num_of_function_params);
11888 handleSimpleAttribute<SYCLKernelAttr>(S, D, AL);
11892 SYCLTypeAttr::SYCLType TypeName) {
11893 if (
const auto *ExistingAttr = D->
getAttr<SYCLTypeAttr>()) {
11894 if (ExistingAttr->getType() != TypeName) {
11895 Diag(ExistingAttr->getLoc(), diag::err_duplicate_attribute)
11897 Diag(CI.
getLoc(), diag::note_previous_attribute);
11902 return ::new (Context) SYCLTypeAttr(Context, CI, TypeName);
11907 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
11913 SYCLTypeAttr::SYCLType
Type;
11915 if (!SYCLTypeAttr::ConvertStrToSYCLType(II->
getName(),
Type)) {
11916 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_not_supported) << AL << II;
11925 if (!cast<VarDecl>(D)->hasGlobalStorage()) {
11927 << (A.
getKind() == ParsedAttr::AT_AlwaysDestroy);
11931 if (A.
getKind() == ParsedAttr::AT_AlwaysDestroy)
11932 handleSimpleAttribute<AlwaysDestroyAttr>(S, D, A);
11934 handleSimpleAttribute<NoDestroyAttr>(S, D, A);
11938 assert(cast<VarDecl>(D)->getStorageDuration() ==
SD_Automatic &&
11939 "uninitialized is only valid on automatic duration variables");
11943 static bool tryMakeVariablePseudoStrong(
Sema &S,
VarDecl *VD,
11944 bool DiagnoseFailure) {
11947 if (DiagnoseFailure) {
11948 S.
Diag(VD->
getBeginLoc(), diag::warn_ignored_objc_externally_retained)
11965 if (DiagnoseFailure) {
11966 S.
Diag(VD->
getBeginLoc(), diag::warn_ignored_objc_externally_retained)
11980 static void handleObjCExternallyRetainedAttr(
Sema &S,
Decl *D,
11982 if (
auto *VD = dyn_cast<VarDecl>(D)) {
11983 assert(!isa<ParmVarDecl>(VD) &&
"should be diagnosed automatically");
11985 S.
Diag(D->
getBeginLoc(), diag::warn_ignored_objc_externally_retained)
11990 if (!tryMakeVariablePseudoStrong(S, VD,
true))
11993 handleSimpleAttribute<ObjCExternallyRetainedAttr>(S, D, AL);
11999 unsigned NumParams =
12001 for (
unsigned I = 0; I != NumParams; ++I) {
12013 tryMakeVariablePseudoStrong(S, PVD,
false);
12015 handleSimpleAttribute<ObjCExternallyRetainedAttr>(S, D, AL);
12023 if (!isa<BlockDecl>(D)) {
12025 bool IsKernReturnT =
false;
12027 IsKernReturnT = (TT->getDecl()->getName() ==
"kern_return_t");
12032 diag::warn_mig_server_routine_does_not_return_kern_return_t);
12037 handleSimpleAttribute<MIGServerRoutineAttr>(S, D, AL);
12042 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
12043 QualType RetTy = FD->getReturnType();
12045 S.
Diag(AL.
getLoc(), diag::warn_declspec_allocator_nonpointer)
12051 handleSimpleAttribute<MSAllocatorAttr>(S, D, AL);
12058 if (
const auto *PVD = dyn_cast<ParmVarDecl>(D)) {
12059 if (PVD->getType()->isIntegerType()) {
12060 S.
Diag(AL.
getLoc(), diag::err_attribute_output_parameter)
12065 StringRef Argument;
12071 template<
typename Attr>
12073 StringRef Argument;
12079 template<
typename Attr>
12088 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
12093 CFGuardAttr::GuardArg Arg;
12095 if (!CFGuardAttr::ConvertStrToGuardArg(II->
getName(), Arg)) {
12096 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
12104 template <
typename AttrTy>
12105 static const AttrTy *findEnforceTCBAttrByName(
Decl *D, StringRef Name) {
12107 auto I = llvm::find_if(Attrs,
12108 [Name](
const AttrTy *A) {
12109 return A->getTCBName() == Name;
12111 return I == Attrs.end() ? nullptr : *I;
12114 template <
typename AttrTy,
typename ConflictingAttrTy>
12116 StringRef Argument;
12121 if (
const ConflictingAttrTy *ConflictingAttr =
12122 findEnforceTCBAttrByName<ConflictingAttrTy>(D, Argument)) {
12125 S.
Diag(AL.
getLoc(), diag::err_tcb_conflicting_attributes)
12139 template <
typename AttrTy,
typename ConflictingAttrTy>
12140 static AttrTy *mergeEnforceTCBAttrImpl(
Sema &S,
Decl *D,
const AttrTy &AL) {
12142 StringRef TCBName = AL.getTCBName();
12143 if (
const ConflictingAttrTy *ConflictingAttr =
12144 findEnforceTCBAttrByName<ConflictingAttrTy>(D, TCBName)) {
12145 S.
Diag(ConflictingAttr->getLoc(), diag::err_tcb_conflicting_attributes)
12146 << ConflictingAttr->getAttrName()->getName()
12147 << AL.getAttrName()->getName() << TCBName;
12150 S.
Diag(AL.getLoc(), diag::note_conflicting_attribute);
12158 return ::new(Context) AttrTy(Context, AL, AL.getTCBName());
12162 return mergeEnforceTCBAttrImpl<EnforceTCBAttr, EnforceTCBLeafAttr>(
12167 Decl *D,
const EnforceTCBLeafAttr &AL) {
12168 return mergeEnforceTCBAttrImpl<EnforceTCBLeafAttr, EnforceTCBAttr>(
12176 static bool IsDeclLambdaCallOperator(
Decl *D) {
12177 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D))
12185 static bool MustDelayAttributeArguments(
const ParsedAttr &AL) {
12193 bool IsLastAttrArg = I == (AttrNumArgs - 1);
12196 if (IsLastAttrArg && AttrHasVariadicArg)
12203 if (isa<PackExpansionExpr>(E))
12204 return !(IsLastAttrArg && ArgMemberCanHoldExpr);
12214 static bool checkArmNewAttrMutualExclusion(
12217 auto CheckForIncompatibleAttr =
12219 StringRef IncompatibleStateName) {
12220 if (CurrentState == IncompatibleState) {
12221 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
12222 << (std::string(
"'__arm_new(\"") + StateName.str() +
"\")'")
12223 << (std::string(
"'") + IncompatibleStateName.str() +
"(\"" +
12224 StateName.str() +
"\")'")
12239 S.
Diag(AL.
getLoc(), diag::err_missing_arm_state) << AL;
12244 std::vector<StringRef> NewState;
12245 if (
const auto *ExistingAttr = D->
getAttr<ArmNewAttr>()) {
12246 for (StringRef S : ExistingAttr->newArgs())
12247 NewState.push_back(S);
12250 bool HasZA =
false;
12251 bool HasZT0 =
false;
12252 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
12253 StringRef StateName;
12258 if (StateName ==
"za")
12260 else if (StateName ==
"zt0")
12263 S.
Diag(LiteralLoc, diag::err_unknown_arm_state) << StateName;
12268 if (!llvm::is_contained(NewState, StateName))
12269 NewState.push_back(StateName);
12276 checkArmNewAttrMutualExclusion(S, AL, FPT, ZAState,
"za"))
12281 checkArmNewAttrMutualExclusion(S, AL, FPT, ZT0State,
"zt0"))
12287 ArmNewAttr(S.
Context, AL, NewState.data(), NewState.size()));
12315 ? (
unsigned)diag::err_keyword_not_supported_on_target
12317 ? (
unsigned)diag::warn_unhandled_ms_attribute_ignored
12318 : (
unsigned)diag::warn_unknown_attribute_ignored)
12324 bool MustDelayArgs = MustDelayAttributeArguments(AL);
12330 if (MustDelayArgs) {
12340 assert(AL.
isTypeAttr() &&
"Non-type attribute not handled");
12343 if (Options.IgnoreTypeAttributes)
12361 isa<DeclaratorDecl, TypeAliasDecl>(D)) {
12366 S.
Diag(AL.
getLoc(), diag::warn_type_attribute_deprecated_on_decl)
12375 if (AL.
getKind() == ParsedAttr::AT_Regparm) {
12388 if (AL.
getKind() == ParsedAttr::AT_VectorSize) {
12398 if (AL.
getKind() == ParsedAttr::AT_NoDeref) {
12409 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_on_decl)
12412 case ParsedAttr::AT_Interrupt:
12413 handleInterruptAttr(S, D, AL);
12415 case ParsedAttr::AT_X86ForceAlignArgPointer:
12416 handleX86ForceAlignArgPointerAttr(S, D, AL);
12418 case ParsedAttr::AT_ReadOnlyPlacement:
12419 handleSimpleAttribute<ReadOnlyPlacementAttr>(S, D, AL);
12421 case ParsedAttr::AT_DLLExport:
12422 case ParsedAttr::AT_DLLImport:
12423 handleDLLAttr(S, D, AL);
12425 case ParsedAttr::AT_AMDGPUFlatWorkGroupSize:
12426 handleAMDGPUFlatWorkGroupSizeAttr(S, D, AL);
12428 case ParsedAttr::AT_AMDGPUWavesPerEU:
12429 handleAMDGPUWavesPerEUAttr(S, D, AL);
12431 case ParsedAttr::AT_AMDGPUNumSGPR:
12432 handleAMDGPUNumSGPRAttr(S, D, AL);
12434 case ParsedAttr::AT_AMDGPUNumVGPR:
12435 handleAMDGPUNumVGPRAttr(S, D, AL);
12437 case ParsedAttr::AT_AMDGPUMaxNumWorkGroups:
12438 handleAMDGPUMaxNumWorkGroupsAttr(S, D, AL);
12440 case ParsedAttr::AT_AVRSignal:
12441 handleAVRSignalAttr(S, D, AL);
12443 case ParsedAttr::AT_BPFPreserveAccessIndex:
12444 handleBPFPreserveAccessIndexAttr(S, D, AL);
12446 case ParsedAttr::AT_BPFPreserveStaticOffset:
12447 handleSimpleAttribute<BPFPreserveStaticOffsetAttr>(S, D, AL);
12449 case ParsedAttr::AT_BTFDeclTag:
12450 handleBTFDeclTagAttr(S, D, AL);
12452 case ParsedAttr::AT_WebAssemblyExportName:
12453 handleWebAssemblyExportNameAttr(S, D, AL);
12455 case ParsedAttr::AT_WebAssemblyImportModule:
12456 handleWebAssemblyImportModuleAttr(S, D, AL);
12458 case ParsedAttr::AT_WebAssemblyImportName:
12459 handleWebAssemblyImportNameAttr(S, D, AL);
12461 case ParsedAttr::AT_IBOutlet:
12462 handleIBOutlet(S, D, AL);
12464 case ParsedAttr::AT_IBOutletCollection:
12465 handleIBOutletCollection(S, D, AL);
12467 case ParsedAttr::AT_IFunc:
12468 handleIFuncAttr(S, D, AL);
12470 case ParsedAttr::AT_Alias:
12471 handleAliasAttr(S, D, AL);
12473 case ParsedAttr::AT_Aligned:
12474 handleAlignedAttr(S, D, AL);
12476 case ParsedAttr::AT_AlignValue:
12477 handleAlignValueAttr(S, D, AL);
12479 case ParsedAttr::AT_AllocSize:
12480 handleAllocSizeAttr(S, D, AL);
12482 case ParsedAttr::AT_AlwaysInline:
12485 case ParsedAttr::AT_AnalyzerNoReturn:
12486 handleAnalyzerNoReturnAttr(S, D, AL);
12488 case ParsedAttr::AT_TLSModel:
12489 handleTLSModelAttr(S, D, AL);
12491 case ParsedAttr::AT_Annotate:
12492 handleAnnotateAttr(S, D, AL);
12494 case ParsedAttr::AT_Availability:
12495 handleAvailabilityAttr(S, D, AL);
12497 case ParsedAttr::AT_CarriesDependency:
12498 handleDependencyAttr(S, scope, D, AL);
12500 case ParsedAttr::AT_CPUDispatch:
12501 case ParsedAttr::AT_CPUSpecific:
12502 handleCPUSpecificAttr(S, D, AL);
12504 case ParsedAttr::AT_Common:
12505 handleCommonAttr(S, D, AL);
12507 case ParsedAttr::AT_CUDAConstant:
12508 handleConstantAttr(S, D, AL);
12510 case ParsedAttr::AT_PassObjectSize:
12511 handlePassObjectSizeAttr(S, D, AL);
12513 case ParsedAttr::AT_Constructor:
12514 handleConstructorAttr(S, D, AL);
12516 case ParsedAttr::AT_Deprecated:
12517 handleDeprecatedAttr(S, D, AL);
12519 case ParsedAttr::AT_Destructor:
12520 handleDestructorAttr(S, D, AL);
12522 case ParsedAttr::AT_EnableIf:
12523 handleEnableIfAttr(S, D, AL);
12525 case ParsedAttr::AT_Error:
12526 handleErrorAttr(S, D, AL);
12528 case ParsedAttr::AT_ExcludeFromExplicitInstantiation:
12529 handleExcludeFromExplicitInstantiationAttr(S, D, AL);
12531 case ParsedAttr::AT_DiagnoseIf:
12532 handleDiagnoseIfAttr(S, D, AL);
12534 case ParsedAttr::AT_DiagnoseAsBuiltin:
12535 handleDiagnoseAsBuiltinAttr(S, D, AL);
12537 case ParsedAttr::AT_NoBuiltin:
12538 handleNoBuiltinAttr(S, D, AL);
12540 case ParsedAttr::AT_ExtVectorType:
12541 handleExtVectorTypeAttr(S, D, AL);
12543 case ParsedAttr::AT_ExternalSourceSymbol:
12544 handleExternalSourceSymbolAttr(S, D, AL);
12546 case ParsedAttr::AT_MinSize:
12547 handleMinSizeAttr(S, D, AL);
12549 case ParsedAttr::AT_OptimizeNone:
12550 handleOptimizeNoneAttr(S, D, AL);
12552 case ParsedAttr::AT_EnumExtensibility:
12553 handleEnumExtensibilityAttr(S, D, AL);
12555 case ParsedAttr::AT_SYCLKernel:
12556 handleSYCLKernelAttr(S, D, AL);
12558 case ParsedAttr::AT_SYCLSimd:
12559 handleSimpleAttribute<SYCLSimdAttr>(S, D, AL);
12561 case ParsedAttr::AT_SYCLSpecialClass:
12562 handleSimpleAttribute<SYCLSpecialClassAttr>(S, D, AL);
12564 case ParsedAttr::AT_SYCLType:
12565 handleSYCLTypeAttr(S, D, AL);
12567 case ParsedAttr::AT_SYCLDevice:
12568 handleSYCLDeviceAttr(S, D, AL);
12570 case ParsedAttr::AT_SYCLDeviceIndirectlyCallable:
12571 handleSYCLDeviceIndirectlyCallableAttr(S, D, AL);
12573 case ParsedAttr::AT_SYCLGlobalVar:
12574 handleSYCLGlobalVarAttr(S, D, AL);
12576 case ParsedAttr::AT_SYCLRegisterNum:
12577 handleSYCLRegisterNumAttr(S, D, AL);
12579 case ParsedAttr::AT_SYCLIntelESimdVectorize:
12580 handleSYCLIntelESimdVectorizeAttr(S, D, AL);
12582 case ParsedAttr::AT_SYCLDeviceHas:
12583 handleSYCLDeviceHasAttr(S, D, AL);
12585 case ParsedAttr::AT_SYCLUsesAspects:
12586 handleSYCLUsesAspectsAttr(S, D, AL);
12588 case ParsedAttr::AT_Format:
12589 handleFormatAttr(S, D, AL);
12591 case ParsedAttr::AT_FormatArg:
12592 handleFormatArgAttr(S, D, AL);
12594 case ParsedAttr::AT_Callback:
12595 handleCallbackAttr(S, D, AL);
12597 case ParsedAttr::AT_CalledOnce:
12598 handleCalledOnceAttr(S, D, AL);
12600 case ParsedAttr::AT_NVPTXKernel:
12601 case ParsedAttr::AT_CUDAGlobal:
12602 handleGlobalAttr(S, D, AL);
12604 case ParsedAttr::AT_CUDADevice:
12605 handleDeviceAttr(S, D, AL);
12607 case ParsedAttr::AT_HIPManaged:
12608 handleManagedAttr(S, D, AL);
12610 case ParsedAttr::AT_GNUInline:
12611 handleGNUInlineAttr(S, D, AL);
12613 case ParsedAttr::AT_CUDALaunchBounds:
12614 handleLaunchBoundsAttr(S, D, AL);
12616 case ParsedAttr::AT_Restrict:
12617 handleRestrictAttr(S, D, AL);
12619 case ParsedAttr::AT_Mode:
12620 handleModeAttr(S, D, AL);
12622 case ParsedAttr::AT_NonNull:
12623 if (
auto *PVD = dyn_cast<ParmVarDecl>(D))
12624 handleNonNullAttrParameter(S, PVD, AL);
12626 handleNonNullAttr(S, D, AL);
12628 case ParsedAttr::AT_ReturnsNonNull:
12629 handleReturnsNonNullAttr(S, D, AL);
12631 case ParsedAttr::AT_NoEscape:
12632 handleNoEscapeAttr(S, D, AL);
12634 case ParsedAttr::AT_MaybeUndef:
12635 handleSimpleAttribute<MaybeUndefAttr>(S, D, AL);
12637 case ParsedAttr::AT_AssumeAligned:
12638 handleAssumeAlignedAttr(S, D, AL);
12640 case ParsedAttr::AT_AllocAlign:
12641 handleAllocAlignAttr(S, D, AL);
12643 case ParsedAttr::AT_Ownership:
12644 handleOwnershipAttr(S, D, AL);
12646 case ParsedAttr::AT_Naked:
12647 handleNakedAttr(S, D, AL);
12649 case ParsedAttr::AT_NoReturn:
12650 handleNoReturnAttr(S, D, AL);
12652 case ParsedAttr::AT_CXX11NoReturn:
12653 handleStandardNoReturnAttr(S, D, AL);
12655 case ParsedAttr::AT_AnyX86NoCfCheck:
12656 handleNoCfCheckAttr(S, D, AL);
12658 case ParsedAttr::AT_NoThrow:
12660 handleSimpleAttribute<NoThrowAttr>(S, D, AL);
12662 case ParsedAttr::AT_CUDAShared:
12663 handleSharedAttr(S, D, AL);
12665 case ParsedAttr::AT_VecReturn:
12666 handleVecReturnAttr(S, D, AL);
12668 case ParsedAttr::AT_ObjCOwnership:
12669 handleObjCOwnershipAttr(S, D, AL);
12671 case ParsedAttr::AT_ObjCPreciseLifetime:
12672 handleObjCPreciseLifetimeAttr(S, D, AL);
12674 case ParsedAttr::AT_ObjCReturnsInnerPointer:
12675 handleObjCReturnsInnerPointerAttr(S, D, AL);
12677 case ParsedAttr::AT_ObjCRequiresSuper:
12678 handleObjCRequiresSuperAttr(S, D, AL);
12680 case ParsedAttr::AT_ObjCBridge:
12681 handleObjCBridgeAttr(S, D, AL);
12683 case ParsedAttr::AT_ObjCBridgeMutable:
12684 handleObjCBridgeMutableAttr(S, D, AL);
12686 case ParsedAttr::AT_ObjCBridgeRelated:
12687 handleObjCBridgeRelatedAttr(S, D, AL);
12689 case ParsedAttr::AT_ObjCDesignatedInitializer:
12690 handleObjCDesignatedInitializer(S, D, AL);
12692 case ParsedAttr::AT_ObjCRuntimeName:
12693 handleObjCRuntimeName(S, D, AL);
12695 case ParsedAttr::AT_ObjCBoxable:
12696 handleObjCBoxable(S, D, AL);
12698 case ParsedAttr::AT_NSErrorDomain:
12699 handleNSErrorDomain(S, D, AL);
12701 case ParsedAttr::AT_CFConsumed:
12702 case ParsedAttr::AT_NSConsumed:
12703 case ParsedAttr::AT_OSConsumed:
12707 case ParsedAttr::AT_OSReturnsRetainedOnZero:
12708 handleSimpleAttributeOrDiagnose<OSReturnsRetainedOnZeroAttr>(
12709 S, D, AL, isValidOSObjectOutParameter(D),
12710 diag::warn_ns_attribute_wrong_parameter_type,
12713 case ParsedAttr::AT_OSReturnsRetainedOnNonZero:
12714 handleSimpleAttributeOrDiagnose<OSReturnsRetainedOnNonZeroAttr>(
12715 S, D, AL, isValidOSObjectOutParameter(D),
12716 diag::warn_ns_attribute_wrong_parameter_type,
12719 case ParsedAttr::AT_NSReturnsAutoreleased:
12720 case ParsedAttr::AT_NSReturnsNotRetained:
12721 case ParsedAttr::AT_NSReturnsRetained:
12722 case ParsedAttr::AT_CFReturnsNotRetained:
12723 case ParsedAttr::AT_CFReturnsRetained:
12724 case ParsedAttr::AT_OSReturnsNotRetained:
12725 case ParsedAttr::AT_OSReturnsRetained:
12726 handleXReturnsXRetainedAttr(S, D, AL);
12728 case ParsedAttr::AT_WorkGroupSizeHint:
12729 handleWorkGroupSizeHint(S, D, AL);
12731 case ParsedAttr::AT_ReqdWorkGroupSize:
12732 handleReqdWorkGroupSize(S, D, AL);
12734 case ParsedAttr::AT_SYCLIntelMaxWorkGroupSize:
12735 handleSYCLIntelMaxWorkGroupSize(S, D, AL);
12737 case ParsedAttr::AT_SYCLIntelMinWorkGroupsPerComputeUnit:
12738 handleSYCLIntelMinWorkGroupsPerComputeUnit(S, D, AL);
12740 case ParsedAttr::AT_SYCLIntelMaxWorkGroupsPerMultiprocessor:
12741 handleSYCLIntelMaxWorkGroupsPerMultiprocessor(S, D, AL);
12743 case ParsedAttr::AT_IntelReqdSubGroupSize:
12744 handleIntelReqdSubGroupSize(S, D, AL);
12746 case ParsedAttr::AT_IntelNamedSubGroupSize:
12747 handleIntelNamedSubGroupSize(S, D, AL);
12749 case ParsedAttr::AT_SYCLIntelNumSimdWorkItems:
12750 handleSYCLIntelNumSimdWorkItemsAttr(S, D, AL);
12752 case ParsedAttr::AT_SYCLIntelSchedulerTargetFmaxMhz:
12753 handleSYCLIntelSchedulerTargetFmaxMhzAttr(S, D, AL);
12755 case ParsedAttr::AT_SYCLIntelMaxGlobalWorkDim:
12756 handleSYCLIntelMaxGlobalWorkDimAttr(S, D, AL);
12758 case ParsedAttr::AT_SYCLIntelNoGlobalWorkOffset:
12759 handleSYCLIntelNoGlobalWorkOffsetAttr(S, D, AL);
12761 case ParsedAttr::AT_SYCLIntelUseStallEnableClusters:
12762 handleSYCLIntelUseStallEnableClustersAttr(S, D, AL);
12764 case ParsedAttr::AT_SYCLIntelLoopFuse:
12765 handleSYCLIntelLoopFuseAttr(S, D, AL);
12767 case ParsedAttr::AT_SYCLIntelInitiationInterval:
12770 case ParsedAttr::AT_VecTypeHint:
12771 handleVecTypeHint(S, D, AL);
12773 case ParsedAttr::AT_InitPriority:
12774 handleInitPriorityAttr(S, D, AL);
12776 case ParsedAttr::AT_Packed:
12777 handlePackedAttr(S, D, AL);
12779 case ParsedAttr::AT_PreferredName:
12780 handlePreferredName(S, D, AL);
12782 case ParsedAttr::AT_Section:
12783 handleSectionAttr(S, D, AL);
12785 case ParsedAttr::AT_CodeModel:
12786 handleCodeModelAttr(S, D, AL);
12788 case ParsedAttr::AT_RandomizeLayout:
12789 handleRandomizeLayoutAttr(S, D, AL);
12791 case ParsedAttr::AT_NoRandomizeLayout:
12792 handleNoRandomizeLayoutAttr(S, D, AL);
12794 case ParsedAttr::AT_CodeSeg:
12795 handleCodeSegAttr(S, D, AL);
12797 case ParsedAttr::AT_Target:
12798 handleTargetAttr(S, D, AL);
12800 case ParsedAttr::AT_TargetVersion:
12801 handleTargetVersionAttr(S, D, AL);
12803 case ParsedAttr::AT_TargetClones:
12804 handleTargetClonesAttr(S, D, AL);
12806 case ParsedAttr::AT_MinVectorWidth:
12807 handleMinVectorWidthAttr(S, D, AL);
12809 case ParsedAttr::AT_Unavailable:
12810 handleAttrWithMessage<UnavailableAttr>(S, D, AL);
12812 case ParsedAttr::AT_OMPAssume:
12813 handleOMPAssumeAttr(S, D, AL);
12815 case ParsedAttr::AT_ObjCDirect:
12816 handleObjCDirectAttr(S, D, AL);
12818 case ParsedAttr::AT_ObjCDirectMembers:
12819 handleObjCDirectMembersAttr(S, D, AL);
12820 handleSimpleAttribute<ObjCDirectMembersAttr>(S, D, AL);
12822 case ParsedAttr::AT_ObjCExplicitProtocolImpl:
12823 handleObjCSuppresProtocolAttr(S, D, AL);
12825 case ParsedAttr::AT_Unused:
12826 handleUnusedAttr(S, D, AL);
12828 case ParsedAttr::AT_Visibility:
12829 handleVisibilityAttr(S, D, AL,
false);
12831 case ParsedAttr::AT_TypeVisibility:
12832 handleVisibilityAttr(S, D, AL,
true);
12834 case ParsedAttr::AT_WarnUnusedResult:
12835 handleWarnUnusedResult(S, D, AL);
12837 case ParsedAttr::AT_WeakRef:
12838 handleWeakRefAttr(S, D, AL);
12840 case ParsedAttr::AT_WeakImport:
12841 handleWeakImportAttr(S, D, AL);
12843 case ParsedAttr::AT_TransparentUnion:
12844 handleTransparentUnionAttr(S, D, AL);
12846 case ParsedAttr::AT_ObjCMethodFamily:
12847 handleObjCMethodFamilyAttr(S, D, AL);
12849 case ParsedAttr::AT_ObjCNSObject:
12850 handleObjCNSObject(S, D, AL);
12852 case ParsedAttr::AT_ObjCIndependentClass:
12853 handleObjCIndependentClass(S, D, AL);
12855 case ParsedAttr::AT_Blocks:
12856 handleBlocksAttr(S, D, AL);
12858 case ParsedAttr::AT_Sentinel:
12859 handleSentinelAttr(S, D, AL);
12861 case ParsedAttr::AT_Cleanup:
12862 handleCleanupAttr(S, D, AL);
12864 case ParsedAttr::AT_NoDebug:
12865 handleNoDebugAttr(S, D, AL);
12867 case ParsedAttr::AT_CmseNSEntry:
12868 handleCmseNSEntryAttr(S, D, AL);
12870 case ParsedAttr::AT_StdCall:
12871 case ParsedAttr::AT_CDecl:
12872 case ParsedAttr::AT_FastCall:
12873 case ParsedAttr::AT_ThisCall:
12874 case ParsedAttr::AT_Pascal:
12875 case ParsedAttr::AT_RegCall:
12876 case ParsedAttr::AT_SwiftCall:
12877 case ParsedAttr::AT_SwiftAsyncCall:
12878 case ParsedAttr::AT_VectorCall:
12879 case ParsedAttr::AT_MSABI:
12880 case ParsedAttr::AT_SysVABI:
12881 case ParsedAttr::AT_Pcs:
12882 case ParsedAttr::AT_IntelOclBicc:
12883 case ParsedAttr::AT_PreserveMost:
12884 case ParsedAttr::AT_PreserveAll:
12885 case ParsedAttr::AT_AArch64VectorPcs:
12886 case ParsedAttr::AT_AArch64SVEPcs:
12887 case ParsedAttr::AT_AMDGPUKernelCall:
12888 case ParsedAttr::AT_M68kRTD:
12889 case ParsedAttr::AT_PreserveNone:
12890 case ParsedAttr::AT_RISCVVectorCC:
12891 handleCallConvAttr(S, D, AL);
12893 case ParsedAttr::AT_Suppress:
12896 case ParsedAttr::AT_Owner:
12897 case ParsedAttr::AT_Pointer:
12898 handleLifetimeCategoryAttr(S, D, AL);
12900 case ParsedAttr::AT_OpenCLAccess:
12901 handleOpenCLAccessAttr(S, D, AL);
12903 case ParsedAttr::AT_OpenCLNoSVM:
12904 handleOpenCLNoSVMAttr(S, D, AL);
12906 case ParsedAttr::AT_SwiftContext:
12909 case ParsedAttr::AT_SwiftAsyncContext:
12912 case ParsedAttr::AT_SwiftErrorResult:
12915 case ParsedAttr::AT_SwiftIndirectResult:
12918 case ParsedAttr::AT_InternalLinkage:
12919 handleInternalLinkageAttr(S, D, AL);
12921 case ParsedAttr::AT_ZeroCallUsedRegs:
12922 handleZeroCallUsedRegsAttr(S, D, AL);
12924 case ParsedAttr::AT_FunctionReturnThunks:
12925 handleFunctionReturnThunksAttr(S, D, AL);
12927 case ParsedAttr::AT_NoMerge:
12930 case ParsedAttr::AT_NoUniqueAddress:
12931 handleNoUniqueAddressAttr(S, D, AL);
12934 case ParsedAttr::AT_AvailableOnlyInDefaultEvalMethod:
12935 handleAvailableOnlyInDefaultEvalMethod(S, D, AL);
12938 case ParsedAttr::AT_CountedBy:
12939 handleCountedByAttrField(S, D, AL);
12943 case ParsedAttr::AT_LayoutVersion:
12944 handleLayoutVersion(S, D, AL);
12946 case ParsedAttr::AT_Uuid:
12947 handleUuidAttr(S, D, AL);
12949 case ParsedAttr::AT_MSInheritance:
12950 handleMSInheritanceAttr(S, D, AL);
12952 case ParsedAttr::AT_Thread:
12953 handleDeclspecThreadAttr(S, D, AL);
12955 case ParsedAttr::AT_MSConstexpr:
12960 case ParsedAttr::AT_HLSLNumThreads:
12961 handleHLSLNumThreadsAttr(S, D, AL);
12963 case ParsedAttr::AT_HLSLSV_GroupIndex:
12964 handleSimpleAttribute<HLSLSV_GroupIndexAttr>(S, D, AL);
12966 case ParsedAttr::AT_HLSLSV_DispatchThreadID:
12967 handleHLSLSV_DispatchThreadIDAttr(S, D, AL);
12969 case ParsedAttr::AT_HLSLPackOffset:
12970 handleHLSLPackOffsetAttr(S, D, AL);
12972 case ParsedAttr::AT_HLSLShader:
12973 handleHLSLShaderAttr(S, D, AL);
12975 case ParsedAttr::AT_HLSLResourceBinding:
12976 handleHLSLResourceBindingAttr(S, D, AL);
12978 case ParsedAttr::AT_HLSLParamModifier:
12979 handleHLSLParamModifierAttr(S, D, AL);
12982 case ParsedAttr::AT_AbiTag:
12983 handleAbiTagAttr(S, D, AL);
12985 case ParsedAttr::AT_CFGuard:
12986 handleCFGuardAttr(S, D, AL);
12990 case ParsedAttr::AT_AssertExclusiveLock:
12991 handleAssertExclusiveLockAttr(S, D, AL);
12993 case ParsedAttr::AT_AssertSharedLock:
12994 handleAssertSharedLockAttr(S, D, AL);
12996 case ParsedAttr::AT_PtGuardedVar:
12997 handlePtGuardedVarAttr(S, D, AL);
12999 case ParsedAttr::AT_NoSanitize:
13000 handleNoSanitizeAttr(S, D, AL);
13002 case ParsedAttr::AT_NoSanitizeSpecific:
13003 handleNoSanitizeSpecificAttr(S, D, AL);
13005 case ParsedAttr::AT_GuardedBy:
13006 handleGuardedByAttr(S, D, AL);
13008 case ParsedAttr::AT_PtGuardedBy:
13009 handlePtGuardedByAttr(S, D, AL);
13011 case ParsedAttr::AT_ExclusiveTrylockFunction:
13012 handleExclusiveTrylockFunctionAttr(S, D, AL);
13014 case ParsedAttr::AT_LockReturned:
13015 handleLockReturnedAttr(S, D, AL);
13017 case ParsedAttr::AT_LocksExcluded:
13018 handleLocksExcludedAttr(S, D, AL);
13020 case ParsedAttr::AT_SharedTrylockFunction:
13021 handleSharedTrylockFunctionAttr(S, D, AL);
13023 case ParsedAttr::AT_AcquiredBefore:
13024 handleAcquiredBeforeAttr(S, D, AL);
13026 case ParsedAttr::AT_AcquiredAfter:
13027 handleAcquiredAfterAttr(S, D, AL);
13031 case ParsedAttr::AT_Capability:
13032 case ParsedAttr::AT_Lockable:
13033 handleCapabilityAttr(S, D, AL);
13035 case ParsedAttr::AT_RequiresCapability:
13036 handleRequiresCapabilityAttr(S, D, AL);
13039 case ParsedAttr::AT_AssertCapability:
13040 handleAssertCapabilityAttr(S, D, AL);
13042 case ParsedAttr::AT_AcquireCapability:
13043 handleAcquireCapabilityAttr(S, D, AL);
13045 case ParsedAttr::AT_ReleaseCapability:
13046 handleReleaseCapabilityAttr(S, D, AL);
13048 case ParsedAttr::AT_TryAcquireCapability:
13049 handleTryAcquireCapabilityAttr(S, D, AL);
13053 case ParsedAttr::AT_Consumable:
13054 handleConsumableAttr(S, D, AL);
13056 case ParsedAttr::AT_CallableWhen:
13057 handleCallableWhenAttr(S, D, AL);
13059 case ParsedAttr::AT_ParamTypestate:
13060 handleParamTypestateAttr(S, D, AL);
13062 case ParsedAttr::AT_ReturnTypestate:
13063 handleReturnTypestateAttr(S, D, AL);
13065 case ParsedAttr::AT_SetTypestate:
13066 handleSetTypestateAttr(S, D, AL);
13068 case ParsedAttr::AT_TestTypestate:
13069 handleTestTypestateAttr(S, D, AL);
13073 case ParsedAttr::AT_ArgumentWithTypeTag:
13074 handleArgumentWithTypeTagAttr(S, D, AL);
13076 case ParsedAttr::AT_TypeTagForDatatype:
13077 handleTypeTagForDatatypeAttr(S, D, AL);
13081 case ParsedAttr::AT_SYCLIntelDoublePump:
13082 handleSYCLIntelDoublePumpAttr(S, D, AL);
13084 case ParsedAttr::AT_SYCLIntelSinglePump:
13085 handleSYCLIntelSinglePumpAttr(S, D, AL);
13087 case ParsedAttr::AT_SYCLIntelMemory:
13088 handleSYCLIntelMemoryAttr(S, D, AL);
13090 case ParsedAttr::AT_SYCLIntelRegister:
13091 handleSYCLIntelRegisterAttr(S, D, AL);
13093 case ParsedAttr::AT_SYCLIntelBankWidth:
13094 handleSYCLIntelBankWidthAttr(S, D, AL);
13096 case ParsedAttr::AT_SYCLIntelNumBanks:
13097 handleSYCLIntelNumBanksAttr(S, D, AL);
13099 case ParsedAttr::AT_SYCLIntelPrivateCopies:
13100 handleSYCLIntelPrivateCopiesAttr(S, D, AL);
13102 case ParsedAttr::AT_SYCLIntelMaxReplicates:
13103 handleSYCLIntelMaxReplicatesAttr(S, D, AL);
13105 case ParsedAttr::AT_SYCLIntelSimpleDualPort:
13106 handleIntelSimpleDualPortAttr(S, D, AL);
13108 case ParsedAttr::AT_SYCLIntelMerge:
13109 handleSYCLIntelMergeAttr(S, D, AL);
13111 case ParsedAttr::AT_SYCLIntelBankBits:
13112 handleSYCLIntelBankBitsAttr(S, D, AL);
13114 case ParsedAttr::AT_SYCLIntelForcePow2Depth:
13115 handleSYCLIntelForcePow2DepthAttr(S, D, AL);
13117 case ParsedAttr::AT_SYCLIntelPipeIO:
13118 handleSYCLIntelPipeIOAttr(S, D, AL);
13120 case ParsedAttr::AT_SYCLIntelMaxConcurrency:
13123 case ParsedAttr::AT_SYCLAddIRAttributesFunction:
13124 handleSYCLAddIRAttributesFunctionAttr(S, D, AL);
13126 case ParsedAttr::AT_SYCLAddIRAttributesKernelParameter:
13127 handleSYCLAddIRAttributesKernelParameterAttr(S, D, AL);
13129 case ParsedAttr::AT_SYCLAddIRAttributesGlobalVariable:
13130 handleSYCLAddIRAttributesGlobalVariableAttr(S, D, AL);
13132 case ParsedAttr::AT_SYCLAddIRAnnotationsMember:
13133 handleSYCLAddIRAnnotationsMemberAttr(S, D, AL);
13137 case ParsedAttr::AT_SwiftAsyncName:
13138 handleSwiftAsyncName(S, D, AL);
13140 case ParsedAttr::AT_SwiftAttr:
13141 handleSwiftAttrAttr(S, D, AL);
13143 case ParsedAttr::AT_SwiftBridge:
13144 handleSwiftBridge(S, D, AL);
13146 case ParsedAttr::AT_SwiftError:
13147 handleSwiftError(S, D, AL);
13149 case ParsedAttr::AT_SwiftName:
13150 handleSwiftName(S, D, AL);
13152 case ParsedAttr::AT_SwiftNewType:
13153 handleSwiftNewType(S, D, AL);
13155 case ParsedAttr::AT_SwiftAsync:
13156 handleSwiftAsyncAttr(S, D, AL);
13158 case ParsedAttr::AT_SwiftAsyncError:
13159 handleSwiftAsyncError(S, D, AL);
13163 case ParsedAttr::AT_XRayLogArgs:
13164 handleXRayLogArgsAttr(S, D, AL);
13167 case ParsedAttr::AT_PatchableFunctionEntry:
13168 handlePatchableFunctionEntryAttr(S, D, AL);
13171 case ParsedAttr::AT_AlwaysDestroy:
13172 case ParsedAttr::AT_NoDestroy:
13173 handleDestroyAttr(S, D, AL);
13176 case ParsedAttr::AT_Uninitialized:
13177 handleUninitializedAttr(S, D, AL);
13180 case ParsedAttr::AT_ObjCExternallyRetained:
13181 handleObjCExternallyRetainedAttr(S, D, AL);
13184 case ParsedAttr::AT_MIGServerRoutine:
13185 handleMIGServerRoutineAttr(S, D, AL);
13188 case ParsedAttr::AT_MSAllocator:
13189 handleMSAllocatorAttr(S, D, AL);
13192 case ParsedAttr::AT_ArmBuiltinAlias:
13193 handleArmBuiltinAliasAttr(S, D, AL);
13196 case ParsedAttr::AT_ArmLocallyStreaming:
13197 handleSimpleAttribute<ArmLocallyStreamingAttr>(S, D, AL);
13200 case ParsedAttr::AT_ArmNew:
13201 handleArmNewAttr(S, D, AL);
13204 case ParsedAttr::AT_AcquireHandle:
13205 handleAcquireHandleAttr(S, D, AL);
13208 case ParsedAttr::AT_ReleaseHandle:
13209 handleHandleAttr<ReleaseHandleAttr>(S, D, AL);
13212 case ParsedAttr::AT_UnsafeBufferUsage:
13213 handleUnsafeBufferUsage<UnsafeBufferUsageAttr>(S, D, AL);
13216 case ParsedAttr::AT_UseHandle:
13217 handleHandleAttr<UseHandleAttr>(S, D, AL);
13220 case ParsedAttr::AT_EnforceTCB:
13221 handleEnforceTCBAttr<EnforceTCBAttr, EnforceTCBLeafAttr>(S, D, AL);
13224 case ParsedAttr::AT_EnforceTCBLeaf:
13225 handleEnforceTCBAttr<EnforceTCBLeafAttr, EnforceTCBAttr>(S, D, AL);
13228 case ParsedAttr::AT_BuiltinAlias:
13229 handleBuiltinAliasAttr(S, D, AL);
13232 case ParsedAttr::AT_PreferredType:
13233 handlePreferredTypeAttr(S, D, AL);
13236 case ParsedAttr::AT_UsingIfExists:
13237 handleSimpleAttribute<UsingIfExistsAttr>(S, D, AL);
13240 case ParsedAttr::AT_TypeNullable:
13241 handleNullableTypeAttr(S, D, AL);
13250 const ProcessDeclAttributeOptions &Options) {
13251 if (AttrList.
empty())
13255 ProcessDeclAttribute(*
this, S, D, AL, Options);
13262 Diag(AttrList.begin()->getLoc(), diag::err_attribute_weakref_without_alias)
13263 << cast<NamedDecl>(D);
13272 if (!(D->
hasAttr<OpenCLKernelAttr>() ||
13273 LangOpts.SYCLIsDevice || LangOpts.SYCLIsHost)) {
13275 if (
const auto *A = D->
getAttr<ReqdWorkGroupSizeAttr>()) {
13280 }
else if (
const auto *A = D->
getAttr<WorkGroupSizeHintAttr>()) {
13283 }
else if (
const auto *A = D->
getAttr<SYCLReqdWorkGroupSizeAttr>()) {
13286 }
else if (
const auto *A = D->
getAttr<SYCLWorkGroupSizeHintAttr>()) {
13289 }
else if (
const auto *A = D->
getAttr<SYCLIntelMaxWorkGroupSizeAttr>()) {
13292 }
else if (
const auto *A =
13293 D->
getAttr<SYCLIntelMinWorkGroupsPerComputeUnitAttr>()) {
13296 }
else if (
const auto *A =
13297 D->
getAttr<SYCLIntelMaxWorkGroupsPerMultiprocessorAttr>()) {
13300 }
else if (
const auto *A = D->
getAttr<SYCLIntelNoGlobalWorkOffsetAttr>()) {
13303 }
else if (
const auto *A = D->
getAttr<VecTypeHintAttr>()) {
13306 }
else if (
const auto *A = D->
getAttr<IntelReqdSubGroupSizeAttr>()) {
13309 }
else if (!D->
hasAttr<CUDAGlobalAttr>()) {
13310 if (
const auto *A = D->
getAttr<AMDGPUFlatWorkGroupSizeAttr>()) {
13314 }
else if (
const auto *A = D->
getAttr<AMDGPUWavesPerEUAttr>()) {
13318 }
else if (
const auto *A = D->
getAttr<AMDGPUNumSGPRAttr>()) {
13322 }
else if (
const auto *A = D->
getAttr<AMDGPUNumVGPRAttr>()) {
13335 if (D->
hasAttr<ObjCDesignatedInitializerAttr>() &&
13336 cast<ObjCMethodDecl>(D)->getMethodFamily() !=
OMF_init) {
13338 D->
dropAttr<ObjCDesignatedInitializerAttr>();
13347 if (AL.
getKind() == ParsedAttr::AT_TransparentUnion) {
13348 handleTransparentUnionAttr(*
this, D, AL);
13354 if (D && D->
hasAttr<BPFPreserveAccessIndexAttr>())
13355 handleBPFPreserveAIRecord(*
this, cast<RecordDecl>(D));
13363 if (AL.
getKind() == ParsedAttr::AT_Annotate) {
13364 ProcessDeclAttribute(*
this,
nullptr, ASDecl, AL,
13365 ProcessDeclAttributeOptions());
13367 Diag(AL.
getLoc(), diag::err_only_annotate_after_access_spec);
13385 S.
Diag(AL.
getLoc(), diag::warn_unknown_attribute_ignored)
13388 S.
Diag(AL.
getLoc(), diag::warn_attribute_not_on_decl) << AL
13409 assert(isa<FunctionDecl>(ND) || isa<VarDecl>(ND));
13411 if (
auto *FD = dyn_cast<FunctionDecl>(ND)) {
13420 getCurFPFeatures().isFPConstrained(),
false ,
13433 for (
const auto &AI : FT->param_types()) {
13434 ParmVarDecl *Param = BuildParmVarDeclForTypedef(NewFD,
Loc, AI);
13436 Params.push_back(Param);
13438 NewFD->setParams(Params);
13440 }
else if (
auto *VD = dyn_cast<VarDecl>(ND)) {
13460 WeakTopLevelDecl.push_back(NewD);
13467 PushOnScopeChains(NewD, S);
13468 CurContext = SavedContext;
13477 LoadExternalWeakUndeclaredIdentifiers();
13478 if (WeakUndeclaredIdentifiers.empty())
13481 if (
auto *VD = dyn_cast<VarDecl>(D))
13484 if (
auto *FD = dyn_cast<FunctionDecl>(D))
13485 if (FD->isExternC())
13490 auto I = WeakUndeclaredIdentifiers.find(
Id);
13491 if (I != WeakUndeclaredIdentifiers.end()) {
13492 auto &WeakInfos = I->second;
13493 for (
const auto &W : WeakInfos)
13494 DeclApplyPragmaWeak(S, ND, W);
13495 std::remove_reference_t<decltype(WeakInfos)> EmptyWeakInfos;
13496 WeakInfos.swap(EmptyWeakInfos);
13522 ProcessDeclAttributeList(S, D, NonSlidingAttrs);
13527 ProcessDeclAttributeOptions()
13528 .WithIncludeCXX11Attributes(
false)
13529 .WithIgnoreTypeAttributes(
true));
13538 ProcessDeclAttributeOptions()
13539 .WithIncludeCXX11Attributes(
false)
13540 .WithIgnoreTypeAttributes(
true));
13547 AddPragmaAttributes(S, D);
13556 static bool isForbiddenTypeAllowed(
Sema &S,
Decl *D,
13558 UnavailableAttr::ImplicitReason &reason) {
13562 if (!isa<FieldDecl>(D) && !isa<ObjCPropertyDecl>(D) &&
13563 !isa<FunctionDecl>(D))
13571 if ((isa<ObjCIvarDecl>(D) || isa<ObjCPropertyDecl>(D))) {
13574 reason = UnavailableAttr::IR_ForbiddenWeak;
13583 reason = UnavailableAttr::IR_ARCForbiddenType;
13593 auto Reason = UnavailableAttr::IR_None;
13594 if (D && isForbiddenTypeAllowed(S, D, DD, Reason)) {
13595 assert(Reason &&
"didn't set reason?");
13600 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
13603 if (FD->
hasAttr<UnavailableAttr>() &&
13605 diag::err_arc_array_param_no_ownership) {
13618 assert(DelayedDiagnostics.getCurrentPool());
13620 DelayedDiagnostics.popWithoutEmitting(state);
13636 bool AnyAccessFailures =
false;
13644 switch (diag.
Kind) {
13648 if (!
decl->isInvalidDecl())
13649 handleDelayedAvailabilityCheck(diag,
decl);
13656 if (AnyAccessFailures && isa<DecompositionDecl>(
decl))
13658 HandleDelayedAccessCheck(diag,
decl);
13660 AnyAccessFailures =
true;
13664 handleDelayedForbiddenType(*
this, diag,
decl);
13676 assert(curPool &&
"re-emitting in undelayed context not supported");
13677 curPool->
steal(pool);
Defines the clang::ASTContext interface.
static SmallString< 64 > normalizeName(const IdentifierInfo *Name, const IdentifierInfo *Scope, AttributeCommonInfo::Syntax SyntaxUsed)
static CudaArch getCudaArch(CodeGenModule &CGM)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines helper utilities for supporting the HLSL runtime environment.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Defines the clang::LangOptions interface.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
llvm::MachO::Target Target
llvm::MachO::Record Record
static bool versionsMatch(const VersionTuple &X, const VersionTuple &Y)
Check whether the two versions match.
Defines the clang::Preprocessor interface.
static void ProcessAPINotes(Sema &S, Decl *D, const api_notes::CommonEntityInfo &Info, VersionedInfoMetadata Metadata)
This file declares semantic analysis for CUDA constructs.
static bool isCFStringType(QualType T, ASTContext &Ctx)
static bool isNSStringType(QualType T, ASTContext &Ctx, bool AllowNSAttributedString=false)
static const ParmVarDecl * getFunctionOrMethodParam(const Decl *D, unsigned Idx)
static bool isFunctionOrMethodVariadic(const Decl *D)
static QualType getFunctionOrMethodParamType(const Decl *D, unsigned Idx)
static bool checkUInt32Argument(Sema &S, const AttrInfo &AI, const Expr *Expr, uint32_t &Val, unsigned Idx=UINT_MAX, bool StrictlyUnsigned=false)
If Expr is a valid integer constant, get the value of the integer expression and return success or fa...
static bool checkAttrMutualExclusion(Sema &S, Decl *D, const AttributeCommonInfo &AL)
Diagnose mutually exclusive attributes when present on a given declaration.
static bool isFunctionOrMethod(const Decl *D)
isFunctionOrMethod - Return true if the given decl has function type (function or function-typed vari...
static bool hasDeclarator(const Decl *D)
Return true if the given decl has a declarator that should have been processed by Sema::GetTypeForDec...
static bool isFunctionOrMethodOrBlock(const Decl *D)
Return true if the given decl has function type (function or function-typed variable) or an Objective...
static SourceRange getFunctionOrMethodResultSourceRange(const Decl *D)
static unsigned getNumAttributeArgs(const ParsedAttr &AL)
static bool hasFunctionProto(const Decl *D)
hasFunctionProto - Return true if the given decl has a argument information.
static unsigned getFunctionOrMethodNumParams(const Decl *D)
getFunctionOrMethodNumParams - Return number of function or method parameters.
static bool isInstanceMethod(const Decl *D)
static SourceRange getFunctionOrMethodParamRange(const Decl *D, unsigned Idx)
static QualType getFunctionOrMethodResultType(const Decl *D)
static std::enable_if_t< std::is_base_of_v< Attr, AttrInfo >, SourceLocation > getAttrLoc(const AttrInfo &AL)
A helper function to provide Attribute Location for the Attr types AND the ParsedAttr.
static bool checkPositiveIntArgument(Sema &S, const AttrInfo &AI, const Expr *Expr, int &Val, unsigned Idx=UINT_MAX)
Wrapper around checkUInt32Argument, with an extra check to be sure that the result will fit into a re...
This file declares semantic analysis for HLSL constructs.
This file declares semantic analysis for Objective-C.
This file declares semantic analysis for SYCL constructs.
static Attr * handleSuppressAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static Attr * handleSYCLIntelInitiationIntervalAttr(Sema &S, Stmt *St, const ParsedAttr &A)
static Attr * handleMSConstexprAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static Attr * handleSYCLIntelMaxConcurrencyAttr(Sema &S, Stmt *St, const ParsedAttr &A)
static Attr * handleAlwaysInlineAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
static Attr * handleNoMergeAttr(Sema &S, Stmt *St, const ParsedAttr &A, SourceRange Range)
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
Enumerates target-specific builtins in their own namespaces within namespace clang.
C Language Family Type Representation.
__DEVICE__ int min(int __a, int __b)
__DEVICE__ int max(int __a, int __b)
virtual void AssignInheritanceModel(CXXRecordDecl *RD)
Callback invoked when an MSInheritanceAttr has been attached to a CXXRecordDecl.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
MSGuidDecl * getMSGuidDecl(MSGuidDeclParts Parts) const
Return a declaration for the global GUID object representing the given GUID value.
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
SourceManager & getSourceManager()
TypedefDecl * getObjCInstanceTypeDecl()
Retrieve the typedef declaration corresponding to the Objective-C "instancetype" type.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl.
DeclarationNameTable DeclarationNames
MangleContext * createMangleContext(const TargetInfo *T=nullptr)
If T is null pointer, assume the target in ASTContext.
QualType getRealTypeForBitwidth(unsigned DestWidth, FloatModeKind ExplicitType) const
getRealTypeForBitwidth - sets floating point QualTy according to specified bitwidth.
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod, bool IsBuiltin=false) const
Retrieves the default calling convention for the current target.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
Builtin::Context & BuiltinInfo
QualType getConstType(QualType T) const
Return the uniqued reference to the type for a const qualified type.
const LangOptions & getLangOpts() const
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth,...
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
const TargetInfo & getTargetInfo() const
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type.
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
TargetCXXABI::Kind getCXXABIKind() const
Return the C++ ABI kind that should be used.
const TargetInfo * getAuxTargetInfo() const
TranslationUnitDecl * getTranslationUnitDecl() const
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
uint64_t getCharWidth() const
Return the size of the character type, in bits.
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Represents an access specifier followed by colon ':'.
Attr - This represents one attribute.
SourceLocation getLocation() const
SourceLocation getScopeLoc() const
bool isMicrosoftAttribute() const
bool isClangScope() const
void setAttributeSpellingListIndex(unsigned V)
std::string getNormalizedFullName() const
Gets the normalized full name, which consists of both scope and name and with surrounding underscores...
bool isCXX11Attribute() const
bool isDeclspecAttribute() const
SourceRange getRange() const
unsigned getAttributeSpellingListIndex() const
const IdentifierInfo * getAttrName() const
bool isGNUAttribute() const
bool isRegularKeywordAttribute() const
SourceLocation getLoc() const
const IdentifierInfo * getScopeName() const
bool isStandardAttributeSyntax() const
The attribute is spelled [[]] in either C or C++ mode, including standard attributes spelled with a k...
Kind getParsedKind() const
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
This class is used for builtin types like 'int'.
bool isAuxBuiltinID(unsigned ID) const
Return true if builtin ID belongs to AuxTarget.
llvm::StringRef getName(unsigned ID) const
Return the identifier name for the specified builtin, e.g.
static bool isBuiltinFunc(llvm::StringRef Name)
Returns true if this is a libc/libm function without the '__builtin_' prefix.
unsigned getAuxBuiltinID(unsigned ID) const
Return real builtin ID (i.e.
Represents a static or instance method of a struct/union/class.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
QualType getFunctionObjectParameterType() const
static bool isStaticOverloadedOperator(OverloadedOperatorKind OOK)
Returns true if the given operator is implicitly static in a record context.
Represents a C++ struct/union/class.
const FunctionDecl * isLocalClass() const
If the class is a local class [class.local], returns the enclosing function declaration.
bool isLambda() const
Determine whether this class describes a lambda function object.
bool hasDefinition() const
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
MSInheritanceModel calculateInheritanceModel() const
Calculate what the inheritance model would be for this class.
CXXRecordDecl * getDefinition() const
Represents the this expression in C++.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
CharUnits - This is an opaque type for sizes expressed in character units.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Declaration of a class template.
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
llvm::APSInt getResultAsAPSInt() const
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
const RelatedTargetVersionMapping * getVersionMapping(OSEnvPair Kind) const
The results of name lookup within a DeclContext.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool isFileContext() const
DeclContext * getParent()
getParent - Returns the containing DeclContext.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
A reference to a declared variable, function, enum, etc.
DeclarationNameInfo getNameInfo() const
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr, NonOdrUseReason NOUR=NOUR_None)
bool hasQualifier() const
Determine whether this declaration reference was preceded by a C++ nested-name-specifier,...
ParsedAttributes & getAttributes()
Decl - This represents one declaration (or definition), e.g.
ASTContext & getASTContext() const LLVM_READONLY
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
const FunctionType * getFunctionType(bool BlocksToo=true) const
Looks through the Decl's underlying type to extract a FunctionType when possible.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
bool canBeWeakImported(bool &IsDefinition) const
Determines whether this symbol can be weak-imported, e.g., whether it would be well-formed to add the...
bool isInvalidDecl() const
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
SourceLocation getLocation() const
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
SourceLocation getBeginLoc() const LLVM_READONLY
static bool isFlexibleArrayMemberLike(ASTContext &Context, const Decl *D, QualType Ty, LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel, bool IgnoreTemplateOrMacroSubstitution)
Whether it resembles a flexible array member.
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
void setLexicalDeclContext(DeclContext *DC)
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
DeclContext * getDeclContext()
The name of a declaration.
Expr * getTrailingRequiresClause()
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
SourceLocation getTypeSpecStartLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
TypeSourceInfo * getTypeSourceInfo() const
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
Information about one declarator, including the parsed type information and the identifier.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
const ParsedAttributesView & getDeclarationAttributes() const
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
const ParsedAttributes & getAttributes() const
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
EnumDecl * getDecl() const
This represents one expression.
bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects, bool InConstantContext=false) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer,...
static bool isPotentialConstantExprUnevaluated(Expr *E, const FunctionDecl *FD, SmallVectorImpl< PartialDiagnosticAt > &Diags)
isPotentialConstantExprUnevaluated - Return true if this expression might be usable in a constant exp...
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
bool isValueDependent() const
Determines whether the value of this expression depends on.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates).
bool EvaluateAsConstantExpr(EvalResult &Result, const ASTContext &Ctx, ConstantExprKind Kind=ConstantExprKind::Normal) const
Evaluate an expression that is required to be a constant expression.
bool isIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr) const
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
Represents a function declaration or definition.
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
param_iterator param_end()
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
void setIsMultiVersion(bool V=true)
Sets the multiversion state for this declaration and all of its redeclarations.
QualType getReturnType() const
param_iterator param_begin()
bool isVariadic() const
Whether this function is variadic.
bool isConstexprSpecified() const
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin=false, bool isInlineSpecified=false, bool hasWrittenPrototype=true, ConstexprSpecKind ConstexprKind=ConstexprSpecKind::Unspecified, Expr *TrailingRequiresClause=nullptr)
ArrayRef< ParmVarDecl * > parameters() const
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
const ParmVarDecl * getParamDecl(unsigned i) const
Represents a prototype with parameter type info, e.g.
unsigned getAArch64SMEAttributes() const
Return a bitmask describing the SME attributes on the function type, see AArch64SMETypeAttributes for...
Declaration of a template function.
FunctionType - C99 6.7.5.3 - Function Declarators.
static ArmStateValue getArmZT0State(unsigned AttrBits)
static ArmStateValue getArmZAState(unsigned AttrBits)
QualType getReturnType() const
GlobalDecl - represents a global declaration.
One of these records is kept for each identifier that is lexed.
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
StringRef getName() const
Return the actual identifier string.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
Describes an entity that is being initialized.
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
StrictFlexArraysLevelKind
@ IncompleteOnly
Any trailing array member of undefined size is a FAM.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const
clang::ObjCRuntime ObjCRuntime
std::string getOpenCLVersionString() const
Return the OpenCL C or C++ for OpenCL language name and version as a string.
unsigned getOpenCLCompatibleVersion() const
Return the OpenCL version that kernel language is compatible with.
void push_back(const T &LocalValue)
Represents the results of name lookup.
Describes a module or submodule.
This represents a decl that may have a name.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
bool isExternallyVisible() const
A C++ nested-name-specifier augmented with source location information.
Represents an ObjC class declaration.
void setHasDesignatedInitializers()
Indicate that this interface decl contains at least one initializer marked with the 'objc_designated_...
ObjCMethodDecl - Represents an instance or class method declaration.
Represents a pointer to an Objective C object.
Represents one property declaration in an Objective-C interface.
bool allowsDirectDispatch() const
Does this runtime supports direct dispatch.
static OpaquePtr getFromOpaquePtr(void *P)
void * getAsOpaquePtr() const
bool isSupported(llvm::StringRef Ext, const LangOptions &LO) const
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
unsigned getSourceIndex() const
Get the parameter index as it would normally be encoded for attributes at the source level of represe...
unsigned getASTIndex() const
Get the parameter index as it would normally be encoded at the AST level of representation: zero-orig...
A parameter attribute which changes the argument-passing ABI rule for the parameter.
Represents a parameter to a function.
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
ParsedAttr - Represents a syntactic attribute.
bool isPackExpansion() const
const ParsedType & getMatchingCType() const
IdentifierLoc * getArgAsIdent(unsigned Arg) const
unsigned getSemanticSpelling() const
If the parsed attribute has a semantic equivalent, and it would have a semantic Spelling enumeration ...
bool supportsNonconformingLambdaSyntax() const
bool existsInTarget(const TargetInfo &Target) const
bool checkExactlyNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has exactly as many args as Num.
bool hasParsedType() const
const IdentifierLoc * getEnvironment() const
Expr * getArgAsExpr(unsigned Arg) const
void setInvalid(bool b=true) const
bool hasVariadicArg() const
void handleAttrWithDelayedArgs(Sema &S, Decl *D) const
const ParsedAttrInfo & getInfo() const
bool hasProcessingCache() const
SourceLocation getUnavailableLoc() const
bool diagnoseAppertainsTo(class Sema &S, const Decl *D) const
unsigned getProcessingCache() const
bool acceptsExprPack() const
SourceLocation getStrictLoc() const
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this attribute.
bool isArgIdent(unsigned Arg) const
bool getMustBeNull() const
bool checkAtLeastNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has at least as many args as Num.
bool isUsedAsTypeAttr() const
unsigned getNumArgMembers() const
bool isPragmaClangAttribute() const
True if the attribute is specified using '#pragma clang attribute'.
bool slidesFromDeclToDeclSpecLegacyBehavior() const
Returns whether a [[]] attribute, if specified ahead of a declaration, should be applied to the decl-...
const AvailabilityChange & getAvailabilityObsoleted() const
AttributeCommonInfo::Kind getKind() const
void setProcessingCache(unsigned value) const
const Expr * getMessageExpr() const
bool isParamExpr(size_t N) const
bool isArgExpr(unsigned Arg) const
const AvailabilityChange & getAvailabilityDeprecated() const
bool getLayoutCompatible() const
const Expr * getReplacementExpr() const
ArgsUnion getArg(unsigned Arg) const
getArg - Return the specified argument.
SourceLocation getEllipsisLoc() const
const AvailabilityChange & getAvailabilityIntroduced() const
bool checkAtMostNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has at most as many args as Num.
const ParsedType & getTypeArg() const
void addAtEnd(ParsedAttr *newAttr)
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
IdentifierTable & getIdentifierTable()
A (possibly-)qualified type.
QualType withConst() const
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
bool isConstQualified() const
Determine whether this type is const-qualified.
const Type * getTypePtrOrNull() const
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
ObjCLifetime getObjCLifetime() const
Represents a struct/union/class.
field_iterator field_end() const
field_range fields() const
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
field_iterator field_begin() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
Base for LValueReferenceType and RValueReferenceType.
Scope - A scope is a transient data structure that is used while parsing the program.
unsigned getFlags() const
getFlags - Return the flags for this scope.
@ FunctionDeclarationScope
This is a scope that corresponds to the parameters within a function prototype for a function declara...
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
CUDAFunctionTarget IdentifyTarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
CUDAFunctionTarget CurrentTarget()
Gets the CUDA target for the current context.
SemaDiagnosticBuilder DiagIfHostCode(SourceLocation Loc, unsigned DiagID)
Creates a SemaDiagnosticBuilder that emits the diagnostic if the current context is "used as host cod...
HLSLNumThreadsAttr * mergeNumThreadsAttr(Decl *D, const AttributeCommonInfo &AL, int X, int Y, int Z)
HLSLShaderAttr * mergeShaderAttr(Decl *D, const AttributeCommonInfo &AL, HLSLShaderAttr::ShaderType ShaderType)
HLSLParamModifierAttr * mergeParamModifierAttr(Decl *D, const AttributeCommonInfo &AL, HLSLParamModifierAttr::Spelling Spelling)
bool isCFError(RecordDecl *D)
IdentifierInfo * getNSErrorIdent()
Retrieve the identifier "NSError".
static bool isTypeDecoratedWithDeclAttribute(QualType Ty)
Sema - This implements semantic analysis and AST building for C.
void AddXConsumedAttr(Decl *D, const AttributeCommonInfo &CI, RetainOwnershipKind K, bool IsTemplateInstantiation)
InternalLinkageAttr * mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL)
OpenCLOptions & getOpenCLOptions()
SYCLIntelMaxConcurrencyAttr * MergeSYCLIntelMaxConcurrencyAttr(Decl *D, const SYCLIntelMaxConcurrencyAttr &A)
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
SYCLIntelMaxReplicatesAttr * MergeSYCLIntelMaxReplicatesAttr(Decl *D, const SYCLIntelMaxReplicatesAttr &A)
void AddSYCLIntelMaxConcurrencyAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E)
AddSYCLIntelMaxConcurrencyAttr - Adds a max_concurrency attribute to a particular declaration.
void ProcessDeclAttributeDelayed(Decl *D, const ParsedAttributesView &AttrList)
void AddSYCLIntelMaxReplicatesAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E)
void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Name, bool InInstantiation=false)
AddModeAttr - Adds a mode attribute to a particular declaration.
SYCLIntelNumSimdWorkItemsAttr * MergeSYCLIntelNumSimdWorkItemsAttr(Decl *D, const SYCLIntelNumSimdWorkItemsAttr &A)
bool CheckCallingConvAttr(const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD=nullptr, CUDAFunctionTarget CFT=CUDAFunctionTarget::InvalidTarget)
Check validaty of calling convention attribute attr.
void ProcessPragmaWeak(Scope *S, Decl *D)
bool checkSectionName(SourceLocation LiteralLoc, StringRef Str)
bool checkCommonAttributeFeatures(const Decl *D, const ParsedAttr &A, bool SkipArgCountCheck=false)
Handles semantic checking for features that are common to all attributes, such as checking whether a ...
MinSizeAttr * mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI)
void AddSYCLIntelMaxWorkGroupsPerMultiprocessorAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E)
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
IntelNamedSubGroupSizeAttr * MergeIntelNamedSubGroupSizeAttr(Decl *D, const IntelNamedSubGroupSizeAttr &A)
void AddSYCLUsesAspectsAttr(Decl *D, const AttributeCommonInfo &CI, Expr **Exprs, unsigned Size)
ExtVectorDeclsType ExtVectorDecls
ExtVectorDecls - This is a list all the extended vector types.
WebAssemblyImportModuleAttr * mergeImportModuleAttr(Decl *D, const WebAssemblyImportModuleAttr &AL)
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
bool checkTargetClonesAttrString(SourceLocation LiteralLoc, StringRef Str, const StringLiteral *Literal, Decl *D, bool &HasDefault, bool &HasCommas, bool &HasNotDefault, SmallVectorImpl< SmallString< 64 >> &StringsBuffer)
MSInheritanceAttr * mergeMSInheritanceAttr(Decl *D, const AttributeCommonInfo &CI, bool BestCase, MSInheritanceModel Model)
SYCLIntelLoopFuseAttr * MergeSYCLIntelLoopFuseAttr(Decl *D, const SYCLIntelLoopFuseAttr &A)
bool AnyWorkGroupSizesDiffer(const Expr *LHSXDim, const Expr *LHSYDim, const Expr *LHSZDim, const Expr *RHSXDim, const Expr *RHSYDim, const Expr *RHSZDim)
void AddLaunchBoundsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks)
AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular declaration.
void addAMDGPUWavesPerEUAttr(Decl *D, const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
addAMDGPUWavePersEUAttr - Adds an amdgpu_waves_per_eu attribute to a particular declaration.
void AddSYCLWorkGroupSizeHintAttr(Decl *D, const AttributeCommonInfo &CI, Expr *XDim, Expr *YDim, Expr *ZDim)
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, bool BestCase, MSInheritanceModel SemanticSpelling)
AMDGPUMaxNumWorkGroupsAttr * CreateAMDGPUMaxNumWorkGroupsAttr(const AttributeCommonInfo &CI, Expr *XExpr, Expr *YExpr, Expr *ZExpr)
Create an AMDGPUMaxNumWorkGroupsAttr attribute.
void AddSYCLDeviceHasAttr(Decl *D, const AttributeCommonInfo &CI, Expr **Exprs, unsigned Size)
SYCLAddIRAttributesGlobalVariableAttr * MergeSYCLAddIRAttributesGlobalVariableAttr(Decl *D, const SYCLAddIRAttributesGlobalVariableAttr &A)
SYCLDeviceHasAttr * MergeSYCLDeviceHasAttr(Decl *D, const SYCLDeviceHasAttr &A)
FunctionDecl * ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, bool Complain=false, DeclAccessPair *Found=nullptr, TemplateSpecCandidateSet *FailedTSC=nullptr)
Given an expression that refers to an overloaded function, try to resolve that overloaded function ex...
void redelayDiagnostics(sema::DelayedDiagnosticPool &pool)
void DiagnoseDeprecatedAttribute(const ParsedAttr &A, StringRef NewScope, StringRef NewName)
Emit a diagnostic about the given attribute having a deprecated name, and also emit a fixit hint to g...
llvm::Error isValidSectionSpecifier(StringRef Str)
DLLExportAttr * mergeDLLExportAttr(Decl *D, const AttributeCommonInfo &CI)
void AddSYCLIntelBankWidthAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E)
void checkUnusedDeclAttributes(Declarator &D)
bool UnifySection(StringRef SectionName, int SectionFlags, NamedDecl *TheDecl)
void AddParameterABIAttr(Decl *D, const AttributeCommonInfo &CI, ParameterABI ABI)
SYCLAddIRAttributesFunctionAttr * MergeSYCLAddIRAttributesFunctionAttr(Decl *D, const SYCLAddIRAttributesFunctionAttr &A)
@ UPPC_Expression
An arbitrary expression.
CodeSegAttr * mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Name)
bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type)
void PopParsingDeclaration(ParsingDeclState state, Decl *decl)
void AddSYCLReqdWorkGroupSizeAttr(Decl *D, const AttributeCommonInfo &CI, Expr *XDim, Expr *YDim, Expr *ZDim)
void CheckDeprecatedSYCLAttributeSpelling(const ParsedAttr &A, StringRef NewName="")
Diagnoses an attribute in the 'intelfpga' namespace and suggests using the attribute in the 'intel' n...
bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl, const ParsedAttributesView &AttrList)
SYCLIntelPipeIOAttr * MergeSYCLIntelPipeIOAttr(Decl *D, const SYCLIntelPipeIOAttr &A)
void CheckAlignasUnderalignment(Decl *D)
void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AttrList, const ProcessDeclAttributeOptions &Options=ProcessDeclAttributeOptions())
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
void AddSYCLAddIRAnnotationsMemberAttr(Decl *D, const AttributeCommonInfo &CI, MutableArrayRef< Expr * > Args)
bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value)
void AddSYCLIntelPrivateCopiesAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E)
const LangOptions & LangOpts
const LangOptions & getLangOpts() const
static const uint64_t MaximumAlignment
void CheckSYCLAddIRAttributesFunctionAttrConflicts(Decl *D)
void AddSYCLIntelNumBanksAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E)
EnforceTCBAttr * mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL)
CUDALaunchBoundsAttr * CreateLaunchBoundsAttr(const AttributeCommonInfo &CI, Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks)
Create an CUDALaunchBoundsAttr attribute.
SYCLAddIRAnnotationsMemberAttr * MergeSYCLAddIRAnnotationsMemberAttr(Decl *D, const SYCLAddIRAnnotationsMemberAttr &A)
void AddSYCLIntelSchedulerTargetFmaxMhzAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E)
EnforceTCBLeafAttr * mergeEnforceTCBLeafAttr(Decl *D, const EnforceTCBLeafAttr &AL)
NamedDecl * getCurFunctionOrMethodDecl() const
getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method or C function we're in,...
AMDGPUWavesPerEUAttr * CreateAMDGPUWavesPerEUAttr(const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
Create an AMDGPUWavesPerEUAttr attribute.
IntelReqdSubGroupSizeAttr * MergeIntelReqdSubGroupSizeAttr(Decl *D, const IntelReqdSubGroupSizeAttr &A)
bool checkTargetVersionAttr(SourceLocation LiteralLoc, Decl *D, StringRef &Str, bool &isDefault)
UuidAttr * mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI, StringRef UuidAsWritten, MSGuidDecl *GuidDecl)
bool isValidPointerAttrType(QualType T, bool RefOkay=false)
Determine if type T is a valid subject for a nonnull and similar attributes.
SYCLAddIRAttributesKernelParameterAttr * MergeSYCLAddIRAttributesKernelParameterAttr(Decl *D, const SYCLAddIRAttributesKernelParameterAttr &A)
void AddIntelReqdSubGroupSize(Decl *D, const AttributeCommonInfo &CI, Expr *E)
bool checkStringLiteralArgumentAttr(const AttributeCommonInfo &CI, const Expr *E, StringRef &Str, SourceLocation *ArgLocation=nullptr)
SYCLIntelESimdVectorizeAttr * MergeSYCLIntelESimdVectorizeAttr(Decl *D, const SYCLIntelESimdVectorizeAttr &A)
SYCLIntelSchedulerTargetFmaxMhzAttr * MergeSYCLIntelSchedulerTargetFmaxMhzAttr(Decl *D, const SYCLIntelSchedulerTargetFmaxMhzAttr &A)
ErrorAttr * mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI, StringRef NewUserDiagnostic)
FormatAttr * mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Format, int FormatIdx, int FirstArg)
VisibilityAttr * mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, VisibilityAttr::VisibilityType Vis)
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
SYCLTypeAttr * MergeSYCLTypeAttr(Decl *D, const AttributeCommonInfo &CI, SYCLTypeAttr::SYCLType TypeName)
@ Compatible
Compatible - the types are compatible according to the standard.
SourceManager & getSourceManager() const
void AddSYCLIntelNoGlobalWorkOffsetAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E)
bool DiagnoseSwiftName(Decl *D, StringRef Name, SourceLocation Loc, const ParsedAttr &AL, bool IsAsync)
Do a check to make sure Name looks like a legal argument for the swift_name attribute applied to decl...
void AddSYCLAddIRAttributesKernelParameterAttr(Decl *D, const AttributeCommonInfo &CI, MutableArrayRef< Expr * > Args)
bool AllWorkGroupSizesSame(const Expr *LHSXDim, const Expr *LHSYDim, const Expr *LHSZDim, const Expr *RHSXDim, const Expr *RHSYDim, const Expr *RHSZDim)
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
void AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, Expr *OE)
AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular declaration.
void AddSYCLIntelMaxGlobalWorkDimAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E)
SYCLWorkGroupSizeHintAttr * MergeSYCLWorkGroupSizeHintAttr(Decl *D, const SYCLWorkGroupSizeHintAttr &A)
void AddSYCLIntelForcePow2DepthAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E)
SYCLIntelMaxGlobalWorkDimAttr * MergeSYCLIntelMaxGlobalWorkDimAttr(Decl *D, const SYCLIntelMaxGlobalWorkDimAttr &A)
void AddSYCLIntelBankBitsAttr(Decl *D, const AttributeCommonInfo &CI, Expr **Exprs, unsigned Size)
SYCLIntelNumBanksAttr * MergeSYCLIntelNumBanksAttr(Decl *D, const SYCLIntelNumBanksAttr &A)
OptimizeNoneAttr * mergeOptimizeNoneAttr(Decl *D, const AttributeCommonInfo &CI)
SYCLIntelMaxWorkGroupSizeAttr * MergeSYCLIntelMaxWorkGroupSizeAttr(Decl *D, const SYCLIntelMaxWorkGroupSizeAttr &A)
void AddSYCLAddIRAttributesGlobalVariableAttr(Decl *D, const AttributeCommonInfo &CI, MutableArrayRef< Expr * > Args)
ASTContext & getASTContext() const
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type.
bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str)
AlwaysInlineAttr * mergeAlwaysInlineAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Ident)
void addAMDGPUFlatWorkGroupSizeAttr(Decl *D, const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
addAMDGPUFlatWorkGroupSizeAttr - Adds an amdgpu_flat_work_group_size attribute to a particular declar...
void NoteAllOverloadCandidates(Expr *E, QualType DestType=QualType(), bool TakingAddress=false)
void addAMDGPUMaxNumWorkGroupsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *XExpr, Expr *YExpr, Expr *ZExpr)
addAMDGPUMaxNumWorkGroupsAttr - Adds an amdgpu_max_num_work_groups attribute to a particular declarat...
@ AP_PragmaClangAttribute
The availability attribute was applied using '#pragma clang attribute'.
@ AP_InferredFromOtherPlatform
The availability attribute for a specific platform was inferred from an availability attribute for an...
@ AP_Explicit
The availability attribute was specified explicitly next to the declaration.
@ AMK_None
Don't merge availability attributes at all.
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
SectionAttr * mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Name)
SwiftNameAttr * mergeSwiftNameAttr(Decl *D, const SwiftNameAttr &SNA, StringRef Name)
AvailabilityAttr * mergeAvailabilityAttr(NamedDecl *D, const AttributeCommonInfo &CI, IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK, int Priority, IdentifierInfo *IIEnvironment)
bool CheckMaxAllowedWorkGroupSize(const Expr *RWGSXDim, const Expr *RWGSYDim, const Expr *RWGSZDim, const Expr *MWGSXDim, const Expr *MWGSYDim, const Expr *MWGSZDim)
bool CheckAttrTarget(const ParsedAttr &CurrAttr)
void AddSYCLIntelESimdVectorizeAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E)
SYCLIntelMaxWorkGroupsPerMultiprocessorAttr * MergeSYCLIntelMaxWorkGroupsPerMultiprocessorAttr(Decl *D, const SYCLIntelMaxWorkGroupsPerMultiprocessorAttr &A)
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
void AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, bool IsPackExpansion)
AddAlignedAttr - Adds an aligned attribute to a particular declaration.
SYCLUsesAspectsAttr * MergeSYCLUsesAspectsAttr(Decl *D, const SYCLUsesAspectsAttr &A)
SYCLIntelForcePow2DepthAttr * MergeSYCLIntelForcePow2DepthAttr(Decl *D, const SYCLIntelForcePow2DepthAttr &A)
SYCLIntelBankWidthAttr * MergeSYCLIntelBankWidthAttr(Decl *D, const SYCLIntelBankWidthAttr &A)
void AddSYCLAddIRAttributesFunctionAttr(Decl *D, const AttributeCommonInfo &CI, MutableArrayRef< Expr * > Args)
TypeVisibilityAttr * mergeTypeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, TypeVisibilityAttr::VisibilityType Vis)
void AddAnnotationAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Annot, MutableArrayRef< Expr * > Args)
AddAnnotationAttr - Adds an annotation Annot with Args arguments to D.
void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W)
SYCLIntelMinWorkGroupsPerComputeUnitAttr * MergeSYCLIntelMinWorkGroupsPerComputeUnitAttr(Decl *D, const SYCLIntelMinWorkGroupsPerComputeUnitAttr &A)
bool CheckAttrNoArgs(const ParsedAttr &CurrAttr)
WebAssemblyImportNameAttr * mergeImportNameAttr(Decl *D, const WebAssemblyImportNameAttr &AL)
DarwinSDKInfo * getDarwinSDKInfoForAvailabilityChecking(SourceLocation Loc, StringRef Platform)
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing,...
void AddSYCLIntelNumSimdWorkItemsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E)
void AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E)
AddAlignValueAttr - Adds an align_value attribute to a particular declaration.
void AddSYCLIntelMinWorkGroupsPerComputeUnitAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E)
BTFDeclTagAttr * mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL)
void AddSYCLIntelLoopFuseAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E)
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
SYCLIntelInitiationIntervalAttr * MergeSYCLIntelInitiationIntervalAttr(Decl *D, const SYCLIntelInitiationIntervalAttr &A)
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
SYCLReqdWorkGroupSizeAttr * MergeSYCLReqdWorkGroupSizeAttr(Decl *D, const SYCLReqdWorkGroupSizeAttr &A)
void addSYCLIntelPipeIOAttr(Decl *D, const AttributeCommonInfo &CI, Expr *ID)
addSYCLIntelPipeIOAttr - Adds a pipe I/O attribute to a particular declaration.
void AddAllocAlignAttr(Decl *D, const AttributeCommonInfo &CI, Expr *ParamExpr)
AddAllocAlignAttr - Adds an alloc_align attribute to a particular declaration.
AMDGPUFlatWorkGroupSizeAttr * CreateAMDGPUFlatWorkGroupSizeAttr(const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
Create an AMDGPUWavesPerEUAttr attribute.
QualType BuildCountAttributedArrayType(QualType WrappedTy, Expr *CountExpr)
SYCLIntelNoGlobalWorkOffsetAttr * MergeSYCLIntelNoGlobalWorkOffsetAttr(Decl *D, const SYCLIntelNoGlobalWorkOffsetAttr &A)
DLLImportAttr * mergeDLLImportAttr(Decl *D, const AttributeCommonInfo &CI)
void AddSYCLIntelInitiationIntervalAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E)
bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall, const FunctionProtoType *Proto)
CheckFunctionCall - Check a direct function call for various correctness and safety properties not st...
ASTMutationListener * getASTMutationListener() const
void AddSYCLIntelMaxWorkGroupSizeAttr(Decl *D, const AttributeCommonInfo &CI, Expr *XDim, Expr *YDim, Expr *ZDim)
NamedDecl * DeclClonePragmaWeak(NamedDecl *ND, const IdentifierInfo *II, SourceLocation Loc)
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
bool isInSystemMacro(SourceLocation loc) const
Returns whether Loc is expanded from a macro in a system header.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteral - This represents a string literal expression, e.g.
bool isBeingDefined() const
Return true if this decl is currently being defined.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
TagKind getTagKind() const
Exposes information about the current target.
const llvm::VersionTuple & getSDKVersion() const
uint64_t getPointerWidth(LangAS AddrSpace) const
Return the width of pointers on this target, for the specified address space.
virtual CallingConv getDefaultCallingConv() const
Gets the default calling convention for the given target and declaration context.
virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const
Determines whether a given calling convention is valid for the target.
bool isTLSSupported() const
Whether the target supports thread-local storage.
unsigned getMaxTLSAlign() const
Return the maximum alignment (in bits) of a TLS variable.
virtual unsigned getRegisterWidth() const
Return the "preferred" register width on this target.
virtual bool validateCpuSupports(StringRef Name) const
virtual bool doesFeatureAffectCodeGen(StringRef Feature) const
Returns true if feature has an impact on target code generation.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
virtual bool validateCPUSpecificCPUDispatch(StringRef Name) const
virtual bool hasProtectedVisibility() const
Does this target support "protected" visibility?
unsigned getRegParmMax() const
virtual unsigned getUnwindWordWidth() const
virtual bool isValidFeatureName(StringRef Feature) const
Determine whether this TargetInfo supports the given feature.
unsigned getCharWidth() const
virtual ParsedTargetAttr parseTargetAttr(StringRef Str) const
virtual bool supportsTargetAttributeTune() const
Determine whether this TargetInfo supports tune in target attribute.
virtual bool shouldDLLImportComdatSymbols() const
Does this target aim for semantic compatibility with Microsoft C++ code using dllimport/export attrib...
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
virtual bool isValidCPUName(StringRef Name) const
Determine whether this TargetInfo supports the given CPU name.
TargetOptions & getTargetOpts() const
Retrieve the target options.
virtual bool validateBranchProtection(StringRef Spec, StringRef Arch, BranchProtectionInfo &BPI, StringRef &Err) const
Determine if this TargetInfo supports the given branch protection specification.
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
Represents a type template specialization; the template must be a class template, a type alias templa...
[BoundsSafety] Represents information of declarations referenced by the arguments of the counted_by a...
const Type * getTypeForDecl() const
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
The base class of the type hierarchy.
bool isSizelessType() const
As an extension, we classify types as one of "sized" or "sizeless"; every type is one or the other.
bool isStructureType() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isBlockPointerType() const
bool isBooleanType() const
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
bool isVoidPointerType() const
bool isFunctionPointerType() const
bool isPointerType() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isObjCNSObjectType() const
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that the type refers to.
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool hasUnsignedIntegerRepresentation() const
Determine whether this type has an unsigned integer representation of some sort, e....
bool isExtVectorType() const
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isBitIntType() const
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isCARCBridgableType() const
Determine whether the given type T is a "bridgeable" C type.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
bool isMemberPointerType() const
bool isObjCIdType() const
bool isObjCObjectType() const
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const
Return the implicit lifetime for this type, which must not be dependent.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isObjCObjectPointerType() const
Visibility getVisibility() const
Determine the visibility of this type.
bool hasFloatingRepresentation() const
Determine whether this type has a floating-point representation of some sort, e.g....
bool isVectorType() const
bool isFloatingType() const
bool isAnyPointerType() const
const T * getAs() const
Member-template getAs<specific type>'.
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs,...
bool isNullPtrType() const
bool isObjCRetainableType() const
bool isTypedefNameType() const
Determines whether this type is written as a typedef-name.
bool hasPointerRepresentation() const
Whether this type is represented natively as a pointer.
Base class for declarations which introduce a typedef-name.
static UnaryOperator * Create(const ASTContext &C, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)
Represents a dependent using declaration which was marked with typename.
Represents a dependent using declaration which was not marked with typename.
Represents a C++ using-declaration.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
Represents a variable declaration or definition.
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
TLSKind getTLSKind() const
void setARCPseudoStrong(bool PS)
bool isExceptionVariable() const
Determine whether this variable is the exception variable in a C++ catch statememt or an Objective-C ...
bool hasExternalStorage() const
Returns true if a variable has extern or private_extern storage.
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
@ TLS_None
Not a TLS variable.
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Represents a GCC generic vector type.
Captures information about a #pragma weak directive.
SourceLocation getLocation() const
const IdentifierInfo * getAlias() const
A collection of diagnostics which were delayed.
void steal(DelayedDiagnosticPool &pool)
Steal the diagnostics from the given pool.
const DelayedDiagnosticPool * getParent() const
pool_iterator pool_end() const
SmallVectorImpl< DelayedDiagnostic >::const_iterator pool_iterator
pool_iterator pool_begin() const
A diagnostic message which has been conditionally emitted pending the complete parsing of the current...
QualType getForbiddenTypeOperand() const
unsigned getForbiddenTypeDiagnostic() const
The diagnostic ID to emit.
unsigned getForbiddenTypeArgument() const
Defines the clang::TargetInfo interface.
constexpr XRayInstrMask None
bool isGlobalVar(Expr *E)
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
uint32_t Literal
Literals are represented as positive integers.
bool Sub(InterpState &S, CodePtr OpPC)
unsigned llvm::PointerUnion< const Decl *, const Expr * > DeclTy
std::string toString(const til::SExpr *E)
The JSON file list parser is used to communicate input to InstallAPI.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
bool isa(CodeGen::Address addr)
AttributeDeclKind
These constants match the enumerated choices of warn_attribute_wrong_decl_type and err_attribute_wron...
@ ExpectedFunctionMethodOrParameter
@ ExpectedFunctionWithProtoType
@ ExpectedFunctionMethodOrBlock
@ ExpectedTypeOrNamespace
@ ExpectedVariableFieldOrTag
@ ExpectedVariableOrField
@ ExpectedFunctionOrMethod
@ ExpectedVariableOrFunction
@ ExpectedFunctionVariableOrClass
if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))
llvm::StringRef getParameterABISpelling(ParameterABI kind)
@ OK_Ordinary
An ordinary object is located at an address in memory.
CudaVersion ToCudaVersion(llvm::VersionTuple)
LLVM_READONLY bool isValidAsciiIdentifier(StringRef S, bool AllowDollar=false)
Return true if this is a valid ASCII identifier.
CudaArch StringToCudaArch(llvm::StringRef S)
Language
The language for the input, used to select and validate the language standard and possible actions.
AttributeArgumentNType
These constants match the enumerated choices of err_attribute_argument_n_type and err_attribute_argum...
@ AANT_ArgumentIntegerConstant
@ AANT_ArgumentBuiltinFunction
@ AANT_ArgumentConstantExpr
@ AANT_ArgumentIdentifier
@ SD_Automatic
Automatic storage duration (most local variables).
@ Property
The type of a property.
ParameterABI
Kinds of parameter ABI.
@ SwiftAsyncContext
This parameter (which must have pointer type) uses the special Swift asynchronous context-pointer ABI...
@ SwiftErrorResult
This parameter (which must have pointer-to-pointer type) uses the special Swift error-result ABI trea...
@ Ordinary
This parameter uses ordinary ABI rules for its type.
@ SwiftIndirectResult
This parameter (which must have pointer type) is a Swift indirect result parameter.
@ SwiftContext
This parameter (which must have pointer type) uses the special Swift context-pointer ABI treatment.
@ Struct
The "struct" keyword.
LLVM_READONLY bool isHexDigit(unsigned char c)
Return true if this character is an ASCII hex digit: [0-9a-fA-F].
SanitizerMask parseSanitizerValue(StringRef Value, bool AllowGroups)
Parse a single value from a -fsanitize= or -fno-sanitize= value list.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
const FunctionProtoType * T
MSInheritanceModel
Assigned inheritance model for a class in the MS C++ ABI.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
@ Generic
not a target-specific vector type
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
@ Union
The "union" keyword introduces the elaborated-type-specifier.
bool IsArmStreamingFunction(const FunctionDecl *FD, bool IncludeLocallyStreaming)
Returns whether the given FunctionDecl has an __arm[_locally]_streaming attribute.
@ Other
Other implicit parameter.
const char * CudaArchToString(CudaArch A)
Represents information about a change in availability for an entity, which is part of the encoding of...
VersionTuple Version
The version number at which the change occurred.
bool isValid() const
Determine whether this availability change is valid.
static constexpr OSEnvPair macOStoMacCatalystPair()
Returns the os-environment mapping pair that's used to represent the macOS -> Mac Catalyst version ma...
static constexpr OSEnvPair iOStoWatchOSPair()
Returns the os-environment mapping pair that's used to represent the iOS -> watchOS version mapping.
static constexpr OSEnvPair iOStoTvOSPair()
Returns the os-environment mapping pair that's used to represent the iOS -> tvOS version mapping.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
DeclarationName getName() const
getName - Returns the embedded declaration name.
const ParsedAttributesView & getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
EvalResult is a struct with detailed info about an evaluated expression.
APValue Val
Val - This is the value the expression can be folded to.
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
Wraps an identifier and optional source location for the identifier.
Parts of a decomposed MSGuidDecl.
uint16_t Part2
...-89ab-...
uint32_t Part1
{01234567-...
uint16_t Part3
...-cdef-...
uint8_t Part4And5[8]
...-0123-456789abcdef}
virtual AttrHandling handleDeclAttribute(Sema &S, Decl *D, const ParsedAttr &Attr) const
If this ParsedAttrInfo knows how to handle this ParsedAttr applied to this Decl then do so and return...
Contains information gathered from parsing the contents of TargetAttr.
std::vector< std::string > Features
StringRef BranchProtection