forked from OSchip/llvm-project
Remove ImplicitMustBeDefined, use universal 'Used' flag
instead. Do the implicit default ctor checking in MarkDeclarationReferenced. llvm-svn: 73888
This commit is contained in:
parent
360eef0782
commit
3a36343b88
|
@ -642,18 +642,13 @@ class CXXConstructorDecl : public CXXMethodDecl {
|
|||
/// @c !Implicit && ImplicitlyDefined.
|
||||
bool ImplicitlyDefined : 1;
|
||||
|
||||
/// ImplicitMustBeDefined - Implicit constructor was used to create an
|
||||
/// object of its class type. It must be defined.
|
||||
bool ImplicitMustBeDefined : 1;
|
||||
|
||||
/// FIXME: Add support for base and member initializers.
|
||||
|
||||
CXXConstructorDecl(CXXRecordDecl *RD, SourceLocation L,
|
||||
DeclarationName N, QualType T,
|
||||
bool isExplicit, bool isInline, bool isImplicitlyDeclared)
|
||||
: CXXMethodDecl(CXXConstructor, RD, L, N, T, false, isInline),
|
||||
Explicit(isExplicit), ImplicitlyDefined(false),
|
||||
ImplicitMustBeDefined(false) {
|
||||
Explicit(isExplicit), ImplicitlyDefined(false) {
|
||||
setImplicit(isImplicitlyDeclared);
|
||||
}
|
||||
|
||||
|
@ -684,17 +679,6 @@ public:
|
|||
ImplicitlyDefined = ID;
|
||||
}
|
||||
|
||||
/// isImplicitMustBeDefined - Whether a definition must be synthesized for
|
||||
/// the implicit constructor.
|
||||
bool isImplicitMustBeDefined() const {
|
||||
return isImplicit() && ImplicitMustBeDefined;
|
||||
}
|
||||
|
||||
/// setImplicitMustBeDefined - constructor must be implicitly defined.
|
||||
void setImplicitMustBeDefined() {
|
||||
ImplicitMustBeDefined = true;
|
||||
}
|
||||
|
||||
/// isDefaultConstructor - Whether this constructor is a default
|
||||
/// constructor (C++ [class.ctor]p5), which can be used to
|
||||
/// default-initialize a class of this type.
|
||||
|
|
|
@ -2733,12 +2733,9 @@ void Sema::ActOnUninitializedDecl(DeclPtrTy dcl) {
|
|||
IK_Default);
|
||||
if (!Constructor)
|
||||
Var->setInvalidDecl();
|
||||
else {
|
||||
else
|
||||
if (!RD->hasTrivialConstructor())
|
||||
InitializeVarWithConstructor(Var, Constructor, InitType, 0, 0);
|
||||
// Check for valid construction.
|
||||
DefineImplicitDefaultConstructor(Var->getLocation(), Constructor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1843,7 +1843,7 @@ Sema::DeclPtrTy Sema::ActOnNamespaceAliasDef(Scope *S,
|
|||
void Sema::DefineImplicitDefaultConstructor(SourceLocation CurrentLocation,
|
||||
CXXConstructorDecl *Constructor) {
|
||||
if (!Constructor->isDefaultConstructor() ||
|
||||
!Constructor->isImplicit() || Constructor->isImplicitMustBeDefined())
|
||||
!Constructor->isImplicit() || Constructor->isUsed())
|
||||
return;
|
||||
|
||||
CXXRecordDecl *ClassDecl
|
||||
|
@ -1862,7 +1862,7 @@ void Sema::DefineImplicitDefaultConstructor(SourceLocation CurrentLocation,
|
|||
if (CXXConstructorDecl *BaseCtor =
|
||||
BaseClassDecl->getDefaultConstructor(Context)) {
|
||||
if (BaseCtor->isImplicit())
|
||||
BaseCtor->setImplicitMustBeDefined();
|
||||
BaseCtor->setUsed();
|
||||
}
|
||||
else {
|
||||
Diag(CurrentLocation, diag::err_defining_default_ctor)
|
||||
|
@ -1887,7 +1887,7 @@ void Sema::DefineImplicitDefaultConstructor(SourceLocation CurrentLocation,
|
|||
if (CXXConstructorDecl *FieldCtor =
|
||||
FieldClassDecl->getDefaultConstructor(Context)) {
|
||||
if (FieldCtor->isImplicit())
|
||||
FieldCtor->setImplicitMustBeDefined();
|
||||
FieldCtor->setUsed();
|
||||
}
|
||||
else {
|
||||
Diag(CurrentLocation, diag::err_defining_default_ctor)
|
||||
|
@ -1912,7 +1912,7 @@ void Sema::DefineImplicitDefaultConstructor(SourceLocation CurrentLocation,
|
|||
}
|
||||
}
|
||||
if (!err)
|
||||
Constructor->setImplicitMustBeDefined();
|
||||
Constructor->setUsed();
|
||||
}
|
||||
|
||||
void Sema::InitializeVarWithConstructor(VarDecl *VD,
|
||||
|
@ -1990,9 +1990,6 @@ void Sema::AddCXXDirectInitializerToDecl(DeclPtrTy Dcl,
|
|||
VDecl->setCXXDirectInitializer(true);
|
||||
InitializeVarWithConstructor(VDecl, Constructor, DeclInitType,
|
||||
(Expr**)Exprs.release(), NumExprs);
|
||||
// An implicitly-declared default constructor for a class is implicitly
|
||||
// defined when it is used to creat an object of its class type.
|
||||
DefineImplicitDefaultConstructor(VDecl->getLocation(), Constructor);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -5461,6 +5461,13 @@ void Sema::MarkDeclarationReferenced(SourceLocation Loc, Decl *D) {
|
|||
return;
|
||||
|
||||
// Note that this declaration has been used.
|
||||
if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(D)) {
|
||||
DefineImplicitDefaultConstructor(Loc, Constructor);
|
||||
// FIXME: set the Used flag if it is determined that ctor is valid.
|
||||
Constructor->setUsed(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (FunctionDecl *Function = dyn_cast<FunctionDecl>(D)) {
|
||||
// FIXME: implicit template instantiation
|
||||
// FIXME: keep track of references to static functions
|
||||
|
|
Loading…
Reference in New Issue