clang  3.9.0
Public Member Functions | Static Public Member Functions | List of all members
clang::Builtin::Context Class Reference

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, const TargetInfo *AuxTarget)
 Perform target-specific initialization. More...
 
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. More...
 
const char * getName (unsigned ID) const
 Return the identifier name for the specified builtin, e.g. More...
 
const char * getTypeString (unsigned ID) const
 Get the type descriptor string for the specified builtin. More...
 
bool isTSBuiltin (unsigned ID) const
 Return true if this function is a target-specific builtin. More...
 
bool isPure (unsigned ID) const
 Return true if this function has no side effects. More...
 
bool isConst (unsigned ID) const
 Return true if this function has no side effects and doesn't read memory. More...
 
bool isNoThrow (unsigned ID) const
 Return true if we know this builtin never throws an exception. More...
 
bool isNoReturn (unsigned ID) const
 Return true if we know this builtin never returns. More...
 
bool isReturnsTwice (unsigned ID) const
 Return true if we know this builtin can return twice. More...
 
bool isUnevaluated (unsigned ID) const
 Returns true if this builtin does not perform the side-effects of its arguments. More...
 
bool isLibFunction (unsigned ID) const
 Return true if this is a builtin for a libc/libm function, with a "__builtin_" prefix (e.g. More...
 
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. More...
 
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. More...
 
bool hasCustomTypechecking (unsigned ID) const
 Determines whether this builtin has custom typechecking. More...
 
bool hasPtrArgsOrResult (unsigned ID) const
 Determines whether this builtin has a result or any arguments which are pointer types. More...
 
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. More...
 
const char * getHeaderName (unsigned ID) const
 If this is a library function that comes from a specific header, retrieve that header name. More...
 
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. More...
 
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. More...
 
bool isConstWithoutErrno (unsigned ID) const
 Return true if this function has no side effects and doesn't read memory, except for possibly errno. More...
 
const char * getRequiredFeatures (unsigned ID) const
 
bool isAuxBuiltinID (unsigned ID) const
 Return true if builtin ID belongs to AuxTarget. More...
 
unsigned getAuxBuiltinID (unsigned ID) const
 Return real buitin ID (i.e. More...
 

Static Public Member Functions

static bool isBuiltinFunc (const char *Name)
 Returns true if this is a libc/libm function without the '__builtin_' prefix. More...
 

Detailed Description

Holds information about both target-independent and target-specific builtins, allowing easy queries by clients.

Builtins from an optional auxiliary target are stored in AuxTSRecords. Their IDs are shifted up by TSRecords.size() and need to be translated back with getAuxBuiltinID() before use.

Definition at line 65 of file Builtins.h.

Constructor & Destructor Documentation

clang::Builtin::Context::Context ( )
inline

Definition at line 70 of file Builtins.h.

Member Function Documentation

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 100 of file Builtins.cpp.

References clang::IdentifierTable::get(), clang::Name, and clang::IdentifierInfo::setBuiltinID().

Referenced by clang::Sema::CheckFunctionDeclaration().

unsigned clang::Builtin::Context::getAuxBuiltinID ( unsigned  ID) const
inline

Return real buitin ID (i.e.

ID it would have furing compilation for AuxTarget).

Definition at line 199 of file Builtins.h.

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 166 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 83 of file Builtins.h.

References clang::Builtin::Info::Name.

Referenced by emitReplacement(), clang::CodeGen::CodeGenModule::getBuiltinLibFunction(), and clang::Sema::LazilyCreateBuiltin().

const char* clang::Builtin::Context::getRequiredFeatures ( unsigned  ID) const
inline
const char* clang::Builtin::Context::getTypeString ( unsigned  ID) const
inline

Get the type descriptor string for the specified builtin.

Definition at line 88 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 150 of file Builtins.h.

Referenced by clang::Sema::BuildResolvedCallExpr(), and clang::Sema::ConvertArgumentsForCall().

bool clang::Builtin::Context::hasPtrArgsOrResult ( unsigned  ID) const
inline

Determines whether this builtin has a result or any arguments which are pointer types.

Definition at line 156 of file Builtins.h.

Referenced by rewriteBuiltinFunctionDecl().

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 81 of file Builtins.cpp.

References clang::Builtin::FirstTSBuiltin, clang::IdentifierTable::get(), clang::Name, clang::Builtin::NotBuiltin, and clang::IdentifierInfo::setBuiltinID().

Referenced by clang::FrontendAction::BeginSourceFile(), and clang::createChainedIncludesSource().

void Builtin::Context::InitializeTarget ( const TargetInfo Target,
const TargetInfo AuxTarget 
)

Perform target-specific initialization.

Parameters
AuxTargetTarget info to incorporate builtins from. May be nullptr.

Definition at line 43 of file Builtins.cpp.

References clang::TargetInfo::getTargetBuiltins().

bool clang::Builtin::Context::isAuxBuiltinID ( unsigned  ID) const
inline

Return true if builtin ID belongs to AuxTarget.

Definition at line 193 of file Builtins.h.

References clang::Builtin::FirstTSBuiltin.

Referenced by clang::Sema::AddKnownFunctionAttributes().

bool Builtin::Context::isBuiltinFunc ( const char *  Name)
static

Returns true if this is a libc/libm function without the '__builtin_' prefix.

Definition at line 51 of file Builtins.cpp.

References BuiltinInfo, clang::Builtin::FirstTSBuiltin, clang::Builtin::Info::Name, and clang::Builtin::NotBuiltin.

Referenced by getAllNoBuiltinFuncValues().

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 104 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 184 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 131 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 114 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 109 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 138 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 145 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 127 of file Builtins.cpp.

Referenced by clang::Sema::AddKnownFunctionAttributes().

bool clang::Builtin::Context::isPure ( unsigned  ID) const
inline

Return true if this function has no side effects.

Definition at line 98 of file Builtins.h.

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 119 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 132 of file Builtins.cpp.

Referenced by clang::Sema::AddKnownFunctionAttributes().

bool clang::Builtin::Context::isTSBuiltin ( unsigned  ID) const
inline

Return true if this function is a target-specific builtin.

Definition at line 93 of file Builtins.h.

References clang::Builtin::FirstTSBuiltin.

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 125 of file Builtins.h.

Referenced by clang::CallExpr::isUnevaluatedBuiltinCall().


The documentation for this class was generated from the following files: