45#include "llvm/ADT/STLExtras.h"
46#include "llvm/ADT/STLForwardCompat.h"
47#include "llvm/ADT/StringExtras.h"
48#include "llvm/Demangle/Demangle.h"
49#include "llvm/IR/Assumptions.h"
50#include "llvm/MC/MCSectionMachO.h"
51#include "llvm/Support/Error.h"
52#include "llvm/Support/MathExtras.h"
53#include "llvm/Support/raw_ostream.h"
88 return isa<DeclaratorDecl>(D) || isa<BlockDecl>(D) || isa<TypedefNameDecl>(D) ||
89 isa<ObjCPropertyDecl>(D);
97 return isa<FunctionProtoType>(FnTy);
98 return isa<ObjCMethodDecl>(D) || isa<BlockDecl>(D);
106 return cast<FunctionProtoType>(FnTy)->getNumParams();
107 if (
const auto *BD = dyn_cast<BlockDecl>(D))
108 return BD->getNumParams();
109 return cast<ObjCMethodDecl>(D)->param_size();
114 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
115 return FD->getParamDecl(Idx);
116 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
117 return MD->getParamDecl(Idx);
118 if (
const auto *BD = dyn_cast<BlockDecl>(D))
119 return BD->getParamDecl(Idx);
125 return cast<FunctionProtoType>(FnTy)->getParamType(Idx);
126 if (
const auto *BD = dyn_cast<BlockDecl>(D))
127 return BD->getParamDecl(Idx)->getType();
129 return cast<ObjCMethodDecl>(D)->parameters()[Idx]->getType();
134 return PVD->getSourceRange();
140 return FnTy->getReturnType();
141 return cast<ObjCMethodDecl>(D)->getReturnType();
145 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
146 return FD->getReturnTypeSourceRange();
147 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
148 return MD->getReturnTypeSourceRange();
154 return cast<FunctionProtoType>(FnTy)->isVariadic();
155 if (
const auto *BD = dyn_cast<BlockDecl>(D))
156 return BD->isVariadic();
157 return cast<ObjCMethodDecl>(D)->isVariadic();
161 if (
const auto *MethodDecl = dyn_cast<CXXMethodDecl>(D))
162 return MethodDecl->isInstance();
167 bool AllowNSAttributedString =
false) {
178 if (AllowNSAttributedString &&
179 ClsName == &Ctx.
Idents.
get(
"NSAttributedString"))
182 return ClsName == &Ctx.
Idents.
get(
"NSString") ||
183 ClsName == &Ctx.
Idents.
get(
"NSMutableString");
209template <
typename AttrInfo>
210static std::enable_if_t<std::is_base_of_v<Attr, AttrInfo>,
SourceLocation>
212 return AL.getLocation();
221template <
typename AttrInfo>
223 uint32_t &Val,
unsigned Idx =
UINT_MAX,
224 bool StrictlyUnsigned =
false) {
225 std::optional<llvm::APSInt> I = llvm::APSInt(32);
238 if (!I->isIntN(32)) {
240 <<
toString(*I, 10,
false) << 32 << 1;
244 if (StrictlyUnsigned && I->isSigned() && I->isNegative()) {
245 S.
Diag(
getAttrLoc(AI), diag::err_attribute_requires_positive_integer)
250 Val = (uint32_t)I->getZExtValue();
257template <
typename AttrInfo>
259 int &Val,
unsigned Idx =
UINT_MAX) {
264 if (UVal > (uint32_t)std::numeric_limits<int>::max()) {
268 <<
toString(I, 10,
false) << 32 << 0;
278template <
typename AttrTy>
280 if (
const auto *A = D->
getAttr<AttrTy>()) {
281 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
284 S.
Diag(A->getLocation(), diag::note_conflicting_attribute);
290template <
typename AttrTy>
292 if (
const auto *A = D->
getAttr<AttrTy>()) {
296 S.
Diag(A->getLocation(), diag::note_conflicting_attribute);
306template <
typename AttrInfo>
308 Sema &S,
const Decl *D,
const AttrInfo &AI,
unsigned AttrArgNum,
309 const Expr *IdxExpr,
ParamIdx &Idx,
bool CanIndexImplicitThis =
false) {
320 std::optional<llvm::APSInt> IdxInt;
329 unsigned IdxSource = IdxInt->getLimitedValue(
UINT_MAX);
330 if (IdxSource < 1 || (!IV && IdxSource > NumParams)) {
331 S.
Diag(
getAttrLoc(AI), diag::err_attribute_argument_out_of_bounds)
335 if (HasImplicitThisParam && !CanIndexImplicitThis) {
336 if (IdxSource == 1) {
337 S.
Diag(
getAttrLoc(AI), diag::err_attribute_invalid_implicit_this_argument)
351 const Expr *E, StringRef &Str,
357 if (!Literal || (!Literal->isUnevaluated() && !Literal->isOrdinary())) {
363 Str = Literal->getString();
377 Diag(Loc->
Loc, diag::err_attribute_argument_type)
383 *ArgLocation = Loc->
Loc;
393 if (!Literal || (!Literal->isUnevaluated() && !Literal->isOrdinary())) {
398 Str = Literal->getString();
404template <
typename AttrType>
410template <
typename... DiagnosticArgs>
416template <
typename T,
typename... DiagnosticArgs>
419 DiagnosticArgs &&... ExtraArgs) {
421 std::forward<DiagnosticArgs>(ExtraArgs)...);
428template <
typename AttrType,
typename... DiagnosticArgs>
431 bool PassesCheck,
unsigned DiagID,
432 DiagnosticArgs &&... ExtraArgs) {
438 handleSimpleAttribute<AttrType>(S, D, CI);
459 bool foundStarOperator = IsOverloadedOperatorPresent(
Record, OO_Star);
460 bool foundArrowOperator = IsOverloadedOperatorPresent(
Record, OO_Arrow);
461 if (foundStarOperator && foundArrowOperator)
468 for (
const auto &BaseSpecifier : CXXRecord->bases()) {
469 if (!foundStarOperator)
470 foundStarOperator = IsOverloadedOperatorPresent(
471 BaseSpecifier.getType()->getAsRecordDecl(), OO_Star);
472 if (!foundArrowOperator)
473 foundArrowOperator = IsOverloadedOperatorPresent(
474 BaseSpecifier.getType()->getAsRecordDecl(), OO_Arrow);
477 if (foundStarOperator && foundArrowOperator)
488 const auto *VD = cast<ValueDecl>(D);
497 if (RT->isIncompleteType())
504 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_decl_not_pointer) << AL << QT;
521template <
typename AttrType>
528 if (
const auto *CRD = dyn_cast<CXXRecordDecl>(RD)) {
530 return !Base->hasAttr<AttrType>();
552 return checkRecordDeclForAttr<CapabilityAttr>(RT->
getDecl());
564 return TN->
hasAttr<CapabilityAttr>();
583 if (
const auto *E = dyn_cast<CastExpr>(Ex))
585 else if (
const auto *E = dyn_cast<ParenExpr>(Ex))
587 else if (
const auto *E = dyn_cast<UnaryOperator>(Ex)) {
588 if (E->getOpcode() == UO_LNot || E->getOpcode() == UO_AddrOf ||
589 E->getOpcode() == UO_Deref)
592 }
else if (
const auto *E = dyn_cast<BinaryOperator>(Ex)) {
593 if (E->getOpcode() == BO_LAnd || E->getOpcode() == BO_LOr)
611 bool ParamIdxOk =
false) {
616 const auto *MD = dyn_cast<const CXXMethodDecl>(D);
617 if (MD && !MD->isStatic()) {
620 if (!checkRecordDeclForAttr<CapabilityAttr>(RD) &&
621 !checkRecordDeclForAttr<ScopedLockableAttr>(RD))
623 diag::warn_thread_attribute_not_on_capability_member)
624 << AL << MD->getParent();
626 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_not_on_non_static_member)
631 for (
unsigned Idx = Sidx; Idx < AL.
getNumArgs(); ++Idx) {
636 Args.push_back(ArgExp);
640 if (
const auto *StrLit = dyn_cast<StringLiteral>(ArgExp)) {
641 if (StrLit->getLength() == 0 ||
642 (StrLit->isOrdinary() && StrLit->getString() == StringRef(
"*"))) {
645 Args.push_back(ArgExp);
651 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_ignored) << AL;
652 Args.push_back(ArgExp);
660 if (
const auto *UOp = dyn_cast<UnaryOperator>(ArgExp))
661 if (UOp->getOpcode() == UO_AddrOf)
662 if (
const auto *DRE = dyn_cast<DeclRefExpr>(UOp->getSubExpr()))
663 if (DRE->getDecl()->isCXXInstanceMember())
664 ArgTy = DRE->getDecl()->getType();
670 if(!RT && ParamIdxOk) {
671 const auto *FD = dyn_cast<FunctionDecl>(D);
672 const auto *IL = dyn_cast<IntegerLiteral>(ArgExp);
674 unsigned int NumParams = FD->getNumParams();
675 llvm::APInt ArgValue = IL->getValue();
676 uint64_t ParamIdxFromOne = ArgValue.getZExtValue();
677 uint64_t ParamIdxFromZero = ParamIdxFromOne - 1;
678 if (!ArgValue.isStrictlyPositive() || ParamIdxFromOne > NumParams) {
680 diag::err_attribute_argument_out_of_bounds_extra_info)
681 << AL << Idx + 1 << NumParams;
684 ArgTy = FD->getParamDecl(ParamIdxFromZero)->getType();
693 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_argument_not_lockable)
696 Args.push_back(ArgExp);
716 unsigned Size = Args.size();
750 QualType QT = cast<ValueDecl>(D)->getType();
752 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_decl_not_lockable) << AL;
769 Expr **StartArg = &Args[0];
771 AcquiredAfterAttr(S.
Context, AL, StartArg, Args.size()));
779 Expr **StartArg = &Args[0];
781 AcquiredBeforeAttr(S.
Context, AL, StartArg, Args.size()));
798 unsigned Size = Args.size();
799 Expr **StartArg = Size == 0 ? nullptr : &Args[0];
801 AssertSharedLockAttr(S.
Context, AL, StartArg, Size));
810 unsigned Size = Args.size();
811 Expr **StartArg = Size == 0 ? nullptr : &Args[0];
813 AssertExclusiveLockAttr(S.
Context, AL, StartArg, Size));
821template <
typename AttrInfo>
823 unsigned AttrArgNo) {
824 assert(AI.isArgExpr(AttrArgNo) &&
"Expected expression argument");
825 Expr *AttrArg = AI.getArgAsExpr(AttrArgNo);
834 S.
Diag(SrcLoc, diag::err_attribute_integers_only)
849 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only) << AL;
860 ParamIdx SizeArgNo(SizeArgNoVal, D);
875 AllocSizeAttr(S.
Context, AL, SizeArgNo, NumberArgNo));
884 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
919 unsigned Size = Args.size();
933 unsigned Size = Args.size();
936 Expr **StartArg = &Args[0];
939 LocksExcludedAttr(S.
Context, AL, StartArg, Size));
943 Expr *&Cond, StringRef &Msg) {
949 Cond = Converted.
get();
956 Msg =
"<no message provided>";
962 S.
Diag(AL.
getLoc(), diag::err_attr_cond_never_constant_expr) << AL;
964 S.
Diag(PDiag.first, PDiag.second);
971 S.
Diag(AL.
getLoc(), diag::ext_clang_enable_if);
980 StringRef NewUserDiagnostic;
989 const auto *PD = isa<CXXRecordDecl>(D)
990 ? cast<DeclContext>(D)
992 if (
const auto *RD = dyn_cast<CXXRecordDecl>(PD); RD && RD->isLocalClass()) {
994 diag::warn_attribute_exclude_from_explicit_instantiation_local_class)
995 << AL << !isa<CXXRecordDecl>(D);
999 ExcludeFromExplicitInstantiationAttr(S.
Context, AL));
1005class ArgumentDependenceChecker
1016 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD))
1019 ClassType =
nullptr;
1024 bool referencesArgs(
Expr *E) {
1032 "`this` doesn't refer to the enclosing class?");
1038 if (
const auto *PVD = dyn_cast<ParmVarDecl>(DRE->
getDecl()))
1039 if (Parms.count(PVD)) {
1050 const auto *DeclFD = cast<FunctionDecl>(D);
1052 if (
const auto *MethodDecl = dyn_cast<CXXMethodDecl>(DeclFD))
1053 if (!MethodDecl->isStatic()) {
1054 S.
Diag(AL.
getLoc(), diag::err_attribute_no_member_function) << AL;
1066 S.
Diag(Loc, diag::err_attribute_argument_n_type) << AL << Index <<
T;
1072 auto *F = dyn_cast_if_present<DeclRefExpr>(AL.
getArgAsExpr(0));
1075 return dyn_cast_if_present<FunctionDecl>(F->getFoundDecl());
1084 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments_for)
1091 for (
unsigned I = 1; I < AL.
getNumArgs(); ++I) {
1103 if (Index > DeclFD->getNumParams()) {
1104 S.
Diag(AL.
getLoc(), diag::err_attribute_bounds_for_function)
1105 << AL << Index << DeclFD << DeclFD->getNumParams();
1110 QualType T2 = DeclFD->getParamDecl(Index - 1)->getType();
1115 << AL << Index << DeclFD << T2 << I << AttrFD << T1;
1119 Indices.push_back(Index - 1);
1123 S.
Context, AL, AttrFD, Indices.data(), Indices.size()));
1127 S.
Diag(AL.
getLoc(), diag::ext_clang_diagnose_if);
1134 StringRef DiagTypeStr;
1138 DiagnoseIfAttr::DiagnosticType DiagType;
1139 if (!DiagnoseIfAttr::ConvertStrToDiagnosticType(DiagTypeStr, DiagType)) {
1141 diag::err_diagnose_if_invalid_diagnostic_type);
1145 bool ArgDependent =
false;
1146 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
1147 ArgDependent = ArgumentDependenceChecker(FD).referencesArgs(Cond);
1149 S.
Context, AL, Cond, Msg, DiagType, ArgDependent, cast<NamedDecl>(D)));
1153 static constexpr const StringRef kWildcard =
"*";
1156 bool HasWildcard =
false;
1158 const auto AddBuiltinName = [&Names, &HasWildcard](StringRef Name) {
1159 if (Name == kWildcard)
1161 Names.push_back(Name);
1165 if (
const auto *NBA = D->
getAttr<NoBuiltinAttr>())
1166 for (StringRef BuiltinName : NBA->builtinNames())
1167 AddBuiltinName(BuiltinName);
1171 AddBuiltinName(kWildcard);
1173 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
1174 StringRef BuiltinName;
1180 AddBuiltinName(BuiltinName);
1182 S.
Diag(LiteralLoc, diag::warn_attribute_no_builtin_invalid_builtin_name)
1183 << BuiltinName << AL;
1188 Names.erase(std::unique(Names.begin(), Names.end()), Names.end());
1191 if (HasWildcard && Names.size() > 1)
1193 diag::err_attribute_no_builtin_wildcard_or_builtin_name)
1196 if (D->
hasAttr<NoBuiltinAttr>())
1199 NoBuiltinAttr(S.
Context, AL, Names.data(), Names.size()));
1203 if (D->
hasAttr<PassObjectSizeAttr>()) {
1204 S.
Diag(D->
getBeginLoc(), diag::err_attribute_only_once_per_parameter) << AL;
1226 if (!cast<ParmVarDecl>(D)->getType()->isPointerType()) {
1227 S.
Diag(D->
getBeginLoc(), diag::err_attribute_pointers_only) << AL << 1;
1235 ConsumableAttr::ConsumedState DefaultState;
1239 if (!ConsumableAttr::ConvertStrToConsumedState(IL->
Ident->
getName(),
1241 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported) << AL
1246 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1259 if (!RD->hasAttr<ConsumableAttr>()) {
1260 S.
Diag(AL.
getLoc(), diag::warn_attr_on_unconsumable_class) << RD;
1277 for (
unsigned ArgIndex = 0; ArgIndex < AL.
getNumArgs(); ++ArgIndex) {
1278 CallableWhenAttr::ConsumedState CallableState;
1280 StringRef StateString;
1291 if (!CallableWhenAttr::ConvertStrToConsumedState(StateString,
1293 S.
Diag(Loc, diag::warn_attribute_type_not_supported) << AL << StateString;
1297 States.push_back(CallableState);
1301 CallableWhenAttr(S.
Context, AL, States.data(), States.size()));
1305 ParamTypestateAttr::ConsumedState ParamState;
1311 if (!ParamTypestateAttr::ConvertStrToConsumedState(StateString,
1313 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported)
1314 << AL << StateString;
1318 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1339 ReturnTypestateAttr::ConsumedState ReturnState;
1343 if (!ReturnTypestateAttr::ConvertStrToConsumedState(IL->
Ident->
getName(),
1345 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported) << AL
1350 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1387 SetTypestateAttr::ConsumedState NewState;
1391 if (!SetTypestateAttr::ConvertStrToConsumedState(Param, NewState)) {
1392 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported) << AL
1397 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1409 TestTypestateAttr::ConsumedState TestState;
1413 if (!TestTypestateAttr::ConvertStrToConsumedState(Param, TestState)) {
1414 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported) << AL
1419 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1433 if (
auto *TD = dyn_cast<TagDecl>(D))
1435 else if (
auto *FD = dyn_cast<FieldDecl>(D)) {
1442 if (BitfieldByteAligned)
1444 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored_for_field_of_type)
1450 if (BitfieldByteAligned)
1451 S.
Diag(AL.
getLoc(), diag::warn_attribute_packed_for_bitfield);
1457 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored) << AL;
1461 auto *RD = cast<CXXRecordDecl>(D);
1463 assert(CTD &&
"attribute does not appertain to this declaration");
1474 if (
const auto *CTSD = dyn_cast_if_present<ClassTemplateSpecializationDecl>(
1476 Template = CTSD->getSpecializedTemplate();
1478 while (TST && TST->isTypeAlias())
1481 Template = TST->getTemplateName().getAsTemplateDecl();
1490 S.
Diag(AL.
getLoc(), diag::err_attribute_preferred_name_arg_invalid)
1493 S.
Diag(TT->getDecl()->getLocation(), diag::note_entity_declared_at)
1501 if (
const auto *VD = dyn_cast<ObjCIvarDecl>(D)) {
1503 S.
Diag(AL.
getLoc(), diag::warn_iboutlet_object_type)
1504 << AL << VD->getType() << 0;
1508 else if (
const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
1510 S.
Diag(AL.
getLoc(), diag::warn_iboutlet_object_type)
1511 << AL << PD->getType() << 1;
1516 S.
Diag(AL.
getLoc(), diag::warn_attribute_iboutlet) << AL;
1534 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
1549 S.
Diag(AL.
getLoc(), diag::err_iboutletcollection_type) <<
"NSObject";
1565 QT->
isBuiltinType() ? diag::err_iboutletcollection_builtintype
1566 : diag::err_iboutletcollection_type) << QT;
1578 T =
T.getNonReferenceType();
1584 if (UT && UT->getDecl()->hasAttr<TransparentUnionAttr>()) {
1586 for (
const auto *I : UD->
fields()) {
1600 bool isReturnValue =
false) {
1603 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only)
1604 << AL << AttrParmRange << TypeRange;
1606 S.
Diag(AL.
getLoc(), diag::warn_attribute_pointers_only)
1607 << AL << AttrParmRange << TypeRange << 0;
1615 for (
unsigned I = 0; I < AL.
getNumArgs(); ++I) {
1629 NonNullArgs.push_back(Idx);
1640 I != E && !AnyPointers; ++I) {
1647 S.
Diag(AL.
getLoc(), diag::warn_attribute_nonnull_no_pointers);
1650 ParamIdx *Start = NonNullArgs.data();
1651 unsigned Size = NonNullArgs.size();
1652 llvm::array_pod_sort(Start, Start + Size);
1662 S.
Diag(AL.
getLoc(), diag::warn_attribute_nonnull_parm_no_args)
1691 QualType T = cast<ParmVarDecl>(D)->getType();
1693 S.
Diag(AL.
getLoc(), diag::warn_attribute_pointers_only)
1716 AssumeAlignedAttr TmpAttr(
Context, CI, E, OE);
1720 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
1721 << &TmpAttr << TmpAttr.getRange() << SR;
1726 std::optional<llvm::APSInt> I = llvm::APSInt(64);
1729 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1733 Diag(AttrLoc, diag::err_attribute_argument_type)
1739 if (!I->isPowerOf2()) {
1740 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
1746 Diag(CI.
getLoc(), diag::warn_assume_aligned_too_great)
1751 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1769 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
1775 const auto *FuncDecl = cast<FunctionDecl>(D);
1785 << FuncDecl->getParamDecl(Idx.
getASTIndex())->getSourceRange();
1794 StringRef AssumptionStr) {
1795 if (llvm::KnownAssumptionStrings.count(AssumptionStr))
1798 unsigned BestEditDistance = 3;
1799 StringRef Suggestion;
1800 for (
const auto &KnownAssumptionIt : llvm::KnownAssumptionStrings) {
1801 unsigned EditDistance =
1802 AssumptionStr.edit_distance(KnownAssumptionIt.getKey());
1803 if (EditDistance < BestEditDistance) {
1804 Suggestion = KnownAssumptionIt.getKey();
1805 BestEditDistance = EditDistance;
1809 if (!Suggestion.empty())
1810 S.
Diag(Loc, diag::warn_omp_assume_attribute_string_unknown_suggested)
1811 << AssumptionStr << Suggestion;
1813 S.
Diag(Loc, diag::warn_omp_assume_attribute_string_unknown)
1832 if (AttrName.size() > 4 && AttrName.starts_with(
"__") &&
1833 AttrName.ends_with(
"__")) {
1834 AttrName = AttrName.drop_front(2).drop_back(2);
1850 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
1856 OwnershipAttr::OwnershipKind K =
1857 OwnershipAttr(S.
Context, AL,
nullptr,
nullptr, 0).getOwnKind();
1861 case OwnershipAttr::Takes:
1862 case OwnershipAttr::Holds:
1864 S.
Diag(AL.
getLoc(), diag::err_attribute_too_few_arguments) << AL << 2;
1868 case OwnershipAttr::Returns:
1870 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 1;
1878 StringRef ModuleName =
Module->getName();
1884 for (
unsigned i = 1; i < AL.
getNumArgs(); ++i) {
1894 case OwnershipAttr::Takes:
1895 case OwnershipAttr::Holds:
1899 case OwnershipAttr::Returns:
1905 S.
Diag(AL.
getLoc(), diag::err_ownership_type) << AL << Err
1914 if (I->getOwnKind() != K && llvm::is_contained(I->args(), Idx)) {
1915 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
1918 I->isRegularKeywordAttribute());
1920 }
else if (K == OwnershipAttr::Returns &&
1921 I->getOwnKind() == OwnershipAttr::Returns) {
1924 if (!llvm::is_contained(I->args(), Idx)) {
1925 S.
Diag(I->getLocation(), diag::err_ownership_returns_index_mismatch)
1926 << I->args_begin()->getSourceIndex();
1928 S.
Diag(AL.
getLoc(), diag::note_ownership_returns_index_mismatch)
1934 OwnershipArgs.push_back(Idx);
1937 ParamIdx *Start = OwnershipArgs.data();
1938 unsigned Size = OwnershipArgs.size();
1939 llvm::array_pod_sort(Start, Start + Size);
1947 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
1963 S.
Diag(AL.
getLoc(), diag::err_attribute_weakref_not_global_context)
1964 << cast<NamedDecl>(D);
2008 std::unique_ptr<char, llvm::FreeDeleter> Demangled;
2010 Demangled.reset(llvm::itaniumDemangle(Str,
false));
2019 if (!isa<FunctionDecl>(ND) && !isa<VarDecl>(ND))
2021 if (MC->shouldMangleDeclName(ND)) {
2022 llvm::raw_svector_ostream Out(Name);
2026 Name = ND->getIdentifier()->getName();
2040 const auto *FD = cast<FunctionDecl>(D);
2042 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << FD << 1;
2056 S.
Diag(AL.
getLoc(), diag::err_alias_not_supported_on_darwin);
2064 S.
Diag(AL.
getLoc(), diag::err_alias_not_supported_on_nvptx);
2068 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
2070 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << FD << 0;
2074 const auto *VD = cast<VarDecl>(D);
2075 if (VD->isThisDeclarationADefinition() && VD->isExternallyVisible()) {
2076 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << VD << 0;
2093 if (Model !=
"global-dynamic" && Model !=
"local-dynamic"
2094 && Model !=
"initial-exec" && Model !=
"local-exec") {
2095 S.
Diag(LiteralLoc, diag::err_attr_tlsmodel_arg);
2109 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only)
2117 if (checkAttrMutualExclusion<CPUSpecificAttr>(S, D, AL))
2120 if (
const auto *
Other = D->
getAttr<CPUDispatchAttr>()) {
2121 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
2122 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
2125 }
else if (AL.
getParsedKind() == ParsedAttr::AT_CPUSpecific) {
2126 if (checkAttrMutualExclusion<CPUDispatchAttr>(S, D, AL))
2129 if (
const auto *
Other = D->
getAttr<CPUSpecificAttr>()) {
2130 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
2131 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
2138 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
2139 if (MD->getParent()->isLambda()) {
2140 S.
Diag(AL.
getLoc(), diag::err_attribute_dll_lambda) << AL;
2151 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
2160 S.
Diag(CPUArg->
Loc, diag::err_invalid_cpu_specific_dispatch_value)
2161 << CPUName << (AL.
getKind() == ParsedAttr::AT_CPUDispatch);
2167 return Target.CPUSpecificManglingCharacter(CPUName) ==
2170 S.
Diag(AL.
getLoc(), diag::warn_multiversion_duplicate_entries);
2173 CPUs.push_back(CPUArg->
Ident);
2177 if (AL.
getKind() == ParsedAttr::AT_CPUSpecific)
2179 CPUSpecificAttr(S.
Context, AL, CPUs.data(), CPUs.size()));
2182 CPUDispatchAttr(S.
Context, AL, CPUs.data(), CPUs.size()));
2187 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
2197 S.
Diag(AL.
getLoc(), diag::err_attribute_not_clinkage) << AL;
2201 const auto *FD = cast<FunctionDecl>(D);
2203 S.
Diag(AL.
getLoc(), diag::warn_attribute_cmse_entry_static);
2213 const auto &Arch = Triple.getArch();
2214 if (Arch != llvm::Triple::x86 &&
2215 (Arch != llvm::Triple::arm && Arch != llvm::Triple::thumb)) {
2216 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_on_arch)
2217 << AL << Triple.getArchName();
2223 if (S.
getLangOpts().MSVCCompat && isa<CXXMethodDecl>(D)) {
2224 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_decl_type_str)
2236 if (!isa<ObjCMethodDecl>(D)) {
2237 S.
Diag(Attrs.
getLoc(), diag::warn_attribute_wrong_decl_type)
2263 S.
Diag(Attrs.
getLoc(), diag::warn_nocf_check_attribute_ignored);
2265 handleSimpleAttribute<AnyX86NoCfCheckAttr>(S, D, Attrs);
2281 ? diag::err_keyword_not_supported_on_target
2282 : diag::warn_unknown_attribute_ignored)
2300 ? diag::err_attribute_wrong_decl_type
2301 : diag::warn_attribute_wrong_decl_type)
2337 if (VecReturnAttr *A = D->
getAttr<VecReturnAttr>()) {
2338 S.
Diag(AL.
getLoc(), diag::err_repeat_attribute) << A;
2342 const auto *R = cast<RecordDecl>(D);
2345 if (!isa<CXXRecordDecl>(R)) {
2346 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
2350 if (!cast<CXXRecordDecl>(R)->isPOD()) {
2351 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_pod_record);
2355 for (
const auto *I : R->fields()) {
2356 if ((count == 1) || !I->getType()->isVectorType()) {
2357 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
2368 if (isa<ParmVarDecl>(D)) {
2373 diag::err_carries_dependency_param_not_function_decl);
2387 S.
Diag(AL.
getLoc(), diag::ext_cxx17_attr) << AL;
2393 uint32_t priority = ConstructorAttr::DefaultPriority;
2395 S.
Diag(AL.
getLoc(), diag::err_hlsl_init_priority_unsupported);
2406 uint32_t priority = DestructorAttr::DefaultPriority;
2414template <
typename AttrTy>
2426 if (!cast<ObjCProtocolDecl>(D)->isThisDeclarationADefinition()) {
2427 S.
Diag(AL.
getLoc(), diag::err_objc_attr_protocol_requires_definition)
2437 VersionTuple Introduced,
2438 VersionTuple Deprecated,
2439 VersionTuple Obsoleted) {
2440 StringRef PlatformName
2441 = AvailabilityAttr::getPrettyPlatformName(Platform->
getName());
2442 if (PlatformName.empty())
2443 PlatformName = Platform->
getName();
2447 if (!Introduced.empty() && !Deprecated.empty() &&
2448 !(Introduced <= Deprecated)) {
2449 S.
Diag(Range.getBegin(), diag::warn_availability_version_ordering)
2450 << 1 << PlatformName << Deprecated.getAsString()
2451 << 0 << Introduced.getAsString();
2455 if (!Introduced.empty() && !Obsoleted.empty() &&
2456 !(Introduced <= Obsoleted)) {
2457 S.
Diag(Range.getBegin(), diag::warn_availability_version_ordering)
2458 << 2 << PlatformName << Obsoleted.getAsString()
2459 << 0 << Introduced.getAsString();
2463 if (!Deprecated.empty() && !Obsoleted.empty() &&
2464 !(Deprecated <= Obsoleted)) {
2465 S.
Diag(Range.getBegin(), diag::warn_availability_version_ordering)
2466 << 2 << PlatformName << Obsoleted.getAsString()
2467 << 1 << Deprecated.getAsString();
2479 bool BeforeIsOkay) {
2480 if (
X.empty() || Y.empty())
2486 if (BeforeIsOkay &&
X < Y)
2494 bool Implicit, VersionTuple Introduced, VersionTuple Deprecated,
2495 VersionTuple Obsoleted,
bool IsUnavailable, StringRef Message,
2498 VersionTuple MergedIntroduced = Introduced;
2499 VersionTuple MergedDeprecated = Deprecated;
2500 VersionTuple MergedObsoleted = Obsoleted;
2501 bool FoundAny =
false;
2502 bool OverrideOrImpl =
false;
2506 OverrideOrImpl =
false;
2512 OverrideOrImpl =
true;
2518 for (
unsigned i = 0, e = Attrs.size(); i != e;) {
2519 const auto *OldAA = dyn_cast<AvailabilityAttr>(Attrs[i]);
2526 if (OldPlatform != Platform) {
2534 if (OldAA->getPriority() <
Priority)
2540 if (OldAA->getPriority() >
Priority) {
2541 Attrs.erase(Attrs.begin() + i);
2547 VersionTuple OldIntroduced = OldAA->getIntroduced();
2548 VersionTuple OldDeprecated = OldAA->getDeprecated();
2549 VersionTuple OldObsoleted = OldAA->getObsoleted();
2550 bool OldIsUnavailable = OldAA->getUnavailable();
2552 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl) ||
2553 !
versionsMatch(Deprecated, OldDeprecated, OverrideOrImpl) ||
2555 !(OldIsUnavailable == IsUnavailable ||
2556 (OverrideOrImpl && !OldIsUnavailable && IsUnavailable))) {
2557 if (OverrideOrImpl) {
2559 VersionTuple FirstVersion;
2560 VersionTuple SecondVersion;
2561 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl)) {
2563 FirstVersion = OldIntroduced;
2564 SecondVersion = Introduced;
2565 }
else if (!
versionsMatch(Deprecated, OldDeprecated, OverrideOrImpl)) {
2567 FirstVersion = Deprecated;
2568 SecondVersion = OldDeprecated;
2569 }
else if (!
versionsMatch(Obsoleted, OldObsoleted, OverrideOrImpl)) {
2571 FirstVersion = Obsoleted;
2572 SecondVersion = OldObsoleted;
2576 Diag(OldAA->getLocation(),
2577 diag::warn_mismatched_availability_override_unavail)
2578 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2589 Diag(OldAA->getLocation(),
2590 diag::warn_mismatched_availability_override)
2592 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2593 << FirstVersion.getAsString() << SecondVersion.getAsString()
2597 Diag(CI.
getLoc(), diag::note_overridden_method);
2599 Diag(CI.
getLoc(), diag::note_protocol_method);
2601 Diag(OldAA->getLocation(), diag::warn_mismatched_availability);
2602 Diag(CI.
getLoc(), diag::note_previous_attribute);
2605 Attrs.erase(Attrs.begin() + i);
2610 VersionTuple MergedIntroduced2 = MergedIntroduced;
2611 VersionTuple MergedDeprecated2 = MergedDeprecated;
2612 VersionTuple MergedObsoleted2 = MergedObsoleted;
2614 if (MergedIntroduced2.empty())
2615 MergedIntroduced2 = OldIntroduced;
2616 if (MergedDeprecated2.empty())
2617 MergedDeprecated2 = OldDeprecated;
2618 if (MergedObsoleted2.empty())
2619 MergedObsoleted2 = OldObsoleted;
2622 MergedIntroduced2, MergedDeprecated2,
2623 MergedObsoleted2)) {
2624 Attrs.erase(Attrs.begin() + i);
2629 MergedIntroduced = MergedIntroduced2;
2630 MergedDeprecated = MergedDeprecated2;
2631 MergedObsoleted = MergedObsoleted2;
2637 MergedIntroduced == Introduced &&
2638 MergedDeprecated == Deprecated &&
2639 MergedObsoleted == Obsoleted)
2645 MergedDeprecated, MergedObsoleted) &&
2647 auto *Avail = ::new (
Context) AvailabilityAttr(
2648 Context, CI, Platform, Introduced, Deprecated, Obsoleted, IsUnavailable,
2649 Message, IsStrict, Replacement,
Priority);
2657 if (isa<UsingDecl, UnresolvedUsingTypenameDecl, UnresolvedUsingValueDecl>(
2669 if (AvailabilityAttr::getPrettyPlatformName(II->
getName()).empty())
2670 S.
Diag(Platform->
Loc, diag::warn_availability_unknown_platform)
2673 auto *ND = dyn_cast<NamedDecl>(D);
2683 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getMessageExpr()))
2684 Str = SE->getString();
2685 StringRef Replacement;
2686 if (
const auto *SE =
2688 Replacement = SE->getString();
2690 if (II->
isStr(
"swift")) {
2692 (!IsUnavailable && !Deprecated.
isValid())) {
2694 diag::warn_availability_swift_unavailable_deprecated_only);
2699 if (II->
isStr(
"fuchsia")) {
2700 std::optional<unsigned>
Min, Sub;
2702 (Sub = Introduced.
Version.getSubminor())) {
2703 S.
Diag(AL.
getLoc(), diag::warn_availability_fuchsia_unavailable_minor);
2713 Obsoleted.
Version, IsUnavailable, Str, IsStrict, Replacement,
2724 else if (II->
getName() ==
"ios_app_extension")
2729 const auto *IOSToWatchOSMapping =
2734 auto adjustWatchOSVersion =
2735 [IOSToWatchOSMapping](VersionTuple Version) -> VersionTuple {
2736 if (Version.empty())
2738 auto MinimumWatchOSVersion = VersionTuple(2, 0);
2740 if (IOSToWatchOSMapping) {
2741 if (
auto MappedVersion = IOSToWatchOSMapping->map(
2742 Version, MinimumWatchOSVersion, std::nullopt)) {
2743 return *MappedVersion;
2747 auto Major = Version.getMajor();
2748 auto NewMajor = Major >= 9 ? Major - 7 : 0;
2749 if (NewMajor >= 2) {
2750 if (Version.getMinor()) {
2751 if (Version.getSubminor())
2752 return VersionTuple(NewMajor, *Version.getMinor(),
2753 *Version.getSubminor());
2755 return VersionTuple(NewMajor, *Version.getMinor());
2757 return VersionTuple(NewMajor);
2760 return MinimumWatchOSVersion;
2763 auto NewIntroduced = adjustWatchOSVersion(Introduced.
Version);
2764 auto NewDeprecated = adjustWatchOSVersion(Deprecated.
Version);
2765 auto NewObsoleted = adjustWatchOSVersion(Obsoleted.
Version);
2768 ND, AL, NewII,
true , NewIntroduced, NewDeprecated,
2769 NewObsoleted, IsUnavailable, Str, IsStrict, Replacement,
2781 else if (II->
getName() ==
"ios_app_extension")
2786 const auto *IOSToTvOSMapping =
2791 auto AdjustTvOSVersion =
2792 [IOSToTvOSMapping](VersionTuple Version) -> VersionTuple {
2793 if (Version.empty())
2796 if (IOSToTvOSMapping) {
2797 if (
auto MappedVersion = IOSToTvOSMapping->map(
2798 Version, VersionTuple(0, 0), std::nullopt)) {
2799 return *MappedVersion;
2805 auto NewIntroduced = AdjustTvOSVersion(Introduced.
Version);
2806 auto NewDeprecated = AdjustTvOSVersion(Deprecated.
Version);
2807 auto NewObsoleted = AdjustTvOSVersion(Obsoleted.
Version);
2810 ND, AL, NewII,
true , NewIntroduced, NewDeprecated,
2811 NewObsoleted, IsUnavailable, Str, IsStrict, Replacement,
2818 llvm::Triple::IOS &&
2820 auto GetSDKInfo = [&]() {
2829 else if (II->
getName() ==
"ios_app_extension")
2832 auto MinMacCatalystVersion = [](
const VersionTuple &
V) {
2835 if (
V.getMajor() < 13 ||
2836 (
V.getMajor() == 13 &&
V.getMinor() && *
V.getMinor() < 1))
2837 return VersionTuple(13, 1);
2841 ND, AL, NewII,
true ,
2842 MinMacCatalystVersion(Introduced.
Version),
2843 MinMacCatalystVersion(Deprecated.
Version),
2844 MinMacCatalystVersion(Obsoleted.
Version), IsUnavailable, Str,
2849 }
else if (II->
getName() ==
"macos" && GetSDKInfo() &&
2851 !Obsoleted.
Version.empty())) {
2852 if (
const auto *MacOStoMacCatalystMapping =
2853 GetSDKInfo()->getVersionMapping(
2860 auto RemapMacOSVersion =
2861 [&](
const VersionTuple &
V) -> std::optional<VersionTuple> {
2863 return std::nullopt;
2865 if (
V.getMajor() == 100000)
2866 return VersionTuple(100000);
2868 return MacOStoMacCatalystMapping->map(
V, VersionTuple(13, 1),
2871 std::optional<VersionTuple> NewIntroduced =
2872 RemapMacOSVersion(Introduced.
Version),
2874 RemapMacOSVersion(Deprecated.
Version),
2876 RemapMacOSVersion(Obsoleted.
Version);
2877 if (NewIntroduced || NewDeprecated || NewObsoleted) {
2878 auto VersionOrEmptyVersion =
2879 [](
const std::optional<VersionTuple> &
V) -> VersionTuple {
2880 return V ? *
V : VersionTuple();
2883 ND, AL, NewII,
true ,
2884 VersionOrEmptyVersion(NewIntroduced),
2885 VersionOrEmptyVersion(NewDeprecated),
2886 VersionOrEmptyVersion(NewObsoleted),
false, Str,
2904 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(0)))
2906 StringRef DefinedIn;
2907 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(1)))
2908 DefinedIn = SE->getString();
2909 bool IsGeneratedDeclaration = AL.
getArgAsIdent(2) !=
nullptr;
2911 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(3)))
2912 USR = SE->getString();
2920 typename T::VisibilityType value) {
2923 typename T::VisibilityType existingValue = existingAttr->
getVisibility();
2924 if (existingValue == value)
2926 S.
Diag(existingAttr->getLocation(), diag::err_mismatched_visibility);
2927 S.
Diag(CI.
getLoc(), diag::note_previous_attribute);
2935 VisibilityAttr::VisibilityType Vis) {
2936 return ::mergeVisibilityAttr<VisibilityAttr>(*
this, D, CI, Vis);
2941 TypeVisibilityAttr::VisibilityType Vis) {
2942 return ::mergeVisibilityAttr<TypeVisibilityAttr>(*
this, D, CI, Vis);
2946 bool isTypeVisibility) {
2948 if (isa<TypedefNameDecl>(D)) {
2954 if (isTypeVisibility && !(isa<TagDecl>(D) || isa<ObjCInterfaceDecl>(D) ||
2955 isa<NamespaceDecl>(D))) {
2967 VisibilityAttr::VisibilityType
type;
2968 if (!VisibilityAttr::ConvertStrToVisibilityType(TypeStr,
type)) {
2969 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported) << AL
2976 if (
type == VisibilityAttr::Protected &&
2978 S.
Diag(AL.
getLoc(), diag::warn_attribute_protected_visibility);
2979 type = VisibilityAttr::Default;
2983 if (isTypeVisibility) {
2985 D, AL, (TypeVisibilityAttr::VisibilityType)
type);
2996 S.
Diag(AL.
getLoc(), diag::err_objc_direct_on_protocol) <<
false;
3001 handleSimpleAttribute<ObjCDirectAttr>(S, D, AL);
3003 S.
Diag(AL.
getLoc(), diag::warn_objc_direct_ignored) << AL;
3010 handleSimpleAttribute<ObjCDirectMembersAttr>(S, D, AL);
3012 S.
Diag(AL.
getLoc(), diag::warn_objc_direct_ignored) << AL;
3017 const auto *M = cast<ObjCMethodDecl>(D);
3019 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3025 ObjCMethodFamilyAttr::FamilyKind F;
3026 if (!ObjCMethodFamilyAttr::ConvertStrToFamilyKind(IL->
Ident->
getName(), F)) {
3027 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported) << AL << IL->
Ident;
3031 if (F == ObjCMethodFamilyAttr::OMF_init &&
3032 !M->getReturnType()->isObjCObjectPointerType()) {
3033 S.
Diag(M->getLocation(), diag::err_init_method_bad_return_type)
3034 << M->getReturnType();
3043 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
3046 S.
Diag(TD->getLocation(), diag::err_nsobject_attribute);
3050 else if (
const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
3053 S.
Diag(PD->getLocation(), diag::err_nsobject_attribute);
3070 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
3073 S.
Diag(TD->getLocation(), diag::warn_ptr_independentclass_attribute);
3085 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3091 BlocksAttr::BlockType
type;
3092 if (!BlocksAttr::ConvertStrToBlockType(II->
getName(),
type)) {
3093 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
3101 unsigned sentinel = (
unsigned)SentinelAttr::DefaultSentinel;
3104 std::optional<llvm::APSInt> Idx = llvm::APSInt(32);
3106 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3111 if (Idx->isSigned() && Idx->isNegative()) {
3112 S.
Diag(AL.
getLoc(), diag::err_attribute_sentinel_less_than_zero)
3117 sentinel = Idx->getZExtValue();
3120 unsigned nullPos = (
unsigned)SentinelAttr::DefaultNullPos;
3123 std::optional<llvm::APSInt> Idx = llvm::APSInt(32);
3125 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3129 nullPos = Idx->getZExtValue();
3131 if ((Idx->isSigned() && Idx->isNegative()) || nullPos > 1) {
3134 S.
Diag(AL.
getLoc(), diag::err_attribute_sentinel_not_zero_or_one)
3140 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
3142 if (isa<FunctionNoProtoType>(FT)) {
3143 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_named_arguments);
3147 if (!cast<FunctionProtoType>(FT)->isVariadic()) {
3148 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
3151 }
else if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
3152 if (!MD->isVariadic()) {
3153 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
3156 }
else if (
const auto *BD = dyn_cast<BlockDecl>(D)) {
3157 if (!BD->isVariadic()) {
3158 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 1;
3161 }
else if (
const auto *
V = dyn_cast<VarDecl>(D)) {
3169 if (!cast<FunctionProtoType>(FT)->isVariadic()) {
3171 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << m;
3175 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
3181 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
3192 !isa<CXXConstructorDecl>(D)) {
3193 S.
Diag(AL.
getLoc(), diag::warn_attribute_void_function_method) << AL << 0;
3196 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
3197 if (MD->getReturnType()->isVoidType()) {
3198 S.
Diag(AL.
getLoc(), diag::warn_attribute_void_function_method) << AL << 1;
3206 if (isa<VarDecl>(D))
3207 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type_str)
3209 <<
"functions, classes, or enumerations";
3218 if (LO.CPlusPlus && !LO.CPlusPlus20)
3219 S.
Diag(AL.
getLoc(), diag::ext_cxx20_attr) << AL;
3227 }
else if (LO.CPlusPlus && !LO.CPlusPlus17)
3228 S.
Diag(AL.
getLoc(), diag::ext_cxx17_attr) << AL;
3233 isa<TypedefNameDecl>(D)) {
3234 S.
Diag(AL.
getLoc(), diag::warn_unused_result_typedef_unsupported_spelling)
3247 S.
Diag(AL.
getLoc(), diag::warn_attribute_invalid_on_definition)
3249 else if (isa<ObjCPropertyDecl>(D) || isa<ObjCMethodDecl>(D) ||
3251 (isa<ObjCInterfaceDecl>(D) || isa<EnumDecl>(D)))) {
3254 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
3264template <
typename WorkGroupAttr>
3267 for (
unsigned i = 0; i < 3; ++i) {
3272 if (WGSize[i] == 0) {
3273 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_is_zero)
3279 WorkGroupAttr *Existing = D->
getAttr<WorkGroupAttr>();
3280 if (Existing && !(Existing->getXDim() == WGSize[0] &&
3281 Existing->getYDim() == WGSize[1] &&
3282 Existing->getZDim() == WGSize[2]))
3283 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3286 WorkGroupAttr(S.
Context, AL, WGSize[0], WGSize[1], WGSize[2]));
3296 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_is_zero)
3301 OpenCLIntelReqdSubGroupSizeAttr *Existing =
3302 D->
getAttr<OpenCLIntelReqdSubGroupSizeAttr>();
3303 if (Existing && Existing->getSubGroupSize() != SGSize)
3304 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3307 OpenCLIntelReqdSubGroupSizeAttr(S.
Context, AL, SGSize));
3312 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
3318 assert(ParmTSI &&
"no type source info for attribute argument");
3323 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_argument) << 2 << AL;
3327 if (VecTypeHintAttr *A = D->
getAttr<VecTypeHintAttr>()) {
3329 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3341 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
3346 if (SectionAttr *ExistingAttr = D->
getAttr<SectionAttr>()) {
3347 if (ExistingAttr->getName() == Name)
3349 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section)
3351 Diag(CI.
getLoc(), diag::note_previous_attribute);
3368 return llvm::Error::success();
3371 StringRef Segment, Section;
3372 unsigned TAA, StubSize;
3374 return llvm::MCSectionMachO::ParseSectionSpecifier(SecName, Segment, Section,
3375 TAA, HasTAA, StubSize);
3380 Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
3405 cast<NamedDecl>(D));
3416 llvm::CodeModel::Model CM;
3417 if (!CodeModelAttr::ConvertStrToModel(Str, CM)) {
3418 S.
Diag(LiteralLoc, diag::err_attr_codemodel_arg) << Str;
3428 StringRef CodeSegName) {
3430 S.
Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
3442 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
3446 if (
const auto *ExistingAttr = D->
getAttr<CodeSegAttr>()) {
3447 if (ExistingAttr->getName() == Name)
3449 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section)
3451 Diag(CI.
getLoc(), diag::note_previous_attribute);
3464 if (
const auto *ExistingAttr = D->
getAttr<CodeSegAttr>()) {
3465 if (!ExistingAttr->isImplicit()) {
3467 ExistingAttr->getName() == Str
3468 ? diag::warn_duplicate_codeseg_attribute
3469 : diag::err_conflicting_codeseg_attribute);
3481 enum FirstParam { Unsupported, Duplicate,
Unknown };
3482 enum SecondParam {
None, CPU, Tune };
3484 if (AttrStr.contains(
"fpmath="))
3485 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3486 << Unsupported <<
None <<
"fpmath=" <<
Target;
3490 AttrStr.contains(
"tune="))
3491 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3497 if (!ParsedAttrs.
CPU.empty() &&
3499 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3502 if (!ParsedAttrs.
Tune.empty() &&
3504 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3509 return Diag(LiteralLoc, diag::err_duplicate_target_attribute)
3513 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3516 for (
const auto &Feature : ParsedAttrs.
Features) {
3517 auto CurFeature = StringRef(Feature).drop_front();
3519 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3520 << Unsupported <<
None << CurFeature <<
Target;
3529 if (DiagMsg.empty())
3530 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3531 << Unsupported <<
None <<
"branch-protection" <<
Target;
3532 return Diag(LiteralLoc, diag::err_invalid_branch_protection_spec)
3535 if (!DiagMsg.empty())
3536 Diag(LiteralLoc, diag::warn_unsupported_branch_protection_spec) << DiagMsg;
3550 StringRef &AttrStr,
bool &isDefault) {
3551 enum FirstParam { Unsupported };
3552 enum SecondParam {
None };
3554 if (AttrStr.trim() ==
"default")
3557 AttrStr.split(Features,
"+");
3558 for (
auto &CurFeature : Features) {
3559 CurFeature = CurFeature.trim();
3560 if (CurFeature ==
"default")
3563 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3567 return Diag(LiteralLoc, diag::err_sme_streaming_cannot_be_multiversioned);
3574 bool isDefault =
false;
3580 TargetVersionAttr *NewAttr =
3593 TargetAttr *NewAttr = ::new (S.
Context) TargetAttr(S.
Context, AL, Str);
3599 Decl *D,
bool &HasDefault,
bool &HasCommas,
bool &HasNotDefault,
3601 enum FirstParam { Unsupported, Duplicate,
Unknown };
3602 enum SecondParam {
None, CPU, Tune };
3604 HasCommas = HasCommas || Str.contains(
',');
3607 if (Str.size() == 0)
3608 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3611 std::pair<StringRef, StringRef> Parts = {{}, Str};
3612 while (!Parts.second.empty()) {
3613 Parts = Parts.second.split(
',');
3614 StringRef Cur = Parts.first.trim();
3616 Literal->getLocationOfByte(Cur.data() - Literal->getString().data(),
3619 bool DefaultIsDupe =
false;
3620 bool HasCodeGenImpact =
false;
3622 return Diag(CurLoc, diag::warn_unsupported_target_attribute)
3627 if (Cur ==
"default") {
3628 DefaultIsDupe = HasDefault;
3630 if (llvm::is_contained(StringsBuffer, Cur) || DefaultIsDupe)
3631 Diag(CurLoc, diag::warn_target_clone_duplicate_options);
3633 StringsBuffer.push_back(Cur);
3635 std::pair<StringRef, StringRef> CurParts = {{}, Cur};
3637 while (!CurParts.second.empty()) {
3638 CurParts = CurParts.second.split(
'+');
3639 StringRef CurFeature = CurParts.first.trim();
3641 Diag(CurLoc, diag::warn_unsupported_target_attribute)
3646 HasCodeGenImpact =
true;
3647 CurFeatures.push_back(CurFeature);
3650 llvm::sort(CurFeatures);
3652 for (
auto &CurFeat : CurFeatures) {
3653 if (!Res.equals(
""))
3655 Res.append(CurFeat);
3657 if (llvm::is_contained(StringsBuffer, Res) || DefaultIsDupe)
3658 Diag(CurLoc, diag::warn_target_clone_duplicate_options);
3659 else if (!HasCodeGenImpact)
3662 Diag(CurLoc, diag::warn_target_clone_no_impact_options);
3663 else if (!Res.empty()) {
3664 StringsBuffer.push_back(Res);
3665 HasNotDefault =
true;
3669 return Diag(LiteralLoc,
3670 diag::err_sme_streaming_cannot_be_multiversioned);
3673 if (Cur.starts_with(
"arch=")) {
3675 Cur.drop_front(
sizeof(
"arch=") - 1)))
3676 return Diag(CurLoc, diag::warn_unsupported_target_attribute)
3677 << Unsupported << CPU << Cur.drop_front(
sizeof(
"arch=") - 1)
3679 }
else if (Cur ==
"default") {
3680 DefaultIsDupe = HasDefault;
3683 return Diag(CurLoc, diag::warn_unsupported_target_attribute)
3685 if (llvm::is_contained(StringsBuffer, Cur) || DefaultIsDupe)
3686 Diag(CurLoc, diag::warn_target_clone_duplicate_options);
3688 StringsBuffer.push_back(Cur);
3691 if (Str.rtrim().ends_with(
","))
3692 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3704 if (
const auto *
Other = D->
getAttr<TargetClonesAttr>()) {
3705 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
3706 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
3709 if (checkAttrMutualExclusion<TargetClonesAttr>(S, D, AL))
3714 bool HasCommas =
false, HasDefault =
false, HasNotDefault =
false;
3716 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
3723 HasDefault, HasCommas, HasNotDefault, StringsBuffer))
3726 for (
auto &SmallStr : StringsBuffer)
3727 Strings.push_back(SmallStr.str());
3730 S.
Diag(AL.
getLoc(), diag::warn_target_clone_mixed_values);
3735 Strings.push_back(
"default");
3739 S.
Diag(AL.
getLoc(), diag::err_target_clone_must_have_default);
3745 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
3746 if (MD->getParent()->isLambda()) {
3758 cast<FunctionDecl>(D)->setIsMultiVersion();
3759 TargetClonesAttr *NewAttr = ::new (S.
Context)
3760 TargetClonesAttr(S.
Context, AL, Strings.data(), Strings.size());
3772 MinVectorWidthAttr *Existing = D->
getAttr<MinVectorWidthAttr>();
3773 if (Existing && Existing->getVectorWidth() != VecWidth) {
3774 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3789 if (
auto *DRE = dyn_cast<DeclRefExpr>(E)) {
3791 S.
Diag(Loc, diag::warn_cleanup_ext);
3792 FD = dyn_cast<FunctionDecl>(DRE->
getDecl());
3795 S.
Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 1
3799 }
else if (
auto *ULE = dyn_cast<UnresolvedLookupExpr>(E)) {
3800 if (ULE->hasExplicitTemplateArgs())
3801 S.
Diag(Loc, diag::warn_cleanup_ext);
3803 NI = ULE->getNameInfo();
3805 S.
Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 2
3812 S.
Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 0;
3817 S.
Diag(Loc, diag::err_attribute_cleanup_func_must_take_one_arg)
3828 S.
Diag(Loc, diag::err_attribute_cleanup_func_arg_incompatible_type)
3829 << NI.
getName() << ParamTy << Ty;
3832 VarDecl *VD = cast<VarDecl>(D);
3843 S.
Context, VariableReference, UnaryOperatorKind::UO_AddrOf,
3863 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3868 EnumExtensibilityAttr::Kind ExtensibilityKind;
3870 if (!EnumExtensibilityAttr::ConvertStrToKind(II->
getName(),
3871 ExtensibilityKind)) {
3872 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
3877 EnumExtensibilityAttr(S.
Context, AL, ExtensibilityKind));
3892 if (NotNSStringTy &&
3896 S.
Diag(AL.
getLoc(), diag::err_format_attribute_not)
3904 if (
auto *OMD = dyn_cast<ObjCMethodDecl>(D))
3905 if (
auto *
Interface = OMD->getClassInterface())
3912 S.
Diag(AL.
getLoc(), diag::err_format_attribute_result_not)
3913 << (NotNSStringTy ?
"string type" :
"NSString")
3933 return llvm::StringSwitch<FormatAttrKind>(Format)
3947 .Cases(
"gcc_diag",
"gcc_cdiag",
"gcc_cxxdiag",
"gcc_tdiag",
IgnoredFormat)
3955 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored) << AL;
3960 S.
Diag(AL.
getLoc(), diag::err_hlsl_init_priority_unsupported);
3965 S.
Diag(AL.
getLoc(), diag::err_init_priority_object_attr);
3969 QualType T = cast<VarDecl>(D)->getType();
3973 S.
Diag(AL.
getLoc(), diag::err_init_priority_object_attr);
3979 uint32_t prioritynum;
3988 if ((prioritynum < 101 || prioritynum > 65535) &&
3990 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_range)
3999 StringRef NewUserDiagnostic) {
4000 if (
const auto *EA = D->
getAttr<ErrorAttr>()) {
4002 assert((NewAttr ==
"error" || NewAttr ==
"warning") &&
4003 "unexpected normalized full name");
4004 bool Match = (EA->isError() && NewAttr ==
"error") ||
4005 (EA->isWarning() && NewAttr ==
"warning");
4007 Diag(EA->getLocation(), diag::err_attributes_are_not_compatible)
4010 EA->isRegularKeywordAttribute());
4011 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
4014 if (EA->getUserDiagnostic() != NewUserDiagnostic) {
4015 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << EA;
4016 Diag(EA->getLoc(), diag::note_previous_attribute);
4020 return ::new (
Context) ErrorAttr(
Context, CI, NewUserDiagnostic);
4028 if (F->getType() == Format &&
4029 F->getFormatIdx() == FormatIdx &&
4030 F->getFirstArg() == FirstArg) {
4033 if (F->getLocation().isInvalid())
4039 return ::new (
Context) FormatAttr(
Context, CI, Format, FormatIdx, FirstArg);
4046 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
4057 StringRef Format = II->
getName();
4071 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
4082 if (Idx < 1 || Idx > NumArgs) {
4083 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4089 unsigned ArgIdx = Idx - 1;
4091 if (HasImplicitThisParam) {
4094 diag::err_format_attribute_implicit_this_format_string)
4108 S.
Diag(AL.
getLoc(), diag::err_format_attribute_not)
4120 if (FirstArg != 0) {
4124 S.
Diag(AL.
getLoc(), diag::err_format_strftime_third_parameter)
4132 if (FirstArg != NumArgs + 1) {
4133 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4136 std::to_string(NumArgs + 1));
4141 S.
Diag(D->
getLocation(), diag::warn_gcc_requires_variadic_function) << AL;
4142 if (FirstArg <= Idx) {
4146 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4162 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_no_callee)
4171 assert(FD &&
"Expected a function declaration!");
4173 llvm::StringMap<int> NameIdxMapping;
4174 NameIdxMapping[
"__"] = -1;
4176 NameIdxMapping[
"this"] = 0;
4180 NameIdxMapping[PVD->getName()] = Idx++;
4182 auto UnknownName = NameIdxMapping.end();
4185 for (
unsigned I = 0, E = AL.
getNumArgs(); I < E; ++I) {
4191 auto It = NameIdxMapping.find(IdLoc->
Ident->
getName());
4192 if (It == UnknownName) {
4193 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_argument_unknown)
4199 ArgIdx = It->second;
4206 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4212 if (ArgIdx < -1 || ArgIdx > NumArgs) {
4213 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4220 llvm_unreachable(
"Unexpected ParsedAttr argument type!");
4223 if (ArgIdx == 0 && !HasImplicitThisParam) {
4224 S.
Diag(AL.
getLoc(), diag::err_callback_implicit_this_not_available)
4231 if (!HasImplicitThisParam && ArgIdx > 0)
4234 EncodingIndices.push_back(ArgIdx);
4237 int CalleeIdx = EncodingIndices.front();
4241 if (CalleeIdx < (
int)HasImplicitThisParam) {
4242 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_invalid_callee)
4249 const Type *CalleeType =
4253 S.
Diag(AL.
getLoc(), diag::err_callback_callee_no_function_type)
4258 const Type *CalleeFnType =
4263 const auto *CalleeFnProtoType = dyn_cast<FunctionProtoType>(CalleeFnType);
4264 if (!CalleeFnProtoType) {
4265 S.
Diag(AL.
getLoc(), diag::err_callback_callee_no_function_type)
4270 if (CalleeFnProtoType->getNumParams() > EncodingIndices.size() - 1) {
4271 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments)
4272 << AL << (
unsigned)(EncodingIndices.size() - 1);
4276 if (CalleeFnProtoType->getNumParams() < EncodingIndices.size() - 1) {
4277 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments)
4278 << AL << (
unsigned)(EncodingIndices.size() - 1);
4282 if (CalleeFnProtoType->isVariadic()) {
4288 if (D->
hasAttr<CallbackAttr>()) {
4294 S.
Context, AL, EncodingIndices.data(), EncodingIndices.size()));
4307 QualType T = cast<ParmVarDecl>(D)->getType();
4310 S.
Diag(AL.
getLoc(), diag::err_called_once_attribute_wrong_type);
4320 const auto *TD = dyn_cast<TypedefNameDecl>(D);
4321 if (TD && TD->getUnderlyingType()->isUnionType())
4322 RD = TD->getUnderlyingType()->getAsUnionType()->getDecl();
4324 RD = dyn_cast<RecordDecl>(D);
4327 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
4335 diag::warn_transparent_union_attribute_not_definition);
4341 if (Field == FieldEnd) {
4342 S.
Diag(AL.
getLoc(), diag::warn_transparent_union_attribute_zero_fields);
4350 diag::warn_transparent_union_attribute_floating)
4359 for (; Field != FieldEnd; ++Field) {
4360 QualType FieldType = Field->getType();
4374 S.
Diag(Field->getLocation(),
4375 diag::warn_transparent_union_attribute_field_size_align)
4376 << isSize << *Field << FieldBits;
4377 unsigned FirstBits = isSize ? FirstSize : FirstAlign;
4379 diag::note_transparent_union_first_field_size_align)
4380 << isSize << FirstBits;
4390 auto *
Attr = AnnotateAttr::Create(
Context, Str, Args.data(), Args.size(), CI);
4406 for (
unsigned Idx = 1; Idx < AL.
getNumArgs(); Idx++) {
4419 AlignValueAttr TmpAttr(
Context, CI, E);
4423 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D))
4424 T = TD->getUnderlyingType();
4425 else if (
const auto *VD = dyn_cast<ValueDecl>(D))
4428 llvm_unreachable(
"Unknown decl type for align_value");
4432 Diag(AttrLoc, diag::warn_attribute_pointer_or_reference_only)
4438 llvm::APSInt Alignment;
4440 E, &Alignment, diag::err_align_value_attribute_argument_not_int);
4444 if (!Alignment.isPowerOf2()) {
4445 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
4467 diag::err_pack_expansion_without_parameter_packs);
4482 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
4494 diag::err_pack_expansion_without_parameter_packs);
4521 const AlignedAttr &
Attr,
4524 if (isa<ParmVarDecl>(D)) {
4526 }
else if (
const auto *VD = dyn_cast<VarDecl>(D)) {
4529 if (VD->isExceptionVariable())
4531 }
else if (
const auto *FD = dyn_cast<FieldDecl>(D)) {
4532 if (FD->isBitField())
4534 }
else if (
const auto *ED = dyn_cast<EnumDecl>(D)) {
4535 if (ED->getLangOpts().CPlusPlus)
4537 }
else if (!isa<TagDecl>(D)) {
4538 return S.
Diag(AttrLoc, diag::err_attribute_wrong_decl_type)
4543 if (DiagKind != -1) {
4544 return S.
Diag(AttrLoc, diag::err_alignas_attribute_wrong_decl_type)
4545 << &
Attr << DiagKind;
4551 bool IsPackExpansion) {
4552 AlignedAttr TmpAttr(
Context, CI,
true, E);
4556 if (TmpAttr.isAlignas() &&
4564 if (
const auto *TND = dyn_cast<TypedefNameDecl>(D)) {
4565 if (!TND->getUnderlyingType()->isDependentType()) {
4566 Diag(AttrLoc, diag::err_alignment_dependent_typedef_name)
4573 AlignedAttr *AA = ::new (
Context) AlignedAttr(
Context, CI,
true, E);
4574 AA->setPackExpansion(IsPackExpansion);
4580 llvm::APSInt Alignment;
4582 E, &Alignment, diag::err_aligned_attribute_argument_not_int);
4590 Diag(AttrLoc, diag::err_attribute_aligned_too_great)
4595 uint64_t AlignVal = Alignment.getZExtValue();
4601 if (!(TmpAttr.isAlignas() && !Alignment)) {
4602 if (!llvm::isPowerOf2_64(AlignVal)) {
4603 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
4609 const auto *VD = dyn_cast<VarDecl>(D);
4611 unsigned MaxTLSAlign =
4614 if (MaxTLSAlign && AlignVal > MaxTLSAlign &&
4616 Diag(VD->getLocation(), diag::err_tls_var_aligned_over_maximum)
4617 << (
unsigned)AlignVal << VD << MaxTLSAlign;
4625 const Type *Ty = VD->getType().getTypePtr();
4627 Diag(VD->getLocation(), diag::warn_aligned_attr_underaligned)
4628 << VD->getType() << 16;
4634 AA->setPackExpansion(IsPackExpansion);
4635 AA->setCachedAlignmentValue(
4642 AlignedAttr TmpAttr(
Context, CI,
false, TS);
4646 if (TmpAttr.isAlignas() &&
4654 if (
const auto *TND = dyn_cast<TypedefNameDecl>(D)) {
4655 if (!TND->getUnderlyingType()->isDependentType()) {
4656 Diag(AttrLoc, diag::err_alignment_dependent_typedef_name)
4662 AlignedAttr *AA = ::new (
Context) AlignedAttr(
Context, CI,
false, TS);
4663 AA->setPackExpansion(IsPackExpansion);
4668 const auto *VD = dyn_cast<VarDecl>(D);
4669 unsigned AlignVal = TmpAttr.getAlignment(
Context);
4673 const Type *Ty = VD->getType().getTypePtr();
4676 Diag(VD->getLocation(), diag::warn_aligned_attr_underaligned)
4677 << VD->getType() << 16;
4682 AlignedAttr *AA = ::new (
Context) AlignedAttr(
Context, CI,
false, TS);
4683 AA->setPackExpansion(IsPackExpansion);
4684 AA->setCachedAlignmentValue(AlignVal);
4689 assert(D->
hasAttrs() &&
"no attributes on decl");
4692 if (
const auto *VD = dyn_cast<ValueDecl>(D)) {
4693 UnderlyingTy = DiagTy = VD->getType();
4696 if (
const auto *ED = dyn_cast<EnumDecl>(D))
4697 UnderlyingTy = ED->getIntegerType();
4706 AlignedAttr *AlignasAttr =
nullptr;
4707 AlignedAttr *LastAlignedAttr =
nullptr;
4710 if (I->isAlignmentDependent())
4714 Align = std::max(Align, I->getAlignment(
Context));
4715 LastAlignedAttr = I;
4719 Diag(LastAlignedAttr->getLocation(), diag::err_attribute_sizeless_type)
4720 << LastAlignedAttr << DiagTy;
4721 }
else if (AlignasAttr && Align) {
4724 if (NaturalAlign > RequestedAlign)
4725 Diag(AlignasAttr->getLocation(), diag::err_alignas_underaligned)
4752 Diag(Range.getBegin(), diag::err_mismatched_ms_inheritance)
4761 bool &IntegerMode,
bool &ComplexMode,
4764 ComplexMode =
false;
4766 switch (Str.size()) {
4786 DestWidth = Str[1] ==
'I' ? 0 : 128;
4794 DestWidth = Str[1] ==
'I' ? 0 : 128;
4797 if (Str[1] ==
'F') {
4798 IntegerMode =
false;
4799 }
else if (Str[1] ==
'C') {
4800 IntegerMode =
false;
4802 }
else if (Str[1] !=
'I') {
4811 else if (Str ==
"byte")
4815 if (Str ==
"pointer")
4819 if (Str ==
"unwind_word")
4835 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
4847 StringRef Str = Name->getName();
4851 unsigned DestWidth = 0;
4852 bool IntegerMode =
true;
4853 bool ComplexMode =
false;
4855 llvm::APInt VectorSize(64, 0);
4856 if (Str.size() >= 4 && Str[0] ==
'V') {
4858 size_t StrSize = Str.size();
4859 size_t VectorStringLength = 0;
4860 while ((VectorStringLength + 1) < StrSize &&
4861 isdigit(Str[VectorStringLength + 1]))
4862 ++VectorStringLength;
4863 if (VectorStringLength &&
4864 !Str.substr(1, VectorStringLength).getAsInteger(10, VectorSize) &&
4865 VectorSize.isPowerOf2()) {
4867 IntegerMode, ComplexMode, ExplicitType);
4869 if (!InInstantiation)
4870 Diag(AttrLoc, diag::warn_vector_mode_deprecated);
4885 Diag(AttrLoc, diag::err_machine_mode) << 0 << Name;
4890 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D))
4891 OldTy = TD->getUnderlyingType();
4892 else if (
const auto *ED = dyn_cast<EnumDecl>(D)) {
4895 OldTy = ED->getIntegerType();
4899 OldTy = cast<ValueDecl>(D)->getType();
4910 OldElemTy = VT->getElementType();
4916 VectorSize.getBoolValue()) {
4917 Diag(AttrLoc, diag::err_enum_mode_vector_type) << Name << CI.
getRange();
4925 !IntegralOrAnyEnumType)
4926 Diag(AttrLoc, diag::err_mode_not_primitive);
4927 else if (IntegerMode) {
4928 if (!IntegralOrAnyEnumType)
4929 Diag(AttrLoc, diag::err_mode_wrong_type);
4930 }
else if (ComplexMode) {
4932 Diag(AttrLoc, diag::err_mode_wrong_type);
4935 Diag(AttrLoc, diag::err_mode_wrong_type);
4946 if (NewElemTy.
isNull()) {
4948 if (!(DestWidth == 128 &&
getLangOpts().CUDAIsDevice))
4949 Diag(AttrLoc, diag::err_machine_mode) << 1 << Name;
4958 if (VectorSize.getBoolValue()) {
4964 Diag(AttrLoc, diag::err_complex_mode_vector_type);
4968 OldVT->getNumElements() /
4975 Diag(AttrLoc, diag::err_mode_wrong_type);
4980 if (
auto *TD = dyn_cast<TypedefNameDecl>(D))
4981 TD->setModedTypeSourceInfo(TD->getTypeSourceInfo(), NewTy);
4982 else if (
auto *ED = dyn_cast<EnumDecl>(D))
4983 ED->setIntegerType(NewTy);
4985 cast<ValueDecl>(D)->setType(NewTy);
4997 if (OptimizeNoneAttr *Optnone = D->
getAttr<OptimizeNoneAttr>()) {
4998 Diag(CI.
getLoc(), diag::warn_attribute_ignored) << Ident;
4999 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
5003 if (D->
hasAttr<AlwaysInlineAttr>())
5011 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
5014 if (VD->getKind() != Decl::Var) {
5015 Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
5022 if (VD->hasLocalStorage()) {
5023 Diag(VD->getLocation(), diag::warn_internal_linkage_local_storage);
5030InternalLinkageAttr *
5032 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
5035 if (VD->getKind() != Decl::Var) {
5036 Diag(AL.getLocation(), diag::warn_attribute_wrong_decl_type)
5037 << &AL << AL.isRegularKeywordAttribute()
5043 if (VD->hasLocalStorage()) {
5044 Diag(VD->getLocation(), diag::warn_internal_linkage_local_storage);
5053 if (OptimizeNoneAttr *Optnone = D->
getAttr<OptimizeNoneAttr>()) {
5054 Diag(CI.
getLoc(), diag::warn_attribute_ignored) <<
"'minsize'";
5055 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
5059 if (D->
hasAttr<MinSizeAttr>())
5067 if (
const auto *PrevSNA = D->
getAttr<SwiftNameAttr>()) {
5068 if (PrevSNA->getName() != Name && !PrevSNA->isImplicit()) {
5069 Diag(PrevSNA->getLocation(), diag::err_attributes_are_not_compatible)
5071 << (PrevSNA->isRegularKeywordAttribute() ||
5072 SNA.isRegularKeywordAttribute());
5073 Diag(SNA.getLoc(), diag::note_conflicting_attribute);
5083 if (AlwaysInlineAttr *Inline = D->
getAttr<AlwaysInlineAttr>()) {
5084 Diag(Inline->getLocation(), diag::warn_attribute_ignored) << Inline;
5085 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
5088 if (MinSizeAttr *MinSize = D->
getAttr<MinSizeAttr>()) {
5089 Diag(MinSize->getLocation(), diag::warn_attribute_ignored) << MinSize;
5090 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
5094 if (D->
hasAttr<OptimizeNoneAttr>())
5101 if (AlwaysInlineAttr *Inline =
5117 const auto *VD = cast<VarDecl>(D);
5118 if (VD->hasLocalStorage()) {
5119 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
5124 if (
auto *A = D->
getAttr<CUDAConstantAttr>()) {
5125 if (!A->isImplicit())
5133 const auto *VD = cast<VarDecl>(D);
5136 if (!S.
getLangOpts().GPURelocatableDeviceCode && VD->hasExternalStorage() &&
5137 !isa<IncompleteArrayType>(VD->getType())) {
5138 S.
Diag(AL.
getLoc(), diag::err_cuda_extern_shared) << VD;
5141 if (S.
getLangOpts().CUDA && VD->hasLocalStorage() &&
5149 const auto *FD = cast<FunctionDecl>(D);
5160 if (
const auto *Method = dyn_cast<CXXMethodDecl>(FD)) {
5161 if (Method->isInstance()) {
5162 S.
Diag(Method->getBeginLoc(), diag::err_kern_is_nonstatic_method)
5166 S.
Diag(Method->getBeginLoc(), diag::warn_kern_is_method) << Method;
5172 if (AL.
getKind() == ParsedAttr::AT_NVPTXKernel)
5185 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
5186 if (VD->hasLocalStorage()) {
5187 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
5192 if (
auto *A = D->
getAttr<CUDADeviceAttr>()) {
5193 if (!A->isImplicit())
5201 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
5202 if (VD->hasLocalStorage()) {
5203 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
5207 if (!D->
hasAttr<HIPManagedAttr>())
5209 if (!D->
hasAttr<CUDADeviceAttr>())
5214 const auto *Fn = cast<FunctionDecl>(D);
5215 if (!Fn->isInlineSpecified()) {
5216 S.
Diag(AL.
getLoc(), diag::warn_gnu_inline_attribute_requires_inline);
5221 S.
Diag(AL.
getLoc(), diag::warn_gnu_inline_cplusplus_without_extern);
5237 if (!isa<ObjCMethodDecl>(D)) {
5238 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
5244 case ParsedAttr::AT_FastCall:
5247 case ParsedAttr::AT_StdCall:
5250 case ParsedAttr::AT_ThisCall:
5253 case ParsedAttr::AT_CDecl:
5256 case ParsedAttr::AT_Pascal:
5259 case ParsedAttr::AT_SwiftCall:
5262 case ParsedAttr::AT_SwiftAsyncCall:
5265 case ParsedAttr::AT_VectorCall:
5268 case ParsedAttr::AT_MSABI:
5271 case ParsedAttr::AT_SysVABI:
5274 case ParsedAttr::AT_RegCall:
5277 case ParsedAttr::AT_Pcs: {
5278 PcsAttr::PCSType PCS;
5281 PCS = PcsAttr::AAPCS;
5284 PCS = PcsAttr::AAPCS_VFP;
5287 llvm_unreachable(
"unexpected calling convention in pcs attribute");
5293 case ParsedAttr::AT_AArch64VectorPcs:
5296 case ParsedAttr::AT_AArch64SVEPcs:
5299 case ParsedAttr::AT_AMDGPUKernelCall:
5302 case ParsedAttr::AT_IntelOclBicc:
5305 case ParsedAttr::AT_PreserveMost:
5308 case ParsedAttr::AT_PreserveAll:
5311 case ParsedAttr::AT_M68kRTD:
5314 case ParsedAttr::AT_PreserveNone:
5317 case ParsedAttr::AT_RISCVVectorCC:
5321 llvm_unreachable(
"unexpected attribute kind");
5332 std::vector<StringRef> DiagnosticIdentifiers;
5333 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
5339 DiagnosticIdentifiers.push_back(RuleName);
5342 SuppressAttr(S.
Context, AL, DiagnosticIdentifiers.data(),
5343 DiagnosticIdentifiers.size()));
5352 unsigned SelectIdx = ~0
U;
5358 if (SelectIdx != ~0
U) {
5359 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_argument)
5371 if (AL.
getKind() == ParsedAttr::AT_Owner) {
5372 if (checkAttrMutualExclusion<PointerAttr>(S, D, AL))
5374 if (
const auto *OAttr = D->
getAttr<OwnerAttr>()) {
5375 const Type *ExistingDerefType = OAttr->getDerefTypeLoc()
5376 ? OAttr->getDerefType().getTypePtr()
5379 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
5382 OAttr->isRegularKeywordAttribute());
5383 S.
Diag(OAttr->getLocation(), diag::note_conflicting_attribute);
5388 Redecl->addAttr(::new (S.
Context) OwnerAttr(S.
Context, AL, DerefTypeLoc));
5391 if (checkAttrMutualExclusion<OwnerAttr>(S, D, AL))
5393 if (
const auto *PAttr = D->
getAttr<PointerAttr>()) {
5394 const Type *ExistingDerefType = PAttr->getDerefTypeLoc()
5395 ? PAttr->getDerefType().getTypePtr()
5398 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
5401 PAttr->isRegularKeywordAttribute());
5402 S.
Diag(PAttr->getLocation(), diag::note_conflicting_attribute);
5407 Redecl->addAttr(::new (S.
Context)
5408 PointerAttr(S.
Context, AL, DerefTypeLoc));
5414 if (checkAttrMutualExclusion<NoRandomizeLayoutAttr>(S, D, AL))
5416 if (!D->
hasAttr<RandomizeLayoutAttr>())
5422 if (checkAttrMutualExclusion<RandomizeLayoutAttr>(S, D, AL))
5424 if (!D->
hasAttr<NoRandomizeLayoutAttr>())
5439 unsigned ReqArgs = Attrs.
getKind() == ParsedAttr::AT_Pcs ? 1 : 0;
5447 case ParsedAttr::AT_CDecl:
5450 case ParsedAttr::AT_FastCall:
5453 case ParsedAttr::AT_StdCall:
5456 case ParsedAttr::AT_ThisCall:
5459 case ParsedAttr::AT_Pascal:
5462 case ParsedAttr::AT_SwiftCall:
5465 case ParsedAttr::AT_SwiftAsyncCall:
5468 case ParsedAttr::AT_VectorCall:
5471 case ParsedAttr::AT_AArch64VectorPcs:
5474 case ParsedAttr::AT_AArch64SVEPcs:
5477 case ParsedAttr::AT_AMDGPUKernelCall:
5480 case ParsedAttr::AT_RegCall:
5483 case ParsedAttr::AT_MSABI:
5487 case ParsedAttr::AT_SysVABI:
5491 case ParsedAttr::AT_Pcs: {
5497 if (StrRef ==
"aapcs") {
5500 }
else if (StrRef ==
"aapcs-vfp") {
5509 case ParsedAttr::AT_IntelOclBicc:
5512 case ParsedAttr::AT_PreserveMost:
5515 case ParsedAttr::AT_PreserveAll:
5518 case ParsedAttr::AT_M68kRTD:
5521 case ParsedAttr::AT_PreserveNone:
5524 case ParsedAttr::AT_RISCVVectorCC:
5527 default: llvm_unreachable(
"unexpected attribute kind");
5540 bool CheckHost =
false, CheckDevice =
false;
5541 switch (CudaTarget) {
5554 llvm_unreachable(
"unexpected cuda target");
5556 auto *HostTI =
LangOpts.CUDAIsDevice ? Aux : &TI;
5557 auto *DeviceTI =
LangOpts.CUDAIsDevice ? &TI : Aux;
5558 if (CheckHost && HostTI)
5561 A = DeviceTI->checkCallingConvention(CC);
5579 Diag(Attrs.
getLoc(), diag::error_cconv_unsupported)
5584 Diag(Attrs.
getLoc(), diag::warn_cconv_unsupported)
5589 bool IsCXXMethod =
false, IsVariadic =
false;
5642 if (existingAttr->getABI() != abi) {
5643 Diag(CI.
getLoc(), diag::err_attributes_are_not_compatible)
5646 existingAttr->isRegularKeywordAttribute());
5647 Diag(existingAttr->getLocation(), diag::note_conflicting_attribute);
5654 llvm_unreachable(
"explicit attribute for ordinary parameter ABI?");
5658 Diag(CI.
getLoc(), diag::err_swift_abi_parameter_wrong_type)
5666 Diag(CI.
getLoc(), diag::err_swift_abi_parameter_wrong_type)
5674 Diag(CI.
getLoc(), diag::err_swift_abi_parameter_wrong_type)
5682 Diag(CI.
getLoc(), diag::err_swift_abi_parameter_wrong_type)
5688 llvm_unreachable(
"bad parameter ABI attribute");
5710 Diag(AL.
getLoc(), diag::err_attribute_regparm_wrong_platform)
5718 Diag(AL.
getLoc(), diag::err_attribute_regparm_invalid_number)
5730 llvm_unreachable(
"getCudaArch is only valid for NVPTX triple");
5740 const CUDALaunchBoundsAttr &AL,
5741 const unsigned Idx) {
5750 std::optional<llvm::APSInt> I = llvm::APSInt(64);
5757 if (!I->isIntN(32)) {
5759 <<
toString(*I, 10,
false) << 32 << 1;
5763 S.
Diag(E->
getExprLoc(), diag::warn_attribute_argument_n_negative)
5771 "Unexpected PerformCopyInitialization() failure.");
5776CUDALaunchBoundsAttr *
5778 Expr *MinBlocks,
Expr *MaxBlocks) {
5779 CUDALaunchBoundsAttr TmpAttr(
Context, CI, MaxThreads, MinBlocks, MaxBlocks);
5797 MaxBlocks =
nullptr;
5806 CUDALaunchBoundsAttr(
Context, CI, MaxThreads, MinBlocks, MaxBlocks);
5828 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
5846 unsigned ArgumentIdxAST = ArgumentIdx.
getASTIndex();
5849 S.
Diag(AL.
getLoc(), diag::err_attribute_pointers_only) << AL << 0;
5860 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
5868 if (!isa<VarDecl>(D)) {
5869 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_decl_type)
5877 assert(MatchingCTypeLoc &&
"no type source info for attribute argument");
5899 uint32_t Count = 0, Offset = 0;
5906 if (Count < Offset) {
5907 S.
Diag(
getAttrLoc(AL), diag::err_attribute_argument_out_of_range)
5913 PatchableFunctionEntryAttr(S.
Context, AL, Count, Offset));
5917struct IntrinToName {
5926 const char *IntrinNames) {
5927 AliasName.consume_front(
"__arm_");
5928 const IntrinToName *It =
5929 llvm::lower_bound(Map, BuiltinID, [](
const IntrinToName &L,
unsigned Id) {
5932 if (It == Map.end() || It->Id != BuiltinID)
5934 StringRef FullName(&IntrinNames[It->FullName]);
5935 if (AliasName == FullName)
5937 if (It->ShortName == -1)
5939 StringRef ShortName(&IntrinNames[It->ShortName]);
5940 return AliasName == ShortName;
5944#include "clang/Basic/arm_mve_builtin_aliases.inc"
5952#include "clang/Basic/arm_cde_builtin_aliases.inc"
5957 StringRef AliasName) {
5965 StringRef AliasName) {
5974 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
5981 StringRef AliasName = cast<FunctionDecl>(D)->getIdentifier()->getName();
5988 S.
Diag(AL.
getLoc(), diag::err_attribute_arm_builtin_alias);
6003 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
6010 StringRef AliasName = cast<FunctionDecl>(D)->getIdentifier()->getName();
6020 (!IsAArch64 && !IsARM && !IsRISCV && !IsHLSL)) {
6021 S.
Diag(AL.
getLoc(), diag::err_attribute_builtin_alias) << AL;
6032 if (
auto *CRD = dyn_cast<CXXRecordDecl>(D);
6033 !CRD || !(CRD->isClass() || CRD->isStruct())) {
6039 handleSimpleAttribute<TypeNullableAttr>(S, D, AL);
6044 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
6050 assert(ParmTSI &&
"no type source info for attribute argument");
6052 diag::err_incomplete_type);
6083 bool IsTemplateInstantiation) {
6087 handleSimpleAttributeOrDiagnose<OSConsumedAttr>(
6089 diag::warn_ns_attribute_wrong_parameter_type,
6093 handleSimpleAttributeOrDiagnose<NSConsumedAttr>(
6100 ((IsTemplateInstantiation &&
getLangOpts().ObjCAutoRefCount)
6101 ? diag::err_ns_attribute_wrong_parameter_type
6102 : diag::warn_ns_attribute_wrong_parameter_type),
6106 handleSimpleAttributeOrDiagnose<CFConsumedAttr>(
6108 diag::warn_ns_attribute_wrong_parameter_type,
6117 case ParsedAttr::AT_CFConsumed:
6118 case ParsedAttr::AT_CFReturnsRetained:
6119 case ParsedAttr::AT_CFReturnsNotRetained:
6121 case ParsedAttr::AT_OSConsumesThis:
6122 case ParsedAttr::AT_OSConsumed:
6123 case ParsedAttr::AT_OSReturnsRetained:
6124 case ParsedAttr::AT_OSReturnsNotRetained:
6125 case ParsedAttr::AT_OSReturnsRetainedOnZero:
6126 case ParsedAttr::AT_OSReturnsRetainedOnNonZero:
6128 case ParsedAttr::AT_NSConsumesSelf:
6129 case ParsedAttr::AT_NSConsumed:
6130 case ParsedAttr::AT_NSReturnsRetained:
6131 case ParsedAttr::AT_NSReturnsNotRetained:
6132 case ParsedAttr::AT_NSReturnsAutoreleased:
6135 llvm_unreachable(
"Wrong argument supplied");
6143 Diag(Loc, diag::warn_ns_attribute_wrong_return_type)
6144 <<
"'ns_returns_retained'" << 0 << 0;
6150 const auto *PVD = dyn_cast<ParmVarDecl>(D);
6163 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
6164 ReturnType = MD->getReturnType();
6166 (AL.
getKind() == ParsedAttr::AT_NSReturnsRetained)) {
6168 }
else if (
const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
6169 ReturnType = PD->getType();
6170 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
6172 }
else if (
const auto *Param = dyn_cast<ParmVarDecl>(D)) {
6179 if (ReturnType.
isNull()) {
6180 S.
Diag(D->
getBeginLoc(), diag::warn_ns_attribute_wrong_parameter_type)
6189 default: llvm_unreachable(
"invalid ownership attribute");
6190 case ParsedAttr::AT_NSReturnsRetained:
6191 case ParsedAttr::AT_NSReturnsAutoreleased:
6192 case ParsedAttr::AT_NSReturnsNotRetained:
6196 case ParsedAttr::AT_OSReturnsRetained:
6197 case ParsedAttr::AT_OSReturnsNotRetained:
6198 case ParsedAttr::AT_CFReturnsRetained:
6199 case ParsedAttr::AT_CFReturnsNotRetained:
6205 << ExpectedDeclKind;
6211 unsigned ParmDiagID = 2;
6213 default: llvm_unreachable(
"invalid ownership attribute");
6214 case ParsedAttr::AT_NSReturnsRetained:
6219 case ParsedAttr::AT_NSReturnsAutoreleased:
6220 case ParsedAttr::AT_NSReturnsNotRetained:
6225 case ParsedAttr::AT_CFReturnsRetained:
6226 case ParsedAttr::AT_CFReturnsNotRetained:
6231 case ParsedAttr::AT_OSReturnsRetained:
6232 case ParsedAttr::AT_OSReturnsNotRetained:
6243 if (isa<ParmVarDecl>(D)) {
6244 S.
Diag(D->
getBeginLoc(), diag::warn_ns_attribute_wrong_parameter_type)
6245 << AL << ParmDiagID << AL.
getRange();
6253 if (isa<ObjCMethodDecl>(D))
6254 SubjectKind = Method;
6255 else if (isa<ObjCPropertyDecl>(D))
6258 << AL << SubjectKind << Cf << AL.
getRange();
6265 llvm_unreachable(
"invalid ownership attribute");
6266 case ParsedAttr::AT_NSReturnsAutoreleased:
6267 handleSimpleAttribute<NSReturnsAutoreleasedAttr>(S, D, AL);
6269 case ParsedAttr::AT_CFReturnsNotRetained:
6270 handleSimpleAttribute<CFReturnsNotRetainedAttr>(S, D, AL);
6272 case ParsedAttr::AT_NSReturnsNotRetained:
6273 handleSimpleAttribute<NSReturnsNotRetainedAttr>(S, D, AL);
6275 case ParsedAttr::AT_CFReturnsRetained:
6276 handleSimpleAttribute<CFReturnsRetainedAttr>(S, D, AL);
6278 case ParsedAttr::AT_NSReturnsRetained:
6279 handleSimpleAttribute<NSReturnsRetainedAttr>(S, D, AL);
6281 case ParsedAttr::AT_OSReturnsRetained:
6282 handleSimpleAttribute<OSReturnsRetainedAttr>(S, D, AL);
6284 case ParsedAttr::AT_OSReturnsNotRetained:
6285 handleSimpleAttribute<OSReturnsNotRetainedAttr>(S, D, AL);
6292 const int EP_ObjCMethod = 1;
6293 const int EP_ObjCProperty = 2;
6297 if (isa<ObjCMethodDecl>(D))
6298 resultType = cast<ObjCMethodDecl>(D)->getReturnType();
6300 resultType = cast<ObjCPropertyDecl>(D)->getType();
6306 << (isa<ObjCMethodDecl>(D) ? EP_ObjCMethod : EP_ObjCProperty)
6318 const auto *Method = cast<ObjCMethodDecl>(D);
6321 if (
const auto *PDecl = dyn_cast_if_present<ObjCProtocolDecl>(DC)) {
6322 S.
Diag(D->
getBeginLoc(), diag::warn_objc_requires_super_protocol) << Attrs
6324 S.
Diag(PDecl->getLocation(), diag::note_protocol_decl);
6328 S.
Diag(D->
getBeginLoc(), diag::warn_objc_requires_super_protocol) << Attrs
6337 if (!isa<TagDecl>(D)) {
6343 Attr.isArgIdent(0) ?
Attr.getArgAsIdent(0) :
nullptr;
6344 if (!IdentLoc || !IdentLoc->
Ident) {
6347 if (
Attr.isArgExpr(0) &&
Attr.getArgAsExpr(0))
6348 Loc =
Attr.getArgAsExpr(0)->getBeginLoc();
6350 S.
Diag(Loc, diag::err_nserrordomain_invalid_decl) << 0;
6358 S.
Diag(IdentLoc->
Loc, diag::err_nserrordomain_invalid_decl)
6359 << 1 << IdentLoc->
Ident;
6376 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
6378 S.
Diag(AL.
getLoc(), diag::err_objc_attr_typedef_not_id) << AL;
6385 S.
Diag(AL.
getLoc(), diag::err_objc_attr_typedef_not_void_pointer);
6410 if (!RelatedClass) {
6419 S.
Context, AL, RelatedClass, ClassMethod, InstanceMethod));
6428 if (!isa<ObjCInterfaceDecl>(Ctx) &&
6429 !(isa<ObjCCategoryDecl>(Ctx) &&
6430 cast<ObjCCategoryDecl>(Ctx)->IsClassExtension())) {
6436 if (
auto *CatDecl = dyn_cast<ObjCCategoryDecl>(Ctx))
6437 IFace = CatDecl->getClassInterface();
6439 IFace = cast<ObjCInterfaceDecl>(Ctx);
6449 StringRef MetaDataName;
6453 ObjCRuntimeNameAttr(S.
Context, AL, MetaDataName));
6461 bool notify =
false;
6463 auto *RD = dyn_cast<RecordDecl>(D);
6464 if (RD && RD->getDefinition()) {
6465 RD = RD->getDefinition();
6470 ObjCBoxableAttr *BoxableAttr =
6472 RD->addAttr(BoxableAttr);
6477 L->AddedAttributeToRecord(BoxableAttr, RD);
6493 const auto *VD = cast<ValueDecl>(D);
6498 S.
Diag(AL.
getLoc(), diag::err_objc_precise_lifetime_bad_type)
6513 "didn't infer lifetime for non-dependent type?");
6522 S.
Diag(AL.
getLoc(), diag::warn_objc_precise_lifetime_meaningless)
6549 if (
const auto *
Other = D->
getAttr<SwiftBridgeAttr>()) {
6550 if (
Other->getSwiftType() != BT)
6551 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
6567 if (
const auto *ID = OPT->getInterfaceDecl())
6573 if (
const auto *RT = PT->getPointeeType()->getAs<
RecordType>())
6587 S.
Diag(AL.
getLoc(), diag::err_attr_swift_error_no_error_parameter)
6588 << AL << isa<ObjCMethodDecl>(D);
6600 S.
Diag(AL.
getLoc(), diag::err_attr_swift_error_return_type)
6611 S.
Diag(AL.
getLoc(), diag::err_attr_swift_error_return_type)
6621 SwiftErrorAttr::ConventionKind Convention;
6622 if (!SwiftErrorAttr::ConvertStrToConventionKind(Loc->
Ident->
getName(),
6624 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
6625 << AL << Loc->
Ident;
6629 switch (Convention) {
6630 case SwiftErrorAttr::None:
6634 case SwiftErrorAttr::NonNullError:
6635 if (!hasErrorParameter(S, D, AL))
6639 case SwiftErrorAttr::NullResult:
6640 if (!hasErrorParameter(S, D, AL) || !hasPointerResult(S, D, AL))
6644 case SwiftErrorAttr::NonZeroResult:
6645 case SwiftErrorAttr::ZeroResult:
6646 if (!hasErrorParameter(S, D, AL) || !hasIntegerResult(S, D, AL))
6655 const SwiftAsyncErrorAttr *ErrorAttr,
6656 const SwiftAsyncAttr *AsyncAttr) {
6657 if (AsyncAttr->getKind() == SwiftAsyncAttr::None) {
6658 if (ErrorAttr->getConvention() != SwiftAsyncErrorAttr::None) {
6659 S.
Diag(AsyncAttr->getLocation(),
6660 diag::err_swift_async_error_without_swift_async)
6661 << AsyncAttr << isa<ObjCMethodDecl>(D);
6667 D, AsyncAttr->getCompletionHandlerIndex().getASTIndex());
6670 const auto *FuncTy = HandlerParam->
getType()
6676 BlockParams = FuncTy->getParamTypes();
6678 switch (ErrorAttr->getConvention()) {
6679 case SwiftAsyncErrorAttr::ZeroArgument:
6680 case SwiftAsyncErrorAttr::NonZeroArgument: {
6681 uint32_t
ParamIdx = ErrorAttr->getHandlerParamIdx();
6683 S.
Diag(ErrorAttr->getLocation(),
6684 diag::err_attribute_argument_out_of_bounds) << ErrorAttr << 2;
6690 ErrorAttr->getConvention() == SwiftAsyncErrorAttr::ZeroArgument
6692 :
"nonzero_argument";
6693 S.
Diag(ErrorAttr->getLocation(), diag::err_swift_async_error_non_integral)
6694 << ErrorAttr << ConvStr <<
ParamIdx << ErrorParam;
6699 case SwiftAsyncErrorAttr::NonNullError: {
6700 bool AnyErrorParams =
false;
6701 for (
QualType Param : BlockParams) {
6704 if (
const auto *ID = ObjCPtrTy->getInterfaceDecl()) {
6706 AnyErrorParams =
true;
6712 if (
const auto *PtrTy = Param->getAs<
PointerType>()) {
6713 if (
const auto *RT = PtrTy->getPointeeType()->getAs<
RecordType>()) {
6715 AnyErrorParams =
true;
6722 if (!AnyErrorParams) {
6723 S.
Diag(ErrorAttr->getLocation(),
6724 diag::err_swift_async_error_no_error_parameter)
6725 << ErrorAttr << isa<ObjCMethodDecl>(D);
6730 case SwiftAsyncErrorAttr::None:
6737 SwiftAsyncErrorAttr::ConventionKind ConvKind;
6738 if (!SwiftAsyncErrorAttr::ConvertStrToConventionKind(IDLoc->
Ident->
getName(),
6740 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
6741 << AL << IDLoc->
Ident;
6747 case SwiftAsyncErrorAttr::ZeroArgument:
6748 case SwiftAsyncErrorAttr::NonZeroArgument: {
6757 case SwiftAsyncErrorAttr::NonNullError:
6758 case SwiftAsyncErrorAttr::None: {
6769 if (
auto *AsyncAttr = D->
getAttr<SwiftAsyncAttr>())
6783 StringRef Name,
unsigned &SwiftParamCount,
6784 bool &IsSingleParamInit) {
6785 SwiftParamCount = 0;
6786 IsSingleParamInit =
false;
6789 bool IsGetter =
false, IsSetter =
false;
6790 if (Name.consume_front(
"getter:"))
6792 else if (Name.consume_front(
"setter:"))
6795 if (Name.back() !=
')') {
6796 S.
Diag(Loc, diag::warn_attr_swift_name_function) << AL;
6800 bool IsMember =
false;
6801 StringRef ContextName, BaseName, Parameters;
6803 std::tie(BaseName, Parameters) = Name.split(
'(');
6807 std::tie(ContextName, BaseName) = BaseName.split(
'.');
6808 if (BaseName.empty()) {
6809 BaseName = ContextName;
6810 ContextName = StringRef();
6812 S.
Diag(Loc, diag::warn_attr_swift_name_invalid_identifier)
6820 S.
Diag(Loc, diag::warn_attr_swift_name_invalid_identifier)
6825 bool IsSubscript = BaseName ==
"subscript";
6827 if (IsSubscript && !IsGetter && !IsSetter) {
6828 S.
Diag(Loc, diag::warn_attr_swift_name_subscript_invalid_parameter)
6833 if (Parameters.empty()) {
6834 S.
Diag(Loc, diag::warn_attr_swift_name_missing_parameters) << AL;
6838 assert(Parameters.back() ==
')' &&
"expected ')'");
6839 Parameters = Parameters.drop_back();
6841 if (Parameters.empty()) {
6844 S.
Diag(Loc, diag::warn_attr_swift_name_subscript_invalid_parameter)
6850 S.
Diag(Loc, diag::warn_attr_swift_name_setter_parameters) << AL;
6857 if (Parameters.back() !=
':') {
6858 S.
Diag(Loc, diag::warn_attr_swift_name_function) << AL;
6862 StringRef CurrentParam;
6863 std::optional<unsigned> SelfLocation;
6864 unsigned NewValueCount = 0;
6865 std::optional<unsigned> NewValueLocation;
6867 std::tie(CurrentParam, Parameters) = Parameters.split(
':');
6870 S.
Diag(Loc, diag::warn_attr_swift_name_invalid_identifier)
6875 if (IsMember && CurrentParam ==
"self") {
6880 S.
Diag(Loc, diag::warn_attr_swift_name_multiple_selfs) << AL;
6885 SelfLocation = SwiftParamCount;
6886 }
else if (CurrentParam ==
"newValue") {
6893 NewValueLocation = SwiftParamCount;
6897 }
while (!Parameters.empty());
6900 if (IsSubscript && !SelfLocation) {
6901 S.
Diag(Loc, diag::warn_attr_swift_name_subscript_invalid_parameter)
6907 SwiftParamCount == 1 && BaseName ==
"init" && CurrentParam !=
"_";
6910 if (IsGetter || IsSetter) {
6912 unsigned NumExpectedParams = IsGetter ? 0 : 1;
6913 unsigned ParamDiag =
6914 IsGetter ? diag::warn_attr_swift_name_getter_parameters
6915 : diag::warn_attr_swift_name_setter_parameters;
6919 ++NumExpectedParams;
6924 if (SwiftParamCount < NumExpectedParams) {
6925 S.
Diag(Loc, ParamDiag) << AL;
6932 if (!NewValueLocation) {
6933 S.
Diag(Loc, diag::warn_attr_swift_name_subscript_setter_no_newValue)
6937 if (NewValueCount > 1) {
6938 S.
Diag(Loc, diag::warn_attr_swift_name_subscript_setter_multiple_newValues)
6944 if (NewValueLocation) {
6945 S.
Diag(Loc, diag::warn_attr_swift_name_subscript_getter_newValue)
6952 if (SwiftParamCount != NumExpectedParams) {
6953 S.
Diag(Loc, ParamDiag) << AL;
6964 if (isa<ObjCMethodDecl>(D) || isa<FunctionDecl>(D)) {
6966 unsigned ParamCount;
6968 if (
const auto *Method = dyn_cast<ObjCMethodDecl>(D)) {
6969 ParamCount = Method->getSelector().getNumArgs();
6970 Params = Method->parameters().slice(0, ParamCount);
6972 const auto *F = cast<FunctionDecl>(D);
6974 ParamCount = F->getNumParams();
6975 Params = F->parameters();
6977 if (!F->hasWrittenPrototype()) {
6978 Diag(Loc, diag::warn_attribute_wrong_decl_type)
6987 if (ParamCount == 0) {
6988 Diag(Loc, diag::warn_attr_swift_name_decl_missing_params)
6989 << AL << isa<ObjCMethodDecl>(D);
6995 unsigned SwiftParamCount;
6996 bool IsSingleParamInit;
6998 SwiftParamCount, IsSingleParamInit))
7001 bool ParamCountValid;
7002 if (SwiftParamCount == ParamCount) {
7003 ParamCountValid =
true;
7004 }
else if (SwiftParamCount > ParamCount) {
7005 ParamCountValid = IsSingleParamInit && ParamCount == 0;
7010 unsigned MaybeOutParamCount =
7011 llvm::count_if(Params, [](
const ParmVarDecl *Param) ->
bool {
7018 ParamCountValid = SwiftParamCount + MaybeOutParamCount >= ParamCount;
7021 if (!ParamCountValid) {
7022 Diag(Loc, diag::warn_attr_swift_name_num_params)
7023 << (SwiftParamCount > ParamCount) << AL << ParamCount
7027 }
else if ((isa<EnumConstantDecl>(D) || isa<ObjCProtocolDecl>(D) ||
7028 isa<ObjCInterfaceDecl>(D) || isa<ObjCPropertyDecl>(D) ||
7029 isa<VarDecl>(D) || isa<TypedefNameDecl>(D) || isa<TagDecl>(D) ||
7030 isa<IndirectFieldDecl>(D) || isa<FieldDecl>(D)) &&
7032 StringRef ContextName, BaseName;
7034 std::tie(ContextName, BaseName) = Name.split(
'.');
7035 if (BaseName.empty()) {
7036 BaseName = ContextName;
7037 ContextName = StringRef();
7039 Diag(Loc, diag::warn_attr_swift_name_invalid_identifier) << AL
7045 Diag(Loc, diag::warn_attr_swift_name_invalid_identifier) << AL
7050 Diag(Loc, diag::warn_attr_swift_name_decl_kind) << AL;
7086 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7091 SwiftNewTypeAttr::NewtypeKind Kind;
7093 if (!SwiftNewTypeAttr::ConvertStrToNewtypeKind(II->
getName(), Kind)) {
7094 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
7098 if (!isa<TypedefNameDecl>(D)) {
7099 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type_str)
7109 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
7114 SwiftAsyncAttr::Kind Kind;
7116 if (!SwiftAsyncAttr::ConvertStrToKind(II->
getName(), Kind)) {
7117 S.
Diag(AL.
getLoc(), diag::err_swift_async_no_access) << AL << II;
7122 if (Kind == SwiftAsyncAttr::None) {
7140 diag::err_swift_async_bad_block_type)
7141 << CompletionBlock->
getType();
7148 diag::err_swift_async_bad_block_type)
7149 << CompletionBlock->
getType();
7158 if (
auto *ErrorAttr = D->
getAttr<SwiftAsyncErrorAttr>())
7167 StringRef UuidAsWritten,
MSGuidDecl *GuidDecl) {
7168 if (
const auto *UA = D->
getAttr<UuidAttr>()) {
7171 if (!UA->getGuid().empty()) {
7172 Diag(UA->getLocation(), diag::err_mismatched_uuid);
7178 return ::new (
Context) UuidAttr(
Context, CI, UuidAsWritten, GuidDecl);
7183 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
7188 StringRef OrigStrRef;
7195 StringRef StrRef = OrigStrRef;
7196 if (StrRef.size() == 38 && StrRef.front() ==
'{' && StrRef.back() ==
'}')
7197 StrRef = StrRef.drop_front().drop_back();
7200 if (StrRef.size() != 36) {
7201 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
7205 for (
unsigned i = 0; i < 36; ++i) {
7206 if (i == 8 || i == 13 || i == 18 || i == 23) {
7207 if (StrRef[i] !=
'-') {
7208 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
7212 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
7219 StrRef.substr(0, 8).getAsInteger(16, Parsed.
Part1);
7220 StrRef.substr(9, 4).getAsInteger(16, Parsed.
Part2);
7221 StrRef.substr(14, 4).getAsInteger(16, Parsed.
Part3);
7222 for (
unsigned i = 0; i != 8; ++i)
7223 StrRef.substr(19 + 2 * i + (i >= 2 ? 1 : 0), 2)
7234 S.
Diag(AL.
getLoc(), diag::warn_atl_uuid_deprecated);
7242 llvm::VersionTuple SMVersion =
7244 uint32_t ZMax = 1024;
7245 uint32_t ThreadMax = 1024;
7246 if (SMVersion.getMajor() <= 4) {
7249 }
else if (SMVersion.getMajor() == 5) {
7259 diag::err_hlsl_numthreads_argument_oor) << 0 << 1024;
7267 diag::err_hlsl_numthreads_argument_oor) << 1 << 1024;
7275 diag::err_hlsl_numthreads_argument_oor) << 2 << ZMax;
7279 if (
X * Y * Z > ThreadMax) {
7280 S.
Diag(AL.
getLoc(), diag::err_hlsl_numthreads_invalid) << ThreadMax;
7293 return VT->getNumElements() <= 3;
7301 if (isa<FieldDecl>(D)) {
7302 S.
Diag(AL.
getLoc(), diag::err_hlsl_attr_invalid_ast_node)
7303 << AL <<
"parameter";
7307 auto *VD = cast<ValueDecl>(D);
7309 S.
Diag(AL.
getLoc(), diag::err_hlsl_attr_invalid_type)
7310 << AL <<
"uint/uint2/uint3";
7323 HLSLShaderAttr::ShaderType ShaderType;
7324 if (!HLSLShaderAttr::ConvertStrToShaderType(Str, ShaderType)) {
7325 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
7326 << AL << Str << ArgLoc;
7339 StringRef Space =
"space0";
7340 StringRef Slot =
"";
7343 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7356 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7363 SpaceArgLoc = Loc->
Loc;
7369 if (!Slot.empty()) {
7377 S.
Diag(ArgLoc, diag::err_hlsl_unsupported_register_type)
7378 << Slot.substr(0, 1);
7382 StringRef SlotNum = Slot.substr(1);
7384 if (SlotNum.getAsInteger(10, Num)) {
7385 S.
Diag(ArgLoc, diag::err_hlsl_unsupported_register_number);
7390 if (!Space.starts_with(
"space")) {
7391 S.
Diag(SpaceArgLoc, diag::err_hlsl_expected_space) << Space;
7394 StringRef SpaceNum = Space.substr(5);
7396 if (SpaceNum.getAsInteger(10, Num)) {
7397 S.
Diag(SpaceArgLoc, diag::err_hlsl_expected_space) << Space;
7403 HLSLResourceBindingAttr *NewAttr =
7404 HLSLResourceBindingAttr::Create(S.
getASTContext(), Slot, Space, AL);
7420 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
7433 const auto *VD = cast<VarDecl>(D);
7435 S.
Diag(AL.
getLoc(), diag::err_thread_unsupported);
7439 S.
Diag(AL.
getLoc(), diag::err_declspec_thread_on_thread_variable);
7442 if (VD->hasLocalStorage()) {
7443 S.
Diag(AL.
getLoc(), diag::err_thread_non_global) <<
"__declspec(thread)";
7451 S.
Diag(AL.
getLoc(), diag::warn_unknown_attribute_ignored)
7455 auto *FD = cast<FunctionDecl>(D);
7457 S.
Diag(AL.
getLoc(), diag::err_ms_constexpr_cannot_be_applied)
7461 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
7462 if (!S.
getLangOpts().CPlusPlus20 && MD->isVirtual()) {
7463 S.
Diag(AL.
getLoc(), diag::err_ms_constexpr_cannot_be_applied)
7473 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
7477 Tags.push_back(Tag);
7480 if (
const auto *NS = dyn_cast<NamespaceDecl>(D)) {
7481 if (!NS->isInline()) {
7482 S.
Diag(AL.
getLoc(), diag::warn_attr_abi_tag_namespace) << 0;
7485 if (NS->isAnonymousNamespace()) {
7486 S.
Diag(AL.
getLoc(), diag::warn_attr_abi_tag_namespace) << 1;
7490 Tags.push_back(NS->getName());
7496 Tags.erase(std::unique(Tags.begin(), Tags.end()), Tags.end());
7499 AbiTagAttr(S.
Context, AL, Tags.data(), Tags.size()));
7505 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 1;
7517 ARMInterruptAttr::InterruptType Kind;
7518 if (!ARMInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
7519 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << Str
7553 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7559 std::optional<llvm::APSInt> NumParams = llvm::APSInt(32);
7561 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7567 unsigned Num = NumParams->getLimitedValue(255);
7569 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
7570 << AL << (
int)NumParams->getSExtValue()
7582 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 1;
7623 if (checkAttrMutualExclusion<Mips16Attr>(S, D, AL))
7626 MipsInterruptAttr::InterruptType Kind;
7627 if (!MipsInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
7628 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
7629 << AL <<
"'" + std::string(Str) +
"'";
7641 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7650 if (!MaybeNumParams) {
7651 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7657 unsigned Num = MaybeNumParams->getLimitedValue(255);
7658 if ((Num & 1) || Num > 30) {
7659 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
7660 << AL << (
int)MaybeNumParams->getSExtValue()
7678 cast<NamedDecl>(D)->getDeclName().getCXXOverloadedOperator())) {
7679 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
7687 diag::err_anyx86_interrupt_attribute)
7696 if (NumParams < 1 || NumParams > 2) {
7707 diag::err_anyx86_interrupt_attribute)
7719 if (NumParams == 2 &&
7723 diag::err_anyx86_interrupt_attribute)
7744 handleSimpleAttribute<AVRInterruptAttr>(S, D, AL);
7757 handleSimpleAttribute<AVRSignalAttr>(S, D, AL);
7762 for (
auto *D : RD->
decls()) {
7763 if (D->hasAttr<BPFPreserveAccessIndexAttr>())
7766 D->addAttr(BPFPreserveAccessIndexAttr::CreateImplicit(S.
Context));
7767 if (
auto *Rec = dyn_cast<RecordDecl>(D))
7774 auto *Rec = cast<RecordDecl>(D);
7776 Rec->addAttr(::new (S.
Context) BPFPreserveAccessIndexAttr(S.
Context, AL));
7781 if (I->getBTFDeclTag() == Tag)
7800 return ::new (
Context) BTFDeclTagAttr(
Context, AL, AL.getBTFDeclTag());
7811 auto *FD = cast<FunctionDecl>(D);
7826WebAssemblyImportModuleAttr *
7828 auto *FD = cast<FunctionDecl>(D);
7830 if (
const auto *ExistingAttr = FD->
getAttr<WebAssemblyImportModuleAttr>()) {
7831 if (ExistingAttr->getImportModule() == AL.getImportModule())
7833 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_import) << 0
7834 << ExistingAttr->getImportModule() << AL.getImportModule();
7835 Diag(AL.getLoc(), diag::note_previous_attribute);
7839 Diag(AL.getLoc(), diag::warn_import_on_definition) << 0;
7843 AL.getImportModule());
7846WebAssemblyImportNameAttr *
7848 auto *FD = cast<FunctionDecl>(D);
7850 if (
const auto *ExistingAttr = FD->
getAttr<WebAssemblyImportNameAttr>()) {
7851 if (ExistingAttr->getImportName() == AL.getImportName())
7853 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_import) << 1
7854 << ExistingAttr->getImportName() << AL.getImportName();
7855 Diag(AL.getLoc(), diag::note_previous_attribute);
7859 Diag(AL.getLoc(), diag::warn_import_on_definition) << 1;
7863 AL.getImportName());
7868 auto *FD = cast<FunctionDecl>(D);
7875 S.
Diag(AL.
getLoc(), diag::warn_import_on_definition) << 0;
7880 WebAssemblyImportModuleAttr(S.
Context, AL, Str));
7885 auto *FD = cast<FunctionDecl>(D);
7892 S.
Diag(AL.
getLoc(), diag::warn_import_on_definition) << 1;
7902 if (
const auto *A = D->
getAttr<RISCVInterruptAttr>()) {
7904 diag::warn_riscv_repeated_interrupt_attribute);
7905 S.
Diag(A->getLocation(), diag::note_riscv_repeated_interrupt_attribute);
7947 RISCVInterruptAttr::InterruptType Kind;
7948 if (!RISCVInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
7949 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << Str
7960 case llvm::Triple::msp430:
7963 case llvm::Triple::mipsel:
7964 case llvm::Triple::mips:
7967 case llvm::Triple::m68k:
7970 case llvm::Triple::x86:
7971 case llvm::Triple::x86_64:
7974 case llvm::Triple::avr:
7977 case llvm::Triple::riscv32:
7978 case llvm::Triple::riscv64:
7989 const AMDGPUFlatWorkGroupSizeAttr &
Attr) {
8003 if (
Min == 0 &&
Max != 0) {
8017AMDGPUFlatWorkGroupSizeAttr *
8020 AMDGPUFlatWorkGroupSizeAttr TmpAttr(
Context, CI, MinExpr, MaxExpr);
8025 AMDGPUFlatWorkGroupSizeAttr(
Context, CI, MinExpr, MaxExpr);
8045 const AMDGPUWavesPerEUAttr &
Attr) {
8063 if (
Min == 0 &&
Max != 0) {
8077AMDGPUWavesPerEUAttr *
8080 AMDGPUWavesPerEUAttr TmpAttr(
Context, CI, MinExpr, MaxExpr);
8085 return ::new (
Context) AMDGPUWavesPerEUAttr(
Context, CI, MinExpr, MaxExpr);
8105 uint32_t NumSGPR = 0;
8114 uint32_t NumVGPR = 0;
8125 const AMDGPUMaxNumWorkGroupsAttr &
Attr) {
8138 Expr *Exprs[3] = {XExpr, YExpr, ZExpr};
8139 for (
int i = 0; i < 3; i++) {
8155AMDGPUMaxNumWorkGroupsAttr *
8158 AMDGPUMaxNumWorkGroupsAttr TmpAttr(
Context, CI, XExpr, YExpr, ZExpr);
8164 AMDGPUMaxNumWorkGroupsAttr(
Context, CI, XExpr, YExpr, ZExpr);
8186 const auto *VD = dyn_cast<ValueDecl>(D);
8187 if (VD && VD->getType()->isFunctionPointerType())
8190 const auto *TD = dyn_cast<TypedefNameDecl>(D);
8191 if (TD && (TD->getUnderlyingType()->isFunctionPointerType() ||
8192 TD->getUnderlyingType()->isFunctionType()))
8195 if (!isa<FunctionDecl>(D)) {
8196 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
8212 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
8227 if (D->
hasAttr<DLLExportAttr>()) {
8228 Diag(CI.
getLoc(), diag::warn_attribute_ignored) <<
"'dllimport'";
8232 if (D->
hasAttr<DLLImportAttr>())
8240 if (DLLImportAttr *Import = D->
getAttr<DLLImportAttr>()) {
8241 Diag(Import->getLocation(), diag::warn_attribute_ignored) << Import;
8245 if (D->
hasAttr<DLLExportAttr>())
8252 if (isa<ClassTemplatePartialSpecializationDecl>(D) &&
8258 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
8268 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
8270 MD->getParent()->isLambda()) {
8276 Attr *NewAttr = A.
getKind() == ParsedAttr::AT_DLLExport
8287 if (MSInheritanceAttr *IA = D->
getAttr<MSInheritanceAttr>()) {
8288 if (IA->getInheritanceModel() == Model)
8290 Diag(IA->getLocation(), diag::err_mismatched_ms_inheritance)
8292 Diag(CI.
getLoc(), diag::note_previous_ms_inheritance);
8296 auto *RD = cast<CXXRecordDecl>(D);
8297 if (RD->hasDefinition()) {
8303 if (isa<ClassTemplatePartialSpecializationDecl>(RD)) {
8304 Diag(CI.
getLoc(), diag::warn_ignored_ms_inheritance)
8308 if (RD->getDescribedClassTemplate()) {
8309 Diag(CI.
getLoc(), diag::warn_ignored_ms_inheritance)
8327 StringRef N(
"mutex");
8329 if (AL.
getKind() == ParsedAttr::AT_Capability &&
8342 AssertCapabilityAttr(S.
Context, AL, Args.data(), Args.size()));
8386 RequiresCapabilityAttr *RCA = ::new (S.
Context)
8387 RequiresCapabilityAttr(S.
Context, AL, Args.data(), Args.size());
8393 if (
const auto *NSD = dyn_cast<NamespaceDecl>(D)) {
8394 if (NSD->isAnonymousNamespace()) {
8395 S.
Diag(AL.
getLoc(), diag::warn_deprecated_anonymous_namespace);
8409 StringRef Str, Replacement;
8422 S.
Diag(AL.
getLoc(), diag::ext_cxx14_attr) << AL;
8428 if (
const auto *S = dyn_cast<VarDecl>(D))
8429 return S->hasGlobalStorage();
8434 return Sanitizer ==
"address" || Sanitizer ==
"hwaddress" ||
8435 Sanitizer ==
"memtag";
8442 std::vector<StringRef> Sanitizers;
8444 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
8445 StringRef SanitizerName;
8453 SanitizerName !=
"coverage")
8454 S.
Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << SanitizerName;
8456 S.
Diag(D->
getLocation(), diag::warn_attribute_type_not_supported_global)
8457 << AL << SanitizerName;
8458 Sanitizers.push_back(SanitizerName);
8462 Sanitizers.size()));
8469 StringRef SanitizerName = llvm::StringSwitch<StringRef>(AttrName)
8470 .Case(
"no_address_safety_analysis",
"address")
8471 .Case(
"no_sanitize_address",
"address")
8472 .Case(
"no_sanitize_thread",
"thread")
8473 .Case(
"no_sanitize_memory",
"memory");
8486 unsigned TranslatedSpellingIndex = 0;
8488 TranslatedSpellingIndex = 1;
8493 NoSanitizeAttr(S.
Context, Info, &SanitizerName, 1));
8503 S.
Diag(AL.
getLoc(), diag::err_attribute_requires_opencl_version)
8504 << AL <<
"2.0" << 1;
8506 S.
Diag(AL.
getLoc(), diag::warn_opencl_attr_deprecated_ignored)
8515 if (D->
hasAttr<OpenCLAccessAttr>()) {
8516 if (D->
getAttr<OpenCLAccessAttr>()->getSemanticSpelling() ==
8518 S.
Diag(AL.
getLoc(), diag::warn_duplicate_declspec)
8521 S.
Diag(AL.
getLoc(), diag::err_opencl_multiple_access_qualifiers)
8537 if (
const auto *PDecl = dyn_cast<ParmVarDecl>(D)) {
8538 const Type *DeclTy = PDecl->getType().getCanonicalType().getTypePtr();
8540 bool ReadWriteImagesUnsupported =
8545 if (ReadWriteImagesUnsupported || DeclTy->isPipeType()) {
8546 S.
Diag(AL.
getLoc(), diag::err_opencl_invalid_read_write)
8547 << AL << PDecl->getType() << DeclTy->isImageType();
8564 ZeroCallUsedRegsAttr::ZeroCallUsedRegsKind Kind;
8565 if (!ZeroCallUsedRegsAttr::ConvertStrToZeroCallUsedRegsKind(KindStr, Kind)) {
8566 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported)
8571 D->
dropAttr<ZeroCallUsedRegsAttr>();
8581 while (RD && (RD->isAnonymousStructOrUnion() ||
8582 (!RD->isCompleteDefinition() && RD->getName().empty()))) {
8583 const auto *
Parent = dyn_cast<RecordDecl>(RD->getParent());
8601 S.
Diag(E->
getBeginLoc(), diag::err_counted_by_attr_argument_not_integer)
8610 StrictFlexArraysLevel,
true)) {
8614 diag::err_counted_by_attr_not_on_flexible_array_member)
8619 auto *DRE = dyn_cast<DeclRefExpr>(E);
8622 diag::err_counted_by_attr_only_support_simple_decl_reference)
8627 auto *CountDecl = DRE->
getDecl();
8628 FieldDecl *CountFD = dyn_cast<FieldDecl>(CountDecl);
8629 if (
auto *IFD = dyn_cast<IndirectFieldDecl>(CountDecl)) {
8630 CountFD = IFD->getAnonField();
8636 S.
Diag(CountDecl->getBeginLoc(),
8637 diag::note_flexible_array_counted_by_attr_field)
8638 << CountDecl << CountDecl->getSourceRange();
8644 S.
Diag(CountFD->
getBeginLoc(), diag::err_counted_by_attr_refer_to_union)
8654 if (RD != CountRD) {
8656 diag::err_flexible_array_count_not_in_same_struct)
8659 diag::note_flexible_array_counted_by_attr_field)
8670 auto *FD = dyn_cast<FieldDecl>(D);
8692 FunctionReturnThunksAttr::Kind Kind;
8693 if (!FunctionReturnThunksAttr::ConvertStrToKind(KindStr, Kind)) {
8694 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported)
8701 D->
dropAttr<FunctionReturnThunksAttr>();
8702 D->
addAttr(FunctionReturnThunksAttr::Create(S.
Context, Kind, AL));
8707 assert(isa<TypedefNameDecl>(D) &&
"This attribute only applies to a typedef");
8708 handleSimpleAttribute<AvailableOnlyInDefaultEvalMethodAttr>(S, D, AL);
8712 auto *VDecl = dyn_cast<VarDecl>(D);
8713 if (VDecl && !VDecl->isFunctionPointerType()) {
8714 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored_non_function_pointer)
8727 const auto *FD = cast<FunctionDecl>(D);
8729 assert(FT &&
"Function template is expected");
8733 if (TL->
size() < 2) {
8734 S.
Diag(FT->
getLocation(), diag::warn_sycl_kernel_num_of_template_params);
8739 for (
unsigned I = 0; I < 2; ++I) {
8741 if (isa<NonTypeTemplateParmDecl>(TParam)) {
8743 diag::warn_sycl_kernel_invalid_template_param_type);
8750 S.
Diag(FT->
getLocation(), diag::warn_sycl_kernel_num_of_function_params);
8761 handleSimpleAttribute<SYCLKernelAttr>(S, D, AL);
8765 if (!cast<VarDecl>(D)->hasGlobalStorage()) {
8767 << (A.
getKind() == ParsedAttr::AT_AlwaysDestroy);
8771 if (A.
getKind() == ParsedAttr::AT_AlwaysDestroy)
8772 handleSimpleAttribute<AlwaysDestroyAttr>(S, D, A);
8774 handleSimpleAttribute<NoDestroyAttr>(S, D, A);
8778 assert(cast<VarDecl>(D)->getStorageDuration() ==
SD_Automatic &&
8779 "uninitialized is only valid on automatic duration variables");
8784 bool DiagnoseFailure) {
8787 if (DiagnoseFailure) {
8788 S.
Diag(VD->
getBeginLoc(), diag::warn_ignored_objc_externally_retained)
8805 if (DiagnoseFailure) {
8806 S.
Diag(VD->
getBeginLoc(), diag::warn_ignored_objc_externally_retained)
8822 if (
auto *VD = dyn_cast<VarDecl>(D)) {
8823 assert(!isa<ParmVarDecl>(VD) &&
"should be diagnosed automatically");
8824 if (!VD->hasLocalStorage()) {
8833 handleSimpleAttribute<ObjCExternallyRetainedAttr>(S, D, AL);
8839 unsigned NumParams =
8841 for (
unsigned I = 0; I != NumParams; ++I) {
8855 handleSimpleAttribute<ObjCExternallyRetainedAttr>(S, D, AL);
8863 if (!isa<BlockDecl>(D)) {
8865 bool IsKernReturnT =
false;
8867 IsKernReturnT = (TT->getDecl()->getName() ==
"kern_return_t");
8872 diag::warn_mig_server_routine_does_not_return_kern_return_t);
8877 handleSimpleAttribute<MIGServerRoutineAttr>(S, D, AL);
8882 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
8885 S.
Diag(AL.
getLoc(), diag::warn_declspec_allocator_nonpointer)
8891 handleSimpleAttribute<MSAllocatorAttr>(S, D, AL);
8898 if (
const auto *PVD = dyn_cast<ParmVarDecl>(D)) {
8899 if (PVD->getType()->isIntegerType()) {
8900 S.
Diag(AL.
getLoc(), diag::err_attribute_output_parameter)
8911template<
typename Attr>
8919template<
typename Attr>
8928 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
8933 CFGuardAttr::GuardArg Arg;
8935 if (!CFGuardAttr::ConvertStrToGuardArg(II->
getName(), Arg)) {
8936 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
8944template <
typename AttrTy>
8947 auto I = llvm::find_if(Attrs,
8948 [Name](
const AttrTy *A) {
8949 return A->getTCBName() == Name;
8951 return I == Attrs.end() ? nullptr : *I;
8954template <
typename AttrTy,
typename ConflictingAttrTy>
8961 if (
const ConflictingAttrTy *ConflictingAttr =
8962 findEnforceTCBAttrByName<ConflictingAttrTy>(D, Argument)) {
8965 S.
Diag(AL.
getLoc(), diag::err_tcb_conflicting_attributes)
8979template <
typename AttrTy,
typename ConflictingAttrTy>
8982 StringRef TCBName = AL.getTCBName();
8983 if (
const ConflictingAttrTy *ConflictingAttr =
8984 findEnforceTCBAttrByName<ConflictingAttrTy>(D, TCBName)) {
8985 S.
Diag(ConflictingAttr->getLoc(), diag::err_tcb_conflicting_attributes)
8986 << ConflictingAttr->getAttrName()->getName()
8987 << AL.getAttrName()->getName() << TCBName;
8990 S.
Diag(AL.getLoc(), diag::note_conflicting_attribute);
8998 return ::new(Context) AttrTy(Context, AL, AL.getTCBName());
9002 return mergeEnforceTCBAttrImpl<EnforceTCBAttr, EnforceTCBLeafAttr>(
9007 Decl *D,
const EnforceTCBLeafAttr &AL) {
9008 return mergeEnforceTCBAttrImpl<EnforceTCBLeafAttr, EnforceTCBAttr>(
9025 for (
size_t I = 0; I < std::min(AL.
getNumArgs(), AttrNumArgs); ++I) {
9026 bool IsLastAttrArg = I == (AttrNumArgs - 1);
9029 if (IsLastAttrArg && AttrHasVariadicArg)
9036 if (isa<PackExpansionExpr>(E))
9037 return !(IsLastAttrArg && ArgMemberCanHoldExpr);
9050 auto CheckForIncompatibleAttr =
9052 StringRef IncompatibleStateName) {
9053 if (CurrentState == IncompatibleState) {
9054 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
9055 << (std::string(
"'__arm_new(\"") + StateName.str() +
"\")'")
9056 << (std::string(
"'") + IncompatibleStateName.str() +
"(\"" +
9057 StateName.str() +
"\")'")
9072 S.
Diag(AL.
getLoc(), diag::err_missing_arm_state) << AL;
9077 std::vector<StringRef> NewState;
9078 if (
const auto *ExistingAttr = D->
getAttr<ArmNewAttr>()) {
9079 for (StringRef S : ExistingAttr->newArgs())
9080 NewState.push_back(S);
9084 bool HasZT0 =
false;
9085 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
9086 StringRef StateName;
9091 if (StateName ==
"za")
9093 else if (StateName ==
"zt0")
9096 S.
Diag(LiteralLoc, diag::err_unknown_arm_state) << StateName;
9101 if (!llvm::is_contained(NewState, StateName))
9102 NewState.push_back(StateName);
9120 ArmNewAttr(S.
Context, AL, NewState.data(), NewState.size()));
9144 ? (
unsigned)diag::err_keyword_not_supported_on_target
9146 ? (
unsigned)diag::warn_unhandled_ms_attribute_ignored
9147 : (
unsigned)diag::warn_unknown_attribute_ignored)
9159 if (MustDelayArgs) {
9169 assert(AL.
isTypeAttr() &&
"Non-type attribute not handled");
9172 if (Options.IgnoreTypeAttributes)
9190 isa<DeclaratorDecl, TypeAliasDecl>(D)) {
9195 S.
Diag(AL.
getLoc(), diag::warn_type_attribute_deprecated_on_decl)
9204 if (AL.
getKind() == ParsedAttr::AT_Regparm) {
9217 if (AL.
getKind() == ParsedAttr::AT_VectorSize) {
9227 if (AL.
getKind() == ParsedAttr::AT_NoDeref) {
9238 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_on_decl)
9241 case ParsedAttr::AT_Interrupt:
9244 case ParsedAttr::AT_X86ForceAlignArgPointer:
9247 case ParsedAttr::AT_ReadOnlyPlacement:
9248 handleSimpleAttribute<ReadOnlyPlacementAttr>(S, D, AL);
9250 case ParsedAttr::AT_DLLExport:
9251 case ParsedAttr::AT_DLLImport:
9254 case ParsedAttr::AT_AMDGPUFlatWorkGroupSize:
9257 case ParsedAttr::AT_AMDGPUWavesPerEU:
9260 case ParsedAttr::AT_AMDGPUNumSGPR:
9263 case ParsedAttr::AT_AMDGPUNumVGPR:
9266 case ParsedAttr::AT_AMDGPUMaxNumWorkGroups:
9269 case ParsedAttr::AT_AVRSignal:
9272 case ParsedAttr::AT_BPFPreserveAccessIndex:
9275 case ParsedAttr::AT_BPFPreserveStaticOffset:
9276 handleSimpleAttribute<BPFPreserveStaticOffsetAttr>(S, D, AL);
9278 case ParsedAttr::AT_BTFDeclTag:
9281 case ParsedAttr::AT_WebAssemblyExportName:
9284 case ParsedAttr::AT_WebAssemblyImportModule:
9287 case ParsedAttr::AT_WebAssemblyImportName:
9290 case ParsedAttr::AT_IBOutlet:
9293 case ParsedAttr::AT_IBOutletCollection:
9296 case ParsedAttr::AT_IFunc:
9299 case ParsedAttr::AT_Alias:
9302 case ParsedAttr::AT_Aligned:
9305 case ParsedAttr::AT_AlignValue:
9308 case ParsedAttr::AT_AllocSize:
9311 case ParsedAttr::AT_AlwaysInline:
9314 case ParsedAttr::AT_AnalyzerNoReturn:
9317 case ParsedAttr::AT_TLSModel:
9320 case ParsedAttr::AT_Annotate:
9323 case ParsedAttr::AT_Availability:
9326 case ParsedAttr::AT_CarriesDependency:
9329 case ParsedAttr::AT_CPUDispatch:
9330 case ParsedAttr::AT_CPUSpecific:
9333 case ParsedAttr::AT_Common:
9336 case ParsedAttr::AT_CUDAConstant:
9339 case ParsedAttr::AT_PassObjectSize:
9342 case ParsedAttr::AT_Constructor:
9345 case ParsedAttr::AT_Deprecated:
9348 case ParsedAttr::AT_Destructor:
9351 case ParsedAttr::AT_EnableIf:
9354 case ParsedAttr::AT_Error:
9357 case ParsedAttr::AT_ExcludeFromExplicitInstantiation:
9360 case ParsedAttr::AT_DiagnoseIf:
9363 case ParsedAttr::AT_DiagnoseAsBuiltin:
9366 case ParsedAttr::AT_NoBuiltin:
9369 case ParsedAttr::AT_ExtVectorType:
9372 case ParsedAttr::AT_ExternalSourceSymbol:
9375 case ParsedAttr::AT_MinSize:
9378 case ParsedAttr::AT_OptimizeNone:
9381 case ParsedAttr::AT_EnumExtensibility:
9384 case ParsedAttr::AT_SYCLKernel:
9387 case ParsedAttr::AT_SYCLSpecialClass:
9388 handleSimpleAttribute<SYCLSpecialClassAttr>(S, D, AL);
9390 case ParsedAttr::AT_Format:
9393 case ParsedAttr::AT_FormatArg:
9396 case ParsedAttr::AT_Callback:
9399 case ParsedAttr::AT_CalledOnce:
9402 case ParsedAttr::AT_NVPTXKernel:
9403 case ParsedAttr::AT_CUDAGlobal:
9406 case ParsedAttr::AT_CUDADevice:
9409 case ParsedAttr::AT_HIPManaged:
9412 case ParsedAttr::AT_GNUInline:
9415 case ParsedAttr::AT_CUDALaunchBounds:
9418 case ParsedAttr::AT_Restrict:
9421 case ParsedAttr::AT_Mode:
9424 case ParsedAttr::AT_NonNull:
9425 if (
auto *PVD = dyn_cast<ParmVarDecl>(D))
9430 case ParsedAttr::AT_ReturnsNonNull:
9433 case ParsedAttr::AT_NoEscape:
9436 case ParsedAttr::AT_MaybeUndef:
9437 handleSimpleAttribute<MaybeUndefAttr>(S, D, AL);
9439 case ParsedAttr::AT_AssumeAligned:
9442 case ParsedAttr::AT_AllocAlign:
9445 case ParsedAttr::AT_Ownership:
9448 case ParsedAttr::AT_Naked:
9451 case ParsedAttr::AT_NoReturn:
9454 case ParsedAttr::AT_CXX11NoReturn:
9457 case ParsedAttr::AT_AnyX86NoCfCheck:
9460 case ParsedAttr::AT_NoThrow:
9462 handleSimpleAttribute<NoThrowAttr>(S, D, AL);
9464 case ParsedAttr::AT_CUDAShared:
9467 case ParsedAttr::AT_VecReturn:
9470 case ParsedAttr::AT_ObjCOwnership:
9473 case ParsedAttr::AT_ObjCPreciseLifetime:
9476 case ParsedAttr::AT_ObjCReturnsInnerPointer:
9479 case ParsedAttr::AT_ObjCRequiresSuper:
9482 case ParsedAttr::AT_ObjCBridge:
9485 case ParsedAttr::AT_ObjCBridgeMutable:
9488 case ParsedAttr::AT_ObjCBridgeRelated:
9491 case ParsedAttr::AT_ObjCDesignatedInitializer:
9494 case ParsedAttr::AT_ObjCRuntimeName:
9497 case ParsedAttr::AT_ObjCBoxable:
9500 case ParsedAttr::AT_NSErrorDomain:
9503 case ParsedAttr::AT_CFConsumed:
9504 case ParsedAttr::AT_NSConsumed:
9505 case ParsedAttr::AT_OSConsumed:
9509 case ParsedAttr::AT_OSReturnsRetainedOnZero:
9510 handleSimpleAttributeOrDiagnose<OSReturnsRetainedOnZeroAttr>(
9512 diag::warn_ns_attribute_wrong_parameter_type,
9515 case ParsedAttr::AT_OSReturnsRetainedOnNonZero:
9516 handleSimpleAttributeOrDiagnose<OSReturnsRetainedOnNonZeroAttr>(
9518 diag::warn_ns_attribute_wrong_parameter_type,
9521 case ParsedAttr::AT_NSReturnsAutoreleased:
9522 case ParsedAttr::AT_NSReturnsNotRetained:
9523 case ParsedAttr::AT_NSReturnsRetained:
9524 case ParsedAttr::AT_CFReturnsNotRetained:
9525 case ParsedAttr::AT_CFReturnsRetained:
9526 case ParsedAttr::AT_OSReturnsNotRetained:
9527 case ParsedAttr::AT_OSReturnsRetained:
9530 case ParsedAttr::AT_WorkGroupSizeHint:
9531 handleWorkGroupSize<WorkGroupSizeHintAttr>(S, D, AL);
9533 case ParsedAttr::AT_ReqdWorkGroupSize:
9534 handleWorkGroupSize<ReqdWorkGroupSizeAttr>(S, D, AL);
9536 case ParsedAttr::AT_OpenCLIntelReqdSubGroupSize:
9539 case ParsedAttr::AT_VecTypeHint:
9542 case ParsedAttr::AT_InitPriority:
9545 case ParsedAttr::AT_Packed:
9548 case ParsedAttr::AT_PreferredName:
9551 case ParsedAttr::AT_Section:
9554 case ParsedAttr::AT_CodeModel:
9557 case ParsedAttr::AT_RandomizeLayout:
9560 case ParsedAttr::AT_NoRandomizeLayout:
9563 case ParsedAttr::AT_CodeSeg:
9566 case ParsedAttr::AT_Target:
9569 case ParsedAttr::AT_TargetVersion:
9572 case ParsedAttr::AT_TargetClones:
9575 case ParsedAttr::AT_MinVectorWidth:
9578 case ParsedAttr::AT_Unavailable:
9579 handleAttrWithMessage<UnavailableAttr>(S, D, AL);
9581 case ParsedAttr::AT_OMPAssume:
9584 case ParsedAttr::AT_ObjCDirect:
9587 case ParsedAttr::AT_ObjCDirectMembers:
9589 handleSimpleAttribute<ObjCDirectMembersAttr>(S, D, AL);
9591 case ParsedAttr::AT_ObjCExplicitProtocolImpl:
9594 case ParsedAttr::AT_Unused:
9597 case ParsedAttr::AT_Visibility:
9600 case ParsedAttr::AT_TypeVisibility:
9603 case ParsedAttr::AT_WarnUnusedResult:
9606 case ParsedAttr::AT_WeakRef:
9609 case ParsedAttr::AT_WeakImport:
9612 case ParsedAttr::AT_TransparentUnion:
9615 case ParsedAttr::AT_ObjCMethodFamily:
9618 case ParsedAttr::AT_ObjCNSObject:
9621 case ParsedAttr::AT_ObjCIndependentClass:
9624 case ParsedAttr::AT_Blocks:
9627 case ParsedAttr::AT_Sentinel:
9630 case ParsedAttr::AT_Cleanup:
9633 case ParsedAttr::AT_NoDebug:
9636 case ParsedAttr::AT_CmseNSEntry:
9639 case ParsedAttr::AT_StdCall:
9640 case ParsedAttr::AT_CDecl:
9641 case ParsedAttr::AT_FastCall:
9642 case ParsedAttr::AT_ThisCall:
9643 case ParsedAttr::AT_Pascal:
9644 case ParsedAttr::AT_RegCall:
9645 case ParsedAttr::AT_SwiftCall:
9646 case ParsedAttr::AT_SwiftAsyncCall:
9647 case ParsedAttr::AT_VectorCall:
9648 case ParsedAttr::AT_MSABI:
9649 case ParsedAttr::AT_SysVABI:
9650 case ParsedAttr::AT_Pcs:
9651 case ParsedAttr::AT_IntelOclBicc:
9652 case ParsedAttr::AT_PreserveMost:
9653 case ParsedAttr::AT_PreserveAll:
9654 case ParsedAttr::AT_AArch64VectorPcs:
9655 case ParsedAttr::AT_AArch64SVEPcs:
9656 case ParsedAttr::AT_AMDGPUKernelCall:
9657 case ParsedAttr::AT_M68kRTD:
9658 case ParsedAttr::AT_PreserveNone:
9659 case ParsedAttr::AT_RISCVVectorCC:
9662 case ParsedAttr::AT_Suppress:
9665 case ParsedAttr::AT_Owner:
9666 case ParsedAttr::AT_Pointer:
9669 case ParsedAttr::AT_OpenCLAccess:
9672 case ParsedAttr::AT_OpenCLNoSVM:
9675 case ParsedAttr::AT_SwiftContext:
9678 case ParsedAttr::AT_SwiftAsyncContext:
9681 case ParsedAttr::AT_SwiftErrorResult:
9684 case ParsedAttr::AT_SwiftIndirectResult:
9687 case ParsedAttr::AT_InternalLinkage:
9690 case ParsedAttr::AT_ZeroCallUsedRegs:
9693 case ParsedAttr::AT_FunctionReturnThunks:
9696 case ParsedAttr::AT_NoMerge:
9699 case ParsedAttr::AT_NoUniqueAddress:
9703 case ParsedAttr::AT_AvailableOnlyInDefaultEvalMethod:
9707 case ParsedAttr::AT_CountedBy:
9712 case ParsedAttr::AT_LayoutVersion:
9715 case ParsedAttr::AT_Uuid:
9718 case ParsedAttr::AT_MSInheritance:
9721 case ParsedAttr::AT_Thread:
9724 case ParsedAttr::AT_MSConstexpr:
9729 case ParsedAttr::AT_HLSLNumThreads:
9732 case ParsedAttr::AT_HLSLSV_GroupIndex:
9733 handleSimpleAttribute<HLSLSV_GroupIndexAttr>(S, D, AL);
9735 case ParsedAttr::AT_HLSLSV_DispatchThreadID:
9738 case ParsedAttr::AT_HLSLShader:
9741 case ParsedAttr::AT_HLSLResourceBinding:
9744 case ParsedAttr::AT_HLSLParamModifier:
9748 case ParsedAttr::AT_AbiTag:
9751 case ParsedAttr::AT_CFGuard:
9756 case ParsedAttr::AT_AssertExclusiveLock:
9759 case ParsedAttr::AT_AssertSharedLock:
9762 case ParsedAttr::AT_PtGuardedVar:
9765 case ParsedAttr::AT_NoSanitize:
9768 case ParsedAttr::AT_NoSanitizeSpecific:
9771 case ParsedAttr::AT_GuardedBy:
9774 case ParsedAttr::AT_PtGuardedBy:
9777 case ParsedAttr::AT_ExclusiveTrylockFunction:
9780 case ParsedAttr::AT_LockReturned:
9783 case ParsedAttr::AT_LocksExcluded:
9786 case ParsedAttr::AT_SharedTrylockFunction:
9789 case ParsedAttr::AT_AcquiredBefore:
9792 case ParsedAttr::AT_AcquiredAfter:
9797 case ParsedAttr::AT_Capability:
9798 case ParsedAttr::AT_Lockable:
9801 case ParsedAttr::AT_RequiresCapability:
9805 case ParsedAttr::AT_AssertCapability:
9808 case ParsedAttr::AT_AcquireCapability:
9811 case ParsedAttr::AT_ReleaseCapability:
9814 case ParsedAttr::AT_TryAcquireCapability:
9819 case ParsedAttr::AT_Consumable:
9822 case ParsedAttr::AT_CallableWhen:
9825 case ParsedAttr::AT_ParamTypestate:
9828 case ParsedAttr::AT_ReturnTypestate:
9831 case ParsedAttr::AT_SetTypestate:
9834 case ParsedAttr::AT_TestTypestate:
9839 case ParsedAttr::AT_ArgumentWithTypeTag:
9842 case ParsedAttr::AT_TypeTagForDatatype:
9847 case ParsedAttr::AT_SwiftAsyncName:
9850 case ParsedAttr::AT_SwiftAttr:
9853 case ParsedAttr::AT_SwiftBridge:
9856 case ParsedAttr::AT_SwiftError:
9859 case ParsedAttr::AT_SwiftName:
9862 case ParsedAttr::AT_SwiftNewType:
9865 case ParsedAttr::AT_SwiftAsync:
9868 case ParsedAttr::AT_SwiftAsyncError:
9873 case ParsedAttr::AT_XRayLogArgs:
9877 case ParsedAttr::AT_PatchableFunctionEntry:
9881 case ParsedAttr::AT_AlwaysDestroy:
9882 case ParsedAttr::AT_NoDestroy:
9886 case ParsedAttr::AT_Uninitialized:
9890 case ParsedAttr::AT_ObjCExternallyRetained:
9894 case ParsedAttr::AT_MIGServerRoutine:
9898 case ParsedAttr::AT_MSAllocator:
9902 case ParsedAttr::AT_ArmBuiltinAlias:
9906 case ParsedAttr::AT_ArmLocallyStreaming:
9907 handleSimpleAttribute<ArmLocallyStreamingAttr>(S, D, AL);
9910 case ParsedAttr::AT_ArmNew:
9914 case ParsedAttr::AT_AcquireHandle:
9918 case ParsedAttr::AT_ReleaseHandle:
9919 handleHandleAttr<ReleaseHandleAttr>(S, D, AL);
9922 case ParsedAttr::AT_UnsafeBufferUsage:
9923 handleUnsafeBufferUsage<UnsafeBufferUsageAttr>(S, D, AL);
9926 case ParsedAttr::AT_UseHandle:
9927 handleHandleAttr<UseHandleAttr>(S, D, AL);
9930 case ParsedAttr::AT_EnforceTCB:
9931 handleEnforceTCBAttr<EnforceTCBAttr, EnforceTCBLeafAttr>(S, D, AL);
9934 case ParsedAttr::AT_EnforceTCBLeaf:
9935 handleEnforceTCBAttr<EnforceTCBLeafAttr, EnforceTCBAttr>(S, D, AL);
9938 case ParsedAttr::AT_BuiltinAlias:
9942 case ParsedAttr::AT_PreferredType:
9946 case ParsedAttr::AT_UsingIfExists:
9947 handleSimpleAttribute<UsingIfExistsAttr>(S, D, AL);
9950 case ParsedAttr::AT_TypeNullable:
9961 if (AttrList.
empty())
9972 Diag(AttrList.
begin()->getLoc(), diag::err_attribute_weakref_without_alias)
9973 << cast<NamedDecl>(D);
9982 if (!D->
hasAttr<OpenCLKernelAttr>()) {
9984 if (
const auto *A = D->
getAttr<ReqdWorkGroupSizeAttr>()) {
9989 }
else if (
const auto *A = D->
getAttr<WorkGroupSizeHintAttr>()) {
9992 }
else if (
const auto *A = D->
getAttr<VecTypeHintAttr>()) {
9995 }
else if (
const auto *A = D->
getAttr<OpenCLIntelReqdSubGroupSizeAttr>()) {
9998 }
else if (!D->
hasAttr<CUDAGlobalAttr>()) {
9999 if (
const auto *A = D->
getAttr<AMDGPUFlatWorkGroupSizeAttr>()) {
10003 }
else if (
const auto *A = D->
getAttr<AMDGPUWavesPerEUAttr>()) {
10007 }
else if (
const auto *A = D->
getAttr<AMDGPUNumSGPRAttr>()) {
10011 }
else if (
const auto *A = D->
getAttr<AMDGPUNumVGPRAttr>()) {
10024 if (D->
hasAttr<ObjCDesignatedInitializerAttr>() &&
10025 cast<ObjCMethodDecl>(D)->getMethodFamily() !=
OMF_init) {
10027 D->
dropAttr<ObjCDesignatedInitializerAttr>();
10036 if (AL.getKind() == ParsedAttr::AT_TransparentUnion) {
10043 if (D && D->
hasAttr<BPFPreserveAccessIndexAttr>())
10052 if (AL.getKind() == ParsedAttr::AT_Annotate) {
10056 Diag(AL.getLoc(), diag::err_only_annotate_after_access_spec);
10068 if (AL.isUsedAsTypeAttr() || AL.isInvalid())
10074 S.
Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored)
10075 << AL << AL.getRange();
10077 S.
Diag(AL.getLoc(), diag::warn_attribute_not_on_decl) << AL
10098 assert(isa<FunctionDecl>(ND) || isa<VarDecl>(ND));
10100 if (
auto *FD = dyn_cast<FunctionDecl>(ND)) {
10122 for (
const auto &AI : FT->param_types()) {
10125 Params.push_back(Param);
10127 NewFD->setParams(Params);
10129 }
else if (
auto *VD = dyn_cast<VarDecl>(ND)) {
10131 VD->getInnerLocStart(), VD->getLocation(), II,
10132 VD->getType(), VD->getTypeSourceInfo(),
10133 VD->getStorageClass());
10134 if (VD->getQualifier())
10135 cast<VarDecl>(NewD)->setQualifierInfo(VD->getQualifierLoc());
10170 if (
auto *VD = dyn_cast<VarDecl>(D))
10171 if (VD->isExternC())
10173 if (
auto *FD = dyn_cast<FunctionDecl>(D))
10181 auto &WeakInfos = I->second;
10182 for (
const auto &W : WeakInfos)
10184 std::remove_reference_t<
decltype(WeakInfos)> EmptyWeakInfos;
10185 WeakInfos.swap(EmptyWeakInfos);
10201 if (AL.slidesFromDeclToDeclSpecLegacyBehavior()) {
10206 AL.diagnoseAppertainsTo(*
this, D);
10217 .WithIncludeCXX11Attributes(
false)
10218 .WithIgnoreTypeAttributes(
true));
10228 .WithIncludeCXX11Attributes(
false)
10229 .WithIgnoreTypeAttributes(
true));
10247 UnavailableAttr::ImplicitReason &reason) {
10251 if (!isa<FieldDecl>(D) && !isa<ObjCPropertyDecl>(D) &&
10252 !isa<FunctionDecl>(D))
10260 if ((isa<ObjCIvarDecl>(D) || isa<ObjCPropertyDecl>(D))) {
10263 reason = UnavailableAttr::IR_ForbiddenWeak;
10272 reason = UnavailableAttr::IR_ARCForbiddenType;
10282 auto Reason = UnavailableAttr::IR_None;
10284 assert(Reason &&
"didn't set reason?");
10289 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
10292 if (FD->
hasAttr<UnavailableAttr>() &&
10294 diag::err_arc_array_param_no_ownership) {
10325 bool AnyAccessFailures =
false;
10333 switch (diag.
Kind) {
10337 if (!
decl->isInvalidDecl())
10345 if (AnyAccessFailures && isa<DecompositionDecl>(
decl))
10349 AnyAccessFailures =
true;
10365 assert(curPool &&
"re-emitting in undelayed context not supported");
10366 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::LangOptions interface.
llvm::MachO::Target Target
llvm::MachO::Record Record
static bool versionsMatch(const VersionTuple &X, const VersionTuple &Y)
Check whether the two versions match.
static unsigned getNumAttributeArgs(const ParsedAttr &AL)
Defines the clang::Preprocessor interface.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
This file declares semantic analysis for CUDA constructs.
static bool isCFStringType(QualType T, ASTContext &Ctx)
static void handleObjCBoxable(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleBPFPreserveAccessIndexAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleCleanupAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAlignedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleWeakImportAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleHandleAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleHLSLShaderAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkGuardedByAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, Expr *&Arg)
static void handleCodeSegAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handlePatchableFunctionEntryAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleCountedByAttrField(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAMDGPUNumVGPRAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleOpenCLAccessAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleFormatAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Handle attribute((format(type,idx,firstarg))) attributes based on http://gcc.gnu.org/onlinedocs/gcc/F...
static void handleUninitializedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isNSStringType(QualType T, ASTContext &Ctx, bool AllowNSAttributedString=false)
static void handleRequiresCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleBTFDeclTagAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleOptimizeNoneAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleEnableIfAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isFunctionOrMethodVariadic(const Decl *D)
static void handleSwiftError(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSectionAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleStandardNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &A)
static void handleMIGServerRoutineAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleGuardedByAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleZeroCallUsedRegsAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static const RecordDecl * GetEnclosingNamedOrTopAnonRecord(const FieldDecl *FD)
static void handleDiagnoseAsBuiltinAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleEnumExtensibilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static T * mergeVisibilityAttr(Sema &S, Decl *D, const AttributeCommonInfo &CI, typename T::VisibilityType value)
static bool hasArmStreamingInterface(const FunctionDecl *FD)
static bool CheckCountExpr(Sema &S, FieldDecl *FD, Expr *E, llvm::SmallVectorImpl< TypeCoupledDeclRefInfo > &Decls)
static void handleLayoutVersion(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAMDGPUWavesPerEUAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkForConsumableClass(Sema &S, const CXXMethodDecl *MD, const ParsedAttr &AL)
static void handleDLLAttr(Sema &S, Decl *D, const ParsedAttr &A)
static void handleConstantAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAlignValueAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleHLSLSV_DispatchThreadIDAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSubGroupSize(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNoCfCheckAttr(Sema &S, Decl *D, const ParsedAttr &Attrs)
static void handleArmBuiltinAliasAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleCmseNSEntryAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleOpenCLNoSVMAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleReturnsNonNullAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void checkUnusedDeclAttributes(Sema &S, const ParsedAttributesView &A)
checkUnusedDeclAttributes - Check a list of attributes to see if it contains any decl attributes that...
static void handleGNUInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkArmNewAttrMutualExclusion(Sema &S, const ParsedAttr &AL, const FunctionProtoType *FPT, FunctionType::ArmStateValue CurrentState, StringRef StateName)
static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleBuiltinAliasAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleTransparentUnionAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isErrorParameter(Sema &S, QualType QT)
static void handleEnforceTCBAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void checkAttrArgsAreCapabilityObjs(Sema &S, Decl *D, const ParsedAttr &AL, SmallVectorImpl< Expr * > &Args, unsigned Sidx=0, bool ParamIdxOk=false)
Checks that all attribute arguments, starting from Sidx, resolve to a capability object.
static QualType getFunctionOrMethodParamType(const Decl *D, unsigned Idx)
static bool isLegalTypeForHLSLSV_DispatchThreadID(QualType T)
static void handleSwiftNewType(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleObjCIndependentClass(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleXReturnsXRetainedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleErrorAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkCodeSegName(Sema &S, SourceLocation LiteralLoc, StringRef CodeSegName)
static void handleAvailabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSwiftAsyncName(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleTryAcquireCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleRISCVInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSetTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleFormatArgAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Handle attribute((format_arg((idx)))) attribute based on http://gcc.gnu.org/onlinedocs/gcc/Function-A...
static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL, const Sema::ProcessDeclAttributeOptions &Options)
ProcessDeclAttribute - Apply the specific attribute to the specified decl if the attribute applies to...
static void handleTargetAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleXRayLogArgsAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleObjCOwnershipAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static const Sema::SemaDiagnosticBuilder & appendDiagnostics(const Sema::SemaDiagnosticBuilder &Bldr)
static void handlePassObjectSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static const ParmVarDecl * getFunctionOrMethodParam(const Decl *D, unsigned Idx)
static bool ArmCdeAliasValid(unsigned BuiltinID, StringRef AliasName)
static void handleAMDGPUMaxNumWorkGroupsAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNoMergeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleArmNewAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleObjCPreciseLifetimeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
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 void handleAnyX86InterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleObjCDirectMembersAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleManagedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSwiftAttrAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAVRInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSwiftAsyncAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleParamTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleUnsafeBufferUsage(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isValidSubjectOfNSReturnsRetainedAttribute(QualType QT)
static bool attrNonNullArgCheck(Sema &S, QualType T, const ParsedAttr &AL, SourceRange AttrParmRange, SourceRange TypeRange, bool isReturnValue=false)
static void handleAcquireCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
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 void handleCPUSpecificAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleObjCRuntimeName(Sema &S, Decl *D, const ParsedAttr &AL)
static void handlePackedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleIFuncAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkFunctionOrMethodParameterIndex(Sema &S, const Decl *D, const AttrInfo &AI, unsigned AttrArgNum, const Expr *IdxExpr, ParamIdx &Idx, bool CanIndexImplicitThis=false)
Check if IdxExpr is a valid parameter index for a function or instance method D.
static void handleAbiTagAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isFunctionOrMethod(const Decl *D)
isFunctionOrMethod - Return true if the given decl has function type (function or function-typed vari...
static void handleObjCMethodFamilyAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAttrWithMessage(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleWeakRefAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleExtVectorTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleX86ForceAlignArgPointerAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleCalledOnceAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Handle 'called_once' attribute.
static void handleLockReturnedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkFunctionConditionAttr(Sema &S, Decl *D, const ParsedAttr &AL, Expr *&Cond, StringRef &Msg)
static void handleAcquiredAfterAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleExternalSourceSymbolAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNonNullAttrParameter(Sema &S, ParmVarDecl *D, const ParsedAttr &AL)
static bool checkParamIsIntegerType(Sema &S, const Decl *D, const AttrInfo &AI, unsigned AttrArgNo)
Checks to be sure that the given parameter number is in bounds, and is an integral type.
static void handleObjCReturnsInnerPointerAttr(Sema &S, Decl *D, const ParsedAttr &Attrs)
static bool checkRecordTypeForCapability(Sema &S, QualType Ty)
static void handleArgumentWithTypeTagAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkIBOutletCommon(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkAcquireOrderAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, SmallVectorImpl< Expr * > &Args)
static void handleWebAssemblyImportModuleAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleLocksExcludedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleMSAllocatorAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static AttrTy * mergeEnforceTCBAttrImpl(Sema &S, Decl *D, const AttrTy &AL)
static bool isValidSubjectOfOSAttribute(QualType QT)
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 ArmMveAliasValid(unsigned BuiltinID, StringRef AliasName)
static void handleConstructorAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAllocSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleConsumableAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static const RecordType * getRecordType(QualType QT)
Checks that the passed in QualType either is of RecordType or points to RecordType.
static void handleObjCExternallyRetainedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNoSanitizeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleReturnTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isValidSubjectOfNSAttribute(QualType QT)
static void handleTargetClonesAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAllocAlignAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleM68kInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleIBOutlet(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleHLSLResourceBindingAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleObjCSuppresProtocolAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkAMDGPUFlatWorkGroupSizeArguments(Sema &S, Expr *MinExpr, Expr *MaxExpr, const AMDGPUFlatWorkGroupSizeAttr &Attr)
static void handleSwiftBridge(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleBPFPreserveAIRecord(Sema &S, RecordDecl *RD)
static bool isFunctionOrMethodOrBlock(const Decl *D)
Return true if the given decl has function type (function or function-typed variable) or an Objective...
static void handlePreferredTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isValidSubjectOfCFAttribute(QualType QT)
static void checkOMPAssumeAttr(Sema &S, SourceLocation Loc, StringRef AssumptionStr)
Check if AssumptionStr is a known assumption and warn if not.
static void handleDeviceAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handlePtGuardedByAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAlwaysInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAssertCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleVisibilityAttr(Sema &S, Decl *D, const ParsedAttr &AL, bool isTypeVisibility)
static void handleAnnotateAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static FormatAttrKind getFormatAttrKind(StringRef Format)
getFormatAttrKind - Map from format attribute names to supported format types.
static void handleNullableTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleUuidAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAcquireHandleAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isValidSwiftIndirectResultType(QualType Ty)
Pointers and references in the default address space.
static void handleWebAssemblyImportNameAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool tryMakeVariablePseudoStrong(Sema &S, VarDecl *VD, bool DiagnoseFailure)
static void handleMSConstexprAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void checkSwiftAsyncErrorBlock(Sema &S, Decl *D, const SwiftAsyncErrorAttr *ErrorAttr, const SwiftAsyncAttr *AsyncAttr)
static void handleCommonAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleTestTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkTryLockFunAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, SmallVectorImpl< Expr * > &Args)
static bool ArmBuiltinAliasValid(unsigned BuiltinID, StringRef AliasName, ArrayRef< IntrinToName > Map, const char *IntrinNames)
static void parseModeAttrArg(Sema &S, StringRef Str, unsigned &DestWidth, bool &IntegerMode, bool &ComplexMode, FloatModeKind &ExplicitType)
parseModeAttrArg - Parses attribute mode string and returns parsed type attribute.
static void handleSimpleAttribute(Sema &S, Decl *D, const AttributeCommonInfo &CI)
Applies the given attribute to the Decl without performing any additional semantic checking.
static void handleExcludeFromExplicitInstantiationAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleHLSLNumThreadsAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSharedTrylockFunctionAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleLaunchBoundsAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkAvailabilityAttr(Sema &S, SourceRange Range, IdentifierInfo *Platform, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted)
static void handleObjCBridgeMutableAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleDependencyAttr(Sema &S, Scope *Scope, Decl *D, const ParsedAttr &AL)
static void handleARMInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNoBuiltinAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleLifetimeCategoryAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNoUniqueAddressAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool validateAlignasAppliedType(Sema &S, Decl *D, const AlignedAttr &Attr, SourceLocation AttrLoc)
Perform checking of type validity.
static void handleNakedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleFunctionReturnThunksAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleDeprecatedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static SourceRange getFunctionOrMethodResultSourceRange(const Decl *D)
static Sema::RetainOwnershipKind parsedAttrToRetainOwnershipKind(const ParsedAttr &AL)
static unsigned getNumAttributeArgs(const ParsedAttr &AL)
static void handleGlobalAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSentinelAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleCodeModelAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleHLSLParamModifierAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleCallableWhenAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool hasBTFDeclTagAttr(Decl *D, StringRef Tag)
static void handleDelayedForbiddenType(Sema &S, DelayedDiagnostic &DD, Decl *D)
Handle a delayed forbidden-type diagnostic.
static void handleAssertSharedLockAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkLockFunAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, SmallVectorImpl< Expr * > &Args)
static bool RISCVAliasValid(unsigned BuiltinID, StringRef AliasName)
static void handleAssumeAlignedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSharedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleMSInheritanceAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkAMDGPUMaxNumWorkGroupsArguments(Sema &S, Expr *XExpr, Expr *YExpr, Expr *ZExpr, const AMDGPUMaxNumWorkGroupsAttr &Attr)
static void handleVecTypeHint(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleRestrictAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleMinVectorWidthAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleUnusedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static Expr * makeLaunchBoundsArgExpr(Sema &S, Expr *E, const CUDALaunchBoundsAttr &AL, const unsigned Idx)
static bool ArmSmeAliasValid(ASTContext &Context, unsigned BuiltinID, StringRef AliasName)
static void handleMipsInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleDeclspecThreadAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSYCLKernelAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAMDGPUNumSGPRAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool ArmSveAliasValid(ASTContext &Context, unsigned BuiltinID, StringRef AliasName)
static void handleInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleExclusiveTrylockFunctionAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleCallbackAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Handle attribute((callback(CalleeIdx, PayloadIdx0, ...))) attributes.
static void handleInitPriorityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Handle attribute((init_priority(priority))) attributes based on http://gcc.gnu.org/onlinedocs/gcc/C_0...
static void handlePtGuardedVarAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool hasFunctionProto(const Decl *D)
hasFunctionProto - Return true if the given decl has a argument information.
static bool checkRecordDeclForAttr(const RecordDecl *RD)
static void handleDestroyAttr(Sema &S, Decl *D, const ParsedAttr &A)
static void handleTypeTagForDatatypeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static unsigned getFunctionOrMethodNumParams(const Decl *D)
getFunctionOrMethodNumParams - Return number of function or method parameters.
static void handleRandomizeLayoutAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void markUsedForAliasOrIfunc(Sema &S, Decl *D, const ParsedAttr &AL, StringRef Str)
static bool isCapabilityExpr(Sema &S, const Expr *Ex)
static bool isValidOSObjectOutParameter(const Decl *D)
static bool isValidSwiftContextType(QualType Ty)
Pointer-like types in the default address space.
static void handleNoDebugAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSuppressAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSwiftName(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleObjCRequiresSuperAttr(Sema &S, Decl *D, const ParsedAttr &Attrs)
static void handleObjCDesignatedInitializer(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &Attrs)
static const AttrTy * findEnforceTCBAttrByName(Decl *D, StringRef Name)
static void handleWebAssemblyExportNameAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNoEscapeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAvailableOnlyInDefaultEvalMethod(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkAttrMutualExclusion(Sema &S, Decl *D, const ParsedAttr &AL)
Diagnose mutually exclusive attributes when present on a given declaration.
static bool MustDelayAttributeArguments(const ParsedAttr &AL)
static void handleNoRandomizeLayoutAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isInstanceMethod(const Decl *D)
static void handleTargetVersionAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static SourceRange getFunctionOrMethodParamRange(const Decl *D, unsigned Idx)
static void handleAVRSignalAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static QualType getFunctionOrMethodResultType(const Decl *D)
static void handleWarnUnusedResult(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleBlocksAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAssertExclusiveLockAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isIntOrBool(Expr *Exp)
Check if the passed-in expression is of type int or bool.
static void handleSimpleAttributeOrDiagnose(Sema &S, Decl *D, const AttributeCommonInfo &CI, bool PassesCheck, unsigned DiagID, DiagnosticArgs &&... ExtraArgs)
Add an attribute AttrType to declaration D, provided that PassesCheck is true.
static bool isSanitizerAttributeAllowedOnGlobals(StringRef Sanitizer)
static void handleObjCBridgeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleObjCBridgeRelatedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isValidSwiftErrorResultType(QualType Ty)
Pointers and references to pointers in the default address space.
static void handleCallConvAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkAMDGPUWavesPerEUArguments(Sema &S, Expr *MinExpr, Expr *MaxExpr, const AMDGPUWavesPerEUAttr &Attr)
static void handleMinSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool validateSwiftFunctionName(Sema &S, const ParsedAttr &AL, SourceLocation Loc, StringRef Name, unsigned &SwiftParamCount, bool &IsSingleParamInit)
static void handleOwnershipAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkTypedefTypeForCapability(QualType Ty)
static void handleAcquiredBeforeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleReleaseCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleMSP430InterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool typeHasCapability(Sema &S, QualType Ty)
static void handleAnalyzerNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleIBOutletCollection(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleObjCNSObject(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleObjCDirectAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNSErrorDomain(Sema &S, Decl *D, const ParsedAttr &Attr)
static bool threadSafetyCheckIsSmartPointer(Sema &S, const RecordType *RT)
static bool isFunctionLike(const Type &T)
static void handleOMPAssumeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleDiagnoseIfAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleCFGuardAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNonNullAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool threadSafetyCheckIsPointer(Sema &S, const Decl *D, const ParsedAttr &AL)
Check if passed in Decl is a pointer type.
static bool isForbiddenTypeAllowed(Sema &S, Decl *D, const DelayedDiagnostic &diag, UnavailableAttr::ImplicitReason &reason)
Is the given declaration allowed to use a forbidden type? If so, it'll still be annotated with an att...
static void handleInternalLinkageAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAMDGPUFlatWorkGroupSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleModeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
handleModeAttr - This attribute modifies the width of a decl with primitive type.
static void handleDestructorAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handlePreferredName(Sema &S, Decl *D, const ParsedAttr &AL)
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...
static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleVecReturnAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isGlobalVar(const Decl *D)
static void handleSwiftAsyncError(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleTLSModelAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAliasAttr(Sema &S, Decl *D, const ParsedAttr &AL)
This file declares semantic analysis for HLSL constructs.
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.
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.
SourceManager & getSourceManager()
TranslationUnitDecl * getTranslationUnitDecl() const
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
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
const LangOptions & getLangOpts() const
QualType getConstType(QualType T) const
Return the uniqued reference to the type for a const qualified type.
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,...
const TargetInfo * getAuxTargetInfo() const
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.
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type.
const TargetInfo & getTargetInfo() const
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.
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
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 * getScopeName() const
bool isGNUAttribute() const
bool isRegularKeywordAttribute() const
SourceLocation getLoc() const
const IdentifierInfo * getAttrName() 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.
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.
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.
CXXRecordDecl * getDefinition() const
bool hasDefinition() const
MSInheritanceModel calculateInheritanceModel() const
Calculate what the inheritance model would be for this class.
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.
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...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isFileContext() const
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
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
SourceLocation getLocation() const
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
DeclContext * getDeclContext()
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 Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
The name of a declaration.
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)
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
Expr * getTrailingRequiresClause()
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
TypeSourceInfo * getTypeSourceInfo() const
Information about one declarator, including the parsed type information and the identifier.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
const ParsedAttributes & getAttributes() const
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
const ParsedAttributesView & getDeclarationAttributes() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
This represents one expression.
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 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.
const ParmVarDecl * getParamDecl(unsigned i) const
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
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
ArrayRef< ParmVarDecl * > parameters() const
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
param_iterator param_begin()
bool isVariadic() const
Whether this function is variadic.
bool isConstexprSpecified() const
bool isExternC() const
Determines whether this function is a function with external, C linkage.
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)
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.
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
@ SME_PStateSMEnabledMask
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.
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.
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.
void * getAsOpaquePtr() const
static OpaquePtr getFromOpaquePtr(void *P)
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 AvailabilityChange & getAvailabilityDeprecated() const
unsigned getSemanticSpelling() const
If the parsed attribute has a semantic equivalent, and it would have a semantic Spelling enumeration ...
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.
IdentifierLoc * getArgAsIdent(unsigned Arg) const
bool hasParsedType() const
const AvailabilityChange & getAvailabilityIntroduced() const
void setInvalid(bool b=true) const
bool hasVariadicArg() const
const ParsedAttrInfo & getInfo() const
void handleAttrWithDelayedArgs(Sema &S, Decl *D) const
const Expr * getReplacementExpr() const
bool hasProcessingCache() const
SourceLocation getUnavailableLoc() const
unsigned getProcessingCache() const
bool acceptsExprPack() const
const Expr * getMessageExpr() const
const ParsedType & getMatchingCType() const
const ParsedType & getTypeArg() const
SourceLocation getStrictLoc() const
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this attribute.
bool isArgIdent(unsigned Arg) const
Expr * getArgAsExpr(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-...
AttributeCommonInfo::Kind getKind() const
void setProcessingCache(unsigned value) const
bool isParamExpr(size_t N) const
bool isArgExpr(unsigned Arg) const
bool getLayoutCompatible() const
ArgsUnion getArg(unsigned Arg) const
getArg - Return the specified argument.
SourceLocation getEllipsisLoc() const
bool checkAtMostNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has at most as many args as Num.
const AvailabilityChange & getAvailabilityObsoleted() 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
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...
A generic diagnostic builder for errors which may or may not be deferred.
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)
A class which encapsulates the logic for delaying diagnostics during parsing and other processing.
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
void popWithoutEmitting(DelayedDiagnosticsState state)
Leave a delayed-diagnostic state that was previously pushed.
Sema - This implements semantic analysis and AST building for C.
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)
bool ConstantFoldAttrArgs(const AttributeCommonInfo &CI, MutableArrayRef< Expr * > Args)
ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs (unless they are value dependent ...
BTFDeclTagAttr * mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL)
void LoadExternalWeakUndeclaredIdentifiers()
Load weak undeclared identifiers from the external source.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
EnforceTCBAttr * mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL)
bool checkTargetVersionAttr(SourceLocation LiteralLoc, Decl *D, StringRef &Str, bool &isDefault)
bool isValidPointerAttrType(QualType T, bool RefOkay=false)
Determine if type T is a valid subject for a nonnull and similar attributes.
TypeVisibilityAttr * mergeTypeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, TypeVisibilityAttr::VisibilityType Vis)
void AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, bool IsPackExpansion)
AddAlignedAttr - Adds an aligned attribute to a particular declaration.
void AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, Expr *OE)
AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular declaration.
bool checkSectionName(SourceLocation LiteralLoc, StringRef Str)
void AddPragmaAttributes(Scope *S, Decl *D)
Adds the attributes that have been specified using the '#pragma clang attribute push' directives to t...
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 ...
void addAMDGPUWavesPerEUAttr(Decl *D, const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
addAMDGPUWavePersEUAttr - Adds an amdgpu_waves_per_eu attribute to a particular declaration.
WebAssemblyImportNameAttr * mergeImportNameAttr(Decl *D, const WebAssemblyImportNameAttr &AL)
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...
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl, const ParsedAttributesView &AttrList)
AMDGPUFlatWorkGroupSizeAttr * CreateAMDGPUFlatWorkGroupSizeAttr(const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
Create an AMDGPUWavesPerEUAttr attribute.
DLLImportAttr * mergeDLLImportAttr(Decl *D, const AttributeCommonInfo &CI)
ExtVectorDeclsType ExtVectorDecls
ExtVectorDecls - This is a list all the extended vector types.
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=NoFold)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
void PopParsingDeclaration(ParsingDeclState state, Decl *decl)
ErrorAttr * mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI, StringRef NewUserDiagnostic)
void redelayDiagnostics(sema::DelayedDiagnosticPool &pool)
Given a set of delayed diagnostics, re-emit them as if they had been delayed in the current context i...
VisibilityAttr * mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, VisibilityAttr::VisibilityType Vis)
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
AMDGPUWavesPerEUAttr * CreateAMDGPUWavesPerEUAttr(const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
Create an AMDGPUWavesPerEUAttr attribute.
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
ASTContext & getASTContext() const
@ None
This is not a defaultable comparison operator.
bool CheckCallingConvAttr(const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD=nullptr, CUDAFunctionTarget CFT=CUDAFunctionTarget::InvalidTarget)
Check validaty of calling convention attribute attr.
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 ProcessPragmaWeak(Scope *S, Decl *D)
void AddXConsumedAttr(Decl *D, const AttributeCommonInfo &CI, RetainOwnershipKind K, bool IsTemplateInstantiation)
bool CheckAttrNoArgs(const ParsedAttr &CurrAttr)
bool UnifySection(StringRef SectionName, int SectionFlags, NamedDecl *TheDecl)
FPOptions & getCurFPFeatures()
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
@ UPPC_Expression
An arbitrary expression.
const LangOptions & getLangOpts() const
void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Name, bool InInstantiation=false)
AddModeAttr - Adds a mode attribute to a particular declaration.
bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type)
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
MinSizeAttr * mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI)
const LangOptions & LangOpts
static const uint64_t MaximumAlignment
AlwaysInlineAttr * mergeAlwaysInlineAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Ident)
void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AttrList, const ProcessDeclAttributeOptions &Options=ProcessDeclAttributeOptions())
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
WebAssemblyImportModuleAttr * mergeImportModuleAttr(Decl *D, const WebAssemblyImportModuleAttr &AL)
NamedDecl * getCurFunctionOrMethodDecl() const
getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method or C function we're in,...
void AddAllocAlignAttr(Decl *D, const AttributeCommonInfo &CI, Expr *ParamExpr)
AddAllocAlignAttr - Adds an alloc_align attribute to a particular declaration.
bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value)
Checks a regparm attribute, returning true if it is ill-formed and otherwise setting numParams to the...
void AddAnnotationAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Annot, MutableArrayRef< Expr * > Args)
AddAnnotationAttr - Adds an annotation Annot with Args arguments to D.
void ProcessDeclAttributeDelayed(Decl *D, const ParsedAttributesView &AttrList)
MSInheritanceAttr * mergeMSInheritanceAttr(Decl *D, const AttributeCommonInfo &CI, bool BestCase, MSInheritanceModel Model)
InternalLinkageAttr * mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
@ Compatible
Compatible - the types are compatible according to the standard.
NamedDecl * DeclClonePragmaWeak(NamedDecl *ND, const IdentifierInfo *II, SourceLocation Loc)
DeclClonePragmaWeak - clone existing decl (maybe definition), #pragma weak needs a non-definition dec...
DLLExportAttr * mergeDLLExportAttr(Decl *D, const AttributeCommonInfo &CI)
AMDGPUMaxNumWorkGroupsAttr * CreateAMDGPUMaxNumWorkGroupsAttr(const AttributeCommonInfo &CI, Expr *XExpr, Expr *YExpr, Expr *ZExpr)
Create an AMDGPUMaxNumWorkGroupsAttr attribute.
CodeSegAttr * mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Name)
SectionAttr * mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Name)
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
SourceManager & getSourceManager() const
bool isCFError(RecordDecl *D)
bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str)
llvm::Error isValidSectionSpecifier(StringRef Str)
Used to implement to perform semantic checking on attribute((section("foo"))) specifiers.
void AddLaunchBoundsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks)
AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular declaration.
OptimizeNoneAttr * mergeOptimizeNoneAttr(Decl *D, const AttributeCommonInfo &CI)
void checkUnusedDeclAttributes(Declarator &D)
checkUnusedDeclAttributes - Given a declarator which is not being used to build a declaration,...
bool CheckAttrTarget(const ParsedAttr &CurrAttr)
EnforceTCBLeafAttr * mergeEnforceTCBLeafAttr(Decl *D, const EnforceTCBLeafAttr &AL)
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.
void NoteAllOverloadCandidates(Expr *E, QualType DestType=QualType(), bool TakingAddress=false)
FormatAttr * mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Format, int FormatIdx, int FirstArg)
@ 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.
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated",...
@ AMK_None
Don't merge availability attributes at all.
@ AMK_Override
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
@ AMK_ProtocolImplementation
Merge availability attributes for an implementation of a protocol requirement.
@ AMK_OptionalProtocolImplementation
Merge availability attributes for an implementation of an optional protocol requirement.
@ AMK_Redeclaration
Merge availability attributes for a redeclaration, which requires an exact match.
SmallVector< Decl *, 2 > WeakTopLevelDecl
WeakTopLevelDecl - Translation-unit scoped declarations generated by #pragma weak during processing o...
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...
IdentifierInfo * getNSErrorIdent()
Retrieve the identifier "NSError".
UuidAttr * mergeUuidAttr(Decl *D, const AttributeCommonInfo &CI, StringRef UuidAsWritten, MSGuidDecl *GuidDecl)
void addAMDGPUFlatWorkGroupSizeAttr(Decl *D, const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
addAMDGPUFlatWorkGroupSizeAttr - Adds an amdgpu_flat_work_group_size attribute to a particular declar...
OpenCLOptions & getOpenCLOptions()
void AddParameterABIAttr(Decl *D, const AttributeCommonInfo &CI, ParameterABI ABI)
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
bool checkTargetClonesAttrString(SourceLocation LiteralLoc, StringRef Str, const StringLiteral *Literal, Decl *D, bool &HasDefault, bool &HasCommas, bool &HasNotDefault, SmallVectorImpl< SmallString< 64 > > &StringsBuffer)
void handleDelayedAvailabilityCheck(sema::DelayedDiagnostic &DD, Decl *Ctx)
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in it, apply them to D.
void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W)
DeclApplyPragmaWeak - A declaration (maybe definition) needs #pragma weak applied to it,...
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...
llvm::MapVector< IdentifierInfo *, llvm::SetVector< WeakInfo, llvm::SmallVector< WeakInfo, 1u >, llvm::SmallDenseSet< WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly > > > WeakUndeclaredIdentifiers
WeakUndeclaredIdentifiers - Identifiers contained in #pragma weak before declared.
void ProcessAPINotes(Decl *D)
Map any API notes provided for this declaration to attributes on the declaration.
void CheckAlignasUnderalignment(Decl *D)
void HandleDelayedAccessCheck(sema::DelayedDiagnostic &DD, Decl *Ctx)
DarwinSDKInfo * getDarwinSDKInfoForAvailabilityChecking(SourceLocation Loc, StringRef Platform)
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing,...
SwiftNameAttr * mergeSwiftNameAttr(Decl *D, const SwiftNameAttr &SNA, StringRef Name)
CUDALaunchBoundsAttr * CreateLaunchBoundsAttr(const AttributeCommonInfo &CI, Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks)
Create an CUDALaunchBoundsAttr attribute.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
void AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E)
AddAlignValueAttr - Adds an align_value attribute to a particular declaration.
QualType BuildCountAttributedArrayType(QualType WrappedTy, Expr *CountExpr)
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, bool BestCase, MSInheritanceModel SemanticSpelling)
bool checkStringLiteralArgumentAttr(const AttributeCommonInfo &CI, const Expr *E, StringRef &Str, SourceLocation *ArgLocation=nullptr)
Check if the argument E is a ASCII string literal.
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
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.
TargetOptions & getTargetOpts() const
Retrieve the target options.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
uint64_t getPointerWidth(LangAS AddrSpace) const
Return the width of pointers on this target, for the specified address space.
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.
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.
const llvm::VersionTuple & getSDKVersion() const
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.
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 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)
void setARCPseudoStrong(bool PS)
@ TLS_None
Not a TLS variable.
Represents a GCC generic vector type.
Captures information about a #pragma weak directive.
const IdentifierInfo * getAlias() const
SourceLocation getLocation() const
A collection of diagnostics which were delayed.
const DelayedDiagnosticPool * getParent() const
void steal(DelayedDiagnosticPool &pool)
Steal the diagnostics from the given pool.
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.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
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
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)
@ Internal
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
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_ArgumentIdentifier
@ SD_Automatic
Automatic storage duration (most local variables).
@ Property
The type of a property.
@ Result
The result type of a method or function.
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.
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.
@ Other
Other implicit parameter.
@ Implicit
An implicit conversion.
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.
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