clang API Documentation

Classes | Public Types | Public Member Functions
clang::InitializationSequence Class Reference

Describes the sequence of initializations required to initialize a given object or reference with a set of arguments. More...

#include <Initialization.h>

List of all members.

Classes

class  Step
 A single step in the initialization sequence. More...

Public Types

enum  SequenceKind { FailedSequence = 0, DependentSequence, NormalSequence }
 Describes the kind of initialization sequence computed. More...
enum  StepKind {
  SK_ResolveAddressOfOverloadedFunction, SK_CastDerivedToBaseRValue, SK_CastDerivedToBaseXValue, SK_CastDerivedToBaseLValue,
  SK_BindReference, SK_BindReferenceToTemporary, SK_ExtraneousCopyToTemporary, SK_UserConversion,
  SK_QualificationConversionRValue, SK_QualificationConversionXValue, SK_QualificationConversionLValue, SK_AtomicConversion,
  SK_LValueToRValue, SK_ConversionSequence, SK_ConversionSequenceNoNarrowing, SK_ListInitialization,
  SK_UnwrapInitList, SK_RewrapInitList, SK_ConstructorInitialization, SK_ConstructorInitializationFromList,
  SK_ZeroInitialization, SK_CAssignment, SK_StringInit, SK_ObjCObjectConversion,
  SK_ArrayInit, SK_ParenthesizedArrayInit, SK_PassByIndirectCopyRestore, SK_PassByIndirectRestore,
  SK_ProduceObjCObject, SK_StdInitializerList, SK_StdInitializerListConstructorCall, SK_OCLSamplerInit,
  SK_OCLZeroEvent
}
 Describes the kind of a particular step in an initialization sequence. More...
enum  FailureKind {
  FK_TooManyInitsForReference, FK_ArrayNeedsInitList, FK_ArrayNeedsInitListOrStringLiteral, FK_ArrayNeedsInitListOrWideStringLiteral,
  FK_NarrowStringIntoWideCharArray, FK_WideStringIntoCharArray, FK_IncompatWideStringIntoWideChar, FK_ArrayTypeMismatch,
  FK_NonConstantArrayInit, FK_AddressOfOverloadFailed, FK_ReferenceInitOverloadFailed, FK_NonConstLValueReferenceBindingToTemporary,
  FK_NonConstLValueReferenceBindingToUnrelated, FK_RValueReferenceBindingToLValue, FK_ReferenceInitDropsQualifiers, FK_ReferenceInitFailed,
  FK_ConversionFailed, FK_ConversionFromPropertyFailed, FK_TooManyInitsForScalar, FK_ReferenceBindingToInitList,
  FK_InitListBadDestinationType, FK_UserConversionOverloadFailed, FK_ConstructorOverloadFailed, FK_ListConstructorOverloadFailed,
  FK_DefaultInitOfConst, FK_Incomplete, FK_VariableLengthArrayHasInitializer, FK_ListInitializationFailed,
  FK_PlaceholderType, FK_ExplicitConstructor
}
 Describes why initialization failed. More...
typedef SmallVectorImpl< Step >
::const_iterator 
step_iterator

Public Member Functions

 InitializationSequence (Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, bool TopLevelOfInitList=false)
 Try to perform initialization of the given entity, creating a record of the steps required to perform the initialization.
void InitializeFrom (Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, bool TopLevelOfInitList)
 ~InitializationSequence ()
ExprResult Perform (Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
 Perform the actual initialization of the given entity based on the computed initialization sequence.
bool Diagnose (Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, ArrayRef< Expr * > Args)
 Diagnose an potentially-invalid initialization sequence.
enum SequenceKind getKind () const
 Determine the kind of initialization sequence computed.
void setSequenceKind (enum SequenceKind SK)
 Set the kind of sequence computed.
LLVM_EXPLICIT operator bool () const
 Determine whether the initialization sequence is valid.
bool Failed () const
 Determine whether the initialization sequence is invalid.
step_iterator step_begin () const
step_iterator step_end () const
bool isDirectReferenceBinding () const
 Determine whether this initialization is a direct reference binding (C++ [dcl.init.ref]).
bool isAmbiguous () const
 Determine whether this initialization failed due to an ambiguity.
bool isConstructorInitialization () const
 Determine whether this initialization is direct call to a constructor.
bool endsWithNarrowing (ASTContext &Ctx, const Expr *Initializer, bool *isInitializerConstant, APValue *ConstantValue) const
 Returns whether the last step in this initialization sequence is a narrowing conversion, defined by C++0x [dcl.init.list]p7.
void AddAddressOverloadResolutionStep (FunctionDecl *Function, DeclAccessPair Found, bool HadMultipleCandidates)
 Add a new step in the initialization that resolves the address of an overloaded function to a specific function declaration.
void AddDerivedToBaseCastStep (QualType BaseType, ExprValueKind Category)
 Add a new step in the initialization that performs a derived-to- base cast.
void AddReferenceBindingStep (QualType T, bool BindingTemporary)
 Add a new step binding a reference to an object.
void AddExtraneousCopyToTemporary (QualType T)
 Add a new step that makes an extraneous copy of the input to a temporary of the same class type.
void AddUserConversionStep (FunctionDecl *Function, DeclAccessPair FoundDecl, QualType T, bool HadMultipleCandidates)
 Add a new step invoking a conversion function, which is either a constructor or a conversion function.
void AddQualificationConversionStep (QualType Ty, ExprValueKind Category)
 Add a new step that performs a qualification conversion to the given type.
void AddAtomicConversionStep (QualType Ty)
 Add a new step that performs conversion from non-atomic to atomic type.
void AddLValueToRValueStep (QualType Ty)
 Add a new step that performs a load of the given type.
void AddConversionSequenceStep (const ImplicitConversionSequence &ICS, QualType T, bool TopLevelOfInitList=false)
 Add a new step that applies an implicit conversion sequence.
void AddListInitializationStep (QualType T)
 Add a list-initialization step.
void AddConstructorInitializationStep (CXXConstructorDecl *Constructor, AccessSpecifier Access, QualType T, bool HadMultipleCandidates, bool FromInitList, bool AsInitList)
 Add a constructor-initialization step.
void AddZeroInitializationStep (QualType T)
 Add a zero-initialization step.
void AddCAssignmentStep (QualType T)
 Add a C assignment step.
void AddStringInitStep (QualType T)
 Add a string init step.
void AddObjCObjectConversionStep (QualType T)
 Add an Objective-C object conversion step, which is always a no-op.
void AddArrayInitStep (QualType T)
 Add an array initialization step.
void AddParenthesizedArrayInitStep (QualType T)
 Add a parenthesized array initialization step.
void AddPassByIndirectCopyRestoreStep (QualType T, bool shouldCopy)
 Add a step to pass an object by indirect copy-restore.
void AddProduceObjCObjectStep (QualType T)
 Add a step to "produce" an Objective-C object (by retaining it).
void AddStdInitializerListConstructionStep (QualType T)
 Add a step to construct a std::initializer_list object from an initializer list.
void AddOCLSamplerInitStep (QualType T)
 Add a step to initialize an OpenCL sampler from an integer constant.
void AddOCLZeroEventStep (QualType T)
 Add a step to initialize an OpenCL event_t from a NULL constant.
void RewrapReferenceInitList (QualType T, InitListExpr *Syntactic)
 Add steps to unwrap a initializer list for a reference around a single element and rewrap it at the end.
void SetFailed (FailureKind Failure)
 Note that this initialization sequence failed.
void SetOverloadFailure (FailureKind Failure, OverloadingResult Result)
 Note that this initialization sequence failed due to failed overload resolution.
OverloadCandidateSetgetFailedCandidateSet ()
 Retrieve a reference to the candidate set when overload resolution fails.
OverloadingResult getFailedOverloadResult () const
 Get the overloading result, for when the initialization sequence failed due to a bad overload.
void setIncompleteTypeFailure (QualType IncompleteType)
 Note that this initialization sequence failed due to an incomplete type.
FailureKind getFailureKind () const
 Determine why initialization failed.
void dump (raw_ostream &OS) const
 Dump a representation of this initialization sequence to the given stream, for debugging purposes.
void dump () const
 Dump a representation of this initialization sequence to standard error, for debugging purposes.

Detailed Description

Describes the sequence of initializations required to initialize a given object or reference with a set of arguments.

Definition at line 620 of file Initialization.h.


Member Typedef Documentation

typedef SmallVectorImpl<Step>::const_iterator clang::InitializationSequence::step_iterator

Definition at line 929 of file Initialization.h.


Member Enumeration Documentation

Describes why initialization failed.

Enumerator:
FK_TooManyInitsForReference 

Too many initializers provided for a reference.

FK_ArrayNeedsInitList 

Array must be initialized with an initializer list.

FK_ArrayNeedsInitListOrStringLiteral 

Array must be initialized with an initializer list or a string literal.

FK_ArrayNeedsInitListOrWideStringLiteral 

Array must be initialized with an initializer list or a wide string literal.

FK_NarrowStringIntoWideCharArray 

Initializing a wide char array with narrow string literal.

FK_WideStringIntoCharArray 

Initializing char array with wide string literal.

FK_IncompatWideStringIntoWideChar 

Initializing wide char array with incompatible wide string literal.

FK_ArrayTypeMismatch 

Array type mismatch.

FK_NonConstantArrayInit 

Non-constant array initializer.

FK_AddressOfOverloadFailed 

Cannot resolve the address of an overloaded function.

FK_ReferenceInitOverloadFailed 

Overloading due to reference initialization failed.

FK_NonConstLValueReferenceBindingToTemporary 

Non-const lvalue reference binding to a temporary.

FK_NonConstLValueReferenceBindingToUnrelated 

Non-const lvalue reference binding to an lvalue of unrelated type.

FK_RValueReferenceBindingToLValue 

Rvalue reference binding to an lvalue.

FK_ReferenceInitDropsQualifiers 

Reference binding drops qualifiers.

FK_ReferenceInitFailed 

Reference binding failed.

FK_ConversionFailed 

Implicit conversion failed.

FK_ConversionFromPropertyFailed 

Implicit conversion failed.

FK_TooManyInitsForScalar 

Too many initializers for scalar.

FK_ReferenceBindingToInitList 

Reference initialization from an initializer list.

FK_InitListBadDestinationType 

Initialization of some unused destination type with an initializer list.

FK_UserConversionOverloadFailed 

Overloading for a user-defined conversion failed.

FK_ConstructorOverloadFailed 

Overloading for initialization by constructor failed.

FK_ListConstructorOverloadFailed 

Overloading for list-initialization by constructor failed.

FK_DefaultInitOfConst 

Default-initialization of a 'const' object.

FK_Incomplete 

Initialization of an incomplete type.

FK_VariableLengthArrayHasInitializer 

Variable-length array must not have an initializer.

FK_ListInitializationFailed 

List initialization failed at some point.

FK_PlaceholderType 

Initializer has a placeholder type which cannot be resolved by initialization.

FK_ExplicitConstructor 

List-copy-initialization chose an explicit constructor.

Definition at line 766 of file Initialization.h.

Describes the kind of initialization sequence computed.

Enumerator:
FailedSequence 

A failed initialization sequence. The failure kind tells what happened.

DependentSequence 

A dependent initialization, which could not be type-checked due to the presence of dependent types or dependently-typed expressions.

NormalSequence 

A normal sequence.

Definition at line 623 of file Initialization.h.

Describes the kind of a particular step in an initialization sequence.

Enumerator:
SK_ResolveAddressOfOverloadedFunction 

Resolve the address of an overloaded function to a specific function declaration.

SK_CastDerivedToBaseRValue 

Perform a derived-to-base cast, producing an rvalue.

SK_CastDerivedToBaseXValue 

Perform a derived-to-base cast, producing an xvalue.

SK_CastDerivedToBaseLValue 

Perform a derived-to-base cast, producing an lvalue.

SK_BindReference 

Reference binding to an lvalue.

SK_BindReferenceToTemporary 

Reference binding to a temporary.

SK_ExtraneousCopyToTemporary 

An optional copy of a temporary object to another temporary object, which is permitted (but not required) by C++98/03 but not C++0x.

SK_UserConversion 

Perform a user-defined conversion, either via a conversion function or via a constructor.

SK_QualificationConversionRValue 

Perform a qualification conversion, producing an rvalue.

SK_QualificationConversionXValue 

Perform a qualification conversion, producing an xvalue.

SK_QualificationConversionLValue 

Perform a qualification conversion, producing an lvalue.

SK_AtomicConversion 

Perform a conversion adding _Atomic to a type.

SK_LValueToRValue 

Perform a load from a glvalue, producing an rvalue.

SK_ConversionSequence 

Perform an implicit conversion sequence.

SK_ConversionSequenceNoNarrowing 

Perform an implicit conversion sequence without narrowing.

SK_ListInitialization 

Perform list-initialization without a constructor.

SK_UnwrapInitList 

Unwrap the single-element initializer list for a reference.

SK_RewrapInitList 

Rewrap the single-element initializer list for a reference.

SK_ConstructorInitialization 

Perform initialization via a constructor.

SK_ConstructorInitializationFromList 

Perform initialization via a constructor, taking arguments from a single InitListExpr.

SK_ZeroInitialization 

Zero-initialize the object.

SK_CAssignment 

C assignment.

SK_StringInit 

Initialization by string.

SK_ObjCObjectConversion 

An initialization that "converts" an Objective-C object (not a point to an object) to another Objective-C object type.

SK_ArrayInit 

Array initialization (from an array rvalue). This is a GNU C extension.

SK_ParenthesizedArrayInit 

Array initialization from a parenthesized initializer list. This is a GNU C++ extension.

SK_PassByIndirectCopyRestore 

Pass an object by indirect copy-and-restore.

SK_PassByIndirectRestore 

Pass an object by indirect restore.

SK_ProduceObjCObject 

Produce an Objective-C object pointer.

SK_StdInitializerList 

Construct a std::initializer_list from an initializer list.

SK_StdInitializerListConstructorCall 

Perform initialization via a constructor taking a single std::initializer_list argument.

SK_OCLSamplerInit 

Initialize an OpenCL sampler from an integer.

SK_OCLZeroEvent 

Passing zero to a function where OpenCL event_t is expected.

Definition at line 639 of file Initialization.h.


Constructor & Destructor Documentation

InitializationSequence::InitializationSequence ( Sema S,
const InitializedEntity Entity,
const InitializationKind Kind,
MultiExprArg  Args,
bool  TopLevelOfInitList = false 
)

Try to perform initialization of the given entity, creating a record of the steps required to perform the initialization.

The generated initialization sequence will either contain enough information to diagnose

Parameters:
Sthe semantic analysis object.
Entitythe entity being initialized.
Kindthe kind of initialization being performed.
Argsthe argument(s) provided for initialization.
TopLevelOfInitListtrue if we are initializing from an expression at the top level inside an initializer list. This disallows narrowing conversions in C++11 onwards.

Definition at line 4508 of file SemaInit.cpp.

References InitializeFrom().

Definition at line 4804 of file SemaInit.cpp.

References clang::InitializationSequence::Step::Destroy().


Member Function Documentation

void InitializationSequence::AddAddressOverloadResolutionStep ( FunctionDecl Function,
DeclAccessPair  Found,
bool  HadMultipleCandidates 
)

Add a new step in the initialization that resolves the address of an overloaded function to a specific function declaration.

Parameters:
Functionthe function to which the overloaded function reference resolves.

Definition at line 2811 of file SemaInit.cpp.

References clang::InitializationSequence::Step::F::FoundDecl, clang::InitializationSequence::Step::F::Function, clang::InitializationSequence::Step::Function, clang::ValueDecl::getType(), clang::InitializationSequence::Step::F::HadMultipleCandidates, clang::InitializationSequence::Step::Kind, S, SK_ResolveAddressOfOverloadedFunction, and clang::InitializationSequence::Step::Type.

Referenced by ResolveOverloadedFunctionForReferenceBinding().

Add an array initialization step.

Definition at line 2963 of file SemaInit.cpp.

References clang::InitializationSequence::Step::Kind, S, SK_ArrayInit, and clang::InitializationSequence::Step::Type.

Referenced by InitializeFrom().

Add a new step that performs conversion from non-atomic to atomic type.

Definition at line 2883 of file SemaInit.cpp.

References clang::InitializationSequence::Step::Kind, S, SK_AtomicConversion, and clang::InitializationSequence::Step::Type.

Referenced by InitializeFrom().

Add a C assignment step.

Definition at line 2942 of file SemaInit.cpp.

References clang::InitializationSequence::Step::Kind, S, SK_CAssignment, and clang::InitializationSequence::Step::Type.

Referenced by InitializeFrom().

void InitializationSequence::AddConstructorInitializationStep ( CXXConstructorDecl Constructor,
AccessSpecifier  Access,
QualType  T,
bool  HadMultipleCandidates,
bool  FromInitList,
bool  AsInitList 
)

Add a new step in the initialization that performs a derived-to- base cast.

Parameters:
BaseTypethe base type to which we will be casting.
CategoryIndicates whether the result will be treated as an rvalue, an xvalue, or an lvalue.

Definition at line 2823 of file SemaInit.cpp.

References clang::InitializationSequence::Step::Kind, S, SK_CastDerivedToBaseLValue, SK_CastDerivedToBaseRValue, SK_CastDerivedToBaseXValue, clang::InitializationSequence::Step::Type, clang::VK_LValue, clang::VK_RValue, and clang::VK_XValue.

Referenced by TryReferenceInitializationCore(), and TryRefInitWithConversionFunction().

Add a new step that makes an extraneous copy of the input to a temporary of the same class type.

This extraneous copy only occurs during reference binding in C++98/03, where we are permitted (but not required) to introduce an extra copy. At a bare minimum, we must check that we could call the copy constructor, and produce a diagnostic if the copy constructor is inaccessible or no copy constructor matches.

Parameters:
TThe type of the temporary being created.

Definition at line 2843 of file SemaInit.cpp.

References clang::InitializationSequence::Step::Kind, S, SK_ExtraneousCopyToTemporary, and clang::InitializationSequence::Step::Type.

Referenced by TryReferenceInitializationCore().

Add a list-initialization step.

Definition at line 2910 of file SemaInit.cpp.

References clang::InitializationSequence::Step::Kind, S, SK_ListInitialization, and clang::InitializationSequence::Step::Type.

Referenced by TryListInitialization().

Add a new step that performs a load of the given type.

Although the term "LValueToRValue" is conventional, this applies to both lvalues and xvalues.

Definition at line 2890 of file SemaInit.cpp.

References clang::QualType::hasQualifiers(), S, and SK_LValueToRValue.

Referenced by convertQualifiersAndValueKindIfNecessary().

Add an Objective-C object conversion step, which is always a no-op.

Definition at line 2956 of file SemaInit.cpp.

References clang::InitializationSequence::Step::Kind, S, SK_ObjCObjectConversion, and clang::InitializationSequence::Step::Type.

Referenced by TryReferenceInitializationCore(), and TryRefInitWithConversionFunction().

Add a step to initialize an OpenCL sampler from an integer constant.

Definition at line 3000 of file SemaInit.cpp.

References clang::InitializationSequence::Step::Kind, S, SK_OCLSamplerInit, and clang::InitializationSequence::Step::Type.

Referenced by TryOCLSamplerInitialization().

Add a step to initialize an OpenCL event_t from a NULL constant.

Definition at line 3007 of file SemaInit.cpp.

References clang::InitializationSequence::Step::Kind, S, SK_OCLZeroEvent, and clang::InitializationSequence::Step::Type.

Referenced by TryOCLZeroEventInitialization().

Add a parenthesized array initialization step.

Definition at line 2970 of file SemaInit.cpp.

References clang::InitializationSequence::Step::Kind, S, SK_ParenthesizedArrayInit, and clang::InitializationSequence::Step::Type.

Referenced by InitializeFrom().

Add a step to "produce" an Objective-C object (by retaining it).

Definition at line 2986 of file SemaInit.cpp.

References clang::InitializationSequence::Step::Kind, S, SK_ProduceObjCObject, and clang::InitializationSequence::Step::Type.

Referenced by MaybeProduceObjCObject().

Add a new step binding a reference to an object.

Parameters:
BindingTemporaryTrue if we are binding a reference to a temporary object (thereby extending its lifetime); false if we are binding to an lvalue or an lvalue treated as an rvalue.

Definition at line 2835 of file SemaInit.cpp.

References clang::InitializationSequence::Step::Kind, S, SK_BindReference, SK_BindReferenceToTemporary, and clang::InitializationSequence::Step::Type.

Referenced by TryReferenceInitializationCore(), TryReferenceListInitialization(), and TryRefInitWithConversionFunction().

Add a step to construct a std::initializer_list object from an initializer list.

Definition at line 2993 of file SemaInit.cpp.

References clang::InitializationSequence::Step::Kind, S, SK_StdInitializerList, and clang::InitializationSequence::Step::Type.

Referenced by TryInitializerListConstruction().

void InitializationSequence::AddUserConversionStep ( FunctionDecl Function,
DeclAccessPair  FoundDecl,
QualType  T,
bool  HadMultipleCandidates 
)
bool InitializationSequence::Diagnose ( Sema S,
const InitializedEntity Entity,
const InitializationKind Kind,
ArrayRef< Expr * >  Args 
)

Diagnose an potentially-invalid initialization sequence.

Returns:
true if the initialization sequence was ill-formed, false otherwise.

Definition at line 6478 of file SemaInit.cpp.

References clang::OverloadCandidateSet::BestViableFunction(), clang::Sema::Context, clang::Sema::CurContext, clang::Sema::Diag(), diagnoseListInit(), DiagnoseUninitializedReference(), clang::InitializedEntity::EK_Base, clang::InitializedEntity::EK_Member, emitBadConversionNotes(), Failed(), FK_AddressOfOverloadFailed, FK_ArrayNeedsInitList, FK_ArrayNeedsInitListOrStringLiteral, FK_ArrayNeedsInitListOrWideStringLiteral, FK_ArrayTypeMismatch, FK_ConstructorOverloadFailed, FK_ConversionFailed, FK_ConversionFromPropertyFailed, FK_DefaultInitOfConst, FK_ExplicitConstructor, FK_IncompatWideStringIntoWideChar, FK_Incomplete, FK_InitListBadDestinationType, FK_ListConstructorOverloadFailed, FK_ListInitializationFailed, FK_NarrowStringIntoWideCharArray, FK_NonConstantArrayInit, FK_NonConstLValueReferenceBindingToTemporary, FK_NonConstLValueReferenceBindingToUnrelated, FK_PlaceholderType, FK_ReferenceBindingToInitList, FK_ReferenceInitDropsQualifiers, FK_ReferenceInitFailed, FK_ReferenceInitOverloadFailed, FK_RValueReferenceBindingToLValue, FK_TooManyInitsForReference, FK_TooManyInitsForScalar, FK_UserConversionOverloadFailed, FK_VariableLengthArrayHasInitializer, FK_WideStringIntoCharArray, clang::Type::getAs(), clang::InitializedEntity::getBaseSpecifier(), clang::SourceRange::getBegin(), clang::InitializedEntity::getDecl(), clang::CXXConstructorDecl::getInheritedConstructor(), clang::InitializedEntity::getKind(), clang::InitializationKind::getKind(), clang::Decl::getLocation(), clang::InitializationKind::getLocation(), clang::Sema::getLocForEndOfToken(), clang::InitializedEntity::getName(), clang::QualType::getNonReferenceType(), clang::CXXMethodDecl::getParent(), clang::Sema::getSpecialMember(), clang::ASTContext::getTagDeclType(), clang::CXXBaseSpecifier::getType(), clang::InitializedEntity::getType(), clang::ASTContext::getTypeDeclType(), clang::Sema::HandleFunctionTypeMismatch(), clang::InitializationKind::IK_Default, clang::InitializationKind::IK_Value, clang::InitializationKind::isCStyleOrFunctionalCast(), clang::Decl::isImplicit(), clang::Sema::isImplicitlyDeleted(), clang::Type::isRecordType(), clang::Type::isReferenceType(), clang::QualType::isVolatileQualified(), maybeEmitZeroInitializationFixit(), clang::OverloadCandidateSet::NoteCandidates(), clang::Sema::NoteDeletedFunction(), clang::OCD_AllCandidates, clang::OCD_ViableCandidates, clang::OR_Ambiguous, clang::OR_Deleted, clang::OR_No_Viable_Function, clang::OR_Success, clang::Sema::PDiag(), Record, clang::Sema::RequireCompleteType(), clang::Sema::ResolveAddressOfOverloadedFunction(), and clang::SourceRange::setBegin().

Referenced by Perform(), and TryClassUnification().

void InitializationSequence::dump ( raw_ostream &  OS) const

Dump a representation of this initialization sequence to the given stream, for debugging purposes.

Definition at line 6848 of file SemaInit.cpp.

References DependentSequence, FailedSequence, FK_AddressOfOverloadFailed, FK_ArrayNeedsInitList, FK_ArrayNeedsInitListOrStringLiteral, FK_ArrayNeedsInitListOrWideStringLiteral, FK_ArrayTypeMismatch, FK_ConstructorOverloadFailed, FK_ConversionFailed, FK_ConversionFromPropertyFailed, FK_DefaultInitOfConst, FK_ExplicitConstructor, FK_IncompatWideStringIntoWideChar, FK_Incomplete, FK_InitListBadDestinationType, FK_ListConstructorOverloadFailed, FK_ListInitializationFailed, FK_NarrowStringIntoWideCharArray, FK_NonConstantArrayInit, FK_NonConstLValueReferenceBindingToTemporary, FK_NonConstLValueReferenceBindingToUnrelated, FK_PlaceholderType, FK_ReferenceBindingToInitList, FK_ReferenceInitDropsQualifiers, FK_ReferenceInitFailed, FK_ReferenceInitOverloadFailed, FK_RValueReferenceBindingToLValue, FK_TooManyInitsForReference, FK_TooManyInitsForScalar, FK_UserConversionOverloadFailed, FK_VariableLengthArrayHasInitializer, FK_WideStringIntoCharArray, NormalSequence, S, SK_ArrayInit, SK_AtomicConversion, SK_BindReference, SK_BindReferenceToTemporary, SK_CAssignment, SK_CastDerivedToBaseLValue, SK_CastDerivedToBaseRValue, SK_CastDerivedToBaseXValue, SK_ConstructorInitialization, SK_ConstructorInitializationFromList, SK_ConversionSequence, SK_ConversionSequenceNoNarrowing, SK_ExtraneousCopyToTemporary, SK_ListInitialization, SK_LValueToRValue, SK_ObjCObjectConversion, SK_OCLSamplerInit, SK_OCLZeroEvent, SK_ParenthesizedArrayInit, SK_PassByIndirectCopyRestore, SK_PassByIndirectRestore, SK_ProduceObjCObject, SK_QualificationConversionLValue, SK_QualificationConversionRValue, SK_QualificationConversionXValue, SK_ResolveAddressOfOverloadedFunction, SK_RewrapInitList, SK_StdInitializerList, SK_StdInitializerListConstructorCall, SK_StringInit, SK_UnwrapInitList, SK_UserConversion, SK_ZeroInitialization, step_begin(), and step_end().

Dump a representation of this initialization sequence to standard error, for debugging purposes.

Definition at line 7135 of file SemaInit.cpp.

bool clang::InitializationSequence::endsWithNarrowing ( ASTContext Ctx,
const Expr Initializer,
bool isInitializerConstant,
APValue ConstantValue 
) const

Returns whether the last step in this initialization sequence is a narrowing conversion, defined by C++0x [dcl.init.list]p7.

If this function returns true, *isInitializerConstant will be set to describe whether *Initializer was a constant expression. If isInitializerConstant is set to true, *ConstantValue will be set to the evaluated value of *Initializer.

Determine whether the initialization sequence is invalid.

Definition at line 927 of file Initialization.h.

References FailedSequence.

Referenced by Diagnose(), evaluateTypeTrait(), getFailureKind(), InitializeFrom(), isAmbiguous(), operator bool(), Perform(), TryClassUnification(), tryDiagnoseOverloadedCast(), and TryStaticImplicitCast().

Retrieve a reference to the candidate set when overload resolution fails.

Definition at line 1093 of file Initialization.h.

Referenced by TryConstructorInitialization(), tryDiagnoseOverloadedCast(), TryReferenceInitializationCore(), TryRefInitWithConversionFunction(), and TryUserDefinedConversion().

Get the overloading result, for when the initialization sequence failed due to a bad overload.

Definition at line 1099 of file Initialization.h.

Referenced by tryDiagnoseOverloadedCast().

Determine why initialization failed.

Definition at line 1111 of file Initialization.h.

References Failed().

Referenced by isAmbiguous(), and tryDiagnoseOverloadedCast().

Determine the kind of initialization sequence computed.

Definition at line 918 of file Initialization.h.

Referenced by Perform().

void InitializationSequence::InitializeFrom ( Sema S,
const InitializedEntity Entity,
const InitializationKind Kind,
MultiExprArg  Args,
bool  TopLevelOfInitList 
)

Definition at line 4517 of file SemaInit.cpp.

References AddArrayInitStep(), AddAtomicConversionStep(), AddCAssignmentStep(), AddConversionSequenceStep(), AddParenthesizedArrayInitStep(), AddPassByIndirectCopyRestoreStep(), AddZeroInitializationStep(), clang::Sema::CheckObjCBridgeRelatedConversions(), clang::Sema::CheckPlaceholderExpr(), clang::Sema::Context, Context, clang::Sema::ConversionToObjCStringLiteralCheck(), DependentSequence, clang::InitializedEntity::EK_Member, Failed(), clang::StandardConversionSequence::First, FK_AddressOfOverloadFailed, FK_ArrayNeedsInitList, FK_ArrayNeedsInitListOrStringLiteral, FK_ArrayNeedsInitListOrWideStringLiteral, FK_ArrayTypeMismatch, FK_ConversionFailed, FK_IncompatWideStringIntoWideChar, FK_NarrowStringIntoWideCharArray, FK_NonConstantArrayInit, FK_PlaceholderType, FK_TooManyInitsForReference, FK_TooManyInitsForScalar, FK_VariableLengthArrayHasInitializer, FK_WideStringIntoCharArray, clang::ActionResult< PtrTy, CompressInvalid >::get(), clang::Type::getAs(), clang::ASTContext::getAsArrayType(), clang::InitializedEntity::getDecl(), clang::InitializedEntity::getKind(), clang::InitializationKind::getKind(), clang::Sema::getLangOpts(), clang::Stmt::getLocStart(), clang::StandardConversionSequence::getToType(), clang::Expr::getType(), clang::InitializedEntity::getType(), clang::Expr::hasAnyTypeDependentArguments(), hasCompatibleArrayTypes(), clang::ASTContext::hasSameUnqualifiedType(), clang::Expr::HasSideEffects(), clang::ICK_Array_To_Pointer, clang::ICK_Lvalue_To_Rvalue, clang::ICK_Writeback_Conversion, clang::Expr::IgnoreParens(), clang::InitializationKind::IK_Copy, clang::InitializationKind::IK_Default, clang::InitializationKind::IK_Direct, clang::InitializationKind::IK_Value, clang::Type::isArrayType(), clang::ImplicitConversionSequence::isBad(), clang::InitializationKind::isCStyleOrFunctionalCast(), clang::Type::isDependentType(), clang::Sema::IsDerivedFrom(), clang::ActionResult< PtrTy, CompressInvalid >::isInvalid(), isLibstdcxxPointerReturnFalseHack(), clang::QualType::isNull(), clang::InitializedEntity::isParameterKind(), clang::Type::isRecordType(), clang::Type::isReferenceType(), clang::ImplicitConversionSequence::isStandard(), IsStringInit(), IsWideCharCompatible(), MaybeProduceObjCObject(), NormalSequence, clang::Decl::OBJC_TQ_Out, clang::ASTContext::OverloadTy, clang::Sema::ResolveAddressOfOverloadedFunction(), clang::StandardConversionSequence::Second, clang::StandardConversionSequence::setAllToTypes(), clang::StandardConversionSequence::setAsIdentityConversion(), SetFailed(), setSequenceKind(), clang::ImplicitConversionSequence::setStandard(), SIF_IncompatWideStringIntoWideChar, SIF_NarrowStringIntoWideChar, SIF_None, SIF_Other, SIF_WideStringIntoChar, clang::ImplicitConversionSequence::Standard, TryConstructorInitialization(), TryDefaultInitialization(), clang::Sema::TryImplicitConversion(), TryListInitialization(), tryObjCWritebackConversion(), TryOCLSamplerInitialization(), TryOCLZeroEventInitialization(), TryReferenceInitialization(), TryStringLiteralInitialization(), TryUserDefinedConversion(), and TryValueInitialization().

Referenced by InitializationSequence(), and TryListInitialization().

Determine whether this initialization is direct call to a constructor.

Definition at line 2805 of file SemaInit.cpp.

References SK_ConstructorInitialization.

Referenced by TryStaticImplicitCast().

Determine whether this initialization is a direct reference binding (C++ [dcl.init.ref]).

Definition at line 2758 of file SemaInit.cpp.

References SK_BindReference.

Referenced by TryClassUnification().

LLVM_EXPLICIT clang::InitializationSequence::operator bool ( ) const [inline]

Determine whether the initialization sequence is valid.

Definition at line 924 of file Initialization.h.

References Failed().

ExprResult InitializationSequence::Perform ( Sema S,
const InitializedEntity Entity,
const InitializationKind Kind,
MultiExprArg  Args,
QualType ResultType = nullptr 
)

Perform the actual initialization of the given entity based on the computed initialization sequence.

Parameters:
Sthe semantic analysis object.
Entitythe entity being initialized.
Kindthe kind of initialization being performed.
Argsthe argument(s) provided for initialization, ownership of which is transferred into the routine.
ResultTypeif non-NULL, will be set to the type of the initialized object, which is the type of the declaration in most cases. However, when the initialized object is a variable of incomplete array type and the initializer is an initializer list, this type will be set to the completed array type.
Returns:
an expression that performs the actual object initialization, if the initialization is well-formed. Otherwise, emits diagnostics and returns an invalid expression.

Definition at line 5640 of file SemaInit.cpp.

References clang::Sema::ActOnParenListExpr(), clang::Sema::BasePathInvolvesVirtualBase(), clang::Sema::BuildCXXConstructExpr(), clang::Sema::BuildCXXMemberCallExpr(), clang::Sema::CCK_CStyleCast, clang::Sema::CCK_FunctionalCast, clang::Sema::CCK_ImplicitConversion, clang::Sema::CCK_OtherCast, clang::Sema::CheckAddressOfMemberAccess(), clang::Sema::CheckConstructorAccess(), clang::Sema::CheckDerivedToBaseConversion(), clang::Sema::CheckDestructorAccess(), clang::Sema::CheckExceptionSpecCompatibility(), checkIndirectCopyRestoreSource(), clang::Sema::CheckMemberOperatorAccess(), clang::Sema::CheckSingleAssignmentConstraints(), CheckStringInit(), clang::Sema::CheckTransparentUnionArgumentConstraints(), clang::CK_ARCProduceObject, clang::CXXConstructExpr::CK_Complete, clang::CK_ConstructorConversion, clang::CK_DerivedToBase, clang::CK_LValueToRValue, clang::CK_NonAtomicToAtomic, clang::CK_NoOp, clang::CK_ObjCObjectLValueCast, clang::CK_UserDefinedConversion, clang::CK_ZeroToOCLEvent, clang::Expr::ClassifyLValue(), clang::Sema::Compatible, clang::Sema::CompleteConstructorCall(), clang::Sema::Context, CopyObject(), clang::ImplicitCastExpr::Create(), DependentSequence, clang::Sema::Diag(), Diagnose(), clang::Sema::DiagnoseAssignmentResult(), DiagnoseNarrowingInInitList(), clang::Sema::DiagnoseUseOfDecl(), clang::InitializedEntity::EK_Member, clang::InitializedEntity::EK_Parameter_CF_Audited, clang::InitializedEntity::EK_Variable, clang::ExprError(), clang::Sema::ExprNeedsCleanups, Failed(), clang::Sema::FixOverloadedFunctionReference(), clang::InitializationSequence::Step::F::FoundDecl, clang::InitializationSequence::Step::F::Function, clang::InitializationSequence::Step::Function, clang::ActionResult< PtrTy, CompressInvalid >::get(), clang::DeclAccessPair::getAccess(), clang::TypeLoc::getAs(), clang::ActionResult< PtrTy, CompressInvalid >::getAs(), clang::Type::getAs(), clang::ASTContext::getAsArrayType(), clang::ASTContext::getAsConstantArrayType(), clang::ASTContext::getAsIncompleteArrayType(), getAssignmentAction(), clang::SourceRange::getBegin(), clang::ASTContext::getConstantArrayType(), clang::InitializedEntity::getDecl(), clang::NamedDecl::getDeclName(), clang::ASTContext::getDependentSizedArrayType(), clang::SourceRange::getEnd(), getEntityForTemporaryLifetimeExtension(), clang::InitializedEntity::getKind(), clang::InitializationKind::getKind(), getKind(), clang::Sema::getLangOpts(), clang::InitListExpr::getLBraceLoc(), clang::Decl::getLocation(), clang::InitializationKind::getLocation(), clang::Stmt::getLocStart(), clang::ASTContext::getLValueReferenceType(), clang::QualType::getNonLValueExprType(), clang::QualType::getNonReferenceType(), clang::InitializationKind::getParenRange(), clang::Type::getPointeeType(), clang::InitializationKind::getRange(), clang::InitListExpr::getRBraceLoc(), clang::ASTContext::getRValueReferenceType(), clang::Expr::getSourceBitField(), clang::Stmt::getSourceRange(), clang::MaterializeTemporaryExpr::getStorageDuration(), clang::ASTContext::getTrivialTypeSourceInfo(), clang::TypeSourceInfo::getType(), clang::Expr::getType(), clang::InitializedEntity::getType(), clang::ValueDecl::getType(), clang::ASTContext::getTypeDeclType(), clang::InitializedEntity::getTypeSourceInfo(), clang::Expr::getValueKind(), clang::InitializationSequence::Step::F::HadMultipleCandidates, clang::ASTContext::hasSameType(), clang::ASTContext::hasSameUnqualifiedType(), clang::InitializationSequence::Step::ICS, clang::InitializationKind::IK_Copy, clang::InitializationKind::IK_Direct, clang::InitializationKind::IK_DirectList, clang::InitializationKind::IK_Value, clang::Sema::ImpCastExprToType(), InitializedEntityOutlivesFullExpression(), clang::InitializedEntity::InitializeTemporary(), clang::InitializationKind::isCStyleCast(), clang::InitializationKind::isCStyleOrFunctionalCast(), clang::Type::isDependentType(), clang::Sema::IsDerivedFrom(), clang::QualType::isDestructedType(), clang::Type::isEventT(), clang::InitializationKind::isExplicitCast(), clang::InitializationKind::isFunctionalCast(), clang::Expr::isGLValue(), clang::InitializationKind::isImplicitValueInit(), clang::Type::isIncompleteArrayType(), clang::ActionResult< PtrTy, CompressInvalid >::isInvalid(), clang::Type::isLValueReferenceType(), clang::Type::isObjCLifetimeType(), clang::InitializedEntity::isParameterKind(), clang::Type::isPointerType(), isReferenceBinding(), clang::Type::isReferenceType(), clang::Expr::isRValue(), clang::Type::isSamplerT(), clang::ReferenceType::isSpelledAsLValue(), clang::Expr::isValueDependent(), clang::QualType::isVolatileQualified(), clang::InitializationSequence::Step::Kind, clang::Sema::LookupDestructor(), clang::Expr::LV_ArrayTemporary, clang::Expr::LV_ClassTemporary, clang::Sema::MarkFunctionReferenced(), clang::Sema::MarkVTableUsed(), clang::Sema::MaybeBindToTemporary(), clang::ArrayType::Normal, clang::Sema::PDiag(), PerformConstructorInitialization(), clang::Sema::PerformImplicitConversion(), clang::Sema::PerformObjectArgumentInitialization(), performReferenceExtension(), Record, clang::Expr::refersToBitField(), clang::Expr::refersToVectorElement(), S, clang::SD_Automatic, clang::InitListExpr::setSyntacticForm(), clang::Expr::setType(), clang::Expr::setValueKind(), shouldBindAsTemporary(), shouldDestroyTemporary(), SK_ArrayInit, SK_AtomicConversion, SK_BindReference, SK_BindReferenceToTemporary, SK_CAssignment, SK_CastDerivedToBaseLValue, SK_CastDerivedToBaseRValue, SK_CastDerivedToBaseXValue, SK_ConstructorInitialization, SK_ConstructorInitializationFromList, SK_ConversionSequence, SK_ConversionSequenceNoNarrowing, SK_ExtraneousCopyToTemporary, SK_ListInitialization, SK_LValueToRValue, SK_ObjCObjectConversion, SK_OCLSamplerInit, SK_OCLZeroEvent, SK_ParenthesizedArrayInit, SK_PassByIndirectCopyRestore, SK_PassByIndirectRestore, SK_ProduceObjCObject, SK_QualificationConversionLValue, SK_QualificationConversionRValue, SK_QualificationConversionXValue, SK_ResolveAddressOfOverloadedFunction, SK_RewrapInitList, SK_StdInitializerList, SK_StdInitializerListConstructorCall, SK_StringInit, SK_UnwrapInitList, SK_UserConversion, SK_ZeroInitialization, step_begin(), step_end(), clang::InitializationSequence::Step::Type, clang::VK_LValue, clang::VK_RValue, clang::VK_XValue, warnOnLifetimeExtension(), and clang::InitializationSequence::Step::WrappingSyntacticList.

Referenced by clang::Sema::ActOnOpenMPFirstprivateClause(), clang::Sema::BuildCompoundLiteralExpr(), clang::Sema::BuildCXXNew(), clang::Sema::BuildCXXTypeConstructExpr(), clang::Sema::BuildExceptionDeclaration(), BuildImplicitMemberInitializer(), ConvertForConditional(), evaluateTypeTrait(), clang::Sema::FindCompositePointerType(), clang::Sema::performLambdaInitCaptureInitialization(), and TryStaticImplicitCast().

Add steps to unwrap a initializer list for a reference around a single element and rewrap it at the end.

Definition at line 3014 of file SemaInit.cpp.

References clang::InitListExpr::getInit(), clang::InitListExpr::getNumInits(), clang::Expr::getType(), S, SK_RewrapInitList, and SK_UnwrapInitList.

Referenced by TryListInitialization(), and TryReferenceListInitialization().

Note that this initialization sequence failed due to an incomplete type.

Definition at line 1105 of file Initialization.h.

References FK_Incomplete, and SetFailed().

Referenced by TryConstructorInitialization(), TryInitializerListConstruction(), and TryListInitialization().

Note that this initialization sequence failed due to failed overload resolution.

Definition at line 3029 of file SemaInit.cpp.

References FailedSequence, and setSequenceKind().

Referenced by TryConstructorInitialization(), TryReferenceInitializationCore(), and TryUserDefinedConversion().

Set the kind of sequence computed.

Definition at line 921 of file Initialization.h.

Referenced by InitializeFrom(), and SetOverloadFailure().

Definition at line 930 of file Initialization.h.

Referenced by dump(), Perform(), and TryReferenceListInitialization().

Definition at line 931 of file Initialization.h.

Referenced by dump(), Perform(), and TryReferenceListInitialization().


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