43#include "llvm/ADT/STLExtras.h"
44#include "llvm/ADT/StringExtras.h"
45#include "llvm/IR/Assumptions.h"
46#include "llvm/MC/MCSectionMachO.h"
47#include "llvm/Support/Error.h"
48#include "llvm/Support/MathExtras.h"
49#include "llvm/Support/raw_ostream.h"
84 return isa<DeclaratorDecl>(D) || isa<BlockDecl>(D) || isa<TypedefNameDecl>(D) ||
85 isa<ObjCPropertyDecl>(D);
93 return isa<FunctionProtoType>(FnTy);
94 return isa<ObjCMethodDecl>(D) || isa<BlockDecl>(D);
102 return cast<FunctionProtoType>(FnTy)->getNumParams();
103 if (
const auto *BD = dyn_cast<BlockDecl>(D))
104 return BD->getNumParams();
105 return cast<ObjCMethodDecl>(D)->param_size();
110 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
111 return FD->getParamDecl(Idx);
112 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
113 return MD->getParamDecl(Idx);
114 if (
const auto *BD = dyn_cast<BlockDecl>(D))
115 return BD->getParamDecl(Idx);
121 return cast<FunctionProtoType>(FnTy)->getParamType(Idx);
122 if (
const auto *BD = dyn_cast<BlockDecl>(D))
123 return BD->getParamDecl(Idx)->getType();
125 return cast<ObjCMethodDecl>(D)->parameters()[Idx]->getType();
130 return PVD->getSourceRange();
136 return FnTy->getReturnType();
137 return cast<ObjCMethodDecl>(D)->getReturnType();
141 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
142 return FD->getReturnTypeSourceRange();
143 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
144 return MD->getReturnTypeSourceRange();
150 return cast<FunctionProtoType>(FnTy)->isVariadic();
151 if (
const auto *BD = dyn_cast<BlockDecl>(D))
152 return BD->isVariadic();
153 return cast<ObjCMethodDecl>(D)->isVariadic();
157 if (
const auto *MethodDecl = dyn_cast<CXXMethodDecl>(D))
158 return MethodDecl->isInstance();
163 bool AllowNSAttributedString =
false) {
174 if (AllowNSAttributedString &&
175 ClsName == &Ctx.
Idents.
get(
"NSAttributedString"))
178 return ClsName == &Ctx.
Idents.
get(
"NSString") ||
179 ClsName == &Ctx.
Idents.
get(
"NSMutableString");
205template <
typename AttrInfo>
206static std::enable_if_t<std::is_base_of_v<Attr, AttrInfo>,
SourceLocation>
208 return AL.getLocation();
217template <
typename AttrInfo>
219 uint32_t &Val,
unsigned Idx =
UINT_MAX,
220 bool StrictlyUnsigned =
false) {
221 std::optional<llvm::APSInt> I = llvm::APSInt(32);
234 if (!I->isIntN(32)) {
236 <<
toString(*I, 10,
false) << 32 << 1;
240 if (StrictlyUnsigned && I->isSigned() && I->isNegative()) {
241 S.
Diag(
getAttrLoc(AI), diag::err_attribute_requires_positive_integer)
246 Val = (uint32_t)I->getZExtValue();
253template <
typename AttrInfo>
255 int &Val,
unsigned Idx =
UINT_MAX) {
260 if (UVal > (uint32_t)std::numeric_limits<int>::max()) {
264 <<
toString(I, 10,
false) << 32 << 0;
274template <
typename AttrTy>
276 if (
const auto *A = D->
getAttr<AttrTy>()) {
277 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
280 S.
Diag(A->getLocation(), diag::note_conflicting_attribute);
286template <
typename AttrTy>
288 if (
const auto *A = D->
getAttr<AttrTy>()) {
292 S.
Diag(A->getLocation(), diag::note_conflicting_attribute);
302template <
typename AttrInfo>
304 Sema &S,
const Decl *D,
const AttrInfo &AI,
unsigned AttrArgNum,
305 const Expr *IdxExpr,
ParamIdx &Idx,
bool CanIndexImplicitThis =
false) {
316 std::optional<llvm::APSInt> IdxInt;
325 unsigned IdxSource = IdxInt->getLimitedValue(
UINT_MAX);
326 if (IdxSource < 1 || (!IV && IdxSource > NumParams)) {
327 S.
Diag(
getAttrLoc(AI), diag::err_attribute_argument_out_of_bounds)
331 if (HasImplicitThisParam && !CanIndexImplicitThis) {
332 if (IdxSource == 1) {
333 S.
Diag(
getAttrLoc(AI), diag::err_attribute_invalid_implicit_this_argument)
347 const Expr *E, StringRef &Str,
353 if (!Literal || (!Literal->isUnevaluated() && !Literal->isOrdinary())) {
359 Str = Literal->getString();
373 Diag(Loc->
Loc, diag::err_attribute_argument_type)
379 *ArgLocation = Loc->
Loc;
389 if (!Literal || (!Literal->isUnevaluated() && !Literal->isOrdinary())) {
394 Str = Literal->getString();
400template <
typename AttrType>
406template <
typename... DiagnosticArgs>
412template <
typename T,
typename... DiagnosticArgs>
415 DiagnosticArgs &&... ExtraArgs) {
417 std::forward<DiagnosticArgs>(ExtraArgs)...);
424template <
typename AttrType,
typename... DiagnosticArgs>
427 bool PassesCheck,
unsigned DiagID,
428 DiagnosticArgs &&... ExtraArgs) {
434 handleSimpleAttribute<AttrType>(S, D, CI);
455 bool foundStarOperator = IsOverloadedOperatorPresent(
Record, OO_Star);
456 bool foundArrowOperator = IsOverloadedOperatorPresent(
Record, OO_Arrow);
457 if (foundStarOperator && foundArrowOperator)
464 for (
const auto &BaseSpecifier : CXXRecord->bases()) {
465 if (!foundStarOperator)
466 foundStarOperator = IsOverloadedOperatorPresent(
467 BaseSpecifier.getType()->getAsRecordDecl(), OO_Star);
468 if (!foundArrowOperator)
469 foundArrowOperator = IsOverloadedOperatorPresent(
470 BaseSpecifier.getType()->getAsRecordDecl(), OO_Arrow);
473 if (foundStarOperator && foundArrowOperator)
484 const auto *VD = cast<ValueDecl>(D);
493 if (RT->isIncompleteType())
500 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_decl_not_pointer) << AL << QT;
517template <
typename AttrType>
524 if (
const auto *CRD = dyn_cast<CXXRecordDecl>(RD)) {
526 return !Base->hasAttr<AttrType>();
548 return checkRecordDeclForAttr<CapabilityAttr>(RT->
getDecl());
560 return TN->
hasAttr<CapabilityAttr>();
579 if (
const auto *E = dyn_cast<CastExpr>(Ex))
581 else if (
const auto *E = dyn_cast<ParenExpr>(Ex))
583 else if (
const auto *E = dyn_cast<UnaryOperator>(Ex)) {
584 if (E->getOpcode() == UO_LNot || E->getOpcode() == UO_AddrOf ||
585 E->getOpcode() == UO_Deref)
588 }
else if (
const auto *E = dyn_cast<BinaryOperator>(Ex)) {
589 if (E->getOpcode() == BO_LAnd || E->getOpcode() == BO_LOr)
607 bool ParamIdxOk =
false) {
612 const auto *MD = dyn_cast<const CXXMethodDecl>(D);
613 if (MD && !MD->isStatic()) {
616 if (!checkRecordDeclForAttr<CapabilityAttr>(RD) &&
617 !checkRecordDeclForAttr<ScopedLockableAttr>(RD))
619 diag::warn_thread_attribute_not_on_capability_member)
620 << AL << MD->getParent();
622 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_not_on_non_static_member)
627 for (
unsigned Idx = Sidx; Idx < AL.
getNumArgs(); ++Idx) {
632 Args.push_back(ArgExp);
636 if (
const auto *StrLit = dyn_cast<StringLiteral>(ArgExp)) {
637 if (StrLit->getLength() == 0 ||
638 (StrLit->isOrdinary() && StrLit->getString() == StringRef(
"*"))) {
641 Args.push_back(ArgExp);
647 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_ignored) << AL;
648 Args.push_back(ArgExp);
656 if (
const auto *UOp = dyn_cast<UnaryOperator>(ArgExp))
657 if (UOp->getOpcode() == UO_AddrOf)
658 if (
const auto *DRE = dyn_cast<DeclRefExpr>(UOp->getSubExpr()))
659 if (DRE->getDecl()->isCXXInstanceMember())
660 ArgTy = DRE->getDecl()->getType();
666 if(!RT && ParamIdxOk) {
667 const auto *FD = dyn_cast<FunctionDecl>(D);
668 const auto *IL = dyn_cast<IntegerLiteral>(ArgExp);
670 unsigned int NumParams = FD->getNumParams();
671 llvm::APInt ArgValue = IL->getValue();
672 uint64_t ParamIdxFromOne = ArgValue.getZExtValue();
673 uint64_t ParamIdxFromZero = ParamIdxFromOne - 1;
674 if (!ArgValue.isStrictlyPositive() || ParamIdxFromOne > NumParams) {
676 diag::err_attribute_argument_out_of_bounds_extra_info)
677 << AL << Idx + 1 << NumParams;
680 ArgTy = FD->getParamDecl(ParamIdxFromZero)->getType();
689 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_argument_not_lockable)
692 Args.push_back(ArgExp);
712 unsigned Size = Args.size();
746 QualType QT = cast<ValueDecl>(D)->getType();
748 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_decl_not_lockable) << AL;
765 Expr **StartArg = &Args[0];
767 AcquiredAfterAttr(S.
Context, AL, StartArg, Args.size()));
775 Expr **StartArg = &Args[0];
777 AcquiredBeforeAttr(S.
Context, AL, StartArg, Args.size()));
794 unsigned Size = Args.size();
795 Expr **StartArg = Size == 0 ? nullptr : &Args[0];
797 AssertSharedLockAttr(S.
Context, AL, StartArg, Size));
806 unsigned Size = Args.size();
807 Expr **StartArg = Size == 0 ? nullptr : &Args[0];
809 AssertExclusiveLockAttr(S.
Context, AL, StartArg, Size));
817template <
typename AttrInfo>
819 unsigned AttrArgNo) {
820 assert(AI.isArgExpr(AttrArgNo) &&
"Expected expression argument");
821 Expr *AttrArg = AI.getArgAsExpr(AttrArgNo);
830 S.
Diag(SrcLoc, diag::err_attribute_integers_only)
845 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only) << AL;
856 ParamIdx SizeArgNo(SizeArgNoVal, D);
871 AllocSizeAttr(S.
Context, AL, SizeArgNo, NumberArgNo));
880 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
915 unsigned Size = Args.size();
929 unsigned Size = Args.size();
932 Expr **StartArg = &Args[0];
935 LocksExcludedAttr(S.
Context, AL, StartArg, Size));
939 Expr *&Cond, StringRef &Msg) {
945 Cond = Converted.
get();
952 Msg =
"<no message provided>";
958 S.
Diag(AL.
getLoc(), diag::err_attr_cond_never_constant_expr) << AL;
960 S.
Diag(PDiag.first, PDiag.second);
967 S.
Diag(AL.
getLoc(), diag::ext_clang_enable_if);
976 StringRef NewUserDiagnostic;
986class ArgumentDependenceChecker
997 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD))
1000 ClassType =
nullptr;
1005 bool referencesArgs(
Expr *E) {
1013 "`this` doesn't refer to the enclosing class?");
1019 if (
const auto *PVD = dyn_cast<ParmVarDecl>(DRE->
getDecl()))
1020 if (Parms.count(PVD)) {
1031 const auto *DeclFD = cast<FunctionDecl>(D);
1033 if (
const auto *MethodDecl = dyn_cast<CXXMethodDecl>(DeclFD))
1034 if (!MethodDecl->isStatic()) {
1035 S.
Diag(AL.
getLoc(), diag::err_attribute_no_member_function) << AL;
1047 S.
Diag(Loc, diag::err_attribute_argument_n_type) << AL << Index << T;
1053 auto *F = dyn_cast_if_present<DeclRefExpr>(AL.
getArgAsExpr(0));
1056 return dyn_cast_if_present<FunctionDecl>(F->getFoundDecl());
1065 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments_for)
1072 for (
unsigned I = 1; I < AL.
getNumArgs(); ++I) {
1084 if (Index > DeclFD->getNumParams()) {
1085 S.
Diag(AL.
getLoc(), diag::err_attribute_bounds_for_function)
1086 << AL << Index << DeclFD << DeclFD->getNumParams();
1091 QualType T2 = DeclFD->getParamDecl(Index - 1)->getType();
1096 << AL << Index << DeclFD << T2 << I << AttrFD << T1;
1100 Indices.push_back(Index - 1);
1104 S.
Context, AL, AttrFD, Indices.data(), Indices.size()));
1108 S.
Diag(AL.
getLoc(), diag::ext_clang_diagnose_if);
1115 StringRef DiagTypeStr;
1119 DiagnoseIfAttr::DiagnosticType DiagType;
1120 if (!DiagnoseIfAttr::ConvertStrToDiagnosticType(DiagTypeStr, DiagType)) {
1122 diag::err_diagnose_if_invalid_diagnostic_type);
1126 bool ArgDependent =
false;
1127 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
1128 ArgDependent = ArgumentDependenceChecker(FD).referencesArgs(Cond);
1130 S.
Context, AL, Cond, Msg, DiagType, ArgDependent, cast<NamedDecl>(D)));
1134 static constexpr const StringRef kWildcard =
"*";
1137 bool HasWildcard =
false;
1139 const auto AddBuiltinName = [&Names, &HasWildcard](StringRef Name) {
1140 if (Name == kWildcard)
1142 Names.push_back(Name);
1146 if (
const auto *NBA = D->
getAttr<NoBuiltinAttr>())
1147 for (StringRef BuiltinName : NBA->builtinNames())
1148 AddBuiltinName(BuiltinName);
1152 AddBuiltinName(kWildcard);
1154 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
1155 StringRef BuiltinName;
1161 AddBuiltinName(BuiltinName);
1163 S.
Diag(LiteralLoc, diag::warn_attribute_no_builtin_invalid_builtin_name)
1164 << BuiltinName << AL;
1169 Names.erase(std::unique(Names.begin(), Names.end()), Names.end());
1172 if (HasWildcard && Names.size() > 1)
1174 diag::err_attribute_no_builtin_wildcard_or_builtin_name)
1177 if (D->
hasAttr<NoBuiltinAttr>())
1180 NoBuiltinAttr(S.
Context, AL, Names.data(), Names.size()));
1184 if (D->
hasAttr<PassObjectSizeAttr>()) {
1185 S.
Diag(D->
getBeginLoc(), diag::err_attribute_only_once_per_parameter) << AL;
1207 if (!cast<ParmVarDecl>(D)->getType()->isPointerType()) {
1208 S.
Diag(D->
getBeginLoc(), diag::err_attribute_pointers_only) << AL << 1;
1216 ConsumableAttr::ConsumedState DefaultState;
1220 if (!ConsumableAttr::ConvertStrToConsumedState(IL->
Ident->
getName(),
1222 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported) << AL
1227 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1240 if (!RD->hasAttr<ConsumableAttr>()) {
1241 S.
Diag(AL.
getLoc(), diag::warn_attr_on_unconsumable_class) << RD;
1258 for (
unsigned ArgIndex = 0; ArgIndex < AL.
getNumArgs(); ++ArgIndex) {
1259 CallableWhenAttr::ConsumedState CallableState;
1261 StringRef StateString;
1272 if (!CallableWhenAttr::ConvertStrToConsumedState(StateString,
1274 S.
Diag(Loc, diag::warn_attribute_type_not_supported) << AL << StateString;
1278 States.push_back(CallableState);
1282 CallableWhenAttr(S.
Context, AL, States.data(), States.size()));
1286 ParamTypestateAttr::ConsumedState ParamState;
1292 if (!ParamTypestateAttr::ConvertStrToConsumedState(StateString,
1294 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported)
1295 << AL << StateString;
1299 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1320 ReturnTypestateAttr::ConsumedState ReturnState;
1324 if (!ReturnTypestateAttr::ConvertStrToConsumedState(IL->
Ident->
getName(),
1326 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported) << AL
1331 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1368 SetTypestateAttr::ConsumedState NewState;
1372 if (!SetTypestateAttr::ConvertStrToConsumedState(Param, NewState)) {
1373 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported) << AL
1378 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1390 TestTypestateAttr::ConsumedState TestState;
1394 if (!TestTypestateAttr::ConvertStrToConsumedState(Param, TestState)) {
1395 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported) << AL
1400 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1414 if (
auto *TD = dyn_cast<TagDecl>(D))
1416 else if (
auto *FD = dyn_cast<FieldDecl>(D)) {
1423 if (BitfieldByteAligned)
1425 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored_for_field_of_type)
1431 if (BitfieldByteAligned)
1432 S.
Diag(AL.
getLoc(), diag::warn_attribute_packed_for_bitfield);
1438 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored) << AL;
1442 auto *RD = cast<CXXRecordDecl>(D);
1444 assert(CTD &&
"attribute does not appertain to this declaration");
1455 if (
const auto *CTSD = dyn_cast_if_present<ClassTemplateSpecializationDecl>(
1457 Template = CTSD->getSpecializedTemplate();
1459 while (TST && TST->isTypeAlias())
1462 Template = TST->getTemplateName().getAsTemplateDecl();
1471 S.
Diag(AL.
getLoc(), diag::err_attribute_preferred_name_arg_invalid)
1474 S.
Diag(TT->getDecl()->getLocation(), diag::note_entity_declared_at)
1482 if (
const auto *VD = dyn_cast<ObjCIvarDecl>(D)) {
1484 S.
Diag(AL.
getLoc(), diag::warn_iboutlet_object_type)
1485 << AL << VD->getType() << 0;
1489 else if (
const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
1491 S.
Diag(AL.
getLoc(), diag::warn_iboutlet_object_type)
1492 << AL << PD->getType() << 1;
1497 S.
Diag(AL.
getLoc(), diag::warn_attribute_iboutlet) << AL;
1515 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
1530 S.
Diag(AL.
getLoc(), diag::err_iboutletcollection_type) <<
"NSObject";
1546 QT->
isBuiltinType() ? diag::err_iboutletcollection_builtintype
1547 : diag::err_iboutletcollection_type) << QT;
1565 if (UT && UT->getDecl()->hasAttr<TransparentUnionAttr>()) {
1567 for (
const auto *I : UD->
fields()) {
1581 bool isReturnValue =
false) {
1584 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only)
1585 << AL << AttrParmRange << TypeRange;
1587 S.
Diag(AL.
getLoc(), diag::warn_attribute_pointers_only)
1588 << AL << AttrParmRange << TypeRange << 0;
1596 for (
unsigned I = 0; I < AL.
getNumArgs(); ++I) {
1610 NonNullArgs.push_back(Idx);
1621 I != E && !AnyPointers; ++I) {
1628 S.
Diag(AL.
getLoc(), diag::warn_attribute_nonnull_no_pointers);
1631 ParamIdx *Start = NonNullArgs.data();
1632 unsigned Size = NonNullArgs.size();
1633 llvm::array_pod_sort(Start, Start + Size);
1643 S.
Diag(AL.
getLoc(), diag::warn_attribute_nonnull_parm_no_args)
1672 QualType T = cast<ParmVarDecl>(D)->getType();
1674 S.
Diag(AL.
getLoc(), diag::warn_attribute_pointers_only)
1697 AssumeAlignedAttr TmpAttr(
Context, CI, E, OE);
1701 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
1702 << &TmpAttr << TmpAttr.getRange() << SR;
1707 std::optional<llvm::APSInt> I = llvm::APSInt(64);
1710 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1714 Diag(AttrLoc, diag::err_attribute_argument_type)
1720 if (!I->isPowerOf2()) {
1721 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
1727 Diag(CI.
getLoc(), diag::warn_assume_aligned_too_great)
1732 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1750 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
1756 const auto *FuncDecl = cast<FunctionDecl>(D);
1766 << FuncDecl->getParamDecl(Idx.
getASTIndex())->getSourceRange();
1775 StringRef AssumptionStr) {
1776 if (llvm::KnownAssumptionStrings.count(AssumptionStr))
1779 unsigned BestEditDistance = 3;
1780 StringRef Suggestion;
1781 for (
const auto &KnownAssumptionIt : llvm::KnownAssumptionStrings) {
1782 unsigned EditDistance =
1783 AssumptionStr.edit_distance(KnownAssumptionIt.getKey());
1784 if (EditDistance < BestEditDistance) {
1785 Suggestion = KnownAssumptionIt.getKey();
1786 BestEditDistance = EditDistance;
1790 if (!Suggestion.empty())
1791 S.
Diag(Loc, diag::warn_omp_assume_attribute_string_unknown_suggested)
1792 << AssumptionStr << Suggestion;
1794 S.
Diag(Loc, diag::warn_omp_assume_attribute_string_unknown)
1813 if (AttrName.size() > 4 && AttrName.starts_with(
"__") &&
1814 AttrName.ends_with(
"__")) {
1815 AttrName = AttrName.drop_front(2).drop_back(2);
1831 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
1837 OwnershipAttr::OwnershipKind K =
1838 OwnershipAttr(S.
Context, AL,
nullptr,
nullptr, 0).getOwnKind();
1842 case OwnershipAttr::Takes:
1843 case OwnershipAttr::Holds:
1845 S.
Diag(AL.
getLoc(), diag::err_attribute_too_few_arguments) << AL << 2;
1849 case OwnershipAttr::Returns:
1851 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 1;
1859 StringRef ModuleName =
Module->getName();
1865 for (
unsigned i = 1; i < AL.
getNumArgs(); ++i) {
1875 case OwnershipAttr::Takes:
1876 case OwnershipAttr::Holds:
1880 case OwnershipAttr::Returns:
1886 S.
Diag(AL.
getLoc(), diag::err_ownership_type) << AL << Err
1895 if (I->getOwnKind() != K && llvm::is_contained(I->args(), Idx)) {
1896 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
1899 I->isRegularKeywordAttribute());
1901 }
else if (K == OwnershipAttr::Returns &&
1902 I->getOwnKind() == OwnershipAttr::Returns) {
1905 if (!llvm::is_contained(I->args(), Idx)) {
1906 S.
Diag(I->getLocation(), diag::err_ownership_returns_index_mismatch)
1907 << I->args_begin()->getSourceIndex();
1909 S.
Diag(AL.
getLoc(), diag::note_ownership_returns_index_mismatch)
1915 OwnershipArgs.push_back(Idx);
1918 ParamIdx *Start = OwnershipArgs.data();
1919 unsigned Size = OwnershipArgs.size();
1920 llvm::array_pod_sort(Start, Start + Size);
1928 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
1944 S.
Diag(AL.
getLoc(), diag::err_attribute_weakref_not_global_context)
1945 << cast<NamedDecl>(D);
1989 const auto *FD = cast<FunctionDecl>(D);
1991 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << FD << 1;
2004 S.
Diag(AL.
getLoc(), diag::err_alias_not_supported_on_darwin);
2012 S.
Diag(AL.
getLoc(), diag::err_alias_not_supported_on_nvptx);
2016 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
2018 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << FD << 0;
2022 const auto *VD = cast<VarDecl>(D);
2023 if (VD->isThisDeclarationADefinition() && VD->isExternallyVisible()) {
2024 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << VD << 0;
2051 if (Model !=
"global-dynamic" && Model !=
"local-dynamic"
2052 && Model !=
"initial-exec" && Model !=
"local-exec") {
2053 S.
Diag(LiteralLoc, diag::err_attr_tlsmodel_arg);
2067 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only)
2075 if (checkAttrMutualExclusion<CPUSpecificAttr>(S, D, AL))
2078 if (
const auto *
Other = D->
getAttr<CPUDispatchAttr>()) {
2079 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
2080 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
2083 }
else if (AL.
getParsedKind() == ParsedAttr::AT_CPUSpecific) {
2084 if (checkAttrMutualExclusion<CPUDispatchAttr>(S, D, AL))
2087 if (
const auto *
Other = D->
getAttr<CPUSpecificAttr>()) {
2088 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
2089 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
2096 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
2097 if (MD->getParent()->isLambda()) {
2098 S.
Diag(AL.
getLoc(), diag::err_attribute_dll_lambda) << AL;
2109 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
2118 S.
Diag(CPUArg->
Loc, diag::err_invalid_cpu_specific_dispatch_value)
2119 << CPUName << (AL.
getKind() == ParsedAttr::AT_CPUDispatch);
2125 return Target.CPUSpecificManglingCharacter(CPUName) ==
2128 S.
Diag(AL.
getLoc(), diag::warn_multiversion_duplicate_entries);
2131 CPUs.push_back(CPUArg->
Ident);
2135 if (AL.
getKind() == ParsedAttr::AT_CPUSpecific)
2137 CPUSpecificAttr(S.
Context, AL, CPUs.data(), CPUs.size()));
2140 CPUDispatchAttr(S.
Context, AL, CPUs.data(), CPUs.size()));
2145 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
2155 S.
Diag(AL.
getLoc(), diag::err_attribute_not_clinkage) << AL;
2159 const auto *FD = cast<FunctionDecl>(D);
2161 S.
Diag(AL.
getLoc(), diag::warn_attribute_cmse_entry_static);
2171 const auto &Arch = Triple.getArch();
2172 if (Arch != llvm::Triple::x86 &&
2173 (Arch != llvm::Triple::arm && Arch != llvm::Triple::thumb)) {
2174 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_on_arch)
2175 << AL << Triple.getArchName();
2181 if (S.
getLangOpts().MSVCCompat && isa<CXXMethodDecl>(D)) {
2182 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_decl_type_str)
2194 if (!isa<ObjCMethodDecl>(D)) {
2195 S.
Diag(Attrs.
getLoc(), diag::warn_attribute_wrong_decl_type)
2221 S.
Diag(Attrs.
getLoc(), diag::warn_nocf_check_attribute_ignored);
2223 handleSimpleAttribute<AnyX86NoCfCheckAttr>(S, D, Attrs);
2239 ? diag::err_keyword_not_supported_on_target
2240 : diag::warn_unknown_attribute_ignored)
2258 ? diag::err_attribute_wrong_decl_type
2259 : diag::warn_attribute_wrong_decl_type)
2295 if (VecReturnAttr *A = D->
getAttr<VecReturnAttr>()) {
2296 S.
Diag(AL.
getLoc(), diag::err_repeat_attribute) << A;
2300 const auto *R = cast<RecordDecl>(D);
2303 if (!isa<CXXRecordDecl>(R)) {
2304 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
2308 if (!cast<CXXRecordDecl>(R)->isPOD()) {
2309 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_pod_record);
2313 for (
const auto *I : R->fields()) {
2314 if ((count == 1) || !I->getType()->isVectorType()) {
2315 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
2326 if (isa<ParmVarDecl>(D)) {
2331 diag::err_carries_dependency_param_not_function_decl);
2345 S.
Diag(AL.
getLoc(), diag::ext_cxx17_attr) << AL;
2351 uint32_t priority = ConstructorAttr::DefaultPriority;
2353 S.
Diag(AL.
getLoc(), diag::err_hlsl_init_priority_unsupported);
2364 uint32_t priority = DestructorAttr::DefaultPriority;
2372template <
typename AttrTy>
2384 if (!cast<ObjCProtocolDecl>(D)->isThisDeclarationADefinition()) {
2385 S.
Diag(AL.
getLoc(), diag::err_objc_attr_protocol_requires_definition)
2395 VersionTuple Introduced,
2396 VersionTuple Deprecated,
2397 VersionTuple Obsoleted) {
2398 StringRef PlatformName
2399 = AvailabilityAttr::getPrettyPlatformName(Platform->
getName());
2400 if (PlatformName.empty())
2401 PlatformName = Platform->
getName();
2405 if (!Introduced.empty() && !Deprecated.empty() &&
2406 !(Introduced <= Deprecated)) {
2407 S.
Diag(Range.getBegin(), diag::warn_availability_version_ordering)
2408 << 1 << PlatformName << Deprecated.getAsString()
2409 << 0 << Introduced.getAsString();
2413 if (!Introduced.empty() && !Obsoleted.empty() &&
2414 !(Introduced <= Obsoleted)) {
2415 S.
Diag(Range.getBegin(), diag::warn_availability_version_ordering)
2416 << 2 << PlatformName << Obsoleted.getAsString()
2417 << 0 << Introduced.getAsString();
2421 if (!Deprecated.empty() && !Obsoleted.empty() &&
2422 !(Deprecated <= Obsoleted)) {
2423 S.
Diag(Range.getBegin(), diag::warn_availability_version_ordering)
2424 << 2 << PlatformName << Obsoleted.getAsString()
2425 << 1 << Deprecated.getAsString();
2437 bool BeforeIsOkay) {
2438 if (
X.empty() || Y.empty())
2444 if (BeforeIsOkay &&
X < Y)
2452 bool Implicit, VersionTuple Introduced, VersionTuple Deprecated,
2453 VersionTuple Obsoleted,
bool IsUnavailable, StringRef Message,
2456 VersionTuple MergedIntroduced = Introduced;
2457 VersionTuple MergedDeprecated = Deprecated;
2458 VersionTuple MergedObsoleted = Obsoleted;
2459 bool FoundAny =
false;
2460 bool OverrideOrImpl =
false;
2464 OverrideOrImpl =
false;
2470 OverrideOrImpl =
true;
2476 for (
unsigned i = 0, e = Attrs.size(); i != e;) {
2477 const auto *OldAA = dyn_cast<AvailabilityAttr>(Attrs[i]);
2484 if (OldPlatform != Platform) {
2492 if (OldAA->getPriority() <
Priority)
2498 if (OldAA->getPriority() >
Priority) {
2499 Attrs.erase(Attrs.begin() + i);
2505 VersionTuple OldIntroduced = OldAA->getIntroduced();
2506 VersionTuple OldDeprecated = OldAA->getDeprecated();
2507 VersionTuple OldObsoleted = OldAA->getObsoleted();
2508 bool OldIsUnavailable = OldAA->getUnavailable();
2510 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl) ||
2511 !
versionsMatch(Deprecated, OldDeprecated, OverrideOrImpl) ||
2513 !(OldIsUnavailable == IsUnavailable ||
2514 (OverrideOrImpl && !OldIsUnavailable && IsUnavailable))) {
2515 if (OverrideOrImpl) {
2517 VersionTuple FirstVersion;
2518 VersionTuple SecondVersion;
2519 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl)) {
2521 FirstVersion = OldIntroduced;
2522 SecondVersion = Introduced;
2523 }
else if (!
versionsMatch(Deprecated, OldDeprecated, OverrideOrImpl)) {
2525 FirstVersion = Deprecated;
2526 SecondVersion = OldDeprecated;
2527 }
else if (!
versionsMatch(Obsoleted, OldObsoleted, OverrideOrImpl)) {
2529 FirstVersion = Obsoleted;
2530 SecondVersion = OldObsoleted;
2534 Diag(OldAA->getLocation(),
2535 diag::warn_mismatched_availability_override_unavail)
2536 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2547 Diag(OldAA->getLocation(),
2548 diag::warn_mismatched_availability_override)
2550 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2551 << FirstVersion.getAsString() << SecondVersion.getAsString()
2555 Diag(CI.
getLoc(), diag::note_overridden_method);
2557 Diag(CI.
getLoc(), diag::note_protocol_method);
2559 Diag(OldAA->getLocation(), diag::warn_mismatched_availability);
2560 Diag(CI.
getLoc(), diag::note_previous_attribute);
2563 Attrs.erase(Attrs.begin() + i);
2568 VersionTuple MergedIntroduced2 = MergedIntroduced;
2569 VersionTuple MergedDeprecated2 = MergedDeprecated;
2570 VersionTuple MergedObsoleted2 = MergedObsoleted;
2572 if (MergedIntroduced2.empty())
2573 MergedIntroduced2 = OldIntroduced;
2574 if (MergedDeprecated2.empty())
2575 MergedDeprecated2 = OldDeprecated;
2576 if (MergedObsoleted2.empty())
2577 MergedObsoleted2 = OldObsoleted;
2580 MergedIntroduced2, MergedDeprecated2,
2581 MergedObsoleted2)) {
2582 Attrs.erase(Attrs.begin() + i);
2587 MergedIntroduced = MergedIntroduced2;
2588 MergedDeprecated = MergedDeprecated2;
2589 MergedObsoleted = MergedObsoleted2;
2595 MergedIntroduced == Introduced &&
2596 MergedDeprecated == Deprecated &&
2597 MergedObsoleted == Obsoleted)
2603 MergedDeprecated, MergedObsoleted) &&
2605 auto *Avail = ::new (
Context) AvailabilityAttr(
2606 Context, CI, Platform, Introduced, Deprecated, Obsoleted, IsUnavailable,
2607 Message, IsStrict, Replacement,
Priority);
2608 Avail->setImplicit(Implicit);
2615 if (isa<UsingDecl, UnresolvedUsingTypenameDecl, UnresolvedUsingValueDecl>(
2627 if (AvailabilityAttr::getPrettyPlatformName(II->
getName()).empty())
2628 S.
Diag(Platform->
Loc, diag::warn_availability_unknown_platform)
2631 auto *ND = dyn_cast<NamedDecl>(D);
2641 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getMessageExpr()))
2642 Str = SE->getString();
2643 StringRef Replacement;
2644 if (
const auto *SE =
2646 Replacement = SE->getString();
2648 if (II->
isStr(
"swift")) {
2650 (!IsUnavailable && !Deprecated.
isValid())) {
2652 diag::warn_availability_swift_unavailable_deprecated_only);
2657 if (II->
isStr(
"fuchsia")) {
2658 std::optional<unsigned>
Min, Sub;
2660 (Sub = Introduced.
Version.getSubminor())) {
2661 S.
Diag(AL.
getLoc(), diag::warn_availability_fuchsia_unavailable_minor);
2671 Obsoleted.
Version, IsUnavailable, Str, IsStrict, Replacement,
2682 else if (II->
getName() ==
"ios_app_extension")
2687 const auto *IOSToWatchOSMapping =
2692 auto adjustWatchOSVersion =
2693 [IOSToWatchOSMapping](VersionTuple Version) -> VersionTuple {
2694 if (Version.empty())
2696 auto MinimumWatchOSVersion = VersionTuple(2, 0);
2698 if (IOSToWatchOSMapping) {
2699 if (
auto MappedVersion = IOSToWatchOSMapping->map(
2700 Version, MinimumWatchOSVersion, std::nullopt)) {
2701 return *MappedVersion;
2705 auto Major = Version.getMajor();
2706 auto NewMajor = Major >= 9 ? Major - 7 : 0;
2707 if (NewMajor >= 2) {
2708 if (Version.getMinor()) {
2709 if (Version.getSubminor())
2710 return VersionTuple(NewMajor, *Version.getMinor(),
2711 *Version.getSubminor());
2713 return VersionTuple(NewMajor, *Version.getMinor());
2715 return VersionTuple(NewMajor);
2718 return MinimumWatchOSVersion;
2721 auto NewIntroduced = adjustWatchOSVersion(Introduced.
Version);
2722 auto NewDeprecated = adjustWatchOSVersion(Deprecated.
Version);
2723 auto NewObsoleted = adjustWatchOSVersion(Obsoleted.
Version);
2726 ND, AL, NewII,
true , NewIntroduced, NewDeprecated,
2727 NewObsoleted, IsUnavailable, Str, IsStrict, Replacement,
2739 else if (II->
getName() ==
"ios_app_extension")
2744 const auto *IOSToTvOSMapping =
2749 auto AdjustTvOSVersion =
2750 [IOSToTvOSMapping](VersionTuple Version) -> VersionTuple {
2751 if (Version.empty())
2754 if (IOSToTvOSMapping) {
2755 if (
auto MappedVersion = IOSToTvOSMapping->map(
2756 Version, VersionTuple(0, 0), std::nullopt)) {
2757 return *MappedVersion;
2763 auto NewIntroduced = AdjustTvOSVersion(Introduced.
Version);
2764 auto NewDeprecated = AdjustTvOSVersion(Deprecated.
Version);
2765 auto NewObsoleted = AdjustTvOSVersion(Obsoleted.
Version);
2768 ND, AL, NewII,
true , NewIntroduced, NewDeprecated,
2769 NewObsoleted, IsUnavailable, Str, IsStrict, Replacement,
2776 llvm::Triple::IOS &&
2778 auto GetSDKInfo = [&]() {
2787 else if (II->
getName() ==
"ios_app_extension")
2790 auto MinMacCatalystVersion = [](
const VersionTuple &
V) {
2793 if (
V.getMajor() < 13 ||
2794 (
V.getMajor() == 13 &&
V.getMinor() && *
V.getMinor() < 1))
2795 return VersionTuple(13, 1);
2799 ND, AL, NewII,
true ,
2800 MinMacCatalystVersion(Introduced.
Version),
2801 MinMacCatalystVersion(Deprecated.
Version),
2802 MinMacCatalystVersion(Obsoleted.
Version), IsUnavailable, Str,
2807 }
else if (II->
getName() ==
"macos" && GetSDKInfo() &&
2809 !Obsoleted.
Version.empty())) {
2810 if (
const auto *MacOStoMacCatalystMapping =
2811 GetSDKInfo()->getVersionMapping(
2818 auto RemapMacOSVersion =
2819 [&](
const VersionTuple &
V) -> std::optional<VersionTuple> {
2821 return std::nullopt;
2823 if (
V.getMajor() == 100000)
2824 return VersionTuple(100000);
2826 return MacOStoMacCatalystMapping->map(
V, VersionTuple(13, 1),
2829 std::optional<VersionTuple> NewIntroduced =
2830 RemapMacOSVersion(Introduced.
Version),
2832 RemapMacOSVersion(Deprecated.
Version),
2834 RemapMacOSVersion(Obsoleted.
Version);
2835 if (NewIntroduced || NewDeprecated || NewObsoleted) {
2836 auto VersionOrEmptyVersion =
2837 [](
const std::optional<VersionTuple> &
V) -> VersionTuple {
2838 return V ? *
V : VersionTuple();
2841 ND, AL, NewII,
true ,
2842 VersionOrEmptyVersion(NewIntroduced),
2843 VersionOrEmptyVersion(NewDeprecated),
2844 VersionOrEmptyVersion(NewObsoleted),
false, Str,
2862 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(0)))
2864 StringRef DefinedIn;
2865 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(1)))
2866 DefinedIn = SE->getString();
2867 bool IsGeneratedDeclaration = AL.
getArgAsIdent(2) !=
nullptr;
2869 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(3)))
2870 USR = SE->getString();
2878 typename T::VisibilityType value) {
2879 T *existingAttr = D->
getAttr<T>();
2881 typename T::VisibilityType existingValue = existingAttr->getVisibility();
2882 if (existingValue == value)
2884 S.
Diag(existingAttr->getLocation(), diag::err_mismatched_visibility);
2885 S.
Diag(CI.
getLoc(), diag::note_previous_attribute);
2893 VisibilityAttr::VisibilityType Vis) {
2894 return ::mergeVisibilityAttr<VisibilityAttr>(*
this, D, CI, Vis);
2899 TypeVisibilityAttr::VisibilityType Vis) {
2900 return ::mergeVisibilityAttr<TypeVisibilityAttr>(*
this, D, CI, Vis);
2904 bool isTypeVisibility) {
2906 if (isa<TypedefNameDecl>(D)) {
2912 if (isTypeVisibility && !(isa<TagDecl>(D) || isa<ObjCInterfaceDecl>(D) ||
2913 isa<NamespaceDecl>(D))) {
2925 VisibilityAttr::VisibilityType
type;
2926 if (!VisibilityAttr::ConvertStrToVisibilityType(TypeStr,
type)) {
2927 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported) << AL
2934 if (
type == VisibilityAttr::Protected &&
2936 S.
Diag(AL.
getLoc(), diag::warn_attribute_protected_visibility);
2937 type = VisibilityAttr::Default;
2941 if (isTypeVisibility) {
2943 D, AL, (TypeVisibilityAttr::VisibilityType)
type);
2954 S.
Diag(AL.
getLoc(), diag::err_objc_direct_on_protocol) <<
false;
2959 handleSimpleAttribute<ObjCDirectAttr>(S, D, AL);
2961 S.
Diag(AL.
getLoc(), diag::warn_objc_direct_ignored) << AL;
2968 handleSimpleAttribute<ObjCDirectMembersAttr>(S, D, AL);
2970 S.
Diag(AL.
getLoc(), diag::warn_objc_direct_ignored) << AL;
2975 const auto *M = cast<ObjCMethodDecl>(D);
2977 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
2983 ObjCMethodFamilyAttr::FamilyKind F;
2984 if (!ObjCMethodFamilyAttr::ConvertStrToFamilyKind(IL->
Ident->
getName(), F)) {
2985 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported) << AL << IL->
Ident;
2989 if (F == ObjCMethodFamilyAttr::OMF_init &&
2990 !M->getReturnType()->isObjCObjectPointerType()) {
2991 S.
Diag(M->getLocation(), diag::err_init_method_bad_return_type)
2992 << M->getReturnType();
3001 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
3002 QualType T = TD->getUnderlyingType();
3004 S.
Diag(TD->getLocation(), diag::err_nsobject_attribute);
3008 else if (
const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
3011 S.
Diag(PD->getLocation(), diag::err_nsobject_attribute);
3028 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
3029 QualType T = TD->getUnderlyingType();
3031 S.
Diag(TD->getLocation(), diag::warn_ptr_independentclass_attribute);
3043 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3049 BlocksAttr::BlockType
type;
3050 if (!BlocksAttr::ConvertStrToBlockType(II->
getName(),
type)) {
3051 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
3059 unsigned sentinel = (
unsigned)SentinelAttr::DefaultSentinel;
3062 std::optional<llvm::APSInt> Idx = llvm::APSInt(32);
3064 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3069 if (Idx->isSigned() && Idx->isNegative()) {
3070 S.
Diag(AL.
getLoc(), diag::err_attribute_sentinel_less_than_zero)
3075 sentinel = Idx->getZExtValue();
3078 unsigned nullPos = (
unsigned)SentinelAttr::DefaultNullPos;
3081 std::optional<llvm::APSInt> Idx = llvm::APSInt(32);
3083 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3087 nullPos = Idx->getZExtValue();
3089 if ((Idx->isSigned() && Idx->isNegative()) || nullPos > 1) {
3092 S.
Diag(AL.
getLoc(), diag::err_attribute_sentinel_not_zero_or_one)
3098 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
3100 if (isa<FunctionNoProtoType>(FT)) {
3101 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_named_arguments);
3105 if (!cast<FunctionProtoType>(FT)->isVariadic()) {
3106 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
3109 }
else if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
3110 if (!MD->isVariadic()) {
3111 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
3114 }
else if (
const auto *BD = dyn_cast<BlockDecl>(D)) {
3115 if (!BD->isVariadic()) {
3116 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 1;
3119 }
else if (
const auto *
V = dyn_cast<VarDecl>(D)) {
3127 if (!cast<FunctionProtoType>(FT)->isVariadic()) {
3129 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << m;
3133 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
3139 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
3150 !isa<CXXConstructorDecl>(D)) {
3151 S.
Diag(AL.
getLoc(), diag::warn_attribute_void_function_method) << AL << 0;
3154 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
3155 if (MD->getReturnType()->isVoidType()) {
3156 S.
Diag(AL.
getLoc(), diag::warn_attribute_void_function_method) << AL << 1;
3164 if (isa<VarDecl>(D))
3165 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type_str)
3167 <<
"functions, classes, or enumerations";
3176 if (LO.CPlusPlus && !LO.CPlusPlus20)
3177 S.
Diag(AL.
getLoc(), diag::ext_cxx20_attr) << AL;
3185 }
else if (LO.CPlusPlus && !LO.CPlusPlus17)
3186 S.
Diag(AL.
getLoc(), diag::ext_cxx17_attr) << AL;
3191 isa<TypedefNameDecl>(D)) {
3192 S.
Diag(AL.
getLoc(), diag::warn_unused_result_typedef_unsupported_spelling)
3205 S.
Diag(AL.
getLoc(), diag::warn_attribute_invalid_on_definition)
3207 else if (isa<ObjCPropertyDecl>(D) || isa<ObjCMethodDecl>(D) ||
3209 (isa<ObjCInterfaceDecl>(D) || isa<EnumDecl>(D)))) {
3212 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
3222template <
typename WorkGroupAttr>
3225 for (
unsigned i = 0; i < 3; ++i) {
3230 if (WGSize[i] == 0) {
3231 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_is_zero)
3237 WorkGroupAttr *Existing = D->
getAttr<WorkGroupAttr>();
3238 if (Existing && !(Existing->getXDim() == WGSize[0] &&
3239 Existing->getYDim() == WGSize[1] &&
3240 Existing->getZDim() == WGSize[2]))
3241 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3244 WorkGroupAttr(S.
Context, AL, WGSize[0], WGSize[1], WGSize[2]));
3254 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_is_zero)
3259 OpenCLIntelReqdSubGroupSizeAttr *Existing =
3260 D->
getAttr<OpenCLIntelReqdSubGroupSizeAttr>();
3261 if (Existing && Existing->getSubGroupSize() != SGSize)
3262 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3265 OpenCLIntelReqdSubGroupSizeAttr(S.
Context, AL, SGSize));
3270 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
3276 assert(ParmTSI &&
"no type source info for attribute argument");
3281 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_argument) << 2 << AL;
3285 if (VecTypeHintAttr *A = D->
getAttr<VecTypeHintAttr>()) {
3287 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3299 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
3304 if (SectionAttr *ExistingAttr = D->
getAttr<SectionAttr>()) {
3305 if (ExistingAttr->getName() == Name)
3307 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section)
3309 Diag(CI.
getLoc(), diag::note_previous_attribute);
3326 return llvm::Error::success();
3329 StringRef Segment, Section;
3330 unsigned TAA, StubSize;
3332 return llvm::MCSectionMachO::ParseSectionSpecifier(SecName, Segment, Section,
3333 TAA, HasTAA, StubSize);
3338 Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
3363 cast<NamedDecl>(D));
3374 llvm::CodeModel::Model CM;
3375 if (!CodeModelAttr::ConvertStrToModel(Str, CM)) {
3376 S.
Diag(LiteralLoc, diag::err_attr_codemodel_arg) << Str;
3386 StringRef CodeSegName) {
3388 S.
Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
3400 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
3404 if (
const auto *ExistingAttr = D->
getAttr<CodeSegAttr>()) {
3405 if (ExistingAttr->getName() == Name)
3407 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section)
3409 Diag(CI.
getLoc(), diag::note_previous_attribute);
3422 if (
const auto *ExistingAttr = D->
getAttr<CodeSegAttr>()) {
3423 if (!ExistingAttr->isImplicit()) {
3425 ExistingAttr->getName() == Str
3426 ? diag::warn_duplicate_codeseg_attribute
3427 : diag::err_conflicting_codeseg_attribute);
3439 enum FirstParam { Unsupported, Duplicate,
Unknown };
3440 enum SecondParam {
None, CPU, Tune };
3442 if (AttrStr.contains(
"fpmath="))
3443 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3444 << Unsupported <<
None <<
"fpmath=" <<
Target;
3448 AttrStr.contains(
"tune="))
3449 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3455 if (!ParsedAttrs.
CPU.empty() &&
3457 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3460 if (!ParsedAttrs.
Tune.empty() &&
3462 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3467 return Diag(LiteralLoc, diag::err_duplicate_target_attribute)
3471 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3474 for (
const auto &Feature : ParsedAttrs.
Features) {
3475 auto CurFeature = StringRef(Feature).drop_front();
3477 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3478 << Unsupported <<
None << CurFeature <<
Target;
3487 if (DiagMsg.empty())
3488 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3489 << Unsupported <<
None <<
"branch-protection" <<
Target;
3490 return Diag(LiteralLoc, diag::err_invalid_branch_protection_spec)
3493 if (!DiagMsg.empty())
3494 Diag(LiteralLoc, diag::warn_unsupported_branch_protection_spec) << DiagMsg;
3508 StringRef &AttrStr,
bool &isDefault) {
3509 enum FirstParam { Unsupported };
3510 enum SecondParam {
None };
3512 if (AttrStr.trim() ==
"default")
3515 AttrStr.split(Features,
"+");
3516 for (
auto &CurFeature : Features) {
3517 CurFeature = CurFeature.trim();
3518 if (CurFeature ==
"default")
3521 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3525 return Diag(LiteralLoc, diag::err_sme_streaming_cannot_be_multiversioned);
3532 bool isDefault =
false;
3538 TargetVersionAttr *NewAttr =
3551 TargetAttr *NewAttr = ::new (S.
Context) TargetAttr(S.
Context, AL, Str);
3557 Decl *D,
bool &HasDefault,
bool &HasCommas,
bool &HasNotDefault,
3559 enum FirstParam { Unsupported, Duplicate,
Unknown };
3560 enum SecondParam {
None, CPU, Tune };
3562 HasCommas = HasCommas || Str.contains(
',');
3565 if (Str.size() == 0)
3566 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3569 std::pair<StringRef, StringRef> Parts = {{}, Str};
3570 while (!Parts.second.empty()) {
3571 Parts = Parts.second.split(
',');
3572 StringRef Cur = Parts.first.trim();
3574 Literal->getLocationOfByte(Cur.data() - Literal->getString().data(),
3577 bool DefaultIsDupe =
false;
3578 bool HasCodeGenImpact =
false;
3580 return Diag(CurLoc, diag::warn_unsupported_target_attribute)
3585 if (Cur ==
"default") {
3586 DefaultIsDupe = HasDefault;
3588 if (llvm::is_contained(StringsBuffer, Cur) || DefaultIsDupe)
3589 Diag(CurLoc, diag::warn_target_clone_duplicate_options);
3591 StringsBuffer.push_back(Cur);
3593 std::pair<StringRef, StringRef> CurParts = {{}, Cur};
3595 while (!CurParts.second.empty()) {
3596 CurParts = CurParts.second.split(
'+');
3597 StringRef CurFeature = CurParts.first.trim();
3599 Diag(CurLoc, diag::warn_unsupported_target_attribute)
3604 HasCodeGenImpact =
true;
3605 CurFeatures.push_back(CurFeature);
3608 llvm::sort(CurFeatures);
3610 for (
auto &CurFeat : CurFeatures) {
3611 if (!Res.equals(
""))
3613 Res.append(CurFeat);
3615 if (llvm::is_contained(StringsBuffer, Res) || DefaultIsDupe)
3616 Diag(CurLoc, diag::warn_target_clone_duplicate_options);
3617 else if (!HasCodeGenImpact)
3620 Diag(CurLoc, diag::warn_target_clone_no_impact_options);
3621 else if (!Res.empty()) {
3622 StringsBuffer.push_back(Res);
3623 HasNotDefault =
true;
3627 return Diag(LiteralLoc,
3628 diag::err_sme_streaming_cannot_be_multiversioned);
3631 if (Cur.starts_with(
"arch=")) {
3633 Cur.drop_front(
sizeof(
"arch=") - 1)))
3634 return Diag(CurLoc, diag::warn_unsupported_target_attribute)
3635 << Unsupported << CPU << Cur.drop_front(
sizeof(
"arch=") - 1)
3637 }
else if (Cur ==
"default") {
3638 DefaultIsDupe = HasDefault;
3641 return Diag(CurLoc, diag::warn_unsupported_target_attribute)
3643 if (llvm::is_contained(StringsBuffer, Cur) || DefaultIsDupe)
3644 Diag(CurLoc, diag::warn_target_clone_duplicate_options);
3646 StringsBuffer.push_back(Cur);
3649 if (Str.rtrim().ends_with(
","))
3650 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3662 if (
const auto *
Other = D->
getAttr<TargetClonesAttr>()) {
3663 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
3664 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
3667 if (checkAttrMutualExclusion<TargetClonesAttr>(S, D, AL))
3672 bool HasCommas =
false, HasDefault =
false, HasNotDefault =
false;
3674 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
3681 HasDefault, HasCommas, HasNotDefault, StringsBuffer))
3684 for (
auto &SmallStr : StringsBuffer)
3685 Strings.push_back(SmallStr.str());
3688 S.
Diag(AL.
getLoc(), diag::warn_target_clone_mixed_values);
3693 Strings.push_back(
"default");
3697 S.
Diag(AL.
getLoc(), diag::err_target_clone_must_have_default);
3703 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
3704 if (MD->getParent()->isLambda()) {
3716 cast<FunctionDecl>(D)->setIsMultiVersion();
3717 TargetClonesAttr *NewAttr = ::new (S.
Context)
3718 TargetClonesAttr(S.
Context, AL, Strings.data(), Strings.size());
3730 MinVectorWidthAttr *Existing = D->
getAttr<MinVectorWidthAttr>();
3731 if (Existing && Existing->getVectorWidth() != VecWidth) {
3732 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3747 if (
auto *DRE = dyn_cast<DeclRefExpr>(E)) {
3749 S.
Diag(Loc, diag::warn_cleanup_ext);
3750 FD = dyn_cast<FunctionDecl>(DRE->
getDecl());
3753 S.
Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 1
3757 }
else if (
auto *ULE = dyn_cast<UnresolvedLookupExpr>(E)) {
3758 if (ULE->hasExplicitTemplateArgs())
3759 S.
Diag(Loc, diag::warn_cleanup_ext);
3761 NI = ULE->getNameInfo();
3763 S.
Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 2
3770 S.
Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 0;
3775 S.
Diag(Loc, diag::err_attribute_cleanup_func_must_take_one_arg)
3786 S.
Diag(Loc, diag::err_attribute_cleanup_func_arg_incompatible_type)
3787 << NI.
getName() << ParamTy << Ty;
3790 VarDecl *VD = cast<VarDecl>(D);
3801 S.
Context, VariableReference, UnaryOperatorKind::UO_AddrOf,
3821 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3826 EnumExtensibilityAttr::Kind ExtensibilityKind;
3828 if (!EnumExtensibilityAttr::ConvertStrToKind(II->
getName(),
3829 ExtensibilityKind)) {
3830 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
3835 EnumExtensibilityAttr(S.
Context, AL, ExtensibilityKind));
3850 if (NotNSStringTy &&
3854 S.
Diag(AL.
getLoc(), diag::err_format_attribute_not)
3862 if (
auto *OMD = dyn_cast<ObjCMethodDecl>(D))
3863 if (
auto *
Interface = OMD->getClassInterface())
3870 S.
Diag(AL.
getLoc(), diag::err_format_attribute_result_not)
3871 << (NotNSStringTy ?
"string type" :
"NSString")
3891 return llvm::StringSwitch<FormatAttrKind>(Format)
3905 .Cases(
"gcc_diag",
"gcc_cdiag",
"gcc_cxxdiag",
"gcc_tdiag",
IgnoredFormat)
3913 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored) << AL;
3918 S.
Diag(AL.
getLoc(), diag::err_hlsl_init_priority_unsupported);
3923 S.
Diag(AL.
getLoc(), diag::err_init_priority_object_attr);
3927 QualType T = cast<VarDecl>(D)->getType();
3931 S.
Diag(AL.
getLoc(), diag::err_init_priority_object_attr);
3937 uint32_t prioritynum;
3946 if ((prioritynum < 101 || prioritynum > 65535) &&
3948 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_range)
3957 StringRef NewUserDiagnostic) {
3958 if (
const auto *EA = D->
getAttr<ErrorAttr>()) {
3960 assert((NewAttr ==
"error" || NewAttr ==
"warning") &&
3961 "unexpected normalized full name");
3962 bool Match = (EA->isError() && NewAttr ==
"error") ||
3963 (EA->isWarning() && NewAttr ==
"warning");
3965 Diag(EA->getLocation(), diag::err_attributes_are_not_compatible)
3968 EA->isRegularKeywordAttribute());
3969 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
3972 if (EA->getUserDiagnostic() != NewUserDiagnostic) {
3973 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << EA;
3974 Diag(EA->getLoc(), diag::note_previous_attribute);
3978 return ::new (
Context) ErrorAttr(
Context, CI, NewUserDiagnostic);
3986 if (F->getType() == Format &&
3987 F->getFormatIdx() == FormatIdx &&
3988 F->getFirstArg() == FirstArg) {
3991 if (F->getLocation().isInvalid())
3997 return ::new (
Context) FormatAttr(
Context, CI, Format, FormatIdx, FirstArg);
4004 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
4015 StringRef Format = II->
getName();
4029 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
4040 if (Idx < 1 || Idx > NumArgs) {
4041 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4047 unsigned ArgIdx = Idx - 1;
4049 if (HasImplicitThisParam) {
4052 diag::err_format_attribute_implicit_this_format_string)
4066 S.
Diag(AL.
getLoc(), diag::err_format_attribute_not)
4078 if (FirstArg != 0) {
4082 S.
Diag(AL.
getLoc(), diag::err_format_strftime_third_parameter)
4090 if (FirstArg != NumArgs + 1) {
4091 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4094 std::to_string(NumArgs + 1));
4099 S.
Diag(D->
getLocation(), diag::warn_gcc_requires_variadic_function) << AL;
4100 if (FirstArg <= Idx) {
4104 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4120 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_no_callee)
4129 assert(FD &&
"Expected a function declaration!");
4131 llvm::StringMap<int> NameIdxMapping;
4132 NameIdxMapping[
"__"] = -1;
4134 NameIdxMapping[
"this"] = 0;
4138 NameIdxMapping[PVD->getName()] = Idx++;
4140 auto UnknownName = NameIdxMapping.end();
4143 for (
unsigned I = 0, E = AL.
getNumArgs(); I < E; ++I) {
4149 auto It = NameIdxMapping.find(IdLoc->
Ident->
getName());
4150 if (It == UnknownName) {
4151 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_argument_unknown)
4157 ArgIdx = It->second;
4164 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4170 if (ArgIdx < -1 || ArgIdx > NumArgs) {
4171 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4178 llvm_unreachable(
"Unexpected ParsedAttr argument type!");
4181 if (ArgIdx == 0 && !HasImplicitThisParam) {
4182 S.
Diag(AL.
getLoc(), diag::err_callback_implicit_this_not_available)
4189 if (!HasImplicitThisParam && ArgIdx > 0)
4192 EncodingIndices.push_back(ArgIdx);
4195 int CalleeIdx = EncodingIndices.front();
4199 if (CalleeIdx < (
int)HasImplicitThisParam) {
4200 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_invalid_callee)
4207 const Type *CalleeType =
4211 S.
Diag(AL.
getLoc(), diag::err_callback_callee_no_function_type)
4216 const Type *CalleeFnType =
4221 const auto *CalleeFnProtoType = dyn_cast<FunctionProtoType>(CalleeFnType);
4222 if (!CalleeFnProtoType) {
4223 S.
Diag(AL.
getLoc(), diag::err_callback_callee_no_function_type)
4228 if (CalleeFnProtoType->getNumParams() > EncodingIndices.size() - 1) {
4229 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments)
4230 << AL << (
unsigned)(EncodingIndices.size() - 1);
4234 if (CalleeFnProtoType->getNumParams() < EncodingIndices.size() - 1) {
4235 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments)
4236 << AL << (
unsigned)(EncodingIndices.size() - 1);
4240 if (CalleeFnProtoType->isVariadic()) {
4246 if (D->
hasAttr<CallbackAttr>()) {
4252 S.
Context, AL, EncodingIndices.data(), EncodingIndices.size()));
4265 QualType T = cast<ParmVarDecl>(D)->getType();
4268 S.
Diag(AL.
getLoc(), diag::err_called_once_attribute_wrong_type);
4278 const auto *TD = dyn_cast<TypedefNameDecl>(D);
4279 if (TD && TD->getUnderlyingType()->isUnionType())
4280 RD = TD->getUnderlyingType()->getAsUnionType()->getDecl();
4282 RD = dyn_cast<RecordDecl>(D);
4285 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
4293 diag::warn_transparent_union_attribute_not_definition);
4299 if (Field == FieldEnd) {
4300 S.
Diag(AL.
getLoc(), diag::warn_transparent_union_attribute_zero_fields);
4308 diag::warn_transparent_union_attribute_floating)
4317 for (; Field != FieldEnd; ++Field) {
4318 QualType FieldType = Field->getType();
4332 S.
Diag(Field->getLocation(),
4333 diag::warn_transparent_union_attribute_field_size_align)
4334 << isSize << *Field << FieldBits;
4335 unsigned FirstBits = isSize ? FirstSize : FirstAlign;
4337 diag::note_transparent_union_first_field_size_align)
4338 << isSize << FirstBits;
4348 auto *
Attr = AnnotateAttr::Create(
Context, Str, Args.data(), Args.size(), CI);
4364 for (
unsigned Idx = 1; Idx < AL.
getNumArgs(); Idx++) {
4377 AlignValueAttr TmpAttr(
Context, CI, E);
4381 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D))
4382 T = TD->getUnderlyingType();
4383 else if (
const auto *VD = dyn_cast<ValueDecl>(D))
4386 llvm_unreachable(
"Unknown decl type for align_value");
4390 Diag(AttrLoc, diag::warn_attribute_pointer_or_reference_only)
4396 llvm::APSInt Alignment;
4398 E, &Alignment, diag::err_align_value_attribute_argument_not_int);
4402 if (!Alignment.isPowerOf2()) {
4403 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
4425 diag::err_pack_expansion_without_parameter_packs);
4440 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
4452 diag::err_pack_expansion_without_parameter_packs);
4479 const AlignedAttr &
Attr,
4482 if (isa<ParmVarDecl>(D)) {
4484 }
else if (
const auto *VD = dyn_cast<VarDecl>(D)) {
4487 if (VD->isExceptionVariable())
4489 }
else if (
const auto *FD = dyn_cast<FieldDecl>(D)) {
4490 if (FD->isBitField())
4492 }
else if (
const auto *ED = dyn_cast<EnumDecl>(D)) {
4493 if (ED->getLangOpts().CPlusPlus)
4495 }
else if (!isa<TagDecl>(D)) {
4496 return S.
Diag(AttrLoc, diag::err_attribute_wrong_decl_type)
4501 if (DiagKind != -1) {
4502 return S.
Diag(AttrLoc, diag::err_alignas_attribute_wrong_decl_type)
4503 << &
Attr << DiagKind;
4509 bool IsPackExpansion) {
4510 AlignedAttr TmpAttr(
Context, CI,
true, E);
4514 if (TmpAttr.isAlignas() &&
4522 if (
const auto *TND = dyn_cast<TypedefNameDecl>(D)) {
4523 if (!TND->getUnderlyingType()->isDependentType()) {
4524 Diag(AttrLoc, diag::err_alignment_dependent_typedef_name)
4531 AlignedAttr *AA = ::new (
Context) AlignedAttr(
Context, CI,
true, E);
4532 AA->setPackExpansion(IsPackExpansion);
4538 llvm::APSInt Alignment;
4540 E, &Alignment, diag::err_aligned_attribute_argument_not_int);
4548 Diag(AttrLoc, diag::err_attribute_aligned_too_great)
4553 uint64_t AlignVal = Alignment.getZExtValue();
4559 if (!(TmpAttr.isAlignas() && !Alignment)) {
4560 if (!llvm::isPowerOf2_64(AlignVal)) {
4561 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
4567 const auto *VD = dyn_cast<VarDecl>(D);
4569 unsigned MaxTLSAlign =
4572 if (MaxTLSAlign && AlignVal > MaxTLSAlign &&
4574 Diag(VD->getLocation(), diag::err_tls_var_aligned_over_maximum)
4575 << (
unsigned)AlignVal << VD << MaxTLSAlign;
4583 const Type *Ty = VD->getType().getTypePtr();
4585 Diag(VD->getLocation(), diag::warn_aligned_attr_underaligned)
4586 << VD->getType() << 16;
4592 AA->setPackExpansion(IsPackExpansion);
4593 AA->setCachedAlignmentValue(
4600 AlignedAttr TmpAttr(
Context, CI,
false, TS);
4604 if (TmpAttr.isAlignas() &&
4612 if (
const auto *TND = dyn_cast<TypedefNameDecl>(D)) {
4613 if (!TND->getUnderlyingType()->isDependentType()) {
4614 Diag(AttrLoc, diag::err_alignment_dependent_typedef_name)
4620 AlignedAttr *AA = ::new (
Context) AlignedAttr(
Context, CI,
false, TS);
4621 AA->setPackExpansion(IsPackExpansion);
4626 const auto *VD = dyn_cast<VarDecl>(D);
4627 unsigned AlignVal = TmpAttr.getAlignment(
Context);
4631 const Type *Ty = VD->getType().getTypePtr();
4634 Diag(VD->getLocation(), diag::warn_aligned_attr_underaligned)
4635 << VD->getType() << 16;
4640 AlignedAttr *AA = ::new (
Context) AlignedAttr(
Context, CI,
false, TS);
4641 AA->setPackExpansion(IsPackExpansion);
4642 AA->setCachedAlignmentValue(AlignVal);
4647 assert(D->
hasAttrs() &&
"no attributes on decl");
4650 if (
const auto *VD = dyn_cast<ValueDecl>(D)) {
4651 UnderlyingTy = DiagTy = VD->getType();
4654 if (
const auto *ED = dyn_cast<EnumDecl>(D))
4655 UnderlyingTy = ED->getIntegerType();
4664 AlignedAttr *AlignasAttr =
nullptr;
4665 AlignedAttr *LastAlignedAttr =
nullptr;
4668 if (I->isAlignmentDependent())
4672 Align = std::max(Align, I->getAlignment(
Context));
4673 LastAlignedAttr = I;
4677 Diag(LastAlignedAttr->getLocation(), diag::err_attribute_sizeless_type)
4678 << LastAlignedAttr << DiagTy;
4679 }
else if (AlignasAttr && Align) {
4682 if (NaturalAlign > RequestedAlign)
4683 Diag(AlignasAttr->getLocation(), diag::err_alignas_underaligned)
4710 Diag(Range.getBegin(), diag::err_mismatched_ms_inheritance)
4719 bool &IntegerMode,
bool &ComplexMode,
4722 ComplexMode =
false;
4724 switch (Str.size()) {
4744 DestWidth = Str[1] ==
'I' ? 0 : 128;
4752 DestWidth = Str[1] ==
'I' ? 0 : 128;
4755 if (Str[1] ==
'F') {
4756 IntegerMode =
false;
4757 }
else if (Str[1] ==
'C') {
4758 IntegerMode =
false;
4760 }
else if (Str[1] !=
'I') {
4769 else if (Str ==
"byte")
4773 if (Str ==
"pointer")
4777 if (Str ==
"unwind_word")
4793 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
4805 StringRef Str = Name->getName();
4809 unsigned DestWidth = 0;
4810 bool IntegerMode =
true;
4811 bool ComplexMode =
false;
4813 llvm::APInt VectorSize(64, 0);
4814 if (Str.size() >= 4 && Str[0] ==
'V') {
4816 size_t StrSize = Str.size();
4817 size_t VectorStringLength = 0;
4818 while ((VectorStringLength + 1) < StrSize &&
4819 isdigit(Str[VectorStringLength + 1]))
4820 ++VectorStringLength;
4821 if (VectorStringLength &&
4822 !Str.substr(1, VectorStringLength).getAsInteger(10, VectorSize) &&
4823 VectorSize.isPowerOf2()) {
4825 IntegerMode, ComplexMode, ExplicitType);
4827 if (!InInstantiation)
4828 Diag(AttrLoc, diag::warn_vector_mode_deprecated);
4843 Diag(AttrLoc, diag::err_machine_mode) << 0 << Name;
4848 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D))
4849 OldTy = TD->getUnderlyingType();
4850 else if (
const auto *ED = dyn_cast<EnumDecl>(D)) {
4853 OldTy = ED->getIntegerType();
4857 OldTy = cast<ValueDecl>(D)->getType();
4868 OldElemTy = VT->getElementType();
4874 VectorSize.getBoolValue()) {
4875 Diag(AttrLoc, diag::err_enum_mode_vector_type) << Name << CI.
getRange();
4883 !IntegralOrAnyEnumType)
4884 Diag(AttrLoc, diag::err_mode_not_primitive);
4885 else if (IntegerMode) {
4886 if (!IntegralOrAnyEnumType)
4887 Diag(AttrLoc, diag::err_mode_wrong_type);
4888 }
else if (ComplexMode) {
4890 Diag(AttrLoc, diag::err_mode_wrong_type);
4893 Diag(AttrLoc, diag::err_mode_wrong_type);
4904 if (NewElemTy.
isNull()) {
4906 if (!(DestWidth == 128 &&
getLangOpts().CUDAIsDevice))
4907 Diag(AttrLoc, diag::err_machine_mode) << 1 << Name;
4916 if (VectorSize.getBoolValue()) {
4922 Diag(AttrLoc, diag::err_complex_mode_vector_type);
4926 OldVT->getNumElements() /
4933 Diag(AttrLoc, diag::err_mode_wrong_type);
4938 if (
auto *TD = dyn_cast<TypedefNameDecl>(D))
4939 TD->setModedTypeSourceInfo(TD->getTypeSourceInfo(), NewTy);
4940 else if (
auto *ED = dyn_cast<EnumDecl>(D))
4941 ED->setIntegerType(NewTy);
4943 cast<ValueDecl>(D)->setType(NewTy);
4955 if (OptimizeNoneAttr *Optnone = D->
getAttr<OptimizeNoneAttr>()) {
4956 Diag(CI.
getLoc(), diag::warn_attribute_ignored) << Ident;
4957 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
4961 if (D->
hasAttr<AlwaysInlineAttr>())
4969 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
4972 if (VD->getKind() != Decl::Var) {
4973 Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
4980 if (VD->hasLocalStorage()) {
4981 Diag(VD->getLocation(), diag::warn_internal_linkage_local_storage);
4988InternalLinkageAttr *
4990 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
4993 if (VD->getKind() != Decl::Var) {
4994 Diag(AL.getLocation(), diag::warn_attribute_wrong_decl_type)
4995 << &AL << AL.isRegularKeywordAttribute()
5001 if (VD->hasLocalStorage()) {
5002 Diag(VD->getLocation(), diag::warn_internal_linkage_local_storage);
5011 if (OptimizeNoneAttr *Optnone = D->
getAttr<OptimizeNoneAttr>()) {
5012 Diag(CI.
getLoc(), diag::warn_attribute_ignored) <<
"'minsize'";
5013 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
5017 if (D->
hasAttr<MinSizeAttr>())
5025 if (
const auto *PrevSNA = D->
getAttr<SwiftNameAttr>()) {
5026 if (PrevSNA->getName() != Name && !PrevSNA->isImplicit()) {
5027 Diag(PrevSNA->getLocation(), diag::err_attributes_are_not_compatible)
5029 << (PrevSNA->isRegularKeywordAttribute() ||
5030 SNA.isRegularKeywordAttribute());
5031 Diag(SNA.getLoc(), diag::note_conflicting_attribute);
5041 if (AlwaysInlineAttr *Inline = D->
getAttr<AlwaysInlineAttr>()) {
5042 Diag(Inline->getLocation(), diag::warn_attribute_ignored) << Inline;
5043 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
5046 if (MinSizeAttr *MinSize = D->
getAttr<MinSizeAttr>()) {
5047 Diag(MinSize->getLocation(), diag::warn_attribute_ignored) << MinSize;
5048 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
5052 if (D->
hasAttr<OptimizeNoneAttr>())
5059 if (AlwaysInlineAttr *Inline =
5075 const auto *VD = cast<VarDecl>(D);
5076 if (VD->hasLocalStorage()) {
5077 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
5082 if (
auto *A = D->
getAttr<CUDAConstantAttr>()) {
5083 if (!A->isImplicit())
5091 const auto *VD = cast<VarDecl>(D);
5094 if (!S.
getLangOpts().GPURelocatableDeviceCode && VD->hasExternalStorage() &&
5095 !isa<IncompleteArrayType>(VD->getType())) {
5096 S.
Diag(AL.
getLoc(), diag::err_cuda_extern_shared) << VD;
5099 if (S.
getLangOpts().CUDA && VD->hasLocalStorage() &&
5107 const auto *FD = cast<FunctionDecl>(D);
5118 if (
const auto *Method = dyn_cast<CXXMethodDecl>(FD)) {
5119 if (Method->isInstance()) {
5120 S.
Diag(Method->getBeginLoc(), diag::err_kern_is_nonstatic_method)
5124 S.
Diag(Method->getBeginLoc(), diag::warn_kern_is_method) << Method;
5130 if (AL.
getKind() == ParsedAttr::AT_NVPTXKernel)
5143 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
5144 if (VD->hasLocalStorage()) {
5145 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
5150 if (
auto *A = D->
getAttr<CUDADeviceAttr>()) {
5151 if (!A->isImplicit())
5159 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
5160 if (VD->hasLocalStorage()) {
5161 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
5165 if (!D->
hasAttr<HIPManagedAttr>())
5167 if (!D->
hasAttr<CUDADeviceAttr>())
5172 const auto *Fn = cast<FunctionDecl>(D);
5173 if (!Fn->isInlineSpecified()) {
5174 S.
Diag(AL.
getLoc(), diag::warn_gnu_inline_attribute_requires_inline);
5179 S.
Diag(AL.
getLoc(), diag::warn_gnu_inline_cplusplus_without_extern);
5194 if (!isa<ObjCMethodDecl>(D)) {
5195 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
5201 case ParsedAttr::AT_FastCall:
5204 case ParsedAttr::AT_StdCall:
5207 case ParsedAttr::AT_ThisCall:
5210 case ParsedAttr::AT_CDecl:
5213 case ParsedAttr::AT_Pascal:
5216 case ParsedAttr::AT_SwiftCall:
5219 case ParsedAttr::AT_SwiftAsyncCall:
5222 case ParsedAttr::AT_VectorCall:
5225 case ParsedAttr::AT_MSABI:
5228 case ParsedAttr::AT_SysVABI:
5231 case ParsedAttr::AT_RegCall:
5234 case ParsedAttr::AT_Pcs: {
5235 PcsAttr::PCSType PCS;
5238 PCS = PcsAttr::AAPCS;
5241 PCS = PcsAttr::AAPCS_VFP;
5244 llvm_unreachable(
"unexpected calling convention in pcs attribute");
5250 case ParsedAttr::AT_AArch64VectorPcs:
5253 case ParsedAttr::AT_AArch64SVEPcs:
5256 case ParsedAttr::AT_AMDGPUKernelCall:
5259 case ParsedAttr::AT_IntelOclBicc:
5262 case ParsedAttr::AT_PreserveMost:
5265 case ParsedAttr::AT_PreserveAll:
5268 case ParsedAttr::AT_M68kRTD:
5271 case ParsedAttr::AT_PreserveNone:
5275 llvm_unreachable(
"unexpected attribute kind");
5286 std::vector<StringRef> DiagnosticIdentifiers;
5287 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
5293 DiagnosticIdentifiers.push_back(RuleName);
5296 SuppressAttr(S.
Context, AL, DiagnosticIdentifiers.data(),
5297 DiagnosticIdentifiers.size()));
5306 unsigned SelectIdx = ~0
U;
5312 if (SelectIdx != ~0
U) {
5313 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_argument)
5325 if (AL.
getKind() == ParsedAttr::AT_Owner) {
5326 if (checkAttrMutualExclusion<PointerAttr>(S, D, AL))
5328 if (
const auto *OAttr = D->
getAttr<OwnerAttr>()) {
5329 const Type *ExistingDerefType = OAttr->getDerefTypeLoc()
5330 ? OAttr->getDerefType().getTypePtr()
5333 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
5336 OAttr->isRegularKeywordAttribute());
5337 S.
Diag(OAttr->getLocation(), diag::note_conflicting_attribute);
5342 Redecl->addAttr(::new (S.
Context) OwnerAttr(S.
Context, AL, DerefTypeLoc));
5345 if (checkAttrMutualExclusion<OwnerAttr>(S, D, AL))
5347 if (
const auto *PAttr = D->
getAttr<PointerAttr>()) {
5348 const Type *ExistingDerefType = PAttr->getDerefTypeLoc()
5349 ? PAttr->getDerefType().getTypePtr()
5352 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
5355 PAttr->isRegularKeywordAttribute());
5356 S.
Diag(PAttr->getLocation(), diag::note_conflicting_attribute);
5361 Redecl->addAttr(::new (S.
Context)
5362 PointerAttr(S.
Context, AL, DerefTypeLoc));
5368 if (checkAttrMutualExclusion<NoRandomizeLayoutAttr>(S, D, AL))
5370 if (!D->
hasAttr<RandomizeLayoutAttr>())
5376 if (checkAttrMutualExclusion<RandomizeLayoutAttr>(S, D, AL))
5378 if (!D->
hasAttr<NoRandomizeLayoutAttr>())
5393 unsigned ReqArgs = Attrs.
getKind() == ParsedAttr::AT_Pcs ? 1 : 0;
5401 case ParsedAttr::AT_CDecl:
5404 case ParsedAttr::AT_FastCall:
5407 case ParsedAttr::AT_StdCall:
5410 case ParsedAttr::AT_ThisCall:
5413 case ParsedAttr::AT_Pascal:
5416 case ParsedAttr::AT_SwiftCall:
5419 case ParsedAttr::AT_SwiftAsyncCall:
5422 case ParsedAttr::AT_VectorCall:
5425 case ParsedAttr::AT_AArch64VectorPcs:
5428 case ParsedAttr::AT_AArch64SVEPcs:
5431 case ParsedAttr::AT_AMDGPUKernelCall:
5434 case ParsedAttr::AT_RegCall:
5437 case ParsedAttr::AT_MSABI:
5441 case ParsedAttr::AT_SysVABI:
5445 case ParsedAttr::AT_Pcs: {
5451 if (StrRef ==
"aapcs") {
5454 }
else if (StrRef ==
"aapcs-vfp") {
5463 case ParsedAttr::AT_IntelOclBicc:
5466 case ParsedAttr::AT_PreserveMost:
5469 case ParsedAttr::AT_PreserveAll:
5472 case ParsedAttr::AT_M68kRTD:
5475 case ParsedAttr::AT_PreserveNone:
5478 default: llvm_unreachable(
"unexpected attribute kind");
5491 bool CheckHost =
false, CheckDevice =
false;
5492 switch (CudaTarget) {
5505 llvm_unreachable(
"unexpected cuda target");
5507 auto *HostTI =
LangOpts.CUDAIsDevice ? Aux : &TI;
5508 auto *DeviceTI =
LangOpts.CUDAIsDevice ? &TI : Aux;
5509 if (CheckHost && HostTI)
5512 A = DeviceTI->checkCallingConvention(CC);
5530 Diag(Attrs.
getLoc(), diag::error_cconv_unsupported)
5535 Diag(Attrs.
getLoc(), diag::warn_cconv_unsupported)
5540 bool IsCXXMethod =
false, IsVariadic =
false;
5593 if (existingAttr->getABI() != abi) {
5594 Diag(CI.
getLoc(), diag::err_attributes_are_not_compatible)
5597 existingAttr->isRegularKeywordAttribute());
5598 Diag(existingAttr->getLocation(), diag::note_conflicting_attribute);
5605 llvm_unreachable(
"explicit attribute for ordinary parameter ABI?");
5609 Diag(CI.
getLoc(), diag::err_swift_abi_parameter_wrong_type)
5617 Diag(CI.
getLoc(), diag::err_swift_abi_parameter_wrong_type)
5625 Diag(CI.
getLoc(), diag::err_swift_abi_parameter_wrong_type)
5633 Diag(CI.
getLoc(), diag::err_swift_abi_parameter_wrong_type)
5639 llvm_unreachable(
"bad parameter ABI attribute");
5661 Diag(AL.
getLoc(), diag::err_attribute_regparm_wrong_platform)
5669 Diag(AL.
getLoc(), diag::err_attribute_regparm_invalid_number)
5681 llvm_unreachable(
"getCudaArch is only valid for NVPTX triple");
5691 const CUDALaunchBoundsAttr &AL,
5692 const unsigned Idx) {
5701 std::optional<llvm::APSInt> I = llvm::APSInt(64);
5708 if (!I->isIntN(32)) {
5710 <<
toString(*I, 10,
false) << 32 << 1;
5714 S.
Diag(E->
getExprLoc(), diag::warn_attribute_argument_n_negative)
5722 "Unexpected PerformCopyInitialization() failure.");
5727CUDALaunchBoundsAttr *
5729 Expr *MinBlocks,
Expr *MaxBlocks) {
5730 CUDALaunchBoundsAttr TmpAttr(
Context, CI, MaxThreads, MinBlocks, MaxBlocks);
5748 MaxBlocks =
nullptr;
5757 CUDALaunchBoundsAttr(
Context, CI, MaxThreads, MinBlocks, MaxBlocks);
5779 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
5797 unsigned ArgumentIdxAST = ArgumentIdx.
getASTIndex();
5800 S.
Diag(AL.
getLoc(), diag::err_attribute_pointers_only) << AL << 0;
5811 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
5819 if (!isa<VarDecl>(D)) {
5820 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_decl_type)
5828 assert(MatchingCTypeLoc &&
"no type source info for attribute argument");
5850 uint32_t Count = 0, Offset = 0;
5857 if (Count < Offset) {
5858 S.
Diag(
getAttrLoc(AL), diag::err_attribute_argument_out_of_range)
5864 PatchableFunctionEntryAttr(S.
Context, AL, Count, Offset));
5868struct IntrinToName {
5877 const char *IntrinNames) {
5878 AliasName.consume_front(
"__arm_");
5879 const IntrinToName *It =
5880 llvm::lower_bound(Map, BuiltinID, [](
const IntrinToName &L,
unsigned Id) {
5883 if (It == Map.end() || It->Id != BuiltinID)
5885 StringRef FullName(&IntrinNames[It->FullName]);
5886 if (AliasName == FullName)
5888 if (It->ShortName == -1)
5890 StringRef ShortName(&IntrinNames[It->ShortName]);
5891 return AliasName == ShortName;
5895#include "clang/Basic/arm_mve_builtin_aliases.inc"
5903#include "clang/Basic/arm_cde_builtin_aliases.inc"
5908 StringRef AliasName) {
5916 StringRef AliasName) {
5925 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
5932 StringRef AliasName = cast<FunctionDecl>(D)->getIdentifier()->getName();
5939 S.
Diag(AL.
getLoc(), diag::err_attribute_arm_builtin_alias);
5954 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
5961 StringRef AliasName = cast<FunctionDecl>(D)->getIdentifier()->getName();
5971 (!IsAArch64 && !IsARM && !IsRISCV && !IsHLSL)) {
5972 S.
Diag(AL.
getLoc(), diag::err_attribute_builtin_alias) << AL;
5981 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
5987 assert(ParmTSI &&
"no type source info for attribute argument");
5989 diag::err_incomplete_type);
6020 bool IsTemplateInstantiation) {
6024 handleSimpleAttributeOrDiagnose<OSConsumedAttr>(
6026 diag::warn_ns_attribute_wrong_parameter_type,
6030 handleSimpleAttributeOrDiagnose<NSConsumedAttr>(
6037 ((IsTemplateInstantiation &&
getLangOpts().ObjCAutoRefCount)
6038 ? diag::err_ns_attribute_wrong_parameter_type
6039 : diag::warn_ns_attribute_wrong_parameter_type),
6043 handleSimpleAttributeOrDiagnose<CFConsumedAttr>(
6045 diag::warn_ns_attribute_wrong_parameter_type,
6054 case ParsedAttr::AT_CFConsumed:
6055 case ParsedAttr::AT_CFReturnsRetained:
6056 case ParsedAttr::AT_CFReturnsNotRetained:
6058 case ParsedAttr::AT_OSConsumesThis:
6059 case ParsedAttr::AT_OSConsumed:
6060 case ParsedAttr::AT_OSReturnsRetained:
6061 case ParsedAttr::AT_OSReturnsNotRetained:
6062 case ParsedAttr::AT_OSReturnsRetainedOnZero:
6063 case ParsedAttr::AT_OSReturnsRetainedOnNonZero:
6065 case ParsedAttr::AT_NSConsumesSelf:
6066 case ParsedAttr::AT_NSConsumed:
6067 case ParsedAttr::AT_NSReturnsRetained:
6068 case ParsedAttr::AT_NSReturnsNotRetained:
6069 case ParsedAttr::AT_NSReturnsAutoreleased:
6072 llvm_unreachable(
"Wrong argument supplied");
6080 Diag(Loc, diag::warn_ns_attribute_wrong_return_type)
6081 <<
"'ns_returns_retained'" << 0 << 0;
6087 const auto *PVD = dyn_cast<ParmVarDecl>(D);
6100 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
6101 ReturnType = MD->getReturnType();
6103 (AL.
getKind() == ParsedAttr::AT_NSReturnsRetained)) {
6105 }
else if (
const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
6106 ReturnType = PD->getType();
6107 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
6109 }
else if (
const auto *Param = dyn_cast<ParmVarDecl>(D)) {
6116 if (ReturnType.
isNull()) {
6117 S.
Diag(D->
getBeginLoc(), diag::warn_ns_attribute_wrong_parameter_type)
6126 default: llvm_unreachable(
"invalid ownership attribute");
6127 case ParsedAttr::AT_NSReturnsRetained:
6128 case ParsedAttr::AT_NSReturnsAutoreleased:
6129 case ParsedAttr::AT_NSReturnsNotRetained:
6133 case ParsedAttr::AT_OSReturnsRetained:
6134 case ParsedAttr::AT_OSReturnsNotRetained:
6135 case ParsedAttr::AT_CFReturnsRetained:
6136 case ParsedAttr::AT_CFReturnsNotRetained:
6142 << ExpectedDeclKind;
6148 unsigned ParmDiagID = 2;
6150 default: llvm_unreachable(
"invalid ownership attribute");
6151 case ParsedAttr::AT_NSReturnsRetained:
6156 case ParsedAttr::AT_NSReturnsAutoreleased:
6157 case ParsedAttr::AT_NSReturnsNotRetained:
6162 case ParsedAttr::AT_CFReturnsRetained:
6163 case ParsedAttr::AT_CFReturnsNotRetained:
6168 case ParsedAttr::AT_OSReturnsRetained:
6169 case ParsedAttr::AT_OSReturnsNotRetained:
6180 if (isa<ParmVarDecl>(D)) {
6181 S.
Diag(D->
getBeginLoc(), diag::warn_ns_attribute_wrong_parameter_type)
6182 << AL << ParmDiagID << AL.
getRange();
6190 if (isa<ObjCMethodDecl>(D))
6191 SubjectKind = Method;
6192 else if (isa<ObjCPropertyDecl>(D))
6195 << AL << SubjectKind << Cf << AL.
getRange();
6202 llvm_unreachable(
"invalid ownership attribute");
6203 case ParsedAttr::AT_NSReturnsAutoreleased:
6204 handleSimpleAttribute<NSReturnsAutoreleasedAttr>(S, D, AL);
6206 case ParsedAttr::AT_CFReturnsNotRetained:
6207 handleSimpleAttribute<CFReturnsNotRetainedAttr>(S, D, AL);
6209 case ParsedAttr::AT_NSReturnsNotRetained:
6210 handleSimpleAttribute<NSReturnsNotRetainedAttr>(S, D, AL);
6212 case ParsedAttr::AT_CFReturnsRetained:
6213 handleSimpleAttribute<CFReturnsRetainedAttr>(S, D, AL);
6215 case ParsedAttr::AT_NSReturnsRetained:
6216 handleSimpleAttribute<NSReturnsRetainedAttr>(S, D, AL);
6218 case ParsedAttr::AT_OSReturnsRetained:
6219 handleSimpleAttribute<OSReturnsRetainedAttr>(S, D, AL);
6221 case ParsedAttr::AT_OSReturnsNotRetained:
6222 handleSimpleAttribute<OSReturnsNotRetainedAttr>(S, D, AL);
6229 const int EP_ObjCMethod = 1;
6230 const int EP_ObjCProperty = 2;
6234 if (isa<ObjCMethodDecl>(D))
6235 resultType = cast<ObjCMethodDecl>(D)->getReturnType();
6237 resultType = cast<ObjCPropertyDecl>(D)->getType();
6243 << (isa<ObjCMethodDecl>(D) ? EP_ObjCMethod : EP_ObjCProperty)
6255 const auto *Method = cast<ObjCMethodDecl>(D);
6258 if (
const auto *PDecl = dyn_cast_if_present<ObjCProtocolDecl>(DC)) {
6259 S.
Diag(D->
getBeginLoc(), diag::warn_objc_requires_super_protocol) << Attrs
6261 S.
Diag(PDecl->getLocation(), diag::note_protocol_decl);
6265 S.
Diag(D->
getBeginLoc(), diag::warn_objc_requires_super_protocol) << Attrs
6274 if (!isa<TagDecl>(D)) {
6280 Attr.isArgIdent(0) ?
Attr.getArgAsIdent(0) :
nullptr;
6281 if (!IdentLoc || !IdentLoc->
Ident) {
6284 if (
Attr.isArgExpr(0) &&
Attr.getArgAsExpr(0))
6285 Loc =
Attr.getArgAsExpr(0)->getBeginLoc();
6287 S.
Diag(Loc, diag::err_nserrordomain_invalid_decl) << 0;
6295 S.
Diag(IdentLoc->
Loc, diag::err_nserrordomain_invalid_decl)
6296 << 1 << IdentLoc->
Ident;
6313 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
6315 S.
Diag(AL.
getLoc(), diag::err_objc_attr_typedef_not_id) << AL;
6320 QualType T = TD->getUnderlyingType();
6322 S.
Diag(AL.
getLoc(), diag::err_objc_attr_typedef_not_void_pointer);
6347 if (!RelatedClass) {
6356 S.
Context, AL, RelatedClass, ClassMethod, InstanceMethod));
6365 if (!isa<ObjCInterfaceDecl>(Ctx) &&
6366 !(isa<ObjCCategoryDecl>(Ctx) &&
6367 cast<ObjCCategoryDecl>(Ctx)->IsClassExtension())) {
6373 if (
auto *CatDecl = dyn_cast<ObjCCategoryDecl>(Ctx))
6374 IFace = CatDecl->getClassInterface();
6376 IFace = cast<ObjCInterfaceDecl>(Ctx);
6386 StringRef MetaDataName;
6390 ObjCRuntimeNameAttr(S.
Context, AL, MetaDataName));
6398 bool notify =
false;
6400 auto *RD = dyn_cast<RecordDecl>(D);
6401 if (RD && RD->getDefinition()) {
6402 RD = RD->getDefinition();
6407 ObjCBoxableAttr *BoxableAttr =
6409 RD->addAttr(BoxableAttr);
6414 L->AddedAttributeToRecord(BoxableAttr, RD);
6430 const auto *VD = cast<ValueDecl>(D);
6435 S.
Diag(AL.
getLoc(), diag::err_objc_precise_lifetime_bad_type)
6450 "didn't infer lifetime for non-dependent type?");
6459 S.
Diag(AL.
getLoc(), diag::warn_objc_precise_lifetime_meaningless)
6486 if (
const auto *
Other = D->
getAttr<SwiftBridgeAttr>()) {
6487 if (
Other->getSwiftType() != BT)
6488 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
6504 if (
const auto *ID = OPT->getInterfaceDecl())
6510 if (
const auto *RT = PT->getPointeeType()->getAs<
RecordType>())
6524 S.
Diag(AL.
getLoc(), diag::err_attr_swift_error_no_error_parameter)
6525 << AL << isa<ObjCMethodDecl>(D);
6537 S.
Diag(AL.
getLoc(), diag::err_attr_swift_error_return_type)
6548 S.
Diag(AL.
getLoc(), diag::err_attr_swift_error_return_type)
6558 SwiftErrorAttr::ConventionKind Convention;
6559 if (!SwiftErrorAttr::ConvertStrToConventionKind(Loc->
Ident->
getName(),
6561 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
6562 << AL << Loc->
Ident;
6566 switch (Convention) {
6567 case SwiftErrorAttr::None:
6571 case SwiftErrorAttr::NonNullError:
6572 if (!hasErrorParameter(S, D, AL))
6576 case SwiftErrorAttr::NullResult:
6577 if (!hasErrorParameter(S, D, AL) || !hasPointerResult(S, D, AL))
6581 case SwiftErrorAttr::NonZeroResult:
6582 case SwiftErrorAttr::ZeroResult:
6583 if (!hasErrorParameter(S, D, AL) || !hasIntegerResult(S, D, AL))
6592 const SwiftAsyncErrorAttr *ErrorAttr,
6593 const SwiftAsyncAttr *AsyncAttr) {
6594 if (AsyncAttr->getKind() == SwiftAsyncAttr::None) {
6595 if (ErrorAttr->getConvention() != SwiftAsyncErrorAttr::None) {
6596 S.
Diag(AsyncAttr->getLocation(),
6597 diag::err_swift_async_error_without_swift_async)
6598 << AsyncAttr << isa<ObjCMethodDecl>(D);
6604 D, AsyncAttr->getCompletionHandlerIndex().getASTIndex());
6607 const auto *FuncTy = HandlerParam->
getType()
6613 BlockParams = FuncTy->getParamTypes();
6615 switch (ErrorAttr->getConvention()) {
6616 case SwiftAsyncErrorAttr::ZeroArgument:
6617 case SwiftAsyncErrorAttr::NonZeroArgument: {
6618 uint32_t
ParamIdx = ErrorAttr->getHandlerParamIdx();
6620 S.
Diag(ErrorAttr->getLocation(),
6621 diag::err_attribute_argument_out_of_bounds) << ErrorAttr << 2;
6627 ErrorAttr->getConvention() == SwiftAsyncErrorAttr::ZeroArgument
6629 :
"nonzero_argument";
6630 S.
Diag(ErrorAttr->getLocation(), diag::err_swift_async_error_non_integral)
6631 << ErrorAttr << ConvStr <<
ParamIdx << ErrorParam;
6636 case SwiftAsyncErrorAttr::NonNullError: {
6637 bool AnyErrorParams =
false;
6638 for (
QualType Param : BlockParams) {
6641 if (
const auto *ID = ObjCPtrTy->getInterfaceDecl()) {
6643 AnyErrorParams =
true;
6649 if (
const auto *PtrTy = Param->getAs<
PointerType>()) {
6650 if (
const auto *RT = PtrTy->getPointeeType()->getAs<
RecordType>()) {
6652 AnyErrorParams =
true;
6659 if (!AnyErrorParams) {
6660 S.
Diag(ErrorAttr->getLocation(),
6661 diag::err_swift_async_error_no_error_parameter)
6662 << ErrorAttr << isa<ObjCMethodDecl>(D);
6667 case SwiftAsyncErrorAttr::None:
6674 SwiftAsyncErrorAttr::ConventionKind ConvKind;
6675 if (!SwiftAsyncErrorAttr::ConvertStrToConventionKind(IDLoc->
Ident->
getName(),
6677 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
6678 << AL << IDLoc->
Ident;
6684 case SwiftAsyncErrorAttr::ZeroArgument:
6685 case SwiftAsyncErrorAttr::NonZeroArgument: {
6694 case SwiftAsyncErrorAttr::NonNullError:
6695 case SwiftAsyncErrorAttr::None: {
6706 if (
auto *AsyncAttr = D->
getAttr<SwiftAsyncAttr>())
6720 StringRef Name,
unsigned &SwiftParamCount,
6721 bool &IsSingleParamInit) {
6722 SwiftParamCount = 0;
6723 IsSingleParamInit =
false;
6726 bool IsGetter =
false, IsSetter =
false;
6727 if (Name.consume_front(
"getter:"))
6729 else if (Name.consume_front(
"setter:"))
6732 if (Name.back() !=
')') {
6733 S.
Diag(Loc, diag::warn_attr_swift_name_function) << AL;
6737 bool IsMember =
false;
6738 StringRef ContextName, BaseName, Parameters;
6740 std::tie(BaseName, Parameters) = Name.split(
'(');
6744 std::tie(ContextName, BaseName) = BaseName.split(
'.');
6745 if (BaseName.empty()) {
6746 BaseName = ContextName;
6747 ContextName = StringRef();
6749 S.
Diag(Loc, diag::warn_attr_swift_name_invalid_identifier)
6757 S.
Diag(Loc, diag::warn_attr_swift_name_invalid_identifier)
6762 bool IsSubscript = BaseName ==
"subscript";
6764 if (IsSubscript && !IsGetter && !IsSetter) {
6765 S.
Diag(Loc, diag::warn_attr_swift_name_subscript_invalid_parameter)
6770 if (Parameters.empty()) {
6771 S.
Diag(Loc, diag::warn_attr_swift_name_missing_parameters) << AL;
6775 assert(Parameters.back() ==
')' &&
"expected ')'");
6776 Parameters = Parameters.drop_back();
6778 if (Parameters.empty()) {
6781 S.
Diag(Loc, diag::warn_attr_swift_name_subscript_invalid_parameter)
6787 S.
Diag(Loc, diag::warn_attr_swift_name_setter_parameters) << AL;
6794 if (Parameters.back() !=
':') {
6795 S.
Diag(Loc, diag::warn_attr_swift_name_function) << AL;
6799 StringRef CurrentParam;
6800 std::optional<unsigned> SelfLocation;
6801 unsigned NewValueCount = 0;
6802 std::optional<unsigned> NewValueLocation;
6804 std::tie(CurrentParam, Parameters) = Parameters.split(
':');
6807 S.
Diag(Loc, diag::warn_attr_swift_name_invalid_identifier)
6812 if (IsMember && CurrentParam ==
"self") {
6817 S.
Diag(Loc, diag::warn_attr_swift_name_multiple_selfs) << AL;
6822 SelfLocation = SwiftParamCount;
6823 }
else if (CurrentParam ==
"newValue") {
6830 NewValueLocation = SwiftParamCount;
6834 }
while (!Parameters.empty());
6837 if (IsSubscript && !SelfLocation) {
6838 S.
Diag(Loc, diag::warn_attr_swift_name_subscript_invalid_parameter)
6844 SwiftParamCount == 1 && BaseName ==
"init" && CurrentParam !=
"_";
6847 if (IsGetter || IsSetter) {
6849 unsigned NumExpectedParams = IsGetter ? 0 : 1;
6850 unsigned ParamDiag =
6851 IsGetter ? diag::warn_attr_swift_name_getter_parameters
6852 : diag::warn_attr_swift_name_setter_parameters;
6856 ++NumExpectedParams;
6861 if (SwiftParamCount < NumExpectedParams) {
6862 S.
Diag(Loc, ParamDiag) << AL;
6869 if (!NewValueLocation) {
6870 S.
Diag(Loc, diag::warn_attr_swift_name_subscript_setter_no_newValue)
6874 if (NewValueCount > 1) {
6875 S.
Diag(Loc, diag::warn_attr_swift_name_subscript_setter_multiple_newValues)
6881 if (NewValueLocation) {
6882 S.
Diag(Loc, diag::warn_attr_swift_name_subscript_getter_newValue)
6889 if (SwiftParamCount != NumExpectedParams) {
6890 S.
Diag(Loc, ParamDiag) << AL;
6901 if (isa<ObjCMethodDecl>(D) || isa<FunctionDecl>(D)) {
6903 unsigned ParamCount;
6905 if (
const auto *Method = dyn_cast<ObjCMethodDecl>(D)) {
6906 ParamCount = Method->getSelector().getNumArgs();
6907 Params = Method->parameters().slice(0, ParamCount);
6909 const auto *F = cast<FunctionDecl>(D);
6911 ParamCount = F->getNumParams();
6912 Params = F->parameters();
6914 if (!F->hasWrittenPrototype()) {
6915 Diag(Loc, diag::warn_attribute_wrong_decl_type)
6924 if (ParamCount == 0) {
6925 Diag(Loc, diag::warn_attr_swift_name_decl_missing_params)
6926 << AL << isa<ObjCMethodDecl>(D);
6932 unsigned SwiftParamCount;
6933 bool IsSingleParamInit;
6935 SwiftParamCount, IsSingleParamInit))
6938 bool ParamCountValid;
6939 if (SwiftParamCount == ParamCount) {
6940 ParamCountValid =
true;
6941 }
else if (SwiftParamCount > ParamCount) {
6942 ParamCountValid = IsSingleParamInit && ParamCount == 0;
6947 unsigned MaybeOutParamCount =
6948 llvm::count_if(Params, [](
const ParmVarDecl *Param) ->
bool {
6955 ParamCountValid = SwiftParamCount + MaybeOutParamCount >= ParamCount;
6958 if (!ParamCountValid) {
6959 Diag(Loc, diag::warn_attr_swift_name_num_params)
6960 << (SwiftParamCount > ParamCount) << AL << ParamCount
6964 }
else if ((isa<EnumConstantDecl>(D) || isa<ObjCProtocolDecl>(D) ||
6965 isa<ObjCInterfaceDecl>(D) || isa<ObjCPropertyDecl>(D) ||
6966 isa<VarDecl>(D) || isa<TypedefNameDecl>(D) || isa<TagDecl>(D) ||
6967 isa<IndirectFieldDecl>(D) || isa<FieldDecl>(D)) &&
6969 StringRef ContextName, BaseName;
6971 std::tie(ContextName, BaseName) = Name.split(
'.');
6972 if (BaseName.empty()) {
6973 BaseName = ContextName;
6974 ContextName = StringRef();
6976 Diag(Loc, diag::warn_attr_swift_name_invalid_identifier) << AL
6982 Diag(Loc, diag::warn_attr_swift_name_invalid_identifier) << AL
6987 Diag(Loc, diag::warn_attr_swift_name_decl_kind) << AL;
7023 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7028 SwiftNewTypeAttr::NewtypeKind Kind;
7030 if (!SwiftNewTypeAttr::ConvertStrToNewtypeKind(II->
getName(), Kind)) {
7031 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
7035 if (!isa<TypedefNameDecl>(D)) {
7036 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type_str)
7046 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
7051 SwiftAsyncAttr::Kind Kind;
7053 if (!SwiftAsyncAttr::ConvertStrToKind(II->
getName(), Kind)) {
7054 S.
Diag(AL.
getLoc(), diag::err_swift_async_no_access) << AL << II;
7059 if (Kind == SwiftAsyncAttr::None) {
7077 diag::err_swift_async_bad_block_type)
7078 << CompletionBlock->
getType();
7085 diag::err_swift_async_bad_block_type)
7086 << CompletionBlock->
getType();
7095 if (
auto *ErrorAttr = D->
getAttr<SwiftAsyncErrorAttr>())
7104 StringRef UuidAsWritten,
MSGuidDecl *GuidDecl) {
7105 if (
const auto *UA = D->
getAttr<UuidAttr>()) {
7108 if (!UA->getGuid().empty()) {
7109 Diag(UA->getLocation(), diag::err_mismatched_uuid);
7115 return ::new (
Context) UuidAttr(
Context, CI, UuidAsWritten, GuidDecl);
7120 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
7125 StringRef OrigStrRef;
7132 StringRef StrRef = OrigStrRef;
7133 if (StrRef.size() == 38 && StrRef.front() ==
'{' && StrRef.back() ==
'}')
7134 StrRef = StrRef.drop_front().drop_back();
7137 if (StrRef.size() != 36) {
7138 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
7142 for (
unsigned i = 0; i < 36; ++i) {
7143 if (i == 8 || i == 13 || i == 18 || i == 23) {
7144 if (StrRef[i] !=
'-') {
7145 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
7149 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
7156 StrRef.substr(0, 8).getAsInteger(16, Parsed.
Part1);
7157 StrRef.substr(9, 4).getAsInteger(16, Parsed.
Part2);
7158 StrRef.substr(14, 4).getAsInteger(16, Parsed.
Part3);
7159 for (
unsigned i = 0; i != 8; ++i)
7160 StrRef.substr(19 + 2 * i + (i >= 2 ? 1 : 0), 2)
7171 S.
Diag(AL.
getLoc(), diag::warn_atl_uuid_deprecated);
7179 llvm::VersionTuple SMVersion =
7181 uint32_t ZMax = 1024;
7182 uint32_t ThreadMax = 1024;
7183 if (SMVersion.getMajor() <= 4) {
7186 }
else if (SMVersion.getMajor() == 5) {
7196 diag::err_hlsl_numthreads_argument_oor) << 0 << 1024;
7204 diag::err_hlsl_numthreads_argument_oor) << 1 << 1024;
7212 diag::err_hlsl_numthreads_argument_oor) << 2 << ZMax;
7216 if (
X * Y * Z > ThreadMax) {
7217 S.
Diag(AL.
getLoc(), diag::err_hlsl_numthreads_invalid) << ThreadMax;
7228 int X,
int Y,
int Z) {
7229 if (HLSLNumThreadsAttr *NT = D->
getAttr<HLSLNumThreadsAttr>()) {
7230 if (NT->getX() !=
X || NT->getY() != Y || NT->getZ() != Z) {
7231 Diag(NT->getLocation(), diag::err_hlsl_attribute_param_mismatch) << AL;
7232 Diag(AL.
getLoc(), diag::note_conflicting_attribute);
7243 return VT->getNumElements() <= 3;
7251 if (isa<FieldDecl>(D)) {
7252 S.
Diag(AL.
getLoc(), diag::err_hlsl_attr_invalid_ast_node)
7253 << AL <<
"parameter";
7257 auto *VD = cast<ValueDecl>(D);
7259 S.
Diag(AL.
getLoc(), diag::err_hlsl_attr_invalid_type)
7260 << AL <<
"uint/uint2/uint3";
7273 HLSLShaderAttr::ShaderType ShaderType;
7274 if (!HLSLShaderAttr::ConvertStrToShaderType(Str, ShaderType)) {
7275 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
7276 << AL << Str << ArgLoc;
7289 HLSLShaderAttr::ShaderType ShaderType) {
7290 if (HLSLShaderAttr *NT = D->
getAttr<HLSLShaderAttr>()) {
7291 if (NT->getType() != ShaderType) {
7292 Diag(NT->getLocation(), diag::err_hlsl_attribute_param_mismatch) << AL;
7293 Diag(AL.
getLoc(), diag::note_conflicting_attribute);
7297 return HLSLShaderAttr::Create(
Context, ShaderType, AL);
7302 StringRef Space =
"space0";
7303 StringRef Slot =
"";
7306 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7319 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7326 SpaceArgLoc = Loc->
Loc;
7332 if (!Slot.empty()) {
7340 S.
Diag(ArgLoc, diag::err_hlsl_unsupported_register_type)
7341 << Slot.substr(0, 1);
7345 StringRef SlotNum = Slot.substr(1);
7347 if (SlotNum.getAsInteger(10, Num)) {
7348 S.
Diag(ArgLoc, diag::err_hlsl_unsupported_register_number);
7353 if (!Space.starts_with(
"space")) {
7354 S.
Diag(SpaceArgLoc, diag::err_hlsl_expected_space) << Space;
7357 StringRef SpaceNum = Space.substr(5);
7359 if (SpaceNum.getAsInteger(10, Num)) {
7360 S.
Diag(SpaceArgLoc, diag::err_hlsl_expected_space) << Space;
7366 HLSLResourceBindingAttr *NewAttr =
7367 HLSLResourceBindingAttr::Create(S.
getASTContext(), Slot, Space, AL);
7381HLSLParamModifierAttr *
7383 HLSLParamModifierAttr::Spelling Spelling) {
7386 if (HLSLParamModifierAttr *PA = D->
getAttr<HLSLParamModifierAttr>()) {
7387 if ((PA->isIn() && Spelling == HLSLParamModifierAttr::Keyword_out) ||
7388 (PA->isOut() && Spelling == HLSLParamModifierAttr::Keyword_in)) {
7389 D->
dropAttr<HLSLParamModifierAttr>();
7391 return HLSLParamModifierAttr::Create(
7393 HLSLParamModifierAttr::Keyword_inout);
7395 Diag(AL.
getLoc(), diag::err_hlsl_duplicate_parameter_modifier) << AL;
7396 Diag(PA->getLocation(), diag::note_conflicting_attribute);
7399 return HLSLParamModifierAttr::Create(
Context, AL);
7404 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
7417 const auto *VD = cast<VarDecl>(D);
7419 S.
Diag(AL.
getLoc(), diag::err_thread_unsupported);
7423 S.
Diag(AL.
getLoc(), diag::err_declspec_thread_on_thread_variable);
7426 if (VD->hasLocalStorage()) {
7427 S.
Diag(AL.
getLoc(), diag::err_thread_non_global) <<
"__declspec(thread)";
7435 S.
Diag(AL.
getLoc(), diag::warn_unknown_attribute_ignored)
7439 auto *FD = cast<FunctionDecl>(D);
7441 S.
Diag(AL.
getLoc(), diag::err_ms_constexpr_cannot_be_applied)
7445 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
7446 if (!S.
getLangOpts().CPlusPlus20 && MD->isVirtual()) {
7447 S.
Diag(AL.
getLoc(), diag::err_ms_constexpr_cannot_be_applied)
7457 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
7461 Tags.push_back(Tag);
7464 if (
const auto *NS = dyn_cast<NamespaceDecl>(D)) {
7465 if (!NS->isInline()) {
7466 S.
Diag(AL.
getLoc(), diag::warn_attr_abi_tag_namespace) << 0;
7469 if (NS->isAnonymousNamespace()) {
7470 S.
Diag(AL.
getLoc(), diag::warn_attr_abi_tag_namespace) << 1;
7474 Tags.push_back(NS->getName());
7480 Tags.erase(std::unique(Tags.begin(), Tags.end()), Tags.end());
7483 AbiTagAttr(S.
Context, AL, Tags.data(), Tags.size()));
7489 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 1;
7501 ARMInterruptAttr::InterruptType Kind;
7502 if (!ARMInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
7503 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << Str
7537 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7543 std::optional<llvm::APSInt> NumParams = llvm::APSInt(32);
7545 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7551 unsigned Num = NumParams->getLimitedValue(255);
7553 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
7554 << AL << (
int)NumParams->getSExtValue()
7566 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 1;
7607 if (checkAttrMutualExclusion<Mips16Attr>(S, D, AL))
7610 MipsInterruptAttr::InterruptType Kind;
7611 if (!MipsInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
7612 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
7613 << AL <<
"'" + std::string(Str) +
"'";
7625 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7634 if (!MaybeNumParams) {
7635 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7641 unsigned Num = MaybeNumParams->getLimitedValue(255);
7642 if ((Num & 1) || Num > 30) {
7643 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
7644 << AL << (
int)MaybeNumParams->getSExtValue()
7662 cast<NamedDecl>(D)->getDeclName().getCXXOverloadedOperator())) {
7663 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
7671 diag::err_anyx86_interrupt_attribute)
7680 if (NumParams < 1 || NumParams > 2) {
7691 diag::err_anyx86_interrupt_attribute)
7703 if (NumParams == 2 &&
7707 diag::err_anyx86_interrupt_attribute)
7728 handleSimpleAttribute<AVRInterruptAttr>(S, D, AL);
7741 handleSimpleAttribute<AVRSignalAttr>(S, D, AL);
7746 for (
auto *D : RD->
decls()) {
7747 if (D->hasAttr<BPFPreserveAccessIndexAttr>())
7750 D->addAttr(BPFPreserveAccessIndexAttr::CreateImplicit(S.
Context));
7751 if (
auto *Rec = dyn_cast<RecordDecl>(D))
7758 auto *Rec = cast<RecordDecl>(D);
7760 Rec->addAttr(::new (S.
Context) BPFPreserveAccessIndexAttr(S.
Context, AL));
7765 if (I->getBTFDeclTag() == Tag)
7784 return ::new (
Context) BTFDeclTagAttr(
Context, AL, AL.getBTFDeclTag());
7795 auto *FD = cast<FunctionDecl>(D);
7810WebAssemblyImportModuleAttr *
7812 auto *FD = cast<FunctionDecl>(D);
7814 if (
const auto *ExistingAttr = FD->
getAttr<WebAssemblyImportModuleAttr>()) {
7815 if (ExistingAttr->getImportModule() == AL.getImportModule())
7817 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_import) << 0
7818 << ExistingAttr->getImportModule() << AL.getImportModule();
7819 Diag(AL.getLoc(), diag::note_previous_attribute);
7823 Diag(AL.getLoc(), diag::warn_import_on_definition) << 0;
7827 AL.getImportModule());
7830WebAssemblyImportNameAttr *
7832 auto *FD = cast<FunctionDecl>(D);
7834 if (
const auto *ExistingAttr = FD->
getAttr<WebAssemblyImportNameAttr>()) {
7835 if (ExistingAttr->getImportName() == AL.getImportName())
7837 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_import) << 1
7838 << ExistingAttr->getImportName() << AL.getImportName();
7839 Diag(AL.getLoc(), diag::note_previous_attribute);
7843 Diag(AL.getLoc(), diag::warn_import_on_definition) << 1;
7847 AL.getImportName());
7852 auto *FD = cast<FunctionDecl>(D);
7859 S.
Diag(AL.
getLoc(), diag::warn_import_on_definition) << 0;
7864 WebAssemblyImportModuleAttr(S.
Context, AL, Str));
7869 auto *FD = cast<FunctionDecl>(D);
7876 S.
Diag(AL.
getLoc(), diag::warn_import_on_definition) << 1;
7886 if (
const auto *A = D->
getAttr<RISCVInterruptAttr>()) {
7888 diag::warn_riscv_repeated_interrupt_attribute);
7889 S.
Diag(A->getLocation(), diag::note_riscv_repeated_interrupt_attribute);
7931 RISCVInterruptAttr::InterruptType Kind;
7932 if (!RISCVInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
7933 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << Str
7944 case llvm::Triple::msp430:
7947 case llvm::Triple::mipsel:
7948 case llvm::Triple::mips:
7951 case llvm::Triple::m68k:
7954 case llvm::Triple::x86:
7955 case llvm::Triple::x86_64:
7958 case llvm::Triple::avr:
7961 case llvm::Triple::riscv32:
7962 case llvm::Triple::riscv64:
7973 const AMDGPUFlatWorkGroupSizeAttr &
Attr) {
7987 if (
Min == 0 &&
Max != 0) {
8001AMDGPUFlatWorkGroupSizeAttr *
8004 AMDGPUFlatWorkGroupSizeAttr TmpAttr(
Context, CI, MinExpr, MaxExpr);
8009 AMDGPUFlatWorkGroupSizeAttr(
Context, CI, MinExpr, MaxExpr);
8029 const AMDGPUWavesPerEUAttr &
Attr) {
8047 if (
Min == 0 &&
Max != 0) {
8061AMDGPUWavesPerEUAttr *
8064 AMDGPUWavesPerEUAttr TmpAttr(
Context, CI, MinExpr, MaxExpr);
8069 return ::new (
Context) AMDGPUWavesPerEUAttr(
Context, CI, MinExpr, MaxExpr);
8089 uint32_t NumSGPR = 0;
8098 uint32_t NumVGPR = 0;
8109 const AMDGPUMaxNumWorkGroupsAttr &
Attr) {
8122 Expr *Exprs[3] = {XExpr, YExpr, ZExpr};
8123 for (
int i = 0; i < 3; i++) {
8139AMDGPUMaxNumWorkGroupsAttr *
8142 AMDGPUMaxNumWorkGroupsAttr TmpAttr(
Context, CI, XExpr, YExpr, ZExpr);
8148 AMDGPUMaxNumWorkGroupsAttr(
Context, CI, XExpr, YExpr, ZExpr);
8170 const auto *VD = dyn_cast<ValueDecl>(D);
8171 if (VD && VD->getType()->isFunctionPointerType())
8174 const auto *TD = dyn_cast<TypedefNameDecl>(D);
8175 if (TD && (TD->getUnderlyingType()->isFunctionPointerType() ||
8176 TD->getUnderlyingType()->isFunctionType()))
8179 if (!isa<FunctionDecl>(D)) {
8180 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
8196 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
8211 if (D->
hasAttr<DLLExportAttr>()) {
8212 Diag(CI.
getLoc(), diag::warn_attribute_ignored) <<
"'dllimport'";
8216 if (D->
hasAttr<DLLImportAttr>())
8224 if (DLLImportAttr *Import = D->
getAttr<DLLImportAttr>()) {
8225 Diag(Import->getLocation(), diag::warn_attribute_ignored) << Import;
8229 if (D->
hasAttr<DLLExportAttr>())
8236 if (isa<ClassTemplatePartialSpecializationDecl>(D) &&
8242 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
8252 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
8254 MD->getParent()->isLambda()) {
8260 Attr *NewAttr = A.
getKind() == ParsedAttr::AT_DLLExport
8271 if (MSInheritanceAttr *IA = D->
getAttr<MSInheritanceAttr>()) {
8272 if (IA->getInheritanceModel() == Model)
8274 Diag(IA->getLocation(), diag::err_mismatched_ms_inheritance)
8276 Diag(CI.
getLoc(), diag::note_previous_ms_inheritance);
8280 auto *RD = cast<CXXRecordDecl>(D);
8281 if (RD->hasDefinition()) {
8287 if (isa<ClassTemplatePartialSpecializationDecl>(RD)) {
8288 Diag(CI.
getLoc(), diag::warn_ignored_ms_inheritance)
8292 if (RD->getDescribedClassTemplate()) {
8293 Diag(CI.
getLoc(), diag::warn_ignored_ms_inheritance)
8311 StringRef N(
"mutex");
8313 if (AL.
getKind() == ParsedAttr::AT_Capability &&
8326 AssertCapabilityAttr(S.
Context, AL, Args.data(), Args.size()));
8370 RequiresCapabilityAttr *RCA = ::new (S.
Context)
8371 RequiresCapabilityAttr(S.
Context, AL, Args.data(), Args.size());
8377 if (
const auto *NSD = dyn_cast<NamespaceDecl>(D)) {
8378 if (NSD->isAnonymousNamespace()) {
8379 S.
Diag(AL.
getLoc(), diag::warn_deprecated_anonymous_namespace);
8393 StringRef Str, Replacement;
8406 S.
Diag(AL.
getLoc(), diag::ext_cxx14_attr) << AL;
8412 if (
const auto *S = dyn_cast<VarDecl>(D))
8413 return S->hasGlobalStorage();
8418 return Sanitizer ==
"address" || Sanitizer ==
"hwaddress" ||
8419 Sanitizer ==
"memtag";
8426 std::vector<StringRef> Sanitizers;
8428 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
8429 StringRef SanitizerName;
8437 SanitizerName !=
"coverage")
8438 S.
Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << SanitizerName;
8440 S.
Diag(D->
getLocation(), diag::warn_attribute_type_not_supported_global)
8441 << AL << SanitizerName;
8442 Sanitizers.push_back(SanitizerName);
8446 Sanitizers.size()));
8453 StringRef SanitizerName = llvm::StringSwitch<StringRef>(AttrName)
8454 .Case(
"no_address_safety_analysis",
"address")
8455 .Case(
"no_sanitize_address",
"address")
8456 .Case(
"no_sanitize_thread",
"thread")
8457 .Case(
"no_sanitize_memory",
"memory");
8470 unsigned TranslatedSpellingIndex = 0;
8472 TranslatedSpellingIndex = 1;
8477 NoSanitizeAttr(S.
Context, Info, &SanitizerName, 1));
8487 S.
Diag(AL.
getLoc(), diag::err_attribute_requires_opencl_version)
8488 << AL <<
"2.0" << 1;
8490 S.
Diag(AL.
getLoc(), diag::warn_opencl_attr_deprecated_ignored)
8499 if (D->
hasAttr<OpenCLAccessAttr>()) {
8500 if (D->
getAttr<OpenCLAccessAttr>()->getSemanticSpelling() ==
8502 S.
Diag(AL.
getLoc(), diag::warn_duplicate_declspec)
8505 S.
Diag(AL.
getLoc(), diag::err_opencl_multiple_access_qualifiers)
8521 if (
const auto *PDecl = dyn_cast<ParmVarDecl>(D)) {
8522 const Type *DeclTy = PDecl->getType().getCanonicalType().getTypePtr();
8524 bool ReadWriteImagesUnsupported =
8529 if (ReadWriteImagesUnsupported || DeclTy->isPipeType()) {
8530 S.
Diag(AL.
getLoc(), diag::err_opencl_invalid_read_write)
8531 << AL << PDecl->getType() << DeclTy->isImageType();
8548 ZeroCallUsedRegsAttr::ZeroCallUsedRegsKind Kind;
8549 if (!ZeroCallUsedRegsAttr::ConvertStrToZeroCallUsedRegsKind(KindStr, Kind)) {
8550 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported)
8555 D->
dropAttr<ZeroCallUsedRegsAttr>();
8561 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
8567 CountedByAttr *CBA =
8569 CBA->setCountedByFieldLoc(IL->
Loc);
8577 if (
const auto *FD = dyn_cast<FieldDecl>(D))
8581 if (
const auto *R = dyn_cast<RecordDecl>(D))
8594 StrictFlexArraysLevel,
true)) {
8597 Diag(SR.
getBegin(), diag::err_counted_by_attr_not_on_flexible_array_member)
8602 const auto *CBA = FD->
getAttr<CountedByAttr>();
8605 auto GetNonAnonStructOrUnion = [](
const RecordDecl *RD) {
8606 while (RD && !RD->getDeclName())
8607 if (
const auto *R = dyn_cast<RecordDecl>(RD->getDeclContext()))
8621 CBA->getCountedByFieldLoc().getBegin());
8625 if (!MemResult.
empty()) {
8627 Diag(SR.
getBegin(), diag::err_flexible_array_count_not_in_same_struct)
8628 << CBA->getCountedByField() << SR;
8631 SR = ND->getLocation();
8632 Diag(SR.
getBegin(), diag::note_flexible_array_counted_by_attr_field)
8642 if (!OrdResult.
empty()) {
8644 Diag(SR.
getBegin(), diag::err_counted_by_must_be_in_structure)
8648 SR = ND->getLocation();
8649 Diag(SR.
getBegin(), diag::note_flexible_array_counted_by_attr_field)
8663 if (CountFD->
hasAttr<CountedByAttr>()) {
8666 Diag(SR.
getBegin(), diag::err_counted_by_attr_refers_to_flexible_array)
8667 << CBA->getCountedByField() << SR;
8676 diag::err_flexible_array_counted_by_attr_field_not_integer)
8677 << CBA->getCountedByField() << SR;
8680 Diag(SR.
getBegin(), diag::note_flexible_array_counted_by_attr_field)
8695 FunctionReturnThunksAttr::Kind Kind;
8696 if (!FunctionReturnThunksAttr::ConvertStrToKind(KindStr, Kind)) {
8697 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported)
8704 D->
dropAttr<FunctionReturnThunksAttr>();
8705 D->
addAttr(FunctionReturnThunksAttr::Create(S.
Context, Kind, AL));
8710 assert(isa<TypedefNameDecl>(D) &&
"This attribute only applies to a typedef");
8711 handleSimpleAttribute<AvailableOnlyInDefaultEvalMethodAttr>(S, D, AL);
8715 auto *VDecl = dyn_cast<VarDecl>(D);
8716 if (VDecl && !VDecl->isFunctionPointerType()) {
8717 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored_non_function_pointer)
8730 const auto *FD = cast<FunctionDecl>(D);
8732 assert(FT &&
"Function template is expected");
8736 if (TL->
size() < 2) {
8737 S.
Diag(FT->
getLocation(), diag::warn_sycl_kernel_num_of_template_params);
8742 for (
unsigned I = 0; I < 2; ++I) {
8744 if (isa<NonTypeTemplateParmDecl>(TParam)) {
8746 diag::warn_sycl_kernel_invalid_template_param_type);
8753 S.
Diag(FT->
getLocation(), diag::warn_sycl_kernel_num_of_function_params);
8764 handleSimpleAttribute<SYCLKernelAttr>(S, D, AL);
8768 if (!cast<VarDecl>(D)->hasGlobalStorage()) {
8770 << (A.
getKind() == ParsedAttr::AT_AlwaysDestroy);
8774 if (A.
getKind() == ParsedAttr::AT_AlwaysDestroy)
8775 handleSimpleAttribute<AlwaysDestroyAttr>(S, D, A);
8777 handleSimpleAttribute<NoDestroyAttr>(S, D, A);
8781 assert(cast<VarDecl>(D)->getStorageDuration() ==
SD_Automatic &&
8782 "uninitialized is only valid on automatic duration variables");
8787 bool DiagnoseFailure) {
8790 if (DiagnoseFailure) {
8791 S.
Diag(VD->
getBeginLoc(), diag::warn_ignored_objc_externally_retained)
8808 if (DiagnoseFailure) {
8809 S.
Diag(VD->
getBeginLoc(), diag::warn_ignored_objc_externally_retained)
8825 if (
auto *VD = dyn_cast<VarDecl>(D)) {
8826 assert(!isa<ParmVarDecl>(VD) &&
"should be diagnosed automatically");
8827 if (!VD->hasLocalStorage()) {
8836 handleSimpleAttribute<ObjCExternallyRetainedAttr>(S, D, AL);
8842 unsigned NumParams =
8844 for (
unsigned I = 0; I != NumParams; ++I) {
8858 handleSimpleAttribute<ObjCExternallyRetainedAttr>(S, D, AL);
8866 if (!isa<BlockDecl>(D)) {
8868 bool IsKernReturnT =
false;
8870 IsKernReturnT = (TT->getDecl()->getName() ==
"kern_return_t");
8875 diag::warn_mig_server_routine_does_not_return_kern_return_t);
8880 handleSimpleAttribute<MIGServerRoutineAttr>(S, D, AL);
8885 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
8888 S.
Diag(AL.
getLoc(), diag::warn_declspec_allocator_nonpointer)
8894 handleSimpleAttribute<MSAllocatorAttr>(S, D, AL);
8901 if (
const auto *PVD = dyn_cast<ParmVarDecl>(D)) {
8902 if (PVD->getType()->isIntegerType()) {
8903 S.
Diag(AL.
getLoc(), diag::err_attribute_output_parameter)
8914template<
typename Attr>
8922template<
typename Attr>
8931 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
8936 CFGuardAttr::GuardArg Arg;
8938 if (!CFGuardAttr::ConvertStrToGuardArg(II->
getName(), Arg)) {
8939 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
8947template <
typename AttrTy>
8950 auto I = llvm::find_if(Attrs,
8951 [Name](
const AttrTy *A) {
8952 return A->getTCBName() == Name;
8954 return I == Attrs.end() ? nullptr : *I;
8957template <
typename AttrTy,
typename ConflictingAttrTy>
8964 if (
const ConflictingAttrTy *ConflictingAttr =
8965 findEnforceTCBAttrByName<ConflictingAttrTy>(D, Argument)) {
8968 S.
Diag(AL.
getLoc(), diag::err_tcb_conflicting_attributes)
8982template <
typename AttrTy,
typename ConflictingAttrTy>
8985 StringRef TCBName = AL.getTCBName();
8986 if (
const ConflictingAttrTy *ConflictingAttr =
8987 findEnforceTCBAttrByName<ConflictingAttrTy>(D, TCBName)) {
8988 S.
Diag(ConflictingAttr->getLoc(), diag::err_tcb_conflicting_attributes)
8989 << ConflictingAttr->getAttrName()->getName()
8990 << AL.getAttrName()->getName() << TCBName;
8993 S.
Diag(AL.getLoc(), diag::note_conflicting_attribute);
9001 return ::new(Context) AttrTy(Context, AL, AL.getTCBName());
9005 return mergeEnforceTCBAttrImpl<EnforceTCBAttr, EnforceTCBLeafAttr>(
9010 Decl *D,
const EnforceTCBLeafAttr &AL) {
9011 return mergeEnforceTCBAttrImpl<EnforceTCBLeafAttr, EnforceTCBAttr>(
9028 for (
size_t I = 0; I < std::min(AL.
getNumArgs(), AttrNumArgs); ++I) {
9029 bool IsLastAttrArg = I == (AttrNumArgs - 1);
9032 if (IsLastAttrArg && AttrHasVariadicArg)
9039 if (isa<PackExpansionExpr>(E))
9040 return !(IsLastAttrArg && ArgMemberCanHoldExpr);
9053 auto CheckForIncompatibleAttr =
9055 StringRef IncompatibleStateName) {
9056 if (CurrentState == IncompatibleState) {
9057 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
9058 << (std::string(
"'__arm_new(\"") + StateName.str() +
"\")'")
9059 << (std::string(
"'") + IncompatibleStateName.str() +
"(\"" +
9060 StateName.str() +
"\")'")
9075 S.
Diag(AL.
getLoc(), diag::err_missing_arm_state) << AL;
9080 std::vector<StringRef> NewState;
9081 if (
const auto *ExistingAttr = D->
getAttr<ArmNewAttr>()) {
9082 for (StringRef S : ExistingAttr->newArgs())
9083 NewState.push_back(S);
9087 bool HasZT0 =
false;
9088 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
9089 StringRef StateName;
9094 if (StateName ==
"za")
9096 else if (StateName ==
"zt0")
9099 S.
Diag(LiteralLoc, diag::err_unknown_arm_state) << StateName;
9104 if (!llvm::is_contained(NewState, StateName))
9105 NewState.push_back(StateName);
9123 ArmNewAttr(S.
Context, AL, NewState.data(), NewState.size()));
9147 ? (
unsigned)diag::err_keyword_not_supported_on_target
9149 ? (
unsigned)diag::warn_unhandled_ms_attribute_ignored
9150 : (
unsigned)diag::warn_unknown_attribute_ignored)
9162 if (MustDelayArgs) {
9172 assert(AL.
isTypeAttr() &&
"Non-type attribute not handled");
9175 if (Options.IgnoreTypeAttributes)
9193 isa<DeclaratorDecl, TypeAliasDecl>(D)) {
9198 S.
Diag(AL.
getLoc(), diag::warn_type_attribute_deprecated_on_decl)
9207 if (AL.
getKind() == ParsedAttr::AT_Regparm) {
9220 if (AL.
getKind() == ParsedAttr::AT_VectorSize) {
9230 if (AL.
getKind() == ParsedAttr::AT_NoDeref) {
9241 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_on_decl)
9244 case ParsedAttr::AT_Interrupt:
9247 case ParsedAttr::AT_X86ForceAlignArgPointer:
9250 case ParsedAttr::AT_ReadOnlyPlacement:
9251 handleSimpleAttribute<ReadOnlyPlacementAttr>(S, D, AL);
9253 case ParsedAttr::AT_DLLExport:
9254 case ParsedAttr::AT_DLLImport:
9257 case ParsedAttr::AT_AMDGPUFlatWorkGroupSize:
9260 case ParsedAttr::AT_AMDGPUWavesPerEU:
9263 case ParsedAttr::AT_AMDGPUNumSGPR:
9266 case ParsedAttr::AT_AMDGPUNumVGPR:
9269 case ParsedAttr::AT_AMDGPUMaxNumWorkGroups:
9272 case ParsedAttr::AT_AVRSignal:
9275 case ParsedAttr::AT_BPFPreserveAccessIndex:
9278 case ParsedAttr::AT_BPFPreserveStaticOffset:
9279 handleSimpleAttribute<BPFPreserveStaticOffsetAttr>(S, D, AL);
9281 case ParsedAttr::AT_BTFDeclTag:
9284 case ParsedAttr::AT_WebAssemblyExportName:
9287 case ParsedAttr::AT_WebAssemblyImportModule:
9290 case ParsedAttr::AT_WebAssemblyImportName:
9293 case ParsedAttr::AT_IBOutlet:
9296 case ParsedAttr::AT_IBOutletCollection:
9299 case ParsedAttr::AT_IFunc:
9302 case ParsedAttr::AT_Alias:
9305 case ParsedAttr::AT_Aligned:
9308 case ParsedAttr::AT_AlignValue:
9311 case ParsedAttr::AT_AllocSize:
9314 case ParsedAttr::AT_AlwaysInline:
9317 case ParsedAttr::AT_AnalyzerNoReturn:
9320 case ParsedAttr::AT_TLSModel:
9323 case ParsedAttr::AT_Annotate:
9326 case ParsedAttr::AT_Availability:
9329 case ParsedAttr::AT_CarriesDependency:
9332 case ParsedAttr::AT_CPUDispatch:
9333 case ParsedAttr::AT_CPUSpecific:
9336 case ParsedAttr::AT_Common:
9339 case ParsedAttr::AT_CUDAConstant:
9342 case ParsedAttr::AT_PassObjectSize:
9345 case ParsedAttr::AT_Constructor:
9348 case ParsedAttr::AT_Deprecated:
9351 case ParsedAttr::AT_Destructor:
9354 case ParsedAttr::AT_EnableIf:
9357 case ParsedAttr::AT_Error:
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:
9661 case ParsedAttr::AT_Suppress:
9664 case ParsedAttr::AT_Owner:
9665 case ParsedAttr::AT_Pointer:
9668 case ParsedAttr::AT_OpenCLAccess:
9671 case ParsedAttr::AT_OpenCLNoSVM:
9674 case ParsedAttr::AT_SwiftContext:
9677 case ParsedAttr::AT_SwiftAsyncContext:
9680 case ParsedAttr::AT_SwiftErrorResult:
9683 case ParsedAttr::AT_SwiftIndirectResult:
9686 case ParsedAttr::AT_InternalLinkage:
9689 case ParsedAttr::AT_ZeroCallUsedRegs:
9692 case ParsedAttr::AT_FunctionReturnThunks:
9695 case ParsedAttr::AT_NoMerge:
9698 case ParsedAttr::AT_NoUniqueAddress:
9702 case ParsedAttr::AT_AvailableOnlyInDefaultEvalMethod:
9706 case ParsedAttr::AT_CountedBy:
9711 case ParsedAttr::AT_LayoutVersion:
9714 case ParsedAttr::AT_Uuid:
9717 case ParsedAttr::AT_MSInheritance:
9720 case ParsedAttr::AT_Thread:
9723 case ParsedAttr::AT_MSConstexpr:
9728 case ParsedAttr::AT_HLSLNumThreads:
9731 case ParsedAttr::AT_HLSLSV_GroupIndex:
9732 handleSimpleAttribute<HLSLSV_GroupIndexAttr>(S, D, AL);
9734 case ParsedAttr::AT_HLSLSV_DispatchThreadID:
9737 case ParsedAttr::AT_HLSLShader:
9740 case ParsedAttr::AT_HLSLResourceBinding:
9743 case ParsedAttr::AT_HLSLParamModifier:
9747 case ParsedAttr::AT_AbiTag:
9750 case ParsedAttr::AT_CFGuard:
9755 case ParsedAttr::AT_AssertExclusiveLock:
9758 case ParsedAttr::AT_AssertSharedLock:
9761 case ParsedAttr::AT_PtGuardedVar:
9764 case ParsedAttr::AT_NoSanitize:
9767 case ParsedAttr::AT_NoSanitizeSpecific:
9770 case ParsedAttr::AT_GuardedBy:
9773 case ParsedAttr::AT_PtGuardedBy:
9776 case ParsedAttr::AT_ExclusiveTrylockFunction:
9779 case ParsedAttr::AT_LockReturned:
9782 case ParsedAttr::AT_LocksExcluded:
9785 case ParsedAttr::AT_SharedTrylockFunction:
9788 case ParsedAttr::AT_AcquiredBefore:
9791 case ParsedAttr::AT_AcquiredAfter:
9796 case ParsedAttr::AT_Capability:
9797 case ParsedAttr::AT_Lockable:
9800 case ParsedAttr::AT_RequiresCapability:
9804 case ParsedAttr::AT_AssertCapability:
9807 case ParsedAttr::AT_AcquireCapability:
9810 case ParsedAttr::AT_ReleaseCapability:
9813 case ParsedAttr::AT_TryAcquireCapability:
9818 case ParsedAttr::AT_Consumable:
9821 case ParsedAttr::AT_CallableWhen:
9824 case ParsedAttr::AT_ParamTypestate:
9827 case ParsedAttr::AT_ReturnTypestate:
9830 case ParsedAttr::AT_SetTypestate:
9833 case ParsedAttr::AT_TestTypestate:
9838 case ParsedAttr::AT_ArgumentWithTypeTag:
9841 case ParsedAttr::AT_TypeTagForDatatype:
9846 case ParsedAttr::AT_SwiftAsyncName:
9849 case ParsedAttr::AT_SwiftAttr:
9852 case ParsedAttr::AT_SwiftBridge:
9855 case ParsedAttr::AT_SwiftError:
9858 case ParsedAttr::AT_SwiftName:
9861 case ParsedAttr::AT_SwiftNewType:
9864 case ParsedAttr::AT_SwiftAsync:
9867 case ParsedAttr::AT_SwiftAsyncError:
9872 case ParsedAttr::AT_XRayLogArgs:
9876 case ParsedAttr::AT_PatchableFunctionEntry:
9880 case ParsedAttr::AT_AlwaysDestroy:
9881 case ParsedAttr::AT_NoDestroy:
9885 case ParsedAttr::AT_Uninitialized:
9889 case ParsedAttr::AT_ObjCExternallyRetained:
9893 case ParsedAttr::AT_MIGServerRoutine:
9897 case ParsedAttr::AT_MSAllocator:
9901 case ParsedAttr::AT_ArmBuiltinAlias:
9905 case ParsedAttr::AT_ArmLocallyStreaming:
9906 handleSimpleAttribute<ArmLocallyStreamingAttr>(S, D, AL);
9909 case ParsedAttr::AT_ArmNew:
9913 case ParsedAttr::AT_AcquireHandle:
9917 case ParsedAttr::AT_ReleaseHandle:
9918 handleHandleAttr<ReleaseHandleAttr>(S, D, AL);
9921 case ParsedAttr::AT_UnsafeBufferUsage:
9922 handleUnsafeBufferUsage<UnsafeBufferUsageAttr>(S, D, AL);
9925 case ParsedAttr::AT_UseHandle:
9926 handleHandleAttr<UseHandleAttr>(S, D, AL);
9929 case ParsedAttr::AT_EnforceTCB:
9930 handleEnforceTCBAttr<EnforceTCBAttr, EnforceTCBLeafAttr>(S, D, AL);
9933 case ParsedAttr::AT_EnforceTCBLeaf:
9934 handleEnforceTCBAttr<EnforceTCBLeafAttr, EnforceTCBAttr>(S, D, AL);
9937 case ParsedAttr::AT_BuiltinAlias:
9941 case ParsedAttr::AT_PreferredType:
9945 case ParsedAttr::AT_UsingIfExists:
9946 handleSimpleAttribute<UsingIfExistsAttr>(S, D, AL);
9956 if (AttrList.
empty())
9967 Diag(AttrList.
begin()->getLoc(), diag::err_attribute_weakref_without_alias)
9968 << cast<NamedDecl>(D);
9977 if (!D->
hasAttr<OpenCLKernelAttr>()) {
9979 if (
const auto *A = D->
getAttr<ReqdWorkGroupSizeAttr>()) {
9984 }
else if (
const auto *A = D->
getAttr<WorkGroupSizeHintAttr>()) {
9987 }
else if (
const auto *A = D->
getAttr<VecTypeHintAttr>()) {
9990 }
else if (
const auto *A = D->
getAttr<OpenCLIntelReqdSubGroupSizeAttr>()) {
9993 }
else if (!D->
hasAttr<CUDAGlobalAttr>()) {
9994 if (
const auto *A = D->
getAttr<AMDGPUFlatWorkGroupSizeAttr>()) {
9998 }
else if (
const auto *A = D->
getAttr<AMDGPUWavesPerEUAttr>()) {
10002 }
else if (
const auto *A = D->
getAttr<AMDGPUNumSGPRAttr>()) {
10006 }
else if (
const auto *A = D->
getAttr<AMDGPUNumVGPRAttr>()) {
10019 if (D->
hasAttr<ObjCDesignatedInitializerAttr>() &&
10020 cast<ObjCMethodDecl>(D)->getMethodFamily() !=
OMF_init) {
10022 D->
dropAttr<ObjCDesignatedInitializerAttr>();
10031 if (AL.getKind() == ParsedAttr::AT_TransparentUnion) {
10038 if (D && D->
hasAttr<BPFPreserveAccessIndexAttr>())
10047 if (AL.getKind() == ParsedAttr::AT_Annotate) {
10051 Diag(AL.getLoc(), diag::err_only_annotate_after_access_spec);
10063 if (AL.isUsedAsTypeAttr() || AL.isInvalid())
10069 S.
Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored)
10070 << AL << AL.getRange();
10072 S.
Diag(AL.getLoc(), diag::warn_attribute_not_on_decl) << AL
10093 assert(isa<FunctionDecl>(ND) || isa<VarDecl>(ND));
10095 if (
auto *FD = dyn_cast<FunctionDecl>(ND)) {
10117 for (
const auto &AI : FT->param_types()) {
10120 Params.push_back(Param);
10122 NewFD->setParams(Params);
10124 }
else if (
auto *VD = dyn_cast<VarDecl>(ND)) {
10126 VD->getInnerLocStart(), VD->getLocation(), II,
10127 VD->getType(), VD->getTypeSourceInfo(),
10128 VD->getStorageClass());
10129 if (VD->getQualifier())
10130 cast<VarDecl>(NewD)->setQualifierInfo(VD->getQualifierLoc());
10165 if (
auto *VD = dyn_cast<VarDecl>(D))
10166 if (VD->isExternC())
10168 if (
auto *FD = dyn_cast<FunctionDecl>(D))
10176 auto &WeakInfos = I->second;
10177 for (
const auto &W : WeakInfos)
10179 std::remove_reference_t<
decltype(WeakInfos)> EmptyWeakInfos;
10180 WeakInfos.swap(EmptyWeakInfos);
10196 if (AL.slidesFromDeclToDeclSpecLegacyBehavior()) {
10201 AL.diagnoseAppertainsTo(*
this, D);
10212 .WithIncludeCXX11Attributes(
false)
10213 .WithIgnoreTypeAttributes(
true));
10223 .WithIncludeCXX11Attributes(
false)
10224 .WithIgnoreTypeAttributes(
true));
10242 UnavailableAttr::ImplicitReason &reason) {
10246 if (!isa<FieldDecl>(D) && !isa<ObjCPropertyDecl>(D) &&
10247 !isa<FunctionDecl>(D))
10255 if ((isa<ObjCIvarDecl>(D) || isa<ObjCPropertyDecl>(D))) {
10258 reason = UnavailableAttr::IR_ForbiddenWeak;
10267 reason = UnavailableAttr::IR_ARCForbiddenType;
10277 auto Reason = UnavailableAttr::IR_None;
10279 assert(Reason &&
"didn't set reason?");
10284 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
10287 if (FD->
hasAttr<UnavailableAttr>() &&
10289 diag::err_arc_array_param_no_ownership) {
10320 bool AnyAccessFailures =
false;
10328 switch (diag.
Kind) {
10332 if (!
decl->isInvalidDecl())
10340 if (AnyAccessFailures && isa<DecompositionDecl>(
decl))
10344 AnyAccessFailures =
true;
10360 assert(curPool &&
"re-emitting in undelayed context not supported");
10361 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.
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 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 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 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 const FieldDecl * FindFieldInTopLevelOrAnonymousStruct(const RecordDecl *RD, const IdentifierInfo *FieldName)
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 handleCountedByAttr(Sema &S, Decl *D, const ParsedAttr &AL)
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 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 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 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)
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
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.
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 a C++ nested-name-specifier or a global scope specifier.
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...
Simple template class for restricting typo correction candidates to ones having a single Decl* of the...
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.
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.
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
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.
DeclClass * getAsSingle() const
bool empty() const
Return true if no decls were found.
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.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
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.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
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 getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
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 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.
A generic diagnostic builder for errors which may or may not be deferred.
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 ...
CUDAFunctionTarget IdentifyCUDATarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
BTFDeclTagAttr * mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL)
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, CorrectionCandidateCallback &CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr * > Args=std::nullopt, DeclContext *LookupCtx=nullptr, TypoExpr **Out=nullptr)
Diagnose an empty lookup.
void LoadExternalWeakUndeclaredIdentifiers()
Load weak undeclared identifiers from the external source.
bool CheckCallingConvAttr(const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD=nullptr, CUDAFunctionTarget CFT=CFT_InvalidTarget)
Check validaty of calling convention attribute attr.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
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.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
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.
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)
DeclContext * getCurLexicalContext() const
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)
HLSLNumThreadsAttr * mergeHLSLNumThreadsAttr(Decl *D, const AttributeCommonInfo &AL, int X, int Y, int Z)
bool CheckCountedByAttr(Scope *Scope, const FieldDecl *FD)
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)
SemaDiagnosticBuilder CUDADiagIfHostCode(SourceLocation Loc, unsigned DiagID)
Creates a SemaDiagnosticBuilder that emits the diagnostic if the current context is "used as host cod...
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)
CUDAFunctionTarget CurrentCUDATarget()
Gets the CUDA target for the current context.
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...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
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,...
HLSLShaderAttr * mergeHLSLShaderAttr(Decl *D, const AttributeCommonInfo &AL, HLSLShaderAttr::ShaderType ShaderType)
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.
HLSLParamModifierAttr * mergeHLSLParamModifierAttr(Decl *D, const AttributeCommonInfo &AL, HLSLParamModifierAttr::Spelling Spelling)
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 getEnd() const
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...
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
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.
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.
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