clang API Documentation
Represents a C++ base or member initializer. More...
#include <DeclCXX.h>
Public Member Functions | |
CXXCtorInitializer (ASTContext &Context, TypeSourceInfo *TInfo, bool IsVirtual, SourceLocation L, Expr *Init, SourceLocation R, SourceLocation EllipsisLoc) | |
Creates a new base-class initializer. | |
CXXCtorInitializer (ASTContext &Context, FieldDecl *Member, SourceLocation MemberLoc, SourceLocation L, Expr *Init, SourceLocation R) | |
Creates a new member initializer. | |
CXXCtorInitializer (ASTContext &Context, IndirectFieldDecl *Member, SourceLocation MemberLoc, SourceLocation L, Expr *Init, SourceLocation R) | |
Creates a new anonymous field initializer. | |
CXXCtorInitializer (ASTContext &Context, TypeSourceInfo *TInfo, SourceLocation L, Expr *Init, SourceLocation R) | |
Creates a new delegating initializer. | |
bool | isBaseInitializer () const |
Determine whether this initializer is initializing a base class. | |
bool | isMemberInitializer () const |
Determine whether this initializer is initializing a non-static data member. | |
bool | isAnyMemberInitializer () const |
bool | isIndirectMemberInitializer () const |
bool | isInClassMemberInitializer () const |
Determine whether this initializer is an implicit initializer generated for a field with an initializer defined on the member declaration. | |
bool | isDelegatingInitializer () const |
Determine whether this initializer is creating a delegating constructor. | |
bool | isPackExpansion () const |
Determine whether this initializer is a pack expansion. | |
SourceLocation | getEllipsisLoc () const |
TypeLoc | getBaseClassLoc () const |
const Type * | getBaseClass () const |
bool | isBaseVirtual () const |
Returns whether the base is virtual or not. | |
TypeSourceInfo * | getTypeSourceInfo () const |
Returns the declarator information for a base class or delegating initializer. | |
FieldDecl * | getMember () const |
If this is a member initializer, returns the declaration of the non-static data member being initialized. Otherwise, returns null. | |
FieldDecl * | getAnyMember () const |
IndirectFieldDecl * | getIndirectMember () const |
SourceLocation | getMemberLocation () const |
SourceLocation | getSourceLocation () const |
Determine the source location of the initializer. | |
SourceRange | getSourceRange () const LLVM_READONLY |
Determine the source range covering the entire initializer. | |
bool | isWritten () const |
Determine whether this initializer is explicitly written in the source code. | |
int | getSourceOrder () const |
Return the source position of the initializer, counting from 0. If the initializer was implicit, -1 is returned. | |
void | setSourceOrder (int pos) |
Set the source order of this initializer. | |
SourceLocation | getLParenLoc () const |
SourceLocation | getRParenLoc () const |
unsigned | getNumArrayIndices () const |
Determine the number of implicit array indices used while described an array member initialization. | |
VarDecl * | getArrayIndex (unsigned I) |
Retrieve a particular array index variable used to describe an array member initialization. | |
const VarDecl * | getArrayIndex (unsigned I) const |
void | setArrayIndex (unsigned I, VarDecl *Index) |
ArrayRef< VarDecl * > | getArrayIndexes () |
Expr * | getInit () const |
Get the initializer. | |
Static Public Member Functions | |
static CXXCtorInitializer * | Create (ASTContext &Context, FieldDecl *Member, SourceLocation MemberLoc, SourceLocation L, Expr *Init, SourceLocation R, VarDecl **Indices, unsigned NumIndices) |
Creates a new member initializer that optionally contains array indices used to describe an elementwise initialization. |
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:
class A { }; class B : public A { float f; public: B(A& a) : A(a), f(3.14159) { } };
CXXCtorInitializer::CXXCtorInitializer | ( | ASTContext & | Context, |
TypeSourceInfo * | TInfo, | ||
bool | IsVirtual, | ||
SourceLocation | L, | ||
Expr * | Init, | ||
SourceLocation | R, | ||
SourceLocation | EllipsisLoc | ||
) | [explicit] |
Creates a new base-class initializer.
Definition at line 1609 of file DeclCXX.cpp.
CXXCtorInitializer::CXXCtorInitializer | ( | ASTContext & | Context, |
FieldDecl * | Member, | ||
SourceLocation | MemberLoc, | ||
SourceLocation | L, | ||
Expr * | Init, | ||
SourceLocation | R | ||
) | [explicit] |
Creates a new member initializer.
Definition at line 1620 of file DeclCXX.cpp.
CXXCtorInitializer::CXXCtorInitializer | ( | ASTContext & | Context, |
IndirectFieldDecl * | Member, | ||
SourceLocation | MemberLoc, | ||
SourceLocation | L, | ||
Expr * | Init, | ||
SourceLocation | R | ||
) | [explicit] |
Creates a new anonymous field initializer.
Definition at line 1631 of file DeclCXX.cpp.
CXXCtorInitializer::CXXCtorInitializer | ( | ASTContext & | Context, |
TypeSourceInfo * | TInfo, | ||
SourceLocation | L, | ||
Expr * | Init, | ||
SourceLocation | R | ||
) | [explicit] |
Creates a new delegating initializer.
Definition at line 1642 of file DeclCXX.cpp.
CXXCtorInitializer * CXXCtorInitializer::Create | ( | ASTContext & | Context, |
FieldDecl * | Member, | ||
SourceLocation | MemberLoc, | ||
SourceLocation | L, | ||
Expr * | Init, | ||
SourceLocation | R, | ||
VarDecl ** | Indices, | ||
unsigned | NumIndices | ||
) | [static] |
Creates a new member initializer that optionally contains array indices used to describe an elementwise initialization.
Definition at line 1667 of file DeclCXX.cpp.
References clang::ASTContext::Allocate().
Referenced by BuildImplicitMemberInitializer(), and clang::ASTReader::ReadCXXCtorInitializers().
FieldDecl* clang::CXXCtorInitializer::getAnyMember | ( | ) | const [inline] |
Definition at line 2045 of file DeclCXX.h.
References clang::IndirectFieldDecl::getAnonField(), isIndirectMemberInitializer(), and isMemberInitializer().
Referenced by DiagnoseBaseOrMemInitializerOrder(), EmitMemberInitializer(), GetKeyForMember(), llvm::DOTGraphTraits< ExplodedNode * >::getNodeLabel(), getSourceLocation(), getSourceRange(), print_elem(), and clang::Sema::SetCtorInitializers().
VarDecl* clang::CXXCtorInitializer::getArrayIndex | ( | unsigned | I | ) | [inline] |
Retrieve a particular array index variable used to describe an array member initialization.
Definition at line 2108 of file DeclCXX.h.
References getNumArrayIndices().
Referenced by clang::ASTWriter::AddCXXCtorInitializers().
const VarDecl* clang::CXXCtorInitializer::getArrayIndex | ( | unsigned | I | ) | const [inline] |
Definition at line 2112 of file DeclCXX.h.
References getNumArrayIndices().
ArrayRef<VarDecl *> clang::CXXCtorInitializer::getArrayIndexes | ( | ) | [inline] |
Definition at line 2120 of file DeclCXX.h.
References getNumArrayIndices().
Referenced by EmitMemberInitializer().
const Type * CXXCtorInitializer::getBaseClass | ( | ) | const |
If this is a base class initializer, returns the type of the base class. Otherwise, returns null.
Definition at line 1688 of file DeclCXX.cpp.
References isBaseInitializer().
Referenced by EmitBaseInitializer(), GetKeyForMember(), print_elem(), and clang::Sema::SetCtorInitializers().
TypeLoc CXXCtorInitializer::getBaseClassLoc | ( | ) | const |
If this is a base class initializer, returns the type of the base class with location information. Otherwise, returns an NULL type location.
Definition at line 1681 of file DeclCXX.cpp.
References isBaseInitializer().
SourceLocation clang::CXXCtorInitializer::getEllipsisLoc | ( | ) | const [inline] |
Definition at line 2011 of file DeclCXX.h.
References isPackExpansion().
IndirectFieldDecl* clang::CXXCtorInitializer::getIndirectMember | ( | ) | const [inline] |
Definition at line 2053 of file DeclCXX.h.
References isIndirectMemberInitializer().
Referenced by clang::ASTWriter::AddCXXCtorInitializers(), EmitMemberInitializer(), getRegionForConstructedObject(), clang::ento::ExprEngine::ProcessInitializer(), and clang::Sema::SetCtorInitializers().
Expr* clang::CXXCtorInitializer::getInit | ( | ) | const [inline] |
Get the initializer.
Definition at line 2127 of file DeclCXX.h.
Referenced by clang::ASTWriter::AddCXXCtorInitializers(), AllTrivialInitializers(), EmitBaseInitializer(), clang::CodeGen::CodeGenFunction::EmitDelegatingCXXConstructorCall(), EmitMemberInitializer(), getLocationForCaller(), print_elem(), clang::ento::ExprEngine::ProcessInitializer(), and clang::RecursiveASTVisitor< Derived >::TraverseConstructorInitializer().
SourceLocation clang::CXXCtorInitializer::getLParenLoc | ( | ) | const [inline] |
Definition at line 2097 of file DeclCXX.h.
Referenced by clang::ASTWriter::AddCXXCtorInitializers().
FieldDecl* clang::CXXCtorInitializer::getMember | ( | ) | const [inline] |
If this is a member initializer, returns the declaration of the non-static data member being initialized. Otherwise, returns null.
Definition at line 2040 of file DeclCXX.h.
References isMemberInitializer().
Referenced by clang::ASTWriter::AddCXXCtorInitializers(), getRegionForConstructedObject(), clang::ento::ExprEngine::ProcessInitializer(), and clang::Sema::SetCtorInitializers().
SourceLocation clang::CXXCtorInitializer::getMemberLocation | ( | ) | const [inline] |
Definition at line 2059 of file DeclCXX.h.
Referenced by clang::ASTWriter::AddCXXCtorInitializers(), and getSourceLocation().
unsigned clang::CXXCtorInitializer::getNumArrayIndices | ( | ) | const [inline] |
Determine the number of implicit array indices used while described an array member initialization.
Definition at line 2102 of file DeclCXX.h.
Referenced by clang::ASTWriter::AddCXXCtorInitializers(), EmitMemberInitializer(), getArrayIndex(), getArrayIndexes(), clang::ento::ExprEngine::ProcessInitializer(), and setArrayIndex().
SourceLocation clang::CXXCtorInitializer::getRParenLoc | ( | ) | const [inline] |
Definition at line 2098 of file DeclCXX.h.
Referenced by clang::ASTWriter::AddCXXCtorInitializers(), and getSourceRange().
Determine the source location of the initializer.
Definition at line 1695 of file DeclCXX.cpp.
References getAnyMember(), clang::Decl::getLocation(), getMemberLocation(), isAnyMemberInitializer(), and isInClassMemberInitializer().
Referenced by clang::Sema::ActOnMemInitializers(), DiagnoseBaseOrMemInitializerOrder(), getSourceRange(), clang::ento::ExprEngine::ProcessInitializer(), and clang::Sema::SetDelegatingInitializer().
int clang::CXXCtorInitializer::getSourceOrder | ( | ) | const [inline] |
Return the source position of the initializer, counting from 0. If the initializer was implicit, -1 is returned.
Definition at line 2075 of file DeclCXX.h.
Referenced by clang::ASTWriter::AddCXXCtorInitializers().
Determine the source range covering the entire initializer.
Definition at line 1708 of file DeclCXX.cpp.
References getAnyMember(), clang::FieldDecl::getInClassInitializer(), getRParenLoc(), getSourceLocation(), and isInClassMemberInitializer().
Referenced by clang::Sema::ActOnMemInitializers().
TypeSourceInfo* clang::CXXCtorInitializer::getTypeSourceInfo | ( | ) | const [inline] |
Returns the declarator information for a base class or delegating initializer.
Definition at line 2034 of file DeclCXX.h.
Referenced by clang::ASTWriter::AddCXXCtorInitializers(), DiagnoseBaseOrMemInitializerOrder(), llvm::DOTGraphTraits< ExplodedNode * >::getNodeLabel(), print_elem(), and clang::RecursiveASTVisitor< Derived >::TraverseConstructorInitializer().
bool clang::CXXCtorInitializer::isAnyMemberInitializer | ( | ) | const [inline] |
Definition at line 1981 of file DeclCXX.h.
References isIndirectMemberInitializer(), and isMemberInitializer().
Referenced by clang::Sema::ActOnMemInitializers(), DiagnoseBaseOrMemInitializerOrder(), clang::CodeGen::CodeGenFunction::EmitCtorPrologue(), EmitMemberInitializer(), GetKeyForMember(), getRegionForConstructedObject(), getSourceLocation(), and clang::ento::ExprEngine::ProcessInitializer().
bool clang::CXXCtorInitializer::isBaseInitializer | ( | ) | const [inline] |
Determine whether this initializer is initializing a base class.
Definition at line 1973 of file DeclCXX.h.
Referenced by clang::Sema::ActOnMemInitializers(), clang::ASTWriter::AddCXXCtorInitializers(), EmitBaseInitializer(), clang::CodeGen::CodeGenFunction::EmitCtorPrologue(), getBaseClass(), getBaseClassLoc(), isBaseVirtual(), isPackExpansion(), print_elem(), clang::ento::ExprEngine::ProcessInitializer(), and clang::Sema::SetCtorInitializers().
bool clang::CXXCtorInitializer::isBaseVirtual | ( | ) | const [inline] |
Returns whether the base is virtual or not.
Definition at line 2026 of file DeclCXX.h.
References isBaseInitializer().
Referenced by clang::ASTWriter::AddCXXCtorInitializers(), and EmitBaseInitializer().
bool clang::CXXCtorInitializer::isDelegatingInitializer | ( | ) | const [inline] |
Determine whether this initializer is creating a delegating constructor.
Definition at line 2001 of file DeclCXX.h.
Referenced by clang::Sema::ActOnMemInitializers(), clang::ASTWriter::AddCXXCtorInitializers(), clang::CXXConstructorDecl::isDelegatingConstructor(), print_elem(), clang::ento::ExprEngine::ProcessInitializer(), and clang::Sema::SetDelegatingInitializer().
bool clang::CXXCtorInitializer::isInClassMemberInitializer | ( | ) | const [inline] |
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.
Definition at line 1995 of file DeclCXX.h.
References clang::Stmt::getStmtClass().
Referenced by getSourceLocation(), and getSourceRange().
bool clang::CXXCtorInitializer::isIndirectMemberInitializer | ( | ) | const [inline] |
Definition at line 1985 of file DeclCXX.h.
Referenced by EmitMemberInitializer(), getAnyMember(), getIndirectMember(), getRegionForConstructedObject(), isAnyMemberInitializer(), and clang::ento::ExprEngine::ProcessInitializer().
bool clang::CXXCtorInitializer::isMemberInitializer | ( | ) | const [inline] |
Determine whether this initializer is initializing a non-static data member.
Definition at line 1979 of file DeclCXX.h.
Referenced by clang::ASTWriter::AddCXXCtorInitializers(), getAnyMember(), getMember(), and isAnyMemberInitializer().
bool clang::CXXCtorInitializer::isPackExpansion | ( | ) | const [inline] |
Determine whether this initializer is a pack expansion.
Definition at line 2006 of file DeclCXX.h.
References isBaseInitializer(), and clang::SourceLocation::isValid().
Referenced by getEllipsisLoc().
bool clang::CXXCtorInitializer::isWritten | ( | ) | const [inline] |
Determine whether this initializer is explicitly written in the source code.
Definition at line 2071 of file DeclCXX.h.
Referenced by clang::ASTWriter::AddCXXCtorInitializers(), and clang::RecursiveASTVisitor< Derived >::TraverseConstructorInitializer().
void clang::CXXCtorInitializer::setArrayIndex | ( | unsigned | I, |
VarDecl * | Index | ||
) | [inline] |
Definition at line 2116 of file DeclCXX.h.
References getNumArrayIndices().
void clang::CXXCtorInitializer::setSourceOrder | ( | int | pos | ) | [inline] |
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 initialzier was written in the source code, and ensures that isWritten() returns true.
Definition at line 2086 of file DeclCXX.h.
Referenced by clang::Sema::ActOnMemInitializers(), and clang::ASTReader::ReadCXXCtorInitializers().