class CXXNewExpr

Declaration

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

Description

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

Declared at: clang/include/clang/AST/ExprCXX.h:2139

Inherits from: Expr, TrailingObjects

Member Variables

private clang::FunctionDecl* OperatorNew
Points to the allocation function used.
private clang::FunctionDecl* OperatorDelete
Points to the deallocation function used in case of error. May be null.
private clang::TypeSourceInfo* AllocatedTypeInfo
The allocated type-source information, as written in the source.
private clang::SourceRange Range
Range of the entire new expression.
private clang::SourceRange DirectInitRange
Source-range of a paren-delimited initializer.

Inherited from Stmt:

protected

Method Overview

  • private CXXNewExpr(clang::Stmt::EmptyShell Empty, bool IsArray, unsigned int NumPlacementArgs, bool IsParenTypeId)
  • private CXXNewExpr(bool IsGlobalNew, clang::FunctionDecl * OperatorNew, clang::FunctionDecl * OperatorDelete, bool ShouldPassAlignment, bool UsualArrayDeleteWantsSize, ArrayRef<clang::Expr *> PlacementArgs, clang::SourceRange TypeIdParens, Optional<clang::Expr *> ArraySize, clang::CXXNewExpr::InitializationStyle InitializationStyle, clang::Expr * Initializer, clang::QualType Ty, clang::TypeSourceInfo * AllocatedTypeInfo, clang::SourceRange Range, clang::SourceRange DirectInitRange)
  • public static clang::CXXNewExpr * Create(const clang::ASTContext & Ctx, bool IsGlobalNew, clang::FunctionDecl * OperatorNew, clang::FunctionDecl * OperatorDelete, bool ShouldPassAlignment, bool UsualArrayDeleteWantsSize, ArrayRef<clang::Expr *> PlacementArgs, clang::SourceRange TypeIdParens, Optional<clang::Expr *> ArraySize, clang::CXXNewExpr::InitializationStyle InitializationStyle, clang::Expr * Initializer, clang::QualType Ty, clang::TypeSourceInfo * AllocatedTypeInfo, clang::SourceRange Range, clang::SourceRange DirectInitRange)
  • public static clang::CXXNewExpr * CreateEmpty(const clang::ASTContext & Ctx, bool IsArray, bool HasInit, unsigned int NumPlacementArgs, bool IsParenTypeId)
  • private unsigned int arraySizeOffset() const
  • public clang::Stmt::child_range children()
  • public clang::Stmt::const_child_range children() const
  • public static bool classof(const clang::Stmt * T)
  • public bool doesUsualArrayDeleteWantSize() const
  • public clang::QualType getAllocatedType() const
  • public clang::TypeSourceInfo * getAllocatedTypeSourceInfo() const
  • public Optional<const clang::Expr *> getArraySize() const
  • public Optional<clang::Expr *> getArraySize()
  • public clang::SourceLocation getBeginLoc() const
  • public const clang::CXXConstructExpr * getConstructExpr() const
  • public clang::SourceRange getDirectInitRange() const
  • public clang::SourceLocation getEndLoc() const
  • public clang::CXXNewExpr::InitializationStyle getInitializationStyle() const
  • public clang::Expr * getInitializer()
  • public const clang::Expr * getInitializer() const
  • public unsigned int getNumPlacementArgs() const
  • public clang::FunctionDecl * getOperatorDelete() const
  • public clang::FunctionDecl * getOperatorNew() const
  • public clang::Expr * getPlacementArg(unsigned int I)
  • public const clang::Expr * getPlacementArg(unsigned int I) const
  • public clang::Expr ** getPlacementArgs()
  • public clang::SourceRange getSourceRange() const
  • public clang::SourceRange getTypeIdParens() const
  • public bool hasInitializer() const
  • private unsigned int initExprOffset() const
  • public bool isArray() const
  • public bool isGlobalNew() const
  • public bool isParenTypeId() const
  • private unsigned int numTrailingObjects(OverloadToken<clang::Stmt *>) const
  • private unsigned int numTrailingObjects(OverloadToken<clang::SourceRange>) const
  • public bool passAlignment() const
  • private unsigned int placementNewArgsOffset() const
  • public clang::CXXNewExpr::const_arg_iterator placement_arg_begin() const
  • public clang::CXXNewExpr::arg_iterator placement_arg_begin()
  • public clang::CXXNewExpr::const_arg_iterator placement_arg_end() const
  • public clang::CXXNewExpr::arg_iterator placement_arg_end()
  • public llvm::iterator_range<const_arg_iterator> placement_arguments() const
  • public llvm::iterator_range<arg_iterator> placement_arguments()
  • public clang::CXXNewExpr::raw_arg_iterator raw_arg_begin()
  • public clang::CXXNewExpr::const_arg_iterator raw_arg_begin() const
  • public clang::CXXNewExpr::raw_arg_iterator raw_arg_end()
  • public clang::CXXNewExpr::const_arg_iterator raw_arg_end() const
  • public void setOperatorDelete(clang::FunctionDecl * D)
  • public void setOperatorNew(clang::FunctionDecl * D)
  • public bool shouldNullCheckAllocation() const

Inherited from Expr:

Inherited from ValueStmt:

Inherited from Stmt:

Methods

CXXNewExpr(clang::Stmt::EmptyShell Empty,
           bool IsArray,
           unsigned int NumPlacementArgs,
           bool IsParenTypeId)

Description

Build an empty c++ new expression.

Declared at: clang/include/clang/AST/ExprCXX.h:2213

Parameters

clang::Stmt::EmptyShell Empty
bool IsArray
unsigned int NumPlacementArgs
bool IsParenTypeId

CXXNewExpr(
    bool IsGlobalNew,
    clang::FunctionDecl* OperatorNew,
    clang::FunctionDecl* OperatorDelete,
    bool ShouldPassAlignment,
    bool UsualArrayDeleteWantsSize,
    ArrayRef<clang::Expr*> PlacementArgs,
    clang::SourceRange TypeIdParens,
    Optional<clang::Expr*> ArraySize,
    clang::CXXNewExpr::InitializationStyle
        InitializationStyle,
    clang::Expr* Initializer,
    clang::QualType Ty,
    clang::TypeSourceInfo* AllocatedTypeInfo,
    clang::SourceRange Range,
    clang::SourceRange DirectInitRange)

Description

Build a c++ new expression.

Declared at: clang/include/clang/AST/ExprCXX.h:2204

Parameters

bool IsGlobalNew
clang::FunctionDecl* OperatorNew
clang::FunctionDecl* OperatorDelete
bool ShouldPassAlignment
bool UsualArrayDeleteWantsSize
ArrayRef<clang::Expr*> PlacementArgs
clang::SourceRange TypeIdParens
Optional<clang::Expr*> ArraySize
clang::CXXNewExpr::InitializationStyle InitializationStyle
clang::Expr* Initializer
clang::QualType Ty
clang::TypeSourceInfo* AllocatedTypeInfo
clang::SourceRange Range
clang::SourceRange DirectInitRange

static clang::CXXNewExpr* Create(
    const clang::ASTContext& Ctx,
    bool IsGlobalNew,
    clang::FunctionDecl* OperatorNew,
    clang::FunctionDecl* OperatorDelete,
    bool ShouldPassAlignment,
    bool UsualArrayDeleteWantsSize,
    ArrayRef<clang::Expr*> PlacementArgs,
    clang::SourceRange TypeIdParens,
    Optional<clang::Expr*> ArraySize,
    clang::CXXNewExpr::InitializationStyle
        InitializationStyle,
    clang::Expr* Initializer,
    clang::QualType Ty,
    clang::TypeSourceInfo* AllocatedTypeInfo,
    clang::SourceRange Range,
    clang::SourceRange DirectInitRange)

Description

Create a c++ new expression.

Declared at: clang/include/clang/AST/ExprCXX.h:2219

Parameters

const clang::ASTContext& Ctx
bool IsGlobalNew
clang::FunctionDecl* OperatorNew
clang::FunctionDecl* OperatorDelete
bool ShouldPassAlignment
bool UsualArrayDeleteWantsSize
ArrayRef<clang::Expr*> PlacementArgs
clang::SourceRange TypeIdParens
Optional<clang::Expr*> ArraySize
clang::CXXNewExpr::InitializationStyle InitializationStyle
clang::Expr* Initializer
clang::QualType Ty
clang::TypeSourceInfo* AllocatedTypeInfo
clang::SourceRange Range
clang::SourceRange DirectInitRange

static clang::CXXNewExpr* CreateEmpty(
    const clang::ASTContext& Ctx,
    bool IsArray,
    bool HasInit,
    unsigned int NumPlacementArgs,
    bool IsParenTypeId)

Description

Create an empty c++ new expression.

Declared at: clang/include/clang/AST/ExprCXX.h:2228

Parameters

const clang::ASTContext& Ctx
bool IsArray
bool HasInit
unsigned int NumPlacementArgs
bool IsParenTypeId

unsigned int arraySizeOffset() const

Declared at: clang/include/clang/AST/ExprCXX.h:2176

clang::Stmt::child_range children()

Declared at: clang/include/clang/AST/ExprCXX.h:2406

clang::Stmt::const_child_range children() const

Declared at: clang/include/clang/AST/ExprCXX.h:2408

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

Declared at: clang/include/clang/AST/ExprCXX.h:2401

Parameters

const clang::Stmt* T

bool doesUsualArrayDeleteWantSize() const

Description

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

Declared at: clang/include/clang/AST/ExprCXX.h:2354

clang::QualType getAllocatedType() const

Declared at: clang/include/clang/AST/ExprCXX.h:2232

clang::TypeSourceInfo*
getAllocatedTypeSourceInfo() const

Declared at: clang/include/clang/AST/ExprCXX.h:2236

Optional<const clang::Expr*> getArraySize() const

Description

This might return None even if isArray() returns true, since there might not be an array size expression. If the result is not-None, it will never wrap a nullptr.

Declared at: clang/include/clang/AST/ExprCXX.h:2281

Optional<clang::Expr*> getArraySize()

Description

This might return None even if isArray() returns true, since there might not be an array size expression. If the result is not-None, it will never wrap a nullptr.

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

clang::SourceLocation getBeginLoc() const

Declared at: clang/include/clang/AST/ExprCXX.h:2395

const clang::CXXConstructExpr* getConstructExpr()
    const

Description

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

Declared at: clang/include/clang/AST/ExprCXX.h:2343

clang::SourceRange getDirectInitRange() const

Declared at: clang/include/clang/AST/ExprCXX.h:2398

clang::SourceLocation getEndLoc() const

Declared at: clang/include/clang/AST/ExprCXX.h:2396

clang::CXXNewExpr::InitializationStyle
getInitializationStyle() const

Description

The kind of initializer this new-expression has.

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

clang::Expr* getInitializer()

Description

The initializer of this new-expression.

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

const clang::Expr* getInitializer() const

Declared at: clang/include/clang/AST/ExprCXX.h:2336

unsigned int getNumPlacementArgs() const

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

clang::FunctionDecl* getOperatorDelete() const

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

clang::FunctionDecl* getOperatorNew() const

Declared at: clang/include/clang/AST/ExprCXX.h:2257

clang::Expr* getPlacementArg(unsigned int I)

Declared at: clang/include/clang/AST/ExprCXX.h:2301

Parameters

unsigned int I

const clang::Expr* getPlacementArg(
    unsigned int I) const

Declared at: clang/include/clang/AST/ExprCXX.h:2305

Parameters

unsigned int I

clang::Expr** getPlacementArgs()

Declared at: clang/include/clang/AST/ExprCXX.h:2296

clang::SourceRange getSourceRange() const

Declared at: clang/include/clang/AST/ExprCXX.h:2399

clang::SourceRange getTypeIdParens() const

Declared at: clang/include/clang/AST/ExprCXX.h:2310

bool hasInitializer() const

Description

Whether this new-expression has any initializer at all.

Declared at: clang/include/clang/AST/ExprCXX.h:2318

unsigned int initExprOffset() const

Declared at: clang/include/clang/AST/ExprCXX.h:2177

bool isArray() const

Declared at: clang/include/clang/AST/ExprCXX.h:2262

bool isGlobalNew() const

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

bool isParenTypeId() const

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

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

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

Parameters

OverloadToken<clang::Stmt*>

unsigned int numTrailingObjects(
    OverloadToken<clang::SourceRange>) const

Declared at: clang/include/clang/AST/ExprCXX.h:2186

Parameters

OverloadToken<clang::SourceRange>

bool passAlignment() const

Description

Indicates whether the required alignment should be implicitly passed to the allocation function.

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

unsigned int placementNewArgsOffset() const

Declared at: clang/include/clang/AST/ExprCXX.h:2178

clang::CXXNewExpr::const_arg_iterator
placement_arg_begin() const

Declared at: clang/include/clang/AST/ExprCXX.h:2375

clang::CXXNewExpr::arg_iterator
placement_arg_begin()

Declared at: clang/include/clang/AST/ExprCXX.h:2369

clang::CXXNewExpr::const_arg_iterator
placement_arg_end() const

Declared at: clang/include/clang/AST/ExprCXX.h:2378

clang::CXXNewExpr::arg_iterator
placement_arg_end()

Declared at: clang/include/clang/AST/ExprCXX.h:2372

llvm::iterator_range<const_arg_iterator>
placement_arguments() const

Declared at: clang/include/clang/AST/ExprCXX.h:2365

llvm::iterator_range<arg_iterator>
placement_arguments()

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

clang::CXXNewExpr::raw_arg_iterator
raw_arg_begin()

Declared at: clang/include/clang/AST/ExprCXX.h:2384

clang::CXXNewExpr::const_arg_iterator
raw_arg_begin() const

Declared at: clang/include/clang/AST/ExprCXX.h:2388

clang::CXXNewExpr::raw_arg_iterator raw_arg_end()

Declared at: clang/include/clang/AST/ExprCXX.h:2385

clang::CXXNewExpr::const_arg_iterator
raw_arg_end() const

Declared at: clang/include/clang/AST/ExprCXX.h:2391

void setOperatorDelete(clang::FunctionDecl* D)

Declared at: clang/include/clang/AST/ExprCXX.h:2260

Parameters

clang::FunctionDecl* D

void setOperatorNew(clang::FunctionDecl* D)

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

Parameters

clang::FunctionDecl* D

bool shouldNullCheckAllocation() const

Description

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. C++ DR1748: If the allocation function is a reserved placement allocation function that returns null, the behavior is undefined. 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()?".

Declared at: clang/include/clang/AST/ExprCXX.h:2255