32 #include "llvm/ADT/StringExtras.h"
33 #include "llvm/Support/MathExtras.h"
34 using namespace clang;
37 namespace AttributeLangSupport {
65 return isa<DeclaratorDecl>(D) || isa<BlockDecl>(D) || isa<TypedefNameDecl>(D) ||
66 isa<ObjCPropertyDecl>(D);
74 return isa<FunctionProtoType>(FnTy);
75 return isa<ObjCMethodDecl>(D) || isa<BlockDecl>(D);
83 return cast<FunctionProtoType>(FnTy)->getNumParams();
84 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D))
85 return BD->getNumParams();
86 return cast<ObjCMethodDecl>(D)->param_size();
91 return cast<FunctionProtoType>(FnTy)->getParamType(Idx);
92 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D))
93 return BD->getParamDecl(Idx)->getType();
95 return cast<ObjCMethodDecl>(D)->parameters()[Idx]->getType();
99 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
100 return FD->getParamDecl(Idx)->getSourceRange();
101 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
102 return MD->parameters()[Idx]->getSourceRange();
103 if (
const auto *BD = dyn_cast<BlockDecl>(D))
104 return BD->getParamDecl(Idx)->getSourceRange();
110 return cast<FunctionType>(FnTy)->getReturnType();
111 return cast<ObjCMethodDecl>(D)->getReturnType();
115 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
116 return FD->getReturnTypeSourceRange();
117 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
118 return MD->getReturnTypeSourceRange();
127 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D))
128 return BD->isVariadic();
130 return cast<ObjCMethodDecl>(D)->isVariadic();
134 if (
const CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(D))
135 return MethodDecl->isInstance();
151 return ClsName == &Ctx.
Idents.
get(
"NSString") ||
152 ClsName == &Ctx.
Idents.
get(
"NSMutableString");
176 template <
typename Compare>
178 unsigned Num,
unsigned Diag,
193 diag::err_attribute_wrong_number_arguments,
194 std::not_equal_to<unsigned>());
202 diag::err_attribute_too_few_arguments,
203 std::less<unsigned>());
211 diag::err_attribute_too_many_arguments,
212 std::greater<unsigned>());
224 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
226 << Expr->getSourceRange();
228 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type)
230 << Expr->getSourceRange();
236 << I.toString(10,
false) << 32 << 1;
240 Val = (uint32_t)I.getZExtValue();
246 template <
typename AttrTy>
249 if (AttrTy *A = D->
getAttr<AttrTy>()) {
250 S.
Diag(Range.
getBegin(), diag::err_attributes_are_not_compatible) << Ident
252 S.
Diag(A->getLocation(), diag::note_conflicting_attribute);
280 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
282 << IdxExpr->getSourceRange();
286 Idx = IdxInt.getLimitedValue();
287 if (Idx < 1 || (!IV && Idx > NumParams)) {
288 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_out_of_bounds)
289 << Attr.
getName() << AttrArgNum << IdxExpr->getSourceRange();
293 if (HasImplicitThisParam) {
296 diag::err_attribute_invalid_implicit_this_argument)
297 << Attr.
getName() << IdxExpr->getSourceRange();
311 unsigned ArgNum, StringRef &Str,
316 Diag(Loc->
Loc, diag::err_attribute_argument_type)
322 *ArgLocation = Loc->
Loc;
330 *ArgLocation = ArgExpr->getLocStart();
332 if (!Literal || !Literal->
isAscii()) {
333 Diag(ArgExpr->getLocStart(), diag::err_attribute_argument_type)
344 template <
typename AttrType>
351 template <
typename AttrType>
354 handleSimpleAttribute<AttrType>(
S, D, Attr);
359 template <
typename AttrType,
typename IncompatibleAttrType,
360 typename... IncompatibleAttrTypes>
363 if (checkAttrMutualExclusion<IncompatibleAttrType>(S, D, Attr.
getRange(),
398 const ValueDecl *vd = cast<ValueDecl>(D);
400 if (QT->isAnyPointerType())
407 if (RT->isIncompleteType())
414 S.
Diag(Attr.
getLoc(), diag::warn_thread_attribute_decl_not_pointer)
449 if (RD->
hasAttr<CapabilityAttr>())
457 return Type->getDecl()->hasAttr<CapabilityAttr>();
473 return TN->
hasAttr<CapabilityAttr>();
492 if (
const auto *
E = dyn_cast<DeclRefExpr>(Ex))
494 else if (
const auto *
E = dyn_cast<CastExpr>(Ex))
496 else if (
const auto *
E = dyn_cast<ParenExpr>(Ex))
498 else if (
const auto *
E = dyn_cast<UnaryOperator>(Ex)) {
502 }
else if (
const auto *
E = dyn_cast<BinaryOperator>(Ex)) {
521 bool ParamIdxOk =
false) {
522 for (
unsigned Idx = Sidx; Idx < Attr.
getNumArgs(); ++Idx) {
527 Args.push_back(ArgExp);
531 if (
StringLiteral *StrLit = dyn_cast<StringLiteral>(ArgExp)) {
532 if (StrLit->getLength() == 0 ||
533 (StrLit->isAscii() && StrLit->getString() == StringRef(
"*"))) {
536 Args.push_back(ArgExp);
542 S.
Diag(Attr.
getLoc(), diag::warn_thread_attribute_ignored) <<
544 Args.push_back(ArgExp);
554 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(UOp->getSubExpr()))
555 if (DRE->getDecl()->isCXXInstanceMember())
556 ArgTy = DRE->getDecl()->getType();
562 if(!RT && ParamIdxOk) {
567 llvm::APInt ArgValue = IL->getValue();
568 uint64_t ParamIdxFromOne = ArgValue.getZExtValue();
569 uint64_t ParamIdxFromZero = ParamIdxFromOne - 1;
570 if(!ArgValue.isStrictlyPositive() || ParamIdxFromOne > NumParams) {
571 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_out_of_range)
572 << Attr.
getName() << Idx + 1 << NumParams;
584 S.
Diag(Attr.
getLoc(), diag::warn_thread_attribute_argument_not_lockable)
587 Args.push_back(ArgExp);
611 unsigned Size = Args.size();
650 QualType QT = cast<ValueDecl>(D)->getType();
652 S.
Diag(Attr.
getLoc(), diag::warn_thread_attribute_decl_not_lockable)
671 Expr **StartArg = &Args[0];
674 StartArg, Args.size(),
684 Expr **StartArg = &Args[0];
687 StartArg, Args.size(),
707 unsigned Size = Args.size();
708 Expr **StartArg = Size == 0 ?
nullptr : &Args[0];
720 unsigned Size = Args.size();
721 Expr **StartArg = Size == 0 ?
nullptr : &Args[0];
736 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
756 Args.data(), Args.size(),
776 unsigned Size = Args.size();
793 unsigned Size = Args.size();
796 Expr **StartArg = &Args[0];
809 Cond = Converted.
get();
820 S.
Diag(Attr.
getLoc(), diag::err_enable_if_never_constant_expr);
821 for (
int I = 0, N = Diags.size();
I != N; ++
I)
822 S.
Diag(Diags[
I].first, Diags[I].second);
833 if (D->
hasAttr<PassObjectSizeAttr>()) {
848 S.
Diag(E->getLocStart(), diag::err_attribute_argument_outof_range)
849 << Attr.
getName() << 0 << 3 << E->getSourceRange();
857 if (!cast<ParmVarDecl>(D)->getType()->isPointerType()) {
873 if (!ConsumableAttr::ConvertStrToConsumedState(IL->
Ident->
getName(),
875 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported)
880 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type)
897 if (!RD->hasAttr<ConsumableAttr>()) {
898 S.
Diag(Attr.
getLoc(), diag::warn_attr_on_unconsumable_class) <<
899 RD->getNameAsString();
918 for (
unsigned ArgIndex = 0; ArgIndex < Attr.
getNumArgs(); ++ArgIndex) {
921 StringRef StateString;
932 if (!CallableWhenAttr::ConvertStrToConsumedState(StateString,
934 S.
Diag(Loc, diag::warn_attribute_type_not_supported)
935 << Attr.
getName() << StateString;
939 States.push_back(CallableState);
956 if (!ParamTypestateAttr::ConvertStrToConsumedState(StateString,
958 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported)
959 << Attr.
getName() << StateString;
963 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type) <<
992 if (!ReturnTypestateAttr::ConvertStrToConsumedState(IL->
Ident->
getName(),
994 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported)
999 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type) <<
1043 if (!SetTypestateAttr::ConvertStrToConsumedState(Param, NewState)) {
1044 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported)
1049 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type) <<
1068 if (!TestTypestateAttr::ConvertStrToConsumedState(Param, TestState)) {
1069 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported)
1074 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type) <<
1091 if (
TagDecl *TD = dyn_cast<TagDecl>(D))
1094 else if (
FieldDecl *FD = dyn_cast<FieldDecl>(D)) {
1096 if (!FD->getType()->isDependentType() &&
1097 !FD->getType()->isIncompleteType() && FD->isBitField() &&
1099 S.
Diag(Attr.
getLoc(), diag::warn_attribute_packed_for_bitfield);
1101 FD->addAttr(::
new (S.
Context) PackedAttr(
1111 if (
const ObjCIvarDecl *VD = dyn_cast<ObjCIvarDecl>(D)) {
1113 S.
Diag(Attr.
getLoc(), diag::warn_iboutlet_object_type)
1114 << Attr.
getName() << VD->getType() << 0;
1120 S.
Diag(Attr.
getLoc(), diag::warn_iboutlet_object_type)
1121 << Attr.
getName() << PD->getType() << 1;
1147 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
1163 S.
Diag(Attr.
getLoc(), diag::err_iboutletcollection_type) <<
"NSObject";
1179 QT->
isBuiltinType() ? diag::err_iboutletcollection_builtintype
1180 : diag::err_iboutletcollection_type) << QT;
1200 if (UT && UT->getDecl()->hasAttr<TransparentUnionAttr>()) {
1202 for (
const auto *
I : UD->
fields()) {
1216 bool isReturnValue =
false) {
1219 S.
Diag(Attr.
getLoc(), diag::warn_attribute_return_pointers_only)
1220 << Attr.
getName() << AttrParmRange << TypeRange;
1222 S.
Diag(Attr.
getLoc(), diag::warn_attribute_pointers_only)
1223 << Attr.
getName() << AttrParmRange << TypeRange << 0;
1240 Ex->getSourceRange(),
1244 NonNullArgs.push_back(Idx);
1255 I !=
E && !AnyPointers; ++
I) {
1262 S.
Diag(Attr.
getLoc(), diag::warn_attribute_nonnull_no_pointers);
1265 unsigned *Start = NonNullArgs.data();
1266 unsigned Size = NonNullArgs.size();
1267 llvm::array_pod_sort(Start, Start + Size);
1279 S.
Diag(Attr.
getLoc(), diag::warn_attribute_nonnull_parm_no_args)
1317 Expr *OE,
unsigned SpellingListIndex) {
1321 AssumeAlignedAttr TmpAttr(AttrRange,
Context, E, OE, SpellingListIndex);
1325 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
1326 << &TmpAttr << AttrRange << SR;
1334 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1336 << E->getSourceRange();
1338 Diag(AttrLoc, diag::err_attribute_argument_type)
1340 << E->getSourceRange();
1344 if (!I.isPowerOf2()) {
1345 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
1346 << E->getSourceRange();
1355 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1357 << OE->getSourceRange();
1364 AssumeAlignedAttr(AttrRange,
Context, E, OE, SpellingListIndex));
1370 if (AttrName.size() > 4 && AttrName.startswith(
"__") &&
1371 AttrName.endswith(
"__")) {
1372 AttrName = AttrName.drop_front(2).drop_back(2);
1388 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
1394 OwnershipAttr::OwnershipKind K =
1400 case OwnershipAttr::Takes:
1401 case OwnershipAttr::Holds:
1403 S.
Diag(AL.
getLoc(), diag::err_attribute_too_few_arguments)
1408 case OwnershipAttr::Returns:
1410 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments)
1419 StringRef ModuleName = Module->
getName();
1425 for (
unsigned i = 1; i < AL.
getNumArgs(); ++i) {
1435 case OwnershipAttr::Takes:
1436 case OwnershipAttr::Holds:
1440 case OwnershipAttr::Returns:
1447 << Ex->getSourceRange();
1455 if (
I->getOwnKind() != K &&
I->args_end() !=
1456 std::find(
I->args_begin(),
I->args_end(), Idx)) {
1457 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
1460 }
else if (K == OwnershipAttr::Returns &&
1461 I->getOwnKind() == OwnershipAttr::Returns) {
1465 if (std::find(
I->args_begin(),
I->args_end(), Idx) ==
I->args_end()) {
1466 S.
Diag(
I->getLocation(), diag::err_ownership_returns_index_mismatch)
1467 << *(
I->args_begin()) + 1;
1469 S.
Diag(AL.
getLoc(), diag::note_ownership_returns_index_mismatch)
1470 << (
unsigned)Idx + 1 << Ex->getSourceRange();
1475 OwnershipArgs.push_back(Idx);
1478 unsigned* start = OwnershipArgs.data();
1479 unsigned size = OwnershipArgs.size();
1480 llvm::array_pod_sort(start, start + size);
1490 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
1508 if (!Ctx->isFileContext()) {
1509 S.
Diag(Attr.
getLoc(), diag::err_attribute_weakref_not_global_context)
1557 S.
Diag(Attr.
getLoc(), diag::err_alias_not_supported_on_darwin);
1562 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
1563 if (FD->isThisDeclarationADefinition()) {
1564 S.
Diag(Attr.
getLoc(), diag::err_alias_is_definition) << FD;
1568 const auto *VD = cast<VarDecl>(D);
1569 if (VD->isThisDeclarationADefinition() && VD->isExternallyVisible()) {
1570 S.
Diag(Attr.
getLoc(), diag::err_alias_is_definition) << VD;
1582 if (checkAttrMutualExclusion<HotAttr>(S, D, Attr.
getRange(), Attr.
getName()))
1590 if (checkAttrMutualExclusion<ColdAttr>(S, D, Attr.
getRange(), Attr.
getName()))
1606 if (Model !=
"global-dynamic" && Model !=
"local-dynamic"
1607 && Model !=
"initial-exec" && Model !=
"local-exec") {
1608 S.
Diag(LiteralLoc, diag::err_attr_tlsmodel_arg);
1625 S.
Diag(Attr.
getLoc(), diag::warn_attribute_return_pointers_only)
1631 S.
Diag(Attr.
getLoc(), diag::err_attribute_not_supported_in_lang)
1642 if (checkAttrMutualExclusion<DisableTailCallsAttr>(S, D, Attr.
getRange(),
1655 if (!isa<ObjCMethodDecl>(D)) {
1656 S.
Diag(attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
1686 : diag::warn_attribute_wrong_decl_type)
1722 if (VecReturnAttr *A = D->
getAttr<VecReturnAttr>()) {
1723 S.
Diag(Attr.
getLoc(), diag::err_repeat_attribute) << A;
1730 if (!isa<CXXRecordDecl>(record)) {
1731 S.
Diag(Attr.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
1735 if (!cast<CXXRecordDecl>(record)->isPOD()) {
1736 S.
Diag(Attr.
getLoc(), diag::err_attribute_vecreturn_only_pod_record);
1740 for (
const auto *
I : record->
fields()) {
1741 if ((count == 1) || !
I->getType()->isVectorType()) {
1742 S.
Diag(Attr.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
1755 if (isa<ParmVarDecl>(D)) {
1760 diag::err_carries_dependency_param_not_function_decl);
1772 if (checkAttrMutualExclusion<AlwaysInlineAttr>(S, D, Attr.
getRange(),
1782 if (checkAttrMutualExclusion<NakedAttr>(S, D, Attr.
getRange(),
1791 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1792 if (VD->hasLocalStorage()) {
1797 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
1808 uint32_t priority = ConstructorAttr::DefaultPriority;
1819 uint32_t priority = DestructorAttr::DefaultPriority;
1829 template <
typename AttrTy>
1843 if (!cast<ObjCProtocolDecl>(D)->isThisDeclarationADefinition()) {
1844 S.
Diag(Attr.
getLoc(), diag::err_objc_attr_protocol_requires_definition)
1859 StringRef PlatformName
1860 = AvailabilityAttr::getPrettyPlatformName(Platform->
getName());
1861 if (PlatformName.empty())
1862 PlatformName = Platform->
getName();
1866 if (!Introduced.
empty() && !Deprecated.
empty() &&
1867 !(Introduced <= Deprecated)) {
1868 S.
Diag(Range.
getBegin(), diag::warn_availability_version_ordering)
1874 if (!Introduced.
empty() && !Obsoleted.
empty() &&
1875 !(Introduced <= Obsoleted)) {
1876 S.
Diag(Range.
getBegin(), diag::warn_availability_version_ordering)
1882 if (!Deprecated.
empty() && !Obsoleted.
empty() &&
1883 !(Deprecated <= Obsoleted)) {
1884 S.
Diag(Range.
getBegin(), diag::warn_availability_version_ordering)
1898 bool BeforeIsOkay) {
1905 if (BeforeIsOkay && X < Y)
1919 unsigned AttrSpellingListIndex) {
1923 bool FoundAny =
false;
1924 bool OverrideOrImpl =
false;
1928 OverrideOrImpl =
false;
1933 OverrideOrImpl =
true;
1939 for (
unsigned i = 0, e = Attrs.size(); i != e;) {
1940 const AvailabilityAttr *OldAA = dyn_cast<AvailabilityAttr>(Attrs[i]);
1947 if (OldPlatform != Platform) {
1955 if (OldAA->getRange().isValid() && Range.
isInvalid()) {
1962 if (Range.
isValid() && OldAA->getRange().isInvalid()) {
1963 Attrs.erase(Attrs.begin() + i);
1972 bool OldIsUnavailable = OldAA->getUnavailable();
1974 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl) ||
1975 !
versionsMatch(Deprecated, OldDeprecated, OverrideOrImpl) ||
1977 !(OldIsUnavailable == IsUnavailable ||
1978 (OverrideOrImpl && !OldIsUnavailable && IsUnavailable))) {
1979 if (OverrideOrImpl) {
1983 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl)) {
1985 FirstVersion = OldIntroduced;
1986 SecondVersion = Introduced;
1987 }
else if (!
versionsMatch(Deprecated, OldDeprecated, OverrideOrImpl)) {
1989 FirstVersion = Deprecated;
1990 SecondVersion = OldDeprecated;
1991 }
else if (!
versionsMatch(Obsoleted, OldObsoleted, OverrideOrImpl)) {
1993 FirstVersion = Obsoleted;
1994 SecondVersion = OldObsoleted;
1998 Diag(OldAA->getLocation(),
1999 diag::warn_mismatched_availability_override_unavail)
2000 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2003 Diag(OldAA->getLocation(),
2004 diag::warn_mismatched_availability_override)
2006 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2015 Diag(OldAA->getLocation(), diag::warn_mismatched_availability);
2019 Attrs.erase(Attrs.begin() + i);
2028 if (MergedIntroduced2.
empty())
2029 MergedIntroduced2 = OldIntroduced;
2030 if (MergedDeprecated2.
empty())
2031 MergedDeprecated2 = OldDeprecated;
2032 if (MergedObsoleted2.
empty())
2033 MergedObsoleted2 = OldObsoleted;
2036 MergedIntroduced2, MergedDeprecated2,
2037 MergedObsoleted2)) {
2038 Attrs.erase(Attrs.begin() + i);
2043 MergedIntroduced = MergedIntroduced2;
2044 MergedDeprecated = MergedDeprecated2;
2045 MergedObsoleted = MergedObsoleted2;
2051 MergedIntroduced == Introduced &&
2052 MergedDeprecated == Deprecated &&
2053 MergedObsoleted == Obsoleted)
2059 MergedDeprecated, MergedObsoleted) &&
2061 return ::new (
Context) AvailabilityAttr(Range,
Context, Platform,
2062 Introduced, Deprecated,
2063 Obsoleted, IsUnavailable, Message,
2064 AttrSpellingListIndex);
2077 if (AvailabilityAttr::getPrettyPlatformName(II->
getName()).empty())
2078 S.
Diag(Platform->
Loc, diag::warn_availability_unknown_platform)
2094 Str = SE->getString();
2112 else if (II->
getName() ==
"ios_app_extension")
2117 if (Version.empty())
2120 auto NewMajor = Major >= 9 ? Major - 7 : 0;
2121 if (NewMajor >= 2) {
2122 if (Version.getMinor().hasValue()) {
2123 if (Version.getSubminor().hasValue())
2124 return VersionTuple(NewMajor, Version.getMinor().getValue(),
2125 Version.getSubminor().getValue());
2127 return VersionTuple(NewMajor, Version.getMinor().getValue());
2134 auto NewIntroduced = adjustWatchOSVersion(Introduced.
Version);
2135 auto NewDeprecated = adjustWatchOSVersion(Deprecated.
Version);
2136 auto NewObsoleted = adjustWatchOSVersion(Obsoleted.
Version);
2156 else if (II->
getName() ==
"ios_app_extension")
2177 typename T::VisibilityType value,
2178 unsigned attrSpellingListIndex) {
2179 T *existingAttr = D->
getAttr<T>();
2181 typename T::VisibilityType existingValue = existingAttr->getVisibility();
2182 if (existingValue == value)
2184 S.
Diag(existingAttr->getLocation(), diag::err_mismatched_visibility);
2185 S.
Diag(range.
getBegin(), diag::note_previous_attribute);
2188 return ::new (S.
Context) T(range, S.
Context, value, attrSpellingListIndex);
2192 VisibilityAttr::VisibilityType Vis,
2193 unsigned AttrSpellingListIndex) {
2194 return ::mergeVisibilityAttr<VisibilityAttr>(*
this, D, Range, Vis,
2195 AttrSpellingListIndex);
2199 TypeVisibilityAttr::VisibilityType Vis,
2200 unsigned AttrSpellingListIndex) {
2201 return ::mergeVisibilityAttr<TypeVisibilityAttr>(*
this, D, Range, Vis,
2202 AttrSpellingListIndex);
2206 bool isTypeVisibility) {
2208 if (isa<TypedefNameDecl>(D)) {
2215 if (isTypeVisibility &&
2216 !(isa<TagDecl>(D) ||
2217 isa<ObjCInterfaceDecl>(D) ||
2218 isa<NamespaceDecl>(D))) {
2230 VisibilityAttr::VisibilityType
type;
2231 if (!VisibilityAttr::ConvertStrToVisibilityType(TypeStr, type)) {
2232 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported)
2239 if (type == VisibilityAttr::Protected &&
2241 S.
Diag(Attr.
getLoc(), diag::warn_attribute_protected_visibility);
2242 type = VisibilityAttr::Default;
2247 if (isTypeVisibility) {
2249 (TypeVisibilityAttr::VisibilityType) type,
2262 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
2268 ObjCMethodFamilyAttr::FamilyKind F;
2269 if (!ObjCMethodFamilyAttr::ConvertStrToFamilyKind(IL->
Ident->
getName(), F)) {
2270 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported) << Attr.
getName()
2290 QualType T = TD->getUnderlyingType();
2292 S.
Diag(TD->getLocation(), diag::err_nsobject_attribute);
2299 S.
Diag(PD->getLocation(), diag::err_nsobject_attribute);
2319 QualType T = TD->getUnderlyingType();
2321 S.
Diag(TD->getLocation(), diag::warn_ptr_independentclass_attribute);
2335 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
2341 BlocksAttr::BlockType
type;
2342 if (!BlocksAttr::ConvertStrToBlockType(II->
getName(),
type)) {
2343 S.
Diag(Attr.
getLoc(), diag::warn_attribute_type_not_supported)
2354 unsigned sentinel = (
unsigned)SentinelAttr::DefaultSentinel;
2357 llvm::APSInt Idx(32);
2360 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
2362 << E->getSourceRange();
2366 if (Idx.isSigned() && Idx.isNegative()) {
2367 S.
Diag(Attr.
getLoc(), diag::err_attribute_sentinel_less_than_zero)
2368 << E->getSourceRange();
2372 sentinel = Idx.getZExtValue();
2375 unsigned nullPos = (
unsigned)SentinelAttr::DefaultNullPos;
2378 llvm::APSInt Idx(32);
2381 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
2383 << E->getSourceRange();
2386 nullPos = Idx.getZExtValue();
2388 if ((Idx.isSigned() && Idx.isNegative()) || nullPos > 1) {
2391 S.
Diag(Attr.
getLoc(), diag::err_attribute_sentinel_not_zero_or_one)
2392 << E->getSourceRange();
2399 if (isa<FunctionNoProtoType>(FT)) {
2400 S.
Diag(Attr.
getLoc(), diag::warn_attribute_sentinel_named_arguments);
2404 if (!cast<FunctionProtoType>(FT)->isVariadic()) {
2405 S.
Diag(Attr.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
2409 if (!MD->isVariadic()) {
2410 S.
Diag(Attr.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
2413 }
else if (
BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
2414 if (!BD->isVariadic()) {
2415 S.
Diag(Attr.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 1;
2418 }
else if (
const VarDecl *V = dyn_cast<VarDecl>(D)) {
2424 if (!cast<FunctionProtoType>(FT)->isVariadic()) {
2426 S.
Diag(Attr.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << m;
2430 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
2435 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
2447 S.
Diag(Attr.
getLoc(), diag::warn_attribute_void_function_method)
2452 if (MD->getReturnType()->isVoidType()) {
2453 S.
Diag(Attr.
getLoc(), diag::warn_attribute_void_function_method)
2468 S.
Diag(Attr.
getLoc(), diag::warn_attribute_invalid_on_definition)
2470 else if (isa<ObjCPropertyDecl>(D) || isa<ObjCMethodDecl>(D) ||
2472 (isa<ObjCInterfaceDecl>(D) || isa<EnumDecl>(D)))) {
2475 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
2487 template <
typename WorkGroupAttr>
2491 for (
unsigned i = 0; i < 3; ++i) {
2495 if (WGSize[i] == 0) {
2496 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_is_zero)
2497 << Attr.
getName() << E->getSourceRange();
2502 WorkGroupAttr *Existing = D->
getAttr<WorkGroupAttr>();
2503 if (Existing && !(Existing->getXDim() == WGSize[0] &&
2504 Existing->getYDim() == WGSize[1] &&
2505 Existing->getZDim() == WGSize[2]))
2509 WGSize[0], WGSize[1], WGSize[2],
2515 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
2522 assert(ParmTSI &&
"no type source info for attribute argument");
2527 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_vec_type_hint)
2532 if (VecTypeHintAttr *A = D->
getAttr<VecTypeHintAttr>()) {
2546 unsigned AttrSpellingListIndex) {
2547 if (SectionAttr *ExistingAttr = D->
getAttr<SectionAttr>()) {
2548 if (ExistingAttr->getName() ==
Name)
2550 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section);
2555 AttrSpellingListIndex);
2560 if (!Error.empty()) {
2561 Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target) <<
Error;
2580 if (!Error.empty()) {
2581 S.
Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
2597 for (
auto Str : {
"tune=",
"fpmath="})
2598 if (AttrStr.find(Str) != StringRef::npos)
2599 Diag(LiteralLoc, diag::warn_unsupported_target_attribute) << Str;
2609 TargetAttr *NewAttr =
2616 VarDecl *VD = cast<VarDecl>(D);
2629 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
2630 if (DRE->hasQualifier())
2631 S.
Diag(Loc, diag::warn_cleanup_ext);
2633 NI = DRE->getNameInfo();
2635 S.
Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 1
2640 if (ULE->hasExplicitTemplateArgs())
2641 S.
Diag(Loc, diag::warn_cleanup_ext);
2643 NI = ULE->getNameInfo();
2645 S.
Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 2
2652 S.
Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 0;
2657 S.
Diag(Loc, diag::err_attribute_cleanup_func_must_take_one_arg)
2668 S.
Diag(Loc, diag::err_attribute_cleanup_func_arg_incompatible_type)
2669 << NI.
getName() << ParamTy << Ty;
2690 if (NotNSStringTy &&
2694 S.
Diag(Attr.
getLoc(), diag::err_format_attribute_not)
2695 <<
"a string type" << IdxExpr->getSourceRange()
2704 S.
Diag(Attr.
getLoc(), diag::err_format_attribute_result_not)
2705 << (NotNSStringTy ?
"string type" :
"NSString")
2733 return llvm::StringSwitch<FormatAttrKind>(Format)
2746 .Cases(
"gcc_diag",
"gcc_cdiag",
"gcc_cxxdiag",
"gcc_tdiag",
IgnoredFormat)
2760 S.
Diag(Attr.
getLoc(), diag::err_init_priority_object_attr);
2764 QualType T = cast<VarDecl>(D)->getType();
2768 S.
Diag(Attr.
getLoc(), diag::err_init_priority_object_attr);
2774 uint32_t prioritynum;
2780 if (prioritynum < 101 || prioritynum > 65535) {
2781 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_outof_range)
2782 << E->getSourceRange() << Attr.
getName() << 101 << 65535;
2794 unsigned AttrSpellingListIndex) {
2797 if (F->getType() == Format &&
2798 F->getFormatIdx() == FormatIdx &&
2799 F->getFirstArg() == FirstArg) {
2802 if (F->getLocation().isInvalid())
2808 return ::new (
Context) FormatAttr(Range,
Context, Format, FormatIdx,
2809 FirstArg, AttrSpellingListIndex);
2816 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
2827 StringRef Format = II->
getName();
2841 S.
Diag(Attr.
getLoc(), diag::warn_attribute_type_not_supported)
2852 if (Idx < 1 || Idx > NumArgs) {
2853 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_out_of_bounds)
2854 << Attr.
getName() << 2 << IdxExpr->getSourceRange();
2859 unsigned ArgIdx = Idx - 1;
2861 if (HasImplicitThisParam) {
2864 diag::err_format_attribute_implicit_this_format_string)
2865 << IdxExpr->getSourceRange();
2876 S.
Diag(Attr.
getLoc(), diag::err_format_attribute_not)
2877 <<
"a CFString" << IdxExpr->getSourceRange()
2885 S.
Diag(Attr.
getLoc(), diag::err_format_attribute_not)
2886 <<
"an NSString" << IdxExpr->getSourceRange()
2892 S.
Diag(Attr.
getLoc(), diag::err_format_attribute_not)
2893 <<
"a string type" << IdxExpr->getSourceRange()
2905 if (FirstArg != 0) {
2909 S.
Diag(D->
getLocation(), diag::err_format_attribute_requires_variadic);
2917 if (FirstArg != 0) {
2918 S.
Diag(Attr.
getLoc(), diag::err_format_strftime_third_parameter)
2919 << FirstArgExpr->getSourceRange();
2923 }
else if (FirstArg != 0 && FirstArg != NumArgs) {
2924 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_out_of_bounds)
2925 << Attr.
getName() << 3 << FirstArgExpr->getSourceRange();
2947 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
2954 diag::warn_transparent_union_attribute_not_definition);
2960 if (Field == FieldEnd) {
2961 S.
Diag(Attr.
getLoc(), diag::warn_transparent_union_attribute_zero_fields);
2969 diag::warn_transparent_union_attribute_floating)
2976 for (; Field != FieldEnd; ++Field) {
2977 QualType FieldType = Field->getType();
2989 S.
Diag(Field->getLocation(),
2990 diag::warn_transparent_union_attribute_field_size_align)
2991 << isSize << Field->getDeclName() << FieldBits;
2992 unsigned FirstBits = isSize? FirstSize : FirstAlign;
2994 diag::note_transparent_union_first_field_size_align)
2995 << isSize << FirstBits;
3014 if (
I->getAnnotation() == Str)
3030 unsigned SpellingListIndex) {
3031 AlignValueAttr TmpAttr(AttrRange,
Context, E, SpellingListIndex);
3036 T = TD->getUnderlyingType();
3037 else if (
ValueDecl *VD = dyn_cast<ValueDecl>(D))
3040 llvm_unreachable(
"Unknown decl type for align_value");
3044 Diag(AttrLoc, diag::warn_attribute_pointer_or_reference_only)
3050 llvm::APSInt Alignment;
3053 diag::err_align_value_attribute_argument_not_int,
3058 if (!Alignment.isPowerOf2()) {
3059 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
3060 << E->getSourceRange();
3065 AlignValueAttr(AttrRange,
Context, ICE.
get(),
3066 SpellingListIndex));
3078 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
3092 diag::err_pack_expansion_without_parameter_packs);
3100 if (
const auto *TND = dyn_cast<TypedefNameDecl>(D)) {
3101 if (!TND->getUnderlyingType()->isDependentType()) {
3102 S.
Diag(Attr.
getLoc(), diag::err_alignment_dependent_typedef_name)
3103 << E->getSourceRange();
3114 unsigned SpellingListIndex,
bool IsPackExpansion) {
3115 AlignedAttr TmpAttr(AttrRange,
Context,
true, E, SpellingListIndex);
3119 if (TmpAttr.isAlignas()) {
3132 if (isa<ParmVarDecl>(D)) {
3134 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(D)) {
3137 if (VD->isExceptionVariable())
3139 }
else if (
FieldDecl *FD = dyn_cast<FieldDecl>(D)) {
3140 if (FD->isBitField())
3142 }
else if (!isa<TagDecl>(D)) {
3143 Diag(AttrLoc, diag::err_attribute_wrong_decl_type) << &TmpAttr
3148 if (DiagKind != -1) {
3149 Diag(AttrLoc, diag::err_alignas_attribute_wrong_decl_type)
3150 << &TmpAttr << DiagKind;
3157 AlignedAttr *AA = ::new (
Context) AlignedAttr(TmpAttr);
3158 AA->setPackExpansion(IsPackExpansion);
3164 llvm::APSInt Alignment;
3167 diag::err_aligned_attribute_argument_not_int,
3172 uint64_t AlignVal = Alignment.getZExtValue();
3179 if (!(TmpAttr.isAlignas() && !Alignment)) {
3180 if (!llvm::isPowerOf2_64(AlignVal)) {
3181 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
3182 << E->getSourceRange();
3188 unsigned MaxValidAlignment =
3191 if (AlignVal > MaxValidAlignment) {
3192 Diag(AttrLoc, diag::err_attribute_aligned_too_great) << MaxValidAlignment
3193 << E->getSourceRange();
3198 unsigned MaxTLSAlign =
3201 auto *VD = dyn_cast<
VarDecl>(D);
3202 if (MaxTLSAlign && AlignVal > MaxTLSAlign && VD &&
3204 Diag(VD->getLocation(), diag::err_tls_var_aligned_over_maximum)
3205 << (
unsigned)AlignVal << VD << MaxTLSAlign;
3210 AlignedAttr *AA = ::new (
Context) AlignedAttr(AttrRange,
Context,
true,
3211 ICE.
get(), SpellingListIndex);
3212 AA->setPackExpansion(IsPackExpansion);
3217 unsigned SpellingListIndex,
bool IsPackExpansion) {
3220 AlignedAttr *AA = ::new (
Context) AlignedAttr(AttrRange,
Context,
false, TS,
3222 AA->setPackExpansion(IsPackExpansion);
3227 assert(D->
hasAttrs() &&
"no attributes on decl");
3230 if (
ValueDecl *VD = dyn_cast<ValueDecl>(D)) {
3231 UnderlyingTy = DiagTy = VD->getType();
3234 if (
EnumDecl *ED = dyn_cast<EnumDecl>(D))
3235 UnderlyingTy = ED->getIntegerType();
3237 if (DiagTy->isDependentType() || DiagTy->isIncompleteType())
3244 AlignedAttr *AlignasAttr =
nullptr;
3247 if (
I->isAlignmentDependent())
3251 Align = std::max(Align,
I->getAlignment(
Context));
3254 if (AlignasAttr && Align) {
3257 if (NaturalAlign > RequestedAlign)
3258 Diag(AlignasAttr->getLocation(), diag::err_alignas_underaligned)
3259 << DiagTy << (
unsigned)NaturalAlign.
getQuantity();
3265 MSInheritanceAttr::Spelling SemanticSpelling) {
3274 if (SemanticSpelling == MSInheritanceAttr::Keyword_unspecified_inheritance)
3285 Diag(Range.
getBegin(), diag::err_mismatched_ms_inheritance)
3295 bool &IntegerMode,
bool &ComplexMode) {
3296 switch (Str.size()) {
3318 if (Str[1] ==
'F') {
3319 IntegerMode =
false;
3320 }
else if (Str[1] ==
'C') {
3321 IntegerMode =
false;
3323 }
else if (Str[1] !=
'I') {
3332 else if (Str ==
"byte")
3336 if (Str ==
"pointer")
3340 if (Str ==
"unwind_word")
3362 StringRef Str = Name->
getName();
3366 unsigned DestWidth = 0;
3367 bool IntegerMode =
true;
3368 bool ComplexMode =
false;
3369 llvm::APInt VectorSize(64, 0);
3370 if (Str.size() >= 4 && Str[0] ==
'V') {
3372 size_t StrSize = Str.size();
3373 size_t VectorStringLength = 0;
3374 while ((VectorStringLength + 1) < StrSize &&
3375 isdigit(Str[VectorStringLength + 1]))
3376 ++VectorStringLength;
3377 if (VectorStringLength &&
3378 !Str.substr(1, VectorStringLength).getAsInteger(10, VectorSize) &&
3379 VectorSize.isPowerOf2()) {
3381 IntegerMode, ComplexMode);
3382 S.
Diag(Attr.
getLoc(), diag::warn_vector_mode_deprecated);
3393 OldTy = TD->getUnderlyingType();
3394 else if (
ValueDecl *VD = dyn_cast<ValueDecl>(D))
3395 OldTy = VD->getType();
3406 OldElemTy = VT->getElementType();
3409 S.
Diag(Attr.
getLoc(), diag::err_mode_not_primitive);
3410 else if (IntegerMode) {
3412 S.
Diag(Attr.
getLoc(), diag::err_mode_wrong_type);
3413 }
else if (ComplexMode) {
3415 S.
Diag(Attr.
getLoc(), diag::err_mode_wrong_type);
3418 S.
Diag(Attr.
getLoc(), diag::err_mode_wrong_type);
3426 S.
Diag(Attr.
getLoc(), diag::err_machine_mode) << 0 << Name;
3438 if (NewElemTy.
isNull()) {
3439 S.
Diag(Attr.
getLoc(), diag::err_machine_mode) << 1 << Name;
3448 if (VectorSize.getBoolValue()) {
3454 S.
Diag(Attr.
getLoc(), diag::err_complex_mode_vector_type);
3458 OldVT->getNumElements() /
3465 S.
Diag(Attr.
getLoc(), diag::err_mode_wrong_type);
3471 TD->setModedTypeSourceInfo(TD->getTypeSourceInfo(), NewTy);
3473 cast<ValueDecl>(D)->setType(NewTy);
3481 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
3482 if (!VD->hasGlobalStorage())
3484 diag::warn_attribute_requires_functions_or_static_globals)
3488 diag::warn_attribute_requires_functions_or_static_globals)
3500 unsigned AttrSpellingListIndex) {
3501 if (OptimizeNoneAttr *Optnone = D->
getAttr<OptimizeNoneAttr>()) {
3502 Diag(Range.
getBegin(), diag::warn_attribute_ignored) << Ident;
3503 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
3507 if (D->
hasAttr<AlwaysInlineAttr>())
3511 AttrSpellingListIndex);
3516 unsigned AttrSpellingListIndex) {
3517 if (checkAttrMutualExclusion<InternalLinkageAttr>(*
this, D, Range, Ident))
3520 return ::new (
Context) CommonAttr(Range,
Context, AttrSpellingListIndex);
3523 InternalLinkageAttr *
3526 unsigned AttrSpellingListIndex) {
3527 if (
auto VD = dyn_cast<VarDecl>(D)) {
3530 if (VD->getKind() != Decl::Var) {
3531 Diag(Range.
getBegin(), diag::warn_attribute_wrong_decl_type)
3537 if (VD->hasLocalStorage()) {
3538 Diag(VD->getLocation(), diag::warn_internal_linkage_local_storage);
3543 if (checkAttrMutualExclusion<CommonAttr>(*
this, D, Range, Ident))
3547 InternalLinkageAttr(Range,
Context, AttrSpellingListIndex);
3551 unsigned AttrSpellingListIndex) {
3552 if (OptimizeNoneAttr *Optnone = D->
getAttr<OptimizeNoneAttr>()) {
3553 Diag(Range.
getBegin(), diag::warn_attribute_ignored) <<
"'minsize'";
3554 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
3558 if (D->
hasAttr<MinSizeAttr>())
3561 return ::new (
Context) MinSizeAttr(Range,
Context, AttrSpellingListIndex);
3565 unsigned AttrSpellingListIndex) {
3566 if (AlwaysInlineAttr *Inline = D->
getAttr<AlwaysInlineAttr>()) {
3567 Diag(Inline->getLocation(), diag::warn_attribute_ignored) << Inline;
3568 Diag(Range.
getBegin(), diag::note_conflicting_attribute);
3571 if (MinSizeAttr *MinSize = D->
getAttr<MinSizeAttr>()) {
3572 Diag(MinSize->getLocation(), diag::warn_attribute_ignored) << MinSize;
3573 Diag(Range.
getBegin(), diag::note_conflicting_attribute);
3577 if (D->
hasAttr<OptimizeNoneAttr>())
3581 AttrSpellingListIndex);
3586 if (checkAttrMutualExclusion<NotTailCalledAttr>(S, D, Attr.
getRange(),
3610 if (checkAttrMutualExclusion<CUDADeviceAttr>(S, D, Attr.
getRange(),
3612 checkAttrMutualExclusion<CUDAHostAttr>(S, D, Attr.
getRange(),
3635 S.
Diag(Attr.
getLoc(), diag::warn_gnu_inline_attribute_requires_inline);
3653 if (!isa<ObjCMethodDecl>(D)) {
3654 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
3660 case AttributeList::AT_FastCall:
3665 case AttributeList::AT_StdCall:
3670 case AttributeList::AT_ThisCall:
3675 case AttributeList::AT_CDecl:
3680 case AttributeList::AT_Pascal:
3685 case AttributeList::AT_VectorCall:
3690 case AttributeList::AT_MSABI:
3695 case AttributeList::AT_SysVABI:
3700 case AttributeList::AT_Pcs: {
3701 PcsAttr::PCSType PCS;
3704 PCS = PcsAttr::AAPCS;
3707 PCS = PcsAttr::AAPCS_VFP;
3710 llvm_unreachable(
"unexpected calling convention in pcs attribute");
3718 case AttributeList::AT_IntelOclBicc:
3725 llvm_unreachable(
"unexpected attribute kind");
3734 unsigned ReqArgs = attr.
getKind() == AttributeList::AT_Pcs ? 1 : 0;
3742 case AttributeList::AT_CDecl: CC =
CC_C;
break;
3746 case AttributeList::AT_Pascal: CC =
CC_X86Pascal;
break;
3748 case AttributeList::AT_MSABI:
3752 case AttributeList::AT_SysVABI:
3756 case AttributeList::AT_Pcs: {
3762 if (StrRef ==
"aapcs") {
3765 }
else if (StrRef ==
"aapcs-vfp") {
3775 default: llvm_unreachable(
"unexpected attribute kind");
3815 Diag(Attr.
getLoc(), diag::err_attribute_regparm_wrong_platform)
3816 << NumParamsExpr->getSourceRange();
3823 Diag(Attr.
getLoc(), diag::err_attribute_regparm_invalid_number)
3835 const CUDALaunchBoundsAttr &
Attr,
3836 const unsigned Idx) {
3853 if (!I.isIntN(32)) {
3854 S.
Diag(E->
getExprLoc(), diag::err_ice_too_large) << I.toString(10,
false)
3859 S.
Diag(E->
getExprLoc(), diag::warn_attribute_argument_n_negative)
3860 << &Attr << Idx << E->getSourceRange();
3866 Expr *MinBlocks,
unsigned SpellingListIndex) {
3867 CUDALaunchBoundsAttr TmpAttr(AttrRange,
Context, MaxThreads, MinBlocks,
3877 AttrRange,
Context, MaxThreads, MinBlocks, SpellingListIndex));
3894 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
3905 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_decl_type)
3910 uint64_t ArgumentIdx;
3915 uint64_t TypeTagIdx;
3920 bool IsPointer = (Attr.
getName()->
getName() ==
"pointer_with_type_tag");
3925 S.
Diag(Attr.
getLoc(), diag::err_attribute_pointers_only)
3932 ArgumentIdx, TypeTagIdx, IsPointer,
3939 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
3947 if (!isa<VarDecl>(D)) {
3948 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_decl_type)
3956 assert(MatchingCTypeLoc &&
"no type source info for attribute argument");
3990 if (Attr.
getKind() == AttributeList::AT_NSConsumed) {
3999 S.
Diag(D->
getLocStart(), diag::warn_ns_attribute_wrong_parameter_type)
4020 returnType = MD->getReturnType();
4022 (Attr.
getKind() == AttributeList::AT_NSReturnsRetained))
4025 returnType = PD->getType();
4027 returnType = FD->getReturnType();
4028 else if (
auto *Param = dyn_cast<ParmVarDecl>(D)) {
4030 if (returnType.
isNull()) {
4031 S.
Diag(D->
getLocStart(), diag::warn_ns_attribute_wrong_parameter_type)
4039 default: llvm_unreachable(
"invalid ownership attribute");
4040 case AttributeList::AT_NSReturnsRetained:
4041 case AttributeList::AT_NSReturnsAutoreleased:
4042 case AttributeList::AT_NSReturnsNotRetained:
4046 case AttributeList::AT_CFReturnsRetained:
4047 case AttributeList::AT_CFReturnsNotRetained:
4059 default: llvm_unreachable(
"invalid ownership attribute");
4060 case AttributeList::AT_NSReturnsRetained:
4065 case AttributeList::AT_NSReturnsAutoreleased:
4066 case AttributeList::AT_NSReturnsNotRetained:
4071 case AttributeList::AT_CFReturnsRetained:
4072 case AttributeList::AT_CFReturnsNotRetained:
4079 if (isa<ParmVarDecl>(D)) {
4080 S.
Diag(D->
getLocStart(), diag::warn_ns_attribute_wrong_parameter_type)
4089 } SubjectKind = Function;
4090 if (isa<ObjCMethodDecl>(D))
4091 SubjectKind = Method;
4092 else if (isa<ObjCPropertyDecl>(D))
4095 << Attr.
getName() << SubjectKind << cf
4103 llvm_unreachable(
"invalid ownership attribute");
4104 case AttributeList::AT_NSReturnsAutoreleased:
4108 case AttributeList::AT_CFReturnsNotRetained:
4112 case AttributeList::AT_NSReturnsNotRetained:
4116 case AttributeList::AT_CFReturnsRetained:
4120 case AttributeList::AT_NSReturnsRetained:
4129 const int EP_ObjCMethod = 1;
4130 const int EP_ObjCProperty = 2;
4134 if (isa<ObjCMethodDecl>(D))
4135 resultType = cast<ObjCMethodDecl>(D)->getReturnType();
4137 resultType = cast<ObjCPropertyDecl>(D)->getType();
4144 << (isa<ObjCMethodDecl>(D) ? EP_ObjCMethod : EP_ObjCProperty)
4160 if (
const ObjCProtocolDecl *PDecl = dyn_cast_or_null<ObjCProtocolDecl>(DC)) {
4163 S.
Diag(PDecl->getLocation(), diag::note_protocol_decl);
4179 if (checkAttrMutualExclusion<CFUnknownTransferAttr>(S, D, Attr.
getRange(),
4190 if (checkAttrMutualExclusion<CFAuditedTransferAttr>(S, D, Attr.
getRange(),
4209 if (
auto TD = dyn_cast<TypedefNameDecl>(D)) {
4211 S.
Diag(Attr.
getLoc(), diag::err_objc_attr_typedef_not_id)
4217 QualType T = TD->getUnderlyingType();
4219 S.
Diag(Attr.
getLoc(), diag::err_objc_attr_typedef_not_void_pointer);
4247 if (!RelatedClass) {
4257 ClassMethod, InstanceMethod,
4266 IFace = CatDecl->getClassInterface();
4281 StringRef MetaDataName;
4296 bool notify =
false;
4305 ObjCBoxableAttr *BoxableAttr = ::new (S.
Context)
4313 L->AddedAttributeToRecord(BoxableAttr, RD);
4331 if (!type->isDependentType() &&
4332 !type->isObjCLifetimeType()) {
4333 S.
Diag(Attr.
getLoc(), diag::err_objc_precise_lifetime_bad_type)
4343 lifetime = type->getObjCARCImplicitLifetime();
4347 assert(type->isDependentType() &&
4348 "didn't infer lifetime for non-dependent type?");
4357 S.
Diag(Attr.
getLoc(), diag::warn_objc_precise_lifetime_meaningless)
4373 S.
Diag(Attr.
getLoc(), diag::err_attribute_not_supported_in_lang)
4378 if (!isa<CXXRecordDecl>(D)) {
4379 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
4391 if (StrRef.size() == 38 && StrRef.front() ==
'{' && StrRef.back() ==
'}')
4392 StrRef = StrRef.drop_front().drop_back();
4395 if (StrRef.size() != 36) {
4396 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
4400 for (
unsigned i = 0; i < 36; ++i) {
4401 if (i == 8 || i == 13 || i == 18 || i == 23) {
4402 if (StrRef[i] !=
'-') {
4403 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
4407 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
4418 S.
Diag(Attr.
getLoc(), diag::err_attribute_not_supported_in_lang)
4432 VarDecl *VD = cast<VarDecl>(D);
4434 S.
Diag(Attr.
getLoc(), diag::err_thread_unsupported);
4438 S.
Diag(Attr.
getLoc(), diag::err_declspec_thread_on_thread_variable);
4442 S.
Diag(Attr.
getLoc(), diag::err_thread_non_global) <<
"__declspec(thread)";
4453 S.
Diag(Attr.
getLoc(), diag::err_attribute_too_many_arguments)
4466 ARMInterruptAttr::InterruptType
Kind;
4467 if (!ARMInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
4468 S.
Diag(Attr.
getLoc(), diag::warn_attribute_type_not_supported)
4469 << Attr.
getName() << Str << ArgLoc;
4492 llvm::APSInt NumParams(32);
4494 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type)
4496 << NumParamsExpr->getSourceRange();
4500 unsigned Num = NumParams.getLimitedValue(255);
4501 if ((Num & 1) || Num > 30) {
4502 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4503 << Attr.
getName() << (int)NumParams.getSExtValue()
4504 << NumParamsExpr->getSourceRange();
4518 S.
Diag(Attr.
getLoc(), diag::err_attribute_too_many_arguments)
4558 if (checkAttrMutualExclusion<Mips16Attr>(S, D, Attr.
getRange(),
4562 MipsInterruptAttr::InterruptType
Kind;
4563 if (!MipsInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
4564 S.
Diag(Attr.
getLoc(), diag::warn_attribute_type_not_supported)
4565 << Attr.
getName() <<
"'" + std::string(Str) +
"'";
4578 llvm::Triple::mipsel ||
4626 if (!isa<FunctionDecl>(D)) {
4627 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
4638 unsigned AttrSpellingListIndex) {
4639 if (D->
hasAttr<DLLExportAttr>()) {
4640 Diag(Range.
getBegin(), diag::warn_attribute_ignored) <<
"'dllimport'";
4644 if (D->
hasAttr<DLLImportAttr>())
4647 return ::new (
Context) DLLImportAttr(Range,
Context, AttrSpellingListIndex);
4651 unsigned AttrSpellingListIndex) {
4652 if (DLLImportAttr *Import = D->
getAttr<DLLImportAttr>()) {
4653 Diag(Import->getLocation(), diag::warn_attribute_ignored) << Import;
4657 if (D->
hasAttr<DLLExportAttr>())
4660 return ::new (
Context) DLLExportAttr(Range,
Context, AttrSpellingListIndex);
4664 if (isa<ClassTemplatePartialSpecializationDecl>(D) &&
4672 if (FD->isInlined() && A.
getKind() == AttributeList::AT_DLLImport &&
4681 if (
auto *MD = dyn_cast<CXXMethodDecl>(D)) {
4683 MD->getParent()->isLambda()) {
4690 Attr *NewAttr = A.
getKind() == AttributeList::AT_DLLExport
4699 unsigned AttrSpellingListIndex,
4700 MSInheritanceAttr::Spelling SemanticSpelling) {
4701 if (MSInheritanceAttr *IA = D->
getAttr<MSInheritanceAttr>()) {
4702 if (IA->getSemanticSpelling() == SemanticSpelling)
4704 Diag(IA->getLocation(), diag::err_mismatched_ms_inheritance)
4706 Diag(Range.
getBegin(), diag::note_previous_ms_inheritance);
4713 SemanticSpelling)) {
4717 if (isa<ClassTemplatePartialSpecializationDecl>(RD)) {
4718 Diag(Range.
getBegin(), diag::warn_ignored_ms_inheritance)
4723 Diag(Range.
getBegin(), diag::warn_ignored_ms_inheritance)
4730 MSInheritanceAttr(Range,
Context, BestCase, AttrSpellingListIndex);
4742 StringRef N(
"mutex");
4744 if (Attr.
getKind() == AttributeList::AT_Capability &&
4750 if (!N.equals_lower(
"mutex") && !N.equals_lower(
"role"))
4751 S.
Diag(LiteralLoc, diag::warn_invalid_capability_name) << N;
4772 Args.data(), Args.size(),
4812 RequiresCapabilityAttr *RCA = ::new (S.
Context)
4820 if (
auto *NSD = dyn_cast<NamespaceDecl>(D)) {
4821 if (NSD->isAnonymousNamespace()) {
4822 S.
Diag(Attr.
getLoc(), diag::warn_deprecated_anonymous_namespace);
4833 S.
Diag(Attr.
getLoc(), diag::ext_deprecated_attr_is_a_cxx14_extension);
4835 handleAttrWithMessage<DeprecatedAttr>(
S, D, Attr);
4842 std::vector<std::string> Sanitizers;
4845 StringRef SanitizerName;
4852 S.
Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << SanitizerName;
4854 Sanitizers.push_back(SanitizerName);
4866 std::string SanitizerName =
4867 llvm::StringSwitch<std::string>(AttrName)
4868 .Case(
"no_address_safety_analysis",
"address")
4869 .Case(
"no_sanitize_address",
"address")
4870 .Case(
"no_sanitize_thread",
"thread")
4871 .Case(
"no_sanitize_memory",
"memory");
4879 if (InternalLinkageAttr *Internal =
4935 bool IncludeCXX11Attributes) {
4950 ? diag::warn_unhandled_ms_attribute_ignored
4951 : diag::warn_unknown_attribute_ignored)
4962 assert(Attr.
isTypeAttr() &&
"Non-type attribute not handled");
4964 case AttributeList::AT_Interrupt:
4967 case AttributeList::AT_X86ForceAlignArgPointer:
4970 case AttributeList::AT_DLLExport:
4971 case AttributeList::AT_DLLImport:
4974 case AttributeList::AT_Mips16:
4975 handleSimpleAttributeWithExclusions<Mips16Attr, MipsInterruptAttr>(
S, D,
4978 case AttributeList::AT_NoMips16:
4979 handleSimpleAttribute<NoMips16Attr>(
S, D, Attr);
4981 case AttributeList::AT_AMDGPUNumVGPR:
4984 case AttributeList::AT_AMDGPUNumSGPR:
4987 case AttributeList::AT_IBAction:
4988 handleSimpleAttribute<IBActionAttr>(
S, D, Attr);
4990 case AttributeList::AT_IBOutlet:
4993 case AttributeList::AT_IBOutletCollection:
4996 case AttributeList::AT_Alias:
4999 case AttributeList::AT_Aligned:
5002 case AttributeList::AT_AlignValue:
5005 case AttributeList::AT_AlwaysInline:
5008 case AttributeList::AT_AnalyzerNoReturn:
5011 case AttributeList::AT_TLSModel:
5014 case AttributeList::AT_Annotate:
5017 case AttributeList::AT_Availability:
5020 case AttributeList::AT_CarriesDependency:
5023 case AttributeList::AT_Common:
5026 case AttributeList::AT_CUDAConstant:
5027 handleSimpleAttributeWithExclusions<CUDAConstantAttr, CUDASharedAttr>(
S, D,
5030 case AttributeList::AT_PassObjectSize:
5033 case AttributeList::AT_Constructor:
5036 case AttributeList::AT_CXX11NoReturn:
5037 handleSimpleAttribute<CXX11NoReturnAttr>(
S, D, Attr);
5039 case AttributeList::AT_Deprecated:
5042 case AttributeList::AT_Destructor:
5045 case AttributeList::AT_EnableIf:
5048 case AttributeList::AT_ExtVectorType:
5051 case AttributeList::AT_MinSize:
5054 case AttributeList::AT_OptimizeNone:
5057 case AttributeList::AT_FlagEnum:
5058 handleSimpleAttribute<FlagEnumAttr>(
S, D, Attr);
5060 case AttributeList::AT_Flatten:
5061 handleSimpleAttribute<FlattenAttr>(
S, D, Attr);
5063 case AttributeList::AT_Format:
5066 case AttributeList::AT_FormatArg:
5069 case AttributeList::AT_CUDAGlobal:
5072 case AttributeList::AT_CUDADevice:
5073 handleSimpleAttributeWithExclusions<CUDADeviceAttr, CUDAGlobalAttr>(
S, D,
5076 case AttributeList::AT_CUDAHost:
5077 handleSimpleAttributeWithExclusions<CUDAHostAttr, CUDAGlobalAttr>(
S, D,
5080 case AttributeList::AT_GNUInline:
5083 case AttributeList::AT_CUDALaunchBounds:
5086 case AttributeList::AT_Restrict:
5089 case AttributeList::AT_MayAlias:
5090 handleSimpleAttribute<MayAliasAttr>(
S, D, Attr);
5092 case AttributeList::AT_Mode:
5095 case AttributeList::AT_NoAlias:
5096 handleSimpleAttribute<NoAliasAttr>(
S, D, Attr);
5098 case AttributeList::AT_NoCommon:
5099 handleSimpleAttribute<NoCommonAttr>(
S, D, Attr);
5101 case AttributeList::AT_NoSplitStack:
5102 handleSimpleAttribute<NoSplitStackAttr>(
S, D, Attr);
5104 case AttributeList::AT_NonNull:
5110 case AttributeList::AT_ReturnsNonNull:
5113 case AttributeList::AT_AssumeAligned:
5116 case AttributeList::AT_Overloadable:
5117 handleSimpleAttribute<OverloadableAttr>(
S, D, Attr);
5119 case AttributeList::AT_Ownership:
5122 case AttributeList::AT_Cold:
5125 case AttributeList::AT_Hot:
5128 case AttributeList::AT_Naked:
5131 case AttributeList::AT_NoReturn:
5134 case AttributeList::AT_NoThrow:
5135 handleSimpleAttribute<NoThrowAttr>(
S, D, Attr);
5137 case AttributeList::AT_CUDAShared:
5138 handleSimpleAttributeWithExclusions<CUDASharedAttr, CUDAConstantAttr>(
S, D,
5141 case AttributeList::AT_VecReturn:
5145 case AttributeList::AT_ObjCOwnership:
5148 case AttributeList::AT_ObjCPreciseLifetime:
5152 case AttributeList::AT_ObjCReturnsInnerPointer:
5156 case AttributeList::AT_ObjCRequiresSuper:
5160 case AttributeList::AT_ObjCBridge:
5164 case AttributeList::AT_ObjCBridgeMutable:
5168 case AttributeList::AT_ObjCBridgeRelated:
5172 case AttributeList::AT_ObjCDesignatedInitializer:
5176 case AttributeList::AT_ObjCRuntimeName:
5180 case AttributeList::AT_ObjCBoxable:
5184 case AttributeList::AT_CFAuditedTransfer:
5187 case AttributeList::AT_CFUnknownTransfer:
5191 case AttributeList::AT_CFConsumed:
5192 case AttributeList::AT_NSConsumed:
5195 case AttributeList::AT_NSConsumesSelf:
5196 handleSimpleAttribute<NSConsumesSelfAttr>(
S, D, Attr);
5199 case AttributeList::AT_NSReturnsAutoreleased:
5200 case AttributeList::AT_NSReturnsNotRetained:
5201 case AttributeList::AT_CFReturnsNotRetained:
5202 case AttributeList::AT_NSReturnsRetained:
5203 case AttributeList::AT_CFReturnsRetained:
5206 case AttributeList::AT_WorkGroupSizeHint:
5207 handleWorkGroupSize<WorkGroupSizeHintAttr>(
S, D, Attr);
5209 case AttributeList::AT_ReqdWorkGroupSize:
5210 handleWorkGroupSize<ReqdWorkGroupSizeAttr>(
S, D, Attr);
5212 case AttributeList::AT_VecTypeHint:
5216 case AttributeList::AT_InitPriority:
5220 case AttributeList::AT_Packed:
5223 case AttributeList::AT_Section:
5226 case AttributeList::AT_Target:
5229 case AttributeList::AT_Unavailable:
5230 handleAttrWithMessage<UnavailableAttr>(
S, D, Attr);
5232 case AttributeList::AT_ArcWeakrefUnavailable:
5233 handleSimpleAttribute<ArcWeakrefUnavailableAttr>(
S, D, Attr);
5235 case AttributeList::AT_ObjCRootClass:
5236 handleSimpleAttribute<ObjCRootClassAttr>(
S, D, Attr);
5238 case AttributeList::AT_ObjCExplicitProtocolImpl:
5241 case AttributeList::AT_ObjCRequiresPropertyDefs:
5242 handleSimpleAttribute<ObjCRequiresPropertyDefsAttr>(
S, D, Attr);
5244 case AttributeList::AT_Unused:
5245 handleSimpleAttribute<UnusedAttr>(
S, D, Attr);
5247 case AttributeList::AT_ReturnsTwice:
5248 handleSimpleAttribute<ReturnsTwiceAttr>(
S, D, Attr);
5250 case AttributeList::AT_NotTailCalled:
5253 case AttributeList::AT_DisableTailCalls:
5256 case AttributeList::AT_Used:
5259 case AttributeList::AT_Visibility:
5262 case AttributeList::AT_TypeVisibility:
5265 case AttributeList::AT_WarnUnused:
5266 handleSimpleAttribute<WarnUnusedAttr>(
S, D, Attr);
5268 case AttributeList::AT_WarnUnusedResult:
5271 case AttributeList::AT_Weak:
5272 handleSimpleAttribute<WeakAttr>(
S, D, Attr);
5274 case AttributeList::AT_WeakRef:
5277 case AttributeList::AT_WeakImport:
5280 case AttributeList::AT_TransparentUnion:
5283 case AttributeList::AT_ObjCException:
5284 handleSimpleAttribute<ObjCExceptionAttr>(
S, D, Attr);
5286 case AttributeList::AT_ObjCMethodFamily:
5289 case AttributeList::AT_ObjCNSObject:
5292 case AttributeList::AT_ObjCIndependentClass:
5295 case AttributeList::AT_Blocks:
5298 case AttributeList::AT_Sentinel:
5301 case AttributeList::AT_Const:
5302 handleSimpleAttribute<ConstAttr>(
S, D, Attr);
5304 case AttributeList::AT_Pure:
5305 handleSimpleAttribute<PureAttr>(
S, D, Attr);
5307 case AttributeList::AT_Cleanup:
5310 case AttributeList::AT_NoDebug:
5313 case AttributeList::AT_NoDuplicate:
5314 handleSimpleAttribute<NoDuplicateAttr>(
S, D, Attr);
5316 case AttributeList::AT_NoInline:
5317 handleSimpleAttribute<NoInlineAttr>(
S, D, Attr);
5319 case AttributeList::AT_NoInstrumentFunction:
5320 handleSimpleAttribute<NoInstrumentFunctionAttr>(
S, D, Attr);
5322 case AttributeList::AT_StdCall:
5323 case AttributeList::AT_CDecl:
5324 case AttributeList::AT_FastCall:
5325 case AttributeList::AT_ThisCall:
5326 case AttributeList::AT_Pascal:
5327 case AttributeList::AT_VectorCall:
5328 case AttributeList::AT_MSABI:
5329 case AttributeList::AT_SysVABI:
5330 case AttributeList::AT_Pcs:
5331 case AttributeList::AT_IntelOclBicc:
5334 case AttributeList::AT_OpenCLKernel:
5335 handleSimpleAttribute<OpenCLKernelAttr>(
S, D, Attr);
5337 case AttributeList::AT_OpenCLImageAccess:
5338 handleSimpleAttribute<OpenCLImageAccessAttr>(
S, D, Attr);
5340 case AttributeList::AT_InternalLinkage:
5345 case AttributeList::AT_MSNoVTable:
5346 handleSimpleAttribute<MSNoVTableAttr>(
S, D, Attr);
5348 case AttributeList::AT_MSStruct:
5349 handleSimpleAttribute<MSStructAttr>(
S, D, Attr);
5351 case AttributeList::AT_Uuid:
5354 case AttributeList::AT_MSInheritance:
5357 case AttributeList::AT_SelectAny:
5358 handleSimpleAttribute<SelectAnyAttr>(
S, D, Attr);
5360 case AttributeList::AT_Thread:
5365 case AttributeList::AT_AssertExclusiveLock:
5368 case AttributeList::AT_AssertSharedLock:
5371 case AttributeList::AT_GuardedVar:
5372 handleSimpleAttribute<GuardedVarAttr>(
S, D, Attr);
5374 case AttributeList::AT_PtGuardedVar:
5377 case AttributeList::AT_ScopedLockable:
5378 handleSimpleAttribute<ScopedLockableAttr>(
S, D, Attr);
5380 case AttributeList::AT_NoSanitize:
5383 case AttributeList::AT_NoSanitizeSpecific:
5386 case AttributeList::AT_NoThreadSafetyAnalysis:
5387 handleSimpleAttribute<NoThreadSafetyAnalysisAttr>(
S, D, Attr);
5389 case AttributeList::AT_GuardedBy:
5392 case AttributeList::AT_PtGuardedBy:
5395 case AttributeList::AT_ExclusiveTrylockFunction:
5398 case AttributeList::AT_LockReturned:
5401 case AttributeList::AT_LocksExcluded:
5404 case AttributeList::AT_SharedTrylockFunction:
5407 case AttributeList::AT_AcquiredBefore:
5410 case AttributeList::AT_AcquiredAfter:
5415 case AttributeList::AT_Capability:
5416 case AttributeList::AT_Lockable:
5419 case AttributeList::AT_RequiresCapability:
5423 case AttributeList::AT_AssertCapability:
5426 case AttributeList::AT_AcquireCapability:
5429 case AttributeList::AT_ReleaseCapability:
5432 case AttributeList::AT_TryAcquireCapability:
5437 case AttributeList::AT_Consumable:
5440 case AttributeList::AT_ConsumableAutoCast:
5441 handleSimpleAttribute<ConsumableAutoCastAttr>(
S, D, Attr);
5443 case AttributeList::AT_ConsumableSetOnRead:
5444 handleSimpleAttribute<ConsumableSetOnReadAttr>(
S, D, Attr);
5446 case AttributeList::AT_CallableWhen:
5449 case AttributeList::AT_ParamTypestate:
5452 case AttributeList::AT_ReturnTypestate:
5455 case AttributeList::AT_SetTypestate:
5458 case AttributeList::AT_TestTypestate:
5463 case AttributeList::AT_ArgumentWithTypeTag:
5466 case AttributeList::AT_TypeTagForDatatype:
5476 bool IncludeCXX11Attributes) {
5485 Diag(AttrList->
getLoc(), diag::err_attribute_weakref_without_alias)
5486 << cast<NamedDecl>(D);
5495 if (!D->
hasAttr<OpenCLKernelAttr>()) {
5497 if (
Attr *A = D->
getAttr<ReqdWorkGroupSizeAttr>()) {
5502 }
else if (
Attr *A = D->
getAttr<WorkGroupSizeHintAttr>()) {
5505 }
else if (
Attr *A = D->
getAttr<VecTypeHintAttr>()) {
5508 }
else if (
Attr *A = D->
getAttr<AMDGPUNumVGPRAttr>()) {
5512 }
else if (
Attr *A = D->
getAttr<AMDGPUNumSGPRAttr>()) {
5525 if (l->getKind() == AttributeList::AT_Annotate) {
5528 Diag(l->getLoc(), diag::err_only_annotate_after_access_spec);
5539 for ( ; A; A = A->
getNext()) {
5545 S.
Diag(A->
getLoc(), diag::warn_unknown_attribute_ignored)
5548 S.
Diag(A->
getLoc(), diag::warn_attribute_not_on_decl)
5568 assert(isa<FunctionDecl>(ND) || isa<VarDecl>(ND));
5578 FD->getType(), FD->getTypeSourceInfo(),
5584 if (FD->getQualifier())
5592 for (
const auto &AI : FT->param_types()) {
5595 Params.push_back(Param);
5597 NewFD->setParams(Params);
5599 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(ND)) {
5601 VD->getInnerLocStart(), VD->getLocation(), II,
5602 VD->getType(), VD->getTypeSourceInfo(),
5603 VD->getStorageClass());
5604 if (VD->getQualifier()) {
5605 VarDecl *NewVD = cast<VarDecl>(NewD);
5643 if (
VarDecl *VD = dyn_cast<VarDecl>(D))
5644 if (VD->isExternC())
5647 if (FD->isExternC())
5688 UnavailableAttr::ImplicitReason &reason) {
5692 if (!isa<FieldDecl>(decl) && !isa<ObjCPropertyDecl>(decl) &&
5693 !isa<FunctionDecl>(decl))
5701 if ((isa<ObjCIvarDecl>(decl) || isa<ObjCPropertyDecl>(decl))) {
5704 reason = UnavailableAttr::IR_ForbiddenWeak;
5713 reason = UnavailableAttr::IR_ARCForbiddenType;
5723 auto reason = UnavailableAttr::IR_None;
5725 assert(reason &&
"didn't set reason?");
5726 decl->
addAttr(UnavailableAttr::CreateImplicit(S.
Context,
"", reason,
5731 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(decl)) {
5734 if (FD->hasAttr<UnavailableAttr>() &&
5736 diag::err_arc_array_param_no_ownership) {
5755 return Interface->isDeprecated();
5767 return Interface->isUnavailable();
5777 bool ObjCPropertyAccess) {
5779 unsigned diag, diag_message, diag_fwdclass_message;
5780 unsigned diag_available_here = diag::note_availability_specified_here;
5783 unsigned property_note_select;
5786 unsigned available_here_select_kind;
5793 diag = !ObjCPropertyAccess ? diag::warn_deprecated
5794 : diag::warn_property_method_deprecated;
5795 diag_message = diag::warn_deprecated_message;
5796 diag_fwdclass_message = diag::warn_deprecated_fwdclass_message;
5797 property_note_select = 0;
5798 available_here_select_kind = 2;
5804 diag = !ObjCPropertyAccess ? diag::err_unavailable
5805 : diag::err_property_method_unavailable;
5806 diag_message = diag::err_unavailable_message;
5807 diag_fwdclass_message = diag::warn_unavailable_fwdclass_message;
5808 property_note_select = 1;
5809 available_here_select_kind = 0;
5811 if (
auto attr = D->
getAttr<UnavailableAttr>()) {
5812 if (attr->isImplicit() && attr->getImplicitReason()) {
5815 auto flagARCError = [&] {
5818 diag = diag::err_unavailable_in_arc;
5821 switch (attr->getImplicitReason()) {
5822 case UnavailableAttr::IR_None:
break;
5824 case UnavailableAttr::IR_ARCForbiddenType:
5826 diag_available_here = diag::note_arc_forbidden_type;
5829 case UnavailableAttr::IR_ForbiddenWeak:
5831 diag_available_here = diag::note_arc_weak_disabled;
5833 diag_available_here = diag::note_arc_weak_no_runtime;
5836 case UnavailableAttr::IR_ARCForbiddenConversion:
5838 diag_available_here = diag::note_performs_forbidden_arc_conversion;
5841 case UnavailableAttr::IR_ARCInitReturnsUnrelated:
5843 diag_available_here = diag::note_arc_init_returns_unrelated;
5846 case UnavailableAttr::IR_ARCFieldWithOwnership:
5848 diag_available_here = diag::note_arc_field_with_ownership;
5857 diag = diag::warn_partial_availability;
5858 diag_message = diag::warn_partial_message;
5859 diag_fwdclass_message = diag::warn_partial_fwdclass_message;
5860 property_note_select = 2;
5861 available_here_select_kind = 3;
5865 if (!Message.empty()) {
5866 S.
Diag(Loc, diag_message) << D << Message;
5869 << ObjCProperty->
getDeclName() << property_note_select;
5870 }
else if (!UnknownObjCClass) {
5871 S.
Diag(Loc, diag) << D;
5874 << ObjCProperty->
getDeclName() << property_note_select;
5876 S.
Diag(Loc, diag_fwdclass_message) << D;
5881 << D << available_here_select_kind;
5883 S.
Diag(Loc, diag::note_partial_availability_silence) << D;
5925 switch (diag.
Kind) {
5951 assert(curPool &&
"re-emitting in undelayed context not supported");
5952 curPool->
steal(pool);
5960 bool ObjCPropertyAccess) {
5964 AD, Loc, D, UnknownObjCClass, ObjCProperty, Message,
5965 ObjCPropertyAccess));
5971 ObjCProperty, ObjCPropertyAccess);
static void handleConsumableAttr(Sema &S, Decl *D, const AttributeList &Attr)
unsigned getFlags() const
getFlags - Return the flags for this scope.
bool CheckNoReturnAttr(const AttributeList &attr)
static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D, const AttributeList &Attr)
Defines the clang::ASTContext interface.
static bool hasFunctionProto(const Decl *D)
hasFunctionProto - Return true if the given decl has a argument information.
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
static bool threadSafetyCheckIsPointer(Sema &S, const Decl *D, const AttributeList &Attr)
Check if passed in Decl is a pointer type.
static bool checkTryLockFunAttrCommon(Sema &S, Decl *D, const AttributeList &Attr, SmallVectorImpl< Expr * > &Args)
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
static void handleAssertSharedLockAttr(Sema &S, Decl *D, const AttributeList &Attr)
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.
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
static void handleDLLAttr(Sema &S, Decl *D, const AttributeList &A)
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
const AttributeList * getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
Represents a version number in the form major[.minor[.subminor[.build]]].
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.
DeclContext * getCurLexicalContext() const
bool isMemberPointerType() const
QualType getType() const
Retrieves the type of the base class.
static void handleAcquiredAfterAttr(Sema &S, Decl *D, const AttributeList &Attr)
bool isUnavailable(std::string *Message=nullptr) const
Determine whether this declaration is marked 'unavailable'.
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type...
static bool isDeclUnavailable(Decl *D)
A class which encapsulates the logic for delaying diagnostics during parsing and other processing...
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
static bool checkAttributeNumArgsImpl(Sema &S, const AttributeList &Attr, unsigned Num, unsigned Diag, Compare Comp)
const LangOptions & getLangOpts() const
static QualType getFunctionOrMethodResultType(const Decl *D)
bool diagnoseAppertainsTo(class Sema &S, const Decl *D) const
FunctionType - C99 6.7.5.3 - Function Declarators.
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
unsigned getSemanticSpelling() const
If the parsed attribute has a semantic equivalent, and it would have a semantic Spelling enumeration ...
static void handleObjCPreciseLifetimeAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleAcquireCapabilityAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleUuidAttr(Sema &S, Decl *D, const AttributeList &Attr)
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth, signed/unsigned.
static void handleSimpleAttributeWithExclusions(Sema &S, Decl *D, const AttributeList &Attr)
Defines the SourceManager interface.
static void handleObjCIndependentClass(Sema &S, Decl *D, const AttributeList &Attr)
static void handleAttrWithMessage(Sema &S, Decl *D, const AttributeList &Attr)
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
QualType getUnderlyingType() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
SourceRange getRange() const
static void handleCommonAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleObjCRuntimeName(Sema &S, Decl *D, const AttributeList &Attr)
static void handleSetTypestateAttr(Sema &S, Decl *D, const AttributeList &Attr)
const AvailabilityChange & getAvailabilityDeprecated() const
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
static bool checkUInt32Argument(Sema &S, const AttributeList &Attr, 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...
Defines the C++ template declaration subclasses.
bool isVoidPointerType() const
bool hasDefinition() const
static void handleDestructorAttr(Sema &S, Decl *D, const AttributeList &Attr)
The base class of the type hierarchy.
static void handleTypeTagForDatatypeAttr(Sema &S, Decl *D, const AttributeList &Attr)
const ObjCObjectType * getObjectType() const
Gets the type pointed to by this ObjC pointer.
unsigned getRegParmMax() const
static void handleFormatAttr(Sema &S, Decl *D, const AttributeList &Attr)
Handle attribute((format(type,idx,firstarg))) attributes based on http://gcc.gnu.org/onlinedocs/gcc/F...
bool isBooleanType() const
A container of type source information.
static void handleNoReturnAttr(Sema &S, Decl *D, const AttributeList &attr)
bool isBlockPointerType() const
static void handleAliasAttr(Sema &S, Decl *D, const AttributeList &Attr)
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
void LoadExternalWeakUndeclaredIdentifiers()
Load weak undeclared identifiers from the external source.
bool hasCustomParsing() const
static bool threadSafetyCheckIsSmartPointer(Sema &S, const RecordType *RT)
OptimizeNoneAttr * mergeOptimizeNoneAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
bool isValidPointerAttrType(QualType T, bool RefOkay=false)
Determine if type T is a valid subject for a nonnull and similar attributes.
static void handleHotAttr(Sema &S, Decl *D, const AttributeList &Attr)
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Information about one declarator, including the parsed type information and the identifier.
static void handleMinSizeAttr(Sema &S, Decl *D, const AttributeList &Attr)
static bool checkGuardedByAttrCommon(Sema &S, Decl *D, const AttributeList &Attr, Expr *&Arg)
field_iterator field_begin() const
bool isUsedAsTypeAttr() const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
ObjCMethodDecl - Represents an instance or class method declaration.
QualType getThisType(ASTContext &C) const
Returns the type of the this pointer.
static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList &AL)
static void handleReturnTypestateAttr(Sema &S, Decl *D, const AttributeList &Attr)
bool isArgIdent(unsigned Arg) const
ParmVarDecl - Represents a parameter to a function.
bool isObjCRetainableType() const
Defines the clang::Expr interface and subclasses for C++ expressions.
FormatAttr * mergeFormatAttr(Decl *D, SourceRange Range, IdentifierInfo *Format, int FormatIdx, int FirstArg, unsigned AttrSpellingListIndex)
static void handleDisableTailCallsAttr(Sema &S, Decl *D, const AttributeList &Attr)
static bool isForbiddenTypeAllowed(Sema &S, Decl *decl, 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...
RecordDecl - Represents a struct/union/class.
static void handleExclusiveTrylockFunctionAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void checkAttrArgsAreCapabilityObjs(Sema &S, Decl *D, const AttributeList &Attr, SmallVectorImpl< Expr * > &Args, int Sidx=0, bool ParamIdxOk=false)
Checks that all attribute arguments, starting from Sidx, resolve to a capability object.
static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, const AttributeList &Attr, bool IncludeCXX11Attributes)
ProcessDeclAttribute - Apply the specific attribute to the specified decl if the attribute applies to...
static void handleMSP430InterruptAttr(Sema &S, Decl *D, const AttributeList &Attr)
DeclarationName getName() const
getName - Returns the embedded declaration name.
One of these records is kept for each identifier that is lexed.
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
SourceLocation getUnavailableLoc() const
static void DoEmitAvailabilityWarning(Sema &S, Sema::AvailabilityDiagnostic K, Decl *Ctx, const NamedDecl *D, StringRef Message, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass, const ObjCPropertyDecl *ObjCProperty, bool ObjCPropertyAccess)
static void handleAssumeAlignedAttr(Sema &S, Decl *D, const AttributeList &Attr)
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
static void handleIBOutlet(Sema &S, Decl *D, const AttributeList &Attr)
AttributeList * getList() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
static void handleAnalyzerNoReturnAttr(Sema &S, Decl *D, const AttributeList &Attr)
The results of name lookup within a DeclContext.
static bool checkTypedefTypeForCapability(QualType Ty)
static void handleObjCOwnershipAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleGlobalAttr(Sema &S, Decl *D, const AttributeList &Attr)
bool isReferenceType() const
QualType getReturnType() const
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
bool isAnyPointerType() const
static void handleRestrictAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleDeclspecThreadAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleModeAttr(Sema &S, Decl *D, const AttributeList &Attr)
handleModeAttr - This attribute modifies the width of a decl with primitive type. ...
static void handleCallableWhenAttr(Sema &S, Decl *D, const AttributeList &Attr)
static bool versionsMatch(const VersionTuple &X, const VersionTuple &Y, bool BeforeIsOkay)
Check whether the two versions match.
static void checkUnusedDeclAttributes(Sema &S, const AttributeList *A)
checkUnusedDeclAttributes - Check a list of attributes to see if it contains any decl attributes that...
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
CXXRecordDecl * getDefinition() const
static void handleLocksExcludedAttr(Sema &S, Decl *D, const AttributeList &Attr)
TagKind getTagKind() const
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
static void handleTransparentUnionAttr(Sema &S, Decl *D, const AttributeList &Attr)
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
static void handleCapabilityAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleColdAttr(Sema &S, Decl *D, const AttributeList &Attr)
bool hasVariadicArg() const
static void handleAssertExclusiveLockAttr(Sema &S, Decl *D, const AttributeList &Attr)
Represents an access specifier followed by colon ':'.
static void handleConstructorAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleARMInterruptAttr(Sema &S, Decl *D, const AttributeList &Attr)
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...
Describes a module or submodule.
virtual CallingConv getDefaultCallingConv(CallingConvMethodType MT) const
Gets the default calling convention for the given target and declaration context. ...
static void handleMSInheritanceAttr(Sema &S, Decl *D, const AttributeList &Attr)
static bool attrNonNullArgCheck(Sema &S, QualType T, const AttributeList &Attr, SourceRange AttrParmRange, SourceRange TypeRange, bool isReturnValue=false)
static void handleNakedAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void parseModeAttrArg(Sema &S, StringRef Str, unsigned &DestWidth, bool &IntegerMode, bool &ComplexMode)
parseModeAttrArg - Parses attribute mode string and returns parsed type attribute.
void AddAssumeAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, Expr *OE, unsigned SpellingListIndex)
AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular declaration.
static void handleExtVectorTypeAttr(Sema &S, Scope *scope, Decl *D, const AttributeList &Attr)
static void handleObjCReturnsInnerPointerAttr(Sema &S, Decl *D, const AttributeList &attr)
static void handleNotTailCalledAttr(Sema &S, Decl *D, const AttributeList &Attr)
const TargetInfo & getTargetInfo() const
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.
std::string getAsString() const
Retrieve a string representation of the version number.
MinSizeAttr * mergeMinSizeAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
CharUnits - This is an opaque type for sizes expressed in character units.
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=ParsedType(), bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type...
static void handleNoSanitizeAttr(Sema &S, Decl *D, const AttributeList &Attr)
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
QualType getReturnType() const
static void handleInterruptAttr(Sema &S, Decl *D, const AttributeList &Attr)
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)
field_range fields() const
static void handleAlignValueAttr(Sema &S, Decl *D, const AttributeList &Attr)
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
const DelayedDiagnosticPool * getParent() const
QualType getForbiddenTypeOperand() const
bool CheckCallingConvAttr(const AttributeList &attr, CallingConv &CC, const FunctionDecl *FD=nullptr)
bool hasParsedType() const
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
AvailabilityAttr * mergeAvailabilityAttr(NamedDecl *D, SourceRange Range, IdentifierInfo *Platform, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, AvailabilityMergeKind AMK, unsigned AttrSpellingListIndex)
Attribute merging methods. Return true if a new attribute was added.
RecordDecl * getDecl() const
void steal(DelayedDiagnosticPool &pool)
Steal the diagnostics from the given pool.
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface...
static void handleObjCDesignatedInitializer(Sema &S, Decl *D, const AttributeList &Attr)
pool_iterator pool_end() const
std::string getNameAsString() const
getNameAsString - Get a human-readable name for the declaration, even if it is one of the special kin...
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
Scope - A scope is a transient data structure that is used while parsing the program.
static void handleDependencyAttr(Sema &S, Scope *Scope, Decl *D, const AttributeList &Attr)
Represents information about a change in availability for an entity, which is part of the encoding of...
bool getLayoutCompatible() const
Represents an Objective-C protocol declaration.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
Represents an ObjC class declaration.
static void handleCleanupAttr(Sema &S, Decl *D, const AttributeList &Attr)
bool isExtVectorType() const
void setInvalid(bool b=true) const
detail::InMemoryDirectory::const_iterator I
static void handleSectionAttr(Sema &S, Decl *D, const AttributeList &Attr)
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this attribute.
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
void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AL, bool IncludeCXX11Attributes=true)
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
static void handleLaunchBoundsAttr(Sema &S, Decl *D, const AttributeList &Attr)
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.
field_iterator field_end() const
IdentifierInfo * getAlias() const
static void handleNSConsumedAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleAlignedAttr(Sema &S, Decl *D, const AttributeList &Attr)
bool canBeWeakImported(bool &IsDefinition) const
Determines whether this symbol can be weak-imported, e.g., whether it would be well-formed to add the...
Sema - This implements semantic analysis and AST building for C.
Merge availability attributes for an implementation of a protocol requirement.
Represents a prototype with parameter type info, e.g.
static bool isDeclDeprecated(Decl *D)
static void handleObjCSuppresProtocolAttr(Sema &S, Decl *D, const AttributeList &Attr)
DeclarationNameTable DeclarationNames
const AvailabilityChange & getAvailabilityIntroduced() const
static void handleCFAuditedTransferAttr(Sema &S, Decl *D, const AttributeList &Attr)
SourceLocation getTypeSpecStartLoc() const
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
Captures information about a #pragma weak directive.
static void handleObjCBoxable(Sema &S, Decl *D, const AttributeList &Attr)
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isFunctionPointerType() const
void AddAlignValueAttr(SourceRange AttrRange, Decl *D, Expr *E, unsigned SpellingListIndex)
AddAlignValueAttr - Adds an align_value attribute to a particular declaration.
static void handlePtGuardedVarAttr(Sema &S, Decl *D, const AttributeList &Attr)
Exposes information about the current target.
static bool isValidSubjectOfNSReturnsRetainedAttribute(QualType type)
static DelayedDiagnostic makeAvailability(Sema::AvailabilityDiagnostic AD, SourceLocation Loc, const NamedDecl *D, const ObjCInterfaceDecl *UnknownObjCClass, const ObjCPropertyDecl *ObjCProperty, StringRef Msg, bool ObjCPropertyAccess)
static bool isCFStringType(QualType T, ASTContext &Ctx)
static void handleNonNullAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleObjCRequiresSuperAttr(Sema &S, Decl *D, const AttributeList &attr)
void popWithoutEmitting(DelayedDiagnosticsState state)
Leave a delayed-diagnostic state that was previously pushed.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
static bool checkLaunchBoundsArgument(Sema &S, Expr *E, const CUDALaunchBoundsAttr &Attr, const unsigned Idx)
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
MSInheritanceAttr::Spelling calculateInheritanceModel() const
Calculate what the inheritance model would be for this class.
static void handleTargetAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleWarnUnusedResult(Sema &S, Decl *D, const AttributeList &Attr)
StringRef getName() const
Return the actual identifier string.
SmallVector< Decl *, 2 > WeakTopLevelDecl
WeakTopLevelDecl - Translation-unit scoped declarations generated by #pragma weak during processing o...
DLLImportAttr * mergeDLLImportAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
static bool checkIBOutletCommon(Sema &S, Decl *D, const AttributeList &Attr)
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 handleTestTypestateAttr(Sema &S, Decl *D, const AttributeList &Attr)
static bool isCapabilityExpr(Sema &S, const Expr *Ex)
This file defines the classes used to store parsed information about declaration-specifiers and decla...
virtual std::string isValidSectionSpecifier(StringRef SR) const
An optional hook that targets can implement to perform semantic checking on attribute((section("foo")...
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
TranslationUnitDecl * getTranslationUnitDecl() const
static void handleCFUnknownTransferAttr(Sema &S, Decl *D, const AttributeList &Attr)
Defines the clang::Preprocessor interface.
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, bool AllowFold=true)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
static bool typeHasCapability(Sema &S, QualType Ty)
const ParmVarDecl * getParamDecl(unsigned i) const
llvm::MapVector< IdentifierInfo *, WeakInfo > WeakUndeclaredIdentifiers
WeakUndeclaredIdentifiers - Identifiers contained in #pragma weak before declared.
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
static void handleEnableIfAttr(Sema &S, Decl *D, const AttributeList &Attr)
DeclContext * getDeclContext()
void CheckAlignasUnderalignment(Decl *D)
bool isFloatingType() const
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
bool isObjCIdType() const
unsigned getUnwindWordWidth() const
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...
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
static void handleSentinelAttr(Sema &S, Decl *D, const AttributeList &Attr)
void HandleDelayedAccessCheck(sema::DelayedDiagnostic &DD, Decl *Ctx)
MSInheritanceAttr * mergeMSInheritanceAttr(Decl *D, SourceRange Range, bool BestCase, unsigned AttrSpellingListIndex, MSInheritanceAttr::Spelling SemanticSpelling)
ASTMutationListener * getASTMutationListener() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
virtual bool hasProtectedVisibility() const
Does this target support "protected" visibility?
const ParsedType & getTypeArg() const
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool EvaluateAsInt(llvm::APSInt &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer...
static void handleAcquiredBeforeAttr(Sema &S, Decl *D, const AttributeList &Attr)
static bool isNSStringType(QualType T, ASTContext &Ctx)
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
SmallVector< ActiveTemplateInstantiation, 16 > ActiveTemplateInstantiations
List of active template instantiations.
Represents a GCC generic vector type.
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
bool existsInTarget(const TargetInfo &Target) const
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
Wraps an identifier and optional source location for the identifier.
InternalLinkageAttr * mergeInternalLinkageAttr(Decl *D, SourceRange Range, IdentifierInfo *Ident, unsigned AttrSpellingListIndex)
static void handleDeprecatedAttr(Sema &S, Decl *D, const AttributeList &Attr)
unsigned getForbiddenTypeDiagnostic() const
The diagnostic ID to emit.
static void handlePtGuardedByAttr(Sema &S, Decl *D, const AttributeList &Attr)
RecordDecl * getDefinition() const
getDefinition - Returns the RecordDecl that actually defines this struct/union/class.
static void handleDelayedForbiddenType(Sema &S, DelayedDiagnostic &diag, Decl *decl)
Handle a delayed forbidden-type diagnostic.
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 handleWeakImportAttr(Sema &S, Decl *D, const AttributeList &Attr)
This is a scope that corresponds to the parameters within a function prototype for a function declara...
static const RecordType * getRecordType(QualType QT)
Checks that the passed in QualType either is of RecordType or points to RecordType.
static void handleMipsInterruptAttr(Sema &S, Decl *D, const AttributeList &Attr)
static bool checkAttributeNumArgs(Sema &S, const AttributeList &Attr, unsigned Num)
Check if the attribute has exactly as many args as Num.
SourceLocation getLocStart() const LLVM_READONLY
static void handleTryAcquireCapabilityAttr(Sema &S, Decl *D, const AttributeList &Attr)
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.
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type. ...
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
static bool checkRecordTypeForCapability(Sema &S, QualType Ty)
static bool isValidSubjectOfNSAttribute(Sema &S, QualType type)
unsigned getAttributeSpellingListIndex() const
Get an index into the attribute spelling list defined in Attr.td.
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
Assigning into this object requires the old value to be released and the new value to be retained...
static bool checkAcquireOrderAttrCommon(Sema &S, Decl *D, const AttributeList &Attr, SmallVectorImpl< Expr * > &Args)
static FormatAttrKind getFormatAttrKind(StringRef Format)
getFormatAttrKind - Map from format attribute names to supported format types.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
const ParsedType & getMatchingCType() const
not a target-specific vector type
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Encodes a location in the source.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
static bool handleCommonAttributeFeatures(Sema &S, Scope *scope, Decl *D, const AttributeList &Attr)
Handles semantic checking for features that are common to all attributes, such as checking whether a ...
SourceLocation getEllipsisLoc() const
DLLExportAttr * mergeDLLExportAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
void setUsed(bool Used=true)
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
bool isBuiltinType() const
Helper methods to distinguish type categories.
bool isValid() const
Return true if this is a valid SourceLocation object.
TagDecl - Represents the declaration of a struct/union/class/enum.
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.
ASTContext & getASTContext() const
const ObjCInterfaceDecl * getUnknownObjCClass() const
bool getMustBeNull() const
CommonAttr * mergeCommonAttr(Decl *D, SourceRange Range, IdentifierInfo *Ident, unsigned AttrSpellingListIndex)
IdentifierTable & getIdentifierTable()
const NamedDecl * getDeprecationDecl() const
static void handleLockReturnedAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleAvailabilityAttr(Sema &S, Decl *D, const AttributeList &Attr)
Represents a static or instance method of a struct/union/class.
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
static void handleNonNullAttrParameter(Sema &S, ParmVarDecl *D, const AttributeList &Attr)
static T * mergeVisibilityAttr(Sema &S, Decl *D, SourceRange range, typename T::VisibilityType value, unsigned attrSpellingListIndex)
static void handleAlwaysInlineAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleBlocksAttr(Sema &S, Decl *D, const AttributeList &Attr)
ObjCCategoryDecl - Represents a category declaration.
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 void handlePackedAttr(Sema &S, Decl *D, const AttributeList &Attr)
void push_back(const T &LocalValue)
static void handleArgumentWithTypeTagAttr(Sema &S, Decl *D, const AttributeList &Attr)
unsigned getMajor() const
Retrieve the major version number.
static void handleNSReturnsRetainedAttr(Sema &S, Decl *D, const AttributeList &Attr)
StringRef getDeprecationMessage() const
static unsigned getNumAttributeArgs(const AttributeList &Attr)
ThreadStorageClassSpecifier getTSCSpec() const
Represents one property declaration in an Objective-C interface.
unsigned getForbiddenTypeArgument() const
QualType getReturnType() const
SourceLocation getBegin() const
const T * castAs() const
Member-template castAs<specific type>.
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.
bool isArgExpr(unsigned Arg) const
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
static void handleObjCBridgeMutableAttr(Sema &S, Scope *Sc, Decl *D, const AttributeList &Attr)
static void handleDelayedAvailabilityCheck(Sema &S, DelayedDiagnostic &DD, Decl *Ctx)
IdentifierInfo * getScopeName() const
static void handleOptimizeNoneAttr(Sema &S, Decl *D, const AttributeList &Attr)
bool isVectorType() const
IdentifierLoc * getArgAsIdent(unsigned Arg) const
static void handleParamTypestateAttr(Sema &S, Decl *D, const AttributeList &Attr)
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
QualType getRealTypeForBitwidth(unsigned DestWidth) const
getRealTypeForBitwidth - sets floating point QualTy according to specified bitwidth.
Assigning into this object requires a lifetime extension.
static bool checkForConsumableClass(Sema &S, const CXXMethodDecl *MD, const AttributeList &Attr)
static void handleSharedTrylockFunctionAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleAMDGPUNumVGPRAttr(Sema &S, Decl *D, const AttributeList &Attr)
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
QualType getPointeeType() const
unsigned getMinArgs() const
pool_iterator pool_begin() const
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
SourceLocation getLocation() const
Base class for declarations which introduce a typedef-name.
static bool normalizeName(StringRef &AttrName)
Normalize the attribute, foo becomes foo.
static void handleObjCBridgeAttr(Sema &S, Scope *Sc, Decl *D, const AttributeList &Attr)
bool checkStringLiteralArgumentAttr(const AttributeList &Attr, unsigned ArgNum, StringRef &Str, SourceLocation *ArgLocation=nullptr)
Check if the argument ArgNum of Attr is a ASCII string literal.
bool diagnoseLangOpts(class Sema &S) const
void checkUnusedDeclAttributes(Declarator &D)
checkUnusedDeclAttributes - Given a declarator which is not being used to build a declaration...
Don't merge availability attributes at all.
static void handleReturnsNonNullAttr(Sema &S, Decl *D, const AttributeList &Attr)
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
const AvailabilityChange & getAvailabilityObsoleted() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
static void handleAMDGPUNumSGPRAttr(Sema &S, Decl *D, const AttributeList &Attr)
void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, WeakInfo &W)
DeclApplyPragmaWeak - A declaration (maybe definition) needs #pragma weak applied to it...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
bool empty() const
Determine whether this version information is empty (e.g., all version components are zero)...
void ProcessPragmaWeak(Scope *S, Decl *D)
bool isInvalidDecl() const
NamedDecl * DeclClonePragmaWeak(NamedDecl *ND, IdentifierInfo *II, SourceLocation Loc)
DeclClonePragmaWeak - clone existing decl (maybe definition), #pragma weak needs a non-definition dec...
unsigned getCharWidth() const
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, bool BestCase, MSInheritanceAttr::Spelling SemanticSpelling)
static void handleObjCBridgeRelatedAttr(Sema &S, Scope *Sc, Decl *D, const AttributeList &Attr)
SectionAttr * mergeSectionAttr(Decl *D, SourceRange Range, StringRef Name, unsigned AttrSpellingListIndex)
Expr * getArgAsExpr(unsigned Arg) const
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
DeclarationName - The name of a declaration.
unsigned short getMaxTLSAlign() const
Return the maximum alignment (in bits) of a TLS variable.
StringRef getString() const
const FunctionType * getFunctionType(bool BlocksToo=true) const
Looks through the Decl's underlying type to extract a FunctionType when possible. ...
static void handleInternalLinkageAttr(Sema &S, Decl *D, const AttributeList &Attr)
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
EnumDecl - Represents an enum.
VisibilityAttr * mergeVisibilityAttr(Decl *D, SourceRange Range, VisibilityAttr::VisibilityType Vis, unsigned AttrSpellingListIndex)
detail::InMemoryDirectory::const_iterator E
static void handleIBOutletCollection(Sema &S, Decl *D, const AttributeList &Attr)
static void handleVisibilityAttr(Sema &S, Decl *D, const AttributeList &Attr, bool isTypeVisibility)
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).
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
const Expr * getMessageExpr() const
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)
bool isObjCObjectType() const
bool isPackExpansion() const
static void handleCallConvAttr(Sema &S, Decl *D, const AttributeList &Attr)
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
static void handleObjCNSObject(Sema &S, Decl *D, const AttributeList &Attr)
IdentifierInfo * getName() const
SourceManager & getSourceManager() const
const T * getAs() const
Member-template getAs<specific type>'.
static void handleSimpleAttribute(Sema &S, Decl *D, const AttributeList &Attr)
Applies the given attribute to the Decl without performing any additional semantic checking...
void add(const sema::DelayedDiagnostic &diag)
Adds a delayed diagnostic.
bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl, const AttributeList *AttrList)
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 handleGuardedByAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleReleaseCapabilityAttr(Sema &S, Decl *D, const AttributeList &Attr)
unsigned getMaxArgs() const
static void handleWeakRefAttr(Sema &S, Decl *D, const AttributeList &Attr)
bool isFunctionType() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
SourceLocation getLoc() 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.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
Represents a base class of a C++ class.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
void checkTargetAttr(SourceLocation LiteralLoc, StringRef Str)
SourceManager & getSourceManager()
bool isTLSSupported() const
Whether the target supports thread-local storage.
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
static void handleRequiresCapabilityAttr(Sema &S, Decl *D, const AttributeList &Attr)
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
static void handleInitPriorityAttr(Sema &S, Decl *D, const AttributeList &Attr)
Handle attribute((init_priority(priority))) attributes based on http://gcc.gnu.org/onlinedocs/gcc/C_0...
bool CheckRegparmAttr(const AttributeList &attr, unsigned &value)
Checks a regparm attribute, returning true if it is ill-formed and otherwise setting numParams to the...
Merge availability attributes for a redeclaration, which requires an exact match. ...
const ObjCPropertyDecl * getObjCProperty() const
bool isCXX11Attribute() const
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
static bool checkAttributeAtMostNumArgs(Sema &S, const AttributeList &Attr, unsigned Num)
Check if the attribute has at most as many args as Num.
Reading or writing from this object requires a barrier call.
static void handleNoDebugAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleX86ForceAlignArgPointerAttr(Sema &S, Decl *D, const AttributeList &Attr)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
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)
bool isCARCBridgableType() const
Determine whether the given type T is a "bridgeable" C type.
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in it, apply them to D...
virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const
Determines whether a given calling convention is valid for the target.
Represents a C++ struct/union/class.
Compatible - the types are compatible according to the standard.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
static unsigned getFunctionOrMethodNumParams(const Decl *D)
getFunctionOrMethodNumParams - Return number of function or method parameters.
bool isObjCObjectPointerType() const
static void handleAnnotateAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleUsedAttr(Sema &S, Decl *D, const AttributeList &Attr)
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
A diagnostic message which has been conditionally emitted pending the complete parsing of the current...
ObjCIvarDecl - Represents an ObjC instance variable.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
void AddLaunchBoundsAttr(SourceRange AttrRange, Decl *D, Expr *MaxThreads, Expr *MinBlocks, unsigned SpellingListIndex)
AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular declaration. ...
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.
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 handleFormatArgAttr(Sema &S, Decl *D, const AttributeList &Attr)
Handle attribute((format_arg((idx)))) attribute based on http://gcc.gnu.org/onlinedocs/gcc/Function-A...
static SourceRange getFunctionOrMethodResultSourceRange(const Decl *D)
static void handleAssertCapabilityAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleVecTypeHint(Sema &S, Decl *D, const AttributeList &Attr)
static bool checkAttributeAtLeastNumArgs(Sema &S, const AttributeList &Attr, unsigned Num)
Check if the attribute has at least as many args as Num.
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
static void handleObjCMethodFamilyAttr(Sema &S, Decl *decl, const AttributeList &Attr)
bool checkSectionName(SourceLocation LiteralLoc, StringRef Str)
A reference to a declared variable, function, enum, etc.
static QualType getFunctionOrMethodParamType(const Decl *D, unsigned Idx)
static void handleGNUInlineAttr(Sema &S, Decl *D, const AttributeList &Attr)
bool isDeclspecAttribute() 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...
A collection of diagnostics which were delayed.
static bool isValidSubjectOfCFAttribute(Sema &S, QualType type)
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
static bool checkLockFunAttrCommon(Sema &S, Decl *D, const AttributeList &Attr, SmallVectorImpl< Expr * > &Args)
static bool isPotentialConstantExprUnevaluated(Expr *E, const FunctionDecl *FD, SmallVectorImpl< PartialDiagnosticAt > &Diags)
isPotentialConstantExprUnevaluted - Return true if this expression might be usable in a constant expr...
AttributeList * getNext() const
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
void setLexicalDeclContext(DeclContext *DC)
static void handlePassObjectSizeAttr(Sema &S, Decl *D, const AttributeList &Attr)
AlwaysInlineAttr * mergeAlwaysInlineAttr(Decl *D, SourceRange Range, IdentifierInfo *Ident, unsigned AttrSpellingListIndex)
NamedDecl - This represents a decl with a name.
static void handleTLSModelAttr(Sema &S, Decl *D, const AttributeList &Attr)
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.
static bool checkFunctionOrMethodParameterIndex(Sema &S, const Decl *D, const AttributeList &Attr, unsigned AttrArgNum, const Expr *IdxExpr, uint64_t &Idx)
Check if IdxExpr is a valid parameter index for a function or instance method D.
static bool isFunctionOrMethodVariadic(const Decl *D)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
static bool isObjCNSObjectType(QualType Ty)
Return true if this is an NSObject object with its NSObject attribute set.
void setHasDesignatedInitializers()
Indicate that this interface decl contains at least one initializer marked with the 'objc_designated_...
void EmitAvailabilityWarning(AvailabilityDiagnostic AD, NamedDecl *D, StringRef Message, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass, const ObjCPropertyDecl *ObjCProperty, bool ObjCPropertyAccess)
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.
bool isIntegralType(ASTContext &Ctx) const
Determine whether this type is an integral type.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
static void handleWorkGroupSize(Sema &S, Decl *D, const AttributeList &Attr)
Attr - This represents one attribute.
ParsedAttributes & getAttributes()
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool hasLocalStorage() const
hasLocalStorage - Returns true if a variable with function scope is a non-static local variable...
SmallVectorImpl< DelayedDiagnostic >::const_iterator pool_iterator
bool isDeprecated(std::string *Message=nullptr) const
Determine whether this declaration is marked 'deprecated'.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
AttributeList - Represents a syntactic attribute.
bool isPointerType() const
static void handleVecReturnAttr(Sema &S, Decl *D, const AttributeList &Attr)
static LLVM_READONLY bool isHexDigit(unsigned char c)
Return true if this character is an ASCII hex digit: [0-9a-fA-F].
const AttributeList * getAttributes() const