1 Optional<attr::SubjectMatchRule> defaultIsAttributeSubjectMatchSubRuleFor(StringRef, bool) { 2 return None; 3 } 4 5 Optional<attr::SubjectMatchRule> isAttributeSubjectMatchSubRuleFor_function(StringRef Name, bool IsUnless) { 6 if (IsUnless) 7 return llvm::StringSwitch<Optional<attr::SubjectMatchRule>>(Name). 8 Default(None); 9 return llvm::StringSwitch<Optional<attr::SubjectMatchRule>>(Name). 10 Case("is_member", attr::SubjectMatchRule_function_is_member). 11 Default(None); 12 } 13 14 Optional<attr::SubjectMatchRule> isAttributeSubjectMatchSubRuleFor_hasType(StringRef Name, bool IsUnless) { 15 if (IsUnless) 16 return llvm::StringSwitch<Optional<attr::SubjectMatchRule>>(Name). 17 Default(None); 18 return llvm::StringSwitch<Optional<attr::SubjectMatchRule>>(Name). 19 Case("functionType", attr::SubjectMatchRule_hasType_functionType). 20 Default(None); 21 } 22 23 Optional<attr::SubjectMatchRule> isAttributeSubjectMatchSubRuleFor_record(StringRef Name, bool IsUnless) { 24 if (IsUnless) 25 return llvm::StringSwitch<Optional<attr::SubjectMatchRule>>(Name). 26 Case("is_union", attr::SubjectMatchRule_record_not_is_union). 27 Default(None); 28 return llvm::StringSwitch<Optional<attr::SubjectMatchRule>>(Name). 29 Default(None); 30 } 31 32 Optional<attr::SubjectMatchRule> isAttributeSubjectMatchSubRuleFor_variable(StringRef Name, bool IsUnless) { 33 if (IsUnless) 34 return llvm::StringSwitch<Optional<attr::SubjectMatchRule>>(Name). 35 Case("is_parameter", attr::SubjectMatchRule_variable_not_is_parameter). 36 Default(None); 37 return llvm::StringSwitch<Optional<attr::SubjectMatchRule>>(Name). 38 Case("is_thread_local", attr::SubjectMatchRule_variable_is_thread_local). 39 Case("is_global", attr::SubjectMatchRule_variable_is_global). 40 Case("is_parameter", attr::SubjectMatchRule_variable_is_parameter). 41 Default(None); 42 } 43 44 Optional<attr::SubjectMatchRule> isAttributeSubjectMatchSubRuleFor_objc_method(StringRef Name, bool IsUnless) { 45 if (IsUnless) 46 return llvm::StringSwitch<Optional<attr::SubjectMatchRule>>(Name). 47 Default(None); 48 return llvm::StringSwitch<Optional<attr::SubjectMatchRule>>(Name). 49 Case("is_instance", attr::SubjectMatchRule_objc_method_is_instance). 50 Default(None); 51 } 52 53 std::pair<Optional<attr::SubjectMatchRule>, Optional<attr::SubjectMatchRule> (*)(StringRef, bool)> isAttributeSubjectMatchRule(StringRef Name) { 54 return llvm::StringSwitch<std::pair<Optional<attr::SubjectMatchRule>, Optional<attr::SubjectMatchRule> (*) (StringRef, bool)>>(Name). 55 Case("block", std::make_pair(attr::SubjectMatchRule_block, defaultIsAttributeSubjectMatchSubRuleFor)). 56 Case("enum", std::make_pair(attr::SubjectMatchRule_enum, defaultIsAttributeSubjectMatchSubRuleFor)). 57 Case("enum_constant", std::make_pair(attr::SubjectMatchRule_enum_constant, defaultIsAttributeSubjectMatchSubRuleFor)). 58 Case("field", std::make_pair(attr::SubjectMatchRule_field, defaultIsAttributeSubjectMatchSubRuleFor)). 59 Case("function", std::make_pair(attr::SubjectMatchRule_function, isAttributeSubjectMatchSubRuleFor_function)). 60 Case("namespace", std::make_pair(attr::SubjectMatchRule_namespace, defaultIsAttributeSubjectMatchSubRuleFor)). 61 Case("objc_category", std::make_pair(attr::SubjectMatchRule_objc_category, defaultIsAttributeSubjectMatchSubRuleFor)). 62 Case("objc_interface", std::make_pair(attr::SubjectMatchRule_objc_interface, defaultIsAttributeSubjectMatchSubRuleFor)). 63 Case("objc_method", std::make_pair(attr::SubjectMatchRule_objc_method, isAttributeSubjectMatchSubRuleFor_objc_method)). 64 Case("objc_property", std::make_pair(attr::SubjectMatchRule_objc_property, defaultIsAttributeSubjectMatchSubRuleFor)). 65 Case("objc_protocol", std::make_pair(attr::SubjectMatchRule_objc_protocol, defaultIsAttributeSubjectMatchSubRuleFor)). 66 Case("record", std::make_pair(attr::SubjectMatchRule_record, isAttributeSubjectMatchSubRuleFor_record)). 67 Case("hasType", std::make_pair(attr::SubjectMatchRule_hasType_abstract, isAttributeSubjectMatchSubRuleFor_hasType)). 68 Case("type_alias", std::make_pair(attr::SubjectMatchRule_type_alias, defaultIsAttributeSubjectMatchSubRuleFor)). 69 Case("variable", std::make_pair(attr::SubjectMatchRule_variable, isAttributeSubjectMatchSubRuleFor_variable)). 70 Default(std::make_pair(None, defaultIsAttributeSubjectMatchSubRuleFor)); 71 } 72 73 const char *validAttributeSubjectMatchSubRules(attr::SubjectMatchRule Rule) { 74 switch (Rule) { 75 case attr::SubjectMatchRule_function: 76 return "'is_member'"; 77 case attr::SubjectMatchRule_hasType_abstract: 78 return "'functionType'"; 79 case attr::SubjectMatchRule_record: 80 return "'unless(is_union)'"; 81 case attr::SubjectMatchRule_variable: 82 return "'is_thread_local', 'is_global', 'is_parameter', 'unless(is_parameter)'"; 83 case attr::SubjectMatchRule_objc_method: 84 return "'is_instance'"; 85 default: return nullptr; 86 } 87 } 88 89