clang
9.0.0
|
Describes an entity that is being initialized. More...
#include "clang/Sema/Initialization.h"
Public Types | |
enum | EntityKind { EK_Variable, EK_Parameter, EK_Result, EK_StmtExprResult, EK_Exception, EK_Member, EK_ArrayElement, EK_New, EK_Temporary, EK_Base, EK_Delegating, EK_VectorElement, EK_BlockElement, EK_LambdaToBlockConversionBlockElement, EK_ComplexElement, EK_LambdaCapture, EK_CompoundLiteralInit, EK_RelatedResult, EK_Parameter_CF_Audited, EK_Binding } |
Specifies the kind of entity being initialized. More... | |
Public Member Functions | |
EntityKind | getKind () const |
Determine the kind of initialization. More... | |
const InitializedEntity * | getParent () const |
Retrieve the parent of the entity being initialized, when the initialization itself is occurring within the context of a larger initialization. More... | |
QualType | getType () const |
Retrieve type being initialized. More... | |
TypeSourceInfo * | getTypeSourceInfo () const |
Retrieve complete type-source information for the object being constructed, if known. More... | |
DeclarationName | getName () const |
Retrieve the name of the entity being initialized. More... | |
ValueDecl * | getDecl () const |
Retrieve the variable, parameter, or field being initialized. More... | |
ObjCMethodDecl * | getMethodDecl () const |
Retrieve the ObjectiveC method being initialized. More... | |
bool | allowsNRVO () const |
Determine whether this initialization allows the named return value optimization, which also applies to thrown objects. More... | |
bool | isParameterKind () const |
bool | isParameterConsumed () const |
Determine whether this initialization consumes the parameter. More... | |
const CXXBaseSpecifier * | getBaseSpecifier () const |
Retrieve the base specifier. More... | |
bool | isInheritedVirtualBase () const |
Return whether the base is an inherited virtual base. More... | |
bool | isVariableLengthArrayNew () const |
Determine whether this is an array new with an unknown bound. More... | |
bool | isImplicitMemberInitializer () const |
Is this the implicit initialization of a member of a class from a defaulted constructor? More... | |
bool | isDefaultMemberInitializer () const |
Is this the default member initializer of a member (specified inside the class definition)? More... | |
SourceLocation | getReturnLoc () const |
Determine the location of the 'return' keyword when initializing the result of a function call. More... | |
SourceLocation | getThrowLoc () const |
Determine the location of the 'throw' keyword when initializing an exception object. More... | |
unsigned | getElementIndex () const |
If this is an array, vector, or complex number element, get the element's index. More... | |
void | setElementIndex (unsigned Index) |
If this is already the initializer for an array or vector element, sets the element index. More... | |
StringRef | getCapturedVarName () const |
For a lambda capture, return the capture's name. More... | |
SourceLocation | getCaptureLoc () const |
Determine the location of the capture when initializing field from a captured variable in a lambda. More... | |
void | setParameterCFAudited () |
unsigned | allocateManglingNumber () const |
void | dump () const |
Dump a representation of the initialized entity to standard error, for debugging purposes. More... | |
Static Public Member Functions | |
static InitializedEntity | InitializeVariable (VarDecl *Var) |
Create the initialization entity for a variable. More... | |
static InitializedEntity | InitializeParameter (ASTContext &Context, const ParmVarDecl *Parm) |
Create the initialization entity for a parameter. More... | |
static InitializedEntity | InitializeParameter (ASTContext &Context, const ParmVarDecl *Parm, QualType Type) |
Create the initialization entity for a parameter, but use another type. More... | |
static InitializedEntity | InitializeParameter (ASTContext &Context, QualType Type, bool Consumed) |
Create the initialization entity for a parameter that is only known by its type. More... | |
static InitializedEntity | InitializeResult (SourceLocation ReturnLoc, QualType Type, bool NRVO) |
Create the initialization entity for the result of a function. More... | |
static InitializedEntity | InitializeStmtExprResult (SourceLocation ReturnLoc, QualType Type) |
static InitializedEntity | InitializeBlock (SourceLocation BlockVarLoc, QualType Type, bool NRVO) |
static InitializedEntity | InitializeLambdaToBlock (SourceLocation BlockVarLoc, QualType Type, bool NRVO) |
static InitializedEntity | InitializeException (SourceLocation ThrowLoc, QualType Type, bool NRVO) |
Create the initialization entity for an exception object. More... | |
static InitializedEntity | InitializeNew (SourceLocation NewLoc, QualType Type) |
Create the initialization entity for an object allocated via new. More... | |
static InitializedEntity | InitializeTemporary (QualType Type) |
Create the initialization entity for a temporary. More... | |
static InitializedEntity | InitializeTemporary (TypeSourceInfo *TypeInfo) |
Create the initialization entity for a temporary. More... | |
static InitializedEntity | InitializeTemporary (TypeSourceInfo *TypeInfo, QualType Type) |
Create the initialization entity for a temporary. More... | |
static InitializedEntity | InitializeRelatedResult (ObjCMethodDecl *MD, QualType Type) |
Create the initialization entity for a related result. More... | |
static InitializedEntity | InitializeBase (ASTContext &Context, const CXXBaseSpecifier *Base, bool IsInheritedVirtualBase, const InitializedEntity *Parent=nullptr) |
Create the initialization entity for a base class subobject. More... | |
static InitializedEntity | InitializeDelegation (QualType Type) |
Create the initialization entity for a delegated constructor. More... | |
static InitializedEntity | InitializeMember (FieldDecl *Member, const InitializedEntity *Parent=nullptr, bool Implicit=false) |
Create the initialization entity for a member subobject. More... | |
static InitializedEntity | InitializeMember (IndirectFieldDecl *Member, const InitializedEntity *Parent=nullptr, bool Implicit=false) |
Create the initialization entity for a member subobject. More... | |
static InitializedEntity | InitializeMemberFromDefaultMemberInitializer (FieldDecl *Member) |
Create the initialization entity for a default member initializer. More... | |
static InitializedEntity | InitializeElement (ASTContext &Context, unsigned Index, const InitializedEntity &Parent) |
Create the initialization entity for an array element. More... | |
static InitializedEntity | InitializeBinding (VarDecl *Binding) |
Create the initialization entity for a structured binding. More... | |
static InitializedEntity | InitializeLambdaCapture (IdentifierInfo *VarID, QualType FieldType, SourceLocation Loc) |
Create the initialization entity for a lambda capture. More... | |
static InitializedEntity | InitializeCompoundLiteralInit (TypeSourceInfo *TSI) |
Create the entity for a compound literal initializer. More... | |
Describes an entity that is being initialized.
Definition at line 48 of file Initialization.h.
Specifies the kind of entity being initialized.
Definition at line 51 of file Initialization.h.
|
inline |
Definition at line 528 of file Initialization.h.
References dump().
Referenced by clang::Sema::checkInitializerLifetime().
bool InitializedEntity::allowsNRVO | ( | ) | const |
Determine whether this initialization allows the named return value optimization, which also applies to thrown objects.
Definition at line 3195 of file SemaInit.cpp.
References Depth, and getKind().
Referenced by getMethodDecl(), and PerformConstructorInitialization().
LLVM_DUMP_METHOD void InitializedEntity::dump | ( | ) | const |
Dump a representation of the initialized entity to standard error, for debugging purposes.
Definition at line 3270 of file SemaInit.cpp.
Referenced by allocateManglingNumber(), and clang::InitializationSequence::getFailureKind().
|
inline |
Retrieve the base specifier.
Definition at line 452 of file Initialization.h.
References EK_Base, and getKind().
Referenced by clang::Sema::CheckConstructorAccess(), and PerformConstructorInitialization().
|
inline |
For a lambda capture, return the capture's name.
Definition at line 512 of file Initialization.h.
References EK_LambdaCapture, and getKind().
Referenced by clang::Sema::CheckConstructorAccess().
|
inline |
Determine the location of the capture when initializing field from a captured variable in a lambda.
Definition at line 519 of file Initialization.h.
References EK_LambdaCapture, clang::SourceLocation::getFromRawEncoding(), and getKind().
Referenced by getInitializationLoc().
ValueDecl * InitializedEntity::getDecl | ( | ) | const |
Retrieve the variable, parameter, or field being initialized.
Definition at line 3163 of file SemaInit.cpp.
References getKind(), and clang::Parameter.
Referenced by canPerformArrayCopy(), clang::Sema::CheckConstructorAccess(), CheckCXX98CompatAccessibleCopy(), clang::Sema::checkInitializerLifetime(), diagnoseListInit(), getAssignmentAction(), getInitializationLoc(), getTypeSourceInfo(), maybeRecoverWithZeroInitialization(), clang::InitializationSequence::Perform(), and tryObjCWritebackConversion().
|
inline |
If this is an array, vector, or complex number element, get the element's index.
Definition at line 497 of file Initialization.h.
References EK_ArrayElement, EK_ComplexElement, EK_VectorElement, getKind(), and Index.
|
inline |
Determine the kind of initialization.
Definition at line 406 of file Initialization.h.
Referenced by canPerformArrayCopy(), clang::Sema::CheckConstructorAccess(), CheckCXX98CompatAccessibleCopy(), CopyObject(), emitBadConversionNotes(), getAssignmentAction(), getBaseSpecifier(), getCapturedVarName(), getCaptureLoc(), getElementIndex(), getEntityLifetime(), getInitializationLoc(), getReturnLoc(), getThrowLoc(), clang::InitializationSequence::InitializeFrom(), isDefaultMemberInitializer(), isExplicitTemporary(), isIdiomaticBraceElisionEntity(), isImplicitMemberInitializer(), isInheritedVirtualBase(), isLibstdcxxPointerReturnFalseHack(), isParameterKind(), isVariableLengthArrayNew(), MaybeProduceObjCObject(), maybeRecoverWithZeroInitialization(), clang::InitializationSequence::Perform(), PerformConstructorInitialization(), setElementIndex(), shouldBindAsTemporary(), shouldDestroyEntity(), TryConstructorInitialization(), TryReferenceListInitialization(), and warnBracedScalarInit().
|
inline |
Retrieve the ObjectiveC method being initialized.
Definition at line 433 of file Initialization.h.
References allowsNRVO(), and MethodDecl.
Referenced by CheckCXX98CompatAccessibleCopy().
DeclarationName InitializedEntity::getName | ( | ) | const |
Retrieve the name of the entity being initialized.
Definition at line 3127 of file SemaInit.cpp.
References clang::NamedDecl::getDeclName(), getKind(), and clang::Parameter.
Referenced by getTypeSourceInfo().
|
inline |
Retrieve the parent of the entity being initialized, when the initialization itself is occurring within the context of a larger initialization.
Definition at line 411 of file Initialization.h.
References Parent.
Referenced by canPerformArrayCopy(), clang::Sema::CheckConstructorAccess(), clang::Sema::checkInitializerLifetime(), getEntityLifetime(), isIdiomaticBraceElisionEntity(), and warnBracedScalarInit().
|
inline |
Determine the location of the 'return' keyword when initializing the result of a function call.
Definition at line 483 of file Initialization.h.
References EK_Result, clang::SourceLocation::getFromRawEncoding(), getKind(), and LocAndNRVO.
Referenced by getInitializationLoc().
|
inline |
Determine the location of the 'throw' keyword when initializing an exception object.
Definition at line 490 of file Initialization.h.
References EK_Exception, clang::SourceLocation::getFromRawEncoding(), getKind(), and LocAndNRVO.
Referenced by getInitializationLoc().
|
inline |
Retrieve type being initialized.
Definition at line 414 of file Initialization.h.
References Type.
Referenced by clang::Sema::CheckConstructorAccess(), clang::Sema::checkInitializerLifetime(), diagnoseListInit(), emitBadConversionNotes(), clang::InitializationSequence::InitializeFrom(), isIdiomaticBraceElisionEntity(), isLibstdcxxPointerReturnFalseHack(), isVariableLengthArrayNew(), MaybeProduceObjCObject(), maybeRecoverWithZeroInitialization(), clang::InitializationSequence::Perform(), PerformConstructorInitialization(), clang::Sema::PerformCopyInitialization(), TryConstructorInitialization(), TryDefaultInitialization(), TryListInitialization(), tryObjCWritebackConversion(), TryReferenceInitialization(), TryReferenceInitializationCore(), TryReferenceListInitialization(), TryRefInitWithConversionFunction(), TryStringLiteralInitialization(), and TryValueInitialization().
|
inline |
Retrieve complete type-source information for the object being constructed, if known.
Definition at line 418 of file Initialization.h.
References EK_CompoundLiteralInit, EK_Temporary, getDecl(), getName(), and TypeInfo.
Referenced by clang::InitializationSequence::Perform(), and PerformConstructorInitialization().
|
static |
Create the initialization entity for a base class subobject.
Definition at line 3112 of file SemaInit.cpp.
References Base, Parent, and clang::Result.
Referenced by BuildImplicitBaseInitializer(), and InitializeRelatedResult().
|
inlinestatic |
Create the initialization entity for a structured binding.
Definition at line 384 of file Initialization.h.
References EK_Binding.
Referenced by checkTupleLikeDecomposition().
|
inlinestatic |
Definition at line 295 of file Initialization.h.
References EK_BlockElement.
Referenced by checkEscapingByref().
|
inlinestatic |
Create the entity for a compound literal initializer.
Definition at line 398 of file Initialization.h.
References EK_CompoundLiteralInit, clang::TypeSourceInfo::getType(), and clang::Result.
|
inlinestatic |
Create the initialization entity for a delegated constructor.
Definition at line 350 of file Initialization.h.
References EK_Delegating.
Referenced by clang::Sema::BuildDelegatingInitializer().
|
inlinestatic |
Create the initialization entity for an array element.
Definition at line 377 of file Initialization.h.
Referenced by clang::InitializationSequence::InitializeFrom().
|
inlinestatic |
Create the initialization entity for an exception object.
Definition at line 307 of file Initialization.h.
References EK_Exception.
|
inlinestatic |
Create the initialization entity for a lambda capture.
VarID
The name of the entity being captured, or nullptr for 'this'.
Definition at line 391 of file Initialization.h.
|
inlinestatic |
Definition at line 300 of file Initialization.h.
References EK_LambdaToBlockConversionBlockElement.
|
inlinestatic |
Create the initialization entity for a member subobject.
Definition at line 356 of file Initialization.h.
Referenced by BuildImplicitMemberInitializer(), clang::Sema::BuildMemberInitializer(), CollectFieldInitializer(), and clang::Sema::SetIvarInitializers().
|
inlinestatic |
Create the initialization entity for a member subobject.
Definition at line 364 of file Initialization.h.
References clang::IndirectFieldDecl::getAnonField(), and Parent.
|
inlinestatic |
Create the initialization entity for a default member initializer.
Definition at line 372 of file Initialization.h.
Referenced by clang::Sema::ActOnFinishCXXInClassMemberInitializer().
|
inlinestatic |
Create the initialization entity for an object allocated via new.
Definition at line 313 of file Initialization.h.
References EK_New.
|
inlinestatic |
Create the initialization entity for a parameter.
Definition at line 248 of file Initialization.h.
Referenced by clang::Sema::BuildLiteralOperatorCall(), checkBuiltinArgument(), clang::Sema::CheckCXXDefaultArgExpr(), CheckObjCCollectionLiteralElement(), clang::Sema::checkUnknownAnyArg(), convertArgsForAvailabilityChecks(), resolveBuiltinNewDeleteOverload(), SemaBuiltinLaunder(), clang::Sema::SetParamDefaultArgument(), and TryListConversion().
|
inlinestatic |
Create the initialization entity for a parameter, but use another type.
Definition at line 255 of file Initialization.h.
|
inlinestatic |
Create the initialization entity for a parameter that is only known by its type.
Definition at line 273 of file Initialization.h.
|
inlinestatic |
Create the initialization entity for a related result.
Definition at line 336 of file Initialization.h.
References EK_RelatedResult, InitializeBase(), MethodDecl, and clang::Result.
|
inlinestatic |
Create the initialization entity for the result of a function.
Definition at line 285 of file Initialization.h.
References EK_Result.
Referenced by clang::Sema::BuildCoreturnStmt(), and noteMemberDeclaredHere().
|
inlinestatic |
Definition at line 290 of file Initialization.h.
References EK_StmtExprResult.
Referenced by clang::Sema::ActOnStmtExprResult().
|
inlinestatic |
Create the initialization entity for a temporary.
Definition at line 318 of file Initialization.h.
Referenced by clang::Sema::BuildCXXTypeConstructExpr(), ConvertForConditional(), clang::Sema::CreateBuiltinBinOp(), clang::Sema::CXXCheckConditionalOperands(), diagnoseListInit(), EvaluateBinaryTypeTrait(), evaluateTypeTrait(), clang::Sema::FindCompositePointerType(), InitializeTemporary(), clang::InitializationSequence::Perform(), TryClassUnification(), TryReferenceInitializationCore(), TryReferenceListInitialization(), and TryStaticImplicitCast().
|
inlinestatic |
Create the initialization entity for a temporary.
Definition at line 323 of file Initialization.h.
References clang::TypeSourceInfo::getType(), and InitializeTemporary().
|
inlinestatic |
Create the initialization entity for a temporary.
Definition at line 328 of file Initialization.h.
References EK_Temporary, clang::Result, and TypeInfo.
|
inlinestatic |
Create the initialization entity for a variable.
Definition at line 243 of file Initialization.h.
Referenced by noteMemberDeclaredHere().
|
inline |
Is this the default member initializer of a member (specified inside the class definition)?
Definition at line 477 of file Initialization.h.
References EK_Member, getKind(), and Variable.
Referenced by getEntityLifetime().
|
inline |
Is this the implicit initialization of a member of a class from a defaulted constructor?
Definition at line 471 of file Initialization.h.
References EK_Member, getKind(), and Variable.
Referenced by canPerformArrayCopy().
|
inline |
Return whether the base is an inherited virtual base.
Definition at line 458 of file Initialization.h.
References EK_Base, and getKind().
Referenced by clang::Sema::CheckConstructorAccess().
|
inline |
Determine whether this initialization consumes the parameter.
Definition at line 446 of file Initialization.h.
References isParameterKind(), and Parameter.
Referenced by MaybeProduceObjCObject().
|
inline |
Definition at line 439 of file Initialization.h.
References EK_Parameter, EK_Parameter_CF_Audited, and getKind().
Referenced by CheckCXX98CompatAccessibleCopy(), isParameterConsumed(), MaybeProduceObjCObject(), clang::InitializationSequence::Perform(), and clang::Sema::PerformCopyInitialization().
|
inline |
Determine whether this is an array new with an unknown bound.
Definition at line 464 of file Initialization.h.
References EK_New, clang::Type::getAsArrayTypeUnsafe(), getKind(), and getType().
|
inline |
If this is already the initializer for an array or vector element, sets the element index.
Definition at line 505 of file Initialization.h.
References EK_ArrayElement, EK_ComplexElement, EK_VectorElement, getKind(), and Index.
|
inline |
Definition at line 524 of file Initialization.h.
References EK_Parameter_CF_Audited.
uintptr_t clang::InitializedEntity::Base |
When Kind == EK_Base, the base specifier that provides the base class.
The lower bit specifies whether the base is an inherited virtual base.
Definition at line 198 of file Initialization.h.
Referenced by InitializeBase().
struct C clang::InitializedEntity::Capture |
Definition at line 205 of file Initialization.h.
unsigned clang::InitializedEntity::Index |
When Kind == EK_ArrayElement, EK_VectorElement, or EK_ComplexElement, the index of the array or vector element being initialized.
Definition at line 203 of file Initialization.h.
Referenced by getElementIndex(), and setElementIndex().
struct LN clang::InitializedEntity::LocAndNRVO |
Definition at line 193 of file Initialization.h.
Referenced by getReturnLoc(), and getThrowLoc().
ObjCMethodDecl* clang::InitializedEntity::MethodDecl |
When Kind == EK_RelatedResult, the ObjectiveC method where result type was implicitly changed to accommodate ARC semantics.
Definition at line 183 of file Initialization.h.
Referenced by getMethodDecl(), and InitializeRelatedResult().
uintptr_t clang::InitializedEntity::Parameter |
When Kind == EK_Parameter, the ParmVarDecl, with the low bit indicating whether the parameter is "consumed".
Definition at line 187 of file Initialization.h.
Referenced by isParameterConsumed().
TypeSourceInfo* clang::InitializedEntity::TypeInfo |
When Kind == EK_Temporary or EK_CompoundLiteralInit, the type source information for the temporary.
Definition at line 191 of file Initialization.h.
Referenced by getTypeSourceInfo(), and InitializeTemporary().
VD clang::InitializedEntity::Variable |
When Kind == EK_Variable, EK_Member or EK_Binding, the variable.
Definition at line 179 of file Initialization.h.
Referenced by isDefaultMemberInitializer(), and isImplicitMemberInitializer().