clang 22.0.0git
Builtins.h
Go to the documentation of this file.
1//===--- Builtins.h - Builtin function header -------------------*- 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/// \file
10/// Defines enum values for all the target-independent builtin
11/// functions.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CLANG_BASIC_BUILTINS_H
16#define LLVM_CLANG_BASIC_BUILTINS_H
17
18#include "llvm/ADT/ArrayRef.h"
19#include "llvm/ADT/StringMap.h"
20#include "llvm/ADT/StringRef.h"
21#include "llvm/ADT/StringTable.h"
22#include <cstring>
23
24// VC++ defines 'alloca' as an object-like macro, which interferes with our
25// builtins.
26#undef alloca
27
28namespace clang {
29class TargetInfo;
30class IdentifierTable;
31class LangOptions;
32
33enum LanguageID : uint16_t {
34 GNU_LANG = 0x1, // builtin requires GNU mode.
35 C_LANG = 0x2, // builtin for c only.
36 CXX_LANG = 0x4, // builtin for cplusplus only.
37 OBJC_LANG = 0x8, // builtin for objective-c and objective-c++
38 MS_LANG = 0x10, // builtin requires MS mode.
39 OMP_LANG = 0x20, // builtin requires OpenMP.
40 CUDA_LANG = 0x40, // builtin requires CUDA.
41 COR_LANG = 0x80, // builtin requires use of 'fcoroutine-ts' option.
42 OCL_GAS = 0x100, // builtin requires OpenCL generic address space.
43 OCL_PIPE = 0x200, // builtin requires OpenCL pipe.
44 OCL_DSE = 0x400, // builtin requires OpenCL device side enqueue.
45 ALL_OCL_LANGUAGES = 0x800, // builtin for OCL languages.
46 HLSL_LANG = 0x1000, // builtin requires HLSL.
47 C23_LANG = 0x2000, // builtin requires C23 or later.
48 ALL_LANGUAGES = C_LANG | CXX_LANG | OBJC_LANG, // builtin for all languages.
49 ALL_GNU_LANGUAGES = ALL_LANGUAGES | GNU_LANG, // builtin requires GNU mode.
50 ALL_MS_LANGUAGES = ALL_LANGUAGES | MS_LANG // builtin requires MS mode.
51};
52
53struct HeaderDesc {
54 enum HeaderID : uint16_t {
55#define HEADER(ID, NAME) ID,
56#include "clang/Basic/BuiltinHeaders.def"
57#undef HEADER
58 } ID;
59
60 constexpr HeaderDesc() : ID() {}
61 constexpr HeaderDesc(HeaderID ID) : ID(ID) {}
62
63 const char *getName() const;
64};
65
66namespace Builtin {
67enum ID {
68 NotBuiltin = 0, // This is not a builtin function.
69#define GET_BUILTIN_ENUMERATORS
70#include "clang/Basic/Builtins.inc"
71#undef GET_BUILTIN_ENUMERATORS
73};
74
75struct InfosShard;
76
77/// The info used to represent each builtin.
78struct Info {
79 // Rather than store pointers to the string literals describing these four
80 // aspects of builtins, we store offsets into a common string table.
81 struct StrOffsets {
82 llvm::StringTable::Offset Name = {};
83 llvm::StringTable::Offset Type = {};
84 llvm::StringTable::Offset Attributes = {};
85
86 // Defaults to the empty string offset.
87 llvm::StringTable::Offset Features = {};
89
90 HeaderDesc Header = HeaderDesc::NO_HEADER;
92
93 /// Get the name for the builtin represented by this `Info` object.
94 ///
95 /// Must be provided the `Shard` for this `Info` object.
96 std::string getName(const InfosShard &Shard) const;
97};
98
99/// A constexpr function to construct an infos array from X-macros.
100///
101/// The input array uses the same data structure, but the offsets are actually
102/// _lengths_ when input. This is all we can compute from the X-macro approach
103/// to builtins. This function will convert these lengths into actual offsets to
104/// a string table built up through sequentially appending strings with the
105/// given lengths.
106template <size_t N>
107static constexpr std::array<Info, N> MakeInfos(std::array<Info, N> Infos) {
108 // Translate lengths to offsets. We start past the initial empty string at
109 // offset zero.
110 unsigned Offset = 1;
111 for (Info &I : Infos) {
112 Info::StrOffsets NewOffsets = {};
113 NewOffsets.Name = Offset;
114 Offset += I.Offsets.Name.value();
115 NewOffsets.Type = Offset;
116 Offset += I.Offsets.Type.value();
117 NewOffsets.Attributes = Offset;
118 Offset += I.Offsets.Attributes.value();
119 NewOffsets.Features = Offset;
120 Offset += I.Offsets.Features.value();
121 I.Offsets = NewOffsets;
122 }
123 return Infos;
124}
125
126/// A shard of a target's builtins string table and info.
127///
128/// Target builtins are sharded across multiple tables due to different
129/// structures, origins, and also to improve the overall scaling by avoiding a
130/// single table across all builtins.
132 const llvm::StringTable *Strings;
134
135 llvm::StringLiteral NamePrefix = "";
136};
137
138// A detail macro used below to emit a string literal that, after string literal
139// concatenation, ends up triggering the `-Woverlength-strings` warning. While
140// the warning is useful in general to catch accidentally excessive strings,
141// here we are creating them intentionally.
142//
143// This relies on a subtle aspect of `_Pragma`: that the *diagnostic* ones don't
144// turn into actual tokens that would disrupt string literal concatenation.
145#ifdef __clang__
146#define CLANG_BUILTIN_DETAIL_STR_TABLE(S) \
147 _Pragma("clang diagnostic push") \
148 _Pragma("clang diagnostic ignored \"-Woverlength-strings\"") \
149 S _Pragma("clang diagnostic pop")
150#else
151#define CLANG_BUILTIN_DETAIL_STR_TABLE(S) S
152#endif
153
154// We require string tables to start with an empty string so that a `0` offset
155// can always be used to refer to an empty string. To satisfy that when building
156// string tables with X-macros, we use this start macro prior to expanding the
157// X-macros.
158#define CLANG_BUILTIN_STR_TABLE_START CLANG_BUILTIN_DETAIL_STR_TABLE("\0")
159
160// A macro that can be used with `Builtins.def` and similar files as an X-macro
161// to add the string arguments to a builtin string table. This is typically the
162// target for the `BUILTIN`, `LANGBUILTIN`, or `LIBBUILTIN` macros in those
163// files.
164#define CLANG_BUILTIN_STR_TABLE(ID, TYPE, ATTRS) \
165 CLANG_BUILTIN_DETAIL_STR_TABLE(#ID "\0" TYPE "\0" ATTRS "\0" /*FEATURE*/ "\0")
166
167// A macro that can be used with target builtin `.def` and `.inc` files as an
168// X-macro to add the string arguments to a builtin string table. this is
169// typically the target for the `TARGET_BUILTIN` macro.
170#define CLANG_TARGET_BUILTIN_STR_TABLE(ID, TYPE, ATTRS, FEATURE) \
171 CLANG_BUILTIN_DETAIL_STR_TABLE(#ID "\0" TYPE "\0" ATTRS "\0" FEATURE "\0")
172
173// A macro that can be used with target builtin `.def` and `.inc` files as an
174// X-macro to add the string arguments to a builtin string table. this is
175// typically the target for the `TARGET_HEADER_BUILTIN` macro. We can't delegate
176// to `TARGET_BUILTIN` because the `FEATURE` string changes position.
177#define CLANG_TARGET_HEADER_BUILTIN_STR_TABLE(ID, TYPE, ATTRS, HEADER, LANGS, \
178 FEATURE) \
179 CLANG_BUILTIN_DETAIL_STR_TABLE(#ID "\0" TYPE "\0" ATTRS "\0" FEATURE "\0")
180
181// A detail macro used internally to compute the desired string table
182// `StrOffsets` struct for arguments to `MakeInfos`.
183#define CLANG_BUILTIN_DETAIL_STR_OFFSETS(ID, TYPE, ATTRS) \
184 Builtin::Info::StrOffsets { \
185 sizeof(#ID), sizeof(TYPE), sizeof(ATTRS), sizeof("") \
186 }
187
188// A detail macro used internally to compute the desired string table
189// `StrOffsets` struct for arguments to `Storage::Make`.
190#define CLANG_TARGET_BUILTIN_DETAIL_STR_OFFSETS(ID, TYPE, ATTRS, FEATURE) \
191 Builtin::Info::StrOffsets { \
192 sizeof(#ID), sizeof(TYPE), sizeof(ATTRS), sizeof(FEATURE) \
193 }
194
195// A set of macros that can be used with builtin `.def' files as an X-macro to
196// create an `Info` struct for a particular builtin. It both computes the
197// `StrOffsets` value for the string table (the lengths here, translated to
198// offsets by the `MakeInfos` function), and the other metadata for each
199// builtin.
200//
201// There is a corresponding macro for each of `BUILTIN`, `LANGBUILTIN`,
202// `LIBBUILTIN`, `TARGET_BUILTIN`, and `TARGET_HEADER_BUILTIN`.
203#define CLANG_BUILTIN_ENTRY(ID, TYPE, ATTRS) \
204 Builtin::Info{CLANG_BUILTIN_DETAIL_STR_OFFSETS(ID, TYPE, ATTRS), \
205 HeaderDesc::NO_HEADER, ALL_LANGUAGES},
206#define CLANG_LANGBUILTIN_ENTRY(ID, TYPE, ATTRS, LANG) \
207 Builtin::Info{CLANG_BUILTIN_DETAIL_STR_OFFSETS(ID, TYPE, ATTRS), \
208 HeaderDesc::NO_HEADER, LANG},
209#define CLANG_LIBBUILTIN_ENTRY(ID, TYPE, ATTRS, HEADER, LANG) \
210 Builtin::Info{CLANG_BUILTIN_DETAIL_STR_OFFSETS(ID, TYPE, ATTRS), \
211 HeaderDesc::HEADER, LANG},
212#define CLANG_TARGET_BUILTIN_ENTRY(ID, TYPE, ATTRS, FEATURE) \
213 Builtin::Info{ \
214 CLANG_TARGET_BUILTIN_DETAIL_STR_OFFSETS(ID, TYPE, ATTRS, FEATURE), \
215 HeaderDesc::NO_HEADER, ALL_LANGUAGES},
216#define CLANG_TARGET_HEADER_BUILTIN_ENTRY(ID, TYPE, ATTRS, HEADER, LANG, \
217 FEATURE) \
218 Builtin::Info{ \
219 CLANG_TARGET_BUILTIN_DETAIL_STR_OFFSETS(ID, TYPE, ATTRS, FEATURE), \
220 HeaderDesc::HEADER, LANG},
221
222/// Holds information about both target-independent and
223/// target-specific builtins, allowing easy queries by clients.
224///
225/// Builtins from an optional auxiliary target are stored in
226/// AuxTSRecords. Their IDs are shifted up by TSRecords.size() and need to
227/// be translated back with getAuxBuiltinID() before use.
228class Context {
229 llvm::SmallVector<InfosShard> BuiltinShards;
230
232 llvm::SmallVector<InfosShard> AuxTargetShards;
233
234 unsigned NumTargetBuiltins = 0;
235 unsigned NumAuxTargetBuiltins = 0;
236
237public:
238 Context();
239
240 /// Perform target-specific initialization
241 /// \param AuxTarget Target info to incorporate builtins from. May be nullptr.
242 void InitializeTarget(const TargetInfo &Target, const TargetInfo *AuxTarget);
243
244 /// Mark the identifiers for all the builtins with their
245 /// appropriate builtin ID # and mark any non-portable builtin identifiers as
246 /// such.
247 void initializeBuiltins(IdentifierTable &Table, const LangOptions& LangOpts);
248
249 /// Return the identifier name for the specified builtin,
250 /// e.g. "__builtin_abs".
251 std::string getName(unsigned ID) const;
252
253 /// Return the identifier name for the specified builtin inside single quotes
254 /// for a diagnostic, e.g. "'__builtin_abs'".
255 std::string getQuotedName(unsigned ID) const;
256
257 /// Get the type descriptor string for the specified builtin.
258 const char *getTypeString(unsigned ID) const;
259
260 /// Get the attributes descriptor string for the specified builtin.
261 const char *getAttributesString(unsigned ID) const;
262
263 /// Return true if this function is a target-specific builtin.
264 bool isTSBuiltin(unsigned ID) const {
265 return ID >= Builtin::FirstTSBuiltin;
266 }
267
268 /// Return true if this function has no side effects.
269 bool isPure(unsigned ID) const {
270 return strchr(getAttributesString(ID), 'U') != nullptr;
271 }
272
273 /// Return true if this function has no side effects and doesn't
274 /// read memory.
275 bool isConst(unsigned ID) const {
276 return strchr(getAttributesString(ID), 'c') != nullptr;
277 }
278
279 /// Return true if we know this builtin never throws an exception.
280 bool isNoThrow(unsigned ID) const {
281 return strchr(getAttributesString(ID), 'n') != nullptr;
282 }
283
284 /// Return true if we know this builtin never returns.
285 bool isNoReturn(unsigned ID) const {
286 return strchr(getAttributesString(ID), 'r') != nullptr;
287 }
288
289 /// Return true if we know this builtin can return twice.
290 bool isReturnsTwice(unsigned ID) const {
291 return strchr(getAttributesString(ID), 'j') != nullptr;
292 }
293
294 /// Returns true if this builtin does not perform the side-effects
295 /// of its arguments.
296 bool isUnevaluated(unsigned ID) const {
297 return strchr(getAttributesString(ID), 'u') != nullptr;
298 }
299
300 /// Return true if this is a builtin for a libc/libm function,
301 /// with a "__builtin_" prefix (e.g. __builtin_abs).
302 bool isLibFunction(unsigned ID) const {
303 return strchr(getAttributesString(ID), 'F') != nullptr;
304 }
305
306 /// Determines whether this builtin is a predefined libc/libm
307 /// function, such as "malloc", where we know the signature a
308 /// priori.
309 /// In C, such functions behave as if they are predeclared,
310 /// possibly with a warning on first use. In Objective-C and C++,
311 /// they do not, but they are recognized as builtins once we see
312 /// a declaration.
313 bool isPredefinedLibFunction(unsigned ID) const {
314 return strchr(getAttributesString(ID), 'f') != nullptr;
315 }
316
317 /// Returns true if this builtin requires appropriate header in other
318 /// compilers. In Clang it will work even without including it, but we can emit
319 /// a warning about missing header.
320 bool isHeaderDependentFunction(unsigned ID) const {
321 return strchr(getAttributesString(ID), 'h') != nullptr;
322 }
323
324 /// Determines whether this builtin is a predefined compiler-rt/libgcc
325 /// function, such as "__clear_cache", where we know the signature a
326 /// priori.
327 bool isPredefinedRuntimeFunction(unsigned ID) const {
328 return strchr(getAttributesString(ID), 'i') != nullptr;
329 }
330
331 /// Determines whether this builtin is a C++ standard library function
332 /// that lives in (possibly-versioned) namespace std, possibly a template
333 /// specialization, where the signature is determined by the standard library
334 /// declaration.
335 bool isInStdNamespace(unsigned ID) const {
336 return strchr(getAttributesString(ID), 'z') != nullptr;
337 }
338
339 /// Determines whether this builtin can have its address taken with no
340 /// special action required.
341 bool isDirectlyAddressable(unsigned ID) const {
342 // Most standard library functions can have their addresses taken. C++
343 // standard library functions formally cannot in C++20 onwards, and when
344 // we allow it, we need to ensure we instantiate a definition.
346 }
347
348 /// Determines whether this builtin has custom typechecking.
349 bool hasCustomTypechecking(unsigned ID) const {
350 return strchr(getAttributesString(ID), 't') != nullptr;
351 }
352
353 /// Determines whether a declaration of this builtin should be recognized
354 /// even if the type doesn't match the specified signature.
355 bool allowTypeMismatch(unsigned ID) const {
356 return strchr(getAttributesString(ID), 'T') != nullptr ||
358 }
359
360 /// Determines whether this builtin has a result or any arguments which
361 /// are pointer types.
362 bool hasPtrArgsOrResult(unsigned ID) const {
363 return strchr(getTypeString(ID), '*') != nullptr;
364 }
365
366 /// Return true if this builtin has a result or any arguments which are
367 /// reference types.
368 bool hasReferenceArgsOrResult(unsigned ID) const {
369 return strchr(getTypeString(ID), '&') != nullptr ||
370 strchr(getTypeString(ID), 'A') != nullptr;
371 }
372
373 /// If this is a library function that comes from a specific
374 /// header, retrieve that header name.
375 const char *getHeaderName(unsigned ID) const {
376 return getInfo(ID).Header.getName();
377 }
378
379 /// Determine whether this builtin is like printf in its
380 /// formatting rules and, if so, set the index to the format string
381 /// argument and whether this function as a va_list argument.
382 bool isPrintfLike(unsigned ID, unsigned &FormatIdx, bool &HasVAListArg);
383
384 /// Determine whether this builtin is like scanf in its
385 /// formatting rules and, if so, set the index to the format string
386 /// argument and whether this function as a va_list argument.
387 bool isScanfLike(unsigned ID, unsigned &FormatIdx, bool &HasVAListArg);
388
389 /// Determine whether this builtin has callback behavior (see
390 /// llvm::AbstractCallSites for details). If so, add the index to the
391 /// callback callee argument and the callback payload arguments.
392 bool performsCallback(unsigned ID,
393 llvm::SmallVectorImpl<int> &Encoding) const;
394
395 /// Return true if this function has no side effects and doesn't
396 /// read memory, except for possibly errno or raising FP exceptions.
397 ///
398 /// Such functions can be const when the MathErrno lang option and FP
399 /// exceptions are disabled.
401 return strchr(getAttributesString(ID), 'e') != nullptr;
402 }
403
404 bool isConstWithoutExceptions(unsigned ID) const {
405 return strchr(getAttributesString(ID), 'g') != nullptr;
406 }
407
408 const char *getRequiredFeatures(unsigned ID) const;
409
410 unsigned getRequiredVectorWidth(unsigned ID) const;
411
412 /// Return true if the builtin ID belongs exclusively to the AuxTarget,
413 /// and false if it belongs to both primary and aux target, or neither.
414 bool isAuxBuiltinID(unsigned ID) const {
415 return ID >= (Builtin::FirstTSBuiltin + NumTargetBuiltins);
416 }
417
418 /// Return real builtin ID (i.e. ID it would have during compilation
419 /// for AuxTarget).
420 unsigned getAuxBuiltinID(unsigned ID) const { return ID - NumTargetBuiltins; }
421
422 /// Returns true if this is a libc/libm function without the '__builtin_'
423 /// prefix.
424 static bool isBuiltinFunc(llvm::StringRef Name);
425
426 /// Returns true if this is a builtin that can be redeclared. Returns true
427 /// for non-builtins.
428 bool canBeRedeclared(unsigned ID) const;
429
430 /// Return true if this function can be constant evaluated by Clang frontend.
431 bool isConstantEvaluated(unsigned ID) const {
432 return strchr(getAttributesString(ID), 'E') != nullptr;
433 }
434
435 /// Returns true if this is an immediate (consteval) function
436 bool isImmediate(unsigned ID) const {
437 return strchr(getAttributesString(ID), 'G') != nullptr;
438 }
439
440private:
441 std::pair<const InfosShard &, const Info &>
442 getShardAndInfo(unsigned ID) const;
443
444 const Info &getInfo(unsigned ID) const { return getShardAndInfo(ID).second; }
445
446 /// Helper function for isPrintfLike and isScanfLike.
447 bool isLike(unsigned ID, unsigned &FormatIdx, bool &HasVAListArg,
448 const char *Fmt) const;
449};
450
451/// Returns true if the required target features of a builtin function are
452/// enabled.
453/// \p TargetFeatureMap maps a target feature to true if it is enabled and
454/// false if it is disabled.
456 llvm::StringRef RequiredFatures,
457 const llvm::StringMap<bool> &TargetFetureMap);
458
459} // namespace Builtin
460
461/// Kinds of BuiltinTemplateDecl.
463#define BuiltinTemplate(BTName) BTK##BTName,
464#include "clang/Basic/BuiltinTemplates.inc"
465};
466
467} // end namespace clang
468#endif
llvm::MachO::Target Target
Definition: MachO.h:51
Holds information about both target-independent and target-specific builtins, allowing easy queries b...
Definition: Builtins.h:228
bool isUnevaluated(unsigned ID) const
Returns true if this builtin does not perform the side-effects of its arguments.
Definition: Builtins.h:296
std::string getQuotedName(unsigned ID) const
Return the identifier name for the specified builtin inside single quotes for a diagnostic,...
Definition: Builtins.cpp:85
bool hasReferenceArgsOrResult(unsigned ID) const
Return true if this builtin has a result or any arguments which are reference types.
Definition: Builtins.h:368
bool performsCallback(unsigned ID, llvm::SmallVectorImpl< int > &Encoding) const
Determine whether this builtin has callback behavior (see llvm::AbstractCallSites for details).
Definition: Builtins.cpp:296
bool isAuxBuiltinID(unsigned ID) const
Return true if the builtin ID belongs exclusively to the AuxTarget, and false if it belongs to both p...
Definition: Builtins.h:414
bool isLibFunction(unsigned ID) const
Return true if this is a builtin for a libc/libm function, with a "__builtin_" prefix (e....
Definition: Builtins.h:302
const char * getHeaderName(unsigned ID) const
If this is a library function that comes from a specific header, retrieve that header name.
Definition: Builtins.h:375
bool hasPtrArgsOrResult(unsigned ID) const
Determines whether this builtin has a result or any arguments which are pointer types.
Definition: Builtins.h:362
bool isReturnsTwice(unsigned ID) const
Return true if we know this builtin can return twice.
Definition: Builtins.h:290
bool isImmediate(unsigned ID) const
Returns true if this is an immediate (consteval) function.
Definition: Builtins.h:436
bool isConstWithoutErrnoAndExceptions(unsigned ID) const
Return true if this function has no side effects and doesn't read memory, except for possibly errno o...
Definition: Builtins.h:400
static bool isBuiltinFunc(llvm::StringRef Name)
Returns true if this is a libc/libm function without the '__builtin_' prefix.
Definition: Builtins.cpp:123
unsigned getRequiredVectorWidth(unsigned ID) const
Definition: Builtins.cpp:247
unsigned getAuxBuiltinID(unsigned ID) const
Return real builtin ID (i.e.
Definition: Builtins.h:420
bool allowTypeMismatch(unsigned ID) const
Determines whether a declaration of this builtin should be recognized even if the type doesn't match ...
Definition: Builtins.h:355
bool isTSBuiltin(unsigned ID) const
Return true if this function is a target-specific builtin.
Definition: Builtins.h:264
bool hasCustomTypechecking(unsigned ID) const
Determines whether this builtin has custom typechecking.
Definition: Builtins.h:349
std::string getName(unsigned ID) const
Return the identifier name for the specified builtin, e.g.
Definition: Builtins.cpp:80
bool isHeaderDependentFunction(unsigned ID) const
Returns true if this builtin requires appropriate header in other compilers.
Definition: Builtins.h:320
void initializeBuiltins(IdentifierTable &Table, const LangOptions &LangOpts)
Mark the identifiers for all the builtins with their appropriate builtin ID # and mark any non-portab...
Definition: Builtins.cpp:203
bool isScanfLike(unsigned ID, unsigned &FormatIdx, bool &HasVAListArg)
Determine whether this builtin is like scanf in its formatting rules and, if so, set the index to the...
Definition: Builtins.cpp:291
bool isInStdNamespace(unsigned ID) const
Determines whether this builtin is a C++ standard library function that lives in (possibly-versioned)...
Definition: Builtins.h:335
bool canBeRedeclared(unsigned ID) const
Returns true if this is a builtin that can be redeclared.
Definition: Builtins.cpp:323
const char * getAttributesString(unsigned ID) const
Get the attributes descriptor string for the specified builtin.
Definition: Builtins.cpp:97
bool isConstantEvaluated(unsigned ID) const
Return true if this function can be constant evaluated by Clang frontend.
Definition: Builtins.h:431
bool isPredefinedLibFunction(unsigned ID) const
Determines whether this builtin is a predefined libc/libm function, such as "malloc",...
Definition: Builtins.h:313
bool isPrintfLike(unsigned ID, unsigned &FormatIdx, bool &HasVAListArg)
Determine whether this builtin is like printf in its formatting rules and, if so, set the index to th...
Definition: Builtins.cpp:286
const char * getTypeString(unsigned ID) const
Get the type descriptor string for the specified builtin.
Definition: Builtins.cpp:92
bool isNoReturn(unsigned ID) const
Return true if we know this builtin never returns.
Definition: Builtins.h:285
const char * getRequiredFeatures(unsigned ID) const
Definition: Builtins.cpp:102
bool isDirectlyAddressable(unsigned ID) const
Determines whether this builtin can have its address taken with no special action required.
Definition: Builtins.h:341
bool isConstWithoutExceptions(unsigned ID) const
Definition: Builtins.h:404
bool isPredefinedRuntimeFunction(unsigned ID) const
Determines whether this builtin is a predefined compiler-rt/libgcc function, such as "__clear_cache",...
Definition: Builtins.h:327
bool isPure(unsigned ID) const
Return true if this function has no side effects.
Definition: Builtins.h:269
bool isNoThrow(unsigned ID) const
Return true if we know this builtin never throws an exception.
Definition: Builtins.h:280
void InitializeTarget(const TargetInfo &Target, const TargetInfo *AuxTarget)
Perform target-specific initialization.
Definition: Builtins.cpp:109
bool isConst(unsigned ID) const
Return true if this function has no side effects and doesn't read memory.
Definition: Builtins.h:275
Implements an efficient mapping from strings to IdentifierInfo nodes.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:434
Exposes information about the current target.
Definition: TargetInfo.h:226
The base class of the type hierarchy.
Definition: TypeBase.h:1833
bool evaluateRequiredTargetFeatures(llvm::StringRef RequiredFatures, const llvm::StringMap< bool > &TargetFetureMap)
Returns true if the required target features of a builtin function are enabled.
static constexpr std::array< Info, N > MakeInfos(std::array< Info, N > Infos)
A constexpr function to construct an infos array from X-macros.
Definition: Builtins.h:107
The JSON file list parser is used to communicate input to InstallAPI.
LanguageID
Definition: Builtins.h:33
@ ALL_LANGUAGES
Definition: Builtins.h:48
@ MS_LANG
Definition: Builtins.h:38
@ CUDA_LANG
Definition: Builtins.h:40
@ OMP_LANG
Definition: Builtins.h:39
@ CXX_LANG
Definition: Builtins.h:36
@ OBJC_LANG
Definition: Builtins.h:37
@ OCL_DSE
Definition: Builtins.h:44
@ C_LANG
Definition: Builtins.h:35
@ C23_LANG
Definition: Builtins.h:47
@ ALL_OCL_LANGUAGES
Definition: Builtins.h:45
@ HLSL_LANG
Definition: Builtins.h:46
@ OCL_GAS
Definition: Builtins.h:42
@ ALL_GNU_LANGUAGES
Definition: Builtins.h:49
@ ALL_MS_LANGUAGES
Definition: Builtins.h:50
@ GNU_LANG
Definition: Builtins.h:34
@ COR_LANG
Definition: Builtins.h:41
@ OCL_PIPE
Definition: Builtins.h:43
BuiltinTemplateKind
Kinds of BuiltinTemplateDecl.
Definition: Builtins.h:462
llvm::StringTable::Offset Name
Definition: Builtins.h:82
llvm::StringTable::Offset Features
Definition: Builtins.h:87
llvm::StringTable::Offset Attributes
Definition: Builtins.h:84
llvm::StringTable::Offset Type
Definition: Builtins.h:83
The info used to represent each builtin.
Definition: Builtins.h:78
HeaderDesc Header
Definition: Builtins.h:90
LanguageID Langs
Definition: Builtins.h:91
struct clang::Builtin::Info::StrOffsets Offsets
std::string getName(const InfosShard &Shard) const
Get the name for the builtin represented by this Info object.
Definition: Builtins.cpp:74
A shard of a target's builtins string table and info.
Definition: Builtins.h:131
const llvm::StringTable * Strings
Definition: Builtins.h:132
llvm::StringLiteral NamePrefix
Definition: Builtins.h:135
llvm::ArrayRef< Info > Infos
Definition: Builtins.h:133
const char * getName() const
Definition: Builtins.cpp:21
constexpr HeaderDesc()
Definition: Builtins.h:60
enum clang::HeaderDesc::HeaderID ID
constexpr HeaderDesc(HeaderID ID)
Definition: Builtins.h:61