clang API Documentation
Describes an C or C++ initializer list. More...
#include <Expr.h>


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 Expr * | getInit (unsigned Init) const |
| Expr * | getInit (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. | |
| Expr * | 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. | |
| Expr * | getArrayFiller () |
| 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 Expr * | getArrayFiller () const |
| void | setArrayFiller (Expr *filler) |
| bool | hasArrayFiller () const |
| Return true if this is an array initializer and its array "filler" has been set. | |
| FieldDecl * | getInitializedFieldInUnion () |
| If this initializes a union, specifies which field in the union to initialize. | |
| const FieldDecl * | getInitializedFieldInUnion () const |
| void | setInitializedFieldInUnion (FieldDecl *FD) |
| bool | isExplicit () |
| bool | isStringLiteralInit () const |
| SourceLocation | getLBraceLoc () const |
| void | setLBraceLoc (SourceLocation Loc) |
| SourceLocation | getRBraceLoc () const |
| void | setRBraceLoc (SourceLocation Loc) |
| InitListExpr * | getSyntacticForm () 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 |
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.
| InitListExpr::InitListExpr | ( | ASTContext & | C, |
| SourceLocation | lbraceloc, | ||
| Expr ** | initexprs, | ||
| unsigned | numinits, | ||
| SourceLocation | rbraceloc | ||
| ) |
Definition at line 1536 of file Expr.cpp.
References clang::Expr::containsUnexpandedParameterPack(), clang::ASTVector< T >::end(), clang::Stmt::ExprBits, clang::ASTVector< T >::insert(), clang::Expr::isInstantiationDependent(), clang::Expr::isTypeDependent(), clang::Expr::isValueDependent(), sawArrayRangeDesignator(), and setInitializesStdInitializerList().
| clang::InitListExpr::InitListExpr | ( | ASTContext & | C, |
| EmptyShell | Empty | ||
| ) | [inline, explicit] |
| 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.
| static bool clang::InitListExpr::classof | ( | const InitListExpr * | ) | [inline, static] |
| 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] |
Definition at line 3529 of file Expr.h.
References getNumInits().
Referenced by clang::Sema::DeduceAutoType(), clang::InitializationSequence::Diagnose(), clang::CodeGen::CodeGenFunction::EmitInitListLValue(), EmitRecursiveStdInitializerListCleanup(), GetNumNonZeroBytesInInit(), clang::Expr::isConstantInitializer(), isStringLiteralInit(), clang::InitializationSequence::Perform(), clang::InitializationSequence::RewrapReferenceInitList(), TryListConstructionSpecialCases(), clang::TryListConversion(), TryReferenceListInitialization(), and clang::ento::ExprEngine::VisitInitListExpr().
| 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] |
Retrieve the set of initializers.
Definition at line 3527 of file Expr.h.
References clang::ASTVector< T >::data().
Referenced by clang::Sema::BuildMemberInitializer(), clang::InitializationSequence::Diagnose(), clang::InitializationSequence::Perform(), and setArrayFiller().
| 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] |
Definition at line 3524 of file Expr.h.
References clang::ASTVector< T >::size().
Referenced by clang::Sema::BuildMemberInitializer(), clang::Sema::DeduceAutoType(), clang::InitializationSequence::Diagnose(), clang::CodeGen::CodeGenFunction::EmitInitListLValue(), EmitRecursiveStdInitializerListCleanup(), clang::CodeGen::CodeGenFunction::EmitStdInitializerListCleanup(), getInit(), GetNumNonZeroBytesInInit(), clang::Expr::isConstantInitializer(), isStringLiteralInit(), clang::InitializationSequence::Perform(), clang::InitializationSequence::RewrapReferenceInitList(), setArrayFiller(), setInit(), TryListConstructionSpecialCases(), clang::TryListConversion(), TryListInitialization(), TryReferenceListInitialization(), and clang::ento::ExprEngine::VisitInitListExpr().
| 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] |
| 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 |
Definition at line 1591 of file Expr.cpp.
References clang::ArrayType::getElementType(), getInit(), getNumInits(), clang::Expr::getType(), and clang::Expr::IgnoreParenImpCasts().
| 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] |
| void clang::InitListExpr::setRBraceLoc | ( | SourceLocation | Loc | ) | [inline] |
| 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().
friend class ASTStmtReader [friend] |
Reimplemented from clang::Stmt.
friend class ASTStmtWriter [friend] |
Reimplemented from clang::Stmt.