34 #include "llvm/ADT/StringExtras.h"
35 #include "llvm/Support/MathExtras.h"
37 using namespace clang;
40 namespace AttributeLangSupport {
56 return (D->getFunctionType() !=
nullptr) || isa<ObjCMethodDecl>(D);
69 return isa<DeclaratorDecl>(D) || isa<BlockDecl>(D) || isa<TypedefNameDecl>(D) ||
70 isa<ObjCPropertyDecl>(D);
78 return isa<FunctionProtoType>(FnTy);
79 return isa<ObjCMethodDecl>(D) || isa<BlockDecl>(D);
87 return cast<FunctionProtoType>(FnTy)->getNumParams();
88 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D))
89 return BD->getNumParams();
90 return cast<ObjCMethodDecl>(D)->param_size();
95 return cast<FunctionProtoType>(FnTy)->getParamType(Idx);
96 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D))
97 return BD->getParamDecl(Idx)->getType();
99 return cast<ObjCMethodDecl>(D)->parameters()[Idx]->getType();
103 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
104 return FD->getParamDecl(Idx)->getSourceRange();
105 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
106 return MD->parameters()[Idx]->getSourceRange();
107 if (
const auto *BD = dyn_cast<BlockDecl>(D))
108 return BD->getParamDecl(Idx)->getSourceRange();
114 return cast<FunctionType>(FnTy)->getReturnType();
115 return cast<ObjCMethodDecl>(D)->getReturnType();
119 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
120 return FD->getReturnTypeSourceRange();
121 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
122 return MD->getReturnTypeSourceRange();
131 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D))
132 return BD->isVariadic();
134 return cast<ObjCMethodDecl>(D)->isVariadic();
138 if (
const CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(D))
139 return MethodDecl->isInstance();
155 return ClsName == &Ctx.
Idents.
get(
"NSString") ||
156 ClsName == &Ctx.
Idents.
get(
"NSMutableString");
180 template <
typename Compare>
182 unsigned Num,
unsigned Diag,
197 diag::err_attribute_wrong_number_arguments,
198 std::not_equal_to<unsigned>());
206 diag::err_attribute_too_few_arguments,
207 std::less<unsigned>());
215 diag::err_attribute_too_many_arguments,
216 std::greater<unsigned>());
228 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
230 << Expr->getSourceRange();
232 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type)
234 << Expr->getSourceRange();
240 << I.toString(10,
false) << 32 << 1;
244 Val = (uint32_t)I.getZExtValue();
250 template <
typename AttrTy>
253 if (AttrTy *A = D->getAttr<AttrTy>()) {
254 S.
Diag(Range.
getBegin(), diag::err_attributes_are_not_compatible) << Ident
256 S.
Diag(A->getLocation(), diag::note_conflicting_attribute);
284 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
286 << IdxExpr->getSourceRange();
290 Idx = IdxInt.getLimitedValue();
291 if (Idx < 1 || (!IV && Idx > NumParams)) {
292 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_out_of_bounds)
293 << Attr.
getName() << AttrArgNum << IdxExpr->getSourceRange();
297 if (HasImplicitThisParam) {
300 diag::err_attribute_invalid_implicit_this_argument)
301 << Attr.
getName() << IdxExpr->getSourceRange();
315 unsigned ArgNum, StringRef &Str,
320 Diag(Loc->
Loc, diag::err_attribute_argument_type)
326 *ArgLocation = Loc->
Loc;
334 *ArgLocation = ArgExpr->getLocStart();
336 if (!Literal || !Literal->
isAscii()) {
337 Diag(ArgExpr->getLocStart(), diag::err_attribute_argument_type)
348 template <
typename AttrType>
355 template <
typename AttrType>
358 handleSimpleAttribute<AttrType>(
S, D, Attr);
363 template <
typename AttrType,
typename IncompatibleAttrType,
364 typename... IncompatibleAttrTypes>
367 if (checkAttrMutualExclusion<IncompatibleAttrType>(S, D, Attr.
getRange(),
402 const ValueDecl *vd = cast<ValueDecl>(D);
404 if (QT->isAnyPointerType())
411 if (RT->isIncompleteType())
418 S.
Diag(Attr.
getLoc(), diag::warn_thread_attribute_decl_not_pointer)
453 if (RD->hasAttr<CapabilityAttr>())
461 return Type->getDecl()->hasAttr<CapabilityAttr>();
477 return TN->hasAttr<CapabilityAttr>();
496 if (
const auto *
E = dyn_cast<DeclRefExpr>(Ex))
498 else if (
const auto *
E = dyn_cast<CastExpr>(Ex))
500 else if (
const auto *
E = dyn_cast<ParenExpr>(Ex))
502 else if (
const auto *
E = dyn_cast<UnaryOperator>(Ex)) {
503 if (
E->getOpcode() == UO_LNot)
506 }
else if (
const auto *
E = dyn_cast<BinaryOperator>(Ex)) {
507 if (
E->getOpcode() == BO_LAnd ||
E->getOpcode() == BO_LOr)
525 bool ParamIdxOk =
false) {
526 for (
unsigned Idx = Sidx; Idx < Attr.
getNumArgs(); ++Idx) {
531 Args.push_back(ArgExp);
535 if (
StringLiteral *StrLit = dyn_cast<StringLiteral>(ArgExp)) {
536 if (StrLit->getLength() == 0 ||
537 (StrLit->isAscii() && StrLit->getString() == StringRef(
"*"))) {
540 Args.push_back(ArgExp);
546 S.
Diag(Attr.
getLoc(), diag::warn_thread_attribute_ignored) <<
548 Args.push_back(ArgExp);
557 if (UOp->getOpcode() == UO_AddrOf)
558 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(UOp->getSubExpr()))
559 if (DRE->getDecl()->isCXXInstanceMember())
560 ArgTy = DRE->getDecl()->getType();
566 if(!RT && ParamIdxOk) {
571 llvm::APInt ArgValue = IL->getValue();
572 uint64_t ParamIdxFromOne = ArgValue.getZExtValue();
573 uint64_t ParamIdxFromZero = ParamIdxFromOne - 1;
574 if(!ArgValue.isStrictlyPositive() || ParamIdxFromOne > NumParams) {
575 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_out_of_range)
576 << Attr.
getName() << Idx + 1 << NumParams;
588 S.
Diag(Attr.
getLoc(), diag::warn_thread_attribute_argument_not_lockable)
591 Args.push_back(ArgExp);
615 unsigned Size = Args.size();
654 QualType QT = cast<ValueDecl>(D)->getType();
656 S.
Diag(Attr.
getLoc(), diag::warn_thread_attribute_decl_not_lockable)
675 Expr **StartArg = &Args[0];
678 StartArg, Args.size(),
688 Expr **StartArg = &Args[0];
691 StartArg, Args.size(),
711 unsigned Size = Args.size();
712 Expr **StartArg = Size == 0 ?
nullptr : &Args[0];
724 unsigned Size = Args.size();
725 Expr **StartArg = Size == 0 ?
nullptr : &Args[0];
740 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
760 Args.data(), Args.size(),
770 D->addAttr(::
new (S.
Context) ExclusiveTrylockFunctionAttr(
780 unsigned Size = Args.size();
797 unsigned Size = Args.size();
800 Expr **StartArg = &Args[0];
808 S.
Diag(Attr.
getLoc(), diag::ext_clang_enable_if);
815 Cond = Converted.
get();
826 S.
Diag(Attr.
getLoc(), diag::err_enable_if_never_constant_expr);
827 for (
int I = 0, N = Diags.size();
I != N; ++
I)
828 S.
Diag(Diags[
I].first, Diags[I].second);
839 if (D->hasAttr<PassObjectSizeAttr>()) {
840 S.
Diag(D->getLocStart(), diag::err_attribute_only_once_per_parameter)
854 S.
Diag(E->getLocStart(), diag::err_attribute_argument_outof_range)
855 << Attr.
getName() << 0 << 3 << E->getSourceRange();
863 if (!cast<ParmVarDecl>(D)->getType()->isPointerType()) {
864 S.
Diag(D->getLocStart(), diag::err_attribute_pointers_only)
879 if (!ConsumableAttr::ConvertStrToConsumedState(IL->
Ident->
getName(),
881 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported)
886 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type)
902 if (!RD->hasAttr<ConsumableAttr>()) {
903 S.
Diag(Attr.
getLoc(), diag::warn_attr_on_unconsumable_class) <<
904 RD->getNameAsString();
922 for (
unsigned ArgIndex = 0; ArgIndex < Attr.
getNumArgs(); ++ArgIndex) {
925 StringRef StateString;
936 if (!CallableWhenAttr::ConvertStrToConsumedState(StateString,
938 S.
Diag(Loc, diag::warn_attribute_type_not_supported)
939 << Attr.
getName() << StateString;
943 States.push_back(CallableState);
959 if (!ParamTypestateAttr::ConvertStrToConsumedState(StateString,
961 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported)
962 << Attr.
getName() << StateString;
966 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type) <<
994 if (!ReturnTypestateAttr::ConvertStrToConsumedState(IL->
Ident->
getName(),
996 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported)
1001 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type) <<
1044 if (!SetTypestateAttr::ConvertStrToConsumedState(Param, NewState)) {
1045 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported)
1050 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type) <<
1069 if (!TestTypestateAttr::ConvertStrToConsumedState(Param, TestState)) {
1070 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported)
1075 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type) <<
1092 if (
TagDecl *TD = dyn_cast<TagDecl>(D))
1095 else if (
FieldDecl *FD = dyn_cast<FieldDecl>(D)) {
1097 if (!FD->getType()->isDependentType() &&
1098 !FD->getType()->isIncompleteType() && FD->isBitField() &&
1100 S.
Diag(Attr.
getLoc(), diag::warn_attribute_packed_for_bitfield);
1102 FD->addAttr(::
new (S.
Context) PackedAttr(
1112 if (
const ObjCIvarDecl *VD = dyn_cast<ObjCIvarDecl>(D)) {
1114 S.
Diag(Attr.
getLoc(), diag::warn_iboutlet_object_type)
1115 << Attr.
getName() << VD->getType() << 0;
1121 S.
Diag(Attr.
getLoc(), diag::warn_iboutlet_object_type)
1122 << Attr.
getName() << PD->getType() << 1;
1148 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
1164 S.
Diag(Attr.
getLoc(), diag::err_iboutletcollection_type) <<
"NSObject";
1180 QT->
isBuiltinType() ? diag::err_iboutletcollection_builtintype
1181 : diag::err_iboutletcollection_type) << QT;
1201 if (UT && UT->getDecl()->hasAttr<TransparentUnionAttr>()) {
1203 for (
const auto *
I : UD->
fields()) {
1217 bool isReturnValue =
false) {
1220 S.
Diag(Attr.
getLoc(), diag::warn_attribute_return_pointers_only)
1221 << Attr.
getName() << AttrParmRange << TypeRange;
1223 S.
Diag(Attr.
getLoc(), diag::warn_attribute_pointers_only)
1224 << Attr.
getName() << AttrParmRange << TypeRange << 0;
1241 Ex->getSourceRange(),
1245 NonNullArgs.push_back(Idx);
1256 I !=
E && !AnyPointers; ++
I) {
1263 S.
Diag(Attr.
getLoc(), diag::warn_attribute_nonnull_no_pointers);
1266 unsigned *Start = NonNullArgs.data();
1267 unsigned Size = NonNullArgs.size();
1268 llvm::array_pod_sort(Start, Start + Size);
1277 if (D->getFunctionType()) {
1280 S.
Diag(Attr.
getLoc(), diag::warn_attribute_nonnull_parm_no_args)
1318 Expr *OE,
unsigned SpellingListIndex) {
1322 AssumeAlignedAttr TmpAttr(AttrRange,
Context, E, OE, SpellingListIndex);
1326 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
1327 << &TmpAttr << AttrRange << SR;
1335 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1337 << E->getSourceRange();
1339 Diag(AttrLoc, diag::err_attribute_argument_type)
1341 << E->getSourceRange();
1345 if (!I.isPowerOf2()) {
1346 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
1347 << E->getSourceRange();
1356 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1358 << OE->getSourceRange();
1365 AssumeAlignedAttr(AttrRange,
Context, E, OE, SpellingListIndex));
1371 if (AttrName.size() > 4 && AttrName.startswith(
"__") &&
1372 AttrName.endswith(
"__")) {
1373 AttrName = AttrName.drop_front(2).drop_back(2);
1389 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
1395 OwnershipAttr::OwnershipKind K =
1401 case OwnershipAttr::Takes:
1402 case OwnershipAttr::Holds:
1404 S.
Diag(AL.
getLoc(), diag::err_attribute_too_few_arguments)
1409 case OwnershipAttr::Returns:
1411 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments)
1420 StringRef ModuleName = Module->
getName();
1426 for (
unsigned i = 1; i < AL.
getNumArgs(); ++i) {
1436 case OwnershipAttr::Takes:
1437 case OwnershipAttr::Holds:
1441 case OwnershipAttr::Returns:
1448 << Ex->getSourceRange();
1453 for (
const auto *
I : D->specific_attrs<OwnershipAttr>()) {
1456 if (
I->getOwnKind() != K &&
I->args_end() !=
1457 std::find(
I->args_begin(),
I->args_end(), Idx)) {
1458 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
1461 }
else if (K == OwnershipAttr::Returns &&
1462 I->getOwnKind() == OwnershipAttr::Returns) {
1466 if (std::find(
I->args_begin(),
I->args_end(), Idx) ==
I->args_end()) {
1467 S.
Diag(
I->getLocation(), diag::err_ownership_returns_index_mismatch)
1468 << *(
I->args_begin()) + 1;
1470 S.
Diag(AL.
getLoc(), diag::note_ownership_returns_index_mismatch)
1471 << (
unsigned)Idx + 1 << Ex->getSourceRange();
1476 OwnershipArgs.push_back(Idx);
1479 unsigned* start = OwnershipArgs.data();
1480 unsigned size = OwnershipArgs.size();
1481 llvm::array_pod_sort(start, start + size);
1491 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
1508 const DeclContext *Ctx = D->getDeclContext()->getRedeclContext();
1509 if (!Ctx->isFileContext()) {
1510 S.
Diag(Attr.
getLoc(), diag::err_attribute_weakref_not_global_context)
1558 const auto *FD = cast<FunctionDecl>(D);
1559 if (FD->isThisDeclarationADefinition()) {
1560 S.
Diag(Attr.
getLoc(), diag::err_alias_is_definition) << FD << 1;
1565 llvm::Triple::ELF) {
1580 S.
Diag(Attr.
getLoc(), diag::err_alias_not_supported_on_darwin);
1584 S.
Diag(Attr.
getLoc(), diag::err_alias_not_supported_on_nvptx);
1588 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
1589 if (FD->isThisDeclarationADefinition()) {
1590 S.
Diag(Attr.
getLoc(), diag::err_alias_is_definition) << FD << 0;
1594 const auto *VD = cast<VarDecl>(D);
1595 if (VD->isThisDeclarationADefinition() && VD->isExternallyVisible()) {
1596 S.
Diag(Attr.
getLoc(), diag::err_alias_is_definition) << VD << 0;
1608 if (checkAttrMutualExclusion<HotAttr>(S, D, Attr.
getRange(), Attr.
getName()))
1616 if (checkAttrMutualExclusion<ColdAttr>(S, D, Attr.
getRange(), Attr.
getName()))
1632 if (Model !=
"global-dynamic" && Model !=
"local-dynamic"
1633 && Model !=
"initial-exec" && Model !=
"local-exec") {
1634 S.
Diag(LiteralLoc, diag::err_attr_tlsmodel_arg);
1646 D->addAttr(::
new (S.
Context) RestrictAttr(
1651 S.
Diag(Attr.
getLoc(), diag::warn_attribute_return_pointers_only)
1657 S.
Diag(Attr.
getLoc(), diag::err_attribute_not_supported_in_lang)
1668 if (checkAttrMutualExclusion<DisableTailCallsAttr>(S, D, Attr.
getRange(),
1681 if (!isa<ObjCMethodDecl>(D)) {
1682 S.
Diag(attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
1712 : diag::warn_attribute_wrong_decl_type)
1748 if (VecReturnAttr *A = D->getAttr<VecReturnAttr>()) {
1749 S.
Diag(Attr.
getLoc(), diag::err_repeat_attribute) << A;
1756 if (!isa<CXXRecordDecl>(record)) {
1757 S.
Diag(Attr.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
1761 if (!cast<CXXRecordDecl>(record)->isPOD()) {
1762 S.
Diag(Attr.
getLoc(), diag::err_attribute_vecreturn_only_pod_record);
1766 for (
const auto *
I : record->
fields()) {
1767 if ((count == 1) || !
I->getType()->isVectorType()) {
1768 S.
Diag(Attr.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
1781 if (isa<ParmVarDecl>(D)) {
1786 diag::err_carries_dependency_param_not_function_decl);
1791 D->addAttr(::
new (S.
Context) CarriesDependencyAttr(
1798 if (checkAttrMutualExclusion<AlwaysInlineAttr>(S, D, Attr.
getRange(),
1802 D->addAttr(::
new (S.
Context) NotTailCalledAttr(
1808 if (checkAttrMutualExclusion<NakedAttr>(S, D, Attr.
getRange(),
1812 D->addAttr(::
new (S.
Context) DisableTailCallsAttr(
1817 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1818 if (VD->hasLocalStorage()) {
1823 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
1836 if (IsCXX1zAttr && isa<VarDecl>(D)) {
1840 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
1851 D->addAttr(::
new (S.
Context) UnusedAttr(
1856 uint32_t priority = ConstructorAttr::DefaultPriority;
1867 uint32_t priority = DestructorAttr::DefaultPriority;
1877 template <
typename AttrTy>
1891 if (!cast<ObjCProtocolDecl>(D)->isThisDeclarationADefinition()) {
1892 S.
Diag(Attr.
getLoc(), diag::err_objc_attr_protocol_requires_definition)
1907 StringRef PlatformName
1908 = AvailabilityAttr::getPrettyPlatformName(Platform->
getName());
1909 if (PlatformName.empty())
1910 PlatformName = Platform->
getName();
1914 if (!Introduced.
empty() && !Deprecated.
empty() &&
1915 !(Introduced <= Deprecated)) {
1916 S.
Diag(Range.
getBegin(), diag::warn_availability_version_ordering)
1922 if (!Introduced.
empty() && !Obsoleted.
empty() &&
1923 !(Introduced <= Obsoleted)) {
1924 S.
Diag(Range.
getBegin(), diag::warn_availability_version_ordering)
1930 if (!Deprecated.
empty() && !Obsoleted.
empty() &&
1931 !(Deprecated <= Obsoleted)) {
1932 S.
Diag(Range.
getBegin(), diag::warn_availability_version_ordering)
1946 bool BeforeIsOkay) {
1953 if (BeforeIsOkay && X < Y)
1970 unsigned AttrSpellingListIndex) {
1974 bool FoundAny =
false;
1975 bool OverrideOrImpl =
false;
1979 OverrideOrImpl =
false;
1984 OverrideOrImpl =
true;
1988 if (D->hasAttrs()) {
1989 AttrVec &Attrs = D->getAttrs();
1990 for (
unsigned i = 0, e = Attrs.size(); i != e;) {
1991 const AvailabilityAttr *OldAA = dyn_cast<AvailabilityAttr>(Attrs[i]);
1998 if (OldPlatform != Platform) {
2006 if (!OldAA->isImplicit() && Implicit) {
2013 if (!Implicit && OldAA->isImplicit()) {
2014 Attrs.erase(Attrs.begin() + i);
2023 bool OldIsUnavailable = OldAA->getUnavailable();
2025 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl) ||
2026 !
versionsMatch(Deprecated, OldDeprecated, OverrideOrImpl) ||
2028 !(OldIsUnavailable == IsUnavailable ||
2029 (OverrideOrImpl && !OldIsUnavailable && IsUnavailable))) {
2030 if (OverrideOrImpl) {
2034 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl)) {
2036 FirstVersion = OldIntroduced;
2037 SecondVersion = Introduced;
2038 }
else if (!
versionsMatch(Deprecated, OldDeprecated, OverrideOrImpl)) {
2040 FirstVersion = Deprecated;
2041 SecondVersion = OldDeprecated;
2042 }
else if (!
versionsMatch(Obsoleted, OldObsoleted, OverrideOrImpl)) {
2044 FirstVersion = Obsoleted;
2045 SecondVersion = OldObsoleted;
2049 Diag(OldAA->getLocation(),
2050 diag::warn_mismatched_availability_override_unavail)
2051 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2054 Diag(OldAA->getLocation(),
2055 diag::warn_mismatched_availability_override)
2057 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2066 Diag(OldAA->getLocation(), diag::warn_mismatched_availability);
2070 Attrs.erase(Attrs.begin() + i);
2079 if (MergedIntroduced2.
empty())
2080 MergedIntroduced2 = OldIntroduced;
2081 if (MergedDeprecated2.
empty())
2082 MergedDeprecated2 = OldDeprecated;
2083 if (MergedObsoleted2.
empty())
2084 MergedObsoleted2 = OldObsoleted;
2087 MergedIntroduced2, MergedDeprecated2,
2088 MergedObsoleted2)) {
2089 Attrs.erase(Attrs.begin() + i);
2094 MergedIntroduced = MergedIntroduced2;
2095 MergedDeprecated = MergedDeprecated2;
2096 MergedObsoleted = MergedObsoleted2;
2102 MergedIntroduced == Introduced &&
2103 MergedDeprecated == Deprecated &&
2104 MergedObsoleted == Obsoleted)
2110 MergedDeprecated, MergedObsoleted) &&
2112 auto *Avail = ::new (
Context) AvailabilityAttr(Range,
Context, Platform,
2113 Introduced, Deprecated,
2114 Obsoleted, IsUnavailable, Message,
2115 IsStrict, Replacement,
2116 AttrSpellingListIndex);
2117 Avail->setImplicit(Implicit);
2131 if (AvailabilityAttr::getPrettyPlatformName(II->
getName()).empty())
2132 S.
Diag(Platform->
Loc, diag::warn_availability_unknown_platform)
2149 Str = SE->getString();
2153 Replacement = SE->getString();
2165 D->addAttr(NewAttr);
2173 else if (II->
getName() ==
"ios_app_extension")
2178 if (Version.empty())
2181 auto NewMajor = Major >= 9 ? Major - 7 : 0;
2182 if (NewMajor >= 2) {
2183 if (Version.getMinor().hasValue()) {
2184 if (Version.getSubminor().hasValue())
2185 return VersionTuple(NewMajor, Version.getMinor().getValue(),
2186 Version.getSubminor().getValue());
2188 return VersionTuple(NewMajor, Version.getMinor().getValue());
2195 auto NewIntroduced = adjustWatchOSVersion(Introduced.
Version);
2196 auto NewDeprecated = adjustWatchOSVersion(Deprecated.
Version);
2197 auto NewObsoleted = adjustWatchOSVersion(Obsoleted.
Version);
2212 D->addAttr(NewAttr);
2220 else if (II->
getName() ==
"ios_app_extension")
2237 D->addAttr(NewAttr);
2244 typename T::VisibilityType value,
2245 unsigned attrSpellingListIndex) {
2246 T *existingAttr = D->getAttr<T>();
2248 typename T::VisibilityType existingValue = existingAttr->getVisibility();
2249 if (existingValue == value)
2251 S.
Diag(existingAttr->getLocation(), diag::err_mismatched_visibility);
2252 S.
Diag(range.
getBegin(), diag::note_previous_attribute);
2255 return ::new (S.
Context) T(range, S.
Context, value, attrSpellingListIndex);
2259 VisibilityAttr::VisibilityType Vis,
2260 unsigned AttrSpellingListIndex) {
2261 return ::mergeVisibilityAttr<VisibilityAttr>(*
this, D, Range, Vis,
2262 AttrSpellingListIndex);
2266 TypeVisibilityAttr::VisibilityType Vis,
2267 unsigned AttrSpellingListIndex) {
2268 return ::mergeVisibilityAttr<TypeVisibilityAttr>(*
this, D, Range, Vis,
2269 AttrSpellingListIndex);
2273 bool isTypeVisibility) {
2275 if (isa<TypedefNameDecl>(D)) {
2282 if (isTypeVisibility &&
2283 !(isa<TagDecl>(D) ||
2284 isa<ObjCInterfaceDecl>(D) ||
2285 isa<NamespaceDecl>(D))) {
2297 VisibilityAttr::VisibilityType
type;
2298 if (!VisibilityAttr::ConvertStrToVisibilityType(TypeStr, type)) {
2299 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported)
2306 if (type == VisibilityAttr::Protected &&
2308 S.
Diag(Attr.
getLoc(), diag::warn_attribute_protected_visibility);
2309 type = VisibilityAttr::Default;
2314 if (isTypeVisibility) {
2316 (TypeVisibilityAttr::VisibilityType) type,
2322 D->addAttr(newAttr);
2329 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
2335 ObjCMethodFamilyAttr::FamilyKind F;
2336 if (!ObjCMethodFamilyAttr::ConvertStrToFamilyKind(IL->
Ident->
getName(), F)) {
2337 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported) << Attr.
getName()
2344 S.
Diag(method->getLocation(), diag::err_init_method_bad_return_type)
2357 QualType T = TD->getUnderlyingType();
2359 S.
Diag(TD->getLocation(), diag::err_nsobject_attribute);
2366 S.
Diag(PD->getLocation(), diag::err_nsobject_attribute);
2377 S.
Diag(D->getLocation(), diag::warn_nsobject_attribute);
2386 QualType T = TD->getUnderlyingType();
2388 S.
Diag(TD->getLocation(), diag::warn_ptr_independentclass_attribute);
2392 S.
Diag(D->getLocation(), diag::warn_independentclass_attribute);
2402 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
2408 BlocksAttr::BlockType
type;
2409 if (!BlocksAttr::ConvertStrToBlockType(II->
getName(),
type)) {
2410 S.
Diag(Attr.
getLoc(), diag::warn_attribute_type_not_supported)
2421 unsigned sentinel = (
unsigned)SentinelAttr::DefaultSentinel;
2424 llvm::APSInt Idx(32);
2427 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
2429 << E->getSourceRange();
2433 if (Idx.isSigned() && Idx.isNegative()) {
2434 S.
Diag(Attr.
getLoc(), diag::err_attribute_sentinel_less_than_zero)
2435 << E->getSourceRange();
2439 sentinel = Idx.getZExtValue();
2442 unsigned nullPos = (
unsigned)SentinelAttr::DefaultNullPos;
2445 llvm::APSInt Idx(32);
2448 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
2450 << E->getSourceRange();
2453 nullPos = Idx.getZExtValue();
2455 if ((Idx.isSigned() && Idx.isNegative()) || nullPos > 1) {
2458 S.
Diag(Attr.
getLoc(), diag::err_attribute_sentinel_not_zero_or_one)
2459 << E->getSourceRange();
2466 if (isa<FunctionNoProtoType>(FT)) {
2467 S.
Diag(Attr.
getLoc(), diag::warn_attribute_sentinel_named_arguments);
2471 if (!cast<FunctionProtoType>(FT)->isVariadic()) {
2472 S.
Diag(Attr.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
2476 if (!MD->isVariadic()) {
2477 S.
Diag(Attr.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
2480 }
else if (
BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
2481 if (!BD->isVariadic()) {
2482 S.
Diag(Attr.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 1;
2485 }
else if (
const VarDecl *V = dyn_cast<VarDecl>(D)) {
2489 ? D->getFunctionType()
2491 if (!cast<FunctionProtoType>(FT)->isVariadic()) {
2493 S.
Diag(Attr.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << m;
2497 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
2502 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
2512 if (D->getFunctionType() &&
2513 D->getFunctionType()->getReturnType()->isVoidType()) {
2514 S.
Diag(Attr.
getLoc(), diag::warn_attribute_void_function_method)
2519 if (MD->getReturnType()->isVoidType()) {
2520 S.
Diag(Attr.
getLoc(), diag::warn_attribute_void_function_method)
2539 if (!D->canBeWeakImported(isDef)) {
2541 S.
Diag(Attr.
getLoc(), diag::warn_attribute_invalid_on_definition)
2543 else if (isa<ObjCPropertyDecl>(D) || isa<ObjCMethodDecl>(D) ||
2545 (isa<ObjCInterfaceDecl>(D) || isa<EnumDecl>(D)))) {
2548 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
2560 template <
typename WorkGroupAttr>
2564 for (
unsigned i = 0; i < 3; ++i) {
2568 if (WGSize[i] == 0) {
2569 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_is_zero)
2570 << Attr.
getName() << E->getSourceRange();
2575 WorkGroupAttr *Existing = D->getAttr<WorkGroupAttr>();
2576 if (Existing && !(Existing->getXDim() == WGSize[0] &&
2577 Existing->getYDim() == WGSize[1] &&
2578 Existing->getZDim() == WGSize[2]))
2582 WGSize[0], WGSize[1], WGSize[2],
2588 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
2595 assert(ParmTSI &&
"no type source info for attribute argument");
2600 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_vec_type_hint)
2605 if (VecTypeHintAttr *A = D->getAttr<VecTypeHintAttr>()) {
2619 unsigned AttrSpellingListIndex) {
2620 if (SectionAttr *ExistingAttr = D->getAttr<SectionAttr>()) {
2621 if (ExistingAttr->getName() ==
Name)
2623 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section);
2628 AttrSpellingListIndex);
2633 if (!Error.empty()) {
2634 Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target) <<
Error;
2653 if (!Error.empty()) {
2654 S.
Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
2662 D->addAttr(NewAttr);
2670 for (
auto Str : {
"tune=",
"fpmath="})
2671 if (AttrStr.find(Str) != StringRef::npos)
2672 Diag(LiteralLoc, diag::warn_unsupported_target_attribute) << Str;
2682 TargetAttr *NewAttr =
2684 D->addAttr(NewAttr);
2688 VarDecl *VD = cast<VarDecl>(D);
2701 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
2702 if (DRE->hasQualifier())
2703 S.
Diag(Loc, diag::warn_cleanup_ext);
2705 NI = DRE->getNameInfo();
2707 S.
Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 1
2712 if (ULE->hasExplicitTemplateArgs())
2713 S.
Diag(Loc, diag::warn_cleanup_ext);
2715 NI = ULE->getNameInfo();
2717 S.
Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 2
2724 S.
Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 0;
2729 S.
Diag(Loc, diag::err_attribute_cleanup_func_must_take_one_arg)
2740 S.
Diag(Loc, diag::err_attribute_cleanup_func_arg_incompatible_type)
2741 << NI.
getName() << ParamTy << Ty;
2762 if (NotNSStringTy &&
2766 S.
Diag(Attr.
getLoc(), diag::err_format_attribute_not)
2767 <<
"a string type" << IdxExpr->getSourceRange()
2776 S.
Diag(Attr.
getLoc(), diag::err_format_attribute_result_not)
2777 << (NotNSStringTy ?
"string type" :
"NSString")
2805 return llvm::StringSwitch<FormatAttrKind>(Format)
2818 .Cases(
"gcc_diag",
"gcc_cdiag",
"gcc_cxxdiag",
"gcc_tdiag",
IgnoredFormat)
2832 S.
Diag(Attr.
getLoc(), diag::err_init_priority_object_attr);
2836 QualType T = cast<VarDecl>(D)->getType();
2840 S.
Diag(Attr.
getLoc(), diag::err_init_priority_object_attr);
2846 uint32_t prioritynum;
2852 if (prioritynum < 101 || prioritynum > 65535) {
2853 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_outof_range)
2854 << E->getSourceRange() << Attr.
getName() << 101 << 65535;
2866 unsigned AttrSpellingListIndex) {
2868 for (
auto *F : D->specific_attrs<FormatAttr>()) {
2869 if (F->getType() == Format &&
2870 F->getFormatIdx() == FormatIdx &&
2871 F->getFirstArg() == FirstArg) {
2874 if (F->getLocation().isInvalid())
2880 return ::new (
Context) FormatAttr(Range,
Context, Format, FormatIdx,
2881 FirstArg, AttrSpellingListIndex);
2888 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
2899 StringRef Format = II->
getName();
2913 S.
Diag(Attr.
getLoc(), diag::warn_attribute_type_not_supported)
2924 if (Idx < 1 || Idx > NumArgs) {
2925 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_out_of_bounds)
2926 << Attr.
getName() << 2 << IdxExpr->getSourceRange();
2931 unsigned ArgIdx = Idx - 1;
2933 if (HasImplicitThisParam) {
2936 diag::err_format_attribute_implicit_this_format_string)
2937 << IdxExpr->getSourceRange();
2948 S.
Diag(Attr.
getLoc(), diag::err_format_attribute_not)
2949 <<
"a CFString" << IdxExpr->getSourceRange()
2957 S.
Diag(Attr.
getLoc(), diag::err_format_attribute_not)
2958 <<
"an NSString" << IdxExpr->getSourceRange()
2964 S.
Diag(Attr.
getLoc(), diag::err_format_attribute_not)
2965 <<
"a string type" << IdxExpr->getSourceRange()
2977 if (FirstArg != 0) {
2981 S.
Diag(D->getLocation(), diag::err_format_attribute_requires_variadic);
2989 if (FirstArg != 0) {
2990 S.
Diag(Attr.
getLoc(), diag::err_format_strftime_third_parameter)
2991 << FirstArgExpr->getSourceRange();
2995 }
else if (FirstArg != 0 && FirstArg != NumArgs) {
2996 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_out_of_bounds)
2997 << Attr.
getName() << 3 << FirstArgExpr->getSourceRange();
3005 D->addAttr(NewAttr);
3019 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
3026 diag::warn_transparent_union_attribute_not_definition);
3032 if (Field == FieldEnd) {
3033 S.
Diag(Attr.
getLoc(), diag::warn_transparent_union_attribute_zero_fields);
3040 S.
Diag(FirstField->getLocation(),
3041 diag::warn_transparent_union_attribute_floating)
3048 for (; Field != FieldEnd; ++Field) {
3049 QualType FieldType = Field->getType();
3061 S.
Diag(Field->getLocation(),
3062 diag::warn_transparent_union_attribute_field_size_align)
3063 << isSize << Field->getDeclName() << FieldBits;
3064 unsigned FirstBits = isSize? FirstSize : FirstAlign;
3065 S.
Diag(FirstField->getLocation(),
3066 diag::note_transparent_union_first_field_size_align)
3067 << isSize << FirstBits;
3085 for (
const auto *
I : D->specific_attrs<AnnotateAttr>()) {
3086 if (
I->getAnnotation() == Str)
3102 unsigned SpellingListIndex) {
3103 AlignValueAttr TmpAttr(AttrRange,
Context, E, SpellingListIndex);
3108 T = TD->getUnderlyingType();
3109 else if (
ValueDecl *VD = dyn_cast<ValueDecl>(D))
3112 llvm_unreachable(
"Unknown decl type for align_value");
3116 Diag(AttrLoc, diag::warn_attribute_pointer_or_reference_only)
3117 << &TmpAttr << T << D->getSourceRange();
3122 llvm::APSInt Alignment;
3125 diag::err_align_value_attribute_argument_not_int,
3130 if (!Alignment.isPowerOf2()) {
3131 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
3132 << E->getSourceRange();
3137 AlignValueAttr(AttrRange,
Context, ICE.
get(),
3138 SpellingListIndex));
3143 D->addAttr(::
new (
Context) AlignValueAttr(TmpAttr));
3149 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
3163 diag::err_pack_expansion_without_parameter_packs);
3171 if (
const auto *TND = dyn_cast<TypedefNameDecl>(D)) {
3172 if (!TND->getUnderlyingType()->isDependentType()) {
3173 S.
Diag(Attr.
getLoc(), diag::err_alignment_dependent_typedef_name)
3174 << E->getSourceRange();
3185 unsigned SpellingListIndex,
bool IsPackExpansion) {
3186 AlignedAttr TmpAttr(AttrRange,
Context,
true, E, SpellingListIndex);
3190 if (TmpAttr.isAlignas()) {
3203 if (isa<ParmVarDecl>(D)) {
3205 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(D)) {
3208 if (VD->isExceptionVariable())
3210 }
else if (
FieldDecl *FD = dyn_cast<FieldDecl>(D)) {
3211 if (FD->isBitField())
3213 }
else if (!isa<TagDecl>(D)) {
3214 Diag(AttrLoc, diag::err_attribute_wrong_decl_type) << &TmpAttr
3219 if (DiagKind != -1) {
3220 Diag(AttrLoc, diag::err_alignas_attribute_wrong_decl_type)
3221 << &TmpAttr << DiagKind;
3228 AlignedAttr *AA = ::new (
Context) AlignedAttr(TmpAttr);
3229 AA->setPackExpansion(IsPackExpansion);
3235 llvm::APSInt Alignment;
3238 diag::err_aligned_attribute_argument_not_int,
3243 uint64_t AlignVal = Alignment.getZExtValue();
3250 if (!(TmpAttr.isAlignas() && !Alignment)) {
3251 if (!llvm::isPowerOf2_64(AlignVal)) {
3252 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
3253 << E->getSourceRange();
3259 unsigned MaxValidAlignment =
3262 if (AlignVal > MaxValidAlignment) {
3263 Diag(AttrLoc, diag::err_attribute_aligned_too_great) << MaxValidAlignment
3264 << E->getSourceRange();
3269 unsigned MaxTLSAlign =
3272 auto *VD = dyn_cast<
VarDecl>(D);
3273 if (MaxTLSAlign && AlignVal > MaxTLSAlign && VD &&
3275 Diag(VD->getLocation(), diag::err_tls_var_aligned_over_maximum)
3276 << (
unsigned)AlignVal << VD << MaxTLSAlign;
3281 AlignedAttr *AA = ::new (
Context) AlignedAttr(AttrRange,
Context,
true,
3282 ICE.
get(), SpellingListIndex);
3283 AA->setPackExpansion(IsPackExpansion);
3288 unsigned SpellingListIndex,
bool IsPackExpansion) {
3291 AlignedAttr *AA = ::new (
Context) AlignedAttr(AttrRange,
Context,
false, TS,
3293 AA->setPackExpansion(IsPackExpansion);
3298 assert(D->hasAttrs() &&
"no attributes on decl");
3301 if (
ValueDecl *VD = dyn_cast<ValueDecl>(D)) {
3302 UnderlyingTy = DiagTy = VD->getType();
3305 if (
EnumDecl *ED = dyn_cast<EnumDecl>(D))
3306 UnderlyingTy = ED->getIntegerType();
3308 if (DiagTy->isDependentType() || DiagTy->isIncompleteType())
3315 AlignedAttr *AlignasAttr =
nullptr;
3317 for (
auto *
I : D->specific_attrs<AlignedAttr>()) {
3318 if (
I->isAlignmentDependent())
3325 if (AlignasAttr && Align) {
3328 if (NaturalAlign > RequestedAlign)
3329 Diag(AlignasAttr->getLocation(), diag::err_alignas_underaligned)
3330 << DiagTy << (
unsigned)NaturalAlign.
getQuantity();
3336 MSInheritanceAttr::Spelling SemanticSpelling) {
3345 if (SemanticSpelling == MSInheritanceAttr::Keyword_unspecified_inheritance)
3356 Diag(Range.
getBegin(), diag::err_mismatched_ms_inheritance)
3366 bool &IntegerMode,
bool &ComplexMode) {
3368 ComplexMode =
false;
3369 switch (Str.size()) {
3391 if (Str[1] ==
'F') {
3392 IntegerMode =
false;
3393 }
else if (Str[1] ==
'C') {
3394 IntegerMode =
false;
3396 }
else if (Str[1] !=
'I') {
3405 else if (Str ==
"byte")
3409 if (Str ==
"pointer")
3413 if (Str ==
"unwind_word")
3440 unsigned SpellingListIndex,
bool InInstantiation) {
3441 StringRef Str = Name->
getName();
3445 unsigned DestWidth = 0;
3446 bool IntegerMode =
true;
3447 bool ComplexMode =
false;
3448 llvm::APInt VectorSize(64, 0);
3449 if (Str.size() >= 4 && Str[0] ==
'V') {
3451 size_t StrSize = Str.size();
3452 size_t VectorStringLength = 0;
3453 while ((VectorStringLength + 1) < StrSize &&
3454 isdigit(Str[VectorStringLength + 1]))
3455 ++VectorStringLength;
3456 if (VectorStringLength &&
3457 !Str.substr(1, VectorStringLength).getAsInteger(10, VectorSize) &&
3458 VectorSize.isPowerOf2()) {
3460 IntegerMode, ComplexMode);
3462 if (!InInstantiation)
3463 Diag(AttrLoc, diag::warn_vector_mode_deprecated);
3477 Diag(AttrLoc, diag::err_machine_mode) << 0 <<
Name;
3483 OldTy = TD->getUnderlyingType();
3484 else if (
EnumDecl *ED = dyn_cast<EnumDecl>(D)) {
3487 OldTy = ED->getIntegerType();
3491 OldTy = cast<ValueDecl>(D)->getType();
3495 ModeAttr(AttrRange,
Context, Name, SpellingListIndex));
3503 OldElemTy = VT->getElementType();
3509 VectorSize.getBoolValue()) {
3510 Diag(AttrLoc, diag::err_enum_mode_vector_type) << Name << AttrRange;
3513 bool IntegralOrAnyEnumType =
3517 !IntegralOrAnyEnumType)
3518 Diag(AttrLoc, diag::err_mode_not_primitive);
3519 else if (IntegerMode) {
3520 if (!IntegralOrAnyEnumType)
3521 Diag(AttrLoc, diag::err_mode_wrong_type);
3522 }
else if (ComplexMode) {
3524 Diag(AttrLoc, diag::err_mode_wrong_type);
3527 Diag(AttrLoc, diag::err_mode_wrong_type);
3538 if (NewElemTy.
isNull()) {
3539 Diag(AttrLoc, diag::err_machine_mode) << 1 <<
Name;
3548 if (VectorSize.getBoolValue()) {
3554 Diag(AttrLoc, diag::err_complex_mode_vector_type);
3558 OldVT->getNumElements() /
3565 Diag(AttrLoc, diag::err_mode_wrong_type);
3571 TD->setModedTypeSourceInfo(TD->getTypeSourceInfo(), NewTy);
3572 else if (
EnumDecl *ED = dyn_cast<EnumDecl>(D))
3573 ED->setIntegerType(NewTy);
3575 cast<ValueDecl>(D)->setType(NewTy);
3578 ModeAttr(AttrRange,
Context, Name, SpellingListIndex));
3589 unsigned AttrSpellingListIndex) {
3590 if (OptimizeNoneAttr *Optnone = D->getAttr<OptimizeNoneAttr>()) {
3591 Diag(Range.
getBegin(), diag::warn_attribute_ignored) << Ident;
3592 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
3596 if (D->hasAttr<AlwaysInlineAttr>())
3600 AttrSpellingListIndex);
3605 unsigned AttrSpellingListIndex) {
3606 if (checkAttrMutualExclusion<InternalLinkageAttr>(*
this, D, Range, Ident))
3609 return ::new (
Context) CommonAttr(Range,
Context, AttrSpellingListIndex);
3612 InternalLinkageAttr *
3615 unsigned AttrSpellingListIndex) {
3616 if (
auto VD = dyn_cast<VarDecl>(D)) {
3619 if (VD->getKind() != Decl::Var) {
3620 Diag(Range.
getBegin(), diag::warn_attribute_wrong_decl_type)
3626 if (VD->hasLocalStorage()) {
3627 Diag(VD->getLocation(), diag::warn_internal_linkage_local_storage);
3632 if (checkAttrMutualExclusion<CommonAttr>(*
this, D, Range, Ident))
3636 InternalLinkageAttr(Range,
Context, AttrSpellingListIndex);
3640 unsigned AttrSpellingListIndex) {
3641 if (OptimizeNoneAttr *Optnone = D->getAttr<OptimizeNoneAttr>()) {
3642 Diag(Range.
getBegin(), diag::warn_attribute_ignored) <<
"'minsize'";
3643 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
3647 if (D->hasAttr<MinSizeAttr>())
3650 return ::new (
Context) MinSizeAttr(Range,
Context, AttrSpellingListIndex);
3654 unsigned AttrSpellingListIndex) {
3655 if (AlwaysInlineAttr *Inline = D->getAttr<AlwaysInlineAttr>()) {
3656 Diag(Inline->getLocation(), diag::warn_attribute_ignored) << Inline;
3657 Diag(Range.
getBegin(), diag::note_conflicting_attribute);
3658 D->dropAttr<AlwaysInlineAttr>();
3660 if (MinSizeAttr *MinSize = D->getAttr<MinSizeAttr>()) {
3661 Diag(MinSize->getLocation(), diag::warn_attribute_ignored) << MinSize;
3662 Diag(Range.
getBegin(), diag::note_conflicting_attribute);
3663 D->dropAttr<MinSizeAttr>();
3666 if (D->hasAttr<OptimizeNoneAttr>())
3670 AttrSpellingListIndex);
3675 if (checkAttrMutualExclusion<NotTailCalledAttr>(S, D, Attr.
getRange(),
3688 D->addAttr(MinSize);
3695 D->addAttr(Optnone);
3699 if (checkAttrMutualExclusion<CUDADeviceAttr>(S, D, Attr.
getRange(),
3701 checkAttrMutualExclusion<CUDAHostAttr>(S, D, Attr.
getRange(),
3714 if (
const auto *Method = dyn_cast<CXXMethodDecl>(FD)) {
3715 if (Method->isInstance()) {
3716 S.
Diag(Method->getLocStart(), diag::err_kern_is_nonstatic_method)
3720 S.
Diag(Method->getLocStart(), diag::warn_kern_is_method) << Method;
3734 S.
Diag(Attr.
getLoc(), diag::warn_gnu_inline_attribute_requires_inline);
3752 if (!isa<ObjCMethodDecl>(D)) {
3753 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
3759 case AttributeList::AT_FastCall:
3764 case AttributeList::AT_StdCall:
3769 case AttributeList::AT_ThisCall:
3774 case AttributeList::AT_CDecl:
3779 case AttributeList::AT_Pascal:
3784 case AttributeList::AT_SwiftCall:
3789 case AttributeList::AT_VectorCall:
3794 case AttributeList::AT_MSABI:
3799 case AttributeList::AT_SysVABI:
3804 case AttributeList::AT_Pcs: {
3805 PcsAttr::PCSType PCS;
3808 PCS = PcsAttr::AAPCS;
3811 PCS = PcsAttr::AAPCS_VFP;
3814 llvm_unreachable(
"unexpected calling convention in pcs attribute");
3822 case AttributeList::AT_IntelOclBicc:
3827 case AttributeList::AT_PreserveMost:
3828 D->addAttr(::
new (S.
Context) PreserveMostAttr(
3831 case AttributeList::AT_PreserveAll:
3832 D->addAttr(::
new (S.
Context) PreserveAllAttr(
3836 llvm_unreachable(
"unexpected attribute kind");
3850 unsigned ReqArgs = attr.
getKind() == AttributeList::AT_Pcs ? 1 : 0;
3858 case AttributeList::AT_CDecl: CC =
CC_C;
break;
3862 case AttributeList::AT_Pascal: CC =
CC_X86Pascal;
break;
3863 case AttributeList::AT_SwiftCall: CC =
CC_Swift;
break;
3865 case AttributeList::AT_MSABI:
3869 case AttributeList::AT_SysVABI:
3873 case AttributeList::AT_Pcs: {
3879 if (StrRef ==
"aapcs") {
3882 }
else if (StrRef ==
"aapcs-vfp") {
3894 default: llvm_unreachable(
"unexpected attribute kind");
3905 bool IsCXXMethod =
false, IsVariadic =
false;
3957 unsigned spellingIndex) {
3962 if (existingAttr->getABI() != abi) {
3963 Diag(range.
getBegin(), diag::err_attributes_are_not_compatible)
3965 Diag(existingAttr->getLocation(), diag::note_conflicting_attribute);
3972 llvm_unreachable(
"explicit attribute for ordinary parameter ABI?");
3976 Diag(range.
getBegin(), diag::err_swift_abi_parameter_wrong_type)
3981 SwiftContextAttr(range,
Context, spellingIndex));
3986 Diag(range.
getBegin(), diag::err_swift_abi_parameter_wrong_type)
3991 SwiftErrorResultAttr(range,
Context, spellingIndex));
3996 Diag(range.
getBegin(), diag::err_swift_abi_parameter_wrong_type)
4001 SwiftIndirectResultAttr(range,
Context, spellingIndex));
4004 llvm_unreachable(
"bad parameter ABI attribute");
4026 Diag(Attr.
getLoc(), diag::err_attribute_regparm_wrong_platform)
4027 << NumParamsExpr->getSourceRange();
4034 Diag(Attr.
getLoc(), diag::err_attribute_regparm_invalid_number)
4048 const CUDALaunchBoundsAttr &
Attr,
4049 const unsigned Idx) {
4065 if (!I.isIntN(32)) {
4066 S.
Diag(E->
getExprLoc(), diag::err_ice_too_large) << I.toString(10,
false)
4071 S.
Diag(E->
getExprLoc(), diag::warn_attribute_argument_n_negative)
4072 << &Attr << Idx << E->getSourceRange();
4078 assert(!ValArg.isInvalid() &&
4079 "Unexpected PerformCopyInitialization() failure.");
4085 Expr *MinBlocks,
unsigned SpellingListIndex) {
4086 CUDALaunchBoundsAttr TmpAttr(AttrRange,
Context, MaxThreads, MinBlocks,
4089 if (MaxThreads ==
nullptr)
4094 if (MinBlocks ==
nullptr)
4098 D->addAttr(::
new (
Context) CUDALaunchBoundsAttr(
4099 AttrRange,
Context, MaxThreads, MinBlocks, SpellingListIndex));
4116 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
4127 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_decl_type)
4132 uint64_t ArgumentIdx;
4137 uint64_t TypeTagIdx;
4142 bool IsPointer = (Attr.
getName()->
getName() ==
"pointer_with_type_tag");
4147 S.
Diag(Attr.
getLoc(), diag::err_attribute_pointers_only)
4154 ArgumentIdx, TypeTagIdx, IsPointer,
4161 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
4169 if (!isa<VarDecl>(D)) {
4170 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_decl_type)
4178 assert(MatchingCTypeLoc &&
"no type source info for attribute argument");
4211 Attr.
getKind() == AttributeList::AT_NSConsumed,
4216 unsigned spellingIndex,
bool isNSConsumed,
4232 Diag(D->getLocStart(),
4233 (isTemplateInstantiation && isNSConsumed &&
4235 ? diag::err_ns_attribute_wrong_parameter_type
4236 : diag::warn_ns_attribute_wrong_parameter_type))
4238 << (isNSConsumed ?
"ns_consumed" :
"cf_consumed")
4239 << (isNSConsumed ? 0 : 1);
4244 param->addAttr(::
new (
Context)
4245 NSConsumedAttr(attrRange,
Context, spellingIndex));
4247 param->addAttr(::
new (
Context)
4248 CFConsumedAttr(attrRange,
Context, spellingIndex));
4256 returnType = MD->getReturnType();
4258 (Attr.
getKind() == AttributeList::AT_NSReturnsRetained))
4261 returnType = PD->getType();
4263 returnType = FD->getReturnType();
4264 else if (
auto *Param = dyn_cast<ParmVarDecl>(D)) {
4266 if (returnType.
isNull()) {
4267 S.
Diag(D->getLocStart(), diag::warn_ns_attribute_wrong_parameter_type)
4275 default: llvm_unreachable(
"invalid ownership attribute");
4276 case AttributeList::AT_NSReturnsRetained:
4277 case AttributeList::AT_NSReturnsAutoreleased:
4278 case AttributeList::AT_NSReturnsNotRetained:
4282 case AttributeList::AT_CFReturnsRetained:
4283 case AttributeList::AT_CFReturnsNotRetained:
4287 S.
Diag(D->getLocStart(), diag::warn_attribute_wrong_decl_type)
4295 default: llvm_unreachable(
"invalid ownership attribute");
4296 case AttributeList::AT_NSReturnsRetained:
4301 case AttributeList::AT_NSReturnsAutoreleased:
4302 case AttributeList::AT_NSReturnsNotRetained:
4307 case AttributeList::AT_CFReturnsRetained:
4308 case AttributeList::AT_CFReturnsNotRetained:
4315 if (isa<ParmVarDecl>(D)) {
4316 S.
Diag(D->getLocStart(), diag::warn_ns_attribute_wrong_parameter_type)
4325 } SubjectKind = Function;
4326 if (isa<ObjCMethodDecl>(D))
4327 SubjectKind = Method;
4328 else if (isa<ObjCPropertyDecl>(D))
4330 S.
Diag(D->getLocStart(), diag::warn_ns_attribute_wrong_return_type)
4331 << Attr.
getName() << SubjectKind << cf
4339 llvm_unreachable(
"invalid ownership attribute");
4340 case AttributeList::AT_NSReturnsAutoreleased:
4341 D->addAttr(::
new (S.
Context) NSReturnsAutoreleasedAttr(
4344 case AttributeList::AT_CFReturnsNotRetained:
4345 D->addAttr(::
new (S.
Context) CFReturnsNotRetainedAttr(
4348 case AttributeList::AT_NSReturnsNotRetained:
4349 D->addAttr(::
new (S.
Context) NSReturnsNotRetainedAttr(
4352 case AttributeList::AT_CFReturnsRetained:
4353 D->addAttr(::
new (S.
Context) CFReturnsRetainedAttr(
4356 case AttributeList::AT_NSReturnsRetained:
4357 D->addAttr(::
new (S.
Context) NSReturnsRetainedAttr(
4365 const int EP_ObjCMethod = 1;
4366 const int EP_ObjCProperty = 2;
4370 if (isa<ObjCMethodDecl>(D))
4371 resultType = cast<ObjCMethodDecl>(D)->getReturnType();
4373 resultType = cast<ObjCPropertyDecl>(D)->getType();
4377 S.
Diag(D->getLocStart(), diag::warn_ns_attribute_wrong_return_type)
4380 << (isa<ObjCMethodDecl>(D) ? EP_ObjCMethod : EP_ObjCProperty)
4387 D->addAttr(::
new (S.
Context) ObjCReturnsInnerPointerAttr(
4396 if (
const ObjCProtocolDecl *PDecl = dyn_cast_or_null<ObjCProtocolDecl>(DC)) {
4397 S.
Diag(D->getLocStart(), diag::warn_objc_requires_super_protocol)
4399 S.
Diag(PDecl->getLocation(), diag::note_protocol_decl);
4403 S.
Diag(D->getLocStart(), diag::warn_objc_requires_super_protocol)
4408 method->addAttr(::
new (S.
Context)
4415 if (checkAttrMutualExclusion<CFUnknownTransferAttr>(S, D, Attr.
getRange(),
4426 if (checkAttrMutualExclusion<CFAuditedTransferAttr>(S, D, Attr.
getRange(),
4440 S.
Diag(D->getLocStart(), diag::err_objc_attr_not_id) << Attr.
getName() << 0;
4445 if (
auto TD = dyn_cast<TypedefNameDecl>(D)) {
4447 S.
Diag(Attr.
getLoc(), diag::err_objc_attr_typedef_not_id)
4453 QualType T = TD->getUnderlyingType();
4455 S.
Diag(Attr.
getLoc(), diag::err_objc_attr_typedef_not_void_pointer);
4470 S.
Diag(D->getLocStart(), diag::err_objc_attr_not_id) << Attr.
getName() << 0;
4483 if (!RelatedClass) {
4484 S.
Diag(D->getLocStart(), diag::err_objc_attr_not_id) << Attr.
getName() << 0;
4493 ClassMethod, InstanceMethod,
4501 dyn_cast<ObjCCategoryDecl>(D->getDeclContext()))
4502 IFace = CatDecl->getClassInterface();
4504 IFace = cast<ObjCInterfaceDecl>(D->getDeclContext());
4517 StringRef MetaDataName;
4531 bool notify =
false;
4540 ObjCBoxableAttr *BoxableAttr = ::new (S.
Context)
4543 RD->addAttr(BoxableAttr);
4548 L->AddedAttributeToRecord(BoxableAttr, RD);
4557 S.
Diag(D->getLocStart(), diag::err_attribute_wrong_decl_type)
4566 if (!type->isDependentType() &&
4567 !type->isObjCLifetimeType()) {
4568 S.
Diag(Attr.
getLoc(), diag::err_objc_precise_lifetime_bad_type)
4578 lifetime = type->getObjCARCImplicitLifetime();
4582 assert(type->isDependentType() &&
4583 "didn't infer lifetime for non-dependent type?");
4592 S.
Diag(Attr.
getLoc(), diag::warn_objc_precise_lifetime_meaningless)
4608 S.
Diag(Attr.
getLoc(), diag::err_attribute_not_supported_in_lang)
4613 if (!isa<CXXRecordDecl>(D)) {
4614 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
4626 if (StrRef.size() == 38 && StrRef.front() ==
'{' && StrRef.back() ==
'}')
4627 StrRef = StrRef.drop_front().drop_back();
4630 if (StrRef.size() != 36) {
4631 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
4635 for (
unsigned i = 0; i < 36; ++i) {
4636 if (i == 8 || i == 13 || i == 18 || i == 23) {
4637 if (StrRef[i] !=
'-') {
4638 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
4642 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
4653 S.
Diag(Attr.
getLoc(), diag::err_attribute_not_supported_in_lang)
4669 VarDecl *VD = cast<VarDecl>(D);
4671 S.
Diag(Attr.
getLoc(), diag::err_thread_unsupported);
4675 S.
Diag(Attr.
getLoc(), diag::err_declspec_thread_on_thread_variable);
4679 S.
Diag(Attr.
getLoc(), diag::err_thread_non_global) <<
"__declspec(thread)";
4682 VD->addAttr(::
new (S.
Context) ThreadAttr(
4692 Tags.push_back(Tag);
4695 if (
const auto *NS = dyn_cast<NamespaceDecl>(D)) {
4696 if (!NS->isInline()) {
4697 S.
Diag(Attr.
getLoc(), diag::warn_attr_abi_tag_namespace) << 0;
4700 if (NS->isAnonymousNamespace()) {
4701 S.
Diag(Attr.
getLoc(), diag::warn_attr_abi_tag_namespace) << 1;
4705 Tags.push_back(NS->getName());
4710 std::sort(Tags.begin(), Tags.end());
4711 Tags.erase(std::unique(Tags.begin(), Tags.end()), Tags.end());
4722 S.
Diag(Attr.
getLoc(), diag::err_attribute_too_many_arguments)
4735 ARMInterruptAttr::InterruptType
Kind;
4736 if (!ARMInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
4737 S.
Diag(Attr.
getLoc(), diag::warn_attribute_type_not_supported)
4738 << Attr.
getName() << Str << ArgLoc;
4761 llvm::APSInt NumParams(32);
4763 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type)
4765 << NumParamsExpr->getSourceRange();
4769 unsigned Num = NumParams.getLimitedValue(255);
4770 if ((Num & 1) || Num > 30) {
4771 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4772 << Attr.
getName() << (int)NumParams.getSExtValue()
4773 << NumParamsExpr->getSourceRange();
4780 D->addAttr(UsedAttr::CreateImplicit(S.
Context));
4787 S.
Diag(Attr.
getLoc(), diag::err_attribute_too_many_arguments)
4810 S.
Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
4816 S.
Diag(D->getLocation(), diag::warn_mips_interrupt_attribute)
4822 S.
Diag(D->getLocation(), diag::warn_mips_interrupt_attribute)
4827 if (checkAttrMutualExclusion<Mips16Attr>(S, D, Attr.
getRange(),
4831 MipsInterruptAttr::InterruptType
Kind;
4832 if (!MipsInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
4833 S.
Diag(Attr.
getLoc(), diag::warn_attribute_type_not_supported)
4834 << Attr.
getName() <<
"'" + std::string(Str) +
"'";
4838 D->addAttr(::
new (S.
Context) MipsInterruptAttr(
4852 cast<NamedDecl>(D)->getDeclName().getCXXOverloadedOperator())) {
4853 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
4860 diag::err_anyx86_interrupt_attribute)
4869 if (NumParams < 1 || NumParams > 2) {
4870 S.
Diag(D->getLocStart(), diag::err_anyx86_interrupt_attribute)
4880 diag::err_anyx86_interrupt_attribute)
4892 if (NumParams == 2 &&
4896 diag::err_anyx86_interrupt_attribute)
4903 D->addAttr(::
new (S.
Context) AnyX86InterruptAttr(
4905 D->addAttr(UsedAttr::CreateImplicit(S.
Context));
4911 case llvm::Triple::msp430:
4914 case llvm::Triple::mipsel:
4915 case llvm::Triple::mips:
4918 case llvm::Triple::x86:
4919 case llvm::Triple::x86_64:
4968 if (!isa<FunctionDecl>(D)) {
4969 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
4987 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_out_of_bounds)
4988 << Attr.
getName() << Version << VersionExpr->getSourceRange();
4998 unsigned AttrSpellingListIndex) {
4999 if (D->hasAttr<DLLExportAttr>()) {
5000 Diag(Range.
getBegin(), diag::warn_attribute_ignored) <<
"'dllimport'";
5004 if (D->hasAttr<DLLImportAttr>())
5007 return ::new (
Context) DLLImportAttr(Range,
Context, AttrSpellingListIndex);
5011 unsigned AttrSpellingListIndex) {
5012 if (DLLImportAttr *Import = D->getAttr<DLLImportAttr>()) {
5013 Diag(Import->getLocation(), diag::warn_attribute_ignored) << Import;
5014 D->dropAttr<DLLImportAttr>();
5017 if (D->hasAttr<DLLExportAttr>())
5020 return ::new (
Context) DLLExportAttr(Range,
Context, AttrSpellingListIndex);
5024 if (isa<ClassTemplatePartialSpecializationDecl>(D) &&
5032 if (FD->isInlined() && A.
getKind() == AttributeList::AT_DLLImport &&
5041 if (
auto *MD = dyn_cast<CXXMethodDecl>(D)) {
5043 MD->getParent()->isLambda()) {
5050 Attr *NewAttr = A.
getKind() == AttributeList::AT_DLLExport
5054 D->addAttr(NewAttr);
5059 unsigned AttrSpellingListIndex,
5060 MSInheritanceAttr::Spelling SemanticSpelling) {
5061 if (MSInheritanceAttr *IA = D->getAttr<MSInheritanceAttr>()) {
5062 if (IA->getSemanticSpelling() == SemanticSpelling)
5064 Diag(IA->getLocation(), diag::err_mismatched_ms_inheritance)
5066 Diag(Range.
getBegin(), diag::note_previous_ms_inheritance);
5067 D->dropAttr<MSInheritanceAttr>();
5073 SemanticSpelling)) {
5077 if (isa<ClassTemplatePartialSpecializationDecl>(RD)) {
5078 Diag(Range.
getBegin(), diag::warn_ignored_ms_inheritance)
5083 Diag(Range.
getBegin(), diag::warn_ignored_ms_inheritance)
5090 MSInheritanceAttr(Range,
Context, BestCase, AttrSpellingListIndex);
5102 StringRef N(
"mutex");
5104 if (Attr.
getKind() == AttributeList::AT_Capability &&
5110 if (!N.equals_lower(
"mutex") && !N.equals_lower(
"role"))
5111 S.
Diag(LiteralLoc, diag::warn_invalid_capability_name) << N;
5132 Args.data(), Args.size(),
5142 D->addAttr(::
new (S.
Context) TryAcquireCapabilityAttr(Attr.
getRange(),
5156 D->addAttr(::
new (S.
Context) ReleaseCapabilityAttr(
5172 RequiresCapabilityAttr *RCA = ::new (S.
Context)
5180 if (
auto *NSD = dyn_cast<NamespaceDecl>(D)) {
5181 if (NSD->isAnonymousNamespace()) {
5182 S.
Diag(Attr.
getLoc(), diag::warn_deprecated_anonymous_namespace);
5217 std::vector<StringRef> Sanitizers;
5220 StringRef SanitizerName;
5227 S.
Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << SanitizerName;
5229 Sanitizers.push_back(SanitizerName);
5232 D->addAttr(::
new (S.
Context) NoSanitizeAttr(
5241 StringRef SanitizerName =
5242 llvm::StringSwitch<StringRef>(AttrName)
5243 .Case(
"no_address_safety_analysis",
"address")
5244 .Case(
"no_sanitize_address",
"address")
5245 .Case(
"no_sanitize_thread",
"thread")
5246 .Case(
"no_sanitize_memory",
"memory");
5254 if (InternalLinkageAttr *Internal =
5257 D->addAttr(Internal);
5261 if (S.
LangOpts.OpenCLVersion != 200)
5262 S.
Diag(Attr.
getLoc(), diag::err_attribute_requires_opencl_version)
5263 << Attr.
getName() <<
"2.0" << 0;
5265 S.
Diag(Attr.
getLoc(), diag::warn_opencl_attr_deprecated_ignored)
5312 if (D->isInvalidDecl())
5316 if (D->hasAttr<OpenCLAccessAttr>()) {
5317 S.
Diag(Attr.
getLoc(), diag::err_opencl_multiple_access_qualifiers)
5318 << D->getSourceRange();
5319 D->setInvalidDecl(
true);
5328 if (
const ParmVarDecl *PDecl = dyn_cast<ParmVarDecl>(D)) {
5329 const Type *DeclTy = PDecl->getType().getCanonicalType().getTypePtr();
5330 if (Attr.
getName()->
getName().find(
"read_write") != StringRef::npos) {
5332 S.
Diag(Attr.
getLoc(), diag::err_opencl_invalid_read_write)
5334 D->setInvalidDecl(
true);
5340 D->addAttr(::
new (S.
Context) OpenCLAccessAttr(
5353 bool IncludeCXX11Attributes) {
5368 ? diag::warn_unhandled_ms_attribute_ignored
5369 : diag::warn_unknown_attribute_ignored)
5381 assert(Attr.
isTypeAttr() &&
"Non-type attribute not handled");
5384 S.
Diag(Attr.
getLoc(), diag::err_stmt_attribute_invalid_on_decl)
5385 << Attr.
getName() << D->getLocation();
5387 case AttributeList::AT_Interrupt:
5390 case AttributeList::AT_X86ForceAlignArgPointer:
5393 case AttributeList::AT_DLLExport:
5394 case AttributeList::AT_DLLImport:
5397 case AttributeList::AT_Mips16:
5398 handleSimpleAttributeWithExclusions<Mips16Attr, MipsInterruptAttr>(
S, D,
5401 case AttributeList::AT_NoMips16:
5402 handleSimpleAttribute<NoMips16Attr>(
S, D, Attr);
5404 case AttributeList::AT_AMDGPUNumVGPR:
5407 case AttributeList::AT_AMDGPUNumSGPR:
5410 case AttributeList::AT_IBAction:
5411 handleSimpleAttribute<IBActionAttr>(
S, D, Attr);
5413 case AttributeList::AT_IBOutlet:
5416 case AttributeList::AT_IBOutletCollection:
5419 case AttributeList::AT_IFunc:
5422 case AttributeList::AT_Alias:
5425 case AttributeList::AT_Aligned:
5428 case AttributeList::AT_AlignValue:
5431 case AttributeList::AT_AlwaysInline:
5434 case AttributeList::AT_AnalyzerNoReturn:
5437 case AttributeList::AT_TLSModel:
5440 case AttributeList::AT_Annotate:
5443 case AttributeList::AT_Availability:
5446 case AttributeList::AT_CarriesDependency:
5449 case AttributeList::AT_Common:
5452 case AttributeList::AT_CUDAConstant:
5453 handleSimpleAttributeWithExclusions<CUDAConstantAttr, CUDASharedAttr>(
S, D,
5456 case AttributeList::AT_PassObjectSize:
5459 case AttributeList::AT_Constructor:
5462 case AttributeList::AT_CXX11NoReturn:
5463 handleSimpleAttribute<CXX11NoReturnAttr>(
S, D, Attr);
5465 case AttributeList::AT_Deprecated:
5468 case AttributeList::AT_Destructor:
5471 case AttributeList::AT_EnableIf:
5474 case AttributeList::AT_ExtVectorType:
5477 case AttributeList::AT_MinSize:
5480 case AttributeList::AT_OptimizeNone:
5483 case AttributeList::AT_FlagEnum:
5484 handleSimpleAttribute<FlagEnumAttr>(
S, D, Attr);
5486 case AttributeList::AT_Flatten:
5487 handleSimpleAttribute<FlattenAttr>(
S, D, Attr);
5489 case AttributeList::AT_Format:
5492 case AttributeList::AT_FormatArg:
5495 case AttributeList::AT_CUDAGlobal:
5498 case AttributeList::AT_CUDADevice:
5499 handleSimpleAttributeWithExclusions<CUDADeviceAttr, CUDAGlobalAttr>(
S, D,
5502 case AttributeList::AT_CUDAHost:
5503 handleSimpleAttributeWithExclusions<CUDAHostAttr, CUDAGlobalAttr>(
S, D,
5506 case AttributeList::AT_GNUInline:
5509 case AttributeList::AT_CUDALaunchBounds:
5512 case AttributeList::AT_Restrict:
5515 case AttributeList::AT_MayAlias:
5516 handleSimpleAttribute<MayAliasAttr>(
S, D, Attr);
5518 case AttributeList::AT_Mode:
5521 case AttributeList::AT_NoAlias:
5522 handleSimpleAttribute<NoAliasAttr>(
S, D, Attr);
5524 case AttributeList::AT_NoCommon:
5525 handleSimpleAttribute<NoCommonAttr>(
S, D, Attr);
5527 case AttributeList::AT_NoSplitStack:
5528 handleSimpleAttribute<NoSplitStackAttr>(
S, D, Attr);
5530 case AttributeList::AT_NonNull:
5536 case AttributeList::AT_ReturnsNonNull:
5539 case AttributeList::AT_AssumeAligned:
5542 case AttributeList::AT_Overloadable:
5543 handleSimpleAttribute<OverloadableAttr>(
S, D, Attr);
5545 case AttributeList::AT_Ownership:
5548 case AttributeList::AT_Cold:
5551 case AttributeList::AT_Hot:
5554 case AttributeList::AT_Naked:
5557 case AttributeList::AT_NoReturn:
5560 case AttributeList::AT_NoThrow:
5561 handleSimpleAttribute<NoThrowAttr>(
S, D, Attr);
5563 case AttributeList::AT_CUDAShared:
5564 handleSimpleAttributeWithExclusions<CUDASharedAttr, CUDAConstantAttr>(
S, D,
5567 case AttributeList::AT_VecReturn:
5570 case AttributeList::AT_ObjCOwnership:
5573 case AttributeList::AT_ObjCPreciseLifetime:
5576 case AttributeList::AT_ObjCReturnsInnerPointer:
5579 case AttributeList::AT_ObjCRequiresSuper:
5582 case AttributeList::AT_ObjCBridge:
5585 case AttributeList::AT_ObjCBridgeMutable:
5588 case AttributeList::AT_ObjCBridgeRelated:
5591 case AttributeList::AT_ObjCDesignatedInitializer:
5594 case AttributeList::AT_ObjCRuntimeName:
5597 case AttributeList::AT_ObjCRuntimeVisible:
5598 handleSimpleAttribute<ObjCRuntimeVisibleAttr>(
S, D, Attr);
5600 case AttributeList::AT_ObjCBoxable:
5603 case AttributeList::AT_CFAuditedTransfer:
5606 case AttributeList::AT_CFUnknownTransfer:
5609 case AttributeList::AT_CFConsumed:
5610 case AttributeList::AT_NSConsumed:
5613 case AttributeList::AT_NSConsumesSelf:
5614 handleSimpleAttribute<NSConsumesSelfAttr>(
S, D, Attr);
5616 case AttributeList::AT_NSReturnsAutoreleased:
5617 case AttributeList::AT_NSReturnsNotRetained:
5618 case AttributeList::AT_CFReturnsNotRetained:
5619 case AttributeList::AT_NSReturnsRetained:
5620 case AttributeList::AT_CFReturnsRetained:
5623 case AttributeList::AT_WorkGroupSizeHint:
5624 handleWorkGroupSize<WorkGroupSizeHintAttr>(
S, D, Attr);
5626 case AttributeList::AT_ReqdWorkGroupSize:
5627 handleWorkGroupSize<ReqdWorkGroupSizeAttr>(
S, D, Attr);
5629 case AttributeList::AT_VecTypeHint:
5632 case AttributeList::AT_InitPriority:
5635 case AttributeList::AT_Packed:
5638 case AttributeList::AT_Section:
5641 case AttributeList::AT_Target:
5644 case AttributeList::AT_Unavailable:
5645 handleAttrWithMessage<UnavailableAttr>(
S, D, Attr);
5647 case AttributeList::AT_ArcWeakrefUnavailable:
5648 handleSimpleAttribute<ArcWeakrefUnavailableAttr>(
S, D, Attr);
5650 case AttributeList::AT_ObjCRootClass:
5651 handleSimpleAttribute<ObjCRootClassAttr>(
S, D, Attr);
5653 case AttributeList::AT_ObjCExplicitProtocolImpl:
5656 case AttributeList::AT_ObjCRequiresPropertyDefs:
5657 handleSimpleAttribute<ObjCRequiresPropertyDefsAttr>(
S, D, Attr);
5659 case AttributeList::AT_Unused:
5662 case AttributeList::AT_ReturnsTwice:
5663 handleSimpleAttribute<ReturnsTwiceAttr>(
S, D, Attr);
5665 case AttributeList::AT_NotTailCalled:
5668 case AttributeList::AT_DisableTailCalls:
5671 case AttributeList::AT_Used:
5674 case AttributeList::AT_Visibility:
5677 case AttributeList::AT_TypeVisibility:
5680 case AttributeList::AT_WarnUnused:
5681 handleSimpleAttribute<WarnUnusedAttr>(
S, D, Attr);
5683 case AttributeList::AT_WarnUnusedResult:
5686 case AttributeList::AT_Weak:
5687 handleSimpleAttribute<WeakAttr>(
S, D, Attr);
5689 case AttributeList::AT_WeakRef:
5692 case AttributeList::AT_WeakImport:
5695 case AttributeList::AT_TransparentUnion:
5698 case AttributeList::AT_ObjCException:
5699 handleSimpleAttribute<ObjCExceptionAttr>(
S, D, Attr);
5701 case AttributeList::AT_ObjCMethodFamily:
5704 case AttributeList::AT_ObjCNSObject:
5707 case AttributeList::AT_ObjCIndependentClass:
5710 case AttributeList::AT_Blocks:
5713 case AttributeList::AT_Sentinel:
5716 case AttributeList::AT_Const:
5717 handleSimpleAttribute<ConstAttr>(
S, D, Attr);
5719 case AttributeList::AT_Pure:
5720 handleSimpleAttribute<PureAttr>(
S, D, Attr);
5722 case AttributeList::AT_Cleanup:
5725 case AttributeList::AT_NoDebug:
5728 case AttributeList::AT_NoDuplicate:
5729 handleSimpleAttribute<NoDuplicateAttr>(
S, D, Attr);
5731 case AttributeList::AT_NoInline:
5732 handleSimpleAttribute<NoInlineAttr>(
S, D, Attr);
5734 case AttributeList::AT_NoInstrumentFunction:
5735 handleSimpleAttribute<NoInstrumentFunctionAttr>(
S, D, Attr);
5737 case AttributeList::AT_StdCall:
5738 case AttributeList::AT_CDecl:
5739 case AttributeList::AT_FastCall:
5740 case AttributeList::AT_ThisCall:
5741 case AttributeList::AT_Pascal:
5742 case AttributeList::AT_SwiftCall:
5743 case AttributeList::AT_VectorCall:
5744 case AttributeList::AT_MSABI:
5745 case AttributeList::AT_SysVABI:
5746 case AttributeList::AT_Pcs:
5747 case AttributeList::AT_IntelOclBicc:
5748 case AttributeList::AT_PreserveMost:
5749 case AttributeList::AT_PreserveAll:
5752 case AttributeList::AT_OpenCLKernel:
5753 handleSimpleAttribute<OpenCLKernelAttr>(
S, D, Attr);
5755 case AttributeList::AT_OpenCLAccess:
5758 case AttributeList::AT_OpenCLNoSVM:
5761 case AttributeList::AT_SwiftContext:
5764 case AttributeList::AT_SwiftErrorResult:
5767 case AttributeList::AT_SwiftIndirectResult:
5770 case AttributeList::AT_InternalLinkage:
5773 case AttributeList::AT_LTOVisibilityPublic:
5774 handleSimpleAttribute<LTOVisibilityPublicAttr>(
S, D, Attr);
5778 case AttributeList::AT_EmptyBases:
5779 handleSimpleAttribute<EmptyBasesAttr>(
S, D, Attr);
5781 case AttributeList::AT_LayoutVersion:
5784 case AttributeList::AT_MSNoVTable:
5785 handleSimpleAttribute<MSNoVTableAttr>(
S, D, Attr);
5787 case AttributeList::AT_MSStruct:
5788 handleSimpleAttribute<MSStructAttr>(
S, D, Attr);
5790 case AttributeList::AT_Uuid:
5793 case AttributeList::AT_MSInheritance:
5796 case AttributeList::AT_SelectAny:
5797 handleSimpleAttribute<SelectAnyAttr>(
S, D, Attr);
5799 case AttributeList::AT_Thread:
5803 case AttributeList::AT_AbiTag:
5808 case AttributeList::AT_AssertExclusiveLock:
5811 case AttributeList::AT_AssertSharedLock:
5814 case AttributeList::AT_GuardedVar:
5815 handleSimpleAttribute<GuardedVarAttr>(
S, D, Attr);
5817 case AttributeList::AT_PtGuardedVar:
5820 case AttributeList::AT_ScopedLockable:
5821 handleSimpleAttribute<ScopedLockableAttr>(
S, D, Attr);
5823 case AttributeList::AT_NoSanitize:
5826 case AttributeList::AT_NoSanitizeSpecific:
5829 case AttributeList::AT_NoThreadSafetyAnalysis:
5830 handleSimpleAttribute<NoThreadSafetyAnalysisAttr>(
S, D, Attr);
5832 case AttributeList::AT_GuardedBy:
5835 case AttributeList::AT_PtGuardedBy:
5838 case AttributeList::AT_ExclusiveTrylockFunction:
5841 case AttributeList::AT_LockReturned:
5844 case AttributeList::AT_LocksExcluded:
5847 case AttributeList::AT_SharedTrylockFunction:
5850 case AttributeList::AT_AcquiredBefore:
5853 case AttributeList::AT_AcquiredAfter:
5858 case AttributeList::AT_Capability:
5859 case AttributeList::AT_Lockable:
5862 case AttributeList::AT_RequiresCapability:
5866 case AttributeList::AT_AssertCapability:
5869 case AttributeList::AT_AcquireCapability:
5872 case AttributeList::AT_ReleaseCapability:
5875 case AttributeList::AT_TryAcquireCapability:
5880 case AttributeList::AT_Consumable:
5883 case AttributeList::AT_ConsumableAutoCast:
5884 handleSimpleAttribute<ConsumableAutoCastAttr>(
S, D, Attr);
5886 case AttributeList::AT_ConsumableSetOnRead:
5887 handleSimpleAttribute<ConsumableSetOnReadAttr>(
S, D, Attr);
5889 case AttributeList::AT_CallableWhen:
5892 case AttributeList::AT_ParamTypestate:
5895 case AttributeList::AT_ReturnTypestate:
5898 case AttributeList::AT_SetTypestate:
5901 case AttributeList::AT_TestTypestate:
5906 case AttributeList::AT_ArgumentWithTypeTag:
5909 case AttributeList::AT_TypeTagForDatatype:
5912 case AttributeList::AT_RenderScriptKernel:
5913 handleSimpleAttribute<RenderScriptKernelAttr>(
S, D, Attr);
5916 case AttributeList::AT_XRayInstrument:
5917 handleSimpleAttribute<XRayInstrumentAttr>(
S, D, Attr);
5926 bool IncludeCXX11Attributes) {
5934 if (D->hasAttr<WeakRefAttr>() && !D->hasAttr<AliasAttr>()) {
5935 Diag(AttrList->
getLoc(), diag::err_attribute_weakref_without_alias)
5936 << cast<NamedDecl>(D);
5937 D->dropAttr<WeakRefAttr>();
5945 if (!D->hasAttr<OpenCLKernelAttr>()) {
5947 if (
Attr *A = D->getAttr<ReqdWorkGroupSizeAttr>()) {
5950 Diag(D->getLocation(), diag::err_opencl_kernel_attr) << A;
5951 D->setInvalidDecl();
5952 }
else if (
Attr *A = D->getAttr<WorkGroupSizeHintAttr>()) {
5953 Diag(D->getLocation(), diag::err_opencl_kernel_attr) << A;
5954 D->setInvalidDecl();
5955 }
else if (
Attr *A = D->getAttr<VecTypeHintAttr>()) {
5956 Diag(D->getLocation(), diag::err_opencl_kernel_attr) << A;
5957 D->setInvalidDecl();
5958 }
else if (
Attr *A = D->getAttr<AMDGPUNumVGPRAttr>()) {
5959 Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
5961 D->setInvalidDecl();
5962 }
else if (
Attr *A = D->getAttr<AMDGPUNumSGPRAttr>()) {
5963 Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
5965 D->setInvalidDecl();
5975 if (l->getKind() == AttributeList::AT_Annotate) {
5978 Diag(l->getLoc(), diag::err_only_annotate_after_access_spec);
5989 for ( ; A; A = A->
getNext()) {
5995 S.
Diag(A->
getLoc(), diag::warn_unknown_attribute_ignored)
5998 S.
Diag(A->
getLoc(), diag::warn_attribute_not_on_decl)
6018 assert(isa<FunctionDecl>(ND) || isa<VarDecl>(ND));
6028 FD->getType(), FD->getTypeSourceInfo(),
6034 if (FD->getQualifier())
6042 for (
const auto &AI : FT->param_types()) {
6045 Params.push_back(Param);
6047 NewFD->setParams(Params);
6049 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(ND)) {
6051 VD->getInnerLocStart(), VD->getLocation(), II,
6052 VD->getType(), VD->getTypeSourceInfo(),
6053 VD->getStorageClass());
6054 if (VD->getQualifier()) {
6055 VarDecl *NewVD = cast<VarDecl>(NewD);
6070 NewD->addAttr(AliasAttr::CreateImplicit(
Context, NDId->
getName(),
6093 if (
VarDecl *VD = dyn_cast<VarDecl>(D))
6094 if (VD->isExternC())
6097 if (FD->isExternC())
6138 UnavailableAttr::ImplicitReason &reason) {
6142 if (!isa<FieldDecl>(decl) && !isa<ObjCPropertyDecl>(decl) &&
6143 !isa<FunctionDecl>(decl))
6151 if ((isa<ObjCIvarDecl>(decl) || isa<ObjCPropertyDecl>(decl))) {
6154 reason = UnavailableAttr::IR_ForbiddenWeak;
6163 reason = UnavailableAttr::IR_ARCForbiddenType;
6173 auto reason = UnavailableAttr::IR_None;
6175 assert(reason &&
"didn't set reason?");
6176 decl->addAttr(UnavailableAttr::CreateImplicit(S.
Context,
"", reason,
6181 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(decl)) {
6184 if (FD->hasAttr<UnavailableAttr>() &&
6186 diag::err_arc_array_param_no_ownership) {
6199 if (D->isDeprecated())
6204 return Interface->isDeprecated();
6205 }
while ((D = cast_or_null<Decl>(D->getDeclContext())));
6211 if (D->isUnavailable())
6216 return Interface->isUnavailable();
6217 }
while ((D = cast_or_null<Decl>(D->getDeclContext())));
6224 for (
const auto *A : D->attrs()) {
6225 if (
const auto *Avail = dyn_cast<AvailabilityAttr>(A)) {
6231 StringRef ActualPlatform = Avail->getPlatform()->getName();
6232 StringRef RealizedPlatform = ActualPlatform;
6234 size_t suffix = RealizedPlatform.rfind(
"_app_extension");
6235 if (suffix != StringRef::npos)
6236 RealizedPlatform = RealizedPlatform.slice(0, suffix);
6242 if (RealizedPlatform == TargetPlatform)
6254 bool ObjCPropertyAccess) {
6256 unsigned diag, diag_message, diag_fwdclass_message;
6257 unsigned diag_available_here = diag::note_availability_specified_here;
6260 unsigned property_note_select;
6263 unsigned available_here_select_kind;
6270 diag = !ObjCPropertyAccess ? diag::warn_deprecated
6271 : diag::warn_property_method_deprecated;
6272 diag_message = diag::warn_deprecated_message;
6273 diag_fwdclass_message = diag::warn_deprecated_fwdclass_message;
6274 property_note_select = 0;
6275 available_here_select_kind = 2;
6281 diag = !ObjCPropertyAccess ? diag::err_unavailable
6282 : diag::err_property_method_unavailable;
6283 diag_message = diag::err_unavailable_message;
6284 diag_fwdclass_message = diag::warn_unavailable_fwdclass_message;
6285 property_note_select = 1;
6286 available_here_select_kind = 0;
6288 if (
auto attr = D->getAttr<UnavailableAttr>()) {
6289 if (attr->isImplicit() && attr->getImplicitReason()) {
6292 auto flagARCError = [&] {
6295 diag = diag::err_unavailable_in_arc;
6298 switch (attr->getImplicitReason()) {
6299 case UnavailableAttr::IR_None:
break;
6301 case UnavailableAttr::IR_ARCForbiddenType:
6303 diag_available_here = diag::note_arc_forbidden_type;
6306 case UnavailableAttr::IR_ForbiddenWeak:
6308 diag_available_here = diag::note_arc_weak_disabled;
6310 diag_available_here = diag::note_arc_weak_no_runtime;
6313 case UnavailableAttr::IR_ARCForbiddenConversion:
6315 diag_available_here = diag::note_performs_forbidden_arc_conversion;
6318 case UnavailableAttr::IR_ARCInitReturnsUnrelated:
6320 diag_available_here = diag::note_arc_init_returns_unrelated;
6323 case UnavailableAttr::IR_ARCFieldWithOwnership:
6325 diag_available_here = diag::note_arc_field_with_ownership;
6333 diag = diag::warn_partial_availability;
6334 diag_message = diag::warn_partial_message;
6335 diag_fwdclass_message = diag::warn_partial_fwdclass_message;
6336 property_note_select = 2;
6337 available_here_select_kind = 3;
6344 if (
auto attr = D->getAttr<DeprecatedAttr>())
6345 Replacement = attr->getReplacement();
6347 Replacement = attr->getReplacement();
6349 if (!Replacement.empty())
6354 if (!Message.empty()) {
6355 S.
Diag(Loc, diag_message) << D << Message
6359 S.
Diag(ObjCProperty->getLocation(), diag::note_property_attribute)
6360 << ObjCProperty->
getDeclName() << property_note_select;
6361 }
else if (!UnknownObjCClass) {
6362 S.
Diag(Loc, diag) << D
6366 S.
Diag(ObjCProperty->getLocation(), diag::note_property_attribute)
6367 << ObjCProperty->
getDeclName() << property_note_select;
6369 S.
Diag(Loc, diag_fwdclass_message) << D
6372 S.
Diag(UnknownObjCClass->getLocation(), diag::note_forward_class);
6378 if (A && A->isInherited()) {
6380 Redecl = Redecl->getPreviousDecl()) {
6383 if (AForRedecl && !AForRedecl->isInherited()) {
6386 S.
Diag(Redecl->getLocation(), diag_available_here) << D
6387 << available_here_select_kind;
6393 S.
Diag(D->getLocation(), diag_available_here)
6394 << D << available_here_select_kind;
6397 S.
Diag(Loc, diag::note_partial_availability_silence) << D;
6439 switch (diag.
Kind) {
6444 if (!decl->isInvalidDecl())
6465 assert(curPool &&
"re-emitting in undelayed context not supported");
6466 curPool->
steal(pool);
6474 bool ObjCPropertyAccess) {
6478 AD, Loc, D, UnknownObjCClass, ObjCProperty, Message,
6479 ObjCPropertyAccess));
6485 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)
unsigned getAddressSpace() const
Return the address space of this type.
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)
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.
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)
unsigned getProcessingCache() const
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.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
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 handleOpenCLNoSVMAttr(Sema &S, Decl *D, const AttributeList &Attr)
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)
static bool isValidSwiftErrorResultType(QualType type)
Pointers and references to pointers in the default address space.
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
void AddParameterABIAttr(SourceRange AttrRange, Decl *D, ParameterABI ABI, unsigned SpellingListIndex)
ParmVarDecl - Represents a parameter to a function.
bool isObjCRetainableType() const
Defines the clang::Expr interface and subclasses for C++ expressions.
const Expr * getReplacementExpr() const
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.
static void handleAnyX86InterruptAttr(Sema &S, Decl *D, const AttributeList &Attr)
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)
void AddModeAttr(SourceRange AttrRange, Decl *D, IdentifierInfo *Name, unsigned SpellingListIndex, bool InInstantiation=false)
AddModeAttr - Adds a mode attribute to a particular declaration.
static void handleOpenCLAccessAttr(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.
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)
i32 captured_struct **param SharedsTy A type which contains references the shared variables *param Shareds Context with the list of shared variables from the p *TaskFunction *param Data Additional data for task generation like final * state
static void 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.
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)
This parameter (which must have pointer type) uses the special Swift context-pointer ABI treatment...
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)
const LangOptions & getLangOpts() const
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
CharUnits - This is an opaque type for sizes expressed in character units.
static void handleNoSanitizeAttr(Sema &S, Decl *D, const AttributeList &Attr)
static bool isStaticDataMember(const Decl *D)
Determine whether the given declaration is a static data member.
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
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]).
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...
bool hasProcessingCache() const
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
bool isVariadic() const
Whether this function is variadic.
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)
This parameter (which must have pointer-to-pointer type) uses the special Swift error-result ABI trea...
virtual unsigned getUnwindWordWidth() const
static SourceRange getFunctionOrMethodParamRange(const Decl *D, unsigned Idx)
void AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, unsigned SpellingListIndex, bool IsPackExpansion)
AddAlignedAttr - Adds an aligned attribute to a particular declaration.
This object can be modified without requiring retains or releases.
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)
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?
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...
Represents a character-granular source range.
DLLImportAttr * mergeDLLImportAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
static bool checkIBOutletCommon(Sema &S, Decl *D, const AttributeList &Attr)
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type...
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")...
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)
void CheckAlignasUnderalignment(Decl *D)
bool isFloatingType() const
static void handleParameterABIAttr(Sema &S, Decl *D, const AttributeList &attr, ParameterABI abi)
void setProcessingCache(unsigned value) const
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
virtual void AssignInheritanceModel(CXXRecordDecl *RD)
Callback invoked when an MSInheritanceAttr has been attached to a CXXRecordDecl.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
static void handleIFuncAttr(Sema &S, Decl *D, const AttributeList &Attr)
bool isObjCIdType() 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
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.
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
static void handleAbiTagAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleWeakImportAttr(Sema &S, Decl *D, const AttributeList &Attr)
static CharSourceRange getCharRange(SourceRange R)
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.
static void handleTryAcquireCapabilityAttr(Sema &S, Decl *D, const AttributeList &Attr)
A parameter attribute which changes the argument-passing ABI rule for the parameter.
static bool isFunctionOrMethodOrBlock(const Decl *D)
Return true if the given decl has function type (function or function-typed variable) or an Objective...
There is no lifetime qualification on this type.
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
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 ...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
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)
QualType getConstType(QualType T) const
Return the uniqued reference to the type for a const qualified type.
Represents a static or instance method of a struct/union/class.
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
virtual unsigned getRegisterWidth() const
Return the "preferred" register width on this target.
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)
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
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)
ParameterABI
Kinds of parameter ABI.
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.
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
static void handleLayoutVersion(Sema &S, Decl *D, const AttributeList &Attr)
static bool isStaticOverloadedOperator(OverloadedOperatorKind OOK)
Returns true if the given operator is implicitly static in a record context.
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 handleUnusedAttr(Sema &S, Decl *D, const AttributeList &Attr)
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)
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.
void AddNSConsumedAttr(SourceRange AttrRange, Decl *D, unsigned SpellingListIndex, bool isNSConsumed, bool isTemplateInstantiation)
StringRef getString() const
static void handleInternalLinkageAttr(Sema &S, Decl *D, const AttributeList &Attr)
SourceLocation getLocStart() const LLVM_READONLY
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)
SourceLocation getStrictLoc() const
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
Base for LValueReferenceType and RValueReferenceType.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
llvm::StringRef getParameterABISpelling(ParameterABI kind)
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)
char __ovld __cnfn max(char x, char y)
Returns y if x < y, otherwise it returns x.
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)
A diagnostic message which has been conditionally emitted pending the complete parsing of the current...
ObjCIvarDecl - Represents an ObjC instance variable.
CallingConv getDefaultCallingConvention(bool isVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current target.
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.
NamedDecl * getMostRecentDecl()
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...
static const AvailabilityAttr * getAttrForPlatform(ASTContext &Context, const Decl *D)
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
static Expr * makeLaunchBoundsArgExpr(Sema &S, Expr *E, const CUDALaunchBoundsAttr &Attr, const unsigned Idx)
A trivial tuple used to represent a source range.
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.
Describes an entity that is being initialized.
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
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)
StringRef getPlatformName() const
Retrieve the name of the platform as it is used in the availability attribute.
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.
AvailabilityAttr * mergeAvailabilityAttr(NamedDecl *D, SourceRange Range, IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK, unsigned AttrSpellingListIndex)
Attribute merging methods. Return true if a new attribute was added.
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)
static bool isValidSwiftIndirectResultType(QualType type)
Pointers and references in the default address space.
Attr - This represents one attribute.
ParsedAttributes & getAttributes()
bool hasPointerRepresentation() const
Whether this type is represented natively as a pointer.
This parameter (which must have pointer type) is a Swift indirect result parameter.
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
static bool isValidSwiftContextType(QualType type)
Pointer-like types in the default address space.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
AttributeList - Represents a syntactic attribute.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
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