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 39FEATURE(speculative_load_hardening, LangOpts.SpeculativeLoadHardening) 40FEATURE(address_sanitizer, 41 LangOpts.Sanitize.hasOneOf(SanitizerKind::Address | 42 SanitizerKind::KernelAddress)) 43FEATURE(leak_sanitizer, 44 LangOpts.Sanitize.has(SanitizerKind::Leak)) 45FEATURE(hwaddress_sanitizer, 46 LangOpts.Sanitize.hasOneOf(SanitizerKind::HWAddress | 47 SanitizerKind::KernelHWAddress)) 48FEATURE(memtag_stack, 49 LangOpts.Sanitize.has(SanitizerKind::MemtagStack)) 50FEATURE(memtag_heap, 51 LangOpts.Sanitize.has(SanitizerKind::MemtagHeap)) 52FEATURE(memtag_globals, 53 LangOpts.Sanitize.has(SanitizerKind::MemtagGlobals)) 54FEATURE(xray_instrument, LangOpts.XRayInstrument) 55FEATURE(undefined_behavior_sanitizer, 56 LangOpts.Sanitize.hasOneOf(SanitizerKind::Undefined)) 57FEATURE(coverage_sanitizer, LangOpts.SanitizeCoverage) 58FEATURE(assume_nonnull, true) 59FEATURE(attribute_analyzer_noreturn, true) 60FEATURE(attribute_availability, true) 61FEATURE(attribute_availability_with_message, true) 62FEATURE(attribute_availability_app_extension, true) 63FEATURE(attribute_availability_with_version_underscores, true) 64FEATURE(attribute_availability_tvos, true) 65FEATURE(attribute_availability_watchos, true) 66FEATURE(attribute_availability_driverkit, true) 67FEATURE(attribute_availability_with_strict, true) 68FEATURE(attribute_availability_with_replacement, true) 69FEATURE(attribute_availability_in_templates, true) 70FEATURE(attribute_availability_swift, true) 71FEATURE(attribute_cf_returns_not_retained, true) 72FEATURE(attribute_cf_returns_retained, true) 73FEATURE(attribute_cf_returns_on_parameters, true) 74FEATURE(attribute_deprecated_with_message, true) 75FEATURE(attribute_deprecated_with_replacement, true) 76FEATURE(attribute_ext_vector_type, true) 77FEATURE(attribute_ns_returns_not_retained, true) 78FEATURE(attribute_ns_returns_retained, true) 79FEATURE(attribute_ns_consumes_self, true) 80FEATURE(attribute_ns_consumed, true) 81FEATURE(attribute_cf_consumed, true) 82FEATURE(attribute_objc_ivar_unused, true) 83FEATURE(attribute_objc_method_family, true) 84FEATURE(attribute_overloadable, true) 85FEATURE(attribute_unavailable_with_message, true) 86FEATURE(attribute_unused_on_fields, true) 87FEATURE(attribute_diagnose_if_objc, true) 88FEATURE(blocks, LangOpts.Blocks) 89FEATURE(c_thread_safety_attributes, true) 90FEATURE(cxx_exceptions, LangOpts.CXXExceptions) 91FEATURE(cxx_rtti, LangOpts.RTTI &&LangOpts.RTTIData) 92EXTENSION(define_target_os_macros, 93 PP.getPreprocessorOpts().DefineTargetOSMacros) 94FEATURE(enumerator_attributes, true) 95FEATURE(nullability, true) 96FEATURE(nullability_on_arrays, true) 97FEATURE(nullability_on_classes, true) 98FEATURE(nullability_nullable_result, true) 99FEATURE(numerical_stability_sanitizer, LangOpts.Sanitize.has(SanitizerKind::NumericalStability)) 100FEATURE(memory_sanitizer, 101 LangOpts.Sanitize.hasOneOf(SanitizerKind::Memory | 102 SanitizerKind::KernelMemory)) 103FEATURE(thread_sanitizer, LangOpts.Sanitize.has(SanitizerKind::Thread)) 104FEATURE(dataflow_sanitizer, LangOpts.Sanitize.has(SanitizerKind::DataFlow)) 105FEATURE(scudo, LangOpts.Sanitize.hasOneOf(SanitizerKind::Scudo)) 106FEATURE(ptrauth_intrinsics, LangOpts.PointerAuthIntrinsics) 107FEATURE(ptrauth_calls, LangOpts.PointerAuthCalls) 108FEATURE(ptrauth_returns, LangOpts.PointerAuthReturns) 109FEATURE(ptrauth_vtable_pointer_address_discrimination, LangOpts.PointerAuthVTPtrAddressDiscrimination) 110FEATURE(ptrauth_vtable_pointer_type_discrimination, LangOpts.PointerAuthVTPtrTypeDiscrimination) 111FEATURE(ptrauth_type_info_vtable_pointer_discrimination, LangOpts.PointerAuthTypeInfoVTPtrDiscrimination) 112FEATURE(ptrauth_member_function_pointer_type_discrimination, LangOpts.PointerAuthCalls) 113FEATURE(ptrauth_init_fini, LangOpts.PointerAuthInitFini) 114FEATURE(ptrauth_function_pointer_type_discrimination, LangOpts.PointerAuthFunctionTypeDiscrimination) 115FEATURE(ptrauth_indirect_gotos, LangOpts.PointerAuthIndirectGotos) 116EXTENSION(swiftcc, 117 PP.getTargetInfo().checkCallingConvention(CC_Swift) == 118 clang::TargetInfo::CCCR_OK) 119EXTENSION(swiftasynccc, 120 PP.getTargetInfo().checkCallingConvention(CC_SwiftAsync) == 121 clang::TargetInfo::CCCR_OK) 122FEATURE(pragma_stdc_cx_limited_range, true) 123// Objective-C features 124FEATURE(objc_arr, LangOpts.ObjCAutoRefCount) // FIXME: REMOVE? 125FEATURE(objc_arc, LangOpts.ObjCAutoRefCount) 126FEATURE(objc_arc_fields, true) 127FEATURE(objc_arc_weak, LangOpts.ObjCWeak) 128FEATURE(objc_default_synthesize_properties, LangOpts.ObjC) 129FEATURE(objc_fixed_enum, LangOpts.ObjC) 130FEATURE(objc_instancetype, LangOpts.ObjC) 131FEATURE(objc_kindof, LangOpts.ObjC) 132FEATURE(objc_modules, LangOpts.ObjC && LangOpts.Modules) 133FEATURE(objc_nonfragile_abi, LangOpts.ObjCRuntime.isNonFragile()) 134FEATURE(objc_property_explicit_atomic, true) 135FEATURE(objc_protocol_qualifier_mangling, true) 136FEATURE(objc_weak_class, LangOpts.ObjCRuntime.hasWeakClassImport()) 137FEATURE(ownership_holds, true) 138FEATURE(ownership_returns, true) 139FEATURE(ownership_takes, true) 140FEATURE(objc_bool, true) 141FEATURE(objc_subscripting, LangOpts.ObjCRuntime.isNonFragile()) 142FEATURE(objc_array_literals, LangOpts.ObjC) 143FEATURE(objc_dictionary_literals, LangOpts.ObjC) 144FEATURE(objc_boxed_expressions, LangOpts.ObjC) 145FEATURE(objc_boxed_nsvalue_expressions, LangOpts.ObjC) 146FEATURE(arc_cf_code_audited, true) 147FEATURE(objc_bridge_id, true) 148FEATURE(objc_bridge_id_on_typedefs, true) 149FEATURE(objc_generics, LangOpts.ObjC) 150FEATURE(objc_generics_variance, LangOpts.ObjC) 151FEATURE(objc_class_property, LangOpts.ObjC) 152FEATURE(objc_c_static_assert, LangOpts.C11) 153FEATURE(objc_cxx_static_assert, LangOpts.CPlusPlus11) 154EXTENSION(objc_c_static_assert, true) 155// C11 features 156FEATURE(c_alignas, LangOpts.C11) 157FEATURE(c_alignof, LangOpts.C11) 158FEATURE(c_atomic, LangOpts.C11) 159FEATURE(c_generic_selections, LangOpts.C11) 160FEATURE(c_static_assert, LangOpts.C11) 161FEATURE(c_thread_local, LangOpts.C11 &&PP.getTargetInfo().isTLSSupported()) 162// C++11 features 163FEATURE(cxx_access_control_sfinae, LangOpts.CPlusPlus11) 164FEATURE(cxx_alias_templates, LangOpts.CPlusPlus11) 165FEATURE(cxx_alignas, LangOpts.CPlusPlus11) 166FEATURE(cxx_alignof, LangOpts.CPlusPlus11) 167FEATURE(cxx_atomic, LangOpts.CPlusPlus11) 168FEATURE(cxx_attributes, LangOpts.CPlusPlus11) 169FEATURE(cxx_auto_type, LangOpts.CPlusPlus11) 170FEATURE(cxx_constexpr, LangOpts.CPlusPlus11) 171FEATURE(cxx_constexpr_string_builtins, LangOpts.CPlusPlus11) 172FEATURE(cxx_decltype, LangOpts.CPlusPlus11) 173FEATURE(cxx_decltype_incomplete_return_types, LangOpts.CPlusPlus11) 174FEATURE(cxx_default_function_template_args, LangOpts.CPlusPlus11) 175FEATURE(cxx_defaulted_functions, LangOpts.CPlusPlus11) 176FEATURE(cxx_delegating_constructors, LangOpts.CPlusPlus11) 177FEATURE(cxx_deleted_functions, LangOpts.CPlusPlus11) 178FEATURE(cxx_explicit_conversions, LangOpts.CPlusPlus11) 179FEATURE(cxx_generalized_initializers, LangOpts.CPlusPlus11) 180FEATURE(cxx_implicit_moves, LangOpts.CPlusPlus11) 181FEATURE(cxx_inheriting_constructors, LangOpts.CPlusPlus11) 182FEATURE(cxx_inline_namespaces, LangOpts.CPlusPlus11) 183FEATURE(cxx_lambdas, LangOpts.CPlusPlus11) 184FEATURE(cxx_local_type_template_args, LangOpts.CPlusPlus11) 185FEATURE(cxx_nonstatic_member_init, LangOpts.CPlusPlus11) 186FEATURE(cxx_noexcept, LangOpts.CPlusPlus11) 187FEATURE(cxx_nullptr, LangOpts.CPlusPlus11) 188FEATURE(cxx_override_control, LangOpts.CPlusPlus11) 189FEATURE(cxx_range_for, LangOpts.CPlusPlus11) 190FEATURE(cxx_raw_string_literals, LangOpts.CPlusPlus11) 191FEATURE(cxx_reference_qualified_functions, LangOpts.CPlusPlus11) 192FEATURE(cxx_rvalue_references, LangOpts.CPlusPlus11) 193FEATURE(cxx_strong_enums, LangOpts.CPlusPlus11) 194FEATURE(cxx_static_assert, LangOpts.CPlusPlus11) 195FEATURE(cxx_thread_local, 196 LangOpts.CPlusPlus11 &&PP.getTargetInfo().isTLSSupported()) 197FEATURE(cxx_trailing_return, LangOpts.CPlusPlus11) 198FEATURE(cxx_unicode_literals, LangOpts.CPlusPlus11) 199FEATURE(cxx_unrestricted_unions, LangOpts.CPlusPlus11) 200FEATURE(cxx_user_literals, LangOpts.CPlusPlus11) 201FEATURE(cxx_variadic_templates, LangOpts.CPlusPlus11) 202// C++14 features 203FEATURE(cxx_aggregate_nsdmi, LangOpts.CPlusPlus14) 204FEATURE(cxx_binary_literals, LangOpts.CPlusPlus14) 205FEATURE(cxx_contextual_conversions, LangOpts.CPlusPlus14) 206FEATURE(cxx_decltype_auto, LangOpts.CPlusPlus14) 207FEATURE(cxx_generic_lambdas, LangOpts.CPlusPlus14) 208FEATURE(cxx_init_captures, LangOpts.CPlusPlus14) 209FEATURE(cxx_relaxed_constexpr, LangOpts.CPlusPlus14) 210FEATURE(cxx_return_type_deduction, LangOpts.CPlusPlus14) 211FEATURE(cxx_variable_templates, LangOpts.CPlusPlus14) 212// NOTE: For features covered by SD-6, it is preferable to provide *only* 213// the SD-6 macro and not a __has_feature check. 214 215// C++ TSes 216// FEATURE(cxx_runtime_arrays, LangOpts.CPlusPlusTSArrays) 217// FEATURE(cxx_concepts, LangOpts.CPlusPlusTSConcepts) 218// FIXME: Should this be __has_feature or __has_extension? 219// FEATURE(raw_invocation_type, LangOpts.CPlusPlus) 220// Type traits 221// N.B. Additional type traits should not be added to the following list. 222// Instead, they should be detected by has_builtin. 223FEATURE(has_nothrow_assign, LangOpts.CPlusPlus) 224FEATURE(has_nothrow_copy, LangOpts.CPlusPlus) 225FEATURE(has_nothrow_constructor, LangOpts.CPlusPlus) 226FEATURE(has_trivial_assign, LangOpts.CPlusPlus) 227FEATURE(has_trivial_copy, LangOpts.CPlusPlus) 228FEATURE(has_trivial_constructor, LangOpts.CPlusPlus) 229FEATURE(has_trivial_destructor, LangOpts.CPlusPlus) 230FEATURE(has_virtual_destructor, LangOpts.CPlusPlus) 231FEATURE(is_abstract, LangOpts.CPlusPlus) 232FEATURE(is_base_of, LangOpts.CPlusPlus) 233FEATURE(is_class, LangOpts.CPlusPlus) 234FEATURE(is_constructible, LangOpts.CPlusPlus) 235FEATURE(is_convertible_to, LangOpts.CPlusPlus) 236FEATURE(is_empty, LangOpts.CPlusPlus) 237FEATURE(is_enum, LangOpts.CPlusPlus) 238FEATURE(is_final, LangOpts.CPlusPlus) 239FEATURE(is_literal, LangOpts.CPlusPlus) 240FEATURE(is_standard_layout, LangOpts.CPlusPlus) 241FEATURE(is_pod, LangOpts.CPlusPlus) 242FEATURE(is_polymorphic, LangOpts.CPlusPlus) 243FEATURE(is_sealed, LangOpts.CPlusPlus &&LangOpts.MicrosoftExt) 244FEATURE(is_trivial, LangOpts.CPlusPlus) 245FEATURE(is_trivially_assignable, LangOpts.CPlusPlus) 246FEATURE(is_trivially_constructible, LangOpts.CPlusPlus) 247FEATURE(is_trivially_copyable, LangOpts.CPlusPlus) 248FEATURE(is_union, LangOpts.CPlusPlus) 249FEATURE(kcfi, LangOpts.Sanitize.has(SanitizerKind::KCFI)) 250FEATURE(modules, LangOpts.Modules) 251FEATURE(safe_stack, LangOpts.Sanitize.has(SanitizerKind::SafeStack)) 252FEATURE(shadow_call_stack, 253 LangOpts.Sanitize.has(SanitizerKind::ShadowCallStack)) 254FEATURE(tls, PP.getTargetInfo().isTLSSupported()) 255FEATURE(underlying_type, LangOpts.CPlusPlus) 256FEATURE(experimental_library, LangOpts.ExperimentalLibrary) 257 258// C11 features supported by other languages as extensions. 259EXTENSION(c_alignas, true) 260EXTENSION(c_alignof, true) 261EXTENSION(c_atomic, true) 262EXTENSION(c_generic_selections, true) 263EXTENSION(c_generic_selection_with_controlling_type, true) 264EXTENSION(c_static_assert, true) 265EXTENSION(c_thread_local, PP.getTargetInfo().isTLSSupported()) 266// C23 features supported by other languages as extensions 267EXTENSION(c_attributes, true) 268// C++11 features supported by other languages as extensions. 269EXTENSION(cxx_atomic, LangOpts.CPlusPlus) 270EXTENSION(cxx_default_function_template_args, LangOpts.CPlusPlus) 271EXTENSION(cxx_defaulted_functions, LangOpts.CPlusPlus) 272EXTENSION(cxx_deleted_functions, LangOpts.CPlusPlus) 273EXTENSION(cxx_explicit_conversions, LangOpts.CPlusPlus) 274EXTENSION(cxx_inline_namespaces, LangOpts.CPlusPlus) 275EXTENSION(cxx_lambdas, LangOpts.CPlusPlus) 276EXTENSION(cxx_local_type_template_args, LangOpts.CPlusPlus) 277EXTENSION(cxx_nonstatic_member_init, LangOpts.CPlusPlus) 278EXTENSION(cxx_override_control, LangOpts.CPlusPlus) 279EXTENSION(cxx_range_for, LangOpts.CPlusPlus) 280EXTENSION(cxx_reference_qualified_functions, LangOpts.CPlusPlus) 281EXTENSION(cxx_rvalue_references, LangOpts.CPlusPlus) 282EXTENSION(cxx_variadic_templates, LangOpts.CPlusPlus) 283EXTENSION(cxx_fixed_enum, true) 284// C++14 features supported by other languages as extensions. 285EXTENSION(cxx_binary_literals, true) 286EXTENSION(cxx_init_captures, LangOpts.CPlusPlus11) 287EXTENSION(cxx_variable_templates, LangOpts.CPlusPlus) 288//C++20 289EXTENSION(cxx_generalized_nttp, LangOpts.CPlusPlus20) 290//C++23 291EXTENSION(cxx_explicit_this_parameter, LangOpts.CPlusPlus23) 292// Miscellaneous language extensions 293EXTENSION(overloadable_unmarked, true) 294EXTENSION(pragma_clang_attribute_namespaces, true) 295EXTENSION(pragma_clang_attribute_external_declaration, true) 296EXTENSION(statement_attributes_with_gnu_syntax, true) 297EXTENSION(gnu_asm, LangOpts.GNUAsm) 298EXTENSION(gnu_asm_goto_with_outputs, LangOpts.GNUAsm) 299EXTENSION(gnu_asm_goto_with_outputs_full, LangOpts.GNUAsm) 300EXTENSION(matrix_types, LangOpts.MatrixTypes) 301EXTENSION(matrix_types_scalar_division, true) 302EXTENSION(cxx_attributes_on_using_declarations, LangOpts.CPlusPlus11) 303EXTENSION(datasizeof, LangOpts.CPlusPlus) 304 305FEATURE(cxx_abi_relative_vtable, LangOpts.CPlusPlus && LangOpts.RelativeCXXABIVTables) 306 307// CUDA/HIP Features 308FEATURE(cuda_noinline_keyword, LangOpts.CUDA) 309EXTENSION(cuda_implicit_host_device_templates, LangOpts.CUDA && LangOpts.OffloadImplicitHostDeviceTemplates) 310 311#undef EXTENSION 312#undef FEATURE 313