| 1 | //===--- Features.def - Features and Extensions database --------*- C++ -*-===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file defines features exposed via __has_feature and extensions exposed |
| 10 | // via __has_extension. Users of this file must either define the FEATURE or |
| 11 | // EXTENSION macros (or both) to make use of this information. Note that these |
| 12 | // macros expect the following declarations to be available for the Predicate: |
| 13 | // |
| 14 | // const LangOptions &LangOpts; |
| 15 | // const Preprocessor &PP; |
| 16 | // |
| 17 | // The Predicate field dictates the conditions under which the feature or |
| 18 | // extension will be made available. |
| 19 | // |
| 20 | // FEATURE(...) should be used to advertise support for standard language |
| 21 | // features, whereas EXTENSION(...) should be used for clang extensions. Note |
| 22 | // that many of the identifiers in this file don't follow this rule for backward |
| 23 | // compatibility reasons. |
| 24 | // |
| 25 | //===----------------------------------------------------------------------===// |
| 26 | |
| 27 | #if !defined(FEATURE) && !defined(EXTENSION) |
| 28 | # error Define either the FEATURE or EXTENSION macro to handle features |
| 29 | #endif |
| 30 | |
| 31 | #ifndef FEATURE |
| 32 | #define FEATURE(Name, Predicate) |
| 33 | #endif |
| 34 | |
| 35 | #ifndef EXTENSION |
| 36 | #define EXTENSION(Name, Predicate) |
| 37 | #endif |
| 38 | |
| 39 | FEATURE(address_sanitizer, |
| 40 | LangOpts.Sanitize.hasOneOf(SanitizerKind::Address | |
| 41 | SanitizerKind::KernelAddress)) |
| 42 | FEATURE(hwaddress_sanitizer, |
| 43 | LangOpts.Sanitize.hasOneOf(SanitizerKind::HWAddress | |
| 44 | SanitizerKind::KernelHWAddress)) |
| 45 | FEATURE(xray_instrument, LangOpts.XRayInstrument) |
| 46 | FEATURE(undefined_behavior_sanitizer, |
| 47 | LangOpts.Sanitize.hasOneOf(SanitizerKind::Undefined)) |
| 48 | FEATURE(assume_nonnull, true) |
| 49 | FEATURE(attribute_analyzer_noreturn, true) |
| 50 | FEATURE(attribute_availability, true) |
| 51 | FEATURE(attribute_availability_with_message, true) |
| 52 | FEATURE(attribute_availability_app_extension, true) |
| 53 | FEATURE(attribute_availability_with_version_underscores, true) |
| 54 | FEATURE(attribute_availability_tvos, true) |
| 55 | FEATURE(attribute_availability_watchos, true) |
| 56 | FEATURE(attribute_availability_with_strict, true) |
| 57 | FEATURE(attribute_availability_with_replacement, true) |
| 58 | FEATURE(attribute_availability_in_templates, true) |
| 59 | FEATURE(attribute_availability_swift, true) |
| 60 | FEATURE(attribute_cf_returns_not_retained, true) |
| 61 | FEATURE(attribute_cf_returns_retained, true) |
| 62 | FEATURE(attribute_cf_returns_on_parameters, true) |
| 63 | FEATURE(attribute_deprecated_with_message, true) |
| 64 | FEATURE(attribute_deprecated_with_replacement, true) |
| 65 | FEATURE(attribute_ext_vector_type, true) |
| 66 | FEATURE(attribute_ns_returns_not_retained, true) |
| 67 | FEATURE(attribute_ns_returns_retained, true) |
| 68 | FEATURE(attribute_ns_consumes_self, true) |
| 69 | FEATURE(attribute_ns_consumed, true) |
| 70 | FEATURE(attribute_cf_consumed, true) |
| 71 | FEATURE(attribute_objc_ivar_unused, true) |
| 72 | FEATURE(attribute_objc_method_family, true) |
| 73 | FEATURE(attribute_overloadable, true) |
| 74 | FEATURE(attribute_unavailable_with_message, true) |
| 75 | FEATURE(attribute_unused_on_fields, true) |
| 76 | FEATURE(attribute_diagnose_if_objc, true) |
| 77 | FEATURE(blocks, LangOpts.Blocks) |
| 78 | FEATURE(c_thread_safety_attributes, true) |
| 79 | FEATURE(cxx_exceptions, LangOpts.CXXExceptions) |
| 80 | FEATURE(cxx_rtti, LangOpts.RTTI &&LangOpts.RTTIData) |
| 81 | FEATURE(enumerator_attributes, true) |
| 82 | FEATURE(nullability, true) |
| 83 | FEATURE(nullability_on_arrays, true) |
| 84 | FEATURE(memory_sanitizer, |
| 85 | LangOpts.Sanitize.hasOneOf(SanitizerKind::Memory | |
| 86 | SanitizerKind::KernelMemory)) |
| 87 | FEATURE(thread_sanitizer, LangOpts.Sanitize.has(SanitizerKind::Thread)) |
| 88 | FEATURE(dataflow_sanitizer, LangOpts.Sanitize.has(SanitizerKind::DataFlow)) |
| 89 | FEATURE(scudo, LangOpts.Sanitize.hasOneOf(SanitizerKind::Scudo)) |
| 90 | // Objective-C features |
| 91 | FEATURE(objc_arr, LangOpts.ObjCAutoRefCount) // FIXME: REMOVE? |
| 92 | FEATURE(objc_arc, LangOpts.ObjCAutoRefCount) |
| 93 | FEATURE(objc_arc_fields, true) |
| 94 | FEATURE(objc_arc_weak, LangOpts.ObjCWeak) |
| 95 | FEATURE(objc_default_synthesize_properties, LangOpts.ObjC) |
| 96 | FEATURE(objc_fixed_enum, LangOpts.ObjC) |
| 97 | FEATURE(objc_instancetype, LangOpts.ObjC) |
| 98 | FEATURE(objc_kindof, LangOpts.ObjC) |
| 99 | FEATURE(objc_modules, LangOpts.ObjC && LangOpts.Modules) |
| 100 | FEATURE(objc_nonfragile_abi, LangOpts.ObjCRuntime.isNonFragile()) |
| 101 | FEATURE(objc_property_explicit_atomic, true) |
| 102 | FEATURE(objc_protocol_qualifier_mangling, true) |
| 103 | FEATURE(objc_weak_class, LangOpts.ObjCRuntime.hasWeakClassImport()) |
| 104 | FEATURE(ownership_holds, true) |
| 105 | FEATURE(ownership_returns, true) |
| 106 | FEATURE(ownership_takes, true) |
| 107 | FEATURE(objc_bool, true) |
| 108 | FEATURE(objc_subscripting, LangOpts.ObjCRuntime.isNonFragile()) |
| 109 | FEATURE(objc_array_literals, LangOpts.ObjC) |
| 110 | FEATURE(objc_dictionary_literals, LangOpts.ObjC) |
| 111 | FEATURE(objc_boxed_expressions, LangOpts.ObjC) |
| 112 | FEATURE(objc_boxed_nsvalue_expressions, LangOpts.ObjC) |
| 113 | FEATURE(arc_cf_code_audited, true) |
| 114 | FEATURE(objc_bridge_id, true) |
| 115 | FEATURE(objc_bridge_id_on_typedefs, true) |
| 116 | FEATURE(objc_generics, LangOpts.ObjC) |
| 117 | FEATURE(objc_generics_variance, LangOpts.ObjC) |
| 118 | FEATURE(objc_class_property, LangOpts.ObjC) |
| 119 | FEATURE(objc_c_static_assert, LangOpts.C11) |
| 120 | FEATURE(objc_cxx_static_assert, LangOpts.CPlusPlus11) |
| 121 | EXTENSION(objc_c_static_assert, true) |
| 122 | // C11 features |
| 123 | FEATURE(c_alignas, LangOpts.C11) |
| 124 | FEATURE(c_alignof, LangOpts.C11) |
| 125 | FEATURE(c_atomic, LangOpts.C11) |
| 126 | FEATURE(c_generic_selections, LangOpts.C11) |
| 127 | FEATURE(c_static_assert, LangOpts.C11) |
| 128 | FEATURE(c_thread_local, LangOpts.C11 &&PP.getTargetInfo().isTLSSupported()) |
| 129 | // C++11 features |
| 130 | FEATURE(cxx_access_control_sfinae, LangOpts.CPlusPlus11) |
| 131 | FEATURE(cxx_alias_templates, LangOpts.CPlusPlus11) |
| 132 | FEATURE(cxx_alignas, LangOpts.CPlusPlus11) |
| 133 | FEATURE(cxx_alignof, LangOpts.CPlusPlus11) |
| 134 | FEATURE(cxx_atomic, LangOpts.CPlusPlus11) |
| 135 | FEATURE(cxx_attributes, LangOpts.CPlusPlus11) |
| 136 | FEATURE(cxx_auto_type, LangOpts.CPlusPlus11) |
| 137 | FEATURE(cxx_constexpr, LangOpts.CPlusPlus11) |
| 138 | FEATURE(cxx_constexpr_string_builtins, LangOpts.CPlusPlus11) |
| 139 | FEATURE(cxx_decltype, LangOpts.CPlusPlus11) |
| 140 | FEATURE(cxx_decltype_incomplete_return_types, LangOpts.CPlusPlus11) |
| 141 | FEATURE(cxx_default_function_template_args, LangOpts.CPlusPlus11) |
| 142 | FEATURE(cxx_defaulted_functions, LangOpts.CPlusPlus11) |
| 143 | FEATURE(cxx_delegating_constructors, LangOpts.CPlusPlus11) |
| 144 | FEATURE(cxx_deleted_functions, LangOpts.CPlusPlus11) |
| 145 | FEATURE(cxx_explicit_conversions, LangOpts.CPlusPlus11) |
| 146 | FEATURE(cxx_generalized_initializers, LangOpts.CPlusPlus11) |
| 147 | FEATURE(cxx_implicit_moves, LangOpts.CPlusPlus11) |
| 148 | FEATURE(cxx_inheriting_constructors, LangOpts.CPlusPlus11) |
| 149 | FEATURE(cxx_inline_namespaces, LangOpts.CPlusPlus11) |
| 150 | FEATURE(cxx_lambdas, LangOpts.CPlusPlus11) |
| 151 | FEATURE(cxx_local_type_template_args, LangOpts.CPlusPlus11) |
| 152 | FEATURE(cxx_nonstatic_member_init, LangOpts.CPlusPlus11) |
| 153 | FEATURE(cxx_noexcept, LangOpts.CPlusPlus11) |
| 154 | FEATURE(cxx_nullptr, LangOpts.CPlusPlus11) |
| 155 | FEATURE(cxx_override_control, LangOpts.CPlusPlus11) |
| 156 | FEATURE(cxx_range_for, LangOpts.CPlusPlus11) |
| 157 | FEATURE(cxx_raw_string_literals, LangOpts.CPlusPlus11) |
| 158 | FEATURE(cxx_reference_qualified_functions, LangOpts.CPlusPlus11) |
| 159 | FEATURE(cxx_rvalue_references, LangOpts.CPlusPlus11) |
| 160 | FEATURE(cxx_strong_enums, LangOpts.CPlusPlus11) |
| 161 | FEATURE(cxx_static_assert, LangOpts.CPlusPlus11) |
| 162 | FEATURE(cxx_thread_local, |
| 163 | LangOpts.CPlusPlus11 &&PP.getTargetInfo().isTLSSupported()) |
| 164 | FEATURE(cxx_trailing_return, LangOpts.CPlusPlus11) |
| 165 | FEATURE(cxx_unicode_literals, LangOpts.CPlusPlus11) |
| 166 | FEATURE(cxx_unrestricted_unions, LangOpts.CPlusPlus11) |
| 167 | FEATURE(cxx_user_literals, LangOpts.CPlusPlus11) |
| 168 | FEATURE(cxx_variadic_templates, LangOpts.CPlusPlus11) |
| 169 | // C++14 features |
| 170 | FEATURE(cxx_aggregate_nsdmi, LangOpts.CPlusPlus14) |
| 171 | FEATURE(cxx_binary_literals, LangOpts.CPlusPlus14) |
| 172 | FEATURE(cxx_contextual_conversions, LangOpts.CPlusPlus14) |
| 173 | FEATURE(cxx_decltype_auto, LangOpts.CPlusPlus14) |
| 174 | FEATURE(cxx_generic_lambdas, LangOpts.CPlusPlus14) |
| 175 | FEATURE(cxx_init_captures, LangOpts.CPlusPlus14) |
| 176 | FEATURE(cxx_relaxed_constexpr, LangOpts.CPlusPlus14) |
| 177 | FEATURE(cxx_return_type_deduction, LangOpts.CPlusPlus14) |
| 178 | FEATURE(cxx_variable_templates, LangOpts.CPlusPlus14) |
| 179 | // NOTE: For features covered by SD-6, it is preferable to provide *only* |
| 180 | // the SD-6 macro and not a __has_feature check. |
| 181 | |
| 182 | // C++ TSes |
| 183 | // FEATURE(cxx_runtime_arrays, LangOpts.CPlusPlusTSArrays) |
| 184 | // FEATURE(cxx_concepts, LangOpts.CPlusPlusTSConcepts) |
| 185 | // FIXME: Should this be __has_feature or __has_extension? |
| 186 | // FEATURE(raw_invocation_type, LangOpts.CPlusPlus) |
| 187 | // Type traits |
| 188 | // N.B. Additional type traits should not be added to the following list. |
| 189 | // Instead, they should be detected by has_extension. |
| 190 | FEATURE(has_nothrow_assign, LangOpts.CPlusPlus) |
| 191 | FEATURE(has_nothrow_copy, LangOpts.CPlusPlus) |
| 192 | FEATURE(has_nothrow_constructor, LangOpts.CPlusPlus) |
| 193 | FEATURE(has_trivial_assign, LangOpts.CPlusPlus) |
| 194 | FEATURE(has_trivial_copy, LangOpts.CPlusPlus) |
| 195 | FEATURE(has_trivial_constructor, LangOpts.CPlusPlus) |
| 196 | FEATURE(has_trivial_destructor, LangOpts.CPlusPlus) |
| 197 | FEATURE(has_virtual_destructor, LangOpts.CPlusPlus) |
| 198 | FEATURE(is_abstract, LangOpts.CPlusPlus) |
| 199 | FEATURE(is_base_of, LangOpts.CPlusPlus) |
| 200 | FEATURE(is_class, LangOpts.CPlusPlus) |
| 201 | FEATURE(is_constructible, LangOpts.CPlusPlus) |
| 202 | FEATURE(is_convertible_to, LangOpts.CPlusPlus) |
| 203 | FEATURE(is_empty, LangOpts.CPlusPlus) |
| 204 | FEATURE(is_enum, LangOpts.CPlusPlus) |
| 205 | FEATURE(is_final, LangOpts.CPlusPlus) |
| 206 | FEATURE(is_literal, LangOpts.CPlusPlus) |
| 207 | FEATURE(is_standard_layout, LangOpts.CPlusPlus) |
| 208 | FEATURE(is_pod, LangOpts.CPlusPlus) |
| 209 | FEATURE(is_polymorphic, LangOpts.CPlusPlus) |
| 210 | FEATURE(is_sealed, LangOpts.CPlusPlus &&LangOpts.MicrosoftExt) |
| 211 | FEATURE(is_trivial, LangOpts.CPlusPlus) |
| 212 | FEATURE(is_trivially_assignable, LangOpts.CPlusPlus) |
| 213 | FEATURE(is_trivially_constructible, LangOpts.CPlusPlus) |
| 214 | FEATURE(is_trivially_copyable, LangOpts.CPlusPlus) |
| 215 | FEATURE(is_union, LangOpts.CPlusPlus) |
| 216 | FEATURE(modules, LangOpts.Modules) |
| 217 | FEATURE(safe_stack, LangOpts.Sanitize.has(SanitizerKind::SafeStack)) |
| 218 | FEATURE(shadow_call_stack, |
| 219 | LangOpts.Sanitize.has(SanitizerKind::ShadowCallStack)) |
| 220 | FEATURE(tls, PP.getTargetInfo().isTLSSupported()) |
| 221 | FEATURE(underlying_type, LangOpts.CPlusPlus) |
| 222 | |
| 223 | // C11 features supported by other languages as extensions. |
| 224 | EXTENSION(c_alignas, true) |
| 225 | EXTENSION(c_alignof, true) |
| 226 | EXTENSION(c_atomic, true) |
| 227 | EXTENSION(c_generic_selections, true) |
| 228 | EXTENSION(c_static_assert, true) |
| 229 | EXTENSION(c_thread_local, PP.getTargetInfo().isTLSSupported()) |
| 230 | // C++11 features supported by other languages as extensions. |
| 231 | EXTENSION(cxx_atomic, LangOpts.CPlusPlus) |
| 232 | EXTENSION(cxx_deleted_functions, LangOpts.CPlusPlus) |
| 233 | EXTENSION(cxx_explicit_conversions, LangOpts.CPlusPlus) |
| 234 | EXTENSION(cxx_inline_namespaces, LangOpts.CPlusPlus) |
| 235 | EXTENSION(cxx_local_type_template_args, LangOpts.CPlusPlus) |
| 236 | EXTENSION(cxx_nonstatic_member_init, LangOpts.CPlusPlus) |
| 237 | EXTENSION(cxx_override_control, LangOpts.CPlusPlus) |
| 238 | EXTENSION(cxx_range_for, LangOpts.CPlusPlus) |
| 239 | EXTENSION(cxx_reference_qualified_functions, LangOpts.CPlusPlus) |
| 240 | EXTENSION(cxx_rvalue_references, LangOpts.CPlusPlus) |
| 241 | EXTENSION(cxx_variadic_templates, LangOpts.CPlusPlus) |
| 242 | EXTENSION(cxx_fixed_enum, true) |
| 243 | // C++14 features supported by other languages as extensions. |
| 244 | EXTENSION(cxx_binary_literals, true) |
| 245 | EXTENSION(cxx_init_captures, LangOpts.CPlusPlus11) |
| 246 | EXTENSION(cxx_variable_templates, LangOpts.CPlusPlus) |
| 247 | // Miscellaneous language extensions |
| 248 | EXTENSION(overloadable_unmarked, true) |
| 249 | EXTENSION(pragma_clang_attribute_namespaces, true) |
| 250 | EXTENSION(pragma_clang_attribute_external_declaration, true) |
| 251 | |
| 252 | #undef EXTENSION |
| 253 | #undef FEATURE |
| 254 | |