clang API Documentation
Holds information about both target-independent and target-specific builtins, allowing easy queries by clients. More...
#include <Builtins.h>
Public Member Functions | |
Context () | |
void | InitializeTarget (const TargetInfo &Target) |
Perform target-specific initialization. | |
void | InitializeBuiltins (IdentifierTable &Table, const LangOptions &LangOpts) |
Mark the identifiers for all the builtins with their appropriate builtin ID # and mark any non-portable builtin identifiers as such. | |
void | GetBuiltinNames (SmallVectorImpl< const char * > &Names) |
Populate the vector with the names of all of the builtins. | |
const char * | GetName (unsigned ID) const |
Return the identifier name for the specified builtin, e.g. "__builtin_abs". | |
const char * | GetTypeString (unsigned ID) const |
Get the type descriptor string for the specified builtin. | |
bool | isConst (unsigned ID) const |
Return true if this function has no side effects and doesn't read memory. | |
bool | isNoThrow (unsigned ID) const |
Return true if we know this builtin never throws an exception. | |
bool | isNoReturn (unsigned ID) const |
Return true if we know this builtin never returns. | |
bool | isReturnsTwice (unsigned ID) const |
Return true if we know this builtin can return twice. | |
bool | isUnevaluated (unsigned ID) const |
Returns true if this builtin does not perform the side-effects of its arguments. | |
bool | isLibFunction (unsigned ID) const |
Return true if this is a builtin for a libc/libm function, with a "__builtin_" prefix (e.g. __builtin_abs). | |
bool | isPredefinedLibFunction (unsigned ID) const |
Determines whether this builtin is a predefined libc/libm function, such as "malloc", where we know the signature a priori. | |
bool | isPredefinedRuntimeFunction (unsigned ID) const |
Determines whether this builtin is a predefined compiler-rt/libgcc function, such as "__clear_cache", where we know the signature a priori. | |
bool | hasCustomTypechecking (unsigned ID) const |
Determines whether this builtin has custom typechecking. | |
void | ForgetBuiltin (unsigned ID, IdentifierTable &Table) |
Completely forget that the given ID was ever considered a builtin, e.g., because the user provided a conflicting signature. | |
const char * | getHeaderName (unsigned ID) const |
If this is a library function that comes from a specific header, retrieve that header name. | |
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 the format string argument and whether this function as a va_list argument. | |
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 format string argument and whether this function as a va_list argument. | |
bool | isConstWithoutErrno (unsigned ID) const |
Return true if this function has no side effects and doesn't read memory, except for possibly errno. |
Holds information about both target-independent and target-specific builtins, allowing easy queries by clients.
Definition at line 66 of file Builtins.h.
Definition at line 38 of file Builtins.cpp.
void Builtin::Context::ForgetBuiltin | ( | unsigned | ID, |
IdentifierTable & | Table | ||
) |
Completely forget that the given ID was ever considered a builtin, e.g., because the user provided a conflicting signature.
Definition at line 96 of file Builtins.cpp.
References clang::IdentifierTable::get(), and clang::IdentifierInfo::setBuiltinID().
Referenced by clang::Sema::CheckFunctionDeclaration().
void Builtin::Context::GetBuiltinNames | ( | SmallVectorImpl< const char * > & | Names | ) |
Populate the vector with the names of all of the builtins.
Definition at line 84 of file Builtins.cpp.
References clang::Builtin::NotBuiltin.
const char* clang::Builtin::Context::getHeaderName | ( | unsigned | ID | ) | const [inline] |
If this is a library function that comes from a specific header, retrieve that header name.
Definition at line 152 of file Builtins.h.
References clang::Builtin::Info::HeaderName.
Referenced by emitReplacement(), and clang::Sema::LazilyCreateBuiltin().
const char* clang::Builtin::Context::GetName | ( | unsigned | ID | ) | const [inline] |
Return the identifier name for the specified builtin, e.g. "__builtin_abs".
Definition at line 85 of file Builtins.h.
References clang::Builtin::Info::Name.
Referenced by emitReplacement(), clang::CodeGen::CodeGenModule::getBuiltinLibFunction(), clang::ento::CheckerContext::isCLibraryFunction(), and clang::Sema::LazilyCreateBuiltin().
const char* clang::Builtin::Context::GetTypeString | ( | unsigned | ID | ) | const [inline] |
Get the type descriptor string for the specified builtin.
Definition at line 90 of file Builtins.h.
References clang::Builtin::Info::Type.
Referenced by clang::ASTContext::GetBuiltinType().
bool clang::Builtin::Context::hasCustomTypechecking | ( | unsigned | ID | ) | const [inline] |
Determines whether this builtin has custom typechecking.
Definition at line 142 of file Builtins.h.
Referenced by clang::Sema::BuildResolvedCallExpr(), and clang::Sema::ConvertArgumentsForCall().
void Builtin::Context::InitializeBuiltins | ( | IdentifierTable & | Table, |
const LangOptions & | LangOpts | ||
) |
Mark the identifiers for all the builtins with their appropriate builtin ID # and mark any non-portable builtin identifiers as such.
InitializeBuiltins - Mark the identifiers for all the builtins with their appropriate builtin ID # and mark any non-portable builtin identifiers as such.
Definition at line 69 of file Builtins.cpp.
References clang::IdentifierTable::get(), clang::Builtin::NotBuiltin, and clang::IdentifierInfo::setBuiltinID().
Referenced by clang::FrontendAction::BeginSourceFile(), and clang::createChainedIncludesSource().
void Builtin::Context::InitializeTarget | ( | const TargetInfo & | Target | ) |
Perform target-specific initialization.
Definition at line 44 of file Builtins.cpp.
References clang::TargetInfo::getTargetBuiltins().
bool clang::Builtin::Context::isConst | ( | unsigned | ID | ) | const [inline] |
Return true if this function has no side effects and doesn't read memory.
Definition at line 96 of file Builtins.h.
Referenced by clang::Sema::AddKnownFunctionAttributes().
bool clang::Builtin::Context::isConstWithoutErrno | ( | unsigned | ID | ) | const [inline] |
Return true if this function has no side effects and doesn't read memory, except for possibly errno.
Such functions can be const when the MathErrno lang option is disabled.
Definition at line 170 of file Builtins.h.
Referenced by clang::Sema::AddKnownFunctionAttributes().
bool clang::Builtin::Context::isLibFunction | ( | unsigned | ID | ) | const [inline] |
Return true if this is a builtin for a libc/libm function, with a "__builtin_" prefix (e.g. __builtin_abs).
Definition at line 123 of file Builtins.h.
Referenced by clang::CodeGen::CodeGenModule::getBuiltinLibFunction().
bool clang::Builtin::Context::isNoReturn | ( | unsigned | ID | ) | const [inline] |
Return true if we know this builtin never returns.
Definition at line 106 of file Builtins.h.
Referenced by clang::ASTContext::GetBuiltinType().
bool clang::Builtin::Context::isNoThrow | ( | unsigned | ID | ) | const [inline] |
Return true if we know this builtin never throws an exception.
Definition at line 101 of file Builtins.h.
Referenced by clang::Sema::AddKnownFunctionAttributes().
bool clang::Builtin::Context::isPredefinedLibFunction | ( | unsigned | ID | ) | const [inline] |
Determines whether this builtin is a predefined libc/libm function, such as "malloc", where we know the signature a priori.
Definition at line 130 of file Builtins.h.
Referenced by clang::Sema::ActOnStartOfFunctionDef(), clang::Sema::BuildDeclarationNameExpr(), clang::FunctionDecl::getBuiltinID(), clang::Sema::LazilyCreateBuiltin(), LookupBuiltin(), clang::Sema::LookupInObjCMethod(), and clang::Sema::MergeFunctionDecl().
bool clang::Builtin::Context::isPredefinedRuntimeFunction | ( | unsigned | ID | ) | const [inline] |
Determines whether this builtin is a predefined compiler-rt/libgcc function, such as "__clear_cache", where we know the signature a priori.
Definition at line 137 of file Builtins.h.
Referenced by clang::Sema::ActOnStartOfFunctionDef().
bool Builtin::Context::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 the format string argument and whether this function as a va_list argument.
Definition at line 123 of file Builtins.cpp.
Referenced by clang::Sema::AddKnownFunctionAttributes().
bool clang::Builtin::Context::isReturnsTwice | ( | unsigned | ID | ) | const [inline] |
Return true if we know this builtin can return twice.
Definition at line 111 of file Builtins.h.
Referenced by clang::Sema::AddKnownFunctionAttributes().
bool Builtin::Context::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 format string argument and whether this function as a va_list argument.
Definition at line 128 of file Builtins.cpp.
Referenced by clang::Sema::AddKnownFunctionAttributes().
bool clang::Builtin::Context::isUnevaluated | ( | unsigned | ID | ) | const [inline] |
Returns true if this builtin does not perform the side-effects of its arguments.
Definition at line 117 of file Builtins.h.
Referenced by clang::CallExpr::isUnevaluatedBuiltinCall().