47#include "llvm/ADT/STLExtras.h"
48#include "llvm/ADT/STLForwardCompat.h"
49#include "llvm/ADT/StringExtras.h"
50#include "llvm/Demangle/Demangle.h"
51#include "llvm/IR/Assumptions.h"
52#include "llvm/MC/MCSectionMachO.h"
53#include "llvm/Support/Error.h"
54#include "llvm/Support/MathExtras.h"
55#include "llvm/Support/raw_ostream.h"
56#include "llvm/TargetParser/Triple.h"
91 return isa<DeclaratorDecl>(D) || isa<BlockDecl>(D) || isa<TypedefNameDecl>(D) ||
92 isa<ObjCPropertyDecl>(D);
100 return isa<FunctionProtoType>(FnTy);
101 return isa<ObjCMethodDecl>(D) || isa<BlockDecl>(D);
109 return cast<FunctionProtoType>(FnTy)->getNumParams();
110 if (
const auto *BD = dyn_cast<BlockDecl>(D))
111 return BD->getNumParams();
112 return cast<ObjCMethodDecl>(D)->param_size();
117 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
118 return FD->getParamDecl(Idx);
119 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
120 return MD->getParamDecl(Idx);
121 if (
const auto *BD = dyn_cast<BlockDecl>(D))
122 return BD->getParamDecl(Idx);
128 return cast<FunctionProtoType>(FnTy)->getParamType(Idx);
129 if (
const auto *BD = dyn_cast<BlockDecl>(D))
130 return BD->getParamDecl(Idx)->getType();
132 return cast<ObjCMethodDecl>(D)->parameters()[Idx]->getType();
137 return PVD->getSourceRange();
143 return FnTy->getReturnType();
144 return cast<ObjCMethodDecl>(D)->getReturnType();
148 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
149 return FD->getReturnTypeSourceRange();
150 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
151 return MD->getReturnTypeSourceRange();
157 return cast<FunctionProtoType>(FnTy)->isVariadic();
158 if (
const auto *BD = dyn_cast<BlockDecl>(D))
159 return BD->isVariadic();
160 return cast<ObjCMethodDecl>(D)->isVariadic();
164 if (
const auto *MethodDecl = dyn_cast<CXXMethodDecl>(D))
165 return MethodDecl->isInstance();
170 bool AllowNSAttributedString =
false) {
181 if (AllowNSAttributedString &&
182 ClsName == &Ctx.
Idents.
get(
"NSAttributedString"))
185 return ClsName == &Ctx.
Idents.
get(
"NSString") ||
186 ClsName == &Ctx.
Idents.
get(
"NSMutableString");
212template <
typename AttrInfo>
213static std::enable_if_t<std::is_base_of_v<Attr, AttrInfo>,
SourceLocation>
215 return AL.getLocation();
224template <
typename AttrInfo>
226 uint32_t &Val,
unsigned Idx =
UINT_MAX,
227 bool StrictlyUnsigned =
false) {
228 std::optional<llvm::APSInt> I = llvm::APSInt(32);
241 if (!I->isIntN(32)) {
243 <<
toString(*I, 10,
false) << 32 << 1;
247 if (StrictlyUnsigned && I->isSigned() && I->isNegative()) {
248 S.
Diag(
getAttrLoc(AI), diag::err_attribute_requires_positive_integer)
253 Val = (uint32_t)I->getZExtValue();
260template <
typename AttrInfo>
262 int &Val,
unsigned Idx =
UINT_MAX) {
267 if (UVal > (uint32_t)std::numeric_limits<int>::max()) {
271 <<
toString(I, 10,
false) << 32 << 0;
281template <
typename AttrTy>
283 if (
const auto *A = D->
getAttr<AttrTy>()) {
284 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
287 S.
Diag(A->getLocation(), diag::note_conflicting_attribute);
293template <
typename AttrTy>
295 if (
const auto *A = D->
getAttr<AttrTy>()) {
299 S.
Diag(A->getLocation(), diag::note_conflicting_attribute);
309template <
typename AttrInfo>
311 Sema &S,
const Decl *D,
const AttrInfo &AI,
unsigned AttrArgNum,
312 const Expr *IdxExpr,
ParamIdx &Idx,
bool CanIndexImplicitThis =
false) {
323 std::optional<llvm::APSInt> IdxInt;
332 unsigned IdxSource = IdxInt->getLimitedValue(
UINT_MAX);
333 if (IdxSource < 1 || (!IV && IdxSource > NumParams)) {
334 S.
Diag(
getAttrLoc(AI), diag::err_attribute_argument_out_of_bounds)
338 if (HasImplicitThisParam && !CanIndexImplicitThis) {
339 if (IdxSource == 1) {
340 S.
Diag(
getAttrLoc(AI), diag::err_attribute_invalid_implicit_this_argument)
354 const Expr *E, StringRef &Str,
360 if (!Literal || (!Literal->isUnevaluated() && !Literal->isOrdinary())) {
366 Str = Literal->getString();
380 Diag(
Loc->Loc, diag::err_attribute_argument_type)
384 Str =
Loc->Ident->getName();
386 *ArgLocation =
Loc->Loc;
396 if (!Literal || (!Literal->isUnevaluated() && !Literal->isOrdinary())) {
401 Str = Literal->getString();
407template <
typename AttrType>
413template <
typename... DiagnosticArgs>
419template <
typename T,
typename... DiagnosticArgs>
422 DiagnosticArgs &&... ExtraArgs) {
424 std::forward<DiagnosticArgs>(ExtraArgs)...);
431template <
typename AttrType,
typename... DiagnosticArgs>
434 bool PassesCheck,
unsigned DiagID,
435 DiagnosticArgs &&... ExtraArgs) {
441 handleSimpleAttribute<AttrType>(S, D, CI);
462 bool foundStarOperator = IsOverloadedOperatorPresent(
Record, OO_Star);
463 bool foundArrowOperator = IsOverloadedOperatorPresent(
Record, OO_Arrow);
464 if (foundStarOperator && foundArrowOperator)
471 for (
const auto &BaseSpecifier : CXXRecord->bases()) {
472 if (!foundStarOperator)
473 foundStarOperator = IsOverloadedOperatorPresent(
474 BaseSpecifier.getType()->getAsRecordDecl(), OO_Star);
475 if (!foundArrowOperator)
476 foundArrowOperator = IsOverloadedOperatorPresent(
477 BaseSpecifier.getType()->getAsRecordDecl(), OO_Arrow);
480 if (foundStarOperator && foundArrowOperator)
491 const auto *VD = cast<ValueDecl>(D);
500 if (RT->isIncompleteType())
507 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_decl_not_pointer) << AL << QT;
524template <
typename AttrType>
531 if (
const auto *CRD = dyn_cast<CXXRecordDecl>(RD)) {
533 return !Base->hasAttr<AttrType>();
555 return checkRecordDeclForAttr<CapabilityAttr>(RT->
getDecl());
567 return TN->
hasAttr<CapabilityAttr>();
586 if (
const auto *E = dyn_cast<CastExpr>(Ex))
588 else if (
const auto *E = dyn_cast<ParenExpr>(Ex))
590 else if (
const auto *E = dyn_cast<UnaryOperator>(Ex)) {
591 if (E->getOpcode() == UO_LNot || E->getOpcode() == UO_AddrOf ||
592 E->getOpcode() == UO_Deref)
595 }
else if (
const auto *E = dyn_cast<BinaryOperator>(Ex)) {
596 if (E->getOpcode() == BO_LAnd || E->getOpcode() == BO_LOr)
614 bool ParamIdxOk =
false) {
619 const auto *MD = dyn_cast<const CXXMethodDecl>(D);
620 if (MD && !MD->isStatic()) {
623 if (!checkRecordDeclForAttr<CapabilityAttr>(RD) &&
624 !checkRecordDeclForAttr<ScopedLockableAttr>(RD))
626 diag::warn_thread_attribute_not_on_capability_member)
627 << AL << MD->getParent();
629 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_not_on_non_static_member)
634 for (
unsigned Idx = Sidx; Idx < AL.
getNumArgs(); ++Idx) {
639 Args.push_back(ArgExp);
643 if (
const auto *StrLit = dyn_cast<StringLiteral>(ArgExp)) {
644 if (StrLit->getLength() == 0 ||
645 (StrLit->isOrdinary() && StrLit->getString() ==
"*")) {
648 Args.push_back(ArgExp);
654 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_ignored) << AL;
655 Args.push_back(ArgExp);
663 if (
const auto *UOp = dyn_cast<UnaryOperator>(ArgExp))
664 if (UOp->getOpcode() == UO_AddrOf)
665 if (
const auto *DRE = dyn_cast<DeclRefExpr>(UOp->getSubExpr()))
666 if (DRE->getDecl()->isCXXInstanceMember())
667 ArgTy = DRE->getDecl()->getType();
673 if(!RT && ParamIdxOk) {
674 const auto *FD = dyn_cast<FunctionDecl>(D);
675 const auto *IL = dyn_cast<IntegerLiteral>(ArgExp);
677 unsigned int NumParams = FD->getNumParams();
678 llvm::APInt ArgValue = IL->getValue();
679 uint64_t ParamIdxFromOne = ArgValue.getZExtValue();
680 uint64_t ParamIdxFromZero = ParamIdxFromOne - 1;
681 if (!ArgValue.isStrictlyPositive() || ParamIdxFromOne > NumParams) {
683 diag::err_attribute_argument_out_of_bounds_extra_info)
684 << AL << Idx + 1 << NumParams;
687 ArgTy = FD->getParamDecl(ParamIdxFromZero)->getType();
696 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_argument_not_lockable)
699 Args.push_back(ArgExp);
719 unsigned Size = Args.size();
753 QualType QT = cast<ValueDecl>(D)->getType();
755 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_decl_not_lockable) << AL;
772 Expr **StartArg = &Args[0];
774 AcquiredAfterAttr(S.
Context, AL, StartArg, Args.size()));
782 Expr **StartArg = &Args[0];
784 AcquiredBeforeAttr(S.
Context, AL, StartArg, Args.size()));
801 unsigned Size = Args.size();
802 Expr **StartArg = Size == 0 ? nullptr : &Args[0];
804 AssertSharedLockAttr(S.
Context, AL, StartArg, Size));
813 unsigned Size = Args.size();
814 Expr **StartArg = Size == 0 ? nullptr : &Args[0];
816 AssertExclusiveLockAttr(S.
Context, AL, StartArg, Size));
824template <
typename AttrInfo>
826 unsigned AttrArgNo) {
827 assert(AI.isArgExpr(AttrArgNo) &&
"Expected expression argument");
828 Expr *AttrArg = AI.getArgAsExpr(AttrArgNo);
837 S.
Diag(SrcLoc, diag::err_attribute_integers_only)
852 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only) << AL;
863 ParamIdx SizeArgNo(SizeArgNoVal, D);
878 AllocSizeAttr(S.
Context, AL, SizeArgNo, NumberArgNo));
887 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
922 unsigned Size = Args.size();
936 unsigned Size = Args.size();
939 Expr **StartArg = &Args[0];
942 LocksExcludedAttr(S.
Context, AL, StartArg, Size));
946 Expr *&Cond, StringRef &Msg) {
952 Cond = Converted.
get();
959 Msg =
"<no message provided>";
965 S.
Diag(AL.
getLoc(), diag::err_attr_cond_never_constant_expr) << AL;
967 S.
Diag(PDiag.first, PDiag.second);
974 S.
Diag(AL.
getLoc(), diag::ext_clang_enable_if);
983 StringRef NewUserDiagnostic;
992 const auto *PD = isa<CXXRecordDecl>(D)
993 ? cast<DeclContext>(D)
995 if (
const auto *RD = dyn_cast<CXXRecordDecl>(PD); RD && RD->isLocalClass()) {
997 diag::warn_attribute_exclude_from_explicit_instantiation_local_class)
998 << AL << !isa<CXXRecordDecl>(D);
1002 ExcludeFromExplicitInstantiationAttr(S.
Context, AL));
1008class ArgumentDependenceChecker
1019 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD))
1022 ClassType =
nullptr;
1027 bool referencesArgs(
Expr *E) {
1035 "`this` doesn't refer to the enclosing class?");
1041 if (
const auto *PVD = dyn_cast<ParmVarDecl>(DRE->
getDecl()))
1042 if (Parms.count(PVD)) {
1053 const auto *DeclFD = cast<FunctionDecl>(D);
1055 if (
const auto *MethodDecl = dyn_cast<CXXMethodDecl>(DeclFD))
1056 if (!MethodDecl->isStatic()) {
1057 S.
Diag(AL.
getLoc(), diag::err_attribute_no_member_function) << AL;
1069 S.
Diag(
Loc, diag::err_attribute_argument_n_type) << AL << Index <<
T;
1075 auto *F = dyn_cast_if_present<DeclRefExpr>(AL.
getArgAsExpr(0));
1078 return dyn_cast_if_present<FunctionDecl>(F->getFoundDecl());
1087 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments_for)
1094 for (
unsigned I = 1; I < AL.
getNumArgs(); ++I) {
1106 if (Index > DeclFD->getNumParams()) {
1107 S.
Diag(AL.
getLoc(), diag::err_attribute_bounds_for_function)
1108 << AL << Index << DeclFD << DeclFD->getNumParams();
1113 QualType T2 = DeclFD->getParamDecl(Index - 1)->getType();
1118 << AL << Index << DeclFD << T2 << I << AttrFD << T1;
1122 Indices.push_back(Index - 1);
1126 S.
Context, AL, AttrFD, Indices.data(), Indices.size()));
1130 S.
Diag(AL.
getLoc(), diag::ext_clang_diagnose_if);
1137 StringRef DiagTypeStr;
1141 DiagnoseIfAttr::DiagnosticType DiagType;
1142 if (!DiagnoseIfAttr::ConvertStrToDiagnosticType(DiagTypeStr, DiagType)) {
1144 diag::err_diagnose_if_invalid_diagnostic_type);
1148 bool ArgDependent =
false;
1149 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
1150 ArgDependent = ArgumentDependenceChecker(FD).referencesArgs(Cond);
1152 S.
Context, AL, Cond, Msg, DiagType, ArgDependent, cast<NamedDecl>(D)));
1156 static constexpr const StringRef kWildcard =
"*";
1159 bool HasWildcard =
false;
1161 const auto AddBuiltinName = [&Names, &HasWildcard](StringRef Name) {
1162 if (Name == kWildcard)
1164 Names.push_back(Name);
1168 if (
const auto *NBA = D->
getAttr<NoBuiltinAttr>())
1169 for (StringRef BuiltinName : NBA->builtinNames())
1170 AddBuiltinName(BuiltinName);
1174 AddBuiltinName(kWildcard);
1176 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
1177 StringRef BuiltinName;
1183 AddBuiltinName(BuiltinName);
1185 S.
Diag(LiteralLoc, diag::warn_attribute_no_builtin_invalid_builtin_name)
1186 << BuiltinName << AL;
1191 Names.erase(std::unique(Names.begin(), Names.end()), Names.end());
1194 if (HasWildcard && Names.size() > 1)
1196 diag::err_attribute_no_builtin_wildcard_or_builtin_name)
1199 if (D->
hasAttr<NoBuiltinAttr>())
1202 NoBuiltinAttr(S.
Context, AL, Names.data(), Names.size()));
1206 if (D->
hasAttr<PassObjectSizeAttr>()) {
1207 S.
Diag(D->
getBeginLoc(), diag::err_attribute_only_once_per_parameter) << AL;
1229 if (!cast<ParmVarDecl>(D)->getType()->isPointerType()) {
1230 S.
Diag(D->
getBeginLoc(), diag::err_attribute_pointers_only) << AL << 1;
1238 ConsumableAttr::ConsumedState DefaultState;
1242 if (!ConsumableAttr::ConvertStrToConsumedState(IL->
Ident->
getName(),
1244 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported) << AL
1249 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1262 if (!RD->hasAttr<ConsumableAttr>()) {
1263 S.
Diag(AL.
getLoc(), diag::warn_attr_on_unconsumable_class) << RD;
1280 for (
unsigned ArgIndex = 0; ArgIndex < AL.
getNumArgs(); ++ArgIndex) {
1281 CallableWhenAttr::ConsumedState CallableState;
1283 StringRef StateString;
1294 if (!CallableWhenAttr::ConvertStrToConsumedState(StateString,
1296 S.
Diag(
Loc, diag::warn_attribute_type_not_supported) << AL << StateString;
1300 States.push_back(CallableState);
1304 CallableWhenAttr(S.
Context, AL, States.data(), States.size()));
1308 ParamTypestateAttr::ConsumedState ParamState;
1314 if (!ParamTypestateAttr::ConvertStrToConsumedState(StateString,
1316 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported)
1317 << AL << StateString;
1321 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1342 ReturnTypestateAttr::ConsumedState ReturnState;
1346 if (!ReturnTypestateAttr::ConvertStrToConsumedState(IL->
Ident->
getName(),
1348 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported) << AL
1353 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1390 SetTypestateAttr::ConsumedState NewState;
1394 if (!SetTypestateAttr::ConvertStrToConsumedState(Param, NewState)) {
1395 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported) << AL
1400 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1412 TestTypestateAttr::ConsumedState TestState;
1416 if (!TestTypestateAttr::ConvertStrToConsumedState(Param, TestState)) {
1417 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported) << AL
1422 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1436 if (
auto *TD = dyn_cast<TagDecl>(D))
1438 else if (
auto *FD = dyn_cast<FieldDecl>(D)) {
1445 if (BitfieldByteAligned)
1447 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored_for_field_of_type)
1453 if (BitfieldByteAligned)
1454 S.
Diag(AL.
getLoc(), diag::warn_attribute_packed_for_bitfield);
1460 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored) << AL;
1464 auto *RD = cast<CXXRecordDecl>(D);
1466 assert(CTD &&
"attribute does not appertain to this declaration");
1477 if (
const auto *CTSD = dyn_cast_if_present<ClassTemplateSpecializationDecl>(
1479 Template = CTSD->getSpecializedTemplate();
1481 while (TST && TST->isTypeAlias())
1484 Template = TST->getTemplateName().getAsTemplateDecl();
1493 S.
Diag(AL.
getLoc(), diag::err_attribute_preferred_name_arg_invalid)
1496 S.
Diag(TT->getDecl()->getLocation(), diag::note_entity_declared_at)
1504 if (
const auto *VD = dyn_cast<ObjCIvarDecl>(D)) {
1506 S.
Diag(AL.
getLoc(), diag::warn_iboutlet_object_type)
1507 << AL << VD->getType() << 0;
1511 else if (
const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
1513 S.
Diag(AL.
getLoc(), diag::warn_iboutlet_object_type)
1514 << AL << PD->getType() << 1;
1519 S.
Diag(AL.
getLoc(), diag::warn_attribute_iboutlet) << AL;
1537 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
1552 S.
Diag(AL.
getLoc(), diag::err_iboutletcollection_type) <<
"NSObject";
1568 QT->
isBuiltinType() ? diag::err_iboutletcollection_builtintype
1569 : diag::err_iboutletcollection_type) << QT;
1581 T =
T.getNonReferenceType();
1587 if (UT && UT->getDecl()->hasAttr<TransparentUnionAttr>()) {
1589 for (
const auto *I : UD->
fields()) {
1603 bool isReturnValue =
false) {
1606 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only)
1607 << AL << AttrParmRange << TypeRange;
1609 S.
Diag(AL.
getLoc(), diag::warn_attribute_pointers_only)
1610 << AL << AttrParmRange << TypeRange << 0;
1618 for (
unsigned I = 0; I < AL.
getNumArgs(); ++I) {
1632 NonNullArgs.push_back(Idx);
1643 I != E && !AnyPointers; ++I) {
1650 S.
Diag(AL.
getLoc(), diag::warn_attribute_nonnull_no_pointers);
1653 ParamIdx *Start = NonNullArgs.data();
1654 unsigned Size = NonNullArgs.size();
1655 llvm::array_pod_sort(Start, Start + Size);
1665 S.
Diag(AL.
getLoc(), diag::warn_attribute_nonnull_parm_no_args)
1694 QualType T = cast<ParmVarDecl>(D)->getType();
1696 S.
Diag(AL.
getLoc(), diag::warn_attribute_pointers_only)
1719 AssumeAlignedAttr TmpAttr(
Context, CI, E, OE);
1723 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
1724 << &TmpAttr << TmpAttr.getRange() << SR;
1729 std::optional<llvm::APSInt> I = llvm::APSInt(64);
1732 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1736 Diag(AttrLoc, diag::err_attribute_argument_type)
1742 if (!I->isPowerOf2()) {
1743 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
1749 Diag(CI.
getLoc(), diag::warn_assume_aligned_too_great)
1754 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1772 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
1778 const auto *FuncDecl = cast<FunctionDecl>(D);
1788 << FuncDecl->getParamDecl(Idx.
getASTIndex())->getSourceRange();
1797 StringRef AssumptionStr) {
1798 if (llvm::KnownAssumptionStrings.count(AssumptionStr))
1801 unsigned BestEditDistance = 3;
1802 StringRef Suggestion;
1803 for (
const auto &KnownAssumptionIt : llvm::KnownAssumptionStrings) {
1804 unsigned EditDistance =
1805 AssumptionStr.edit_distance(KnownAssumptionIt.getKey());
1806 if (EditDistance < BestEditDistance) {
1807 Suggestion = KnownAssumptionIt.getKey();
1808 BestEditDistance = EditDistance;
1812 if (!Suggestion.empty())
1813 S.
Diag(
Loc, diag::warn_omp_assume_attribute_string_unknown_suggested)
1814 << AssumptionStr << Suggestion;
1816 S.
Diag(
Loc, diag::warn_omp_assume_attribute_string_unknown)
1835 if (AttrName.size() > 4 && AttrName.starts_with(
"__") &&
1836 AttrName.ends_with(
"__")) {
1837 AttrName = AttrName.drop_front(2).drop_back(2);
1853 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
1859 OwnershipAttr::OwnershipKind K =
1860 OwnershipAttr(S.
Context, AL,
nullptr,
nullptr, 0).getOwnKind();
1864 case OwnershipAttr::Takes:
1865 case OwnershipAttr::Holds:
1867 S.
Diag(AL.
getLoc(), diag::err_attribute_too_few_arguments) << AL << 2;
1871 case OwnershipAttr::Returns:
1873 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 1;
1881 StringRef ModuleName =
Module->getName();
1887 for (
unsigned i = 1; i < AL.
getNumArgs(); ++i) {
1897 case OwnershipAttr::Takes:
1898 case OwnershipAttr::Holds:
1902 case OwnershipAttr::Returns:
1908 S.
Diag(AL.
getLoc(), diag::err_ownership_type) << AL << Err
1917 if (I->getOwnKind() != K && llvm::is_contained(I->args(), Idx)) {
1918 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
1921 I->isRegularKeywordAttribute());
1923 }
else if (K == OwnershipAttr::Returns &&
1924 I->getOwnKind() == OwnershipAttr::Returns) {
1927 if (!llvm::is_contained(I->args(), Idx)) {
1928 S.
Diag(I->getLocation(), diag::err_ownership_returns_index_mismatch)
1929 << I->args_begin()->getSourceIndex();
1931 S.
Diag(AL.
getLoc(), diag::note_ownership_returns_index_mismatch)
1937 OwnershipArgs.push_back(Idx);
1940 ParamIdx *Start = OwnershipArgs.data();
1941 unsigned Size = OwnershipArgs.size();
1942 llvm::array_pod_sort(Start, Start + Size);
1950 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
1966 S.
Diag(AL.
getLoc(), diag::err_attribute_weakref_not_global_context)
1967 << cast<NamedDecl>(D);
2011 std::unique_ptr<char, llvm::FreeDeleter> Demangled;
2013 Demangled.reset(llvm::itaniumDemangle(Str,
false));
2022 if (!isa<FunctionDecl>(ND) && !isa<VarDecl>(ND))
2024 if (MC->shouldMangleDeclName(ND)) {
2025 llvm::raw_svector_ostream Out(Name);
2029 Name = ND->getIdentifier()->getName();
2043 const auto *FD = cast<FunctionDecl>(D);
2045 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << FD << 1;
2059 S.
Diag(AL.
getLoc(), diag::err_alias_not_supported_on_darwin);
2067 S.
Diag(AL.
getLoc(), diag::err_alias_not_supported_on_nvptx);
2071 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
2073 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << FD << 0;
2077 const auto *VD = cast<VarDecl>(D);
2078 if (VD->isThisDeclarationADefinition() && VD->isExternallyVisible()) {
2079 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << VD << 0;
2096 if (Model !=
"global-dynamic" && Model !=
"local-dynamic"
2097 && Model !=
"initial-exec" && Model !=
"local-exec") {
2098 S.
Diag(LiteralLoc, diag::err_attr_tlsmodel_arg);
2112 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only)
2120 if (checkAttrMutualExclusion<CPUSpecificAttr>(S, D, AL))
2123 if (
const auto *
Other = D->
getAttr<CPUDispatchAttr>()) {
2124 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
2125 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
2128 }
else if (AL.
getParsedKind() == ParsedAttr::AT_CPUSpecific) {
2129 if (checkAttrMutualExclusion<CPUDispatchAttr>(S, D, AL))
2132 if (
const auto *
Other = D->
getAttr<CPUSpecificAttr>()) {
2133 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
2134 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
2141 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
2142 if (MD->getParent()->isLambda()) {
2143 S.
Diag(AL.
getLoc(), diag::err_attribute_dll_lambda) << AL;
2154 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
2163 S.
Diag(CPUArg->
Loc, diag::err_invalid_cpu_specific_dispatch_value)
2164 << CPUName << (AL.
getKind() == ParsedAttr::AT_CPUDispatch);
2170 return Target.CPUSpecificManglingCharacter(CPUName) ==
2173 S.
Diag(AL.
getLoc(), diag::warn_multiversion_duplicate_entries);
2176 CPUs.push_back(CPUArg->
Ident);
2180 if (AL.
getKind() == ParsedAttr::AT_CPUSpecific)
2182 CPUSpecificAttr(S.
Context, AL, CPUs.data(), CPUs.size()));
2185 CPUDispatchAttr(S.
Context, AL, CPUs.data(), CPUs.size()));
2190 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
2200 S.
Diag(AL.
getLoc(), diag::err_attribute_not_clinkage) << AL;
2204 const auto *FD = cast<FunctionDecl>(D);
2206 S.
Diag(AL.
getLoc(), diag::warn_attribute_cmse_entry_static);
2216 const auto &Arch = Triple.getArch();
2217 if (Arch != llvm::Triple::x86 &&
2218 (Arch != llvm::Triple::arm && Arch != llvm::Triple::thumb)) {
2219 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_on_arch)
2220 << AL << Triple.getArchName();
2226 if (S.
getLangOpts().MSVCCompat && isa<CXXMethodDecl>(D)) {
2227 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_decl_type_str)
2239 if (!isa<ObjCMethodDecl>(D)) {
2240 S.
Diag(Attrs.
getLoc(), diag::warn_attribute_wrong_decl_type)
2266 S.
Diag(Attrs.
getLoc(), diag::warn_nocf_check_attribute_ignored);
2268 handleSimpleAttribute<AnyX86NoCfCheckAttr>(S, D, Attrs);
2284 ? diag::err_keyword_not_supported_on_target
2285 : diag::warn_unknown_attribute_ignored)
2303 ? diag::err_attribute_wrong_decl_type
2304 : diag::warn_attribute_wrong_decl_type)
2340 if (VecReturnAttr *A = D->
getAttr<VecReturnAttr>()) {
2341 S.
Diag(AL.
getLoc(), diag::err_repeat_attribute) << A;
2345 const auto *R = cast<RecordDecl>(D);
2348 if (!isa<CXXRecordDecl>(R)) {
2349 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
2353 if (!cast<CXXRecordDecl>(R)->isPOD()) {
2354 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_pod_record);
2358 for (
const auto *I : R->fields()) {
2359 if ((count == 1) || !I->getType()->isVectorType()) {
2360 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
2371 if (isa<ParmVarDecl>(D)) {
2376 diag::err_carries_dependency_param_not_function_decl);
2390 S.
Diag(AL.
getLoc(), diag::ext_cxx17_attr) << AL;
2396 uint32_t priority = ConstructorAttr::DefaultPriority;
2398 S.
Diag(AL.
getLoc(), diag::err_hlsl_init_priority_unsupported);
2409 uint32_t priority = DestructorAttr::DefaultPriority;
2417template <
typename AttrTy>
2429 if (!cast<ObjCProtocolDecl>(D)->isThisDeclarationADefinition()) {
2430 S.
Diag(AL.
getLoc(), diag::err_objc_attr_protocol_requires_definition)
2440 VersionTuple Introduced,
2441 VersionTuple Deprecated,
2442 VersionTuple Obsoleted) {
2443 StringRef PlatformName
2444 = AvailabilityAttr::getPrettyPlatformName(Platform->
getName());
2445 if (PlatformName.empty())
2446 PlatformName = Platform->
getName();
2450 if (!Introduced.empty() && !Deprecated.empty() &&
2451 !(Introduced <= Deprecated)) {
2453 << 1 << PlatformName << Deprecated.getAsString()
2454 << 0 << Introduced.getAsString();
2458 if (!Introduced.empty() && !Obsoleted.empty() &&
2459 !(Introduced <= Obsoleted)) {
2461 << 2 << PlatformName << Obsoleted.getAsString()
2462 << 0 << Introduced.getAsString();
2466 if (!Deprecated.empty() && !Obsoleted.empty() &&
2467 !(Deprecated <= Obsoleted)) {
2469 << 2 << PlatformName << Obsoleted.getAsString()
2470 << 1 << Deprecated.getAsString();
2482 bool BeforeIsOkay) {
2483 if (
X.empty() || Y.empty())
2489 if (BeforeIsOkay &&
X < Y)
2497 bool Implicit, VersionTuple Introduced, VersionTuple Deprecated,
2498 VersionTuple Obsoleted,
bool IsUnavailable, StringRef Message,
2501 VersionTuple MergedIntroduced = Introduced;
2502 VersionTuple MergedDeprecated = Deprecated;
2503 VersionTuple MergedObsoleted = Obsoleted;
2504 bool FoundAny =
false;
2505 bool OverrideOrImpl =
false;
2509 OverrideOrImpl =
false;
2515 OverrideOrImpl =
true;
2521 for (
unsigned i = 0, e = Attrs.size(); i != e;) {
2522 const auto *OldAA = dyn_cast<AvailabilityAttr>(Attrs[i]);
2529 if (OldPlatform != Platform) {
2535 if (OldEnvironment != Environment) {
2543 if (OldAA->getPriority() <
Priority)
2549 if (OldAA->getPriority() >
Priority) {
2550 Attrs.erase(Attrs.begin() + i);
2556 VersionTuple OldIntroduced = OldAA->getIntroduced();
2557 VersionTuple OldDeprecated = OldAA->getDeprecated();
2558 VersionTuple OldObsoleted = OldAA->getObsoleted();
2559 bool OldIsUnavailable = OldAA->getUnavailable();
2561 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl) ||
2562 !
versionsMatch(Deprecated, OldDeprecated, OverrideOrImpl) ||
2564 !(OldIsUnavailable == IsUnavailable ||
2565 (OverrideOrImpl && !OldIsUnavailable && IsUnavailable))) {
2566 if (OverrideOrImpl) {
2568 VersionTuple FirstVersion;
2569 VersionTuple SecondVersion;
2570 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl)) {
2572 FirstVersion = OldIntroduced;
2573 SecondVersion = Introduced;
2574 }
else if (!
versionsMatch(Deprecated, OldDeprecated, OverrideOrImpl)) {
2576 FirstVersion = Deprecated;
2577 SecondVersion = OldDeprecated;
2578 }
else if (!
versionsMatch(Obsoleted, OldObsoleted, OverrideOrImpl)) {
2580 FirstVersion = Obsoleted;
2581 SecondVersion = OldObsoleted;
2585 Diag(OldAA->getLocation(),
2586 diag::warn_mismatched_availability_override_unavail)
2587 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2598 Diag(OldAA->getLocation(),
2599 diag::warn_mismatched_availability_override)
2601 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2602 << FirstVersion.getAsString() << SecondVersion.getAsString()
2606 Diag(CI.
getLoc(), diag::note_overridden_method);
2608 Diag(CI.
getLoc(), diag::note_protocol_method);
2610 Diag(OldAA->getLocation(), diag::warn_mismatched_availability);
2611 Diag(CI.
getLoc(), diag::note_previous_attribute);
2614 Attrs.erase(Attrs.begin() + i);
2619 VersionTuple MergedIntroduced2 = MergedIntroduced;
2620 VersionTuple MergedDeprecated2 = MergedDeprecated;
2621 VersionTuple MergedObsoleted2 = MergedObsoleted;
2623 if (MergedIntroduced2.empty())
2624 MergedIntroduced2 = OldIntroduced;
2625 if (MergedDeprecated2.empty())
2626 MergedDeprecated2 = OldDeprecated;
2627 if (MergedObsoleted2.empty())
2628 MergedObsoleted2 = OldObsoleted;
2631 MergedIntroduced2, MergedDeprecated2,
2632 MergedObsoleted2)) {
2633 Attrs.erase(Attrs.begin() + i);
2638 MergedIntroduced = MergedIntroduced2;
2639 MergedDeprecated = MergedDeprecated2;
2640 MergedObsoleted = MergedObsoleted2;
2646 MergedIntroduced == Introduced &&
2647 MergedDeprecated == Deprecated &&
2648 MergedObsoleted == Obsoleted)
2654 MergedDeprecated, MergedObsoleted) &&
2656 auto *Avail = ::new (
Context) AvailabilityAttr(
2657 Context, CI, Platform, Introduced, Deprecated, Obsoleted, IsUnavailable,
2658 Message, IsStrict, Replacement,
Priority, Environment);
2666 if (isa<UsingDecl, UnresolvedUsingTypenameDecl, UnresolvedUsingValueDecl>(
2678 if (AvailabilityAttr::getPrettyPlatformName(II->
getName()).empty())
2679 S.
Diag(Platform->
Loc, diag::warn_availability_unknown_platform)
2682 auto *ND = dyn_cast<NamedDecl>(D);
2692 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getMessageExpr()))
2693 Str = SE->getString();
2694 StringRef Replacement;
2695 if (
const auto *SE =
2697 Replacement = SE->getString();
2699 if (II->
isStr(
"swift")) {
2701 (!IsUnavailable && !Deprecated.
isValid())) {
2703 diag::warn_availability_swift_unavailable_deprecated_only);
2708 if (II->
isStr(
"fuchsia")) {
2709 std::optional<unsigned>
Min, Sub;
2711 (Sub = Introduced.
Version.getSubminor())) {
2712 S.
Diag(AL.
getLoc(), diag::warn_availability_fuchsia_unavailable_minor);
2727 if (EnvironmentLoc) {
2729 IIEnvironment = EnvironmentLoc->
Ident;
2730 if (AvailabilityAttr::getEnvironmentType(
2732 llvm::Triple::EnvironmentType::UnknownEnvironment)
2733 S.
Diag(EnvironmentLoc->
Loc, diag::warn_availability_unknown_environment)
2734 << EnvironmentLoc->
Ident;
2736 S.
Diag(EnvironmentLoc->
Loc, diag::err_availability_unexpected_parameter)
2737 <<
"environment" << 1;
2743 Obsoleted.
Version, IsUnavailable, Str, IsStrict, Replacement,
2754 else if (II->
getName() ==
"ios_app_extension")
2759 const auto *IOSToWatchOSMapping =
2764 auto adjustWatchOSVersion =
2765 [IOSToWatchOSMapping](VersionTuple Version) -> VersionTuple {
2766 if (Version.empty())
2768 auto MinimumWatchOSVersion = VersionTuple(2, 0);
2770 if (IOSToWatchOSMapping) {
2771 if (
auto MappedVersion = IOSToWatchOSMapping->map(
2772 Version, MinimumWatchOSVersion, std::nullopt)) {
2773 return *MappedVersion;
2777 auto Major = Version.getMajor();
2778 auto NewMajor = Major >= 9 ? Major - 7 : 0;
2779 if (NewMajor >= 2) {
2780 if (Version.getMinor()) {
2781 if (Version.getSubminor())
2782 return VersionTuple(NewMajor, *Version.getMinor(),
2783 *Version.getSubminor());
2785 return VersionTuple(NewMajor, *Version.getMinor());
2787 return VersionTuple(NewMajor);
2790 return MinimumWatchOSVersion;
2793 auto NewIntroduced = adjustWatchOSVersion(Introduced.
Version);
2794 auto NewDeprecated = adjustWatchOSVersion(Deprecated.
Version);
2795 auto NewObsoleted = adjustWatchOSVersion(Obsoleted.
Version);
2798 ND, AL, NewII,
true , NewIntroduced, NewDeprecated,
2799 NewObsoleted, IsUnavailable, Str, IsStrict, Replacement,
2811 else if (II->
getName() ==
"ios_app_extension")
2816 const auto *IOSToTvOSMapping =
2821 auto AdjustTvOSVersion =
2822 [IOSToTvOSMapping](VersionTuple Version) -> VersionTuple {
2823 if (Version.empty())
2826 if (IOSToTvOSMapping) {
2827 if (
auto MappedVersion = IOSToTvOSMapping->map(
2828 Version, VersionTuple(0, 0), std::nullopt)) {
2829 return *MappedVersion;
2835 auto NewIntroduced = AdjustTvOSVersion(Introduced.
Version);
2836 auto NewDeprecated = AdjustTvOSVersion(Deprecated.
Version);
2837 auto NewObsoleted = AdjustTvOSVersion(Obsoleted.
Version);
2840 ND, AL, NewII,
true , NewIntroduced, NewDeprecated,
2841 NewObsoleted, IsUnavailable, Str, IsStrict, Replacement,
2848 llvm::Triple::IOS &&
2850 auto GetSDKInfo = [&]() {
2859 else if (II->
getName() ==
"ios_app_extension")
2862 auto MinMacCatalystVersion = [](
const VersionTuple &
V) {
2865 if (
V.getMajor() < 13 ||
2866 (
V.getMajor() == 13 &&
V.getMinor() && *
V.getMinor() < 1))
2867 return VersionTuple(13, 1);
2871 ND, AL, NewII,
true ,
2872 MinMacCatalystVersion(Introduced.
Version),
2873 MinMacCatalystVersion(Deprecated.
Version),
2874 MinMacCatalystVersion(Obsoleted.
Version), IsUnavailable, Str,
2879 }
else if (II->
getName() ==
"macos" && GetSDKInfo() &&
2881 !Obsoleted.
Version.empty())) {
2882 if (
const auto *MacOStoMacCatalystMapping =
2883 GetSDKInfo()->getVersionMapping(
2890 auto RemapMacOSVersion =
2891 [&](
const VersionTuple &
V) -> std::optional<VersionTuple> {
2893 return std::nullopt;
2895 if (
V.getMajor() == 100000)
2896 return VersionTuple(100000);
2898 return MacOStoMacCatalystMapping->map(
V, VersionTuple(13, 1),
2901 std::optional<VersionTuple> NewIntroduced =
2902 RemapMacOSVersion(Introduced.
Version),
2904 RemapMacOSVersion(Deprecated.
Version),
2906 RemapMacOSVersion(Obsoleted.
Version);
2907 if (NewIntroduced || NewDeprecated || NewObsoleted) {
2908 auto VersionOrEmptyVersion =
2909 [](
const std::optional<VersionTuple> &
V) -> VersionTuple {
2910 return V ? *
V : VersionTuple();
2913 ND, AL, NewII,
true ,
2914 VersionOrEmptyVersion(NewIntroduced),
2915 VersionOrEmptyVersion(NewDeprecated),
2916 VersionOrEmptyVersion(NewObsoleted),
false, Str,
2935 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(0)))
2937 StringRef DefinedIn;
2938 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(1)))
2939 DefinedIn = SE->getString();
2940 bool IsGeneratedDeclaration = AL.
getArgAsIdent(2) !=
nullptr;
2942 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(3)))
2943 USR = SE->getString();
2951 typename T::VisibilityType value) {
2954 typename T::VisibilityType existingValue = existingAttr->
getVisibility();
2955 if (existingValue == value)
2957 S.
Diag(existingAttr->getLocation(), diag::err_mismatched_visibility);
2958 S.
Diag(CI.
getLoc(), diag::note_previous_attribute);
2966 VisibilityAttr::VisibilityType Vis) {
2967 return ::mergeVisibilityAttr<VisibilityAttr>(*
this, D, CI, Vis);
2972 TypeVisibilityAttr::VisibilityType Vis) {
2973 return ::mergeVisibilityAttr<TypeVisibilityAttr>(*
this, D, CI, Vis);
2977 bool isTypeVisibility) {
2979 if (isa<TypedefNameDecl>(D)) {
2985 if (isTypeVisibility && !(isa<TagDecl>(D) || isa<ObjCInterfaceDecl>(D) ||
2986 isa<NamespaceDecl>(D))) {
2998 VisibilityAttr::VisibilityType
type;
2999 if (!VisibilityAttr::ConvertStrToVisibilityType(TypeStr,
type)) {
3000 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported) << AL
3007 if (
type == VisibilityAttr::Protected &&
3009 S.
Diag(AL.
getLoc(), diag::warn_attribute_protected_visibility);
3010 type = VisibilityAttr::Default;
3014 if (isTypeVisibility) {
3016 D, AL, (TypeVisibilityAttr::VisibilityType)
type);
3027 S.
Diag(AL.
getLoc(), diag::err_objc_direct_on_protocol) <<
false;
3032 handleSimpleAttribute<ObjCDirectAttr>(S, D, AL);
3034 S.
Diag(AL.
getLoc(), diag::warn_objc_direct_ignored) << AL;
3041 handleSimpleAttribute<ObjCDirectMembersAttr>(S, D, AL);
3043 S.
Diag(AL.
getLoc(), diag::warn_objc_direct_ignored) << AL;
3048 const auto *M = cast<ObjCMethodDecl>(D);
3050 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3056 ObjCMethodFamilyAttr::FamilyKind F;
3057 if (!ObjCMethodFamilyAttr::ConvertStrToFamilyKind(IL->
Ident->
getName(), F)) {
3058 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported) << AL << IL->
Ident;
3062 if (F == ObjCMethodFamilyAttr::OMF_init &&
3063 !M->getReturnType()->isObjCObjectPointerType()) {
3064 S.
Diag(M->getLocation(), diag::err_init_method_bad_return_type)
3065 << M->getReturnType();
3074 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
3077 S.
Diag(TD->getLocation(), diag::err_nsobject_attribute);
3081 else if (
const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
3084 S.
Diag(PD->getLocation(), diag::err_nsobject_attribute);
3101 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
3104 S.
Diag(TD->getLocation(), diag::warn_ptr_independentclass_attribute);
3116 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3122 BlocksAttr::BlockType
type;
3123 if (!BlocksAttr::ConvertStrToBlockType(II->
getName(),
type)) {
3124 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
3132 unsigned sentinel = (
unsigned)SentinelAttr::DefaultSentinel;
3135 std::optional<llvm::APSInt> Idx = llvm::APSInt(32);
3137 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3142 if (Idx->isSigned() && Idx->isNegative()) {
3143 S.
Diag(AL.
getLoc(), diag::err_attribute_sentinel_less_than_zero)
3148 sentinel = Idx->getZExtValue();
3151 unsigned nullPos = (
unsigned)SentinelAttr::DefaultNullPos;
3154 std::optional<llvm::APSInt> Idx = llvm::APSInt(32);
3156 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3160 nullPos = Idx->getZExtValue();
3162 if ((Idx->isSigned() && Idx->isNegative()) || nullPos > 1) {
3165 S.
Diag(AL.
getLoc(), diag::err_attribute_sentinel_not_zero_or_one)
3171 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
3173 if (isa<FunctionNoProtoType>(FT)) {
3174 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_named_arguments);
3178 if (!cast<FunctionProtoType>(FT)->isVariadic()) {
3179 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
3182 }
else if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
3183 if (!MD->isVariadic()) {
3184 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
3187 }
else if (
const auto *BD = dyn_cast<BlockDecl>(D)) {
3188 if (!BD->isVariadic()) {
3189 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 1;
3192 }
else if (
const auto *
V = dyn_cast<VarDecl>(D)) {
3200 if (!cast<FunctionProtoType>(FT)->isVariadic()) {
3202 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << m;
3206 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
3212 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
3223 !isa<CXXConstructorDecl>(D)) {
3224 S.
Diag(AL.
getLoc(), diag::warn_attribute_void_function_method) << AL << 0;
3227 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
3228 if (MD->getReturnType()->isVoidType()) {
3229 S.
Diag(AL.
getLoc(), diag::warn_attribute_void_function_method) << AL << 1;
3237 if (isa<VarDecl>(D))
3238 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type_str)
3240 <<
"functions, classes, or enumerations";
3249 if (LO.CPlusPlus && !LO.CPlusPlus20)
3250 S.
Diag(AL.
getLoc(), diag::ext_cxx20_attr) << AL;
3258 }
else if (LO.CPlusPlus && !LO.CPlusPlus17)
3259 S.
Diag(AL.
getLoc(), diag::ext_cxx17_attr) << AL;
3264 isa<TypedefNameDecl>(D)) {
3265 S.
Diag(AL.
getLoc(), diag::warn_unused_result_typedef_unsupported_spelling)
3278 S.
Diag(AL.
getLoc(), diag::warn_attribute_invalid_on_definition)
3280 else if (isa<ObjCPropertyDecl>(D) || isa<ObjCMethodDecl>(D) ||
3282 (isa<ObjCInterfaceDecl>(D) || isa<EnumDecl>(D)))) {
3285 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
3295template <
typename WorkGroupAttr>
3298 for (
unsigned i = 0; i < 3; ++i) {
3303 if (WGSize[i] == 0) {
3304 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_is_zero)
3310 WorkGroupAttr *Existing = D->
getAttr<WorkGroupAttr>();
3311 if (Existing && !(Existing->getXDim() == WGSize[0] &&
3312 Existing->getYDim() == WGSize[1] &&
3313 Existing->getZDim() == WGSize[2]))
3314 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3317 WorkGroupAttr(S.
Context, AL, WGSize[0], WGSize[1], WGSize[2]));
3327 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_is_zero)
3332 OpenCLIntelReqdSubGroupSizeAttr *Existing =
3333 D->
getAttr<OpenCLIntelReqdSubGroupSizeAttr>();
3334 if (Existing && Existing->getSubGroupSize() != SGSize)
3335 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3338 OpenCLIntelReqdSubGroupSizeAttr(S.
Context, AL, SGSize));
3343 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
3349 assert(ParmTSI &&
"no type source info for attribute argument");
3354 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_argument) << 2 << AL;
3358 if (VecTypeHintAttr *A = D->
getAttr<VecTypeHintAttr>()) {
3360 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3372 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
3377 if (SectionAttr *ExistingAttr = D->
getAttr<SectionAttr>()) {
3378 if (ExistingAttr->getName() == Name)
3380 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section)
3382 Diag(CI.
getLoc(), diag::note_previous_attribute);
3399 return llvm::Error::success();
3402 StringRef Segment, Section;
3403 unsigned TAA, StubSize;
3405 return llvm::MCSectionMachO::ParseSectionSpecifier(SecName, Segment, Section,
3406 TAA, HasTAA, StubSize);
3411 Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
3436 cast<NamedDecl>(D));
3447 llvm::CodeModel::Model CM;
3448 if (!CodeModelAttr::ConvertStrToModel(Str, CM)) {
3449 S.
Diag(LiteralLoc, diag::err_attr_codemodel_arg) << Str;
3459 StringRef CodeSegName) {
3461 S.
Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
3473 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
3477 if (
const auto *ExistingAttr = D->
getAttr<CodeSegAttr>()) {
3478 if (ExistingAttr->getName() == Name)
3480 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section)
3482 Diag(CI.
getLoc(), diag::note_previous_attribute);
3495 if (
const auto *ExistingAttr = D->
getAttr<CodeSegAttr>()) {
3496 if (!ExistingAttr->isImplicit()) {
3498 ExistingAttr->getName() == Str
3499 ? diag::warn_duplicate_codeseg_attribute
3500 : diag::err_conflicting_codeseg_attribute);
3512 enum FirstParam { Unsupported, Duplicate,
Unknown };
3513 enum SecondParam {
None, CPU, Tune };
3515 if (AttrStr.contains(
"fpmath="))
3516 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3517 << Unsupported <<
None <<
"fpmath=" <<
Target;
3521 AttrStr.contains(
"tune="))
3522 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3528 if (!ParsedAttrs.
CPU.empty() &&
3530 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3533 if (!ParsedAttrs.
Tune.empty() &&
3535 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3540 return Diag(LiteralLoc, diag::err_duplicate_target_attribute)
3544 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3547 for (
const auto &Feature : ParsedAttrs.
Features) {
3548 auto CurFeature = StringRef(Feature).drop_front();
3550 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3551 << Unsupported <<
None << CurFeature <<
Target;
3560 if (DiagMsg.empty())
3561 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3562 << Unsupported <<
None <<
"branch-protection" <<
Target;
3563 return Diag(LiteralLoc, diag::err_invalid_branch_protection_spec)
3566 if (!DiagMsg.empty())
3567 Diag(LiteralLoc, diag::warn_unsupported_branch_protection_spec) << DiagMsg;
3574 StringRef &AttrStr,
bool &isDefault) {
3575 enum FirstParam { Unsupported };
3576 enum SecondParam {
None };
3578 if (AttrStr.trim() ==
"default")
3581 AttrStr.split(Features,
"+");
3582 for (
auto &CurFeature : Features) {
3583 CurFeature = CurFeature.trim();
3584 if (CurFeature ==
"default")
3587 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3592 return Diag(LiteralLoc, diag::err_sme_streaming_cannot_be_multiversioned);
3599 bool isDefault =
false;
3605 TargetVersionAttr *NewAttr =
3618 TargetAttr *NewAttr = ::new (S.
Context) TargetAttr(S.
Context, AL, Str);
3624 Decl *D,
bool &HasDefault,
bool &HasCommas,
bool &HasNotDefault,
3626 enum FirstParam { Unsupported, Duplicate,
Unknown };
3627 enum SecondParam {
None, CPU, Tune };
3629 HasCommas = HasCommas || Str.contains(
',');
3632 if (Str.size() == 0)
3633 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3636 std::pair<StringRef, StringRef> Parts = {{}, Str};
3637 while (!Parts.second.empty()) {
3638 Parts = Parts.second.split(
',');
3639 StringRef Cur = Parts.first.trim();
3641 Literal->getLocationOfByte(Cur.data() - Literal->getString().data(),
3644 bool DefaultIsDupe =
false;
3645 bool HasCodeGenImpact =
false;
3647 return Diag(CurLoc, diag::warn_unsupported_target_attribute)
3652 if (Cur ==
"default") {
3653 DefaultIsDupe = HasDefault;
3655 if (llvm::is_contained(StringsBuffer, Cur) || DefaultIsDupe)
3656 Diag(CurLoc, diag::warn_target_clone_duplicate_options);
3658 StringsBuffer.push_back(Cur);
3660 std::pair<StringRef, StringRef> CurParts = {{}, Cur};
3662 while (!CurParts.second.empty()) {
3663 CurParts = CurParts.second.split(
'+');
3664 StringRef CurFeature = CurParts.first.trim();
3666 Diag(CurLoc, diag::warn_unsupported_target_attribute)
3671 HasCodeGenImpact =
true;
3672 CurFeatures.push_back(CurFeature);
3675 llvm::sort(CurFeatures);
3677 for (
auto &CurFeat : CurFeatures) {
3680 Res.append(CurFeat);
3682 if (llvm::is_contained(StringsBuffer, Res) || DefaultIsDupe)
3683 Diag(CurLoc, diag::warn_target_clone_duplicate_options);
3684 else if (!HasCodeGenImpact)
3687 Diag(CurLoc, diag::warn_target_clone_no_impact_options);
3688 else if (!Res.empty()) {
3689 StringsBuffer.push_back(Res);
3690 HasNotDefault =
true;
3695 return Diag(LiteralLoc,
3696 diag::err_sme_streaming_cannot_be_multiversioned);
3699 if (Cur.starts_with(
"arch=")) {
3701 Cur.drop_front(
sizeof(
"arch=") - 1)))
3702 return Diag(CurLoc, diag::warn_unsupported_target_attribute)
3703 << Unsupported << CPU << Cur.drop_front(
sizeof(
"arch=") - 1)
3705 }
else if (Cur ==
"default") {
3706 DefaultIsDupe = HasDefault;
3709 return Diag(CurLoc, diag::warn_unsupported_target_attribute)
3711 if (llvm::is_contained(StringsBuffer, Cur) || DefaultIsDupe)
3712 Diag(CurLoc, diag::warn_target_clone_duplicate_options);
3714 StringsBuffer.push_back(Cur);
3717 if (Str.rtrim().ends_with(
","))
3718 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3730 if (
const auto *
Other = D->
getAttr<TargetClonesAttr>()) {
3731 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
3732 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
3735 if (checkAttrMutualExclusion<TargetClonesAttr>(S, D, AL))
3740 bool HasCommas =
false, HasDefault =
false, HasNotDefault =
false;
3742 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
3749 HasDefault, HasCommas, HasNotDefault, StringsBuffer))
3752 for (
auto &SmallStr : StringsBuffer)
3753 Strings.push_back(SmallStr.str());
3756 S.
Diag(AL.
getLoc(), diag::warn_target_clone_mixed_values);
3761 Strings.push_back(
"default");
3765 S.
Diag(AL.
getLoc(), diag::err_target_clone_must_have_default);
3771 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
3772 if (MD->getParent()->isLambda()) {
3784 cast<FunctionDecl>(D)->setIsMultiVersion();
3785 TargetClonesAttr *NewAttr = ::new (S.
Context)
3786 TargetClonesAttr(S.
Context, AL, Strings.data(), Strings.size());
3798 MinVectorWidthAttr *Existing = D->
getAttr<MinVectorWidthAttr>();
3799 if (Existing && Existing->getVectorWidth() != VecWidth) {
3800 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3815 if (
auto *DRE = dyn_cast<DeclRefExpr>(E)) {
3817 S.
Diag(
Loc, diag::warn_cleanup_ext);
3818 FD = dyn_cast<FunctionDecl>(DRE->
getDecl());
3821 S.
Diag(
Loc, diag::err_attribute_cleanup_arg_not_function) << 1
3825 }
else if (
auto *ULE = dyn_cast<UnresolvedLookupExpr>(E)) {
3826 if (ULE->hasExplicitTemplateArgs())
3827 S.
Diag(
Loc, diag::warn_cleanup_ext);
3829 NI = ULE->getNameInfo();
3831 S.
Diag(
Loc, diag::err_attribute_cleanup_arg_not_function) << 2
3838 S.
Diag(
Loc, diag::err_attribute_cleanup_arg_not_function) << 0;
3843 S.
Diag(
Loc, diag::err_attribute_cleanup_func_must_take_one_arg)
3854 S.
Diag(
Loc, diag::err_attribute_cleanup_func_arg_incompatible_type)
3855 << NI.
getName() << ParamTy << Ty;
3858 VarDecl *VD = cast<VarDecl>(D);
3869 S.
Context, VariableReference, UnaryOperatorKind::UO_AddrOf,
3889 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3894 EnumExtensibilityAttr::Kind ExtensibilityKind;
3896 if (!EnumExtensibilityAttr::ConvertStrToKind(II->
getName(),
3897 ExtensibilityKind)) {
3898 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
3903 EnumExtensibilityAttr(S.
Context, AL, ExtensibilityKind));
3918 if (NotNSStringTy &&
3922 S.
Diag(AL.
getLoc(), diag::err_format_attribute_not)
3930 if (
auto *OMD = dyn_cast<ObjCMethodDecl>(D))
3931 if (
auto *
Interface = OMD->getClassInterface())
3938 S.
Diag(AL.
getLoc(), diag::err_format_attribute_result_not)
3939 << (NotNSStringTy ?
"string type" :
"NSString")
3959 return llvm::StringSwitch<FormatAttrKind>(Format)
3973 .Cases(
"gcc_diag",
"gcc_cdiag",
"gcc_cxxdiag",
"gcc_tdiag",
IgnoredFormat)
3981 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored) << AL;
3986 S.
Diag(AL.
getLoc(), diag::err_hlsl_init_priority_unsupported);
3991 S.
Diag(AL.
getLoc(), diag::err_init_priority_object_attr);
3995 QualType T = cast<VarDecl>(D)->getType();
3999 S.
Diag(AL.
getLoc(), diag::err_init_priority_object_attr);
4005 uint32_t prioritynum;
4014 if ((prioritynum < 101 || prioritynum > 65535) &&
4016 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_range)
4025 StringRef NewUserDiagnostic) {
4026 if (
const auto *EA = D->
getAttr<ErrorAttr>()) {
4028 assert((NewAttr ==
"error" || NewAttr ==
"warning") &&
4029 "unexpected normalized full name");
4030 bool Match = (EA->isError() && NewAttr ==
"error") ||
4031 (EA->isWarning() && NewAttr ==
"warning");
4033 Diag(EA->getLocation(), diag::err_attributes_are_not_compatible)
4036 EA->isRegularKeywordAttribute());
4037 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
4040 if (EA->getUserDiagnostic() != NewUserDiagnostic) {
4041 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << EA;
4042 Diag(EA->getLoc(), diag::note_previous_attribute);
4046 return ::new (
Context) ErrorAttr(
Context, CI, NewUserDiagnostic);
4054 if (F->getType() == Format &&
4055 F->getFormatIdx() == FormatIdx &&
4056 F->getFirstArg() == FirstArg) {
4059 if (F->getLocation().isInvalid())
4065 return ::new (
Context) FormatAttr(
Context, CI, Format, FormatIdx, FirstArg);
4072 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
4083 StringRef Format = II->
getName();
4097 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
4108 if (Idx < 1 || Idx > NumArgs) {
4109 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4115 unsigned ArgIdx = Idx - 1;
4117 if (HasImplicitThisParam) {
4120 diag::err_format_attribute_implicit_this_format_string)
4134 S.
Diag(AL.
getLoc(), diag::err_format_attribute_not)
4146 if (FirstArg != 0) {
4150 S.
Diag(AL.
getLoc(), diag::err_format_strftime_third_parameter)
4158 if (FirstArg != NumArgs + 1) {
4159 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4162 std::to_string(NumArgs + 1));
4167 S.
Diag(D->
getLocation(), diag::warn_gcc_requires_variadic_function) << AL;
4168 if (FirstArg <= Idx) {
4172 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4188 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_no_callee)
4197 assert(FD &&
"Expected a function declaration!");
4199 llvm::StringMap<int> NameIdxMapping;
4200 NameIdxMapping[
"__"] = -1;
4202 NameIdxMapping[
"this"] = 0;
4206 NameIdxMapping[PVD->getName()] = Idx++;
4208 auto UnknownName = NameIdxMapping.end();
4211 for (
unsigned I = 0, E = AL.
getNumArgs(); I < E; ++I) {
4217 auto It = NameIdxMapping.find(IdLoc->
Ident->
getName());
4218 if (It == UnknownName) {
4219 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_argument_unknown)
4225 ArgIdx = It->second;
4232 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4238 if (ArgIdx < -1 || ArgIdx > NumArgs) {
4239 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4246 llvm_unreachable(
"Unexpected ParsedAttr argument type!");
4249 if (ArgIdx == 0 && !HasImplicitThisParam) {
4250 S.
Diag(AL.
getLoc(), diag::err_callback_implicit_this_not_available)
4257 if (!HasImplicitThisParam && ArgIdx > 0)
4260 EncodingIndices.push_back(ArgIdx);
4263 int CalleeIdx = EncodingIndices.front();
4267 if (CalleeIdx < (
int)HasImplicitThisParam) {
4268 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_invalid_callee)
4275 const Type *CalleeType =
4279 S.
Diag(AL.
getLoc(), diag::err_callback_callee_no_function_type)
4284 const Type *CalleeFnType =
4289 const auto *CalleeFnProtoType = dyn_cast<FunctionProtoType>(CalleeFnType);
4290 if (!CalleeFnProtoType) {
4291 S.
Diag(AL.
getLoc(), diag::err_callback_callee_no_function_type)
4296 if (CalleeFnProtoType->getNumParams() > EncodingIndices.size() - 1) {
4297 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments)
4298 << AL << (
unsigned)(EncodingIndices.size() - 1);
4302 if (CalleeFnProtoType->getNumParams() < EncodingIndices.size() - 1) {
4303 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments)
4304 << AL << (
unsigned)(EncodingIndices.size() - 1);
4308 if (CalleeFnProtoType->isVariadic()) {
4314 if (D->
hasAttr<CallbackAttr>()) {
4320 S.
Context, AL, EncodingIndices.data(), EncodingIndices.size()));
4333 QualType T = cast<ParmVarDecl>(D)->getType();
4336 S.
Diag(AL.
getLoc(), diag::err_called_once_attribute_wrong_type);
4346 const auto *TD = dyn_cast<TypedefNameDecl>(D);
4347 if (TD && TD->getUnderlyingType()->isUnionType())
4348 RD = TD->getUnderlyingType()->getAsUnionType()->getDecl();
4350 RD = dyn_cast<RecordDecl>(D);
4353 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
4361 diag::warn_transparent_union_attribute_not_definition);
4367 if (Field == FieldEnd) {
4368 S.
Diag(AL.
getLoc(), diag::warn_transparent_union_attribute_zero_fields);
4376 diag::warn_transparent_union_attribute_floating)
4385 for (; Field != FieldEnd; ++Field) {
4386 QualType FieldType = Field->getType();
4400 S.
Diag(Field->getLocation(),
4401 diag::warn_transparent_union_attribute_field_size_align)
4402 << isSize << *Field << FieldBits;
4403 unsigned FirstBits = isSize ? FirstSize : FirstAlign;
4405 diag::note_transparent_union_first_field_size_align)
4406 << isSize << FirstBits;
4416 auto *
Attr = AnnotateAttr::Create(
Context, Str, Args.data(), Args.size(), CI);
4432 for (
unsigned Idx = 1; Idx < AL.
getNumArgs(); Idx++) {
4445 AlignValueAttr TmpAttr(
Context, CI, E);
4449 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D))
4450 T = TD->getUnderlyingType();
4451 else if (
const auto *VD = dyn_cast<ValueDecl>(D))
4454 llvm_unreachable(
"Unknown decl type for align_value");
4458 Diag(AttrLoc, diag::warn_attribute_pointer_or_reference_only)
4464 llvm::APSInt Alignment;
4466 E, &Alignment, diag::err_align_value_attribute_argument_not_int);
4470 if (!Alignment.isPowerOf2()) {
4471 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
4493 diag::err_pack_expansion_without_parameter_packs);
4508 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
4520 diag::err_pack_expansion_without_parameter_packs);
4547 const AlignedAttr &
Attr,
4550 if (isa<ParmVarDecl>(D)) {
4552 }
else if (
const auto *VD = dyn_cast<VarDecl>(D)) {
4555 if (VD->isExceptionVariable())
4557 }
else if (
const auto *FD = dyn_cast<FieldDecl>(D)) {
4558 if (FD->isBitField())
4560 }
else if (
const auto *ED = dyn_cast<EnumDecl>(D)) {
4561 if (ED->getLangOpts().CPlusPlus)
4563 }
else if (!isa<TagDecl>(D)) {
4564 return S.
Diag(AttrLoc, diag::err_attribute_wrong_decl_type)
4569 if (DiagKind != -1) {
4570 return S.
Diag(AttrLoc, diag::err_alignas_attribute_wrong_decl_type)
4571 << &
Attr << DiagKind;
4577 bool IsPackExpansion) {
4578 AlignedAttr TmpAttr(
Context, CI,
true, E);
4582 if (TmpAttr.isAlignas() &&
4590 if (
const auto *TND = dyn_cast<TypedefNameDecl>(D)) {
4591 if (!TND->getUnderlyingType()->isDependentType()) {
4592 Diag(AttrLoc, diag::err_alignment_dependent_typedef_name)
4599 AlignedAttr *AA = ::new (
Context) AlignedAttr(
Context, CI,
true, E);
4600 AA->setPackExpansion(IsPackExpansion);
4606 llvm::APSInt Alignment;
4608 E, &Alignment, diag::err_aligned_attribute_argument_not_int);
4616 Diag(AttrLoc, diag::err_attribute_aligned_too_great)
4621 uint64_t AlignVal = Alignment.getZExtValue();
4627 if (!(TmpAttr.isAlignas() && !Alignment)) {
4628 if (!llvm::isPowerOf2_64(AlignVal)) {
4629 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
4635 const auto *VD = dyn_cast<VarDecl>(D);
4637 unsigned MaxTLSAlign =
4640 if (MaxTLSAlign && AlignVal > MaxTLSAlign &&
4642 Diag(VD->getLocation(), diag::err_tls_var_aligned_over_maximum)
4643 << (
unsigned)AlignVal << VD << MaxTLSAlign;
4651 const Type *Ty = VD->getType().getTypePtr();
4653 Diag(VD->getLocation(), diag::warn_aligned_attr_underaligned)
4654 << VD->getType() << 16;
4660 AA->setPackExpansion(IsPackExpansion);
4661 AA->setCachedAlignmentValue(
4668 AlignedAttr TmpAttr(
Context, CI,
false, TS);
4672 if (TmpAttr.isAlignas() &&
4680 if (
const auto *TND = dyn_cast<TypedefNameDecl>(D)) {
4681 if (!TND->getUnderlyingType()->isDependentType()) {
4682 Diag(AttrLoc, diag::err_alignment_dependent_typedef_name)
4688 AlignedAttr *AA = ::new (
Context) AlignedAttr(
Context, CI,
false, TS);
4689 AA->setPackExpansion(IsPackExpansion);
4694 const auto *VD = dyn_cast<VarDecl>(D);
4695 unsigned AlignVal = TmpAttr.getAlignment(
Context);
4699 const Type *Ty = VD->getType().getTypePtr();
4702 Diag(VD->getLocation(), diag::warn_aligned_attr_underaligned)
4703 << VD->getType() << 16;
4708 AlignedAttr *AA = ::new (
Context) AlignedAttr(
Context, CI,
false, TS);
4709 AA->setPackExpansion(IsPackExpansion);
4710 AA->setCachedAlignmentValue(AlignVal);
4715 assert(D->
hasAttrs() &&
"no attributes on decl");
4718 if (
const auto *VD = dyn_cast<ValueDecl>(D)) {
4719 UnderlyingTy = DiagTy = VD->getType();
4722 if (
const auto *ED = dyn_cast<EnumDecl>(D))
4723 UnderlyingTy = ED->getIntegerType();
4732 AlignedAttr *AlignasAttr =
nullptr;
4733 AlignedAttr *LastAlignedAttr =
nullptr;
4736 if (I->isAlignmentDependent())
4740 Align = std::max(Align, I->getAlignment(
Context));
4741 LastAlignedAttr = I;
4745 Diag(LastAlignedAttr->getLocation(), diag::err_attribute_sizeless_type)
4746 << LastAlignedAttr << DiagTy;
4747 }
else if (AlignasAttr && Align) {
4750 if (NaturalAlign > RequestedAlign)
4751 Diag(AlignasAttr->getLocation(), diag::err_alignas_underaligned)
4787 bool &IntegerMode,
bool &ComplexMode,
4790 ComplexMode =
false;
4792 switch (Str.size()) {
4812 DestWidth = Str[1] ==
'I' ? 0 : 128;
4820 DestWidth = Str[1] ==
'I' ? 0 : 128;
4823 if (Str[1] ==
'F') {
4824 IntegerMode =
false;
4825 }
else if (Str[1] ==
'C') {
4826 IntegerMode =
false;
4828 }
else if (Str[1] !=
'I') {
4837 else if (Str ==
"byte")
4841 if (Str ==
"pointer")
4845 if (Str ==
"unwind_word")
4861 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
4873 StringRef Str = Name->getName();
4877 unsigned DestWidth = 0;
4878 bool IntegerMode =
true;
4879 bool ComplexMode =
false;
4881 llvm::APInt VectorSize(64, 0);
4882 if (Str.size() >= 4 && Str[0] ==
'V') {
4884 size_t StrSize = Str.size();
4885 size_t VectorStringLength = 0;
4886 while ((VectorStringLength + 1) < StrSize &&
4887 isdigit(Str[VectorStringLength + 1]))
4888 ++VectorStringLength;
4889 if (VectorStringLength &&
4890 !Str.substr(1, VectorStringLength).getAsInteger(10, VectorSize) &&
4891 VectorSize.isPowerOf2()) {
4893 IntegerMode, ComplexMode, ExplicitType);
4895 if (!InInstantiation)
4896 Diag(AttrLoc, diag::warn_vector_mode_deprecated);
4911 Diag(AttrLoc, diag::err_machine_mode) << 0 << Name;
4916 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D))
4917 OldTy = TD->getUnderlyingType();
4918 else if (
const auto *ED = dyn_cast<EnumDecl>(D)) {
4921 OldTy = ED->getIntegerType();
4925 OldTy = cast<ValueDecl>(D)->getType();
4936 OldElemTy = VT->getElementType();
4942 VectorSize.getBoolValue()) {
4943 Diag(AttrLoc, diag::err_enum_mode_vector_type) << Name << CI.
getRange();
4951 !IntegralOrAnyEnumType)
4952 Diag(AttrLoc, diag::err_mode_not_primitive);
4953 else if (IntegerMode) {
4954 if (!IntegralOrAnyEnumType)
4955 Diag(AttrLoc, diag::err_mode_wrong_type);
4956 }
else if (ComplexMode) {
4958 Diag(AttrLoc, diag::err_mode_wrong_type);
4961 Diag(AttrLoc, diag::err_mode_wrong_type);
4972 if (NewElemTy.
isNull()) {
4974 if (!(DestWidth == 128 &&
getLangOpts().CUDAIsDevice))
4975 Diag(AttrLoc, diag::err_machine_mode) << 1 << Name;
4984 if (VectorSize.getBoolValue()) {
4990 Diag(AttrLoc, diag::err_complex_mode_vector_type);
4994 OldVT->getNumElements() /
5001 Diag(AttrLoc, diag::err_mode_wrong_type);
5006 if (
auto *TD = dyn_cast<TypedefNameDecl>(D))
5007 TD->setModedTypeSourceInfo(TD->getTypeSourceInfo(), NewTy);
5008 else if (
auto *ED = dyn_cast<EnumDecl>(D))
5009 ED->setIntegerType(NewTy);
5011 cast<ValueDecl>(D)->setType(NewTy);
5023 if (OptimizeNoneAttr *Optnone = D->
getAttr<OptimizeNoneAttr>()) {
5024 Diag(CI.
getLoc(), diag::warn_attribute_ignored) << Ident;
5025 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
5029 if (D->
hasAttr<AlwaysInlineAttr>())
5037 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
5040 if (VD->getKind() != Decl::Var) {
5041 Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
5048 if (VD->hasLocalStorage()) {
5049 Diag(VD->getLocation(), diag::warn_internal_linkage_local_storage);
5056InternalLinkageAttr *
5058 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
5061 if (VD->getKind() != Decl::Var) {
5062 Diag(AL.getLocation(), diag::warn_attribute_wrong_decl_type)
5063 << &AL << AL.isRegularKeywordAttribute()
5069 if (VD->hasLocalStorage()) {
5070 Diag(VD->getLocation(), diag::warn_internal_linkage_local_storage);
5079 if (OptimizeNoneAttr *Optnone = D->
getAttr<OptimizeNoneAttr>()) {
5080 Diag(CI.
getLoc(), diag::warn_attribute_ignored) <<
"'minsize'";
5081 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
5085 if (D->
hasAttr<MinSizeAttr>())
5093 if (
const auto *PrevSNA = D->
getAttr<SwiftNameAttr>()) {
5094 if (PrevSNA->getName() != Name && !PrevSNA->isImplicit()) {
5095 Diag(PrevSNA->getLocation(), diag::err_attributes_are_not_compatible)
5097 << (PrevSNA->isRegularKeywordAttribute() ||
5098 SNA.isRegularKeywordAttribute());
5099 Diag(SNA.getLoc(), diag::note_conflicting_attribute);
5109 if (AlwaysInlineAttr *Inline = D->
getAttr<AlwaysInlineAttr>()) {
5110 Diag(Inline->getLocation(), diag::warn_attribute_ignored) << Inline;
5111 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
5114 if (MinSizeAttr *MinSize = D->
getAttr<MinSizeAttr>()) {
5115 Diag(MinSize->getLocation(), diag::warn_attribute_ignored) << MinSize;
5116 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
5120 if (D->
hasAttr<OptimizeNoneAttr>())
5127 if (AlwaysInlineAttr *Inline =
5143 const auto *VD = cast<VarDecl>(D);
5144 if (VD->hasLocalStorage()) {
5145 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
5150 if (
auto *A = D->
getAttr<CUDAConstantAttr>()) {
5151 if (!A->isImplicit())
5159 const auto *VD = cast<VarDecl>(D);
5162 if (!S.
getLangOpts().GPURelocatableDeviceCode && VD->hasExternalStorage() &&
5163 !isa<IncompleteArrayType>(VD->getType())) {
5164 S.
Diag(AL.
getLoc(), diag::err_cuda_extern_shared) << VD;
5167 if (S.
getLangOpts().CUDA && VD->hasLocalStorage() &&
5175 const auto *FD = cast<FunctionDecl>(D);
5186 if (
const auto *Method = dyn_cast<CXXMethodDecl>(FD)) {
5187 if (Method->isInstance()) {
5188 S.
Diag(Method->getBeginLoc(), diag::err_kern_is_nonstatic_method)
5192 S.
Diag(Method->getBeginLoc(), diag::warn_kern_is_method) << Method;
5198 if (AL.
getKind() == ParsedAttr::AT_NVPTXKernel)
5211 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
5212 if (VD->hasLocalStorage()) {
5213 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
5218 if (
auto *A = D->
getAttr<CUDADeviceAttr>()) {
5219 if (!A->isImplicit())
5227 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
5228 if (VD->hasLocalStorage()) {
5229 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
5233 if (!D->
hasAttr<HIPManagedAttr>())
5235 if (!D->
hasAttr<CUDADeviceAttr>())
5240 const auto *Fn = cast<FunctionDecl>(D);
5241 if (!Fn->isInlineSpecified()) {
5242 S.
Diag(AL.
getLoc(), diag::warn_gnu_inline_attribute_requires_inline);
5247 S.
Diag(AL.
getLoc(), diag::warn_gnu_inline_cplusplus_without_extern);
5263 if (!isa<ObjCMethodDecl>(D)) {
5264 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
5270 case ParsedAttr::AT_FastCall:
5273 case ParsedAttr::AT_StdCall:
5276 case ParsedAttr::AT_ThisCall:
5279 case ParsedAttr::AT_CDecl:
5282 case ParsedAttr::AT_Pascal:
5285 case ParsedAttr::AT_SwiftCall:
5288 case ParsedAttr::AT_SwiftAsyncCall:
5291 case ParsedAttr::AT_VectorCall:
5294 case ParsedAttr::AT_MSABI:
5297 case ParsedAttr::AT_SysVABI:
5300 case ParsedAttr::AT_RegCall:
5303 case ParsedAttr::AT_Pcs: {
5304 PcsAttr::PCSType PCS;
5307 PCS = PcsAttr::AAPCS;
5310 PCS = PcsAttr::AAPCS_VFP;
5313 llvm_unreachable(
"unexpected calling convention in pcs attribute");
5319 case ParsedAttr::AT_AArch64VectorPcs:
5322 case ParsedAttr::AT_AArch64SVEPcs:
5325 case ParsedAttr::AT_AMDGPUKernelCall:
5328 case ParsedAttr::AT_IntelOclBicc:
5331 case ParsedAttr::AT_PreserveMost:
5334 case ParsedAttr::AT_PreserveAll:
5337 case ParsedAttr::AT_M68kRTD:
5340 case ParsedAttr::AT_PreserveNone:
5343 case ParsedAttr::AT_RISCVVectorCC:
5347 llvm_unreachable(
"unexpected attribute kind");
5358 std::vector<StringRef> DiagnosticIdentifiers;
5359 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
5365 DiagnosticIdentifiers.push_back(RuleName);
5368 SuppressAttr(S.
Context, AL, DiagnosticIdentifiers.data(),
5369 DiagnosticIdentifiers.size()));
5378 unsigned SelectIdx = ~0
U;
5384 if (SelectIdx != ~0
U) {
5385 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_argument)
5397 if (AL.
getKind() == ParsedAttr::AT_Owner) {
5398 if (checkAttrMutualExclusion<PointerAttr>(S, D, AL))
5400 if (
const auto *OAttr = D->
getAttr<OwnerAttr>()) {
5401 const Type *ExistingDerefType = OAttr->getDerefTypeLoc()
5402 ? OAttr->getDerefType().getTypePtr()
5405 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
5408 OAttr->isRegularKeywordAttribute());
5409 S.
Diag(OAttr->getLocation(), diag::note_conflicting_attribute);
5414 Redecl->addAttr(::new (S.
Context) OwnerAttr(S.
Context, AL, DerefTypeLoc));
5417 if (checkAttrMutualExclusion<OwnerAttr>(S, D, AL))
5419 if (
const auto *PAttr = D->
getAttr<PointerAttr>()) {
5420 const Type *ExistingDerefType = PAttr->getDerefTypeLoc()
5421 ? PAttr->getDerefType().getTypePtr()
5424 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
5427 PAttr->isRegularKeywordAttribute());
5428 S.
Diag(PAttr->getLocation(), diag::note_conflicting_attribute);
5433 Redecl->addAttr(::new (S.
Context)
5434 PointerAttr(S.
Context, AL, DerefTypeLoc));
5440 if (checkAttrMutualExclusion<NoRandomizeLayoutAttr>(S, D, AL))
5442 if (!D->
hasAttr<RandomizeLayoutAttr>())
5448 if (checkAttrMutualExclusion<RandomizeLayoutAttr>(S, D, AL))
5450 if (!D->
hasAttr<NoRandomizeLayoutAttr>())
5465 unsigned ReqArgs = Attrs.
getKind() == ParsedAttr::AT_Pcs ? 1 : 0;
5473 case ParsedAttr::AT_CDecl:
5476 case ParsedAttr::AT_FastCall:
5479 case ParsedAttr::AT_StdCall:
5482 case ParsedAttr::AT_ThisCall:
5485 case ParsedAttr::AT_Pascal:
5488 case ParsedAttr::AT_SwiftCall:
5491 case ParsedAttr::AT_SwiftAsyncCall:
5494 case ParsedAttr::AT_VectorCall:
5497 case ParsedAttr::AT_AArch64VectorPcs:
5500 case ParsedAttr::AT_AArch64SVEPcs:
5503 case ParsedAttr::AT_AMDGPUKernelCall:
5506 case ParsedAttr::AT_RegCall:
5509 case ParsedAttr::AT_MSABI:
5513 case ParsedAttr::AT_SysVABI:
5517 case ParsedAttr::AT_Pcs: {
5523 if (StrRef ==
"aapcs") {
5526 }
else if (StrRef ==
"aapcs-vfp") {
5535 case ParsedAttr::AT_IntelOclBicc:
5538 case ParsedAttr::AT_PreserveMost:
5541 case ParsedAttr::AT_PreserveAll:
5544 case ParsedAttr::AT_M68kRTD:
5547 case ParsedAttr::AT_PreserveNone:
5550 case ParsedAttr::AT_RISCVVectorCC:
5553 default: llvm_unreachable(
"unexpected attribute kind");
5566 bool CheckHost =
false, CheckDevice =
false;
5567 switch (CudaTarget) {
5580 llvm_unreachable(
"unexpected cuda target");
5582 auto *HostTI =
LangOpts.CUDAIsDevice ? Aux : &TI;
5583 auto *DeviceTI =
LangOpts.CUDAIsDevice ? &TI : Aux;
5584 if (CheckHost && HostTI)
5587 A = DeviceTI->checkCallingConvention(CC);
5605 Diag(Attrs.
getLoc(), diag::error_cconv_unsupported)
5610 Diag(Attrs.
getLoc(), diag::warn_cconv_unsupported)
5615 bool IsCXXMethod =
false, IsVariadic =
false;
5668 if (existingAttr->getABI() != abi) {
5669 Diag(CI.
getLoc(), diag::err_attributes_are_not_compatible)
5672 existingAttr->isRegularKeywordAttribute());
5673 Diag(existingAttr->getLocation(), diag::note_conflicting_attribute);
5680 llvm_unreachable(
"explicit attribute for ordinary parameter ABI?");
5684 Diag(CI.
getLoc(), diag::err_swift_abi_parameter_wrong_type)
5692 Diag(CI.
getLoc(), diag::err_swift_abi_parameter_wrong_type)
5700 Diag(CI.
getLoc(), diag::err_swift_abi_parameter_wrong_type)
5708 Diag(CI.
getLoc(), diag::err_swift_abi_parameter_wrong_type)
5714 llvm_unreachable(
"bad parameter ABI attribute");
5736 Diag(AL.
getLoc(), diag::err_attribute_regparm_wrong_platform)
5744 Diag(AL.
getLoc(), diag::err_attribute_regparm_invalid_number)
5756 llvm_unreachable(
"getCudaArch is only valid for NVPTX triple");
5766 const CUDALaunchBoundsAttr &AL,
5767 const unsigned Idx) {
5776 std::optional<llvm::APSInt> I = llvm::APSInt(64);
5783 if (!I->isIntN(32)) {
5785 <<
toString(*I, 10,
false) << 32 << 1;
5789 S.
Diag(E->
getExprLoc(), diag::warn_attribute_argument_n_negative)
5797 "Unexpected PerformCopyInitialization() failure.");
5802CUDALaunchBoundsAttr *
5804 Expr *MinBlocks,
Expr *MaxBlocks) {
5805 CUDALaunchBoundsAttr TmpAttr(
Context, CI, MaxThreads, MinBlocks, MaxBlocks);
5823 MaxBlocks =
nullptr;
5832 CUDALaunchBoundsAttr(
Context, CI, MaxThreads, MinBlocks, MaxBlocks);
5854 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
5872 unsigned ArgumentIdxAST = ArgumentIdx.
getASTIndex();
5875 S.
Diag(AL.
getLoc(), diag::err_attribute_pointers_only) << AL << 0;
5886 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
5894 if (!isa<VarDecl>(D)) {
5895 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_decl_type)
5903 assert(MatchingCTypeLoc &&
"no type source info for attribute argument");
5925 uint32_t Count = 0, Offset = 0;
5932 if (Count < Offset) {
5933 S.
Diag(
getAttrLoc(AL), diag::err_attribute_argument_out_of_range)
5939 PatchableFunctionEntryAttr(S.
Context, AL, Count, Offset));
5943struct IntrinToName {
5952 const char *IntrinNames) {
5953 AliasName.consume_front(
"__arm_");
5954 const IntrinToName *It =
5955 llvm::lower_bound(Map, BuiltinID, [](
const IntrinToName &L,
unsigned Id) {
5958 if (It == Map.end() || It->Id != BuiltinID)
5960 StringRef FullName(&IntrinNames[It->FullName]);
5961 if (AliasName == FullName)
5963 if (It->ShortName == -1)
5965 StringRef ShortName(&IntrinNames[It->ShortName]);
5966 return AliasName == ShortName;
5970#include "clang/Basic/arm_mve_builtin_aliases.inc"
5978#include "clang/Basic/arm_cde_builtin_aliases.inc"
5983 StringRef AliasName) {
5991 StringRef AliasName) {
6000 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
6007 StringRef AliasName = cast<FunctionDecl>(D)->getIdentifier()->getName();
6014 S.
Diag(AL.
getLoc(), diag::err_attribute_arm_builtin_alias);
6029 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
6036 StringRef AliasName = cast<FunctionDecl>(D)->getIdentifier()->getName();
6046 (!IsAArch64 && !IsARM && !IsRISCV && !IsHLSL)) {
6047 S.
Diag(AL.
getLoc(), diag::err_attribute_builtin_alias) << AL;
6058 if (
auto *CRD = dyn_cast<CXXRecordDecl>(D);
6059 !CRD || !(CRD->isClass() || CRD->isStruct())) {
6065 handleSimpleAttribute<TypeNullableAttr>(S, D, AL);
6070 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
6076 assert(ParmTSI &&
"no type source info for attribute argument");
6078 diag::err_incomplete_type);
6109 bool IsTemplateInstantiation) {
6113 handleSimpleAttributeOrDiagnose<OSConsumedAttr>(
6115 diag::warn_ns_attribute_wrong_parameter_type,
6119 handleSimpleAttributeOrDiagnose<NSConsumedAttr>(
6126 ((IsTemplateInstantiation &&
getLangOpts().ObjCAutoRefCount)
6127 ? diag::err_ns_attribute_wrong_parameter_type
6128 : diag::warn_ns_attribute_wrong_parameter_type),
6132 handleSimpleAttributeOrDiagnose<CFConsumedAttr>(
6134 diag::warn_ns_attribute_wrong_parameter_type,
6143 case ParsedAttr::AT_CFConsumed:
6144 case ParsedAttr::AT_CFReturnsRetained:
6145 case ParsedAttr::AT_CFReturnsNotRetained:
6147 case ParsedAttr::AT_OSConsumesThis:
6148 case ParsedAttr::AT_OSConsumed:
6149 case ParsedAttr::AT_OSReturnsRetained:
6150 case ParsedAttr::AT_OSReturnsNotRetained:
6151 case ParsedAttr::AT_OSReturnsRetainedOnZero:
6152 case ParsedAttr::AT_OSReturnsRetainedOnNonZero:
6154 case ParsedAttr::AT_NSConsumesSelf:
6155 case ParsedAttr::AT_NSConsumed:
6156 case ParsedAttr::AT_NSReturnsRetained:
6157 case ParsedAttr::AT_NSReturnsNotRetained:
6158 case ParsedAttr::AT_NSReturnsAutoreleased:
6161 llvm_unreachable(
"Wrong argument supplied");
6169 Diag(
Loc, diag::warn_ns_attribute_wrong_return_type)
6170 <<
"'ns_returns_retained'" << 0 << 0;
6176 const auto *PVD = dyn_cast<ParmVarDecl>(D);
6189 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
6190 ReturnType = MD->getReturnType();
6192 (AL.
getKind() == ParsedAttr::AT_NSReturnsRetained)) {
6194 }
else if (
const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
6195 ReturnType = PD->getType();
6196 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
6198 }
else if (
const auto *Param = dyn_cast<ParmVarDecl>(D)) {
6205 if (ReturnType.
isNull()) {
6206 S.
Diag(D->
getBeginLoc(), diag::warn_ns_attribute_wrong_parameter_type)
6215 default: llvm_unreachable(
"invalid ownership attribute");
6216 case ParsedAttr::AT_NSReturnsRetained:
6217 case ParsedAttr::AT_NSReturnsAutoreleased:
6218 case ParsedAttr::AT_NSReturnsNotRetained:
6222 case ParsedAttr::AT_OSReturnsRetained:
6223 case ParsedAttr::AT_OSReturnsNotRetained:
6224 case ParsedAttr::AT_CFReturnsRetained:
6225 case ParsedAttr::AT_CFReturnsNotRetained:
6231 << ExpectedDeclKind;
6237 unsigned ParmDiagID = 2;
6239 default: llvm_unreachable(
"invalid ownership attribute");
6240 case ParsedAttr::AT_NSReturnsRetained:
6245 case ParsedAttr::AT_NSReturnsAutoreleased:
6246 case ParsedAttr::AT_NSReturnsNotRetained:
6251 case ParsedAttr::AT_CFReturnsRetained:
6252 case ParsedAttr::AT_CFReturnsNotRetained:
6257 case ParsedAttr::AT_OSReturnsRetained:
6258 case ParsedAttr::AT_OSReturnsNotRetained:
6269 if (isa<ParmVarDecl>(D)) {
6270 S.
Diag(D->
getBeginLoc(), diag::warn_ns_attribute_wrong_parameter_type)
6271 << AL << ParmDiagID << AL.
getRange();
6279 if (isa<ObjCMethodDecl>(D))
6280 SubjectKind = Method;
6281 else if (isa<ObjCPropertyDecl>(D))
6284 << AL << SubjectKind << Cf << AL.
getRange();
6291 llvm_unreachable(
"invalid ownership attribute");
6292 case ParsedAttr::AT_NSReturnsAutoreleased:
6293 handleSimpleAttribute<NSReturnsAutoreleasedAttr>(S, D, AL);
6295 case ParsedAttr::AT_CFReturnsNotRetained:
6296 handleSimpleAttribute<CFReturnsNotRetainedAttr>(S, D, AL);
6298 case ParsedAttr::AT_NSReturnsNotRetained:
6299 handleSimpleAttribute<NSReturnsNotRetainedAttr>(S, D, AL);
6301 case ParsedAttr::AT_CFReturnsRetained:
6302 handleSimpleAttribute<CFReturnsRetainedAttr>(S, D, AL);
6304 case ParsedAttr::AT_NSReturnsRetained:
6305 handleSimpleAttribute<NSReturnsRetainedAttr>(S, D, AL);
6307 case ParsedAttr::AT_OSReturnsRetained:
6308 handleSimpleAttribute<OSReturnsRetainedAttr>(S, D, AL);
6310 case ParsedAttr::AT_OSReturnsNotRetained:
6311 handleSimpleAttribute<OSReturnsNotRetainedAttr>(S, D, AL);
6318 const int EP_ObjCMethod = 1;
6319 const int EP_ObjCProperty = 2;
6323 if (isa<ObjCMethodDecl>(D))
6324 resultType = cast<ObjCMethodDecl>(D)->getReturnType();
6326 resultType = cast<ObjCPropertyDecl>(D)->getType();
6332 << (isa<ObjCMethodDecl>(D) ? EP_ObjCMethod : EP_ObjCProperty)
6344 const auto *Method = cast<ObjCMethodDecl>(D);
6347 if (
const auto *PDecl = dyn_cast_if_present<ObjCProtocolDecl>(DC)) {
6348 S.
Diag(D->
getBeginLoc(), diag::warn_objc_requires_super_protocol) << Attrs
6350 S.
Diag(PDecl->getLocation(), diag::note_protocol_decl);
6354 S.
Diag(D->
getBeginLoc(), diag::warn_objc_requires_super_protocol) << Attrs
6363 if (!isa<TagDecl>(D)) {
6369 Attr.isArgIdent(0) ?
Attr.getArgAsIdent(0) :
nullptr;
6370 if (!IdentLoc || !IdentLoc->
Ident) {
6373 if (
Attr.isArgExpr(0) &&
Attr.getArgAsExpr(0))
6374 Loc =
Attr.getArgAsExpr(0)->getBeginLoc();
6376 S.
Diag(
Loc, diag::err_nserrordomain_invalid_decl) << 0;
6384 S.
Diag(IdentLoc->
Loc, diag::err_nserrordomain_invalid_decl)
6385 << 1 << IdentLoc->
Ident;
6402 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
6404 S.
Diag(AL.
getLoc(), diag::err_objc_attr_typedef_not_id) << AL;
6411 S.
Diag(AL.
getLoc(), diag::err_objc_attr_typedef_not_void_pointer);
6436 if (!RelatedClass) {
6445 S.
Context, AL, RelatedClass, ClassMethod, InstanceMethod));
6454 if (!isa<ObjCInterfaceDecl>(Ctx) &&
6455 !(isa<ObjCCategoryDecl>(Ctx) &&
6456 cast<ObjCCategoryDecl>(Ctx)->IsClassExtension())) {
6462 if (
auto *CatDecl = dyn_cast<ObjCCategoryDecl>(Ctx))
6463 IFace = CatDecl->getClassInterface();
6465 IFace = cast<ObjCInterfaceDecl>(Ctx);
6475 StringRef MetaDataName;
6479 ObjCRuntimeNameAttr(S.
Context, AL, MetaDataName));
6487 bool notify =
false;
6489 auto *RD = dyn_cast<RecordDecl>(D);
6490 if (RD && RD->getDefinition()) {
6491 RD = RD->getDefinition();
6496 ObjCBoxableAttr *BoxableAttr =
6498 RD->addAttr(BoxableAttr);
6503 L->AddedAttributeToRecord(BoxableAttr, RD);
6519 const auto *VD = cast<ValueDecl>(D);
6524 S.
Diag(AL.
getLoc(), diag::err_objc_precise_lifetime_bad_type)
6539 "didn't infer lifetime for non-dependent type?");
6548 S.
Diag(AL.
getLoc(), diag::warn_objc_precise_lifetime_meaningless)
6575 if (
const auto *
Other = D->
getAttr<SwiftBridgeAttr>()) {
6576 if (
Other->getSwiftType() != BT)
6577 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
6593 if (
const auto *ID = OPT->getInterfaceDecl())
6599 if (
const auto *RT = PT->getPointeeType()->getAs<
RecordType>())
6613 S.
Diag(AL.
getLoc(), diag::err_attr_swift_error_no_error_parameter)
6614 << AL << isa<ObjCMethodDecl>(D);
6626 S.
Diag(AL.
getLoc(), diag::err_attr_swift_error_return_type)
6637 S.
Diag(AL.
getLoc(), diag::err_attr_swift_error_return_type)
6647 SwiftErrorAttr::ConventionKind Convention;
6648 if (!SwiftErrorAttr::ConvertStrToConventionKind(
Loc->Ident->getName(),
6650 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
6651 << AL <<
Loc->Ident;
6655 switch (Convention) {
6656 case SwiftErrorAttr::None:
6660 case SwiftErrorAttr::NonNullError:
6661 if (!hasErrorParameter(S, D, AL))
6665 case SwiftErrorAttr::NullResult:
6666 if (!hasErrorParameter(S, D, AL) || !hasPointerResult(S, D, AL))
6670 case SwiftErrorAttr::NonZeroResult:
6671 case SwiftErrorAttr::ZeroResult:
6672 if (!hasErrorParameter(S, D, AL) || !hasIntegerResult(S, D, AL))
6681 const SwiftAsyncErrorAttr *ErrorAttr,
6682 const SwiftAsyncAttr *AsyncAttr) {
6683 if (AsyncAttr->getKind() == SwiftAsyncAttr::None) {
6684 if (ErrorAttr->getConvention() != SwiftAsyncErrorAttr::None) {
6685 S.
Diag(AsyncAttr->getLocation(),
6686 diag::err_swift_async_error_without_swift_async)
6687 << AsyncAttr << isa<ObjCMethodDecl>(D);
6693 D, AsyncAttr->getCompletionHandlerIndex().getASTIndex());
6696 const auto *FuncTy = HandlerParam->
getType()
6702 BlockParams = FuncTy->getParamTypes();
6704 switch (ErrorAttr->getConvention()) {
6705 case SwiftAsyncErrorAttr::ZeroArgument:
6706 case SwiftAsyncErrorAttr::NonZeroArgument: {
6707 uint32_t
ParamIdx = ErrorAttr->getHandlerParamIdx();
6709 S.
Diag(ErrorAttr->getLocation(),
6710 diag::err_attribute_argument_out_of_bounds) << ErrorAttr << 2;
6716 ErrorAttr->getConvention() == SwiftAsyncErrorAttr::ZeroArgument
6718 :
"nonzero_argument";
6719 S.
Diag(ErrorAttr->getLocation(), diag::err_swift_async_error_non_integral)
6720 << ErrorAttr << ConvStr <<
ParamIdx << ErrorParam;
6725 case SwiftAsyncErrorAttr::NonNullError: {
6726 bool AnyErrorParams =
false;
6727 for (
QualType Param : BlockParams) {
6730 if (
const auto *ID = ObjCPtrTy->getInterfaceDecl()) {
6732 AnyErrorParams =
true;
6738 if (
const auto *PtrTy = Param->getAs<
PointerType>()) {
6739 if (
const auto *RT = PtrTy->getPointeeType()->getAs<
RecordType>()) {
6741 AnyErrorParams =
true;
6748 if (!AnyErrorParams) {
6749 S.
Diag(ErrorAttr->getLocation(),
6750 diag::err_swift_async_error_no_error_parameter)
6751 << ErrorAttr << isa<ObjCMethodDecl>(D);
6756 case SwiftAsyncErrorAttr::None:
6763 SwiftAsyncErrorAttr::ConventionKind ConvKind;
6764 if (!SwiftAsyncErrorAttr::ConvertStrToConventionKind(IDLoc->
Ident->
getName(),
6766 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
6767 << AL << IDLoc->
Ident;
6773 case SwiftAsyncErrorAttr::ZeroArgument:
6774 case SwiftAsyncErrorAttr::NonZeroArgument: {
6783 case SwiftAsyncErrorAttr::NonNullError:
6784 case SwiftAsyncErrorAttr::None: {
6795 if (
auto *AsyncAttr = D->
getAttr<SwiftAsyncAttr>())
6809 StringRef Name,
unsigned &SwiftParamCount,
6810 bool &IsSingleParamInit) {
6811 SwiftParamCount = 0;
6812 IsSingleParamInit =
false;
6815 bool IsGetter =
false, IsSetter =
false;
6816 if (Name.consume_front(
"getter:"))
6818 else if (Name.consume_front(
"setter:"))
6821 if (Name.back() !=
')') {
6822 S.
Diag(
Loc, diag::warn_attr_swift_name_function) << AL;
6826 bool IsMember =
false;
6827 StringRef ContextName, BaseName, Parameters;
6829 std::tie(BaseName, Parameters) = Name.split(
'(');
6833 std::tie(ContextName, BaseName) = BaseName.split(
'.');
6834 if (BaseName.empty()) {
6835 BaseName = ContextName;
6836 ContextName = StringRef();
6838 S.
Diag(
Loc, diag::warn_attr_swift_name_invalid_identifier)
6846 S.
Diag(
Loc, diag::warn_attr_swift_name_invalid_identifier)
6851 bool IsSubscript = BaseName ==
"subscript";
6853 if (IsSubscript && !IsGetter && !IsSetter) {
6854 S.
Diag(
Loc, diag::warn_attr_swift_name_subscript_invalid_parameter)
6859 if (Parameters.empty()) {
6860 S.
Diag(
Loc, diag::warn_attr_swift_name_missing_parameters) << AL;
6864 assert(Parameters.back() ==
')' &&
"expected ')'");
6865 Parameters = Parameters.drop_back();
6867 if (Parameters.empty()) {
6870 S.
Diag(
Loc, diag::warn_attr_swift_name_subscript_invalid_parameter)
6876 S.
Diag(
Loc, diag::warn_attr_swift_name_setter_parameters) << AL;
6883 if (Parameters.back() !=
':') {
6884 S.
Diag(
Loc, diag::warn_attr_swift_name_function) << AL;
6888 StringRef CurrentParam;
6889 std::optional<unsigned> SelfLocation;
6890 unsigned NewValueCount = 0;
6891 std::optional<unsigned> NewValueLocation;
6893 std::tie(CurrentParam, Parameters) = Parameters.split(
':');
6896 S.
Diag(
Loc, diag::warn_attr_swift_name_invalid_identifier)
6901 if (IsMember && CurrentParam ==
"self") {
6906 S.
Diag(
Loc, diag::warn_attr_swift_name_multiple_selfs) << AL;
6911 SelfLocation = SwiftParamCount;
6912 }
else if (CurrentParam ==
"newValue") {
6919 NewValueLocation = SwiftParamCount;
6923 }
while (!Parameters.empty());
6926 if (IsSubscript && !SelfLocation) {
6927 S.
Diag(
Loc, diag::warn_attr_swift_name_subscript_invalid_parameter)
6933 SwiftParamCount == 1 && BaseName ==
"init" && CurrentParam !=
"_";
6936 if (IsGetter || IsSetter) {
6938 unsigned NumExpectedParams = IsGetter ? 0 : 1;
6939 unsigned ParamDiag =
6940 IsGetter ? diag::warn_attr_swift_name_getter_parameters
6941 : diag::warn_attr_swift_name_setter_parameters;
6945 ++NumExpectedParams;
6950 if (SwiftParamCount < NumExpectedParams) {
6958 if (!NewValueLocation) {
6959 S.
Diag(
Loc, diag::warn_attr_swift_name_subscript_setter_no_newValue)
6963 if (NewValueCount > 1) {
6964 S.
Diag(
Loc, diag::warn_attr_swift_name_subscript_setter_multiple_newValues)
6970 if (NewValueLocation) {
6971 S.
Diag(
Loc, diag::warn_attr_swift_name_subscript_getter_newValue)
6978 if (SwiftParamCount != NumExpectedParams) {
6990 if (isa<ObjCMethodDecl>(D) || isa<FunctionDecl>(D)) {
6992 unsigned ParamCount;
6994 if (
const auto *Method = dyn_cast<ObjCMethodDecl>(D)) {
6995 ParamCount = Method->getSelector().getNumArgs();
6996 Params = Method->parameters().slice(0, ParamCount);
6998 const auto *F = cast<FunctionDecl>(D);
7000 ParamCount = F->getNumParams();
7001 Params = F->parameters();
7003 if (!F->hasWrittenPrototype()) {
7004 Diag(
Loc, diag::warn_attribute_wrong_decl_type)
7013 if (ParamCount == 0) {
7014 Diag(
Loc, diag::warn_attr_swift_name_decl_missing_params)
7015 << AL << isa<ObjCMethodDecl>(D);
7021 unsigned SwiftParamCount;
7022 bool IsSingleParamInit;
7024 SwiftParamCount, IsSingleParamInit))
7027 bool ParamCountValid;
7028 if (SwiftParamCount == ParamCount) {
7029 ParamCountValid =
true;
7030 }
else if (SwiftParamCount > ParamCount) {
7031 ParamCountValid = IsSingleParamInit && ParamCount == 0;
7036 unsigned MaybeOutParamCount =
7037 llvm::count_if(Params, [](
const ParmVarDecl *Param) ->
bool {
7044 ParamCountValid = SwiftParamCount + MaybeOutParamCount >= ParamCount;
7047 if (!ParamCountValid) {
7048 Diag(
Loc, diag::warn_attr_swift_name_num_params)
7049 << (SwiftParamCount > ParamCount) << AL << ParamCount
7053 }
else if ((isa<EnumConstantDecl>(D) || isa<ObjCProtocolDecl>(D) ||
7054 isa<ObjCInterfaceDecl>(D) || isa<ObjCPropertyDecl>(D) ||
7055 isa<VarDecl>(D) || isa<TypedefNameDecl>(D) || isa<TagDecl>(D) ||
7056 isa<IndirectFieldDecl>(D) || isa<FieldDecl>(D)) &&
7058 StringRef ContextName, BaseName;
7060 std::tie(ContextName, BaseName) = Name.split(
'.');
7061 if (BaseName.empty()) {
7062 BaseName = ContextName;
7063 ContextName = StringRef();
7065 Diag(
Loc, diag::warn_attr_swift_name_invalid_identifier) << AL
7071 Diag(
Loc, diag::warn_attr_swift_name_invalid_identifier) << AL
7076 Diag(
Loc, diag::warn_attr_swift_name_decl_kind) << AL;
7112 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7117 SwiftNewTypeAttr::NewtypeKind Kind;
7119 if (!SwiftNewTypeAttr::ConvertStrToNewtypeKind(II->
getName(), Kind)) {
7120 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
7124 if (!isa<TypedefNameDecl>(D)) {
7125 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type_str)
7135 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
7140 SwiftAsyncAttr::Kind Kind;
7142 if (!SwiftAsyncAttr::ConvertStrToKind(II->
getName(), Kind)) {
7143 S.
Diag(AL.
getLoc(), diag::err_swift_async_no_access) << AL << II;
7148 if (Kind == SwiftAsyncAttr::None) {
7166 diag::err_swift_async_bad_block_type)
7167 << CompletionBlock->
getType();
7174 diag::err_swift_async_bad_block_type)
7175 << CompletionBlock->
getType();
7184 if (
auto *ErrorAttr = D->
getAttr<SwiftAsyncErrorAttr>())
7193 StringRef UuidAsWritten,
MSGuidDecl *GuidDecl) {
7194 if (
const auto *UA = D->
getAttr<UuidAttr>()) {
7197 if (!UA->getGuid().empty()) {
7198 Diag(UA->getLocation(), diag::err_mismatched_uuid);
7204 return ::new (
Context) UuidAttr(
Context, CI, UuidAsWritten, GuidDecl);
7209 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
7214 StringRef OrigStrRef;
7221 StringRef StrRef = OrigStrRef;
7222 if (StrRef.size() == 38 && StrRef.front() ==
'{' && StrRef.back() ==
'}')
7223 StrRef = StrRef.drop_front().drop_back();
7226 if (StrRef.size() != 36) {
7227 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
7231 for (
unsigned i = 0; i < 36; ++i) {
7232 if (i == 8 || i == 13 || i == 18 || i == 23) {
7233 if (StrRef[i] !=
'-') {
7234 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
7238 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
7245 StrRef.substr(0, 8).getAsInteger(16, Parsed.
Part1);
7246 StrRef.substr(9, 4).getAsInteger(16, Parsed.
Part2);
7247 StrRef.substr(14, 4).getAsInteger(16, Parsed.
Part3);
7248 for (
unsigned i = 0; i != 8; ++i)
7249 StrRef.substr(19 + 2 * i + (i >= 2 ? 1 : 0), 2)
7260 S.
Diag(AL.
getLoc(), diag::warn_atl_uuid_deprecated);
7268 llvm::VersionTuple SMVersion =
7270 uint32_t ZMax = 1024;
7271 uint32_t ThreadMax = 1024;
7272 if (SMVersion.getMajor() <= 4) {
7275 }
else if (SMVersion.getMajor() == 5) {
7285 diag::err_hlsl_numthreads_argument_oor) << 0 << 1024;
7293 diag::err_hlsl_numthreads_argument_oor) << 1 << 1024;
7301 diag::err_hlsl_numthreads_argument_oor) << 2 << ZMax;
7305 if (
X * Y * Z > ThreadMax) {
7306 S.
Diag(AL.
getLoc(), diag::err_hlsl_numthreads_invalid) << ThreadMax;
7319 return VT->getNumElements() <= 3;
7327 if (isa<FieldDecl>(D)) {
7328 S.
Diag(AL.
getLoc(), diag::err_hlsl_attr_invalid_ast_node)
7329 << AL <<
"parameter";
7333 auto *VD = cast<ValueDecl>(D);
7335 S.
Diag(AL.
getLoc(), diag::err_hlsl_attr_invalid_type)
7336 << AL <<
"uint/uint2/uint3";
7344 if (!isa<VarDecl>(D) || !isa<HLSLBufferDecl>(D->
getDeclContext())) {
7345 S.
Diag(AL.
getLoc(), diag::err_hlsl_attr_invalid_ast_node)
7346 << AL <<
"shader constant in a constant buffer";
7350 uint32_t SubComponent;
7357 QualType T = cast<VarDecl>(D)->getType().getCanonicalType();
7365 if (IsAggregateTy || Size > 128) {
7366 S.
Diag(AL.
getLoc(), diag::err_hlsl_packoffset_cross_reg_boundary);
7370 if ((Component * 32 + Size) > 128) {
7371 S.
Diag(AL.
getLoc(), diag::err_hlsl_packoffset_cross_reg_boundary);
7376 EltTy = VT->getElementType();
7378 if (Align > 32 && Component == 1) {
7381 S.
Diag(AL.
getLoc(), diag::err_hlsl_packoffset_alignment_mismatch)
7389 HLSLPackOffsetAttr(S.
Context, AL, SubComponent, Component));
7398 HLSLShaderAttr::ShaderType ShaderType;
7399 if (!HLSLShaderAttr::ConvertStrToShaderType(Str, ShaderType)) {
7400 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
7401 << AL << Str << ArgLoc;
7414 StringRef Space =
"space0";
7415 StringRef Slot =
"";
7418 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7424 StringRef Str =
Loc->Ident->getName();
7431 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7437 Space =
Loc->Ident->getName();
7438 SpaceArgLoc =
Loc->Loc;
7444 if (!Slot.empty()) {
7452 S.
Diag(ArgLoc, diag::err_hlsl_unsupported_register_type)
7453 << Slot.substr(0, 1);
7457 StringRef SlotNum = Slot.substr(1);
7459 if (SlotNum.getAsInteger(10, Num)) {
7460 S.
Diag(ArgLoc, diag::err_hlsl_unsupported_register_number);
7465 if (!Space.starts_with(
"space")) {
7466 S.
Diag(SpaceArgLoc, diag::err_hlsl_expected_space) << Space;
7469 StringRef SpaceNum = Space.substr(5);
7471 if (SpaceNum.getAsInteger(10, Num)) {
7472 S.
Diag(SpaceArgLoc, diag::err_hlsl_expected_space) << Space;
7478 HLSLResourceBindingAttr *NewAttr =
7479 HLSLResourceBindingAttr::Create(S.
getASTContext(), Slot, Space, AL);
7495 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
7508 const auto *VD = cast<VarDecl>(D);
7510 S.
Diag(AL.
getLoc(), diag::err_thread_unsupported);
7514 S.
Diag(AL.
getLoc(), diag::err_declspec_thread_on_thread_variable);
7517 if (VD->hasLocalStorage()) {
7518 S.
Diag(AL.
getLoc(), diag::err_thread_non_global) <<
"__declspec(thread)";
7526 S.
Diag(AL.
getLoc(), diag::warn_unknown_attribute_ignored)
7530 auto *FD = cast<FunctionDecl>(D);
7532 S.
Diag(AL.
getLoc(), diag::err_ms_constexpr_cannot_be_applied)
7536 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
7537 if (!S.
getLangOpts().CPlusPlus20 && MD->isVirtual()) {
7538 S.
Diag(AL.
getLoc(), diag::err_ms_constexpr_cannot_be_applied)
7548 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
7552 Tags.push_back(Tag);
7555 if (
const auto *NS = dyn_cast<NamespaceDecl>(D)) {
7556 if (!NS->isInline()) {
7557 S.
Diag(AL.
getLoc(), diag::warn_attr_abi_tag_namespace) << 0;
7560 if (NS->isAnonymousNamespace()) {
7561 S.
Diag(AL.
getLoc(), diag::warn_attr_abi_tag_namespace) << 1;
7565 Tags.push_back(NS->getName());
7571 Tags.erase(std::unique(Tags.begin(), Tags.end()), Tags.end());
7574 AbiTagAttr(S.
Context, AL, Tags.data(), Tags.size()));
7580 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 1;
7592 ARMInterruptAttr::InterruptType Kind;
7593 if (!ARMInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
7594 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << Str
7628 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7634 std::optional<llvm::APSInt> NumParams = llvm::APSInt(32);
7636 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7642 unsigned Num = NumParams->getLimitedValue(255);
7644 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
7645 << AL << (
int)NumParams->getSExtValue()
7657 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 1;
7698 if (checkAttrMutualExclusion<Mips16Attr>(S, D, AL))
7701 MipsInterruptAttr::InterruptType Kind;
7702 if (!MipsInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
7703 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
7704 << AL <<
"'" + std::string(Str) +
"'";
7716 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7725 if (!MaybeNumParams) {
7726 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7732 unsigned Num = MaybeNumParams->getLimitedValue(255);
7733 if ((Num & 1) || Num > 30) {
7734 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
7735 << AL << (
int)MaybeNumParams->getSExtValue()
7753 cast<NamedDecl>(D)->getDeclName().getCXXOverloadedOperator())) {
7754 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
7762 diag::err_anyx86_interrupt_attribute)
7771 if (NumParams < 1 || NumParams > 2) {
7782 diag::err_anyx86_interrupt_attribute)
7794 if (NumParams == 2 &&
7798 diag::err_anyx86_interrupt_attribute)
7819 handleSimpleAttribute<AVRInterruptAttr>(S, D, AL);
7832 handleSimpleAttribute<AVRSignalAttr>(S, D, AL);
7837 for (
auto *D : RD->
decls()) {
7838 if (D->hasAttr<BPFPreserveAccessIndexAttr>())
7841 D->addAttr(BPFPreserveAccessIndexAttr::CreateImplicit(S.
Context));
7842 if (
auto *Rec = dyn_cast<RecordDecl>(D))
7849 auto *Rec = cast<RecordDecl>(D);
7851 Rec->addAttr(::new (S.
Context) BPFPreserveAccessIndexAttr(S.
Context, AL));
7856 if (I->getBTFDeclTag() == Tag)
7875 return ::new (
Context) BTFDeclTagAttr(
Context, AL, AL.getBTFDeclTag());
7886 auto *FD = cast<FunctionDecl>(D);
7901WebAssemblyImportModuleAttr *
7903 auto *FD = cast<FunctionDecl>(D);
7905 if (
const auto *ExistingAttr = FD->
getAttr<WebAssemblyImportModuleAttr>()) {
7906 if (ExistingAttr->getImportModule() == AL.getImportModule())
7908 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_import) << 0
7909 << ExistingAttr->getImportModule() << AL.getImportModule();
7910 Diag(AL.getLoc(), diag::note_previous_attribute);
7914 Diag(AL.getLoc(), diag::warn_import_on_definition) << 0;
7918 AL.getImportModule());
7921WebAssemblyImportNameAttr *
7923 auto *FD = cast<FunctionDecl>(D);
7925 if (
const auto *ExistingAttr = FD->
getAttr<WebAssemblyImportNameAttr>()) {
7926 if (ExistingAttr->getImportName() == AL.getImportName())
7928 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_import) << 1
7929 << ExistingAttr->getImportName() << AL.getImportName();
7930 Diag(AL.getLoc(), diag::note_previous_attribute);
7934 Diag(AL.getLoc(), diag::warn_import_on_definition) << 1;
7938 AL.getImportName());
7943 auto *FD = cast<FunctionDecl>(D);
7950 S.
Diag(AL.
getLoc(), diag::warn_import_on_definition) << 0;
7955 WebAssemblyImportModuleAttr(S.
Context, AL, Str));
7960 auto *FD = cast<FunctionDecl>(D);
7967 S.
Diag(AL.
getLoc(), diag::warn_import_on_definition) << 1;
7977 if (
const auto *A = D->
getAttr<RISCVInterruptAttr>()) {
7979 diag::warn_riscv_repeated_interrupt_attribute);
7980 S.
Diag(A->getLocation(), diag::note_riscv_repeated_interrupt_attribute);
8022 RISCVInterruptAttr::InterruptType Kind;
8023 if (!RISCVInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
8024 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << Str
8035 case llvm::Triple::msp430:
8038 case llvm::Triple::mipsel:
8039 case llvm::Triple::mips:
8042 case llvm::Triple::m68k:
8045 case llvm::Triple::x86:
8046 case llvm::Triple::x86_64:
8049 case llvm::Triple::avr:
8052 case llvm::Triple::riscv32:
8053 case llvm::Triple::riscv64:
8064 const AMDGPUFlatWorkGroupSizeAttr &
Attr) {
8078 if (
Min == 0 &&
Max != 0) {
8092AMDGPUFlatWorkGroupSizeAttr *
8095 AMDGPUFlatWorkGroupSizeAttr TmpAttr(
Context, CI, MinExpr, MaxExpr);
8100 AMDGPUFlatWorkGroupSizeAttr(
Context, CI, MinExpr, MaxExpr);
8120 const AMDGPUWavesPerEUAttr &
Attr) {
8138 if (
Min == 0 &&
Max != 0) {
8152AMDGPUWavesPerEUAttr *
8155 AMDGPUWavesPerEUAttr TmpAttr(
Context, CI, MinExpr, MaxExpr);
8160 return ::new (
Context) AMDGPUWavesPerEUAttr(
Context, CI, MinExpr, MaxExpr);
8180 uint32_t NumSGPR = 0;
8189 uint32_t NumVGPR = 0;
8200 const AMDGPUMaxNumWorkGroupsAttr &
Attr) {
8213 Expr *Exprs[3] = {XExpr, YExpr, ZExpr};
8214 for (
int i = 0; i < 3; i++) {
8230AMDGPUMaxNumWorkGroupsAttr *
8233 AMDGPUMaxNumWorkGroupsAttr TmpAttr(
Context, CI, XExpr, YExpr, ZExpr);
8239 AMDGPUMaxNumWorkGroupsAttr(
Context, CI, XExpr, YExpr, ZExpr);
8261 const auto *VD = dyn_cast<ValueDecl>(D);
8262 if (VD && VD->getType()->isFunctionPointerType())
8265 const auto *TD = dyn_cast<TypedefNameDecl>(D);
8266 if (TD && (TD->getUnderlyingType()->isFunctionPointerType() ||
8267 TD->getUnderlyingType()->isFunctionType()))
8270 if (!isa<FunctionDecl>(D)) {
8271 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
8287 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
8302 if (D->
hasAttr<DLLExportAttr>()) {
8303 Diag(CI.
getLoc(), diag::warn_attribute_ignored) <<
"'dllimport'";
8307 if (D->
hasAttr<DLLImportAttr>())
8315 if (DLLImportAttr *Import = D->
getAttr<DLLImportAttr>()) {
8316 Diag(Import->getLocation(), diag::warn_attribute_ignored) << Import;
8320 if (D->
hasAttr<DLLExportAttr>())
8327 if (isa<ClassTemplatePartialSpecializationDecl>(D) &&
8333 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
8343 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
8345 MD->getParent()->isLambda()) {
8351 Attr *NewAttr = A.
getKind() == ParsedAttr::AT_DLLExport
8362 if (MSInheritanceAttr *IA = D->
getAttr<MSInheritanceAttr>()) {
8363 if (IA->getInheritanceModel() == Model)
8365 Diag(IA->getLocation(), diag::err_mismatched_ms_inheritance)
8367 Diag(CI.
getLoc(), diag::note_previous_ms_inheritance);
8371 auto *RD = cast<CXXRecordDecl>(D);
8372 if (RD->hasDefinition()) {
8378 if (isa<ClassTemplatePartialSpecializationDecl>(RD)) {
8379 Diag(CI.
getLoc(), diag::warn_ignored_ms_inheritance)
8383 if (RD->getDescribedClassTemplate()) {
8384 Diag(CI.
getLoc(), diag::warn_ignored_ms_inheritance)
8402 StringRef N(
"mutex");
8404 if (AL.
getKind() == ParsedAttr::AT_Capability &&
8417 AssertCapabilityAttr(S.
Context, AL, Args.data(), Args.size()));
8461 RequiresCapabilityAttr *RCA = ::new (S.
Context)
8462 RequiresCapabilityAttr(S.
Context, AL, Args.data(), Args.size());
8468 if (
const auto *NSD = dyn_cast<NamespaceDecl>(D)) {
8469 if (NSD->isAnonymousNamespace()) {
8470 S.
Diag(AL.
getLoc(), diag::warn_deprecated_anonymous_namespace);
8484 StringRef Str, Replacement;
8497 S.
Diag(AL.
getLoc(), diag::ext_cxx14_attr) << AL;
8503 if (
const auto *S = dyn_cast<VarDecl>(D))
8504 return S->hasGlobalStorage();
8509 return Sanitizer ==
"address" || Sanitizer ==
"hwaddress" ||
8510 Sanitizer ==
"memtag";
8517 std::vector<StringRef> Sanitizers;
8519 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
8520 StringRef SanitizerName;
8528 SanitizerName !=
"coverage")
8529 S.
Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << SanitizerName;
8531 S.
Diag(D->
getLocation(), diag::warn_attribute_type_not_supported_global)
8532 << AL << SanitizerName;
8533 Sanitizers.push_back(SanitizerName);
8537 Sanitizers.size()));
8544 StringRef SanitizerName = llvm::StringSwitch<StringRef>(AttrName)
8545 .Case(
"no_address_safety_analysis",
"address")
8546 .Case(
"no_sanitize_address",
"address")
8547 .Case(
"no_sanitize_thread",
"thread")
8548 .Case(
"no_sanitize_memory",
"memory");
8561 unsigned TranslatedSpellingIndex = 0;
8563 TranslatedSpellingIndex = 1;
8568 NoSanitizeAttr(S.
Context, Info, &SanitizerName, 1));
8578 S.
Diag(AL.
getLoc(), diag::err_attribute_requires_opencl_version)
8579 << AL <<
"2.0" << 1;
8581 S.
Diag(AL.
getLoc(), diag::warn_opencl_attr_deprecated_ignored)
8590 if (D->
hasAttr<OpenCLAccessAttr>()) {
8591 if (D->
getAttr<OpenCLAccessAttr>()->getSemanticSpelling() ==
8593 S.
Diag(AL.
getLoc(), diag::warn_duplicate_declspec)
8596 S.
Diag(AL.
getLoc(), diag::err_opencl_multiple_access_qualifiers)
8612 if (
const auto *PDecl = dyn_cast<ParmVarDecl>(D)) {
8613 const Type *DeclTy = PDecl->getType().getCanonicalType().getTypePtr();
8615 bool ReadWriteImagesUnsupported =
8620 if (ReadWriteImagesUnsupported || DeclTy->isPipeType()) {
8621 S.
Diag(AL.
getLoc(), diag::err_opencl_invalid_read_write)
8622 << AL << PDecl->getType() << DeclTy->isImageType();
8639 ZeroCallUsedRegsAttr::ZeroCallUsedRegsKind Kind;
8640 if (!ZeroCallUsedRegsAttr::ConvertStrToZeroCallUsedRegsKind(KindStr, Kind)) {
8641 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported)
8646 D->
dropAttr<ZeroCallUsedRegsAttr>();
8656 while (RD && (RD->isAnonymousStructOrUnion() ||
8657 (!RD->isCompleteDefinition() && RD->getName().empty()))) {
8658 const auto *
Parent = dyn_cast<RecordDecl>(RD->getParent());
8676 S.
Diag(E->
getBeginLoc(), diag::err_counted_by_attr_argument_not_integer)
8685 StrictFlexArraysLevel,
true)) {
8689 diag::err_counted_by_attr_not_on_flexible_array_member)
8694 auto *DRE = dyn_cast<DeclRefExpr>(E);
8697 diag::err_counted_by_attr_only_support_simple_decl_reference)
8702 auto *CountDecl = DRE->
getDecl();
8703 FieldDecl *CountFD = dyn_cast<FieldDecl>(CountDecl);
8704 if (
auto *IFD = dyn_cast<IndirectFieldDecl>(CountDecl)) {
8705 CountFD = IFD->getAnonField();
8711 S.
Diag(CountDecl->getBeginLoc(),
8712 diag::note_flexible_array_counted_by_attr_field)
8713 << CountDecl << CountDecl->getSourceRange();
8719 S.
Diag(CountFD->
getBeginLoc(), diag::err_counted_by_attr_refer_to_union)
8729 if (RD != CountRD) {
8731 diag::err_flexible_array_count_not_in_same_struct)
8734 diag::note_flexible_array_counted_by_attr_field)
8745 auto *FD = dyn_cast<FieldDecl>(D);
8767 FunctionReturnThunksAttr::Kind Kind;
8768 if (!FunctionReturnThunksAttr::ConvertStrToKind(KindStr, Kind)) {
8769 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported)
8776 D->
dropAttr<FunctionReturnThunksAttr>();
8777 D->
addAttr(FunctionReturnThunksAttr::Create(S.
Context, Kind, AL));
8782 assert(isa<TypedefNameDecl>(D) &&
"This attribute only applies to a typedef");
8783 handleSimpleAttribute<AvailableOnlyInDefaultEvalMethodAttr>(S, D, AL);
8787 auto *VDecl = dyn_cast<VarDecl>(D);
8788 if (VDecl && !VDecl->isFunctionPointerType()) {
8789 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored_non_function_pointer)
8802 const auto *FD = cast<FunctionDecl>(D);
8804 assert(FT &&
"Function template is expected");
8808 if (TL->
size() < 2) {
8809 S.
Diag(FT->
getLocation(), diag::warn_sycl_kernel_num_of_template_params);
8814 for (
unsigned I = 0; I < 2; ++I) {
8816 if (isa<NonTypeTemplateParmDecl>(TParam)) {
8818 diag::warn_sycl_kernel_invalid_template_param_type);
8825 S.
Diag(FT->
getLocation(), diag::warn_sycl_kernel_num_of_function_params);
8836 handleSimpleAttribute<SYCLKernelAttr>(S, D, AL);
8840 if (!cast<VarDecl>(D)->hasGlobalStorage()) {
8842 << (A.
getKind() == ParsedAttr::AT_AlwaysDestroy);
8846 if (A.
getKind() == ParsedAttr::AT_AlwaysDestroy)
8847 handleSimpleAttribute<AlwaysDestroyAttr>(S, D, A);
8849 handleSimpleAttribute<NoDestroyAttr>(S, D, A);
8853 assert(cast<VarDecl>(D)->getStorageDuration() ==
SD_Automatic &&
8854 "uninitialized is only valid on automatic duration variables");
8859 bool DiagnoseFailure) {
8862 if (DiagnoseFailure) {
8863 S.
Diag(VD->
getBeginLoc(), diag::warn_ignored_objc_externally_retained)
8880 if (DiagnoseFailure) {
8881 S.
Diag(VD->
getBeginLoc(), diag::warn_ignored_objc_externally_retained)
8897 if (
auto *VD = dyn_cast<VarDecl>(D)) {
8898 assert(!isa<ParmVarDecl>(VD) &&
"should be diagnosed automatically");
8899 if (!VD->hasLocalStorage()) {
8908 handleSimpleAttribute<ObjCExternallyRetainedAttr>(S, D, AL);
8914 unsigned NumParams =
8916 for (
unsigned I = 0; I != NumParams; ++I) {
8930 handleSimpleAttribute<ObjCExternallyRetainedAttr>(S, D, AL);
8938 if (!isa<BlockDecl>(D)) {
8940 bool IsKernReturnT =
false;
8942 IsKernReturnT = (TT->getDecl()->getName() ==
"kern_return_t");
8947 diag::warn_mig_server_routine_does_not_return_kern_return_t);
8952 handleSimpleAttribute<MIGServerRoutineAttr>(S, D, AL);
8957 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
8960 S.
Diag(AL.
getLoc(), diag::warn_declspec_allocator_nonpointer)
8966 handleSimpleAttribute<MSAllocatorAttr>(S, D, AL);
8973 if (
const auto *PVD = dyn_cast<ParmVarDecl>(D)) {
8974 if (PVD->getType()->isIntegerType()) {
8975 S.
Diag(AL.
getLoc(), diag::err_attribute_output_parameter)
8986template<
typename Attr>
8994template<
typename Attr>
9003 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
9008 CFGuardAttr::GuardArg Arg;
9010 if (!CFGuardAttr::ConvertStrToGuardArg(II->
getName(), Arg)) {
9011 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
9019template <
typename AttrTy>
9022 auto I = llvm::find_if(Attrs,
9023 [Name](
const AttrTy *A) {
9024 return A->getTCBName() == Name;
9026 return I == Attrs.end() ? nullptr : *I;
9029template <
typename AttrTy,
typename ConflictingAttrTy>
9036 if (
const ConflictingAttrTy *ConflictingAttr =
9037 findEnforceTCBAttrByName<ConflictingAttrTy>(D, Argument)) {
9040 S.
Diag(AL.
getLoc(), diag::err_tcb_conflicting_attributes)
9054template <
typename AttrTy,
typename ConflictingAttrTy>
9057 StringRef TCBName = AL.getTCBName();
9058 if (
const ConflictingAttrTy *ConflictingAttr =
9059 findEnforceTCBAttrByName<ConflictingAttrTy>(D, TCBName)) {
9060 S.
Diag(ConflictingAttr->getLoc(), diag::err_tcb_conflicting_attributes)
9061 << ConflictingAttr->getAttrName()->getName()
9062 << AL.getAttrName()->getName() << TCBName;
9065 S.
Diag(AL.getLoc(), diag::note_conflicting_attribute);
9073 return ::new(Context) AttrTy(Context, AL, AL.getTCBName());
9077 return mergeEnforceTCBAttrImpl<EnforceTCBAttr, EnforceTCBLeafAttr>(
9082 Decl *D,
const EnforceTCBLeafAttr &AL) {
9083 return mergeEnforceTCBAttrImpl<EnforceTCBLeafAttr, EnforceTCBAttr>(
9100 for (
size_t I = 0; I < std::min(AL.
getNumArgs(), AttrNumArgs); ++I) {
9101 bool IsLastAttrArg = I == (AttrNumArgs - 1);
9104 if (IsLastAttrArg && AttrHasVariadicArg)
9111 if (isa<PackExpansionExpr>(E))
9112 return !(IsLastAttrArg && ArgMemberCanHoldExpr);
9125 auto CheckForIncompatibleAttr =
9127 StringRef IncompatibleStateName) {
9128 if (CurrentState == IncompatibleState) {
9129 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
9130 << (std::string(
"'__arm_new(\"") + StateName.str() +
"\")'")
9131 << (std::string(
"'") + IncompatibleStateName.str() +
"(\"" +
9132 StateName.str() +
"\")'")
9147 S.
Diag(AL.
getLoc(), diag::err_missing_arm_state) << AL;
9152 std::vector<StringRef> NewState;
9153 if (
const auto *ExistingAttr = D->
getAttr<ArmNewAttr>()) {
9154 for (StringRef S : ExistingAttr->newArgs())
9155 NewState.push_back(S);
9159 bool HasZT0 =
false;
9160 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
9161 StringRef StateName;
9166 if (StateName ==
"za")
9168 else if (StateName ==
"zt0")
9171 S.
Diag(LiteralLoc, diag::err_unknown_arm_state) << StateName;
9176 if (!llvm::is_contained(NewState, StateName))
9177 NewState.push_back(StateName);
9195 ArmNewAttr(S.
Context, AL, NewState.data(), NewState.size()));
9219 ? (
unsigned)diag::err_keyword_not_supported_on_target
9221 ? (
unsigned)diag::warn_unhandled_ms_attribute_ignored
9222 : (
unsigned)diag::warn_unknown_attribute_ignored)
9234 if (MustDelayArgs) {
9244 assert(AL.
isTypeAttr() &&
"Non-type attribute not handled");
9247 if (Options.IgnoreTypeAttributes)
9265 isa<DeclaratorDecl, TypeAliasDecl>(D)) {
9270 S.
Diag(AL.
getLoc(), diag::warn_type_attribute_deprecated_on_decl)
9279 if (AL.
getKind() == ParsedAttr::AT_Regparm) {
9292 if (AL.
getKind() == ParsedAttr::AT_VectorSize) {
9302 if (AL.
getKind() == ParsedAttr::AT_NoDeref) {
9313 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_on_decl)
9316 case ParsedAttr::AT_Interrupt:
9319 case ParsedAttr::AT_X86ForceAlignArgPointer:
9322 case ParsedAttr::AT_ReadOnlyPlacement:
9323 handleSimpleAttribute<ReadOnlyPlacementAttr>(S, D, AL);
9325 case ParsedAttr::AT_DLLExport:
9326 case ParsedAttr::AT_DLLImport:
9329 case ParsedAttr::AT_AMDGPUFlatWorkGroupSize:
9332 case ParsedAttr::AT_AMDGPUWavesPerEU:
9335 case ParsedAttr::AT_AMDGPUNumSGPR:
9338 case ParsedAttr::AT_AMDGPUNumVGPR:
9341 case ParsedAttr::AT_AMDGPUMaxNumWorkGroups:
9344 case ParsedAttr::AT_AVRSignal:
9347 case ParsedAttr::AT_BPFPreserveAccessIndex:
9350 case ParsedAttr::AT_BPFPreserveStaticOffset:
9351 handleSimpleAttribute<BPFPreserveStaticOffsetAttr>(S, D, AL);
9353 case ParsedAttr::AT_BTFDeclTag:
9356 case ParsedAttr::AT_WebAssemblyExportName:
9359 case ParsedAttr::AT_WebAssemblyImportModule:
9362 case ParsedAttr::AT_WebAssemblyImportName:
9365 case ParsedAttr::AT_IBOutlet:
9368 case ParsedAttr::AT_IBOutletCollection:
9371 case ParsedAttr::AT_IFunc:
9374 case ParsedAttr::AT_Alias:
9377 case ParsedAttr::AT_Aligned:
9380 case ParsedAttr::AT_AlignValue:
9383 case ParsedAttr::AT_AllocSize:
9386 case ParsedAttr::AT_AlwaysInline:
9389 case ParsedAttr::AT_AnalyzerNoReturn:
9392 case ParsedAttr::AT_TLSModel:
9395 case ParsedAttr::AT_Annotate:
9398 case ParsedAttr::AT_Availability:
9401 case ParsedAttr::AT_CarriesDependency:
9404 case ParsedAttr::AT_CPUDispatch:
9405 case ParsedAttr::AT_CPUSpecific:
9408 case ParsedAttr::AT_Common:
9411 case ParsedAttr::AT_CUDAConstant:
9414 case ParsedAttr::AT_PassObjectSize:
9417 case ParsedAttr::AT_Constructor:
9420 case ParsedAttr::AT_Deprecated:
9423 case ParsedAttr::AT_Destructor:
9426 case ParsedAttr::AT_EnableIf:
9429 case ParsedAttr::AT_Error:
9432 case ParsedAttr::AT_ExcludeFromExplicitInstantiation:
9435 case ParsedAttr::AT_DiagnoseIf:
9438 case ParsedAttr::AT_DiagnoseAsBuiltin:
9441 case ParsedAttr::AT_NoBuiltin:
9444 case ParsedAttr::AT_ExtVectorType:
9447 case ParsedAttr::AT_ExternalSourceSymbol:
9450 case ParsedAttr::AT_MinSize:
9453 case ParsedAttr::AT_OptimizeNone:
9456 case ParsedAttr::AT_EnumExtensibility:
9459 case ParsedAttr::AT_SYCLKernel:
9462 case ParsedAttr::AT_SYCLSpecialClass:
9463 handleSimpleAttribute<SYCLSpecialClassAttr>(S, D, AL);
9465 case ParsedAttr::AT_Format:
9468 case ParsedAttr::AT_FormatArg:
9471 case ParsedAttr::AT_Callback:
9474 case ParsedAttr::AT_CalledOnce:
9477 case ParsedAttr::AT_NVPTXKernel:
9478 case ParsedAttr::AT_CUDAGlobal:
9481 case ParsedAttr::AT_CUDADevice:
9484 case ParsedAttr::AT_HIPManaged:
9487 case ParsedAttr::AT_GNUInline:
9490 case ParsedAttr::AT_CUDALaunchBounds:
9493 case ParsedAttr::AT_Restrict:
9496 case ParsedAttr::AT_Mode:
9499 case ParsedAttr::AT_NonNull:
9500 if (
auto *PVD = dyn_cast<ParmVarDecl>(D))
9505 case ParsedAttr::AT_ReturnsNonNull:
9508 case ParsedAttr::AT_NoEscape:
9511 case ParsedAttr::AT_MaybeUndef:
9512 handleSimpleAttribute<MaybeUndefAttr>(S, D, AL);
9514 case ParsedAttr::AT_AssumeAligned:
9517 case ParsedAttr::AT_AllocAlign:
9520 case ParsedAttr::AT_Ownership:
9523 case ParsedAttr::AT_Naked:
9526 case ParsedAttr::AT_NoReturn:
9529 case ParsedAttr::AT_CXX11NoReturn:
9532 case ParsedAttr::AT_AnyX86NoCfCheck:
9535 case ParsedAttr::AT_NoThrow:
9537 handleSimpleAttribute<NoThrowAttr>(S, D, AL);
9539 case ParsedAttr::AT_CUDAShared:
9542 case ParsedAttr::AT_VecReturn:
9545 case ParsedAttr::AT_ObjCOwnership:
9548 case ParsedAttr::AT_ObjCPreciseLifetime:
9551 case ParsedAttr::AT_ObjCReturnsInnerPointer:
9554 case ParsedAttr::AT_ObjCRequiresSuper:
9557 case ParsedAttr::AT_ObjCBridge:
9560 case ParsedAttr::AT_ObjCBridgeMutable:
9563 case ParsedAttr::AT_ObjCBridgeRelated:
9566 case ParsedAttr::AT_ObjCDesignatedInitializer:
9569 case ParsedAttr::AT_ObjCRuntimeName:
9572 case ParsedAttr::AT_ObjCBoxable:
9575 case ParsedAttr::AT_NSErrorDomain:
9578 case ParsedAttr::AT_CFConsumed:
9579 case ParsedAttr::AT_NSConsumed:
9580 case ParsedAttr::AT_OSConsumed:
9584 case ParsedAttr::AT_OSReturnsRetainedOnZero:
9585 handleSimpleAttributeOrDiagnose<OSReturnsRetainedOnZeroAttr>(
9587 diag::warn_ns_attribute_wrong_parameter_type,
9590 case ParsedAttr::AT_OSReturnsRetainedOnNonZero:
9591 handleSimpleAttributeOrDiagnose<OSReturnsRetainedOnNonZeroAttr>(
9593 diag::warn_ns_attribute_wrong_parameter_type,
9596 case ParsedAttr::AT_NSReturnsAutoreleased:
9597 case ParsedAttr::AT_NSReturnsNotRetained:
9598 case ParsedAttr::AT_NSReturnsRetained:
9599 case ParsedAttr::AT_CFReturnsNotRetained:
9600 case ParsedAttr::AT_CFReturnsRetained:
9601 case ParsedAttr::AT_OSReturnsNotRetained:
9602 case ParsedAttr::AT_OSReturnsRetained:
9605 case ParsedAttr::AT_WorkGroupSizeHint:
9606 handleWorkGroupSize<WorkGroupSizeHintAttr>(S, D, AL);
9608 case ParsedAttr::AT_ReqdWorkGroupSize:
9609 handleWorkGroupSize<ReqdWorkGroupSizeAttr>(S, D, AL);
9611 case ParsedAttr::AT_OpenCLIntelReqdSubGroupSize:
9614 case ParsedAttr::AT_VecTypeHint:
9617 case ParsedAttr::AT_InitPriority:
9620 case ParsedAttr::AT_Packed:
9623 case ParsedAttr::AT_PreferredName:
9626 case ParsedAttr::AT_Section:
9629 case ParsedAttr::AT_CodeModel:
9632 case ParsedAttr::AT_RandomizeLayout:
9635 case ParsedAttr::AT_NoRandomizeLayout:
9638 case ParsedAttr::AT_CodeSeg:
9641 case ParsedAttr::AT_Target:
9644 case ParsedAttr::AT_TargetVersion:
9647 case ParsedAttr::AT_TargetClones:
9650 case ParsedAttr::AT_MinVectorWidth:
9653 case ParsedAttr::AT_Unavailable:
9654 handleAttrWithMessage<UnavailableAttr>(S, D, AL);
9656 case ParsedAttr::AT_OMPAssume:
9659 case ParsedAttr::AT_ObjCDirect:
9662 case ParsedAttr::AT_ObjCDirectMembers:
9664 handleSimpleAttribute<ObjCDirectMembersAttr>(S, D, AL);
9666 case ParsedAttr::AT_ObjCExplicitProtocolImpl:
9669 case ParsedAttr::AT_Unused:
9672 case ParsedAttr::AT_Visibility:
9675 case ParsedAttr::AT_TypeVisibility:
9678 case ParsedAttr::AT_WarnUnusedResult:
9681 case ParsedAttr::AT_WeakRef:
9684 case ParsedAttr::AT_WeakImport:
9687 case ParsedAttr::AT_TransparentUnion:
9690 case ParsedAttr::AT_ObjCMethodFamily:
9693 case ParsedAttr::AT_ObjCNSObject:
9696 case ParsedAttr::AT_ObjCIndependentClass:
9699 case ParsedAttr::AT_Blocks:
9702 case ParsedAttr::AT_Sentinel:
9705 case ParsedAttr::AT_Cleanup:
9708 case ParsedAttr::AT_NoDebug:
9711 case ParsedAttr::AT_CmseNSEntry:
9714 case ParsedAttr::AT_StdCall:
9715 case ParsedAttr::AT_CDecl:
9716 case ParsedAttr::AT_FastCall:
9717 case ParsedAttr::AT_ThisCall:
9718 case ParsedAttr::AT_Pascal:
9719 case ParsedAttr::AT_RegCall:
9720 case ParsedAttr::AT_SwiftCall:
9721 case ParsedAttr::AT_SwiftAsyncCall:
9722 case ParsedAttr::AT_VectorCall:
9723 case ParsedAttr::AT_MSABI:
9724 case ParsedAttr::AT_SysVABI:
9725 case ParsedAttr::AT_Pcs:
9726 case ParsedAttr::AT_IntelOclBicc:
9727 case ParsedAttr::AT_PreserveMost:
9728 case ParsedAttr::AT_PreserveAll:
9729 case ParsedAttr::AT_AArch64VectorPcs:
9730 case ParsedAttr::AT_AArch64SVEPcs:
9731 case ParsedAttr::AT_AMDGPUKernelCall:
9732 case ParsedAttr::AT_M68kRTD:
9733 case ParsedAttr::AT_PreserveNone:
9734 case ParsedAttr::AT_RISCVVectorCC:
9737 case ParsedAttr::AT_Suppress:
9740 case ParsedAttr::AT_Owner:
9741 case ParsedAttr::AT_Pointer:
9744 case ParsedAttr::AT_OpenCLAccess:
9747 case ParsedAttr::AT_OpenCLNoSVM:
9750 case ParsedAttr::AT_SwiftContext:
9753 case ParsedAttr::AT_SwiftAsyncContext:
9756 case ParsedAttr::AT_SwiftErrorResult:
9759 case ParsedAttr::AT_SwiftIndirectResult:
9762 case ParsedAttr::AT_InternalLinkage:
9765 case ParsedAttr::AT_ZeroCallUsedRegs:
9768 case ParsedAttr::AT_FunctionReturnThunks:
9771 case ParsedAttr::AT_NoMerge:
9774 case ParsedAttr::AT_NoUniqueAddress:
9778 case ParsedAttr::AT_AvailableOnlyInDefaultEvalMethod:
9782 case ParsedAttr::AT_CountedBy:
9787 case ParsedAttr::AT_LayoutVersion:
9790 case ParsedAttr::AT_Uuid:
9793 case ParsedAttr::AT_MSInheritance:
9796 case ParsedAttr::AT_Thread:
9799 case ParsedAttr::AT_MSConstexpr:
9804 case ParsedAttr::AT_HLSLNumThreads:
9807 case ParsedAttr::AT_HLSLSV_GroupIndex:
9808 handleSimpleAttribute<HLSLSV_GroupIndexAttr>(S, D, AL);
9810 case ParsedAttr::AT_HLSLSV_DispatchThreadID:
9813 case ParsedAttr::AT_HLSLPackOffset:
9816 case ParsedAttr::AT_HLSLShader:
9819 case ParsedAttr::AT_HLSLResourceBinding:
9822 case ParsedAttr::AT_HLSLParamModifier:
9826 case ParsedAttr::AT_AbiTag:
9829 case ParsedAttr::AT_CFGuard:
9834 case ParsedAttr::AT_AssertExclusiveLock:
9837 case ParsedAttr::AT_AssertSharedLock:
9840 case ParsedAttr::AT_PtGuardedVar:
9843 case ParsedAttr::AT_NoSanitize:
9846 case ParsedAttr::AT_NoSanitizeSpecific:
9849 case ParsedAttr::AT_GuardedBy:
9852 case ParsedAttr::AT_PtGuardedBy:
9855 case ParsedAttr::AT_ExclusiveTrylockFunction:
9858 case ParsedAttr::AT_LockReturned:
9861 case ParsedAttr::AT_LocksExcluded:
9864 case ParsedAttr::AT_SharedTrylockFunction:
9867 case ParsedAttr::AT_AcquiredBefore:
9870 case ParsedAttr::AT_AcquiredAfter:
9875 case ParsedAttr::AT_Capability:
9876 case ParsedAttr::AT_Lockable:
9879 case ParsedAttr::AT_RequiresCapability:
9883 case ParsedAttr::AT_AssertCapability:
9886 case ParsedAttr::AT_AcquireCapability:
9889 case ParsedAttr::AT_ReleaseCapability:
9892 case ParsedAttr::AT_TryAcquireCapability:
9897 case ParsedAttr::AT_Consumable:
9900 case ParsedAttr::AT_CallableWhen:
9903 case ParsedAttr::AT_ParamTypestate:
9906 case ParsedAttr::AT_ReturnTypestate:
9909 case ParsedAttr::AT_SetTypestate:
9912 case ParsedAttr::AT_TestTypestate:
9917 case ParsedAttr::AT_ArgumentWithTypeTag:
9920 case ParsedAttr::AT_TypeTagForDatatype:
9925 case ParsedAttr::AT_SwiftAsyncName:
9928 case ParsedAttr::AT_SwiftAttr:
9931 case ParsedAttr::AT_SwiftBridge:
9934 case ParsedAttr::AT_SwiftError:
9937 case ParsedAttr::AT_SwiftName:
9940 case ParsedAttr::AT_SwiftNewType:
9943 case ParsedAttr::AT_SwiftAsync:
9946 case ParsedAttr::AT_SwiftAsyncError:
9951 case ParsedAttr::AT_XRayLogArgs:
9955 case ParsedAttr::AT_PatchableFunctionEntry:
9959 case ParsedAttr::AT_AlwaysDestroy:
9960 case ParsedAttr::AT_NoDestroy:
9964 case ParsedAttr::AT_Uninitialized:
9968 case ParsedAttr::AT_ObjCExternallyRetained:
9972 case ParsedAttr::AT_MIGServerRoutine:
9976 case ParsedAttr::AT_MSAllocator:
9980 case ParsedAttr::AT_ArmBuiltinAlias:
9984 case ParsedAttr::AT_ArmLocallyStreaming:
9985 handleSimpleAttribute<ArmLocallyStreamingAttr>(S, D, AL);
9988 case ParsedAttr::AT_ArmNew:
9992 case ParsedAttr::AT_AcquireHandle:
9996 case ParsedAttr::AT_ReleaseHandle:
9997 handleHandleAttr<ReleaseHandleAttr>(S, D, AL);
10000 case ParsedAttr::AT_UnsafeBufferUsage:
10001 handleUnsafeBufferUsage<UnsafeBufferUsageAttr>(S, D, AL);
10004 case ParsedAttr::AT_UseHandle:
10005 handleHandleAttr<UseHandleAttr>(S, D, AL);
10008 case ParsedAttr::AT_EnforceTCB:
10009 handleEnforceTCBAttr<EnforceTCBAttr, EnforceTCBLeafAttr>(S, D, AL);
10012 case ParsedAttr::AT_EnforceTCBLeaf:
10013 handleEnforceTCBAttr<EnforceTCBLeafAttr, EnforceTCBAttr>(S, D, AL);
10016 case ParsedAttr::AT_BuiltinAlias:
10020 case ParsedAttr::AT_PreferredType:
10024 case ParsedAttr::AT_UsingIfExists:
10025 handleSimpleAttribute<UsingIfExistsAttr>(S, D, AL);
10028 case ParsedAttr::AT_TypeNullable:
10039 if (AttrList.
empty())
10050 Diag(AttrList.
begin()->getLoc(), diag::err_attribute_weakref_without_alias)
10051 << cast<NamedDecl>(D);
10060 if (!D->
hasAttr<OpenCLKernelAttr>()) {
10062 if (
const auto *A = D->
getAttr<ReqdWorkGroupSizeAttr>()) {
10067 }
else if (
const auto *A = D->
getAttr<WorkGroupSizeHintAttr>()) {
10070 }
else if (
const auto *A = D->
getAttr<VecTypeHintAttr>()) {
10073 }
else if (
const auto *A = D->
getAttr<OpenCLIntelReqdSubGroupSizeAttr>()) {
10076 }
else if (!D->
hasAttr<CUDAGlobalAttr>()) {
10077 if (
const auto *A = D->
getAttr<AMDGPUFlatWorkGroupSizeAttr>()) {
10081 }
else if (
const auto *A = D->
getAttr<AMDGPUWavesPerEUAttr>()) {
10085 }
else if (
const auto *A = D->
getAttr<AMDGPUNumSGPRAttr>()) {
10089 }
else if (
const auto *A = D->
getAttr<AMDGPUNumVGPRAttr>()) {
10102 if (D->
hasAttr<ObjCDesignatedInitializerAttr>() &&
10103 cast<ObjCMethodDecl>(D)->getMethodFamily() !=
OMF_init) {
10105 D->
dropAttr<ObjCDesignatedInitializerAttr>();
10114 if (AL.getKind() == ParsedAttr::AT_TransparentUnion) {
10121 if (D && D->
hasAttr<BPFPreserveAccessIndexAttr>())
10130 if (AL.getKind() == ParsedAttr::AT_Annotate) {
10134 Diag(AL.getLoc(), diag::err_only_annotate_after_access_spec);
10146 if (AL.isUsedAsTypeAttr() || AL.isInvalid())
10152 S.
Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored)
10153 << AL << AL.getRange();
10155 S.
Diag(AL.getLoc(), diag::warn_attribute_not_on_decl) << AL
10176 assert(isa<FunctionDecl>(ND) || isa<VarDecl>(ND));
10178 if (
auto *FD = dyn_cast<FunctionDecl>(ND)) {
10200 for (
const auto &AI : FT->param_types()) {
10203 Params.push_back(Param);
10205 NewFD->setParams(Params);
10207 }
else if (
auto *VD = dyn_cast<VarDecl>(ND)) {
10209 VD->getInnerLocStart(), VD->getLocation(), II,
10210 VD->getType(), VD->getTypeSourceInfo(),
10211 VD->getStorageClass());
10212 if (VD->getQualifier())
10213 cast<VarDecl>(NewD)->setQualifierInfo(VD->getQualifierLoc());
10248 if (
auto *VD = dyn_cast<VarDecl>(D))
10249 if (VD->isExternC())
10251 if (
auto *FD = dyn_cast<FunctionDecl>(D))
10259 auto &WeakInfos = I->second;
10260 for (
const auto &W : WeakInfos)
10262 std::remove_reference_t<
decltype(WeakInfos)> EmptyWeakInfos;
10263 WeakInfos.swap(EmptyWeakInfos);
10279 if (AL.slidesFromDeclToDeclSpecLegacyBehavior()) {
10284 AL.diagnoseAppertainsTo(*
this, D);
10295 .WithIncludeCXX11Attributes(
false)
10296 .WithIgnoreTypeAttributes(
true));
10306 .WithIncludeCXX11Attributes(
false)
10307 .WithIgnoreTypeAttributes(
true));
10325 UnavailableAttr::ImplicitReason &reason) {
10329 if (!isa<FieldDecl>(D) && !isa<ObjCPropertyDecl>(D) &&
10330 !isa<FunctionDecl>(D))
10338 if ((isa<ObjCIvarDecl>(D) || isa<ObjCPropertyDecl>(D))) {
10341 reason = UnavailableAttr::IR_ForbiddenWeak;
10350 reason = UnavailableAttr::IR_ARCForbiddenType;
10360 auto Reason = UnavailableAttr::IR_None;
10362 assert(Reason &&
"didn't set reason?");
10367 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
10370 if (FD->
hasAttr<UnavailableAttr>() &&
10372 diag::err_arc_array_param_no_ownership) {
10403 bool AnyAccessFailures =
false;
10411 switch (diag.
Kind) {
10415 if (!
decl->isInvalidDecl())
10423 if (AnyAccessFailures && isa<DecompositionDecl>(
decl))
10427 AnyAccessFailures =
true;
10443 assert(curPool &&
"re-emitting in undelayed context not supported");
10444 curPool->
steal(pool);
Defines the clang::ASTContext interface.
static SmallString< 64 > normalizeName(const IdentifierInfo *Name, const IdentifierInfo *Scope, AttributeCommonInfo::Syntax SyntaxUsed)
static CudaArch getCudaArch(CodeGenModule &CGM)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines helper utilities for supporting the HLSL runtime environment.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Defines the clang::LangOptions interface.
llvm::MachO::Target Target
llvm::MachO::Record Record
static bool versionsMatch(const VersionTuple &X, const VersionTuple &Y)
Check whether the two versions match.
static unsigned getNumAttributeArgs(const ParsedAttr &AL)
Defines the clang::Preprocessor interface.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
This file declares semantic analysis for CUDA constructs.
static bool isCFStringType(QualType T, ASTContext &Ctx)
static void handleObjCBoxable(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleBPFPreserveAccessIndexAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleCleanupAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAlignedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleWeakImportAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleHandleAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleHLSLShaderAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkGuardedByAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, Expr *&Arg)
static void handleCodeSegAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handlePatchableFunctionEntryAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleCountedByAttrField(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAMDGPUNumVGPRAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleOpenCLAccessAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleFormatAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Handle attribute((format(type,idx,firstarg))) attributes based on http://gcc.gnu.org/onlinedocs/gcc/F...
static void handleUninitializedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isNSStringType(QualType T, ASTContext &Ctx, bool AllowNSAttributedString=false)
static void handleRequiresCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleBTFDeclTagAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleOptimizeNoneAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleEnableIfAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isFunctionOrMethodVariadic(const Decl *D)
static void handleSwiftError(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSectionAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleStandardNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &A)
static void handleMIGServerRoutineAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleGuardedByAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleZeroCallUsedRegsAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static const RecordDecl * GetEnclosingNamedOrTopAnonRecord(const FieldDecl *FD)
static void handleDiagnoseAsBuiltinAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleEnumExtensibilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static T * mergeVisibilityAttr(Sema &S, Decl *D, const AttributeCommonInfo &CI, typename T::VisibilityType value)
static bool CheckCountExpr(Sema &S, FieldDecl *FD, Expr *E, llvm::SmallVectorImpl< TypeCoupledDeclRefInfo > &Decls)
static void handleLayoutVersion(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAMDGPUWavesPerEUAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkForConsumableClass(Sema &S, const CXXMethodDecl *MD, const ParsedAttr &AL)
static void handleDLLAttr(Sema &S, Decl *D, const ParsedAttr &A)
static void handleConstantAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAlignValueAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleHLSLSV_DispatchThreadIDAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSubGroupSize(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNoCfCheckAttr(Sema &S, Decl *D, const ParsedAttr &Attrs)
static void handleArmBuiltinAliasAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleCmseNSEntryAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleOpenCLNoSVMAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleReturnsNonNullAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void checkUnusedDeclAttributes(Sema &S, const ParsedAttributesView &A)
checkUnusedDeclAttributes - Check a list of attributes to see if it contains any decl attributes that...
static void handleGNUInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkArmNewAttrMutualExclusion(Sema &S, const ParsedAttr &AL, const FunctionProtoType *FPT, FunctionType::ArmStateValue CurrentState, StringRef StateName)
static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleBuiltinAliasAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleTransparentUnionAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isErrorParameter(Sema &S, QualType QT)
static void handleEnforceTCBAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void checkAttrArgsAreCapabilityObjs(Sema &S, Decl *D, const ParsedAttr &AL, SmallVectorImpl< Expr * > &Args, unsigned Sidx=0, bool ParamIdxOk=false)
Checks that all attribute arguments, starting from Sidx, resolve to a capability object.
static QualType getFunctionOrMethodParamType(const Decl *D, unsigned Idx)
static bool isLegalTypeForHLSLSV_DispatchThreadID(QualType T)
static void handleSwiftNewType(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleObjCIndependentClass(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleXReturnsXRetainedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleErrorAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkCodeSegName(Sema &S, SourceLocation LiteralLoc, StringRef CodeSegName)
static void handleAvailabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSwiftAsyncName(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleTryAcquireCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleRISCVInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSetTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleFormatArgAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Handle attribute((format_arg((idx)))) attribute based on http://gcc.gnu.org/onlinedocs/gcc/Function-A...
static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL, const Sema::ProcessDeclAttributeOptions &Options)
ProcessDeclAttribute - Apply the specific attribute to the specified decl if the attribute applies to...
static void handleTargetAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleXRayLogArgsAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleObjCOwnershipAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static const Sema::SemaDiagnosticBuilder & appendDiagnostics(const Sema::SemaDiagnosticBuilder &Bldr)
static void handlePassObjectSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static const ParmVarDecl * getFunctionOrMethodParam(const Decl *D, unsigned Idx)
static bool ArmCdeAliasValid(unsigned BuiltinID, StringRef AliasName)
static void handleAMDGPUMaxNumWorkGroupsAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNoMergeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleArmNewAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleObjCPreciseLifetimeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkUInt32Argument(Sema &S, const AttrInfo &AI, const Expr *Expr, uint32_t &Val, unsigned Idx=UINT_MAX, bool StrictlyUnsigned=false)
If Expr is a valid integer constant, get the value of the integer expression and return success or fa...
static void handleAnyX86InterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleObjCDirectMembersAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleManagedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSwiftAttrAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAVRInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSwiftAsyncAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleParamTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleUnsafeBufferUsage(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isValidSubjectOfNSReturnsRetainedAttribute(QualType QT)
static bool attrNonNullArgCheck(Sema &S, QualType T, const ParsedAttr &AL, SourceRange AttrParmRange, SourceRange TypeRange, bool isReturnValue=false)
static void handleAcquireCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static std::enable_if_t< std::is_base_of_v< Attr, AttrInfo >, SourceLocation > getAttrLoc(const AttrInfo &AL)
A helper function to provide Attribute Location for the Attr types AND the ParsedAttr.
static void handleCPUSpecificAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleObjCRuntimeName(Sema &S, Decl *D, const ParsedAttr &AL)
static void handlePackedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleIFuncAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkFunctionOrMethodParameterIndex(Sema &S, const Decl *D, const AttrInfo &AI, unsigned AttrArgNum, const Expr *IdxExpr, ParamIdx &Idx, bool CanIndexImplicitThis=false)
Check if IdxExpr is a valid parameter index for a function or instance method D.
static void handleAbiTagAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isFunctionOrMethod(const Decl *D)
isFunctionOrMethod - Return true if the given decl has function type (function or function-typed vari...
static void handleObjCMethodFamilyAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAttrWithMessage(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleWeakRefAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleExtVectorTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleX86ForceAlignArgPointerAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleCalledOnceAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Handle 'called_once' attribute.
static void handleLockReturnedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkFunctionConditionAttr(Sema &S, Decl *D, const ParsedAttr &AL, Expr *&Cond, StringRef &Msg)
static void handleAcquiredAfterAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleExternalSourceSymbolAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNonNullAttrParameter(Sema &S, ParmVarDecl *D, const ParsedAttr &AL)
static bool checkParamIsIntegerType(Sema &S, const Decl *D, const AttrInfo &AI, unsigned AttrArgNo)
Checks to be sure that the given parameter number is in bounds, and is an integral type.
static void handleObjCReturnsInnerPointerAttr(Sema &S, Decl *D, const ParsedAttr &Attrs)
static bool checkRecordTypeForCapability(Sema &S, QualType Ty)
static void handleArgumentWithTypeTagAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkIBOutletCommon(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkAcquireOrderAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, SmallVectorImpl< Expr * > &Args)
static void handleWebAssemblyImportModuleAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleLocksExcludedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleMSAllocatorAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static AttrTy * mergeEnforceTCBAttrImpl(Sema &S, Decl *D, const AttrTy &AL)
static bool isValidSubjectOfOSAttribute(QualType QT)
static bool hasDeclarator(const Decl *D)
Return true if the given decl has a declarator that should have been processed by Sema::GetTypeForDec...
static bool ArmMveAliasValid(unsigned BuiltinID, StringRef AliasName)
static void handleConstructorAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAllocSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleConsumableAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static const RecordType * getRecordType(QualType QT)
Checks that the passed in QualType either is of RecordType or points to RecordType.
static void handleObjCExternallyRetainedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNoSanitizeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleReturnTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isValidSubjectOfNSAttribute(QualType QT)
static void handleTargetClonesAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAllocAlignAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleM68kInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleIBOutlet(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleHLSLResourceBindingAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleObjCSuppresProtocolAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkAMDGPUFlatWorkGroupSizeArguments(Sema &S, Expr *MinExpr, Expr *MaxExpr, const AMDGPUFlatWorkGroupSizeAttr &Attr)
static void handleSwiftBridge(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleBPFPreserveAIRecord(Sema &S, RecordDecl *RD)
static bool isFunctionOrMethodOrBlock(const Decl *D)
Return true if the given decl has function type (function or function-typed variable) or an Objective...
static void handlePreferredTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isValidSubjectOfCFAttribute(QualType QT)
static void checkOMPAssumeAttr(Sema &S, SourceLocation Loc, StringRef AssumptionStr)
Check if AssumptionStr is a known assumption and warn if not.
static void handleDeviceAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleHLSLPackOffsetAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handlePtGuardedByAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAlwaysInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAssertCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleVisibilityAttr(Sema &S, Decl *D, const ParsedAttr &AL, bool isTypeVisibility)
static void handleAnnotateAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static FormatAttrKind getFormatAttrKind(StringRef Format)
getFormatAttrKind - Map from format attribute names to supported format types.
static void handleNullableTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleUuidAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAcquireHandleAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isValidSwiftIndirectResultType(QualType Ty)
Pointers and references in the default address space.
static void handleWebAssemblyImportNameAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool tryMakeVariablePseudoStrong(Sema &S, VarDecl *VD, bool DiagnoseFailure)
static void handleMSConstexprAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void checkSwiftAsyncErrorBlock(Sema &S, Decl *D, const SwiftAsyncErrorAttr *ErrorAttr, const SwiftAsyncAttr *AsyncAttr)
static void handleCommonAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleTestTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkTryLockFunAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, SmallVectorImpl< Expr * > &Args)
static bool ArmBuiltinAliasValid(unsigned BuiltinID, StringRef AliasName, ArrayRef< IntrinToName > Map, const char *IntrinNames)
static void parseModeAttrArg(Sema &S, StringRef Str, unsigned &DestWidth, bool &IntegerMode, bool &ComplexMode, FloatModeKind &ExplicitType)
parseModeAttrArg - Parses attribute mode string and returns parsed type attribute.
static void handleSimpleAttribute(Sema &S, Decl *D, const AttributeCommonInfo &CI)
Applies the given attribute to the Decl without performing any additional semantic checking.
static void handleExcludeFromExplicitInstantiationAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleHLSLNumThreadsAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSharedTrylockFunctionAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleLaunchBoundsAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkAvailabilityAttr(Sema &S, SourceRange Range, IdentifierInfo *Platform, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted)
static void handleObjCBridgeMutableAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleDependencyAttr(Sema &S, Scope *Scope, Decl *D, const ParsedAttr &AL)
static void handleARMInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNoBuiltinAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleLifetimeCategoryAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNoUniqueAddressAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool validateAlignasAppliedType(Sema &S, Decl *D, const AlignedAttr &Attr, SourceLocation AttrLoc)
Perform checking of type validity.
static void handleNakedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleFunctionReturnThunksAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleDeprecatedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static SourceRange getFunctionOrMethodResultSourceRange(const Decl *D)
static Sema::RetainOwnershipKind parsedAttrToRetainOwnershipKind(const ParsedAttr &AL)
static unsigned getNumAttributeArgs(const ParsedAttr &AL)
static void handleGlobalAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSentinelAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleCodeModelAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleHLSLParamModifierAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleCallableWhenAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool hasBTFDeclTagAttr(Decl *D, StringRef Tag)
static void handleDelayedForbiddenType(Sema &S, DelayedDiagnostic &DD, Decl *D)
Handle a delayed forbidden-type diagnostic.
static void handleAssertSharedLockAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkLockFunAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, SmallVectorImpl< Expr * > &Args)
static bool RISCVAliasValid(unsigned BuiltinID, StringRef AliasName)
static void handleAssumeAlignedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSharedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleMSInheritanceAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkAMDGPUMaxNumWorkGroupsArguments(Sema &S, Expr *XExpr, Expr *YExpr, Expr *ZExpr, const AMDGPUMaxNumWorkGroupsAttr &Attr)
static void handleVecTypeHint(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleRestrictAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleMinVectorWidthAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleUnusedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static Expr * makeLaunchBoundsArgExpr(Sema &S, Expr *E, const CUDALaunchBoundsAttr &AL, const unsigned Idx)
static bool ArmSmeAliasValid(ASTContext &Context, unsigned BuiltinID, StringRef AliasName)
static void handleMipsInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleDeclspecThreadAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSYCLKernelAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAMDGPUNumSGPRAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool ArmSveAliasValid(ASTContext &Context, unsigned BuiltinID, StringRef AliasName)
static void handleInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleExclusiveTrylockFunctionAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleCallbackAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Handle attribute((callback(CalleeIdx, PayloadIdx0, ...))) attributes.
static void handleInitPriorityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Handle attribute((init_priority(priority))) attributes based on http://gcc.gnu.org/onlinedocs/gcc/C_0...
static void handlePtGuardedVarAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool hasFunctionProto(const Decl *D)
hasFunctionProto - Return true if the given decl has a argument information.
static bool checkRecordDeclForAttr(const RecordDecl *RD)
static void handleDestroyAttr(Sema &S, Decl *D, const ParsedAttr &A)
static void handleTypeTagForDatatypeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static unsigned getFunctionOrMethodNumParams(const Decl *D)
getFunctionOrMethodNumParams - Return number of function or method parameters.
static void handleRandomizeLayoutAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void markUsedForAliasOrIfunc(Sema &S, Decl *D, const ParsedAttr &AL, StringRef Str)
static bool isCapabilityExpr(Sema &S, const Expr *Ex)
static bool isValidOSObjectOutParameter(const Decl *D)
static bool isValidSwiftContextType(QualType Ty)
Pointer-like types in the default address space.
static void handleNoDebugAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSuppressAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSwiftName(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleObjCRequiresSuperAttr(Sema &S, Decl *D, const ParsedAttr &Attrs)
static void handleObjCDesignatedInitializer(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &Attrs)
static const AttrTy * findEnforceTCBAttrByName(Decl *D, StringRef Name)
static void handleWebAssemblyExportNameAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNoEscapeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAvailableOnlyInDefaultEvalMethod(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkAttrMutualExclusion(Sema &S, Decl *D, const ParsedAttr &AL)
Diagnose mutually exclusive attributes when present on a given declaration.
static bool MustDelayAttributeArguments(const ParsedAttr &AL)
static void handleNoRandomizeLayoutAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isInstanceMethod(const Decl *D)
static void handleTargetVersionAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static SourceRange getFunctionOrMethodParamRange(const Decl *D, unsigned Idx)
static void handleAVRSignalAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static QualType getFunctionOrMethodResultType(const Decl *D)
static void handleWarnUnusedResult(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleBlocksAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAssertExclusiveLockAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isIntOrBool(Expr *Exp)
Check if the passed-in expression is of type int or bool.
static void handleSimpleAttributeOrDiagnose(Sema &S, Decl *D, const AttributeCommonInfo &CI, bool PassesCheck, unsigned DiagID, DiagnosticArgs &&... ExtraArgs)
Add an attribute AttrType to declaration D, provided that PassesCheck is true.
static bool isSanitizerAttributeAllowedOnGlobals(StringRef Sanitizer)
static void handleObjCBridgeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleObjCBridgeRelatedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isValidSwiftErrorResultType(QualType Ty)
Pointers and references to pointers in the default address space.
static void handleCallConvAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkAMDGPUWavesPerEUArguments(Sema &S, Expr *MinExpr, Expr *MaxExpr, const AMDGPUWavesPerEUAttr &Attr)
static void handleMinSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool validateSwiftFunctionName(Sema &S, const ParsedAttr &AL, SourceLocation Loc, StringRef Name, unsigned &SwiftParamCount, bool &IsSingleParamInit)
static void handleOwnershipAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkTypedefTypeForCapability(QualType Ty)
static void handleAcquiredBeforeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleReleaseCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleMSP430InterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool typeHasCapability(Sema &S, QualType Ty)
static void handleAnalyzerNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleIBOutletCollection(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleObjCNSObject(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleObjCDirectAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNSErrorDomain(Sema &S, Decl *D, const ParsedAttr &Attr)
static bool threadSafetyCheckIsSmartPointer(Sema &S, const RecordType *RT)
static bool isFunctionLike(const Type &T)
static void handleOMPAssumeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleDiagnoseIfAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleCFGuardAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNonNullAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool threadSafetyCheckIsPointer(Sema &S, const Decl *D, const ParsedAttr &AL)
Check if passed in Decl is a pointer type.
static bool isForbiddenTypeAllowed(Sema &S, Decl *D, const DelayedDiagnostic &diag, UnavailableAttr::ImplicitReason &reason)
Is the given declaration allowed to use a forbidden type? If so, it'll still be annotated with an att...
static void handleInternalLinkageAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAMDGPUFlatWorkGroupSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleModeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
handleModeAttr - This attribute modifies the width of a decl with primitive type.
static void handleDestructorAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handlePreferredName(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkPositiveIntArgument(Sema &S, const AttrInfo &AI, const Expr *Expr, int &Val, unsigned Idx=UINT_MAX)
Wrapper around checkUInt32Argument, with an extra check to be sure that the result will fit into a re...
static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleVecReturnAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isGlobalVar(const Decl *D)
static void handleSwiftAsyncError(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleTLSModelAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAliasAttr(Sema &S, Decl *D, const ParsedAttr &AL)
This file declares semantic analysis for HLSL constructs.
This file declares semantic analysis for Objective-C.
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
Enumerates target-specific builtins in their own namespaces within namespace clang.
C Language Family Type Representation.
virtual void AssignInheritanceModel(CXXRecordDecl *RD)
Callback invoked when an MSInheritanceAttr has been attached to a CXXRecordDecl.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
MSGuidDecl * getMSGuidDecl(MSGuidDeclParts Parts) const
Return a declaration for the global GUID object representing the given GUID value.
SourceManager & getSourceManager()
TranslationUnitDecl * getTranslationUnitDecl() const
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
TypedefDecl * getObjCInstanceTypeDecl()
Retrieve the typedef declaration corresponding to the Objective-C "instancetype" type.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl.
DeclarationNameTable DeclarationNames
MangleContext * createMangleContext(const TargetInfo *T=nullptr)
If T is null pointer, assume the target in ASTContext.
QualType getRealTypeForBitwidth(unsigned DestWidth, FloatModeKind ExplicitType) const
getRealTypeForBitwidth - sets floating point QualTy according to specified bitwidth.
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod, bool IsBuiltin=false) const
Retrieves the default calling convention for the current target.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
Builtin::Context & BuiltinInfo
const LangOptions & getLangOpts() const
QualType getConstType(QualType T) const
Return the uniqued reference to the type for a const qualified type.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth,...
const TargetInfo * getAuxTargetInfo() const
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type.
const TargetInfo & getTargetInfo() const
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
TargetCXXABI::Kind getCXXABIKind() const
Return the C++ ABI kind that should be used.
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
uint64_t getCharWidth() const
Return the size of the character type, in bits.
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Represents an access specifier followed by colon ':'.
Attr - This represents one attribute.
SourceLocation getLocation() const
bool isMicrosoftAttribute() const
bool isClangScope() const
void setAttributeSpellingListIndex(unsigned V)
std::string getNormalizedFullName() const
Gets the normalized full name, which consists of both scope and name and with surrounding underscores...
bool isCXX11Attribute() const
bool isDeclspecAttribute() const
SourceRange getRange() const
unsigned getAttributeSpellingListIndex() const
const IdentifierInfo * getScopeName() const
bool isGNUAttribute() const
bool isRegularKeywordAttribute() const
SourceLocation getLoc() const
const IdentifierInfo * getAttrName() const
bool isStandardAttributeSyntax() const
The attribute is spelled [[]] in either C or C++ mode, including standard attributes spelled with a k...
Kind getParsedKind() const
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
This class is used for builtin types like 'int'.
bool isAuxBuiltinID(unsigned ID) const
Return true if builtin ID belongs to AuxTarget.
static bool isBuiltinFunc(llvm::StringRef Name)
Returns true if this is a libc/libm function without the '__builtin_' prefix.
unsigned getAuxBuiltinID(unsigned ID) const
Return real builtin ID (i.e.
Represents a static or instance method of a struct/union/class.
QualType getFunctionObjectParameterType() const
static bool isStaticOverloadedOperator(OverloadedOperatorKind OOK)
Returns true if the given operator is implicitly static in a record context.
Represents a C++ struct/union/class.
CXXRecordDecl * getDefinition() const
bool hasDefinition() const
MSInheritanceModel calculateInheritanceModel() const
Calculate what the inheritance model would be for this class.
Represents the this expression in C++.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
CharUnits - This is an opaque type for sizes expressed in character units.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Declaration of a class template.
const RelatedTargetVersionMapping * getVersionMapping(OSEnvPair Kind) const
The results of name lookup within a DeclContext.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isFileContext() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
A reference to a declared variable, function, enum, etc.
DeclarationNameInfo getNameInfo() const
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr, NonOdrUseReason NOUR=NOUR_None)
bool hasQualifier() const
Determine whether this declaration reference was preceded by a C++ nested-name-specifier,...
ParsedAttributes & getAttributes()
Decl - This represents one declaration (or definition), e.g.
ASTContext & getASTContext() const LLVM_READONLY
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
const FunctionType * getFunctionType(bool BlocksToo=true) const
Looks through the Decl's underlying type to extract a FunctionType when possible.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
bool canBeWeakImported(bool &IsDefinition) const
Determines whether this symbol can be weak-imported, e.g., whether it would be well-formed to add the...
bool isInvalidDecl() const
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
SourceLocation getLocation() const
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
DeclContext * getDeclContext()
SourceLocation getBeginLoc() const LLVM_READONLY
static bool isFlexibleArrayMemberLike(ASTContext &Context, const Decl *D, QualType Ty, LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel, bool IgnoreTemplateOrMacroSubstitution)
Whether it resembles a flexible array member.
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
void setLexicalDeclContext(DeclContext *DC)
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
The name of a declaration.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
SourceLocation getTypeSpecStartLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
Expr * getTrailingRequiresClause()
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
TypeSourceInfo * getTypeSourceInfo() const
Information about one declarator, including the parsed type information and the identifier.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
const ParsedAttributes & getAttributes() const
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
const ParsedAttributesView & getDeclarationAttributes() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
This represents one expression.
static bool isPotentialConstantExprUnevaluated(Expr *E, const FunctionDecl *FD, SmallVectorImpl< PartialDiagnosticAt > &Diags)
isPotentialConstantExprUnevaluated - Return true if this expression might be usable in a constant exp...
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
bool isValueDependent() const
Determines whether the value of this expression depends on.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates).
bool isIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr) const
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
Represents a function declaration or definition.
const ParmVarDecl * getParamDecl(unsigned i) const
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
param_iterator param_end()
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
void setIsMultiVersion(bool V=true)
Sets the multiversion state for this declaration and all of its redeclarations.
QualType getReturnType() const
ArrayRef< ParmVarDecl * > parameters() const
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
param_iterator param_begin()
bool isVariadic() const
Whether this function is variadic.
bool isConstexprSpecified() const
bool isExternC() const
Determines whether this function is a function with external, C linkage.
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin=false, bool isInlineSpecified=false, bool hasWrittenPrototype=true, ConstexprSpecKind ConstexprKind=ConstexprSpecKind::Unspecified, Expr *TrailingRequiresClause=nullptr)
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Represents a prototype with parameter type info, e.g.
Declaration of a template function.
FunctionType - C99 6.7.5.3 - Function Declarators.
static ArmStateValue getArmZT0State(unsigned AttrBits)
static ArmStateValue getArmZAState(unsigned AttrBits)
QualType getReturnType() const
GlobalDecl - represents a global declaration.
One of these records is kept for each identifier that is lexed.
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
StringRef getName() const
Return the actual identifier string.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
Describes an entity that is being initialized.
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
StrictFlexArraysLevelKind
@ IncompleteOnly
Any trailing array member of undefined size is a FAM.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const
clang::ObjCRuntime ObjCRuntime
std::string getOpenCLVersionString() const
Return the OpenCL C or C++ for OpenCL language name and version as a string.
unsigned getOpenCLCompatibleVersion() const
Return the OpenCL version that kernel language is compatible with.
void push_back(const T &LocalValue)
Represents the results of name lookup.
Describes a module or submodule.
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
bool isExternallyVisible() const
A C++ nested-name-specifier augmented with source location information.
Represents an ObjC class declaration.
void setHasDesignatedInitializers()
Indicate that this interface decl contains at least one initializer marked with the 'objc_designated_...
ObjCMethodDecl - Represents an instance or class method declaration.
Represents a pointer to an Objective C object.
Represents one property declaration in an Objective-C interface.
bool allowsDirectDispatch() const
Does this runtime supports direct dispatch.
void * getAsOpaquePtr() const
static OpaquePtr getFromOpaquePtr(void *P)
bool isSupported(llvm::StringRef Ext, const LangOptions &LO) const
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
unsigned getSourceIndex() const
Get the parameter index as it would normally be encoded for attributes at the source level of represe...
unsigned getASTIndex() const
Get the parameter index as it would normally be encoded at the AST level of representation: zero-orig...
A parameter attribute which changes the argument-passing ABI rule for the parameter.
Represents a parameter to a function.
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
ParsedAttr - Represents a syntactic attribute.
bool isPackExpansion() const
const AvailabilityChange & getAvailabilityDeprecated() const
unsigned getSemanticSpelling() const
If the parsed attribute has a semantic equivalent, and it would have a semantic Spelling enumeration ...
bool existsInTarget(const TargetInfo &Target) const
bool checkExactlyNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has exactly as many args as Num.
IdentifierLoc * getArgAsIdent(unsigned Arg) const
bool hasParsedType() const
const AvailabilityChange & getAvailabilityIntroduced() const
void setInvalid(bool b=true) const
bool hasVariadicArg() const
const ParsedAttrInfo & getInfo() const
void handleAttrWithDelayedArgs(Sema &S, Decl *D) const
const Expr * getReplacementExpr() const
bool hasProcessingCache() const
SourceLocation getUnavailableLoc() const
unsigned getProcessingCache() const
const IdentifierLoc * getEnvironment() const
bool acceptsExprPack() const
const Expr * getMessageExpr() const
const ParsedType & getMatchingCType() const
const ParsedType & getTypeArg() const
SourceLocation getStrictLoc() const
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this attribute.
bool isArgIdent(unsigned Arg) const
Expr * getArgAsExpr(unsigned Arg) const
bool getMustBeNull() const
bool checkAtLeastNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has at least as many args as Num.
bool isUsedAsTypeAttr() const
unsigned getNumArgMembers() const
bool isPragmaClangAttribute() const
True if the attribute is specified using '#pragma clang attribute'.
bool slidesFromDeclToDeclSpecLegacyBehavior() const
Returns whether a [[]] attribute, if specified ahead of a declaration, should be applied to the decl-...
AttributeCommonInfo::Kind getKind() const
void setProcessingCache(unsigned value) const
bool isParamExpr(size_t N) const
bool isArgExpr(unsigned Arg) const
bool getLayoutCompatible() const
ArgsUnion getArg(unsigned Arg) const
getArg - Return the specified argument.
SourceLocation getEllipsisLoc() const
bool checkAtMostNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has at most as many args as Num.
const AvailabilityChange & getAvailabilityObsoleted() const
void addAtEnd(ParsedAttr *newAttr)
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
IdentifierTable & getIdentifierTable()
A (possibly-)qualified type.
QualType withConst() const
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LangAS getAddressSpace() const
Return the address space of this type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
bool isConstQualified() const
Determine whether this type is const-qualified.
const Type * getTypePtrOrNull() const
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
ObjCLifetime getObjCLifetime() const
Represents a struct/union/class.
field_iterator field_end() const
field_range fields() const
field_iterator field_begin() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
Base for LValueReferenceType and RValueReferenceType.
Scope - A scope is a transient data structure that is used while parsing the program.
unsigned getFlags() const
getFlags - Return the flags for this scope.
@ FunctionDeclarationScope
This is a scope that corresponds to the parameters within a function prototype for a function declara...
A generic diagnostic builder for errors which may or may not be deferred.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
CUDAFunctionTarget IdentifyTarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
CUDAFunctionTarget CurrentTarget()
Gets the CUDA target for the current context.
SemaDiagnosticBuilder DiagIfHostCode(SourceLocation Loc, unsigned DiagID)
Creates a SemaDiagnosticBuilder that emits the diagnostic if the current context is "used as host cod...
HLSLNumThreadsAttr * mergeNumThreadsAttr(Decl *D, const AttributeCommonInfo &AL, int X, int Y, int Z)
HLSLShaderAttr * mergeShaderAttr(Decl *D, const AttributeCommonInfo &AL, HLSLShaderAttr::ShaderType ShaderType)
HLSLParamModifierAttr * mergeParamModifierAttr(Decl *D, const AttributeCommonInfo &AL, HLSLParamModifierAttr::Spelling Spelling)
bool isCFError(RecordDecl *D)
IdentifierInfo * getNSErrorIdent()
Retrieve the identifier "NSError".
A class which encapsulates the logic for delaying diagnostics during parsing and other processing.
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
void popWithoutEmitting(DelayedDiagnosticsState state)
Leave a delayed-diagnostic state that was previously pushed.
Sema - This implements semantic analysis and AST building for C.
bool ConstantFoldAttrArgs(const AttributeCommonInfo &CI, MutableArrayRef< Expr * > Args)
ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs (unless they are value dependent ...
BTFDeclTagAttr * mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL)
void LoadExternalWeakUndeclaredIdentifiers()
Load weak undeclared identifiers from the external source.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
EnforceTCBAttr * mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL)
bool checkTargetVersionAttr(SourceLocation LiteralLoc, Decl *D, StringRef &Str, bool &isDefault)
bool isValidPointerAttrType(QualType T, bool RefOkay=false)
Determine if type T is a valid subject for a nonnull and similar attributes.
TypeVisibilityAttr * mergeTypeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, TypeVisibilityAttr::VisibilityType Vis)
void AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, bool IsPackExpansion)
AddAlignedAttr - Adds an aligned attribute to a particular declaration.
void AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, Expr *OE)
AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular declaration.
bool checkSectionName(SourceLocation LiteralLoc, StringRef Str)
void AddPragmaAttributes(Scope *S, Decl *D)
Adds the attributes that have been specified using the '#pragma clang attribute push' directives to t...
bool checkCommonAttributeFeatures(const Decl *D, const ParsedAttr &A, bool SkipArgCountCheck=false)
Handles semantic checking for features that are common to all attributes, such as checking whether a ...
void addAMDGPUWavesPerEUAttr(Decl *D, const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
addAMDGPUWavePersEUAttr - Adds an amdgpu_waves_per_eu attribute to a particular declaration.
WebAssemblyImportNameAttr * mergeImportNameAttr(Decl *D, const WebAssemblyImportNameAttr &AL)
void addAMDGPUMaxNumWorkGroupsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *XExpr, Expr *YExpr, Expr *ZExpr)
addAMDGPUMaxNumWorkGroupsAttr - Adds an amdgpu_max_num_work_groups attribute to a particular declarat...
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl, const ParsedAttributesView &AttrList)
AMDGPUFlatWorkGroupSizeAttr * CreateAMDGPUFlatWorkGroupSizeAttr(const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
Create an AMDGPUWavesPerEUAttr attribute.
DLLImportAttr * mergeDLLImportAttr(Decl *D, const AttributeCommonInfo &CI)
ExtVectorDeclsType ExtVectorDecls
ExtVectorDecls - This is a list all the extended vector types.
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=NoFold)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
void PopParsingDeclaration(ParsingDeclState state, Decl *decl)
ErrorAttr * mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI, StringRef NewUserDiagnostic)
void redelayDiagnostics(sema::DelayedDiagnosticPool &pool)
Given a set of delayed diagnostics, re-emit them as if they had been delayed in the current context i...
VisibilityAttr * mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, VisibilityAttr::VisibilityType Vis)
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
AMDGPUWavesPerEUAttr * CreateAMDGPUWavesPerEUAttr(const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
Create an AMDGPUWavesPerEUAttr attribute.
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
ASTContext & getASTContext() const
@ None
This is not a defaultable comparison operator.
bool CheckCallingConvAttr(const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD=nullptr, CUDAFunctionTarget CFT=CUDAFunctionTarget::InvalidTarget)
Check validaty of calling convention attribute attr.
FunctionDecl * ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, bool Complain=false, DeclAccessPair *Found=nullptr, TemplateSpecCandidateSet *FailedTSC=nullptr)
Given an expression that refers to an overloaded function, try to resolve that overloaded function ex...
void ProcessPragmaWeak(Scope *S, Decl *D)
void AddXConsumedAttr(Decl *D, const AttributeCommonInfo &CI, RetainOwnershipKind K, bool IsTemplateInstantiation)
bool CheckAttrNoArgs(const ParsedAttr &CurrAttr)
bool UnifySection(StringRef SectionName, int SectionFlags, NamedDecl *TheDecl)
FPOptions & getCurFPFeatures()
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
@ UPPC_Expression
An arbitrary expression.
const LangOptions & getLangOpts() const
void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Name, bool InInstantiation=false)
AddModeAttr - Adds a mode attribute to a particular declaration.
bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type)
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
MinSizeAttr * mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI)
const LangOptions & LangOpts
static const uint64_t MaximumAlignment
AlwaysInlineAttr * mergeAlwaysInlineAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Ident)
void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AttrList, const ProcessDeclAttributeOptions &Options=ProcessDeclAttributeOptions())
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
WebAssemblyImportModuleAttr * mergeImportModuleAttr(Decl *D, const WebAssemblyImportModuleAttr &AL)
NamedDecl * getCurFunctionOrMethodDecl() const
getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method or C function we're in,...
void AddAllocAlignAttr(Decl *D, const AttributeCommonInfo &CI, Expr *ParamExpr)
AddAllocAlignAttr - Adds an alloc_align attribute to a particular declaration.
bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value)
Checks a regparm attribute, returning true if it is ill-formed and otherwise setting numParams to the...
void AddAnnotationAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Annot, MutableArrayRef< Expr * > Args)
AddAnnotationAttr - Adds an annotation Annot with Args arguments to D.
void ProcessDeclAttributeDelayed(Decl *D, const ParsedAttributesView &AttrList)
MSInheritanceAttr * mergeMSInheritanceAttr(Decl *D, const AttributeCommonInfo &CI, bool BestCase, MSInheritanceModel Model)
InternalLinkageAttr * mergeInternalLinkageAttr(Decl *D, const ParsedAttr &AL)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
@ Compatible
Compatible - the types are compatible according to the standard.
NamedDecl * DeclClonePragmaWeak(NamedDecl *ND, const IdentifierInfo *II, SourceLocation Loc)
DeclClonePragmaWeak - clone existing decl (maybe definition), #pragma weak needs a non-definition dec...
DLLExportAttr * mergeDLLExportAttr(Decl *D, const AttributeCommonInfo &CI)
AMDGPUMaxNumWorkGroupsAttr * CreateAMDGPUMaxNumWorkGroupsAttr(const AttributeCommonInfo &CI, Expr *XExpr, Expr *YExpr, Expr *ZExpr)
Create an AMDGPUMaxNumWorkGroupsAttr attribute.
CodeSegAttr * mergeCodeSegAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Name)
SectionAttr * mergeSectionAttr(Decl *D, const AttributeCommonInfo &CI, StringRef Name)
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
SourceManager & getSourceManager() const
bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str)
llvm::Error isValidSectionSpecifier(StringRef Str)
Used to implement to perform semantic checking on attribute((section("foo"))) specifiers.
void AddLaunchBoundsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks)
AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular declaration.
OptimizeNoneAttr * mergeOptimizeNoneAttr(Decl *D, const AttributeCommonInfo &CI)
void checkUnusedDeclAttributes(Declarator &D)
checkUnusedDeclAttributes - Given a declarator which is not being used to build a declaration,...
bool CheckAttrTarget(const ParsedAttr &CurrAttr)
EnforceTCBLeafAttr * mergeEnforceTCBLeafAttr(Decl *D, const EnforceTCBLeafAttr &AL)
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type.
void NoteAllOverloadCandidates(Expr *E, QualType DestType=QualType(), bool TakingAddress=false)
FormatAttr * mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Format, int FormatIdx, int FirstArg)
@ AP_PragmaClangAttribute
The availability attribute was applied using '#pragma clang attribute'.
@ AP_InferredFromOtherPlatform
The availability attribute for a specific platform was inferred from an availability attribute for an...
@ AP_Explicit
The availability attribute was specified explicitly next to the declaration.
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated",...
@ AMK_None
Don't merge availability attributes at all.
@ AMK_Override
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
@ AMK_ProtocolImplementation
Merge availability attributes for an implementation of a protocol requirement.
@ AMK_OptionalProtocolImplementation
Merge availability attributes for an implementation of an optional protocol requirement.
@ AMK_Redeclaration
Merge availability attributes for a redeclaration, which requires an exact match.
SmallVector< Decl *, 2 > WeakTopLevelDecl
WeakTopLevelDecl - Translation-unit scoped declarations generated by #pragma weak during processing o...
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
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,...
AvailabilityAttr * mergeAvailabilityAttr(NamedDecl *D, const AttributeCommonInfo &CI, IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK, int Priority, IdentifierInfo *IIEnvironment)
bool DiagnoseSwiftName(Decl *D, StringRef Name, SourceLocation Loc, const ParsedAttr &AL, bool IsAsync)
Do a check to make sure Name looks like a legal argument for the swift_name attribute applied to decl...
llvm::MapVector< IdentifierInfo *, llvm::SetVector< WeakInfo, llvm::SmallVector< WeakInfo, 1u >, llvm::SmallDenseSet< WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly > > > WeakUndeclaredIdentifiers
WeakUndeclaredIdentifiers - Identifiers contained in #pragma weak before declared.
void ProcessAPINotes(Decl *D)
Map any API notes provided for this declaration to attributes on the declaration.
void CheckAlignasUnderalignment(Decl *D)
void HandleDelayedAccessCheck(sema::DelayedDiagnostic &DD, Decl *Ctx)
DarwinSDKInfo * getDarwinSDKInfoForAvailabilityChecking(SourceLocation Loc, StringRef Platform)
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing,...
SwiftNameAttr * mergeSwiftNameAttr(Decl *D, const SwiftNameAttr &SNA, StringRef Name)
CUDALaunchBoundsAttr * CreateLaunchBoundsAttr(const AttributeCommonInfo &CI, Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks)
Create an CUDALaunchBoundsAttr attribute.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
void AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E)
AddAlignValueAttr - Adds an align_value attribute to a particular declaration.
QualType BuildCountAttributedArrayType(QualType WrappedTy, Expr *CountExpr)
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, bool BestCase, MSInheritanceModel SemanticSpelling)
bool checkStringLiteralArgumentAttr(const AttributeCommonInfo &CI, const Expr *E, StringRef &Str, SourceLocation *ArgLocation=nullptr)
Check if the argument E is a ASCII string literal.
bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall, const FunctionProtoType *Proto)
CheckFunctionCall - Check a direct function call for various correctness and safety properties not st...
ASTMutationListener * getASTMutationListener() const
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
bool isInSystemMacro(SourceLocation loc) const
Returns whether Loc is expanded from a macro in a system header.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteral - This represents a string literal expression, e.g.
bool isBeingDefined() const
Return true if this decl is currently being defined.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
TagKind getTagKind() const
Exposes information about the current target.
TargetOptions & getTargetOpts() const
Retrieve the target options.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
uint64_t getPointerWidth(LangAS AddrSpace) const
Return the width of pointers on this target, for the specified address space.
virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const
Determines whether a given calling convention is valid for the target.
bool isTLSSupported() const
Whether the target supports thread-local storage.
unsigned getMaxTLSAlign() const
Return the maximum alignment (in bits) of a TLS variable.
virtual unsigned getRegisterWidth() const
Return the "preferred" register width on this target.
virtual bool validateCpuSupports(StringRef Name) const
virtual bool doesFeatureAffectCodeGen(StringRef Feature) const
Returns true if feature has an impact on target code generation.
virtual bool validateCPUSpecificCPUDispatch(StringRef Name) const
virtual bool hasProtectedVisibility() const
Does this target support "protected" visibility?
unsigned getRegParmMax() const
virtual unsigned getUnwindWordWidth() const
virtual bool isValidFeatureName(StringRef Feature) const
Determine whether this TargetInfo supports the given feature.
unsigned getCharWidth() const
virtual ParsedTargetAttr parseTargetAttr(StringRef Str) const
virtual bool supportsTargetAttributeTune() const
Determine whether this TargetInfo supports tune in target attribute.
virtual bool shouldDLLImportComdatSymbols() const
Does this target aim for semantic compatibility with Microsoft C++ code using dllimport/export attrib...
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
virtual bool isValidCPUName(StringRef Name) const
Determine whether this TargetInfo supports the given CPU name.
const llvm::VersionTuple & getSDKVersion() const
virtual bool validateBranchProtection(StringRef Spec, StringRef Arch, BranchProtectionInfo &BPI, StringRef &Err) const
Determine if this TargetInfo supports the given branch protection specification.
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
Represents a type template specialization; the template must be a class template, a type alias templa...
[BoundsSafety] Represents information of declarations referenced by the arguments of the counted_by a...
const Type * getTypeForDecl() const
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
The base class of the type hierarchy.
bool isSizelessType() const
As an extension, we classify types as one of "sized" or "sizeless"; every type is one or the other.
bool isStructureType() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isBlockPointerType() const
bool isBooleanType() const
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
bool isVoidPointerType() const
bool isFunctionPointerType() const
bool isPointerType() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isObjCNSObjectType() const
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that the type refers to.
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool hasUnsignedIntegerRepresentation() const
Determine whether this type has an unsigned integer representation of some sort, e....
bool isExtVectorType() const
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isBitIntType() const
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isCARCBridgableType() const
Determine whether the given type T is a "bridgeable" C type.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
bool isMemberPointerType() const
bool isObjCIdType() const
bool isObjCObjectType() const
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const
Return the implicit lifetime for this type, which must not be dependent.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isObjCObjectPointerType() const
Visibility getVisibility() const
Determine the visibility of this type.
bool hasFloatingRepresentation() const
Determine whether this type has a floating-point representation of some sort, e.g....
bool isVectorType() const
bool isFloatingType() const
bool isAnyPointerType() const
const T * getAs() const
Member-template getAs<specific type>'.
const Type * getUnqualifiedDesugaredType() const
Return the specified type with any "sugar" removed from the type, removing any typedefs,...
bool isObjCRetainableType() const
bool isTypedefNameType() const
Determines whether this type is written as a typedef-name.
bool hasPointerRepresentation() const
Whether this type is represented natively as a pointer.
Base class for declarations which introduce a typedef-name.
static UnaryOperator * Create(const ASTContext &C, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)
Represents a dependent using declaration which was marked with typename.
Represents a dependent using declaration which was not marked with typename.
Represents a C++ using-declaration.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
Represents a variable declaration or definition.
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
void setARCPseudoStrong(bool PS)
@ TLS_None
Not a TLS variable.
Represents a GCC generic vector type.
Captures information about a #pragma weak directive.
const IdentifierInfo * getAlias() const
SourceLocation getLocation() const
A collection of diagnostics which were delayed.
const DelayedDiagnosticPool * getParent() const
void steal(DelayedDiagnosticPool &pool)
Steal the diagnostics from the given pool.
pool_iterator pool_end() const
SmallVectorImpl< DelayedDiagnostic >::const_iterator pool_iterator
pool_iterator pool_begin() const
A diagnostic message which has been conditionally emitted pending the complete parsing of the current...
QualType getForbiddenTypeOperand() const
unsigned getForbiddenTypeDiagnostic() const
The diagnostic ID to emit.
unsigned getForbiddenTypeArgument() const
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
The JSON file list parser is used to communicate input to InstallAPI.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
bool isa(CodeGen::Address addr)
AttributeDeclKind
These constants match the enumerated choices of warn_attribute_wrong_decl_type and err_attribute_wron...
@ ExpectedFunctionMethodOrParameter
@ ExpectedFunctionWithProtoType
@ ExpectedFunctionMethodOrBlock
@ ExpectedTypeOrNamespace
@ ExpectedVariableFieldOrTag
@ ExpectedVariableOrField
@ ExpectedFunctionOrMethod
@ ExpectedVariableOrFunction
@ ExpectedFunctionVariableOrClass
llvm::StringRef getParameterABISpelling(ParameterABI kind)
@ OK_Ordinary
An ordinary object is located at an address in memory.
CudaVersion ToCudaVersion(llvm::VersionTuple)
LLVM_READONLY bool isValidAsciiIdentifier(StringRef S, bool AllowDollar=false)
Return true if this is a valid ASCII identifier.
CudaArch StringToCudaArch(llvm::StringRef S)
@ Internal
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
Language
The language for the input, used to select and validate the language standard and possible actions.
AttributeArgumentNType
These constants match the enumerated choices of err_attribute_argument_n_type and err_attribute_argum...
@ AANT_ArgumentIntegerConstant
@ AANT_ArgumentBuiltinFunction
@ AANT_ArgumentIdentifier
@ SD_Automatic
Automatic storage duration (most local variables).
@ Property
The type of a property.
@ Result
The result type of a method or function.
ParameterABI
Kinds of parameter ABI.
@ SwiftAsyncContext
This parameter (which must have pointer type) uses the special Swift asynchronous context-pointer ABI...
@ SwiftErrorResult
This parameter (which must have pointer-to-pointer type) uses the special Swift error-result ABI trea...
@ Ordinary
This parameter uses ordinary ABI rules for its type.
@ SwiftIndirectResult
This parameter (which must have pointer type) is a Swift indirect result parameter.
@ SwiftContext
This parameter (which must have pointer type) uses the special Swift context-pointer ABI treatment.
LLVM_READONLY bool isHexDigit(unsigned char c)
Return true if this character is an ASCII hex digit: [0-9a-fA-F].
SanitizerMask parseSanitizerValue(StringRef Value, bool AllowGroups)
Parse a single value from a -fsanitize= or -fno-sanitize= value list.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
const FunctionProtoType * T
MSInheritanceModel
Assigned inheritance model for a class in the MS C++ ABI.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
@ Generic
not a target-specific vector type
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
@ Union
The "union" keyword introduces the elaborated-type-specifier.
bool IsArmStreamingFunction(const FunctionDecl *FD, bool IncludeLocallyStreaming)
Returns whether the given FunctionDecl has an __arm[_locally]_streaming attribute.
@ Other
Other implicit parameter.
@ Implicit
An implicit conversion.
const char * CudaArchToString(CudaArch A)
Represents information about a change in availability for an entity, which is part of the encoding of...
VersionTuple Version
The version number at which the change occurred.
bool isValid() const
Determine whether this availability change is valid.
static constexpr OSEnvPair macOStoMacCatalystPair()
Returns the os-environment mapping pair that's used to represent the macOS -> Mac Catalyst version ma...
static constexpr OSEnvPair iOStoWatchOSPair()
Returns the os-environment mapping pair that's used to represent the iOS -> watchOS version mapping.
static constexpr OSEnvPair iOStoTvOSPair()
Returns the os-environment mapping pair that's used to represent the iOS -> tvOS version mapping.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
DeclarationName getName() const
getName - Returns the embedded declaration name.
const ParsedAttributesView & getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
Wraps an identifier and optional source location for the identifier.
Parts of a decomposed MSGuidDecl.
uint16_t Part2
...-89ab-...
uint32_t Part1
{01234567-...
uint16_t Part3
...-cdef-...
uint8_t Part4And5[8]
...-0123-456789abcdef}
virtual AttrHandling handleDeclAttribute(Sema &S, Decl *D, const ParsedAttr &Attr) const
If this ParsedAttrInfo knows how to handle this ParsedAttr applied to this Decl then do so and return...
Contains information gathered from parsing the contents of TargetAttr.
std::vector< std::string > Features
StringRef BranchProtection