class GenericSelectionExpr

Declaration

class GenericSelectionExpr : public Expr, private TrailingObjects { /* full declaration omitted */ };

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

Declared at: clang/include/clang/AST/Expr.h:5628

Inherits from: Expr, TrailingObjects

Member Variables

private unsigned int NumAssocs
The number of association expressions and the index of the result expression in the case where the generic selection expression is not result-dependent. The result index is equal to ResultDependentIndex if and only if the generic selection expression is result-dependent.
private unsigned int ResultIndex
The number of association expressions and the index of the result expression in the case where the generic selection expression is not result-dependent. The result index is equal to ResultDependentIndex if and only if the generic selection expression is result-dependent.
private clang::SourceLocation DefaultLoc
The location of the "default" and of the right parenthesis.
private clang::SourceLocation RParenLoc
The location of the "default" and of the right parenthesis.

Inherited from Stmt:

protected

Method Overview

  • public static clang::GenericSelectionExpr * Create(const clang::ASTContext & Context, clang::SourceLocation GenericLoc, clang::Expr * ControllingExpr, ArrayRef<clang::TypeSourceInfo *> AssocTypes, ArrayRef<clang::Expr *> AssocExprs, clang::SourceLocation DefaultLoc, clang::SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned int ResultIndex)
  • public static clang::GenericSelectionExpr * Create(const clang::ASTContext & Context, clang::SourceLocation GenericLoc, clang::Expr * ControllingExpr, ArrayRef<clang::TypeSourceInfo *> AssocTypes, ArrayRef<clang::Expr *> AssocExprs, clang::SourceLocation DefaultLoc, clang::SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack)
  • public static clang::GenericSelectionExpr * CreateEmpty(const clang::ASTContext & Context, unsigned int NumAssocs)
  • private GenericSelectionExpr(const clang::ASTContext & Context, clang::SourceLocation GenericLoc, clang::Expr * ControllingExpr, ArrayRef<clang::TypeSourceInfo *> AssocTypes, ArrayRef<clang::Expr *> AssocExprs, clang::SourceLocation DefaultLoc, clang::SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned int ResultIndex)
  • private GenericSelectionExpr(const clang::ASTContext & Context, clang::SourceLocation GenericLoc, clang::Expr * ControllingExpr, ArrayRef<clang::TypeSourceInfo *> AssocTypes, ArrayRef<clang::Expr *> AssocExprs, clang::SourceLocation DefaultLoc, clang::SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack)
  • private GenericSelectionExpr(clang::Stmt::EmptyShell Empty, unsigned int NumAssocs)
  • public clang::GenericSelectionExpr::association_range associations()
  • public clang::GenericSelectionExpr::const_association_range associations() const
  • public clang::Stmt::const_child_range children() const
  • public clang::Stmt::child_range children()
  • public static bool classof(const clang::Stmt * T)
  • public ArrayRef<clang::Expr *> getAssocExprs() const
  • public ArrayRef<clang::TypeSourceInfo *> getAssocTypeSourceInfos() const
  • public clang::GenericSelectionExpr::ConstAssociation getAssociation(unsigned int I) const
  • public clang::GenericSelectionExpr::Association getAssociation(unsigned int I)
  • public clang::SourceLocation getBeginLoc() const
  • public const clang::Expr * getControllingExpr() const
  • public clang::Expr * getControllingExpr()
  • public clang::SourceLocation getDefaultLoc() const
  • public clang::SourceLocation getEndLoc() const
  • public clang::SourceLocation getGenericLoc() const
  • public unsigned int getNumAssocs() const
  • public clang::SourceLocation getRParenLoc() const
  • public const clang::Expr * getResultExpr() const
  • public clang::Expr * getResultExpr()
  • public unsigned int getResultIndex() const
  • public bool isResultDependent() const
  • private unsigned int numTrailingObjects(OverloadToken<clang::Stmt *>) const
  • private unsigned int numTrailingObjects(OverloadToken<clang::TypeSourceInfo *>) const

Inherited from Expr:

Inherited from ValueStmt:

Inherited from Stmt:

Methods

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

Description

Create a non-result-dependent generic selection expression.

Declared at: clang/include/clang/AST/Expr.h:5768

Parameters

const clang::ASTContext& Context
clang::SourceLocation GenericLoc
clang::Expr* ControllingExpr
ArrayRef<clang::TypeSourceInfo*> AssocTypes
ArrayRef<clang::Expr*> AssocExprs
clang::SourceLocation DefaultLoc
clang::SourceLocation RParenLoc
bool ContainsUnexpandedParameterPack
unsigned int ResultIndex

static clang::GenericSelectionExpr* Create(
    const clang::ASTContext& Context,
    clang::SourceLocation GenericLoc,
    clang::Expr* ControllingExpr,
    ArrayRef<clang::TypeSourceInfo*> AssocTypes,
    ArrayRef<clang::Expr*> AssocExprs,
    clang::SourceLocation DefaultLoc,
    clang::SourceLocation RParenLoc,
    bool ContainsUnexpandedParameterPack)

Description

Create a result-dependent generic selection expression.

Declared at: clang/include/clang/AST/Expr.h:5776

Parameters

const clang::ASTContext& Context
clang::SourceLocation GenericLoc
clang::Expr* ControllingExpr
ArrayRef<clang::TypeSourceInfo*> AssocTypes
ArrayRef<clang::Expr*> AssocExprs
clang::SourceLocation DefaultLoc
clang::SourceLocation RParenLoc
bool ContainsUnexpandedParameterPack

static clang::GenericSelectionExpr* CreateEmpty(
    const clang::ASTContext& Context,
    unsigned int NumAssocs)

Description

Create an empty generic selection expression for deserialization.

Declared at: clang/include/clang/AST/Expr.h:5782

Parameters

const clang::ASTContext& Context
unsigned int NumAssocs

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

Description

Build a non-result-dependent generic selection expression.

Declared at: clang/include/clang/AST/Expr.h:5746

Parameters

const clang::ASTContext& Context
clang::SourceLocation GenericLoc
clang::Expr* ControllingExpr
ArrayRef<clang::TypeSourceInfo*> AssocTypes
ArrayRef<clang::Expr*> AssocExprs
clang::SourceLocation DefaultLoc
clang::SourceLocation RParenLoc
bool ContainsUnexpandedParameterPack
unsigned int ResultIndex

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

Description

Build a result-dependent generic selection expression.

Declared at: clang/include/clang/AST/Expr.h:5755

Parameters

const clang::ASTContext& Context
clang::SourceLocation GenericLoc
clang::Expr* ControllingExpr
ArrayRef<clang::TypeSourceInfo*> AssocTypes
ArrayRef<clang::Expr*> AssocExprs
clang::SourceLocation DefaultLoc
clang::SourceLocation RParenLoc
bool ContainsUnexpandedParameterPack

GenericSelectionExpr(
    clang::Stmt::EmptyShell Empty,
    unsigned int NumAssocs)

Description

Build an empty generic selection expression for deserialization.

Declared at: clang/include/clang/AST/Expr.h:5763

Parameters

clang::Stmt::EmptyShell Empty
unsigned int NumAssocs

clang::GenericSelectionExpr::association_range
associations()

Declared at: clang/include/clang/AST/Expr.h:5855

clang::GenericSelectionExpr::
    const_association_range
    associations() const

Declared at: clang/include/clang/AST/Expr.h:5865

clang::Stmt::const_child_range children() const

Declared at: clang/include/clang/AST/Expr.h:5892

clang::Stmt::child_range children()

Declared at: clang/include/clang/AST/Expr.h:5887

static bool classof(const clang::Stmt* T)

Declared at: clang/include/clang/AST/Expr.h:5883

Parameters

const clang::Stmt* T

ArrayRef<clang::Expr*> getAssocExprs() const

Declared at: clang/include/clang/AST/Expr.h:5827

ArrayRef<clang::TypeSourceInfo*>
getAssocTypeSourceInfos() const

Declared at: clang/include/clang/AST/Expr.h:5832

clang::GenericSelectionExpr::ConstAssociation
getAssociation(unsigned int I) const

Declared at: clang/include/clang/AST/Expr.h:5846

Parameters

unsigned int I

clang::GenericSelectionExpr::Association
getAssociation(unsigned int I)

Description

Return the Ith association expression with its TypeSourceInfo, bundled together in GenericSelectionExpr::(Const)Association.

Declared at: clang/include/clang/AST/Expr.h:5838

Parameters

unsigned int I

clang::SourceLocation getBeginLoc() const

Declared at: clang/include/clang/AST/Expr.h:5880

const clang::Expr* getControllingExpr() const

Declared at: clang/include/clang/AST/Expr.h:5812

clang::Expr* getControllingExpr()

Description

Return the controlling expression of this generic selection expression.

Declared at: clang/include/clang/AST/Expr.h:5809

clang::SourceLocation getDefaultLoc() const

Declared at: clang/include/clang/AST/Expr.h:5878

clang::SourceLocation getEndLoc() const

Declared at: clang/include/clang/AST/Expr.h:5881

clang::SourceLocation getGenericLoc() const

Declared at: clang/include/clang/AST/Expr.h:5875

unsigned int getNumAssocs() const

Description

The number of association expressions.

Declared at: clang/include/clang/AST/Expr.h:5794

clang::SourceLocation getRParenLoc() const

Declared at: clang/include/clang/AST/Expr.h:5879

const clang::Expr* getResultExpr() const

Declared at: clang/include/clang/AST/Expr.h:5822

clang::Expr* getResultExpr()

Description

Return the result expression of this controlling expression. Defined if and only if the generic selection expression is not result-dependent.

Declared at: clang/include/clang/AST/Expr.h:5818

unsigned int getResultIndex() const

Description

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.

Declared at: clang/include/clang/AST/Expr.h:5799

bool isResultDependent() const

Description

Whether this generic selection is result-dependent.

Declared at: clang/include/clang/AST/Expr.h:5806

unsigned int numTrailingObjects(
    OverloadToken<clang::Stmt*>) const

Declared at: clang/include/clang/AST/Expr.h:5657

Parameters

OverloadToken<clang::Stmt*>

unsigned int numTrailingObjects(
    OverloadToken<clang::TypeSourceInfo*>) const

Declared at: clang/include/clang/AST/Expr.h:5663

Parameters

OverloadToken<clang::TypeSourceInfo*>