clang API Documentation
Represents a C99 designated initializer expression. More...
#include <Expr.h>
Classes | |
struct | ArrayOrRangeDesignator |
An array or GNU array-range designator, e.g., "[9]" or "[10..15]". More... | |
class | Designator |
Represents a single C99 designator. More... | |
struct | FieldDesignator |
A field designator, e.g., ".x". More... | |
Public Types | |
typedef Designator * | designators_iterator |
typedef const Designator * | const_designators_iterator |
typedef llvm::iterator_range < designators_iterator > | designators_range |
typedef llvm::iterator_range < const_designators_iterator > | designators_const_range |
typedef std::reverse_iterator < designators_iterator > | reverse_designators_iterator |
typedef std::reverse_iterator < const_designators_iterator > | const_reverse_designators_iterator |
Public Member Functions | |
unsigned | size () const |
Returns the number of designators in this initializer. | |
designators_iterator | designators_begin () |
designators_iterator | designators_end () |
const_designators_iterator | designators_begin () const |
const_designators_iterator | designators_end () const |
designators_range | designators () |
designators_const_range | designators () const |
reverse_designators_iterator | designators_rbegin () |
reverse_designators_iterator | designators_rend () |
const_reverse_designators_iterator | designators_rbegin () const |
const_reverse_designators_iterator | designators_rend () const |
Designator * | getDesignator (unsigned Idx) |
void | setDesignators (const ASTContext &C, const Designator *Desigs, unsigned NumDesigs) |
Expr * | getArrayIndex (const Designator &D) const |
Expr * | getArrayRangeStart (const Designator &D) const |
Expr * | getArrayRangeEnd (const Designator &D) const |
SourceLocation | getEqualOrColonLoc () const |
Retrieve the location of the '=' that precedes the initializer value itself, if present. | |
void | setEqualOrColonLoc (SourceLocation L) |
bool | usesGNUSyntax () const |
Determines whether this designated initializer used the deprecated GNU syntax for designated initializers. | |
void | setGNUSyntax (bool GNU) |
Expr * | getInit () const |
Retrieve the initializer value. | |
void | setInit (Expr *init) |
unsigned | getNumSubExprs () const |
Retrieve the total number of subexpressions in this designated initializer expression, including the actual initialized value and any expressions that occur within array and array-range designators. | |
Expr * | getSubExpr (unsigned Idx) const |
void | setSubExpr (unsigned Idx, Expr *E) |
void | ExpandDesignator (const ASTContext &C, unsigned Idx, const Designator *First, const Designator *Last) |
Replaces the designator at index Idx with the series of designators in [First, Last). | |
SourceRange | getDesignatorsSourceRange () const |
SourceLocation | getLocStart () const LLVM_READONLY |
SourceLocation | getLocEnd () const LLVM_READONLY |
child_range | children () |
Static Public Member Functions | |
static DesignatedInitExpr * | Create (const ASTContext &C, Designator *Designators, unsigned NumDesignators, ArrayRef< Expr * > IndexExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init) |
static DesignatedInitExpr * | CreateEmpty (const ASTContext &C, unsigned NumIndexExprs) |
static bool | classof (const Stmt *T) |
Represents a C99 designated initializer expression.
A designated initializer expression (C99 6.7.8) contains one or more designators (which can be field designators, array designators, or GNU array-range designators) followed by an expression that initializes the field or element(s) that the designators refer to. For example, given:
struct point { double x; double y; }; struct point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 };
The InitListExpr contains three DesignatedInitExprs, the first of which covers [2].y=1.0. This DesignatedInitExpr will have two designators, one array designator for
[2] followed by one field designator for
.y. The initialization expression will be 1.0.
typedef const Designator* clang::DesignatedInitExpr::const_designators_iterator |
typedef std::reverse_iterator<const_designators_iterator> clang::DesignatedInitExpr::const_reverse_designators_iterator |
typedef llvm::iterator_range<const_designators_iterator> clang::DesignatedInitExpr::designators_const_range |
typedef llvm::iterator_range<designators_iterator> clang::DesignatedInitExpr::designators_range |
typedef std::reverse_iterator<designators_iterator> clang::DesignatedInitExpr::reverse_designators_iterator |
child_range clang::DesignatedInitExpr::children | ( | ) | [inline] |
Reimplemented from clang::Stmt.
static bool clang::DesignatedInitExpr::classof | ( | const Stmt * | T | ) | [inline, static] |
Reimplemented from clang::Expr.
DesignatedInitExpr * DesignatedInitExpr::Create | ( | const ASTContext & | C, |
Designator * | Designators, | ||
unsigned | NumDesignators, | ||
ArrayRef< Expr * > | IndexExprs, | ||
SourceLocation | EqualOrColonLoc, | ||
bool | GNUSyntax, | ||
Expr * | Init | ||
) | [static] |
Definition at line 3843 of file Expr.cpp.
References clang::ASTContext::Allocate(), and clang::ASTContext::VoidTy.
Referenced by clang::Sema::ActOnDesignatedInitializer().
DesignatedInitExpr * DesignatedInitExpr::CreateEmpty | ( | const ASTContext & | C, |
unsigned | NumIndexExprs | ||
) | [static] |
Definition at line 3855 of file Expr.cpp.
References clang::ASTContext::Allocate().
designators_range clang::DesignatedInitExpr::designators | ( | ) | [inline] |
Definition at line 4176 of file Expr.h.
References designators_begin(), and designators_end().
designators_const_range clang::DesignatedInitExpr::designators | ( | ) | const [inline] |
Definition at line 4182 of file Expr.h.
References designators_begin(), and designators_end().
Definition at line 4164 of file Expr.h.
Referenced by CloneDesignatedInitExpr(), designators(), designators_rend(), getDesignator(), and getLocStart().
const_designators_iterator clang::DesignatedInitExpr::designators_begin | ( | ) | const [inline] |
Definition at line 4165 of file Expr.h.
Referenced by designators(), and designators_rbegin().
const_designators_iterator clang::DesignatedInitExpr::designators_end | ( | ) | const [inline] |
Definition at line 4188 of file Expr.h.
References designators_end().
const_reverse_designators_iterator clang::DesignatedInitExpr::designators_rbegin | ( | ) | const [inline] |
Definition at line 4197 of file Expr.h.
References designators_end().
Definition at line 4191 of file Expr.h.
References designators_begin().
const_reverse_designators_iterator clang::DesignatedInitExpr::designators_rend | ( | ) | const [inline] |
Definition at line 4200 of file Expr.h.
References designators_begin().
void DesignatedInitExpr::ExpandDesignator | ( | const ASTContext & | C, |
unsigned | Idx, | ||
const Designator * | First, | ||
const Designator * | Last | ||
) |
Replaces the designator at index Idx
with the series of designators in [First, Last).
Definition at line 3920 of file Expr.cpp.
References AttributeLangSupport::C.
Referenced by ExpandAnonymousFieldDesignator().
Expr * DesignatedInitExpr::getArrayIndex | ( | const Designator & | D | ) | const |
Definition at line 3898 of file Expr.cpp.
References clang::DesignatedInitExpr::Designator::ArrayOrRange, and clang::DesignatedInitExpr::ArrayOrRangeDesignator::Index.
Expr * DesignatedInitExpr::getArrayRangeEnd | ( | const Designator & | D | ) | const |
Definition at line 3911 of file Expr.cpp.
References clang::DesignatedInitExpr::Designator::ArrayOrRange, and clang::DesignatedInitExpr::ArrayOrRangeDesignator::Index.
Expr * DesignatedInitExpr::getArrayRangeStart | ( | const Designator & | D | ) | const |
Definition at line 3904 of file Expr.cpp.
References clang::DesignatedInitExpr::Designator::ArrayOrRange, and clang::DesignatedInitExpr::ArrayOrRangeDesignator::Index.
Designator* clang::DesignatedInitExpr::getDesignator | ( | unsigned | Idx | ) | [inline] |
Definition at line 4204 of file Expr.h.
References designators_begin().
Referenced by ExpandAnonymousFieldDesignator(), and getDesignatorsSourceRange().
Definition at line 3871 of file Expr.cpp.
References getDesignator(), clang::DesignatedInitExpr::Designator::getLocEnd(), clang::DesignatedInitExpr::Designator::getLocStart(), clang::DesignatedInitExpr::Designator::getSourceRange(), and size().
SourceLocation clang::DesignatedInitExpr::getEqualOrColonLoc | ( | ) | const [inline] |
Retrieve the location of the '=' that precedes the initializer value itself, if present.
Definition at line 4215 of file Expr.h.
Referenced by CloneDesignatedInitExpr().
Expr* clang::DesignatedInitExpr::getInit | ( | ) | const [inline] |
Retrieve the initializer value.
Definition at line 4224 of file Expr.h.
References clang::Stmt::child_begin().
Referenced by CloneDesignatedInitExpr(), getLocEnd(), and clang::EvaluatedExprVisitor< ImplClass >::VisitDesignatedInitExpr().
SourceLocation DesignatedInitExpr::getLocEnd | ( | ) | const |
Reimplemented from clang::Stmt.
Definition at line 3894 of file Expr.cpp.
References getInit(), and clang::Stmt::getLocEnd().
Reimplemented from clang::Stmt.
Definition at line 3879 of file Expr.cpp.
References clang::DesignatedInitExpr::Designator::ArrayOrRange, designators_begin(), clang::DesignatedInitExpr::FieldDesignator::DotLoc, clang::DesignatedInitExpr::Designator::Field, clang::DesignatedInitExpr::FieldDesignator::FieldLoc, clang::SourceLocation::getFromRawEncoding(), clang::DesignatedInitExpr::Designator::isFieldDesignator(), and clang::DesignatedInitExpr::ArrayOrRangeDesignator::LBracketLoc.
Referenced by clang::Sema::ActOnDesignatedInitializer().
unsigned clang::DesignatedInitExpr::getNumSubExprs | ( | ) | const [inline] |
Retrieve the total number of subexpressions in this designated initializer expression, including the actual initialized value and any expressions that occur within array and array-range designators.
Definition at line 4236 of file Expr.h.
Referenced by CloneDesignatedInitExpr().
Expr* clang::DesignatedInitExpr::getSubExpr | ( | unsigned | Idx | ) | const [inline] |
Definition at line 4238 of file Expr.h.
Referenced by CloneDesignatedInitExpr().
void DesignatedInitExpr::setDesignators | ( | const ASTContext & | C, |
const Designator * | Desigs, | ||
unsigned | NumDesigs | ||
) |
Definition at line 3862 of file Expr.cpp.
References AttributeLangSupport::C.
void clang::DesignatedInitExpr::setEqualOrColonLoc | ( | SourceLocation | L | ) | [inline] |
void clang::DesignatedInitExpr::setGNUSyntax | ( | bool | GNU | ) | [inline] |
Definition at line 4221 of file Expr.h.
References clang::GNU.
void clang::DesignatedInitExpr::setInit | ( | Expr * | init | ) | [inline] |
Definition at line 4228 of file Expr.h.
References clang::Stmt::child_begin().
void clang::DesignatedInitExpr::setSubExpr | ( | unsigned | Idx, |
Expr * | E | ||
) | [inline] |
unsigned clang::DesignatedInitExpr::size | ( | ) | const [inline] |
Returns the number of designators in this initializer.
Definition at line 4160 of file Expr.h.
Referenced by CloneDesignatedInitExpr(), and getDesignatorsSourceRange().
bool clang::DesignatedInitExpr::usesGNUSyntax | ( | ) | const [inline] |
Determines whether this designated initializer used the deprecated GNU syntax for designated initializers.
Definition at line 4220 of file Expr.h.
Referenced by CloneDesignatedInitExpr().