clang API Documentation

Public Member Functions | Static Public Member Functions
clang::CXXCtorInitializer Class Reference

Represents a C++ base or member initializer. More...

#include <DeclCXX.h>

List of all members.

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 TypegetBaseClass () const
bool isBaseVirtual () const
 Returns whether the base is virtual or not.
TypeSourceInfogetTypeSourceInfo () const
 Returns the declarator information for a base class or delegating initializer.
FieldDeclgetMember () const
 If this is a member initializer, returns the declaration of the non-static data member being initialized. Otherwise, returns null.
FieldDeclgetAnyMember () const
IndirectFieldDeclgetIndirectMember () 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.
VarDeclgetArrayIndex (unsigned I)
 Retrieve a particular array index variable used to describe an array member initialization.
const VarDeclgetArrayIndex (unsigned I) const
void setArrayIndex (unsigned I, VarDecl *Index)
ArrayRef< VarDecl * > getArrayIndexes ()
ExprgetInit () const
 Get the initializer.

Static Public Member Functions

static CXXCtorInitializerCreate (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.

Detailed 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:

 class A { };
 class B : public A {
   float f;
 public:
   B(A& a) : A(a), f(3.14159) { }
 };

Definition at line 1894 of file DeclCXX.h.


Constructor & Destructor Documentation

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.


Member Function Documentation

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().

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().

Definition at line 2112 of file DeclCXX.h.

References getNumArrayIndices().

Definition at line 2120 of file DeclCXX.h.

References getNumArrayIndices().

Referenced by EmitMemberInitializer().

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().

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().

Definition at line 2011 of file DeclCXX.h.

References isPackExpansion().

Definition at line 2097 of file DeclCXX.h.

Referenced by clang::ASTWriter::AddCXXCtorInitializers().

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().

Definition at line 2059 of file DeclCXX.h.

Referenced by clang::ASTWriter::AddCXXCtorInitializers(), and getSourceLocation().

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().

Definition at line 2098 of file DeclCXX.h.

Referenced by clang::ASTWriter::AddCXXCtorInitializers(), and getSourceRange().

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().

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().

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().

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().

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().

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().


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