65#include "llvm/ADT/APSInt.h"
66#include "llvm/ADT/STLExtras.h"
67#include "llvm/ADT/StringExtras.h"
68#include "llvm/Demangle/Demangle.h"
69#include "llvm/IR/DerivedTypes.h"
70#include "llvm/MC/MCSectionMachO.h"
71#include "llvm/Support/Error.h"
72#include "llvm/Support/ErrorHandling.h"
73#include "llvm/Support/MathExtras.h"
74#include "llvm/Support/raw_ostream.h"
75#include "llvm/TargetParser/NVPTXTargetParser.h"
76#include "llvm/TargetParser/Triple.h"
102template <
typename AttrInfo>
104 int &Val,
unsigned Idx =
UINT_MAX) {
109 if (UVal > (
uint32_t)std::numeric_limits<int>::max()) {
113 <<
toString(I, 10,
false) << 32 << 0;
122 const Expr *E, StringRef &Str,
128 if (!Literal || (!Literal->isUnevaluated() && !Literal->isOrdinary())) {
134 Str = Literal->getString();
144 Diag(Loc->
getLoc(), diag::err_attribute_argument_type)
150 *ArgLocation = Loc->
getLoc();
160 if (!Literal || (!Literal->isUnevaluated() && !Literal->isOrdinary())) {
165 Str = Literal->getString();
186 bool foundStarOperator = IsOverloadedOperatorPresent(
Record, OO_Star);
187 bool foundArrowOperator = IsOverloadedOperatorPresent(
Record, OO_Arrow);
188 if (foundStarOperator && foundArrowOperator)
195 for (
const auto &BaseSpecifier : CXXRecord->bases()) {
196 if (!foundStarOperator)
197 foundStarOperator = IsOverloadedOperatorPresent(
198 BaseSpecifier.getType()->getAsRecordDecl(), OO_Star);
199 if (!foundArrowOperator)
200 foundArrowOperator = IsOverloadedOperatorPresent(
201 BaseSpecifier.getType()->getAsRecordDecl(), OO_Arrow);
204 if (foundStarOperator && foundArrowOperator)
224 if (!RD->isCompleteDefinition())
231 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_decl_not_pointer) << AL << QT;
243 return PT->getPointeeType()->getAsRecordDecl();
248template <
typename AttrType>
255 if (
const auto *CRD = dyn_cast<CXXRecordDecl>(RD)) {
257 return !Base->hasAttr<AttrType>();
271 if (!RD->isCompleteDefinition())
289 if (!RD->isCompleteDefinition())
304 return TN->
hasAttr<CapabilityAttr>();
323 if (
const auto *E = dyn_cast<CastExpr>(Ex))
325 else if (
const auto *E = dyn_cast<ParenExpr>(Ex))
327 else if (
const auto *E = dyn_cast<UnaryOperator>(Ex)) {
328 if (E->getOpcode() == UO_LNot || E->getOpcode() == UO_AddrOf ||
329 E->getOpcode() == UO_Deref)
332 }
else if (
const auto *E = dyn_cast<BinaryOperator>(Ex)) {
333 if (E->getOpcode() == BO_LAnd || E->getOpcode() == BO_LOr)
351 bool ParamIdxOk =
false) {
356 const auto *MD = dyn_cast<const CXXMethodDecl>(D);
357 if (MD && !MD->isStatic()) {
363 diag::warn_thread_attribute_not_on_capability_member)
364 << AL << MD->getParent();
366 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_not_on_non_static_member)
371 for (
unsigned Idx = Sidx; Idx < AL.
getNumArgs(); ++Idx) {
376 Args.push_back(ArgExp);
380 if (
const auto *StrLit = dyn_cast<StringLiteral>(ArgExp)) {
381 if (StrLit->getLength() == 0 ||
382 (StrLit->isOrdinary() && StrLit->getString() ==
"*")) {
385 Args.push_back(ArgExp);
391 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_ignored) << AL;
392 Args.push_back(ArgExp);
401 if (
const auto *UOp = dyn_cast<UnaryOperator>(ArgExp))
402 if (UOp->getOpcode() == UO_AddrOf)
410 if (!RD && ParamIdxOk) {
411 const auto *FD = dyn_cast<FunctionDecl>(D);
412 const auto *IL = dyn_cast<IntegerLiteral>(ArgExp);
414 unsigned int NumParams = FD->getNumParams();
415 llvm::APInt ArgValue = IL->getValue();
416 uint64_t ParamIdxFromOne = ArgValue.getZExtValue();
417 uint64_t ParamIdxFromZero = ParamIdxFromOne - 1;
418 if (!ArgValue.isStrictlyPositive() || ParamIdxFromOne > NumParams) {
420 diag::err_attribute_argument_out_of_bounds_extra_info)
421 << AL << Idx + 1 << NumParams;
424 ArgTy = FD->getParamDecl(ParamIdxFromZero)->getType();
433 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_argument_not_lockable)
436 Args.push_back(ArgExp);
444 T =
T.getNonReferenceType();
445 return T->isDependentType() ||
T->isFunctionPointerType() ||
455 S.
Diag(A.
getLoc(), diag::warn_thread_attribute_not_on_fun_ptr)
456 << A << (isa<FieldDecl>(VD) ? 1 : 0);
470 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_not_on_scoped_lockable_param)
476 bool CheckParmVar =
false) {
477 const auto *VD = dyn_cast<ValueDecl>(D);
482 if (
const auto *PVD = dyn_cast<ParmVarDecl>(VD)) {
494 if (!
isa<AssertCapabilityAttr, AcquireCapabilityAttr,
495 TryAcquireCapabilityAttr, ReleaseCapabilityAttr,
496 RequiresCapabilityAttr, LocksExcludedAttr, LockReturnedAttr>(A))
499 const auto *VD = dyn_cast<ValueDecl>(D);
506 if (
const auto *PVD = dyn_cast<ParmVarDecl>(VD);
536 return !Args.empty();
545 GuardedByAttr(S.
Context, AL, Args.data(), Args.size()));
557 PtGuardedByAttr(S.
Context, AL, Args.data(), Args.size()));
568 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_decl_not_lockable) << AL;
585 Expr **StartArg = &Args[0];
587 AcquiredAfterAttr(S.
Context, AL, StartArg, Args.size()));
595 Expr **StartArg = &Args[0];
597 AcquiredBeforeAttr(S.
Context, AL, StartArg, Args.size()));
614template <
typename AttrInfo>
616 unsigned AttrArgNo) {
617 assert(AI.isArgExpr(AttrArgNo) &&
"Expected expression argument");
618 Expr *AttrArg = AI.getArgAsExpr(AttrArgNo);
627 S.
Diag(SrcLoc, diag::err_attribute_integers_only)
642 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only) << AL;
653 ParamIdx SizeArgNo(SizeArgNoVal, D);
668 AllocSizeAttr(S.
Context, AL, SizeArgNo, NumberArgNo));
677 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
695 unsigned Size = Args.size();
712 unsigned Size = Args.size();
715 Expr **StartArg = &Args[0];
718 LocksExcludedAttr(S.
Context, AL, StartArg, Size));
722 Expr *&Cond, StringRef &Msg) {
728 Cond = Converted.
get();
735 Msg =
"<no message provided>";
741 S.
Diag(AL.
getLoc(), diag::err_attr_cond_never_constant_expr) << AL;
743 S.
Diag(PDiag.first, PDiag.second);
750 S.
Diag(AL.
getLoc(), diag::ext_clang_enable_if);
759 StringRef NewUserDiagnostic;
771 if (
const auto *RD = dyn_cast<CXXRecordDecl>(PD); RD && RD->isLocalClass()) {
773 diag::warn_attribute_exclude_from_explicit_instantiation_local_class)
779 S.
Diag(DA->getLoc(), diag::warn_dllattr_ignored_exclusion_takes_precedence)
781 D->
dropAttrs<DLLExportAttr, DLLImportAttr>();
785 ExcludeFromExplicitInstantiationAttr(S.
Context, AL));
793 const CXXRecordDecl *ClassType;
795 llvm::SmallPtrSet<const ParmVarDecl *, 16> Parms;
799 ArgumentDependenceChecker(
const FunctionDecl *FD) {
801 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD))
809 bool referencesArgs(Expr *E) {
815 bool VisitCXXThisExpr(CXXThisExpr *E)
override {
817 "`this` doesn't refer to the enclosing class?");
822 bool VisitDeclRefExpr(DeclRefExpr *DRE)
override {
823 if (
const auto *PVD = dyn_cast<ParmVarDecl>(DRE->
getDecl()))
824 if (Parms.count(PVD)) {
837 if (
const auto *MethodDecl = dyn_cast<CXXMethodDecl>(DeclFD))
838 if (!MethodDecl->isStatic()) {
839 S.
Diag(AL.
getLoc(), diag::err_attribute_no_member_function) << AL;
846 if (
auto *E = dyn_cast<Expr *>(
Union))
847 return E->getBeginLoc();
851 S.
Diag(Loc, diag::err_attribute_argument_n_type) << AL << Index <<
T;
857 auto *F = dyn_cast_if_present<DeclRefExpr>(AL.
getArgAsExpr(0));
860 return dyn_cast_if_present<FunctionDecl>(F->getFoundDecl());
869 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments_for)
876 for (
unsigned I = 1; I < AL.
getNumArgs(); ++I) {
888 if (Index > DeclFD->getNumParams()) {
889 S.
Diag(AL.
getLoc(), diag::err_attribute_bounds_for_function)
890 << AL << Index << DeclFD << DeclFD->getNumParams();
895 QualType T2 = DeclFD->getParamDecl(Index - 1)->getType();
900 << AL << Index << DeclFD << T2 << I << AttrFD << T1;
904 Indices.push_back(Index - 1);
908 S.
Context, AL, AttrFD, Indices.data(), Indices.size()));
912 S.
Diag(AL.
getLoc(), diag::ext_clang_diagnose_if);
919 StringRef DefaultSevStr;
923 DiagnoseIfAttr::DefaultSeverity DefaultSev;
924 if (!DiagnoseIfAttr::ConvertStrToDefaultSeverity(DefaultSevStr, DefaultSev)) {
926 diag::err_diagnose_if_invalid_diagnostic_type);
930 StringRef WarningGroup;
934 if (WarningGroup.empty() ||
938 diag::err_diagnose_if_unknown_warning)
944 bool ArgDependent =
false;
945 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
946 ArgDependent = ArgumentDependenceChecker(FD).referencesArgs(Cond);
948 S.
Context, AL, Cond, Msg, DefaultSev, WarningGroup, ArgDependent,
958 S.
Diag(Attrs.
getLoc(), diag::warn_attribute_wrong_decl_type)
968 static constexpr const StringRef kWildcard =
"*";
971 bool HasWildcard =
false;
973 const auto AddBuiltinName = [&Names, &HasWildcard](StringRef Name) {
974 if (Name == kWildcard)
976 Names.push_back(Name);
980 if (
const auto *NBA = D->
getAttr<NoBuiltinAttr>())
981 for (StringRef BuiltinName : NBA->builtinNames())
982 AddBuiltinName(BuiltinName);
986 AddBuiltinName(kWildcard);
988 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
989 StringRef BuiltinName;
995 AddBuiltinName(BuiltinName);
997 S.
Diag(LiteralLoc, diag::warn_attribute_no_builtin_invalid_builtin_name)
998 << BuiltinName << AL;
1003 Names.erase(llvm::unique(Names), Names.end());
1006 if (HasWildcard && Names.size() > 1)
1008 diag::err_attribute_no_builtin_wildcard_or_builtin_name)
1011 if (D->
hasAttr<NoBuiltinAttr>())
1014 NoBuiltinAttr(S.
Context, AL, Names.data(), Names.size()));
1018 if (D->
hasAttr<PassObjectSizeAttr>()) {
1019 S.
Diag(D->
getBeginLoc(), diag::err_attribute_only_once_per_parameter) << AL;
1042 S.
Diag(D->
getBeginLoc(), diag::err_attribute_pointers_only) << AL << 1;
1050 ConsumableAttr::ConsumedState DefaultState;
1054 if (!ConsumableAttr::ConvertStrToConsumedState(
1056 S.
Diag(IL->
getLoc(), diag::warn_attribute_type_not_supported)
1061 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1074 if (!RD->hasAttr<ConsumableAttr>()) {
1075 S.
Diag(AL.
getLoc(), diag::warn_attr_on_unconsumable_class) << RD;
1092 for (
unsigned ArgIndex = 0; ArgIndex < AL.
getNumArgs(); ++ArgIndex) {
1093 CallableWhenAttr::ConsumedState CallableState;
1095 StringRef StateString;
1106 if (!CallableWhenAttr::ConvertStrToConsumedState(StateString,
1108 S.
Diag(Loc, diag::warn_attribute_type_not_supported) << AL << StateString;
1112 States.push_back(CallableState);
1116 CallableWhenAttr(S.
Context, AL, States.data(), States.size()));
1120 ParamTypestateAttr::ConsumedState ParamState;
1126 if (!ParamTypestateAttr::ConvertStrToConsumedState(StateString,
1128 S.
Diag(Ident->
getLoc(), diag::warn_attribute_type_not_supported)
1129 << AL << StateString;
1133 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1154 ReturnTypestateAttr::ConsumedState ReturnState;
1158 if (!ReturnTypestateAttr::ConvertStrToConsumedState(
1160 S.
Diag(IL->
getLoc(), diag::warn_attribute_type_not_supported)
1165 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1202 SetTypestateAttr::ConsumedState NewState;
1206 if (!SetTypestateAttr::ConvertStrToConsumedState(Param, NewState)) {
1207 S.
Diag(Ident->
getLoc(), diag::warn_attribute_type_not_supported)
1212 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1224 TestTypestateAttr::ConsumedState TestState;
1228 if (!TestTypestateAttr::ConvertStrToConsumedState(Param, TestState)) {
1229 S.
Diag(Ident->
getLoc(), diag::warn_attribute_type_not_supported)
1234 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1249 if (
auto *TD = dyn_cast<TagDecl>(D))
1251 else if (
auto *FD = dyn_cast<FieldDecl>(D)) {
1252 bool BitfieldByteAligned = (!FD->
getType()->isDependentType() &&
1258 if (BitfieldByteAligned)
1260 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored_for_field_of_type)
1266 if (BitfieldByteAligned)
1267 S.
Diag(AL.
getLoc(), diag::warn_attribute_packed_for_bitfield);
1273 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored) << AL;
1279 assert(CTD &&
"attribute does not appertain to this declaration");
1287 if (!
T.hasQualifiers() &&
T->isTypedefNameType()) {
1290 if (
const auto *CTSD = dyn_cast_if_present<ClassTemplateSpecializationDecl>(
1291 T->getAsCXXRecordDecl())) {
1292 Template = CTSD->getSpecializedTemplate();
1293 }
else if (
const auto *TST =
T->getAs<TemplateSpecializationType>()) {
1294 while (TST && TST->isTypeAlias())
1295 TST = TST->getAliasedType()->getAs<TemplateSpecializationType>();
1297 Template = TST->getTemplateName().getAsTemplateDecl();
1306 S.
Diag(AL.
getLoc(), diag::err_attribute_not_typedef_for_specialization)
1309 S.
Diag(TT->getDecl()->getLocation(), diag::note_entity_declared_at)
1318 NoSpecializationsAttr::Create(S.
Context, Message, AL));
1322 if (
T->isDependentType())
1325 if (
T->isReferenceType())
1328 T =
T.getNonReferenceType();
1333 if (
const RecordType *UT =
T->getAsUnionType()) {
1335 if (UD->
hasAttr<TransparentUnionAttr>()) {
1336 for (
const auto *I : UD->
fields()) {
1344 return T->isAnyPointerType() ||
T->isBlockPointerType();
1350 bool isReturnValue =
false) {
1353 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only)
1354 << AL << AttrParmRange << TypeRange;
1356 S.
Diag(AL.
getLoc(), diag::warn_attribute_pointers_only)
1357 << AL << AttrParmRange << TypeRange << 0;
1365 for (
unsigned I = 0; I < AL.
getNumArgs(); ++I) {
1369 D, AL, I + 1, Ex, Idx,
1382 NonNullArgs.push_back(Idx);
1392 if (AL.
getNumArgs() != 0 && NonNullArgs.empty())
1403 I != E && !AnyPointers; ++I) {
1410 S.
Diag(AL.
getLoc(), diag::warn_attribute_nonnull_no_pointers);
1413 ParamIdx *Start = NonNullArgs.data();
1414 unsigned Size = NonNullArgs.size();
1415 llvm::array_pod_sort(Start, Start + Size);
1425 S.
Diag(AL.
getLoc(), diag::warn_attribute_nonnull_parm_no_args)
1456 S.
Diag(AL.
getLoc(), diag::warn_attribute_pointers_only)
1481 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
1487 std::optional<llvm::APSInt> I = llvm::APSInt(64);
1490 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1493 Diag(AttrLoc, diag::err_attribute_argument_type)
1498 if (!I->isPowerOf2()) {
1499 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
1505 Diag(CI.
getLoc(), diag::warn_assume_aligned_too_great)
1510 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1524 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
1548 if (AttrName.size() > 4 && AttrName.starts_with(
"__") &&
1549 AttrName.ends_with(
"__")) {
1550 AttrName = AttrName.drop_front(2).drop_back(2);
1566 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
1572 OwnershipAttr::OwnershipKind K =
1573 OwnershipAttr(S.
Context, AL,
nullptr,
nullptr, 0).getOwnKind();
1577 case OwnershipAttr::Takes:
1578 case OwnershipAttr::Holds:
1580 S.
Diag(AL.
getLoc(), diag::err_attribute_too_few_arguments) << AL << 2;
1584 case OwnershipAttr::Returns:
1586 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 2;
1594 if (K == OwnershipAttr::Returns &&
1596 S.
Diag(AL.
getLoc(), diag::err_ownership_takes_return_type) << AL;
1602 StringRef ModuleName =
Module->getName();
1609 if (K == OwnershipAttr::Returns && AL.
getNumArgs() == 1) {
1611 if (I->getOwnKind() == OwnershipAttr::Returns && I->args_size() > 0) {
1612 S.
Diag(I->getLocation(), diag::err_ownership_returns_index_mismatch)
1613 << I->args_begin()->getSourceIndex() << 0;
1614 S.
Diag(AL.
getLoc(), diag::note_ownership_returns_index_mismatch)
1622 for (
unsigned i = 1; i < AL.
getNumArgs(); ++i) {
1632 case OwnershipAttr::Takes:
1633 case OwnershipAttr::Holds:
1634 if (!
T->isAnyPointerType() && !
T->isBlockPointerType())
1637 case OwnershipAttr::Returns:
1638 if (!
T->isIntegerType())
1643 S.
Diag(AL.
getLoc(), diag::err_ownership_type) << AL << Err
1652 if (I->getOwnKind() != K && llvm::is_contained(I->args(), Idx)) {
1653 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
1656 I->isRegularKeywordAttribute());
1660 if (K == OwnershipAttr::Returns &&
1661 I->getOwnKind() == OwnershipAttr::Returns) {
1662 bool IHasArgs = I->args_size() > 0;
1664 if (!IHasArgs || !llvm::is_contained(I->args(), Idx)) {
1665 unsigned IIdx = IHasArgs ? I->args_begin()->getSourceIndex() : 0;
1667 S.
Diag(I->getLocation(), diag::err_ownership_returns_index_mismatch)
1668 << IIdx << (IHasArgs ? 0 : 1);
1670 S.
Diag(AL.
getLoc(), diag::note_ownership_returns_index_mismatch)
1674 }
else if (K == OwnershipAttr::Takes &&
1675 I->getOwnKind() == OwnershipAttr::Takes) {
1676 if (I->getModule()->getName() != ModuleName) {
1677 S.
Diag(I->getLocation(), diag::err_ownership_takes_class_mismatch)
1678 << I->getModule()->getName();
1679 S.
Diag(AL.
getLoc(), diag::note_ownership_takes_class_mismatch)
1686 OwnershipArgs.push_back(Idx);
1689 ParamIdx *Start = OwnershipArgs.data();
1690 unsigned Size = OwnershipArgs.size();
1691 llvm::array_pod_sort(Start, Start + Size);
1699 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
1715 S.
Diag(AL.
getLoc(), diag::err_attribute_weakref_not_global_context)
1760 std::unique_ptr<char, llvm::FreeDeleter> Demangled;
1762 Demangled.reset(llvm::itaniumDemangle(Str,
false));
1773 if (MC->shouldMangleDeclName(ND)) {
1774 llvm::raw_svector_ostream Out(Name);
1778 Name = ND->getIdentifier()->getName();
1794 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << FD << 1;
1808 S.
Diag(AL.
getLoc(), diag::err_alias_not_supported_on_darwin);
1816 S.
Diag(AL.
getLoc(), diag::err_alias_not_supported_on_nvptx);
1820 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
1822 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << FD << 0;
1827 if (VD->isThisDeclarationADefinition() && VD->isExternallyVisible()) {
1828 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << VD << 0;
1845 if (Model !=
"global-dynamic" && Model !=
"local-dynamic"
1846 && Model !=
"initial-exec" && Model !=
"local-exec") {
1847 S.
Diag(LiteralLoc, diag::err_attr_tlsmodel_arg);
1857 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only)
1869 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 0;
1879 if (
auto *DRE = dyn_cast<DeclRefExpr>(DeallocE)) {
1880 DeallocFD = dyn_cast<FunctionDecl>(DRE->
getDecl());
1883 S.
Diag(DeallocLoc, diag::err_attribute_malloc_arg_not_function)
1887 }
else if (
auto *ULE = dyn_cast<UnresolvedLookupExpr>(DeallocE)) {
1889 DeallocNI = ULE->getNameInfo();
1891 S.
Diag(DeallocLoc, diag::err_attribute_malloc_arg_not_function)
1898 S.
Diag(DeallocLoc, diag::err_attribute_malloc_arg_not_function) << 0;
1906 DeallocPtrIdx =
ParamIdx(1, DeallocFD);
1917 diag::err_attribute_malloc_arg_not_function_with_pointer_arg)
1931 diag::err_attribute_malloc_arg_refers_to_non_pointer_type)
1940 S.
Diag(AL.
getLoc(), diag::warn_attribute_form_ignored) << AL;
1942 RestrictAttr(S.
Context, AL, DeallocE, DeallocPtrIdx));
1951 auto emitWarning = [
this, &CI](
unsigned NoteDiagID) {
1952 Diag(CI.
getLoc(), diag::warn_attribute_return_span_only) << CI;
1959 return emitWarning(diag::note_returned_incomplete_type);
1962 return emitWarning(diag::note_returned_not_struct);
1963 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
1964 if (CXXRD->getNumBases() > 0) {
1965 return emitWarning(diag::note_type_inherits_from_base);
1969 auto FieldsCount = std::distance(FieldsBegin, RD->
field_end());
1970 if (FieldsCount != 2)
1971 return emitWarning(diag::note_returned_not_two_field_struct) << FieldsCount;
1972 QualType FirstFieldType = FieldsBegin->getType();
1973 QualType SecondFieldType = std::next(FieldsBegin)->getType();
1974 auto validatePointerType = [](
const QualType &
T) {
1976 return T->isPointerType() && !
T->isFunctionPointerType();
1978 auto checkIntegerType = [
this, emitWarning](
const QualType &
T,
1979 const int FieldNo) ->
bool {
1980 const auto *BT = dyn_cast<BuiltinType>(
T.getCanonicalType());
1981 if (!BT || !BT->isInteger())
1982 return emitWarning(diag::note_returned_not_integer_field) << FieldNo;
1984 if (
Context.getTypeSize(BT) < IntSize)
1985 return emitWarning(diag::note_returned_not_wide_enough_field)
1986 << FieldNo << IntSize;
1989 if (validatePointerType(FirstFieldType) &&
1990 validatePointerType(SecondFieldType)) {
1993 }
else if (validatePointerType(FirstFieldType)) {
1995 return checkIntegerType(SecondFieldType, 2);
1996 }
else if (validatePointerType(SecondFieldType)) {
1998 return checkIntegerType(FirstFieldType, 1);
2000 return emitWarning(diag::note_returned_not_span_struct);
2016 if (
const auto *
Other = D->
getAttr<CPUDispatchAttr>()) {
2017 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
2018 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
2021 }
else if (AL.
getParsedKind() == ParsedAttr::AT_CPUSpecific) {
2025 if (
const auto *
Other = D->
getAttr<CPUSpecificAttr>()) {
2026 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
2027 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
2034 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
2035 if (MD->getParent()->isLambda()) {
2036 S.
Diag(AL.
getLoc(), diag::err_attribute_dll_lambda) << AL;
2047 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
2056 S.
Diag(CPUArg->
getLoc(), diag::err_invalid_cpu_specific_dispatch_value)
2057 << CPUName << (AL.
getKind() == ParsedAttr::AT_CPUDispatch);
2063 return Target.CPUSpecificManglingCharacter(CPUName) ==
2066 S.
Diag(AL.
getLoc(), diag::warn_multiversion_duplicate_entries);
2073 if (AL.
getKind() == ParsedAttr::AT_CPUSpecific)
2075 CPUSpecificAttr(S.
Context, AL, CPUs.data(), CPUs.size()));
2078 CPUDispatchAttr(S.
Context, AL, CPUs.data(), CPUs.size()));
2083 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
2094 const auto &
Arch = Triple.getArch();
2095 if (
Arch != llvm::Triple::x86 &&
2096 (
Arch != llvm::Triple::arm &&
Arch != llvm::Triple::thumb)) {
2097 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_on_arch)
2098 << AL << Triple.getArchName();
2105 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_decl_type)
2122 const Stmt *OnlyStmt =
nullptr;
2124 if (
const auto *Compound = dyn_cast<CompoundStmt>(Body)) {
2125 if (Compound->size() != 1)
2127 OnlyStmt = *Compound->body_begin();
2133 if (
const auto *EWC = dyn_cast<ExprWithCleanups>(OnlyStmt)) {
2134 OnlyStmt = EWC->getSubExpr();
2138 const auto *MD = dyn_cast<CXXMethodDecl>(FD);
2139 if (MD && MD->isVirtual()) {
2140 const auto *RD = MD->getParent();
2141 return MD->hasAttr<FinalAttr>() || (RD && RD->isEffectivelyFinal());
2149 auto *FD = dyn_cast<FunctionDecl>(D);
2170 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD);
2184 S.
Diag(Attrs.
getLoc(), diag::warn_attribute_wrong_decl_type)
2210 S.
Diag(Attrs.
getLoc(), diag::warn_nocf_check_attribute_ignored);
2228 Diag(AL.
getLoc(), diag::err_keyword_not_supported_on_target)
2247 ? diag::err_attribute_wrong_decl_type
2248 : diag::warn_attribute_wrong_decl_type)
2284 if (VecReturnAttr *A = D->
getAttr<VecReturnAttr>()) {
2285 S.
Diag(AL.
getLoc(), diag::err_repeat_attribute) << A;
2293 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
2298 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_pod_record);
2302 for (
const auto *I : R->fields()) {
2303 if ((count == 1) || !I->getType()->isVectorType()) {
2304 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
2319 S.
Diag(AL.
getLoc(), diag::ext_cxx17_attr) << AL;
2334 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
2344 APValue(llvm::APSInt::getUnsigned(priority)));
2352 S.
Diag(AL.
getLoc(), diag::err_hlsl_init_priority_unsupported);
2371template <
typename AttrTy>
2383 VersionTuple Introduced,
2384 VersionTuple Deprecated,
2385 VersionTuple Obsoleted) {
2386 StringRef PlatformName
2387 = AvailabilityAttr::getPrettyPlatformName(Platform->
getName());
2388 if (PlatformName.empty())
2389 PlatformName = Platform->
getName();
2393 if (!Introduced.empty() && !Deprecated.empty() &&
2394 !(Introduced <= Deprecated)) {
2395 S.
Diag(Range.getBegin(), diag::warn_availability_version_ordering)
2396 << 1 << PlatformName << Deprecated.getAsString()
2397 << 0 << Introduced.getAsString();
2401 if (!Introduced.empty() && !Obsoleted.empty() &&
2402 !(Introduced <= Obsoleted)) {
2403 S.
Diag(Range.getBegin(), diag::warn_availability_version_ordering)
2404 << 2 << PlatformName << Obsoleted.getAsString()
2405 << 0 << Introduced.getAsString();
2409 if (!Deprecated.empty() && !Obsoleted.empty() &&
2410 !(Deprecated <= Obsoleted)) {
2411 S.
Diag(Range.getBegin(), diag::warn_availability_version_ordering)
2412 << 2 << PlatformName << Obsoleted.getAsString()
2413 << 1 << Deprecated.getAsString();
2425 bool BeforeIsOkay) {
2426 if (
X.empty() || Y.empty())
2432 if (BeforeIsOkay &&
X < Y)
2440 bool Implicit, VersionTuple Introduced, VersionTuple Deprecated,
2441 VersionTuple Obsoleted,
bool IsUnavailable, StringRef Message,
2445 VersionTuple MergedIntroduced = Introduced;
2446 VersionTuple MergedDeprecated = Deprecated;
2447 VersionTuple MergedObsoleted = Obsoleted;
2448 bool FoundAny =
false;
2449 bool OverrideOrImpl =
false;
2453 OverrideOrImpl =
false;
2459 OverrideOrImpl =
true;
2465 for (
unsigned i = 0, e = Attrs.size(); i != e;) {
2466 auto *OldAA = dyn_cast<AvailabilityAttr>(Attrs[i]);
2473 if (OldEnvironment != Environment) {
2478 if (OldAA->getPlatform() != Platform) {
2481 if (InferredPlatformII) {
2482 if (OldAA->getPlatform() == InferredPlatformII)
2488 if (AvailabilityAttr *
Inf = OldAA->getInferredAttrAs();
2489 Inf &&
Inf->getPlatform() == Platform) {
2490 Attrs.erase(Attrs.begin() + i);
2502 if (OldAA->getPriority() < Priority)
2508 if (OldAA->getPriority() > Priority) {
2509 Attrs.erase(Attrs.begin() + i);
2515 VersionTuple OldIntroduced = OldAA->getIntroduced();
2516 VersionTuple OldDeprecated = OldAA->getDeprecated();
2517 VersionTuple OldObsoleted = OldAA->getObsoleted();
2518 bool OldIsUnavailable = OldAA->getUnavailable();
2520 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl) ||
2521 !
versionsMatch(Deprecated, OldDeprecated, OverrideOrImpl) ||
2523 !(OldIsUnavailable == IsUnavailable ||
2524 (OverrideOrImpl && !OldIsUnavailable && IsUnavailable))) {
2525 if (OverrideOrImpl) {
2527 VersionTuple FirstVersion;
2528 VersionTuple SecondVersion;
2529 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl)) {
2531 FirstVersion = OldIntroduced;
2532 SecondVersion = Introduced;
2533 }
else if (!
versionsMatch(Deprecated, OldDeprecated, OverrideOrImpl)) {
2535 FirstVersion = Deprecated;
2536 SecondVersion = OldDeprecated;
2537 }
else if (!
versionsMatch(Obsoleted, OldObsoleted, OverrideOrImpl)) {
2539 FirstVersion = Obsoleted;
2540 SecondVersion = OldObsoleted;
2544 Diag(OldAA->getLocation(),
2545 diag::warn_mismatched_availability_override_unavail)
2546 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2558 Diag(OldAA->getLocation(),
2559 diag::warn_mismatched_availability_override)
2561 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2562 << FirstVersion.getAsString() << SecondVersion.getAsString()
2566 Diag(CI.
getLoc(), diag::note_overridden_method);
2568 Diag(CI.
getLoc(), diag::note_protocol_method);
2570 Diag(OldAA->getLocation(), diag::warn_mismatched_availability);
2571 Diag(CI.
getLoc(), diag::note_previous_attribute);
2574 Attrs.erase(Attrs.begin() + i);
2579 VersionTuple MergedIntroduced2 = MergedIntroduced;
2580 VersionTuple MergedDeprecated2 = MergedDeprecated;
2581 VersionTuple MergedObsoleted2 = MergedObsoleted;
2583 if (MergedIntroduced2.empty())
2584 MergedIntroduced2 = OldIntroduced;
2585 if (MergedDeprecated2.empty())
2586 MergedDeprecated2 = OldDeprecated;
2587 if (MergedObsoleted2.empty())
2588 MergedObsoleted2 = OldObsoleted;
2591 MergedIntroduced2, MergedDeprecated2,
2592 MergedObsoleted2)) {
2593 Attrs.erase(Attrs.begin() + i);
2598 MergedIntroduced = MergedIntroduced2;
2599 MergedDeprecated = MergedDeprecated2;
2600 MergedObsoleted = MergedObsoleted2;
2606 MergedIntroduced == Introduced &&
2607 MergedDeprecated == Deprecated &&
2608 MergedObsoleted == Obsoleted)
2614 MergedDeprecated, MergedObsoleted) &&
2616 auto *Avail = ::new (
Context) AvailabilityAttr(
2617 Context, CI, Platform, Introduced, Deprecated, Obsoleted, IsUnavailable,
2618 Message, IsStrict, Replacement, Priority, Environment,
2628 bool Implicit, VersionTuple Introduced, VersionTuple Deprecated,
2629 VersionTuple Obsoleted,
bool IsUnavailable, StringRef Message,
2634 D, CI, Platform,
Implicit, Introduced, Deprecated, Obsoleted,
2635 IsUnavailable, Message, IsStrict, Replacement, AMK, Priority,
2636 IIEnvironment, InferredPlatformII);
2637 if (!OrigAttr || !InferredPlatformII)
2640 auto *InferredAttr = ::new (
Context) AvailabilityAttr(
2641 Context, CI, InferredPlatformII, OrigAttr->getIntroduced(),
2642 OrigAttr->getDeprecated(), OrigAttr->getObsoleted(),
2643 OrigAttr->getUnavailable(), OrigAttr->getMessage(), OrigAttr->getStrict(),
2644 OrigAttr->getReplacement(),
2648 IIEnvironment,
nullptr);
2649 InferredAttr->setImplicit(
true);
2650 OrigAttr->setInferredAttr(InferredAttr);
2658 bool &IsUnavailable,
2659 VersionTuple &Introduced,
2660 VersionTuple &Deprecated,
2661 VersionTuple &Obsolete,
Sema &S) {
2664 if (TT.getOS() != llvm::Triple::XROS)
2668 NewII = &Context.Idents.get(
"xros");
2669 else if (II->
getName() ==
"ios_app_extension")
2670 NewII = &Context.Idents.get(
"xros_app_extension");
2675 auto MakeUnavailable = [&]() {
2676 IsUnavailable =
true;
2678 Introduced = VersionTuple();
2679 Deprecated = VersionTuple();
2680 Obsolete = VersionTuple();
2693 llvm::Triple::IOS, llvm::Triple::UnknownEnvironment, llvm::Triple::XROS,
2694 llvm::Triple::UnknownEnvironment));
2700 if (!Introduced.empty()) {
2701 auto NewIntroduced = Mapping->mapIntroducedAvailabilityVersion(Introduced);
2702 if (!NewIntroduced) {
2706 Introduced = *NewIntroduced;
2709 if (!Obsolete.empty()) {
2711 Mapping->mapDeprecatedObsoletedAvailabilityVersion(Obsolete);
2716 Obsolete = *NewObsolete;
2719 if (!Deprecated.empty()) {
2720 auto NewDeprecated =
2721 Mapping->mapDeprecatedObsoletedAvailabilityVersion(Deprecated);
2722 Deprecated = NewDeprecated ? *NewDeprecated : VersionTuple();
2741 StringRef PrettyName = AvailabilityAttr::getPrettyPlatformName(II->
getName());
2742 if (PrettyName.empty())
2743 S.
Diag(Platform->
getLoc(), diag::warn_availability_unknown_platform)
2746 auto *ND = dyn_cast<NamedDecl>(D);
2754 const llvm::Triple::OSType PlatformOS = AvailabilityAttr::getOSType(
2755 AvailabilityAttr::canonicalizePlatformName(II->
getName()));
2757 auto reportAndUpdateIfInvalidOS = [&](
auto &InputVersion) ->
void {
2758 const bool IsInValidRange =
2759 llvm::Triple::isValidVersionForOS(PlatformOS, InputVersion);
2761 auto CanonicalVersion = llvm::Triple::getCanonicalVersionForOS(
2762 PlatformOS, InputVersion, IsInValidRange);
2763 if (!IsInValidRange) {
2764 S.
Diag(Platform->
getLoc(), diag::warn_availability_invalid_os_version)
2765 << InputVersion.getAsString() << PrettyName;
2767 diag::note_availability_invalid_os_version_adjusted)
2768 << CanonicalVersion.getAsString();
2770 InputVersion = CanonicalVersion;
2773 if (PlatformOS != llvm::Triple::OSType::UnknownOS) {
2774 reportAndUpdateIfInvalidOS(Introduced.
Version);
2775 reportAndUpdateIfInvalidOS(Deprecated.
Version);
2776 reportAndUpdateIfInvalidOS(Obsoleted.
Version);
2782 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getMessageExpr()))
2783 Str = SE->getString();
2784 StringRef Replacement;
2785 if (
const auto *SE =
2787 Replacement = SE->getString();
2789 if (II->
isStr(
"swift")) {
2791 (!IsUnavailable && !Deprecated.
isValid())) {
2793 diag::warn_availability_swift_unavailable_deprecated_only);
2798 if (II->
isStr(
"fuchsia")) {
2799 std::optional<unsigned>
Min, Sub;
2801 (Sub = Introduced.
Version.getSubminor())) {
2802 S.
Diag(AL.
getLoc(), diag::warn_availability_fuchsia_unavailable_minor);
2817 if (EnvironmentLoc) {
2820 if (AvailabilityAttr::getEnvironmentType(
2822 llvm::Triple::EnvironmentType::UnknownEnvironment)
2824 diag::warn_availability_unknown_environment)
2828 diag::err_availability_unexpected_parameter)
2829 <<
"environment" << 1;
2835 if (II->
getName() ==
"anyappleos") {
2837 auto ValidateVersion = [&](
const llvm::VersionTuple &Version,
2841 S.
Diag(Loc, diag::err_availability_invalid_anyappleos_version)
2842 << Version.getAsString();
2856 if (!
T.isOSDarwin())
2859 StringRef PlatformName;
2863 PlatformName =
"macos";
2864 else if (
T.getOS() == llvm::Triple::IOS &&
T.isMacCatalystEnvironment())
2865 PlatformName =
"maccatalyst";
2867 PlatformName = llvm::Triple::getOSTypeName(
T.getOS());
2877 Obsoleted.
Version, IsUnavailable, Str, IsStrict, Replacement,
2879 InferredPlatformII);
2888 Obsoleted.
Version, IsUnavailable, Str, IsStrict, Replacement,
2895 bool NewIsUnavailable = IsUnavailable;
2896 VersionTuple NewIntroduced = Introduced.
Version;
2897 VersionTuple NewDeprecated = Deprecated.
Version;
2898 VersionTuple NewObsoleted = Obsoleted.
Version;
2900 NewIntroduced, NewDeprecated,
2903 ND, AL, NewII,
true , NewIntroduced, NewDeprecated,
2904 NewObsoleted, NewIsUnavailable, Str, IsStrict, Replacement,
2918 else if (II->
getName() ==
"ios_app_extension")
2923 const auto *IOSToWatchOSMapping =
2928 auto adjustWatchOSVersion =
2929 [IOSToWatchOSMapping](VersionTuple Version) -> VersionTuple {
2930 if (Version.empty())
2932 auto MinimumWatchOSVersion = VersionTuple(2, 0);
2934 if (IOSToWatchOSMapping) {
2935 if (
auto MappedVersion = IOSToWatchOSMapping->map(
2936 Version, MinimumWatchOSVersion, std::nullopt)) {
2937 return *MappedVersion;
2941 auto Major = Version.getMajor();
2942 auto NewMajor = Major;
2945 else if (Major < 12)
2946 NewMajor = Major - 7;
2947 if (NewMajor >= 2) {
2948 if (Version.getMinor()) {
2949 if (Version.getSubminor())
2950 return VersionTuple(NewMajor, *Version.getMinor(),
2951 *Version.getSubminor());
2953 return VersionTuple(NewMajor, *Version.getMinor());
2955 return VersionTuple(NewMajor);
2958 return MinimumWatchOSVersion;
2961 auto NewIntroduced = adjustWatchOSVersion(Introduced.
Version);
2962 auto NewDeprecated = adjustWatchOSVersion(Deprecated.
Version);
2963 auto NewObsoleted = adjustWatchOSVersion(Obsoleted.
Version);
2966 ND, AL, NewII,
true , NewIntroduced, NewDeprecated,
2967 NewObsoleted, IsUnavailable, Str, IsStrict, Replacement,
2979 else if (II->
getName() ==
"ios_app_extension")
2984 const auto *IOSToTvOSMapping =
2989 auto AdjustTvOSVersion =
2990 [IOSToTvOSMapping](VersionTuple Version) -> VersionTuple {
2991 if (Version.empty())
2994 if (IOSToTvOSMapping) {
2995 if (
auto MappedVersion = IOSToTvOSMapping->map(
2996 Version, VersionTuple(0, 0), std::nullopt)) {
2997 return *MappedVersion;
3003 auto NewIntroduced = AdjustTvOSVersion(Introduced.
Version);
3004 auto NewDeprecated = AdjustTvOSVersion(Deprecated.
Version);
3005 auto NewObsoleted = AdjustTvOSVersion(Obsoleted.
Version);
3008 ND, AL, NewII,
true , NewIntroduced, NewDeprecated,
3009 NewObsoleted, IsUnavailable, Str, IsStrict, Replacement,
3016 llvm::Triple::IOS &&
3018 auto GetSDKInfo = [&]() {
3027 else if (II->
getName() ==
"ios_app_extension")
3030 auto MinMacCatalystVersion = [](
const VersionTuple &
V) {
3033 if (
V.getMajor() < 13 ||
3034 (
V.getMajor() == 13 &&
V.getMinor() && *
V.getMinor() < 1))
3035 return VersionTuple(13, 1);
3039 ND, AL, NewII,
true ,
3040 MinMacCatalystVersion(Introduced.
Version),
3041 MinMacCatalystVersion(Deprecated.
Version),
3042 MinMacCatalystVersion(Obsoleted.
Version), IsUnavailable, Str,
3047 }
else if (II->
getName() ==
"macos" && GetSDKInfo() &&
3049 !Obsoleted.
Version.empty())) {
3050 if (
const auto *MacOStoMacCatalystMapping =
3051 GetSDKInfo()->getVersionMapping(
3058 auto RemapMacOSVersion =
3059 [&](
const VersionTuple &
V) -> std::optional<VersionTuple> {
3061 return std::nullopt;
3063 if (
V.getMajor() == 100000)
3064 return VersionTuple(100000);
3066 return MacOStoMacCatalystMapping->map(
V, VersionTuple(13, 1),
3069 std::optional<VersionTuple> NewIntroduced =
3070 RemapMacOSVersion(Introduced.
Version),
3072 RemapMacOSVersion(Deprecated.
Version),
3074 RemapMacOSVersion(Obsoleted.
Version);
3075 if (NewIntroduced || NewDeprecated || NewObsoleted) {
3076 auto VersionOrEmptyVersion =
3077 [](
const std::optional<VersionTuple> &
V) -> VersionTuple {
3078 return V ? *
V : VersionTuple();
3081 ND, AL, NewII,
true ,
3082 VersionOrEmptyVersion(NewIntroduced),
3083 VersionOrEmptyVersion(NewDeprecated),
3084 VersionOrEmptyVersion(NewObsoleted),
false, Str,
3103 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(0)))
3105 StringRef DefinedIn;
3106 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(1)))
3107 DefinedIn = SE->getString();
3108 bool IsGeneratedDeclaration = AL.
getArgAsIdent(2) !=
nullptr;
3110 if (
const auto *SE = dyn_cast_if_present<StringLiteral>(AL.
getArgAsExpr(3)))
3111 USR = SE->getString();
3118 VisibilityAttr::VisibilityType
Value) {
3119 if (VisibilityAttr *
Attr = D->
getAttr<VisibilityAttr>()) {
3121 Diag(Loc, diag::err_mismatched_visibility);
3128 typename T::VisibilityType value) {
3131 typename T::VisibilityType existingValue = existingAttr->getVisibility();
3132 if (existingValue == value)
3134 S.
Diag(existingAttr->getLocation(), diag::err_mismatched_visibility);
3135 S.
Diag(CI.
getLoc(), diag::note_previous_attribute);
3143 VisibilityAttr::VisibilityType Vis) {
3144 return ::mergeVisibilityAttr<VisibilityAttr>(*
this, D, CI, Vis);
3149 TypeVisibilityAttr::VisibilityType Vis) {
3150 return ::mergeVisibilityAttr<TypeVisibilityAttr>(*
this, D, CI, Vis);
3154 bool isTypeVisibility) {
3175 VisibilityAttr::VisibilityType
type;
3176 if (!VisibilityAttr::ConvertStrToVisibilityType(TypeStr,
type)) {
3177 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported) << AL
3184 if (
type == VisibilityAttr::Protected &&
3186 S.
Diag(AL.
getLoc(), diag::warn_attribute_protected_visibility);
3187 type = VisibilityAttr::Default;
3191 if (isTypeVisibility) {
3193 D, AL, (TypeVisibilityAttr::VisibilityType)
type);
3202 unsigned sentinel = (
unsigned)SentinelAttr::DefaultSentinel;
3205 std::optional<llvm::APSInt> Idx = llvm::APSInt(32);
3207 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3212 if (Idx->isSigned() && Idx->isNegative()) {
3213 S.
Diag(AL.
getLoc(), diag::err_attribute_sentinel_less_than_zero)
3218 sentinel = Idx->getZExtValue();
3221 unsigned nullPos = (
unsigned)SentinelAttr::DefaultNullPos;
3224 std::optional<llvm::APSInt> Idx = llvm::APSInt(32);
3226 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3230 nullPos = Idx->getZExtValue();
3232 if ((Idx->isSigned() && Idx->isNegative()) || nullPos > 1) {
3235 S.
Diag(AL.
getLoc(), diag::err_attribute_sentinel_not_zero_or_one)
3241 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
3244 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_named_arguments);
3249 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
3252 }
else if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
3253 if (!MD->isVariadic()) {
3254 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
3257 }
else if (
const auto *BD = dyn_cast<BlockDecl>(D)) {
3258 if (!BD->isVariadic()) {
3259 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 1;
3262 }
else if (
const auto *
V = dyn_cast<VarDecl>(D)) {
3271 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_named_arguments);
3276 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << m;
3280 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
3286 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
3298 S.
Diag(AL.
getLoc(), diag::warn_attribute_void_function_method) << AL << 0;
3301 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
3302 if (MD->getReturnType()->isVoidType()) {
3303 S.
Diag(AL.
getLoc(), diag::warn_attribute_void_function_method) << AL << 1;
3320 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
3331 if (LO.CPlusPlus && !LO.CPlusPlus20)
3332 S.
Diag(AL.
getLoc(), diag::ext_cxx20_attr) << AL;
3336 }
else if (LO.CPlusPlus && !LO.CPlusPlus17)
3337 S.
Diag(AL.
getLoc(), diag::ext_cxx17_attr) << AL;
3344 S.
Diag(AL.
getLoc(), diag::warn_unused_result_typedef_unsupported_spelling)
3357 S.
Diag(AL.
getLoc(), diag::warn_attribute_invalid_on_definition)
3364 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
3377template <
class Attribute>
3379 const unsigned Idx) {
3388 std::optional<llvm::APSInt> I = llvm::APSInt(64);
3395 if (!I->isIntN(32)) {
3397 <<
toString(*I, 10,
false) << 32 << 1;
3401 S.
Diag(E->
getExprLoc(), diag::err_attribute_requires_positive_integer)
3409 "Unexpected PerformCopyInitialization() failure.");
3415template <
typename WorkGroupAttr>
3418 for (
unsigned i = 0; i < 3; ++i) {
3425 auto IsZero = [&](
Expr *E) {
3426 if (E->isValueDependent())
3428 std::optional<llvm::APSInt> I = E->getIntegerConstantExpr(S.
Context);
3429 assert(I &&
"Non-integer constant expr");
3433 if (!llvm::all_of(WGSize, IsZero)) {
3434 for (
unsigned i = 0; i < 3; ++i) {
3436 if (IsZero(WGSize[i])) {
3437 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_is_zero)
3448 assert(L &&
"Non-integer constant expr");
3449 std::optional<llvm::APSInt> R = RHS->getIntegerConstantExpr(S.
Context);
3450 assert(L &&
"Non-integer constant expr");
3454 WorkGroupAttr *Existing = D->
getAttr<WorkGroupAttr>();
3456 !llvm::equal(std::initializer_list<Expr *>{Existing->getXDim(),
3457 Existing->getYDim(),
3458 Existing->getZDim()},
3460 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3463 WorkGroupAttr(S.
Context, AL, WGSize[0], WGSize[1], WGSize[2]));
3468 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
3474 assert(ParmTSI &&
"no type source info for attribute argument");
3479 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_argument) << 2 << AL;
3483 if (VecTypeHintAttr *A = D->
getAttr<VecTypeHintAttr>()) {
3485 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3497 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
3502 if (SectionAttr *ExistingAttr = D->
getAttr<SectionAttr>()) {
3503 if (ExistingAttr->getName() == Name)
3505 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section)
3507 Diag(CI.
getLoc(), diag::note_previous_attribute);
3514 if (!
Context.getTargetInfo().getTriple().isOSDarwin())
3515 return llvm::Error::success();
3518 StringRef Segment, Section;
3519 unsigned TAA, StubSize;
3521 return llvm::MCSectionMachO::ParseSectionSpecifier(SecName, Segment, Section,
3522 TAA, HasTAA, StubSize);
3527 Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
3557 if (Triple.isLoongArch()) {
3558 return Str ==
"normal" || Str ==
"medium" || Str ==
"extreme";
3560 assert(Triple.getArch() == llvm::Triple::x86_64 &&
3561 "only loongarch/x86-64 supported");
3562 return Str ==
"small" || Str ==
"large";
3569 auto IsTripleSupported = [](llvm::Triple &Triple) {
3570 return Triple.getArch() == llvm::Triple::ArchType::x86_64 ||
3571 Triple.isLoongArch();
3581 Triples.push_back(aux->getTriple());
3590 auto SupportedTripleIt = llvm::find_if(Triples, IsTripleSupported);
3591 if (SupportedTripleIt == Triples.end()) {
3592 S.
Diag(LiteralLoc, diag::warn_unknown_attribute_ignored) << AL;
3596 llvm::CodeModel::Model CM;
3597 if (!CodeModelAttr::ConvertStrToModel(Str, CM) ||
3599 S.
Diag(LiteralLoc, diag::err_attr_codemodel_arg) << Str;
3609 StringRef CodeSegName) {
3611 S.
Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
3623 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
3627 if (
const auto *ExistingAttr = D->
getAttr<CodeSegAttr>()) {
3628 if (ExistingAttr->getName() == Name)
3630 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section)
3632 Diag(CI.
getLoc(), diag::note_previous_attribute);
3645 if (
const auto *ExistingAttr = D->
getAttr<CodeSegAttr>()) {
3646 if (!ExistingAttr->isImplicit()) {
3648 ExistingAttr->getName() == Str
3649 ? diag::warn_duplicate_codeseg_attribute
3650 : diag::err_conflicting_codeseg_attribute);
3662 if (AttrStr.contains(
"fpmath="))
3663 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3664 << Unsupported <<
None <<
"fpmath=" <<
Target;
3667 if (!
Context.getTargetInfo().supportsTargetAttributeTune() &&
3668 AttrStr.contains(
"tune="))
3669 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3673 Context.getTargetInfo().parseTargetAttr(AttrStr);
3675 if (!ParsedAttrs.
CPU.empty() &&
3676 !
Context.getTargetInfo().isValidCPUName(ParsedAttrs.
CPU))
3677 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3680 if (!ParsedAttrs.
Tune.empty() &&
3681 !
Context.getTargetInfo().isValidCPUName(ParsedAttrs.
Tune))
3682 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3685 if (
Context.getTargetInfo().getTriple().isRISCV()) {
3687 return Diag(LiteralLoc, diag::err_duplicate_target_attribute)
3689 for (StringRef CurFeature : ParsedAttrs.
Features) {
3690 if (!CurFeature.starts_with(
'+') && !CurFeature.starts_with(
'-'))
3691 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3696 if (
Context.getTargetInfo().getTriple().isLoongArch()) {
3697 for (StringRef CurFeature : ParsedAttrs.
Features) {
3698 if (CurFeature.starts_with(
"!arch=")) {
3699 StringRef ArchValue = CurFeature.split(
"=").second.trim();
3700 return Diag(LiteralLoc, diag::err_attribute_unsupported)
3701 <<
"target(arch=..)" << ArchValue;
3707 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3711 auto CurFeature = StringRef(
Feature).drop_front();
3712 if (!
Context.getTargetInfo().isValidFeatureName(CurFeature))
3713 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3714 << Unsupported <<
None << CurFeature <<
Target;
3719 return Diag(LiteralLoc,
3720 diag::warn_attribute_harden_pac_ret_requires_pac_ret);
3727 if (!
Context.getTargetInfo().validateBranchProtection(
3728 ParsedAttrs, BPI,
Context.getLangOpts(), DiagMsg)) {
3729 if (DiagMsg.empty())
3730 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3731 << Unsupported <<
None <<
"branch-protection" <<
Target;
3732 return Diag(LiteralLoc, diag::err_invalid_branch_protection_spec)
3735 if (!DiagMsg.empty())
3736 Diag(LiteralLoc, diag::warn_unsupported_branch_protection_spec) << DiagMsg;
3739 auto SignReturnAddrHardenOpt =
3740 Context.getTargetInfo().parseSignReturnAddressHardening(
3742 if (!SignReturnAddrHardenOpt)
3743 return Diag(LiteralLoc, diag::err_invalid_harden_pac_ret_spec)
3747 return Diag(LiteralLoc,
3748 diag::warn_attribute_harden_pac_ret_requires_pac_ret);
3769 TargetVersionAttr *NewAttr =
3781 TargetAttr *NewAttr = ::new (S.
Context) TargetAttr(S.
Context, AL, Str);
3788 if (
const auto *
Other = D->
getAttr<TargetClonesAttr>()) {
3789 S.
Diag(AL.
getLoc(), diag::err_disallowed_duplicate_attribute) << AL;
3790 S.
Diag(
Other->getLocation(), diag::note_conflicting_attribute);
3798 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
3799 if (MD->getParent()->isLambda()) {
3809 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
3814 Params.push_back(Param);
3815 Locations.push_back(Loc);
3836 for (
auto &SmallStr : NewParams)
3837 Params.push_back(SmallStr.str());
3839 TargetClonesAttr *NewAttr = ::new (S.
Context)
3840 TargetClonesAttr(S.
Context, AL, Params.data(), Params.size());
3852 MinVectorWidthAttr *Existing = D->
getAttr<MinVectorWidthAttr>();
3853 if (Existing && Existing->getVectorWidth() != VecWidth) {
3854 S.
Diag(AL.
getLoc(), diag::warn_duplicate_attribute) << AL;
3869 if (
auto *DRE = dyn_cast<DeclRefExpr>(E)) {
3871 S.
Diag(Loc, diag::warn_cleanup_ext);
3872 FD = dyn_cast<FunctionDecl>(DRE->
getDecl());
3875 S.
Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 1
3879 }
else if (
auto *ULE = dyn_cast<UnresolvedLookupExpr>(E)) {
3880 if (ULE->hasExplicitTemplateArgs())
3881 S.
Diag(Loc, diag::warn_cleanup_ext);
3883 NI = ULE->getNameInfo();
3885 S.
Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 2
3892 S.
Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 0;
3897 S.
Diag(Loc, diag::err_attribute_cleanup_func_must_take_one_arg)
3913 S.
Context, VariableReference, UnaryOperatorKind::UO_AddrOf,
3929 if (
const auto *A = D->
getAttr<CleanupAttr>()) {
3930 S.
Diag(A->getLoc(), diag::warn_duplicate_cleanup_attr) << A->getRange();
3942 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3947 EnumExtensibilityAttr::Kind ExtensibilityKind;
3949 if (!EnumExtensibilityAttr::ConvertStrToKind(II->
getName(),
3950 ExtensibilityKind)) {
3951 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
3956 EnumExtensibilityAttr(S.
Context, AL, ExtensibilityKind));
3974 S.
Diag(AL.
getLoc(), diag::err_format_attribute_not)
3984 if (
auto *OMD = dyn_cast<ObjCMethodDecl>(D))
3985 if (
auto *
Interface = OMD->getClassInterface())
3992 S.
Diag(AL.
getLoc(), diag::err_format_attribute_result_not)
3993 << (NotNSStringTy ?
"string type" :
"NSString")
4013 return llvm::StringSwitch<FormatAttrKind>(Format)
4020 .Cases({
"gnu_scanf",
"scanf",
"gnu_printf",
"printf",
"printf0",
4021 "gnu_strfmon",
"strfmon"},
4029 .Cases({
"gcc_diag",
"gcc_cdiag",
"gcc_cxxdiag",
"gcc_tdiag"},
4038 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored) << AL;
4043 S.
Diag(AL.
getLoc(), diag::err_hlsl_init_priority_unsupported);
4048 S.
Diag(AL.
getLoc(), diag::err_init_priority_object_attr);
4060 if (prioritynum > 65535) {
4061 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_range)
4069 if (prioritynum < 101)
4070 S.
Diag(AL.
getLoc(), diag::warn_init_priority_reserved)
4076 StringRef NewUserDiagnostic) {
4077 if (
const auto *EA = D->
getAttr<ErrorAttr>()) {
4079 assert((NewAttr ==
"error" || NewAttr ==
"warning") &&
4080 "unexpected normalized full name");
4081 bool Match = (EA->isError() && NewAttr ==
"error") ||
4082 (EA->isWarning() && NewAttr ==
"warning");
4084 Diag(EA->getLocation(), diag::err_attributes_are_not_compatible)
4087 EA->isRegularKeywordAttribute());
4088 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
4091 if (EA->getUserDiagnostic() != NewUserDiagnostic) {
4092 Diag(CI.
getLoc(), diag::warn_duplicate_attribute) << EA;
4093 Diag(EA->getLoc(), diag::note_previous_attribute);
4097 return ::new (
Context) ErrorAttr(
Context, CI, NewUserDiagnostic);
4105 if (F->getType() == Format &&
4106 F->getFormatIdx() == FormatIdx &&
4107 F->getFirstArg() == FirstArg) {
4110 if (F->getLocation().isInvalid())
4116 return ::new (
Context) FormatAttr(
Context, CI, Format, FormatIdx, FirstArg);
4126 if (F->getType() == Format && F->getFormatIdx() == FormatIdx) {
4128 F->getFormatString(), FormatStr))
4133 if (F->getLocation().isInvalid())
4140 FormatMatchesAttr(
Context, CI, Format, FormatIdx, FormatStr);
4158 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
4182 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
4193 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4204 diag::err_format_attribute_implicit_this_format_string)
4217 S.
Diag(AL.
getLoc(), diag::err_format_attribute_not)
4238 if (FirstArg != 0) {
4242 S.
Diag(AL.
getLoc(), diag::err_format_strftime_third_parameter)
4250 if (FirstArg != Info.
NumArgs + 1) {
4251 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4254 std::to_string(Info.
NumArgs + 1));
4259 S.
Diag(D->
getLocation(), diag::warn_gcc_requires_variadic_function) << AL;
4264 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4271 FormatAttr *NewAttr =
4283 if (
auto *SL = dyn_cast<StringLiteral>(FormatStrExpr)) {
4292 S.
Diag(AL.
getLoc(), diag::err_format_nonliteral)
4300 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_no_callee)
4309 assert(FD &&
"Expected a function declaration!");
4311 llvm::StringMap<int> NameIdxMapping;
4312 NameIdxMapping[
"__"] = -1;
4314 NameIdxMapping[
"this"] = 0;
4318 NameIdxMapping[PVD->getName()] = Idx++;
4320 auto UnknownName = NameIdxMapping.end();
4323 for (
unsigned I = 0, E = AL.
getNumArgs(); I < E; ++I) {
4330 if (It == UnknownName) {
4331 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_argument_unknown)
4337 ArgIdx = It->second;
4344 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4350 if (ArgIdx < -1 || ArgIdx > NumArgs) {
4351 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4358 llvm_unreachable(
"Unexpected ParsedAttr argument type!");
4361 if (ArgIdx == 0 && !HasImplicitThisParam) {
4362 S.
Diag(AL.
getLoc(), diag::err_callback_implicit_this_not_available)
4369 if (!HasImplicitThisParam && ArgIdx > 0)
4372 EncodingIndices.push_back(ArgIdx);
4375 int CalleeIdx = EncodingIndices.front();
4379 if (CalleeIdx < (
int)HasImplicitThisParam) {
4380 S.
Diag(AL.
getLoc(), diag::err_callback_attribute_invalid_callee)
4387 const Type *CalleeType =
4391 S.
Diag(AL.
getLoc(), diag::err_callback_callee_no_function_type)
4396 const Type *CalleeFnType =
4401 const auto *CalleeFnProtoType = dyn_cast<FunctionProtoType>(CalleeFnType);
4402 if (!CalleeFnProtoType) {
4403 S.
Diag(AL.
getLoc(), diag::err_callback_callee_no_function_type)
4408 if (CalleeFnProtoType->getNumParams() != EncodingIndices.size() - 1) {
4409 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_arg_count_for_func)
4410 << AL <<
QualType{CalleeFnProtoType, 0}
4411 << CalleeFnProtoType->getNumParams()
4412 << (
unsigned)(EncodingIndices.size() - 1);
4416 if (CalleeFnProtoType->isVariadic()) {
4422 if (D->
hasAttr<CallbackAttr>()) {
4428 S.
Context, AL, EncodingIndices.data(), EncodingIndices.size()));
4432 StringRef ParamName) {
4434 StringRef SpecialEntity;
4435 if (AttrName ==
"lifetime_capture_by_this")
4436 SpecialEntity =
"this";
4437 else if (AttrName ==
"lifetime_capture_by_global")
4438 SpecialEntity =
"global";
4439 else if (AttrName ==
"lifetime_capture_by_unknown")
4440 SpecialEntity =
"unknown";
4442 if (!SpecialEntity.empty() && AL.
getNumArgs() != 0) {
4443 Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 0;
4448 if (SpecialEntity.empty() && AL.
getNumArgs() == 0) {
4449 Diag(AL.
getLoc(), diag::err_capture_by_attribute_no_entity)
4453 unsigned N = SpecialEntity.empty() ? AL.
getNumArgs() : 1;
4458 if (!SpecialEntity.empty()) {
4459 ParamIdents[0] = &
Context.Idents.get(SpecialEntity);
4461 int FakeParamIndices[] = {LifetimeCaptureByAttr::Invalid};
4463 LifetimeCaptureByAttr::Create(
Context, FakeParamIndices, 1, AL);
4464 CapturedBy->setArgs(ParamIdents, ParamLocs);
4468 bool IsValid =
true;
4469 for (
unsigned I = 0; I < N; ++I) {
4472 Diag(E->
getExprLoc(), diag::err_capture_by_attribute_argument_unknown)
4480 StringRef Replacement;
4482 Replacement =
"lifetime_capture_by_this";
4483 else if (Name ==
"global")
4484 Replacement =
"lifetime_capture_by_global";
4485 else if (Name ==
"unknown")
4486 Replacement =
"lifetime_capture_by_unknown";
4487 if (!Replacement.empty())
4488 Diag(IdLoc->
getLoc(), diag::warn_deprecated_capture_by_special_entity)
4489 << Name << Replacement << IdLoc->
getLoc();
4491 Diag(IdLoc->
getLoc(), diag::err_capture_by_references_itself)
4497 ParamLocs[I] = IdLoc->
getLoc();
4503 LifetimeCaptureByAttr::Create(
Context, FakeParamIndices.data(), N, AL);
4504 CapturedBy->setArgs(ParamIdents, ParamLocs);
4510 auto *PVD = dyn_cast<ParmVarDecl>(D);
4517 auto GetSpellingKind = [](
const LifetimeCaptureByAttr *A) {
4519 return SpellingKind::This;
4521 return SpellingKind::Global;
4523 return SpellingKind::Unknown;
4524 return SpellingKind::ParameterList;
4526 auto GetSpellingName = [](SpellingKind Kind) -> StringRef {
4528 case SpellingKind::ParameterList:
4529 return "lifetime_capture_by";
4530 case SpellingKind::This:
4531 return "lifetime_capture_by_this";
4532 case SpellingKind::Global:
4533 return "lifetime_capture_by_global";
4534 case SpellingKind::Unknown:
4535 return "lifetime_capture_by_unknown";
4537 llvm_unreachable(
"unknown lifetime_capture_by spelling kind");
4540 SpellingKind NewKind = GetSpellingKind(CaptureByAttr);
4541 for (
const auto *Existing : D->
specific_attrs<LifetimeCaptureByAttr>()) {
4542 if (GetSpellingKind(Existing) == NewKind) {
4543 S.
Diag(AL.
getLoc(), diag::err_capture_by_attribute_multiple)
4544 << GetSpellingName(NewKind) << AL.
getRange();
4556 for (
auto *A : PVD->specific_attrs<LifetimeCaptureByAttr>())
4558 if (HasImplicitThisParam) {
4566 if (
auto *A = ATL.
getAttrAs<LifetimeCaptureByAttr>())
4567 Attrs.push_back(
const_cast<LifetimeCaptureByAttr *
>(A));
4572 llvm::StringMap<int> NameIdxMapping = {
4573 {
"global", LifetimeCaptureByAttr::Global},
4574 {
"unknown", LifetimeCaptureByAttr::Unknown}};
4576 if (HasImplicitThisParam) {
4577 NameIdxMapping[
"this"] = 0;
4581 NameIdxMapping[PVD->getName()] = Idx++;
4582 auto DisallowReservedParams = [&](StringRef Reserved) {
4584 if (PVD->getName() == Reserved)
4585 Diag(PVD->getLocation(), diag::err_capture_by_param_uses_reserved_name)
4588 for (
auto *CapturedBy : Attrs) {
4589 const auto &Entities = CapturedBy->getArgIdents();
4590 for (
size_t I = 0; I < Entities.size(); ++I) {
4591 StringRef Name = Entities[I]->getName();
4592 auto It = NameIdxMapping.find(Name);
4593 if (It == NameIdxMapping.end()) {
4594 auto Loc = CapturedBy->getArgLocs()[I];
4595 if (!HasImplicitThisParam && Name ==
"this") {
4597 CapturedBy->isStandaloneSpecial()
4598 ? diag::err_capture_by_this_attr_without_implicit_this
4599 : diag::err_capture_by_implicit_this_not_available;
4600 Diag(Loc, DiagID) << Loc;
4602 Diag(Loc, diag::err_capture_by_attribute_argument_unknown)
4603 << Entities[I] << Loc;
4606 if ((Name ==
"unknown" || Name ==
"global") &&
4607 !CapturedBy->isStandaloneSpecial())
4608 DisallowReservedParams(Name);
4609 CapturedBy->setParamIdx(I, It->second);
4618 return T.isFunctionPointerType() ||
T.isBlockPointerType();
4627 S.
Diag(AL.
getLoc(), diag::err_called_once_attribute_wrong_type);
4637 const auto *TD = dyn_cast<TypedefNameDecl>(D);
4638 if (TD && TD->getUnderlyingType()->isUnionType())
4639 RD = TD->getUnderlyingType()->getAsRecordDecl();
4641 RD = dyn_cast<RecordDecl>(D);
4644 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
4652 diag::warn_transparent_union_attribute_not_definition);
4658 if (Field == FieldEnd) {
4659 S.
Diag(AL.
getLoc(), diag::warn_transparent_union_attribute_zero_fields);
4667 diag::warn_transparent_union_attribute_floating)
4676 for (; Field != FieldEnd; ++Field) {
4677 QualType FieldType = Field->getType();
4691 S.
Diag(Field->getLocation(),
4692 diag::warn_transparent_union_attribute_field_size_align)
4693 << isSize << *Field << FieldBits;
4694 unsigned FirstBits = isSize ? FirstSize : FirstAlign;
4696 diag::note_transparent_union_first_field_size_align)
4697 << isSize << FirstBits;
4720 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D))
4721 T = TD->getUnderlyingType();
4722 else if (
const auto *VD = dyn_cast<ValueDecl>(D))
4725 llvm_unreachable(
"Unknown decl type for align_value");
4727 if (!
T->isDependentType() && !
T->isAnyPointerType() &&
4728 !
T->isReferenceType() && !
T->isMemberPointerType()) {
4729 Diag(AttrLoc, diag::warn_attribute_pointer_or_reference_only)
4735 llvm::APSInt Alignment;
4737 E, &Alignment, diag::err_align_value_attribute_argument_not_int);
4741 if (!Alignment.isPowerOf2()) {
4742 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
4764 diag::err_pack_expansion_without_parameter_packs);
4779 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
4791 diag::err_pack_expansion_without_parameter_packs);
4818 const AlignedAttr &
Attr,
4823 }
else if (
const auto *VD = dyn_cast<VarDecl>(D)) {
4826 if (VD->isExceptionVariable())
4828 }
else if (
const auto *FD = dyn_cast<FieldDecl>(D)) {
4829 if (FD->isBitField())
4831 }
else if (
const auto *ED = dyn_cast<EnumDecl>(D)) {
4832 if (ED->getLangOpts().CPlusPlus)
4835 return S.
Diag(AttrLoc, diag::err_attribute_wrong_decl_type)
4840 if (DiagKind != -1) {
4841 return S.
Diag(AttrLoc, diag::err_alignas_attribute_wrong_decl_type)
4842 << &
Attr << DiagKind;
4848 bool IsPackExpansion) {
4849 AlignedAttr TmpAttr(
Context, CI,
true, E);
4853 if (TmpAttr.isAlignas() &&
4861 if (
const auto *TND = dyn_cast<TypedefNameDecl>(D)) {
4862 if (!TND->getUnderlyingType()->isDependentType()) {
4863 Diag(AttrLoc, diag::err_alignment_dependent_typedef_name)
4870 AlignedAttr *AA = ::new (
Context) AlignedAttr(
Context, CI,
true, E);
4871 AA->setPackExpansion(IsPackExpansion);
4877 llvm::APSInt Alignment;
4879 E, &Alignment, diag::err_aligned_attribute_argument_not_int);
4884 if (
Context.getTargetInfo().getTriple().isOSBinFormatCOFF())
4887 Diag(AttrLoc, diag::err_attribute_aligned_too_great)
4892 uint64_t AlignVal = Alignment.getZExtValue();
4898 if (!(TmpAttr.isAlignas() && !Alignment)) {
4899 if (!llvm::isPowerOf2_64(AlignVal)) {
4900 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
4906 const auto *VD = dyn_cast<VarDecl>(D);
4908 unsigned MaxTLSAlign =
4909 Context.toCharUnitsFromBits(
Context.getTargetInfo().getMaxTLSAlign())
4911 if (MaxTLSAlign && AlignVal > MaxTLSAlign &&
4913 Diag(VD->getLocation(), diag::err_tls_var_aligned_over_maximum)
4914 << (
unsigned)AlignVal << VD << MaxTLSAlign;
4921 if (VD &&
Context.getTargetInfo().getTriple().isOSAIX()) {
4922 const Type *Ty = VD->getType().getTypePtr();
4924 Diag(VD->getLocation(), diag::warn_aligned_attr_underaligned)
4925 << VD->getType() << 16;
4931 AA->setPackExpansion(IsPackExpansion);
4932 AA->setCachedAlignmentValue(
4933 static_cast<unsigned>(AlignVal *
Context.getCharWidth()));
4939 AlignedAttr TmpAttr(
Context, CI,
false, TS);
4943 if (TmpAttr.isAlignas() &&
4951 if (
const auto *TND = dyn_cast<TypedefNameDecl>(D)) {
4952 if (!TND->getUnderlyingType()->isDependentType()) {
4953 Diag(AttrLoc, diag::err_alignment_dependent_typedef_name)
4959 AlignedAttr *AA = ::new (
Context) AlignedAttr(
Context, CI,
false, TS);
4960 AA->setPackExpansion(IsPackExpansion);
4965 const auto *VD = dyn_cast<VarDecl>(D);
4966 unsigned AlignVal = TmpAttr.getAlignment(
Context);
4969 if (VD &&
Context.getTargetInfo().getTriple().isOSAIX()) {
4970 const Type *Ty = VD->getType().getTypePtr();
4972 Context.toCharUnitsFromBits(AlignVal).getQuantity() < 16) {
4973 Diag(VD->getLocation(), diag::warn_aligned_attr_underaligned)
4974 << VD->getType() << 16;
4979 AlignedAttr *AA = ::new (
Context) AlignedAttr(
Context, CI,
false, TS);
4980 AA->setPackExpansion(IsPackExpansion);
4981 AA->setCachedAlignmentValue(AlignVal);
4986 assert(D->
hasAttrs() &&
"no attributes on decl");
4989 if (
const auto *VD = dyn_cast<ValueDecl>(D)) {
4990 UnderlyingTy = DiagTy = VD->getType();
4993 if (
const auto *ED = dyn_cast<EnumDecl>(D))
4994 UnderlyingTy = ED->getIntegerType();
5003 AlignedAttr *AlignasAttr =
nullptr;
5004 AlignedAttr *LastAlignedAttr =
nullptr;
5007 if (I->isAlignmentDependent())
5011 Align = std::max(Align, I->getAlignment(
Context));
5012 LastAlignedAttr = I;
5016 Diag(LastAlignedAttr->getLocation(), diag::err_attribute_sizeless_type)
5017 << LastAlignedAttr << DiagTy;
5018 }
else if (AlignasAttr && Align) {
5021 if (NaturalAlign > RequestedAlign)
5022 Diag(AlignasAttr->getLocation(), diag::err_alignas_underaligned)
5049 Diag(Range.getBegin(), diag::err_mismatched_ms_inheritance)
5058 bool &IntegerMode,
bool &ComplexMode,
5061 ComplexMode =
false;
5063 switch (Str.size()) {
5083 DestWidth = Str[1] ==
'I' ? 0 : 128;
5091 DestWidth = Str[1] ==
'I' ? 0 : 128;
5094 if (Str[1] ==
'F') {
5095 IntegerMode =
false;
5096 }
else if (Str[1] ==
'C') {
5097 IntegerMode =
false;
5099 }
else if (Str[1] !=
'I') {
5108 else if (Str ==
"byte")
5112 if (Str ==
"pointer")
5116 if (Str ==
"unwind_word")
5132 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
5144 StringRef Str = Name->
getName();
5148 unsigned DestWidth = 0;
5149 bool IntegerMode =
true;
5150 bool ComplexMode =
false;
5152 llvm::APInt VectorSize(64, 0);
5153 if (Str.size() >= 4 && Str[0] ==
'V') {
5155 size_t StrSize = Str.size();
5156 size_t VectorStringLength = 0;
5157 while ((VectorStringLength + 1) < StrSize &&
5158 isdigit(Str[VectorStringLength + 1]))
5159 ++VectorStringLength;
5160 if (VectorStringLength &&
5161 !Str.substr(1, VectorStringLength).getAsInteger(10, VectorSize) &&
5162 VectorSize.isPowerOf2()) {
5164 IntegerMode, ComplexMode, ExplicitType);
5166 if (!InInstantiation)
5167 Diag(AttrLoc, diag::warn_vector_mode_deprecated);
5182 Diag(AttrLoc, diag::err_machine_mode) << 0 << Name;
5187 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D))
5188 OldTy = TD->getUnderlyingType();
5189 else if (
const auto *ED = dyn_cast<EnumDecl>(D)) {
5192 OldTy = ED->getIntegerType();
5207 OldElemTy = VT->getElementType();
5213 VectorSize.getBoolValue()) {
5214 Diag(AttrLoc, diag::err_enum_mode_vector_type) << Name << CI.
getRange();
5222 !IntegralOrAnyEnumType)
5223 Diag(AttrLoc, diag::err_mode_not_primitive);
5224 else if (IntegerMode) {
5225 if (!IntegralOrAnyEnumType)
5226 Diag(AttrLoc, diag::err_mode_wrong_type);
5227 }
else if (ComplexMode) {
5229 Diag(AttrLoc, diag::err_mode_wrong_type);
5232 Diag(AttrLoc, diag::err_mode_wrong_type);
5238 NewElemTy =
Context.getIntTypeForBitwidth(DestWidth,
5241 NewElemTy =
Context.getRealTypeForBitwidth(DestWidth, ExplicitType);
5243 if (NewElemTy.
isNull()) {
5247 if (!(DestWidth == 128 &&
getLangOpts().isTargetDevice()))
5248 Diag(AttrLoc, diag::err_machine_mode) << 1 << Name;
5253 NewElemTy =
Context.getComplexType(NewElemTy);
5257 if (VectorSize.getBoolValue()) {
5258 NewTy =
Context.getVectorType(NewTy, VectorSize.getZExtValue(),
5263 Diag(AttrLoc, diag::err_complex_mode_vector_type);
5266 unsigned NumElements =
Context.getTypeSize(OldElemTy) *
5267 OldVT->getNumElements() /
5268 Context.getTypeSize(NewElemTy);
5270 Context.getVectorType(NewElemTy, NumElements, OldVT->getVectorKind());
5274 Diag(AttrLoc, diag::err_mode_wrong_type);
5279 if (
auto *TD = dyn_cast<TypedefNameDecl>(D))
5280 TD->setModedTypeSourceInfo(TD->getTypeSourceInfo(), NewTy);
5281 else if (
auto *ED = dyn_cast<EnumDecl>(D))
5282 ED->setIntegerType(NewTy);
5310 if (OptimizeNoneAttr *Optnone = D->
getAttr<OptimizeNoneAttr>()) {
5311 Diag(CI.
getLoc(), diag::warn_attribute_ignored) << Ident;
5312 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
5316 if (D->
hasAttr<AlwaysInlineAttr>())
5324 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
5327 if (VD->getKind() != Decl::Var) {
5328 Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
5335 if (VD->hasLocalStorage()) {
5336 Diag(VD->getLocation(), diag::warn_internal_linkage_local_storage);
5343InternalLinkageAttr *
5345 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
5348 if (VD->getKind() != Decl::Var) {
5349 Diag(AL.getLocation(), diag::warn_attribute_wrong_decl_type)
5350 << &AL << AL.isRegularKeywordAttribute()
5356 if (VD->hasLocalStorage()) {
5357 Diag(VD->getLocation(), diag::warn_internal_linkage_local_storage);
5366 if (OptimizeNoneAttr *Optnone = D->
getAttr<OptimizeNoneAttr>()) {
5367 Diag(CI.
getLoc(), diag::warn_attribute_ignored) <<
"'minsize'";
5368 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
5372 if (D->
hasAttr<MinSizeAttr>())
5380 if (AlwaysInlineAttr *Inline = D->
getAttr<AlwaysInlineAttr>()) {
5381 Diag(Inline->getLocation(), diag::warn_attribute_ignored) << Inline;
5382 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
5385 if (MinSizeAttr *MinSize = D->
getAttr<MinSizeAttr>()) {
5386 Diag(MinSize->getLocation(), diag::warn_attribute_ignored) << MinSize;
5387 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
5391 if (D->
hasAttr<OptimizeNoneAttr>())
5398 AlwaysInlineAttr AIA(S.
Context, AL);
5400 (AIA.isMSVCForceInline() || AIA.isMSVCForceInlineCalls())) {
5401 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored) << AL;
5404 if (AIA.isMSVCForceInlineCalls()) {
5405 S.
Diag(AL.
getLoc(), diag::warn_stmt_attribute_ignored_in_function)
5406 <<
"[[msvc::forceinline]]";
5410 if (AlwaysInlineAttr *Inline =
5427 if (VD->hasLocalStorage()) {
5428 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
5435 if (
auto *A = D->
getAttr<CUDAConstantAttr>()) {
5436 if (!A->isImplicit())
5447 if (!S.
getLangOpts().GPURelocatableDeviceCode && VD->hasExternalStorage() &&
5449 S.
Diag(AL.
getLoc(), diag::err_cuda_extern_shared) << VD;
5454 if (S.
getLangOpts().CUDA && VD->hasLocalStorage() &&
5473 if (
const auto *Method = dyn_cast<CXXMethodDecl>(FD)) {
5474 if (Method->isInstance()) {
5475 S.
Diag(Method->getBeginLoc(), diag::err_kern_is_nonstatic_method)
5479 S.
Diag(Method->getBeginLoc(), diag::warn_kern_is_method) << Method;
5486 case ParsedAttr::AT_DeviceKernel:
5487 if (!D->
hasAttr<DeviceKernelAttr>())
5490 case ParsedAttr::AT_CUDAGlobal:
5491 if (!D->
hasAttr<CUDAGlobalAttr>())
5495 llvm_unreachable(
"Unexpected attribute kind");
5506 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
5507 if (VD->hasLocalStorage()) {
5508 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
5515 if (
auto *A = D->
getAttr<CUDADeviceAttr>()) {
5516 if (!A->isImplicit())
5524 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
5525 if (VD->hasLocalStorage()) {
5526 S.
Diag(AL.
getLoc(), diag::err_cuda_nonstatic_constdev);
5532 if (!D->
hasAttr<HIPManagedAttr>())
5534 if (!D->
hasAttr<CUDADeviceAttr>())
5549 if (!Fn->isInlineSpecified()) {
5550 S.
Diag(AL.
getLoc(), diag::warn_gnu_inline_attribute_requires_inline);
5555 S.
Diag(AL.
getLoc(), diag::warn_gnu_inline_cplusplus_without_extern);
5572 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
5578 case ParsedAttr::AT_FastCall:
5581 case ParsedAttr::AT_StdCall:
5584 case ParsedAttr::AT_ThisCall:
5587 case ParsedAttr::AT_CDecl:
5590 case ParsedAttr::AT_Pascal:
5593 case ParsedAttr::AT_SwiftCall:
5596 case ParsedAttr::AT_SwiftAsyncCall:
5599 case ParsedAttr::AT_VectorCall:
5602 case ParsedAttr::AT_MSABI:
5605 case ParsedAttr::AT_SysVABI:
5608 case ParsedAttr::AT_RegCall:
5611 case ParsedAttr::AT_Pcs: {
5612 PcsAttr::PCSType PCS;
5615 PCS = PcsAttr::AAPCS;
5618 PCS = PcsAttr::AAPCS_VFP;
5621 llvm_unreachable(
"unexpected calling convention in pcs attribute");
5627 case ParsedAttr::AT_AArch64VectorPcs:
5630 case ParsedAttr::AT_AArch64SVEPcs:
5633 case ParsedAttr::AT_DeviceKernel: {
5635 assert(D->
hasAttr<DeviceKernelAttr>() &&
"Expected attribute");
5638 case ParsedAttr::AT_IntelOclBicc:
5641 case ParsedAttr::AT_PreserveMost:
5644 case ParsedAttr::AT_PreserveAll:
5647 case ParsedAttr::AT_M68kRTD:
5650 case ParsedAttr::AT_PreserveNone:
5653 case ParsedAttr::AT_RISCVVectorCC:
5656 case ParsedAttr::AT_RISCVVLSCC: {
5663 S.
Diag(AL.
getLoc(), diag::err_argument_invalid_range)
5668 S.
Diag(AL.
getLoc(), diag::err_argument_not_power_of_2);
5676 llvm_unreachable(
"unexpected attribute kind");
5681 const auto *FD = dyn_cast_or_null<FunctionDecl>(D);
5687 S.
Diag(AL.
getLoc(), diag::err_hidden_device_kernel) << FD;
5691 if (Triple.isNVPTX()) {
5695 if (!LangOpts.OpenCLCPlusPlus && (!FD || IsFunctionTemplate)) {
5696 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_decl_type_str)
5704 bool TargetDeviceEnvironment = Triple.isGPU() || Triple.isSPIR() ||
5706 if (!TargetDeviceEnvironment) {
5707 S.
Diag(AL.
getLoc(), diag::warn_cconv_unsupported)
5725 std::vector<StringRef> DiagnosticIdentifiers;
5726 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
5732 DiagnosticIdentifiers.push_back(RuleName);
5735 SuppressAttr(S.
Context, AL, DiagnosticIdentifiers.data(),
5736 DiagnosticIdentifiers.size()));
5745 unsigned SelectIdx = ~0
U;
5751 if (SelectIdx != ~0
U) {
5752 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_argument)
5764 if (AL.
getKind() == ParsedAttr::AT_Owner) {
5767 if (
const auto *OAttr = D->
getAttr<OwnerAttr>()) {
5768 const Type *ExistingDerefType = OAttr->getDerefTypeLoc()
5769 ? OAttr->getDerefType().getTypePtr()
5772 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
5775 OAttr->isRegularKeywordAttribute());
5776 S.
Diag(OAttr->getLocation(), diag::note_conflicting_attribute);
5781 Redecl->addAttr(::new (S.
Context) OwnerAttr(S.
Context, AL, DerefTypeLoc));
5786 if (
const auto *PAttr = D->
getAttr<PointerAttr>()) {
5787 const Type *ExistingDerefType = PAttr->getDerefTypeLoc()
5788 ? PAttr->getDerefType().getTypePtr()
5791 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
5794 PAttr->isRegularKeywordAttribute());
5795 S.
Diag(PAttr->getLocation(), diag::note_conflicting_attribute);
5800 Redecl->addAttr(::new (S.
Context)
5801 PointerAttr(S.
Context, AL, DerefTypeLoc));
5809 if (!D->
hasAttr<RandomizeLayoutAttr>())
5817 if (!D->
hasAttr<NoRandomizeLayoutAttr>())
5832 if (Attrs.
getKind() == ParsedAttr::AT_RISCVVLSCC) {
5840 unsigned ReqArgs = Attrs.
getKind() == ParsedAttr::AT_Pcs ? 1 : 0;
5847 bool IsTargetDefaultMSABI =
5848 Context.getTargetInfo().getTriple().isOSWindows() ||
5849 Context.getTargetInfo().getTriple().isUEFI();
5852 case ParsedAttr::AT_CDecl:
5855 case ParsedAttr::AT_FastCall:
5858 case ParsedAttr::AT_StdCall:
5861 case ParsedAttr::AT_ThisCall:
5864 case ParsedAttr::AT_Pascal:
5867 case ParsedAttr::AT_SwiftCall:
5870 case ParsedAttr::AT_SwiftAsyncCall:
5873 case ParsedAttr::AT_VectorCall:
5876 case ParsedAttr::AT_AArch64VectorPcs:
5879 case ParsedAttr::AT_AArch64SVEPcs:
5882 case ParsedAttr::AT_RegCall:
5885 case ParsedAttr::AT_MSABI:
5888 case ParsedAttr::AT_SysVABI:
5891 case ParsedAttr::AT_Pcs: {
5897 if (StrRef ==
"aapcs") {
5900 }
else if (StrRef ==
"aapcs-vfp") {
5909 case ParsedAttr::AT_IntelOclBicc:
5912 case ParsedAttr::AT_PreserveMost:
5915 case ParsedAttr::AT_PreserveAll:
5918 case ParsedAttr::AT_M68kRTD:
5921 case ParsedAttr::AT_PreserveNone:
5924 case ParsedAttr::AT_RISCVVectorCC:
5927 case ParsedAttr::AT_RISCVVLSCC: {
5930 unsigned ABIVLen = 128;
5936 if (Attrs.
getNumArgs() && (ABIVLen < 32 || ABIVLen > 65536)) {
5938 Diag(Attrs.
getLoc(), diag::err_argument_invalid_range)
5939 << ABIVLen << 32 << 65536;
5942 if (!llvm::isPowerOf2_64(ABIVLen)) {
5944 Diag(Attrs.
getLoc(), diag::err_argument_not_power_of_2);
5948 llvm::Log2_64(ABIVLen) - 5);
5951 case ParsedAttr::AT_DeviceKernel: {
5956 default: llvm_unreachable(
"unexpected attribute kind");
5961 auto *Aux =
Context.getAuxTargetInfo();
5969 bool CheckHost =
false, CheckDevice =
false;
5970 switch (CudaTarget) {
5983 llvm_unreachable(
"unexpected cuda target");
5985 auto *HostTI =
LangOpts.CUDAIsDevice ? Aux : &TI;
5986 auto *DeviceTI =
LangOpts.CUDAIsDevice ? &TI : Aux;
5987 if (CheckHost && HostTI)
5990 A = DeviceTI->checkCallingConvention(CC);
5991 }
else if (
LangOpts.SYCLIsDevice) {
6007 A = Aux->checkCallingConvention(CC);
6012 A = Aux->checkCallingConvention(CC);
6031 Diag(Attrs.
getLoc(), diag::error_cconv_unsupported)
6036 Diag(Attrs.
getLoc(), diag::warn_cconv_unsupported)
6041 bool IsCXXMethod =
false, IsVariadic =
false;
6046 CC =
Context.getDefaultCallingConvention(IsVariadic, IsCXXMethod);
6071 if (
Context.getTargetInfo().getRegParmMax() == 0) {
6072 Diag(AL.
getLoc(), diag::err_attribute_regparm_wrong_platform)
6079 if (numParams >
Context.getTargetInfo().getRegParmMax()) {
6080 Diag(AL.
getLoc(), diag::err_attribute_regparm_invalid_number)
6092 llvm_unreachable(
"getOffloadArch is only valid for NVPTX triple");
6102 const CUDALaunchBoundsAttr &AL,
6103 const unsigned Idx) {
6112 std::optional<llvm::APSInt> I = llvm::APSInt(64);
6119 if (!I->isIntN(32)) {
6121 <<
toString(*I, 10,
false) << 32 << 1;
6125 S.
Diag(E->
getExprLoc(), diag::warn_attribute_argument_n_negative)
6133 "Unexpected PerformCopyInitialization() failure.");
6138CUDALaunchBoundsAttr *
6142 CUDALaunchBoundsAttr TmpAttr(
Context, CI, MaxThreads, MinBlocks, MaxBlocks);
6158 (!
Context.getLangOpts().CUDAIsDevice &&
Context.getAuxTargetInfo())
6168 MaxBlocks =
nullptr;
6174 MaxBlocks =
nullptr;
6186 CUDALaunchBoundsAttr(
Context, CI, MaxThreads, MinBlocks, MaxBlocks);
6205static std::pair<Expr *, int>
6207 const unsigned Idx) {
6209 return {
nullptr, 1};
6226 S.
Diag(E->
getExprLoc(), diag::warn_attribute_argument_n_negative)
6231 if (!I->isIntN(8)) {
6233 <<
toString(*I, 10,
false) << 8 << 1;
6247 CUDAClusterDimsAttr TmpAttr(
Context, CI,
X, Y, Z);
6253 if (!NewX || (Y && !NewY) || (Z && !NewZ))
6256 int FlatDim = ValX * ValY * ValZ;
6257 const llvm::Triple TT =
6258 (!
Context.getLangOpts().CUDAIsDevice &&
Context.getAuxTargetInfo())
6259 ?
Context.getAuxTargetInfo()->getTriple()
6260 :
Context.getTargetInfo().getTriple();
6264 else if (TT.isAMDGPU())
6271 if (FlatDim > MaxDim) {
6272 Diag(CI.
getLoc(), diag::err_cluster_dims_too_large) << MaxDim << FlatDim;
6276 return CUDAClusterDimsAttr::Create(
Context, NewX, NewY, NewZ, CI);
6293 llvm::NVPTX::getSmVersion(
Arch.nvptxKind()) < 900) ||
6296 S.
Diag(AL.
getLoc(), diag::err_cluster_attr_not_supported) << AL;
6313 llvm::NVPTX::getSmVersion(
Arch.nvptxKind()) < 900) ||
6316 S.
Diag(AL.
getLoc(), diag::err_cluster_attr_not_supported) << AL;
6326 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
6348 unsigned ArgumentIdxAST = ArgumentIdx.
getASTIndex();
6351 S.
Diag(AL.
getLoc(), diag::err_attribute_pointers_only) << AL << 0;
6356 TypeTagIdx, IsPointer));
6362 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
6371 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_decl_type)
6379 assert(MatchingCTypeLoc &&
"no type source info for attribute argument");
6402 S.
Diag(AL.
getLoc(), diag::err_aix_attr_unsupported) << AL;
6413 if (Count < Offset) {
6414 S.
Diag(S.
getAttrLoc(AL), diag::err_attribute_argument_out_of_range)
6425 diag::err_attribute_patchable_function_entry_invalid_section)
6429 if (Section.empty()) {
6431 diag::err_attribute_patchable_function_entry_invalid_section)
6432 <<
"section must not be empty";
6442 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
6460 (!IsAArch64 && !IsARM && !IsRISCV && !IsHLSL && !IsSPIRV)) {
6461 S.
Diag(AL.
getLoc(), diag::err_attribute_builtin_alias) << AL;
6472 if (
auto *CRD = dyn_cast<CXXRecordDecl>(D);
6473 !CRD || !(CRD->isClass() || CRD->isStruct())) {
6484 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;
6490 assert(ParmTSI &&
"no type source info for attribute argument");
6492 diag::err_incomplete_type);
6502 StringRef UuidAsWritten,
MSGuidDecl *GuidDecl) {
6503 if (
const auto *UA = D->
getAttr<UuidAttr>()) {
6506 if (!UA->getGuid().empty()) {
6507 Diag(UA->getLocation(), diag::err_mismatched_uuid);
6513 return ::new (
Context) UuidAttr(
Context, CI, UuidAsWritten, GuidDecl);
6518 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
6523 StringRef OrigStrRef;
6530 StringRef StrRef = OrigStrRef;
6531 if (StrRef.size() == 38 && StrRef.front() ==
'{' && StrRef.back() ==
'}')
6532 StrRef = StrRef.drop_front().drop_back();
6535 if (StrRef.size() != 36) {
6536 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
6540 for (
unsigned i = 0; i < 36; ++i) {
6541 if (i == 8 || i == 13 || i == 18 || i == 23) {
6542 if (StrRef[i] !=
'-') {
6543 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
6547 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
6554 StrRef.substr(0, 8).getAsInteger(16, Parsed.
Part1);
6555 StrRef.substr(9, 4).getAsInteger(16, Parsed.
Part2);
6556 StrRef.substr(14, 4).getAsInteger(16, Parsed.
Part3);
6557 for (
unsigned i = 0; i != 8; ++i)
6558 StrRef.substr(19 + 2 * i + (i >= 2 ? 1 : 0), 2)
6569 S.
Diag(AL.
getLoc(), diag::warn_atl_uuid_deprecated);
6578 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
6593 S.
Diag(AL.
getLoc(), diag::err_thread_unsupported);
6597 S.
Diag(AL.
getLoc(), diag::err_declspec_thread_on_thread_variable);
6600 if (VD->hasLocalStorage()) {
6601 S.
Diag(AL.
getLoc(), diag::err_thread_non_global) <<
"__declspec(thread)";
6609 S.
Diag(AL.
getLoc(), diag::warn_unknown_attribute_ignored)
6615 S.
Diag(AL.
getLoc(), diag::err_ms_constexpr_cannot_be_applied)
6619 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
6620 if (!S.
getLangOpts().CPlusPlus20 && MD->isVirtual()) {
6621 S.
Diag(AL.
getLoc(), diag::err_ms_constexpr_cannot_be_applied)
6631 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
6632 << AL <<
First << 0;
6633 S.
Diag(
First->getLocation(), diag::note_conflicting_attribute);
6636 if (
const auto *Preexisting = D->
getAttr<MSStructAttr>()) {
6637 if (Preexisting->isImplicit())
6646 if (
First->isImplicit()) {
6649 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
6650 << AL <<
First << 0;
6651 S.
Diag(
First->getLocation(), diag::note_conflicting_attribute);
6661 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
6665 Tags.push_back(Tag);
6668 if (
const auto *NS = dyn_cast<NamespaceDecl>(D)) {
6669 if (!NS->isInline()) {
6670 S.
Diag(AL.
getLoc(), diag::warn_attr_abi_tag_namespace) << 0;
6673 if (NS->isAnonymousNamespace()) {
6674 S.
Diag(AL.
getLoc(), diag::warn_attr_abi_tag_namespace) << 1;
6678 Tags.push_back(NS->getName());
6684 Tags.erase(llvm::unique(Tags), Tags.end());
6687 AbiTagAttr(S.
Context, AL, Tags.data(), Tags.size()));
6692 if (I->getBTFDeclTag() == Tag)
6711 return ::new (
Context) BTFDeclTagAttr(
Context, AL, AL.getBTFDeclTag());
6717 case llvm::Triple::msp430:
6720 case llvm::Triple::mipsel:
6721 case llvm::Triple::mips:
6724 case llvm::Triple::m68k:
6727 case llvm::Triple::x86:
6728 case llvm::Triple::x86_64:
6731 case llvm::Triple::avr:
6734 case llvm::Triple::riscv32:
6735 case llvm::Triple::riscv64:
6736 case llvm::Triple::riscv32be:
6737 case llvm::Triple::riscv64be:
6754 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
6769 if (D->
hasAttr<DLLExportAttr>()) {
6770 Diag(CI.
getLoc(), diag::warn_attribute_ignored) <<
"'dllimport'";
6774 if (D->
hasAttr<DLLImportAttr>())
6782 if (DLLImportAttr *Import = D->
getAttr<DLLImportAttr>()) {
6783 Diag(Import->getLocation(), diag::warn_attribute_ignored) << Import;
6787 if (D->
hasAttr<DLLExportAttr>())
6800 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
6810 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
6812 MD->getParent()->isLambda()) {
6818 if (
auto *EA = D->
getAttr<ExcludeFromExplicitInstantiationAttr>()) {
6820 diag::warn_dllattr_ignored_exclusion_takes_precedence)
6825 Attr *NewAttr = A.
getKind() == ParsedAttr::AT_DLLExport
6836 if (MSInheritanceAttr *IA = D->
getAttr<MSInheritanceAttr>()) {
6837 if (IA->getInheritanceModel() == Model)
6839 Diag(IA->getLocation(), diag::err_mismatched_ms_inheritance)
6841 Diag(CI.
getLoc(), diag::note_previous_ms_inheritance);
6846 if (RD->hasDefinition()) {
6853 Diag(CI.
getLoc(), diag::warn_ignored_ms_inheritance)
6857 if (RD->getDescribedClassTemplate()) {
6858 Diag(CI.
getLoc(), diag::warn_ignored_ms_inheritance)
6876 StringRef N(
"mutex");
6878 if (AL.
getKind() == ParsedAttr::AT_Capability &&
6891 if (!D->
hasAttr<CapabilityAttr>()) {
6892 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_requires_preceded)
6893 << AL << cast<NamedDecl>(D) <<
"'capability'";
6909 AssertCapabilityAttr(S.
Context, AL, Args.data(), Args.size()));
6965 RequiresCapabilityAttr *RCA = ::new (S.
Context)
6966 RequiresCapabilityAttr(S.
Context, AL, Args.data(), Args.size());
6972 if (
const auto *NSD = dyn_cast<NamespaceDecl>(D)) {
6973 if (NSD->isAnonymousNamespace()) {
6974 S.
Diag(AL.
getLoc(), diag::warn_deprecated_anonymous_namespace);
6988 StringRef Str, Replacement;
7001 S.
Diag(AL.
getLoc(), diag::ext_cxx14_attr) << AL;
7007 if (
const auto *S = dyn_cast<VarDecl>(D))
7008 return S->hasGlobalStorage();
7013 return Sanitizer ==
"address" || Sanitizer ==
"hwaddress" ||
7014 Sanitizer ==
"memtag";
7021 std::vector<StringRef> Sanitizers;
7023 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
7024 StringRef SanitizerName;
7032 SanitizerName !=
"coverage")
7033 S.
Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << SanitizerName;
7035 S.
Diag(D->
getLocation(), diag::warn_attribute_type_not_supported_global)
7036 << AL << SanitizerName;
7037 Sanitizers.push_back(SanitizerName);
7041 Sanitizers.size()));
7054 unsigned TranslatedSpellingIndex = 0;
7056 TranslatedSpellingIndex = 1;
7065 StringRef SanitizerName =
"address";
7068 NoSanitizeAttr(S.
Context, Info, &SanitizerName, 1));
7072 StringRef SanitizerName =
"thread";
7075 NoSanitizeAttr(S.
Context, Info, &SanitizerName, 1));
7079 StringRef SanitizerName =
"memory";
7082 NoSanitizeAttr(S.
Context, Info, &SanitizerName, 1));
7097 ZeroCallUsedRegsAttr::ZeroCallUsedRegsKind Kind;
7098 if (!ZeroCallUsedRegsAttr::ConvertStrToZeroCallUsedRegsKind(KindStr, Kind)) {
7099 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported)
7104 D->
dropAttr<ZeroCallUsedRegsAttr>();
7120 case ParsedAttr::AT_CountedBy:
7121 CountInBytes =
false;
7124 case ParsedAttr::AT_CountedByOrNull:
7125 CountInBytes =
false;
7128 case ParsedAttr::AT_SizedBy:
7129 CountInBytes =
true;
7132 case ParsedAttr::AT_SizedByOrNull:
7133 CountInBytes =
true;
7137 llvm_unreachable(
"unexpected counted_by family attribute");
7145 FD->
getType(), CountExpr, CountInBytes, OrNull);
7156 FunctionReturnThunksAttr::Kind Kind;
7157 if (!FunctionReturnThunksAttr::ConvertStrToKind(KindStr, Kind)) {
7158 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported)
7165 D->
dropAttr<FunctionReturnThunksAttr>();
7166 D->
addAttr(FunctionReturnThunksAttr::Create(S.
Context, Kind, AL));
7176 auto *VDecl = dyn_cast<VarDecl>(D);
7177 if (VDecl && !VDecl->isFunctionPointerType()) {
7178 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored_non_function_pointer)
7192 << (A.
getKind() == ParsedAttr::AT_AlwaysDestroy);
7196 if (A.
getKind() == ParsedAttr::AT_AlwaysDestroy)
7204 "uninitialized is only valid on automatic duration variables");
7215 bool IsKernReturnT =
false;
7217 IsKernReturnT = (TT->getDecl()->getName() ==
"kern_return_t");
7222 diag::warn_mig_server_routine_does_not_return_kern_return_t);
7232 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
7235 S.
Diag(AL.
getLoc(), diag::warn_declspec_allocator_nonpointer)
7248 if (
const auto *PVD = dyn_cast<ParmVarDecl>(D)) {
7249 if (PVD->getType()->isIntegerType()) {
7250 S.
Diag(AL.
getLoc(), diag::err_attribute_output_parameter)
7261template<
typename Attr>
7274 Category =
"container";
7279 if (Category !=
"container") {
7280 S.
Diag(Loc, diag::warn_attribute_type_not_supported) << AL << Category;
7284 D->
addAttr(UnsafeBufferUsageAttr::Create(S.
Context, Category, AL));
7291 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7296 CFGuardAttr::GuardArg Arg;
7298 if (!CFGuardAttr::ConvertStrToGuardArg(II->
getName(), Arg)) {
7299 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported) << AL << II;
7307template <
typename AttrTy>
7310 auto I = llvm::find_if(Attrs,
7311 [Name](
const AttrTy *A) {
7312 return A->getTCBName() == Name;
7314 return I == Attrs.end() ?
nullptr : *I;
7317template <
typename AttrTy,
typename ConflictingAttrTy>
7324 if (
const ConflictingAttrTy *ConflictingAttr =
7328 S.
Diag(AL.
getLoc(), diag::err_tcb_conflicting_attributes)
7342template <
typename AttrTy,
typename ConflictingAttrTy>
7345 StringRef TCBName = AL.getTCBName();
7346 if (
const ConflictingAttrTy *ConflictingAttr =
7348 S.
Diag(ConflictingAttr->getLoc(), diag::err_tcb_conflicting_attributes)
7349 << ConflictingAttr->getAttrName()->getName()
7350 << AL.getAttrName()->getName() << TCBName;
7353 S.
Diag(AL.getLoc(), diag::note_conflicting_attribute);
7361 return ::new(Context) AttrTy(Context, AL, AL.getTCBName());
7370 Decl *D,
const EnforceTCBLeafAttr &AL) {
7380 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 4;
7385 S.
Diag(AL.
getLoc(), diag::err_attribute_too_few_arguments) << AL;
7390 if (D->
getAttr<VTablePointerAuthenticationAttr>()) {
7391 S.
Diag(AL.
getLoc(), diag::err_duplicated_vtable_pointer_auth) <<
Decl;
7395 auto KeyType = VTablePointerAuthenticationAttr::VPtrAuthKeyType::DefaultKey;
7398 if (!VTablePointerAuthenticationAttr::ConvertStrToVPtrAuthKeyType(
7400 S.
Diag(IL->
getLoc(), diag::err_invalid_authentication_key)
7404 if (KeyType == VTablePointerAuthenticationAttr::DefaultKey &&
7406 S.
Diag(AL.
getLoc(), diag::err_no_default_vtable_pointer_auth) << 0;
7410 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7415 auto AddressDiversityMode = VTablePointerAuthenticationAttr::
7416 AddressDiscriminationMode::DefaultAddressDiscrimination;
7420 if (!VTablePointerAuthenticationAttr::
7421 ConvertStrToAddressDiscriminationMode(
7423 S.
Diag(IL->
getLoc(), diag::err_invalid_address_discrimination)
7427 if (AddressDiversityMode ==
7428 VTablePointerAuthenticationAttr::DefaultAddressDiscrimination &&
7430 S.
Diag(IL->
getLoc(), diag::err_no_default_vtable_pointer_auth) << 1;
7434 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7439 auto ED = VTablePointerAuthenticationAttr::ExtraDiscrimination::
7440 DefaultExtraDiscrimination;
7444 if (!VTablePointerAuthenticationAttr::ConvertStrToExtraDiscrimination(
7446 S.
Diag(IL->
getLoc(), diag::err_invalid_extra_discrimination)
7450 if (ED == VTablePointerAuthenticationAttr::DefaultExtraDiscrimination &&
7452 S.
Diag(AL.
getLoc(), diag::err_no_default_vtable_pointer_auth) << 2;
7456 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
7461 uint32_t CustomDiscriminationValue = 0;
7462 if (ED == VTablePointerAuthenticationAttr::CustomDiscrimination) {
7464 S.
Diag(AL.
getLoc(), diag::err_missing_custom_discrimination) << AL << 4;
7469 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 4;
7474 CustomDiscriminationValue)) {
7475 S.
Diag(AL.
getLoc(), diag::err_invalid_custom_discrimination);
7478 }
else if (NumArgs > 3) {
7479 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments) << AL << 3;
7484 S.
Context, AL, KeyType, AddressDiversityMode, ED,
7485 CustomDiscriminationValue));
7492 return Existing->getModularImplFn() == ModularImplFn &&
7493 Existing->getImplName() == ImplName &&
7494 Existing->aspects_size() == Aspects.size() &&
7495 llvm::equal(Existing->aspects(), Aspects);
7501 if (
const auto *Existing = D->
getAttr<ModularFormatAttr>()) {
7503 Diag(Existing->getLocation(), diag::err_duplicate_attribute) << *Existing;
7504 Diag(CI.
getLoc(), diag::note_conflicting_attribute);
7508 return ::new (
Context) ModularFormatAttr(
Context, CI, ModularImplFn, ImplName,
7509 Aspects.data(), Aspects.size());
7515 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
7523 llvm::DenseSet<StringRef> SeenAspects;
7524 for (
unsigned I = 2, E = AL.
getNumArgs(); I != E; ++I) {
7528 if (!SeenAspects.insert(Aspect).second) {
7530 diag::err_modular_format_duplicate_aspect)
7535 Aspects.push_back(Aspect);
7541 llvm::sort(Aspects);
7544 if (
const auto *Existing = D->
getAttr<ModularFormatAttr>()) {
7546 S.
Diag(AL.
getLoc(), diag::err_duplicate_attribute) << *Existing;
7547 S.
Diag(Existing->getLoc(), diag::note_conflicting_attribute);
7554 S.
Context, AL, ModularImplFn, ImplName, Aspects.data(), Aspects.size()));
7570 for (
size_t I = 0; I < std::min(AL.
getNumArgs(), AttrNumArgs); ++I) {
7571 bool IsLastAttrArg = I == (AttrNumArgs - 1);
7574 if (IsLastAttrArg && AttrHasVariadicArg)
7582 return !(IsLastAttrArg && ArgMemberCanHoldExpr);
7594 if (PersonalityAttr *PA = D->
getAttr<PersonalityAttr>()) {
7598 Diag(PA->getLocation(), diag::err_mismatched_personality);
7599 Diag(CI.
getLoc(), diag::note_previous_attribute);
7611 S.
Diag(E->
getExprLoc(), diag::err_attribute_personality_arg_not_function)
7641 S.
Diag(AL.
getLoc(), diag::err_keyword_not_supported_on_target)
7644 S.
Diag(AL.
getLoc(), diag::warn_unhandled_ms_attribute_ignored)
7653 AL.
getKind() == ParsedAttr::AT_NoInline) {
7654 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
7656 if (PVD->hasAttr<HLSLGroupSharedAddressSpaceAttr>()) {
7657 S.
Diag(AL.
getLoc(), diag::err_hlsl_attr_incompatible)
7658 <<
"'noinline'" <<
"'groupshared' parameter";
7672 if (MustDelayArgs) {
7682 assert(AL.
isTypeAttr() &&
"Non-type attribute not handled");
7708 S.
Diag(AL.
getLoc(), diag::warn_type_attribute_deprecated_on_decl)
7717 if (AL.
getKind() == ParsedAttr::AT_Regparm) {
7730 if (AL.
getKind() == ParsedAttr::AT_VectorSize) {
7740 if (AL.
getKind() == ParsedAttr::AT_NoDeref) {
7751 S.
Diag(AL.
getLoc(), diag::err_attribute_invalid_on_decl)
7754 case ParsedAttr::AT_Interrupt:
7757 case ParsedAttr::AT_ARMInterruptSaveFP:
7760 case ParsedAttr::AT_X86ForceAlignArgPointer:
7763 case ParsedAttr::AT_ReadOnlyPlacement:
7766 case ParsedAttr::AT_DLLExport:
7767 case ParsedAttr::AT_DLLImport:
7770 case ParsedAttr::AT_AMDGPUFlatWorkGroupSize:
7773 case ParsedAttr::AT_AMDGPUWavesPerEU:
7776 case ParsedAttr::AT_AMDGPUNumSGPR:
7779 case ParsedAttr::AT_AMDGPUNumVGPR:
7782 case ParsedAttr::AT_AMDGPUMaxNumWorkGroups:
7785 case ParsedAttr::AT_AVRSignal:
7788 case ParsedAttr::AT_BPFPreserveAccessIndex:
7791 case ParsedAttr::AT_BPFPreserveStaticOffset:
7794 case ParsedAttr::AT_BTFDeclTag:
7797 case ParsedAttr::AT_WebAssemblyExportName:
7800 case ParsedAttr::AT_WebAssemblyImportModule:
7803 case ParsedAttr::AT_WebAssemblyImportName:
7806 case ParsedAttr::AT_IBOutlet:
7809 case ParsedAttr::AT_IBOutletCollection:
7812 case ParsedAttr::AT_IFunc:
7815 case ParsedAttr::AT_Alias:
7818 case ParsedAttr::AT_Aligned:
7821 case ParsedAttr::AT_AlignValue:
7824 case ParsedAttr::AT_AllocSize:
7827 case ParsedAttr::AT_AlwaysInline:
7830 case ParsedAttr::AT_AnalyzerNoReturn:
7833 case ParsedAttr::AT_TLSModel:
7836 case ParsedAttr::AT_Annotate:
7839 case ParsedAttr::AT_Availability:
7842 case ParsedAttr::AT_CPUDispatch:
7843 case ParsedAttr::AT_CPUSpecific:
7846 case ParsedAttr::AT_Common:
7849 case ParsedAttr::AT_CUDAConstant:
7852 case ParsedAttr::AT_PassObjectSize:
7855 case ParsedAttr::AT_Constructor:
7858 case ParsedAttr::AT_Deprecated:
7861 case ParsedAttr::AT_Destructor:
7864 case ParsedAttr::AT_EnableIf:
7867 case ParsedAttr::AT_Error:
7870 case ParsedAttr::AT_ExcludeFromExplicitInstantiation:
7873 case ParsedAttr::AT_DiagnoseIf:
7876 case ParsedAttr::AT_DiagnoseAsBuiltin:
7879 case ParsedAttr::AT_NoBuiltin:
7882 case ParsedAttr::AT_CFIUncheckedCallee:
7885 case ParsedAttr::AT_ExtVectorType:
7888 case ParsedAttr::AT_ExternalSourceSymbol:
7891 case ParsedAttr::AT_MinSize:
7894 case ParsedAttr::AT_OptimizeNone:
7897 case ParsedAttr::AT_EnumExtensibility:
7900 case ParsedAttr::AT_SYCLKernel:
7903 case ParsedAttr::AT_SYCLExternal:
7906 case ParsedAttr::AT_SYCLKernelEntryPoint:
7909 case ParsedAttr::AT_SYCLSpecialClass:
7912 case ParsedAttr::AT_Format:
7915 case ParsedAttr::AT_FormatMatches:
7918 case ParsedAttr::AT_FormatArg:
7921 case ParsedAttr::AT_Callback:
7924 case ParsedAttr::AT_LifetimeCaptureBy:
7927 case ParsedAttr::AT_CalledOnce:
7930 case ParsedAttr::AT_CUDAGlobal:
7933 case ParsedAttr::AT_CUDADevice:
7936 case ParsedAttr::AT_CUDAGridConstant:
7939 case ParsedAttr::AT_HIPManaged:
7942 case ParsedAttr::AT_GNUInline:
7945 case ParsedAttr::AT_CUDALaunchBounds:
7948 case ParsedAttr::AT_CUDAClusterDims:
7951 case ParsedAttr::AT_CUDANoCluster:
7954 case ParsedAttr::AT_Restrict:
7957 case ParsedAttr::AT_MallocSpan:
7960 case ParsedAttr::AT_Mode:
7963 case ParsedAttr::AT_NonString:
7966 case ParsedAttr::AT_NonNull:
7967 if (
auto *PVD = dyn_cast<ParmVarDecl>(D))
7972 case ParsedAttr::AT_ReturnsNonNull:
7975 case ParsedAttr::AT_NoEscape:
7978 case ParsedAttr::AT_MaybeUndef:
7981 case ParsedAttr::AT_AssumeAligned:
7984 case ParsedAttr::AT_AllocAlign:
7987 case ParsedAttr::AT_Ownership:
7990 case ParsedAttr::AT_Naked:
7993 case ParsedAttr::AT_NoReturn:
7996 case ParsedAttr::AT_CXX11NoReturn:
7999 case ParsedAttr::AT_AnyX86NoCfCheck:
8002 case ParsedAttr::AT_NoThrow:
8006 case ParsedAttr::AT_CUDAShared:
8009 case ParsedAttr::AT_VecReturn:
8012 case ParsedAttr::AT_ObjCOwnership:
8015 case ParsedAttr::AT_ObjCPreciseLifetime:
8018 case ParsedAttr::AT_ObjCReturnsInnerPointer:
8021 case ParsedAttr::AT_ObjCRequiresSuper:
8024 case ParsedAttr::AT_ObjCBridge:
8027 case ParsedAttr::AT_ObjCBridgeMutable:
8030 case ParsedAttr::AT_ObjCBridgeRelated:
8033 case ParsedAttr::AT_ObjCDesignatedInitializer:
8036 case ParsedAttr::AT_ObjCRuntimeName:
8039 case ParsedAttr::AT_ObjCBoxable:
8042 case ParsedAttr::AT_NSErrorDomain:
8045 case ParsedAttr::AT_CFConsumed:
8046 case ParsedAttr::AT_NSConsumed:
8047 case ParsedAttr::AT_OSConsumed:
8052 case ParsedAttr::AT_OSReturnsRetainedOnZero:
8055 diag::warn_ns_attribute_wrong_parameter_type,
8058 case ParsedAttr::AT_OSReturnsRetainedOnNonZero:
8061 diag::warn_ns_attribute_wrong_parameter_type,
8064 case ParsedAttr::AT_NSReturnsAutoreleased:
8065 case ParsedAttr::AT_NSReturnsNotRetained:
8066 case ParsedAttr::AT_NSReturnsRetained:
8067 case ParsedAttr::AT_CFReturnsNotRetained:
8068 case ParsedAttr::AT_CFReturnsRetained:
8069 case ParsedAttr::AT_OSReturnsNotRetained:
8070 case ParsedAttr::AT_OSReturnsRetained:
8073 case ParsedAttr::AT_WorkGroupSizeHint:
8076 case ParsedAttr::AT_ReqdWorkGroupSize:
8079 case ParsedAttr::AT_OpenCLIntelReqdSubGroupSize:
8082 case ParsedAttr::AT_VecTypeHint:
8085 case ParsedAttr::AT_InitPriority:
8088 case ParsedAttr::AT_Packed:
8091 case ParsedAttr::AT_PreferredName:
8094 case ParsedAttr::AT_NoSpecializations:
8097 case ParsedAttr::AT_Section:
8100 case ParsedAttr::AT_CodeModel:
8103 case ParsedAttr::AT_RandomizeLayout:
8106 case ParsedAttr::AT_NoRandomizeLayout:
8109 case ParsedAttr::AT_CodeSeg:
8112 case ParsedAttr::AT_Target:
8115 case ParsedAttr::AT_TargetVersion:
8118 case ParsedAttr::AT_TargetClones:
8121 case ParsedAttr::AT_MinVectorWidth:
8124 case ParsedAttr::AT_Unavailable:
8127 case ParsedAttr::AT_OMPAssume:
8130 case ParsedAttr::AT_ObjCDirect:
8133 case ParsedAttr::AT_ObjCDirectMembers:
8137 case ParsedAttr::AT_ObjCExplicitProtocolImpl:
8140 case ParsedAttr::AT_Unused:
8143 case ParsedAttr::AT_Visibility:
8146 case ParsedAttr::AT_TypeVisibility:
8149 case ParsedAttr::AT_WarnUnusedResult:
8152 case ParsedAttr::AT_WeakRef:
8155 case ParsedAttr::AT_WeakImport:
8158 case ParsedAttr::AT_TransparentUnion:
8161 case ParsedAttr::AT_ObjCMethodFamily:
8164 case ParsedAttr::AT_ObjCNSObject:
8167 case ParsedAttr::AT_ObjCIndependentClass:
8170 case ParsedAttr::AT_Blocks:
8173 case ParsedAttr::AT_Sentinel:
8176 case ParsedAttr::AT_Cleanup:
8179 case ParsedAttr::AT_NoDebug:
8182 case ParsedAttr::AT_CmseNSEntry:
8185 case ParsedAttr::AT_StdCall:
8186 case ParsedAttr::AT_CDecl:
8187 case ParsedAttr::AT_FastCall:
8188 case ParsedAttr::AT_ThisCall:
8189 case ParsedAttr::AT_Pascal:
8190 case ParsedAttr::AT_RegCall:
8191 case ParsedAttr::AT_SwiftCall:
8192 case ParsedAttr::AT_SwiftAsyncCall:
8193 case ParsedAttr::AT_VectorCall:
8194 case ParsedAttr::AT_MSABI:
8195 case ParsedAttr::AT_SysVABI:
8196 case ParsedAttr::AT_Pcs:
8197 case ParsedAttr::AT_IntelOclBicc:
8198 case ParsedAttr::AT_PreserveMost:
8199 case ParsedAttr::AT_PreserveAll:
8200 case ParsedAttr::AT_AArch64VectorPcs:
8201 case ParsedAttr::AT_AArch64SVEPcs:
8202 case ParsedAttr::AT_M68kRTD:
8203 case ParsedAttr::AT_PreserveNone:
8204 case ParsedAttr::AT_RISCVVectorCC:
8205 case ParsedAttr::AT_RISCVVLSCC:
8208 case ParsedAttr::AT_DeviceKernel:
8211 case ParsedAttr::AT_Suppress:
8214 case ParsedAttr::AT_Owner:
8215 case ParsedAttr::AT_Pointer:
8218 case ParsedAttr::AT_OpenCLAccess:
8221 case ParsedAttr::AT_OpenCLNoSVM:
8224 case ParsedAttr::AT_SwiftContext:
8227 case ParsedAttr::AT_SwiftAsyncContext:
8230 case ParsedAttr::AT_SwiftErrorResult:
8233 case ParsedAttr::AT_SwiftIndirectResult:
8236 case ParsedAttr::AT_InternalLinkage:
8239 case ParsedAttr::AT_ZeroCallUsedRegs:
8242 case ParsedAttr::AT_FunctionReturnThunks:
8245 case ParsedAttr::AT_NoMerge:
8248 case ParsedAttr::AT_NoUniqueAddress:
8252 case ParsedAttr::AT_AvailableOnlyInDefaultEvalMethod:
8256 case ParsedAttr::AT_CountedBy:
8257 case ParsedAttr::AT_CountedByOrNull:
8258 case ParsedAttr::AT_SizedBy:
8259 case ParsedAttr::AT_SizedByOrNull:
8263 case ParsedAttr::AT_NoFieldProtection:
8267 case ParsedAttr::AT_Personality:
8272 case ParsedAttr::AT_LayoutVersion:
8275 case ParsedAttr::AT_Uuid:
8278 case ParsedAttr::AT_MSInheritance:
8281 case ParsedAttr::AT_Thread:
8284 case ParsedAttr::AT_MSConstexpr:
8287 case ParsedAttr::AT_HybridPatchable:
8292 case ParsedAttr::AT_RootSignature:
8295 case ParsedAttr::AT_HLSLNumThreads:
8298 case ParsedAttr::AT_HLSLWaveSize:
8301 case ParsedAttr::AT_HLSLVkExtBuiltinInput:
8304 case ParsedAttr::AT_HLSLVkExtBuiltinOutput:
8307 case ParsedAttr::AT_HLSLVkPushConstant:
8310 case ParsedAttr::AT_HLSLVkConstantId:
8313 case ParsedAttr::AT_HLSLVkBinding:
8316 case ParsedAttr::AT_HLSLGroupSharedAddressSpace:
8319 case ParsedAttr::AT_HLSLPackOffset:
8322 case ParsedAttr::AT_HLSLShader:
8325 case ParsedAttr::AT_HLSLResourceBinding:
8328 case ParsedAttr::AT_HLSLInterpolationModifier:
8331 case ParsedAttr::AT_HLSLParamModifier:
8334 case ParsedAttr::AT_HLSLUnparsedSemantic:
8337 case ParsedAttr::AT_HLSLVkLocation:
8341 case ParsedAttr::AT_AbiTag:
8344 case ParsedAttr::AT_CFGuard:
8349 case ParsedAttr::AT_PtGuardedVar:
8352 case ParsedAttr::AT_NoSanitize:
8355 case ParsedAttr::AT_NoSanitizeAddress:
8358 case ParsedAttr::AT_NoSanitizeThread:
8361 case ParsedAttr::AT_NoSanitizeMemory:
8364 case ParsedAttr::AT_GuardedBy:
8367 case ParsedAttr::AT_PtGuardedBy:
8370 case ParsedAttr::AT_LockReturned:
8373 case ParsedAttr::AT_LocksExcluded:
8376 case ParsedAttr::AT_AcquiredBefore:
8379 case ParsedAttr::AT_AcquiredAfter:
8384 case ParsedAttr::AT_Capability:
8385 case ParsedAttr::AT_Lockable:
8388 case ParsedAttr::AT_ReentrantCapability:
8391 case ParsedAttr::AT_RequiresCapability:
8395 case ParsedAttr::AT_AssertCapability:
8398 case ParsedAttr::AT_AcquireCapability:
8401 case ParsedAttr::AT_ReleaseCapability:
8404 case ParsedAttr::AT_TryAcquireCapability:
8409 case ParsedAttr::AT_Consumable:
8412 case ParsedAttr::AT_CallableWhen:
8415 case ParsedAttr::AT_ParamTypestate:
8418 case ParsedAttr::AT_ReturnTypestate:
8421 case ParsedAttr::AT_SetTypestate:
8424 case ParsedAttr::AT_TestTypestate:
8429 case ParsedAttr::AT_ArgumentWithTypeTag:
8432 case ParsedAttr::AT_TypeTagForDatatype:
8437 case ParsedAttr::AT_SwiftAsyncName:
8440 case ParsedAttr::AT_SwiftAttr:
8443 case ParsedAttr::AT_SwiftBridge:
8446 case ParsedAttr::AT_SwiftError:
8449 case ParsedAttr::AT_SwiftName:
8452 case ParsedAttr::AT_SwiftNewType:
8455 case ParsedAttr::AT_SwiftAsync:
8458 case ParsedAttr::AT_SwiftAsyncError:
8463 case ParsedAttr::AT_XRayLogArgs:
8467 case ParsedAttr::AT_PatchableFunctionEntry:
8471 case ParsedAttr::AT_AlwaysDestroy:
8472 case ParsedAttr::AT_NoDestroy:
8476 case ParsedAttr::AT_Uninitialized:
8480 case ParsedAttr::AT_ObjCExternallyRetained:
8484 case ParsedAttr::AT_MIGServerRoutine:
8488 case ParsedAttr::AT_MSAllocator:
8492 case ParsedAttr::AT_ArmBuiltinAlias:
8496 case ParsedAttr::AT_ArmLocallyStreaming:
8500 case ParsedAttr::AT_ArmNew:
8504 case ParsedAttr::AT_AcquireHandle:
8508 case ParsedAttr::AT_ReleaseHandle:
8512 case ParsedAttr::AT_UnsafeBufferUsage:
8516 case ParsedAttr::AT_UseHandle:
8520 case ParsedAttr::AT_EnforceTCB:
8524 case ParsedAttr::AT_EnforceTCBLeaf:
8528 case ParsedAttr::AT_BuiltinAlias:
8532 case ParsedAttr::AT_PreferredType:
8536 case ParsedAttr::AT_UsingIfExists:
8540 case ParsedAttr::AT_TypeNullable:
8544 case ParsedAttr::AT_VTablePointerAuthentication:
8548 case ParsedAttr::AT_ModularFormat:
8552 case ParsedAttr::AT_MSStruct:
8556 case ParsedAttr::AT_GCCStruct:
8560 case ParsedAttr::AT_PointerFieldProtection:
8563 diag::err_attribute_pointer_field_protection_experimental)
8572 return D->
hasAttr<DeviceKernelAttr>() ||
8581 const auto *Flat = D->
getAttr<AMDGPUFlatWorkGroupSizeAttr>();
8582 const auto *Reqd = D->
getAttr<ReqdWorkGroupSizeAttr>();
8586 auto Eval = [&](
Expr *E) -> std::optional<uint64_t> {
8587 if (E->isValueDependent())
8588 return std::nullopt;
8589 std::optional<llvm::APSInt>
V = E->getIntegerConstantExpr(S.
Context);
8591 return std::nullopt;
8592 return V->getZExtValue();
8595 std::optional<uint64_t>
X = Eval(Reqd->getXDim());
8596 std::optional<uint64_t> Y = Eval(Reqd->getYDim());
8597 std::optional<uint64_t> Z = Eval(Reqd->getZDim());
8598 std::optional<uint64_t>
Min = Eval(Flat->getMin());
8599 std::optional<uint64_t>
Max = Eval(Flat->getMax());
8600 if (!
X || !Y || !Z || !
Min || !
Max)
8603 uint64_t Product = *
X * *Y * *Z;
8604 if (*
Min != Product || *
Max != Product) {
8605 S.
Diag(Flat->getLocation(),
8606 diag::err_attribute_amdgpu_flat_work_group_size_mismatch);
8614 if (AttrList.
empty())
8625 Diag(AttrList.
begin()->getLoc(), diag::err_attribute_weakref_without_alias)
8635 if (!(D->
hasAttr<DeviceKernelAttr>() ||
8636 (D->
hasAttr<CUDAGlobalAttr>() &&
8637 Context.getTargetInfo().getTriple().isSPIRV()))) {
8639 if (
const auto *A = D->
getAttr<ReqdWorkGroupSizeAttr>()) {
8644 }
else if (
const auto *A = D->
getAttr<WorkGroupSizeHintAttr>()) {
8647 }
else if (
const auto *A = D->
getAttr<VecTypeHintAttr>()) {
8650 }
else if (
const auto *A = D->
getAttr<OpenCLIntelReqdSubGroupSizeAttr>()) {
8656 if (
const auto *A = D->
getAttr<AMDGPUFlatWorkGroupSizeAttr>()) {
8660 }
else if (
const auto *A = D->
getAttr<AMDGPUWavesPerEUAttr>()) {
8664 }
else if (
const auto *A = D->
getAttr<AMDGPUNumSGPRAttr>()) {
8668 }
else if (
const auto *A = D->
getAttr<AMDGPUNumVGPRAttr>()) {
8686 if (
auto *Guide = dyn_cast<CXXDeductionGuideDecl>(D)) {
8687 bool HasHost = Guide->hasAttr<CUDAHostAttr>();
8688 bool HasDevice = Guide->hasAttr<CUDADeviceAttr>();
8689 bool HasGlobal = Guide->hasAttr<CUDAGlobalAttr>();
8691 if (HasGlobal || HasHost != HasDevice) {
8692 Diag(Guide->getLocation(), diag::err_deduction_guide_target_attr);
8693 Guide->setInvalidDecl();
8694 }
else if (HasHost && HasDevice) {
8695 Diag(Guide->getLocation(),
8696 diag::warn_deduction_guide_target_attr_deprecated);
8702 (D->
hasAttr<ConstructorAttr>() || D->
hasAttr<DestructorAttr>()) &&
8705 << (D->
hasAttr<ConstructorAttr>() ?
"constructors" :
"destructors");
8714 if (D->
hasAttr<ObjCDesignatedInitializerAttr>() &&
8717 D->
dropAttr<ObjCDesignatedInitializerAttr>();
8724 if (AL.getKind() == ParsedAttr::AT_TransparentUnion) {
8731 if (D && D->
hasAttr<BPFPreserveAccessIndexAttr>())
8738 if (AL.getKind() == ParsedAttr::AT_Annotate) {
8741 Diag(AL.getLoc(), diag::err_only_annotate_after_access_spec);
8753 if (AL.isUsedAsTypeAttr() || AL.isInvalid())
8761 S.
Diag(AL.getLoc(), diag::warn_attribute_not_on_decl) << AL
8779 if (
Diags.isIgnored(diag::warn_unknown_attribute_ignored, NR.
getBegin()) &&
8780 Diags.isIgnored(diag::warn_unknown_attribute_ignored_suggestion,
8784 std::optional<StringRef> CorrectedScopeName =
8786 if (CorrectedScopeName) {
8787 ScopeName = *CorrectedScopeName;
8793 if (CorrectedAttrName) {
8794 AttrName = *CorrectedAttrName;
8797 if (CorrectedScopeName || CorrectedAttrName) {
8798 std::string CorrectedFullName =
8802 diag::warn_unknown_attribute_ignored_suggestion);
8804 D << AL << CorrectedFullName;
8809 if (CorrectedScopeName) {
8813 if (CorrectedAttrName) {
8818 Diag(NR.
getBegin(), diag::warn_unknown_attribute_ignored) << AL << NR;
8826 if (
auto *FD = dyn_cast<FunctionDecl>(ND)) {
8848 for (
const auto &AI : FT->param_types()) {
8850 Param->setScopeInfo(0, Params.size());
8851 Params.push_back(Param);
8853 NewFD->setParams(Params);
8855 }
else if (
auto *VD = dyn_cast<VarDecl>(ND)) {
8857 VD->getInnerLocStart(), VD->getLocation(), II,
8858 VD->getType(), VD->getTypeSourceInfo(),
8859 VD->getStorageClass());
8860 if (VD->getQualifier())
8861 cast<VarDecl>(NewD)->setQualifierInfo(VD->getQualifierLoc());
8894 if (
auto *VD = dyn_cast<VarDecl>(D))
8895 if (VD->isExternC())
8897 if (
auto *FD = dyn_cast<FunctionDecl>(D))
8905 auto &WeakInfos = I->second;
8906 for (
const auto &W : WeakInfos)
8908 std::remove_reference_t<
decltype(WeakInfos)> EmptyWeakInfos;
8909 WeakInfos.swap(EmptyWeakInfos);
8921 auto ProcessAttributesWithSliding =
8929 if ((AL.isStandardAttributeSyntax() || AL.isAlignas()) &&
8930 AL.slidesFromDeclToDeclSpecLegacyBehavior()) {
8935 AL.diagnoseAppertainsTo(*
this, D);
8950 .WithIncludeCXX11Attributes(
false)
8951 .WithIgnoreTypeAttributes(
true));
8960 .WithIncludeCXX11Attributes(
false)
8961 .WithIgnoreTypeAttributes(
true));
8979 UnavailableAttr::ImplicitReason &reason) {
8993 if (
diag.getForbiddenTypeDiagnostic() == diag::err_arc_weak_disabled ||
8994 diag.getForbiddenTypeDiagnostic() == diag::err_arc_weak_no_runtime) {
8995 reason = UnavailableAttr::IR_ForbiddenWeak;
9004 reason = UnavailableAttr::IR_ARCForbiddenType;
9014 auto Reason = UnavailableAttr::IR_None;
9016 assert(Reason &&
"didn't set reason?");
9021 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
9024 if (FD->
hasAttr<UnavailableAttr>() &&
9026 diag::err_arc_array_param_no_ownership) {
9057 bool AnyAccessFailures =
false;
9065 switch (
diag.Kind) {
9069 if (!
decl->isInvalidDecl())
9081 AnyAccessFailures =
true;
9094 assert(curPool &&
"re-emitting in undelayed context not supported");
9095 curPool->
steal(pool);
9112 QualType ParamTy = FD->getParamDecl(0)->getType();
9115 FD->getParamDecl(0)->getLocation(), ParamTy, Ty)) &&
9117 this->
Diag(Attr->getArgLoc(),
9118 diag::err_attribute_cleanup_func_arg_incompatible_type)
9119 << NI.
getName() << ParamTy << Ty;
9127 if (this->
Context.getAsArrayType(
T))
9128 T = this->
Context.getBaseElementType(
T);
9129 if (!
T->isRecordType()) {
9130 this->
Diag(A->
getLoc(), diag::err_init_priority_object_attr);
Defines the clang::ASTContext interface.
static SmallString< 64 > normalizeName(StringRef AttrName, StringRef ScopeName, AttributeCommonInfo::Syntax SyntaxUsed)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines the classes used to store parsed information about declaration-specifiers and decla...
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.
Result
Implement __builtin_bit_cast and related operations.
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 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 bool checkThreadSafetyValueDeclIsFunPtr(Sema &S, const ValueDecl *VD, const AttributeCommonInfo &A)
Checks that thread-safety attributes on variables or fields apply only to function pointer or functio...
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 bool modularFormatAttrsEquiv(const ModularFormatAttr *Existing, const IdentifierInfo *ModularImplFn, StringRef ImplName, ArrayRef< StringRef > Aspects)
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 bool checkGuardedByAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, SmallVectorImpl< Expr * > &Args)
static void handleNoCfCheckAttr(Sema &S, Decl *D, const ParsedAttr &Attrs)
static void handleMallocSpanAttr(Sema &S, Decl *D, const ParsedAttr &AL)
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 handleNoPFPAttrField(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 handleModularFormat(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 https://gcc.gnu.org/onlinedocs/gcc/Common-Fu...
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 handleUnsafeBufferUsage(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleMSStructAttr(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 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 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 handlePersonalityAttr(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 bool isCallbackOrDependent(QualType T)
True if T names a function to call: a function pointer, a function reference, or a reference to a fun...
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 handleNoSanitizeAddressAttr(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 shouldInferAvailabilityAttribute(const ParsedAttr &AL, IdentifierInfo *&II, bool &IsUnavailable, VersionTuple &Introduced, VersionTuple &Deprecated, VersionTuple &Obsolete, Sema &S)
Returns true if the given availability attribute should be inferred, and adjusts the value of the att...
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 checkThreadSafetyAttrSubject(Sema &S, Decl *D, const ParsedAttr &AL, bool CheckParmVar=false)
static void handleNoBuiltinAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleGCCStructAttr(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 checkAMDGPUReqdWorkGroupSize(Sema &S, Decl *D)
static void handleCallableWhenAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool hasBTFDeclTagAttr(Decl *D, StringRef Tag)
static void handleDelayedForbiddenType(Sema &S, DelayedDiagnostic &DD, Decl *D)
Handle a delayed forbidden-type diagnostic.
static void handleNoClusterAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkLockFunAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, SmallVectorImpl< Expr * > &Args)
static void handleAssumeAlignedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSharedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleMSInheritanceAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleVecTypeHint(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleRestrictAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleMinVectorWidthAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleUnusedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static Expr * makeLaunchBoundsArgExpr(Sema &S, Expr *E, const CUDALaunchBoundsAttr &AL, const unsigned Idx)
static bool checkFunParamsAreScopedLockable(Sema &S, const ParmVarDecl *ParamDecl, const AttributeCommonInfo &AL)
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 AttributeCommonInfo getNoSanitizeAttrInfo(const ParsedAttr &NoSanitizeSpecificAttr)
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 handleNoSanitizeThreadAttr(Sema &S, Decl *D, const ParsedAttr &AL)
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 std::pair< Expr *, int > makeClusterDimsArgExpr(Sema &S, Expr *E, const CUDAClusterDimsAttr &AL, const unsigned Idx)
static void handleNoSanitizeMemoryAttr(Sema &S, Decl *D, const ParsedAttr &AL)
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 void handleClusterDimsAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool handleFormatAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, FormatAttrCommon *Info)
Handle attribute((format(type,idx,firstarg))) attributes based on https://gcc.gnu....
static void handleCallConvAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleMinSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static ExprResult sharedGetConstructorDestructorAttrExpr(Sema &S, const ParsedAttr &AL)
static void handleOwnershipAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static OffloadArch getOffloadArch(const TargetInfo &TI)
static bool checkTypedefTypeForCapability(QualType Ty)
static void handleAcquiredBeforeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleReleaseCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void ProcessDeclAttribute(Sema &S, Decl *D, const ParsedAttr &AL, const Sema::ProcessDeclAttributeOptions &Options)
ProcessDeclAttribute - Apply the specific attribute to the specified decl if the attribute applies to...
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?
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 bool checkAvailabilityAttr(Sema &S, SourceRange Range, const IdentifierInfo *Platform, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted)
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 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 PowerPC.
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.
a trap message and trap category.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
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()
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 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.
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.
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.
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
const TargetInfo & getTargetInfo() const
TargetCXXABI::Kind getCXXABIKind() const
Return the C++ ABI kind that should be used.
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
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.
static bool validateAnyAppleOSVersion(const llvm::VersionTuple &Version)
Returns true if the anyAppleOS version is valid (empty or >= 26.0).
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.
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.
This is an opaque type for sizes expressed in character units.
QuantityType getQuantity() const
Get the raw integer representation of this quantity.
Declaration of a class template.
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
The information about the darwin SDK that was used during this compilation.
const RelatedTargetVersionMapping * getVersionMapping(OSEnvPair Kind) const
The results of name lookup within a DeclContext.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isFileContext() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
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
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...
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
std::optional< llvm::APSInt > getIntegerConstantExpr(const ASTContext &Ctx, bool AllowRelaxedEval=false) 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 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.
@ None
No signing for any function.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
bool isCompatibleWithMSVC() const
bool isTargetDevice() const
True when compiling for an offloading target device.
void push_back(const T &LocalValue)
Represents the results of name lookup.
A pointer to member type per C++ 8.3.3 - Pointers to members.
Describes a module or submodule.
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
bool isExternallyVisible() const
A C++ nested-name-specifier augmented with source location information.
ObjCMethodDecl - Represents an instance or class method declaration.
Represents one property declaration in an Objective-C interface.
A processor an offloading action can target.
llvm::NVPTX::GPUKind nvptxKind() const
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.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
ParsedAttr - Represents a syntactic attribute.
bool isPackExpansion() const
const AvailabilityChange & getAvailabilityDeprecated() const
unsigned getSemanticSpelling() const
If the parsed attribute has a semantic equivalent, and it would have a semantic Spelling enumeration ...
bool existsInTarget(const TargetInfo &Target) const
bool checkExactlyNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has exactly as many args as Num.
IdentifierLoc * getArgAsIdent(unsigned Arg) const
bool hasParsedType() const
const AvailabilityChange & getAvailabilityIntroduced() const
void setInvalid(bool b=true) const
bool hasVariadicArg() const
const ParsedAttrInfo & getInfo() const
void handleAttrWithDelayedArgs(Sema &S, Decl *D) const
const Expr * getReplacementExpr() const
bool hasProcessingCache() const
SourceLocation getUnavailableLoc() const
unsigned getProcessingCache() const
const IdentifierLoc * getEnvironment() const
bool acceptsExprPack() const
const Expr * getMessageExpr() const
const ParsedType & getMatchingCType() const
const ParsedType & getTypeArg() const
SourceLocation getStrictLoc() const
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this attribute.
bool isArgIdent(unsigned Arg) const
Expr * getArgAsExpr(unsigned Arg) const
bool getMustBeNull() const
bool checkAtLeastNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has at least as many args as Num.
bool isUsedAsTypeAttr() const
unsigned getNumArgMembers() const
bool isPragmaClangAttribute() const
True if the attribute is specified using 'pragma clang attribute'.
bool slidesFromDeclToDeclSpecLegacyBehavior() const
Returns whether a [[]] attribute, if specified ahead of a declaration, should be applied to the decl-...
AttributeCommonInfo::Kind getKind() const
void setProcessingCache(unsigned value) const
bool isParamExpr(size_t N) const
bool isArgExpr(unsigned Arg) const
bool getLayoutCompatible() const
ArgsUnion getArg(unsigned Arg) const
getArg - Return the specified argument.
SourceLocation getEllipsisLoc() const
bool checkAtMostNumArgs(class Sema &S, unsigned Num) const
Check if the attribute has at most as many args as Num.
const AvailabilityChange & getAvailabilityObsoleted() const
void addAtEnd(ParsedAttr *newAttr)
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
IdentifierTable & getIdentifierTable()
A (possibly-)qualified type.
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
specific_decl_iterator< FieldDecl > field_iterator
RecordDecl * getDefinitionOrSelf() const
field_iterator field_begin() const
Base for LValueReferenceType and RValueReferenceType.
Scope - A scope is a transient data structure that is used while parsing the program.
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)
void handleInterruptAttr(Decl *D, const ParsedAttr &AL)
void handleBuiltinAliasAttr(Decl *D, const ParsedAttr &AL)
void handleNewAttr(Decl *D, const ParsedAttr &AL)
bool checkTargetVersionAttr(const StringRef Param, const SourceLocation Loc, SmallString< 64 > &NewParam)
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)
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 handleVkLocationAttr(Decl *D, const ParsedAttr &AL)
void handleSemanticAttr(Decl *D, const ParsedAttr &AL)
void handleInterpolationModifierAttr(Decl *D, const ParsedAttr &AL)
void handleShaderAttr(Decl *D, const ParsedAttr &AL)
void handleVkExtBuiltinOutputAttr(Decl *D, const ParsedAttr &AL)
void handlePackOffsetAttr(Decl *D, const ParsedAttr &AL)
void handleParamModifierAttr(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 handleVkPushConstantAttr(Decl *D, const ParsedAttr &AL)
void handleVkBindingAttr(Decl *D, const ParsedAttr &AL)
void handleVkConstantIdAttr(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)
bool isObjCWritebackConversion(QualType FromType, QualType ToType, QualType &ConvertedType)
Determine whether this is an Objective-C writeback conversion, used for parameter passing when perfor...
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 checkTargetClonesAttr(const SmallVectorImpl< StringRef > &Params, const SmallVectorImpl< SourceLocation > &Locs, SmallVectorImpl< SmallString< 64 > > &NewParams, SourceLocation AttrLoc)
bool isAliasValid(unsigned BuiltinID, llvm::StringRef AliasName)
bool checkTargetClonesAttr(const SmallVectorImpl< StringRef > &Params, const SmallVectorImpl< SourceLocation > &Locs, SmallVectorImpl< SmallString< 64 > > &NewParams, SourceLocation AttrLoc)
void handleInterruptAttr(Decl *D, const ParsedAttr &AL)
bool checkTargetVersionAttr(const StringRef Param, const SourceLocation Loc, SmallString< 64 > &NewParam)
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(const SmallVectorImpl< StringRef > &Params, const SmallVectorImpl< SourceLocation > &Locs, SmallVectorImpl< SmallString< 64 > > &NewParams, SourceLocation AttrLoc)
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)
DelayedDiagnosticsState ParsingDeclState
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.
AvailabilityAttr * mergeAvailabilityAttr(NamedDecl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK, int Priority, const IdentifierInfo *IIEnvironment, const IdentifierInfo *InferredPlatformII=nullptr)
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 ...
bool CheckVarDeclSizeAddressSpace(const VarDecl *VD, LangAS AS)
Check whether the given variable declaration has a size that fits within the address space it is decl...
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...
PersonalityAttr * mergePersonalityAttr(Decl *D, FunctionDecl *Routine, const AttributeCommonInfo &CI)
AvailabilityAttr * mergeAndInferAvailabilityAttr(NamedDecl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK, int Priority, const IdentifierInfo *IIEnvironment, const IdentifierInfo *InferredPlatformII)
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.
void AddModeAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Name, bool InInstantiation=false)
AddModeAttr - Adds a mode attribute to a particular declaration.
ASTContext & getASTContext() const
void mergeVisibilityType(Decl *D, SourceLocation Loc, VisibilityAttr::VisibilityType Type)
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)
void addNoClusterAttr(Decl *D, const AttributeCommonInfo &CI)
Add a no_cluster attribute to a particular declaration.
FPOptions & getCurFPFeatures()
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
@ UPPC_Expression
An arbitrary expression.
const LangOptions & getLangOpts() const
ModularFormatAttr * mergeModularFormatAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *ModularImplFn, StringRef ImplName, MutableArrayRef< StringRef > Aspects)
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
CUDAClusterDimsAttr * createClusterDimsAttr(const AttributeCommonInfo &CI, Expr *X, Expr *Y, Expr *Z)
Add a cluster_dims attribute to a particular declaration.
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...
ExprResult DefaultLvalueConversion(Expr *E)
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.
void ActOnInitPriorityAttr(Decl *D, const Attr *A)
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
void ActOnCleanupAttr(Decl *D, const Attr *A)
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,...
FormatMatchesAttr * mergeFormatMatchesAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Format, int FormatIdx, StringLiteral *FormatStr)
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)
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
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)
bool checkInstantiatedThreadSafetyAttrs(const Decl *D, const Attr *A)
Recheck instantiated thread-safety attributes that could not be validated on the dependent pattern de...
CUDALaunchBoundsAttr * CreateLaunchBoundsAttr(const AttributeCommonInfo &CI, Expr *MaxThreads, Expr *MinBlocks, Expr *MaxBlocks, bool IgnoreArch=false)
Create a CUDALaunchBoundsAttr attribute.
void addClusterDimsAttr(Decl *D, const AttributeCommonInfo &CI, Expr *X, Expr *Y, Expr *Z)
@ AP_InferredFromAnyAppleOS
The availability attribute was inferred from an 'anyAppleOS' availability attribute.
@ 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_PragmaClangAttribute_InferredFromAnyAppleOS
The availability attribute was inferred from an 'anyAppleOS' availability attribute that was applied ...
@ 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)
DiagnosticsEngine & Diags
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,...
bool CheckSpanLikeType(const AttributeCommonInfo &CI, const QualType &Ty)
Check that the type is a plain record with one field being a pointer type and the other field being a...
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)
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.
FormatAttr * mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI, const IdentifierInfo *Format, int FormatIdx, int FirstArg)
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 getEnd() const
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.
LangOptions::SignReturnAddressScopeKind SignReturnAddr
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.
virtual bool hasFeatureEnabled(const llvm::StringMap< bool > &Features, StringRef Name) const
Check if target has a given feature enabled.
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.
virtual unsigned getRegisterWidth() const
Return the "preferred" register width on this target.
virtual bool validateCPUSpecificCPUDispatch(StringRef Name) const
virtual bool hasProtectedVisibility() const
Does this target support "protected" visibility?
virtual unsigned getUnwindWordWidth() const
unsigned getCharWidth() const
virtual bool shouldDLLImportComdatSymbols() const
Does this target aim for semantic compatibility with Microsoft C++ code using dllimport/export attrib...
const llvm::VersionTuple & getSDKVersion() const
std::string CPU
If given, the name of the target CPU to generate code for.
llvm::StringMap< bool > FeatureMap
The map of which features have been enabled disabled based on the command line.
The base class of all kinds of template declarations (e.g., class, function, etc.).
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.
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 isPointerOrReferenceType() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
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,...
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.
Enums for the diagnostics of target, target_version and target_clones.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
Top level wrappers for InstallAPI frontend operations.
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
void handleSimpleAttributeOrDiagnose(SemaBase &S, Decl *D, const AttributeCommonInfo &CI, bool PassesCheck, unsigned DiagID, DiagnosticArgs &&...ExtraArgs)
Add an attribute AttrType to declaration D, provided that PassesCheck is true.
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)
@ 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...
CudaVersion ToCudaVersion(llvm::VersionTuple)
SmallVector< Attr *, 4 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
bool checkAttrMutualExclusion(SemaBase &S, Decl *D, const ParsedAttr &AL)
Diagnose mutually exclusive attributes when present on a given declaration.
void inferNoReturnAttr(Sema &S, Decl *D)
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
@ Default
Set to the current date and time.
@ SD_Automatic
Automatic storage duration (most local variables).
bool isLambdaCallOperator(const CXXMethodDecl *MD)
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
@ 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.
const FunctionProtoType * T
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].
unsigned getFunctionOrMethodNumParams(const Decl *D, bool IncludeThis=false)
getFunctionOrMethodNumParams - Return number of function or method parameters, optionally including t...
SanitizerMask parseSanitizerValue(StringRef Value, bool AllowGroups)
Parse a single value from a -fsanitize= or -fno-sanitize= value list.
const char * OffloadArchToString(OffloadArch A)
void handleSimpleAttribute(SemaBase &S, Decl *D, const AttributeCommonInfo &CI)
Applies the given attribute to the Decl without performing any additional semantic checking.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
bool hasImplicitObjectParameter(const Decl *D)
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
MSInheritanceModel
Assigned inheritance model for a class in the MS C++ ABI.
bool hasFunctionProto(const Decl *D)
hasFunctionProto - Return true if the given decl has a argument information.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
DynamicRecursiveASTVisitorBase< false > DynamicRecursiveASTVisitor
@ 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
U cast(CodeGen::Address addr)
SourceRange getFunctionOrMethodParamRange(const Decl *D, unsigned Idx)
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
@ 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.
ActionResult< Expr * > ExprResult
@ Other
Other implicit parameter.
__builtin_bitreverse32 uint32_t __builtin_riscv_aaddu_u32 __builtin_riscv_asubu_u32 __builtin_elementwise_add_sat __builtin_elementwise_sub_sat int32_t
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.
SourceLocation KeywordLoc
The location of the keyword indicating the kind of change.
A value that describes two os-environment pairs that can be used as a key to the version map in the S...
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.
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
StringRef SignReturnAddrHardening
bool IncludeCXX11Attributes
bool IgnoreTypeAttributes