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