Classes | Typedefs | Functions
clang::insights::asthelpers Namespace Reference

Classes

struct  StmtsContainer
 ! A helper type to have a container for ArrayRef More...
 

Typedefs

using params_vector = std::vector< std::pair< std::string_view, QualType > >
 
using params_store = std::vector< std::pair< std::string, QualType > >
 

Functions

DeclStmt * _mkDeclStmt (std::span< Decl * > decls)
 
BinaryOperator * Assign (const VarDecl *var, Expr *assignExpr)
 
static BinaryOperator * mkBinaryOperator (Expr *lhs, Expr *rhs, BinaryOperator::Opcode opc, QualType resType)
 
BinaryOperator * Assign (UnaryOperator *var, Expr *assignExpr)
 
BinaryOperator * Assign (MemberExpr *me, ValueDecl *field, Expr *assignExpr)
 
BinaryOperator * Assign (DeclRefExpr *declRef, ValueDecl *field, Expr *assignExpr)
 
BinaryOperator * Assign (DeclRefExpr *declRef, Expr *assignExpr)
 
BinaryOperator * Assign (Expr *var, Expr *assignExpr)
 
static UnaryOperator * mkUnaryOperator (const Expr *stmt, UnaryOperatorKind kind, QualType type)
 
UnaryOperator * Not (const Expr *stmt)
 
static UnaryOperator * mkReference (Expr *e, QualType t)
 
UnaryOperator * Ref (const Expr *e)
 
UnaryOperator * Ref (const ValueDecl *d)
 
UnaryOperator * Dref (const Expr *stmt)
 
UnaryOperator * AddrOf (const Expr *stmt)
 
CallExpr * Call (const FunctionDecl *fd, ArrayRef< Expr * > params)
 
CallExpr * Call (MemberExpr *fd, ArrayRef< Expr * > params)
 
CallExpr * Call (std::string_view name, ArrayRef< Expr * > args)
 
CXXTryStmt * Try (const Stmt *tryBody, CXXCatchStmt *catchAllBody)
 
CXXCatchStmt * Catch (ArrayRef< Stmt * > body)
 
CXXCatchStmt * Catch (Stmt *body)
 
CXXThrowExpr * Throw (const Expr *expr)
 
UnaryExprOrTypeTraitExpr * Sizeof (QualType toType)
 
CXXStaticCastExpr * Cast (const Expr *toExpr, QualType toType)
 
QualType Ptr (QualType srcType)
 
CanQualType VoidTy ()
 
ParenExpr * Paren (Expr *expr)
 
QualType ContantArrayTy (QualType t, int size)
 
static QualType mkAnonVoidFunctionPointer ()
 
static FunctionDecl * CreateFunctionDecl (std::string_view funcName, params_vector params)
 
CXXStaticCastExpr * CastToVoidFunPtr (std::string_view name)
 
CXXReinterpretCastExpr * ReinterpretCast (QualType toType, const Expr *toExpr, bool makePointer)
 
CXXStaticCastExpr * StaticCast (QualType toType, const Expr *toExpr, bool makePointer)
 
auto * mkLabelDecl (std::string_view name)
 
LabelStmt * Label (std::string_view name)
 
CompoundStmt * mkCompoundStmt (ArrayRef< Stmt * > bodyStmts, SourceLocation beginLoc, SourceLocation endLoc)
 
IfStmt * If (const Expr *condition, ArrayRef< Stmt * > bodyStmts)
 
IntegerLiteral * Int32 (uint64_t value)
 
MemberExpr * AccessMember (const Expr *expr, const ValueDecl *vd, bool isArrow)
 
BinaryOperator * Equal (Expr *var, Expr *assignExpr)
 
BinaryOperator * Plus (Expr *var, Expr *assignExpr)
 
GotoStmt * Goto (std::string_view labelName)
 
ParmVarDecl * Parameter (const FunctionDecl *fd, std::string_view name, QualType type)
 
static auto * FunctionBase (std::string_view name, QualType returnType, const params_vector &parameters, DeclContext *declCtx)
 
FunctionDecl * Function (std::string_view name, QualType returnType, const params_vector &parameters)
 
auto * mkStdFunctionDecl (std::string_view name, QualType returnType, const params_vector &parameters)
 
DeclRefExpr * mkDeclRefExpr (const ValueDecl *vd)
 
ImplicitCastExpr * CastLToRValue (const VarDecl *vd)
 
CXXMemberCallExpr * CallMemberFun (Expr *memExpr, QualType retType)
 
ReturnStmt * Return (Expr *stmt)
 
ReturnStmt * Return (const ValueDecl *stmt)
 
SwitchStmt * Switch (Expr *stmt)
 
BreakStmt * Break ()
 
CaseStmt * Case (int value, Stmt *stmt)
 
VarDecl * Variable (std::string_view name, QualType type, DeclContext *dc)
 
NullStmt * mkNullStmt ()
 
StmtComment (std::string_view comment)
 
CXXRecordDecl * Struct (std::string_view name)
 
FieldDecl * mkFieldDecl (DeclContext *dc, std::string_view name, QualType type)
 
InitListExpr * InitList (ArrayRef< Expr * > initExprs, QualType t)
 
ArraySubscriptExpr * ArraySubscript (const Expr *lhs, uint64_t index, QualType type)
 
params_vector to_params_view (params_store &params)
 
DeclRefExpr * mkVarDeclRefExpr (std::string_view name, QualType type)
 
static CallExpr * CallConstructor (QualType ctorType, DeclRefExpr *lhsDeclRef, Expr *lhsMemberExpr, ArrayRef< Expr * > callParams, DoCast doCast, AsReference asReference)
 
CallExpr * CallConstructor (QualType ctorType, QualType lhsType, const FieldDecl *fieldDecl, ArrayRef< Expr * > callParams, DoCast doCast, AsReference asReference)
 
CallExpr * CallConstructor (QualType ctorType, const VarDecl *varDecl, ArrayRef< Expr * > callParams, DoCast doCast, AsReference asReference)
 
CXXBoolLiteralExpr * Bool (bool b)
 
CallExpr * CallDestructor (const VarDecl *varDecl)
 
QualType Typedef (std::string_view name, QualType underlayingType)
 
QualType GetRecordDeclType (const CXXMethodDecl *md)
 
QualType GetRecordDeclType (const RecordDecl *rd)
 
CXXNewExpr * New (ArrayRef< Expr * > placementArgs, const Expr *expr, QualType t)
 
BinaryOperator * Mul (Expr *lhs, Expr *rhs)
 
BinaryOperator * And (VarDecl *lhs, Expr *rhs)
 
void ReplaceNode (Stmt *parent, Stmt *oldNode, Stmt *newNode)
 
SmallVector< Expr *, 5 > ArgsToExprVector (const Expr *expr)
 
 STRONG_BOOL (DoCast)
 
 STRONG_BOOL (AsReference)
 
template<typename... Dcls>
DeclStmt * mkDeclStmt (Dcls... dcls)
 

Typedef Documentation

◆ params_store

using clang::insights::asthelpers::params_store = typedef std::vector<std::pair<std::string, QualType> >

Definition at line 28 of file ASTHelpers.h.

◆ params_vector

using clang::insights::asthelpers::params_vector = typedef std::vector<std::pair<std::string_view, QualType> >

Definition at line 27 of file ASTHelpers.h.

Function Documentation

◆ _mkDeclStmt()

DeclStmt* clang::insights::asthelpers::_mkDeclStmt ( std::span< Decl * >  decls)

Definition at line 21 of file ASTHelpers.cpp.

References GetGlobalAST().

Referenced by mkDeclStmt().

◆ AccessMember()

MemberExpr * clang::insights::asthelpers::AccessMember ( const Expr *  expr,
const ValueDecl *  vd,
bool  isArrow 
)

◆ AddrOf()

UnaryOperator * clang::insights::asthelpers::AddrOf ( const Expr *  stmt)

◆ And()

BinaryOperator * clang::insights::asthelpers::And ( VarDecl *  lhs,
Expr *  rhs 
)

◆ ArgsToExprVector()

SmallVector< Expr *, 5 > clang::insights::asthelpers::ArgsToExprVector ( const Expr *  expr)

◆ ArraySubscript()

ArraySubscriptExpr * clang::insights::asthelpers::ArraySubscript ( const Expr *  lhs,
uint64_t  index,
QualType  type 
)

◆ Assign() [1/6]

BinaryOperator * clang::insights::asthelpers::Assign ( const VarDecl *  var,
Expr *  assignExpr 
)

◆ Assign() [2/6]

BinaryOperator * clang::insights::asthelpers::Assign ( DeclRefExpr *  declRef,
Expr *  assignExpr 
)

Definition at line 62 of file ASTHelpers.cpp.

References mkBinaryOperator().

◆ Assign() [3/6]

BinaryOperator * clang::insights::asthelpers::Assign ( DeclRefExpr *  declRef,
ValueDecl *  field,
Expr *  assignExpr 
)

Definition at line 56 of file ASTHelpers.cpp.

References AccessMember(), and Assign().

◆ Assign() [4/6]

BinaryOperator * clang::insights::asthelpers::Assign ( Expr *  var,
Expr *  assignExpr 
)

Definition at line 68 of file ASTHelpers.cpp.

References mkBinaryOperator().

Referenced by Assign().

◆ Assign() [5/6]

BinaryOperator * clang::insights::asthelpers::Assign ( MemberExpr *  me,
ValueDecl *  field,
Expr *  assignExpr 
)

Definition at line 50 of file ASTHelpers.cpp.

References mkBinaryOperator().

◆ Assign() [6/6]

BinaryOperator * clang::insights::asthelpers::Assign ( UnaryOperator *  var,
Expr *  assignExpr 
)

Definition at line 44 of file ASTHelpers.cpp.

References mkBinaryOperator().

◆ Bool()

CXXBoolLiteralExpr * clang::insights::asthelpers::Bool ( bool  b)

◆ Break()

BreakStmt * clang::insights::asthelpers::Break ( )

Definition at line 472 of file ASTHelpers.cpp.

References GetGlobalAST().

Referenced by clang::insights::CoroutinesCodeGenerator::InsertArg().

◆ Call() [1/3]

CallExpr * clang::insights::asthelpers::Call ( const FunctionDecl *  fd,
ArrayRef< Expr * >  params 
)

◆ Call() [2/3]

CallExpr * clang::insights::asthelpers::Call ( MemberExpr *  fd,
ArrayRef< Expr * >  params 
)

Definition at line 123 of file ASTHelpers.cpp.

References GetGlobalAST().

◆ Call() [3/3]

CallExpr * clang::insights::asthelpers::Call ( std::string_view  name,
ArrayRef< Expr * >  args 
)

Definition at line 129 of file ASTHelpers.cpp.

References Function(), and VoidTy().

Referenced by CallConstructor().

◆ CallConstructor() [1/3]

CallExpr * clang::insights::asthelpers::CallConstructor ( QualType  ctorType,
const VarDecl *  varDecl,
ArrayRef< Expr * >  callParams,
DoCast  doCast,
AsReference  asReference 
)

Definition at line 633 of file ASTHelpers.cpp.

References mkDeclRefExpr().

Referenced by CallConstructor().

◆ CallConstructor() [2/3]

static CallExpr* clang::insights::asthelpers::CallConstructor ( QualType  ctorType,
DeclRefExpr *  lhsDeclRef,
Expr *  lhsMemberExpr,
ArrayRef< Expr * >  callParams,
DoCast  doCast,
AsReference  asReference 
)
static

◆ CallConstructor() [3/3]

CallExpr * clang::insights::asthelpers::CallConstructor ( QualType  ctorType,
QualType  lhsType,
const FieldDecl *  fieldDecl,
ArrayRef< Expr * >  callParams,
DoCast  doCast,
AsReference  asReference 
)

Definition at line 615 of file ASTHelpers.cpp.

References AccessMember(), CallConstructor(), kwInternalThis, and mkVarDeclRefExpr().

◆ CallDestructor()

CallExpr * clang::insights::asthelpers::CallDestructor ( const VarDecl *  varDecl)

◆ CallMemberFun()

CXXMemberCallExpr * clang::insights::asthelpers::CallMemberFun ( Expr *  memExpr,
QualType  retType 
)

Definition at line 448 of file ASTHelpers.cpp.

References GetGlobalAST().

Referenced by clang::insights::CoroutinesCodeGenerator::InsertCoroutine().

◆ Case()

CaseStmt * clang::insights::asthelpers::Case ( int  value,
Stmt stmt 
)

Definition at line 478 of file ASTHelpers.cpp.

References GetGlobalAST(), and Int32().

Referenced by clang::insights::CoroutinesCodeGenerator::InsertArg().

◆ Cast()

CXXStaticCastExpr * clang::insights::asthelpers::Cast ( const Expr *  toExpr,
QualType  toType 
)

◆ CastLToRValue()

ImplicitCastExpr * clang::insights::asthelpers::CastLToRValue ( const VarDecl *  vd)

Definition at line 441 of file ASTHelpers.cpp.

References GetGlobalAST(), and mkDeclRefExpr().

◆ CastToVoidFunPtr()

CXXStaticCastExpr * clang::insights::asthelpers::CastToVoidFunPtr ( std::string_view  name)

◆ Catch() [1/2]

CXXCatchStmt * clang::insights::asthelpers::Catch ( ArrayRef< Stmt * >  body)

◆ Catch() [2/2]

CXXCatchStmt * clang::insights::asthelpers::Catch ( Stmt body)

Definition at line 159 of file ASTHelpers.cpp.

◆ Comment()

Stmt * clang::insights::asthelpers::Comment ( std::string_view  comment)

◆ ContantArrayTy()

QualType clang::insights::asthelpers::ContantArrayTy ( QualType  t,
int  size 
)

◆ CreateFunctionDecl()

static FunctionDecl* clang::insights::asthelpers::CreateFunctionDecl ( std::string_view  funcName,
params_vector  params 
)
static

Definition at line 222 of file ASTHelpers.cpp.

References Function(), and VoidTy().

Referenced by CallConstructor(), CallDestructor(), and CastToVoidFunPtr().

◆ Dref()

UnaryOperator * clang::insights::asthelpers::Dref ( const Expr *  stmt)

◆ Equal()

BinaryOperator * clang::insights::asthelpers::Equal ( Expr *  var,
Expr *  assignExpr 
)

◆ Function()

FunctionDecl * clang::insights::asthelpers::Function ( std::string_view  name,
QualType  returnType,
const params_vector parameters 
)

◆ FunctionBase()

static auto* clang::insights::asthelpers::FunctionBase ( std::string_view  name,
QualType  returnType,
const params_vector parameters,
DeclContext *  declCtx 
)
static

Definition at line 365 of file ASTHelpers.cpp.

References GetGlobalAST(), and Parameter().

Referenced by Function(), and mkStdFunctionDecl().

◆ GetRecordDeclType() [1/2]

QualType clang::insights::asthelpers::GetRecordDeclType ( const CXXMethodDecl *  md)

◆ GetRecordDeclType() [2/2]

QualType clang::insights::asthelpers::GetRecordDeclType ( const RecordDecl *  rd)

Definition at line 683 of file ASTHelpers.cpp.

◆ Goto()

GotoStmt * clang::insights::asthelpers::Goto ( std::string_view  labelName)

◆ If()

IfStmt * clang::insights::asthelpers::If ( const Expr *  condition,
ArrayRef< Stmt * >  bodyStmts 
)

◆ InitList()

InitListExpr * clang::insights::asthelpers::InitList ( ArrayRef< Expr * >  initExprs,
QualType  t 
)

◆ Int32()

IntegerLiteral * clang::insights::asthelpers::Int32 ( uint64_t  value)

◆ Label()

LabelStmt * clang::insights::asthelpers::Label ( std::string_view  name)

Definition at line 281 of file ASTHelpers.cpp.

References GetGlobalAST(), and mkLabelDecl().

Referenced by clang::insights::CoroutinesCodeGenerator::InsertArg().

◆ mkAnonVoidFunctionPointer()

static QualType clang::insights::asthelpers::mkAnonVoidFunctionPointer ( )
static

Definition at line 212 of file ASTHelpers.cpp.

References Function(), Ptr(), to_params_view(), and VoidTy().

Referenced by CastToVoidFunPtr().

◆ mkBinaryOperator()

static BinaryOperator* clang::insights::asthelpers::mkBinaryOperator ( Expr *  lhs,
Expr *  rhs,
BinaryOperator::Opcode  opc,
QualType  resType 
)
static

Definition at line 37 of file ASTHelpers.cpp.

References GetGlobalAST().

Referenced by And(), Assign(), Equal(), Mul(), and Plus().

◆ mkCompoundStmt()

CompoundStmt * clang::insights::asthelpers::mkCompoundStmt ( ArrayRef< Stmt * >  bodyStmts,
SourceLocation  beginLoc,
SourceLocation  endLoc 
)

◆ mkDeclRefExpr()

DeclRefExpr * clang::insights::asthelpers::mkDeclRefExpr ( const ValueDecl *  vd)

◆ mkDeclStmt()

template<typename... Dcls>
DeclStmt* clang::insights::asthelpers::mkDeclStmt ( Dcls...  dcls)

Definition at line 91 of file ASTHelpers.h.

References _mkDeclStmt().

Referenced by clang::insights::CfrontCodeGenerator::InsertArg().

◆ mkFieldDecl()

FieldDecl * clang::insights::asthelpers::mkFieldDecl ( DeclContext *  dc,
std::string_view  name,
QualType  type 
)

◆ mkLabelDecl()

auto* clang::insights::asthelpers::mkLabelDecl ( std::string_view  name)

Definition at line 273 of file ASTHelpers.cpp.

References GetGlobalAST().

Referenced by Goto(), and Label().

◆ mkNullStmt()

NullStmt * clang::insights::asthelpers::mkNullStmt ( )

Definition at line 499 of file ASTHelpers.cpp.

References GetGlobalAST().

Referenced by clang::insights::LifetimeTracker::Return().

◆ mkReference()

static UnaryOperator* clang::insights::asthelpers::mkReference ( Expr *  e,
QualType  t 
)
static

Definition at line 87 of file ASTHelpers.cpp.

References mkUnaryOperator().

Referenced by Ref().

◆ mkStdFunctionDecl()

auto* clang::insights::asthelpers::mkStdFunctionDecl ( std::string_view  name,
QualType  returnType,
const params_vector parameters 
)

Definition at line 409 of file ASTHelpers.cpp.

References FunctionBase(), and GetGlobalAST().

◆ mkUnaryOperator()

static UnaryOperator* clang::insights::asthelpers::mkUnaryOperator ( const Expr *  stmt,
UnaryOperatorKind  kind,
QualType  type 
)
static

Definition at line 74 of file ASTHelpers.cpp.

References GetGlobalAST().

Referenced by AddrOf(), Dref(), mkReference(), and Not().

◆ mkVarDeclRefExpr()

DeclRefExpr * clang::insights::asthelpers::mkVarDeclRefExpr ( std::string_view  name,
QualType  type 
)

◆ Mul()

BinaryOperator * clang::insights::asthelpers::Mul ( Expr *  lhs,
Expr *  rhs 
)

Definition at line 711 of file ASTHelpers.cpp.

References mkBinaryOperator().

Referenced by clang::insights::CfrontCodeGenerator::InsertArg().

◆ New()

CXXNewExpr * clang::insights::asthelpers::New ( ArrayRef< Expr * >  placementArgs,
const Expr *  expr,
QualType  t 
)

◆ Not()

UnaryOperator * clang::insights::asthelpers::Not ( const Expr *  stmt)

Definition at line 81 of file ASTHelpers.cpp.

References mkUnaryOperator().

Referenced by clang::insights::CoroutinesCodeGenerator::InsertArg().

◆ Parameter()

ParmVarDecl * clang::insights::asthelpers::Parameter ( const FunctionDecl *  fd,
std::string_view  name,
QualType  type 
)

◆ Paren()

ParenExpr * clang::insights::asthelpers::Paren ( Expr *  expr)

Definition at line 196 of file ASTHelpers.cpp.

References GetGlobalAST().

Referenced by clang::insights::CfrontCodeGenerator::InsertArg().

◆ Plus()

BinaryOperator * clang::insights::asthelpers::Plus ( Expr *  var,
Expr *  assignExpr 
)

Definition at line 336 of file ASTHelpers.cpp.

References mkBinaryOperator().

Referenced by clang::insights::CfrontCodeGenerator::InsertArg().

◆ Ptr()

QualType clang::insights::asthelpers::Ptr ( QualType  srcType)

◆ Ref() [1/2]

UnaryOperator * clang::insights::asthelpers::Ref ( const Expr *  e)

◆ Ref() [2/2]

UnaryOperator * clang::insights::asthelpers::Ref ( const ValueDecl *  d)

Definition at line 99 of file ASTHelpers.cpp.

References mkDeclRefExpr().

Referenced by CallConstructor().

◆ ReinterpretCast()

CXXReinterpretCastExpr * clang::insights::asthelpers::ReinterpretCast ( QualType  toType,
const Expr *  toExpr,
bool  makePointer 
)

◆ ReplaceNode()

void clang::insights::asthelpers::ReplaceNode ( Stmt parent,
Stmt oldNode,
Stmt newNode 
)

◆ Return() [1/2]

ReturnStmt * clang::insights::asthelpers::Return ( const ValueDecl *  stmt)

Definition at line 460 of file ASTHelpers.cpp.

References mkDeclRefExpr().

◆ Return() [2/2]

ReturnStmt * clang::insights::asthelpers::Return ( Expr *  stmt)

◆ Sizeof()

UnaryExprOrTypeTraitExpr * clang::insights::asthelpers::Sizeof ( QualType  toType)

◆ StaticCast()

CXXStaticCastExpr * clang::insights::asthelpers::StaticCast ( QualType  toType,
const Expr *  toExpr,
bool  makePointer 
)

◆ STRONG_BOOL() [1/2]

clang::insights::asthelpers::STRONG_BOOL ( AsReference  )

◆ STRONG_BOOL() [2/2]

clang::insights::asthelpers::STRONG_BOOL ( DoCast  )

◆ Struct()

CXXRecordDecl * clang::insights::asthelpers::Struct ( std::string_view  name)

◆ Switch()

SwitchStmt * clang::insights::asthelpers::Switch ( Expr *  stmt)

Definition at line 466 of file ASTHelpers.cpp.

References GetGlobalAST().

Referenced by clang::insights::CoroutinesCodeGenerator::InsertArg().

◆ Throw()

CXXThrowExpr * clang::insights::asthelpers::Throw ( const Expr *  expr)

◆ to_params_view()

params_vector clang::insights::asthelpers::to_params_view ( params_store params)

◆ Try()

CXXTryStmt * clang::insights::asthelpers::Try ( const Stmt tryBody,
CXXCatchStmt *  catchAllBody 
)

◆ Typedef()

QualType clang::insights::asthelpers::Typedef ( std::string_view  name,
QualType  underlayingType 
)

◆ Variable()

VarDecl * clang::insights::asthelpers::Variable ( std::string_view  name,
QualType  type,
DeclContext *  dc 
)

◆ VoidTy()

CanQualType clang::insights::asthelpers::VoidTy ( )