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