15#ifndef LLVM_CLANG_BASIC_BUILTINS_H
16#define LLVM_CLANG_BASIC_BUILTINS_H
18#include "llvm/ADT/ArrayRef.h"
19#include "llvm/ADT/StringMap.h"
20#include "llvm/ADT/StringRef.h"
53#define HEADER(ID, NAME) ID,
54#include "clang/Basic/BuiltinHeaders.def"
66#define BUILTIN(ID, TYPE, ATTRS) BI##ID,
67#include "clang/Basic/Builtins.inc"
115 return strchr(getRecord(
ID).Attributes,
'U') !=
nullptr;
121 return strchr(getRecord(
ID).Attributes,
'c') !=
nullptr;
126 return strchr(getRecord(
ID).Attributes,
'n') !=
nullptr;
131 return strchr(getRecord(
ID).Attributes,
'r') !=
nullptr;
136 return strchr(getRecord(
ID).Attributes,
'j') !=
nullptr;
142 return strchr(getRecord(
ID).Attributes,
'u') !=
nullptr;
148 return strchr(getRecord(
ID).Attributes,
'F') !=
nullptr;
159 return strchr(getRecord(
ID).Attributes,
'f') !=
nullptr;
166 return strchr(getRecord(
ID).Attributes,
'h') !=
nullptr;
173 return strchr(getRecord(
ID).Attributes,
'i') !=
nullptr;
181 return strchr(getRecord(
ID).Attributes,
'z') !=
nullptr;
195 return strchr(getRecord(
ID).Attributes,
't') !=
nullptr;
201 return strchr(getRecord(
ID).Attributes,
'T') !=
nullptr ||
208 return strchr(getRecord(
ID).
Type,
'*') !=
nullptr;
214 return strchr(getRecord(
ID).
Type,
'&') !=
nullptr ||
215 strchr(getRecord(
ID).
Type,
'A') !=
nullptr;
227 bool isPrintfLike(
unsigned ID,
unsigned &FormatIdx,
bool &HasVAListArg);
232 bool isScanfLike(
unsigned ID,
unsigned &FormatIdx,
bool &HasVAListArg);
246 return strchr(getRecord(
ID).Attributes,
'e') !=
nullptr;
250 return strchr(getRecord(
ID).Attributes,
'g') !=
nullptr;
278 return strchr(getRecord(
ID).Attributes,
'E') !=
nullptr;
283 return strchr(getRecord(
ID).Attributes,
'G') !=
nullptr;
287 const Info &getRecord(
unsigned ID)
const;
290 bool isLike(
unsigned ID,
unsigned &FormatIdx,
bool &HasVAListArg,
291 const char *Fmt)
const;
299 llvm::StringRef RequiredFatures,
300 const llvm::StringMap<bool> &TargetFetureMap);
llvm::MachO::Target Target
Holds information about both target-independent and target-specific builtins, allowing easy queries b...
bool isUnevaluated(unsigned ID) const
Returns true if this builtin does not perform the side-effects of its arguments.
bool hasReferenceArgsOrResult(unsigned ID) const
Return true if this builtin has a result or any arguments which are reference types.
bool performsCallback(unsigned ID, llvm::SmallVectorImpl< int > &Encoding) const
Determine whether this builtin has callback behavior (see llvm::AbstractCallSites for details).
bool isAuxBuiltinID(unsigned ID) const
Return true if builtin ID belongs to AuxTarget.
bool isLibFunction(unsigned ID) const
Return true if this is a builtin for a libc/libm function, with a "__builtin_" prefix (e....
const char * getHeaderName(unsigned ID) const
If this is a library function that comes from a specific header, retrieve that header name.
bool hasPtrArgsOrResult(unsigned ID) const
Determines whether this builtin has a result or any arguments which are pointer types.
llvm::StringRef getName(unsigned ID) const
Return the identifier name for the specified builtin, e.g.
bool isReturnsTwice(unsigned ID) const
Return true if we know this builtin can return twice.
bool isImmediate(unsigned ID) const
Returns true if this is an immediate (consteval) function.
bool isConstWithoutErrnoAndExceptions(unsigned ID) const
Return true if this function has no side effects and doesn't read memory, except for possibly errno o...
static bool isBuiltinFunc(llvm::StringRef Name)
Returns true if this is a libc/libm function without the '__builtin_' prefix.
const char * getTypeString(unsigned ID) const
Get the type descriptor string for the specified builtin.
unsigned getRequiredVectorWidth(unsigned ID) const
unsigned getAuxBuiltinID(unsigned ID) const
Return real builtin ID (i.e.
bool allowTypeMismatch(unsigned ID) const
Determines whether a declaration of this builtin should be recognized even if the type doesn't match ...
bool isTSBuiltin(unsigned ID) const
Return true if this function is a target-specific builtin.
bool hasCustomTypechecking(unsigned ID) const
Determines whether this builtin has custom typechecking.
bool isHeaderDependentFunction(unsigned ID) const
Returns true if this builtin requires appropriate header in other compilers.
void initializeBuiltins(IdentifierTable &Table, const LangOptions &LangOpts)
Mark the identifiers for all the builtins with their appropriate builtin ID # and mark any non-portab...
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...
bool isInStdNamespace(unsigned ID) const
Determines whether this builtin is a C++ standard library function that lives in (possibly-versioned)...
bool canBeRedeclared(unsigned ID) const
Returns true if this is a builtin that can be redeclared.
const char * getRequiredFeatures(unsigned ID) const
bool isConstantEvaluated(unsigned ID) const
Return true if this function can be constant evaluated by Clang frontend.
bool isPredefinedLibFunction(unsigned ID) const
Determines whether this builtin is a predefined libc/libm function, such as "malloc",...
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...
bool isNoReturn(unsigned ID) const
Return true if we know this builtin never returns.
bool isDirectlyAddressable(unsigned ID) const
Determines whether this builtin can have its address taken with no special action required.
bool isConstWithoutExceptions(unsigned ID) const
bool isPredefinedRuntimeFunction(unsigned ID) const
Determines whether this builtin is a predefined compiler-rt/libgcc function, such as "__clear_cache",...
bool isPure(unsigned ID) const
Return true if this function has no side effects.
bool isNoThrow(unsigned ID) const
Return true if we know this builtin never throws an exception.
void InitializeTarget(const TargetInfo &Target, const TargetInfo *AuxTarget)
Perform target-specific initialization.
bool isConst(unsigned ID) const
Return true if this function has no side effects and doesn't read memory.
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.
The base class of the type hierarchy.
bool evaluateRequiredTargetFeatures(llvm::StringRef RequiredFatures, const llvm::StringMap< bool > &TargetFetureMap)
Returns true if the required target features of a builtin function are enabled.
The JSON file list parser is used to communicate input to InstallAPI.
BuiltinTemplateKind
Kinds of BuiltinTemplateDecl.
@ BTK__type_pack_element
This names the __type_pack_element BuiltinTemplateDecl.
@ BTK__builtin_common_type
This names the __builtin_common_type BuiltinTemplateDecl.
@ BTK__make_integer_seq
This names the __make_integer_seq BuiltinTemplateDecl.