36 #include "llvm/ADT/STLExtras.h" 37 #include "llvm/ADT/StringExtras.h" 38 #include "llvm/Support/MathExtras.h" 40 using namespace clang;
72 return isa<DeclaratorDecl>(D) || isa<BlockDecl>(D) || isa<TypedefNameDecl>(D) ||
73 isa<ObjCPropertyDecl>(D);
81 return isa<FunctionProtoType>(FnTy);
82 return isa<ObjCMethodDecl>(D) || isa<BlockDecl>(D);
90 return cast<FunctionProtoType>(FnTy)->getNumParams();
91 if (
const auto *BD = dyn_cast<BlockDecl>(D))
92 return BD->getNumParams();
93 return cast<ObjCMethodDecl>(D)->param_size();
98 return cast<FunctionProtoType>(FnTy)->getParamType(Idx);
99 if (
const auto *BD = dyn_cast<BlockDecl>(D))
100 return BD->getParamDecl(Idx)->getType();
102 return cast<ObjCMethodDecl>(D)->parameters()[Idx]->getType();
106 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
107 return FD->getParamDecl(Idx)->getSourceRange();
108 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
109 return MD->parameters()[Idx]->getSourceRange();
110 if (
const auto *BD = dyn_cast<BlockDecl>(D))
111 return BD->getParamDecl(Idx)->getSourceRange();
117 return FnTy->getReturnType();
118 return cast<ObjCMethodDecl>(D)->getReturnType();
122 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
123 return FD->getReturnTypeSourceRange();
124 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
125 return MD->getReturnTypeSourceRange();
131 return cast<FunctionProtoType>(FnTy)->isVariadic();
132 if (
const auto *BD = dyn_cast<BlockDecl>(D))
133 return BD->isVariadic();
134 return cast<ObjCMethodDecl>(D)->isVariadic();
138 if (
const auto *MethodDecl = dyn_cast<CXXMethodDecl>(D))
139 return MethodDecl->isInstance();
155 return ClsName == &Ctx.
Idents.
get(
"NSString") ||
156 ClsName == &Ctx.
Idents.
get(
"NSMutableString");
180 template <
typename Compare>
182 unsigned Num,
unsigned Diag,
196 diag::err_attribute_wrong_number_arguments,
197 std::not_equal_to<unsigned>());
205 diag::err_attribute_too_few_arguments,
206 std::less<unsigned>());
214 diag::err_attribute_too_many_arguments,
215 std::greater<unsigned>());
220 template <
typename AttrInfo>
221 static typename std::enable_if<std::is_base_of<Attr, AttrInfo>::value,
224 return AL.getLocation();
230 template <
typename AttrInfo>
231 static typename std::enable_if<std::is_base_of<Attr, AttrInfo>::value,
242 template <
typename AttrInfo>
244 uint32_t &Val,
unsigned Idx =
UINT_MAX) {
261 << I.toString(10,
false) << 32 << 1;
265 Val = (uint32_t)I.getZExtValue();
272 template <
typename AttrInfo>
274 int &Val,
unsigned Idx =
UINT_MAX) {
283 << I.toString(10,
false) << 32 << 0;
293 template <
typename AttrTy>
296 if (
const auto *A = D->
getAttr<AttrTy>()) {
297 S.
Diag(Range.
getBegin(), diag::err_attributes_are_not_compatible) << Ident
299 S.
Diag(A->getLocation(), diag::note_conflicting_attribute);
309 template <
typename AttrInfo>
311 Sema &S,
const Decl *D,
const AttrInfo &AI,
unsigned AttrArgNum,
312 const Expr *IdxExpr,
ParamIdx &Idx,
bool CanIndexImplicitThis =
false) {
332 unsigned IdxSource = IdxInt.getLimitedValue(
UINT_MAX);
333 if (IdxSource < 1 || (!IV && IdxSource > NumParams)) {
334 S.
Diag(
getAttrLoc(AI), diag::err_attribute_argument_out_of_bounds)
338 if (HasImplicitThisParam && !CanIndexImplicitThis) {
339 if (IdxSource == 1) {
341 diag::err_attribute_invalid_implicit_this_argument)
361 Diag(Loc->
Loc, diag::err_attribute_argument_type)
367 *ArgLocation = Loc->
Loc;
377 if (!Literal || !Literal->isAscii()) {
383 Str = Literal->getString();
389 template <
typename AttrType>
395 template <
typename AttrType>
398 handleSimpleAttribute<AttrType>(S, D, AL);
403 template <
typename AttrType,
typename IncompatibleAttrType,
404 typename... IncompatibleAttrTypes>
407 if (checkAttrMutualExclusion<IncompatibleAttrType>(S, D, AL.
getRange(),
442 const auto *VD = cast<ValueDecl>(D);
444 if (QT->isAnyPointerType())
447 if (
const auto *RT = QT->getAs<
RecordType>()) {
451 if (RT->isIncompleteType())
458 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_decl_not_pointer)
493 if (RD->
hasAttr<CapabilityAttr>())
497 if (
const auto *CRD = dyn_cast<CXXRecordDecl>(RD)) {
500 const auto *Type = BS->getType()->getAs<RecordType>();
501 return Type->getDecl()->hasAttr<CapabilityAttr>();
517 return TN->
hasAttr<CapabilityAttr>();
536 if (
const auto *E = dyn_cast<CastExpr>(Ex))
538 else if (
const auto *E = dyn_cast<ParenExpr>(Ex))
540 else if (
const auto *E = dyn_cast<UnaryOperator>(Ex)) {
541 if (E->getOpcode() == UO_LNot || E->getOpcode() == UO_AddrOf ||
542 E->getOpcode() == UO_Deref)
545 }
else if (
const auto *E = dyn_cast<BinaryOperator>(Ex)) {
546 if (E->getOpcode() == BO_LAnd || E->getOpcode() == BO_LOr)
564 bool ParamIdxOk =
false) {
565 for (
unsigned Idx = Sidx; Idx < AL.
getNumArgs(); ++Idx) {
570 Args.push_back(ArgExp);
574 if (
const auto *StrLit = dyn_cast<StringLiteral>(ArgExp)) {
575 if (StrLit->getLength() == 0 ||
576 (StrLit->isAscii() && StrLit->getString() == StringRef(
"*"))) {
579 Args.push_back(ArgExp);
586 Args.push_back(ArgExp);
594 if (
const auto *UOp = dyn_cast<UnaryOperator>(ArgExp))
595 if (UOp->getOpcode() == UO_AddrOf)
596 if (
const auto *DRE = dyn_cast<DeclRefExpr>(UOp->getSubExpr()))
597 if (DRE->getDecl()->isCXXInstanceMember())
598 ArgTy = DRE->getDecl()->getType();
604 if(!RT && ParamIdxOk) {
608 unsigned int NumParams = FD->getNumParams();
609 llvm::APInt ArgValue = IL->
getValue();
610 uint64_t ParamIdxFromOne = ArgValue.getZExtValue();
611 uint64_t ParamIdxFromZero = ParamIdxFromOne - 1;
612 if (!ArgValue.isStrictlyPositive() || ParamIdxFromOne > NumParams) {
613 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_range)
614 << AL.
getName() << Idx + 1 << NumParams;
617 ArgTy = FD->getParamDecl(ParamIdxFromZero)->getType();
626 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_argument_not_lockable)
629 Args.push_back(ArgExp);
651 unsigned Size = Args.size();
687 QualType QT = cast<ValueDecl>(D)->getType();
689 S.
Diag(AL.
getLoc(), diag::warn_thread_attribute_decl_not_lockable)
707 Expr **StartArg = &Args[0];
718 Expr **StartArg = &Args[0];
738 unsigned Size = Args.size();
739 Expr **StartArg = Size == 0 ? nullptr : &Args[0];
751 unsigned Size = Args.size();
752 Expr **StartArg = Size == 0 ? nullptr : &Args[0];
763 template <
typename AttrInfo>
765 const AttrInfo &AI,
unsigned AttrArgNo) {
766 assert(AI.isArgExpr(AttrArgNo) &&
"Expected expression argument");
767 Expr *AttrArg = AI.getArgAsExpr(AttrArgNo);
776 S.
Diag(SrcLoc, diag::err_attribute_integers_only)
788 const auto *FD = cast<FunctionDecl>(D);
789 if (!FD->getReturnType()->isPointerType()) {
790 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only)
802 ParamIdx SizeArgNo(SizeArgNoVal, D);
827 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
864 unsigned Size = Args.size();
880 unsigned Size = Args.size();
883 Expr **StartArg = &Args[0];
891 Expr *&Cond, StringRef &Msg) {
897 Cond = Converted.
get();
904 Msg =
"<no message provided>";
910 S.
Diag(AL.
getLoc(), diag::err_attr_cond_never_constant_expr)
913 S.
Diag(PDiag.first, PDiag.second);
920 S.
Diag(AL.
getLoc(), diag::ext_clang_enable_if);
933 class ArgumentDependenceChecker
938 llvm::SmallPtrSet<const ParmVarDecl *, 16> Parms;
944 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD))
952 bool referencesArgs(
Expr *E) {
960 "`this` doesn't refer to the enclosing class?");
966 if (
const auto *PVD = dyn_cast<ParmVarDecl>(DRE->
getDecl()))
967 if (Parms.count(PVD)) {
977 S.
Diag(AL.
getLoc(), diag::ext_clang_diagnose_if);
984 StringRef DiagTypeStr;
988 DiagnoseIfAttr::DiagnosticType DiagType;
989 if (!DiagnoseIfAttr::ConvertStrToDiagnosticType(DiagTypeStr, DiagType)) {
991 diag::err_diagnose_if_invalid_diagnostic_type);
995 bool ArgDependent =
false;
996 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
997 ArgDependent = ArgumentDependenceChecker(FD).referencesArgs(Cond);
1004 if (D->
hasAttr<PassObjectSizeAttr>()) {
1028 if (!cast<ParmVarDecl>(D)->getType()->isPointerType()) {
1043 if (!ConsumableAttr::ConvertStrToConsumedState(IL->
Ident->
getName(),
1045 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported)
1050 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1066 if (!RD->hasAttr<ConsumableAttr>()) {
1067 S.
Diag(AL.
getLoc(), diag::warn_attr_on_unconsumable_class) <<
1068 RD->getNameAsString();
1085 for (
unsigned ArgIndex = 0; ArgIndex < AL.
getNumArgs(); ++ArgIndex) {
1088 StringRef StateString;
1099 if (!CallableWhenAttr::ConvertStrToConsumedState(StateString,
1101 S.
Diag(Loc, diag::warn_attribute_type_not_supported)
1102 << AL.
getName() << StateString;
1106 States.push_back(CallableState);
1121 if (!ParamTypestateAttr::ConvertStrToConsumedState(StateString,
1123 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported)
1124 << AL.
getName() << StateString;
1128 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type) <<
1155 if (!ReturnTypestateAttr::ConvertStrToConsumedState(IL->
Ident->
getName(),
1157 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported)
1162 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type) <<
1205 if (!SetTypestateAttr::ConvertStrToConsumedState(Param, NewState)) {
1206 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported)
1211 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type) <<
1229 if (!TestTypestateAttr::ConvertStrToConsumedState(Param, TestState)) {
1230 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported)
1235 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type) <<
1251 if (
auto *TD = dyn_cast<TagDecl>(D))
1254 else if (
auto *FD = dyn_cast<FieldDecl>(D)) {
1255 bool BitfieldByteAligned = (!FD->getType()->isDependentType() &&
1256 !FD->getType()->isIncompleteType() &&
1261 if (BitfieldByteAligned)
1263 S.
Diag(AL.
getLoc(), diag::warn_attribute_ignored_for_field_of_type)
1264 << AL.
getName() << FD->getType();
1266 FD->addAttr(::
new (S.
Context) PackedAttr(
1270 if (BitfieldByteAligned)
1271 S.
Diag(AL.
getLoc(), diag::warn_attribute_packed_for_bitfield);
1273 FD->addAttr(::
new (S.
Context) PackedAttr(
1285 if (
const auto *VD = dyn_cast<ObjCIvarDecl>(D)) {
1287 S.
Diag(AL.
getLoc(), diag::warn_iboutlet_object_type)
1288 << AL.
getName() << VD->getType() << 0;
1292 else if (
const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
1294 S.
Diag(AL.
getLoc(), diag::warn_iboutlet_object_type)
1295 << AL.
getName() << PD->getType() << 1;
1320 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments)
1336 S.
Diag(AL.
getLoc(), diag::err_iboutletcollection_type) <<
"NSObject";
1352 QT->
isBuiltinType() ? diag::err_iboutletcollection_builtintype
1353 : diag::err_iboutletcollection_type) << QT;
1373 if (UT && UT->getDecl()->hasAttr<TransparentUnionAttr>()) {
1375 for (
const auto *I : UD->
fields()) {
1389 bool isReturnValue =
false) {
1392 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only)
1393 << AL.
getName() << AttrParmRange << TypeRange;
1395 S.
Diag(AL.
getLoc(), diag::warn_attribute_pointers_only)
1396 << AL.
getName() << AttrParmRange << TypeRange << 0;
1404 for (
unsigned I = 0; I < AL.
getNumArgs(); ++I) {
1418 NonNullArgs.push_back(Idx);
1429 I != E && !AnyPointers; ++I) {
1436 S.
Diag(AL.
getLoc(), diag::warn_attribute_nonnull_no_pointers);
1439 ParamIdx *Start = NonNullArgs.data();
1440 unsigned Size = NonNullArgs.size();
1441 llvm::array_pod_sort(Start, Start + Size);
1453 S.
Diag(AL.
getLoc(), diag::warn_attribute_nonnull_parm_no_args)
1486 QualType T = cast<ParmVarDecl>(D)->getType();
1488 S.
Diag(AL.
getLoc(), diag::warn_attribute_pointers_only)
1510 Expr *OE,
unsigned SpellingListIndex) {
1514 AssumeAlignedAttr TmpAttr(AttrRange, Context, E, OE, SpellingListIndex);
1517 if (!isValidPointerAttrType(ResultType,
true)) {
1518 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
1519 << &TmpAttr << AttrRange << SR;
1527 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1531 Diag(AttrLoc, diag::err_attribute_argument_type)
1537 if (!I.isPowerOf2()) {
1538 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
1548 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1557 AssumeAlignedAttr(AttrRange, Context, E, OE, SpellingListIndex));
1561 unsigned SpellingListIndex) {
1564 AllocAlignAttr TmpAttr(AttrRange, Context,
ParamIdx(), SpellingListIndex);
1568 !isValidPointerAttrType(ResultType,
true)) {
1569 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
1575 const auto *FuncDecl = cast<FunctionDecl>(D);
1589 AllocAlignAttr(AttrRange, Context, Idx, SpellingListIndex));
1595 if (AttrName.size() > 4 && AttrName.startswith(
"__") &&
1596 AttrName.endswith(
"__")) {
1597 AttrName = AttrName.drop_front(2).drop_back(2);
1613 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
1619 OwnershipAttr::OwnershipKind K =
1625 case OwnershipAttr::Takes:
1626 case OwnershipAttr::Holds:
1628 S.
Diag(AL.
getLoc(), diag::err_attribute_too_few_arguments)
1633 case OwnershipAttr::Returns:
1635 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments)
1644 StringRef ModuleName = Module->
getName();
1650 for (
unsigned i = 1; i < AL.
getNumArgs(); ++i) {
1660 case OwnershipAttr::Takes:
1661 case OwnershipAttr::Holds:
1665 case OwnershipAttr::Returns:
1680 if (I->getOwnKind() != K && I->args_end() !=
1681 std::find(I->args_begin(), I->args_end(), Idx)) {
1682 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
1685 }
else if (K == OwnershipAttr::Returns &&
1686 I->getOwnKind() == OwnershipAttr::Returns) {
1689 if (std::find(I->args_begin(), I->args_end(), Idx) == I->args_end()) {
1690 S.
Diag(I->getLocation(), diag::err_ownership_returns_index_mismatch)
1691 << I->args_begin()->getSourceIndex();
1693 S.
Diag(AL.
getLoc(), diag::note_ownership_returns_index_mismatch)
1699 OwnershipArgs.push_back(Idx);
1702 ParamIdx *Start = OwnershipArgs.data();
1703 unsigned Size = OwnershipArgs.size();
1704 llvm::array_pod_sort(Start, Start + Size);
1713 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments)
1730 S.
Diag(AL.
getLoc(), diag::err_attribute_weakref_not_global_context)
1731 << cast<NamedDecl>(D);
1778 const auto *FD = cast<FunctionDecl>(D);
1779 if (FD->isThisDeclarationADefinition()) {
1780 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << FD << 1;
1794 S.
Diag(AL.
getLoc(), diag::err_alias_not_supported_on_darwin);
1798 S.
Diag(AL.
getLoc(), diag::err_alias_not_supported_on_nvptx);
1802 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
1803 if (FD->isThisDeclarationADefinition()) {
1804 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << FD << 0;
1808 const auto *VD = cast<VarDecl>(D);
1809 if (VD->isThisDeclarationADefinition() && VD->isExternallyVisible()) {
1810 S.
Diag(AL.
getLoc(), diag::err_alias_is_definition) << VD << 0;
1829 if (Model !=
"global-dynamic" && Model !=
"local-dynamic" 1830 && Model !=
"initial-exec" && Model !=
"local-exec") {
1831 S.
Diag(LiteralLoc, diag::err_attr_tlsmodel_arg);
1848 S.
Diag(AL.
getLoc(), diag::warn_attribute_return_pointers_only)
1860 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
1869 S.
Diag(CPUArg->
Loc, diag::err_invalid_cpu_specific_dispatch_value)
1870 << CPUName << (AL.
getKind() == ParsedAttr::AT_CPUDispatch);
1875 if (llvm::any_of(CPUs, [CPUName, &Target](
const IdentifierInfo *Cur) {
1879 S.
Diag(AL.
getLoc(), diag::warn_multiversion_duplicate_entries);
1882 CPUs.push_back(CPUArg->
Ident);
1886 if (AL.
getKind() == ParsedAttr::AT_CPUSpecific)
1898 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
1909 if (checkAttrMutualExclusion<DisableTailCallsAttr>(S, D, AL.
getRange(),
1915 const auto &Arch = Triple.getArch();
1916 if (Arch != llvm::Triple::x86 &&
1917 (Arch != llvm::Triple::arm && Arch != llvm::Triple::thumb)) {
1918 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_on_arch)
1919 << AL.
getName() << Triple.getArchName();
1931 if (!isa<ObjCMethodDecl>(D)) {
1932 S.
Diag(Attrs.
getLoc(), diag::warn_attribute_wrong_decl_type)
1943 S.
Diag(Attrs.
getLoc(), diag::warn_nocf_check_attribute_ignored);
1945 handleSimpleAttribute<AnyX86NoCfCheckAttr>(S, D, Attrs);
1978 : diag::warn_attribute_wrong_decl_type)
2015 if (VecReturnAttr *A = D->
getAttr<VecReturnAttr>()) {
2016 S.
Diag(AL.
getLoc(), diag::err_repeat_attribute) << A;
2020 const auto *R = cast<RecordDecl>(D);
2023 if (!isa<CXXRecordDecl>(R)) {
2024 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
2028 if (!cast<CXXRecordDecl>(R)->isPOD()) {
2029 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_pod_record);
2033 for (
const auto *I : R->fields()) {
2034 if ((count == 1) || !I->getType()->isVectorType()) {
2035 S.
Diag(AL.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
2047 if (isa<ParmVarDecl>(D)) {
2052 diag::err_carries_dependency_param_not_function_decl);
2075 uint32_t priority = ConstructorAttr::DefaultPriority;
2086 uint32_t priority = DestructorAttr::DefaultPriority;
2096 template <
typename AttrTy>
2109 if (!cast<ObjCProtocolDecl>(D)->isThisDeclarationADefinition()) {
2110 S.
Diag(AL.
getLoc(), diag::err_objc_attr_protocol_requires_definition)
2122 VersionTuple Introduced,
2123 VersionTuple Deprecated,
2124 VersionTuple Obsoleted) {
2125 StringRef PlatformName
2126 = AvailabilityAttr::getPrettyPlatformName(Platform->
getName());
2127 if (PlatformName.empty())
2128 PlatformName = Platform->
getName();
2132 if (!Introduced.empty() && !Deprecated.empty() &&
2133 !(Introduced <= Deprecated)) {
2134 S.
Diag(Range.
getBegin(), diag::warn_availability_version_ordering)
2135 << 1 << PlatformName << Deprecated.getAsString()
2136 << 0 << Introduced.getAsString();
2140 if (!Introduced.empty() && !Obsoleted.empty() &&
2141 !(Introduced <= Obsoleted)) {
2142 S.
Diag(Range.
getBegin(), diag::warn_availability_version_ordering)
2143 << 2 << PlatformName << Obsoleted.getAsString()
2144 << 0 << Introduced.getAsString();
2148 if (!Deprecated.empty() && !Obsoleted.empty() &&
2149 !(Deprecated <= Obsoleted)) {
2150 S.
Diag(Range.
getBegin(), diag::warn_availability_version_ordering)
2151 << 2 << PlatformName << Obsoleted.getAsString()
2152 << 1 << Deprecated.getAsString();
2164 bool BeforeIsOkay) {
2165 if (X.empty() || Y.empty())
2171 if (BeforeIsOkay && X < Y)
2180 VersionTuple Introduced,
2181 VersionTuple Deprecated,
2182 VersionTuple Obsoleted,
2188 unsigned AttrSpellingListIndex) {
2189 VersionTuple MergedIntroduced = Introduced;
2190 VersionTuple MergedDeprecated = Deprecated;
2191 VersionTuple MergedObsoleted = Obsoleted;
2192 bool FoundAny =
false;
2193 bool OverrideOrImpl =
false;
2196 case AMK_Redeclaration:
2197 OverrideOrImpl =
false;
2201 case AMK_ProtocolImplementation:
2202 OverrideOrImpl =
true;
2208 for (
unsigned i = 0, e = Attrs.size(); i != e;) {
2209 const auto *OldAA = dyn_cast<AvailabilityAttr>(Attrs[i]);
2216 if (OldPlatform != Platform) {
2224 if (!OldAA->isImplicit() && Implicit) {
2231 if (!Implicit && OldAA->isImplicit()) {
2232 Attrs.erase(Attrs.begin() + i);
2238 VersionTuple OldIntroduced = OldAA->getIntroduced();
2239 VersionTuple OldDeprecated = OldAA->getDeprecated();
2240 VersionTuple OldObsoleted = OldAA->getObsoleted();
2241 bool OldIsUnavailable = OldAA->getUnavailable();
2243 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl) ||
2244 !
versionsMatch(Deprecated, OldDeprecated, OverrideOrImpl) ||
2246 !(OldIsUnavailable == IsUnavailable ||
2247 (OverrideOrImpl && !OldIsUnavailable && IsUnavailable))) {
2248 if (OverrideOrImpl) {
2250 VersionTuple FirstVersion;
2251 VersionTuple SecondVersion;
2252 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl)) {
2254 FirstVersion = OldIntroduced;
2255 SecondVersion = Introduced;
2256 }
else if (!
versionsMatch(Deprecated, OldDeprecated, OverrideOrImpl)) {
2258 FirstVersion = Deprecated;
2259 SecondVersion = OldDeprecated;
2260 }
else if (!
versionsMatch(Obsoleted, OldObsoleted, OverrideOrImpl)) {
2262 FirstVersion = Obsoleted;
2263 SecondVersion = OldObsoleted;
2267 Diag(OldAA->getLocation(),
2268 diag::warn_mismatched_availability_override_unavail)
2269 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2270 << (AMK == AMK_Override);
2272 Diag(OldAA->getLocation(),
2273 diag::warn_mismatched_availability_override)
2275 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2276 << FirstVersion.getAsString() << SecondVersion.getAsString()
2277 << (AMK == AMK_Override);
2279 if (AMK == AMK_Override)
2284 Diag(OldAA->getLocation(), diag::warn_mismatched_availability);
2288 Attrs.erase(Attrs.begin() + i);
2293 VersionTuple MergedIntroduced2 = MergedIntroduced;
2294 VersionTuple MergedDeprecated2 = MergedDeprecated;
2295 VersionTuple MergedObsoleted2 = MergedObsoleted;
2297 if (MergedIntroduced2.empty())
2298 MergedIntroduced2 = OldIntroduced;
2299 if (MergedDeprecated2.empty())
2300 MergedDeprecated2 = OldDeprecated;
2301 if (MergedObsoleted2.empty())
2302 MergedObsoleted2 = OldObsoleted;
2305 MergedIntroduced2, MergedDeprecated2,
2306 MergedObsoleted2)) {
2307 Attrs.erase(Attrs.begin() + i);
2312 MergedIntroduced = MergedIntroduced2;
2313 MergedDeprecated = MergedDeprecated2;
2314 MergedObsoleted = MergedObsoleted2;
2320 MergedIntroduced == Introduced &&
2321 MergedDeprecated == Deprecated &&
2322 MergedObsoleted == Obsoleted)
2328 MergedDeprecated, MergedObsoleted) &&
2330 auto *Avail = ::new (Context) AvailabilityAttr(Range, Context, Platform,
2331 Introduced, Deprecated,
2332 Obsoleted, IsUnavailable, Message,
2333 IsStrict, Replacement,
2334 AttrSpellingListIndex);
2335 Avail->setImplicit(Implicit);
2348 if (AvailabilityAttr::getPrettyPlatformName(II->
getName()).empty())
2349 S.
Diag(Platform->
Loc, diag::warn_availability_unknown_platform)
2362 if (
const auto *SE = dyn_cast_or_null<StringLiteral>(AL.
getMessageExpr()))
2363 Str = SE->getString();
2366 Replacement = SE->getString();
2386 else if (II->
getName() ==
"ios_app_extension")
2390 auto adjustWatchOSVersion = [](VersionTuple Version) -> VersionTuple {
2391 if (Version.empty())
2393 auto Major = Version.getMajor();
2394 auto NewMajor = Major >= 9 ? Major - 7 : 0;
2395 if (NewMajor >= 2) {
2396 if (Version.getMinor().hasValue()) {
2397 if (Version.getSubminor().hasValue())
2398 return VersionTuple(NewMajor, Version.getMinor().getValue(),
2399 Version.getSubminor().getValue());
2401 return VersionTuple(NewMajor, Version.getMinor().getValue());
2405 return VersionTuple(2, 0);
2408 auto NewIntroduced = adjustWatchOSVersion(Introduced.
Version);
2409 auto NewDeprecated = adjustWatchOSVersion(Deprecated.
Version);
2410 auto NewObsoleted = adjustWatchOSVersion(Obsoleted.
Version);
2433 else if (II->
getName() ==
"ios_app_extension")
2460 "Invalid number of arguments in an external_source_symbol attribute");
2463 if (
const auto *SE = dyn_cast_or_null<StringLiteral>(AL.
getArgAsExpr(0)))
2464 Language = SE->getString();
2465 StringRef DefinedIn;
2466 if (
const auto *SE = dyn_cast_or_null<StringLiteral>(AL.
getArgAsExpr(1)))
2467 DefinedIn = SE->getString();
2468 bool IsGeneratedDeclaration = AL.
getArgAsIdent(2) !=
nullptr;
2471 AL.
getRange(), S.
Context, Language, DefinedIn, IsGeneratedDeclaration,
2477 typename T::VisibilityType value,
2478 unsigned attrSpellingListIndex) {
2479 T *existingAttr = D->
getAttr<T>();
2481 typename T::VisibilityType existingValue = existingAttr->getVisibility();
2482 if (existingValue == value)
2484 S.
Diag(existingAttr->getLocation(), diag::err_mismatched_visibility);
2485 S.
Diag(range.
getBegin(), diag::note_previous_attribute);
2488 return ::new (S.
Context) T(range, S.
Context, value, attrSpellingListIndex);
2492 VisibilityAttr::VisibilityType Vis,
2493 unsigned AttrSpellingListIndex) {
2494 return ::mergeVisibilityAttr<VisibilityAttr>(*
this, D, Range, Vis,
2495 AttrSpellingListIndex);
2499 TypeVisibilityAttr::VisibilityType Vis,
2500 unsigned AttrSpellingListIndex) {
2501 return ::mergeVisibilityAttr<TypeVisibilityAttr>(*
this, D, Range, Vis,
2502 AttrSpellingListIndex);
2506 bool isTypeVisibility) {
2508 if (isa<TypedefNameDecl>(D)) {
2515 if (isTypeVisibility &&
2516 !(isa<TagDecl>(D) ||
2517 isa<ObjCInterfaceDecl>(D) ||
2518 isa<NamespaceDecl>(D))) {
2530 VisibilityAttr::VisibilityType
type;
2531 if (!VisibilityAttr::ConvertStrToVisibilityType(TypeStr, type)) {
2532 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported)
2539 if (type == VisibilityAttr::Protected &&
2541 S.
Diag(AL.
getLoc(), diag::warn_attribute_protected_visibility);
2547 if (isTypeVisibility) {
2549 (TypeVisibilityAttr::VisibilityType) type,
2559 const auto *M = cast<ObjCMethodDecl>(D);
2561 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
2567 ObjCMethodFamilyAttr::FamilyKind F;
2568 if (!ObjCMethodFamilyAttr::ConvertStrToFamilyKind(IL->
Ident->
getName(), F)) {
2569 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported)
2575 !M->getReturnType()->isObjCObjectPointerType()) {
2576 S.
Diag(M->getLocation(), diag::err_init_method_bad_return_type)
2577 << M->getReturnType();
2587 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
2588 QualType T = TD->getUnderlyingType();
2590 S.
Diag(TD->getLocation(), diag::err_nsobject_attribute);
2594 else if (
const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
2597 S.
Diag(PD->getLocation(), diag::err_nsobject_attribute);
2616 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
2617 QualType T = TD->getUnderlyingType();
2619 S.
Diag(TD->getLocation(), diag::warn_ptr_independentclass_attribute);
2633 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
2639 BlocksAttr::BlockType
type;
2640 if (!BlocksAttr::ConvertStrToBlockType(II->
getName(),
type)) {
2641 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
2652 unsigned sentinel = (unsigned)SentinelAttr::DefaultSentinel;
2655 llvm::APSInt Idx(32);
2658 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
2664 if (Idx.isSigned() && Idx.isNegative()) {
2665 S.
Diag(AL.
getLoc(), diag::err_attribute_sentinel_less_than_zero)
2670 sentinel = Idx.getZExtValue();
2673 unsigned nullPos = (unsigned)SentinelAttr::DefaultNullPos;
2676 llvm::APSInt Idx(32);
2679 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
2684 nullPos = Idx.getZExtValue();
2686 if ((Idx.isSigned() && Idx.isNegative()) || nullPos > 1) {
2689 S.
Diag(AL.
getLoc(), diag::err_attribute_sentinel_not_zero_or_one)
2695 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
2697 if (isa<FunctionNoProtoType>(FT)) {
2698 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_named_arguments);
2702 if (!cast<FunctionProtoType>(FT)->isVariadic()) {
2703 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
2706 }
else if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
2707 if (!MD->isVariadic()) {
2708 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
2711 }
else if (
const auto *BD = dyn_cast<BlockDecl>(D)) {
2712 if (!BD->isVariadic()) {
2713 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 1;
2716 }
else if (
const auto *V = dyn_cast<VarDecl>(D)) {
2722 if (!cast<FunctionProtoType>(FT)->isVariadic()) {
2724 S.
Diag(AL.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << m;
2728 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
2733 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
2745 S.
Diag(AL.
getLoc(), diag::warn_attribute_void_function_method)
2749 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
2750 if (MD->getReturnType()->isVoidType()) {
2751 S.
Diag(AL.
getLoc(), diag::warn_attribute_void_function_method)
2772 S.
Diag(AL.
getLoc(), diag::warn_attribute_invalid_on_definition)
2774 else if (isa<ObjCPropertyDecl>(D) || isa<ObjCMethodDecl>(D) ||
2776 (isa<ObjCInterfaceDecl>(D) || isa<EnumDecl>(D)))) {
2779 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
2791 template <
typename WorkGroupAttr>
2794 for (
unsigned i = 0; i < 3; ++i) {
2798 if (WGSize[i] == 0) {
2799 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_is_zero)
2805 WorkGroupAttr *Existing = D->
getAttr<WorkGroupAttr>();
2806 if (Existing && !(Existing->getXDim() == WGSize[0] &&
2807 Existing->getYDim() == WGSize[1] &&
2808 Existing->getZDim() == WGSize[2]))
2812 WGSize[0], WGSize[1], WGSize[2],
2823 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_is_zero)
2828 OpenCLIntelReqdSubGroupSizeAttr *Existing =
2829 D->
getAttr<OpenCLIntelReqdSubGroupSizeAttr>();
2830 if (Existing && Existing->getSubGroupSize() != SGSize)
2840 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments)
2847 assert(ParmTSI &&
"no type source info for attribute argument");
2852 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_vec_type_hint)
2857 if (VecTypeHintAttr *A = D->
getAttr<VecTypeHintAttr>()) {
2871 unsigned AttrSpellingListIndex) {
2874 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
2875 if (AttrSpellingListIndex == SectionAttr::Declspec_allocate &&
2876 FD->isFunctionTemplateSpecialization())
2879 if (SectionAttr *ExistingAttr = D->
getAttr<SectionAttr>()) {
2880 if (ExistingAttr->getName() == Name)
2882 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section)
2887 return ::new (Context) SectionAttr(Range, Context, Name,
2888 AttrSpellingListIndex);
2893 if (!Error.empty()) {
2894 Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target) << Error
2914 if (!Error.empty()) {
2915 S.
Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
2928 if (!Error.empty()) {
2929 S.
Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target) << Error
2938 unsigned AttrSpellingListIndex) {
2941 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
2942 if (FD->isFunctionTemplateSpecialization())
2945 if (
const auto *ExistingAttr = D->
getAttr<CodeSegAttr>()) {
2946 if (ExistingAttr->getName() == Name)
2948 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section)
2953 return ::new (Context) CodeSegAttr(Range, Context, Name,
2954 AttrSpellingListIndex);
2964 if (
const auto *ExistingAttr = D->
getAttr<CodeSegAttr>()) {
2965 if (!ExistingAttr->isImplicit()) {
2967 ExistingAttr->getName() == Str
2968 ? diag::warn_duplicate_codeseg_attribute
2969 : diag::err_conflicting_codeseg_attribute);
2983 enum SecondParam { None, Architecture };
2984 for (
auto Str : {
"tune=",
"fpmath="})
2985 if (AttrStr.find(Str) != StringRef::npos)
2986 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
2989 TargetAttr::ParsedTargetAttr ParsedAttrs = TargetAttr::parse(AttrStr);
2991 if (!ParsedAttrs.Architecture.empty() &&
2993 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
2994 <<
Unsupported << Architecture << ParsedAttrs.Architecture;
2996 if (ParsedAttrs.DuplicateArchitecture)
2997 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
2998 << Duplicate << None <<
"arch=";
3000 for (
const auto &Feature : ParsedAttrs.Features) {
3001 auto CurFeature = StringRef(Feature).drop_front();
3003 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3018 TargetAttr *NewAttr =
3031 MinVectorWidthAttr *Existing = D->
getAttr<MinVectorWidthAttr>();
3032 if (Existing && Existing->getVectorWidth() != VecWidth) {
3050 if (
auto *DRE = dyn_cast<DeclRefExpr>(E)) {
3051 if (DRE->hasQualifier())
3052 S.
Diag(Loc, diag::warn_cleanup_ext);
3054 NI = DRE->getNameInfo();
3056 S.
Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 1
3060 }
else if (
auto *ULE = dyn_cast<UnresolvedLookupExpr>(E)) {
3061 if (ULE->hasExplicitTemplateArgs())
3062 S.
Diag(Loc, diag::warn_cleanup_ext);
3064 NI = ULE->getNameInfo();
3066 S.
Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 2
3073 S.
Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 0;
3078 S.
Diag(Loc, diag::err_attribute_cleanup_func_must_take_one_arg)
3089 S.
Diag(Loc, diag::err_attribute_cleanup_func_arg_incompatible_type)
3090 << NI.
getName() << ParamTy << Ty;
3102 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3109 if (!EnumExtensibilityAttr::ConvertStrToKind(II->
getName(),
3110 ExtensibilityKind)) {
3111 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
3133 if (NotNSStringTy &&
3137 S.
Diag(AL.
getLoc(), diag::err_format_attribute_not)
3147 S.
Diag(AL.
getLoc(), diag::err_format_attribute_result_not)
3148 << (NotNSStringTy ?
"string type" :
"NSString")
3169 return llvm::StringSwitch<FormatAttrKind>(Format)
3183 .Cases(
"gcc_diag",
"gcc_cdiag",
"gcc_cxxdiag",
"gcc_tdiag",
IgnoredFormat)
3196 S.
Diag(AL.
getLoc(), diag::err_init_priority_object_attr);
3200 QualType T = cast<VarDecl>(D)->getType();
3204 S.
Diag(AL.
getLoc(), diag::err_init_priority_object_attr);
3210 uint32_t prioritynum;
3216 if (prioritynum < 101 || prioritynum > 65535) {
3217 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_outof_range)
3230 unsigned AttrSpellingListIndex) {
3233 if (F->getType() == Format &&
3234 F->getFormatIdx() == FormatIdx &&
3235 F->getFirstArg() == FirstArg) {
3238 if (F->getLocation().isInvalid())
3244 return ::new (Context) FormatAttr(Range, Context, Format, FormatIdx,
3245 FirstArg, AttrSpellingListIndex);
3252 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
3263 StringRef Format = II->
getName();
3277 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
3288 if (Idx < 1 || Idx > NumArgs) {
3289 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
3295 unsigned ArgIdx = Idx - 1;
3297 if (HasImplicitThisParam) {
3300 diag::err_format_attribute_implicit_this_format_string)
3312 S.
Diag(AL.
getLoc(), diag::err_format_attribute_not)
3321 S.
Diag(AL.
getLoc(), diag::err_format_attribute_not)
3328 S.
Diag(AL.
getLoc(), diag::err_format_attribute_not)
3341 if (FirstArg != 0) {
3345 S.
Diag(D->
getLocation(), diag::err_format_attribute_requires_variadic);
3353 if (FirstArg != 0) {
3354 S.
Diag(AL.
getLoc(), diag::err_format_strftime_third_parameter)
3359 }
else if (FirstArg != 0 && FirstArg != NumArgs) {
3360 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
3376 if (TD && TD->getUnderlyingType()->isUnionType())
3377 RD = TD->getUnderlyingType()->getAsUnionType()->getDecl();
3382 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
3390 diag::warn_transparent_union_attribute_not_definition);
3396 if (Field == FieldEnd) {
3397 S.
Diag(AL.
getLoc(), diag::warn_transparent_union_attribute_zero_fields);
3405 diag::warn_transparent_union_attribute_floating)
3414 for (; Field != FieldEnd; ++Field) {
3415 QualType FieldType = Field->getType();
3429 S.
Diag(Field->getLocation(),
3430 diag::warn_transparent_union_attribute_field_size_align)
3431 << isSize << Field->getDeclName() << FieldBits;
3432 unsigned FirstBits = isSize? FirstSize : FirstAlign;
3434 diag::note_transparent_union_first_field_size_align)
3435 << isSize << FirstBits;
3454 if (I->getAnnotation() == Str)
3469 unsigned SpellingListIndex) {
3470 AlignValueAttr TmpAttr(AttrRange, Context, E, SpellingListIndex);
3474 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D))
3475 T = TD->getUnderlyingType();
3476 else if (
const auto *VD = dyn_cast<ValueDecl>(D))
3479 llvm_unreachable(
"Unknown decl type for align_value");
3483 Diag(AttrLoc, diag::warn_attribute_pointer_or_reference_only)
3489 llvm::APSInt Alignment;
3491 = VerifyIntegerConstantExpression(E, &Alignment,
3492 diag::err_align_value_attribute_argument_not_int,
3497 if (!Alignment.isPowerOf2()) {
3498 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
3504 AlignValueAttr(AttrRange, Context, ICE.
get(),
3505 SpellingListIndex));
3510 D->
addAttr(::
new (Context) AlignValueAttr(TmpAttr));
3516 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_number_arguments)
3530 diag::err_pack_expansion_without_parameter_packs);
3542 unsigned SpellingListIndex,
bool IsPackExpansion) {
3543 AlignedAttr TmpAttr(AttrRange, Context,
true, E, SpellingListIndex);
3547 if (TmpAttr.isAlignas()) {
3560 if (isa<ParmVarDecl>(D)) {
3562 }
else if (
const auto *VD = dyn_cast<VarDecl>(D)) {
3565 if (VD->isExceptionVariable())
3567 }
else if (
const auto *FD = dyn_cast<FieldDecl>(D)) {
3568 if (FD->isBitField())
3570 }
else if (!isa<TagDecl>(D)) {
3571 Diag(AttrLoc, diag::err_attribute_wrong_decl_type) << &TmpAttr
3576 if (DiagKind != -1) {
3577 Diag(AttrLoc, diag::err_alignas_attribute_wrong_decl_type)
3578 << &TmpAttr << DiagKind;
3587 if (
const auto *TND = dyn_cast<TypedefNameDecl>(D)) {
3588 if (!TND->getUnderlyingType()->isDependentType()) {
3589 Diag(AttrLoc, diag::err_alignment_dependent_typedef_name)
3596 AlignedAttr *AA = ::new (Context) AlignedAttr(TmpAttr);
3597 AA->setPackExpansion(IsPackExpansion);
3603 llvm::APSInt Alignment;
3605 = VerifyIntegerConstantExpression(E, &Alignment,
3606 diag::err_aligned_attribute_argument_not_int,
3611 uint64_t AlignVal = Alignment.getZExtValue();
3618 if (!(TmpAttr.isAlignas() && !Alignment)) {
3619 if (!llvm::isPowerOf2_64(AlignVal)) {
3620 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
3627 unsigned MaxValidAlignment =
3630 if (AlignVal > MaxValidAlignment) {
3631 Diag(AttrLoc, diag::err_attribute_aligned_too_great) << MaxValidAlignment
3637 unsigned MaxTLSAlign =
3640 const auto *VD = dyn_cast<
VarDecl>(D);
3641 if (MaxTLSAlign && AlignVal > MaxTLSAlign && VD &&
3643 Diag(VD->getLocation(), diag::err_tls_var_aligned_over_maximum)
3644 << (
unsigned)AlignVal << VD << MaxTLSAlign;
3649 AlignedAttr *AA = ::new (Context) AlignedAttr(AttrRange, Context,
true,
3650 ICE.
get(), SpellingListIndex);
3651 AA->setPackExpansion(IsPackExpansion);
3656 unsigned SpellingListIndex,
bool IsPackExpansion) {
3659 AlignedAttr *AA = ::new (Context) AlignedAttr(AttrRange, Context,
false, TS,
3661 AA->setPackExpansion(IsPackExpansion);
3666 assert(D->
hasAttrs() &&
"no attributes on decl");
3669 if (
const auto *VD = dyn_cast<ValueDecl>(D)) {
3670 UnderlyingTy = DiagTy = VD->getType();
3672 UnderlyingTy = DiagTy = Context.
getTagDeclType(cast<TagDecl>(D));
3673 if (
const auto *ED = dyn_cast<EnumDecl>(D))
3674 UnderlyingTy = ED->getIntegerType();
3676 if (DiagTy->isDependentType() || DiagTy->isIncompleteType())
3683 AlignedAttr *AlignasAttr =
nullptr;
3686 if (I->isAlignmentDependent())
3690 Align =
std::max(Align, I->getAlignment(Context));
3693 if (AlignasAttr && Align) {
3696 if (NaturalAlign > RequestedAlign)
3697 Diag(AlignasAttr->getLocation(), diag::err_alignas_underaligned)
3698 << DiagTy << (
unsigned)NaturalAlign.
getQuantity();
3704 MSInheritanceAttr::Spelling SemanticSpelling) {
3713 if (SemanticSpelling == MSInheritanceAttr::Keyword_unspecified_inheritance)
3724 Diag(Range.
getBegin(), diag::err_mismatched_ms_inheritance)
3734 bool &IntegerMode,
bool &ComplexMode) {
3736 ComplexMode =
false;
3737 switch (Str.size()) {
3759 if (Str[1] ==
'F') {
3760 IntegerMode =
false;
3761 }
else if (Str[1] ==
'C') {
3762 IntegerMode =
false;
3764 }
else if (Str[1] !=
'I') {
3773 else if (Str ==
"byte")
3777 if (Str ==
"pointer")
3781 if (Str ==
"unwind_word")
3808 unsigned SpellingListIndex,
bool InInstantiation) {
3809 StringRef Str = Name->
getName();
3813 unsigned DestWidth = 0;
3814 bool IntegerMode =
true;
3815 bool ComplexMode =
false;
3816 llvm::APInt VectorSize(64, 0);
3817 if (Str.size() >= 4 && Str[0] ==
'V') {
3819 size_t StrSize = Str.size();
3820 size_t VectorStringLength = 0;
3821 while ((VectorStringLength + 1) < StrSize &&
3822 isdigit(Str[VectorStringLength + 1]))
3823 ++VectorStringLength;
3824 if (VectorStringLength &&
3825 !Str.substr(1, VectorStringLength).getAsInteger(10, VectorSize) &&
3826 VectorSize.isPowerOf2()) {
3828 IntegerMode, ComplexMode);
3830 if (!InInstantiation)
3831 Diag(AttrLoc, diag::warn_vector_mode_deprecated);
3845 Diag(AttrLoc, diag::err_machine_mode) << 0 << Name;
3850 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D))
3851 OldTy = TD->getUnderlyingType();
3852 else if (
const auto *ED = dyn_cast<EnumDecl>(D)) {
3855 OldTy = ED->getIntegerType();
3857 OldTy = Context.
IntTy;
3859 OldTy = cast<ValueDecl>(D)->getType();
3863 ModeAttr(AttrRange, Context, Name, SpellingListIndex));
3871 OldElemTy = VT->getElementType();
3877 VectorSize.getBoolValue()) {
3878 Diag(AttrLoc, diag::err_enum_mode_vector_type) << Name << AttrRange;
3881 bool IntegralOrAnyEnumType =
3885 !IntegralOrAnyEnumType)
3886 Diag(AttrLoc, diag::err_mode_not_primitive);
3887 else if (IntegerMode) {
3888 if (!IntegralOrAnyEnumType)
3889 Diag(AttrLoc, diag::err_mode_wrong_type);
3890 }
else if (ComplexMode) {
3892 Diag(AttrLoc, diag::err_mode_wrong_type);
3895 Diag(AttrLoc, diag::err_mode_wrong_type);
3906 if (NewElemTy.
isNull()) {
3907 Diag(AttrLoc, diag::err_machine_mode) << 1 << Name;
3916 if (VectorSize.getBoolValue()) {
3917 NewTy = Context.
getVectorType(NewTy, VectorSize.getZExtValue(),
3922 Diag(AttrLoc, diag::err_complex_mode_vector_type);
3925 unsigned NumElements = Context.
getTypeSize(OldElemTy) *
3926 OldVT->getNumElements() /
3929 Context.
getVectorType(NewElemTy, NumElements, OldVT->getVectorKind());
3933 Diag(AttrLoc, diag::err_mode_wrong_type);
3938 if (
auto *TD = dyn_cast<TypedefNameDecl>(D))
3939 TD->setModedTypeSourceInfo(TD->getTypeSourceInfo(), NewTy);
3940 else if (
auto *ED = dyn_cast<EnumDecl>(D))
3941 ED->setIntegerType(NewTy);
3943 cast<ValueDecl>(D)->setType(NewTy);
3946 ModeAttr(AttrRange, Context, Name, SpellingListIndex));
3957 unsigned AttrSpellingListIndex) {
3958 if (OptimizeNoneAttr *Optnone = D->
getAttr<OptimizeNoneAttr>()) {
3959 Diag(Range.
getBegin(), diag::warn_attribute_ignored) << Ident;
3960 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
3964 if (D->
hasAttr<AlwaysInlineAttr>())
3967 return ::new (Context) AlwaysInlineAttr(Range, Context,
3968 AttrSpellingListIndex);
3973 unsigned AttrSpellingListIndex) {
3974 if (checkAttrMutualExclusion<InternalLinkageAttr>(*
this, D, Range, Ident))
3977 return ::new (Context) CommonAttr(Range, Context, AttrSpellingListIndex);
3980 InternalLinkageAttr *
3983 unsigned AttrSpellingListIndex) {
3984 if (
const auto *VD = dyn_cast<VarDecl>(D)) {
3987 if (VD->getKind() != Decl::Var) {
3988 Diag(Range.
getBegin(), diag::warn_attribute_wrong_decl_type)
3994 if (VD->hasLocalStorage()) {
3995 Diag(VD->getLocation(), diag::warn_internal_linkage_local_storage);
4000 if (checkAttrMutualExclusion<CommonAttr>(*
this, D, Range, Ident))
4003 return ::new (Context)
4004 InternalLinkageAttr(Range, Context, AttrSpellingListIndex);
4008 unsigned AttrSpellingListIndex) {
4009 if (OptimizeNoneAttr *Optnone = D->
getAttr<OptimizeNoneAttr>()) {
4010 Diag(Range.
getBegin(), diag::warn_attribute_ignored) <<
"'minsize'";
4011 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
4015 if (D->
hasAttr<MinSizeAttr>())
4018 return ::new (Context) MinSizeAttr(Range, Context, AttrSpellingListIndex);
4022 unsigned AttrSpellingListIndex) {
4023 if (AlwaysInlineAttr *Inline = D->
getAttr<AlwaysInlineAttr>()) {
4024 Diag(Inline->getLocation(), diag::warn_attribute_ignored) << Inline;
4025 Diag(Range.
getBegin(), diag::note_conflicting_attribute);
4028 if (MinSizeAttr *MinSize = D->
getAttr<MinSizeAttr>()) {
4029 Diag(MinSize->getLocation(), diag::warn_attribute_ignored) << MinSize;
4030 Diag(Range.
getBegin(), diag::note_conflicting_attribute);
4034 if (D->
hasAttr<OptimizeNoneAttr>())
4037 return ::new (Context) OptimizeNoneAttr(Range, Context,
4038 AttrSpellingListIndex);
4042 if (checkAttrMutualExclusion<NotTailCalledAttr>(S, D, AL.
getRange(),
4065 if (checkAttrMutualExclusion<CUDASharedAttr>(S, D, AL.
getRange(),
4068 const auto *VD = cast<VarDecl>(D);
4069 if (!VD->hasGlobalStorage()) {
4070 S.
Diag(AL.
getLoc(), diag::err_cuda_nonglobal_constant);
4078 if (checkAttrMutualExclusion<CUDAConstantAttr>(S, D, AL.
getRange(),
4081 const auto *VD = cast<VarDecl>(D);
4084 if (!S.
getLangOpts().CUDARelocatableDeviceCode && VD->hasExternalStorage() &&
4085 !isa<IncompleteArrayType>(VD->getType())) {
4086 S.
Diag(AL.
getLoc(), diag::err_cuda_extern_shared) << VD;
4089 if (S.
getLangOpts().CUDA && VD->hasLocalStorage() &&
4098 if (checkAttrMutualExclusion<CUDADeviceAttr>(S, D, AL.
getRange(),
4100 checkAttrMutualExclusion<CUDAHostAttr>(S, D, AL.
getRange(),
4104 const auto *FD = cast<FunctionDecl>(D);
4105 if (!FD->getReturnType()->isVoidType()) {
4106 SourceRange RTRange = FD->getReturnTypeSourceRange();
4107 S.
Diag(FD->getTypeSpecStartLoc(), diag::err_kern_type_not_void_return)
4113 if (
const auto *Method = dyn_cast<CXXMethodDecl>(FD)) {
4114 if (Method->isInstance()) {
4115 S.
Diag(Method->getLocStart(), diag::err_kern_is_nonstatic_method)
4119 S.
Diag(Method->getLocStart(), diag::warn_kern_is_method) << Method;
4122 if (FD->isInlineSpecified() && !S.
getLangOpts().CUDAIsDevice)
4123 S.
Diag(FD->getLocStart(), diag::warn_kern_is_inline) << FD;
4131 const auto *Fn = cast<FunctionDecl>(D);
4132 if (!Fn->isInlineSpecified()) {
4133 S.
Diag(AL.
getLoc(), diag::warn_gnu_inline_attribute_requires_inline);
4151 if (!isa<ObjCMethodDecl>(D)) {
4152 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
4158 case ParsedAttr::AT_FastCall:
4163 case ParsedAttr::AT_StdCall:
4168 case ParsedAttr::AT_ThisCall:
4173 case ParsedAttr::AT_CDecl:
4178 case ParsedAttr::AT_Pascal:
4183 case ParsedAttr::AT_SwiftCall:
4188 case ParsedAttr::AT_VectorCall:
4193 case ParsedAttr::AT_MSABI:
4198 case ParsedAttr::AT_SysVABI:
4203 case ParsedAttr::AT_RegCall:
4207 case ParsedAttr::AT_Pcs: {
4208 PcsAttr::PCSType PCS;
4211 PCS = PcsAttr::AAPCS;
4214 PCS = PcsAttr::AAPCS_VFP;
4217 llvm_unreachable(
"unexpected calling convention in pcs attribute");
4225 case ParsedAttr::AT_IntelOclBicc:
4230 case ParsedAttr::AT_PreserveMost:
4234 case ParsedAttr::AT_PreserveAll:
4239 llvm_unreachable(
"unexpected attribute kind");
4247 std::vector<StringRef> DiagnosticIdentifiers;
4248 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
4256 DiagnosticIdentifiers.push_back(RuleName);
4273 unsigned ReqArgs = Attrs.
getKind() == ParsedAttr::AT_Pcs ? 1 : 0;
4281 case ParsedAttr::AT_CDecl:
4284 case ParsedAttr::AT_FastCall:
4287 case ParsedAttr::AT_StdCall:
4290 case ParsedAttr::AT_ThisCall:
4293 case ParsedAttr::AT_Pascal:
4296 case ParsedAttr::AT_SwiftCall:
4299 case ParsedAttr::AT_VectorCall:
4302 case ParsedAttr::AT_RegCall:
4305 case ParsedAttr::AT_MSABI:
4309 case ParsedAttr::AT_SysVABI:
4313 case ParsedAttr::AT_Pcs: {
4315 if (!checkStringLiteralArgumentAttr(Attrs, 0, StrRef)) {
4319 if (StrRef ==
"aapcs") {
4322 }
else if (StrRef ==
"aapcs-vfp") {
4331 case ParsedAttr::AT_IntelOclBicc:
4334 case ParsedAttr::AT_PreserveMost:
4337 case ParsedAttr::AT_PreserveAll:
4340 default: llvm_unreachable(
"unexpected attribute kind");
4351 bool IsCXXMethod =
false, IsVariadic =
false;
4403 unsigned spellingIndex) {
4408 if (existingAttr->getABI() != abi) {
4409 Diag(range.
getBegin(), diag::err_attributes_are_not_compatible)
4411 Diag(existingAttr->getLocation(), diag::note_conflicting_attribute);
4418 llvm_unreachable(
"explicit attribute for ordinary parameter ABI?");
4422 Diag(range.
getBegin(), diag::err_swift_abi_parameter_wrong_type)
4427 SwiftContextAttr(range, Context, spellingIndex));
4432 Diag(range.
getBegin(), diag::err_swift_abi_parameter_wrong_type)
4437 SwiftErrorResultAttr(range, Context, spellingIndex));
4442 Diag(range.
getBegin(), diag::err_swift_abi_parameter_wrong_type)
4447 SwiftIndirectResultAttr(range, Context, spellingIndex));
4450 llvm_unreachable(
"bad parameter ABI attribute");
4472 Diag(AL.
getLoc(), diag::err_attribute_regparm_wrong_platform)
4480 Diag(AL.
getLoc(), diag::err_attribute_regparm_invalid_number)
4494 const CUDALaunchBoundsAttr &AL,
4495 const unsigned Idx) {
4511 if (!I.isIntN(32)) {
4512 S.
Diag(E->
getExprLoc(), diag::err_ice_too_large) << I.toString(10,
false)
4517 S.
Diag(E->
getExprLoc(), diag::warn_attribute_argument_n_negative)
4524 assert(!ValArg.isInvalid() &&
4525 "Unexpected PerformCopyInitialization() failure.");
4531 Expr *MinBlocks,
unsigned SpellingListIndex) {
4532 CUDALaunchBoundsAttr TmpAttr(AttrRange, Context, MaxThreads, MinBlocks,
4535 if (MaxThreads ==
nullptr)
4540 if (MinBlocks ==
nullptr)
4544 D->
addAttr(::
new (Context) CUDALaunchBoundsAttr(
4545 AttrRange, Context, MaxThreads, MinBlocks, SpellingListIndex));
4561 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
4576 bool IsPointer = AL.
getName()->
getName() ==
"pointer_with_type_tag";
4579 unsigned ArgumentIdxAST = ArgumentIdx.
getASTIndex();
4582 S.
Diag(AL.
getLoc(), diag::err_attribute_pointers_only)
4594 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
4602 if (!isa<VarDecl>(D)) {
4603 S.
Diag(AL.
getLoc(), diag::err_attribute_wrong_decl_type)
4611 assert(MatchingCTypeLoc &&
"no type source info for attribute argument");
4655 AL.
getKind() == ParsedAttr::AT_NSConsumed,
4660 unsigned SpellingIndex,
bool IsNSConsumed,
4661 bool IsTemplateInstantiation) {
4662 const auto *Param = cast<ParmVarDecl>(D);
4676 getLangOpts().ObjCAutoRefCount
4677 ? diag::err_ns_attribute_wrong_parameter_type
4678 : diag::warn_ns_attribute_wrong_parameter_type))
4679 << AttrRange << (IsNSConsumed ?
"ns_consumed" :
"cf_consumed")
4680 << (IsNSConsumed ? 0 : 1);
4686 NSConsumedAttr(AttrRange, Context, SpellingIndex));
4689 CFConsumedAttr(AttrRange, Context, SpellingIndex));
4696 Diag(Loc, diag::warn_ns_attribute_wrong_return_type)
4697 <<
"'ns_returns_retained'" << 0 << 0;
4705 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
4706 ReturnType = MD->getReturnType();
4708 (AL.
getKind() == ParsedAttr::AT_NSReturnsRetained))
4710 else if (
const auto *PD = dyn_cast<ObjCPropertyDecl>(D))
4711 ReturnType = PD->getType();
4712 else if (
const auto *FD = dyn_cast<FunctionDecl>(D))
4713 ReturnType = FD->getReturnType();
4714 else if (
const auto *Param = dyn_cast<ParmVarDecl>(D)) {
4716 if (ReturnType.
isNull()) {
4717 S.
Diag(D->
getLocStart(), diag::warn_ns_attribute_wrong_parameter_type)
4727 default: llvm_unreachable(
"invalid ownership attribute");
4728 case ParsedAttr::AT_NSReturnsRetained:
4729 case ParsedAttr::AT_NSReturnsAutoreleased:
4730 case ParsedAttr::AT_NSReturnsNotRetained:
4734 case ParsedAttr::AT_CFReturnsRetained:
4735 case ParsedAttr::AT_CFReturnsNotRetained:
4747 default: llvm_unreachable(
"invalid ownership attribute");
4748 case ParsedAttr::AT_NSReturnsRetained:
4753 case ParsedAttr::AT_NSReturnsAutoreleased:
4754 case ParsedAttr::AT_NSReturnsNotRetained:
4759 case ParsedAttr::AT_CFReturnsRetained:
4760 case ParsedAttr::AT_CFReturnsNotRetained:
4770 if (isa<ParmVarDecl>(D)) {
4771 S.
Diag(D->
getLocStart(), diag::warn_ns_attribute_wrong_parameter_type)
4780 } SubjectKind = Function;
4781 if (isa<ObjCMethodDecl>(D))
4782 SubjectKind = Method;
4783 else if (isa<ObjCPropertyDecl>(D))
4786 << AL.
getName() << SubjectKind << Cf
4794 llvm_unreachable(
"invalid ownership attribute");
4795 case ParsedAttr::AT_NSReturnsAutoreleased:
4799 case ParsedAttr::AT_CFReturnsNotRetained:
4803 case ParsedAttr::AT_NSReturnsNotRetained:
4807 case ParsedAttr::AT_CFReturnsRetained:
4811 case ParsedAttr::AT_NSReturnsRetained:
4820 const int EP_ObjCMethod = 1;
4821 const int EP_ObjCProperty = 2;
4825 if (isa<ObjCMethodDecl>(D))
4826 resultType = cast<ObjCMethodDecl>(D)->getReturnType();
4828 resultType = cast<ObjCPropertyDecl>(D)->getType();
4835 << (isa<ObjCMethodDecl>(D) ? EP_ObjCMethod : EP_ObjCProperty)
4848 const auto *Method = cast<ObjCMethodDecl>(D);
4851 if (
const auto *PDecl = dyn_cast_or_null<ObjCProtocolDecl>(DC)) {
4854 S.
Diag(PDecl->getLocation(), diag::note_protocol_decl);
4876 if (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
4878 S.
Diag(AL.
getLoc(), diag::err_objc_attr_typedef_not_id)
4884 QualType T = TD->getUnderlyingType();
4886 S.
Diag(AL.
getLoc(), diag::err_objc_attr_typedef_not_void_pointer);
4914 if (!RelatedClass) {
4924 ClassMethod, InstanceMethod,
4931 if (
auto *CatDecl = dyn_cast<ObjCCategoryDecl>(D->
getDeclContext()))
4932 IFace = CatDecl->getClassInterface();
4946 StringRef MetaDataName;
4960 bool notify =
false;
4963 if (RD && RD->getDefinition()) {
4969 ObjCBoxableAttr *BoxableAttr = ::new (S.
Context)
4977 L->AddedAttributeToRecord(BoxableAttr, RD);
4991 const auto *VD = cast<ValueDecl>(D);
4994 if (!QT->isDependentType() &&
4995 !QT->isObjCLifetimeType()) {
4996 S.
Diag(AL.
getLoc(), diag::err_objc_precise_lifetime_bad_type)
5006 Lifetime = QT->getObjCARCImplicitLifetime();
5010 assert(QT->isDependentType() &&
5011 "didn't infer lifetime for non-dependent type?");
5020 S.
Diag(AL.
getLoc(), diag::warn_objc_precise_lifetime_meaningless)
5035 unsigned AttrSpellingListIndex, StringRef Uuid) {
5036 if (
const auto *UA = D->
getAttr<UuidAttr>()) {
5037 if (UA->getGuid().equals_lower(Uuid))
5039 Diag(UA->getLocation(), diag::err_mismatched_uuid);
5044 return ::new (Context) UuidAttr(Range, Context, Uuid, AttrSpellingListIndex);
5049 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
5061 if (StrRef.size() == 38 && StrRef.front() ==
'{' && StrRef.back() ==
'}')
5062 StrRef = StrRef.drop_front().drop_back();
5065 if (StrRef.size() != 36) {
5066 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
5070 for (
unsigned i = 0; i < 36; ++i) {
5071 if (i == 8 || i == 13 || i == 18 || i == 23) {
5072 if (StrRef[i] !=
'-') {
5073 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
5077 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
5089 S.
Diag(AL.
getLoc(), diag::warn_atl_uuid_deprecated);
5099 S.
Diag(AL.
getLoc(), diag::err_attribute_not_supported_in_lang)
5114 const auto *VD = cast<VarDecl>(D);
5116 S.
Diag(AL.
getLoc(), diag::err_thread_unsupported);
5120 S.
Diag(AL.
getLoc(), diag::err_declspec_thread_on_thread_variable);
5123 if (VD->hasLocalStorage()) {
5124 S.
Diag(AL.
getLoc(), diag::err_thread_non_global) <<
"__declspec(thread)";
5133 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
5137 Tags.push_back(Tag);
5140 if (
const auto *NS = dyn_cast<NamespaceDecl>(D)) {
5141 if (!NS->isInline()) {
5142 S.
Diag(AL.
getLoc(), diag::warn_attr_abi_tag_namespace) << 0;
5145 if (NS->isAnonymousNamespace()) {
5146 S.
Diag(AL.
getLoc(), diag::warn_attr_abi_tag_namespace) << 1;
5150 Tags.push_back(NS->getName());
5155 llvm::sort(Tags.begin(), Tags.end());
5156 Tags.erase(std::unique(Tags.begin(), Tags.end()), Tags.end());
5166 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments)
5179 ARMInterruptAttr::InterruptType
Kind;
5180 if (!ARMInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
5181 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
5182 << AL.
getName() << Str << ArgLoc;
5204 llvm::APSInt NumParams(32);
5206 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_type)
5212 unsigned Num = NumParams.getLimitedValue(255);
5213 if ((Num & 1) || Num > 30) {
5214 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
5215 << AL.
getName() << (int)NumParams.getSExtValue()
5229 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments)
5269 if (checkAttrMutualExclusion<Mips16Attr>(S, D, AL.
getRange(),
5273 MipsInterruptAttr::InterruptType
Kind;
5274 if (!MipsInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
5275 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
5276 << AL.
getName() <<
"'" + std::string(Str) +
"'";
5293 cast<NamedDecl>(D)->getDeclName().getCXXOverloadedOperator())) {
5294 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
5301 diag::err_anyx86_interrupt_attribute)
5310 if (NumParams < 1 || NumParams > 2) {
5321 diag::err_anyx86_interrupt_attribute)
5333 if (NumParams == 2 &&
5337 diag::err_anyx86_interrupt_attribute)
5359 handleSimpleAttribute<AVRInterruptAttr>(S, D, AL);
5372 handleSimpleAttribute<AVRSignalAttr>(S, D, AL);
5379 if (
const auto *A = D->
getAttr<RISCVInterruptAttr>()) {
5381 diag::warn_riscv_repeated_interrupt_attribute);
5382 S.
Diag(A->getLocation(), diag::note_riscv_repeated_interrupt_attribute);
5422 RISCVInterruptAttr::InterruptType
Kind;
5423 if (!RISCVInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
5424 S.
Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
5425 << AL.
getName() << Str << ArgLoc;
5436 case llvm::Triple::msp430:
5439 case llvm::Triple::mipsel:
5440 case llvm::Triple::mips:
5443 case llvm::Triple::x86:
5444 case llvm::Triple::x86_64:
5447 case llvm::Triple::avr:
5450 case llvm::Triple::riscv32:
5451 case llvm::Triple::riscv64:
5472 if (Min == 0 && Max != 0) {
5473 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_invalid)
5478 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_invalid)
5484 AMDGPUFlatWorkGroupSizeAttr(AL.
getLoc(), S.
Context, Min, Max,
5501 if (Min == 0 && Max != 0) {
5502 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_invalid)
5506 if (Max != 0 && Min > Max) {
5507 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_invalid)
5518 uint32_t NumSGPR = 0;
5529 uint32_t NumVGPR = 0;
5544 const auto *VD = dyn_cast<
ValueDecl>(D);
5545 if (VD && VD->getType()->isFunctionPointerType())
5549 if (TD && (TD->getUnderlyingType()->isFunctionPointerType() ||
5550 TD->getUnderlyingType()->isFunctionType()))
5553 if (!isa<FunctionDecl>(D)) {
5554 S.
Diag(AL.
getLoc(), diag::warn_attribute_wrong_decl_type)
5572 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_out_of_bounds)
5583 unsigned AttrSpellingListIndex) {
5584 if (D->
hasAttr<DLLExportAttr>()) {
5585 Diag(Range.
getBegin(), diag::warn_attribute_ignored) <<
"'dllimport'";
5589 if (D->
hasAttr<DLLImportAttr>())
5592 return ::new (Context) DLLImportAttr(Range, Context, AttrSpellingListIndex);
5596 unsigned AttrSpellingListIndex) {
5597 if (DLLImportAttr *Import = D->
getAttr<DLLImportAttr>()) {
5598 Diag(Import->getLocation(), diag::warn_attribute_ignored) << Import;
5602 if (D->
hasAttr<DLLExportAttr>())
5605 return ::new (Context) DLLExportAttr(Range, Context, AttrSpellingListIndex);
5609 if (isa<ClassTemplatePartialSpecializationDecl>(D) &&
5616 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
5617 if (FD->isInlined() && A.
getKind() == ParsedAttr::AT_DLLImport &&
5626 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
5628 MD->getParent()->isLambda()) {
5635 Attr *NewAttr = A.
getKind() == ParsedAttr::AT_DLLExport
5644 unsigned AttrSpellingListIndex,
5645 MSInheritanceAttr::Spelling SemanticSpelling) {
5646 if (MSInheritanceAttr *IA = D->
getAttr<MSInheritanceAttr>()) {
5647 if (IA->getSemanticSpelling() == SemanticSpelling)
5649 Diag(IA->getLocation(), diag::err_mismatched_ms_inheritance)
5651 Diag(Range.
getBegin(), diag::note_previous_ms_inheritance);
5655 auto *RD = cast<CXXRecordDecl>(D);
5656 if (RD->hasDefinition()) {
5657 if (checkMSInheritanceAttrOnDefinition(RD, Range, BestCase,
5658 SemanticSpelling)) {
5662 if (isa<ClassTemplatePartialSpecializationDecl>(RD)) {
5663 Diag(Range.
getBegin(), diag::warn_ignored_ms_inheritance)
5667 if (RD->getDescribedClassTemplate()) {
5668 Diag(Range.
getBegin(), diag::warn_ignored_ms_inheritance)
5674 return ::new (Context)
5675 MSInheritanceAttr(Range, Context, BestCase, AttrSpellingListIndex);
5687 StringRef N(
"mutex");
5689 if (AL.
getKind() == ParsedAttr::AT_Capability &&
5695 if (!N.equals_lower(
"mutex") && !N.equals_lower(
"role"))
5696 S.
Diag(LiteralLoc, diag::warn_invalid_capability_name) << N;
5708 Args.data(), Args.size(),
5720 Args.data(), Args.size(),
5760 RequiresCapabilityAttr *RCA = ::new (S.
Context)
5768 if (
const auto *NSD = dyn_cast<NamespaceDecl>(D)) {
5769 if (NSD->isAnonymousNamespace()) {
5770 S.
Diag(AL.
getLoc(), diag::warn_deprecated_anonymous_namespace);
5802 if (
const auto *S = dyn_cast<VarDecl>(D))
5803 return S->hasGlobalStorage();
5811 std::vector<StringRef> Sanitizers;
5813 for (
unsigned I = 0, E = AL.
getNumArgs(); I != E; ++I) {
5814 StringRef SanitizerName;
5821 S.
Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << SanitizerName;
5822 else if (
isGlobalVar(D) && SanitizerName !=
"address")
5825 Sanitizers.push_back(SanitizerName);
5837 StringRef SanitizerName = llvm::StringSwitch<StringRef>(AttrName)
5838 .Case(
"no_address_safety_analysis",
"address")
5839 .Case(
"no_sanitize_address",
"address")
5840 .Case(
"no_sanitize_thread",
"thread")
5841 .Case(
"no_sanitize_memory",
"memory");
5851 if (InternalLinkageAttr *Internal =
5858 if (S.
LangOpts.OpenCLVersion != 200)
5859 S.
Diag(AL.
getLoc(), diag::err_attribute_requires_opencl_version)
5860 << AL.
getName() <<
"2.0" << 0;
5862 S.
Diag(AL.
getLoc(), diag::warn_opencl_attr_deprecated_ignored)
5914 if (D->
hasAttr<OpenCLAccessAttr>()) {
5915 S.
Diag(AL.
getLoc(), diag::err_opencl_multiple_access_qualifiers)
5926 if (
const auto *PDecl = dyn_cast<ParmVarDecl>(D)) {
5927 const Type *DeclTy = PDecl->getType().getCanonicalType().getTypePtr();
5928 if (AL.
getName()->
getName().find(
"read_write") != StringRef::npos) {
5930 S.
Diag(AL.
getLoc(), diag::err_opencl_invalid_read_write)
5951 bool IncludeCXX11Attributes) {
5966 ? diag::warn_unhandled_ms_attribute_ignored
5967 : diag::warn_unknown_attribute_ignored)
5979 assert(AL.
isTypeAttr() &&
"Non-type attribute not handled");
5982 S.
Diag(AL.
getLoc(), diag::err_stmt_attribute_invalid_on_decl)
5985 case ParsedAttr::AT_Interrupt:
5988 case ParsedAttr::AT_X86ForceAlignArgPointer:
5991 case ParsedAttr::AT_DLLExport:
5992 case ParsedAttr::AT_DLLImport:
5995 case ParsedAttr::AT_Mips16:
5997 MipsInterruptAttr>(S, D, AL);
5999 case ParsedAttr::AT_NoMips16:
6000 handleSimpleAttribute<NoMips16Attr>(S, D, AL);
6002 case ParsedAttr::AT_MicroMips:
6003 handleSimpleAttributeWithExclusions<MicroMipsAttr, Mips16Attr>(S, D, AL);
6005 case ParsedAttr::AT_NoMicroMips:
6006 handleSimpleAttribute<NoMicroMipsAttr>(S, D, AL);
6008 case ParsedAttr::AT_MipsLongCall:
6009 handleSimpleAttributeWithExclusions<MipsLongCallAttr, MipsShortCallAttr>(
6012 case ParsedAttr::AT_MipsShortCall:
6013 handleSimpleAttributeWithExclusions<MipsShortCallAttr, MipsLongCallAttr>(
6016 case ParsedAttr::AT_AMDGPUFlatWorkGroupSize:
6019 case ParsedAttr::AT_AMDGPUWavesPerEU:
6022 case ParsedAttr::AT_AMDGPUNumSGPR:
6025 case ParsedAttr::AT_AMDGPUNumVGPR:
6028 case ParsedAttr::AT_AVRSignal:
6031 case ParsedAttr::AT_IBAction:
6032 handleSimpleAttribute<IBActionAttr>(S, D, AL);
6034 case ParsedAttr::AT_IBOutlet:
6037 case ParsedAttr::AT_IBOutletCollection:
6040 case ParsedAttr::AT_IFunc:
6043 case ParsedAttr::AT_Alias:
6046 case ParsedAttr::AT_Aligned:
6049 case ParsedAttr::AT_AlignValue:
6052 case ParsedAttr::AT_AllocSize:
6055 case ParsedAttr::AT_AlwaysInline:
6058 case ParsedAttr::AT_Artificial:
6059 handleSimpleAttribute<ArtificialAttr>(S, D, AL);
6061 case ParsedAttr::AT_AnalyzerNoReturn:
6064 case ParsedAttr::AT_TLSModel:
6067 case ParsedAttr::AT_Annotate:
6070 case ParsedAttr::AT_Availability:
6073 case ParsedAttr::AT_CarriesDependency:
6076 case ParsedAttr::AT_CPUDispatch:
6077 case ParsedAttr::AT_CPUSpecific:
6080 case ParsedAttr::AT_Common:
6083 case ParsedAttr::AT_CUDAConstant:
6086 case ParsedAttr::AT_PassObjectSize:
6089 case ParsedAttr::AT_Constructor:
6092 case ParsedAttr::AT_CXX11NoReturn:
6093 handleSimpleAttribute<CXX11NoReturnAttr>(S, D, AL);
6095 case ParsedAttr::AT_Deprecated:
6098 case ParsedAttr::AT_Destructor:
6101 case ParsedAttr::AT_EnableIf:
6104 case ParsedAttr::AT_DiagnoseIf:
6107 case ParsedAttr::AT_ExtVectorType:
6110 case ParsedAttr::AT_ExternalSourceSymbol:
6113 case ParsedAttr::AT_MinSize:
6116 case ParsedAttr::AT_OptimizeNone:
6119 case ParsedAttr::AT_FlagEnum:
6120 handleSimpleAttribute<FlagEnumAttr>(S, D, AL);
6122 case ParsedAttr::AT_EnumExtensibility:
6125 case ParsedAttr::AT_Flatten:
6126 handleSimpleAttribute<FlattenAttr>(S, D, AL);
6128 case ParsedAttr::AT_Format:
6131 case ParsedAttr::AT_FormatArg:
6134 case ParsedAttr::AT_CUDAGlobal:
6137 case ParsedAttr::AT_CUDADevice:
6138 handleSimpleAttributeWithExclusions<CUDADeviceAttr, CUDAGlobalAttr>(S, D,
6141 case ParsedAttr::AT_CUDAHost:
6142 handleSimpleAttributeWithExclusions<CUDAHostAttr, CUDAGlobalAttr>(S, D, AL);
6144 case ParsedAttr::AT_GNUInline:
6147 case ParsedAttr::AT_CUDALaunchBounds:
6150 case ParsedAttr::AT_Restrict:
6153 case ParsedAttr::AT_LifetimeBound:
6154 handleSimpleAttribute<LifetimeBoundAttr>(S, D, AL);
6156 case ParsedAttr::AT_MayAlias:
6157 handleSimpleAttribute<MayAliasAttr>(S, D, AL);
6159 case ParsedAttr::AT_Mode:
6162 case ParsedAttr::AT_NoAlias:
6163 handleSimpleAttribute<NoAliasAttr>(S, D, AL);
6165 case ParsedAttr::AT_NoCommon:
6166 handleSimpleAttribute<NoCommonAttr>(S, D, AL);
6168 case ParsedAttr::AT_NoSplitStack:
6169 handleSimpleAttribute<NoSplitStackAttr>(S, D, AL);
6171 case ParsedAttr::AT_NonNull:
6172 if (
auto *PVD = dyn_cast<ParmVarDecl>(D))
6177 case ParsedAttr::AT_ReturnsNonNull:
6180 case ParsedAttr::AT_NoEscape:
6183 case ParsedAttr::AT_AssumeAligned:
6186 case ParsedAttr::AT_AllocAlign:
6189 case ParsedAttr::AT_Overloadable:
6190 handleSimpleAttribute<OverloadableAttr>(S, D, AL);
6192 case ParsedAttr::AT_Ownership:
6195 case ParsedAttr::AT_Cold:
6196 handleSimpleAttributeWithExclusions<ColdAttr, HotAttr>(S, D, AL);
6198 case ParsedAttr::AT_Hot:
6199 handleSimpleAttributeWithExclusions<HotAttr, ColdAttr>(S, D, AL);
6201 case ParsedAttr::AT_Naked:
6204 case ParsedAttr::AT_NoReturn:
6207 case ParsedAttr::AT_AnyX86NoCfCheck:
6210 case ParsedAttr::AT_NoThrow:
6211 handleSimpleAttribute<NoThrowAttr>(S, D, AL);
6213 case ParsedAttr::AT_CUDAShared:
6216 case ParsedAttr::AT_VecReturn:
6219 case ParsedAttr::AT_ObjCOwnership:
6222 case ParsedAttr::AT_ObjCPreciseLifetime:
6225 case ParsedAttr::AT_ObjCReturnsInnerPointer:
6228 case ParsedAttr::AT_ObjCRequiresSuper:
6231 case ParsedAttr::AT_ObjCBridge:
6234 case ParsedAttr::AT_ObjCBridgeMutable:
6237 case ParsedAttr::AT_ObjCBridgeRelated:
6240 case ParsedAttr::AT_ObjCDesignatedInitializer:
6243 case ParsedAttr::AT_ObjCRuntimeName:
6246 case ParsedAttr::AT_ObjCRuntimeVisible:
6247 handleSimpleAttribute<ObjCRuntimeVisibleAttr>(S, D, AL);
6249 case ParsedAttr::AT_ObjCBoxable:
6252 case ParsedAttr::AT_CFAuditedTransfer:
6254 CFUnknownTransferAttr>(S, D, AL);
6256 case ParsedAttr::AT_CFUnknownTransfer:
6258 CFAuditedTransferAttr>(S, D, AL);
6260 case ParsedAttr::AT_CFConsumed:
6261 case ParsedAttr::AT_NSConsumed:
6264 case ParsedAttr::AT_NSConsumesSelf:
6265 handleSimpleAttribute<NSConsumesSelfAttr>(S, D, AL);
6267 case ParsedAttr::AT_NSReturnsAutoreleased:
6268 case ParsedAttr::AT_NSReturnsNotRetained:
6269 case ParsedAttr::AT_CFReturnsNotRetained:
6270 case ParsedAttr::AT_NSReturnsRetained:
6271 case ParsedAttr::AT_CFReturnsRetained:
6274 case ParsedAttr::AT_WorkGroupSizeHint:
6275 handleWorkGroupSize<WorkGroupSizeHintAttr>(S, D, AL);
6277 case ParsedAttr::AT_ReqdWorkGroupSize:
6278 handleWorkGroupSize<ReqdWorkGroupSizeAttr>(S, D, AL);
6280 case ParsedAttr::AT_OpenCLIntelReqdSubGroupSize:
6283 case ParsedAttr::AT_VecTypeHint:
6286 case ParsedAttr::AT_RequireConstantInit:
6287 handleSimpleAttribute<RequireConstantInitAttr>(S, D, AL);
6289 case ParsedAttr::AT_InitPriority:
6292 case ParsedAttr::AT_Packed:
6295 case ParsedAttr::AT_Section:
6298 case ParsedAttr::AT_CodeSeg:
6301 case ParsedAttr::AT_Target:
6304 case ParsedAttr::AT_MinVectorWidth:
6307 case ParsedAttr::AT_Unavailable:
6308 handleAttrWithMessage<UnavailableAttr>(S, D, AL);
6310 case ParsedAttr::AT_ArcWeakrefUnavailable:
6311 handleSimpleAttribute<ArcWeakrefUnavailableAttr>(S, D, AL);
6313 case ParsedAttr::AT_ObjCRootClass:
6314 handleSimpleAttribute<ObjCRootClassAttr>(S, D, AL);
6316 case ParsedAttr::AT_ObjCSubclassingRestricted:
6317 handleSimpleAttribute<ObjCSubclassingRestrictedAttr>(S, D, AL);
6319 case ParsedAttr::AT_ObjCExplicitProtocolImpl:
6322 case ParsedAttr::AT_ObjCRequiresPropertyDefs:
6323 handleSimpleAttribute<ObjCRequiresPropertyDefsAttr>(S, D, AL);
6325 case ParsedAttr::AT_Unused:
6328 case ParsedAttr::AT_ReturnsTwice:
6329 handleSimpleAttribute<ReturnsTwiceAttr>(S, D, AL);
6331 case ParsedAttr::AT_NotTailCalled:
6332 handleSimpleAttributeWithExclusions<NotTailCalledAttr, AlwaysInlineAttr>(
6335 case ParsedAttr::AT_DisableTailCalls:
6336 handleSimpleAttributeWithExclusions<DisableTailCallsAttr, NakedAttr>(S, D,
6339 case ParsedAttr::AT_Used:
6340 handleSimpleAttribute<UsedAttr>(S, D, AL);
6342 case ParsedAttr::AT_Visibility:
6345 case ParsedAttr::AT_TypeVisibility:
6348 case ParsedAttr::AT_WarnUnused:
6349 handleSimpleAttribute<WarnUnusedAttr>(S, D, AL);
6351 case ParsedAttr::AT_WarnUnusedResult:
6354 case ParsedAttr::AT_Weak:
6355 handleSimpleAttribute<WeakAttr>(S, D, AL);
6357 case ParsedAttr::AT_WeakRef:
6360 case ParsedAttr::AT_WeakImport:
6363 case ParsedAttr::AT_TransparentUnion:
6366 case ParsedAttr::AT_ObjCException:
6367 handleSimpleAttribute<ObjCExceptionAttr>(S, D, AL);
6369 case ParsedAttr::AT_ObjCMethodFamily:
6372 case ParsedAttr::AT_ObjCNSObject:
6375 case ParsedAttr::AT_ObjCIndependentClass:
6378 case ParsedAttr::AT_Blocks:
6381 case ParsedAttr::AT_Sentinel:
6384 case ParsedAttr::AT_Const:
6385 handleSimpleAttribute<ConstAttr>(S, D, AL);
6387 case ParsedAttr::AT_Pure:
6388 handleSimpleAttribute<PureAttr>(S, D, AL);
6390 case ParsedAttr::AT_Cleanup:
6393 case ParsedAttr::AT_NoDebug:
6396 case ParsedAttr::AT_NoDuplicate:
6397 handleSimpleAttribute<NoDuplicateAttr>(S, D, AL);
6399 case ParsedAttr::AT_Convergent:
6400 handleSimpleAttribute<ConvergentAttr>(S, D, AL);
6402 case ParsedAttr::AT_NoInline:
6403 handleSimpleAttribute<NoInlineAttr>(S, D, AL);
6405 case ParsedAttr::AT_NoInstrumentFunction:
6406 handleSimpleAttribute<NoInstrumentFunctionAttr>(S, D, AL);
6408 case ParsedAttr::AT_NoStackProtector:
6410 handleSimpleAttribute<NoStackProtectorAttr>(S, D, AL);
6412 case ParsedAttr::AT_StdCall:
6413 case ParsedAttr::AT_CDecl:
6414 case ParsedAttr::AT_FastCall:
6415 case ParsedAttr::AT_ThisCall:
6416 case ParsedAttr::AT_Pascal:
6417 case ParsedAttr::AT_RegCall:
6418 case ParsedAttr::AT_SwiftCall:
6419 case ParsedAttr::AT_VectorCall:
6420 case ParsedAttr::AT_MSABI:
6421 case ParsedAttr::AT_SysVABI:
6422 case ParsedAttr::AT_Pcs:
6423 case ParsedAttr::AT_IntelOclBicc:
6424 case ParsedAttr::AT_PreserveMost:
6425 case ParsedAttr::AT_PreserveAll:
6428 case ParsedAttr::AT_Suppress:
6431 case ParsedAttr::AT_OpenCLKernel:
6432 handleSimpleAttribute<OpenCLKernelAttr>(S, D, AL);
6434 case ParsedAttr::AT_OpenCLAccess:
6437 case ParsedAttr::AT_OpenCLNoSVM:
6440 case ParsedAttr::AT_SwiftContext:
6443 case ParsedAttr::AT_SwiftErrorResult:
6446 case ParsedAttr::AT_SwiftIndirectResult:
6449 case ParsedAttr::AT_InternalLinkage:
6452 case ParsedAttr::AT_LTOVisibilityPublic:
6453 handleSimpleAttribute<LTOVisibilityPublicAttr>(S, D, AL);
6457 case ParsedAttr::AT_EmptyBases:
6458 handleSimpleAttribute<EmptyBasesAttr>(S, D, AL);
6460 case ParsedAttr::AT_LayoutVersion:
6463 case ParsedAttr::AT_TrivialABI:
6464 handleSimpleAttribute<TrivialABIAttr>(S, D, AL);
6466 case ParsedAttr::AT_MSNoVTable:
6467 handleSimpleAttribute<MSNoVTableAttr>(S, D, AL);
6469 case ParsedAttr::AT_MSStruct:
6470 handleSimpleAttribute<MSStructAttr>(S, D, AL);
6472 case ParsedAttr::AT_Uuid:
6475 case ParsedAttr::AT_MSInheritance:
6478 case ParsedAttr::AT_SelectAny:
6479 handleSimpleAttribute<SelectAnyAttr>(S, D, AL);
6481 case ParsedAttr::AT_Thread:
6485 case ParsedAttr::AT_AbiTag:
6490 case ParsedAttr::AT_AssertExclusiveLock:
6493 case ParsedAttr::AT_AssertSharedLock:
6496 case ParsedAttr::AT_GuardedVar:
6497 handleSimpleAttribute<GuardedVarAttr>(S, D, AL);
6499 case ParsedAttr::AT_PtGuardedVar:
6502 case ParsedAttr::AT_ScopedLockable:
6503 handleSimpleAttribute<ScopedLockableAttr>(S, D, AL);
6505 case ParsedAttr::AT_NoSanitize:
6508 case ParsedAttr::AT_NoSanitizeSpecific:
6511 case ParsedAttr::AT_NoThreadSafetyAnalysis:
6512 handleSimpleAttribute<NoThreadSafetyAnalysisAttr>(S, D, AL);
6514 case ParsedAttr::AT_GuardedBy:
6517 case ParsedAttr::AT_PtGuardedBy:
6520 case ParsedAttr::AT_ExclusiveTrylockFunction:
6523 case ParsedAttr::AT_LockReturned:
6526 case ParsedAttr::AT_LocksExcluded:
6529 case ParsedAttr::AT_SharedTrylockFunction:
6532 case ParsedAttr::AT_AcquiredBefore:
6535 case ParsedAttr::AT_AcquiredAfter:
6540 case ParsedAttr::AT_Capability:
6541 case ParsedAttr::AT_Lockable:
6544 case ParsedAttr::AT_RequiresCapability:
6548 case ParsedAttr::AT_AssertCapability:
6551 case ParsedAttr::AT_AcquireCapability:
6554 case ParsedAttr::AT_ReleaseCapability:
6557 case ParsedAttr::AT_TryAcquireCapability:
6562 case ParsedAttr::AT_Consumable:
6565 case ParsedAttr::AT_ConsumableAutoCast:
6566 handleSimpleAttribute<ConsumableAutoCastAttr>(S, D, AL);
6568 case ParsedAttr::AT_ConsumableSetOnRead:
6569 handleSimpleAttribute<ConsumableSetOnReadAttr>(S, D, AL);
6571 case ParsedAttr::AT_CallableWhen:
6574 case ParsedAttr::AT_ParamTypestate:
6577 case ParsedAttr::AT_ReturnTypestate:
6580 case ParsedAttr::AT_SetTypestate:
6583 case ParsedAttr::AT_TestTypestate:
6588 case ParsedAttr::AT_ArgumentWithTypeTag:
6591 case ParsedAttr::AT_TypeTagForDatatype:
6594 case ParsedAttr::AT_AnyX86NoCallerSavedRegisters:
6595 handleSimpleAttribute<AnyX86NoCallerSavedRegistersAttr>(S, D, AL);
6597 case ParsedAttr::AT_RenderScriptKernel:
6598 handleSimpleAttribute<RenderScriptKernelAttr>(S, D, AL);
6601 case ParsedAttr::AT_XRayInstrument:
6602 handleSimpleAttribute<XRayInstrumentAttr>(S, D, AL);
6604 case ParsedAttr::AT_XRayLogArgs:
6614 bool IncludeCXX11Attributes) {
6615 if (AttrList.
empty())
6626 Diag(AttrList.begin()->getLoc(), diag::err_attribute_weakref_without_alias)
6627 << cast<NamedDecl>(D);
6636 if (!D->
hasAttr<OpenCLKernelAttr>()) {
6638 if (
const auto *A = D->
getAttr<ReqdWorkGroupSizeAttr>()) {
6643 }
else if (
const auto *A = D->
getAttr<WorkGroupSizeHintAttr>()) {
6646 }
else if (
const auto *A = D->
getAttr<VecTypeHintAttr>()) {
6649 }
else if (
const auto *A = D->
getAttr<OpenCLIntelReqdSubGroupSizeAttr>()) {
6652 }
else if (!D->
hasAttr<CUDAGlobalAttr>()) {
6653 if (
const auto *A = D->
getAttr<AMDGPUFlatWorkGroupSizeAttr>()) {
6657 }
else if (
const auto *A = D->
getAttr<AMDGPUWavesPerEUAttr>()) {
6661 }
else if (
const auto *A = D->
getAttr<AMDGPUNumSGPRAttr>()) {
6665 }
else if (
const auto *A = D->
getAttr<AMDGPUNumVGPRAttr>()) {
6678 if (AL.getKind() == ParsedAttr::AT_TransparentUnion) {
6689 if (AL.getKind() == ParsedAttr::AT_Annotate) {
6692 Diag(AL.getLoc(), diag::err_only_annotate_after_access_spec);
6704 if (AL.isUsedAsTypeAttr() || AL.isInvalid())
6710 S.
Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored)
6711 << AL.getName() << AL.getRange();
6713 S.
Diag(AL.getLoc(), diag::warn_attribute_not_on_decl)
6714 << AL.getName() << AL.getRange();
6733 assert(isa<FunctionDecl>(ND) || isa<VarDecl>(ND));
6735 if (
auto *FD = dyn_cast<FunctionDecl>(ND)) {
6743 FD->getType(), FD->getTypeSourceInfo(),
6749 if (FD->getQualifier())
6757 for (
const auto &AI : FT->param_types()) {
6758 ParmVarDecl *Param = BuildParmVarDeclForTypedef(NewFD, Loc, AI);
6760 Params.push_back(Param);
6762 NewFD->setParams(Params);
6764 }
else if (
auto *VD = dyn_cast<VarDecl>(ND)) {
6766 VD->getInnerLocStart(), VD->getLocation(), II,
6767 VD->getType(), VD->getTypeSourceInfo(),
6768 VD->getStorageClass());
6769 if (VD->getQualifier())
6783 NewD->
addAttr(AliasAttr::CreateImplicit(Context, NDId->
getName(),
6786 WeakTopLevelDecl.push_back(NewD);
6793 PushOnScopeChains(NewD, S);
6794 CurContext = SavedContext;
6803 LoadExternalWeakUndeclaredIdentifiers();
6804 if (!WeakUndeclaredIdentifiers.empty()) {
6806 if (
auto *VD = dyn_cast<VarDecl>(D))
6807 if (VD->isExternC())
6809 if (
auto *FD = dyn_cast<FunctionDecl>(D))
6810 if (FD->isExternC())
6814 auto I = WeakUndeclaredIdentifiers.find(
Id);
6815 if (I != WeakUndeclaredIdentifiers.end()) {
6817 DeclApplyPragmaWeak(S, ND, W);
6818 WeakUndeclaredIdentifiers[
Id] = W;
6845 AddPragmaAttributes(S, D);
6853 UnavailableAttr::ImplicitReason &reason) {
6857 if (!isa<FieldDecl>(D) && !isa<ObjCPropertyDecl>(D) &&
6858 !isa<FunctionDecl>(D))
6866 if ((isa<ObjCIvarDecl>(D) || isa<ObjCPropertyDecl>(D))) {
6869 reason = UnavailableAttr::IR_ForbiddenWeak;
6878 reason = UnavailableAttr::IR_ARCForbiddenType;
6888 auto Reason = UnavailableAttr::IR_None;
6890 assert(Reason &&
"didn't set reason?");
6895 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
6898 if (FD->hasAttr<UnavailableAttr>() &&
6900 diag::err_arc_array_param_no_ownership) {
6914 for (
const auto *A : D->
attrs()) {
6915 if (
const auto *Avail = dyn_cast<AvailabilityAttr>(A)) {
6921 StringRef ActualPlatform = Avail->getPlatform()->getName();
6922 StringRef RealizedPlatform = ActualPlatform;
6924 size_t suffix = RealizedPlatform.rfind(
"_app_extension");
6925 if (suffix != StringRef::npos)
6926 RealizedPlatform = RealizedPlatform.slice(0, suffix);
6932 if (RealizedPlatform == TargetPlatform)
6945 static std::pair<AvailabilityResult, const NamedDecl *>
6951 while (
const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
6953 if (
const auto *TT = TD->getUnderlyingType()->getAs<
TagType>()) {
6963 if (
const auto *IDecl = dyn_cast<ObjCInterfaceDecl>(D)) {
6964 if (IDecl->getDefinition()) {
6965 D = IDecl->getDefinition();
6970 if (
const auto *ECD = dyn_cast<EnumConstantDecl>(D))
6973 if (
const auto *TheEnumDecl = dyn_cast<EnumDecl>(DC)) {
6974 Result = TheEnumDecl->getAvailability(Message);
6987 VersionTuple DeclVersion,
6989 assert(K !=
AR_Available &&
"Expected an unavailable declaration here!");
6992 auto CheckContext = [&](
const Decl *C) {
6995 if (AA->getIntroduced() >= DeclVersion)
6998 if (C->isDeprecated())
7001 if (C->isUnavailable())
7007 if (CheckContext(Ctx))
7012 if (
const auto *MethodD = dyn_cast<ObjCMethodDecl>(Ctx))
7013 if (MethodD->isClassMethod() &&
7014 MethodD->getSelector().getAsString() ==
"load")
7017 if (
const auto *CatOrImpl = dyn_cast<ObjCImplDecl>(Ctx)) {
7019 if (CheckContext(Interface))
7023 else if (
const auto *CatD = dyn_cast<ObjCCategoryDecl>(Ctx))
7025 if (CheckContext(Interface))
7034 const VersionTuple &DeploymentVersion,
7035 const VersionTuple &DeclVersion) {
7037 VersionTuple ForceAvailabilityFromVersion;
7038 switch (Triple.getOS()) {
7039 case llvm::Triple::IOS:
7040 case llvm::Triple::TvOS:
7041 ForceAvailabilityFromVersion = VersionTuple(11);
7043 case llvm::Triple::WatchOS:
7044 ForceAvailabilityFromVersion = VersionTuple(4);
7046 case llvm::Triple::Darwin:
7047 case llvm::Triple::MacOSX:
7048 ForceAvailabilityFromVersion = VersionTuple(10, 13);
7052 return Triple.getVendor() == llvm::Triple::Apple;
7054 return DeploymentVersion >= ForceAvailabilityFromVersion ||
7055 DeclVersion >= ForceAvailabilityFromVersion;
7059 for (
Decl *Ctx = OrigCtx; Ctx;
7060 Ctx = cast_or_null<Decl>(Ctx->getDeclContext())) {
7061 if (isa<TagDecl>(Ctx) || isa<FunctionDecl>(Ctx) || isa<ObjCMethodDecl>(Ctx))
7062 return cast<NamedDecl>(Ctx);
7063 if (
auto *CD = dyn_cast<ObjCContainerDecl>(Ctx)) {
7064 if (
auto *Imp = dyn_cast<ObjCImplDecl>(Ctx))
7065 return Imp->getClassInterface();
7075 struct AttributeInsertion {
7080 static AttributeInsertion createInsertionAfter(
const NamedDecl *D) {
7083 static AttributeInsertion createInsertionAfter(
SourceLocation Loc) {
7084 return {
" ", Loc,
""};
7086 static AttributeInsertion createInsertionBefore(
const NamedDecl *D) {
7101 static Optional<unsigned>
7105 if (!Name.empty() && (Name.front() ==
'-' || Name.front() ==
'+'))
7106 Name = Name.drop_front(1);
7109 Name.split(SlotNames,
':');
7111 if (Name.back() ==
':') {
7113 SlotNames.pop_back();
7114 NumParams = SlotNames.size();
7116 if (SlotNames.size() != 1)
7122 bool AllowDollar = LangOpts.DollarIdents;
7123 for (StringRef S : SlotNames) {
7134 static Optional<AttributeInsertion>
7137 if (isa<ObjCPropertyDecl>(D))
7138 return AttributeInsertion::createInsertionAfter(D);
7139 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
7142 return AttributeInsertion::createInsertionAfter(D);
7144 if (
const auto *TD = dyn_cast<TagDecl>(D)) {
7150 return AttributeInsertion::createInsertionAfter(Loc);
7152 return AttributeInsertion::createInsertionBefore(D);
7172 bool ObjCPropertyAccess) {
7174 unsigned diag, diag_message, diag_fwdclass_message;
7175 unsigned diag_available_here = diag::note_availability_specified_here;
7179 unsigned property_note_select;
7182 unsigned available_here_select_kind;
7184 VersionTuple DeclVersion;
7186 DeclVersion = AA->getIntroduced();
7196 if (A && A->isInherited()) {
7199 const AvailabilityAttr *AForRedecl =
7201 if (AForRedecl && !AForRedecl->isInherited()) {
7204 NoteLocation = Redecl->getLocation();
7216 const AvailabilityAttr *AA =
7218 VersionTuple Introduced = AA->getIntroduced();
7223 unsigned Warning = UseNewWarning ? diag::warn_unguarded_availability_new
7224 : diag::warn_unguarded_availability;
7226 S.
Diag(Loc, Warning)
7228 << AvailabilityAttr::getPrettyPlatformName(
7230 << Introduced.getAsString();
7232 S.
Diag(OffendingDecl->
getLocation(), diag::note_availability_specified_here)
7233 << OffendingDecl << 3;
7236 if (
const auto *TD = dyn_cast<TagDecl>(Enclosing))
7237 if (TD->getDeclName().isEmpty()) {
7238 S.
Diag(TD->getLocation(),
7239 diag::note_decl_unguarded_availability_silence)
7240 << 1 << TD->getKindName();
7243 auto FixitNoteDiag =
7244 S.
Diag(Enclosing->getLocation(),
7245 diag::note_decl_unguarded_availability_silence)
7248 if (Enclosing->hasAttr<AvailabilityAttr>())
7256 std::string PlatformName =
7257 AvailabilityAttr::getPlatformNameSourceSpelling(
7260 std::string Introduced =
7264 (llvm::Twine(Insertion->Prefix) +
"API_AVAILABLE(" + PlatformName +
7265 "(" + Introduced +
"))" + Insertion->Suffix)
7271 diag = !ObjCPropertyAccess ? diag::warn_deprecated
7272 : diag::warn_property_method_deprecated;
7273 diag_message = diag::warn_deprecated_message;
7274 diag_fwdclass_message = diag::warn_deprecated_fwdclass_message;
7275 property_note_select = 0;
7276 available_here_select_kind = 2;
7277 if (
const auto *AL = OffendingDecl->
getAttr<DeprecatedAttr>())
7278 NoteLocation = AL->getLocation();
7282 diag = !ObjCPropertyAccess ? diag::err_unavailable
7283 : diag::err_property_method_unavailable;
7284 diag_message = diag::err_unavailable_message;
7285 diag_fwdclass_message = diag::warn_unavailable_fwdclass_message;
7286 property_note_select = 1;
7287 available_here_select_kind = 0;
7289 if (
auto AL = OffendingDecl->
getAttr<UnavailableAttr>()) {
7290 if (AL->isImplicit() && AL->getImplicitReason()) {
7293 auto flagARCError = [&] {
7297 diag = diag::err_unavailable_in_arc;
7300 switch (AL->getImplicitReason()) {
7301 case UnavailableAttr::IR_None:
break;
7303 case UnavailableAttr::IR_ARCForbiddenType:
7305 diag_available_here = diag::note_arc_forbidden_type;
7308 case UnavailableAttr::IR_ForbiddenWeak:
7310 diag_available_here = diag::note_arc_weak_disabled;
7312 diag_available_here = diag::note_arc_weak_no_runtime;
7315 case UnavailableAttr::IR_ARCForbiddenConversion:
7317 diag_available_here = diag::note_performs_forbidden_arc_conversion;
7320 case UnavailableAttr::IR_ARCInitReturnsUnrelated:
7322 diag_available_here = diag::note_arc_init_returns_unrelated;
7325 case UnavailableAttr::IR_ARCFieldWithOwnership:
7327 diag_available_here = diag::note_arc_field_with_ownership;
7335 llvm_unreachable(
"Warning for availability of available declaration?");
7341 if (
auto AL = OffendingDecl->
getAttr<DeprecatedAttr>())
7342 Replacement = AL->getReplacement();
7344 Replacement = AL->getReplacement();
7347 if (!Replacement.empty())
7351 if (
const auto *MethodDecl = dyn_cast<ObjCMethodDecl>(ReferringDecl)) {
7352 Selector Sel = MethodDecl->getSelector();
7356 if (NumParams && NumParams.getValue() == Sel.
getNumArgs()) {
7357 assert(SelectorSlotNames.size() == Locs.size());
7358 for (
unsigned I = 0; I < Locs.size(); ++I) {
7363 NameRange, SelectorSlotNames[I]));
7375 if (!Message.empty()) {
7376 S.
Diag(Loc, diag_message) << ReferringDecl << Message << FixIts;
7379 << ObjCProperty->
getDeclName() << property_note_select;
7380 }
else if (!UnknownObjCClass) {
7381 S.
Diag(Loc, diag) << ReferringDecl << FixIts;
7384 << ObjCProperty->
getDeclName() << property_note_select;
7386 S.
Diag(Loc, diag_fwdclass_message) << ReferringDecl << FixIts;
7390 S.
Diag(NoteLocation, diag_available_here)
7391 << OffendingDecl << available_here_select_kind;
7397 "Expected an availability diagnostic here");
7433 switch (diag.
Kind) {
7442 HandleDelayedAccessCheck(diag, decl);
7458 assert(curPool &&
"re-emitting in undelayed context not supported");
7459 curPool->
steal(pool);
7469 bool ObjCPropertyAccess) {
7474 AR, Locs, ReferringDecl, OffendingDecl, UnknownObjCClass,
7475 ObjCProperty, Message, ObjCPropertyAccess));
7481 Message, Locs, UnknownObjCClass, ObjCProperty,
7482 ObjCPropertyAccess);
7490 case Stmt::IfStmtClass:
7491 return cast<IfStmt>(
Parent)->getThen() == S ||
7492 cast<IfStmt>(
Parent)->getElse() == S;
7493 case Stmt::WhileStmtClass:
7494 return cast<WhileStmt>(
Parent)->getBody() == S;
7495 case Stmt::DoStmtClass:
7496 return cast<DoStmt>(
Parent)->getBody() == S;
7497 case Stmt::ForStmtClass:
7498 return cast<ForStmt>(
Parent)->getBody() == S;
7499 case Stmt::CXXForRangeStmtClass:
7500 return cast<CXXForRangeStmt>(
Parent)->getBody() == S;
7501 case Stmt::ObjCForCollectionStmtClass:
7502 return cast<ObjCForCollectionStmt>(
Parent)->getBody() == S;
7503 case Stmt::CaseStmtClass:
7504 case Stmt::DefaultStmtClass:
7505 return cast<SwitchCase>(
Parent)->getSubStmt() == S;
7515 bool VisitStmt(
Stmt *S) {
return S !=
Target; }
7518 static bool isContained(
const Stmt *Target,
const Decl *D) {
7519 StmtUSEFinder Visitor;
7521 return !Visitor.TraverseDecl(const_cast<Decl *>(D));
7537 static const Stmt *findLastStmtThatUsesDecl(
const Decl *D,
7539 LastDeclUSEFinder Visitor;
7543 if (!Visitor.TraverseStmt(const_cast<Stmt *>(S)))
7556 class DiagnoseUnguardedAvailability
7570 DiagnoseUnguardedAvailability(
Sema &SemaRef,
Decl *Ctx)
7571 : SemaRef(SemaRef), Ctx(Ctx) {
7572 AvailabilityStack.push_back(
7576 bool TraverseDecl(
Decl *D) {
7578 if (!D || isa<FunctionDecl>(D))
7580 return Base::TraverseDecl(D);
7583 bool TraverseStmt(
Stmt *S) {
7586 StmtStack.push_back(S);
7587 bool Result = Base::TraverseStmt(S);
7588 StmtStack.pop_back();
7592 void IssueDiagnostics(
Stmt *S) { TraverseStmt(S); }
7594 bool TraverseIfStmt(
IfStmt *If);
7596 bool TraverseLambdaExpr(
LambdaExpr *E) {
return true; }
7610 DiagnoseDeclAvailability(
7616 DiagnoseDeclAvailability(DRE->
getDecl(),
7633 bool VisitTypeLoc(
TypeLoc Ty);
7636 void DiagnoseUnguardedAvailability::DiagnoseDeclAvailability(
7640 std::tie(Result, OffendingDecl) =
7648 const AvailabilityAttr *AA =
7650 VersionTuple Introduced = AA->getIntroduced();
7652 if (AvailabilityStack.back() >= Introduced)
7667 SemaRef.Context.getTargetInfo().getPlatformMinVersion(), Introduced)
7668 ? diag::warn_unguarded_availability_new
7669 : diag::warn_unguarded_availability;
7671 SemaRef.Diag(Range.
getBegin(), DiagKind)
7673 << AvailabilityAttr::getPrettyPlatformName(
7674 SemaRef.getASTContext().getTargetInfo().getPlatformName())
7675 << Introduced.getAsString();
7678 diag::note_availability_specified_here)
7679 << OffendingDecl << 3;
7682 SemaRef.Diag(Range.
getBegin(), diag::note_unguarded_available_silence)
7684 << (SemaRef.getLangOpts().ObjC1 ? 0
7688 if (StmtStack.empty())
7690 const Stmt *StmtOfUse = StmtStack.back();
7692 for (
const Stmt *S : llvm::reverse(StmtStack)) {
7693 if (
const auto *CS = dyn_cast<CompoundStmt>(S)) {
7697 if (isBodyLikeChildStmt(StmtOfUse, S)) {
7705 const Stmt *LastStmtOfUse =
nullptr;
7706 if (isa<DeclStmt>(StmtOfUse) && Scope) {
7707 for (
const Decl *D : cast<DeclStmt>(StmtOfUse)->decls()) {
7708 if (StmtUSEFinder::isContained(StmtStack.back(), D)) {
7709 LastStmtOfUse = LastDeclUSEFinder::findLastStmtThatUsesDecl(D, Scope);
7720 (LastStmtOfUse ? LastStmtOfUse : StmtOfUse)->getLocEnd())
7726 const char *ExtraIndentation =
" ";
7727 std::string FixItString;
7728 llvm::raw_string_ostream FixItOS(FixItString);
7729 FixItOS <<
"if (" << (SemaRef.getLangOpts().ObjC1 ?
"@available" 7730 :
"__builtin_available")
7732 << AvailabilityAttr::getPlatformNameSourceSpelling(
7733 SemaRef.getASTContext().getTargetInfo().getPlatformName())
7734 <<
" " << Introduced.getAsString() <<
", *)) {\n" 7735 << Indentation << ExtraIndentation;
7738 StmtEndLoc, tok::semi, SM, SemaRef.getLangOpts(),
7740 if (ElseInsertionLoc.isInvalid())
7743 FixItOS.str().clear();
7745 << Indentation <<
"} else {\n" 7746 << Indentation << ExtraIndentation
7747 <<
"// Fallback on earlier versions\n" 7748 << Indentation <<
"}";
7753 bool DiagnoseUnguardedAvailability::VisitTypeLoc(
TypeLoc Ty) {
7760 if (
const auto *TT = dyn_cast<TagType>(TyPtr)) {
7762 DiagnoseDeclAvailability(TD, Range);
7764 }
else if (
const auto *TD = dyn_cast<TypedefType>(TyPtr)) {
7766 DiagnoseDeclAvailability(D, Range);
7768 }
else if (
const auto *ObjCO = dyn_cast<ObjCObjectType>(TyPtr)) {
7769 if (
NamedDecl *D = ObjCO->getInterface())
7770 DiagnoseDeclAvailability(D, Range);
7776 bool DiagnoseUnguardedAvailability::TraverseIfStmt(
IfStmt *If) {
7777 VersionTuple CondVersion;
7778 if (
auto *E = dyn_cast<ObjCAvailabilityCheckExpr>(If->
getCond())) {
7779 CondVersion = E->getVersion();
7783 if (CondVersion.empty() || CondVersion <= AvailabilityStack.back())
7784 return TraverseStmt(If->
getThen()) && TraverseStmt(If->
getElse());
7787 return Base::TraverseIfStmt(If);
7790 AvailabilityStack.push_back(CondVersion);
7791 bool ShouldContinue = TraverseStmt(If->
getThen());
7792 AvailabilityStack.pop_back();
7794 return ShouldContinue && TraverseStmt(If->
getElse());
7800 Stmt *Body =
nullptr;
7805 if (FD->isTemplateInstantiation())
7808 Body = FD->getBody();
7809 }
else if (
auto *MD = dyn_cast<ObjCMethodDecl>(D))
7810 Body = MD->getBody();
7811 else if (
auto *BD = dyn_cast<BlockDecl>(D))
7812 Body = BD->getBody();
7814 assert(Body &&
"Need a body here!");
7816 DiagnoseUnguardedAvailability(*
this, D).IssueDiagnostics(Body);
7822 bool ObjCPropertyAccess,
7823 bool AvoidPartialAvailabilityChecks) {
7824 std::string Message;
7833 if (AvoidPartialAvailabilityChecks)
7839 if (getCurFunctionOrMethodDecl()) {
7840 getEnclosingFunction()->HasPotentialAvailabilityViolations =
true;
7842 }
else if (getCurBlock() || getCurLambda()) {
7843 getCurFunction()->HasPotentialAvailabilityViolations =
true;
7849 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
7852 if (PDeclResult == Result)
7858 UnknownObjCClass, ObjCPDecl, ObjCPropertyAccess);
static void handleInternalLinkageAttr(Sema &S, Decl *D, const ParsedAttr &AL)
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
static std::enable_if< std::is_base_of< Attr, AttrInfo >::value, SourceLocation >::type getAttrLoc(const AttrInfo &AL)
A helper function to provide Attribute Location for the Attr types AND the ParsedAttr.
static bool isGlobalVar(const Decl *D)
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Defines the clang::ASTContext interface.
unsigned getRegParmMax() const
static bool hasFunctionProto(const Decl *D)
hasFunctionProto - Return true if the given decl has a argument information.
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
bool diagnoseAppertainsTo(class Sema &S, const Decl *D) const
Represents a function declaration or definition.
static void handleOptimizeNoneAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleObjCIndependentClass(Sema &S, Decl *D, const ParsedAttr &AL)
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
ExtVectorDeclsType ExtVectorDecls
ExtVectorDecls - This is a list all the extended vector types.
const Stmt * getElse() const
VersionTuple getPlatformMinVersion() const
Retrieve the minimum desired version of the platform, to which the program should be compiled...
static void handleObjCBridgeRelatedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
CodeSegAttr * mergeCodeSegAttr(Decl *D, SourceRange Range, StringRef Name, unsigned AttrSpellingListIndex)
static void handleCallConvAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &Attrs)
Smart pointer class that efficiently represents Objective-C method names.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
A (possibly-)qualified type.
bool isBlockPointerType() const
bool isMemberPointerType() const
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
static bool checkUInt32Argument(Sema &S, const AttrInfo &AI, const Expr *Expr, uint32_t &Val, unsigned Idx=UINT_MAX)
If Expr is a valid integer constant, get the value of the integer expression and return success or fa...
bool isDeclspecAttribute() const
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
SourceLocation getLocStart() const LLVM_READONLY
SourceLocation getLocStart() const LLVM_READONLY
A class which encapsulates the logic for delaying diagnostics during parsing and other processing...
static void handleOwnershipAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static QualType getFunctionOrMethodResultType(const Decl *D)
Stmt - This represents one statement.
FunctionType - C99 6.7.5.3 - Function Declarators.
static void handleLaunchBoundsAttr(Sema &S, Decl *D, const ParsedAttr &AL)
IfStmt - This represents an if/then/else.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
Defines the SourceManager interface.
virtual bool isValidFeatureName(StringRef Feature) const
Determine whether this TargetInfo supports the given feature.
static InitializedEntity InitializeParameter(ASTContext &Context, const ParmVarDecl *Parm)
Create the initialization entity for a parameter.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
bool isExtVectorType() const
static void handleXRayLogArgsAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Defines the C++ template declaration subclasses.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
static void handleCodeSegAttr(Sema &S, Decl *D, const ParsedAttr &AL)
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
Expr * getArgAsExpr(unsigned Arg) const
static void handleGNUInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL)
The base class of the type hierarchy.
bool getMustBeNull() const
static void handleTypeTagForDatatypeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
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 std::enable_if< std::is_base_of< Attr, AttrInfo >::value, const AttrInfo * >::type getAttrName(const AttrInfo &AL)
A helper function to provide Attribute Name for the Attr types AND the ParsedAttr.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
const TargetInfo & getTargetInfo() const
A container of type source information.
static void handleObjCNSObject(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAcquiredBeforeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
bool isCARCBridgableType() const
Determine whether the given type T is a "bridgeable" C type.
bool hasParsedType() const
SourceLocation getLocEnd() const LLVM_READONLY
static void handleObjCRuntimeName(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNonNullAttrParameter(Sema &S, ParmVarDecl *D, const ParsedAttr &AL)
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
unsigned getCharWidth() const
virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const
Determines whether a given calling convention is valid for the target.
SourceLocation getEndLoc() const
Get the end source location.
static bool threadSafetyCheckIsSmartPointer(Sema &S, const RecordType *RT)
const ParsedAttributes & getAttributes() const
IdentifierInfo * getAlias() const
QualType getConstType(QualType T) const
Return the uniqued reference to the type for a const qualified type.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
static void handleAnyX86InterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL)
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
OptimizeNoneAttr * mergeOptimizeNoneAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
bool isValidPointerAttrType(QualType T, bool RefOkay=false)
Determine if type T is a valid subject for a nonnull and similar attributes.
static void handleAcquireCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Represents a variable declaration or definition.
Information about one declarator, including the parsed type information and the identifier.
static void handleVecTypeHint(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAcquiredAfterAttr(Sema &S, Decl *D, const ParsedAttr &AL)
const T * getAs() const
Member-template getAs<specific type>'.
bool hasPointerRepresentation() const
Whether this type is represented natively as a pointer.
ObjCInterfaceDecl * getClassReceiver() const
ObjCMethodDecl - Represents an instance or class method declaration.
bool isCXX11Attribute() const
static void handleCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSentinelAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleMinSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
bool isInvalidDecl() const
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type...
static bool isValidSubjectOfCFAttribute(Sema &S, QualType QT)
bool hasDefinition() const
void AddParameterABIAttr(SourceRange AttrRange, Decl *D, ParameterABI ABI, unsigned SpellingListIndex)
Represents a parameter to a function.
static void handlePtGuardedVarAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSimpleAttribute(Sema &S, Decl *D, const ParsedAttr &AL)
Applies the given attribute to the Decl without performing any additional semantic checking...
pool_iterator pool_begin() const
Defines the clang::Expr interface and subclasses for C++ expressions.
static void handleExclusiveTrylockFunctionAttr(Sema &S, Decl *D, const ParsedAttr &AL)
FormatAttr * mergeFormatAttr(Decl *D, SourceRange Range, IdentifierInfo *Format, int FormatIdx, int FirstArg, unsigned AttrSpellingListIndex)
static bool isValidSubjectOfNSAttribute(Sema &S, QualType QT)
static void handleAssumeAlignedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
const Type * getTypePtr() const
bool hasFloatingRepresentation() const
Determine whether this type has a floating-point representation of some sort, e.g., it is a floating-point type or a vector thereof.
static void handleAVRSignalAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleTargetAttr(Sema &S, Decl *D, const ParsedAttr &AL)
const ObjCPropertyDecl * getObjCProperty() const
UuidAttr * mergeUuidAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex, StringRef Uuid)
const NamedDecl * getAvailabilityReferringDecl() const
bool CheckRegparmAttr(const ParsedAttr &attr, unsigned &value)
Checks a regparm attribute, returning true if it is ill-formed and otherwise setting numParams to the...
static void handleObjCMethodFamilyAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleVisibilityAttr(Sema &S, Decl *D, const ParsedAttr &AL, bool isTypeVisibility)
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Base wrapper for a particular "section" of type source info.
MSInheritanceAttr::Spelling calculateInheritanceModel() const
Calculate what the inheritance model would be for this class.
static void handleCleanupAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Represents a struct/union/class.
static bool isValidSwiftContextType(QualType Ty)
Pointer-like types in the default address space.
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
const ParsedType & getMatchingCType() const
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
One of these records is kept for each identifier that is lexed.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
unsigned getAttributeSpellingListIndex() const
Get an index into the attribute spelling list defined in Attr.td.
static StringRef getIndentationForLine(SourceLocation Loc, const SourceManager &SM)
Returns the leading whitespace for line that corresponds to the given location Loc.
static void handleNSConsumedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleConstantAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleGuardedByAttr(Sema &S, Decl *D, const ParsedAttr &AL)
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
The results of name lookup within a DeclContext.
static bool checkTypedefTypeForCapability(QualType Ty)
static void handleAnnotateAttr(Sema &S, Decl *D, const ParsedAttr &AL)
void AddModeAttr(SourceRange AttrRange, Decl *D, IdentifierInfo *Name, unsigned SpellingListIndex, bool InInstantiation=false)
AddModeAttr - Adds a mode attribute to a particular declaration.
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
static bool checkFunctionOrMethodParameterIndex(Sema &S, const Decl *D, const AttrInfo &AI, unsigned AttrArgNum, const Expr *IdxExpr, ParamIdx &Idx, bool CanIndexImplicitThis=false)
Check if IdxExpr is a valid parameter index for a function or instance method D.
field_range fields() const
static void handleDependencyAttr(Sema &S, Scope *Scope, Decl *D, const ParsedAttr &AL)
static void handleArgumentWithTypeTagAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleARMInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL)
bool isObjCIdType() const
Represents a member of a struct/union/class.
unsigned getSourceIndex() const
Get the parameter index as it would normally be encoded for attributes at the source level of represe...
static bool checkIBOutletCommon(Sema &S, Decl *D, const ParsedAttr &AL)
static bool versionsMatch(const VersionTuple &X, const VersionTuple &Y, bool BeforeIsOkay)
Check whether the two versions match.
static void handleGlobalAttr(Sema &S, Decl *D, const ParsedAttr &AL)
bool isReferenceType() const
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
static void handleTLSModelAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleCommonAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleMSInheritanceAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Represents an access specifier followed by colon ':'.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
i32 captured_struct **param SharedsTy A type which contains references the shared variables *param Shareds Context with the list of shared variables from the p *TaskFunction *param Data Additional data for task generation like final * state
static void handleFormatArgAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Handle attribute((format_arg((idx)))) attribute based on http://gcc.gnu.org/onlinedocs/gcc/Function-A...
void redelayDiagnostics(sema::DelayedDiagnosticPool &pool)
Given a set of delayed diagnostics, re-emit them as if they had been delayed in the current context i...
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
Describes a module or submodule.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this attribute.
static void handleAllocSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
const NamedDecl * getAvailabilityOffendingDecl() const
static void handleSuppressAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void parseModeAttrArg(Sema &S, StringRef Str, unsigned &DestWidth, bool &IntegerMode, bool &ComplexMode)
parseModeAttrArg - Parses attribute mode string and returns parsed type attribute.
static void handleMSP430InterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL)
virtual std::string isValidSectionSpecifier(StringRef SR) const
An optional hook that targets can implement to perform semantic checking on attribute((section("foo")...
void AddAssumeAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, Expr *OE, unsigned SpellingListIndex)
AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular declaration.
static void handleObjCDesignatedInitializer(Sema &S, Decl *D, const ParsedAttr &AL)
This parameter (which must have pointer type) uses the special Swift context-pointer ABI treatment...
static void handleInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL)
QualType getThisType(ASTContext &C) const
Returns the type of the this pointer.
static void handleModeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
handleModeAttr - This attribute modifies the width of a decl with primitive type. ...
TypeVisibilityAttr * mergeTypeVisibilityAttr(Decl *D, SourceRange Range, TypeVisibilityAttr::VisibilityType Vis, unsigned AttrSpellingListIndex)
static bool isIntOrBool(Expr *Exp)
Check if the passed-in expression is of type int or bool.
static bool isValidSwiftErrorResultType(QualType Ty)
Pointers and references to pointers in the default address space.
MinSizeAttr * mergeMinSizeAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
TagKind getTagKind() const
CharUnits - This is an opaque type for sizes expressed in character units.
bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str)
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing, variable initialization, and function return values.
void PopParsingDeclaration(ParsingDeclState state, Decl *decl)
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID...
static bool checkTryLockFunAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, SmallVectorImpl< Expr *> &Args)
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
static void handleWeakImportAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool attrNonNullArgCheck(Sema &S, QualType T, const ParsedAttr &AL, SourceRange AttrParmRange, SourceRange TypeRange, bool isReturnValue=false)
bool existsInTarget(const TargetInfo &Target) const
void steal(DelayedDiagnosticPool &pool)
Steal the diagnostics from the given pool.
bool isClassReceiver() const
static void handleObjCOwnershipAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleExtVectorTypeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
unsigned getMinArgs() const
Scope - A scope is a transient data structure that is used while parsing the program.
static void handleTestTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL)
field_iterator field_begin() const
static bool shouldDiagnoseAvailabilityByDefault(const ASTContext &Context, const VersionTuple &DeploymentVersion, const VersionTuple &DeclVersion)
bool hasVariadicArg() const
static bool checkForConsumableClass(Sema &S, const CXXMethodDecl *MD, const ParsedAttr &AL)
Represents information about a change in availability for an entity, which is part of the encoding of...
void ProcessDeclAttributeDelayed(Decl *D, const ParsedAttributesView &AttrList)
static void handleOpenCLNoSVMAttr(Sema &S, Decl *D, const ParsedAttr &AL)
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
const LangOptions & getLangOpts() const
static void handleAnalyzerNoReturnAttr(Sema &S, Decl *D, const ParsedAttr &AL)
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
static void handleAssertCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
virtual unsigned getRegisterWidth() const
Return the "preferred" register width on this target.
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
Represents an ObjC class declaration.
static void EmitAvailabilityWarning(Sema &S, AvailabilityResult AR, const NamedDecl *ReferringDecl, const NamedDecl *OffendingDecl, StringRef Message, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass, const ObjCPropertyDecl *ObjCProperty, bool ObjCPropertyAccess)
static void handleConsumableAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleMipsInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL)
VersionTuple Version
The version number at which the change occurred.
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified=false, bool hasWrittenPrototype=true, bool isConstexprSpecified=false)
const LangOptions & LangOpts
This parameter (which must have pointer-to-pointer type) uses the special Swift error-result ABI trea...
bool hasCustomParsing() const
static SourceRange getFunctionOrMethodParamRange(const Decl *D, unsigned Idx)
void AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, unsigned SpellingListIndex, bool IsPackExpansion)
AddAlignedAttr - Adds an aligned attribute to a particular declaration.
This object can be modified without requiring retains or releases.
param_iterator param_begin()
Represents the this expression in C++.
void setInvalid(bool b=true) const
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 bool checkGuardedByAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, Expr *&Arg)
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
AvailabilityResult
Captures the result of checking the availability of a declaration.
static void handleDLLAttr(Sema &S, Decl *D, const ParsedAttr &A)
static void handleFormatAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Handle attribute((format(type,idx,firstarg))) attributes based on http://gcc.gnu.org/onlinedocs/gcc/F...
static void handleAlignedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
unsigned getFlags() const
getFlags - Return the flags for this scope.
llvm::StringRef getParameterABISpelling(ParameterABI kind)
bool canBeWeakImported(bool &IsDefinition) const
Determines whether this symbol can be weak-imported, e.g., whether it would be well-formed to add the...
static bool checkAttributeAtLeastNumArgs(Sema &S, const ParsedAttr &AL, unsigned Num)
Check if the attribute has at least as many args as Num.
Sema - This implements semantic analysis and AST building for C.
SourceLocation getLocEnd() const LLVM_READONLY
CompoundStmt - This represents a group of statements like { stmt stmt }.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
static void handleDestructorAttr(Sema &S, Decl *D, const ParsedAttr &AL)
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple(), StringRef *RealizedPlatform=nullptr) const
Determine the availability of the given declaration.
static void handleObjCBoxable(Sema &S, Decl *D, const ParsedAttr &AL)
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
static bool checkAttributeNumArgs(Sema &S, const ParsedAttr &AL, unsigned Num)
Check if the attribute has exactly as many args as Num.
static void handleEnableIfAttr(Sema &S, Decl *D, const ParsedAttr &AL)
DeclarationNameTable DeclarationNames
static void checkAttrArgsAreCapabilityObjs(Sema &S, Decl *D, const ParsedAttr &AL, SmallVectorImpl< Expr *> &Args, int Sidx=0, bool ParamIdxOk=false)
Checks that all attribute arguments, starting from Sidx, resolve to a capability object.
static void handleMinVectorWidthAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleParamTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL)
const ParsedAttributesView & getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
static void handleNoDebugAttr(Sema &S, Decl *D, const ParsedAttr &AL)
const FunctionType * getFunctionType(bool BlocksToo=true) const
Looks through the Decl's underlying type to extract a FunctionType when possible. ...
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static void handleAliasAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Captures information about a #pragma weak directive.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
void AddAlignValueAttr(SourceRange AttrRange, Decl *D, Expr *E, unsigned SpellingListIndex)
AddAlignValueAttr - Adds an align_value attribute to a particular declaration.
Exposes information about the current target.
static void handleTryAcquireCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
const ObjCInterfaceDecl * getUnknownObjCClass() const
static bool isForbiddenTypeAllowed(Sema &S, Decl *D, const DelayedDiagnostic &diag, UnavailableAttr::ImplicitReason &reason)
Is the given declaration allowed to use a forbidden type? If so, it'll still be annotated with an att...
static bool isCFStringType(QualType T, ASTContext &Ctx)
SourceLocation getBeginLoc() const
Get the begin source location.
static void handleIBOutlet(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAlwaysInlineAttr(Sema &S, Decl *D, const ParsedAttr &AL)
void popWithoutEmitting(DelayedDiagnosticsState state)
Leave a delayed-diagnostic state that was previously pushed.
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorType::VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
virtual bool hasProtectedVisibility() const
Does this target support "protected" visibility?
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Expr - This represents one expression.
static SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset, const SourceManager &SM, const LangOptions &LangOpts)
Computes the source location just past the end of the token at this source location.
Represents a character-granular source range.
bool isVariadic() const
Whether this function is variadic.
DLLImportAttr * mergeDLLImportAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
static void handleAllocAlignAttr(Sema &S, Decl *D, const ParsedAttr &AL)
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
static bool hasDeclarator(const Decl *D)
Return true if the given decl has a declarator that should have been processed by Sema::GetTypeForDec...
static void handleObjCRequiresSuperAttr(Sema &S, Decl *D, const ParsedAttr &Attrs)
static SourceLocation findLocationAfterToken(SourceLocation loc, tok::TokenKind TKind, const SourceManager &SM, const LangOptions &LangOpts, bool SkipTrailingWhitespaceAndNewLine)
Checks that the given token is the first token that occurs after the given location (this excludes co...
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that the type refers to...
static bool isCapabilityExpr(Sema &S, const Expr *Ex)
This file defines the classes used to store parsed information about declaration-specifiers and decla...
static void handleNonNullAttr(Sema &S, Decl *D, const ParsedAttr &AL)
const T * castAs() const
Member-template castAs<specific type>.
bool CheckCallingConvAttr(const ParsedAttr &attr, CallingConv &CC, const FunctionDecl *FD=nullptr)
const Stmt * getThen() const
static void handleSharedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
bool isObjCRetainableType() const
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
void DiagnoseUnguardedAvailabilityViolations(Decl *FD)
Issue any -Wunguarded-availability warnings in FD.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
const AvailabilityChange & getAvailabilityObsoleted() const
Defines the clang::Preprocessor interface.
static bool typeHasCapability(Sema &S, QualType Ty)
static bool checkAcquireOrderAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, SmallVectorImpl< Expr *> &Args)
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
field_iterator field_end() const
bool isFileContext() const
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
DeclContext * getDeclContext()
void CheckAlignasUnderalignment(Decl *D)
CXXRecordDecl * getDefinition() const
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
virtual void AssignInheritanceModel(CXXRecordDecl *RD)
Callback invoked when an MSInheritanceAttr has been attached to a CXXRecordDecl.
static void handleIBOutletCollection(Sema &S, Decl *D, const ParsedAttr &AL)
unsigned short getMaxTLSAlign() const
Return the maximum alignment (in bits) of a TLS variable.
FunctionDecl * ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, bool Complain=false, DeclAccessPair *Found=nullptr)
Given an expression that refers to an overloaded function, try to resolve that overloaded function ex...
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
MSInheritanceAttr * mergeMSInheritanceAttr(Decl *D, SourceRange Range, bool BestCase, unsigned AttrSpellingListIndex, MSInheritanceAttr::Spelling SemanticSpelling)
static void handleNoCfCheckAttr(Sema &S, Decl *D, const ParsedAttr &Attrs)
static void handleWarnUnusedResult(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNSReturnsRetainedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
DeclContext * getParent()
getParent - Returns the containing DeclContext.
An expression that sends a message to the given Objective-C object or class.
static bool isNSStringType(QualType T, ASTContext &Ctx)
Preprocessor & getPreprocessor() const
Represents a GCC generic vector type.
bool CheckAttrNoArgs(const ParsedAttr &CurrAttr)
static void handleParameterABIAttr(Sema &S, Decl *D, const ParsedAttr &Attrs, ParameterABI Abi)
unsigned getNumArgs() const
static void handleOpenCLAccessAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Wraps an identifier and optional source location for the identifier.
InternalLinkageAttr * mergeInternalLinkageAttr(Decl *D, SourceRange Range, IdentifierInfo *Ident, unsigned AttrSpellingListIndex)
static void handleNoSanitizeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
static bool isValidSwiftIndirectResultType(QualType Ty)
Pointers and references in the default address space.
SourceLocation getLocation() const
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static CharSourceRange getCharRange(SourceRange R)
bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type)
bool getLayoutCompatible() const
This is a scope that corresponds to the parameters within a function prototype for a function declara...
bool isVoidPointerType() const
SourceLocation getEllipsisLoc() const
static const RecordType * getRecordType(QualType QT)
Checks that the passed in QualType either is of RecordType or points to RecordType.
unsigned getSemanticSpelling() const
If the parsed attribute has a semantic equivalent, and it would have a semantic Spelling enumeration ...
RecordDecl * getDecl() const
static bool checkAttributeAtMostNumArgs(Sema &S, const ParsedAttr &AL, unsigned Num)
Check if the attribute has at most as many args as Num.
SourceLocation getLocStart() const LLVM_READONLY
ArrayRef< SourceLocation > getAvailabilitySelectorLocs() const
static Expr * makeLaunchBoundsArgExpr(Sema &S, Expr *E, const CUDALaunchBoundsAttr &AL, const unsigned Idx)
unsigned getASTIndex() const
Get the parameter index as it would normally be encoded at the AST level of representation: zero-orig...
A parameter attribute which changes the argument-passing ABI rule for the parameter.
static bool isFunctionOrMethodOrBlock(const Decl *D)
Return true if the given decl has function type (function or function-typed variable) or an Objective...
There is no lifetime qualification on this type.
static bool checkRecordTypeForCapability(Sema &S, QualType Ty)
Assigning into this object requires the old value to be released and the new value to be retained...
static FormatAttrKind getFormatAttrKind(StringRef Format)
getFormatAttrKind - Map from format attribute names to supported format types.
bool isBuiltinType() const
Helper methods to distinguish type categories.
void DiagnoseAvailabilityOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass, bool ObjCPropertyAccess, bool AvoidPartialAvailabilityChecks=false)
not a target-specific vector type
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
LLVM_READONLY bool isValidIdentifier(StringRef S, bool AllowDollar=false)
Return true if this is a valid ASCII identifier.
static void handleLockReturnedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
static void handleObjCBridgeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
ASTContext & getASTContext() const
StringRef getPlatformName() const
Retrieve the name of the platform as it is used in the availability attribute.
unsigned getForbiddenTypeDiagnostic() const
The diagnostic ID to emit.
VersionTuple getVersionIntroduced() const
Retrieve the version of the target platform in which this declaration was introduced.
Encodes a location in the source.
unsigned getForbiddenTypeArgument() const
static void handleRestrictAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAbiTagAttr(Sema &S, Decl *D, const ParsedAttr &AL)
QualType getReturnType() const
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
LangAS getAddressSpace() const
Return the address space of this type.
const ParsedType & getTypeArg() const
DLLExportAttr * mergeDLLExportAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
void setUsed(bool Used=true)
std::string getNameAsString() const
Get a human-readable name for the declaration, even if it is one of the special kinds of names (C++ c...
DeclarationName getName() const
getName - Returns the embedded declaration name.
Represents the declaration of a struct/union/class/enum.
SourceLocation getLocStart() const LLVM_READONLY
void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AL, bool IncludeCXX11Attributes=true)
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
CommonAttr * mergeCommonAttr(Decl *D, SourceRange Range, IdentifierInfo *Ident, unsigned AttrSpellingListIndex)
IdentifierTable & getIdentifierTable()
ParsedAttr - Represents a syntactic attribute.
reverse_body_iterator body_rend()
static void handleAttrWithMessage(Sema &S, Decl *D, const ParsedAttr &AL)
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
static void handleObjCSuppresProtocolAttr(Sema &S, Decl *D, const ParsedAttr &AL)
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs. ...
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
Represents a static or instance method of a struct/union/class.
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
bool hasProcessingCache() const
static void handleAMDGPUNumVGPRAttr(Sema &S, Decl *D, const ParsedAttr &AL)
bool isUsedAsTypeAttr() const
const ParmVarDecl * getParamDecl(unsigned i) const
static T * mergeVisibilityAttr(Sema &S, Decl *D, SourceRange range, typename T::VisibilityType value, unsigned attrSpellingListIndex)
static void handleCPUSpecificAttr(Sema &S, Decl *D, const ParsedAttr &AL)
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
static bool checkLockFunAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, SmallVectorImpl< Expr *> &Args)
void push_back(const T &LocalValue)
CUDADiagBuilder CUDADiagIfHostCode(SourceLocation Loc, unsigned DiagID)
Creates a CUDADiagBuilder that emits the diagnostic if the current context is "used as host code"...
static void handleAssertExclusiveLockAttr(Sema &S, Decl *D, const ParsedAttr &AL)
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
pool_iterator pool_end() const
bool isObjCObjectPointerType() const
bool isAnyPointerType() const
bool isArgExpr(unsigned Arg) const
bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl, const ParsedAttributesView &AttrList)
bool diagnoseLangOpts(class Sema &S) const
AvailabilityResult getAvailabilityResult() const
Represents one property declaration in an Objective-C interface.
static void handleAMDGPUWavesPerEUAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleDelayedAvailabilityCheck(Sema &S, DelayedDiagnostic &DD, Decl *Ctx)
const ObjCMethodDecl * getMethodDecl() const
bool isVectorType() const
static void handleReturnsNonNullAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Assigning into this object requires a lifetime extension.
static void handleUuidAttr(Sema &S, Decl *D, const ParsedAttr &AL)
ParameterABI
Kinds of parameter ABI.
CUDAFunctionTarget CurrentCUDATarget()
Gets the CUDA target for the current context.
SourceRange getRange() const
SourceLocation getLocEnd() const LLVM_READONLY
static void handleVecReturnAttr(Sema &S, Decl *D, const ParsedAttr &AL)
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
static Optional< AttributeInsertion > createAttributeInsertion(const NamedDecl *D, const SourceManager &SM, const LangOptions &LangOpts)
Returns a source location in which it's appropriate to insert a new attribute for the given declarati...
StringRef getName() const
Return the actual identifier string.
bool isMacroDefined(StringRef Id)
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current target.
void setProcessingCache(unsigned value) const
Base class for declarations which introduce a typedef-name.
static bool normalizeName(StringRef &AttrName)
Normalize the attribute, foo becomes foo.
static void handleExternalSourceSymbolAttr(Sema &S, Decl *D, const ParsedAttr &AL)
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
static DelayedDiagnostic makeAvailability(AvailabilityResult AR, ArrayRef< SourceLocation > Locs, const NamedDecl *ReferringDecl, const NamedDecl *OffendingDecl, const ObjCInterfaceDecl *UnknownObjCClass, const ObjCPropertyDecl *ObjCProperty, StringRef Msg, bool ObjCPropertyAccess)
static bool isStaticOverloadedOperator(OverloadedOperatorKind OOK)
Returns true if the given operator is implicitly static in a record context.
Dataflow Directional Tag Classes.
void checkUnusedDeclAttributes(Declarator &D)
checkUnusedDeclAttributes - Given a declarator which is not being used to build a declaration...
bool isValid() const
Return true if this is a valid SourceLocation object.
Don't merge availability attributes at all.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
QualType getForbiddenTypeOperand() const
virtual char CPUSpecificManglingCharacter(StringRef Name) const
static void handleLayoutVersion(Sema &S, Decl *D, const ParsedAttr &AL)
static unsigned getNumAttributeArgs(const ParsedAttr &AL)
ASTMutationListener * getASTMutationListener() const
static void handleDeclspecThreadAttr(Sema &S, Decl *D, const ParsedAttr &AL)
void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, WeakInfo &W)
DeclApplyPragmaWeak - A declaration (maybe definition) needs #pragma weak applied to it...
static void handleReturnTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAVRInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool handleCommonAttributeFeatures(Sema &S, Decl *D, const ParsedAttr &AL)
Handles semantic checking for features that are common to all attributes, such as checking whether a ...
void ProcessPragmaWeak(Scope *S, Decl *D)
const AvailabilityChange & getAvailabilityIntroduced() const
static bool checkParamIsIntegerType(Sema &S, const FunctionDecl *FD, const AttrInfo &AI, unsigned AttrArgNo)
Checks to be sure that the given parameter number is in bounds, and is an integral type...
NamedDecl * DeclClonePragmaWeak(NamedDecl *ND, IdentifierInfo *II, SourceLocation Loc)
DeclClonePragmaWeak - clone existing decl (maybe definition), #pragma weak needs a non-definition dec...
static void handleAssertSharedLockAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAvailabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleX86ForceAlignArgPointerAttr(Sema &S, Decl *D, const ParsedAttr &AL)
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, bool BestCase, MSInheritanceAttr::Spelling SemanticSpelling)
SectionAttr * mergeSectionAttr(Decl *D, SourceRange Range, StringRef Name, unsigned AttrSpellingListIndex)
A runtime availability query.
SmallVectorImpl< DelayedDiagnostic >::const_iterator pool_iterator
bool isPackExpansion() const
static void handleCallableWhenAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleNakedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
DeclarationName - The name of a declaration.
StmtClass getStmtClass() const
bool isMicrosoftAttribute() const
SourceLocation getLoc() const
bool isBooleanType() const
void AddNSConsumedAttr(SourceRange AttrRange, Decl *D, unsigned SpellingListIndex, bool isNSConsumed, bool isTemplateInstantiation)
SourceLocation getStrictLoc() const
static void handleDiagnoseIfAttr(Sema &S, Decl *D, const ParsedAttr &AL)
VisibilityAttr * mergeVisibilityAttr(Decl *D, SourceRange Range, VisibilityAttr::VisibilityType Vis, unsigned AttrSpellingListIndex)
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
static bool ShouldDiagnoseAvailabilityInContext(Sema &S, AvailabilityResult K, VersionTuple DeclVersion, Decl *Ctx)
whether we should emit a diagnostic for K and DeclVersion in the context of Ctx.
static void handleTransparentUnionAttr(Sema &S, Decl *D, const ParsedAttr &AL)
IdentifierInfo * getName() const
static void handleSetTypestateAttr(Sema &S, Decl *D, const ParsedAttr &AL)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
NamedDecl * getCurFunctionOrMethodDecl()
getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method or C function we're in...
SanitizerMask parseSanitizerValue(StringRef Value, bool AllowGroups)
Parse a single value from a -fsanitize= or -fno-sanitize= value list.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
static void handlePtGuardedByAttr(Sema &S, Decl *D, const ParsedAttr &AL)
const AvailabilityChange & getAvailabilityDeprecated() const
param_iterator param_end()
llvm::APInt getValue() const
LLVM_READONLY bool isHexDigit(unsigned char c)
Return true if this character is an ASCII hex digit: [0-9a-fA-F].
static bool checkAttributeNumArgsImpl(Sema &S, const ParsedAttr &AL, unsigned Num, unsigned Diag, Compare Comp)
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated", "unavailable", and "availability").
Represents a pointer to an Objective C object.
static bool checkAvailabilityAttr(Sema &S, SourceRange Range, IdentifierInfo *Platform, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted)
static void handleDelayedForbiddenType(Sema &S, DelayedDiagnostic &DD, Decl *D)
Handle a delayed forbidden-type diagnostic.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
static void handleNoEscapeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
static void handlePassObjectSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleSharedTrylockFunctionAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkCodeSegName(Sema &S, SourceLocation LiteralLoc, StringRef CodeSegName)
void add(const sema::DelayedDiagnostic &diag)
Adds a delayed diagnostic.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
static bool isFunctionOrMethod(const Decl *D)
isFunctionOrMethod - Return true if the given decl has function type (function or function-typed vari...
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const ParsedAttr &AL, bool IncludeCXX11Attributes)
ProcessDeclAttribute - Apply the specific attribute to the specified decl if the attribute applies to...
DeclContext * getCurLexicalContext() const
static void handleRequiresCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleLocksExcludedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
virtual bool isValidCPUName(StringRef Name) const
brief Determine whether this TargetInfo supports the given CPU name.
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
static void handleUnusedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleEnumExtensibilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
SourceLocation getLocStart() const LLVM_READONLY
SourceLocation getEnd() const
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.
static bool threadSafetyCheckIsPointer(Sema &S, const Decl *D, const ParsedAttr &AL)
Check if passed in Decl is a pointer type.
static void handleSubGroupSize(Sema &S, Decl *D, const ParsedAttr &AL)
static bool checkFunctionConditionAttr(Sema &S, Decl *D, const ParsedAttr &AL, Expr *&Cond, StringRef &Msg)
CharSourceRange getExpansionRange(SourceLocation Loc) const
Given a SourceLocation object, return the range of tokens covered by the expansion in the ultimate fi...
const DelayedDiagnosticPool * getParent() const
Represents a base class of a C++ class.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
SourceManager & getSourceManager()
bool isObjCObjectType() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
static void handleWeakRefAttr(Sema &S, Decl *D, const ParsedAttr &AL)
bool CheckAttrTarget(const ParsedAttr &CurrAttr)
static void handleIFuncAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
static void DoEmitAvailabilityWarning(Sema &S, AvailabilityResult K, Decl *Ctx, const NamedDecl *ReferringDecl, const NamedDecl *OffendingDecl, StringRef Message, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass, const ObjCPropertyDecl *ObjCProperty, bool ObjCPropertyAccess)
Actually emit an availability diagnostic for a reference to an unavailable decl.
static void handleBlocksAttr(Sema &S, Decl *D, const ParsedAttr &AL)
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
static void handleObjCReturnsInnerPointerAttr(Sema &S, Decl *D, const ParsedAttr &Attrs)
unsigned getMaxArgs() const
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
Reading or writing from this object requires a barrier call.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
TranslationUnitDecl * getTranslationUnitDecl() const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
static bool isInstanceMethod(const Decl *D)
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in it, apply them to D...
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
Represents a C++ struct/union/class.
Compatible - the types are compatible according to the standard.
static void handleObjCPreciseLifetimeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleAlignValueAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleDeprecatedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static unsigned getFunctionOrMethodNumParams(const Decl *D)
getFunctionOrMethodNumParams - Return number of function or method parameters.
SourceLocation getSelectorStartLoc() const
reverse_body_iterator body_rbegin()
static void handleSectionAttr(Sema &S, Decl *D, const ParsedAttr &AL)
A diagnostic message which has been conditionally emitted pending the complete parsing of the current...
bool isTLSSupported() const
Whether the target supports thread-local storage.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
static void handlePackedAttr(Sema &S, Decl *D, const ParsedAttr &AL)
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
void AddLaunchBoundsAttr(SourceRange AttrRange, Decl *D, Expr *MaxThreads, Expr *MinBlocks, unsigned SpellingListIndex)
AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular declaration. ...
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
This class is used for builtin types like 'int'.
static void handleAMDGPUFlatWorkGroupSizeAttr(Sema &S, Decl *D, const ParsedAttr &AL)
SourceLocation getLocEnd() const LLVM_READONLY
static SourceRange getFunctionOrMethodResultSourceRange(const Decl *D)
SourceManager & getSourceManager() const
static void checkUnusedDeclAttributes(Sema &S, const ParsedAttributesView &A)
checkUnusedDeclAttributes - Check a list of attributes to see if it contains any decl attributes that...
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
const Expr * getMessageExpr() const
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
void AddAllocAlignAttr(SourceRange AttrRange, Decl *D, Expr *ParamExpr, unsigned SpellingListIndex)
AddAllocAlignAttr - Adds an alloc_align attribute to a particular declaration.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
__DEVICE__ int max(int __a, int __b)
bool checkSectionName(SourceLocation LiteralLoc, StringRef Str)
QualType getRealTypeForBitwidth(unsigned DestWidth) const
getRealTypeForBitwidth - sets floating point QualTy according to specified bitwidth.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
A reference to a declared variable, function, enum, etc.
static void handleAMDGPUNumSGPRAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static void handleReleaseCapabilityAttr(Sema &S, Decl *D, const ParsedAttr &AL)
NamedDecl * getMostRecentDecl()
static QualType getFunctionOrMethodParamType(const Decl *D, unsigned Idx)
bool isPointerType() const
static NamedDecl * findEnclosingDeclToAnnotate(Decl *OrigCtx)
bool checkStringLiteralArgumentAttr(const ParsedAttr &Attr, unsigned ArgNum, StringRef &Str, SourceLocation *ArgLocation=nullptr)
Check if the argument ArgNum of Attr is a ASCII string literal.
SourceLocation getReceiverLocation() const
void NoteAllOverloadCandidates(Expr *E, QualType DestType=QualType(), bool TakingAddress=false)
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static const AvailabilityAttr * getAttrForPlatform(ASTContext &Context, const Decl *D)
class clang::Sema::DelayedDiagnostics DelayedDiagnostics
A collection of diagnostics which were delayed.
void setIsMultiVersion(bool V=true)
Sets the multiversion state for this declaration and all of its redeclarations.
static bool isPotentialConstantExprUnevaluated(Expr *E, const FunctionDecl *FD, SmallVectorImpl< PartialDiagnosticAt > &Diags)
isPotentialConstantExprUnevaluted - Return true if this expression might be usable in a constant expr...
bool isFloatingType() const
const Expr * getCond() const
bool isArgIdent(unsigned Arg) const
A trivial tuple used to represent a source range.
void setLexicalDeclContext(DeclContext *DC)
static std::pair< AvailabilityResult, const NamedDecl * > ShouldDiagnoseAvailabilityOfDecl(const NamedDecl *D, std::string *Message)
The diagnostic we should emit for D, and the declaration that originated it, or AR_Available.
AlwaysInlineAttr * mergeAlwaysInlineAttr(Decl *D, SourceRange Range, IdentifierInfo *Ident, unsigned AttrSpellingListIndex)
This represents a decl that may have a name.
static bool isFunctionOrMethodVariadic(const Decl *D)
static bool isObjCNSObjectType(QualType Ty)
Return true if this is an NSObject object with its NSObject attribute set.
Describes an entity that is being initialized.
static void handleRISCVInterruptAttr(Sema &S, Decl *D, const ParsedAttr &AL)
bool isFunctionPointerType() const
void setHasDesignatedInitializers()
Indicate that this interface decl contains at least one initializer marked with the 'objc_designated_...
StringRef getAvailabilityMessage() const
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
SourceLocation getBegin() const
SourceLocation getUnavailableLoc() const
const LangOptions & getLangOpts() const
AttributeDeclKind
These constants match the enumerated choices of warn_attribute_wrong_decl_type and err_attribute_wron...
static bool checkAttrMutualExclusion(Sema &S, Decl *D, SourceRange Range, IdentifierInfo *Ident)
Diagnose mutually exclusive attributes when present on a given declaration.
This class handles loading and caching of source files into memory.
AvailabilityAttr * mergeAvailabilityAttr(NamedDecl *D, SourceRange Range, IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK, unsigned AttrSpellingListIndex)
Attribute merging methods. Return true if a new attribute was added.
static void handleObjCBridgeMutableAttr(Sema &S, Decl *D, const ParsedAttr &AL)
static bool isValidSubjectOfNSReturnsRetainedAttribute(QualType QT)
IdentifierLoc * getArgAsIdent(unsigned Arg) const
static void handleConstructorAttr(Sema &S, Decl *D, const ParsedAttr &AL)
Attr - This represents one attribute.
ParsedAttributes & getAttributes()
SourceLocation getLocation() const
bool isBeingDefined() const
Return true if this decl is currently being defined.
This parameter (which must have pointer type) is a Swift indirect result parameter.
virtual unsigned getUnwindWordWidth() const
virtual bool validateCPUSpecificCPUDispatch(StringRef Name) const
IdentifierInfo * getScopeName() const
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type...
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth, signed/unsigned.
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
unsigned getProcessingCache() const
const Expr * getReplacementExpr() const
static Optional< unsigned > tryParseObjCMethodName(StringRef Name, SmallVectorImpl< StringRef > &SlotNames, const LangOptions &LangOpts)
Tries to parse a string as ObjC method name.
static void handleSimpleAttributeWithExclusions(Sema &S, Decl *D, const ParsedAttr &AL)