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
- public CXXCtorInitializer(clang::ASTContext & Context, clang::FieldDecl * Member, clang::SourceLocation MemberLoc, clang::SourceLocation L, clang::Expr * Init, clang::SourceLocation R)
- public CXXCtorInitializer(clang::ASTContext & Context, clang::IndirectFieldDecl * Member, clang::SourceLocation MemberLoc, clang::SourceLocation L, clang::Expr * Init, clang::SourceLocation R)
- public CXXCtorInitializer(clang::ASTContext & Context, clang::TypeSourceInfo * TInfo, clang::SourceLocation L, clang::Expr * Init, clang::SourceLocation R)
- public CXXCtorInitializer(clang::ASTContext & Context, clang::TypeSourceInfo * TInfo, bool IsVirtual, clang::SourceLocation L, clang::Expr * Init, clang::SourceLocation R, clang::SourceLocation EllipsisLoc)
- public clang::FieldDecl * getAnyMember() const
- public const clang::Type * getBaseClass() const
- public clang::TypeLoc getBaseClassLoc() const
- public clang::SourceLocation getEllipsisLoc() const
- public int64_t getID(const clang::ASTContext & Context) const
- public clang::IndirectFieldDecl * getIndirectMember() const
- public clang::Expr * getInit() const
- public clang::SourceLocation getLParenLoc() const
- public clang::FieldDecl * getMember() const
- public clang::SourceLocation getMemberLocation() const
- public clang::SourceLocation getRParenLoc() const
- public clang::SourceLocation getSourceLocation() const
- public int getSourceOrder() const
- public clang::SourceRange getSourceRange() const
- public clang::TypeSourceInfo * getTypeSourceInfo() const
- public bool isAnyMemberInitializer() const
- public bool isBaseInitializer() const
- public bool isBaseVirtual() const
- public bool isDelegatingInitializer() const
- public bool isInClassMemberInitializer() const
- public bool isIndirectMemberInitializer() const
- public bool isMemberInitializer() const
- public bool isPackExpansion() const
- public bool isWritten() const
- public void setSourceOrder(int Pos)
Methods
¶CXXCtorInitializer(
clang::ASTContext& Context,
clang::FieldDecl* Member,
clang::SourceLocation MemberLoc,
clang::SourceLocation L,
clang::Expr* Init,
clang::SourceLocation R)
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)
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)
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)
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
clang::FieldDecl* getAnyMember() const
Declared at: clang/include/clang/AST/DeclCXX.h:2348
¶const clang::Type* getBaseClass() const
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
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
clang::SourceLocation getEllipsisLoc() const
Declared at: clang/include/clang/AST/DeclCXX.h:2312
¶int64_t getID(
const clang::ASTContext& Context) const
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
clang::IndirectFieldDecl* getIndirectMember()
const
Declared at: clang/include/clang/AST/DeclCXX.h:2356
¶clang::Expr* getInit() const
clang::Expr* getInit() const
Description
Get the initializer.
Declared at: clang/include/clang/AST/DeclCXX.h:2404
¶clang::SourceLocation getLParenLoc() const
clang::SourceLocation getLParenLoc() const
Declared at: clang/include/clang/AST/DeclCXX.h:2400
¶clang::FieldDecl* getMember() const
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
clang::SourceLocation getMemberLocation() const
Declared at: clang/include/clang/AST/DeclCXX.h:2362
¶clang::SourceLocation getRParenLoc() const
clang::SourceLocation getRParenLoc() const
Declared at: clang/include/clang/AST/DeclCXX.h:2401
¶clang::SourceLocation getSourceLocation() const
clang::SourceLocation getSourceLocation() const
Description
Determine the source location of the initializer.
Declared at: clang/include/clang/AST/DeclCXX.h:2367
¶int getSourceOrder() const
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
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
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
bool isAnyMemberInitializer() const
Declared at: clang/include/clang/AST/DeclCXX.h:2282
¶bool isBaseInitializer() const
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
bool isBaseVirtual() const
Description
Returns whether the base is virtual or not.
Declared at: clang/include/clang/AST/DeclCXX.h:2328
¶bool isDelegatingInitializer() const
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
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
bool isIndirectMemberInitializer() const
Declared at: clang/include/clang/AST/DeclCXX.h:2286
¶bool isMemberInitializer() const
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
bool isPackExpansion() const
Description
Determine whether this initializer is a pack expansion.
Declared at: clang/include/clang/AST/DeclCXX.h:2307
¶bool isWritten() const
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)
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