clang API Documentation
Represents a C++ constructor within a class. More...
#include <DeclCXX.h>
Public Types | |
typedef CXXCtorInitializer ** | init_iterator |
Iterates through the member/base initializer list. | |
typedef CXXCtorInitializer *const * | init_const_iterator |
Iterates through the member/base initializer list. | |
typedef llvm::iterator_range < init_iterator > | init_range |
typedef llvm::iterator_range < init_const_iterator > | init_const_range |
typedef std::reverse_iterator < init_iterator > | init_reverse_iterator |
typedef std::reverse_iterator < init_const_iterator > | init_const_reverse_iterator |
Public Member Functions | |
bool | isExplicitSpecified () const |
Determine whether this constructor declaration has the explicit keyword specified. | |
bool | isExplicit () const |
Determine whether this constructor was marked "explicit" or not. | |
init_range | inits () |
init_const_range | inits () const |
init_iterator | init_begin () |
Retrieve an iterator to the first initializer. | |
init_const_iterator | init_begin () const |
Retrieve an iterator to the first initializer. | |
init_iterator | init_end () |
Retrieve an iterator past the last initializer. | |
init_const_iterator | init_end () const |
Retrieve an iterator past the last initializer. | |
init_reverse_iterator | init_rbegin () |
init_const_reverse_iterator | init_rbegin () const |
init_reverse_iterator | init_rend () |
init_const_reverse_iterator | init_rend () const |
unsigned | getNumCtorInitializers () const |
Determine the number of arguments used to initialize the member or base. | |
void | setNumCtorInitializers (unsigned numCtorInitializers) |
void | setCtorInitializers (CXXCtorInitializer **initializers) |
bool | isDelegatingConstructor () const |
Determine whether this constructor is a delegating constructor. | |
CXXConstructorDecl * | getTargetConstructor () const |
When this constructor delegates to another, retrieve the target. | |
bool | isDefaultConstructor () const |
bool | isCopyConstructor (unsigned &TypeQuals) const |
Whether this constructor is a copy constructor (C++ [class.copy]p2, which can be used to copy the class. | |
bool | isCopyConstructor () const |
bool | isMoveConstructor (unsigned &TypeQuals) const |
Determine whether this constructor is a move constructor (C++0x [class.copy]p3), which can be used to move values of the class. | |
bool | isMoveConstructor () const |
Determine whether this constructor is a move constructor (C++0x [class.copy]p3), which can be used to move values of the class. | |
bool | isCopyOrMoveConstructor (unsigned &TypeQuals) const |
Determine whether this is a copy or move constructor. | |
bool | isCopyOrMoveConstructor () const |
Determine whether this a copy or move constructor. | |
bool | isConvertingConstructor (bool AllowExplicit) const |
bool | isSpecializationCopyingObject () const |
Determine whether this is a member template specialization that would copy the object to itself. Such constructors are never used to copy an object. | |
const CXXConstructorDecl * | getInheritedConstructor () const |
Get the constructor that this inheriting constructor is based on. | |
void | setInheritedConstructor (const CXXConstructorDecl *BaseCtor) |
Set the constructor that this inheriting constructor is based on. | |
const CXXConstructorDecl * | getCanonicalDecl () const override |
CXXConstructorDecl * | getCanonicalDecl () override |
Retrieves the "canonical" declaration of the given declaration. | |
Static Public Member Functions | |
static CXXConstructorDecl * | CreateDeserialized (ASTContext &C, unsigned ID) |
static CXXConstructorDecl * | Create (ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isExplicit, bool isInline, bool isImplicitlyDeclared, bool isConstexpr) |
static bool | classof (const Decl *D) |
static bool | classofKind (Kind K) |
Friends | |
class | ASTDeclReader |
class | ASTDeclWriter |
Represents a C++ constructor within a class.
For example:
typedef CXXCtorInitializer* const* clang::CXXConstructorDecl::init_const_iterator |
typedef llvm::iterator_range<init_const_iterator> clang::CXXConstructorDecl::init_const_range |
typedef std::reverse_iterator<init_const_iterator> clang::CXXConstructorDecl::init_const_reverse_iterator |
typedef llvm::iterator_range<init_iterator> clang::CXXConstructorDecl::init_range |
typedef std::reverse_iterator<init_iterator> clang::CXXConstructorDecl::init_reverse_iterator |
static bool clang::CXXConstructorDecl::classof | ( | const Decl * | D | ) | [inline, static] |
Reimplemented from clang::CXXMethodDecl.
Definition at line 2331 of file DeclCXX.h.
References classofKind(), and clang::Decl::getKind().
static bool clang::CXXConstructorDecl::classofKind | ( | Kind | K | ) | [inline, static] |
Reimplemented from clang::CXXMethodDecl.
Definition at line 2332 of file DeclCXX.h.
Referenced by classof().
CXXConstructorDecl * CXXConstructorDecl::Create | ( | ASTContext & | C, |
CXXRecordDecl * | RD, | ||
SourceLocation | StartLoc, | ||
const DeclarationNameInfo & | NameInfo, | ||
QualType | T, | ||
TypeSourceInfo * | TInfo, | ||
bool | isExplicit, | ||
bool | isInline, | ||
bool | isImplicitlyDeclared, | ||
bool | isConstexpr | ||
) | [static] |
Definition at line 1729 of file DeclCXX.cpp.
References AttributeLangSupport::C, clang::DeclarationName::CXXConstructorName, clang::DeclarationNameInfo::getName(), and clang::DeclarationName::getNameKind().
Referenced by CreateNewFunctionDecl(), clang::Sema::DeclareImplicitCopyConstructor(), clang::Sema::DeclareImplicitDefaultConstructor(), clang::Sema::DeclareImplicitMoveConstructor(), clang::TemplateDeclInstantiator::VisitCXXMethodDecl(), and clang::ASTNodeImporter::VisitFunctionDecl().
CXXConstructorDecl * CXXConstructorDecl::CreateDeserialized | ( | ASTContext & | C, |
unsigned | ID | ||
) | [static] |
Reimplemented from clang::CXXMethodDecl.
Definition at line 1722 of file DeclCXX.cpp.
References AttributeLangSupport::C.
const CXXConstructorDecl* clang::CXXConstructorDecl::getCanonicalDecl | ( | ) | const [inline, override, virtual] |
Reimplemented from clang::CXXMethodDecl.
Definition at line 2323 of file DeclCXX.h.
Referenced by DelegatingCycleHelper(), getCanonicalDecl(), and TryValueInitialization().
CXXConstructorDecl* clang::CXXConstructorDecl::getCanonicalDecl | ( | ) | [inline, override, virtual] |
Retrieves the "canonical" declaration of the given declaration.
Reimplemented from clang::CXXMethodDecl.
Definition at line 2326 of file DeclCXX.h.
References getCanonicalDecl().
const CXXConstructorDecl * CXXConstructorDecl::getInheritedConstructor | ( | ) | const |
Get the constructor that this inheriting constructor is based on.
Definition at line 1852 of file DeclCXX.cpp.
References clang::Decl::getASTContext(), and clang::ASTContext::overridden_methods_begin().
Referenced by BuildImplicitBaseInitializer(), clang::Sema::ComputeInheritingCtorExceptionSpec(), clang::Sema::DefineInheritingConstructor(), clang::InitializationSequence::Diagnose(), and clang::ASTDeclWriter::VisitCXXConstructorDecl().
unsigned clang::CXXConstructorDecl::getNumCtorInitializers | ( | ) | const [inline] |
Determine the number of arguments used to initialize the member or base.
Definition at line 2232 of file DeclCXX.h.
Referenced by isDelegatingConstructor().
When this constructor delegates to another, retrieve the target.
Definition at line 1743 of file DeclCXX.cpp.
References clang::Expr::IgnoreImplicit(), init_begin(), and isDelegatingConstructor().
Referenced by DelegatingCycleHelper().
init_iterator clang::CXXConstructorDecl::init_begin | ( | ) | [inline] |
Retrieve an iterator to the first initializer.
Definition at line 2199 of file DeclCXX.h.
Referenced by DelegatingCycleHelper(), clang::CodeGen::CodeGenFunction::EmitCtorPrologue(), clang::CodeGen::CodeGenFunction::EmitDelegatingCXXConstructorCall(), getTargetConstructor(), HandleConstructorCall(), init_rend(), and inits().
init_const_iterator clang::CXXConstructorDecl::init_begin | ( | ) | const [inline] |
init_iterator clang::CXXConstructorDecl::init_end | ( | ) | [inline] |
Retrieve an iterator past the last initializer.
Definition at line 2204 of file DeclCXX.h.
Referenced by clang::CodeGen::CodeGenFunction::EmitCtorPrologue(), init_rbegin(), and inits().
init_const_iterator clang::CXXConstructorDecl::init_end | ( | ) | const [inline] |
Definition at line 2216 of file DeclCXX.h.
References init_end().
init_const_reverse_iterator clang::CXXConstructorDecl::init_rbegin | ( | ) | const [inline] |
Definition at line 2219 of file DeclCXX.h.
References init_end().
Definition at line 2223 of file DeclCXX.h.
References init_begin().
init_const_reverse_iterator clang::CXXConstructorDecl::init_rend | ( | ) | const [inline] |
Definition at line 2226 of file DeclCXX.h.
References init_begin().
init_range clang::CXXConstructorDecl::inits | ( | ) | [inline] |
Definition at line 2193 of file DeclCXX.h.
References init_begin(), and init_end().
Referenced by HandleConstructorCall(), and clang::Sema::InstantiateMemInitializers().
init_const_range clang::CXXConstructorDecl::inits | ( | ) | const [inline] |
Definition at line 2194 of file DeclCXX.h.
References init_begin(), and init_end().
bool CXXConstructorDecl::isConvertingConstructor | ( | bool | AllowExplicit | ) | const |
Whether this constructor is a converting constructor (C++ [class.conv.ctor]), which can be used for user-defined conversions.
Definition at line 1813 of file DeclCXX.cpp.
References clang::FunctionDecl::getNumParams(), clang::FunctionDecl::getParamDecl(), clang::ValueDecl::getType(), clang::ParmVarDecl::hasDefaultArg(), isExplicit(), clang::ParmVarDecl::isParameterPack(), and clang::FunctionDecl::isVariadic().
Referenced by LookupCopyAndMoveConstructors().
bool CXXConstructorDecl::isCopyConstructor | ( | unsigned & | TypeQuals | ) | const |
Whether this constructor is a copy constructor (C++ [class.copy]p2, which can be used to copy the class.
TypeQuals
will be set to the qualifiers on the argument type. For example, TypeQuals
would be set to Qualifiers::Const
for the following copy constructor:
Definition at line 1761 of file DeclCXX.cpp.
References clang::FunctionDecl::getParamDecl(), clang::ValueDecl::getType(), isCopyOrMoveConstructor(), and clang::Type::isLValueReferenceType().
Referenced by clang::Sema::DefineImplicitCopyConstructor(), EvaluateUnaryTypeTrait(), HandleConstructorCall(), clang::consumed::ConsumedStmtVisitor::VisitCXXConstructExpr(), and clang::threadSafety::BuildLockset::VisitCXXConstructExpr().
bool clang::CXXConstructorDecl::isCopyConstructor | ( | ) | const [inline] |
bool CXXConstructorDecl::isCopyOrMoveConstructor | ( | unsigned & | TypeQuals | ) | const |
Determine whether this is a copy or move constructor.
TypeQuals | Will be set to the type qualifiers on the reference parameter, if in fact this is a copy or move constructor. |
Definition at line 1772 of file DeclCXX.cpp.
References clang::Type::getAs(), clang::Decl::getASTContext(), clang::ASTContext::getCanonicalType(), clang::CanQual< T >::getCVRQualifiers(), clang::FunctionDecl::getDescribedFunctionTemplate(), clang::FunctionDecl::getNumParams(), clang::FunctionDecl::getParamDecl(), clang::CXXMethodDecl::getParent(), clang::ReferenceType::getPointeeType(), clang::FunctionDecl::getPrimaryTemplate(), clang::ASTContext::getTagDeclType(), clang::ValueDecl::getType(), and clang::CanQual< T >::getUnqualifiedType().
Referenced by clang::Sema::BuildCXXConstructExpr(), clang::CodeGen::CodeGenFunction::EmitCXXConstructorCall(), EmitMemberInitializer(), clang::CodeGen::CodeGenFunction::EmitSynthesizedCXXCopyCtorCall(), LookupCopyAndMoveConstructors(), PerformConstructorInitialization(), ResolveConstructorOverload(), and clang::ento::ExprEngine::VisitCXXConstructExpr().
bool clang::CXXConstructorDecl::isCopyOrMoveConstructor | ( | ) | const [inline] |
Determine whether this a copy or move constructor.
Definition at line 2302 of file DeclCXX.h.
Referenced by isCopyConstructor(), and isMoveConstructor().
bool CXXConstructorDecl::isDefaultConstructor | ( | ) | const |
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-initialize a class of this type.
Definition at line 1752 of file DeclCXX.cpp.
References clang::FunctionDecl::getNumParams(), clang::FunctionDecl::getParamDecl(), and clang::ParmVarDecl::hasDefaultArg().
Referenced by CheckTrivialDefaultConstructor(), clang::Sema::DefineImplicitDefaultConstructor(), clang::CodeGen::CodeGenModule::EmitConstantInit(), clang::CodeGen::CodeGenFunction::EmitCXXConstructorCall(), EvaluateUnaryTypeTrait(), GetDiagForGotoScopeDecl(), PerformConstructorInitialization(), and clang::consumed::ConsumedStmtVisitor::VisitCXXConstructExpr().
bool clang::CXXConstructorDecl::isDelegatingConstructor | ( | ) | const [inline] |
Determine whether this constructor is a delegating constructor.
Definition at line 2245 of file DeclCXX.h.
References getNumCtorInitializers(), and clang::CXXCtorInitializer::isDelegatingInitializer().
Referenced by DelegatingCycleHelper(), clang::CodeGen::CodeGenFunction::EmitCtorPrologue(), clang::CodeGen::CodeGenFunction::EmitDelegatingCXXConstructorCall(), getTargetConstructor(), HandleConstructorCall(), and IsConstructorDelegationValid().
bool clang::CXXConstructorDecl::isExplicit | ( | ) | const [inline] |
Determine whether this constructor was marked "explicit" or not.
Definition at line 2180 of file DeclCXX.h.
References clang::Redeclarable< FunctionDecl >::getFirstDecl(), and isExplicitSpecified().
Referenced by isConvertingConstructor(), ResolveConstructorOverload(), and TryConstructorInitialization().
bool clang::CXXConstructorDecl::isExplicitSpecified | ( | ) | const [inline] |
Determine whether this constructor declaration has the explicit
keyword specified.
Definition at line 2177 of file DeclCXX.h.
Referenced by isExplicit().
bool CXXConstructorDecl::isMoveConstructor | ( | unsigned & | TypeQuals | ) | const |
Determine whether this constructor is a move constructor (C++0x [class.copy]p3), which can be used to move values of the class.
TypeQuals | If this constructor is a move constructor, will be set to the type qualifiers on the referent of the first parameter's type. |
Definition at line 1766 of file DeclCXX.cpp.
References clang::FunctionDecl::getParamDecl(), clang::ValueDecl::getType(), isCopyOrMoveConstructor(), and clang::Type::isRValueReferenceType().
Referenced by clang::Sema::AddOverloadCandidate(), clang::Sema::DefineImplicitMoveConstructor(), HandleConstructorCall(), and clang::consumed::ConsumedStmtVisitor::VisitCXXConstructExpr().
bool clang::CXXConstructorDecl::isMoveConstructor | ( | ) | const [inline] |
Determine whether this is a member template specialization that would copy the object to itself. Such constructors are never used to copy an object.
Definition at line 1831 of file DeclCXX.cpp.
References clang::Decl::getASTContext(), clang::ASTContext::getCanonicalType(), clang::FunctionDecl::getDescribedFunctionTemplate(), clang::FunctionDecl::getNumParams(), clang::FunctionDecl::getParamDecl(), clang::CXXMethodDecl::getParent(), clang::FunctionDecl::getPrimaryTemplate(), clang::ASTContext::getTagDeclType(), clang::ValueDecl::getType(), and clang::CanQual< T >::getUnqualifiedType().
Referenced by clang::Sema::AddOverloadCandidate().
void clang::CXXConstructorDecl::setCtorInitializers | ( | CXXCtorInitializer ** | initializers | ) | [inline] |
Definition at line 2240 of file DeclCXX.h.
Referenced by clang::Sema::SetCtorInitializers(), and clang::Sema::SetDelegatingInitializer().
void CXXConstructorDecl::setInheritedConstructor | ( | const CXXConstructorDecl * | BaseCtor | ) |
Set the constructor that this inheriting constructor is based on.
Definition at line 1862 of file DeclCXX.cpp.
References clang::ASTContext::addOverriddenMethod(), and clang::Decl::getASTContext().
Referenced by clang::ASTDeclReader::VisitCXXConstructorDecl().
void clang::CXXConstructorDecl::setNumCtorInitializers | ( | unsigned | numCtorInitializers | ) | [inline] |
Definition at line 2236 of file DeclCXX.h.
Referenced by clang::Sema::SetCtorInitializers(), and clang::Sema::SetDelegatingInitializer().
friend class ASTDeclReader [friend] |
Reimplemented from clang::FunctionDecl.
friend class ASTDeclWriter [friend] |
Reimplemented from clang::FunctionDecl.