class SwitchStmt

Declaration

class SwitchStmt : public Stmt, private TrailingObjects { /* full declaration omitted */ };

Description

SwitchStmt - This represents a 'switch' stmt.

Declared at: clang/include/clang/AST/Stmt.h:2182

Inherits from: Stmt, TrailingObjects

Member Variables

private clang::SwitchCase* FirstCase = nullptr
Points to a linked list of case and default statements.
private clang::SourceLocation LParenLoc
private clang::SourceLocation RParenLoc

Inherited from Stmt:

protected

Method Overview

Inherited from Stmt:

Methods

static clang::SwitchStmt* Create(
    const clang::ASTContext& Ctx,
    clang::Stmt* Init,
    clang::VarDecl* Var,
    clang::Expr* Cond,
    clang::SourceLocation LParenLoc,
    clang::SourceLocation RParenLoc)

Description

Create a switch statement.

Declared at: clang/include/clang/AST/Stmt.h:2231

Parameters

const clang::ASTContext& Ctx
clang::Stmt* Init
clang::VarDecl* Var
clang::Expr* Cond
clang::SourceLocation LParenLoc
clang::SourceLocation RParenLoc

static clang::SwitchStmt* CreateEmpty(
    const clang::ASTContext& Ctx,
    bool HasInit,
    bool HasVar)

Description

Create an empty switch statement optionally with storage for an init expression and a condition variable.

Declared at: clang/include/clang/AST/Stmt.h:2237

Parameters

const clang::ASTContext& Ctx
bool HasInit
bool HasVar

SwitchStmt(const clang::ASTContext& Ctx,
           clang::Stmt* Init,
           clang::VarDecl* Var,
           clang::Expr* Cond,
           clang::SourceLocation LParenLoc,
           clang::SourceLocation RParenLoc)

Description

Build a switch statement.

Declared at: clang/include/clang/AST/Stmt.h:2223

Parameters

const clang::ASTContext& Ctx
clang::Stmt* Init
clang::VarDecl* Var
clang::Expr* Cond
clang::SourceLocation LParenLoc
clang::SourceLocation RParenLoc

SwitchStmt(clang::Stmt::EmptyShell Empty,
           bool HasInit,
           bool HasVar)

Description

Build a empty switch statement.

Declared at: clang/include/clang/AST/Stmt.h:2227

Parameters

clang::Stmt::EmptyShell Empty
bool HasInit
bool HasVar

void addSwitchCase(clang::SwitchCase* SC)

Declared at: clang/include/clang/AST/Stmt.h:2331

Parameters

clang::SwitchCase* SC

unsigned int bodyOffset() const

Declared at: clang/include/clang/AST/Stmt.h:2220

clang::Stmt::const_child_range children() const

Declared at: clang/include/clang/AST/Stmt.h:2361

clang::Stmt::child_range children()

Declared at: clang/include/clang/AST/Stmt.h:2355

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

Declared at: clang/include/clang/AST/Stmt.h:2367

Parameters

const clang::Stmt* T

unsigned int condOffset() const

Declared at: clang/include/clang/AST/Stmt.h:2217

clang::SourceLocation getBeginLoc() const

Declared at: clang/include/clang/AST/Stmt.h:2348

clang::Stmt* getBody()

Declared at: clang/include/clang/AST/Stmt.h:2258

const clang::Stmt* getBody() const

Declared at: clang/include/clang/AST/Stmt.h:2259

clang::Expr* getCond()

Declared at: clang/include/clang/AST/Stmt.h:2246

const clang::Expr* getCond() const

Declared at: clang/include/clang/AST/Stmt.h:2250

const clang::VarDecl* getConditionVariable() const

Declared at: clang/include/clang/AST/Stmt.h:2293

clang::VarDecl* getConditionVariable()

Description

Retrieve the variable declared in this "switch" statement, if any. In the following example, "x" is the condition variable.

Declared at: clang/include/clang/AST/Stmt.h:2292

const clang::DeclStmt*
getConditionVariableDeclStmt() const

Declared at: clang/include/clang/AST/Stmt.h:2309

clang::DeclStmt* getConditionVariableDeclStmt()

Description

If this SwitchStmt has a condition variable, return the faux DeclStmt associated with the creation of that condition variable.

Declared at: clang/include/clang/AST/Stmt.h:2303

clang::SourceLocation getEndLoc() const

Declared at: clang/include/clang/AST/Stmt.h:2349

const clang::Stmt* getInit() const

Declared at: clang/include/clang/AST/Stmt.h:2272

clang::Stmt* getInit()

Declared at: clang/include/clang/AST/Stmt.h:2267

clang::SourceLocation getLParenLoc() const

Declared at: clang/include/clang/AST/Stmt.h:2321

clang::SourceLocation getRParenLoc() const

Declared at: clang/include/clang/AST/Stmt.h:2323

clang::SwitchCase* getSwitchCaseList()

Declared at: clang/include/clang/AST/Stmt.h:2315

const clang::SwitchCase* getSwitchCaseList() const

Declared at: clang/include/clang/AST/Stmt.h:2316

clang::SourceLocation getSwitchLoc() const

Declared at: clang/include/clang/AST/Stmt.h:2319

bool hasInitStorage() const

Description

True if this SwitchStmt has storage for an init statement.

Declared at: clang/include/clang/AST/Stmt.h:2241

bool hasVarStorage() const

Description

True if this SwitchStmt has storage for a condition variable.

Declared at: clang/include/clang/AST/Stmt.h:2244

unsigned int initOffset() const

Declared at: clang/include/clang/AST/Stmt.h:2215

bool isAllEnumCasesCovered() const

Description

Returns true if the SwitchStmt is a switch of an enum value and all cases have been explicitly covered.

Declared at: clang/include/clang/AST/Stmt.h:2344

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

Declared at: clang/include/clang/AST/Stmt.h:2211

Parameters

OverloadToken<clang::Stmt*>

void setAllEnumCasesCovered()

Description

Set a flag in the SwitchStmt indicating that if the 'switch (X)' is a switch over an enum value then all cases have been explicitly covered.

Declared at: clang/include/clang/AST/Stmt.h:2340

void setBody(clang::Stmt* S,
             clang::SourceLocation SL)

Declared at: clang/include/clang/AST/Stmt.h:2326

Parameters

clang::Stmt* S
clang::SourceLocation SL

void setBody(clang::Stmt* Body)

Declared at: clang/include/clang/AST/Stmt.h:2263

Parameters

clang::Stmt* Body

void setCond(clang::Expr* Cond)

Declared at: clang/include/clang/AST/Stmt.h:2254

Parameters

clang::Expr* Cond

void setConditionVariable(
    const clang::ASTContext& Ctx,
    clang::VarDecl* VD)

Description

Set the condition variable in this switch statement. The switch statement must have storage for it.

Declared at: clang/include/clang/AST/Stmt.h:2299

Parameters

const clang::ASTContext& Ctx
clang::VarDecl* VD

void setInit(clang::Stmt* Init)

Declared at: clang/include/clang/AST/Stmt.h:2277

Parameters

clang::Stmt* Init

void setLParenLoc(clang::SourceLocation Loc)

Declared at: clang/include/clang/AST/Stmt.h:2322

Parameters

clang::SourceLocation Loc

void setRParenLoc(clang::SourceLocation Loc)

Declared at: clang/include/clang/AST/Stmt.h:2324

Parameters

clang::SourceLocation Loc

void setSwitchCaseList(clang::SwitchCase* SC)

Declared at: clang/include/clang/AST/Stmt.h:2317

Parameters

clang::SwitchCase* SC

void setSwitchLoc(clang::SourceLocation L)

Declared at: clang/include/clang/AST/Stmt.h:2320

Parameters

clang::SourceLocation L

unsigned int varOffset() const

Declared at: clang/include/clang/AST/Stmt.h:2216