46#include "llvm/ADT/STLExtras.h"
47#include "llvm/ADT/STLForwardCompat.h"
48#include "llvm/ADT/StringExtras.h"
49#include "llvm/Demangle/Demangle.h"
50#include "llvm/IR/Assumptions.h"
51#include "llvm/MC/MCSectionMachO.h"
52#include "llvm/Support/Error.h"
53#include "llvm/Support/MathExtras.h"
54#include "llvm/Support/raw_ostream.h"
89 return isa<DeclaratorDecl>(D) || isa<BlockDecl>(D) || isa<TypedefNameDecl>(D) ||
90 isa<ObjCPropertyDecl>(D);
98 return isa<FunctionProtoType>(FnTy);
99 return isa<ObjCMethodDecl>(D) || isa<BlockDecl>(D);
107 return cast<FunctionProtoType>(FnTy)->getNumParams();
108 if (
const auto *BD = dyn_cast<BlockDecl>(D))
109 return BD->getNumParams();
110 return cast<ObjCMethodDecl>(D)->param_size();
115 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
116 return FD->getParamDecl(Idx);
117 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
118 return MD->getParamDecl(Idx);
119 if (
const auto *BD = dyn_cast<BlockDecl>(D))
120 return BD->getParamDecl(Idx);
126 return cast<FunctionProtoType>(FnTy)->getParamType(Idx);
127 if (
const auto *BD = dyn_cast<BlockDecl>(D))
128 return BD->getParamDecl(Idx)->getType();
130 return cast<ObjCMethodDecl>(D)->parameters()[Idx]->getType();
135 return PVD->getSourceRange();
141 return FnTy->getReturnType();
142 return cast<ObjCMethodDecl>(D)->getReturnType();
146 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
147 return FD->getReturnTypeSourceRange();
148 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
149 return MD->getReturnTypeSourceRange();
155 return cast<FunctionProtoType>(FnTy)->isVariadic();
156 if (
const auto *BD = dyn_cast<BlockDecl>(D))
157 return BD->isVariadic();
158 return cast<ObjCMethodDecl>(D)->isVariadic();
162 if (
const auto *MethodDecl = dyn_cast<CXXMethodDecl>(D))
163 return MethodDecl->isInstance();
168 bool AllowNSAttributedString =
false) {
179 if (AllowNSAttributedString &&
180 ClsName == &Ctx.
Idents.
get(
"NSAttributedString"))
183 return ClsName == &Ctx.
Idents.
get(
"NSString") ||
184 ClsName == &Ctx.
Idents.
get(
"NSMutableString");
210template <
typename AttrInfo>
211static std::enable_if_t<std::is_base_of_v<Attr, AttrInfo>,
SourceLocation>
213 return AL.getLocation();
222template <
typename AttrInfo>
224 uint32_t &Val,
unsigned Idx =
UINT_MAX,
225 bool StrictlyUnsigned =
false) {
226 std::optional<llvm::APSInt> I = llvm::APSInt(32);
239 if (!I->isIntN(32)) {
241 <<
toString(*I, 10,
false) << 32 << 1;
245 if (StrictlyUnsigned && I->isSigned() && I->isNegative()) {
246 S.
Diag(
getAttrLoc(AI), diag::err_attribute_requires_positive_integer)
251 Val = (uint32_t)I->getZExtValue();
258template <
typename AttrInfo>
260 int &Val,
unsigned Idx =
UINT_MAX) {
265 if (UVal > (uint32_t)std::numeric_limits<int>::max()) {
269 <<
toString(I, 10,
false) << 32 << 0;
279template <
typename AttrTy>
281 if (
const auto *A = D->
getAttr<AttrTy>()) {
282 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
285 S.
Diag(A->getLocation(), diag::note_conflicting_attribute);
291template <
typename AttrTy>
293 if (
const auto *A = D->
getAttr<AttrTy>()) {
297 S.
Diag(A->getLocation(), diag::note_conflicting_attribute);
307template <
typename AttrInfo>
309 Sema &S,
const Decl *D,
const AttrInfo &AI,
unsigned AttrArgNum,
310 const Expr *IdxExpr,
ParamIdx &Idx,
bool CanIndexImplicitThis =
false) {
321 std::optional<llvm::APSInt> IdxInt;
330 unsigned IdxSource = IdxInt->getLimitedValue(
UINT_MAX);
331 if (IdxSource < 1 || (!IV && IdxSource > NumParams)) {
332 S.
Diag(
getAttrLoc(AI), diag::err_attribute_argument_out_of_bounds)
336 if (HasImplicitThisParam && !CanIndexImplicitThis) {
337 if (IdxSource == 1) {
338 S.
Diag(
getAttrLoc(AI), diag::err_attribute_invalid_implicit_this_argument)
352 const Expr *E, StringRef &Str,
358 if (!Literal || (!Literal->isUnevaluated() && !Literal->isOrdinary())) {
364 Str = Literal->getString();
378 Diag(
Loc->Loc, diag::err_attribute_argument_type)
382 Str =
Loc->Ident->getName();
384 *ArgLocation =
Loc->Loc;
394 if (!Literal || (!Literal->isUnevaluated() && !Literal->isOrdinary())) {
399 Str = Literal->getString();
405template <
typename AttrType>
411template <
typename... DiagnosticArgs>
417template <
typename T,
typename... DiagnosticArgs>
420 DiagnosticArgs &&... ExtraArgs) {
422 std::forward<DiagnosticArgs>(ExtraArgs)...);
429template <
typename AttrType,
typename... DiagnosticArgs>
432 bool PassesCheck,
unsigned DiagID,
433 DiagnosticArgs &&... ExtraArgs) {
439 handleSimpleAttribute<AttrType>(S, D, CI);
460 bool foundStarOperator = IsOverloadedOperatorPresent(
Record, OO_Star);
461 bool foundArrowOperator = IsOverloadedOperatorPresent(
Record, OO_Arrow);
462 if (foundStarOperator && foundArrowOperator)
469 for (
const auto &BaseSpecifier : CXXRecord->bases()) {
470 if (!foundStarOperator)
471 foundStarOperator = IsOverloadedOperatorPresent(
472 BaseSpecifier.getType()->getAsRecordDecl(), OO_Star);
473 if (!foundArrowOperator)
474 foundArrowOperator = IsOverloadedOperatorPresent(
475 BaseSpecifier.getType()->getAsRecordDecl(), OO_Arrow);
478 if (foundStarOperator && foundArrowOperator)
489 const auto *VD = cast<ValueDecl>(D);
498 if (RT->isIncompleteType())
505 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_decl_not_pointer) << AL << QT;
522template <
typename AttrType>
529 if (
const auto *CRD = dyn_cast<CXXRecordDecl>(RD)) {
531 return !Base->hasAttr<AttrType>();
553 return checkRecordDeclForAttr<CapabilityAttr>(RT->
getDecl());
565 return TN->
hasAttr<CapabilityAttr>();
584 if (
const auto *E = dyn_cast<CastExpr>(Ex))
586 else if (
const auto *E = dyn_cast<ParenExpr>(Ex))
588 else if (
const auto *E = dyn_cast<UnaryOperator>(Ex)) {
589 if (E->getOpcode() == UO_LNot || E->getOpcode() == UO_AddrOf ||
590 E->getOpcode() == UO_Deref)
593 }
else if (
const auto *E = dyn_cast<BinaryOperator>(Ex)) {
594 if (E->getOpcode() == BO_LAnd || E->getOpcode() == BO_LOr)
612 bool ParamIdxOk =
false) {
617 const auto *MD = dyn_cast<const CXXMethodDecl>(D);
618 if (MD && !MD->isStatic()) {
621 if (!checkRecordDeclForAttr<CapabilityAttr>(RD) &&
622 !checkRecordDeclForAttr<ScopedLockableAttr>(RD))
624 diag::warn_thread_attribute_not_on_capability_member)
625 << AL << MD->getParent();
627 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_not_on_non_static_member)
632 for (
unsigned Idx = Sidx; Idx < AL.
getNumArgs(); ++Idx) {
637 Args.push_back(ArgExp);
641 if (
const auto *StrLit = dyn_cast<StringLiteral>(ArgExp)) {
642 if (StrLit->getLength() == 0 ||
643 (StrLit->isOrdinary() && StrLit->getString() ==
"*")) {
646 Args.push_back(ArgExp);
652 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_ignored) << AL;
653 Args.push_back(ArgExp);
661 if (
const auto *UOp = dyn_cast<UnaryOperator>(ArgExp))
662 if (UOp->getOpcode() == UO_AddrOf)
663 if (
const auto *DRE = dyn_cast<DeclRefExpr>(UOp->getSubExpr()))
664 if (DRE->getDecl()->isCXXInstanceMember())
665 ArgTy = DRE->getDecl()->getType();
671 if(!RT && ParamIdxOk) {
672 const auto *FD = dyn_cast<FunctionDecl>(D);
673 const auto *IL = dyn_cast<IntegerLiteral>(ArgExp);
675 unsigned int NumParams = FD->getNumParams();
676 llvm::APInt ArgValue = IL->getValue();
677 uint64_t ParamIdxFromOne = ArgValue.getZExtValue();
678 uint64_t ParamIdxFromZero = ParamIdxFromOne - 1;
679 if (!ArgValue.isStrictlyPositive() || ParamIdxFromOne > NumParams) {
681 diag::err_attribute_argument_out_of_bounds_extra_info)
682 << AL << Idx + 1 << NumParams;
685 ArgTy = FD->getParamDecl(ParamIdxFromZero)->getType();
694 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_argument_not_lockable)
697 Args.push_back(ArgExp);
717 unsigned Size = Args.size();
751 QualType QT = cast<ValueDecl>(D)->getType();
753 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_decl_not_lockable) << AL;
770 Expr **StartArg = &Args[0];
772 AcquiredAfterAttr(S.
Context, AL, StartArg, Args.size()));
780 Expr **StartArg = &Args[0];
782 AcquiredBeforeAttr(S.
Context, AL, StartArg, Args.size()));
799 unsigned Size = Args.size();
800 Expr **StartArg = Size == 0 ? nullptr : &Args[0];
802 AssertSharedLockAttr(S.
Context, AL, StartArg, Size));
811 unsigned Size = Args.size();
812 Expr **StartArg = Size == 0 ? nullptr : &Args[0];
814 AssertExclusiveLockAttr(S.
Context, AL, StartArg, Size));
822template <
typename AttrInfo>
824 unsigned AttrArgNo) {
825 assert(AI.isArgExpr(AttrArgNo) &&
"Expected expression argument");
826 Expr *AttrArg = AI.getArgAsExpr(AttrArgNo);
835 S.
Diag(SrcLoc, diag::err_attribute_integers_only)
850 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only) << AL;
861 ParamIdx SizeArgNo(SizeArgNoVal, D);
876 AllocSizeAttr(S.
Context, AL, SizeArgNo, NumberArgNo));
885 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
920 unsigned Size = Args.size();
934 unsigned Size = Args.size();
937 Expr **StartArg = &Args[0];
940 LocksExcludedAttr(S.
Context, AL, StartArg, Size));
944 Expr *&Cond, StringRef &Msg) {
950 Cond = Converted.
get();
957 Msg =
"<no message provided>";
963 S.
Diag(AL.
getLoc(), diag::err_attr_cond_never_constant_expr) << AL;
965 S.
Diag(PDiag.first, PDiag.second);
972 S.
Diag(AL.
getLoc(), diag::ext_clang_enable_if);
981 StringRef NewUserDiagnostic;
990 const auto *PD = isa<CXXRecordDecl>(D)
991 ? cast<DeclContext>(D)
993 if (
const auto *RD = dyn_cast<CXXRecordDecl>(PD); RD && RD->isLocalClass()) {
995 diag::warn_attribute_exclude_from_explicit_instantiation_local_class)
996 << AL << !isa<CXXRecordDecl>(D);
1000 ExcludeFromExplicitInstantiationAttr(S.
Context, AL));
1006class ArgumentDependenceChecker
1017 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD))
1020 ClassType =
nullptr;
1025 bool referencesArgs(
Expr *E) {
1033 "`this` doesn't refer to the enclosing class?");
1039 if (
const auto *PVD = dyn_cast<ParmVarDecl>(DRE->
getDecl()))
1040 if (Parms.count(PVD)) {
1051 const auto *DeclFD = cast<FunctionDecl>(D);
1053 if (
const auto *MethodDecl = dyn_cast<CXXMethodDecl>(DeclFD))
1054 if (!MethodDecl->isStatic()) {
1055 S.
Diag(AL.
getLoc(), diag::err_attribute_no_member_function) << AL;
1067 S.
Diag(
Loc, diag::err_attribute_argument_n_type) << AL << Index <<
T;
1073 auto *F = dyn_cast_if_present<DeclRefExpr>(AL.
getArgAsExpr(0));
1076 return dyn_cast_if_present<FunctionDecl>(F->getFoundDecl());
1085 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments_for)
1092 for (
unsigned I = 1; I < AL.
getNumArgs(); ++I) {
1104 if (Index > DeclFD->getNumParams()) {
1105 S.
Diag(AL.
getLoc(), diag::err_attribute_bounds_for_function)
1106 << AL << Index << DeclFD << DeclFD->getNumParams();
1111 QualType T2 = DeclFD->getParamDecl(Index - 1)->getType();
1116 << AL << Index << DeclFD << T2 << I << AttrFD << T1;
1120 Indices.push_back(Index - 1);
1124 S.
Context, AL, AttrFD, Indices.data(), Indices.size()));
1128 S.
Diag(AL.
getLoc(), diag::ext_clang_diagnose_if);
1135 StringRef DiagTypeStr;
1139 DiagnoseIfAttr::DiagnosticType DiagType;
1140 if (!DiagnoseIfAttr::ConvertStrToDiagnosticType(DiagTypeStr, DiagType)) {
1142 diag::err_diagnose_if_invalid_diagnostic_type);
1146 bool ArgDependent =
false;
1147 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
1148 ArgDependent = ArgumentDependenceChecker(FD).referencesArgs(Cond);
1150 S.
Context, AL, Cond, Msg, DiagType, ArgDependent, cast<NamedDecl>(D)));
1154 static constexpr const StringRef kWildcard =
"*";
1157 bool HasWildcard =
false;
1159 const auto AddBuiltinName = [&Names, &HasWildcard](StringRef Name) {
1160 if (Name == kWildcard)
1162 Names.push_back(Name);
1166 if (
const auto *NBA = D->
getAttr<NoBuiltinAttr>())
1167 for (StringRef BuiltinName : NBA->builtinNames())
1168 AddBuiltinName(BuiltinName);
1172 AddBuiltinName(kWildcard);
1174 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
1175 StringRef BuiltinName;
1181 AddBuiltinName(BuiltinName);
1183 S.
Diag(LiteralLoc, diag::warn_attribute_no_builtin_invalid_builtin_name)
1184 << BuiltinName << AL;
1189 Names.erase(std::unique(Names.begin(), Names.end()), Names.end());
1192 if (HasWildcard && Names.size() > 1)
1194 diag::err_attribute_no_builtin_wildcard_or_builtin_name)
1197 if (D->
hasAttr<NoBuiltinAttr>())
1200 NoBuiltinAttr(S.
Context, AL, Names.data(), Names.size()));
1204 if (D->
hasAttr<PassObjectSizeAttr>()) {
1205 S.
Diag(D->
getBeginLoc(), diag::err_attribute_only_once_per_parameter) << AL;
1227 if (!cast<ParmVarDecl>(D)->getType()->isPointerType()) {
1228 S.
Diag(D->
getBeginLoc(), diag::err_attribute_pointers_only) << AL << 1;
1236 ConsumableAttr::ConsumedState DefaultState;
1240 if (!ConsumableAttr::ConvertStrToConsumedState(IL->
Ident->
getName(),
1242 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported) << AL
1247 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1260 if (!RD->hasAttr<ConsumableAttr>()) {
1261 S.
Diag(AL.
getLoc(), diag::warn_attr_on_unconsumable_class) << RD;
1278 for (
unsigned ArgIndex = 0; ArgIndex < AL.
getNumArgs(); ++ArgIndex) {
1279 CallableWhenAttr::ConsumedState CallableState;
1281 StringRef StateString;
1292 if (!CallableWhenAttr::ConvertStrToConsumedState(StateString,
1294 S.
Diag(
Loc, diag::warn_attribute_type_not_supported) << AL << StateString;
1298 States.push_back(CallableState);
1302 CallableWhenAttr(S.
Context, AL, States.data(), States.size()));
1306 ParamTypestateAttr::ConsumedState ParamState;
1312 if (!ParamTypestateAttr::ConvertStrToConsumedState(StateString,
1314 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported)
1315 << AL << StateString;
1319 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1340 ReturnTypestateAttr::ConsumedState ReturnState;
1344 if (!ReturnTypestateAttr::ConvertStrToConsumedState(IL->
Ident->
getName(),
1346 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported) << AL
1351 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1388 SetTypestateAttr::ConsumedState NewState;
1392 if (!SetTypestateAttr::ConvertStrToConsumedState(Param, NewState)) {
1393 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported) << AL
1398 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1410 TestTypestateAttr::ConsumedState TestState;
1414 if (!TestTypestateAttr::ConvertStrToConsumedState(Param, TestState)) {
1415 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported) << AL
1420 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1434 if (
auto *TD = dyn_cast<TagDecl>(D))
1436 else if (
auto *FD = dyn_cast<FieldDecl>(D)) {
1443 if (BitfieldByteAligned)
1445 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored_for_field_of_type)
1451 if (BitfieldByteAligned)
1452 S.
Diag(AL.
getLoc(), diag::warn_attribute_packed_for_bitfield);
1458 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored) << AL;
1462 auto *RD = cast<CXXRecordDecl>(D);
1464 assert(CTD &&
"attribute does not appertain to this declaration");
1475 if (
const auto *CTSD = dyn_cast_if_present<ClassTemplateSpecializationDecl>(
1477 Template = CTSD->getSpecializedTemplate();
1479 while (TST && TST->isTypeAlias())
1482 Template = TST->getTemplateName().getAsTemplateDecl();
1491 S.
Diag(AL.
getLoc(), diag::err_attribute_preferred_name_arg_invalid)
1494 S.
Diag(TT->getDecl()->getLocation(), diag::note_entity_declared_at)
1502 if (
const auto *VD = dyn_cast<ObjCIvarDecl>(D)) {
1504 S.
Diag(AL.
getLoc(), diag::warn_iboutlet_object_type)
1505 << AL << VD->getType() << 0;
1509 else if (
const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
1511 S.
Diag(AL.
getLoc(), diag::warn_iboutlet_object_type)
1512 << AL << PD->getType() << 1;
1517 S.
Diag(AL.
getLoc(), diag::warn_attribute_iboutlet) << AL;
1535 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
1550 S.
Diag(AL.
getLoc(), diag::err_iboutletcollection_type) <<
"NSObject";
1566 QT->
isBuiltinType() ? diag::err_iboutletcollection_builtintype
1567 : diag::err_iboutletcollection_type) << QT;
1579 T =
T.getNonReferenceType();
1585 if (UT && UT->getDecl()->hasAttr<TransparentUnionAttr>()) {
1587 for (
const auto *I : UD->
fields()) {
1601 bool isReturnValue =
false) {
1604 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only)
1605 << AL << AttrParmRange << TypeRange;
1607 S.
Diag(AL.
getLoc(), diag::warn_attribute_pointers_only)
1608 << AL << AttrParmRange << TypeRange << 0;
1616 for (
unsigned I = 0; I < AL.
getNumArgs(); ++I) {
1630 NonNullArgs.push_back(Idx);
1641 I != E && !AnyPointers; ++I) {
1648 S.
Diag(AL.
getLoc(), diag::warn_attribute_nonnull_no_pointers);
1651 ParamIdx *Start = NonNullArgs.data();
1652 unsigned Size = NonNullArgs.size();
1653 llvm::array_pod_sort(Start, Start + Size);
1663 S.
Diag(AL.
getLoc(), diag::warn_attribute_nonnull_parm_no_args)
1692 QualType T = cast<ParmVarDecl>(D)->getType();
1694 S.
Diag(AL.
getLoc(), diag::warn_attribute_pointers_only)
1717 AssumeAlignedAttr TmpAttr(
Context, CI, E, OE);
1721 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
1722 << &TmpAttr << TmpAttr.getRange() << SR;
1727 std::optional<llvm::APSInt> I = llvm::APSInt(64);
1730 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1734 Diag(AttrLoc, diag::err_attribute_argument_type)
1740 if (!I->isPowerOf2()) {
1741 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
1747 Diag(CI.
getLoc(), diag::warn_assume_aligned_too_great)
1752 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1770 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
1776 const auto *FuncDecl = cast<FunctionDecl>(D);
1786 << FuncDecl->getParamDecl(Idx.
getASTIndex())->getSourceRange();
1795 StringRef AssumptionStr) {
1796 if (llvm::KnownAssumptionStrings.count(AssumptionStr))
1799 unsigned BestEditDistance = 3;
1800 StringRef Suggestion;
1801 for (
const auto &KnownAssumptionIt : llvm::KnownAssumptionStrings) {
1802 unsigned EditDistance =
1803 AssumptionStr.edit_distance(KnownAssumptionIt.getKey());
1804 if (EditDistance < BestEditDistance) {
1805 Suggestion = KnownAssumptionIt.getKey();
1806 BestEditDistance = EditDistance;
1810 if (!Suggestion.empty())
1811 S.
Diag(
Loc, diag::warn_omp_assume_attribute_string_unknown_suggested)
1812 << AssumptionStr << Suggestion;
1814 S.
Diag(
Loc, diag::warn_omp_assume_attribute_string_unknown)
1833 if (AttrName.size() > 4 && AttrName.starts_with(
"__") &&
1834 AttrName.ends_with(
"__")) {
1835 AttrName = AttrName.drop_front(2).drop_back(2);
1851 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
1857 OwnershipAttr::OwnershipKind K =
1858 OwnershipAttr(S.
Context, AL,
nullptr,
nullptr, 0).getOwnKind();
1862 case OwnershipAttr::Takes:
1863 case OwnershipAttr::Holds:
1865 S.
Diag(AL.
getLoc(), diag::err_attribute_too_few_arguments) << AL << 2;
1869 case OwnershipAttr::Returns:
1871 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 1;
1879 StringRef ModuleName =
Module->getName();
1885 for (
unsigned i = 1; i < AL.
getNumArgs(); ++i) {
1895 case OwnershipAttr::Takes:
1896 case OwnershipAttr::Holds:
1900 case OwnershipAttr::Returns:
1906 S.
Diag(AL.
getLoc(), diag::err_ownership_type) << AL << Err
1915 if (I->getOwnKind() != K && llvm::is_contained(I->args(), Idx)) {
1916 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
1919 I->isRegularKeywordAttribute());
1921 }
else if (K == OwnershipAttr::Returns &&
1922 I->getOwnKind() == OwnershipAttr::Returns) {
1925 if (!llvm::is_contained(I->args(), Idx)) {
1926 S.
Diag(I->getLocation(), diag::err_ownership_returns_index_mismatch)
1927 << I->args_begin()->getSourceIndex();
1929 S.
Diag(AL.
getLoc(), diag::note_ownership_returns_index_mismatch)
1935 OwnershipArgs.push_back(Idx);
1938 ParamIdx *Start = OwnershipArgs.data();
1939 unsigned Size = OwnershipArgs.size();
1940 llvm::array_pod_sort(Start, Start + Size);
1948 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
1964 S.
Diag(AL.
getLoc(), diag::err_attribute_weakref_not_global_context)
1965 << cast<NamedDecl>(D);
2009 std::unique_ptr<char, llvm::FreeDeleter> Demangled;
2011 Demangled.reset(llvm::itaniumDemangle(Str,
false));
2020 if (!isa<FunctionDecl>(ND) && !isa<VarDecl>(ND))
2022 if (MC->shouldMangleDeclName(ND)) {
2023 llvm::raw_svector_ostream Out(Name);
2027 Name = ND->getIdentifier()->getName();
2041 const auto *FD = cast<FunctionDecl>(D);
2043 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << FD << 1;
2057 S.
Diag(AL.
getLoc(), diag::err_alias_not_supported_on_darwin);
2065 S.
Diag(AL.
getLoc(), diag::err_alias_not_supported_on_nvptx);
2069 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
2071 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << FD << 0;
2075 const auto *VD = cast<VarDecl>(D);
2076 if (VD->isThisDeclarationADefinition() && VD->isExternallyVisible()) {
2077 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << VD << 0;
2094 if (Model !=
"global-dynamic" && Model !=
"local-dynamic"
2095 && Model !=
"initial-exec" && Model !=
"local-exec") {
2096 S.
Diag(LiteralLoc, diag::err_attr_tlsmodel_arg);
2110 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only)
2118 if (checkAttrMutualExclusion<CPUSpecificAttr>(S, D, AL))
2121 if (
const auto *
Other = D->
getAttr<CPUDispatchAttr>()) {
2122 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
2123 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
2126 }
else if (AL.
getParsedKind() == ParsedAttr::AT_CPUSpecific) {
2127 if (checkAttrMutualExclusion<CPUDispatchAttr>(S, D, AL))
2130 if (
const auto *
Other = D->
getAttr<CPUSpecificAttr>()) {
2131 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
2132 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
2139 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
2140 if (MD->getParent()->isLambda()) {
2141 S.
Diag(AL.
getLoc(), diag::err_attribute_dll_lambda) << AL;
2152 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
2161 S.
Diag(CPUArg->
Loc, diag::err_invalid_cpu_specific_dispatch_value)
2162 << CPUName << (AL.
getKind() == ParsedAttr::AT_CPUDispatch);
2168 return Target.CPUSpecificManglingCharacter(CPUName) ==
2171 S.
Diag(AL.
getLoc(), diag::warn_multiversion_duplicate_entries);
2174 CPUs.push_back(CPUArg->
Ident);
2178 if (AL.
getKind() == ParsedAttr::AT_CPUSpecific)
2180 CPUSpecificAttr(S.
Context, AL, CPUs.data(), CPUs.size()));
2183 CPUDispatchAttr(S.
Context, AL, CPUs.data(), CPUs.size()));
2188 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
2198 S.
Diag(AL.
getLoc(), diag::err_attribute_not_clinkage) << AL;
2202 const auto *FD = cast<FunctionDecl>(D);
2204 S.
Diag(AL.
getLoc(), diag::warn_attribute_cmse_entry_static);
2214 const auto &Arch = Triple.getArch();
2215 if (Arch != llvm::Triple::x86 &&
2216 (Arch != llvm::Triple::arm && Arch != llvm::Triple::thumb)) {
2217 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_on_arch)
2218 << AL << Triple.getArchName();
2224 if (S.
getLangOpts().MSVCCompat && isa<CXXMethodDecl>(D)) {
2225 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_decl_type_str)
2237 if (!isa<ObjCMethodDecl>(D)) {
2238 S.
Diag(Attrs.
getLoc(), diag::warn_attribute_wrong_decl_type)
2264 S.
Diag(Attrs.
getLoc(), diag::warn_nocf_check_attribute_ignored);
2266 handleSimpleAttribute<AnyX86NoCfCheckAttr>(S, D, Attrs);
2282 ? diag::err_keyword_not_supported_on_target
2283 : diag::warn_unknown_attribute_ignored)
2301 ? diag::err_attribute_wrong_decl_type
2302 : diag::warn_attribute_wrong_decl_type)
2338 if (VecReturnAttr *A = D->
getAttr<VecReturnAttr>()) {
2339 S.
Diag(AL.
getLoc(), diag::err_repeat_attribute) << A;
2343 const auto *R = cast<RecordDecl>(D);
2346 if (!isa<CXXRecordDecl>(R)) {
2347 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
2351 if (!cast<CXXRecordDecl>(R)->isPOD()) {
2352 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_pod_record);
2356 for (
const auto *I : R->fields()) {
2357 if ((count == 1) || !I->getType()->isVectorType()) {
2358 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
2369 if (isa<ParmVarDecl>(D)) {
2374 diag::err_carries_dependency_param_not_function_decl);
2388 S.
Diag(AL.
getLoc(), diag::ext_cxx17_attr) << AL;
2394 uint32_t priority = ConstructorAttr::DefaultPriority;
2396 S.
Diag(AL.
getLoc(), diag::err_hlsl_init_priority_unsupported);
2407 uint32_t priority = DestructorAttr::DefaultPriority;
2415template <
typename AttrTy>
2427 if (!cast<ObjCProtocolDecl>(D)->isThisDeclarationADefinition()) {
2428 S.
Diag(AL.
getLoc(), diag::err_objc_attr_protocol_requires_definition)
2438 VersionTuple Introduced,
2439 VersionTuple Deprecated,
2440 VersionTuple Obsoleted) {
2441 StringRef PlatformName
2442 = AvailabilityAttr::getPrettyPlatformName(Platform->
getName());
2443 if (PlatformName.empty())
2444 PlatformName = Platform->
getName();
2448 if (!Introduced.empty() && !Deprecated.empty() &&
2449 !(Introduced <= Deprecated)) {
2451 << 1 << PlatformName << Deprecated.getAsString()
2452 << 0 << Introduced.getAsString();
2456 if (!Introduced.empty() && !Obsoleted.empty() &&
2457 !(Introduced <= Obsoleted)) {
2459 << 2 << PlatformName << Obsoleted.getAsString()
2460 << 0 << Introduced.getAsString();
2464 if (!Deprecated.empty() && !Obsoleted.empty() &&
2465 !(Deprecated <= Obsoleted)) {
2467 << 2 << PlatformName << Obsoleted.getAsString()
2468 << 1 << Deprecated.getAsString();
2480 bool BeforeIsOkay) {
2481 if (
X.empty() || Y.empty())
2487 if (BeforeIsOkay &&
X < Y)
2495 bool Implicit, VersionTuple Introduced, VersionTuple Deprecated,
2496 VersionTuple Obsoleted,
bool IsUnavailable, StringRef Message,
2499 VersionTuple MergedIntroduced = Introduced;
2500 VersionTuple MergedDeprecated = Deprecated;
2501 VersionTuple MergedObsoleted = Obsoleted;
2502 bool FoundAny =
false;
2503 bool OverrideOrImpl =
false;
2507 OverrideOrImpl =
false;
2513 OverrideOrImpl =
true;
2519 for (
unsigned i = 0, e = Attrs.size(); i != e;) {
2520 const auto *OldAA = dyn_cast<AvailabilityAttr>(Attrs[i]);
2527 if (OldPlatform != Platform) {
2535 if (OldAA->getPriority() <
Priority)
2541 if (OldAA->getPriority() >
Priority) {
2542 Attrs.erase(Attrs.begin() + i);
2548 VersionTuple OldIntroduced = OldAA->getIntroduced();
2549 VersionTuple OldDeprecated = OldAA->getDeprecated();
2550 VersionTuple OldObsoleted = OldAA->getObsoleted();
2551 bool OldIsUnavailable = OldAA->getUnavailable();
2553 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl) ||
2554 !
versionsMatch(Deprecated, OldDeprecated, OverrideOrImpl) ||
2556 !(OldIsUnavailable == IsUnavailable ||
2557 (OverrideOrImpl && !OldIsUnavailable && IsUnavailable))) {
2558 if (OverrideOrImpl) {
2560 VersionTuple FirstVersion;
2561 VersionTuple SecondVersion;
2562 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl)) {
2564 FirstVersion = OldIntroduced;
2565 SecondVersion = Introduced;
2566 }
else if (!
versionsMatch(Deprecated, OldDeprecated, OverrideOrImpl)) {
2568 FirstVersion = Deprecated;
2569 SecondVersion = OldDeprecated;
2570 }
else if (!
versionsMatch(Obsoleted, OldObsoleted, OverrideOrImpl)) {
2572 FirstVersion = Obsoleted;
2573 SecondVersion = OldObsoleted;
2577 Diag(OldAA->getLocation(),
2578 diag::warn_mismatched_availability_override_unavail)
2579 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2590 Diag(OldAA->getLocation(),
2591 diag::warn_mismatched_availability_override)
2593 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2594 << FirstVersion.getAsString() << SecondVersion.getAsString()
2598 Diag(CI.
getLoc(), diag::note_overridden_method);
2600 Diag(CI.
getLoc(), diag::note_protocol_method);
2602 Diag(OldAA->getLocation(), diag::warn_mismatched_availability);
2603 Diag(CI.
getLoc(), diag::note_previous_attribute);
2606 Attrs.erase(Attrs.begin() + i);
2611 VersionTuple MergedIntroduced2 = MergedIntroduced;
2612 VersionTuple MergedDeprecated2 = MergedDeprecated;
2613 VersionTuple MergedObsoleted2 = MergedObsoleted;
2615 if (MergedIntroduced2.empty())
2616 MergedIntroduced2 = OldIntroduced;
2617 if (MergedDeprecated2.empty())
2618 MergedDeprecated2 = OldDeprecated;
2619 if (MergedObsoleted2.empty())
2620 MergedObsoleted2 = OldObsoleted;
2623 MergedIntroduced2, MergedDeprecated2,
2624 MergedObsoleted2)) {
2625 Attrs.erase(Attrs.begin() + i);
2630 MergedIntroduced = MergedIntroduced2;
2631 MergedDeprecated = MergedDeprecated2;
2632 MergedObsoleted = MergedObsoleted2;
2638 MergedIntroduced == Introduced &&
2639 MergedDeprecated == Deprecated &&
2640 MergedObsoleted == Obsoleted)
2646 MergedDeprecated, MergedObsoleted) &&
2648 auto *Avail = ::new (
Context) AvailabilityAttr(
2649 Context, CI, Platform, Introduced, Deprecated, Obsoleted, IsUnavailable,
2650 Message, IsStrict, Replacement,
Priority);
2658 if (isa<UsingDecl, UnresolvedUsingTypenameDecl, UnresolvedUsingValueDecl>(
2670 if (AvailabilityAttr::getPrettyPlatformName(II->
getName()).empty())
2671 S.
Diag(Platform->
Loc, diag::warn_availability_unknown_platform)
2674 auto *ND = dyn_cast<NamedDecl>(D);
2684 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getMessageExpr()))
2685 Str = SE->getString();
2686 StringRef Replacement;
2687 if (
const auto *SE =
2689 Replacement = SE->getString();
2691 if (II->
isStr(
"swift")) {
2693 (!IsUnavailable && !Deprecated.
isValid())) {
2695 diag::warn_availability_swift_unavailable_deprecated_only);
2700 if (II->
isStr(
"fuchsia")) {
2701 std::optional<unsigned>
Min, Sub;
2703 (Sub = Introduced.
Version.getSubminor())) {
2704 S.
Diag(AL.
getLoc(), diag::warn_availability_fuchsia_unavailable_minor);
2714 Obsoleted.
Version, IsUnavailable, Str, IsStrict, Replacement,
2725 else if (II->
getName() ==
"ios_app_extension")
2730 const auto *IOSToWatchOSMapping =
2735 auto adjustWatchOSVersion =
2736 [IOSToWatchOSMapping](VersionTuple Version) -> VersionTuple {
2737 if (Version.empty())
2739 auto MinimumWatchOSVersion = VersionTuple(2, 0);
2741 if (IOSToWatchOSMapping) {
2742 if (
auto MappedVersion = IOSToWatchOSMapping->map(
2743 Version, MinimumWatchOSVersion, std::nullopt)) {
2744 return *MappedVersion;
2748 auto Major = Version.getMajor();
2749 auto NewMajor = Major >= 9 ? Major - 7 : 0;
2750 if (NewMajor >= 2) {
2751 if (Version.getMinor()) {
2752 if (Version.getSubminor())
2753 return VersionTuple(NewMajor, *Version.getMinor(),
2754 *Version.getSubminor());
2756 return VersionTuple(NewMajor, *Version.getMinor());
2758 return VersionTuple(NewMajor);
2761 return MinimumWatchOSVersion;
2764 auto NewIntroduced = adjustWatchOSVersion(Introduced.
Version);
2765 auto NewDeprecated = adjustWatchOSVersion(Deprecated.
Version);
2766 auto NewObsoleted = adjustWatchOSVersion(Obsoleted.
Version);
2769 ND, AL, NewII,
true , NewIntroduced, NewDeprecated,
2770 NewObsoleted, IsUnavailable, Str, IsStrict, Replacement,
2782 else if (II->
getName() ==
"ios_app_extension")
2787 const auto *IOSToTvOSMapping =
2792 auto AdjustTvOSVersion =
2793 [IOSToTvOSMapping](VersionTuple Version) -> VersionTuple {
2794 if (Version.empty())
2797 if (IOSToTvOSMapping) {
2798 if (
auto MappedVersion = IOSToTvOSMapping->map(
2799 Version, VersionTuple(0, 0), std::nullopt)) {
2800 return *MappedVersion;
2806 auto NewIntroduced = AdjustTvOSVersion(Introduced.
Version);
2807 auto NewDeprecated = AdjustTvOSVersion(Deprecated.
Version);
2808 auto NewObsoleted = AdjustTvOSVersion(Obsoleted.
Version);
2811 ND, AL, NewII,
true , NewIntroduced, NewDeprecated,
2812 NewObsoleted, IsUnavailable, Str, IsStrict, Replacement,
2819 llvm::Triple::IOS &&
2821 auto GetSDKInfo = [&]() {
2830 else if (II->
getName() ==
"ios_app_extension")
2833 auto MinMacCatalystVersion = [](
const VersionTuple &
V) {
2836 if (
V.getMajor() < 13 ||
2837 (
V.getMajor() == 13 &&
V.getMinor() && *
V.getMinor() < 1))
2838 return VersionTuple(13, 1);
2842 ND, AL, NewII,
true ,
2843 MinMacCatalystVersion(Introduced.
Version),
2844 MinMacCatalystVersion(Deprecated.
Version),
2845 MinMacCatalystVersion(Obsoleted.
Version), IsUnavailable, Str,
2850 }
else if (II->
getName() ==
"macos" && GetSDKInfo() &&
2852 !Obsoleted.
Version.empty())) {
2853 if (
const auto *MacOStoMacCatalystMapping =
2854 GetSDKInfo()->getVersionMapping(
2861 auto RemapMacOSVersion =
2862 [&](
const VersionTuple &
V) -> std::optional<VersionTuple> {
2864 return std::nullopt;
2866 if (
V.getMajor() == 100000)
2867 return VersionTuple(100000);
2869 return MacOStoMacCatalystMapping->map(
V, VersionTuple(13, 1),
2872 std::optional<VersionTuple> NewIntroduced =
2873 RemapMacOSVersion(Introduced.
Version),
2875 RemapMacOSVersion(Deprecated.
Version),
2877 RemapMacOSVersion(Obsoleted.
Version);
2878 if (NewIntroduced || NewDeprecated || NewObsoleted) {
2879 auto VersionOrEmptyVersion =
2880 [](
const std::optional<VersionTuple> &
V) -> VersionTuple {
2881 return V ? *
V : VersionTuple();
2884 ND, AL, NewII,
true ,
2885 VersionOrEmptyVersion(NewIntroduced),
2886 VersionOrEmptyVersion(NewDeprecated),
2887 VersionOrEmptyVersion(NewObsoleted),
false, Str,
2905 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(0)))
2907 StringRef DefinedIn;
2908 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(1)))
2909 DefinedIn = SE->getString();
2910 bool IsGeneratedDeclaration = AL.
getArgAsIdent(2) !=
nullptr;
2912 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(3)))
2913 USR = SE->getString();
2921 typename T::VisibilityType value) {
2924 typename T::VisibilityType existingValue = existingAttr->
getVisibility();
2925 if (existingValue == value)
2927 S.
Diag(existingAttr->getLocation(), diag::err_mismatched_visibility);
2928 S.
Diag(CI.
getLoc(), diag::note_previous_attribute);
2936 VisibilityAttr::VisibilityType Vis) {
2937 return ::mergeVisibilityAttr<VisibilityAttr>(*
this, D, CI, Vis);
2942 TypeVisibilityAttr::VisibilityType Vis) {
2943 return ::mergeVisibilityAttr<TypeVisibilityAttr>(*
this, D, CI, Vis);
2947 bool isTypeVisibility) {
2949 if (isa<TypedefNameDecl>(D)) {
2955 if (isTypeVisibility && !(isa<TagDecl>(D) || isa<ObjCInterfaceDecl>(D) ||
2956 isa<NamespaceDecl>(D))) {
2968 VisibilityAttr::VisibilityType
type;
2969 if (!VisibilityAttr::ConvertStrToVisibilityType(TypeStr,
type)) {
2970 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported) << AL
2977 if (
type == VisibilityAttr::Protected &&
2979 S.
Diag(AL.
getLoc(), diag::warn_attribute_protected_visibility);
2980 type = VisibilityAttr::Default;
2984 if (isTypeVisibility) {
2986 D, AL, (TypeVisibilityAttr::VisibilityType)
type);
2997 S.
Diag(AL.
getLoc(), diag::err_objc_direct_on_protocol) <<
false;
3002 handleSimpleAttribute<ObjCDirectAttr>(S, D, AL);
3004 S.
Diag(AL.
getLoc(), diag::warn_objc_direct_ignored) << AL;
3011 handleSimpleAttribute<ObjCDirectMembersAttr>(S, D, AL);
3013 S.
Diag(AL.
getLoc(), diag::warn_objc_direct_ignored) << AL;
3018 const auto *M = cast<ObjCMethodDecl>(D);
3020 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3026 ObjCMethodFamilyAttr::FamilyKind F;
3027 if (!ObjCMethodFamilyAttr::ConvertStrToFamilyKind(IL->
Ident->
getName(), F)) {
3028 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported) << AL << IL->
Ident;
3032 if (F == ObjCMethodFamilyAttr::OMF_init &&
3033 !M->getReturnType()->isObjCObjectPointerType()) {
3034 S.
Diag(M->getLocation(), diag::err_init_method_bad_return_type)
3035 << M->getReturnType();
3044 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
3047 S.
Diag(TD->getLocation(), diag::err_nsobject_attribute);
3051 else if (
const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
3054 S.
Diag(PD->getLocation(), diag::err_nsobject_attribute);
3071 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
3074 S.
Diag(TD->getLocation(), diag::warn_ptr_independentclass_attribute);
3086 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3092 BlocksAttr::BlockType
type;
3093 if (!BlocksAttr::ConvertStrToBlockType(II->
getName(),
type)) {
3094 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
3102 unsigned sentinel = (
unsigned)SentinelAttr::DefaultSentinel;
3105 std::optional<llvm::APSInt> Idx = llvm::APSInt(32);
3107 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3112 if (Idx->isSigned() && Idx->isNegative()) {
3113 S.
Diag(AL.
getLoc(), diag::err_attribute_sentinel_less_than_zero)
3118 sentinel = Idx->getZExtValue();
3121 unsigned nullPos = (
unsigned)SentinelAttr::DefaultNullPos;
3124 std::optional<llvm::APSInt> Idx = llvm::APSInt(32);
3126 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3130 nullPos = Idx->getZExtValue();
3132 if ((Idx->isSigned() && Idx->isNegative()) || nullPos > 1) {
3135 S.
Diag(AL.
getLoc(), diag::err_attribute_sentinel_not_zero_or_one)
3141 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
3143 if (isa<FunctionNoProtoType>(FT)) {
3144 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_named_arguments);
3148 if (!cast<FunctionProtoType>(FT)->isVariadic()) {
3149 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
3152 }
else if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
3153 if (!MD->isVariadic()) {
3154 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
3157 }
else if (
const auto *BD = dyn_cast<BlockDecl>(D)) {
3158 if (!BD->isVariadic()) {
3159 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 1;
3162 }
else if (
const auto *
V = dyn_cast<VarDecl>(D)) {
3170 if (!cast<FunctionProtoType>(FT)->isVariadic()) {
3172 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << m;
3176 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
3182 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
3193 !isa<CXXConstructorDecl>(D)) {
3194 S.
Diag(AL.
getLoc(), diag::warn_attribute_void_function_method) << AL << 0;
3197 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
3198 if (MD->getReturnType()->isVoidType()) {
3199 S.
Diag(AL.
getLoc(), diag::warn_attribute_void_function_method) << AL << 1;
3207 if (isa<VarDecl>(D))
3208 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type_str)
3210 <<
"functions, classes, or enumerations";
3219 if (LO.CPlusPlus && !LO.CPlusPlus20)
3220 S.
Diag(AL.
getLoc(), diag::ext_cxx20_attr) << AL;
3228 }
else if (LO.CPlusPlus && !LO.CPlusPlus17)
3229 S.
Diag(AL.
getLoc(), diag::ext_cxx17_attr) << AL;
3234 isa<TypedefNameDecl>(D)) {
3235 S.
Diag(AL.
getLoc(), diag::warn_unused_result_typedef_unsupported_spelling)
3248 S.
Diag(AL.
getLoc(), diag::warn_attribute_invalid_on_definition)
3250 else if (isa<ObjCPropertyDecl>(D) || isa<ObjCMethodDecl>(D) ||
3252 (isa<ObjCInterfaceDecl>(D) || isa<EnumDecl>(D)))) {
3255 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
3265template <
typename WorkGroupAttr>
3268 for (
unsigned i = 0; i < 3; ++i) {
3273 if (WGSize[i] == 0) {
3274 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_is_zero)
3280 WorkGroupAttr *Existing = D->
getAttr<WorkGroupAttr>();
3281 if (Existing && !(Existing->getXDim() == WGSize[0] &&
3282 Existing->getYDim() == WGSize[1] &&
3283 Existing->getZDim() == WGSize[2]))
3284 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3287 WorkGroupAttr(S.
Context, AL, WGSize[0], WGSize[1], WGSize[2]));
3297 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_is_zero)
3302 OpenCLIntelReqdSubGroupSizeAttr *Existing =
3303 D->
getAttr<OpenCLIntelReqdSubGroupSizeAttr>();
3304 if (Existing && Existing->getSubGroupSize() != SGSize)
3305 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3308 OpenCLIntelReqdSubGroupSizeAttr(S.
Context, AL, SGSize));
3313 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
3319 assert(ParmTSI &&
"no type source info for attribute argument");
3324 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_argument) << 2 << AL;
3328 if (VecTypeHintAttr *A = D->
getAttr<VecTypeHintAttr>()) {
3330 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3342 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
3347 if (SectionAttr *ExistingAttr = D->
getAttr<SectionAttr>()) {
3348 if (ExistingAttr->getName() == Name)
3350 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section)
3352 Diag(CI.
getLoc(), diag::note_previous_attribute);
3369 return llvm::Error::success();
3372 StringRef Segment, Section;
3373 unsigned TAA, StubSize;
3375 return llvm::MCSectionMachO::ParseSectionSpecifier(SecName, Segment, Section,
3376 TAA, HasTAA, StubSize);
3381 Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
3406 cast<NamedDecl>(D));
3417 llvm::CodeModel::Model CM;
3418 if (!CodeModelAttr::ConvertStrToModel(Str, CM)) {
3419 S.
Diag(LiteralLoc, diag::err_attr_codemodel_arg) << Str;
3429 StringRef CodeSegName) {
3431 S.
Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
3443 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
3447 if (
const auto *ExistingAttr = D->
getAttr<CodeSegAttr>()) {
3448 if (ExistingAttr->getName() == Name)
3450 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section)
3452 Diag(CI.
getLoc(), diag::note_previous_attribute);
3465 if (
const auto *ExistingAttr = D->
getAttr<CodeSegAttr>()) {
3466 if (!ExistingAttr->isImplicit()) {
3468 ExistingAttr->getName() == Str
3469 ? diag::warn_duplicate_codeseg_attribute
3470 : diag::err_conflicting_codeseg_attribute);
3482 enum FirstParam { Unsupported, Duplicate,
Unknown };
3483 enum SecondParam {
None, CPU, Tune };
3485 if (AttrStr.contains(
"fpmath="))
3486 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3487 << Unsupported <<
None <<
"fpmath=" <<
Target;
3491 AttrStr.contains(
"tune="))
3492 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3498 if (!ParsedAttrs.
CPU.empty() &&
3500 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3503 if (!ParsedAttrs.
Tune.empty() &&
3505 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3510 return Diag(LiteralLoc, diag::err_duplicate_target_attribute)
3514 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3517 for (
const auto &Feature : ParsedAttrs.
Features) {
3518 auto CurFeature = StringRef(Feature).drop_front();
3520 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3521 << Unsupported <<
None << CurFeature <<
Target;
3530 if (DiagMsg.empty())
3531 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3532 << Unsupported <<
None <<
"branch-protection" <<
Target;
3533 return Diag(LiteralLoc, diag::err_invalid_branch_protection_spec)
3536 if (!DiagMsg.empty())
3537 Diag(LiteralLoc, diag::warn_unsupported_branch_protection_spec) << DiagMsg;
3544 StringRef &AttrStr,
bool &isDefault) {
3545 enum FirstParam { Unsupported };
3546 enum SecondParam {
None };
3548 if (AttrStr.trim() ==
"default")
3551 AttrStr.split(Features,
"+");
3552 for (
auto &CurFeature : Features) {
3553 CurFeature = CurFeature.trim();
3554 if (CurFeature ==
"default")
3557 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3562 return Diag(LiteralLoc, diag::err_sme_streaming_cannot_be_multiversioned);
3569 bool isDefault =
false;
3575 TargetVersionAttr *NewAttr =
3588 TargetAttr *NewAttr = ::new (S.
Context) TargetAttr(S.
Context, AL, Str);
3594 Decl *D,
bool &HasDefault,
bool &HasCommas,
bool &HasNotDefault,
3596 enum FirstParam { Unsupported, Duplicate,
Unknown };
3597 enum SecondParam {
None, CPU, Tune };
3599 HasCommas = HasCommas || Str.contains(
',');
3602 if (Str.size() == 0)
3603 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3606 std::pair<StringRef, StringRef> Parts = {{}, Str};
3607 while (!Parts.second.empty()) {
3608 Parts = Parts.second.split(
',');
3609 StringRef Cur = Parts.first.trim();
3611 Literal->getLocationOfByte(Cur.data() - Literal->getString().data(),
3614 bool DefaultIsDupe =
false;
3615 bool HasCodeGenImpact =
false;
3617 return Diag(CurLoc, diag::warn_unsupported_target_attribute)
3622 if (Cur ==
"default") {
3623 DefaultIsDupe = HasDefault;
3625 if (llvm::is_contained(StringsBuffer, Cur) || DefaultIsDupe)
3626 Diag(CurLoc, diag::warn_target_clone_duplicate_options);
3628 StringsBuffer.push_back(Cur);
3630 std::pair<StringRef, StringRef> CurParts = {{}, Cur};
3632 while (!CurParts.second.empty()) {
3633 CurParts = CurParts.second.split(
'+');
3634 StringRef CurFeature = CurParts.first.trim();
3636 Diag(CurLoc, diag::warn_unsupported_target_attribute)
3641 HasCodeGenImpact =
true;
3642 CurFeatures.push_back(CurFeature);
3645 llvm::sort(CurFeatures);
3647 for (
auto &CurFeat : CurFeatures) {
3650 Res.append(CurFeat);
3652 if (llvm::is_contained(StringsBuffer, Res) || DefaultIsDupe)
3653 Diag(CurLoc, diag::warn_target_clone_duplicate_options);
3654 else if (!HasCodeGenImpact)
3657 Diag(CurLoc, diag::warn_target_clone_no_impact_options);
3658 else if (!Res.empty()) {
3659 StringsBuffer.push_back(Res);
3660 HasNotDefault =
true;
3665 return Diag(LiteralLoc,
3666 diag::err_sme_streaming_cannot_be_multiversioned);
3669 if (Cur.starts_with(
"arch=")) {
3671 Cur.drop_front(
sizeof(
"arch=") - 1)))
3672 return Diag(CurLoc, diag::warn_unsupported_target_attribute)
3673 << Unsupported << CPU << Cur.drop_front(
sizeof(
"arch=") - 1)
3675 }
else if (Cur ==
"default") {
3676 DefaultIsDupe = HasDefault;
3679 return Diag(CurLoc, diag::warn_unsupported_target_attribute)
3681 if (llvm::is_contained(StringsBuffer, Cur) || DefaultIsDupe)
3682 Diag(CurLoc, diag::warn_target_clone_duplicate_options);
3684 StringsBuffer.push_back(Cur);
3687 if (Str.rtrim().ends_with(
","))
3688 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3700 if (
const auto *
Other = D->
getAttr<TargetClonesAttr>()) {
3701 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
3702 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
3705 if (checkAttrMutualExclusion<TargetClonesAttr>(S, D, AL))
3710 bool HasCommas =
false, HasDefault =
false, HasNotDefault =
false;
3712 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
3719 HasDefault, HasCommas, HasNotDefault, StringsBuffer))
3722 for (
auto &SmallStr : StringsBuffer)
3723 Strings.push_back(SmallStr.str());
3726 S.
Diag(AL.
getLoc(), diag::warn_target_clone_mixed_values);
3731 Strings.push_back(
"default");
3735 S.
Diag(AL.
getLoc(), diag::err_target_clone_must_have_default);
3741 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
3742 if (MD->getParent()->isLambda()) {
3754 cast<FunctionDecl>(D)->setIsMultiVersion();
3755 TargetClonesAttr *NewAttr = ::new (S.
Context)
3756 TargetClonesAttr(S.
Context, AL, Strings.data(), Strings.size());
3768 MinVectorWidthAttr *Existing = D->
getAttr<MinVectorWidthAttr>();
3769 if (Existing && Existing->getVectorWidth() != VecWidth) {
3770 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3785 if (
auto *DRE = dyn_cast<DeclRefExpr>(E)) {
3787 S.
Diag(
Loc, diag::warn_cleanup_ext);
3788 FD = dyn_cast<FunctionDecl>(DRE->
getDecl());
3791 S.
Diag(
Loc, diag::err_attribute_cleanup_arg_not_function) << 1
3795 }
else if (
auto *ULE = dyn_cast<UnresolvedLookupExpr>(E)) {
3796 if (ULE->hasExplicitTemplateArgs())
3797 S.
Diag(
Loc, diag::warn_cleanup_ext);
3799 NI = ULE->getNameInfo();
3801 S.
Diag(
Loc, diag::err_attribute_cleanup_arg_not_function) << 2
3808 S.
Diag(
Loc, diag::err_attribute_cleanup_arg_not_function) << 0;
3813 S.
Diag(
Loc, diag::err_attribute_cleanup_func_must_take_one_arg)
3824 S.
Diag(
Loc, diag::err_attribute_cleanup_func_arg_incompatible_type)
3825 << NI.
getName() << ParamTy << Ty;
3828 VarDecl *VD = cast<VarDecl>(D);
3839 S.
Context, VariableReference, UnaryOperatorKind::UO_AddrOf,
3859 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3864 EnumExtensibilityAttr::Kind ExtensibilityKind;
3866 if (!EnumExtensibilityAttr::ConvertStrToKind(II->
getName(),
3867 ExtensibilityKind)) {
3868 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
3873 EnumExtensibilityAttr(S.
Context, AL, ExtensibilityKind));
3888 if (NotNSStringTy &&
3892 S.
Diag(AL.
getLoc(), diag::err_format_attribute_not)
3900 if (
auto *OMD = dyn_cast<ObjCMethodDecl>(D))
3901 if (
auto *
Interface = OMD->getClassInterface())
3908 S.
Diag(AL.
getLoc(), diag::err_format_attribute_result_not)
3909 << (NotNSStringTy ?
"string type" :
"NSString")
3929 return llvm::StringSwitch<FormatAttrKind>(Format)
3943 .Cases(
"gcc_diag",
"gcc_cdiag",
"gcc_cxxdiag",
"gcc_tdiag",
IgnoredFormat)
3951 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored) << AL;
3956 S.
Diag(AL.
getLoc(), diag::err_hlsl_init_priority_unsupported);
3961 S.
Diag(AL.
getLoc(), diag::err_init_priority_object_attr);
3965 QualType T = cast<VarDecl>(D)->getType();
3969 S.
Diag(AL.
getLoc(), diag::err_init_priority_object_attr);
3975 uint32_t prioritynum;
3984 if ((prioritynum < 101 || prioritynum > 65535) &&
3986 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_range)
3995 StringRef NewUserDiagnostic) {
3996 if (
const auto *EA = D->
getAttr<ErrorAttr>()) {
3998 assert((NewAttr ==
"error" || NewAttr ==
"warning") &&
3999 "unexpected normalized full name");
4000 bool Match = (EA->isError() && NewAttr ==
"error") ||
4001 (EA->isWarning() && NewAttr ==
"warning");
4003 Diag(EA->getLocation(), diag::err_attributes_are_not_compatible)
4006 EA->isRegularKeywordAttribute());
4007 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
4010 if (EA->getUserDiagnostic() != NewUserDiagnostic) {
4011 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << EA;
4012 Diag(EA->getLoc(), diag::note_previous_attribute);
4016 return ::new (
Context) ErrorAttr(
Context, CI, NewUserDiagnostic);
4024 if (F->getType() == Format &&
4025 F->getFormatIdx() == FormatIdx &&
4026 F->getFirstArg() == FirstArg) {
4029 if (F->getLocation().isInvalid())
4035 return ::new (
Context) FormatAttr(
Context, CI, Format, FormatIdx, FirstArg);
4042 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
4053 StringRef Format = II->
getName();
4067 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
4078 if (Idx < 1 || Idx > NumArgs) {
4079 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4085 unsigned ArgIdx = Idx - 1;
4087 if (HasImplicitThisParam) {
4090 diag::err_format_attribute_implicit_this_format_string)
4104 S.
Diag(AL.
getLoc(), diag::err_format_attribute_not)
4116 if (FirstArg != 0) {
4120 S.
Diag(AL.
getLoc(), diag::err_format_strftime_third_parameter)
4128 if (FirstArg != NumArgs + 1) {
4129 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4132 std::to_string(NumArgs + 1));
4137 S.
Diag(D->
getLocation(), diag::warn_gcc_requires_variadic_function) << AL;
4138 if (FirstArg <= Idx) {
4142 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4158 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_no_callee)
4167 assert(FD &&
"Expected a function declaration!");
4169 llvm::StringMap<int> NameIdxMapping;
4170 NameIdxMapping[
"__"] = -1;
4172 NameIdxMapping[
"this"] = 0;
4176 NameIdxMapping[PVD->getName()] = Idx++;
4178 auto UnknownName = NameIdxMapping.end();
4181 for (
unsigned I = 0, E = AL.
getNumArgs(); I < E; ++I) {
4187 auto It = NameIdxMapping.find(IdLoc->
Ident->
getName());
4188 if (It == UnknownName) {
4189 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_argument_unknown)
4195 ArgIdx = It->second;
4202 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4208 if (ArgIdx < -1 || ArgIdx > NumArgs) {
4209 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4216 llvm_unreachable(
"Unexpected ParsedAttr argument type!");
4219 if (ArgIdx == 0 && !HasImplicitThisParam) {
4220 S.
Diag(AL.
getLoc(), diag::err_callback_implicit_this_not_available)
4227 if (!HasImplicitThisParam && ArgIdx > 0)
4230 EncodingIndices.push_back(ArgIdx);
4233 int CalleeIdx = EncodingIndices.front();
4237 if (CalleeIdx < (
int)HasImplicitThisParam) {
4238 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_invalid_callee)
4245 const Type *CalleeType =
4249 S.
Diag(AL.
getLoc(), diag::err_callback_callee_no_function_type)
4254 const Type *CalleeFnType =
4259 const auto *CalleeFnProtoType = dyn_cast<FunctionProtoType>(CalleeFnType);
4260 if (!CalleeFnProtoType) {
4261 S.
Diag(AL.
getLoc(), diag::err_callback_callee_no_function_type)
4266 if (CalleeFnProtoType->getNumParams() > EncodingIndices.size() - 1) {
4267 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments)
4268 << AL << (
unsigned)(EncodingIndices.size() - 1);
4272 if (CalleeFnProtoType->getNumParams() < EncodingIndices.size() - 1) {
4273 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments)
4274 << AL << (
unsigned)(EncodingIndices.size() - 1);
4278 if (CalleeFnProtoType->isVariadic()) {
4284 if (D->
hasAttr<CallbackAttr>()) {
4290 S.
Context, AL, EncodingIndices.data(), EncodingIndices.size()));
4303 QualType T = cast<ParmVarDecl>(D)->getType();
4306 S.
Diag(AL.
getLoc(), diag::err_called_once_attribute_wrong_type);
4316 const auto *TD = dyn_cast<TypedefNameDecl>(D);
4317 if (TD && TD->getUnderlyingType()->isUnionType())
4318 RD = TD->getUnderlyingType()->getAsUnionType()->getDecl();
4320 RD = dyn_cast<RecordDecl>(D);
4323 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
4331 diag::warn_transparent_union_attribute_not_definition);
4337 if (Field == FieldEnd) {
4338 S.
Diag(AL.
getLoc(), diag::warn_transparent_union_attribute_zero_fields);
4346 diag::warn_transparent_union_attribute_floating)
4355 for (; Field != FieldEnd; ++Field) {
4356 QualType FieldType = Field->getType();
4370 S.
Diag(Field->getLocation(),
4371 diag::warn_transparent_union_attribute_field_size_align)
4372 << isSize << *Field << FieldBits;
4373 unsigned FirstBits = isSize ? FirstSize : FirstAlign;
4375 diag::note_transparent_union_first_field_size_align)
4376 << isSize << FirstBits;
4386 auto *
Attr = AnnotateAttr::Create(
Context, Str, Args.data(), Args.size(), CI);
4402 for (
unsigned Idx = 1; Idx < AL.
getNumArgs(); Idx++) {
4415 AlignValueAttr TmpAttr(
Context, CI, E);
4419 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D))
4420 T = TD->getUnderlyingType();
4421 else if (
const auto *VD = dyn_cast<ValueDecl>(D))
4424 llvm_unreachable(
"Unknown decl type for align_value");
4428 Diag(AttrLoc, diag::warn_attribute_pointer_or_reference_only)
4434 llvm::APSInt Alignment;
4436 E, &Alignment, diag::err_align_value_attribute_argument_not_int);
4440 if (!Alignment.isPowerOf2()) {
4441 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
4463 diag::err_pack_expansion_without_parameter_packs);
4478 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
4490 diag::err_pack_expansion_without_parameter_packs);
4517 const AlignedAttr &
Attr,
4520 if (isa<ParmVarDecl>(D)) {
4522 }
else if (
const auto *VD = dyn_cast<VarDecl>(D)) {
4525 if (VD->isExceptionVariable())
4527 }
else if (
const auto *FD = dyn_cast<FieldDecl>(D)) {
4528 if (FD->isBitField())
4530 }
else if (
const auto *ED = dyn_cast<EnumDecl>(D)) {
4531 if (ED->getLangOpts().CPlusPlus)
4533 }
else if (!isa<TagDecl>(D)) {
4534 return S.
Diag(AttrLoc, diag::err_attribute_wrong_decl_type)
4539 if (DiagKind != -1) {
4540 return S.
Diag(AttrLoc, diag::err_alignas_attribute_wrong_decl_type)
4541 << &
Attr << DiagKind;
4547 bool IsPackExpansion) {
4548 AlignedAttr TmpAttr(
Context, CI,
true, E);
4552 if (TmpAttr.isAlignas() &&
4560 if (
const auto *TND = dyn_cast<TypedefNameDecl>(D)) {
4561 if (!TND->getUnderlyingType()->isDependentType()) {
4562 Diag(AttrLoc, diag::err_alignment_dependent_typedef_name)
4569 AlignedAttr *AA = ::new (
Context) AlignedAttr(
Context, CI,
true, E);
4570 AA->setPackExpansion(IsPackExpansion);
4576 llvm::APSInt Alignment;
4578 E, &Alignment, diag::err_aligned_attribute_argument_not_int);
4586 Diag(AttrLoc, diag::err_attribute_aligned_too_great)
4591 uint64_t AlignVal = Alignment.getZExtValue();
4597 if (!(TmpAttr.isAlignas() && !Alignment)) {
4598 if (!llvm::isPowerOf2_64(AlignVal)) {
4599 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
4605 const auto *VD = dyn_cast<VarDecl>(D);
4607 unsigned MaxTLSAlign =
4610 if (MaxTLSAlign && AlignVal > MaxTLSAlign &&
4612 Diag(VD->getLocation(), diag::err_tls_var_aligned_over_maximum)
4613 << (
unsigned)AlignVal << VD << MaxTLSAlign;
4621 const Type *Ty = VD->getType().getTypePtr();
4623 Diag(VD->getLocation(), diag::warn_aligned_attr_underaligned)
4624 << VD->getType() << 16;
4630 AA->setPackExpansion(IsPackExpansion);
4631 AA->setCachedAlignmentValue(
4638 AlignedAttr TmpAttr(
Context, CI,
false, TS);
4642 if (TmpAttr.isAlignas() &&
4650 if (
const auto *TND = dyn_cast<TypedefNameDecl>(D)) {
4651 if (!TND->getUnderlyingType()->isDependentType()) {
4652 Diag(AttrLoc, diag::err_alignment_dependent_typedef_name)
4658 AlignedAttr *AA = ::new (
Context) AlignedAttr(
Context, CI,
false, TS);
4659 AA->setPackExpansion(IsPackExpansion);
4664 const auto *VD = dyn_cast<VarDecl>(D);
4665 unsigned AlignVal = TmpAttr.getAlignment(
Context);
4669 const Type *Ty = VD->getType().getTypePtr();
4672 Diag(VD->getLocation(), diag::warn_aligned_attr_underaligned)
4673 << VD->getType() << 16;
4678 AlignedAttr *AA = ::new (
Context) AlignedAttr(
Context, CI,
false, TS);
4679 AA->setPackExpansion(IsPackExpansion);
4680 AA->setCachedAlignmentValue(AlignVal);
4685 assert(D->
hasAttrs() &&
"no attributes on decl");
4688 if (
const auto *VD = dyn_cast<ValueDecl>(D)) {
4689 UnderlyingTy = DiagTy = VD->getType();
4692 if (
const auto *ED = dyn_cast<EnumDecl>(D))
4693 UnderlyingTy = ED->getIntegerType();
4702 AlignedAttr *AlignasAttr =
nullptr;
4703 AlignedAttr *LastAlignedAttr =
nullptr;
4706 if (I->isAlignmentDependent())
4710 Align = std::max(Align, I->getAlignment(
Context));
4711 LastAlignedAttr = I;
4715 Diag(LastAlignedAttr->getLocation(), diag::err_attribute_sizeless_type)
4716 << LastAlignedAttr << DiagTy;
4717 }
else if (AlignasAttr && Align) {
4720 if (NaturalAlign > RequestedAlign)
4721 Diag(AlignasAttr->getLocation(), diag::err_alignas_underaligned)
4757 bool &IntegerMode,
bool &ComplexMode,
4760 ComplexMode =
false;
4762 switch (Str.size()) {
4782 DestWidth = Str[1] ==
'I' ? 0 : 128;
4790 DestWidth = Str[1] ==
'I' ? 0 : 128;
4793 if (Str[1] ==
'F') {
4794 IntegerMode =
false;
4795 }
else if (Str[1] ==
'C') {
4796 IntegerMode =
false;
4798 }
else if (Str[1] !=
'I') {
4807 else if (Str ==
"byte")
4811 if (Str ==
"pointer")
4815 if (Str ==
"unwind_word")
4831 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
4843 StringRef Str = Name->getName();
4847 unsigned DestWidth = 0;
4848 bool IntegerMode =
true;
4849 bool ComplexMode =
false;
4851 llvm::APInt VectorSize(64, 0);
4852 if (Str.size() >= 4 && Str[0] ==
'V') {
4854 size_t StrSize = Str.size();
4855 size_t VectorStringLength = 0;
4856 while ((VectorStringLength + 1) < StrSize &&
4857 isdigit(Str[VectorStringLength + 1]))
4858 ++VectorStringLength;
4859 if (VectorStringLength &&
4860 !Str.substr(1, VectorStringLength).getAsInteger(10, VectorSize) &&
4861 VectorSize.isPowerOf2()) {
4863 IntegerMode, ComplexMode, ExplicitType);
4865 if (!InInstantiation)
4866 Diag(AttrLoc, diag::warn_vector_mode_deprecated);
4881 Diag(AttrLoc, diag::err_machine_mode) << 0 << Name;
4886 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D))
4887 OldTy = TD->getUnderlyingType();
4888 else if (
const auto *ED = dyn_cast<EnumDecl>(D)) {
4891 OldTy = ED->getIntegerType();
4895 OldTy = cast<ValueDecl>(D)->getType();
4906 OldElemTy = VT->getElementType();
4912 VectorSize.getBoolValue()) {
4913 Diag(AttrLoc, diag::err_enum_mode_vector_type) << Name << CI.
getRange();
4921 !IntegralOrAnyEnumType)
4922 Diag(AttrLoc, diag::err_mode_not_primitive);
4923 else if (IntegerMode) {
4924 if (!IntegralOrAnyEnumType)
4925 Diag(AttrLoc, diag::err_mode_wrong_type);
4926 }
else if (ComplexMode) {
4928 Diag(AttrLoc, diag::err_mode_wrong_type);
4931 Diag(AttrLoc, diag::err_mode_wrong_type);
4942 if (NewElemTy.
isNull()) {
4944 if (!(DestWidth == 128 &&
getLangOpts().CUDAIsDevice))
4945 Diag(AttrLoc, diag::err_machine_mode) << 1 << Name;
4954 if (VectorSize.getBoolValue()) {
4960 Diag(AttrLoc, diag::err_complex_mode_vector_type);
4964 OldVT->getNumElements() /
4971 Diag(AttrLoc, diag::err_mode_wrong_type);
4976 if (
auto *TD = dyn_cast<TypedefNameDecl>(D))
4977 TD->setModedTypeSourceInfo(TD->getTypeSourceInfo(), NewTy);
4978 else if (
auto *ED = dyn_cast<EnumDecl>(D))
4979 ED->setIntegerType(NewTy);
4981 cast<ValueDecl>(D)->setType(NewTy);
4993 if (OptimizeNoneAttr *Optnone = D->
getAttr<OptimizeNoneAttr>()) {
4994 Diag(CI.
getLoc(), diag::warn_attribute_ignored) << Ident;
4995 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
4999 if (D->
hasAttr<AlwaysInlineAttr>())
5007 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
5010 if (VD->getKind() != Decl::Var) {
5011 Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
5018 if (VD->hasLocalStorage()) {
5019 Diag(VD->getLocation(), diag::warn_internal_linkage_local_storage);
5026InternalLinkageAttr *
5028 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
5031 if (VD->getKind() != Decl::Var) {
5032 Diag(AL.getLocation(), diag::warn_attribute_wrong_decl_type)
5033 << &AL << AL.isRegularKeywordAttribute()
5039 if (VD->hasLocalStorage()) {
5040 Diag(VD->getLocation(), diag::warn_internal_linkage_local_storage);
5049 if (OptimizeNoneAttr *Optnone = D->
getAttr<OptimizeNoneAttr>()) {
5050 Diag(CI.
getLoc(), diag::warn_attribute_ignored) <<
"'minsize'";
5051 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
5055 if (D->
hasAttr<MinSizeAttr>())
5063 if (
const auto *PrevSNA = D->
getAttr<SwiftNameAttr>()) {
5064 if (PrevSNA->getName() != Name && !PrevSNA->isImplicit()) {
5065 Diag(PrevSNA->getLocation(), diag::err_attributes_are_not_compatible)
5067 << (PrevSNA->isRegularKeywordAttribute() ||
5068 SNA.isRegularKeywordAttribute());
5069 Diag(SNA.getLoc(), diag::note_conflicting_attribute);
5079 if (AlwaysInlineAttr *Inline = D->
getAttr<AlwaysInlineAttr>()) {
5080 Diag(Inline->getLocation(), diag::warn_attribute_ignored) << Inline;
5081 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
5084 if (MinSizeAttr *MinSize = D->
getAttr<MinSizeAttr>()) {
5085 Diag(MinSize->getLocation(), diag::warn_attribute_ignored) << MinSize;
5086 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
5090 if (D->
hasAttr<OptimizeNoneAttr>())
5097 if (AlwaysInlineAttr *Inline =
5113 const auto *VD = cast<VarDecl>(D);
5114 if (VD->hasLocalStorage()) {
5115 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
5120 if (
auto *A = D->
getAttr<CUDAConstantAttr>()) {
5121 if (!A->isImplicit())
5129 const auto *VD = cast<VarDecl>(D);
5132 if (!S.
getLangOpts().GPURelocatableDeviceCode && VD->hasExternalStorage() &&
5133 !isa<IncompleteArrayType>(VD->getType())) {
5134 S.
Diag(AL.
getLoc(), diag::err_cuda_extern_shared) << VD;
5137 if (S.
getLangOpts().CUDA && VD->hasLocalStorage() &&
5145 const auto *FD = cast<FunctionDecl>(D);
5156 if (
const auto *Method = dyn_cast<CXXMethodDecl>(FD)) {
5157 if (Method->isInstance()) {
5158 S.
Diag(Method->getBeginLoc(), diag::err_kern_is_nonstatic_method)
5162 S.
Diag(Method->getBeginLoc(), diag::warn_kern_is_method) << Method;
5168 if (AL.
getKind() == ParsedAttr::AT_NVPTXKernel)
5181 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
5182 if (VD->hasLocalStorage()) {
5183 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
5188 if (
auto *A = D->
getAttr<CUDADeviceAttr>()) {
5189 if (!A->isImplicit())
5197 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
5198 if (VD->hasLocalStorage()) {
5199 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
5203 if (!D->
hasAttr<HIPManagedAttr>())
5205 if (!D->
hasAttr<CUDADeviceAttr>())
5210 const auto *Fn = cast<FunctionDecl>(D);
5211 if (!Fn->isInlineSpecified()) {
5212 S.
Diag(AL.
getLoc(), diag::warn_gnu_inline_attribute_requires_inline);
5217 S.
Diag(AL.
getLoc(), diag::warn_gnu_inline_cplusplus_without_extern);
5233 if (!isa<ObjCMethodDecl>(D)) {
5234 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
5240 case ParsedAttr::AT_FastCall:
5243 case ParsedAttr::AT_StdCall:
5246 case ParsedAttr::AT_ThisCall:
5249 case ParsedAttr::AT_CDecl:
5252 case ParsedAttr::AT_Pascal:
5255 case ParsedAttr::AT_SwiftCall:
5258 case ParsedAttr::AT_SwiftAsyncCall:
5261 case ParsedAttr::AT_VectorCall:
5264 case ParsedAttr::AT_MSABI:
5267 case ParsedAttr::AT_SysVABI:
5270 case ParsedAttr::AT_RegCall:
5273 case ParsedAttr::AT_Pcs: {
5274 PcsAttr::PCSType PCS;
5277 PCS = PcsAttr::AAPCS;
5280 PCS = PcsAttr::AAPCS_VFP;
5283 llvm_unreachable(
"unexpected calling convention in pcs attribute");
5289 case ParsedAttr::AT_AArch64VectorPcs:
5292 case ParsedAttr::AT_AArch64SVEPcs:
5295 case ParsedAttr::AT_AMDGPUKernelCall:
5298 case ParsedAttr::AT_IntelOclBicc:
5301 case ParsedAttr::AT_PreserveMost:
5304 case ParsedAttr::AT_PreserveAll:
5307 case ParsedAttr::AT_M68kRTD:
5310 case ParsedAttr::AT_PreserveNone:
5313 case ParsedAttr::AT_RISCVVectorCC:
5317 llvm_unreachable(
"unexpected attribute kind");
5328 std::vector<StringRef> DiagnosticIdentifiers;
5329 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
5335 DiagnosticIdentifiers.push_back(RuleName);
5338 SuppressAttr(S.
Context, AL, DiagnosticIdentifiers.data(),
5339 DiagnosticIdentifiers.size()));
5348 unsigned SelectIdx = ~0
U;
5354 if (SelectIdx != ~0
U) {
5355 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_argument)
5367 if (AL.
getKind() == ParsedAttr::AT_Owner) {
5368 if (checkAttrMutualExclusion<PointerAttr>(S, D, AL))
5370 if (
const auto *OAttr = D->
getAttr<OwnerAttr>()) {
5371 const Type *ExistingDerefType = OAttr->getDerefTypeLoc()
5372 ? OAttr->getDerefType().getTypePtr()
5375 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
5378 OAttr->isRegularKeywordAttribute());
5379 S.
Diag(OAttr->getLocation(), diag::note_conflicting_attribute);
5384 Redecl->addAttr(::new (S.
Context) OwnerAttr(S.
Context, AL, DerefTypeLoc));
5387 if (checkAttrMutualExclusion<OwnerAttr>(S, D, AL))
5389 if (
const auto *PAttr = D->
getAttr<PointerAttr>()) {
5390 const Type *ExistingDerefType = PAttr->getDerefTypeLoc()
5391 ? PAttr->getDerefType().getTypePtr()
5394 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
5397 PAttr->isRegularKeywordAttribute());
5398 S.
Diag(PAttr->getLocation(), diag::note_conflicting_attribute);
5403 Redecl->addAttr(::new (S.
Context)
5404 PointerAttr(S.
Context, AL, DerefTypeLoc));
5410 if (checkAttrMutualExclusion<NoRandomizeLayoutAttr>(S, D, AL))
5412 if (!D->
hasAttr<RandomizeLayoutAttr>())
5418 if (checkAttrMutualExclusion<RandomizeLayoutAttr>(S, D, AL))
5420 if (!D->
hasAttr<NoRandomizeLayoutAttr>())
5435 unsigned ReqArgs = Attrs.
getKind() == ParsedAttr::AT_Pcs ? 1 : 0;
5443 case ParsedAttr::AT_CDecl:
5446 case ParsedAttr::AT_FastCall:
5449 case ParsedAttr::AT_StdCall:
5452 case ParsedAttr::AT_ThisCall:
5455 case ParsedAttr::AT_Pascal:
5458 case ParsedAttr::AT_SwiftCall:
5461 case ParsedAttr::AT_SwiftAsyncCall:
5464 case ParsedAttr::AT_VectorCall:
5467 case ParsedAttr::AT_AArch64VectorPcs:
5470 case ParsedAttr::AT_AArch64SVEPcs:
5473 case ParsedAttr::AT_AMDGPUKernelCall:
5476 case ParsedAttr::AT_RegCall:
5479 case ParsedAttr::AT_MSABI:
5483 case ParsedAttr::AT_SysVABI:
5487 case ParsedAttr::AT_Pcs: {
5493 if (StrRef ==
"aapcs") {
5496 }
else if (StrRef ==
"aapcs-vfp") {
5505 case ParsedAttr::AT_IntelOclBicc:
5508 case ParsedAttr::AT_PreserveMost:
5511 case ParsedAttr::AT_PreserveAll:
5514 case ParsedAttr::AT_M68kRTD:
5517 case ParsedAttr::AT_PreserveNone:
5520 case ParsedAttr::AT_RISCVVectorCC:
5523 default: llvm_unreachable(
"unexpected attribute kind");
5536 bool CheckHost =
false, CheckDevice =
false;
5537 switch (CudaTarget) {
5550 llvm_unreachable(
"unexpected cuda target");
5552 auto *HostTI =
LangOpts.CUDAIsDevice ? Aux : &TI;
5553 auto *DeviceTI =
LangOpts.CUDAIsDevice ? &TI : Aux;
5554 if (CheckHost && HostTI)
5557 A = DeviceTI->checkCallingConvention(CC);
5575 Diag(Attrs.
getLoc(), diag::error_cconv_unsupported)
5580 Diag(Attrs.
getLoc(), diag::warn_cconv_unsupported)
5585 bool IsCXXMethod =
false, IsVariadic =
false;
5638 if (existingAttr->getABI() != abi) {
5639 Diag(CI.
getLoc(), diag::err_attributes_are_not_compatible)
5642 existingAttr->isRegularKeywordAttribute());
5643 Diag(existingAttr->getLocation(), diag::note_conflicting_attribute);
5650 llvm_unreachable(
"explicit attribute for ordinary parameter ABI?");
5654 Diag(CI.
getLoc(), diag::err_swift_abi_parameter_wrong_type)
5662 Diag(CI.
getLoc(), diag::err_swift_abi_parameter_wrong_type)
5670 Diag(CI.
getLoc(), diag::err_swift_abi_parameter_wrong_type)
5678 Diag(CI.
getLoc(), diag::err_swift_abi_parameter_wrong_type)
5684 llvm_unreachable(
"bad parameter ABI attribute");
5706 Diag(AL.
getLoc(), diag::err_attribute_regparm_wrong_platform)
5714 Diag(AL.
getLoc(), diag::err_attribute_regparm_invalid_number)
5726 llvm_unreachable(
"getCudaArch is only valid for NVPTX triple");
5736 const CUDALaunchBoundsAttr &AL,
5737 const unsigned Idx) {
5746 std::optional<llvm::APSInt> I = llvm::APSInt(64);
5753 if (!I->isIntN(32)) {
5755 <<
toString(*I, 10,
false) << 32 << 1;
5759 S.
Diag(E->
getExprLoc(), diag::warn_attribute_argument_n_negative)
5767 "Unexpected PerformCopyInitialization() failure.");
5772CUDALaunchBoundsAttr *
5774 Expr *MinBlocks,
Expr *MaxBlocks) {
5775 CUDALaunchBoundsAttr TmpAttr(
Context, CI, MaxThreads, MinBlocks, MaxBlocks);
5793 MaxBlocks =
nullptr;
5802 CUDALaunchBoundsAttr(
Context, CI, MaxThreads, MinBlocks, MaxBlocks);
5824 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
5842 unsigned ArgumentIdxAST = ArgumentIdx.
getASTIndex();
5845 S.
Diag(AL.
getLoc(), diag::err_attribute_pointers_only) << AL << 0;
5856 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
5864 if (!isa<VarDecl>(D)) {
5865 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_decl_type)
5873 assert(MatchingCTypeLoc &&
"no type source info for attribute argument");
5895 uint32_t Count = 0, Offset = 0;
5902 if (Count < Offset) {
5903 S.
Diag(
getAttrLoc(AL), diag::err_attribute_argument_out_of_range)
5909 PatchableFunctionEntryAttr(S.
Context, AL, Count, Offset));
5913struct IntrinToName {
5922 const char *IntrinNames) {
5923 AliasName.consume_front(
"__arm_");
5924 const IntrinToName *It =
5925 llvm::lower_bound(Map, BuiltinID, [](
const IntrinToName &L,
unsigned Id) {
5928 if (It == Map.end() || It->Id != BuiltinID)
5930 StringRef FullName(&IntrinNames[It->FullName]);
5931 if (AliasName == FullName)
5933 if (It->ShortName == -1)
5935 StringRef ShortName(&IntrinNames[It->ShortName]);
5936 return AliasName == ShortName;
5940#include "clang/Basic/arm_mve_builtin_aliases.inc"
5948#include "clang/Basic/arm_cde_builtin_aliases.inc"
5953 StringRef AliasName) {
5961 StringRef AliasName) {
5970 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
5977 StringRef AliasName = cast<FunctionDecl>(D)->getIdentifier()->getName();
5984 S.
Diag(AL.
getLoc(), diag::err_attribute_arm_builtin_alias);
5999 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
6006 StringRef AliasName = cast<FunctionDecl>(D)->getIdentifier()->getName();
6016 (!IsAArch64 && !IsARM && !IsRISCV && !IsHLSL)) {
6017 S.
Diag(AL.
getLoc(), diag::err_attribute_builtin_alias) << AL;
6028 if (
auto *CRD = dyn_cast<CXXRecordDecl>(D);
6029 !CRD || !(CRD->isClass() || CRD->isStruct())) {
6035 handleSimpleAttribute<TypeNullableAttr>(S, D, AL);
6040 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
6046 assert(ParmTSI &&
"no type source info for attribute argument");
6048 diag::err_incomplete_type);
6079 bool IsTemplateInstantiation) {
6083 handleSimpleAttributeOrDiagnose<OSConsumedAttr>(
6085 diag::warn_ns_attribute_wrong_parameter_type,
6089 handleSimpleAttributeOrDiagnose<NSConsumedAttr>(
6096 ((IsTemplateInstantiation &&
getLangOpts().ObjCAutoRefCount)
6097 ? diag::err_ns_attribute_wrong_parameter_type
6098 : diag::warn_ns_attribute_wrong_parameter_type),
6102 handleSimpleAttributeOrDiagnose<CFConsumedAttr>(
6104 diag::warn_ns_attribute_wrong_parameter_type,
6113 case ParsedAttr::AT_CFConsumed:
6114 case ParsedAttr::AT_CFReturnsRetained:
6115 case ParsedAttr::AT_CFReturnsNotRetained:
6117 case ParsedAttr::AT_OSConsumesThis:
6118 case ParsedAttr::AT_OSConsumed:
6119 case ParsedAttr::AT_OSReturnsRetained:
6120 case ParsedAttr::AT_OSReturnsNotRetained:
6121 case ParsedAttr::AT_OSReturnsRetainedOnZero:
6122 case ParsedAttr::AT_OSReturnsRetainedOnNonZero:
6124 case ParsedAttr::AT_NSConsumesSelf:
6125 case ParsedAttr::AT_NSConsumed:
6126 case ParsedAttr::AT_NSReturnsRetained:
6127 case ParsedAttr::AT_NSReturnsNotRetained:
6128 case ParsedAttr::AT_NSReturnsAutoreleased:
6131 llvm_unreachable(
"Wrong argument supplied");
6139 Diag(
Loc, diag::warn_ns_attribute_wrong_return_type)
6140 <<
"'ns_returns_retained'" << 0 << 0;
6146 const auto *PVD = dyn_cast<ParmVarDecl>(D);
6159 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
6160 ReturnType = MD->getReturnType();
6162 (AL.
getKind() == ParsedAttr::AT_NSReturnsRetained)) {
6164 }
else if (
const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
6165 ReturnType = PD->getType();
6166 }
else if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
6168 }
else if (
const auto *Param = dyn_cast<ParmVarDecl>(D)) {
6175 if (ReturnType.
isNull()) {
6176 S.
Diag(D->
getBeginLoc(), diag::warn_ns_attribute_wrong_parameter_type)
6185 default: llvm_unreachable(
"invalid ownership attribute");
6186 case ParsedAttr::AT_NSReturnsRetained:
6187 case ParsedAttr::AT_NSReturnsAutoreleased:
6188 case ParsedAttr::AT_NSReturnsNotRetained:
6192 case ParsedAttr::AT_OSReturnsRetained:
6193 case ParsedAttr::AT_OSReturnsNotRetained:
6194 case ParsedAttr::AT_CFReturnsRetained:
6195 case ParsedAttr::AT_CFReturnsNotRetained:
6201 << ExpectedDeclKind;
6207 unsigned ParmDiagID = 2;
6209 default: llvm_unreachable(
"invalid ownership attribute");
6210 case ParsedAttr::AT_NSReturnsRetained:
6215 case ParsedAttr::AT_NSReturnsAutoreleased:
6216 case ParsedAttr::AT_NSReturnsNotRetained:
6221 case ParsedAttr::AT_CFReturnsRetained:
6222 case ParsedAttr::AT_CFReturnsNotRetained:
6227 case ParsedAttr::AT_OSReturnsRetained:
6228 case ParsedAttr::AT_OSReturnsNotRetained:
6239 if (isa<ParmVarDecl>(D)) {
6240 S.
Diag(D->
getBeginLoc(), diag::warn_ns_attribute_wrong_parameter_type)
6241 << AL << ParmDiagID << AL.
getRange();
6249 if (isa<ObjCMethodDecl>(D))
6250 SubjectKind = Method;
6251 else if (isa<ObjCPropertyDecl>(D))
6254 << AL << SubjectKind << Cf << AL.
getRange();
6261 llvm_unreachable(
"invalid ownership attribute");
6262 case ParsedAttr::AT_NSReturnsAutoreleased:
6263 handleSimpleAttribute<NSReturnsAutoreleasedAttr>(S, D, AL);
6265 case ParsedAttr::AT_CFReturnsNotRetained:
6266 handleSimpleAttribute<CFReturnsNotRetainedAttr>(S, D, AL);
6268 case ParsedAttr::AT_NSReturnsNotRetained:
6269 handleSimpleAttribute<NSReturnsNotRetainedAttr>(S, D, AL);
6271 case ParsedAttr::AT_CFReturnsRetained:
6272 handleSimpleAttribute<CFReturnsRetainedAttr>(S, D, AL);
6274 case ParsedAttr::AT_NSReturnsRetained:
6275 handleSimpleAttribute<NSReturnsRetainedAttr>(S, D, AL);
6277 case ParsedAttr::AT_OSReturnsRetained:
6278 handleSimpleAttribute<OSReturnsRetainedAttr>(S, D, AL);
6280 case ParsedAttr::AT_OSReturnsNotRetained:
6281 handleSimpleAttribute<OSReturnsNotRetainedAttr>(S, D, AL);
6288 const int EP_ObjCMethod = 1;
6289 const int EP_ObjCProperty = 2;
6293 if (isa<ObjCMethodDecl>(D))
6294 resultType = cast<ObjCMethodDecl>(D)->getReturnType();
6296 resultType = cast<ObjCPropertyDecl>(D)->getType();
6302 << (isa<ObjCMethodDecl>(D) ? EP_ObjCMethod : EP_ObjCProperty)
6314 const auto *Method = cast<ObjCMethodDecl>(D);
6317 if (
const auto *PDecl = dyn_cast_if_present<ObjCProtocolDecl>(DC)) {
6318 S.
Diag(D->
getBeginLoc(), diag::warn_objc_requires_super_protocol) << Attrs
6320 S.
Diag(PDecl->getLocation(), diag::note_protocol_decl);
6324 S.
Diag(D->
getBeginLoc(), diag::warn_objc_requires_super_protocol) << Attrs
6333 if (!isa<TagDecl>(D)) {
6339 Attr.isArgIdent(0) ?
Attr.getArgAsIdent(0) :
nullptr;
6340 if (!IdentLoc || !IdentLoc->
Ident) {
6343 if (
Attr.isArgExpr(0) &&
Attr.getArgAsExpr(0))
6344 Loc =
Attr.getArgAsExpr(0)->getBeginLoc();
6346 S.
Diag(
Loc, diag::err_nserrordomain_invalid_decl) << 0;
6354 S.
Diag(IdentLoc->
Loc, diag::err_nserrordomain_invalid_decl)
6355 << 1 << IdentLoc->
Ident;
6372 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
6374 S.
Diag(AL.
getLoc(), diag::err_objc_attr_typedef_not_id) << AL;
6381 S.
Diag(AL.
getLoc(), diag::err_objc_attr_typedef_not_void_pointer);
6406 if (!RelatedClass) {
6415 S.
Context, AL, RelatedClass, ClassMethod, InstanceMethod));
6424 if (!isa<ObjCInterfaceDecl>(Ctx) &&
6425 !(isa<ObjCCategoryDecl>(Ctx) &&
6426 cast<ObjCCategoryDecl>(Ctx)->IsClassExtension())) {
6432 if (
auto *CatDecl = dyn_cast<ObjCCategoryDecl>(Ctx))
6433 IFace = CatDecl->getClassInterface();
6435 IFace = cast<ObjCInterfaceDecl>(Ctx);
6445 StringRef MetaDataName;
6449 ObjCRuntimeNameAttr(S.
Context, AL, MetaDataName));
6457 bool notify =
false;
6459 auto *RD = dyn_cast<RecordDecl>(D);
6460 if (RD && RD->getDefinition()) {
6461 RD = RD->getDefinition();
6466 ObjCBoxableAttr *BoxableAttr =
6468 RD->addAttr(BoxableAttr);
6473 L->AddedAttributeToRecord(BoxableAttr, RD);
6489 const auto *VD = cast<ValueDecl>(D);
6494 S.
Diag(AL.
getLoc(), diag::err_objc_precise_lifetime_bad_type)
6509 "didn't infer lifetime for non-dependent type?");
6518 S.
Diag(AL.
getLoc(), diag::warn_objc_precise_lifetime_meaningless)
6545 if (
const auto *
Other = D->
getAttr<SwiftBridgeAttr>()) {
6546 if (
Other->getSwiftType() != BT)
6547 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
6563 if (
const auto *ID = OPT->getInterfaceDecl())
6569 if (
const auto *RT = PT->getPointeeType()->getAs<
RecordType>())
6583 S.
Diag(AL.
getLoc(), diag::err_attr_swift_error_no_error_parameter)
6584 << AL << isa<ObjCMethodDecl>(D);
6596 S.
Diag(AL.
getLoc(), diag::err_attr_swift_error_return_type)
6607 S.
Diag(AL.
getLoc(), diag::err_attr_swift_error_return_type)
6617 SwiftErrorAttr::ConventionKind Convention;
6618 if (!SwiftErrorAttr::ConvertStrToConventionKind(
Loc->Ident->getName(),
6620 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
6621 << AL <<
Loc->Ident;
6625 switch (Convention) {
6626 case SwiftErrorAttr::None:
6630 case SwiftErrorAttr::NonNullError:
6631 if (!hasErrorParameter(S, D, AL))
6635 case SwiftErrorAttr::NullResult:
6636 if (!hasErrorParameter(S, D, AL) || !hasPointerResult(S, D, AL))
6640 case SwiftErrorAttr::NonZeroResult:
6641 case SwiftErrorAttr::ZeroResult:
6642 if (!hasErrorParameter(S, D, AL) || !hasIntegerResult(S, D, AL))
6651 const SwiftAsyncErrorAttr *ErrorAttr,
6652 const SwiftAsyncAttr *AsyncAttr) {
6653 if (AsyncAttr->getKind() == SwiftAsyncAttr::None) {
6654 if (ErrorAttr->getConvention() != SwiftAsyncErrorAttr::None) {
6655 S.
Diag(AsyncAttr->getLocation(),
6656 diag::err_swift_async_error_without_swift_async)
6657 << AsyncAttr << isa<ObjCMethodDecl>(D);
6663 D, AsyncAttr->getCompletionHandlerIndex().getASTIndex());
6666 const auto *FuncTy = HandlerParam->
getType()
6672 BlockParams = FuncTy->getParamTypes();
6674 switch (ErrorAttr->getConvention()) {
6675 case SwiftAsyncErrorAttr::ZeroArgument:
6676 case SwiftAsyncErrorAttr::NonZeroArgument: {
6677 uint32_t
ParamIdx = ErrorAttr->getHandlerParamIdx();
6679 S.
Diag(ErrorAttr->getLocation(),
6680 diag::err_attribute_argument_out_of_bounds) << ErrorAttr << 2;
6686 ErrorAttr->getConvention() == SwiftAsyncErrorAttr::ZeroArgument
6688 :
"nonzero_argument";
6689 S.
Diag(ErrorAttr->getLocation(), diag::err_swift_async_error_non_integral)
6690 << ErrorAttr << ConvStr <<
ParamIdx << ErrorParam;
6695 case SwiftAsyncErrorAttr::NonNullError: {
6696 bool AnyErrorParams =
false;
6697 for (
QualType Param : BlockParams) {
6700 if (
const auto *ID = ObjCPtrTy->getInterfaceDecl()) {
6702 AnyErrorParams =
true;
6708 if (
const auto *PtrTy = Param->getAs<
PointerType>()) {
6709 if (
const auto *RT = PtrTy->getPointeeType()->getAs<
RecordType>()) {
6711 AnyErrorParams =
true;
6718 if (!AnyErrorParams) {
6719 S.
Diag(ErrorAttr->getLocation(),
6720 diag::err_swift_async_error_no_error_parameter)
6721 << ErrorAttr << isa<ObjCMethodDecl>(D);
6726 case SwiftAsyncErrorAttr::None:
6733 SwiftAsyncErrorAttr::ConventionKind ConvKind;
6734 if (!SwiftAsyncErrorAttr::ConvertStrToConventionKind(IDLoc->
Ident->
getName(),
6736 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
6737 << AL << IDLoc->
Ident;
6743 case SwiftAsyncErrorAttr::ZeroArgument:
6744 case SwiftAsyncErrorAttr::NonZeroArgument: {
6753 case SwiftAsyncErrorAttr::NonNullError:
6754 case SwiftAsyncErrorAttr::None: {
6765 if (
auto *AsyncAttr = D->
getAttr<SwiftAsyncAttr>())
6779 StringRef Name,
unsigned &SwiftParamCount,
6780 bool &IsSingleParamInit) {
6781 SwiftParamCount = 0;
6782 IsSingleParamInit =
false;
6785 bool IsGetter =
false, IsSetter =
false;
6786 if (Name.consume_front(
"getter:"))
6788 else if (Name.consume_front(
"setter:"))
6791 if (Name.back() !=
')') {
6792 S.
Diag(
Loc, diag::warn_attr_swift_name_function) << AL;
6796 bool IsMember =
false;
6797 StringRef ContextName, BaseName, Parameters;
6799 std::tie(BaseName, Parameters) = Name.split(
'(');
6803 std::tie(ContextName, BaseName) = BaseName.split(
'.');
6804 if (BaseName.empty()) {
6805 BaseName = ContextName;
6806 ContextName = StringRef();
6808 S.
Diag(
Loc, diag::warn_attr_swift_name_invalid_identifier)
6816 S.
Diag(
Loc, diag::warn_attr_swift_name_invalid_identifier)
6821 bool IsSubscript = BaseName ==
"subscript";
6823 if (IsSubscript && !IsGetter && !IsSetter) {
6824 S.
Diag(
Loc, diag::warn_attr_swift_name_subscript_invalid_parameter)
6829 if (Parameters.empty()) {
6830 S.
Diag(
Loc, diag::warn_attr_swift_name_missing_parameters) << AL;
6834 assert(Parameters.back() ==
')' &&
"expected ')'");
6835 Parameters = Parameters.drop_back();
6837 if (Parameters.empty()) {
6840 S.
Diag(
Loc, diag::warn_attr_swift_name_subscript_invalid_parameter)
6846 S.
Diag(
Loc, diag::warn_attr_swift_name_setter_parameters) << AL;
6853 if (Parameters.back() !=
':') {
6854 S.
Diag(
Loc, diag::warn_attr_swift_name_function) << AL;
6858 StringRef CurrentParam;
6859 std::optional<unsigned> SelfLocation;
6860 unsigned NewValueCount = 0;
6861 std::optional<unsigned> NewValueLocation;
6863 std::tie(CurrentParam, Parameters) = Parameters.split(
':');
6866 S.
Diag(
Loc, diag::warn_attr_swift_name_invalid_identifier)
6871 if (IsMember && CurrentParam ==
"self") {
6876 S.
Diag(
Loc, diag::warn_attr_swift_name_multiple_selfs) << AL;
6881 SelfLocation = SwiftParamCount;
6882 }
else if (CurrentParam ==
"newValue") {
6889 NewValueLocation = SwiftParamCount;
6893 }
while (!Parameters.empty());
6896 if (IsSubscript && !SelfLocation) {
6897 S.
Diag(
Loc, diag::warn_attr_swift_name_subscript_invalid_parameter)
6903 SwiftParamCount == 1 && BaseName ==
"init" && CurrentParam !=
"_";
6906 if (IsGetter || IsSetter) {
6908 unsigned NumExpectedParams = IsGetter ? 0 : 1;
6909 unsigned ParamDiag =
6910 IsGetter ? diag::warn_attr_swift_name_getter_parameters
6911 : diag::warn_attr_swift_name_setter_parameters;
6915 ++NumExpectedParams;
6920 if (SwiftParamCount < NumExpectedParams) {
6928 if (!NewValueLocation) {
6929 S.
Diag(
Loc, diag::warn_attr_swift_name_subscript_setter_no_newValue)
6933 if (NewValueCount > 1) {
6934 S.
Diag(
Loc, diag::warn_attr_swift_name_subscript_setter_multiple_newValues)
6940 if (NewValueLocation) {
6941 S.
Diag(
Loc, diag::warn_attr_swift_name_subscript_getter_newValue)
6948 if (SwiftParamCount != NumExpectedParams) {
6960 if (isa<ObjCMethodDecl>(D) || isa<FunctionDecl>(D)) {
6962 unsigned ParamCount;
6964 if (
const auto *Method = dyn_cast<ObjCMethodDecl>(D)) {
6965 ParamCount = Method->getSelector().getNumArgs();
6966 Params = Method->parameters().slice(0, ParamCount);
6968 const auto *F = cast<FunctionDecl>(D);
6970 ParamCount = F->getNumParams();
6971 Params = F->parameters();
6973 if (!F->hasWrittenPrototype()) {
6974 Diag(
Loc, diag::warn_attribute_wrong_decl_type)
6983 if (ParamCount == 0) {
6984 Diag(
Loc, diag::warn_attr_swift_name_decl_missing_params)
6985 << AL << isa<ObjCMethodDecl>(D);
6991 unsigned SwiftParamCount;
6992 bool IsSingleParamInit;
6994 SwiftParamCount, IsSingleParamInit))
6997 bool ParamCountValid;
6998 if (SwiftParamCount == ParamCount) {
6999 ParamCountValid =
true;
7000 }
else if (SwiftParamCount > ParamCount) {
7001 ParamCountValid = IsSingleParamInit && ParamCount == 0;
7006 unsigned MaybeOutParamCount =
7007 llvm::count_if(Params, [](
const ParmVarDecl *Param) ->
bool {
7014 ParamCountValid = SwiftParamCount + MaybeOutParamCount >= ParamCount;
7017 if (!ParamCountValid) {
7018 Diag(
Loc, diag::warn_attr_swift_name_num_params)
7019 << (SwiftParamCount > ParamCount) << AL << ParamCount
7023 }
else if ((isa<EnumConstantDecl>(D) || isa<ObjCProtocolDecl>(D) ||
7024 isa<ObjCInterfaceDecl>(D) || isa<ObjCPropertyDecl>(D) ||
7025 isa<VarDecl>(D) || isa<TypedefNameDecl>(D) || isa<TagDecl>(D) ||
7026 isa<IndirectFieldDecl>(D) || isa<FieldDecl>(D)) &&
7028 StringRef ContextName, BaseName;
7030 std::tie(ContextName, BaseName) = Name.split(
'.');
7031 if (BaseName.empty()) {
7032 BaseName = ContextName;
7033 ContextName = StringRef();
7035 Diag(
Loc, diag::warn_attr_swift_name_invalid_identifier) << AL
7041 Diag(
Loc, diag::warn_attr_swift_name_invalid_identifier) << AL
7046 Diag(
Loc, diag::warn_attr_swift_name_decl_kind) << AL;
7082 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7087 SwiftNewTypeAttr::NewtypeKind Kind;
7089 if (!SwiftNewTypeAttr::ConvertStrToNewtypeKind(II->
getName(), Kind)) {
7090 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
7094 if (!isa<TypedefNameDecl>(D)) {
7095 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type_str)
7105 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
7110 SwiftAsyncAttr::Kind Kind;
7112 if (!SwiftAsyncAttr::ConvertStrToKind(II->
getName(), Kind)) {
7113 S.
Diag(AL.
getLoc(), diag::err_swift_async_no_access) << AL << II;
7118 if (Kind == SwiftAsyncAttr::None) {
7136 diag::err_swift_async_bad_block_type)
7137 << CompletionBlock->
getType();
7144 diag::err_swift_async_bad_block_type)
7145 << CompletionBlock->
getType();
7154 if (
auto *ErrorAttr = D->
getAttr<SwiftAsyncErrorAttr>())
7163 StringRef UuidAsWritten,
MSGuidDecl *GuidDecl) {
7164 if (
const auto *UA = D->
getAttr<UuidAttr>()) {
7167 if (!UA->getGuid().empty()) {
7168 Diag(UA->getLocation(), diag::err_mismatched_uuid);
7174 return ::new (
Context) UuidAttr(
Context, CI, UuidAsWritten, GuidDecl);
7179 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
7184 StringRef OrigStrRef;
7191 StringRef StrRef = OrigStrRef;
7192 if (StrRef.size() == 38 && StrRef.front() ==
'{' && StrRef.back() ==
'}')
7193 StrRef = StrRef.drop_front().drop_back();
7196 if (StrRef.size() != 36) {
7197 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
7201 for (
unsigned i = 0; i < 36; ++i) {
7202 if (i == 8 || i == 13 || i == 18 || i == 23) {
7203 if (StrRef[i] !=
'-') {
7204 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
7208 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
7215 StrRef.substr(0, 8).getAsInteger(16, Parsed.
Part1);
7216 StrRef.substr(9, 4).getAsInteger(16, Parsed.
Part2);
7217 StrRef.substr(14, 4).getAsInteger(16, Parsed.
Part3);
7218 for (
unsigned i = 0; i != 8; ++i)
7219 StrRef.substr(19 + 2 * i + (i >= 2 ? 1 : 0), 2)
7230 S.
Diag(AL.
getLoc(), diag::warn_atl_uuid_deprecated);
7238 llvm::VersionTuple SMVersion =
7240 uint32_t ZMax = 1024;
7241 uint32_t ThreadMax = 1024;
7242 if (SMVersion.getMajor() <= 4) {
7245 }
else if (SMVersion.getMajor() == 5) {
7255 diag::err_hlsl_numthreads_argument_oor) << 0 << 1024;
7263 diag::err_hlsl_numthreads_argument_oor) << 1 << 1024;
7271 diag::err_hlsl_numthreads_argument_oor) << 2 << ZMax;
7275 if (
X * Y * Z > ThreadMax) {
7276 S.
Diag(AL.
getLoc(), diag::err_hlsl_numthreads_invalid) << ThreadMax;
7289 return VT->getNumElements() <= 3;
7297 if (isa<FieldDecl>(D)) {
7298 S.
Diag(AL.
getLoc(), diag::err_hlsl_attr_invalid_ast_node)
7299 << AL <<
"parameter";
7303 auto *VD = cast<ValueDecl>(D);
7305 S.
Diag(AL.
getLoc(), diag::err_hlsl_attr_invalid_type)
7306 << AL <<
"uint/uint2/uint3";
7314 if (!isa<VarDecl>(D) || !isa<HLSLBufferDecl>(D->
getDeclContext())) {
7315 S.
Diag(AL.
getLoc(), diag::err_hlsl_attr_invalid_ast_node)
7316 << AL <<
"shader constant in a constant buffer";
7320 uint32_t SubComponent;
7327 QualType T = cast<VarDecl>(D)->getType().getCanonicalType();
7335 if (IsAggregateTy || Size > 128) {
7336 S.
Diag(AL.
getLoc(), diag::err_hlsl_packoffset_cross_reg_boundary);
7340 if ((Component * 32 + Size) > 128) {
7341 S.
Diag(AL.
getLoc(), diag::err_hlsl_packoffset_cross_reg_boundary);
7346 EltTy = VT->getElementType();
7348 if (Align > 32 && Component == 1) {
7351 S.
Diag(AL.
getLoc(), diag::err_hlsl_packoffset_alignment_mismatch)
7359 HLSLPackOffsetAttr(S.
Context, AL, SubComponent, Component));
7368 HLSLShaderAttr::ShaderType ShaderType;
7369 if (!HLSLShaderAttr::ConvertStrToShaderType(Str, ShaderType)) {
7370 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
7371 << AL << Str << ArgLoc;
7384 StringRef Space =
"space0";
7385 StringRef Slot =
"";
7388 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7394 StringRef Str =
Loc->Ident->getName();
7401 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7407 Space =
Loc->Ident->getName();
7408 SpaceArgLoc =
Loc->Loc;
7414 if (!Slot.empty()) {
7422 S.
Diag(ArgLoc, diag::err_hlsl_unsupported_register_type)
7423 << Slot.substr(0, 1);
7427 StringRef SlotNum = Slot.substr(1);
7429 if (SlotNum.getAsInteger(10, Num)) {
7430 S.
Diag(ArgLoc, diag::err_hlsl_unsupported_register_number);
7435 if (!Space.starts_with(
"space")) {
7436 S.
Diag(SpaceArgLoc, diag::err_hlsl_expected_space) << Space;
7439 StringRef SpaceNum = Space.substr(5);
7441 if (SpaceNum.getAsInteger(10, Num)) {
7442 S.
Diag(SpaceArgLoc, diag::err_hlsl_expected_space) << Space;
7448 HLSLResourceBindingAttr *NewAttr =
7449 HLSLResourceBindingAttr::Create(S.
getASTContext(), Slot, Space, AL);
7465 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
7478 const auto *VD = cast<VarDecl>(D);
7480 S.
Diag(AL.
getLoc(), diag::err_thread_unsupported);
7484 S.
Diag(AL.
getLoc(), diag::err_declspec_thread_on_thread_variable);
7487 if (VD->hasLocalStorage()) {
7488 S.
Diag(AL.
getLoc(), diag::err_thread_non_global) <<
"__declspec(thread)";
7496 S.
Diag(AL.
getLoc(), diag::warn_unknown_attribute_ignored)
7500 auto *FD = cast<FunctionDecl>(D);
7502 S.
Diag(AL.
getLoc(), diag::err_ms_constexpr_cannot_be_applied)
7506 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
7507 if (!S.
getLangOpts().CPlusPlus20 && MD->isVirtual()) {
7508 S.
Diag(AL.
getLoc(), diag::err_ms_constexpr_cannot_be_applied)
7518 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
7522 Tags.push_back(Tag);
7525 if (
const auto *NS = dyn_cast<NamespaceDecl>(D)) {
7526 if (!NS->isInline()) {
7527 S.
Diag(AL.
getLoc(), diag::warn_attr_abi_tag_namespace) << 0;
7530 if (NS->isAnonymousNamespace()) {
7531 S.
Diag(AL.
getLoc(), diag::warn_attr_abi_tag_namespace) << 1;
7535 Tags.push_back(NS->getName());
7541 Tags.erase(std::unique(Tags.begin(), Tags.end()), Tags.end());
7544 AbiTagAttr(S.
Context, AL, Tags.data(), Tags.size()));
7550 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 1;
7562 ARMInterruptAttr::InterruptType Kind;
7563 if (!ARMInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
7564 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << Str
7598 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7604 std::optional<llvm::APSInt> NumParams = llvm::APSInt(32);
7606 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7612 unsigned Num = NumParams->getLimitedValue(255);
7614 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
7615 << AL << (
int)NumParams->getSExtValue()
7627 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 1;
7668 if (checkAttrMutualExclusion<Mips16Attr>(S, D, AL))
7671 MipsInterruptAttr::InterruptType Kind;
7672 if (!MipsInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
7673 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
7674 << AL <<
"'" + std::string(Str) +
"'";
7686 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7695 if (!MaybeNumParams) {
7696 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7702 unsigned Num = MaybeNumParams->getLimitedValue(255);
7703 if ((Num & 1) || Num > 30) {
7704 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
7705 << AL << (
int)MaybeNumParams->getSExtValue()
7723 cast<NamedDecl>(D)->getDeclName().getCXXOverloadedOperator())) {
7724 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
7732 diag::err_anyx86_interrupt_attribute)
7741 if (NumParams < 1 || NumParams > 2) {
7752 diag::err_anyx86_interrupt_attribute)
7764 if (NumParams == 2 &&
7768 diag::err_anyx86_interrupt_attribute)
7789 handleSimpleAttribute<AVRInterruptAttr>(S, D, AL);
7802 handleSimpleAttribute<AVRSignalAttr>(S, D, AL);
7807 for (
auto *D : RD->
decls()) {
7808 if (D->hasAttr<BPFPreserveAccessIndexAttr>())
7811 D->addAttr(BPFPreserveAccessIndexAttr::CreateImplicit(S.
Context));
7812 if (
auto *Rec = dyn_cast<RecordDecl>(D))
7819 auto *Rec = cast<RecordDecl>(D);
7821 Rec->addAttr(::new (S.
Context) BPFPreserveAccessIndexAttr(S.
Context, AL));
7826 if (I->getBTFDeclTag() == Tag)
7845 return ::new (
Context) BTFDeclTagAttr(
Context, AL, AL.getBTFDeclTag());
7856 auto *FD = cast<FunctionDecl>(D);
7871WebAssemblyImportModuleAttr *
7873 auto *FD = cast<FunctionDecl>(D);
7875 if (
const auto *ExistingAttr = FD->
getAttr<WebAssemblyImportModuleAttr>()) {
7876 if (ExistingAttr->getImportModule() == AL.getImportModule())
7878 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_import) << 0
7879 << ExistingAttr->getImportModule() << AL.getImportModule();
7880 Diag(AL.getLoc(), diag::note_previous_attribute);
7884 Diag(AL.getLoc(), diag::warn_import_on_definition) << 0;
7888 AL.getImportModule());
7891WebAssemblyImportNameAttr *
7893 auto *FD = cast<FunctionDecl>(D);
7895 if (
const auto *ExistingAttr = FD->
getAttr<WebAssemblyImportNameAttr>()) {
7896 if (ExistingAttr->getImportName() == AL.getImportName())
7898 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_import) << 1
7899 << ExistingAttr->getImportName() << AL.getImportName();
7900 Diag(AL.getLoc(), diag::note_previous_attribute);
7904 Diag(AL.getLoc(), diag::warn_import_on_definition) << 1;
7908 AL.getImportName());
7913 auto *FD = cast<FunctionDecl>(D);
7920 S.
Diag(AL.
getLoc(), diag::warn_import_on_definition) << 0;
7925 WebAssemblyImportModuleAttr(S.
Context, AL, Str));
7930 auto *FD = cast<FunctionDecl>(D);
7937 S.
Diag(AL.
getLoc(), diag::warn_import_on_definition) << 1;
7947 if (
const auto *A = D->
getAttr<RISCVInterruptAttr>()) {
7949 diag::warn_riscv_repeated_interrupt_attribute);
7950 S.
Diag(A->getLocation(), diag::note_riscv_repeated_interrupt_attribute);
7992 RISCVInterruptAttr::InterruptType Kind;
7993 if (!RISCVInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
7994 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << Str
8005 case llvm::Triple::msp430:
8008 case llvm::Triple::mipsel:
8009 case llvm::Triple::mips:
8012 case llvm::Triple::m68k:
8015 case llvm::Triple::x86:
8016 case llvm::Triple::x86_64:
8019 case llvm::Triple::avr:
8022 case llvm::Triple::riscv32:
8023 case llvm::Triple::riscv64:
8034 const AMDGPUFlatWorkGroupSizeAttr &
Attr) {
8048 if (
Min == 0 &&
Max != 0) {
8062AMDGPUFlatWorkGroupSizeAttr *
8065 AMDGPUFlatWorkGroupSizeAttr TmpAttr(
Context, CI, MinExpr, MaxExpr);
8070 AMDGPUFlatWorkGroupSizeAttr(
Context, CI, MinExpr, MaxExpr);
8090 const AMDGPUWavesPerEUAttr &
Attr) {
8108 if (
Min == 0 &&
Max != 0) {
8122AMDGPUWavesPerEUAttr *
8125 AMDGPUWavesPerEUAttr TmpAttr(
Context, CI, MinExpr, MaxExpr);
8130 return ::new (
Context) AMDGPUWavesPerEUAttr(
Context, CI, MinExpr, MaxExpr);
8150 uint32_t NumSGPR = 0;
8159 uint32_t NumVGPR = 0;
8170 const AMDGPUMaxNumWorkGroupsAttr &
Attr) {
8183 Expr *Exprs[3] = {XExpr, YExpr, ZExpr};
8184 for (
int i = 0; i < 3; i++) {
8200AMDGPUMaxNumWorkGroupsAttr *
8203 AMDGPUMaxNumWorkGroupsAttr TmpAttr(
Context, CI, XExpr, YExpr, ZExpr);
8209 AMDGPUMaxNumWorkGroupsAttr(
Context, CI, XExpr, YExpr, ZExpr);
8231 const auto *VD = dyn_cast<ValueDecl>(D);
8232 if (VD && VD->getType()->isFunctionPointerType())
8235 const auto *TD = dyn_cast<TypedefNameDecl>(D);
8236 if (TD && (TD->getUnderlyingType()->isFunctionPointerType() ||
8237 TD->getUnderlyingType()->isFunctionType()))
8240 if (!isa<FunctionDecl>(D)) {
8241 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
8257 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
8272 if (D->
hasAttr<DLLExportAttr>()) {
8273 Diag(CI.
getLoc(), diag::warn_attribute_ignored) <<
"'dllimport'";
8277 if (D->
hasAttr<DLLImportAttr>())
8285 if (DLLImportAttr *Import = D->
getAttr<DLLImportAttr>()) {
8286 Diag(Import->getLocation(), diag::warn_attribute_ignored) << Import;
8290 if (D->
hasAttr<DLLExportAttr>())
8297 if (isa<ClassTemplatePartialSpecializationDecl>(D) &&
8303 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
8313 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
8315 MD->getParent()->isLambda()) {
8321 Attr *NewAttr = A.
getKind() == ParsedAttr::AT_DLLExport
8332 if (MSInheritanceAttr *IA = D->
getAttr<MSInheritanceAttr>()) {
8333 if (IA->getInheritanceModel() == Model)
8335 Diag(IA->getLocation(), diag::err_mismatched_ms_inheritance)
8337 Diag(CI.
getLoc(), diag::note_previous_ms_inheritance);
8341 auto *RD = cast<CXXRecordDecl>(D);
8342 if (RD->hasDefinition()) {
8348 if (isa<ClassTemplatePartialSpecializationDecl>(RD)) {
8349 Diag(CI.
getLoc(), diag::warn_ignored_ms_inheritance)
8353 if (RD->getDescribedClassTemplate()) {
8354 Diag(CI.
getLoc(), diag::warn_ignored_ms_inheritance)
8372 StringRef N(
"mutex");
8374 if (AL.
getKind() == ParsedAttr::AT_Capability &&
8387 AssertCapabilityAttr(S.
Context, AL, Args.data(), Args.size()));
8431 RequiresCapabilityAttr *RCA = ::new (S.
Context)
8432 RequiresCapabilityAttr(S.
Context, AL, Args.data(), Args.size());
8438 if (
const auto *NSD = dyn_cast<NamespaceDecl>(D)) {
8439 if (NSD->isAnonymousNamespace()) {
8440 S.
Diag(AL.
getLoc(), diag::warn_deprecated_anonymous_namespace);
8454 StringRef Str, Replacement;
8467 S.
Diag(AL.
getLoc(), diag::ext_cxx14_attr) << AL;
8473 if (
const auto *S = dyn_cast<VarDecl>(D))
8474 return S->hasGlobalStorage();
8479 return Sanitizer ==
"address" || Sanitizer ==
"hwaddress" ||
8480 Sanitizer ==
"memtag";
8487 std::vector<StringRef> Sanitizers;
8489 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
8490 StringRef SanitizerName;
8498 SanitizerName !=
"coverage")
8499 S.
Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << SanitizerName;
8501 S.
Diag(D->
getLocation(), diag::warn_attribute_type_not_supported_global)
8502 << AL << SanitizerName;
8503 Sanitizers.push_back(SanitizerName);
8507 Sanitizers.size()));
8514 StringRef SanitizerName = llvm::StringSwitch<StringRef>(AttrName)
8515 .Case(
"no_address_safety_analysis",
"address")
8516 .Case(
"no_sanitize_address",
"address")
8517 .Case(
"no_sanitize_thread",
"thread")
8518 .Case(
"no_sanitize_memory",
"memory");
8531 unsigned TranslatedSpellingIndex = 0;
8533 TranslatedSpellingIndex = 1;
8538 NoSanitizeAttr(S.
Context, Info, &SanitizerName, 1));
8548 S.
Diag(AL.
getLoc(), diag::err_attribute_requires_opencl_version)
8549 << AL <<
"2.0" << 1;
8551 S.
Diag(AL.
getLoc(), diag::warn_opencl_attr_deprecated_ignored)
8560 if (D->
hasAttr<OpenCLAccessAttr>()) {
8561 if (D->
getAttr<OpenCLAccessAttr>()->getSemanticSpelling() ==
8563 S.
Diag(AL.
getLoc(), diag::warn_duplicate_declspec)
8566 S.
Diag(AL.
getLoc(), diag::err_opencl_multiple_access_qualifiers)
8582 if (
const auto *PDecl = dyn_cast<ParmVarDecl>(D)) {
8583 const Type *DeclTy = PDecl->getType().getCanonicalType().getTypePtr();
8585 bool ReadWriteImagesUnsupported =
8590 if (ReadWriteImagesUnsupported || DeclTy->isPipeType()) {
8591 S.
Diag(AL.
getLoc(), diag::err_opencl_invalid_read_write)
8592 << AL << PDecl->getType() << DeclTy->isImageType();
8609 ZeroCallUsedRegsAttr::ZeroCallUsedRegsKind Kind;
8610 if (!ZeroCallUsedRegsAttr::ConvertStrToZeroCallUsedRegsKind(KindStr, Kind)) {
8611 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported)
8616 D->
dropAttr<ZeroCallUsedRegsAttr>();
8626 while (RD && (RD->isAnonymousStructOrUnion() ||
8627 (!RD->isCompleteDefinition() && RD->getName().empty()))) {
8628 const auto *
Parent = dyn_cast<RecordDecl>(RD->getParent());
8655 const auto FieldTy = FD->
getType();
8656 if (!FieldTy->isArrayType() && !FieldTy->isPointerType()) {
8658 diag::err_counted_by_attr_not_on_ptr_or_flexible_array_member)
8665 if (FieldTy->isArrayType() &&
8667 StrictFlexArraysLevel,
true)) {
8669 diag::err_counted_by_attr_on_array_not_flexible_array_member)
8675 CountedByInvalidPointeeTypeKind::VALID;
8677 int SelectPtrOrArr = 0;
8678 if (FieldTy->isPointerType()) {
8682 assert(FieldTy->isArrayType());
8691 InvalidTypeKind = CountedByInvalidPointeeTypeKind::INCOMPLETE;
8693 InvalidTypeKind = CountedByInvalidPointeeTypeKind::SIZELESS;
8695 InvalidTypeKind = CountedByInvalidPointeeTypeKind::FUNCTION;
8697 InvalidTypeKind = CountedByInvalidPointeeTypeKind::FLEXIBLE_ARRAY_MEMBER;
8700 if (InvalidTypeKind != CountedByInvalidPointeeTypeKind::VALID) {
8701 S.
Diag(FD->
getBeginLoc(), diag::err_counted_by_attr_pointee_unknown_size)
8702 << SelectPtrOrArr << PointeeTy << (
int)InvalidTypeKind
8710 S.
Diag(E->
getBeginLoc(), diag::err_counted_by_attr_argument_not_integer)
8715 auto *DRE = dyn_cast<DeclRefExpr>(E);
8718 diag::err_counted_by_attr_only_support_simple_decl_reference)
8723 auto *CountDecl = DRE->
getDecl();
8724 FieldDecl *CountFD = dyn_cast<FieldDecl>(CountDecl);
8725 if (
auto *IFD = dyn_cast<IndirectFieldDecl>(CountDecl)) {
8726 CountFD = IFD->getAnonField();
8732 S.
Diag(CountDecl->getBeginLoc(),
8733 diag::note_flexible_array_counted_by_attr_field)
8734 << CountDecl << CountDecl->getSourceRange();
8740 S.
Diag(CountFD->
getBeginLoc(), diag::err_counted_by_attr_refer_to_union)
8750 if (RD != CountRD) {
8752 diag::err_flexible_array_count_not_in_same_struct)
8755 diag::note_flexible_array_counted_by_attr_field)
8766 auto *FD = dyn_cast<FieldDecl>(D);
8789 FunctionReturnThunksAttr::Kind Kind;
8790 if (!FunctionReturnThunksAttr::ConvertStrToKind(KindStr, Kind)) {
8791 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported)
8798 D->
dropAttr<FunctionReturnThunksAttr>();
8799 D->
addAttr(FunctionReturnThunksAttr::Create(S.
Context, Kind, AL));
8804 assert(isa<TypedefNameDecl>(D) &&
"This attribute only applies to a typedef");
8805 handleSimpleAttribute<AvailableOnlyInDefaultEvalMethodAttr>(S, D, AL);
8809 auto *VDecl = dyn_cast<VarDecl>(D);
8810 if (VDecl && !VDecl->isFunctionPointerType()) {
8811 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored_non_function_pointer)
8824 const auto *FD = cast<FunctionDecl>(D);
8826 assert(FT &&
"Function template is expected");
8830 if (TL->
size() < 2) {
8831 S.
Diag(FT->
getLocation(), diag::warn_sycl_kernel_num_of_template_params);
8836 for (
unsigned I = 0; I < 2; ++I) {
8838 if (isa<NonTypeTemplateParmDecl>(TParam)) {
8840 diag::warn_sycl_kernel_invalid_template_param_type);
8847 S.
Diag(FT->
getLocation(), diag::warn_sycl_kernel_num_of_function_params);
8858 handleSimpleAttribute<SYCLKernelAttr>(S, D, AL);
8862 if (!cast<VarDecl>(D)->hasGlobalStorage()) {
8864 << (A.
getKind() == ParsedAttr::AT_AlwaysDestroy);
8868 if (A.
getKind() == ParsedAttr::AT_AlwaysDestroy)
8869 handleSimpleAttribute<AlwaysDestroyAttr>(S, D, A);
8871 handleSimpleAttribute<NoDestroyAttr>(S, D, A);
8875 assert(cast<VarDecl>(D)->getStorageDuration() ==
SD_Automatic &&
8876 "uninitialized is only valid on automatic duration variables");
8881 bool DiagnoseFailure) {
8884 if (DiagnoseFailure) {
8885 S.
Diag(VD->
getBeginLoc(), diag::warn_ignored_objc_externally_retained)
8902 if (DiagnoseFailure) {
8903 S.
Diag(VD->
getBeginLoc(), diag::warn_ignored_objc_externally_retained)
8919 if (
auto *VD = dyn_cast<VarDecl>(D)) {
8920 assert(!isa<ParmVarDecl>(VD) &&
"should be diagnosed automatically");
8921 if (!VD->hasLocalStorage()) {
8930 handleSimpleAttribute<ObjCExternallyRetainedAttr>(S, D, AL);
8936 unsigned NumParams =
8938 for (
unsigned I = 0; I != NumParams; ++I) {
8952 handleSimpleAttribute<ObjCExternallyRetainedAttr>(S, D, AL);
8960 if (!isa<BlockDecl>(D)) {
8962 bool IsKernReturnT =
false;
8964 IsKernReturnT = (TT->getDecl()->getName() ==
"kern_return_t");
8969 diag::warn_mig_server_routine_does_not_return_kern_return_t);
8974 handleSimpleAttribute<MIGServerRoutineAttr>(S, D, AL);
8979 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
8982 S.
Diag(AL.
getLoc(), diag::warn_declspec_allocator_nonpointer)
8988 handleSimpleAttribute<MSAllocatorAttr>(S, D, AL);
8995 if (
const auto *PVD = dyn_cast<ParmVarDecl>(D)) {
8996 if (PVD->getType()->isIntegerType()) {
8997 S.
Diag(AL.
getLoc(), diag::err_attribute_output_parameter)
9008template<
typename Attr>
9016template<
typename Attr>
9025 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
9030 CFGuardAttr::GuardArg Arg;
9032 if (!CFGuardAttr::ConvertStrToGuardArg(II->
getName(), Arg)) {
9033 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
9041template <
typename AttrTy>
9044 auto I = llvm::find_if(Attrs,
9045 [Name](
const AttrTy *A) {
9046 return A->getTCBName() == Name;
9048 return I == Attrs.end() ? nullptr : *I;
9051template <
typename AttrTy,
typename ConflictingAttrTy>
9058 if (
const ConflictingAttrTy *ConflictingAttr =
9059 findEnforceTCBAttrByName<ConflictingAttrTy>(D, Argument)) {
9062 S.
Diag(AL.
getLoc(), diag::err_tcb_conflicting_attributes)
9076template <
typename AttrTy,
typename ConflictingAttrTy>
9079 StringRef TCBName = AL.getTCBName();
9080 if (
const ConflictingAttrTy *ConflictingAttr =
9081 findEnforceTCBAttrByName<ConflictingAttrTy>(D, TCBName)) {
9082 S.
Diag(ConflictingAttr->getLoc(), diag::err_tcb_conflicting_attributes)
9083 << ConflictingAttr->getAttrName()->getName()
9084 << AL.getAttrName()->getName() << TCBName;
9087 S.
Diag(AL.getLoc(), diag::note_conflicting_attribute);
9095 return ::new(Context) AttrTy(Context, AL, AL.getTCBName());
9099 return mergeEnforceTCBAttrImpl<EnforceTCBAttr, EnforceTCBLeafAttr>(
9104 Decl *D,
const EnforceTCBLeafAttr &AL) {
9105 return mergeEnforceTCBAttrImpl<EnforceTCBLeafAttr, EnforceTCBAttr>(
9122 for (
size_t I = 0; I < std::min(AL.
getNumArgs(), AttrNumArgs); ++I) {
9123 bool IsLastAttrArg = I == (AttrNumArgs - 1);
9126 if (IsLastAttrArg && AttrHasVariadicArg)
9133 if (isa<PackExpansionExpr>(E))
9134 return !(IsLastAttrArg && ArgMemberCanHoldExpr);
9147 auto CheckForIncompatibleAttr =
9149 StringRef IncompatibleStateName) {
9150 if (CurrentState == IncompatibleState) {
9151 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
9152 << (std::string(
"'__arm_new(\"") + StateName.str() +
"\")'")
9153 << (std::string(
"'") + IncompatibleStateName.str() +
"(\"" +
9154 StateName.str() +
"\")'")
9169 S.
Diag(AL.
getLoc(), diag::err_missing_arm_state) << AL;
9174 std::vector<StringRef> NewState;
9175 if (
const auto *ExistingAttr = D->
getAttr<ArmNewAttr>()) {
9176 for (StringRef S : ExistingAttr->newArgs())
9177 NewState.push_back(S);
9181 bool HasZT0 =
false;
9182 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
9183 StringRef StateName;
9188 if (StateName ==
"za")
9190 else if (StateName ==
"zt0")
9193 S.
Diag(LiteralLoc, diag::err_unknown_arm_state) << StateName;
9198 if (!llvm::is_contained(NewState, StateName))
9199 NewState.push_back(StateName);
9217 ArmNewAttr(S.
Context, AL, NewState.data(), NewState.size()));
9241 ? (
unsigned)diag::err_keyword_not_supported_on_target
9243 ? (
unsigned)diag::warn_unhandled_ms_attribute_ignored
9244 : (
unsigned)diag::warn_unknown_attribute_ignored)
9256 if (MustDelayArgs) {
9266 assert(AL.
isTypeAttr() &&
"Non-type attribute not handled");
9269 if (Options.IgnoreTypeAttributes)
9287 isa<DeclaratorDecl, TypeAliasDecl>(D)) {
9292 S.
Diag(AL.
getLoc(), diag::warn_type_attribute_deprecated_on_decl)
9301 if (AL.
getKind() == ParsedAttr::AT_Regparm) {
9314 if (AL.
getKind() == ParsedAttr::AT_VectorSize) {
9324 if (AL.
getKind() == ParsedAttr::AT_NoDeref) {
9335 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_on_decl)
9338 case ParsedAttr::AT_Interrupt:
9341 case ParsedAttr::AT_X86ForceAlignArgPointer:
9344 case ParsedAttr::AT_ReadOnlyPlacement:
9345 handleSimpleAttribute<ReadOnlyPlacementAttr>(S, D, AL);
9347 case ParsedAttr::AT_DLLExport:
9348 case ParsedAttr::AT_DLLImport:
9351 case ParsedAttr::AT_AMDGPUFlatWorkGroupSize:
9354 case ParsedAttr::AT_AMDGPUWavesPerEU:
9357 case ParsedAttr::AT_AMDGPUNumSGPR:
9360 case ParsedAttr::AT_AMDGPUNumVGPR:
9363 case ParsedAttr::AT_AMDGPUMaxNumWorkGroups:
9366 case ParsedAttr::AT_AVRSignal:
9369 case ParsedAttr::AT_BPFPreserveAccessIndex:
9372 case ParsedAttr::AT_BPFPreserveStaticOffset:
9373 handleSimpleAttribute<BPFPreserveStaticOffsetAttr>(S, D, AL);
9375 case ParsedAttr::AT_BTFDeclTag:
9378 case ParsedAttr::AT_WebAssemblyExportName:
9381 case ParsedAttr::AT_WebAssemblyImportModule:
9384 case ParsedAttr::AT_WebAssemblyImportName:
9387 case ParsedAttr::AT_IBOutlet:
9390 case ParsedAttr::AT_IBOutletCollection:
9393 case ParsedAttr::AT_IFunc:
9396 case ParsedAttr::AT_Alias:
9399 case ParsedAttr::AT_Aligned:
9402 case ParsedAttr::AT_AlignValue:
9405 case ParsedAttr::AT_AllocSize:
9408 case ParsedAttr::AT_AlwaysInline:
9411 case ParsedAttr::AT_AnalyzerNoReturn:
9414 case ParsedAttr::AT_TLSModel:
9417 case ParsedAttr::AT_Annotate:
9420 case ParsedAttr::AT_Availability:
9423 case ParsedAttr::AT_CarriesDependency:
9426 case ParsedAttr::AT_CPUDispatch:
9427 case ParsedAttr::AT_CPUSpecific:
9430 case ParsedAttr::AT_Common:
9433 case ParsedAttr::AT_CUDAConstant:
9436 case ParsedAttr::AT_PassObjectSize:
9439 case ParsedAttr::AT_Constructor:
9442 case ParsedAttr::AT_Deprecated:
9445 case ParsedAttr::AT_Destructor:
9448 case ParsedAttr::AT_EnableIf:
9451 case ParsedAttr::AT_Error:
9454 case ParsedAttr::AT_ExcludeFromExplicitInstantiation:
9457 case ParsedAttr::AT_DiagnoseIf:
9460 case ParsedAttr::AT_DiagnoseAsBuiltin:
9463 case ParsedAttr::AT_NoBuiltin:
9466 case ParsedAttr::AT_ExtVectorType:
9469 case ParsedAttr::AT_ExternalSourceSymbol:
9472 case ParsedAttr::AT_MinSize:
9475 case ParsedAttr::AT_OptimizeNone:
9478 case ParsedAttr::AT_EnumExtensibility:
9481 case ParsedAttr::AT_SYCLKernel:
9484 case ParsedAttr::AT_SYCLSpecialClass:
9485 handleSimpleAttribute<SYCLSpecialClassAttr>(S, D, AL);
9487 case ParsedAttr::AT_Format:
9490 case ParsedAttr::AT_FormatArg:
9493 case ParsedAttr::AT_Callback:
9496 case ParsedAttr::AT_CalledOnce:
9499 case ParsedAttr::AT_NVPTXKernel:
9500 case ParsedAttr::AT_CUDAGlobal:
9503 case ParsedAttr::AT_CUDADevice:
9506 case ParsedAttr::AT_HIPManaged:
9509 case ParsedAttr::AT_GNUInline:
9512 case ParsedAttr::AT_CUDALaunchBounds:
9515 case ParsedAttr::AT_Restrict:
9518 case ParsedAttr::AT_Mode:
9521 case ParsedAttr::AT_NonNull:
9522 if (
auto *PVD = dyn_cast<ParmVarDecl>(D))
9527 case ParsedAttr::AT_ReturnsNonNull:
9530 case ParsedAttr::AT_NoEscape:
9533 case ParsedAttr::AT_MaybeUndef:
9534 handleSimpleAttribute<MaybeUndefAttr>(S, D, AL);
9536 case ParsedAttr::AT_AssumeAligned:
9539 case ParsedAttr::AT_AllocAlign:
9542 case ParsedAttr::AT_Ownership:
9545 case ParsedAttr::AT_Naked:
9548 case ParsedAttr::AT_NoReturn:
9551 case ParsedAttr::AT_CXX11NoReturn:
9554 case ParsedAttr::AT_AnyX86NoCfCheck:
9557 case ParsedAttr::AT_NoThrow:
9559 handleSimpleAttribute<NoThrowAttr>(S, D, AL);
9561 case ParsedAttr::AT_CUDAShared:
9564 case ParsedAttr::AT_VecReturn:
9567 case ParsedAttr::AT_ObjCOwnership:
9570 case ParsedAttr::AT_ObjCPreciseLifetime:
9573 case ParsedAttr::AT_ObjCReturnsInnerPointer:
9576 case ParsedAttr::AT_ObjCRequiresSuper:
9579 case ParsedAttr::AT_ObjCBridge:
9582 case ParsedAttr::AT_ObjCBridgeMutable:
9585 case ParsedAttr::AT_ObjCBridgeRelated:
9588 case ParsedAttr::AT_ObjCDesignatedInitializer:
9591 case ParsedAttr::AT_ObjCRuntimeName:
9594 case ParsedAttr::AT_ObjCBoxable:
9597 case ParsedAttr::AT_NSErrorDomain:
9600 case ParsedAttr::AT_CFConsumed:
9601 case ParsedAttr::AT_NSConsumed:
9602 case ParsedAttr::AT_OSConsumed:
9606 case ParsedAttr::AT_OSReturnsRetainedOnZero:
9607 handleSimpleAttributeOrDiagnose<OSReturnsRetainedOnZeroAttr>(
9609 diag::warn_ns_attribute_wrong_parameter_type,
9612 case ParsedAttr::AT_OSReturnsRetainedOnNonZero:
9613 handleSimpleAttributeOrDiagnose<OSReturnsRetainedOnNonZeroAttr>(
9615 diag::warn_ns_attribute_wrong_parameter_type,
9618 case ParsedAttr::AT_NSReturnsAutoreleased:
9619 case ParsedAttr::AT_NSReturnsNotRetained:
9620 case ParsedAttr::AT_NSReturnsRetained:
9621 case ParsedAttr::AT_CFReturnsNotRetained:
9622 case ParsedAttr::AT_CFReturnsRetained:
9623 case ParsedAttr::AT_OSReturnsNotRetained:
9624 case ParsedAttr::AT_OSReturnsRetained:
9627 case ParsedAttr::AT_WorkGroupSizeHint:
9628 handleWorkGroupSize<WorkGroupSizeHintAttr>(S, D, AL);
9630 case ParsedAttr::AT_ReqdWorkGroupSize:
9631 handleWorkGroupSize<ReqdWorkGroupSizeAttr>(S, D, AL);
9633 case ParsedAttr::AT_OpenCLIntelReqdSubGroupSize:
9636 case ParsedAttr::AT_VecTypeHint:
9639 case ParsedAttr::AT_InitPriority:
9642 case ParsedAttr::AT_Packed:
9645 case ParsedAttr::AT_PreferredName:
9648 case ParsedAttr::AT_Section:
9651 case ParsedAttr::AT_CodeModel:
9654 case ParsedAttr::AT_RandomizeLayout:
9657 case ParsedAttr::AT_NoRandomizeLayout:
9660 case ParsedAttr::AT_CodeSeg:
9663 case ParsedAttr::AT_Target:
9666 case ParsedAttr::AT_TargetVersion:
9669 case ParsedAttr::AT_TargetClones:
9672 case ParsedAttr::AT_MinVectorWidth:
9675 case ParsedAttr::AT_Unavailable:
9676 handleAttrWithMessage<UnavailableAttr>(S, D, AL);
9678 case ParsedAttr::AT_OMPAssume:
9681 case ParsedAttr::AT_ObjCDirect:
9684 case ParsedAttr::AT_ObjCDirectMembers:
9686 handleSimpleAttribute<ObjCDirectMembersAttr>(S, D, AL);
9688 case ParsedAttr::AT_ObjCExplicitProtocolImpl:
9691 case ParsedAttr::AT_Unused:
9694 case ParsedAttr::AT_Visibility:
9697 case ParsedAttr::AT_TypeVisibility:
9700 case ParsedAttr::AT_WarnUnusedResult:
9703 case ParsedAttr::AT_WeakRef:
9706 case ParsedAttr::AT_WeakImport:
9709 case ParsedAttr::AT_TransparentUnion:
9712 case ParsedAttr::AT_ObjCMethodFamily:
9715 case ParsedAttr::AT_ObjCNSObject:
9718 case ParsedAttr::AT_ObjCIndependentClass:
9721 case ParsedAttr::AT_Blocks:
9724 case ParsedAttr::AT_Sentinel:
9727 case ParsedAttr::AT_Cleanup:
9730 case ParsedAttr::AT_NoDebug:
9733 case ParsedAttr::AT_CmseNSEntry:
9736 case ParsedAttr::AT_StdCall:
9737 case ParsedAttr::AT_CDecl:
9738 case ParsedAttr::AT_FastCall:
9739 case ParsedAttr::AT_ThisCall:
9740 case ParsedAttr::AT_Pascal:
9741 case ParsedAttr::AT_RegCall:
9742 case ParsedAttr::AT_SwiftCall:
9743 case ParsedAttr::AT_SwiftAsyncCall:
9744 case ParsedAttr::AT_VectorCall:
9745 case ParsedAttr::AT_MSABI:
9746 case ParsedAttr::AT_SysVABI:
9747 case ParsedAttr::AT_Pcs:
9748 case ParsedAttr::AT_IntelOclBicc:
9749 case ParsedAttr::AT_PreserveMost:
9750 case ParsedAttr::AT_PreserveAll:
9751 case ParsedAttr::AT_AArch64VectorPcs:
9752 case ParsedAttr::AT_AArch64SVEPcs:
9753 case ParsedAttr::AT_AMDGPUKernelCall:
9754 case ParsedAttr::AT_M68kRTD:
9755 case ParsedAttr::AT_PreserveNone:
9756 case ParsedAttr::AT_RISCVVectorCC:
9759 case ParsedAttr::AT_Suppress:
9762 case ParsedAttr::AT_Owner:
9763 case ParsedAttr::AT_Pointer:
9766 case ParsedAttr::AT_OpenCLAccess:
9769 case ParsedAttr::AT_OpenCLNoSVM:
9772 case ParsedAttr::AT_SwiftContext:
9775 case ParsedAttr::AT_SwiftAsyncContext:
9778 case ParsedAttr::AT_SwiftErrorResult:
9781 case ParsedAttr::AT_SwiftIndirectResult:
9784 case ParsedAttr::AT_InternalLinkage:
9787 case ParsedAttr::AT_ZeroCallUsedRegs:
9790 case ParsedAttr::AT_FunctionReturnThunks:
9793 case ParsedAttr::AT_NoMerge:
9796 case ParsedAttr::AT_NoUniqueAddress:
9800 case ParsedAttr::AT_AvailableOnlyInDefaultEvalMethod:
9804 case ParsedAttr::AT_CountedBy:
9809 case ParsedAttr::AT_LayoutVersion:
9812 case ParsedAttr::AT_Uuid:
9815 case ParsedAttr::AT_MSInheritance:
9818 case ParsedAttr::AT_Thread:
9821 case ParsedAttr::AT_MSConstexpr:
9826 case ParsedAttr::AT_HLSLNumThreads:
9829 case ParsedAttr::AT_HLSLSV_GroupIndex:
9830 handleSimpleAttribute<HLSLSV_GroupIndexAttr>(S, D, AL);
9832 case ParsedAttr::AT_HLSLSV_DispatchThreadID:
9835 case ParsedAttr::AT_HLSLPackOffset:
9838 case ParsedAttr::AT_HLSLShader:
9841 case ParsedAttr::AT_HLSLResourceBinding:
9844 case ParsedAttr::AT_HLSLParamModifier:
9848 case ParsedAttr::AT_AbiTag:
9851 case ParsedAttr::AT_CFGuard:
9856 case ParsedAttr::AT_AssertExclusiveLock:
9859 case ParsedAttr::AT_AssertSharedLock:
9862 case ParsedAttr::AT_PtGuardedVar:
9865 case ParsedAttr::AT_NoSanitize:
9868 case ParsedAttr::AT_NoSanitizeSpecific:
9871 case ParsedAttr::AT_GuardedBy:
9874 case ParsedAttr::AT_PtGuardedBy:
9877 case ParsedAttr::AT_ExclusiveTrylockFunction:
9880 case ParsedAttr::AT_LockReturned:
9883 case ParsedAttr::AT_LocksExcluded:
9886 case ParsedAttr::AT_SharedTrylockFunction:
9889 case ParsedAttr::AT_AcquiredBefore:
9892 case ParsedAttr::AT_AcquiredAfter:
9897 case ParsedAttr::AT_Capability:
9898 case ParsedAttr::AT_Lockable:
9901 case ParsedAttr::AT_RequiresCapability:
9905 case ParsedAttr::AT_AssertCapability:
9908 case ParsedAttr::AT_AcquireCapability:
9911 case ParsedAttr::AT_ReleaseCapability:
9914 case ParsedAttr::AT_TryAcquireCapability:
9919 case ParsedAttr::AT_Consumable:
9922 case ParsedAttr::AT_CallableWhen:
9925 case ParsedAttr::AT_ParamTypestate:
9928 case ParsedAttr::AT_ReturnTypestate:
9931 case ParsedAttr::AT_SetTypestate:
9934 case ParsedAttr::AT_TestTypestate:
9939 case ParsedAttr::AT_ArgumentWithTypeTag:
9942 case ParsedAttr::AT_TypeTagForDatatype:
9947 case ParsedAttr::AT_SwiftAsyncName:
9950 case ParsedAttr::AT_SwiftAttr:
9953 case ParsedAttr::AT_SwiftBridge:
9956 case ParsedAttr::AT_SwiftError:
9959 case ParsedAttr::AT_SwiftName:
9962 case ParsedAttr::AT_SwiftNewType:
9965 case ParsedAttr::AT_SwiftAsync:
9968 case ParsedAttr::AT_SwiftAsyncError:
9973 case ParsedAttr::AT_XRayLogArgs:
9977 case ParsedAttr::AT_PatchableFunctionEntry:
9981 case ParsedAttr::AT_AlwaysDestroy:
9982 case ParsedAttr::AT_NoDestroy:
9986 case ParsedAttr::AT_Uninitialized:
9990 case ParsedAttr::AT_ObjCExternallyRetained:
9994 case ParsedAttr::AT_MIGServerRoutine:
9998 case ParsedAttr::AT_MSAllocator:
10002 case ParsedAttr::AT_ArmBuiltinAlias:
10006 case ParsedAttr::AT_ArmLocallyStreaming:
10007 handleSimpleAttribute<ArmLocallyStreamingAttr>(S, D, AL);
10010 case ParsedAttr::AT_ArmNew:
10014 case ParsedAttr::AT_AcquireHandle:
10018 case ParsedAttr::AT_ReleaseHandle:
10019 handleHandleAttr<ReleaseHandleAttr>(S, D, AL);
10022 case ParsedAttr::AT_UnsafeBufferUsage:
10023 handleUnsafeBufferUsage<UnsafeBufferUsageAttr>(S, D, AL);
10026 case ParsedAttr::AT_UseHandle:
10027 handleHandleAttr<UseHandleAttr>(S, D, AL);
10030 case ParsedAttr::AT_EnforceTCB:
10031 handleEnforceTCBAttr<EnforceTCBAttr, EnforceTCBLeafAttr>(S, D, AL);
10034 case ParsedAttr::AT_EnforceTCBLeaf:
10035 handleEnforceTCBAttr<EnforceTCBLeafAttr, EnforceTCBAttr>(S, D, AL);
10038 case ParsedAttr::AT_BuiltinAlias:
10042 case ParsedAttr::AT_PreferredType:
10046 case ParsedAttr::AT_UsingIfExists:
10047 handleSimpleAttribute<UsingIfExistsAttr>(S, D, AL);
10050 case ParsedAttr::AT_TypeNullable:
10061 if (AttrList.
empty())
10072 Diag(AttrList.
begin()->getLoc(), diag::err_attribute_weakref_without_alias)
10073 << cast<NamedDecl>(D);
10082 if (!D->
hasAttr<OpenCLKernelAttr>()) {
10084 if (
const auto *A = D->
getAttr<ReqdWorkGroupSizeAttr>()) {
10089 }
else if (
const auto *A = D->
getAttr<WorkGroupSizeHintAttr>()) {
10092 }
else if (
const auto *A = D->
getAttr<VecTypeHintAttr>()) {
10095 }
else if (
const auto *A = D->
getAttr<OpenCLIntelReqdSubGroupSizeAttr>()) {
10098 }
else if (!D->
hasAttr<CUDAGlobalAttr>()) {
10099 if (
const auto *A = D->
getAttr<AMDGPUFlatWorkGroupSizeAttr>()) {
10103 }
else if (
const auto *A = D->
getAttr<AMDGPUWavesPerEUAttr>()) {
10107 }
else if (
const auto *A = D->
getAttr<AMDGPUNumSGPRAttr>()) {
10111 }
else if (
const auto *A = D->
getAttr<AMDGPUNumVGPRAttr>()) {
10124 if (D->
hasAttr<ObjCDesignatedInitializerAttr>() &&
10125 cast<ObjCMethodDecl>(D)->getMethodFamily() !=
OMF_init) {
10127 D->
dropAttr<ObjCDesignatedInitializerAttr>();
10136 if (AL.getKind() == ParsedAttr::AT_TransparentUnion) {
10143 if (D && D->
hasAttr<BPFPreserveAccessIndexAttr>())
10152 if (AL.getKind() == ParsedAttr::AT_Annotate) {
10156 Diag(AL.getLoc(), diag::err_only_annotate_after_access_spec);
10168 if (AL.isUsedAsTypeAttr() || AL.isInvalid())
10174 S.
Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored)
10175 << AL << AL.getRange();
10177 S.
Diag(AL.getLoc(), diag::warn_attribute_not_on_decl) << AL
10198 assert(isa<FunctionDecl>(ND) || isa<VarDecl>(ND));
10200 if (
auto *FD = dyn_cast<FunctionDecl>(ND)) {
10222 for (
const auto &AI : FT->param_types()) {
10225 Params.push_back(Param);
10227 NewFD->setParams(Params);
10229 }
else if (
auto *VD = dyn_cast<VarDecl>(ND)) {
10231 VD->getInnerLocStart(), VD->getLocation(), II,
10232 VD->getType(), VD->getTypeSourceInfo(),
10233 VD->getStorageClass());
10234 if (VD->getQualifier())
10235 cast<VarDecl>(NewD)->setQualifierInfo(VD->getQualifierLoc());
10270 if (
auto *VD = dyn_cast<VarDecl>(D))
10271 if (VD->isExternC())
10273 if (
auto *FD = dyn_cast<FunctionDecl>(D))
10281 auto &WeakInfos = I->second;
10282 for (
const auto &W : WeakInfos)
10284 std::remove_reference_t<
decltype(WeakInfos)> EmptyWeakInfos;
10285 WeakInfos.swap(EmptyWeakInfos);
10301 if (AL.slidesFromDeclToDeclSpecLegacyBehavior()) {
10306 AL.diagnoseAppertainsTo(*
this, D);
10317 .WithIncludeCXX11Attributes(
false)
10318 .WithIgnoreTypeAttributes(
true));
10328 .WithIncludeCXX11Attributes(
false)
10329 .WithIgnoreTypeAttributes(
true));
10347 UnavailableAttr::ImplicitReason &reason) {
10351 if (!isa<FieldDecl>(D) && !isa<ObjCPropertyDecl>(D) &&
10352 !isa<FunctionDecl>(D))
10360 if ((isa<ObjCIvarDecl>(D) || isa<ObjCPropertyDecl>(D))) {
10363 reason = UnavailableAttr::IR_ForbiddenWeak;
10372 reason = UnavailableAttr::IR_ARCForbiddenType;
10382 auto Reason = UnavailableAttr::IR_None;
10384 assert(Reason &&
"didn't set reason?");
10389 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
10392 if (FD->
hasAttr<UnavailableAttr>() &&
10394 diag::err_arc_array_param_no_ownership) {
10425 bool AnyAccessFailures =
false;
10433 switch (diag.
Kind) {
10437 if (!
decl->isInvalidDecl())
10445 if (AnyAccessFailures && isa<DecompositionDecl>(
decl))
10449 AnyAccessFailures =
true;
10465 assert(curPool &&
"re-emitting in undelayed context not supported");
10466 curPool->
steal(pool);
Defines the clang::ASTContext interface.
static SmallString< 64 > normalizeName(const IdentifierInfo *Name, const IdentifierInfo *Scope, AttributeCommonInfo::Syntax SyntaxUsed)
static CudaArch getCudaArch(CodeGenModule &CGM)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines helper utilities for supporting the HLSL runtime environment.
Defines the clang::LangOptions interface.
llvm::MachO::Target Target
llvm::MachO::Record Record
static bool versionsMatch(const VersionTuple &X, const VersionTuple &Y)
Check whether the two versions match.
static unsigned getNumAttributeArgs(const ParsedAttr &AL)
Defines the clang::Preprocessor interface.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
This file declares semantic analysis for CUDA constructs.
static bool isCFStringType(QualType T, ASTContext &Ctx)
static void handleObjCBoxable(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleBPFPreserveAccessIndexAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleCleanupAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAlignedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleWeakImportAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleHandleAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleHLSLShaderAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkGuardedByAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, Expr *&Arg)
static void handleCodeSegAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handlePatchableFunctionEntryAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleCountedByAttrField(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAMDGPUNumVGPRAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleOpenCLAccessAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleFormatAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Handle attribute((format(type,idx,firstarg))) attributes based on http://gcc.gnu.org/onlinedocs/gcc/F...
static bool CheckCountedByAttrOnField(Sema &S, FieldDecl *FD, Expr *E, llvm::SmallVectorImpl< TypeCoupledDeclRefInfo > &Decls)
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)
CountedByInvalidPointeeTypeKind
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 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 ':'.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
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
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.
AvailabilityAttr * mergeAvailabilityAttr(NamedDecl *D, const AttributeCommonInfo &CI, IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK, int Priority)
bool ConstantFoldAttrArgs(const AttributeCommonInfo &CI, MutableArrayRef< Expr * > Args)
ConstantFoldAttrArgs - Folds attribute arguments into ConstantExprs (unless they are value dependent ...
BTFDeclTagAttr * mergeBTFDeclTagAttr(Decl *D, const BTFDeclTagAttr &AL)
void LoadExternalWeakUndeclaredIdentifiers()
Load weak undeclared identifiers from the external source.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
EnforceTCBAttr * mergeEnforceTCBAttr(Decl *D, const EnforceTCBAttr &AL)
bool checkTargetVersionAttr(SourceLocation LiteralLoc, Decl *D, StringRef &Str, bool &isDefault)
bool isValidPointerAttrType(QualType T, bool RefOkay=false)
Determine if type T is a valid subject for a nonnull and similar attributes.
TypeVisibilityAttr * mergeTypeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, TypeVisibilityAttr::VisibilityType Vis)
void AddAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, bool IsPackExpansion)
AddAlignedAttr - Adds an aligned attribute to a particular declaration.
void AddAssumeAlignedAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E, Expr *OE)
AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular declaration.
bool checkSectionName(SourceLocation LiteralLoc, StringRef Str)
void AddPragmaAttributes(Scope *S, Decl *D)
Adds the attributes that have been specified using the '#pragma clang attribute push' directives to t...
bool checkCommonAttributeFeatures(const Decl *D, const ParsedAttr &A, bool SkipArgCountCheck=false)
Handles semantic checking for features that are common to all attributes, such as checking whether a ...
void addAMDGPUWavesPerEUAttr(Decl *D, const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
addAMDGPUWavePersEUAttr - Adds an amdgpu_waves_per_eu attribute to a particular declaration.
WebAssemblyImportNameAttr * mergeImportNameAttr(Decl *D, const WebAssemblyImportNameAttr &AL)
void addAMDGPUMaxNumWorkGroupsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *XExpr, Expr *YExpr, Expr *ZExpr)
addAMDGPUMaxNumWorkGroupsAttr - Adds an amdgpu_max_num_work_groups attribute to a particular declarat...
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl, const ParsedAttributesView &AttrList)
AMDGPUFlatWorkGroupSizeAttr * CreateAMDGPUFlatWorkGroupSizeAttr(const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
Create an AMDGPUWavesPerEUAttr attribute.
DLLImportAttr * mergeDLLImportAttr(Decl *D, const AttributeCommonInfo &CI)
ExtVectorDeclsType ExtVectorDecls
ExtVectorDecls - This is a list all the extended vector types.
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=NoFold)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
void PopParsingDeclaration(ParsingDeclState state, Decl *decl)
ErrorAttr * mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI, StringRef NewUserDiagnostic)
void redelayDiagnostics(sema::DelayedDiagnosticPool &pool)
Given a set of delayed diagnostics, re-emit them as if they had been delayed in the current context i...
VisibilityAttr * mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, VisibilityAttr::VisibilityType Vis)
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
AMDGPUWavesPerEUAttr * CreateAMDGPUWavesPerEUAttr(const AttributeCommonInfo &CI, Expr *Min, Expr *Max)
Create an AMDGPUWavesPerEUAttr attribute.
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
ASTContext & getASTContext() const
@ None
This is not a defaultable comparison operator.
bool CheckCallingConvAttr(const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD=nullptr, CUDAFunctionTarget CFT=CUDAFunctionTarget::InvalidTarget)
Check validaty of calling convention attribute attr.
FunctionDecl * ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, bool Complain=false, DeclAccessPair *Found=nullptr, TemplateSpecCandidateSet *FailedTSC=nullptr)
Given an expression that refers to an overloaded function, try to resolve that overloaded function ex...
void ProcessPragmaWeak(Scope *S, Decl *D)
void AddXConsumedAttr(Decl *D, const AttributeCommonInfo &CI, RetainOwnershipKind K, bool IsTemplateInstantiation)
bool CheckAttrNoArgs(const ParsedAttr &CurrAttr)
bool UnifySection(StringRef SectionName, int SectionFlags, NamedDecl *TheDecl)
FPOptions & getCurFPFeatures()
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
@ UPPC_Expression
An arbitrary expression.
const LangOptions & getLangOpts() const
void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Name, bool InInstantiation=false)
AddModeAttr - Adds a mode attribute to a particular declaration.
bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type)
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
MinSizeAttr * mergeMinSizeAttr(Decl *D, const AttributeCommonInfo &CI)
const LangOptions & LangOpts
static const uint64_t MaximumAlignment
AlwaysInlineAttr * mergeAlwaysInlineAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Ident)
QualType BuildCountAttributedArrayOrPointerType(QualType WrappedTy, Expr *CountExpr)
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,...
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.
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 isFunctionType() const
bool isObjCObjectPointerType() const
bool isStructureTypeWithFlexibleArrayMember() 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