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 (ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, TypeSourceInfo **AssocTypes, Expr **AssocExprs, unsigned NumAssocs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
 GenericSelectionExpr (ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, TypeSourceInfo **AssocTypes, Expr **AssocExprs, unsigned NumAssocs, 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 ()
SourceRange getSourceRange () const LLVM_READONLY
child_range children ()

Static Public Member Functions

static bool classof (const Stmt *T)
static bool classof (const GenericSelectionExpr *)

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 4088 of file Expr.h.


Constructor & Destructor Documentation

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

Definition at line 3038 of file Expr.cpp.

GenericSelectionExpr::GenericSelectionExpr ( ASTContext Context,
SourceLocation  GenericLoc,
Expr ControllingExpr,
TypeSourceInfo **  AssocTypes,
Expr **  AssocExprs,
unsigned  NumAssocs,
SourceLocation  DefaultLoc,
SourceLocation  RParenLoc,
bool  ContainsUnexpandedParameterPack 
)

This constructor is used in the result-dependent case.

Definition at line 3062 of file Expr.cpp.

clang::GenericSelectionExpr::GenericSelectionExpr ( EmptyShell  Empty) [inline, explicit]

Definition at line 4112 of file Expr.h.


Member Function Documentation

child_range clang::GenericSelectionExpr::children ( ) [inline]

Reimplemented from clang::Stmt.

Definition at line 4167 of file Expr.h.

static bool clang::GenericSelectionExpr::classof ( const Stmt T) [inline, static]

Reimplemented from clang::Expr.

Definition at line 4162 of file Expr.h.

References clang::Stmt::getStmtClass().

static bool clang::GenericSelectionExpr::classof ( const GenericSelectionExpr ) [inline, static]

Definition at line 4165 of file Expr.h.

const Expr* clang::GenericSelectionExpr::getAssocExpr ( unsigned  i) const [inline]

Definition at line 4121 of file Expr.h.

Referenced by getResultExpr().

Expr* clang::GenericSelectionExpr::getAssocExpr ( unsigned  i) [inline]

Definition at line 4124 of file Expr.h.

QualType clang::GenericSelectionExpr::getAssocType ( unsigned  i) const [inline]

Definition at line 4131 of file Expr.h.

References getAssocTypeSourceInfo().

const TypeSourceInfo* clang::GenericSelectionExpr::getAssocTypeSourceInfo ( unsigned  i) const [inline]

Definition at line 4126 of file Expr.h.

Referenced by getAssocType().

TypeSourceInfo* clang::GenericSelectionExpr::getAssocTypeSourceInfo ( unsigned  i) [inline]

Definition at line 4129 of file Expr.h.

const Expr* clang::GenericSelectionExpr::getControllingExpr ( ) const [inline]

Definition at line 4138 of file Expr.h.

Expr* clang::GenericSelectionExpr::getControllingExpr ( ) [inline]

Definition at line 4141 of file Expr.h.

SourceLocation clang::GenericSelectionExpr::getDefaultLoc ( ) const [inline]

Definition at line 4118 of file Expr.h.

SourceLocation clang::GenericSelectionExpr::getGenericLoc ( ) const [inline]

Definition at line 4117 of file Expr.h.

unsigned clang::GenericSelectionExpr::getNumAssocs ( ) const [inline]

Definition at line 4115 of file Expr.h.

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 4156 of file Expr.h.

References getAssocExpr(), and getResultIndex().

Expr* clang::GenericSelectionExpr::getResultExpr ( ) [inline]

Definition at line 4157 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 4149 of file Expr.h.

References isResultDependent().

Referenced by getResultExpr().

SourceLocation clang::GenericSelectionExpr::getRParenLoc ( ) const [inline]

Definition at line 4119 of file Expr.h.

SourceRange clang::GenericSelectionExpr::getSourceRange ( ) const [inline]

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 4159 of file Expr.h.

bool clang::GenericSelectionExpr::isResultDependent ( ) const [inline]

Whether this generic selection is result-dependent.

Definition at line 4144 of file Expr.h.

Referenced by getResultIndex().


Friends And Related Function Documentation

friend class ASTStmtReader [friend]

Reimplemented from clang::Stmt.

Definition at line 4171 of file Expr.h.


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