clang 8.0.0

Public Member Functions | List of all members
clang::CXXCtorInitializer Class Referencefinal

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

`#include "clang/AST/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. More...
| CXXCtorInitializer (ASTContext &Context, FieldDecl *Member, SourceLocation MemberLoc, SourceLocation L, Expr *Init, SourceLocation R)
| Creates a new member initializer. More...
| CXXCtorInitializer (ASTContext &Context, IndirectFieldDecl *Member, SourceLocation MemberLoc, SourceLocation L, Expr *Init, SourceLocation R)
| Creates a new anonymous field initializer. More...
| CXXCtorInitializer (ASTContext &Context, TypeSourceInfo *TInfo, SourceLocation L, Expr *Init, SourceLocation R)
| Creates a new delegating initializer. More...
int64_t | getID (const ASTContext &Context) const
bool | isBaseInitializer () const
| Determine whether this initializer is initializing a base class. More...
bool | isMemberInitializer () const
| Determine whether this initializer is initializing a non-static data member. More...
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. More...
bool | isDelegatingInitializer () const
| Determine whether this initializer is creating a delegating constructor. More...
bool | isPackExpansion () const
| Determine whether this initializer is a pack expansion. More...
SourceLocation | getEllipsisLoc () const
TypeLoc | getBaseClassLoc () const
| If this is a base class initializer, returns the type of the base class with location information. More...
const Type * | getBaseClass () const
| If this is a base class initializer, returns the type of the base class. More...
bool | isBaseVirtual () const
| Returns whether the base is virtual or not. More...
TypeSourceInfo * | getTypeSourceInfo () const
| Returns the declarator information for a base class or delegating initializer. More...
FieldDecl * | getMember () const
| If this is a member initializer, returns the declaration of the non-static data member being initialized. More...
FieldDecl * | getAnyMember () const
IndirectFieldDecl * | getIndirectMember () const
SourceLocation | getMemberLocation () const
SourceLocation | getSourceLocation () const
| Determine the source location of the initializer. More...
SourceRange | getSourceRange () const LLVM_READONLY
| Determine the source range covering the entire initializer. More...
bool | isWritten () const
| Determine whether this initializer is explicitly written in the source code. More...
int | getSourceOrder () const
| Return the source position of the initializer, counting from 0. More...
void | setSourceOrder (int Pos)
| Set the source order of this initializer. More...
SourceLocation | getLParenLoc () const
SourceLocation | getRParenLoc () const
Expr * | getInit () const
| Get the initializer. More...

## 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 2256 of file DeclCXX.h.

## Constructor & Destructor Documentation

## ◆ CXXCtorInitializer() [1/4]

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 2220 of file DeclCXX.cpp.

## ◆ CXXCtorInitializer() [2/4]

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

Creates a new member initializer.

Definition at line 2229 of file DeclCXX.cpp.

## ◆ CXXCtorInitializer() [3/4]

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

Creates a new anonymous field initializer.

Definition at line 2238 of file DeclCXX.cpp.

## ◆ CXXCtorInitializer() [4/4]

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

Creates a new delegating initializer.

Definition at line 2247 of file DeclCXX.cpp.

## Member Function Documentation

## ◆ getAnyMember()

FieldDecl* clang::CXXCtorInitializer::getAnyMember | ( |  | ) | const
| inline

Definition at line 2398 of file DeclCXX.h.

References clang::IndirectFieldDecl::getAnonField().

Referenced by DiagnoseBaseOrMemInitializerOrder(), clang::CodeGen::CodeGenFunction::EmitConstructorBody(), EmitLValueForAnyFieldInitialization(), EmitMemberInitializer(), clang::diff::getInitializerValue(), getSourceLocation(), getSourceRange(), print_initializer(), and clang::TextNodeDumper::Visit().

## ◆ getBaseClass()

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 2266 of file DeclCXX.cpp.

References isBaseInitializer().

Referenced by DiagnoseBaseOrMemInitializerOrder(), EmitBaseInitializer(), clang::diff::getInitializerValue(), isInitializerOfDynamicClass(), print_initializer(), and clang::TextNodeDumper::Visit().

## ◆ getBaseClassLoc()

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 2259 of file DeclCXX.cpp.

References isBaseInitializer().

## ◆ getEllipsisLoc()

SourceLocation clang::CXXCtorInitializer::getEllipsisLoc | ( |  | ) | const
| inline

Definition at line 2363 of file DeclCXX.h.

Referenced by clang::ASTImporter::Import().

## ◆ getID()

int64_t CXXCtorInitializer::getID | ( | const ASTContext & | Context | ) | const

Returns
  Unique reproducible object identifier.

Definition at line 2254 of file DeclCXX.cpp.

## ◆ getIndirectMember()

IndirectFieldDecl* clang::CXXCtorInitializer::getIndirectMember | ( |  | ) | const
| inline

Definition at line 2406 of file DeclCXX.h.

Referenced by EmitLValueForAnyFieldInitialization(), clang::ASTImporter::Import(), and clang::ento::ExprEngine::ProcessInitializer().

## ◆ getInit()

Expr* clang::CXXCtorInitializer::getInit | ( |  | ) | const
| inline

Get the initializer.

Definition at line 2454 of file DeclCXX.h.

Referenced by AllTrivialInitializers(), EmitBaseInitializer(), clang::CodeGen::CodeGenFunction::EmitConstructorBody(), clang::CodeGen::CodeGenFunction::EmitDelegatingCXXConstructorCall(), EmitMemberInitializer(), getLocationForCaller(), clang::CXXConstructorDecl::getTargetConstructor(), clang::ASTImporter::Import(), print_initializer(), clang::ento::ExprEngine::ProcessInitializer(), and clang::RecursiveASTVisitor< CallGraph >::TraverseConstructorInitializer().

## ◆ getLParenLoc()

SourceLocation clang::CXXCtorInitializer::getLParenLoc | ( |  | ) | const
| inline

Definition at line 2450 of file DeclCXX.h.

Referenced by clang::ASTImporter::Import().

## ◆ getMember()

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 2392 of file DeclCXX.h.

Referenced by clang::CodeGen::CodeGenFunction::EmitConstructorBody(), clang::ASTImporter::Import(), and clang::ento::ExprEngine::ProcessInitializer().

## ◆ getMemberLocation()

SourceLocation clang::CXXCtorInitializer::getMemberLocation | ( |  | ) | const
| inline

Definition at line 2412 of file DeclCXX.h.

References clang::tooling::fixit::internal::getSourceRange().

Referenced by getSourceLocation(), and clang::ASTImporter::Import().

## ◆ getRParenLoc()

SourceLocation clang::CXXCtorInitializer::getRParenLoc | ( |  | ) | const
| inline

Definition at line 2451 of file DeclCXX.h.

Referenced by getSourceRange(), and clang::ASTImporter::Import().

## ◆ getSourceLocation()

SourceLocation CXXCtorInitializer::getSourceLocation | ( |  | ) | const

Determine the source location of the initializer.

Definition at line 2273 of file DeclCXX.cpp.

References getAnyMember(), clang::Decl::getLocation(), getMemberLocation(), isAnyMemberInitializer(), and isInClassMemberInitializer().

Referenced by DiagnoseBaseOrMemInitializerOrder(), EmitMemberInitializer(), getSourceRange(), and clang::ento::ExprEngine::ProcessInitializer().

## ◆ getSourceOrder()

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 2428 of file DeclCXX.h.

## ◆ getSourceRange()

SourceRange CXXCtorInitializer::getSourceRange | ( |  | ) | const

Determine the source range covering the entire initializer.

Definition at line 2286 of file DeclCXX.cpp.

References getAnyMember(), clang::FieldDecl::getInClassInitializer(), getRParenLoc(), getSourceLocation(), isInClassMemberInitializer(), and clang::SC_None.

Referenced by DiagnoseBaseOrMemInitializerOrder().

## ◆ getTypeSourceInfo()

TypeSourceInfo* clang::CXXCtorInitializer::getTypeSourceInfo | ( |  | ) | const
| inline

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

Definition at line 2386 of file DeclCXX.h.

Referenced by DiagnoseBaseOrMemInitializerOrder(), clang::diff::getInitializerValue(), clang::ASTImporter::Import(), print_initializer(), clang::RecursiveASTVisitor< CallGraph >::TraverseConstructorInitializer(), and clang::TextNodeDumper::Visit().

## ◆ isAnyMemberInitializer()

bool clang::CXXCtorInitializer::isAnyMemberInitializer | ( |  | ) | const
| inline

Definition at line 2333 of file DeclCXX.h.

Referenced by clang::Sema::ActOnMemInitializers(), DiagnoseBaseOrMemInitializerOrder(), EmitMemberInitializer(), clang::diff::getInitializerValue(), getSourceLocation(), clang::ento::ExprEngine::ProcessInitializer(), and clang::TextNodeDumper::Visit().

## ◆ isBaseInitializer()

bool clang::CXXCtorInitializer::isBaseInitializer | ( |  | ) | const
| inline

Determine whether this initializer is initializing a base class.

Definition at line 2325 of file DeclCXX.h.

Referenced by EmitBaseInitializer(), getBaseClass(), getBaseClassLoc(), clang::diff::getInitializerValue(), clang::ASTImporter::Import(), print_initializer(), clang::ento::ExprEngine::ProcessInitializer(), and clang::TextNodeDumper::Visit().

## ◆ isBaseVirtual()

bool clang::CXXCtorInitializer::isBaseVirtual | ( |  | ) | const
| inline

Returns whether the base is virtual or not.

Definition at line 2378 of file DeclCXX.h.

Referenced by EmitBaseInitializer(), and clang::ASTImporter::Import().

## ◆ isDelegatingInitializer()

bool clang::CXXCtorInitializer::isDelegatingInitializer | ( |  | ) | const
| inline

Determine whether this initializer is creating a delegating constructor.

Definition at line 2353 of file DeclCXX.h.

Referenced by clang::diff::getInitializerValue(), clang::ASTImporter::Import(), print_initializer(), clang::ento::ExprEngine::ProcessInitializer(), clang::Sema::SetDelegatingInitializer(), and clang::TextNodeDumper::Visit().

## ◆ isInClassMemberInitializer()

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 2347 of file DeclCXX.h.

References clang::Stmt::getStmtClass().

Referenced by getSourceLocation(), and getSourceRange().

## ◆ isIndirectMemberInitializer()

bool clang::CXXCtorInitializer::isIndirectMemberInitializer | ( |  | ) | const
| inline

Definition at line 2337 of file DeclCXX.h.

Referenced by EmitLValueForAnyFieldInitialization(), clang::ASTImporter::Import(), and clang::ento::ExprEngine::ProcessInitializer().

## ◆ isMemberInitializer()

bool clang::CXXCtorInitializer::isMemberInitializer | ( |  | ) | const
| inline

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

Definition at line 2331 of file DeclCXX.h.

Referenced by clang::ASTImporter::Import().

## ◆ isPackExpansion()

bool clang::CXXCtorInitializer::isPackExpansion | ( |  | ) | const
| inline

Determine whether this initializer is a pack expansion.

Definition at line 2358 of file DeclCXX.h.

References clang::SourceLocation::isValid().

Referenced by clang::ASTImporter::Import().

## ◆ isWritten()

bool clang::CXXCtorInitializer::isWritten | ( |  | ) | const
| inline

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

Definition at line 2424 of file DeclCXX.h.

Referenced by clang::diff::isSpecializedNodeExcluded(), and clang::RecursiveASTVisitor< CallGraph >::TraverseConstructorInitializer().

## ◆ setSourceOrder()

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 initializer was written in the source code, and ensures that isWritten() returns true.

Definition at line 2439 of file DeclCXX.h.

Referenced by clang::Sema::ActOnMemInitializers().

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

- include/clang/AST/DeclCXX.h
- lib/AST/DeclCXX.cpp