class CXXCtorInitializer

Declaration

class CXXCtorInitializer { /* full declaration omitted */ };

Description

Represents a C++ base or member initializer. This is part of a constructor initializer that initializes one non-static member variable or one base class. For example, in the following, both 'A(a)' and 'f(3.14159)' are member initializers:

Declared at: clang/include/clang/AST/DeclCXX.h:2205

Member Variables

private llvm::PointerUnion<TypeSourceInfo*, FieldDecl*, IndirectFieldDecl*> Initializee
Either the base class name/delegating constructor type (stored as a TypeSourceInfo*), an normal field (FieldDecl), or an anonymous field (IndirectFieldDecl*) being initialized.
private clang::Stmt* Init
The argument used to initialize the base or member, which may end up constructing an object (when multiple arguments are involved).
private clang::SourceLocation MemberOrEllipsisLocation
In the case of a delegating constructor, it will still include the type's source location as the Initializee points to the CXXConstructorDecl (to allow loop detection).
private clang::SourceLocation LParenLoc
Location of the left paren of the ctor-initializer.
private clang::SourceLocation RParenLoc
Location of the right paren of the ctor-initializer.
private unsigned int IsDelegating
If the initializee is a type, whether that type makes this a delegating initialization.
private unsigned int IsVirtual
If the initializer is a base initializer, this keeps track of whether the base is virtual or not.
private unsigned int IsWritten
Whether or not the initializer is explicitly written in the sources.
private unsigned int SourceOrder
If IsWritten is true, then this number keeps track of the textual order of this initializer in the original sources, counting from 0.

Method Overview

Methods

CXXCtorInitializer(
    clang::ASTContext& Context,
    clang::FieldDecl* Member,
    clang::SourceLocation MemberLoc,
    clang::SourceLocation L,
    clang::Expr* Init,
    clang::SourceLocation R)

Description

Creates a new member initializer.

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

Parameters

clang::ASTContext& Context
clang::FieldDecl* Member
clang::SourceLocation MemberLoc
clang::SourceLocation L
clang::Expr* Init
clang::SourceLocation R

CXXCtorInitializer(
    clang::ASTContext& Context,
    clang::IndirectFieldDecl* Member,
    clang::SourceLocation MemberLoc,
    clang::SourceLocation L,
    clang::Expr* Init,
    clang::SourceLocation R)

Description

Creates a new anonymous field initializer.

Declared at: clang/include/clang/AST/DeclCXX.h:2261

Parameters

clang::ASTContext& Context
clang::IndirectFieldDecl* Member
clang::SourceLocation MemberLoc
clang::SourceLocation L
clang::Expr* Init
clang::SourceLocation R

CXXCtorInitializer(clang::ASTContext& Context,
                   clang::TypeSourceInfo* TInfo,
                   clang::SourceLocation L,
                   clang::Expr* Init,
                   clang::SourceLocation R)

Description

Creates a new delegating initializer.

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

Parameters

clang::ASTContext& Context
clang::TypeSourceInfo* TInfo
clang::SourceLocation L
clang::Expr* Init
clang::SourceLocation R

CXXCtorInitializer(
    clang::ASTContext& Context,
    clang::TypeSourceInfo* TInfo,
    bool IsVirtual,
    clang::SourceLocation L,
    clang::Expr* Init,
    clang::SourceLocation R,
    clang::SourceLocation EllipsisLoc)

Description

Creates a new base-class initializer.

Declared at: clang/include/clang/AST/DeclCXX.h:2249

Parameters

clang::ASTContext& Context
clang::TypeSourceInfo* TInfo
bool IsVirtual
clang::SourceLocation L
clang::Expr* Init
clang::SourceLocation R
clang::SourceLocation EllipsisLoc

clang::FieldDecl* getAnyMember() const

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

const clang::Type* getBaseClass() const

Description

If this is a base class initializer, returns the type of the base class. Otherwise, returns null.

Declared at: clang/include/clang/AST/DeclCXX.h:2325

clang::TypeLoc getBaseClassLoc() const

Description

If this is a base class initializer, returns the type of the base class with location information. Otherwise, returns an NULL type location.

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

clang::SourceLocation getEllipsisLoc() const

Declared at: clang/include/clang/AST/DeclCXX.h:2312

int64_t getID(
    const clang::ASTContext& Context) const

Declared at: clang/include/clang/AST/DeclCXX.h:2271

Parameters

const clang::ASTContext& Context

Returns

Unique reproducible object identifier.

clang::IndirectFieldDecl* getIndirectMember()
    const

Declared at: clang/include/clang/AST/DeclCXX.h:2356

clang::Expr* getInit() const

Description

Get the initializer.

Declared at: clang/include/clang/AST/DeclCXX.h:2404

clang::SourceLocation getLParenLoc() const

Declared at: clang/include/clang/AST/DeclCXX.h:2400

clang::FieldDecl* getMember() const

Description

If this is a member initializer, returns the declaration of the non-static data member being initialized. Otherwise, returns null.

Declared at: clang/include/clang/AST/DeclCXX.h:2342

clang::SourceLocation getMemberLocation() const

Declared at: clang/include/clang/AST/DeclCXX.h:2362

clang::SourceLocation getRParenLoc() const

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

clang::SourceLocation getSourceLocation() const

Description

Determine the source location of the initializer.

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

int getSourceOrder() const

Description

Return the source position of the initializer, counting from 0. If the initializer was implicit, -1 is returned.

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

clang::SourceRange getSourceRange() const

Description

Determine the source range covering the entire initializer.

Declared at: clang/include/clang/AST/DeclCXX.h:2370

clang::TypeSourceInfo* getTypeSourceInfo() const

Description

Returns the declarator information for a base class or delegating initializer.

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

bool isAnyMemberInitializer() const

Declared at: clang/include/clang/AST/DeclCXX.h:2282

bool isBaseInitializer() const

Description

Determine whether this initializer is initializing a base class.

Declared at: clang/include/clang/AST/DeclCXX.h:2274

bool isBaseVirtual() const

Description

Returns whether the base is virtual or not.

Declared at: clang/include/clang/AST/DeclCXX.h:2328

bool isDelegatingInitializer() const

Description

Determine whether this initializer is creating a delegating constructor.

Declared at: clang/include/clang/AST/DeclCXX.h:2302

bool isInClassMemberInitializer() const

Description

Determine whether this initializer is an implicit initializer generated for a field with an initializer defined on the member declaration. In-class member initializers (also known as "non-static data member initializations", NSDMIs) were introduced in C++11.

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

bool isIndirectMemberInitializer() const

Declared at: clang/include/clang/AST/DeclCXX.h:2286

bool isMemberInitializer() const

Description

Determine whether this initializer is initializing a non-static data member.

Declared at: clang/include/clang/AST/DeclCXX.h:2280

bool isPackExpansion() const

Description

Determine whether this initializer is a pack expansion.

Declared at: clang/include/clang/AST/DeclCXX.h:2307

bool isWritten() const

Description

Determine whether this initializer is explicitly written in the source code.

Declared at: clang/include/clang/AST/DeclCXX.h:2374

void setSourceOrder(int Pos)

Description

Set the source order of this initializer. This can only be called once for each initializer; it cannot be called on an initializer having a positive number of (implicit) array indices. This assumes that the initializer was written in the source code, and ensures that isWritten() returns true.

Declared at: clang/include/clang/AST/DeclCXX.h:2389

Parameters

int Pos