class InitListExpr

Declaration

class InitListExpr : public Expr { /* full declaration omitted */ };

Description

Describes an C or C++ initializer list. InitListExpr describes an initializer list, which can be used to initialize objects of different types, including struct/class/union types, arrays, and vectors. For example: Prior to semantic analysis, an initializer list will represent the initializer list as written by the user, but will have the placeholder type "void". This initializer list is called the syntactic form of the initializer, and may contain C99 designated initializers (represented as DesignatedInitExprs), initializations of subobject members without explicit braces, and so on. Clients interested in the original syntax of the initializer list should use the syntactic form of the initializer list. After semantic analysis, the initializer list will represent the semantic form of the initializer, where the initializations of all subobjects are made explicit with nested InitListExpr nodes and C99 designators have been eliminated by placing the designated initializations into the subobject they initialize. Additionally, any "holes" in the initialization, where no initializer has been specified for a particular subobject, will be replaced with implicitly-generated ImplicitValueInitExpr expressions that value-initialize the subobjects. Note, however, that the initializer lists may still have fewer initializers than there are elements to initialize within the object. After semantic analysis has completed, given an initializer list, method isSemanticForm() returns true if and only if this is the semantic form of the initializer list (note: the same AST node may at the same time be the syntactic form). Given the semantic form of the initializer list, one can retrieve the syntactic form of that initializer list (when different) using method getSyntacticForm(); the method returns null if applied to a initializer list which is already in syntactic form. Similarly, given the syntactic form (i.e., an initializer list such that isSemanticForm() returns false), one can retrieve the semantic form using method getSemanticForm(). Since many initializer lists have the same syntactic and semantic forms, getSyntacticForm() may return NULL, indicating that the current semantic initializer list also serves as its syntactic form.

Declared at: clang/include/clang/AST/Expr.h:4791

Inherits from: Expr

Member Variables

private clang::InitListExpr::InitExprsTy InitExprs
private clang::SourceLocation LBraceLoc
private clang::SourceLocation RBraceLoc
private llvm::PointerIntPair<InitListExpr*, 1, bool> AltForm
The alternative form of the initializer list (if it exists). The int part of the pair stores whether this initializer list is in semantic form. If not null, the pointer points to: - the syntactic form, if this is in semantic form; - the semantic form, if this is in syntactic form.
private llvm::PointerUnion<Expr*, FieldDecl*> ArrayFillerOrUnionFieldInit
Either: If this initializer list initializes an array with more elements than there are initializers in the list, specifies an expression to be used for value initialization of the rest of the elements. Or If this initializer list initializes a union, specifies which field within the union will be initialized.

Inherited from Stmt:

protected

Method Overview

Inherited from Expr:

Inherited from ValueStmt:

Inherited from Stmt:

Methods

InitListExpr(clang::Stmt::EmptyShell Empty)

Description

Build an empty initializer list.

Declared at: clang/include/clang/AST/Expr.h:4818

Parameters

clang::Stmt::EmptyShell Empty

InitListExpr(const clang::ASTContext& C,
             clang::SourceLocation lbraceloc,
             ArrayRef<clang::Expr*> initExprs,
             clang::SourceLocation rbraceloc)

Declared at: clang/include/clang/AST/Expr.h:4814

Parameters

const clang::ASTContext& C
clang::SourceLocation lbraceloc
ArrayRef<clang::Expr*> initExprs
clang::SourceLocation rbraceloc

clang::InitListExpr::iterator begin()

Declared at: clang/include/clang/AST/Expr.h:4996

clang::InitListExpr::const_iterator begin() const

Declared at: clang/include/clang/AST/Expr.h:4997

clang::Stmt::child_range children()

Declared at: clang/include/clang/AST/Expr.h:4978

clang::Stmt::const_child_range children() const

Declared at: clang/include/clang/AST/Expr.h:4984

static bool classof(const clang::Stmt* T)

Declared at: clang/include/clang/AST/Expr.h:4973

Parameters

const clang::Stmt* T

clang::InitListExpr::const_iterator end() const

Declared at: clang/include/clang/AST/Expr.h:4999

clang::InitListExpr::iterator end()

Declared at: clang/include/clang/AST/Expr.h:4998

const clang::Expr* getArrayFiller() const

Declared at: clang/include/clang/AST/Expr.h:4890

clang::Expr* getArrayFiller()

Description

If this initializer list initializes an array with more elements than there are initializers in the list, specifies an expression to be used for value initialization of the rest of the elements.

Declared at: clang/include/clang/AST/Expr.h:4887

clang::SourceLocation getBeginLoc() const

Declared at: clang/include/clang/AST/Expr.h:4970

clang::SourceLocation getEndLoc() const

Declared at: clang/include/clang/AST/Expr.h:4971

const clang::Expr* getInit(
    unsigned int Init) const

Declared at: clang/include/clang/AST/Expr.h:4839

Parameters

unsigned int Init

clang::Expr* getInit(unsigned int Init)

Declared at: clang/include/clang/AST/Expr.h:4844

Parameters

unsigned int Init

const clang::FieldDecl*
getInitializedFieldInUnion() const

Declared at: clang/include/clang/AST/Expr.h:4908

clang::FieldDecl* getInitializedFieldInUnion()

Description

If this initializes a union, specifies which field in the union to initialize. Typically, this field is the first named field within the union. However, a designated initializer can specify the initialization of a different field within the union.

Declared at: clang/include/clang/AST/Expr.h:4905

clang::Expr** getInits()

Description

Retrieve the set of initializers.

Declared at: clang/include/clang/AST/Expr.h:4824

clang::Expr* const* getInits() const

Description

Retrieve the set of initializers.

Declared at: clang/include/clang/AST/Expr.h:4827

clang::SourceLocation getLBraceLoc() const

Declared at: clang/include/clang/AST/Expr.h:4940

unsigned int getNumInits() const

Declared at: clang/include/clang/AST/Expr.h:4821

clang::SourceLocation getRBraceLoc() const

Declared at: clang/include/clang/AST/Expr.h:4942

clang::InitListExpr* getSemanticForm() const

Declared at: clang/include/clang/AST/Expr.h:4946

clang::InitListExpr* getSyntacticForm() const

Declared at: clang/include/clang/AST/Expr.h:4952

bool hadArrayRangeDesignator() const

Declared at: clang/include/clang/AST/Expr.h:4963

bool hasArrayFiller() const

Description

Return true if this is an array initializer and its array "filler" has been set.

Declared at: clang/include/clang/AST/Expr.h:4897

ArrayRef<clang::Expr*> inits()

Declared at: clang/include/clang/AST/Expr.h:4831

ArrayRef<clang::Expr*> inits() const

Declared at: clang/include/clang/AST/Expr.h:4835

bool isExplicit() const

Declared at: clang/include/clang/AST/Expr.h:4923

bool isIdiomaticZeroInitializer(
    const clang::LangOptions& LangOpts) const

Description

Is this the zero initializer {0} in a language which considers it idiomatic?

Declared at: clang/include/clang/AST/Expr.h:4938

Parameters

const clang::LangOptions& LangOpts

bool isSemanticForm() const

Declared at: clang/include/clang/AST/Expr.h:4945

bool isStringLiteralInit() const

Declared at: clang/include/clang/AST/Expr.h:4929

bool isSyntacticForm() const

Declared at: clang/include/clang/AST/Expr.h:4949

bool isTransparent() const

Description

Is this a transparent initializer list (that is, an InitListExpr that is purely syntactic, and whose semantics are that of the sole contained initializer)?

Declared at: clang/include/clang/AST/Expr.h:4934

void markError()

Description

Mark the semantic form of the InitListExpr as error when the semantic analysis fails.

Declared at: clang/include/clang/AST/Expr.h:4859

clang::InitListExpr::const_reverse_iterator
rbegin() const

Declared at: clang/include/clang/AST/Expr.h:5001

clang::InitListExpr::reverse_iterator rbegin()

Declared at: clang/include/clang/AST/Expr.h:5000

clang::InitListExpr::const_reverse_iterator rend()
    const

Declared at: clang/include/clang/AST/Expr.h:5003

clang::InitListExpr::reverse_iterator rend()

Declared at: clang/include/clang/AST/Expr.h:5002

void reserveInits(const clang::ASTContext& C,
                  unsigned int NumInits)

Description

Reserve space for some number of initializers.

Declared at: clang/include/clang/AST/Expr.h:4865

Parameters

const clang::ASTContext& C
unsigned int NumInits

void resizeInits(const clang::ASTContext& Context,
                 unsigned int NumInits)

Description

Specify the number of initializers If there are more than @p NumInits initializers, the remaining initializers will be destroyed. If there are fewer than @p NumInits initializers, NULL expressions will be added for the unknown initializers.

Declared at: clang/include/clang/AST/Expr.h:4873

Parameters

const clang::ASTContext& Context
unsigned int NumInits

void sawArrayRangeDesignator(bool ARD = true)

Declared at: clang/include/clang/AST/Expr.h:4966

Parameters

bool ARD = true

void setArrayFiller(clang::Expr* filler)

Declared at: clang/include/clang/AST/Expr.h:4893

Parameters

clang::Expr* filler

void setInit(unsigned int Init, clang::Expr* expr)

Declared at: clang/include/clang/AST/Expr.h:4849

Parameters

unsigned int Init
clang::Expr* expr

void setInitializedFieldInUnion(
    clang::FieldDecl* FD)

Declared at: clang/include/clang/AST/Expr.h:4911

Parameters

clang::FieldDecl* FD

void setLBraceLoc(clang::SourceLocation Loc)

Declared at: clang/include/clang/AST/Expr.h:4941

Parameters

clang::SourceLocation Loc

void setRBraceLoc(clang::SourceLocation Loc)

Declared at: clang/include/clang/AST/Expr.h:4943

Parameters

clang::SourceLocation Loc

void setSyntacticForm(clang::InitListExpr* Init)

Declared at: clang/include/clang/AST/Expr.h:4956

Parameters

clang::InitListExpr* Init

clang::Expr* updateInit(
    const clang::ASTContext& C,
    unsigned int Init,
    clang::Expr* expr)

Description

Updates the initializer at index @p Init with the new expression @p expr, and returns the old expression at that location. When @p Init is out of range for this initializer list, the initializer list will be extended with NULL expressions to accommodate the new entry.

Declared at: clang/include/clang/AST/Expr.h:4882

Parameters

const clang::ASTContext& C
unsigned int Init
clang::Expr* expr