Home | History | Annotate | Download | only in Sema

Lines Matching refs:Constructor

753 // constructor definition. If so, return true. If not, produce appropriate
761 // The definition of a constexpr constructor shall satisfy the following
819 // The definition of a constexpr function(p3) or constructor(p4) [...] shall
921 /// Check that the given field is initialized within a constexpr constructor.
923 /// \param Dcl The constexpr constructor being checked.
1095 // In the definition of a constexpr constructor, [...]
1120 if (const CXXConstructorDecl *Constructor
1122 const CXXRecordDecl *RD = Constructor->getParent();
1130 if (Constructor->getNumCtorInitializers() == 0 &&
1135 } else if (!Constructor->isDependentContext() &&
1136 !Constructor->isDelegatingConstructor()) {
1155 Constructor->getNumCtorInitializers() != RD->getNumBases() + Fields) {
1160 for (const auto *I: Constructor->inits()) {
1203 // - every constructor call and implicit conversion used in initializing the
1206 // - every constructor involved in initializing non-static data members and
1207 // base class sub-objects shall be a constexpr constructor.
2206 // If non-null, add a note to the warning pointing back to the constructor.
2207 const CXXConstructorDecl *Constructor;
2212 const CXXConstructorDecl *Constructor)
2214 Constructor(Constructor) { }
2256 if (Constructor)
2257 S.Diag(Constructor->getLocation(),
2259 << (Constructor->isDefaultConstructor() && Constructor->isImplicit());
2345 const CXXConstructorDecl *Constructor) {
2356 // In class initializers will point to the constructor.
2357 UninitializedFieldVisitor(S, Decls, Constructor).Visit(E);
2365 // where foo is not also a parameter to the constructor.
2370 Sema &SemaRef, const CXXConstructorDecl *Constructor) {
2373 Constructor->getLocation())) {
2377 if (Constructor->isInvalidDecl())
2380 const CXXRecordDecl *RD = Constructor->getParent();
2394 for (const auto *FieldInit : Constructor->inits()) {
2398 SemaRef, InitExpr, UninitializedFields, Constructor);
2410 // Create a synthetic function scope to represent the call to the constructor
2421 // Pop the notional constructor scope we created earlier.
2470 /// within a constructor.
2586 CXXConstructorDecl *Constructor
2588 if (!Constructor) {
2589 // The user wrote a constructor initializer on a function that is
2590 // not a C++ constructor. Ignore the error for now, because we may
2596 CXXRecordDecl *ClassDecl = Constructor->getParent();
2600 // constructor's class and, if not found in that scope, are looked
2601 // up in the scope containing the constructor's definition.
2602 // [Note: if the constructor's class contains a member with the
2880 "Delegating constructor with no target?");
2918 // member of the constructor's class or a direct or virtual base
2955 // constructor's class or a direct or virtual base of that class, the
3060 BuildImplicitBaseInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
3074 Constructor->getInheritedConstructor()->getParent();
3080 // constructor parameter and T is the declared type of p.
3082 for (unsigned I = 0, E = Constructor->getNumParams(); I != E; ++I) {
3083 ParmVarDecl *PD = Constructor->getParamDecl(I);
3093 Constructor->getLocation(), SourceLocation(), SourceLocation());
3102 = InitializationKind::CreateDefault(Constructor->getLocation());
3111 ParmVarDecl *Param = Constructor->getParamDecl(0);
3117 Constructor->getLocation(), ParamType,
3139 = InitializationKind::CreateDirect(Constructor->getLocation(),
3170 BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
3177 SourceLocation Loc = Constructor->getLocation();
3181 ParmVarDecl *Param = Constructor->getParamDecl(0);
3288 // Direct-initialize to use the copy constructor.
3356 SemaRef.Diag(Constructor->getLocation(),
3358 << (int)Constructor->isImplicit()
3359 << SemaRef.Context.getTagDeclType(Constructor->getParent())
3366 Constructor->getLocation(),
3368 << (int)Constructor->isImplicit()
3369 << SemaRef.Context.getTagDeclType(Constructor->getParent())
3451 // In an implicit copy or move constructor, ignore any in-class initializer.
3515 // -- the constructor's class is a union and no other variant member of that
3517 // -- the constructor's class is not a union, and, if the entity is a member
3566 Sema::SetDelegatingInitializer(CXXConstructorDecl *Constructor,
3569 Constructor->setNumCtorInitializers(1);
3573 Constructor->setCtorInitializers(initializer);
3575 if (CXXDestructorDecl *Dtor = LookupDestructor(Constructor->getParent())) {
3580 DelegatingCtorDecls.push_back(Constructor);
3585 bool Sema::SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors,
3587 if (Constructor->isDependentContext()) {
3591 Constructor->setNumCtorInitializers(Initializers.size());
3596 Constructor->setCtorInitializers(baseOrMemberInitializers);
3601 Constructor->setInvalidDecl();
3606 BaseAndFieldInfo Info(*this, Constructor, AnyErrors);
3610 CXXRecordDecl *ClassDecl = Constructor->getParent()->getDefinition();
3652 // class is ignored during execution of a constructor of any class that
3670 if (BuildImplicitBaseInitializer(*this, Constructor, Info.IIK,
3692 if (BuildImplicitBaseInitializer(*this, Constructor, Info.IIK,
3713 // If we're not generating the implicit copy/move constructor, then we'll
3745 Constructor->setNumCtorInitializers(NumInitializers);
3750 Constructor->setCtorInitializers(baseOrMemberInitializers);
3754 MarkBaseAndMemberDestructorsReferenced(Constructor->getLocation(),
3755 Constructor->getParent());
3786 Sema &SemaRef, const CXXConstructorDecl *Constructor,
3788 if (Constructor->getDeclContext()->isDependentContext())
3810 const CXXRecordDecl *ClassDecl = Constructor->getParent();
3942 /// ActOnMemInitializers - Handle the member initializers for a constructor.
3952 CXXConstructorDecl *Constructor
3955 if (!Constructor) {
3993 SetDelegatingInitializer(Constructor, MemInits[i]);
4002 DiagnoseBaseOrMemInitializerOrder(*this, Constructor, MemInits);
4004 SetCtorInitializers(Constructor, AnyErrors, MemInits);
4006 DiagnoseUninitializedFields(*this, Constructor);
4128 if (CXXConstructorDecl *Constructor
4130 SetCtorInitializers(Constructor, /*AnyErrors=*/false);
4131 DiagnoseUninitializedFields(*this, Constructor);
4495 // If this is not an aggregate type and has no user-declared constructor,
4531 // In addition, if class T has a user-declared constructor (12.1), every
4589 // function that is not a constructor declares that member function to be
4682 /// specified operation on the specified class type a constexpr constructor?
4689 // A constructor we wouldn't select can't be "involved in initializing"
4704 // In the definition of a constexpr constructor [...]
4708 // Since default constructor lookup is essentially trivial (and cannot
4710 // defaulted default constructor is constexpr directly within CXXRecordDecl.
4713 // constructor is constexpr to determine whether the type is a literal type.
4739 // will be initialized (if the constructor isn't deleted), we just don't know
4753 // -- every constructor involved in initializing [...] base class
4754 // sub-objects shall be a constexpr constructor;
4766 // -- every constructor involved in initializing non-static data members
4767 // [...] shall be a constexpr constructor;
4859 // Whether this was the first-declared instance of the constructor.
4876 // This also checks for default arguments: a copy or move constructor with a
4877 // default argument is classified as a default constructor, and assignment
5178 // As a weird special case, a destructor call from a union's constructor
5220 // either M has no default constructor or overload resolution as applied
5221 // to M's default constructor results in an ambiguity or in a function
5265 // For a default constructor, all references must be initialized in-class
5276 // constructor.
5289 // For a copy constructor, data members must not be of rvalue reference
5359 /// A defaulted default constructor for a class X is defined as deleted if
5363 // default constructor. Don't do that.
5389 // deleted (8.4.3) default constructor and a deleted copy
5400 // namespace scope, the constructor and destructor are used.
5406 // If the class definition declares a move constructor or move assignment
5407 // operator, an implicitly declared copy constructor or copy assignment
5419 // Find any user-declared move constructor.
5514 // A default constructor is trivial if:
5522 // If there's a default constructor which could have been trivial, dig it
5523 // out. Otherwise, if there's any user-provided default constructor, point
5558 // A copy constructor is trivial if:
5559 // - the constructor selected to copy each direct [subobject] is trivial
5562 // We must either select the trivial copy constructor or reach an
5570 // cases like B as having a non-trivial copy constructor:
5598 // mandates for the default constructor. This should rarely matter, because
5624 // Look for constructor templates.
5715 // A default constructor is trivial if [...]
5826 // A copy/move [constructor or assignment operator] is trivial if
5831 // A [default constructor or destructor] is trivial if
5840 // A copy/move [constructor or assignment operator] for a class X is
5843 // thereof), the constructor selected to copy/move that member is
5847 // A [default constructor or destructor] is trivial if
5850 // constructor or destructor]
6059 /// special functions, such as the default constructor, copy
6060 /// constructor, or destructor, to the given C++ class (C++
6070 // If the properties or semantics of the copy constructor couldn't be
6239 // Now that we have our default arguments, check the constructor
6243 if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(Method))
6244 CheckConstructor(Constructor);
6252 /// the well-formedness of the constructor declarator @p D with type @p
6255 /// will be updated to reflect a well-formed type for the constructor and
6262 // A constructor shall not be virtual (10.3) or static (9.4). A
6263 // constructor can be invoked for a const, volatile or const
6264 // volatile object. A constructor shall not be declared const,
6306 // A constructor shall not be declared with a ref-qualifier.
6328 /// CheckConstructor - Checks a fully-formed constructor for
6330 /// the constructor declarator is invalid.
6331 void Sema::CheckConstructor(CXXConstructorDecl *Constructor) {
6333 = dyn_cast<CXXRecordDecl>(Constructor->getDeclContext());
6335 return Constructor->setInvalidDecl();
6338 // A declaration of a constructor for a class X is ill-formed if
6342 if (!Constructor->isInvalidDecl() &&
6343 ((Constructor->getNumParams() == 1) ||
6344 (Constructor->getNumParams() > 1 &&
6345 Constructor->getParamDecl(1)->hasDefaultArg())) &&
6346 Constructor->getTemplateSpecializationKind()
6348 QualType ParamType = Constructor->getParamDecl(0)->getType();
6351 SourceLocation ParamLoc = Constructor->getParamDecl(0)->getLocation();
6353 = Constructor->getParamDecl(0)->getIdentifier() ? "const &"
6358 // FIXME: Rather that making the constructor invalid, we should endeavor
6360 Constructor->setInvalidDecl();
7008 // A constructor is an initializer-list constructor if its first parameter
7513 // of a base class, unless they're declaring an inheriting constructor.
7530 // Check that this inheriting constructor declaration actually names a
7656 // The normal rules do not apply to inheriting constructor declarations.
7699 // If we corrected to an inheriting constructor, handle it as one.
7714 // Build it and process it as an inheriting constructor.
7771 /// Additional checks for a using declaration referring to a constructor name.
7773 assert(!UD->hasTypename() && "expecting a constructor name");
7777 "Using decl naming constructor doesn't have type in scope spec.");
8260 CXXConstructorDecl *Constructor = LookupDefaultConstructor(BaseClassDecl);
8263 if (Constructor)
8264 ExceptSpec.CalledDecl(B.getLocStart(), Constructor);
8272 CXXConstructorDecl *Constructor = LookupDefaultConstructor(BaseClassDecl);
8275 if (Constructor)
8276 ExceptSpec.CalledDecl(B.getLocStart(), Constructor);
8288 // invokes a defaulted default constructor of its class or of an
8293 // default constructor can be needed in an unevaluated context, in
8304 CXXConstructorDecl *Constructor = LookupDefaultConstructor(FieldRecDecl);
8310 if (Constructor)
8311 ExceptSpec.CalledDecl(F->getLocation(), Constructor);
8323 // An inheriting constructor [...] shall have an exception-specification. [...]
8328 // Inherited constructor.
8332 // set, as could the default arguments for the inherited constructor. This
8345 CXXConstructorDecl *Constructor = LookupDefaultConstructor(BaseClassDecl);
8346 if (Constructor)
8347 ExceptSpec.CalledDecl(B.getLocStart(), Constructor);
8357 CXXConstructorDecl *Constructor = LookupDefaultConstructor(BaseClassDecl);
8358 if (Constructor)
8359 ExceptSpec.CalledDecl(B.getLocStart(), Constructor);
8374 CXXConstructorDecl *Constructor = LookupDefaultConstructor(FieldRecDecl);
8375 if (Constructor)
8376 ExceptSpec.CalledDecl(F->getLocation(), Constructor);
8416 // A default constructor for a class X is a constructor of class X
8418 // user-declared constructor for class X, a default constructor is
8419 // implicitly declared. An implicitly-declared default constructor
8422 "Should not build implicit default constructor!");
8432 // Create the actual constructor declaration.
8447 // Build an exception specification pointing back at this constructor.
8458 // Note that we have declared this constructor.
8469 CXXConstructorDecl *Constructor) {
8470 assert((Constructor->isDefaulted() && Constructor->isDefaultConstructor() &&
8471 !Constructor->doesThisDeclarationHaveABody() &&
8472 !Constructor->isDeleted()) &&
8475 CXXRecordDecl *ClassDecl = Constructor->getParent();
8476 assert(ClassDecl && "DefineImplicitDefaultConstructor - invalid constructor");
8478 SynthesizedFunctionScope Scope(*this, Constructor);
8480 if (SetCtorInitializers(Constructor, /*AnyErrors=*/false) ||
8484 Constructor->setInvalidDecl();
8488 SourceLocation Loc = Constructor->getLocEnd().isValid()
8489 ? Constructor->getLocEnd()
8490 : Constructor->getLocation();
8491 Constructor->setBody(new (Context) CompoundStmt(Loc));
8493 Constructor->markUsed(Context);
8497 L->CompletedImplicitDefinition(Constructor);
8500 DiagnoseUninitializedFields(*this, Constructor);
8516 // C++11 [class.inhctor]p3: [...] a constructor is implicitly declared [...]
8517 // unless there is a user-declared constructor with the same signature in
8527 /// Information about an inheriting constructor.
8532 /// If \c true, a constructor with this signature is already declared
8536 /// The constructor which is inherited.
8539 /// The derived constructor we declared.
8544 /// most one such non-template constructor, and any number of templated
8566 /// Get or create the inheriting constructor record for a constructor.
8588 /// Note that a constructor (or constructor template) was declared in Derived.
8593 /// Inherit a single constructor.
8610 // Declare a constructor for each number of parameters.
8615 // constructor or constructor template of X, the set of constructors or
8616 // constructor templates that results from omitting any ellipsis parameter
8634 // No fancy lookup required; just look for the base constructor name
8645 // [F]or each constructor template in the candidate set of inherited
8646 // constructors, a constructor template is implicitly declared
8650 // For each non-template constructor in the candidate set of inherited
8651 // constructors other than a constructor having no parameters or a
8652 // copy/move constructor having a single parameter, a constructor is
8659 // Per discussion on core reflector, never inherit a constructor which
8660 // would become a default, copy, or move constructor of Derived either.
8666 /// Declare a single inheriting constructor, inheriting the specified
8667 /// constructor, with the given type.
8673 // ... a constructor is implicitly declared with the same constructor
8674 // characteristics unless there is a user-declared constructor with
8684 // Only diagnose this once per constructor.
8697 // Core issue (no number): if the same inheriting constructor is
8699 // class, the inheriting constructor is defined as deleted.
8734 // Build an unevaluated exception specification for this constructor.
8756 // Set up the new constructor.
8763 // If this is a constructor template, build the template declaration.
8809 CXXConstructorDecl *Constructor) {
8810 CXXRecordDecl *ClassDecl = Constructor->getParent();
8811 assert(Constructor->getInheritedConstructor() &&
8812 !Constructor->doesThisDeclarationHaveABody() &&
8813 !Constructor->isDeleted());
8815 SynthesizedFunctionScope Scope(*this, Constructor);
8817 if (SetCtorInitializers(Constructor, /*AnyErrors=*/false) ||
8821 Constructor->setInvalidDecl();
8825 SourceLocation Loc = Constructor->getLocation();
8826 Constructor->setBody(new (Context) CompoundStmt(Loc));
8828 Constructor->markUsed(Context);
8832 L->CompletedImplicitDefinition(Constructor);
9488 // constructor rules. Note that virtual bases are not taken into account
9555 /// which is deprecated because the class has a user-declared copy constructor,
9571 // Find any user-declared copy constructor.
9622 // deprecated if the class has a user-declared copy constructor or a
9832 // Note that a move constructor is not implicitly declared when there are
9875 // constructor rules.
10286 // constructor, one is declared implicitly.
10310 // An implicitly-declared copy constructor is an inline public
10325 // Add the parameter to the constructor.
10341 // Note that we have declared this constructor.
10360 assert(ClassDecl && "DefineImplicitCopyConstructor - invalid constructor");
10363 // The [definition of an implicitly declared copy constructor] is
10410 CXXConstructorDecl *Constructor =
10414 if (Constructor)
10415 ExceptSpec.CalledDecl(B.getLocStart(), Constructor);
10423 CXXConstructorDecl *Constructor =
10427 if (Constructor)
10428 ExceptSpec.CalledDecl(B.getLocStart(), Constructor);
10436 CXXConstructorDecl *Constructor =
10443 if (Constructor)
10444 ExceptSpec.CalledDecl(F->getLocation(), Constructor);
10473 // An implicitly-declared copy/move constructor is an inline public
10488 // Add the parameter to the constructor.
10506 // Note that we have declared this constructor.
10525 assert(ClassDecl && "DefineImplicitMoveConstructor - invalid constructor");
10708 CXXConstructorDecl *Constructor,
10720 // copy/move constructor and/or destructor for the object have
10728 Constructor->isCopyOrMoveConstructor() && hasOneRealArgument(ExprArgs)) {
10730 Elidable = SubExpr->isTemporaryObject(Context, Constructor->getParent());
10733 return BuildCXXConstructExpr(ConstructLoc, DeclInitType, Constructor,
10739 /// BuildCXXConstructExpr - Creates a complete call to a constructor,
10743 CXXConstructorDecl *Constructor, bool Elidable,
10750 MarkFunctionReferenced(ConstructLoc, Constructor);
10752 Context, DeclInitType, ConstructLoc, Constructor, Elidable, ExprArgs,
10786 /// \brief Given a constructor and the set of arguments provided for the
10787 /// constructor, convert the arguments and add any required default arguments
10788 /// to form a proper call to this constructor.
10792 Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor,
10803 = Constructor->getType()->getAs<FunctionProtoType>();
10804 assert(Proto && "Constructor without a prototype?");
10816 bool Invalid = GatherArgumentsForCall(Loc, Constructor,
10824 DiagnoseSentinelCalls(Constructor, Loc, AllArgs);
10826 CheckConstructorCall(Constructor,
11405 // If the constructor used was non-trivial, set this as the
12721 // is required (e.g., because it would call a trivial default constructor)