clang  6.0.0svn
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
clang::InitializedEntity Class Reference

Describes an entity that is being initialized. More...

#include "clang/Sema/Initialization.h"

Collaboration diagram for clang::InitializedEntity:
Collaboration graph
[legend]

Public Types

enum  EntityKind {
  EK_Variable, EK_Parameter, EK_Result, 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 InitializedEntitygetParent () 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...
 
TypeSourceInfogetTypeSourceInfo () 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...
 
ValueDeclgetDecl () const
 Retrieve the variable, parameter, or field being initialized. More...
 
ObjCMethodDeclgetMethodDecl () 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 CXXBaseSpecifiergetBaseSpecifier () 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...
 
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 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 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...
 

Detailed Description

Describes an entity that is being initialized.

Definition at line 40 of file Initialization.h.

Member Enumeration Documentation

◆ EntityKind

Specifies the kind of entity being initialized.

Enumerator
EK_Variable 

The entity being initialized is a variable.

EK_Parameter 

The entity being initialized is a function parameter.

EK_Result 

The entity being initialized is the result of a function call.

EK_Exception 

The entity being initialized is an exception object that is being thrown.

EK_Member 

The entity being initialized is a non-static data member subobject.

EK_ArrayElement 

The entity being initialized is an element of an array.

EK_New 

The entity being initialized is an object (or array of objects) allocated via new.

EK_Temporary 

The entity being initialized is a temporary object.

EK_Base 

The entity being initialized is a base member subobject.

EK_Delegating 

The initialization is being done by a delegating constructor.

EK_VectorElement 

The entity being initialized is an element of a vector.

or vector.

EK_BlockElement 

The entity being initialized is a field of block descriptor for the copied-in c++ object.

EK_LambdaToBlockConversionBlockElement 

The entity being initialized is a field of block descriptor for the copied-in lambda object that's used in the lambda to block conversion.

EK_ComplexElement 

The entity being initialized is the real or imaginary part of a complex number.

EK_LambdaCapture 

The entity being initialized is the field that captures a variable in a lambda.

EK_CompoundLiteralInit 

The entity being initialized is the initializer for a compound literal.

EK_RelatedResult 

The entity being implicitly initialized back to the formal result type.

EK_Parameter_CF_Audited 

The entity being initialized is a function parameter; function is member of group of audited CF APIs.

EK_Binding 

The entity being initialized is a structured binding of a decomposition declaration.

Definition at line 43 of file Initialization.h.

Member Function Documentation

◆ allocateManglingNumber()

unsigned clang::InitializedEntity::allocateManglingNumber ( ) const
inline

Definition at line 479 of file Initialization.h.

References dump().

Referenced by performReferenceExtension().

◆ allowsNRVO()

bool InitializedEntity::allowsNRVO ( ) const

Determine whether this initialization allows the named return value optimization, which also applies to thrown objects.

Definition at line 3012 of file SemaInit.cpp.

References Depth, and getKind().

Referenced by getMethodDecl(), and PerformConstructorInitialization().

◆ dump()

LLVM_DUMP_METHOD void InitializedEntity::dump ( ) const

Dump a representation of the initialized entity to standard error, for debugging purposes.

Definition at line 3085 of file SemaInit.cpp.

Referenced by allocateManglingNumber(), and clang::InitializationSequence::getFailureKind().

◆ getBaseSpecifier()

const CXXBaseSpecifier* clang::InitializedEntity::getBaseSpecifier ( ) const
inline

Retrieve the base specifier.

Definition at line 412 of file Initialization.h.

References EK_Base, and getKind().

Referenced by clang::Sema::CheckConstructorAccess(), clang::InitializationSequence::Diagnose(), and PerformConstructorInitialization().

◆ getCapturedVarName()

StringRef clang::InitializedEntity::getCapturedVarName ( ) const
inline

For a lambda capture, return the capture's name.

Definition at line 464 of file Initialization.h.

References EK_LambdaCapture, and getKind().

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

◆ getCaptureLoc()

SourceLocation clang::InitializedEntity::getCaptureLoc ( ) const
inline

Determine the location of the capture when initializing field from a captured variable in a lambda.

Definition at line 470 of file Initialization.h.

References EK_LambdaCapture, clang::SourceLocation::getFromRawEncoding(), and getKind().

Referenced by getInitializationLoc().

◆ getDecl()

ValueDecl * InitializedEntity::getDecl ( ) const

◆ getElementIndex()

unsigned clang::InitializedEntity::getElementIndex ( ) const
inline

If this is an array, vector, or complex number element, get the element's index.

Definition at line 451 of file Initialization.h.

References EK_ArrayElement, EK_ComplexElement, EK_VectorElement, getKind(), and Index.

◆ getKind()

EntityKind clang::InitializedEntity::getKind ( ) const
inline

◆ getMethodDecl()

ObjCMethodDecl* clang::InitializedEntity::getMethodDecl ( ) const
inline

Retrieve the ObjectiveC method being initialized.

Definition at line 394 of file Initialization.h.

References allowsNRVO(), and MethodDecl.

Referenced by CheckCXX98CompatAccessibleCopy().

◆ getName()

DeclarationName InitializedEntity::getName ( ) const

Retrieve the name of the entity being initialized.

Definition at line 2946 of file SemaInit.cpp.

References clang::NamedDecl::getDeclName(), getKind(), and clang::Parameter.

Referenced by clang::InitializationSequence::Diagnose(), and getTypeSourceInfo().

◆ getParent()

const InitializedEntity* clang::InitializedEntity::getParent ( ) const
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 372 of file Initialization.h.

References Parent.

Referenced by clang::Sema::CheckConstructorAccess(), getEntityForTemporaryLifetimeExtension(), InitializedEntityOutlivesFullExpression(), isIdiomaticBraceElisionEntity(), warnBracedScalarInit(), and warnOnLifetimeExtension().

◆ getReturnLoc()

SourceLocation clang::InitializedEntity::getReturnLoc ( ) const
inline

Determine the location of the 'return' keyword when initializing the result of a function call.

Definition at line 437 of file Initialization.h.

References EK_Result, clang::SourceLocation::getFromRawEncoding(), getKind(), and LocAndNRVO.

Referenced by getInitializationLoc().

◆ getThrowLoc()

SourceLocation clang::InitializedEntity::getThrowLoc ( ) const
inline

Determine the location of the 'throw' keyword when initializing an exception object.

Definition at line 444 of file Initialization.h.

References EK_Exception, clang::SourceLocation::getFromRawEncoding(), getKind(), and LocAndNRVO.

Referenced by getInitializationLoc().

◆ getType()

QualType clang::InitializedEntity::getType ( ) const
inline

◆ getTypeSourceInfo()

TypeSourceInfo* clang::InitializedEntity::getTypeSourceInfo ( ) const
inline

Retrieve complete type-source information for the object being constructed, if known.

Definition at line 379 of file Initialization.h.

References EK_CompoundLiteralInit, EK_Temporary, getDecl(), getName(), and TypeInfo.

Referenced by PerformConstructorInitialization().

◆ InitializeBase()

InitializedEntity InitializedEntity::InitializeBase ( ASTContext Context,
const CXXBaseSpecifier Base,
bool  IsInheritedVirtualBase,
const InitializedEntity Parent = nullptr 
)
static

Create the initialization entity for a base class subobject.

Definition at line 2931 of file SemaInit.cpp.

References Base, clang::CXXBaseSpecifier::getType(), Parent, and clang::Result.

Referenced by BuildImplicitBaseInitializer(), InitializeRelatedResult(), and warnBracedScalarInit().

◆ InitializeBinding()

static InitializedEntity clang::InitializedEntity::InitializeBinding ( VarDecl Binding)
inlinestatic

Create the initialization entity for a structured binding.

Definition at line 346 of file Initialization.h.

References EK_Binding.

◆ InitializeBlock()

static InitializedEntity clang::InitializedEntity::InitializeBlock ( SourceLocation  BlockVarLoc,
QualType  Type,
bool  NRVO 
)
inlinestatic

Definition at line 262 of file Initialization.h.

References EK_BlockElement.

◆ InitializeCompoundLiteralInit()

static InitializedEntity clang::InitializedEntity::InitializeCompoundLiteralInit ( TypeSourceInfo TSI)
inlinestatic

Create the entity for a compound literal initializer.

Definition at line 358 of file Initialization.h.

References EK_CompoundLiteralInit, clang::TypeSourceInfo::getType(), and clang::Result.

◆ InitializeDelegation()

static InitializedEntity clang::InitializedEntity::InitializeDelegation ( QualType  Type)
inlinestatic

Create the initialization entity for a delegated constructor.

Definition at line 318 of file Initialization.h.

References EK_Delegating.

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

◆ InitializeElement()

static InitializedEntity clang::InitializedEntity::InitializeElement ( ASTContext Context,
unsigned  Index,
const InitializedEntity Parent 
)
inlinestatic

Create the initialization entity for an array element.

Definition at line 339 of file Initialization.h.

Referenced by warnBracedScalarInit().

◆ InitializeException()

static InitializedEntity clang::InitializedEntity::InitializeException ( SourceLocation  ThrowLoc,
QualType  Type,
bool  NRVO 
)
inlinestatic

Create the initialization entity for an exception object.

Definition at line 274 of file Initialization.h.

References EK_Exception.

◆ InitializeLambdaCapture()

static InitializedEntity clang::InitializedEntity::InitializeLambdaCapture ( IdentifierInfo VarID,
QualType  FieldType,
SourceLocation  Loc 
)
inlinestatic

Create the initialization entity for a lambda capture.

Definition at line 351 of file Initialization.h.

Referenced by captureThis().

◆ InitializeLambdaToBlock()

static InitializedEntity clang::InitializedEntity::InitializeLambdaToBlock ( SourceLocation  BlockVarLoc,
QualType  Type,
bool  NRVO 
)
inlinestatic

Definition at line 267 of file Initialization.h.

References EK_LambdaToBlockConversionBlockElement.

◆ InitializeMember() [1/2]

static InitializedEntity clang::InitializedEntity::InitializeMember ( FieldDecl Member,
const InitializedEntity Parent = nullptr,
bool  Implicit = false 
)
inlinestatic

◆ InitializeMember() [2/2]

static InitializedEntity clang::InitializedEntity::InitializeMember ( IndirectFieldDecl Member,
const InitializedEntity Parent = nullptr,
bool  Implicit = false 
)
inlinestatic

Create the initialization entity for a member subobject.

Definition at line 332 of file Initialization.h.

References clang::IndirectFieldDecl::getAnonField(), and Parent.

◆ InitializeNew()

static InitializedEntity clang::InitializedEntity::InitializeNew ( SourceLocation  NewLoc,
QualType  Type 
)
inlinestatic

Create the initialization entity for an object allocated via new.

Definition at line 280 of file Initialization.h.

References EK_New.

◆ InitializeParameter() [1/3]

static InitializedEntity clang::InitializedEntity::InitializeParameter ( ASTContext Context,
const ParmVarDecl Parm 
)
inlinestatic

◆ InitializeParameter() [2/3]

static InitializedEntity clang::InitializedEntity::InitializeParameter ( ASTContext Context,
const ParmVarDecl Parm,
QualType  Type 
)
inlinestatic

Create the initialization entity for a parameter, but use another type.

Definition at line 227 of file Initialization.h.

◆ InitializeParameter() [3/3]

static InitializedEntity clang::InitializedEntity::InitializeParameter ( ASTContext Context,
QualType  Type,
bool  Consumed 
)
inlinestatic

Create the initialization entity for a parameter that is only known by its type.

Definition at line 245 of file Initialization.h.

◆ InitializeRelatedResult()

static InitializedEntity clang::InitializedEntity::InitializeRelatedResult ( ObjCMethodDecl MD,
QualType  Type 
)
inlinestatic

Create the initialization entity for a related result.

Definition at line 303 of file Initialization.h.

References EK_RelatedResult, InitializeBase(), MethodDecl, and clang::Result.

◆ InitializeResult()

static InitializedEntity clang::InitializedEntity::InitializeResult ( SourceLocation  ReturnLoc,
QualType  Type,
bool  NRVO 
)
inlinestatic

Create the initialization entity for the result of a function.

Definition at line 257 of file Initialization.h.

References EK_Result.

◆ InitializeTemporary() [1/3]

static InitializedEntity clang::InitializedEntity::InitializeTemporary ( QualType  Type)
inlinestatic

◆ InitializeTemporary() [2/3]

static InitializedEntity clang::InitializedEntity::InitializeTemporary ( TypeSourceInfo TypeInfo)
inlinestatic

Create the initialization entity for a temporary.

Definition at line 290 of file Initialization.h.

References clang::TypeSourceInfo::getType(), and InitializeTemporary().

◆ InitializeTemporary() [3/3]

static InitializedEntity clang::InitializedEntity::InitializeTemporary ( TypeSourceInfo TypeInfo,
QualType  Type 
)
inlinestatic

Create the initialization entity for a temporary.

Definition at line 295 of file Initialization.h.

References EK_Temporary, clang::Result, and TypeInfo.

◆ InitializeVariable()

static InitializedEntity clang::InitializedEntity::InitializeVariable ( VarDecl Var)
inlinestatic

Create the initialization entity for a variable.

Definition at line 215 of file Initialization.h.

◆ isImplicitMemberInitializer()

bool clang::InitializedEntity::isImplicitMemberInitializer ( ) const
inline

Is this the implicit initialization of a member of a class from a defaulted constructor?

Definition at line 431 of file Initialization.h.

References EK_Member, getKind(), and Variable.

Referenced by canPerformArrayCopy().

◆ isInheritedVirtualBase()

bool clang::InitializedEntity::isInheritedVirtualBase ( ) const
inline

Return whether the base is an inherited virtual base.

Definition at line 418 of file Initialization.h.

References EK_Base, and getKind().

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

◆ isParameterConsumed()

bool clang::InitializedEntity::isParameterConsumed ( ) const
inline

Determine whether this initialization consumes the parameter.

Definition at line 406 of file Initialization.h.

References isParameterKind(), and Parameter.

Referenced by MaybeProduceObjCObject().

◆ isParameterKind()

bool clang::InitializedEntity::isParameterKind ( ) const
inline

◆ isVariableLengthArrayNew()

bool clang::InitializedEntity::isVariableLengthArrayNew ( ) const
inline

Determine whether this is an array new with an unknown bound.

Definition at line 424 of file Initialization.h.

References EK_New, clang::Type::getAsArrayTypeUnsafe(), getKind(), and getType().

Referenced by warnBracedScalarInit().

◆ setElementIndex()

void clang::InitializedEntity::setElementIndex ( unsigned  Index)
inline

If this is already the initializer for an array or vector element, sets the element index.

Definition at line 458 of file Initialization.h.

References EK_ArrayElement, EK_ComplexElement, EK_VectorElement, getKind(), and Index.

Referenced by warnBracedScalarInit().

◆ setParameterCFAudited()

void clang::InitializedEntity::setParameterCFAudited ( )
inline

Definition at line 475 of file Initialization.h.

References EK_Parameter_CF_Audited.

Member Data Documentation

◆ Base

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 165 of file Initialization.h.

Referenced by InitializeBase().

◆ Capture

struct C clang::InitializedEntity::Capture

Definition at line 172 of file Initialization.h.

◆ Index

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 170 of file Initialization.h.

Referenced by getElementIndex(), and setElementIndex().

◆ LocAndNRVO

struct LN clang::InitializedEntity::LocAndNRVO

Definition at line 160 of file Initialization.h.

Referenced by getReturnLoc(), and getThrowLoc().

◆ MethodDecl

ObjCMethodDecl* clang::InitializedEntity::MethodDecl

When Kind == EK_RelatedResult, the ObjectiveC method where result type was implicitly changed to accommodate ARC semantics.

Definition at line 150 of file Initialization.h.

Referenced by getMethodDecl(), and InitializeRelatedResult().

◆ Parameter

uintptr_t clang::InitializedEntity::Parameter

When Kind == EK_Parameter, the ParmVarDecl, with the low bit indicating whether the parameter is "consumed".

Definition at line 154 of file Initialization.h.

Referenced by isParameterConsumed().

◆ TypeInfo

TypeSourceInfo* clang::InitializedEntity::TypeInfo

When Kind == EK_Temporary or EK_CompoundLiteralInit, the type source information for the temporary.

Definition at line 158 of file Initialization.h.

Referenced by getTypeSourceInfo(), and InitializeTemporary().

◆ Variable

VD clang::InitializedEntity::Variable

When Kind == EK_Variable, EK_Member or EK_Binding, the variable.

Definition at line 146 of file Initialization.h.

Referenced by isImplicitMemberInitializer().


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