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

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant