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

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

#include "clang/Sema/Initialization.h"

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_FinalCopy,
  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_ArrayLoopIndex, SK_ArrayLoopInit, SK_ArrayInit,
  SK_GNUArrayInit, SK_ParenthesizedArrayInit, SK_PassByIndirectCopyRestore, SK_PassByIndirectRestore,
  SK_ProduceObjCObject, SK_StdInitializerList, SK_StdInitializerListConstructorCall, SK_OCLSamplerInit,
  SK_OCLZeroQueue, SK_OCLZeroEvent
}
 Describes the kind of a particular step in an initialization sequence. More...
 
enum  FailureKind {
  FK_TooManyInitsForReference, FK_ParenthesizedListInitForReference, FK_ArrayNeedsInitList, FK_ArrayNeedsInitListOrStringLiteral,
  FK_ArrayNeedsInitListOrWideStringLiteral, FK_NarrowStringIntoWideCharArray, FK_WideStringIntoCharArray, FK_IncompatWideStringIntoWideChar,
  FK_ArrayTypeMismatch, FK_NonConstantArrayInit, FK_AddressOfOverloadFailed, FK_ReferenceInitOverloadFailed,
  FK_NonConstLValueReferenceBindingToTemporary, FK_NonConstLValueReferenceBindingToBitfield, FK_NonConstLValueReferenceBindingToVectorElement, FK_NonConstLValueReferenceBindingToUnrelated,
  FK_RValueReferenceBindingToLValue, FK_ReferenceInitDropsQualifiers, FK_ReferenceInitFailed, FK_ConversionFailed,
  FK_ConversionFromPropertyFailed, FK_TooManyInitsForScalar, FK_ParenthesizedListInitForScalar, FK_ReferenceBindingToInitList,
  FK_InitListBadDestinationType, FK_UserConversionOverloadFailed, FK_ConstructorOverloadFailed, FK_ListConstructorOverloadFailed,
  FK_DefaultInitOfConst, FK_Incomplete, FK_VariableLengthArrayHasInitializer, FK_ListInitializationFailed,
  FK_PlaceholderType, FK_AddressOfUnaddressableFunction, FK_ExplicitConstructor
}
 Describes why initialization failed. More...
 
typedef SmallVectorImpl< Step >::const_iterator step_iterator
 
typedef llvm::iterator_range< step_iteratorstep_range
 

Public Member Functions

void SetZeroInitializationFixit (const std::string &Fixit, SourceLocation L)
 Call for initializations are invalid but that would be valid zero initialzations if Fixit was applied. More...
 
 InitializationSequence (Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, bool TopLevelOfInitList=false, bool TreatUnavailableAsInvalid=true)
 Try to perform initialization of the given entity, creating a record of the steps required to perform the initialization. More...
 
void InitializeFrom (Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, bool TopLevelOfInitList, bool TreatUnavailableAsInvalid)
 
 ~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. More...
 
bool Diagnose (Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, ArrayRef< Expr *> Args)
 Diagnose an potentially-invalid initialization sequence. More...
 
enum SequenceKind getKind () const
 Determine the kind of initialization sequence computed. More...
 
void setSequenceKind (enum SequenceKind SK)
 Set the kind of sequence computed. More...
 
 operator bool () const
 Determine whether the initialization sequence is valid. More...
 
bool Failed () const
 Determine whether the initialization sequence is invalid. More...
 
step_iterator step_begin () const
 
step_iterator step_end () const
 
step_range steps () const
 
bool isDirectReferenceBinding () const
 Determine whether this initialization is a direct reference binding (C++ [dcl.init.ref]). More...
 
bool isAmbiguous () const
 Determine whether this initialization failed due to an ambiguity. More...
 
bool isConstructorInitialization () const
 Determine whether this initialization is direct call to a constructor. More...
 
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. More...
 
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. More...
 
void AddDerivedToBaseCastStep (QualType BaseType, ExprValueKind Category)
 Add a new step in the initialization that performs a derived-to- base cast. More...
 
void AddReferenceBindingStep (QualType T, bool BindingTemporary)
 Add a new step binding a reference to an object. More...
 
void AddExtraneousCopyToTemporary (QualType T)
 Add a new step that makes an extraneous copy of the input to a temporary of the same class type. More...
 
void AddFinalCopy (QualType T)
 Add a new step that makes a copy of the input to an object of the given type, as the final step in class copy-initialization. More...
 
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. More...
 
void AddQualificationConversionStep (QualType Ty, ExprValueKind Category)
 Add a new step that performs a qualification conversion to the given type. More...
 
void AddAtomicConversionStep (QualType Ty)
 Add a new step that performs conversion from non-atomic to atomic type. More...
 
void AddLValueToRValueStep (QualType Ty)
 Add a new step that performs a load of the given type. More...
 
void AddConversionSequenceStep (const ImplicitConversionSequence &ICS, QualType T, bool TopLevelOfInitList=false)
 Add a new step that applies an implicit conversion sequence. More...
 
void AddListInitializationStep (QualType T)
 Add a list-initialization step. More...
 
void AddConstructorInitializationStep (DeclAccessPair FoundDecl, CXXConstructorDecl *Constructor, QualType T, bool HadMultipleCandidates, bool FromInitList, bool AsInitList)
 Add a constructor-initialization step. More...
 
void AddZeroInitializationStep (QualType T)
 Add a zero-initialization step. More...
 
void AddCAssignmentStep (QualType T)
 Add a C assignment step. More...
 
void AddStringInitStep (QualType T)
 Add a string init step. More...
 
void AddObjCObjectConversionStep (QualType T)
 Add an Objective-C object conversion step, which is always a no-op. More...
 
void AddArrayInitLoopStep (QualType T, QualType EltTy)
 Add an array initialization loop step. More...
 
void AddArrayInitStep (QualType T, bool IsGNUExtension)
 Add an array initialization step. More...
 
void AddParenthesizedArrayInitStep (QualType T)
 Add a parenthesized array initialization step. More...
 
void AddPassByIndirectCopyRestoreStep (QualType T, bool shouldCopy)
 Add a step to pass an object by indirect copy-restore. More...
 
void AddProduceObjCObjectStep (QualType T)
 Add a step to "produce" an Objective-C object (by retaining it). More...
 
void AddStdInitializerListConstructionStep (QualType T)
 Add a step to construct a std::initializer_list object from an initializer list. More...
 
void AddOCLSamplerInitStep (QualType T)
 Add a step to initialize an OpenCL sampler from an integer constant. More...
 
void AddOCLZeroEventStep (QualType T)
 Add a step to initialize an OpenCL event_t from a NULL constant. More...
 
void AddOCLZeroQueueStep (QualType T)
 Add a step to initialize an OpenCL queue_t from 0. More...
 
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. More...
 
void SetFailed (FailureKind Failure)
 Note that this initialization sequence failed. More...
 
void SetOverloadFailure (FailureKind Failure, OverloadingResult Result)
 Note that this initialization sequence failed due to failed overload resolution. More...
 
OverloadCandidateSetgetFailedCandidateSet ()
 Retrieve a reference to the candidate set when overload resolution fails. More...
 
OverloadingResult getFailedOverloadResult () const
 Get the overloading result, for when the initialization sequence failed due to a bad overload. More...
 
void setIncompleteTypeFailure (QualType IncompleteType)
 Note that this initialization sequence failed due to an incomplete type. More...
 
FailureKind getFailureKind () const
 Determine why initialization failed. More...
 
void dump (raw_ostream &OS) const
 Dump a representation of this initialization sequence to the given stream, for debugging purposes. More...
 
void dump () const
 Dump a representation of this initialization sequence to standard error, for debugging purposes. More...
 

Detailed Description

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

Definition at line 675 of file Initialization.h.

Member Typedef Documentation

◆ step_iterator

Definition at line 1023 of file Initialization.h.

◆ step_range

Definition at line 1027 of file Initialization.h.

Member Enumeration Documentation

◆ FailureKind

Describes why initialization failed.

Enumerator
FK_TooManyInitsForReference 

Too many initializers provided for a reference.

FK_ParenthesizedListInitForReference 

Reference initialized from a parenthesized initializer list.

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_NonConstLValueReferenceBindingToBitfield 

Non-const lvalue reference binding to a bit-field.

FK_NonConstLValueReferenceBindingToVectorElement 

Non-const lvalue reference binding to a vector element.

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_ParenthesizedListInitForScalar 

Scalar initialized from a parenthesized initializer list.

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_AddressOfUnaddressableFunction 

Trying to take the address of a function that doesn't support having its address taken.

FK_ExplicitConstructor 

List-copy-initialization chose an explicit constructor.

Definition at line 831 of file Initialization.h.

◆ SequenceKind

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

◆ StepKind

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_FinalCopy 

Direct-initialization from a reference-related object in the final stage of class copy-initialization.

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_ArrayLoopIndex 

Array indexing for initialization by elementwise copy.

SK_ArrayLoopInit 

Array initialization by elementwise copy.

SK_ArrayInit 

Array initialization (from an array rvalue).

SK_GNUArrayInit 

Array initialization (from an array rvalue) as a GNU 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_OCLZeroQueue 

Initialize queue_t from 0.

SK_OCLZeroEvent 

Passing zero to a function where OpenCL event_t is expected.

Definition at line 694 of file Initialization.h.

Constructor & Destructor Documentation

◆ InitializationSequence()

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

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.
TreatUnavailableAsInvalidtrue if we want to treat unavailable as invalid.

Definition at line 5159 of file SemaInit.cpp.

References InitializeFrom().

◆ ~InitializationSequence()

InitializationSequence::~InitializationSequence ( )

Definition at line 5552 of file SemaInit.cpp.

Member Function Documentation

◆ AddAddressOverloadResolutionStep()

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 3204 of file SemaInit.cpp.

Referenced by isConstructorInitialization(), and ResolveOverloadedFunctionForReferenceBinding().

◆ AddArrayInitLoopStep()

void InitializationSequence::AddArrayInitLoopStep ( QualType  T,
QualType  EltTy 
)

Add an array initialization loop step.

Definition at line 3366 of file SemaInit.cpp.

◆ AddArrayInitStep()

void InitializationSequence::AddArrayInitStep ( QualType  T,
bool  IsGNUExtension 
)

Add an array initialization step.

Definition at line 3359 of file SemaInit.cpp.

◆ AddAtomicConversionStep()

void InitializationSequence::AddAtomicConversionStep ( QualType  Ty)

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

Definition at line 3283 of file SemaInit.cpp.

◆ AddCAssignmentStep()

void InitializationSequence::AddCAssignmentStep ( QualType  T)

Add a C assignment step.

Definition at line 3338 of file SemaInit.cpp.

◆ AddConstructorInitializationStep()

void InitializationSequence::AddConstructorInitializationStep ( DeclAccessPair  FoundDecl,
CXXConstructorDecl Constructor,
QualType  T,
bool  HadMultipleCandidates,
bool  FromInitList,
bool  AsInitList 
)

Add a constructor-initialization step.

Parameters
FromInitListThe constructor call is syntactically an initializer list.
AsInitListThe constructor is called as an init list constructor.

Definition at line 3317 of file SemaInit.cpp.

Referenced by TryConstructorInitialization().

◆ AddConversionSequenceStep()

void InitializationSequence::AddConversionSequenceStep ( const ImplicitConversionSequence ICS,
QualType  T,
bool  TopLevelOfInitList = false 
)

Add a new step that applies an implicit conversion sequence.

Definition at line 3299 of file SemaInit.cpp.

Referenced by tryObjCWritebackConversion(), and TryReferenceInitializationCore().

◆ AddDerivedToBaseCastStep()

void InitializationSequence::AddDerivedToBaseCastStep ( QualType  BaseType,
ExprValueKind  Category 
)

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 3216 of file SemaInit.cpp.

Referenced by TryReferenceInitializationCore().

◆ AddExtraneousCopyToTemporary()

void InitializationSequence::AddExtraneousCopyToTemporary ( QualType  T)

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 3243 of file SemaInit.cpp.

Referenced by TryReferenceInitializationCore().

◆ AddFinalCopy()

void InitializationSequence::AddFinalCopy ( QualType  T)

Add a new step that makes a copy of the input to an object of the given type, as the final step in class copy-initialization.

Definition at line 3236 of file SemaInit.cpp.

◆ AddListInitializationStep()

void InitializationSequence::AddListInitializationStep ( QualType  T)

Add a list-initialization step.

Definition at line 3310 of file SemaInit.cpp.

◆ AddLValueToRValueStep()

void InitializationSequence::AddLValueToRValueStep ( QualType  Ty)

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 3290 of file SemaInit.cpp.

References clang::QualType::hasQualifiers().

◆ AddObjCObjectConversionStep()

void InitializationSequence::AddObjCObjectConversionStep ( QualType  T)

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

Definition at line 3352 of file SemaInit.cpp.

Referenced by TryReferenceInitializationCore().

◆ AddOCLSamplerInitStep()

void InitializationSequence::AddOCLSamplerInitStep ( QualType  T)

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

Definition at line 3407 of file SemaInit.cpp.

Referenced by TryOCLSamplerInitialization().

◆ AddOCLZeroEventStep()

void InitializationSequence::AddOCLZeroEventStep ( QualType  T)

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

Definition at line 3414 of file SemaInit.cpp.

Referenced by TryOCLZeroEventInitialization().

◆ AddOCLZeroQueueStep()

void InitializationSequence::AddOCLZeroQueueStep ( QualType  T)

Add a step to initialize an OpenCL queue_t from 0.

Definition at line 3421 of file SemaInit.cpp.

Referenced by TryOCLZeroQueueInitialization().

◆ AddParenthesizedArrayInitStep()

void InitializationSequence::AddParenthesizedArrayInitStep ( QualType  T)

Add a parenthesized array initialization step.

Definition at line 3377 of file SemaInit.cpp.

◆ AddPassByIndirectCopyRestoreStep()

void InitializationSequence::AddPassByIndirectCopyRestoreStep ( QualType  T,
bool  shouldCopy 
)

Add a step to pass an object by indirect copy-restore.

Definition at line 3384 of file SemaInit.cpp.

References clang::InitializationSequence::Step::Kind, clang::InitializationSequence::Step::Type, and clang::ast_matchers::type.

Referenced by tryObjCWritebackConversion().

◆ AddProduceObjCObjectStep()

void InitializationSequence::AddProduceObjCObjectStep ( QualType  T)

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

Definition at line 3393 of file SemaInit.cpp.

Referenced by MaybeProduceObjCObject().

◆ AddQualificationConversionStep()

void InitializationSequence::AddQualificationConversionStep ( QualType  Ty,
ExprValueKind  Category 
)

Add a new step that performs a qualification conversion to the given type.

Definition at line 3264 of file SemaInit.cpp.

Referenced by TryConstructorInitialization(), and TryReferenceInitializationCore().

◆ AddReferenceBindingStep()

void InitializationSequence::AddReferenceBindingStep ( QualType  T,
bool  BindingTemporary 
)

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 3228 of file SemaInit.cpp.

Referenced by TryReferenceInitializationCore(), and TryReferenceListInitialization().

◆ AddStdInitializerListConstructionStep()

void InitializationSequence::AddStdInitializerListConstructionStep ( QualType  T)

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

Definition at line 3400 of file SemaInit.cpp.

◆ AddStringInitStep()

void InitializationSequence::AddStringInitStep ( QualType  T)

Add a string init step.

Definition at line 3345 of file SemaInit.cpp.

Referenced by TryStringLiteralInitialization().

◆ AddUserConversionStep()

void InitializationSequence::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.

Definition at line 3251 of file SemaInit.cpp.

Referenced by TryConstructorInitialization().

◆ AddZeroInitializationStep()

void InitializationSequence::AddZeroInitializationStep ( QualType  T)

Add a zero-initialization step.

Definition at line 3331 of file SemaInit.cpp.

Referenced by maybeRecoverWithZeroInitialization(), TryDefaultInitialization(), and TryValueInitialization().

◆ Diagnose()

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 7516 of file SemaInit.cpp.

References clang::OverloadCandidateSet::BestViableFunction(), clang::Sema::checkAddressOfFunctionIsAvailable(), clang::Sema::Context, clang::Sema::CurContext, clang::Sema::Diag(), diagnoseListInit(), DiagnoseUninitializedReference(), clang::InitializedEntity::EK_Base, clang::InitializedEntity::EK_Member, clang::InitializedEntity::EK_Result, emitBadConversionNotes(), Failed(), FK_AddressOfOverloadFailed, FK_AddressOfUnaddressableFunction, 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_NonConstLValueReferenceBindingToBitfield, FK_NonConstLValueReferenceBindingToTemporary, FK_NonConstLValueReferenceBindingToUnrelated, FK_NonConstLValueReferenceBindingToVectorElement, FK_ParenthesizedListInitForReference, FK_ParenthesizedListInitForScalar, 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::Qualifiers::getCVRQualifiers(), clang::InitializedEntity::getDecl(), clang::NamedDecl::getDeclName(), clang::CXXConstructorDecl::getInheritedConstructor(), clang::InitListExpr::getInit(), clang::InitializedEntity::getKind(), clang::InitializationKind::getKind(), clang::Decl::getLocation(), clang::InitializationKind::getLocation(), clang::Stmt::getLocEnd(), clang::InitListExpr::getLocEnd(), clang::Sema::getLocForEndOfToken(), clang::InitializedEntity::getName(), clang::QualType::getNonReferenceType(), clang::InitListExpr::getNumInits(), clang::CXXMethodDecl::getParent(), clang::QualType::getQualifiers(), clang::tooling::fixit::internal::getSourceRange(), 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(), 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(), clang::Sema::RequireCompleteType(), clang::Sema::ResolveAddressOfOverloadedFunction(), and clang::SourceRange::setBegin().

Referenced by getAssignmentAction(), Perform(), and TryClassUnification().

◆ dump() [1/2]

void InitializationSequence::dump ( raw_ostream &  OS) const

◆ dump() [2/2]

void InitializationSequence::dump ( ) const

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

Definition at line 8260 of file SemaInit.cpp.

◆ endsWithNarrowing()

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.

◆ Failed()

bool clang::InitializationSequence::Failed ( ) const
inline

Determine whether the initialization sequence is invalid.

Definition at line 1021 of file Initialization.h.

Referenced by Diagnose(), Perform(), TryClassUnification(), and TryStaticImplicitCast().

◆ getFailedCandidateSet()

OverloadCandidateSet& clang::InitializationSequence::getFailedCandidateSet ( )
inline

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

Definition at line 1200 of file Initialization.h.

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

◆ getFailedOverloadResult()

OverloadingResult clang::InitializationSequence::getFailedOverloadResult ( ) const
inline

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

Definition at line 1206 of file Initialization.h.

◆ getFailureKind()

FailureKind clang::InitializationSequence::getFailureKind ( ) const
inline

Determine why initialization failed.

Definition at line 1218 of file Initialization.h.

References clang::InitializedEntity::dump().

◆ getKind()

enum SequenceKind clang::InitializationSequence::getKind ( ) const
inline

Determine the kind of initialization sequence computed.

Definition at line 1012 of file Initialization.h.

Referenced by Perform().

◆ InitializeFrom()

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

Definition at line 5217 of file SemaInit.cpp.

References clang::Sema::Context.

Referenced by InitializationSequence(), and TryListInitialization().

◆ isAmbiguous()

bool InitializationSequence::isAmbiguous ( ) const

Determine whether this initialization failed due to an ambiguity.

Definition at line 3150 of file SemaInit.cpp.

References clang::OR_Ambiguous.

Referenced by TryClassUnification().

◆ isConstructorInitialization()

bool InitializationSequence::isConstructorInitialization ( ) const

Determine whether this initialization is direct call to a constructor.

Definition at line 3198 of file SemaInit.cpp.

References AddAddressOverloadResolutionStep().

Referenced by TryStaticImplicitCast().

◆ isDirectReferenceBinding()

bool InitializationSequence::isDirectReferenceBinding ( ) const

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

Definition at line 3139 of file SemaInit.cpp.

Referenced by TryClassUnification().

◆ operator bool()

clang::InitializationSequence::operator bool ( ) const
inlineexplicit

Determine whether the initialization sequence is valid.

Definition at line 1018 of file Initialization.h.

◆ Perform()

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 6526 of file SemaInit.cpp.

References clang::Sema::ActOnParenListExpr(), clang::Sema::BuildCXXConstructExpr(), clang::Sema::BuildCXXMemberCallExpr(), clang::Sema::CCK_CStyleCast, clang::Sema::CCK_FunctionalCast, clang::Sema::CCK_ImplicitConversion, clang::Sema::CCK_OtherCast, clang::Sema::checkAddressOfFunctionIsAvailable(), clang::Sema::CheckAddressOfMemberAccess(), clang::Sema::CheckConstructorAccess(), clang::Sema::CheckDerivedToBaseConversion(), clang::Sema::CheckDestructorAccess(), clang::Sema::CheckExceptionSpecCompatibility(), CheckForNullPointerDereference(), clang::Sema::CheckMemberOperatorAccess(), clang::CXXConstructExpr::CK_Complete, clang::Expr::ClassifyLValue(), clang::Sema::Cleanup, clang::Sema::CompleteConstructorCall(), clang::Sema::Context, CopyObject(), clang::ImplicitCastExpr::Create(), clang::FixItHint::CreateInsertion(), clang::Sema::CreateMaterializeTemporaryExpr(), DependentSequence, clang::Sema::Diag(), Diagnose(), DiagnoseNarrowingInInitList(), clang::Sema::DiagnoseUseOfDecl(), clang::Sema::DiscardMisalignedMemberAddress(), clang::InitializedEntity::EK_Base, clang::InitializedEntity::EK_Delegating, clang::InitializedEntity::EK_Variable, clang::ExprError(), Failed(), clang::Sema::FixOverloadedFunctionReference(), clang::InitializationSequence::Step::F::FoundDecl, clang::InitializationSequence::Step::F::Function, clang::InitializationSequence::Step::Function, clang::ActionResult< PtrTy, CompressInvalid >::get(), clang::Qualifiers::getAddressSpace(), clang::TypeLoc::getAs(), clang::ActionResult< PtrTy, CompressInvalid >::getAs(), clang::Type::getAs(), clang::ASTContext::getAsIncompleteArrayType(), getAssignmentAction(), clang::SourceRange::getBegin(), clang::InitializedEntity::getDecl(), clang::ASTContext::getDependentSizedArrayType(), clang::SourceRange::getEnd(), getEntityForTemporaryLifetimeExtension(), clang::InitializedEntity::getKind(), clang::InitializationKind::getKind(), getKind(), clang::Sema::getLangOpts(), clang::InitializationKind::getLocation(), clang::Stmt::getLocStart(), clang::Decl::getLocStart(), clang::ASTContext::getLValueReferenceType(), clang::QualType::getNonReferenceType(), clang::InitializationKind::getParenRange(), clang::QualType::getQualifiers(), clang::ASTContext::getRValueReferenceType(), clang::Stmt::getSourceRange(), clang::MaterializeTemporaryExpr::getStorageDuration(), clang::Expr::getType(), clang::InitializedEntity::getType(), clang::ValueDecl::getType(), clang::QualType::getTypePtr(), clang::InitializationSequence::Step::F::HadMultipleCandidates, clang::Qualifiers::hasAddressSpace(), clang::ASTContext::hasSameType(), clang::InitializationSequence::Step::ICS, clang::InitializationKind::IK_Copy, clang::InitializationKind::IK_Direct, clang::InitializationKind::IK_DirectList, clang::Sema::ImpCastExprToType(), InitializedEntityOutlivesFullExpression(), clang::InitializedEntity::InitializeTemporary(), clang::EnterExpressionEvaluationContext::InitList, clang::Type::isAtomicType(), clang::InitializationKind::isCStyleCast(), clang::InitializationKind::isCStyleOrFunctionalCast(), clang::Type::isDependentType(), clang::QualType::isDestructedType(), clang::InitializationKind::isExplicitCast(), clang::InitializationKind::isFunctionalCast(), clang::Type::isIncompleteArrayType(), clang::ActionResult< PtrTy, CompressInvalid >::isInvalid(), clang::Type::isLValueReferenceType(), clang::InitializedEntity::isParameterKind(), clang::Type::isPointerType(), clang::Type::isReferenceType(), clang::ReferenceType::isSpelledAsLValue(), clang::InitializationSequence::Step::Kind, clang::Sema::LookupDestructor(), clang::Expr::LV_ArrayTemporary, clang::Expr::LV_ClassTemporary, clang::Sema::MarkFunctionReferenced(), clang::Sema::MaybeBindToTemporary(), clang::opencl_global, clang::Sema::PDiag(), PerformConstructorInitialization(), clang::Sema::PerformImplicitConversion(), clang::Sema::PerformObjectArgumentInitialization(), performReferenceExtension(), clang::Sema::RequireNonAbstractType(), clang::SD_Automatic, clang::CleanupInfo::setExprNeedsCleanups(), shouldBindAsTemporary(), shouldDestroyEntity(), SK_ArrayInit, SK_ArrayLoopIndex, SK_ArrayLoopInit, 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_FinalCopy, SK_GNUArrayInit, SK_ListInitialization, SK_LValueToRValue, SK_ObjCObjectConversion, SK_OCLSamplerInit, SK_OCLZeroEvent, SK_OCLZeroQueue, 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, step_begin(), step_end(), clang::T, clang::InitializationSequence::Step::Type, clang::VK_LValue, clang::VK_RValue, clang::VK_XValue, and warnOnLifetimeExtension().

Referenced by clang::Sema::BuildCXXTypeConstructExpr(), BuildImplicitMemberInitializer(), captureThis(), ConvertForConditional(), and TryStaticImplicitCast().

◆ RewrapReferenceInitList()

void InitializationSequence::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.

Definition at line 3428 of file SemaInit.cpp.

References clang::InitListExpr::getNumInits().

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

◆ SetFailed()

void clang::InitializationSequence::SetFailed ( FailureKind  Failure)
inline

◆ setIncompleteTypeFailure()

void clang::InitializationSequence::setIncompleteTypeFailure ( QualType  IncompleteType)
inline

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

Definition at line 1212 of file Initialization.h.

Referenced by TryConstructorInitialization(), and TryListInitialization().

◆ SetOverloadFailure()

void InitializationSequence::SetOverloadFailure ( FailureKind  Failure,
OverloadingResult  Result 
)

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

Definition at line 3443 of file SemaInit.cpp.

References clang::Result.

Referenced by TryConstructorInitialization(), and TryReferenceInitializationCore().

◆ setSequenceKind()

void clang::InitializationSequence::setSequenceKind ( enum SequenceKind  SK)
inline

Set the kind of sequence computed.

Definition at line 1015 of file Initialization.h.

◆ SetZeroInitializationFixit()

void clang::InitializationSequence::SetZeroInitializationFixit ( const std::string &  Fixit,
SourceLocation  L 
)
inline

Call for initializations are invalid but that would be valid zero initialzations if Fixit was applied.

Definition at line 932 of file Initialization.h.

Referenced by maybeRecoverWithZeroInitialization().

◆ step_begin()

step_iterator clang::InitializationSequence::step_begin ( ) const
inline

Definition at line 1024 of file Initialization.h.

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

◆ step_end()

step_iterator clang::InitializationSequence::step_end ( ) const
inline

Definition at line 1025 of file Initialization.h.

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

◆ steps()

step_range clang::InitializationSequence::steps ( ) const
inline

Definition at line 1028 of file Initialization.h.

References Category, and clang::T.


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