clang  8.0.0svn
Public Member Functions | Static Public Member Functions | List of all members
clang::IfStmt Class Referencefinal

IfStmt - This represents an if/then/else. More...

#include "clang/AST/Stmt.h"

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

Public Member Functions

bool hasInitStorage () const
 True if this IfStmt has the storage for an init statement. More...
 
bool hasVarStorage () const
 True if this IfStmt has storage for a variable declaration. More...
 
bool hasElseStorage () const
 True if this IfStmt has storage for an else statement. More...
 
ExprgetCond ()
 
const ExprgetCond () const
 
void setCond (Expr *Cond)
 
StmtgetThen ()
 
const StmtgetThen () const
 
void setThen (Stmt *Then)
 
StmtgetElse ()
 
const StmtgetElse () const
 
void setElse (Stmt *Else)
 
VarDeclgetConditionVariable ()
 Retrieve the variable declared in this "if" statement, if any. More...
 
const VarDeclgetConditionVariable () const
 
void setConditionVariable (const ASTContext &Ctx, VarDecl *V)
 Set the condition variable for this if statement. More...
 
DeclStmtgetConditionVariableDeclStmt ()
 If this IfStmt has a condition variable, return the faux DeclStmt associated with the creation of that condition variable. More...
 
const DeclStmtgetConditionVariableDeclStmt () const
 
StmtgetInit ()
 
const StmtgetInit () const
 
void setInit (Stmt *Init)
 
SourceLocation getIfLoc () const
 
void setIfLoc (SourceLocation IfLoc)
 
SourceLocation getElseLoc () const
 
void setElseLoc (SourceLocation ElseLoc)
 
bool isConstexpr () const
 
void setConstexpr (bool C)
 
bool isObjCAvailabilityCheck () const
 
SourceLocation getBeginLoc () const
 
SourceLocation getEndLoc () const LLVM_READONLY
 
child_range children ()
 
- Public Member Functions inherited from clang::Stmt
void * operator new (size_t bytes, const ASTContext &C, unsigned alignment=8)
 
void * operator new (size_t bytes, const ASTContext *C, unsigned alignment=8)
 
void * operator new (size_t bytes, void *mem) noexcept
 
void operator delete (void *, const ASTContext &, unsigned) noexcept
 
void operator delete (void *, const ASTContext *, unsigned) noexcept
 
void operator delete (void *, size_t) noexcept
 
void operator delete (void *, void *) noexcept
 
 Stmt (StmtClass SC)
 
StmtClass getStmtClass () const
 
const char * getStmtClassName () const
 
SourceRange getSourceRange () const LLVM_READONLY
 SourceLocation tokens are not useful in isolation - they are low level value objects created/interpreted by SourceManager. More...
 
SourceLocation getBeginLoc () const LLVM_READONLY
 
SourceLocation getEndLoc () const LLVM_READONLY
 
void dump () const
 Dumps the specified AST fragment and all subtrees to llvm::errs(). More...
 
void dump (SourceManager &SM) const
 
void dump (raw_ostream &OS, SourceManager &SM) const
 
void dump (raw_ostream &OS) const
 
int64_t getID (const ASTContext &Context) const
 
void dumpColor () const
 dumpColor - same as dump(), but forces color highlighting. More...
 
void dumpPretty (const ASTContext &Context) const
 dumpPretty/printPretty - These two methods do a "pretty print" of the AST back to its original source language syntax. More...
 
void printPretty (raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\, const ASTContext *Context=nullptr) const
 
void viewAST () const
 viewAST - Visualize an AST rooted at this Stmt* using GraphViz. More...
 
StmtIgnoreImplicit ()
 Skip past any implicit AST nodes which might surround this statement, such as ExprWithCleanups or ImplicitCastExpr nodes. More...
 
const StmtIgnoreImplicit () const
 
StmtIgnoreContainers (bool IgnoreCaptured=false)
 Skip no-op (attributed, compound) container stmts and skip captured stmt at the top, if IgnoreCaptured is true. More...
 
const StmtIgnoreContainers (bool IgnoreCaptured=false) const
 
const StmtstripLabelLikeStatements () const
 Strip off all label-like statements. More...
 
StmtstripLabelLikeStatements ()
 
child_range children ()
 
const_child_range children () const
 
child_iterator child_begin ()
 
child_iterator child_end ()
 
const_child_iterator child_begin () const
 
const_child_iterator child_end () const
 
void Profile (llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool Canonical) const
 Produce a unique representation of the given statement. More...
 
void ProcessODRHash (llvm::FoldingSetNodeID &ID, ODRHash &Hash) const
 Calculate a unique representation for a statement that is stable across compiler invocations. More...
 

Static Public Member Functions

static IfStmtCreate (const ASTContext &Ctx, SourceLocation IL, bool IsConstexpr, Stmt *Init, VarDecl *Var, Expr *Cond, Stmt *Then, SourceLocation EL=SourceLocation(), Stmt *Else=nullptr)
 Create an IfStmt. More...
 
static IfStmtCreateEmpty (const ASTContext &Ctx, bool HasElse, bool HasVar, bool HasInit)
 Create an empty IfStmt optionally with storage for an else statement, condition variable and init expression. More...
 
static bool classof (const Stmt *T)
 
- Static Public Member Functions inherited from clang::Stmt
static void addStmtClass (const StmtClass s)
 
static void EnableStatistics ()
 
static void PrintStats ()
 

Additional Inherited Members

- Public Types inherited from clang::Stmt
enum  StmtClass { NoStmtClass = 0 }
 
using child_iterator = StmtIterator
 Child Iterators: All subclasses must implement 'children' to permit easy iteration over the substatements/subexpessions of an AST node. More...
 
using const_child_iterator = ConstStmtIterator
 
using child_range = llvm::iterator_range< child_iterator >
 
using const_child_range = llvm::iterator_range< const_child_iterator >
 
- Protected Types inherited from clang::Stmt
enum  { NumStmtBits = 8 }
 
enum  { NumExprBits = 17 }
 
enum  APFloatSemantics {
  IEEEhalf, IEEEsingle, IEEEdouble, x87DoubleExtended,
  IEEEquad, PPCDoubleDouble
}
 
- Protected Member Functions inherited from clang::Stmt
void * operator new (size_t bytes) noexcept
 
void operator delete (void *data) noexcept
 
 Stmt (StmtClass SC, EmptyShell)
 Construct an empty statement. More...
 
- Protected Attributes inherited from clang::Stmt
union {
   StmtBitfields   StmtBits
 
   NullStmtBitfields   NullStmtBits
 
   CompoundStmtBitfields   CompoundStmtBits
 
   LabelStmtBitfields   LabelStmtBits
 
   AttributedStmtBitfields   AttributedStmtBits
 
   IfStmtBitfields   IfStmtBits
 
   SwitchStmtBitfields   SwitchStmtBits
 
   WhileStmtBitfields   WhileStmtBits
 
   DoStmtBitfields   DoStmtBits
 
   ForStmtBitfields   ForStmtBits
 
   GotoStmtBitfields   GotoStmtBits
 
   ContinueStmtBitfields   ContinueStmtBits
 
   BreakStmtBitfields   BreakStmtBits
 
   ReturnStmtBitfields   ReturnStmtBits
 
   SwitchCaseBitfields   SwitchCaseBits
 
   ExprBitfields   ExprBits
 
   PredefinedExprBitfields   PredefinedExprBits
 
   CharacterLiteralBitfields   CharacterLiteralBits
 
   FloatingLiteralBitfields   FloatingLiteralBits
 
   UnaryExprOrTypeTraitExprBitfields   UnaryExprOrTypeTraitExprBits
 
   DeclRefExprBitfields   DeclRefExprBits
 
   CastExprBitfields   CastExprBits
 
   CallExprBitfields   CallExprBits
 
   ExprWithCleanupsBitfields   ExprWithCleanupsBits
 
   PseudoObjectExprBitfields   PseudoObjectExprBits
 
   OpaqueValueExprBitfields   OpaqueValueExprBits
 
   ObjCIndirectCopyRestoreExprBitfields   ObjCIndirectCopyRestoreExprBits
 
   InitListExprBitfields   InitListExprBits
 
   TypeTraitExprBitfields   TypeTraitExprBits
 
   CoawaitExprBitfields   CoawaitBits
 
}; 
 

Detailed Description

IfStmt - This represents an if/then/else.

Definition at line 1249 of file Stmt.h.

Member Function Documentation

◆ children()

child_range clang::IfStmt::children ( )
inline

Definition at line 1436 of file Stmt.h.

◆ classof()

static bool clang::IfStmt::classof ( const Stmt T)
inlinestatic

Definition at line 1442 of file Stmt.h.

References clang::Stmt::getStmtClass().

◆ Create()

IfStmt * IfStmt::Create ( const ASTContext Ctx,
SourceLocation  IL,
bool  IsConstexpr,
Stmt Init,
VarDecl Var,
Expr Cond,
Stmt Then,
SourceLocation  EL = SourceLocation(),
Stmt Else = nullptr 
)
static

◆ CreateEmpty()

IfStmt * IfStmt::CreateEmpty ( const ASTContext Ctx,
bool  HasElse,
bool  HasVar,
bool  HasInit 
)
static

Create an empty IfStmt optionally with storage for an else statement, condition variable and init expression.

Definition at line 850 of file Stmt.cpp.

References clang::ASTContext::Allocate().

◆ getBeginLoc()

SourceLocation clang::IfStmt::getBeginLoc ( ) const
inline

Definition at line 1427 of file Stmt.h.

◆ getCond() [1/2]

Expr* clang::IfStmt::getCond ( )
inline

◆ getCond() [2/2]

const Expr* clang::IfStmt::getCond ( ) const
inline

Definition at line 1328 of file Stmt.h.

◆ getConditionVariable() [1/2]

VarDecl * IfStmt::getConditionVariable ( )

Retrieve the variable declared in this "if" statement, if any.

In the following example, "x" is the condition variable.

if (int x = foo()) {
printf("x is %d", x);
}

Definition at line 859 of file Stmt.cpp.

Referenced by clang::TreeTransform< Derived >::TransformAttr().

◆ getConditionVariable() [2/2]

const VarDecl* clang::IfStmt::getConditionVariable ( ) const
inline

Definition at line 1370 of file Stmt.h.

◆ getConditionVariableDeclStmt() [1/2]

DeclStmt* clang::IfStmt::getConditionVariableDeclStmt ( )
inline

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

Definition at line 1380 of file Stmt.h.

◆ getConditionVariableDeclStmt() [2/2]

const DeclStmt* clang::IfStmt::getConditionVariableDeclStmt ( ) const
inline

Definition at line 1386 of file Stmt.h.

◆ getElse() [1/2]

Stmt* clang::IfStmt::getElse ( )
inline

◆ getElse() [2/2]

const Stmt* clang::IfStmt::getElse ( ) const
inline

Definition at line 1350 of file Stmt.h.

◆ getElseLoc()

SourceLocation clang::IfStmt::getElseLoc ( ) const
inline

Definition at line 1411 of file Stmt.h.

Referenced by clang::TreeTransform< Derived >::TransformAttr().

◆ getEndLoc()

SourceLocation clang::IfStmt::getEndLoc ( ) const
inline

Definition at line 1428 of file Stmt.h.

◆ getIfLoc()

SourceLocation clang::IfStmt::getIfLoc ( ) const
inline

Definition at line 1408 of file Stmt.h.

Referenced by clang::TreeTransform< Derived >::TransformAttr().

◆ getInit() [1/2]

Stmt* clang::IfStmt::getInit ( )
inline

Definition at line 1392 of file Stmt.h.

Referenced by clang::TreeTransform< Derived >::TransformAttr().

◆ getInit() [2/2]

const Stmt* clang::IfStmt::getInit ( ) const
inline

Definition at line 1397 of file Stmt.h.

◆ getThen() [1/2]

Stmt* clang::IfStmt::getThen ( )
inline

◆ getThen() [2/2]

const Stmt* clang::IfStmt::getThen ( ) const
inline

Definition at line 1337 of file Stmt.h.

◆ hasElseStorage()

bool clang::IfStmt::hasElseStorage ( ) const
inline

True if this IfStmt has storage for an else statement.

Definition at line 1322 of file Stmt.h.

◆ hasInitStorage()

bool clang::IfStmt::hasInitStorage ( ) const
inline

True if this IfStmt has the storage for an init statement.

Definition at line 1316 of file Stmt.h.

◆ hasVarStorage()

bool clang::IfStmt::hasVarStorage ( ) const
inline

True if this IfStmt has storage for a variable declaration.

Definition at line 1319 of file Stmt.h.

◆ isConstexpr()

bool clang::IfStmt::isConstexpr ( ) const
inline

Definition at line 1422 of file Stmt.h.

Referenced by clang::TreeTransform< Derived >::TransformAttr().

◆ isObjCAvailabilityCheck()

bool IfStmt::isObjCAvailabilityCheck ( ) const

Definition at line 880 of file Stmt.cpp.

◆ setCond()

void clang::IfStmt::setCond ( Expr Cond)
inline

Definition at line 1332 of file Stmt.h.

◆ setConditionVariable()

void IfStmt::setConditionVariable ( const ASTContext Ctx,
VarDecl V 
)

Set the condition variable for this if statement.

The if statement must have storage for the condition variable.

Definition at line 866 of file Stmt.cpp.

References clang::SourceRange::getBegin(), clang::SourceRange::getEnd(), and clang::VarDecl::getSourceRange().

◆ setConstexpr()

void clang::IfStmt::setConstexpr ( bool  C)
inline

Definition at line 1423 of file Stmt.h.

◆ setElse()

void clang::IfStmt::setElse ( Stmt Else)
inline

Definition at line 1355 of file Stmt.h.

◆ setElseLoc()

void clang::IfStmt::setElseLoc ( SourceLocation  ElseLoc)
inline

Definition at line 1416 of file Stmt.h.

◆ setIfLoc()

void clang::IfStmt::setIfLoc ( SourceLocation  IfLoc)
inline

Definition at line 1409 of file Stmt.h.

◆ setInit()

void clang::IfStmt::setInit ( Stmt Init)
inline

Definition at line 1402 of file Stmt.h.

◆ setThen()

void clang::IfStmt::setThen ( Stmt Then)
inline

Definition at line 1341 of file Stmt.h.


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