Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 14 | pmbaty | 1 | /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ |
| 2 | |* *| |
||
| 3 | |* Parsed attribute helpers *| |
||
| 4 | |* *| |
||
| 5 | |* Automatically generated file, do not edit! *| |
||
| 6 | |* *| |
||
| 7 | \*===----------------------------------------------------------------------===*/ |
||
| 8 | |||
| 9 | #if !defined(WANT_DECL_MERGE_LOGIC) && !defined(WANT_STMT_MERGE_LOGIC) |
||
| 10 | static bool isStruct(const Decl *D) { |
||
| 11 | if (const auto *S = dyn_cast<RecordDecl>(D)) |
||
| 12 | return !S->isUnion(); |
||
| 13 | return false; |
||
| 14 | } |
||
| 15 | |||
| 16 | static bool isSharedVar(const Decl *D) { |
||
| 17 | if (const auto *S = dyn_cast<VarDecl>(D)) |
||
| 18 | return S->hasGlobalStorage() && !S->getTLSKind(); |
||
| 19 | return false; |
||
| 20 | } |
||
| 21 | |||
| 22 | static bool isGlobalVar(const Decl *D) { |
||
| 23 | if (const auto *S = dyn_cast<VarDecl>(D)) |
||
| 24 | return S->hasGlobalStorage(); |
||
| 25 | return false; |
||
| 26 | } |
||
| 27 | |||
| 28 | static bool isHasFunctionProto(const Decl *D) { |
||
| 29 | if (const auto *S = dyn_cast<Decl>(D)) |
||
| 30 | return (S->getFunctionType(true) != nullptr && |
||
| 31 | isa<FunctionProtoType>(S->getFunctionType())) || |
||
| 32 | isa<ObjCMethodDecl>(S) || |
||
| 33 | isa<BlockDecl>(S); |
||
| 34 | return false; |
||
| 35 | } |
||
| 36 | |||
| 37 | static bool isFunctionLike(const Decl *D) { |
||
| 38 | if (const auto *S = dyn_cast<Decl>(D)) |
||
| 39 | return S->getFunctionType(false) != nullptr; |
||
| 40 | return false; |
||
| 41 | } |
||
| 42 | |||
| 43 | static bool isInlineFunction(const Decl *D) { |
||
| 44 | if (const auto *S = dyn_cast<FunctionDecl>(D)) |
||
| 45 | return S->isInlineSpecified(); |
||
| 46 | return false; |
||
| 47 | } |
||
| 48 | |||
| 49 | static bool isLocalVar(const Decl *D) { |
||
| 50 | if (const auto *S = dyn_cast<VarDecl>(D)) |
||
| 51 | return S->hasLocalStorage() && !isa<ParmVarDecl>(S); |
||
| 52 | return false; |
||
| 53 | } |
||
| 54 | |||
| 55 | static bool isHLSLEntry(const Decl *D) { |
||
| 56 | if (const auto *S = dyn_cast<FunctionDecl>(D)) |
||
| 57 | return S->isExternallyVisible() && !isa<CXXMethodDecl>(S); |
||
| 58 | return false; |
||
| 59 | } |
||
| 60 | |||
| 61 | static bool isHLSLBufferObj(const Decl *D) { |
||
| 62 | if (const auto *S = dyn_cast<HLSLBufferDecl>(D)) |
||
| 63 | return isa<HLSLBufferDecl>(S); |
||
| 64 | return false; |
||
| 65 | } |
||
| 66 | |||
| 67 | static bool isExternalGlobalVar(const Decl *D) { |
||
| 68 | if (const auto *S = dyn_cast<VarDecl>(D)) |
||
| 69 | return S->hasGlobalStorage() && |
||
| 70 | S->getStorageClass()!=StorageClass::SC_Static && |
||
| 71 | !S->isLocalExternDecl(); |
||
| 72 | return false; |
||
| 73 | } |
||
| 74 | |||
| 75 | static bool isObjCInstanceMethod(const Decl *D) { |
||
| 76 | if (const auto *S = dyn_cast<ObjCMethodDecl>(D)) |
||
| 77 | return S->isInstanceMethod(); |
||
| 78 | return false; |
||
| 79 | } |
||
| 80 | |||
| 81 | static bool isImplicitObjectParameter(const Decl *D) { |
||
| 82 | if (const auto *S = dyn_cast<FunctionDecl>(D)) |
||
| 83 | return static_cast<void>(S), false; |
||
| 84 | return false; |
||
| 85 | } |
||
| 86 | |||
| 87 | static bool isNonParmVar(const Decl *D) { |
||
| 88 | if (const auto *S = dyn_cast<VarDecl>(D)) |
||
| 89 | return S->getKind() != Decl::ParmVar; |
||
| 90 | return false; |
||
| 91 | } |
||
| 92 | |||
| 93 | static bool isNonBitField(const Decl *D) { |
||
| 94 | if (const auto *S = dyn_cast<FieldDecl>(D)) |
||
| 95 | return !S->isBitField(); |
||
| 96 | return false; |
||
| 97 | } |
||
| 98 | |||
| 99 | static bool isNonStaticCXXMethod(const Decl *D) { |
||
| 100 | if (const auto *S = dyn_cast<CXXMethodDecl>(D)) |
||
| 101 | return !S->isStatic(); |
||
| 102 | return false; |
||
| 103 | } |
||
| 104 | |||
| 105 | static bool isClassTmpl(const Decl *D) { |
||
| 106 | if (const auto *S = dyn_cast<CXXRecordDecl>(D)) |
||
| 107 | return S->getDescribedClassTemplate(); |
||
| 108 | return false; |
||
| 109 | } |
||
| 110 | |||
| 111 | static bool isNonStaticNonConstCXXMethod(const Decl *D) { |
||
| 112 | if (const auto *S = dyn_cast<CXXMethodDecl>(D)) |
||
| 113 | return !S->isStatic() && !S->isConst(); |
||
| 114 | return false; |
||
| 115 | } |
||
| 116 | |||
| 117 | static bool isNonLocalVar(const Decl *D) { |
||
| 118 | if (const auto *S = dyn_cast<VarDecl>(D)) |
||
| 119 | return !S->hasLocalStorage(); |
||
| 120 | return false; |
||
| 121 | } |
||
| 122 | |||
| 123 | static bool isFunctionTmpl(const Decl *D) { |
||
| 124 | if (const auto *S = dyn_cast<FunctionDecl>(D)) |
||
| 125 | return S->getTemplatedKind() == |
||
| 126 | FunctionDecl::TK_FunctionTemplate; |
||
| 127 | return false; |
||
| 128 | } |
||
| 129 | |||
| 130 | static bool isTLSVar(const Decl *D) { |
||
| 131 | if (const auto *S = dyn_cast<VarDecl>(D)) |
||
| 132 | return S->getTLSKind() != 0; |
||
| 133 | return false; |
||
| 134 | } |
||
| 135 | |||
| 136 | static constexpr ParsedAttrInfo::Spelling AArch64SVEPcsSpellings[] = { |
||
| 137 | {AttributeCommonInfo::AS_GNU, "aarch64_sve_pcs"}, |
||
| 138 | {AttributeCommonInfo::AS_CXX11, "clang::aarch64_sve_pcs"}, |
||
| 139 | {AttributeCommonInfo::AS_C2x, "clang::aarch64_sve_pcs"}, |
||
| 140 | }; |
||
| 141 | struct ParsedAttrInfoAArch64SVEPcs final : public ParsedAttrInfo { |
||
| 142 | constexpr ParsedAttrInfoAArch64SVEPcs() : ParsedAttrInfo( |
||
| 143 | /*AttrKind=*/ParsedAttr::AT_AArch64SVEPcs, |
||
| 144 | /*NumArgs=*/0, |
||
| 145 | /*OptArgs=*/0, |
||
| 146 | /*NumArgMembers=*/0, |
||
| 147 | /*HasCustomParsing=*/0, |
||
| 148 | /*AcceptsExprPack=*/0, |
||
| 149 | /*IsTargetSpecific=*/0, |
||
| 150 | /*IsType=*/1, |
||
| 151 | /*IsStmt=*/0, |
||
| 152 | /*IsKnownToGCC=*/0, |
||
| 153 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 154 | /*Spellings=*/AArch64SVEPcsSpellings, |
||
| 155 | /*ArgNames=*/{}) {} |
||
| 156 | bool isParamExpr(size_t N) const override { |
||
| 157 | return false; |
||
| 158 | } |
||
| 159 | |||
| 160 | static const ParsedAttrInfoAArch64SVEPcs Instance; |
||
| 161 | }; |
||
| 162 | const ParsedAttrInfoAArch64SVEPcs ParsedAttrInfoAArch64SVEPcs::Instance; |
||
| 163 | static constexpr ParsedAttrInfo::Spelling AArch64VectorPcsSpellings[] = { |
||
| 164 | {AttributeCommonInfo::AS_GNU, "aarch64_vector_pcs"}, |
||
| 165 | {AttributeCommonInfo::AS_CXX11, "clang::aarch64_vector_pcs"}, |
||
| 166 | {AttributeCommonInfo::AS_C2x, "clang::aarch64_vector_pcs"}, |
||
| 167 | }; |
||
| 168 | struct ParsedAttrInfoAArch64VectorPcs final : public ParsedAttrInfo { |
||
| 169 | constexpr ParsedAttrInfoAArch64VectorPcs() : ParsedAttrInfo( |
||
| 170 | /*AttrKind=*/ParsedAttr::AT_AArch64VectorPcs, |
||
| 171 | /*NumArgs=*/0, |
||
| 172 | /*OptArgs=*/0, |
||
| 173 | /*NumArgMembers=*/0, |
||
| 174 | /*HasCustomParsing=*/0, |
||
| 175 | /*AcceptsExprPack=*/0, |
||
| 176 | /*IsTargetSpecific=*/0, |
||
| 177 | /*IsType=*/1, |
||
| 178 | /*IsStmt=*/0, |
||
| 179 | /*IsKnownToGCC=*/0, |
||
| 180 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 181 | /*Spellings=*/AArch64VectorPcsSpellings, |
||
| 182 | /*ArgNames=*/{}) {} |
||
| 183 | bool isParamExpr(size_t N) const override { |
||
| 184 | return false; |
||
| 185 | } |
||
| 186 | |||
| 187 | static const ParsedAttrInfoAArch64VectorPcs Instance; |
||
| 188 | }; |
||
| 189 | const ParsedAttrInfoAArch64VectorPcs ParsedAttrInfoAArch64VectorPcs::Instance; |
||
| 190 | static constexpr ParsedAttrInfo::Spelling AMDGPUFlatWorkGroupSizeSpellings[] = { |
||
| 191 | {AttributeCommonInfo::AS_GNU, "amdgpu_flat_work_group_size"}, |
||
| 192 | {AttributeCommonInfo::AS_CXX11, "clang::amdgpu_flat_work_group_size"}, |
||
| 193 | }; |
||
| 194 | static constexpr const char *AMDGPUFlatWorkGroupSizeArgNames[] = { |
||
| 195 | "Min","Max",}; |
||
| 196 | struct ParsedAttrInfoAMDGPUFlatWorkGroupSize final : public ParsedAttrInfo { |
||
| 197 | constexpr ParsedAttrInfoAMDGPUFlatWorkGroupSize() : ParsedAttrInfo( |
||
| 198 | /*AttrKind=*/ParsedAttr::AT_AMDGPUFlatWorkGroupSize, |
||
| 199 | /*NumArgs=*/2, |
||
| 200 | /*OptArgs=*/0, |
||
| 201 | /*NumArgMembers=*/2, |
||
| 202 | /*HasCustomParsing=*/0, |
||
| 203 | /*AcceptsExprPack=*/0, |
||
| 204 | /*IsTargetSpecific=*/0, |
||
| 205 | /*IsType=*/0, |
||
| 206 | /*IsStmt=*/0, |
||
| 207 | /*IsKnownToGCC=*/0, |
||
| 208 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 209 | /*Spellings=*/AMDGPUFlatWorkGroupSizeSpellings, |
||
| 210 | /*ArgNames=*/AMDGPUFlatWorkGroupSizeArgNames) {} |
||
| 211 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 212 | if (!isa<FunctionDecl>(D)) { |
||
| 213 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 214 | << Attr << "kernel functions"; |
||
| 215 | return false; |
||
| 216 | } |
||
| 217 | return true; |
||
| 218 | } |
||
| 219 | |||
| 220 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 221 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 222 | << AL << St->getBeginLoc(); |
||
| 223 | return false; |
||
| 224 | } |
||
| 225 | |||
| 226 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 227 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 228 | } |
||
| 229 | |||
| 230 | bool isParamExpr(size_t N) const override { |
||
| 231 | return (N == 0) || (N == 1) || false; |
||
| 232 | } |
||
| 233 | |||
| 234 | static const ParsedAttrInfoAMDGPUFlatWorkGroupSize Instance; |
||
| 235 | }; |
||
| 236 | const ParsedAttrInfoAMDGPUFlatWorkGroupSize ParsedAttrInfoAMDGPUFlatWorkGroupSize::Instance; |
||
| 237 | static constexpr ParsedAttrInfo::Spelling AMDGPUKernelCallSpellings[] = { |
||
| 238 | {AttributeCommonInfo::AS_GNU, "amdgpu_kernel"}, |
||
| 239 | {AttributeCommonInfo::AS_CXX11, "clang::amdgpu_kernel"}, |
||
| 240 | {AttributeCommonInfo::AS_C2x, "clang::amdgpu_kernel"}, |
||
| 241 | }; |
||
| 242 | struct ParsedAttrInfoAMDGPUKernelCall final : public ParsedAttrInfo { |
||
| 243 | constexpr ParsedAttrInfoAMDGPUKernelCall() : ParsedAttrInfo( |
||
| 244 | /*AttrKind=*/ParsedAttr::AT_AMDGPUKernelCall, |
||
| 245 | /*NumArgs=*/0, |
||
| 246 | /*OptArgs=*/0, |
||
| 247 | /*NumArgMembers=*/0, |
||
| 248 | /*HasCustomParsing=*/0, |
||
| 249 | /*AcceptsExprPack=*/0, |
||
| 250 | /*IsTargetSpecific=*/0, |
||
| 251 | /*IsType=*/1, |
||
| 252 | /*IsStmt=*/0, |
||
| 253 | /*IsKnownToGCC=*/0, |
||
| 254 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 255 | /*Spellings=*/AMDGPUKernelCallSpellings, |
||
| 256 | /*ArgNames=*/{}) {} |
||
| 257 | bool isParamExpr(size_t N) const override { |
||
| 258 | return false; |
||
| 259 | } |
||
| 260 | |||
| 261 | static const ParsedAttrInfoAMDGPUKernelCall Instance; |
||
| 262 | }; |
||
| 263 | const ParsedAttrInfoAMDGPUKernelCall ParsedAttrInfoAMDGPUKernelCall::Instance; |
||
| 264 | static constexpr ParsedAttrInfo::Spelling AMDGPUNumSGPRSpellings[] = { |
||
| 265 | {AttributeCommonInfo::AS_GNU, "amdgpu_num_sgpr"}, |
||
| 266 | {AttributeCommonInfo::AS_CXX11, "clang::amdgpu_num_sgpr"}, |
||
| 267 | }; |
||
| 268 | static constexpr const char *AMDGPUNumSGPRArgNames[] = { |
||
| 269 | "NumSGPR",}; |
||
| 270 | struct ParsedAttrInfoAMDGPUNumSGPR final : public ParsedAttrInfo { |
||
| 271 | constexpr ParsedAttrInfoAMDGPUNumSGPR() : ParsedAttrInfo( |
||
| 272 | /*AttrKind=*/ParsedAttr::AT_AMDGPUNumSGPR, |
||
| 273 | /*NumArgs=*/1, |
||
| 274 | /*OptArgs=*/0, |
||
| 275 | /*NumArgMembers=*/1, |
||
| 276 | /*HasCustomParsing=*/0, |
||
| 277 | /*AcceptsExprPack=*/0, |
||
| 278 | /*IsTargetSpecific=*/0, |
||
| 279 | /*IsType=*/0, |
||
| 280 | /*IsStmt=*/0, |
||
| 281 | /*IsKnownToGCC=*/0, |
||
| 282 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 283 | /*Spellings=*/AMDGPUNumSGPRSpellings, |
||
| 284 | /*ArgNames=*/AMDGPUNumSGPRArgNames) {} |
||
| 285 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 286 | if (!isa<FunctionDecl>(D)) { |
||
| 287 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 288 | << Attr << "kernel functions"; |
||
| 289 | return false; |
||
| 290 | } |
||
| 291 | return true; |
||
| 292 | } |
||
| 293 | |||
| 294 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 295 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 296 | << AL << St->getBeginLoc(); |
||
| 297 | return false; |
||
| 298 | } |
||
| 299 | |||
| 300 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 301 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 302 | } |
||
| 303 | |||
| 304 | bool isParamExpr(size_t N) const override { |
||
| 305 | return false; |
||
| 306 | } |
||
| 307 | |||
| 308 | static const ParsedAttrInfoAMDGPUNumSGPR Instance; |
||
| 309 | }; |
||
| 310 | const ParsedAttrInfoAMDGPUNumSGPR ParsedAttrInfoAMDGPUNumSGPR::Instance; |
||
| 311 | static constexpr ParsedAttrInfo::Spelling AMDGPUNumVGPRSpellings[] = { |
||
| 312 | {AttributeCommonInfo::AS_GNU, "amdgpu_num_vgpr"}, |
||
| 313 | {AttributeCommonInfo::AS_CXX11, "clang::amdgpu_num_vgpr"}, |
||
| 314 | }; |
||
| 315 | static constexpr const char *AMDGPUNumVGPRArgNames[] = { |
||
| 316 | "NumVGPR",}; |
||
| 317 | struct ParsedAttrInfoAMDGPUNumVGPR final : public ParsedAttrInfo { |
||
| 318 | constexpr ParsedAttrInfoAMDGPUNumVGPR() : ParsedAttrInfo( |
||
| 319 | /*AttrKind=*/ParsedAttr::AT_AMDGPUNumVGPR, |
||
| 320 | /*NumArgs=*/1, |
||
| 321 | /*OptArgs=*/0, |
||
| 322 | /*NumArgMembers=*/1, |
||
| 323 | /*HasCustomParsing=*/0, |
||
| 324 | /*AcceptsExprPack=*/0, |
||
| 325 | /*IsTargetSpecific=*/0, |
||
| 326 | /*IsType=*/0, |
||
| 327 | /*IsStmt=*/0, |
||
| 328 | /*IsKnownToGCC=*/0, |
||
| 329 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 330 | /*Spellings=*/AMDGPUNumVGPRSpellings, |
||
| 331 | /*ArgNames=*/AMDGPUNumVGPRArgNames) {} |
||
| 332 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 333 | if (!isa<FunctionDecl>(D)) { |
||
| 334 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 335 | << Attr << "kernel functions"; |
||
| 336 | return false; |
||
| 337 | } |
||
| 338 | return true; |
||
| 339 | } |
||
| 340 | |||
| 341 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 342 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 343 | << AL << St->getBeginLoc(); |
||
| 344 | return false; |
||
| 345 | } |
||
| 346 | |||
| 347 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 348 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 349 | } |
||
| 350 | |||
| 351 | bool isParamExpr(size_t N) const override { |
||
| 352 | return false; |
||
| 353 | } |
||
| 354 | |||
| 355 | static const ParsedAttrInfoAMDGPUNumVGPR Instance; |
||
| 356 | }; |
||
| 357 | const ParsedAttrInfoAMDGPUNumVGPR ParsedAttrInfoAMDGPUNumVGPR::Instance; |
||
| 358 | static constexpr ParsedAttrInfo::Spelling AMDGPUWavesPerEUSpellings[] = { |
||
| 359 | {AttributeCommonInfo::AS_GNU, "amdgpu_waves_per_eu"}, |
||
| 360 | {AttributeCommonInfo::AS_CXX11, "clang::amdgpu_waves_per_eu"}, |
||
| 361 | }; |
||
| 362 | static constexpr const char *AMDGPUWavesPerEUArgNames[] = { |
||
| 363 | "Min","Max",}; |
||
| 364 | struct ParsedAttrInfoAMDGPUWavesPerEU final : public ParsedAttrInfo { |
||
| 365 | constexpr ParsedAttrInfoAMDGPUWavesPerEU() : ParsedAttrInfo( |
||
| 366 | /*AttrKind=*/ParsedAttr::AT_AMDGPUWavesPerEU, |
||
| 367 | /*NumArgs=*/1, |
||
| 368 | /*OptArgs=*/1, |
||
| 369 | /*NumArgMembers=*/2, |
||
| 370 | /*HasCustomParsing=*/0, |
||
| 371 | /*AcceptsExprPack=*/0, |
||
| 372 | /*IsTargetSpecific=*/0, |
||
| 373 | /*IsType=*/0, |
||
| 374 | /*IsStmt=*/0, |
||
| 375 | /*IsKnownToGCC=*/0, |
||
| 376 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 377 | /*Spellings=*/AMDGPUWavesPerEUSpellings, |
||
| 378 | /*ArgNames=*/AMDGPUWavesPerEUArgNames) {} |
||
| 379 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 380 | if (!isa<FunctionDecl>(D)) { |
||
| 381 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 382 | << Attr << "kernel functions"; |
||
| 383 | return false; |
||
| 384 | } |
||
| 385 | return true; |
||
| 386 | } |
||
| 387 | |||
| 388 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 389 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 390 | << AL << St->getBeginLoc(); |
||
| 391 | return false; |
||
| 392 | } |
||
| 393 | |||
| 394 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 395 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 396 | } |
||
| 397 | |||
| 398 | bool isParamExpr(size_t N) const override { |
||
| 399 | return (N == 0) || (N == 1) || false; |
||
| 400 | } |
||
| 401 | |||
| 402 | static const ParsedAttrInfoAMDGPUWavesPerEU Instance; |
||
| 403 | }; |
||
| 404 | const ParsedAttrInfoAMDGPUWavesPerEU ParsedAttrInfoAMDGPUWavesPerEU::Instance; |
||
| 405 | static constexpr ParsedAttrInfo::Spelling InterruptSpellings[] = { |
||
| 406 | {AttributeCommonInfo::AS_GNU, "interrupt"}, |
||
| 407 | {AttributeCommonInfo::AS_CXX11, "gnu::interrupt"}, |
||
| 408 | {AttributeCommonInfo::AS_C2x, "gnu::interrupt"}, |
||
| 409 | }; |
||
| 410 | static constexpr const char *InterruptArgNames[] = { |
||
| 411 | "Interrupt",}; |
||
| 412 | struct ParsedAttrInfoInterrupt final : public ParsedAttrInfo { |
||
| 413 | constexpr ParsedAttrInfoInterrupt() : ParsedAttrInfo( |
||
| 414 | /*AttrKind=*/ParsedAttr::AT_Interrupt, |
||
| 415 | /*NumArgs=*/0, |
||
| 416 | /*OptArgs=*/1, |
||
| 417 | /*NumArgMembers=*/1, |
||
| 418 | /*HasCustomParsing=*/1, |
||
| 419 | /*AcceptsExprPack=*/0, |
||
| 420 | /*IsTargetSpecific=*/1, |
||
| 421 | /*IsType=*/0, |
||
| 422 | /*IsStmt=*/0, |
||
| 423 | /*IsKnownToGCC=*/1, |
||
| 424 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 425 | /*Spellings=*/InterruptSpellings, |
||
| 426 | /*ArgNames=*/InterruptArgNames) {} |
||
| 427 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 428 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 429 | 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::m68k || 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); |
||
| 430 | } |
||
| 431 | |||
| 432 | bool isParamExpr(size_t N) const override { |
||
| 433 | return false; |
||
| 434 | } |
||
| 435 | |||
| 436 | static const ParsedAttrInfoInterrupt Instance; |
||
| 437 | }; |
||
| 438 | const ParsedAttrInfoInterrupt ParsedAttrInfoInterrupt::Instance; |
||
| 439 | static constexpr ParsedAttrInfo::Spelling AVRSignalSpellings[] = { |
||
| 440 | {AttributeCommonInfo::AS_GNU, "signal"}, |
||
| 441 | {AttributeCommonInfo::AS_CXX11, "gnu::signal"}, |
||
| 442 | {AttributeCommonInfo::AS_C2x, "gnu::signal"}, |
||
| 443 | }; |
||
| 444 | struct ParsedAttrInfoAVRSignal final : public ParsedAttrInfo { |
||
| 445 | constexpr ParsedAttrInfoAVRSignal() : ParsedAttrInfo( |
||
| 446 | /*AttrKind=*/ParsedAttr::AT_AVRSignal, |
||
| 447 | /*NumArgs=*/0, |
||
| 448 | /*OptArgs=*/0, |
||
| 449 | /*NumArgMembers=*/0, |
||
| 450 | /*HasCustomParsing=*/0, |
||
| 451 | /*AcceptsExprPack=*/0, |
||
| 452 | /*IsTargetSpecific=*/1, |
||
| 453 | /*IsType=*/0, |
||
| 454 | /*IsStmt=*/0, |
||
| 455 | /*IsKnownToGCC=*/1, |
||
| 456 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 457 | /*Spellings=*/AVRSignalSpellings, |
||
| 458 | /*ArgNames=*/{}) {} |
||
| 459 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 460 | if (!isa<FunctionDecl>(D)) { |
||
| 461 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 462 | << Attr << "functions"; |
||
| 463 | return false; |
||
| 464 | } |
||
| 465 | return true; |
||
| 466 | } |
||
| 467 | |||
| 468 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 469 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 470 | << AL << St->getBeginLoc(); |
||
| 471 | return false; |
||
| 472 | } |
||
| 473 | |||
| 474 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 475 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 476 | return true && (T.getArch() == llvm::Triple::avr); |
||
| 477 | } |
||
| 478 | |||
| 479 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 480 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 481 | } |
||
| 482 | |||
| 483 | bool isParamExpr(size_t N) const override { |
||
| 484 | return false; |
||
| 485 | } |
||
| 486 | |||
| 487 | static const ParsedAttrInfoAVRSignal Instance; |
||
| 488 | }; |
||
| 489 | const ParsedAttrInfoAVRSignal ParsedAttrInfoAVRSignal::Instance; |
||
| 490 | static constexpr ParsedAttrInfo::Spelling AbiTagSpellings[] = { |
||
| 491 | {AttributeCommonInfo::AS_GNU, "abi_tag"}, |
||
| 492 | {AttributeCommonInfo::AS_CXX11, "gnu::abi_tag"}, |
||
| 493 | }; |
||
| 494 | static constexpr const char *AbiTagArgNames[] = { |
||
| 495 | "Tags...",}; |
||
| 496 | struct ParsedAttrInfoAbiTag final : public ParsedAttrInfo { |
||
| 497 | constexpr ParsedAttrInfoAbiTag() : ParsedAttrInfo( |
||
| 498 | /*AttrKind=*/ParsedAttr::AT_AbiTag, |
||
| 499 | /*NumArgs=*/0, |
||
| 500 | /*OptArgs=*/15, |
||
| 501 | /*NumArgMembers=*/1, |
||
| 502 | /*HasCustomParsing=*/0, |
||
| 503 | /*AcceptsExprPack=*/0, |
||
| 504 | /*IsTargetSpecific=*/0, |
||
| 505 | /*IsType=*/0, |
||
| 506 | /*IsStmt=*/0, |
||
| 507 | /*IsKnownToGCC=*/1, |
||
| 508 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 509 | /*Spellings=*/AbiTagSpellings, |
||
| 510 | /*ArgNames=*/AbiTagArgNames) {} |
||
| 511 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 512 | if (!isStruct(D) && !isa<VarDecl>(D) && !isa<FunctionDecl>(D) && !isa<NamespaceDecl>(D)) { |
||
| 513 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 514 | << Attr << "structs, variables, functions, and namespaces"; |
||
| 515 | return false; |
||
| 516 | } |
||
| 517 | return true; |
||
| 518 | } |
||
| 519 | |||
| 520 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 521 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 522 | << AL << St->getBeginLoc(); |
||
| 523 | return false; |
||
| 524 | } |
||
| 525 | |||
| 526 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 527 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record_not_is_union, /*IsSupported=*/true)); |
||
| 528 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
||
| 529 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 530 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_namespace, /*IsSupported=*/LangOpts.CPlusPlus)); |
||
| 531 | } |
||
| 532 | |||
| 533 | bool isParamExpr(size_t N) const override { |
||
| 534 | return false; |
||
| 535 | } |
||
| 536 | |||
| 537 | static const ParsedAttrInfoAbiTag Instance; |
||
| 538 | }; |
||
| 539 | const ParsedAttrInfoAbiTag ParsedAttrInfoAbiTag::Instance; |
||
| 540 | static constexpr ParsedAttrInfo::Spelling AcquireCapabilitySpellings[] = { |
||
| 541 | {AttributeCommonInfo::AS_GNU, "acquire_capability"}, |
||
| 542 | {AttributeCommonInfo::AS_CXX11, "clang::acquire_capability"}, |
||
| 543 | {AttributeCommonInfo::AS_GNU, "acquire_shared_capability"}, |
||
| 544 | {AttributeCommonInfo::AS_CXX11, "clang::acquire_shared_capability"}, |
||
| 545 | {AttributeCommonInfo::AS_GNU, "exclusive_lock_function"}, |
||
| 546 | {AttributeCommonInfo::AS_GNU, "shared_lock_function"}, |
||
| 547 | }; |
||
| 548 | static constexpr const char *AcquireCapabilityArgNames[] = { |
||
| 549 | "Args...",}; |
||
| 550 | struct ParsedAttrInfoAcquireCapability final : public ParsedAttrInfo { |
||
| 551 | constexpr ParsedAttrInfoAcquireCapability() : ParsedAttrInfo( |
||
| 552 | /*AttrKind=*/ParsedAttr::AT_AcquireCapability, |
||
| 553 | /*NumArgs=*/0, |
||
| 554 | /*OptArgs=*/15, |
||
| 555 | /*NumArgMembers=*/1, |
||
| 556 | /*HasCustomParsing=*/0, |
||
| 557 | /*AcceptsExprPack=*/0, |
||
| 558 | /*IsTargetSpecific=*/0, |
||
| 559 | /*IsType=*/0, |
||
| 560 | /*IsStmt=*/0, |
||
| 561 | /*IsKnownToGCC=*/0, |
||
| 562 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 563 | /*Spellings=*/AcquireCapabilitySpellings, |
||
| 564 | /*ArgNames=*/AcquireCapabilityArgNames) {} |
||
| 565 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 566 | if (!isa<FunctionDecl>(D)) { |
||
| 567 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 568 | << Attr << "functions"; |
||
| 569 | return false; |
||
| 570 | } |
||
| 571 | return true; |
||
| 572 | } |
||
| 573 | |||
| 574 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 575 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 576 | << AL << St->getBeginLoc(); |
||
| 577 | return false; |
||
| 578 | } |
||
| 579 | |||
| 580 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 581 | enum Spelling { |
||
| 582 | GNU_acquire_capability = 0, |
||
| 583 | CXX11_clang_acquire_capability = 1, |
||
| 584 | GNU_acquire_shared_capability = 2, |
||
| 585 | CXX11_clang_acquire_shared_capability = 3, |
||
| 586 | GNU_exclusive_lock_function = 4, |
||
| 587 | GNU_shared_lock_function = 5, |
||
| 588 | SpellingNotCalculated = 15 |
||
| 589 | |||
| 590 | }; |
||
| 591 | |||
| 592 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 593 | switch (Idx) { |
||
| 594 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 595 | case 0: return GNU_acquire_capability; |
||
| 596 | case 1: return CXX11_clang_acquire_capability; |
||
| 597 | case 2: return GNU_acquire_shared_capability; |
||
| 598 | case 3: return CXX11_clang_acquire_shared_capability; |
||
| 599 | case 4: return GNU_exclusive_lock_function; |
||
| 600 | case 5: return GNU_shared_lock_function; |
||
| 601 | } |
||
| 602 | } |
||
| 603 | |||
| 604 | bool isParamExpr(size_t N) const override { |
||
| 605 | return (N == 0) || false; |
||
| 606 | } |
||
| 607 | |||
| 608 | static const ParsedAttrInfoAcquireCapability Instance; |
||
| 609 | }; |
||
| 610 | const ParsedAttrInfoAcquireCapability ParsedAttrInfoAcquireCapability::Instance; |
||
| 611 | static constexpr ParsedAttrInfo::Spelling AcquireHandleSpellings[] = { |
||
| 612 | {AttributeCommonInfo::AS_GNU, "acquire_handle"}, |
||
| 613 | {AttributeCommonInfo::AS_CXX11, "clang::acquire_handle"}, |
||
| 614 | {AttributeCommonInfo::AS_C2x, "clang::acquire_handle"}, |
||
| 615 | }; |
||
| 616 | static constexpr const char *AcquireHandleArgNames[] = { |
||
| 617 | "HandleType",}; |
||
| 618 | struct ParsedAttrInfoAcquireHandle final : public ParsedAttrInfo { |
||
| 619 | constexpr ParsedAttrInfoAcquireHandle() : ParsedAttrInfo( |
||
| 620 | /*AttrKind=*/ParsedAttr::AT_AcquireHandle, |
||
| 621 | /*NumArgs=*/1, |
||
| 622 | /*OptArgs=*/0, |
||
| 623 | /*NumArgMembers=*/1, |
||
| 624 | /*HasCustomParsing=*/0, |
||
| 625 | /*AcceptsExprPack=*/0, |
||
| 626 | /*IsTargetSpecific=*/0, |
||
| 627 | /*IsType=*/1, |
||
| 628 | /*IsStmt=*/0, |
||
| 629 | /*IsKnownToGCC=*/0, |
||
| 630 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 631 | /*Spellings=*/AcquireHandleSpellings, |
||
| 632 | /*ArgNames=*/AcquireHandleArgNames) {} |
||
| 633 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 634 | if (!isa<FunctionDecl>(D) && !isa<TypedefNameDecl>(D) && !isa<ParmVarDecl>(D)) { |
||
| 635 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 636 | << Attr << "functions, typedefs, and parameters"; |
||
| 637 | return false; |
||
| 638 | } |
||
| 639 | return true; |
||
| 640 | } |
||
| 641 | |||
| 642 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 643 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 644 | << AL << St->getBeginLoc(); |
||
| 645 | return false; |
||
| 646 | } |
||
| 647 | |||
| 648 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 649 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 650 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true)); |
||
| 651 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
||
| 652 | } |
||
| 653 | |||
| 654 | bool isParamExpr(size_t N) const override { |
||
| 655 | return false; |
||
| 656 | } |
||
| 657 | |||
| 658 | static const ParsedAttrInfoAcquireHandle Instance; |
||
| 659 | }; |
||
| 660 | const ParsedAttrInfoAcquireHandle ParsedAttrInfoAcquireHandle::Instance; |
||
| 661 | static constexpr ParsedAttrInfo::Spelling AcquiredAfterSpellings[] = { |
||
| 662 | {AttributeCommonInfo::AS_GNU, "acquired_after"}, |
||
| 663 | }; |
||
| 664 | static constexpr const char *AcquiredAfterArgNames[] = { |
||
| 665 | "Args...",}; |
||
| 666 | struct ParsedAttrInfoAcquiredAfter final : public ParsedAttrInfo { |
||
| 667 | constexpr ParsedAttrInfoAcquiredAfter() : ParsedAttrInfo( |
||
| 668 | /*AttrKind=*/ParsedAttr::AT_AcquiredAfter, |
||
| 669 | /*NumArgs=*/0, |
||
| 670 | /*OptArgs=*/15, |
||
| 671 | /*NumArgMembers=*/1, |
||
| 672 | /*HasCustomParsing=*/0, |
||
| 673 | /*AcceptsExprPack=*/0, |
||
| 674 | /*IsTargetSpecific=*/0, |
||
| 675 | /*IsType=*/0, |
||
| 676 | /*IsStmt=*/0, |
||
| 677 | /*IsKnownToGCC=*/0, |
||
| 678 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 679 | /*Spellings=*/AcquiredAfterSpellings, |
||
| 680 | /*ArgNames=*/AcquiredAfterArgNames) {} |
||
| 681 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 682 | if (!isa<FieldDecl>(D) && !isSharedVar(D)) { |
||
| 683 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 684 | << Attr << "non-static data members and global variables"; |
||
| 685 | return false; |
||
| 686 | } |
||
| 687 | return true; |
||
| 688 | } |
||
| 689 | |||
| 690 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 691 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 692 | << AL << St->getBeginLoc(); |
||
| 693 | return false; |
||
| 694 | } |
||
| 695 | |||
| 696 | bool isParamExpr(size_t N) const override { |
||
| 697 | return (N == 0) || false; |
||
| 698 | } |
||
| 699 | |||
| 700 | static const ParsedAttrInfoAcquiredAfter Instance; |
||
| 701 | }; |
||
| 702 | const ParsedAttrInfoAcquiredAfter ParsedAttrInfoAcquiredAfter::Instance; |
||
| 703 | static constexpr ParsedAttrInfo::Spelling AcquiredBeforeSpellings[] = { |
||
| 704 | {AttributeCommonInfo::AS_GNU, "acquired_before"}, |
||
| 705 | }; |
||
| 706 | static constexpr const char *AcquiredBeforeArgNames[] = { |
||
| 707 | "Args...",}; |
||
| 708 | struct ParsedAttrInfoAcquiredBefore final : public ParsedAttrInfo { |
||
| 709 | constexpr ParsedAttrInfoAcquiredBefore() : ParsedAttrInfo( |
||
| 710 | /*AttrKind=*/ParsedAttr::AT_AcquiredBefore, |
||
| 711 | /*NumArgs=*/0, |
||
| 712 | /*OptArgs=*/15, |
||
| 713 | /*NumArgMembers=*/1, |
||
| 714 | /*HasCustomParsing=*/0, |
||
| 715 | /*AcceptsExprPack=*/0, |
||
| 716 | /*IsTargetSpecific=*/0, |
||
| 717 | /*IsType=*/0, |
||
| 718 | /*IsStmt=*/0, |
||
| 719 | /*IsKnownToGCC=*/0, |
||
| 720 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 721 | /*Spellings=*/AcquiredBeforeSpellings, |
||
| 722 | /*ArgNames=*/AcquiredBeforeArgNames) {} |
||
| 723 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 724 | if (!isa<FieldDecl>(D) && !isSharedVar(D)) { |
||
| 725 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 726 | << Attr << "non-static data members and global variables"; |
||
| 727 | return false; |
||
| 728 | } |
||
| 729 | return true; |
||
| 730 | } |
||
| 731 | |||
| 732 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 733 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 734 | << AL << St->getBeginLoc(); |
||
| 735 | return false; |
||
| 736 | } |
||
| 737 | |||
| 738 | bool isParamExpr(size_t N) const override { |
||
| 739 | return (N == 0) || false; |
||
| 740 | } |
||
| 741 | |||
| 742 | static const ParsedAttrInfoAcquiredBefore Instance; |
||
| 743 | }; |
||
| 744 | const ParsedAttrInfoAcquiredBefore ParsedAttrInfoAcquiredBefore::Instance; |
||
| 745 | static constexpr ParsedAttrInfo::Spelling AddressSpaceSpellings[] = { |
||
| 746 | {AttributeCommonInfo::AS_GNU, "address_space"}, |
||
| 747 | {AttributeCommonInfo::AS_CXX11, "clang::address_space"}, |
||
| 748 | {AttributeCommonInfo::AS_C2x, "clang::address_space"}, |
||
| 749 | }; |
||
| 750 | static constexpr const char *AddressSpaceArgNames[] = { |
||
| 751 | "AddressSpace",}; |
||
| 752 | struct ParsedAttrInfoAddressSpace final : public ParsedAttrInfo { |
||
| 753 | constexpr ParsedAttrInfoAddressSpace() : ParsedAttrInfo( |
||
| 754 | /*AttrKind=*/ParsedAttr::AT_AddressSpace, |
||
| 755 | /*NumArgs=*/1, |
||
| 756 | /*OptArgs=*/0, |
||
| 757 | /*NumArgMembers=*/1, |
||
| 758 | /*HasCustomParsing=*/0, |
||
| 759 | /*AcceptsExprPack=*/0, |
||
| 760 | /*IsTargetSpecific=*/0, |
||
| 761 | /*IsType=*/1, |
||
| 762 | /*IsStmt=*/0, |
||
| 763 | /*IsKnownToGCC=*/0, |
||
| 764 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 765 | /*Spellings=*/AddressSpaceSpellings, |
||
| 766 | /*ArgNames=*/AddressSpaceArgNames) {} |
||
| 767 | bool isParamExpr(size_t N) const override { |
||
| 768 | return false; |
||
| 769 | } |
||
| 770 | |||
| 771 | static const ParsedAttrInfoAddressSpace Instance; |
||
| 772 | }; |
||
| 773 | const ParsedAttrInfoAddressSpace ParsedAttrInfoAddressSpace::Instance; |
||
| 774 | static constexpr ParsedAttrInfo::Spelling AliasSpellings[] = { |
||
| 775 | {AttributeCommonInfo::AS_GNU, "alias"}, |
||
| 776 | {AttributeCommonInfo::AS_CXX11, "gnu::alias"}, |
||
| 777 | {AttributeCommonInfo::AS_C2x, "gnu::alias"}, |
||
| 778 | }; |
||
| 779 | static constexpr const char *AliasArgNames[] = { |
||
| 780 | "Aliasee",}; |
||
| 781 | struct ParsedAttrInfoAlias final : public ParsedAttrInfo { |
||
| 782 | constexpr ParsedAttrInfoAlias() : ParsedAttrInfo( |
||
| 783 | /*AttrKind=*/ParsedAttr::AT_Alias, |
||
| 784 | /*NumArgs=*/1, |
||
| 785 | /*OptArgs=*/0, |
||
| 786 | /*NumArgMembers=*/1, |
||
| 787 | /*HasCustomParsing=*/0, |
||
| 788 | /*AcceptsExprPack=*/0, |
||
| 789 | /*IsTargetSpecific=*/0, |
||
| 790 | /*IsType=*/0, |
||
| 791 | /*IsStmt=*/0, |
||
| 792 | /*IsKnownToGCC=*/1, |
||
| 793 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 794 | /*Spellings=*/AliasSpellings, |
||
| 795 | /*ArgNames=*/AliasArgNames) {} |
||
| 796 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 797 | if (!isa<FunctionDecl>(D) && !isGlobalVar(D)) { |
||
| 798 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 799 | << Attr << "functions and global variables"; |
||
| 800 | return false; |
||
| 801 | } |
||
| 802 | return true; |
||
| 803 | } |
||
| 804 | |||
| 805 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 806 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 807 | << AL << St->getBeginLoc(); |
||
| 808 | return false; |
||
| 809 | } |
||
| 810 | |||
| 811 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 812 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 813 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_global, /*IsSupported=*/true)); |
||
| 814 | } |
||
| 815 | |||
| 816 | bool isParamExpr(size_t N) const override { |
||
| 817 | return false; |
||
| 818 | } |
||
| 819 | |||
| 820 | static const ParsedAttrInfoAlias Instance; |
||
| 821 | }; |
||
| 822 | const ParsedAttrInfoAlias ParsedAttrInfoAlias::Instance; |
||
| 823 | static constexpr ParsedAttrInfo::Spelling AlignValueSpellings[] = { |
||
| 824 | {AttributeCommonInfo::AS_GNU, "align_value"}, |
||
| 825 | }; |
||
| 826 | static constexpr const char *AlignValueArgNames[] = { |
||
| 827 | "Alignment",}; |
||
| 828 | struct ParsedAttrInfoAlignValue final : public ParsedAttrInfo { |
||
| 829 | constexpr ParsedAttrInfoAlignValue() : ParsedAttrInfo( |
||
| 830 | /*AttrKind=*/ParsedAttr::AT_AlignValue, |
||
| 831 | /*NumArgs=*/1, |
||
| 832 | /*OptArgs=*/0, |
||
| 833 | /*NumArgMembers=*/1, |
||
| 834 | /*HasCustomParsing=*/0, |
||
| 835 | /*AcceptsExprPack=*/0, |
||
| 836 | /*IsTargetSpecific=*/0, |
||
| 837 | /*IsType=*/0, |
||
| 838 | /*IsStmt=*/0, |
||
| 839 | /*IsKnownToGCC=*/0, |
||
| 840 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 841 | /*Spellings=*/AlignValueSpellings, |
||
| 842 | /*ArgNames=*/AlignValueArgNames) {} |
||
| 843 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 844 | if (!isa<VarDecl>(D) && !isa<TypedefNameDecl>(D)) { |
||
| 845 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 846 | << Attr << "variables and typedefs"; |
||
| 847 | return false; |
||
| 848 | } |
||
| 849 | return true; |
||
| 850 | } |
||
| 851 | |||
| 852 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 853 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 854 | << AL << St->getBeginLoc(); |
||
| 855 | return false; |
||
| 856 | } |
||
| 857 | |||
| 858 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 859 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
||
| 860 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true)); |
||
| 861 | } |
||
| 862 | |||
| 863 | bool isParamExpr(size_t N) const override { |
||
| 864 | return (N == 0) || false; |
||
| 865 | } |
||
| 866 | |||
| 867 | static const ParsedAttrInfoAlignValue Instance; |
||
| 868 | }; |
||
| 869 | const ParsedAttrInfoAlignValue ParsedAttrInfoAlignValue::Instance; |
||
| 870 | static constexpr ParsedAttrInfo::Spelling AlignedSpellings[] = { |
||
| 871 | {AttributeCommonInfo::AS_GNU, "aligned"}, |
||
| 872 | {AttributeCommonInfo::AS_CXX11, "gnu::aligned"}, |
||
| 873 | {AttributeCommonInfo::AS_C2x, "gnu::aligned"}, |
||
| 874 | {AttributeCommonInfo::AS_Declspec, "align"}, |
||
| 875 | {AttributeCommonInfo::AS_Keyword, "alignas"}, |
||
| 876 | {AttributeCommonInfo::AS_Keyword, "_Alignas"}, |
||
| 877 | }; |
||
| 878 | static constexpr const char *AlignedArgNames[] = { |
||
| 879 | "Alignment",}; |
||
| 880 | struct ParsedAttrInfoAligned final : public ParsedAttrInfo { |
||
| 881 | constexpr ParsedAttrInfoAligned() : ParsedAttrInfo( |
||
| 882 | /*AttrKind=*/ParsedAttr::AT_Aligned, |
||
| 883 | /*NumArgs=*/0, |
||
| 884 | /*OptArgs=*/1, |
||
| 885 | /*NumArgMembers=*/1, |
||
| 886 | /*HasCustomParsing=*/0, |
||
| 887 | /*AcceptsExprPack=*/0, |
||
| 888 | /*IsTargetSpecific=*/0, |
||
| 889 | /*IsType=*/0, |
||
| 890 | /*IsStmt=*/0, |
||
| 891 | /*IsKnownToGCC=*/1, |
||
| 892 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 893 | /*Spellings=*/AlignedSpellings, |
||
| 894 | /*ArgNames=*/AlignedArgNames) {} |
||
| 895 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 896 | enum Spelling { |
||
| 897 | GNU_aligned = 0, |
||
| 898 | CXX11_gnu_aligned = 1, |
||
| 899 | C2x_gnu_aligned = 2, |
||
| 900 | Declspec_align = 3, |
||
| 901 | Keyword_alignas = 4, |
||
| 902 | Keyword_Alignas = 5, |
||
| 903 | SpellingNotCalculated = 15 |
||
| 904 | |||
| 905 | }; |
||
| 906 | |||
| 907 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 908 | switch (Idx) { |
||
| 909 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 910 | case 0: return GNU_aligned; |
||
| 911 | case 1: return CXX11_gnu_aligned; |
||
| 912 | case 2: return C2x_gnu_aligned; |
||
| 913 | case 3: return Declspec_align; |
||
| 914 | case 4: return Keyword_alignas; |
||
| 915 | case 5: return Keyword_Alignas; |
||
| 916 | } |
||
| 917 | } |
||
| 918 | |||
| 919 | bool isParamExpr(size_t N) const override { |
||
| 920 | return false; |
||
| 921 | } |
||
| 922 | |||
| 923 | static const ParsedAttrInfoAligned Instance; |
||
| 924 | }; |
||
| 925 | const ParsedAttrInfoAligned ParsedAttrInfoAligned::Instance; |
||
| 926 | static constexpr ParsedAttrInfo::Spelling AllocAlignSpellings[] = { |
||
| 927 | {AttributeCommonInfo::AS_GNU, "alloc_align"}, |
||
| 928 | {AttributeCommonInfo::AS_CXX11, "gnu::alloc_align"}, |
||
| 929 | {AttributeCommonInfo::AS_C2x, "gnu::alloc_align"}, |
||
| 930 | }; |
||
| 931 | static constexpr const char *AllocAlignArgNames[] = { |
||
| 932 | "ParamIndex",}; |
||
| 933 | struct ParsedAttrInfoAllocAlign final : public ParsedAttrInfo { |
||
| 934 | constexpr ParsedAttrInfoAllocAlign() : ParsedAttrInfo( |
||
| 935 | /*AttrKind=*/ParsedAttr::AT_AllocAlign, |
||
| 936 | /*NumArgs=*/1, |
||
| 937 | /*OptArgs=*/0, |
||
| 938 | /*NumArgMembers=*/1, |
||
| 939 | /*HasCustomParsing=*/0, |
||
| 940 | /*AcceptsExprPack=*/0, |
||
| 941 | /*IsTargetSpecific=*/0, |
||
| 942 | /*IsType=*/0, |
||
| 943 | /*IsStmt=*/0, |
||
| 944 | /*IsKnownToGCC=*/1, |
||
| 945 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 946 | /*Spellings=*/AllocAlignSpellings, |
||
| 947 | /*ArgNames=*/AllocAlignArgNames) {} |
||
| 948 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 949 | if (!isHasFunctionProto(D)) { |
||
| 950 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 951 | << Attr << "non-K&R-style functions"; |
||
| 952 | return false; |
||
| 953 | } |
||
| 954 | return true; |
||
| 955 | } |
||
| 956 | |||
| 957 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 958 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 959 | << AL << St->getBeginLoc(); |
||
| 960 | return false; |
||
| 961 | } |
||
| 962 | |||
| 963 | bool isParamExpr(size_t N) const override { |
||
| 964 | return false; |
||
| 965 | } |
||
| 966 | |||
| 967 | static const ParsedAttrInfoAllocAlign Instance; |
||
| 968 | }; |
||
| 969 | const ParsedAttrInfoAllocAlign ParsedAttrInfoAllocAlign::Instance; |
||
| 970 | static constexpr ParsedAttrInfo::Spelling AllocSizeSpellings[] = { |
||
| 971 | {AttributeCommonInfo::AS_GNU, "alloc_size"}, |
||
| 972 | {AttributeCommonInfo::AS_CXX11, "gnu::alloc_size"}, |
||
| 973 | {AttributeCommonInfo::AS_C2x, "gnu::alloc_size"}, |
||
| 974 | }; |
||
| 975 | static constexpr const char *AllocSizeArgNames[] = { |
||
| 976 | "ElemSizeParam","NumElemsParam",}; |
||
| 977 | struct ParsedAttrInfoAllocSize final : public ParsedAttrInfo { |
||
| 978 | constexpr ParsedAttrInfoAllocSize() : ParsedAttrInfo( |
||
| 979 | /*AttrKind=*/ParsedAttr::AT_AllocSize, |
||
| 980 | /*NumArgs=*/1, |
||
| 981 | /*OptArgs=*/1, |
||
| 982 | /*NumArgMembers=*/2, |
||
| 983 | /*HasCustomParsing=*/0, |
||
| 984 | /*AcceptsExprPack=*/0, |
||
| 985 | /*IsTargetSpecific=*/0, |
||
| 986 | /*IsType=*/0, |
||
| 987 | /*IsStmt=*/0, |
||
| 988 | /*IsKnownToGCC=*/1, |
||
| 989 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 990 | /*Spellings=*/AllocSizeSpellings, |
||
| 991 | /*ArgNames=*/AllocSizeArgNames) {} |
||
| 992 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 993 | if (!isHasFunctionProto(D)) { |
||
| 994 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 995 | << Attr << "non-K&R-style functions"; |
||
| 996 | return false; |
||
| 997 | } |
||
| 998 | return true; |
||
| 999 | } |
||
| 1000 | |||
| 1001 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 1002 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 1003 | << AL << St->getBeginLoc(); |
||
| 1004 | return false; |
||
| 1005 | } |
||
| 1006 | |||
| 1007 | bool isParamExpr(size_t N) const override { |
||
| 1008 | return false; |
||
| 1009 | } |
||
| 1010 | |||
| 1011 | static const ParsedAttrInfoAllocSize Instance; |
||
| 1012 | }; |
||
| 1013 | const ParsedAttrInfoAllocSize ParsedAttrInfoAllocSize::Instance; |
||
| 1014 | static constexpr ParsedAttrInfo::Spelling AlwaysDestroySpellings[] = { |
||
| 1015 | {AttributeCommonInfo::AS_GNU, "always_destroy"}, |
||
| 1016 | {AttributeCommonInfo::AS_CXX11, "clang::always_destroy"}, |
||
| 1017 | }; |
||
| 1018 | struct ParsedAttrInfoAlwaysDestroy final : public ParsedAttrInfo { |
||
| 1019 | constexpr ParsedAttrInfoAlwaysDestroy() : ParsedAttrInfo( |
||
| 1020 | /*AttrKind=*/ParsedAttr::AT_AlwaysDestroy, |
||
| 1021 | /*NumArgs=*/0, |
||
| 1022 | /*OptArgs=*/0, |
||
| 1023 | /*NumArgMembers=*/0, |
||
| 1024 | /*HasCustomParsing=*/0, |
||
| 1025 | /*AcceptsExprPack=*/0, |
||
| 1026 | /*IsTargetSpecific=*/0, |
||
| 1027 | /*IsType=*/0, |
||
| 1028 | /*IsStmt=*/0, |
||
| 1029 | /*IsKnownToGCC=*/0, |
||
| 1030 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 1031 | /*Spellings=*/AlwaysDestroySpellings, |
||
| 1032 | /*ArgNames=*/{}) {} |
||
| 1033 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 1034 | if (!isa<VarDecl>(D)) { |
||
| 1035 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 1036 | << Attr << "variables"; |
||
| 1037 | return false; |
||
| 1038 | } |
||
| 1039 | return true; |
||
| 1040 | } |
||
| 1041 | |||
| 1042 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 1043 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 1044 | << AL << St->getBeginLoc(); |
||
| 1045 | return false; |
||
| 1046 | } |
||
| 1047 | |||
| 1048 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 1049 | |||
| 1050 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 1051 | if (const auto *A = D->getAttr<NoDestroyAttr>()) { |
||
| 1052 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 1053 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 1054 | return false; |
||
| 1055 | } |
||
| 1056 | return true; |
||
| 1057 | } |
||
| 1058 | |||
| 1059 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 1060 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
||
| 1061 | } |
||
| 1062 | |||
| 1063 | bool isParamExpr(size_t N) const override { |
||
| 1064 | return false; |
||
| 1065 | } |
||
| 1066 | |||
| 1067 | static const ParsedAttrInfoAlwaysDestroy Instance; |
||
| 1068 | }; |
||
| 1069 | const ParsedAttrInfoAlwaysDestroy ParsedAttrInfoAlwaysDestroy::Instance; |
||
| 1070 | static constexpr ParsedAttrInfo::Spelling AlwaysInlineSpellings[] = { |
||
| 1071 | {AttributeCommonInfo::AS_GNU, "always_inline"}, |
||
| 1072 | {AttributeCommonInfo::AS_CXX11, "gnu::always_inline"}, |
||
| 1073 | {AttributeCommonInfo::AS_C2x, "gnu::always_inline"}, |
||
| 1074 | {AttributeCommonInfo::AS_CXX11, "clang::always_inline"}, |
||
| 1075 | {AttributeCommonInfo::AS_C2x, "clang::always_inline"}, |
||
| 1076 | {AttributeCommonInfo::AS_Keyword, "__forceinline"}, |
||
| 1077 | }; |
||
| 1078 | struct ParsedAttrInfoAlwaysInline final : public ParsedAttrInfo { |
||
| 1079 | constexpr ParsedAttrInfoAlwaysInline() : ParsedAttrInfo( |
||
| 1080 | /*AttrKind=*/ParsedAttr::AT_AlwaysInline, |
||
| 1081 | /*NumArgs=*/0, |
||
| 1082 | /*OptArgs=*/0, |
||
| 1083 | /*NumArgMembers=*/0, |
||
| 1084 | /*HasCustomParsing=*/0, |
||
| 1085 | /*AcceptsExprPack=*/0, |
||
| 1086 | /*IsTargetSpecific=*/0, |
||
| 1087 | /*IsType=*/0, |
||
| 1088 | /*IsStmt=*/1, |
||
| 1089 | /*IsKnownToGCC=*/1, |
||
| 1090 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 1091 | /*Spellings=*/AlwaysInlineSpellings, |
||
| 1092 | /*ArgNames=*/{}) {} |
||
| 1093 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 1094 | if (!isa<FunctionDecl>(D)) { |
||
| 1095 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 1096 | << Attr << "functions and statements"; |
||
| 1097 | return false; |
||
| 1098 | } |
||
| 1099 | return true; |
||
| 1100 | } |
||
| 1101 | |||
| 1102 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &Attr, const Stmt *St) const override { |
||
| 1103 | if (!isa<Stmt>(St)) { |
||
| 1104 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 1105 | << Attr << "functions and statements"; |
||
| 1106 | return false; |
||
| 1107 | } |
||
| 1108 | return true; |
||
| 1109 | } |
||
| 1110 | |||
| 1111 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 1112 | |||
| 1113 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 1114 | if (const auto *A = D->getAttr<NotTailCalledAttr>()) { |
||
| 1115 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 1116 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 1117 | return false; |
||
| 1118 | } |
||
| 1119 | return true; |
||
| 1120 | } |
||
| 1121 | |||
| 1122 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 1123 | enum Spelling { |
||
| 1124 | GNU_always_inline = 0, |
||
| 1125 | CXX11_gnu_always_inline = 1, |
||
| 1126 | C2x_gnu_always_inline = 2, |
||
| 1127 | CXX11_clang_always_inline = 3, |
||
| 1128 | C2x_clang_always_inline = 4, |
||
| 1129 | Keyword_forceinline = 5, |
||
| 1130 | SpellingNotCalculated = 15 |
||
| 1131 | |||
| 1132 | }; |
||
| 1133 | |||
| 1134 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 1135 | switch (Idx) { |
||
| 1136 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 1137 | case 0: return GNU_always_inline; |
||
| 1138 | case 1: return CXX11_gnu_always_inline; |
||
| 1139 | case 2: return C2x_gnu_always_inline; |
||
| 1140 | case 3: return CXX11_clang_always_inline; |
||
| 1141 | case 4: return C2x_clang_always_inline; |
||
| 1142 | case 5: return Keyword_forceinline; |
||
| 1143 | } |
||
| 1144 | } |
||
| 1145 | |||
| 1146 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 1147 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 1148 | } |
||
| 1149 | |||
| 1150 | bool isParamExpr(size_t N) const override { |
||
| 1151 | return false; |
||
| 1152 | } |
||
| 1153 | |||
| 1154 | static const ParsedAttrInfoAlwaysInline Instance; |
||
| 1155 | }; |
||
| 1156 | const ParsedAttrInfoAlwaysInline ParsedAttrInfoAlwaysInline::Instance; |
||
| 1157 | static constexpr ParsedAttrInfo::Spelling AnalyzerNoReturnSpellings[] = { |
||
| 1158 | {AttributeCommonInfo::AS_GNU, "analyzer_noreturn"}, |
||
| 1159 | }; |
||
| 1160 | struct ParsedAttrInfoAnalyzerNoReturn final : public ParsedAttrInfo { |
||
| 1161 | constexpr ParsedAttrInfoAnalyzerNoReturn() : ParsedAttrInfo( |
||
| 1162 | /*AttrKind=*/ParsedAttr::AT_AnalyzerNoReturn, |
||
| 1163 | /*NumArgs=*/0, |
||
| 1164 | /*OptArgs=*/0, |
||
| 1165 | /*NumArgMembers=*/0, |
||
| 1166 | /*HasCustomParsing=*/0, |
||
| 1167 | /*AcceptsExprPack=*/0, |
||
| 1168 | /*IsTargetSpecific=*/0, |
||
| 1169 | /*IsType=*/0, |
||
| 1170 | /*IsStmt=*/0, |
||
| 1171 | /*IsKnownToGCC=*/0, |
||
| 1172 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 1173 | /*Spellings=*/AnalyzerNoReturnSpellings, |
||
| 1174 | /*ArgNames=*/{}) {} |
||
| 1175 | bool isParamExpr(size_t N) const override { |
||
| 1176 | return false; |
||
| 1177 | } |
||
| 1178 | |||
| 1179 | static const ParsedAttrInfoAnalyzerNoReturn Instance; |
||
| 1180 | }; |
||
| 1181 | const ParsedAttrInfoAnalyzerNoReturn ParsedAttrInfoAnalyzerNoReturn::Instance; |
||
| 1182 | static constexpr ParsedAttrInfo::Spelling AnnotateSpellings[] = { |
||
| 1183 | {AttributeCommonInfo::AS_GNU, "annotate"}, |
||
| 1184 | {AttributeCommonInfo::AS_CXX11, "clang::annotate"}, |
||
| 1185 | {AttributeCommonInfo::AS_C2x, "clang::annotate"}, |
||
| 1186 | }; |
||
| 1187 | static constexpr const char *AnnotateArgNames[] = { |
||
| 1188 | "Annotation","Args...",}; |
||
| 1189 | struct ParsedAttrInfoAnnotate final : public ParsedAttrInfo { |
||
| 1190 | constexpr ParsedAttrInfoAnnotate() : ParsedAttrInfo( |
||
| 1191 | /*AttrKind=*/ParsedAttr::AT_Annotate, |
||
| 1192 | /*NumArgs=*/1, |
||
| 1193 | /*OptArgs=*/15, |
||
| 1194 | /*NumArgMembers=*/2, |
||
| 1195 | /*HasCustomParsing=*/0, |
||
| 1196 | /*AcceptsExprPack=*/1, |
||
| 1197 | /*IsTargetSpecific=*/0, |
||
| 1198 | /*IsType=*/0, |
||
| 1199 | /*IsStmt=*/0, |
||
| 1200 | /*IsKnownToGCC=*/0, |
||
| 1201 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 1202 | /*Spellings=*/AnnotateSpellings, |
||
| 1203 | /*ArgNames=*/AnnotateArgNames) {} |
||
| 1204 | bool isParamExpr(size_t N) const override { |
||
| 1205 | return (N == 1) || false; |
||
| 1206 | } |
||
| 1207 | |||
| 1208 | static const ParsedAttrInfoAnnotate Instance; |
||
| 1209 | }; |
||
| 1210 | const ParsedAttrInfoAnnotate ParsedAttrInfoAnnotate::Instance; |
||
| 1211 | static constexpr ParsedAttrInfo::Spelling AnnotateTypeSpellings[] = { |
||
| 1212 | {AttributeCommonInfo::AS_CXX11, "clang::annotate_type"}, |
||
| 1213 | {AttributeCommonInfo::AS_C2x, "clang::annotate_type"}, |
||
| 1214 | }; |
||
| 1215 | static constexpr const char *AnnotateTypeArgNames[] = { |
||
| 1216 | "Annotation","Args...",}; |
||
| 1217 | struct ParsedAttrInfoAnnotateType final : public ParsedAttrInfo { |
||
| 1218 | constexpr ParsedAttrInfoAnnotateType() : ParsedAttrInfo( |
||
| 1219 | /*AttrKind=*/ParsedAttr::AT_AnnotateType, |
||
| 1220 | /*NumArgs=*/1, |
||
| 1221 | /*OptArgs=*/15, |
||
| 1222 | /*NumArgMembers=*/2, |
||
| 1223 | /*HasCustomParsing=*/1, |
||
| 1224 | /*AcceptsExprPack=*/1, |
||
| 1225 | /*IsTargetSpecific=*/0, |
||
| 1226 | /*IsType=*/1, |
||
| 1227 | /*IsStmt=*/0, |
||
| 1228 | /*IsKnownToGCC=*/0, |
||
| 1229 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 1230 | /*Spellings=*/AnnotateTypeSpellings, |
||
| 1231 | /*ArgNames=*/AnnotateTypeArgNames) {} |
||
| 1232 | bool isParamExpr(size_t N) const override { |
||
| 1233 | return (N == 1) || false; |
||
| 1234 | } |
||
| 1235 | |||
| 1236 | static const ParsedAttrInfoAnnotateType Instance; |
||
| 1237 | }; |
||
| 1238 | const ParsedAttrInfoAnnotateType ParsedAttrInfoAnnotateType::Instance; |
||
| 1239 | static constexpr ParsedAttrInfo::Spelling AnyX86NoCallerSavedRegistersSpellings[] = { |
||
| 1240 | {AttributeCommonInfo::AS_GNU, "no_caller_saved_registers"}, |
||
| 1241 | {AttributeCommonInfo::AS_CXX11, "gnu::no_caller_saved_registers"}, |
||
| 1242 | {AttributeCommonInfo::AS_C2x, "gnu::no_caller_saved_registers"}, |
||
| 1243 | }; |
||
| 1244 | struct ParsedAttrInfoAnyX86NoCallerSavedRegisters final : public ParsedAttrInfo { |
||
| 1245 | constexpr ParsedAttrInfoAnyX86NoCallerSavedRegisters() : ParsedAttrInfo( |
||
| 1246 | /*AttrKind=*/ParsedAttr::AT_AnyX86NoCallerSavedRegisters, |
||
| 1247 | /*NumArgs=*/0, |
||
| 1248 | /*OptArgs=*/0, |
||
| 1249 | /*NumArgMembers=*/0, |
||
| 1250 | /*HasCustomParsing=*/0, |
||
| 1251 | /*AcceptsExprPack=*/0, |
||
| 1252 | /*IsTargetSpecific=*/1, |
||
| 1253 | /*IsType=*/0, |
||
| 1254 | /*IsStmt=*/0, |
||
| 1255 | /*IsKnownToGCC=*/1, |
||
| 1256 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 1257 | /*Spellings=*/AnyX86NoCallerSavedRegistersSpellings, |
||
| 1258 | /*ArgNames=*/{}) {} |
||
| 1259 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 1260 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 1261 | return true && (T.getArch() == llvm::Triple::x86 || T.getArch() == llvm::Triple::x86_64); |
||
| 1262 | } |
||
| 1263 | |||
| 1264 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 1265 | D->addAttr(::new (S.Context) AnyX86NoCallerSavedRegistersAttr(S.Context, Attr)); |
||
| 1266 | return AttributeApplied; |
||
| 1267 | } |
||
| 1268 | |||
| 1269 | bool isParamExpr(size_t N) const override { |
||
| 1270 | return false; |
||
| 1271 | } |
||
| 1272 | |||
| 1273 | static const ParsedAttrInfoAnyX86NoCallerSavedRegisters Instance; |
||
| 1274 | }; |
||
| 1275 | const ParsedAttrInfoAnyX86NoCallerSavedRegisters ParsedAttrInfoAnyX86NoCallerSavedRegisters::Instance; |
||
| 1276 | static constexpr ParsedAttrInfo::Spelling AnyX86NoCfCheckSpellings[] = { |
||
| 1277 | {AttributeCommonInfo::AS_GNU, "nocf_check"}, |
||
| 1278 | {AttributeCommonInfo::AS_CXX11, "gnu::nocf_check"}, |
||
| 1279 | {AttributeCommonInfo::AS_C2x, "gnu::nocf_check"}, |
||
| 1280 | }; |
||
| 1281 | struct ParsedAttrInfoAnyX86NoCfCheck final : public ParsedAttrInfo { |
||
| 1282 | constexpr ParsedAttrInfoAnyX86NoCfCheck() : ParsedAttrInfo( |
||
| 1283 | /*AttrKind=*/ParsedAttr::AT_AnyX86NoCfCheck, |
||
| 1284 | /*NumArgs=*/0, |
||
| 1285 | /*OptArgs=*/0, |
||
| 1286 | /*NumArgMembers=*/0, |
||
| 1287 | /*HasCustomParsing=*/0, |
||
| 1288 | /*AcceptsExprPack=*/0, |
||
| 1289 | /*IsTargetSpecific=*/1, |
||
| 1290 | /*IsType=*/1, |
||
| 1291 | /*IsStmt=*/0, |
||
| 1292 | /*IsKnownToGCC=*/1, |
||
| 1293 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 1294 | /*Spellings=*/AnyX86NoCfCheckSpellings, |
||
| 1295 | /*ArgNames=*/{}) {} |
||
| 1296 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 1297 | if (!isFunctionLike(D)) { |
||
| 1298 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 1299 | << Attr << "functions and function pointers"; |
||
| 1300 | return false; |
||
| 1301 | } |
||
| 1302 | return true; |
||
| 1303 | } |
||
| 1304 | |||
| 1305 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 1306 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 1307 | << AL << St->getBeginLoc(); |
||
| 1308 | return false; |
||
| 1309 | } |
||
| 1310 | |||
| 1311 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 1312 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 1313 | return true && (T.getArch() == llvm::Triple::x86 || T.getArch() == llvm::Triple::x86_64); |
||
| 1314 | } |
||
| 1315 | |||
| 1316 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 1317 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_hasType_functionType, /*IsSupported=*/true)); |
||
| 1318 | } |
||
| 1319 | |||
| 1320 | bool isParamExpr(size_t N) const override { |
||
| 1321 | return false; |
||
| 1322 | } |
||
| 1323 | |||
| 1324 | static const ParsedAttrInfoAnyX86NoCfCheck Instance; |
||
| 1325 | }; |
||
| 1326 | const ParsedAttrInfoAnyX86NoCfCheck ParsedAttrInfoAnyX86NoCfCheck::Instance; |
||
| 1327 | static constexpr ParsedAttrInfo::Spelling ArcWeakrefUnavailableSpellings[] = { |
||
| 1328 | {AttributeCommonInfo::AS_GNU, "objc_arc_weak_reference_unavailable"}, |
||
| 1329 | {AttributeCommonInfo::AS_CXX11, "clang::objc_arc_weak_reference_unavailable"}, |
||
| 1330 | {AttributeCommonInfo::AS_C2x, "clang::objc_arc_weak_reference_unavailable"}, |
||
| 1331 | }; |
||
| 1332 | struct ParsedAttrInfoArcWeakrefUnavailable final : public ParsedAttrInfo { |
||
| 1333 | constexpr ParsedAttrInfoArcWeakrefUnavailable() : ParsedAttrInfo( |
||
| 1334 | /*AttrKind=*/ParsedAttr::AT_ArcWeakrefUnavailable, |
||
| 1335 | /*NumArgs=*/0, |
||
| 1336 | /*OptArgs=*/0, |
||
| 1337 | /*NumArgMembers=*/0, |
||
| 1338 | /*HasCustomParsing=*/0, |
||
| 1339 | /*AcceptsExprPack=*/0, |
||
| 1340 | /*IsTargetSpecific=*/0, |
||
| 1341 | /*IsType=*/0, |
||
| 1342 | /*IsStmt=*/0, |
||
| 1343 | /*IsKnownToGCC=*/0, |
||
| 1344 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 1345 | /*Spellings=*/ArcWeakrefUnavailableSpellings, |
||
| 1346 | /*ArgNames=*/{}) {} |
||
| 1347 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 1348 | if (!isa<ObjCInterfaceDecl>(D)) { |
||
| 1349 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 1350 | << Attr << "Objective-C interfaces"; |
||
| 1351 | return false; |
||
| 1352 | } |
||
| 1353 | return true; |
||
| 1354 | } |
||
| 1355 | |||
| 1356 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 1357 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 1358 | << AL << St->getBeginLoc(); |
||
| 1359 | return false; |
||
| 1360 | } |
||
| 1361 | |||
| 1362 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 1363 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
||
| 1364 | } |
||
| 1365 | |||
| 1366 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 1367 | D->addAttr(::new (S.Context) ArcWeakrefUnavailableAttr(S.Context, Attr)); |
||
| 1368 | return AttributeApplied; |
||
| 1369 | } |
||
| 1370 | |||
| 1371 | bool isParamExpr(size_t N) const override { |
||
| 1372 | return false; |
||
| 1373 | } |
||
| 1374 | |||
| 1375 | static const ParsedAttrInfoArcWeakrefUnavailable Instance; |
||
| 1376 | }; |
||
| 1377 | const ParsedAttrInfoArcWeakrefUnavailable ParsedAttrInfoArcWeakrefUnavailable::Instance; |
||
| 1378 | static constexpr ParsedAttrInfo::Spelling ArgumentWithTypeTagSpellings[] = { |
||
| 1379 | {AttributeCommonInfo::AS_GNU, "argument_with_type_tag"}, |
||
| 1380 | {AttributeCommonInfo::AS_CXX11, "clang::argument_with_type_tag"}, |
||
| 1381 | {AttributeCommonInfo::AS_C2x, "clang::argument_with_type_tag"}, |
||
| 1382 | {AttributeCommonInfo::AS_GNU, "pointer_with_type_tag"}, |
||
| 1383 | {AttributeCommonInfo::AS_CXX11, "clang::pointer_with_type_tag"}, |
||
| 1384 | {AttributeCommonInfo::AS_C2x, "clang::pointer_with_type_tag"}, |
||
| 1385 | }; |
||
| 1386 | static constexpr const char *ArgumentWithTypeTagArgNames[] = { |
||
| 1387 | "ArgumentKind","ArgumentIdx","TypeTagIdx",}; |
||
| 1388 | struct ParsedAttrInfoArgumentWithTypeTag final : public ParsedAttrInfo { |
||
| 1389 | constexpr ParsedAttrInfoArgumentWithTypeTag() : ParsedAttrInfo( |
||
| 1390 | /*AttrKind=*/ParsedAttr::AT_ArgumentWithTypeTag, |
||
| 1391 | /*NumArgs=*/3, |
||
| 1392 | /*OptArgs=*/0, |
||
| 1393 | /*NumArgMembers=*/3, |
||
| 1394 | /*HasCustomParsing=*/0, |
||
| 1395 | /*AcceptsExprPack=*/0, |
||
| 1396 | /*IsTargetSpecific=*/0, |
||
| 1397 | /*IsType=*/0, |
||
| 1398 | /*IsStmt=*/0, |
||
| 1399 | /*IsKnownToGCC=*/0, |
||
| 1400 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 1401 | /*Spellings=*/ArgumentWithTypeTagSpellings, |
||
| 1402 | /*ArgNames=*/ArgumentWithTypeTagArgNames) {} |
||
| 1403 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 1404 | if (!isHasFunctionProto(D)) { |
||
| 1405 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 1406 | << Attr << "non-K&R-style functions"; |
||
| 1407 | return false; |
||
| 1408 | } |
||
| 1409 | return true; |
||
| 1410 | } |
||
| 1411 | |||
| 1412 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 1413 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 1414 | << AL << St->getBeginLoc(); |
||
| 1415 | return false; |
||
| 1416 | } |
||
| 1417 | |||
| 1418 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 1419 | enum Spelling { |
||
| 1420 | GNU_argument_with_type_tag = 0, |
||
| 1421 | CXX11_clang_argument_with_type_tag = 1, |
||
| 1422 | C2x_clang_argument_with_type_tag = 2, |
||
| 1423 | GNU_pointer_with_type_tag = 3, |
||
| 1424 | CXX11_clang_pointer_with_type_tag = 4, |
||
| 1425 | C2x_clang_pointer_with_type_tag = 5, |
||
| 1426 | SpellingNotCalculated = 15 |
||
| 1427 | |||
| 1428 | }; |
||
| 1429 | |||
| 1430 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 1431 | switch (Idx) { |
||
| 1432 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 1433 | case 0: return GNU_argument_with_type_tag; |
||
| 1434 | case 1: return CXX11_clang_argument_with_type_tag; |
||
| 1435 | case 2: return C2x_clang_argument_with_type_tag; |
||
| 1436 | case 3: return GNU_pointer_with_type_tag; |
||
| 1437 | case 4: return CXX11_clang_pointer_with_type_tag; |
||
| 1438 | case 5: return C2x_clang_pointer_with_type_tag; |
||
| 1439 | } |
||
| 1440 | } |
||
| 1441 | |||
| 1442 | bool isParamExpr(size_t N) const override { |
||
| 1443 | return false; |
||
| 1444 | } |
||
| 1445 | |||
| 1446 | static const ParsedAttrInfoArgumentWithTypeTag Instance; |
||
| 1447 | }; |
||
| 1448 | const ParsedAttrInfoArgumentWithTypeTag ParsedAttrInfoArgumentWithTypeTag::Instance; |
||
| 1449 | static constexpr ParsedAttrInfo::Spelling ArmBuiltinAliasSpellings[] = { |
||
| 1450 | {AttributeCommonInfo::AS_GNU, "__clang_arm_builtin_alias"}, |
||
| 1451 | {AttributeCommonInfo::AS_CXX11, "clang::__clang_arm_builtin_alias"}, |
||
| 1452 | {AttributeCommonInfo::AS_C2x, "clang::__clang_arm_builtin_alias"}, |
||
| 1453 | }; |
||
| 1454 | static constexpr const char *ArmBuiltinAliasArgNames[] = { |
||
| 1455 | "BuiltinName",}; |
||
| 1456 | struct ParsedAttrInfoArmBuiltinAlias final : public ParsedAttrInfo { |
||
| 1457 | constexpr ParsedAttrInfoArmBuiltinAlias() : ParsedAttrInfo( |
||
| 1458 | /*AttrKind=*/ParsedAttr::AT_ArmBuiltinAlias, |
||
| 1459 | /*NumArgs=*/1, |
||
| 1460 | /*OptArgs=*/0, |
||
| 1461 | /*NumArgMembers=*/1, |
||
| 1462 | /*HasCustomParsing=*/0, |
||
| 1463 | /*AcceptsExprPack=*/0, |
||
| 1464 | /*IsTargetSpecific=*/1, |
||
| 1465 | /*IsType=*/0, |
||
| 1466 | /*IsStmt=*/0, |
||
| 1467 | /*IsKnownToGCC=*/0, |
||
| 1468 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 1469 | /*Spellings=*/ArmBuiltinAliasSpellings, |
||
| 1470 | /*ArgNames=*/ArmBuiltinAliasArgNames) {} |
||
| 1471 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 1472 | if (!isa<FunctionDecl>(D)) { |
||
| 1473 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 1474 | << Attr << "functions"; |
||
| 1475 | return false; |
||
| 1476 | } |
||
| 1477 | return true; |
||
| 1478 | } |
||
| 1479 | |||
| 1480 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 1481 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 1482 | << AL << St->getBeginLoc(); |
||
| 1483 | return false; |
||
| 1484 | } |
||
| 1485 | |||
| 1486 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 1487 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 1488 | 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::aarch64); |
||
| 1489 | } |
||
| 1490 | |||
| 1491 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 1492 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 1493 | } |
||
| 1494 | |||
| 1495 | bool isParamExpr(size_t N) const override { |
||
| 1496 | return false; |
||
| 1497 | } |
||
| 1498 | |||
| 1499 | static const ParsedAttrInfoArmBuiltinAlias Instance; |
||
| 1500 | }; |
||
| 1501 | const ParsedAttrInfoArmBuiltinAlias ParsedAttrInfoArmBuiltinAlias::Instance; |
||
| 1502 | static constexpr ParsedAttrInfo::Spelling ArmMveStrictPolymorphismSpellings[] = { |
||
| 1503 | {AttributeCommonInfo::AS_GNU, "__clang_arm_mve_strict_polymorphism"}, |
||
| 1504 | {AttributeCommonInfo::AS_CXX11, "clang::__clang_arm_mve_strict_polymorphism"}, |
||
| 1505 | {AttributeCommonInfo::AS_C2x, "clang::__clang_arm_mve_strict_polymorphism"}, |
||
| 1506 | }; |
||
| 1507 | struct ParsedAttrInfoArmMveStrictPolymorphism final : public ParsedAttrInfo { |
||
| 1508 | constexpr ParsedAttrInfoArmMveStrictPolymorphism() : ParsedAttrInfo( |
||
| 1509 | /*AttrKind=*/ParsedAttr::AT_ArmMveStrictPolymorphism, |
||
| 1510 | /*NumArgs=*/0, |
||
| 1511 | /*OptArgs=*/0, |
||
| 1512 | /*NumArgMembers=*/0, |
||
| 1513 | /*HasCustomParsing=*/0, |
||
| 1514 | /*AcceptsExprPack=*/0, |
||
| 1515 | /*IsTargetSpecific=*/1, |
||
| 1516 | /*IsType=*/1, |
||
| 1517 | /*IsStmt=*/0, |
||
| 1518 | /*IsKnownToGCC=*/0, |
||
| 1519 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 1520 | /*Spellings=*/ArmMveStrictPolymorphismSpellings, |
||
| 1521 | /*ArgNames=*/{}) {} |
||
| 1522 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 1523 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 1524 | return true && (T.getArch() == llvm::Triple::arm || T.getArch() == llvm::Triple::thumb || T.getArch() == llvm::Triple::armeb || T.getArch() == llvm::Triple::thumbeb); |
||
| 1525 | } |
||
| 1526 | |||
| 1527 | bool isParamExpr(size_t N) const override { |
||
| 1528 | return false; |
||
| 1529 | } |
||
| 1530 | |||
| 1531 | static const ParsedAttrInfoArmMveStrictPolymorphism Instance; |
||
| 1532 | }; |
||
| 1533 | const ParsedAttrInfoArmMveStrictPolymorphism ParsedAttrInfoArmMveStrictPolymorphism::Instance; |
||
| 1534 | static constexpr ParsedAttrInfo::Spelling ArmSveVectorBitsSpellings[] = { |
||
| 1535 | {AttributeCommonInfo::AS_GNU, "arm_sve_vector_bits"}, |
||
| 1536 | }; |
||
| 1537 | static constexpr const char *ArmSveVectorBitsArgNames[] = { |
||
| 1538 | "NumBits",}; |
||
| 1539 | struct ParsedAttrInfoArmSveVectorBits final : public ParsedAttrInfo { |
||
| 1540 | constexpr ParsedAttrInfoArmSveVectorBits() : ParsedAttrInfo( |
||
| 1541 | /*AttrKind=*/ParsedAttr::AT_ArmSveVectorBits, |
||
| 1542 | /*NumArgs=*/1, |
||
| 1543 | /*OptArgs=*/0, |
||
| 1544 | /*NumArgMembers=*/1, |
||
| 1545 | /*HasCustomParsing=*/0, |
||
| 1546 | /*AcceptsExprPack=*/0, |
||
| 1547 | /*IsTargetSpecific=*/0, |
||
| 1548 | /*IsType=*/1, |
||
| 1549 | /*IsStmt=*/0, |
||
| 1550 | /*IsKnownToGCC=*/0, |
||
| 1551 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 1552 | /*Spellings=*/ArmSveVectorBitsSpellings, |
||
| 1553 | /*ArgNames=*/ArmSveVectorBitsArgNames) {} |
||
| 1554 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 1555 | if (!isa<TypedefNameDecl>(D)) { |
||
| 1556 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 1557 | << Attr << "typedefs"; |
||
| 1558 | return false; |
||
| 1559 | } |
||
| 1560 | return true; |
||
| 1561 | } |
||
| 1562 | |||
| 1563 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 1564 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 1565 | << AL << St->getBeginLoc(); |
||
| 1566 | return false; |
||
| 1567 | } |
||
| 1568 | |||
| 1569 | bool isParamExpr(size_t N) const override { |
||
| 1570 | return false; |
||
| 1571 | } |
||
| 1572 | |||
| 1573 | static const ParsedAttrInfoArmSveVectorBits Instance; |
||
| 1574 | }; |
||
| 1575 | const ParsedAttrInfoArmSveVectorBits ParsedAttrInfoArmSveVectorBits::Instance; |
||
| 1576 | static constexpr ParsedAttrInfo::Spelling ArtificialSpellings[] = { |
||
| 1577 | {AttributeCommonInfo::AS_GNU, "artificial"}, |
||
| 1578 | {AttributeCommonInfo::AS_CXX11, "gnu::artificial"}, |
||
| 1579 | {AttributeCommonInfo::AS_C2x, "gnu::artificial"}, |
||
| 1580 | }; |
||
| 1581 | struct ParsedAttrInfoArtificial final : public ParsedAttrInfo { |
||
| 1582 | constexpr ParsedAttrInfoArtificial() : ParsedAttrInfo( |
||
| 1583 | /*AttrKind=*/ParsedAttr::AT_Artificial, |
||
| 1584 | /*NumArgs=*/0, |
||
| 1585 | /*OptArgs=*/0, |
||
| 1586 | /*NumArgMembers=*/0, |
||
| 1587 | /*HasCustomParsing=*/0, |
||
| 1588 | /*AcceptsExprPack=*/0, |
||
| 1589 | /*IsTargetSpecific=*/0, |
||
| 1590 | /*IsType=*/0, |
||
| 1591 | /*IsStmt=*/0, |
||
| 1592 | /*IsKnownToGCC=*/1, |
||
| 1593 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 1594 | /*Spellings=*/ArtificialSpellings, |
||
| 1595 | /*ArgNames=*/{}) {} |
||
| 1596 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 1597 | if (!isInlineFunction(D)) { |
||
| 1598 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 1599 | << Attr << "inline functions"; |
||
| 1600 | return false; |
||
| 1601 | } |
||
| 1602 | return true; |
||
| 1603 | } |
||
| 1604 | |||
| 1605 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 1606 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 1607 | << AL << St->getBeginLoc(); |
||
| 1608 | return false; |
||
| 1609 | } |
||
| 1610 | |||
| 1611 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 1612 | D->addAttr(::new (S.Context) ArtificialAttr(S.Context, Attr)); |
||
| 1613 | return AttributeApplied; |
||
| 1614 | } |
||
| 1615 | |||
| 1616 | bool isParamExpr(size_t N) const override { |
||
| 1617 | return false; |
||
| 1618 | } |
||
| 1619 | |||
| 1620 | static const ParsedAttrInfoArtificial Instance; |
||
| 1621 | }; |
||
| 1622 | const ParsedAttrInfoArtificial ParsedAttrInfoArtificial::Instance; |
||
| 1623 | static constexpr ParsedAttrInfo::Spelling AssertCapabilitySpellings[] = { |
||
| 1624 | {AttributeCommonInfo::AS_GNU, "assert_capability"}, |
||
| 1625 | {AttributeCommonInfo::AS_CXX11, "clang::assert_capability"}, |
||
| 1626 | {AttributeCommonInfo::AS_GNU, "assert_shared_capability"}, |
||
| 1627 | {AttributeCommonInfo::AS_CXX11, "clang::assert_shared_capability"}, |
||
| 1628 | }; |
||
| 1629 | static constexpr const char *AssertCapabilityArgNames[] = { |
||
| 1630 | "Args...",}; |
||
| 1631 | struct ParsedAttrInfoAssertCapability final : public ParsedAttrInfo { |
||
| 1632 | constexpr ParsedAttrInfoAssertCapability() : ParsedAttrInfo( |
||
| 1633 | /*AttrKind=*/ParsedAttr::AT_AssertCapability, |
||
| 1634 | /*NumArgs=*/0, |
||
| 1635 | /*OptArgs=*/15, |
||
| 1636 | /*NumArgMembers=*/1, |
||
| 1637 | /*HasCustomParsing=*/0, |
||
| 1638 | /*AcceptsExprPack=*/0, |
||
| 1639 | /*IsTargetSpecific=*/0, |
||
| 1640 | /*IsType=*/0, |
||
| 1641 | /*IsStmt=*/0, |
||
| 1642 | /*IsKnownToGCC=*/0, |
||
| 1643 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 1644 | /*Spellings=*/AssertCapabilitySpellings, |
||
| 1645 | /*ArgNames=*/AssertCapabilityArgNames) {} |
||
| 1646 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 1647 | if (!isa<FunctionDecl>(D)) { |
||
| 1648 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 1649 | << Attr << "functions"; |
||
| 1650 | return false; |
||
| 1651 | } |
||
| 1652 | return true; |
||
| 1653 | } |
||
| 1654 | |||
| 1655 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 1656 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 1657 | << AL << St->getBeginLoc(); |
||
| 1658 | return false; |
||
| 1659 | } |
||
| 1660 | |||
| 1661 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 1662 | enum Spelling { |
||
| 1663 | GNU_assert_capability = 0, |
||
| 1664 | CXX11_clang_assert_capability = 1, |
||
| 1665 | GNU_assert_shared_capability = 2, |
||
| 1666 | CXX11_clang_assert_shared_capability = 3, |
||
| 1667 | SpellingNotCalculated = 15 |
||
| 1668 | |||
| 1669 | }; |
||
| 1670 | |||
| 1671 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 1672 | switch (Idx) { |
||
| 1673 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 1674 | case 0: return GNU_assert_capability; |
||
| 1675 | case 1: return CXX11_clang_assert_capability; |
||
| 1676 | case 2: return GNU_assert_shared_capability; |
||
| 1677 | case 3: return CXX11_clang_assert_shared_capability; |
||
| 1678 | } |
||
| 1679 | } |
||
| 1680 | |||
| 1681 | bool isParamExpr(size_t N) const override { |
||
| 1682 | return (N == 0) || false; |
||
| 1683 | } |
||
| 1684 | |||
| 1685 | static const ParsedAttrInfoAssertCapability Instance; |
||
| 1686 | }; |
||
| 1687 | const ParsedAttrInfoAssertCapability ParsedAttrInfoAssertCapability::Instance; |
||
| 1688 | static constexpr ParsedAttrInfo::Spelling AssertExclusiveLockSpellings[] = { |
||
| 1689 | {AttributeCommonInfo::AS_GNU, "assert_exclusive_lock"}, |
||
| 1690 | }; |
||
| 1691 | static constexpr const char *AssertExclusiveLockArgNames[] = { |
||
| 1692 | "Args...",}; |
||
| 1693 | struct ParsedAttrInfoAssertExclusiveLock final : public ParsedAttrInfo { |
||
| 1694 | constexpr ParsedAttrInfoAssertExclusiveLock() : ParsedAttrInfo( |
||
| 1695 | /*AttrKind=*/ParsedAttr::AT_AssertExclusiveLock, |
||
| 1696 | /*NumArgs=*/0, |
||
| 1697 | /*OptArgs=*/15, |
||
| 1698 | /*NumArgMembers=*/1, |
||
| 1699 | /*HasCustomParsing=*/0, |
||
| 1700 | /*AcceptsExprPack=*/0, |
||
| 1701 | /*IsTargetSpecific=*/0, |
||
| 1702 | /*IsType=*/0, |
||
| 1703 | /*IsStmt=*/0, |
||
| 1704 | /*IsKnownToGCC=*/0, |
||
| 1705 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 1706 | /*Spellings=*/AssertExclusiveLockSpellings, |
||
| 1707 | /*ArgNames=*/AssertExclusiveLockArgNames) {} |
||
| 1708 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 1709 | if (!isa<FunctionDecl>(D)) { |
||
| 1710 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 1711 | << Attr << "functions"; |
||
| 1712 | return false; |
||
| 1713 | } |
||
| 1714 | return true; |
||
| 1715 | } |
||
| 1716 | |||
| 1717 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 1718 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 1719 | << AL << St->getBeginLoc(); |
||
| 1720 | return false; |
||
| 1721 | } |
||
| 1722 | |||
| 1723 | bool isParamExpr(size_t N) const override { |
||
| 1724 | return (N == 0) || false; |
||
| 1725 | } |
||
| 1726 | |||
| 1727 | static const ParsedAttrInfoAssertExclusiveLock Instance; |
||
| 1728 | }; |
||
| 1729 | const ParsedAttrInfoAssertExclusiveLock ParsedAttrInfoAssertExclusiveLock::Instance; |
||
| 1730 | static constexpr ParsedAttrInfo::Spelling AssertSharedLockSpellings[] = { |
||
| 1731 | {AttributeCommonInfo::AS_GNU, "assert_shared_lock"}, |
||
| 1732 | }; |
||
| 1733 | static constexpr const char *AssertSharedLockArgNames[] = { |
||
| 1734 | "Args...",}; |
||
| 1735 | struct ParsedAttrInfoAssertSharedLock final : public ParsedAttrInfo { |
||
| 1736 | constexpr ParsedAttrInfoAssertSharedLock() : ParsedAttrInfo( |
||
| 1737 | /*AttrKind=*/ParsedAttr::AT_AssertSharedLock, |
||
| 1738 | /*NumArgs=*/0, |
||
| 1739 | /*OptArgs=*/15, |
||
| 1740 | /*NumArgMembers=*/1, |
||
| 1741 | /*HasCustomParsing=*/0, |
||
| 1742 | /*AcceptsExprPack=*/0, |
||
| 1743 | /*IsTargetSpecific=*/0, |
||
| 1744 | /*IsType=*/0, |
||
| 1745 | /*IsStmt=*/0, |
||
| 1746 | /*IsKnownToGCC=*/0, |
||
| 1747 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 1748 | /*Spellings=*/AssertSharedLockSpellings, |
||
| 1749 | /*ArgNames=*/AssertSharedLockArgNames) {} |
||
| 1750 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 1751 | if (!isa<FunctionDecl>(D)) { |
||
| 1752 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 1753 | << Attr << "functions"; |
||
| 1754 | return false; |
||
| 1755 | } |
||
| 1756 | return true; |
||
| 1757 | } |
||
| 1758 | |||
| 1759 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 1760 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 1761 | << AL << St->getBeginLoc(); |
||
| 1762 | return false; |
||
| 1763 | } |
||
| 1764 | |||
| 1765 | bool isParamExpr(size_t N) const override { |
||
| 1766 | return (N == 0) || false; |
||
| 1767 | } |
||
| 1768 | |||
| 1769 | static const ParsedAttrInfoAssertSharedLock Instance; |
||
| 1770 | }; |
||
| 1771 | const ParsedAttrInfoAssertSharedLock ParsedAttrInfoAssertSharedLock::Instance; |
||
| 1772 | static constexpr ParsedAttrInfo::Spelling AssumeAlignedSpellings[] = { |
||
| 1773 | {AttributeCommonInfo::AS_GNU, "assume_aligned"}, |
||
| 1774 | {AttributeCommonInfo::AS_CXX11, "gnu::assume_aligned"}, |
||
| 1775 | {AttributeCommonInfo::AS_C2x, "gnu::assume_aligned"}, |
||
| 1776 | }; |
||
| 1777 | static constexpr const char *AssumeAlignedArgNames[] = { |
||
| 1778 | "Alignment","Offset",}; |
||
| 1779 | struct ParsedAttrInfoAssumeAligned final : public ParsedAttrInfo { |
||
| 1780 | constexpr ParsedAttrInfoAssumeAligned() : ParsedAttrInfo( |
||
| 1781 | /*AttrKind=*/ParsedAttr::AT_AssumeAligned, |
||
| 1782 | /*NumArgs=*/1, |
||
| 1783 | /*OptArgs=*/1, |
||
| 1784 | /*NumArgMembers=*/2, |
||
| 1785 | /*HasCustomParsing=*/0, |
||
| 1786 | /*AcceptsExprPack=*/0, |
||
| 1787 | /*IsTargetSpecific=*/0, |
||
| 1788 | /*IsType=*/0, |
||
| 1789 | /*IsStmt=*/0, |
||
| 1790 | /*IsKnownToGCC=*/1, |
||
| 1791 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 1792 | /*Spellings=*/AssumeAlignedSpellings, |
||
| 1793 | /*ArgNames=*/AssumeAlignedArgNames) {} |
||
| 1794 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 1795 | if (!isa<ObjCMethodDecl>(D) && !isa<FunctionDecl>(D)) { |
||
| 1796 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 1797 | << Attr << "Objective-C methods and functions"; |
||
| 1798 | return false; |
||
| 1799 | } |
||
| 1800 | return true; |
||
| 1801 | } |
||
| 1802 | |||
| 1803 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 1804 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 1805 | << AL << St->getBeginLoc(); |
||
| 1806 | return false; |
||
| 1807 | } |
||
| 1808 | |||
| 1809 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 1810 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 1811 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 1812 | } |
||
| 1813 | |||
| 1814 | bool isParamExpr(size_t N) const override { |
||
| 1815 | return (N == 0) || (N == 1) || false; |
||
| 1816 | } |
||
| 1817 | |||
| 1818 | static const ParsedAttrInfoAssumeAligned Instance; |
||
| 1819 | }; |
||
| 1820 | const ParsedAttrInfoAssumeAligned ParsedAttrInfoAssumeAligned::Instance; |
||
| 1821 | static constexpr ParsedAttrInfo::Spelling AssumptionSpellings[] = { |
||
| 1822 | {AttributeCommonInfo::AS_GNU, "assume"}, |
||
| 1823 | {AttributeCommonInfo::AS_CXX11, "clang::assume"}, |
||
| 1824 | {AttributeCommonInfo::AS_C2x, "clang::assume"}, |
||
| 1825 | }; |
||
| 1826 | static constexpr const char *AssumptionArgNames[] = { |
||
| 1827 | "Assumption",}; |
||
| 1828 | struct ParsedAttrInfoAssumption final : public ParsedAttrInfo { |
||
| 1829 | constexpr ParsedAttrInfoAssumption() : ParsedAttrInfo( |
||
| 1830 | /*AttrKind=*/ParsedAttr::AT_Assumption, |
||
| 1831 | /*NumArgs=*/1, |
||
| 1832 | /*OptArgs=*/0, |
||
| 1833 | /*NumArgMembers=*/1, |
||
| 1834 | /*HasCustomParsing=*/0, |
||
| 1835 | /*AcceptsExprPack=*/0, |
||
| 1836 | /*IsTargetSpecific=*/0, |
||
| 1837 | /*IsType=*/0, |
||
| 1838 | /*IsStmt=*/0, |
||
| 1839 | /*IsKnownToGCC=*/0, |
||
| 1840 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 1841 | /*Spellings=*/AssumptionSpellings, |
||
| 1842 | /*ArgNames=*/AssumptionArgNames) {} |
||
| 1843 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 1844 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
||
| 1845 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 1846 | << Attr << "functions and Objective-C methods"; |
||
| 1847 | return false; |
||
| 1848 | } |
||
| 1849 | return true; |
||
| 1850 | } |
||
| 1851 | |||
| 1852 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 1853 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 1854 | << AL << St->getBeginLoc(); |
||
| 1855 | return false; |
||
| 1856 | } |
||
| 1857 | |||
| 1858 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 1859 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 1860 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 1861 | } |
||
| 1862 | |||
| 1863 | bool isParamExpr(size_t N) const override { |
||
| 1864 | return false; |
||
| 1865 | } |
||
| 1866 | |||
| 1867 | static const ParsedAttrInfoAssumption Instance; |
||
| 1868 | }; |
||
| 1869 | const ParsedAttrInfoAssumption ParsedAttrInfoAssumption::Instance; |
||
| 1870 | static constexpr ParsedAttrInfo::Spelling AvailabilitySpellings[] = { |
||
| 1871 | {AttributeCommonInfo::AS_GNU, "availability"}, |
||
| 1872 | {AttributeCommonInfo::AS_CXX11, "clang::availability"}, |
||
| 1873 | {AttributeCommonInfo::AS_C2x, "clang::availability"}, |
||
| 1874 | }; |
||
| 1875 | static constexpr const char *AvailabilityArgNames[] = { |
||
| 1876 | "platform","introduced","deprecated","obsoleted","unavailable","message","strict","replacement","priority",}; |
||
| 1877 | struct ParsedAttrInfoAvailability final : public ParsedAttrInfo { |
||
| 1878 | constexpr ParsedAttrInfoAvailability() : ParsedAttrInfo( |
||
| 1879 | /*AttrKind=*/ParsedAttr::AT_Availability, |
||
| 1880 | /*NumArgs=*/9, |
||
| 1881 | /*OptArgs=*/0, |
||
| 1882 | /*NumArgMembers=*/9, |
||
| 1883 | /*HasCustomParsing=*/1, |
||
| 1884 | /*AcceptsExprPack=*/0, |
||
| 1885 | /*IsTargetSpecific=*/0, |
||
| 1886 | /*IsType=*/0, |
||
| 1887 | /*IsStmt=*/0, |
||
| 1888 | /*IsKnownToGCC=*/0, |
||
| 1889 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 1890 | /*Spellings=*/AvailabilitySpellings, |
||
| 1891 | /*ArgNames=*/AvailabilityArgNames) {} |
||
| 1892 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 1893 | if (!isa<NamedDecl>(D)) { |
||
| 1894 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 1895 | << Attr << "named declarations"; |
||
| 1896 | return false; |
||
| 1897 | } |
||
| 1898 | return true; |
||
| 1899 | } |
||
| 1900 | |||
| 1901 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 1902 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 1903 | << AL << St->getBeginLoc(); |
||
| 1904 | return false; |
||
| 1905 | } |
||
| 1906 | |||
| 1907 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 1908 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 1909 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_enum, /*IsSupported=*/true)); |
||
| 1910 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_enum_constant, /*IsSupported=*/true)); |
||
| 1911 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_field, /*IsSupported=*/true)); |
||
| 1912 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 1913 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_namespace, /*IsSupported=*/LangOpts.CPlusPlus)); |
||
| 1914 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_category, /*IsSupported=*/LangOpts.ObjC)); |
||
| 1915 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_implementation, /*IsSupported=*/LangOpts.ObjC)); |
||
| 1916 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
||
| 1917 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 1918 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_property, /*IsSupported=*/LangOpts.ObjC)); |
||
| 1919 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_protocol, /*IsSupported=*/LangOpts.ObjC)); |
||
| 1920 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 1921 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true)); |
||
| 1922 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
||
| 1923 | } |
||
| 1924 | |||
| 1925 | bool isParamExpr(size_t N) const override { |
||
| 1926 | return false; |
||
| 1927 | } |
||
| 1928 | |||
| 1929 | static const ParsedAttrInfoAvailability Instance; |
||
| 1930 | }; |
||
| 1931 | const ParsedAttrInfoAvailability ParsedAttrInfoAvailability::Instance; |
||
| 1932 | static constexpr ParsedAttrInfo::Spelling BPFPreserveAccessIndexSpellings[] = { |
||
| 1933 | {AttributeCommonInfo::AS_GNU, "preserve_access_index"}, |
||
| 1934 | {AttributeCommonInfo::AS_CXX11, "clang::preserve_access_index"}, |
||
| 1935 | {AttributeCommonInfo::AS_C2x, "clang::preserve_access_index"}, |
||
| 1936 | }; |
||
| 1937 | struct ParsedAttrInfoBPFPreserveAccessIndex final : public ParsedAttrInfo { |
||
| 1938 | constexpr ParsedAttrInfoBPFPreserveAccessIndex() : ParsedAttrInfo( |
||
| 1939 | /*AttrKind=*/ParsedAttr::AT_BPFPreserveAccessIndex, |
||
| 1940 | /*NumArgs=*/0, |
||
| 1941 | /*OptArgs=*/0, |
||
| 1942 | /*NumArgMembers=*/0, |
||
| 1943 | /*HasCustomParsing=*/0, |
||
| 1944 | /*AcceptsExprPack=*/0, |
||
| 1945 | /*IsTargetSpecific=*/1, |
||
| 1946 | /*IsType=*/0, |
||
| 1947 | /*IsStmt=*/0, |
||
| 1948 | /*IsKnownToGCC=*/0, |
||
| 1949 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 1950 | /*Spellings=*/BPFPreserveAccessIndexSpellings, |
||
| 1951 | /*ArgNames=*/{}) {} |
||
| 1952 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 1953 | if (!isa<RecordDecl>(D)) { |
||
| 1954 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 1955 | << Attr << "structs, unions, and classes"; |
||
| 1956 | return false; |
||
| 1957 | } |
||
| 1958 | return true; |
||
| 1959 | } |
||
| 1960 | |||
| 1961 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 1962 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 1963 | << AL << St->getBeginLoc(); |
||
| 1964 | return false; |
||
| 1965 | } |
||
| 1966 | |||
| 1967 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 1968 | return (!LangOpts.CPlusPlus); |
||
| 1969 | } |
||
| 1970 | |||
| 1971 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 1972 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 1973 | return true && (T.getArch() == llvm::Triple::bpfel || T.getArch() == llvm::Triple::bpfeb); |
||
| 1974 | } |
||
| 1975 | |||
| 1976 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 1977 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 1978 | } |
||
| 1979 | |||
| 1980 | bool isParamExpr(size_t N) const override { |
||
| 1981 | return false; |
||
| 1982 | } |
||
| 1983 | |||
| 1984 | static const ParsedAttrInfoBPFPreserveAccessIndex Instance; |
||
| 1985 | }; |
||
| 1986 | const ParsedAttrInfoBPFPreserveAccessIndex ParsedAttrInfoBPFPreserveAccessIndex::Instance; |
||
| 1987 | static constexpr ParsedAttrInfo::Spelling BTFDeclTagSpellings[] = { |
||
| 1988 | {AttributeCommonInfo::AS_GNU, "btf_decl_tag"}, |
||
| 1989 | {AttributeCommonInfo::AS_CXX11, "clang::btf_decl_tag"}, |
||
| 1990 | {AttributeCommonInfo::AS_C2x, "clang::btf_decl_tag"}, |
||
| 1991 | }; |
||
| 1992 | static constexpr const char *BTFDeclTagArgNames[] = { |
||
| 1993 | "BTFDeclTag",}; |
||
| 1994 | struct ParsedAttrInfoBTFDeclTag final : public ParsedAttrInfo { |
||
| 1995 | constexpr ParsedAttrInfoBTFDeclTag() : ParsedAttrInfo( |
||
| 1996 | /*AttrKind=*/ParsedAttr::AT_BTFDeclTag, |
||
| 1997 | /*NumArgs=*/1, |
||
| 1998 | /*OptArgs=*/0, |
||
| 1999 | /*NumArgMembers=*/1, |
||
| 2000 | /*HasCustomParsing=*/0, |
||
| 2001 | /*AcceptsExprPack=*/0, |
||
| 2002 | /*IsTargetSpecific=*/0, |
||
| 2003 | /*IsType=*/0, |
||
| 2004 | /*IsStmt=*/0, |
||
| 2005 | /*IsKnownToGCC=*/0, |
||
| 2006 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 2007 | /*Spellings=*/BTFDeclTagSpellings, |
||
| 2008 | /*ArgNames=*/BTFDeclTagArgNames) {} |
||
| 2009 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 2010 | if (!isa<VarDecl>(D) && !isa<FunctionDecl>(D) && !isa<RecordDecl>(D) && !isa<FieldDecl>(D) && !isa<TypedefNameDecl>(D)) { |
||
| 2011 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 2012 | << Attr << "variables, functions, structs, unions, classes, non-static data members, and typedefs"; |
||
| 2013 | return false; |
||
| 2014 | } |
||
| 2015 | return true; |
||
| 2016 | } |
||
| 2017 | |||
| 2018 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 2019 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 2020 | << AL << St->getBeginLoc(); |
||
| 2021 | return false; |
||
| 2022 | } |
||
| 2023 | |||
| 2024 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 2025 | return (!LangOpts.CPlusPlus); |
||
| 2026 | } |
||
| 2027 | |||
| 2028 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 2029 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
||
| 2030 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 2031 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 2032 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_field, /*IsSupported=*/true)); |
||
| 2033 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true)); |
||
| 2034 | } |
||
| 2035 | |||
| 2036 | bool isParamExpr(size_t N) const override { |
||
| 2037 | return false; |
||
| 2038 | } |
||
| 2039 | |||
| 2040 | static const ParsedAttrInfoBTFDeclTag Instance; |
||
| 2041 | }; |
||
| 2042 | const ParsedAttrInfoBTFDeclTag ParsedAttrInfoBTFDeclTag::Instance; |
||
| 2043 | static constexpr ParsedAttrInfo::Spelling BTFTypeTagSpellings[] = { |
||
| 2044 | {AttributeCommonInfo::AS_GNU, "btf_type_tag"}, |
||
| 2045 | {AttributeCommonInfo::AS_CXX11, "clang::btf_type_tag"}, |
||
| 2046 | {AttributeCommonInfo::AS_C2x, "clang::btf_type_tag"}, |
||
| 2047 | }; |
||
| 2048 | static constexpr const char *BTFTypeTagArgNames[] = { |
||
| 2049 | "BTFTypeTag",}; |
||
| 2050 | struct ParsedAttrInfoBTFTypeTag final : public ParsedAttrInfo { |
||
| 2051 | constexpr ParsedAttrInfoBTFTypeTag() : ParsedAttrInfo( |
||
| 2052 | /*AttrKind=*/ParsedAttr::AT_BTFTypeTag, |
||
| 2053 | /*NumArgs=*/1, |
||
| 2054 | /*OptArgs=*/0, |
||
| 2055 | /*NumArgMembers=*/1, |
||
| 2056 | /*HasCustomParsing=*/0, |
||
| 2057 | /*AcceptsExprPack=*/0, |
||
| 2058 | /*IsTargetSpecific=*/0, |
||
| 2059 | /*IsType=*/1, |
||
| 2060 | /*IsStmt=*/0, |
||
| 2061 | /*IsKnownToGCC=*/0, |
||
| 2062 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 2063 | /*Spellings=*/BTFTypeTagSpellings, |
||
| 2064 | /*ArgNames=*/BTFTypeTagArgNames) {} |
||
| 2065 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 2066 | return (!LangOpts.CPlusPlus); |
||
| 2067 | } |
||
| 2068 | |||
| 2069 | bool isParamExpr(size_t N) const override { |
||
| 2070 | return false; |
||
| 2071 | } |
||
| 2072 | |||
| 2073 | static const ParsedAttrInfoBTFTypeTag Instance; |
||
| 2074 | }; |
||
| 2075 | const ParsedAttrInfoBTFTypeTag ParsedAttrInfoBTFTypeTag::Instance; |
||
| 2076 | static constexpr ParsedAttrInfo::Spelling BlocksSpellings[] = { |
||
| 2077 | {AttributeCommonInfo::AS_GNU, "blocks"}, |
||
| 2078 | {AttributeCommonInfo::AS_CXX11, "clang::blocks"}, |
||
| 2079 | {AttributeCommonInfo::AS_C2x, "clang::blocks"}, |
||
| 2080 | }; |
||
| 2081 | static constexpr const char *BlocksArgNames[] = { |
||
| 2082 | "Type",}; |
||
| 2083 | struct ParsedAttrInfoBlocks final : public ParsedAttrInfo { |
||
| 2084 | constexpr ParsedAttrInfoBlocks() : ParsedAttrInfo( |
||
| 2085 | /*AttrKind=*/ParsedAttr::AT_Blocks, |
||
| 2086 | /*NumArgs=*/1, |
||
| 2087 | /*OptArgs=*/0, |
||
| 2088 | /*NumArgMembers=*/1, |
||
| 2089 | /*HasCustomParsing=*/0, |
||
| 2090 | /*AcceptsExprPack=*/0, |
||
| 2091 | /*IsTargetSpecific=*/0, |
||
| 2092 | /*IsType=*/0, |
||
| 2093 | /*IsStmt=*/0, |
||
| 2094 | /*IsKnownToGCC=*/0, |
||
| 2095 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 2096 | /*Spellings=*/BlocksSpellings, |
||
| 2097 | /*ArgNames=*/BlocksArgNames) {} |
||
| 2098 | bool isParamExpr(size_t N) const override { |
||
| 2099 | return false; |
||
| 2100 | } |
||
| 2101 | |||
| 2102 | static const ParsedAttrInfoBlocks Instance; |
||
| 2103 | }; |
||
| 2104 | const ParsedAttrInfoBlocks ParsedAttrInfoBlocks::Instance; |
||
| 2105 | static constexpr ParsedAttrInfo::Spelling BuiltinAliasSpellings[] = { |
||
| 2106 | {AttributeCommonInfo::AS_CXX11, "clang::builtin_alias"}, |
||
| 2107 | {AttributeCommonInfo::AS_C2x, "clang::builtin_alias"}, |
||
| 2108 | {AttributeCommonInfo::AS_GNU, "clang_builtin_alias"}, |
||
| 2109 | }; |
||
| 2110 | static constexpr const char *BuiltinAliasArgNames[] = { |
||
| 2111 | "BuiltinName",}; |
||
| 2112 | struct ParsedAttrInfoBuiltinAlias final : public ParsedAttrInfo { |
||
| 2113 | constexpr ParsedAttrInfoBuiltinAlias() : ParsedAttrInfo( |
||
| 2114 | /*AttrKind=*/ParsedAttr::AT_BuiltinAlias, |
||
| 2115 | /*NumArgs=*/1, |
||
| 2116 | /*OptArgs=*/0, |
||
| 2117 | /*NumArgMembers=*/1, |
||
| 2118 | /*HasCustomParsing=*/0, |
||
| 2119 | /*AcceptsExprPack=*/0, |
||
| 2120 | /*IsTargetSpecific=*/0, |
||
| 2121 | /*IsType=*/0, |
||
| 2122 | /*IsStmt=*/0, |
||
| 2123 | /*IsKnownToGCC=*/0, |
||
| 2124 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 2125 | /*Spellings=*/BuiltinAliasSpellings, |
||
| 2126 | /*ArgNames=*/BuiltinAliasArgNames) {} |
||
| 2127 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 2128 | if (!isa<FunctionDecl>(D)) { |
||
| 2129 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 2130 | << Attr << "functions"; |
||
| 2131 | return false; |
||
| 2132 | } |
||
| 2133 | return true; |
||
| 2134 | } |
||
| 2135 | |||
| 2136 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 2137 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 2138 | << AL << St->getBeginLoc(); |
||
| 2139 | return false; |
||
| 2140 | } |
||
| 2141 | |||
| 2142 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 2143 | enum Spelling { |
||
| 2144 | CXX11_clang_builtin_alias = 0, |
||
| 2145 | C2x_clang_builtin_alias = 1, |
||
| 2146 | GNU_clang_builtin_alias = 2, |
||
| 2147 | SpellingNotCalculated = 15 |
||
| 2148 | |||
| 2149 | }; |
||
| 2150 | |||
| 2151 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 2152 | switch (Idx) { |
||
| 2153 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 2154 | case 0: return CXX11_clang_builtin_alias; |
||
| 2155 | case 1: return C2x_clang_builtin_alias; |
||
| 2156 | case 2: return GNU_clang_builtin_alias; |
||
| 2157 | } |
||
| 2158 | } |
||
| 2159 | |||
| 2160 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 2161 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 2162 | } |
||
| 2163 | |||
| 2164 | bool isParamExpr(size_t N) const override { |
||
| 2165 | return false; |
||
| 2166 | } |
||
| 2167 | |||
| 2168 | static const ParsedAttrInfoBuiltinAlias Instance; |
||
| 2169 | }; |
||
| 2170 | const ParsedAttrInfoBuiltinAlias ParsedAttrInfoBuiltinAlias::Instance; |
||
| 2171 | static constexpr ParsedAttrInfo::Spelling CDeclSpellings[] = { |
||
| 2172 | {AttributeCommonInfo::AS_GNU, "cdecl"}, |
||
| 2173 | {AttributeCommonInfo::AS_CXX11, "gnu::cdecl"}, |
||
| 2174 | {AttributeCommonInfo::AS_C2x, "gnu::cdecl"}, |
||
| 2175 | {AttributeCommonInfo::AS_Keyword, "__cdecl"}, |
||
| 2176 | {AttributeCommonInfo::AS_Keyword, "_cdecl"}, |
||
| 2177 | }; |
||
| 2178 | struct ParsedAttrInfoCDecl final : public ParsedAttrInfo { |
||
| 2179 | constexpr ParsedAttrInfoCDecl() : ParsedAttrInfo( |
||
| 2180 | /*AttrKind=*/ParsedAttr::AT_CDecl, |
||
| 2181 | /*NumArgs=*/0, |
||
| 2182 | /*OptArgs=*/0, |
||
| 2183 | /*NumArgMembers=*/0, |
||
| 2184 | /*HasCustomParsing=*/0, |
||
| 2185 | /*AcceptsExprPack=*/0, |
||
| 2186 | /*IsTargetSpecific=*/0, |
||
| 2187 | /*IsType=*/1, |
||
| 2188 | /*IsStmt=*/0, |
||
| 2189 | /*IsKnownToGCC=*/1, |
||
| 2190 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 2191 | /*Spellings=*/CDeclSpellings, |
||
| 2192 | /*ArgNames=*/{}) {} |
||
| 2193 | bool isParamExpr(size_t N) const override { |
||
| 2194 | return false; |
||
| 2195 | } |
||
| 2196 | |||
| 2197 | static const ParsedAttrInfoCDecl Instance; |
||
| 2198 | }; |
||
| 2199 | const ParsedAttrInfoCDecl ParsedAttrInfoCDecl::Instance; |
||
| 2200 | static constexpr ParsedAttrInfo::Spelling CFAuditedTransferSpellings[] = { |
||
| 2201 | {AttributeCommonInfo::AS_GNU, "cf_audited_transfer"}, |
||
| 2202 | {AttributeCommonInfo::AS_CXX11, "clang::cf_audited_transfer"}, |
||
| 2203 | {AttributeCommonInfo::AS_C2x, "clang::cf_audited_transfer"}, |
||
| 2204 | }; |
||
| 2205 | struct ParsedAttrInfoCFAuditedTransfer final : public ParsedAttrInfo { |
||
| 2206 | constexpr ParsedAttrInfoCFAuditedTransfer() : ParsedAttrInfo( |
||
| 2207 | /*AttrKind=*/ParsedAttr::AT_CFAuditedTransfer, |
||
| 2208 | /*NumArgs=*/0, |
||
| 2209 | /*OptArgs=*/0, |
||
| 2210 | /*NumArgMembers=*/0, |
||
| 2211 | /*HasCustomParsing=*/0, |
||
| 2212 | /*AcceptsExprPack=*/0, |
||
| 2213 | /*IsTargetSpecific=*/0, |
||
| 2214 | /*IsType=*/0, |
||
| 2215 | /*IsStmt=*/0, |
||
| 2216 | /*IsKnownToGCC=*/0, |
||
| 2217 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 2218 | /*Spellings=*/CFAuditedTransferSpellings, |
||
| 2219 | /*ArgNames=*/{}) {} |
||
| 2220 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 2221 | if (!isa<FunctionDecl>(D)) { |
||
| 2222 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 2223 | << Attr << "functions"; |
||
| 2224 | return false; |
||
| 2225 | } |
||
| 2226 | return true; |
||
| 2227 | } |
||
| 2228 | |||
| 2229 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 2230 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 2231 | << AL << St->getBeginLoc(); |
||
| 2232 | return false; |
||
| 2233 | } |
||
| 2234 | |||
| 2235 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 2236 | |||
| 2237 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 2238 | if (const auto *A = D->getAttr<CFUnknownTransferAttr>()) { |
||
| 2239 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 2240 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 2241 | return false; |
||
| 2242 | } |
||
| 2243 | return true; |
||
| 2244 | } |
||
| 2245 | |||
| 2246 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 2247 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 2248 | } |
||
| 2249 | |||
| 2250 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 2251 | D->addAttr(::new (S.Context) CFAuditedTransferAttr(S.Context, Attr)); |
||
| 2252 | return AttributeApplied; |
||
| 2253 | } |
||
| 2254 | |||
| 2255 | bool isParamExpr(size_t N) const override { |
||
| 2256 | return false; |
||
| 2257 | } |
||
| 2258 | |||
| 2259 | static const ParsedAttrInfoCFAuditedTransfer Instance; |
||
| 2260 | }; |
||
| 2261 | const ParsedAttrInfoCFAuditedTransfer ParsedAttrInfoCFAuditedTransfer::Instance; |
||
| 2262 | static constexpr ParsedAttrInfo::Spelling CFConsumedSpellings[] = { |
||
| 2263 | {AttributeCommonInfo::AS_GNU, "cf_consumed"}, |
||
| 2264 | {AttributeCommonInfo::AS_CXX11, "clang::cf_consumed"}, |
||
| 2265 | {AttributeCommonInfo::AS_C2x, "clang::cf_consumed"}, |
||
| 2266 | }; |
||
| 2267 | struct ParsedAttrInfoCFConsumed final : public ParsedAttrInfo { |
||
| 2268 | constexpr ParsedAttrInfoCFConsumed() : ParsedAttrInfo( |
||
| 2269 | /*AttrKind=*/ParsedAttr::AT_CFConsumed, |
||
| 2270 | /*NumArgs=*/0, |
||
| 2271 | /*OptArgs=*/0, |
||
| 2272 | /*NumArgMembers=*/0, |
||
| 2273 | /*HasCustomParsing=*/0, |
||
| 2274 | /*AcceptsExprPack=*/0, |
||
| 2275 | /*IsTargetSpecific=*/0, |
||
| 2276 | /*IsType=*/0, |
||
| 2277 | /*IsStmt=*/0, |
||
| 2278 | /*IsKnownToGCC=*/0, |
||
| 2279 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 2280 | /*Spellings=*/CFConsumedSpellings, |
||
| 2281 | /*ArgNames=*/{}) {} |
||
| 2282 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 2283 | if (!isa<ParmVarDecl>(D)) { |
||
| 2284 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 2285 | << Attr << "parameters"; |
||
| 2286 | return false; |
||
| 2287 | } |
||
| 2288 | return true; |
||
| 2289 | } |
||
| 2290 | |||
| 2291 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 2292 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 2293 | << AL << St->getBeginLoc(); |
||
| 2294 | return false; |
||
| 2295 | } |
||
| 2296 | |||
| 2297 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 2298 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
||
| 2299 | } |
||
| 2300 | |||
| 2301 | bool isParamExpr(size_t N) const override { |
||
| 2302 | return false; |
||
| 2303 | } |
||
| 2304 | |||
| 2305 | static const ParsedAttrInfoCFConsumed Instance; |
||
| 2306 | }; |
||
| 2307 | const ParsedAttrInfoCFConsumed ParsedAttrInfoCFConsumed::Instance; |
||
| 2308 | static constexpr ParsedAttrInfo::Spelling CFGuardSpellings[] = { |
||
| 2309 | {AttributeCommonInfo::AS_Declspec, "guard"}, |
||
| 2310 | {AttributeCommonInfo::AS_GNU, "guard"}, |
||
| 2311 | {AttributeCommonInfo::AS_CXX11, "clang::guard"}, |
||
| 2312 | {AttributeCommonInfo::AS_C2x, "clang::guard"}, |
||
| 2313 | }; |
||
| 2314 | static constexpr const char *CFGuardArgNames[] = { |
||
| 2315 | "Guard",}; |
||
| 2316 | struct ParsedAttrInfoCFGuard final : public ParsedAttrInfo { |
||
| 2317 | constexpr ParsedAttrInfoCFGuard() : ParsedAttrInfo( |
||
| 2318 | /*AttrKind=*/ParsedAttr::AT_CFGuard, |
||
| 2319 | /*NumArgs=*/1, |
||
| 2320 | /*OptArgs=*/0, |
||
| 2321 | /*NumArgMembers=*/1, |
||
| 2322 | /*HasCustomParsing=*/0, |
||
| 2323 | /*AcceptsExprPack=*/0, |
||
| 2324 | /*IsTargetSpecific=*/1, |
||
| 2325 | /*IsType=*/0, |
||
| 2326 | /*IsStmt=*/0, |
||
| 2327 | /*IsKnownToGCC=*/0, |
||
| 2328 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 2329 | /*Spellings=*/CFGuardSpellings, |
||
| 2330 | /*ArgNames=*/CFGuardArgNames) {} |
||
| 2331 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 2332 | if (!isa<FunctionDecl>(D)) { |
||
| 2333 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 2334 | << Attr << "functions"; |
||
| 2335 | return false; |
||
| 2336 | } |
||
| 2337 | return true; |
||
| 2338 | } |
||
| 2339 | |||
| 2340 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 2341 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 2342 | << AL << St->getBeginLoc(); |
||
| 2343 | return false; |
||
| 2344 | } |
||
| 2345 | |||
| 2346 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 2347 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 2348 | return true && (T.getOS() == llvm::Triple::Win32); |
||
| 2349 | } |
||
| 2350 | |||
| 2351 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 2352 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 2353 | } |
||
| 2354 | |||
| 2355 | bool isParamExpr(size_t N) const override { |
||
| 2356 | return false; |
||
| 2357 | } |
||
| 2358 | |||
| 2359 | static const ParsedAttrInfoCFGuard Instance; |
||
| 2360 | }; |
||
| 2361 | const ParsedAttrInfoCFGuard ParsedAttrInfoCFGuard::Instance; |
||
| 2362 | static constexpr ParsedAttrInfo::Spelling CFICanonicalJumpTableSpellings[] = { |
||
| 2363 | {AttributeCommonInfo::AS_GNU, "cfi_canonical_jump_table"}, |
||
| 2364 | {AttributeCommonInfo::AS_CXX11, "clang::cfi_canonical_jump_table"}, |
||
| 2365 | {AttributeCommonInfo::AS_C2x, "clang::cfi_canonical_jump_table"}, |
||
| 2366 | }; |
||
| 2367 | struct ParsedAttrInfoCFICanonicalJumpTable final : public ParsedAttrInfo { |
||
| 2368 | constexpr ParsedAttrInfoCFICanonicalJumpTable() : ParsedAttrInfo( |
||
| 2369 | /*AttrKind=*/ParsedAttr::AT_CFICanonicalJumpTable, |
||
| 2370 | /*NumArgs=*/0, |
||
| 2371 | /*OptArgs=*/0, |
||
| 2372 | /*NumArgMembers=*/0, |
||
| 2373 | /*HasCustomParsing=*/0, |
||
| 2374 | /*AcceptsExprPack=*/0, |
||
| 2375 | /*IsTargetSpecific=*/0, |
||
| 2376 | /*IsType=*/0, |
||
| 2377 | /*IsStmt=*/0, |
||
| 2378 | /*IsKnownToGCC=*/0, |
||
| 2379 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 2380 | /*Spellings=*/CFICanonicalJumpTableSpellings, |
||
| 2381 | /*ArgNames=*/{}) {} |
||
| 2382 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 2383 | if (!isa<FunctionDecl>(D)) { |
||
| 2384 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 2385 | << Attr << "functions"; |
||
| 2386 | return false; |
||
| 2387 | } |
||
| 2388 | return true; |
||
| 2389 | } |
||
| 2390 | |||
| 2391 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 2392 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 2393 | << AL << St->getBeginLoc(); |
||
| 2394 | return false; |
||
| 2395 | } |
||
| 2396 | |||
| 2397 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 2398 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 2399 | } |
||
| 2400 | |||
| 2401 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 2402 | D->addAttr(::new (S.Context) CFICanonicalJumpTableAttr(S.Context, Attr)); |
||
| 2403 | return AttributeApplied; |
||
| 2404 | } |
||
| 2405 | |||
| 2406 | bool isParamExpr(size_t N) const override { |
||
| 2407 | return false; |
||
| 2408 | } |
||
| 2409 | |||
| 2410 | static const ParsedAttrInfoCFICanonicalJumpTable Instance; |
||
| 2411 | }; |
||
| 2412 | const ParsedAttrInfoCFICanonicalJumpTable ParsedAttrInfoCFICanonicalJumpTable::Instance; |
||
| 2413 | static constexpr ParsedAttrInfo::Spelling CFReturnsNotRetainedSpellings[] = { |
||
| 2414 | {AttributeCommonInfo::AS_GNU, "cf_returns_not_retained"}, |
||
| 2415 | {AttributeCommonInfo::AS_CXX11, "clang::cf_returns_not_retained"}, |
||
| 2416 | {AttributeCommonInfo::AS_C2x, "clang::cf_returns_not_retained"}, |
||
| 2417 | }; |
||
| 2418 | struct ParsedAttrInfoCFReturnsNotRetained final : public ParsedAttrInfo { |
||
| 2419 | constexpr ParsedAttrInfoCFReturnsNotRetained() : ParsedAttrInfo( |
||
| 2420 | /*AttrKind=*/ParsedAttr::AT_CFReturnsNotRetained, |
||
| 2421 | /*NumArgs=*/0, |
||
| 2422 | /*OptArgs=*/0, |
||
| 2423 | /*NumArgMembers=*/0, |
||
| 2424 | /*HasCustomParsing=*/0, |
||
| 2425 | /*AcceptsExprPack=*/0, |
||
| 2426 | /*IsTargetSpecific=*/0, |
||
| 2427 | /*IsType=*/0, |
||
| 2428 | /*IsStmt=*/0, |
||
| 2429 | /*IsKnownToGCC=*/0, |
||
| 2430 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 2431 | /*Spellings=*/CFReturnsNotRetainedSpellings, |
||
| 2432 | /*ArgNames=*/{}) {} |
||
| 2433 | bool isParamExpr(size_t N) const override { |
||
| 2434 | return false; |
||
| 2435 | } |
||
| 2436 | |||
| 2437 | static const ParsedAttrInfoCFReturnsNotRetained Instance; |
||
| 2438 | }; |
||
| 2439 | const ParsedAttrInfoCFReturnsNotRetained ParsedAttrInfoCFReturnsNotRetained::Instance; |
||
| 2440 | static constexpr ParsedAttrInfo::Spelling CFReturnsRetainedSpellings[] = { |
||
| 2441 | {AttributeCommonInfo::AS_GNU, "cf_returns_retained"}, |
||
| 2442 | {AttributeCommonInfo::AS_CXX11, "clang::cf_returns_retained"}, |
||
| 2443 | {AttributeCommonInfo::AS_C2x, "clang::cf_returns_retained"}, |
||
| 2444 | }; |
||
| 2445 | struct ParsedAttrInfoCFReturnsRetained final : public ParsedAttrInfo { |
||
| 2446 | constexpr ParsedAttrInfoCFReturnsRetained() : ParsedAttrInfo( |
||
| 2447 | /*AttrKind=*/ParsedAttr::AT_CFReturnsRetained, |
||
| 2448 | /*NumArgs=*/0, |
||
| 2449 | /*OptArgs=*/0, |
||
| 2450 | /*NumArgMembers=*/0, |
||
| 2451 | /*HasCustomParsing=*/0, |
||
| 2452 | /*AcceptsExprPack=*/0, |
||
| 2453 | /*IsTargetSpecific=*/0, |
||
| 2454 | /*IsType=*/0, |
||
| 2455 | /*IsStmt=*/0, |
||
| 2456 | /*IsKnownToGCC=*/0, |
||
| 2457 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 2458 | /*Spellings=*/CFReturnsRetainedSpellings, |
||
| 2459 | /*ArgNames=*/{}) {} |
||
| 2460 | bool isParamExpr(size_t N) const override { |
||
| 2461 | return false; |
||
| 2462 | } |
||
| 2463 | |||
| 2464 | static const ParsedAttrInfoCFReturnsRetained Instance; |
||
| 2465 | }; |
||
| 2466 | const ParsedAttrInfoCFReturnsRetained ParsedAttrInfoCFReturnsRetained::Instance; |
||
| 2467 | static constexpr ParsedAttrInfo::Spelling CFUnknownTransferSpellings[] = { |
||
| 2468 | {AttributeCommonInfo::AS_GNU, "cf_unknown_transfer"}, |
||
| 2469 | {AttributeCommonInfo::AS_CXX11, "clang::cf_unknown_transfer"}, |
||
| 2470 | {AttributeCommonInfo::AS_C2x, "clang::cf_unknown_transfer"}, |
||
| 2471 | }; |
||
| 2472 | struct ParsedAttrInfoCFUnknownTransfer final : public ParsedAttrInfo { |
||
| 2473 | constexpr ParsedAttrInfoCFUnknownTransfer() : ParsedAttrInfo( |
||
| 2474 | /*AttrKind=*/ParsedAttr::AT_CFUnknownTransfer, |
||
| 2475 | /*NumArgs=*/0, |
||
| 2476 | /*OptArgs=*/0, |
||
| 2477 | /*NumArgMembers=*/0, |
||
| 2478 | /*HasCustomParsing=*/0, |
||
| 2479 | /*AcceptsExprPack=*/0, |
||
| 2480 | /*IsTargetSpecific=*/0, |
||
| 2481 | /*IsType=*/0, |
||
| 2482 | /*IsStmt=*/0, |
||
| 2483 | /*IsKnownToGCC=*/0, |
||
| 2484 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 2485 | /*Spellings=*/CFUnknownTransferSpellings, |
||
| 2486 | /*ArgNames=*/{}) {} |
||
| 2487 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 2488 | if (!isa<FunctionDecl>(D)) { |
||
| 2489 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 2490 | << Attr << "functions"; |
||
| 2491 | return false; |
||
| 2492 | } |
||
| 2493 | return true; |
||
| 2494 | } |
||
| 2495 | |||
| 2496 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 2497 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 2498 | << AL << St->getBeginLoc(); |
||
| 2499 | return false; |
||
| 2500 | } |
||
| 2501 | |||
| 2502 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 2503 | |||
| 2504 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 2505 | if (const auto *A = D->getAttr<CFAuditedTransferAttr>()) { |
||
| 2506 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 2507 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 2508 | return false; |
||
| 2509 | } |
||
| 2510 | return true; |
||
| 2511 | } |
||
| 2512 | |||
| 2513 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 2514 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 2515 | } |
||
| 2516 | |||
| 2517 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 2518 | D->addAttr(::new (S.Context) CFUnknownTransferAttr(S.Context, Attr)); |
||
| 2519 | return AttributeApplied; |
||
| 2520 | } |
||
| 2521 | |||
| 2522 | bool isParamExpr(size_t N) const override { |
||
| 2523 | return false; |
||
| 2524 | } |
||
| 2525 | |||
| 2526 | static const ParsedAttrInfoCFUnknownTransfer Instance; |
||
| 2527 | }; |
||
| 2528 | const ParsedAttrInfoCFUnknownTransfer ParsedAttrInfoCFUnknownTransfer::Instance; |
||
| 2529 | static constexpr ParsedAttrInfo::Spelling CPUDispatchSpellings[] = { |
||
| 2530 | {AttributeCommonInfo::AS_GNU, "cpu_dispatch"}, |
||
| 2531 | {AttributeCommonInfo::AS_CXX11, "clang::cpu_dispatch"}, |
||
| 2532 | {AttributeCommonInfo::AS_C2x, "clang::cpu_dispatch"}, |
||
| 2533 | {AttributeCommonInfo::AS_Declspec, "cpu_dispatch"}, |
||
| 2534 | }; |
||
| 2535 | static constexpr const char *CPUDispatchArgNames[] = { |
||
| 2536 | "Cpus...",}; |
||
| 2537 | struct ParsedAttrInfoCPUDispatch final : public ParsedAttrInfo { |
||
| 2538 | constexpr ParsedAttrInfoCPUDispatch() : ParsedAttrInfo( |
||
| 2539 | /*AttrKind=*/ParsedAttr::AT_CPUDispatch, |
||
| 2540 | /*NumArgs=*/0, |
||
| 2541 | /*OptArgs=*/15, |
||
| 2542 | /*NumArgMembers=*/1, |
||
| 2543 | /*HasCustomParsing=*/0, |
||
| 2544 | /*AcceptsExprPack=*/0, |
||
| 2545 | /*IsTargetSpecific=*/0, |
||
| 2546 | /*IsType=*/0, |
||
| 2547 | /*IsStmt=*/0, |
||
| 2548 | /*IsKnownToGCC=*/0, |
||
| 2549 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 2550 | /*Spellings=*/CPUDispatchSpellings, |
||
| 2551 | /*ArgNames=*/CPUDispatchArgNames) {} |
||
| 2552 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 2553 | if (!isa<FunctionDecl>(D)) { |
||
| 2554 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 2555 | << Attr << "functions"; |
||
| 2556 | return false; |
||
| 2557 | } |
||
| 2558 | return true; |
||
| 2559 | } |
||
| 2560 | |||
| 2561 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 2562 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 2563 | << AL << St->getBeginLoc(); |
||
| 2564 | return false; |
||
| 2565 | } |
||
| 2566 | |||
| 2567 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 2568 | |||
| 2569 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 2570 | if (const auto *A = D->getAttr<TargetClonesAttr>()) { |
||
| 2571 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 2572 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 2573 | return false; |
||
| 2574 | } |
||
| 2575 | if (const auto *A = D->getAttr<TargetVersionAttr>()) { |
||
| 2576 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 2577 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 2578 | return false; |
||
| 2579 | } |
||
| 2580 | if (const auto *A = D->getAttr<TargetAttr>()) { |
||
| 2581 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 2582 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 2583 | return false; |
||
| 2584 | } |
||
| 2585 | if (const auto *A = D->getAttr<CPUSpecificAttr>()) { |
||
| 2586 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 2587 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 2588 | return false; |
||
| 2589 | } |
||
| 2590 | return true; |
||
| 2591 | } |
||
| 2592 | |||
| 2593 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 2594 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 2595 | } |
||
| 2596 | |||
| 2597 | bool isParamExpr(size_t N) const override { |
||
| 2598 | return false; |
||
| 2599 | } |
||
| 2600 | |||
| 2601 | static const ParsedAttrInfoCPUDispatch Instance; |
||
| 2602 | }; |
||
| 2603 | const ParsedAttrInfoCPUDispatch ParsedAttrInfoCPUDispatch::Instance; |
||
| 2604 | static constexpr ParsedAttrInfo::Spelling CPUSpecificSpellings[] = { |
||
| 2605 | {AttributeCommonInfo::AS_GNU, "cpu_specific"}, |
||
| 2606 | {AttributeCommonInfo::AS_CXX11, "clang::cpu_specific"}, |
||
| 2607 | {AttributeCommonInfo::AS_C2x, "clang::cpu_specific"}, |
||
| 2608 | {AttributeCommonInfo::AS_Declspec, "cpu_specific"}, |
||
| 2609 | }; |
||
| 2610 | static constexpr const char *CPUSpecificArgNames[] = { |
||
| 2611 | "Cpus...",}; |
||
| 2612 | struct ParsedAttrInfoCPUSpecific final : public ParsedAttrInfo { |
||
| 2613 | constexpr ParsedAttrInfoCPUSpecific() : ParsedAttrInfo( |
||
| 2614 | /*AttrKind=*/ParsedAttr::AT_CPUSpecific, |
||
| 2615 | /*NumArgs=*/0, |
||
| 2616 | /*OptArgs=*/15, |
||
| 2617 | /*NumArgMembers=*/1, |
||
| 2618 | /*HasCustomParsing=*/0, |
||
| 2619 | /*AcceptsExprPack=*/0, |
||
| 2620 | /*IsTargetSpecific=*/0, |
||
| 2621 | /*IsType=*/0, |
||
| 2622 | /*IsStmt=*/0, |
||
| 2623 | /*IsKnownToGCC=*/0, |
||
| 2624 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 2625 | /*Spellings=*/CPUSpecificSpellings, |
||
| 2626 | /*ArgNames=*/CPUSpecificArgNames) {} |
||
| 2627 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 2628 | if (!isa<FunctionDecl>(D)) { |
||
| 2629 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 2630 | << Attr << "functions"; |
||
| 2631 | return false; |
||
| 2632 | } |
||
| 2633 | return true; |
||
| 2634 | } |
||
| 2635 | |||
| 2636 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 2637 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 2638 | << AL << St->getBeginLoc(); |
||
| 2639 | return false; |
||
| 2640 | } |
||
| 2641 | |||
| 2642 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 2643 | |||
| 2644 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 2645 | if (const auto *A = D->getAttr<TargetClonesAttr>()) { |
||
| 2646 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 2647 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 2648 | return false; |
||
| 2649 | } |
||
| 2650 | if (const auto *A = D->getAttr<TargetVersionAttr>()) { |
||
| 2651 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 2652 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 2653 | return false; |
||
| 2654 | } |
||
| 2655 | if (const auto *A = D->getAttr<TargetAttr>()) { |
||
| 2656 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 2657 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 2658 | return false; |
||
| 2659 | } |
||
| 2660 | if (const auto *A = D->getAttr<CPUDispatchAttr>()) { |
||
| 2661 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 2662 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 2663 | return false; |
||
| 2664 | } |
||
| 2665 | return true; |
||
| 2666 | } |
||
| 2667 | |||
| 2668 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 2669 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 2670 | } |
||
| 2671 | |||
| 2672 | bool isParamExpr(size_t N) const override { |
||
| 2673 | return false; |
||
| 2674 | } |
||
| 2675 | |||
| 2676 | static const ParsedAttrInfoCPUSpecific Instance; |
||
| 2677 | }; |
||
| 2678 | const ParsedAttrInfoCPUSpecific ParsedAttrInfoCPUSpecific::Instance; |
||
| 2679 | static constexpr ParsedAttrInfo::Spelling CUDAConstantSpellings[] = { |
||
| 2680 | {AttributeCommonInfo::AS_GNU, "constant"}, |
||
| 2681 | {AttributeCommonInfo::AS_Declspec, "__constant__"}, |
||
| 2682 | }; |
||
| 2683 | struct ParsedAttrInfoCUDAConstant final : public ParsedAttrInfo { |
||
| 2684 | constexpr ParsedAttrInfoCUDAConstant() : ParsedAttrInfo( |
||
| 2685 | /*AttrKind=*/ParsedAttr::AT_CUDAConstant, |
||
| 2686 | /*NumArgs=*/0, |
||
| 2687 | /*OptArgs=*/0, |
||
| 2688 | /*NumArgMembers=*/0, |
||
| 2689 | /*HasCustomParsing=*/0, |
||
| 2690 | /*AcceptsExprPack=*/0, |
||
| 2691 | /*IsTargetSpecific=*/0, |
||
| 2692 | /*IsType=*/0, |
||
| 2693 | /*IsStmt=*/0, |
||
| 2694 | /*IsKnownToGCC=*/0, |
||
| 2695 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 2696 | /*Spellings=*/CUDAConstantSpellings, |
||
| 2697 | /*ArgNames=*/{}) {} |
||
| 2698 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 2699 | if (!isa<VarDecl>(D)) { |
||
| 2700 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 2701 | << Attr << "variables"; |
||
| 2702 | return false; |
||
| 2703 | } |
||
| 2704 | return true; |
||
| 2705 | } |
||
| 2706 | |||
| 2707 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 2708 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 2709 | << AL << St->getBeginLoc(); |
||
| 2710 | return false; |
||
| 2711 | } |
||
| 2712 | |||
| 2713 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 2714 | |||
| 2715 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 2716 | if (const auto *A = D->getAttr<CUDASharedAttr>()) { |
||
| 2717 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 2718 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 2719 | return false; |
||
| 2720 | } |
||
| 2721 | if (const auto *A = D->getAttr<HIPManagedAttr>()) { |
||
| 2722 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 2723 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 2724 | return false; |
||
| 2725 | } |
||
| 2726 | return true; |
||
| 2727 | } |
||
| 2728 | |||
| 2729 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 2730 | return LangOpts.CUDA; |
||
| 2731 | } |
||
| 2732 | |||
| 2733 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 2734 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
||
| 2735 | } |
||
| 2736 | |||
| 2737 | bool isParamExpr(size_t N) const override { |
||
| 2738 | return false; |
||
| 2739 | } |
||
| 2740 | |||
| 2741 | static const ParsedAttrInfoCUDAConstant Instance; |
||
| 2742 | }; |
||
| 2743 | const ParsedAttrInfoCUDAConstant ParsedAttrInfoCUDAConstant::Instance; |
||
| 2744 | static constexpr ParsedAttrInfo::Spelling CUDADeviceSpellings[] = { |
||
| 2745 | {AttributeCommonInfo::AS_GNU, "device"}, |
||
| 2746 | {AttributeCommonInfo::AS_Declspec, "__device__"}, |
||
| 2747 | }; |
||
| 2748 | struct ParsedAttrInfoCUDADevice final : public ParsedAttrInfo { |
||
| 2749 | constexpr ParsedAttrInfoCUDADevice() : ParsedAttrInfo( |
||
| 2750 | /*AttrKind=*/ParsedAttr::AT_CUDADevice, |
||
| 2751 | /*NumArgs=*/0, |
||
| 2752 | /*OptArgs=*/0, |
||
| 2753 | /*NumArgMembers=*/0, |
||
| 2754 | /*HasCustomParsing=*/0, |
||
| 2755 | /*AcceptsExprPack=*/0, |
||
| 2756 | /*IsTargetSpecific=*/0, |
||
| 2757 | /*IsType=*/0, |
||
| 2758 | /*IsStmt=*/0, |
||
| 2759 | /*IsKnownToGCC=*/0, |
||
| 2760 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 2761 | /*Spellings=*/CUDADeviceSpellings, |
||
| 2762 | /*ArgNames=*/{}) {} |
||
| 2763 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 2764 | if (!isa<FunctionDecl>(D) && !isa<VarDecl>(D)) { |
||
| 2765 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 2766 | << Attr << "functions and variables"; |
||
| 2767 | return false; |
||
| 2768 | } |
||
| 2769 | return true; |
||
| 2770 | } |
||
| 2771 | |||
| 2772 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 2773 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 2774 | << AL << St->getBeginLoc(); |
||
| 2775 | return false; |
||
| 2776 | } |
||
| 2777 | |||
| 2778 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 2779 | |||
| 2780 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 2781 | if (const auto *A = D->getAttr<CUDAGlobalAttr>()) { |
||
| 2782 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 2783 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 2784 | return false; |
||
| 2785 | } |
||
| 2786 | return true; |
||
| 2787 | } |
||
| 2788 | |||
| 2789 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 2790 | return LangOpts.CUDA; |
||
| 2791 | } |
||
| 2792 | |||
| 2793 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 2794 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 2795 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
||
| 2796 | } |
||
| 2797 | |||
| 2798 | bool isParamExpr(size_t N) const override { |
||
| 2799 | return false; |
||
| 2800 | } |
||
| 2801 | |||
| 2802 | static const ParsedAttrInfoCUDADevice Instance; |
||
| 2803 | }; |
||
| 2804 | const ParsedAttrInfoCUDADevice ParsedAttrInfoCUDADevice::Instance; |
||
| 2805 | static constexpr ParsedAttrInfo::Spelling CUDADeviceBuiltinSurfaceTypeSpellings[] = { |
||
| 2806 | {AttributeCommonInfo::AS_GNU, "device_builtin_surface_type"}, |
||
| 2807 | {AttributeCommonInfo::AS_Declspec, "__device_builtin_surface_type__"}, |
||
| 2808 | }; |
||
| 2809 | struct ParsedAttrInfoCUDADeviceBuiltinSurfaceType final : public ParsedAttrInfo { |
||
| 2810 | constexpr ParsedAttrInfoCUDADeviceBuiltinSurfaceType() : ParsedAttrInfo( |
||
| 2811 | /*AttrKind=*/ParsedAttr::AT_CUDADeviceBuiltinSurfaceType, |
||
| 2812 | /*NumArgs=*/0, |
||
| 2813 | /*OptArgs=*/0, |
||
| 2814 | /*NumArgMembers=*/0, |
||
| 2815 | /*HasCustomParsing=*/0, |
||
| 2816 | /*AcceptsExprPack=*/0, |
||
| 2817 | /*IsTargetSpecific=*/0, |
||
| 2818 | /*IsType=*/0, |
||
| 2819 | /*IsStmt=*/0, |
||
| 2820 | /*IsKnownToGCC=*/0, |
||
| 2821 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 2822 | /*Spellings=*/CUDADeviceBuiltinSurfaceTypeSpellings, |
||
| 2823 | /*ArgNames=*/{}) {} |
||
| 2824 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 2825 | if (!isa<CXXRecordDecl>(D)) { |
||
| 2826 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 2827 | << Attr << "classes"; |
||
| 2828 | return false; |
||
| 2829 | } |
||
| 2830 | return true; |
||
| 2831 | } |
||
| 2832 | |||
| 2833 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 2834 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 2835 | << AL << St->getBeginLoc(); |
||
| 2836 | return false; |
||
| 2837 | } |
||
| 2838 | |||
| 2839 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 2840 | |||
| 2841 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 2842 | if (const auto *A = D->getAttr<CUDADeviceBuiltinTextureTypeAttr>()) { |
||
| 2843 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 2844 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 2845 | return false; |
||
| 2846 | } |
||
| 2847 | return true; |
||
| 2848 | } |
||
| 2849 | |||
| 2850 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 2851 | return LangOpts.CUDA; |
||
| 2852 | } |
||
| 2853 | |||
| 2854 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 2855 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 2856 | } |
||
| 2857 | |||
| 2858 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 2859 | D->addAttr(::new (S.Context) CUDADeviceBuiltinSurfaceTypeAttr(S.Context, Attr)); |
||
| 2860 | return AttributeApplied; |
||
| 2861 | } |
||
| 2862 | |||
| 2863 | bool isParamExpr(size_t N) const override { |
||
| 2864 | return false; |
||
| 2865 | } |
||
| 2866 | |||
| 2867 | static const ParsedAttrInfoCUDADeviceBuiltinSurfaceType Instance; |
||
| 2868 | }; |
||
| 2869 | const ParsedAttrInfoCUDADeviceBuiltinSurfaceType ParsedAttrInfoCUDADeviceBuiltinSurfaceType::Instance; |
||
| 2870 | static constexpr ParsedAttrInfo::Spelling CUDADeviceBuiltinTextureTypeSpellings[] = { |
||
| 2871 | {AttributeCommonInfo::AS_GNU, "device_builtin_texture_type"}, |
||
| 2872 | {AttributeCommonInfo::AS_Declspec, "__device_builtin_texture_type__"}, |
||
| 2873 | }; |
||
| 2874 | struct ParsedAttrInfoCUDADeviceBuiltinTextureType final : public ParsedAttrInfo { |
||
| 2875 | constexpr ParsedAttrInfoCUDADeviceBuiltinTextureType() : ParsedAttrInfo( |
||
| 2876 | /*AttrKind=*/ParsedAttr::AT_CUDADeviceBuiltinTextureType, |
||
| 2877 | /*NumArgs=*/0, |
||
| 2878 | /*OptArgs=*/0, |
||
| 2879 | /*NumArgMembers=*/0, |
||
| 2880 | /*HasCustomParsing=*/0, |
||
| 2881 | /*AcceptsExprPack=*/0, |
||
| 2882 | /*IsTargetSpecific=*/0, |
||
| 2883 | /*IsType=*/0, |
||
| 2884 | /*IsStmt=*/0, |
||
| 2885 | /*IsKnownToGCC=*/0, |
||
| 2886 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 2887 | /*Spellings=*/CUDADeviceBuiltinTextureTypeSpellings, |
||
| 2888 | /*ArgNames=*/{}) {} |
||
| 2889 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 2890 | if (!isa<CXXRecordDecl>(D)) { |
||
| 2891 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 2892 | << Attr << "classes"; |
||
| 2893 | return false; |
||
| 2894 | } |
||
| 2895 | return true; |
||
| 2896 | } |
||
| 2897 | |||
| 2898 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 2899 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 2900 | << AL << St->getBeginLoc(); |
||
| 2901 | return false; |
||
| 2902 | } |
||
| 2903 | |||
| 2904 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 2905 | |||
| 2906 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 2907 | if (const auto *A = D->getAttr<CUDADeviceBuiltinSurfaceTypeAttr>()) { |
||
| 2908 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 2909 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 2910 | return false; |
||
| 2911 | } |
||
| 2912 | return true; |
||
| 2913 | } |
||
| 2914 | |||
| 2915 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 2916 | return LangOpts.CUDA; |
||
| 2917 | } |
||
| 2918 | |||
| 2919 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 2920 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 2921 | } |
||
| 2922 | |||
| 2923 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 2924 | D->addAttr(::new (S.Context) CUDADeviceBuiltinTextureTypeAttr(S.Context, Attr)); |
||
| 2925 | return AttributeApplied; |
||
| 2926 | } |
||
| 2927 | |||
| 2928 | bool isParamExpr(size_t N) const override { |
||
| 2929 | return false; |
||
| 2930 | } |
||
| 2931 | |||
| 2932 | static const ParsedAttrInfoCUDADeviceBuiltinTextureType Instance; |
||
| 2933 | }; |
||
| 2934 | const ParsedAttrInfoCUDADeviceBuiltinTextureType ParsedAttrInfoCUDADeviceBuiltinTextureType::Instance; |
||
| 2935 | static constexpr ParsedAttrInfo::Spelling CUDAGlobalSpellings[] = { |
||
| 2936 | {AttributeCommonInfo::AS_GNU, "global"}, |
||
| 2937 | {AttributeCommonInfo::AS_Declspec, "__global__"}, |
||
| 2938 | }; |
||
| 2939 | struct ParsedAttrInfoCUDAGlobal final : public ParsedAttrInfo { |
||
| 2940 | constexpr ParsedAttrInfoCUDAGlobal() : ParsedAttrInfo( |
||
| 2941 | /*AttrKind=*/ParsedAttr::AT_CUDAGlobal, |
||
| 2942 | /*NumArgs=*/0, |
||
| 2943 | /*OptArgs=*/0, |
||
| 2944 | /*NumArgMembers=*/0, |
||
| 2945 | /*HasCustomParsing=*/0, |
||
| 2946 | /*AcceptsExprPack=*/0, |
||
| 2947 | /*IsTargetSpecific=*/0, |
||
| 2948 | /*IsType=*/0, |
||
| 2949 | /*IsStmt=*/0, |
||
| 2950 | /*IsKnownToGCC=*/0, |
||
| 2951 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 2952 | /*Spellings=*/CUDAGlobalSpellings, |
||
| 2953 | /*ArgNames=*/{}) {} |
||
| 2954 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 2955 | if (!isa<FunctionDecl>(D)) { |
||
| 2956 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 2957 | << Attr << "functions"; |
||
| 2958 | return false; |
||
| 2959 | } |
||
| 2960 | return true; |
||
| 2961 | } |
||
| 2962 | |||
| 2963 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 2964 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 2965 | << AL << St->getBeginLoc(); |
||
| 2966 | return false; |
||
| 2967 | } |
||
| 2968 | |||
| 2969 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 2970 | |||
| 2971 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 2972 | if (const auto *A = D->getAttr<CUDADeviceAttr>()) { |
||
| 2973 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 2974 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 2975 | return false; |
||
| 2976 | } |
||
| 2977 | if (const auto *A = D->getAttr<CUDAHostAttr>()) { |
||
| 2978 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 2979 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 2980 | return false; |
||
| 2981 | } |
||
| 2982 | return true; |
||
| 2983 | } |
||
| 2984 | |||
| 2985 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 2986 | return LangOpts.CUDA; |
||
| 2987 | } |
||
| 2988 | |||
| 2989 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 2990 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 2991 | } |
||
| 2992 | |||
| 2993 | bool isParamExpr(size_t N) const override { |
||
| 2994 | return false; |
||
| 2995 | } |
||
| 2996 | |||
| 2997 | static const ParsedAttrInfoCUDAGlobal Instance; |
||
| 2998 | }; |
||
| 2999 | const ParsedAttrInfoCUDAGlobal ParsedAttrInfoCUDAGlobal::Instance; |
||
| 3000 | static constexpr ParsedAttrInfo::Spelling CUDAHostSpellings[] = { |
||
| 3001 | {AttributeCommonInfo::AS_GNU, "host"}, |
||
| 3002 | {AttributeCommonInfo::AS_Declspec, "__host__"}, |
||
| 3003 | }; |
||
| 3004 | struct ParsedAttrInfoCUDAHost final : public ParsedAttrInfo { |
||
| 3005 | constexpr ParsedAttrInfoCUDAHost() : ParsedAttrInfo( |
||
| 3006 | /*AttrKind=*/ParsedAttr::AT_CUDAHost, |
||
| 3007 | /*NumArgs=*/0, |
||
| 3008 | /*OptArgs=*/0, |
||
| 3009 | /*NumArgMembers=*/0, |
||
| 3010 | /*HasCustomParsing=*/0, |
||
| 3011 | /*AcceptsExprPack=*/0, |
||
| 3012 | /*IsTargetSpecific=*/0, |
||
| 3013 | /*IsType=*/0, |
||
| 3014 | /*IsStmt=*/0, |
||
| 3015 | /*IsKnownToGCC=*/0, |
||
| 3016 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 3017 | /*Spellings=*/CUDAHostSpellings, |
||
| 3018 | /*ArgNames=*/{}) {} |
||
| 3019 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 3020 | if (!isa<FunctionDecl>(D)) { |
||
| 3021 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 3022 | << Attr << "functions"; |
||
| 3023 | return false; |
||
| 3024 | } |
||
| 3025 | return true; |
||
| 3026 | } |
||
| 3027 | |||
| 3028 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 3029 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 3030 | << AL << St->getBeginLoc(); |
||
| 3031 | return false; |
||
| 3032 | } |
||
| 3033 | |||
| 3034 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 3035 | |||
| 3036 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 3037 | if (const auto *A = D->getAttr<CUDAGlobalAttr>()) { |
||
| 3038 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 3039 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 3040 | return false; |
||
| 3041 | } |
||
| 3042 | return true; |
||
| 3043 | } |
||
| 3044 | |||
| 3045 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 3046 | return LangOpts.CUDA; |
||
| 3047 | } |
||
| 3048 | |||
| 3049 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 3050 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 3051 | } |
||
| 3052 | |||
| 3053 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 3054 | D->addAttr(::new (S.Context) CUDAHostAttr(S.Context, Attr)); |
||
| 3055 | return AttributeApplied; |
||
| 3056 | } |
||
| 3057 | |||
| 3058 | bool isParamExpr(size_t N) const override { |
||
| 3059 | return false; |
||
| 3060 | } |
||
| 3061 | |||
| 3062 | static const ParsedAttrInfoCUDAHost Instance; |
||
| 3063 | }; |
||
| 3064 | const ParsedAttrInfoCUDAHost ParsedAttrInfoCUDAHost::Instance; |
||
| 3065 | struct ParsedAttrInfoCUDAInvalidTarget final : public ParsedAttrInfo { |
||
| 3066 | constexpr ParsedAttrInfoCUDAInvalidTarget() : ParsedAttrInfo( |
||
| 3067 | /*AttrKind=*/ParsedAttr::AT_CUDAInvalidTarget, |
||
| 3068 | /*NumArgs=*/0, |
||
| 3069 | /*OptArgs=*/0, |
||
| 3070 | /*NumArgMembers=*/0, |
||
| 3071 | /*HasCustomParsing=*/0, |
||
| 3072 | /*AcceptsExprPack=*/0, |
||
| 3073 | /*IsTargetSpecific=*/0, |
||
| 3074 | /*IsType=*/0, |
||
| 3075 | /*IsStmt=*/0, |
||
| 3076 | /*IsKnownToGCC=*/0, |
||
| 3077 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 3078 | /*Spellings=*/{}, |
||
| 3079 | /*ArgNames=*/{}) {} |
||
| 3080 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 3081 | if (!isa<FunctionDecl>(D)) { |
||
| 3082 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 3083 | << Attr << "functions"; |
||
| 3084 | return false; |
||
| 3085 | } |
||
| 3086 | return true; |
||
| 3087 | } |
||
| 3088 | |||
| 3089 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 3090 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 3091 | << AL << St->getBeginLoc(); |
||
| 3092 | return false; |
||
| 3093 | } |
||
| 3094 | |||
| 3095 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 3096 | return LangOpts.CUDA; |
||
| 3097 | } |
||
| 3098 | |||
| 3099 | bool isParamExpr(size_t N) const override { |
||
| 3100 | return false; |
||
| 3101 | } |
||
| 3102 | |||
| 3103 | static const ParsedAttrInfoCUDAInvalidTarget Instance; |
||
| 3104 | }; |
||
| 3105 | const ParsedAttrInfoCUDAInvalidTarget ParsedAttrInfoCUDAInvalidTarget::Instance; |
||
| 3106 | static constexpr ParsedAttrInfo::Spelling CUDALaunchBoundsSpellings[] = { |
||
| 3107 | {AttributeCommonInfo::AS_GNU, "launch_bounds"}, |
||
| 3108 | {AttributeCommonInfo::AS_Declspec, "__launch_bounds__"}, |
||
| 3109 | }; |
||
| 3110 | static constexpr const char *CUDALaunchBoundsArgNames[] = { |
||
| 3111 | "MaxThreads","MinBlocks",}; |
||
| 3112 | struct ParsedAttrInfoCUDALaunchBounds final : public ParsedAttrInfo { |
||
| 3113 | constexpr ParsedAttrInfoCUDALaunchBounds() : ParsedAttrInfo( |
||
| 3114 | /*AttrKind=*/ParsedAttr::AT_CUDALaunchBounds, |
||
| 3115 | /*NumArgs=*/1, |
||
| 3116 | /*OptArgs=*/1, |
||
| 3117 | /*NumArgMembers=*/2, |
||
| 3118 | /*HasCustomParsing=*/0, |
||
| 3119 | /*AcceptsExprPack=*/0, |
||
| 3120 | /*IsTargetSpecific=*/0, |
||
| 3121 | /*IsType=*/0, |
||
| 3122 | /*IsStmt=*/0, |
||
| 3123 | /*IsKnownToGCC=*/0, |
||
| 3124 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 3125 | /*Spellings=*/CUDALaunchBoundsSpellings, |
||
| 3126 | /*ArgNames=*/CUDALaunchBoundsArgNames) {} |
||
| 3127 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 3128 | if (!isa<ObjCMethodDecl>(D) && !isFunctionLike(D)) { |
||
| 3129 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 3130 | << Attr << "Objective-C methods, functions, and function pointers"; |
||
| 3131 | return false; |
||
| 3132 | } |
||
| 3133 | return true; |
||
| 3134 | } |
||
| 3135 | |||
| 3136 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 3137 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 3138 | << AL << St->getBeginLoc(); |
||
| 3139 | return false; |
||
| 3140 | } |
||
| 3141 | |||
| 3142 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 3143 | return LangOpts.CUDA; |
||
| 3144 | } |
||
| 3145 | |||
| 3146 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 3147 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 3148 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_hasType_functionType, /*IsSupported=*/true)); |
||
| 3149 | } |
||
| 3150 | |||
| 3151 | bool isParamExpr(size_t N) const override { |
||
| 3152 | return (N == 0) || (N == 1) || false; |
||
| 3153 | } |
||
| 3154 | |||
| 3155 | static const ParsedAttrInfoCUDALaunchBounds Instance; |
||
| 3156 | }; |
||
| 3157 | const ParsedAttrInfoCUDALaunchBounds ParsedAttrInfoCUDALaunchBounds::Instance; |
||
| 3158 | static constexpr ParsedAttrInfo::Spelling CUDASharedSpellings[] = { |
||
| 3159 | {AttributeCommonInfo::AS_GNU, "shared"}, |
||
| 3160 | {AttributeCommonInfo::AS_Declspec, "__shared__"}, |
||
| 3161 | }; |
||
| 3162 | struct ParsedAttrInfoCUDAShared final : public ParsedAttrInfo { |
||
| 3163 | constexpr ParsedAttrInfoCUDAShared() : ParsedAttrInfo( |
||
| 3164 | /*AttrKind=*/ParsedAttr::AT_CUDAShared, |
||
| 3165 | /*NumArgs=*/0, |
||
| 3166 | /*OptArgs=*/0, |
||
| 3167 | /*NumArgMembers=*/0, |
||
| 3168 | /*HasCustomParsing=*/0, |
||
| 3169 | /*AcceptsExprPack=*/0, |
||
| 3170 | /*IsTargetSpecific=*/0, |
||
| 3171 | /*IsType=*/0, |
||
| 3172 | /*IsStmt=*/0, |
||
| 3173 | /*IsKnownToGCC=*/0, |
||
| 3174 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 3175 | /*Spellings=*/CUDASharedSpellings, |
||
| 3176 | /*ArgNames=*/{}) {} |
||
| 3177 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 3178 | if (!isa<VarDecl>(D)) { |
||
| 3179 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 3180 | << Attr << "variables"; |
||
| 3181 | return false; |
||
| 3182 | } |
||
| 3183 | return true; |
||
| 3184 | } |
||
| 3185 | |||
| 3186 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 3187 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 3188 | << AL << St->getBeginLoc(); |
||
| 3189 | return false; |
||
| 3190 | } |
||
| 3191 | |||
| 3192 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 3193 | |||
| 3194 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 3195 | if (const auto *A = D->getAttr<CUDAConstantAttr>()) { |
||
| 3196 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 3197 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 3198 | return false; |
||
| 3199 | } |
||
| 3200 | if (const auto *A = D->getAttr<HIPManagedAttr>()) { |
||
| 3201 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 3202 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 3203 | return false; |
||
| 3204 | } |
||
| 3205 | return true; |
||
| 3206 | } |
||
| 3207 | |||
| 3208 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 3209 | return LangOpts.CUDA; |
||
| 3210 | } |
||
| 3211 | |||
| 3212 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 3213 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
||
| 3214 | } |
||
| 3215 | |||
| 3216 | bool isParamExpr(size_t N) const override { |
||
| 3217 | return false; |
||
| 3218 | } |
||
| 3219 | |||
| 3220 | static const ParsedAttrInfoCUDAShared Instance; |
||
| 3221 | }; |
||
| 3222 | const ParsedAttrInfoCUDAShared ParsedAttrInfoCUDAShared::Instance; |
||
| 3223 | static constexpr ParsedAttrInfo::Spelling CXX11NoReturnSpellings[] = { |
||
| 3224 | {AttributeCommonInfo::AS_CXX11, "noreturn"}, |
||
| 3225 | {AttributeCommonInfo::AS_C2x, "noreturn"}, |
||
| 3226 | {AttributeCommonInfo::AS_C2x, "_Noreturn"}, |
||
| 3227 | }; |
||
| 3228 | struct ParsedAttrInfoCXX11NoReturn final : public ParsedAttrInfo { |
||
| 3229 | constexpr ParsedAttrInfoCXX11NoReturn() : ParsedAttrInfo( |
||
| 3230 | /*AttrKind=*/ParsedAttr::AT_CXX11NoReturn, |
||
| 3231 | /*NumArgs=*/0, |
||
| 3232 | /*OptArgs=*/0, |
||
| 3233 | /*NumArgMembers=*/0, |
||
| 3234 | /*HasCustomParsing=*/0, |
||
| 3235 | /*AcceptsExprPack=*/0, |
||
| 3236 | /*IsTargetSpecific=*/0, |
||
| 3237 | /*IsType=*/0, |
||
| 3238 | /*IsStmt=*/0, |
||
| 3239 | /*IsKnownToGCC=*/0, |
||
| 3240 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 3241 | /*Spellings=*/CXX11NoReturnSpellings, |
||
| 3242 | /*ArgNames=*/{}) {} |
||
| 3243 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 3244 | if (!isa<FunctionDecl>(D)) { |
||
| 3245 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 3246 | << Attr << "functions"; |
||
| 3247 | return false; |
||
| 3248 | } |
||
| 3249 | return true; |
||
| 3250 | } |
||
| 3251 | |||
| 3252 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 3253 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 3254 | << AL << St->getBeginLoc(); |
||
| 3255 | return false; |
||
| 3256 | } |
||
| 3257 | |||
| 3258 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 3259 | enum Spelling { |
||
| 3260 | CXX11_noreturn = 0, |
||
| 3261 | C2x_noreturn = 1, |
||
| 3262 | C2x_Noreturn = 2, |
||
| 3263 | SpellingNotCalculated = 15 |
||
| 3264 | |||
| 3265 | }; |
||
| 3266 | |||
| 3267 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 3268 | switch (Idx) { |
||
| 3269 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 3270 | case 0: return CXX11_noreturn; |
||
| 3271 | case 1: return C2x_noreturn; |
||
| 3272 | case 2: return C2x_Noreturn; |
||
| 3273 | } |
||
| 3274 | } |
||
| 3275 | |||
| 3276 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 3277 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 3278 | } |
||
| 3279 | |||
| 3280 | bool isParamExpr(size_t N) const override { |
||
| 3281 | return false; |
||
| 3282 | } |
||
| 3283 | |||
| 3284 | static const ParsedAttrInfoCXX11NoReturn Instance; |
||
| 3285 | }; |
||
| 3286 | const ParsedAttrInfoCXX11NoReturn ParsedAttrInfoCXX11NoReturn::Instance; |
||
| 3287 | static constexpr ParsedAttrInfo::Spelling CallableWhenSpellings[] = { |
||
| 3288 | {AttributeCommonInfo::AS_GNU, "callable_when"}, |
||
| 3289 | {AttributeCommonInfo::AS_CXX11, "clang::callable_when"}, |
||
| 3290 | }; |
||
| 3291 | static constexpr const char *CallableWhenArgNames[] = { |
||
| 3292 | "CallableStates...",}; |
||
| 3293 | struct ParsedAttrInfoCallableWhen final : public ParsedAttrInfo { |
||
| 3294 | constexpr ParsedAttrInfoCallableWhen() : ParsedAttrInfo( |
||
| 3295 | /*AttrKind=*/ParsedAttr::AT_CallableWhen, |
||
| 3296 | /*NumArgs=*/0, |
||
| 3297 | /*OptArgs=*/15, |
||
| 3298 | /*NumArgMembers=*/1, |
||
| 3299 | /*HasCustomParsing=*/0, |
||
| 3300 | /*AcceptsExprPack=*/0, |
||
| 3301 | /*IsTargetSpecific=*/0, |
||
| 3302 | /*IsType=*/0, |
||
| 3303 | /*IsStmt=*/0, |
||
| 3304 | /*IsKnownToGCC=*/0, |
||
| 3305 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 3306 | /*Spellings=*/CallableWhenSpellings, |
||
| 3307 | /*ArgNames=*/CallableWhenArgNames) {} |
||
| 3308 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 3309 | if (!isa<CXXMethodDecl>(D)) { |
||
| 3310 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 3311 | << Attr << "functions"; |
||
| 3312 | return false; |
||
| 3313 | } |
||
| 3314 | return true; |
||
| 3315 | } |
||
| 3316 | |||
| 3317 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 3318 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 3319 | << AL << St->getBeginLoc(); |
||
| 3320 | return false; |
||
| 3321 | } |
||
| 3322 | |||
| 3323 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 3324 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function_is_member, /*IsSupported=*/LangOpts.CPlusPlus)); |
||
| 3325 | } |
||
| 3326 | |||
| 3327 | bool isParamExpr(size_t N) const override { |
||
| 3328 | return false; |
||
| 3329 | } |
||
| 3330 | |||
| 3331 | static const ParsedAttrInfoCallableWhen Instance; |
||
| 3332 | }; |
||
| 3333 | const ParsedAttrInfoCallableWhen ParsedAttrInfoCallableWhen::Instance; |
||
| 3334 | static constexpr ParsedAttrInfo::Spelling CallbackSpellings[] = { |
||
| 3335 | {AttributeCommonInfo::AS_GNU, "callback"}, |
||
| 3336 | {AttributeCommonInfo::AS_CXX11, "clang::callback"}, |
||
| 3337 | {AttributeCommonInfo::AS_C2x, "clang::callback"}, |
||
| 3338 | }; |
||
| 3339 | static constexpr const char *CallbackArgNames[] = { |
||
| 3340 | "Encoding...",}; |
||
| 3341 | struct ParsedAttrInfoCallback final : public ParsedAttrInfo { |
||
| 3342 | constexpr ParsedAttrInfoCallback() : ParsedAttrInfo( |
||
| 3343 | /*AttrKind=*/ParsedAttr::AT_Callback, |
||
| 3344 | /*NumArgs=*/0, |
||
| 3345 | /*OptArgs=*/15, |
||
| 3346 | /*NumArgMembers=*/1, |
||
| 3347 | /*HasCustomParsing=*/0, |
||
| 3348 | /*AcceptsExprPack=*/0, |
||
| 3349 | /*IsTargetSpecific=*/0, |
||
| 3350 | /*IsType=*/0, |
||
| 3351 | /*IsStmt=*/0, |
||
| 3352 | /*IsKnownToGCC=*/0, |
||
| 3353 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 3354 | /*Spellings=*/CallbackSpellings, |
||
| 3355 | /*ArgNames=*/CallbackArgNames) {} |
||
| 3356 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 3357 | if (!isa<FunctionDecl>(D)) { |
||
| 3358 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 3359 | << Attr << "functions"; |
||
| 3360 | return false; |
||
| 3361 | } |
||
| 3362 | return true; |
||
| 3363 | } |
||
| 3364 | |||
| 3365 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 3366 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 3367 | << AL << St->getBeginLoc(); |
||
| 3368 | return false; |
||
| 3369 | } |
||
| 3370 | |||
| 3371 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 3372 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 3373 | } |
||
| 3374 | |||
| 3375 | bool isParamExpr(size_t N) const override { |
||
| 3376 | return false; |
||
| 3377 | } |
||
| 3378 | |||
| 3379 | static const ParsedAttrInfoCallback Instance; |
||
| 3380 | }; |
||
| 3381 | const ParsedAttrInfoCallback ParsedAttrInfoCallback::Instance; |
||
| 3382 | static constexpr ParsedAttrInfo::Spelling CalledOnceSpellings[] = { |
||
| 3383 | {AttributeCommonInfo::AS_GNU, "called_once"}, |
||
| 3384 | {AttributeCommonInfo::AS_CXX11, "clang::called_once"}, |
||
| 3385 | {AttributeCommonInfo::AS_C2x, "clang::called_once"}, |
||
| 3386 | }; |
||
| 3387 | struct ParsedAttrInfoCalledOnce final : public ParsedAttrInfo { |
||
| 3388 | constexpr ParsedAttrInfoCalledOnce() : ParsedAttrInfo( |
||
| 3389 | /*AttrKind=*/ParsedAttr::AT_CalledOnce, |
||
| 3390 | /*NumArgs=*/0, |
||
| 3391 | /*OptArgs=*/0, |
||
| 3392 | /*NumArgMembers=*/0, |
||
| 3393 | /*HasCustomParsing=*/0, |
||
| 3394 | /*AcceptsExprPack=*/0, |
||
| 3395 | /*IsTargetSpecific=*/0, |
||
| 3396 | /*IsType=*/0, |
||
| 3397 | /*IsStmt=*/0, |
||
| 3398 | /*IsKnownToGCC=*/0, |
||
| 3399 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 3400 | /*Spellings=*/CalledOnceSpellings, |
||
| 3401 | /*ArgNames=*/{}) {} |
||
| 3402 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 3403 | if (!isa<ParmVarDecl>(D)) { |
||
| 3404 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 3405 | << Attr << "parameters"; |
||
| 3406 | return false; |
||
| 3407 | } |
||
| 3408 | return true; |
||
| 3409 | } |
||
| 3410 | |||
| 3411 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 3412 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 3413 | << AL << St->getBeginLoc(); |
||
| 3414 | return false; |
||
| 3415 | } |
||
| 3416 | |||
| 3417 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 3418 | return LangOpts.ObjC; |
||
| 3419 | } |
||
| 3420 | |||
| 3421 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 3422 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
||
| 3423 | } |
||
| 3424 | |||
| 3425 | bool isParamExpr(size_t N) const override { |
||
| 3426 | return false; |
||
| 3427 | } |
||
| 3428 | |||
| 3429 | static const ParsedAttrInfoCalledOnce Instance; |
||
| 3430 | }; |
||
| 3431 | const ParsedAttrInfoCalledOnce ParsedAttrInfoCalledOnce::Instance; |
||
| 3432 | static constexpr ParsedAttrInfo::Spelling CapabilitySpellings[] = { |
||
| 3433 | {AttributeCommonInfo::AS_GNU, "capability"}, |
||
| 3434 | {AttributeCommonInfo::AS_CXX11, "clang::capability"}, |
||
| 3435 | {AttributeCommonInfo::AS_GNU, "shared_capability"}, |
||
| 3436 | {AttributeCommonInfo::AS_CXX11, "clang::shared_capability"}, |
||
| 3437 | }; |
||
| 3438 | static constexpr const char *CapabilityArgNames[] = { |
||
| 3439 | "Name",}; |
||
| 3440 | struct ParsedAttrInfoCapability final : public ParsedAttrInfo { |
||
| 3441 | constexpr ParsedAttrInfoCapability() : ParsedAttrInfo( |
||
| 3442 | /*AttrKind=*/ParsedAttr::AT_Capability, |
||
| 3443 | /*NumArgs=*/1, |
||
| 3444 | /*OptArgs=*/0, |
||
| 3445 | /*NumArgMembers=*/1, |
||
| 3446 | /*HasCustomParsing=*/0, |
||
| 3447 | /*AcceptsExprPack=*/0, |
||
| 3448 | /*IsTargetSpecific=*/0, |
||
| 3449 | /*IsType=*/0, |
||
| 3450 | /*IsStmt=*/0, |
||
| 3451 | /*IsKnownToGCC=*/0, |
||
| 3452 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 3453 | /*Spellings=*/CapabilitySpellings, |
||
| 3454 | /*ArgNames=*/CapabilityArgNames) {} |
||
| 3455 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 3456 | if (!isa<RecordDecl>(D) && !isa<TypedefNameDecl>(D)) { |
||
| 3457 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 3458 | << Attr << "structs, unions, classes, and typedefs"; |
||
| 3459 | return false; |
||
| 3460 | } |
||
| 3461 | return true; |
||
| 3462 | } |
||
| 3463 | |||
| 3464 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 3465 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 3466 | << AL << St->getBeginLoc(); |
||
| 3467 | return false; |
||
| 3468 | } |
||
| 3469 | |||
| 3470 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 3471 | enum Spelling { |
||
| 3472 | GNU_capability = 0, |
||
| 3473 | CXX11_clang_capability = 1, |
||
| 3474 | GNU_shared_capability = 2, |
||
| 3475 | CXX11_clang_shared_capability = 3, |
||
| 3476 | SpellingNotCalculated = 15 |
||
| 3477 | |||
| 3478 | }; |
||
| 3479 | |||
| 3480 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 3481 | switch (Idx) { |
||
| 3482 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 3483 | case 0: return GNU_capability; |
||
| 3484 | case 1: return CXX11_clang_capability; |
||
| 3485 | case 2: return GNU_shared_capability; |
||
| 3486 | case 3: return CXX11_clang_shared_capability; |
||
| 3487 | } |
||
| 3488 | } |
||
| 3489 | |||
| 3490 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 3491 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 3492 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true)); |
||
| 3493 | } |
||
| 3494 | |||
| 3495 | bool isParamExpr(size_t N) const override { |
||
| 3496 | return false; |
||
| 3497 | } |
||
| 3498 | |||
| 3499 | static const ParsedAttrInfoCapability Instance; |
||
| 3500 | }; |
||
| 3501 | const ParsedAttrInfoCapability ParsedAttrInfoCapability::Instance; |
||
| 3502 | static constexpr ParsedAttrInfo::Spelling CarriesDependencySpellings[] = { |
||
| 3503 | {AttributeCommonInfo::AS_GNU, "carries_dependency"}, |
||
| 3504 | {AttributeCommonInfo::AS_CXX11, "carries_dependency"}, |
||
| 3505 | }; |
||
| 3506 | struct ParsedAttrInfoCarriesDependency final : public ParsedAttrInfo { |
||
| 3507 | constexpr ParsedAttrInfoCarriesDependency() : ParsedAttrInfo( |
||
| 3508 | /*AttrKind=*/ParsedAttr::AT_CarriesDependency, |
||
| 3509 | /*NumArgs=*/0, |
||
| 3510 | /*OptArgs=*/0, |
||
| 3511 | /*NumArgMembers=*/0, |
||
| 3512 | /*HasCustomParsing=*/0, |
||
| 3513 | /*AcceptsExprPack=*/0, |
||
| 3514 | /*IsTargetSpecific=*/0, |
||
| 3515 | /*IsType=*/0, |
||
| 3516 | /*IsStmt=*/0, |
||
| 3517 | /*IsKnownToGCC=*/0, |
||
| 3518 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 3519 | /*Spellings=*/CarriesDependencySpellings, |
||
| 3520 | /*ArgNames=*/{}) {} |
||
| 3521 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 3522 | if (!isa<ParmVarDecl>(D) && !isa<ObjCMethodDecl>(D) && !isa<FunctionDecl>(D)) { |
||
| 3523 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 3524 | << Attr << "parameters, Objective-C methods, and functions"; |
||
| 3525 | return false; |
||
| 3526 | } |
||
| 3527 | return true; |
||
| 3528 | } |
||
| 3529 | |||
| 3530 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 3531 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 3532 | << AL << St->getBeginLoc(); |
||
| 3533 | return false; |
||
| 3534 | } |
||
| 3535 | |||
| 3536 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 3537 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
||
| 3538 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 3539 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 3540 | } |
||
| 3541 | |||
| 3542 | bool isParamExpr(size_t N) const override { |
||
| 3543 | return false; |
||
| 3544 | } |
||
| 3545 | |||
| 3546 | static const ParsedAttrInfoCarriesDependency Instance; |
||
| 3547 | }; |
||
| 3548 | const ParsedAttrInfoCarriesDependency ParsedAttrInfoCarriesDependency::Instance; |
||
| 3549 | static constexpr ParsedAttrInfo::Spelling CleanupSpellings[] = { |
||
| 3550 | {AttributeCommonInfo::AS_GNU, "cleanup"}, |
||
| 3551 | {AttributeCommonInfo::AS_CXX11, "gnu::cleanup"}, |
||
| 3552 | {AttributeCommonInfo::AS_C2x, "gnu::cleanup"}, |
||
| 3553 | }; |
||
| 3554 | static constexpr const char *CleanupArgNames[] = { |
||
| 3555 | "FunctionDecl",}; |
||
| 3556 | struct ParsedAttrInfoCleanup final : public ParsedAttrInfo { |
||
| 3557 | constexpr ParsedAttrInfoCleanup() : ParsedAttrInfo( |
||
| 3558 | /*AttrKind=*/ParsedAttr::AT_Cleanup, |
||
| 3559 | /*NumArgs=*/1, |
||
| 3560 | /*OptArgs=*/0, |
||
| 3561 | /*NumArgMembers=*/1, |
||
| 3562 | /*HasCustomParsing=*/0, |
||
| 3563 | /*AcceptsExprPack=*/0, |
||
| 3564 | /*IsTargetSpecific=*/0, |
||
| 3565 | /*IsType=*/0, |
||
| 3566 | /*IsStmt=*/0, |
||
| 3567 | /*IsKnownToGCC=*/1, |
||
| 3568 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 3569 | /*Spellings=*/CleanupSpellings, |
||
| 3570 | /*ArgNames=*/CleanupArgNames) {} |
||
| 3571 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 3572 | if (!isLocalVar(D)) { |
||
| 3573 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 3574 | << Attr << "local variables"; |
||
| 3575 | return false; |
||
| 3576 | } |
||
| 3577 | return true; |
||
| 3578 | } |
||
| 3579 | |||
| 3580 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 3581 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 3582 | << AL << St->getBeginLoc(); |
||
| 3583 | return false; |
||
| 3584 | } |
||
| 3585 | |||
| 3586 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 3587 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_local, /*IsSupported=*/true)); |
||
| 3588 | } |
||
| 3589 | |||
| 3590 | bool isParamExpr(size_t N) const override { |
||
| 3591 | return false; |
||
| 3592 | } |
||
| 3593 | |||
| 3594 | static const ParsedAttrInfoCleanup Instance; |
||
| 3595 | }; |
||
| 3596 | const ParsedAttrInfoCleanup ParsedAttrInfoCleanup::Instance; |
||
| 3597 | static constexpr ParsedAttrInfo::Spelling CmseNSCallSpellings[] = { |
||
| 3598 | {AttributeCommonInfo::AS_GNU, "cmse_nonsecure_call"}, |
||
| 3599 | }; |
||
| 3600 | struct ParsedAttrInfoCmseNSCall final : public ParsedAttrInfo { |
||
| 3601 | constexpr ParsedAttrInfoCmseNSCall() : ParsedAttrInfo( |
||
| 3602 | /*AttrKind=*/ParsedAttr::AT_CmseNSCall, |
||
| 3603 | /*NumArgs=*/0, |
||
| 3604 | /*OptArgs=*/0, |
||
| 3605 | /*NumArgMembers=*/0, |
||
| 3606 | /*HasCustomParsing=*/0, |
||
| 3607 | /*AcceptsExprPack=*/0, |
||
| 3608 | /*IsTargetSpecific=*/1, |
||
| 3609 | /*IsType=*/1, |
||
| 3610 | /*IsStmt=*/0, |
||
| 3611 | /*IsKnownToGCC=*/0, |
||
| 3612 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 3613 | /*Spellings=*/CmseNSCallSpellings, |
||
| 3614 | /*ArgNames=*/{}) {} |
||
| 3615 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 3616 | return LangOpts.Cmse; |
||
| 3617 | } |
||
| 3618 | |||
| 3619 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 3620 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 3621 | return true && (T.getArch() == llvm::Triple::arm || T.getArch() == llvm::Triple::thumb || T.getArch() == llvm::Triple::armeb || T.getArch() == llvm::Triple::thumbeb); |
||
| 3622 | } |
||
| 3623 | |||
| 3624 | bool isParamExpr(size_t N) const override { |
||
| 3625 | return false; |
||
| 3626 | } |
||
| 3627 | |||
| 3628 | static const ParsedAttrInfoCmseNSCall Instance; |
||
| 3629 | }; |
||
| 3630 | const ParsedAttrInfoCmseNSCall ParsedAttrInfoCmseNSCall::Instance; |
||
| 3631 | static constexpr ParsedAttrInfo::Spelling CmseNSEntrySpellings[] = { |
||
| 3632 | {AttributeCommonInfo::AS_GNU, "cmse_nonsecure_entry"}, |
||
| 3633 | }; |
||
| 3634 | struct ParsedAttrInfoCmseNSEntry final : public ParsedAttrInfo { |
||
| 3635 | constexpr ParsedAttrInfoCmseNSEntry() : ParsedAttrInfo( |
||
| 3636 | /*AttrKind=*/ParsedAttr::AT_CmseNSEntry, |
||
| 3637 | /*NumArgs=*/0, |
||
| 3638 | /*OptArgs=*/0, |
||
| 3639 | /*NumArgMembers=*/0, |
||
| 3640 | /*HasCustomParsing=*/0, |
||
| 3641 | /*AcceptsExprPack=*/0, |
||
| 3642 | /*IsTargetSpecific=*/1, |
||
| 3643 | /*IsType=*/0, |
||
| 3644 | /*IsStmt=*/0, |
||
| 3645 | /*IsKnownToGCC=*/0, |
||
| 3646 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 3647 | /*Spellings=*/CmseNSEntrySpellings, |
||
| 3648 | /*ArgNames=*/{}) {} |
||
| 3649 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 3650 | if (!isa<FunctionDecl>(D)) { |
||
| 3651 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 3652 | << Attr << "functions"; |
||
| 3653 | return false; |
||
| 3654 | } |
||
| 3655 | return true; |
||
| 3656 | } |
||
| 3657 | |||
| 3658 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 3659 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 3660 | << AL << St->getBeginLoc(); |
||
| 3661 | return false; |
||
| 3662 | } |
||
| 3663 | |||
| 3664 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 3665 | return LangOpts.Cmse; |
||
| 3666 | } |
||
| 3667 | |||
| 3668 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 3669 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 3670 | return true && (T.getArch() == llvm::Triple::arm || T.getArch() == llvm::Triple::thumb || T.getArch() == llvm::Triple::armeb || T.getArch() == llvm::Triple::thumbeb); |
||
| 3671 | } |
||
| 3672 | |||
| 3673 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 3674 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 3675 | } |
||
| 3676 | |||
| 3677 | bool isParamExpr(size_t N) const override { |
||
| 3678 | return false; |
||
| 3679 | } |
||
| 3680 | |||
| 3681 | static const ParsedAttrInfoCmseNSEntry Instance; |
||
| 3682 | }; |
||
| 3683 | const ParsedAttrInfoCmseNSEntry ParsedAttrInfoCmseNSEntry::Instance; |
||
| 3684 | static constexpr ParsedAttrInfo::Spelling CodeSegSpellings[] = { |
||
| 3685 | {AttributeCommonInfo::AS_Declspec, "code_seg"}, |
||
| 3686 | }; |
||
| 3687 | static constexpr const char *CodeSegArgNames[] = { |
||
| 3688 | "Name",}; |
||
| 3689 | struct ParsedAttrInfoCodeSeg final : public ParsedAttrInfo { |
||
| 3690 | constexpr ParsedAttrInfoCodeSeg() : ParsedAttrInfo( |
||
| 3691 | /*AttrKind=*/ParsedAttr::AT_CodeSeg, |
||
| 3692 | /*NumArgs=*/1, |
||
| 3693 | /*OptArgs=*/0, |
||
| 3694 | /*NumArgMembers=*/1, |
||
| 3695 | /*HasCustomParsing=*/0, |
||
| 3696 | /*AcceptsExprPack=*/0, |
||
| 3697 | /*IsTargetSpecific=*/0, |
||
| 3698 | /*IsType=*/0, |
||
| 3699 | /*IsStmt=*/0, |
||
| 3700 | /*IsKnownToGCC=*/0, |
||
| 3701 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 3702 | /*Spellings=*/CodeSegSpellings, |
||
| 3703 | /*ArgNames=*/CodeSegArgNames) {} |
||
| 3704 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 3705 | if (!isa<FunctionDecl>(D) && !isa<CXXRecordDecl>(D)) { |
||
| 3706 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 3707 | << Attr << "functions and classes"; |
||
| 3708 | return false; |
||
| 3709 | } |
||
| 3710 | return true; |
||
| 3711 | } |
||
| 3712 | |||
| 3713 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 3714 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 3715 | << AL << St->getBeginLoc(); |
||
| 3716 | return false; |
||
| 3717 | } |
||
| 3718 | |||
| 3719 | bool isParamExpr(size_t N) const override { |
||
| 3720 | return false; |
||
| 3721 | } |
||
| 3722 | |||
| 3723 | static const ParsedAttrInfoCodeSeg Instance; |
||
| 3724 | }; |
||
| 3725 | const ParsedAttrInfoCodeSeg ParsedAttrInfoCodeSeg::Instance; |
||
| 3726 | static constexpr ParsedAttrInfo::Spelling ColdSpellings[] = { |
||
| 3727 | {AttributeCommonInfo::AS_GNU, "cold"}, |
||
| 3728 | {AttributeCommonInfo::AS_CXX11, "gnu::cold"}, |
||
| 3729 | {AttributeCommonInfo::AS_C2x, "gnu::cold"}, |
||
| 3730 | }; |
||
| 3731 | struct ParsedAttrInfoCold final : public ParsedAttrInfo { |
||
| 3732 | constexpr ParsedAttrInfoCold() : ParsedAttrInfo( |
||
| 3733 | /*AttrKind=*/ParsedAttr::AT_Cold, |
||
| 3734 | /*NumArgs=*/0, |
||
| 3735 | /*OptArgs=*/0, |
||
| 3736 | /*NumArgMembers=*/0, |
||
| 3737 | /*HasCustomParsing=*/0, |
||
| 3738 | /*AcceptsExprPack=*/0, |
||
| 3739 | /*IsTargetSpecific=*/0, |
||
| 3740 | /*IsType=*/0, |
||
| 3741 | /*IsStmt=*/0, |
||
| 3742 | /*IsKnownToGCC=*/1, |
||
| 3743 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 3744 | /*Spellings=*/ColdSpellings, |
||
| 3745 | /*ArgNames=*/{}) {} |
||
| 3746 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 3747 | if (!isa<FunctionDecl>(D)) { |
||
| 3748 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 3749 | << Attr << "functions"; |
||
| 3750 | return false; |
||
| 3751 | } |
||
| 3752 | return true; |
||
| 3753 | } |
||
| 3754 | |||
| 3755 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 3756 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 3757 | << AL << St->getBeginLoc(); |
||
| 3758 | return false; |
||
| 3759 | } |
||
| 3760 | |||
| 3761 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 3762 | |||
| 3763 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 3764 | if (const auto *A = D->getAttr<HotAttr>()) { |
||
| 3765 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 3766 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 3767 | return false; |
||
| 3768 | } |
||
| 3769 | return true; |
||
| 3770 | } |
||
| 3771 | |||
| 3772 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 3773 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 3774 | } |
||
| 3775 | |||
| 3776 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 3777 | D->addAttr(::new (S.Context) ColdAttr(S.Context, Attr)); |
||
| 3778 | return AttributeApplied; |
||
| 3779 | } |
||
| 3780 | |||
| 3781 | bool isParamExpr(size_t N) const override { |
||
| 3782 | return false; |
||
| 3783 | } |
||
| 3784 | |||
| 3785 | static const ParsedAttrInfoCold Instance; |
||
| 3786 | }; |
||
| 3787 | const ParsedAttrInfoCold ParsedAttrInfoCold::Instance; |
||
| 3788 | static constexpr ParsedAttrInfo::Spelling CommonSpellings[] = { |
||
| 3789 | {AttributeCommonInfo::AS_GNU, "common"}, |
||
| 3790 | {AttributeCommonInfo::AS_CXX11, "gnu::common"}, |
||
| 3791 | {AttributeCommonInfo::AS_C2x, "gnu::common"}, |
||
| 3792 | }; |
||
| 3793 | struct ParsedAttrInfoCommon final : public ParsedAttrInfo { |
||
| 3794 | constexpr ParsedAttrInfoCommon() : ParsedAttrInfo( |
||
| 3795 | /*AttrKind=*/ParsedAttr::AT_Common, |
||
| 3796 | /*NumArgs=*/0, |
||
| 3797 | /*OptArgs=*/0, |
||
| 3798 | /*NumArgMembers=*/0, |
||
| 3799 | /*HasCustomParsing=*/0, |
||
| 3800 | /*AcceptsExprPack=*/0, |
||
| 3801 | /*IsTargetSpecific=*/0, |
||
| 3802 | /*IsType=*/0, |
||
| 3803 | /*IsStmt=*/0, |
||
| 3804 | /*IsKnownToGCC=*/1, |
||
| 3805 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 3806 | /*Spellings=*/CommonSpellings, |
||
| 3807 | /*ArgNames=*/{}) {} |
||
| 3808 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 3809 | if (!isa<VarDecl>(D)) { |
||
| 3810 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 3811 | << Attr << "variables"; |
||
| 3812 | return false; |
||
| 3813 | } |
||
| 3814 | return true; |
||
| 3815 | } |
||
| 3816 | |||
| 3817 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 3818 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 3819 | << AL << St->getBeginLoc(); |
||
| 3820 | return false; |
||
| 3821 | } |
||
| 3822 | |||
| 3823 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 3824 | |||
| 3825 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 3826 | if (const auto *A = D->getAttr<InternalLinkageAttr>()) { |
||
| 3827 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 3828 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 3829 | return false; |
||
| 3830 | } |
||
| 3831 | return true; |
||
| 3832 | } |
||
| 3833 | |||
| 3834 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 3835 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
||
| 3836 | } |
||
| 3837 | |||
| 3838 | bool isParamExpr(size_t N) const override { |
||
| 3839 | return false; |
||
| 3840 | } |
||
| 3841 | |||
| 3842 | static const ParsedAttrInfoCommon Instance; |
||
| 3843 | }; |
||
| 3844 | const ParsedAttrInfoCommon ParsedAttrInfoCommon::Instance; |
||
| 3845 | static constexpr ParsedAttrInfo::Spelling ConstSpellings[] = { |
||
| 3846 | {AttributeCommonInfo::AS_GNU, "const"}, |
||
| 3847 | {AttributeCommonInfo::AS_CXX11, "gnu::const"}, |
||
| 3848 | {AttributeCommonInfo::AS_C2x, "gnu::const"}, |
||
| 3849 | {AttributeCommonInfo::AS_GNU, "__const"}, |
||
| 3850 | {AttributeCommonInfo::AS_CXX11, "gnu::__const"}, |
||
| 3851 | {AttributeCommonInfo::AS_C2x, "gnu::__const"}, |
||
| 3852 | }; |
||
| 3853 | struct ParsedAttrInfoConst final : public ParsedAttrInfo { |
||
| 3854 | constexpr ParsedAttrInfoConst() : ParsedAttrInfo( |
||
| 3855 | /*AttrKind=*/ParsedAttr::AT_Const, |
||
| 3856 | /*NumArgs=*/0, |
||
| 3857 | /*OptArgs=*/0, |
||
| 3858 | /*NumArgMembers=*/0, |
||
| 3859 | /*HasCustomParsing=*/0, |
||
| 3860 | /*AcceptsExprPack=*/0, |
||
| 3861 | /*IsTargetSpecific=*/0, |
||
| 3862 | /*IsType=*/0, |
||
| 3863 | /*IsStmt=*/0, |
||
| 3864 | /*IsKnownToGCC=*/1, |
||
| 3865 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 3866 | /*Spellings=*/ConstSpellings, |
||
| 3867 | /*ArgNames=*/{}) {} |
||
| 3868 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 3869 | D->addAttr(::new (S.Context) ConstAttr(S.Context, Attr)); |
||
| 3870 | return AttributeApplied; |
||
| 3871 | } |
||
| 3872 | |||
| 3873 | bool isParamExpr(size_t N) const override { |
||
| 3874 | return false; |
||
| 3875 | } |
||
| 3876 | |||
| 3877 | static const ParsedAttrInfoConst Instance; |
||
| 3878 | }; |
||
| 3879 | const ParsedAttrInfoConst ParsedAttrInfoConst::Instance; |
||
| 3880 | static constexpr ParsedAttrInfo::Spelling ConstInitSpellings[] = { |
||
| 3881 | {AttributeCommonInfo::AS_Keyword, "constinit"}, |
||
| 3882 | {AttributeCommonInfo::AS_GNU, "require_constant_initialization"}, |
||
| 3883 | {AttributeCommonInfo::AS_CXX11, "clang::require_constant_initialization"}, |
||
| 3884 | }; |
||
| 3885 | struct ParsedAttrInfoConstInit final : public ParsedAttrInfo { |
||
| 3886 | constexpr ParsedAttrInfoConstInit() : ParsedAttrInfo( |
||
| 3887 | /*AttrKind=*/ParsedAttr::AT_ConstInit, |
||
| 3888 | /*NumArgs=*/0, |
||
| 3889 | /*OptArgs=*/0, |
||
| 3890 | /*NumArgMembers=*/0, |
||
| 3891 | /*HasCustomParsing=*/0, |
||
| 3892 | /*AcceptsExprPack=*/0, |
||
| 3893 | /*IsTargetSpecific=*/0, |
||
| 3894 | /*IsType=*/0, |
||
| 3895 | /*IsStmt=*/0, |
||
| 3896 | /*IsKnownToGCC=*/0, |
||
| 3897 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 3898 | /*Spellings=*/ConstInitSpellings, |
||
| 3899 | /*ArgNames=*/{}) {} |
||
| 3900 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 3901 | if (!isGlobalVar(D)) { |
||
| 3902 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 3903 | << Attr << "global variables"; |
||
| 3904 | return false; |
||
| 3905 | } |
||
| 3906 | return true; |
||
| 3907 | } |
||
| 3908 | |||
| 3909 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 3910 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 3911 | << AL << St->getBeginLoc(); |
||
| 3912 | return false; |
||
| 3913 | } |
||
| 3914 | |||
| 3915 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 3916 | return LangOpts.CPlusPlus; |
||
| 3917 | } |
||
| 3918 | |||
| 3919 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 3920 | enum Spelling { |
||
| 3921 | Keyword_constinit = 0, |
||
| 3922 | GNU_require_constant_initialization = 1, |
||
| 3923 | CXX11_clang_require_constant_initialization = 2, |
||
| 3924 | SpellingNotCalculated = 15 |
||
| 3925 | |||
| 3926 | }; |
||
| 3927 | |||
| 3928 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 3929 | switch (Idx) { |
||
| 3930 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 3931 | case 0: return Keyword_constinit; |
||
| 3932 | case 1: return GNU_require_constant_initialization; |
||
| 3933 | case 2: return CXX11_clang_require_constant_initialization; |
||
| 3934 | } |
||
| 3935 | } |
||
| 3936 | |||
| 3937 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 3938 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_global, /*IsSupported=*/true)); |
||
| 3939 | } |
||
| 3940 | |||
| 3941 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 3942 | D->addAttr(::new (S.Context) ConstInitAttr(S.Context, Attr)); |
||
| 3943 | return AttributeApplied; |
||
| 3944 | } |
||
| 3945 | |||
| 3946 | bool isParamExpr(size_t N) const override { |
||
| 3947 | return false; |
||
| 3948 | } |
||
| 3949 | |||
| 3950 | static const ParsedAttrInfoConstInit Instance; |
||
| 3951 | }; |
||
| 3952 | const ParsedAttrInfoConstInit ParsedAttrInfoConstInit::Instance; |
||
| 3953 | static constexpr ParsedAttrInfo::Spelling ConstructorSpellings[] = { |
||
| 3954 | {AttributeCommonInfo::AS_GNU, "constructor"}, |
||
| 3955 | {AttributeCommonInfo::AS_CXX11, "gnu::constructor"}, |
||
| 3956 | {AttributeCommonInfo::AS_C2x, "gnu::constructor"}, |
||
| 3957 | }; |
||
| 3958 | static constexpr const char *ConstructorArgNames[] = { |
||
| 3959 | "Priority",}; |
||
| 3960 | struct ParsedAttrInfoConstructor final : public ParsedAttrInfo { |
||
| 3961 | constexpr ParsedAttrInfoConstructor() : ParsedAttrInfo( |
||
| 3962 | /*AttrKind=*/ParsedAttr::AT_Constructor, |
||
| 3963 | /*NumArgs=*/0, |
||
| 3964 | /*OptArgs=*/1, |
||
| 3965 | /*NumArgMembers=*/1, |
||
| 3966 | /*HasCustomParsing=*/0, |
||
| 3967 | /*AcceptsExprPack=*/0, |
||
| 3968 | /*IsTargetSpecific=*/0, |
||
| 3969 | /*IsType=*/0, |
||
| 3970 | /*IsStmt=*/0, |
||
| 3971 | /*IsKnownToGCC=*/1, |
||
| 3972 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 3973 | /*Spellings=*/ConstructorSpellings, |
||
| 3974 | /*ArgNames=*/ConstructorArgNames) {} |
||
| 3975 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 3976 | if (!isa<FunctionDecl>(D)) { |
||
| 3977 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 3978 | << Attr << "functions"; |
||
| 3979 | return false; |
||
| 3980 | } |
||
| 3981 | return true; |
||
| 3982 | } |
||
| 3983 | |||
| 3984 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 3985 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 3986 | << AL << St->getBeginLoc(); |
||
| 3987 | return false; |
||
| 3988 | } |
||
| 3989 | |||
| 3990 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 3991 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 3992 | } |
||
| 3993 | |||
| 3994 | bool isParamExpr(size_t N) const override { |
||
| 3995 | return false; |
||
| 3996 | } |
||
| 3997 | |||
| 3998 | static const ParsedAttrInfoConstructor Instance; |
||
| 3999 | }; |
||
| 4000 | const ParsedAttrInfoConstructor ParsedAttrInfoConstructor::Instance; |
||
| 4001 | static constexpr ParsedAttrInfo::Spelling ConsumableSpellings[] = { |
||
| 4002 | {AttributeCommonInfo::AS_GNU, "consumable"}, |
||
| 4003 | {AttributeCommonInfo::AS_CXX11, "clang::consumable"}, |
||
| 4004 | }; |
||
| 4005 | static constexpr const char *ConsumableArgNames[] = { |
||
| 4006 | "DefaultState",}; |
||
| 4007 | struct ParsedAttrInfoConsumable final : public ParsedAttrInfo { |
||
| 4008 | constexpr ParsedAttrInfoConsumable() : ParsedAttrInfo( |
||
| 4009 | /*AttrKind=*/ParsedAttr::AT_Consumable, |
||
| 4010 | /*NumArgs=*/1, |
||
| 4011 | /*OptArgs=*/0, |
||
| 4012 | /*NumArgMembers=*/1, |
||
| 4013 | /*HasCustomParsing=*/0, |
||
| 4014 | /*AcceptsExprPack=*/0, |
||
| 4015 | /*IsTargetSpecific=*/0, |
||
| 4016 | /*IsType=*/0, |
||
| 4017 | /*IsStmt=*/0, |
||
| 4018 | /*IsKnownToGCC=*/0, |
||
| 4019 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 4020 | /*Spellings=*/ConsumableSpellings, |
||
| 4021 | /*ArgNames=*/ConsumableArgNames) {} |
||
| 4022 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 4023 | if (!isa<CXXRecordDecl>(D)) { |
||
| 4024 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 4025 | << Attr << "classes"; |
||
| 4026 | return false; |
||
| 4027 | } |
||
| 4028 | return true; |
||
| 4029 | } |
||
| 4030 | |||
| 4031 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 4032 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 4033 | << AL << St->getBeginLoc(); |
||
| 4034 | return false; |
||
| 4035 | } |
||
| 4036 | |||
| 4037 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 4038 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 4039 | } |
||
| 4040 | |||
| 4041 | bool isParamExpr(size_t N) const override { |
||
| 4042 | return false; |
||
| 4043 | } |
||
| 4044 | |||
| 4045 | static const ParsedAttrInfoConsumable Instance; |
||
| 4046 | }; |
||
| 4047 | const ParsedAttrInfoConsumable ParsedAttrInfoConsumable::Instance; |
||
| 4048 | static constexpr ParsedAttrInfo::Spelling ConsumableAutoCastSpellings[] = { |
||
| 4049 | {AttributeCommonInfo::AS_GNU, "consumable_auto_cast_state"}, |
||
| 4050 | {AttributeCommonInfo::AS_CXX11, "clang::consumable_auto_cast_state"}, |
||
| 4051 | }; |
||
| 4052 | struct ParsedAttrInfoConsumableAutoCast final : public ParsedAttrInfo { |
||
| 4053 | constexpr ParsedAttrInfoConsumableAutoCast() : ParsedAttrInfo( |
||
| 4054 | /*AttrKind=*/ParsedAttr::AT_ConsumableAutoCast, |
||
| 4055 | /*NumArgs=*/0, |
||
| 4056 | /*OptArgs=*/0, |
||
| 4057 | /*NumArgMembers=*/0, |
||
| 4058 | /*HasCustomParsing=*/0, |
||
| 4059 | /*AcceptsExprPack=*/0, |
||
| 4060 | /*IsTargetSpecific=*/0, |
||
| 4061 | /*IsType=*/0, |
||
| 4062 | /*IsStmt=*/0, |
||
| 4063 | /*IsKnownToGCC=*/0, |
||
| 4064 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 4065 | /*Spellings=*/ConsumableAutoCastSpellings, |
||
| 4066 | /*ArgNames=*/{}) {} |
||
| 4067 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 4068 | if (!isa<CXXRecordDecl>(D)) { |
||
| 4069 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 4070 | << Attr << "classes"; |
||
| 4071 | return false; |
||
| 4072 | } |
||
| 4073 | return true; |
||
| 4074 | } |
||
| 4075 | |||
| 4076 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 4077 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 4078 | << AL << St->getBeginLoc(); |
||
| 4079 | return false; |
||
| 4080 | } |
||
| 4081 | |||
| 4082 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 4083 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 4084 | } |
||
| 4085 | |||
| 4086 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 4087 | D->addAttr(::new (S.Context) ConsumableAutoCastAttr(S.Context, Attr)); |
||
| 4088 | return AttributeApplied; |
||
| 4089 | } |
||
| 4090 | |||
| 4091 | bool isParamExpr(size_t N) const override { |
||
| 4092 | return false; |
||
| 4093 | } |
||
| 4094 | |||
| 4095 | static const ParsedAttrInfoConsumableAutoCast Instance; |
||
| 4096 | }; |
||
| 4097 | const ParsedAttrInfoConsumableAutoCast ParsedAttrInfoConsumableAutoCast::Instance; |
||
| 4098 | static constexpr ParsedAttrInfo::Spelling ConsumableSetOnReadSpellings[] = { |
||
| 4099 | {AttributeCommonInfo::AS_GNU, "consumable_set_state_on_read"}, |
||
| 4100 | {AttributeCommonInfo::AS_CXX11, "clang::consumable_set_state_on_read"}, |
||
| 4101 | }; |
||
| 4102 | struct ParsedAttrInfoConsumableSetOnRead final : public ParsedAttrInfo { |
||
| 4103 | constexpr ParsedAttrInfoConsumableSetOnRead() : ParsedAttrInfo( |
||
| 4104 | /*AttrKind=*/ParsedAttr::AT_ConsumableSetOnRead, |
||
| 4105 | /*NumArgs=*/0, |
||
| 4106 | /*OptArgs=*/0, |
||
| 4107 | /*NumArgMembers=*/0, |
||
| 4108 | /*HasCustomParsing=*/0, |
||
| 4109 | /*AcceptsExprPack=*/0, |
||
| 4110 | /*IsTargetSpecific=*/0, |
||
| 4111 | /*IsType=*/0, |
||
| 4112 | /*IsStmt=*/0, |
||
| 4113 | /*IsKnownToGCC=*/0, |
||
| 4114 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 4115 | /*Spellings=*/ConsumableSetOnReadSpellings, |
||
| 4116 | /*ArgNames=*/{}) {} |
||
| 4117 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 4118 | if (!isa<CXXRecordDecl>(D)) { |
||
| 4119 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 4120 | << Attr << "classes"; |
||
| 4121 | return false; |
||
| 4122 | } |
||
| 4123 | return true; |
||
| 4124 | } |
||
| 4125 | |||
| 4126 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 4127 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 4128 | << AL << St->getBeginLoc(); |
||
| 4129 | return false; |
||
| 4130 | } |
||
| 4131 | |||
| 4132 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 4133 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 4134 | } |
||
| 4135 | |||
| 4136 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 4137 | D->addAttr(::new (S.Context) ConsumableSetOnReadAttr(S.Context, Attr)); |
||
| 4138 | return AttributeApplied; |
||
| 4139 | } |
||
| 4140 | |||
| 4141 | bool isParamExpr(size_t N) const override { |
||
| 4142 | return false; |
||
| 4143 | } |
||
| 4144 | |||
| 4145 | static const ParsedAttrInfoConsumableSetOnRead Instance; |
||
| 4146 | }; |
||
| 4147 | const ParsedAttrInfoConsumableSetOnRead ParsedAttrInfoConsumableSetOnRead::Instance; |
||
| 4148 | static constexpr ParsedAttrInfo::Spelling ConvergentSpellings[] = { |
||
| 4149 | {AttributeCommonInfo::AS_GNU, "convergent"}, |
||
| 4150 | {AttributeCommonInfo::AS_CXX11, "clang::convergent"}, |
||
| 4151 | {AttributeCommonInfo::AS_C2x, "clang::convergent"}, |
||
| 4152 | }; |
||
| 4153 | struct ParsedAttrInfoConvergent final : public ParsedAttrInfo { |
||
| 4154 | constexpr ParsedAttrInfoConvergent() : ParsedAttrInfo( |
||
| 4155 | /*AttrKind=*/ParsedAttr::AT_Convergent, |
||
| 4156 | /*NumArgs=*/0, |
||
| 4157 | /*OptArgs=*/0, |
||
| 4158 | /*NumArgMembers=*/0, |
||
| 4159 | /*HasCustomParsing=*/0, |
||
| 4160 | /*AcceptsExprPack=*/0, |
||
| 4161 | /*IsTargetSpecific=*/0, |
||
| 4162 | /*IsType=*/0, |
||
| 4163 | /*IsStmt=*/0, |
||
| 4164 | /*IsKnownToGCC=*/0, |
||
| 4165 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 4166 | /*Spellings=*/ConvergentSpellings, |
||
| 4167 | /*ArgNames=*/{}) {} |
||
| 4168 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 4169 | if (!isa<FunctionDecl>(D)) { |
||
| 4170 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 4171 | << Attr << "functions"; |
||
| 4172 | return false; |
||
| 4173 | } |
||
| 4174 | return true; |
||
| 4175 | } |
||
| 4176 | |||
| 4177 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 4178 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 4179 | << AL << St->getBeginLoc(); |
||
| 4180 | return false; |
||
| 4181 | } |
||
| 4182 | |||
| 4183 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 4184 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 4185 | } |
||
| 4186 | |||
| 4187 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 4188 | D->addAttr(::new (S.Context) ConvergentAttr(S.Context, Attr)); |
||
| 4189 | return AttributeApplied; |
||
| 4190 | } |
||
| 4191 | |||
| 4192 | bool isParamExpr(size_t N) const override { |
||
| 4193 | return false; |
||
| 4194 | } |
||
| 4195 | |||
| 4196 | static const ParsedAttrInfoConvergent Instance; |
||
| 4197 | }; |
||
| 4198 | const ParsedAttrInfoConvergent ParsedAttrInfoConvergent::Instance; |
||
| 4199 | static constexpr ParsedAttrInfo::Spelling DLLExportSpellings[] = { |
||
| 4200 | {AttributeCommonInfo::AS_Declspec, "dllexport"}, |
||
| 4201 | {AttributeCommonInfo::AS_GNU, "dllexport"}, |
||
| 4202 | {AttributeCommonInfo::AS_CXX11, "gnu::dllexport"}, |
||
| 4203 | {AttributeCommonInfo::AS_C2x, "gnu::dllexport"}, |
||
| 4204 | }; |
||
| 4205 | struct ParsedAttrInfoDLLExport final : public ParsedAttrInfo { |
||
| 4206 | constexpr ParsedAttrInfoDLLExport() : ParsedAttrInfo( |
||
| 4207 | /*AttrKind=*/ParsedAttr::AT_DLLExport, |
||
| 4208 | /*NumArgs=*/0, |
||
| 4209 | /*OptArgs=*/0, |
||
| 4210 | /*NumArgMembers=*/0, |
||
| 4211 | /*HasCustomParsing=*/0, |
||
| 4212 | /*AcceptsExprPack=*/0, |
||
| 4213 | /*IsTargetSpecific=*/1, |
||
| 4214 | /*IsType=*/0, |
||
| 4215 | /*IsStmt=*/0, |
||
| 4216 | /*IsKnownToGCC=*/1, |
||
| 4217 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 4218 | /*Spellings=*/DLLExportSpellings, |
||
| 4219 | /*ArgNames=*/{}) {} |
||
| 4220 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 4221 | if (!isa<FunctionDecl>(D) && !isa<VarDecl>(D) && !isa<CXXRecordDecl>(D) && !isa<ObjCInterfaceDecl>(D)) { |
||
| 4222 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 4223 | << Attr << "functions, variables, classes, and Objective-C interfaces"; |
||
| 4224 | return false; |
||
| 4225 | } |
||
| 4226 | return true; |
||
| 4227 | } |
||
| 4228 | |||
| 4229 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 4230 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 4231 | << AL << St->getBeginLoc(); |
||
| 4232 | return false; |
||
| 4233 | } |
||
| 4234 | |||
| 4235 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 4236 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 4237 | return true && ( Target.getTriple().hasDLLImportExport() ); |
||
| 4238 | } |
||
| 4239 | |||
| 4240 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 4241 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 4242 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
||
| 4243 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 4244 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
||
| 4245 | } |
||
| 4246 | |||
| 4247 | bool isParamExpr(size_t N) const override { |
||
| 4248 | return false; |
||
| 4249 | } |
||
| 4250 | |||
| 4251 | static const ParsedAttrInfoDLLExport Instance; |
||
| 4252 | }; |
||
| 4253 | const ParsedAttrInfoDLLExport ParsedAttrInfoDLLExport::Instance; |
||
| 4254 | struct ParsedAttrInfoDLLExportStaticLocal final : public ParsedAttrInfo { |
||
| 4255 | constexpr ParsedAttrInfoDLLExportStaticLocal() : ParsedAttrInfo( |
||
| 4256 | /*AttrKind=*/ParsedAttr::AT_DLLExportStaticLocal, |
||
| 4257 | /*NumArgs=*/0, |
||
| 4258 | /*OptArgs=*/0, |
||
| 4259 | /*NumArgMembers=*/0, |
||
| 4260 | /*HasCustomParsing=*/0, |
||
| 4261 | /*AcceptsExprPack=*/0, |
||
| 4262 | /*IsTargetSpecific=*/1, |
||
| 4263 | /*IsType=*/0, |
||
| 4264 | /*IsStmt=*/0, |
||
| 4265 | /*IsKnownToGCC=*/0, |
||
| 4266 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 4267 | /*Spellings=*/{}, |
||
| 4268 | /*ArgNames=*/{}) {} |
||
| 4269 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 4270 | if (!isa<FunctionDecl>(D)) { |
||
| 4271 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 4272 | << Attr << "functions"; |
||
| 4273 | return false; |
||
| 4274 | } |
||
| 4275 | return true; |
||
| 4276 | } |
||
| 4277 | |||
| 4278 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 4279 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 4280 | << AL << St->getBeginLoc(); |
||
| 4281 | return false; |
||
| 4282 | } |
||
| 4283 | |||
| 4284 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 4285 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 4286 | return true && ( Target.getTriple().hasDLLImportExport() ); |
||
| 4287 | } |
||
| 4288 | |||
| 4289 | bool isParamExpr(size_t N) const override { |
||
| 4290 | return false; |
||
| 4291 | } |
||
| 4292 | |||
| 4293 | static const ParsedAttrInfoDLLExportStaticLocal Instance; |
||
| 4294 | }; |
||
| 4295 | const ParsedAttrInfoDLLExportStaticLocal ParsedAttrInfoDLLExportStaticLocal::Instance; |
||
| 4296 | static constexpr ParsedAttrInfo::Spelling DLLImportSpellings[] = { |
||
| 4297 | {AttributeCommonInfo::AS_Declspec, "dllimport"}, |
||
| 4298 | {AttributeCommonInfo::AS_GNU, "dllimport"}, |
||
| 4299 | {AttributeCommonInfo::AS_CXX11, "gnu::dllimport"}, |
||
| 4300 | {AttributeCommonInfo::AS_C2x, "gnu::dllimport"}, |
||
| 4301 | }; |
||
| 4302 | struct ParsedAttrInfoDLLImport final : public ParsedAttrInfo { |
||
| 4303 | constexpr ParsedAttrInfoDLLImport() : ParsedAttrInfo( |
||
| 4304 | /*AttrKind=*/ParsedAttr::AT_DLLImport, |
||
| 4305 | /*NumArgs=*/0, |
||
| 4306 | /*OptArgs=*/0, |
||
| 4307 | /*NumArgMembers=*/0, |
||
| 4308 | /*HasCustomParsing=*/0, |
||
| 4309 | /*AcceptsExprPack=*/0, |
||
| 4310 | /*IsTargetSpecific=*/1, |
||
| 4311 | /*IsType=*/0, |
||
| 4312 | /*IsStmt=*/0, |
||
| 4313 | /*IsKnownToGCC=*/1, |
||
| 4314 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 4315 | /*Spellings=*/DLLImportSpellings, |
||
| 4316 | /*ArgNames=*/{}) {} |
||
| 4317 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 4318 | if (!isa<FunctionDecl>(D) && !isa<VarDecl>(D) && !isa<CXXRecordDecl>(D) && !isa<ObjCInterfaceDecl>(D)) { |
||
| 4319 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 4320 | << Attr << "functions, variables, classes, and Objective-C interfaces"; |
||
| 4321 | return false; |
||
| 4322 | } |
||
| 4323 | return true; |
||
| 4324 | } |
||
| 4325 | |||
| 4326 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 4327 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 4328 | << AL << St->getBeginLoc(); |
||
| 4329 | return false; |
||
| 4330 | } |
||
| 4331 | |||
| 4332 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 4333 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 4334 | return true && ( Target.getTriple().hasDLLImportExport() ); |
||
| 4335 | } |
||
| 4336 | |||
| 4337 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 4338 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 4339 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
||
| 4340 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 4341 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
||
| 4342 | } |
||
| 4343 | |||
| 4344 | bool isParamExpr(size_t N) const override { |
||
| 4345 | return false; |
||
| 4346 | } |
||
| 4347 | |||
| 4348 | static const ParsedAttrInfoDLLImport Instance; |
||
| 4349 | }; |
||
| 4350 | const ParsedAttrInfoDLLImport ParsedAttrInfoDLLImport::Instance; |
||
| 4351 | struct ParsedAttrInfoDLLImportStaticLocal final : public ParsedAttrInfo { |
||
| 4352 | constexpr ParsedAttrInfoDLLImportStaticLocal() : ParsedAttrInfo( |
||
| 4353 | /*AttrKind=*/ParsedAttr::AT_DLLImportStaticLocal, |
||
| 4354 | /*NumArgs=*/0, |
||
| 4355 | /*OptArgs=*/0, |
||
| 4356 | /*NumArgMembers=*/0, |
||
| 4357 | /*HasCustomParsing=*/0, |
||
| 4358 | /*AcceptsExprPack=*/0, |
||
| 4359 | /*IsTargetSpecific=*/1, |
||
| 4360 | /*IsType=*/0, |
||
| 4361 | /*IsStmt=*/0, |
||
| 4362 | /*IsKnownToGCC=*/0, |
||
| 4363 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 4364 | /*Spellings=*/{}, |
||
| 4365 | /*ArgNames=*/{}) {} |
||
| 4366 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 4367 | if (!isa<FunctionDecl>(D)) { |
||
| 4368 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 4369 | << Attr << "functions"; |
||
| 4370 | return false; |
||
| 4371 | } |
||
| 4372 | return true; |
||
| 4373 | } |
||
| 4374 | |||
| 4375 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 4376 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 4377 | << AL << St->getBeginLoc(); |
||
| 4378 | return false; |
||
| 4379 | } |
||
| 4380 | |||
| 4381 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 4382 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 4383 | return true && ( Target.getTriple().hasDLLImportExport() ); |
||
| 4384 | } |
||
| 4385 | |||
| 4386 | bool isParamExpr(size_t N) const override { |
||
| 4387 | return false; |
||
| 4388 | } |
||
| 4389 | |||
| 4390 | static const ParsedAttrInfoDLLImportStaticLocal Instance; |
||
| 4391 | }; |
||
| 4392 | const ParsedAttrInfoDLLImportStaticLocal ParsedAttrInfoDLLImportStaticLocal::Instance; |
||
| 4393 | static constexpr ParsedAttrInfo::Spelling DeprecatedSpellings[] = { |
||
| 4394 | {AttributeCommonInfo::AS_GNU, "deprecated"}, |
||
| 4395 | {AttributeCommonInfo::AS_CXX11, "gnu::deprecated"}, |
||
| 4396 | {AttributeCommonInfo::AS_C2x, "gnu::deprecated"}, |
||
| 4397 | {AttributeCommonInfo::AS_Declspec, "deprecated"}, |
||
| 4398 | {AttributeCommonInfo::AS_CXX11, "deprecated"}, |
||
| 4399 | {AttributeCommonInfo::AS_C2x, "deprecated"}, |
||
| 4400 | }; |
||
| 4401 | static constexpr const char *DeprecatedArgNames[] = { |
||
| 4402 | "Message","Replacement",}; |
||
| 4403 | struct ParsedAttrInfoDeprecated final : public ParsedAttrInfo { |
||
| 4404 | constexpr ParsedAttrInfoDeprecated() : ParsedAttrInfo( |
||
| 4405 | /*AttrKind=*/ParsedAttr::AT_Deprecated, |
||
| 4406 | /*NumArgs=*/0, |
||
| 4407 | /*OptArgs=*/2, |
||
| 4408 | /*NumArgMembers=*/2, |
||
| 4409 | /*HasCustomParsing=*/0, |
||
| 4410 | /*AcceptsExprPack=*/0, |
||
| 4411 | /*IsTargetSpecific=*/0, |
||
| 4412 | /*IsType=*/0, |
||
| 4413 | /*IsStmt=*/0, |
||
| 4414 | /*IsKnownToGCC=*/1, |
||
| 4415 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 4416 | /*Spellings=*/DeprecatedSpellings, |
||
| 4417 | /*ArgNames=*/DeprecatedArgNames) {} |
||
| 4418 | bool isParamExpr(size_t N) const override { |
||
| 4419 | return false; |
||
| 4420 | } |
||
| 4421 | |||
| 4422 | static const ParsedAttrInfoDeprecated Instance; |
||
| 4423 | }; |
||
| 4424 | const ParsedAttrInfoDeprecated ParsedAttrInfoDeprecated::Instance; |
||
| 4425 | static constexpr ParsedAttrInfo::Spelling DestructorSpellings[] = { |
||
| 4426 | {AttributeCommonInfo::AS_GNU, "destructor"}, |
||
| 4427 | {AttributeCommonInfo::AS_CXX11, "gnu::destructor"}, |
||
| 4428 | {AttributeCommonInfo::AS_C2x, "gnu::destructor"}, |
||
| 4429 | }; |
||
| 4430 | static constexpr const char *DestructorArgNames[] = { |
||
| 4431 | "Priority",}; |
||
| 4432 | struct ParsedAttrInfoDestructor final : public ParsedAttrInfo { |
||
| 4433 | constexpr ParsedAttrInfoDestructor() : ParsedAttrInfo( |
||
| 4434 | /*AttrKind=*/ParsedAttr::AT_Destructor, |
||
| 4435 | /*NumArgs=*/0, |
||
| 4436 | /*OptArgs=*/1, |
||
| 4437 | /*NumArgMembers=*/1, |
||
| 4438 | /*HasCustomParsing=*/0, |
||
| 4439 | /*AcceptsExprPack=*/0, |
||
| 4440 | /*IsTargetSpecific=*/0, |
||
| 4441 | /*IsType=*/0, |
||
| 4442 | /*IsStmt=*/0, |
||
| 4443 | /*IsKnownToGCC=*/1, |
||
| 4444 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 4445 | /*Spellings=*/DestructorSpellings, |
||
| 4446 | /*ArgNames=*/DestructorArgNames) {} |
||
| 4447 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 4448 | if (!isa<FunctionDecl>(D)) { |
||
| 4449 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 4450 | << Attr << "functions"; |
||
| 4451 | return false; |
||
| 4452 | } |
||
| 4453 | return true; |
||
| 4454 | } |
||
| 4455 | |||
| 4456 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 4457 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 4458 | << AL << St->getBeginLoc(); |
||
| 4459 | return false; |
||
| 4460 | } |
||
| 4461 | |||
| 4462 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 4463 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 4464 | } |
||
| 4465 | |||
| 4466 | bool isParamExpr(size_t N) const override { |
||
| 4467 | return false; |
||
| 4468 | } |
||
| 4469 | |||
| 4470 | static const ParsedAttrInfoDestructor Instance; |
||
| 4471 | }; |
||
| 4472 | const ParsedAttrInfoDestructor ParsedAttrInfoDestructor::Instance; |
||
| 4473 | static constexpr ParsedAttrInfo::Spelling DiagnoseAsBuiltinSpellings[] = { |
||
| 4474 | {AttributeCommonInfo::AS_GNU, "diagnose_as_builtin"}, |
||
| 4475 | {AttributeCommonInfo::AS_CXX11, "clang::diagnose_as_builtin"}, |
||
| 4476 | {AttributeCommonInfo::AS_C2x, "clang::diagnose_as_builtin"}, |
||
| 4477 | }; |
||
| 4478 | static constexpr const char *DiagnoseAsBuiltinArgNames[] = { |
||
| 4479 | "Function","ArgIndices...",}; |
||
| 4480 | struct ParsedAttrInfoDiagnoseAsBuiltin final : public ParsedAttrInfo { |
||
| 4481 | constexpr ParsedAttrInfoDiagnoseAsBuiltin() : ParsedAttrInfo( |
||
| 4482 | /*AttrKind=*/ParsedAttr::AT_DiagnoseAsBuiltin, |
||
| 4483 | /*NumArgs=*/1, |
||
| 4484 | /*OptArgs=*/15, |
||
| 4485 | /*NumArgMembers=*/2, |
||
| 4486 | /*HasCustomParsing=*/0, |
||
| 4487 | /*AcceptsExprPack=*/0, |
||
| 4488 | /*IsTargetSpecific=*/0, |
||
| 4489 | /*IsType=*/0, |
||
| 4490 | /*IsStmt=*/0, |
||
| 4491 | /*IsKnownToGCC=*/0, |
||
| 4492 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 4493 | /*Spellings=*/DiagnoseAsBuiltinSpellings, |
||
| 4494 | /*ArgNames=*/DiagnoseAsBuiltinArgNames) {} |
||
| 4495 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 4496 | if (!isa<FunctionDecl>(D)) { |
||
| 4497 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 4498 | << Attr << "functions"; |
||
| 4499 | return false; |
||
| 4500 | } |
||
| 4501 | return true; |
||
| 4502 | } |
||
| 4503 | |||
| 4504 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 4505 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 4506 | << AL << St->getBeginLoc(); |
||
| 4507 | return false; |
||
| 4508 | } |
||
| 4509 | |||
| 4510 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 4511 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 4512 | } |
||
| 4513 | |||
| 4514 | bool isParamExpr(size_t N) const override { |
||
| 4515 | return false; |
||
| 4516 | } |
||
| 4517 | |||
| 4518 | static const ParsedAttrInfoDiagnoseAsBuiltin Instance; |
||
| 4519 | }; |
||
| 4520 | const ParsedAttrInfoDiagnoseAsBuiltin ParsedAttrInfoDiagnoseAsBuiltin::Instance; |
||
| 4521 | static constexpr ParsedAttrInfo::Spelling DiagnoseIfSpellings[] = { |
||
| 4522 | {AttributeCommonInfo::AS_GNU, "diagnose_if"}, |
||
| 4523 | }; |
||
| 4524 | static constexpr const char *DiagnoseIfArgNames[] = { |
||
| 4525 | "Cond","Message","DiagnosticType",}; |
||
| 4526 | struct ParsedAttrInfoDiagnoseIf final : public ParsedAttrInfo { |
||
| 4527 | constexpr ParsedAttrInfoDiagnoseIf() : ParsedAttrInfo( |
||
| 4528 | /*AttrKind=*/ParsedAttr::AT_DiagnoseIf, |
||
| 4529 | /*NumArgs=*/3, |
||
| 4530 | /*OptArgs=*/0, |
||
| 4531 | /*NumArgMembers=*/3, |
||
| 4532 | /*HasCustomParsing=*/0, |
||
| 4533 | /*AcceptsExprPack=*/0, |
||
| 4534 | /*IsTargetSpecific=*/0, |
||
| 4535 | /*IsType=*/0, |
||
| 4536 | /*IsStmt=*/0, |
||
| 4537 | /*IsKnownToGCC=*/0, |
||
| 4538 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 4539 | /*Spellings=*/DiagnoseIfSpellings, |
||
| 4540 | /*ArgNames=*/DiagnoseIfArgNames) {} |
||
| 4541 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 4542 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D) && !isa<ObjCPropertyDecl>(D)) { |
||
| 4543 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 4544 | << Attr << "functions, Objective-C methods, and Objective-C properties"; |
||
| 4545 | return false; |
||
| 4546 | } |
||
| 4547 | return true; |
||
| 4548 | } |
||
| 4549 | |||
| 4550 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 4551 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 4552 | << AL << St->getBeginLoc(); |
||
| 4553 | return false; |
||
| 4554 | } |
||
| 4555 | |||
| 4556 | bool isParamExpr(size_t N) const override { |
||
| 4557 | return (N == 0) || false; |
||
| 4558 | } |
||
| 4559 | |||
| 4560 | static const ParsedAttrInfoDiagnoseIf Instance; |
||
| 4561 | }; |
||
| 4562 | const ParsedAttrInfoDiagnoseIf ParsedAttrInfoDiagnoseIf::Instance; |
||
| 4563 | static constexpr ParsedAttrInfo::Spelling DisableSanitizerInstrumentationSpellings[] = { |
||
| 4564 | {AttributeCommonInfo::AS_GNU, "disable_sanitizer_instrumentation"}, |
||
| 4565 | {AttributeCommonInfo::AS_CXX11, "clang::disable_sanitizer_instrumentation"}, |
||
| 4566 | {AttributeCommonInfo::AS_C2x, "clang::disable_sanitizer_instrumentation"}, |
||
| 4567 | }; |
||
| 4568 | struct ParsedAttrInfoDisableSanitizerInstrumentation final : public ParsedAttrInfo { |
||
| 4569 | constexpr ParsedAttrInfoDisableSanitizerInstrumentation() : ParsedAttrInfo( |
||
| 4570 | /*AttrKind=*/ParsedAttr::AT_DisableSanitizerInstrumentation, |
||
| 4571 | /*NumArgs=*/0, |
||
| 4572 | /*OptArgs=*/0, |
||
| 4573 | /*NumArgMembers=*/0, |
||
| 4574 | /*HasCustomParsing=*/0, |
||
| 4575 | /*AcceptsExprPack=*/0, |
||
| 4576 | /*IsTargetSpecific=*/0, |
||
| 4577 | /*IsType=*/0, |
||
| 4578 | /*IsStmt=*/0, |
||
| 4579 | /*IsKnownToGCC=*/0, |
||
| 4580 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 4581 | /*Spellings=*/DisableSanitizerInstrumentationSpellings, |
||
| 4582 | /*ArgNames=*/{}) {} |
||
| 4583 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 4584 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D) && !isGlobalVar(D)) { |
||
| 4585 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 4586 | << Attr << "functions, Objective-C methods, and global variables"; |
||
| 4587 | return false; |
||
| 4588 | } |
||
| 4589 | return true; |
||
| 4590 | } |
||
| 4591 | |||
| 4592 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 4593 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 4594 | << AL << St->getBeginLoc(); |
||
| 4595 | return false; |
||
| 4596 | } |
||
| 4597 | |||
| 4598 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 4599 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 4600 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 4601 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_global, /*IsSupported=*/true)); |
||
| 4602 | } |
||
| 4603 | |||
| 4604 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 4605 | D->addAttr(::new (S.Context) DisableSanitizerInstrumentationAttr(S.Context, Attr)); |
||
| 4606 | return AttributeApplied; |
||
| 4607 | } |
||
| 4608 | |||
| 4609 | bool isParamExpr(size_t N) const override { |
||
| 4610 | return false; |
||
| 4611 | } |
||
| 4612 | |||
| 4613 | static const ParsedAttrInfoDisableSanitizerInstrumentation Instance; |
||
| 4614 | }; |
||
| 4615 | const ParsedAttrInfoDisableSanitizerInstrumentation ParsedAttrInfoDisableSanitizerInstrumentation::Instance; |
||
| 4616 | static constexpr ParsedAttrInfo::Spelling DisableTailCallsSpellings[] = { |
||
| 4617 | {AttributeCommonInfo::AS_GNU, "disable_tail_calls"}, |
||
| 4618 | {AttributeCommonInfo::AS_CXX11, "clang::disable_tail_calls"}, |
||
| 4619 | {AttributeCommonInfo::AS_C2x, "clang::disable_tail_calls"}, |
||
| 4620 | }; |
||
| 4621 | struct ParsedAttrInfoDisableTailCalls final : public ParsedAttrInfo { |
||
| 4622 | constexpr ParsedAttrInfoDisableTailCalls() : ParsedAttrInfo( |
||
| 4623 | /*AttrKind=*/ParsedAttr::AT_DisableTailCalls, |
||
| 4624 | /*NumArgs=*/0, |
||
| 4625 | /*OptArgs=*/0, |
||
| 4626 | /*NumArgMembers=*/0, |
||
| 4627 | /*HasCustomParsing=*/0, |
||
| 4628 | /*AcceptsExprPack=*/0, |
||
| 4629 | /*IsTargetSpecific=*/0, |
||
| 4630 | /*IsType=*/0, |
||
| 4631 | /*IsStmt=*/0, |
||
| 4632 | /*IsKnownToGCC=*/0, |
||
| 4633 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 4634 | /*Spellings=*/DisableTailCallsSpellings, |
||
| 4635 | /*ArgNames=*/{}) {} |
||
| 4636 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 4637 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
||
| 4638 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 4639 | << Attr << "functions and Objective-C methods"; |
||
| 4640 | return false; |
||
| 4641 | } |
||
| 4642 | return true; |
||
| 4643 | } |
||
| 4644 | |||
| 4645 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 4646 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 4647 | << AL << St->getBeginLoc(); |
||
| 4648 | return false; |
||
| 4649 | } |
||
| 4650 | |||
| 4651 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 4652 | |||
| 4653 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 4654 | if (const auto *A = D->getAttr<NakedAttr>()) { |
||
| 4655 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 4656 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 4657 | return false; |
||
| 4658 | } |
||
| 4659 | return true; |
||
| 4660 | } |
||
| 4661 | |||
| 4662 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 4663 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 4664 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 4665 | } |
||
| 4666 | |||
| 4667 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 4668 | D->addAttr(::new (S.Context) DisableTailCallsAttr(S.Context, Attr)); |
||
| 4669 | return AttributeApplied; |
||
| 4670 | } |
||
| 4671 | |||
| 4672 | bool isParamExpr(size_t N) const override { |
||
| 4673 | return false; |
||
| 4674 | } |
||
| 4675 | |||
| 4676 | static const ParsedAttrInfoDisableTailCalls Instance; |
||
| 4677 | }; |
||
| 4678 | const ParsedAttrInfoDisableTailCalls ParsedAttrInfoDisableTailCalls::Instance; |
||
| 4679 | static constexpr ParsedAttrInfo::Spelling EmptyBasesSpellings[] = { |
||
| 4680 | {AttributeCommonInfo::AS_Declspec, "empty_bases"}, |
||
| 4681 | }; |
||
| 4682 | struct ParsedAttrInfoEmptyBases final : public ParsedAttrInfo { |
||
| 4683 | constexpr ParsedAttrInfoEmptyBases() : ParsedAttrInfo( |
||
| 4684 | /*AttrKind=*/ParsedAttr::AT_EmptyBases, |
||
| 4685 | /*NumArgs=*/0, |
||
| 4686 | /*OptArgs=*/0, |
||
| 4687 | /*NumArgMembers=*/0, |
||
| 4688 | /*HasCustomParsing=*/0, |
||
| 4689 | /*AcceptsExprPack=*/0, |
||
| 4690 | /*IsTargetSpecific=*/1, |
||
| 4691 | /*IsType=*/0, |
||
| 4692 | /*IsStmt=*/0, |
||
| 4693 | /*IsKnownToGCC=*/0, |
||
| 4694 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 4695 | /*Spellings=*/EmptyBasesSpellings, |
||
| 4696 | /*ArgNames=*/{}) {} |
||
| 4697 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 4698 | if (!isa<CXXRecordDecl>(D)) { |
||
| 4699 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 4700 | << Attr << "classes"; |
||
| 4701 | return false; |
||
| 4702 | } |
||
| 4703 | return true; |
||
| 4704 | } |
||
| 4705 | |||
| 4706 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 4707 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 4708 | << AL << St->getBeginLoc(); |
||
| 4709 | return false; |
||
| 4710 | } |
||
| 4711 | |||
| 4712 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 4713 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 4714 | 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().isMicrosoft() ); |
||
| 4715 | } |
||
| 4716 | |||
| 4717 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 4718 | D->addAttr(::new (S.Context) EmptyBasesAttr(S.Context, Attr)); |
||
| 4719 | return AttributeApplied; |
||
| 4720 | } |
||
| 4721 | |||
| 4722 | bool isParamExpr(size_t N) const override { |
||
| 4723 | return false; |
||
| 4724 | } |
||
| 4725 | |||
| 4726 | static const ParsedAttrInfoEmptyBases Instance; |
||
| 4727 | }; |
||
| 4728 | const ParsedAttrInfoEmptyBases ParsedAttrInfoEmptyBases::Instance; |
||
| 4729 | static constexpr ParsedAttrInfo::Spelling EnableIfSpellings[] = { |
||
| 4730 | {AttributeCommonInfo::AS_GNU, "enable_if"}, |
||
| 4731 | }; |
||
| 4732 | static constexpr const char *EnableIfArgNames[] = { |
||
| 4733 | "Cond","Message",}; |
||
| 4734 | struct ParsedAttrInfoEnableIf final : public ParsedAttrInfo { |
||
| 4735 | constexpr ParsedAttrInfoEnableIf() : ParsedAttrInfo( |
||
| 4736 | /*AttrKind=*/ParsedAttr::AT_EnableIf, |
||
| 4737 | /*NumArgs=*/2, |
||
| 4738 | /*OptArgs=*/0, |
||
| 4739 | /*NumArgMembers=*/2, |
||
| 4740 | /*HasCustomParsing=*/0, |
||
| 4741 | /*AcceptsExprPack=*/0, |
||
| 4742 | /*IsTargetSpecific=*/0, |
||
| 4743 | /*IsType=*/0, |
||
| 4744 | /*IsStmt=*/0, |
||
| 4745 | /*IsKnownToGCC=*/0, |
||
| 4746 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 4747 | /*Spellings=*/EnableIfSpellings, |
||
| 4748 | /*ArgNames=*/EnableIfArgNames) {} |
||
| 4749 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 4750 | if (!isa<FunctionDecl>(D)) { |
||
| 4751 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 4752 | << Attr << "functions"; |
||
| 4753 | return false; |
||
| 4754 | } |
||
| 4755 | return true; |
||
| 4756 | } |
||
| 4757 | |||
| 4758 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 4759 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 4760 | << AL << St->getBeginLoc(); |
||
| 4761 | return false; |
||
| 4762 | } |
||
| 4763 | |||
| 4764 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 4765 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 4766 | } |
||
| 4767 | |||
| 4768 | bool isParamExpr(size_t N) const override { |
||
| 4769 | return (N == 0) || false; |
||
| 4770 | } |
||
| 4771 | |||
| 4772 | static const ParsedAttrInfoEnableIf Instance; |
||
| 4773 | }; |
||
| 4774 | const ParsedAttrInfoEnableIf ParsedAttrInfoEnableIf::Instance; |
||
| 4775 | static constexpr ParsedAttrInfo::Spelling EnforceTCBSpellings[] = { |
||
| 4776 | {AttributeCommonInfo::AS_GNU, "enforce_tcb"}, |
||
| 4777 | {AttributeCommonInfo::AS_CXX11, "clang::enforce_tcb"}, |
||
| 4778 | {AttributeCommonInfo::AS_C2x, "clang::enforce_tcb"}, |
||
| 4779 | }; |
||
| 4780 | static constexpr const char *EnforceTCBArgNames[] = { |
||
| 4781 | "TCBName",}; |
||
| 4782 | struct ParsedAttrInfoEnforceTCB final : public ParsedAttrInfo { |
||
| 4783 | constexpr ParsedAttrInfoEnforceTCB() : ParsedAttrInfo( |
||
| 4784 | /*AttrKind=*/ParsedAttr::AT_EnforceTCB, |
||
| 4785 | /*NumArgs=*/1, |
||
| 4786 | /*OptArgs=*/0, |
||
| 4787 | /*NumArgMembers=*/1, |
||
| 4788 | /*HasCustomParsing=*/0, |
||
| 4789 | /*AcceptsExprPack=*/0, |
||
| 4790 | /*IsTargetSpecific=*/0, |
||
| 4791 | /*IsType=*/0, |
||
| 4792 | /*IsStmt=*/0, |
||
| 4793 | /*IsKnownToGCC=*/0, |
||
| 4794 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 4795 | /*Spellings=*/EnforceTCBSpellings, |
||
| 4796 | /*ArgNames=*/EnforceTCBArgNames) {} |
||
| 4797 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 4798 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
||
| 4799 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 4800 | << Attr << "functions and Objective-C methods"; |
||
| 4801 | return false; |
||
| 4802 | } |
||
| 4803 | return true; |
||
| 4804 | } |
||
| 4805 | |||
| 4806 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 4807 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 4808 | << AL << St->getBeginLoc(); |
||
| 4809 | return false; |
||
| 4810 | } |
||
| 4811 | |||
| 4812 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 4813 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 4814 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 4815 | } |
||
| 4816 | |||
| 4817 | bool isParamExpr(size_t N) const override { |
||
| 4818 | return false; |
||
| 4819 | } |
||
| 4820 | |||
| 4821 | static const ParsedAttrInfoEnforceTCB Instance; |
||
| 4822 | }; |
||
| 4823 | const ParsedAttrInfoEnforceTCB ParsedAttrInfoEnforceTCB::Instance; |
||
| 4824 | static constexpr ParsedAttrInfo::Spelling EnforceTCBLeafSpellings[] = { |
||
| 4825 | {AttributeCommonInfo::AS_GNU, "enforce_tcb_leaf"}, |
||
| 4826 | {AttributeCommonInfo::AS_CXX11, "clang::enforce_tcb_leaf"}, |
||
| 4827 | {AttributeCommonInfo::AS_C2x, "clang::enforce_tcb_leaf"}, |
||
| 4828 | }; |
||
| 4829 | static constexpr const char *EnforceTCBLeafArgNames[] = { |
||
| 4830 | "TCBName",}; |
||
| 4831 | struct ParsedAttrInfoEnforceTCBLeaf final : public ParsedAttrInfo { |
||
| 4832 | constexpr ParsedAttrInfoEnforceTCBLeaf() : ParsedAttrInfo( |
||
| 4833 | /*AttrKind=*/ParsedAttr::AT_EnforceTCBLeaf, |
||
| 4834 | /*NumArgs=*/1, |
||
| 4835 | /*OptArgs=*/0, |
||
| 4836 | /*NumArgMembers=*/1, |
||
| 4837 | /*HasCustomParsing=*/0, |
||
| 4838 | /*AcceptsExprPack=*/0, |
||
| 4839 | /*IsTargetSpecific=*/0, |
||
| 4840 | /*IsType=*/0, |
||
| 4841 | /*IsStmt=*/0, |
||
| 4842 | /*IsKnownToGCC=*/0, |
||
| 4843 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 4844 | /*Spellings=*/EnforceTCBLeafSpellings, |
||
| 4845 | /*ArgNames=*/EnforceTCBLeafArgNames) {} |
||
| 4846 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 4847 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
||
| 4848 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 4849 | << Attr << "functions and Objective-C methods"; |
||
| 4850 | return false; |
||
| 4851 | } |
||
| 4852 | return true; |
||
| 4853 | } |
||
| 4854 | |||
| 4855 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 4856 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 4857 | << AL << St->getBeginLoc(); |
||
| 4858 | return false; |
||
| 4859 | } |
||
| 4860 | |||
| 4861 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 4862 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 4863 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 4864 | } |
||
| 4865 | |||
| 4866 | bool isParamExpr(size_t N) const override { |
||
| 4867 | return false; |
||
| 4868 | } |
||
| 4869 | |||
| 4870 | static const ParsedAttrInfoEnforceTCBLeaf Instance; |
||
| 4871 | }; |
||
| 4872 | const ParsedAttrInfoEnforceTCBLeaf ParsedAttrInfoEnforceTCBLeaf::Instance; |
||
| 4873 | static constexpr ParsedAttrInfo::Spelling EnumExtensibilitySpellings[] = { |
||
| 4874 | {AttributeCommonInfo::AS_GNU, "enum_extensibility"}, |
||
| 4875 | {AttributeCommonInfo::AS_CXX11, "clang::enum_extensibility"}, |
||
| 4876 | {AttributeCommonInfo::AS_C2x, "clang::enum_extensibility"}, |
||
| 4877 | }; |
||
| 4878 | static constexpr const char *EnumExtensibilityArgNames[] = { |
||
| 4879 | "Extensibility",}; |
||
| 4880 | struct ParsedAttrInfoEnumExtensibility final : public ParsedAttrInfo { |
||
| 4881 | constexpr ParsedAttrInfoEnumExtensibility() : ParsedAttrInfo( |
||
| 4882 | /*AttrKind=*/ParsedAttr::AT_EnumExtensibility, |
||
| 4883 | /*NumArgs=*/1, |
||
| 4884 | /*OptArgs=*/0, |
||
| 4885 | /*NumArgMembers=*/1, |
||
| 4886 | /*HasCustomParsing=*/0, |
||
| 4887 | /*AcceptsExprPack=*/0, |
||
| 4888 | /*IsTargetSpecific=*/0, |
||
| 4889 | /*IsType=*/0, |
||
| 4890 | /*IsStmt=*/0, |
||
| 4891 | /*IsKnownToGCC=*/0, |
||
| 4892 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 4893 | /*Spellings=*/EnumExtensibilitySpellings, |
||
| 4894 | /*ArgNames=*/EnumExtensibilityArgNames) {} |
||
| 4895 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 4896 | if (!isa<EnumDecl>(D)) { |
||
| 4897 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 4898 | << Attr << "enums"; |
||
| 4899 | return false; |
||
| 4900 | } |
||
| 4901 | return true; |
||
| 4902 | } |
||
| 4903 | |||
| 4904 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 4905 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 4906 | << AL << St->getBeginLoc(); |
||
| 4907 | return false; |
||
| 4908 | } |
||
| 4909 | |||
| 4910 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 4911 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_enum, /*IsSupported=*/true)); |
||
| 4912 | } |
||
| 4913 | |||
| 4914 | bool isParamExpr(size_t N) const override { |
||
| 4915 | return false; |
||
| 4916 | } |
||
| 4917 | |||
| 4918 | static const ParsedAttrInfoEnumExtensibility Instance; |
||
| 4919 | }; |
||
| 4920 | const ParsedAttrInfoEnumExtensibility ParsedAttrInfoEnumExtensibility::Instance; |
||
| 4921 | static constexpr ParsedAttrInfo::Spelling ErrorSpellings[] = { |
||
| 4922 | {AttributeCommonInfo::AS_GNU, "error"}, |
||
| 4923 | {AttributeCommonInfo::AS_CXX11, "gnu::error"}, |
||
| 4924 | {AttributeCommonInfo::AS_C2x, "gnu::error"}, |
||
| 4925 | {AttributeCommonInfo::AS_GNU, "warning"}, |
||
| 4926 | {AttributeCommonInfo::AS_CXX11, "gnu::warning"}, |
||
| 4927 | {AttributeCommonInfo::AS_C2x, "gnu::warning"}, |
||
| 4928 | }; |
||
| 4929 | static constexpr const char *ErrorArgNames[] = { |
||
| 4930 | "UserDiagnostic",}; |
||
| 4931 | struct ParsedAttrInfoError final : public ParsedAttrInfo { |
||
| 4932 | constexpr ParsedAttrInfoError() : ParsedAttrInfo( |
||
| 4933 | /*AttrKind=*/ParsedAttr::AT_Error, |
||
| 4934 | /*NumArgs=*/1, |
||
| 4935 | /*OptArgs=*/0, |
||
| 4936 | /*NumArgMembers=*/1, |
||
| 4937 | /*HasCustomParsing=*/0, |
||
| 4938 | /*AcceptsExprPack=*/0, |
||
| 4939 | /*IsTargetSpecific=*/0, |
||
| 4940 | /*IsType=*/0, |
||
| 4941 | /*IsStmt=*/0, |
||
| 4942 | /*IsKnownToGCC=*/1, |
||
| 4943 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 4944 | /*Spellings=*/ErrorSpellings, |
||
| 4945 | /*ArgNames=*/ErrorArgNames) {} |
||
| 4946 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 4947 | if (!isa<FunctionDecl>(D)) { |
||
| 4948 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 4949 | << Attr << "functions"; |
||
| 4950 | return false; |
||
| 4951 | } |
||
| 4952 | return true; |
||
| 4953 | } |
||
| 4954 | |||
| 4955 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 4956 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 4957 | << AL << St->getBeginLoc(); |
||
| 4958 | return false; |
||
| 4959 | } |
||
| 4960 | |||
| 4961 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 4962 | enum Spelling { |
||
| 4963 | GNU_error = 0, |
||
| 4964 | CXX11_gnu_error = 1, |
||
| 4965 | C2x_gnu_error = 2, |
||
| 4966 | GNU_warning = 3, |
||
| 4967 | CXX11_gnu_warning = 4, |
||
| 4968 | C2x_gnu_warning = 5, |
||
| 4969 | SpellingNotCalculated = 15 |
||
| 4970 | |||
| 4971 | }; |
||
| 4972 | |||
| 4973 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 4974 | switch (Idx) { |
||
| 4975 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 4976 | case 0: return GNU_error; |
||
| 4977 | case 1: return CXX11_gnu_error; |
||
| 4978 | case 2: return C2x_gnu_error; |
||
| 4979 | case 3: return GNU_warning; |
||
| 4980 | case 4: return CXX11_gnu_warning; |
||
| 4981 | case 5: return C2x_gnu_warning; |
||
| 4982 | } |
||
| 4983 | } |
||
| 4984 | |||
| 4985 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 4986 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 4987 | } |
||
| 4988 | |||
| 4989 | bool isParamExpr(size_t N) const override { |
||
| 4990 | return false; |
||
| 4991 | } |
||
| 4992 | |||
| 4993 | static const ParsedAttrInfoError Instance; |
||
| 4994 | }; |
||
| 4995 | const ParsedAttrInfoError ParsedAttrInfoError::Instance; |
||
| 4996 | static constexpr ParsedAttrInfo::Spelling ExcludeFromExplicitInstantiationSpellings[] = { |
||
| 4997 | {AttributeCommonInfo::AS_GNU, "exclude_from_explicit_instantiation"}, |
||
| 4998 | {AttributeCommonInfo::AS_CXX11, "clang::exclude_from_explicit_instantiation"}, |
||
| 4999 | {AttributeCommonInfo::AS_C2x, "clang::exclude_from_explicit_instantiation"}, |
||
| 5000 | }; |
||
| 5001 | struct ParsedAttrInfoExcludeFromExplicitInstantiation final : public ParsedAttrInfo { |
||
| 5002 | constexpr ParsedAttrInfoExcludeFromExplicitInstantiation() : ParsedAttrInfo( |
||
| 5003 | /*AttrKind=*/ParsedAttr::AT_ExcludeFromExplicitInstantiation, |
||
| 5004 | /*NumArgs=*/0, |
||
| 5005 | /*OptArgs=*/0, |
||
| 5006 | /*NumArgMembers=*/0, |
||
| 5007 | /*HasCustomParsing=*/0, |
||
| 5008 | /*AcceptsExprPack=*/0, |
||
| 5009 | /*IsTargetSpecific=*/0, |
||
| 5010 | /*IsType=*/0, |
||
| 5011 | /*IsStmt=*/0, |
||
| 5012 | /*IsKnownToGCC=*/0, |
||
| 5013 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 5014 | /*Spellings=*/ExcludeFromExplicitInstantiationSpellings, |
||
| 5015 | /*ArgNames=*/{}) {} |
||
| 5016 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 5017 | if (!isa<VarDecl>(D) && !isa<FunctionDecl>(D) && !isa<CXXRecordDecl>(D)) { |
||
| 5018 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 5019 | << Attr << "variables, functions, and classes"; |
||
| 5020 | return false; |
||
| 5021 | } |
||
| 5022 | return true; |
||
| 5023 | } |
||
| 5024 | |||
| 5025 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 5026 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 5027 | << AL << St->getBeginLoc(); |
||
| 5028 | return false; |
||
| 5029 | } |
||
| 5030 | |||
| 5031 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 5032 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
||
| 5033 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 5034 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 5035 | } |
||
| 5036 | |||
| 5037 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 5038 | D->addAttr(::new (S.Context) ExcludeFromExplicitInstantiationAttr(S.Context, Attr)); |
||
| 5039 | return AttributeApplied; |
||
| 5040 | } |
||
| 5041 | |||
| 5042 | bool isParamExpr(size_t N) const override { |
||
| 5043 | return false; |
||
| 5044 | } |
||
| 5045 | |||
| 5046 | static const ParsedAttrInfoExcludeFromExplicitInstantiation Instance; |
||
| 5047 | }; |
||
| 5048 | const ParsedAttrInfoExcludeFromExplicitInstantiation ParsedAttrInfoExcludeFromExplicitInstantiation::Instance; |
||
| 5049 | static constexpr ParsedAttrInfo::Spelling ExclusiveTrylockFunctionSpellings[] = { |
||
| 5050 | {AttributeCommonInfo::AS_GNU, "exclusive_trylock_function"}, |
||
| 5051 | }; |
||
| 5052 | static constexpr const char *ExclusiveTrylockFunctionArgNames[] = { |
||
| 5053 | "SuccessValue","Args...",}; |
||
| 5054 | struct ParsedAttrInfoExclusiveTrylockFunction final : public ParsedAttrInfo { |
||
| 5055 | constexpr ParsedAttrInfoExclusiveTrylockFunction() : ParsedAttrInfo( |
||
| 5056 | /*AttrKind=*/ParsedAttr::AT_ExclusiveTrylockFunction, |
||
| 5057 | /*NumArgs=*/1, |
||
| 5058 | /*OptArgs=*/15, |
||
| 5059 | /*NumArgMembers=*/2, |
||
| 5060 | /*HasCustomParsing=*/0, |
||
| 5061 | /*AcceptsExprPack=*/0, |
||
| 5062 | /*IsTargetSpecific=*/0, |
||
| 5063 | /*IsType=*/0, |
||
| 5064 | /*IsStmt=*/0, |
||
| 5065 | /*IsKnownToGCC=*/0, |
||
| 5066 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 5067 | /*Spellings=*/ExclusiveTrylockFunctionSpellings, |
||
| 5068 | /*ArgNames=*/ExclusiveTrylockFunctionArgNames) {} |
||
| 5069 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 5070 | if (!isa<FunctionDecl>(D)) { |
||
| 5071 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 5072 | << Attr << "functions"; |
||
| 5073 | return false; |
||
| 5074 | } |
||
| 5075 | return true; |
||
| 5076 | } |
||
| 5077 | |||
| 5078 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 5079 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 5080 | << AL << St->getBeginLoc(); |
||
| 5081 | return false; |
||
| 5082 | } |
||
| 5083 | |||
| 5084 | bool isParamExpr(size_t N) const override { |
||
| 5085 | return (N == 0) || (N == 1) || false; |
||
| 5086 | } |
||
| 5087 | |||
| 5088 | static const ParsedAttrInfoExclusiveTrylockFunction Instance; |
||
| 5089 | }; |
||
| 5090 | const ParsedAttrInfoExclusiveTrylockFunction ParsedAttrInfoExclusiveTrylockFunction::Instance; |
||
| 5091 | static constexpr ParsedAttrInfo::Spelling ExtVectorTypeSpellings[] = { |
||
| 5092 | {AttributeCommonInfo::AS_GNU, "ext_vector_type"}, |
||
| 5093 | }; |
||
| 5094 | static constexpr const char *ExtVectorTypeArgNames[] = { |
||
| 5095 | "NumElements",}; |
||
| 5096 | struct ParsedAttrInfoExtVectorType final : public ParsedAttrInfo { |
||
| 5097 | constexpr ParsedAttrInfoExtVectorType() : ParsedAttrInfo( |
||
| 5098 | /*AttrKind=*/ParsedAttr::AT_ExtVectorType, |
||
| 5099 | /*NumArgs=*/1, |
||
| 5100 | /*OptArgs=*/0, |
||
| 5101 | /*NumArgMembers=*/1, |
||
| 5102 | /*HasCustomParsing=*/0, |
||
| 5103 | /*AcceptsExprPack=*/0, |
||
| 5104 | /*IsTargetSpecific=*/0, |
||
| 5105 | /*IsType=*/0, |
||
| 5106 | /*IsStmt=*/0, |
||
| 5107 | /*IsKnownToGCC=*/0, |
||
| 5108 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 5109 | /*Spellings=*/ExtVectorTypeSpellings, |
||
| 5110 | /*ArgNames=*/ExtVectorTypeArgNames) {} |
||
| 5111 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 5112 | if (!isa<TypedefNameDecl>(D)) { |
||
| 5113 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 5114 | << Attr << "typedefs"; |
||
| 5115 | return false; |
||
| 5116 | } |
||
| 5117 | return true; |
||
| 5118 | } |
||
| 5119 | |||
| 5120 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 5121 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 5122 | << AL << St->getBeginLoc(); |
||
| 5123 | return false; |
||
| 5124 | } |
||
| 5125 | |||
| 5126 | bool isParamExpr(size_t N) const override { |
||
| 5127 | return (N == 0) || false; |
||
| 5128 | } |
||
| 5129 | |||
| 5130 | static const ParsedAttrInfoExtVectorType Instance; |
||
| 5131 | }; |
||
| 5132 | const ParsedAttrInfoExtVectorType ParsedAttrInfoExtVectorType::Instance; |
||
| 5133 | static constexpr ParsedAttrInfo::Spelling ExternalSourceSymbolSpellings[] = { |
||
| 5134 | {AttributeCommonInfo::AS_GNU, "external_source_symbol"}, |
||
| 5135 | {AttributeCommonInfo::AS_CXX11, "clang::external_source_symbol"}, |
||
| 5136 | {AttributeCommonInfo::AS_C2x, "clang::external_source_symbol"}, |
||
| 5137 | }; |
||
| 5138 | static constexpr const char *ExternalSourceSymbolArgNames[] = { |
||
| 5139 | "language","definedIn","generatedDeclaration",}; |
||
| 5140 | struct ParsedAttrInfoExternalSourceSymbol final : public ParsedAttrInfo { |
||
| 5141 | constexpr ParsedAttrInfoExternalSourceSymbol() : ParsedAttrInfo( |
||
| 5142 | /*AttrKind=*/ParsedAttr::AT_ExternalSourceSymbol, |
||
| 5143 | /*NumArgs=*/0, |
||
| 5144 | /*OptArgs=*/3, |
||
| 5145 | /*NumArgMembers=*/3, |
||
| 5146 | /*HasCustomParsing=*/1, |
||
| 5147 | /*AcceptsExprPack=*/0, |
||
| 5148 | /*IsTargetSpecific=*/0, |
||
| 5149 | /*IsType=*/0, |
||
| 5150 | /*IsStmt=*/0, |
||
| 5151 | /*IsKnownToGCC=*/0, |
||
| 5152 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 5153 | /*Spellings=*/ExternalSourceSymbolSpellings, |
||
| 5154 | /*ArgNames=*/ExternalSourceSymbolArgNames) {} |
||
| 5155 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 5156 | if (!isa<NamedDecl>(D)) { |
||
| 5157 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 5158 | << Attr << "named declarations"; |
||
| 5159 | return false; |
||
| 5160 | } |
||
| 5161 | return true; |
||
| 5162 | } |
||
| 5163 | |||
| 5164 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 5165 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 5166 | << AL << St->getBeginLoc(); |
||
| 5167 | return false; |
||
| 5168 | } |
||
| 5169 | |||
| 5170 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 5171 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 5172 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_enum, /*IsSupported=*/true)); |
||
| 5173 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_enum_constant, /*IsSupported=*/true)); |
||
| 5174 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_field, /*IsSupported=*/true)); |
||
| 5175 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 5176 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_namespace, /*IsSupported=*/LangOpts.CPlusPlus)); |
||
| 5177 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_category, /*IsSupported=*/LangOpts.ObjC)); |
||
| 5178 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_implementation, /*IsSupported=*/LangOpts.ObjC)); |
||
| 5179 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
||
| 5180 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 5181 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_property, /*IsSupported=*/LangOpts.ObjC)); |
||
| 5182 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_protocol, /*IsSupported=*/LangOpts.ObjC)); |
||
| 5183 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 5184 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true)); |
||
| 5185 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
||
| 5186 | } |
||
| 5187 | |||
| 5188 | bool isParamExpr(size_t N) const override { |
||
| 5189 | return false; |
||
| 5190 | } |
||
| 5191 | |||
| 5192 | static const ParsedAttrInfoExternalSourceSymbol Instance; |
||
| 5193 | }; |
||
| 5194 | const ParsedAttrInfoExternalSourceSymbol ParsedAttrInfoExternalSourceSymbol::Instance; |
||
| 5195 | static constexpr ParsedAttrInfo::Spelling FallThroughSpellings[] = { |
||
| 5196 | {AttributeCommonInfo::AS_CXX11, "fallthrough"}, |
||
| 5197 | {AttributeCommonInfo::AS_C2x, "fallthrough"}, |
||
| 5198 | {AttributeCommonInfo::AS_CXX11, "clang::fallthrough"}, |
||
| 5199 | {AttributeCommonInfo::AS_GNU, "fallthrough"}, |
||
| 5200 | {AttributeCommonInfo::AS_CXX11, "gnu::fallthrough"}, |
||
| 5201 | {AttributeCommonInfo::AS_C2x, "gnu::fallthrough"}, |
||
| 5202 | }; |
||
| 5203 | struct ParsedAttrInfoFallThrough final : public ParsedAttrInfo { |
||
| 5204 | constexpr ParsedAttrInfoFallThrough() : ParsedAttrInfo( |
||
| 5205 | /*AttrKind=*/ParsedAttr::AT_FallThrough, |
||
| 5206 | /*NumArgs=*/0, |
||
| 5207 | /*OptArgs=*/0, |
||
| 5208 | /*NumArgMembers=*/0, |
||
| 5209 | /*HasCustomParsing=*/0, |
||
| 5210 | /*AcceptsExprPack=*/0, |
||
| 5211 | /*IsTargetSpecific=*/0, |
||
| 5212 | /*IsType=*/0, |
||
| 5213 | /*IsStmt=*/1, |
||
| 5214 | /*IsKnownToGCC=*/1, |
||
| 5215 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 5216 | /*Spellings=*/FallThroughSpellings, |
||
| 5217 | /*ArgNames=*/{}) {} |
||
| 5218 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 5219 | S.Diag(AL.getLoc(), diag::err_attribute_invalid_on_decl) |
||
| 5220 | << AL << D->getLocation(); |
||
| 5221 | return false; |
||
| 5222 | } |
||
| 5223 | |||
| 5224 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &Attr, const Stmt *St) const override { |
||
| 5225 | if (!isa<NullStmt>(St) && !isa<SwitchCase>(St)) { |
||
| 5226 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 5227 | << Attr << "empty statements"; |
||
| 5228 | return false; |
||
| 5229 | } |
||
| 5230 | return true; |
||
| 5231 | } |
||
| 5232 | |||
| 5233 | bool isParamExpr(size_t N) const override { |
||
| 5234 | return false; |
||
| 5235 | } |
||
| 5236 | |||
| 5237 | static const ParsedAttrInfoFallThrough Instance; |
||
| 5238 | }; |
||
| 5239 | const ParsedAttrInfoFallThrough ParsedAttrInfoFallThrough::Instance; |
||
| 5240 | static constexpr ParsedAttrInfo::Spelling FastCallSpellings[] = { |
||
| 5241 | {AttributeCommonInfo::AS_GNU, "fastcall"}, |
||
| 5242 | {AttributeCommonInfo::AS_CXX11, "gnu::fastcall"}, |
||
| 5243 | {AttributeCommonInfo::AS_C2x, "gnu::fastcall"}, |
||
| 5244 | {AttributeCommonInfo::AS_Keyword, "__fastcall"}, |
||
| 5245 | {AttributeCommonInfo::AS_Keyword, "_fastcall"}, |
||
| 5246 | }; |
||
| 5247 | struct ParsedAttrInfoFastCall final : public ParsedAttrInfo { |
||
| 5248 | constexpr ParsedAttrInfoFastCall() : ParsedAttrInfo( |
||
| 5249 | /*AttrKind=*/ParsedAttr::AT_FastCall, |
||
| 5250 | /*NumArgs=*/0, |
||
| 5251 | /*OptArgs=*/0, |
||
| 5252 | /*NumArgMembers=*/0, |
||
| 5253 | /*HasCustomParsing=*/0, |
||
| 5254 | /*AcceptsExprPack=*/0, |
||
| 5255 | /*IsTargetSpecific=*/0, |
||
| 5256 | /*IsType=*/1, |
||
| 5257 | /*IsStmt=*/0, |
||
| 5258 | /*IsKnownToGCC=*/1, |
||
| 5259 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 5260 | /*Spellings=*/FastCallSpellings, |
||
| 5261 | /*ArgNames=*/{}) {} |
||
| 5262 | bool isParamExpr(size_t N) const override { |
||
| 5263 | return false; |
||
| 5264 | } |
||
| 5265 | |||
| 5266 | static const ParsedAttrInfoFastCall Instance; |
||
| 5267 | }; |
||
| 5268 | const ParsedAttrInfoFastCall ParsedAttrInfoFastCall::Instance; |
||
| 5269 | static constexpr ParsedAttrInfo::Spelling FlagEnumSpellings[] = { |
||
| 5270 | {AttributeCommonInfo::AS_GNU, "flag_enum"}, |
||
| 5271 | {AttributeCommonInfo::AS_CXX11, "clang::flag_enum"}, |
||
| 5272 | {AttributeCommonInfo::AS_C2x, "clang::flag_enum"}, |
||
| 5273 | }; |
||
| 5274 | struct ParsedAttrInfoFlagEnum final : public ParsedAttrInfo { |
||
| 5275 | constexpr ParsedAttrInfoFlagEnum() : ParsedAttrInfo( |
||
| 5276 | /*AttrKind=*/ParsedAttr::AT_FlagEnum, |
||
| 5277 | /*NumArgs=*/0, |
||
| 5278 | /*OptArgs=*/0, |
||
| 5279 | /*NumArgMembers=*/0, |
||
| 5280 | /*HasCustomParsing=*/0, |
||
| 5281 | /*AcceptsExprPack=*/0, |
||
| 5282 | /*IsTargetSpecific=*/0, |
||
| 5283 | /*IsType=*/0, |
||
| 5284 | /*IsStmt=*/0, |
||
| 5285 | /*IsKnownToGCC=*/0, |
||
| 5286 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 5287 | /*Spellings=*/FlagEnumSpellings, |
||
| 5288 | /*ArgNames=*/{}) {} |
||
| 5289 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 5290 | if (!isa<EnumDecl>(D)) { |
||
| 5291 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 5292 | << Attr << "enums"; |
||
| 5293 | return false; |
||
| 5294 | } |
||
| 5295 | return true; |
||
| 5296 | } |
||
| 5297 | |||
| 5298 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 5299 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 5300 | << AL << St->getBeginLoc(); |
||
| 5301 | return false; |
||
| 5302 | } |
||
| 5303 | |||
| 5304 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 5305 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_enum, /*IsSupported=*/true)); |
||
| 5306 | } |
||
| 5307 | |||
| 5308 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 5309 | D->addAttr(::new (S.Context) FlagEnumAttr(S.Context, Attr)); |
||
| 5310 | return AttributeApplied; |
||
| 5311 | } |
||
| 5312 | |||
| 5313 | bool isParamExpr(size_t N) const override { |
||
| 5314 | return false; |
||
| 5315 | } |
||
| 5316 | |||
| 5317 | static const ParsedAttrInfoFlagEnum Instance; |
||
| 5318 | }; |
||
| 5319 | const ParsedAttrInfoFlagEnum ParsedAttrInfoFlagEnum::Instance; |
||
| 5320 | static constexpr ParsedAttrInfo::Spelling FlattenSpellings[] = { |
||
| 5321 | {AttributeCommonInfo::AS_GNU, "flatten"}, |
||
| 5322 | {AttributeCommonInfo::AS_CXX11, "gnu::flatten"}, |
||
| 5323 | {AttributeCommonInfo::AS_C2x, "gnu::flatten"}, |
||
| 5324 | }; |
||
| 5325 | struct ParsedAttrInfoFlatten final : public ParsedAttrInfo { |
||
| 5326 | constexpr ParsedAttrInfoFlatten() : ParsedAttrInfo( |
||
| 5327 | /*AttrKind=*/ParsedAttr::AT_Flatten, |
||
| 5328 | /*NumArgs=*/0, |
||
| 5329 | /*OptArgs=*/0, |
||
| 5330 | /*NumArgMembers=*/0, |
||
| 5331 | /*HasCustomParsing=*/0, |
||
| 5332 | /*AcceptsExprPack=*/0, |
||
| 5333 | /*IsTargetSpecific=*/0, |
||
| 5334 | /*IsType=*/0, |
||
| 5335 | /*IsStmt=*/0, |
||
| 5336 | /*IsKnownToGCC=*/1, |
||
| 5337 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 5338 | /*Spellings=*/FlattenSpellings, |
||
| 5339 | /*ArgNames=*/{}) {} |
||
| 5340 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 5341 | if (!isa<FunctionDecl>(D)) { |
||
| 5342 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 5343 | << Attr << "functions"; |
||
| 5344 | return false; |
||
| 5345 | } |
||
| 5346 | return true; |
||
| 5347 | } |
||
| 5348 | |||
| 5349 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 5350 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 5351 | << AL << St->getBeginLoc(); |
||
| 5352 | return false; |
||
| 5353 | } |
||
| 5354 | |||
| 5355 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 5356 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 5357 | } |
||
| 5358 | |||
| 5359 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 5360 | D->addAttr(::new (S.Context) FlattenAttr(S.Context, Attr)); |
||
| 5361 | return AttributeApplied; |
||
| 5362 | } |
||
| 5363 | |||
| 5364 | bool isParamExpr(size_t N) const override { |
||
| 5365 | return false; |
||
| 5366 | } |
||
| 5367 | |||
| 5368 | static const ParsedAttrInfoFlatten Instance; |
||
| 5369 | }; |
||
| 5370 | const ParsedAttrInfoFlatten ParsedAttrInfoFlatten::Instance; |
||
| 5371 | static constexpr ParsedAttrInfo::Spelling FormatSpellings[] = { |
||
| 5372 | {AttributeCommonInfo::AS_GNU, "format"}, |
||
| 5373 | {AttributeCommonInfo::AS_CXX11, "gnu::format"}, |
||
| 5374 | {AttributeCommonInfo::AS_C2x, "gnu::format"}, |
||
| 5375 | }; |
||
| 5376 | static constexpr const char *FormatArgNames[] = { |
||
| 5377 | "Type","FormatIdx","FirstArg",}; |
||
| 5378 | struct ParsedAttrInfoFormat final : public ParsedAttrInfo { |
||
| 5379 | constexpr ParsedAttrInfoFormat() : ParsedAttrInfo( |
||
| 5380 | /*AttrKind=*/ParsedAttr::AT_Format, |
||
| 5381 | /*NumArgs=*/3, |
||
| 5382 | /*OptArgs=*/0, |
||
| 5383 | /*NumArgMembers=*/3, |
||
| 5384 | /*HasCustomParsing=*/0, |
||
| 5385 | /*AcceptsExprPack=*/0, |
||
| 5386 | /*IsTargetSpecific=*/0, |
||
| 5387 | /*IsType=*/0, |
||
| 5388 | /*IsStmt=*/0, |
||
| 5389 | /*IsKnownToGCC=*/1, |
||
| 5390 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 5391 | /*Spellings=*/FormatSpellings, |
||
| 5392 | /*ArgNames=*/FormatArgNames) {} |
||
| 5393 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 5394 | if (!isa<ObjCMethodDecl>(D) && !isa<BlockDecl>(D) && !isHasFunctionProto(D)) { |
||
| 5395 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 5396 | << Attr << "Objective-C methods, blocks, and non-K&R-style functions"; |
||
| 5397 | return false; |
||
| 5398 | } |
||
| 5399 | return true; |
||
| 5400 | } |
||
| 5401 | |||
| 5402 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 5403 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 5404 | << AL << St->getBeginLoc(); |
||
| 5405 | return false; |
||
| 5406 | } |
||
| 5407 | |||
| 5408 | bool isParamExpr(size_t N) const override { |
||
| 5409 | return false; |
||
| 5410 | } |
||
| 5411 | |||
| 5412 | static const ParsedAttrInfoFormat Instance; |
||
| 5413 | }; |
||
| 5414 | const ParsedAttrInfoFormat ParsedAttrInfoFormat::Instance; |
||
| 5415 | static constexpr ParsedAttrInfo::Spelling FormatArgSpellings[] = { |
||
| 5416 | {AttributeCommonInfo::AS_GNU, "format_arg"}, |
||
| 5417 | {AttributeCommonInfo::AS_CXX11, "gnu::format_arg"}, |
||
| 5418 | {AttributeCommonInfo::AS_C2x, "gnu::format_arg"}, |
||
| 5419 | }; |
||
| 5420 | static constexpr const char *FormatArgArgNames[] = { |
||
| 5421 | "FormatIdx",}; |
||
| 5422 | struct ParsedAttrInfoFormatArg final : public ParsedAttrInfo { |
||
| 5423 | constexpr ParsedAttrInfoFormatArg() : ParsedAttrInfo( |
||
| 5424 | /*AttrKind=*/ParsedAttr::AT_FormatArg, |
||
| 5425 | /*NumArgs=*/1, |
||
| 5426 | /*OptArgs=*/0, |
||
| 5427 | /*NumArgMembers=*/1, |
||
| 5428 | /*HasCustomParsing=*/0, |
||
| 5429 | /*AcceptsExprPack=*/0, |
||
| 5430 | /*IsTargetSpecific=*/0, |
||
| 5431 | /*IsType=*/0, |
||
| 5432 | /*IsStmt=*/0, |
||
| 5433 | /*IsKnownToGCC=*/1, |
||
| 5434 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 5435 | /*Spellings=*/FormatArgSpellings, |
||
| 5436 | /*ArgNames=*/FormatArgArgNames) {} |
||
| 5437 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 5438 | if (!isa<ObjCMethodDecl>(D) && !isHasFunctionProto(D)) { |
||
| 5439 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 5440 | << Attr << "Objective-C methods and non-K&R-style functions"; |
||
| 5441 | return false; |
||
| 5442 | } |
||
| 5443 | return true; |
||
| 5444 | } |
||
| 5445 | |||
| 5446 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 5447 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 5448 | << AL << St->getBeginLoc(); |
||
| 5449 | return false; |
||
| 5450 | } |
||
| 5451 | |||
| 5452 | bool isParamExpr(size_t N) const override { |
||
| 5453 | return false; |
||
| 5454 | } |
||
| 5455 | |||
| 5456 | static const ParsedAttrInfoFormatArg Instance; |
||
| 5457 | }; |
||
| 5458 | const ParsedAttrInfoFormatArg ParsedAttrInfoFormatArg::Instance; |
||
| 5459 | static constexpr ParsedAttrInfo::Spelling FunctionReturnThunksSpellings[] = { |
||
| 5460 | {AttributeCommonInfo::AS_GNU, "function_return"}, |
||
| 5461 | {AttributeCommonInfo::AS_CXX11, "gnu::function_return"}, |
||
| 5462 | {AttributeCommonInfo::AS_C2x, "gnu::function_return"}, |
||
| 5463 | }; |
||
| 5464 | static constexpr const char *FunctionReturnThunksArgNames[] = { |
||
| 5465 | "ThunkType",}; |
||
| 5466 | struct ParsedAttrInfoFunctionReturnThunks final : public ParsedAttrInfo { |
||
| 5467 | constexpr ParsedAttrInfoFunctionReturnThunks() : ParsedAttrInfo( |
||
| 5468 | /*AttrKind=*/ParsedAttr::AT_FunctionReturnThunks, |
||
| 5469 | /*NumArgs=*/1, |
||
| 5470 | /*OptArgs=*/0, |
||
| 5471 | /*NumArgMembers=*/1, |
||
| 5472 | /*HasCustomParsing=*/0, |
||
| 5473 | /*AcceptsExprPack=*/0, |
||
| 5474 | /*IsTargetSpecific=*/1, |
||
| 5475 | /*IsType=*/0, |
||
| 5476 | /*IsStmt=*/0, |
||
| 5477 | /*IsKnownToGCC=*/1, |
||
| 5478 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 5479 | /*Spellings=*/FunctionReturnThunksSpellings, |
||
| 5480 | /*ArgNames=*/FunctionReturnThunksArgNames) {} |
||
| 5481 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 5482 | if (!isa<FunctionDecl>(D)) { |
||
| 5483 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 5484 | << Attr << "functions"; |
||
| 5485 | return false; |
||
| 5486 | } |
||
| 5487 | return true; |
||
| 5488 | } |
||
| 5489 | |||
| 5490 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 5491 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 5492 | << AL << St->getBeginLoc(); |
||
| 5493 | return false; |
||
| 5494 | } |
||
| 5495 | |||
| 5496 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 5497 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 5498 | return true && (T.getArch() == llvm::Triple::x86 || T.getArch() == llvm::Triple::x86_64); |
||
| 5499 | } |
||
| 5500 | |||
| 5501 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 5502 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 5503 | } |
||
| 5504 | |||
| 5505 | bool isParamExpr(size_t N) const override { |
||
| 5506 | return false; |
||
| 5507 | } |
||
| 5508 | |||
| 5509 | static const ParsedAttrInfoFunctionReturnThunks Instance; |
||
| 5510 | }; |
||
| 5511 | const ParsedAttrInfoFunctionReturnThunks ParsedAttrInfoFunctionReturnThunks::Instance; |
||
| 5512 | static constexpr ParsedAttrInfo::Spelling GNUInlineSpellings[] = { |
||
| 5513 | {AttributeCommonInfo::AS_GNU, "gnu_inline"}, |
||
| 5514 | {AttributeCommonInfo::AS_CXX11, "gnu::gnu_inline"}, |
||
| 5515 | {AttributeCommonInfo::AS_C2x, "gnu::gnu_inline"}, |
||
| 5516 | }; |
||
| 5517 | struct ParsedAttrInfoGNUInline final : public ParsedAttrInfo { |
||
| 5518 | constexpr ParsedAttrInfoGNUInline() : ParsedAttrInfo( |
||
| 5519 | /*AttrKind=*/ParsedAttr::AT_GNUInline, |
||
| 5520 | /*NumArgs=*/0, |
||
| 5521 | /*OptArgs=*/0, |
||
| 5522 | /*NumArgMembers=*/0, |
||
| 5523 | /*HasCustomParsing=*/0, |
||
| 5524 | /*AcceptsExprPack=*/0, |
||
| 5525 | /*IsTargetSpecific=*/0, |
||
| 5526 | /*IsType=*/0, |
||
| 5527 | /*IsStmt=*/0, |
||
| 5528 | /*IsKnownToGCC=*/1, |
||
| 5529 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 5530 | /*Spellings=*/GNUInlineSpellings, |
||
| 5531 | /*ArgNames=*/{}) {} |
||
| 5532 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 5533 | if (!isa<FunctionDecl>(D)) { |
||
| 5534 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 5535 | << Attr << "functions"; |
||
| 5536 | return false; |
||
| 5537 | } |
||
| 5538 | return true; |
||
| 5539 | } |
||
| 5540 | |||
| 5541 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 5542 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 5543 | << AL << St->getBeginLoc(); |
||
| 5544 | return false; |
||
| 5545 | } |
||
| 5546 | |||
| 5547 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 5548 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 5549 | } |
||
| 5550 | |||
| 5551 | bool isParamExpr(size_t N) const override { |
||
| 5552 | return false; |
||
| 5553 | } |
||
| 5554 | |||
| 5555 | static const ParsedAttrInfoGNUInline Instance; |
||
| 5556 | }; |
||
| 5557 | const ParsedAttrInfoGNUInline ParsedAttrInfoGNUInline::Instance; |
||
| 5558 | static constexpr ParsedAttrInfo::Spelling GuardedBySpellings[] = { |
||
| 5559 | {AttributeCommonInfo::AS_GNU, "guarded_by"}, |
||
| 5560 | }; |
||
| 5561 | static constexpr const char *GuardedByArgNames[] = { |
||
| 5562 | "Arg",}; |
||
| 5563 | struct ParsedAttrInfoGuardedBy final : public ParsedAttrInfo { |
||
| 5564 | constexpr ParsedAttrInfoGuardedBy() : ParsedAttrInfo( |
||
| 5565 | /*AttrKind=*/ParsedAttr::AT_GuardedBy, |
||
| 5566 | /*NumArgs=*/1, |
||
| 5567 | /*OptArgs=*/0, |
||
| 5568 | /*NumArgMembers=*/1, |
||
| 5569 | /*HasCustomParsing=*/0, |
||
| 5570 | /*AcceptsExprPack=*/0, |
||
| 5571 | /*IsTargetSpecific=*/0, |
||
| 5572 | /*IsType=*/0, |
||
| 5573 | /*IsStmt=*/0, |
||
| 5574 | /*IsKnownToGCC=*/0, |
||
| 5575 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 5576 | /*Spellings=*/GuardedBySpellings, |
||
| 5577 | /*ArgNames=*/GuardedByArgNames) {} |
||
| 5578 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 5579 | if (!isa<FieldDecl>(D) && !isSharedVar(D)) { |
||
| 5580 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 5581 | << Attr << "non-static data members and global variables"; |
||
| 5582 | return false; |
||
| 5583 | } |
||
| 5584 | return true; |
||
| 5585 | } |
||
| 5586 | |||
| 5587 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 5588 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 5589 | << AL << St->getBeginLoc(); |
||
| 5590 | return false; |
||
| 5591 | } |
||
| 5592 | |||
| 5593 | bool isParamExpr(size_t N) const override { |
||
| 5594 | return (N == 0) || false; |
||
| 5595 | } |
||
| 5596 | |||
| 5597 | static const ParsedAttrInfoGuardedBy Instance; |
||
| 5598 | }; |
||
| 5599 | const ParsedAttrInfoGuardedBy ParsedAttrInfoGuardedBy::Instance; |
||
| 5600 | static constexpr ParsedAttrInfo::Spelling GuardedVarSpellings[] = { |
||
| 5601 | {AttributeCommonInfo::AS_GNU, "guarded_var"}, |
||
| 5602 | {AttributeCommonInfo::AS_CXX11, "clang::guarded_var"}, |
||
| 5603 | }; |
||
| 5604 | struct ParsedAttrInfoGuardedVar final : public ParsedAttrInfo { |
||
| 5605 | constexpr ParsedAttrInfoGuardedVar() : ParsedAttrInfo( |
||
| 5606 | /*AttrKind=*/ParsedAttr::AT_GuardedVar, |
||
| 5607 | /*NumArgs=*/0, |
||
| 5608 | /*OptArgs=*/0, |
||
| 5609 | /*NumArgMembers=*/0, |
||
| 5610 | /*HasCustomParsing=*/0, |
||
| 5611 | /*AcceptsExprPack=*/0, |
||
| 5612 | /*IsTargetSpecific=*/0, |
||
| 5613 | /*IsType=*/0, |
||
| 5614 | /*IsStmt=*/0, |
||
| 5615 | /*IsKnownToGCC=*/0, |
||
| 5616 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 5617 | /*Spellings=*/GuardedVarSpellings, |
||
| 5618 | /*ArgNames=*/{}) {} |
||
| 5619 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 5620 | if (!isa<FieldDecl>(D) && !isSharedVar(D)) { |
||
| 5621 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 5622 | << Attr << "non-static data members and global variables"; |
||
| 5623 | return false; |
||
| 5624 | } |
||
| 5625 | return true; |
||
| 5626 | } |
||
| 5627 | |||
| 5628 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 5629 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 5630 | << AL << St->getBeginLoc(); |
||
| 5631 | return false; |
||
| 5632 | } |
||
| 5633 | |||
| 5634 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 5635 | D->addAttr(::new (S.Context) GuardedVarAttr(S.Context, Attr)); |
||
| 5636 | return AttributeApplied; |
||
| 5637 | } |
||
| 5638 | |||
| 5639 | bool isParamExpr(size_t N) const override { |
||
| 5640 | return false; |
||
| 5641 | } |
||
| 5642 | |||
| 5643 | static const ParsedAttrInfoGuardedVar Instance; |
||
| 5644 | }; |
||
| 5645 | const ParsedAttrInfoGuardedVar ParsedAttrInfoGuardedVar::Instance; |
||
| 5646 | static constexpr ParsedAttrInfo::Spelling HIPManagedSpellings[] = { |
||
| 5647 | {AttributeCommonInfo::AS_GNU, "managed"}, |
||
| 5648 | {AttributeCommonInfo::AS_Declspec, "__managed__"}, |
||
| 5649 | }; |
||
| 5650 | struct ParsedAttrInfoHIPManaged final : public ParsedAttrInfo { |
||
| 5651 | constexpr ParsedAttrInfoHIPManaged() : ParsedAttrInfo( |
||
| 5652 | /*AttrKind=*/ParsedAttr::AT_HIPManaged, |
||
| 5653 | /*NumArgs=*/0, |
||
| 5654 | /*OptArgs=*/0, |
||
| 5655 | /*NumArgMembers=*/0, |
||
| 5656 | /*HasCustomParsing=*/0, |
||
| 5657 | /*AcceptsExprPack=*/0, |
||
| 5658 | /*IsTargetSpecific=*/0, |
||
| 5659 | /*IsType=*/0, |
||
| 5660 | /*IsStmt=*/0, |
||
| 5661 | /*IsKnownToGCC=*/0, |
||
| 5662 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 5663 | /*Spellings=*/HIPManagedSpellings, |
||
| 5664 | /*ArgNames=*/{}) {} |
||
| 5665 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 5666 | if (!isa<VarDecl>(D)) { |
||
| 5667 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 5668 | << Attr << "variables"; |
||
| 5669 | return false; |
||
| 5670 | } |
||
| 5671 | return true; |
||
| 5672 | } |
||
| 5673 | |||
| 5674 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 5675 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 5676 | << AL << St->getBeginLoc(); |
||
| 5677 | return false; |
||
| 5678 | } |
||
| 5679 | |||
| 5680 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 5681 | |||
| 5682 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 5683 | if (const auto *A = D->getAttr<CUDAConstantAttr>()) { |
||
| 5684 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 5685 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 5686 | return false; |
||
| 5687 | } |
||
| 5688 | if (const auto *A = D->getAttr<CUDASharedAttr>()) { |
||
| 5689 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 5690 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 5691 | return false; |
||
| 5692 | } |
||
| 5693 | return true; |
||
| 5694 | } |
||
| 5695 | |||
| 5696 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 5697 | return LangOpts.HIP; |
||
| 5698 | } |
||
| 5699 | |||
| 5700 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 5701 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
||
| 5702 | } |
||
| 5703 | |||
| 5704 | bool isParamExpr(size_t N) const override { |
||
| 5705 | return false; |
||
| 5706 | } |
||
| 5707 | |||
| 5708 | static const ParsedAttrInfoHIPManaged Instance; |
||
| 5709 | }; |
||
| 5710 | const ParsedAttrInfoHIPManaged ParsedAttrInfoHIPManaged::Instance; |
||
| 5711 | static constexpr ParsedAttrInfo::Spelling HLSLGroupSharedAddressSpaceSpellings[] = { |
||
| 5712 | {AttributeCommonInfo::AS_Keyword, "groupshared"}, |
||
| 5713 | }; |
||
| 5714 | struct ParsedAttrInfoHLSLGroupSharedAddressSpace final : public ParsedAttrInfo { |
||
| 5715 | constexpr ParsedAttrInfoHLSLGroupSharedAddressSpace() : ParsedAttrInfo( |
||
| 5716 | /*AttrKind=*/ParsedAttr::AT_HLSLGroupSharedAddressSpace, |
||
| 5717 | /*NumArgs=*/0, |
||
| 5718 | /*OptArgs=*/0, |
||
| 5719 | /*NumArgMembers=*/0, |
||
| 5720 | /*HasCustomParsing=*/0, |
||
| 5721 | /*AcceptsExprPack=*/0, |
||
| 5722 | /*IsTargetSpecific=*/0, |
||
| 5723 | /*IsType=*/1, |
||
| 5724 | /*IsStmt=*/0, |
||
| 5725 | /*IsKnownToGCC=*/0, |
||
| 5726 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 5727 | /*Spellings=*/HLSLGroupSharedAddressSpaceSpellings, |
||
| 5728 | /*ArgNames=*/{}) {} |
||
| 5729 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 5730 | if (!isa<VarDecl>(D)) { |
||
| 5731 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 5732 | << Attr << "variables"; |
||
| 5733 | return false; |
||
| 5734 | } |
||
| 5735 | return true; |
||
| 5736 | } |
||
| 5737 | |||
| 5738 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 5739 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 5740 | << AL << St->getBeginLoc(); |
||
| 5741 | return false; |
||
| 5742 | } |
||
| 5743 | |||
| 5744 | bool isParamExpr(size_t N) const override { |
||
| 5745 | return false; |
||
| 5746 | } |
||
| 5747 | |||
| 5748 | static const ParsedAttrInfoHLSLGroupSharedAddressSpace Instance; |
||
| 5749 | }; |
||
| 5750 | const ParsedAttrInfoHLSLGroupSharedAddressSpace ParsedAttrInfoHLSLGroupSharedAddressSpace::Instance; |
||
| 5751 | static constexpr ParsedAttrInfo::Spelling HLSLNumThreadsSpellings[] = { |
||
| 5752 | {AttributeCommonInfo::AS_Microsoft, "numthreads"}, |
||
| 5753 | }; |
||
| 5754 | static constexpr const char *HLSLNumThreadsArgNames[] = { |
||
| 5755 | "X","Y","Z",}; |
||
| 5756 | struct ParsedAttrInfoHLSLNumThreads final : public ParsedAttrInfo { |
||
| 5757 | constexpr ParsedAttrInfoHLSLNumThreads() : ParsedAttrInfo( |
||
| 5758 | /*AttrKind=*/ParsedAttr::AT_HLSLNumThreads, |
||
| 5759 | /*NumArgs=*/3, |
||
| 5760 | /*OptArgs=*/0, |
||
| 5761 | /*NumArgMembers=*/3, |
||
| 5762 | /*HasCustomParsing=*/0, |
||
| 5763 | /*AcceptsExprPack=*/0, |
||
| 5764 | /*IsTargetSpecific=*/0, |
||
| 5765 | /*IsType=*/0, |
||
| 5766 | /*IsStmt=*/0, |
||
| 5767 | /*IsKnownToGCC=*/0, |
||
| 5768 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 5769 | /*Spellings=*/HLSLNumThreadsSpellings, |
||
| 5770 | /*ArgNames=*/HLSLNumThreadsArgNames) {} |
||
| 5771 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 5772 | if (!isHLSLEntry(D)) { |
||
| 5773 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 5774 | << Attr << "global functions"; |
||
| 5775 | return false; |
||
| 5776 | } |
||
| 5777 | return true; |
||
| 5778 | } |
||
| 5779 | |||
| 5780 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 5781 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 5782 | << AL << St->getBeginLoc(); |
||
| 5783 | return false; |
||
| 5784 | } |
||
| 5785 | |||
| 5786 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 5787 | return LangOpts.HLSL; |
||
| 5788 | } |
||
| 5789 | |||
| 5790 | bool isParamExpr(size_t N) const override { |
||
| 5791 | return false; |
||
| 5792 | } |
||
| 5793 | |||
| 5794 | static const ParsedAttrInfoHLSLNumThreads Instance; |
||
| 5795 | }; |
||
| 5796 | const ParsedAttrInfoHLSLNumThreads ParsedAttrInfoHLSLNumThreads::Instance; |
||
| 5797 | static constexpr const char *HLSLResourceArgNames[] = { |
||
| 5798 | "ResourceType","ResourceShape",}; |
||
| 5799 | struct ParsedAttrInfoHLSLResource final : public ParsedAttrInfo { |
||
| 5800 | constexpr ParsedAttrInfoHLSLResource() : ParsedAttrInfo( |
||
| 5801 | /*AttrKind=*/ParsedAttr::AT_HLSLResource, |
||
| 5802 | /*NumArgs=*/2, |
||
| 5803 | /*OptArgs=*/0, |
||
| 5804 | /*NumArgMembers=*/2, |
||
| 5805 | /*HasCustomParsing=*/0, |
||
| 5806 | /*AcceptsExprPack=*/0, |
||
| 5807 | /*IsTargetSpecific=*/0, |
||
| 5808 | /*IsType=*/0, |
||
| 5809 | /*IsStmt=*/0, |
||
| 5810 | /*IsKnownToGCC=*/0, |
||
| 5811 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 5812 | /*Spellings=*/{}, |
||
| 5813 | /*ArgNames=*/HLSLResourceArgNames) {} |
||
| 5814 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 5815 | if (!isStruct(D)) { |
||
| 5816 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 5817 | << Attr << "structs"; |
||
| 5818 | return false; |
||
| 5819 | } |
||
| 5820 | return true; |
||
| 5821 | } |
||
| 5822 | |||
| 5823 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 5824 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 5825 | << AL << St->getBeginLoc(); |
||
| 5826 | return false; |
||
| 5827 | } |
||
| 5828 | |||
| 5829 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 5830 | return LangOpts.HLSL; |
||
| 5831 | } |
||
| 5832 | |||
| 5833 | bool isParamExpr(size_t N) const override { |
||
| 5834 | return false; |
||
| 5835 | } |
||
| 5836 | |||
| 5837 | static const ParsedAttrInfoHLSLResource Instance; |
||
| 5838 | }; |
||
| 5839 | const ParsedAttrInfoHLSLResource ParsedAttrInfoHLSLResource::Instance; |
||
| 5840 | static constexpr ParsedAttrInfo::Spelling HLSLResourceBindingSpellings[] = { |
||
| 5841 | {AttributeCommonInfo::AS_HLSLSemantic, "register"}, |
||
| 5842 | }; |
||
| 5843 | static constexpr const char *HLSLResourceBindingArgNames[] = { |
||
| 5844 | "Slot","Space",}; |
||
| 5845 | struct ParsedAttrInfoHLSLResourceBinding final : public ParsedAttrInfo { |
||
| 5846 | constexpr ParsedAttrInfoHLSLResourceBinding() : ParsedAttrInfo( |
||
| 5847 | /*AttrKind=*/ParsedAttr::AT_HLSLResourceBinding, |
||
| 5848 | /*NumArgs=*/1, |
||
| 5849 | /*OptArgs=*/1, |
||
| 5850 | /*NumArgMembers=*/2, |
||
| 5851 | /*HasCustomParsing=*/0, |
||
| 5852 | /*AcceptsExprPack=*/0, |
||
| 5853 | /*IsTargetSpecific=*/0, |
||
| 5854 | /*IsType=*/0, |
||
| 5855 | /*IsStmt=*/0, |
||
| 5856 | /*IsKnownToGCC=*/0, |
||
| 5857 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 5858 | /*Spellings=*/HLSLResourceBindingSpellings, |
||
| 5859 | /*ArgNames=*/HLSLResourceBindingArgNames) {} |
||
| 5860 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 5861 | if (!isHLSLBufferObj(D) && !isExternalGlobalVar(D)) { |
||
| 5862 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 5863 | << Attr << "cbuffer/tbuffer and external global variables"; |
||
| 5864 | return false; |
||
| 5865 | } |
||
| 5866 | return true; |
||
| 5867 | } |
||
| 5868 | |||
| 5869 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 5870 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 5871 | << AL << St->getBeginLoc(); |
||
| 5872 | return false; |
||
| 5873 | } |
||
| 5874 | |||
| 5875 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 5876 | return LangOpts.HLSL; |
||
| 5877 | } |
||
| 5878 | |||
| 5879 | bool isParamExpr(size_t N) const override { |
||
| 5880 | return false; |
||
| 5881 | } |
||
| 5882 | |||
| 5883 | static const ParsedAttrInfoHLSLResourceBinding Instance; |
||
| 5884 | }; |
||
| 5885 | const ParsedAttrInfoHLSLResourceBinding ParsedAttrInfoHLSLResourceBinding::Instance; |
||
| 5886 | static constexpr ParsedAttrInfo::Spelling HLSLSV_DispatchThreadIDSpellings[] = { |
||
| 5887 | {AttributeCommonInfo::AS_HLSLSemantic, "SV_DispatchThreadID"}, |
||
| 5888 | }; |
||
| 5889 | struct ParsedAttrInfoHLSLSV_DispatchThreadID final : public ParsedAttrInfo { |
||
| 5890 | constexpr ParsedAttrInfoHLSLSV_DispatchThreadID() : ParsedAttrInfo( |
||
| 5891 | /*AttrKind=*/ParsedAttr::AT_HLSLSV_DispatchThreadID, |
||
| 5892 | /*NumArgs=*/0, |
||
| 5893 | /*OptArgs=*/0, |
||
| 5894 | /*NumArgMembers=*/0, |
||
| 5895 | /*HasCustomParsing=*/0, |
||
| 5896 | /*AcceptsExprPack=*/0, |
||
| 5897 | /*IsTargetSpecific=*/0, |
||
| 5898 | /*IsType=*/0, |
||
| 5899 | /*IsStmt=*/0, |
||
| 5900 | /*IsKnownToGCC=*/0, |
||
| 5901 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 5902 | /*Spellings=*/HLSLSV_DispatchThreadIDSpellings, |
||
| 5903 | /*ArgNames=*/{}) {} |
||
| 5904 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 5905 | if (!isa<ParmVarDecl>(D) && !isa<FieldDecl>(D)) { |
||
| 5906 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 5907 | << Attr << "parameters and non-static data members"; |
||
| 5908 | return false; |
||
| 5909 | } |
||
| 5910 | return true; |
||
| 5911 | } |
||
| 5912 | |||
| 5913 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 5914 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 5915 | << AL << St->getBeginLoc(); |
||
| 5916 | return false; |
||
| 5917 | } |
||
| 5918 | |||
| 5919 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 5920 | return LangOpts.HLSL; |
||
| 5921 | } |
||
| 5922 | |||
| 5923 | bool isParamExpr(size_t N) const override { |
||
| 5924 | return false; |
||
| 5925 | } |
||
| 5926 | |||
| 5927 | static const ParsedAttrInfoHLSLSV_DispatchThreadID Instance; |
||
| 5928 | }; |
||
| 5929 | const ParsedAttrInfoHLSLSV_DispatchThreadID ParsedAttrInfoHLSLSV_DispatchThreadID::Instance; |
||
| 5930 | static constexpr ParsedAttrInfo::Spelling HLSLSV_GroupIndexSpellings[] = { |
||
| 5931 | {AttributeCommonInfo::AS_HLSLSemantic, "SV_GroupIndex"}, |
||
| 5932 | }; |
||
| 5933 | struct ParsedAttrInfoHLSLSV_GroupIndex final : public ParsedAttrInfo { |
||
| 5934 | constexpr ParsedAttrInfoHLSLSV_GroupIndex() : ParsedAttrInfo( |
||
| 5935 | /*AttrKind=*/ParsedAttr::AT_HLSLSV_GroupIndex, |
||
| 5936 | /*NumArgs=*/0, |
||
| 5937 | /*OptArgs=*/0, |
||
| 5938 | /*NumArgMembers=*/0, |
||
| 5939 | /*HasCustomParsing=*/0, |
||
| 5940 | /*AcceptsExprPack=*/0, |
||
| 5941 | /*IsTargetSpecific=*/0, |
||
| 5942 | /*IsType=*/0, |
||
| 5943 | /*IsStmt=*/0, |
||
| 5944 | /*IsKnownToGCC=*/0, |
||
| 5945 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 5946 | /*Spellings=*/HLSLSV_GroupIndexSpellings, |
||
| 5947 | /*ArgNames=*/{}) {} |
||
| 5948 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 5949 | if (!isa<ParmVarDecl>(D) && !isGlobalVar(D)) { |
||
| 5950 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 5951 | << Attr << "parameters and global variables"; |
||
| 5952 | return false; |
||
| 5953 | } |
||
| 5954 | return true; |
||
| 5955 | } |
||
| 5956 | |||
| 5957 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 5958 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 5959 | << AL << St->getBeginLoc(); |
||
| 5960 | return false; |
||
| 5961 | } |
||
| 5962 | |||
| 5963 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 5964 | return LangOpts.HLSL; |
||
| 5965 | } |
||
| 5966 | |||
| 5967 | bool isParamExpr(size_t N) const override { |
||
| 5968 | return false; |
||
| 5969 | } |
||
| 5970 | |||
| 5971 | static const ParsedAttrInfoHLSLSV_GroupIndex Instance; |
||
| 5972 | }; |
||
| 5973 | const ParsedAttrInfoHLSLSV_GroupIndex ParsedAttrInfoHLSLSV_GroupIndex::Instance; |
||
| 5974 | static constexpr ParsedAttrInfo::Spelling HLSLShaderSpellings[] = { |
||
| 5975 | {AttributeCommonInfo::AS_Microsoft, "shader"}, |
||
| 5976 | }; |
||
| 5977 | static constexpr const char *HLSLShaderArgNames[] = { |
||
| 5978 | "Type",}; |
||
| 5979 | struct ParsedAttrInfoHLSLShader final : public ParsedAttrInfo { |
||
| 5980 | constexpr ParsedAttrInfoHLSLShader() : ParsedAttrInfo( |
||
| 5981 | /*AttrKind=*/ParsedAttr::AT_HLSLShader, |
||
| 5982 | /*NumArgs=*/1, |
||
| 5983 | /*OptArgs=*/0, |
||
| 5984 | /*NumArgMembers=*/1, |
||
| 5985 | /*HasCustomParsing=*/0, |
||
| 5986 | /*AcceptsExprPack=*/0, |
||
| 5987 | /*IsTargetSpecific=*/0, |
||
| 5988 | /*IsType=*/0, |
||
| 5989 | /*IsStmt=*/0, |
||
| 5990 | /*IsKnownToGCC=*/0, |
||
| 5991 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 5992 | /*Spellings=*/HLSLShaderSpellings, |
||
| 5993 | /*ArgNames=*/HLSLShaderArgNames) {} |
||
| 5994 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 5995 | if (!isHLSLEntry(D)) { |
||
| 5996 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 5997 | << Attr << "global functions"; |
||
| 5998 | return false; |
||
| 5999 | } |
||
| 6000 | return true; |
||
| 6001 | } |
||
| 6002 | |||
| 6003 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 6004 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 6005 | << AL << St->getBeginLoc(); |
||
| 6006 | return false; |
||
| 6007 | } |
||
| 6008 | |||
| 6009 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 6010 | return LangOpts.HLSL; |
||
| 6011 | } |
||
| 6012 | |||
| 6013 | bool isParamExpr(size_t N) const override { |
||
| 6014 | return false; |
||
| 6015 | } |
||
| 6016 | |||
| 6017 | static const ParsedAttrInfoHLSLShader Instance; |
||
| 6018 | }; |
||
| 6019 | const ParsedAttrInfoHLSLShader ParsedAttrInfoHLSLShader::Instance; |
||
| 6020 | static constexpr ParsedAttrInfo::Spelling HotSpellings[] = { |
||
| 6021 | {AttributeCommonInfo::AS_GNU, "hot"}, |
||
| 6022 | {AttributeCommonInfo::AS_CXX11, "gnu::hot"}, |
||
| 6023 | {AttributeCommonInfo::AS_C2x, "gnu::hot"}, |
||
| 6024 | }; |
||
| 6025 | struct ParsedAttrInfoHot final : public ParsedAttrInfo { |
||
| 6026 | constexpr ParsedAttrInfoHot() : ParsedAttrInfo( |
||
| 6027 | /*AttrKind=*/ParsedAttr::AT_Hot, |
||
| 6028 | /*NumArgs=*/0, |
||
| 6029 | /*OptArgs=*/0, |
||
| 6030 | /*NumArgMembers=*/0, |
||
| 6031 | /*HasCustomParsing=*/0, |
||
| 6032 | /*AcceptsExprPack=*/0, |
||
| 6033 | /*IsTargetSpecific=*/0, |
||
| 6034 | /*IsType=*/0, |
||
| 6035 | /*IsStmt=*/0, |
||
| 6036 | /*IsKnownToGCC=*/1, |
||
| 6037 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 6038 | /*Spellings=*/HotSpellings, |
||
| 6039 | /*ArgNames=*/{}) {} |
||
| 6040 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 6041 | if (!isa<FunctionDecl>(D)) { |
||
| 6042 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 6043 | << Attr << "functions"; |
||
| 6044 | return false; |
||
| 6045 | } |
||
| 6046 | return true; |
||
| 6047 | } |
||
| 6048 | |||
| 6049 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 6050 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 6051 | << AL << St->getBeginLoc(); |
||
| 6052 | return false; |
||
| 6053 | } |
||
| 6054 | |||
| 6055 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 6056 | |||
| 6057 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 6058 | if (const auto *A = D->getAttr<ColdAttr>()) { |
||
| 6059 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 6060 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 6061 | return false; |
||
| 6062 | } |
||
| 6063 | return true; |
||
| 6064 | } |
||
| 6065 | |||
| 6066 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 6067 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 6068 | } |
||
| 6069 | |||
| 6070 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 6071 | D->addAttr(::new (S.Context) HotAttr(S.Context, Attr)); |
||
| 6072 | return AttributeApplied; |
||
| 6073 | } |
||
| 6074 | |||
| 6075 | bool isParamExpr(size_t N) const override { |
||
| 6076 | return false; |
||
| 6077 | } |
||
| 6078 | |||
| 6079 | static const ParsedAttrInfoHot Instance; |
||
| 6080 | }; |
||
| 6081 | const ParsedAttrInfoHot ParsedAttrInfoHot::Instance; |
||
| 6082 | static constexpr ParsedAttrInfo::Spelling IBActionSpellings[] = { |
||
| 6083 | {AttributeCommonInfo::AS_GNU, "ibaction"}, |
||
| 6084 | {AttributeCommonInfo::AS_CXX11, "clang::ibaction"}, |
||
| 6085 | {AttributeCommonInfo::AS_C2x, "clang::ibaction"}, |
||
| 6086 | }; |
||
| 6087 | struct ParsedAttrInfoIBAction final : public ParsedAttrInfo { |
||
| 6088 | constexpr ParsedAttrInfoIBAction() : ParsedAttrInfo( |
||
| 6089 | /*AttrKind=*/ParsedAttr::AT_IBAction, |
||
| 6090 | /*NumArgs=*/0, |
||
| 6091 | /*OptArgs=*/0, |
||
| 6092 | /*NumArgMembers=*/0, |
||
| 6093 | /*HasCustomParsing=*/0, |
||
| 6094 | /*AcceptsExprPack=*/0, |
||
| 6095 | /*IsTargetSpecific=*/0, |
||
| 6096 | /*IsType=*/0, |
||
| 6097 | /*IsStmt=*/0, |
||
| 6098 | /*IsKnownToGCC=*/0, |
||
| 6099 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 6100 | /*Spellings=*/IBActionSpellings, |
||
| 6101 | /*ArgNames=*/{}) {} |
||
| 6102 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 6103 | if (!isObjCInstanceMethod(D)) { |
||
| 6104 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 6105 | << Attr << "Objective-C instance methods"; |
||
| 6106 | return false; |
||
| 6107 | } |
||
| 6108 | return true; |
||
| 6109 | } |
||
| 6110 | |||
| 6111 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 6112 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 6113 | << AL << St->getBeginLoc(); |
||
| 6114 | return false; |
||
| 6115 | } |
||
| 6116 | |||
| 6117 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 6118 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method_is_instance, /*IsSupported=*/LangOpts.ObjC)); |
||
| 6119 | } |
||
| 6120 | |||
| 6121 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 6122 | D->addAttr(::new (S.Context) IBActionAttr(S.Context, Attr)); |
||
| 6123 | return AttributeApplied; |
||
| 6124 | } |
||
| 6125 | |||
| 6126 | bool isParamExpr(size_t N) const override { |
||
| 6127 | return false; |
||
| 6128 | } |
||
| 6129 | |||
| 6130 | static const ParsedAttrInfoIBAction Instance; |
||
| 6131 | }; |
||
| 6132 | const ParsedAttrInfoIBAction ParsedAttrInfoIBAction::Instance; |
||
| 6133 | static constexpr ParsedAttrInfo::Spelling IBOutletSpellings[] = { |
||
| 6134 | {AttributeCommonInfo::AS_GNU, "iboutlet"}, |
||
| 6135 | {AttributeCommonInfo::AS_CXX11, "clang::iboutlet"}, |
||
| 6136 | {AttributeCommonInfo::AS_C2x, "clang::iboutlet"}, |
||
| 6137 | }; |
||
| 6138 | struct ParsedAttrInfoIBOutlet final : public ParsedAttrInfo { |
||
| 6139 | constexpr ParsedAttrInfoIBOutlet() : ParsedAttrInfo( |
||
| 6140 | /*AttrKind=*/ParsedAttr::AT_IBOutlet, |
||
| 6141 | /*NumArgs=*/0, |
||
| 6142 | /*OptArgs=*/0, |
||
| 6143 | /*NumArgMembers=*/0, |
||
| 6144 | /*HasCustomParsing=*/0, |
||
| 6145 | /*AcceptsExprPack=*/0, |
||
| 6146 | /*IsTargetSpecific=*/0, |
||
| 6147 | /*IsType=*/0, |
||
| 6148 | /*IsStmt=*/0, |
||
| 6149 | /*IsKnownToGCC=*/0, |
||
| 6150 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 6151 | /*Spellings=*/IBOutletSpellings, |
||
| 6152 | /*ArgNames=*/{}) {} |
||
| 6153 | bool isParamExpr(size_t N) const override { |
||
| 6154 | return false; |
||
| 6155 | } |
||
| 6156 | |||
| 6157 | static const ParsedAttrInfoIBOutlet Instance; |
||
| 6158 | }; |
||
| 6159 | const ParsedAttrInfoIBOutlet ParsedAttrInfoIBOutlet::Instance; |
||
| 6160 | static constexpr ParsedAttrInfo::Spelling IBOutletCollectionSpellings[] = { |
||
| 6161 | {AttributeCommonInfo::AS_GNU, "iboutletcollection"}, |
||
| 6162 | {AttributeCommonInfo::AS_CXX11, "clang::iboutletcollection"}, |
||
| 6163 | {AttributeCommonInfo::AS_C2x, "clang::iboutletcollection"}, |
||
| 6164 | }; |
||
| 6165 | static constexpr const char *IBOutletCollectionArgNames[] = { |
||
| 6166 | "Interface",}; |
||
| 6167 | struct ParsedAttrInfoIBOutletCollection final : public ParsedAttrInfo { |
||
| 6168 | constexpr ParsedAttrInfoIBOutletCollection() : ParsedAttrInfo( |
||
| 6169 | /*AttrKind=*/ParsedAttr::AT_IBOutletCollection, |
||
| 6170 | /*NumArgs=*/0, |
||
| 6171 | /*OptArgs=*/1, |
||
| 6172 | /*NumArgMembers=*/1, |
||
| 6173 | /*HasCustomParsing=*/0, |
||
| 6174 | /*AcceptsExprPack=*/0, |
||
| 6175 | /*IsTargetSpecific=*/0, |
||
| 6176 | /*IsType=*/0, |
||
| 6177 | /*IsStmt=*/0, |
||
| 6178 | /*IsKnownToGCC=*/0, |
||
| 6179 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 6180 | /*Spellings=*/IBOutletCollectionSpellings, |
||
| 6181 | /*ArgNames=*/IBOutletCollectionArgNames) {} |
||
| 6182 | bool isParamExpr(size_t N) const override { |
||
| 6183 | return false; |
||
| 6184 | } |
||
| 6185 | |||
| 6186 | static const ParsedAttrInfoIBOutletCollection Instance; |
||
| 6187 | }; |
||
| 6188 | const ParsedAttrInfoIBOutletCollection ParsedAttrInfoIBOutletCollection::Instance; |
||
| 6189 | static constexpr ParsedAttrInfo::Spelling IFuncSpellings[] = { |
||
| 6190 | {AttributeCommonInfo::AS_GNU, "ifunc"}, |
||
| 6191 | {AttributeCommonInfo::AS_CXX11, "gnu::ifunc"}, |
||
| 6192 | {AttributeCommonInfo::AS_C2x, "gnu::ifunc"}, |
||
| 6193 | }; |
||
| 6194 | static constexpr const char *IFuncArgNames[] = { |
||
| 6195 | "Resolver",}; |
||
| 6196 | struct ParsedAttrInfoIFunc final : public ParsedAttrInfo { |
||
| 6197 | constexpr ParsedAttrInfoIFunc() : ParsedAttrInfo( |
||
| 6198 | /*AttrKind=*/ParsedAttr::AT_IFunc, |
||
| 6199 | /*NumArgs=*/1, |
||
| 6200 | /*OptArgs=*/0, |
||
| 6201 | /*NumArgMembers=*/1, |
||
| 6202 | /*HasCustomParsing=*/0, |
||
| 6203 | /*AcceptsExprPack=*/0, |
||
| 6204 | /*IsTargetSpecific=*/1, |
||
| 6205 | /*IsType=*/0, |
||
| 6206 | /*IsStmt=*/0, |
||
| 6207 | /*IsKnownToGCC=*/1, |
||
| 6208 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 6209 | /*Spellings=*/IFuncSpellings, |
||
| 6210 | /*ArgNames=*/IFuncArgNames) {} |
||
| 6211 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 6212 | if (!isa<FunctionDecl>(D)) { |
||
| 6213 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 6214 | << Attr << "functions"; |
||
| 6215 | return false; |
||
| 6216 | } |
||
| 6217 | return true; |
||
| 6218 | } |
||
| 6219 | |||
| 6220 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 6221 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 6222 | << AL << St->getBeginLoc(); |
||
| 6223 | return false; |
||
| 6224 | } |
||
| 6225 | |||
| 6226 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 6227 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 6228 | return true && (T.getObjectFormat() == llvm::Triple::ELF); |
||
| 6229 | } |
||
| 6230 | |||
| 6231 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 6232 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 6233 | } |
||
| 6234 | |||
| 6235 | bool isParamExpr(size_t N) const override { |
||
| 6236 | return false; |
||
| 6237 | } |
||
| 6238 | |||
| 6239 | static const ParsedAttrInfoIFunc Instance; |
||
| 6240 | }; |
||
| 6241 | const ParsedAttrInfoIFunc ParsedAttrInfoIFunc::Instance; |
||
| 6242 | static constexpr ParsedAttrInfo::Spelling InitPrioritySpellings[] = { |
||
| 6243 | {AttributeCommonInfo::AS_GNU, "init_priority"}, |
||
| 6244 | {AttributeCommonInfo::AS_CXX11, "gnu::init_priority"}, |
||
| 6245 | }; |
||
| 6246 | static constexpr const char *InitPriorityArgNames[] = { |
||
| 6247 | "Priority",}; |
||
| 6248 | struct ParsedAttrInfoInitPriority final : public ParsedAttrInfo { |
||
| 6249 | constexpr ParsedAttrInfoInitPriority() : ParsedAttrInfo( |
||
| 6250 | /*AttrKind=*/ParsedAttr::AT_InitPriority, |
||
| 6251 | /*NumArgs=*/1, |
||
| 6252 | /*OptArgs=*/0, |
||
| 6253 | /*NumArgMembers=*/1, |
||
| 6254 | /*HasCustomParsing=*/0, |
||
| 6255 | /*AcceptsExprPack=*/0, |
||
| 6256 | /*IsTargetSpecific=*/1, |
||
| 6257 | /*IsType=*/0, |
||
| 6258 | /*IsStmt=*/0, |
||
| 6259 | /*IsKnownToGCC=*/1, |
||
| 6260 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 6261 | /*Spellings=*/InitPrioritySpellings, |
||
| 6262 | /*ArgNames=*/InitPriorityArgNames) {} |
||
| 6263 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 6264 | if (!isa<VarDecl>(D)) { |
||
| 6265 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 6266 | << Attr << "variables"; |
||
| 6267 | return false; |
||
| 6268 | } |
||
| 6269 | return true; |
||
| 6270 | } |
||
| 6271 | |||
| 6272 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 6273 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 6274 | << AL << St->getBeginLoc(); |
||
| 6275 | return false; |
||
| 6276 | } |
||
| 6277 | |||
| 6278 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 6279 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 6280 | return true && ( !Target.getTriple().isOSzOS() ); |
||
| 6281 | } |
||
| 6282 | |||
| 6283 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 6284 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
||
| 6285 | } |
||
| 6286 | |||
| 6287 | bool isParamExpr(size_t N) const override { |
||
| 6288 | return false; |
||
| 6289 | } |
||
| 6290 | |||
| 6291 | static const ParsedAttrInfoInitPriority Instance; |
||
| 6292 | }; |
||
| 6293 | const ParsedAttrInfoInitPriority ParsedAttrInfoInitPriority::Instance; |
||
| 6294 | static constexpr ParsedAttrInfo::Spelling IntelOclBiccSpellings[] = { |
||
| 6295 | {AttributeCommonInfo::AS_GNU, "intel_ocl_bicc"}, |
||
| 6296 | {AttributeCommonInfo::AS_CXX11, "clang::intel_ocl_bicc"}, |
||
| 6297 | }; |
||
| 6298 | struct ParsedAttrInfoIntelOclBicc final : public ParsedAttrInfo { |
||
| 6299 | constexpr ParsedAttrInfoIntelOclBicc() : ParsedAttrInfo( |
||
| 6300 | /*AttrKind=*/ParsedAttr::AT_IntelOclBicc, |
||
| 6301 | /*NumArgs=*/0, |
||
| 6302 | /*OptArgs=*/0, |
||
| 6303 | /*NumArgMembers=*/0, |
||
| 6304 | /*HasCustomParsing=*/0, |
||
| 6305 | /*AcceptsExprPack=*/0, |
||
| 6306 | /*IsTargetSpecific=*/0, |
||
| 6307 | /*IsType=*/1, |
||
| 6308 | /*IsStmt=*/0, |
||
| 6309 | /*IsKnownToGCC=*/0, |
||
| 6310 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 6311 | /*Spellings=*/IntelOclBiccSpellings, |
||
| 6312 | /*ArgNames=*/{}) {} |
||
| 6313 | bool isParamExpr(size_t N) const override { |
||
| 6314 | return false; |
||
| 6315 | } |
||
| 6316 | |||
| 6317 | static const ParsedAttrInfoIntelOclBicc Instance; |
||
| 6318 | }; |
||
| 6319 | const ParsedAttrInfoIntelOclBicc ParsedAttrInfoIntelOclBicc::Instance; |
||
| 6320 | static constexpr ParsedAttrInfo::Spelling InternalLinkageSpellings[] = { |
||
| 6321 | {AttributeCommonInfo::AS_GNU, "internal_linkage"}, |
||
| 6322 | {AttributeCommonInfo::AS_CXX11, "clang::internal_linkage"}, |
||
| 6323 | {AttributeCommonInfo::AS_C2x, "clang::internal_linkage"}, |
||
| 6324 | }; |
||
| 6325 | struct ParsedAttrInfoInternalLinkage final : public ParsedAttrInfo { |
||
| 6326 | constexpr ParsedAttrInfoInternalLinkage() : ParsedAttrInfo( |
||
| 6327 | /*AttrKind=*/ParsedAttr::AT_InternalLinkage, |
||
| 6328 | /*NumArgs=*/0, |
||
| 6329 | /*OptArgs=*/0, |
||
| 6330 | /*NumArgMembers=*/0, |
||
| 6331 | /*HasCustomParsing=*/0, |
||
| 6332 | /*AcceptsExprPack=*/0, |
||
| 6333 | /*IsTargetSpecific=*/0, |
||
| 6334 | /*IsType=*/0, |
||
| 6335 | /*IsStmt=*/0, |
||
| 6336 | /*IsKnownToGCC=*/0, |
||
| 6337 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 6338 | /*Spellings=*/InternalLinkageSpellings, |
||
| 6339 | /*ArgNames=*/{}) {} |
||
| 6340 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 6341 | if (!isa<VarDecl>(D) && !isa<FunctionDecl>(D) && !isa<CXXRecordDecl>(D)) { |
||
| 6342 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 6343 | << Attr << "variables, functions, and classes"; |
||
| 6344 | return false; |
||
| 6345 | } |
||
| 6346 | return true; |
||
| 6347 | } |
||
| 6348 | |||
| 6349 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 6350 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 6351 | << AL << St->getBeginLoc(); |
||
| 6352 | return false; |
||
| 6353 | } |
||
| 6354 | |||
| 6355 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 6356 | |||
| 6357 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 6358 | if (const auto *A = D->getAttr<CommonAttr>()) { |
||
| 6359 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 6360 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 6361 | return false; |
||
| 6362 | } |
||
| 6363 | return true; |
||
| 6364 | } |
||
| 6365 | |||
| 6366 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 6367 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
||
| 6368 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 6369 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 6370 | } |
||
| 6371 | |||
| 6372 | bool isParamExpr(size_t N) const override { |
||
| 6373 | return false; |
||
| 6374 | } |
||
| 6375 | |||
| 6376 | static const ParsedAttrInfoInternalLinkage Instance; |
||
| 6377 | }; |
||
| 6378 | const ParsedAttrInfoInternalLinkage ParsedAttrInfoInternalLinkage::Instance; |
||
| 6379 | static constexpr ParsedAttrInfo::Spelling LTOVisibilityPublicSpellings[] = { |
||
| 6380 | {AttributeCommonInfo::AS_GNU, "lto_visibility_public"}, |
||
| 6381 | {AttributeCommonInfo::AS_CXX11, "clang::lto_visibility_public"}, |
||
| 6382 | {AttributeCommonInfo::AS_C2x, "clang::lto_visibility_public"}, |
||
| 6383 | }; |
||
| 6384 | struct ParsedAttrInfoLTOVisibilityPublic final : public ParsedAttrInfo { |
||
| 6385 | constexpr ParsedAttrInfoLTOVisibilityPublic() : ParsedAttrInfo( |
||
| 6386 | /*AttrKind=*/ParsedAttr::AT_LTOVisibilityPublic, |
||
| 6387 | /*NumArgs=*/0, |
||
| 6388 | /*OptArgs=*/0, |
||
| 6389 | /*NumArgMembers=*/0, |
||
| 6390 | /*HasCustomParsing=*/0, |
||
| 6391 | /*AcceptsExprPack=*/0, |
||
| 6392 | /*IsTargetSpecific=*/0, |
||
| 6393 | /*IsType=*/0, |
||
| 6394 | /*IsStmt=*/0, |
||
| 6395 | /*IsKnownToGCC=*/0, |
||
| 6396 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 6397 | /*Spellings=*/LTOVisibilityPublicSpellings, |
||
| 6398 | /*ArgNames=*/{}) {} |
||
| 6399 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 6400 | if (!isa<RecordDecl>(D)) { |
||
| 6401 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 6402 | << Attr << "structs, unions, and classes"; |
||
| 6403 | return false; |
||
| 6404 | } |
||
| 6405 | return true; |
||
| 6406 | } |
||
| 6407 | |||
| 6408 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 6409 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 6410 | << AL << St->getBeginLoc(); |
||
| 6411 | return false; |
||
| 6412 | } |
||
| 6413 | |||
| 6414 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 6415 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 6416 | } |
||
| 6417 | |||
| 6418 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 6419 | D->addAttr(::new (S.Context) LTOVisibilityPublicAttr(S.Context, Attr)); |
||
| 6420 | return AttributeApplied; |
||
| 6421 | } |
||
| 6422 | |||
| 6423 | bool isParamExpr(size_t N) const override { |
||
| 6424 | return false; |
||
| 6425 | } |
||
| 6426 | |||
| 6427 | static const ParsedAttrInfoLTOVisibilityPublic Instance; |
||
| 6428 | }; |
||
| 6429 | const ParsedAttrInfoLTOVisibilityPublic ParsedAttrInfoLTOVisibilityPublic::Instance; |
||
| 6430 | static constexpr ParsedAttrInfo::Spelling LayoutVersionSpellings[] = { |
||
| 6431 | {AttributeCommonInfo::AS_Declspec, "layout_version"}, |
||
| 6432 | }; |
||
| 6433 | static constexpr const char *LayoutVersionArgNames[] = { |
||
| 6434 | "Version",}; |
||
| 6435 | struct ParsedAttrInfoLayoutVersion final : public ParsedAttrInfo { |
||
| 6436 | constexpr ParsedAttrInfoLayoutVersion() : ParsedAttrInfo( |
||
| 6437 | /*AttrKind=*/ParsedAttr::AT_LayoutVersion, |
||
| 6438 | /*NumArgs=*/1, |
||
| 6439 | /*OptArgs=*/0, |
||
| 6440 | /*NumArgMembers=*/1, |
||
| 6441 | /*HasCustomParsing=*/0, |
||
| 6442 | /*AcceptsExprPack=*/0, |
||
| 6443 | /*IsTargetSpecific=*/1, |
||
| 6444 | /*IsType=*/0, |
||
| 6445 | /*IsStmt=*/0, |
||
| 6446 | /*IsKnownToGCC=*/0, |
||
| 6447 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 6448 | /*Spellings=*/LayoutVersionSpellings, |
||
| 6449 | /*ArgNames=*/LayoutVersionArgNames) {} |
||
| 6450 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 6451 | if (!isa<CXXRecordDecl>(D)) { |
||
| 6452 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 6453 | << Attr << "classes"; |
||
| 6454 | return false; |
||
| 6455 | } |
||
| 6456 | return true; |
||
| 6457 | } |
||
| 6458 | |||
| 6459 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 6460 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 6461 | << AL << St->getBeginLoc(); |
||
| 6462 | return false; |
||
| 6463 | } |
||
| 6464 | |||
| 6465 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 6466 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 6467 | 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().isMicrosoft() ); |
||
| 6468 | } |
||
| 6469 | |||
| 6470 | bool isParamExpr(size_t N) const override { |
||
| 6471 | return false; |
||
| 6472 | } |
||
| 6473 | |||
| 6474 | static const ParsedAttrInfoLayoutVersion Instance; |
||
| 6475 | }; |
||
| 6476 | const ParsedAttrInfoLayoutVersion ParsedAttrInfoLayoutVersion::Instance; |
||
| 6477 | static constexpr ParsedAttrInfo::Spelling LeafSpellings[] = { |
||
| 6478 | {AttributeCommonInfo::AS_GNU, "leaf"}, |
||
| 6479 | {AttributeCommonInfo::AS_CXX11, "gnu::leaf"}, |
||
| 6480 | {AttributeCommonInfo::AS_C2x, "gnu::leaf"}, |
||
| 6481 | }; |
||
| 6482 | struct ParsedAttrInfoLeaf final : public ParsedAttrInfo { |
||
| 6483 | constexpr ParsedAttrInfoLeaf() : ParsedAttrInfo( |
||
| 6484 | /*AttrKind=*/ParsedAttr::AT_Leaf, |
||
| 6485 | /*NumArgs=*/0, |
||
| 6486 | /*OptArgs=*/0, |
||
| 6487 | /*NumArgMembers=*/0, |
||
| 6488 | /*HasCustomParsing=*/0, |
||
| 6489 | /*AcceptsExprPack=*/0, |
||
| 6490 | /*IsTargetSpecific=*/0, |
||
| 6491 | /*IsType=*/0, |
||
| 6492 | /*IsStmt=*/0, |
||
| 6493 | /*IsKnownToGCC=*/1, |
||
| 6494 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 6495 | /*Spellings=*/LeafSpellings, |
||
| 6496 | /*ArgNames=*/{}) {} |
||
| 6497 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 6498 | if (!isa<FunctionDecl>(D)) { |
||
| 6499 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 6500 | << Attr << "functions"; |
||
| 6501 | return false; |
||
| 6502 | } |
||
| 6503 | return true; |
||
| 6504 | } |
||
| 6505 | |||
| 6506 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 6507 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 6508 | << AL << St->getBeginLoc(); |
||
| 6509 | return false; |
||
| 6510 | } |
||
| 6511 | |||
| 6512 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 6513 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 6514 | } |
||
| 6515 | |||
| 6516 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 6517 | D->addAttr(::new (S.Context) LeafAttr(S.Context, Attr)); |
||
| 6518 | return AttributeApplied; |
||
| 6519 | } |
||
| 6520 | |||
| 6521 | bool isParamExpr(size_t N) const override { |
||
| 6522 | return false; |
||
| 6523 | } |
||
| 6524 | |||
| 6525 | static const ParsedAttrInfoLeaf Instance; |
||
| 6526 | }; |
||
| 6527 | const ParsedAttrInfoLeaf ParsedAttrInfoLeaf::Instance; |
||
| 6528 | static constexpr ParsedAttrInfo::Spelling LifetimeBoundSpellings[] = { |
||
| 6529 | {AttributeCommonInfo::AS_GNU, "lifetimebound"}, |
||
| 6530 | {AttributeCommonInfo::AS_CXX11, "clang::lifetimebound"}, |
||
| 6531 | }; |
||
| 6532 | struct ParsedAttrInfoLifetimeBound final : public ParsedAttrInfo { |
||
| 6533 | constexpr ParsedAttrInfoLifetimeBound() : ParsedAttrInfo( |
||
| 6534 | /*AttrKind=*/ParsedAttr::AT_LifetimeBound, |
||
| 6535 | /*NumArgs=*/0, |
||
| 6536 | /*OptArgs=*/0, |
||
| 6537 | /*NumArgMembers=*/0, |
||
| 6538 | /*HasCustomParsing=*/0, |
||
| 6539 | /*AcceptsExprPack=*/0, |
||
| 6540 | /*IsTargetSpecific=*/0, |
||
| 6541 | /*IsType=*/1, |
||
| 6542 | /*IsStmt=*/0, |
||
| 6543 | /*IsKnownToGCC=*/0, |
||
| 6544 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 6545 | /*Spellings=*/LifetimeBoundSpellings, |
||
| 6546 | /*ArgNames=*/{}) {} |
||
| 6547 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 6548 | if (!isa<ParmVarDecl>(D) && !isImplicitObjectParameter(D)) { |
||
| 6549 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 6550 | << Attr << "parameters and implicit object parameters"; |
||
| 6551 | return false; |
||
| 6552 | } |
||
| 6553 | return true; |
||
| 6554 | } |
||
| 6555 | |||
| 6556 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 6557 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 6558 | << AL << St->getBeginLoc(); |
||
| 6559 | return false; |
||
| 6560 | } |
||
| 6561 | |||
| 6562 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 6563 | return LangOpts.CPlusPlus; |
||
| 6564 | } |
||
| 6565 | |||
| 6566 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 6567 | D->addAttr(::new (S.Context) LifetimeBoundAttr(S.Context, Attr)); |
||
| 6568 | return AttributeApplied; |
||
| 6569 | } |
||
| 6570 | |||
| 6571 | bool isParamExpr(size_t N) const override { |
||
| 6572 | return false; |
||
| 6573 | } |
||
| 6574 | |||
| 6575 | static const ParsedAttrInfoLifetimeBound Instance; |
||
| 6576 | }; |
||
| 6577 | const ParsedAttrInfoLifetimeBound ParsedAttrInfoLifetimeBound::Instance; |
||
| 6578 | static constexpr ParsedAttrInfo::Spelling LikelySpellings[] = { |
||
| 6579 | {AttributeCommonInfo::AS_CXX11, "likely"}, |
||
| 6580 | {AttributeCommonInfo::AS_C2x, "clang::likely"}, |
||
| 6581 | }; |
||
| 6582 | struct ParsedAttrInfoLikely final : public ParsedAttrInfo { |
||
| 6583 | constexpr ParsedAttrInfoLikely() : ParsedAttrInfo( |
||
| 6584 | /*AttrKind=*/ParsedAttr::AT_Likely, |
||
| 6585 | /*NumArgs=*/0, |
||
| 6586 | /*OptArgs=*/0, |
||
| 6587 | /*NumArgMembers=*/0, |
||
| 6588 | /*HasCustomParsing=*/0, |
||
| 6589 | /*AcceptsExprPack=*/0, |
||
| 6590 | /*IsTargetSpecific=*/0, |
||
| 6591 | /*IsType=*/0, |
||
| 6592 | /*IsStmt=*/1, |
||
| 6593 | /*IsKnownToGCC=*/0, |
||
| 6594 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 6595 | /*Spellings=*/LikelySpellings, |
||
| 6596 | /*ArgNames=*/{}) {} |
||
| 6597 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 6598 | |||
| 6599 | bool isParamExpr(size_t N) const override { |
||
| 6600 | return false; |
||
| 6601 | } |
||
| 6602 | |||
| 6603 | static const ParsedAttrInfoLikely Instance; |
||
| 6604 | }; |
||
| 6605 | const ParsedAttrInfoLikely ParsedAttrInfoLikely::Instance; |
||
| 6606 | static constexpr ParsedAttrInfo::Spelling LoaderUninitializedSpellings[] = { |
||
| 6607 | {AttributeCommonInfo::AS_GNU, "loader_uninitialized"}, |
||
| 6608 | {AttributeCommonInfo::AS_CXX11, "clang::loader_uninitialized"}, |
||
| 6609 | {AttributeCommonInfo::AS_C2x, "clang::loader_uninitialized"}, |
||
| 6610 | }; |
||
| 6611 | struct ParsedAttrInfoLoaderUninitialized final : public ParsedAttrInfo { |
||
| 6612 | constexpr ParsedAttrInfoLoaderUninitialized() : ParsedAttrInfo( |
||
| 6613 | /*AttrKind=*/ParsedAttr::AT_LoaderUninitialized, |
||
| 6614 | /*NumArgs=*/0, |
||
| 6615 | /*OptArgs=*/0, |
||
| 6616 | /*NumArgMembers=*/0, |
||
| 6617 | /*HasCustomParsing=*/0, |
||
| 6618 | /*AcceptsExprPack=*/0, |
||
| 6619 | /*IsTargetSpecific=*/0, |
||
| 6620 | /*IsType=*/0, |
||
| 6621 | /*IsStmt=*/0, |
||
| 6622 | /*IsKnownToGCC=*/0, |
||
| 6623 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 6624 | /*Spellings=*/LoaderUninitializedSpellings, |
||
| 6625 | /*ArgNames=*/{}) {} |
||
| 6626 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 6627 | if (!isGlobalVar(D)) { |
||
| 6628 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 6629 | << Attr << "global variables"; |
||
| 6630 | return false; |
||
| 6631 | } |
||
| 6632 | return true; |
||
| 6633 | } |
||
| 6634 | |||
| 6635 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 6636 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 6637 | << AL << St->getBeginLoc(); |
||
| 6638 | return false; |
||
| 6639 | } |
||
| 6640 | |||
| 6641 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 6642 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_global, /*IsSupported=*/true)); |
||
| 6643 | } |
||
| 6644 | |||
| 6645 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 6646 | D->addAttr(::new (S.Context) LoaderUninitializedAttr(S.Context, Attr)); |
||
| 6647 | return AttributeApplied; |
||
| 6648 | } |
||
| 6649 | |||
| 6650 | bool isParamExpr(size_t N) const override { |
||
| 6651 | return false; |
||
| 6652 | } |
||
| 6653 | |||
| 6654 | static const ParsedAttrInfoLoaderUninitialized Instance; |
||
| 6655 | }; |
||
| 6656 | const ParsedAttrInfoLoaderUninitialized ParsedAttrInfoLoaderUninitialized::Instance; |
||
| 6657 | static constexpr ParsedAttrInfo::Spelling LockReturnedSpellings[] = { |
||
| 6658 | {AttributeCommonInfo::AS_GNU, "lock_returned"}, |
||
| 6659 | }; |
||
| 6660 | static constexpr const char *LockReturnedArgNames[] = { |
||
| 6661 | "Arg",}; |
||
| 6662 | struct ParsedAttrInfoLockReturned final : public ParsedAttrInfo { |
||
| 6663 | constexpr ParsedAttrInfoLockReturned() : ParsedAttrInfo( |
||
| 6664 | /*AttrKind=*/ParsedAttr::AT_LockReturned, |
||
| 6665 | /*NumArgs=*/1, |
||
| 6666 | /*OptArgs=*/0, |
||
| 6667 | /*NumArgMembers=*/1, |
||
| 6668 | /*HasCustomParsing=*/0, |
||
| 6669 | /*AcceptsExprPack=*/0, |
||
| 6670 | /*IsTargetSpecific=*/0, |
||
| 6671 | /*IsType=*/0, |
||
| 6672 | /*IsStmt=*/0, |
||
| 6673 | /*IsKnownToGCC=*/0, |
||
| 6674 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 6675 | /*Spellings=*/LockReturnedSpellings, |
||
| 6676 | /*ArgNames=*/LockReturnedArgNames) {} |
||
| 6677 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 6678 | if (!isa<FunctionDecl>(D)) { |
||
| 6679 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 6680 | << Attr << "functions"; |
||
| 6681 | return false; |
||
| 6682 | } |
||
| 6683 | return true; |
||
| 6684 | } |
||
| 6685 | |||
| 6686 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 6687 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 6688 | << AL << St->getBeginLoc(); |
||
| 6689 | return false; |
||
| 6690 | } |
||
| 6691 | |||
| 6692 | bool isParamExpr(size_t N) const override { |
||
| 6693 | return (N == 0) || false; |
||
| 6694 | } |
||
| 6695 | |||
| 6696 | static const ParsedAttrInfoLockReturned Instance; |
||
| 6697 | }; |
||
| 6698 | const ParsedAttrInfoLockReturned ParsedAttrInfoLockReturned::Instance; |
||
| 6699 | static constexpr ParsedAttrInfo::Spelling LockableSpellings[] = { |
||
| 6700 | {AttributeCommonInfo::AS_GNU, "lockable"}, |
||
| 6701 | }; |
||
| 6702 | struct ParsedAttrInfoLockable final : public ParsedAttrInfo { |
||
| 6703 | constexpr ParsedAttrInfoLockable() : ParsedAttrInfo( |
||
| 6704 | /*AttrKind=*/ParsedAttr::AT_Lockable, |
||
| 6705 | /*NumArgs=*/0, |
||
| 6706 | /*OptArgs=*/0, |
||
| 6707 | /*NumArgMembers=*/0, |
||
| 6708 | /*HasCustomParsing=*/0, |
||
| 6709 | /*AcceptsExprPack=*/0, |
||
| 6710 | /*IsTargetSpecific=*/0, |
||
| 6711 | /*IsType=*/0, |
||
| 6712 | /*IsStmt=*/0, |
||
| 6713 | /*IsKnownToGCC=*/0, |
||
| 6714 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 6715 | /*Spellings=*/LockableSpellings, |
||
| 6716 | /*ArgNames=*/{}) {} |
||
| 6717 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 6718 | if (!isa<RecordDecl>(D)) { |
||
| 6719 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 6720 | << Attr << "structs, unions, and classes"; |
||
| 6721 | return false; |
||
| 6722 | } |
||
| 6723 | return true; |
||
| 6724 | } |
||
| 6725 | |||
| 6726 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 6727 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 6728 | << AL << St->getBeginLoc(); |
||
| 6729 | return false; |
||
| 6730 | } |
||
| 6731 | |||
| 6732 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 6733 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 6734 | } |
||
| 6735 | |||
| 6736 | bool isParamExpr(size_t N) const override { |
||
| 6737 | return false; |
||
| 6738 | } |
||
| 6739 | |||
| 6740 | static const ParsedAttrInfoLockable Instance; |
||
| 6741 | }; |
||
| 6742 | const ParsedAttrInfoLockable ParsedAttrInfoLockable::Instance; |
||
| 6743 | static constexpr ParsedAttrInfo::Spelling LocksExcludedSpellings[] = { |
||
| 6744 | {AttributeCommonInfo::AS_GNU, "locks_excluded"}, |
||
| 6745 | }; |
||
| 6746 | static constexpr const char *LocksExcludedArgNames[] = { |
||
| 6747 | "Args...",}; |
||
| 6748 | struct ParsedAttrInfoLocksExcluded final : public ParsedAttrInfo { |
||
| 6749 | constexpr ParsedAttrInfoLocksExcluded() : ParsedAttrInfo( |
||
| 6750 | /*AttrKind=*/ParsedAttr::AT_LocksExcluded, |
||
| 6751 | /*NumArgs=*/0, |
||
| 6752 | /*OptArgs=*/15, |
||
| 6753 | /*NumArgMembers=*/1, |
||
| 6754 | /*HasCustomParsing=*/0, |
||
| 6755 | /*AcceptsExprPack=*/0, |
||
| 6756 | /*IsTargetSpecific=*/0, |
||
| 6757 | /*IsType=*/0, |
||
| 6758 | /*IsStmt=*/0, |
||
| 6759 | /*IsKnownToGCC=*/0, |
||
| 6760 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 6761 | /*Spellings=*/LocksExcludedSpellings, |
||
| 6762 | /*ArgNames=*/LocksExcludedArgNames) {} |
||
| 6763 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 6764 | if (!isa<FunctionDecl>(D)) { |
||
| 6765 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 6766 | << Attr << "functions"; |
||
| 6767 | return false; |
||
| 6768 | } |
||
| 6769 | return true; |
||
| 6770 | } |
||
| 6771 | |||
| 6772 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 6773 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 6774 | << AL << St->getBeginLoc(); |
||
| 6775 | return false; |
||
| 6776 | } |
||
| 6777 | |||
| 6778 | bool isParamExpr(size_t N) const override { |
||
| 6779 | return (N == 0) || false; |
||
| 6780 | } |
||
| 6781 | |||
| 6782 | static const ParsedAttrInfoLocksExcluded Instance; |
||
| 6783 | }; |
||
| 6784 | const ParsedAttrInfoLocksExcluded ParsedAttrInfoLocksExcluded::Instance; |
||
| 6785 | static constexpr ParsedAttrInfo::Spelling LoopHintSpellings[] = { |
||
| 6786 | {AttributeCommonInfo::AS_Pragma, "clang::loop"}, |
||
| 6787 | {AttributeCommonInfo::AS_Pragma, "unroll"}, |
||
| 6788 | {AttributeCommonInfo::AS_Pragma, "nounroll"}, |
||
| 6789 | {AttributeCommonInfo::AS_Pragma, "unroll_and_jam"}, |
||
| 6790 | {AttributeCommonInfo::AS_Pragma, "nounroll_and_jam"}, |
||
| 6791 | }; |
||
| 6792 | static constexpr const char *LoopHintArgNames[] = { |
||
| 6793 | "Option","State","Value",}; |
||
| 6794 | struct ParsedAttrInfoLoopHint final : public ParsedAttrInfo { |
||
| 6795 | constexpr ParsedAttrInfoLoopHint() : ParsedAttrInfo( |
||
| 6796 | /*AttrKind=*/ParsedAttr::AT_LoopHint, |
||
| 6797 | /*NumArgs=*/3, |
||
| 6798 | /*OptArgs=*/0, |
||
| 6799 | /*NumArgMembers=*/3, |
||
| 6800 | /*HasCustomParsing=*/1, |
||
| 6801 | /*AcceptsExprPack=*/0, |
||
| 6802 | /*IsTargetSpecific=*/0, |
||
| 6803 | /*IsType=*/0, |
||
| 6804 | /*IsStmt=*/0, |
||
| 6805 | /*IsKnownToGCC=*/0, |
||
| 6806 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 6807 | /*Spellings=*/LoopHintSpellings, |
||
| 6808 | /*ArgNames=*/LoopHintArgNames) {} |
||
| 6809 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 6810 | enum Spelling { |
||
| 6811 | Pragma_clang_loop = 0, |
||
| 6812 | Pragma_unroll = 1, |
||
| 6813 | Pragma_nounroll = 2, |
||
| 6814 | Pragma_unroll_and_jam = 3, |
||
| 6815 | Pragma_nounroll_and_jam = 4, |
||
| 6816 | SpellingNotCalculated = 15 |
||
| 6817 | |||
| 6818 | }; |
||
| 6819 | |||
| 6820 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 6821 | switch (Idx) { |
||
| 6822 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 6823 | case 0: return Pragma_clang_loop; |
||
| 6824 | case 1: return Pragma_unroll; |
||
| 6825 | case 2: return Pragma_nounroll; |
||
| 6826 | case 3: return Pragma_unroll_and_jam; |
||
| 6827 | case 4: return Pragma_nounroll_and_jam; |
||
| 6828 | } |
||
| 6829 | } |
||
| 6830 | |||
| 6831 | bool isParamExpr(size_t N) const override { |
||
| 6832 | return (N == 2) || false; |
||
| 6833 | } |
||
| 6834 | |||
| 6835 | static const ParsedAttrInfoLoopHint Instance; |
||
| 6836 | }; |
||
| 6837 | const ParsedAttrInfoLoopHint ParsedAttrInfoLoopHint::Instance; |
||
| 6838 | static constexpr ParsedAttrInfo::Spelling MIGServerRoutineSpellings[] = { |
||
| 6839 | {AttributeCommonInfo::AS_GNU, "mig_server_routine"}, |
||
| 6840 | {AttributeCommonInfo::AS_CXX11, "clang::mig_server_routine"}, |
||
| 6841 | {AttributeCommonInfo::AS_C2x, "clang::mig_server_routine"}, |
||
| 6842 | }; |
||
| 6843 | struct ParsedAttrInfoMIGServerRoutine final : public ParsedAttrInfo { |
||
| 6844 | constexpr ParsedAttrInfoMIGServerRoutine() : ParsedAttrInfo( |
||
| 6845 | /*AttrKind=*/ParsedAttr::AT_MIGServerRoutine, |
||
| 6846 | /*NumArgs=*/0, |
||
| 6847 | /*OptArgs=*/0, |
||
| 6848 | /*NumArgMembers=*/0, |
||
| 6849 | /*HasCustomParsing=*/0, |
||
| 6850 | /*AcceptsExprPack=*/0, |
||
| 6851 | /*IsTargetSpecific=*/0, |
||
| 6852 | /*IsType=*/0, |
||
| 6853 | /*IsStmt=*/0, |
||
| 6854 | /*IsKnownToGCC=*/0, |
||
| 6855 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 6856 | /*Spellings=*/MIGServerRoutineSpellings, |
||
| 6857 | /*ArgNames=*/{}) {} |
||
| 6858 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 6859 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D) && !isa<BlockDecl>(D)) { |
||
| 6860 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 6861 | << Attr << "functions, Objective-C methods, and blocks"; |
||
| 6862 | return false; |
||
| 6863 | } |
||
| 6864 | return true; |
||
| 6865 | } |
||
| 6866 | |||
| 6867 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 6868 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 6869 | << AL << St->getBeginLoc(); |
||
| 6870 | return false; |
||
| 6871 | } |
||
| 6872 | |||
| 6873 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 6874 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 6875 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 6876 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_block, /*IsSupported=*/LangOpts.Blocks)); |
||
| 6877 | } |
||
| 6878 | |||
| 6879 | bool isParamExpr(size_t N) const override { |
||
| 6880 | return false; |
||
| 6881 | } |
||
| 6882 | |||
| 6883 | static const ParsedAttrInfoMIGServerRoutine Instance; |
||
| 6884 | }; |
||
| 6885 | const ParsedAttrInfoMIGServerRoutine ParsedAttrInfoMIGServerRoutine::Instance; |
||
| 6886 | static constexpr ParsedAttrInfo::Spelling MSABISpellings[] = { |
||
| 6887 | {AttributeCommonInfo::AS_GNU, "ms_abi"}, |
||
| 6888 | {AttributeCommonInfo::AS_CXX11, "gnu::ms_abi"}, |
||
| 6889 | {AttributeCommonInfo::AS_C2x, "gnu::ms_abi"}, |
||
| 6890 | }; |
||
| 6891 | struct ParsedAttrInfoMSABI final : public ParsedAttrInfo { |
||
| 6892 | constexpr ParsedAttrInfoMSABI() : ParsedAttrInfo( |
||
| 6893 | /*AttrKind=*/ParsedAttr::AT_MSABI, |
||
| 6894 | /*NumArgs=*/0, |
||
| 6895 | /*OptArgs=*/0, |
||
| 6896 | /*NumArgMembers=*/0, |
||
| 6897 | /*HasCustomParsing=*/0, |
||
| 6898 | /*AcceptsExprPack=*/0, |
||
| 6899 | /*IsTargetSpecific=*/0, |
||
| 6900 | /*IsType=*/1, |
||
| 6901 | /*IsStmt=*/0, |
||
| 6902 | /*IsKnownToGCC=*/1, |
||
| 6903 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 6904 | /*Spellings=*/MSABISpellings, |
||
| 6905 | /*ArgNames=*/{}) {} |
||
| 6906 | bool isParamExpr(size_t N) const override { |
||
| 6907 | return false; |
||
| 6908 | } |
||
| 6909 | |||
| 6910 | static const ParsedAttrInfoMSABI Instance; |
||
| 6911 | }; |
||
| 6912 | const ParsedAttrInfoMSABI ParsedAttrInfoMSABI::Instance; |
||
| 6913 | static constexpr ParsedAttrInfo::Spelling MSAllocatorSpellings[] = { |
||
| 6914 | {AttributeCommonInfo::AS_Declspec, "allocator"}, |
||
| 6915 | }; |
||
| 6916 | struct ParsedAttrInfoMSAllocator final : public ParsedAttrInfo { |
||
| 6917 | constexpr ParsedAttrInfoMSAllocator() : ParsedAttrInfo( |
||
| 6918 | /*AttrKind=*/ParsedAttr::AT_MSAllocator, |
||
| 6919 | /*NumArgs=*/0, |
||
| 6920 | /*OptArgs=*/0, |
||
| 6921 | /*NumArgMembers=*/0, |
||
| 6922 | /*HasCustomParsing=*/0, |
||
| 6923 | /*AcceptsExprPack=*/0, |
||
| 6924 | /*IsTargetSpecific=*/0, |
||
| 6925 | /*IsType=*/0, |
||
| 6926 | /*IsStmt=*/0, |
||
| 6927 | /*IsKnownToGCC=*/0, |
||
| 6928 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 6929 | /*Spellings=*/MSAllocatorSpellings, |
||
| 6930 | /*ArgNames=*/{}) {} |
||
| 6931 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 6932 | if (!isa<FunctionDecl>(D)) { |
||
| 6933 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 6934 | << Attr << "functions"; |
||
| 6935 | return false; |
||
| 6936 | } |
||
| 6937 | return true; |
||
| 6938 | } |
||
| 6939 | |||
| 6940 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 6941 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 6942 | << AL << St->getBeginLoc(); |
||
| 6943 | return false; |
||
| 6944 | } |
||
| 6945 | |||
| 6946 | bool isParamExpr(size_t N) const override { |
||
| 6947 | return false; |
||
| 6948 | } |
||
| 6949 | |||
| 6950 | static const ParsedAttrInfoMSAllocator Instance; |
||
| 6951 | }; |
||
| 6952 | const ParsedAttrInfoMSAllocator ParsedAttrInfoMSAllocator::Instance; |
||
| 6953 | static constexpr ParsedAttrInfo::Spelling MSInheritanceSpellings[] = { |
||
| 6954 | {AttributeCommonInfo::AS_Keyword, "__single_inheritance"}, |
||
| 6955 | {AttributeCommonInfo::AS_Keyword, "__multiple_inheritance"}, |
||
| 6956 | {AttributeCommonInfo::AS_Keyword, "__virtual_inheritance"}, |
||
| 6957 | {AttributeCommonInfo::AS_Keyword, "__unspecified_inheritance"}, |
||
| 6958 | }; |
||
| 6959 | struct ParsedAttrInfoMSInheritance final : public ParsedAttrInfo { |
||
| 6960 | constexpr ParsedAttrInfoMSInheritance() : ParsedAttrInfo( |
||
| 6961 | /*AttrKind=*/ParsedAttr::AT_MSInheritance, |
||
| 6962 | /*NumArgs=*/0, |
||
| 6963 | /*OptArgs=*/0, |
||
| 6964 | /*NumArgMembers=*/0, |
||
| 6965 | /*HasCustomParsing=*/0, |
||
| 6966 | /*AcceptsExprPack=*/0, |
||
| 6967 | /*IsTargetSpecific=*/0, |
||
| 6968 | /*IsType=*/0, |
||
| 6969 | /*IsStmt=*/0, |
||
| 6970 | /*IsKnownToGCC=*/0, |
||
| 6971 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 6972 | /*Spellings=*/MSInheritanceSpellings, |
||
| 6973 | /*ArgNames=*/{}) {} |
||
| 6974 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 6975 | return LangOpts.MicrosoftExt; |
||
| 6976 | } |
||
| 6977 | |||
| 6978 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 6979 | enum Spelling { |
||
| 6980 | Keyword_single_inheritance = 0, |
||
| 6981 | Keyword_multiple_inheritance = 1, |
||
| 6982 | Keyword_virtual_inheritance = 2, |
||
| 6983 | Keyword_unspecified_inheritance = 3, |
||
| 6984 | SpellingNotCalculated = 15 |
||
| 6985 | |||
| 6986 | }; |
||
| 6987 | |||
| 6988 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 6989 | switch (Idx) { |
||
| 6990 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 6991 | case 0: return Keyword_single_inheritance; |
||
| 6992 | case 1: return Keyword_multiple_inheritance; |
||
| 6993 | case 2: return Keyword_virtual_inheritance; |
||
| 6994 | case 3: return Keyword_unspecified_inheritance; |
||
| 6995 | } |
||
| 6996 | } |
||
| 6997 | |||
| 6998 | bool isParamExpr(size_t N) const override { |
||
| 6999 | return false; |
||
| 7000 | } |
||
| 7001 | |||
| 7002 | static const ParsedAttrInfoMSInheritance Instance; |
||
| 7003 | }; |
||
| 7004 | const ParsedAttrInfoMSInheritance ParsedAttrInfoMSInheritance::Instance; |
||
| 7005 | static constexpr ParsedAttrInfo::Spelling MSNoVTableSpellings[] = { |
||
| 7006 | {AttributeCommonInfo::AS_Declspec, "novtable"}, |
||
| 7007 | }; |
||
| 7008 | struct ParsedAttrInfoMSNoVTable final : public ParsedAttrInfo { |
||
| 7009 | constexpr ParsedAttrInfoMSNoVTable() : ParsedAttrInfo( |
||
| 7010 | /*AttrKind=*/ParsedAttr::AT_MSNoVTable, |
||
| 7011 | /*NumArgs=*/0, |
||
| 7012 | /*OptArgs=*/0, |
||
| 7013 | /*NumArgMembers=*/0, |
||
| 7014 | /*HasCustomParsing=*/0, |
||
| 7015 | /*AcceptsExprPack=*/0, |
||
| 7016 | /*IsTargetSpecific=*/1, |
||
| 7017 | /*IsType=*/0, |
||
| 7018 | /*IsStmt=*/0, |
||
| 7019 | /*IsKnownToGCC=*/0, |
||
| 7020 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 7021 | /*Spellings=*/MSNoVTableSpellings, |
||
| 7022 | /*ArgNames=*/{}) {} |
||
| 7023 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 7024 | if (!isa<CXXRecordDecl>(D)) { |
||
| 7025 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 7026 | << Attr << "classes"; |
||
| 7027 | return false; |
||
| 7028 | } |
||
| 7029 | return true; |
||
| 7030 | } |
||
| 7031 | |||
| 7032 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 7033 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 7034 | << AL << St->getBeginLoc(); |
||
| 7035 | return false; |
||
| 7036 | } |
||
| 7037 | |||
| 7038 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 7039 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 7040 | 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().isMicrosoft() ); |
||
| 7041 | } |
||
| 7042 | |||
| 7043 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 7044 | D->addAttr(::new (S.Context) MSNoVTableAttr(S.Context, Attr)); |
||
| 7045 | return AttributeApplied; |
||
| 7046 | } |
||
| 7047 | |||
| 7048 | bool isParamExpr(size_t N) const override { |
||
| 7049 | return false; |
||
| 7050 | } |
||
| 7051 | |||
| 7052 | static const ParsedAttrInfoMSNoVTable Instance; |
||
| 7053 | }; |
||
| 7054 | const ParsedAttrInfoMSNoVTable ParsedAttrInfoMSNoVTable::Instance; |
||
| 7055 | static constexpr ParsedAttrInfo::Spelling MSStructSpellings[] = { |
||
| 7056 | {AttributeCommonInfo::AS_GNU, "ms_struct"}, |
||
| 7057 | {AttributeCommonInfo::AS_CXX11, "gnu::ms_struct"}, |
||
| 7058 | {AttributeCommonInfo::AS_C2x, "gnu::ms_struct"}, |
||
| 7059 | }; |
||
| 7060 | struct ParsedAttrInfoMSStruct final : public ParsedAttrInfo { |
||
| 7061 | constexpr ParsedAttrInfoMSStruct() : ParsedAttrInfo( |
||
| 7062 | /*AttrKind=*/ParsedAttr::AT_MSStruct, |
||
| 7063 | /*NumArgs=*/0, |
||
| 7064 | /*OptArgs=*/0, |
||
| 7065 | /*NumArgMembers=*/0, |
||
| 7066 | /*HasCustomParsing=*/0, |
||
| 7067 | /*AcceptsExprPack=*/0, |
||
| 7068 | /*IsTargetSpecific=*/0, |
||
| 7069 | /*IsType=*/0, |
||
| 7070 | /*IsStmt=*/0, |
||
| 7071 | /*IsKnownToGCC=*/1, |
||
| 7072 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 7073 | /*Spellings=*/MSStructSpellings, |
||
| 7074 | /*ArgNames=*/{}) {} |
||
| 7075 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 7076 | if (!isa<RecordDecl>(D)) { |
||
| 7077 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 7078 | << Attr << "structs, unions, and classes"; |
||
| 7079 | return false; |
||
| 7080 | } |
||
| 7081 | return true; |
||
| 7082 | } |
||
| 7083 | |||
| 7084 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 7085 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 7086 | << AL << St->getBeginLoc(); |
||
| 7087 | return false; |
||
| 7088 | } |
||
| 7089 | |||
| 7090 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 7091 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 7092 | } |
||
| 7093 | |||
| 7094 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 7095 | D->addAttr(::new (S.Context) MSStructAttr(S.Context, Attr)); |
||
| 7096 | return AttributeApplied; |
||
| 7097 | } |
||
| 7098 | |||
| 7099 | bool isParamExpr(size_t N) const override { |
||
| 7100 | return false; |
||
| 7101 | } |
||
| 7102 | |||
| 7103 | static const ParsedAttrInfoMSStruct Instance; |
||
| 7104 | }; |
||
| 7105 | const ParsedAttrInfoMSStruct ParsedAttrInfoMSStruct::Instance; |
||
| 7106 | static constexpr ParsedAttrInfo::Spelling MatrixTypeSpellings[] = { |
||
| 7107 | {AttributeCommonInfo::AS_GNU, "matrix_type"}, |
||
| 7108 | {AttributeCommonInfo::AS_CXX11, "clang::matrix_type"}, |
||
| 7109 | {AttributeCommonInfo::AS_C2x, "clang::matrix_type"}, |
||
| 7110 | }; |
||
| 7111 | static constexpr const char *MatrixTypeArgNames[] = { |
||
| 7112 | "NumRows","NumColumns",}; |
||
| 7113 | struct ParsedAttrInfoMatrixType final : public ParsedAttrInfo { |
||
| 7114 | constexpr ParsedAttrInfoMatrixType() : ParsedAttrInfo( |
||
| 7115 | /*AttrKind=*/ParsedAttr::AT_MatrixType, |
||
| 7116 | /*NumArgs=*/2, |
||
| 7117 | /*OptArgs=*/0, |
||
| 7118 | /*NumArgMembers=*/2, |
||
| 7119 | /*HasCustomParsing=*/0, |
||
| 7120 | /*AcceptsExprPack=*/0, |
||
| 7121 | /*IsTargetSpecific=*/0, |
||
| 7122 | /*IsType=*/1, |
||
| 7123 | /*IsStmt=*/0, |
||
| 7124 | /*IsKnownToGCC=*/0, |
||
| 7125 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 7126 | /*Spellings=*/MatrixTypeSpellings, |
||
| 7127 | /*ArgNames=*/MatrixTypeArgNames) {} |
||
| 7128 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 7129 | if (!isa<TypedefNameDecl>(D)) { |
||
| 7130 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 7131 | << Attr << "typedefs"; |
||
| 7132 | return false; |
||
| 7133 | } |
||
| 7134 | return true; |
||
| 7135 | } |
||
| 7136 | |||
| 7137 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 7138 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 7139 | << AL << St->getBeginLoc(); |
||
| 7140 | return false; |
||
| 7141 | } |
||
| 7142 | |||
| 7143 | bool isParamExpr(size_t N) const override { |
||
| 7144 | return (N == 0) || (N == 1) || false; |
||
| 7145 | } |
||
| 7146 | |||
| 7147 | static const ParsedAttrInfoMatrixType Instance; |
||
| 7148 | }; |
||
| 7149 | const ParsedAttrInfoMatrixType ParsedAttrInfoMatrixType::Instance; |
||
| 7150 | static constexpr ParsedAttrInfo::Spelling MayAliasSpellings[] = { |
||
| 7151 | {AttributeCommonInfo::AS_GNU, "may_alias"}, |
||
| 7152 | {AttributeCommonInfo::AS_CXX11, "gnu::may_alias"}, |
||
| 7153 | {AttributeCommonInfo::AS_C2x, "gnu::may_alias"}, |
||
| 7154 | }; |
||
| 7155 | struct ParsedAttrInfoMayAlias final : public ParsedAttrInfo { |
||
| 7156 | constexpr ParsedAttrInfoMayAlias() : ParsedAttrInfo( |
||
| 7157 | /*AttrKind=*/ParsedAttr::AT_MayAlias, |
||
| 7158 | /*NumArgs=*/0, |
||
| 7159 | /*OptArgs=*/0, |
||
| 7160 | /*NumArgMembers=*/0, |
||
| 7161 | /*HasCustomParsing=*/0, |
||
| 7162 | /*AcceptsExprPack=*/0, |
||
| 7163 | /*IsTargetSpecific=*/0, |
||
| 7164 | /*IsType=*/0, |
||
| 7165 | /*IsStmt=*/0, |
||
| 7166 | /*IsKnownToGCC=*/1, |
||
| 7167 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 7168 | /*Spellings=*/MayAliasSpellings, |
||
| 7169 | /*ArgNames=*/{}) {} |
||
| 7170 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 7171 | D->addAttr(::new (S.Context) MayAliasAttr(S.Context, Attr)); |
||
| 7172 | return AttributeApplied; |
||
| 7173 | } |
||
| 7174 | |||
| 7175 | bool isParamExpr(size_t N) const override { |
||
| 7176 | return false; |
||
| 7177 | } |
||
| 7178 | |||
| 7179 | static const ParsedAttrInfoMayAlias Instance; |
||
| 7180 | }; |
||
| 7181 | const ParsedAttrInfoMayAlias ParsedAttrInfoMayAlias::Instance; |
||
| 7182 | static constexpr ParsedAttrInfo::Spelling MaybeUndefSpellings[] = { |
||
| 7183 | {AttributeCommonInfo::AS_GNU, "maybe_undef"}, |
||
| 7184 | {AttributeCommonInfo::AS_CXX11, "clang::maybe_undef"}, |
||
| 7185 | {AttributeCommonInfo::AS_C2x, "clang::maybe_undef"}, |
||
| 7186 | }; |
||
| 7187 | struct ParsedAttrInfoMaybeUndef final : public ParsedAttrInfo { |
||
| 7188 | constexpr ParsedAttrInfoMaybeUndef() : ParsedAttrInfo( |
||
| 7189 | /*AttrKind=*/ParsedAttr::AT_MaybeUndef, |
||
| 7190 | /*NumArgs=*/0, |
||
| 7191 | /*OptArgs=*/0, |
||
| 7192 | /*NumArgMembers=*/0, |
||
| 7193 | /*HasCustomParsing=*/0, |
||
| 7194 | /*AcceptsExprPack=*/0, |
||
| 7195 | /*IsTargetSpecific=*/0, |
||
| 7196 | /*IsType=*/0, |
||
| 7197 | /*IsStmt=*/0, |
||
| 7198 | /*IsKnownToGCC=*/0, |
||
| 7199 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 7200 | /*Spellings=*/MaybeUndefSpellings, |
||
| 7201 | /*ArgNames=*/{}) {} |
||
| 7202 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 7203 | if (!isa<ParmVarDecl>(D)) { |
||
| 7204 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 7205 | << Attr << "parameters"; |
||
| 7206 | return false; |
||
| 7207 | } |
||
| 7208 | return true; |
||
| 7209 | } |
||
| 7210 | |||
| 7211 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 7212 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 7213 | << AL << St->getBeginLoc(); |
||
| 7214 | return false; |
||
| 7215 | } |
||
| 7216 | |||
| 7217 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 7218 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
||
| 7219 | } |
||
| 7220 | |||
| 7221 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 7222 | D->addAttr(::new (S.Context) MaybeUndefAttr(S.Context, Attr)); |
||
| 7223 | return AttributeApplied; |
||
| 7224 | } |
||
| 7225 | |||
| 7226 | bool isParamExpr(size_t N) const override { |
||
| 7227 | return false; |
||
| 7228 | } |
||
| 7229 | |||
| 7230 | static const ParsedAttrInfoMaybeUndef Instance; |
||
| 7231 | }; |
||
| 7232 | const ParsedAttrInfoMaybeUndef ParsedAttrInfoMaybeUndef::Instance; |
||
| 7233 | static constexpr ParsedAttrInfo::Spelling MicroMipsSpellings[] = { |
||
| 7234 | {AttributeCommonInfo::AS_GNU, "micromips"}, |
||
| 7235 | {AttributeCommonInfo::AS_CXX11, "gnu::micromips"}, |
||
| 7236 | {AttributeCommonInfo::AS_C2x, "gnu::micromips"}, |
||
| 7237 | }; |
||
| 7238 | struct ParsedAttrInfoMicroMips final : public ParsedAttrInfo { |
||
| 7239 | constexpr ParsedAttrInfoMicroMips() : ParsedAttrInfo( |
||
| 7240 | /*AttrKind=*/ParsedAttr::AT_MicroMips, |
||
| 7241 | /*NumArgs=*/0, |
||
| 7242 | /*OptArgs=*/0, |
||
| 7243 | /*NumArgMembers=*/0, |
||
| 7244 | /*HasCustomParsing=*/0, |
||
| 7245 | /*AcceptsExprPack=*/0, |
||
| 7246 | /*IsTargetSpecific=*/1, |
||
| 7247 | /*IsType=*/0, |
||
| 7248 | /*IsStmt=*/0, |
||
| 7249 | /*IsKnownToGCC=*/1, |
||
| 7250 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 7251 | /*Spellings=*/MicroMipsSpellings, |
||
| 7252 | /*ArgNames=*/{}) {} |
||
| 7253 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 7254 | if (!isa<FunctionDecl>(D)) { |
||
| 7255 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 7256 | << Attr << "functions"; |
||
| 7257 | return false; |
||
| 7258 | } |
||
| 7259 | return true; |
||
| 7260 | } |
||
| 7261 | |||
| 7262 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 7263 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 7264 | << AL << St->getBeginLoc(); |
||
| 7265 | return false; |
||
| 7266 | } |
||
| 7267 | |||
| 7268 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 7269 | |||
| 7270 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 7271 | if (const auto *A = D->getAttr<Mips16Attr>()) { |
||
| 7272 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 7273 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 7274 | return false; |
||
| 7275 | } |
||
| 7276 | return true; |
||
| 7277 | } |
||
| 7278 | |||
| 7279 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 7280 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 7281 | return true && (T.getArch() == llvm::Triple::mips || T.getArch() == llvm::Triple::mipsel); |
||
| 7282 | } |
||
| 7283 | |||
| 7284 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 7285 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 7286 | } |
||
| 7287 | |||
| 7288 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 7289 | D->addAttr(::new (S.Context) MicroMipsAttr(S.Context, Attr)); |
||
| 7290 | return AttributeApplied; |
||
| 7291 | } |
||
| 7292 | |||
| 7293 | bool isParamExpr(size_t N) const override { |
||
| 7294 | return false; |
||
| 7295 | } |
||
| 7296 | |||
| 7297 | static const ParsedAttrInfoMicroMips Instance; |
||
| 7298 | }; |
||
| 7299 | const ParsedAttrInfoMicroMips ParsedAttrInfoMicroMips::Instance; |
||
| 7300 | static constexpr ParsedAttrInfo::Spelling MinSizeSpellings[] = { |
||
| 7301 | {AttributeCommonInfo::AS_GNU, "minsize"}, |
||
| 7302 | {AttributeCommonInfo::AS_CXX11, "clang::minsize"}, |
||
| 7303 | {AttributeCommonInfo::AS_C2x, "clang::minsize"}, |
||
| 7304 | }; |
||
| 7305 | struct ParsedAttrInfoMinSize final : public ParsedAttrInfo { |
||
| 7306 | constexpr ParsedAttrInfoMinSize() : ParsedAttrInfo( |
||
| 7307 | /*AttrKind=*/ParsedAttr::AT_MinSize, |
||
| 7308 | /*NumArgs=*/0, |
||
| 7309 | /*OptArgs=*/0, |
||
| 7310 | /*NumArgMembers=*/0, |
||
| 7311 | /*HasCustomParsing=*/0, |
||
| 7312 | /*AcceptsExprPack=*/0, |
||
| 7313 | /*IsTargetSpecific=*/0, |
||
| 7314 | /*IsType=*/0, |
||
| 7315 | /*IsStmt=*/0, |
||
| 7316 | /*IsKnownToGCC=*/0, |
||
| 7317 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 7318 | /*Spellings=*/MinSizeSpellings, |
||
| 7319 | /*ArgNames=*/{}) {} |
||
| 7320 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 7321 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
||
| 7322 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 7323 | << Attr << "functions and Objective-C methods"; |
||
| 7324 | return false; |
||
| 7325 | } |
||
| 7326 | return true; |
||
| 7327 | } |
||
| 7328 | |||
| 7329 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 7330 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 7331 | << AL << St->getBeginLoc(); |
||
| 7332 | return false; |
||
| 7333 | } |
||
| 7334 | |||
| 7335 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 7336 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 7337 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 7338 | } |
||
| 7339 | |||
| 7340 | bool isParamExpr(size_t N) const override { |
||
| 7341 | return false; |
||
| 7342 | } |
||
| 7343 | |||
| 7344 | static const ParsedAttrInfoMinSize Instance; |
||
| 7345 | }; |
||
| 7346 | const ParsedAttrInfoMinSize ParsedAttrInfoMinSize::Instance; |
||
| 7347 | static constexpr ParsedAttrInfo::Spelling MinVectorWidthSpellings[] = { |
||
| 7348 | {AttributeCommonInfo::AS_GNU, "min_vector_width"}, |
||
| 7349 | {AttributeCommonInfo::AS_CXX11, "clang::min_vector_width"}, |
||
| 7350 | {AttributeCommonInfo::AS_C2x, "clang::min_vector_width"}, |
||
| 7351 | }; |
||
| 7352 | static constexpr const char *MinVectorWidthArgNames[] = { |
||
| 7353 | "VectorWidth",}; |
||
| 7354 | struct ParsedAttrInfoMinVectorWidth final : public ParsedAttrInfo { |
||
| 7355 | constexpr ParsedAttrInfoMinVectorWidth() : ParsedAttrInfo( |
||
| 7356 | /*AttrKind=*/ParsedAttr::AT_MinVectorWidth, |
||
| 7357 | /*NumArgs=*/1, |
||
| 7358 | /*OptArgs=*/0, |
||
| 7359 | /*NumArgMembers=*/1, |
||
| 7360 | /*HasCustomParsing=*/0, |
||
| 7361 | /*AcceptsExprPack=*/0, |
||
| 7362 | /*IsTargetSpecific=*/0, |
||
| 7363 | /*IsType=*/0, |
||
| 7364 | /*IsStmt=*/0, |
||
| 7365 | /*IsKnownToGCC=*/0, |
||
| 7366 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 7367 | /*Spellings=*/MinVectorWidthSpellings, |
||
| 7368 | /*ArgNames=*/MinVectorWidthArgNames) {} |
||
| 7369 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 7370 | if (!isa<FunctionDecl>(D)) { |
||
| 7371 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 7372 | << Attr << "functions"; |
||
| 7373 | return false; |
||
| 7374 | } |
||
| 7375 | return true; |
||
| 7376 | } |
||
| 7377 | |||
| 7378 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 7379 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 7380 | << AL << St->getBeginLoc(); |
||
| 7381 | return false; |
||
| 7382 | } |
||
| 7383 | |||
| 7384 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 7385 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 7386 | } |
||
| 7387 | |||
| 7388 | bool isParamExpr(size_t N) const override { |
||
| 7389 | return false; |
||
| 7390 | } |
||
| 7391 | |||
| 7392 | static const ParsedAttrInfoMinVectorWidth Instance; |
||
| 7393 | }; |
||
| 7394 | const ParsedAttrInfoMinVectorWidth ParsedAttrInfoMinVectorWidth::Instance; |
||
| 7395 | static constexpr ParsedAttrInfo::Spelling Mips16Spellings[] = { |
||
| 7396 | {AttributeCommonInfo::AS_GNU, "mips16"}, |
||
| 7397 | {AttributeCommonInfo::AS_CXX11, "gnu::mips16"}, |
||
| 7398 | {AttributeCommonInfo::AS_C2x, "gnu::mips16"}, |
||
| 7399 | }; |
||
| 7400 | struct ParsedAttrInfoMips16 final : public ParsedAttrInfo { |
||
| 7401 | constexpr ParsedAttrInfoMips16() : ParsedAttrInfo( |
||
| 7402 | /*AttrKind=*/ParsedAttr::AT_Mips16, |
||
| 7403 | /*NumArgs=*/0, |
||
| 7404 | /*OptArgs=*/0, |
||
| 7405 | /*NumArgMembers=*/0, |
||
| 7406 | /*HasCustomParsing=*/0, |
||
| 7407 | /*AcceptsExprPack=*/0, |
||
| 7408 | /*IsTargetSpecific=*/1, |
||
| 7409 | /*IsType=*/0, |
||
| 7410 | /*IsStmt=*/0, |
||
| 7411 | /*IsKnownToGCC=*/1, |
||
| 7412 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 7413 | /*Spellings=*/Mips16Spellings, |
||
| 7414 | /*ArgNames=*/{}) {} |
||
| 7415 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 7416 | if (!isa<FunctionDecl>(D)) { |
||
| 7417 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 7418 | << Attr << "functions"; |
||
| 7419 | return false; |
||
| 7420 | } |
||
| 7421 | return true; |
||
| 7422 | } |
||
| 7423 | |||
| 7424 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 7425 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 7426 | << AL << St->getBeginLoc(); |
||
| 7427 | return false; |
||
| 7428 | } |
||
| 7429 | |||
| 7430 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 7431 | |||
| 7432 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 7433 | if (const auto *A = D->getAttr<MipsInterruptAttr>()) { |
||
| 7434 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 7435 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 7436 | return false; |
||
| 7437 | } |
||
| 7438 | if (const auto *A = D->getAttr<MicroMipsAttr>()) { |
||
| 7439 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 7440 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 7441 | return false; |
||
| 7442 | } |
||
| 7443 | return true; |
||
| 7444 | } |
||
| 7445 | |||
| 7446 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 7447 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 7448 | return true && (T.getArch() == llvm::Triple::mips || T.getArch() == llvm::Triple::mipsel); |
||
| 7449 | } |
||
| 7450 | |||
| 7451 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 7452 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 7453 | } |
||
| 7454 | |||
| 7455 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 7456 | D->addAttr(::new (S.Context) Mips16Attr(S.Context, Attr)); |
||
| 7457 | return AttributeApplied; |
||
| 7458 | } |
||
| 7459 | |||
| 7460 | bool isParamExpr(size_t N) const override { |
||
| 7461 | return false; |
||
| 7462 | } |
||
| 7463 | |||
| 7464 | static const ParsedAttrInfoMips16 Instance; |
||
| 7465 | }; |
||
| 7466 | const ParsedAttrInfoMips16 ParsedAttrInfoMips16::Instance; |
||
| 7467 | static constexpr ParsedAttrInfo::Spelling MipsLongCallSpellings[] = { |
||
| 7468 | {AttributeCommonInfo::AS_GNU, "long_call"}, |
||
| 7469 | {AttributeCommonInfo::AS_CXX11, "gnu::long_call"}, |
||
| 7470 | {AttributeCommonInfo::AS_C2x, "gnu::long_call"}, |
||
| 7471 | {AttributeCommonInfo::AS_GNU, "far"}, |
||
| 7472 | {AttributeCommonInfo::AS_CXX11, "gnu::far"}, |
||
| 7473 | {AttributeCommonInfo::AS_C2x, "gnu::far"}, |
||
| 7474 | }; |
||
| 7475 | struct ParsedAttrInfoMipsLongCall final : public ParsedAttrInfo { |
||
| 7476 | constexpr ParsedAttrInfoMipsLongCall() : ParsedAttrInfo( |
||
| 7477 | /*AttrKind=*/ParsedAttr::AT_MipsLongCall, |
||
| 7478 | /*NumArgs=*/0, |
||
| 7479 | /*OptArgs=*/0, |
||
| 7480 | /*NumArgMembers=*/0, |
||
| 7481 | /*HasCustomParsing=*/0, |
||
| 7482 | /*AcceptsExprPack=*/0, |
||
| 7483 | /*IsTargetSpecific=*/1, |
||
| 7484 | /*IsType=*/0, |
||
| 7485 | /*IsStmt=*/0, |
||
| 7486 | /*IsKnownToGCC=*/1, |
||
| 7487 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 7488 | /*Spellings=*/MipsLongCallSpellings, |
||
| 7489 | /*ArgNames=*/{}) {} |
||
| 7490 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 7491 | if (!isa<FunctionDecl>(D)) { |
||
| 7492 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 7493 | << Attr << "functions"; |
||
| 7494 | return false; |
||
| 7495 | } |
||
| 7496 | return true; |
||
| 7497 | } |
||
| 7498 | |||
| 7499 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 7500 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 7501 | << AL << St->getBeginLoc(); |
||
| 7502 | return false; |
||
| 7503 | } |
||
| 7504 | |||
| 7505 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 7506 | |||
| 7507 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 7508 | if (const auto *A = D->getAttr<MipsShortCallAttr>()) { |
||
| 7509 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 7510 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 7511 | return false; |
||
| 7512 | } |
||
| 7513 | return true; |
||
| 7514 | } |
||
| 7515 | |||
| 7516 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 7517 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 7518 | return true && (T.getArch() == llvm::Triple::mips || T.getArch() == llvm::Triple::mipsel || T.getArch() == llvm::Triple::mips64 || T.getArch() == llvm::Triple::mips64el); |
||
| 7519 | } |
||
| 7520 | |||
| 7521 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 7522 | enum Spelling { |
||
| 7523 | GNU_long_call = 0, |
||
| 7524 | CXX11_gnu_long_call = 1, |
||
| 7525 | C2x_gnu_long_call = 2, |
||
| 7526 | GNU_far = 3, |
||
| 7527 | CXX11_gnu_far = 4, |
||
| 7528 | C2x_gnu_far = 5, |
||
| 7529 | SpellingNotCalculated = 15 |
||
| 7530 | |||
| 7531 | }; |
||
| 7532 | |||
| 7533 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 7534 | switch (Idx) { |
||
| 7535 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 7536 | case 0: return GNU_long_call; |
||
| 7537 | case 1: return CXX11_gnu_long_call; |
||
| 7538 | case 2: return C2x_gnu_long_call; |
||
| 7539 | case 3: return GNU_far; |
||
| 7540 | case 4: return CXX11_gnu_far; |
||
| 7541 | case 5: return C2x_gnu_far; |
||
| 7542 | } |
||
| 7543 | } |
||
| 7544 | |||
| 7545 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 7546 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 7547 | } |
||
| 7548 | |||
| 7549 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 7550 | D->addAttr(::new (S.Context) MipsLongCallAttr(S.Context, Attr)); |
||
| 7551 | return AttributeApplied; |
||
| 7552 | } |
||
| 7553 | |||
| 7554 | bool isParamExpr(size_t N) const override { |
||
| 7555 | return false; |
||
| 7556 | } |
||
| 7557 | |||
| 7558 | static const ParsedAttrInfoMipsLongCall Instance; |
||
| 7559 | }; |
||
| 7560 | const ParsedAttrInfoMipsLongCall ParsedAttrInfoMipsLongCall::Instance; |
||
| 7561 | static constexpr ParsedAttrInfo::Spelling MipsShortCallSpellings[] = { |
||
| 7562 | {AttributeCommonInfo::AS_GNU, "short_call"}, |
||
| 7563 | {AttributeCommonInfo::AS_CXX11, "gnu::short_call"}, |
||
| 7564 | {AttributeCommonInfo::AS_C2x, "gnu::short_call"}, |
||
| 7565 | {AttributeCommonInfo::AS_GNU, "near"}, |
||
| 7566 | {AttributeCommonInfo::AS_CXX11, "gnu::near"}, |
||
| 7567 | {AttributeCommonInfo::AS_C2x, "gnu::near"}, |
||
| 7568 | }; |
||
| 7569 | struct ParsedAttrInfoMipsShortCall final : public ParsedAttrInfo { |
||
| 7570 | constexpr ParsedAttrInfoMipsShortCall() : ParsedAttrInfo( |
||
| 7571 | /*AttrKind=*/ParsedAttr::AT_MipsShortCall, |
||
| 7572 | /*NumArgs=*/0, |
||
| 7573 | /*OptArgs=*/0, |
||
| 7574 | /*NumArgMembers=*/0, |
||
| 7575 | /*HasCustomParsing=*/0, |
||
| 7576 | /*AcceptsExprPack=*/0, |
||
| 7577 | /*IsTargetSpecific=*/1, |
||
| 7578 | /*IsType=*/0, |
||
| 7579 | /*IsStmt=*/0, |
||
| 7580 | /*IsKnownToGCC=*/1, |
||
| 7581 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 7582 | /*Spellings=*/MipsShortCallSpellings, |
||
| 7583 | /*ArgNames=*/{}) {} |
||
| 7584 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 7585 | if (!isa<FunctionDecl>(D)) { |
||
| 7586 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 7587 | << Attr << "functions"; |
||
| 7588 | return false; |
||
| 7589 | } |
||
| 7590 | return true; |
||
| 7591 | } |
||
| 7592 | |||
| 7593 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 7594 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 7595 | << AL << St->getBeginLoc(); |
||
| 7596 | return false; |
||
| 7597 | } |
||
| 7598 | |||
| 7599 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 7600 | |||
| 7601 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 7602 | if (const auto *A = D->getAttr<MipsLongCallAttr>()) { |
||
| 7603 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 7604 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 7605 | return false; |
||
| 7606 | } |
||
| 7607 | return true; |
||
| 7608 | } |
||
| 7609 | |||
| 7610 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 7611 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 7612 | return true && (T.getArch() == llvm::Triple::mips || T.getArch() == llvm::Triple::mipsel || T.getArch() == llvm::Triple::mips64 || T.getArch() == llvm::Triple::mips64el); |
||
| 7613 | } |
||
| 7614 | |||
| 7615 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 7616 | enum Spelling { |
||
| 7617 | GNU_short_call = 0, |
||
| 7618 | CXX11_gnu_short_call = 1, |
||
| 7619 | C2x_gnu_short_call = 2, |
||
| 7620 | GNU_near = 3, |
||
| 7621 | CXX11_gnu_near = 4, |
||
| 7622 | C2x_gnu_near = 5, |
||
| 7623 | SpellingNotCalculated = 15 |
||
| 7624 | |||
| 7625 | }; |
||
| 7626 | |||
| 7627 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 7628 | switch (Idx) { |
||
| 7629 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 7630 | case 0: return GNU_short_call; |
||
| 7631 | case 1: return CXX11_gnu_short_call; |
||
| 7632 | case 2: return C2x_gnu_short_call; |
||
| 7633 | case 3: return GNU_near; |
||
| 7634 | case 4: return CXX11_gnu_near; |
||
| 7635 | case 5: return C2x_gnu_near; |
||
| 7636 | } |
||
| 7637 | } |
||
| 7638 | |||
| 7639 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 7640 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 7641 | } |
||
| 7642 | |||
| 7643 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 7644 | D->addAttr(::new (S.Context) MipsShortCallAttr(S.Context, Attr)); |
||
| 7645 | return AttributeApplied; |
||
| 7646 | } |
||
| 7647 | |||
| 7648 | bool isParamExpr(size_t N) const override { |
||
| 7649 | return false; |
||
| 7650 | } |
||
| 7651 | |||
| 7652 | static const ParsedAttrInfoMipsShortCall Instance; |
||
| 7653 | }; |
||
| 7654 | const ParsedAttrInfoMipsShortCall ParsedAttrInfoMipsShortCall::Instance; |
||
| 7655 | static constexpr ParsedAttrInfo::Spelling ModeSpellings[] = { |
||
| 7656 | {AttributeCommonInfo::AS_GNU, "mode"}, |
||
| 7657 | {AttributeCommonInfo::AS_CXX11, "gnu::mode"}, |
||
| 7658 | {AttributeCommonInfo::AS_C2x, "gnu::mode"}, |
||
| 7659 | }; |
||
| 7660 | static constexpr const char *ModeArgNames[] = { |
||
| 7661 | "Mode",}; |
||
| 7662 | struct ParsedAttrInfoMode final : public ParsedAttrInfo { |
||
| 7663 | constexpr ParsedAttrInfoMode() : ParsedAttrInfo( |
||
| 7664 | /*AttrKind=*/ParsedAttr::AT_Mode, |
||
| 7665 | /*NumArgs=*/1, |
||
| 7666 | /*OptArgs=*/0, |
||
| 7667 | /*NumArgMembers=*/1, |
||
| 7668 | /*HasCustomParsing=*/0, |
||
| 7669 | /*AcceptsExprPack=*/0, |
||
| 7670 | /*IsTargetSpecific=*/0, |
||
| 7671 | /*IsType=*/0, |
||
| 7672 | /*IsStmt=*/0, |
||
| 7673 | /*IsKnownToGCC=*/1, |
||
| 7674 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 7675 | /*Spellings=*/ModeSpellings, |
||
| 7676 | /*ArgNames=*/ModeArgNames) {} |
||
| 7677 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 7678 | if (!isa<VarDecl>(D) && !isa<EnumDecl>(D) && !isa<TypedefNameDecl>(D) && !isa<FieldDecl>(D)) { |
||
| 7679 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 7680 | << Attr << "variables, enums, typedefs, and non-static data members"; |
||
| 7681 | return false; |
||
| 7682 | } |
||
| 7683 | return true; |
||
| 7684 | } |
||
| 7685 | |||
| 7686 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 7687 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 7688 | << AL << St->getBeginLoc(); |
||
| 7689 | return false; |
||
| 7690 | } |
||
| 7691 | |||
| 7692 | bool isParamExpr(size_t N) const override { |
||
| 7693 | return false; |
||
| 7694 | } |
||
| 7695 | |||
| 7696 | static const ParsedAttrInfoMode Instance; |
||
| 7697 | }; |
||
| 7698 | const ParsedAttrInfoMode ParsedAttrInfoMode::Instance; |
||
| 7699 | static constexpr ParsedAttrInfo::Spelling MustTailSpellings[] = { |
||
| 7700 | {AttributeCommonInfo::AS_GNU, "musttail"}, |
||
| 7701 | {AttributeCommonInfo::AS_CXX11, "clang::musttail"}, |
||
| 7702 | {AttributeCommonInfo::AS_C2x, "clang::musttail"}, |
||
| 7703 | }; |
||
| 7704 | struct ParsedAttrInfoMustTail final : public ParsedAttrInfo { |
||
| 7705 | constexpr ParsedAttrInfoMustTail() : ParsedAttrInfo( |
||
| 7706 | /*AttrKind=*/ParsedAttr::AT_MustTail, |
||
| 7707 | /*NumArgs=*/0, |
||
| 7708 | /*OptArgs=*/0, |
||
| 7709 | /*NumArgMembers=*/0, |
||
| 7710 | /*HasCustomParsing=*/0, |
||
| 7711 | /*AcceptsExprPack=*/0, |
||
| 7712 | /*IsTargetSpecific=*/0, |
||
| 7713 | /*IsType=*/0, |
||
| 7714 | /*IsStmt=*/1, |
||
| 7715 | /*IsKnownToGCC=*/0, |
||
| 7716 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 7717 | /*Spellings=*/MustTailSpellings, |
||
| 7718 | /*ArgNames=*/{}) {} |
||
| 7719 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 7720 | S.Diag(AL.getLoc(), diag::err_attribute_invalid_on_decl) |
||
| 7721 | << AL << D->getLocation(); |
||
| 7722 | return false; |
||
| 7723 | } |
||
| 7724 | |||
| 7725 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &Attr, const Stmt *St) const override { |
||
| 7726 | if (!isa<ReturnStmt>(St)) { |
||
| 7727 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 7728 | << Attr << "return statements"; |
||
| 7729 | return false; |
||
| 7730 | } |
||
| 7731 | return true; |
||
| 7732 | } |
||
| 7733 | |||
| 7734 | bool isParamExpr(size_t N) const override { |
||
| 7735 | return false; |
||
| 7736 | } |
||
| 7737 | |||
| 7738 | static const ParsedAttrInfoMustTail Instance; |
||
| 7739 | }; |
||
| 7740 | const ParsedAttrInfoMustTail ParsedAttrInfoMustTail::Instance; |
||
| 7741 | static constexpr ParsedAttrInfo::Spelling NSConsumedSpellings[] = { |
||
| 7742 | {AttributeCommonInfo::AS_GNU, "ns_consumed"}, |
||
| 7743 | {AttributeCommonInfo::AS_CXX11, "clang::ns_consumed"}, |
||
| 7744 | {AttributeCommonInfo::AS_C2x, "clang::ns_consumed"}, |
||
| 7745 | }; |
||
| 7746 | struct ParsedAttrInfoNSConsumed final : public ParsedAttrInfo { |
||
| 7747 | constexpr ParsedAttrInfoNSConsumed() : ParsedAttrInfo( |
||
| 7748 | /*AttrKind=*/ParsedAttr::AT_NSConsumed, |
||
| 7749 | /*NumArgs=*/0, |
||
| 7750 | /*OptArgs=*/0, |
||
| 7751 | /*NumArgMembers=*/0, |
||
| 7752 | /*HasCustomParsing=*/0, |
||
| 7753 | /*AcceptsExprPack=*/0, |
||
| 7754 | /*IsTargetSpecific=*/0, |
||
| 7755 | /*IsType=*/0, |
||
| 7756 | /*IsStmt=*/0, |
||
| 7757 | /*IsKnownToGCC=*/0, |
||
| 7758 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 7759 | /*Spellings=*/NSConsumedSpellings, |
||
| 7760 | /*ArgNames=*/{}) {} |
||
| 7761 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 7762 | if (!isa<ParmVarDecl>(D)) { |
||
| 7763 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 7764 | << Attr << "parameters"; |
||
| 7765 | return false; |
||
| 7766 | } |
||
| 7767 | return true; |
||
| 7768 | } |
||
| 7769 | |||
| 7770 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 7771 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 7772 | << AL << St->getBeginLoc(); |
||
| 7773 | return false; |
||
| 7774 | } |
||
| 7775 | |||
| 7776 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 7777 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
||
| 7778 | } |
||
| 7779 | |||
| 7780 | bool isParamExpr(size_t N) const override { |
||
| 7781 | return false; |
||
| 7782 | } |
||
| 7783 | |||
| 7784 | static const ParsedAttrInfoNSConsumed Instance; |
||
| 7785 | }; |
||
| 7786 | const ParsedAttrInfoNSConsumed ParsedAttrInfoNSConsumed::Instance; |
||
| 7787 | static constexpr ParsedAttrInfo::Spelling NSConsumesSelfSpellings[] = { |
||
| 7788 | {AttributeCommonInfo::AS_GNU, "ns_consumes_self"}, |
||
| 7789 | {AttributeCommonInfo::AS_CXX11, "clang::ns_consumes_self"}, |
||
| 7790 | {AttributeCommonInfo::AS_C2x, "clang::ns_consumes_self"}, |
||
| 7791 | }; |
||
| 7792 | struct ParsedAttrInfoNSConsumesSelf final : public ParsedAttrInfo { |
||
| 7793 | constexpr ParsedAttrInfoNSConsumesSelf() : ParsedAttrInfo( |
||
| 7794 | /*AttrKind=*/ParsedAttr::AT_NSConsumesSelf, |
||
| 7795 | /*NumArgs=*/0, |
||
| 7796 | /*OptArgs=*/0, |
||
| 7797 | /*NumArgMembers=*/0, |
||
| 7798 | /*HasCustomParsing=*/0, |
||
| 7799 | /*AcceptsExprPack=*/0, |
||
| 7800 | /*IsTargetSpecific=*/0, |
||
| 7801 | /*IsType=*/0, |
||
| 7802 | /*IsStmt=*/0, |
||
| 7803 | /*IsKnownToGCC=*/0, |
||
| 7804 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 7805 | /*Spellings=*/NSConsumesSelfSpellings, |
||
| 7806 | /*ArgNames=*/{}) {} |
||
| 7807 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 7808 | if (!isa<ObjCMethodDecl>(D)) { |
||
| 7809 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 7810 | << Attr << "Objective-C methods"; |
||
| 7811 | return false; |
||
| 7812 | } |
||
| 7813 | return true; |
||
| 7814 | } |
||
| 7815 | |||
| 7816 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 7817 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 7818 | << AL << St->getBeginLoc(); |
||
| 7819 | return false; |
||
| 7820 | } |
||
| 7821 | |||
| 7822 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 7823 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 7824 | } |
||
| 7825 | |||
| 7826 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 7827 | D->addAttr(::new (S.Context) NSConsumesSelfAttr(S.Context, Attr)); |
||
| 7828 | return AttributeApplied; |
||
| 7829 | } |
||
| 7830 | |||
| 7831 | bool isParamExpr(size_t N) const override { |
||
| 7832 | return false; |
||
| 7833 | } |
||
| 7834 | |||
| 7835 | static const ParsedAttrInfoNSConsumesSelf Instance; |
||
| 7836 | }; |
||
| 7837 | const ParsedAttrInfoNSConsumesSelf ParsedAttrInfoNSConsumesSelf::Instance; |
||
| 7838 | static constexpr ParsedAttrInfo::Spelling NSErrorDomainSpellings[] = { |
||
| 7839 | {AttributeCommonInfo::AS_GNU, "ns_error_domain"}, |
||
| 7840 | }; |
||
| 7841 | static constexpr const char *NSErrorDomainArgNames[] = { |
||
| 7842 | "ErrorDomain",}; |
||
| 7843 | struct ParsedAttrInfoNSErrorDomain final : public ParsedAttrInfo { |
||
| 7844 | constexpr ParsedAttrInfoNSErrorDomain() : ParsedAttrInfo( |
||
| 7845 | /*AttrKind=*/ParsedAttr::AT_NSErrorDomain, |
||
| 7846 | /*NumArgs=*/1, |
||
| 7847 | /*OptArgs=*/0, |
||
| 7848 | /*NumArgMembers=*/1, |
||
| 7849 | /*HasCustomParsing=*/0, |
||
| 7850 | /*AcceptsExprPack=*/0, |
||
| 7851 | /*IsTargetSpecific=*/0, |
||
| 7852 | /*IsType=*/0, |
||
| 7853 | /*IsStmt=*/0, |
||
| 7854 | /*IsKnownToGCC=*/0, |
||
| 7855 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 7856 | /*Spellings=*/NSErrorDomainSpellings, |
||
| 7857 | /*ArgNames=*/NSErrorDomainArgNames) {} |
||
| 7858 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 7859 | if (!isa<EnumDecl>(D)) { |
||
| 7860 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 7861 | << Attr << "enums"; |
||
| 7862 | return false; |
||
| 7863 | } |
||
| 7864 | return true; |
||
| 7865 | } |
||
| 7866 | |||
| 7867 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 7868 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 7869 | << AL << St->getBeginLoc(); |
||
| 7870 | return false; |
||
| 7871 | } |
||
| 7872 | |||
| 7873 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 7874 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_enum, /*IsSupported=*/true)); |
||
| 7875 | } |
||
| 7876 | |||
| 7877 | bool isParamExpr(size_t N) const override { |
||
| 7878 | return false; |
||
| 7879 | } |
||
| 7880 | |||
| 7881 | static const ParsedAttrInfoNSErrorDomain Instance; |
||
| 7882 | }; |
||
| 7883 | const ParsedAttrInfoNSErrorDomain ParsedAttrInfoNSErrorDomain::Instance; |
||
| 7884 | static constexpr ParsedAttrInfo::Spelling NSReturnsAutoreleasedSpellings[] = { |
||
| 7885 | {AttributeCommonInfo::AS_GNU, "ns_returns_autoreleased"}, |
||
| 7886 | {AttributeCommonInfo::AS_CXX11, "clang::ns_returns_autoreleased"}, |
||
| 7887 | {AttributeCommonInfo::AS_C2x, "clang::ns_returns_autoreleased"}, |
||
| 7888 | }; |
||
| 7889 | struct ParsedAttrInfoNSReturnsAutoreleased final : public ParsedAttrInfo { |
||
| 7890 | constexpr ParsedAttrInfoNSReturnsAutoreleased() : ParsedAttrInfo( |
||
| 7891 | /*AttrKind=*/ParsedAttr::AT_NSReturnsAutoreleased, |
||
| 7892 | /*NumArgs=*/0, |
||
| 7893 | /*OptArgs=*/0, |
||
| 7894 | /*NumArgMembers=*/0, |
||
| 7895 | /*HasCustomParsing=*/0, |
||
| 7896 | /*AcceptsExprPack=*/0, |
||
| 7897 | /*IsTargetSpecific=*/0, |
||
| 7898 | /*IsType=*/0, |
||
| 7899 | /*IsStmt=*/0, |
||
| 7900 | /*IsKnownToGCC=*/0, |
||
| 7901 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 7902 | /*Spellings=*/NSReturnsAutoreleasedSpellings, |
||
| 7903 | /*ArgNames=*/{}) {} |
||
| 7904 | bool isParamExpr(size_t N) const override { |
||
| 7905 | return false; |
||
| 7906 | } |
||
| 7907 | |||
| 7908 | static const ParsedAttrInfoNSReturnsAutoreleased Instance; |
||
| 7909 | }; |
||
| 7910 | const ParsedAttrInfoNSReturnsAutoreleased ParsedAttrInfoNSReturnsAutoreleased::Instance; |
||
| 7911 | static constexpr ParsedAttrInfo::Spelling NSReturnsNotRetainedSpellings[] = { |
||
| 7912 | {AttributeCommonInfo::AS_GNU, "ns_returns_not_retained"}, |
||
| 7913 | {AttributeCommonInfo::AS_CXX11, "clang::ns_returns_not_retained"}, |
||
| 7914 | {AttributeCommonInfo::AS_C2x, "clang::ns_returns_not_retained"}, |
||
| 7915 | }; |
||
| 7916 | struct ParsedAttrInfoNSReturnsNotRetained final : public ParsedAttrInfo { |
||
| 7917 | constexpr ParsedAttrInfoNSReturnsNotRetained() : ParsedAttrInfo( |
||
| 7918 | /*AttrKind=*/ParsedAttr::AT_NSReturnsNotRetained, |
||
| 7919 | /*NumArgs=*/0, |
||
| 7920 | /*OptArgs=*/0, |
||
| 7921 | /*NumArgMembers=*/0, |
||
| 7922 | /*HasCustomParsing=*/0, |
||
| 7923 | /*AcceptsExprPack=*/0, |
||
| 7924 | /*IsTargetSpecific=*/0, |
||
| 7925 | /*IsType=*/0, |
||
| 7926 | /*IsStmt=*/0, |
||
| 7927 | /*IsKnownToGCC=*/0, |
||
| 7928 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 7929 | /*Spellings=*/NSReturnsNotRetainedSpellings, |
||
| 7930 | /*ArgNames=*/{}) {} |
||
| 7931 | bool isParamExpr(size_t N) const override { |
||
| 7932 | return false; |
||
| 7933 | } |
||
| 7934 | |||
| 7935 | static const ParsedAttrInfoNSReturnsNotRetained Instance; |
||
| 7936 | }; |
||
| 7937 | const ParsedAttrInfoNSReturnsNotRetained ParsedAttrInfoNSReturnsNotRetained::Instance; |
||
| 7938 | static constexpr ParsedAttrInfo::Spelling NSReturnsRetainedSpellings[] = { |
||
| 7939 | {AttributeCommonInfo::AS_GNU, "ns_returns_retained"}, |
||
| 7940 | {AttributeCommonInfo::AS_CXX11, "clang::ns_returns_retained"}, |
||
| 7941 | {AttributeCommonInfo::AS_C2x, "clang::ns_returns_retained"}, |
||
| 7942 | }; |
||
| 7943 | struct ParsedAttrInfoNSReturnsRetained final : public ParsedAttrInfo { |
||
| 7944 | constexpr ParsedAttrInfoNSReturnsRetained() : ParsedAttrInfo( |
||
| 7945 | /*AttrKind=*/ParsedAttr::AT_NSReturnsRetained, |
||
| 7946 | /*NumArgs=*/0, |
||
| 7947 | /*OptArgs=*/0, |
||
| 7948 | /*NumArgMembers=*/0, |
||
| 7949 | /*HasCustomParsing=*/0, |
||
| 7950 | /*AcceptsExprPack=*/0, |
||
| 7951 | /*IsTargetSpecific=*/0, |
||
| 7952 | /*IsType=*/1, |
||
| 7953 | /*IsStmt=*/0, |
||
| 7954 | /*IsKnownToGCC=*/0, |
||
| 7955 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 7956 | /*Spellings=*/NSReturnsRetainedSpellings, |
||
| 7957 | /*ArgNames=*/{}) {} |
||
| 7958 | bool isParamExpr(size_t N) const override { |
||
| 7959 | return false; |
||
| 7960 | } |
||
| 7961 | |||
| 7962 | static const ParsedAttrInfoNSReturnsRetained Instance; |
||
| 7963 | }; |
||
| 7964 | const ParsedAttrInfoNSReturnsRetained ParsedAttrInfoNSReturnsRetained::Instance; |
||
| 7965 | static constexpr ParsedAttrInfo::Spelling NakedSpellings[] = { |
||
| 7966 | {AttributeCommonInfo::AS_GNU, "naked"}, |
||
| 7967 | {AttributeCommonInfo::AS_CXX11, "gnu::naked"}, |
||
| 7968 | {AttributeCommonInfo::AS_C2x, "gnu::naked"}, |
||
| 7969 | {AttributeCommonInfo::AS_Declspec, "naked"}, |
||
| 7970 | }; |
||
| 7971 | struct ParsedAttrInfoNaked final : public ParsedAttrInfo { |
||
| 7972 | constexpr ParsedAttrInfoNaked() : ParsedAttrInfo( |
||
| 7973 | /*AttrKind=*/ParsedAttr::AT_Naked, |
||
| 7974 | /*NumArgs=*/0, |
||
| 7975 | /*OptArgs=*/0, |
||
| 7976 | /*NumArgMembers=*/0, |
||
| 7977 | /*HasCustomParsing=*/0, |
||
| 7978 | /*AcceptsExprPack=*/0, |
||
| 7979 | /*IsTargetSpecific=*/0, |
||
| 7980 | /*IsType=*/0, |
||
| 7981 | /*IsStmt=*/0, |
||
| 7982 | /*IsKnownToGCC=*/1, |
||
| 7983 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 7984 | /*Spellings=*/NakedSpellings, |
||
| 7985 | /*ArgNames=*/{}) {} |
||
| 7986 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 7987 | if (!isa<FunctionDecl>(D)) { |
||
| 7988 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 7989 | << Attr << "functions"; |
||
| 7990 | return false; |
||
| 7991 | } |
||
| 7992 | return true; |
||
| 7993 | } |
||
| 7994 | |||
| 7995 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 7996 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 7997 | << AL << St->getBeginLoc(); |
||
| 7998 | return false; |
||
| 7999 | } |
||
| 8000 | |||
| 8001 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 8002 | |||
| 8003 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 8004 | if (const auto *A = D->getAttr<DisableTailCallsAttr>()) { |
||
| 8005 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 8006 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 8007 | return false; |
||
| 8008 | } |
||
| 8009 | return true; |
||
| 8010 | } |
||
| 8011 | |||
| 8012 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 8013 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 8014 | } |
||
| 8015 | |||
| 8016 | bool isParamExpr(size_t N) const override { |
||
| 8017 | return false; |
||
| 8018 | } |
||
| 8019 | |||
| 8020 | static const ParsedAttrInfoNaked Instance; |
||
| 8021 | }; |
||
| 8022 | const ParsedAttrInfoNaked ParsedAttrInfoNaked::Instance; |
||
| 8023 | static constexpr ParsedAttrInfo::Spelling NeonPolyVectorTypeSpellings[] = { |
||
| 8024 | {AttributeCommonInfo::AS_GNU, "neon_polyvector_type"}, |
||
| 8025 | {AttributeCommonInfo::AS_CXX11, "clang::neon_polyvector_type"}, |
||
| 8026 | {AttributeCommonInfo::AS_C2x, "clang::neon_polyvector_type"}, |
||
| 8027 | }; |
||
| 8028 | static constexpr const char *NeonPolyVectorTypeArgNames[] = { |
||
| 8029 | "NumElements",}; |
||
| 8030 | struct ParsedAttrInfoNeonPolyVectorType final : public ParsedAttrInfo { |
||
| 8031 | constexpr ParsedAttrInfoNeonPolyVectorType() : ParsedAttrInfo( |
||
| 8032 | /*AttrKind=*/ParsedAttr::AT_NeonPolyVectorType, |
||
| 8033 | /*NumArgs=*/1, |
||
| 8034 | /*OptArgs=*/0, |
||
| 8035 | /*NumArgMembers=*/1, |
||
| 8036 | /*HasCustomParsing=*/0, |
||
| 8037 | /*AcceptsExprPack=*/0, |
||
| 8038 | /*IsTargetSpecific=*/0, |
||
| 8039 | /*IsType=*/1, |
||
| 8040 | /*IsStmt=*/0, |
||
| 8041 | /*IsKnownToGCC=*/0, |
||
| 8042 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 8043 | /*Spellings=*/NeonPolyVectorTypeSpellings, |
||
| 8044 | /*ArgNames=*/NeonPolyVectorTypeArgNames) {} |
||
| 8045 | bool isParamExpr(size_t N) const override { |
||
| 8046 | return false; |
||
| 8047 | } |
||
| 8048 | |||
| 8049 | static const ParsedAttrInfoNeonPolyVectorType Instance; |
||
| 8050 | }; |
||
| 8051 | const ParsedAttrInfoNeonPolyVectorType ParsedAttrInfoNeonPolyVectorType::Instance; |
||
| 8052 | static constexpr ParsedAttrInfo::Spelling NeonVectorTypeSpellings[] = { |
||
| 8053 | {AttributeCommonInfo::AS_GNU, "neon_vector_type"}, |
||
| 8054 | {AttributeCommonInfo::AS_CXX11, "clang::neon_vector_type"}, |
||
| 8055 | {AttributeCommonInfo::AS_C2x, "clang::neon_vector_type"}, |
||
| 8056 | }; |
||
| 8057 | static constexpr const char *NeonVectorTypeArgNames[] = { |
||
| 8058 | "NumElements",}; |
||
| 8059 | struct ParsedAttrInfoNeonVectorType final : public ParsedAttrInfo { |
||
| 8060 | constexpr ParsedAttrInfoNeonVectorType() : ParsedAttrInfo( |
||
| 8061 | /*AttrKind=*/ParsedAttr::AT_NeonVectorType, |
||
| 8062 | /*NumArgs=*/1, |
||
| 8063 | /*OptArgs=*/0, |
||
| 8064 | /*NumArgMembers=*/1, |
||
| 8065 | /*HasCustomParsing=*/0, |
||
| 8066 | /*AcceptsExprPack=*/0, |
||
| 8067 | /*IsTargetSpecific=*/0, |
||
| 8068 | /*IsType=*/1, |
||
| 8069 | /*IsStmt=*/0, |
||
| 8070 | /*IsKnownToGCC=*/0, |
||
| 8071 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 8072 | /*Spellings=*/NeonVectorTypeSpellings, |
||
| 8073 | /*ArgNames=*/NeonVectorTypeArgNames) {} |
||
| 8074 | bool isParamExpr(size_t N) const override { |
||
| 8075 | return false; |
||
| 8076 | } |
||
| 8077 | |||
| 8078 | static const ParsedAttrInfoNeonVectorType Instance; |
||
| 8079 | }; |
||
| 8080 | const ParsedAttrInfoNeonVectorType ParsedAttrInfoNeonVectorType::Instance; |
||
| 8081 | static constexpr ParsedAttrInfo::Spelling NoAliasSpellings[] = { |
||
| 8082 | {AttributeCommonInfo::AS_Declspec, "noalias"}, |
||
| 8083 | }; |
||
| 8084 | struct ParsedAttrInfoNoAlias final : public ParsedAttrInfo { |
||
| 8085 | constexpr ParsedAttrInfoNoAlias() : ParsedAttrInfo( |
||
| 8086 | /*AttrKind=*/ParsedAttr::AT_NoAlias, |
||
| 8087 | /*NumArgs=*/0, |
||
| 8088 | /*OptArgs=*/0, |
||
| 8089 | /*NumArgMembers=*/0, |
||
| 8090 | /*HasCustomParsing=*/0, |
||
| 8091 | /*AcceptsExprPack=*/0, |
||
| 8092 | /*IsTargetSpecific=*/0, |
||
| 8093 | /*IsType=*/0, |
||
| 8094 | /*IsStmt=*/0, |
||
| 8095 | /*IsKnownToGCC=*/0, |
||
| 8096 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 8097 | /*Spellings=*/NoAliasSpellings, |
||
| 8098 | /*ArgNames=*/{}) {} |
||
| 8099 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 8100 | if (!isa<FunctionDecl>(D)) { |
||
| 8101 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 8102 | << Attr << "functions"; |
||
| 8103 | return false; |
||
| 8104 | } |
||
| 8105 | return true; |
||
| 8106 | } |
||
| 8107 | |||
| 8108 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 8109 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 8110 | << AL << St->getBeginLoc(); |
||
| 8111 | return false; |
||
| 8112 | } |
||
| 8113 | |||
| 8114 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 8115 | D->addAttr(::new (S.Context) NoAliasAttr(S.Context, Attr)); |
||
| 8116 | return AttributeApplied; |
||
| 8117 | } |
||
| 8118 | |||
| 8119 | bool isParamExpr(size_t N) const override { |
||
| 8120 | return false; |
||
| 8121 | } |
||
| 8122 | |||
| 8123 | static const ParsedAttrInfoNoAlias Instance; |
||
| 8124 | }; |
||
| 8125 | const ParsedAttrInfoNoAlias ParsedAttrInfoNoAlias::Instance; |
||
| 8126 | static constexpr ParsedAttrInfo::Spelling NoBuiltinSpellings[] = { |
||
| 8127 | {AttributeCommonInfo::AS_GNU, "no_builtin"}, |
||
| 8128 | {AttributeCommonInfo::AS_CXX11, "clang::no_builtin"}, |
||
| 8129 | {AttributeCommonInfo::AS_C2x, "clang::no_builtin"}, |
||
| 8130 | }; |
||
| 8131 | static constexpr const char *NoBuiltinArgNames[] = { |
||
| 8132 | "BuiltinNames...",}; |
||
| 8133 | struct ParsedAttrInfoNoBuiltin final : public ParsedAttrInfo { |
||
| 8134 | constexpr ParsedAttrInfoNoBuiltin() : ParsedAttrInfo( |
||
| 8135 | /*AttrKind=*/ParsedAttr::AT_NoBuiltin, |
||
| 8136 | /*NumArgs=*/0, |
||
| 8137 | /*OptArgs=*/15, |
||
| 8138 | /*NumArgMembers=*/1, |
||
| 8139 | /*HasCustomParsing=*/0, |
||
| 8140 | /*AcceptsExprPack=*/0, |
||
| 8141 | /*IsTargetSpecific=*/0, |
||
| 8142 | /*IsType=*/0, |
||
| 8143 | /*IsStmt=*/0, |
||
| 8144 | /*IsKnownToGCC=*/0, |
||
| 8145 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 8146 | /*Spellings=*/NoBuiltinSpellings, |
||
| 8147 | /*ArgNames=*/NoBuiltinArgNames) {} |
||
| 8148 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 8149 | if (!isa<FunctionDecl>(D)) { |
||
| 8150 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 8151 | << Attr << "functions"; |
||
| 8152 | return false; |
||
| 8153 | } |
||
| 8154 | return true; |
||
| 8155 | } |
||
| 8156 | |||
| 8157 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 8158 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 8159 | << AL << St->getBeginLoc(); |
||
| 8160 | return false; |
||
| 8161 | } |
||
| 8162 | |||
| 8163 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 8164 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 8165 | } |
||
| 8166 | |||
| 8167 | bool isParamExpr(size_t N) const override { |
||
| 8168 | return false; |
||
| 8169 | } |
||
| 8170 | |||
| 8171 | static const ParsedAttrInfoNoBuiltin Instance; |
||
| 8172 | }; |
||
| 8173 | const ParsedAttrInfoNoBuiltin ParsedAttrInfoNoBuiltin::Instance; |
||
| 8174 | static constexpr ParsedAttrInfo::Spelling NoCommonSpellings[] = { |
||
| 8175 | {AttributeCommonInfo::AS_GNU, "nocommon"}, |
||
| 8176 | {AttributeCommonInfo::AS_CXX11, "gnu::nocommon"}, |
||
| 8177 | {AttributeCommonInfo::AS_C2x, "gnu::nocommon"}, |
||
| 8178 | }; |
||
| 8179 | struct ParsedAttrInfoNoCommon final : public ParsedAttrInfo { |
||
| 8180 | constexpr ParsedAttrInfoNoCommon() : ParsedAttrInfo( |
||
| 8181 | /*AttrKind=*/ParsedAttr::AT_NoCommon, |
||
| 8182 | /*NumArgs=*/0, |
||
| 8183 | /*OptArgs=*/0, |
||
| 8184 | /*NumArgMembers=*/0, |
||
| 8185 | /*HasCustomParsing=*/0, |
||
| 8186 | /*AcceptsExprPack=*/0, |
||
| 8187 | /*IsTargetSpecific=*/0, |
||
| 8188 | /*IsType=*/0, |
||
| 8189 | /*IsStmt=*/0, |
||
| 8190 | /*IsKnownToGCC=*/1, |
||
| 8191 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 8192 | /*Spellings=*/NoCommonSpellings, |
||
| 8193 | /*ArgNames=*/{}) {} |
||
| 8194 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 8195 | if (!isa<VarDecl>(D)) { |
||
| 8196 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 8197 | << Attr << "variables"; |
||
| 8198 | return false; |
||
| 8199 | } |
||
| 8200 | return true; |
||
| 8201 | } |
||
| 8202 | |||
| 8203 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 8204 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 8205 | << AL << St->getBeginLoc(); |
||
| 8206 | return false; |
||
| 8207 | } |
||
| 8208 | |||
| 8209 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 8210 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
||
| 8211 | } |
||
| 8212 | |||
| 8213 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 8214 | D->addAttr(::new (S.Context) NoCommonAttr(S.Context, Attr)); |
||
| 8215 | return AttributeApplied; |
||
| 8216 | } |
||
| 8217 | |||
| 8218 | bool isParamExpr(size_t N) const override { |
||
| 8219 | return false; |
||
| 8220 | } |
||
| 8221 | |||
| 8222 | static const ParsedAttrInfoNoCommon Instance; |
||
| 8223 | }; |
||
| 8224 | const ParsedAttrInfoNoCommon ParsedAttrInfoNoCommon::Instance; |
||
| 8225 | static constexpr ParsedAttrInfo::Spelling NoDebugSpellings[] = { |
||
| 8226 | {AttributeCommonInfo::AS_GNU, "nodebug"}, |
||
| 8227 | {AttributeCommonInfo::AS_CXX11, "gnu::nodebug"}, |
||
| 8228 | {AttributeCommonInfo::AS_C2x, "gnu::nodebug"}, |
||
| 8229 | }; |
||
| 8230 | struct ParsedAttrInfoNoDebug final : public ParsedAttrInfo { |
||
| 8231 | constexpr ParsedAttrInfoNoDebug() : ParsedAttrInfo( |
||
| 8232 | /*AttrKind=*/ParsedAttr::AT_NoDebug, |
||
| 8233 | /*NumArgs=*/0, |
||
| 8234 | /*OptArgs=*/0, |
||
| 8235 | /*NumArgMembers=*/0, |
||
| 8236 | /*HasCustomParsing=*/0, |
||
| 8237 | /*AcceptsExprPack=*/0, |
||
| 8238 | /*IsTargetSpecific=*/0, |
||
| 8239 | /*IsType=*/0, |
||
| 8240 | /*IsStmt=*/0, |
||
| 8241 | /*IsKnownToGCC=*/1, |
||
| 8242 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 8243 | /*Spellings=*/NoDebugSpellings, |
||
| 8244 | /*ArgNames=*/{}) {} |
||
| 8245 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 8246 | if (!isa<TypedefNameDecl>(D) && !isFunctionLike(D) && !isa<ObjCMethodDecl>(D) && !isNonParmVar(D)) { |
||
| 8247 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 8248 | << Attr << "typedefs, functions, function pointers, Objective-C methods, and variables"; |
||
| 8249 | return false; |
||
| 8250 | } |
||
| 8251 | return true; |
||
| 8252 | } |
||
| 8253 | |||
| 8254 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 8255 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 8256 | << AL << St->getBeginLoc(); |
||
| 8257 | return false; |
||
| 8258 | } |
||
| 8259 | |||
| 8260 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 8261 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true)); |
||
| 8262 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_hasType_functionType, /*IsSupported=*/true)); |
||
| 8263 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 8264 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_not_is_parameter, /*IsSupported=*/true)); |
||
| 8265 | } |
||
| 8266 | |||
| 8267 | bool isParamExpr(size_t N) const override { |
||
| 8268 | return false; |
||
| 8269 | } |
||
| 8270 | |||
| 8271 | static const ParsedAttrInfoNoDebug Instance; |
||
| 8272 | }; |
||
| 8273 | const ParsedAttrInfoNoDebug ParsedAttrInfoNoDebug::Instance; |
||
| 8274 | static constexpr ParsedAttrInfo::Spelling NoDerefSpellings[] = { |
||
| 8275 | {AttributeCommonInfo::AS_GNU, "noderef"}, |
||
| 8276 | {AttributeCommonInfo::AS_CXX11, "clang::noderef"}, |
||
| 8277 | {AttributeCommonInfo::AS_C2x, "clang::noderef"}, |
||
| 8278 | }; |
||
| 8279 | struct ParsedAttrInfoNoDeref final : public ParsedAttrInfo { |
||
| 8280 | constexpr ParsedAttrInfoNoDeref() : ParsedAttrInfo( |
||
| 8281 | /*AttrKind=*/ParsedAttr::AT_NoDeref, |
||
| 8282 | /*NumArgs=*/0, |
||
| 8283 | /*OptArgs=*/0, |
||
| 8284 | /*NumArgMembers=*/0, |
||
| 8285 | /*HasCustomParsing=*/0, |
||
| 8286 | /*AcceptsExprPack=*/0, |
||
| 8287 | /*IsTargetSpecific=*/0, |
||
| 8288 | /*IsType=*/1, |
||
| 8289 | /*IsStmt=*/0, |
||
| 8290 | /*IsKnownToGCC=*/0, |
||
| 8291 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 8292 | /*Spellings=*/NoDerefSpellings, |
||
| 8293 | /*ArgNames=*/{}) {} |
||
| 8294 | bool isParamExpr(size_t N) const override { |
||
| 8295 | return false; |
||
| 8296 | } |
||
| 8297 | |||
| 8298 | static const ParsedAttrInfoNoDeref Instance; |
||
| 8299 | }; |
||
| 8300 | const ParsedAttrInfoNoDeref ParsedAttrInfoNoDeref::Instance; |
||
| 8301 | static constexpr ParsedAttrInfo::Spelling NoDestroySpellings[] = { |
||
| 8302 | {AttributeCommonInfo::AS_GNU, "no_destroy"}, |
||
| 8303 | {AttributeCommonInfo::AS_CXX11, "clang::no_destroy"}, |
||
| 8304 | }; |
||
| 8305 | struct ParsedAttrInfoNoDestroy final : public ParsedAttrInfo { |
||
| 8306 | constexpr ParsedAttrInfoNoDestroy() : ParsedAttrInfo( |
||
| 8307 | /*AttrKind=*/ParsedAttr::AT_NoDestroy, |
||
| 8308 | /*NumArgs=*/0, |
||
| 8309 | /*OptArgs=*/0, |
||
| 8310 | /*NumArgMembers=*/0, |
||
| 8311 | /*HasCustomParsing=*/0, |
||
| 8312 | /*AcceptsExprPack=*/0, |
||
| 8313 | /*IsTargetSpecific=*/0, |
||
| 8314 | /*IsType=*/0, |
||
| 8315 | /*IsStmt=*/0, |
||
| 8316 | /*IsKnownToGCC=*/0, |
||
| 8317 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 8318 | /*Spellings=*/NoDestroySpellings, |
||
| 8319 | /*ArgNames=*/{}) {} |
||
| 8320 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 8321 | if (!isa<VarDecl>(D)) { |
||
| 8322 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 8323 | << Attr << "variables"; |
||
| 8324 | return false; |
||
| 8325 | } |
||
| 8326 | return true; |
||
| 8327 | } |
||
| 8328 | |||
| 8329 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 8330 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 8331 | << AL << St->getBeginLoc(); |
||
| 8332 | return false; |
||
| 8333 | } |
||
| 8334 | |||
| 8335 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 8336 | |||
| 8337 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 8338 | if (const auto *A = D->getAttr<AlwaysDestroyAttr>()) { |
||
| 8339 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 8340 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 8341 | return false; |
||
| 8342 | } |
||
| 8343 | return true; |
||
| 8344 | } |
||
| 8345 | |||
| 8346 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 8347 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
||
| 8348 | } |
||
| 8349 | |||
| 8350 | bool isParamExpr(size_t N) const override { |
||
| 8351 | return false; |
||
| 8352 | } |
||
| 8353 | |||
| 8354 | static const ParsedAttrInfoNoDestroy Instance; |
||
| 8355 | }; |
||
| 8356 | const ParsedAttrInfoNoDestroy ParsedAttrInfoNoDestroy::Instance; |
||
| 8357 | static constexpr ParsedAttrInfo::Spelling NoDuplicateSpellings[] = { |
||
| 8358 | {AttributeCommonInfo::AS_GNU, "noduplicate"}, |
||
| 8359 | {AttributeCommonInfo::AS_CXX11, "clang::noduplicate"}, |
||
| 8360 | {AttributeCommonInfo::AS_C2x, "clang::noduplicate"}, |
||
| 8361 | }; |
||
| 8362 | struct ParsedAttrInfoNoDuplicate final : public ParsedAttrInfo { |
||
| 8363 | constexpr ParsedAttrInfoNoDuplicate() : ParsedAttrInfo( |
||
| 8364 | /*AttrKind=*/ParsedAttr::AT_NoDuplicate, |
||
| 8365 | /*NumArgs=*/0, |
||
| 8366 | /*OptArgs=*/0, |
||
| 8367 | /*NumArgMembers=*/0, |
||
| 8368 | /*HasCustomParsing=*/0, |
||
| 8369 | /*AcceptsExprPack=*/0, |
||
| 8370 | /*IsTargetSpecific=*/0, |
||
| 8371 | /*IsType=*/0, |
||
| 8372 | /*IsStmt=*/0, |
||
| 8373 | /*IsKnownToGCC=*/0, |
||
| 8374 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 8375 | /*Spellings=*/NoDuplicateSpellings, |
||
| 8376 | /*ArgNames=*/{}) {} |
||
| 8377 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 8378 | if (!isa<FunctionDecl>(D)) { |
||
| 8379 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 8380 | << Attr << "functions"; |
||
| 8381 | return false; |
||
| 8382 | } |
||
| 8383 | return true; |
||
| 8384 | } |
||
| 8385 | |||
| 8386 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 8387 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 8388 | << AL << St->getBeginLoc(); |
||
| 8389 | return false; |
||
| 8390 | } |
||
| 8391 | |||
| 8392 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 8393 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 8394 | } |
||
| 8395 | |||
| 8396 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 8397 | D->addAttr(::new (S.Context) NoDuplicateAttr(S.Context, Attr)); |
||
| 8398 | return AttributeApplied; |
||
| 8399 | } |
||
| 8400 | |||
| 8401 | bool isParamExpr(size_t N) const override { |
||
| 8402 | return false; |
||
| 8403 | } |
||
| 8404 | |||
| 8405 | static const ParsedAttrInfoNoDuplicate Instance; |
||
| 8406 | }; |
||
| 8407 | const ParsedAttrInfoNoDuplicate ParsedAttrInfoNoDuplicate::Instance; |
||
| 8408 | static constexpr ParsedAttrInfo::Spelling NoEscapeSpellings[] = { |
||
| 8409 | {AttributeCommonInfo::AS_GNU, "noescape"}, |
||
| 8410 | {AttributeCommonInfo::AS_CXX11, "clang::noescape"}, |
||
| 8411 | {AttributeCommonInfo::AS_C2x, "clang::noescape"}, |
||
| 8412 | }; |
||
| 8413 | struct ParsedAttrInfoNoEscape final : public ParsedAttrInfo { |
||
| 8414 | constexpr ParsedAttrInfoNoEscape() : ParsedAttrInfo( |
||
| 8415 | /*AttrKind=*/ParsedAttr::AT_NoEscape, |
||
| 8416 | /*NumArgs=*/0, |
||
| 8417 | /*OptArgs=*/0, |
||
| 8418 | /*NumArgMembers=*/0, |
||
| 8419 | /*HasCustomParsing=*/0, |
||
| 8420 | /*AcceptsExprPack=*/0, |
||
| 8421 | /*IsTargetSpecific=*/0, |
||
| 8422 | /*IsType=*/0, |
||
| 8423 | /*IsStmt=*/0, |
||
| 8424 | /*IsKnownToGCC=*/0, |
||
| 8425 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 8426 | /*Spellings=*/NoEscapeSpellings, |
||
| 8427 | /*ArgNames=*/{}) {} |
||
| 8428 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 8429 | if (!isa<ParmVarDecl>(D)) { |
||
| 8430 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 8431 | << Attr << "parameters"; |
||
| 8432 | return false; |
||
| 8433 | } |
||
| 8434 | return true; |
||
| 8435 | } |
||
| 8436 | |||
| 8437 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 8438 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 8439 | << AL << St->getBeginLoc(); |
||
| 8440 | return false; |
||
| 8441 | } |
||
| 8442 | |||
| 8443 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 8444 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
||
| 8445 | } |
||
| 8446 | |||
| 8447 | bool isParamExpr(size_t N) const override { |
||
| 8448 | return false; |
||
| 8449 | } |
||
| 8450 | |||
| 8451 | static const ParsedAttrInfoNoEscape Instance; |
||
| 8452 | }; |
||
| 8453 | const ParsedAttrInfoNoEscape ParsedAttrInfoNoEscape::Instance; |
||
| 8454 | static constexpr ParsedAttrInfo::Spelling NoInlineSpellings[] = { |
||
| 8455 | {AttributeCommonInfo::AS_Keyword, "__noinline__"}, |
||
| 8456 | {AttributeCommonInfo::AS_GNU, "noinline"}, |
||
| 8457 | {AttributeCommonInfo::AS_CXX11, "gnu::noinline"}, |
||
| 8458 | {AttributeCommonInfo::AS_C2x, "gnu::noinline"}, |
||
| 8459 | {AttributeCommonInfo::AS_CXX11, "clang::noinline"}, |
||
| 8460 | {AttributeCommonInfo::AS_C2x, "clang::noinline"}, |
||
| 8461 | {AttributeCommonInfo::AS_Declspec, "noinline"}, |
||
| 8462 | }; |
||
| 8463 | struct ParsedAttrInfoNoInline final : public ParsedAttrInfo { |
||
| 8464 | constexpr ParsedAttrInfoNoInline() : ParsedAttrInfo( |
||
| 8465 | /*AttrKind=*/ParsedAttr::AT_NoInline, |
||
| 8466 | /*NumArgs=*/0, |
||
| 8467 | /*OptArgs=*/0, |
||
| 8468 | /*NumArgMembers=*/0, |
||
| 8469 | /*HasCustomParsing=*/0, |
||
| 8470 | /*AcceptsExprPack=*/0, |
||
| 8471 | /*IsTargetSpecific=*/0, |
||
| 8472 | /*IsType=*/0, |
||
| 8473 | /*IsStmt=*/1, |
||
| 8474 | /*IsKnownToGCC=*/1, |
||
| 8475 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 8476 | /*Spellings=*/NoInlineSpellings, |
||
| 8477 | /*ArgNames=*/{}) {} |
||
| 8478 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 8479 | if (!isa<FunctionDecl>(D)) { |
||
| 8480 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 8481 | << Attr << "functions and statements"; |
||
| 8482 | return false; |
||
| 8483 | } |
||
| 8484 | return true; |
||
| 8485 | } |
||
| 8486 | |||
| 8487 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &Attr, const Stmt *St) const override { |
||
| 8488 | if (!isa<Stmt>(St)) { |
||
| 8489 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 8490 | << Attr << "functions and statements"; |
||
| 8491 | return false; |
||
| 8492 | } |
||
| 8493 | return true; |
||
| 8494 | } |
||
| 8495 | |||
| 8496 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 8497 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 8498 | } |
||
| 8499 | |||
| 8500 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 8501 | D->addAttr(::new (S.Context) NoInlineAttr(S.Context, Attr)); |
||
| 8502 | return AttributeApplied; |
||
| 8503 | } |
||
| 8504 | |||
| 8505 | bool isParamExpr(size_t N) const override { |
||
| 8506 | return false; |
||
| 8507 | } |
||
| 8508 | |||
| 8509 | static const ParsedAttrInfoNoInline Instance; |
||
| 8510 | }; |
||
| 8511 | const ParsedAttrInfoNoInline ParsedAttrInfoNoInline::Instance; |
||
| 8512 | static constexpr ParsedAttrInfo::Spelling NoInstrumentFunctionSpellings[] = { |
||
| 8513 | {AttributeCommonInfo::AS_GNU, "no_instrument_function"}, |
||
| 8514 | {AttributeCommonInfo::AS_CXX11, "gnu::no_instrument_function"}, |
||
| 8515 | {AttributeCommonInfo::AS_C2x, "gnu::no_instrument_function"}, |
||
| 8516 | }; |
||
| 8517 | struct ParsedAttrInfoNoInstrumentFunction final : public ParsedAttrInfo { |
||
| 8518 | constexpr ParsedAttrInfoNoInstrumentFunction() : ParsedAttrInfo( |
||
| 8519 | /*AttrKind=*/ParsedAttr::AT_NoInstrumentFunction, |
||
| 8520 | /*NumArgs=*/0, |
||
| 8521 | /*OptArgs=*/0, |
||
| 8522 | /*NumArgMembers=*/0, |
||
| 8523 | /*HasCustomParsing=*/0, |
||
| 8524 | /*AcceptsExprPack=*/0, |
||
| 8525 | /*IsTargetSpecific=*/0, |
||
| 8526 | /*IsType=*/0, |
||
| 8527 | /*IsStmt=*/0, |
||
| 8528 | /*IsKnownToGCC=*/1, |
||
| 8529 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 8530 | /*Spellings=*/NoInstrumentFunctionSpellings, |
||
| 8531 | /*ArgNames=*/{}) {} |
||
| 8532 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 8533 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
||
| 8534 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 8535 | << Attr << "functions and Objective-C methods"; |
||
| 8536 | return false; |
||
| 8537 | } |
||
| 8538 | return true; |
||
| 8539 | } |
||
| 8540 | |||
| 8541 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 8542 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 8543 | << AL << St->getBeginLoc(); |
||
| 8544 | return false; |
||
| 8545 | } |
||
| 8546 | |||
| 8547 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 8548 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 8549 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 8550 | } |
||
| 8551 | |||
| 8552 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 8553 | D->addAttr(::new (S.Context) NoInstrumentFunctionAttr(S.Context, Attr)); |
||
| 8554 | return AttributeApplied; |
||
| 8555 | } |
||
| 8556 | |||
| 8557 | bool isParamExpr(size_t N) const override { |
||
| 8558 | return false; |
||
| 8559 | } |
||
| 8560 | |||
| 8561 | static const ParsedAttrInfoNoInstrumentFunction Instance; |
||
| 8562 | }; |
||
| 8563 | const ParsedAttrInfoNoInstrumentFunction ParsedAttrInfoNoInstrumentFunction::Instance; |
||
| 8564 | static constexpr ParsedAttrInfo::Spelling NoMergeSpellings[] = { |
||
| 8565 | {AttributeCommonInfo::AS_GNU, "nomerge"}, |
||
| 8566 | {AttributeCommonInfo::AS_CXX11, "clang::nomerge"}, |
||
| 8567 | {AttributeCommonInfo::AS_C2x, "clang::nomerge"}, |
||
| 8568 | }; |
||
| 8569 | struct ParsedAttrInfoNoMerge final : public ParsedAttrInfo { |
||
| 8570 | constexpr ParsedAttrInfoNoMerge() : ParsedAttrInfo( |
||
| 8571 | /*AttrKind=*/ParsedAttr::AT_NoMerge, |
||
| 8572 | /*NumArgs=*/0, |
||
| 8573 | /*OptArgs=*/0, |
||
| 8574 | /*NumArgMembers=*/0, |
||
| 8575 | /*HasCustomParsing=*/0, |
||
| 8576 | /*AcceptsExprPack=*/0, |
||
| 8577 | /*IsTargetSpecific=*/0, |
||
| 8578 | /*IsType=*/0, |
||
| 8579 | /*IsStmt=*/1, |
||
| 8580 | /*IsKnownToGCC=*/0, |
||
| 8581 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 8582 | /*Spellings=*/NoMergeSpellings, |
||
| 8583 | /*ArgNames=*/{}) {} |
||
| 8584 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 8585 | if (!isa<FunctionDecl>(D)) { |
||
| 8586 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 8587 | << Attr << "functions and statements"; |
||
| 8588 | return false; |
||
| 8589 | } |
||
| 8590 | return true; |
||
| 8591 | } |
||
| 8592 | |||
| 8593 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &Attr, const Stmt *St) const override { |
||
| 8594 | if (!isa<Stmt>(St)) { |
||
| 8595 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 8596 | << Attr << "functions and statements"; |
||
| 8597 | return false; |
||
| 8598 | } |
||
| 8599 | return true; |
||
| 8600 | } |
||
| 8601 | |||
| 8602 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 8603 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 8604 | } |
||
| 8605 | |||
| 8606 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 8607 | D->addAttr(::new (S.Context) NoMergeAttr(S.Context, Attr)); |
||
| 8608 | return AttributeApplied; |
||
| 8609 | } |
||
| 8610 | |||
| 8611 | bool isParamExpr(size_t N) const override { |
||
| 8612 | return false; |
||
| 8613 | } |
||
| 8614 | |||
| 8615 | static const ParsedAttrInfoNoMerge Instance; |
||
| 8616 | }; |
||
| 8617 | const ParsedAttrInfoNoMerge ParsedAttrInfoNoMerge::Instance; |
||
| 8618 | static constexpr ParsedAttrInfo::Spelling NoMicroMipsSpellings[] = { |
||
| 8619 | {AttributeCommonInfo::AS_GNU, "nomicromips"}, |
||
| 8620 | {AttributeCommonInfo::AS_CXX11, "gnu::nomicromips"}, |
||
| 8621 | {AttributeCommonInfo::AS_C2x, "gnu::nomicromips"}, |
||
| 8622 | }; |
||
| 8623 | struct ParsedAttrInfoNoMicroMips final : public ParsedAttrInfo { |
||
| 8624 | constexpr ParsedAttrInfoNoMicroMips() : ParsedAttrInfo( |
||
| 8625 | /*AttrKind=*/ParsedAttr::AT_NoMicroMips, |
||
| 8626 | /*NumArgs=*/0, |
||
| 8627 | /*OptArgs=*/0, |
||
| 8628 | /*NumArgMembers=*/0, |
||
| 8629 | /*HasCustomParsing=*/0, |
||
| 8630 | /*AcceptsExprPack=*/0, |
||
| 8631 | /*IsTargetSpecific=*/1, |
||
| 8632 | /*IsType=*/0, |
||
| 8633 | /*IsStmt=*/0, |
||
| 8634 | /*IsKnownToGCC=*/1, |
||
| 8635 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 8636 | /*Spellings=*/NoMicroMipsSpellings, |
||
| 8637 | /*ArgNames=*/{}) {} |
||
| 8638 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 8639 | if (!isa<FunctionDecl>(D)) { |
||
| 8640 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 8641 | << Attr << "functions"; |
||
| 8642 | return false; |
||
| 8643 | } |
||
| 8644 | return true; |
||
| 8645 | } |
||
| 8646 | |||
| 8647 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 8648 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 8649 | << AL << St->getBeginLoc(); |
||
| 8650 | return false; |
||
| 8651 | } |
||
| 8652 | |||
| 8653 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 8654 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 8655 | return true && (T.getArch() == llvm::Triple::mips || T.getArch() == llvm::Triple::mipsel); |
||
| 8656 | } |
||
| 8657 | |||
| 8658 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 8659 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 8660 | } |
||
| 8661 | |||
| 8662 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 8663 | D->addAttr(::new (S.Context) NoMicroMipsAttr(S.Context, Attr)); |
||
| 8664 | return AttributeApplied; |
||
| 8665 | } |
||
| 8666 | |||
| 8667 | bool isParamExpr(size_t N) const override { |
||
| 8668 | return false; |
||
| 8669 | } |
||
| 8670 | |||
| 8671 | static const ParsedAttrInfoNoMicroMips Instance; |
||
| 8672 | }; |
||
| 8673 | const ParsedAttrInfoNoMicroMips ParsedAttrInfoNoMicroMips::Instance; |
||
| 8674 | static constexpr ParsedAttrInfo::Spelling NoMips16Spellings[] = { |
||
| 8675 | {AttributeCommonInfo::AS_GNU, "nomips16"}, |
||
| 8676 | {AttributeCommonInfo::AS_CXX11, "gnu::nomips16"}, |
||
| 8677 | {AttributeCommonInfo::AS_C2x, "gnu::nomips16"}, |
||
| 8678 | }; |
||
| 8679 | struct ParsedAttrInfoNoMips16 final : public ParsedAttrInfo { |
||
| 8680 | constexpr ParsedAttrInfoNoMips16() : ParsedAttrInfo( |
||
| 8681 | /*AttrKind=*/ParsedAttr::AT_NoMips16, |
||
| 8682 | /*NumArgs=*/0, |
||
| 8683 | /*OptArgs=*/0, |
||
| 8684 | /*NumArgMembers=*/0, |
||
| 8685 | /*HasCustomParsing=*/0, |
||
| 8686 | /*AcceptsExprPack=*/0, |
||
| 8687 | /*IsTargetSpecific=*/1, |
||
| 8688 | /*IsType=*/0, |
||
| 8689 | /*IsStmt=*/0, |
||
| 8690 | /*IsKnownToGCC=*/1, |
||
| 8691 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 8692 | /*Spellings=*/NoMips16Spellings, |
||
| 8693 | /*ArgNames=*/{}) {} |
||
| 8694 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 8695 | if (!isa<FunctionDecl>(D)) { |
||
| 8696 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 8697 | << Attr << "functions"; |
||
| 8698 | return false; |
||
| 8699 | } |
||
| 8700 | return true; |
||
| 8701 | } |
||
| 8702 | |||
| 8703 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 8704 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 8705 | << AL << St->getBeginLoc(); |
||
| 8706 | return false; |
||
| 8707 | } |
||
| 8708 | |||
| 8709 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 8710 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 8711 | return true && (T.getArch() == llvm::Triple::mips || T.getArch() == llvm::Triple::mipsel); |
||
| 8712 | } |
||
| 8713 | |||
| 8714 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 8715 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 8716 | } |
||
| 8717 | |||
| 8718 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 8719 | D->addAttr(::new (S.Context) NoMips16Attr(S.Context, Attr)); |
||
| 8720 | return AttributeApplied; |
||
| 8721 | } |
||
| 8722 | |||
| 8723 | bool isParamExpr(size_t N) const override { |
||
| 8724 | return false; |
||
| 8725 | } |
||
| 8726 | |||
| 8727 | static const ParsedAttrInfoNoMips16 Instance; |
||
| 8728 | }; |
||
| 8729 | const ParsedAttrInfoNoMips16 ParsedAttrInfoNoMips16::Instance; |
||
| 8730 | static constexpr ParsedAttrInfo::Spelling NoProfileFunctionSpellings[] = { |
||
| 8731 | {AttributeCommonInfo::AS_GNU, "no_profile_instrument_function"}, |
||
| 8732 | {AttributeCommonInfo::AS_CXX11, "gnu::no_profile_instrument_function"}, |
||
| 8733 | {AttributeCommonInfo::AS_C2x, "gnu::no_profile_instrument_function"}, |
||
| 8734 | }; |
||
| 8735 | struct ParsedAttrInfoNoProfileFunction final : public ParsedAttrInfo { |
||
| 8736 | constexpr ParsedAttrInfoNoProfileFunction() : ParsedAttrInfo( |
||
| 8737 | /*AttrKind=*/ParsedAttr::AT_NoProfileFunction, |
||
| 8738 | /*NumArgs=*/0, |
||
| 8739 | /*OptArgs=*/0, |
||
| 8740 | /*NumArgMembers=*/0, |
||
| 8741 | /*HasCustomParsing=*/0, |
||
| 8742 | /*AcceptsExprPack=*/0, |
||
| 8743 | /*IsTargetSpecific=*/0, |
||
| 8744 | /*IsType=*/0, |
||
| 8745 | /*IsStmt=*/0, |
||
| 8746 | /*IsKnownToGCC=*/1, |
||
| 8747 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 8748 | /*Spellings=*/NoProfileFunctionSpellings, |
||
| 8749 | /*ArgNames=*/{}) {} |
||
| 8750 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 8751 | if (!isa<FunctionDecl>(D)) { |
||
| 8752 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 8753 | << Attr << "functions"; |
||
| 8754 | return false; |
||
| 8755 | } |
||
| 8756 | return true; |
||
| 8757 | } |
||
| 8758 | |||
| 8759 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 8760 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 8761 | << AL << St->getBeginLoc(); |
||
| 8762 | return false; |
||
| 8763 | } |
||
| 8764 | |||
| 8765 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 8766 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 8767 | } |
||
| 8768 | |||
| 8769 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 8770 | D->addAttr(::new (S.Context) NoProfileFunctionAttr(S.Context, Attr)); |
||
| 8771 | return AttributeApplied; |
||
| 8772 | } |
||
| 8773 | |||
| 8774 | bool isParamExpr(size_t N) const override { |
||
| 8775 | return false; |
||
| 8776 | } |
||
| 8777 | |||
| 8778 | static const ParsedAttrInfoNoProfileFunction Instance; |
||
| 8779 | }; |
||
| 8780 | const ParsedAttrInfoNoProfileFunction ParsedAttrInfoNoProfileFunction::Instance; |
||
| 8781 | static constexpr ParsedAttrInfo::Spelling NoRandomizeLayoutSpellings[] = { |
||
| 8782 | {AttributeCommonInfo::AS_GNU, "no_randomize_layout"}, |
||
| 8783 | {AttributeCommonInfo::AS_CXX11, "gnu::no_randomize_layout"}, |
||
| 8784 | {AttributeCommonInfo::AS_C2x, "gnu::no_randomize_layout"}, |
||
| 8785 | }; |
||
| 8786 | struct ParsedAttrInfoNoRandomizeLayout final : public ParsedAttrInfo { |
||
| 8787 | constexpr ParsedAttrInfoNoRandomizeLayout() : ParsedAttrInfo( |
||
| 8788 | /*AttrKind=*/ParsedAttr::AT_NoRandomizeLayout, |
||
| 8789 | /*NumArgs=*/0, |
||
| 8790 | /*OptArgs=*/0, |
||
| 8791 | /*NumArgMembers=*/0, |
||
| 8792 | /*HasCustomParsing=*/0, |
||
| 8793 | /*AcceptsExprPack=*/0, |
||
| 8794 | /*IsTargetSpecific=*/0, |
||
| 8795 | /*IsType=*/0, |
||
| 8796 | /*IsStmt=*/0, |
||
| 8797 | /*IsKnownToGCC=*/1, |
||
| 8798 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 8799 | /*Spellings=*/NoRandomizeLayoutSpellings, |
||
| 8800 | /*ArgNames=*/{}) {} |
||
| 8801 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 8802 | if (!isa<RecordDecl>(D)) { |
||
| 8803 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 8804 | << Attr << "structs, unions, and classes"; |
||
| 8805 | return false; |
||
| 8806 | } |
||
| 8807 | return true; |
||
| 8808 | } |
||
| 8809 | |||
| 8810 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 8811 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 8812 | << AL << St->getBeginLoc(); |
||
| 8813 | return false; |
||
| 8814 | } |
||
| 8815 | |||
| 8816 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 8817 | |||
| 8818 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 8819 | if (const auto *A = D->getAttr<RandomizeLayoutAttr>()) { |
||
| 8820 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 8821 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 8822 | return false; |
||
| 8823 | } |
||
| 8824 | return true; |
||
| 8825 | } |
||
| 8826 | |||
| 8827 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 8828 | return (!LangOpts.CPlusPlus); |
||
| 8829 | } |
||
| 8830 | |||
| 8831 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 8832 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 8833 | } |
||
| 8834 | |||
| 8835 | bool isParamExpr(size_t N) const override { |
||
| 8836 | return false; |
||
| 8837 | } |
||
| 8838 | |||
| 8839 | static const ParsedAttrInfoNoRandomizeLayout Instance; |
||
| 8840 | }; |
||
| 8841 | const ParsedAttrInfoNoRandomizeLayout ParsedAttrInfoNoRandomizeLayout::Instance; |
||
| 8842 | static constexpr ParsedAttrInfo::Spelling NoReturnSpellings[] = { |
||
| 8843 | {AttributeCommonInfo::AS_GNU, "noreturn"}, |
||
| 8844 | {AttributeCommonInfo::AS_CXX11, "gnu::noreturn"}, |
||
| 8845 | {AttributeCommonInfo::AS_C2x, "gnu::noreturn"}, |
||
| 8846 | {AttributeCommonInfo::AS_Declspec, "noreturn"}, |
||
| 8847 | }; |
||
| 8848 | struct ParsedAttrInfoNoReturn final : public ParsedAttrInfo { |
||
| 8849 | constexpr ParsedAttrInfoNoReturn() : ParsedAttrInfo( |
||
| 8850 | /*AttrKind=*/ParsedAttr::AT_NoReturn, |
||
| 8851 | /*NumArgs=*/0, |
||
| 8852 | /*OptArgs=*/0, |
||
| 8853 | /*NumArgMembers=*/0, |
||
| 8854 | /*HasCustomParsing=*/0, |
||
| 8855 | /*AcceptsExprPack=*/0, |
||
| 8856 | /*IsTargetSpecific=*/0, |
||
| 8857 | /*IsType=*/0, |
||
| 8858 | /*IsStmt=*/0, |
||
| 8859 | /*IsKnownToGCC=*/1, |
||
| 8860 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 8861 | /*Spellings=*/NoReturnSpellings, |
||
| 8862 | /*ArgNames=*/{}) {} |
||
| 8863 | bool isParamExpr(size_t N) const override { |
||
| 8864 | return false; |
||
| 8865 | } |
||
| 8866 | |||
| 8867 | static const ParsedAttrInfoNoReturn Instance; |
||
| 8868 | }; |
||
| 8869 | const ParsedAttrInfoNoReturn ParsedAttrInfoNoReturn::Instance; |
||
| 8870 | static constexpr ParsedAttrInfo::Spelling NoSanitizeSpellings[] = { |
||
| 8871 | {AttributeCommonInfo::AS_GNU, "no_sanitize"}, |
||
| 8872 | {AttributeCommonInfo::AS_CXX11, "clang::no_sanitize"}, |
||
| 8873 | {AttributeCommonInfo::AS_C2x, "clang::no_sanitize"}, |
||
| 8874 | }; |
||
| 8875 | static constexpr const char *NoSanitizeArgNames[] = { |
||
| 8876 | "Sanitizers...",}; |
||
| 8877 | struct ParsedAttrInfoNoSanitize final : public ParsedAttrInfo { |
||
| 8878 | constexpr ParsedAttrInfoNoSanitize() : ParsedAttrInfo( |
||
| 8879 | /*AttrKind=*/ParsedAttr::AT_NoSanitize, |
||
| 8880 | /*NumArgs=*/0, |
||
| 8881 | /*OptArgs=*/15, |
||
| 8882 | /*NumArgMembers=*/1, |
||
| 8883 | /*HasCustomParsing=*/0, |
||
| 8884 | /*AcceptsExprPack=*/0, |
||
| 8885 | /*IsTargetSpecific=*/0, |
||
| 8886 | /*IsType=*/0, |
||
| 8887 | /*IsStmt=*/0, |
||
| 8888 | /*IsKnownToGCC=*/0, |
||
| 8889 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 8890 | /*Spellings=*/NoSanitizeSpellings, |
||
| 8891 | /*ArgNames=*/NoSanitizeArgNames) {} |
||
| 8892 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 8893 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D) && !isGlobalVar(D)) { |
||
| 8894 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 8895 | << Attr << "functions, Objective-C methods, and global variables"; |
||
| 8896 | return false; |
||
| 8897 | } |
||
| 8898 | return true; |
||
| 8899 | } |
||
| 8900 | |||
| 8901 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 8902 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 8903 | << AL << St->getBeginLoc(); |
||
| 8904 | return false; |
||
| 8905 | } |
||
| 8906 | |||
| 8907 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 8908 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 8909 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 8910 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_global, /*IsSupported=*/true)); |
||
| 8911 | } |
||
| 8912 | |||
| 8913 | bool isParamExpr(size_t N) const override { |
||
| 8914 | return false; |
||
| 8915 | } |
||
| 8916 | |||
| 8917 | static const ParsedAttrInfoNoSanitize Instance; |
||
| 8918 | }; |
||
| 8919 | const ParsedAttrInfoNoSanitize ParsedAttrInfoNoSanitize::Instance; |
||
| 8920 | static constexpr ParsedAttrInfo::Spelling NoSanitizeSpecificSpellings[] = { |
||
| 8921 | {AttributeCommonInfo::AS_GNU, "no_address_safety_analysis"}, |
||
| 8922 | {AttributeCommonInfo::AS_CXX11, "gnu::no_address_safety_analysis"}, |
||
| 8923 | {AttributeCommonInfo::AS_C2x, "gnu::no_address_safety_analysis"}, |
||
| 8924 | {AttributeCommonInfo::AS_GNU, "no_sanitize_address"}, |
||
| 8925 | {AttributeCommonInfo::AS_CXX11, "gnu::no_sanitize_address"}, |
||
| 8926 | {AttributeCommonInfo::AS_C2x, "gnu::no_sanitize_address"}, |
||
| 8927 | {AttributeCommonInfo::AS_GNU, "no_sanitize_thread"}, |
||
| 8928 | {AttributeCommonInfo::AS_CXX11, "gnu::no_sanitize_thread"}, |
||
| 8929 | {AttributeCommonInfo::AS_C2x, "gnu::no_sanitize_thread"}, |
||
| 8930 | {AttributeCommonInfo::AS_GNU, "no_sanitize_memory"}, |
||
| 8931 | {AttributeCommonInfo::AS_CXX11, "clang::no_sanitize_memory"}, |
||
| 8932 | {AttributeCommonInfo::AS_C2x, "clang::no_sanitize_memory"}, |
||
| 8933 | }; |
||
| 8934 | struct ParsedAttrInfoNoSanitizeSpecific final : public ParsedAttrInfo { |
||
| 8935 | constexpr ParsedAttrInfoNoSanitizeSpecific() : ParsedAttrInfo( |
||
| 8936 | /*AttrKind=*/ParsedAttr::AT_NoSanitizeSpecific, |
||
| 8937 | /*NumArgs=*/0, |
||
| 8938 | /*OptArgs=*/0, |
||
| 8939 | /*NumArgMembers=*/0, |
||
| 8940 | /*HasCustomParsing=*/0, |
||
| 8941 | /*AcceptsExprPack=*/0, |
||
| 8942 | /*IsTargetSpecific=*/0, |
||
| 8943 | /*IsType=*/0, |
||
| 8944 | /*IsStmt=*/0, |
||
| 8945 | /*IsKnownToGCC=*/1, |
||
| 8946 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 8947 | /*Spellings=*/NoSanitizeSpecificSpellings, |
||
| 8948 | /*ArgNames=*/{}) {} |
||
| 8949 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 8950 | if (!isa<FunctionDecl>(D) && !isGlobalVar(D)) { |
||
| 8951 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 8952 | << Attr << "functions and global variables"; |
||
| 8953 | return false; |
||
| 8954 | } |
||
| 8955 | return true; |
||
| 8956 | } |
||
| 8957 | |||
| 8958 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 8959 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 8960 | << AL << St->getBeginLoc(); |
||
| 8961 | return false; |
||
| 8962 | } |
||
| 8963 | |||
| 8964 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 8965 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 8966 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_global, /*IsSupported=*/true)); |
||
| 8967 | } |
||
| 8968 | |||
| 8969 | bool isParamExpr(size_t N) const override { |
||
| 8970 | return false; |
||
| 8971 | } |
||
| 8972 | |||
| 8973 | static const ParsedAttrInfoNoSanitizeSpecific Instance; |
||
| 8974 | }; |
||
| 8975 | const ParsedAttrInfoNoSanitizeSpecific ParsedAttrInfoNoSanitizeSpecific::Instance; |
||
| 8976 | static constexpr ParsedAttrInfo::Spelling NoSpeculativeLoadHardeningSpellings[] = { |
||
| 8977 | {AttributeCommonInfo::AS_GNU, "no_speculative_load_hardening"}, |
||
| 8978 | {AttributeCommonInfo::AS_CXX11, "clang::no_speculative_load_hardening"}, |
||
| 8979 | {AttributeCommonInfo::AS_C2x, "clang::no_speculative_load_hardening"}, |
||
| 8980 | }; |
||
| 8981 | struct ParsedAttrInfoNoSpeculativeLoadHardening final : public ParsedAttrInfo { |
||
| 8982 | constexpr ParsedAttrInfoNoSpeculativeLoadHardening() : ParsedAttrInfo( |
||
| 8983 | /*AttrKind=*/ParsedAttr::AT_NoSpeculativeLoadHardening, |
||
| 8984 | /*NumArgs=*/0, |
||
| 8985 | /*OptArgs=*/0, |
||
| 8986 | /*NumArgMembers=*/0, |
||
| 8987 | /*HasCustomParsing=*/0, |
||
| 8988 | /*AcceptsExprPack=*/0, |
||
| 8989 | /*IsTargetSpecific=*/0, |
||
| 8990 | /*IsType=*/0, |
||
| 8991 | /*IsStmt=*/0, |
||
| 8992 | /*IsKnownToGCC=*/0, |
||
| 8993 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 8994 | /*Spellings=*/NoSpeculativeLoadHardeningSpellings, |
||
| 8995 | /*ArgNames=*/{}) {} |
||
| 8996 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 8997 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
||
| 8998 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 8999 | << Attr << "functions and Objective-C methods"; |
||
| 9000 | return false; |
||
| 9001 | } |
||
| 9002 | return true; |
||
| 9003 | } |
||
| 9004 | |||
| 9005 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 9006 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 9007 | << AL << St->getBeginLoc(); |
||
| 9008 | return false; |
||
| 9009 | } |
||
| 9010 | |||
| 9011 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 9012 | |||
| 9013 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 9014 | if (const auto *A = D->getAttr<SpeculativeLoadHardeningAttr>()) { |
||
| 9015 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 9016 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 9017 | return false; |
||
| 9018 | } |
||
| 9019 | return true; |
||
| 9020 | } |
||
| 9021 | |||
| 9022 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 9023 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 9024 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 9025 | } |
||
| 9026 | |||
| 9027 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 9028 | D->addAttr(::new (S.Context) NoSpeculativeLoadHardeningAttr(S.Context, Attr)); |
||
| 9029 | return AttributeApplied; |
||
| 9030 | } |
||
| 9031 | |||
| 9032 | bool isParamExpr(size_t N) const override { |
||
| 9033 | return false; |
||
| 9034 | } |
||
| 9035 | |||
| 9036 | static const ParsedAttrInfoNoSpeculativeLoadHardening Instance; |
||
| 9037 | }; |
||
| 9038 | const ParsedAttrInfoNoSpeculativeLoadHardening ParsedAttrInfoNoSpeculativeLoadHardening::Instance; |
||
| 9039 | static constexpr ParsedAttrInfo::Spelling NoSplitStackSpellings[] = { |
||
| 9040 | {AttributeCommonInfo::AS_GNU, "no_split_stack"}, |
||
| 9041 | {AttributeCommonInfo::AS_CXX11, "gnu::no_split_stack"}, |
||
| 9042 | {AttributeCommonInfo::AS_C2x, "gnu::no_split_stack"}, |
||
| 9043 | }; |
||
| 9044 | struct ParsedAttrInfoNoSplitStack final : public ParsedAttrInfo { |
||
| 9045 | constexpr ParsedAttrInfoNoSplitStack() : ParsedAttrInfo( |
||
| 9046 | /*AttrKind=*/ParsedAttr::AT_NoSplitStack, |
||
| 9047 | /*NumArgs=*/0, |
||
| 9048 | /*OptArgs=*/0, |
||
| 9049 | /*NumArgMembers=*/0, |
||
| 9050 | /*HasCustomParsing=*/0, |
||
| 9051 | /*AcceptsExprPack=*/0, |
||
| 9052 | /*IsTargetSpecific=*/0, |
||
| 9053 | /*IsType=*/0, |
||
| 9054 | /*IsStmt=*/0, |
||
| 9055 | /*IsKnownToGCC=*/1, |
||
| 9056 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 9057 | /*Spellings=*/NoSplitStackSpellings, |
||
| 9058 | /*ArgNames=*/{}) {} |
||
| 9059 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 9060 | if (!isa<FunctionDecl>(D)) { |
||
| 9061 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 9062 | << Attr << "functions"; |
||
| 9063 | return false; |
||
| 9064 | } |
||
| 9065 | return true; |
||
| 9066 | } |
||
| 9067 | |||
| 9068 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 9069 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 9070 | << AL << St->getBeginLoc(); |
||
| 9071 | return false; |
||
| 9072 | } |
||
| 9073 | |||
| 9074 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 9075 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 9076 | } |
||
| 9077 | |||
| 9078 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 9079 | D->addAttr(::new (S.Context) NoSplitStackAttr(S.Context, Attr)); |
||
| 9080 | return AttributeApplied; |
||
| 9081 | } |
||
| 9082 | |||
| 9083 | bool isParamExpr(size_t N) const override { |
||
| 9084 | return false; |
||
| 9085 | } |
||
| 9086 | |||
| 9087 | static const ParsedAttrInfoNoSplitStack Instance; |
||
| 9088 | }; |
||
| 9089 | const ParsedAttrInfoNoSplitStack ParsedAttrInfoNoSplitStack::Instance; |
||
| 9090 | static constexpr ParsedAttrInfo::Spelling NoStackProtectorSpellings[] = { |
||
| 9091 | {AttributeCommonInfo::AS_GNU, "no_stack_protector"}, |
||
| 9092 | {AttributeCommonInfo::AS_CXX11, "clang::no_stack_protector"}, |
||
| 9093 | {AttributeCommonInfo::AS_C2x, "clang::no_stack_protector"}, |
||
| 9094 | {AttributeCommonInfo::AS_Declspec, "safebuffers"}, |
||
| 9095 | }; |
||
| 9096 | struct ParsedAttrInfoNoStackProtector final : public ParsedAttrInfo { |
||
| 9097 | constexpr ParsedAttrInfoNoStackProtector() : ParsedAttrInfo( |
||
| 9098 | /*AttrKind=*/ParsedAttr::AT_NoStackProtector, |
||
| 9099 | /*NumArgs=*/0, |
||
| 9100 | /*OptArgs=*/0, |
||
| 9101 | /*NumArgMembers=*/0, |
||
| 9102 | /*HasCustomParsing=*/0, |
||
| 9103 | /*AcceptsExprPack=*/0, |
||
| 9104 | /*IsTargetSpecific=*/0, |
||
| 9105 | /*IsType=*/0, |
||
| 9106 | /*IsStmt=*/0, |
||
| 9107 | /*IsKnownToGCC=*/0, |
||
| 9108 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 9109 | /*Spellings=*/NoStackProtectorSpellings, |
||
| 9110 | /*ArgNames=*/{}) {} |
||
| 9111 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 9112 | if (!isa<FunctionDecl>(D)) { |
||
| 9113 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 9114 | << Attr << "functions"; |
||
| 9115 | return false; |
||
| 9116 | } |
||
| 9117 | return true; |
||
| 9118 | } |
||
| 9119 | |||
| 9120 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 9121 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 9122 | << AL << St->getBeginLoc(); |
||
| 9123 | return false; |
||
| 9124 | } |
||
| 9125 | |||
| 9126 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 9127 | enum Spelling { |
||
| 9128 | GNU_no_stack_protector = 0, |
||
| 9129 | CXX11_clang_no_stack_protector = 1, |
||
| 9130 | C2x_clang_no_stack_protector = 2, |
||
| 9131 | Declspec_safebuffers = 3, |
||
| 9132 | SpellingNotCalculated = 15 |
||
| 9133 | |||
| 9134 | }; |
||
| 9135 | |||
| 9136 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 9137 | switch (Idx) { |
||
| 9138 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 9139 | case 0: return GNU_no_stack_protector; |
||
| 9140 | case 1: return CXX11_clang_no_stack_protector; |
||
| 9141 | case 2: return C2x_clang_no_stack_protector; |
||
| 9142 | case 3: return Declspec_safebuffers; |
||
| 9143 | } |
||
| 9144 | } |
||
| 9145 | |||
| 9146 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 9147 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 9148 | } |
||
| 9149 | |||
| 9150 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 9151 | D->addAttr(::new (S.Context) NoStackProtectorAttr(S.Context, Attr)); |
||
| 9152 | return AttributeApplied; |
||
| 9153 | } |
||
| 9154 | |||
| 9155 | bool isParamExpr(size_t N) const override { |
||
| 9156 | return false; |
||
| 9157 | } |
||
| 9158 | |||
| 9159 | static const ParsedAttrInfoNoStackProtector Instance; |
||
| 9160 | }; |
||
| 9161 | const ParsedAttrInfoNoStackProtector ParsedAttrInfoNoStackProtector::Instance; |
||
| 9162 | static constexpr ParsedAttrInfo::Spelling NoThreadSafetyAnalysisSpellings[] = { |
||
| 9163 | {AttributeCommonInfo::AS_GNU, "no_thread_safety_analysis"}, |
||
| 9164 | {AttributeCommonInfo::AS_CXX11, "clang::no_thread_safety_analysis"}, |
||
| 9165 | {AttributeCommonInfo::AS_C2x, "clang::no_thread_safety_analysis"}, |
||
| 9166 | }; |
||
| 9167 | struct ParsedAttrInfoNoThreadSafetyAnalysis final : public ParsedAttrInfo { |
||
| 9168 | constexpr ParsedAttrInfoNoThreadSafetyAnalysis() : ParsedAttrInfo( |
||
| 9169 | /*AttrKind=*/ParsedAttr::AT_NoThreadSafetyAnalysis, |
||
| 9170 | /*NumArgs=*/0, |
||
| 9171 | /*OptArgs=*/0, |
||
| 9172 | /*NumArgMembers=*/0, |
||
| 9173 | /*HasCustomParsing=*/0, |
||
| 9174 | /*AcceptsExprPack=*/0, |
||
| 9175 | /*IsTargetSpecific=*/0, |
||
| 9176 | /*IsType=*/0, |
||
| 9177 | /*IsStmt=*/0, |
||
| 9178 | /*IsKnownToGCC=*/0, |
||
| 9179 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 9180 | /*Spellings=*/NoThreadSafetyAnalysisSpellings, |
||
| 9181 | /*ArgNames=*/{}) {} |
||
| 9182 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 9183 | if (!isa<FunctionDecl>(D)) { |
||
| 9184 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 9185 | << Attr << "functions"; |
||
| 9186 | return false; |
||
| 9187 | } |
||
| 9188 | return true; |
||
| 9189 | } |
||
| 9190 | |||
| 9191 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 9192 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 9193 | << AL << St->getBeginLoc(); |
||
| 9194 | return false; |
||
| 9195 | } |
||
| 9196 | |||
| 9197 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 9198 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 9199 | } |
||
| 9200 | |||
| 9201 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 9202 | D->addAttr(::new (S.Context) NoThreadSafetyAnalysisAttr(S.Context, Attr)); |
||
| 9203 | return AttributeApplied; |
||
| 9204 | } |
||
| 9205 | |||
| 9206 | bool isParamExpr(size_t N) const override { |
||
| 9207 | return false; |
||
| 9208 | } |
||
| 9209 | |||
| 9210 | static const ParsedAttrInfoNoThreadSafetyAnalysis Instance; |
||
| 9211 | }; |
||
| 9212 | const ParsedAttrInfoNoThreadSafetyAnalysis ParsedAttrInfoNoThreadSafetyAnalysis::Instance; |
||
| 9213 | static constexpr ParsedAttrInfo::Spelling NoThrowSpellings[] = { |
||
| 9214 | {AttributeCommonInfo::AS_GNU, "nothrow"}, |
||
| 9215 | {AttributeCommonInfo::AS_CXX11, "gnu::nothrow"}, |
||
| 9216 | {AttributeCommonInfo::AS_C2x, "gnu::nothrow"}, |
||
| 9217 | {AttributeCommonInfo::AS_Declspec, "nothrow"}, |
||
| 9218 | }; |
||
| 9219 | struct ParsedAttrInfoNoThrow final : public ParsedAttrInfo { |
||
| 9220 | constexpr ParsedAttrInfoNoThrow() : ParsedAttrInfo( |
||
| 9221 | /*AttrKind=*/ParsedAttr::AT_NoThrow, |
||
| 9222 | /*NumArgs=*/0, |
||
| 9223 | /*OptArgs=*/0, |
||
| 9224 | /*NumArgMembers=*/0, |
||
| 9225 | /*HasCustomParsing=*/0, |
||
| 9226 | /*AcceptsExprPack=*/0, |
||
| 9227 | /*IsTargetSpecific=*/0, |
||
| 9228 | /*IsType=*/0, |
||
| 9229 | /*IsStmt=*/0, |
||
| 9230 | /*IsKnownToGCC=*/1, |
||
| 9231 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 9232 | /*Spellings=*/NoThrowSpellings, |
||
| 9233 | /*ArgNames=*/{}) {} |
||
| 9234 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 9235 | if (!isFunctionLike(D)) { |
||
| 9236 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 9237 | << Attr << "functions and function pointers"; |
||
| 9238 | return false; |
||
| 9239 | } |
||
| 9240 | return true; |
||
| 9241 | } |
||
| 9242 | |||
| 9243 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 9244 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 9245 | << AL << St->getBeginLoc(); |
||
| 9246 | return false; |
||
| 9247 | } |
||
| 9248 | |||
| 9249 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 9250 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_hasType_functionType, /*IsSupported=*/true)); |
||
| 9251 | } |
||
| 9252 | |||
| 9253 | bool isParamExpr(size_t N) const override { |
||
| 9254 | return false; |
||
| 9255 | } |
||
| 9256 | |||
| 9257 | static const ParsedAttrInfoNoThrow Instance; |
||
| 9258 | }; |
||
| 9259 | const ParsedAttrInfoNoThrow ParsedAttrInfoNoThrow::Instance; |
||
| 9260 | static constexpr ParsedAttrInfo::Spelling NoUniqueAddressSpellings[] = { |
||
| 9261 | {AttributeCommonInfo::AS_CXX11, "no_unique_address"}, |
||
| 9262 | }; |
||
| 9263 | struct ParsedAttrInfoNoUniqueAddress final : public ParsedAttrInfo { |
||
| 9264 | constexpr ParsedAttrInfoNoUniqueAddress() : ParsedAttrInfo( |
||
| 9265 | /*AttrKind=*/ParsedAttr::AT_NoUniqueAddress, |
||
| 9266 | /*NumArgs=*/0, |
||
| 9267 | /*OptArgs=*/0, |
||
| 9268 | /*NumArgMembers=*/0, |
||
| 9269 | /*HasCustomParsing=*/0, |
||
| 9270 | /*AcceptsExprPack=*/0, |
||
| 9271 | /*IsTargetSpecific=*/1, |
||
| 9272 | /*IsType=*/0, |
||
| 9273 | /*IsStmt=*/0, |
||
| 9274 | /*IsKnownToGCC=*/0, |
||
| 9275 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 9276 | /*Spellings=*/NoUniqueAddressSpellings, |
||
| 9277 | /*ArgNames=*/{}) {} |
||
| 9278 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 9279 | if (!isNonBitField(D)) { |
||
| 9280 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 9281 | << Attr << "non-bit-field non-static data members"; |
||
| 9282 | return false; |
||
| 9283 | } |
||
| 9284 | return true; |
||
| 9285 | } |
||
| 9286 | |||
| 9287 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 9288 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 9289 | << AL << St->getBeginLoc(); |
||
| 9290 | return false; |
||
| 9291 | } |
||
| 9292 | |||
| 9293 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 9294 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 9295 | return true && ( Target.getCXXABI().isItaniumFamily() ); |
||
| 9296 | } |
||
| 9297 | |||
| 9298 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 9299 | D->addAttr(::new (S.Context) NoUniqueAddressAttr(S.Context, Attr)); |
||
| 9300 | return AttributeApplied; |
||
| 9301 | } |
||
| 9302 | |||
| 9303 | bool isParamExpr(size_t N) const override { |
||
| 9304 | return false; |
||
| 9305 | } |
||
| 9306 | |||
| 9307 | static const ParsedAttrInfoNoUniqueAddress Instance; |
||
| 9308 | }; |
||
| 9309 | const ParsedAttrInfoNoUniqueAddress ParsedAttrInfoNoUniqueAddress::Instance; |
||
| 9310 | static constexpr ParsedAttrInfo::Spelling NoUwtableSpellings[] = { |
||
| 9311 | {AttributeCommonInfo::AS_GNU, "nouwtable"}, |
||
| 9312 | {AttributeCommonInfo::AS_CXX11, "clang::nouwtable"}, |
||
| 9313 | {AttributeCommonInfo::AS_C2x, "clang::nouwtable"}, |
||
| 9314 | }; |
||
| 9315 | struct ParsedAttrInfoNoUwtable final : public ParsedAttrInfo { |
||
| 9316 | constexpr ParsedAttrInfoNoUwtable() : ParsedAttrInfo( |
||
| 9317 | /*AttrKind=*/ParsedAttr::AT_NoUwtable, |
||
| 9318 | /*NumArgs=*/0, |
||
| 9319 | /*OptArgs=*/0, |
||
| 9320 | /*NumArgMembers=*/0, |
||
| 9321 | /*HasCustomParsing=*/0, |
||
| 9322 | /*AcceptsExprPack=*/0, |
||
| 9323 | /*IsTargetSpecific=*/0, |
||
| 9324 | /*IsType=*/0, |
||
| 9325 | /*IsStmt=*/0, |
||
| 9326 | /*IsKnownToGCC=*/0, |
||
| 9327 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 9328 | /*Spellings=*/NoUwtableSpellings, |
||
| 9329 | /*ArgNames=*/{}) {} |
||
| 9330 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 9331 | if (!isFunctionLike(D)) { |
||
| 9332 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 9333 | << Attr << "functions and function pointers"; |
||
| 9334 | return false; |
||
| 9335 | } |
||
| 9336 | return true; |
||
| 9337 | } |
||
| 9338 | |||
| 9339 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 9340 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 9341 | << AL << St->getBeginLoc(); |
||
| 9342 | return false; |
||
| 9343 | } |
||
| 9344 | |||
| 9345 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 9346 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_hasType_functionType, /*IsSupported=*/true)); |
||
| 9347 | } |
||
| 9348 | |||
| 9349 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 9350 | D->addAttr(::new (S.Context) NoUwtableAttr(S.Context, Attr)); |
||
| 9351 | return AttributeApplied; |
||
| 9352 | } |
||
| 9353 | |||
| 9354 | bool isParamExpr(size_t N) const override { |
||
| 9355 | return false; |
||
| 9356 | } |
||
| 9357 | |||
| 9358 | static const ParsedAttrInfoNoUwtable Instance; |
||
| 9359 | }; |
||
| 9360 | const ParsedAttrInfoNoUwtable ParsedAttrInfoNoUwtable::Instance; |
||
| 9361 | static constexpr ParsedAttrInfo::Spelling NonNullSpellings[] = { |
||
| 9362 | {AttributeCommonInfo::AS_GNU, "nonnull"}, |
||
| 9363 | {AttributeCommonInfo::AS_CXX11, "gnu::nonnull"}, |
||
| 9364 | {AttributeCommonInfo::AS_C2x, "gnu::nonnull"}, |
||
| 9365 | }; |
||
| 9366 | static constexpr const char *NonNullArgNames[] = { |
||
| 9367 | "Args...",}; |
||
| 9368 | struct ParsedAttrInfoNonNull final : public ParsedAttrInfo { |
||
| 9369 | constexpr ParsedAttrInfoNonNull() : ParsedAttrInfo( |
||
| 9370 | /*AttrKind=*/ParsedAttr::AT_NonNull, |
||
| 9371 | /*NumArgs=*/0, |
||
| 9372 | /*OptArgs=*/15, |
||
| 9373 | /*NumArgMembers=*/1, |
||
| 9374 | /*HasCustomParsing=*/0, |
||
| 9375 | /*AcceptsExprPack=*/0, |
||
| 9376 | /*IsTargetSpecific=*/0, |
||
| 9377 | /*IsType=*/0, |
||
| 9378 | /*IsStmt=*/0, |
||
| 9379 | /*IsKnownToGCC=*/1, |
||
| 9380 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 9381 | /*Spellings=*/NonNullSpellings, |
||
| 9382 | /*ArgNames=*/NonNullArgNames) {} |
||
| 9383 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 9384 | if (!isa<ObjCMethodDecl>(D) && !isHasFunctionProto(D) && !isa<ParmVarDecl>(D)) { |
||
| 9385 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 9386 | << Attr << "functions, methods, and parameters"; |
||
| 9387 | return false; |
||
| 9388 | } |
||
| 9389 | return true; |
||
| 9390 | } |
||
| 9391 | |||
| 9392 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 9393 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 9394 | << AL << St->getBeginLoc(); |
||
| 9395 | return false; |
||
| 9396 | } |
||
| 9397 | |||
| 9398 | bool isParamExpr(size_t N) const override { |
||
| 9399 | return false; |
||
| 9400 | } |
||
| 9401 | |||
| 9402 | static const ParsedAttrInfoNonNull Instance; |
||
| 9403 | }; |
||
| 9404 | const ParsedAttrInfoNonNull ParsedAttrInfoNonNull::Instance; |
||
| 9405 | static constexpr ParsedAttrInfo::Spelling NotTailCalledSpellings[] = { |
||
| 9406 | {AttributeCommonInfo::AS_GNU, "not_tail_called"}, |
||
| 9407 | {AttributeCommonInfo::AS_CXX11, "clang::not_tail_called"}, |
||
| 9408 | {AttributeCommonInfo::AS_C2x, "clang::not_tail_called"}, |
||
| 9409 | }; |
||
| 9410 | struct ParsedAttrInfoNotTailCalled final : public ParsedAttrInfo { |
||
| 9411 | constexpr ParsedAttrInfoNotTailCalled() : ParsedAttrInfo( |
||
| 9412 | /*AttrKind=*/ParsedAttr::AT_NotTailCalled, |
||
| 9413 | /*NumArgs=*/0, |
||
| 9414 | /*OptArgs=*/0, |
||
| 9415 | /*NumArgMembers=*/0, |
||
| 9416 | /*HasCustomParsing=*/0, |
||
| 9417 | /*AcceptsExprPack=*/0, |
||
| 9418 | /*IsTargetSpecific=*/0, |
||
| 9419 | /*IsType=*/0, |
||
| 9420 | /*IsStmt=*/0, |
||
| 9421 | /*IsKnownToGCC=*/0, |
||
| 9422 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 9423 | /*Spellings=*/NotTailCalledSpellings, |
||
| 9424 | /*ArgNames=*/{}) {} |
||
| 9425 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 9426 | if (!isa<FunctionDecl>(D)) { |
||
| 9427 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 9428 | << Attr << "functions"; |
||
| 9429 | return false; |
||
| 9430 | } |
||
| 9431 | return true; |
||
| 9432 | } |
||
| 9433 | |||
| 9434 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 9435 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 9436 | << AL << St->getBeginLoc(); |
||
| 9437 | return false; |
||
| 9438 | } |
||
| 9439 | |||
| 9440 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 9441 | |||
| 9442 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 9443 | if (const auto *A = D->getAttr<AlwaysInlineAttr>()) { |
||
| 9444 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 9445 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 9446 | return false; |
||
| 9447 | } |
||
| 9448 | return true; |
||
| 9449 | } |
||
| 9450 | |||
| 9451 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 9452 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 9453 | } |
||
| 9454 | |||
| 9455 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 9456 | D->addAttr(::new (S.Context) NotTailCalledAttr(S.Context, Attr)); |
||
| 9457 | return AttributeApplied; |
||
| 9458 | } |
||
| 9459 | |||
| 9460 | bool isParamExpr(size_t N) const override { |
||
| 9461 | return false; |
||
| 9462 | } |
||
| 9463 | |||
| 9464 | static const ParsedAttrInfoNotTailCalled Instance; |
||
| 9465 | }; |
||
| 9466 | const ParsedAttrInfoNotTailCalled ParsedAttrInfoNotTailCalled::Instance; |
||
| 9467 | static constexpr ParsedAttrInfo::Spelling OSConsumedSpellings[] = { |
||
| 9468 | {AttributeCommonInfo::AS_GNU, "os_consumed"}, |
||
| 9469 | {AttributeCommonInfo::AS_CXX11, "clang::os_consumed"}, |
||
| 9470 | {AttributeCommonInfo::AS_C2x, "clang::os_consumed"}, |
||
| 9471 | }; |
||
| 9472 | struct ParsedAttrInfoOSConsumed final : public ParsedAttrInfo { |
||
| 9473 | constexpr ParsedAttrInfoOSConsumed() : ParsedAttrInfo( |
||
| 9474 | /*AttrKind=*/ParsedAttr::AT_OSConsumed, |
||
| 9475 | /*NumArgs=*/0, |
||
| 9476 | /*OptArgs=*/0, |
||
| 9477 | /*NumArgMembers=*/0, |
||
| 9478 | /*HasCustomParsing=*/0, |
||
| 9479 | /*AcceptsExprPack=*/0, |
||
| 9480 | /*IsTargetSpecific=*/0, |
||
| 9481 | /*IsType=*/0, |
||
| 9482 | /*IsStmt=*/0, |
||
| 9483 | /*IsKnownToGCC=*/0, |
||
| 9484 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 9485 | /*Spellings=*/OSConsumedSpellings, |
||
| 9486 | /*ArgNames=*/{}) {} |
||
| 9487 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 9488 | if (!isa<ParmVarDecl>(D)) { |
||
| 9489 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 9490 | << Attr << "parameters"; |
||
| 9491 | return false; |
||
| 9492 | } |
||
| 9493 | return true; |
||
| 9494 | } |
||
| 9495 | |||
| 9496 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 9497 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 9498 | << AL << St->getBeginLoc(); |
||
| 9499 | return false; |
||
| 9500 | } |
||
| 9501 | |||
| 9502 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 9503 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
||
| 9504 | } |
||
| 9505 | |||
| 9506 | bool isParamExpr(size_t N) const override { |
||
| 9507 | return false; |
||
| 9508 | } |
||
| 9509 | |||
| 9510 | static const ParsedAttrInfoOSConsumed Instance; |
||
| 9511 | }; |
||
| 9512 | const ParsedAttrInfoOSConsumed ParsedAttrInfoOSConsumed::Instance; |
||
| 9513 | static constexpr ParsedAttrInfo::Spelling OSConsumesThisSpellings[] = { |
||
| 9514 | {AttributeCommonInfo::AS_GNU, "os_consumes_this"}, |
||
| 9515 | {AttributeCommonInfo::AS_CXX11, "clang::os_consumes_this"}, |
||
| 9516 | {AttributeCommonInfo::AS_C2x, "clang::os_consumes_this"}, |
||
| 9517 | }; |
||
| 9518 | struct ParsedAttrInfoOSConsumesThis final : public ParsedAttrInfo { |
||
| 9519 | constexpr ParsedAttrInfoOSConsumesThis() : ParsedAttrInfo( |
||
| 9520 | /*AttrKind=*/ParsedAttr::AT_OSConsumesThis, |
||
| 9521 | /*NumArgs=*/0, |
||
| 9522 | /*OptArgs=*/0, |
||
| 9523 | /*NumArgMembers=*/0, |
||
| 9524 | /*HasCustomParsing=*/0, |
||
| 9525 | /*AcceptsExprPack=*/0, |
||
| 9526 | /*IsTargetSpecific=*/0, |
||
| 9527 | /*IsType=*/0, |
||
| 9528 | /*IsStmt=*/0, |
||
| 9529 | /*IsKnownToGCC=*/0, |
||
| 9530 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 9531 | /*Spellings=*/OSConsumesThisSpellings, |
||
| 9532 | /*ArgNames=*/{}) {} |
||
| 9533 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 9534 | if (!isNonStaticCXXMethod(D)) { |
||
| 9535 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 9536 | << Attr << "non-static member functions"; |
||
| 9537 | return false; |
||
| 9538 | } |
||
| 9539 | return true; |
||
| 9540 | } |
||
| 9541 | |||
| 9542 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 9543 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 9544 | << AL << St->getBeginLoc(); |
||
| 9545 | return false; |
||
| 9546 | } |
||
| 9547 | |||
| 9548 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 9549 | D->addAttr(::new (S.Context) OSConsumesThisAttr(S.Context, Attr)); |
||
| 9550 | return AttributeApplied; |
||
| 9551 | } |
||
| 9552 | |||
| 9553 | bool isParamExpr(size_t N) const override { |
||
| 9554 | return false; |
||
| 9555 | } |
||
| 9556 | |||
| 9557 | static const ParsedAttrInfoOSConsumesThis Instance; |
||
| 9558 | }; |
||
| 9559 | const ParsedAttrInfoOSConsumesThis ParsedAttrInfoOSConsumesThis::Instance; |
||
| 9560 | static constexpr ParsedAttrInfo::Spelling OSReturnsNotRetainedSpellings[] = { |
||
| 9561 | {AttributeCommonInfo::AS_GNU, "os_returns_not_retained"}, |
||
| 9562 | {AttributeCommonInfo::AS_CXX11, "clang::os_returns_not_retained"}, |
||
| 9563 | {AttributeCommonInfo::AS_C2x, "clang::os_returns_not_retained"}, |
||
| 9564 | }; |
||
| 9565 | struct ParsedAttrInfoOSReturnsNotRetained final : public ParsedAttrInfo { |
||
| 9566 | constexpr ParsedAttrInfoOSReturnsNotRetained() : ParsedAttrInfo( |
||
| 9567 | /*AttrKind=*/ParsedAttr::AT_OSReturnsNotRetained, |
||
| 9568 | /*NumArgs=*/0, |
||
| 9569 | /*OptArgs=*/0, |
||
| 9570 | /*NumArgMembers=*/0, |
||
| 9571 | /*HasCustomParsing=*/0, |
||
| 9572 | /*AcceptsExprPack=*/0, |
||
| 9573 | /*IsTargetSpecific=*/0, |
||
| 9574 | /*IsType=*/0, |
||
| 9575 | /*IsStmt=*/0, |
||
| 9576 | /*IsKnownToGCC=*/0, |
||
| 9577 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 9578 | /*Spellings=*/OSReturnsNotRetainedSpellings, |
||
| 9579 | /*ArgNames=*/{}) {} |
||
| 9580 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 9581 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D) && !isa<ObjCPropertyDecl>(D) && !isa<ParmVarDecl>(D)) { |
||
| 9582 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 9583 | << Attr << "functions, Objective-C methods, Objective-C properties, and parameters"; |
||
| 9584 | return false; |
||
| 9585 | } |
||
| 9586 | return true; |
||
| 9587 | } |
||
| 9588 | |||
| 9589 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 9590 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 9591 | << AL << St->getBeginLoc(); |
||
| 9592 | return false; |
||
| 9593 | } |
||
| 9594 | |||
| 9595 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 9596 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 9597 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 9598 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_property, /*IsSupported=*/LangOpts.ObjC)); |
||
| 9599 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
||
| 9600 | } |
||
| 9601 | |||
| 9602 | bool isParamExpr(size_t N) const override { |
||
| 9603 | return false; |
||
| 9604 | } |
||
| 9605 | |||
| 9606 | static const ParsedAttrInfoOSReturnsNotRetained Instance; |
||
| 9607 | }; |
||
| 9608 | const ParsedAttrInfoOSReturnsNotRetained ParsedAttrInfoOSReturnsNotRetained::Instance; |
||
| 9609 | static constexpr ParsedAttrInfo::Spelling OSReturnsRetainedSpellings[] = { |
||
| 9610 | {AttributeCommonInfo::AS_GNU, "os_returns_retained"}, |
||
| 9611 | {AttributeCommonInfo::AS_CXX11, "clang::os_returns_retained"}, |
||
| 9612 | {AttributeCommonInfo::AS_C2x, "clang::os_returns_retained"}, |
||
| 9613 | }; |
||
| 9614 | struct ParsedAttrInfoOSReturnsRetained final : public ParsedAttrInfo { |
||
| 9615 | constexpr ParsedAttrInfoOSReturnsRetained() : ParsedAttrInfo( |
||
| 9616 | /*AttrKind=*/ParsedAttr::AT_OSReturnsRetained, |
||
| 9617 | /*NumArgs=*/0, |
||
| 9618 | /*OptArgs=*/0, |
||
| 9619 | /*NumArgMembers=*/0, |
||
| 9620 | /*HasCustomParsing=*/0, |
||
| 9621 | /*AcceptsExprPack=*/0, |
||
| 9622 | /*IsTargetSpecific=*/0, |
||
| 9623 | /*IsType=*/0, |
||
| 9624 | /*IsStmt=*/0, |
||
| 9625 | /*IsKnownToGCC=*/0, |
||
| 9626 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 9627 | /*Spellings=*/OSReturnsRetainedSpellings, |
||
| 9628 | /*ArgNames=*/{}) {} |
||
| 9629 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 9630 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D) && !isa<ObjCPropertyDecl>(D) && !isa<ParmVarDecl>(D)) { |
||
| 9631 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 9632 | << Attr << "functions, Objective-C methods, Objective-C properties, and parameters"; |
||
| 9633 | return false; |
||
| 9634 | } |
||
| 9635 | return true; |
||
| 9636 | } |
||
| 9637 | |||
| 9638 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 9639 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 9640 | << AL << St->getBeginLoc(); |
||
| 9641 | return false; |
||
| 9642 | } |
||
| 9643 | |||
| 9644 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 9645 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 9646 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 9647 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_property, /*IsSupported=*/LangOpts.ObjC)); |
||
| 9648 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
||
| 9649 | } |
||
| 9650 | |||
| 9651 | bool isParamExpr(size_t N) const override { |
||
| 9652 | return false; |
||
| 9653 | } |
||
| 9654 | |||
| 9655 | static const ParsedAttrInfoOSReturnsRetained Instance; |
||
| 9656 | }; |
||
| 9657 | const ParsedAttrInfoOSReturnsRetained ParsedAttrInfoOSReturnsRetained::Instance; |
||
| 9658 | static constexpr ParsedAttrInfo::Spelling OSReturnsRetainedOnNonZeroSpellings[] = { |
||
| 9659 | {AttributeCommonInfo::AS_GNU, "os_returns_retained_on_non_zero"}, |
||
| 9660 | {AttributeCommonInfo::AS_CXX11, "clang::os_returns_retained_on_non_zero"}, |
||
| 9661 | {AttributeCommonInfo::AS_C2x, "clang::os_returns_retained_on_non_zero"}, |
||
| 9662 | }; |
||
| 9663 | struct ParsedAttrInfoOSReturnsRetainedOnNonZero final : public ParsedAttrInfo { |
||
| 9664 | constexpr ParsedAttrInfoOSReturnsRetainedOnNonZero() : ParsedAttrInfo( |
||
| 9665 | /*AttrKind=*/ParsedAttr::AT_OSReturnsRetainedOnNonZero, |
||
| 9666 | /*NumArgs=*/0, |
||
| 9667 | /*OptArgs=*/0, |
||
| 9668 | /*NumArgMembers=*/0, |
||
| 9669 | /*HasCustomParsing=*/0, |
||
| 9670 | /*AcceptsExprPack=*/0, |
||
| 9671 | /*IsTargetSpecific=*/0, |
||
| 9672 | /*IsType=*/0, |
||
| 9673 | /*IsStmt=*/0, |
||
| 9674 | /*IsKnownToGCC=*/0, |
||
| 9675 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 9676 | /*Spellings=*/OSReturnsRetainedOnNonZeroSpellings, |
||
| 9677 | /*ArgNames=*/{}) {} |
||
| 9678 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 9679 | if (!isa<ParmVarDecl>(D)) { |
||
| 9680 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 9681 | << Attr << "parameters"; |
||
| 9682 | return false; |
||
| 9683 | } |
||
| 9684 | return true; |
||
| 9685 | } |
||
| 9686 | |||
| 9687 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 9688 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 9689 | << AL << St->getBeginLoc(); |
||
| 9690 | return false; |
||
| 9691 | } |
||
| 9692 | |||
| 9693 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 9694 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
||
| 9695 | } |
||
| 9696 | |||
| 9697 | bool isParamExpr(size_t N) const override { |
||
| 9698 | return false; |
||
| 9699 | } |
||
| 9700 | |||
| 9701 | static const ParsedAttrInfoOSReturnsRetainedOnNonZero Instance; |
||
| 9702 | }; |
||
| 9703 | const ParsedAttrInfoOSReturnsRetainedOnNonZero ParsedAttrInfoOSReturnsRetainedOnNonZero::Instance; |
||
| 9704 | static constexpr ParsedAttrInfo::Spelling OSReturnsRetainedOnZeroSpellings[] = { |
||
| 9705 | {AttributeCommonInfo::AS_GNU, "os_returns_retained_on_zero"}, |
||
| 9706 | {AttributeCommonInfo::AS_CXX11, "clang::os_returns_retained_on_zero"}, |
||
| 9707 | {AttributeCommonInfo::AS_C2x, "clang::os_returns_retained_on_zero"}, |
||
| 9708 | }; |
||
| 9709 | struct ParsedAttrInfoOSReturnsRetainedOnZero final : public ParsedAttrInfo { |
||
| 9710 | constexpr ParsedAttrInfoOSReturnsRetainedOnZero() : ParsedAttrInfo( |
||
| 9711 | /*AttrKind=*/ParsedAttr::AT_OSReturnsRetainedOnZero, |
||
| 9712 | /*NumArgs=*/0, |
||
| 9713 | /*OptArgs=*/0, |
||
| 9714 | /*NumArgMembers=*/0, |
||
| 9715 | /*HasCustomParsing=*/0, |
||
| 9716 | /*AcceptsExprPack=*/0, |
||
| 9717 | /*IsTargetSpecific=*/0, |
||
| 9718 | /*IsType=*/0, |
||
| 9719 | /*IsStmt=*/0, |
||
| 9720 | /*IsKnownToGCC=*/0, |
||
| 9721 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 9722 | /*Spellings=*/OSReturnsRetainedOnZeroSpellings, |
||
| 9723 | /*ArgNames=*/{}) {} |
||
| 9724 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 9725 | if (!isa<ParmVarDecl>(D)) { |
||
| 9726 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 9727 | << Attr << "parameters"; |
||
| 9728 | return false; |
||
| 9729 | } |
||
| 9730 | return true; |
||
| 9731 | } |
||
| 9732 | |||
| 9733 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 9734 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 9735 | << AL << St->getBeginLoc(); |
||
| 9736 | return false; |
||
| 9737 | } |
||
| 9738 | |||
| 9739 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 9740 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
||
| 9741 | } |
||
| 9742 | |||
| 9743 | bool isParamExpr(size_t N) const override { |
||
| 9744 | return false; |
||
| 9745 | } |
||
| 9746 | |||
| 9747 | static const ParsedAttrInfoOSReturnsRetainedOnZero Instance; |
||
| 9748 | }; |
||
| 9749 | const ParsedAttrInfoOSReturnsRetainedOnZero ParsedAttrInfoOSReturnsRetainedOnZero::Instance; |
||
| 9750 | static constexpr ParsedAttrInfo::Spelling ObjCBoxableSpellings[] = { |
||
| 9751 | {AttributeCommonInfo::AS_GNU, "objc_boxable"}, |
||
| 9752 | {AttributeCommonInfo::AS_CXX11, "clang::objc_boxable"}, |
||
| 9753 | {AttributeCommonInfo::AS_C2x, "clang::objc_boxable"}, |
||
| 9754 | }; |
||
| 9755 | struct ParsedAttrInfoObjCBoxable final : public ParsedAttrInfo { |
||
| 9756 | constexpr ParsedAttrInfoObjCBoxable() : ParsedAttrInfo( |
||
| 9757 | /*AttrKind=*/ParsedAttr::AT_ObjCBoxable, |
||
| 9758 | /*NumArgs=*/0, |
||
| 9759 | /*OptArgs=*/0, |
||
| 9760 | /*NumArgMembers=*/0, |
||
| 9761 | /*HasCustomParsing=*/0, |
||
| 9762 | /*AcceptsExprPack=*/0, |
||
| 9763 | /*IsTargetSpecific=*/0, |
||
| 9764 | /*IsType=*/0, |
||
| 9765 | /*IsStmt=*/0, |
||
| 9766 | /*IsKnownToGCC=*/0, |
||
| 9767 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 9768 | /*Spellings=*/ObjCBoxableSpellings, |
||
| 9769 | /*ArgNames=*/{}) {} |
||
| 9770 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 9771 | if (!isa<RecordDecl>(D)) { |
||
| 9772 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 9773 | << Attr << "structs, unions, and classes"; |
||
| 9774 | return false; |
||
| 9775 | } |
||
| 9776 | return true; |
||
| 9777 | } |
||
| 9778 | |||
| 9779 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 9780 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 9781 | << AL << St->getBeginLoc(); |
||
| 9782 | return false; |
||
| 9783 | } |
||
| 9784 | |||
| 9785 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 9786 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 9787 | } |
||
| 9788 | |||
| 9789 | bool isParamExpr(size_t N) const override { |
||
| 9790 | return false; |
||
| 9791 | } |
||
| 9792 | |||
| 9793 | static const ParsedAttrInfoObjCBoxable Instance; |
||
| 9794 | }; |
||
| 9795 | const ParsedAttrInfoObjCBoxable ParsedAttrInfoObjCBoxable::Instance; |
||
| 9796 | static constexpr ParsedAttrInfo::Spelling ObjCBridgeSpellings[] = { |
||
| 9797 | {AttributeCommonInfo::AS_GNU, "objc_bridge"}, |
||
| 9798 | {AttributeCommonInfo::AS_CXX11, "clang::objc_bridge"}, |
||
| 9799 | {AttributeCommonInfo::AS_C2x, "clang::objc_bridge"}, |
||
| 9800 | }; |
||
| 9801 | static constexpr const char *ObjCBridgeArgNames[] = { |
||
| 9802 | "BridgedType",}; |
||
| 9803 | struct ParsedAttrInfoObjCBridge final : public ParsedAttrInfo { |
||
| 9804 | constexpr ParsedAttrInfoObjCBridge() : ParsedAttrInfo( |
||
| 9805 | /*AttrKind=*/ParsedAttr::AT_ObjCBridge, |
||
| 9806 | /*NumArgs=*/1, |
||
| 9807 | /*OptArgs=*/0, |
||
| 9808 | /*NumArgMembers=*/1, |
||
| 9809 | /*HasCustomParsing=*/0, |
||
| 9810 | /*AcceptsExprPack=*/0, |
||
| 9811 | /*IsTargetSpecific=*/0, |
||
| 9812 | /*IsType=*/0, |
||
| 9813 | /*IsStmt=*/0, |
||
| 9814 | /*IsKnownToGCC=*/0, |
||
| 9815 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 9816 | /*Spellings=*/ObjCBridgeSpellings, |
||
| 9817 | /*ArgNames=*/ObjCBridgeArgNames) {} |
||
| 9818 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 9819 | if (!isa<RecordDecl>(D) && !isa<TypedefNameDecl>(D)) { |
||
| 9820 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 9821 | << Attr << "structs, unions, classes, and typedefs"; |
||
| 9822 | return false; |
||
| 9823 | } |
||
| 9824 | return true; |
||
| 9825 | } |
||
| 9826 | |||
| 9827 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 9828 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 9829 | << AL << St->getBeginLoc(); |
||
| 9830 | return false; |
||
| 9831 | } |
||
| 9832 | |||
| 9833 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 9834 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 9835 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true)); |
||
| 9836 | } |
||
| 9837 | |||
| 9838 | bool isParamExpr(size_t N) const override { |
||
| 9839 | return false; |
||
| 9840 | } |
||
| 9841 | |||
| 9842 | static const ParsedAttrInfoObjCBridge Instance; |
||
| 9843 | }; |
||
| 9844 | const ParsedAttrInfoObjCBridge ParsedAttrInfoObjCBridge::Instance; |
||
| 9845 | static constexpr ParsedAttrInfo::Spelling ObjCBridgeMutableSpellings[] = { |
||
| 9846 | {AttributeCommonInfo::AS_GNU, "objc_bridge_mutable"}, |
||
| 9847 | {AttributeCommonInfo::AS_CXX11, "clang::objc_bridge_mutable"}, |
||
| 9848 | {AttributeCommonInfo::AS_C2x, "clang::objc_bridge_mutable"}, |
||
| 9849 | }; |
||
| 9850 | static constexpr const char *ObjCBridgeMutableArgNames[] = { |
||
| 9851 | "BridgedType",}; |
||
| 9852 | struct ParsedAttrInfoObjCBridgeMutable final : public ParsedAttrInfo { |
||
| 9853 | constexpr ParsedAttrInfoObjCBridgeMutable() : ParsedAttrInfo( |
||
| 9854 | /*AttrKind=*/ParsedAttr::AT_ObjCBridgeMutable, |
||
| 9855 | /*NumArgs=*/1, |
||
| 9856 | /*OptArgs=*/0, |
||
| 9857 | /*NumArgMembers=*/1, |
||
| 9858 | /*HasCustomParsing=*/0, |
||
| 9859 | /*AcceptsExprPack=*/0, |
||
| 9860 | /*IsTargetSpecific=*/0, |
||
| 9861 | /*IsType=*/0, |
||
| 9862 | /*IsStmt=*/0, |
||
| 9863 | /*IsKnownToGCC=*/0, |
||
| 9864 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 9865 | /*Spellings=*/ObjCBridgeMutableSpellings, |
||
| 9866 | /*ArgNames=*/ObjCBridgeMutableArgNames) {} |
||
| 9867 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 9868 | if (!isa<RecordDecl>(D)) { |
||
| 9869 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 9870 | << Attr << "structs, unions, and classes"; |
||
| 9871 | return false; |
||
| 9872 | } |
||
| 9873 | return true; |
||
| 9874 | } |
||
| 9875 | |||
| 9876 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 9877 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 9878 | << AL << St->getBeginLoc(); |
||
| 9879 | return false; |
||
| 9880 | } |
||
| 9881 | |||
| 9882 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 9883 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 9884 | } |
||
| 9885 | |||
| 9886 | bool isParamExpr(size_t N) const override { |
||
| 9887 | return false; |
||
| 9888 | } |
||
| 9889 | |||
| 9890 | static const ParsedAttrInfoObjCBridgeMutable Instance; |
||
| 9891 | }; |
||
| 9892 | const ParsedAttrInfoObjCBridgeMutable ParsedAttrInfoObjCBridgeMutable::Instance; |
||
| 9893 | static constexpr ParsedAttrInfo::Spelling ObjCBridgeRelatedSpellings[] = { |
||
| 9894 | {AttributeCommonInfo::AS_GNU, "objc_bridge_related"}, |
||
| 9895 | {AttributeCommonInfo::AS_CXX11, "clang::objc_bridge_related"}, |
||
| 9896 | {AttributeCommonInfo::AS_C2x, "clang::objc_bridge_related"}, |
||
| 9897 | }; |
||
| 9898 | static constexpr const char *ObjCBridgeRelatedArgNames[] = { |
||
| 9899 | "RelatedClass","ClassMethod","InstanceMethod",}; |
||
| 9900 | struct ParsedAttrInfoObjCBridgeRelated final : public ParsedAttrInfo { |
||
| 9901 | constexpr ParsedAttrInfoObjCBridgeRelated() : ParsedAttrInfo( |
||
| 9902 | /*AttrKind=*/ParsedAttr::AT_ObjCBridgeRelated, |
||
| 9903 | /*NumArgs=*/3, |
||
| 9904 | /*OptArgs=*/0, |
||
| 9905 | /*NumArgMembers=*/3, |
||
| 9906 | /*HasCustomParsing=*/1, |
||
| 9907 | /*AcceptsExprPack=*/0, |
||
| 9908 | /*IsTargetSpecific=*/0, |
||
| 9909 | /*IsType=*/0, |
||
| 9910 | /*IsStmt=*/0, |
||
| 9911 | /*IsKnownToGCC=*/0, |
||
| 9912 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 9913 | /*Spellings=*/ObjCBridgeRelatedSpellings, |
||
| 9914 | /*ArgNames=*/ObjCBridgeRelatedArgNames) {} |
||
| 9915 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 9916 | if (!isa<RecordDecl>(D)) { |
||
| 9917 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 9918 | << Attr << "structs, unions, and classes"; |
||
| 9919 | return false; |
||
| 9920 | } |
||
| 9921 | return true; |
||
| 9922 | } |
||
| 9923 | |||
| 9924 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 9925 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 9926 | << AL << St->getBeginLoc(); |
||
| 9927 | return false; |
||
| 9928 | } |
||
| 9929 | |||
| 9930 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 9931 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 9932 | } |
||
| 9933 | |||
| 9934 | bool isParamExpr(size_t N) const override { |
||
| 9935 | return false; |
||
| 9936 | } |
||
| 9937 | |||
| 9938 | static const ParsedAttrInfoObjCBridgeRelated Instance; |
||
| 9939 | }; |
||
| 9940 | const ParsedAttrInfoObjCBridgeRelated ParsedAttrInfoObjCBridgeRelated::Instance; |
||
| 9941 | static constexpr ParsedAttrInfo::Spelling ObjCClassStubSpellings[] = { |
||
| 9942 | {AttributeCommonInfo::AS_GNU, "objc_class_stub"}, |
||
| 9943 | {AttributeCommonInfo::AS_CXX11, "clang::objc_class_stub"}, |
||
| 9944 | {AttributeCommonInfo::AS_C2x, "clang::objc_class_stub"}, |
||
| 9945 | }; |
||
| 9946 | struct ParsedAttrInfoObjCClassStub final : public ParsedAttrInfo { |
||
| 9947 | constexpr ParsedAttrInfoObjCClassStub() : ParsedAttrInfo( |
||
| 9948 | /*AttrKind=*/ParsedAttr::AT_ObjCClassStub, |
||
| 9949 | /*NumArgs=*/0, |
||
| 9950 | /*OptArgs=*/0, |
||
| 9951 | /*NumArgMembers=*/0, |
||
| 9952 | /*HasCustomParsing=*/0, |
||
| 9953 | /*AcceptsExprPack=*/0, |
||
| 9954 | /*IsTargetSpecific=*/0, |
||
| 9955 | /*IsType=*/0, |
||
| 9956 | /*IsStmt=*/0, |
||
| 9957 | /*IsKnownToGCC=*/0, |
||
| 9958 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 9959 | /*Spellings=*/ObjCClassStubSpellings, |
||
| 9960 | /*ArgNames=*/{}) {} |
||
| 9961 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 9962 | if (!isa<ObjCInterfaceDecl>(D)) { |
||
| 9963 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 9964 | << Attr << "Objective-C interfaces"; |
||
| 9965 | return false; |
||
| 9966 | } |
||
| 9967 | return true; |
||
| 9968 | } |
||
| 9969 | |||
| 9970 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 9971 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 9972 | << AL << St->getBeginLoc(); |
||
| 9973 | return false; |
||
| 9974 | } |
||
| 9975 | |||
| 9976 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 9977 | return (LangOpts.ObjCRuntime.allowsClassStubs()); |
||
| 9978 | } |
||
| 9979 | |||
| 9980 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 9981 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
||
| 9982 | } |
||
| 9983 | |||
| 9984 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 9985 | D->addAttr(::new (S.Context) ObjCClassStubAttr(S.Context, Attr)); |
||
| 9986 | return AttributeApplied; |
||
| 9987 | } |
||
| 9988 | |||
| 9989 | bool isParamExpr(size_t N) const override { |
||
| 9990 | return false; |
||
| 9991 | } |
||
| 9992 | |||
| 9993 | static const ParsedAttrInfoObjCClassStub Instance; |
||
| 9994 | }; |
||
| 9995 | const ParsedAttrInfoObjCClassStub ParsedAttrInfoObjCClassStub::Instance; |
||
| 9996 | static constexpr ParsedAttrInfo::Spelling ObjCDesignatedInitializerSpellings[] = { |
||
| 9997 | {AttributeCommonInfo::AS_GNU, "objc_designated_initializer"}, |
||
| 9998 | {AttributeCommonInfo::AS_CXX11, "clang::objc_designated_initializer"}, |
||
| 9999 | {AttributeCommonInfo::AS_C2x, "clang::objc_designated_initializer"}, |
||
| 10000 | }; |
||
| 10001 | struct ParsedAttrInfoObjCDesignatedInitializer final : public ParsedAttrInfo { |
||
| 10002 | constexpr ParsedAttrInfoObjCDesignatedInitializer() : ParsedAttrInfo( |
||
| 10003 | /*AttrKind=*/ParsedAttr::AT_ObjCDesignatedInitializer, |
||
| 10004 | /*NumArgs=*/0, |
||
| 10005 | /*OptArgs=*/0, |
||
| 10006 | /*NumArgMembers=*/0, |
||
| 10007 | /*HasCustomParsing=*/0, |
||
| 10008 | /*AcceptsExprPack=*/0, |
||
| 10009 | /*IsTargetSpecific=*/0, |
||
| 10010 | /*IsType=*/0, |
||
| 10011 | /*IsStmt=*/0, |
||
| 10012 | /*IsKnownToGCC=*/0, |
||
| 10013 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 10014 | /*Spellings=*/ObjCDesignatedInitializerSpellings, |
||
| 10015 | /*ArgNames=*/{}) {} |
||
| 10016 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 10017 | if (!isa<ObjCMethodDecl>(D)) { |
||
| 10018 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 10019 | << Attr << "Objective-C methods"; |
||
| 10020 | return false; |
||
| 10021 | } |
||
| 10022 | return true; |
||
| 10023 | } |
||
| 10024 | |||
| 10025 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 10026 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 10027 | << AL << St->getBeginLoc(); |
||
| 10028 | return false; |
||
| 10029 | } |
||
| 10030 | |||
| 10031 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 10032 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 10033 | } |
||
| 10034 | |||
| 10035 | bool isParamExpr(size_t N) const override { |
||
| 10036 | return false; |
||
| 10037 | } |
||
| 10038 | |||
| 10039 | static const ParsedAttrInfoObjCDesignatedInitializer Instance; |
||
| 10040 | }; |
||
| 10041 | const ParsedAttrInfoObjCDesignatedInitializer ParsedAttrInfoObjCDesignatedInitializer::Instance; |
||
| 10042 | static constexpr ParsedAttrInfo::Spelling ObjCDirectSpellings[] = { |
||
| 10043 | {AttributeCommonInfo::AS_GNU, "objc_direct"}, |
||
| 10044 | {AttributeCommonInfo::AS_CXX11, "clang::objc_direct"}, |
||
| 10045 | {AttributeCommonInfo::AS_C2x, "clang::objc_direct"}, |
||
| 10046 | }; |
||
| 10047 | struct ParsedAttrInfoObjCDirect final : public ParsedAttrInfo { |
||
| 10048 | constexpr ParsedAttrInfoObjCDirect() : ParsedAttrInfo( |
||
| 10049 | /*AttrKind=*/ParsedAttr::AT_ObjCDirect, |
||
| 10050 | /*NumArgs=*/0, |
||
| 10051 | /*OptArgs=*/0, |
||
| 10052 | /*NumArgMembers=*/0, |
||
| 10053 | /*HasCustomParsing=*/0, |
||
| 10054 | /*AcceptsExprPack=*/0, |
||
| 10055 | /*IsTargetSpecific=*/0, |
||
| 10056 | /*IsType=*/0, |
||
| 10057 | /*IsStmt=*/0, |
||
| 10058 | /*IsKnownToGCC=*/0, |
||
| 10059 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 10060 | /*Spellings=*/ObjCDirectSpellings, |
||
| 10061 | /*ArgNames=*/{}) {} |
||
| 10062 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 10063 | if (!isa<ObjCMethodDecl>(D)) { |
||
| 10064 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 10065 | << Attr << "Objective-C methods"; |
||
| 10066 | return false; |
||
| 10067 | } |
||
| 10068 | return true; |
||
| 10069 | } |
||
| 10070 | |||
| 10071 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 10072 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 10073 | << AL << St->getBeginLoc(); |
||
| 10074 | return false; |
||
| 10075 | } |
||
| 10076 | |||
| 10077 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 10078 | return LangOpts.ObjC; |
||
| 10079 | } |
||
| 10080 | |||
| 10081 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 10082 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 10083 | } |
||
| 10084 | |||
| 10085 | bool isParamExpr(size_t N) const override { |
||
| 10086 | return false; |
||
| 10087 | } |
||
| 10088 | |||
| 10089 | static const ParsedAttrInfoObjCDirect Instance; |
||
| 10090 | }; |
||
| 10091 | const ParsedAttrInfoObjCDirect ParsedAttrInfoObjCDirect::Instance; |
||
| 10092 | static constexpr ParsedAttrInfo::Spelling ObjCDirectMembersSpellings[] = { |
||
| 10093 | {AttributeCommonInfo::AS_GNU, "objc_direct_members"}, |
||
| 10094 | {AttributeCommonInfo::AS_CXX11, "clang::objc_direct_members"}, |
||
| 10095 | {AttributeCommonInfo::AS_C2x, "clang::objc_direct_members"}, |
||
| 10096 | }; |
||
| 10097 | struct ParsedAttrInfoObjCDirectMembers final : public ParsedAttrInfo { |
||
| 10098 | constexpr ParsedAttrInfoObjCDirectMembers() : ParsedAttrInfo( |
||
| 10099 | /*AttrKind=*/ParsedAttr::AT_ObjCDirectMembers, |
||
| 10100 | /*NumArgs=*/0, |
||
| 10101 | /*OptArgs=*/0, |
||
| 10102 | /*NumArgMembers=*/0, |
||
| 10103 | /*HasCustomParsing=*/0, |
||
| 10104 | /*AcceptsExprPack=*/0, |
||
| 10105 | /*IsTargetSpecific=*/0, |
||
| 10106 | /*IsType=*/0, |
||
| 10107 | /*IsStmt=*/0, |
||
| 10108 | /*IsKnownToGCC=*/0, |
||
| 10109 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 10110 | /*Spellings=*/ObjCDirectMembersSpellings, |
||
| 10111 | /*ArgNames=*/{}) {} |
||
| 10112 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 10113 | if (!isa<ObjCImplDecl>(D) && !isa<ObjCInterfaceDecl>(D) && !isa<ObjCCategoryDecl>(D)) { |
||
| 10114 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 10115 | << Attr << "Objective-C implementation declarations, Objective-C interfaces, and Objective-C containers"; |
||
| 10116 | return false; |
||
| 10117 | } |
||
| 10118 | return true; |
||
| 10119 | } |
||
| 10120 | |||
| 10121 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 10122 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 10123 | << AL << St->getBeginLoc(); |
||
| 10124 | return false; |
||
| 10125 | } |
||
| 10126 | |||
| 10127 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 10128 | return LangOpts.ObjC; |
||
| 10129 | } |
||
| 10130 | |||
| 10131 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 10132 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_implementation, /*IsSupported=*/LangOpts.ObjC)); |
||
| 10133 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
||
| 10134 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_category, /*IsSupported=*/LangOpts.ObjC)); |
||
| 10135 | } |
||
| 10136 | |||
| 10137 | bool isParamExpr(size_t N) const override { |
||
| 10138 | return false; |
||
| 10139 | } |
||
| 10140 | |||
| 10141 | static const ParsedAttrInfoObjCDirectMembers Instance; |
||
| 10142 | }; |
||
| 10143 | const ParsedAttrInfoObjCDirectMembers ParsedAttrInfoObjCDirectMembers::Instance; |
||
| 10144 | static constexpr ParsedAttrInfo::Spelling ObjCExceptionSpellings[] = { |
||
| 10145 | {AttributeCommonInfo::AS_GNU, "objc_exception"}, |
||
| 10146 | {AttributeCommonInfo::AS_CXX11, "clang::objc_exception"}, |
||
| 10147 | {AttributeCommonInfo::AS_C2x, "clang::objc_exception"}, |
||
| 10148 | }; |
||
| 10149 | struct ParsedAttrInfoObjCException final : public ParsedAttrInfo { |
||
| 10150 | constexpr ParsedAttrInfoObjCException() : ParsedAttrInfo( |
||
| 10151 | /*AttrKind=*/ParsedAttr::AT_ObjCException, |
||
| 10152 | /*NumArgs=*/0, |
||
| 10153 | /*OptArgs=*/0, |
||
| 10154 | /*NumArgMembers=*/0, |
||
| 10155 | /*HasCustomParsing=*/0, |
||
| 10156 | /*AcceptsExprPack=*/0, |
||
| 10157 | /*IsTargetSpecific=*/0, |
||
| 10158 | /*IsType=*/0, |
||
| 10159 | /*IsStmt=*/0, |
||
| 10160 | /*IsKnownToGCC=*/0, |
||
| 10161 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 10162 | /*Spellings=*/ObjCExceptionSpellings, |
||
| 10163 | /*ArgNames=*/{}) {} |
||
| 10164 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 10165 | if (!isa<ObjCInterfaceDecl>(D)) { |
||
| 10166 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 10167 | << Attr << "Objective-C interfaces"; |
||
| 10168 | return false; |
||
| 10169 | } |
||
| 10170 | return true; |
||
| 10171 | } |
||
| 10172 | |||
| 10173 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 10174 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 10175 | << AL << St->getBeginLoc(); |
||
| 10176 | return false; |
||
| 10177 | } |
||
| 10178 | |||
| 10179 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 10180 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
||
| 10181 | } |
||
| 10182 | |||
| 10183 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 10184 | D->addAttr(::new (S.Context) ObjCExceptionAttr(S.Context, Attr)); |
||
| 10185 | return AttributeApplied; |
||
| 10186 | } |
||
| 10187 | |||
| 10188 | bool isParamExpr(size_t N) const override { |
||
| 10189 | return false; |
||
| 10190 | } |
||
| 10191 | |||
| 10192 | static const ParsedAttrInfoObjCException Instance; |
||
| 10193 | }; |
||
| 10194 | const ParsedAttrInfoObjCException ParsedAttrInfoObjCException::Instance; |
||
| 10195 | static constexpr ParsedAttrInfo::Spelling ObjCExplicitProtocolImplSpellings[] = { |
||
| 10196 | {AttributeCommonInfo::AS_GNU, "objc_protocol_requires_explicit_implementation"}, |
||
| 10197 | {AttributeCommonInfo::AS_CXX11, "clang::objc_protocol_requires_explicit_implementation"}, |
||
| 10198 | {AttributeCommonInfo::AS_C2x, "clang::objc_protocol_requires_explicit_implementation"}, |
||
| 10199 | }; |
||
| 10200 | struct ParsedAttrInfoObjCExplicitProtocolImpl final : public ParsedAttrInfo { |
||
| 10201 | constexpr ParsedAttrInfoObjCExplicitProtocolImpl() : ParsedAttrInfo( |
||
| 10202 | /*AttrKind=*/ParsedAttr::AT_ObjCExplicitProtocolImpl, |
||
| 10203 | /*NumArgs=*/0, |
||
| 10204 | /*OptArgs=*/0, |
||
| 10205 | /*NumArgMembers=*/0, |
||
| 10206 | /*HasCustomParsing=*/0, |
||
| 10207 | /*AcceptsExprPack=*/0, |
||
| 10208 | /*IsTargetSpecific=*/0, |
||
| 10209 | /*IsType=*/0, |
||
| 10210 | /*IsStmt=*/0, |
||
| 10211 | /*IsKnownToGCC=*/0, |
||
| 10212 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 10213 | /*Spellings=*/ObjCExplicitProtocolImplSpellings, |
||
| 10214 | /*ArgNames=*/{}) {} |
||
| 10215 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 10216 | if (!isa<ObjCProtocolDecl>(D)) { |
||
| 10217 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 10218 | << Attr << "Objective-C protocols"; |
||
| 10219 | return false; |
||
| 10220 | } |
||
| 10221 | return true; |
||
| 10222 | } |
||
| 10223 | |||
| 10224 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 10225 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 10226 | << AL << St->getBeginLoc(); |
||
| 10227 | return false; |
||
| 10228 | } |
||
| 10229 | |||
| 10230 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 10231 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_protocol, /*IsSupported=*/LangOpts.ObjC)); |
||
| 10232 | } |
||
| 10233 | |||
| 10234 | bool isParamExpr(size_t N) const override { |
||
| 10235 | return false; |
||
| 10236 | } |
||
| 10237 | |||
| 10238 | static const ParsedAttrInfoObjCExplicitProtocolImpl Instance; |
||
| 10239 | }; |
||
| 10240 | const ParsedAttrInfoObjCExplicitProtocolImpl ParsedAttrInfoObjCExplicitProtocolImpl::Instance; |
||
| 10241 | static constexpr ParsedAttrInfo::Spelling ObjCExternallyRetainedSpellings[] = { |
||
| 10242 | {AttributeCommonInfo::AS_GNU, "objc_externally_retained"}, |
||
| 10243 | {AttributeCommonInfo::AS_CXX11, "clang::objc_externally_retained"}, |
||
| 10244 | {AttributeCommonInfo::AS_C2x, "clang::objc_externally_retained"}, |
||
| 10245 | }; |
||
| 10246 | struct ParsedAttrInfoObjCExternallyRetained final : public ParsedAttrInfo { |
||
| 10247 | constexpr ParsedAttrInfoObjCExternallyRetained() : ParsedAttrInfo( |
||
| 10248 | /*AttrKind=*/ParsedAttr::AT_ObjCExternallyRetained, |
||
| 10249 | /*NumArgs=*/0, |
||
| 10250 | /*OptArgs=*/0, |
||
| 10251 | /*NumArgMembers=*/0, |
||
| 10252 | /*HasCustomParsing=*/0, |
||
| 10253 | /*AcceptsExprPack=*/0, |
||
| 10254 | /*IsTargetSpecific=*/0, |
||
| 10255 | /*IsType=*/0, |
||
| 10256 | /*IsStmt=*/0, |
||
| 10257 | /*IsKnownToGCC=*/0, |
||
| 10258 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 10259 | /*Spellings=*/ObjCExternallyRetainedSpellings, |
||
| 10260 | /*ArgNames=*/{}) {} |
||
| 10261 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 10262 | if (!isNonParmVar(D) && !isa<FunctionDecl>(D) && !isa<BlockDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
||
| 10263 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 10264 | << Attr << "variables, functions, blocks, and Objective-C methods"; |
||
| 10265 | return false; |
||
| 10266 | } |
||
| 10267 | return true; |
||
| 10268 | } |
||
| 10269 | |||
| 10270 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 10271 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 10272 | << AL << St->getBeginLoc(); |
||
| 10273 | return false; |
||
| 10274 | } |
||
| 10275 | |||
| 10276 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 10277 | return LangOpts.ObjCAutoRefCount; |
||
| 10278 | } |
||
| 10279 | |||
| 10280 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 10281 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_not_is_parameter, /*IsSupported=*/true)); |
||
| 10282 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 10283 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_block, /*IsSupported=*/LangOpts.Blocks)); |
||
| 10284 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 10285 | } |
||
| 10286 | |||
| 10287 | bool isParamExpr(size_t N) const override { |
||
| 10288 | return false; |
||
| 10289 | } |
||
| 10290 | |||
| 10291 | static const ParsedAttrInfoObjCExternallyRetained Instance; |
||
| 10292 | }; |
||
| 10293 | const ParsedAttrInfoObjCExternallyRetained ParsedAttrInfoObjCExternallyRetained::Instance; |
||
| 10294 | static constexpr ParsedAttrInfo::Spelling ObjCGCSpellings[] = { |
||
| 10295 | {AttributeCommonInfo::AS_GNU, "objc_gc"}, |
||
| 10296 | {AttributeCommonInfo::AS_CXX11, "clang::objc_gc"}, |
||
| 10297 | {AttributeCommonInfo::AS_C2x, "clang::objc_gc"}, |
||
| 10298 | }; |
||
| 10299 | static constexpr const char *ObjCGCArgNames[] = { |
||
| 10300 | "Kind",}; |
||
| 10301 | struct ParsedAttrInfoObjCGC final : public ParsedAttrInfo { |
||
| 10302 | constexpr ParsedAttrInfoObjCGC() : ParsedAttrInfo( |
||
| 10303 | /*AttrKind=*/ParsedAttr::AT_ObjCGC, |
||
| 10304 | /*NumArgs=*/1, |
||
| 10305 | /*OptArgs=*/0, |
||
| 10306 | /*NumArgMembers=*/1, |
||
| 10307 | /*HasCustomParsing=*/0, |
||
| 10308 | /*AcceptsExprPack=*/0, |
||
| 10309 | /*IsTargetSpecific=*/0, |
||
| 10310 | /*IsType=*/1, |
||
| 10311 | /*IsStmt=*/0, |
||
| 10312 | /*IsKnownToGCC=*/0, |
||
| 10313 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 10314 | /*Spellings=*/ObjCGCSpellings, |
||
| 10315 | /*ArgNames=*/ObjCGCArgNames) {} |
||
| 10316 | bool isParamExpr(size_t N) const override { |
||
| 10317 | return false; |
||
| 10318 | } |
||
| 10319 | |||
| 10320 | static const ParsedAttrInfoObjCGC Instance; |
||
| 10321 | }; |
||
| 10322 | const ParsedAttrInfoObjCGC ParsedAttrInfoObjCGC::Instance; |
||
| 10323 | static constexpr ParsedAttrInfo::Spelling ObjCIndependentClassSpellings[] = { |
||
| 10324 | {AttributeCommonInfo::AS_GNU, "objc_independent_class"}, |
||
| 10325 | {AttributeCommonInfo::AS_CXX11, "clang::objc_independent_class"}, |
||
| 10326 | {AttributeCommonInfo::AS_C2x, "clang::objc_independent_class"}, |
||
| 10327 | }; |
||
| 10328 | struct ParsedAttrInfoObjCIndependentClass final : public ParsedAttrInfo { |
||
| 10329 | constexpr ParsedAttrInfoObjCIndependentClass() : ParsedAttrInfo( |
||
| 10330 | /*AttrKind=*/ParsedAttr::AT_ObjCIndependentClass, |
||
| 10331 | /*NumArgs=*/0, |
||
| 10332 | /*OptArgs=*/0, |
||
| 10333 | /*NumArgMembers=*/0, |
||
| 10334 | /*HasCustomParsing=*/0, |
||
| 10335 | /*AcceptsExprPack=*/0, |
||
| 10336 | /*IsTargetSpecific=*/0, |
||
| 10337 | /*IsType=*/0, |
||
| 10338 | /*IsStmt=*/0, |
||
| 10339 | /*IsKnownToGCC=*/0, |
||
| 10340 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 10341 | /*Spellings=*/ObjCIndependentClassSpellings, |
||
| 10342 | /*ArgNames=*/{}) {} |
||
| 10343 | bool isParamExpr(size_t N) const override { |
||
| 10344 | return false; |
||
| 10345 | } |
||
| 10346 | |||
| 10347 | static const ParsedAttrInfoObjCIndependentClass Instance; |
||
| 10348 | }; |
||
| 10349 | const ParsedAttrInfoObjCIndependentClass ParsedAttrInfoObjCIndependentClass::Instance; |
||
| 10350 | static constexpr ParsedAttrInfo::Spelling ObjCInertUnsafeUnretainedSpellings[] = { |
||
| 10351 | {AttributeCommonInfo::AS_Keyword, "__unsafe_unretained"}, |
||
| 10352 | }; |
||
| 10353 | struct ParsedAttrInfoObjCInertUnsafeUnretained final : public ParsedAttrInfo { |
||
| 10354 | constexpr ParsedAttrInfoObjCInertUnsafeUnretained() : ParsedAttrInfo( |
||
| 10355 | /*AttrKind=*/ParsedAttr::AT_ObjCInertUnsafeUnretained, |
||
| 10356 | /*NumArgs=*/0, |
||
| 10357 | /*OptArgs=*/0, |
||
| 10358 | /*NumArgMembers=*/0, |
||
| 10359 | /*HasCustomParsing=*/0, |
||
| 10360 | /*AcceptsExprPack=*/0, |
||
| 10361 | /*IsTargetSpecific=*/0, |
||
| 10362 | /*IsType=*/1, |
||
| 10363 | /*IsStmt=*/0, |
||
| 10364 | /*IsKnownToGCC=*/0, |
||
| 10365 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 10366 | /*Spellings=*/ObjCInertUnsafeUnretainedSpellings, |
||
| 10367 | /*ArgNames=*/{}) {} |
||
| 10368 | bool isParamExpr(size_t N) const override { |
||
| 10369 | return false; |
||
| 10370 | } |
||
| 10371 | |||
| 10372 | static const ParsedAttrInfoObjCInertUnsafeUnretained Instance; |
||
| 10373 | }; |
||
| 10374 | const ParsedAttrInfoObjCInertUnsafeUnretained ParsedAttrInfoObjCInertUnsafeUnretained::Instance; |
||
| 10375 | static constexpr ParsedAttrInfo::Spelling ObjCKindOfSpellings[] = { |
||
| 10376 | {AttributeCommonInfo::AS_Keyword, "__kindof"}, |
||
| 10377 | }; |
||
| 10378 | struct ParsedAttrInfoObjCKindOf final : public ParsedAttrInfo { |
||
| 10379 | constexpr ParsedAttrInfoObjCKindOf() : ParsedAttrInfo( |
||
| 10380 | /*AttrKind=*/ParsedAttr::AT_ObjCKindOf, |
||
| 10381 | /*NumArgs=*/0, |
||
| 10382 | /*OptArgs=*/0, |
||
| 10383 | /*NumArgMembers=*/0, |
||
| 10384 | /*HasCustomParsing=*/0, |
||
| 10385 | /*AcceptsExprPack=*/0, |
||
| 10386 | /*IsTargetSpecific=*/0, |
||
| 10387 | /*IsType=*/1, |
||
| 10388 | /*IsStmt=*/0, |
||
| 10389 | /*IsKnownToGCC=*/0, |
||
| 10390 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 10391 | /*Spellings=*/ObjCKindOfSpellings, |
||
| 10392 | /*ArgNames=*/{}) {} |
||
| 10393 | bool isParamExpr(size_t N) const override { |
||
| 10394 | return false; |
||
| 10395 | } |
||
| 10396 | |||
| 10397 | static const ParsedAttrInfoObjCKindOf Instance; |
||
| 10398 | }; |
||
| 10399 | const ParsedAttrInfoObjCKindOf ParsedAttrInfoObjCKindOf::Instance; |
||
| 10400 | static constexpr ParsedAttrInfo::Spelling ObjCMethodFamilySpellings[] = { |
||
| 10401 | {AttributeCommonInfo::AS_GNU, "objc_method_family"}, |
||
| 10402 | {AttributeCommonInfo::AS_CXX11, "clang::objc_method_family"}, |
||
| 10403 | {AttributeCommonInfo::AS_C2x, "clang::objc_method_family"}, |
||
| 10404 | }; |
||
| 10405 | static constexpr const char *ObjCMethodFamilyArgNames[] = { |
||
| 10406 | "Family",}; |
||
| 10407 | struct ParsedAttrInfoObjCMethodFamily final : public ParsedAttrInfo { |
||
| 10408 | constexpr ParsedAttrInfoObjCMethodFamily() : ParsedAttrInfo( |
||
| 10409 | /*AttrKind=*/ParsedAttr::AT_ObjCMethodFamily, |
||
| 10410 | /*NumArgs=*/1, |
||
| 10411 | /*OptArgs=*/0, |
||
| 10412 | /*NumArgMembers=*/1, |
||
| 10413 | /*HasCustomParsing=*/0, |
||
| 10414 | /*AcceptsExprPack=*/0, |
||
| 10415 | /*IsTargetSpecific=*/0, |
||
| 10416 | /*IsType=*/0, |
||
| 10417 | /*IsStmt=*/0, |
||
| 10418 | /*IsKnownToGCC=*/0, |
||
| 10419 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 10420 | /*Spellings=*/ObjCMethodFamilySpellings, |
||
| 10421 | /*ArgNames=*/ObjCMethodFamilyArgNames) {} |
||
| 10422 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 10423 | if (!isa<ObjCMethodDecl>(D)) { |
||
| 10424 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 10425 | << Attr << "Objective-C methods"; |
||
| 10426 | return false; |
||
| 10427 | } |
||
| 10428 | return true; |
||
| 10429 | } |
||
| 10430 | |||
| 10431 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 10432 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 10433 | << AL << St->getBeginLoc(); |
||
| 10434 | return false; |
||
| 10435 | } |
||
| 10436 | |||
| 10437 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 10438 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 10439 | } |
||
| 10440 | |||
| 10441 | bool isParamExpr(size_t N) const override { |
||
| 10442 | return false; |
||
| 10443 | } |
||
| 10444 | |||
| 10445 | static const ParsedAttrInfoObjCMethodFamily Instance; |
||
| 10446 | }; |
||
| 10447 | const ParsedAttrInfoObjCMethodFamily ParsedAttrInfoObjCMethodFamily::Instance; |
||
| 10448 | static constexpr ParsedAttrInfo::Spelling ObjCNSObjectSpellings[] = { |
||
| 10449 | {AttributeCommonInfo::AS_GNU, "NSObject"}, |
||
| 10450 | {AttributeCommonInfo::AS_CXX11, "clang::NSObject"}, |
||
| 10451 | {AttributeCommonInfo::AS_C2x, "clang::NSObject"}, |
||
| 10452 | }; |
||
| 10453 | struct ParsedAttrInfoObjCNSObject final : public ParsedAttrInfo { |
||
| 10454 | constexpr ParsedAttrInfoObjCNSObject() : ParsedAttrInfo( |
||
| 10455 | /*AttrKind=*/ParsedAttr::AT_ObjCNSObject, |
||
| 10456 | /*NumArgs=*/0, |
||
| 10457 | /*OptArgs=*/0, |
||
| 10458 | /*NumArgMembers=*/0, |
||
| 10459 | /*HasCustomParsing=*/0, |
||
| 10460 | /*AcceptsExprPack=*/0, |
||
| 10461 | /*IsTargetSpecific=*/0, |
||
| 10462 | /*IsType=*/0, |
||
| 10463 | /*IsStmt=*/0, |
||
| 10464 | /*IsKnownToGCC=*/0, |
||
| 10465 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 10466 | /*Spellings=*/ObjCNSObjectSpellings, |
||
| 10467 | /*ArgNames=*/{}) {} |
||
| 10468 | bool isParamExpr(size_t N) const override { |
||
| 10469 | return false; |
||
| 10470 | } |
||
| 10471 | |||
| 10472 | static const ParsedAttrInfoObjCNSObject Instance; |
||
| 10473 | }; |
||
| 10474 | const ParsedAttrInfoObjCNSObject ParsedAttrInfoObjCNSObject::Instance; |
||
| 10475 | static constexpr ParsedAttrInfo::Spelling ObjCNonLazyClassSpellings[] = { |
||
| 10476 | {AttributeCommonInfo::AS_GNU, "objc_nonlazy_class"}, |
||
| 10477 | {AttributeCommonInfo::AS_CXX11, "clang::objc_nonlazy_class"}, |
||
| 10478 | {AttributeCommonInfo::AS_C2x, "clang::objc_nonlazy_class"}, |
||
| 10479 | }; |
||
| 10480 | struct ParsedAttrInfoObjCNonLazyClass final : public ParsedAttrInfo { |
||
| 10481 | constexpr ParsedAttrInfoObjCNonLazyClass() : ParsedAttrInfo( |
||
| 10482 | /*AttrKind=*/ParsedAttr::AT_ObjCNonLazyClass, |
||
| 10483 | /*NumArgs=*/0, |
||
| 10484 | /*OptArgs=*/0, |
||
| 10485 | /*NumArgMembers=*/0, |
||
| 10486 | /*HasCustomParsing=*/0, |
||
| 10487 | /*AcceptsExprPack=*/0, |
||
| 10488 | /*IsTargetSpecific=*/0, |
||
| 10489 | /*IsType=*/0, |
||
| 10490 | /*IsStmt=*/0, |
||
| 10491 | /*IsKnownToGCC=*/0, |
||
| 10492 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 10493 | /*Spellings=*/ObjCNonLazyClassSpellings, |
||
| 10494 | /*ArgNames=*/{}) {} |
||
| 10495 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 10496 | if (!isa<ObjCInterfaceDecl>(D) && !isa<ObjCImplDecl>(D)) { |
||
| 10497 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 10498 | << Attr << "Objective-C interfaces and Objective-C implementation declarations"; |
||
| 10499 | return false; |
||
| 10500 | } |
||
| 10501 | return true; |
||
| 10502 | } |
||
| 10503 | |||
| 10504 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 10505 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 10506 | << AL << St->getBeginLoc(); |
||
| 10507 | return false; |
||
| 10508 | } |
||
| 10509 | |||
| 10510 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 10511 | return LangOpts.ObjC; |
||
| 10512 | } |
||
| 10513 | |||
| 10514 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 10515 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
||
| 10516 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_implementation, /*IsSupported=*/LangOpts.ObjC)); |
||
| 10517 | } |
||
| 10518 | |||
| 10519 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 10520 | D->addAttr(::new (S.Context) ObjCNonLazyClassAttr(S.Context, Attr)); |
||
| 10521 | return AttributeApplied; |
||
| 10522 | } |
||
| 10523 | |||
| 10524 | bool isParamExpr(size_t N) const override { |
||
| 10525 | return false; |
||
| 10526 | } |
||
| 10527 | |||
| 10528 | static const ParsedAttrInfoObjCNonLazyClass Instance; |
||
| 10529 | }; |
||
| 10530 | const ParsedAttrInfoObjCNonLazyClass ParsedAttrInfoObjCNonLazyClass::Instance; |
||
| 10531 | static constexpr ParsedAttrInfo::Spelling ObjCNonRuntimeProtocolSpellings[] = { |
||
| 10532 | {AttributeCommonInfo::AS_GNU, "objc_non_runtime_protocol"}, |
||
| 10533 | {AttributeCommonInfo::AS_CXX11, "clang::objc_non_runtime_protocol"}, |
||
| 10534 | {AttributeCommonInfo::AS_C2x, "clang::objc_non_runtime_protocol"}, |
||
| 10535 | }; |
||
| 10536 | struct ParsedAttrInfoObjCNonRuntimeProtocol final : public ParsedAttrInfo { |
||
| 10537 | constexpr ParsedAttrInfoObjCNonRuntimeProtocol() : ParsedAttrInfo( |
||
| 10538 | /*AttrKind=*/ParsedAttr::AT_ObjCNonRuntimeProtocol, |
||
| 10539 | /*NumArgs=*/0, |
||
| 10540 | /*OptArgs=*/0, |
||
| 10541 | /*NumArgMembers=*/0, |
||
| 10542 | /*HasCustomParsing=*/0, |
||
| 10543 | /*AcceptsExprPack=*/0, |
||
| 10544 | /*IsTargetSpecific=*/0, |
||
| 10545 | /*IsType=*/0, |
||
| 10546 | /*IsStmt=*/0, |
||
| 10547 | /*IsKnownToGCC=*/0, |
||
| 10548 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 10549 | /*Spellings=*/ObjCNonRuntimeProtocolSpellings, |
||
| 10550 | /*ArgNames=*/{}) {} |
||
| 10551 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 10552 | if (!isa<ObjCProtocolDecl>(D)) { |
||
| 10553 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 10554 | << Attr << "Objective-C protocols"; |
||
| 10555 | return false; |
||
| 10556 | } |
||
| 10557 | return true; |
||
| 10558 | } |
||
| 10559 | |||
| 10560 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 10561 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 10562 | << AL << St->getBeginLoc(); |
||
| 10563 | return false; |
||
| 10564 | } |
||
| 10565 | |||
| 10566 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 10567 | return LangOpts.ObjC; |
||
| 10568 | } |
||
| 10569 | |||
| 10570 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 10571 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_protocol, /*IsSupported=*/LangOpts.ObjC)); |
||
| 10572 | } |
||
| 10573 | |||
| 10574 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 10575 | D->addAttr(::new (S.Context) ObjCNonRuntimeProtocolAttr(S.Context, Attr)); |
||
| 10576 | return AttributeApplied; |
||
| 10577 | } |
||
| 10578 | |||
| 10579 | bool isParamExpr(size_t N) const override { |
||
| 10580 | return false; |
||
| 10581 | } |
||
| 10582 | |||
| 10583 | static const ParsedAttrInfoObjCNonRuntimeProtocol Instance; |
||
| 10584 | }; |
||
| 10585 | const ParsedAttrInfoObjCNonRuntimeProtocol ParsedAttrInfoObjCNonRuntimeProtocol::Instance; |
||
| 10586 | static constexpr ParsedAttrInfo::Spelling ObjCOwnershipSpellings[] = { |
||
| 10587 | {AttributeCommonInfo::AS_GNU, "objc_ownership"}, |
||
| 10588 | {AttributeCommonInfo::AS_CXX11, "clang::objc_ownership"}, |
||
| 10589 | {AttributeCommonInfo::AS_C2x, "clang::objc_ownership"}, |
||
| 10590 | }; |
||
| 10591 | static constexpr const char *ObjCOwnershipArgNames[] = { |
||
| 10592 | "Kind",}; |
||
| 10593 | struct ParsedAttrInfoObjCOwnership final : public ParsedAttrInfo { |
||
| 10594 | constexpr ParsedAttrInfoObjCOwnership() : ParsedAttrInfo( |
||
| 10595 | /*AttrKind=*/ParsedAttr::AT_ObjCOwnership, |
||
| 10596 | /*NumArgs=*/1, |
||
| 10597 | /*OptArgs=*/0, |
||
| 10598 | /*NumArgMembers=*/1, |
||
| 10599 | /*HasCustomParsing=*/0, |
||
| 10600 | /*AcceptsExprPack=*/0, |
||
| 10601 | /*IsTargetSpecific=*/0, |
||
| 10602 | /*IsType=*/1, |
||
| 10603 | /*IsStmt=*/0, |
||
| 10604 | /*IsKnownToGCC=*/0, |
||
| 10605 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 10606 | /*Spellings=*/ObjCOwnershipSpellings, |
||
| 10607 | /*ArgNames=*/ObjCOwnershipArgNames) {} |
||
| 10608 | bool isParamExpr(size_t N) const override { |
||
| 10609 | return false; |
||
| 10610 | } |
||
| 10611 | |||
| 10612 | static const ParsedAttrInfoObjCOwnership Instance; |
||
| 10613 | }; |
||
| 10614 | const ParsedAttrInfoObjCOwnership ParsedAttrInfoObjCOwnership::Instance; |
||
| 10615 | static constexpr ParsedAttrInfo::Spelling ObjCPreciseLifetimeSpellings[] = { |
||
| 10616 | {AttributeCommonInfo::AS_GNU, "objc_precise_lifetime"}, |
||
| 10617 | {AttributeCommonInfo::AS_CXX11, "clang::objc_precise_lifetime"}, |
||
| 10618 | {AttributeCommonInfo::AS_C2x, "clang::objc_precise_lifetime"}, |
||
| 10619 | }; |
||
| 10620 | struct ParsedAttrInfoObjCPreciseLifetime final : public ParsedAttrInfo { |
||
| 10621 | constexpr ParsedAttrInfoObjCPreciseLifetime() : ParsedAttrInfo( |
||
| 10622 | /*AttrKind=*/ParsedAttr::AT_ObjCPreciseLifetime, |
||
| 10623 | /*NumArgs=*/0, |
||
| 10624 | /*OptArgs=*/0, |
||
| 10625 | /*NumArgMembers=*/0, |
||
| 10626 | /*HasCustomParsing=*/0, |
||
| 10627 | /*AcceptsExprPack=*/0, |
||
| 10628 | /*IsTargetSpecific=*/0, |
||
| 10629 | /*IsType=*/0, |
||
| 10630 | /*IsStmt=*/0, |
||
| 10631 | /*IsKnownToGCC=*/0, |
||
| 10632 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 10633 | /*Spellings=*/ObjCPreciseLifetimeSpellings, |
||
| 10634 | /*ArgNames=*/{}) {} |
||
| 10635 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 10636 | if (!isa<VarDecl>(D)) { |
||
| 10637 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 10638 | << Attr << "variables"; |
||
| 10639 | return false; |
||
| 10640 | } |
||
| 10641 | return true; |
||
| 10642 | } |
||
| 10643 | |||
| 10644 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 10645 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 10646 | << AL << St->getBeginLoc(); |
||
| 10647 | return false; |
||
| 10648 | } |
||
| 10649 | |||
| 10650 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 10651 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
||
| 10652 | } |
||
| 10653 | |||
| 10654 | bool isParamExpr(size_t N) const override { |
||
| 10655 | return false; |
||
| 10656 | } |
||
| 10657 | |||
| 10658 | static const ParsedAttrInfoObjCPreciseLifetime Instance; |
||
| 10659 | }; |
||
| 10660 | const ParsedAttrInfoObjCPreciseLifetime ParsedAttrInfoObjCPreciseLifetime::Instance; |
||
| 10661 | static constexpr ParsedAttrInfo::Spelling ObjCRequiresPropertyDefsSpellings[] = { |
||
| 10662 | {AttributeCommonInfo::AS_GNU, "objc_requires_property_definitions"}, |
||
| 10663 | {AttributeCommonInfo::AS_CXX11, "clang::objc_requires_property_definitions"}, |
||
| 10664 | {AttributeCommonInfo::AS_C2x, "clang::objc_requires_property_definitions"}, |
||
| 10665 | }; |
||
| 10666 | struct ParsedAttrInfoObjCRequiresPropertyDefs final : public ParsedAttrInfo { |
||
| 10667 | constexpr ParsedAttrInfoObjCRequiresPropertyDefs() : ParsedAttrInfo( |
||
| 10668 | /*AttrKind=*/ParsedAttr::AT_ObjCRequiresPropertyDefs, |
||
| 10669 | /*NumArgs=*/0, |
||
| 10670 | /*OptArgs=*/0, |
||
| 10671 | /*NumArgMembers=*/0, |
||
| 10672 | /*HasCustomParsing=*/0, |
||
| 10673 | /*AcceptsExprPack=*/0, |
||
| 10674 | /*IsTargetSpecific=*/0, |
||
| 10675 | /*IsType=*/0, |
||
| 10676 | /*IsStmt=*/0, |
||
| 10677 | /*IsKnownToGCC=*/0, |
||
| 10678 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 10679 | /*Spellings=*/ObjCRequiresPropertyDefsSpellings, |
||
| 10680 | /*ArgNames=*/{}) {} |
||
| 10681 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 10682 | if (!isa<ObjCInterfaceDecl>(D)) { |
||
| 10683 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 10684 | << Attr << "Objective-C interfaces"; |
||
| 10685 | return false; |
||
| 10686 | } |
||
| 10687 | return true; |
||
| 10688 | } |
||
| 10689 | |||
| 10690 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 10691 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 10692 | << AL << St->getBeginLoc(); |
||
| 10693 | return false; |
||
| 10694 | } |
||
| 10695 | |||
| 10696 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 10697 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
||
| 10698 | } |
||
| 10699 | |||
| 10700 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 10701 | D->addAttr(::new (S.Context) ObjCRequiresPropertyDefsAttr(S.Context, Attr)); |
||
| 10702 | return AttributeApplied; |
||
| 10703 | } |
||
| 10704 | |||
| 10705 | bool isParamExpr(size_t N) const override { |
||
| 10706 | return false; |
||
| 10707 | } |
||
| 10708 | |||
| 10709 | static const ParsedAttrInfoObjCRequiresPropertyDefs Instance; |
||
| 10710 | }; |
||
| 10711 | const ParsedAttrInfoObjCRequiresPropertyDefs ParsedAttrInfoObjCRequiresPropertyDefs::Instance; |
||
| 10712 | static constexpr ParsedAttrInfo::Spelling ObjCRequiresSuperSpellings[] = { |
||
| 10713 | {AttributeCommonInfo::AS_GNU, "objc_requires_super"}, |
||
| 10714 | {AttributeCommonInfo::AS_CXX11, "clang::objc_requires_super"}, |
||
| 10715 | {AttributeCommonInfo::AS_C2x, "clang::objc_requires_super"}, |
||
| 10716 | }; |
||
| 10717 | struct ParsedAttrInfoObjCRequiresSuper final : public ParsedAttrInfo { |
||
| 10718 | constexpr ParsedAttrInfoObjCRequiresSuper() : ParsedAttrInfo( |
||
| 10719 | /*AttrKind=*/ParsedAttr::AT_ObjCRequiresSuper, |
||
| 10720 | /*NumArgs=*/0, |
||
| 10721 | /*OptArgs=*/0, |
||
| 10722 | /*NumArgMembers=*/0, |
||
| 10723 | /*HasCustomParsing=*/0, |
||
| 10724 | /*AcceptsExprPack=*/0, |
||
| 10725 | /*IsTargetSpecific=*/0, |
||
| 10726 | /*IsType=*/0, |
||
| 10727 | /*IsStmt=*/0, |
||
| 10728 | /*IsKnownToGCC=*/0, |
||
| 10729 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 10730 | /*Spellings=*/ObjCRequiresSuperSpellings, |
||
| 10731 | /*ArgNames=*/{}) {} |
||
| 10732 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 10733 | if (!isa<ObjCMethodDecl>(D)) { |
||
| 10734 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 10735 | << Attr << "Objective-C methods"; |
||
| 10736 | return false; |
||
| 10737 | } |
||
| 10738 | return true; |
||
| 10739 | } |
||
| 10740 | |||
| 10741 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 10742 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 10743 | << AL << St->getBeginLoc(); |
||
| 10744 | return false; |
||
| 10745 | } |
||
| 10746 | |||
| 10747 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 10748 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 10749 | } |
||
| 10750 | |||
| 10751 | bool isParamExpr(size_t N) const override { |
||
| 10752 | return false; |
||
| 10753 | } |
||
| 10754 | |||
| 10755 | static const ParsedAttrInfoObjCRequiresSuper Instance; |
||
| 10756 | }; |
||
| 10757 | const ParsedAttrInfoObjCRequiresSuper ParsedAttrInfoObjCRequiresSuper::Instance; |
||
| 10758 | static constexpr ParsedAttrInfo::Spelling ObjCReturnsInnerPointerSpellings[] = { |
||
| 10759 | {AttributeCommonInfo::AS_GNU, "objc_returns_inner_pointer"}, |
||
| 10760 | {AttributeCommonInfo::AS_CXX11, "clang::objc_returns_inner_pointer"}, |
||
| 10761 | {AttributeCommonInfo::AS_C2x, "clang::objc_returns_inner_pointer"}, |
||
| 10762 | }; |
||
| 10763 | struct ParsedAttrInfoObjCReturnsInnerPointer final : public ParsedAttrInfo { |
||
| 10764 | constexpr ParsedAttrInfoObjCReturnsInnerPointer() : ParsedAttrInfo( |
||
| 10765 | /*AttrKind=*/ParsedAttr::AT_ObjCReturnsInnerPointer, |
||
| 10766 | /*NumArgs=*/0, |
||
| 10767 | /*OptArgs=*/0, |
||
| 10768 | /*NumArgMembers=*/0, |
||
| 10769 | /*HasCustomParsing=*/0, |
||
| 10770 | /*AcceptsExprPack=*/0, |
||
| 10771 | /*IsTargetSpecific=*/0, |
||
| 10772 | /*IsType=*/0, |
||
| 10773 | /*IsStmt=*/0, |
||
| 10774 | /*IsKnownToGCC=*/0, |
||
| 10775 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 10776 | /*Spellings=*/ObjCReturnsInnerPointerSpellings, |
||
| 10777 | /*ArgNames=*/{}) {} |
||
| 10778 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 10779 | if (!isa<ObjCMethodDecl>(D) && !isa<ObjCPropertyDecl>(D)) { |
||
| 10780 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 10781 | << Attr << "Objective-C methods and Objective-C properties"; |
||
| 10782 | return false; |
||
| 10783 | } |
||
| 10784 | return true; |
||
| 10785 | } |
||
| 10786 | |||
| 10787 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 10788 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 10789 | << AL << St->getBeginLoc(); |
||
| 10790 | return false; |
||
| 10791 | } |
||
| 10792 | |||
| 10793 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 10794 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 10795 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_property, /*IsSupported=*/LangOpts.ObjC)); |
||
| 10796 | } |
||
| 10797 | |||
| 10798 | bool isParamExpr(size_t N) const override { |
||
| 10799 | return false; |
||
| 10800 | } |
||
| 10801 | |||
| 10802 | static const ParsedAttrInfoObjCReturnsInnerPointer Instance; |
||
| 10803 | }; |
||
| 10804 | const ParsedAttrInfoObjCReturnsInnerPointer ParsedAttrInfoObjCReturnsInnerPointer::Instance; |
||
| 10805 | static constexpr ParsedAttrInfo::Spelling ObjCRootClassSpellings[] = { |
||
| 10806 | {AttributeCommonInfo::AS_GNU, "objc_root_class"}, |
||
| 10807 | {AttributeCommonInfo::AS_CXX11, "clang::objc_root_class"}, |
||
| 10808 | {AttributeCommonInfo::AS_C2x, "clang::objc_root_class"}, |
||
| 10809 | }; |
||
| 10810 | struct ParsedAttrInfoObjCRootClass final : public ParsedAttrInfo { |
||
| 10811 | constexpr ParsedAttrInfoObjCRootClass() : ParsedAttrInfo( |
||
| 10812 | /*AttrKind=*/ParsedAttr::AT_ObjCRootClass, |
||
| 10813 | /*NumArgs=*/0, |
||
| 10814 | /*OptArgs=*/0, |
||
| 10815 | /*NumArgMembers=*/0, |
||
| 10816 | /*HasCustomParsing=*/0, |
||
| 10817 | /*AcceptsExprPack=*/0, |
||
| 10818 | /*IsTargetSpecific=*/0, |
||
| 10819 | /*IsType=*/0, |
||
| 10820 | /*IsStmt=*/0, |
||
| 10821 | /*IsKnownToGCC=*/0, |
||
| 10822 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 10823 | /*Spellings=*/ObjCRootClassSpellings, |
||
| 10824 | /*ArgNames=*/{}) {} |
||
| 10825 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 10826 | if (!isa<ObjCInterfaceDecl>(D)) { |
||
| 10827 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 10828 | << Attr << "Objective-C interfaces"; |
||
| 10829 | return false; |
||
| 10830 | } |
||
| 10831 | return true; |
||
| 10832 | } |
||
| 10833 | |||
| 10834 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 10835 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 10836 | << AL << St->getBeginLoc(); |
||
| 10837 | return false; |
||
| 10838 | } |
||
| 10839 | |||
| 10840 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 10841 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
||
| 10842 | } |
||
| 10843 | |||
| 10844 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 10845 | D->addAttr(::new (S.Context) ObjCRootClassAttr(S.Context, Attr)); |
||
| 10846 | return AttributeApplied; |
||
| 10847 | } |
||
| 10848 | |||
| 10849 | bool isParamExpr(size_t N) const override { |
||
| 10850 | return false; |
||
| 10851 | } |
||
| 10852 | |||
| 10853 | static const ParsedAttrInfoObjCRootClass Instance; |
||
| 10854 | }; |
||
| 10855 | const ParsedAttrInfoObjCRootClass ParsedAttrInfoObjCRootClass::Instance; |
||
| 10856 | static constexpr ParsedAttrInfo::Spelling ObjCRuntimeNameSpellings[] = { |
||
| 10857 | {AttributeCommonInfo::AS_GNU, "objc_runtime_name"}, |
||
| 10858 | {AttributeCommonInfo::AS_CXX11, "clang::objc_runtime_name"}, |
||
| 10859 | {AttributeCommonInfo::AS_C2x, "clang::objc_runtime_name"}, |
||
| 10860 | }; |
||
| 10861 | static constexpr const char *ObjCRuntimeNameArgNames[] = { |
||
| 10862 | "MetadataName",}; |
||
| 10863 | struct ParsedAttrInfoObjCRuntimeName final : public ParsedAttrInfo { |
||
| 10864 | constexpr ParsedAttrInfoObjCRuntimeName() : ParsedAttrInfo( |
||
| 10865 | /*AttrKind=*/ParsedAttr::AT_ObjCRuntimeName, |
||
| 10866 | /*NumArgs=*/1, |
||
| 10867 | /*OptArgs=*/0, |
||
| 10868 | /*NumArgMembers=*/1, |
||
| 10869 | /*HasCustomParsing=*/0, |
||
| 10870 | /*AcceptsExprPack=*/0, |
||
| 10871 | /*IsTargetSpecific=*/0, |
||
| 10872 | /*IsType=*/0, |
||
| 10873 | /*IsStmt=*/0, |
||
| 10874 | /*IsKnownToGCC=*/0, |
||
| 10875 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 10876 | /*Spellings=*/ObjCRuntimeNameSpellings, |
||
| 10877 | /*ArgNames=*/ObjCRuntimeNameArgNames) {} |
||
| 10878 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 10879 | if (!isa<ObjCInterfaceDecl>(D) && !isa<ObjCProtocolDecl>(D)) { |
||
| 10880 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 10881 | << Attr << "Objective-C interfaces and Objective-C protocols"; |
||
| 10882 | return false; |
||
| 10883 | } |
||
| 10884 | return true; |
||
| 10885 | } |
||
| 10886 | |||
| 10887 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 10888 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 10889 | << AL << St->getBeginLoc(); |
||
| 10890 | return false; |
||
| 10891 | } |
||
| 10892 | |||
| 10893 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 10894 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
||
| 10895 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_protocol, /*IsSupported=*/LangOpts.ObjC)); |
||
| 10896 | } |
||
| 10897 | |||
| 10898 | bool isParamExpr(size_t N) const override { |
||
| 10899 | return false; |
||
| 10900 | } |
||
| 10901 | |||
| 10902 | static const ParsedAttrInfoObjCRuntimeName Instance; |
||
| 10903 | }; |
||
| 10904 | const ParsedAttrInfoObjCRuntimeName ParsedAttrInfoObjCRuntimeName::Instance; |
||
| 10905 | static constexpr ParsedAttrInfo::Spelling ObjCRuntimeVisibleSpellings[] = { |
||
| 10906 | {AttributeCommonInfo::AS_GNU, "objc_runtime_visible"}, |
||
| 10907 | {AttributeCommonInfo::AS_CXX11, "clang::objc_runtime_visible"}, |
||
| 10908 | {AttributeCommonInfo::AS_C2x, "clang::objc_runtime_visible"}, |
||
| 10909 | }; |
||
| 10910 | struct ParsedAttrInfoObjCRuntimeVisible final : public ParsedAttrInfo { |
||
| 10911 | constexpr ParsedAttrInfoObjCRuntimeVisible() : ParsedAttrInfo( |
||
| 10912 | /*AttrKind=*/ParsedAttr::AT_ObjCRuntimeVisible, |
||
| 10913 | /*NumArgs=*/0, |
||
| 10914 | /*OptArgs=*/0, |
||
| 10915 | /*NumArgMembers=*/0, |
||
| 10916 | /*HasCustomParsing=*/0, |
||
| 10917 | /*AcceptsExprPack=*/0, |
||
| 10918 | /*IsTargetSpecific=*/0, |
||
| 10919 | /*IsType=*/0, |
||
| 10920 | /*IsStmt=*/0, |
||
| 10921 | /*IsKnownToGCC=*/0, |
||
| 10922 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 10923 | /*Spellings=*/ObjCRuntimeVisibleSpellings, |
||
| 10924 | /*ArgNames=*/{}) {} |
||
| 10925 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 10926 | if (!isa<ObjCInterfaceDecl>(D)) { |
||
| 10927 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 10928 | << Attr << "Objective-C interfaces"; |
||
| 10929 | return false; |
||
| 10930 | } |
||
| 10931 | return true; |
||
| 10932 | } |
||
| 10933 | |||
| 10934 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 10935 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 10936 | << AL << St->getBeginLoc(); |
||
| 10937 | return false; |
||
| 10938 | } |
||
| 10939 | |||
| 10940 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 10941 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
||
| 10942 | } |
||
| 10943 | |||
| 10944 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 10945 | D->addAttr(::new (S.Context) ObjCRuntimeVisibleAttr(S.Context, Attr)); |
||
| 10946 | return AttributeApplied; |
||
| 10947 | } |
||
| 10948 | |||
| 10949 | bool isParamExpr(size_t N) const override { |
||
| 10950 | return false; |
||
| 10951 | } |
||
| 10952 | |||
| 10953 | static const ParsedAttrInfoObjCRuntimeVisible Instance; |
||
| 10954 | }; |
||
| 10955 | const ParsedAttrInfoObjCRuntimeVisible ParsedAttrInfoObjCRuntimeVisible::Instance; |
||
| 10956 | static constexpr ParsedAttrInfo::Spelling ObjCSubclassingRestrictedSpellings[] = { |
||
| 10957 | {AttributeCommonInfo::AS_GNU, "objc_subclassing_restricted"}, |
||
| 10958 | {AttributeCommonInfo::AS_CXX11, "clang::objc_subclassing_restricted"}, |
||
| 10959 | {AttributeCommonInfo::AS_C2x, "clang::objc_subclassing_restricted"}, |
||
| 10960 | }; |
||
| 10961 | struct ParsedAttrInfoObjCSubclassingRestricted final : public ParsedAttrInfo { |
||
| 10962 | constexpr ParsedAttrInfoObjCSubclassingRestricted() : ParsedAttrInfo( |
||
| 10963 | /*AttrKind=*/ParsedAttr::AT_ObjCSubclassingRestricted, |
||
| 10964 | /*NumArgs=*/0, |
||
| 10965 | /*OptArgs=*/0, |
||
| 10966 | /*NumArgMembers=*/0, |
||
| 10967 | /*HasCustomParsing=*/0, |
||
| 10968 | /*AcceptsExprPack=*/0, |
||
| 10969 | /*IsTargetSpecific=*/0, |
||
| 10970 | /*IsType=*/0, |
||
| 10971 | /*IsStmt=*/0, |
||
| 10972 | /*IsKnownToGCC=*/0, |
||
| 10973 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 10974 | /*Spellings=*/ObjCSubclassingRestrictedSpellings, |
||
| 10975 | /*ArgNames=*/{}) {} |
||
| 10976 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 10977 | if (!isa<ObjCInterfaceDecl>(D)) { |
||
| 10978 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 10979 | << Attr << "Objective-C interfaces"; |
||
| 10980 | return false; |
||
| 10981 | } |
||
| 10982 | return true; |
||
| 10983 | } |
||
| 10984 | |||
| 10985 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 10986 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 10987 | << AL << St->getBeginLoc(); |
||
| 10988 | return false; |
||
| 10989 | } |
||
| 10990 | |||
| 10991 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 10992 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
||
| 10993 | } |
||
| 10994 | |||
| 10995 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 10996 | D->addAttr(::new (S.Context) ObjCSubclassingRestrictedAttr(S.Context, Attr)); |
||
| 10997 | return AttributeApplied; |
||
| 10998 | } |
||
| 10999 | |||
| 11000 | bool isParamExpr(size_t N) const override { |
||
| 11001 | return false; |
||
| 11002 | } |
||
| 11003 | |||
| 11004 | static const ParsedAttrInfoObjCSubclassingRestricted Instance; |
||
| 11005 | }; |
||
| 11006 | const ParsedAttrInfoObjCSubclassingRestricted ParsedAttrInfoObjCSubclassingRestricted::Instance; |
||
| 11007 | static constexpr ParsedAttrInfo::Spelling OpenCLAccessSpellings[] = { |
||
| 11008 | {AttributeCommonInfo::AS_Keyword, "__read_only"}, |
||
| 11009 | {AttributeCommonInfo::AS_Keyword, "read_only"}, |
||
| 11010 | {AttributeCommonInfo::AS_Keyword, "__write_only"}, |
||
| 11011 | {AttributeCommonInfo::AS_Keyword, "write_only"}, |
||
| 11012 | {AttributeCommonInfo::AS_Keyword, "__read_write"}, |
||
| 11013 | {AttributeCommonInfo::AS_Keyword, "read_write"}, |
||
| 11014 | }; |
||
| 11015 | struct ParsedAttrInfoOpenCLAccess final : public ParsedAttrInfo { |
||
| 11016 | constexpr ParsedAttrInfoOpenCLAccess() : ParsedAttrInfo( |
||
| 11017 | /*AttrKind=*/ParsedAttr::AT_OpenCLAccess, |
||
| 11018 | /*NumArgs=*/0, |
||
| 11019 | /*OptArgs=*/0, |
||
| 11020 | /*NumArgMembers=*/0, |
||
| 11021 | /*HasCustomParsing=*/0, |
||
| 11022 | /*AcceptsExprPack=*/0, |
||
| 11023 | /*IsTargetSpecific=*/0, |
||
| 11024 | /*IsType=*/0, |
||
| 11025 | /*IsStmt=*/0, |
||
| 11026 | /*IsKnownToGCC=*/0, |
||
| 11027 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 11028 | /*Spellings=*/OpenCLAccessSpellings, |
||
| 11029 | /*ArgNames=*/{}) {} |
||
| 11030 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 11031 | if (!isa<ParmVarDecl>(D) && !isa<TypedefNameDecl>(D)) { |
||
| 11032 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 11033 | << Attr << "parameters and typedefs"; |
||
| 11034 | return false; |
||
| 11035 | } |
||
| 11036 | return true; |
||
| 11037 | } |
||
| 11038 | |||
| 11039 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 11040 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 11041 | << AL << St->getBeginLoc(); |
||
| 11042 | return false; |
||
| 11043 | } |
||
| 11044 | |||
| 11045 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 11046 | enum Spelling { |
||
| 11047 | Keyword_read_only = 0, |
||
| 11048 | Keyword_write_only = 2, |
||
| 11049 | Keyword_read_write = 4, |
||
| 11050 | SpellingNotCalculated = 15 |
||
| 11051 | |||
| 11052 | }; |
||
| 11053 | |||
| 11054 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 11055 | switch (Idx) { |
||
| 11056 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 11057 | case 0: return Keyword_read_only; |
||
| 11058 | case 1: return Keyword_read_only; |
||
| 11059 | case 2: return Keyword_write_only; |
||
| 11060 | case 3: return Keyword_write_only; |
||
| 11061 | case 4: return Keyword_read_write; |
||
| 11062 | case 5: return Keyword_read_write; |
||
| 11063 | } |
||
| 11064 | } |
||
| 11065 | |||
| 11066 | bool isParamExpr(size_t N) const override { |
||
| 11067 | return false; |
||
| 11068 | } |
||
| 11069 | |||
| 11070 | static const ParsedAttrInfoOpenCLAccess Instance; |
||
| 11071 | }; |
||
| 11072 | const ParsedAttrInfoOpenCLAccess ParsedAttrInfoOpenCLAccess::Instance; |
||
| 11073 | static constexpr ParsedAttrInfo::Spelling OpenCLConstantAddressSpaceSpellings[] = { |
||
| 11074 | {AttributeCommonInfo::AS_Keyword, "__constant"}, |
||
| 11075 | {AttributeCommonInfo::AS_Keyword, "constant"}, |
||
| 11076 | {AttributeCommonInfo::AS_GNU, "opencl_constant"}, |
||
| 11077 | {AttributeCommonInfo::AS_CXX11, "clang::opencl_constant"}, |
||
| 11078 | {AttributeCommonInfo::AS_C2x, "clang::opencl_constant"}, |
||
| 11079 | }; |
||
| 11080 | struct ParsedAttrInfoOpenCLConstantAddressSpace final : public ParsedAttrInfo { |
||
| 11081 | constexpr ParsedAttrInfoOpenCLConstantAddressSpace() : ParsedAttrInfo( |
||
| 11082 | /*AttrKind=*/ParsedAttr::AT_OpenCLConstantAddressSpace, |
||
| 11083 | /*NumArgs=*/0, |
||
| 11084 | /*OptArgs=*/0, |
||
| 11085 | /*NumArgMembers=*/0, |
||
| 11086 | /*HasCustomParsing=*/0, |
||
| 11087 | /*AcceptsExprPack=*/0, |
||
| 11088 | /*IsTargetSpecific=*/0, |
||
| 11089 | /*IsType=*/1, |
||
| 11090 | /*IsStmt=*/0, |
||
| 11091 | /*IsKnownToGCC=*/0, |
||
| 11092 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 11093 | /*Spellings=*/OpenCLConstantAddressSpaceSpellings, |
||
| 11094 | /*ArgNames=*/{}) {} |
||
| 11095 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 11096 | enum Spelling { |
||
| 11097 | Keyword_constant = 0, |
||
| 11098 | GNU_opencl_constant = 2, |
||
| 11099 | CXX11_clang_opencl_constant = 3, |
||
| 11100 | C2x_clang_opencl_constant = 4, |
||
| 11101 | SpellingNotCalculated = 15 |
||
| 11102 | |||
| 11103 | }; |
||
| 11104 | |||
| 11105 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 11106 | switch (Idx) { |
||
| 11107 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 11108 | case 0: return Keyword_constant; |
||
| 11109 | case 1: return Keyword_constant; |
||
| 11110 | case 2: return GNU_opencl_constant; |
||
| 11111 | case 3: return CXX11_clang_opencl_constant; |
||
| 11112 | case 4: return C2x_clang_opencl_constant; |
||
| 11113 | } |
||
| 11114 | } |
||
| 11115 | |||
| 11116 | bool isParamExpr(size_t N) const override { |
||
| 11117 | return false; |
||
| 11118 | } |
||
| 11119 | |||
| 11120 | static const ParsedAttrInfoOpenCLConstantAddressSpace Instance; |
||
| 11121 | }; |
||
| 11122 | const ParsedAttrInfoOpenCLConstantAddressSpace ParsedAttrInfoOpenCLConstantAddressSpace::Instance; |
||
| 11123 | static constexpr ParsedAttrInfo::Spelling OpenCLGenericAddressSpaceSpellings[] = { |
||
| 11124 | {AttributeCommonInfo::AS_Keyword, "__generic"}, |
||
| 11125 | {AttributeCommonInfo::AS_Keyword, "generic"}, |
||
| 11126 | {AttributeCommonInfo::AS_GNU, "opencl_generic"}, |
||
| 11127 | {AttributeCommonInfo::AS_CXX11, "clang::opencl_generic"}, |
||
| 11128 | {AttributeCommonInfo::AS_C2x, "clang::opencl_generic"}, |
||
| 11129 | }; |
||
| 11130 | struct ParsedAttrInfoOpenCLGenericAddressSpace final : public ParsedAttrInfo { |
||
| 11131 | constexpr ParsedAttrInfoOpenCLGenericAddressSpace() : ParsedAttrInfo( |
||
| 11132 | /*AttrKind=*/ParsedAttr::AT_OpenCLGenericAddressSpace, |
||
| 11133 | /*NumArgs=*/0, |
||
| 11134 | /*OptArgs=*/0, |
||
| 11135 | /*NumArgMembers=*/0, |
||
| 11136 | /*HasCustomParsing=*/0, |
||
| 11137 | /*AcceptsExprPack=*/0, |
||
| 11138 | /*IsTargetSpecific=*/0, |
||
| 11139 | /*IsType=*/1, |
||
| 11140 | /*IsStmt=*/0, |
||
| 11141 | /*IsKnownToGCC=*/0, |
||
| 11142 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 11143 | /*Spellings=*/OpenCLGenericAddressSpaceSpellings, |
||
| 11144 | /*ArgNames=*/{}) {} |
||
| 11145 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 11146 | enum Spelling { |
||
| 11147 | Keyword_generic = 0, |
||
| 11148 | GNU_opencl_generic = 2, |
||
| 11149 | CXX11_clang_opencl_generic = 3, |
||
| 11150 | C2x_clang_opencl_generic = 4, |
||
| 11151 | SpellingNotCalculated = 15 |
||
| 11152 | |||
| 11153 | }; |
||
| 11154 | |||
| 11155 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 11156 | switch (Idx) { |
||
| 11157 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 11158 | case 0: return Keyword_generic; |
||
| 11159 | case 1: return Keyword_generic; |
||
| 11160 | case 2: return GNU_opencl_generic; |
||
| 11161 | case 3: return CXX11_clang_opencl_generic; |
||
| 11162 | case 4: return C2x_clang_opencl_generic; |
||
| 11163 | } |
||
| 11164 | } |
||
| 11165 | |||
| 11166 | bool isParamExpr(size_t N) const override { |
||
| 11167 | return false; |
||
| 11168 | } |
||
| 11169 | |||
| 11170 | static const ParsedAttrInfoOpenCLGenericAddressSpace Instance; |
||
| 11171 | }; |
||
| 11172 | const ParsedAttrInfoOpenCLGenericAddressSpace ParsedAttrInfoOpenCLGenericAddressSpace::Instance; |
||
| 11173 | static constexpr ParsedAttrInfo::Spelling OpenCLGlobalAddressSpaceSpellings[] = { |
||
| 11174 | {AttributeCommonInfo::AS_Keyword, "__global"}, |
||
| 11175 | {AttributeCommonInfo::AS_Keyword, "global"}, |
||
| 11176 | {AttributeCommonInfo::AS_GNU, "opencl_global"}, |
||
| 11177 | {AttributeCommonInfo::AS_CXX11, "clang::opencl_global"}, |
||
| 11178 | {AttributeCommonInfo::AS_C2x, "clang::opencl_global"}, |
||
| 11179 | }; |
||
| 11180 | struct ParsedAttrInfoOpenCLGlobalAddressSpace final : public ParsedAttrInfo { |
||
| 11181 | constexpr ParsedAttrInfoOpenCLGlobalAddressSpace() : ParsedAttrInfo( |
||
| 11182 | /*AttrKind=*/ParsedAttr::AT_OpenCLGlobalAddressSpace, |
||
| 11183 | /*NumArgs=*/0, |
||
| 11184 | /*OptArgs=*/0, |
||
| 11185 | /*NumArgMembers=*/0, |
||
| 11186 | /*HasCustomParsing=*/0, |
||
| 11187 | /*AcceptsExprPack=*/0, |
||
| 11188 | /*IsTargetSpecific=*/0, |
||
| 11189 | /*IsType=*/1, |
||
| 11190 | /*IsStmt=*/0, |
||
| 11191 | /*IsKnownToGCC=*/0, |
||
| 11192 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 11193 | /*Spellings=*/OpenCLGlobalAddressSpaceSpellings, |
||
| 11194 | /*ArgNames=*/{}) {} |
||
| 11195 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 11196 | enum Spelling { |
||
| 11197 | Keyword_global = 0, |
||
| 11198 | GNU_opencl_global = 2, |
||
| 11199 | CXX11_clang_opencl_global = 3, |
||
| 11200 | C2x_clang_opencl_global = 4, |
||
| 11201 | SpellingNotCalculated = 15 |
||
| 11202 | |||
| 11203 | }; |
||
| 11204 | |||
| 11205 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 11206 | switch (Idx) { |
||
| 11207 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 11208 | case 0: return Keyword_global; |
||
| 11209 | case 1: return Keyword_global; |
||
| 11210 | case 2: return GNU_opencl_global; |
||
| 11211 | case 3: return CXX11_clang_opencl_global; |
||
| 11212 | case 4: return C2x_clang_opencl_global; |
||
| 11213 | } |
||
| 11214 | } |
||
| 11215 | |||
| 11216 | bool isParamExpr(size_t N) const override { |
||
| 11217 | return false; |
||
| 11218 | } |
||
| 11219 | |||
| 11220 | static const ParsedAttrInfoOpenCLGlobalAddressSpace Instance; |
||
| 11221 | }; |
||
| 11222 | const ParsedAttrInfoOpenCLGlobalAddressSpace ParsedAttrInfoOpenCLGlobalAddressSpace::Instance; |
||
| 11223 | static constexpr ParsedAttrInfo::Spelling OpenCLGlobalDeviceAddressSpaceSpellings[] = { |
||
| 11224 | {AttributeCommonInfo::AS_GNU, "opencl_global_device"}, |
||
| 11225 | {AttributeCommonInfo::AS_CXX11, "clang::opencl_global_device"}, |
||
| 11226 | {AttributeCommonInfo::AS_C2x, "clang::opencl_global_device"}, |
||
| 11227 | }; |
||
| 11228 | struct ParsedAttrInfoOpenCLGlobalDeviceAddressSpace final : public ParsedAttrInfo { |
||
| 11229 | constexpr ParsedAttrInfoOpenCLGlobalDeviceAddressSpace() : ParsedAttrInfo( |
||
| 11230 | /*AttrKind=*/ParsedAttr::AT_OpenCLGlobalDeviceAddressSpace, |
||
| 11231 | /*NumArgs=*/0, |
||
| 11232 | /*OptArgs=*/0, |
||
| 11233 | /*NumArgMembers=*/0, |
||
| 11234 | /*HasCustomParsing=*/0, |
||
| 11235 | /*AcceptsExprPack=*/0, |
||
| 11236 | /*IsTargetSpecific=*/0, |
||
| 11237 | /*IsType=*/1, |
||
| 11238 | /*IsStmt=*/0, |
||
| 11239 | /*IsKnownToGCC=*/0, |
||
| 11240 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 11241 | /*Spellings=*/OpenCLGlobalDeviceAddressSpaceSpellings, |
||
| 11242 | /*ArgNames=*/{}) {} |
||
| 11243 | bool isParamExpr(size_t N) const override { |
||
| 11244 | return false; |
||
| 11245 | } |
||
| 11246 | |||
| 11247 | static const ParsedAttrInfoOpenCLGlobalDeviceAddressSpace Instance; |
||
| 11248 | }; |
||
| 11249 | const ParsedAttrInfoOpenCLGlobalDeviceAddressSpace ParsedAttrInfoOpenCLGlobalDeviceAddressSpace::Instance; |
||
| 11250 | static constexpr ParsedAttrInfo::Spelling OpenCLGlobalHostAddressSpaceSpellings[] = { |
||
| 11251 | {AttributeCommonInfo::AS_GNU, "opencl_global_host"}, |
||
| 11252 | {AttributeCommonInfo::AS_CXX11, "clang::opencl_global_host"}, |
||
| 11253 | {AttributeCommonInfo::AS_C2x, "clang::opencl_global_host"}, |
||
| 11254 | }; |
||
| 11255 | struct ParsedAttrInfoOpenCLGlobalHostAddressSpace final : public ParsedAttrInfo { |
||
| 11256 | constexpr ParsedAttrInfoOpenCLGlobalHostAddressSpace() : ParsedAttrInfo( |
||
| 11257 | /*AttrKind=*/ParsedAttr::AT_OpenCLGlobalHostAddressSpace, |
||
| 11258 | /*NumArgs=*/0, |
||
| 11259 | /*OptArgs=*/0, |
||
| 11260 | /*NumArgMembers=*/0, |
||
| 11261 | /*HasCustomParsing=*/0, |
||
| 11262 | /*AcceptsExprPack=*/0, |
||
| 11263 | /*IsTargetSpecific=*/0, |
||
| 11264 | /*IsType=*/1, |
||
| 11265 | /*IsStmt=*/0, |
||
| 11266 | /*IsKnownToGCC=*/0, |
||
| 11267 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 11268 | /*Spellings=*/OpenCLGlobalHostAddressSpaceSpellings, |
||
| 11269 | /*ArgNames=*/{}) {} |
||
| 11270 | bool isParamExpr(size_t N) const override { |
||
| 11271 | return false; |
||
| 11272 | } |
||
| 11273 | |||
| 11274 | static const ParsedAttrInfoOpenCLGlobalHostAddressSpace Instance; |
||
| 11275 | }; |
||
| 11276 | const ParsedAttrInfoOpenCLGlobalHostAddressSpace ParsedAttrInfoOpenCLGlobalHostAddressSpace::Instance; |
||
| 11277 | static constexpr ParsedAttrInfo::Spelling OpenCLIntelReqdSubGroupSizeSpellings[] = { |
||
| 11278 | {AttributeCommonInfo::AS_GNU, "intel_reqd_sub_group_size"}, |
||
| 11279 | }; |
||
| 11280 | static constexpr const char *OpenCLIntelReqdSubGroupSizeArgNames[] = { |
||
| 11281 | "SubGroupSize",}; |
||
| 11282 | struct ParsedAttrInfoOpenCLIntelReqdSubGroupSize final : public ParsedAttrInfo { |
||
| 11283 | constexpr ParsedAttrInfoOpenCLIntelReqdSubGroupSize() : ParsedAttrInfo( |
||
| 11284 | /*AttrKind=*/ParsedAttr::AT_OpenCLIntelReqdSubGroupSize, |
||
| 11285 | /*NumArgs=*/1, |
||
| 11286 | /*OptArgs=*/0, |
||
| 11287 | /*NumArgMembers=*/1, |
||
| 11288 | /*HasCustomParsing=*/0, |
||
| 11289 | /*AcceptsExprPack=*/0, |
||
| 11290 | /*IsTargetSpecific=*/0, |
||
| 11291 | /*IsType=*/0, |
||
| 11292 | /*IsStmt=*/0, |
||
| 11293 | /*IsKnownToGCC=*/0, |
||
| 11294 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 11295 | /*Spellings=*/OpenCLIntelReqdSubGroupSizeSpellings, |
||
| 11296 | /*ArgNames=*/OpenCLIntelReqdSubGroupSizeArgNames) {} |
||
| 11297 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 11298 | if (!isa<FunctionDecl>(D)) { |
||
| 11299 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 11300 | << Attr << "functions"; |
||
| 11301 | return false; |
||
| 11302 | } |
||
| 11303 | return true; |
||
| 11304 | } |
||
| 11305 | |||
| 11306 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 11307 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 11308 | << AL << St->getBeginLoc(); |
||
| 11309 | return false; |
||
| 11310 | } |
||
| 11311 | |||
| 11312 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 11313 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 11314 | } |
||
| 11315 | |||
| 11316 | bool isParamExpr(size_t N) const override { |
||
| 11317 | return false; |
||
| 11318 | } |
||
| 11319 | |||
| 11320 | static const ParsedAttrInfoOpenCLIntelReqdSubGroupSize Instance; |
||
| 11321 | }; |
||
| 11322 | const ParsedAttrInfoOpenCLIntelReqdSubGroupSize ParsedAttrInfoOpenCLIntelReqdSubGroupSize::Instance; |
||
| 11323 | static constexpr ParsedAttrInfo::Spelling OpenCLKernelSpellings[] = { |
||
| 11324 | {AttributeCommonInfo::AS_Keyword, "__kernel"}, |
||
| 11325 | {AttributeCommonInfo::AS_Keyword, "kernel"}, |
||
| 11326 | }; |
||
| 11327 | struct ParsedAttrInfoOpenCLKernel final : public ParsedAttrInfo { |
||
| 11328 | constexpr ParsedAttrInfoOpenCLKernel() : ParsedAttrInfo( |
||
| 11329 | /*AttrKind=*/ParsedAttr::AT_OpenCLKernel, |
||
| 11330 | /*NumArgs=*/0, |
||
| 11331 | /*OptArgs=*/0, |
||
| 11332 | /*NumArgMembers=*/0, |
||
| 11333 | /*HasCustomParsing=*/0, |
||
| 11334 | /*AcceptsExprPack=*/0, |
||
| 11335 | /*IsTargetSpecific=*/0, |
||
| 11336 | /*IsType=*/0, |
||
| 11337 | /*IsStmt=*/0, |
||
| 11338 | /*IsKnownToGCC=*/0, |
||
| 11339 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 11340 | /*Spellings=*/OpenCLKernelSpellings, |
||
| 11341 | /*ArgNames=*/{}) {} |
||
| 11342 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 11343 | if (!isa<FunctionDecl>(D)) { |
||
| 11344 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 11345 | << Attr << "functions"; |
||
| 11346 | return false; |
||
| 11347 | } |
||
| 11348 | return true; |
||
| 11349 | } |
||
| 11350 | |||
| 11351 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 11352 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 11353 | << AL << St->getBeginLoc(); |
||
| 11354 | return false; |
||
| 11355 | } |
||
| 11356 | |||
| 11357 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 11358 | D->addAttr(::new (S.Context) OpenCLKernelAttr(S.Context, Attr)); |
||
| 11359 | return AttributeApplied; |
||
| 11360 | } |
||
| 11361 | |||
| 11362 | bool isParamExpr(size_t N) const override { |
||
| 11363 | return false; |
||
| 11364 | } |
||
| 11365 | |||
| 11366 | static const ParsedAttrInfoOpenCLKernel Instance; |
||
| 11367 | }; |
||
| 11368 | const ParsedAttrInfoOpenCLKernel ParsedAttrInfoOpenCLKernel::Instance; |
||
| 11369 | static constexpr ParsedAttrInfo::Spelling OpenCLLocalAddressSpaceSpellings[] = { |
||
| 11370 | {AttributeCommonInfo::AS_Keyword, "__local"}, |
||
| 11371 | {AttributeCommonInfo::AS_Keyword, "local"}, |
||
| 11372 | {AttributeCommonInfo::AS_GNU, "opencl_local"}, |
||
| 11373 | {AttributeCommonInfo::AS_CXX11, "clang::opencl_local"}, |
||
| 11374 | {AttributeCommonInfo::AS_C2x, "clang::opencl_local"}, |
||
| 11375 | }; |
||
| 11376 | struct ParsedAttrInfoOpenCLLocalAddressSpace final : public ParsedAttrInfo { |
||
| 11377 | constexpr ParsedAttrInfoOpenCLLocalAddressSpace() : ParsedAttrInfo( |
||
| 11378 | /*AttrKind=*/ParsedAttr::AT_OpenCLLocalAddressSpace, |
||
| 11379 | /*NumArgs=*/0, |
||
| 11380 | /*OptArgs=*/0, |
||
| 11381 | /*NumArgMembers=*/0, |
||
| 11382 | /*HasCustomParsing=*/0, |
||
| 11383 | /*AcceptsExprPack=*/0, |
||
| 11384 | /*IsTargetSpecific=*/0, |
||
| 11385 | /*IsType=*/1, |
||
| 11386 | /*IsStmt=*/0, |
||
| 11387 | /*IsKnownToGCC=*/0, |
||
| 11388 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 11389 | /*Spellings=*/OpenCLLocalAddressSpaceSpellings, |
||
| 11390 | /*ArgNames=*/{}) {} |
||
| 11391 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 11392 | enum Spelling { |
||
| 11393 | Keyword_local = 0, |
||
| 11394 | GNU_opencl_local = 2, |
||
| 11395 | CXX11_clang_opencl_local = 3, |
||
| 11396 | C2x_clang_opencl_local = 4, |
||
| 11397 | SpellingNotCalculated = 15 |
||
| 11398 | |||
| 11399 | }; |
||
| 11400 | |||
| 11401 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 11402 | switch (Idx) { |
||
| 11403 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 11404 | case 0: return Keyword_local; |
||
| 11405 | case 1: return Keyword_local; |
||
| 11406 | case 2: return GNU_opencl_local; |
||
| 11407 | case 3: return CXX11_clang_opencl_local; |
||
| 11408 | case 4: return C2x_clang_opencl_local; |
||
| 11409 | } |
||
| 11410 | } |
||
| 11411 | |||
| 11412 | bool isParamExpr(size_t N) const override { |
||
| 11413 | return false; |
||
| 11414 | } |
||
| 11415 | |||
| 11416 | static const ParsedAttrInfoOpenCLLocalAddressSpace Instance; |
||
| 11417 | }; |
||
| 11418 | const ParsedAttrInfoOpenCLLocalAddressSpace ParsedAttrInfoOpenCLLocalAddressSpace::Instance; |
||
| 11419 | static constexpr ParsedAttrInfo::Spelling OpenCLNoSVMSpellings[] = { |
||
| 11420 | {AttributeCommonInfo::AS_GNU, "nosvm"}, |
||
| 11421 | }; |
||
| 11422 | struct ParsedAttrInfoOpenCLNoSVM final : public ParsedAttrInfo { |
||
| 11423 | constexpr ParsedAttrInfoOpenCLNoSVM() : ParsedAttrInfo( |
||
| 11424 | /*AttrKind=*/ParsedAttr::AT_OpenCLNoSVM, |
||
| 11425 | /*NumArgs=*/0, |
||
| 11426 | /*OptArgs=*/0, |
||
| 11427 | /*NumArgMembers=*/0, |
||
| 11428 | /*HasCustomParsing=*/0, |
||
| 11429 | /*AcceptsExprPack=*/0, |
||
| 11430 | /*IsTargetSpecific=*/0, |
||
| 11431 | /*IsType=*/0, |
||
| 11432 | /*IsStmt=*/0, |
||
| 11433 | /*IsKnownToGCC=*/0, |
||
| 11434 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 11435 | /*Spellings=*/OpenCLNoSVMSpellings, |
||
| 11436 | /*ArgNames=*/{}) {} |
||
| 11437 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 11438 | if (!isa<VarDecl>(D)) { |
||
| 11439 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 11440 | << Attr << "variables"; |
||
| 11441 | return false; |
||
| 11442 | } |
||
| 11443 | return true; |
||
| 11444 | } |
||
| 11445 | |||
| 11446 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 11447 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 11448 | << AL << St->getBeginLoc(); |
||
| 11449 | return false; |
||
| 11450 | } |
||
| 11451 | |||
| 11452 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 11453 | return LangOpts.OpenCL; |
||
| 11454 | } |
||
| 11455 | |||
| 11456 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 11457 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
||
| 11458 | } |
||
| 11459 | |||
| 11460 | bool isParamExpr(size_t N) const override { |
||
| 11461 | return false; |
||
| 11462 | } |
||
| 11463 | |||
| 11464 | static const ParsedAttrInfoOpenCLNoSVM Instance; |
||
| 11465 | }; |
||
| 11466 | const ParsedAttrInfoOpenCLNoSVM ParsedAttrInfoOpenCLNoSVM::Instance; |
||
| 11467 | static constexpr ParsedAttrInfo::Spelling OpenCLPrivateAddressSpaceSpellings[] = { |
||
| 11468 | {AttributeCommonInfo::AS_Keyword, "__private"}, |
||
| 11469 | {AttributeCommonInfo::AS_Keyword, "private"}, |
||
| 11470 | {AttributeCommonInfo::AS_GNU, "opencl_private"}, |
||
| 11471 | {AttributeCommonInfo::AS_CXX11, "clang::opencl_private"}, |
||
| 11472 | {AttributeCommonInfo::AS_C2x, "clang::opencl_private"}, |
||
| 11473 | }; |
||
| 11474 | struct ParsedAttrInfoOpenCLPrivateAddressSpace final : public ParsedAttrInfo { |
||
| 11475 | constexpr ParsedAttrInfoOpenCLPrivateAddressSpace() : ParsedAttrInfo( |
||
| 11476 | /*AttrKind=*/ParsedAttr::AT_OpenCLPrivateAddressSpace, |
||
| 11477 | /*NumArgs=*/0, |
||
| 11478 | /*OptArgs=*/0, |
||
| 11479 | /*NumArgMembers=*/0, |
||
| 11480 | /*HasCustomParsing=*/0, |
||
| 11481 | /*AcceptsExprPack=*/0, |
||
| 11482 | /*IsTargetSpecific=*/0, |
||
| 11483 | /*IsType=*/1, |
||
| 11484 | /*IsStmt=*/0, |
||
| 11485 | /*IsKnownToGCC=*/0, |
||
| 11486 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 11487 | /*Spellings=*/OpenCLPrivateAddressSpaceSpellings, |
||
| 11488 | /*ArgNames=*/{}) {} |
||
| 11489 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 11490 | enum Spelling { |
||
| 11491 | Keyword_private = 0, |
||
| 11492 | GNU_opencl_private = 2, |
||
| 11493 | CXX11_clang_opencl_private = 3, |
||
| 11494 | C2x_clang_opencl_private = 4, |
||
| 11495 | SpellingNotCalculated = 15 |
||
| 11496 | |||
| 11497 | }; |
||
| 11498 | |||
| 11499 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 11500 | switch (Idx) { |
||
| 11501 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 11502 | case 0: return Keyword_private; |
||
| 11503 | case 1: return Keyword_private; |
||
| 11504 | case 2: return GNU_opencl_private; |
||
| 11505 | case 3: return CXX11_clang_opencl_private; |
||
| 11506 | case 4: return C2x_clang_opencl_private; |
||
| 11507 | } |
||
| 11508 | } |
||
| 11509 | |||
| 11510 | bool isParamExpr(size_t N) const override { |
||
| 11511 | return false; |
||
| 11512 | } |
||
| 11513 | |||
| 11514 | static const ParsedAttrInfoOpenCLPrivateAddressSpace Instance; |
||
| 11515 | }; |
||
| 11516 | const ParsedAttrInfoOpenCLPrivateAddressSpace ParsedAttrInfoOpenCLPrivateAddressSpace::Instance; |
||
| 11517 | static constexpr ParsedAttrInfo::Spelling OpenCLUnrollHintSpellings[] = { |
||
| 11518 | {AttributeCommonInfo::AS_GNU, "opencl_unroll_hint"}, |
||
| 11519 | }; |
||
| 11520 | static constexpr const char *OpenCLUnrollHintArgNames[] = { |
||
| 11521 | "UnrollHint",}; |
||
| 11522 | struct ParsedAttrInfoOpenCLUnrollHint final : public ParsedAttrInfo { |
||
| 11523 | constexpr ParsedAttrInfoOpenCLUnrollHint() : ParsedAttrInfo( |
||
| 11524 | /*AttrKind=*/ParsedAttr::AT_OpenCLUnrollHint, |
||
| 11525 | /*NumArgs=*/0, |
||
| 11526 | /*OptArgs=*/1, |
||
| 11527 | /*NumArgMembers=*/1, |
||
| 11528 | /*HasCustomParsing=*/0, |
||
| 11529 | /*AcceptsExprPack=*/0, |
||
| 11530 | /*IsTargetSpecific=*/0, |
||
| 11531 | /*IsType=*/0, |
||
| 11532 | /*IsStmt=*/1, |
||
| 11533 | /*IsKnownToGCC=*/0, |
||
| 11534 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 11535 | /*Spellings=*/OpenCLUnrollHintSpellings, |
||
| 11536 | /*ArgNames=*/OpenCLUnrollHintArgNames) {} |
||
| 11537 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 11538 | S.Diag(AL.getLoc(), diag::err_attribute_invalid_on_decl) |
||
| 11539 | << AL << D->getLocation(); |
||
| 11540 | return false; |
||
| 11541 | } |
||
| 11542 | |||
| 11543 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &Attr, const Stmt *St) const override { |
||
| 11544 | if (!isa<ForStmt>(St) && !isa<CXXForRangeStmt>(St) && !isa<WhileStmt>(St) && !isa<DoStmt>(St)) { |
||
| 11545 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 11546 | << Attr << "'for', 'while', and 'do' statements"; |
||
| 11547 | return false; |
||
| 11548 | } |
||
| 11549 | return true; |
||
| 11550 | } |
||
| 11551 | |||
| 11552 | bool isParamExpr(size_t N) const override { |
||
| 11553 | return false; |
||
| 11554 | } |
||
| 11555 | |||
| 11556 | static const ParsedAttrInfoOpenCLUnrollHint Instance; |
||
| 11557 | }; |
||
| 11558 | const ParsedAttrInfoOpenCLUnrollHint ParsedAttrInfoOpenCLUnrollHint::Instance; |
||
| 11559 | static constexpr ParsedAttrInfo::Spelling OptimizeNoneSpellings[] = { |
||
| 11560 | {AttributeCommonInfo::AS_GNU, "optnone"}, |
||
| 11561 | {AttributeCommonInfo::AS_CXX11, "clang::optnone"}, |
||
| 11562 | {AttributeCommonInfo::AS_C2x, "clang::optnone"}, |
||
| 11563 | }; |
||
| 11564 | struct ParsedAttrInfoOptimizeNone final : public ParsedAttrInfo { |
||
| 11565 | constexpr ParsedAttrInfoOptimizeNone() : ParsedAttrInfo( |
||
| 11566 | /*AttrKind=*/ParsedAttr::AT_OptimizeNone, |
||
| 11567 | /*NumArgs=*/0, |
||
| 11568 | /*OptArgs=*/0, |
||
| 11569 | /*NumArgMembers=*/0, |
||
| 11570 | /*HasCustomParsing=*/0, |
||
| 11571 | /*AcceptsExprPack=*/0, |
||
| 11572 | /*IsTargetSpecific=*/0, |
||
| 11573 | /*IsType=*/0, |
||
| 11574 | /*IsStmt=*/0, |
||
| 11575 | /*IsKnownToGCC=*/0, |
||
| 11576 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 11577 | /*Spellings=*/OptimizeNoneSpellings, |
||
| 11578 | /*ArgNames=*/{}) {} |
||
| 11579 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 11580 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
||
| 11581 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 11582 | << Attr << "functions and Objective-C methods"; |
||
| 11583 | return false; |
||
| 11584 | } |
||
| 11585 | return true; |
||
| 11586 | } |
||
| 11587 | |||
| 11588 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 11589 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 11590 | << AL << St->getBeginLoc(); |
||
| 11591 | return false; |
||
| 11592 | } |
||
| 11593 | |||
| 11594 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 11595 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 11596 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 11597 | } |
||
| 11598 | |||
| 11599 | bool isParamExpr(size_t N) const override { |
||
| 11600 | return false; |
||
| 11601 | } |
||
| 11602 | |||
| 11603 | static const ParsedAttrInfoOptimizeNone Instance; |
||
| 11604 | }; |
||
| 11605 | const ParsedAttrInfoOptimizeNone ParsedAttrInfoOptimizeNone::Instance; |
||
| 11606 | static constexpr ParsedAttrInfo::Spelling OverloadableSpellings[] = { |
||
| 11607 | {AttributeCommonInfo::AS_GNU, "overloadable"}, |
||
| 11608 | {AttributeCommonInfo::AS_CXX11, "clang::overloadable"}, |
||
| 11609 | {AttributeCommonInfo::AS_C2x, "clang::overloadable"}, |
||
| 11610 | }; |
||
| 11611 | struct ParsedAttrInfoOverloadable final : public ParsedAttrInfo { |
||
| 11612 | constexpr ParsedAttrInfoOverloadable() : ParsedAttrInfo( |
||
| 11613 | /*AttrKind=*/ParsedAttr::AT_Overloadable, |
||
| 11614 | /*NumArgs=*/0, |
||
| 11615 | /*OptArgs=*/0, |
||
| 11616 | /*NumArgMembers=*/0, |
||
| 11617 | /*HasCustomParsing=*/0, |
||
| 11618 | /*AcceptsExprPack=*/0, |
||
| 11619 | /*IsTargetSpecific=*/0, |
||
| 11620 | /*IsType=*/0, |
||
| 11621 | /*IsStmt=*/0, |
||
| 11622 | /*IsKnownToGCC=*/0, |
||
| 11623 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 11624 | /*Spellings=*/OverloadableSpellings, |
||
| 11625 | /*ArgNames=*/{}) {} |
||
| 11626 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 11627 | if (!isa<FunctionDecl>(D)) { |
||
| 11628 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 11629 | << Attr << "functions"; |
||
| 11630 | return false; |
||
| 11631 | } |
||
| 11632 | return true; |
||
| 11633 | } |
||
| 11634 | |||
| 11635 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 11636 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 11637 | << AL << St->getBeginLoc(); |
||
| 11638 | return false; |
||
| 11639 | } |
||
| 11640 | |||
| 11641 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 11642 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 11643 | } |
||
| 11644 | |||
| 11645 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 11646 | D->addAttr(::new (S.Context) OverloadableAttr(S.Context, Attr)); |
||
| 11647 | return AttributeApplied; |
||
| 11648 | } |
||
| 11649 | |||
| 11650 | bool isParamExpr(size_t N) const override { |
||
| 11651 | return false; |
||
| 11652 | } |
||
| 11653 | |||
| 11654 | static const ParsedAttrInfoOverloadable Instance; |
||
| 11655 | }; |
||
| 11656 | const ParsedAttrInfoOverloadable ParsedAttrInfoOverloadable::Instance; |
||
| 11657 | static constexpr ParsedAttrInfo::Spelling OwnerSpellings[] = { |
||
| 11658 | {AttributeCommonInfo::AS_CXX11, "gsl::Owner"}, |
||
| 11659 | }; |
||
| 11660 | static constexpr const char *OwnerArgNames[] = { |
||
| 11661 | "DerefType",}; |
||
| 11662 | struct ParsedAttrInfoOwner final : public ParsedAttrInfo { |
||
| 11663 | constexpr ParsedAttrInfoOwner() : ParsedAttrInfo( |
||
| 11664 | /*AttrKind=*/ParsedAttr::AT_Owner, |
||
| 11665 | /*NumArgs=*/0, |
||
| 11666 | /*OptArgs=*/1, |
||
| 11667 | /*NumArgMembers=*/1, |
||
| 11668 | /*HasCustomParsing=*/0, |
||
| 11669 | /*AcceptsExprPack=*/0, |
||
| 11670 | /*IsTargetSpecific=*/0, |
||
| 11671 | /*IsType=*/0, |
||
| 11672 | /*IsStmt=*/0, |
||
| 11673 | /*IsKnownToGCC=*/0, |
||
| 11674 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 11675 | /*Spellings=*/OwnerSpellings, |
||
| 11676 | /*ArgNames=*/OwnerArgNames) {} |
||
| 11677 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 11678 | if (!isStruct(D)) { |
||
| 11679 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 11680 | << Attr << "structs"; |
||
| 11681 | return false; |
||
| 11682 | } |
||
| 11683 | return true; |
||
| 11684 | } |
||
| 11685 | |||
| 11686 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 11687 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 11688 | << AL << St->getBeginLoc(); |
||
| 11689 | return false; |
||
| 11690 | } |
||
| 11691 | |||
| 11692 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 11693 | |||
| 11694 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 11695 | if (const auto *A = D->getAttr<PointerAttr>()) { |
||
| 11696 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 11697 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 11698 | return false; |
||
| 11699 | } |
||
| 11700 | return true; |
||
| 11701 | } |
||
| 11702 | |||
| 11703 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 11704 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record_not_is_union, /*IsSupported=*/true)); |
||
| 11705 | } |
||
| 11706 | |||
| 11707 | bool isParamExpr(size_t N) const override { |
||
| 11708 | return false; |
||
| 11709 | } |
||
| 11710 | |||
| 11711 | static const ParsedAttrInfoOwner Instance; |
||
| 11712 | }; |
||
| 11713 | const ParsedAttrInfoOwner ParsedAttrInfoOwner::Instance; |
||
| 11714 | static constexpr ParsedAttrInfo::Spelling OwnershipSpellings[] = { |
||
| 11715 | {AttributeCommonInfo::AS_GNU, "ownership_holds"}, |
||
| 11716 | {AttributeCommonInfo::AS_CXX11, "clang::ownership_holds"}, |
||
| 11717 | {AttributeCommonInfo::AS_C2x, "clang::ownership_holds"}, |
||
| 11718 | {AttributeCommonInfo::AS_GNU, "ownership_returns"}, |
||
| 11719 | {AttributeCommonInfo::AS_CXX11, "clang::ownership_returns"}, |
||
| 11720 | {AttributeCommonInfo::AS_C2x, "clang::ownership_returns"}, |
||
| 11721 | {AttributeCommonInfo::AS_GNU, "ownership_takes"}, |
||
| 11722 | {AttributeCommonInfo::AS_CXX11, "clang::ownership_takes"}, |
||
| 11723 | {AttributeCommonInfo::AS_C2x, "clang::ownership_takes"}, |
||
| 11724 | }; |
||
| 11725 | static constexpr const char *OwnershipArgNames[] = { |
||
| 11726 | "Module","Args...",}; |
||
| 11727 | struct ParsedAttrInfoOwnership final : public ParsedAttrInfo { |
||
| 11728 | constexpr ParsedAttrInfoOwnership() : ParsedAttrInfo( |
||
| 11729 | /*AttrKind=*/ParsedAttr::AT_Ownership, |
||
| 11730 | /*NumArgs=*/1, |
||
| 11731 | /*OptArgs=*/15, |
||
| 11732 | /*NumArgMembers=*/2, |
||
| 11733 | /*HasCustomParsing=*/0, |
||
| 11734 | /*AcceptsExprPack=*/0, |
||
| 11735 | /*IsTargetSpecific=*/0, |
||
| 11736 | /*IsType=*/0, |
||
| 11737 | /*IsStmt=*/0, |
||
| 11738 | /*IsKnownToGCC=*/0, |
||
| 11739 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 11740 | /*Spellings=*/OwnershipSpellings, |
||
| 11741 | /*ArgNames=*/OwnershipArgNames) {} |
||
| 11742 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 11743 | if (!isHasFunctionProto(D)) { |
||
| 11744 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 11745 | << Attr << "non-K&R-style functions"; |
||
| 11746 | return false; |
||
| 11747 | } |
||
| 11748 | return true; |
||
| 11749 | } |
||
| 11750 | |||
| 11751 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 11752 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 11753 | << AL << St->getBeginLoc(); |
||
| 11754 | return false; |
||
| 11755 | } |
||
| 11756 | |||
| 11757 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 11758 | enum Spelling { |
||
| 11759 | GNU_ownership_holds = 0, |
||
| 11760 | CXX11_clang_ownership_holds = 1, |
||
| 11761 | C2x_clang_ownership_holds = 2, |
||
| 11762 | GNU_ownership_returns = 3, |
||
| 11763 | CXX11_clang_ownership_returns = 4, |
||
| 11764 | C2x_clang_ownership_returns = 5, |
||
| 11765 | GNU_ownership_takes = 6, |
||
| 11766 | CXX11_clang_ownership_takes = 7, |
||
| 11767 | C2x_clang_ownership_takes = 8, |
||
| 11768 | SpellingNotCalculated = 15 |
||
| 11769 | |||
| 11770 | }; |
||
| 11771 | |||
| 11772 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 11773 | switch (Idx) { |
||
| 11774 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 11775 | case 0: return GNU_ownership_holds; |
||
| 11776 | case 1: return CXX11_clang_ownership_holds; |
||
| 11777 | case 2: return C2x_clang_ownership_holds; |
||
| 11778 | case 3: return GNU_ownership_returns; |
||
| 11779 | case 4: return CXX11_clang_ownership_returns; |
||
| 11780 | case 5: return C2x_clang_ownership_returns; |
||
| 11781 | case 6: return GNU_ownership_takes; |
||
| 11782 | case 7: return CXX11_clang_ownership_takes; |
||
| 11783 | case 8: return C2x_clang_ownership_takes; |
||
| 11784 | } |
||
| 11785 | } |
||
| 11786 | |||
| 11787 | bool isParamExpr(size_t N) const override { |
||
| 11788 | return false; |
||
| 11789 | } |
||
| 11790 | |||
| 11791 | static const ParsedAttrInfoOwnership Instance; |
||
| 11792 | }; |
||
| 11793 | const ParsedAttrInfoOwnership ParsedAttrInfoOwnership::Instance; |
||
| 11794 | static constexpr ParsedAttrInfo::Spelling PackedSpellings[] = { |
||
| 11795 | {AttributeCommonInfo::AS_GNU, "packed"}, |
||
| 11796 | {AttributeCommonInfo::AS_CXX11, "gnu::packed"}, |
||
| 11797 | {AttributeCommonInfo::AS_C2x, "gnu::packed"}, |
||
| 11798 | }; |
||
| 11799 | struct ParsedAttrInfoPacked final : public ParsedAttrInfo { |
||
| 11800 | constexpr ParsedAttrInfoPacked() : ParsedAttrInfo( |
||
| 11801 | /*AttrKind=*/ParsedAttr::AT_Packed, |
||
| 11802 | /*NumArgs=*/0, |
||
| 11803 | /*OptArgs=*/0, |
||
| 11804 | /*NumArgMembers=*/0, |
||
| 11805 | /*HasCustomParsing=*/0, |
||
| 11806 | /*AcceptsExprPack=*/0, |
||
| 11807 | /*IsTargetSpecific=*/0, |
||
| 11808 | /*IsType=*/0, |
||
| 11809 | /*IsStmt=*/0, |
||
| 11810 | /*IsKnownToGCC=*/1, |
||
| 11811 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 11812 | /*Spellings=*/PackedSpellings, |
||
| 11813 | /*ArgNames=*/{}) {} |
||
| 11814 | bool isParamExpr(size_t N) const override { |
||
| 11815 | return false; |
||
| 11816 | } |
||
| 11817 | |||
| 11818 | static const ParsedAttrInfoPacked Instance; |
||
| 11819 | }; |
||
| 11820 | const ParsedAttrInfoPacked ParsedAttrInfoPacked::Instance; |
||
| 11821 | static constexpr ParsedAttrInfo::Spelling ParamTypestateSpellings[] = { |
||
| 11822 | {AttributeCommonInfo::AS_GNU, "param_typestate"}, |
||
| 11823 | {AttributeCommonInfo::AS_CXX11, "clang::param_typestate"}, |
||
| 11824 | }; |
||
| 11825 | static constexpr const char *ParamTypestateArgNames[] = { |
||
| 11826 | "ParamState",}; |
||
| 11827 | struct ParsedAttrInfoParamTypestate final : public ParsedAttrInfo { |
||
| 11828 | constexpr ParsedAttrInfoParamTypestate() : ParsedAttrInfo( |
||
| 11829 | /*AttrKind=*/ParsedAttr::AT_ParamTypestate, |
||
| 11830 | /*NumArgs=*/1, |
||
| 11831 | /*OptArgs=*/0, |
||
| 11832 | /*NumArgMembers=*/1, |
||
| 11833 | /*HasCustomParsing=*/0, |
||
| 11834 | /*AcceptsExprPack=*/0, |
||
| 11835 | /*IsTargetSpecific=*/0, |
||
| 11836 | /*IsType=*/0, |
||
| 11837 | /*IsStmt=*/0, |
||
| 11838 | /*IsKnownToGCC=*/0, |
||
| 11839 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 11840 | /*Spellings=*/ParamTypestateSpellings, |
||
| 11841 | /*ArgNames=*/ParamTypestateArgNames) {} |
||
| 11842 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 11843 | if (!isa<ParmVarDecl>(D)) { |
||
| 11844 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 11845 | << Attr << "parameters"; |
||
| 11846 | return false; |
||
| 11847 | } |
||
| 11848 | return true; |
||
| 11849 | } |
||
| 11850 | |||
| 11851 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 11852 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 11853 | << AL << St->getBeginLoc(); |
||
| 11854 | return false; |
||
| 11855 | } |
||
| 11856 | |||
| 11857 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 11858 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
||
| 11859 | } |
||
| 11860 | |||
| 11861 | bool isParamExpr(size_t N) const override { |
||
| 11862 | return false; |
||
| 11863 | } |
||
| 11864 | |||
| 11865 | static const ParsedAttrInfoParamTypestate Instance; |
||
| 11866 | }; |
||
| 11867 | const ParsedAttrInfoParamTypestate ParsedAttrInfoParamTypestate::Instance; |
||
| 11868 | static constexpr ParsedAttrInfo::Spelling PascalSpellings[] = { |
||
| 11869 | {AttributeCommonInfo::AS_GNU, "pascal"}, |
||
| 11870 | {AttributeCommonInfo::AS_CXX11, "clang::pascal"}, |
||
| 11871 | {AttributeCommonInfo::AS_C2x, "clang::pascal"}, |
||
| 11872 | {AttributeCommonInfo::AS_Keyword, "__pascal"}, |
||
| 11873 | {AttributeCommonInfo::AS_Keyword, "_pascal"}, |
||
| 11874 | }; |
||
| 11875 | struct ParsedAttrInfoPascal final : public ParsedAttrInfo { |
||
| 11876 | constexpr ParsedAttrInfoPascal() : ParsedAttrInfo( |
||
| 11877 | /*AttrKind=*/ParsedAttr::AT_Pascal, |
||
| 11878 | /*NumArgs=*/0, |
||
| 11879 | /*OptArgs=*/0, |
||
| 11880 | /*NumArgMembers=*/0, |
||
| 11881 | /*HasCustomParsing=*/0, |
||
| 11882 | /*AcceptsExprPack=*/0, |
||
| 11883 | /*IsTargetSpecific=*/0, |
||
| 11884 | /*IsType=*/1, |
||
| 11885 | /*IsStmt=*/0, |
||
| 11886 | /*IsKnownToGCC=*/0, |
||
| 11887 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 11888 | /*Spellings=*/PascalSpellings, |
||
| 11889 | /*ArgNames=*/{}) {} |
||
| 11890 | bool isParamExpr(size_t N) const override { |
||
| 11891 | return false; |
||
| 11892 | } |
||
| 11893 | |||
| 11894 | static const ParsedAttrInfoPascal Instance; |
||
| 11895 | }; |
||
| 11896 | const ParsedAttrInfoPascal ParsedAttrInfoPascal::Instance; |
||
| 11897 | static constexpr ParsedAttrInfo::Spelling PassObjectSizeSpellings[] = { |
||
| 11898 | {AttributeCommonInfo::AS_GNU, "pass_object_size"}, |
||
| 11899 | {AttributeCommonInfo::AS_CXX11, "clang::pass_object_size"}, |
||
| 11900 | {AttributeCommonInfo::AS_C2x, "clang::pass_object_size"}, |
||
| 11901 | {AttributeCommonInfo::AS_GNU, "pass_dynamic_object_size"}, |
||
| 11902 | {AttributeCommonInfo::AS_CXX11, "clang::pass_dynamic_object_size"}, |
||
| 11903 | {AttributeCommonInfo::AS_C2x, "clang::pass_dynamic_object_size"}, |
||
| 11904 | }; |
||
| 11905 | static constexpr const char *PassObjectSizeArgNames[] = { |
||
| 11906 | "Type",}; |
||
| 11907 | struct ParsedAttrInfoPassObjectSize final : public ParsedAttrInfo { |
||
| 11908 | constexpr ParsedAttrInfoPassObjectSize() : ParsedAttrInfo( |
||
| 11909 | /*AttrKind=*/ParsedAttr::AT_PassObjectSize, |
||
| 11910 | /*NumArgs=*/1, |
||
| 11911 | /*OptArgs=*/0, |
||
| 11912 | /*NumArgMembers=*/1, |
||
| 11913 | /*HasCustomParsing=*/0, |
||
| 11914 | /*AcceptsExprPack=*/0, |
||
| 11915 | /*IsTargetSpecific=*/0, |
||
| 11916 | /*IsType=*/0, |
||
| 11917 | /*IsStmt=*/0, |
||
| 11918 | /*IsKnownToGCC=*/0, |
||
| 11919 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 11920 | /*Spellings=*/PassObjectSizeSpellings, |
||
| 11921 | /*ArgNames=*/PassObjectSizeArgNames) {} |
||
| 11922 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 11923 | if (!isa<ParmVarDecl>(D)) { |
||
| 11924 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 11925 | << Attr << "parameters"; |
||
| 11926 | return false; |
||
| 11927 | } |
||
| 11928 | return true; |
||
| 11929 | } |
||
| 11930 | |||
| 11931 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 11932 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 11933 | << AL << St->getBeginLoc(); |
||
| 11934 | return false; |
||
| 11935 | } |
||
| 11936 | |||
| 11937 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 11938 | enum Spelling { |
||
| 11939 | GNU_pass_object_size = 0, |
||
| 11940 | CXX11_clang_pass_object_size = 1, |
||
| 11941 | C2x_clang_pass_object_size = 2, |
||
| 11942 | GNU_pass_dynamic_object_size = 3, |
||
| 11943 | CXX11_clang_pass_dynamic_object_size = 4, |
||
| 11944 | C2x_clang_pass_dynamic_object_size = 5, |
||
| 11945 | SpellingNotCalculated = 15 |
||
| 11946 | |||
| 11947 | }; |
||
| 11948 | |||
| 11949 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 11950 | switch (Idx) { |
||
| 11951 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 11952 | case 0: return GNU_pass_object_size; |
||
| 11953 | case 1: return CXX11_clang_pass_object_size; |
||
| 11954 | case 2: return C2x_clang_pass_object_size; |
||
| 11955 | case 3: return GNU_pass_dynamic_object_size; |
||
| 11956 | case 4: return CXX11_clang_pass_dynamic_object_size; |
||
| 11957 | case 5: return C2x_clang_pass_dynamic_object_size; |
||
| 11958 | } |
||
| 11959 | } |
||
| 11960 | |||
| 11961 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 11962 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
||
| 11963 | } |
||
| 11964 | |||
| 11965 | bool isParamExpr(size_t N) const override { |
||
| 11966 | return false; |
||
| 11967 | } |
||
| 11968 | |||
| 11969 | static const ParsedAttrInfoPassObjectSize Instance; |
||
| 11970 | }; |
||
| 11971 | const ParsedAttrInfoPassObjectSize ParsedAttrInfoPassObjectSize::Instance; |
||
| 11972 | static constexpr ParsedAttrInfo::Spelling PatchableFunctionEntrySpellings[] = { |
||
| 11973 | {AttributeCommonInfo::AS_GNU, "patchable_function_entry"}, |
||
| 11974 | {AttributeCommonInfo::AS_CXX11, "gnu::patchable_function_entry"}, |
||
| 11975 | {AttributeCommonInfo::AS_C2x, "gnu::patchable_function_entry"}, |
||
| 11976 | }; |
||
| 11977 | static constexpr const char *PatchableFunctionEntryArgNames[] = { |
||
| 11978 | "Count","Offset",}; |
||
| 11979 | struct ParsedAttrInfoPatchableFunctionEntry final : public ParsedAttrInfo { |
||
| 11980 | constexpr ParsedAttrInfoPatchableFunctionEntry() : ParsedAttrInfo( |
||
| 11981 | /*AttrKind=*/ParsedAttr::AT_PatchableFunctionEntry, |
||
| 11982 | /*NumArgs=*/1, |
||
| 11983 | /*OptArgs=*/1, |
||
| 11984 | /*NumArgMembers=*/2, |
||
| 11985 | /*HasCustomParsing=*/0, |
||
| 11986 | /*AcceptsExprPack=*/0, |
||
| 11987 | /*IsTargetSpecific=*/1, |
||
| 11988 | /*IsType=*/0, |
||
| 11989 | /*IsStmt=*/0, |
||
| 11990 | /*IsKnownToGCC=*/1, |
||
| 11991 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 11992 | /*Spellings=*/PatchableFunctionEntrySpellings, |
||
| 11993 | /*ArgNames=*/PatchableFunctionEntryArgNames) {} |
||
| 11994 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 11995 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
||
| 11996 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 11997 | << Attr << "functions and Objective-C methods"; |
||
| 11998 | return false; |
||
| 11999 | } |
||
| 12000 | return true; |
||
| 12001 | } |
||
| 12002 | |||
| 12003 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 12004 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 12005 | << AL << St->getBeginLoc(); |
||
| 12006 | return false; |
||
| 12007 | } |
||
| 12008 | |||
| 12009 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 12010 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 12011 | return true && (T.getArch() == llvm::Triple::aarch64 || T.getArch() == llvm::Triple::aarch64_be || T.getArch() == llvm::Triple::riscv32 || T.getArch() == llvm::Triple::riscv64 || T.getArch() == llvm::Triple::x86 || T.getArch() == llvm::Triple::x86_64); |
||
| 12012 | } |
||
| 12013 | |||
| 12014 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 12015 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 12016 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 12017 | } |
||
| 12018 | |||
| 12019 | bool isParamExpr(size_t N) const override { |
||
| 12020 | return false; |
||
| 12021 | } |
||
| 12022 | |||
| 12023 | static const ParsedAttrInfoPatchableFunctionEntry Instance; |
||
| 12024 | }; |
||
| 12025 | const ParsedAttrInfoPatchableFunctionEntry ParsedAttrInfoPatchableFunctionEntry::Instance; |
||
| 12026 | static constexpr ParsedAttrInfo::Spelling PcsSpellings[] = { |
||
| 12027 | {AttributeCommonInfo::AS_GNU, "pcs"}, |
||
| 12028 | {AttributeCommonInfo::AS_CXX11, "gnu::pcs"}, |
||
| 12029 | {AttributeCommonInfo::AS_C2x, "gnu::pcs"}, |
||
| 12030 | }; |
||
| 12031 | static constexpr const char *PcsArgNames[] = { |
||
| 12032 | "PCS",}; |
||
| 12033 | struct ParsedAttrInfoPcs final : public ParsedAttrInfo { |
||
| 12034 | constexpr ParsedAttrInfoPcs() : ParsedAttrInfo( |
||
| 12035 | /*AttrKind=*/ParsedAttr::AT_Pcs, |
||
| 12036 | /*NumArgs=*/1, |
||
| 12037 | /*OptArgs=*/0, |
||
| 12038 | /*NumArgMembers=*/1, |
||
| 12039 | /*HasCustomParsing=*/0, |
||
| 12040 | /*AcceptsExprPack=*/0, |
||
| 12041 | /*IsTargetSpecific=*/0, |
||
| 12042 | /*IsType=*/1, |
||
| 12043 | /*IsStmt=*/0, |
||
| 12044 | /*IsKnownToGCC=*/1, |
||
| 12045 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 12046 | /*Spellings=*/PcsSpellings, |
||
| 12047 | /*ArgNames=*/PcsArgNames) {} |
||
| 12048 | bool isParamExpr(size_t N) const override { |
||
| 12049 | return false; |
||
| 12050 | } |
||
| 12051 | |||
| 12052 | static const ParsedAttrInfoPcs Instance; |
||
| 12053 | }; |
||
| 12054 | const ParsedAttrInfoPcs ParsedAttrInfoPcs::Instance; |
||
| 12055 | static constexpr ParsedAttrInfo::Spelling PointerSpellings[] = { |
||
| 12056 | {AttributeCommonInfo::AS_CXX11, "gsl::Pointer"}, |
||
| 12057 | }; |
||
| 12058 | static constexpr const char *PointerArgNames[] = { |
||
| 12059 | "DerefType",}; |
||
| 12060 | struct ParsedAttrInfoPointer final : public ParsedAttrInfo { |
||
| 12061 | constexpr ParsedAttrInfoPointer() : ParsedAttrInfo( |
||
| 12062 | /*AttrKind=*/ParsedAttr::AT_Pointer, |
||
| 12063 | /*NumArgs=*/0, |
||
| 12064 | /*OptArgs=*/1, |
||
| 12065 | /*NumArgMembers=*/1, |
||
| 12066 | /*HasCustomParsing=*/0, |
||
| 12067 | /*AcceptsExprPack=*/0, |
||
| 12068 | /*IsTargetSpecific=*/0, |
||
| 12069 | /*IsType=*/0, |
||
| 12070 | /*IsStmt=*/0, |
||
| 12071 | /*IsKnownToGCC=*/0, |
||
| 12072 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 12073 | /*Spellings=*/PointerSpellings, |
||
| 12074 | /*ArgNames=*/PointerArgNames) {} |
||
| 12075 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 12076 | if (!isStruct(D)) { |
||
| 12077 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 12078 | << Attr << "structs"; |
||
| 12079 | return false; |
||
| 12080 | } |
||
| 12081 | return true; |
||
| 12082 | } |
||
| 12083 | |||
| 12084 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 12085 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 12086 | << AL << St->getBeginLoc(); |
||
| 12087 | return false; |
||
| 12088 | } |
||
| 12089 | |||
| 12090 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 12091 | |||
| 12092 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 12093 | if (const auto *A = D->getAttr<OwnerAttr>()) { |
||
| 12094 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 12095 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 12096 | return false; |
||
| 12097 | } |
||
| 12098 | return true; |
||
| 12099 | } |
||
| 12100 | |||
| 12101 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 12102 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record_not_is_union, /*IsSupported=*/true)); |
||
| 12103 | } |
||
| 12104 | |||
| 12105 | bool isParamExpr(size_t N) const override { |
||
| 12106 | return false; |
||
| 12107 | } |
||
| 12108 | |||
| 12109 | static const ParsedAttrInfoPointer Instance; |
||
| 12110 | }; |
||
| 12111 | const ParsedAttrInfoPointer ParsedAttrInfoPointer::Instance; |
||
| 12112 | static constexpr const char *PragmaClangBSSSectionArgNames[] = { |
||
| 12113 | "Name",}; |
||
| 12114 | struct ParsedAttrInfoPragmaClangBSSSection final : public ParsedAttrInfo { |
||
| 12115 | constexpr ParsedAttrInfoPragmaClangBSSSection() : ParsedAttrInfo( |
||
| 12116 | /*AttrKind=*/ParsedAttr::AT_PragmaClangBSSSection, |
||
| 12117 | /*NumArgs=*/1, |
||
| 12118 | /*OptArgs=*/0, |
||
| 12119 | /*NumArgMembers=*/1, |
||
| 12120 | /*HasCustomParsing=*/0, |
||
| 12121 | /*AcceptsExprPack=*/0, |
||
| 12122 | /*IsTargetSpecific=*/0, |
||
| 12123 | /*IsType=*/0, |
||
| 12124 | /*IsStmt=*/0, |
||
| 12125 | /*IsKnownToGCC=*/0, |
||
| 12126 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 12127 | /*Spellings=*/{}, |
||
| 12128 | /*ArgNames=*/PragmaClangBSSSectionArgNames) {} |
||
| 12129 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 12130 | if (!isGlobalVar(D)) { |
||
| 12131 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 12132 | << Attr << "global variables"; |
||
| 12133 | return false; |
||
| 12134 | } |
||
| 12135 | return true; |
||
| 12136 | } |
||
| 12137 | |||
| 12138 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 12139 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 12140 | << AL << St->getBeginLoc(); |
||
| 12141 | return false; |
||
| 12142 | } |
||
| 12143 | |||
| 12144 | bool isParamExpr(size_t N) const override { |
||
| 12145 | return false; |
||
| 12146 | } |
||
| 12147 | |||
| 12148 | static const ParsedAttrInfoPragmaClangBSSSection Instance; |
||
| 12149 | }; |
||
| 12150 | const ParsedAttrInfoPragmaClangBSSSection ParsedAttrInfoPragmaClangBSSSection::Instance; |
||
| 12151 | static constexpr const char *PragmaClangDataSectionArgNames[] = { |
||
| 12152 | "Name",}; |
||
| 12153 | struct ParsedAttrInfoPragmaClangDataSection final : public ParsedAttrInfo { |
||
| 12154 | constexpr ParsedAttrInfoPragmaClangDataSection() : ParsedAttrInfo( |
||
| 12155 | /*AttrKind=*/ParsedAttr::AT_PragmaClangDataSection, |
||
| 12156 | /*NumArgs=*/1, |
||
| 12157 | /*OptArgs=*/0, |
||
| 12158 | /*NumArgMembers=*/1, |
||
| 12159 | /*HasCustomParsing=*/0, |
||
| 12160 | /*AcceptsExprPack=*/0, |
||
| 12161 | /*IsTargetSpecific=*/0, |
||
| 12162 | /*IsType=*/0, |
||
| 12163 | /*IsStmt=*/0, |
||
| 12164 | /*IsKnownToGCC=*/0, |
||
| 12165 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 12166 | /*Spellings=*/{}, |
||
| 12167 | /*ArgNames=*/PragmaClangDataSectionArgNames) {} |
||
| 12168 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 12169 | if (!isGlobalVar(D)) { |
||
| 12170 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 12171 | << Attr << "global variables"; |
||
| 12172 | return false; |
||
| 12173 | } |
||
| 12174 | return true; |
||
| 12175 | } |
||
| 12176 | |||
| 12177 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 12178 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 12179 | << AL << St->getBeginLoc(); |
||
| 12180 | return false; |
||
| 12181 | } |
||
| 12182 | |||
| 12183 | bool isParamExpr(size_t N) const override { |
||
| 12184 | return false; |
||
| 12185 | } |
||
| 12186 | |||
| 12187 | static const ParsedAttrInfoPragmaClangDataSection Instance; |
||
| 12188 | }; |
||
| 12189 | const ParsedAttrInfoPragmaClangDataSection ParsedAttrInfoPragmaClangDataSection::Instance; |
||
| 12190 | static constexpr const char *PragmaClangRelroSectionArgNames[] = { |
||
| 12191 | "Name",}; |
||
| 12192 | struct ParsedAttrInfoPragmaClangRelroSection final : public ParsedAttrInfo { |
||
| 12193 | constexpr ParsedAttrInfoPragmaClangRelroSection() : ParsedAttrInfo( |
||
| 12194 | /*AttrKind=*/ParsedAttr::AT_PragmaClangRelroSection, |
||
| 12195 | /*NumArgs=*/1, |
||
| 12196 | /*OptArgs=*/0, |
||
| 12197 | /*NumArgMembers=*/1, |
||
| 12198 | /*HasCustomParsing=*/0, |
||
| 12199 | /*AcceptsExprPack=*/0, |
||
| 12200 | /*IsTargetSpecific=*/0, |
||
| 12201 | /*IsType=*/0, |
||
| 12202 | /*IsStmt=*/0, |
||
| 12203 | /*IsKnownToGCC=*/0, |
||
| 12204 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 12205 | /*Spellings=*/{}, |
||
| 12206 | /*ArgNames=*/PragmaClangRelroSectionArgNames) {} |
||
| 12207 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 12208 | if (!isGlobalVar(D)) { |
||
| 12209 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 12210 | << Attr << "global variables"; |
||
| 12211 | return false; |
||
| 12212 | } |
||
| 12213 | return true; |
||
| 12214 | } |
||
| 12215 | |||
| 12216 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 12217 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 12218 | << AL << St->getBeginLoc(); |
||
| 12219 | return false; |
||
| 12220 | } |
||
| 12221 | |||
| 12222 | bool isParamExpr(size_t N) const override { |
||
| 12223 | return false; |
||
| 12224 | } |
||
| 12225 | |||
| 12226 | static const ParsedAttrInfoPragmaClangRelroSection Instance; |
||
| 12227 | }; |
||
| 12228 | const ParsedAttrInfoPragmaClangRelroSection ParsedAttrInfoPragmaClangRelroSection::Instance; |
||
| 12229 | static constexpr const char *PragmaClangRodataSectionArgNames[] = { |
||
| 12230 | "Name",}; |
||
| 12231 | struct ParsedAttrInfoPragmaClangRodataSection final : public ParsedAttrInfo { |
||
| 12232 | constexpr ParsedAttrInfoPragmaClangRodataSection() : ParsedAttrInfo( |
||
| 12233 | /*AttrKind=*/ParsedAttr::AT_PragmaClangRodataSection, |
||
| 12234 | /*NumArgs=*/1, |
||
| 12235 | /*OptArgs=*/0, |
||
| 12236 | /*NumArgMembers=*/1, |
||
| 12237 | /*HasCustomParsing=*/0, |
||
| 12238 | /*AcceptsExprPack=*/0, |
||
| 12239 | /*IsTargetSpecific=*/0, |
||
| 12240 | /*IsType=*/0, |
||
| 12241 | /*IsStmt=*/0, |
||
| 12242 | /*IsKnownToGCC=*/0, |
||
| 12243 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 12244 | /*Spellings=*/{}, |
||
| 12245 | /*ArgNames=*/PragmaClangRodataSectionArgNames) {} |
||
| 12246 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 12247 | if (!isGlobalVar(D)) { |
||
| 12248 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 12249 | << Attr << "global variables"; |
||
| 12250 | return false; |
||
| 12251 | } |
||
| 12252 | return true; |
||
| 12253 | } |
||
| 12254 | |||
| 12255 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 12256 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 12257 | << AL << St->getBeginLoc(); |
||
| 12258 | return false; |
||
| 12259 | } |
||
| 12260 | |||
| 12261 | bool isParamExpr(size_t N) const override { |
||
| 12262 | return false; |
||
| 12263 | } |
||
| 12264 | |||
| 12265 | static const ParsedAttrInfoPragmaClangRodataSection Instance; |
||
| 12266 | }; |
||
| 12267 | const ParsedAttrInfoPragmaClangRodataSection ParsedAttrInfoPragmaClangRodataSection::Instance; |
||
| 12268 | static constexpr const char *PragmaClangTextSectionArgNames[] = { |
||
| 12269 | "Name",}; |
||
| 12270 | struct ParsedAttrInfoPragmaClangTextSection final : public ParsedAttrInfo { |
||
| 12271 | constexpr ParsedAttrInfoPragmaClangTextSection() : ParsedAttrInfo( |
||
| 12272 | /*AttrKind=*/ParsedAttr::AT_PragmaClangTextSection, |
||
| 12273 | /*NumArgs=*/1, |
||
| 12274 | /*OptArgs=*/0, |
||
| 12275 | /*NumArgMembers=*/1, |
||
| 12276 | /*HasCustomParsing=*/0, |
||
| 12277 | /*AcceptsExprPack=*/0, |
||
| 12278 | /*IsTargetSpecific=*/0, |
||
| 12279 | /*IsType=*/0, |
||
| 12280 | /*IsStmt=*/0, |
||
| 12281 | /*IsKnownToGCC=*/0, |
||
| 12282 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 12283 | /*Spellings=*/{}, |
||
| 12284 | /*ArgNames=*/PragmaClangTextSectionArgNames) {} |
||
| 12285 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 12286 | if (!isa<FunctionDecl>(D)) { |
||
| 12287 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 12288 | << Attr << "functions"; |
||
| 12289 | return false; |
||
| 12290 | } |
||
| 12291 | return true; |
||
| 12292 | } |
||
| 12293 | |||
| 12294 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 12295 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 12296 | << AL << St->getBeginLoc(); |
||
| 12297 | return false; |
||
| 12298 | } |
||
| 12299 | |||
| 12300 | bool isParamExpr(size_t N) const override { |
||
| 12301 | return false; |
||
| 12302 | } |
||
| 12303 | |||
| 12304 | static const ParsedAttrInfoPragmaClangTextSection Instance; |
||
| 12305 | }; |
||
| 12306 | const ParsedAttrInfoPragmaClangTextSection ParsedAttrInfoPragmaClangTextSection::Instance; |
||
| 12307 | static constexpr ParsedAttrInfo::Spelling PreferredNameSpellings[] = { |
||
| 12308 | {AttributeCommonInfo::AS_GNU, "preferred_name"}, |
||
| 12309 | {AttributeCommonInfo::AS_CXX11, "clang::preferred_name"}, |
||
| 12310 | }; |
||
| 12311 | static constexpr const char *PreferredNameArgNames[] = { |
||
| 12312 | "TypedefType",}; |
||
| 12313 | struct ParsedAttrInfoPreferredName final : public ParsedAttrInfo { |
||
| 12314 | constexpr ParsedAttrInfoPreferredName() : ParsedAttrInfo( |
||
| 12315 | /*AttrKind=*/ParsedAttr::AT_PreferredName, |
||
| 12316 | /*NumArgs=*/1, |
||
| 12317 | /*OptArgs=*/0, |
||
| 12318 | /*NumArgMembers=*/1, |
||
| 12319 | /*HasCustomParsing=*/0, |
||
| 12320 | /*AcceptsExprPack=*/0, |
||
| 12321 | /*IsTargetSpecific=*/0, |
||
| 12322 | /*IsType=*/0, |
||
| 12323 | /*IsStmt=*/0, |
||
| 12324 | /*IsKnownToGCC=*/0, |
||
| 12325 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 12326 | /*Spellings=*/PreferredNameSpellings, |
||
| 12327 | /*ArgNames=*/PreferredNameArgNames) {} |
||
| 12328 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 12329 | if (!isClassTmpl(D)) { |
||
| 12330 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 12331 | << Attr << "class templates"; |
||
| 12332 | return false; |
||
| 12333 | } |
||
| 12334 | return true; |
||
| 12335 | } |
||
| 12336 | |||
| 12337 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 12338 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 12339 | << AL << St->getBeginLoc(); |
||
| 12340 | return false; |
||
| 12341 | } |
||
| 12342 | |||
| 12343 | bool isParamExpr(size_t N) const override { |
||
| 12344 | return false; |
||
| 12345 | } |
||
| 12346 | |||
| 12347 | static const ParsedAttrInfoPreferredName Instance; |
||
| 12348 | }; |
||
| 12349 | const ParsedAttrInfoPreferredName ParsedAttrInfoPreferredName::Instance; |
||
| 12350 | static constexpr ParsedAttrInfo::Spelling PreserveAllSpellings[] = { |
||
| 12351 | {AttributeCommonInfo::AS_GNU, "preserve_all"}, |
||
| 12352 | {AttributeCommonInfo::AS_CXX11, "clang::preserve_all"}, |
||
| 12353 | {AttributeCommonInfo::AS_C2x, "clang::preserve_all"}, |
||
| 12354 | }; |
||
| 12355 | struct ParsedAttrInfoPreserveAll final : public ParsedAttrInfo { |
||
| 12356 | constexpr ParsedAttrInfoPreserveAll() : ParsedAttrInfo( |
||
| 12357 | /*AttrKind=*/ParsedAttr::AT_PreserveAll, |
||
| 12358 | /*NumArgs=*/0, |
||
| 12359 | /*OptArgs=*/0, |
||
| 12360 | /*NumArgMembers=*/0, |
||
| 12361 | /*HasCustomParsing=*/0, |
||
| 12362 | /*AcceptsExprPack=*/0, |
||
| 12363 | /*IsTargetSpecific=*/0, |
||
| 12364 | /*IsType=*/1, |
||
| 12365 | /*IsStmt=*/0, |
||
| 12366 | /*IsKnownToGCC=*/0, |
||
| 12367 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 12368 | /*Spellings=*/PreserveAllSpellings, |
||
| 12369 | /*ArgNames=*/{}) {} |
||
| 12370 | bool isParamExpr(size_t N) const override { |
||
| 12371 | return false; |
||
| 12372 | } |
||
| 12373 | |||
| 12374 | static const ParsedAttrInfoPreserveAll Instance; |
||
| 12375 | }; |
||
| 12376 | const ParsedAttrInfoPreserveAll ParsedAttrInfoPreserveAll::Instance; |
||
| 12377 | static constexpr ParsedAttrInfo::Spelling PreserveMostSpellings[] = { |
||
| 12378 | {AttributeCommonInfo::AS_GNU, "preserve_most"}, |
||
| 12379 | {AttributeCommonInfo::AS_CXX11, "clang::preserve_most"}, |
||
| 12380 | {AttributeCommonInfo::AS_C2x, "clang::preserve_most"}, |
||
| 12381 | }; |
||
| 12382 | struct ParsedAttrInfoPreserveMost final : public ParsedAttrInfo { |
||
| 12383 | constexpr ParsedAttrInfoPreserveMost() : ParsedAttrInfo( |
||
| 12384 | /*AttrKind=*/ParsedAttr::AT_PreserveMost, |
||
| 12385 | /*NumArgs=*/0, |
||
| 12386 | /*OptArgs=*/0, |
||
| 12387 | /*NumArgMembers=*/0, |
||
| 12388 | /*HasCustomParsing=*/0, |
||
| 12389 | /*AcceptsExprPack=*/0, |
||
| 12390 | /*IsTargetSpecific=*/0, |
||
| 12391 | /*IsType=*/1, |
||
| 12392 | /*IsStmt=*/0, |
||
| 12393 | /*IsKnownToGCC=*/0, |
||
| 12394 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 12395 | /*Spellings=*/PreserveMostSpellings, |
||
| 12396 | /*ArgNames=*/{}) {} |
||
| 12397 | bool isParamExpr(size_t N) const override { |
||
| 12398 | return false; |
||
| 12399 | } |
||
| 12400 | |||
| 12401 | static const ParsedAttrInfoPreserveMost Instance; |
||
| 12402 | }; |
||
| 12403 | const ParsedAttrInfoPreserveMost ParsedAttrInfoPreserveMost::Instance; |
||
| 12404 | static constexpr ParsedAttrInfo::Spelling PtGuardedBySpellings[] = { |
||
| 12405 | {AttributeCommonInfo::AS_GNU, "pt_guarded_by"}, |
||
| 12406 | }; |
||
| 12407 | static constexpr const char *PtGuardedByArgNames[] = { |
||
| 12408 | "Arg",}; |
||
| 12409 | struct ParsedAttrInfoPtGuardedBy final : public ParsedAttrInfo { |
||
| 12410 | constexpr ParsedAttrInfoPtGuardedBy() : ParsedAttrInfo( |
||
| 12411 | /*AttrKind=*/ParsedAttr::AT_PtGuardedBy, |
||
| 12412 | /*NumArgs=*/1, |
||
| 12413 | /*OptArgs=*/0, |
||
| 12414 | /*NumArgMembers=*/1, |
||
| 12415 | /*HasCustomParsing=*/0, |
||
| 12416 | /*AcceptsExprPack=*/0, |
||
| 12417 | /*IsTargetSpecific=*/0, |
||
| 12418 | /*IsType=*/0, |
||
| 12419 | /*IsStmt=*/0, |
||
| 12420 | /*IsKnownToGCC=*/0, |
||
| 12421 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 12422 | /*Spellings=*/PtGuardedBySpellings, |
||
| 12423 | /*ArgNames=*/PtGuardedByArgNames) {} |
||
| 12424 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 12425 | if (!isa<FieldDecl>(D) && !isSharedVar(D)) { |
||
| 12426 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 12427 | << Attr << "non-static data members and global variables"; |
||
| 12428 | return false; |
||
| 12429 | } |
||
| 12430 | return true; |
||
| 12431 | } |
||
| 12432 | |||
| 12433 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 12434 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 12435 | << AL << St->getBeginLoc(); |
||
| 12436 | return false; |
||
| 12437 | } |
||
| 12438 | |||
| 12439 | bool isParamExpr(size_t N) const override { |
||
| 12440 | return (N == 0) || false; |
||
| 12441 | } |
||
| 12442 | |||
| 12443 | static const ParsedAttrInfoPtGuardedBy Instance; |
||
| 12444 | }; |
||
| 12445 | const ParsedAttrInfoPtGuardedBy ParsedAttrInfoPtGuardedBy::Instance; |
||
| 12446 | static constexpr ParsedAttrInfo::Spelling PtGuardedVarSpellings[] = { |
||
| 12447 | {AttributeCommonInfo::AS_GNU, "pt_guarded_var"}, |
||
| 12448 | {AttributeCommonInfo::AS_CXX11, "clang::pt_guarded_var"}, |
||
| 12449 | }; |
||
| 12450 | struct ParsedAttrInfoPtGuardedVar final : public ParsedAttrInfo { |
||
| 12451 | constexpr ParsedAttrInfoPtGuardedVar() : ParsedAttrInfo( |
||
| 12452 | /*AttrKind=*/ParsedAttr::AT_PtGuardedVar, |
||
| 12453 | /*NumArgs=*/0, |
||
| 12454 | /*OptArgs=*/0, |
||
| 12455 | /*NumArgMembers=*/0, |
||
| 12456 | /*HasCustomParsing=*/0, |
||
| 12457 | /*AcceptsExprPack=*/0, |
||
| 12458 | /*IsTargetSpecific=*/0, |
||
| 12459 | /*IsType=*/0, |
||
| 12460 | /*IsStmt=*/0, |
||
| 12461 | /*IsKnownToGCC=*/0, |
||
| 12462 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 12463 | /*Spellings=*/PtGuardedVarSpellings, |
||
| 12464 | /*ArgNames=*/{}) {} |
||
| 12465 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 12466 | if (!isa<FieldDecl>(D) && !isSharedVar(D)) { |
||
| 12467 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 12468 | << Attr << "non-static data members and global variables"; |
||
| 12469 | return false; |
||
| 12470 | } |
||
| 12471 | return true; |
||
| 12472 | } |
||
| 12473 | |||
| 12474 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 12475 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 12476 | << AL << St->getBeginLoc(); |
||
| 12477 | return false; |
||
| 12478 | } |
||
| 12479 | |||
| 12480 | bool isParamExpr(size_t N) const override { |
||
| 12481 | return false; |
||
| 12482 | } |
||
| 12483 | |||
| 12484 | static const ParsedAttrInfoPtGuardedVar Instance; |
||
| 12485 | }; |
||
| 12486 | const ParsedAttrInfoPtGuardedVar ParsedAttrInfoPtGuardedVar::Instance; |
||
| 12487 | static constexpr ParsedAttrInfo::Spelling Ptr32Spellings[] = { |
||
| 12488 | {AttributeCommonInfo::AS_Keyword, "__ptr32"}, |
||
| 12489 | }; |
||
| 12490 | struct ParsedAttrInfoPtr32 final : public ParsedAttrInfo { |
||
| 12491 | constexpr ParsedAttrInfoPtr32() : ParsedAttrInfo( |
||
| 12492 | /*AttrKind=*/ParsedAttr::AT_Ptr32, |
||
| 12493 | /*NumArgs=*/0, |
||
| 12494 | /*OptArgs=*/0, |
||
| 12495 | /*NumArgMembers=*/0, |
||
| 12496 | /*HasCustomParsing=*/0, |
||
| 12497 | /*AcceptsExprPack=*/0, |
||
| 12498 | /*IsTargetSpecific=*/0, |
||
| 12499 | /*IsType=*/1, |
||
| 12500 | /*IsStmt=*/0, |
||
| 12501 | /*IsKnownToGCC=*/0, |
||
| 12502 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 12503 | /*Spellings=*/Ptr32Spellings, |
||
| 12504 | /*ArgNames=*/{}) {} |
||
| 12505 | bool isParamExpr(size_t N) const override { |
||
| 12506 | return false; |
||
| 12507 | } |
||
| 12508 | |||
| 12509 | static const ParsedAttrInfoPtr32 Instance; |
||
| 12510 | }; |
||
| 12511 | const ParsedAttrInfoPtr32 ParsedAttrInfoPtr32::Instance; |
||
| 12512 | static constexpr ParsedAttrInfo::Spelling Ptr64Spellings[] = { |
||
| 12513 | {AttributeCommonInfo::AS_Keyword, "__ptr64"}, |
||
| 12514 | }; |
||
| 12515 | struct ParsedAttrInfoPtr64 final : public ParsedAttrInfo { |
||
| 12516 | constexpr ParsedAttrInfoPtr64() : ParsedAttrInfo( |
||
| 12517 | /*AttrKind=*/ParsedAttr::AT_Ptr64, |
||
| 12518 | /*NumArgs=*/0, |
||
| 12519 | /*OptArgs=*/0, |
||
| 12520 | /*NumArgMembers=*/0, |
||
| 12521 | /*HasCustomParsing=*/0, |
||
| 12522 | /*AcceptsExprPack=*/0, |
||
| 12523 | /*IsTargetSpecific=*/0, |
||
| 12524 | /*IsType=*/1, |
||
| 12525 | /*IsStmt=*/0, |
||
| 12526 | /*IsKnownToGCC=*/0, |
||
| 12527 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 12528 | /*Spellings=*/Ptr64Spellings, |
||
| 12529 | /*ArgNames=*/{}) {} |
||
| 12530 | bool isParamExpr(size_t N) const override { |
||
| 12531 | return false; |
||
| 12532 | } |
||
| 12533 | |||
| 12534 | static const ParsedAttrInfoPtr64 Instance; |
||
| 12535 | }; |
||
| 12536 | const ParsedAttrInfoPtr64 ParsedAttrInfoPtr64::Instance; |
||
| 12537 | static constexpr ParsedAttrInfo::Spelling PureSpellings[] = { |
||
| 12538 | {AttributeCommonInfo::AS_GNU, "pure"}, |
||
| 12539 | {AttributeCommonInfo::AS_CXX11, "gnu::pure"}, |
||
| 12540 | {AttributeCommonInfo::AS_C2x, "gnu::pure"}, |
||
| 12541 | }; |
||
| 12542 | struct ParsedAttrInfoPure final : public ParsedAttrInfo { |
||
| 12543 | constexpr ParsedAttrInfoPure() : ParsedAttrInfo( |
||
| 12544 | /*AttrKind=*/ParsedAttr::AT_Pure, |
||
| 12545 | /*NumArgs=*/0, |
||
| 12546 | /*OptArgs=*/0, |
||
| 12547 | /*NumArgMembers=*/0, |
||
| 12548 | /*HasCustomParsing=*/0, |
||
| 12549 | /*AcceptsExprPack=*/0, |
||
| 12550 | /*IsTargetSpecific=*/0, |
||
| 12551 | /*IsType=*/0, |
||
| 12552 | /*IsStmt=*/0, |
||
| 12553 | /*IsKnownToGCC=*/1, |
||
| 12554 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 12555 | /*Spellings=*/PureSpellings, |
||
| 12556 | /*ArgNames=*/{}) {} |
||
| 12557 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 12558 | D->addAttr(::new (S.Context) PureAttr(S.Context, Attr)); |
||
| 12559 | return AttributeApplied; |
||
| 12560 | } |
||
| 12561 | |||
| 12562 | bool isParamExpr(size_t N) const override { |
||
| 12563 | return false; |
||
| 12564 | } |
||
| 12565 | |||
| 12566 | static const ParsedAttrInfoPure Instance; |
||
| 12567 | }; |
||
| 12568 | const ParsedAttrInfoPure ParsedAttrInfoPure::Instance; |
||
| 12569 | static constexpr ParsedAttrInfo::Spelling RandomizeLayoutSpellings[] = { |
||
| 12570 | {AttributeCommonInfo::AS_GNU, "randomize_layout"}, |
||
| 12571 | {AttributeCommonInfo::AS_CXX11, "gnu::randomize_layout"}, |
||
| 12572 | {AttributeCommonInfo::AS_C2x, "gnu::randomize_layout"}, |
||
| 12573 | }; |
||
| 12574 | struct ParsedAttrInfoRandomizeLayout final : public ParsedAttrInfo { |
||
| 12575 | constexpr ParsedAttrInfoRandomizeLayout() : ParsedAttrInfo( |
||
| 12576 | /*AttrKind=*/ParsedAttr::AT_RandomizeLayout, |
||
| 12577 | /*NumArgs=*/0, |
||
| 12578 | /*OptArgs=*/0, |
||
| 12579 | /*NumArgMembers=*/0, |
||
| 12580 | /*HasCustomParsing=*/0, |
||
| 12581 | /*AcceptsExprPack=*/0, |
||
| 12582 | /*IsTargetSpecific=*/0, |
||
| 12583 | /*IsType=*/0, |
||
| 12584 | /*IsStmt=*/0, |
||
| 12585 | /*IsKnownToGCC=*/1, |
||
| 12586 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 12587 | /*Spellings=*/RandomizeLayoutSpellings, |
||
| 12588 | /*ArgNames=*/{}) {} |
||
| 12589 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 12590 | if (!isa<RecordDecl>(D)) { |
||
| 12591 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 12592 | << Attr << "structs, unions, and classes"; |
||
| 12593 | return false; |
||
| 12594 | } |
||
| 12595 | return true; |
||
| 12596 | } |
||
| 12597 | |||
| 12598 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 12599 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 12600 | << AL << St->getBeginLoc(); |
||
| 12601 | return false; |
||
| 12602 | } |
||
| 12603 | |||
| 12604 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 12605 | |||
| 12606 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 12607 | if (const auto *A = D->getAttr<NoRandomizeLayoutAttr>()) { |
||
| 12608 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 12609 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 12610 | return false; |
||
| 12611 | } |
||
| 12612 | return true; |
||
| 12613 | } |
||
| 12614 | |||
| 12615 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 12616 | return (!LangOpts.CPlusPlus); |
||
| 12617 | } |
||
| 12618 | |||
| 12619 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 12620 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 12621 | } |
||
| 12622 | |||
| 12623 | bool isParamExpr(size_t N) const override { |
||
| 12624 | return false; |
||
| 12625 | } |
||
| 12626 | |||
| 12627 | static const ParsedAttrInfoRandomizeLayout Instance; |
||
| 12628 | }; |
||
| 12629 | const ParsedAttrInfoRandomizeLayout ParsedAttrInfoRandomizeLayout::Instance; |
||
| 12630 | static constexpr ParsedAttrInfo::Spelling ReadOnlyPlacementSpellings[] = { |
||
| 12631 | {AttributeCommonInfo::AS_GNU, "enforce_read_only_placement"}, |
||
| 12632 | {AttributeCommonInfo::AS_CXX11, "clang::enforce_read_only_placement"}, |
||
| 12633 | {AttributeCommonInfo::AS_C2x, "clang::enforce_read_only_placement"}, |
||
| 12634 | }; |
||
| 12635 | struct ParsedAttrInfoReadOnlyPlacement final : public ParsedAttrInfo { |
||
| 12636 | constexpr ParsedAttrInfoReadOnlyPlacement() : ParsedAttrInfo( |
||
| 12637 | /*AttrKind=*/ParsedAttr::AT_ReadOnlyPlacement, |
||
| 12638 | /*NumArgs=*/0, |
||
| 12639 | /*OptArgs=*/0, |
||
| 12640 | /*NumArgMembers=*/0, |
||
| 12641 | /*HasCustomParsing=*/0, |
||
| 12642 | /*AcceptsExprPack=*/0, |
||
| 12643 | /*IsTargetSpecific=*/0, |
||
| 12644 | /*IsType=*/0, |
||
| 12645 | /*IsStmt=*/0, |
||
| 12646 | /*IsKnownToGCC=*/0, |
||
| 12647 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 12648 | /*Spellings=*/ReadOnlyPlacementSpellings, |
||
| 12649 | /*ArgNames=*/{}) {} |
||
| 12650 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 12651 | if (!isa<RecordDecl>(D)) { |
||
| 12652 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 12653 | << Attr << "structs, unions, and classes"; |
||
| 12654 | return false; |
||
| 12655 | } |
||
| 12656 | return true; |
||
| 12657 | } |
||
| 12658 | |||
| 12659 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 12660 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 12661 | << AL << St->getBeginLoc(); |
||
| 12662 | return false; |
||
| 12663 | } |
||
| 12664 | |||
| 12665 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 12666 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 12667 | } |
||
| 12668 | |||
| 12669 | bool isParamExpr(size_t N) const override { |
||
| 12670 | return false; |
||
| 12671 | } |
||
| 12672 | |||
| 12673 | static const ParsedAttrInfoReadOnlyPlacement Instance; |
||
| 12674 | }; |
||
| 12675 | const ParsedAttrInfoReadOnlyPlacement ParsedAttrInfoReadOnlyPlacement::Instance; |
||
| 12676 | static constexpr ParsedAttrInfo::Spelling RegCallSpellings[] = { |
||
| 12677 | {AttributeCommonInfo::AS_GNU, "regcall"}, |
||
| 12678 | {AttributeCommonInfo::AS_CXX11, "gnu::regcall"}, |
||
| 12679 | {AttributeCommonInfo::AS_C2x, "gnu::regcall"}, |
||
| 12680 | {AttributeCommonInfo::AS_Keyword, "__regcall"}, |
||
| 12681 | }; |
||
| 12682 | struct ParsedAttrInfoRegCall final : public ParsedAttrInfo { |
||
| 12683 | constexpr ParsedAttrInfoRegCall() : ParsedAttrInfo( |
||
| 12684 | /*AttrKind=*/ParsedAttr::AT_RegCall, |
||
| 12685 | /*NumArgs=*/0, |
||
| 12686 | /*OptArgs=*/0, |
||
| 12687 | /*NumArgMembers=*/0, |
||
| 12688 | /*HasCustomParsing=*/0, |
||
| 12689 | /*AcceptsExprPack=*/0, |
||
| 12690 | /*IsTargetSpecific=*/0, |
||
| 12691 | /*IsType=*/1, |
||
| 12692 | /*IsStmt=*/0, |
||
| 12693 | /*IsKnownToGCC=*/1, |
||
| 12694 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 12695 | /*Spellings=*/RegCallSpellings, |
||
| 12696 | /*ArgNames=*/{}) {} |
||
| 12697 | bool isParamExpr(size_t N) const override { |
||
| 12698 | return false; |
||
| 12699 | } |
||
| 12700 | |||
| 12701 | static const ParsedAttrInfoRegCall Instance; |
||
| 12702 | }; |
||
| 12703 | const ParsedAttrInfoRegCall ParsedAttrInfoRegCall::Instance; |
||
| 12704 | static constexpr ParsedAttrInfo::Spelling RegparmSpellings[] = { |
||
| 12705 | {AttributeCommonInfo::AS_GNU, "regparm"}, |
||
| 12706 | {AttributeCommonInfo::AS_CXX11, "gnu::regparm"}, |
||
| 12707 | {AttributeCommonInfo::AS_C2x, "gnu::regparm"}, |
||
| 12708 | }; |
||
| 12709 | static constexpr const char *RegparmArgNames[] = { |
||
| 12710 | "NumParams",}; |
||
| 12711 | struct ParsedAttrInfoRegparm final : public ParsedAttrInfo { |
||
| 12712 | constexpr ParsedAttrInfoRegparm() : ParsedAttrInfo( |
||
| 12713 | /*AttrKind=*/ParsedAttr::AT_Regparm, |
||
| 12714 | /*NumArgs=*/1, |
||
| 12715 | /*OptArgs=*/0, |
||
| 12716 | /*NumArgMembers=*/1, |
||
| 12717 | /*HasCustomParsing=*/0, |
||
| 12718 | /*AcceptsExprPack=*/0, |
||
| 12719 | /*IsTargetSpecific=*/0, |
||
| 12720 | /*IsType=*/1, |
||
| 12721 | /*IsStmt=*/0, |
||
| 12722 | /*IsKnownToGCC=*/1, |
||
| 12723 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 12724 | /*Spellings=*/RegparmSpellings, |
||
| 12725 | /*ArgNames=*/RegparmArgNames) {} |
||
| 12726 | bool isParamExpr(size_t N) const override { |
||
| 12727 | return false; |
||
| 12728 | } |
||
| 12729 | |||
| 12730 | static const ParsedAttrInfoRegparm Instance; |
||
| 12731 | }; |
||
| 12732 | const ParsedAttrInfoRegparm ParsedAttrInfoRegparm::Instance; |
||
| 12733 | static constexpr ParsedAttrInfo::Spelling ReinitializesSpellings[] = { |
||
| 12734 | {AttributeCommonInfo::AS_GNU, "reinitializes"}, |
||
| 12735 | {AttributeCommonInfo::AS_CXX11, "clang::reinitializes"}, |
||
| 12736 | }; |
||
| 12737 | struct ParsedAttrInfoReinitializes final : public ParsedAttrInfo { |
||
| 12738 | constexpr ParsedAttrInfoReinitializes() : ParsedAttrInfo( |
||
| 12739 | /*AttrKind=*/ParsedAttr::AT_Reinitializes, |
||
| 12740 | /*NumArgs=*/0, |
||
| 12741 | /*OptArgs=*/0, |
||
| 12742 | /*NumArgMembers=*/0, |
||
| 12743 | /*HasCustomParsing=*/0, |
||
| 12744 | /*AcceptsExprPack=*/0, |
||
| 12745 | /*IsTargetSpecific=*/0, |
||
| 12746 | /*IsType=*/0, |
||
| 12747 | /*IsStmt=*/0, |
||
| 12748 | /*IsKnownToGCC=*/0, |
||
| 12749 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 12750 | /*Spellings=*/ReinitializesSpellings, |
||
| 12751 | /*ArgNames=*/{}) {} |
||
| 12752 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 12753 | if (!isNonStaticNonConstCXXMethod(D)) { |
||
| 12754 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 12755 | << Attr << "non-static non-const member functions"; |
||
| 12756 | return false; |
||
| 12757 | } |
||
| 12758 | return true; |
||
| 12759 | } |
||
| 12760 | |||
| 12761 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 12762 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 12763 | << AL << St->getBeginLoc(); |
||
| 12764 | return false; |
||
| 12765 | } |
||
| 12766 | |||
| 12767 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 12768 | D->addAttr(::new (S.Context) ReinitializesAttr(S.Context, Attr)); |
||
| 12769 | return AttributeApplied; |
||
| 12770 | } |
||
| 12771 | |||
| 12772 | bool isParamExpr(size_t N) const override { |
||
| 12773 | return false; |
||
| 12774 | } |
||
| 12775 | |||
| 12776 | static const ParsedAttrInfoReinitializes Instance; |
||
| 12777 | }; |
||
| 12778 | const ParsedAttrInfoReinitializes ParsedAttrInfoReinitializes::Instance; |
||
| 12779 | static constexpr ParsedAttrInfo::Spelling ReleaseCapabilitySpellings[] = { |
||
| 12780 | {AttributeCommonInfo::AS_GNU, "release_capability"}, |
||
| 12781 | {AttributeCommonInfo::AS_CXX11, "clang::release_capability"}, |
||
| 12782 | {AttributeCommonInfo::AS_GNU, "release_shared_capability"}, |
||
| 12783 | {AttributeCommonInfo::AS_CXX11, "clang::release_shared_capability"}, |
||
| 12784 | {AttributeCommonInfo::AS_GNU, "release_generic_capability"}, |
||
| 12785 | {AttributeCommonInfo::AS_CXX11, "clang::release_generic_capability"}, |
||
| 12786 | {AttributeCommonInfo::AS_GNU, "unlock_function"}, |
||
| 12787 | {AttributeCommonInfo::AS_CXX11, "clang::unlock_function"}, |
||
| 12788 | }; |
||
| 12789 | static constexpr const char *ReleaseCapabilityArgNames[] = { |
||
| 12790 | "Args...",}; |
||
| 12791 | struct ParsedAttrInfoReleaseCapability final : public ParsedAttrInfo { |
||
| 12792 | constexpr ParsedAttrInfoReleaseCapability() : ParsedAttrInfo( |
||
| 12793 | /*AttrKind=*/ParsedAttr::AT_ReleaseCapability, |
||
| 12794 | /*NumArgs=*/0, |
||
| 12795 | /*OptArgs=*/15, |
||
| 12796 | /*NumArgMembers=*/1, |
||
| 12797 | /*HasCustomParsing=*/0, |
||
| 12798 | /*AcceptsExprPack=*/0, |
||
| 12799 | /*IsTargetSpecific=*/0, |
||
| 12800 | /*IsType=*/0, |
||
| 12801 | /*IsStmt=*/0, |
||
| 12802 | /*IsKnownToGCC=*/0, |
||
| 12803 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 12804 | /*Spellings=*/ReleaseCapabilitySpellings, |
||
| 12805 | /*ArgNames=*/ReleaseCapabilityArgNames) {} |
||
| 12806 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 12807 | if (!isa<FunctionDecl>(D)) { |
||
| 12808 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 12809 | << Attr << "functions"; |
||
| 12810 | return false; |
||
| 12811 | } |
||
| 12812 | return true; |
||
| 12813 | } |
||
| 12814 | |||
| 12815 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 12816 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 12817 | << AL << St->getBeginLoc(); |
||
| 12818 | return false; |
||
| 12819 | } |
||
| 12820 | |||
| 12821 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 12822 | enum Spelling { |
||
| 12823 | GNU_release_capability = 0, |
||
| 12824 | CXX11_clang_release_capability = 1, |
||
| 12825 | GNU_release_shared_capability = 2, |
||
| 12826 | CXX11_clang_release_shared_capability = 3, |
||
| 12827 | GNU_release_generic_capability = 4, |
||
| 12828 | CXX11_clang_release_generic_capability = 5, |
||
| 12829 | GNU_unlock_function = 6, |
||
| 12830 | CXX11_clang_unlock_function = 7, |
||
| 12831 | SpellingNotCalculated = 15 |
||
| 12832 | |||
| 12833 | }; |
||
| 12834 | |||
| 12835 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 12836 | switch (Idx) { |
||
| 12837 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 12838 | case 0: return GNU_release_capability; |
||
| 12839 | case 1: return CXX11_clang_release_capability; |
||
| 12840 | case 2: return GNU_release_shared_capability; |
||
| 12841 | case 3: return CXX11_clang_release_shared_capability; |
||
| 12842 | case 4: return GNU_release_generic_capability; |
||
| 12843 | case 5: return CXX11_clang_release_generic_capability; |
||
| 12844 | case 6: return GNU_unlock_function; |
||
| 12845 | case 7: return CXX11_clang_unlock_function; |
||
| 12846 | } |
||
| 12847 | } |
||
| 12848 | |||
| 12849 | bool isParamExpr(size_t N) const override { |
||
| 12850 | return (N == 0) || false; |
||
| 12851 | } |
||
| 12852 | |||
| 12853 | static const ParsedAttrInfoReleaseCapability Instance; |
||
| 12854 | }; |
||
| 12855 | const ParsedAttrInfoReleaseCapability ParsedAttrInfoReleaseCapability::Instance; |
||
| 12856 | static constexpr ParsedAttrInfo::Spelling ReleaseHandleSpellings[] = { |
||
| 12857 | {AttributeCommonInfo::AS_GNU, "release_handle"}, |
||
| 12858 | {AttributeCommonInfo::AS_CXX11, "clang::release_handle"}, |
||
| 12859 | {AttributeCommonInfo::AS_C2x, "clang::release_handle"}, |
||
| 12860 | }; |
||
| 12861 | static constexpr const char *ReleaseHandleArgNames[] = { |
||
| 12862 | "HandleType",}; |
||
| 12863 | struct ParsedAttrInfoReleaseHandle final : public ParsedAttrInfo { |
||
| 12864 | constexpr ParsedAttrInfoReleaseHandle() : ParsedAttrInfo( |
||
| 12865 | /*AttrKind=*/ParsedAttr::AT_ReleaseHandle, |
||
| 12866 | /*NumArgs=*/1, |
||
| 12867 | /*OptArgs=*/0, |
||
| 12868 | /*NumArgMembers=*/1, |
||
| 12869 | /*HasCustomParsing=*/0, |
||
| 12870 | /*AcceptsExprPack=*/0, |
||
| 12871 | /*IsTargetSpecific=*/0, |
||
| 12872 | /*IsType=*/0, |
||
| 12873 | /*IsStmt=*/0, |
||
| 12874 | /*IsKnownToGCC=*/0, |
||
| 12875 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 12876 | /*Spellings=*/ReleaseHandleSpellings, |
||
| 12877 | /*ArgNames=*/ReleaseHandleArgNames) {} |
||
| 12878 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 12879 | if (!isa<ParmVarDecl>(D)) { |
||
| 12880 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 12881 | << Attr << "parameters"; |
||
| 12882 | return false; |
||
| 12883 | } |
||
| 12884 | return true; |
||
| 12885 | } |
||
| 12886 | |||
| 12887 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 12888 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 12889 | << AL << St->getBeginLoc(); |
||
| 12890 | return false; |
||
| 12891 | } |
||
| 12892 | |||
| 12893 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 12894 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
||
| 12895 | } |
||
| 12896 | |||
| 12897 | bool isParamExpr(size_t N) const override { |
||
| 12898 | return false; |
||
| 12899 | } |
||
| 12900 | |||
| 12901 | static const ParsedAttrInfoReleaseHandle Instance; |
||
| 12902 | }; |
||
| 12903 | const ParsedAttrInfoReleaseHandle ParsedAttrInfoReleaseHandle::Instance; |
||
| 12904 | static constexpr ParsedAttrInfo::Spelling RenderScriptKernelSpellings[] = { |
||
| 12905 | {AttributeCommonInfo::AS_GNU, "kernel"}, |
||
| 12906 | }; |
||
| 12907 | struct ParsedAttrInfoRenderScriptKernel final : public ParsedAttrInfo { |
||
| 12908 | constexpr ParsedAttrInfoRenderScriptKernel() : ParsedAttrInfo( |
||
| 12909 | /*AttrKind=*/ParsedAttr::AT_RenderScriptKernel, |
||
| 12910 | /*NumArgs=*/0, |
||
| 12911 | /*OptArgs=*/0, |
||
| 12912 | /*NumArgMembers=*/0, |
||
| 12913 | /*HasCustomParsing=*/0, |
||
| 12914 | /*AcceptsExprPack=*/0, |
||
| 12915 | /*IsTargetSpecific=*/0, |
||
| 12916 | /*IsType=*/0, |
||
| 12917 | /*IsStmt=*/0, |
||
| 12918 | /*IsKnownToGCC=*/0, |
||
| 12919 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 12920 | /*Spellings=*/RenderScriptKernelSpellings, |
||
| 12921 | /*ArgNames=*/{}) {} |
||
| 12922 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 12923 | if (!isa<FunctionDecl>(D)) { |
||
| 12924 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 12925 | << Attr << "functions"; |
||
| 12926 | return false; |
||
| 12927 | } |
||
| 12928 | return true; |
||
| 12929 | } |
||
| 12930 | |||
| 12931 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 12932 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 12933 | << AL << St->getBeginLoc(); |
||
| 12934 | return false; |
||
| 12935 | } |
||
| 12936 | |||
| 12937 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 12938 | return LangOpts.RenderScript; |
||
| 12939 | } |
||
| 12940 | |||
| 12941 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 12942 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 12943 | } |
||
| 12944 | |||
| 12945 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 12946 | D->addAttr(::new (S.Context) RenderScriptKernelAttr(S.Context, Attr)); |
||
| 12947 | return AttributeApplied; |
||
| 12948 | } |
||
| 12949 | |||
| 12950 | bool isParamExpr(size_t N) const override { |
||
| 12951 | return false; |
||
| 12952 | } |
||
| 12953 | |||
| 12954 | static const ParsedAttrInfoRenderScriptKernel Instance; |
||
| 12955 | }; |
||
| 12956 | const ParsedAttrInfoRenderScriptKernel ParsedAttrInfoRenderScriptKernel::Instance; |
||
| 12957 | static constexpr ParsedAttrInfo::Spelling ReqdWorkGroupSizeSpellings[] = { |
||
| 12958 | {AttributeCommonInfo::AS_GNU, "reqd_work_group_size"}, |
||
| 12959 | }; |
||
| 12960 | static constexpr const char *ReqdWorkGroupSizeArgNames[] = { |
||
| 12961 | "XDim","YDim","ZDim",}; |
||
| 12962 | struct ParsedAttrInfoReqdWorkGroupSize final : public ParsedAttrInfo { |
||
| 12963 | constexpr ParsedAttrInfoReqdWorkGroupSize() : ParsedAttrInfo( |
||
| 12964 | /*AttrKind=*/ParsedAttr::AT_ReqdWorkGroupSize, |
||
| 12965 | /*NumArgs=*/3, |
||
| 12966 | /*OptArgs=*/0, |
||
| 12967 | /*NumArgMembers=*/3, |
||
| 12968 | /*HasCustomParsing=*/0, |
||
| 12969 | /*AcceptsExprPack=*/0, |
||
| 12970 | /*IsTargetSpecific=*/0, |
||
| 12971 | /*IsType=*/0, |
||
| 12972 | /*IsStmt=*/0, |
||
| 12973 | /*IsKnownToGCC=*/0, |
||
| 12974 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 12975 | /*Spellings=*/ReqdWorkGroupSizeSpellings, |
||
| 12976 | /*ArgNames=*/ReqdWorkGroupSizeArgNames) {} |
||
| 12977 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 12978 | if (!isa<FunctionDecl>(D)) { |
||
| 12979 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 12980 | << Attr << "functions"; |
||
| 12981 | return false; |
||
| 12982 | } |
||
| 12983 | return true; |
||
| 12984 | } |
||
| 12985 | |||
| 12986 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 12987 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 12988 | << AL << St->getBeginLoc(); |
||
| 12989 | return false; |
||
| 12990 | } |
||
| 12991 | |||
| 12992 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 12993 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 12994 | } |
||
| 12995 | |||
| 12996 | bool isParamExpr(size_t N) const override { |
||
| 12997 | return false; |
||
| 12998 | } |
||
| 12999 | |||
| 13000 | static const ParsedAttrInfoReqdWorkGroupSize Instance; |
||
| 13001 | }; |
||
| 13002 | const ParsedAttrInfoReqdWorkGroupSize ParsedAttrInfoReqdWorkGroupSize::Instance; |
||
| 13003 | static constexpr ParsedAttrInfo::Spelling RequiresCapabilitySpellings[] = { |
||
| 13004 | {AttributeCommonInfo::AS_GNU, "requires_capability"}, |
||
| 13005 | {AttributeCommonInfo::AS_CXX11, "clang::requires_capability"}, |
||
| 13006 | {AttributeCommonInfo::AS_GNU, "exclusive_locks_required"}, |
||
| 13007 | {AttributeCommonInfo::AS_CXX11, "clang::exclusive_locks_required"}, |
||
| 13008 | {AttributeCommonInfo::AS_GNU, "requires_shared_capability"}, |
||
| 13009 | {AttributeCommonInfo::AS_CXX11, "clang::requires_shared_capability"}, |
||
| 13010 | {AttributeCommonInfo::AS_GNU, "shared_locks_required"}, |
||
| 13011 | {AttributeCommonInfo::AS_CXX11, "clang::shared_locks_required"}, |
||
| 13012 | }; |
||
| 13013 | static constexpr const char *RequiresCapabilityArgNames[] = { |
||
| 13014 | "Args...",}; |
||
| 13015 | struct ParsedAttrInfoRequiresCapability final : public ParsedAttrInfo { |
||
| 13016 | constexpr ParsedAttrInfoRequiresCapability() : ParsedAttrInfo( |
||
| 13017 | /*AttrKind=*/ParsedAttr::AT_RequiresCapability, |
||
| 13018 | /*NumArgs=*/0, |
||
| 13019 | /*OptArgs=*/15, |
||
| 13020 | /*NumArgMembers=*/1, |
||
| 13021 | /*HasCustomParsing=*/0, |
||
| 13022 | /*AcceptsExprPack=*/0, |
||
| 13023 | /*IsTargetSpecific=*/0, |
||
| 13024 | /*IsType=*/0, |
||
| 13025 | /*IsStmt=*/0, |
||
| 13026 | /*IsKnownToGCC=*/0, |
||
| 13027 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 13028 | /*Spellings=*/RequiresCapabilitySpellings, |
||
| 13029 | /*ArgNames=*/RequiresCapabilityArgNames) {} |
||
| 13030 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 13031 | if (!isa<FunctionDecl>(D)) { |
||
| 13032 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 13033 | << Attr << "functions"; |
||
| 13034 | return false; |
||
| 13035 | } |
||
| 13036 | return true; |
||
| 13037 | } |
||
| 13038 | |||
| 13039 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 13040 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 13041 | << AL << St->getBeginLoc(); |
||
| 13042 | return false; |
||
| 13043 | } |
||
| 13044 | |||
| 13045 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 13046 | enum Spelling { |
||
| 13047 | GNU_requires_capability = 0, |
||
| 13048 | CXX11_clang_requires_capability = 1, |
||
| 13049 | GNU_exclusive_locks_required = 2, |
||
| 13050 | CXX11_clang_exclusive_locks_required = 3, |
||
| 13051 | GNU_requires_shared_capability = 4, |
||
| 13052 | CXX11_clang_requires_shared_capability = 5, |
||
| 13053 | GNU_shared_locks_required = 6, |
||
| 13054 | CXX11_clang_shared_locks_required = 7, |
||
| 13055 | SpellingNotCalculated = 15 |
||
| 13056 | |||
| 13057 | }; |
||
| 13058 | |||
| 13059 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 13060 | switch (Idx) { |
||
| 13061 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 13062 | case 0: return GNU_requires_capability; |
||
| 13063 | case 1: return CXX11_clang_requires_capability; |
||
| 13064 | case 2: return GNU_exclusive_locks_required; |
||
| 13065 | case 3: return CXX11_clang_exclusive_locks_required; |
||
| 13066 | case 4: return GNU_requires_shared_capability; |
||
| 13067 | case 5: return CXX11_clang_requires_shared_capability; |
||
| 13068 | case 6: return GNU_shared_locks_required; |
||
| 13069 | case 7: return CXX11_clang_shared_locks_required; |
||
| 13070 | } |
||
| 13071 | } |
||
| 13072 | |||
| 13073 | bool isParamExpr(size_t N) const override { |
||
| 13074 | return (N == 0) || false; |
||
| 13075 | } |
||
| 13076 | |||
| 13077 | static const ParsedAttrInfoRequiresCapability Instance; |
||
| 13078 | }; |
||
| 13079 | const ParsedAttrInfoRequiresCapability ParsedAttrInfoRequiresCapability::Instance; |
||
| 13080 | static constexpr ParsedAttrInfo::Spelling RestrictSpellings[] = { |
||
| 13081 | {AttributeCommonInfo::AS_Declspec, "restrict"}, |
||
| 13082 | {AttributeCommonInfo::AS_GNU, "malloc"}, |
||
| 13083 | {AttributeCommonInfo::AS_CXX11, "gnu::malloc"}, |
||
| 13084 | {AttributeCommonInfo::AS_C2x, "gnu::malloc"}, |
||
| 13085 | }; |
||
| 13086 | struct ParsedAttrInfoRestrict final : public ParsedAttrInfo { |
||
| 13087 | constexpr ParsedAttrInfoRestrict() : ParsedAttrInfo( |
||
| 13088 | /*AttrKind=*/ParsedAttr::AT_Restrict, |
||
| 13089 | /*NumArgs=*/0, |
||
| 13090 | /*OptArgs=*/0, |
||
| 13091 | /*NumArgMembers=*/0, |
||
| 13092 | /*HasCustomParsing=*/0, |
||
| 13093 | /*AcceptsExprPack=*/0, |
||
| 13094 | /*IsTargetSpecific=*/0, |
||
| 13095 | /*IsType=*/0, |
||
| 13096 | /*IsStmt=*/0, |
||
| 13097 | /*IsKnownToGCC=*/1, |
||
| 13098 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 13099 | /*Spellings=*/RestrictSpellings, |
||
| 13100 | /*ArgNames=*/{}) {} |
||
| 13101 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 13102 | if (!isa<FunctionDecl>(D)) { |
||
| 13103 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 13104 | << Attr << "functions"; |
||
| 13105 | return false; |
||
| 13106 | } |
||
| 13107 | return true; |
||
| 13108 | } |
||
| 13109 | |||
| 13110 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 13111 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 13112 | << AL << St->getBeginLoc(); |
||
| 13113 | return false; |
||
| 13114 | } |
||
| 13115 | |||
| 13116 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 13117 | enum Spelling { |
||
| 13118 | Declspec_restrict = 0, |
||
| 13119 | GNU_malloc = 1, |
||
| 13120 | CXX11_gnu_malloc = 2, |
||
| 13121 | C2x_gnu_malloc = 3, |
||
| 13122 | SpellingNotCalculated = 15 |
||
| 13123 | |||
| 13124 | }; |
||
| 13125 | |||
| 13126 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 13127 | switch (Idx) { |
||
| 13128 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 13129 | case 0: return Declspec_restrict; |
||
| 13130 | case 1: return GNU_malloc; |
||
| 13131 | case 2: return CXX11_gnu_malloc; |
||
| 13132 | case 3: return C2x_gnu_malloc; |
||
| 13133 | } |
||
| 13134 | } |
||
| 13135 | |||
| 13136 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 13137 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 13138 | } |
||
| 13139 | |||
| 13140 | bool isParamExpr(size_t N) const override { |
||
| 13141 | return false; |
||
| 13142 | } |
||
| 13143 | |||
| 13144 | static const ParsedAttrInfoRestrict Instance; |
||
| 13145 | }; |
||
| 13146 | const ParsedAttrInfoRestrict ParsedAttrInfoRestrict::Instance; |
||
| 13147 | static constexpr ParsedAttrInfo::Spelling RetainSpellings[] = { |
||
| 13148 | {AttributeCommonInfo::AS_GNU, "retain"}, |
||
| 13149 | {AttributeCommonInfo::AS_CXX11, "gnu::retain"}, |
||
| 13150 | {AttributeCommonInfo::AS_C2x, "gnu::retain"}, |
||
| 13151 | }; |
||
| 13152 | struct ParsedAttrInfoRetain final : public ParsedAttrInfo { |
||
| 13153 | constexpr ParsedAttrInfoRetain() : ParsedAttrInfo( |
||
| 13154 | /*AttrKind=*/ParsedAttr::AT_Retain, |
||
| 13155 | /*NumArgs=*/0, |
||
| 13156 | /*OptArgs=*/0, |
||
| 13157 | /*NumArgMembers=*/0, |
||
| 13158 | /*HasCustomParsing=*/0, |
||
| 13159 | /*AcceptsExprPack=*/0, |
||
| 13160 | /*IsTargetSpecific=*/0, |
||
| 13161 | /*IsType=*/0, |
||
| 13162 | /*IsStmt=*/0, |
||
| 13163 | /*IsKnownToGCC=*/1, |
||
| 13164 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 13165 | /*Spellings=*/RetainSpellings, |
||
| 13166 | /*ArgNames=*/{}) {} |
||
| 13167 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 13168 | if (!isNonLocalVar(D) && !isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
||
| 13169 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 13170 | << Attr << "variables with non-local storage, functions, and Objective-C methods"; |
||
| 13171 | return false; |
||
| 13172 | } |
||
| 13173 | return true; |
||
| 13174 | } |
||
| 13175 | |||
| 13176 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 13177 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 13178 | << AL << St->getBeginLoc(); |
||
| 13179 | return false; |
||
| 13180 | } |
||
| 13181 | |||
| 13182 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 13183 | D->addAttr(::new (S.Context) RetainAttr(S.Context, Attr)); |
||
| 13184 | return AttributeApplied; |
||
| 13185 | } |
||
| 13186 | |||
| 13187 | bool isParamExpr(size_t N) const override { |
||
| 13188 | return false; |
||
| 13189 | } |
||
| 13190 | |||
| 13191 | static const ParsedAttrInfoRetain Instance; |
||
| 13192 | }; |
||
| 13193 | const ParsedAttrInfoRetain ParsedAttrInfoRetain::Instance; |
||
| 13194 | static constexpr ParsedAttrInfo::Spelling ReturnTypestateSpellings[] = { |
||
| 13195 | {AttributeCommonInfo::AS_GNU, "return_typestate"}, |
||
| 13196 | {AttributeCommonInfo::AS_CXX11, "clang::return_typestate"}, |
||
| 13197 | }; |
||
| 13198 | static constexpr const char *ReturnTypestateArgNames[] = { |
||
| 13199 | "State",}; |
||
| 13200 | struct ParsedAttrInfoReturnTypestate final : public ParsedAttrInfo { |
||
| 13201 | constexpr ParsedAttrInfoReturnTypestate() : ParsedAttrInfo( |
||
| 13202 | /*AttrKind=*/ParsedAttr::AT_ReturnTypestate, |
||
| 13203 | /*NumArgs=*/1, |
||
| 13204 | /*OptArgs=*/0, |
||
| 13205 | /*NumArgMembers=*/1, |
||
| 13206 | /*HasCustomParsing=*/0, |
||
| 13207 | /*AcceptsExprPack=*/0, |
||
| 13208 | /*IsTargetSpecific=*/0, |
||
| 13209 | /*IsType=*/0, |
||
| 13210 | /*IsStmt=*/0, |
||
| 13211 | /*IsKnownToGCC=*/0, |
||
| 13212 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 13213 | /*Spellings=*/ReturnTypestateSpellings, |
||
| 13214 | /*ArgNames=*/ReturnTypestateArgNames) {} |
||
| 13215 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 13216 | if (!isa<FunctionDecl>(D) && !isa<ParmVarDecl>(D)) { |
||
| 13217 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 13218 | << Attr << "functions and parameters"; |
||
| 13219 | return false; |
||
| 13220 | } |
||
| 13221 | return true; |
||
| 13222 | } |
||
| 13223 | |||
| 13224 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 13225 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 13226 | << AL << St->getBeginLoc(); |
||
| 13227 | return false; |
||
| 13228 | } |
||
| 13229 | |||
| 13230 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 13231 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 13232 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
||
| 13233 | } |
||
| 13234 | |||
| 13235 | bool isParamExpr(size_t N) const override { |
||
| 13236 | return false; |
||
| 13237 | } |
||
| 13238 | |||
| 13239 | static const ParsedAttrInfoReturnTypestate Instance; |
||
| 13240 | }; |
||
| 13241 | const ParsedAttrInfoReturnTypestate ParsedAttrInfoReturnTypestate::Instance; |
||
| 13242 | static constexpr ParsedAttrInfo::Spelling ReturnsNonNullSpellings[] = { |
||
| 13243 | {AttributeCommonInfo::AS_GNU, "returns_nonnull"}, |
||
| 13244 | {AttributeCommonInfo::AS_CXX11, "gnu::returns_nonnull"}, |
||
| 13245 | {AttributeCommonInfo::AS_C2x, "gnu::returns_nonnull"}, |
||
| 13246 | }; |
||
| 13247 | struct ParsedAttrInfoReturnsNonNull final : public ParsedAttrInfo { |
||
| 13248 | constexpr ParsedAttrInfoReturnsNonNull() : ParsedAttrInfo( |
||
| 13249 | /*AttrKind=*/ParsedAttr::AT_ReturnsNonNull, |
||
| 13250 | /*NumArgs=*/0, |
||
| 13251 | /*OptArgs=*/0, |
||
| 13252 | /*NumArgMembers=*/0, |
||
| 13253 | /*HasCustomParsing=*/0, |
||
| 13254 | /*AcceptsExprPack=*/0, |
||
| 13255 | /*IsTargetSpecific=*/0, |
||
| 13256 | /*IsType=*/0, |
||
| 13257 | /*IsStmt=*/0, |
||
| 13258 | /*IsKnownToGCC=*/1, |
||
| 13259 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 13260 | /*Spellings=*/ReturnsNonNullSpellings, |
||
| 13261 | /*ArgNames=*/{}) {} |
||
| 13262 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 13263 | if (!isa<ObjCMethodDecl>(D) && !isa<FunctionDecl>(D)) { |
||
| 13264 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 13265 | << Attr << "Objective-C methods and functions"; |
||
| 13266 | return false; |
||
| 13267 | } |
||
| 13268 | return true; |
||
| 13269 | } |
||
| 13270 | |||
| 13271 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 13272 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 13273 | << AL << St->getBeginLoc(); |
||
| 13274 | return false; |
||
| 13275 | } |
||
| 13276 | |||
| 13277 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 13278 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 13279 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 13280 | } |
||
| 13281 | |||
| 13282 | bool isParamExpr(size_t N) const override { |
||
| 13283 | return false; |
||
| 13284 | } |
||
| 13285 | |||
| 13286 | static const ParsedAttrInfoReturnsNonNull Instance; |
||
| 13287 | }; |
||
| 13288 | const ParsedAttrInfoReturnsNonNull ParsedAttrInfoReturnsNonNull::Instance; |
||
| 13289 | static constexpr ParsedAttrInfo::Spelling ReturnsTwiceSpellings[] = { |
||
| 13290 | {AttributeCommonInfo::AS_GNU, "returns_twice"}, |
||
| 13291 | {AttributeCommonInfo::AS_CXX11, "gnu::returns_twice"}, |
||
| 13292 | {AttributeCommonInfo::AS_C2x, "gnu::returns_twice"}, |
||
| 13293 | }; |
||
| 13294 | struct ParsedAttrInfoReturnsTwice final : public ParsedAttrInfo { |
||
| 13295 | constexpr ParsedAttrInfoReturnsTwice() : ParsedAttrInfo( |
||
| 13296 | /*AttrKind=*/ParsedAttr::AT_ReturnsTwice, |
||
| 13297 | /*NumArgs=*/0, |
||
| 13298 | /*OptArgs=*/0, |
||
| 13299 | /*NumArgMembers=*/0, |
||
| 13300 | /*HasCustomParsing=*/0, |
||
| 13301 | /*AcceptsExprPack=*/0, |
||
| 13302 | /*IsTargetSpecific=*/0, |
||
| 13303 | /*IsType=*/0, |
||
| 13304 | /*IsStmt=*/0, |
||
| 13305 | /*IsKnownToGCC=*/1, |
||
| 13306 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 13307 | /*Spellings=*/ReturnsTwiceSpellings, |
||
| 13308 | /*ArgNames=*/{}) {} |
||
| 13309 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 13310 | if (!isa<FunctionDecl>(D)) { |
||
| 13311 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 13312 | << Attr << "functions"; |
||
| 13313 | return false; |
||
| 13314 | } |
||
| 13315 | return true; |
||
| 13316 | } |
||
| 13317 | |||
| 13318 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 13319 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 13320 | << AL << St->getBeginLoc(); |
||
| 13321 | return false; |
||
| 13322 | } |
||
| 13323 | |||
| 13324 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 13325 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 13326 | } |
||
| 13327 | |||
| 13328 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 13329 | D->addAttr(::new (S.Context) ReturnsTwiceAttr(S.Context, Attr)); |
||
| 13330 | return AttributeApplied; |
||
| 13331 | } |
||
| 13332 | |||
| 13333 | bool isParamExpr(size_t N) const override { |
||
| 13334 | return false; |
||
| 13335 | } |
||
| 13336 | |||
| 13337 | static const ParsedAttrInfoReturnsTwice Instance; |
||
| 13338 | }; |
||
| 13339 | const ParsedAttrInfoReturnsTwice ParsedAttrInfoReturnsTwice::Instance; |
||
| 13340 | static constexpr ParsedAttrInfo::Spelling SPtrSpellings[] = { |
||
| 13341 | {AttributeCommonInfo::AS_Keyword, "__sptr"}, |
||
| 13342 | }; |
||
| 13343 | struct ParsedAttrInfoSPtr final : public ParsedAttrInfo { |
||
| 13344 | constexpr ParsedAttrInfoSPtr() : ParsedAttrInfo( |
||
| 13345 | /*AttrKind=*/ParsedAttr::AT_SPtr, |
||
| 13346 | /*NumArgs=*/0, |
||
| 13347 | /*OptArgs=*/0, |
||
| 13348 | /*NumArgMembers=*/0, |
||
| 13349 | /*HasCustomParsing=*/0, |
||
| 13350 | /*AcceptsExprPack=*/0, |
||
| 13351 | /*IsTargetSpecific=*/0, |
||
| 13352 | /*IsType=*/1, |
||
| 13353 | /*IsStmt=*/0, |
||
| 13354 | /*IsKnownToGCC=*/0, |
||
| 13355 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 13356 | /*Spellings=*/SPtrSpellings, |
||
| 13357 | /*ArgNames=*/{}) {} |
||
| 13358 | bool isParamExpr(size_t N) const override { |
||
| 13359 | return false; |
||
| 13360 | } |
||
| 13361 | |||
| 13362 | static const ParsedAttrInfoSPtr Instance; |
||
| 13363 | }; |
||
| 13364 | const ParsedAttrInfoSPtr ParsedAttrInfoSPtr::Instance; |
||
| 13365 | static constexpr ParsedAttrInfo::Spelling SYCLKernelSpellings[] = { |
||
| 13366 | {AttributeCommonInfo::AS_GNU, "sycl_kernel"}, |
||
| 13367 | {AttributeCommonInfo::AS_CXX11, "clang::sycl_kernel"}, |
||
| 13368 | {AttributeCommonInfo::AS_C2x, "clang::sycl_kernel"}, |
||
| 13369 | }; |
||
| 13370 | struct ParsedAttrInfoSYCLKernel final : public ParsedAttrInfo { |
||
| 13371 | constexpr ParsedAttrInfoSYCLKernel() : ParsedAttrInfo( |
||
| 13372 | /*AttrKind=*/ParsedAttr::AT_SYCLKernel, |
||
| 13373 | /*NumArgs=*/0, |
||
| 13374 | /*OptArgs=*/0, |
||
| 13375 | /*NumArgMembers=*/0, |
||
| 13376 | /*HasCustomParsing=*/0, |
||
| 13377 | /*AcceptsExprPack=*/0, |
||
| 13378 | /*IsTargetSpecific=*/0, |
||
| 13379 | /*IsType=*/0, |
||
| 13380 | /*IsStmt=*/0, |
||
| 13381 | /*IsKnownToGCC=*/0, |
||
| 13382 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 13383 | /*Spellings=*/SYCLKernelSpellings, |
||
| 13384 | /*ArgNames=*/{}) {} |
||
| 13385 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 13386 | if (!isFunctionTmpl(D)) { |
||
| 13387 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 13388 | << Attr << "function templates"; |
||
| 13389 | return false; |
||
| 13390 | } |
||
| 13391 | return true; |
||
| 13392 | } |
||
| 13393 | |||
| 13394 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 13395 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 13396 | << AL << St->getBeginLoc(); |
||
| 13397 | return false; |
||
| 13398 | } |
||
| 13399 | |||
| 13400 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 13401 | return LangOpts.SYCLIsDevice; |
||
| 13402 | } |
||
| 13403 | |||
| 13404 | bool isParamExpr(size_t N) const override { |
||
| 13405 | return false; |
||
| 13406 | } |
||
| 13407 | |||
| 13408 | static const ParsedAttrInfoSYCLKernel Instance; |
||
| 13409 | }; |
||
| 13410 | const ParsedAttrInfoSYCLKernel ParsedAttrInfoSYCLKernel::Instance; |
||
| 13411 | static constexpr ParsedAttrInfo::Spelling SYCLSpecialClassSpellings[] = { |
||
| 13412 | {AttributeCommonInfo::AS_GNU, "sycl_special_class"}, |
||
| 13413 | {AttributeCommonInfo::AS_CXX11, "clang::sycl_special_class"}, |
||
| 13414 | {AttributeCommonInfo::AS_C2x, "clang::sycl_special_class"}, |
||
| 13415 | }; |
||
| 13416 | struct ParsedAttrInfoSYCLSpecialClass final : public ParsedAttrInfo { |
||
| 13417 | constexpr ParsedAttrInfoSYCLSpecialClass() : ParsedAttrInfo( |
||
| 13418 | /*AttrKind=*/ParsedAttr::AT_SYCLSpecialClass, |
||
| 13419 | /*NumArgs=*/0, |
||
| 13420 | /*OptArgs=*/0, |
||
| 13421 | /*NumArgMembers=*/0, |
||
| 13422 | /*HasCustomParsing=*/0, |
||
| 13423 | /*AcceptsExprPack=*/0, |
||
| 13424 | /*IsTargetSpecific=*/0, |
||
| 13425 | /*IsType=*/0, |
||
| 13426 | /*IsStmt=*/0, |
||
| 13427 | /*IsKnownToGCC=*/0, |
||
| 13428 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 13429 | /*Spellings=*/SYCLSpecialClassSpellings, |
||
| 13430 | /*ArgNames=*/{}) {} |
||
| 13431 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 13432 | if (!isa<CXXRecordDecl>(D)) { |
||
| 13433 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 13434 | << Attr << "classes"; |
||
| 13435 | return false; |
||
| 13436 | } |
||
| 13437 | return true; |
||
| 13438 | } |
||
| 13439 | |||
| 13440 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 13441 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 13442 | << AL << St->getBeginLoc(); |
||
| 13443 | return false; |
||
| 13444 | } |
||
| 13445 | |||
| 13446 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 13447 | return LangOpts.SYCLIsDevice; |
||
| 13448 | } |
||
| 13449 | |||
| 13450 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 13451 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 13452 | } |
||
| 13453 | |||
| 13454 | bool isParamExpr(size_t N) const override { |
||
| 13455 | return false; |
||
| 13456 | } |
||
| 13457 | |||
| 13458 | static const ParsedAttrInfoSYCLSpecialClass Instance; |
||
| 13459 | }; |
||
| 13460 | const ParsedAttrInfoSYCLSpecialClass ParsedAttrInfoSYCLSpecialClass::Instance; |
||
| 13461 | static constexpr ParsedAttrInfo::Spelling ScopedLockableSpellings[] = { |
||
| 13462 | {AttributeCommonInfo::AS_GNU, "scoped_lockable"}, |
||
| 13463 | {AttributeCommonInfo::AS_CXX11, "clang::scoped_lockable"}, |
||
| 13464 | }; |
||
| 13465 | struct ParsedAttrInfoScopedLockable final : public ParsedAttrInfo { |
||
| 13466 | constexpr ParsedAttrInfoScopedLockable() : ParsedAttrInfo( |
||
| 13467 | /*AttrKind=*/ParsedAttr::AT_ScopedLockable, |
||
| 13468 | /*NumArgs=*/0, |
||
| 13469 | /*OptArgs=*/0, |
||
| 13470 | /*NumArgMembers=*/0, |
||
| 13471 | /*HasCustomParsing=*/0, |
||
| 13472 | /*AcceptsExprPack=*/0, |
||
| 13473 | /*IsTargetSpecific=*/0, |
||
| 13474 | /*IsType=*/0, |
||
| 13475 | /*IsStmt=*/0, |
||
| 13476 | /*IsKnownToGCC=*/0, |
||
| 13477 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 13478 | /*Spellings=*/ScopedLockableSpellings, |
||
| 13479 | /*ArgNames=*/{}) {} |
||
| 13480 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 13481 | if (!isa<RecordDecl>(D)) { |
||
| 13482 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 13483 | << Attr << "structs, unions, and classes"; |
||
| 13484 | return false; |
||
| 13485 | } |
||
| 13486 | return true; |
||
| 13487 | } |
||
| 13488 | |||
| 13489 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 13490 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 13491 | << AL << St->getBeginLoc(); |
||
| 13492 | return false; |
||
| 13493 | } |
||
| 13494 | |||
| 13495 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 13496 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 13497 | } |
||
| 13498 | |||
| 13499 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 13500 | D->addAttr(::new (S.Context) ScopedLockableAttr(S.Context, Attr)); |
||
| 13501 | return AttributeApplied; |
||
| 13502 | } |
||
| 13503 | |||
| 13504 | bool isParamExpr(size_t N) const override { |
||
| 13505 | return false; |
||
| 13506 | } |
||
| 13507 | |||
| 13508 | static const ParsedAttrInfoScopedLockable Instance; |
||
| 13509 | }; |
||
| 13510 | const ParsedAttrInfoScopedLockable ParsedAttrInfoScopedLockable::Instance; |
||
| 13511 | static constexpr ParsedAttrInfo::Spelling SectionSpellings[] = { |
||
| 13512 | {AttributeCommonInfo::AS_GNU, "section"}, |
||
| 13513 | {AttributeCommonInfo::AS_CXX11, "gnu::section"}, |
||
| 13514 | {AttributeCommonInfo::AS_C2x, "gnu::section"}, |
||
| 13515 | {AttributeCommonInfo::AS_Declspec, "allocate"}, |
||
| 13516 | }; |
||
| 13517 | static constexpr const char *SectionArgNames[] = { |
||
| 13518 | "Name",}; |
||
| 13519 | struct ParsedAttrInfoSection final : public ParsedAttrInfo { |
||
| 13520 | constexpr ParsedAttrInfoSection() : ParsedAttrInfo( |
||
| 13521 | /*AttrKind=*/ParsedAttr::AT_Section, |
||
| 13522 | /*NumArgs=*/1, |
||
| 13523 | /*OptArgs=*/0, |
||
| 13524 | /*NumArgMembers=*/1, |
||
| 13525 | /*HasCustomParsing=*/0, |
||
| 13526 | /*AcceptsExprPack=*/0, |
||
| 13527 | /*IsTargetSpecific=*/0, |
||
| 13528 | /*IsType=*/0, |
||
| 13529 | /*IsStmt=*/0, |
||
| 13530 | /*IsKnownToGCC=*/1, |
||
| 13531 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 13532 | /*Spellings=*/SectionSpellings, |
||
| 13533 | /*ArgNames=*/SectionArgNames) {} |
||
| 13534 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 13535 | if (!isa<FunctionDecl>(D) && !isGlobalVar(D) && !isa<ObjCMethodDecl>(D) && !isa<ObjCPropertyDecl>(D)) { |
||
| 13536 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 13537 | << Attr << "functions, global variables, Objective-C methods, and Objective-C properties"; |
||
| 13538 | return false; |
||
| 13539 | } |
||
| 13540 | return true; |
||
| 13541 | } |
||
| 13542 | |||
| 13543 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 13544 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 13545 | << AL << St->getBeginLoc(); |
||
| 13546 | return false; |
||
| 13547 | } |
||
| 13548 | |||
| 13549 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 13550 | enum Spelling { |
||
| 13551 | GNU_section = 0, |
||
| 13552 | CXX11_gnu_section = 1, |
||
| 13553 | C2x_gnu_section = 2, |
||
| 13554 | Declspec_allocate = 3, |
||
| 13555 | SpellingNotCalculated = 15 |
||
| 13556 | |||
| 13557 | }; |
||
| 13558 | |||
| 13559 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 13560 | switch (Idx) { |
||
| 13561 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 13562 | case 0: return GNU_section; |
||
| 13563 | case 1: return CXX11_gnu_section; |
||
| 13564 | case 2: return C2x_gnu_section; |
||
| 13565 | case 3: return Declspec_allocate; |
||
| 13566 | } |
||
| 13567 | } |
||
| 13568 | |||
| 13569 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 13570 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 13571 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_global, /*IsSupported=*/true)); |
||
| 13572 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 13573 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_property, /*IsSupported=*/LangOpts.ObjC)); |
||
| 13574 | } |
||
| 13575 | |||
| 13576 | bool isParamExpr(size_t N) const override { |
||
| 13577 | return false; |
||
| 13578 | } |
||
| 13579 | |||
| 13580 | static const ParsedAttrInfoSection Instance; |
||
| 13581 | }; |
||
| 13582 | const ParsedAttrInfoSection ParsedAttrInfoSection::Instance; |
||
| 13583 | static constexpr ParsedAttrInfo::Spelling SelectAnySpellings[] = { |
||
| 13584 | {AttributeCommonInfo::AS_Declspec, "selectany"}, |
||
| 13585 | {AttributeCommonInfo::AS_GNU, "selectany"}, |
||
| 13586 | {AttributeCommonInfo::AS_CXX11, "gnu::selectany"}, |
||
| 13587 | {AttributeCommonInfo::AS_C2x, "gnu::selectany"}, |
||
| 13588 | }; |
||
| 13589 | struct ParsedAttrInfoSelectAny final : public ParsedAttrInfo { |
||
| 13590 | constexpr ParsedAttrInfoSelectAny() : ParsedAttrInfo( |
||
| 13591 | /*AttrKind=*/ParsedAttr::AT_SelectAny, |
||
| 13592 | /*NumArgs=*/0, |
||
| 13593 | /*OptArgs=*/0, |
||
| 13594 | /*NumArgMembers=*/0, |
||
| 13595 | /*HasCustomParsing=*/0, |
||
| 13596 | /*AcceptsExprPack=*/0, |
||
| 13597 | /*IsTargetSpecific=*/0, |
||
| 13598 | /*IsType=*/0, |
||
| 13599 | /*IsStmt=*/0, |
||
| 13600 | /*IsKnownToGCC=*/1, |
||
| 13601 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 13602 | /*Spellings=*/SelectAnySpellings, |
||
| 13603 | /*ArgNames=*/{}) {} |
||
| 13604 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 13605 | D->addAttr(::new (S.Context) SelectAnyAttr(S.Context, Attr)); |
||
| 13606 | return AttributeApplied; |
||
| 13607 | } |
||
| 13608 | |||
| 13609 | bool isParamExpr(size_t N) const override { |
||
| 13610 | return false; |
||
| 13611 | } |
||
| 13612 | |||
| 13613 | static const ParsedAttrInfoSelectAny Instance; |
||
| 13614 | }; |
||
| 13615 | const ParsedAttrInfoSelectAny ParsedAttrInfoSelectAny::Instance; |
||
| 13616 | static constexpr ParsedAttrInfo::Spelling SentinelSpellings[] = { |
||
| 13617 | {AttributeCommonInfo::AS_GNU, "sentinel"}, |
||
| 13618 | {AttributeCommonInfo::AS_CXX11, "gnu::sentinel"}, |
||
| 13619 | {AttributeCommonInfo::AS_C2x, "gnu::sentinel"}, |
||
| 13620 | }; |
||
| 13621 | static constexpr const char *SentinelArgNames[] = { |
||
| 13622 | "Sentinel","NullPos",}; |
||
| 13623 | struct ParsedAttrInfoSentinel final : public ParsedAttrInfo { |
||
| 13624 | constexpr ParsedAttrInfoSentinel() : ParsedAttrInfo( |
||
| 13625 | /*AttrKind=*/ParsedAttr::AT_Sentinel, |
||
| 13626 | /*NumArgs=*/0, |
||
| 13627 | /*OptArgs=*/2, |
||
| 13628 | /*NumArgMembers=*/2, |
||
| 13629 | /*HasCustomParsing=*/0, |
||
| 13630 | /*AcceptsExprPack=*/0, |
||
| 13631 | /*IsTargetSpecific=*/0, |
||
| 13632 | /*IsType=*/0, |
||
| 13633 | /*IsStmt=*/0, |
||
| 13634 | /*IsKnownToGCC=*/1, |
||
| 13635 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 13636 | /*Spellings=*/SentinelSpellings, |
||
| 13637 | /*ArgNames=*/SentinelArgNames) {} |
||
| 13638 | bool isParamExpr(size_t N) const override { |
||
| 13639 | return false; |
||
| 13640 | } |
||
| 13641 | |||
| 13642 | static const ParsedAttrInfoSentinel Instance; |
||
| 13643 | }; |
||
| 13644 | const ParsedAttrInfoSentinel ParsedAttrInfoSentinel::Instance; |
||
| 13645 | static constexpr ParsedAttrInfo::Spelling SetTypestateSpellings[] = { |
||
| 13646 | {AttributeCommonInfo::AS_GNU, "set_typestate"}, |
||
| 13647 | {AttributeCommonInfo::AS_CXX11, "clang::set_typestate"}, |
||
| 13648 | }; |
||
| 13649 | static constexpr const char *SetTypestateArgNames[] = { |
||
| 13650 | "NewState",}; |
||
| 13651 | struct ParsedAttrInfoSetTypestate final : public ParsedAttrInfo { |
||
| 13652 | constexpr ParsedAttrInfoSetTypestate() : ParsedAttrInfo( |
||
| 13653 | /*AttrKind=*/ParsedAttr::AT_SetTypestate, |
||
| 13654 | /*NumArgs=*/1, |
||
| 13655 | /*OptArgs=*/0, |
||
| 13656 | /*NumArgMembers=*/1, |
||
| 13657 | /*HasCustomParsing=*/0, |
||
| 13658 | /*AcceptsExprPack=*/0, |
||
| 13659 | /*IsTargetSpecific=*/0, |
||
| 13660 | /*IsType=*/0, |
||
| 13661 | /*IsStmt=*/0, |
||
| 13662 | /*IsKnownToGCC=*/0, |
||
| 13663 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 13664 | /*Spellings=*/SetTypestateSpellings, |
||
| 13665 | /*ArgNames=*/SetTypestateArgNames) {} |
||
| 13666 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 13667 | if (!isa<CXXMethodDecl>(D)) { |
||
| 13668 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 13669 | << Attr << "functions"; |
||
| 13670 | return false; |
||
| 13671 | } |
||
| 13672 | return true; |
||
| 13673 | } |
||
| 13674 | |||
| 13675 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 13676 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 13677 | << AL << St->getBeginLoc(); |
||
| 13678 | return false; |
||
| 13679 | } |
||
| 13680 | |||
| 13681 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 13682 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function_is_member, /*IsSupported=*/LangOpts.CPlusPlus)); |
||
| 13683 | } |
||
| 13684 | |||
| 13685 | bool isParamExpr(size_t N) const override { |
||
| 13686 | return false; |
||
| 13687 | } |
||
| 13688 | |||
| 13689 | static const ParsedAttrInfoSetTypestate Instance; |
||
| 13690 | }; |
||
| 13691 | const ParsedAttrInfoSetTypestate ParsedAttrInfoSetTypestate::Instance; |
||
| 13692 | static constexpr ParsedAttrInfo::Spelling SharedTrylockFunctionSpellings[] = { |
||
| 13693 | {AttributeCommonInfo::AS_GNU, "shared_trylock_function"}, |
||
| 13694 | }; |
||
| 13695 | static constexpr const char *SharedTrylockFunctionArgNames[] = { |
||
| 13696 | "SuccessValue","Args...",}; |
||
| 13697 | struct ParsedAttrInfoSharedTrylockFunction final : public ParsedAttrInfo { |
||
| 13698 | constexpr ParsedAttrInfoSharedTrylockFunction() : ParsedAttrInfo( |
||
| 13699 | /*AttrKind=*/ParsedAttr::AT_SharedTrylockFunction, |
||
| 13700 | /*NumArgs=*/1, |
||
| 13701 | /*OptArgs=*/15, |
||
| 13702 | /*NumArgMembers=*/2, |
||
| 13703 | /*HasCustomParsing=*/0, |
||
| 13704 | /*AcceptsExprPack=*/0, |
||
| 13705 | /*IsTargetSpecific=*/0, |
||
| 13706 | /*IsType=*/0, |
||
| 13707 | /*IsStmt=*/0, |
||
| 13708 | /*IsKnownToGCC=*/0, |
||
| 13709 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 13710 | /*Spellings=*/SharedTrylockFunctionSpellings, |
||
| 13711 | /*ArgNames=*/SharedTrylockFunctionArgNames) {} |
||
| 13712 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 13713 | if (!isa<FunctionDecl>(D)) { |
||
| 13714 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 13715 | << Attr << "functions"; |
||
| 13716 | return false; |
||
| 13717 | } |
||
| 13718 | return true; |
||
| 13719 | } |
||
| 13720 | |||
| 13721 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 13722 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 13723 | << AL << St->getBeginLoc(); |
||
| 13724 | return false; |
||
| 13725 | } |
||
| 13726 | |||
| 13727 | bool isParamExpr(size_t N) const override { |
||
| 13728 | return (N == 0) || (N == 1) || false; |
||
| 13729 | } |
||
| 13730 | |||
| 13731 | static const ParsedAttrInfoSharedTrylockFunction Instance; |
||
| 13732 | }; |
||
| 13733 | const ParsedAttrInfoSharedTrylockFunction ParsedAttrInfoSharedTrylockFunction::Instance; |
||
| 13734 | static constexpr ParsedAttrInfo::Spelling SpeculativeLoadHardeningSpellings[] = { |
||
| 13735 | {AttributeCommonInfo::AS_GNU, "speculative_load_hardening"}, |
||
| 13736 | {AttributeCommonInfo::AS_CXX11, "clang::speculative_load_hardening"}, |
||
| 13737 | {AttributeCommonInfo::AS_C2x, "clang::speculative_load_hardening"}, |
||
| 13738 | }; |
||
| 13739 | struct ParsedAttrInfoSpeculativeLoadHardening final : public ParsedAttrInfo { |
||
| 13740 | constexpr ParsedAttrInfoSpeculativeLoadHardening() : ParsedAttrInfo( |
||
| 13741 | /*AttrKind=*/ParsedAttr::AT_SpeculativeLoadHardening, |
||
| 13742 | /*NumArgs=*/0, |
||
| 13743 | /*OptArgs=*/0, |
||
| 13744 | /*NumArgMembers=*/0, |
||
| 13745 | /*HasCustomParsing=*/0, |
||
| 13746 | /*AcceptsExprPack=*/0, |
||
| 13747 | /*IsTargetSpecific=*/0, |
||
| 13748 | /*IsType=*/0, |
||
| 13749 | /*IsStmt=*/0, |
||
| 13750 | /*IsKnownToGCC=*/0, |
||
| 13751 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 13752 | /*Spellings=*/SpeculativeLoadHardeningSpellings, |
||
| 13753 | /*ArgNames=*/{}) {} |
||
| 13754 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 13755 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
||
| 13756 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 13757 | << Attr << "functions and Objective-C methods"; |
||
| 13758 | return false; |
||
| 13759 | } |
||
| 13760 | return true; |
||
| 13761 | } |
||
| 13762 | |||
| 13763 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 13764 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 13765 | << AL << St->getBeginLoc(); |
||
| 13766 | return false; |
||
| 13767 | } |
||
| 13768 | |||
| 13769 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 13770 | |||
| 13771 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 13772 | if (const auto *A = D->getAttr<NoSpeculativeLoadHardeningAttr>()) { |
||
| 13773 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 13774 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 13775 | return false; |
||
| 13776 | } |
||
| 13777 | return true; |
||
| 13778 | } |
||
| 13779 | |||
| 13780 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 13781 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 13782 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 13783 | } |
||
| 13784 | |||
| 13785 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 13786 | D->addAttr(::new (S.Context) SpeculativeLoadHardeningAttr(S.Context, Attr)); |
||
| 13787 | return AttributeApplied; |
||
| 13788 | } |
||
| 13789 | |||
| 13790 | bool isParamExpr(size_t N) const override { |
||
| 13791 | return false; |
||
| 13792 | } |
||
| 13793 | |||
| 13794 | static const ParsedAttrInfoSpeculativeLoadHardening Instance; |
||
| 13795 | }; |
||
| 13796 | const ParsedAttrInfoSpeculativeLoadHardening ParsedAttrInfoSpeculativeLoadHardening::Instance; |
||
| 13797 | static constexpr ParsedAttrInfo::Spelling StandaloneDebugSpellings[] = { |
||
| 13798 | {AttributeCommonInfo::AS_GNU, "standalone_debug"}, |
||
| 13799 | {AttributeCommonInfo::AS_CXX11, "clang::standalone_debug"}, |
||
| 13800 | }; |
||
| 13801 | struct ParsedAttrInfoStandaloneDebug final : public ParsedAttrInfo { |
||
| 13802 | constexpr ParsedAttrInfoStandaloneDebug() : ParsedAttrInfo( |
||
| 13803 | /*AttrKind=*/ParsedAttr::AT_StandaloneDebug, |
||
| 13804 | /*NumArgs=*/0, |
||
| 13805 | /*OptArgs=*/0, |
||
| 13806 | /*NumArgMembers=*/0, |
||
| 13807 | /*HasCustomParsing=*/0, |
||
| 13808 | /*AcceptsExprPack=*/0, |
||
| 13809 | /*IsTargetSpecific=*/0, |
||
| 13810 | /*IsType=*/0, |
||
| 13811 | /*IsStmt=*/0, |
||
| 13812 | /*IsKnownToGCC=*/0, |
||
| 13813 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 13814 | /*Spellings=*/StandaloneDebugSpellings, |
||
| 13815 | /*ArgNames=*/{}) {} |
||
| 13816 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 13817 | if (!isa<CXXRecordDecl>(D)) { |
||
| 13818 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 13819 | << Attr << "classes"; |
||
| 13820 | return false; |
||
| 13821 | } |
||
| 13822 | return true; |
||
| 13823 | } |
||
| 13824 | |||
| 13825 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 13826 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 13827 | << AL << St->getBeginLoc(); |
||
| 13828 | return false; |
||
| 13829 | } |
||
| 13830 | |||
| 13831 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 13832 | return LangOpts.CPlusPlus; |
||
| 13833 | } |
||
| 13834 | |||
| 13835 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 13836 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 13837 | } |
||
| 13838 | |||
| 13839 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 13840 | D->addAttr(::new (S.Context) StandaloneDebugAttr(S.Context, Attr)); |
||
| 13841 | return AttributeApplied; |
||
| 13842 | } |
||
| 13843 | |||
| 13844 | bool isParamExpr(size_t N) const override { |
||
| 13845 | return false; |
||
| 13846 | } |
||
| 13847 | |||
| 13848 | static const ParsedAttrInfoStandaloneDebug Instance; |
||
| 13849 | }; |
||
| 13850 | const ParsedAttrInfoStandaloneDebug ParsedAttrInfoStandaloneDebug::Instance; |
||
| 13851 | static constexpr ParsedAttrInfo::Spelling StdCallSpellings[] = { |
||
| 13852 | {AttributeCommonInfo::AS_GNU, "stdcall"}, |
||
| 13853 | {AttributeCommonInfo::AS_CXX11, "gnu::stdcall"}, |
||
| 13854 | {AttributeCommonInfo::AS_C2x, "gnu::stdcall"}, |
||
| 13855 | {AttributeCommonInfo::AS_Keyword, "__stdcall"}, |
||
| 13856 | {AttributeCommonInfo::AS_Keyword, "_stdcall"}, |
||
| 13857 | }; |
||
| 13858 | struct ParsedAttrInfoStdCall final : public ParsedAttrInfo { |
||
| 13859 | constexpr ParsedAttrInfoStdCall() : ParsedAttrInfo( |
||
| 13860 | /*AttrKind=*/ParsedAttr::AT_StdCall, |
||
| 13861 | /*NumArgs=*/0, |
||
| 13862 | /*OptArgs=*/0, |
||
| 13863 | /*NumArgMembers=*/0, |
||
| 13864 | /*HasCustomParsing=*/0, |
||
| 13865 | /*AcceptsExprPack=*/0, |
||
| 13866 | /*IsTargetSpecific=*/0, |
||
| 13867 | /*IsType=*/1, |
||
| 13868 | /*IsStmt=*/0, |
||
| 13869 | /*IsKnownToGCC=*/1, |
||
| 13870 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 13871 | /*Spellings=*/StdCallSpellings, |
||
| 13872 | /*ArgNames=*/{}) {} |
||
| 13873 | bool isParamExpr(size_t N) const override { |
||
| 13874 | return false; |
||
| 13875 | } |
||
| 13876 | |||
| 13877 | static const ParsedAttrInfoStdCall Instance; |
||
| 13878 | }; |
||
| 13879 | const ParsedAttrInfoStdCall ParsedAttrInfoStdCall::Instance; |
||
| 13880 | struct ParsedAttrInfoStrictFP final : public ParsedAttrInfo { |
||
| 13881 | constexpr ParsedAttrInfoStrictFP() : ParsedAttrInfo( |
||
| 13882 | /*AttrKind=*/ParsedAttr::AT_StrictFP, |
||
| 13883 | /*NumArgs=*/0, |
||
| 13884 | /*OptArgs=*/0, |
||
| 13885 | /*NumArgMembers=*/0, |
||
| 13886 | /*HasCustomParsing=*/0, |
||
| 13887 | /*AcceptsExprPack=*/0, |
||
| 13888 | /*IsTargetSpecific=*/0, |
||
| 13889 | /*IsType=*/0, |
||
| 13890 | /*IsStmt=*/0, |
||
| 13891 | /*IsKnownToGCC=*/0, |
||
| 13892 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 13893 | /*Spellings=*/{}, |
||
| 13894 | /*ArgNames=*/{}) {} |
||
| 13895 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 13896 | if (!isa<FunctionDecl>(D)) { |
||
| 13897 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 13898 | << Attr << "functions"; |
||
| 13899 | return false; |
||
| 13900 | } |
||
| 13901 | return true; |
||
| 13902 | } |
||
| 13903 | |||
| 13904 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 13905 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 13906 | << AL << St->getBeginLoc(); |
||
| 13907 | return false; |
||
| 13908 | } |
||
| 13909 | |||
| 13910 | bool isParamExpr(size_t N) const override { |
||
| 13911 | return false; |
||
| 13912 | } |
||
| 13913 | |||
| 13914 | static const ParsedAttrInfoStrictFP Instance; |
||
| 13915 | }; |
||
| 13916 | const ParsedAttrInfoStrictFP ParsedAttrInfoStrictFP::Instance; |
||
| 13917 | static constexpr ParsedAttrInfo::Spelling StrictGuardStackCheckSpellings[] = { |
||
| 13918 | {AttributeCommonInfo::AS_Declspec, "strict_gs_check"}, |
||
| 13919 | }; |
||
| 13920 | struct ParsedAttrInfoStrictGuardStackCheck final : public ParsedAttrInfo { |
||
| 13921 | constexpr ParsedAttrInfoStrictGuardStackCheck() : ParsedAttrInfo( |
||
| 13922 | /*AttrKind=*/ParsedAttr::AT_StrictGuardStackCheck, |
||
| 13923 | /*NumArgs=*/0, |
||
| 13924 | /*OptArgs=*/0, |
||
| 13925 | /*NumArgMembers=*/0, |
||
| 13926 | /*HasCustomParsing=*/0, |
||
| 13927 | /*AcceptsExprPack=*/0, |
||
| 13928 | /*IsTargetSpecific=*/0, |
||
| 13929 | /*IsType=*/0, |
||
| 13930 | /*IsStmt=*/0, |
||
| 13931 | /*IsKnownToGCC=*/0, |
||
| 13932 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 13933 | /*Spellings=*/StrictGuardStackCheckSpellings, |
||
| 13934 | /*ArgNames=*/{}) {} |
||
| 13935 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 13936 | if (!isa<FunctionDecl>(D)) { |
||
| 13937 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 13938 | << Attr << "functions"; |
||
| 13939 | return false; |
||
| 13940 | } |
||
| 13941 | return true; |
||
| 13942 | } |
||
| 13943 | |||
| 13944 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 13945 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 13946 | << AL << St->getBeginLoc(); |
||
| 13947 | return false; |
||
| 13948 | } |
||
| 13949 | |||
| 13950 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 13951 | D->addAttr(::new (S.Context) StrictGuardStackCheckAttr(S.Context, Attr)); |
||
| 13952 | return AttributeApplied; |
||
| 13953 | } |
||
| 13954 | |||
| 13955 | bool isParamExpr(size_t N) const override { |
||
| 13956 | return false; |
||
| 13957 | } |
||
| 13958 | |||
| 13959 | static const ParsedAttrInfoStrictGuardStackCheck Instance; |
||
| 13960 | }; |
||
| 13961 | const ParsedAttrInfoStrictGuardStackCheck ParsedAttrInfoStrictGuardStackCheck::Instance; |
||
| 13962 | static constexpr ParsedAttrInfo::Spelling SuppressSpellings[] = { |
||
| 13963 | {AttributeCommonInfo::AS_CXX11, "gsl::suppress"}, |
||
| 13964 | }; |
||
| 13965 | static constexpr const char *SuppressArgNames[] = { |
||
| 13966 | "DiagnosticIdentifiers...",}; |
||
| 13967 | struct ParsedAttrInfoSuppress final : public ParsedAttrInfo { |
||
| 13968 | constexpr ParsedAttrInfoSuppress() : ParsedAttrInfo( |
||
| 13969 | /*AttrKind=*/ParsedAttr::AT_Suppress, |
||
| 13970 | /*NumArgs=*/0, |
||
| 13971 | /*OptArgs=*/15, |
||
| 13972 | /*NumArgMembers=*/1, |
||
| 13973 | /*HasCustomParsing=*/0, |
||
| 13974 | /*AcceptsExprPack=*/0, |
||
| 13975 | /*IsTargetSpecific=*/0, |
||
| 13976 | /*IsType=*/0, |
||
| 13977 | /*IsStmt=*/1, |
||
| 13978 | /*IsKnownToGCC=*/0, |
||
| 13979 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 13980 | /*Spellings=*/SuppressSpellings, |
||
| 13981 | /*ArgNames=*/SuppressArgNames) {} |
||
| 13982 | bool isParamExpr(size_t N) const override { |
||
| 13983 | return false; |
||
| 13984 | } |
||
| 13985 | |||
| 13986 | static const ParsedAttrInfoSuppress Instance; |
||
| 13987 | }; |
||
| 13988 | const ParsedAttrInfoSuppress ParsedAttrInfoSuppress::Instance; |
||
| 13989 | static constexpr ParsedAttrInfo::Spelling SwiftAsyncSpellings[] = { |
||
| 13990 | {AttributeCommonInfo::AS_GNU, "swift_async"}, |
||
| 13991 | {AttributeCommonInfo::AS_CXX11, "clang::swift_async"}, |
||
| 13992 | {AttributeCommonInfo::AS_C2x, "clang::swift_async"}, |
||
| 13993 | }; |
||
| 13994 | static constexpr const char *SwiftAsyncArgNames[] = { |
||
| 13995 | "Kind","CompletionHandlerIndex",}; |
||
| 13996 | struct ParsedAttrInfoSwiftAsync final : public ParsedAttrInfo { |
||
| 13997 | constexpr ParsedAttrInfoSwiftAsync() : ParsedAttrInfo( |
||
| 13998 | /*AttrKind=*/ParsedAttr::AT_SwiftAsync, |
||
| 13999 | /*NumArgs=*/1, |
||
| 14000 | /*OptArgs=*/1, |
||
| 14001 | /*NumArgMembers=*/2, |
||
| 14002 | /*HasCustomParsing=*/0, |
||
| 14003 | /*AcceptsExprPack=*/0, |
||
| 14004 | /*IsTargetSpecific=*/0, |
||
| 14005 | /*IsType=*/0, |
||
| 14006 | /*IsStmt=*/0, |
||
| 14007 | /*IsKnownToGCC=*/0, |
||
| 14008 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 14009 | /*Spellings=*/SwiftAsyncSpellings, |
||
| 14010 | /*ArgNames=*/SwiftAsyncArgNames) {} |
||
| 14011 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 14012 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
||
| 14013 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 14014 | << Attr << "functions and Objective-C methods"; |
||
| 14015 | return false; |
||
| 14016 | } |
||
| 14017 | return true; |
||
| 14018 | } |
||
| 14019 | |||
| 14020 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 14021 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 14022 | << AL << St->getBeginLoc(); |
||
| 14023 | return false; |
||
| 14024 | } |
||
| 14025 | |||
| 14026 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 14027 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 14028 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 14029 | } |
||
| 14030 | |||
| 14031 | bool isParamExpr(size_t N) const override { |
||
| 14032 | return false; |
||
| 14033 | } |
||
| 14034 | |||
| 14035 | static const ParsedAttrInfoSwiftAsync Instance; |
||
| 14036 | }; |
||
| 14037 | const ParsedAttrInfoSwiftAsync ParsedAttrInfoSwiftAsync::Instance; |
||
| 14038 | static constexpr ParsedAttrInfo::Spelling SwiftAsyncCallSpellings[] = { |
||
| 14039 | {AttributeCommonInfo::AS_GNU, "swiftasynccall"}, |
||
| 14040 | {AttributeCommonInfo::AS_CXX11, "clang::swiftasynccall"}, |
||
| 14041 | {AttributeCommonInfo::AS_C2x, "clang::swiftasynccall"}, |
||
| 14042 | }; |
||
| 14043 | struct ParsedAttrInfoSwiftAsyncCall final : public ParsedAttrInfo { |
||
| 14044 | constexpr ParsedAttrInfoSwiftAsyncCall() : ParsedAttrInfo( |
||
| 14045 | /*AttrKind=*/ParsedAttr::AT_SwiftAsyncCall, |
||
| 14046 | /*NumArgs=*/0, |
||
| 14047 | /*OptArgs=*/0, |
||
| 14048 | /*NumArgMembers=*/0, |
||
| 14049 | /*HasCustomParsing=*/0, |
||
| 14050 | /*AcceptsExprPack=*/0, |
||
| 14051 | /*IsTargetSpecific=*/0, |
||
| 14052 | /*IsType=*/1, |
||
| 14053 | /*IsStmt=*/0, |
||
| 14054 | /*IsKnownToGCC=*/0, |
||
| 14055 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 14056 | /*Spellings=*/SwiftAsyncCallSpellings, |
||
| 14057 | /*ArgNames=*/{}) {} |
||
| 14058 | bool isParamExpr(size_t N) const override { |
||
| 14059 | return false; |
||
| 14060 | } |
||
| 14061 | |||
| 14062 | static const ParsedAttrInfoSwiftAsyncCall Instance; |
||
| 14063 | }; |
||
| 14064 | const ParsedAttrInfoSwiftAsyncCall ParsedAttrInfoSwiftAsyncCall::Instance; |
||
| 14065 | static constexpr ParsedAttrInfo::Spelling SwiftAsyncContextSpellings[] = { |
||
| 14066 | {AttributeCommonInfo::AS_GNU, "swift_async_context"}, |
||
| 14067 | {AttributeCommonInfo::AS_CXX11, "clang::swift_async_context"}, |
||
| 14068 | {AttributeCommonInfo::AS_C2x, "clang::swift_async_context"}, |
||
| 14069 | }; |
||
| 14070 | struct ParsedAttrInfoSwiftAsyncContext final : public ParsedAttrInfo { |
||
| 14071 | constexpr ParsedAttrInfoSwiftAsyncContext() : ParsedAttrInfo( |
||
| 14072 | /*AttrKind=*/ParsedAttr::AT_SwiftAsyncContext, |
||
| 14073 | /*NumArgs=*/0, |
||
| 14074 | /*OptArgs=*/0, |
||
| 14075 | /*NumArgMembers=*/0, |
||
| 14076 | /*HasCustomParsing=*/0, |
||
| 14077 | /*AcceptsExprPack=*/0, |
||
| 14078 | /*IsTargetSpecific=*/0, |
||
| 14079 | /*IsType=*/0, |
||
| 14080 | /*IsStmt=*/0, |
||
| 14081 | /*IsKnownToGCC=*/0, |
||
| 14082 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 14083 | /*Spellings=*/SwiftAsyncContextSpellings, |
||
| 14084 | /*ArgNames=*/{}) {} |
||
| 14085 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 14086 | if (!isa<ParmVarDecl>(D)) { |
||
| 14087 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 14088 | << Attr << "parameters"; |
||
| 14089 | return false; |
||
| 14090 | } |
||
| 14091 | return true; |
||
| 14092 | } |
||
| 14093 | |||
| 14094 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 14095 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 14096 | << AL << St->getBeginLoc(); |
||
| 14097 | return false; |
||
| 14098 | } |
||
| 14099 | |||
| 14100 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 14101 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
||
| 14102 | } |
||
| 14103 | |||
| 14104 | bool isParamExpr(size_t N) const override { |
||
| 14105 | return false; |
||
| 14106 | } |
||
| 14107 | |||
| 14108 | static const ParsedAttrInfoSwiftAsyncContext Instance; |
||
| 14109 | }; |
||
| 14110 | const ParsedAttrInfoSwiftAsyncContext ParsedAttrInfoSwiftAsyncContext::Instance; |
||
| 14111 | static constexpr ParsedAttrInfo::Spelling SwiftAsyncErrorSpellings[] = { |
||
| 14112 | {AttributeCommonInfo::AS_GNU, "swift_async_error"}, |
||
| 14113 | {AttributeCommonInfo::AS_CXX11, "clang::swift_async_error"}, |
||
| 14114 | {AttributeCommonInfo::AS_C2x, "clang::swift_async_error"}, |
||
| 14115 | }; |
||
| 14116 | static constexpr const char *SwiftAsyncErrorArgNames[] = { |
||
| 14117 | "Convention","HandlerParamIdx",}; |
||
| 14118 | struct ParsedAttrInfoSwiftAsyncError final : public ParsedAttrInfo { |
||
| 14119 | constexpr ParsedAttrInfoSwiftAsyncError() : ParsedAttrInfo( |
||
| 14120 | /*AttrKind=*/ParsedAttr::AT_SwiftAsyncError, |
||
| 14121 | /*NumArgs=*/1, |
||
| 14122 | /*OptArgs=*/1, |
||
| 14123 | /*NumArgMembers=*/2, |
||
| 14124 | /*HasCustomParsing=*/0, |
||
| 14125 | /*AcceptsExprPack=*/0, |
||
| 14126 | /*IsTargetSpecific=*/0, |
||
| 14127 | /*IsType=*/0, |
||
| 14128 | /*IsStmt=*/0, |
||
| 14129 | /*IsKnownToGCC=*/0, |
||
| 14130 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 14131 | /*Spellings=*/SwiftAsyncErrorSpellings, |
||
| 14132 | /*ArgNames=*/SwiftAsyncErrorArgNames) {} |
||
| 14133 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 14134 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
||
| 14135 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 14136 | << Attr << "functions and Objective-C methods"; |
||
| 14137 | return false; |
||
| 14138 | } |
||
| 14139 | return true; |
||
| 14140 | } |
||
| 14141 | |||
| 14142 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 14143 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 14144 | << AL << St->getBeginLoc(); |
||
| 14145 | return false; |
||
| 14146 | } |
||
| 14147 | |||
| 14148 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 14149 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 14150 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 14151 | } |
||
| 14152 | |||
| 14153 | bool isParamExpr(size_t N) const override { |
||
| 14154 | return false; |
||
| 14155 | } |
||
| 14156 | |||
| 14157 | static const ParsedAttrInfoSwiftAsyncError Instance; |
||
| 14158 | }; |
||
| 14159 | const ParsedAttrInfoSwiftAsyncError ParsedAttrInfoSwiftAsyncError::Instance; |
||
| 14160 | static constexpr ParsedAttrInfo::Spelling SwiftAsyncNameSpellings[] = { |
||
| 14161 | {AttributeCommonInfo::AS_GNU, "swift_async_name"}, |
||
| 14162 | }; |
||
| 14163 | static constexpr const char *SwiftAsyncNameArgNames[] = { |
||
| 14164 | "Name",}; |
||
| 14165 | struct ParsedAttrInfoSwiftAsyncName final : public ParsedAttrInfo { |
||
| 14166 | constexpr ParsedAttrInfoSwiftAsyncName() : ParsedAttrInfo( |
||
| 14167 | /*AttrKind=*/ParsedAttr::AT_SwiftAsyncName, |
||
| 14168 | /*NumArgs=*/1, |
||
| 14169 | /*OptArgs=*/0, |
||
| 14170 | /*NumArgMembers=*/1, |
||
| 14171 | /*HasCustomParsing=*/0, |
||
| 14172 | /*AcceptsExprPack=*/0, |
||
| 14173 | /*IsTargetSpecific=*/0, |
||
| 14174 | /*IsType=*/0, |
||
| 14175 | /*IsStmt=*/0, |
||
| 14176 | /*IsKnownToGCC=*/0, |
||
| 14177 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 14178 | /*Spellings=*/SwiftAsyncNameSpellings, |
||
| 14179 | /*ArgNames=*/SwiftAsyncNameArgNames) {} |
||
| 14180 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 14181 | if (!isa<ObjCMethodDecl>(D) && !isa<FunctionDecl>(D)) { |
||
| 14182 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 14183 | << Attr << "Objective-C methods and functions"; |
||
| 14184 | return false; |
||
| 14185 | } |
||
| 14186 | return true; |
||
| 14187 | } |
||
| 14188 | |||
| 14189 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 14190 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 14191 | << AL << St->getBeginLoc(); |
||
| 14192 | return false; |
||
| 14193 | } |
||
| 14194 | |||
| 14195 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 14196 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 14197 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 14198 | } |
||
| 14199 | |||
| 14200 | bool isParamExpr(size_t N) const override { |
||
| 14201 | return false; |
||
| 14202 | } |
||
| 14203 | |||
| 14204 | static const ParsedAttrInfoSwiftAsyncName Instance; |
||
| 14205 | }; |
||
| 14206 | const ParsedAttrInfoSwiftAsyncName ParsedAttrInfoSwiftAsyncName::Instance; |
||
| 14207 | static constexpr ParsedAttrInfo::Spelling SwiftAttrSpellings[] = { |
||
| 14208 | {AttributeCommonInfo::AS_GNU, "swift_attr"}, |
||
| 14209 | }; |
||
| 14210 | static constexpr const char *SwiftAttrArgNames[] = { |
||
| 14211 | "Attribute",}; |
||
| 14212 | struct ParsedAttrInfoSwiftAttr final : public ParsedAttrInfo { |
||
| 14213 | constexpr ParsedAttrInfoSwiftAttr() : ParsedAttrInfo( |
||
| 14214 | /*AttrKind=*/ParsedAttr::AT_SwiftAttr, |
||
| 14215 | /*NumArgs=*/1, |
||
| 14216 | /*OptArgs=*/0, |
||
| 14217 | /*NumArgMembers=*/1, |
||
| 14218 | /*HasCustomParsing=*/0, |
||
| 14219 | /*AcceptsExprPack=*/0, |
||
| 14220 | /*IsTargetSpecific=*/0, |
||
| 14221 | /*IsType=*/0, |
||
| 14222 | /*IsStmt=*/0, |
||
| 14223 | /*IsKnownToGCC=*/0, |
||
| 14224 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 14225 | /*Spellings=*/SwiftAttrSpellings, |
||
| 14226 | /*ArgNames=*/SwiftAttrArgNames) {} |
||
| 14227 | bool isParamExpr(size_t N) const override { |
||
| 14228 | return false; |
||
| 14229 | } |
||
| 14230 | |||
| 14231 | static const ParsedAttrInfoSwiftAttr Instance; |
||
| 14232 | }; |
||
| 14233 | const ParsedAttrInfoSwiftAttr ParsedAttrInfoSwiftAttr::Instance; |
||
| 14234 | static constexpr ParsedAttrInfo::Spelling SwiftBridgeSpellings[] = { |
||
| 14235 | {AttributeCommonInfo::AS_GNU, "swift_bridge"}, |
||
| 14236 | }; |
||
| 14237 | static constexpr const char *SwiftBridgeArgNames[] = { |
||
| 14238 | "SwiftType",}; |
||
| 14239 | struct ParsedAttrInfoSwiftBridge final : public ParsedAttrInfo { |
||
| 14240 | constexpr ParsedAttrInfoSwiftBridge() : ParsedAttrInfo( |
||
| 14241 | /*AttrKind=*/ParsedAttr::AT_SwiftBridge, |
||
| 14242 | /*NumArgs=*/1, |
||
| 14243 | /*OptArgs=*/0, |
||
| 14244 | /*NumArgMembers=*/1, |
||
| 14245 | /*HasCustomParsing=*/0, |
||
| 14246 | /*AcceptsExprPack=*/0, |
||
| 14247 | /*IsTargetSpecific=*/0, |
||
| 14248 | /*IsType=*/0, |
||
| 14249 | /*IsStmt=*/0, |
||
| 14250 | /*IsKnownToGCC=*/0, |
||
| 14251 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 14252 | /*Spellings=*/SwiftBridgeSpellings, |
||
| 14253 | /*ArgNames=*/SwiftBridgeArgNames) {} |
||
| 14254 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 14255 | if (!isa<TagDecl>(D) && !isa<TypedefNameDecl>(D) && !isa<ObjCInterfaceDecl>(D) && !isa<ObjCProtocolDecl>(D)) { |
||
| 14256 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 14257 | << Attr << "tag types, typedefs, Objective-C interfaces, and Objective-C protocols"; |
||
| 14258 | return false; |
||
| 14259 | } |
||
| 14260 | return true; |
||
| 14261 | } |
||
| 14262 | |||
| 14263 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 14264 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 14265 | << AL << St->getBeginLoc(); |
||
| 14266 | return false; |
||
| 14267 | } |
||
| 14268 | |||
| 14269 | bool isParamExpr(size_t N) const override { |
||
| 14270 | return false; |
||
| 14271 | } |
||
| 14272 | |||
| 14273 | static const ParsedAttrInfoSwiftBridge Instance; |
||
| 14274 | }; |
||
| 14275 | const ParsedAttrInfoSwiftBridge ParsedAttrInfoSwiftBridge::Instance; |
||
| 14276 | static constexpr ParsedAttrInfo::Spelling SwiftBridgedTypedefSpellings[] = { |
||
| 14277 | {AttributeCommonInfo::AS_GNU, "swift_bridged_typedef"}, |
||
| 14278 | }; |
||
| 14279 | struct ParsedAttrInfoSwiftBridgedTypedef final : public ParsedAttrInfo { |
||
| 14280 | constexpr ParsedAttrInfoSwiftBridgedTypedef() : ParsedAttrInfo( |
||
| 14281 | /*AttrKind=*/ParsedAttr::AT_SwiftBridgedTypedef, |
||
| 14282 | /*NumArgs=*/0, |
||
| 14283 | /*OptArgs=*/0, |
||
| 14284 | /*NumArgMembers=*/0, |
||
| 14285 | /*HasCustomParsing=*/0, |
||
| 14286 | /*AcceptsExprPack=*/0, |
||
| 14287 | /*IsTargetSpecific=*/0, |
||
| 14288 | /*IsType=*/0, |
||
| 14289 | /*IsStmt=*/0, |
||
| 14290 | /*IsKnownToGCC=*/0, |
||
| 14291 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 14292 | /*Spellings=*/SwiftBridgedTypedefSpellings, |
||
| 14293 | /*ArgNames=*/{}) {} |
||
| 14294 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 14295 | if (!isa<TypedefNameDecl>(D)) { |
||
| 14296 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 14297 | << Attr << "typedefs"; |
||
| 14298 | return false; |
||
| 14299 | } |
||
| 14300 | return true; |
||
| 14301 | } |
||
| 14302 | |||
| 14303 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 14304 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 14305 | << AL << St->getBeginLoc(); |
||
| 14306 | return false; |
||
| 14307 | } |
||
| 14308 | |||
| 14309 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 14310 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true)); |
||
| 14311 | } |
||
| 14312 | |||
| 14313 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 14314 | D->addAttr(::new (S.Context) SwiftBridgedTypedefAttr(S.Context, Attr)); |
||
| 14315 | return AttributeApplied; |
||
| 14316 | } |
||
| 14317 | |||
| 14318 | bool isParamExpr(size_t N) const override { |
||
| 14319 | return false; |
||
| 14320 | } |
||
| 14321 | |||
| 14322 | static const ParsedAttrInfoSwiftBridgedTypedef Instance; |
||
| 14323 | }; |
||
| 14324 | const ParsedAttrInfoSwiftBridgedTypedef ParsedAttrInfoSwiftBridgedTypedef::Instance; |
||
| 14325 | static constexpr ParsedAttrInfo::Spelling SwiftCallSpellings[] = { |
||
| 14326 | {AttributeCommonInfo::AS_GNU, "swiftcall"}, |
||
| 14327 | {AttributeCommonInfo::AS_CXX11, "clang::swiftcall"}, |
||
| 14328 | {AttributeCommonInfo::AS_C2x, "clang::swiftcall"}, |
||
| 14329 | }; |
||
| 14330 | struct ParsedAttrInfoSwiftCall final : public ParsedAttrInfo { |
||
| 14331 | constexpr ParsedAttrInfoSwiftCall() : ParsedAttrInfo( |
||
| 14332 | /*AttrKind=*/ParsedAttr::AT_SwiftCall, |
||
| 14333 | /*NumArgs=*/0, |
||
| 14334 | /*OptArgs=*/0, |
||
| 14335 | /*NumArgMembers=*/0, |
||
| 14336 | /*HasCustomParsing=*/0, |
||
| 14337 | /*AcceptsExprPack=*/0, |
||
| 14338 | /*IsTargetSpecific=*/0, |
||
| 14339 | /*IsType=*/1, |
||
| 14340 | /*IsStmt=*/0, |
||
| 14341 | /*IsKnownToGCC=*/0, |
||
| 14342 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 14343 | /*Spellings=*/SwiftCallSpellings, |
||
| 14344 | /*ArgNames=*/{}) {} |
||
| 14345 | bool isParamExpr(size_t N) const override { |
||
| 14346 | return false; |
||
| 14347 | } |
||
| 14348 | |||
| 14349 | static const ParsedAttrInfoSwiftCall Instance; |
||
| 14350 | }; |
||
| 14351 | const ParsedAttrInfoSwiftCall ParsedAttrInfoSwiftCall::Instance; |
||
| 14352 | static constexpr ParsedAttrInfo::Spelling SwiftContextSpellings[] = { |
||
| 14353 | {AttributeCommonInfo::AS_GNU, "swift_context"}, |
||
| 14354 | {AttributeCommonInfo::AS_CXX11, "clang::swift_context"}, |
||
| 14355 | {AttributeCommonInfo::AS_C2x, "clang::swift_context"}, |
||
| 14356 | }; |
||
| 14357 | struct ParsedAttrInfoSwiftContext final : public ParsedAttrInfo { |
||
| 14358 | constexpr ParsedAttrInfoSwiftContext() : ParsedAttrInfo( |
||
| 14359 | /*AttrKind=*/ParsedAttr::AT_SwiftContext, |
||
| 14360 | /*NumArgs=*/0, |
||
| 14361 | /*OptArgs=*/0, |
||
| 14362 | /*NumArgMembers=*/0, |
||
| 14363 | /*HasCustomParsing=*/0, |
||
| 14364 | /*AcceptsExprPack=*/0, |
||
| 14365 | /*IsTargetSpecific=*/0, |
||
| 14366 | /*IsType=*/0, |
||
| 14367 | /*IsStmt=*/0, |
||
| 14368 | /*IsKnownToGCC=*/0, |
||
| 14369 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 14370 | /*Spellings=*/SwiftContextSpellings, |
||
| 14371 | /*ArgNames=*/{}) {} |
||
| 14372 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 14373 | if (!isa<ParmVarDecl>(D)) { |
||
| 14374 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 14375 | << Attr << "parameters"; |
||
| 14376 | return false; |
||
| 14377 | } |
||
| 14378 | return true; |
||
| 14379 | } |
||
| 14380 | |||
| 14381 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 14382 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 14383 | << AL << St->getBeginLoc(); |
||
| 14384 | return false; |
||
| 14385 | } |
||
| 14386 | |||
| 14387 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 14388 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
||
| 14389 | } |
||
| 14390 | |||
| 14391 | bool isParamExpr(size_t N) const override { |
||
| 14392 | return false; |
||
| 14393 | } |
||
| 14394 | |||
| 14395 | static const ParsedAttrInfoSwiftContext Instance; |
||
| 14396 | }; |
||
| 14397 | const ParsedAttrInfoSwiftContext ParsedAttrInfoSwiftContext::Instance; |
||
| 14398 | static constexpr ParsedAttrInfo::Spelling SwiftErrorSpellings[] = { |
||
| 14399 | {AttributeCommonInfo::AS_GNU, "swift_error"}, |
||
| 14400 | }; |
||
| 14401 | static constexpr const char *SwiftErrorArgNames[] = { |
||
| 14402 | "Convention",}; |
||
| 14403 | struct ParsedAttrInfoSwiftError final : public ParsedAttrInfo { |
||
| 14404 | constexpr ParsedAttrInfoSwiftError() : ParsedAttrInfo( |
||
| 14405 | /*AttrKind=*/ParsedAttr::AT_SwiftError, |
||
| 14406 | /*NumArgs=*/1, |
||
| 14407 | /*OptArgs=*/0, |
||
| 14408 | /*NumArgMembers=*/1, |
||
| 14409 | /*HasCustomParsing=*/0, |
||
| 14410 | /*AcceptsExprPack=*/0, |
||
| 14411 | /*IsTargetSpecific=*/0, |
||
| 14412 | /*IsType=*/0, |
||
| 14413 | /*IsStmt=*/0, |
||
| 14414 | /*IsKnownToGCC=*/0, |
||
| 14415 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 14416 | /*Spellings=*/SwiftErrorSpellings, |
||
| 14417 | /*ArgNames=*/SwiftErrorArgNames) {} |
||
| 14418 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 14419 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
||
| 14420 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 14421 | << Attr << "functions and Objective-C methods"; |
||
| 14422 | return false; |
||
| 14423 | } |
||
| 14424 | return true; |
||
| 14425 | } |
||
| 14426 | |||
| 14427 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 14428 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 14429 | << AL << St->getBeginLoc(); |
||
| 14430 | return false; |
||
| 14431 | } |
||
| 14432 | |||
| 14433 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 14434 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 14435 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 14436 | } |
||
| 14437 | |||
| 14438 | bool isParamExpr(size_t N) const override { |
||
| 14439 | return false; |
||
| 14440 | } |
||
| 14441 | |||
| 14442 | static const ParsedAttrInfoSwiftError Instance; |
||
| 14443 | }; |
||
| 14444 | const ParsedAttrInfoSwiftError ParsedAttrInfoSwiftError::Instance; |
||
| 14445 | static constexpr ParsedAttrInfo::Spelling SwiftErrorResultSpellings[] = { |
||
| 14446 | {AttributeCommonInfo::AS_GNU, "swift_error_result"}, |
||
| 14447 | {AttributeCommonInfo::AS_CXX11, "clang::swift_error_result"}, |
||
| 14448 | {AttributeCommonInfo::AS_C2x, "clang::swift_error_result"}, |
||
| 14449 | }; |
||
| 14450 | struct ParsedAttrInfoSwiftErrorResult final : public ParsedAttrInfo { |
||
| 14451 | constexpr ParsedAttrInfoSwiftErrorResult() : ParsedAttrInfo( |
||
| 14452 | /*AttrKind=*/ParsedAttr::AT_SwiftErrorResult, |
||
| 14453 | /*NumArgs=*/0, |
||
| 14454 | /*OptArgs=*/0, |
||
| 14455 | /*NumArgMembers=*/0, |
||
| 14456 | /*HasCustomParsing=*/0, |
||
| 14457 | /*AcceptsExprPack=*/0, |
||
| 14458 | /*IsTargetSpecific=*/0, |
||
| 14459 | /*IsType=*/0, |
||
| 14460 | /*IsStmt=*/0, |
||
| 14461 | /*IsKnownToGCC=*/0, |
||
| 14462 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 14463 | /*Spellings=*/SwiftErrorResultSpellings, |
||
| 14464 | /*ArgNames=*/{}) {} |
||
| 14465 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 14466 | if (!isa<ParmVarDecl>(D)) { |
||
| 14467 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 14468 | << Attr << "parameters"; |
||
| 14469 | return false; |
||
| 14470 | } |
||
| 14471 | return true; |
||
| 14472 | } |
||
| 14473 | |||
| 14474 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 14475 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 14476 | << AL << St->getBeginLoc(); |
||
| 14477 | return false; |
||
| 14478 | } |
||
| 14479 | |||
| 14480 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 14481 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
||
| 14482 | } |
||
| 14483 | |||
| 14484 | bool isParamExpr(size_t N) const override { |
||
| 14485 | return false; |
||
| 14486 | } |
||
| 14487 | |||
| 14488 | static const ParsedAttrInfoSwiftErrorResult Instance; |
||
| 14489 | }; |
||
| 14490 | const ParsedAttrInfoSwiftErrorResult ParsedAttrInfoSwiftErrorResult::Instance; |
||
| 14491 | static constexpr ParsedAttrInfo::Spelling SwiftIndirectResultSpellings[] = { |
||
| 14492 | {AttributeCommonInfo::AS_GNU, "swift_indirect_result"}, |
||
| 14493 | {AttributeCommonInfo::AS_CXX11, "clang::swift_indirect_result"}, |
||
| 14494 | {AttributeCommonInfo::AS_C2x, "clang::swift_indirect_result"}, |
||
| 14495 | }; |
||
| 14496 | struct ParsedAttrInfoSwiftIndirectResult final : public ParsedAttrInfo { |
||
| 14497 | constexpr ParsedAttrInfoSwiftIndirectResult() : ParsedAttrInfo( |
||
| 14498 | /*AttrKind=*/ParsedAttr::AT_SwiftIndirectResult, |
||
| 14499 | /*NumArgs=*/0, |
||
| 14500 | /*OptArgs=*/0, |
||
| 14501 | /*NumArgMembers=*/0, |
||
| 14502 | /*HasCustomParsing=*/0, |
||
| 14503 | /*AcceptsExprPack=*/0, |
||
| 14504 | /*IsTargetSpecific=*/0, |
||
| 14505 | /*IsType=*/0, |
||
| 14506 | /*IsStmt=*/0, |
||
| 14507 | /*IsKnownToGCC=*/0, |
||
| 14508 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 14509 | /*Spellings=*/SwiftIndirectResultSpellings, |
||
| 14510 | /*ArgNames=*/{}) {} |
||
| 14511 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 14512 | if (!isa<ParmVarDecl>(D)) { |
||
| 14513 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 14514 | << Attr << "parameters"; |
||
| 14515 | return false; |
||
| 14516 | } |
||
| 14517 | return true; |
||
| 14518 | } |
||
| 14519 | |||
| 14520 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 14521 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 14522 | << AL << St->getBeginLoc(); |
||
| 14523 | return false; |
||
| 14524 | } |
||
| 14525 | |||
| 14526 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 14527 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
||
| 14528 | } |
||
| 14529 | |||
| 14530 | bool isParamExpr(size_t N) const override { |
||
| 14531 | return false; |
||
| 14532 | } |
||
| 14533 | |||
| 14534 | static const ParsedAttrInfoSwiftIndirectResult Instance; |
||
| 14535 | }; |
||
| 14536 | const ParsedAttrInfoSwiftIndirectResult ParsedAttrInfoSwiftIndirectResult::Instance; |
||
| 14537 | static constexpr ParsedAttrInfo::Spelling SwiftNameSpellings[] = { |
||
| 14538 | {AttributeCommonInfo::AS_GNU, "swift_name"}, |
||
| 14539 | }; |
||
| 14540 | static constexpr const char *SwiftNameArgNames[] = { |
||
| 14541 | "Name",}; |
||
| 14542 | struct ParsedAttrInfoSwiftName final : public ParsedAttrInfo { |
||
| 14543 | constexpr ParsedAttrInfoSwiftName() : ParsedAttrInfo( |
||
| 14544 | /*AttrKind=*/ParsedAttr::AT_SwiftName, |
||
| 14545 | /*NumArgs=*/1, |
||
| 14546 | /*OptArgs=*/0, |
||
| 14547 | /*NumArgMembers=*/1, |
||
| 14548 | /*HasCustomParsing=*/0, |
||
| 14549 | /*AcceptsExprPack=*/0, |
||
| 14550 | /*IsTargetSpecific=*/0, |
||
| 14551 | /*IsType=*/0, |
||
| 14552 | /*IsStmt=*/0, |
||
| 14553 | /*IsKnownToGCC=*/0, |
||
| 14554 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 14555 | /*Spellings=*/SwiftNameSpellings, |
||
| 14556 | /*ArgNames=*/SwiftNameArgNames) {} |
||
| 14557 | bool isParamExpr(size_t N) const override { |
||
| 14558 | return false; |
||
| 14559 | } |
||
| 14560 | |||
| 14561 | static const ParsedAttrInfoSwiftName Instance; |
||
| 14562 | }; |
||
| 14563 | const ParsedAttrInfoSwiftName ParsedAttrInfoSwiftName::Instance; |
||
| 14564 | static constexpr ParsedAttrInfo::Spelling SwiftNewTypeSpellings[] = { |
||
| 14565 | {AttributeCommonInfo::AS_GNU, "swift_newtype"}, |
||
| 14566 | {AttributeCommonInfo::AS_GNU, "swift_wrapper"}, |
||
| 14567 | }; |
||
| 14568 | static constexpr const char *SwiftNewTypeArgNames[] = { |
||
| 14569 | "NewtypeKind",}; |
||
| 14570 | struct ParsedAttrInfoSwiftNewType final : public ParsedAttrInfo { |
||
| 14571 | constexpr ParsedAttrInfoSwiftNewType() : ParsedAttrInfo( |
||
| 14572 | /*AttrKind=*/ParsedAttr::AT_SwiftNewType, |
||
| 14573 | /*NumArgs=*/1, |
||
| 14574 | /*OptArgs=*/0, |
||
| 14575 | /*NumArgMembers=*/1, |
||
| 14576 | /*HasCustomParsing=*/1, |
||
| 14577 | /*AcceptsExprPack=*/0, |
||
| 14578 | /*IsTargetSpecific=*/0, |
||
| 14579 | /*IsType=*/0, |
||
| 14580 | /*IsStmt=*/0, |
||
| 14581 | /*IsKnownToGCC=*/0, |
||
| 14582 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 14583 | /*Spellings=*/SwiftNewTypeSpellings, |
||
| 14584 | /*ArgNames=*/SwiftNewTypeArgNames) {} |
||
| 14585 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 14586 | if (!isa<TypedefNameDecl>(D)) { |
||
| 14587 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 14588 | << Attr << "typedefs"; |
||
| 14589 | return false; |
||
| 14590 | } |
||
| 14591 | return true; |
||
| 14592 | } |
||
| 14593 | |||
| 14594 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 14595 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 14596 | << AL << St->getBeginLoc(); |
||
| 14597 | return false; |
||
| 14598 | } |
||
| 14599 | |||
| 14600 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 14601 | enum Spelling { |
||
| 14602 | GNU_swift_newtype = 0, |
||
| 14603 | GNU_swift_wrapper = 1, |
||
| 14604 | SpellingNotCalculated = 15 |
||
| 14605 | |||
| 14606 | }; |
||
| 14607 | |||
| 14608 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 14609 | switch (Idx) { |
||
| 14610 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 14611 | case 0: return GNU_swift_newtype; |
||
| 14612 | case 1: return GNU_swift_wrapper; |
||
| 14613 | } |
||
| 14614 | } |
||
| 14615 | |||
| 14616 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 14617 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true)); |
||
| 14618 | } |
||
| 14619 | |||
| 14620 | bool isParamExpr(size_t N) const override { |
||
| 14621 | return false; |
||
| 14622 | } |
||
| 14623 | |||
| 14624 | static const ParsedAttrInfoSwiftNewType Instance; |
||
| 14625 | }; |
||
| 14626 | const ParsedAttrInfoSwiftNewType ParsedAttrInfoSwiftNewType::Instance; |
||
| 14627 | static constexpr ParsedAttrInfo::Spelling SwiftObjCMembersSpellings[] = { |
||
| 14628 | {AttributeCommonInfo::AS_GNU, "swift_objc_members"}, |
||
| 14629 | }; |
||
| 14630 | struct ParsedAttrInfoSwiftObjCMembers final : public ParsedAttrInfo { |
||
| 14631 | constexpr ParsedAttrInfoSwiftObjCMembers() : ParsedAttrInfo( |
||
| 14632 | /*AttrKind=*/ParsedAttr::AT_SwiftObjCMembers, |
||
| 14633 | /*NumArgs=*/0, |
||
| 14634 | /*OptArgs=*/0, |
||
| 14635 | /*NumArgMembers=*/0, |
||
| 14636 | /*HasCustomParsing=*/0, |
||
| 14637 | /*AcceptsExprPack=*/0, |
||
| 14638 | /*IsTargetSpecific=*/0, |
||
| 14639 | /*IsType=*/0, |
||
| 14640 | /*IsStmt=*/0, |
||
| 14641 | /*IsKnownToGCC=*/0, |
||
| 14642 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 14643 | /*Spellings=*/SwiftObjCMembersSpellings, |
||
| 14644 | /*ArgNames=*/{}) {} |
||
| 14645 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 14646 | if (!isa<ObjCInterfaceDecl>(D)) { |
||
| 14647 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 14648 | << Attr << "Objective-C interfaces"; |
||
| 14649 | return false; |
||
| 14650 | } |
||
| 14651 | return true; |
||
| 14652 | } |
||
| 14653 | |||
| 14654 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 14655 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 14656 | << AL << St->getBeginLoc(); |
||
| 14657 | return false; |
||
| 14658 | } |
||
| 14659 | |||
| 14660 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 14661 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_interface, /*IsSupported=*/LangOpts.ObjC)); |
||
| 14662 | } |
||
| 14663 | |||
| 14664 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 14665 | D->addAttr(::new (S.Context) SwiftObjCMembersAttr(S.Context, Attr)); |
||
| 14666 | return AttributeApplied; |
||
| 14667 | } |
||
| 14668 | |||
| 14669 | bool isParamExpr(size_t N) const override { |
||
| 14670 | return false; |
||
| 14671 | } |
||
| 14672 | |||
| 14673 | static const ParsedAttrInfoSwiftObjCMembers Instance; |
||
| 14674 | }; |
||
| 14675 | const ParsedAttrInfoSwiftObjCMembers ParsedAttrInfoSwiftObjCMembers::Instance; |
||
| 14676 | static constexpr ParsedAttrInfo::Spelling SwiftPrivateSpellings[] = { |
||
| 14677 | {AttributeCommonInfo::AS_GNU, "swift_private"}, |
||
| 14678 | }; |
||
| 14679 | struct ParsedAttrInfoSwiftPrivate final : public ParsedAttrInfo { |
||
| 14680 | constexpr ParsedAttrInfoSwiftPrivate() : ParsedAttrInfo( |
||
| 14681 | /*AttrKind=*/ParsedAttr::AT_SwiftPrivate, |
||
| 14682 | /*NumArgs=*/0, |
||
| 14683 | /*OptArgs=*/0, |
||
| 14684 | /*NumArgMembers=*/0, |
||
| 14685 | /*HasCustomParsing=*/0, |
||
| 14686 | /*AcceptsExprPack=*/0, |
||
| 14687 | /*IsTargetSpecific=*/0, |
||
| 14688 | /*IsType=*/0, |
||
| 14689 | /*IsStmt=*/0, |
||
| 14690 | /*IsKnownToGCC=*/0, |
||
| 14691 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 14692 | /*Spellings=*/SwiftPrivateSpellings, |
||
| 14693 | /*ArgNames=*/{}) {} |
||
| 14694 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 14695 | D->addAttr(::new (S.Context) SwiftPrivateAttr(S.Context, Attr)); |
||
| 14696 | return AttributeApplied; |
||
| 14697 | } |
||
| 14698 | |||
| 14699 | bool isParamExpr(size_t N) const override { |
||
| 14700 | return false; |
||
| 14701 | } |
||
| 14702 | |||
| 14703 | static const ParsedAttrInfoSwiftPrivate Instance; |
||
| 14704 | }; |
||
| 14705 | const ParsedAttrInfoSwiftPrivate ParsedAttrInfoSwiftPrivate::Instance; |
||
| 14706 | static constexpr ParsedAttrInfo::Spelling SysVABISpellings[] = { |
||
| 14707 | {AttributeCommonInfo::AS_GNU, "sysv_abi"}, |
||
| 14708 | {AttributeCommonInfo::AS_CXX11, "gnu::sysv_abi"}, |
||
| 14709 | {AttributeCommonInfo::AS_C2x, "gnu::sysv_abi"}, |
||
| 14710 | }; |
||
| 14711 | struct ParsedAttrInfoSysVABI final : public ParsedAttrInfo { |
||
| 14712 | constexpr ParsedAttrInfoSysVABI() : ParsedAttrInfo( |
||
| 14713 | /*AttrKind=*/ParsedAttr::AT_SysVABI, |
||
| 14714 | /*NumArgs=*/0, |
||
| 14715 | /*OptArgs=*/0, |
||
| 14716 | /*NumArgMembers=*/0, |
||
| 14717 | /*HasCustomParsing=*/0, |
||
| 14718 | /*AcceptsExprPack=*/0, |
||
| 14719 | /*IsTargetSpecific=*/0, |
||
| 14720 | /*IsType=*/1, |
||
| 14721 | /*IsStmt=*/0, |
||
| 14722 | /*IsKnownToGCC=*/1, |
||
| 14723 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 14724 | /*Spellings=*/SysVABISpellings, |
||
| 14725 | /*ArgNames=*/{}) {} |
||
| 14726 | bool isParamExpr(size_t N) const override { |
||
| 14727 | return false; |
||
| 14728 | } |
||
| 14729 | |||
| 14730 | static const ParsedAttrInfoSysVABI Instance; |
||
| 14731 | }; |
||
| 14732 | const ParsedAttrInfoSysVABI ParsedAttrInfoSysVABI::Instance; |
||
| 14733 | static constexpr ParsedAttrInfo::Spelling TLSModelSpellings[] = { |
||
| 14734 | {AttributeCommonInfo::AS_GNU, "tls_model"}, |
||
| 14735 | {AttributeCommonInfo::AS_CXX11, "gnu::tls_model"}, |
||
| 14736 | {AttributeCommonInfo::AS_C2x, "gnu::tls_model"}, |
||
| 14737 | }; |
||
| 14738 | static constexpr const char *TLSModelArgNames[] = { |
||
| 14739 | "Model",}; |
||
| 14740 | struct ParsedAttrInfoTLSModel final : public ParsedAttrInfo { |
||
| 14741 | constexpr ParsedAttrInfoTLSModel() : ParsedAttrInfo( |
||
| 14742 | /*AttrKind=*/ParsedAttr::AT_TLSModel, |
||
| 14743 | /*NumArgs=*/1, |
||
| 14744 | /*OptArgs=*/0, |
||
| 14745 | /*NumArgMembers=*/1, |
||
| 14746 | /*HasCustomParsing=*/0, |
||
| 14747 | /*AcceptsExprPack=*/0, |
||
| 14748 | /*IsTargetSpecific=*/0, |
||
| 14749 | /*IsType=*/0, |
||
| 14750 | /*IsStmt=*/0, |
||
| 14751 | /*IsKnownToGCC=*/1, |
||
| 14752 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 14753 | /*Spellings=*/TLSModelSpellings, |
||
| 14754 | /*ArgNames=*/TLSModelArgNames) {} |
||
| 14755 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 14756 | if (!isTLSVar(D)) { |
||
| 14757 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 14758 | << Attr << "thread-local variables"; |
||
| 14759 | return false; |
||
| 14760 | } |
||
| 14761 | return true; |
||
| 14762 | } |
||
| 14763 | |||
| 14764 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 14765 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 14766 | << AL << St->getBeginLoc(); |
||
| 14767 | return false; |
||
| 14768 | } |
||
| 14769 | |||
| 14770 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 14771 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_thread_local, /*IsSupported=*/true)); |
||
| 14772 | } |
||
| 14773 | |||
| 14774 | bool isParamExpr(size_t N) const override { |
||
| 14775 | return false; |
||
| 14776 | } |
||
| 14777 | |||
| 14778 | static const ParsedAttrInfoTLSModel Instance; |
||
| 14779 | }; |
||
| 14780 | const ParsedAttrInfoTLSModel ParsedAttrInfoTLSModel::Instance; |
||
| 14781 | static constexpr ParsedAttrInfo::Spelling TargetSpellings[] = { |
||
| 14782 | {AttributeCommonInfo::AS_GNU, "target"}, |
||
| 14783 | {AttributeCommonInfo::AS_CXX11, "gnu::target"}, |
||
| 14784 | {AttributeCommonInfo::AS_C2x, "gnu::target"}, |
||
| 14785 | }; |
||
| 14786 | static constexpr const char *TargetArgNames[] = { |
||
| 14787 | "featuresStr",}; |
||
| 14788 | struct ParsedAttrInfoTarget final : public ParsedAttrInfo { |
||
| 14789 | constexpr ParsedAttrInfoTarget() : ParsedAttrInfo( |
||
| 14790 | /*AttrKind=*/ParsedAttr::AT_Target, |
||
| 14791 | /*NumArgs=*/1, |
||
| 14792 | /*OptArgs=*/0, |
||
| 14793 | /*NumArgMembers=*/1, |
||
| 14794 | /*HasCustomParsing=*/0, |
||
| 14795 | /*AcceptsExprPack=*/0, |
||
| 14796 | /*IsTargetSpecific=*/0, |
||
| 14797 | /*IsType=*/0, |
||
| 14798 | /*IsStmt=*/0, |
||
| 14799 | /*IsKnownToGCC=*/1, |
||
| 14800 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 14801 | /*Spellings=*/TargetSpellings, |
||
| 14802 | /*ArgNames=*/TargetArgNames) {} |
||
| 14803 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 14804 | if (!isa<FunctionDecl>(D)) { |
||
| 14805 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 14806 | << Attr << "functions"; |
||
| 14807 | return false; |
||
| 14808 | } |
||
| 14809 | return true; |
||
| 14810 | } |
||
| 14811 | |||
| 14812 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 14813 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 14814 | << AL << St->getBeginLoc(); |
||
| 14815 | return false; |
||
| 14816 | } |
||
| 14817 | |||
| 14818 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 14819 | |||
| 14820 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 14821 | if (const auto *A = D->getAttr<TargetClonesAttr>()) { |
||
| 14822 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 14823 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 14824 | return false; |
||
| 14825 | } |
||
| 14826 | if (const auto *A = D->getAttr<TargetVersionAttr>()) { |
||
| 14827 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 14828 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 14829 | return false; |
||
| 14830 | } |
||
| 14831 | if (const auto *A = D->getAttr<CPUDispatchAttr>()) { |
||
| 14832 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 14833 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 14834 | return false; |
||
| 14835 | } |
||
| 14836 | if (const auto *A = D->getAttr<CPUSpecificAttr>()) { |
||
| 14837 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 14838 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 14839 | return false; |
||
| 14840 | } |
||
| 14841 | return true; |
||
| 14842 | } |
||
| 14843 | |||
| 14844 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 14845 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 14846 | } |
||
| 14847 | |||
| 14848 | bool isParamExpr(size_t N) const override { |
||
| 14849 | return false; |
||
| 14850 | } |
||
| 14851 | |||
| 14852 | static const ParsedAttrInfoTarget Instance; |
||
| 14853 | }; |
||
| 14854 | const ParsedAttrInfoTarget ParsedAttrInfoTarget::Instance; |
||
| 14855 | static constexpr ParsedAttrInfo::Spelling TargetClonesSpellings[] = { |
||
| 14856 | {AttributeCommonInfo::AS_GNU, "target_clones"}, |
||
| 14857 | {AttributeCommonInfo::AS_CXX11, "gnu::target_clones"}, |
||
| 14858 | {AttributeCommonInfo::AS_C2x, "gnu::target_clones"}, |
||
| 14859 | }; |
||
| 14860 | static constexpr const char *TargetClonesArgNames[] = { |
||
| 14861 | "featuresStrs...",}; |
||
| 14862 | struct ParsedAttrInfoTargetClones final : public ParsedAttrInfo { |
||
| 14863 | constexpr ParsedAttrInfoTargetClones() : ParsedAttrInfo( |
||
| 14864 | /*AttrKind=*/ParsedAttr::AT_TargetClones, |
||
| 14865 | /*NumArgs=*/0, |
||
| 14866 | /*OptArgs=*/15, |
||
| 14867 | /*NumArgMembers=*/1, |
||
| 14868 | /*HasCustomParsing=*/0, |
||
| 14869 | /*AcceptsExprPack=*/0, |
||
| 14870 | /*IsTargetSpecific=*/0, |
||
| 14871 | /*IsType=*/0, |
||
| 14872 | /*IsStmt=*/0, |
||
| 14873 | /*IsKnownToGCC=*/1, |
||
| 14874 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 14875 | /*Spellings=*/TargetClonesSpellings, |
||
| 14876 | /*ArgNames=*/TargetClonesArgNames) {} |
||
| 14877 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 14878 | if (!isa<FunctionDecl>(D)) { |
||
| 14879 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 14880 | << Attr << "functions"; |
||
| 14881 | return false; |
||
| 14882 | } |
||
| 14883 | return true; |
||
| 14884 | } |
||
| 14885 | |||
| 14886 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 14887 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 14888 | << AL << St->getBeginLoc(); |
||
| 14889 | return false; |
||
| 14890 | } |
||
| 14891 | |||
| 14892 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 14893 | |||
| 14894 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 14895 | if (const auto *A = D->getAttr<TargetVersionAttr>()) { |
||
| 14896 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 14897 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 14898 | return false; |
||
| 14899 | } |
||
| 14900 | if (const auto *A = D->getAttr<TargetAttr>()) { |
||
| 14901 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 14902 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 14903 | return false; |
||
| 14904 | } |
||
| 14905 | if (const auto *A = D->getAttr<CPUDispatchAttr>()) { |
||
| 14906 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 14907 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 14908 | return false; |
||
| 14909 | } |
||
| 14910 | if (const auto *A = D->getAttr<CPUSpecificAttr>()) { |
||
| 14911 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 14912 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 14913 | return false; |
||
| 14914 | } |
||
| 14915 | return true; |
||
| 14916 | } |
||
| 14917 | |||
| 14918 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 14919 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 14920 | } |
||
| 14921 | |||
| 14922 | bool isParamExpr(size_t N) const override { |
||
| 14923 | return false; |
||
| 14924 | } |
||
| 14925 | |||
| 14926 | static const ParsedAttrInfoTargetClones Instance; |
||
| 14927 | }; |
||
| 14928 | const ParsedAttrInfoTargetClones ParsedAttrInfoTargetClones::Instance; |
||
| 14929 | static constexpr ParsedAttrInfo::Spelling TargetVersionSpellings[] = { |
||
| 14930 | {AttributeCommonInfo::AS_GNU, "target_version"}, |
||
| 14931 | {AttributeCommonInfo::AS_CXX11, "gnu::target_version"}, |
||
| 14932 | {AttributeCommonInfo::AS_C2x, "gnu::target_version"}, |
||
| 14933 | }; |
||
| 14934 | static constexpr const char *TargetVersionArgNames[] = { |
||
| 14935 | "NamesStr",}; |
||
| 14936 | struct ParsedAttrInfoTargetVersion final : public ParsedAttrInfo { |
||
| 14937 | constexpr ParsedAttrInfoTargetVersion() : ParsedAttrInfo( |
||
| 14938 | /*AttrKind=*/ParsedAttr::AT_TargetVersion, |
||
| 14939 | /*NumArgs=*/1, |
||
| 14940 | /*OptArgs=*/0, |
||
| 14941 | /*NumArgMembers=*/1, |
||
| 14942 | /*HasCustomParsing=*/0, |
||
| 14943 | /*AcceptsExprPack=*/0, |
||
| 14944 | /*IsTargetSpecific=*/0, |
||
| 14945 | /*IsType=*/0, |
||
| 14946 | /*IsStmt=*/0, |
||
| 14947 | /*IsKnownToGCC=*/1, |
||
| 14948 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 14949 | /*Spellings=*/TargetVersionSpellings, |
||
| 14950 | /*ArgNames=*/TargetVersionArgNames) {} |
||
| 14951 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 14952 | if (!isa<FunctionDecl>(D)) { |
||
| 14953 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 14954 | << Attr << "functions"; |
||
| 14955 | return false; |
||
| 14956 | } |
||
| 14957 | return true; |
||
| 14958 | } |
||
| 14959 | |||
| 14960 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 14961 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 14962 | << AL << St->getBeginLoc(); |
||
| 14963 | return false; |
||
| 14964 | } |
||
| 14965 | |||
| 14966 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 14967 | |||
| 14968 | bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, const Decl *D) const override { |
||
| 14969 | if (const auto *A = D->getAttr<TargetClonesAttr>()) { |
||
| 14970 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 14971 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 14972 | return false; |
||
| 14973 | } |
||
| 14974 | if (const auto *A = D->getAttr<TargetAttr>()) { |
||
| 14975 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 14976 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 14977 | return false; |
||
| 14978 | } |
||
| 14979 | if (const auto *A = D->getAttr<CPUDispatchAttr>()) { |
||
| 14980 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 14981 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 14982 | return false; |
||
| 14983 | } |
||
| 14984 | if (const auto *A = D->getAttr<CPUSpecificAttr>()) { |
||
| 14985 | S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) << AL << A; |
||
| 14986 | S.Diag(A->getLocation(), diag::note_conflicting_attribute); |
||
| 14987 | return false; |
||
| 14988 | } |
||
| 14989 | return true; |
||
| 14990 | } |
||
| 14991 | |||
| 14992 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 14993 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 14994 | } |
||
| 14995 | |||
| 14996 | bool isParamExpr(size_t N) const override { |
||
| 14997 | return false; |
||
| 14998 | } |
||
| 14999 | |||
| 15000 | static const ParsedAttrInfoTargetVersion Instance; |
||
| 15001 | }; |
||
| 15002 | const ParsedAttrInfoTargetVersion ParsedAttrInfoTargetVersion::Instance; |
||
| 15003 | static constexpr ParsedAttrInfo::Spelling TestTypestateSpellings[] = { |
||
| 15004 | {AttributeCommonInfo::AS_GNU, "test_typestate"}, |
||
| 15005 | {AttributeCommonInfo::AS_CXX11, "clang::test_typestate"}, |
||
| 15006 | }; |
||
| 15007 | static constexpr const char *TestTypestateArgNames[] = { |
||
| 15008 | "TestState",}; |
||
| 15009 | struct ParsedAttrInfoTestTypestate final : public ParsedAttrInfo { |
||
| 15010 | constexpr ParsedAttrInfoTestTypestate() : ParsedAttrInfo( |
||
| 15011 | /*AttrKind=*/ParsedAttr::AT_TestTypestate, |
||
| 15012 | /*NumArgs=*/1, |
||
| 15013 | /*OptArgs=*/0, |
||
| 15014 | /*NumArgMembers=*/1, |
||
| 15015 | /*HasCustomParsing=*/0, |
||
| 15016 | /*AcceptsExprPack=*/0, |
||
| 15017 | /*IsTargetSpecific=*/0, |
||
| 15018 | /*IsType=*/0, |
||
| 15019 | /*IsStmt=*/0, |
||
| 15020 | /*IsKnownToGCC=*/0, |
||
| 15021 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 15022 | /*Spellings=*/TestTypestateSpellings, |
||
| 15023 | /*ArgNames=*/TestTypestateArgNames) {} |
||
| 15024 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 15025 | if (!isa<CXXMethodDecl>(D)) { |
||
| 15026 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 15027 | << Attr << "functions"; |
||
| 15028 | return false; |
||
| 15029 | } |
||
| 15030 | return true; |
||
| 15031 | } |
||
| 15032 | |||
| 15033 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 15034 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 15035 | << AL << St->getBeginLoc(); |
||
| 15036 | return false; |
||
| 15037 | } |
||
| 15038 | |||
| 15039 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 15040 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function_is_member, /*IsSupported=*/LangOpts.CPlusPlus)); |
||
| 15041 | } |
||
| 15042 | |||
| 15043 | bool isParamExpr(size_t N) const override { |
||
| 15044 | return false; |
||
| 15045 | } |
||
| 15046 | |||
| 15047 | static const ParsedAttrInfoTestTypestate Instance; |
||
| 15048 | }; |
||
| 15049 | const ParsedAttrInfoTestTypestate ParsedAttrInfoTestTypestate::Instance; |
||
| 15050 | static constexpr ParsedAttrInfo::Spelling ThisCallSpellings[] = { |
||
| 15051 | {AttributeCommonInfo::AS_GNU, "thiscall"}, |
||
| 15052 | {AttributeCommonInfo::AS_CXX11, "gnu::thiscall"}, |
||
| 15053 | {AttributeCommonInfo::AS_C2x, "gnu::thiscall"}, |
||
| 15054 | {AttributeCommonInfo::AS_Keyword, "__thiscall"}, |
||
| 15055 | {AttributeCommonInfo::AS_Keyword, "_thiscall"}, |
||
| 15056 | }; |
||
| 15057 | struct ParsedAttrInfoThisCall final : public ParsedAttrInfo { |
||
| 15058 | constexpr ParsedAttrInfoThisCall() : ParsedAttrInfo( |
||
| 15059 | /*AttrKind=*/ParsedAttr::AT_ThisCall, |
||
| 15060 | /*NumArgs=*/0, |
||
| 15061 | /*OptArgs=*/0, |
||
| 15062 | /*NumArgMembers=*/0, |
||
| 15063 | /*HasCustomParsing=*/0, |
||
| 15064 | /*AcceptsExprPack=*/0, |
||
| 15065 | /*IsTargetSpecific=*/0, |
||
| 15066 | /*IsType=*/1, |
||
| 15067 | /*IsStmt=*/0, |
||
| 15068 | /*IsKnownToGCC=*/1, |
||
| 15069 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 15070 | /*Spellings=*/ThisCallSpellings, |
||
| 15071 | /*ArgNames=*/{}) {} |
||
| 15072 | bool isParamExpr(size_t N) const override { |
||
| 15073 | return false; |
||
| 15074 | } |
||
| 15075 | |||
| 15076 | static const ParsedAttrInfoThisCall Instance; |
||
| 15077 | }; |
||
| 15078 | const ParsedAttrInfoThisCall ParsedAttrInfoThisCall::Instance; |
||
| 15079 | static constexpr ParsedAttrInfo::Spelling ThreadSpellings[] = { |
||
| 15080 | {AttributeCommonInfo::AS_Declspec, "thread"}, |
||
| 15081 | }; |
||
| 15082 | struct ParsedAttrInfoThread final : public ParsedAttrInfo { |
||
| 15083 | constexpr ParsedAttrInfoThread() : ParsedAttrInfo( |
||
| 15084 | /*AttrKind=*/ParsedAttr::AT_Thread, |
||
| 15085 | /*NumArgs=*/0, |
||
| 15086 | /*OptArgs=*/0, |
||
| 15087 | /*NumArgMembers=*/0, |
||
| 15088 | /*HasCustomParsing=*/0, |
||
| 15089 | /*AcceptsExprPack=*/0, |
||
| 15090 | /*IsTargetSpecific=*/0, |
||
| 15091 | /*IsType=*/0, |
||
| 15092 | /*IsStmt=*/0, |
||
| 15093 | /*IsKnownToGCC=*/0, |
||
| 15094 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 15095 | /*Spellings=*/ThreadSpellings, |
||
| 15096 | /*ArgNames=*/{}) {} |
||
| 15097 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 15098 | if (!isa<VarDecl>(D)) { |
||
| 15099 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 15100 | << Attr << "variables"; |
||
| 15101 | return false; |
||
| 15102 | } |
||
| 15103 | return true; |
||
| 15104 | } |
||
| 15105 | |||
| 15106 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 15107 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 15108 | << AL << St->getBeginLoc(); |
||
| 15109 | return false; |
||
| 15110 | } |
||
| 15111 | |||
| 15112 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 15113 | return LangOpts.MicrosoftExt; |
||
| 15114 | } |
||
| 15115 | |||
| 15116 | bool isParamExpr(size_t N) const override { |
||
| 15117 | return false; |
||
| 15118 | } |
||
| 15119 | |||
| 15120 | static const ParsedAttrInfoThread Instance; |
||
| 15121 | }; |
||
| 15122 | const ParsedAttrInfoThread ParsedAttrInfoThread::Instance; |
||
| 15123 | static constexpr ParsedAttrInfo::Spelling TransparentUnionSpellings[] = { |
||
| 15124 | {AttributeCommonInfo::AS_GNU, "transparent_union"}, |
||
| 15125 | {AttributeCommonInfo::AS_CXX11, "gnu::transparent_union"}, |
||
| 15126 | {AttributeCommonInfo::AS_C2x, "gnu::transparent_union"}, |
||
| 15127 | }; |
||
| 15128 | struct ParsedAttrInfoTransparentUnion final : public ParsedAttrInfo { |
||
| 15129 | constexpr ParsedAttrInfoTransparentUnion() : ParsedAttrInfo( |
||
| 15130 | /*AttrKind=*/ParsedAttr::AT_TransparentUnion, |
||
| 15131 | /*NumArgs=*/0, |
||
| 15132 | /*OptArgs=*/0, |
||
| 15133 | /*NumArgMembers=*/0, |
||
| 15134 | /*HasCustomParsing=*/0, |
||
| 15135 | /*AcceptsExprPack=*/0, |
||
| 15136 | /*IsTargetSpecific=*/0, |
||
| 15137 | /*IsType=*/0, |
||
| 15138 | /*IsStmt=*/0, |
||
| 15139 | /*IsKnownToGCC=*/1, |
||
| 15140 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 15141 | /*Spellings=*/TransparentUnionSpellings, |
||
| 15142 | /*ArgNames=*/{}) {} |
||
| 15143 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 15144 | return (!LangOpts.CPlusPlus); |
||
| 15145 | } |
||
| 15146 | |||
| 15147 | bool isParamExpr(size_t N) const override { |
||
| 15148 | return false; |
||
| 15149 | } |
||
| 15150 | |||
| 15151 | static const ParsedAttrInfoTransparentUnion Instance; |
||
| 15152 | }; |
||
| 15153 | const ParsedAttrInfoTransparentUnion ParsedAttrInfoTransparentUnion::Instance; |
||
| 15154 | static constexpr ParsedAttrInfo::Spelling TrivialABISpellings[] = { |
||
| 15155 | {AttributeCommonInfo::AS_GNU, "trivial_abi"}, |
||
| 15156 | {AttributeCommonInfo::AS_CXX11, "clang::trivial_abi"}, |
||
| 15157 | }; |
||
| 15158 | struct ParsedAttrInfoTrivialABI final : public ParsedAttrInfo { |
||
| 15159 | constexpr ParsedAttrInfoTrivialABI() : ParsedAttrInfo( |
||
| 15160 | /*AttrKind=*/ParsedAttr::AT_TrivialABI, |
||
| 15161 | /*NumArgs=*/0, |
||
| 15162 | /*OptArgs=*/0, |
||
| 15163 | /*NumArgMembers=*/0, |
||
| 15164 | /*HasCustomParsing=*/0, |
||
| 15165 | /*AcceptsExprPack=*/0, |
||
| 15166 | /*IsTargetSpecific=*/0, |
||
| 15167 | /*IsType=*/0, |
||
| 15168 | /*IsStmt=*/0, |
||
| 15169 | /*IsKnownToGCC=*/0, |
||
| 15170 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 15171 | /*Spellings=*/TrivialABISpellings, |
||
| 15172 | /*ArgNames=*/{}) {} |
||
| 15173 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 15174 | if (!isa<CXXRecordDecl>(D)) { |
||
| 15175 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 15176 | << Attr << "classes"; |
||
| 15177 | return false; |
||
| 15178 | } |
||
| 15179 | return true; |
||
| 15180 | } |
||
| 15181 | |||
| 15182 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 15183 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 15184 | << AL << St->getBeginLoc(); |
||
| 15185 | return false; |
||
| 15186 | } |
||
| 15187 | |||
| 15188 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 15189 | return LangOpts.CPlusPlus; |
||
| 15190 | } |
||
| 15191 | |||
| 15192 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 15193 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 15194 | } |
||
| 15195 | |||
| 15196 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 15197 | D->addAttr(::new (S.Context) TrivialABIAttr(S.Context, Attr)); |
||
| 15198 | return AttributeApplied; |
||
| 15199 | } |
||
| 15200 | |||
| 15201 | bool isParamExpr(size_t N) const override { |
||
| 15202 | return false; |
||
| 15203 | } |
||
| 15204 | |||
| 15205 | static const ParsedAttrInfoTrivialABI Instance; |
||
| 15206 | }; |
||
| 15207 | const ParsedAttrInfoTrivialABI ParsedAttrInfoTrivialABI::Instance; |
||
| 15208 | static constexpr ParsedAttrInfo::Spelling TryAcquireCapabilitySpellings[] = { |
||
| 15209 | {AttributeCommonInfo::AS_GNU, "try_acquire_capability"}, |
||
| 15210 | {AttributeCommonInfo::AS_CXX11, "clang::try_acquire_capability"}, |
||
| 15211 | {AttributeCommonInfo::AS_GNU, "try_acquire_shared_capability"}, |
||
| 15212 | {AttributeCommonInfo::AS_CXX11, "clang::try_acquire_shared_capability"}, |
||
| 15213 | }; |
||
| 15214 | static constexpr const char *TryAcquireCapabilityArgNames[] = { |
||
| 15215 | "SuccessValue","Args...",}; |
||
| 15216 | struct ParsedAttrInfoTryAcquireCapability final : public ParsedAttrInfo { |
||
| 15217 | constexpr ParsedAttrInfoTryAcquireCapability() : ParsedAttrInfo( |
||
| 15218 | /*AttrKind=*/ParsedAttr::AT_TryAcquireCapability, |
||
| 15219 | /*NumArgs=*/1, |
||
| 15220 | /*OptArgs=*/15, |
||
| 15221 | /*NumArgMembers=*/2, |
||
| 15222 | /*HasCustomParsing=*/0, |
||
| 15223 | /*AcceptsExprPack=*/0, |
||
| 15224 | /*IsTargetSpecific=*/0, |
||
| 15225 | /*IsType=*/0, |
||
| 15226 | /*IsStmt=*/0, |
||
| 15227 | /*IsKnownToGCC=*/0, |
||
| 15228 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 15229 | /*Spellings=*/TryAcquireCapabilitySpellings, |
||
| 15230 | /*ArgNames=*/TryAcquireCapabilityArgNames) {} |
||
| 15231 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 15232 | if (!isa<FunctionDecl>(D)) { |
||
| 15233 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 15234 | << Attr << "functions"; |
||
| 15235 | return false; |
||
| 15236 | } |
||
| 15237 | return true; |
||
| 15238 | } |
||
| 15239 | |||
| 15240 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 15241 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 15242 | << AL << St->getBeginLoc(); |
||
| 15243 | return false; |
||
| 15244 | } |
||
| 15245 | |||
| 15246 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 15247 | enum Spelling { |
||
| 15248 | GNU_try_acquire_capability = 0, |
||
| 15249 | CXX11_clang_try_acquire_capability = 1, |
||
| 15250 | GNU_try_acquire_shared_capability = 2, |
||
| 15251 | CXX11_clang_try_acquire_shared_capability = 3, |
||
| 15252 | SpellingNotCalculated = 15 |
||
| 15253 | |||
| 15254 | }; |
||
| 15255 | |||
| 15256 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 15257 | switch (Idx) { |
||
| 15258 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 15259 | case 0: return GNU_try_acquire_capability; |
||
| 15260 | case 1: return CXX11_clang_try_acquire_capability; |
||
| 15261 | case 2: return GNU_try_acquire_shared_capability; |
||
| 15262 | case 3: return CXX11_clang_try_acquire_shared_capability; |
||
| 15263 | } |
||
| 15264 | } |
||
| 15265 | |||
| 15266 | bool isParamExpr(size_t N) const override { |
||
| 15267 | return (N == 0) || (N == 1) || false; |
||
| 15268 | } |
||
| 15269 | |||
| 15270 | static const ParsedAttrInfoTryAcquireCapability Instance; |
||
| 15271 | }; |
||
| 15272 | const ParsedAttrInfoTryAcquireCapability ParsedAttrInfoTryAcquireCapability::Instance; |
||
| 15273 | static constexpr ParsedAttrInfo::Spelling TypeNonNullSpellings[] = { |
||
| 15274 | {AttributeCommonInfo::AS_Keyword, "_Nonnull"}, |
||
| 15275 | }; |
||
| 15276 | struct ParsedAttrInfoTypeNonNull final : public ParsedAttrInfo { |
||
| 15277 | constexpr ParsedAttrInfoTypeNonNull() : ParsedAttrInfo( |
||
| 15278 | /*AttrKind=*/ParsedAttr::AT_TypeNonNull, |
||
| 15279 | /*NumArgs=*/0, |
||
| 15280 | /*OptArgs=*/0, |
||
| 15281 | /*NumArgMembers=*/0, |
||
| 15282 | /*HasCustomParsing=*/0, |
||
| 15283 | /*AcceptsExprPack=*/0, |
||
| 15284 | /*IsTargetSpecific=*/0, |
||
| 15285 | /*IsType=*/1, |
||
| 15286 | /*IsStmt=*/0, |
||
| 15287 | /*IsKnownToGCC=*/0, |
||
| 15288 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 15289 | /*Spellings=*/TypeNonNullSpellings, |
||
| 15290 | /*ArgNames=*/{}) {} |
||
| 15291 | bool isParamExpr(size_t N) const override { |
||
| 15292 | return false; |
||
| 15293 | } |
||
| 15294 | |||
| 15295 | static const ParsedAttrInfoTypeNonNull Instance; |
||
| 15296 | }; |
||
| 15297 | const ParsedAttrInfoTypeNonNull ParsedAttrInfoTypeNonNull::Instance; |
||
| 15298 | static constexpr ParsedAttrInfo::Spelling TypeNullUnspecifiedSpellings[] = { |
||
| 15299 | {AttributeCommonInfo::AS_Keyword, "_Null_unspecified"}, |
||
| 15300 | }; |
||
| 15301 | struct ParsedAttrInfoTypeNullUnspecified final : public ParsedAttrInfo { |
||
| 15302 | constexpr ParsedAttrInfoTypeNullUnspecified() : ParsedAttrInfo( |
||
| 15303 | /*AttrKind=*/ParsedAttr::AT_TypeNullUnspecified, |
||
| 15304 | /*NumArgs=*/0, |
||
| 15305 | /*OptArgs=*/0, |
||
| 15306 | /*NumArgMembers=*/0, |
||
| 15307 | /*HasCustomParsing=*/0, |
||
| 15308 | /*AcceptsExprPack=*/0, |
||
| 15309 | /*IsTargetSpecific=*/0, |
||
| 15310 | /*IsType=*/1, |
||
| 15311 | /*IsStmt=*/0, |
||
| 15312 | /*IsKnownToGCC=*/0, |
||
| 15313 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 15314 | /*Spellings=*/TypeNullUnspecifiedSpellings, |
||
| 15315 | /*ArgNames=*/{}) {} |
||
| 15316 | bool isParamExpr(size_t N) const override { |
||
| 15317 | return false; |
||
| 15318 | } |
||
| 15319 | |||
| 15320 | static const ParsedAttrInfoTypeNullUnspecified Instance; |
||
| 15321 | }; |
||
| 15322 | const ParsedAttrInfoTypeNullUnspecified ParsedAttrInfoTypeNullUnspecified::Instance; |
||
| 15323 | static constexpr ParsedAttrInfo::Spelling TypeNullableSpellings[] = { |
||
| 15324 | {AttributeCommonInfo::AS_Keyword, "_Nullable"}, |
||
| 15325 | }; |
||
| 15326 | struct ParsedAttrInfoTypeNullable final : public ParsedAttrInfo { |
||
| 15327 | constexpr ParsedAttrInfoTypeNullable() : ParsedAttrInfo( |
||
| 15328 | /*AttrKind=*/ParsedAttr::AT_TypeNullable, |
||
| 15329 | /*NumArgs=*/0, |
||
| 15330 | /*OptArgs=*/0, |
||
| 15331 | /*NumArgMembers=*/0, |
||
| 15332 | /*HasCustomParsing=*/0, |
||
| 15333 | /*AcceptsExprPack=*/0, |
||
| 15334 | /*IsTargetSpecific=*/0, |
||
| 15335 | /*IsType=*/1, |
||
| 15336 | /*IsStmt=*/0, |
||
| 15337 | /*IsKnownToGCC=*/0, |
||
| 15338 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 15339 | /*Spellings=*/TypeNullableSpellings, |
||
| 15340 | /*ArgNames=*/{}) {} |
||
| 15341 | bool isParamExpr(size_t N) const override { |
||
| 15342 | return false; |
||
| 15343 | } |
||
| 15344 | |||
| 15345 | static const ParsedAttrInfoTypeNullable Instance; |
||
| 15346 | }; |
||
| 15347 | const ParsedAttrInfoTypeNullable ParsedAttrInfoTypeNullable::Instance; |
||
| 15348 | static constexpr ParsedAttrInfo::Spelling TypeNullableResultSpellings[] = { |
||
| 15349 | {AttributeCommonInfo::AS_Keyword, "_Nullable_result"}, |
||
| 15350 | }; |
||
| 15351 | struct ParsedAttrInfoTypeNullableResult final : public ParsedAttrInfo { |
||
| 15352 | constexpr ParsedAttrInfoTypeNullableResult() : ParsedAttrInfo( |
||
| 15353 | /*AttrKind=*/ParsedAttr::AT_TypeNullableResult, |
||
| 15354 | /*NumArgs=*/0, |
||
| 15355 | /*OptArgs=*/0, |
||
| 15356 | /*NumArgMembers=*/0, |
||
| 15357 | /*HasCustomParsing=*/0, |
||
| 15358 | /*AcceptsExprPack=*/0, |
||
| 15359 | /*IsTargetSpecific=*/0, |
||
| 15360 | /*IsType=*/1, |
||
| 15361 | /*IsStmt=*/0, |
||
| 15362 | /*IsKnownToGCC=*/0, |
||
| 15363 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 15364 | /*Spellings=*/TypeNullableResultSpellings, |
||
| 15365 | /*ArgNames=*/{}) {} |
||
| 15366 | bool isParamExpr(size_t N) const override { |
||
| 15367 | return false; |
||
| 15368 | } |
||
| 15369 | |||
| 15370 | static const ParsedAttrInfoTypeNullableResult Instance; |
||
| 15371 | }; |
||
| 15372 | const ParsedAttrInfoTypeNullableResult ParsedAttrInfoTypeNullableResult::Instance; |
||
| 15373 | static constexpr ParsedAttrInfo::Spelling TypeTagForDatatypeSpellings[] = { |
||
| 15374 | {AttributeCommonInfo::AS_GNU, "type_tag_for_datatype"}, |
||
| 15375 | {AttributeCommonInfo::AS_CXX11, "clang::type_tag_for_datatype"}, |
||
| 15376 | {AttributeCommonInfo::AS_C2x, "clang::type_tag_for_datatype"}, |
||
| 15377 | }; |
||
| 15378 | static constexpr const char *TypeTagForDatatypeArgNames[] = { |
||
| 15379 | "ArgumentKind","MatchingCType","LayoutCompatible","MustBeNull",}; |
||
| 15380 | struct ParsedAttrInfoTypeTagForDatatype final : public ParsedAttrInfo { |
||
| 15381 | constexpr ParsedAttrInfoTypeTagForDatatype() : ParsedAttrInfo( |
||
| 15382 | /*AttrKind=*/ParsedAttr::AT_TypeTagForDatatype, |
||
| 15383 | /*NumArgs=*/4, |
||
| 15384 | /*OptArgs=*/0, |
||
| 15385 | /*NumArgMembers=*/4, |
||
| 15386 | /*HasCustomParsing=*/1, |
||
| 15387 | /*AcceptsExprPack=*/0, |
||
| 15388 | /*IsTargetSpecific=*/0, |
||
| 15389 | /*IsType=*/0, |
||
| 15390 | /*IsStmt=*/0, |
||
| 15391 | /*IsKnownToGCC=*/0, |
||
| 15392 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 15393 | /*Spellings=*/TypeTagForDatatypeSpellings, |
||
| 15394 | /*ArgNames=*/TypeTagForDatatypeArgNames) {} |
||
| 15395 | bool isParamExpr(size_t N) const override { |
||
| 15396 | return false; |
||
| 15397 | } |
||
| 15398 | |||
| 15399 | static const ParsedAttrInfoTypeTagForDatatype Instance; |
||
| 15400 | }; |
||
| 15401 | const ParsedAttrInfoTypeTagForDatatype ParsedAttrInfoTypeTagForDatatype::Instance; |
||
| 15402 | static constexpr ParsedAttrInfo::Spelling TypeVisibilitySpellings[] = { |
||
| 15403 | {AttributeCommonInfo::AS_GNU, "type_visibility"}, |
||
| 15404 | {AttributeCommonInfo::AS_CXX11, "clang::type_visibility"}, |
||
| 15405 | {AttributeCommonInfo::AS_C2x, "clang::type_visibility"}, |
||
| 15406 | }; |
||
| 15407 | static constexpr const char *TypeVisibilityArgNames[] = { |
||
| 15408 | "Visibility",}; |
||
| 15409 | struct ParsedAttrInfoTypeVisibility final : public ParsedAttrInfo { |
||
| 15410 | constexpr ParsedAttrInfoTypeVisibility() : ParsedAttrInfo( |
||
| 15411 | /*AttrKind=*/ParsedAttr::AT_TypeVisibility, |
||
| 15412 | /*NumArgs=*/1, |
||
| 15413 | /*OptArgs=*/0, |
||
| 15414 | /*NumArgMembers=*/1, |
||
| 15415 | /*HasCustomParsing=*/0, |
||
| 15416 | /*AcceptsExprPack=*/0, |
||
| 15417 | /*IsTargetSpecific=*/0, |
||
| 15418 | /*IsType=*/0, |
||
| 15419 | /*IsStmt=*/0, |
||
| 15420 | /*IsKnownToGCC=*/0, |
||
| 15421 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 15422 | /*Spellings=*/TypeVisibilitySpellings, |
||
| 15423 | /*ArgNames=*/TypeVisibilityArgNames) {} |
||
| 15424 | bool isParamExpr(size_t N) const override { |
||
| 15425 | return false; |
||
| 15426 | } |
||
| 15427 | |||
| 15428 | static const ParsedAttrInfoTypeVisibility Instance; |
||
| 15429 | }; |
||
| 15430 | const ParsedAttrInfoTypeVisibility ParsedAttrInfoTypeVisibility::Instance; |
||
| 15431 | static constexpr ParsedAttrInfo::Spelling UPtrSpellings[] = { |
||
| 15432 | {AttributeCommonInfo::AS_Keyword, "__uptr"}, |
||
| 15433 | }; |
||
| 15434 | struct ParsedAttrInfoUPtr final : public ParsedAttrInfo { |
||
| 15435 | constexpr ParsedAttrInfoUPtr() : ParsedAttrInfo( |
||
| 15436 | /*AttrKind=*/ParsedAttr::AT_UPtr, |
||
| 15437 | /*NumArgs=*/0, |
||
| 15438 | /*OptArgs=*/0, |
||
| 15439 | /*NumArgMembers=*/0, |
||
| 15440 | /*HasCustomParsing=*/0, |
||
| 15441 | /*AcceptsExprPack=*/0, |
||
| 15442 | /*IsTargetSpecific=*/0, |
||
| 15443 | /*IsType=*/1, |
||
| 15444 | /*IsStmt=*/0, |
||
| 15445 | /*IsKnownToGCC=*/0, |
||
| 15446 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 15447 | /*Spellings=*/UPtrSpellings, |
||
| 15448 | /*ArgNames=*/{}) {} |
||
| 15449 | bool isParamExpr(size_t N) const override { |
||
| 15450 | return false; |
||
| 15451 | } |
||
| 15452 | |||
| 15453 | static const ParsedAttrInfoUPtr Instance; |
||
| 15454 | }; |
||
| 15455 | const ParsedAttrInfoUPtr ParsedAttrInfoUPtr::Instance; |
||
| 15456 | static constexpr ParsedAttrInfo::Spelling UnavailableSpellings[] = { |
||
| 15457 | {AttributeCommonInfo::AS_GNU, "unavailable"}, |
||
| 15458 | {AttributeCommonInfo::AS_CXX11, "clang::unavailable"}, |
||
| 15459 | {AttributeCommonInfo::AS_C2x, "clang::unavailable"}, |
||
| 15460 | }; |
||
| 15461 | static constexpr const char *UnavailableArgNames[] = { |
||
| 15462 | "Message",}; |
||
| 15463 | struct ParsedAttrInfoUnavailable final : public ParsedAttrInfo { |
||
| 15464 | constexpr ParsedAttrInfoUnavailable() : ParsedAttrInfo( |
||
| 15465 | /*AttrKind=*/ParsedAttr::AT_Unavailable, |
||
| 15466 | /*NumArgs=*/0, |
||
| 15467 | /*OptArgs=*/1, |
||
| 15468 | /*NumArgMembers=*/1, |
||
| 15469 | /*HasCustomParsing=*/0, |
||
| 15470 | /*AcceptsExprPack=*/0, |
||
| 15471 | /*IsTargetSpecific=*/0, |
||
| 15472 | /*IsType=*/0, |
||
| 15473 | /*IsStmt=*/0, |
||
| 15474 | /*IsKnownToGCC=*/0, |
||
| 15475 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 15476 | /*Spellings=*/UnavailableSpellings, |
||
| 15477 | /*ArgNames=*/UnavailableArgNames) {} |
||
| 15478 | bool isParamExpr(size_t N) const override { |
||
| 15479 | return false; |
||
| 15480 | } |
||
| 15481 | |||
| 15482 | static const ParsedAttrInfoUnavailable Instance; |
||
| 15483 | }; |
||
| 15484 | const ParsedAttrInfoUnavailable ParsedAttrInfoUnavailable::Instance; |
||
| 15485 | static constexpr ParsedAttrInfo::Spelling UninitializedSpellings[] = { |
||
| 15486 | {AttributeCommonInfo::AS_GNU, "uninitialized"}, |
||
| 15487 | {AttributeCommonInfo::AS_CXX11, "clang::uninitialized"}, |
||
| 15488 | }; |
||
| 15489 | struct ParsedAttrInfoUninitialized final : public ParsedAttrInfo { |
||
| 15490 | constexpr ParsedAttrInfoUninitialized() : ParsedAttrInfo( |
||
| 15491 | /*AttrKind=*/ParsedAttr::AT_Uninitialized, |
||
| 15492 | /*NumArgs=*/0, |
||
| 15493 | /*OptArgs=*/0, |
||
| 15494 | /*NumArgMembers=*/0, |
||
| 15495 | /*HasCustomParsing=*/0, |
||
| 15496 | /*AcceptsExprPack=*/0, |
||
| 15497 | /*IsTargetSpecific=*/0, |
||
| 15498 | /*IsType=*/0, |
||
| 15499 | /*IsStmt=*/0, |
||
| 15500 | /*IsKnownToGCC=*/0, |
||
| 15501 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 15502 | /*Spellings=*/UninitializedSpellings, |
||
| 15503 | /*ArgNames=*/{}) {} |
||
| 15504 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 15505 | if (!isLocalVar(D)) { |
||
| 15506 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 15507 | << Attr << "local variables"; |
||
| 15508 | return false; |
||
| 15509 | } |
||
| 15510 | return true; |
||
| 15511 | } |
||
| 15512 | |||
| 15513 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 15514 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 15515 | << AL << St->getBeginLoc(); |
||
| 15516 | return false; |
||
| 15517 | } |
||
| 15518 | |||
| 15519 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 15520 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_local, /*IsSupported=*/true)); |
||
| 15521 | } |
||
| 15522 | |||
| 15523 | bool isParamExpr(size_t N) const override { |
||
| 15524 | return false; |
||
| 15525 | } |
||
| 15526 | |||
| 15527 | static const ParsedAttrInfoUninitialized Instance; |
||
| 15528 | }; |
||
| 15529 | const ParsedAttrInfoUninitialized ParsedAttrInfoUninitialized::Instance; |
||
| 15530 | static constexpr ParsedAttrInfo::Spelling UnlikelySpellings[] = { |
||
| 15531 | {AttributeCommonInfo::AS_CXX11, "unlikely"}, |
||
| 15532 | {AttributeCommonInfo::AS_C2x, "clang::unlikely"}, |
||
| 15533 | }; |
||
| 15534 | struct ParsedAttrInfoUnlikely final : public ParsedAttrInfo { |
||
| 15535 | constexpr ParsedAttrInfoUnlikely() : ParsedAttrInfo( |
||
| 15536 | /*AttrKind=*/ParsedAttr::AT_Unlikely, |
||
| 15537 | /*NumArgs=*/0, |
||
| 15538 | /*OptArgs=*/0, |
||
| 15539 | /*NumArgMembers=*/0, |
||
| 15540 | /*HasCustomParsing=*/0, |
||
| 15541 | /*AcceptsExprPack=*/0, |
||
| 15542 | /*IsTargetSpecific=*/0, |
||
| 15543 | /*IsType=*/0, |
||
| 15544 | /*IsStmt=*/1, |
||
| 15545 | /*IsKnownToGCC=*/0, |
||
| 15546 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 15547 | /*Spellings=*/UnlikelySpellings, |
||
| 15548 | /*ArgNames=*/{}) {} |
||
| 15549 | using ParsedAttrInfo::diagMutualExclusion; |
||
| 15550 | |||
| 15551 | bool isParamExpr(size_t N) const override { |
||
| 15552 | return false; |
||
| 15553 | } |
||
| 15554 | |||
| 15555 | static const ParsedAttrInfoUnlikely Instance; |
||
| 15556 | }; |
||
| 15557 | const ParsedAttrInfoUnlikely ParsedAttrInfoUnlikely::Instance; |
||
| 15558 | static constexpr ParsedAttrInfo::Spelling UnusedSpellings[] = { |
||
| 15559 | {AttributeCommonInfo::AS_CXX11, "maybe_unused"}, |
||
| 15560 | {AttributeCommonInfo::AS_GNU, "unused"}, |
||
| 15561 | {AttributeCommonInfo::AS_CXX11, "gnu::unused"}, |
||
| 15562 | {AttributeCommonInfo::AS_C2x, "gnu::unused"}, |
||
| 15563 | {AttributeCommonInfo::AS_C2x, "maybe_unused"}, |
||
| 15564 | }; |
||
| 15565 | struct ParsedAttrInfoUnused final : public ParsedAttrInfo { |
||
| 15566 | constexpr ParsedAttrInfoUnused() : ParsedAttrInfo( |
||
| 15567 | /*AttrKind=*/ParsedAttr::AT_Unused, |
||
| 15568 | /*NumArgs=*/0, |
||
| 15569 | /*OptArgs=*/0, |
||
| 15570 | /*NumArgMembers=*/0, |
||
| 15571 | /*HasCustomParsing=*/0, |
||
| 15572 | /*AcceptsExprPack=*/0, |
||
| 15573 | /*IsTargetSpecific=*/0, |
||
| 15574 | /*IsType=*/0, |
||
| 15575 | /*IsStmt=*/0, |
||
| 15576 | /*IsKnownToGCC=*/1, |
||
| 15577 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 15578 | /*Spellings=*/UnusedSpellings, |
||
| 15579 | /*ArgNames=*/{}) {} |
||
| 15580 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 15581 | if (!isa<VarDecl>(D) && !isa<ObjCIvarDecl>(D) && !isa<TypeDecl>(D) && !isa<EnumDecl>(D) && !isa<EnumConstantDecl>(D) && !isa<LabelDecl>(D) && !isa<FieldDecl>(D) && !isa<ObjCMethodDecl>(D) && !isFunctionLike(D)) { |
||
| 15582 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 15583 | << Attr << "variables, non-static data members, types, enums, enumerators, labels, non-static data members, Objective-C methods, functions, and function pointers"; |
||
| 15584 | return false; |
||
| 15585 | } |
||
| 15586 | return true; |
||
| 15587 | } |
||
| 15588 | |||
| 15589 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 15590 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 15591 | << AL << St->getBeginLoc(); |
||
| 15592 | return false; |
||
| 15593 | } |
||
| 15594 | |||
| 15595 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 15596 | enum Spelling { |
||
| 15597 | CXX11_maybe_unused = 0, |
||
| 15598 | GNU_unused = 1, |
||
| 15599 | CXX11_gnu_unused = 2, |
||
| 15600 | C2x_gnu_unused = 3, |
||
| 15601 | C2x_maybe_unused = 4, |
||
| 15602 | SpellingNotCalculated = 15 |
||
| 15603 | |||
| 15604 | }; |
||
| 15605 | |||
| 15606 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 15607 | switch (Idx) { |
||
| 15608 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 15609 | case 0: return CXX11_maybe_unused; |
||
| 15610 | case 1: return GNU_unused; |
||
| 15611 | case 2: return CXX11_gnu_unused; |
||
| 15612 | case 3: return C2x_gnu_unused; |
||
| 15613 | case 4: return C2x_maybe_unused; |
||
| 15614 | } |
||
| 15615 | } |
||
| 15616 | |||
| 15617 | bool isParamExpr(size_t N) const override { |
||
| 15618 | return false; |
||
| 15619 | } |
||
| 15620 | |||
| 15621 | static const ParsedAttrInfoUnused Instance; |
||
| 15622 | }; |
||
| 15623 | const ParsedAttrInfoUnused ParsedAttrInfoUnused::Instance; |
||
| 15624 | static constexpr ParsedAttrInfo::Spelling UseHandleSpellings[] = { |
||
| 15625 | {AttributeCommonInfo::AS_GNU, "use_handle"}, |
||
| 15626 | {AttributeCommonInfo::AS_CXX11, "clang::use_handle"}, |
||
| 15627 | {AttributeCommonInfo::AS_C2x, "clang::use_handle"}, |
||
| 15628 | }; |
||
| 15629 | static constexpr const char *UseHandleArgNames[] = { |
||
| 15630 | "HandleType",}; |
||
| 15631 | struct ParsedAttrInfoUseHandle final : public ParsedAttrInfo { |
||
| 15632 | constexpr ParsedAttrInfoUseHandle() : ParsedAttrInfo( |
||
| 15633 | /*AttrKind=*/ParsedAttr::AT_UseHandle, |
||
| 15634 | /*NumArgs=*/1, |
||
| 15635 | /*OptArgs=*/0, |
||
| 15636 | /*NumArgMembers=*/1, |
||
| 15637 | /*HasCustomParsing=*/0, |
||
| 15638 | /*AcceptsExprPack=*/0, |
||
| 15639 | /*IsTargetSpecific=*/0, |
||
| 15640 | /*IsType=*/0, |
||
| 15641 | /*IsStmt=*/0, |
||
| 15642 | /*IsKnownToGCC=*/0, |
||
| 15643 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 15644 | /*Spellings=*/UseHandleSpellings, |
||
| 15645 | /*ArgNames=*/UseHandleArgNames) {} |
||
| 15646 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 15647 | if (!isa<ParmVarDecl>(D)) { |
||
| 15648 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 15649 | << Attr << "parameters"; |
||
| 15650 | return false; |
||
| 15651 | } |
||
| 15652 | return true; |
||
| 15653 | } |
||
| 15654 | |||
| 15655 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 15656 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 15657 | << AL << St->getBeginLoc(); |
||
| 15658 | return false; |
||
| 15659 | } |
||
| 15660 | |||
| 15661 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 15662 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable_is_parameter, /*IsSupported=*/true)); |
||
| 15663 | } |
||
| 15664 | |||
| 15665 | bool isParamExpr(size_t N) const override { |
||
| 15666 | return false; |
||
| 15667 | } |
||
| 15668 | |||
| 15669 | static const ParsedAttrInfoUseHandle Instance; |
||
| 15670 | }; |
||
| 15671 | const ParsedAttrInfoUseHandle ParsedAttrInfoUseHandle::Instance; |
||
| 15672 | static constexpr ParsedAttrInfo::Spelling UsedSpellings[] = { |
||
| 15673 | {AttributeCommonInfo::AS_GNU, "used"}, |
||
| 15674 | {AttributeCommonInfo::AS_CXX11, "gnu::used"}, |
||
| 15675 | {AttributeCommonInfo::AS_C2x, "gnu::used"}, |
||
| 15676 | }; |
||
| 15677 | struct ParsedAttrInfoUsed final : public ParsedAttrInfo { |
||
| 15678 | constexpr ParsedAttrInfoUsed() : ParsedAttrInfo( |
||
| 15679 | /*AttrKind=*/ParsedAttr::AT_Used, |
||
| 15680 | /*NumArgs=*/0, |
||
| 15681 | /*OptArgs=*/0, |
||
| 15682 | /*NumArgMembers=*/0, |
||
| 15683 | /*HasCustomParsing=*/0, |
||
| 15684 | /*AcceptsExprPack=*/0, |
||
| 15685 | /*IsTargetSpecific=*/0, |
||
| 15686 | /*IsType=*/0, |
||
| 15687 | /*IsStmt=*/0, |
||
| 15688 | /*IsKnownToGCC=*/1, |
||
| 15689 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 15690 | /*Spellings=*/UsedSpellings, |
||
| 15691 | /*ArgNames=*/{}) {} |
||
| 15692 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 15693 | if (!isNonLocalVar(D) && !isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
||
| 15694 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 15695 | << Attr << "variables with non-local storage, functions, and Objective-C methods"; |
||
| 15696 | return false; |
||
| 15697 | } |
||
| 15698 | return true; |
||
| 15699 | } |
||
| 15700 | |||
| 15701 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 15702 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 15703 | << AL << St->getBeginLoc(); |
||
| 15704 | return false; |
||
| 15705 | } |
||
| 15706 | |||
| 15707 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 15708 | D->addAttr(::new (S.Context) UsedAttr(S.Context, Attr)); |
||
| 15709 | return AttributeApplied; |
||
| 15710 | } |
||
| 15711 | |||
| 15712 | bool isParamExpr(size_t N) const override { |
||
| 15713 | return false; |
||
| 15714 | } |
||
| 15715 | |||
| 15716 | static const ParsedAttrInfoUsed Instance; |
||
| 15717 | }; |
||
| 15718 | const ParsedAttrInfoUsed ParsedAttrInfoUsed::Instance; |
||
| 15719 | static constexpr ParsedAttrInfo::Spelling UsingIfExistsSpellings[] = { |
||
| 15720 | {AttributeCommonInfo::AS_GNU, "using_if_exists"}, |
||
| 15721 | {AttributeCommonInfo::AS_CXX11, "clang::using_if_exists"}, |
||
| 15722 | }; |
||
| 15723 | struct ParsedAttrInfoUsingIfExists final : public ParsedAttrInfo { |
||
| 15724 | constexpr ParsedAttrInfoUsingIfExists() : ParsedAttrInfo( |
||
| 15725 | /*AttrKind=*/ParsedAttr::AT_UsingIfExists, |
||
| 15726 | /*NumArgs=*/0, |
||
| 15727 | /*OptArgs=*/0, |
||
| 15728 | /*NumArgMembers=*/0, |
||
| 15729 | /*HasCustomParsing=*/0, |
||
| 15730 | /*AcceptsExprPack=*/0, |
||
| 15731 | /*IsTargetSpecific=*/0, |
||
| 15732 | /*IsType=*/0, |
||
| 15733 | /*IsStmt=*/0, |
||
| 15734 | /*IsKnownToGCC=*/0, |
||
| 15735 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 15736 | /*Spellings=*/UsingIfExistsSpellings, |
||
| 15737 | /*ArgNames=*/{}) {} |
||
| 15738 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 15739 | if (!isa<UsingDecl>(D) && !isa<UnresolvedUsingTypenameDecl>(D) && !isa<UnresolvedUsingValueDecl>(D)) { |
||
| 15740 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 15741 | << Attr << "named declarations, types, and value declarations"; |
||
| 15742 | return false; |
||
| 15743 | } |
||
| 15744 | return true; |
||
| 15745 | } |
||
| 15746 | |||
| 15747 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 15748 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 15749 | << AL << St->getBeginLoc(); |
||
| 15750 | return false; |
||
| 15751 | } |
||
| 15752 | |||
| 15753 | bool isParamExpr(size_t N) const override { |
||
| 15754 | return false; |
||
| 15755 | } |
||
| 15756 | |||
| 15757 | static const ParsedAttrInfoUsingIfExists Instance; |
||
| 15758 | }; |
||
| 15759 | const ParsedAttrInfoUsingIfExists ParsedAttrInfoUsingIfExists::Instance; |
||
| 15760 | static constexpr ParsedAttrInfo::Spelling UuidSpellings[] = { |
||
| 15761 | {AttributeCommonInfo::AS_Declspec, "uuid"}, |
||
| 15762 | {AttributeCommonInfo::AS_Microsoft, "uuid"}, |
||
| 15763 | }; |
||
| 15764 | static constexpr const char *UuidArgNames[] = { |
||
| 15765 | "Guid",}; |
||
| 15766 | struct ParsedAttrInfoUuid final : public ParsedAttrInfo { |
||
| 15767 | constexpr ParsedAttrInfoUuid() : ParsedAttrInfo( |
||
| 15768 | /*AttrKind=*/ParsedAttr::AT_Uuid, |
||
| 15769 | /*NumArgs=*/1, |
||
| 15770 | /*OptArgs=*/0, |
||
| 15771 | /*NumArgMembers=*/1, |
||
| 15772 | /*HasCustomParsing=*/0, |
||
| 15773 | /*AcceptsExprPack=*/0, |
||
| 15774 | /*IsTargetSpecific=*/0, |
||
| 15775 | /*IsType=*/0, |
||
| 15776 | /*IsStmt=*/0, |
||
| 15777 | /*IsKnownToGCC=*/0, |
||
| 15778 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 15779 | /*Spellings=*/UuidSpellings, |
||
| 15780 | /*ArgNames=*/UuidArgNames) {} |
||
| 15781 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 15782 | if (!isa<RecordDecl>(D) && !isa<EnumDecl>(D)) { |
||
| 15783 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 15784 | << Attr << "structs, unions, classes, and enums"; |
||
| 15785 | return false; |
||
| 15786 | } |
||
| 15787 | return true; |
||
| 15788 | } |
||
| 15789 | |||
| 15790 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 15791 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 15792 | << AL << St->getBeginLoc(); |
||
| 15793 | return false; |
||
| 15794 | } |
||
| 15795 | |||
| 15796 | bool acceptsLangOpts(const LangOptions &LangOpts) const override { |
||
| 15797 | return LangOpts.MicrosoftExt || LangOpts.Borland; |
||
| 15798 | } |
||
| 15799 | |||
| 15800 | bool isParamExpr(size_t N) const override { |
||
| 15801 | return false; |
||
| 15802 | } |
||
| 15803 | |||
| 15804 | static const ParsedAttrInfoUuid Instance; |
||
| 15805 | }; |
||
| 15806 | const ParsedAttrInfoUuid ParsedAttrInfoUuid::Instance; |
||
| 15807 | static constexpr ParsedAttrInfo::Spelling VecReturnSpellings[] = { |
||
| 15808 | {AttributeCommonInfo::AS_GNU, "vecreturn"}, |
||
| 15809 | {AttributeCommonInfo::AS_CXX11, "clang::vecreturn"}, |
||
| 15810 | }; |
||
| 15811 | struct ParsedAttrInfoVecReturn final : public ParsedAttrInfo { |
||
| 15812 | constexpr ParsedAttrInfoVecReturn() : ParsedAttrInfo( |
||
| 15813 | /*AttrKind=*/ParsedAttr::AT_VecReturn, |
||
| 15814 | /*NumArgs=*/0, |
||
| 15815 | /*OptArgs=*/0, |
||
| 15816 | /*NumArgMembers=*/0, |
||
| 15817 | /*HasCustomParsing=*/0, |
||
| 15818 | /*AcceptsExprPack=*/0, |
||
| 15819 | /*IsTargetSpecific=*/0, |
||
| 15820 | /*IsType=*/0, |
||
| 15821 | /*IsStmt=*/0, |
||
| 15822 | /*IsKnownToGCC=*/0, |
||
| 15823 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 15824 | /*Spellings=*/VecReturnSpellings, |
||
| 15825 | /*ArgNames=*/{}) {} |
||
| 15826 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 15827 | if (!isa<CXXRecordDecl>(D)) { |
||
| 15828 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 15829 | << Attr << "classes"; |
||
| 15830 | return false; |
||
| 15831 | } |
||
| 15832 | return true; |
||
| 15833 | } |
||
| 15834 | |||
| 15835 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 15836 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 15837 | << AL << St->getBeginLoc(); |
||
| 15838 | return false; |
||
| 15839 | } |
||
| 15840 | |||
| 15841 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 15842 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 15843 | } |
||
| 15844 | |||
| 15845 | bool isParamExpr(size_t N) const override { |
||
| 15846 | return false; |
||
| 15847 | } |
||
| 15848 | |||
| 15849 | static const ParsedAttrInfoVecReturn Instance; |
||
| 15850 | }; |
||
| 15851 | const ParsedAttrInfoVecReturn ParsedAttrInfoVecReturn::Instance; |
||
| 15852 | static constexpr ParsedAttrInfo::Spelling VecTypeHintSpellings[] = { |
||
| 15853 | {AttributeCommonInfo::AS_GNU, "vec_type_hint"}, |
||
| 15854 | }; |
||
| 15855 | static constexpr const char *VecTypeHintArgNames[] = { |
||
| 15856 | "TypeHint",}; |
||
| 15857 | struct ParsedAttrInfoVecTypeHint final : public ParsedAttrInfo { |
||
| 15858 | constexpr ParsedAttrInfoVecTypeHint() : ParsedAttrInfo( |
||
| 15859 | /*AttrKind=*/ParsedAttr::AT_VecTypeHint, |
||
| 15860 | /*NumArgs=*/1, |
||
| 15861 | /*OptArgs=*/0, |
||
| 15862 | /*NumArgMembers=*/1, |
||
| 15863 | /*HasCustomParsing=*/0, |
||
| 15864 | /*AcceptsExprPack=*/0, |
||
| 15865 | /*IsTargetSpecific=*/0, |
||
| 15866 | /*IsType=*/0, |
||
| 15867 | /*IsStmt=*/0, |
||
| 15868 | /*IsKnownToGCC=*/0, |
||
| 15869 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 15870 | /*Spellings=*/VecTypeHintSpellings, |
||
| 15871 | /*ArgNames=*/VecTypeHintArgNames) {} |
||
| 15872 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 15873 | if (!isa<FunctionDecl>(D)) { |
||
| 15874 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 15875 | << Attr << "functions"; |
||
| 15876 | return false; |
||
| 15877 | } |
||
| 15878 | return true; |
||
| 15879 | } |
||
| 15880 | |||
| 15881 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 15882 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 15883 | << AL << St->getBeginLoc(); |
||
| 15884 | return false; |
||
| 15885 | } |
||
| 15886 | |||
| 15887 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 15888 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 15889 | } |
||
| 15890 | |||
| 15891 | bool isParamExpr(size_t N) const override { |
||
| 15892 | return false; |
||
| 15893 | } |
||
| 15894 | |||
| 15895 | static const ParsedAttrInfoVecTypeHint Instance; |
||
| 15896 | }; |
||
| 15897 | const ParsedAttrInfoVecTypeHint ParsedAttrInfoVecTypeHint::Instance; |
||
| 15898 | static constexpr ParsedAttrInfo::Spelling VectorCallSpellings[] = { |
||
| 15899 | {AttributeCommonInfo::AS_GNU, "vectorcall"}, |
||
| 15900 | {AttributeCommonInfo::AS_CXX11, "clang::vectorcall"}, |
||
| 15901 | {AttributeCommonInfo::AS_C2x, "clang::vectorcall"}, |
||
| 15902 | {AttributeCommonInfo::AS_Keyword, "__vectorcall"}, |
||
| 15903 | {AttributeCommonInfo::AS_Keyword, "_vectorcall"}, |
||
| 15904 | }; |
||
| 15905 | struct ParsedAttrInfoVectorCall final : public ParsedAttrInfo { |
||
| 15906 | constexpr ParsedAttrInfoVectorCall() : ParsedAttrInfo( |
||
| 15907 | /*AttrKind=*/ParsedAttr::AT_VectorCall, |
||
| 15908 | /*NumArgs=*/0, |
||
| 15909 | /*OptArgs=*/0, |
||
| 15910 | /*NumArgMembers=*/0, |
||
| 15911 | /*HasCustomParsing=*/0, |
||
| 15912 | /*AcceptsExprPack=*/0, |
||
| 15913 | /*IsTargetSpecific=*/0, |
||
| 15914 | /*IsType=*/1, |
||
| 15915 | /*IsStmt=*/0, |
||
| 15916 | /*IsKnownToGCC=*/0, |
||
| 15917 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 15918 | /*Spellings=*/VectorCallSpellings, |
||
| 15919 | /*ArgNames=*/{}) {} |
||
| 15920 | bool isParamExpr(size_t N) const override { |
||
| 15921 | return false; |
||
| 15922 | } |
||
| 15923 | |||
| 15924 | static const ParsedAttrInfoVectorCall Instance; |
||
| 15925 | }; |
||
| 15926 | const ParsedAttrInfoVectorCall ParsedAttrInfoVectorCall::Instance; |
||
| 15927 | static constexpr ParsedAttrInfo::Spelling VectorSizeSpellings[] = { |
||
| 15928 | {AttributeCommonInfo::AS_GNU, "vector_size"}, |
||
| 15929 | {AttributeCommonInfo::AS_CXX11, "gnu::vector_size"}, |
||
| 15930 | {AttributeCommonInfo::AS_C2x, "gnu::vector_size"}, |
||
| 15931 | }; |
||
| 15932 | static constexpr const char *VectorSizeArgNames[] = { |
||
| 15933 | "NumBytes",}; |
||
| 15934 | struct ParsedAttrInfoVectorSize final : public ParsedAttrInfo { |
||
| 15935 | constexpr ParsedAttrInfoVectorSize() : ParsedAttrInfo( |
||
| 15936 | /*AttrKind=*/ParsedAttr::AT_VectorSize, |
||
| 15937 | /*NumArgs=*/1, |
||
| 15938 | /*OptArgs=*/0, |
||
| 15939 | /*NumArgMembers=*/1, |
||
| 15940 | /*HasCustomParsing=*/0, |
||
| 15941 | /*AcceptsExprPack=*/0, |
||
| 15942 | /*IsTargetSpecific=*/0, |
||
| 15943 | /*IsType=*/1, |
||
| 15944 | /*IsStmt=*/0, |
||
| 15945 | /*IsKnownToGCC=*/1, |
||
| 15946 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 15947 | /*Spellings=*/VectorSizeSpellings, |
||
| 15948 | /*ArgNames=*/VectorSizeArgNames) {} |
||
| 15949 | bool isParamExpr(size_t N) const override { |
||
| 15950 | return (N == 0) || false; |
||
| 15951 | } |
||
| 15952 | |||
| 15953 | static const ParsedAttrInfoVectorSize Instance; |
||
| 15954 | }; |
||
| 15955 | const ParsedAttrInfoVectorSize ParsedAttrInfoVectorSize::Instance; |
||
| 15956 | static constexpr ParsedAttrInfo::Spelling VisibilitySpellings[] = { |
||
| 15957 | {AttributeCommonInfo::AS_GNU, "visibility"}, |
||
| 15958 | {AttributeCommonInfo::AS_CXX11, "gnu::visibility"}, |
||
| 15959 | {AttributeCommonInfo::AS_C2x, "gnu::visibility"}, |
||
| 15960 | }; |
||
| 15961 | static constexpr const char *VisibilityArgNames[] = { |
||
| 15962 | "Visibility",}; |
||
| 15963 | struct ParsedAttrInfoVisibility final : public ParsedAttrInfo { |
||
| 15964 | constexpr ParsedAttrInfoVisibility() : ParsedAttrInfo( |
||
| 15965 | /*AttrKind=*/ParsedAttr::AT_Visibility, |
||
| 15966 | /*NumArgs=*/1, |
||
| 15967 | /*OptArgs=*/0, |
||
| 15968 | /*NumArgMembers=*/1, |
||
| 15969 | /*HasCustomParsing=*/0, |
||
| 15970 | /*AcceptsExprPack=*/0, |
||
| 15971 | /*IsTargetSpecific=*/0, |
||
| 15972 | /*IsType=*/0, |
||
| 15973 | /*IsStmt=*/0, |
||
| 15974 | /*IsKnownToGCC=*/1, |
||
| 15975 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 15976 | /*Spellings=*/VisibilitySpellings, |
||
| 15977 | /*ArgNames=*/VisibilityArgNames) {} |
||
| 15978 | bool isParamExpr(size_t N) const override { |
||
| 15979 | return false; |
||
| 15980 | } |
||
| 15981 | |||
| 15982 | static const ParsedAttrInfoVisibility Instance; |
||
| 15983 | }; |
||
| 15984 | const ParsedAttrInfoVisibility ParsedAttrInfoVisibility::Instance; |
||
| 15985 | static constexpr ParsedAttrInfo::Spelling WarnUnusedSpellings[] = { |
||
| 15986 | {AttributeCommonInfo::AS_GNU, "warn_unused"}, |
||
| 15987 | {AttributeCommonInfo::AS_CXX11, "gnu::warn_unused"}, |
||
| 15988 | {AttributeCommonInfo::AS_C2x, "gnu::warn_unused"}, |
||
| 15989 | }; |
||
| 15990 | struct ParsedAttrInfoWarnUnused final : public ParsedAttrInfo { |
||
| 15991 | constexpr ParsedAttrInfoWarnUnused() : ParsedAttrInfo( |
||
| 15992 | /*AttrKind=*/ParsedAttr::AT_WarnUnused, |
||
| 15993 | /*NumArgs=*/0, |
||
| 15994 | /*OptArgs=*/0, |
||
| 15995 | /*NumArgMembers=*/0, |
||
| 15996 | /*HasCustomParsing=*/0, |
||
| 15997 | /*AcceptsExprPack=*/0, |
||
| 15998 | /*IsTargetSpecific=*/0, |
||
| 15999 | /*IsType=*/0, |
||
| 16000 | /*IsStmt=*/0, |
||
| 16001 | /*IsKnownToGCC=*/1, |
||
| 16002 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 16003 | /*Spellings=*/WarnUnusedSpellings, |
||
| 16004 | /*ArgNames=*/{}) {} |
||
| 16005 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 16006 | if (!isa<RecordDecl>(D)) { |
||
| 16007 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 16008 | << Attr << "structs, unions, and classes"; |
||
| 16009 | return false; |
||
| 16010 | } |
||
| 16011 | return true; |
||
| 16012 | } |
||
| 16013 | |||
| 16014 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 16015 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 16016 | << AL << St->getBeginLoc(); |
||
| 16017 | return false; |
||
| 16018 | } |
||
| 16019 | |||
| 16020 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 16021 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 16022 | } |
||
| 16023 | |||
| 16024 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 16025 | D->addAttr(::new (S.Context) WarnUnusedAttr(S.Context, Attr)); |
||
| 16026 | return AttributeApplied; |
||
| 16027 | } |
||
| 16028 | |||
| 16029 | bool isParamExpr(size_t N) const override { |
||
| 16030 | return false; |
||
| 16031 | } |
||
| 16032 | |||
| 16033 | static const ParsedAttrInfoWarnUnused Instance; |
||
| 16034 | }; |
||
| 16035 | const ParsedAttrInfoWarnUnused ParsedAttrInfoWarnUnused::Instance; |
||
| 16036 | static constexpr ParsedAttrInfo::Spelling WarnUnusedResultSpellings[] = { |
||
| 16037 | {AttributeCommonInfo::AS_CXX11, "nodiscard"}, |
||
| 16038 | {AttributeCommonInfo::AS_C2x, "nodiscard"}, |
||
| 16039 | {AttributeCommonInfo::AS_CXX11, "clang::warn_unused_result"}, |
||
| 16040 | {AttributeCommonInfo::AS_GNU, "warn_unused_result"}, |
||
| 16041 | {AttributeCommonInfo::AS_CXX11, "gnu::warn_unused_result"}, |
||
| 16042 | {AttributeCommonInfo::AS_C2x, "gnu::warn_unused_result"}, |
||
| 16043 | }; |
||
| 16044 | static constexpr const char *WarnUnusedResultArgNames[] = { |
||
| 16045 | "Message",}; |
||
| 16046 | struct ParsedAttrInfoWarnUnusedResult final : public ParsedAttrInfo { |
||
| 16047 | constexpr ParsedAttrInfoWarnUnusedResult() : ParsedAttrInfo( |
||
| 16048 | /*AttrKind=*/ParsedAttr::AT_WarnUnusedResult, |
||
| 16049 | /*NumArgs=*/0, |
||
| 16050 | /*OptArgs=*/1, |
||
| 16051 | /*NumArgMembers=*/1, |
||
| 16052 | /*HasCustomParsing=*/0, |
||
| 16053 | /*AcceptsExprPack=*/0, |
||
| 16054 | /*IsTargetSpecific=*/0, |
||
| 16055 | /*IsType=*/0, |
||
| 16056 | /*IsStmt=*/0, |
||
| 16057 | /*IsKnownToGCC=*/1, |
||
| 16058 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 16059 | /*Spellings=*/WarnUnusedResultSpellings, |
||
| 16060 | /*ArgNames=*/WarnUnusedResultArgNames) {} |
||
| 16061 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 16062 | if (!isa<ObjCMethodDecl>(D) && !isa<EnumDecl>(D) && !isa<RecordDecl>(D) && !isFunctionLike(D) && !isa<TypedefNameDecl>(D)) { |
||
| 16063 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 16064 | << Attr << "Objective-C methods, enums, structs, unions, classes, functions, function pointers, and typedefs"; |
||
| 16065 | return false; |
||
| 16066 | } |
||
| 16067 | return true; |
||
| 16068 | } |
||
| 16069 | |||
| 16070 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 16071 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 16072 | << AL << St->getBeginLoc(); |
||
| 16073 | return false; |
||
| 16074 | } |
||
| 16075 | |||
| 16076 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 16077 | enum Spelling { |
||
| 16078 | CXX11_nodiscard = 0, |
||
| 16079 | C2x_nodiscard = 1, |
||
| 16080 | CXX11_clang_warn_unused_result = 2, |
||
| 16081 | GNU_warn_unused_result = 3, |
||
| 16082 | CXX11_gnu_warn_unused_result = 4, |
||
| 16083 | C2x_gnu_warn_unused_result = 5, |
||
| 16084 | SpellingNotCalculated = 15 |
||
| 16085 | |||
| 16086 | }; |
||
| 16087 | |||
| 16088 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 16089 | switch (Idx) { |
||
| 16090 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 16091 | case 0: return CXX11_nodiscard; |
||
| 16092 | case 1: return C2x_nodiscard; |
||
| 16093 | case 2: return CXX11_clang_warn_unused_result; |
||
| 16094 | case 3: return GNU_warn_unused_result; |
||
| 16095 | case 4: return CXX11_gnu_warn_unused_result; |
||
| 16096 | case 5: return C2x_gnu_warn_unused_result; |
||
| 16097 | } |
||
| 16098 | } |
||
| 16099 | |||
| 16100 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 16101 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 16102 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_enum, /*IsSupported=*/true)); |
||
| 16103 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 16104 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_hasType_functionType, /*IsSupported=*/true)); |
||
| 16105 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_type_alias, /*IsSupported=*/true)); |
||
| 16106 | } |
||
| 16107 | |||
| 16108 | bool isParamExpr(size_t N) const override { |
||
| 16109 | return false; |
||
| 16110 | } |
||
| 16111 | |||
| 16112 | static const ParsedAttrInfoWarnUnusedResult Instance; |
||
| 16113 | }; |
||
| 16114 | const ParsedAttrInfoWarnUnusedResult ParsedAttrInfoWarnUnusedResult::Instance; |
||
| 16115 | static constexpr ParsedAttrInfo::Spelling WeakSpellings[] = { |
||
| 16116 | {AttributeCommonInfo::AS_GNU, "weak"}, |
||
| 16117 | {AttributeCommonInfo::AS_CXX11, "gnu::weak"}, |
||
| 16118 | {AttributeCommonInfo::AS_C2x, "gnu::weak"}, |
||
| 16119 | }; |
||
| 16120 | struct ParsedAttrInfoWeak final : public ParsedAttrInfo { |
||
| 16121 | constexpr ParsedAttrInfoWeak() : ParsedAttrInfo( |
||
| 16122 | /*AttrKind=*/ParsedAttr::AT_Weak, |
||
| 16123 | /*NumArgs=*/0, |
||
| 16124 | /*OptArgs=*/0, |
||
| 16125 | /*NumArgMembers=*/0, |
||
| 16126 | /*HasCustomParsing=*/0, |
||
| 16127 | /*AcceptsExprPack=*/0, |
||
| 16128 | /*IsTargetSpecific=*/0, |
||
| 16129 | /*IsType=*/0, |
||
| 16130 | /*IsStmt=*/0, |
||
| 16131 | /*IsKnownToGCC=*/1, |
||
| 16132 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 16133 | /*Spellings=*/WeakSpellings, |
||
| 16134 | /*ArgNames=*/{}) {} |
||
| 16135 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 16136 | if (!isa<VarDecl>(D) && !isa<FunctionDecl>(D) && !isa<CXXRecordDecl>(D)) { |
||
| 16137 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 16138 | << Attr << "variables, functions, and classes"; |
||
| 16139 | return false; |
||
| 16140 | } |
||
| 16141 | return true; |
||
| 16142 | } |
||
| 16143 | |||
| 16144 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 16145 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 16146 | << AL << St->getBeginLoc(); |
||
| 16147 | return false; |
||
| 16148 | } |
||
| 16149 | |||
| 16150 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 16151 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
||
| 16152 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 16153 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_record, /*IsSupported=*/true)); |
||
| 16154 | } |
||
| 16155 | |||
| 16156 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 16157 | D->addAttr(::new (S.Context) WeakAttr(S.Context, Attr)); |
||
| 16158 | return AttributeApplied; |
||
| 16159 | } |
||
| 16160 | |||
| 16161 | bool isParamExpr(size_t N) const override { |
||
| 16162 | return false; |
||
| 16163 | } |
||
| 16164 | |||
| 16165 | static const ParsedAttrInfoWeak Instance; |
||
| 16166 | }; |
||
| 16167 | const ParsedAttrInfoWeak ParsedAttrInfoWeak::Instance; |
||
| 16168 | static constexpr ParsedAttrInfo::Spelling WeakImportSpellings[] = { |
||
| 16169 | {AttributeCommonInfo::AS_GNU, "weak_import"}, |
||
| 16170 | {AttributeCommonInfo::AS_CXX11, "clang::weak_import"}, |
||
| 16171 | {AttributeCommonInfo::AS_C2x, "clang::weak_import"}, |
||
| 16172 | }; |
||
| 16173 | struct ParsedAttrInfoWeakImport final : public ParsedAttrInfo { |
||
| 16174 | constexpr ParsedAttrInfoWeakImport() : ParsedAttrInfo( |
||
| 16175 | /*AttrKind=*/ParsedAttr::AT_WeakImport, |
||
| 16176 | /*NumArgs=*/0, |
||
| 16177 | /*OptArgs=*/0, |
||
| 16178 | /*NumArgMembers=*/0, |
||
| 16179 | /*HasCustomParsing=*/0, |
||
| 16180 | /*AcceptsExprPack=*/0, |
||
| 16181 | /*IsTargetSpecific=*/0, |
||
| 16182 | /*IsType=*/0, |
||
| 16183 | /*IsStmt=*/0, |
||
| 16184 | /*IsKnownToGCC=*/0, |
||
| 16185 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 16186 | /*Spellings=*/WeakImportSpellings, |
||
| 16187 | /*ArgNames=*/{}) {} |
||
| 16188 | bool isParamExpr(size_t N) const override { |
||
| 16189 | return false; |
||
| 16190 | } |
||
| 16191 | |||
| 16192 | static const ParsedAttrInfoWeakImport Instance; |
||
| 16193 | }; |
||
| 16194 | const ParsedAttrInfoWeakImport ParsedAttrInfoWeakImport::Instance; |
||
| 16195 | static constexpr ParsedAttrInfo::Spelling WeakRefSpellings[] = { |
||
| 16196 | {AttributeCommonInfo::AS_GNU, "weakref"}, |
||
| 16197 | {AttributeCommonInfo::AS_CXX11, "gnu::weakref"}, |
||
| 16198 | {AttributeCommonInfo::AS_C2x, "gnu::weakref"}, |
||
| 16199 | }; |
||
| 16200 | static constexpr const char *WeakRefArgNames[] = { |
||
| 16201 | "Aliasee",}; |
||
| 16202 | struct ParsedAttrInfoWeakRef final : public ParsedAttrInfo { |
||
| 16203 | constexpr ParsedAttrInfoWeakRef() : ParsedAttrInfo( |
||
| 16204 | /*AttrKind=*/ParsedAttr::AT_WeakRef, |
||
| 16205 | /*NumArgs=*/0, |
||
| 16206 | /*OptArgs=*/1, |
||
| 16207 | /*NumArgMembers=*/1, |
||
| 16208 | /*HasCustomParsing=*/0, |
||
| 16209 | /*AcceptsExprPack=*/0, |
||
| 16210 | /*IsTargetSpecific=*/0, |
||
| 16211 | /*IsType=*/0, |
||
| 16212 | /*IsStmt=*/0, |
||
| 16213 | /*IsKnownToGCC=*/1, |
||
| 16214 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 16215 | /*Spellings=*/WeakRefSpellings, |
||
| 16216 | /*ArgNames=*/WeakRefArgNames) {} |
||
| 16217 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 16218 | if (!isa<VarDecl>(D) && !isa<FunctionDecl>(D)) { |
||
| 16219 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 16220 | << Attr << "variables and functions"; |
||
| 16221 | return false; |
||
| 16222 | } |
||
| 16223 | return true; |
||
| 16224 | } |
||
| 16225 | |||
| 16226 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 16227 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 16228 | << AL << St->getBeginLoc(); |
||
| 16229 | return false; |
||
| 16230 | } |
||
| 16231 | |||
| 16232 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 16233 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_variable, /*IsSupported=*/true)); |
||
| 16234 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 16235 | } |
||
| 16236 | |||
| 16237 | bool isParamExpr(size_t N) const override { |
||
| 16238 | return false; |
||
| 16239 | } |
||
| 16240 | |||
| 16241 | static const ParsedAttrInfoWeakRef Instance; |
||
| 16242 | }; |
||
| 16243 | const ParsedAttrInfoWeakRef ParsedAttrInfoWeakRef::Instance; |
||
| 16244 | static constexpr ParsedAttrInfo::Spelling WebAssemblyExportNameSpellings[] = { |
||
| 16245 | {AttributeCommonInfo::AS_GNU, "export_name"}, |
||
| 16246 | {AttributeCommonInfo::AS_CXX11, "clang::export_name"}, |
||
| 16247 | {AttributeCommonInfo::AS_C2x, "clang::export_name"}, |
||
| 16248 | }; |
||
| 16249 | static constexpr const char *WebAssemblyExportNameArgNames[] = { |
||
| 16250 | "ExportName",}; |
||
| 16251 | struct ParsedAttrInfoWebAssemblyExportName final : public ParsedAttrInfo { |
||
| 16252 | constexpr ParsedAttrInfoWebAssemblyExportName() : ParsedAttrInfo( |
||
| 16253 | /*AttrKind=*/ParsedAttr::AT_WebAssemblyExportName, |
||
| 16254 | /*NumArgs=*/1, |
||
| 16255 | /*OptArgs=*/0, |
||
| 16256 | /*NumArgMembers=*/1, |
||
| 16257 | /*HasCustomParsing=*/0, |
||
| 16258 | /*AcceptsExprPack=*/0, |
||
| 16259 | /*IsTargetSpecific=*/1, |
||
| 16260 | /*IsType=*/0, |
||
| 16261 | /*IsStmt=*/0, |
||
| 16262 | /*IsKnownToGCC=*/0, |
||
| 16263 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 16264 | /*Spellings=*/WebAssemblyExportNameSpellings, |
||
| 16265 | /*ArgNames=*/WebAssemblyExportNameArgNames) {} |
||
| 16266 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 16267 | if (!isa<FunctionDecl>(D)) { |
||
| 16268 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 16269 | << Attr << "functions"; |
||
| 16270 | return false; |
||
| 16271 | } |
||
| 16272 | return true; |
||
| 16273 | } |
||
| 16274 | |||
| 16275 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 16276 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 16277 | << AL << St->getBeginLoc(); |
||
| 16278 | return false; |
||
| 16279 | } |
||
| 16280 | |||
| 16281 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 16282 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 16283 | return true && (T.getArch() == llvm::Triple::wasm32 || T.getArch() == llvm::Triple::wasm64); |
||
| 16284 | } |
||
| 16285 | |||
| 16286 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 16287 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 16288 | } |
||
| 16289 | |||
| 16290 | bool isParamExpr(size_t N) const override { |
||
| 16291 | return false; |
||
| 16292 | } |
||
| 16293 | |||
| 16294 | static const ParsedAttrInfoWebAssemblyExportName Instance; |
||
| 16295 | }; |
||
| 16296 | const ParsedAttrInfoWebAssemblyExportName ParsedAttrInfoWebAssemblyExportName::Instance; |
||
| 16297 | static constexpr ParsedAttrInfo::Spelling WebAssemblyImportModuleSpellings[] = { |
||
| 16298 | {AttributeCommonInfo::AS_GNU, "import_module"}, |
||
| 16299 | {AttributeCommonInfo::AS_CXX11, "clang::import_module"}, |
||
| 16300 | {AttributeCommonInfo::AS_C2x, "clang::import_module"}, |
||
| 16301 | }; |
||
| 16302 | static constexpr const char *WebAssemblyImportModuleArgNames[] = { |
||
| 16303 | "ImportModule",}; |
||
| 16304 | struct ParsedAttrInfoWebAssemblyImportModule final : public ParsedAttrInfo { |
||
| 16305 | constexpr ParsedAttrInfoWebAssemblyImportModule() : ParsedAttrInfo( |
||
| 16306 | /*AttrKind=*/ParsedAttr::AT_WebAssemblyImportModule, |
||
| 16307 | /*NumArgs=*/1, |
||
| 16308 | /*OptArgs=*/0, |
||
| 16309 | /*NumArgMembers=*/1, |
||
| 16310 | /*HasCustomParsing=*/0, |
||
| 16311 | /*AcceptsExprPack=*/0, |
||
| 16312 | /*IsTargetSpecific=*/1, |
||
| 16313 | /*IsType=*/0, |
||
| 16314 | /*IsStmt=*/0, |
||
| 16315 | /*IsKnownToGCC=*/0, |
||
| 16316 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 16317 | /*Spellings=*/WebAssemblyImportModuleSpellings, |
||
| 16318 | /*ArgNames=*/WebAssemblyImportModuleArgNames) {} |
||
| 16319 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 16320 | if (!isa<FunctionDecl>(D)) { |
||
| 16321 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 16322 | << Attr << "functions"; |
||
| 16323 | return false; |
||
| 16324 | } |
||
| 16325 | return true; |
||
| 16326 | } |
||
| 16327 | |||
| 16328 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 16329 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 16330 | << AL << St->getBeginLoc(); |
||
| 16331 | return false; |
||
| 16332 | } |
||
| 16333 | |||
| 16334 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 16335 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 16336 | return true && (T.getArch() == llvm::Triple::wasm32 || T.getArch() == llvm::Triple::wasm64); |
||
| 16337 | } |
||
| 16338 | |||
| 16339 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 16340 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 16341 | } |
||
| 16342 | |||
| 16343 | bool isParamExpr(size_t N) const override { |
||
| 16344 | return false; |
||
| 16345 | } |
||
| 16346 | |||
| 16347 | static const ParsedAttrInfoWebAssemblyImportModule Instance; |
||
| 16348 | }; |
||
| 16349 | const ParsedAttrInfoWebAssemblyImportModule ParsedAttrInfoWebAssemblyImportModule::Instance; |
||
| 16350 | static constexpr ParsedAttrInfo::Spelling WebAssemblyImportNameSpellings[] = { |
||
| 16351 | {AttributeCommonInfo::AS_GNU, "import_name"}, |
||
| 16352 | {AttributeCommonInfo::AS_CXX11, "clang::import_name"}, |
||
| 16353 | {AttributeCommonInfo::AS_C2x, "clang::import_name"}, |
||
| 16354 | }; |
||
| 16355 | static constexpr const char *WebAssemblyImportNameArgNames[] = { |
||
| 16356 | "ImportName",}; |
||
| 16357 | struct ParsedAttrInfoWebAssemblyImportName final : public ParsedAttrInfo { |
||
| 16358 | constexpr ParsedAttrInfoWebAssemblyImportName() : ParsedAttrInfo( |
||
| 16359 | /*AttrKind=*/ParsedAttr::AT_WebAssemblyImportName, |
||
| 16360 | /*NumArgs=*/1, |
||
| 16361 | /*OptArgs=*/0, |
||
| 16362 | /*NumArgMembers=*/1, |
||
| 16363 | /*HasCustomParsing=*/0, |
||
| 16364 | /*AcceptsExprPack=*/0, |
||
| 16365 | /*IsTargetSpecific=*/1, |
||
| 16366 | /*IsType=*/0, |
||
| 16367 | /*IsStmt=*/0, |
||
| 16368 | /*IsKnownToGCC=*/0, |
||
| 16369 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 16370 | /*Spellings=*/WebAssemblyImportNameSpellings, |
||
| 16371 | /*ArgNames=*/WebAssemblyImportNameArgNames) {} |
||
| 16372 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 16373 | if (!isa<FunctionDecl>(D)) { |
||
| 16374 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 16375 | << Attr << "functions"; |
||
| 16376 | return false; |
||
| 16377 | } |
||
| 16378 | return true; |
||
| 16379 | } |
||
| 16380 | |||
| 16381 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 16382 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 16383 | << AL << St->getBeginLoc(); |
||
| 16384 | return false; |
||
| 16385 | } |
||
| 16386 | |||
| 16387 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 16388 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 16389 | return true && (T.getArch() == llvm::Triple::wasm32 || T.getArch() == llvm::Triple::wasm64); |
||
| 16390 | } |
||
| 16391 | |||
| 16392 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 16393 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 16394 | } |
||
| 16395 | |||
| 16396 | bool isParamExpr(size_t N) const override { |
||
| 16397 | return false; |
||
| 16398 | } |
||
| 16399 | |||
| 16400 | static const ParsedAttrInfoWebAssemblyImportName Instance; |
||
| 16401 | }; |
||
| 16402 | const ParsedAttrInfoWebAssemblyImportName ParsedAttrInfoWebAssemblyImportName::Instance; |
||
| 16403 | static constexpr ParsedAttrInfo::Spelling WorkGroupSizeHintSpellings[] = { |
||
| 16404 | {AttributeCommonInfo::AS_GNU, "work_group_size_hint"}, |
||
| 16405 | }; |
||
| 16406 | static constexpr const char *WorkGroupSizeHintArgNames[] = { |
||
| 16407 | "XDim","YDim","ZDim",}; |
||
| 16408 | struct ParsedAttrInfoWorkGroupSizeHint final : public ParsedAttrInfo { |
||
| 16409 | constexpr ParsedAttrInfoWorkGroupSizeHint() : ParsedAttrInfo( |
||
| 16410 | /*AttrKind=*/ParsedAttr::AT_WorkGroupSizeHint, |
||
| 16411 | /*NumArgs=*/3, |
||
| 16412 | /*OptArgs=*/0, |
||
| 16413 | /*NumArgMembers=*/3, |
||
| 16414 | /*HasCustomParsing=*/0, |
||
| 16415 | /*AcceptsExprPack=*/0, |
||
| 16416 | /*IsTargetSpecific=*/0, |
||
| 16417 | /*IsType=*/0, |
||
| 16418 | /*IsStmt=*/0, |
||
| 16419 | /*IsKnownToGCC=*/0, |
||
| 16420 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 16421 | /*Spellings=*/WorkGroupSizeHintSpellings, |
||
| 16422 | /*ArgNames=*/WorkGroupSizeHintArgNames) {} |
||
| 16423 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 16424 | if (!isa<FunctionDecl>(D)) { |
||
| 16425 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 16426 | << Attr << "functions"; |
||
| 16427 | return false; |
||
| 16428 | } |
||
| 16429 | return true; |
||
| 16430 | } |
||
| 16431 | |||
| 16432 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 16433 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 16434 | << AL << St->getBeginLoc(); |
||
| 16435 | return false; |
||
| 16436 | } |
||
| 16437 | |||
| 16438 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 16439 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 16440 | } |
||
| 16441 | |||
| 16442 | bool isParamExpr(size_t N) const override { |
||
| 16443 | return false; |
||
| 16444 | } |
||
| 16445 | |||
| 16446 | static const ParsedAttrInfoWorkGroupSizeHint Instance; |
||
| 16447 | }; |
||
| 16448 | const ParsedAttrInfoWorkGroupSizeHint ParsedAttrInfoWorkGroupSizeHint::Instance; |
||
| 16449 | static constexpr ParsedAttrInfo::Spelling X86ForceAlignArgPointerSpellings[] = { |
||
| 16450 | {AttributeCommonInfo::AS_GNU, "force_align_arg_pointer"}, |
||
| 16451 | {AttributeCommonInfo::AS_CXX11, "gnu::force_align_arg_pointer"}, |
||
| 16452 | {AttributeCommonInfo::AS_C2x, "gnu::force_align_arg_pointer"}, |
||
| 16453 | }; |
||
| 16454 | struct ParsedAttrInfoX86ForceAlignArgPointer final : public ParsedAttrInfo { |
||
| 16455 | constexpr ParsedAttrInfoX86ForceAlignArgPointer() : ParsedAttrInfo( |
||
| 16456 | /*AttrKind=*/ParsedAttr::AT_X86ForceAlignArgPointer, |
||
| 16457 | /*NumArgs=*/0, |
||
| 16458 | /*OptArgs=*/0, |
||
| 16459 | /*NumArgMembers=*/0, |
||
| 16460 | /*HasCustomParsing=*/0, |
||
| 16461 | /*AcceptsExprPack=*/0, |
||
| 16462 | /*IsTargetSpecific=*/1, |
||
| 16463 | /*IsType=*/0, |
||
| 16464 | /*IsStmt=*/0, |
||
| 16465 | /*IsKnownToGCC=*/1, |
||
| 16466 | /*IsSupportedByPragmaAttribute=*/0, |
||
| 16467 | /*Spellings=*/X86ForceAlignArgPointerSpellings, |
||
| 16468 | /*ArgNames=*/{}) {} |
||
| 16469 | bool existsInTarget(const TargetInfo &Target) const override { |
||
| 16470 | const llvm::Triple &T = Target.getTriple(); (void)T; |
||
| 16471 | return true && (T.getArch() == llvm::Triple::x86 || T.getArch() == llvm::Triple::x86_64); |
||
| 16472 | } |
||
| 16473 | |||
| 16474 | bool isParamExpr(size_t N) const override { |
||
| 16475 | return false; |
||
| 16476 | } |
||
| 16477 | |||
| 16478 | static const ParsedAttrInfoX86ForceAlignArgPointer Instance; |
||
| 16479 | }; |
||
| 16480 | const ParsedAttrInfoX86ForceAlignArgPointer ParsedAttrInfoX86ForceAlignArgPointer::Instance; |
||
| 16481 | static constexpr ParsedAttrInfo::Spelling XRayInstrumentSpellings[] = { |
||
| 16482 | {AttributeCommonInfo::AS_GNU, "xray_always_instrument"}, |
||
| 16483 | {AttributeCommonInfo::AS_CXX11, "clang::xray_always_instrument"}, |
||
| 16484 | {AttributeCommonInfo::AS_C2x, "clang::xray_always_instrument"}, |
||
| 16485 | {AttributeCommonInfo::AS_GNU, "xray_never_instrument"}, |
||
| 16486 | {AttributeCommonInfo::AS_CXX11, "clang::xray_never_instrument"}, |
||
| 16487 | {AttributeCommonInfo::AS_C2x, "clang::xray_never_instrument"}, |
||
| 16488 | }; |
||
| 16489 | struct ParsedAttrInfoXRayInstrument final : public ParsedAttrInfo { |
||
| 16490 | constexpr ParsedAttrInfoXRayInstrument() : ParsedAttrInfo( |
||
| 16491 | /*AttrKind=*/ParsedAttr::AT_XRayInstrument, |
||
| 16492 | /*NumArgs=*/0, |
||
| 16493 | /*OptArgs=*/0, |
||
| 16494 | /*NumArgMembers=*/0, |
||
| 16495 | /*HasCustomParsing=*/0, |
||
| 16496 | /*AcceptsExprPack=*/0, |
||
| 16497 | /*IsTargetSpecific=*/0, |
||
| 16498 | /*IsType=*/0, |
||
| 16499 | /*IsStmt=*/0, |
||
| 16500 | /*IsKnownToGCC=*/0, |
||
| 16501 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 16502 | /*Spellings=*/XRayInstrumentSpellings, |
||
| 16503 | /*ArgNames=*/{}) {} |
||
| 16504 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 16505 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
||
| 16506 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 16507 | << Attr << "functions and Objective-C methods"; |
||
| 16508 | return false; |
||
| 16509 | } |
||
| 16510 | return true; |
||
| 16511 | } |
||
| 16512 | |||
| 16513 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 16514 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 16515 | << AL << St->getBeginLoc(); |
||
| 16516 | return false; |
||
| 16517 | } |
||
| 16518 | |||
| 16519 | unsigned spellingIndexToSemanticSpelling(const ParsedAttr &Attr) const override { |
||
| 16520 | enum Spelling { |
||
| 16521 | GNU_xray_always_instrument = 0, |
||
| 16522 | CXX11_clang_xray_always_instrument = 1, |
||
| 16523 | C2x_clang_xray_always_instrument = 2, |
||
| 16524 | GNU_xray_never_instrument = 3, |
||
| 16525 | CXX11_clang_xray_never_instrument = 4, |
||
| 16526 | C2x_clang_xray_never_instrument = 5, |
||
| 16527 | SpellingNotCalculated = 15 |
||
| 16528 | |||
| 16529 | }; |
||
| 16530 | |||
| 16531 | unsigned Idx = Attr.getAttributeSpellingListIndex(); |
||
| 16532 | switch (Idx) { |
||
| 16533 | default: llvm_unreachable("Unknown spelling list index"); |
||
| 16534 | case 0: return GNU_xray_always_instrument; |
||
| 16535 | case 1: return CXX11_clang_xray_always_instrument; |
||
| 16536 | case 2: return C2x_clang_xray_always_instrument; |
||
| 16537 | case 3: return GNU_xray_never_instrument; |
||
| 16538 | case 4: return CXX11_clang_xray_never_instrument; |
||
| 16539 | case 5: return C2x_clang_xray_never_instrument; |
||
| 16540 | } |
||
| 16541 | } |
||
| 16542 | |||
| 16543 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 16544 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 16545 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 16546 | } |
||
| 16547 | |||
| 16548 | AttrHandling handleDeclAttribute(Sema &S, Decl *D,const ParsedAttr &Attr) const override { |
||
| 16549 | D->addAttr(::new (S.Context) XRayInstrumentAttr(S.Context, Attr)); |
||
| 16550 | return AttributeApplied; |
||
| 16551 | } |
||
| 16552 | |||
| 16553 | bool isParamExpr(size_t N) const override { |
||
| 16554 | return false; |
||
| 16555 | } |
||
| 16556 | |||
| 16557 | static const ParsedAttrInfoXRayInstrument Instance; |
||
| 16558 | }; |
||
| 16559 | const ParsedAttrInfoXRayInstrument ParsedAttrInfoXRayInstrument::Instance; |
||
| 16560 | static constexpr ParsedAttrInfo::Spelling XRayLogArgsSpellings[] = { |
||
| 16561 | {AttributeCommonInfo::AS_GNU, "xray_log_args"}, |
||
| 16562 | {AttributeCommonInfo::AS_CXX11, "clang::xray_log_args"}, |
||
| 16563 | {AttributeCommonInfo::AS_C2x, "clang::xray_log_args"}, |
||
| 16564 | }; |
||
| 16565 | static constexpr const char *XRayLogArgsArgNames[] = { |
||
| 16566 | "ArgumentCount",}; |
||
| 16567 | struct ParsedAttrInfoXRayLogArgs final : public ParsedAttrInfo { |
||
| 16568 | constexpr ParsedAttrInfoXRayLogArgs() : ParsedAttrInfo( |
||
| 16569 | /*AttrKind=*/ParsedAttr::AT_XRayLogArgs, |
||
| 16570 | /*NumArgs=*/1, |
||
| 16571 | /*OptArgs=*/0, |
||
| 16572 | /*NumArgMembers=*/1, |
||
| 16573 | /*HasCustomParsing=*/0, |
||
| 16574 | /*AcceptsExprPack=*/0, |
||
| 16575 | /*IsTargetSpecific=*/0, |
||
| 16576 | /*IsType=*/0, |
||
| 16577 | /*IsStmt=*/0, |
||
| 16578 | /*IsKnownToGCC=*/0, |
||
| 16579 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 16580 | /*Spellings=*/XRayLogArgsSpellings, |
||
| 16581 | /*ArgNames=*/XRayLogArgsArgNames) {} |
||
| 16582 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 16583 | if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) { |
||
| 16584 | S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str) |
||
| 16585 | << Attr << "functions and Objective-C methods"; |
||
| 16586 | return false; |
||
| 16587 | } |
||
| 16588 | return true; |
||
| 16589 | } |
||
| 16590 | |||
| 16591 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 16592 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 16593 | << AL << St->getBeginLoc(); |
||
| 16594 | return false; |
||
| 16595 | } |
||
| 16596 | |||
| 16597 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 16598 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 16599 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_objc_method, /*IsSupported=*/LangOpts.ObjC)); |
||
| 16600 | } |
||
| 16601 | |||
| 16602 | bool isParamExpr(size_t N) const override { |
||
| 16603 | return false; |
||
| 16604 | } |
||
| 16605 | |||
| 16606 | static const ParsedAttrInfoXRayLogArgs Instance; |
||
| 16607 | }; |
||
| 16608 | const ParsedAttrInfoXRayLogArgs ParsedAttrInfoXRayLogArgs::Instance; |
||
| 16609 | static constexpr ParsedAttrInfo::Spelling ZeroCallUsedRegsSpellings[] = { |
||
| 16610 | {AttributeCommonInfo::AS_GNU, "zero_call_used_regs"}, |
||
| 16611 | {AttributeCommonInfo::AS_CXX11, "gnu::zero_call_used_regs"}, |
||
| 16612 | {AttributeCommonInfo::AS_C2x, "gnu::zero_call_used_regs"}, |
||
| 16613 | }; |
||
| 16614 | static constexpr const char *ZeroCallUsedRegsArgNames[] = { |
||
| 16615 | "ZeroCallUsedRegs",}; |
||
| 16616 | struct ParsedAttrInfoZeroCallUsedRegs final : public ParsedAttrInfo { |
||
| 16617 | constexpr ParsedAttrInfoZeroCallUsedRegs() : ParsedAttrInfo( |
||
| 16618 | /*AttrKind=*/ParsedAttr::AT_ZeroCallUsedRegs, |
||
| 16619 | /*NumArgs=*/1, |
||
| 16620 | /*OptArgs=*/0, |
||
| 16621 | /*NumArgMembers=*/1, |
||
| 16622 | /*HasCustomParsing=*/0, |
||
| 16623 | /*AcceptsExprPack=*/0, |
||
| 16624 | /*IsTargetSpecific=*/0, |
||
| 16625 | /*IsType=*/0, |
||
| 16626 | /*IsStmt=*/0, |
||
| 16627 | /*IsKnownToGCC=*/1, |
||
| 16628 | /*IsSupportedByPragmaAttribute=*/1, |
||
| 16629 | /*Spellings=*/ZeroCallUsedRegsSpellings, |
||
| 16630 | /*ArgNames=*/ZeroCallUsedRegsArgNames) {} |
||
| 16631 | bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override { |
||
| 16632 | if (!isa<FunctionDecl>(D)) { |
||
| 16633 | S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type_str) |
||
| 16634 | << Attr << "functions"; |
||
| 16635 | return false; |
||
| 16636 | } |
||
| 16637 | return true; |
||
| 16638 | } |
||
| 16639 | |||
| 16640 | bool diagAppertainsToStmt(Sema &S, const ParsedAttr &AL, const Stmt *St) const override { |
||
| 16641 | S.Diag(AL.getLoc(), diag::err_decl_attribute_invalid_on_stmt) |
||
| 16642 | << AL << St->getBeginLoc(); |
||
| 16643 | return false; |
||
| 16644 | } |
||
| 16645 | |||
| 16646 | void getPragmaAttributeMatchRules(llvm::SmallVectorImpl<std::pair<attr::SubjectMatchRule, bool>> &MatchRules, const LangOptions &LangOpts) const override { |
||
| 16647 | MatchRules.push_back(std::make_pair(attr::SubjectMatchRule_function, /*IsSupported=*/true)); |
||
| 16648 | } |
||
| 16649 | |||
| 16650 | bool isParamExpr(size_t N) const override { |
||
| 16651 | return false; |
||
| 16652 | } |
||
| 16653 | |||
| 16654 | static const ParsedAttrInfoZeroCallUsedRegs Instance; |
||
| 16655 | }; |
||
| 16656 | const ParsedAttrInfoZeroCallUsedRegs ParsedAttrInfoZeroCallUsedRegs::Instance; |
||
| 16657 | static const ParsedAttrInfo *AttrInfoMap[] = { |
||
| 16658 | &ParsedAttrInfoAArch64SVEPcs::Instance, |
||
| 16659 | &ParsedAttrInfoAArch64VectorPcs::Instance, |
||
| 16660 | &ParsedAttrInfoAMDGPUFlatWorkGroupSize::Instance, |
||
| 16661 | &ParsedAttrInfoAMDGPUKernelCall::Instance, |
||
| 16662 | &ParsedAttrInfoAMDGPUNumSGPR::Instance, |
||
| 16663 | &ParsedAttrInfoAMDGPUNumVGPR::Instance, |
||
| 16664 | &ParsedAttrInfoAMDGPUWavesPerEU::Instance, |
||
| 16665 | &ParsedAttrInfoInterrupt::Instance, |
||
| 16666 | &ParsedAttrInfoAVRSignal::Instance, |
||
| 16667 | &ParsedAttrInfoAbiTag::Instance, |
||
| 16668 | &ParsedAttrInfoAcquireCapability::Instance, |
||
| 16669 | &ParsedAttrInfoAcquireHandle::Instance, |
||
| 16670 | &ParsedAttrInfoAcquiredAfter::Instance, |
||
| 16671 | &ParsedAttrInfoAcquiredBefore::Instance, |
||
| 16672 | &ParsedAttrInfoAddressSpace::Instance, |
||
| 16673 | &ParsedAttrInfoAlias::Instance, |
||
| 16674 | &ParsedAttrInfoAlignValue::Instance, |
||
| 16675 | &ParsedAttrInfoAligned::Instance, |
||
| 16676 | &ParsedAttrInfoAllocAlign::Instance, |
||
| 16677 | &ParsedAttrInfoAllocSize::Instance, |
||
| 16678 | &ParsedAttrInfoAlwaysDestroy::Instance, |
||
| 16679 | &ParsedAttrInfoAlwaysInline::Instance, |
||
| 16680 | &ParsedAttrInfoAnalyzerNoReturn::Instance, |
||
| 16681 | &ParsedAttrInfoAnnotate::Instance, |
||
| 16682 | &ParsedAttrInfoAnnotateType::Instance, |
||
| 16683 | &ParsedAttrInfoAnyX86NoCallerSavedRegisters::Instance, |
||
| 16684 | &ParsedAttrInfoAnyX86NoCfCheck::Instance, |
||
| 16685 | &ParsedAttrInfoArcWeakrefUnavailable::Instance, |
||
| 16686 | &ParsedAttrInfoArgumentWithTypeTag::Instance, |
||
| 16687 | &ParsedAttrInfoArmBuiltinAlias::Instance, |
||
| 16688 | &ParsedAttrInfoArmMveStrictPolymorphism::Instance, |
||
| 16689 | &ParsedAttrInfoArmSveVectorBits::Instance, |
||
| 16690 | &ParsedAttrInfoArtificial::Instance, |
||
| 16691 | &ParsedAttrInfoAssertCapability::Instance, |
||
| 16692 | &ParsedAttrInfoAssertExclusiveLock::Instance, |
||
| 16693 | &ParsedAttrInfoAssertSharedLock::Instance, |
||
| 16694 | &ParsedAttrInfoAssumeAligned::Instance, |
||
| 16695 | &ParsedAttrInfoAssumption::Instance, |
||
| 16696 | &ParsedAttrInfoAvailability::Instance, |
||
| 16697 | &ParsedAttrInfoBPFPreserveAccessIndex::Instance, |
||
| 16698 | &ParsedAttrInfoBTFDeclTag::Instance, |
||
| 16699 | &ParsedAttrInfoBTFTypeTag::Instance, |
||
| 16700 | &ParsedAttrInfoBlocks::Instance, |
||
| 16701 | &ParsedAttrInfoBuiltinAlias::Instance, |
||
| 16702 | &ParsedAttrInfoCDecl::Instance, |
||
| 16703 | &ParsedAttrInfoCFAuditedTransfer::Instance, |
||
| 16704 | &ParsedAttrInfoCFConsumed::Instance, |
||
| 16705 | &ParsedAttrInfoCFGuard::Instance, |
||
| 16706 | &ParsedAttrInfoCFICanonicalJumpTable::Instance, |
||
| 16707 | &ParsedAttrInfoCFReturnsNotRetained::Instance, |
||
| 16708 | &ParsedAttrInfoCFReturnsRetained::Instance, |
||
| 16709 | &ParsedAttrInfoCFUnknownTransfer::Instance, |
||
| 16710 | &ParsedAttrInfoCPUDispatch::Instance, |
||
| 16711 | &ParsedAttrInfoCPUSpecific::Instance, |
||
| 16712 | &ParsedAttrInfoCUDAConstant::Instance, |
||
| 16713 | &ParsedAttrInfoCUDADevice::Instance, |
||
| 16714 | &ParsedAttrInfoCUDADeviceBuiltinSurfaceType::Instance, |
||
| 16715 | &ParsedAttrInfoCUDADeviceBuiltinTextureType::Instance, |
||
| 16716 | &ParsedAttrInfoCUDAGlobal::Instance, |
||
| 16717 | &ParsedAttrInfoCUDAHost::Instance, |
||
| 16718 | &ParsedAttrInfoCUDAInvalidTarget::Instance, |
||
| 16719 | &ParsedAttrInfoCUDALaunchBounds::Instance, |
||
| 16720 | &ParsedAttrInfoCUDAShared::Instance, |
||
| 16721 | &ParsedAttrInfoCXX11NoReturn::Instance, |
||
| 16722 | &ParsedAttrInfoCallableWhen::Instance, |
||
| 16723 | &ParsedAttrInfoCallback::Instance, |
||
| 16724 | &ParsedAttrInfoCalledOnce::Instance, |
||
| 16725 | &ParsedAttrInfoCapability::Instance, |
||
| 16726 | &ParsedAttrInfoCarriesDependency::Instance, |
||
| 16727 | &ParsedAttrInfoCleanup::Instance, |
||
| 16728 | &ParsedAttrInfoCmseNSCall::Instance, |
||
| 16729 | &ParsedAttrInfoCmseNSEntry::Instance, |
||
| 16730 | &ParsedAttrInfoCodeSeg::Instance, |
||
| 16731 | &ParsedAttrInfoCold::Instance, |
||
| 16732 | &ParsedAttrInfoCommon::Instance, |
||
| 16733 | &ParsedAttrInfoConst::Instance, |
||
| 16734 | &ParsedAttrInfoConstInit::Instance, |
||
| 16735 | &ParsedAttrInfoConstructor::Instance, |
||
| 16736 | &ParsedAttrInfoConsumable::Instance, |
||
| 16737 | &ParsedAttrInfoConsumableAutoCast::Instance, |
||
| 16738 | &ParsedAttrInfoConsumableSetOnRead::Instance, |
||
| 16739 | &ParsedAttrInfoConvergent::Instance, |
||
| 16740 | &ParsedAttrInfoDLLExport::Instance, |
||
| 16741 | &ParsedAttrInfoDLLExportStaticLocal::Instance, |
||
| 16742 | &ParsedAttrInfoDLLImport::Instance, |
||
| 16743 | &ParsedAttrInfoDLLImportStaticLocal::Instance, |
||
| 16744 | &ParsedAttrInfoDeprecated::Instance, |
||
| 16745 | &ParsedAttrInfoDestructor::Instance, |
||
| 16746 | &ParsedAttrInfoDiagnoseAsBuiltin::Instance, |
||
| 16747 | &ParsedAttrInfoDiagnoseIf::Instance, |
||
| 16748 | &ParsedAttrInfoDisableSanitizerInstrumentation::Instance, |
||
| 16749 | &ParsedAttrInfoDisableTailCalls::Instance, |
||
| 16750 | &ParsedAttrInfoEmptyBases::Instance, |
||
| 16751 | &ParsedAttrInfoEnableIf::Instance, |
||
| 16752 | &ParsedAttrInfoEnforceTCB::Instance, |
||
| 16753 | &ParsedAttrInfoEnforceTCBLeaf::Instance, |
||
| 16754 | &ParsedAttrInfoEnumExtensibility::Instance, |
||
| 16755 | &ParsedAttrInfoError::Instance, |
||
| 16756 | &ParsedAttrInfoExcludeFromExplicitInstantiation::Instance, |
||
| 16757 | &ParsedAttrInfoExclusiveTrylockFunction::Instance, |
||
| 16758 | &ParsedAttrInfoExtVectorType::Instance, |
||
| 16759 | &ParsedAttrInfoExternalSourceSymbol::Instance, |
||
| 16760 | &ParsedAttrInfoFallThrough::Instance, |
||
| 16761 | &ParsedAttrInfoFastCall::Instance, |
||
| 16762 | &ParsedAttrInfoFlagEnum::Instance, |
||
| 16763 | &ParsedAttrInfoFlatten::Instance, |
||
| 16764 | &ParsedAttrInfoFormat::Instance, |
||
| 16765 | &ParsedAttrInfoFormatArg::Instance, |
||
| 16766 | &ParsedAttrInfoFunctionReturnThunks::Instance, |
||
| 16767 | &ParsedAttrInfoGNUInline::Instance, |
||
| 16768 | &ParsedAttrInfoGuardedBy::Instance, |
||
| 16769 | &ParsedAttrInfoGuardedVar::Instance, |
||
| 16770 | &ParsedAttrInfoHIPManaged::Instance, |
||
| 16771 | &ParsedAttrInfoHLSLGroupSharedAddressSpace::Instance, |
||
| 16772 | &ParsedAttrInfoHLSLNumThreads::Instance, |
||
| 16773 | &ParsedAttrInfoHLSLResource::Instance, |
||
| 16774 | &ParsedAttrInfoHLSLResourceBinding::Instance, |
||
| 16775 | &ParsedAttrInfoHLSLSV_DispatchThreadID::Instance, |
||
| 16776 | &ParsedAttrInfoHLSLSV_GroupIndex::Instance, |
||
| 16777 | &ParsedAttrInfoHLSLShader::Instance, |
||
| 16778 | &ParsedAttrInfoHot::Instance, |
||
| 16779 | &ParsedAttrInfoIBAction::Instance, |
||
| 16780 | &ParsedAttrInfoIBOutlet::Instance, |
||
| 16781 | &ParsedAttrInfoIBOutletCollection::Instance, |
||
| 16782 | &ParsedAttrInfoIFunc::Instance, |
||
| 16783 | &ParsedAttrInfoInitPriority::Instance, |
||
| 16784 | &ParsedAttrInfoIntelOclBicc::Instance, |
||
| 16785 | &ParsedAttrInfoInternalLinkage::Instance, |
||
| 16786 | &ParsedAttrInfoLTOVisibilityPublic::Instance, |
||
| 16787 | &ParsedAttrInfoLayoutVersion::Instance, |
||
| 16788 | &ParsedAttrInfoLeaf::Instance, |
||
| 16789 | &ParsedAttrInfoLifetimeBound::Instance, |
||
| 16790 | &ParsedAttrInfoLikely::Instance, |
||
| 16791 | &ParsedAttrInfoLoaderUninitialized::Instance, |
||
| 16792 | &ParsedAttrInfoLockReturned::Instance, |
||
| 16793 | &ParsedAttrInfoLockable::Instance, |
||
| 16794 | &ParsedAttrInfoLocksExcluded::Instance, |
||
| 16795 | &ParsedAttrInfoLoopHint::Instance, |
||
| 16796 | &ParsedAttrInfoMIGServerRoutine::Instance, |
||
| 16797 | &ParsedAttrInfoMSABI::Instance, |
||
| 16798 | &ParsedAttrInfoMSAllocator::Instance, |
||
| 16799 | &ParsedAttrInfoMSInheritance::Instance, |
||
| 16800 | &ParsedAttrInfoMSNoVTable::Instance, |
||
| 16801 | &ParsedAttrInfoMSStruct::Instance, |
||
| 16802 | &ParsedAttrInfoMatrixType::Instance, |
||
| 16803 | &ParsedAttrInfoMayAlias::Instance, |
||
| 16804 | &ParsedAttrInfoMaybeUndef::Instance, |
||
| 16805 | &ParsedAttrInfoMicroMips::Instance, |
||
| 16806 | &ParsedAttrInfoMinSize::Instance, |
||
| 16807 | &ParsedAttrInfoMinVectorWidth::Instance, |
||
| 16808 | &ParsedAttrInfoMips16::Instance, |
||
| 16809 | &ParsedAttrInfoMipsLongCall::Instance, |
||
| 16810 | &ParsedAttrInfoMipsShortCall::Instance, |
||
| 16811 | &ParsedAttrInfoMode::Instance, |
||
| 16812 | &ParsedAttrInfoMustTail::Instance, |
||
| 16813 | &ParsedAttrInfoNSConsumed::Instance, |
||
| 16814 | &ParsedAttrInfoNSConsumesSelf::Instance, |
||
| 16815 | &ParsedAttrInfoNSErrorDomain::Instance, |
||
| 16816 | &ParsedAttrInfoNSReturnsAutoreleased::Instance, |
||
| 16817 | &ParsedAttrInfoNSReturnsNotRetained::Instance, |
||
| 16818 | &ParsedAttrInfoNSReturnsRetained::Instance, |
||
| 16819 | &ParsedAttrInfoNaked::Instance, |
||
| 16820 | &ParsedAttrInfoNeonPolyVectorType::Instance, |
||
| 16821 | &ParsedAttrInfoNeonVectorType::Instance, |
||
| 16822 | &ParsedAttrInfoNoAlias::Instance, |
||
| 16823 | &ParsedAttrInfoNoBuiltin::Instance, |
||
| 16824 | &ParsedAttrInfoNoCommon::Instance, |
||
| 16825 | &ParsedAttrInfoNoDebug::Instance, |
||
| 16826 | &ParsedAttrInfoNoDeref::Instance, |
||
| 16827 | &ParsedAttrInfoNoDestroy::Instance, |
||
| 16828 | &ParsedAttrInfoNoDuplicate::Instance, |
||
| 16829 | &ParsedAttrInfoNoEscape::Instance, |
||
| 16830 | &ParsedAttrInfoNoInline::Instance, |
||
| 16831 | &ParsedAttrInfoNoInstrumentFunction::Instance, |
||
| 16832 | &ParsedAttrInfoNoMerge::Instance, |
||
| 16833 | &ParsedAttrInfoNoMicroMips::Instance, |
||
| 16834 | &ParsedAttrInfoNoMips16::Instance, |
||
| 16835 | &ParsedAttrInfoNoProfileFunction::Instance, |
||
| 16836 | &ParsedAttrInfoNoRandomizeLayout::Instance, |
||
| 16837 | &ParsedAttrInfoNoReturn::Instance, |
||
| 16838 | &ParsedAttrInfoNoSanitize::Instance, |
||
| 16839 | &ParsedAttrInfoNoSanitizeSpecific::Instance, |
||
| 16840 | &ParsedAttrInfoNoSpeculativeLoadHardening::Instance, |
||
| 16841 | &ParsedAttrInfoNoSplitStack::Instance, |
||
| 16842 | &ParsedAttrInfoNoStackProtector::Instance, |
||
| 16843 | &ParsedAttrInfoNoThreadSafetyAnalysis::Instance, |
||
| 16844 | &ParsedAttrInfoNoThrow::Instance, |
||
| 16845 | &ParsedAttrInfoNoUniqueAddress::Instance, |
||
| 16846 | &ParsedAttrInfoNoUwtable::Instance, |
||
| 16847 | &ParsedAttrInfoNonNull::Instance, |
||
| 16848 | &ParsedAttrInfoNotTailCalled::Instance, |
||
| 16849 | &ParsedAttrInfoOSConsumed::Instance, |
||
| 16850 | &ParsedAttrInfoOSConsumesThis::Instance, |
||
| 16851 | &ParsedAttrInfoOSReturnsNotRetained::Instance, |
||
| 16852 | &ParsedAttrInfoOSReturnsRetained::Instance, |
||
| 16853 | &ParsedAttrInfoOSReturnsRetainedOnNonZero::Instance, |
||
| 16854 | &ParsedAttrInfoOSReturnsRetainedOnZero::Instance, |
||
| 16855 | &ParsedAttrInfoObjCBoxable::Instance, |
||
| 16856 | &ParsedAttrInfoObjCBridge::Instance, |
||
| 16857 | &ParsedAttrInfoObjCBridgeMutable::Instance, |
||
| 16858 | &ParsedAttrInfoObjCBridgeRelated::Instance, |
||
| 16859 | &ParsedAttrInfoObjCClassStub::Instance, |
||
| 16860 | &ParsedAttrInfoObjCDesignatedInitializer::Instance, |
||
| 16861 | &ParsedAttrInfoObjCDirect::Instance, |
||
| 16862 | &ParsedAttrInfoObjCDirectMembers::Instance, |
||
| 16863 | &ParsedAttrInfoObjCException::Instance, |
||
| 16864 | &ParsedAttrInfoObjCExplicitProtocolImpl::Instance, |
||
| 16865 | &ParsedAttrInfoObjCExternallyRetained::Instance, |
||
| 16866 | &ParsedAttrInfoObjCGC::Instance, |
||
| 16867 | &ParsedAttrInfoObjCIndependentClass::Instance, |
||
| 16868 | &ParsedAttrInfoObjCInertUnsafeUnretained::Instance, |
||
| 16869 | &ParsedAttrInfoObjCKindOf::Instance, |
||
| 16870 | &ParsedAttrInfoObjCMethodFamily::Instance, |
||
| 16871 | &ParsedAttrInfoObjCNSObject::Instance, |
||
| 16872 | &ParsedAttrInfoObjCNonLazyClass::Instance, |
||
| 16873 | &ParsedAttrInfoObjCNonRuntimeProtocol::Instance, |
||
| 16874 | &ParsedAttrInfoObjCOwnership::Instance, |
||
| 16875 | &ParsedAttrInfoObjCPreciseLifetime::Instance, |
||
| 16876 | &ParsedAttrInfoObjCRequiresPropertyDefs::Instance, |
||
| 16877 | &ParsedAttrInfoObjCRequiresSuper::Instance, |
||
| 16878 | &ParsedAttrInfoObjCReturnsInnerPointer::Instance, |
||
| 16879 | &ParsedAttrInfoObjCRootClass::Instance, |
||
| 16880 | &ParsedAttrInfoObjCRuntimeName::Instance, |
||
| 16881 | &ParsedAttrInfoObjCRuntimeVisible::Instance, |
||
| 16882 | &ParsedAttrInfoObjCSubclassingRestricted::Instance, |
||
| 16883 | &ParsedAttrInfoOpenCLAccess::Instance, |
||
| 16884 | &ParsedAttrInfoOpenCLConstantAddressSpace::Instance, |
||
| 16885 | &ParsedAttrInfoOpenCLGenericAddressSpace::Instance, |
||
| 16886 | &ParsedAttrInfoOpenCLGlobalAddressSpace::Instance, |
||
| 16887 | &ParsedAttrInfoOpenCLGlobalDeviceAddressSpace::Instance, |
||
| 16888 | &ParsedAttrInfoOpenCLGlobalHostAddressSpace::Instance, |
||
| 16889 | &ParsedAttrInfoOpenCLIntelReqdSubGroupSize::Instance, |
||
| 16890 | &ParsedAttrInfoOpenCLKernel::Instance, |
||
| 16891 | &ParsedAttrInfoOpenCLLocalAddressSpace::Instance, |
||
| 16892 | &ParsedAttrInfoOpenCLNoSVM::Instance, |
||
| 16893 | &ParsedAttrInfoOpenCLPrivateAddressSpace::Instance, |
||
| 16894 | &ParsedAttrInfoOpenCLUnrollHint::Instance, |
||
| 16895 | &ParsedAttrInfoOptimizeNone::Instance, |
||
| 16896 | &ParsedAttrInfoOverloadable::Instance, |
||
| 16897 | &ParsedAttrInfoOwner::Instance, |
||
| 16898 | &ParsedAttrInfoOwnership::Instance, |
||
| 16899 | &ParsedAttrInfoPacked::Instance, |
||
| 16900 | &ParsedAttrInfoParamTypestate::Instance, |
||
| 16901 | &ParsedAttrInfoPascal::Instance, |
||
| 16902 | &ParsedAttrInfoPassObjectSize::Instance, |
||
| 16903 | &ParsedAttrInfoPatchableFunctionEntry::Instance, |
||
| 16904 | &ParsedAttrInfoPcs::Instance, |
||
| 16905 | &ParsedAttrInfoPointer::Instance, |
||
| 16906 | &ParsedAttrInfoPragmaClangBSSSection::Instance, |
||
| 16907 | &ParsedAttrInfoPragmaClangDataSection::Instance, |
||
| 16908 | &ParsedAttrInfoPragmaClangRelroSection::Instance, |
||
| 16909 | &ParsedAttrInfoPragmaClangRodataSection::Instance, |
||
| 16910 | &ParsedAttrInfoPragmaClangTextSection::Instance, |
||
| 16911 | &ParsedAttrInfoPreferredName::Instance, |
||
| 16912 | &ParsedAttrInfoPreserveAll::Instance, |
||
| 16913 | &ParsedAttrInfoPreserveMost::Instance, |
||
| 16914 | &ParsedAttrInfoPtGuardedBy::Instance, |
||
| 16915 | &ParsedAttrInfoPtGuardedVar::Instance, |
||
| 16916 | &ParsedAttrInfoPtr32::Instance, |
||
| 16917 | &ParsedAttrInfoPtr64::Instance, |
||
| 16918 | &ParsedAttrInfoPure::Instance, |
||
| 16919 | &ParsedAttrInfoRandomizeLayout::Instance, |
||
| 16920 | &ParsedAttrInfoReadOnlyPlacement::Instance, |
||
| 16921 | &ParsedAttrInfoRegCall::Instance, |
||
| 16922 | &ParsedAttrInfoRegparm::Instance, |
||
| 16923 | &ParsedAttrInfoReinitializes::Instance, |
||
| 16924 | &ParsedAttrInfoReleaseCapability::Instance, |
||
| 16925 | &ParsedAttrInfoReleaseHandle::Instance, |
||
| 16926 | &ParsedAttrInfoRenderScriptKernel::Instance, |
||
| 16927 | &ParsedAttrInfoReqdWorkGroupSize::Instance, |
||
| 16928 | &ParsedAttrInfoRequiresCapability::Instance, |
||
| 16929 | &ParsedAttrInfoRestrict::Instance, |
||
| 16930 | &ParsedAttrInfoRetain::Instance, |
||
| 16931 | &ParsedAttrInfoReturnTypestate::Instance, |
||
| 16932 | &ParsedAttrInfoReturnsNonNull::Instance, |
||
| 16933 | &ParsedAttrInfoReturnsTwice::Instance, |
||
| 16934 | &ParsedAttrInfoSPtr::Instance, |
||
| 16935 | &ParsedAttrInfoSYCLKernel::Instance, |
||
| 16936 | &ParsedAttrInfoSYCLSpecialClass::Instance, |
||
| 16937 | &ParsedAttrInfoScopedLockable::Instance, |
||
| 16938 | &ParsedAttrInfoSection::Instance, |
||
| 16939 | &ParsedAttrInfoSelectAny::Instance, |
||
| 16940 | &ParsedAttrInfoSentinel::Instance, |
||
| 16941 | &ParsedAttrInfoSetTypestate::Instance, |
||
| 16942 | &ParsedAttrInfoSharedTrylockFunction::Instance, |
||
| 16943 | &ParsedAttrInfoSpeculativeLoadHardening::Instance, |
||
| 16944 | &ParsedAttrInfoStandaloneDebug::Instance, |
||
| 16945 | &ParsedAttrInfoStdCall::Instance, |
||
| 16946 | &ParsedAttrInfoStrictFP::Instance, |
||
| 16947 | &ParsedAttrInfoStrictGuardStackCheck::Instance, |
||
| 16948 | &ParsedAttrInfoSuppress::Instance, |
||
| 16949 | &ParsedAttrInfoSwiftAsync::Instance, |
||
| 16950 | &ParsedAttrInfoSwiftAsyncCall::Instance, |
||
| 16951 | &ParsedAttrInfoSwiftAsyncContext::Instance, |
||
| 16952 | &ParsedAttrInfoSwiftAsyncError::Instance, |
||
| 16953 | &ParsedAttrInfoSwiftAsyncName::Instance, |
||
| 16954 | &ParsedAttrInfoSwiftAttr::Instance, |
||
| 16955 | &ParsedAttrInfoSwiftBridge::Instance, |
||
| 16956 | &ParsedAttrInfoSwiftBridgedTypedef::Instance, |
||
| 16957 | &ParsedAttrInfoSwiftCall::Instance, |
||
| 16958 | &ParsedAttrInfoSwiftContext::Instance, |
||
| 16959 | &ParsedAttrInfoSwiftError::Instance, |
||
| 16960 | &ParsedAttrInfoSwiftErrorResult::Instance, |
||
| 16961 | &ParsedAttrInfoSwiftIndirectResult::Instance, |
||
| 16962 | &ParsedAttrInfoSwiftName::Instance, |
||
| 16963 | &ParsedAttrInfoSwiftNewType::Instance, |
||
| 16964 | &ParsedAttrInfoSwiftObjCMembers::Instance, |
||
| 16965 | &ParsedAttrInfoSwiftPrivate::Instance, |
||
| 16966 | &ParsedAttrInfoSysVABI::Instance, |
||
| 16967 | &ParsedAttrInfoTLSModel::Instance, |
||
| 16968 | &ParsedAttrInfoTarget::Instance, |
||
| 16969 | &ParsedAttrInfoTargetClones::Instance, |
||
| 16970 | &ParsedAttrInfoTargetVersion::Instance, |
||
| 16971 | &ParsedAttrInfoTestTypestate::Instance, |
||
| 16972 | &ParsedAttrInfoThisCall::Instance, |
||
| 16973 | &ParsedAttrInfoThread::Instance, |
||
| 16974 | &ParsedAttrInfoTransparentUnion::Instance, |
||
| 16975 | &ParsedAttrInfoTrivialABI::Instance, |
||
| 16976 | &ParsedAttrInfoTryAcquireCapability::Instance, |
||
| 16977 | &ParsedAttrInfoTypeNonNull::Instance, |
||
| 16978 | &ParsedAttrInfoTypeNullUnspecified::Instance, |
||
| 16979 | &ParsedAttrInfoTypeNullable::Instance, |
||
| 16980 | &ParsedAttrInfoTypeNullableResult::Instance, |
||
| 16981 | &ParsedAttrInfoTypeTagForDatatype::Instance, |
||
| 16982 | &ParsedAttrInfoTypeVisibility::Instance, |
||
| 16983 | &ParsedAttrInfoUPtr::Instance, |
||
| 16984 | &ParsedAttrInfoUnavailable::Instance, |
||
| 16985 | &ParsedAttrInfoUninitialized::Instance, |
||
| 16986 | &ParsedAttrInfoUnlikely::Instance, |
||
| 16987 | &ParsedAttrInfoUnused::Instance, |
||
| 16988 | &ParsedAttrInfoUseHandle::Instance, |
||
| 16989 | &ParsedAttrInfoUsed::Instance, |
||
| 16990 | &ParsedAttrInfoUsingIfExists::Instance, |
||
| 16991 | &ParsedAttrInfoUuid::Instance, |
||
| 16992 | &ParsedAttrInfoVecReturn::Instance, |
||
| 16993 | &ParsedAttrInfoVecTypeHint::Instance, |
||
| 16994 | &ParsedAttrInfoVectorCall::Instance, |
||
| 16995 | &ParsedAttrInfoVectorSize::Instance, |
||
| 16996 | &ParsedAttrInfoVisibility::Instance, |
||
| 16997 | &ParsedAttrInfoWarnUnused::Instance, |
||
| 16998 | &ParsedAttrInfoWarnUnusedResult::Instance, |
||
| 16999 | &ParsedAttrInfoWeak::Instance, |
||
| 17000 | &ParsedAttrInfoWeakImport::Instance, |
||
| 17001 | &ParsedAttrInfoWeakRef::Instance, |
||
| 17002 | &ParsedAttrInfoWebAssemblyExportName::Instance, |
||
| 17003 | &ParsedAttrInfoWebAssemblyImportModule::Instance, |
||
| 17004 | &ParsedAttrInfoWebAssemblyImportName::Instance, |
||
| 17005 | &ParsedAttrInfoWorkGroupSizeHint::Instance, |
||
| 17006 | &ParsedAttrInfoX86ForceAlignArgPointer::Instance, |
||
| 17007 | &ParsedAttrInfoXRayInstrument::Instance, |
||
| 17008 | &ParsedAttrInfoXRayLogArgs::Instance, |
||
| 17009 | &ParsedAttrInfoZeroCallUsedRegs::Instance, |
||
| 17010 | }; |
||
| 17011 | |||
| 17012 | static void handleAttrWithDelayedArgs(Sema &S, Decl *D, const ParsedAttr &Attr) { |
||
| 17013 | SmallVector<Expr *, 4> ArgExprs; |
||
| 17014 | ArgExprs.reserve(Attr.getNumArgs()); |
||
| 17015 | for (unsigned I = 0; I < Attr.getNumArgs(); ++I) { |
||
| 17016 | assert(!Attr.isArgIdent(I)); |
||
| 17017 | ArgExprs.push_back(Attr.getArgAsExpr(I)); |
||
| 17018 | } |
||
| 17019 | clang::Attr *CreatedAttr = nullptr; |
||
| 17020 | switch (Attr.getKind()) { |
||
| 17021 | default: |
||
| 17022 | llvm_unreachable("Attribute cannot hold delayed arguments."); |
||
| 17023 | case ParsedAttr::AT_Annotate: { |
||
| 17024 | CreatedAttr = AnnotateAttr::CreateWithDelayedArgs(S.Context, ArgExprs.data(), ArgExprs.size(), Attr); |
||
| 17025 | break; |
||
| 17026 | } |
||
| 17027 | case ParsedAttr::AT_AnnotateType: { |
||
| 17028 | CreatedAttr = AnnotateTypeAttr::CreateWithDelayedArgs(S.Context, ArgExprs.data(), ArgExprs.size(), Attr); |
||
| 17029 | break; |
||
| 17030 | } |
||
| 17031 | } |
||
| 17032 | D->addAttr(CreatedAttr); |
||
| 17033 | } |
||
| 17034 | |||
| 17035 | static bool checkAttributeMatchRuleAppliesTo(const Decl *D, attr::SubjectMatchRule rule) { |
||
| 17036 | switch (rule) { |
||
| 17037 | case attr::SubjectMatchRule_block: |
||
| 17038 | return isa<BlockDecl>(D); |
||
| 17039 | case attr::SubjectMatchRule_enum: |
||
| 17040 | return isa<EnumDecl>(D); |
||
| 17041 | case attr::SubjectMatchRule_enum_constant: |
||
| 17042 | return isa<EnumConstantDecl>(D); |
||
| 17043 | case attr::SubjectMatchRule_field: |
||
| 17044 | return isa<FieldDecl>(D); |
||
| 17045 | case attr::SubjectMatchRule_function: |
||
| 17046 | return isa<FunctionDecl>(D); |
||
| 17047 | case attr::SubjectMatchRule_function_is_member: |
||
| 17048 | return isa<CXXMethodDecl>(D); |
||
| 17049 | case attr::SubjectMatchRule_namespace: |
||
| 17050 | return isa<NamespaceDecl>(D); |
||
| 17051 | case attr::SubjectMatchRule_objc_category: |
||
| 17052 | return isa<ObjCCategoryDecl>(D); |
||
| 17053 | case attr::SubjectMatchRule_objc_implementation: |
||
| 17054 | return isa<ObjCImplDecl>(D); |
||
| 17055 | case attr::SubjectMatchRule_objc_interface: |
||
| 17056 | return isa<ObjCInterfaceDecl>(D); |
||
| 17057 | case attr::SubjectMatchRule_objc_method: |
||
| 17058 | return isa<ObjCMethodDecl>(D); |
||
| 17059 | case attr::SubjectMatchRule_objc_method_is_instance: |
||
| 17060 | return isObjCInstanceMethod(D); |
||
| 17061 | case attr::SubjectMatchRule_objc_property: |
||
| 17062 | return isa<ObjCPropertyDecl>(D); |
||
| 17063 | case attr::SubjectMatchRule_objc_protocol: |
||
| 17064 | return isa<ObjCProtocolDecl>(D); |
||
| 17065 | case attr::SubjectMatchRule_record: |
||
| 17066 | return isa<RecordDecl>(D) || isa<CXXRecordDecl>(D); |
||
| 17067 | case attr::SubjectMatchRule_record_not_is_union: |
||
| 17068 | return isStruct(D); |
||
| 17069 | case attr::SubjectMatchRule_hasType_abstract: |
||
| 17070 | assert(false && "Abstract matcher rule isn't allowed"); |
||
| 17071 | return false; |
||
| 17072 | case attr::SubjectMatchRule_hasType_functionType: |
||
| 17073 | return isFunctionLike(D); |
||
| 17074 | case attr::SubjectMatchRule_type_alias: |
||
| 17075 | return isa<TypedefNameDecl>(D); |
||
| 17076 | case attr::SubjectMatchRule_variable: |
||
| 17077 | return isa<VarDecl>(D); |
||
| 17078 | case attr::SubjectMatchRule_variable_is_thread_local: |
||
| 17079 | return isTLSVar(D); |
||
| 17080 | case attr::SubjectMatchRule_variable_is_global: |
||
| 17081 | return isGlobalVar(D); |
||
| 17082 | case attr::SubjectMatchRule_variable_is_local: |
||
| 17083 | return isLocalVar(D); |
||
| 17084 | case attr::SubjectMatchRule_variable_is_parameter: |
||
| 17085 | return isa<ParmVarDecl>(D); |
||
| 17086 | case attr::SubjectMatchRule_variable_not_is_parameter: |
||
| 17087 | return isNonParmVar(D); |
||
| 17088 | } |
||
| 17089 | llvm_unreachable("Invalid match rule"); |
||
| 17090 | return false; |
||
| 17091 | } |
||
| 17092 | |||
| 17093 | #elif defined(WANT_DECL_MERGE_LOGIC) |
||
| 17094 | |||
| 17095 | static bool DiagnoseMutualExclusions(Sema &S, const NamedDecl *D, const Attr *A) { |
||
| 17096 | if (const auto *Second = dyn_cast<AlwaysDestroyAttr>(A)) { |
||
| 17097 | if (const auto *First = D->getAttr<NoDestroyAttr>()) { |
||
| 17098 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17099 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17100 | return false; |
||
| 17101 | } |
||
| 17102 | return true; |
||
| 17103 | } |
||
| 17104 | if (const auto *Second = dyn_cast<AlwaysInlineAttr>(A)) { |
||
| 17105 | if (const auto *First = D->getAttr<NotTailCalledAttr>()) { |
||
| 17106 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17107 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17108 | return false; |
||
| 17109 | } |
||
| 17110 | return true; |
||
| 17111 | } |
||
| 17112 | if (const auto *Second = dyn_cast<CFAuditedTransferAttr>(A)) { |
||
| 17113 | if (const auto *First = D->getAttr<CFUnknownTransferAttr>()) { |
||
| 17114 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17115 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17116 | return false; |
||
| 17117 | } |
||
| 17118 | return true; |
||
| 17119 | } |
||
| 17120 | if (const auto *Second = dyn_cast<CFUnknownTransferAttr>(A)) { |
||
| 17121 | if (const auto *First = D->getAttr<CFAuditedTransferAttr>()) { |
||
| 17122 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17123 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17124 | return false; |
||
| 17125 | } |
||
| 17126 | return true; |
||
| 17127 | } |
||
| 17128 | if (const auto *Second = dyn_cast<CPUDispatchAttr>(A)) { |
||
| 17129 | if (const auto *First = D->getAttr<TargetClonesAttr>()) { |
||
| 17130 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17131 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17132 | return false; |
||
| 17133 | } |
||
| 17134 | if (const auto *First = D->getAttr<TargetVersionAttr>()) { |
||
| 17135 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17136 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17137 | return false; |
||
| 17138 | } |
||
| 17139 | if (const auto *First = D->getAttr<TargetAttr>()) { |
||
| 17140 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17141 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17142 | return false; |
||
| 17143 | } |
||
| 17144 | if (const auto *First = D->getAttr<CPUSpecificAttr>()) { |
||
| 17145 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17146 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17147 | return false; |
||
| 17148 | } |
||
| 17149 | return true; |
||
| 17150 | } |
||
| 17151 | if (const auto *Second = dyn_cast<CPUSpecificAttr>(A)) { |
||
| 17152 | if (const auto *First = D->getAttr<TargetClonesAttr>()) { |
||
| 17153 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17154 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17155 | return false; |
||
| 17156 | } |
||
| 17157 | if (const auto *First = D->getAttr<TargetVersionAttr>()) { |
||
| 17158 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17159 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17160 | return false; |
||
| 17161 | } |
||
| 17162 | if (const auto *First = D->getAttr<TargetAttr>()) { |
||
| 17163 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17164 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17165 | return false; |
||
| 17166 | } |
||
| 17167 | if (const auto *First = D->getAttr<CPUDispatchAttr>()) { |
||
| 17168 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17169 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17170 | return false; |
||
| 17171 | } |
||
| 17172 | return true; |
||
| 17173 | } |
||
| 17174 | if (const auto *Second = dyn_cast<CUDAConstantAttr>(A)) { |
||
| 17175 | if (const auto *First = D->getAttr<CUDASharedAttr>()) { |
||
| 17176 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17177 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17178 | return false; |
||
| 17179 | } |
||
| 17180 | if (const auto *First = D->getAttr<HIPManagedAttr>()) { |
||
| 17181 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17182 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17183 | return false; |
||
| 17184 | } |
||
| 17185 | return true; |
||
| 17186 | } |
||
| 17187 | if (const auto *Second = dyn_cast<CUDADeviceAttr>(A)) { |
||
| 17188 | if (const auto *First = D->getAttr<CUDAGlobalAttr>()) { |
||
| 17189 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17190 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17191 | return false; |
||
| 17192 | } |
||
| 17193 | return true; |
||
| 17194 | } |
||
| 17195 | if (const auto *Second = dyn_cast<CUDADeviceBuiltinSurfaceTypeAttr>(A)) { |
||
| 17196 | if (const auto *First = D->getAttr<CUDADeviceBuiltinTextureTypeAttr>()) { |
||
| 17197 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17198 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17199 | return false; |
||
| 17200 | } |
||
| 17201 | return true; |
||
| 17202 | } |
||
| 17203 | if (const auto *Second = dyn_cast<CUDADeviceBuiltinTextureTypeAttr>(A)) { |
||
| 17204 | if (const auto *First = D->getAttr<CUDADeviceBuiltinSurfaceTypeAttr>()) { |
||
| 17205 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17206 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17207 | return false; |
||
| 17208 | } |
||
| 17209 | return true; |
||
| 17210 | } |
||
| 17211 | if (const auto *Second = dyn_cast<CUDAGlobalAttr>(A)) { |
||
| 17212 | if (const auto *First = D->getAttr<CUDADeviceAttr>()) { |
||
| 17213 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17214 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17215 | return false; |
||
| 17216 | } |
||
| 17217 | if (const auto *First = D->getAttr<CUDAHostAttr>()) { |
||
| 17218 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17219 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17220 | return false; |
||
| 17221 | } |
||
| 17222 | return true; |
||
| 17223 | } |
||
| 17224 | if (const auto *Second = dyn_cast<CUDAHostAttr>(A)) { |
||
| 17225 | if (const auto *First = D->getAttr<CUDAGlobalAttr>()) { |
||
| 17226 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17227 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17228 | return false; |
||
| 17229 | } |
||
| 17230 | return true; |
||
| 17231 | } |
||
| 17232 | if (const auto *Second = dyn_cast<CUDASharedAttr>(A)) { |
||
| 17233 | if (const auto *First = D->getAttr<CUDAConstantAttr>()) { |
||
| 17234 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17235 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17236 | return false; |
||
| 17237 | } |
||
| 17238 | if (const auto *First = D->getAttr<HIPManagedAttr>()) { |
||
| 17239 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17240 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17241 | return false; |
||
| 17242 | } |
||
| 17243 | return true; |
||
| 17244 | } |
||
| 17245 | if (const auto *Second = dyn_cast<ColdAttr>(A)) { |
||
| 17246 | if (const auto *First = D->getAttr<HotAttr>()) { |
||
| 17247 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17248 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17249 | return false; |
||
| 17250 | } |
||
| 17251 | return true; |
||
| 17252 | } |
||
| 17253 | if (const auto *Second = dyn_cast<CommonAttr>(A)) { |
||
| 17254 | if (const auto *First = D->getAttr<InternalLinkageAttr>()) { |
||
| 17255 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17256 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17257 | return false; |
||
| 17258 | } |
||
| 17259 | return true; |
||
| 17260 | } |
||
| 17261 | if (const auto *Second = dyn_cast<DisableTailCallsAttr>(A)) { |
||
| 17262 | if (const auto *First = D->getAttr<NakedAttr>()) { |
||
| 17263 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17264 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17265 | return false; |
||
| 17266 | } |
||
| 17267 | return true; |
||
| 17268 | } |
||
| 17269 | if (const auto *Second = dyn_cast<HIPManagedAttr>(A)) { |
||
| 17270 | if (const auto *First = D->getAttr<CUDAConstantAttr>()) { |
||
| 17271 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17272 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17273 | return false; |
||
| 17274 | } |
||
| 17275 | if (const auto *First = D->getAttr<CUDASharedAttr>()) { |
||
| 17276 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17277 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17278 | return false; |
||
| 17279 | } |
||
| 17280 | return true; |
||
| 17281 | } |
||
| 17282 | if (const auto *Second = dyn_cast<HotAttr>(A)) { |
||
| 17283 | if (const auto *First = D->getAttr<ColdAttr>()) { |
||
| 17284 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17285 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17286 | return false; |
||
| 17287 | } |
||
| 17288 | return true; |
||
| 17289 | } |
||
| 17290 | if (const auto *Second = dyn_cast<InternalLinkageAttr>(A)) { |
||
| 17291 | if (const auto *First = D->getAttr<CommonAttr>()) { |
||
| 17292 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17293 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17294 | return false; |
||
| 17295 | } |
||
| 17296 | return true; |
||
| 17297 | } |
||
| 17298 | if (const auto *Second = dyn_cast<MicroMipsAttr>(A)) { |
||
| 17299 | if (const auto *First = D->getAttr<Mips16Attr>()) { |
||
| 17300 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17301 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17302 | return false; |
||
| 17303 | } |
||
| 17304 | return true; |
||
| 17305 | } |
||
| 17306 | if (const auto *Second = dyn_cast<Mips16Attr>(A)) { |
||
| 17307 | if (const auto *First = D->getAttr<MipsInterruptAttr>()) { |
||
| 17308 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17309 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17310 | return false; |
||
| 17311 | } |
||
| 17312 | if (const auto *First = D->getAttr<MicroMipsAttr>()) { |
||
| 17313 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17314 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17315 | return false; |
||
| 17316 | } |
||
| 17317 | return true; |
||
| 17318 | } |
||
| 17319 | if (const auto *Second = dyn_cast<MipsLongCallAttr>(A)) { |
||
| 17320 | if (const auto *First = D->getAttr<MipsShortCallAttr>()) { |
||
| 17321 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17322 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17323 | return false; |
||
| 17324 | } |
||
| 17325 | return true; |
||
| 17326 | } |
||
| 17327 | if (const auto *Second = dyn_cast<MipsShortCallAttr>(A)) { |
||
| 17328 | if (const auto *First = D->getAttr<MipsLongCallAttr>()) { |
||
| 17329 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17330 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17331 | return false; |
||
| 17332 | } |
||
| 17333 | return true; |
||
| 17334 | } |
||
| 17335 | if (const auto *Second = dyn_cast<NakedAttr>(A)) { |
||
| 17336 | if (const auto *First = D->getAttr<DisableTailCallsAttr>()) { |
||
| 17337 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17338 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17339 | return false; |
||
| 17340 | } |
||
| 17341 | return true; |
||
| 17342 | } |
||
| 17343 | if (const auto *Second = dyn_cast<NoDestroyAttr>(A)) { |
||
| 17344 | if (const auto *First = D->getAttr<AlwaysDestroyAttr>()) { |
||
| 17345 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17346 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17347 | return false; |
||
| 17348 | } |
||
| 17349 | return true; |
||
| 17350 | } |
||
| 17351 | if (const auto *Second = dyn_cast<NoRandomizeLayoutAttr>(A)) { |
||
| 17352 | if (const auto *First = D->getAttr<RandomizeLayoutAttr>()) { |
||
| 17353 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17354 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17355 | return false; |
||
| 17356 | } |
||
| 17357 | return true; |
||
| 17358 | } |
||
| 17359 | if (const auto *Second = dyn_cast<NoSpeculativeLoadHardeningAttr>(A)) { |
||
| 17360 | if (const auto *First = D->getAttr<SpeculativeLoadHardeningAttr>()) { |
||
| 17361 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17362 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17363 | return false; |
||
| 17364 | } |
||
| 17365 | return true; |
||
| 17366 | } |
||
| 17367 | if (const auto *Second = dyn_cast<NotTailCalledAttr>(A)) { |
||
| 17368 | if (const auto *First = D->getAttr<AlwaysInlineAttr>()) { |
||
| 17369 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17370 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17371 | return false; |
||
| 17372 | } |
||
| 17373 | return true; |
||
| 17374 | } |
||
| 17375 | if (const auto *Second = dyn_cast<OwnerAttr>(A)) { |
||
| 17376 | if (const auto *First = D->getAttr<PointerAttr>()) { |
||
| 17377 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17378 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17379 | return false; |
||
| 17380 | } |
||
| 17381 | return true; |
||
| 17382 | } |
||
| 17383 | if (const auto *Second = dyn_cast<PointerAttr>(A)) { |
||
| 17384 | if (const auto *First = D->getAttr<OwnerAttr>()) { |
||
| 17385 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17386 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17387 | return false; |
||
| 17388 | } |
||
| 17389 | return true; |
||
| 17390 | } |
||
| 17391 | if (const auto *Second = dyn_cast<RandomizeLayoutAttr>(A)) { |
||
| 17392 | if (const auto *First = D->getAttr<NoRandomizeLayoutAttr>()) { |
||
| 17393 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17394 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17395 | return false; |
||
| 17396 | } |
||
| 17397 | return true; |
||
| 17398 | } |
||
| 17399 | if (const auto *Second = dyn_cast<SpeculativeLoadHardeningAttr>(A)) { |
||
| 17400 | if (const auto *First = D->getAttr<NoSpeculativeLoadHardeningAttr>()) { |
||
| 17401 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17402 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17403 | return false; |
||
| 17404 | } |
||
| 17405 | return true; |
||
| 17406 | } |
||
| 17407 | if (const auto *Second = dyn_cast<TargetAttr>(A)) { |
||
| 17408 | if (const auto *First = D->getAttr<TargetClonesAttr>()) { |
||
| 17409 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17410 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17411 | return false; |
||
| 17412 | } |
||
| 17413 | if (const auto *First = D->getAttr<TargetVersionAttr>()) { |
||
| 17414 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17415 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17416 | return false; |
||
| 17417 | } |
||
| 17418 | if (const auto *First = D->getAttr<CPUDispatchAttr>()) { |
||
| 17419 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17420 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17421 | return false; |
||
| 17422 | } |
||
| 17423 | if (const auto *First = D->getAttr<CPUSpecificAttr>()) { |
||
| 17424 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17425 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17426 | return false; |
||
| 17427 | } |
||
| 17428 | return true; |
||
| 17429 | } |
||
| 17430 | if (const auto *Second = dyn_cast<TargetClonesAttr>(A)) { |
||
| 17431 | if (const auto *First = D->getAttr<TargetVersionAttr>()) { |
||
| 17432 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17433 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17434 | return false; |
||
| 17435 | } |
||
| 17436 | if (const auto *First = D->getAttr<TargetAttr>()) { |
||
| 17437 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17438 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17439 | return false; |
||
| 17440 | } |
||
| 17441 | if (const auto *First = D->getAttr<CPUDispatchAttr>()) { |
||
| 17442 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17443 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17444 | return false; |
||
| 17445 | } |
||
| 17446 | if (const auto *First = D->getAttr<CPUSpecificAttr>()) { |
||
| 17447 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17448 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17449 | return false; |
||
| 17450 | } |
||
| 17451 | return true; |
||
| 17452 | } |
||
| 17453 | if (const auto *Second = dyn_cast<TargetVersionAttr>(A)) { |
||
| 17454 | if (const auto *First = D->getAttr<TargetClonesAttr>()) { |
||
| 17455 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17456 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17457 | return false; |
||
| 17458 | } |
||
| 17459 | if (const auto *First = D->getAttr<TargetAttr>()) { |
||
| 17460 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17461 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17462 | return false; |
||
| 17463 | } |
||
| 17464 | if (const auto *First = D->getAttr<CPUDispatchAttr>()) { |
||
| 17465 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17466 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17467 | return false; |
||
| 17468 | } |
||
| 17469 | if (const auto *First = D->getAttr<CPUSpecificAttr>()) { |
||
| 17470 | S.Diag(First->getLocation(), diag::err_attributes_are_not_compatible) << First << Second; |
||
| 17471 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17472 | return false; |
||
| 17473 | } |
||
| 17474 | return true; |
||
| 17475 | } |
||
| 17476 | return true; |
||
| 17477 | } |
||
| 17478 | |||
| 17479 | #elif defined(WANT_STMT_MERGE_LOGIC) |
||
| 17480 | |||
| 17481 | static bool DiagnoseMutualExclusions(Sema &S, const SmallVectorImpl<const Attr *> &C) { |
||
| 17482 | for (const Attr *A : C) { |
||
| 17483 | if (const auto *Second = dyn_cast<AlwaysInlineAttr>(A)) { |
||
| 17484 | auto Iter = llvm::find_if(C, [](const Attr *Check) { return isa<NotTailCalledAttr>(Check); }); |
||
| 17485 | if (Iter != C.end()) { |
||
| 17486 | S.Diag((*Iter)->getLocation(), diag::err_attributes_are_not_compatible) << *Iter << Second; |
||
| 17487 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17488 | return false; |
||
| 17489 | } |
||
| 17490 | } |
||
| 17491 | if (const auto *Second = dyn_cast<LikelyAttr>(A)) { |
||
| 17492 | auto Iter = llvm::find_if(C, [](const Attr *Check) { return isa<UnlikelyAttr>(Check); }); |
||
| 17493 | if (Iter != C.end()) { |
||
| 17494 | S.Diag((*Iter)->getLocation(), diag::err_attributes_are_not_compatible) << *Iter << Second; |
||
| 17495 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17496 | return false; |
||
| 17497 | } |
||
| 17498 | } |
||
| 17499 | if (const auto *Second = dyn_cast<UnlikelyAttr>(A)) { |
||
| 17500 | auto Iter = llvm::find_if(C, [](const Attr *Check) { return isa<LikelyAttr>(Check); }); |
||
| 17501 | if (Iter != C.end()) { |
||
| 17502 | S.Diag((*Iter)->getLocation(), diag::err_attributes_are_not_compatible) << *Iter << Second; |
||
| 17503 | S.Diag(Second->getLocation(), diag::note_conflicting_attribute); |
||
| 17504 | return false; |
||
| 17505 | } |
||
| 17506 | } |
||
| 17507 | } |
||
| 17508 | return true; |
||
| 17509 | } |
||
| 17510 | |||
| 17511 | #endif |