blob: d4aa5a68fc8e35aee02d583e672d060439e8136c [file] [log] [blame]
/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
|* *|
|* Parsed attribute helpers *|
|* *|
|* Automatically generated file, do not edit! *|
|* *|
\*===----------------------------------------------------------------------===*/
static bool defaultAppertainsTo(Sema &, const ParsedAttr &,const Decl *) {
return true;
}
static bool defaultDiagnoseLangOpts(Sema &, const ParsedAttr &) {
return true;
}
static bool defaultTargetRequirements(const TargetInfo &) {
return true;
}
static unsigned defaultSpellingIndexToSemanticSpelling(const ParsedAttr &Attr) {
return UINT_MAX;
}
static bool checkAMDGPUFlatWorkGroupSizeAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "kernel functions";
return false;
}
return true;
}
static void matchRulesForAMDGPUFlatWorkGroupSize(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkAMDGPUNumSGPRAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "kernel functions";
return false;
}
return true;
}
static void matchRulesForAMDGPUNumSGPR(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkAMDGPUNumVGPRAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "kernel functions";
return false;
}
return true;
}
static void matchRulesForAMDGPUNumVGPR(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkAMDGPUWavesPerEUAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "kernel functions";
return false;
}
return true;
}
static void matchRulesForAMDGPUWavesPerEU(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool isTargetarmthumbarmebthumbebavrx86x86_64msp430mipsmipselriscv32riscv64(const TargetInfo &Target) {
const llvm::Triple &T = Target.getTriple();
return true && (T.getArch() == llvm::Triple::arm || T.getArch() == llvm::Triple::thumb || T.getArch() == llvm::Triple::armeb || T.getArch() == llvm::Triple::thumbeb || T.getArch() == llvm::Triple::avr || T.getArch() == llvm::Triple::x86 || T.getArch() == llvm::Triple::x86_64 || T.getArch() == llvm::Triple::msp430 || T.getArch() == llvm::Triple::mips || T.getArch() == llvm::Triple::mipsel || T.getArch() == llvm::Triple::riscv32 || T.getArch() == llvm::Triple::riscv64);
}
static bool checkAVRSignalAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static bool isTargetavr(const TargetInfo &Target) {
const llvm::Triple &T = Target.getTriple();
return true && (T.getArch() == llvm::Triple::avr);
}
static void matchRulesForAVRSignal(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool isStruct(const Decl *D) {
if (const auto *S = dyn_cast<RecordDecl>(D))
return !S->isUnion();
return false;
}
static bool checkAbiTagAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isStruct(D) && !isa<VarDecl>(D) && !isa<FunctionDecl>(D) && !isa<NamespaceDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "structs, variables, functions, and namespaces";
return false;
}
return true;
}
static void matchRulesForAbiTag(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record_not_is_union, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_namespace, /*IsSupported=*/LangOpts.CPlusPlus));
}
static bool checkAcquireCapabilityAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static unsigned AcquireCapabilityAttrSpellingMap(const ParsedAttr &Attr) {
enum Spelling {
GNU_acquire_capability = 0,
CXX11_clang_acquire_capability = 1,
GNU_acquire_shared_capability = 2,
CXX11_clang_acquire_shared_capability = 3,
GNU_exclusive_lock_function = 4,
GNU_shared_lock_function = 5
};
unsigned Idx = Attr.getAttributeSpellingListIndex();
switch (Idx) {
default: llvm_unreachable("Unknown spelling list index");
case 0: return GNU_acquire_capability;
case 1: return CXX11_clang_acquire_capability;
case 2: return GNU_acquire_shared_capability;
case 3: return CXX11_clang_acquire_shared_capability;
case 4: return GNU_exclusive_lock_function;
case 5: return GNU_shared_lock_function;
}
}
static bool isSharedVar(const Decl *D) {
if (const auto *S = dyn_cast<VarDecl>(D))
return S->hasGlobalStorage() && !S->getTLSKind();
return false;
}
static bool checkAcquiredAfterAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FieldDecl>(D) && !isSharedVar(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "non-static data members and global variables";
return false;
}
return true;
}
static bool checkAcquiredBeforeAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FieldDecl>(D) && !isSharedVar(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "non-static data members and global variables";
return false;
}
return true;
}
static bool isGlobalVar(const Decl *D) {
if (const auto *S = dyn_cast<VarDecl>(D))
return S->hasGlobalStorage();
return false;
}
static bool checkAliasAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D) && !isGlobalVar(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "functions and global variables";
return false;
}
return true;
}
static void matchRulesForAlias(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_global, /*IsSupported=*/true));
}
static bool checkAlignValueAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<VarDecl>(D) && !isa<TypedefNameDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "variables and typedefs";
return false;
}
return true;
}
static void matchRulesForAlignValue(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true));
}
static unsigned AlignedAttrSpellingMap(const ParsedAttr &Attr) {
enum Spelling {
GNU_aligned = 0,
CXX11_gnu_aligned = 1,
Declspec_align = 2,
Keyword_alignas = 3,
Keyword_Alignas = 4
};
unsigned Idx = Attr.getAttributeSpellingListIndex();
switch (Idx) {
default: llvm_unreachable("Unknown spelling list index");
case 0: return GNU_aligned;
case 1: return CXX11_gnu_aligned;
case 2: return Declspec_align;
case 3: return Keyword_alignas;
case 4: return Keyword_Alignas;
}
}
static bool isHasFunctionProto(const Decl *D) {
if (const auto *S = dyn_cast<Decl>(D))
return (S->getFunctionType(true) != nullptr &&
isa<FunctionProtoType>(S->getFunctionType())) ||
isa<ObjCMethodDecl>(S) ||
isa<BlockDecl>(S);
return false;
}
static bool checkAllocAlignAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isHasFunctionProto(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "non-K&R-style functions";
return false;
}
return true;
}
static bool checkAllocSizeAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForAllocSize(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkAlwaysDestroyAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<VarDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "variables";
return false;
}
return true;
}
static void matchRulesForAlwaysDestroy(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true));
}
static bool checkAlwaysInlineAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static unsigned AlwaysInlineAttrSpellingMap(const ParsedAttr &Attr) {
enum Spelling {
GNU_always_inline = 0,
CXX11_gnu_always_inline = 1,
Keyword_forceinline = 2
};
unsigned Idx = Attr.getAttributeSpellingListIndex();
switch (Idx) {
default: llvm_unreachable("Unknown spelling list index");
case 0: return GNU_always_inline;
case 1: return CXX11_gnu_always_inline;
case 2: return Keyword_forceinline;
}
}
static void matchRulesForAlwaysInline(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static void matchRulesForAnnotate(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
}
static bool isTargetx86x86_64(const TargetInfo &Target) {
const llvm::Triple &T = Target.getTriple();
return true && (T.getArch() == llvm::Triple::x86 || T.getArch() == llvm::Triple::x86_64);
}
static bool isFunctionLike(const Decl *D) {
if (const auto *S = dyn_cast<Decl>(D))
return S->getFunctionType(false) != nullptr;
return false;
}
static bool checkAnyX86NoCfCheckAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isFunctionLike(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions and function pointers";
return false;
}
return true;
}
static void matchRulesForAnyX86NoCfCheck(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_hasType_functionType, /*IsSupported=*/true));
}
static bool checkArcWeakrefUnavailableAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ObjCInterfaceDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "Objective-C interfaces";
return false;
}
return true;
}
static void matchRulesForArcWeakrefUnavailable(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC));
}
static bool checkArgumentWithTypeTagAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isHasFunctionProto(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "non-K&R-style functions";
return false;
}
return true;
}
static unsigned ArgumentWithTypeTagAttrSpellingMap(const ParsedAttr &Attr) {
enum Spelling {
GNU_argument_with_type_tag = 0,
CXX11_clang_argument_with_type_tag = 1,
C2x_clang_argument_with_type_tag = 2,
GNU_pointer_with_type_tag = 3,
CXX11_clang_pointer_with_type_tag = 4,
C2x_clang_pointer_with_type_tag = 5
};
unsigned Idx = Attr.getAttributeSpellingListIndex();
switch (Idx) {
default: llvm_unreachable("Unknown spelling list index");
case 0: return GNU_argument_with_type_tag;
case 1: return CXX11_clang_argument_with_type_tag;
case 2: return C2x_clang_argument_with_type_tag;
case 3: return GNU_pointer_with_type_tag;
case 4: return CXX11_clang_pointer_with_type_tag;
case 5: return C2x_clang_pointer_with_type_tag;
}
}
static bool isInlineFunction(const Decl *D) {
if (const auto *S = dyn_cast<FunctionDecl>(D))
return S->isInlineSpecified();
return false;
}
static bool checkArtificialAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isInlineFunction(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "inline functions";
return false;
}
return true;
}
static bool checkAssertCapabilityAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static unsigned AssertCapabilityAttrSpellingMap(const ParsedAttr &Attr) {
enum Spelling {
GNU_assert_capability = 0,
CXX11_clang_assert_capability = 1,
GNU_assert_shared_capability = 2,
CXX11_clang_assert_shared_capability = 3
};
unsigned Idx = Attr.getAttributeSpellingListIndex();
switch (Idx) {
default: llvm_unreachable("Unknown spelling list index");
case 0: return GNU_assert_capability;
case 1: return CXX11_clang_assert_capability;
case 2: return GNU_assert_shared_capability;
case 3: return CXX11_clang_assert_shared_capability;
}
}
static bool checkAssertExclusiveLockAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static bool checkAssertSharedLockAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static bool checkAssumeAlignedAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ObjCMethodDecl>(D) && !isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "Objective-C methods and functions";
return false;
}
return true;
}
static void matchRulesForAssumeAligned(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkAvailabilityAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<NamedDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "named declarations";
return false;
}
return true;
}
static void matchRulesForAvailability(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_enum, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_enum_constant, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_field, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_namespace, /*IsSupported=*/LangOpts.CPlusPlus));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_category, /*IsSupported=*/LangOpts.ObjC));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_property, /*IsSupported=*/LangOpts.ObjC));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_protocol, /*IsSupported=*/LangOpts.ObjC));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true));
}
static bool checkCFAuditedTransferAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForCFAuditedTransfer(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkCFConsumedAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ParmVarDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "parameters";
return false;
}
return true;
}
static void matchRulesForCFConsumed(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true));
}
static bool checkCFUnknownTransferAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForCFUnknownTransfer(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkCPUDispatchAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForCPUDispatch(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkCPUSpecificAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForCPUSpecific(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkCUDAConstantAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<VarDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "variables";
return false;
}
return true;
}
static bool checkCUDALangOpts(Sema &S, const ParsedAttr &Attr) {
if (S.LangOpts.CUDA)
return true;
S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
return false;
}
static void matchRulesForCUDAConstant(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true));
}
static bool checkCUDADeviceAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D) && !isa<VarDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions and variables";
return false;
}
return true;
}
static void matchRulesForCUDADevice(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true));
}
static bool checkCUDAGlobalAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForCUDAGlobal(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkCUDAHostAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForCUDAHost(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkCUDAInvalidTargetAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static bool checkCUDALaunchBoundsAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ObjCMethodDecl>(D) && !isFunctionLike(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "Objective-C methods, functions, and function pointers";
return false;
}
return true;
}
static void matchRulesForCUDALaunchBounds(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_hasType_functionType, /*IsSupported=*/true));
}
static bool checkCUDASharedAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<VarDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "variables";
return false;
}
return true;
}
static void matchRulesForCUDAShared(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true));
}
static bool checkCXX11NoReturnAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForCXX11NoReturn(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkCallableWhenAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<CXXMethodDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForCallableWhen(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function_is_member, /*IsSupported=*/LangOpts.CPlusPlus));
}
static bool checkCapabilityAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<RecordDecl>(D) && !isa<TypedefNameDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "structs, unions, classes, and typedefs";
return false;
}
return true;
}
static unsigned CapabilityAttrSpellingMap(const ParsedAttr &Attr) {
enum Spelling {
GNU_capability = 0,
CXX11_clang_capability = 1,
GNU_shared_capability = 2,
CXX11_clang_shared_capability = 3
};
unsigned Idx = Attr.getAttributeSpellingListIndex();
switch (Idx) {
default: llvm_unreachable("Unknown spelling list index");
case 0: return GNU_capability;
case 1: return CXX11_clang_capability;
case 2: return GNU_shared_capability;
case 3: return CXX11_clang_shared_capability;
}
}
static void matchRulesForCapability(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true));
}
static bool checkCarriesDependencyAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ParmVarDecl>(D) && !isa<ObjCMethodDecl>(D) && !isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "parameters, Objective-C methods, and functions";
return false;
}
return true;
}
static void matchRulesForCarriesDependency(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool isLocalVar(const Decl *D) {
if (const auto *S = dyn_cast<VarDecl>(D))
return S->hasLocalStorage() && !isa<ParmVarDecl>(S);
return false;
}
static bool checkCleanupAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isLocalVar(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "local variables";
return false;
}
return true;
}
static bool checkCodeSegAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D) && !isa<CXXRecordDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "functions and classes";
return false;
}
return true;
}
static bool checkColdAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForCold(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkCommonAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<VarDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "variables";
return false;
}
return true;
}
static void matchRulesForCommon(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true));
}
static bool checkConstructorAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForConstructor(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkConsumableAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<CXXRecordDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "classes";
return false;
}
return true;
}
static void matchRulesForConsumable(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true));
}
static bool checkConsumableAutoCastAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<CXXRecordDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "classes";
return false;
}
return true;
}
static void matchRulesForConsumableAutoCast(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true));
}
static bool checkConsumableSetOnReadAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<CXXRecordDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "classes";
return false;
}
return true;
}
static void matchRulesForConsumableSetOnRead(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true));
}
static bool checkConvergentAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForConvergent(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkDLLExportAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D) && !isa<VarDecl>(D) && !isa<CXXRecordDecl>(D) && !isa<ObjCInterfaceDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions, variables, classes, and Objective-C interfaces";
return false;
}
return true;
}
static bool isTargetx86x86_64armthumbaarch64Win32(const TargetInfo &Target) {
const llvm::Triple &T = Target.getTriple();
return true && (T.getArch() == llvm::Triple::x86 || T.getArch() == llvm::Triple::x86_64 || T.getArch() == llvm::Triple::arm || T.getArch() == llvm::Triple::thumb || T.getArch() == llvm::Triple::aarch64) && (T.getOS() == llvm::Triple::Win32);
}
static void matchRulesForDLLExport(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC));
}
static bool checkDLLExportStaticLocalAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static bool checkDLLImportAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D) && !isa<VarDecl>(D) && !isa<CXXRecordDecl>(D) && !isa<ObjCInterfaceDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions, variables, classes, and Objective-C interfaces";
return false;
}
return true;
}
static void matchRulesForDLLImport(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC));
}
static bool checkDLLImportStaticLocalAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static bool checkDestructorAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForDestructor(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkDiagnoseIfAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D) && !isa<ObjCPropertyDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions, Objective-C methods, and Objective-C properties";
return false;
}
return true;
}
static bool checkDisableTailCallsAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions and Objective-C methods";
return false;
}
return true;
}
static void matchRulesForDisableTailCalls(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC));
}
static bool checkEmptyBasesAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<CXXRecordDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "classes";
return false;
}
return true;
}
static bool isTargetx86x86_64armthumbaarch64Microsoft(const TargetInfo &Target) {
const llvm::Triple &T = Target.getTriple();
return true && (T.getArch() == llvm::Triple::x86 || T.getArch() == llvm::Triple::x86_64 || T.getArch() == llvm::Triple::arm || T.getArch() == llvm::Triple::thumb || T.getArch() == llvm::Triple::aarch64) && (Target.getCXXABI().getKind() == TargetCXXABI::Microsoft);
}
static bool checkEnableIfAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForEnableIf(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkEnumExtensibilityAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<EnumDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "enums";
return false;
}
return true;
}
static void matchRulesForEnumExtensibility(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_enum, /*IsSupported=*/true));
}
static bool checkExcludeFromExplicitInstantiationAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<VarDecl>(D) && !isa<FunctionDecl>(D) && !isa<CXXRecordDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "variables, functions, and classes";
return false;
}
return true;
}
static void matchRulesForExcludeFromExplicitInstantiation(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true));
}
static bool checkExclusiveTrylockFunctionAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static bool checkExtVectorTypeAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<TypedefNameDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "typedefs";
return false;
}
return true;
}
static bool checkExternalSourceSymbolAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<NamedDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "named declarations";
return false;
}
return true;
}
static void matchRulesForExternalSourceSymbol(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_enum, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_enum_constant, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_field, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_namespace, /*IsSupported=*/LangOpts.CPlusPlus));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_category, /*IsSupported=*/LangOpts.ObjC));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_property, /*IsSupported=*/LangOpts.ObjC));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_protocol, /*IsSupported=*/LangOpts.ObjC));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true));
}
static bool checkFlagEnumAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<EnumDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "enums";
return false;
}
return true;
}
static void matchRulesForFlagEnum(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_enum, /*IsSupported=*/true));
}
static bool checkFlattenAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForFlatten(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkFormatAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ObjCMethodDecl>(D) && !isa<BlockDecl>(D) && !isHasFunctionProto(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "Objective-C methods, blocks, and non-K&R-style functions";
return false;
}
return true;
}
static bool checkFormatArgAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ObjCMethodDecl>(D) && !isHasFunctionProto(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "Objective-C methods and non-K&R-style functions";
return false;
}
return true;
}
static bool checkGNUInlineAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForGNUInline(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkGuardedByAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FieldDecl>(D) && !isSharedVar(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "non-static data members and global variables";
return false;
}
return true;
}
static bool checkGuardedVarAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FieldDecl>(D) && !isSharedVar(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "non-static data members and global variables";
return false;
}
return true;
}
static bool checkHotAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForHot(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool isObjCInstanceMethod(const Decl *D) {
if (const auto *S = dyn_cast<ObjCMethodDecl>(D))
return S->isInstanceMethod();
return false;
}
static bool checkIBActionAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isObjCInstanceMethod(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "Objective-C instance methods";
return false;
}
return true;
}
static void matchRulesForIBAction(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method_is_instance, /*IsSupported=*/LangOpts.ObjC));
}
static bool checkIFuncAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static bool isTargetELF(const TargetInfo &Target) {
const llvm::Triple &T = Target.getTriple();
return true && (T.getObjectFormat() == llvm::Triple::ELF);
}
static void matchRulesForIFunc(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkInitPriorityAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<VarDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "variables";
return false;
}
return true;
}
static void matchRulesForInitPriority(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true));
}
static bool checkInternalLinkageAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<VarDecl>(D) && !isa<FunctionDecl>(D) && !isa<CXXRecordDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "variables, functions, and classes";
return false;
}
return true;
}
static void matchRulesForInternalLinkage(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true));
}
static bool checkLTOVisibilityPublicAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<RecordDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "structs, unions, and classes";
return false;
}
return true;
}
static void matchRulesForLTOVisibilityPublic(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true));
}
static bool checkLayoutVersionAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<CXXRecordDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "classes";
return false;
}
return true;
}
static bool isImplicitObjectParameter(const Decl *D) {
if (const auto *S = dyn_cast<FunctionDecl>(D))
return static_cast<void>(S), false;
return false;
}
static bool checkLifetimeBoundAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ParmVarDecl>(D) && !isImplicitObjectParameter(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "parameters and implicit object parameters";
return false;
}
return true;
}
static bool checkCPlusPlusLangOpts(Sema &S, const ParsedAttr &Attr) {
if (S.LangOpts.CPlusPlus)
return true;
S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
return false;
}
static bool checkLockReturnedAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static bool checkLockableAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<RecordDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "structs, unions, and classes";
return false;
}
return true;
}
static void matchRulesForLockable(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true));
}
static bool checkLocksExcludedAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static unsigned LoopHintAttrSpellingMap(const ParsedAttr &Attr) {
enum Spelling {
Pragma_clang_loop = 0,
Pragma_unroll = 1,
Pragma_nounroll = 2,
Pragma_unroll_and_jam = 3,
Pragma_nounroll_and_jam = 4
};
unsigned Idx = Attr.getAttributeSpellingListIndex();
switch (Idx) {
default: llvm_unreachable("Unknown spelling list index");
case 0: return Pragma_clang_loop;
case 1: return Pragma_unroll;
case 2: return Pragma_nounroll;
case 3: return Pragma_unroll_and_jam;
case 4: return Pragma_nounroll_and_jam;
}
}
static bool checkMicrosoftExtLangOpts(Sema &S, const ParsedAttr &Attr) {
if (S.LangOpts.MicrosoftExt)
return true;
S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
return false;
}
static unsigned MSInheritanceAttrSpellingMap(const ParsedAttr &Attr) {
enum Spelling {
Keyword_single_inheritance = 0,
Keyword_multiple_inheritance = 1,
Keyword_virtual_inheritance = 2,
Keyword_unspecified_inheritance = 3
};
unsigned Idx = Attr.getAttributeSpellingListIndex();
switch (Idx) {
default: llvm_unreachable("Unknown spelling list index");
case 0: return Keyword_single_inheritance;
case 1: return Keyword_multiple_inheritance;
case 2: return Keyword_virtual_inheritance;
case 3: return Keyword_unspecified_inheritance;
}
}
static bool checkMSNoVTableAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<CXXRecordDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "classes";
return false;
}
return true;
}
static bool checkMSStructAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<RecordDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "structs, unions, and classes";
return false;
}
return true;
}
static void matchRulesForMSStruct(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true));
}
static bool checkMicroMipsAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static bool isTargetmipsmipsel(const TargetInfo &Target) {
const llvm::Triple &T = Target.getTriple();
return true && (T.getArch() == llvm::Triple::mips || T.getArch() == llvm::Triple::mipsel);
}
static void matchRulesForMicroMips(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkMinSizeAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "functions and Objective-C methods";
return false;
}
return true;
}
static void matchRulesForMinSize(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC));
}
static bool checkMinVectorWidthAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForMinVectorWidth(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkMips16AppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForMips16(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkMipsLongCallAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static bool isTargetmipsmipselmips64mips64el(const TargetInfo &Target) {
const llvm::Triple &T = Target.getTriple();
return true && (T.getArch() == llvm::Triple::mips || T.getArch() == llvm::Triple::mipsel || T.getArch() == llvm::Triple::mips64 || T.getArch() == llvm::Triple::mips64el);
}
static unsigned MipsLongCallAttrSpellingMap(const ParsedAttr &Attr) {
enum Spelling {
GNU_long_call = 0,
CXX11_gnu_long_call = 1,
GNU_far = 2,
CXX11_gnu_far = 3
};
unsigned Idx = Attr.getAttributeSpellingListIndex();
switch (Idx) {
default: llvm_unreachable("Unknown spelling list index");
case 0: return GNU_long_call;
case 1: return CXX11_gnu_long_call;
case 2: return GNU_far;
case 3: return CXX11_gnu_far;
}
}
static void matchRulesForMipsLongCall(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkMipsShortCallAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static unsigned MipsShortCallAttrSpellingMap(const ParsedAttr &Attr) {
enum Spelling {
GNU_short_call = 0,
CXX11_gnu_short_call = 1,
GNU_near = 2,
CXX11_gnu_near = 3
};
unsigned Idx = Attr.getAttributeSpellingListIndex();
switch (Idx) {
default: llvm_unreachable("Unknown spelling list index");
case 0: return GNU_short_call;
case 1: return CXX11_gnu_short_call;
case 2: return GNU_near;
case 3: return CXX11_gnu_near;
}
}
static void matchRulesForMipsShortCall(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkModeAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<VarDecl>(D) && !isa<EnumDecl>(D) && !isa<TypedefNameDecl>(D) && !isa<FieldDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "variables, enums, typedefs, and non-static data members";
return false;
}
return true;
}
static bool checkNSConsumedAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ParmVarDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "parameters";
return false;
}
return true;
}
static void matchRulesForNSConsumed(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true));
}
static bool checkNSConsumesSelfAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ObjCMethodDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "Objective-C methods";
return false;
}
return true;
}
static void matchRulesForNSConsumesSelf(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC));
}
static bool checkNakedAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForNaked(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkNoAliasAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static bool checkNoCommonAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<VarDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "variables";
return false;
}
return true;
}
static void matchRulesForNoCommon(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true));
}
static bool isNonParmVar(const Decl *D) {
if (const auto *S = dyn_cast<VarDecl>(D))
return S->getKind() != Decl::ParmVar;
return false;
}
static bool checkNoDebugAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isFunctionLike(D) && !isa<ObjCMethodDecl>(D) && !isNonParmVar(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions, function pointers, Objective-C methods, and variables";
return false;
}
return true;
}
static void matchRulesForNoDebug(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_hasType_functionType, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_not_is_parameter, /*IsSupported=*/true));
}
static bool checkNoDestroyAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<VarDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "variables";
return false;
}
return true;
}
static void matchRulesForNoDestroy(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true));
}
static bool checkNoDuplicateAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForNoDuplicate(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkNoEscapeAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ParmVarDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "parameters";
return false;
}
return true;
}
static void matchRulesForNoEscape(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true));
}
static bool checkNoInlineAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForNoInline(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkNoInstrumentFunctionAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForNoInstrumentFunction(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkNoMicroMipsAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForNoMicroMips(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkNoMips16AppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForNoMips16(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkNoSanitizeAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D) && !isGlobalVar(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "functions, Objective-C methods, and global variables";
return false;
}
return true;
}
static void matchRulesForNoSanitize(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_global, /*IsSupported=*/true));
}
static bool checkNoSanitizeSpecificAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D) && !isGlobalVar(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "functions and global variables";
return false;
}
return true;
}
static void matchRulesForNoSanitizeSpecific(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_global, /*IsSupported=*/true));
}
static bool checkNoSplitStackAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForNoSplitStack(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkNoStackProtectorAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForNoStackProtector(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkNoThreadSafetyAnalysisAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForNoThreadSafetyAnalysis(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkNoThrowAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForNoThrow(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkNonNullAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ObjCMethodDecl>(D) && !isHasFunctionProto(D) && !isa<ParmVarDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions, methods, and parameters";
return false;
}
return true;
}
static bool checkNotTailCalledAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForNotTailCalled(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkObjCBoxableAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<RecordDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "structs, unions, and classes";
return false;
}
return true;
}
static void matchRulesForObjCBoxable(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true));
}
static bool checkObjCBridgeAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<RecordDecl>(D) && !isa<TypedefNameDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "structs, unions, classes, and typedefs";
return false;
}
return true;
}
static void matchRulesForObjCBridge(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true));
}
static bool checkObjCBridgeMutableAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<RecordDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "structs, unions, and classes";
return false;
}
return true;
}
static void matchRulesForObjCBridgeMutable(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true));
}
static bool checkObjCBridgeRelatedAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<RecordDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "structs, unions, and classes";
return false;
}
return true;
}
static void matchRulesForObjCBridgeRelated(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true));
}
static bool isObjCInterfaceDeclInitMethod(const Decl *D) {
if (const auto *S = dyn_cast<ObjCMethodDecl>(D))
return S->getMethodFamily() == OMF_init &&
(isa<ObjCInterfaceDecl>(S->getDeclContext()) ||
(isa<ObjCCategoryDecl>(S->getDeclContext()) &&
cast<ObjCCategoryDecl>(S->getDeclContext())->IsClassExtension()));
return false;
}
static bool checkObjCDesignatedInitializerAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isObjCInterfaceDeclInitMethod(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "init methods of interface or class extension declarations";
return false;
}
return true;
}
static bool checkObjCExceptionAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ObjCInterfaceDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "Objective-C interfaces";
return false;
}
return true;
}
static void matchRulesForObjCException(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC));
}
static bool checkObjCExplicitProtocolImplAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ObjCProtocolDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "Objective-C protocols";
return false;
}
return true;
}
static void matchRulesForObjCExplicitProtocolImpl(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_protocol, /*IsSupported=*/LangOpts.ObjC));
}
static bool checkObjCMethodFamilyAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ObjCMethodDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "Objective-C methods";
return false;
}
return true;
}
static void matchRulesForObjCMethodFamily(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC));
}
static bool checkObjCPreciseLifetimeAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<VarDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "variables";
return false;
}
return true;
}
static void matchRulesForObjCPreciseLifetime(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true));
}
static bool checkObjCRequiresPropertyDefsAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ObjCInterfaceDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "Objective-C interfaces";
return false;
}
return true;
}
static void matchRulesForObjCRequiresPropertyDefs(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC));
}
static bool checkObjCRequiresSuperAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ObjCMethodDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "Objective-C methods";
return false;
}
return true;
}
static void matchRulesForObjCRequiresSuper(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC));
}
static bool checkObjCReturnsInnerPointerAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ObjCMethodDecl>(D) && !isa<ObjCPropertyDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "Objective-C methods and Objective-C properties";
return false;
}
return true;
}
static void matchRulesForObjCReturnsInnerPointer(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_property, /*IsSupported=*/LangOpts.ObjC));
}
static bool checkObjCRootClassAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ObjCInterfaceDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "Objective-C interfaces";
return false;
}
return true;
}
static void matchRulesForObjCRootClass(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC));
}
static bool checkObjCRuntimeNameAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ObjCInterfaceDecl>(D) && !isa<ObjCProtocolDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "Objective-C interfaces and Objective-C protocols";
return false;
}
return true;
}
static void matchRulesForObjCRuntimeName(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_protocol, /*IsSupported=*/LangOpts.ObjC));
}
static bool checkObjCRuntimeVisibleAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ObjCInterfaceDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "Objective-C interfaces";
return false;
}
return true;
}
static void matchRulesForObjCRuntimeVisible(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC));
}
static bool checkObjCSubclassingRestrictedAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ObjCInterfaceDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "Objective-C interfaces";
return false;
}
return true;
}
static void matchRulesForObjCSubclassingRestricted(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC));
}
static bool checkOpenCLAccessAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ParmVarDecl>(D) && !isa<TypedefNameDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "parameters and typedefs";
return false;
}
return true;
}
static unsigned OpenCLAccessAttrSpellingMap(const ParsedAttr &Attr) {
enum Spelling {
Keyword_read_only = 0,
Keyword_write_only = 2,
Keyword_read_write = 4
};
unsigned Idx = Attr.getAttributeSpellingListIndex();
switch (Idx) {
default: llvm_unreachable("Unknown spelling list index");
case 0: return Keyword_read_only;
case 1: return Keyword_read_only;
case 2: return Keyword_write_only;
case 3: return Keyword_write_only;
case 4: return Keyword_read_write;
case 5: return Keyword_read_write;
}
}
static bool checkOpenCLIntelReqdSubGroupSizeAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForOpenCLIntelReqdSubGroupSize(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkOpenCLKernelAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static bool checkOpenCLNoSVMAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<VarDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "variables";
return false;
}
return true;
}
static bool checkOpenCLLangOpts(Sema &S, const ParsedAttr &Attr) {
if (S.LangOpts.OpenCL)
return true;
S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
return false;
}
static void matchRulesForOpenCLNoSVM(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true));
}
static bool checkOptimizeNoneAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions and Objective-C methods";
return false;
}
return true;
}
static void matchRulesForOptimizeNone(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC));
}
static bool checkOverloadableAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static void matchRulesForOverloadable(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true));
}
static bool checkOwnershipAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isHasFunctionProto(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "non-K&R-style functions";
return false;
}
return true;
}
static unsigned OwnershipAttrSpellingMap(const ParsedAttr &Attr) {
enum Spelling {
GNU_ownership_holds = 0,
CXX11_clang_ownership_holds = 1,
C2x_clang_ownership_holds = 2,
GNU_ownership_returns = 3,
CXX11_clang_ownership_returns = 4,
C2x_clang_ownership_returns = 5,
GNU_ownership_takes = 6,
CXX11_clang_ownership_takes = 7,
C2x_clang_ownership_takes = 8
};
unsigned Idx = Attr.getAttributeSpellingListIndex();
switch (Idx) {
default: llvm_unreachable("Unknown spelling list index");
case 0: return GNU_ownership_holds;
case 1: return CXX11_clang_ownership_holds;
case 2: return C2x_clang_ownership_holds;
case 3: return GNU_ownership_returns;
case 4: return CXX11_clang_ownership_returns;
case 5: return C2x_clang_ownership_returns;
case 6: return GNU_ownership_takes;
case 7: return CXX11_clang_ownership_takes;
case 8: return C2x_clang_ownership_takes;
}
}
static bool checkParamTypestateAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ParmVarDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "parameters";
return false;
}
return true;
}
static void matchRulesForParamTypestate(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true));
}
static bool checkPassObjectSizeAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<ParmVarDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "parameters";
return false;
}
return true;
}
static void matchRulesForPassObjectSize(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) {
MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true));
}
static bool checkPragmaClangBSSSectionAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isGlobalVar(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "global variables";
return false;
}
return true;
}
static bool checkPragmaClangDataSectionAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isGlobalVar(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "global variables";
return false;
}
return true;
}
static bool checkPragmaClangRodataSectionAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isGlobalVar(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "global variables";
return false;
}
return true;
}
static bool checkPragmaClangTextSectionAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static bool checkPtGuardedByAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FieldDecl>(D) && !isSharedVar(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "non-static data members and global variables";
return false;
}
return true;
}
static bool checkPtGuardedVarAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FieldDecl>(D) && !isSharedVar(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "non-static data members and global variables";
return false;
}
return true;
}
static bool isNonStaticNonConstCXXMethod(const Decl *D) {
if (const auto *S = dyn_cast<CXXMethodDecl>(D))
return !S->isStatic() && !S->isConst();
return false;
}
static bool checkReinitializesAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isNonStaticNonConstCXXMethod(D))) {
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str)
<< Attr << "non-static non-const member functions";
return false;
}
return true;
}
static bool checkReleaseCapabilityAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
<< Attr << "functions";
return false;
}
return true;
}
static unsigned ReleaseCapabilityAttrSpellingMap(const ParsedAttr &Attr) {
enum Spelling {
GNU_release_capability = 0,
CXX11_clang_release_capability = 1,
GNU_release_shared_capability = 2,
CXX11_clang_release_shared_capability = 3,
GNU_release_generic_capability = 4,
CXX11_clang_release_generic_capability = 5,
GNU_unlock_function = 6,
CXX11_clang_unlock_function = 7
};
unsigned Idx = Attr.getAttributeSpellingListIndex();
switch (Idx) {
default: llvm_unreachable("Unknown spelling list index");
case 0: return GNU_release_capability;
case 1: return CXX11_clang_release_capability;
case 2: return GNU_release_shared_capability;
case 3: return CXX11_clang_release_shared_capability;
case 4: return GNU_release_generic_capability;
case 5: return CXX11_clang_release_generic_capability;
case 6: return GNU_unlock_function;
case 7: return CXX11_clang_unlock_function;
}
}
static bool checkRenderScriptKernelAppertainsTo(Sema &S, const ParsedAttr &Attr, const Decl *D) {
if (!D || (!isa<FunctionDecl>(D))) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)