clang API Documentation

Public Member Functions | Static Public Member Functions | Friends
clang::GenericSelectionExpr Class Reference

Represents a C11 generic selection. More...

#include <Expr.h>

Inheritance diagram for clang::GenericSelectionExpr:
Inheritance graph
[legend]
Collaboration diagram for clang::GenericSelectionExpr:
Collaboration graph
[legend]

List of all members.

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 ExprgetAssocExpr (unsigned i) const
ExprgetAssocExpr (unsigned i)
const TypeSourceInfogetAssocTypeSourceInfo (unsigned i) const
TypeSourceInfogetAssocTypeSourceInfo (unsigned i)
QualType getAssocType (unsigned i) const
const ExprgetControllingExpr () const
ExprgetControllingExpr ()
bool isResultDependent () const
 Whether this generic selection is result-dependent.
unsigned getResultIndex () const
const ExprgetResultExpr () const
ExprgetResultExpr ()
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

Detailed Description

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.

Definition at line 4371 of file Expr.h.


Constructor & Destructor Documentation

GenericSelectionExpr::GenericSelectionExpr ( const ASTContext Context,
SourceLocation  GenericLoc,
Expr ControllingExpr,
ArrayRef< TypeSourceInfo * >  AssocTypes,
ArrayRef< Expr * >  AssocExprs,
SourceLocation  DefaultLoc,
SourceLocation  RParenLoc,
bool  ContainsUnexpandedParameterPack,
unsigned  ResultIndex 
)

Definition at line 3713 of file Expr.cpp.

GenericSelectionExpr::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.

Definition at line 3739 of file Expr.cpp.

Definition at line 4395 of file Expr.h.


Member Function Documentation

Reimplemented from clang::Stmt.

Definition at line 4449 of file Expr.h.

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().

Definition at line 4404 of file Expr.h.

Referenced by getResultExpr().

Definition at line 4407 of file Expr.h.

Definition at line 4414 of file Expr.h.

References getAssocTypeSourceInfo().

Definition at line 4409 of file Expr.h.

Referenced by getAssocType().

Definition at line 4412 of file Expr.h.

Definition at line 4421 of file Expr.h.

Definition at line 4424 of file Expr.h.

Definition at line 4401 of file Expr.h.

Definition at line 4400 of file Expr.h.

Reimplemented from clang::Stmt.

Definition at line 4443 of file Expr.h.

Reimplemented from clang::Stmt.

Definition at line 4442 of file Expr.h.

Definition at line 4398 of file Expr.h.

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().

Definition at line 4440 of file Expr.h.

References getAssocExpr(), and getResultIndex().

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().

Definition at line 4402 of file Expr.h.

Whether this generic selection is result-dependent.

Definition at line 4427 of file Expr.h.

Referenced by getResultIndex().


Friends And Related Function Documentation

friend class ASTStmtReader [friend]

Reimplemented from clang::Stmt.

Definition at line 4453 of file Expr.h.


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