60#include "llvm/ADT/STLExtras.h"
61#include "llvm/ADT/STLForwardCompat.h"
62#include "llvm/ADT/StringExtras.h"
63#include "llvm/Demangle/Demangle.h"
64#include "llvm/IR/DerivedTypes.h"
65#include "llvm/MC/MCSectionMachO.h"
66#include "llvm/Support/Error.h"
67#include "llvm/Support/MathExtras.h"
68#include "llvm/Support/raw_ostream.h"
69#include "llvm/TargetParser/Triple.h"
93template <
typename AttrInfo>
100 if (UVal > (uint32_t)std::numeric_limits<int>::max()) {
104 <<
toString(I, 10,
false) << 32 << 0;
113 const Expr *
E, StringRef &Str,
119 if (!Literal || (!Literal->isUnevaluated() && !Literal->isOrdinary())) {
125 Str = Literal->getString();
135 Diag(
Loc->Loc, diag::err_attribute_argument_type)
139 Str =
Loc->Ident->getName();
141 *ArgLocation =
Loc->Loc;
151 if (!Literal || (!Literal->isUnevaluated() && !Literal->isOrdinary())) {
156 Str = Literal->getString();
178 bool foundStarOperator = IsOverloadedOperatorPresent(
Record, OO_Star);
179 bool foundArrowOperator = IsOverloadedOperatorPresent(
Record, OO_Arrow);
180 if (foundStarOperator && foundArrowOperator)
187 for (
const auto &BaseSpecifier : CXXRecord->bases()) {
188 if (!foundStarOperator)
189 foundStarOperator = IsOverloadedOperatorPresent(
190 BaseSpecifier.getType()->getAsRecordDecl(), OO_Star);
191 if (!foundArrowOperator)
192 foundArrowOperator = IsOverloadedOperatorPresent(
193 BaseSpecifier.getType()->getAsRecordDecl(), OO_Arrow);
196 if (foundStarOperator && foundArrowOperator)
207 const auto *VD = cast<ValueDecl>(
D);
216 if (RT->isIncompleteType())
223 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_decl_not_pointer) << AL << QT;
240template <
typename AttrType>
247 if (
const auto *CRD = dyn_cast<CXXRecordDecl>(RD)) {
249 return !Base->hasAttr<AttrType>();
271 return checkRecordDeclForAttr<CapabilityAttr>(RT->
getDecl());
284 return checkRecordDeclForAttr<ScopedLockableAttr>(RT->
getDecl());
296 return TN->
hasAttr<CapabilityAttr>();
315 if (
const auto *
E = dyn_cast<CastExpr>(Ex))
317 else if (
const auto *
E = dyn_cast<ParenExpr>(Ex))
319 else if (
const auto *
E = dyn_cast<UnaryOperator>(Ex)) {
320 if (
E->getOpcode() == UO_LNot ||
E->getOpcode() == UO_AddrOf ||
321 E->getOpcode() == UO_Deref)
324 }
else if (
const auto *
E = dyn_cast<BinaryOperator>(Ex)) {
325 if (
E->getOpcode() == BO_LAnd ||
E->getOpcode() == BO_LOr)
343 bool ParamIdxOk =
false) {
348 const auto *MD = dyn_cast<const CXXMethodDecl>(
D);
349 if (MD && !MD->isStatic()) {
352 if (!checkRecordDeclForAttr<CapabilityAttr>(RD) &&
353 !checkRecordDeclForAttr<ScopedLockableAttr>(RD))
355 diag::warn_thread_attribute_not_on_capability_member)
356 << AL << MD->getParent();
358 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_not_on_non_static_member)
363 for (
unsigned Idx = Sidx; Idx < AL.
getNumArgs(); ++Idx) {
368 Args.push_back(ArgExp);
372 if (
const auto *StrLit = dyn_cast<StringLiteral>(ArgExp)) {
373 if (StrLit->getLength() == 0 ||
374 (StrLit->isOrdinary() && StrLit->getString() ==
"*")) {
377 Args.push_back(ArgExp);
383 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_ignored) << AL;
384 Args.push_back(ArgExp);
392 if (
const auto *UOp = dyn_cast<UnaryOperator>(ArgExp))
393 if (UOp->getOpcode() == UO_AddrOf)
394 if (
const auto *DRE = dyn_cast<DeclRefExpr>(UOp->getSubExpr()))
395 if (DRE->getDecl()->isCXXInstanceMember())
396 ArgTy = DRE->getDecl()->getType();
402 if(!RT && ParamIdxOk) {
403 const auto *FD = dyn_cast<FunctionDecl>(
D);
404 const auto *IL = dyn_cast<IntegerLiteral>(ArgExp);
406 unsigned int NumParams = FD->getNumParams();
407 llvm::APInt ArgValue = IL->getValue();
408 uint64_t ParamIdxFromOne = ArgValue.getZExtValue();
409 uint64_t ParamIdxFromZero = ParamIdxFromOne - 1;
410 if (!ArgValue.isStrictlyPositive() || ParamIdxFromOne > NumParams) {
412 diag::err_attribute_argument_out_of_bounds_extra_info)
413 << AL << Idx + 1 << NumParams;
416 ArgTy = FD->getParamDecl(ParamIdxFromZero)->getType();
425 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_argument_not_lockable)
428 Args.push_back(ArgExp);
440 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_not_on_scoped_lockable_param)
461 unsigned Size = Args.size();
495 QualType QT = cast<ValueDecl>(
D)->getType();
497 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_decl_not_lockable) << AL;
514 Expr **StartArg = &Args[0];
516 AcquiredAfterAttr(S.
Context, AL, StartArg, Args.size()));
524 Expr **StartArg = &Args[0];
526 AcquiredBeforeAttr(S.
Context, AL, StartArg, Args.size()));
543 unsigned Size = Args.size();
544 Expr **StartArg = Size == 0 ? nullptr : &Args[0];
546 AssertSharedLockAttr(S.
Context, AL, StartArg, Size));
555 unsigned Size = Args.size();
556 Expr **StartArg = Size == 0 ? nullptr : &Args[0];
558 AssertExclusiveLockAttr(S.
Context, AL, StartArg, Size));
566template <
typename AttrInfo>
568 unsigned AttrArgNo) {
569 assert(AI.isArgExpr(AttrArgNo) &&
"Expected expression argument");
570 Expr *AttrArg = AI.getArgAsExpr(AttrArgNo);
579 S.
Diag(SrcLoc, diag::err_attribute_integers_only)
594 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only) << AL;
620 AllocSizeAttr(S.
Context, AL, SizeArgNo, NumberArgNo));
629 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
664 unsigned Size = Args.size();
672 if (
const auto *ParmDecl = dyn_cast<ParmVarDecl>(
D);
682 unsigned Size = Args.size();
685 Expr **StartArg = &Args[0];
688 LocksExcludedAttr(S.
Context, AL, StartArg, Size));
692 Expr *&Cond, StringRef &Msg) {
698 Cond = Converted.
get();
705 Msg =
"<no message provided>";
711 S.
Diag(AL.
getLoc(), diag::err_attr_cond_never_constant_expr) << AL;
713 S.
Diag(PDiag.first, PDiag.second);
720 S.
Diag(AL.
getLoc(), diag::ext_clang_enable_if);
729 StringRef NewUserDiagnostic;
738 const auto *PD = isa<CXXRecordDecl>(
D)
739 ? cast<DeclContext>(
D)
741 if (
const auto *RD = dyn_cast<CXXRecordDecl>(PD); RD && RD->isLocalClass()) {
743 diag::warn_attribute_exclude_from_explicit_instantiation_local_class)
744 << AL << !isa<CXXRecordDecl>(
D);
748 ExcludeFromExplicitInstantiationAttr(S.
Context, AL));
764 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD))
772 bool referencesArgs(
Expr *
E) {
780 "`this` doesn't refer to the enclosing class?");
786 if (
const auto *PVD = dyn_cast<ParmVarDecl>(DRE->
getDecl()))
787 if (Parms.count(PVD)) {
798 const auto *DeclFD = cast<FunctionDecl>(
D);
800 if (
const auto *MethodDecl = dyn_cast<CXXMethodDecl>(DeclFD))
801 if (!MethodDecl->isStatic()) {
802 S.
Diag(AL.
getLoc(), diag::err_attribute_no_member_function) << AL;
809 if (
auto *
E = dyn_cast<Expr *>(
Union))
811 return cast<IdentifierLoc *>(
Union)->Loc;
814 S.
Diag(
Loc, diag::err_attribute_argument_n_type) << AL << Index <<
T;
820 auto *F = dyn_cast_if_present<DeclRefExpr>(AL.
getArgAsExpr(0));
823 return dyn_cast_if_present<FunctionDecl>(F->getFoundDecl());
832 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments_for)
839 for (
unsigned I = 1; I < AL.
getNumArgs(); ++I) {
851 if (Index > DeclFD->getNumParams()) {
852 S.
Diag(AL.
getLoc(), diag::err_attribute_bounds_for_function)
853 << AL << Index << DeclFD << DeclFD->getNumParams();
858 QualType T2 = DeclFD->getParamDecl(Index - 1)->getType();
863 << AL << Index << DeclFD << T2 << I << AttrFD << T1;
867 Indices.push_back(Index - 1);
871 S.
Context, AL, AttrFD, Indices.data(), Indices.size()));
875 S.
Diag(AL.
getLoc(), diag::ext_clang_diagnose_if);
882 StringRef DefaultSevStr;
886 DiagnoseIfAttr::DefaultSeverity DefaultSev;
887 if (!DiagnoseIfAttr::ConvertStrToDefaultSeverity(DefaultSevStr, DefaultSev)) {
889 diag::err_diagnose_if_invalid_diagnostic_type);
893 StringRef WarningGroup;
898 if (WarningGroup.empty() ||
902 diag::err_diagnose_if_unknown_warning)
908 bool ArgDependent =
false;
909 if (
const auto *FD = dyn_cast<FunctionDecl>(
D))
910 ArgDependent = ArgumentDependenceChecker(FD).referencesArgs(Cond);
912 S.
Context, AL, Cond, Msg, DefaultSev, WarningGroup, ArgDependent,
913 cast<NamedDecl>(
D)));
917 static constexpr const StringRef kWildcard =
"*";
920 bool HasWildcard =
false;
922 const auto AddBuiltinName = [&Names, &HasWildcard](StringRef Name) {
923 if (Name == kWildcard)
925 Names.push_back(Name);
929 if (
const auto *NBA =
D->
getAttr<NoBuiltinAttr>())
930 for (StringRef BuiltinName : NBA->builtinNames())
931 AddBuiltinName(BuiltinName);
935 AddBuiltinName(kWildcard);
937 for (
unsigned I = 0,
E = AL.
getNumArgs(); I !=
E; ++I) {
938 StringRef BuiltinName;
944 AddBuiltinName(BuiltinName);
946 S.
Diag(LiteralLoc, diag::warn_attribute_no_builtin_invalid_builtin_name)
947 << BuiltinName << AL;
952 Names.erase(std::unique(Names.begin(), Names.end()), Names.end());
955 if (HasWildcard && Names.size() > 1)
957 diag::err_attribute_no_builtin_wildcard_or_builtin_name)
963 NoBuiltinAttr(S.
Context, AL, Names.data(), Names.size()));
967 if (
D->
hasAttr<PassObjectSizeAttr>()) {
968 S.
Diag(
D->
getBeginLoc(), diag::err_attribute_only_once_per_parameter) << AL;
990 if (!cast<ParmVarDecl>(
D)->getType()->isPointerType()) {
999 ConsumableAttr::ConsumedState DefaultState;
1003 if (!ConsumableAttr::ConvertStrToConsumedState(IL->
Ident->
getName(),
1005 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported) << AL
1010 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1023 if (!RD->hasAttr<ConsumableAttr>()) {
1024 S.
Diag(AL.
getLoc(), diag::warn_attr_on_unconsumable_class) << RD;
1041 for (
unsigned ArgIndex = 0; ArgIndex < AL.
getNumArgs(); ++ArgIndex) {
1042 CallableWhenAttr::ConsumedState CallableState;
1044 StringRef StateString;
1055 if (!CallableWhenAttr::ConvertStrToConsumedState(StateString,
1057 S.
Diag(
Loc, diag::warn_attribute_type_not_supported) << AL << StateString;
1061 States.push_back(CallableState);
1065 CallableWhenAttr(S.
Context, AL, States.data(), States.size()));
1069 ParamTypestateAttr::ConsumedState ParamState;
1075 if (!ParamTypestateAttr::ConvertStrToConsumedState(StateString,
1077 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported)
1078 << AL << StateString;
1082 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1103 ReturnTypestateAttr::ConsumedState ReturnState;
1107 if (!ReturnTypestateAttr::ConvertStrToConsumedState(IL->
Ident->
getName(),
1109 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported) << AL
1114 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1151 SetTypestateAttr::ConsumedState NewState;
1155 if (!SetTypestateAttr::ConvertStrToConsumedState(Param, NewState)) {
1156 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported) << AL
1161 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1173 TestTypestateAttr::ConsumedState TestState;
1177 if (!TestTypestateAttr::ConvertStrToConsumedState(Param, TestState)) {
1178 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported) << AL
1183 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1197 if (
auto *TD = dyn_cast<TagDecl>(
D))
1199 else if (
auto *FD = dyn_cast<FieldDecl>(
D)) {
1206 if (BitfieldByteAligned)
1208 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored_for_field_of_type)
1214 if (BitfieldByteAligned)
1215 S.
Diag(AL.
getLoc(), diag::warn_attribute_packed_for_bitfield);
1221 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored) << AL;
1225 auto *RD = cast<CXXRecordDecl>(
D);
1227 assert(CTD &&
"attribute does not appertain to this declaration");
1238 if (
const auto *CTSD = dyn_cast_if_present<ClassTemplateSpecializationDecl>(
1240 Template = CTSD->getSpecializedTemplate();
1242 while (TST && TST->isTypeAlias())
1245 Template = TST->getTemplateName().getAsTemplateDecl();
1254 S.
Diag(AL.
getLoc(), diag::err_attribute_preferred_name_arg_invalid)
1257 S.
Diag(TT->getDecl()->getLocation(), diag::note_entity_declared_at)
1266 NoSpecializationsAttr::Create(S.
Context, Message, AL));
1276 T =
T.getNonReferenceType();
1282 if (UT && UT->getDecl()->hasAttr<TransparentUnionAttr>()) {
1284 for (
const auto *I : UD->
fields()) {
1298 bool isReturnValue =
false) {
1301 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only)
1302 << AL << AttrParmRange << TypeRange;
1304 S.
Diag(AL.
getLoc(), diag::warn_attribute_pointers_only)
1305 << AL << AttrParmRange << TypeRange << 0;
1313 for (
unsigned I = 0; I < AL.
getNumArgs(); ++I) {
1327 NonNullArgs.push_back(Idx);
1338 I !=
E && !AnyPointers; ++I) {
1345 S.
Diag(AL.
getLoc(), diag::warn_attribute_nonnull_no_pointers);
1348 ParamIdx *Start = NonNullArgs.data();
1349 unsigned Size = NonNullArgs.size();
1350 llvm::array_pod_sort(Start, Start + Size);
1360 S.
Diag(AL.
getLoc(), diag::warn_attribute_nonnull_parm_no_args)
1389 QualType T = cast<ParmVarDecl>(
D)->getType();
1391 S.
Diag(AL.
getLoc(), diag::warn_attribute_pointers_only)
1414 AssumeAlignedAttr TmpAttr(
Context, CI,
E, OE);
1418 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
1419 << &TmpAttr << TmpAttr.getRange() << SR;
1424 std::optional<llvm::APSInt> I = llvm::APSInt(64);
1427 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1431 Diag(AttrLoc, diag::err_attribute_argument_type)
1437 if (!I->isPowerOf2()) {
1438 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
1444 Diag(CI.
getLoc(), diag::warn_assume_aligned_too_great)
1449 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1466 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
1472 const auto *FuncDecl = cast<FunctionDecl>(
D);
1482 << FuncDecl->getParamDecl(Idx.
getASTIndex())->getSourceRange();
1492 if (AttrName.size() > 4 && AttrName.starts_with(
"__") &&
1493 AttrName.ends_with(
"__")) {
1494 AttrName = AttrName.drop_front(2).drop_back(2);
1510 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
1516 OwnershipAttr::OwnershipKind K =
1517 OwnershipAttr(S.
Context, AL,
nullptr,
nullptr, 0).getOwnKind();
1521 case OwnershipAttr::Takes:
1522 case OwnershipAttr::Holds:
1524 S.
Diag(AL.
getLoc(), diag::err_attribute_too_few_arguments) << AL << 2;
1528 case OwnershipAttr::Returns:
1530 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 1;
1538 if (K == OwnershipAttr::Returns &&
1540 S.
Diag(AL.
getLoc(), diag::err_ownership_takes_return_type) << AL;
1546 StringRef ModuleName =
Module->getName();
1552 for (
unsigned i = 1; i < AL.
getNumArgs(); ++i) {
1562 case OwnershipAttr::Takes:
1563 case OwnershipAttr::Holds:
1567 case OwnershipAttr::Returns:
1573 S.
Diag(AL.
getLoc(), diag::err_ownership_type) << AL << Err
1582 if (I->getOwnKind() != K && llvm::is_contained(I->args(), Idx)) {
1583 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
1586 I->isRegularKeywordAttribute());
1588 }
else if (K == OwnershipAttr::Returns &&
1589 I->getOwnKind() == OwnershipAttr::Returns) {
1592 if (!llvm::is_contained(I->args(), Idx)) {
1593 S.
Diag(I->getLocation(), diag::err_ownership_returns_index_mismatch)
1594 << I->args_begin()->getSourceIndex();
1596 S.
Diag(AL.
getLoc(), diag::note_ownership_returns_index_mismatch)
1600 }
else if (K == OwnershipAttr::Takes &&
1601 I->getOwnKind() == OwnershipAttr::Takes) {
1602 if (I->getModule()->getName() != ModuleName) {
1603 S.
Diag(I->getLocation(), diag::err_ownership_takes_class_mismatch)
1604 << I->getModule()->getName();
1605 S.
Diag(AL.
getLoc(), diag::note_ownership_takes_class_mismatch)
1612 OwnershipArgs.push_back(Idx);
1615 ParamIdx *Start = OwnershipArgs.data();
1616 unsigned Size = OwnershipArgs.size();
1617 llvm::array_pod_sort(Start, Start + Size);
1625 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
1640 if (!Ctx->isFileContext()) {
1641 S.
Diag(AL.
getLoc(), diag::err_attribute_weakref_not_global_context)
1642 << cast<NamedDecl>(
D);
1686 std::unique_ptr<char, llvm::FreeDeleter> Demangled;
1688 Demangled.reset(llvm::itaniumDemangle(Str,
false));
1697 if (!isa<FunctionDecl>(ND) && !isa<VarDecl>(ND))
1699 if (MC->shouldMangleDeclName(ND)) {
1700 llvm::raw_svector_ostream Out(Name);
1704 Name = ND->getIdentifier()->getName();
1718 const auto *FD = cast<FunctionDecl>(
D);
1720 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << FD << 1;
1734 S.
Diag(AL.
getLoc(), diag::err_alias_not_supported_on_darwin);
1742 S.
Diag(AL.
getLoc(), diag::err_alias_not_supported_on_nvptx);
1746 if (
const auto *FD = dyn_cast<FunctionDecl>(
D)) {
1748 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << FD << 0;
1752 const auto *VD = cast<VarDecl>(
D);
1753 if (VD->isThisDeclarationADefinition() && VD->isExternallyVisible()) {
1754 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << VD << 0;
1771 if (Model !=
"global-dynamic" && Model !=
"local-dynamic"
1772 && Model !=
"initial-exec" && Model !=
"local-exec") {
1773 S.
Diag(LiteralLoc, diag::err_attr_tlsmodel_arg);
1787 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only)
1795 if (checkAttrMutualExclusion<CPUSpecificAttr>(S,
D, AL))
1799 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
1800 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
1803 }
else if (AL.
getParsedKind() == ParsedAttr::AT_CPUSpecific) {
1804 if (checkAttrMutualExclusion<CPUDispatchAttr>(S,
D, AL))
1808 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
1809 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
1816 if (
const auto *MD = dyn_cast<CXXMethodDecl>(
D)) {
1817 if (MD->getParent()->isLambda()) {
1818 S.
Diag(AL.
getLoc(), diag::err_attribute_dll_lambda) << AL;
1829 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1838 S.
Diag(CPUArg->
Loc, diag::err_invalid_cpu_specific_dispatch_value)
1839 << CPUName << (AL.
getKind() == ParsedAttr::AT_CPUDispatch);
1845 return Target.CPUSpecificManglingCharacter(CPUName) ==
1848 S.
Diag(AL.
getLoc(), diag::warn_multiversion_duplicate_entries);
1851 CPUs.push_back(CPUArg->
Ident);
1855 if (AL.
getKind() == ParsedAttr::AT_CPUSpecific)
1857 CPUSpecificAttr(S.
Context, AL, CPUs.data(), CPUs.size()));
1860 CPUDispatchAttr(S.
Context, AL, CPUs.data(), CPUs.size()));
1865 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
1876 const auto &Arch = Triple.getArch();
1877 if (Arch != llvm::Triple::x86 &&
1878 (Arch != llvm::Triple::arm && Arch != llvm::Triple::thumb)) {
1879 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_on_arch)
1880 << AL << Triple.getArchName();
1886 if (S.
getLangOpts().MSVCCompat && isa<CXXMethodDecl>(
D)) {
1887 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_decl_type)
1899 if (!isa<ObjCMethodDecl>(
D)) {
1900 S.
Diag(Attrs.
getLoc(), diag::warn_attribute_wrong_decl_type)
1926 S.
Diag(Attrs.
getLoc(), diag::warn_nocf_check_attribute_ignored);
1928 handleSimpleAttribute<AnyX86NoCfCheckAttr>(S,
D, Attrs);
1944 ? diag::err_keyword_not_supported_on_target
1945 : diag::warn_unknown_attribute_ignored)
1963 ? diag::err_attribute_wrong_decl_type
1964 : diag::warn_attribute_wrong_decl_type)
2000 if (VecReturnAttr *A =
D->
getAttr<VecReturnAttr>()) {
2001 S.
Diag(AL.
getLoc(), diag::err_repeat_attribute) << A;
2005 const auto *R = cast<RecordDecl>(
D);
2008 if (!isa<CXXRecordDecl>(R)) {
2009 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
2013 if (!cast<CXXRecordDecl>(R)->isPOD()) {
2014 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_pod_record);
2018 for (
const auto *I : R->fields()) {
2019 if ((count == 1) || !I->getType()->isVectorType()) {
2020 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
2031 if (isa<ParmVarDecl>(
D)) {
2036 diag::err_carries_dependency_param_not_function_decl);
2050 S.
Diag(AL.
getLoc(), diag::ext_cxx17_attr) << AL;
2056 uint32_t priority = ConstructorAttr::DefaultPriority;
2058 S.
Diag(AL.
getLoc(), diag::err_hlsl_init_priority_unsupported);
2069 uint32_t priority = DestructorAttr::DefaultPriority;
2077template <
typename AttrTy>
2089 VersionTuple Introduced,
2090 VersionTuple Deprecated,
2091 VersionTuple Obsoleted) {
2092 StringRef PlatformName
2093 = AvailabilityAttr::getPrettyPlatformName(Platform->
getName());
2094 if (PlatformName.empty())
2095 PlatformName = Platform->
getName();
2099 if (!Introduced.empty() && !Deprecated.empty() &&
2100 !(Introduced <= Deprecated)) {
2102 << 1 << PlatformName << Deprecated.getAsString()
2103 << 0 << Introduced.getAsString();
2107 if (!Introduced.empty() && !Obsoleted.empty() &&
2108 !(Introduced <= Obsoleted)) {
2110 << 2 << PlatformName << Obsoleted.getAsString()
2111 << 0 << Introduced.getAsString();
2115 if (!Deprecated.empty() && !Obsoleted.empty() &&
2116 !(Deprecated <= Obsoleted)) {
2118 << 2 << PlatformName << Obsoleted.getAsString()
2119 << 1 << Deprecated.getAsString();
2131 bool BeforeIsOkay) {
2132 if (
X.empty() || Y.empty())
2138 if (BeforeIsOkay &&
X < Y)
2146 bool Implicit, VersionTuple Introduced, VersionTuple Deprecated,
2147 VersionTuple Obsoleted,
bool IsUnavailable, StringRef Message,
2150 VersionTuple MergedIntroduced = Introduced;
2151 VersionTuple MergedDeprecated = Deprecated;
2152 VersionTuple MergedObsoleted = Obsoleted;
2153 bool FoundAny =
false;
2154 bool OverrideOrImpl =
false;
2158 OverrideOrImpl =
false;
2164 OverrideOrImpl =
true;
2170 for (
unsigned i = 0, e = Attrs.size(); i != e;) {
2171 const auto *OldAA = dyn_cast<AvailabilityAttr>(Attrs[i]);
2178 if (OldPlatform != Platform) {
2184 if (OldEnvironment != Environment) {
2192 if (OldAA->getPriority() <
Priority)
2198 if (OldAA->getPriority() >
Priority) {
2199 Attrs.erase(Attrs.begin() + i);
2205 VersionTuple OldIntroduced = OldAA->getIntroduced();
2206 VersionTuple OldDeprecated = OldAA->getDeprecated();
2207 VersionTuple OldObsoleted = OldAA->getObsoleted();
2208 bool OldIsUnavailable = OldAA->getUnavailable();
2210 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl) ||
2211 !
versionsMatch(Deprecated, OldDeprecated, OverrideOrImpl) ||
2213 !(OldIsUnavailable == IsUnavailable ||
2214 (OverrideOrImpl && !OldIsUnavailable && IsUnavailable))) {
2215 if (OverrideOrImpl) {
2217 VersionTuple FirstVersion;
2218 VersionTuple SecondVersion;
2219 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl)) {
2221 FirstVersion = OldIntroduced;
2222 SecondVersion = Introduced;
2223 }
else if (!
versionsMatch(Deprecated, OldDeprecated, OverrideOrImpl)) {
2225 FirstVersion = Deprecated;
2226 SecondVersion = OldDeprecated;
2227 }
else if (!
versionsMatch(Obsoleted, OldObsoleted, OverrideOrImpl)) {
2229 FirstVersion = Obsoleted;
2230 SecondVersion = OldObsoleted;
2234 Diag(OldAA->getLocation(),
2235 diag::warn_mismatched_availability_override_unavail)
2236 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2247 Diag(OldAA->getLocation(),
2248 diag::warn_mismatched_availability_override)
2250 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2251 << FirstVersion.getAsString() << SecondVersion.getAsString()
2255 Diag(CI.
getLoc(), diag::note_overridden_method);
2257 Diag(CI.
getLoc(), diag::note_protocol_method);
2259 Diag(OldAA->getLocation(), diag::warn_mismatched_availability);
2260 Diag(CI.
getLoc(), diag::note_previous_attribute);
2263 Attrs.erase(Attrs.begin() + i);
2268 VersionTuple MergedIntroduced2 = MergedIntroduced;
2269 VersionTuple MergedDeprecated2 = MergedDeprecated;
2270 VersionTuple MergedObsoleted2 = MergedObsoleted;
2272 if (MergedIntroduced2.empty())
2273 MergedIntroduced2 = OldIntroduced;
2274 if (MergedDeprecated2.empty())
2275 MergedDeprecated2 = OldDeprecated;
2276 if (MergedObsoleted2.empty())
2277 MergedObsoleted2 = OldObsoleted;
2280 MergedIntroduced2, MergedDeprecated2,
2281 MergedObsoleted2)) {
2282 Attrs.erase(Attrs.begin() + i);
2287 MergedIntroduced = MergedIntroduced2;
2288 MergedDeprecated = MergedDeprecated2;
2289 MergedObsoleted = MergedObsoleted2;
2295 MergedIntroduced == Introduced &&
2296 MergedDeprecated == Deprecated &&
2297 MergedObsoleted == Obsoleted)
2303 MergedDeprecated, MergedObsoleted) &&
2305 auto *Avail = ::new (
Context) AvailabilityAttr(
2306 Context, CI, Platform, Introduced, Deprecated, Obsoleted, IsUnavailable,
2307 Message, IsStrict, Replacement,
Priority, Environment);
2315 if (isa<UsingDecl, UnresolvedUsingTypenameDecl, UnresolvedUsingValueDecl>(
2327 if (AvailabilityAttr::getPrettyPlatformName(II->
getName()).empty())
2328 S.
Diag(Platform->
Loc, diag::warn_availability_unknown_platform)
2331 auto *ND = dyn_cast<NamedDecl>(
D);
2341 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getMessageExpr()))
2342 Str = SE->getString();
2343 StringRef Replacement;
2344 if (
const auto *SE =
2346 Replacement = SE->getString();
2348 if (II->
isStr(
"swift")) {
2350 (!IsUnavailable && !Deprecated.
isValid())) {
2352 diag::warn_availability_swift_unavailable_deprecated_only);
2357 if (II->
isStr(
"fuchsia")) {
2358 std::optional<unsigned>
Min, Sub;
2360 (Sub = Introduced.
Version.getSubminor())) {
2361 S.
Diag(AL.
getLoc(), diag::warn_availability_fuchsia_unavailable_minor);
2376 if (EnvironmentLoc) {
2378 IIEnvironment = EnvironmentLoc->
Ident;
2379 if (AvailabilityAttr::getEnvironmentType(
2381 llvm::Triple::EnvironmentType::UnknownEnvironment)
2382 S.
Diag(EnvironmentLoc->
Loc, diag::warn_availability_unknown_environment)
2383 << EnvironmentLoc->
Ident;
2385 S.
Diag(EnvironmentLoc->
Loc, diag::err_availability_unexpected_parameter)
2386 <<
"environment" << 1;
2392 Obsoleted.
Version, IsUnavailable, Str, IsStrict, Replacement,
2403 else if (II->
getName() ==
"ios_app_extension")
2408 const auto *IOSToWatchOSMapping =
2413 auto adjustWatchOSVersion =
2414 [IOSToWatchOSMapping](VersionTuple Version) -> VersionTuple {
2415 if (Version.empty())
2417 auto MinimumWatchOSVersion = VersionTuple(2, 0);
2419 if (IOSToWatchOSMapping) {
2420 if (
auto MappedVersion = IOSToWatchOSMapping->map(
2421 Version, MinimumWatchOSVersion, std::nullopt)) {
2422 return *MappedVersion;
2426 auto Major = Version.getMajor();
2427 auto NewMajor = Major >= 9 ? Major - 7 : 0;
2428 if (NewMajor >= 2) {
2429 if (Version.getMinor()) {
2430 if (Version.getSubminor())
2431 return VersionTuple(NewMajor, *Version.getMinor(),
2432 *Version.getSubminor());
2434 return VersionTuple(NewMajor, *Version.getMinor());
2436 return VersionTuple(NewMajor);
2439 return MinimumWatchOSVersion;
2442 auto NewIntroduced = adjustWatchOSVersion(Introduced.
Version);
2443 auto NewDeprecated = adjustWatchOSVersion(Deprecated.
Version);
2444 auto NewObsoleted = adjustWatchOSVersion(Obsoleted.
Version);
2447 ND, AL, NewII,
true , NewIntroduced, NewDeprecated,
2448 NewObsoleted, IsUnavailable, Str, IsStrict, Replacement,
2460 else if (II->
getName() ==
"ios_app_extension")
2465 const auto *IOSToTvOSMapping =
2470 auto AdjustTvOSVersion =
2471 [IOSToTvOSMapping](VersionTuple Version) -> VersionTuple {
2472 if (Version.empty())
2475 if (IOSToTvOSMapping) {
2476 if (
auto MappedVersion = IOSToTvOSMapping->map(
2477 Version, VersionTuple(0, 0), std::nullopt)) {
2478 return *MappedVersion;
2484 auto NewIntroduced = AdjustTvOSVersion(Introduced.
Version);
2485 auto NewDeprecated = AdjustTvOSVersion(Deprecated.
Version);
2486 auto NewObsoleted = AdjustTvOSVersion(Obsoleted.
Version);
2489 ND, AL, NewII,
true , NewIntroduced, NewDeprecated,
2490 NewObsoleted, IsUnavailable, Str, IsStrict, Replacement,
2497 llvm::Triple::IOS &&
2499 auto GetSDKInfo = [&]() {
2508 else if (II->
getName() ==
"ios_app_extension")
2511 auto MinMacCatalystVersion = [](
const VersionTuple &
V) {
2514 if (
V.getMajor() < 13 ||
2515 (
V.getMajor() == 13 &&
V.getMinor() && *
V.getMinor() < 1))
2516 return VersionTuple(13, 1);
2520 ND, AL, NewII,
true ,
2521 MinMacCatalystVersion(Introduced.
Version),
2522 MinMacCatalystVersion(Deprecated.
Version),
2523 MinMacCatalystVersion(Obsoleted.
Version), IsUnavailable, Str,
2528 }
else if (II->
getName() ==
"macos" && GetSDKInfo() &&
2530 !Obsoleted.
Version.empty())) {
2531 if (
const auto *MacOStoMacCatalystMapping =
2532 GetSDKInfo()->getVersionMapping(
2539 auto RemapMacOSVersion =
2540 [&](
const VersionTuple &
V) -> std::optional<VersionTuple> {
2542 return std::nullopt;
2544 if (
V.getMajor() == 100000)
2545 return VersionTuple(100000);
2547 return MacOStoMacCatalystMapping->map(
V, VersionTuple(13, 1),
2550 std::optional<VersionTuple> NewIntroduced =
2551 RemapMacOSVersion(Introduced.
Version),
2553 RemapMacOSVersion(Deprecated.
Version),
2555 RemapMacOSVersion(Obsoleted.
Version);
2556 if (NewIntroduced || NewDeprecated || NewObsoleted) {
2557 auto VersionOrEmptyVersion =
2558 [](
const std::optional<VersionTuple> &
V) -> VersionTuple {
2559 return V ? *
V : VersionTuple();
2562 ND, AL, NewII,
true ,
2563 VersionOrEmptyVersion(NewIntroduced),
2564 VersionOrEmptyVersion(NewDeprecated),
2565 VersionOrEmptyVersion(NewObsoleted),
false, Str,
2584 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(0)))
2586 StringRef DefinedIn;
2587 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(1)))
2588 DefinedIn = SE->getString();
2589 bool IsGeneratedDeclaration = AL.
getArgAsIdent(2) !=
nullptr;
2591 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(3)))
2592 USR = SE->getString();
2600 typename T::VisibilityType value) {
2603 typename T::VisibilityType existingValue = existingAttr->
getVisibility();
2604 if (existingValue == value)
2606 S.
Diag(existingAttr->getLocation(), diag::err_mismatched_visibility);
2607 S.
Diag(CI.
getLoc(), diag::note_previous_attribute);
2615 VisibilityAttr::VisibilityType Vis) {
2616 return ::mergeVisibilityAttr<VisibilityAttr>(*
this,
D, CI, Vis);
2621 TypeVisibilityAttr::VisibilityType Vis) {
2622 return ::mergeVisibilityAttr<TypeVisibilityAttr>(*
this,
D, CI, Vis);
2626 bool isTypeVisibility) {
2628 if (isa<TypedefNameDecl>(
D)) {
2634 if (isTypeVisibility && !(isa<TagDecl>(
D) || isa<ObjCInterfaceDecl>(
D) ||
2635 isa<NamespaceDecl>(
D))) {
2647 VisibilityAttr::VisibilityType
type;
2648 if (!VisibilityAttr::ConvertStrToVisibilityType(TypeStr,
type)) {
2649 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported) << AL
2656 if (
type == VisibilityAttr::Protected &&
2658 S.
Diag(AL.
getLoc(), diag::warn_attribute_protected_visibility);
2659 type = VisibilityAttr::Default;
2663 if (isTypeVisibility) {
2665 D, AL, (TypeVisibilityAttr::VisibilityType)
type);
2674 unsigned sentinel = (
unsigned)SentinelAttr::DefaultSentinel;
2677 std::optional<llvm::APSInt> Idx = llvm::APSInt(32);
2679 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
2684 if (Idx->isSigned() && Idx->isNegative()) {
2685 S.
Diag(AL.
getLoc(), diag::err_attribute_sentinel_less_than_zero)
2690 sentinel = Idx->getZExtValue();
2693 unsigned nullPos = (
unsigned)SentinelAttr::DefaultNullPos;
2696 std::optional<llvm::APSInt> Idx = llvm::APSInt(32);
2698 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
2702 nullPos = Idx->getZExtValue();
2704 if ((Idx->isSigned() && Idx->isNegative()) || nullPos > 1) {
2707 S.
Diag(AL.
getLoc(), diag::err_attribute_sentinel_not_zero_or_one)
2713 if (
const auto *FD = dyn_cast<FunctionDecl>(
D)) {
2715 if (isa<FunctionNoProtoType>(FT)) {
2716 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_named_arguments);
2720 if (!cast<FunctionProtoType>(FT)->isVariadic()) {
2721 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
2724 }
else if (
const auto *MD = dyn_cast<ObjCMethodDecl>(
D)) {
2725 if (!MD->isVariadic()) {
2726 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
2729 }
else if (
const auto *BD = dyn_cast<BlockDecl>(
D)) {
2730 if (!BD->isVariadic()) {
2731 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 1;
2734 }
else if (
const auto *
V = dyn_cast<VarDecl>(
D)) {
2742 if (!cast<FunctionProtoType>(FT)->isVariadic()) {
2744 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << m;
2748 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
2754 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
2765 !isa<CXXConstructorDecl>(
D)) {
2766 S.
Diag(AL.
getLoc(), diag::warn_attribute_void_function_method) << AL << 0;
2769 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(
D))
2770 if (MD->getReturnType()->isVoidType()) {
2771 S.
Diag(AL.
getLoc(), diag::warn_attribute_void_function_method) << AL << 1;
2779 if (isa<VarDecl>(
D))
2780 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
2791 if (LO.CPlusPlus && !LO.CPlusPlus20)
2792 S.
Diag(AL.
getLoc(), diag::ext_cxx20_attr) << AL;
2800 }
else if (LO.CPlusPlus && !LO.CPlusPlus17)
2801 S.
Diag(AL.
getLoc(), diag::ext_cxx17_attr) << AL;
2806 isa<TypedefNameDecl>(
D)) {
2807 S.
Diag(AL.
getLoc(), diag::warn_unused_result_typedef_unsupported_spelling)
2820 S.
Diag(AL.
getLoc(), diag::warn_attribute_invalid_on_definition)
2822 else if (isa<ObjCPropertyDecl>(
D) || isa<ObjCMethodDecl>(
D) ||
2824 (isa<ObjCInterfaceDecl>(
D) || isa<EnumDecl>(
D)))) {
2827 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
2837template <
typename WorkGroupAttr>
2840 for (
unsigned i = 0; i < 3; ++i) {
2845 if (WGSize[i] == 0) {
2846 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_is_zero)
2852 WorkGroupAttr *Existing =
D->
getAttr<WorkGroupAttr>();
2853 if (Existing && !(Existing->getXDim() == WGSize[0] &&
2854 Existing->getYDim() == WGSize[1] &&
2855 Existing->getZDim() == WGSize[2]))
2856 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
2859 WorkGroupAttr(S.
Context, AL, WGSize[0], WGSize[1], WGSize[2]));
2864 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
2870 assert(ParmTSI &&
"no type source info for attribute argument");
2875 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_argument) << 2 << AL;
2879 if (VecTypeHintAttr *A =
D->
getAttr<VecTypeHintAttr>()) {
2881 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
2893 if (
const auto *FD = dyn_cast<FunctionDecl>(
D)) {
2898 if (SectionAttr *ExistingAttr =
D->
getAttr<SectionAttr>()) {
2899 if (ExistingAttr->getName() == Name)
2901 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section)
2903 Diag(CI.
getLoc(), diag::note_previous_attribute);
2911 return llvm::Error::success();
2914 StringRef Segment, Section;
2915 unsigned TAA, StubSize;
2917 return llvm::MCSectionMachO::ParseSectionSpecifier(SecName, Segment, Section,
2918 TAA, HasTAA, StubSize);
2923 Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
2948 cast<NamedDecl>(
D));
2959 llvm::CodeModel::Model CM;
2960 if (!CodeModelAttr::ConvertStrToModel(Str, CM)) {
2961 S.
Diag(LiteralLoc, diag::err_attr_codemodel_arg) << Str;
2971 StringRef CodeSegName) {
2973 S.
Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
2985 if (
const auto *FD = dyn_cast<FunctionDecl>(
D)) {
2989 if (
const auto *ExistingAttr =
D->
getAttr<CodeSegAttr>()) {
2990 if (ExistingAttr->getName() == Name)
2992 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section)
2994 Diag(CI.
getLoc(), diag::note_previous_attribute);
3007 if (
const auto *ExistingAttr =
D->
getAttr<CodeSegAttr>()) {
3008 if (!ExistingAttr->isImplicit()) {
3010 ExistingAttr->getName() == Str
3011 ? diag::warn_duplicate_codeseg_attribute
3012 : diag::err_conflicting_codeseg_attribute);
3022 enum FirstParam { Unsupported, Duplicate,
Unknown };
3023 enum SecondParam {
None, CPU, Tune };
3025 if (AttrStr.contains(
"fpmath="))
3026 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3027 << Unsupported <<
None <<
"fpmath=" <<
Target;
3031 AttrStr.contains(
"tune="))
3032 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3038 if (!ParsedAttrs.
CPU.empty() &&
3040 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3043 if (!ParsedAttrs.
Tune.empty() &&
3045 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3050 return Diag(LiteralLoc, diag::err_duplicate_target_attribute)
3052 for (
const auto &Feature : ParsedAttrs.
Features) {
3053 StringRef CurFeature = Feature;
3054 if (!CurFeature.starts_with(
'+') && !CurFeature.starts_with(
'-'))
3055 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3061 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3064 for (
const auto &Feature : ParsedAttrs.
Features) {
3065 auto CurFeature = StringRef(Feature).drop_front();
3067 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3068 << Unsupported <<
None << CurFeature <<
Target;
3077 if (DiagMsg.empty())
3078 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3079 << Unsupported <<
None <<
"branch-protection" <<
Target;
3080 return Diag(LiteralLoc, diag::err_invalid_branch_protection_spec)
3083 if (!DiagMsg.empty())
3084 Diag(LiteralLoc, diag::warn_unsupported_branch_protection_spec) << DiagMsg;
3090 StringRef AttrStr) {
3091 enum FirstParam { Unsupported };
3092 enum SecondParam {
None };
3097 AttrStr.split(AttrStrs,
';');
3099 bool HasArch =
false;
3100 bool HasPriority =
false;
3101 bool HasDefault =
false;
3102 bool DuplicateAttr =
false;
3103 for (
auto &AttrStr : AttrStrs) {
3105 if (AttrStr.starts_with(
"arch=+")) {
3107 DuplicateAttr =
true;
3113 llvm::any_of(TargetAttr.
Features, [&](
const StringRef Ext) {
3114 return !RISCV().isValidFMVExtension(Ext);
3116 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3118 }
else if (AttrStr.starts_with(
"default")) {
3120 DuplicateAttr =
true;
3122 }
else if (AttrStr.consume_front(
"priority=")) {
3124 DuplicateAttr =
true;
3127 if (AttrStr.getAsInteger(0, Digit))
3128 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3131 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3136 if (((HasPriority || HasArch) && HasDefault) || DuplicateAttr ||
3137 (HasPriority && !HasArch))
3138 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3143 AttrStr.split(Features,
"+");
3144 for (
auto &CurFeature : Features) {
3145 CurFeature = CurFeature.trim();
3146 if (CurFeature ==
"default")
3149 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3161 TargetVersionAttr *NewAttr =
3173 TargetAttr *NewAttr = ::new (S.
Context) TargetAttr(S.
Context, AL, Str);
3179 Decl *
D,
bool &HasDefault,
bool &HasCommas,
bool &HasNotDefault,
3181 enum FirstParam { Unsupported, Duplicate,
Unknown };
3182 enum SecondParam {
None, CPU, Tune };
3184 HasCommas = HasCommas || Str.contains(
',');
3187 if (Str.size() == 0)
3188 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3191 std::pair<StringRef, StringRef> Parts = {{}, Str};
3192 while (!Parts.second.empty()) {
3193 Parts = Parts.second.split(
',');
3194 StringRef Cur = Parts.first.trim();
3196 Literal->getLocationOfByte(Cur.data() - Literal->getString().data(),
3199 bool DefaultIsDupe =
false;
3200 bool HasCodeGenImpact =
false;
3202 return Diag(CurLoc, diag::warn_unsupported_target_attribute)
3207 if (Cur ==
"default") {
3208 DefaultIsDupe = HasDefault;
3210 if (llvm::is_contained(StringsBuffer, Cur) || DefaultIsDupe)
3211 Diag(CurLoc, diag::warn_target_clone_duplicate_options);
3213 StringsBuffer.push_back(Cur);
3215 std::pair<StringRef, StringRef> CurParts = {{}, Cur};
3217 while (!CurParts.second.empty()) {
3218 CurParts = CurParts.second.split(
'+');
3219 StringRef CurFeature = CurParts.first.trim();
3221 Diag(CurLoc, diag::warn_unsupported_target_attribute)
3226 HasCodeGenImpact =
true;
3227 CurFeatures.push_back(CurFeature);
3230 llvm::sort(CurFeatures);
3232 for (
auto &CurFeat : CurFeatures) {
3235 Res.append(CurFeat);
3237 if (llvm::is_contained(StringsBuffer, Res) || DefaultIsDupe)
3238 Diag(CurLoc, diag::warn_target_clone_duplicate_options);
3239 else if (!HasCodeGenImpact)
3242 Diag(CurLoc, diag::warn_target_clone_no_impact_options);
3243 else if (!Res.empty()) {
3244 StringsBuffer.push_back(Res);
3245 HasNotDefault =
true;
3248 }
else if (TInfo.
getTriple().isRISCV()) {
3254 if (!Str.starts_with(Cur))
3258 Str.split(AttrStrs,
";");
3260 bool IsPriority =
false;
3261 bool IsDefault =
false;
3262 for (
auto &AttrStr : AttrStrs) {
3264 if (AttrStr.starts_with(
"arch=+")) {
3269 llvm::any_of(TargetAttr.
Features, [&](
const StringRef Ext) {
3270 return !RISCV().isValidFMVExtension(Ext);
3272 return Diag(CurLoc, diag::warn_unsupported_target_attribute)
3274 }
else if (AttrStr.starts_with(
"default")) {
3276 DefaultIsDupe = HasDefault;
3278 }
else if (AttrStr.consume_front(
"priority=")) {
3281 if (AttrStr.getAsInteger(0, Digit))
3282 return Diag(CurLoc, diag::warn_unsupported_target_attribute)
3285 return Diag(CurLoc, diag::warn_unsupported_target_attribute)
3290 if (IsPriority && IsDefault)
3291 return Diag(CurLoc, diag::warn_unsupported_target_attribute)
3294 if (llvm::is_contained(StringsBuffer, Str) || DefaultIsDupe)
3295 Diag(CurLoc, diag::warn_target_clone_duplicate_options);
3296 StringsBuffer.push_back(Str);
3299 if (Cur.starts_with(
"arch=")) {
3301 Cur.drop_front(
sizeof(
"arch=") - 1)))
3302 return Diag(CurLoc, diag::warn_unsupported_target_attribute)
3303 << Unsupported << CPU << Cur.drop_front(
sizeof(
"arch=") - 1)
3305 }
else if (Cur ==
"default") {
3306 DefaultIsDupe = HasDefault;
3310 return Diag(CurLoc, diag::warn_unsupported_target_attribute)
3312 if (llvm::is_contained(StringsBuffer, Cur) || DefaultIsDupe)
3313 Diag(CurLoc, diag::warn_target_clone_duplicate_options);
3315 StringsBuffer.push_back(Cur);
3318 if (Str.rtrim().ends_with(
","))
3319 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3332 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
3333 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
3336 if (checkAttrMutualExclusion<TargetClonesAttr>(S,
D, AL))
3341 bool HasCommas =
false, HasDefault =
false, HasNotDefault =
false;
3343 for (
unsigned I = 0,
E = AL.
getNumArgs(); I !=
E; ++I) {
3350 HasDefault, HasCommas, HasNotDefault, StringsBuffer))
3353 for (
auto &SmallStr : StringsBuffer)
3354 Strings.push_back(SmallStr.str());
3357 S.
Diag(AL.
getLoc(), diag::warn_target_clone_mixed_values);
3362 Strings.push_back(
"default");
3366 S.
Diag(AL.
getLoc(), diag::err_target_clone_must_have_default);
3372 if (
const auto *MD = dyn_cast<CXXMethodDecl>(
D)) {
3373 if (MD->getParent()->isLambda()) {
3385 cast<FunctionDecl>(
D)->setIsMultiVersion();
3386 TargetClonesAttr *NewAttr = ::new (S.
Context)
3387 TargetClonesAttr(S.
Context, AL, Strings.data(), Strings.size());
3399 MinVectorWidthAttr *Existing =
D->
getAttr<MinVectorWidthAttr>();
3400 if (Existing && Existing->getVectorWidth() != VecWidth) {
3401 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3416 if (
auto *DRE = dyn_cast<DeclRefExpr>(
E)) {
3418 S.
Diag(
Loc, diag::warn_cleanup_ext);
3419 FD = dyn_cast<FunctionDecl>(DRE->
getDecl());
3422 S.
Diag(
Loc, diag::err_attribute_cleanup_arg_not_function) << 1
3426 }
else if (
auto *ULE = dyn_cast<UnresolvedLookupExpr>(
E)) {
3427 if (ULE->hasExplicitTemplateArgs())
3428 S.
Diag(
Loc, diag::warn_cleanup_ext);
3430 NI = ULE->getNameInfo();
3432 S.
Diag(
Loc, diag::err_attribute_cleanup_arg_not_function) << 2
3439 S.
Diag(
Loc, diag::err_attribute_cleanup_arg_not_function) << 0;
3444 S.
Diag(
Loc, diag::err_attribute_cleanup_func_must_take_one_arg)
3455 S.
Diag(
Loc, diag::err_attribute_cleanup_func_arg_incompatible_type)
3456 << NI.
getName() << ParamTy << Ty;
3470 S.
Context, VariableReference, UnaryOperatorKind::UO_AddrOf,
3490 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3495 EnumExtensibilityAttr::Kind ExtensibilityKind;
3497 if (!EnumExtensibilityAttr::ConvertStrToKind(II->
getName(),
3498 ExtensibilityKind)) {
3499 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
3504 EnumExtensibilityAttr(S.
Context, AL, ExtensibilityKind));
3522 S.
Diag(AL.
getLoc(), diag::err_format_attribute_not)
3530 if (
auto *OMD = dyn_cast<ObjCMethodDecl>(
D))
3531 if (
auto *
Interface = OMD->getClassInterface())
3538 S.
Diag(AL.
getLoc(), diag::err_format_attribute_result_not)
3539 << (NotNSStringTy ?
"string type" :
"NSString")
3559 return llvm::StringSwitch<FormatAttrKind>(Format)
3573 .Cases(
"gcc_diag",
"gcc_cdiag",
"gcc_cxxdiag",
"gcc_tdiag",
IgnoredFormat)
3581 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored) << AL;
3586 S.
Diag(AL.
getLoc(), diag::err_hlsl_init_priority_unsupported);
3591 S.
Diag(AL.
getLoc(), diag::err_init_priority_object_attr);
3599 S.
Diag(AL.
getLoc(), diag::err_init_priority_object_attr);
3605 uint32_t prioritynum;
3614 if ((prioritynum < 101 || prioritynum > 65535) &&
3616 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_range)
3625 StringRef NewUserDiagnostic) {
3626 if (
const auto *EA =
D->
getAttr<ErrorAttr>()) {
3628 assert((NewAttr ==
"error" || NewAttr ==
"warning") &&
3629 "unexpected normalized full name");
3630 bool Match = (EA->isError() && NewAttr ==
"error") ||
3631 (EA->isWarning() && NewAttr ==
"warning");
3633 Diag(EA->getLocation(), diag::err_attributes_are_not_compatible)
3636 EA->isRegularKeywordAttribute());
3637 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
3640 if (EA->getUserDiagnostic() != NewUserDiagnostic) {
3641 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << EA;
3642 Diag(EA->getLoc(), diag::note_previous_attribute);
3646 return ::new (
Context) ErrorAttr(
Context, CI, NewUserDiagnostic);
3654 if (F->getType() == Format &&
3655 F->getFormatIdx() == FormatIdx &&
3656 F->getFirstArg() == FirstArg) {
3659 if (F->getLocation().isInvalid())
3665 return ::new (
Context) FormatAttr(
Context, CI, Format, FormatIdx, FirstArg);
3672 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3683 StringRef Format = II->
getName();
3697 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
3708 if (Idx < 1 || Idx > NumArgs) {
3709 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
3715 unsigned ArgIdx = Idx - 1;
3717 if (HasImplicitThisParam) {
3720 diag::err_format_attribute_implicit_this_format_string)
3733 S.
Diag(AL.
getLoc(), diag::err_format_attribute_not)
3745 if (FirstArg != 0) {
3749 S.
Diag(AL.
getLoc(), diag::err_format_strftime_third_parameter)
3757 if (FirstArg != NumArgs + 1) {
3758 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
3761 std::to_string(NumArgs + 1));
3767 if (FirstArg <= Idx) {
3771 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
3787 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_no_callee)
3796 assert(FD &&
"Expected a function declaration!");
3798 llvm::StringMap<int> NameIdxMapping;
3799 NameIdxMapping[
"__"] = -1;
3801 NameIdxMapping[
"this"] = 0;
3805 NameIdxMapping[PVD->getName()] = Idx++;
3807 auto UnknownName = NameIdxMapping.end();
3810 for (
unsigned I = 0,
E = AL.
getNumArgs(); I <
E; ++I) {
3816 auto It = NameIdxMapping.find(IdLoc->
Ident->
getName());
3817 if (It == UnknownName) {
3818 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_argument_unknown)
3824 ArgIdx = It->second;
3831 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
3837 if (ArgIdx < -1 || ArgIdx > NumArgs) {
3838 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
3845 llvm_unreachable(
"Unexpected ParsedAttr argument type!");
3848 if (ArgIdx == 0 && !HasImplicitThisParam) {
3849 S.
Diag(AL.
getLoc(), diag::err_callback_implicit_this_not_available)
3856 if (!HasImplicitThisParam && ArgIdx > 0)
3859 EncodingIndices.push_back(ArgIdx);
3862 int CalleeIdx = EncodingIndices.front();
3866 if (CalleeIdx < (
int)HasImplicitThisParam) {
3867 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_invalid_callee)
3874 const Type *CalleeType =
3878 S.
Diag(AL.
getLoc(), diag::err_callback_callee_no_function_type)
3883 const Type *CalleeFnType =
3888 const auto *CalleeFnProtoType = dyn_cast<FunctionProtoType>(CalleeFnType);
3889 if (!CalleeFnProtoType) {
3890 S.
Diag(AL.
getLoc(), diag::err_callback_callee_no_function_type)
3895 if (CalleeFnProtoType->getNumParams() > EncodingIndices.size() - 1) {
3896 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments)
3897 << AL << (
unsigned)(EncodingIndices.size() - 1);
3901 if (CalleeFnProtoType->getNumParams() < EncodingIndices.size() - 1) {
3902 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments)
3903 << AL << (
unsigned)(EncodingIndices.size() - 1);
3907 if (CalleeFnProtoType->isVariadic()) {
3919 S.
Context, AL, EncodingIndices.data(), EncodingIndices.size()));
3923 StringRef ParamName) {
3926 Diag(AL.
getLoc(), diag::err_capture_by_attribute_no_entity)
3935 bool IsValid =
true;
3936 for (
unsigned I = 0; I < N; ++I) {
3939 Diag(
E->
getExprLoc(), diag::err_capture_by_attribute_argument_unknown)
3947 Diag(IdLoc->
Loc, diag::err_capture_by_references_itself) << IdLoc->
Loc;
3951 ParamIdents[I] = IdLoc->
Ident;
3952 ParamLocs[I] = IdLoc->
Loc;
3958 LifetimeCaptureByAttr::Create(
Context, FakeParamIndices.data(), N, AL);
3959 CapturedBy->setArgs(ParamIdents, ParamLocs);
3966 if (
D->
hasAttr<LifetimeCaptureByAttr>()) {
3967 S.
Diag(AL.
getLoc(), diag::err_capture_by_attribute_multiple)
3971 auto *PVD = dyn_cast<ParmVarDecl>(
D);
3982 if (
auto *A = PVD->getAttr<LifetimeCaptureByAttr>())
3984 if (HasImplicitThisParam) {
3992 if (
auto *A = ATL.
getAttrAs<LifetimeCaptureByAttr>())
3993 Attrs.push_back(
const_cast<LifetimeCaptureByAttr *
>(A));
3998 llvm::StringMap<int> NameIdxMapping = {
3999 {
"global", LifetimeCaptureByAttr::GLOBAL},
4000 {
"unknown", LifetimeCaptureByAttr::UNKNOWN}};
4002 if (HasImplicitThisParam) {
4003 NameIdxMapping[
"this"] = 0;
4007 NameIdxMapping[PVD->getName()] = Idx++;
4008 auto DisallowReservedParams = [&](StringRef Reserved) {
4010 if (PVD->getName() == Reserved)
4011 Diag(PVD->getLocation(), diag::err_capture_by_param_uses_reserved_name)
4012 << (PVD->getName() ==
"unknown");
4014 for (
auto *CapturedBy : Attrs) {
4015 const auto &Entities = CapturedBy->getArgIdents();
4016 for (
size_t I = 0; I < Entities.size(); ++I) {
4017 StringRef Name = Entities[I]->getName();
4018 auto It = NameIdxMapping.find(Name);
4019 if (It == NameIdxMapping.end()) {
4020 auto Loc = CapturedBy->getArgLocs()[I];
4021 if (!HasImplicitThisParam && Name ==
"this")
4022 Diag(
Loc, diag::err_capture_by_implicit_this_not_available) <<
Loc;
4024 Diag(
Loc, diag::err_capture_by_attribute_argument_unknown)
4025 << Entities[I] <<
Loc;
4028 if (Name ==
"unknown" || Name ==
"global")
4029 DisallowReservedParams(Name);
4030 CapturedBy->setParamIdx(I, It->second);
4045 QualType T = cast<ParmVarDecl>(
D)->getType();
4048 S.
Diag(AL.
getLoc(), diag::err_called_once_attribute_wrong_type);
4058 const auto *TD = dyn_cast<TypedefNameDecl>(
D);
4059 if (TD && TD->getUnderlyingType()->isUnionType())
4060 RD = TD->getUnderlyingType()->getAsUnionType()->getDecl();
4062 RD = dyn_cast<RecordDecl>(
D);
4065 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
4073 diag::warn_transparent_union_attribute_not_definition);
4079 if (Field == FieldEnd) {
4080 S.
Diag(AL.
getLoc(), diag::warn_transparent_union_attribute_zero_fields);
4088 diag::warn_transparent_union_attribute_floating)
4097 for (; Field != FieldEnd; ++Field) {
4098 QualType FieldType = Field->getType();
4112 S.
Diag(Field->getLocation(),
4113 diag::warn_transparent_union_attribute_field_size_align)
4114 << isSize << *Field << FieldBits;
4115 unsigned FirstBits = isSize ? FirstSize : FirstAlign;
4117 diag::note_transparent_union_first_field_size_align)
4118 << isSize << FirstBits;
4138 AlignValueAttr TmpAttr(
Context, CI,
E);
4142 if (
const auto *TD = dyn_cast<TypedefNameDecl>(
D))
4143 T = TD->getUnderlyingType();
4144 else if (
const auto *VD = dyn_cast<ValueDecl>(
D))
4147 llvm_unreachable(
"Unknown decl type for align_value");
4151 Diag(AttrLoc, diag::warn_attribute_pointer_or_reference_only)
4157 llvm::APSInt Alignment;
4159 E, &Alignment, diag::err_align_value_attribute_argument_not_int);
4163 if (!Alignment.isPowerOf2()) {
4164 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
4186 diag::err_pack_expansion_without_parameter_packs);
4201 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
4213 diag::err_pack_expansion_without_parameter_packs);
4240 const AlignedAttr &
Attr,
4243 if (isa<ParmVarDecl>(
D)) {
4245 }
else if (
const auto *VD = dyn_cast<VarDecl>(
D)) {
4248 if (VD->isExceptionVariable())
4250 }
else if (
const auto *FD = dyn_cast<FieldDecl>(
D)) {
4251 if (FD->isBitField())
4253 }
else if (
const auto *ED = dyn_cast<EnumDecl>(
D)) {
4254 if (ED->getLangOpts().CPlusPlus)
4256 }
else if (!isa<TagDecl>(
D)) {
4257 return S.
Diag(AttrLoc, diag::err_attribute_wrong_decl_type)
4262 if (DiagKind != -1) {
4263 return S.
Diag(AttrLoc, diag::err_alignas_attribute_wrong_decl_type)
4264 << &
Attr << DiagKind;
4270 bool IsPackExpansion) {
4271 AlignedAttr TmpAttr(
Context, CI,
true,
E);
4275 if (TmpAttr.isAlignas() &&
4283 if (
const auto *TND = dyn_cast<TypedefNameDecl>(
D)) {
4284 if (!TND->getUnderlyingType()->isDependentType()) {
4285 Diag(AttrLoc, diag::err_alignment_dependent_typedef_name)
4293 AA->setPackExpansion(IsPackExpansion);
4299 llvm::APSInt Alignment;
4301 E, &Alignment, diag::err_aligned_attribute_argument_not_int);
4309 Diag(AttrLoc, diag::err_attribute_aligned_too_great)
4314 uint64_t AlignVal = Alignment.getZExtValue();
4320 if (!(TmpAttr.isAlignas() && !Alignment)) {
4321 if (!llvm::isPowerOf2_64(AlignVal)) {
4322 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
4328 const auto *VD = dyn_cast<VarDecl>(
D);
4330 unsigned MaxTLSAlign =
4333 if (MaxTLSAlign && AlignVal > MaxTLSAlign &&
4335 Diag(VD->getLocation(), diag::err_tls_var_aligned_over_maximum)
4336 << (
unsigned)AlignVal << VD << MaxTLSAlign;
4344 const Type *Ty = VD->getType().getTypePtr();
4346 Diag(VD->getLocation(), diag::warn_aligned_attr_underaligned)
4347 << VD->getType() << 16;
4353 AA->setPackExpansion(IsPackExpansion);
4354 AA->setCachedAlignmentValue(
4361 AlignedAttr TmpAttr(
Context, CI,
false, TS);
4365 if (TmpAttr.isAlignas() &&
4373 if (
const auto *TND = dyn_cast<TypedefNameDecl>(
D)) {
4374 if (!TND->getUnderlyingType()->isDependentType()) {
4375 Diag(AttrLoc, diag::err_alignment_dependent_typedef_name)
4381 AlignedAttr *AA = ::new (
Context) AlignedAttr(
Context, CI,
false, TS);
4382 AA->setPackExpansion(IsPackExpansion);
4387 const auto *VD = dyn_cast<VarDecl>(
D);
4388 unsigned AlignVal = TmpAttr.getAlignment(
Context);
4392 const Type *Ty = VD->getType().getTypePtr();
4395 Diag(VD->getLocation(), diag::warn_aligned_attr_underaligned)
4396 << VD->getType() << 16;
4401 AlignedAttr *AA = ::new (
Context) AlignedAttr(
Context, CI,
false, TS);
4402 AA->setPackExpansion(IsPackExpansion);
4403 AA->setCachedAlignmentValue(AlignVal);
4408 assert(
D->
hasAttrs() &&
"no attributes on decl");
4411 if (
const auto *VD = dyn_cast<ValueDecl>(
D)) {
4412 UnderlyingTy = DiagTy = VD->getType();
4415 if (
const auto *ED = dyn_cast<EnumDecl>(
D))
4416 UnderlyingTy = ED->getIntegerType();
4425 AlignedAttr *AlignasAttr =
nullptr;
4426 AlignedAttr *LastAlignedAttr =
nullptr;
4429 if (I->isAlignmentDependent())
4433 Align = std::max(Align, I->getAlignment(
Context));
4434 LastAlignedAttr = I;
4438 Diag(LastAlignedAttr->getLocation(), diag::err_attribute_sizeless_type)
4439 << LastAlignedAttr << DiagTy;
4440 }
else if (AlignasAttr && Align) {
4443 if (NaturalAlign > RequestedAlign)
4444 Diag(AlignasAttr->getLocation(), diag::err_alignas_underaligned)
4480 bool &IntegerMode,
bool &ComplexMode,
4483 ComplexMode =
false;
4485 switch (Str.size()) {
4505 DestWidth = Str[1] ==
'I' ? 0 : 128;
4513 DestWidth = Str[1] ==
'I' ? 0 : 128;
4516 if (Str[1] ==
'F') {
4517 IntegerMode =
false;
4518 }
else if (Str[1] ==
'C') {
4519 IntegerMode =
false;
4521 }
else if (Str[1] !=
'I') {
4530 else if (Str ==
"byte")
4534 if (Str ==
"pointer")
4538 if (Str ==
"unwind_word")
4554 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
4566 StringRef Str = Name->getName();
4570 unsigned DestWidth = 0;
4571 bool IntegerMode =
true;
4572 bool ComplexMode =
false;
4574 llvm::APInt VectorSize(64, 0);
4575 if (Str.size() >= 4 && Str[0] ==
'V') {
4577 size_t StrSize = Str.size();
4578 size_t VectorStringLength = 0;
4579 while ((VectorStringLength + 1) < StrSize &&
4580 isdigit(Str[VectorStringLength + 1]))
4581 ++VectorStringLength;
4582 if (VectorStringLength &&
4583 !Str.substr(1, VectorStringLength).getAsInteger(10, VectorSize) &&
4584 VectorSize.isPowerOf2()) {
4586 IntegerMode, ComplexMode, ExplicitType);
4588 if (!InInstantiation)
4589 Diag(AttrLoc, diag::warn_vector_mode_deprecated);
4604 Diag(AttrLoc, diag::err_machine_mode) << 0 << Name;
4609 if (
const auto *TD = dyn_cast<TypedefNameDecl>(
D))
4610 OldTy = TD->getUnderlyingType();
4611 else if (
const auto *ED = dyn_cast<EnumDecl>(
D)) {
4614 OldTy = ED->getIntegerType();
4618 OldTy = cast<ValueDecl>(
D)->getType();
4629 OldElemTy = VT->getElementType();
4635 VectorSize.getBoolValue()) {
4636 Diag(AttrLoc, diag::err_enum_mode_vector_type) << Name << CI.
getRange();
4644 !IntegralOrAnyEnumType)
4645 Diag(AttrLoc, diag::err_mode_not_primitive);
4646 else if (IntegerMode) {
4647 if (!IntegralOrAnyEnumType)
4648 Diag(AttrLoc, diag::err_mode_wrong_type);
4649 }
else if (ComplexMode) {
4651 Diag(AttrLoc, diag::err_mode_wrong_type);
4654 Diag(AttrLoc, diag::err_mode_wrong_type);
4665 if (NewElemTy.
isNull()) {
4667 if (!(DestWidth == 128 &&
getLangOpts().CUDAIsDevice))
4668 Diag(AttrLoc, diag::err_machine_mode) << 1 << Name;
4677 if (VectorSize.getBoolValue()) {
4683 Diag(AttrLoc, diag::err_complex_mode_vector_type);
4687 OldVT->getNumElements() /
4694 Diag(AttrLoc, diag::err_mode_wrong_type);
4699 if (
auto *TD = dyn_cast<TypedefNameDecl>(
D))
4700 TD->setModedTypeSourceInfo(TD->getTypeSourceInfo(), NewTy);
4701 else if (
auto *ED = dyn_cast<EnumDecl>(
D))
4702 ED->setIntegerType(NewTy);
4704 cast<ValueDecl>(
D)->setType(NewTy);
4716 if (OptimizeNoneAttr *Optnone =
D->
getAttr<OptimizeNoneAttr>()) {
4717 Diag(CI.
getLoc(), diag::warn_attribute_ignored) << Ident;
4718 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
4722 if (
D->
hasAttr<AlwaysInlineAttr>())
4730 if (
const auto *VD = dyn_cast<VarDecl>(
D)) {
4733 if (VD->getKind() != Decl::Var) {
4734 Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
4741 if (VD->hasLocalStorage()) {
4742 Diag(VD->getLocation(), diag::warn_internal_linkage_local_storage);
4749InternalLinkageAttr *
4751 if (
const auto *VD = dyn_cast<VarDecl>(
D)) {
4754 if (VD->getKind() != Decl::Var) {
4755 Diag(AL.getLocation(), diag::warn_attribute_wrong_decl_type)
4756 << &AL << AL.isRegularKeywordAttribute()
4762 if (VD->hasLocalStorage()) {
4763 Diag(VD->getLocation(), diag::warn_internal_linkage_local_storage);
4772 if (OptimizeNoneAttr *Optnone =
D->
getAttr<OptimizeNoneAttr>()) {
4773 Diag(CI.
getLoc(), diag::warn_attribute_ignored) <<
"'minsize'";
4774 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
4786 if (AlwaysInlineAttr *Inline =
D->
getAttr<AlwaysInlineAttr>()) {
4787 Diag(Inline->getLocation(), diag::warn_attribute_ignored) << Inline;
4788 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
4791 if (MinSizeAttr *MinSize =
D->
getAttr<MinSizeAttr>()) {
4792 Diag(MinSize->getLocation(), diag::warn_attribute_ignored) << MinSize;
4793 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
4797 if (
D->
hasAttr<OptimizeNoneAttr>())
4804 if (AlwaysInlineAttr *Inline =
4820 const auto *VD = cast<VarDecl>(
D);
4821 if (VD->hasLocalStorage()) {
4822 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
4827 if (
auto *A =
D->
getAttr<CUDAConstantAttr>()) {
4828 if (!A->isImplicit())
4836 const auto *VD = cast<VarDecl>(
D);
4839 if (!S.
getLangOpts().GPURelocatableDeviceCode && VD->hasExternalStorage() &&
4840 !isa<IncompleteArrayType>(VD->getType())) {
4841 S.
Diag(AL.
getLoc(), diag::err_cuda_extern_shared) << VD;
4844 if (S.
getLangOpts().CUDA && VD->hasLocalStorage() &&
4852 const auto *FD = cast<FunctionDecl>(
D);
4863 if (
const auto *Method = dyn_cast<CXXMethodDecl>(FD)) {
4864 if (Method->isInstance()) {
4865 S.
Diag(Method->getBeginLoc(), diag::err_kern_is_nonstatic_method)
4869 S.
Diag(Method->getBeginLoc(), diag::warn_kern_is_method) << Method;
4875 if (AL.
getKind() == ParsedAttr::AT_NVPTXKernel)
4888 if (
const auto *VD = dyn_cast<VarDecl>(
D)) {
4889 if (VD->hasLocalStorage()) {
4890 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
4895 if (
auto *A =
D->
getAttr<CUDADeviceAttr>()) {
4896 if (!A->isImplicit())
4904 if (
const auto *VD = dyn_cast<VarDecl>(
D)) {
4905 if (VD->hasLocalStorage()) {
4906 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
4926 const auto *Fn = cast<FunctionDecl>(
D);
4927 if (!Fn->isInlineSpecified()) {
4928 S.
Diag(AL.
getLoc(), diag::warn_gnu_inline_attribute_requires_inline);
4933 S.
Diag(AL.
getLoc(), diag::warn_gnu_inline_cplusplus_without_extern);
4949 if (!isa<ObjCMethodDecl>(
D)) {
4950 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
4956 case ParsedAttr::AT_FastCall:
4959 case ParsedAttr::AT_StdCall:
4962 case ParsedAttr::AT_ThisCall:
4965 case ParsedAttr::AT_CDecl:
4968 case ParsedAttr::AT_Pascal:
4971 case ParsedAttr::AT_SwiftCall:
4974 case ParsedAttr::AT_SwiftAsyncCall:
4977 case ParsedAttr::AT_VectorCall:
4980 case ParsedAttr::AT_MSABI:
4983 case ParsedAttr::AT_SysVABI:
4986 case ParsedAttr::AT_RegCall:
4989 case ParsedAttr::AT_Pcs: {
4990 PcsAttr::PCSType PCS;
4993 PCS = PcsAttr::AAPCS;
4996 PCS = PcsAttr::AAPCS_VFP;
4999 llvm_unreachable(
"unexpected calling convention in pcs attribute");
5005 case ParsedAttr::AT_AArch64VectorPcs:
5008 case ParsedAttr::AT_AArch64SVEPcs:
5011 case ParsedAttr::AT_AMDGPUKernelCall:
5014 case ParsedAttr::AT_IntelOclBicc:
5017 case ParsedAttr::AT_PreserveMost:
5020 case ParsedAttr::AT_PreserveAll:
5023 case ParsedAttr::AT_M68kRTD:
5026 case ParsedAttr::AT_PreserveNone:
5029 case ParsedAttr::AT_RISCVVectorCC:
5033 llvm_unreachable(
"unexpected attribute kind");
5044 std::vector<StringRef> DiagnosticIdentifiers;
5045 for (
unsigned I = 0,
E = AL.
getNumArgs(); I !=
E; ++I) {
5051 DiagnosticIdentifiers.push_back(RuleName);
5054 SuppressAttr(S.
Context, AL, DiagnosticIdentifiers.data(),
5055 DiagnosticIdentifiers.size()));
5064 unsigned SelectIdx = ~0
U;
5070 if (SelectIdx != ~0
U) {
5071 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_argument)
5083 if (AL.
getKind() == ParsedAttr::AT_Owner) {
5084 if (checkAttrMutualExclusion<PointerAttr>(S,
D, AL))
5086 if (
const auto *OAttr =
D->
getAttr<OwnerAttr>()) {
5087 const Type *ExistingDerefType = OAttr->getDerefTypeLoc()
5088 ? OAttr->getDerefType().getTypePtr()
5091 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
5094 OAttr->isRegularKeywordAttribute());
5095 S.
Diag(OAttr->getLocation(), diag::note_conflicting_attribute);
5100 Redecl->addAttr(::new (S.
Context) OwnerAttr(S.
Context, AL, DerefTypeLoc));
5103 if (checkAttrMutualExclusion<OwnerAttr>(S,
D, AL))
5105 if (
const auto *PAttr =
D->
getAttr<PointerAttr>()) {
5106 const Type *ExistingDerefType = PAttr->getDerefTypeLoc()
5107 ? PAttr->getDerefType().getTypePtr()
5110 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
5113 PAttr->isRegularKeywordAttribute());
5114 S.
Diag(PAttr->getLocation(), diag::note_conflicting_attribute);
5119 Redecl->addAttr(::new (S.
Context)
5120 PointerAttr(S.
Context, AL, DerefTypeLoc));
5126 if (checkAttrMutualExclusion<NoRandomizeLayoutAttr>(S,
D, AL))
5128 if (!
D->
hasAttr<RandomizeLayoutAttr>())
5134 if (checkAttrMutualExclusion<RandomizeLayoutAttr>(S,
D, AL))
5136 if (!
D->
hasAttr<NoRandomizeLayoutAttr>())
5151 unsigned ReqArgs = Attrs.
getKind() == ParsedAttr::AT_Pcs ? 1 : 0;
5159 case ParsedAttr::AT_CDecl:
5162 case ParsedAttr::AT_FastCall:
5165 case ParsedAttr::AT_StdCall:
5168 case ParsedAttr::AT_ThisCall:
5171 case ParsedAttr::AT_Pascal:
5174 case ParsedAttr::AT_SwiftCall:
5177 case ParsedAttr::AT_SwiftAsyncCall:
5180 case ParsedAttr::AT_VectorCall:
5183 case ParsedAttr::AT_AArch64VectorPcs:
5186 case ParsedAttr::AT_AArch64SVEPcs:
5189 case ParsedAttr::AT_AMDGPUKernelCall:
5192 case ParsedAttr::AT_RegCall:
5195 case ParsedAttr::AT_MSABI:
5199 case ParsedAttr::AT_SysVABI:
5203 case ParsedAttr::AT_Pcs: {
5209 if (StrRef ==
"aapcs") {
5212 }
else if (StrRef ==
"aapcs-vfp") {
5221 case ParsedAttr::AT_IntelOclBicc:
5224 case ParsedAttr::AT_PreserveMost:
5227 case ParsedAttr::AT_PreserveAll:
5230 case ParsedAttr::AT_M68kRTD:
5233 case ParsedAttr::AT_PreserveNone:
5236 case ParsedAttr::AT_RISCVVectorCC:
5239 default: llvm_unreachable(
"unexpected attribute kind");
5252 bool CheckHost =
false, CheckDevice =
false;
5253 switch (CudaTarget) {
5266 llvm_unreachable(
"unexpected cuda target");
5268 auto *HostTI =
LangOpts.CUDAIsDevice ? Aux : &TI;
5269 auto *DeviceTI =
LangOpts.CUDAIsDevice ? &TI : Aux;
5270 if (CheckHost && HostTI)
5273 A = DeviceTI->checkCallingConvention(CC);
5291 Diag(Attrs.
getLoc(), diag::error_cconv_unsupported)
5296 Diag(Attrs.
getLoc(), diag::warn_cconv_unsupported)
5301 bool IsCXXMethod =
false, IsVariadic =
false;
5332 Diag(AL.
getLoc(), diag::err_attribute_regparm_wrong_platform)
5340 Diag(AL.
getLoc(), diag::err_attribute_regparm_invalid_number)
5352 llvm_unreachable(
"getOffloadArch is only valid for NVPTX triple");
5362 const CUDALaunchBoundsAttr &AL,
5363 const unsigned Idx) {
5372 std::optional<llvm::APSInt> I = llvm::APSInt(64);
5379 if (!I->isIntN(32)) {
5381 <<
toString(*I, 10,
false) << 32 << 1;
5393 "Unexpected PerformCopyInitialization() failure.");
5398CUDALaunchBoundsAttr *
5400 Expr *MinBlocks,
Expr *MaxBlocks) {
5401 CUDALaunchBoundsAttr TmpAttr(
Context, CI, MaxThreads, MinBlocks, MaxBlocks);
5419 MaxBlocks =
nullptr;
5428 CUDALaunchBoundsAttr(
Context, CI, MaxThreads, MinBlocks, MaxBlocks);
5450 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
5468 unsigned ArgumentIdxAST = ArgumentIdx.
getASTIndex();
5471 S.
Diag(AL.
getLoc(), diag::err_attribute_pointers_only) << AL << 0;
5482 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
5490 if (!isa<VarDecl>(
D)) {
5491 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_decl_type)
5499 assert(MatchingCTypeLoc &&
"no type source info for attribute argument");
5522 S.
Diag(AL.
getLoc(), diag::err_aix_attr_unsupported) << AL;
5525 uint32_t Count = 0, Offset = 0;
5532 if (Count < Offset) {
5533 S.
Diag(S.
getAttrLoc(AL), diag::err_attribute_argument_out_of_range)
5539 PatchableFunctionEntryAttr(S.
Context, AL, Count, Offset));
5544 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
5551 StringRef AliasName = cast<FunctionDecl>(
D)->getIdentifier()->getName();
5561 (!IsAArch64 && !IsARM && !IsRISCV && !IsHLSL)) {
5562 S.
Diag(AL.
getLoc(), diag::err_attribute_builtin_alias) << AL;
5573 if (
auto *CRD = dyn_cast<CXXRecordDecl>(
D);
5574 !CRD || !(CRD->isClass() || CRD->isStruct())) {
5580 handleSimpleAttribute<TypeNullableAttr>(S,
D, AL);
5585 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
5591 assert(ParmTSI &&
"no type source info for attribute argument");
5593 diag::err_incomplete_type);
5603 StringRef UuidAsWritten,
MSGuidDecl *GuidDecl) {
5604 if (
const auto *UA =
D->
getAttr<UuidAttr>()) {
5607 if (!UA->getGuid().empty()) {
5608 Diag(UA->getLocation(), diag::err_mismatched_uuid);
5614 return ::new (
Context) UuidAttr(
Context, CI, UuidAsWritten, GuidDecl);
5619 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
5624 StringRef OrigStrRef;
5631 StringRef StrRef = OrigStrRef;
5632 if (StrRef.size() == 38 && StrRef.front() ==
'{' && StrRef.back() ==
'}')
5633 StrRef = StrRef.drop_front().drop_back();
5636 if (StrRef.size() != 36) {
5637 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
5641 for (
unsigned i = 0; i < 36; ++i) {
5642 if (i == 8 || i == 13 || i == 18 || i == 23) {
5643 if (StrRef[i] !=
'-') {
5644 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
5648 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
5655 StrRef.substr(0, 8).getAsInteger(16, Parsed.
Part1);
5656 StrRef.substr(9, 4).getAsInteger(16, Parsed.
Part2);
5657 StrRef.substr(14, 4).getAsInteger(16, Parsed.
Part3);
5658 for (
unsigned i = 0; i != 8; ++i)
5659 StrRef.substr(19 + 2 * i + (i >= 2 ? 1 : 0), 2)
5670 S.
Diag(AL.
getLoc(), diag::warn_atl_uuid_deprecated);
5679 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
5692 const auto *VD = cast<VarDecl>(
D);
5694 S.
Diag(AL.
getLoc(), diag::err_thread_unsupported);
5698 S.
Diag(AL.
getLoc(), diag::err_declspec_thread_on_thread_variable);
5701 if (VD->hasLocalStorage()) {
5702 S.
Diag(AL.
getLoc(), diag::err_thread_non_global) <<
"__declspec(thread)";
5710 S.
Diag(AL.
getLoc(), diag::warn_unknown_attribute_ignored)
5714 auto *FD = cast<FunctionDecl>(
D);
5716 S.
Diag(AL.
getLoc(), diag::err_ms_constexpr_cannot_be_applied)
5720 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
5721 if (!S.
getLangOpts().CPlusPlus20 && MD->isVirtual()) {
5722 S.
Diag(AL.
getLoc(), diag::err_ms_constexpr_cannot_be_applied)
5732 for (
unsigned I = 0,
E = AL.
getNumArgs(); I !=
E; ++I) {
5736 Tags.push_back(Tag);
5739 if (
const auto *NS = dyn_cast<NamespaceDecl>(
D)) {
5740 if (!NS->isInline()) {
5741 S.
Diag(AL.
getLoc(), diag::warn_attr_abi_tag_namespace) << 0;
5744 if (NS->isAnonymousNamespace()) {
5745 S.
Diag(AL.
getLoc(), diag::warn_attr_abi_tag_namespace) << 1;
5749 Tags.push_back(NS->getName());
5755 Tags.erase(std::unique(Tags.begin(), Tags.end()), Tags.end());
5758 AbiTagAttr(S.
Context, AL, Tags.data(), Tags.size()));
5763 if (I->getBTFDeclTag() == Tag)
5782 return ::new (
Context) BTFDeclTagAttr(
Context, AL, AL.getBTFDeclTag());
5788 case llvm::Triple::msp430:
5791 case llvm::Triple::mipsel:
5792 case llvm::Triple::mips:
5795 case llvm::Triple::m68k:
5798 case llvm::Triple::x86:
5799 case llvm::Triple::x86_64:
5802 case llvm::Triple::avr:
5805 case llvm::Triple::riscv32:
5806 case llvm::Triple::riscv64:
5823 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
5839 Diag(CI.
getLoc(), diag::warn_attribute_ignored) <<
"'dllimport'";
5851 if (DLLImportAttr *Import =
D->
getAttr<DLLImportAttr>()) {
5852 Diag(Import->getLocation(), diag::warn_attribute_ignored) << Import;
5863 if (isa<ClassTemplatePartialSpecializationDecl>(
D) &&
5869 if (
const auto *FD = dyn_cast<FunctionDecl>(
D)) {
5879 if (
const auto *MD = dyn_cast<CXXMethodDecl>(
D)) {
5881 MD->getParent()->isLambda()) {
5887 Attr *NewAttr = A.
getKind() == ParsedAttr::AT_DLLExport
5898 if (MSInheritanceAttr *IA =
D->
getAttr<MSInheritanceAttr>()) {
5899 if (IA->getInheritanceModel() == Model)
5901 Diag(IA->getLocation(), diag::err_mismatched_ms_inheritance)
5903 Diag(CI.
getLoc(), diag::note_previous_ms_inheritance);
5907 auto *RD = cast<CXXRecordDecl>(
D);
5908 if (RD->hasDefinition()) {
5914 if (isa<ClassTemplatePartialSpecializationDecl>(RD)) {
5915 Diag(CI.
getLoc(), diag::warn_ignored_ms_inheritance)
5919 if (RD->getDescribedClassTemplate()) {
5920 Diag(CI.
getLoc(), diag::warn_ignored_ms_inheritance)
5938 StringRef N(
"mutex");
5940 if (AL.
getKind() == ParsedAttr::AT_Capability &&
5953 AssertCapabilityAttr(S.
Context, AL, Args.data(), Args.size()));
5958 if (
const auto *ParmDecl = dyn_cast<ParmVarDecl>(
D);
5982 if (
const auto *ParmDecl = dyn_cast<ParmVarDecl>(
D);
5995 if (
const auto *ParmDecl = dyn_cast<ParmVarDecl>(
D);
6008 RequiresCapabilityAttr *RCA = ::new (S.
Context)
6009 RequiresCapabilityAttr(S.
Context, AL, Args.data(), Args.size());
6015 if (
const auto *NSD = dyn_cast<NamespaceDecl>(
D)) {
6016 if (NSD->isAnonymousNamespace()) {
6017 S.
Diag(AL.
getLoc(), diag::warn_deprecated_anonymous_namespace);
6031 StringRef Str, Replacement;
6044 S.
Diag(AL.
getLoc(), diag::ext_cxx14_attr) << AL;
6050 if (
const auto *S = dyn_cast<VarDecl>(
D))
6051 return S->hasGlobalStorage();
6056 return Sanitizer ==
"address" || Sanitizer ==
"hwaddress" ||
6057 Sanitizer ==
"memtag";
6064 std::vector<StringRef> Sanitizers;
6066 for (
unsigned I = 0,
E = AL.
getNumArgs(); I !=
E; ++I) {
6067 StringRef SanitizerName;
6075 SanitizerName !=
"coverage")
6076 S.
Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << SanitizerName;
6079 << AL << SanitizerName;
6080 Sanitizers.push_back(SanitizerName);
6084 Sanitizers.size()));
6091 StringRef SanitizerName = llvm::StringSwitch<StringRef>(AttrName)
6092 .Case(
"no_address_safety_analysis",
"address")
6093 .Case(
"no_sanitize_address",
"address")
6094 .Case(
"no_sanitize_thread",
"thread")
6095 .Case(
"no_sanitize_memory",
"memory");
6108 unsigned TranslatedSpellingIndex = 0;
6110 TranslatedSpellingIndex = 1;
6115 NoSanitizeAttr(S.
Context, Info, &SanitizerName, 1));
6130 ZeroCallUsedRegsAttr::ZeroCallUsedRegsKind Kind;
6131 if (!ZeroCallUsedRegsAttr::ConvertStrToZeroCallUsedRegsKind(KindStr, Kind)) {
6132 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported)
6142 auto *FD = dyn_cast<FieldDecl>(
D);
6152 case ParsedAttr::AT_CountedBy:
6153 CountInBytes =
false;
6156 case ParsedAttr::AT_CountedByOrNull:
6157 CountInBytes =
false;
6160 case ParsedAttr::AT_SizedBy:
6161 CountInBytes =
true;
6164 case ParsedAttr::AT_SizedByOrNull:
6165 CountInBytes =
true;
6169 llvm_unreachable(
"unexpected counted_by family attribute");
6176 FD->
getType(), CountExpr, CountInBytes, OrNull);
6187 FunctionReturnThunksAttr::Kind Kind;
6188 if (!FunctionReturnThunksAttr::ConvertStrToKind(KindStr, Kind)) {
6189 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported)
6196 D->
dropAttr<FunctionReturnThunksAttr>();
6202 assert(isa<TypedefNameDecl>(
D) &&
"This attribute only applies to a typedef");
6203 handleSimpleAttribute<AvailableOnlyInDefaultEvalMethodAttr>(S,
D, AL);
6207 auto *VDecl = dyn_cast<VarDecl>(
D);
6208 if (VDecl && !VDecl->isFunctionPointerType()) {
6209 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored_non_function_pointer)
6221 if (!cast<VarDecl>(
D)->hasGlobalStorage()) {
6223 << (A.
getKind() == ParsedAttr::AT_AlwaysDestroy);
6227 if (A.
getKind() == ParsedAttr::AT_AlwaysDestroy)
6228 handleSimpleAttribute<AlwaysDestroyAttr>(S,
D, A);
6230 handleSimpleAttribute<NoDestroyAttr>(S,
D, A);
6234 assert(cast<VarDecl>(
D)->getStorageDuration() ==
SD_Automatic &&
6235 "uninitialized is only valid on automatic duration variables");
6244 if (!isa<BlockDecl>(
D)) {
6246 bool IsKernReturnT =
false;
6248 IsKernReturnT = (TT->getDecl()->getName() ==
"kern_return_t");
6253 diag::warn_mig_server_routine_does_not_return_kern_return_t);
6258 handleSimpleAttribute<MIGServerRoutineAttr>(S,
D, AL);
6263 if (
auto *FD = dyn_cast<FunctionDecl>(
D)) {
6266 S.
Diag(AL.
getLoc(), diag::warn_declspec_allocator_nonpointer)
6272 handleSimpleAttribute<MSAllocatorAttr>(S,
D, AL);
6279 if (
const auto *PVD = dyn_cast<ParmVarDecl>(
D)) {
6280 if (PVD->getType()->isIntegerType()) {
6281 S.
Diag(AL.
getLoc(), diag::err_attribute_output_parameter)
6292template<
typename Attr>
6300template<
typename Attr>
6309 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
6314 CFGuardAttr::GuardArg Arg;
6316 if (!CFGuardAttr::ConvertStrToGuardArg(II->
getName(), Arg)) {
6317 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
6325template <
typename AttrTy>
6328 auto I = llvm::find_if(Attrs,
6329 [Name](
const AttrTy *A) {
6330 return A->getTCBName() == Name;
6332 return I == Attrs.end() ? nullptr : *I;
6335template <
typename AttrTy,
typename ConflictingAttrTy>
6342 if (
const ConflictingAttrTy *ConflictingAttr =
6343 findEnforceTCBAttrByName<ConflictingAttrTy>(
D, Argument)) {
6346 S.
Diag(AL.
getLoc(), diag::err_tcb_conflicting_attributes)
6360template <
typename AttrTy,
typename ConflictingAttrTy>
6363 StringRef TCBName = AL.getTCBName();
6364 if (
const ConflictingAttrTy *ConflictingAttr =
6365 findEnforceTCBAttrByName<ConflictingAttrTy>(
D, TCBName)) {
6366 S.
Diag(ConflictingAttr->getLoc(), diag::err_tcb_conflicting_attributes)
6367 << ConflictingAttr->getAttrName()->getName()
6368 << AL.getAttrName()->getName() << TCBName;
6371 S.
Diag(AL.getLoc(), diag::note_conflicting_attribute);
6379 return ::new(Context) AttrTy(Context, AL, AL.getTCBName());
6383 return mergeEnforceTCBAttrImpl<EnforceTCBAttr, EnforceTCBLeafAttr>(
6388 Decl *
D,
const EnforceTCBLeafAttr &AL) {
6389 return mergeEnforceTCBAttrImpl<EnforceTCBLeafAttr, EnforceTCBAttr>(
6398 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 4;
6403 S.
Diag(AL.
getLoc(), diag::err_attribute_too_few_arguments) << AL;
6408 if (
D->
getAttr<VTablePointerAuthenticationAttr>()) {
6409 S.
Diag(AL.
getLoc(), diag::err_duplicated_vtable_pointer_auth) <<
Decl;
6413 auto KeyType = VTablePointerAuthenticationAttr::VPtrAuthKeyType::DefaultKey;
6416 if (!VTablePointerAuthenticationAttr::ConvertStrToVPtrAuthKeyType(
6418 S.
Diag(IL->
Loc, diag::err_invalid_authentication_key) << IL->
Ident;
6421 if (KeyType == VTablePointerAuthenticationAttr::DefaultKey &&
6423 S.
Diag(AL.
getLoc(), diag::err_no_default_vtable_pointer_auth) << 0;
6427 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
6432 auto AddressDiversityMode = VTablePointerAuthenticationAttr::
6433 AddressDiscriminationMode::DefaultAddressDiscrimination;
6437 if (!VTablePointerAuthenticationAttr::
6438 ConvertStrToAddressDiscriminationMode(IL->
Ident->
getName(),
6439 AddressDiversityMode)) {
6440 S.
Diag(IL->
Loc, diag::err_invalid_address_discrimination) << IL->
Ident;
6443 if (AddressDiversityMode ==
6444 VTablePointerAuthenticationAttr::DefaultAddressDiscrimination &&
6446 S.
Diag(IL->
Loc, diag::err_no_default_vtable_pointer_auth) << 1;
6450 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
6455 auto ED = VTablePointerAuthenticationAttr::ExtraDiscrimination::
6456 DefaultExtraDiscrimination;
6460 if (!VTablePointerAuthenticationAttr::ConvertStrToExtraDiscrimination(
6462 S.
Diag(IL->
Loc, diag::err_invalid_extra_discrimination) << IL->
Ident;
6465 if (ED == VTablePointerAuthenticationAttr::DefaultExtraDiscrimination &&
6467 S.
Diag(AL.
getLoc(), diag::err_no_default_vtable_pointer_auth) << 2;
6471 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
6476 uint32_t CustomDiscriminationValue = 0;
6477 if (ED == VTablePointerAuthenticationAttr::CustomDiscrimination) {
6479 S.
Diag(AL.
getLoc(), diag::err_missing_custom_discrimination) << AL << 4;
6484 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 4;
6489 CustomDiscriminationValue)) {
6490 S.
Diag(AL.
getLoc(), diag::err_invalid_custom_discrimination);
6493 }
else if (NumArgs > 3) {
6494 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 3;
6499 S.
Context, AL, KeyType, AddressDiversityMode, ED,
6500 CustomDiscriminationValue));
6516 for (
size_t I = 0; I < std::min(AL.
getNumArgs(), AttrNumArgs); ++I) {
6517 bool IsLastAttrArg = I == (AttrNumArgs - 1);
6520 if (IsLastAttrArg && AttrHasVariadicArg)
6527 if (isa<PackExpansionExpr>(
E))
6528 return !(IsLastAttrArg && ArgMemberCanHoldExpr);
6555 !Options.IncludeCXX11Attributes)
6565 ? (
unsigned)diag::err_keyword_not_supported_on_target
6567 ? (
unsigned)diag::warn_unhandled_ms_attribute_ignored
6568 : (
unsigned)diag::warn_unknown_attribute_ignored)
6580 if (MustDelayArgs) {
6590 assert(AL.
isTypeAttr() &&
"Non-type attribute not handled");
6593 if (Options.IgnoreTypeAttributes)
6611 isa<DeclaratorDecl, TypeAliasDecl>(
D)) {
6616 S.
Diag(AL.
getLoc(), diag::warn_type_attribute_deprecated_on_decl)
6625 if (AL.
getKind() == ParsedAttr::AT_Regparm) {
6638 if (AL.
getKind() == ParsedAttr::AT_VectorSize) {
6648 if (AL.
getKind() == ParsedAttr::AT_NoDeref) {
6659 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_on_decl)
6662 case ParsedAttr::AT_Interrupt:
6665 case ParsedAttr::AT_X86ForceAlignArgPointer:
6668 case ParsedAttr::AT_ReadOnlyPlacement:
6669 handleSimpleAttribute<ReadOnlyPlacementAttr>(S,
D, AL);
6671 case ParsedAttr::AT_DLLExport:
6672 case ParsedAttr::AT_DLLImport:
6675 case ParsedAttr::AT_AMDGPUFlatWorkGroupSize:
6678 case ParsedAttr::AT_AMDGPUWavesPerEU:
6681 case ParsedAttr::AT_AMDGPUNumSGPR:
6684 case ParsedAttr::AT_AMDGPUNumVGPR:
6687 case ParsedAttr::AT_AMDGPUMaxNumWorkGroups:
6690 case ParsedAttr::AT_AVRSignal:
6693 case ParsedAttr::AT_BPFPreserveAccessIndex:
6696 case ParsedAttr::AT_BPFPreserveStaticOffset:
6697 handleSimpleAttribute<BPFPreserveStaticOffsetAttr>(S,
D, AL);
6699 case ParsedAttr::AT_BTFDeclTag:
6702 case ParsedAttr::AT_WebAssemblyExportName:
6705 case ParsedAttr::AT_WebAssemblyImportModule:
6708 case ParsedAttr::AT_WebAssemblyImportName:
6711 case ParsedAttr::AT_IBOutlet:
6714 case ParsedAttr::AT_IBOutletCollection:
6717 case ParsedAttr::AT_IFunc:
6720 case ParsedAttr::AT_Alias:
6723 case ParsedAttr::AT_Aligned:
6726 case ParsedAttr::AT_AlignValue:
6729 case ParsedAttr::AT_AllocSize:
6732 case ParsedAttr::AT_AlwaysInline:
6735 case ParsedAttr::AT_AnalyzerNoReturn:
6738 case ParsedAttr::AT_TLSModel:
6741 case ParsedAttr::AT_Annotate:
6744 case ParsedAttr::AT_Availability:
6747 case ParsedAttr::AT_CarriesDependency:
6750 case ParsedAttr::AT_CPUDispatch:
6751 case ParsedAttr::AT_CPUSpecific:
6754 case ParsedAttr::AT_Common:
6757 case ParsedAttr::AT_CUDAConstant:
6760 case ParsedAttr::AT_PassObjectSize:
6763 case ParsedAttr::AT_Constructor:
6766 case ParsedAttr::AT_Deprecated:
6769 case ParsedAttr::AT_Destructor:
6772 case ParsedAttr::AT_EnableIf:
6775 case ParsedAttr::AT_Error:
6778 case ParsedAttr::AT_ExcludeFromExplicitInstantiation:
6781 case ParsedAttr::AT_DiagnoseIf:
6784 case ParsedAttr::AT_DiagnoseAsBuiltin:
6787 case ParsedAttr::AT_NoBuiltin:
6790 case ParsedAttr::AT_ExtVectorType:
6793 case ParsedAttr::AT_ExternalSourceSymbol:
6796 case ParsedAttr::AT_MinSize:
6799 case ParsedAttr::AT_OptimizeNone:
6802 case ParsedAttr::AT_EnumExtensibility:
6805 case ParsedAttr::AT_SYCLKernel:
6808 case ParsedAttr::AT_SYCLKernelEntryPoint:
6811 case ParsedAttr::AT_SYCLSpecialClass:
6812 handleSimpleAttribute<SYCLSpecialClassAttr>(S,
D, AL);
6814 case ParsedAttr::AT_Format:
6817 case ParsedAttr::AT_FormatArg:
6820 case ParsedAttr::AT_Callback:
6823 case ParsedAttr::AT_LifetimeCaptureBy:
6826 case ParsedAttr::AT_CalledOnce:
6829 case ParsedAttr::AT_NVPTXKernel:
6830 case ParsedAttr::AT_CUDAGlobal:
6833 case ParsedAttr::AT_CUDADevice:
6836 case ParsedAttr::AT_CUDAGridConstant:
6839 case ParsedAttr::AT_HIPManaged:
6842 case ParsedAttr::AT_GNUInline:
6845 case ParsedAttr::AT_CUDALaunchBounds:
6848 case ParsedAttr::AT_Restrict:
6851 case ParsedAttr::AT_Mode:
6854 case ParsedAttr::AT_NonNull:
6855 if (
auto *PVD = dyn_cast<ParmVarDecl>(
D))
6860 case ParsedAttr::AT_ReturnsNonNull:
6863 case ParsedAttr::AT_NoEscape:
6866 case ParsedAttr::AT_MaybeUndef:
6867 handleSimpleAttribute<MaybeUndefAttr>(S,
D, AL);
6869 case ParsedAttr::AT_AssumeAligned:
6872 case ParsedAttr::AT_AllocAlign:
6875 case ParsedAttr::AT_Ownership:
6878 case ParsedAttr::AT_Naked:
6881 case ParsedAttr::AT_NoReturn:
6884 case ParsedAttr::AT_CXX11NoReturn:
6887 case ParsedAttr::AT_AnyX86NoCfCheck:
6890 case ParsedAttr::AT_NoThrow:
6892 handleSimpleAttribute<NoThrowAttr>(S,
D, AL);
6894 case ParsedAttr::AT_CUDAShared:
6897 case ParsedAttr::AT_VecReturn:
6900 case ParsedAttr::AT_ObjCOwnership:
6903 case ParsedAttr::AT_ObjCPreciseLifetime:
6906 case ParsedAttr::AT_ObjCReturnsInnerPointer:
6909 case ParsedAttr::AT_ObjCRequiresSuper:
6912 case ParsedAttr::AT_ObjCBridge:
6915 case ParsedAttr::AT_ObjCBridgeMutable:
6918 case ParsedAttr::AT_ObjCBridgeRelated:
6921 case ParsedAttr::AT_ObjCDesignatedInitializer:
6924 case ParsedAttr::AT_ObjCRuntimeName:
6927 case ParsedAttr::AT_ObjCBoxable:
6930 case ParsedAttr::AT_NSErrorDomain:
6933 case ParsedAttr::AT_CFConsumed:
6934 case ParsedAttr::AT_NSConsumed:
6935 case ParsedAttr::AT_OSConsumed:
6940 case ParsedAttr::AT_OSReturnsRetainedOnZero:
6941 handleSimpleAttributeOrDiagnose<OSReturnsRetainedOnZeroAttr>(
6943 diag::warn_ns_attribute_wrong_parameter_type,
6946 case ParsedAttr::AT_OSReturnsRetainedOnNonZero:
6947 handleSimpleAttributeOrDiagnose<OSReturnsRetainedOnNonZeroAttr>(
6949 diag::warn_ns_attribute_wrong_parameter_type,
6952 case ParsedAttr::AT_NSReturnsAutoreleased:
6953 case ParsedAttr::AT_NSReturnsNotRetained:
6954 case ParsedAttr::AT_NSReturnsRetained:
6955 case ParsedAttr::AT_CFReturnsNotRetained:
6956 case ParsedAttr::AT_CFReturnsRetained:
6957 case ParsedAttr::AT_OSReturnsNotRetained:
6958 case ParsedAttr::AT_OSReturnsRetained:
6961 case ParsedAttr::AT_WorkGroupSizeHint:
6962 handleWorkGroupSize<WorkGroupSizeHintAttr>(S,
D, AL);
6964 case ParsedAttr::AT_ReqdWorkGroupSize:
6965 handleWorkGroupSize<ReqdWorkGroupSizeAttr>(S,
D, AL);
6967 case ParsedAttr::AT_OpenCLIntelReqdSubGroupSize:
6970 case ParsedAttr::AT_VecTypeHint:
6973 case ParsedAttr::AT_InitPriority:
6976 case ParsedAttr::AT_Packed:
6979 case ParsedAttr::AT_PreferredName:
6982 case ParsedAttr::AT_NoSpecializations:
6985 case ParsedAttr::AT_Section:
6988 case ParsedAttr::AT_CodeModel:
6991 case ParsedAttr::AT_RandomizeLayout:
6994 case ParsedAttr::AT_NoRandomizeLayout:
6997 case ParsedAttr::AT_CodeSeg:
7000 case ParsedAttr::AT_Target:
7003 case ParsedAttr::AT_TargetVersion:
7006 case ParsedAttr::AT_TargetClones:
7009 case ParsedAttr::AT_MinVectorWidth:
7012 case ParsedAttr::AT_Unavailable:
7013 handleAttrWithMessage<UnavailableAttr>(S,
D, AL);
7015 case ParsedAttr::AT_OMPAssume:
7018 case ParsedAttr::AT_ObjCDirect:
7021 case ParsedAttr::AT_ObjCDirectMembers:
7023 handleSimpleAttribute<ObjCDirectMembersAttr>(S,
D, AL);
7025 case ParsedAttr::AT_ObjCExplicitProtocolImpl:
7028 case ParsedAttr::AT_Unused:
7031 case ParsedAttr::AT_Visibility:
7034 case ParsedAttr::AT_TypeVisibility:
7037 case ParsedAttr::AT_WarnUnusedResult:
7040 case ParsedAttr::AT_WeakRef:
7043 case ParsedAttr::AT_WeakImport:
7046 case ParsedAttr::AT_TransparentUnion:
7049 case ParsedAttr::AT_ObjCMethodFamily:
7052 case ParsedAttr::AT_ObjCNSObject:
7055 case ParsedAttr::AT_ObjCIndependentClass:
7058 case ParsedAttr::AT_Blocks:
7061 case ParsedAttr::AT_Sentinel:
7064 case ParsedAttr::AT_Cleanup:
7067 case ParsedAttr::AT_NoDebug:
7070 case ParsedAttr::AT_CmseNSEntry:
7073 case ParsedAttr::AT_StdCall:
7074 case ParsedAttr::AT_CDecl:
7075 case ParsedAttr::AT_FastCall:
7076 case ParsedAttr::AT_ThisCall:
7077 case ParsedAttr::AT_Pascal:
7078 case ParsedAttr::AT_RegCall:
7079 case ParsedAttr::AT_SwiftCall:
7080 case ParsedAttr::AT_SwiftAsyncCall:
7081 case ParsedAttr::AT_VectorCall:
7082 case ParsedAttr::AT_MSABI:
7083 case ParsedAttr::AT_SysVABI:
7084 case ParsedAttr::AT_Pcs:
7085 case ParsedAttr::AT_IntelOclBicc:
7086 case ParsedAttr::AT_PreserveMost:
7087 case ParsedAttr::AT_PreserveAll:
7088 case ParsedAttr::AT_AArch64VectorPcs:
7089 case ParsedAttr::AT_AArch64SVEPcs:
7090 case ParsedAttr::AT_AMDGPUKernelCall:
7091 case ParsedAttr::AT_M68kRTD:
7092 case ParsedAttr::AT_PreserveNone:
7093 case ParsedAttr::AT_RISCVVectorCC:
7096 case ParsedAttr::AT_Suppress:
7099 case ParsedAttr::AT_Owner:
7100 case ParsedAttr::AT_Pointer:
7103 case ParsedAttr::AT_OpenCLAccess:
7106 case ParsedAttr::AT_OpenCLNoSVM:
7109 case ParsedAttr::AT_SwiftContext:
7112 case ParsedAttr::AT_SwiftAsyncContext:
7115 case ParsedAttr::AT_SwiftErrorResult:
7118 case ParsedAttr::AT_SwiftIndirectResult:
7121 case ParsedAttr::AT_InternalLinkage:
7124 case ParsedAttr::AT_ZeroCallUsedRegs:
7127 case ParsedAttr::AT_FunctionReturnThunks:
7130 case ParsedAttr::AT_NoMerge:
7133 case ParsedAttr::AT_NoUniqueAddress:
7137 case ParsedAttr::AT_AvailableOnlyInDefaultEvalMethod:
7141 case ParsedAttr::AT_CountedBy:
7142 case ParsedAttr::AT_CountedByOrNull:
7143 case ParsedAttr::AT_SizedBy:
7144 case ParsedAttr::AT_SizedByOrNull:
7149 case ParsedAttr::AT_LayoutVersion:
7152 case ParsedAttr::AT_Uuid:
7155 case ParsedAttr::AT_MSInheritance:
7158 case ParsedAttr::AT_Thread:
7161 case ParsedAttr::AT_MSConstexpr:
7164 case ParsedAttr::AT_HybridPatchable:
7165 handleSimpleAttribute<HybridPatchableAttr>(S,
D, AL);
7169 case ParsedAttr::AT_HLSLNumThreads:
7172 case ParsedAttr::AT_HLSLWaveSize:
7175 case ParsedAttr::AT_HLSLSV_GroupThreadID:
7178 case ParsedAttr::AT_HLSLSV_GroupID:
7181 case ParsedAttr::AT_HLSLSV_GroupIndex:
7182 handleSimpleAttribute<HLSLSV_GroupIndexAttr>(S,
D, AL);
7184 case ParsedAttr::AT_HLSLGroupSharedAddressSpace:
7185 handleSimpleAttribute<HLSLGroupSharedAddressSpaceAttr>(S,
D, AL);
7187 case ParsedAttr::AT_HLSLSV_DispatchThreadID:
7190 case ParsedAttr::AT_HLSLPackOffset:
7193 case ParsedAttr::AT_HLSLShader:
7196 case ParsedAttr::AT_HLSLResourceBinding:
7199 case ParsedAttr::AT_HLSLParamModifier:
7203 case ParsedAttr::AT_AbiTag:
7206 case ParsedAttr::AT_CFGuard:
7211 case ParsedAttr::AT_AssertExclusiveLock:
7214 case ParsedAttr::AT_AssertSharedLock:
7217 case ParsedAttr::AT_PtGuardedVar:
7220 case ParsedAttr::AT_NoSanitize:
7223 case ParsedAttr::AT_NoSanitizeSpecific:
7226 case ParsedAttr::AT_GuardedBy:
7229 case ParsedAttr::AT_PtGuardedBy:
7232 case ParsedAttr::AT_ExclusiveTrylockFunction:
7235 case ParsedAttr::AT_LockReturned:
7238 case ParsedAttr::AT_LocksExcluded:
7241 case ParsedAttr::AT_SharedTrylockFunction:
7244 case ParsedAttr::AT_AcquiredBefore:
7247 case ParsedAttr::AT_AcquiredAfter:
7252 case ParsedAttr::AT_Capability:
7253 case ParsedAttr::AT_Lockable:
7256 case ParsedAttr::AT_RequiresCapability:
7260 case ParsedAttr::AT_AssertCapability:
7263 case ParsedAttr::AT_AcquireCapability:
7266 case ParsedAttr::AT_ReleaseCapability:
7269 case ParsedAttr::AT_TryAcquireCapability:
7274 case ParsedAttr::AT_Consumable:
7277 case ParsedAttr::AT_CallableWhen:
7280 case ParsedAttr::AT_ParamTypestate:
7283 case ParsedAttr::AT_ReturnTypestate:
7286 case ParsedAttr::AT_SetTypestate:
7289 case ParsedAttr::AT_TestTypestate:
7294 case ParsedAttr::AT_ArgumentWithTypeTag:
7297 case ParsedAttr::AT_TypeTagForDatatype:
7302 case ParsedAttr::AT_SwiftAsyncName:
7305 case ParsedAttr::AT_SwiftAttr:
7308 case ParsedAttr::AT_SwiftBridge:
7311 case ParsedAttr::AT_SwiftError:
7314 case ParsedAttr::AT_SwiftName:
7317 case ParsedAttr::AT_SwiftNewType:
7320 case ParsedAttr::AT_SwiftAsync:
7323 case ParsedAttr::AT_SwiftAsyncError:
7328 case ParsedAttr::AT_XRayLogArgs:
7332 case ParsedAttr::AT_PatchableFunctionEntry:
7336 case ParsedAttr::AT_AlwaysDestroy:
7337 case ParsedAttr::AT_NoDestroy:
7341 case ParsedAttr::AT_Uninitialized:
7345 case ParsedAttr::AT_ObjCExternallyRetained:
7349 case ParsedAttr::AT_MIGServerRoutine:
7353 case ParsedAttr::AT_MSAllocator:
7357 case ParsedAttr::AT_ArmBuiltinAlias:
7361 case ParsedAttr::AT_ArmLocallyStreaming:
7362 handleSimpleAttribute<ArmLocallyStreamingAttr>(S,
D, AL);
7365 case ParsedAttr::AT_ArmNew:
7369 case ParsedAttr::AT_AcquireHandle:
7373 case ParsedAttr::AT_ReleaseHandle:
7374 handleHandleAttr<ReleaseHandleAttr>(S,
D, AL);
7377 case ParsedAttr::AT_UnsafeBufferUsage:
7378 handleUnsafeBufferUsage<UnsafeBufferUsageAttr>(S,
D, AL);
7381 case ParsedAttr::AT_UseHandle:
7382 handleHandleAttr<UseHandleAttr>(S,
D, AL);
7385 case ParsedAttr::AT_EnforceTCB:
7386 handleEnforceTCBAttr<EnforceTCBAttr, EnforceTCBLeafAttr>(S,
D, AL);
7389 case ParsedAttr::AT_EnforceTCBLeaf:
7390 handleEnforceTCBAttr<EnforceTCBLeafAttr, EnforceTCBAttr>(S,
D, AL);
7393 case ParsedAttr::AT_BuiltinAlias:
7397 case ParsedAttr::AT_PreferredType:
7401 case ParsedAttr::AT_UsingIfExists:
7402 handleSimpleAttribute<UsingIfExistsAttr>(S,
D, AL);
7405 case ParsedAttr::AT_TypeNullable:
7409 case ParsedAttr::AT_VTablePointerAuthentication:
7417 return D->
hasAttr<OpenCLKernelAttr>() ||
7425 if (AttrList.
empty())
7436 Diag(AttrList.
begin()->getLoc(), diag::err_attribute_weakref_without_alias)
7437 << cast<NamedDecl>(
D);
7446 if (!(
D->
hasAttr<OpenCLKernelAttr>() ||
7450 if (
const auto *A =
D->
getAttr<ReqdWorkGroupSizeAttr>()) {
7455 }
else if (
const auto *A =
D->
getAttr<WorkGroupSizeHintAttr>()) {
7458 }
else if (
const auto *A =
D->
getAttr<VecTypeHintAttr>()) {
7461 }
else if (
const auto *A =
D->
getAttr<OpenCLIntelReqdSubGroupSizeAttr>()) {
7467 if (
const auto *A =
D->
getAttr<AMDGPUFlatWorkGroupSizeAttr>()) {
7471 }
else if (
const auto *A =
D->
getAttr<AMDGPUWavesPerEUAttr>()) {
7475 }
else if (
const auto *A =
D->
getAttr<AMDGPUNumSGPRAttr>()) {
7479 }
else if (
const auto *A =
D->
getAttr<AMDGPUNumVGPRAttr>()) {
7491 if (
D->
hasAttr<ObjCDesignatedInitializerAttr>() &&
7492 cast<ObjCMethodDecl>(
D)->getMethodFamily() !=
OMF_init) {
7494 D->
dropAttr<ObjCDesignatedInitializerAttr>();
7501 if (AL.getKind() == ParsedAttr::AT_TransparentUnion) {
7508 if (
D &&
D->
hasAttr<BPFPreserveAccessIndexAttr>())
7515 if (AL.getKind() == ParsedAttr::AT_Annotate) {
7519 Diag(AL.getLoc(), diag::err_only_annotate_after_access_spec);
7531 if (AL.isUsedAsTypeAttr() || AL.isInvalid())
7537 S.
Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored)
7538 << AL << AL.getRange();
7540 S.
Diag(AL.getLoc(), diag::warn_attribute_not_on_decl) << AL
7550 for (
unsigned i = 0, e =
D.getNumTypeObjects(); i != e; ++i)
7556 assert(isa<FunctionDecl>(ND) || isa<VarDecl>(ND));
7558 if (
auto *FD = dyn_cast<FunctionDecl>(ND)) {
7580 for (
const auto &AI : FT->param_types()) {
7583 Params.push_back(Param);
7585 NewFD->setParams(Params);
7587 }
else if (
auto *VD = dyn_cast<VarDecl>(ND)) {
7589 VD->getInnerLocStart(), VD->getLocation(), II,
7590 VD->getType(), VD->getTypeSourceInfo(),
7591 VD->getStorageClass());
7592 if (VD->getQualifier())
7593 cast<VarDecl>(NewD)->setQualifierInfo(VD->getQualifierLoc());
7626 if (
auto *VD = dyn_cast<VarDecl>(
D))
7627 if (VD->isExternC())
7629 if (
auto *FD = dyn_cast<FunctionDecl>(
D))
7637 auto &WeakInfos = I->second;
7638 for (
const auto &W : WeakInfos)
7640 std::remove_reference_t<
decltype(WeakInfos)> EmptyWeakInfos;
7641 WeakInfos.swap(EmptyWeakInfos);
7653 auto ProcessAttributesWithSliding =
7661 if ((AL.isStandardAttributeSyntax() || AL.isAlignas()) &&
7662 AL.slidesFromDeclToDeclSpecLegacyBehavior()) {
7667 AL.diagnoseAppertainsTo(*
this,
D);
7682 .WithIncludeCXX11Attributes(
false)
7683 .WithIgnoreTypeAttributes(
true));
7692 .WithIncludeCXX11Attributes(
false)
7693 .WithIgnoreTypeAttributes(
true));
7711 UnavailableAttr::ImplicitReason &reason) {
7715 if (!isa<FieldDecl>(
D) && !isa<ObjCPropertyDecl>(
D) &&
7716 !isa<FunctionDecl>(
D))
7724 if ((isa<ObjCIvarDecl>(
D) || isa<ObjCPropertyDecl>(
D))) {
7727 reason = UnavailableAttr::IR_ForbiddenWeak;
7736 reason = UnavailableAttr::IR_ARCForbiddenType;
7746 auto Reason = UnavailableAttr::IR_None;
7748 assert(Reason &&
"didn't set reason?");
7753 if (
const auto *FD = dyn_cast<FunctionDecl>(
D)) {
7756 if (FD->
hasAttr<UnavailableAttr>() &&
7758 diag::err_arc_array_param_no_ownership) {
7789 bool AnyAccessFailures =
false;
7797 switch (diag.
Kind) {
7801 if (!
decl->isInvalidDecl())
7809 if (AnyAccessFailures && isa<DecompositionDecl>(
decl))
7813 AnyAccessFailures =
true;
7826 assert(curPool &&
"re-emitting in undelayed context not supported");
7827 curPool->
steal(pool);
Defines the clang::ASTContext interface.
static SmallString< 64 > normalizeName(const IdentifierInfo *Name, const IdentifierInfo *Scope, AttributeCommonInfo::Syntax SyntaxUsed)
static OffloadArch getOffloadArch(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 the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Defines the clang::LangOptions interface.
llvm::MachO::Target Target
llvm::MachO::Record Record
static bool versionsMatch(const VersionTuple &X, const VersionTuple &Y)
Check whether the two versions match.
static unsigned getNumAttributeArgs(const ParsedAttr &AL)
Defines the clang::Preprocessor interface.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
This file declares semantic analysis functions specific to AMDGPU.
This file declares semantic analysis functions specific to ARM.
This file declares semantic analysis functions specific to AVR.
This file declares semantic analysis functions specific to BPF.
This file declares semantic analysis for CUDA constructs.
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 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 handleFormatAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Handle attribute((format(type,idx,firstarg))) attributes based on http://gcc.gnu.org/onlinedocs/gcc/F...
static void handleUninitializedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static 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 void handleSectionAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleStandardNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &A)
static void handleMIGServerRoutineAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleGuardedByAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleZeroCallUsedRegsAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleDiagnoseAsBuiltinAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleEnumExtensibilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static T * mergeVisibilityAttr(Sema &S, Decl *D, const AttributeCommonInfo &CI, typename T::VisibilityType value)
static void handleLayoutVersion(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 handleLifetimeCaptureByAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNoCfCheckAttr(Sema &S, Decl *D, const ParsedAttr &Attrs)
static void handleNoSpecializations(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 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 void handleVTablePointerAuthentication(Sema &S, Decl *D, const ParsedAttr &AL)
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 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 handleTryAcquireCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleGridConstantAttr(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 handlePassObjectSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNoMergeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleManagedAttr(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 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 void handleCPUSpecificAttr(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 void handleAbiTagAttr(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 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 bool checkFunParamsAreScopedLockable(Sema &S, const ParmVarDecl *ParamDecl, const ParsedAttr &AL)
static bool checkRecordTypeForCapability(Sema &S, QualType Ty)
static void handleArgumentWithTypeTagAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkAcquireOrderAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, SmallVectorImpl< Expr * > &Args)
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 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 handleNoSanitizeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleReturnTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleTargetClonesAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isKernelDecl(Decl *D)
static void handleAllocAlignAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handlePreferredTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleDeviceAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handlePtGuardedByAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAlwaysInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAssertCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleVisibilityAttr(Sema &S, Decl *D, const ParsedAttr &AL, bool isTypeVisibility)
static void handleAnnotateAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static FormatAttrKind getFormatAttrKind(StringRef Format)
getFormatAttrKind - Map from format attribute names to supported format types.
static void handleNullableTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleUuidAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAcquireHandleAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleMSConstexprAttr(Sema &S, Decl *D, const ParsedAttr &AL)
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 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 handleExcludeFromExplicitInstantiationAttr(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 handleDependencyAttr(Sema &S, Scope *Scope, 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 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 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 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 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 void handleDeclspecThreadAttr(Sema &S, Decl *D, const ParsedAttr &AL)
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 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 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 void handleNoDebugAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSuppressAttr(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 handleNoEscapeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAvailableOnlyInDefaultEvalMethod(Sema &S, Decl *D, const ParsedAttr &AL)
static bool MustDelayAttributeArguments(const ParsedAttr &AL)
static void handleNoRandomizeLayoutAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleTargetVersionAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleWarnUnusedResult(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkRecordTypeForScopedCapability(Sema &S, QualType Ty)
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 bool isSanitizerAttributeAllowedOnGlobals(StringRef Sanitizer)
static void handleCallConvAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleMinSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
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 bool typeHasCapability(Sema &S, QualType Ty)
static void handleAnalyzerNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool threadSafetyCheckIsSmartPointer(Sema &S, const RecordType *RT)
static bool isFunctionLike(const Type &T)
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 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 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 functions specific to M68k.
This file declares semantic analysis functions specific to MIPS.
This file declares semantic analysis functions specific to MSP430.
This file declares semantic analysis for Objective-C.
This file declares semantic analysis routines for OpenCL.
This file declares semantic analysis for OpenMP constructs and clauses.
This file declares semantic analysis functions specific to RISC-V.
This file declares semantic analysis for SYCL constructs.
This file declares semantic analysis functions specific to Swift.
This file declares semantic analysis functions specific to Wasm.
This file declares semantic analysis functions specific to X86.
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
static QualType getPointeeType(const MemRegion *R)
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.
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.
Represents an access specifier followed by colon ':'.
Attr - This represents one attribute.
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
bool isC23Attribute() 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
Type source information for an attributed type.
TypeLoc getModifiedLoc() const
The modified type, which is generally canonically different from the attribute type.
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'.
static bool isBuiltinFunc(llvm::StringRef Name)
Returns true if this is a libc/libm function without the '__builtin_' prefix.
Represents a static or instance method of a struct/union/class.
QualType getFunctionObjectParameterType() const
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.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
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.
TemplateDecl * getDescribedTemplate() const
If this is a declaration that describes some template, this method returns that template declaration.
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
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
const IntrusiveRefCntPtr< DiagnosticIDs > & getDiagnosticIDs() const
Recursive AST visitor that supports extension via dynamic dispatch.
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.
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.
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 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.
CallingConv getCallConv() const
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.
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
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.
A C++ nested-name-specifier augmented with source location information.
ObjCMethodDecl - Represents an instance or class method declaration.
Represents one property declaration in an Objective-C interface.
void * getAsOpaquePtr() const
static OpaquePtr getFromOpaquePtr(void *P)
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...
Represents a parameter to a function.
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
ParsedAttr - Represents a syntactic attribute.
bool isPackExpansion() const
const AvailabilityChange & getAvailabilityDeprecated() const
unsigned getSemanticSpelling() const
If the parsed attribute has a semantic equivalent, and it would have a semantic Spelling enumeration ...
bool existsInTarget(const TargetInfo &Target) const
bool checkExactlyNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has exactly as many args as Num.
IdentifierLoc * getArgAsIdent(unsigned Arg) const
bool hasParsedType() const
const AvailabilityChange & getAvailabilityIntroduced() const
void setInvalid(bool b=true) const
bool hasVariadicArg() const
const ParsedAttrInfo & getInfo() const
void handleAttrWithDelayedArgs(Sema &S, Decl *D) const
const Expr * getReplacementExpr() const
bool hasProcessingCache() const
SourceLocation getUnavailableLoc() const
unsigned getProcessingCache() const
const IdentifierLoc * getEnvironment() const
bool acceptsExprPack() const
const Expr * getMessageExpr() const
const ParsedType & getMatchingCType() const
const ParsedType & getTypeArg() const
SourceLocation getStrictLoc() const
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this attribute.
bool isArgIdent(unsigned Arg) const
Expr * getArgAsExpr(unsigned Arg) const
bool getMustBeNull() const
bool checkAtLeastNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has at least as many args as Num.
bool isUsedAsTypeAttr() const
unsigned getNumArgMembers() const
bool isPragmaClangAttribute() const
True if the attribute is specified using '#pragma clang attribute'.
bool slidesFromDeclToDeclSpecLegacyBehavior() const
Returns whether a [[]] attribute, if specified ahead of a declaration, should be applied to the decl-...
AttributeCommonInfo::Kind getKind() const
void setProcessingCache(unsigned value) const
bool isParamExpr(size_t N) const
bool isArgExpr(unsigned Arg) const
bool getLayoutCompatible() const
ArgsUnion getArg(unsigned Arg) const
getArg - Return the specified argument.
SourceLocation getEllipsisLoc() const
bool checkAtMostNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has at most as many args as Num.
const AvailabilityChange & getAvailabilityObsoleted() const
void addAtEnd(ParsedAttr *newAttr)
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
IdentifierTable & getIdentifierTable()
A (possibly-)qualified type.
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.
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
const Type * getTypePtrOrNull() 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
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...
void handleAMDGPUMaxNumWorkGroupsAttr(Decl *D, const ParsedAttr &AL)
void handleAMDGPUFlatWorkGroupSizeAttr(Decl *D, const ParsedAttr &AL)
void handleAMDGPUNumSGPRAttr(Decl *D, const ParsedAttr &AL)
void handleAMDGPUNumVGPRAttr(Decl *D, const ParsedAttr &AL)
void handleAMDGPUWavesPerEUAttr(Decl *D, const ParsedAttr &AL)
void handleInterruptAttr(Decl *D, const ParsedAttr &AL)
void handleBuiltinAliasAttr(Decl *D, const ParsedAttr &AL)
void handleNewAttr(Decl *D, const ParsedAttr &AL)
bool SveAliasValid(unsigned BuiltinID, llvm::StringRef AliasName)
bool MveAliasValid(unsigned BuiltinID, llvm::StringRef AliasName)
void handleCmseNSEntryAttr(Decl *D, const ParsedAttr &AL)
bool CdeAliasValid(unsigned BuiltinID, llvm::StringRef AliasName)
void handleSignalAttr(Decl *D, const ParsedAttr &AL)
void handleInterruptAttr(Decl *D, const ParsedAttr &AL)
void handlePreserveAIRecord(RecordDecl *RD)
void handlePreserveAccessIndexAttr(Decl *D, const ParsedAttr &AL)
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...
void handleWaveSizeAttr(Decl *D, const ParsedAttr &AL)
void handleSV_GroupThreadIDAttr(Decl *D, const ParsedAttr &AL)
void handleShaderAttr(Decl *D, const ParsedAttr &AL)
void handleSV_DispatchThreadIDAttr(Decl *D, const ParsedAttr &AL)
void handlePackOffsetAttr(Decl *D, const ParsedAttr &AL)
void handleParamModifierAttr(Decl *D, const ParsedAttr &AL)
void handleResourceBindingAttr(Decl *D, const ParsedAttr &AL)
void handleNumThreadsAttr(Decl *D, const ParsedAttr &AL)
void handleSV_GroupIDAttr(Decl *D, const ParsedAttr &AL)
void handleInterruptAttr(Decl *D, const ParsedAttr &AL)
void handleInterruptAttr(Decl *D, const ParsedAttr &AL)
void handleInterruptAttr(Decl *D, const ParsedAttr &AL)
void handleRuntimeName(Decl *D, const ParsedAttr &AL)
void handleNSObject(Decl *D, const ParsedAttr &AL)
bool isValidOSObjectOutParameter(const Decl *D)
void handleNSErrorDomain(Decl *D, const ParsedAttr &Attr)
void handleXReturnsXRetainedAttr(Decl *D, const ParsedAttr &AL)
void handleExternallyRetainedAttr(Decl *D, const ParsedAttr &AL)
void handleMethodFamilyAttr(Decl *D, const ParsedAttr &AL)
void handleIndependentClass(Decl *D, const ParsedAttr &AL)
void handleIBOutlet(Decl *D, const ParsedAttr &AL)
void handleReturnsInnerPointerAttr(Decl *D, const ParsedAttr &Attrs)
void handleSuppresProtocolAttr(Decl *D, const ParsedAttr &AL)
void handleOwnershipAttr(Decl *D, const ParsedAttr &AL)
void handleBlocksAttr(Decl *D, const ParsedAttr &AL)
void handleBridgeMutableAttr(Decl *D, const ParsedAttr &AL)
Sema::RetainOwnershipKind parsedAttrToRetainOwnershipKind(const ParsedAttr &AL)
void handleRequiresSuperAttr(Decl *D, const ParsedAttr &Attrs)
void AddXConsumedAttr(Decl *D, const AttributeCommonInfo &CI, Sema::RetainOwnershipKind K, bool IsTemplateInstantiation)
void handleDesignatedInitializer(Decl *D, const ParsedAttr &AL)
void handleBridgeRelatedAttr(Decl *D, const ParsedAttr &AL)
void handleIBOutletCollection(Decl *D, const ParsedAttr &AL)
bool isCFStringType(QualType T)
void handleDirectAttr(Decl *D, const ParsedAttr &AL)
bool isNSStringType(QualType T, bool AllowNSAttributedString=false)
void handleBoxable(Decl *D, const ParsedAttr &AL)
void handleDirectMembersAttr(Decl *D, const ParsedAttr &AL)
void handleBridgeAttr(Decl *D, const ParsedAttr &AL)
void handlePreciseLifetimeAttr(Decl *D, const ParsedAttr &AL)
void handleSubGroupSize(Decl *D, const ParsedAttr &AL)
void handleNoSVMAttr(Decl *D, const ParsedAttr &AL)
void handleAccessAttr(Decl *D, const ParsedAttr &AL)
void handleOMPAssumeAttr(Decl *D, const ParsedAttr &AL)
bool isAliasValid(unsigned BuiltinID, llvm::StringRef AliasName)
void handleInterruptAttr(Decl *D, const ParsedAttr &AL)
void handleKernelEntryPointAttr(Decl *D, const ParsedAttr &AL)
void handleKernelAttr(Decl *D, const ParsedAttr &AL)
void handleBridge(Decl *D, const ParsedAttr &AL)
void handleAsyncAttr(Decl *D, const ParsedAttr &AL)
void handleAsyncName(Decl *D, const ParsedAttr &AL)
void handleNewType(Decl *D, const ParsedAttr &AL)
void handleError(Decl *D, const ParsedAttr &AL)
void AddParameterABIAttr(Decl *D, const AttributeCommonInfo &CI, ParameterABI abi)
void handleAsyncError(Decl *D, const ParsedAttr &AL)
void handleName(Decl *D, const ParsedAttr &AL)
void handleAttrAttr(Decl *D, const ParsedAttr &AL)
void handleWebAssemblyImportNameAttr(Decl *D, const ParsedAttr &AL)
void handleWebAssemblyImportModuleAttr(Decl *D, const ParsedAttr &AL)
void handleWebAssemblyExportNameAttr(Decl *D, const ParsedAttr &AL)
void handleForceAlignArgPointerAttr(Decl *D, const ParsedAttr &AL)
void handleAnyInterruptAttr(Decl *D, const ParsedAttr &AL)
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.
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 isValidPointerAttrType(QualType T, bool RefOkay=false)
Determine if type T is a valid subject for a nonnull and similar attributes.
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.
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 ...
bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl, const ParsedAttributesView &AttrList)
Annotation attributes are the only attributes allowed after an access specifier.
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...
bool checkTargetVersionAttr(SourceLocation Loc, Decl *D, StringRef Str)
Check Target Version attrs.
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.
void LazyProcessLifetimeCaptureByParams(FunctionDecl *FD)
DiagnosticsEngine & getDiagnostics() const
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...
QualType BuildCountAttributedArrayOrPointerType(QualType WrappedTy, Expr *CountExpr, bool CountInBytes, bool OrNull)
void ProcessPragmaWeak(Scope *S, Decl *D)
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 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)
bool CheckCountedByAttrOnField(FieldDecl *FD, Expr *E, bool CountInBytes, bool OrNull)
Check if applying the specified attribute variant from the "counted by" family of attributes to Field...
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...
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 ProcessDeclAttributeDelayed(Decl *D, const ParsedAttributesView &AttrList)
Helper for delayed processing TransparentUnion or BPFPreserveAccessIndexAttr attribute.
bool checkUInt32Argument(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...
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)
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)
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)
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
Attr * CreateAnnotationAttr(const AttributeCommonInfo &CI, StringRef Annot, MutableArrayRef< Expr * > Args)
CreateAnnotationAttr - Creates an annotation Annot with Args arguments.
bool checkTargetClonesAttrString(SourceLocation LiteralLoc, StringRef Str, const StringLiteral *Literal, Decl *D, bool &HasDefault, bool &HasCommas, bool &HasNotDefault, SmallVectorImpl< SmallString< 64 > > &StringsBuffer)
void handleDelayedAvailabilityCheck(sema::DelayedDiagnostic &DD, Decl *Ctx)
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in it, apply them to D.
void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, const WeakInfo &W)
DeclApplyPragmaWeak - A declaration (maybe definition) needs #pragma weak applied to it,...
AvailabilityAttr * mergeAvailabilityAttr(NamedDecl *D, const AttributeCommonInfo &CI, IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK, int Priority, IdentifierInfo *IIEnvironment)
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.
bool checkFunctionOrMethodParameterIndex(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.
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,...
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.
LifetimeCaptureByAttr * ParseLifetimeCaptureByAttr(const ParsedAttr &AL, StringRef ParamName)
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...
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.
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 uint64_t getFMVPriority(ArrayRef< StringRef > Features) const
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.).
Represents a type template specialization; the template must be a class template, a type alias templa...
const Type * getTypeForDecl() const
Base wrapper for a particular "section" of type source info.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
The base class of the type hierarchy.
bool isSizelessType() const
As an extension, we classify types as one of "sized" or "sizeless"; every type is one or the other.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isBlockPointerType() const
bool isBooleanType() const
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
bool 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
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 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 isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
bool isMemberPointerType() const
bool isPointerOrReferenceType() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
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 isTypedefNameType() const
Determines whether this type is written as a typedef-name.
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)
@ 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)
@ ExpectedFunctionMethodOrBlock
@ ExpectedTypeOrNamespace
@ ExpectedVariableFieldOrTag
@ ExpectedVariableOrField
@ ExpectedFunctionOrMethod
@ ExpectedFunctionOrClassOrEnum
@ ExpectedVariableOrFunction
@ ExpectedFunctionVariableOrClass
@ ExpectedNonMemberFunction
bool hasDeclarator(const Decl *D)
Return true if the given decl has a declarator that should have been processed by Sema::GetTypeForDec...
QualType getFunctionOrMethodResultType(const Decl *D)
bool isInstanceMethod(const Decl *D)
@ OK_Ordinary
An ordinary object is located at an address in memory.
CudaVersion ToCudaVersion(llvm::VersionTuple)
SourceRange getFunctionOrMethodResultSourceRange(const Decl *D)
bool isFunctionOrMethodOrBlockForAttrSubject(const Decl *D)
Return true if the given decl has function type (function or function-typed variable) or an Objective...
QualType getFunctionOrMethodParamType(const Decl *D, unsigned Idx)
@ 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).
@ Result
The result type of a method or function.
@ 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...
@ 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.
bool isFunctionOrMethodVariadic(const Decl *D)
bool isFuncOrMethodForAttrSubject(const Decl *D)
isFuncOrMethodForAttrSubject - Return true if the given decl has function type (function or function-...
OffloadArch StringToOffloadArch(llvm::StringRef S)
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.
const char * OffloadArchToString(OffloadArch A)
@ 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 hasFunctionProto(const Decl *D)
hasFunctionProto - Return true if the given decl has a argument information.
unsigned getFunctionOrMethodNumParams(const Decl *D)
getFunctionOrMethodNumParams - Return number of function or method parameters.
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
SourceRange getFunctionOrMethodParamRange(const Decl *D, unsigned Idx)
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
@ Union
The "union" keyword introduces the elaborated-type-specifier.
@ Other
Other implicit parameter.
@ Implicit
An implicit conversion.
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