61#include "llvm/ADT/STLExtras.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/ErrorHandling.h"
68#include "llvm/Support/MathExtras.h"
69#include "llvm/Support/raw_ostream.h"
70#include "llvm/TargetParser/Triple.h"
96template <
typename AttrInfo>
103 if (UVal > (uint32_t)std::numeric_limits<int>::max()) {
107 <<
toString(I, 10,
false) << 32 << 0;
116 const Expr *
E, StringRef &Str,
122 if (!Literal || (!Literal->isUnevaluated() && !Literal->isOrdinary())) {
128 Str = Literal->getString();
138 Diag(
Loc->getLoc(), diag::err_attribute_argument_type)
142 Str =
Loc->getIdentifierInfo()->getName();
144 *ArgLocation =
Loc->getLoc();
154 if (!Literal || (!Literal->isUnevaluated() && !Literal->isOrdinary())) {
159 Str = Literal->getString();
180 bool foundStarOperator = IsOverloadedOperatorPresent(
Record, OO_Star);
181 bool foundArrowOperator = IsOverloadedOperatorPresent(
Record, OO_Arrow);
182 if (foundStarOperator && foundArrowOperator)
189 for (
const auto &BaseSpecifier : CXXRecord->bases()) {
190 if (!foundStarOperator)
191 foundStarOperator = IsOverloadedOperatorPresent(
192 BaseSpecifier.getType()->getAsRecordDecl(), OO_Star);
193 if (!foundArrowOperator)
194 foundArrowOperator = IsOverloadedOperatorPresent(
195 BaseSpecifier.getType()->getAsRecordDecl(), OO_Arrow);
198 if (foundStarOperator && foundArrowOperator)
209 const auto *VD = cast<ValueDecl>(
D);
218 if (!RD->isCompleteDefinition())
225 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_decl_not_pointer) << AL << QT;
237 return PT->getPointeeType()->getAsRecordDecl();
242template <
typename AttrType>
249 if (
const auto *CRD = dyn_cast<CXXRecordDecl>(RD)) {
251 return !Base->hasAttr<AttrType>();
265 if (!RD->isCompleteDefinition())
273 return checkRecordDeclForAttr<CapabilityAttr>(RD);
283 if (!RD->isCompleteDefinition())
286 return checkRecordDeclForAttr<ScopedLockableAttr>(RD);
298 return TN->
hasAttr<CapabilityAttr>();
317 if (
const auto *
E = dyn_cast<CastExpr>(Ex))
319 else if (
const auto *
E = dyn_cast<ParenExpr>(Ex))
321 else if (
const auto *
E = dyn_cast<UnaryOperator>(Ex)) {
322 if (
E->getOpcode() == UO_LNot ||
E->getOpcode() == UO_AddrOf ||
323 E->getOpcode() == UO_Deref)
326 }
else if (
const auto *
E = dyn_cast<BinaryOperator>(Ex)) {
327 if (
E->getOpcode() == BO_LAnd ||
E->getOpcode() == BO_LOr)
345 bool ParamIdxOk =
false) {
350 const auto *MD = dyn_cast<const CXXMethodDecl>(
D);
351 if (MD && !MD->isStatic()) {
354 if (!checkRecordDeclForAttr<CapabilityAttr>(RD) &&
355 !checkRecordDeclForAttr<ScopedLockableAttr>(RD))
357 diag::warn_thread_attribute_not_on_capability_member)
358 << AL << MD->getParent();
360 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_not_on_non_static_member)
365 for (
unsigned Idx = Sidx; Idx < AL.
getNumArgs(); ++Idx) {
370 Args.push_back(ArgExp);
374 if (
const auto *StrLit = dyn_cast<StringLiteral>(ArgExp)) {
375 if (StrLit->getLength() == 0 ||
376 (StrLit->isOrdinary() && StrLit->getString() ==
"*")) {
379 Args.push_back(ArgExp);
385 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_ignored) << AL;
386 Args.push_back(ArgExp);
394 if (
const auto *UOp = dyn_cast<UnaryOperator>(ArgExp))
395 if (UOp->getOpcode() == UO_AddrOf)
396 if (
const auto *DRE = dyn_cast<DeclRefExpr>(UOp->getSubExpr()))
397 if (DRE->getDecl()->isCXXInstanceMember())
398 ArgTy = DRE->getDecl()->getType();
404 if (!RD && ParamIdxOk) {
405 const auto *FD = dyn_cast<FunctionDecl>(
D);
406 const auto *IL = dyn_cast<IntegerLiteral>(ArgExp);
408 unsigned int NumParams = FD->getNumParams();
409 llvm::APInt ArgValue = IL->getValue();
410 uint64_t ParamIdxFromOne = ArgValue.getZExtValue();
411 uint64_t ParamIdxFromZero = ParamIdxFromOne - 1;
412 if (!ArgValue.isStrictlyPositive() || ParamIdxFromOne > NumParams) {
414 diag::err_attribute_argument_out_of_bounds_extra_info)
415 << AL << Idx + 1 << NumParams;
418 ArgTy = FD->getParamDecl(ParamIdxFromZero)->getType();
427 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_argument_not_lockable)
430 Args.push_back(ArgExp);
442 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_not_on_scoped_lockable_param)
463 unsigned Size = Args.size();
497 QualType QT = cast<ValueDecl>(
D)->getType();
499 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_decl_not_lockable) << AL;
516 Expr **StartArg = &Args[0];
518 AcquiredAfterAttr(S.
Context, AL, StartArg, Args.size()));
526 Expr **StartArg = &Args[0];
528 AcquiredBeforeAttr(S.
Context, AL, StartArg, Args.size()));
545template <
typename AttrInfo>
547 unsigned AttrArgNo) {
548 assert(AI.isArgExpr(AttrArgNo) &&
"Expected expression argument");
549 Expr *AttrArg = AI.getArgAsExpr(AttrArgNo);
558 S.
Diag(SrcLoc, diag::err_attribute_integers_only)
573 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only) << AL;
599 AllocSizeAttr(S.
Context, AL, SizeArgNo, NumberArgNo));
608 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
623 unsigned Size = Args.size();
631 if (
const auto *ParmDecl = dyn_cast<ParmVarDecl>(
D);
641 unsigned Size = Args.size();
644 Expr **StartArg = &Args[0];
647 LocksExcludedAttr(S.
Context, AL, StartArg, Size));
651 Expr *&Cond, StringRef &Msg) {
657 Cond = Converted.
get();
664 Msg =
"<no message provided>";
670 S.
Diag(AL.
getLoc(), diag::err_attr_cond_never_constant_expr) << AL;
672 S.
Diag(PDiag.first, PDiag.second);
679 S.
Diag(AL.
getLoc(), diag::ext_clang_enable_if);
688 StringRef NewUserDiagnostic;
697 const auto *PD = isa<CXXRecordDecl>(
D)
698 ? cast<DeclContext>(
D)
700 if (
const auto *RD = dyn_cast<CXXRecordDecl>(PD); RD && RD->isLocalClass()) {
702 diag::warn_attribute_exclude_from_explicit_instantiation_local_class)
703 << AL << !isa<CXXRecordDecl>(
D);
707 ExcludeFromExplicitInstantiationAttr(S.
Context, AL));
723 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD))
731 bool referencesArgs(
Expr *
E) {
739 "`this` doesn't refer to the enclosing class?");
745 if (
const auto *PVD = dyn_cast<ParmVarDecl>(DRE->
getDecl()))
746 if (Parms.count(PVD)) {
757 const auto *DeclFD = cast<FunctionDecl>(
D);
759 if (
const auto *MethodDecl = dyn_cast<CXXMethodDecl>(DeclFD))
760 if (!MethodDecl->isStatic()) {
761 S.
Diag(AL.
getLoc(), diag::err_attribute_no_member_function) << AL;
768 if (
auto *
E = dyn_cast<Expr *>(
Union))
770 return cast<IdentifierLoc *>(
Union)->getLoc();
773 S.
Diag(
Loc, diag::err_attribute_argument_n_type) << AL << Index <<
T;
779 auto *F = dyn_cast_if_present<DeclRefExpr>(AL.
getArgAsExpr(0));
782 return dyn_cast_if_present<FunctionDecl>(F->getFoundDecl());
791 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments_for)
798 for (
unsigned I = 1; I < AL.
getNumArgs(); ++I) {
810 if (Index > DeclFD->getNumParams()) {
811 S.
Diag(AL.
getLoc(), diag::err_attribute_bounds_for_function)
812 << AL << Index << DeclFD << DeclFD->getNumParams();
817 QualType T2 = DeclFD->getParamDecl(Index - 1)->getType();
822 << AL << Index << DeclFD << T2 << I << AttrFD << T1;
826 Indices.push_back(Index - 1);
830 S.
Context, AL, AttrFD, Indices.data(), Indices.size()));
834 S.
Diag(AL.
getLoc(), diag::ext_clang_diagnose_if);
841 StringRef DefaultSevStr;
845 DiagnoseIfAttr::DefaultSeverity DefaultSev;
846 if (!DiagnoseIfAttr::ConvertStrToDefaultSeverity(DefaultSevStr, DefaultSev)) {
848 diag::err_diagnose_if_invalid_diagnostic_type);
852 StringRef WarningGroup;
856 if (WarningGroup.empty() ||
860 diag::err_diagnose_if_unknown_warning)
866 bool ArgDependent =
false;
867 if (
const auto *FD = dyn_cast<FunctionDecl>(
D))
868 ArgDependent = ArgumentDependenceChecker(FD).referencesArgs(Cond);
870 S.
Context, AL, Cond, Msg, DefaultSev, WarningGroup, ArgDependent,
871 cast<NamedDecl>(
D)));
879 if (!isa<ObjCMethodDecl>(
D)) {
880 S.
Diag(Attrs.
getLoc(), diag::warn_attribute_wrong_decl_type)
890 static constexpr const StringRef kWildcard =
"*";
893 bool HasWildcard =
false;
895 const auto AddBuiltinName = [&Names, &HasWildcard](StringRef Name) {
896 if (Name == kWildcard)
898 Names.push_back(Name);
902 if (
const auto *NBA =
D->
getAttr<NoBuiltinAttr>())
903 for (StringRef BuiltinName : NBA->builtinNames())
904 AddBuiltinName(BuiltinName);
908 AddBuiltinName(kWildcard);
910 for (
unsigned I = 0,
E = AL.
getNumArgs(); I !=
E; ++I) {
911 StringRef BuiltinName;
917 AddBuiltinName(BuiltinName);
919 S.
Diag(LiteralLoc, diag::warn_attribute_no_builtin_invalid_builtin_name)
920 << BuiltinName << AL;
925 Names.erase(llvm::unique(Names), Names.end());
928 if (HasWildcard && Names.size() > 1)
930 diag::err_attribute_no_builtin_wildcard_or_builtin_name)
936 NoBuiltinAttr(S.
Context, AL, Names.data(), Names.size()));
940 if (
D->
hasAttr<PassObjectSizeAttr>()) {
941 S.
Diag(
D->
getBeginLoc(), diag::err_attribute_only_once_per_parameter) << AL;
963 if (!cast<ParmVarDecl>(
D)->getType()->isPointerType()) {
972 ConsumableAttr::ConsumedState DefaultState;
976 if (!ConsumableAttr::ConvertStrToConsumedState(
978 S.
Diag(IL->
getLoc(), diag::warn_attribute_type_not_supported)
983 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
996 if (!RD->hasAttr<ConsumableAttr>()) {
997 S.
Diag(AL.
getLoc(), diag::warn_attr_on_unconsumable_class) << RD;
1014 for (
unsigned ArgIndex = 0; ArgIndex < AL.
getNumArgs(); ++ArgIndex) {
1015 CallableWhenAttr::ConsumedState CallableState;
1017 StringRef StateString;
1028 if (!CallableWhenAttr::ConvertStrToConsumedState(StateString,
1030 S.
Diag(
Loc, diag::warn_attribute_type_not_supported) << AL << StateString;
1034 States.push_back(CallableState);
1038 CallableWhenAttr(S.
Context, AL, States.data(), States.size()));
1042 ParamTypestateAttr::ConsumedState ParamState;
1048 if (!ParamTypestateAttr::ConvertStrToConsumedState(StateString,
1050 S.
Diag(Ident->
getLoc(), diag::warn_attribute_type_not_supported)
1051 << AL << StateString;
1055 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1076 ReturnTypestateAttr::ConsumedState ReturnState;
1080 if (!ReturnTypestateAttr::ConvertStrToConsumedState(
1082 S.
Diag(IL->
getLoc(), diag::warn_attribute_type_not_supported)
1087 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1124 SetTypestateAttr::ConsumedState NewState;
1128 if (!SetTypestateAttr::ConvertStrToConsumedState(Param, NewState)) {
1129 S.
Diag(Ident->
getLoc(), diag::warn_attribute_type_not_supported)
1134 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1146 TestTypestateAttr::ConsumedState TestState;
1150 if (!TestTypestateAttr::ConvertStrToConsumedState(Param, TestState)) {
1151 S.
Diag(Ident->
getLoc(), diag::warn_attribute_type_not_supported)
1156 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1166 if (isa<TypedefNameDecl>(
D))
1171 if (
auto *TD = dyn_cast<TagDecl>(
D))
1173 else if (
auto *FD = dyn_cast<FieldDecl>(
D)) {
1180 if (BitfieldByteAligned)
1182 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored_for_field_of_type)
1188 if (BitfieldByteAligned)
1189 S.
Diag(AL.
getLoc(), diag::warn_attribute_packed_for_bitfield);
1195 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored) << AL;
1199 auto *RD = cast<CXXRecordDecl>(
D);
1201 assert(CTD &&
"attribute does not appertain to this declaration");
1212 if (
const auto *CTSD = dyn_cast_if_present<ClassTemplateSpecializationDecl>(
1214 Template = CTSD->getSpecializedTemplate();
1216 while (TST && TST->isTypeAlias())
1219 Template = TST->getTemplateName().getAsTemplateDecl();
1228 S.
Diag(AL.
getLoc(), diag::err_attribute_not_typedef_for_specialization)
1231 S.
Diag(TT->getDecl()->getLocation(), diag::note_entity_declared_at)
1240 NoSpecializationsAttr::Create(S.
Context, Message, AL));
1250 T =
T.getNonReferenceType();
1257 if (UD->
hasAttr<TransparentUnionAttr>()) {
1258 for (
const auto *I : UD->
fields()) {
1272 bool isReturnValue =
false) {
1275 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only)
1276 << AL << AttrParmRange << TypeRange;
1278 S.
Diag(AL.
getLoc(), diag::warn_attribute_pointers_only)
1279 << AL << AttrParmRange << TypeRange << 0;
1287 for (
unsigned I = 0; I < AL.
getNumArgs(); ++I) {
1291 D, AL, I + 1, Ex, Idx,
1304 NonNullArgs.push_back(Idx);
1315 I !=
E && !AnyPointers; ++I) {
1322 S.
Diag(AL.
getLoc(), diag::warn_attribute_nonnull_no_pointers);
1325 ParamIdx *Start = NonNullArgs.data();
1326 unsigned Size = NonNullArgs.size();
1327 llvm::array_pod_sort(Start, Start + Size);
1337 S.
Diag(AL.
getLoc(), diag::warn_attribute_nonnull_parm_no_args)
1366 QualType T = cast<ParmVarDecl>(
D)->getType();
1368 S.
Diag(AL.
getLoc(), diag::warn_attribute_pointers_only)
1393 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
1399 std::optional<llvm::APSInt> I = llvm::APSInt(64);
1402 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1405 Diag(AttrLoc, diag::err_attribute_argument_type)
1410 if (!I->isPowerOf2()) {
1411 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
1417 Diag(CI.
getLoc(), diag::warn_assume_aligned_too_great)
1422 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1436 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
1442 const auto *FuncDecl = cast<FunctionDecl>(
D);
1451 << CI << FuncDecl->getParamDecl(Idx.
getASTIndex())->getSourceRange();
1461 if (AttrName.size() > 4 && AttrName.starts_with(
"__") &&
1462 AttrName.ends_with(
"__")) {
1463 AttrName = AttrName.drop_front(2).drop_back(2);
1479 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
1485 OwnershipAttr::OwnershipKind K =
1486 OwnershipAttr(S.
Context, AL,
nullptr,
nullptr, 0).getOwnKind();
1490 case OwnershipAttr::Takes:
1491 case OwnershipAttr::Holds:
1493 S.
Diag(AL.
getLoc(), diag::err_attribute_too_few_arguments) << AL << 2;
1497 case OwnershipAttr::Returns:
1499 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 2;
1507 if (K == OwnershipAttr::Returns &&
1509 S.
Diag(AL.
getLoc(), diag::err_ownership_takes_return_type) << AL;
1515 StringRef ModuleName =
Module->getName();
1521 for (
unsigned i = 1; i < AL.
getNumArgs(); ++i) {
1531 case OwnershipAttr::Takes:
1532 case OwnershipAttr::Holds:
1536 case OwnershipAttr::Returns:
1542 S.
Diag(AL.
getLoc(), diag::err_ownership_type) << AL << Err
1551 if (I->getOwnKind() != K && llvm::is_contained(I->args(), Idx)) {
1552 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
1555 I->isRegularKeywordAttribute());
1557 }
else if (K == OwnershipAttr::Returns &&
1558 I->getOwnKind() == OwnershipAttr::Returns) {
1561 if (!llvm::is_contained(I->args(), Idx)) {
1562 S.
Diag(I->getLocation(), diag::err_ownership_returns_index_mismatch)
1563 << I->args_begin()->getSourceIndex();
1565 S.
Diag(AL.
getLoc(), diag::note_ownership_returns_index_mismatch)
1569 }
else if (K == OwnershipAttr::Takes &&
1570 I->getOwnKind() == OwnershipAttr::Takes) {
1571 if (I->getModule()->getName() != ModuleName) {
1572 S.
Diag(I->getLocation(), diag::err_ownership_takes_class_mismatch)
1573 << I->getModule()->getName();
1574 S.
Diag(AL.
getLoc(), diag::note_ownership_takes_class_mismatch)
1581 OwnershipArgs.push_back(Idx);
1584 ParamIdx *Start = OwnershipArgs.data();
1585 unsigned Size = OwnershipArgs.size();
1586 llvm::array_pod_sort(Start, Start + Size);
1594 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
1609 if (!Ctx->isFileContext()) {
1610 S.
Diag(AL.
getLoc(), diag::err_attribute_weakref_not_global_context)
1611 << cast<NamedDecl>(
D);
1655 std::unique_ptr<char, llvm::FreeDeleter> Demangled;
1657 Demangled.reset(llvm::itaniumDemangle(Str,
false));
1666 if (!isa<FunctionDecl>(ND) && !isa<VarDecl>(ND))
1668 if (MC->shouldMangleDeclName(ND)) {
1669 llvm::raw_svector_ostream Out(Name);
1673 Name = ND->getIdentifier()->getName();
1687 const auto *FD = cast<FunctionDecl>(
D);
1689 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << FD << 1;
1703 S.
Diag(AL.
getLoc(), diag::err_alias_not_supported_on_darwin);
1711 S.
Diag(AL.
getLoc(), diag::err_alias_not_supported_on_nvptx);
1715 if (
const auto *FD = dyn_cast<FunctionDecl>(
D)) {
1717 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << FD << 0;
1721 const auto *VD = cast<VarDecl>(
D);
1722 if (VD->isThisDeclarationADefinition() && VD->isExternallyVisible()) {
1723 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << VD << 0;
1740 if (Model !=
"global-dynamic" && Model !=
"local-dynamic"
1741 && Model !=
"initial-exec" && Model !=
"local-exec") {
1742 S.
Diag(LiteralLoc, diag::err_attr_tlsmodel_arg);
1752 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only)
1764 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 0;
1774 if (
auto *DRE = dyn_cast<DeclRefExpr>(DeallocE)) {
1775 DeallocFD = dyn_cast<FunctionDecl>(DRE->
getDecl());
1778 S.
Diag(DeallocLoc, diag::err_attribute_malloc_arg_not_function)
1782 }
else if (
auto *ULE = dyn_cast<UnresolvedLookupExpr>(DeallocE)) {
1784 DeallocNI = ULE->getNameInfo();
1786 S.
Diag(DeallocLoc, diag::err_attribute_malloc_arg_not_function)
1793 S.
Diag(DeallocLoc, diag::err_attribute_malloc_arg_not_function) << 0;
1801 DeallocPtrIdx =
ParamIdx(1, DeallocFD);
1803 if (!DeallocPtrIdx.
isValid() ||
1808 diag::err_attribute_malloc_arg_not_function_with_pointer_arg)
1822 diag::err_attribute_malloc_arg_refers_to_non_pointer_type)
1831 S.
Diag(AL.
getLoc(), diag::warn_attribute_form_ignored) << AL;
1833 RestrictAttr(S.
Context, AL, DeallocE, DeallocPtrIdx));
1840 if (checkAttrMutualExclusion<CPUSpecificAttr>(S,
D, AL))
1844 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
1845 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
1848 }
else if (AL.
getParsedKind() == ParsedAttr::AT_CPUSpecific) {
1849 if (checkAttrMutualExclusion<CPUDispatchAttr>(S,
D, AL))
1853 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
1854 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
1861 if (
const auto *MD = dyn_cast<CXXMethodDecl>(
D)) {
1862 if (MD->getParent()->isLambda()) {
1863 S.
Diag(AL.
getLoc(), diag::err_attribute_dll_lambda) << AL;
1874 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1883 S.
Diag(CPUArg->
getLoc(), diag::err_invalid_cpu_specific_dispatch_value)
1884 << CPUName << (AL.
getKind() == ParsedAttr::AT_CPUDispatch);
1890 return Target.CPUSpecificManglingCharacter(CPUName) ==
1893 S.
Diag(AL.
getLoc(), diag::warn_multiversion_duplicate_entries);
1900 if (AL.
getKind() == ParsedAttr::AT_CPUSpecific)
1902 CPUSpecificAttr(S.
Context, AL, CPUs.data(), CPUs.size()));
1905 CPUDispatchAttr(S.
Context, AL, CPUs.data(), CPUs.size()));
1910 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
1921 const auto &
Arch = Triple.getArch();
1922 if (
Arch != llvm::Triple::x86 &&
1923 (
Arch != llvm::Triple::arm &&
Arch != llvm::Triple::thumb)) {
1924 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_on_arch)
1925 << AL << Triple.getArchName();
1931 if (S.
getLangOpts().MSVCCompat && isa<CXXMethodDecl>(
D)) {
1932 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_decl_type)
1949 const Stmt *OnlyStmt =
nullptr;
1951 if (
const auto *Compound = dyn_cast<CompoundStmt>(Body)) {
1952 if (Compound->size() != 1)
1954 OnlyStmt = *Compound->body_begin();
1960 if (
const auto *EWC = dyn_cast<ExprWithCleanups>(OnlyStmt)) {
1961 OnlyStmt = EWC->getSubExpr();
1964 return isa<CXXThrowExpr>(OnlyStmt);
1968 auto *FD = dyn_cast<FunctionDecl>(
D);
1987 NonConstFD->addAttr(InferredNoReturnAttr::CreateImplicit(S.
Context));
1990 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD);
2003 if (!isa<ObjCMethodDecl>(
D)) {
2004 S.
Diag(Attrs.
getLoc(), diag::warn_attribute_wrong_decl_type)
2030 S.
Diag(Attrs.
getLoc(), diag::warn_nocf_check_attribute_ignored);
2032 handleSimpleAttribute<AnyX86NoCfCheckAttr>(S,
D, Attrs);
2048 Diag(AL.
getLoc(), diag::err_keyword_not_supported_on_target)
2067 ? diag::err_attribute_wrong_decl_type
2068 : diag::warn_attribute_wrong_decl_type)
2104 if (VecReturnAttr *A =
D->
getAttr<VecReturnAttr>()) {
2105 S.
Diag(AL.
getLoc(), diag::err_repeat_attribute) << A;
2109 const auto *R = cast<RecordDecl>(
D);
2112 if (!isa<CXXRecordDecl>(R)) {
2113 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
2117 if (!cast<CXXRecordDecl>(R)->isPOD()) {
2118 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_pod_record);
2122 for (
const auto *I : R->fields()) {
2123 if ((count == 1) || !I->getType()->isVectorType()) {
2124 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
2135 if (isa<ParmVarDecl>(
D)) {
2140 diag::err_carries_dependency_param_not_function_decl);
2154 S.
Diag(AL.
getLoc(), diag::ext_cxx17_attr) << AL;
2160 uint32_t priority = ConstructorAttr::DefaultPriority;
2162 S.
Diag(AL.
getLoc(), diag::err_hlsl_init_priority_unsupported);
2175 uint32_t priority = DestructorAttr::DefaultPriority;
2184template <
typename AttrTy>
2196 VersionTuple Introduced,
2197 VersionTuple Deprecated,
2198 VersionTuple Obsoleted) {
2199 StringRef PlatformName
2200 = AvailabilityAttr::getPrettyPlatformName(Platform->
getName());
2201 if (PlatformName.empty())
2202 PlatformName = Platform->
getName();
2206 if (!Introduced.empty() && !Deprecated.empty() &&
2207 !(Introduced <= Deprecated)) {
2209 << 1 << PlatformName << Deprecated.getAsString()
2210 << 0 << Introduced.getAsString();
2214 if (!Introduced.empty() && !Obsoleted.empty() &&
2215 !(Introduced <= Obsoleted)) {
2217 << 2 << PlatformName << Obsoleted.getAsString()
2218 << 0 << Introduced.getAsString();
2222 if (!Deprecated.empty() && !Obsoleted.empty() &&
2223 !(Deprecated <= Obsoleted)) {
2225 << 2 << PlatformName << Obsoleted.getAsString()
2226 << 1 << Deprecated.getAsString();
2238 bool BeforeIsOkay) {
2239 if (
X.empty() || Y.empty())
2245 if (BeforeIsOkay &&
X < Y)
2253 bool Implicit, VersionTuple Introduced, VersionTuple Deprecated,
2254 VersionTuple Obsoleted,
bool IsUnavailable, StringRef Message,
2257 VersionTuple MergedIntroduced = Introduced;
2258 VersionTuple MergedDeprecated = Deprecated;
2259 VersionTuple MergedObsoleted = Obsoleted;
2260 bool FoundAny =
false;
2261 bool OverrideOrImpl =
false;
2265 OverrideOrImpl =
false;
2271 OverrideOrImpl =
true;
2277 for (
unsigned i = 0, e = Attrs.size(); i != e;) {
2278 const auto *OldAA = dyn_cast<AvailabilityAttr>(Attrs[i]);
2285 if (OldPlatform != Platform) {
2291 if (OldEnvironment != Environment) {
2299 if (OldAA->getPriority() <
Priority)
2305 if (OldAA->getPriority() >
Priority) {
2306 Attrs.erase(Attrs.begin() + i);
2312 VersionTuple OldIntroduced = OldAA->getIntroduced();
2313 VersionTuple OldDeprecated = OldAA->getDeprecated();
2314 VersionTuple OldObsoleted = OldAA->getObsoleted();
2315 bool OldIsUnavailable = OldAA->getUnavailable();
2317 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl) ||
2318 !
versionsMatch(Deprecated, OldDeprecated, OverrideOrImpl) ||
2320 !(OldIsUnavailable == IsUnavailable ||
2321 (OverrideOrImpl && !OldIsUnavailable && IsUnavailable))) {
2322 if (OverrideOrImpl) {
2324 VersionTuple FirstVersion;
2325 VersionTuple SecondVersion;
2326 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl)) {
2328 FirstVersion = OldIntroduced;
2329 SecondVersion = Introduced;
2330 }
else if (!
versionsMatch(Deprecated, OldDeprecated, OverrideOrImpl)) {
2332 FirstVersion = Deprecated;
2333 SecondVersion = OldDeprecated;
2334 }
else if (!
versionsMatch(Obsoleted, OldObsoleted, OverrideOrImpl)) {
2336 FirstVersion = Obsoleted;
2337 SecondVersion = OldObsoleted;
2341 Diag(OldAA->getLocation(),
2342 diag::warn_mismatched_availability_override_unavail)
2343 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2355 Diag(OldAA->getLocation(),
2356 diag::warn_mismatched_availability_override)
2358 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2359 << FirstVersion.getAsString() << SecondVersion.getAsString()
2363 Diag(CI.
getLoc(), diag::note_overridden_method);
2365 Diag(CI.
getLoc(), diag::note_protocol_method);
2367 Diag(OldAA->getLocation(), diag::warn_mismatched_availability);
2368 Diag(CI.
getLoc(), diag::note_previous_attribute);
2371 Attrs.erase(Attrs.begin() + i);
2376 VersionTuple MergedIntroduced2 = MergedIntroduced;
2377 VersionTuple MergedDeprecated2 = MergedDeprecated;
2378 VersionTuple MergedObsoleted2 = MergedObsoleted;
2380 if (MergedIntroduced2.empty())
2381 MergedIntroduced2 = OldIntroduced;
2382 if (MergedDeprecated2.empty())
2383 MergedDeprecated2 = OldDeprecated;
2384 if (MergedObsoleted2.empty())
2385 MergedObsoleted2 = OldObsoleted;
2388 MergedIntroduced2, MergedDeprecated2,
2389 MergedObsoleted2)) {
2390 Attrs.erase(Attrs.begin() + i);
2395 MergedIntroduced = MergedIntroduced2;
2396 MergedDeprecated = MergedDeprecated2;
2397 MergedObsoleted = MergedObsoleted2;
2403 MergedIntroduced == Introduced &&
2404 MergedDeprecated == Deprecated &&
2405 MergedObsoleted == Obsoleted)
2411 MergedDeprecated, MergedObsoleted) &&
2413 auto *Avail = ::new (
Context) AvailabilityAttr(
2414 Context, CI, Platform, Introduced, Deprecated, Obsoleted, IsUnavailable,
2415 Message, IsStrict, Replacement,
Priority, Environment);
2423 if (isa<UsingDecl, UnresolvedUsingTypenameDecl, UnresolvedUsingValueDecl>(
2435 StringRef PrettyName = AvailabilityAttr::getPrettyPlatformName(II->
getName());
2436 if (PrettyName.empty())
2437 S.
Diag(Platform->
getLoc(), diag::warn_availability_unknown_platform)
2440 auto *ND = dyn_cast<NamedDecl>(
D);
2448 const llvm::Triple::OSType PlatformOS = AvailabilityAttr::getOSType(
2449 AvailabilityAttr::canonicalizePlatformName(II->
getName()));
2451 auto reportAndUpdateIfInvalidOS = [&](
auto &InputVersion) ->
void {
2452 const bool IsInValidRange =
2453 llvm::Triple::isValidVersionForOS(PlatformOS, InputVersion);
2455 auto CanonicalVersion = llvm::Triple::getCanonicalVersionForOS(
2456 PlatformOS, InputVersion, IsInValidRange);
2457 if (!IsInValidRange) {
2458 S.
Diag(Platform->
getLoc(), diag::warn_availability_invalid_os_version)
2459 << InputVersion.getAsString() << PrettyName;
2461 diag::note_availability_invalid_os_version_adjusted)
2462 << CanonicalVersion.getAsString();
2464 InputVersion = CanonicalVersion;
2467 if (PlatformOS != llvm::Triple::OSType::UnknownOS) {
2468 reportAndUpdateIfInvalidOS(Introduced.
Version);
2469 reportAndUpdateIfInvalidOS(Deprecated.
Version);
2470 reportAndUpdateIfInvalidOS(Obsoleted.
Version);
2476 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getMessageExpr()))
2477 Str = SE->getString();
2478 StringRef Replacement;
2479 if (
const auto *SE =
2481 Replacement = SE->getString();
2483 if (II->
isStr(
"swift")) {
2485 (!IsUnavailable && !Deprecated.
isValid())) {
2487 diag::warn_availability_swift_unavailable_deprecated_only);
2492 if (II->
isStr(
"fuchsia")) {
2493 std::optional<unsigned>
Min, Sub;
2495 (Sub = Introduced.
Version.getSubminor())) {
2496 S.
Diag(AL.
getLoc(), diag::warn_availability_fuchsia_unavailable_minor);
2511 if (EnvironmentLoc) {
2514 if (AvailabilityAttr::getEnvironmentType(
2516 llvm::Triple::EnvironmentType::UnknownEnvironment)
2518 diag::warn_availability_unknown_environment)
2522 diag::err_availability_unexpected_parameter)
2523 <<
"environment" << 1;
2529 Obsoleted.
Version, IsUnavailable, Str, IsStrict, Replacement,
2540 else if (II->
getName() ==
"ios_app_extension")
2545 const auto *IOSToWatchOSMapping =
2550 auto adjustWatchOSVersion =
2551 [IOSToWatchOSMapping](VersionTuple Version) -> VersionTuple {
2552 if (Version.empty())
2554 auto MinimumWatchOSVersion = VersionTuple(2, 0);
2556 if (IOSToWatchOSMapping) {
2557 if (
auto MappedVersion = IOSToWatchOSMapping->map(
2558 Version, MinimumWatchOSVersion, std::nullopt)) {
2559 return *MappedVersion;
2563 auto Major = Version.getMajor();
2564 auto NewMajor = Major;
2567 else if (Major < 12)
2568 NewMajor = Major - 7;
2569 if (NewMajor >= 2) {
2570 if (Version.getMinor()) {
2571 if (Version.getSubminor())
2572 return VersionTuple(NewMajor, *Version.getMinor(),
2573 *Version.getSubminor());
2575 return VersionTuple(NewMajor, *Version.getMinor());
2577 return VersionTuple(NewMajor);
2580 return MinimumWatchOSVersion;
2583 auto NewIntroduced = adjustWatchOSVersion(Introduced.
Version);
2584 auto NewDeprecated = adjustWatchOSVersion(Deprecated.
Version);
2585 auto NewObsoleted = adjustWatchOSVersion(Obsoleted.
Version);
2588 ND, AL, NewII,
true , NewIntroduced, NewDeprecated,
2589 NewObsoleted, IsUnavailable, Str, IsStrict, Replacement,
2601 else if (II->
getName() ==
"ios_app_extension")
2606 const auto *IOSToTvOSMapping =
2611 auto AdjustTvOSVersion =
2612 [IOSToTvOSMapping](VersionTuple Version) -> VersionTuple {
2613 if (Version.empty())
2616 if (IOSToTvOSMapping) {
2617 if (
auto MappedVersion = IOSToTvOSMapping->map(
2618 Version, VersionTuple(0, 0), std::nullopt)) {
2619 return *MappedVersion;
2625 auto NewIntroduced = AdjustTvOSVersion(Introduced.
Version);
2626 auto NewDeprecated = AdjustTvOSVersion(Deprecated.
Version);
2627 auto NewObsoleted = AdjustTvOSVersion(Obsoleted.
Version);
2630 ND, AL, NewII,
true , NewIntroduced, NewDeprecated,
2631 NewObsoleted, IsUnavailable, Str, IsStrict, Replacement,
2638 llvm::Triple::IOS &&
2640 auto GetSDKInfo = [&]() {
2649 else if (II->
getName() ==
"ios_app_extension")
2652 auto MinMacCatalystVersion = [](
const VersionTuple &
V) {
2655 if (
V.getMajor() < 13 ||
2656 (
V.getMajor() == 13 &&
V.getMinor() && *
V.getMinor() < 1))
2657 return VersionTuple(13, 1);
2661 ND, AL, NewII,
true ,
2662 MinMacCatalystVersion(Introduced.
Version),
2663 MinMacCatalystVersion(Deprecated.
Version),
2664 MinMacCatalystVersion(Obsoleted.
Version), IsUnavailable, Str,
2669 }
else if (II->
getName() ==
"macos" && GetSDKInfo() &&
2671 !Obsoleted.
Version.empty())) {
2672 if (
const auto *MacOStoMacCatalystMapping =
2673 GetSDKInfo()->getVersionMapping(
2680 auto RemapMacOSVersion =
2681 [&](
const VersionTuple &
V) -> std::optional<VersionTuple> {
2683 return std::nullopt;
2685 if (
V.getMajor() == 100000)
2686 return VersionTuple(100000);
2688 return MacOStoMacCatalystMapping->map(
V, VersionTuple(13, 1),
2691 std::optional<VersionTuple> NewIntroduced =
2692 RemapMacOSVersion(Introduced.
Version),
2694 RemapMacOSVersion(Deprecated.
Version),
2696 RemapMacOSVersion(Obsoleted.
Version);
2697 if (NewIntroduced || NewDeprecated || NewObsoleted) {
2698 auto VersionOrEmptyVersion =
2699 [](
const std::optional<VersionTuple> &
V) -> VersionTuple {
2700 return V ? *
V : VersionTuple();
2703 ND, AL, NewII,
true ,
2704 VersionOrEmptyVersion(NewIntroduced),
2705 VersionOrEmptyVersion(NewDeprecated),
2706 VersionOrEmptyVersion(NewObsoleted),
false, Str,
2725 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(0)))
2727 StringRef DefinedIn;
2728 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(1)))
2729 DefinedIn = SE->getString();
2730 bool IsGeneratedDeclaration = AL.
getArgAsIdent(2) !=
nullptr;
2732 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(3)))
2733 USR = SE->getString();
2741 typename T::VisibilityType value) {
2744 typename T::VisibilityType existingValue = existingAttr->
getVisibility();
2745 if (existingValue == value)
2747 S.
Diag(existingAttr->getLocation(), diag::err_mismatched_visibility);
2748 S.
Diag(CI.
getLoc(), diag::note_previous_attribute);
2756 VisibilityAttr::VisibilityType Vis) {
2757 return ::mergeVisibilityAttr<VisibilityAttr>(*
this,
D, CI, Vis);
2762 TypeVisibilityAttr::VisibilityType Vis) {
2763 return ::mergeVisibilityAttr<TypeVisibilityAttr>(*
this,
D, CI, Vis);
2767 bool isTypeVisibility) {
2769 if (isa<TypedefNameDecl>(
D)) {
2775 if (isTypeVisibility && !(isa<TagDecl>(
D) || isa<ObjCInterfaceDecl>(
D) ||
2776 isa<NamespaceDecl>(
D))) {
2788 VisibilityAttr::VisibilityType
type;
2789 if (!VisibilityAttr::ConvertStrToVisibilityType(TypeStr,
type)) {
2790 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported) << AL
2797 if (
type == VisibilityAttr::Protected &&
2799 S.
Diag(AL.
getLoc(), diag::warn_attribute_protected_visibility);
2800 type = VisibilityAttr::Default;
2804 if (isTypeVisibility) {
2806 D, AL, (TypeVisibilityAttr::VisibilityType)
type);
2815 unsigned sentinel = (
unsigned)SentinelAttr::DefaultSentinel;
2818 std::optional<llvm::APSInt> Idx = llvm::APSInt(32);
2820 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
2825 if (Idx->isSigned() && Idx->isNegative()) {
2826 S.
Diag(AL.
getLoc(), diag::err_attribute_sentinel_less_than_zero)
2831 sentinel = Idx->getZExtValue();
2834 unsigned nullPos = (
unsigned)SentinelAttr::DefaultNullPos;
2837 std::optional<llvm::APSInt> Idx = llvm::APSInt(32);
2839 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
2843 nullPos = Idx->getZExtValue();
2845 if ((Idx->isSigned() && Idx->isNegative()) || nullPos > 1) {
2848 S.
Diag(AL.
getLoc(), diag::err_attribute_sentinel_not_zero_or_one)
2854 if (
const auto *FD = dyn_cast<FunctionDecl>(
D)) {
2856 if (isa<FunctionNoProtoType>(FT)) {
2857 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_named_arguments);
2861 if (!cast<FunctionProtoType>(FT)->isVariadic()) {
2862 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
2865 }
else if (
const auto *MD = dyn_cast<ObjCMethodDecl>(
D)) {
2866 if (!MD->isVariadic()) {
2867 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
2870 }
else if (
const auto *BD = dyn_cast<BlockDecl>(
D)) {
2871 if (!BD->isVariadic()) {
2872 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 1;
2875 }
else if (
const auto *
V = dyn_cast<VarDecl>(
D)) {
2883 if (!cast<FunctionProtoType>(FT)->isVariadic()) {
2885 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << m;
2889 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
2895 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
2906 !isa<CXXConstructorDecl>(
D)) {
2907 S.
Diag(AL.
getLoc(), diag::warn_attribute_void_function_method) << AL << 0;
2910 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(
D))
2911 if (MD->getReturnType()->isVoidType()) {
2912 S.
Diag(AL.
getLoc(), diag::warn_attribute_void_function_method) << AL << 1;
2928 if (isa<VarDecl>(
D))
2929 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
2940 if (LO.CPlusPlus && !LO.CPlusPlus20)
2941 S.
Diag(AL.
getLoc(), diag::ext_cxx20_attr) << AL;
2945 }
else if (LO.CPlusPlus && !LO.CPlusPlus17)
2946 S.
Diag(AL.
getLoc(), diag::ext_cxx17_attr) << AL;
2952 isa<TypedefNameDecl>(
D)) {
2953 S.
Diag(AL.
getLoc(), diag::warn_unused_result_typedef_unsupported_spelling)
2966 S.
Diag(AL.
getLoc(), diag::warn_attribute_invalid_on_definition)
2968 else if (isa<ObjCPropertyDecl>(
D) || isa<ObjCMethodDecl>(
D) ||
2970 (isa<ObjCInterfaceDecl>(
D) || isa<EnumDecl>(
D)))) {
2973 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
2986template <
class Attribute>
2988 const unsigned Idx) {
2997 std::optional<llvm::APSInt> I = llvm::APSInt(64);
3004 if (!I->isIntN(32)) {
3006 <<
toString(*I, 10,
false) << 32 << 1;
3010 S.
Diag(
E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
3018 "Unexpected PerformCopyInitialization() failure.");
3024template <
typename WorkGroupAttr>
3027 for (
unsigned i = 0; i < 3; ++i) {
3034 auto IsZero = [&](
Expr *
E) {
3038 assert(I &&
"Non-integer constant expr");
3042 if (!llvm::all_of(WGSize, IsZero)) {
3043 for (
unsigned i = 0; i < 3; ++i) {
3045 if (IsZero(WGSize[i])) {
3046 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_is_zero)
3057 assert(L &&
"Non-integer constant expr");
3058 std::optional<llvm::APSInt> R = RHS->getIntegerConstantExpr(S.
Context);
3059 assert(L &&
"Non-integer constant expr");
3063 WorkGroupAttr *Existing =
D->
getAttr<WorkGroupAttr>();
3065 !llvm::equal(std::initializer_list<Expr *>{Existing->getXDim(),
3066 Existing->getYDim(),
3067 Existing->getZDim()},
3069 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3072 WorkGroupAttr(S.
Context, AL, WGSize[0], WGSize[1], WGSize[2]));
3077 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
3083 assert(ParmTSI &&
"no type source info for attribute argument");
3088 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_argument) << 2 << AL;
3092 if (VecTypeHintAttr *A =
D->
getAttr<VecTypeHintAttr>()) {
3094 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3106 if (
const auto *FD = dyn_cast<FunctionDecl>(
D)) {
3111 if (SectionAttr *ExistingAttr =
D->
getAttr<SectionAttr>()) {
3112 if (ExistingAttr->getName() == Name)
3114 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section)
3116 Diag(CI.
getLoc(), diag::note_previous_attribute);
3124 return llvm::Error::success();
3127 StringRef Segment, Section;
3128 unsigned TAA, StubSize;
3130 return llvm::MCSectionMachO::ParseSectionSpecifier(SecName, Segment, Section,
3131 TAA, HasTAA, StubSize);
3136 Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
3161 cast<NamedDecl>(
D));
3166 if (Triple.isLoongArch()) {
3167 return Str ==
"normal" || Str ==
"medium" || Str ==
"extreme";
3169 assert(Triple.getArch() == llvm::Triple::x86_64 &&
3170 "only loongarch/x86-64 supported");
3171 return Str ==
"small" || Str ==
"large";
3178 auto IsTripleSupported = [](llvm::Triple &Triple) {
3179 return Triple.getArch() == llvm::Triple::ArchType::x86_64 ||
3180 Triple.isLoongArch();
3190 Triples.push_back(aux->getTriple());
3199 auto SupportedTripleIt = llvm::find_if(Triples, IsTripleSupported);
3200 if (SupportedTripleIt == Triples.end()) {
3201 S.
Diag(LiteralLoc, diag::warn_unknown_attribute_ignored) << AL;
3205 llvm::CodeModel::Model CM;
3206 if (!CodeModelAttr::ConvertStrToModel(Str, CM) ||
3208 S.
Diag(LiteralLoc, diag::err_attr_codemodel_arg) << Str;
3218 StringRef CodeSegName) {
3220 S.
Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
3232 if (
const auto *FD = dyn_cast<FunctionDecl>(
D)) {
3236 if (
const auto *ExistingAttr =
D->
getAttr<CodeSegAttr>()) {
3237 if (ExistingAttr->getName() == Name)
3239 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section)
3241 Diag(CI.
getLoc(), diag::note_previous_attribute);
3254 if (
const auto *ExistingAttr =
D->
getAttr<CodeSegAttr>()) {
3255 if (!ExistingAttr->isImplicit()) {
3257 ExistingAttr->getName() == Str
3258 ? diag::warn_duplicate_codeseg_attribute
3259 : diag::err_conflicting_codeseg_attribute);
3269 using namespace DiagAttrParams;
3271 if (AttrStr.contains(
"fpmath="))
3272 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3273 << Unsupported <<
None <<
"fpmath=" <<
Target;
3277 AttrStr.contains(
"tune="))
3278 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3284 if (!ParsedAttrs.
CPU.empty() &&
3286 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3289 if (!ParsedAttrs.
Tune.empty() &&
3291 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3296 return Diag(LiteralLoc, diag::err_duplicate_target_attribute)
3298 for (StringRef CurFeature : ParsedAttrs.
Features) {
3299 if (!CurFeature.starts_with(
'+') && !CurFeature.starts_with(
'-'))
3300 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3306 for (StringRef CurFeature : ParsedAttrs.
Features) {
3307 if (CurFeature.starts_with(
"!arch=")) {
3308 StringRef ArchValue = CurFeature.split(
"=").second.trim();
3309 return Diag(LiteralLoc, diag::err_attribute_unsupported)
3310 <<
"target(arch=..)" << ArchValue;
3316 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3320 auto CurFeature = StringRef(
Feature).drop_front();
3322 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3323 << Unsupported <<
None << CurFeature <<
Target;
3333 if (DiagMsg.empty())
3334 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3335 << Unsupported <<
None <<
"branch-protection" <<
Target;
3336 return Diag(LiteralLoc, diag::err_invalid_branch_protection_spec)
3339 if (!DiagMsg.empty())
3340 Diag(LiteralLoc, diag::warn_unsupported_branch_protection_spec) << DiagMsg;
3359 TargetVersionAttr *NewAttr =
3371 TargetAttr *NewAttr = ::new (S.
Context) TargetAttr(S.
Context, AL, Str);
3379 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
3380 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
3383 if (checkAttrMutualExclusion<TargetClonesAttr>(S,
D, AL))
3388 if (
const auto *MD = dyn_cast<CXXMethodDecl>(
D)) {
3389 if (MD->getParent()->isLambda()) {
3399 for (
unsigned I = 0,
E = AL.
getNumArgs(); I !=
E; ++I) {
3404 Params.push_back(Param);
3405 Locations.push_back(
Loc);
3420 for (
auto &SmallStr : NewParams)
3421 Params.push_back(SmallStr.str());
3423 TargetClonesAttr *NewAttr = ::new (S.
Context)
3424 TargetClonesAttr(S.
Context, AL, Params.data(), Params.size());
3436 MinVectorWidthAttr *Existing =
D->
getAttr<MinVectorWidthAttr>();
3437 if (Existing && Existing->getVectorWidth() != VecWidth) {
3438 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3453 if (
auto *DRE = dyn_cast<DeclRefExpr>(
E)) {
3455 S.
Diag(
Loc, diag::warn_cleanup_ext);
3456 FD = dyn_cast<FunctionDecl>(DRE->
getDecl());
3459 S.
Diag(
Loc, diag::err_attribute_cleanup_arg_not_function) << 1
3463 }
else if (
auto *ULE = dyn_cast<UnresolvedLookupExpr>(
E)) {
3464 if (ULE->hasExplicitTemplateArgs())
3465 S.
Diag(
Loc, diag::warn_cleanup_ext);
3467 NI = ULE->getNameInfo();
3469 S.
Diag(
Loc, diag::err_attribute_cleanup_arg_not_function) << 2
3476 S.
Diag(
Loc, diag::err_attribute_cleanup_arg_not_function) << 0;
3481 S.
Diag(
Loc, diag::err_attribute_cleanup_func_must_take_one_arg)
3492 S.
Diag(
Loc, diag::err_attribute_cleanup_func_arg_incompatible_type)
3493 << NI.
getName() << ParamTy << Ty;
3507 S.
Context, VariableReference, UnaryOperatorKind::UO_AddrOf,
3529 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3534 EnumExtensibilityAttr::Kind ExtensibilityKind;
3536 if (!EnumExtensibilityAttr::ConvertStrToKind(II->
getName(),
3537 ExtensibilityKind)) {
3538 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
3543 EnumExtensibilityAttr(S.
Context, AL, ExtensibilityKind));
3561 S.
Diag(AL.
getLoc(), diag::err_format_attribute_not)
3571 if (
auto *OMD = dyn_cast<ObjCMethodDecl>(
D))
3572 if (
auto *
Interface = OMD->getClassInterface())
3579 S.
Diag(AL.
getLoc(), diag::err_format_attribute_result_not)
3580 << (NotNSStringTy ?
"string type" :
"NSString")
3600 return llvm::StringSwitch<FormatAttrKind>(Format)
3614 .Cases(
"gcc_diag",
"gcc_cdiag",
"gcc_cxxdiag",
"gcc_tdiag",
IgnoredFormat)
3622 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored) << AL;
3627 S.
Diag(AL.
getLoc(), diag::err_hlsl_init_priority_unsupported);
3632 S.
Diag(AL.
getLoc(), diag::err_init_priority_object_attr);
3640 S.
Diag(AL.
getLoc(), diag::err_init_priority_object_attr);
3646 uint32_t prioritynum;
3652 if (prioritynum > 65535) {
3653 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_range)
3661 if (prioritynum < 101)
3662 S.
Diag(AL.
getLoc(), diag::warn_init_priority_reserved)
3668 StringRef NewUserDiagnostic) {
3669 if (
const auto *EA =
D->
getAttr<ErrorAttr>()) {
3671 assert((NewAttr ==
"error" || NewAttr ==
"warning") &&
3672 "unexpected normalized full name");
3673 bool Match = (EA->isError() && NewAttr ==
"error") ||
3674 (EA->isWarning() && NewAttr ==
"warning");
3676 Diag(EA->getLocation(), diag::err_attributes_are_not_compatible)
3679 EA->isRegularKeywordAttribute());
3680 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
3683 if (EA->getUserDiagnostic() != NewUserDiagnostic) {
3684 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << EA;
3685 Diag(EA->getLoc(), diag::note_previous_attribute);
3689 return ::new (
Context) ErrorAttr(
Context, CI, NewUserDiagnostic);
3697 if (F->getType() == Format &&
3698 F->getFormatIdx() == FormatIdx &&
3699 F->getFirstArg() == FirstArg) {
3702 if (F->getLocation().isInvalid())
3708 return ::new (
Context) FormatAttr(
Context, CI, Format, FormatIdx, FirstArg);
3718 if (F->getType() == Format && F->getFormatIdx() == FormatIdx) {
3720 F->getFormatString(), FormatStr))
3725 if (F->getLocation().isInvalid())
3732 FormatMatchesAttr(
Context, CI, Format, FormatIdx, FormatStr);
3750 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3775 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
3786 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
3794 if (HasImplicitThisParam) {
3797 diag::err_format_attribute_implicit_this_format_string)
3810 S.
Diag(AL.
getLoc(), diag::err_format_attribute_not)
3831 if (FirstArg != 0) {
3835 S.
Diag(AL.
getLoc(), diag::err_format_strftime_third_parameter)
3843 if (FirstArg != Info.
NumArgs + 1) {
3844 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
3847 std::to_string(Info.
NumArgs + 1));
3857 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
3864 FormatAttr *NewAttr =
3876 if (
auto *SL = dyn_cast<StringLiteral>(FormatStrExpr)) {
3885 S.
Diag(AL.
getLoc(), diag::err_format_nonliteral)
3893 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_no_callee)
3902 assert(FD &&
"Expected a function declaration!");
3904 llvm::StringMap<int> NameIdxMapping;
3905 NameIdxMapping[
"__"] = -1;
3907 NameIdxMapping[
"this"] = 0;
3911 NameIdxMapping[PVD->getName()] = Idx++;
3913 auto UnknownName = NameIdxMapping.end();
3916 for (
unsigned I = 0,
E = AL.
getNumArgs(); I <
E; ++I) {
3923 if (It == UnknownName) {
3924 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_argument_unknown)
3930 ArgIdx = It->second;
3937 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
3943 if (ArgIdx < -1 || ArgIdx > NumArgs) {
3944 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
3951 llvm_unreachable(
"Unexpected ParsedAttr argument type!");
3954 if (ArgIdx == 0 && !HasImplicitThisParam) {
3955 S.
Diag(AL.
getLoc(), diag::err_callback_implicit_this_not_available)
3962 if (!HasImplicitThisParam && ArgIdx > 0)
3965 EncodingIndices.push_back(ArgIdx);
3968 int CalleeIdx = EncodingIndices.front();
3972 if (CalleeIdx < (
int)HasImplicitThisParam) {
3973 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_invalid_callee)
3980 const Type *CalleeType =
3984 S.
Diag(AL.
getLoc(), diag::err_callback_callee_no_function_type)
3989 const Type *CalleeFnType =
3994 const auto *CalleeFnProtoType = dyn_cast<FunctionProtoType>(CalleeFnType);
3995 if (!CalleeFnProtoType) {
3996 S.
Diag(AL.
getLoc(), diag::err_callback_callee_no_function_type)
4001 if (CalleeFnProtoType->getNumParams() != EncodingIndices.size() - 1) {
4002 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_arg_count_for_func)
4003 << AL <<
QualType{CalleeFnProtoType, 0}
4004 << CalleeFnProtoType->getNumParams()
4005 << (
unsigned)(EncodingIndices.size() - 1);
4009 if (CalleeFnProtoType->isVariadic()) {
4021 S.
Context, AL, EncodingIndices.data(), EncodingIndices.size()));
4025 StringRef ParamName) {
4028 Diag(AL.
getLoc(), diag::err_capture_by_attribute_no_entity)
4037 bool IsValid =
true;
4038 for (
unsigned I = 0; I < N; ++I) {
4041 Diag(
E->
getExprLoc(), diag::err_capture_by_attribute_argument_unknown)
4049 Diag(IdLoc->
getLoc(), diag::err_capture_by_references_itself)
4055 ParamLocs[I] = IdLoc->
getLoc();
4061 LifetimeCaptureByAttr::Create(
Context, FakeParamIndices.data(), N, AL);
4062 CapturedBy->setArgs(ParamIdents, ParamLocs);
4069 if (
D->
hasAttr<LifetimeCaptureByAttr>()) {
4070 S.
Diag(AL.
getLoc(), diag::err_capture_by_attribute_multiple)
4074 auto *PVD = dyn_cast<ParmVarDecl>(
D);
4085 if (
auto *A = PVD->getAttr<LifetimeCaptureByAttr>())
4087 if (HasImplicitThisParam) {
4095 if (
auto *A = ATL.
getAttrAs<LifetimeCaptureByAttr>())
4096 Attrs.push_back(
const_cast<LifetimeCaptureByAttr *
>(A));
4101 llvm::StringMap<int> NameIdxMapping = {
4102 {
"global", LifetimeCaptureByAttr::Global},
4103 {
"unknown", LifetimeCaptureByAttr::Unknown}};
4105 if (HasImplicitThisParam) {
4106 NameIdxMapping[
"this"] = 0;
4110 NameIdxMapping[PVD->getName()] = Idx++;
4111 auto DisallowReservedParams = [&](StringRef Reserved) {
4113 if (PVD->getName() == Reserved)
4114 Diag(PVD->getLocation(), diag::err_capture_by_param_uses_reserved_name)
4115 << (PVD->getName() ==
"unknown");
4117 for (
auto *CapturedBy : Attrs) {
4118 const auto &Entities = CapturedBy->getArgIdents();
4119 for (
size_t I = 0; I < Entities.size(); ++I) {
4120 StringRef Name = Entities[I]->getName();
4121 auto It = NameIdxMapping.find(Name);
4122 if (It == NameIdxMapping.end()) {
4123 auto Loc = CapturedBy->getArgLocs()[I];
4124 if (!HasImplicitThisParam && Name ==
"this")
4125 Diag(
Loc, diag::err_capture_by_implicit_this_not_available) <<
Loc;
4127 Diag(
Loc, diag::err_capture_by_attribute_argument_unknown)
4128 << Entities[I] <<
Loc;
4131 if (Name ==
"unknown" || Name ==
"global")
4132 DisallowReservedParams(Name);
4133 CapturedBy->setParamIdx(I, It->second);
4148 QualType T = cast<ParmVarDecl>(
D)->getType();
4151 S.
Diag(AL.
getLoc(), diag::err_called_once_attribute_wrong_type);
4161 const auto *TD = dyn_cast<TypedefNameDecl>(
D);
4162 if (TD && TD->getUnderlyingType()->isUnionType())
4163 RD = TD->getUnderlyingType()->getAsRecordDecl();
4165 RD = dyn_cast<RecordDecl>(
D);
4168 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
4176 diag::warn_transparent_union_attribute_not_definition);
4182 if (Field == FieldEnd) {
4183 S.
Diag(AL.
getLoc(), diag::warn_transparent_union_attribute_zero_fields);
4191 diag::warn_transparent_union_attribute_floating)
4200 for (; Field != FieldEnd; ++Field) {
4201 QualType FieldType = Field->getType();
4215 S.
Diag(Field->getLocation(),
4216 diag::warn_transparent_union_attribute_field_size_align)
4217 << isSize << *Field << FieldBits;
4218 unsigned FirstBits = isSize ? FirstSize : FirstAlign;
4220 diag::note_transparent_union_first_field_size_align)
4221 << isSize << FirstBits;
4244 if (
const auto *TD = dyn_cast<TypedefNameDecl>(
D))
4245 T = TD->getUnderlyingType();
4246 else if (
const auto *VD = dyn_cast<ValueDecl>(
D))
4249 llvm_unreachable(
"Unknown decl type for align_value");
4253 Diag(AttrLoc, diag::warn_attribute_pointer_or_reference_only)
4259 llvm::APSInt Alignment;
4261 E, &Alignment, diag::err_align_value_attribute_argument_not_int);
4265 if (!Alignment.isPowerOf2()) {
4266 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
4288 diag::err_pack_expansion_without_parameter_packs);
4303 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
4315 diag::err_pack_expansion_without_parameter_packs);
4342 const AlignedAttr &
Attr,
4345 if (isa<ParmVarDecl>(
D)) {
4347 }
else if (
const auto *VD = dyn_cast<VarDecl>(
D)) {
4350 if (VD->isExceptionVariable())
4352 }
else if (
const auto *FD = dyn_cast<FieldDecl>(
D)) {
4353 if (FD->isBitField())
4355 }
else if (
const auto *ED = dyn_cast<EnumDecl>(
D)) {
4356 if (ED->getLangOpts().CPlusPlus)
4358 }
else if (!isa<TagDecl>(
D)) {
4359 return S.
Diag(AttrLoc, diag::err_attribute_wrong_decl_type)
4364 if (DiagKind != -1) {
4365 return S.
Diag(AttrLoc, diag::err_alignas_attribute_wrong_decl_type)
4366 << &
Attr << DiagKind;
4372 bool IsPackExpansion) {
4373 AlignedAttr TmpAttr(
Context, CI,
true,
E);
4377 if (TmpAttr.isAlignas() &&
4385 if (
const auto *TND = dyn_cast<TypedefNameDecl>(
D)) {
4386 if (!TND->getUnderlyingType()->isDependentType()) {
4387 Diag(AttrLoc, diag::err_alignment_dependent_typedef_name)
4395 AA->setPackExpansion(IsPackExpansion);
4401 llvm::APSInt Alignment;
4403 E, &Alignment, diag::err_aligned_attribute_argument_not_int);
4411 Diag(AttrLoc, diag::err_attribute_aligned_too_great)
4416 uint64_t AlignVal = Alignment.getZExtValue();
4422 if (!(TmpAttr.isAlignas() && !Alignment)) {
4423 if (!llvm::isPowerOf2_64(AlignVal)) {
4424 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
4430 const auto *VD = dyn_cast<VarDecl>(
D);
4432 unsigned MaxTLSAlign =
4435 if (MaxTLSAlign && AlignVal > MaxTLSAlign &&
4437 Diag(VD->getLocation(), diag::err_tls_var_aligned_over_maximum)
4438 << (
unsigned)AlignVal << VD << MaxTLSAlign;
4446 const Type *Ty = VD->getType().getTypePtr();
4448 Diag(VD->getLocation(), diag::warn_aligned_attr_underaligned)
4449 << VD->getType() << 16;
4455 AA->setPackExpansion(IsPackExpansion);
4456 AA->setCachedAlignmentValue(
4463 AlignedAttr TmpAttr(
Context, CI,
false, TS);
4467 if (TmpAttr.isAlignas() &&
4475 if (
const auto *TND = dyn_cast<TypedefNameDecl>(
D)) {
4476 if (!TND->getUnderlyingType()->isDependentType()) {
4477 Diag(AttrLoc, diag::err_alignment_dependent_typedef_name)
4483 AlignedAttr *AA = ::new (
Context) AlignedAttr(
Context, CI,
false, TS);
4484 AA->setPackExpansion(IsPackExpansion);
4489 const auto *VD = dyn_cast<VarDecl>(
D);
4490 unsigned AlignVal = TmpAttr.getAlignment(
Context);
4494 const Type *Ty = VD->getType().getTypePtr();
4497 Diag(VD->getLocation(), diag::warn_aligned_attr_underaligned)
4498 << VD->getType() << 16;
4503 AlignedAttr *AA = ::new (
Context) AlignedAttr(
Context, CI,
false, TS);
4504 AA->setPackExpansion(IsPackExpansion);
4505 AA->setCachedAlignmentValue(AlignVal);
4510 assert(
D->
hasAttrs() &&
"no attributes on decl");
4513 if (
const auto *VD = dyn_cast<ValueDecl>(
D)) {
4514 UnderlyingTy = DiagTy = VD->getType();
4517 if (
const auto *ED = dyn_cast<EnumDecl>(
D))
4518 UnderlyingTy = ED->getIntegerType();
4527 AlignedAttr *AlignasAttr =
nullptr;
4528 AlignedAttr *LastAlignedAttr =
nullptr;
4531 if (I->isAlignmentDependent())
4535 Align = std::max(Align, I->getAlignment(
Context));
4536 LastAlignedAttr = I;
4540 Diag(LastAlignedAttr->getLocation(), diag::err_attribute_sizeless_type)
4541 << LastAlignedAttr << DiagTy;
4542 }
else if (AlignasAttr && Align) {
4545 if (NaturalAlign > RequestedAlign)
4546 Diag(AlignasAttr->getLocation(), diag::err_alignas_underaligned)
4582 bool &IntegerMode,
bool &ComplexMode,
4585 ComplexMode =
false;
4587 switch (Str.size()) {
4607 DestWidth = Str[1] ==
'I' ? 0 : 128;
4615 DestWidth = Str[1] ==
'I' ? 0 : 128;
4618 if (Str[1] ==
'F') {
4619 IntegerMode =
false;
4620 }
else if (Str[1] ==
'C') {
4621 IntegerMode =
false;
4623 }
else if (Str[1] !=
'I') {
4632 else if (Str ==
"byte")
4636 if (Str ==
"pointer")
4640 if (Str ==
"unwind_word")
4656 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
4668 StringRef Str = Name->getName();
4672 unsigned DestWidth = 0;
4673 bool IntegerMode =
true;
4674 bool ComplexMode =
false;
4676 llvm::APInt VectorSize(64, 0);
4677 if (Str.size() >= 4 && Str[0] ==
'V') {
4679 size_t StrSize = Str.size();
4680 size_t VectorStringLength = 0;
4681 while ((VectorStringLength + 1) < StrSize &&
4682 isdigit(Str[VectorStringLength + 1]))
4683 ++VectorStringLength;
4684 if (VectorStringLength &&
4685 !Str.substr(1, VectorStringLength).getAsInteger(10, VectorSize) &&
4686 VectorSize.isPowerOf2()) {
4688 IntegerMode, ComplexMode, ExplicitType);
4690 if (!InInstantiation)
4691 Diag(AttrLoc, diag::warn_vector_mode_deprecated);
4706 Diag(AttrLoc, diag::err_machine_mode) << 0 << Name;
4711 if (
const auto *TD = dyn_cast<TypedefNameDecl>(
D))
4712 OldTy = TD->getUnderlyingType();
4713 else if (
const auto *ED = dyn_cast<EnumDecl>(
D)) {
4716 OldTy = ED->getIntegerType();
4720 OldTy = cast<ValueDecl>(
D)->getType();
4731 OldElemTy = VT->getElementType();
4737 VectorSize.getBoolValue()) {
4738 Diag(AttrLoc, diag::err_enum_mode_vector_type) << Name << CI.
getRange();
4746 !IntegralOrAnyEnumType)
4747 Diag(AttrLoc, diag::err_mode_not_primitive);
4748 else if (IntegerMode) {
4749 if (!IntegralOrAnyEnumType)
4750 Diag(AttrLoc, diag::err_mode_wrong_type);
4751 }
else if (ComplexMode) {
4753 Diag(AttrLoc, diag::err_mode_wrong_type);
4756 Diag(AttrLoc, diag::err_mode_wrong_type);
4767 if (NewElemTy.
isNull()) {
4769 if (!(DestWidth == 128 &&
4771 Diag(AttrLoc, diag::err_machine_mode) << 1 << Name;
4780 if (VectorSize.getBoolValue()) {
4786 Diag(AttrLoc, diag::err_complex_mode_vector_type);
4790 OldVT->getNumElements() /
4797 Diag(AttrLoc, diag::err_mode_wrong_type);
4802 if (
auto *TD = dyn_cast<TypedefNameDecl>(
D))
4803 TD->setModedTypeSourceInfo(TD->getTypeSourceInfo(), NewTy);
4804 else if (
auto *ED = dyn_cast<EnumDecl>(
D))
4805 ED->setIntegerType(NewTy);
4807 cast<ValueDecl>(
D)->setType(NewTy);
4815 QualType QT = cast<ValueDecl>(
D)->getType();
4833 if (OptimizeNoneAttr *Optnone =
D->
getAttr<OptimizeNoneAttr>()) {
4834 Diag(CI.
getLoc(), diag::warn_attribute_ignored) << Ident;
4835 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
4839 if (
D->
hasAttr<AlwaysInlineAttr>())
4847 if (
const auto *VD = dyn_cast<VarDecl>(
D)) {
4850 if (VD->getKind() != Decl::Var) {
4851 Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
4858 if (VD->hasLocalStorage()) {
4859 Diag(VD->getLocation(), diag::warn_internal_linkage_local_storage);
4866InternalLinkageAttr *
4868 if (
const auto *VD = dyn_cast<VarDecl>(
D)) {
4871 if (VD->getKind() != Decl::Var) {
4872 Diag(AL.getLocation(), diag::warn_attribute_wrong_decl_type)
4873 << &AL << AL.isRegularKeywordAttribute()
4879 if (VD->hasLocalStorage()) {
4880 Diag(VD->getLocation(), diag::warn_internal_linkage_local_storage);
4889 if (OptimizeNoneAttr *Optnone =
D->
getAttr<OptimizeNoneAttr>()) {
4890 Diag(CI.
getLoc(), diag::warn_attribute_ignored) <<
"'minsize'";
4891 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
4903 if (AlwaysInlineAttr *Inline =
D->
getAttr<AlwaysInlineAttr>()) {
4904 Diag(Inline->getLocation(), diag::warn_attribute_ignored) << Inline;
4905 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
4908 if (MinSizeAttr *MinSize =
D->
getAttr<MinSizeAttr>()) {
4909 Diag(MinSize->getLocation(), diag::warn_attribute_ignored) << MinSize;
4910 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
4914 if (
D->
hasAttr<OptimizeNoneAttr>())
4921 if (AlwaysInlineAttr *Inline =
4937 const auto *VD = cast<VarDecl>(
D);
4938 if (VD->hasLocalStorage()) {
4939 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
4944 if (
auto *A =
D->
getAttr<CUDAConstantAttr>()) {
4945 if (!A->isImplicit())
4953 const auto *VD = cast<VarDecl>(
D);
4956 if (!S.
getLangOpts().GPURelocatableDeviceCode && VD->hasExternalStorage() &&
4957 !isa<IncompleteArrayType>(VD->getType())) {
4958 S.
Diag(AL.
getLoc(), diag::err_cuda_extern_shared) << VD;
4961 if (S.
getLangOpts().CUDA && VD->hasLocalStorage() &&
4969 const auto *FD = cast<FunctionDecl>(
D);
4980 if (
const auto *
Method = dyn_cast<CXXMethodDecl>(FD)) {
4981 if (
Method->isInstance()) {
4982 S.
Diag(
Method->getBeginLoc(), diag::err_kern_is_nonstatic_method)
4992 if (AL.
getKind() == ParsedAttr::AT_DeviceKernel)
5005 if (
const auto *VD = dyn_cast<VarDecl>(
D)) {
5006 if (VD->hasLocalStorage()) {
5007 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
5012 if (
auto *A =
D->
getAttr<CUDADeviceAttr>()) {
5013 if (!A->isImplicit())
5021 if (
const auto *VD = dyn_cast<VarDecl>(
D)) {
5022 if (VD->hasLocalStorage()) {
5023 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
5043 const auto *Fn = cast<FunctionDecl>(
D);
5044 if (!Fn->isInlineSpecified()) {
5045 S.
Diag(AL.
getLoc(), diag::warn_gnu_inline_attribute_requires_inline);
5050 S.
Diag(AL.
getLoc(), diag::warn_gnu_inline_cplusplus_without_extern);
5066 if (!isa<ObjCMethodDecl>(
D)) {
5067 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
5073 case ParsedAttr::AT_FastCall:
5076 case ParsedAttr::AT_StdCall:
5079 case ParsedAttr::AT_ThisCall:
5082 case ParsedAttr::AT_CDecl:
5085 case ParsedAttr::AT_Pascal:
5088 case ParsedAttr::AT_SwiftCall:
5091 case ParsedAttr::AT_SwiftAsyncCall:
5094 case ParsedAttr::AT_VectorCall:
5097 case ParsedAttr::AT_MSABI:
5100 case ParsedAttr::AT_SysVABI:
5103 case ParsedAttr::AT_RegCall:
5106 case ParsedAttr::AT_Pcs: {
5107 PcsAttr::PCSType PCS;
5110 PCS = PcsAttr::AAPCS;
5113 PCS = PcsAttr::AAPCS_VFP;
5116 llvm_unreachable(
"unexpected calling convention in pcs attribute");
5122 case ParsedAttr::AT_AArch64VectorPcs:
5125 case ParsedAttr::AT_AArch64SVEPcs:
5128 case ParsedAttr::AT_DeviceKernel: {
5130 assert(
D->
hasAttr<DeviceKernelAttr>() &&
"Expected attribute");
5133 case ParsedAttr::AT_IntelOclBicc:
5136 case ParsedAttr::AT_PreserveMost:
5139 case ParsedAttr::AT_PreserveAll:
5142 case ParsedAttr::AT_M68kRTD:
5145 case ParsedAttr::AT_PreserveNone:
5148 case ParsedAttr::AT_RISCVVectorCC:
5151 case ParsedAttr::AT_RISCVVLSCC: {
5157 if (VectorLength < 32 || VectorLength > 65536) {
5158 S.
Diag(AL.
getLoc(), diag::err_argument_invalid_range)
5163 S.
Diag(AL.
getLoc(), diag::err_argument_not_power_of_2);
5171 llvm_unreachable(
"unexpected attribute kind");
5176 const auto *FD = dyn_cast_or_null<FunctionDecl>(
D);
5179 if (!IsFunctionTemplate) {
5180 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type_str)
5185 }
else if (DeviceKernelAttr::isSYCLSpelling(AL)) {
5186 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored) << AL;
5191 if (!S.
getLangOpts().OpenCLCPlusPlus && (!FD || IsFunctionTemplate)) {
5192 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_decl_type_str)
5195 handleSimpleAttribute<DeviceKernelAttr>(S,
D, AL);
5209 std::vector<StringRef> DiagnosticIdentifiers;
5210 for (
unsigned I = 0,
E = AL.
getNumArgs(); I !=
E; ++I) {
5216 DiagnosticIdentifiers.push_back(RuleName);
5219 SuppressAttr(S.
Context, AL, DiagnosticIdentifiers.data(),
5220 DiagnosticIdentifiers.size()));
5229 unsigned SelectIdx = ~0
U;
5235 if (SelectIdx != ~0
U) {
5236 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_argument)
5248 if (AL.
getKind() == ParsedAttr::AT_Owner) {
5249 if (checkAttrMutualExclusion<PointerAttr>(S,
D, AL))
5251 if (
const auto *OAttr =
D->
getAttr<OwnerAttr>()) {
5252 const Type *ExistingDerefType = OAttr->getDerefTypeLoc()
5253 ? OAttr->getDerefType().getTypePtr()
5256 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
5259 OAttr->isRegularKeywordAttribute());
5260 S.
Diag(OAttr->getLocation(), diag::note_conflicting_attribute);
5265 Redecl->addAttr(::new (S.
Context) OwnerAttr(S.
Context, AL, DerefTypeLoc));
5268 if (checkAttrMutualExclusion<OwnerAttr>(S,
D, AL))
5270 if (
const auto *PAttr =
D->
getAttr<PointerAttr>()) {
5271 const Type *ExistingDerefType = PAttr->getDerefTypeLoc()
5272 ? PAttr->getDerefType().getTypePtr()
5275 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
5278 PAttr->isRegularKeywordAttribute());
5279 S.
Diag(PAttr->getLocation(), diag::note_conflicting_attribute);
5284 Redecl->addAttr(::new (S.
Context)
5285 PointerAttr(S.
Context, AL, DerefTypeLoc));
5291 if (checkAttrMutualExclusion<NoRandomizeLayoutAttr>(S,
D, AL))
5293 if (!
D->
hasAttr<RandomizeLayoutAttr>())
5299 if (checkAttrMutualExclusion<RandomizeLayoutAttr>(S,
D, AL))
5301 if (!
D->
hasAttr<NoRandomizeLayoutAttr>())
5316 if (Attrs.
getKind() == ParsedAttr::AT_RISCVVLSCC) {
5324 unsigned ReqArgs = Attrs.
getKind() == ParsedAttr::AT_Pcs ? 1 : 0;
5331 bool IsTargetDefaultMSABI =
5336 case ParsedAttr::AT_CDecl:
5339 case ParsedAttr::AT_FastCall:
5342 case ParsedAttr::AT_StdCall:
5345 case ParsedAttr::AT_ThisCall:
5348 case ParsedAttr::AT_Pascal:
5351 case ParsedAttr::AT_SwiftCall:
5354 case ParsedAttr::AT_SwiftAsyncCall:
5357 case ParsedAttr::AT_VectorCall:
5360 case ParsedAttr::AT_AArch64VectorPcs:
5363 case ParsedAttr::AT_AArch64SVEPcs:
5366 case ParsedAttr::AT_RegCall:
5369 case ParsedAttr::AT_MSABI:
5372 case ParsedAttr::AT_SysVABI:
5375 case ParsedAttr::AT_Pcs: {
5381 if (StrRef ==
"aapcs") {
5384 }
else if (StrRef ==
"aapcs-vfp") {
5393 case ParsedAttr::AT_IntelOclBicc:
5396 case ParsedAttr::AT_PreserveMost:
5399 case ParsedAttr::AT_PreserveAll:
5402 case ParsedAttr::AT_M68kRTD:
5405 case ParsedAttr::AT_PreserveNone:
5408 case ParsedAttr::AT_RISCVVectorCC:
5411 case ParsedAttr::AT_RISCVVLSCC: {
5414 unsigned ABIVLen = 128;
5420 if (Attrs.
getNumArgs() && (ABIVLen < 32 || ABIVLen > 65536)) {
5422 Diag(Attrs.
getLoc(), diag::err_argument_invalid_range)
5423 << ABIVLen << 32 << 65536;
5426 if (!llvm::isPowerOf2_64(ABIVLen)) {
5428 Diag(Attrs.
getLoc(), diag::err_argument_not_power_of_2);
5432 llvm::Log2_64(ABIVLen) - 5);
5435 case ParsedAttr::AT_DeviceKernel: {
5440 default: llvm_unreachable(
"unexpected attribute kind");
5453 bool CheckHost =
false, CheckDevice =
false;
5454 switch (CudaTarget) {
5467 llvm_unreachable(
"unexpected cuda target");
5469 auto *HostTI =
LangOpts.CUDAIsDevice ? Aux : &TI;
5470 auto *DeviceTI =
LangOpts.CUDAIsDevice ? &TI : Aux;
5471 if (CheckHost && HostTI)
5474 A = DeviceTI->checkCallingConvention(CC);
5483 A = Aux->checkCallingConvention(CC);
5501 Diag(Attrs.
getLoc(), diag::error_cconv_unsupported)
5506 Diag(Attrs.
getLoc(), diag::warn_cconv_unsupported)
5511 bool IsCXXMethod =
false, IsVariadic =
false;
5542 Diag(AL.
getLoc(), diag::err_attribute_regparm_wrong_platform)
5550 Diag(AL.
getLoc(), diag::err_attribute_regparm_invalid_number)
5562 llvm_unreachable(
"getOffloadArch is only valid for NVPTX triple");
5572 const CUDALaunchBoundsAttr &AL,
5573 const unsigned Idx) {
5582 std::optional<llvm::APSInt> I = llvm::APSInt(64);
5589 if (!I->isIntN(32)) {
5591 <<
toString(*I, 10,
false) << 32 << 1;
5603 "Unexpected PerformCopyInitialization() failure.");
5608CUDALaunchBoundsAttr *
5610 Expr *MinBlocks,
Expr *MaxBlocks) {
5611 CUDALaunchBoundsAttr TmpAttr(
Context, CI, MaxThreads, MinBlocks, MaxBlocks);
5629 MaxBlocks =
nullptr;
5638 CUDALaunchBoundsAttr(
Context, CI, MaxThreads, MinBlocks, MaxBlocks);
5660 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
5682 unsigned ArgumentIdxAST = ArgumentIdx.
getASTIndex();
5685 S.
Diag(AL.
getLoc(), diag::err_attribute_pointers_only) << AL << 0;
5690 TypeTagIdx, IsPointer));
5696 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
5704 if (!isa<VarDecl>(
D)) {
5705 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_decl_type)
5713 assert(MatchingCTypeLoc &&
"no type source info for attribute argument");
5736 S.
Diag(AL.
getLoc(), diag::err_aix_attr_unsupported) << AL;
5739 uint32_t Count = 0, Offset = 0;
5747 if (Count < Offset) {
5748 S.
Diag(S.
getAttrLoc(AL), diag::err_attribute_argument_out_of_range)
5759 diag::err_attribute_patchable_function_entry_invalid_section)
5763 if (Section.empty()) {
5765 diag::err_attribute_patchable_function_entry_invalid_section)
5766 <<
"section must not be empty";
5776 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
5783 StringRef AliasName = cast<FunctionDecl>(
D)->getIdentifier()->getName();
5794 (!IsAArch64 && !IsARM && !IsRISCV && !IsHLSL && !IsSPIRV)) {
5795 S.
Diag(AL.
getLoc(), diag::err_attribute_builtin_alias) << AL;
5806 if (
auto *CRD = dyn_cast<CXXRecordDecl>(
D);
5807 !CRD || !(CRD->isClass() || CRD->isStruct())) {
5813 handleSimpleAttribute<TypeNullableAttr>(S,
D, AL);
5818 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
5824 assert(ParmTSI &&
"no type source info for attribute argument");
5826 diag::err_incomplete_type);
5836 StringRef UuidAsWritten,
MSGuidDecl *GuidDecl) {
5837 if (
const auto *UA =
D->
getAttr<UuidAttr>()) {
5840 if (!UA->getGuid().empty()) {
5841 Diag(UA->getLocation(), diag::err_mismatched_uuid);
5847 return ::new (
Context) UuidAttr(
Context, CI, UuidAsWritten, GuidDecl);
5852 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
5857 StringRef OrigStrRef;
5864 StringRef StrRef = OrigStrRef;
5865 if (StrRef.size() == 38 && StrRef.front() ==
'{' && StrRef.back() ==
'}')
5866 StrRef = StrRef.drop_front().drop_back();
5869 if (StrRef.size() != 36) {
5870 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
5874 for (
unsigned i = 0; i < 36; ++i) {
5875 if (i == 8 || i == 13 || i == 18 || i == 23) {
5876 if (StrRef[i] !=
'-') {
5877 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
5881 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
5888 StrRef.substr(0, 8).getAsInteger(16, Parsed.
Part1);
5889 StrRef.substr(9, 4).getAsInteger(16, Parsed.
Part2);
5890 StrRef.substr(14, 4).getAsInteger(16, Parsed.
Part3);
5891 for (
unsigned i = 0; i != 8; ++i)
5892 StrRef.substr(19 + 2 * i + (i >= 2 ? 1 : 0), 2)
5903 S.
Diag(AL.
getLoc(), diag::warn_atl_uuid_deprecated);
5912 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
5925 const auto *VD = cast<VarDecl>(
D);
5927 S.
Diag(AL.
getLoc(), diag::err_thread_unsupported);
5931 S.
Diag(AL.
getLoc(), diag::err_declspec_thread_on_thread_variable);
5934 if (VD->hasLocalStorage()) {
5935 S.
Diag(AL.
getLoc(), diag::err_thread_non_global) <<
"__declspec(thread)";
5943 S.
Diag(AL.
getLoc(), diag::warn_unknown_attribute_ignored)
5947 auto *FD = cast<FunctionDecl>(
D);
5949 S.
Diag(AL.
getLoc(), diag::err_ms_constexpr_cannot_be_applied)
5953 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
5954 if (!S.
getLangOpts().CPlusPlus20 && MD->isVirtual()) {
5955 S.
Diag(AL.
getLoc(), diag::err_ms_constexpr_cannot_be_applied)
5965 for (
unsigned I = 0,
E = AL.
getNumArgs(); I !=
E; ++I) {
5969 Tags.push_back(Tag);
5972 if (
const auto *NS = dyn_cast<NamespaceDecl>(
D)) {
5973 if (!NS->isInline()) {
5974 S.
Diag(AL.
getLoc(), diag::warn_attr_abi_tag_namespace) << 0;
5977 if (NS->isAnonymousNamespace()) {
5978 S.
Diag(AL.
getLoc(), diag::warn_attr_abi_tag_namespace) << 1;
5982 Tags.push_back(NS->getName());
5988 Tags.erase(llvm::unique(Tags), Tags.end());
5991 AbiTagAttr(S.
Context, AL, Tags.data(), Tags.size()));
5996 if (I->getBTFDeclTag() == Tag)
6015 return ::new (
Context) BTFDeclTagAttr(
Context, AL, AL.getBTFDeclTag());
6021 case llvm::Triple::msp430:
6024 case llvm::Triple::mipsel:
6025 case llvm::Triple::mips:
6028 case llvm::Triple::m68k:
6031 case llvm::Triple::x86:
6032 case llvm::Triple::x86_64:
6035 case llvm::Triple::avr:
6038 case llvm::Triple::riscv32:
6039 case llvm::Triple::riscv64:
6056 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
6072 Diag(CI.
getLoc(), diag::warn_attribute_ignored) <<
"'dllimport'";
6084 if (DLLImportAttr *Import =
D->
getAttr<DLLImportAttr>()) {
6085 Diag(Import->getLocation(), diag::warn_attribute_ignored) << Import;
6096 if (isa<ClassTemplatePartialSpecializationDecl>(
D) &&
6102 if (
const auto *FD = dyn_cast<FunctionDecl>(
D)) {
6112 if (
const auto *MD = dyn_cast<CXXMethodDecl>(
D)) {
6114 MD->getParent()->isLambda()) {
6120 Attr *NewAttr = A.
getKind() == ParsedAttr::AT_DLLExport
6131 if (MSInheritanceAttr *IA =
D->
getAttr<MSInheritanceAttr>()) {
6132 if (IA->getInheritanceModel() == Model)
6134 Diag(IA->getLocation(), diag::err_mismatched_ms_inheritance)
6136 Diag(CI.
getLoc(), diag::note_previous_ms_inheritance);
6140 auto *RD = cast<CXXRecordDecl>(
D);
6141 if (RD->hasDefinition()) {
6147 if (isa<ClassTemplatePartialSpecializationDecl>(RD)) {
6148 Diag(CI.
getLoc(), diag::warn_ignored_ms_inheritance)
6152 if (RD->getDescribedClassTemplate()) {
6153 Diag(CI.
getLoc(), diag::warn_ignored_ms_inheritance)
6171 StringRef N(
"mutex");
6173 if (AL.
getKind() == ParsedAttr::AT_Capability &&
6186 if (!
D->
hasAttr<CapabilityAttr>()) {
6187 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_requires_preceded)
6188 << AL << cast<NamedDecl>(
D) <<
"'capability'";
6201 AssertCapabilityAttr(S.
Context, AL, Args.data(), Args.size()));
6206 if (
const auto *ParmDecl = dyn_cast<ParmVarDecl>(
D);
6230 if (
const auto *ParmDecl = dyn_cast<ParmVarDecl>(
D);
6243 if (
const auto *ParmDecl = dyn_cast<ParmVarDecl>(
D);
6256 RequiresCapabilityAttr *RCA = ::new (S.
Context)
6257 RequiresCapabilityAttr(S.
Context, AL, Args.data(), Args.size());
6263 if (
const auto *NSD = dyn_cast<NamespaceDecl>(
D)) {
6264 if (NSD->isAnonymousNamespace()) {
6265 S.
Diag(AL.
getLoc(), diag::warn_deprecated_anonymous_namespace);
6279 StringRef Str, Replacement;
6292 S.
Diag(AL.
getLoc(), diag::ext_cxx14_attr) << AL;
6298 if (
const auto *S = dyn_cast<VarDecl>(
D))
6299 return S->hasGlobalStorage();
6304 return Sanitizer ==
"address" || Sanitizer ==
"hwaddress" ||
6305 Sanitizer ==
"memtag";
6312 std::vector<StringRef> Sanitizers;
6314 for (
unsigned I = 0,
E = AL.
getNumArgs(); I !=
E; ++I) {
6315 StringRef SanitizerName;
6323 SanitizerName !=
"coverage")
6324 S.
Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << SanitizerName;
6327 << AL << SanitizerName;
6328 Sanitizers.push_back(SanitizerName);
6332 Sanitizers.size()));
6339 StringRef SanitizerName = llvm::StringSwitch<StringRef>(AttrName)
6340 .Case(
"no_address_safety_analysis",
"address")
6341 .Case(
"no_sanitize_address",
"address")
6342 .Case(
"no_sanitize_thread",
"thread")
6343 .Case(
"no_sanitize_memory",
"memory");
6356 unsigned TranslatedSpellingIndex = 0;
6358 TranslatedSpellingIndex = 1;
6363 NoSanitizeAttr(S.
Context, Info, &SanitizerName, 1));
6378 ZeroCallUsedRegsAttr::ZeroCallUsedRegsKind Kind;
6379 if (!ZeroCallUsedRegsAttr::ConvertStrToZeroCallUsedRegsKind(KindStr, Kind)) {
6380 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported)
6390 auto *FD = dyn_cast<FieldDecl>(
D);
6400 case ParsedAttr::AT_CountedBy:
6401 CountInBytes =
false;
6404 case ParsedAttr::AT_CountedByOrNull:
6405 CountInBytes =
false;
6408 case ParsedAttr::AT_SizedBy:
6409 CountInBytes =
true;
6412 case ParsedAttr::AT_SizedByOrNull:
6413 CountInBytes =
true;
6417 llvm_unreachable(
"unexpected counted_by family attribute");
6424 FD->
getType(), CountExpr, CountInBytes, OrNull);
6435 FunctionReturnThunksAttr::Kind Kind;
6436 if (!FunctionReturnThunksAttr::ConvertStrToKind(KindStr, Kind)) {
6437 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported)
6444 D->
dropAttr<FunctionReturnThunksAttr>();
6450 assert(isa<TypedefNameDecl>(
D) &&
"This attribute only applies to a typedef");
6451 handleSimpleAttribute<AvailableOnlyInDefaultEvalMethodAttr>(S,
D, AL);
6455 auto *VDecl = dyn_cast<VarDecl>(
D);
6456 if (VDecl && !VDecl->isFunctionPointerType()) {
6457 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored_non_function_pointer)
6469 if (!cast<VarDecl>(
D)->hasGlobalStorage()) {
6471 << (A.
getKind() == ParsedAttr::AT_AlwaysDestroy);
6475 if (A.
getKind() == ParsedAttr::AT_AlwaysDestroy)
6476 handleSimpleAttribute<AlwaysDestroyAttr>(S,
D, A);
6478 handleSimpleAttribute<NoDestroyAttr>(S,
D, A);
6482 assert(cast<VarDecl>(
D)->getStorageDuration() ==
SD_Automatic &&
6483 "uninitialized is only valid on automatic duration variables");
6492 if (!isa<BlockDecl>(
D)) {
6494 bool IsKernReturnT =
false;
6496 IsKernReturnT = (TT->getDecl()->getName() ==
"kern_return_t");
6501 diag::warn_mig_server_routine_does_not_return_kern_return_t);
6506 handleSimpleAttribute<MIGServerRoutineAttr>(S,
D, AL);
6511 if (
auto *FD = dyn_cast<FunctionDecl>(
D)) {
6514 S.
Diag(AL.
getLoc(), diag::warn_declspec_allocator_nonpointer)
6520 handleSimpleAttribute<MSAllocatorAttr>(S,
D, AL);
6527 if (
const auto *PVD = dyn_cast<ParmVarDecl>(
D)) {
6528 if (PVD->getType()->isIntegerType()) {
6529 S.
Diag(AL.
getLoc(), diag::err_attribute_output_parameter)
6540template<
typename Attr>
6548template<
typename Attr>
6557 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
6562 CFGuardAttr::GuardArg Arg;
6564 if (!CFGuardAttr::ConvertStrToGuardArg(II->
getName(), Arg)) {
6565 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
6573template <
typename AttrTy>
6576 auto I = llvm::find_if(Attrs,
6577 [Name](
const AttrTy *A) {
6578 return A->getTCBName() == Name;
6580 return I == Attrs.end() ? nullptr : *I;
6583template <
typename AttrTy,
typename ConflictingAttrTy>
6590 if (
const ConflictingAttrTy *ConflictingAttr =
6591 findEnforceTCBAttrByName<ConflictingAttrTy>(
D, Argument)) {
6594 S.
Diag(AL.
getLoc(), diag::err_tcb_conflicting_attributes)
6608template <
typename AttrTy,
typename ConflictingAttrTy>
6611 StringRef TCBName = AL.getTCBName();
6612 if (
const ConflictingAttrTy *ConflictingAttr =
6613 findEnforceTCBAttrByName<ConflictingAttrTy>(
D, TCBName)) {
6614 S.
Diag(ConflictingAttr->getLoc(), diag::err_tcb_conflicting_attributes)
6615 << ConflictingAttr->getAttrName()->getName()
6616 << AL.getAttrName()->getName() << TCBName;
6619 S.
Diag(AL.getLoc(), diag::note_conflicting_attribute);
6627 return ::new(Context) AttrTy(Context, AL, AL.getTCBName());
6631 return mergeEnforceTCBAttrImpl<EnforceTCBAttr, EnforceTCBLeafAttr>(
6636 Decl *
D,
const EnforceTCBLeafAttr &AL) {
6637 return mergeEnforceTCBAttrImpl<EnforceTCBLeafAttr, EnforceTCBAttr>(
6646 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 4;
6651 S.
Diag(AL.
getLoc(), diag::err_attribute_too_few_arguments) << AL;
6656 if (
D->
getAttr<VTablePointerAuthenticationAttr>()) {
6657 S.
Diag(AL.
getLoc(), diag::err_duplicated_vtable_pointer_auth) <<
Decl;
6661 auto KeyType = VTablePointerAuthenticationAttr::VPtrAuthKeyType::DefaultKey;
6664 if (!VTablePointerAuthenticationAttr::ConvertStrToVPtrAuthKeyType(
6666 S.
Diag(IL->
getLoc(), diag::err_invalid_authentication_key)
6670 if (KeyType == VTablePointerAuthenticationAttr::DefaultKey &&
6672 S.
Diag(AL.
getLoc(), diag::err_no_default_vtable_pointer_auth) << 0;
6676 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
6681 auto AddressDiversityMode = VTablePointerAuthenticationAttr::
6682 AddressDiscriminationMode::DefaultAddressDiscrimination;
6686 if (!VTablePointerAuthenticationAttr::
6687 ConvertStrToAddressDiscriminationMode(
6689 S.
Diag(IL->
getLoc(), diag::err_invalid_address_discrimination)
6693 if (AddressDiversityMode ==
6694 VTablePointerAuthenticationAttr::DefaultAddressDiscrimination &&
6696 S.
Diag(IL->
getLoc(), diag::err_no_default_vtable_pointer_auth) << 1;
6700 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
6705 auto ED = VTablePointerAuthenticationAttr::ExtraDiscrimination::
6706 DefaultExtraDiscrimination;
6710 if (!VTablePointerAuthenticationAttr::ConvertStrToExtraDiscrimination(
6712 S.
Diag(IL->
getLoc(), diag::err_invalid_extra_discrimination)
6716 if (ED == VTablePointerAuthenticationAttr::DefaultExtraDiscrimination &&
6718 S.
Diag(AL.
getLoc(), diag::err_no_default_vtable_pointer_auth) << 2;
6722 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
6727 uint32_t CustomDiscriminationValue = 0;
6728 if (ED == VTablePointerAuthenticationAttr::CustomDiscrimination) {
6730 S.
Diag(AL.
getLoc(), diag::err_missing_custom_discrimination) << AL << 4;
6735 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 4;
6740 CustomDiscriminationValue)) {
6741 S.
Diag(AL.
getLoc(), diag::err_invalid_custom_discrimination);
6744 }
else if (NumArgs > 3) {
6745 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 3;
6750 S.
Context, AL, KeyType, AddressDiversityMode, ED,
6751 CustomDiscriminationValue));
6767 for (
size_t I = 0; I < std::min(AL.
getNumArgs(), AttrNumArgs); ++I) {
6768 bool IsLastAttrArg = I == (AttrNumArgs - 1);
6771 if (IsLastAttrArg && AttrHasVariadicArg)
6778 if (isa<PackExpansionExpr>(
E))
6779 return !(IsLastAttrArg && ArgMemberCanHoldExpr);
6806 !Options.IncludeCXX11Attributes)
6816 ? diag::err_keyword_not_supported_on_target
6817 : diag::warn_unhandled_ms_attribute_ignored)
6832 if (MustDelayArgs) {
6842 assert(AL.
isTypeAttr() &&
"Non-type attribute not handled");
6845 if (Options.IgnoreTypeAttributes)
6863 isa<DeclaratorDecl, TypeAliasDecl>(
D)) {
6868 S.
Diag(AL.
getLoc(), diag::warn_type_attribute_deprecated_on_decl)
6877 if (AL.
getKind() == ParsedAttr::AT_Regparm) {
6890 if (AL.
getKind() == ParsedAttr::AT_VectorSize) {
6900 if (AL.
getKind() == ParsedAttr::AT_NoDeref) {
6911 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_on_decl)
6914 case ParsedAttr::AT_Interrupt:
6917 case ParsedAttr::AT_ARMInterruptSaveFP:
6920 case ParsedAttr::AT_X86ForceAlignArgPointer:
6923 case ParsedAttr::AT_ReadOnlyPlacement:
6924 handleSimpleAttribute<ReadOnlyPlacementAttr>(S,
D, AL);
6926 case ParsedAttr::AT_DLLExport:
6927 case ParsedAttr::AT_DLLImport:
6930 case ParsedAttr::AT_AMDGPUFlatWorkGroupSize:
6933 case ParsedAttr::AT_AMDGPUWavesPerEU:
6936 case ParsedAttr::AT_AMDGPUNumSGPR:
6939 case ParsedAttr::AT_AMDGPUNumVGPR:
6942 case ParsedAttr::AT_AMDGPUMaxNumWorkGroups:
6945 case ParsedAttr::AT_AVRSignal:
6948 case ParsedAttr::AT_BPFPreserveAccessIndex:
6951 case ParsedAttr::AT_BPFPreserveStaticOffset:
6952 handleSimpleAttribute<BPFPreserveStaticOffsetAttr>(S,
D, AL);
6954 case ParsedAttr::AT_BTFDeclTag:
6957 case ParsedAttr::AT_WebAssemblyExportName:
6960 case ParsedAttr::AT_WebAssemblyImportModule:
6963 case ParsedAttr::AT_WebAssemblyImportName:
6966 case ParsedAttr::AT_IBOutlet:
6969 case ParsedAttr::AT_IBOutletCollection:
6972 case ParsedAttr::AT_IFunc:
6975 case ParsedAttr::AT_Alias:
6978 case ParsedAttr::AT_Aligned:
6981 case ParsedAttr::AT_AlignValue:
6984 case ParsedAttr::AT_AllocSize:
6987 case ParsedAttr::AT_AlwaysInline:
6990 case ParsedAttr::AT_AnalyzerNoReturn:
6993 case ParsedAttr::AT_TLSModel:
6996 case ParsedAttr::AT_Annotate:
6999 case ParsedAttr::AT_Availability:
7002 case ParsedAttr::AT_CarriesDependency:
7005 case ParsedAttr::AT_CPUDispatch:
7006 case ParsedAttr::AT_CPUSpecific:
7009 case ParsedAttr::AT_Common:
7012 case ParsedAttr::AT_CUDAConstant:
7015 case ParsedAttr::AT_PassObjectSize:
7018 case ParsedAttr::AT_Constructor:
7021 case ParsedAttr::AT_Deprecated:
7024 case ParsedAttr::AT_Destructor:
7027 case ParsedAttr::AT_EnableIf:
7030 case ParsedAttr::AT_Error:
7033 case ParsedAttr::AT_ExcludeFromExplicitInstantiation:
7036 case ParsedAttr::AT_DiagnoseIf:
7039 case ParsedAttr::AT_DiagnoseAsBuiltin:
7042 case ParsedAttr::AT_NoBuiltin:
7045 case ParsedAttr::AT_CFIUncheckedCallee:
7048 case ParsedAttr::AT_ExtVectorType:
7051 case ParsedAttr::AT_ExternalSourceSymbol:
7054 case ParsedAttr::AT_MinSize:
7057 case ParsedAttr::AT_OptimizeNone:
7060 case ParsedAttr::AT_EnumExtensibility:
7063 case ParsedAttr::AT_SYCLExternal:
7064 handleSimpleAttribute<SYCLExternalAttr>(S,
D, AL);
7066 case ParsedAttr::AT_SYCLKernelEntryPoint:
7069 case ParsedAttr::AT_SYCLSpecialClass:
7070 handleSimpleAttribute<SYCLSpecialClassAttr>(S,
D, AL);
7072 case ParsedAttr::AT_Format:
7075 case ParsedAttr::AT_FormatMatches:
7078 case ParsedAttr::AT_FormatArg:
7081 case ParsedAttr::AT_Callback:
7084 case ParsedAttr::AT_LifetimeCaptureBy:
7087 case ParsedAttr::AT_CalledOnce:
7090 case ParsedAttr::AT_CUDAGlobal:
7093 case ParsedAttr::AT_CUDADevice:
7096 case ParsedAttr::AT_CUDAGridConstant:
7099 case ParsedAttr::AT_HIPManaged:
7102 case ParsedAttr::AT_GNUInline:
7105 case ParsedAttr::AT_CUDALaunchBounds:
7108 case ParsedAttr::AT_Restrict:
7111 case ParsedAttr::AT_Mode:
7114 case ParsedAttr::AT_NonString:
7117 case ParsedAttr::AT_NonNull:
7118 if (
auto *PVD = dyn_cast<ParmVarDecl>(
D))
7123 case ParsedAttr::AT_ReturnsNonNull:
7126 case ParsedAttr::AT_NoEscape:
7129 case ParsedAttr::AT_MaybeUndef:
7130 handleSimpleAttribute<MaybeUndefAttr>(S,
D, AL);
7132 case ParsedAttr::AT_AssumeAligned:
7135 case ParsedAttr::AT_AllocAlign:
7138 case ParsedAttr::AT_Ownership:
7141 case ParsedAttr::AT_Naked:
7144 case ParsedAttr::AT_NoReturn:
7147 case ParsedAttr::AT_CXX11NoReturn:
7150 case ParsedAttr::AT_AnyX86NoCfCheck:
7153 case ParsedAttr::AT_NoThrow:
7155 handleSimpleAttribute<NoThrowAttr>(S,
D, AL);
7157 case ParsedAttr::AT_CUDAShared:
7160 case ParsedAttr::AT_VecReturn:
7163 case ParsedAttr::AT_ObjCOwnership:
7166 case ParsedAttr::AT_ObjCPreciseLifetime:
7169 case ParsedAttr::AT_ObjCReturnsInnerPointer:
7172 case ParsedAttr::AT_ObjCRequiresSuper:
7175 case ParsedAttr::AT_ObjCBridge:
7178 case ParsedAttr::AT_ObjCBridgeMutable:
7181 case ParsedAttr::AT_ObjCBridgeRelated:
7184 case ParsedAttr::AT_ObjCDesignatedInitializer:
7187 case ParsedAttr::AT_ObjCRuntimeName:
7190 case ParsedAttr::AT_ObjCBoxable:
7193 case ParsedAttr::AT_NSErrorDomain:
7196 case ParsedAttr::AT_CFConsumed:
7197 case ParsedAttr::AT_NSConsumed:
7198 case ParsedAttr::AT_OSConsumed:
7203 case ParsedAttr::AT_OSReturnsRetainedOnZero:
7204 handleSimpleAttributeOrDiagnose<OSReturnsRetainedOnZeroAttr>(
7206 diag::warn_ns_attribute_wrong_parameter_type,
7209 case ParsedAttr::AT_OSReturnsRetainedOnNonZero:
7210 handleSimpleAttributeOrDiagnose<OSReturnsRetainedOnNonZeroAttr>(
7212 diag::warn_ns_attribute_wrong_parameter_type,
7215 case ParsedAttr::AT_NSReturnsAutoreleased:
7216 case ParsedAttr::AT_NSReturnsNotRetained:
7217 case ParsedAttr::AT_NSReturnsRetained:
7218 case ParsedAttr::AT_CFReturnsNotRetained:
7219 case ParsedAttr::AT_CFReturnsRetained:
7220 case ParsedAttr::AT_OSReturnsNotRetained:
7221 case ParsedAttr::AT_OSReturnsRetained:
7224 case ParsedAttr::AT_WorkGroupSizeHint:
7225 handleWorkGroupSize<WorkGroupSizeHintAttr>(S,
D, AL);
7227 case ParsedAttr::AT_ReqdWorkGroupSize:
7228 handleWorkGroupSize<ReqdWorkGroupSizeAttr>(S,
D, AL);
7230 case ParsedAttr::AT_OpenCLIntelReqdSubGroupSize:
7233 case ParsedAttr::AT_VecTypeHint:
7236 case ParsedAttr::AT_InitPriority:
7239 case ParsedAttr::AT_Packed:
7242 case ParsedAttr::AT_PreferredName:
7245 case ParsedAttr::AT_NoSpecializations:
7248 case ParsedAttr::AT_Section:
7251 case ParsedAttr::AT_CodeModel:
7254 case ParsedAttr::AT_RandomizeLayout:
7257 case ParsedAttr::AT_NoRandomizeLayout:
7260 case ParsedAttr::AT_CodeSeg:
7263 case ParsedAttr::AT_Target:
7266 case ParsedAttr::AT_TargetVersion:
7269 case ParsedAttr::AT_TargetClones:
7272 case ParsedAttr::AT_MinVectorWidth:
7275 case ParsedAttr::AT_Unavailable:
7276 handleAttrWithMessage<UnavailableAttr>(S,
D, AL);
7278 case ParsedAttr::AT_OMPAssume:
7281 case ParsedAttr::AT_ObjCDirect:
7284 case ParsedAttr::AT_ObjCDirectMembers:
7286 handleSimpleAttribute<ObjCDirectMembersAttr>(S,
D, AL);
7288 case ParsedAttr::AT_ObjCExplicitProtocolImpl:
7291 case ParsedAttr::AT_Unused:
7294 case ParsedAttr::AT_Visibility:
7297 case ParsedAttr::AT_TypeVisibility:
7300 case ParsedAttr::AT_WarnUnusedResult:
7303 case ParsedAttr::AT_WeakRef:
7306 case ParsedAttr::AT_WeakImport:
7309 case ParsedAttr::AT_TransparentUnion:
7312 case ParsedAttr::AT_ObjCMethodFamily:
7315 case ParsedAttr::AT_ObjCNSObject:
7318 case ParsedAttr::AT_ObjCIndependentClass:
7321 case ParsedAttr::AT_Blocks:
7324 case ParsedAttr::AT_Sentinel:
7327 case ParsedAttr::AT_Cleanup:
7330 case ParsedAttr::AT_NoDebug:
7333 case ParsedAttr::AT_CmseNSEntry:
7336 case ParsedAttr::AT_StdCall:
7337 case ParsedAttr::AT_CDecl:
7338 case ParsedAttr::AT_FastCall:
7339 case ParsedAttr::AT_ThisCall:
7340 case ParsedAttr::AT_Pascal:
7341 case ParsedAttr::AT_RegCall:
7342 case ParsedAttr::AT_SwiftCall:
7343 case ParsedAttr::AT_SwiftAsyncCall:
7344 case ParsedAttr::AT_VectorCall:
7345 case ParsedAttr::AT_MSABI:
7346 case ParsedAttr::AT_SysVABI:
7347 case ParsedAttr::AT_Pcs:
7348 case ParsedAttr::AT_IntelOclBicc:
7349 case ParsedAttr::AT_PreserveMost:
7350 case ParsedAttr::AT_PreserveAll:
7351 case ParsedAttr::AT_AArch64VectorPcs:
7352 case ParsedAttr::AT_AArch64SVEPcs:
7353 case ParsedAttr::AT_M68kRTD:
7354 case ParsedAttr::AT_PreserveNone:
7355 case ParsedAttr::AT_RISCVVectorCC:
7356 case ParsedAttr::AT_RISCVVLSCC:
7359 case ParsedAttr::AT_DeviceKernel:
7362 case ParsedAttr::AT_Suppress:
7365 case ParsedAttr::AT_Owner:
7366 case ParsedAttr::AT_Pointer:
7369 case ParsedAttr::AT_OpenCLAccess:
7372 case ParsedAttr::AT_OpenCLNoSVM:
7375 case ParsedAttr::AT_SwiftContext:
7378 case ParsedAttr::AT_SwiftAsyncContext:
7381 case ParsedAttr::AT_SwiftErrorResult:
7384 case ParsedAttr::AT_SwiftIndirectResult:
7387 case ParsedAttr::AT_InternalLinkage:
7390 case ParsedAttr::AT_ZeroCallUsedRegs:
7393 case ParsedAttr::AT_FunctionReturnThunks:
7396 case ParsedAttr::AT_NoMerge:
7399 case ParsedAttr::AT_NoUniqueAddress:
7403 case ParsedAttr::AT_AvailableOnlyInDefaultEvalMethod:
7407 case ParsedAttr::AT_CountedBy:
7408 case ParsedAttr::AT_CountedByOrNull:
7409 case ParsedAttr::AT_SizedBy:
7410 case ParsedAttr::AT_SizedByOrNull:
7415 case ParsedAttr::AT_LayoutVersion:
7418 case ParsedAttr::AT_Uuid:
7421 case ParsedAttr::AT_MSInheritance:
7424 case ParsedAttr::AT_Thread:
7427 case ParsedAttr::AT_MSConstexpr:
7430 case ParsedAttr::AT_HybridPatchable:
7431 handleSimpleAttribute<HybridPatchableAttr>(S,
D, AL);
7435 case ParsedAttr::AT_RootSignature:
7438 case ParsedAttr::AT_HLSLNumThreads:
7441 case ParsedAttr::AT_HLSLWaveSize:
7444 case ParsedAttr::AT_HLSLSV_Position:
7447 case ParsedAttr::AT_HLSLVkExtBuiltinInput:
7450 case ParsedAttr::AT_HLSLVkConstantId:
7453 case ParsedAttr::AT_HLSLVkBinding:
7456 case ParsedAttr::AT_HLSLSV_GroupThreadID:
7459 case ParsedAttr::AT_HLSLSV_GroupID:
7462 case ParsedAttr::AT_HLSLSV_GroupIndex:
7463 handleSimpleAttribute<HLSLSV_GroupIndexAttr>(S,
D, AL);
7465 case ParsedAttr::AT_HLSLGroupSharedAddressSpace:
7466 handleSimpleAttribute<HLSLGroupSharedAddressSpaceAttr>(S,
D, AL);
7468 case ParsedAttr::AT_HLSLSV_DispatchThreadID:
7471 case ParsedAttr::AT_HLSLPackOffset:
7474 case ParsedAttr::AT_HLSLShader:
7477 case ParsedAttr::AT_HLSLResourceBinding:
7480 case ParsedAttr::AT_HLSLParamModifier:
7484 case ParsedAttr::AT_AbiTag:
7487 case ParsedAttr::AT_CFGuard:
7492 case ParsedAttr::AT_PtGuardedVar:
7495 case ParsedAttr::AT_NoSanitize:
7498 case ParsedAttr::AT_NoSanitizeSpecific:
7501 case ParsedAttr::AT_GuardedBy:
7504 case ParsedAttr::AT_PtGuardedBy:
7507 case ParsedAttr::AT_LockReturned:
7510 case ParsedAttr::AT_LocksExcluded:
7513 case ParsedAttr::AT_AcquiredBefore:
7516 case ParsedAttr::AT_AcquiredAfter:
7521 case ParsedAttr::AT_Capability:
7522 case ParsedAttr::AT_Lockable:
7525 case ParsedAttr::AT_ReentrantCapability:
7528 case ParsedAttr::AT_RequiresCapability:
7532 case ParsedAttr::AT_AssertCapability:
7535 case ParsedAttr::AT_AcquireCapability:
7538 case ParsedAttr::AT_ReleaseCapability:
7541 case ParsedAttr::AT_TryAcquireCapability:
7546 case ParsedAttr::AT_Consumable:
7549 case ParsedAttr::AT_CallableWhen:
7552 case ParsedAttr::AT_ParamTypestate:
7555 case ParsedAttr::AT_ReturnTypestate:
7558 case ParsedAttr::AT_SetTypestate:
7561 case ParsedAttr::AT_TestTypestate:
7566 case ParsedAttr::AT_ArgumentWithTypeTag:
7569 case ParsedAttr::AT_TypeTagForDatatype:
7574 case ParsedAttr::AT_SwiftAsyncName:
7577 case ParsedAttr::AT_SwiftAttr:
7580 case ParsedAttr::AT_SwiftBridge:
7583 case ParsedAttr::AT_SwiftError:
7586 case ParsedAttr::AT_SwiftName:
7589 case ParsedAttr::AT_SwiftNewType:
7592 case ParsedAttr::AT_SwiftAsync:
7595 case ParsedAttr::AT_SwiftAsyncError:
7600 case ParsedAttr::AT_XRayLogArgs:
7604 case ParsedAttr::AT_PatchableFunctionEntry:
7608 case ParsedAttr::AT_AlwaysDestroy:
7609 case ParsedAttr::AT_NoDestroy:
7613 case ParsedAttr::AT_Uninitialized:
7617 case ParsedAttr::AT_ObjCExternallyRetained:
7621 case ParsedAttr::AT_MIGServerRoutine:
7625 case ParsedAttr::AT_MSAllocator:
7629 case ParsedAttr::AT_ArmBuiltinAlias:
7633 case ParsedAttr::AT_ArmLocallyStreaming:
7634 handleSimpleAttribute<ArmLocallyStreamingAttr>(S,
D, AL);
7637 case ParsedAttr::AT_ArmNew:
7641 case ParsedAttr::AT_AcquireHandle:
7645 case ParsedAttr::AT_ReleaseHandle:
7646 handleHandleAttr<ReleaseHandleAttr>(S,
D, AL);
7649 case ParsedAttr::AT_UnsafeBufferUsage:
7650 handleUnsafeBufferUsage<UnsafeBufferUsageAttr>(S,
D, AL);
7653 case ParsedAttr::AT_UseHandle:
7654 handleHandleAttr<UseHandleAttr>(S,
D, AL);
7657 case ParsedAttr::AT_EnforceTCB:
7658 handleEnforceTCBAttr<EnforceTCBAttr, EnforceTCBLeafAttr>(S,
D, AL);
7661 case ParsedAttr::AT_EnforceTCBLeaf:
7662 handleEnforceTCBAttr<EnforceTCBLeafAttr, EnforceTCBAttr>(S,
D, AL);
7665 case ParsedAttr::AT_BuiltinAlias:
7669 case ParsedAttr::AT_PreferredType:
7673 case ParsedAttr::AT_UsingIfExists:
7674 handleSimpleAttribute<UsingIfExistsAttr>(S,
D, AL);
7677 case ParsedAttr::AT_TypeNullable:
7681 case ParsedAttr::AT_VTablePointerAuthentication:
7689 return D->
hasAttr<DeviceKernelAttr>() ||
7697 if (AttrList.
empty())
7708 Diag(AttrList.
begin()->getLoc(), diag::err_attribute_weakref_without_alias)
7709 << cast<NamedDecl>(
D);
7718 if (!(
D->
hasAttr<DeviceKernelAttr>() ||
7722 if (
const auto *A =
D->
getAttr<ReqdWorkGroupSizeAttr>()) {
7727 }
else if (
const auto *A =
D->
getAttr<WorkGroupSizeHintAttr>()) {
7730 }
else if (
const auto *A =
D->
getAttr<VecTypeHintAttr>()) {
7733 }
else if (
const auto *A =
D->
getAttr<OpenCLIntelReqdSubGroupSizeAttr>()) {
7739 if (
const auto *A =
D->
getAttr<AMDGPUFlatWorkGroupSizeAttr>()) {
7743 }
else if (
const auto *A =
D->
getAttr<AMDGPUWavesPerEUAttr>()) {
7747 }
else if (
const auto *A =
D->
getAttr<AMDGPUNumSGPRAttr>()) {
7751 }
else if (
const auto *A =
D->
getAttr<AMDGPUNumVGPRAttr>()) {
7763 << (
D->
hasAttr<ConstructorAttr>() ?
"constructors" :
"destructors");
7772 if (
D->
hasAttr<ObjCDesignatedInitializerAttr>() &&
7773 cast<ObjCMethodDecl>(
D)->getMethodFamily() !=
OMF_init) {
7775 D->
dropAttr<ObjCDesignatedInitializerAttr>();
7782 if (AL.getKind() == ParsedAttr::AT_TransparentUnion) {
7789 if (
D &&
D->
hasAttr<BPFPreserveAccessIndexAttr>())
7796 if (AL.getKind() == ParsedAttr::AT_Annotate) {
7800 Diag(AL.getLoc(), diag::err_only_annotate_after_access_spec);
7812 if (AL.isUsedAsTypeAttr() || AL.isInvalid())
7820 S.
Diag(AL.getLoc(), diag::warn_attribute_not_on_decl) << AL
7830 for (
unsigned i = 0, e =
D.getNumTypeObjects(); i != e; ++i)
7837 std::optional<StringRef> CorrectedScopeName =
7839 if (CorrectedScopeName) {
7840 ScopeName = *CorrectedScopeName;
7846 if (CorrectedAttrName) {
7847 AttrName = *CorrectedAttrName;
7850 if (CorrectedScopeName || CorrectedAttrName) {
7851 std::string CorrectedFullName =
7855 diag::warn_unknown_attribute_ignored_suggestion);
7857 D << AL << CorrectedFullName;
7862 if (CorrectedScopeName) {
7866 if (CorrectedAttrName) {
7871 Diag(NR.
getBegin(), diag::warn_unknown_attribute_ignored) << AL << NR;
7877 assert(isa<FunctionDecl>(ND) || isa<VarDecl>(ND));
7879 if (
auto *FD = dyn_cast<FunctionDecl>(ND)) {
7901 for (
const auto &AI : FT->param_types()) {
7904 Params.push_back(Param);
7906 NewFD->setParams(Params);
7908 }
else if (
auto *VD = dyn_cast<VarDecl>(ND)) {
7910 VD->getInnerLocStart(), VD->getLocation(), II,
7911 VD->getType(), VD->getTypeSourceInfo(),
7912 VD->getStorageClass());
7913 if (VD->getQualifier())
7914 cast<VarDecl>(NewD)->setQualifierInfo(VD->getQualifierLoc());
7947 if (
auto *VD = dyn_cast<VarDecl>(
D))
7948 if (VD->isExternC())
7950 if (
auto *FD = dyn_cast<FunctionDecl>(
D))
7958 auto &WeakInfos = I->second;
7959 for (
const auto &W : WeakInfos)
7961 std::remove_reference_t<
decltype(WeakInfos)> EmptyWeakInfos;
7962 WeakInfos.swap(EmptyWeakInfos);
7974 auto ProcessAttributesWithSliding =
7982 if ((AL.isStandardAttributeSyntax() || AL.isAlignas()) &&
7983 AL.slidesFromDeclToDeclSpecLegacyBehavior()) {
7988 AL.diagnoseAppertainsTo(*
this,
D);
8003 .WithIncludeCXX11Attributes(
false)
8004 .WithIgnoreTypeAttributes(
true));
8013 .WithIncludeCXX11Attributes(
false)
8014 .WithIgnoreTypeAttributes(
true));
8032 UnavailableAttr::ImplicitReason &reason) {
8036 if (!isa<FieldDecl>(
D) && !isa<ObjCPropertyDecl>(
D) &&
8037 !isa<FunctionDecl>(
D))
8045 if ((isa<ObjCIvarDecl>(
D) || isa<ObjCPropertyDecl>(
D))) {
8048 reason = UnavailableAttr::IR_ForbiddenWeak;
8057 reason = UnavailableAttr::IR_ARCForbiddenType;
8067 auto Reason = UnavailableAttr::IR_None;
8069 assert(Reason &&
"didn't set reason?");
8074 if (
const auto *FD = dyn_cast<FunctionDecl>(
D)) {
8077 if (FD->
hasAttr<UnavailableAttr>() &&
8079 diag::err_arc_array_param_no_ownership) {
8110 bool AnyAccessFailures =
false;
8118 switch (diag.
Kind) {
8122 if (!
decl->isInvalidDecl())
8130 if (AnyAccessFailures && isa<DecompositionDecl>(
decl))
8134 AnyAccessFailures =
true;
8147 assert(curPool &&
"re-emitting in undelayed context not supported");
8148 curPool->
steal(pool);
Defines the clang::ASTContext interface.
static SmallString< 64 > normalizeName(StringRef AttrName, StringRef ScopeName, 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 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 const RecordDecl * getRecordDecl(QualType QT)
Checks that the passed in QualType either is of RecordType or points to RecordType.
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)
static void handleUninitializedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleRequiresCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleDeviceKernelAttr(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 handleFormatMatchesAttr(Sema &S, Decl *D, const ParsedAttr &AL)
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 Expr * makeAttributeArgExpr(Sema &S, Expr *E, const Attribute &Attr, const unsigned Idx)
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 bool threadSafetyCheckIsSmartPointer(Sema &S, const RecordDecl *Record)
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 handleNonStringAttr(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 bool isValidCodeModelAttr(llvm::Triple &Triple, StringRef Str)
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 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 handleCFIUncheckedCalleeAttr(Sema &S, Decl *D, const ParsedAttr &Attrs)
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 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 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 bool isKnownToAlwaysThrow(const FunctionDecl *FD)
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 bool isIntOrBool(Expr *Exp)
Check if the passed-in expression is of type int or bool.
static bool versionsMatch(const VersionTuple &X, const VersionTuple &Y, bool BeforeIsOkay)
Check whether the two versions match.
static bool isSanitizerAttributeAllowedOnGlobals(StringRef Sanitizer)
static bool handleFormatAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, FormatAttrCommon *Info)
Handle attribute((format(type,idx,firstarg))) attributes based on http://gcc.gnu.org/onlinedocs/gcc/F...
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 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 handleReentrantCapabilityAttr(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.
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.
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.
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current context.
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 getTypedefType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypedefNameDecl *Decl, QualType UnderlyingType=QualType(), std::optional< bool > TypeMatchesDeclOrNone=std::nullopt) const
Return the unique reference to the type for the specified typedef-name decl.
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.
CanQualType getCanonicalTagType(const TagDecl *TD) const
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.
SourceLocation getScopeLoc() const
bool isMicrosoftAttribute() const
bool isClangScope() const
void setAttributeSpellingListIndex(unsigned V)
std::string getNormalizedFullName() const
Gets the normalized full name, which consists of both scope and name and with surrounding underscores...
bool isCXX11Attribute() const
bool isDeclspecAttribute() const
SourceRange getRange() const
bool isC23Attribute() const
unsigned getAttributeSpellingListIndex() const
const IdentifierInfo * getScopeName() const
bool isExplicitScope() const
StringRef getNormalizedAttrName(StringRef ScopeName) const
std::optional< StringRef > tryGetCorrectedAttrName(StringRef ScopeName, StringRef AttrName, const TargetInfo &Target, const LangOptions &LangOpts) const
bool isGNUAttribute() const
bool isRegularKeywordAttribute() const
SourceRange getNormalizedRange() const
std::optional< StringRef > tryGetCorrectedScopeName(StringRef ScopeName) const
SourceLocation getLoc() const
const IdentifierInfo * getAttrName() const
StringRef getNormalizedScopeName() 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.
SourceLocation getTypeSpecStartLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
const AssociatedConstraint & getTrailingRequiresClause() const
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies the name of this declaration, if it was present in ...
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
Concrete class used by the front-end to report problems and issues.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
const IntrusiveRefCntPtr< DiagnosticIDs > & getDiagnosticIDs() const
Recursive AST visitor that supports extension via dynamic dispatch.
This represents one expression.
bool isIntegerConstantExpr(const ASTContext &Ctx) const
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).
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx) const
isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
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.
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, const AssociatedConstraint &TrailingRequiresClause={})
const ParmVarDecl * getParamDecl(unsigned i) const
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
param_iterator param_end()
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
void setIsMultiVersion(bool V=true)
Sets the multiversion state for this declaration and all of its redeclarations.
bool isNoReturn() const
Determines whether this function is known to be 'noreturn', through an attribute on its declaration o...
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.
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Represents a prototype with parameter type info, e.g.
Declaration of a template function.
FunctionType - C99 6.7.5.3 - Function Declarators.
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.
A simple pair of identifier info and location.
SourceLocation getLoc() const
IdentifierInfo * getIdentifierInfo() const
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...
bool isValid() const
Is this parameter index valid?
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
RecordDecl * getDefinitionOrSelf() 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...
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 handleInterruptSaveFPAttr(Decl *D, const ParsedAttr &AL)
bool checkTargetVersionAttr(const StringRef Str, const SourceLocation Loc)
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 checkTargetClonesAttr(SmallVectorImpl< StringRef > &Params, SmallVectorImpl< SourceLocation > &Locs, SmallVectorImpl< SmallString< 64 > > &NewParams)
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)
A generic diagnostic builder for errors which may or may not be deferred.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
CUDAFunctionTarget IdentifyTarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
CUDAFunctionTarget CurrentTarget()
Gets the CUDA target for the current context.
SemaDiagnosticBuilder DiagIfHostCode(SourceLocation Loc, unsigned DiagID)
Creates a SemaDiagnosticBuilder that emits the diagnostic if the current context is "used as host cod...
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 handleSV_PositionAttr(Decl *D, const ParsedAttr &AL)
void handleRootSignatureAttr(Decl *D, const ParsedAttr &AL)
void handleResourceBindingAttr(Decl *D, const ParsedAttr &AL)
void handleNumThreadsAttr(Decl *D, const ParsedAttr &AL)
void handleVkExtBuiltinInputAttr(Decl *D, const ParsedAttr &AL)
void handleVkBindingAttr(Decl *D, const ParsedAttr &AL)
void handleVkConstantIdAttr(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)
bool checkTargetClonesAttr(SmallVectorImpl< StringRef > &Params, SmallVectorImpl< SourceLocation > &Locs, SmallVectorImpl< SmallString< 64 > > &NewParams)
bool checkTargetVersionAttr(const StringRef Param, const SourceLocation Loc)
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)
bool checkTargetClonesAttr(SmallVectorImpl< StringRef > &Params, SmallVectorImpl< SourceLocation > &Locs, SmallVectorImpl< SmallString< 64 > > &NewParams)
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.
bool checkFunctionOrMethodParameterIndex(const Decl *D, const AttrInfo &AI, unsigned AttrArgNum, const Expr *IdxExpr, ParamIdx &Idx, bool CanIndexImplicitThis=false, bool CanIndexVariadicArguments=false)
Check if IdxExpr is a valid parameter index for a function or instance method D.
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.
void PopParsingDeclaration(ParsingDeclState state, Decl *decl)
ErrorAttr * mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI, StringRef NewUserDiagnostic)
bool CheckFormatStringsCompatible(FormatStringType FST, const StringLiteral *AuthoritativeFormatString, const StringLiteral *TestedFormatString, const Expr *FunctionCallArg=nullptr)
Verify that two format strings (as understood by attribute(format) and attribute(format_matches) are ...
void redelayDiagnostics(sema::DelayedDiagnosticPool &pool)
Given a set of delayed diagnostics, re-emit them as if they had been delayed in the current context i...
VisibilityAttr * mergeVisibilityAttr(Decl *D, const AttributeCommonInfo &CI, VisibilityAttr::VisibilityType Vis)
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
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
bool CheckCallingConvAttr(const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD=nullptr, CUDAFunctionTarget CFT=CUDAFunctionTarget::InvalidTarget)
Check validaty of calling convention attribute attr.
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)
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing,...
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)
bool IsAssignConvertCompatible(AssignConvertType ConvTy)
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+...
FunctionDecl * ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, bool Complain=false, DeclAccessPair *Found=nullptr, TemplateSpecCandidateSet *FailedTSC=nullptr, bool ForTypeDeduction=false)
Given an expression that refers to an overloaded function, try to resolve that overloaded function ex...
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
static FormatStringType GetFormatStringType(StringRef FormatFlavor)
bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str)
bool ValidateFormatString(FormatStringType FST, const StringLiteral *Str)
Verify that one format string (as understood by attribute(format)) is self-consistent; for instance,...
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.
void DiagnoseUnknownAttribute(const ParsedAttr &AL)
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)
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=AllowFoldKind::No)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
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.
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.
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,...
FormatMatchesAttr * mergeFormatMatchesAttr(Decl *D, const AttributeCommonInfo &CI, IdentifierInfo *Format, int FormatIdx, StringLiteral *FormatStr)
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.
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)
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
Stmt - This represents one statement.
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 validateBranchProtection(StringRef Spec, StringRef Arch, BranchProtectionInfo &BPI, const LangOptions &LO, StringRef &Err) const
Determine if this TargetInfo supports the given branch protection specification.
virtual bool validateCPUSpecificCPUDispatch(StringRef Name) const
virtual bool hasProtectedVisibility() const
Does this target support "protected" visibility?
unsigned getRegParmMax() const
virtual unsigned getUnwindWordWidth() const
virtual bool isValidFeatureName(StringRef Feature) const
Determine whether this TargetInfo supports the given feature.
unsigned getCharWidth() const
virtual ParsedTargetAttr parseTargetAttr(StringRef Str) const
virtual bool supportsTargetAttributeTune() const
Determine whether this TargetInfo supports tune in target attribute.
virtual bool shouldDLLImportComdatSymbols() const
Does this target aim for semantic compatibility with Microsoft C++ code using dllimport/export attrib...
virtual bool isValidCPUName(StringRef Name) const
Determine whether this TargetInfo supports the given CPU name.
const llvm::VersionTuple & getSDKVersion() const
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...
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.
bool isBlockPointerType() const
bool isBooleanType() const
const Type * getPointeeOrArrayElementType() const
If this is a pointer type, return the pointee type.
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).
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
bool isFunctionPointerType() const
bool isPointerType() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isEnumeralType() 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 isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
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
const T * getAsCanonical() const
If this type is canonically the specified type, return its canonical type cast to that specified type...
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 isRecordType() const
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< Attr > attr
Matches attributes.
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.
@ Match
This is not an overload because the signature exactly matches an existing declaration.
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.
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated",...
@ None
Don't merge availability attributes at all.
@ Override
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
@ OptionalProtocolImplementation
Merge availability attributes for an implementation of an optional protocol requirement.
@ Redeclaration
Merge availability attributes for a redeclaration, which requires an exact match.
@ ProtocolImplementation
Merge availability attributes for an implementation of a protocol requirement.
@ VectorLength
'vector_length' clause, allowed on 'parallel', 'kernels', 'parallel loop', and 'kernels loop' constru...
void inferNoReturnAttr(Sema &S, const Decl *D)
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).
bool isLambdaCallOperator(const CXXMethodDecl *MD)
@ 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)
@ Template
We are parsing a template declaration.
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.
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
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.
@ None
No keyword precedes the qualified type name.
@ 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.
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