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 (ASTContext &C, SourceLocation lbraceloc, Expr **initexprs, unsigned numinits, SourceLocation rbraceloc)
 InitListExpr (ASTContext &C, 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 (ASTContext &C, unsigned NumInits)
 Reserve space for some number of initializers.
void resizeInits (ASTContext &Context, unsigned NumInits)
 Specify the number of initializers.
ExprupdateInit (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)
InitListExprgetSyntacticForm () const
 Retrieve the initializer list that describes the syntactic form of the initializer.
void setSyntacticForm (InitListExpr *Init)
bool hadArrayRangeDesignator () const
void sawArrayRangeDesignator (bool ARD=true)
bool initializesStdInitializerList () const
void setInitializesStdInitializerList (bool ISIL=true)
SourceRange getSourceRange () 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)
static bool classof (const InitListExpr *)

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.

Given the semantic form of the initializer list, one can retrieve the original syntactic form of that initializer list (if it exists) using getSyntacticForm(). Since many initializer lists have the same syntactic and semantic forms, getSyntacticForm() may return NULL, indicating that the current initializer list also serves as its syntactic form.

Definition at line 3496 of file Expr.h.


Member Typedef Documentation

Definition at line 3645 of file Expr.h.

Definition at line 3647 of file Expr.h.

Definition at line 3644 of file Expr.h.

Definition at line 3646 of file Expr.h.


Constructor & Destructor Documentation

InitListExpr::InitListExpr ( ASTContext C,
SourceLocation  lbraceloc,
Expr **  initexprs,
unsigned  numinits,
SourceLocation  rbraceloc 
)
clang::InitListExpr::InitListExpr ( ASTContext C,
EmptyShell  Empty 
) [inline, explicit]

Build an empty initializer list.

Definition at line 3521 of file Expr.h.


Member Function Documentation

iterator clang::InitListExpr::begin ( ) [inline]

Definition at line 3649 of file Expr.h.

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

const_iterator clang::InitListExpr::begin ( ) const [inline]

Definition at line 3650 of file Expr.h.

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

child_range clang::InitListExpr::children ( ) [inline]

Reimplemented from clang::Stmt.

Definition at line 3639 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 3633 of file Expr.h.

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

Definition at line 3636 of file Expr.h.

iterator clang::InitListExpr::end ( ) [inline]

Definition at line 3651 of file Expr.h.

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

const_iterator clang::InitListExpr::end ( ) const [inline]

Definition at line 3652 of file Expr.h.

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

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

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 3567 of file Expr.h.

Referenced by getArrayFiller(), and hasArrayFiller().

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

Definition at line 3570 of file Expr.h.

References getArrayFiller().

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

Definition at line 3534 of file Expr.h.

References getNumInits().

FieldDecl* clang::InitListExpr::getInitializedFieldInUnion ( ) [inline]

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 3585 of file Expr.h.

Referenced by getInitializedFieldInUnion().

const FieldDecl* clang::InitListExpr::getInitializedFieldInUnion ( ) const [inline]

Definition at line 3588 of file Expr.h.

References getInitializedFieldInUnion().

Expr** clang::InitListExpr::getInits ( ) [inline]
SourceLocation clang::InitListExpr::getLBraceLoc ( ) const [inline]

Definition at line 3605 of file Expr.h.

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

unsigned clang::InitListExpr::getNumInits ( ) const [inline]
SourceLocation clang::InitListExpr::getRBraceLoc ( ) const [inline]

Definition at line 3607 of file Expr.h.

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

SourceRange InitListExpr::getSourceRange ( ) const

SourceLocation tokens are not useful in isolation - they are low level value objects created/interpreted by SourceManager. We assume AST clients will have a pointer to the respective SourceManager.

Reimplemented from clang::Stmt.

Definition at line 1601 of file Expr.cpp.

References clang::ASTVector< T >::begin(), clang::ASTVector< T >::end(), getSourceRange(), clang::SourceLocation::isInvalid(), clang::ASTVector< T >::rbegin(), clang::ASTVector< T >::rend(), and S.

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

InitListExpr* clang::InitListExpr::getSyntacticForm ( ) const [inline]

Retrieve the initializer list that describes the syntactic form of the initializer.

Definition at line 3614 of file Expr.h.

bool clang::InitListExpr::hadArrayRangeDesignator ( ) const [inline]

Definition at line 3617 of file Expr.h.

References clang::Stmt::InitListExprBits.

bool clang::InitListExpr::hasArrayFiller ( ) const [inline]

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

Definition at line 3577 of file Expr.h.

References getArrayFiller().

Referenced by setArrayFiller().

bool clang::InitListExpr::initializesStdInitializerList ( ) const [inline]

Definition at line 3624 of file Expr.h.

References clang::Stmt::InitListExprBits.

Referenced by EmitRecursiveStdInitializerListCleanup().

bool clang::InitListExpr::isExplicit ( ) [inline]

Definition at line 3597 of file Expr.h.

References clang::SourceLocation::isValid().

bool InitListExpr::isStringLiteralInit ( ) const
reverse_iterator clang::InitListExpr::rbegin ( ) [inline]

Definition at line 3653 of file Expr.h.

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

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

const_reverse_iterator clang::InitListExpr::rbegin ( ) const [inline]

Definition at line 3654 of file Expr.h.

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

reverse_iterator clang::InitListExpr::rend ( ) [inline]

Definition at line 3655 of file Expr.h.

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

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

const_reverse_iterator clang::InitListExpr::rend ( ) const [inline]

Definition at line 3656 of file Expr.h.

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

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

Reserve space for some number of initializers.

Definition at line 1560 of file Expr.cpp.

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

void InitListExpr::resizeInits ( 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 1565 of file Expr.cpp.

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

void clang::InitListExpr::sawArrayRangeDesignator ( bool  ARD = true) [inline]

Definition at line 3620 of file Expr.h.

References clang::Stmt::InitListExprBits.

Referenced by InitListExpr().

void InitListExpr::setArrayFiller ( Expr filler)

Definition at line 1581 of file Expr.cpp.

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

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

Definition at line 3539 of file Expr.h.

References getNumInits().

void clang::InitListExpr::setInitializedFieldInUnion ( FieldDecl FD) [inline]

Definition at line 3591 of file Expr.h.

Referenced by ConstructTransparentUnion().

void clang::InitListExpr::setInitializesStdInitializerList ( bool  ISIL = true) [inline]

Definition at line 3627 of file Expr.h.

References clang::Stmt::InitListExprBits.

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

void clang::InitListExpr::setLBraceLoc ( SourceLocation  Loc) [inline]

Definition at line 3606 of file Expr.h.

void clang::InitListExpr::setRBraceLoc ( SourceLocation  Loc) [inline]

Definition at line 3608 of file Expr.h.

void clang::InitListExpr::setSyntacticForm ( InitListExpr Init) [inline]

Definition at line 3615 of file Expr.h.

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

Expr * InitListExpr::updateInit ( 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 1569 of file Expr.cpp.

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


Friends And Related Function Documentation

friend class ASTStmtReader [friend]

Reimplemented from clang::Stmt.

Definition at line 3658 of file Expr.h.

friend class ASTStmtWriter [friend]

Reimplemented from clang::Stmt.

Definition at line 3659 of file Expr.h.


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