35 #include "llvm/ADT/STLExtras.h" 36 #include "llvm/ADT/StringExtras.h" 37 #include "llvm/Support/MathExtras.h" 39 using namespace clang;
71 return isa<DeclaratorDecl>(D) || isa<BlockDecl>(D) || isa<TypedefNameDecl>(D) ||
72 isa<ObjCPropertyDecl>(D);
80 return isa<FunctionProtoType>(FnTy);
81 return isa<ObjCMethodDecl>(D) || isa<BlockDecl>(D);
89 return cast<FunctionProtoType>(FnTy)->getNumParams();
90 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D))
91 return BD->getNumParams();
92 return cast<ObjCMethodDecl>(D)->param_size();
97 return cast<FunctionProtoType>(FnTy)->getParamType(Idx);
98 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D))
99 return BD->getParamDecl(Idx)->getType();
101 return cast<ObjCMethodDecl>(D)->parameters()[Idx]->getType();
105 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
106 return FD->getParamDecl(Idx)->getSourceRange();
107 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
108 return MD->parameters()[Idx]->getSourceRange();
109 if (
const auto *BD = dyn_cast<BlockDecl>(D))
110 return BD->getParamDecl(Idx)->getSourceRange();
116 return cast<FunctionType>(FnTy)->getReturnType();
117 return cast<ObjCMethodDecl>(D)->getReturnType();
121 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
122 return FD->getReturnTypeSourceRange();
123 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
124 return MD->getReturnTypeSourceRange();
133 if (
const BlockDecl *BD = dyn_cast<BlockDecl>(D))
134 return BD->isVariadic();
136 return cast<ObjCMethodDecl>(D)->isVariadic();
140 if (
const CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(D))
141 return MethodDecl->isInstance();
157 return ClsName == &Ctx.
Idents.
get(
"NSString") ||
158 ClsName == &Ctx.
Idents.
get(
"NSMutableString");
182 template <
typename Compare>
184 unsigned Num,
unsigned Diag,
199 diag::err_attribute_wrong_number_arguments,
200 std::not_equal_to<unsigned>());
208 diag::err_attribute_too_few_arguments,
209 std::less<unsigned>());
217 diag::err_attribute_too_many_arguments,
218 std::greater<unsigned>());
223 template <
typename AttrInfo>
224 static typename std::enable_if<std::is_base_of<clang::Attr, AttrInfo>::value,
227 return Attr.getLocation();
235 template <
typename AttrInfo>
236 static typename std::enable_if<std::is_base_of<clang::Attr, AttrInfo>::value,
247 template<
typename AttrInfo>
249 uint32_t &Val,
unsigned Idx =
UINT_MAX) {
266 << I.toString(10,
false) << 32 << 1;
270 Val = (uint32_t)I.getZExtValue();
277 template<
typename AttrInfo>
279 int &Val,
unsigned Idx =
UINT_MAX) {
288 << I.toString(10,
false) << 32 << 0;
298 template <
typename AttrTy>
301 if (AttrTy *A = D->
getAttr<AttrTy>()) {
302 S.
Diag(Range.
getBegin(), diag::err_attributes_are_not_compatible) << Ident
304 S.
Diag(A->getLocation(), diag::note_conflicting_attribute);
314 template <
typename AttrInfo>
316 Sema &S,
const Decl *D,
const AttrInfo &
Attr,
unsigned AttrArgNum,
317 const Expr *IdxExpr, uint64_t &Idx,
bool AllowImplicitThis =
false) {
337 Idx = IdxInt.getLimitedValue();
338 if (Idx < 1 || (!IV && Idx > NumParams)) {
339 S.
Diag(
getAttrLoc(Attr), diag::err_attribute_argument_out_of_bounds)
344 if (HasImplicitThisParam && !AllowImplicitThis) {
347 diag::err_attribute_invalid_implicit_this_argument)
362 unsigned ArgNum, StringRef &Str,
367 Diag(Loc->
Loc, diag::err_attribute_argument_type)
373 *ArgLocation = Loc->
Loc;
383 if (!Literal || !Literal->
isAscii()) {
395 template <
typename AttrType>
402 template <
typename AttrType>
405 handleSimpleAttribute<AttrType>(S, D, Attr);
410 template <
typename AttrType,
typename IncompatibleAttrType,
411 typename... IncompatibleAttrTypes>
414 if (checkAttrMutualExclusion<IncompatibleAttrType>(S, D, Attr.
getRange(),
449 const ValueDecl *vd = cast<ValueDecl>(D);
451 if (QT->isAnyPointerType())
458 if (RT->isIncompleteType())
465 S.
Diag(Attr.
getLoc(), diag::warn_thread_attribute_decl_not_pointer)
500 if (RD->
hasAttr<CapabilityAttr>())
507 const auto *Type = BS->getType()->getAs<RecordType>();
508 return Type->getDecl()->hasAttr<CapabilityAttr>();
524 return TN->
hasAttr<CapabilityAttr>();
543 if (
const auto *E = dyn_cast<CastExpr>(Ex))
545 else if (
const auto *E = dyn_cast<ParenExpr>(Ex))
547 else if (
const auto *E = dyn_cast<UnaryOperator>(Ex)) {
548 if (E->getOpcode() == UO_LNot || E->getOpcode() == UO_AddrOf ||
549 E->getOpcode() == UO_Deref)
552 }
else if (
const auto *E = dyn_cast<BinaryOperator>(Ex)) {
553 if (E->getOpcode() == BO_LAnd || E->getOpcode() == BO_LOr)
571 bool ParamIdxOk =
false) {
572 for (
unsigned Idx = Sidx; Idx < Attr.
getNumArgs(); ++Idx) {
577 Args.push_back(ArgExp);
581 if (
StringLiteral *StrLit = dyn_cast<StringLiteral>(ArgExp)) {
582 if (StrLit->getLength() == 0 ||
583 (StrLit->isAscii() && StrLit->getString() == StringRef(
"*"))) {
586 Args.push_back(ArgExp);
592 S.
Diag(Attr.
getLoc(), diag::warn_thread_attribute_ignored) <<
594 Args.push_back(ArgExp);
603 if (UOp->getOpcode() == UO_AddrOf)
604 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(UOp->getSubExpr()))
605 if (DRE->getDecl()->isCXXInstanceMember())
606 ArgTy = DRE->getDecl()->getType();
612 if(!RT && ParamIdxOk) {
617 llvm::APInt ArgValue = IL->getValue();
618 uint64_t ParamIdxFromOne = ArgValue.getZExtValue();
619 uint64_t ParamIdxFromZero = ParamIdxFromOne - 1;
620 if(!ArgValue.isStrictlyPositive() || ParamIdxFromOne > NumParams) {
621 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_out_of_range)
622 << Attr.
getName() << Idx + 1 << NumParams;
634 S.
Diag(Attr.
getLoc(), diag::warn_thread_attribute_argument_not_lockable)
637 Args.push_back(ArgExp);
661 unsigned Size = Args.size();
700 QualType QT = cast<ValueDecl>(D)->getType();
702 S.
Diag(Attr.
getLoc(), diag::warn_thread_attribute_decl_not_lockable)
721 Expr **StartArg = &Args[0];
724 StartArg, Args.size(),
734 Expr **StartArg = &Args[0];
737 StartArg, Args.size(),
757 unsigned Size = Args.size();
758 Expr **StartArg = Size == 0 ? nullptr : &Args[0];
770 unsigned Size = Args.size();
771 Expr **StartArg = Size == 0 ? nullptr : &Args[0];
784 template <
typename AttrInfo>
786 const AttrInfo &
Attr,
Expr *AttrArg,
787 unsigned FuncParamNo,
unsigned AttrArgNo,
788 bool AllowDependentType =
false) {
799 S.
Diag(SrcLoc, diag::err_attribute_integers_only)
813 unsigned FuncParamNo,
unsigned AttrArgNo,
814 bool AllowDependentType =
false) {
815 assert(Attr.
isArgExpr(AttrArgNo) &&
"Expected expression argument");
817 FuncParamNo, AttrArgNo, AllowDependentType);
825 const auto *FD = cast<FunctionDecl>(D);
826 if (!FD->getReturnType()->isPointerType()) {
827 S.
Diag(Attr.
getLoc(), diag::warn_attribute_return_pointers_only)
866 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
886 Args.data(), Args.size(),
906 unsigned Size = Args.size();
923 unsigned Size = Args.size();
926 Expr **StartArg = &Args[0];
935 Expr *&Cond, StringRef &Msg) {
941 Cond = Converted.
get();
948 Msg =
"<no message provided>";
954 S.
Diag(Attr.
getLoc(), diag::err_attr_cond_never_constant_expr)
957 S.
Diag(PDiag.first, PDiag.second);
964 S.
Diag(Attr.
getLoc(), diag::ext_clang_enable_if);
977 class ArgumentDependenceChecker
982 llvm::SmallPtrSet<const ParmVarDecl *, 16> Parms;
988 if (
const auto *MD = dyn_cast<CXXMethodDecl>(FD))
996 bool referencesArgs(
Expr *E) {
1004 "`this` doesn't refer to the enclosing class?");
1010 if (
const auto *PVD = dyn_cast<ParmVarDecl>(DRE->
getDecl()))
1011 if (Parms.count(PVD)) {
1021 S.
Diag(Attr.
getLoc(), diag::ext_clang_diagnose_if);
1028 StringRef DiagTypeStr;
1032 DiagnoseIfAttr::DiagnosticType DiagType;
1033 if (!DiagnoseIfAttr::ConvertStrToDiagnosticType(DiagTypeStr, DiagType)) {
1035 diag::err_diagnose_if_invalid_diagnostic_type);
1039 bool ArgDependent =
false;
1040 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
1041 ArgDependent = ArgumentDependenceChecker(FD).referencesArgs(Cond);
1043 Attr.
getRange(), S.
Context, Cond, Msg, DiagType, ArgDependent, cast<NamedDecl>(D),
1049 if (D->
hasAttr<PassObjectSizeAttr>()) {
1073 if (!cast<ParmVarDecl>(D)->getType()->isPointerType()) {
1089 if (!ConsumableAttr::ConvertStrToConsumedState(IL->
Ident->
getName(),
1091 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported)
1096 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type)
1112 if (!RD->hasAttr<ConsumableAttr>()) {
1113 S.
Diag(Attr.
getLoc(), diag::warn_attr_on_unconsumable_class) <<
1114 RD->getNameAsString();
1132 for (
unsigned ArgIndex = 0; ArgIndex < Attr.
getNumArgs(); ++ArgIndex) {
1135 StringRef StateString;
1146 if (!CallableWhenAttr::ConvertStrToConsumedState(StateString,
1148 S.
Diag(Loc, diag::warn_attribute_type_not_supported)
1149 << Attr.
getName() << StateString;
1153 States.push_back(CallableState);
1169 if (!ParamTypestateAttr::ConvertStrToConsumedState(StateString,
1171 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported)
1172 << Attr.
getName() << StateString;
1176 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type) <<
1204 if (!ReturnTypestateAttr::ConvertStrToConsumedState(IL->
Ident->
getName(),
1206 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported)
1211 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type) <<
1254 if (!SetTypestateAttr::ConvertStrToConsumedState(Param, NewState)) {
1255 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported)
1260 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type) <<
1279 if (!TestTypestateAttr::ConvertStrToConsumedState(Param, TestState)) {
1280 S.
Diag(Ident->
Loc, diag::warn_attribute_type_not_supported)
1285 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type) <<
1302 if (
TagDecl *TD = dyn_cast<TagDecl>(D))
1305 else if (
FieldDecl *FD = dyn_cast<FieldDecl>(D)) {
1306 bool BitfieldByteAligned = (!FD->getType()->isDependentType() &&
1307 !FD->getType()->isIncompleteType() &&
1312 if (BitfieldByteAligned)
1314 S.
Diag(Attr.
getLoc(), diag::warn_attribute_ignored_for_field_of_type)
1315 << Attr.
getName() << FD->getType();
1317 FD->addAttr(::
new (S.
Context) PackedAttr(
1321 if (BitfieldByteAligned)
1322 S.
Diag(Attr.
getLoc(), diag::warn_attribute_packed_for_bitfield);
1324 FD->addAttr(::
new (S.
Context) PackedAttr(
1336 if (
const ObjCIvarDecl *VD = dyn_cast<ObjCIvarDecl>(D)) {
1338 S.
Diag(Attr.
getLoc(), diag::warn_iboutlet_object_type)
1339 << Attr.
getName() << VD->getType() << 0;
1345 S.
Diag(Attr.
getLoc(), diag::warn_iboutlet_object_type)
1346 << Attr.
getName() << PD->getType() << 1;
1372 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
1388 S.
Diag(Attr.
getLoc(), diag::err_iboutletcollection_type) <<
"NSObject";
1404 QT->
isBuiltinType() ? diag::err_iboutletcollection_builtintype
1405 : diag::err_iboutletcollection_type) << QT;
1425 if (UT && UT->getDecl()->hasAttr<TransparentUnionAttr>()) {
1427 for (
const auto *I : UD->
fields()) {
1441 bool isReturnValue =
false) {
1444 S.
Diag(Attr.
getLoc(), diag::warn_attribute_return_pointers_only)
1445 << Attr.
getName() << AttrParmRange << TypeRange;
1447 S.
Diag(Attr.
getLoc(), diag::warn_attribute_pointers_only)
1448 << Attr.
getName() << AttrParmRange << TypeRange << 0;
1456 for (
unsigned I = 0; I < Attr.
getNumArgs(); ++I) {
1469 NonNullArgs.push_back(Idx);
1480 I != E && !AnyPointers; ++I) {
1487 S.
Diag(Attr.
getLoc(), diag::warn_attribute_nonnull_no_pointers);
1490 unsigned *Start = NonNullArgs.data();
1491 unsigned Size = NonNullArgs.size();
1492 llvm::array_pod_sort(Start, Start + Size);
1504 S.
Diag(Attr.
getLoc(), diag::warn_attribute_nonnull_parm_no_args)
1538 QualType T = cast<ParmVarDecl>(D)->getType();
1540 S.
Diag(Attr.
getLoc(), diag::warn_attribute_pointers_only)
1564 Expr *OE,
unsigned SpellingListIndex) {
1568 AssumeAlignedAttr TmpAttr(AttrRange, Context, E, OE, SpellingListIndex);
1571 if (!isValidPointerAttrType(ResultType,
true)) {
1572 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
1573 << &TmpAttr << AttrRange << SR;
1581 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1585 Diag(AttrLoc, diag::err_attribute_argument_type)
1591 if (!I.isPowerOf2()) {
1592 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
1602 Diag(AttrLoc, diag::err_attribute_argument_n_type)
1611 AssumeAlignedAttr(AttrRange, Context, E, OE, SpellingListIndex));
1615 unsigned SpellingListIndex) {
1618 AllocAlignAttr TmpAttr(AttrRange, Context, 0, SpellingListIndex);
1622 !isValidPointerAttrType(ResultType,
true)) {
1623 Diag(AttrLoc, diag::warn_attribute_return_pointers_refs_only)
1629 const auto *FuncDecl = cast<FunctionDecl>(D);
1638 << &TmpAttr << FuncDecl->getParamDecl(IndexVal)->getSourceRange();
1648 D->
addAttr(::
new (Context) AllocAlignAttr(
1649 AttrRange, Context, Val.getZExtValue(), SpellingListIndex));
1655 if (AttrName.size() > 4 && AttrName.startswith(
"__") &&
1656 AttrName.endswith(
"__")) {
1657 AttrName = AttrName.drop_front(2).drop_back(2);
1673 S.
Diag(AL.
getLoc(), diag::err_attribute_argument_n_type)
1679 OwnershipAttr::OwnershipKind K =
1685 case OwnershipAttr::Takes:
1686 case OwnershipAttr::Holds:
1688 S.
Diag(AL.
getLoc(), diag::err_attribute_too_few_arguments)
1693 case OwnershipAttr::Returns:
1695 S.
Diag(AL.
getLoc(), diag::err_attribute_too_many_arguments)
1704 StringRef ModuleName = Module->
getName();
1710 for (
unsigned i = 1; i < AL.
getNumArgs(); ++i) {
1720 case OwnershipAttr::Takes:
1721 case OwnershipAttr::Holds:
1725 case OwnershipAttr::Returns:
1740 if (I->getOwnKind() != K && I->args_end() !=
1741 std::find(I->args_begin(), I->args_end(), Idx)) {
1742 S.
Diag(AL.
getLoc(), diag::err_attributes_are_not_compatible)
1745 }
else if (K == OwnershipAttr::Returns &&
1746 I->getOwnKind() == OwnershipAttr::Returns) {
1750 if (std::find(I->args_begin(), I->args_end(), Idx) == I->args_end()) {
1751 S.
Diag(I->getLocation(), diag::err_ownership_returns_index_mismatch)
1752 << *(I->args_begin()) + 1;
1754 S.
Diag(AL.
getLoc(), diag::note_ownership_returns_index_mismatch)
1760 OwnershipArgs.push_back(Idx);
1763 unsigned* start = OwnershipArgs.data();
1764 unsigned size = OwnershipArgs.size();
1765 llvm::array_pod_sort(start, start + size);
1775 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
1793 if (!Ctx->isFileContext()) {
1794 S.
Diag(Attr.
getLoc(), diag::err_attribute_weakref_not_global_context)
1842 const auto *FD = cast<FunctionDecl>(D);
1843 if (FD->isThisDeclarationADefinition()) {
1844 S.
Diag(Attr.
getLoc(), diag::err_alias_is_definition) << FD << 1;
1858 S.
Diag(Attr.
getLoc(), diag::err_alias_not_supported_on_darwin);
1862 S.
Diag(Attr.
getLoc(), diag::err_alias_not_supported_on_nvptx);
1866 if (
const auto *FD = dyn_cast<FunctionDecl>(D)) {
1867 if (FD->isThisDeclarationADefinition()) {
1868 S.
Diag(Attr.
getLoc(), diag::err_alias_is_definition) << FD << 0;
1872 const auto *VD = cast<VarDecl>(D);
1873 if (VD->isThisDeclarationADefinition() && VD->isExternallyVisible()) {
1874 S.
Diag(Attr.
getLoc(), diag::err_alias_is_definition) << VD << 0;
1886 if (checkAttrMutualExclusion<HotAttr>(S, D, Attr.
getRange(), Attr.
getName()))
1894 if (checkAttrMutualExclusion<ColdAttr>(S, D, Attr.
getRange(), Attr.
getName()))
1910 if (Model !=
"global-dynamic" && Model !=
"local-dynamic" 1911 && Model !=
"initial-exec" && Model !=
"local-exec") {
1912 S.
Diag(LiteralLoc, diag::err_attr_tlsmodel_arg);
1929 S.
Diag(Attr.
getLoc(), diag::warn_attribute_return_pointers_only)
1935 S.
Diag(Attr.
getLoc(), diag::err_attribute_not_supported_in_lang)
1946 if (checkAttrMutualExclusion<DisableTailCallsAttr>(S, D, Attr.
getRange(),
1952 const auto &Arch = Triple.getArch();
1953 if (Arch != llvm::Triple::x86 &&
1954 (Arch != llvm::Triple::arm && Arch != llvm::Triple::thumb)) {
1955 S.
Diag(Attr.
getLoc(), diag::err_attribute_not_supported_on_arch)
1956 << Attr.
getName() << Triple.getArchName();
1971 if (!isa<ObjCMethodDecl>(D)) {
1972 S.
Diag(Attrs.
getLoc(), diag::warn_attribute_wrong_decl_type)
2026 : diag::warn_attribute_wrong_decl_type)
2062 if (VecReturnAttr *A = D->
getAttr<VecReturnAttr>()) {
2063 S.
Diag(Attr.
getLoc(), diag::err_repeat_attribute) << A;
2070 if (!isa<CXXRecordDecl>(record)) {
2071 S.
Diag(Attr.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
2075 if (!cast<CXXRecordDecl>(record)->isPOD()) {
2076 S.
Diag(Attr.
getLoc(), diag::err_attribute_vecreturn_only_pod_record);
2080 for (
const auto *I : record->
fields()) {
2081 if ((count == 1) || !I->getType()->isVectorType()) {
2082 S.
Diag(Attr.
getLoc(), diag::err_attribute_vecreturn_only_vector_member);
2095 if (isa<ParmVarDecl>(D)) {
2100 diag::err_carries_dependency_param_not_function_decl);
2112 if (checkAttrMutualExclusion<AlwaysInlineAttr>(S, D, Attr.
getRange(),
2122 if (checkAttrMutualExclusion<NakedAttr>(S, D, Attr.
getRange(),
2131 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2132 if (VD->hasLocalStorage()) {
2137 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
2150 if (IsCXX17Attr && isa<VarDecl>(D)) {
2153 if (cast<VarDecl>(D)->isStaticDataMember()) {
2154 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
2170 uint32_t priority = ConstructorAttr::DefaultPriority;
2181 uint32_t priority = DestructorAttr::DefaultPriority;
2191 template <
typename AttrTy>
2205 if (!cast<ObjCProtocolDecl>(D)->isThisDeclarationADefinition()) {
2206 S.
Diag(Attr.
getLoc(), diag::err_objc_attr_protocol_requires_definition)
2221 StringRef PlatformName
2222 = AvailabilityAttr::getPrettyPlatformName(Platform->
getName());
2223 if (PlatformName.empty())
2224 PlatformName = Platform->
getName();
2228 if (!Introduced.
empty() && !Deprecated.
empty() &&
2229 !(Introduced <= Deprecated)) {
2230 S.
Diag(Range.
getBegin(), diag::warn_availability_version_ordering)
2236 if (!Introduced.
empty() && !Obsoleted.
empty() &&
2237 !(Introduced <= Obsoleted)) {
2238 S.
Diag(Range.
getBegin(), diag::warn_availability_version_ordering)
2244 if (!Deprecated.
empty() && !Obsoleted.
empty() &&
2245 !(Deprecated <= Obsoleted)) {
2246 S.
Diag(Range.
getBegin(), diag::warn_availability_version_ordering)
2260 bool BeforeIsOkay) {
2267 if (BeforeIsOkay && X < Y)
2284 unsigned AttrSpellingListIndex) {
2288 bool FoundAny =
false;
2289 bool OverrideOrImpl =
false;
2292 case AMK_Redeclaration:
2293 OverrideOrImpl =
false;
2297 case AMK_ProtocolImplementation:
2298 OverrideOrImpl =
true;
2304 for (
unsigned i = 0, e = Attrs.size(); i != e;) {
2305 const AvailabilityAttr *OldAA = dyn_cast<AvailabilityAttr>(Attrs[i]);
2312 if (OldPlatform != Platform) {
2320 if (!OldAA->isImplicit() && Implicit) {
2327 if (!Implicit && OldAA->isImplicit()) {
2328 Attrs.erase(Attrs.begin() + i);
2337 bool OldIsUnavailable = OldAA->getUnavailable();
2339 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl) ||
2340 !
versionsMatch(Deprecated, OldDeprecated, OverrideOrImpl) ||
2342 !(OldIsUnavailable == IsUnavailable ||
2343 (OverrideOrImpl && !OldIsUnavailable && IsUnavailable))) {
2344 if (OverrideOrImpl) {
2348 if (!
versionsMatch(OldIntroduced, Introduced, OverrideOrImpl)) {
2350 FirstVersion = OldIntroduced;
2351 SecondVersion = Introduced;
2352 }
else if (!
versionsMatch(Deprecated, OldDeprecated, OverrideOrImpl)) {
2354 FirstVersion = Deprecated;
2355 SecondVersion = OldDeprecated;
2356 }
else if (!
versionsMatch(Obsoleted, OldObsoleted, OverrideOrImpl)) {
2358 FirstVersion = Obsoleted;
2359 SecondVersion = OldObsoleted;
2363 Diag(OldAA->getLocation(),
2364 diag::warn_mismatched_availability_override_unavail)
2365 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2366 << (AMK == AMK_Override);
2368 Diag(OldAA->getLocation(),
2369 diag::warn_mismatched_availability_override)
2371 << AvailabilityAttr::getPrettyPlatformName(Platform->
getName())
2373 << (AMK == AMK_Override);
2375 if (AMK == AMK_Override)
2380 Diag(OldAA->getLocation(), diag::warn_mismatched_availability);
2384 Attrs.erase(Attrs.begin() + i);
2393 if (MergedIntroduced2.
empty())
2394 MergedIntroduced2 = OldIntroduced;
2395 if (MergedDeprecated2.
empty())
2396 MergedDeprecated2 = OldDeprecated;
2397 if (MergedObsoleted2.
empty())
2398 MergedObsoleted2 = OldObsoleted;
2401 MergedIntroduced2, MergedDeprecated2,
2402 MergedObsoleted2)) {
2403 Attrs.erase(Attrs.begin() + i);
2408 MergedIntroduced = MergedIntroduced2;
2409 MergedDeprecated = MergedDeprecated2;
2410 MergedObsoleted = MergedObsoleted2;
2416 MergedIntroduced == Introduced &&
2417 MergedDeprecated == Deprecated &&
2418 MergedObsoleted == Obsoleted)
2424 MergedDeprecated, MergedObsoleted) &&
2426 auto *Avail = ::new (Context) AvailabilityAttr(Range, Context, Platform,
2427 Introduced, Deprecated,
2428 Obsoleted, IsUnavailable, Message,
2429 IsStrict, Replacement,
2430 AttrSpellingListIndex);
2431 Avail->setImplicit(Implicit);
2445 if (AvailabilityAttr::getPrettyPlatformName(II->
getName()).empty())
2446 S.
Diag(Platform->
Loc, diag::warn_availability_unknown_platform)
2461 Str = SE->getString();
2465 Replacement = SE->getString();
2485 else if (II->
getName() ==
"ios_app_extension")
2490 if (Version.empty())
2493 auto NewMajor = Major >= 9 ? Major - 7 : 0;
2494 if (NewMajor >= 2) {
2495 if (Version.getMinor().hasValue()) {
2496 if (Version.getSubminor().hasValue())
2497 return VersionTuple(NewMajor, Version.getMinor().getValue(),
2498 Version.getSubminor().getValue());
2500 return VersionTuple(NewMajor, Version.getMinor().getValue());
2507 auto NewIntroduced = adjustWatchOSVersion(Introduced.
Version);
2508 auto NewDeprecated = adjustWatchOSVersion(Deprecated.
Version);
2509 auto NewObsoleted = adjustWatchOSVersion(Obsoleted.
Version);
2532 else if (II->
getName() ==
"ios_app_extension")
2559 "Invalid number of arguments in an external_source_symbol attribute");
2562 if (
const auto *SE = dyn_cast_or_null<StringLiteral>(Attr.
getArgAsExpr(0)))
2563 Language = SE->getString();
2564 StringRef DefinedIn;
2565 if (
const auto *SE = dyn_cast_or_null<StringLiteral>(Attr.
getArgAsExpr(1)))
2566 DefinedIn = SE->getString();
2567 bool IsGeneratedDeclaration = Attr.
getArgAsIdent(2) !=
nullptr;
2570 Attr.
getRange(), S.
Context, Language, DefinedIn, IsGeneratedDeclaration,
2576 typename T::VisibilityType value,
2577 unsigned attrSpellingListIndex) {
2580 typename T::VisibilityType existingValue = existingAttr->
getVisibility();
2581 if (existingValue == value)
2583 S.
Diag(existingAttr->getLocation(), diag::err_mismatched_visibility);
2584 S.
Diag(range.
getBegin(), diag::note_previous_attribute);
2587 return ::new (S.
Context)
T(range, S.
Context, value, attrSpellingListIndex);
2591 VisibilityAttr::VisibilityType Vis,
2592 unsigned AttrSpellingListIndex) {
2593 return ::mergeVisibilityAttr<VisibilityAttr>(*
this, D, Range, Vis,
2594 AttrSpellingListIndex);
2598 TypeVisibilityAttr::VisibilityType Vis,
2599 unsigned AttrSpellingListIndex) {
2600 return ::mergeVisibilityAttr<TypeVisibilityAttr>(*
this, D, Range, Vis,
2601 AttrSpellingListIndex);
2605 bool isTypeVisibility) {
2607 if (isa<TypedefNameDecl>(D)) {
2614 if (isTypeVisibility &&
2615 !(isa<TagDecl>(D) ||
2616 isa<ObjCInterfaceDecl>(D) ||
2617 isa<NamespaceDecl>(D))) {
2629 VisibilityAttr::VisibilityType
type;
2630 if (!VisibilityAttr::ConvertStrToVisibilityType(TypeStr, type)) {
2631 S.
Diag(LiteralLoc, diag::warn_attribute_type_not_supported)
2638 if (type == VisibilityAttr::Protected &&
2640 S.
Diag(Attr.
getLoc(), diag::warn_attribute_protected_visibility);
2646 if (isTypeVisibility) {
2648 (TypeVisibilityAttr::VisibilityType) type,
2661 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
2667 ObjCMethodFamilyAttr::FamilyKind F;
2668 if (!ObjCMethodFamilyAttr::ConvertStrToFamilyKind(IL->
Ident->
getName(), F)) {
2669 S.
Diag(IL->
Loc, diag::warn_attribute_type_not_supported) << Attr.
getName()
2691 S.
Diag(TD->getLocation(), diag::err_nsobject_attribute);
2698 S.
Diag(PD->getLocation(), diag::err_nsobject_attribute);
2720 S.
Diag(TD->getLocation(), diag::warn_ptr_independentclass_attribute);
2734 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
2740 BlocksAttr::BlockType
type;
2741 if (!BlocksAttr::ConvertStrToBlockType(II->
getName(),
type)) {
2742 S.
Diag(Attr.
getLoc(), diag::warn_attribute_type_not_supported)
2753 unsigned sentinel = (unsigned)SentinelAttr::DefaultSentinel;
2756 llvm::APSInt Idx(32);
2759 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
2765 if (Idx.isSigned() && Idx.isNegative()) {
2766 S.
Diag(Attr.
getLoc(), diag::err_attribute_sentinel_less_than_zero)
2771 sentinel = Idx.getZExtValue();
2774 unsigned nullPos = (unsigned)SentinelAttr::DefaultNullPos;
2777 llvm::APSInt Idx(32);
2780 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
2785 nullPos = Idx.getZExtValue();
2787 if ((Idx.isSigned() && Idx.isNegative()) || nullPos > 1) {
2790 S.
Diag(Attr.
getLoc(), diag::err_attribute_sentinel_not_zero_or_one)
2798 if (isa<FunctionNoProtoType>(FT)) {
2799 S.
Diag(Attr.
getLoc(), diag::warn_attribute_sentinel_named_arguments);
2803 if (!cast<FunctionProtoType>(FT)->isVariadic()) {
2804 S.
Diag(Attr.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
2808 if (!MD->isVariadic()) {
2809 S.
Diag(Attr.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
2812 }
else if (
BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
2813 if (!BD->isVariadic()) {
2814 S.
Diag(Attr.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << 1;
2817 }
else if (
const VarDecl *V = dyn_cast<VarDecl>(D)) {
2823 if (!cast<FunctionProtoType>(FT)->isVariadic()) {
2825 S.
Diag(Attr.
getLoc(), diag::warn_attribute_sentinel_not_variadic) << m;
2829 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
2834 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
2846 S.
Diag(Attr.
getLoc(), diag::warn_attribute_void_function_method)
2851 if (MD->getReturnType()->isVoidType()) {
2852 S.
Diag(Attr.
getLoc(), diag::warn_attribute_void_function_method)
2873 S.
Diag(Attr.
getLoc(), diag::warn_attribute_invalid_on_definition)
2875 else if (isa<ObjCPropertyDecl>(D) || isa<ObjCMethodDecl>(D) ||
2877 (isa<ObjCInterfaceDecl>(D) || isa<EnumDecl>(D)))) {
2880 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
2892 template <
typename WorkGroupAttr>
2896 for (
unsigned i = 0; i < 3; ++i) {
2900 if (WGSize[i] == 0) {
2901 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_is_zero)
2907 WorkGroupAttr *Existing = D->
getAttr<WorkGroupAttr>();
2908 if (Existing && !(Existing->getXDim() == WGSize[0] &&
2909 Existing->getYDim() == WGSize[1] &&
2910 Existing->getZDim() == WGSize[2]))
2914 WGSize[0], WGSize[1], WGSize[2],
2925 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_is_zero)
2930 OpenCLIntelReqdSubGroupSizeAttr *Existing =
2931 D->
getAttr<OpenCLIntelReqdSubGroupSizeAttr>();
2932 if (Existing && Existing->getSubGroupSize() != SGSize)
2942 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
2949 assert(ParmTSI &&
"no type source info for attribute argument");
2954 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_vec_type_hint)
2959 if (VecTypeHintAttr *A = D->
getAttr<VecTypeHintAttr>()) {
2973 unsigned AttrSpellingListIndex) {
2974 if (SectionAttr *ExistingAttr = D->
getAttr<SectionAttr>()) {
2975 if (ExistingAttr->getName() == Name)
2977 Diag(ExistingAttr->getLocation(), diag::warn_mismatched_section);
2981 return ::new (Context) SectionAttr(Range, Context, Name,
2982 AttrSpellingListIndex);
2987 if (!Error.empty()) {
2988 Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target) << Error;
3007 if (!Error.empty()) {
3008 S.
Diag(LiteralLoc, diag::err_attribute_section_invalid_for_target)
3023 enum SecondParam { None, Architecture };
3024 for (
auto Str : {
"tune=",
"fpmath="})
3025 if (AttrStr.find(Str) != StringRef::npos)
3026 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3029 TargetAttr::ParsedTargetAttr ParsedAttrs = TargetAttr::parse(AttrStr);
3031 if (!ParsedAttrs.Architecture.empty() &&
3033 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3034 <<
Unsupported << Architecture << ParsedAttrs.Architecture;
3036 if (ParsedAttrs.DuplicateArchitecture)
3037 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3038 << Duplicate << None <<
"arch=";
3040 for (
const auto &Feature : ParsedAttrs.Features) {
3041 auto CurFeature = StringRef(Feature).drop_front();
3043 return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
3057 TargetAttr *NewAttr =
3070 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
3071 if (DRE->hasQualifier())
3072 S.
Diag(Loc, diag::warn_cleanup_ext);
3074 NI = DRE->getNameInfo();
3076 S.
Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 1
3081 if (ULE->hasExplicitTemplateArgs())
3082 S.
Diag(Loc, diag::warn_cleanup_ext);
3084 NI = ULE->getNameInfo();
3086 S.
Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 2
3093 S.
Diag(Loc, diag::err_attribute_cleanup_arg_not_function) << 0;
3098 S.
Diag(Loc, diag::err_attribute_cleanup_func_must_take_one_arg)
3109 S.
Diag(Loc, diag::err_attribute_cleanup_func_arg_incompatible_type)
3110 << NI.
getName() << ParamTy << Ty;
3122 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
3129 if (!EnumExtensibilityAttr::ConvertStrToKind(II->
getName(),
3130 ExtensibilityKind)) {
3131 S.
Diag(Attr.
getLoc(), diag::warn_attribute_type_not_supported)
3153 if (NotNSStringTy &&
3157 S.
Diag(Attr.
getLoc(), diag::err_format_attribute_not)
3167 S.
Diag(Attr.
getLoc(), diag::err_format_attribute_result_not)
3168 << (NotNSStringTy ?
"string type" :
"NSString")
3196 return llvm::StringSwitch<FormatAttrKind>(Format)
3210 .Cases(
"gcc_diag",
"gcc_cdiag",
"gcc_cxxdiag",
"gcc_tdiag",
IgnoredFormat)
3224 S.
Diag(Attr.
getLoc(), diag::err_init_priority_object_attr);
3228 QualType T = cast<VarDecl>(D)->getType();
3232 S.
Diag(Attr.
getLoc(), diag::err_init_priority_object_attr);
3238 uint32_t prioritynum;
3244 if (prioritynum < 101 || prioritynum > 65535) {
3245 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_outof_range)
3258 unsigned AttrSpellingListIndex) {
3261 if (F->getType() == Format &&
3262 F->getFormatIdx() == FormatIdx &&
3263 F->getFirstArg() == FirstArg) {
3266 if (F->getLocation().isInvalid())
3272 return ::new (Context) FormatAttr(Range, Context, Format, FormatIdx,
3273 FirstArg, AttrSpellingListIndex);
3280 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
3291 StringRef Format = II->
getName();
3305 S.
Diag(Attr.
getLoc(), diag::warn_attribute_type_not_supported)
3316 if (Idx < 1 || Idx > NumArgs) {
3317 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_out_of_bounds)
3323 unsigned ArgIdx = Idx - 1;
3325 if (HasImplicitThisParam) {
3328 diag::err_format_attribute_implicit_this_format_string)
3340 S.
Diag(Attr.
getLoc(), diag::err_format_attribute_not)
3349 S.
Diag(Attr.
getLoc(), diag::err_format_attribute_not)
3356 S.
Diag(Attr.
getLoc(), diag::err_format_attribute_not)
3369 if (FirstArg != 0) {
3373 S.
Diag(D->
getLocation(), diag::err_format_attribute_requires_variadic);
3381 if (FirstArg != 0) {
3382 S.
Diag(Attr.
getLoc(), diag::err_format_strftime_third_parameter)
3387 }
else if (FirstArg != 0 && FirstArg != NumArgs) {
3388 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_out_of_bounds)
3411 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
3419 diag::warn_transparent_union_attribute_not_definition);
3425 if (Field == FieldEnd) {
3426 S.
Diag(Attr.
getLoc(), diag::warn_transparent_union_attribute_zero_fields);
3434 diag::warn_transparent_union_attribute_floating)
3443 for (; Field != FieldEnd; ++Field) {
3444 QualType FieldType = Field->getType();
3458 S.
Diag(Field->getLocation(),
3459 diag::warn_transparent_union_attribute_field_size_align)
3460 << isSize << Field->getDeclName() << FieldBits;
3461 unsigned FirstBits = isSize? FirstSize : FirstAlign;
3463 diag::note_transparent_union_first_field_size_align)
3464 << isSize << FirstBits;
3483 if (I->getAnnotation() == Str)
3499 unsigned SpellingListIndex) {
3500 AlignValueAttr TmpAttr(AttrRange, Context, E, SpellingListIndex);
3505 T = TD->getUnderlyingType();
3506 else if (
ValueDecl *VD = dyn_cast<ValueDecl>(D))
3509 llvm_unreachable(
"Unknown decl type for align_value");
3513 Diag(AttrLoc, diag::warn_attribute_pointer_or_reference_only)
3519 llvm::APSInt Alignment;
3521 = VerifyIntegerConstantExpression(E, &Alignment,
3522 diag::err_align_value_attribute_argument_not_int,
3527 if (!Alignment.isPowerOf2()) {
3528 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
3534 AlignValueAttr(AttrRange, Context, ICE.
get(),
3535 SpellingListIndex));
3540 D->
addAttr(::
new (Context) AlignValueAttr(TmpAttr));
3546 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_number_arguments)
3560 diag::err_pack_expansion_without_parameter_packs);
3568 if (
const auto *TND = dyn_cast<TypedefNameDecl>(D)) {
3569 if (!TND->getUnderlyingType()->isDependentType()) {
3570 S.
Diag(Attr.
getLoc(), diag::err_alignment_dependent_typedef_name)
3582 unsigned SpellingListIndex,
bool IsPackExpansion) {
3583 AlignedAttr TmpAttr(AttrRange, Context,
true, E, SpellingListIndex);
3587 if (TmpAttr.isAlignas()) {
3600 if (isa<ParmVarDecl>(D)) {
3602 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(D)) {
3605 if (VD->isExceptionVariable())
3607 }
else if (
FieldDecl *FD = dyn_cast<FieldDecl>(D)) {
3608 if (FD->isBitField())
3610 }
else if (!isa<TagDecl>(D)) {
3611 Diag(AttrLoc, diag::err_attribute_wrong_decl_type) << &TmpAttr
3616 if (DiagKind != -1) {
3617 Diag(AttrLoc, diag::err_alignas_attribute_wrong_decl_type)
3618 << &TmpAttr << DiagKind;
3625 AlignedAttr *AA = ::new (Context) AlignedAttr(TmpAttr);
3626 AA->setPackExpansion(IsPackExpansion);
3632 llvm::APSInt Alignment;
3634 = VerifyIntegerConstantExpression(E, &Alignment,
3635 diag::err_aligned_attribute_argument_not_int,
3640 uint64_t AlignVal = Alignment.getZExtValue();
3647 if (!(TmpAttr.isAlignas() && !Alignment)) {
3648 if (!llvm::isPowerOf2_64(AlignVal)) {
3649 Diag(AttrLoc, diag::err_alignment_not_power_of_two)
3656 unsigned MaxValidAlignment =
3659 if (AlignVal > MaxValidAlignment) {
3660 Diag(AttrLoc, diag::err_attribute_aligned_too_great) << MaxValidAlignment
3666 unsigned MaxTLSAlign =
3669 auto *VD = dyn_cast<
VarDecl>(D);
3670 if (MaxTLSAlign && AlignVal > MaxTLSAlign && VD &&
3672 Diag(VD->getLocation(), diag::err_tls_var_aligned_over_maximum)
3673 << (
unsigned)AlignVal << VD << MaxTLSAlign;
3678 AlignedAttr *AA = ::new (Context) AlignedAttr(AttrRange, Context,
true,
3679 ICE.
get(), SpellingListIndex);
3680 AA->setPackExpansion(IsPackExpansion);
3685 unsigned SpellingListIndex,
bool IsPackExpansion) {
3688 AlignedAttr *AA = ::new (Context) AlignedAttr(AttrRange, Context,
false, TS,
3690 AA->setPackExpansion(IsPackExpansion);
3695 assert(D->
hasAttrs() &&
"no attributes on decl");
3698 if (
ValueDecl *VD = dyn_cast<ValueDecl>(D)) {
3699 UnderlyingTy = DiagTy = VD->getType();
3701 UnderlyingTy = DiagTy = Context.
getTagDeclType(cast<TagDecl>(D));
3702 if (
EnumDecl *ED = dyn_cast<EnumDecl>(D))
3703 UnderlyingTy = ED->getIntegerType();
3705 if (DiagTy->isDependentType() || DiagTy->isIncompleteType())
3712 AlignedAttr *AlignasAttr =
nullptr;
3715 if (I->isAlignmentDependent())
3719 Align =
std::max(Align, I->getAlignment(Context));
3722 if (AlignasAttr && Align) {
3725 if (NaturalAlign > RequestedAlign)
3726 Diag(AlignasAttr->getLocation(), diag::err_alignas_underaligned)
3727 << DiagTy << (
unsigned)NaturalAlign.
getQuantity();
3733 MSInheritanceAttr::Spelling SemanticSpelling) {
3742 if (SemanticSpelling == MSInheritanceAttr::Keyword_unspecified_inheritance)
3753 Diag(Range.
getBegin(), diag::err_mismatched_ms_inheritance)
3763 bool &IntegerMode,
bool &ComplexMode) {
3765 ComplexMode =
false;
3766 switch (Str.size()) {
3788 if (Str[1] ==
'F') {
3789 IntegerMode =
false;
3790 }
else if (Str[1] ==
'C') {
3791 IntegerMode =
false;
3793 }
else if (Str[1] !=
'I') {
3802 else if (Str ==
"byte")
3806 if (Str ==
"pointer")
3810 if (Str ==
"unwind_word")
3837 unsigned SpellingListIndex,
bool InInstantiation) {
3838 StringRef Str = Name->
getName();
3842 unsigned DestWidth = 0;
3843 bool IntegerMode =
true;
3844 bool ComplexMode =
false;
3845 llvm::APInt VectorSize(64, 0);
3846 if (Str.size() >= 4 && Str[0] ==
'V') {
3848 size_t StrSize = Str.size();
3849 size_t VectorStringLength = 0;
3850 while ((VectorStringLength + 1) < StrSize &&
3851 isdigit(Str[VectorStringLength + 1]))
3852 ++VectorStringLength;
3853 if (VectorStringLength &&
3854 !Str.substr(1, VectorStringLength).getAsInteger(10, VectorSize) &&
3855 VectorSize.isPowerOf2()) {
3857 IntegerMode, ComplexMode);
3859 if (!InInstantiation)
3860 Diag(AttrLoc, diag::warn_vector_mode_deprecated);
3874 Diag(AttrLoc, diag::err_machine_mode) << 0 << Name;
3880 OldTy = TD->getUnderlyingType();
3881 else if (
EnumDecl *ED = dyn_cast<EnumDecl>(D)) {
3884 OldTy = ED->getIntegerType();
3886 OldTy = Context.
IntTy;
3888 OldTy = cast<ValueDecl>(D)->getType();
3892 ModeAttr(AttrRange, Context, Name, SpellingListIndex));
3900 OldElemTy = VT->getElementType();
3906 VectorSize.getBoolValue()) {
3907 Diag(AttrLoc, diag::err_enum_mode_vector_type) << Name << AttrRange;
3910 bool IntegralOrAnyEnumType =
3914 !IntegralOrAnyEnumType)
3915 Diag(AttrLoc, diag::err_mode_not_primitive);
3916 else if (IntegerMode) {
3917 if (!IntegralOrAnyEnumType)
3918 Diag(AttrLoc, diag::err_mode_wrong_type);
3919 }
else if (ComplexMode) {
3921 Diag(AttrLoc, diag::err_mode_wrong_type);
3924 Diag(AttrLoc, diag::err_mode_wrong_type);
3935 if (NewElemTy.
isNull()) {
3936 Diag(AttrLoc, diag::err_machine_mode) << 1 << Name;
3945 if (VectorSize.getBoolValue()) {
3946 NewTy = Context.
getVectorType(NewTy, VectorSize.getZExtValue(),
3951 Diag(AttrLoc, diag::err_complex_mode_vector_type);
3954 unsigned NumElements = Context.
getTypeSize(OldElemTy) *
3955 OldVT->getNumElements() /
3958 Context.
getVectorType(NewElemTy, NumElements, OldVT->getVectorKind());
3962 Diag(AttrLoc, diag::err_mode_wrong_type);
3968 TD->setModedTypeSourceInfo(TD->getTypeSourceInfo(), NewTy);
3969 else if (
EnumDecl *ED = dyn_cast<EnumDecl>(D))
3970 ED->setIntegerType(NewTy);
3972 cast<ValueDecl>(D)->setType(NewTy);
3975 ModeAttr(AttrRange, Context, Name, SpellingListIndex));
3986 unsigned AttrSpellingListIndex) {
3987 if (OptimizeNoneAttr *Optnone = D->
getAttr<OptimizeNoneAttr>()) {
3988 Diag(Range.
getBegin(), diag::warn_attribute_ignored) << Ident;
3989 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
3993 if (D->
hasAttr<AlwaysInlineAttr>())
3996 return ::new (Context) AlwaysInlineAttr(Range, Context,
3997 AttrSpellingListIndex);
4002 unsigned AttrSpellingListIndex) {
4003 if (checkAttrMutualExclusion<InternalLinkageAttr>(*
this, D, Range, Ident))
4006 return ::new (Context) CommonAttr(Range, Context, AttrSpellingListIndex);
4009 InternalLinkageAttr *
4012 unsigned AttrSpellingListIndex) {
4013 if (
auto VD = dyn_cast<VarDecl>(D)) {
4016 if (VD->getKind() != Decl::Var) {
4017 Diag(Range.
getBegin(), diag::warn_attribute_wrong_decl_type)
4023 if (VD->hasLocalStorage()) {
4024 Diag(VD->getLocation(), diag::warn_internal_linkage_local_storage);
4029 if (checkAttrMutualExclusion<CommonAttr>(*
this, D, Range, Ident))
4032 return ::new (Context)
4033 InternalLinkageAttr(Range, Context, AttrSpellingListIndex);
4037 unsigned AttrSpellingListIndex) {
4038 if (OptimizeNoneAttr *Optnone = D->
getAttr<OptimizeNoneAttr>()) {
4039 Diag(Range.
getBegin(), diag::warn_attribute_ignored) <<
"'minsize'";
4040 Diag(Optnone->getLocation(), diag::note_conflicting_attribute);
4044 if (D->
hasAttr<MinSizeAttr>())
4047 return ::new (Context) MinSizeAttr(Range, Context, AttrSpellingListIndex);
4051 unsigned AttrSpellingListIndex) {
4052 if (AlwaysInlineAttr *Inline = D->
getAttr<AlwaysInlineAttr>()) {
4053 Diag(Inline->getLocation(), diag::warn_attribute_ignored) << Inline;
4054 Diag(Range.
getBegin(), diag::note_conflicting_attribute);
4057 if (MinSizeAttr *MinSize = D->
getAttr<MinSizeAttr>()) {
4058 Diag(MinSize->getLocation(), diag::warn_attribute_ignored) << MinSize;
4059 Diag(Range.
getBegin(), diag::note_conflicting_attribute);
4063 if (D->
hasAttr<OptimizeNoneAttr>())
4066 return ::new (Context) OptimizeNoneAttr(Range, Context,
4067 AttrSpellingListIndex);
4072 if (checkAttrMutualExclusion<NotTailCalledAttr>(S, D, Attr.
getRange(),
4096 if (checkAttrMutualExclusion<CUDASharedAttr>(S, D, Attr.
getRange(),
4099 auto *VD = cast<VarDecl>(D);
4100 if (!VD->hasGlobalStorage()) {
4101 S.
Diag(Attr.
getLoc(), diag::err_cuda_nonglobal_constant);
4109 if (checkAttrMutualExclusion<CUDAConstantAttr>(S, D, Attr.
getRange(),
4112 auto *VD = cast<VarDecl>(D);
4115 if (VD->hasExternalStorage() && !isa<IncompleteArrayType>(VD->getType())) {
4116 S.
Diag(Attr.
getLoc(), diag::err_cuda_extern_shared) << VD;
4119 if (S.
getLangOpts().CUDA && VD->hasLocalStorage() &&
4128 if (checkAttrMutualExclusion<CUDADeviceAttr>(S, D, Attr.
getRange(),
4130 checkAttrMutualExclusion<CUDAHostAttr>(S, D, Attr.
getRange(),
4143 if (
const auto *Method = dyn_cast<CXXMethodDecl>(FD)) {
4144 if (Method->isInstance()) {
4145 S.
Diag(Method->getLocStart(), diag::err_kern_is_nonstatic_method)
4149 S.
Diag(Method->getLocStart(), diag::warn_kern_is_method) << Method;
4163 S.
Diag(Attr.
getLoc(), diag::warn_gnu_inline_attribute_requires_inline);
4181 if (!isa<ObjCMethodDecl>(D)) {
4182 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
4188 case AttributeList::AT_FastCall:
4193 case AttributeList::AT_StdCall:
4198 case AttributeList::AT_ThisCall:
4203 case AttributeList::AT_CDecl:
4208 case AttributeList::AT_Pascal:
4213 case AttributeList::AT_SwiftCall:
4218 case AttributeList::AT_VectorCall:
4223 case AttributeList::AT_MSABI:
4228 case AttributeList::AT_SysVABI:
4233 case AttributeList::AT_RegCall:
4237 case AttributeList::AT_Pcs: {
4238 PcsAttr::PCSType PCS;
4241 PCS = PcsAttr::AAPCS;
4244 PCS = PcsAttr::AAPCS_VFP;
4247 llvm_unreachable(
"unexpected calling convention in pcs attribute");
4255 case AttributeList::AT_IntelOclBicc:
4260 case AttributeList::AT_PreserveMost:
4264 case AttributeList::AT_PreserveAll:
4269 llvm_unreachable(
"unexpected attribute kind");
4277 std::vector<StringRef> DiagnosticIdentifiers;
4278 for (
unsigned I = 0, E = Attr.
getNumArgs(); I != E; ++I) {
4286 DiagnosticIdentifiers.push_back(RuleName);
4303 unsigned ReqArgs = Attrs.
getKind() == AttributeList::AT_Pcs ? 1 : 0;
4311 case AttributeList::AT_CDecl: CC =
CC_C;
break;
4315 case AttributeList::AT_Pascal: CC =
CC_X86Pascal;
break;
4316 case AttributeList::AT_SwiftCall: CC =
CC_Swift;
break;
4319 case AttributeList::AT_MSABI:
4323 case AttributeList::AT_SysVABI:
4327 case AttributeList::AT_Pcs: {
4329 if (!checkStringLiteralArgumentAttr(Attrs, 0, StrRef)) {
4333 if (StrRef ==
"aapcs") {
4336 }
else if (StrRef ==
"aapcs-vfp") {
4348 default: llvm_unreachable(
"unexpected attribute kind");
4359 bool IsCXXMethod =
false, IsVariadic =
false;
4411 unsigned spellingIndex) {
4416 if (existingAttr->getABI() != abi) {
4417 Diag(range.
getBegin(), diag::err_attributes_are_not_compatible)
4419 Diag(existingAttr->getLocation(), diag::note_conflicting_attribute);
4426 llvm_unreachable(
"explicit attribute for ordinary parameter ABI?");
4430 Diag(range.
getBegin(), diag::err_swift_abi_parameter_wrong_type)
4435 SwiftContextAttr(range, Context, spellingIndex));
4440 Diag(range.
getBegin(), diag::err_swift_abi_parameter_wrong_type)
4445 SwiftErrorResultAttr(range, Context, spellingIndex));
4450 Diag(range.
getBegin(), diag::err_swift_abi_parameter_wrong_type)
4455 SwiftIndirectResultAttr(range, Context, spellingIndex));
4458 llvm_unreachable(
"bad parameter ABI attribute");
4480 Diag(Attr.
getLoc(), diag::err_attribute_regparm_wrong_platform)
4488 Diag(Attr.
getLoc(), diag::err_attribute_regparm_invalid_number)
4502 const CUDALaunchBoundsAttr &
Attr,
4503 const unsigned Idx) {
4519 if (!I.isIntN(32)) {
4520 S.
Diag(E->
getExprLoc(), diag::err_ice_too_large) << I.toString(10,
false)
4525 S.
Diag(E->
getExprLoc(), diag::warn_attribute_argument_n_negative)
4532 assert(!ValArg.isInvalid() &&
4533 "Unexpected PerformCopyInitialization() failure.");
4539 Expr *MinBlocks,
unsigned SpellingListIndex) {
4540 CUDALaunchBoundsAttr TmpAttr(AttrRange, Context, MaxThreads, MinBlocks,
4543 if (MaxThreads ==
nullptr)
4548 if (MinBlocks ==
nullptr)
4552 D->
addAttr(::
new (Context) CUDALaunchBoundsAttr(
4553 AttrRange, Context, MaxThreads, MinBlocks, SpellingListIndex));
4570 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
4581 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_decl_type)
4586 uint64_t ArgumentIdx;
4591 uint64_t TypeTagIdx;
4596 bool IsPointer = (Attr.
getName()->
getName() ==
"pointer_with_type_tag");
4601 S.
Diag(Attr.
getLoc(), diag::err_attribute_pointers_only)
4608 ArgumentIdx, TypeTagIdx, IsPointer,
4615 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_n_type)
4623 if (!isa<VarDecl>(D)) {
4624 S.
Diag(Attr.
getLoc(), diag::err_attribute_wrong_decl_type)
4632 assert(MatchingCTypeLoc &&
"no type source info for attribute argument");
4680 Attr.
getKind() == AttributeList::AT_NSConsumed,
4685 unsigned spellingIndex,
bool isNSConsumed,
4702 (isTemplateInstantiation && isNSConsumed &&
4703 getLangOpts().ObjCAutoRefCount
4704 ? diag::err_ns_attribute_wrong_parameter_type
4705 : diag::warn_ns_attribute_wrong_parameter_type))
4707 << (isNSConsumed ?
"ns_consumed" :
"cf_consumed")
4708 << (isNSConsumed ? 0 : 1);
4713 param->
addAttr(::
new (Context)
4714 NSConsumedAttr(attrRange, Context, spellingIndex));
4716 param->
addAttr(::
new (Context)
4717 CFConsumedAttr(attrRange, Context, spellingIndex));
4725 Diag(loc, diag::warn_ns_attribute_wrong_return_type)
4726 <<
"'ns_returns_retained'" << 0 << 0;
4735 returnType = MD->getReturnType();
4737 (Attr.
getKind() == AttributeList::AT_NSReturnsRetained))
4740 returnType = PD->getType();
4742 returnType = FD->getReturnType();
4743 else if (
auto *Param = dyn_cast<ParmVarDecl>(D)) {
4745 if (returnType.
isNull()) {
4746 S.
Diag(D->
getLocStart(), diag::warn_ns_attribute_wrong_parameter_type)
4756 default: llvm_unreachable(
"invalid ownership attribute");
4757 case AttributeList::AT_NSReturnsRetained:
4758 case AttributeList::AT_NSReturnsAutoreleased:
4759 case AttributeList::AT_NSReturnsNotRetained:
4763 case AttributeList::AT_CFReturnsRetained:
4764 case AttributeList::AT_CFReturnsNotRetained:
4776 default: llvm_unreachable(
"invalid ownership attribute");
4777 case AttributeList::AT_NSReturnsRetained:
4782 case AttributeList::AT_NSReturnsAutoreleased:
4783 case AttributeList::AT_NSReturnsNotRetained:
4788 case AttributeList::AT_CFReturnsRetained:
4789 case AttributeList::AT_CFReturnsNotRetained:
4799 if (isa<ParmVarDecl>(D)) {
4800 S.
Diag(D->
getLocStart(), diag::warn_ns_attribute_wrong_parameter_type)
4809 } SubjectKind = Function;
4810 if (isa<ObjCMethodDecl>(D))
4811 SubjectKind = Method;
4812 else if (isa<ObjCPropertyDecl>(D))
4815 << Attr.
getName() << SubjectKind << cf
4823 llvm_unreachable(
"invalid ownership attribute");
4824 case AttributeList::AT_NSReturnsAutoreleased:
4828 case AttributeList::AT_CFReturnsNotRetained:
4832 case AttributeList::AT_NSReturnsNotRetained:
4836 case AttributeList::AT_CFReturnsRetained:
4840 case AttributeList::AT_NSReturnsRetained:
4849 const int EP_ObjCMethod = 1;
4850 const int EP_ObjCProperty = 2;
4854 if (isa<ObjCMethodDecl>(D))
4855 resultType = cast<ObjCMethodDecl>(D)->getReturnType();
4857 resultType = cast<ObjCPropertyDecl>(D)->getType();
4864 << (isa<ObjCMethodDecl>(D) ? EP_ObjCMethod : EP_ObjCProperty)
4880 if (
const ObjCProtocolDecl *PDecl = dyn_cast_or_null<ObjCProtocolDecl>(DC)) {
4883 S.
Diag(PDecl->getLocation(), diag::note_protocol_decl);
4899 if (checkAttrMutualExclusion<CFUnknownTransferAttr>(S, D, Attr.
getRange(),
4910 if (checkAttrMutualExclusion<CFAuditedTransferAttr>(S, D, Attr.
getRange(),
4929 if (
auto TD = dyn_cast<TypedefNameDecl>(D)) {
4931 S.
Diag(Attr.
getLoc(), diag::err_objc_attr_typedef_not_id)
4939 S.
Diag(Attr.
getLoc(), diag::err_objc_attr_typedef_not_void_pointer);
4967 if (!RelatedClass) {
4977 ClassMethod, InstanceMethod,
4986 IFace = CatDecl->getClassInterface();
5001 StringRef MetaDataName;
5015 bool notify =
false;
5024 ObjCBoxableAttr *BoxableAttr = ::new (S.
Context)
5032 L->AddedAttributeToRecord(BoxableAttr, RD);
5050 if (!type->isDependentType() &&
5051 !type->isObjCLifetimeType()) {
5052 S.
Diag(Attr.
getLoc(), diag::err_objc_precise_lifetime_bad_type)
5062 lifetime = type->getObjCARCImplicitLifetime();
5066 assert(type->isDependentType() &&
5067 "didn't infer lifetime for non-dependent type?");
5076 S.
Diag(Attr.
getLoc(), diag::warn_objc_precise_lifetime_meaningless)
5091 unsigned AttrSpellingListIndex, StringRef Uuid) {
5092 if (
const auto *UA = D->
getAttr<UuidAttr>()) {
5093 if (UA->getGuid().equals_lower(Uuid))
5095 Diag(UA->getLocation(), diag::err_mismatched_uuid);
5100 return ::new (Context) UuidAttr(Range, Context, Uuid, AttrSpellingListIndex);
5105 S.
Diag(Attr.
getLoc(), diag::err_attribute_not_supported_in_lang)
5117 if (StrRef.size() == 38 && StrRef.front() ==
'{' && StrRef.back() ==
'}')
5118 StrRef = StrRef.drop_front().drop_back();
5121 if (StrRef.size() != 36) {
5122 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
5126 for (
unsigned i = 0; i < 36; ++i) {
5127 if (i == 8 || i == 13 || i == 18 || i == 23) {
5128 if (StrRef[i] !=
'-') {
5129 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
5133 S.
Diag(LiteralLoc, diag::err_attribute_uuid_malformed_guid);
5145 S.
Diag(Attr.
getLoc(), diag::warn_atl_uuid_deprecated);
5155 S.
Diag(Attr.
getLoc(), diag::err_attribute_not_supported_in_lang)
5171 VarDecl *VD = cast<VarDecl>(D);
5173 S.
Diag(Attr.
getLoc(), diag::err_thread_unsupported);
5177 S.
Diag(Attr.
getLoc(), diag::err_declspec_thread_on_thread_variable);
5181 S.
Diag(Attr.
getLoc(), diag::err_thread_non_global) <<
"__declspec(thread)";
5190 for (
unsigned I = 0, E = Attr.
getNumArgs(); I != E; ++I) {
5194 Tags.push_back(Tag);
5197 if (
const auto *NS = dyn_cast<NamespaceDecl>(D)) {
5198 if (!NS->isInline()) {
5199 S.
Diag(Attr.
getLoc(), diag::warn_attr_abi_tag_namespace) << 0;
5202 if (NS->isAnonymousNamespace()) {
5203 S.
Diag(Attr.
getLoc(), diag::warn_attr_abi_tag_namespace) << 1;
5207 Tags.push_back(NS->getName());
5212 std::sort(Tags.begin(), Tags.end());
5213 Tags.erase(std::unique(Tags.begin(), Tags.end()), Tags.end());
5224 S.
Diag(Attr.
getLoc(), diag::err_attribute_too_many_arguments)
5237 ARMInterruptAttr::InterruptType
Kind;
5238 if (!ARMInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
5239 S.
Diag(Attr.
getLoc(), diag::warn_attribute_type_not_supported)
5240 << Attr.
getName() << Str << ArgLoc;
5263 llvm::APSInt NumParams(32);
5265 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_type)
5271 unsigned Num = NumParams.getLimitedValue(255);
5272 if ((Num & 1) || Num > 30) {
5273 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_out_of_bounds)
5274 << Attr.
getName() << (int)NumParams.getSExtValue()
5289 S.
Diag(Attr.
getLoc(), diag::err_attribute_too_many_arguments)
5329 if (checkAttrMutualExclusion<Mips16Attr>(S, D, Attr.
getRange(),
5333 MipsInterruptAttr::InterruptType
Kind;
5334 if (!MipsInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
5335 S.
Diag(Attr.
getLoc(), diag::warn_attribute_type_not_supported)
5336 << Attr.
getName() <<
"'" + std::string(Str) +
"'";
5354 cast<NamedDecl>(D)->getDeclName().getCXXOverloadedOperator())) {
5355 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
5362 diag::err_anyx86_interrupt_attribute)
5371 if (NumParams < 1 || NumParams > 2) {
5382 diag::err_anyx86_interrupt_attribute)
5394 if (NumParams == 2 &&
5398 diag::err_anyx86_interrupt_attribute)
5420 handleSimpleAttribute<AVRInterruptAttr>(S, D, Attr);
5433 handleSimpleAttribute<AVRSignalAttr>(S, D, Attr);
5439 case llvm::Triple::msp430:
5442 case llvm::Triple::mipsel:
5443 case llvm::Triple::mips:
5446 case llvm::Triple::x86:
5447 case llvm::Triple::x86_64:
5450 case llvm::Triple::avr:
5471 if (Min == 0 && Max != 0) {
5472 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_invalid)
5477 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_invalid)
5483 AMDGPUFlatWorkGroupSizeAttr(Attr.
getLoc(), S.
Context, Min, Max,
5501 if (Min == 0 && Max != 0) {
5502 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_invalid)
5506 if (Max != 0 && Min > Max) {
5507 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_invalid)
5519 uint32_t NumSGPR = 0;
5531 uint32_t NumVGPR = 0;
5555 if (!isa<FunctionDecl>(D)) {
5556 S.
Diag(Attr.
getLoc(), diag::warn_attribute_wrong_decl_type)
5574 S.
Diag(Attr.
getLoc(), diag::err_attribute_argument_out_of_bounds)
5585 unsigned AttrSpellingListIndex) {
5586 if (D->
hasAttr<DLLExportAttr>()) {
5587 Diag(Range.
getBegin(), diag::warn_attribute_ignored) <<
"'dllimport'";
5591 if (D->
hasAttr<DLLImportAttr>())
5594 return ::new (Context) DLLImportAttr(Range, Context, AttrSpellingListIndex);
5598 unsigned AttrSpellingListIndex) {
5599 if (DLLImportAttr *Import = D->
getAttr<DLLImportAttr>()) {
5600 Diag(Import->getLocation(), diag::warn_attribute_ignored) << Import;
5604 if (D->
hasAttr<DLLExportAttr>())
5607 return ::new (Context) DLLExportAttr(Range, Context, AttrSpellingListIndex);
5611 if (isa<ClassTemplatePartialSpecializationDecl>(D) &&
5619 if (FD->isInlined() && A.
getKind() == AttributeList::AT_DLLImport &&
5628 if (
auto *MD = dyn_cast<CXXMethodDecl>(D)) {
5630 MD->getParent()->isLambda()) {
5637 Attr *NewAttr = A.
getKind() == AttributeList::AT_DLLExport
5646 unsigned AttrSpellingListIndex,
5647 MSInheritanceAttr::Spelling SemanticSpelling) {
5648 if (MSInheritanceAttr *IA = D->
getAttr<MSInheritanceAttr>()) {
5649 if (IA->getSemanticSpelling() == SemanticSpelling)
5651 Diag(IA->getLocation(), diag::err_mismatched_ms_inheritance)
5653 Diag(Range.
getBegin(), diag::note_previous_ms_inheritance);
5658 if (RD->hasDefinition()) {
5659 if (checkMSInheritanceAttrOnDefinition(RD, Range, BestCase,
5660 SemanticSpelling)) {
5664 if (isa<ClassTemplatePartialSpecializationDecl>(RD)) {
5665 Diag(Range.
getBegin(), diag::warn_ignored_ms_inheritance)
5669 if (RD->getDescribedClassTemplate()) {
5670 Diag(Range.
getBegin(), diag::warn_ignored_ms_inheritance)
5676 return ::new (Context)
5677 MSInheritanceAttr(Range, Context, BestCase, AttrSpellingListIndex);
5689 StringRef N(
"mutex");
5691 if (Attr.
getKind() == AttributeList::AT_Capability &&
5697 if (!N.equals_lower(
"mutex") && !N.equals_lower(
"role"))
5698 S.
Diag(LiteralLoc, diag::warn_invalid_capability_name) << N;
5711 Args.data(), Args.size(),
5723 Args.data(), Args.size(),
5763 RequiresCapabilityAttr *RCA = ::new (S.
Context)
5771 if (
auto *NSD = dyn_cast<NamespaceDecl>(D)) {
5772 if (NSD->isAnonymousNamespace()) {
5773 S.
Diag(Attr.
getLoc(), diag::warn_deprecated_anonymous_namespace);
5805 if (
const auto *S = dyn_cast<VarDecl>(D))
5806 return S->hasGlobalStorage();
5814 std::vector<StringRef> Sanitizers;
5816 for (
unsigned I = 0, E = Attr.
getNumArgs(); I != E; ++I) {
5817 StringRef SanitizerName;
5824 S.
Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << SanitizerName;
5825 else if (
isGlobalVar(D) && SanitizerName !=
"address")
5828 Sanitizers.push_back(SanitizerName);
5840 StringRef SanitizerName = llvm::StringSwitch<StringRef>(AttrName)
5841 .Case(
"no_address_safety_analysis",
"address")
5842 .Case(
"no_sanitize_address",
"address")
5843 .Case(
"no_sanitize_thread",
"thread")
5844 .Case(
"no_sanitize_memory",
"memory");
5855 if (InternalLinkageAttr *Internal =
5862 if (S.
LangOpts.OpenCLVersion != 200)
5863 S.
Diag(Attr.
getLoc(), diag::err_attribute_requires_opencl_version)
5864 << Attr.
getName() <<
"2.0" << 0;
5866 S.
Diag(Attr.
getLoc(), diag::warn_opencl_attr_deprecated_ignored)
5916 if (D->
hasAttr<OpenCLAccessAttr>()) {
5917 S.
Diag(Attr.
getLoc(), diag::err_opencl_multiple_access_qualifiers)
5928 if (
const ParmVarDecl *PDecl = dyn_cast<ParmVarDecl>(D)) {
5929 const Type *DeclTy = PDecl->getType().getCanonicalType().getTypePtr();
5930 if (Attr.
getName()->
getName().find(
"read_write") != StringRef::npos) {
5932 S.
Diag(Attr.
getLoc(), diag::err_opencl_invalid_read_write)
5953 bool IncludeCXX11Attributes) {
5968 ? diag::warn_unhandled_ms_attribute_ignored
5969 : diag::warn_unknown_attribute_ignored)
5981 assert(Attr.
isTypeAttr() &&
"Non-type attribute not handled");
5984 S.
Diag(Attr.
getLoc(), diag::err_stmt_attribute_invalid_on_decl)
5987 case AttributeList::AT_Interrupt:
5990 case AttributeList::AT_X86ForceAlignArgPointer:
5993 case AttributeList::AT_DLLExport:
5994 case AttributeList::AT_DLLImport:
5997 case AttributeList::AT_Mips16:
5999 MipsInterruptAttr>(S, D, Attr);
6001 case AttributeList::AT_NoMips16:
6002 handleSimpleAttribute<NoMips16Attr>(S, D, Attr);
6004 case AttributeList::AT_MicroMips:
6005 handleSimpleAttributeWithExclusions<MicroMipsAttr, Mips16Attr>(S, D, Attr);
6007 case AttributeList::AT_NoMicroMips:
6008 handleSimpleAttribute<NoMicroMipsAttr>(S, D, Attr);
6010 case AttributeList::AT_MipsLongCall:
6011 handleSimpleAttributeWithExclusions<MipsLongCallAttr, MipsShortCallAttr>(
6014 case AttributeList::AT_MipsShortCall:
6015 handleSimpleAttributeWithExclusions<MipsShortCallAttr, MipsLongCallAttr>(
6018 case AttributeList::AT_AMDGPUFlatWorkGroupSize:
6021 case AttributeList::AT_AMDGPUWavesPerEU:
6024 case AttributeList::AT_AMDGPUNumSGPR:
6027 case AttributeList::AT_AMDGPUNumVGPR:
6030 case AttributeList::AT_AVRSignal:
6033 case AttributeList::AT_IBAction:
6034 handleSimpleAttribute<IBActionAttr>(S, D, Attr);
6036 case AttributeList::AT_IBOutlet:
6039 case AttributeList::AT_IBOutletCollection:
6042 case AttributeList::AT_IFunc:
6045 case AttributeList::AT_Alias:
6048 case AttributeList::AT_Aligned:
6051 case AttributeList::AT_AlignValue:
6054 case AttributeList::AT_AllocSize:
6057 case AttributeList::AT_AlwaysInline:
6060 case AttributeList::AT_AnalyzerNoReturn:
6063 case AttributeList::AT_TLSModel:
6066 case AttributeList::AT_Annotate:
6069 case AttributeList::AT_Availability:
6072 case AttributeList::AT_CarriesDependency:
6075 case AttributeList::AT_Common:
6078 case AttributeList::AT_CUDAConstant:
6081 case AttributeList::AT_PassObjectSize:
6084 case AttributeList::AT_Constructor:
6087 case AttributeList::AT_CXX11NoReturn:
6088 handleSimpleAttribute<CXX11NoReturnAttr>(S, D, Attr);
6090 case AttributeList::AT_Deprecated:
6093 case AttributeList::AT_Destructor:
6096 case AttributeList::AT_EnableIf:
6099 case AttributeList::AT_DiagnoseIf:
6102 case AttributeList::AT_ExtVectorType:
6105 case AttributeList::AT_ExternalSourceSymbol:
6108 case AttributeList::AT_MinSize:
6111 case AttributeList::AT_OptimizeNone:
6114 case AttributeList::AT_FlagEnum:
6115 handleSimpleAttribute<FlagEnumAttr>(S, D, Attr);
6117 case AttributeList::AT_EnumExtensibility:
6120 case AttributeList::AT_Flatten:
6121 handleSimpleAttribute<FlattenAttr>(S, D, Attr);
6123 case AttributeList::AT_Format:
6126 case AttributeList::AT_FormatArg:
6129 case AttributeList::AT_CUDAGlobal:
6132 case AttributeList::AT_CUDADevice:
6133 handleSimpleAttributeWithExclusions<CUDADeviceAttr, CUDAGlobalAttr>(S, D,
6136 case AttributeList::AT_CUDAHost:
6137 handleSimpleAttributeWithExclusions<CUDAHostAttr, CUDAGlobalAttr>(S, D,
6140 case AttributeList::AT_GNUInline:
6143 case AttributeList::AT_CUDALaunchBounds:
6146 case AttributeList::AT_Restrict:
6149 case AttributeList::AT_MayAlias:
6150 handleSimpleAttribute<MayAliasAttr>(S, D, Attr);
6152 case AttributeList::AT_Mode:
6155 case AttributeList::AT_NoAlias:
6156 handleSimpleAttribute<NoAliasAttr>(S, D, Attr);
6158 case AttributeList::AT_NoCommon:
6159 handleSimpleAttribute<NoCommonAttr>(S, D, Attr);
6161 case AttributeList::AT_NoSplitStack:
6162 handleSimpleAttribute<NoSplitStackAttr>(S, D, Attr);
6164 case AttributeList::AT_NonNull:
6170 case AttributeList::AT_ReturnsNonNull:
6173 case AttributeList::AT_NoEscape:
6176 case AttributeList::AT_AssumeAligned:
6179 case AttributeList::AT_AllocAlign:
6182 case AttributeList::AT_Overloadable:
6183 handleSimpleAttribute<OverloadableAttr>(S, D, Attr);
6185 case AttributeList::AT_Ownership:
6188 case AttributeList::AT_Cold:
6191 case AttributeList::AT_Hot:
6194 case AttributeList::AT_Naked:
6197 case AttributeList::AT_NoReturn:
6200 case AttributeList::AT_NoThrow:
6201 handleSimpleAttribute<NoThrowAttr>(S, D, Attr);
6203 case AttributeList::AT_CUDAShared:
6206 case AttributeList::AT_VecReturn:
6209 case AttributeList::AT_ObjCOwnership:
6212 case AttributeList::AT_ObjCPreciseLifetime:
6215 case AttributeList::AT_ObjCReturnsInnerPointer:
6218 case AttributeList::AT_ObjCRequiresSuper:
6221 case AttributeList::AT_ObjCBridge:
6224 case AttributeList::AT_ObjCBridgeMutable:
6227 case AttributeList::AT_ObjCBridgeRelated:
6230 case AttributeList::AT_ObjCDesignatedInitializer:
6233 case AttributeList::AT_ObjCRuntimeName:
6236 case AttributeList::AT_ObjCRuntimeVisible:
6237 handleSimpleAttribute<ObjCRuntimeVisibleAttr>(S, D, Attr);
6239 case AttributeList::AT_ObjCBoxable:
6242 case AttributeList::AT_CFAuditedTransfer:
6245 case AttributeList::AT_CFUnknownTransfer:
6248 case AttributeList::AT_CFConsumed:
6249 case AttributeList::AT_NSConsumed:
6252 case AttributeList::AT_NSConsumesSelf:
6253 handleSimpleAttribute<NSConsumesSelfAttr>(S, D, Attr);
6255 case AttributeList::AT_NSReturnsAutoreleased:
6256 case AttributeList::AT_NSReturnsNotRetained:
6257 case AttributeList::AT_CFReturnsNotRetained:
6258 case AttributeList::AT_NSReturnsRetained:
6259 case AttributeList::AT_CFReturnsRetained:
6262 case AttributeList::AT_WorkGroupSizeHint:
6263 handleWorkGroupSize<WorkGroupSizeHintAttr>(S, D, Attr);
6265 case AttributeList::AT_ReqdWorkGroupSize:
6266 handleWorkGroupSize<ReqdWorkGroupSizeAttr>(S, D, Attr);
6268 case AttributeList::AT_OpenCLIntelReqdSubGroupSize:
6271 case AttributeList::AT_VecTypeHint:
6274 case AttributeList::AT_RequireConstantInit:
6275 handleSimpleAttribute<RequireConstantInitAttr>(S, D, Attr);
6277 case AttributeList::AT_InitPriority:
6280 case AttributeList::AT_Packed:
6283 case AttributeList::AT_Section:
6286 case AttributeList::AT_Target:
6289 case AttributeList::AT_Unavailable:
6290 handleAttrWithMessage<UnavailableAttr>(S, D, Attr);
6292 case AttributeList::AT_ArcWeakrefUnavailable:
6293 handleSimpleAttribute<ArcWeakrefUnavailableAttr>(S, D, Attr);
6295 case AttributeList::AT_ObjCRootClass:
6296 handleSimpleAttribute<ObjCRootClassAttr>(S, D, Attr);
6298 case AttributeList::AT_ObjCSubclassingRestricted:
6299 handleSimpleAttribute<ObjCSubclassingRestrictedAttr>(S, D, Attr);
6301 case AttributeList::AT_ObjCExplicitProtocolImpl:
6304 case AttributeList::AT_ObjCRequiresPropertyDefs:
6305 handleSimpleAttribute<ObjCRequiresPropertyDefsAttr>(S, D, Attr);
6307 case AttributeList::AT_Unused:
6310 case AttributeList::AT_ReturnsTwice:
6311 handleSimpleAttribute<ReturnsTwiceAttr>(S, D, Attr);
6313 case AttributeList::AT_NotTailCalled:
6316 case AttributeList::AT_DisableTailCalls:
6319 case AttributeList::AT_Used:
6322 case AttributeList::AT_Visibility:
6325 case AttributeList::AT_TypeVisibility:
6328 case AttributeList::AT_WarnUnused:
6329 handleSimpleAttribute<WarnUnusedAttr>(S, D, Attr);
6331 case AttributeList::AT_WarnUnusedResult:
6334 case AttributeList::AT_Weak:
6335 handleSimpleAttribute<WeakAttr>(S, D, Attr);
6337 case AttributeList::AT_WeakRef:
6340 case AttributeList::AT_WeakImport:
6343 case AttributeList::AT_TransparentUnion:
6346 case AttributeList::AT_ObjCException:
6347 handleSimpleAttribute<ObjCExceptionAttr>(S, D, Attr);
6349 case AttributeList::AT_ObjCMethodFamily:
6352 case AttributeList::AT_ObjCNSObject:
6355 case AttributeList::AT_ObjCIndependentClass:
6358 case AttributeList::AT_Blocks:
6361 case AttributeList::AT_Sentinel:
6364 case AttributeList::AT_Const:
6365 handleSimpleAttribute<ConstAttr>(S, D, Attr);
6367 case AttributeList::AT_Pure:
6368 handleSimpleAttribute<PureAttr>(S, D, Attr);
6370 case AttributeList::AT_Cleanup:
6373 case AttributeList::AT_NoDebug:
6376 case AttributeList::AT_NoDuplicate:
6377 handleSimpleAttribute<NoDuplicateAttr>(S, D, Attr);
6379 case AttributeList::AT_Convergent:
6380 handleSimpleAttribute<ConvergentAttr>(S, D, Attr);
6382 case AttributeList::AT_NoInline:
6383 handleSimpleAttribute<NoInlineAttr>(S, D, Attr);
6385 case AttributeList::AT_NoInstrumentFunction:
6386 handleSimpleAttribute<NoInstrumentFunctionAttr>(S, D, Attr);
6388 case AttributeList::AT_StdCall:
6389 case AttributeList::AT_CDecl:
6390 case AttributeList::AT_FastCall:
6391 case AttributeList::AT_ThisCall:
6392 case AttributeList::AT_Pascal:
6393 case AttributeList::AT_RegCall:
6394 case AttributeList::AT_SwiftCall:
6395 case AttributeList::AT_VectorCall:
6396 case AttributeList::AT_MSABI:
6397 case AttributeList::AT_SysVABI:
6398 case AttributeList::AT_Pcs:
6399 case AttributeList::AT_IntelOclBicc:
6400 case AttributeList::AT_PreserveMost:
6401 case AttributeList::AT_PreserveAll:
6404 case AttributeList::AT_Suppress:
6407 case AttributeList::AT_OpenCLKernel:
6408 handleSimpleAttribute<OpenCLKernelAttr>(S, D, Attr);
6410 case AttributeList::AT_OpenCLAccess:
6413 case AttributeList::AT_OpenCLNoSVM:
6416 case AttributeList::AT_SwiftContext:
6419 case AttributeList::AT_SwiftErrorResult:
6422 case AttributeList::AT_SwiftIndirectResult:
6425 case AttributeList::AT_InternalLinkage:
6428 case AttributeList::AT_LTOVisibilityPublic:
6429 handleSimpleAttribute<LTOVisibilityPublicAttr>(S, D, Attr);
6433 case AttributeList::AT_EmptyBases:
6434 handleSimpleAttribute<EmptyBasesAttr>(S, D, Attr);
6436 case AttributeList::AT_LayoutVersion:
6439 case AttributeList::AT_MSNoVTable:
6440 handleSimpleAttribute<MSNoVTableAttr>(S, D, Attr);
6442 case AttributeList::AT_MSStruct:
6443 handleSimpleAttribute<MSStructAttr>(S, D, Attr);
6445 case AttributeList::AT_Uuid:
6448 case AttributeList::AT_MSInheritance:
6451 case AttributeList::AT_SelectAny:
6452 handleSimpleAttribute<SelectAnyAttr>(S, D, Attr);
6454 case AttributeList::AT_Thread:
6458 case AttributeList::AT_AbiTag:
6463 case AttributeList::AT_AssertExclusiveLock:
6466 case AttributeList::AT_AssertSharedLock:
6469 case AttributeList::AT_GuardedVar:
6470 handleSimpleAttribute<GuardedVarAttr>(S, D, Attr);
6472 case AttributeList::AT_PtGuardedVar:
6475 case AttributeList::AT_ScopedLockable:
6476 handleSimpleAttribute<ScopedLockableAttr>(S, D, Attr);
6478 case AttributeList::AT_NoSanitize:
6481 case AttributeList::AT_NoSanitizeSpecific:
6484 case AttributeList::AT_NoThreadSafetyAnalysis:
6485 handleSimpleAttribute<NoThreadSafetyAnalysisAttr>(S, D, Attr);
6487 case AttributeList::AT_GuardedBy:
6490 case AttributeList::AT_PtGuardedBy:
6493 case AttributeList::AT_ExclusiveTrylockFunction:
6496 case AttributeList::AT_LockReturned:
6499 case AttributeList::AT_LocksExcluded:
6502 case AttributeList::AT_SharedTrylockFunction:
6505 case AttributeList::AT_AcquiredBefore:
6508 case AttributeList::AT_AcquiredAfter:
6513 case AttributeList::AT_Capability:
6514 case AttributeList::AT_Lockable:
6517 case AttributeList::AT_RequiresCapability:
6521 case AttributeList::AT_AssertCapability:
6524 case AttributeList::AT_AcquireCapability:
6527 case AttributeList::AT_ReleaseCapability:
6530 case AttributeList::AT_TryAcquireCapability:
6535 case AttributeList::AT_Consumable:
6538 case AttributeList::AT_ConsumableAutoCast:
6539 handleSimpleAttribute<ConsumableAutoCastAttr>(S, D, Attr);
6541 case AttributeList::AT_ConsumableSetOnRead:
6542 handleSimpleAttribute<ConsumableSetOnReadAttr>(S, D, Attr);
6544 case AttributeList::AT_CallableWhen:
6547 case AttributeList::AT_ParamTypestate:
6550 case AttributeList::AT_ReturnTypestate:
6553 case AttributeList::AT_SetTypestate:
6556 case AttributeList::AT_TestTypestate:
6561 case AttributeList::AT_ArgumentWithTypeTag:
6564 case AttributeList::AT_TypeTagForDatatype:
6567 case AttributeList::AT_AnyX86NoCallerSavedRegisters:
6570 case AttributeList::AT_RenderScriptKernel:
6571 handleSimpleAttribute<RenderScriptKernelAttr>(S, D, Attr);
6574 case AttributeList::AT_XRayInstrument:
6575 handleSimpleAttribute<XRayInstrumentAttr>(S, D, Attr);
6577 case AttributeList::AT_XRayLogArgs:
6587 bool IncludeCXX11Attributes) {
6596 Diag(AttrList->
getLoc(), diag::err_attribute_weakref_without_alias)
6597 << cast<NamedDecl>(D);
6606 if (!D->
hasAttr<OpenCLKernelAttr>()) {
6608 if (
Attr *A = D->
getAttr<ReqdWorkGroupSizeAttr>()) {
6613 }
else if (
Attr *A = D->
getAttr<WorkGroupSizeHintAttr>()) {
6616 }
else if (
Attr *A = D->
getAttr<VecTypeHintAttr>()) {
6619 }
else if (
Attr *A = D->
getAttr<AMDGPUFlatWorkGroupSizeAttr>()) {
6623 }
else if (
Attr *A = D->
getAttr<AMDGPUWavesPerEUAttr>()) {
6627 }
else if (
Attr *A = D->
getAttr<AMDGPUNumSGPRAttr>()) {
6631 }
else if (
Attr *A = D->
getAttr<AMDGPUNumVGPRAttr>()) {
6635 }
else if (
Attr *A = D->
getAttr<OpenCLIntelReqdSubGroupSizeAttr>()) {
6645 if (
Attr->
getKind() == AttributeList::AT_TransparentUnion) {
6656 if (l->getKind() == AttributeList::AT_Annotate) {
6659 Diag(l->getLoc(), diag::err_only_annotate_after_access_spec);
6670 for ( ; A; A = A->
getNext()) {
6676 S.
Diag(A->
getLoc(), diag::warn_unknown_attribute_ignored)
6679 S.
Diag(A->
getLoc(), diag::warn_attribute_not_on_decl)
6699 assert(isa<FunctionDecl>(ND) || isa<VarDecl>(ND));
6709 FD->getType(), FD->getTypeSourceInfo(),
6715 if (FD->getQualifier())
6723 for (
const auto &AI : FT->param_types()) {
6724 ParmVarDecl *Param = BuildParmVarDeclForTypedef(NewFD, Loc, AI);
6726 Params.push_back(Param);
6728 NewFD->setParams(Params);
6730 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(ND)) {
6732 VD->getInnerLocStart(), VD->getLocation(), II,
6733 VD->getType(), VD->getTypeSourceInfo(),
6734 VD->getStorageClass());
6735 if (VD->getQualifier()) {
6736 VarDecl *NewVD = cast<VarDecl>(NewD);
6751 NewD->
addAttr(AliasAttr::CreateImplicit(Context, NDId->
getName(),
6754 WeakTopLevelDecl.push_back(NewD);
6761 PushOnScopeChains(NewD, S);
6762 CurContext = SavedContext;
6771 LoadExternalWeakUndeclaredIdentifiers();
6772 if (!WeakUndeclaredIdentifiers.empty()) {
6774 if (
VarDecl *VD = dyn_cast<VarDecl>(D))
6775 if (VD->isExternC())
6778 if (FD->isExternC())
6782 auto I = WeakUndeclaredIdentifiers.find(
Id);
6783 if (I != WeakUndeclaredIdentifiers.end()) {
6785 DeclApplyPragmaWeak(S, ND, W);
6786 WeakUndeclaredIdentifiers[
Id] = W;
6799 ProcessDeclAttributeList(S, D, Attrs);
6807 ProcessDeclAttributeList(S, D, Attrs,
false);
6811 ProcessDeclAttributeList(S, D, Attrs);
6814 AddPragmaAttributes(S, D);
6822 UnavailableAttr::ImplicitReason &reason) {
6826 if (!isa<FieldDecl>(decl) && !isa<ObjCPropertyDecl>(decl) &&
6827 !isa<FunctionDecl>(decl))
6835 if ((isa<ObjCIvarDecl>(decl) || isa<ObjCPropertyDecl>(decl))) {
6838 reason = UnavailableAttr::IR_ForbiddenWeak;
6847 reason = UnavailableAttr::IR_ARCForbiddenType;
6857 auto reason = UnavailableAttr::IR_None;
6859 assert(reason &&
"didn't set reason?");
6860 decl->
addAttr(UnavailableAttr::CreateImplicit(S.
Context,
"", reason,
6865 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(decl)) {
6868 if (FD->hasAttr<UnavailableAttr>() &&
6870 diag::err_arc_array_param_no_ownership) {
6884 for (
const auto *A : D->
attrs()) {
6885 if (
const auto *Avail = dyn_cast<AvailabilityAttr>(A)) {
6891 StringRef ActualPlatform = Avail->getPlatform()->getName();
6892 StringRef RealizedPlatform = ActualPlatform;
6894 size_t suffix = RealizedPlatform.rfind(
"_app_extension");
6895 if (suffix != StringRef::npos)
6896 RealizedPlatform = RealizedPlatform.slice(0, suffix);
6902 if (RealizedPlatform == TargetPlatform)
6915 static std::pair<AvailabilityResult, const NamedDecl *>
6934 if (IDecl->getDefinition()) {
6935 D = IDecl->getDefinition();
6940 if (
const auto *ECD = dyn_cast<EnumConstantDecl>(D))
6943 if (
const auto *TheEnumDecl = dyn_cast<EnumDecl>(DC)) {
6944 Result = TheEnumDecl->getAvailability(Message);
6959 assert(K !=
AR_Available &&
"Expected an unavailable declaration here!");
6962 auto CheckContext = [&](
const Decl *C) {
6965 if (AA->getIntroduced() >= DeclVersion)
6968 if (C->isDeprecated())
6971 if (C->isUnavailable())
6982 if (CheckContext(OrigCtx))
6986 if (
auto *CatOrImpl = dyn_cast<ObjCImplDecl>(OrigCtx)) {
6988 if (CheckContext(Interface))
6992 else if (
auto *CatD = dyn_cast<ObjCCategoryDecl>(OrigCtx))
6994 if (CheckContext(Interface))
6999 if (CheckContext(Ctx))
7003 if (
auto *CatOrImpl = dyn_cast<ObjCImplDecl>(Ctx)) {
7005 if (CheckContext(Interface))
7009 else if (
auto *CatD = dyn_cast<ObjCCategoryDecl>(Ctx))
7011 if (CheckContext(Interface))
7024 switch (Triple.getOS()) {
7025 case llvm::Triple::IOS:
7026 case llvm::Triple::TvOS:
7029 case llvm::Triple::WatchOS:
7032 case llvm::Triple::Darwin:
7033 case llvm::Triple::MacOSX:
7038 return Triple.getVendor() == llvm::Triple::Apple;
7040 return DeploymentVersion >= ForceAvailabilityFromVersion ||
7041 DeclVersion >= ForceAvailabilityFromVersion;
7045 for (
Decl *Ctx = OrigCtx; Ctx;
7046 Ctx = cast_or_null<Decl>(Ctx->getDeclContext())) {
7047 if (isa<TagDecl>(Ctx) || isa<FunctionDecl>(Ctx) || isa<ObjCMethodDecl>(Ctx))
7048 return cast<NamedDecl>(Ctx);
7049 if (
auto *CD = dyn_cast<ObjCContainerDecl>(Ctx)) {
7050 if (
auto *Imp = dyn_cast<ObjCImplDecl>(Ctx))
7051 return Imp->getClassInterface();
7061 struct AttributeInsertion {
7066 static AttributeInsertion createInsertionAfter(
const NamedDecl *D) {
7069 static AttributeInsertion createInsertionAfter(
SourceLocation Loc) {
7070 return {
" ", Loc,
""};
7072 static AttributeInsertion createInsertionBefore(
const NamedDecl *D) {
7081 static Optional<AttributeInsertion>
7084 if (isa<ObjCPropertyDecl>(D))
7085 return AttributeInsertion::createInsertionAfter(D);
7086 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
7089 return AttributeInsertion::createInsertionAfter(D);
7091 if (
const auto *TD = dyn_cast<TagDecl>(D)) {
7097 return AttributeInsertion::createInsertionAfter(Loc);
7099 return AttributeInsertion::createInsertionBefore(D);
7118 bool ObjCPropertyAccess) {
7120 unsigned diag, diag_message, diag_fwdclass_message;
7121 unsigned diag_available_here = diag::note_availability_specified_here;
7125 unsigned property_note_select;
7128 unsigned available_here_select_kind;
7132 DeclVersion = AA->getIntroduced();
7140 if (A && A->isInherited()) {
7143 const AvailabilityAttr *AForRedecl =
7145 if (AForRedecl && !AForRedecl->isInherited()) {
7148 NoteLocation = Redecl->getLocation();
7160 const AvailabilityAttr *AA =
7167 unsigned Warning = UseNewWarning ? diag::warn_unguarded_availability_new
7168 : diag::warn_unguarded_availability;
7170 S.
Diag(Loc, Warning)
7172 << AvailabilityAttr::getPrettyPlatformName(
7174 << Introduced.getAsString();
7176 S.
Diag(OffendingDecl->
getLocation(), diag::note_availability_specified_here)
7177 << OffendingDecl << 3;
7180 if (
auto *TD = dyn_cast<TagDecl>(Enclosing))
7181 if (TD->getDeclName().isEmpty()) {
7182 S.
Diag(TD->getLocation(),
7183 diag::note_decl_unguarded_availability_silence)
7184 << 1 << TD->getKindName();
7187 auto FixitNoteDiag =
7188 S.
Diag(Enclosing->getLocation(),
7189 diag::note_decl_unguarded_availability_silence)
7192 if (Enclosing->hasAttr<AvailabilityAttr>())
7200 std::string PlatformName =
7201 AvailabilityAttr::getPlatformNameSourceSpelling(
7204 std::string Introduced =
7208 (llvm::Twine(Insertion->Prefix) +
"API_AVAILABLE(" + PlatformName +
7209 "(" + Introduced +
"))" + Insertion->Suffix)
7215 diag = !ObjCPropertyAccess ? diag::warn_deprecated
7216 : diag::warn_property_method_deprecated;
7217 diag_message = diag::warn_deprecated_message;
7218 diag_fwdclass_message = diag::warn_deprecated_fwdclass_message;
7219 property_note_select = 0;
7220 available_here_select_kind = 2;
7221 if (
const auto *
Attr = OffendingDecl->
getAttr<DeprecatedAttr>())
7226 diag = !ObjCPropertyAccess ? diag::err_unavailable
7227 : diag::err_property_method_unavailable;
7228 diag_message = diag::err_unavailable_message;
7229 diag_fwdclass_message = diag::warn_unavailable_fwdclass_message;
7230 property_note_select = 1;
7231 available_here_select_kind = 0;
7233 if (
auto Attr = OffendingDecl->
getAttr<UnavailableAttr>()) {
7237 auto flagARCError = [&] {
7241 diag = diag::err_unavailable_in_arc;
7244 switch (
Attr->getImplicitReason()) {
7245 case UnavailableAttr::IR_None:
break;
7247 case UnavailableAttr::IR_ARCForbiddenType:
7249 diag_available_here = diag::note_arc_forbidden_type;
7252 case UnavailableAttr::IR_ForbiddenWeak:
7254 diag_available_here = diag::note_arc_weak_disabled;
7256 diag_available_here = diag::note_arc_weak_no_runtime;
7259 case UnavailableAttr::IR_ARCForbiddenConversion:
7261 diag_available_here = diag::note_performs_forbidden_arc_conversion;
7264 case UnavailableAttr::IR_ARCInitReturnsUnrelated:
7266 diag_available_here = diag::note_arc_init_returns_unrelated;
7269 case UnavailableAttr::IR_ARCFieldWithOwnership:
7271 diag_available_here = diag::note_arc_field_with_ownership;
7279 llvm_unreachable(
"Warning for availability of available declaration?");
7285 if (
auto Attr = OffendingDecl->
getAttr<DeprecatedAttr>())
7286 Replacement =
Attr->getReplacement();
7288 Replacement =
Attr->getReplacement();
7290 if (!Replacement.empty())
7295 if (!Message.empty()) {
7296 S.
Diag(Loc, diag_message) << ReferringDecl << Message
7301 << ObjCProperty->
getDeclName() << property_note_select;
7302 }
else if (!UnknownObjCClass) {
7303 S.
Diag(Loc, diag) << ReferringDecl
7308 << ObjCProperty->
getDeclName() << property_note_select;
7310 S.
Diag(Loc, diag_fwdclass_message) << ReferringDecl
7316 S.
Diag(NoteLocation, diag_available_here)
7317 << OffendingDecl << available_here_select_kind;
7323 "Expected an availability diagnostic here");
7358 switch (diag.
Kind) {
7367 HandleDelayedAccessCheck(diag, decl);
7383 assert(curPool &&
"re-emitting in undelayed context not supported");
7384 curPool->
steal(pool);
7393 bool ObjCPropertyAccess) {
7398 AR, Loc, ReferringDecl, OffendingDecl, UnknownObjCClass,
7399 ObjCProperty, Message, ObjCPropertyAccess));
7405 Message, Loc, UnknownObjCClass, ObjCProperty,
7406 ObjCPropertyAccess);
7414 case Stmt::IfStmtClass:
7415 return cast<IfStmt>(
Parent)->getThen() == S ||
7416 cast<IfStmt>(
Parent)->getElse() == S;
7417 case Stmt::WhileStmtClass:
7418 return cast<WhileStmt>(
Parent)->getBody() == S;
7419 case Stmt::DoStmtClass:
7420 return cast<DoStmt>(
Parent)->getBody() == S;
7421 case Stmt::ForStmtClass:
7422 return cast<ForStmt>(
Parent)->getBody() == S;
7423 case Stmt::CXXForRangeStmtClass:
7424 return cast<CXXForRangeStmt>(
Parent)->getBody() == S;
7425 case Stmt::ObjCForCollectionStmtClass:
7426 return cast<ObjCForCollectionStmt>(
Parent)->getBody() == S;
7427 case Stmt::CaseStmtClass:
7428 case Stmt::DefaultStmtClass:
7429 return cast<SwitchCase>(
Parent)->getSubStmt() == S;
7439 bool VisitStmt(
Stmt *S) {
return S != Target; }
7442 static bool isContained(
const Stmt *Target,
const Decl *D) {
7443 StmtUSEFinder Visitor;
7444 Visitor.Target = Target;
7445 return !Visitor.TraverseDecl(const_cast<Decl *>(D));
7461 static const Stmt *findLastStmtThatUsesDecl(
const Decl *D,
7463 LastDeclUSEFinder Visitor;
7467 if (!Visitor.TraverseStmt(const_cast<Stmt *>(S)))
7480 class DiagnoseUnguardedAvailability
7494 DiagnoseUnguardedAvailability(
Sema &SemaRef,
Decl *Ctx)
7495 : SemaRef(SemaRef), Ctx(Ctx) {
7496 AvailabilityStack.push_back(
7500 bool TraverseDecl(
Decl *D) {
7502 if (!D || isa<FunctionDecl>(D))
7504 return Base::TraverseDecl(D);
7507 bool TraverseStmt(
Stmt *S) {
7510 StmtStack.push_back(S);
7511 bool Result = Base::TraverseStmt(S);
7512 StmtStack.pop_back();
7516 void IssueDiagnostics(
Stmt *S) { TraverseStmt(S); }
7518 bool TraverseIfStmt(
IfStmt *If);
7520 bool TraverseLambdaExpr(
LambdaExpr *E) {
return true; }
7534 DiagnoseDeclAvailability(
7540 DiagnoseDeclAvailability(DRE->
getDecl(),
7557 bool VisitTypeLoc(
TypeLoc Ty);
7560 void DiagnoseUnguardedAvailability::DiagnoseDeclAvailability(
7564 std::tie(Result, OffendingDecl) =
7572 const AvailabilityAttr *AA =
7576 if (AvailabilityStack.back() >= Introduced)
7591 SemaRef.Context.getTargetInfo().getPlatformMinVersion(), Introduced)
7592 ? diag::warn_unguarded_availability_new
7593 : diag::warn_unguarded_availability;
7595 SemaRef.Diag(Range.
getBegin(), DiagKind)
7597 << AvailabilityAttr::getPrettyPlatformName(
7598 SemaRef.getASTContext().getTargetInfo().getPlatformName())
7599 << Introduced.getAsString();
7602 diag::note_availability_specified_here)
7603 << OffendingDecl << 3;
7606 SemaRef.Diag(Range.
getBegin(), diag::note_unguarded_available_silence)
7608 << (SemaRef.getLangOpts().ObjC1 ? 0
7612 if (StmtStack.empty())
7614 const Stmt *StmtOfUse = StmtStack.back();
7616 for (
const Stmt *S : llvm::reverse(StmtStack)) {
7617 if (
const auto *CS = dyn_cast<CompoundStmt>(S)) {
7621 if (isBodyLikeChildStmt(StmtOfUse, S)) {
7629 const Stmt *LastStmtOfUse =
nullptr;
7630 if (isa<DeclStmt>(StmtOfUse) && Scope) {
7631 for (
const Decl *D : cast<DeclStmt>(StmtOfUse)->decls()) {
7632 if (StmtUSEFinder::isContained(StmtStack.back(), D)) {
7633 LastStmtOfUse = LastDeclUSEFinder::findLastStmtThatUsesDecl(D, Scope);
7644 (LastStmtOfUse ? LastStmtOfUse : StmtOfUse)->getLocEnd())
7650 const char *ExtraIndentation =
" ";
7651 std::string FixItString;
7652 llvm::raw_string_ostream FixItOS(FixItString);
7653 FixItOS <<
"if (" << (SemaRef.getLangOpts().ObjC1 ?
"@available" 7654 :
"__builtin_available")
7656 << AvailabilityAttr::getPlatformNameSourceSpelling(
7657 SemaRef.getASTContext().getTargetInfo().getPlatformName())
7658 <<
" " << Introduced.getAsString() <<
", *)) {\n" 7659 << Indentation << ExtraIndentation;
7662 StmtEndLoc, tok::semi, SM, SemaRef.getLangOpts(),
7664 if (ElseInsertionLoc.isInvalid())
7667 FixItOS.str().clear();
7669 << Indentation <<
"} else {\n" 7670 << Indentation << ExtraIndentation
7671 <<
"// Fallback on earlier versions\n" 7672 << Indentation <<
"}";
7677 bool DiagnoseUnguardedAvailability::VisitTypeLoc(
TypeLoc Ty) {
7684 if (
const TagType *TT = dyn_cast<TagType>(TyPtr)) {
7686 DiagnoseDeclAvailability(TD, Range);
7688 }
else if (
const TypedefType *TD = dyn_cast<TypedefType>(TyPtr)) {
7690 DiagnoseDeclAvailability(D, Range);
7692 }
else if (
const auto *ObjCO = dyn_cast<ObjCObjectType>(TyPtr)) {
7693 if (
NamedDecl *D = ObjCO->getInterface())
7694 DiagnoseDeclAvailability(D, Range);
7700 bool DiagnoseUnguardedAvailability::TraverseIfStmt(
IfStmt *If) {
7702 if (
auto *E = dyn_cast<ObjCAvailabilityCheckExpr>(If->
getCond())) {
7703 CondVersion = E->getVersion();
7707 if (CondVersion.
empty() || CondVersion <= AvailabilityStack.back())
7708 return TraverseStmt(If->
getThen()) && TraverseStmt(If->
getElse());
7711 return Base::TraverseIfStmt(If);
7714 AvailabilityStack.push_back(CondVersion);
7715 bool ShouldContinue = TraverseStmt(If->
getThen());
7716 AvailabilityStack.pop_back();
7718 return ShouldContinue && TraverseStmt(If->
getElse());
7724 Stmt *Body =
nullptr;
7729 if (FD->isTemplateInstantiation())
7732 Body = FD->getBody();
7733 }
else if (
auto *MD = dyn_cast<ObjCMethodDecl>(D))
7734 Body = MD->getBody();
7735 else if (
auto *BD = dyn_cast<BlockDecl>(D))
7736 Body = BD->getBody();
7738 assert(Body &&
"Need a body here!");
7740 DiagnoseUnguardedAvailability(*
this, D).IssueDiagnostics(Body);
7745 bool ObjCPropertyAccess,
7746 bool AvoidPartialAvailabilityChecks) {
7747 std::string Message;
7756 if (AvoidPartialAvailabilityChecks)
7762 if (getCurFunctionOrMethodDecl()) {
7763 getEnclosingFunction()->HasPotentialAvailabilityViolations =
true;
7765 }
else if (getCurBlock() || getCurLambda()) {
7766 getCurFunction()->HasPotentialAvailabilityViolations =
true;
7775 if (PDeclResult == Result)
7781 UnknownObjCClass, ObjCPDecl, ObjCPropertyAccess);
bool CheckNoCallerSavedRegsAttr(const AttributeList &attr)
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
static void handleConsumableAttr(Sema &S, Decl *D, const AttributeList &Attr)
bool CheckNoReturnAttr(const AttributeList &attr)
static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D, const AttributeList &Attr)
static bool isGlobalVar(const Decl *D)
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Defines the clang::ASTContext interface.
unsigned getRegParmMax() const
static bool hasFunctionProto(const Decl *D)
hasFunctionProto - Return true if the given decl has a argument information.
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
static bool threadSafetyCheckIsPointer(Sema &S, const Decl *D, const AttributeList &Attr)
Check if passed in Decl is a pointer type.
void setProcessingCache(unsigned value) const
An instance of this class is created to represent a function declaration or definition.
bool hasCustomParsing() const
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.
const Stmt * getElse() const
VersionTuple getPlatformMinVersion() const
Retrieve the minimum desired version of the platform, to which the program should be compiled...
bool isUsedAsTypeAttr() const
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
static void handleObjCReturnsInnerPointerAttr(Sema &S, Decl *D, const AttributeList &Attrs)
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
A (possibly-)qualified type.
bool isBlockPointerType() const
static void handleDLLAttr(Sema &S, Decl *D, const AttributeList &A)
bool isMemberPointerType() const
const Expr * getMessageExpr() const
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Represents a version number in the form major[.minor[.subminor[.build]]].
AttributeList * getNext() const
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this attribute.
static void handleAcquiredAfterAttr(Sema &S, Decl *D, const AttributeList &Attr)
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
static void handleAVRInterruptAttr(Sema &S, Decl *D, const AttributeList &Attr)
A class which encapsulates the logic for delaying diagnostics during parsing and other processing...
static bool checkAttributeNumArgsImpl(Sema &S, const AttributeList &Attr, unsigned Num, unsigned Diag, Compare Comp)
const AvailabilityChange & getAvailabilityIntroduced() const
static QualType getFunctionOrMethodResultType(const Decl *D)
Stmt - This represents one statement.
unsigned getProcessingCache() const
FunctionType - C99 6.7.5.3 - Function Declarators.
IfStmt - This represents an if/then/else.
static bool checkTryLockFunAttrCommon(Sema &S, Decl *D, const AttributeList &Attr, SmallVectorImpl< Expr *> &Args)
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
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)
static void handleSimpleAttributeWithExclusions(Sema &S, Decl *D, const AttributeList &Attr)
Defines the SourceManager interface.
static void handleObjCIndependentClass(Sema &S, Decl *D, const AttributeList &Attr)
virtual bool isValidFeatureName(StringRef Feature) const
Determine whether this TargetInfo supports the given feature.
static void handleAttrWithMessage(Sema &S, Decl *D, const AttributeList &Attr)
static InitializedEntity InitializeParameter(ASTContext &Context, const ParmVarDecl *Parm)
Create the initialization entity for a parameter.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
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)
bool isExtVectorType() const
ThreadStorageClassSpecifier getTSCSpec() const
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Defines the C++ template declaration subclasses.
static DelayedDiagnostic makeAvailability(AvailabilityResult AR, SourceLocation Loc, const NamedDecl *ReferringDecl, const NamedDecl *OffendingDecl, const ObjCInterfaceDecl *UnknownObjCClass, const ObjCPropertyDecl *ObjCProperty, StringRef Msg, bool ObjCPropertyAccess)
DeclContext * OriginalLexicalContext
Generally null except when we temporarily switch decl contexts, like in.
static void handleAllocAlignAttr(Sema &S, Decl *D, const AttributeList &Attr)
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
static void handleDestructorAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleSuppressAttr(Sema &S, Decl *D, const AttributeList &Attr)
The base class of the type hierarchy.
static void handleTypeTagForDatatypeAttr(Sema &S, Decl *D, const AttributeList &Attr)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
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...
const TargetInfo & getTargetInfo() const
A container of type source information.
bool isCARCBridgableType() const
Determine whether the given type T is a "bridgeable" C type.
SourceLocation getLocEnd() const LLVM_READONLY
bool getMustBeNull() 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...
unsigned getCharWidth() const
virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const
Determines whether a given calling convention is valid for the target.
SourceLocation getEndLoc() const
Get the end source location.
static bool threadSafetyCheckIsSmartPointer(Sema &S, const RecordType *RT)
IdentifierInfo * getAlias() const
QualType getConstType(QualType T) const
Return the uniqued reference to the type for a const qualified type.
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
OptimizeNoneAttr * mergeOptimizeNoneAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
bool isValidPointerAttrType(QualType T, bool RefOkay=false)
Determine if type T is a valid subject for a nonnull and similar attributes.
static void handleOpenCLNoSVMAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleHotAttr(Sema &S, Decl *D, const AttributeList &Attr)
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...
VarDecl - An instance of this class is created to represent a variable declaration or definition...
bool isArgIdent(unsigned Arg) const
Information about one declarator, including the parsed type information and the identifier.
QualType getReturnType() const
const T * getAs() const
Member-template getAs<specific type>'.
static void handleMinSizeAttr(Sema &S, Decl *D, const AttributeList &Attr)
bool hasPointerRepresentation() const
Whether this type is represented natively as a pointer.
static bool checkGuardedByAttrCommon(Sema &S, Decl *D, const AttributeList &Attr, Expr *&Arg)
ObjCInterfaceDecl * getClassReceiver() const
static bool isValidSwiftErrorResultType(QualType type)
Pointers and references to pointers in the default address space.
ObjCMethodDecl - Represents an instance or class method declaration.
static bool checkParamIsIntegerType(Sema &S, const FunctionDecl *FD, const AttrInfo &Attr, Expr *AttrArg, unsigned FuncParamNo, unsigned AttrArgNo, bool AllowDependentType=false)
Checks to be sure that the given parameter number is in bounds, and is an integral type...
bool isInvalidDecl() const
static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList &AL)
static void handleReturnTypestateAttr(Sema &S, Decl *D, const AttributeList &Attr)
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type...
bool hasDefinition() const
void AddParameterABIAttr(SourceRange AttrRange, Decl *D, ParameterABI ABI, unsigned SpellingListIndex)
ParmVarDecl - Represents a parameter to a function.
pool_iterator pool_begin() const
Defines the clang::Expr interface and subclasses for C++ expressions.
AttributeList * getList() const
FormatAttr * mergeFormatAttr(Decl *D, SourceRange Range, IdentifierInfo *Format, int FormatIdx, int FirstArg, unsigned AttrSpellingListIndex)
const Type * getTypePtr() const
bool hasFloatingRepresentation() const
Determine whether this type has a floating-point representation of some sort, e.g., it is a floating-point type or a vector thereof.
const ObjCPropertyDecl * getObjCProperty() const
UuidAttr * mergeUuidAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex, StringRef Uuid)
const NamedDecl * getAvailabilityReferringDecl() const
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type. ...
static void handleDisableTailCallsAttr(Sema &S, Decl *D, const AttributeList &Attr)
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
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...
Base wrapper for a particular "section" of type source info.
MSInheritanceAttr::Spelling calculateInheritanceModel() const
Calculate what the inheritance model would be for this class.
RecordDecl - Represents a struct/union/class.
static void handleExclusiveTrylockFunctionAttr(Sema &S, Decl *D, const AttributeList &Attr)
SourceLocation getLoc() const
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...
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
static void handleMSP430InterruptAttr(Sema &S, Decl *D, const AttributeList &Attr)
One of these records is kept for each identifier that is lexed.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
static void handleAnyX86InterruptAttr(Sema &S, Decl *D, const AttributeList &Attr)
static StringRef getIndentationForLine(SourceLocation Loc, const SourceManager &SM)
Returns the leading whitespace for line that corresponds to the given location Loc.
static void handleAssumeAlignedAttr(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.
bool isImplicit() const
Returns true if the attribute has been implicitly created instead of explicitly written by the user...
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
static void handleIBOutlet(Sema &S, Decl *D, const AttributeList &Attr)
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)
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
The results of name lookup within a DeclContext.
static bool checkTypedefTypeForCapability(QualType Ty)
static void handleObjCOwnershipAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleGlobalAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleNoCallerSavedRegsAttr(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.
RecordDecl * getDefinition() const
getDefinition - Returns the RecordDecl that actually defines this struct/union/class.
static void handleOpenCLAccessAttr(Sema &S, Decl *D, const AttributeList &Attr)
field_range fields() const
bool isObjCIdType() const
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
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...
bool isReferenceType() const
static void handleLocksExcludedAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleSubGroupSize(Sema &S, Decl *D, const AttributeList &Attr)
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
static void handleTransparentUnionAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleCapabilityAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleColdAttr(Sema &S, Decl *D, const AttributeList &Attr)
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)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
i32 captured_struct **param SharedsTy A type which contains references the shared variables *param Shareds Context with the list of shared variables from the p *TaskFunction *param Data Additional data for task generation like final * state
static void 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...
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
Describes a module or submodule.
bool getLayoutCompatible() const
const NamedDecl * getAvailabilityOffendingDecl() const
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.
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
virtual std::string isValidSectionSpecifier(StringRef SR) const
An optional hook that targets can implement to perform semantic checking on attribute((section("foo")...
void AddAssumeAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, Expr *OE, unsigned SpellingListIndex)
AddAssumeAlignedAttr - Adds an assume_aligned attribute to a particular declaration.
static void 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...
QualType getThisType(ASTContext &C) const
Returns the type of the this pointer.
static void handleNotTailCalledAttr(Sema &S, Decl *D, const AttributeList &Attr)
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.
MinSizeAttr * mergeMinSizeAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
TagKind getTagKind() const
CharUnits - This is an opaque type for sizes expressed in character units.
bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str)
static void handleNoSanitizeAttr(Sema &S, Decl *D, const AttributeList &Attr)
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)
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID...
static void handleAlignValueAttr(Sema &S, Decl *D, const AttributeList &Attr)
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
Visibility getVisibility() const
Determine the visibility of this type.
bool CheckCallingConvAttr(const AttributeList &attr, CallingConv &CC, const FunctionDecl *FD=nullptr)
void steal(DelayedDiagnosticPool &pool)
Steal the diagnostics from the given pool.
bool isClassReceiver() const
static void handleObjCDesignatedInitializer(Sema &S, Decl *D, const AttributeList &Attr)
IdentifierLoc * getArgAsIdent(unsigned Arg) const
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
Scope - A scope is a transient data structure that is used while parsing the program.
static void handleDependencyAttr(Sema &S, Scope *Scope, Decl *D, const AttributeList &Attr)
field_iterator field_begin() const
static bool shouldDiagnoseAvailabilityByDefault(const ASTContext &Context, const VersionTuple &DeploymentVersion, const VersionTuple &DeclVersion)
Represents information about a change in availability for an entity, which is part of the encoding of...
Represents an Objective-C protocol declaration.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
unsigned getAttributeSpellingListIndex() const
Get an index into the attribute spelling list defined in Attr.td.
const LangOptions & getLangOpts() const
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.
virtual unsigned getRegisterWidth() const
Return the "preferred" register width on this target.
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
Represents an ObjC class declaration.
bool diagnoseAppertainsTo(class Sema &S, const Decl *D) const
static void handleCleanupAttr(Sema &S, Decl *D, const AttributeList &Attr)
QualType getReturnType() const
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface...
SourceLocation getTypeSpecStartLoc() const
static bool checkAcquireOrderAttrCommon(Sema &S, Decl *D, const AttributeList &Attr, SmallVectorImpl< Expr *> &Args)
static void handleSectionAttr(Sema &S, Decl *D, const AttributeList &Attr)
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...
static bool checkPositiveIntArgument(Sema &S, const AttrInfo &Attr, const Expr *Expr, int &Val, unsigned Idx=UINT_MAX)
Wrapper around checkUInt32Argument, with an extra check to be sure that the result will fit into a re...
static SourceRange getFunctionOrMethodParamRange(const Decl *D, unsigned Idx)
void AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, unsigned SpellingListIndex, bool IsPackExpansion)
AddAlignedAttr - Adds an aligned attribute to a particular declaration.
This object can be modified without requiring retains or releases.
param_iterator param_begin()
Represents the this expression in C++.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
AvailabilityResult
Captures the result of checking the availability of a declaration.
static void handleNSConsumedAttr(Sema &S, Decl *D, const AttributeList &Attr)
unsigned getFlags() const
getFlags - Return the flags for this scope.
bool canBeWeakImported(bool &IsDefinition) const
Determines whether this symbol can be weak-imported, e.g., whether it would be well-formed to add the...
static void handleAlignedAttr(Sema &S, Decl *D, const AttributeList &Attr)
Sema - This implements semantic analysis and AST building for C.
StringRef getString() const
SourceLocation getLocEnd() const LLVM_READONLY
CompoundStmt - This represents a group of statements like { stmt stmt }.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
static void handleObjCSuppresProtocolAttr(Sema &S, Decl *D, const AttributeList &Attr)
DeclarationNameTable DeclarationNames
static void handleCFAuditedTransferAttr(Sema &S, Decl *D, const AttributeList &Attr)
const FunctionType * getFunctionType(bool BlocksToo=true) const
Looks through the Decl's underlying type to extract a FunctionType when possible. ...
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Captures information about a #pragma weak directive.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
static void handleObjCBoxable(Sema &S, Decl *D, const AttributeList &Attr)
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)
const ObjCInterfaceDecl * getUnknownObjCClass() const
static bool isCFStringType(QualType T, ASTContext &Ctx)
SourceLocation getBeginLoc() const
Get the begin source location.
static void handleNonNullAttr(Sema &S, Decl *D, const AttributeList &Attr)
void popWithoutEmitting(DelayedDiagnosticsState state)
Leave a delayed-diagnostic state that was previously pushed.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
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.
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
virtual bool hasProtectedVisibility() const
Does this target support "protected" visibility?
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
static void handleTargetAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleWarnUnusedResult(Sema &S, Decl *D, const AttributeList &Attr)
static SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset, const SourceManager &SM, const LangOptions &LangOpts)
Computes the source location just past the end of the token at this source location.
static bool checkFunctionConditionAttr(Sema &S, Decl *D, const AttributeList &Attr, Expr *&Cond, StringRef &Msg)
Represents a character-granular source range.
bool isVariadic() const
Whether this function is variadic.
DLLImportAttr * mergeDLLImportAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
bool hasLocalStorage() const
hasLocalStorage - Returns true if a variable with function scope is a non-static local variable...
static bool checkIBOutletCommon(Sema &S, Decl *D, const AttributeList &Attr)
const FunctionProtoType * T
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 SourceLocation findLocationAfterToken(SourceLocation loc, tok::TokenKind TKind, const SourceManager &SM, const LangOptions &LangOpts, bool SkipTrailingWhitespaceAndNewLine)
Checks that the given token is the first token that occurs after the given location (this excludes co...
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that that type refers to...
static bool isCapabilityExpr(Sema &S, const Expr *Ex)
This file defines the classes used to store parsed information about declaration-specifiers and decla...
const T * castAs() const
Member-template castAs<specific type>.
SourceLocation getLocEnd() const LLVM_READONLY
const Stmt * getThen() const
bool isObjCRetainableType() const
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
static void handleCFUnknownTransferAttr(Sema &S, Decl *D, const AttributeList &Attr)
void DiagnoseUnguardedAvailabilityViolations(Decl *FD)
Issue any -Wunguarded-availability warnings in FD.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
Defines the clang::Preprocessor interface.
static bool typeHasCapability(Sema &S, QualType Ty)
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
field_iterator field_end() const
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
static void handleEnableIfAttr(Sema &S, Decl *D, const AttributeList &Attr)
DeclContext * getDeclContext()
void CheckAlignasUnderalignment(Decl *D)
CXXRecordDecl * getDefinition() const
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
virtual void AssignInheritanceModel(CXXRecordDecl *RD)
Callback invoked when an MSInheritanceAttr has been attached to a CXXRecordDecl.
static void handleIFuncAttr(Sema &S, Decl *D, const AttributeList &Attr)
unsigned short getMaxTLSAlign() const
Return the maximum alignment (in bits) of a TLS variable.
FunctionDecl * ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, bool Complain=false, DeclAccessPair *Found=nullptr)
Given an expression that refers to an overloaded function, try to resolve that overloaded function ex...
static void handleSentinelAttr(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.
MSInheritanceAttr * mergeMSInheritanceAttr(Decl *D, SourceRange Range, bool BestCase, unsigned AttrSpellingListIndex, MSInheritanceAttr::Spelling SemanticSpelling)
DeclContext * getParent()
getParent - Returns the containing DeclContext.
An expression that sends a message to the given Objective-C object or class.
static void handleAcquiredBeforeAttr(Sema &S, Decl *D, const AttributeList &Attr)
static bool isNSStringType(QualType T, ASTContext &Ctx)
bool existsInTarget(const TargetInfo &Target) const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Preprocessor & getPreprocessor() const
Represents a GCC generic vector type.
const AvailabilityChange & getAvailabilityObsoleted() const
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)
bool isCXX11Attribute() const
static void handlePtGuardedByAttr(Sema &S, Decl *D, const AttributeList &Attr)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
unsigned getSemanticSpelling() const
If the parsed attribute has a semantic equivalent, and it would have a semantic Spelling enumeration ...
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...
SourceLocation getLocEnd() const LLVM_READONLY
bool hasParsedType() const
SourceLocation getLocation() const
SourceRange getRange() const
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
CallingConv
CallingConv - Specifies the calling convention that a function uses.
static void handleAbiTagAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleWeakImportAttr(Sema &S, Decl *D, const AttributeList &Attr)
static CharSourceRange getCharRange(SourceRange R)
bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type)
This is a scope that corresponds to the parameters within a function prototype for a function declara...
bool isVoidPointerType() const
static void handleAllocSizeAttr(Sema &S, Decl *D, const AttributeList &Attr)
static const RecordType * getRecordType(QualType QT)
Checks that the passed in QualType either is of RecordType or points to RecordType.
RecordDecl * getDecl() const
static void handleMipsInterruptAttr(Sema &S, Decl *D, const AttributeList &Attr)
static bool checkAttributeNumArgs(Sema &S, const AttributeList &Attr, unsigned Num)
Check if the attribute has exactly as many args as Num.
SourceLocation getLocStart() const LLVM_READONLY
static void handleTryAcquireCapabilityAttr(Sema &S, Decl *D, const AttributeList &Attr)
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.
bool empty() const
Determine whether this version information is empty (e.g., all version components are zero)...
const AttributeList * getAttributes() const
static bool checkRecordTypeForCapability(Sema &S, QualType Ty)
static bool isValidSubjectOfNSAttribute(Sema &S, QualType type)
Assigning into this object requires the old value to be released and the new value to be retained...
static FormatAttrKind getFormatAttrKind(StringRef Format)
getFormatAttrKind - Map from format attribute names to supported format types.
bool isBuiltinType() const
Helper methods to distinguish type categories.
not a target-specific vector type
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
ASTContext & getASTContext() const
StringRef getPlatformName() const
Retrieve the name of the platform as it is used in the availability attribute.
unsigned getForbiddenTypeDiagnostic() const
The diagnostic ID to emit.
VersionTuple getVersionIntroduced() const
Retrieve the version of the target platform in which this declaration was introduced.
static void handleNoEscapeAttr(Sema &S, Decl *D, const AttributeList &Attr)
Encodes a location in the source.
unsigned getForbiddenTypeArgument() const
QualType getReturnType() const
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
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 ...
void DiagnoseAvailabilityOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass, bool ObjCPropertyAccess, bool AvoidPartialAvailabilityChecks=false)
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
LangAS getAddressSpace() const
Return the address space of this type.
DLLExportAttr * mergeDLLExportAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
void setUsed(bool Used=true)
std::string getNameAsString() const
getNameAsString - Get a human-readable name for the declaration, even if it is one of the special kin...
SourceLocation getUnavailableLoc() const
DeclarationName getName() const
getName - Returns the embedded declaration name.
TagDecl - Represents the declaration of a struct/union/class/enum.
CommonAttr * mergeCommonAttr(Decl *D, SourceRange Range, IdentifierInfo *Ident, unsigned AttrSpellingListIndex)
IdentifierTable & getIdentifierTable()
IdentifierInfo * getScopeName() const
reverse_body_iterator body_rend()
bool hasVariadicArg() const
static void handleLockReturnedAttr(Sema &S, Decl *D, const AttributeList &Attr)
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
static void handleAvailabilityAttr(Sema &S, Decl *D, const AttributeList &Attr)
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
Represents a static or instance method of a struct/union/class.
bool shouldDelayDiagnostics()
Determines whether diagnostics should be delayed.
static std::enable_if< std::is_base_of< clang::Attr, AttrInfo >::value, SourceLocation >::type getAttrLoc(const AttrInfo &Attr)
A helper function to provide Attribute Location for the Attr types AND the AttributeList.
static void handleNonNullAttrParameter(Sema &S, ParmVarDecl *D, const AttributeList &Attr)
static void DoEmitAvailabilityWarning(Sema &S, AvailabilityResult K, Decl *Ctx, const NamedDecl *ReferringDecl, const NamedDecl *OffendingDecl, StringRef Message, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass, const ObjCPropertyDecl *ObjCProperty, bool ObjCPropertyAccess)
Actually emit an availability diagnostic for a reference to an unavailable decl.
const ParmVarDecl * getParamDecl(unsigned i) const
static T * mergeVisibilityAttr(Sema &S, Decl *D, SourceRange range, typename T::VisibilityType value, unsigned attrSpellingListIndex)
SourceLocation getLocation() const
static void handleAlwaysInlineAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleBlocksAttr(Sema &S, Decl *D, const AttributeList &Attr)
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
ObjCCategoryDecl - Represents a category declaration.
const ParsedType & getMatchingCType() const
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)
static void handleXRayLogArgsAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleNSReturnsRetainedAttr(Sema &S, Decl *D, const AttributeList &Attr)
CUDADiagBuilder CUDADiagIfHostCode(SourceLocation Loc, unsigned DiagID)
Creates a CUDADiagBuilder that emits the diagnostic if the current context is "used as host code"...
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
pool_iterator pool_end() const
bool isObjCObjectPointerType() const
bool isAnyPointerType() const
static unsigned getNumAttributeArgs(const AttributeList &Attr)
AvailabilityResult getAvailabilityResult() const
Represents one property declaration in an Objective-C interface.
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs. ...
static void handleExternalSourceSymbolAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleObjCBridgeMutableAttr(Sema &S, Scope *Sc, Decl *D, const AttributeList &Attr)
static void handleDelayedAvailabilityCheck(Sema &S, DelayedDiagnostic &DD, Decl *Ctx)
static void handleOptimizeNoneAttr(Sema &S, Decl *D, const AttributeList &Attr)
bool isDeclspecAttribute() const
const ObjCMethodDecl * getMethodDecl() const
bool isVectorType() const
static void handleParamTypestateAttr(Sema &S, Decl *D, const AttributeList &Attr)
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)
SourceLocation getLocStart() const LLVM_READONLY
static void handleAMDGPUNumVGPRAttr(Sema &S, Decl *D, const AttributeList &Attr)
ParameterABI
Kinds of parameter ABI.
CUDAFunctionTarget CurrentCUDATarget()
Gets the CUDA target for the current context.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
static Optional< AttributeInsertion > createAttributeInsertion(const NamedDecl *D, const SourceManager &SM, const LangOptions &LangOpts)
Returns a source location in which it's appropriate to insert a new attribute for the given declarati...
StringRef getName() const
Return the actual identifier string.
bool isMacroDefined(StringRef Id)
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current target.
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 EmitAvailabilityWarning(Sema &S, AvailabilityResult AR, const NamedDecl *ReferringDecl, const NamedDecl *OffendingDecl, StringRef Message, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass, const ObjCPropertyDecl *ObjCProperty, bool ObjCPropertyAccess)
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.
static std::enable_if< std::is_base_of< clang::Attr, AttrInfo >::value, const AttrInfo * >::type getAttrName(const AttrInfo &Attr)
A helper function to provide Attribute Name for the Attr types AND the AttributeList.
Dataflow Directional Tag Classes.
void checkUnusedDeclAttributes(Declarator &D)
checkUnusedDeclAttributes - Given a declarator which is not being used to build a declaration...
bool isValid() const
Return true if this is a valid SourceLocation object.
Don't merge availability attributes at all.
static void handleUnusedAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleReturnsNonNullAttr(Sema &S, Decl *D, const AttributeList &Attr)
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)
QualType getForbiddenTypeOperand() const
SourceLocation getLocStart() const
const AttributeList * getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
bool isMicrosoftAttribute() const
bool diagnoseLangOpts(class Sema &S) const
ASTMutationListener * getASTMutationListener() const
void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, WeakInfo &W)
DeclApplyPragmaWeak - A declaration (maybe definition) needs #pragma weak applied to it...
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...
bool hasProcessingCache() const
bool checkMSInheritanceAttrOnDefinition(CXXRecordDecl *RD, SourceRange Range, bool BestCase, MSInheritanceAttr::Spelling SemanticSpelling)
QualType getUnderlyingType() const
std::pair< SourceLocation, SourceLocation > getExpansionRange(SourceLocation Loc) const
Given a SourceLocation object, return the range of tokens covered by the expansion in the ultimate fi...
static void handleObjCBridgeRelatedAttr(Sema &S, Scope *Sc, Decl *D, const AttributeList &Attr)
SectionAttr * mergeSectionAttr(Decl *D, SourceRange Range, StringRef Name, unsigned AttrSpellingListIndex)
A runtime availability query.
Expr * getArgAsExpr(unsigned Arg) const
static void handleSharedAttr(Sema &S, Decl *D, const AttributeList &Attr)
unsigned getMajor() const
Retrieve the major version number.
DeclarationName - The name of a declaration.
StmtClass getStmtClass() const
bool isBooleanType() const
void AddNSConsumedAttr(SourceRange AttrRange, Decl *D, unsigned SpellingListIndex, bool isNSConsumed, bool isTemplateInstantiation)
const ObjCObjectType * getObjectType() const
Gets the type pointed to by this ObjC pointer.
static void handleInternalLinkageAttr(Sema &S, Decl *D, const AttributeList &Attr)
SourceLocation getLocStart() const LLVM_READONLY
EnumDecl - Represents an enum.
VisibilityAttr * mergeVisibilityAttr(Decl *D, SourceRange Range, VisibilityAttr::VisibilityType Vis, unsigned AttrSpellingListIndex)
static void handleIBOutletCollection(Sema &S, Decl *D, const AttributeList &Attr)
void ProcessDeclAttributeDelayed(Decl *D, const AttributeList *AttrList)
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 handleVisibilityAttr(Sema &S, Decl *D, const AttributeList &Attr, bool isTypeVisibility)
static bool ShouldDiagnoseAvailabilityInContext(Sema &S, AvailabilityResult K, VersionTuple DeclVersion, Decl *Ctx)
whether we should emit a diagnostic for K and DeclVersion in the context of Ctx.
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.
const AvailabilityChange & getAvailabilityDeprecated() const
IdentifierInfo * getName() const
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).
std::string getAsString() const
Retrieve a string representation of the version number.
param_iterator param_end()
LLVM_READONLY bool isHexDigit(unsigned char c)
Return true if this character is an ASCII hex digit: [0-9a-fA-F].
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)
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
static bool checkLockFunAttrCommon(Sema &S, Decl *D, const AttributeList &Attr, SmallVectorImpl< Expr *> &Args)
static void handleCallConvAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleAVRSignalAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleAMDGPUWavesPerEUAttr(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)
static void handleSimpleAttribute(Sema &S, Decl *D, const AttributeList &Attr)
Applies the given attribute to the Decl without performing any additional semantic checking...
const ParsedType & getTypeArg() const
void add(const sema::DelayedDiagnostic &diag)
Adds a delayed diagnostic.
bool ProcessAccessDeclAttributeList(AccessSpecDecl *ASDecl, const AttributeList *AttrList)
static bool checkUInt32Argument(Sema &S, const AttrInfo &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...
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
static bool isFunctionOrMethod(const Decl *D)
isFunctionOrMethod - Return true if the given decl has function type (function or function-typed vari...
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple()) const
Determine the availability of the given declaration.
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
bool isPackExpansion() const
bool isArgExpr(unsigned Arg) const
static void handleGuardedByAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleReleaseCapabilityAttr(Sema &S, Decl *D, const AttributeList &Attr)
bool isFunctionType() const
void setInvalid(bool b=true) const
static void handleWeakRefAttr(Sema &S, Decl *D, const AttributeList &Attr)
DeclContext * getCurLexicalContext() const
virtual bool isValidCPUName(StringRef Name) const
brief Determine whether this TargetInfo supports the given CPU name.
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
llvm::StringRef getParameterABISpelling(ParameterABI kind)
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.
const DelayedDiagnosticPool * getParent() const
Represents a base class of a C++ class.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
char __ovld __cnfn max(char x, char y)
Returns y if x < y, otherwise it returns x.
const Expr * getReplacementExpr() const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
SourceManager & getSourceManager()
unsigned getMaxArgs() const
SourceLocation getStrictLoc() const
bool isObjCObjectType() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
static void handleRequiresCapabilityAttr(Sema &S, Decl *D, const AttributeList &Attr)
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
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...
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.
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
Reading or writing from this object requires a barrier call.
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).
TranslationUnitDecl * getTranslationUnitDecl() const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
static void handleEnumExtensibilityAttr(Sema &S, Decl *D, const AttributeList &Attr)
static bool isInstanceMethod(const Decl *D)
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in it, apply them to D...
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
Represents a C++ struct/union/class.
Compatible - the types are compatible according to the standard.
static unsigned getFunctionOrMethodNumParams(const Decl *D)
getFunctionOrMethodNumParams - Return number of function or method parameters.
SourceLocation getSelectorStartLoc() const
reverse_body_iterator body_rbegin()
static void handleAnnotateAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleUsedAttr(Sema &S, Decl *D, const AttributeList &Attr)
SourceLocation getEllipsisLoc() const
A diagnostic message which has been conditionally emitted pending the complete parsing of the current...
bool isTLSSupported() const
Whether the target supports thread-local storage.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
ObjCIvarDecl - Represents an ObjC instance variable.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
unsigned getMinArgs() const
void AddLaunchBoundsAttr(SourceRange AttrRange, Decl *D, Expr *MaxThreads, Expr *MinBlocks, unsigned SpellingListIndex)
AddLaunchBoundsAttr - Adds a launch_bounds attribute to a particular declaration. ...
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
This class is used for builtin types like 'int'.
static void 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)
SourceManager & getSourceManager() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
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.
void AddAllocAlignAttr(SourceRange AttrRange, Decl *D, Expr *ParamExpr, unsigned SpellingListIndex)
AddAllocAlignAttr - Adds an alloc_align attribute to a particular declaration.
static void handleObjCMethodFamilyAttr(Sema &S, Decl *decl, const AttributeList &Attr)
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
static void handleConstantAttr(Sema &S, Decl *D, const AttributeList &Attr)
static bool checkFunctionOrMethodParameterIndex(Sema &S, const Decl *D, const AttrInfo &Attr, unsigned AttrArgNum, const Expr *IdxExpr, uint64_t &Idx, bool AllowImplicitThis=false)
Check if IdxExpr is a valid parameter index for a function or instance method D.
bool checkSectionName(SourceLocation LiteralLoc, StringRef Str)
QualType getRealTypeForBitwidth(unsigned DestWidth) const
getRealTypeForBitwidth - sets floating point QualTy according to specified bitwidth.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
A reference to a declared variable, function, enum, etc.
NamedDecl * getMostRecentDecl()
static QualType getFunctionOrMethodParamType(const Decl *D, unsigned Idx)
static void handleGNUInlineAttr(Sema &S, Decl *D, const AttributeList &Attr)
bool isPointerType() const
static NamedDecl * findEnclosingDeclToAnnotate(Decl *OrigCtx)
SourceLocation getReceiverLocation() const
void NoteAllOverloadCandidates(Expr *E, QualType DestType=QualType(), bool TakingAddress=false)
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static const AvailabilityAttr * getAttrForPlatform(ASTContext &Context, const Decl *D)
class clang::Sema::DelayedDiagnostics DelayedDiagnostics
A collection of diagnostics which were delayed.
static bool isValidSubjectOfCFAttribute(Sema &S, QualType type)
static bool isPotentialConstantExprUnevaluated(Expr *E, const FunctionDecl *FD, SmallVectorImpl< PartialDiagnosticAt > &Diags)
isPotentialConstantExprUnevaluted - Return true if this expression might be usable in a constant expr...
bool isFloatingType() const
const Expr * getCond() const
static Expr * makeLaunchBoundsArgExpr(Sema &S, Expr *E, const CUDALaunchBoundsAttr &Attr, const unsigned Idx)
static void handleNoReturnAttr(Sema &S, Decl *D, const AttributeList &Attrs)
A trivial tuple used to represent a source range.
void setLexicalDeclContext(DeclContext *DC)
static std::pair< AvailabilityResult, const NamedDecl * > ShouldDiagnoseAvailabilityOfDecl(const NamedDecl *D, std::string *Message)
The diagnostic we should emit for D, and the declaration that originated it, or AR_Available.
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)
static void handleParameterABIAttr(Sema &S, Decl *D, const AttributeList &Attrs, ParameterABI Abi)
static bool isFunctionOrMethodVariadic(const Decl *D)
static bool isObjCNSObjectType(QualType Ty)
Return true if this is an NSObject object with its NSObject attribute set.
Describes an entity that is being initialized.
bool isFunctionPointerType() const
attr::Kind getKind() const
static void handleObjCRequiresSuperAttr(Sema &S, Decl *D, const AttributeList &Attrs)
void setHasDesignatedInitializers()
Indicate that this interface decl contains at least one initializer marked with the 'objc_designated_...
StringRef getAvailabilityMessage() const
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
SourceLocation getLocStart() const LLVM_READONLY
SourceLocation getBegin() const
const LangOptions & getLangOpts() const
AttributeDeclKind
These constants match the enumerated choices of warn_attribute_wrong_decl_type and err_attribute_wron...
static bool checkAttrMutualExclusion(Sema &S, Decl *D, SourceRange Range, IdentifierInfo *Ident)
Diagnose mutually exclusive attributes when present on a given declaration.
This class handles loading and caching of source files into memory.
AvailabilityAttr * mergeAvailabilityAttr(NamedDecl *D, SourceRange Range, IdentifierInfo *Platform, bool Implicit, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool IsStrict, StringRef Replacement, AvailabilityMergeKind AMK, unsigned AttrSpellingListIndex)
Attribute merging methods. Return true if a new attribute was added.
static void 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()
static void handleDiagnoseIfAttr(Sema &S, Decl *D, const AttributeList &Attr)
SourceLocation getLocation() const
bool isBeingDefined() const
isBeingDefined - Return true if this decl is currently being defined.
This parameter (which must have pointer type) is a Swift indirect result parameter.
virtual unsigned getUnwindWordWidth() const
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type...
SmallVectorImpl< DelayedDiagnostic >::const_iterator pool_iterator
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth, signed/unsigned.
static bool isValidSwiftContextType(QualType type)
Pointer-like types in the default address space.
AttributeList - Represents a syntactic attribute.
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
static void handleAMDGPUFlatWorkGroupSizeAttr(Sema &S, Decl *D, const AttributeList &Attr)
static void handleVecReturnAttr(Sema &S, Decl *D, const AttributeList &Attr)
SourceLocation getLocStart() const LLVM_READONLY