Lines Matching refs:Constructor
1732 // constexpr function definition or a constexpr constructor definition. If so,
1742 // The definition of a constexpr constructor shall satisfy the following
1828 // The definition of a constexpr function(p3) or constructor(p4) [...] shall
1952 /// Check that the given field is initialized within a constexpr constructor.
1954 /// \param Dcl The constexpr constructor being checked.
1961 /// \param Kind Whether we're diagnosing a constructor as written or determining
1963 /// \return \c false if we're checking for validity and the constructor does
1964 /// not satisfy the requirements on a constexpr constructor.
2179 // In the definition of a constexpr constructor, [...]
2233 if (const CXXConstructorDecl *Constructor
2235 const CXXRecordDecl *RD = Constructor->getParent();
2243 if (Constructor->getNumCtorInitializers() == 0 &&
2255 } else if (!Constructor->isDependentContext() &&
2256 !Constructor->isDelegatingConstructor()) {
2275 Constructor->getNumCtorInitializers() != RD->getNumBases() + Fields) {
2280 for (const auto *I: Constructor->inits()) {
2347 // - every constructor call and implicit conversion used in initializing the
2350 // - every constructor involved in initializing non-static data members and
2351 // base class sub-objects shall be a constexpr constructor.
2371 /// class for which an unqualified-id in this scope could name a constructor
3544 // If non-null, add a note to the warning pointing back to the constructor.
3545 const CXXConstructorDecl *Constructor;
3559 Constructor(nullptr), InitList(false), InitListFieldDecl(nullptr) {}
3675 if (Constructor)
3676 S.Diag(Constructor->getLocation(),
3678 << (Constructor->isDefaultConstructor() && Constructor->isImplicit());
3750 Constructor = FieldConstructor;
3867 // where foo is not also a parameter to the constructor.
3872 Sema &SemaRef, const CXXConstructorDecl *Constructor) {
3875 Constructor->getLocation())) {
3879 if (Constructor->isInvalidDecl())
3882 const CXXRecordDecl *RD = Constructor->getParent();
3910 for (const auto *FieldInit : Constructor->inits()) {
3923 // In class initializers will point to the constructor.
3924 UninitializedChecker.CheckInitializer(InitExpr, Constructor,
3940 // Create a synthetic function scope to represent the call to the constructor
3984 // Pop the notional constructor scope we created earlier.
4038 /// within a constructor.
4175 CXXConstructorDecl *Constructor
4177 if (!Constructor) {
4178 // The user wrote a constructor initializer on a function that is
4179 // not a C++ constructor. Ignore the error for now, because we may
4185 CXXRecordDecl *ClassDecl = Constructor->getParent();
4189 // constructor's class and, if not found in that scope, are looked
4190 // up in the scope containing the constructor's definition.
4191 // [Note: if the constructor's class contains a member with the
4435 "Delegating constructor with no target?");
4473 // member of the constructor's class or a direct or virtual base
4510 // constructor's class or a direct or virtual base of that class, the
4616 BuildImplicitBaseInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
4631 = InitializationKind::CreateDefault(Constructor->getLocation());
4640 ParmVarDecl *Param = Constructor->getParamDecl(0);
4646 Constructor->getLocation(), ParamType,
4668 = InitializationKind::CreateDirect(Constructor->getLocation(),
4699 BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor,
4706 SourceLocation Loc = Constructor->getLocation();
4710 ParmVarDecl *Param = Constructor->getParamDecl(0);
4761 // Direct-initialize to use the copy constructor.
4821 SemaRef.Diag(Constructor->getLocation(),
4823 << (int)Constructor->isImplicit()
4824 << SemaRef.Context.getTagDeclType(Constructor->getParent())
4831 SemaRef.Diag(Constructor->getLocation(),
4833 << (int)Constructor->isImplicit()
4834 << SemaRef.Context.getTagDeclType(Constructor->getParent())
4913 // In an implicit copy or move constructor, ignore any in-class initializer.
4977 // -- the constructor's class is a union and no other variant member of that
4979 // -- the constructor's class is not a union, and, if the entity is a member
5032 Sema::SetDelegatingInitializer(CXXConstructorDecl *Constructor,
5035 Constructor->setNumCtorInitializers(1);
5039 Constructor->setCtorInitializers(initializer);
5041 if (CXXDestructorDecl *Dtor = LookupDestructor(Constructor->getParent())) {
5046 DelegatingCtorDecls.push_back(Constructor);
5048 DiagnoseUninitializedFields(*this, Constructor);
5053 bool Sema::SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors,
5055 if (Constructor->isDependentContext()) {
5059 Constructor->setNumCtorInitializers(Initializers.size());
5064 Constructor->setCtorInitializers(baseOrMemberInitializers);
5069 Constructor->setInvalidDecl();
5074 BaseAndFieldInfo Info(*this, Constructor, AnyErrors);
5078 CXXRecordDecl *ClassDecl = Constructor->getParent()->getDefinition();
5120 // class is ignored during execution of a constructor of any class that
5138 if (BuildImplicitBaseInitializer(*this, Constructor, Info.IIK,
5160 if (BuildImplicitBaseInitializer(*this, Constructor, Info.IIK,
5181 // If we're not generating the implicit copy/move constructor, then we'll
5213 Constructor->setNumCtorInitializers(NumInitializers);
5218 Constructor->setCtorInitializers(baseOrMemberInitializers);
5222 MarkBaseAndMemberDestructorsReferenced(Constructor->getLocation(),
5223 Constructor->getParent());
5268 Sema &SemaRef, const CXXConstructorDecl *Constructor,
5270 if (Constructor->getDeclContext()->isDependentContext())
5292 const CXXRecordDecl *ClassDecl = Constructor->getParent();
5463 /// ActOnMemInitializers - Handle the member initializers for a constructor.
5473 CXXConstructorDecl *Constructor
5476 if (!Constructor) {
5514 SetDelegatingInitializer(Constructor, MemInits[i]);
5523 DiagnoseBaseOrMemInitializerOrder(*this, Constructor, MemInits);
5525 SetCtorInitializers(Constructor, AnyErrors, MemInits);
5527 DiagnoseUninitializedFields(*this, Constructor);
5673 if (CXXConstructorDecl *Constructor
5675 SetCtorInitializers(Constructor, /*AnyErrors=*/false);
5676 DiagnoseUninitializedFields(*this, Constructor);
6015 // Only the MS ABI has default constructor closures, so we don't need to do
6031 // that we can properly codegen the constructor closure.
6274 // and move constructor, so don't attempt to import/export them if
6403 /// If the function is both a default constructor and a copy / move constructor
6510 // If a class has at least one non-deleted, trivial copy constructor, it
6567 // each copy constructor, move constructor, and destructor of X is
6569 // or move constructor
6644 // If this is not an aggregate type and has no user-declared constructor,
6677 // In addition, if class T has a user-declared constructor (12.1), every
6821 // copy/move constructor or destructor.
6991 /// A mapping from the base classes through which the constructor was
6993 /// pointer if the constructor was declared in that base class).
7023 // If the constructor was inherited from multiple base class subobjects
7048 /// Find the constructor to use for inherited construction of a base class,
7049 /// and whether that base class constructor inherits the constructor from a
7063 // This is the base class from which the constructor was inherited.
7069 /// specified operation on the specified class type a constexpr constructor?
7076 // If we're inheriting a constructor, see if we need to call it for this base
7094 // A constructor we wouldn't select can't be "involved in initializing"
7110 // In the definition of a constexpr constructor [...]
7116 // Since default constructor lookup is essentially trivial (and cannot
7118 // defaulted default constructor is constexpr directly within CXXRecordDecl.
7121 // constructor is constexpr to determine whether the type is a literal type.
7149 // will be initialized (if the constructor isn't deleted), we just don't know
7166 // -- every constructor involved in initializing [...] base class
7167 // sub-objects shall be a constexpr constructor;
7180 // -- every constructor involved in initializing non-static data members
7181 // [...] shall be a constexpr constructor;
7313 // Whether this was the first-declared instance of the constructor.
7335 // This checks for default arguments: a copy or move constructor with a
7336 // default argument is classified as a default constructor, and assignment
8687 /// function (or inherited constructor).
8738 /// Look up the constructor for the specified base class to see if it's
8739 /// overridden due to this being an inherited constructor.
8883 // As a weird special case, a destructor call from a union's constructor
8926 // either M has no default constructor or overload resolution as applied
8927 // to M's default constructor results in an ambiguity or in a function
8965 // Don't make the defaulted default constructor defined as deleted if the
8989 // If we have an inheriting constructor, check whether we're calling an
8990 // inherited constructor instead of a default constructor.
9020 // For a default constructor, all references must be initialized in-class
9031 // constructor.
9044 // For a copy constructor, data members must not be of rvalue reference
9117 /// A defaulted default constructor for a class X is defined as deleted if
9121 // default constructor. Don't do that.
9153 // deleted (8.4.3) default constructor and a deleted copy
9165 // namespace scope, the constructor and destructor are used.
9171 // If the class definition declares a move constructor or move assignment
9172 // operator, an implicitly declared copy constructor or copy assignment
9189 // Find any user-declared move constructor.
9313 // A default constructor is trivial if:
9321 // If there's a default constructor which could have been trivial, dig it
9322 // out. Otherwise, if there's any user-provided default constructor, point
9359 // A copy constructor is trivial if:
9360 // - the constructor selected to copy each direct [subobject] is trivial
9365 constructor or reach an
9373 // cases like B as having a non-trivial copy constructor:
9401 // mandates for the default constructor. This should rarely matter, because
9431 // Look for constructor templates.
9525 // A default constructor is trivial if [...]
9637 // A copy/move [constructor or assignment operator] is trivial if
9642 // A [default constructor or destructor] is trivial if
9651 // A copy/move [constructor or assignment operator] for a class X is
9654 // thereof), the constructor selected to copy/move that member is
9658 // A [default constructor or destructor] is trivial if
9661 // constructor or destructor]
9980 /// special functions, such as the default constructor, copy
9981 /// constructor, or destructor, to the given C++ class (C++
9999 // If the properties or semantics of the copy constructor couldn't be
10009 // more direct way for CodeGen to ask whether the constructor was deleted.
10213 // Now that we have our default arguments, check the constructor
10217 if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(Method))
10218 CheckConstructor(Constructor);
10247 /// the well-formedness of the constructor declarator @p D with type @p
10250 /// will be updated to reflect a well-formed type for the constructor and
10257 // A constructor shall not be virtual (10.3) or static (9.4). A
10258 // constructor can be invoked for a const, volatile or const
10259 // volatile object. A constructor shall not be declared const,
10289 // A constructor shall not be declared with a ref-qualifier.
10312 /// CheckConstructor - Checks a fully-formed constructor for
10314 /// the constructor declarator is invalid.
10315 void Sema::CheckConstructor(CXXConstructorDecl *Constructor) {
10317 = dyn_cast<CXXRecordDecl>(Constructor->getDeclContext());
10319 return Constructor->setInvalidDecl();
10322 // A declaration of a constructor for a class X is ill-formed if
10326 if (!Constructor->isInvalidDecl() &&
10327 Constructor->hasOneParamOrDefaultArgs() &&
10328 Constructor->getTemplateSpecializationKind() !=
10330 QualType ParamType = Constructor->getParamDecl(0)->getType();
10333 SourceLocation ParamLoc = Constructor->getParamDecl(0)->getLocation();
10335 = Constructor->getParamDecl(0)->getIdentifier() ? "const &"
10340 // FIXME: Rather that making the constructor invalid, we should endeavor
10342 Constructor->setInvalidDecl();
11365 // A constructor is an initializer-list constructor if its first parameter
11939 // of a base class, unless they're declaring an inheriting constructor.
11956 // Check that this inheriting constructor declaration actually names a
12011 // For an inheriting constructor declaration, the name of the using
12012 // declaration is the name of a constructor in this class, not in the
12127 // Try to correct typos if possible. If constructor name lookup finds no
12159 // If we corrected to an inheriting constructor, handle it as one.
12174 // constructor.
12242 // point of use for an inheriting constructor.
12270 /// Additional checks for a using declaration referring to a constructor name.
12272 assert(!UD->hasTypename() && "expecting a constructor name");
12276 "Using decl naming constructor doesn't have type in scope spec.");
12921 // [Look for exceptions thrown by] a constructor selected [...] to
13005 // Build an exception specification pointing back at this constructor.
13020 // A default constructor for a class X is a constructor of class X
13022 // user-declared constructor for class X, a default constructor is
13023 // implicitly declared. An implicitly-declared default constructor
13026 "Should not build implicit default constructor!");
13036 // Create the actual constructor declaration.
13065 // Note that we have declared this constructor.
13082 CXXConstructorDecl *Constructor) {
13083 assert((Constructor->isDefaulted() && Constructor->isDefaultConstructor() &&
13084 !Constructor->doesThisDeclarationHaveABody() &&
13085 !Constructor->isDeleted()) &&
13087 if (Constructor->willHaveBody() || Constructor->isInvalidDecl())
13090 CXXRecordDecl *ClassDecl = Constructor->getParent();
13091 assert(ClassDecl && "DefineImplicitDefaultConstructor - invalid constructor");
13093 SynthesizedFunctionScope Scope(*this, Constructor);
13098 Constructor->getType()->castAs<FunctionProtoType>());
13104 if (SetCtorInitializers(Constructor, /*AnyErrors=*/false)) {
13105 Constructor->setInvalidDecl();
13109 SourceLocation Loc = Constructor->getEndLoc().isValid()
13110 ? Constructor->getEndLoc()
13111 : Constructor->getLocation();
13112 Constructor->setBody(new (Context) CompoundStmt(Loc));
13113 Constructor->markUsed(Context);
13116 L->CompletedImplicitDefinition(Constructor);
13119 DiagnoseUninitializedFields(*this, Constructor);
13127 /// Find or create the fake constructor we synthesize to model constructing an
13128 /// object of a derived class via a constructor of a base class.
13136 // FIXME: Add a new kind of DeclarationName for an inherited constructor.
13137 // For now we use the name of the base class constructor as a member of the
13138 // derived class to indicate a (fake) inherited constructor name.
13141 // Check to see if we already have a fake constructor for this inherited
13142 // constructor call.
13156 // Check the inherited constructor is valid and find the list of base classes
13175 // Build an unevaluated exception specification for this fake constructor.
13200 // Set up the new constructor.
13201 assert(!BaseCtor->isDeleted() && "should not use deleted constructor");
13220 CXXConstructorDecl *Constructor) {
13221 CXXRecordDecl *ClassDecl = Constructor->getParent();
13222 assert(Constructor->getInheritedConstructor() &&
13223 !Constructor->doesThisDeclarationHaveABody() &&
13224 !Constructor->isDeleted());
13225 if (Constructor->willHaveBody() || Constructor->isInvalidDecl())
13228 // Initializations are performed "as if by a defaulted default constructor",
13230 SynthesizedFunctionScope Scope(*this, Constructor);
13235 Constructor->getType()->castAs<FunctionProtoType>());
13242 Constructor->getInheritedConstructor().getShadowDecl();
13244 Constructor->getInheritedConstructor().getConstructor();
13247 // initialization proceeds as if a defaulted default constructor is used to
13249 // constructor was inherited
13256 // constructor was inherited.
13282 // We now proceed as if for a defaulted default constructor, with the relevant
13285 if (SetCtorInitializers(Constructor, /*AnyErrors*/false, Inits)) {
13286 Constructor->setInvalidDecl();
13290 Constructor->setBody(new (Context) CompoundStmt(InitLoc));
13291 Constructor->markUsed(Context);
13294 L->CompletedImplicitDefinition(Constructor);
13297 DiagnoseUninitializedFields(*this, Constructor);
13930 // constructor rules. Note that virtual bases are not taken into account
14010 /// which is deprecated because the class has a user-declared copy constructor,
14025 // Find any user-declared copy constructor.
14092 // deprecated if the class has a user-declared copy constructor or a
14275 // constructor rules.
14645 // constructor, one is declared implicitly.
14674 // An implicitly-declared copy constructor is an inline public
14695 // Add the parameter to the constructor.
14715 // Note that we have declared this constructor.
14744 assert(ClassDecl && "DefineImplicitCopyConstructor - invalid constructor");
14758 // The [definition of an implicitly declared copy constructor] is
14808 // An implicitly-declared copy/move constructor is an inline public
14829 // Add the parameter to the constructor.
14849 // Note that we have declared this constructor.
14878 assert(ClassDecl && "DefineImplicitMoveConstructor - invalid constructor");
15048 CXXConstructorDecl *Constructor,
15061 // copy/move constructor and/or destructor for the object have
15068 if (ConstructKind == CXXConstructExpr::CK_Complete && Constructor &&
15069 Constructor->isCopyOrMoveConstructor() && hasOneRealArgument(ExprArgs)) {
15076 FoundDecl, Constructor,
15086 CXXConstructorDecl *Constructor,
15096 Constructor = findInheritingConstructor(ConstructLoc, Constructor, Shadow);
15097 if (DiagnoseUseOfDecl(Constructor, ConstructLoc))
15102 ConstructLoc, DeclInitType, Constructor, Elidable, ExprArgs,
15107 /// BuildCXXConstructExpr - Creates a complete call to a constructor,
15111 CXXConstructorDecl *Constructor,
15121 Constructor->getParent(),
15123 "given constructor for wrong type");
15124 MarkFunctionReferenced(ConstructLoc, Constructor);
15125 if (getLangOpts().CUDA && !CheckCUDACall(ConstructLoc, Constructor))
15128 !checkSYCLDeviceFunction(ConstructLoc, Constructor))
15133 Context, DeclInitType, ConstructLoc, Constructor, Elidable, ExprArgs,
15138 Constructor);
15182 // invokes a defaulted default constructor of its class or of an
15187 // default constructor can be needed in an unevaluated context, in
15192 // constructor before the initializer is lexically complete will ultimately
15262 /// Given a constructor and the set of arguments provided for the
15263 /// constructor, convert the arguments and add any required default arguments
15264 /// to form a proper call to this constructor.
15267 bool Sema::CompleteConstructorCall(CXXConstructorDecl *Constructor,
15277 const auto *Proto = Constructor->getType()->castAs<FunctionProtoType>();
15289 bool Invalid = GatherArgumentsForCall(Loc, Constructor,
15297 DiagnoseSentinelCalls(Constructor, Loc, AllArgs);
15299 CheckConstructorCall(Constructor, DeclInitType,
16019 // If the constructor used was non-trivial, set this as the
16876 // still instantiate to a defaultable function if it's a constructor
17465 // is required (e.g., because it would call a trivial default constructor)