clang API Documentation
Represents a C11 generic selection. More...
#include <Expr.h>
Public Member Functions | |
GenericSelectionExpr (const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > AssocTypes, ArrayRef< Expr * > AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex) | |
GenericSelectionExpr (const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > AssocTypes, ArrayRef< Expr * > AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack) | |
This constructor is used in the result-dependent case. | |
GenericSelectionExpr (EmptyShell Empty) | |
unsigned | getNumAssocs () const |
SourceLocation | getGenericLoc () const |
SourceLocation | getDefaultLoc () const |
SourceLocation | getRParenLoc () const |
const Expr * | getAssocExpr (unsigned i) const |
Expr * | getAssocExpr (unsigned i) |
const TypeSourceInfo * | getAssocTypeSourceInfo (unsigned i) const |
TypeSourceInfo * | getAssocTypeSourceInfo (unsigned i) |
QualType | getAssocType (unsigned i) const |
const Expr * | getControllingExpr () const |
Expr * | getControllingExpr () |
bool | isResultDependent () const |
Whether this generic selection is result-dependent. | |
unsigned | getResultIndex () const |
const Expr * | getResultExpr () const |
Expr * | getResultExpr () |
SourceLocation | getLocStart () const LLVM_READONLY |
SourceLocation | getLocEnd () const LLVM_READONLY |
child_range | children () |
Static Public Member Functions | |
static bool | classof (const Stmt *T) |
Friends | |
class | ASTStmtReader |
Represents a C11 generic selection.
A generic selection (C11 6.5.1.1) contains an unevaluated controlling expression, followed by one or more generic associations. Each generic association specifies a type name and an expression, or "default" and an expression (in which case it is known as a default generic association). The type and value of the generic selection are identical to those of its result expression, which is defined as the expression in the generic association with a type name that is compatible with the type of the controlling expression, or the expression in the default generic association if no types are compatible. For example:
_Generic(X, double: 1, float: 2, default: 3)
The above expression evaluates to 1 if 1.0 is substituted for X, 2 if 1.0f or 3 if "hello".
As an extension, generic selections are allowed in C++, where the following additional semantics apply:
Any generic selection whose controlling expression is type-dependent or which names a dependent type in its association list is result-dependent, which means that the choice of result expression is dependent. Result-dependent generic associations are both type- and value-dependent.
GenericSelectionExpr::GenericSelectionExpr | ( | const ASTContext & | Context, |
SourceLocation | GenericLoc, | ||
Expr * | ControllingExpr, | ||
ArrayRef< TypeSourceInfo * > | AssocTypes, | ||
ArrayRef< Expr * > | AssocExprs, | ||
SourceLocation | DefaultLoc, | ||
SourceLocation | RParenLoc, | ||
bool | ContainsUnexpandedParameterPack, | ||
unsigned | ResultIndex | ||
) |
GenericSelectionExpr::GenericSelectionExpr | ( | const ASTContext & | Context, |
SourceLocation | GenericLoc, | ||
Expr * | ControllingExpr, | ||
ArrayRef< TypeSourceInfo * > | AssocTypes, | ||
ArrayRef< Expr * > | AssocExprs, | ||
SourceLocation | DefaultLoc, | ||
SourceLocation | RParenLoc, | ||
bool | ContainsUnexpandedParameterPack | ||
) |
clang::GenericSelectionExpr::GenericSelectionExpr | ( | EmptyShell | Empty | ) | [inline, explicit] |
child_range clang::GenericSelectionExpr::children | ( | ) | [inline] |
Reimplemented from clang::Stmt.
static bool clang::GenericSelectionExpr::classof | ( | const Stmt * | T | ) | [inline, static] |
Reimplemented from clang::Expr.
Definition at line 4445 of file Expr.h.
References clang::Stmt::getStmtClass().
const Expr* clang::GenericSelectionExpr::getAssocExpr | ( | unsigned | i | ) | const [inline] |
Definition at line 4404 of file Expr.h.
Referenced by getResultExpr().
Expr* clang::GenericSelectionExpr::getAssocExpr | ( | unsigned | i | ) | [inline] |
QualType clang::GenericSelectionExpr::getAssocType | ( | unsigned | i | ) | const [inline] |
Definition at line 4414 of file Expr.h.
References getAssocTypeSourceInfo().
const TypeSourceInfo* clang::GenericSelectionExpr::getAssocTypeSourceInfo | ( | unsigned | i | ) | const [inline] |
Definition at line 4409 of file Expr.h.
Referenced by getAssocType().
const Expr* clang::GenericSelectionExpr::getControllingExpr | ( | ) | const [inline] |
Expr* clang::GenericSelectionExpr::getControllingExpr | ( | ) | [inline] |
SourceLocation clang::GenericSelectionExpr::getDefaultLoc | ( | ) | const [inline] |
SourceLocation clang::GenericSelectionExpr::getGenericLoc | ( | ) | const [inline] |
SourceLocation clang::GenericSelectionExpr::getLocEnd | ( | ) | const [inline] |
Reimplemented from clang::Stmt.
SourceLocation clang::GenericSelectionExpr::getLocStart | ( | ) | const [inline] |
Reimplemented from clang::Stmt.
unsigned clang::GenericSelectionExpr::getNumAssocs | ( | ) | const [inline] |
const Expr* clang::GenericSelectionExpr::getResultExpr | ( | ) | const [inline] |
The generic selection's result expression. Defined only if the generic selection is not result-dependent.
Definition at line 4439 of file Expr.h.
References getAssocExpr(), and getResultIndex().
Expr* clang::GenericSelectionExpr::getResultExpr | ( | ) | [inline] |
Definition at line 4440 of file Expr.h.
References getAssocExpr(), and getResultIndex().
unsigned clang::GenericSelectionExpr::getResultIndex | ( | ) | const [inline] |
The zero-based index of the result expression's generic association in the generic selection's association list. Defined only if the generic selection is not result-dependent.
Definition at line 4432 of file Expr.h.
References isResultDependent().
Referenced by getResultExpr().
SourceLocation clang::GenericSelectionExpr::getRParenLoc | ( | ) | const [inline] |
bool clang::GenericSelectionExpr::isResultDependent | ( | ) | const [inline] |
Whether this generic selection is result-dependent.
Definition at line 4427 of file Expr.h.
Referenced by getResultIndex().
friend class ASTStmtReader [friend] |
Reimplemented from clang::Stmt.