clang API Documentation

Public Types | Public Member Functions | Static Public Member Functions | Friends
clang::CXXNewExpr Class Reference

Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)". More...

#include <ExprCXX.h>

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

List of all members.

Public Types

enum  InitializationStyle { NoInit, CallInit, ListInit }
typedef ExprIterator arg_iterator
typedef ConstExprIterator const_arg_iterator
typedef Stmt ** raw_arg_iterator

Public Member Functions

 CXXNewExpr (const ASTContext &C, bool globalNew, FunctionDecl *operatorNew, FunctionDecl *operatorDelete, bool usualArrayDeleteWantsSize, ArrayRef< Expr * > placementArgs, SourceRange typeIdParens, Expr *arraySize, InitializationStyle initializationStyle, Expr *initializer, QualType ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range, SourceRange directInitRange)
 CXXNewExpr (EmptyShell Shell)
void AllocateArgsArray (const ASTContext &C, bool isArray, unsigned numPlaceArgs, bool hasInitializer)
QualType getAllocatedType () const
TypeSourceInfogetAllocatedTypeSourceInfo () const
bool shouldNullCheckAllocation (const ASTContext &Ctx) const
 True if the allocation result needs to be null-checked.
FunctionDeclgetOperatorNew () const
void setOperatorNew (FunctionDecl *D)
FunctionDeclgetOperatorDelete () const
void setOperatorDelete (FunctionDecl *D)
bool isArray () const
ExprgetArraySize ()
const ExprgetArraySize () const
unsigned getNumPlacementArgs () const
Expr ** getPlacementArgs ()
ExprgetPlacementArg (unsigned i)
const ExprgetPlacementArg (unsigned i) const
bool isParenTypeId () const
SourceRange getTypeIdParens () const
bool isGlobalNew () const
bool hasInitializer () const
 Whether this new-expression has any initializer at all.
InitializationStyle getInitializationStyle () const
 The kind of initializer this new-expression has.
ExprgetInitializer ()
 The initializer of this new-expression.
const ExprgetInitializer () const
const CXXConstructExprgetConstructExpr () const
 Returns the CXXConstructExpr from this new-expression, or null.
bool doesUsualArrayDeleteWantSize () const
arg_iterator placement_arg_begin ()
arg_iterator placement_arg_end ()
const_arg_iterator placement_arg_begin () const
const_arg_iterator placement_arg_end () const
raw_arg_iterator raw_arg_begin ()
raw_arg_iterator raw_arg_end ()
const_arg_iterator raw_arg_begin () const
const_arg_iterator raw_arg_end () const
SourceLocation getStartLoc () const
SourceLocation getEndLoc () const
SourceRange getDirectInitRange () const
SourceRange getSourceRange () const LLVM_READONLY
SourceLocation getLocStart () const LLVM_READONLY
SourceLocation getLocEnd () const LLVM_READONLY
child_range children ()

Static Public Member Functions

static bool classof (const Stmt *T)

Friends

class ASTStmtReader
class ASTStmtWriter

Detailed Description

Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".

Definition at line 1614 of file ExprCXX.h.


Member Typedef Documentation

Definition at line 1757 of file ExprCXX.h.

Definition at line 1758 of file ExprCXX.h.

Definition at line 1773 of file ExprCXX.h.


Member Enumeration Documentation

Enumerator:
NoInit 

New-expression has no initializer as written.

CallInit 

New-expression has a C++98 paren-delimited initializer.

ListInit 

New-expression has a C++11 list-initializer.

Definition at line 1654 of file ExprCXX.h.


Constructor & Destructor Documentation

CXXNewExpr::CXXNewExpr ( const ASTContext C,
bool  globalNew,
FunctionDecl operatorNew,
FunctionDecl operatorDelete,
bool  usualArrayDeleteWantsSize,
ArrayRef< Expr * >  placementArgs,
SourceRange  typeIdParens,
Expr arraySize,
InitializationStyle  initializationStyle,
Expr initializer,
QualType  ty,
TypeSourceInfo AllocatedTypeInfo,
SourceRange  Range,
SourceRange  directInitRange 
)
clang::CXXNewExpr::CXXNewExpr ( EmptyShell  Shell) [inline, explicit]

Definition at line 1667 of file ExprCXX.h.


Member Function Documentation

void CXXNewExpr::AllocateArgsArray ( const ASTContext C,
bool  isArray,
unsigned  numPlaceArgs,
bool  hasInitializer 
)

Definition at line 200 of file ExprCXX.cpp.

References AttributeLangSupport::C, and isArray().

Referenced by CXXNewExpr().

Reimplemented from clang::Stmt.

Definition at line 1799 of file ExprCXX.h.

References raw_arg_begin(), and raw_arg_end().

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

Reimplemented from clang::Expr.

Definition at line 1794 of file ExprCXX.h.

References clang::Stmt::getStmtClass().

Answers whether the usual array deallocation function for the allocated type expects the size of the allocation as a parameter.

Definition at line 1753 of file ExprCXX.h.

Referenced by clang::CodeGen::CGCXXABI::requiresArrayCookie().

Definition at line 1678 of file ExprCXX.h.

Definition at line 1701 of file ExprCXX.h.

Referenced by EmitCXXNewAllocSize().

const Expr* clang::CXXNewExpr::getArraySize ( ) const [inline]

Definition at line 1704 of file ExprCXX.h.

Returns the CXXConstructExpr from this new-expression, or null.

Definition at line 1746 of file ExprCXX.h.

References getInitializer().

Referenced by treatUnusedNewEscaped().

Definition at line 1786 of file ExprCXX.h.

Definition at line 1784 of file ExprCXX.h.

References clang::SourceRange::getEnd().

Referenced by getLocEnd().

The kind of initializer this new-expression has.

Definition at line 1731 of file ExprCXX.h.

References NoInit.

Referenced by CXXNewExpr().

const Expr* clang::CXXNewExpr::getInitializer ( ) const [inline]

Definition at line 1741 of file ExprCXX.h.

References hasInitializer().

Reimplemented from clang::Stmt.

Definition at line 1792 of file ExprCXX.h.

References getEndLoc().

Reimplemented from clang::Stmt.

Definition at line 1791 of file ExprCXX.h.

References getStartLoc().

Referenced by clang::ento::ExprEngine::ProcessNewAllocator().

Definition at line 1708 of file ExprCXX.h.

Referenced by EnterNewDeleteCleanup(), placement_arg_end(), and raw_arg_end().

Definition at line 1713 of file ExprCXX.h.

References getPlacementArgs().

Referenced by getPlacementArg(), and clang::ento::ExprEngine::VisitCXXNewExpr().

const Expr* clang::CXXNewExpr::getPlacementArg ( unsigned  i) const [inline]

Definition at line 1717 of file ExprCXX.h.

References getPlacementArg().

Definition at line 1709 of file ExprCXX.h.

References hasInitializer().

Referenced by getPlacementArg().

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 1788 of file ExprCXX.h.

Referenced by CXXNewExpr().

Definition at line 1723 of file ExprCXX.h.

bool clang::CXXNewExpr::isArray ( ) const [inline]

Definition at line 1725 of file ExprCXX.h.

Definition at line 1722 of file ExprCXX.h.

References clang::SourceRange::isValid().

Definition at line 1760 of file ExprCXX.h.

References hasInitializer().

Referenced by clang::CodeGen::CodeGenFunction::EmitCXXNewExpr().

Definition at line 1766 of file ExprCXX.h.

References hasInitializer().

Definition at line 1763 of file ExprCXX.h.

References getNumPlacementArgs(), and hasInitializer().

Referenced by clang::CodeGen::CodeGenFunction::EmitCXXNewExpr().

Definition at line 1769 of file ExprCXX.h.

References getNumPlacementArgs(), and hasInitializer().

Definition at line 1774 of file ExprCXX.h.

Referenced by children().

Definition at line 1778 of file ExprCXX.h.

Definition at line 1775 of file ExprCXX.h.

References getNumPlacementArgs(), and hasInitializer().

Referenced by children().

Definition at line 1779 of file ExprCXX.h.

References getNumPlacementArgs(), and hasInitializer().

Definition at line 1698 of file ExprCXX.h.

Definition at line 1696 of file ExprCXX.h.

True if the allocation result needs to be null-checked.

C++11 [expr.new]p13: If the allocation function returns null, initialization shall not be done, the deallocation function shall not be called, and the value of the new-expression shall be null.

An allocation function is not allowed to return null unless it has a non-throwing exception-specification. The '03 rule is identical except that the definition of a non-throwing exception specification is just "is it throw()?".

Definition at line 210 of file ExprCXX.cpp.

References getOperatorNew(), and clang::ValueDecl::getType().


Friends And Related Function Documentation

friend class ASTStmtReader [friend]

Reimplemented from clang::Stmt.

Definition at line 1651 of file ExprCXX.h.

friend class ASTStmtWriter [friend]

Reimplemented from clang::Stmt.

Definition at line 1652 of file ExprCXX.h.


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