clang API Documentation

Public Types | Public Member Functions | Static Public Member Functions | Friends
clang::InitListExpr Class Reference

Describes an C or C++ initializer list. More...

#include <Expr.h>

Inheritance diagram for clang::InitListExpr:
Inheritance graph
[legend]
Collaboration diagram for clang::InitListExpr:
Collaboration graph
[legend]

List of all members.

Public Types

typedef InitExprsTy::iterator iterator
typedef InitExprsTy::const_iterator const_iterator
typedef
InitExprsTy::reverse_iterator 
reverse_iterator
typedef
InitExprsTy::const_reverse_iterator 
const_reverse_iterator

Public Member Functions

 InitListExpr (const ASTContext &C, SourceLocation lbraceloc, ArrayRef< Expr * > initExprs, SourceLocation rbraceloc)
 InitListExpr (EmptyShell Empty)
 Build an empty initializer list.
unsigned getNumInits () const
Expr ** getInits ()
 Retrieve the set of initializers.
const ExprgetInit (unsigned Init) const
ExprgetInit (unsigned Init)
void setInit (unsigned Init, Expr *expr)
void reserveInits (const ASTContext &C, unsigned NumInits)
 Reserve space for some number of initializers.
void resizeInits (const ASTContext &Context, unsigned NumInits)
 Specify the number of initializers.
ExprupdateInit (const ASTContext &C, unsigned Init, Expr *expr)
 Updates the initializer at index Init with the new expression expr, and returns the old expression at that location.
ExprgetArrayFiller ()
 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.
const ExprgetArrayFiller () const
void setArrayFiller (Expr *filler)
bool hasArrayFiller () const
 Return true if this is an array initializer and its array "filler" has been set.
FieldDeclgetInitializedFieldInUnion ()
 If this initializes a union, specifies which field in the union to initialize.
const FieldDeclgetInitializedFieldInUnion () const
void setInitializedFieldInUnion (FieldDecl *FD)
bool isExplicit ()
bool isStringLiteralInit () const
SourceLocation getLBraceLoc () const
void setLBraceLoc (SourceLocation Loc)
SourceLocation getRBraceLoc () const
void setRBraceLoc (SourceLocation Loc)
bool isSemanticForm () const
InitListExprgetSemanticForm () const
InitListExprgetSyntacticForm () const
void setSyntacticForm (InitListExpr *Init)
bool hadArrayRangeDesignator () const
void sawArrayRangeDesignator (bool ARD=true)
SourceLocation getLocStart () const LLVM_READONLY
SourceLocation getLocEnd () const LLVM_READONLY
child_range children ()
iterator begin ()
const_iterator begin () const
iterator end ()
const_iterator end () const
reverse_iterator rbegin ()
const_reverse_iterator rbegin () const
reverse_iterator rend ()
const_reverse_iterator rend () const

Static Public Member Functions

static bool classof (const Stmt *T)

Friends

class ASTStmtReader
class ASTStmtWriter

Detailed 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:

 struct foo x = { 1, { 2, 3 } };

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.

Definition at line 3758 of file Expr.h.


Member Typedef Documentation

Definition at line 3923 of file Expr.h.

Definition at line 3925 of file Expr.h.

Definition at line 3922 of file Expr.h.

Definition at line 3924 of file Expr.h.


Constructor & Destructor Documentation

InitListExpr::InitListExpr ( const ASTContext C,
SourceLocation  lbraceloc,
ArrayRef< Expr * >  initExprs,
SourceLocation  rbraceloc 
)
clang::InitListExpr::InitListExpr ( EmptyShell  Empty) [inline, explicit]

Build an empty initializer list.

Definition at line 3785 of file Expr.h.


Member Function Documentation

Definition at line 3927 of file Expr.h.

References clang::ASTVector< T >::begin().

Definition at line 3928 of file Expr.h.

References clang::ASTVector< T >::begin().

Reimplemented from clang::Stmt.

Definition at line 3916 of file Expr.h.

References clang::ASTVector< T >::empty(), and clang::ASTVector< T >::size().

static bool clang::InitListExpr::classof ( const Stmt T) [inline, static]

Reimplemented from clang::Expr.

Definition at line 3911 of file Expr.h.

Definition at line 3929 of file Expr.h.

References clang::ASTVector< T >::end().

Definition at line 3930 of file Expr.h.

References clang::ASTVector< T >::end().

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.

Definition at line 3839 of file Expr.h.

Referenced by getArrayFiller(), and hasArrayFiller().

const Expr* clang::InitListExpr::getArrayFiller ( ) const [inline]

Definition at line 3842 of file Expr.h.

References getArrayFiller().

const Expr* clang::InitListExpr::getInit ( unsigned  Init) const [inline]

Definition at line 3798 of file Expr.h.

References getNumInits().

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.

Definition at line 3857 of file Expr.h.

Referenced by getInitializedFieldInUnion(), clang::Expr::isConstantInitializer(), and setInitializedFieldInUnion().

Definition at line 3860 of file Expr.h.

References getInitializedFieldInUnion().

Retrieve the set of initializers.

Definition at line 3791 of file Expr.h.

References clang::ASTVector< T >::data().

Referenced by setArrayFiller(), and TryConstructorInitialization().

Definition at line 3881 of file Expr.h.

Referenced by clang::InitializationSequence::Perform(), and TryListInitialization().

Definition at line 3883 of file Expr.h.

Referenced by clang::InitializationSequence::Perform(), and TryListInitialization().

Definition at line 3887 of file Expr.h.

References isSemanticForm().

Definition at line 3890 of file Expr.h.

References isSemanticForm().

Referenced by getLocEnd(), and getLocStart().

Definition at line 3901 of file Expr.h.

References clang::Stmt::InitListExprBits.

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

Definition at line 3849 of file Expr.h.

References getArrayFiller().

Referenced by setArrayFiller().

Definition at line 3873 of file Expr.h.

References clang::SourceLocation::isValid().

Definition at line 3886 of file Expr.h.

Referenced by getSemanticForm(), and getSyntacticForm().

Definition at line 3931 of file Expr.h.

References clang::ASTVector< T >::rbegin().

Referenced by clang::ento::ExprEngine::VisitInitListExpr().

Definition at line 3932 of file Expr.h.

References clang::ASTVector< T >::rbegin().

Definition at line 3933 of file Expr.h.

References clang::ASTVector< T >::rend().

Referenced by clang::ento::ExprEngine::VisitInitListExpr().

Definition at line 3934 of file Expr.h.

References clang::ASTVector< T >::rend().

void InitListExpr::reserveInits ( const ASTContext C,
unsigned  NumInits 
)

Reserve space for some number of initializers.

Definition at line 1891 of file Expr.cpp.

References clang::ASTVector< T >::reserve(), and clang::ASTVector< T >::size().

void InitListExpr::resizeInits ( const ASTContext Context,
unsigned  NumInits 
)

Specify the number of initializers.

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

Definition at line 1896 of file Expr.cpp.

References clang::ASTVector< T >::resize().

Definition at line 3904 of file Expr.h.

References clang::Stmt::InitListExprBits.

Referenced by InitListExpr().

void InitListExpr::setArrayFiller ( Expr filler)

Definition at line 1912 of file Expr.cpp.

References getInits(), getNumInits(), and hasArrayFiller().

void clang::InitListExpr::setInit ( unsigned  Init,
Expr expr 
) [inline]

Definition at line 3863 of file Expr.h.

References getInitializedFieldInUnion().

Referenced by ConstructTransparentUnion().

Definition at line 3882 of file Expr.h.

Definition at line 3884 of file Expr.h.

Definition at line 3894 of file Expr.h.

Referenced by clang::InitializationSequence::Perform().

Expr * InitListExpr::updateInit ( const ASTContext C,
unsigned  Init,
Expr expr 
)

Updates the initializer at index Init with the new expression expr, and returns the old expression at that location.

When Init is out of range for this initializer list, the initializer list will be extended with NULL expressions to accommodate the new entry.

Definition at line 1900 of file Expr.cpp.

References clang::ASTVector< T >::end(), clang::ASTVector< T >::insert(), setInit(), and clang::ASTVector< T >::size().


Friends And Related Function Documentation

friend class ASTStmtReader [friend]

Reimplemented from clang::Stmt.

Definition at line 3936 of file Expr.h.

friend class ASTStmtWriter [friend]

Reimplemented from clang::Stmt.

Definition at line 3937 of file Expr.h.


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