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 (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 Expr * | getInit (unsigned Init) const |
Expr * | getInit (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. | |
Expr * | 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. | |
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) |
bool | isSemanticForm () const |
InitListExpr * | getSemanticForm () const |
InitListExpr * | getSyntacticForm () 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 |
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.
InitListExpr::InitListExpr | ( | const ASTContext & | C, |
SourceLocation | lbraceloc, | ||
ArrayRef< Expr * > | initExprs, | ||
SourceLocation | rbraceloc | ||
) |
Definition at line 1869 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(), and sawArrayRangeDesignator().
clang::InitListExpr::InitListExpr | ( | EmptyShell | Empty | ) | [inline, explicit] |
iterator clang::InitListExpr::begin | ( | ) | [inline] |
Definition at line 3927 of file Expr.h.
References clang::ASTVector< T >::begin().
const_iterator clang::InitListExpr::begin | ( | ) | const [inline] |
Definition at line 3928 of file Expr.h.
References clang::ASTVector< T >::begin().
child_range clang::InitListExpr::children | ( | ) | [inline] |
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.
iterator clang::InitListExpr::end | ( | ) | [inline] |
Definition at line 3929 of file Expr.h.
References clang::ASTVector< T >::end().
const_iterator clang::InitListExpr::end | ( | ) | const [inline] |
Definition at line 3930 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 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 3793 of file Expr.h.
References getNumInits().
Referenced by clang::Sema::DeduceAutoType(), clang::CodeGen::CodeGenFunction::EmitInitListLValue(), GetNumNonZeroBytesInInit(), clang::Expr::isConstantInitializer(), isStringLiteralInit(), clang::InitializationSequence::RewrapReferenceInitList(), TryListConversion(), TryListInitialization(), TryReferenceListInitialization(), and clang::ento::ExprEngine::VisitInitListExpr().
Expr* clang::InitListExpr::getInit | ( | unsigned | Init | ) | [inline] |
Definition at line 3798 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 3857 of file Expr.h.
Referenced by getInitializedFieldInUnion(), clang::Expr::isConstantInitializer(), and setInitializedFieldInUnion().
const FieldDecl* clang::InitListExpr::getInitializedFieldInUnion | ( | ) | const [inline] |
Definition at line 3860 of file Expr.h.
References getInitializedFieldInUnion().
Expr** clang::InitListExpr::getInits | ( | ) | [inline] |
Retrieve the set of initializers.
Definition at line 3791 of file Expr.h.
References clang::ASTVector< T >::data().
Referenced by setArrayFiller(), and TryConstructorInitialization().
SourceLocation clang::InitListExpr::getLBraceLoc | ( | ) | const [inline] |
Definition at line 3881 of file Expr.h.
Referenced by clang::InitializationSequence::Perform(), and TryListInitialization().
SourceLocation InitListExpr::getLocEnd | ( | ) | const |
Reimplemented from clang::Stmt.
Definition at line 1954 of file Expr.cpp.
References getSyntacticForm(), clang::SourceLocation::isInvalid(), clang::ASTVector< T >::rbegin(), clang::ASTVector< T >::rend(), and S.
SourceLocation InitListExpr::getLocStart | ( | ) | const |
Reimplemented from clang::Stmt.
Definition at line 1936 of file Expr.cpp.
References clang::ASTVector< T >::begin(), clang::ASTVector< T >::end(), getSyntacticForm(), clang::SourceLocation::isInvalid(), and S.
Referenced by diagnoseListInit(), TryListConversion(), and TryListInitialization().
unsigned clang::InitListExpr::getNumInits | ( | ) | const [inline] |
Definition at line 3788 of file Expr.h.
References clang::ASTVector< T >::size().
Referenced by clang::Sema::DeduceAutoType(), diagnoseListInit(), clang::CodeGen::CodeGenFunction::EmitInitListLValue(), getInit(), GetNumNonZeroBytesInInit(), clang::Expr::isConstantInitializer(), isStringLiteralInit(), clang::InitializationSequence::RewrapReferenceInitList(), setArrayFiller(), setInit(), TryConstructorInitialization(), TryInitializerListConstruction(), TryListConversion(), TryListInitialization(), TryReferenceListInitialization(), TryValueInitialization(), and clang::ento::ExprEngine::VisitInitListExpr().
SourceLocation clang::InitListExpr::getRBraceLoc | ( | ) | const [inline] |
Definition at line 3883 of file Expr.h.
Referenced by clang::InitializationSequence::Perform(), and TryListInitialization().
InitListExpr* clang::InitListExpr::getSemanticForm | ( | ) | const [inline] |
Definition at line 3887 of file Expr.h.
References isSemanticForm().
InitListExpr* clang::InitListExpr::getSyntacticForm | ( | ) | const [inline] |
Definition at line 3890 of file Expr.h.
References isSemanticForm().
Referenced by getLocEnd(), and getLocStart().
bool clang::InitListExpr::hadArrayRangeDesignator | ( | ) | const [inline] |
Definition at line 3901 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 3849 of file Expr.h.
References getArrayFiller().
Referenced by setArrayFiller().
bool clang::InitListExpr::isExplicit | ( | ) | [inline] |
Definition at line 3873 of file Expr.h.
References clang::SourceLocation::isValid().
bool clang::InitListExpr::isSemanticForm | ( | ) | const [inline] |
Definition at line 3886 of file Expr.h.
Referenced by getSemanticForm(), and getSyntacticForm().
bool InitListExpr::isStringLiteralInit | ( | ) | const |
Definition at line 1922 of file Expr.cpp.
References clang::Type::getAsArrayTypeUnsafe(), clang::ArrayType::getElementType(), getInit(), getNumInits(), clang::Expr::getType(), clang::Expr::IgnoreParens(), and clang::Type::isIntegerType().
reverse_iterator clang::InitListExpr::rbegin | ( | ) | [inline] |
Definition at line 3931 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 3932 of file Expr.h.
References clang::ASTVector< T >::rbegin().
reverse_iterator clang::InitListExpr::rend | ( | ) | [inline] |
Definition at line 3933 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 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().
void clang::InitListExpr::sawArrayRangeDesignator | ( | bool | ARD = true | ) | [inline] |
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 3803 of file Expr.h.
References clang::Expr::containsUnexpandedParameterPack(), clang::ast_matchers::expr, clang::Stmt::ExprBits, getNumInits(), clang::Expr::isInstantiationDependent(), clang::Expr::isTypeDependent(), and clang::Expr::isValueDependent().
Referenced by updateInit().
void clang::InitListExpr::setInitializedFieldInUnion | ( | FieldDecl * | FD | ) | [inline] |
Definition at line 3863 of file Expr.h.
References getInitializedFieldInUnion().
Referenced by ConstructTransparentUnion().
void clang::InitListExpr::setLBraceLoc | ( | SourceLocation | Loc | ) | [inline] |
void clang::InitListExpr::setRBraceLoc | ( | SourceLocation | Loc | ) | [inline] |
void clang::InitListExpr::setSyntacticForm | ( | InitListExpr * | Init | ) | [inline] |
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().
friend class ASTStmtReader [friend] |
Reimplemented from clang::Stmt.
friend class ASTStmtWriter [friend] |
Reimplemented from clang::Stmt.