forked from OSchip/llvm-project
Eliminate CXXConstructorDecl::IsImplicitlyDefined.
This field is just IsDefaulted && !IsDeleted; in all places it's used, a simple check for isDefaulted() is superior anyway, and we were forgetting to set it in a few cases. Also eliminate CXXDestructorDecl::IsImplicitlyDefined, for the same reasons. No intended functionality change. llvm-svn: 187891
This commit is contained in:
parent
65b4b97f1b
commit
54533f73a8
|
@ -2025,14 +2025,6 @@ class CXXConstructorDecl : public CXXMethodDecl {
|
|||
/// specified.
|
||||
bool IsExplicitSpecified : 1;
|
||||
|
||||
/// \brief Whether this constructor was implicitly defined by the compiler.
|
||||
///
|
||||
/// When false, the constructor was defined by the user. In C++03, this flag
|
||||
/// will have the same value as Implicit. In C++11, however, a constructor
|
||||
/// that is explicitly defaulted (i.e., defined with " = default") will have
|
||||
/// \c !Implicit && ImplicitlyDefined.
|
||||
bool ImplicitlyDefined : 1;
|
||||
|
||||
/// \name Support for base and member initializers.
|
||||
/// \{
|
||||
/// \brief The arguments used to initialize the base or member.
|
||||
|
@ -2047,8 +2039,8 @@ class CXXConstructorDecl : public CXXMethodDecl {
|
|||
bool isImplicitlyDeclared, bool isConstexpr)
|
||||
: CXXMethodDecl(CXXConstructor, RD, StartLoc, NameInfo, T, TInfo,
|
||||
SC_None, isInline, isConstexpr, SourceLocation()),
|
||||
IsExplicitSpecified(isExplicitSpecified), ImplicitlyDefined(false),
|
||||
CtorInitializers(0), NumCtorInitializers(0) {
|
||||
IsExplicitSpecified(isExplicitSpecified), CtorInitializers(0),
|
||||
NumCtorInitializers(0) {
|
||||
setImplicit(isImplicitlyDeclared);
|
||||
}
|
||||
|
||||
|
@ -2072,25 +2064,6 @@ public:
|
|||
->isExplicitSpecified();
|
||||
}
|
||||
|
||||
/// \brief Whether this constructor was implicitly defined.
|
||||
///
|
||||
/// If false, then this constructor was defined by the user. This operation
|
||||
/// must only be invoked if the constructor has already been defined.
|
||||
bool isImplicitlyDefined() const {
|
||||
assert(isThisDeclarationADefinition() &&
|
||||
"Can only get the implicit-definition flag once the "
|
||||
"constructor has been defined");
|
||||
return ImplicitlyDefined;
|
||||
}
|
||||
|
||||
/// \brief Set whether this constructor was implicitly defined or not.
|
||||
void setImplicitlyDefined(bool ID) {
|
||||
assert(isThisDeclarationADefinition() &&
|
||||
"Can only set the implicit-definition flag once the constructor "
|
||||
"has been defined");
|
||||
ImplicitlyDefined = ID;
|
||||
}
|
||||
|
||||
/// \brief Iterates through the member/base initializer list.
|
||||
typedef CXXCtorInitializer **init_iterator;
|
||||
|
||||
|
@ -2249,13 +2222,6 @@ public:
|
|||
/// \endcode
|
||||
class CXXDestructorDecl : public CXXMethodDecl {
|
||||
virtual void anchor();
|
||||
/// \brief Whether this destructor was implicitly defined by the compiler.
|
||||
///
|
||||
/// When false, the destructor was defined by the user. In C++03, this
|
||||
/// flag will have the same value as Implicit. In C++11, however, a
|
||||
/// destructor that is explicitly defaulted (i.e., defined with " = default")
|
||||
/// will have \c !Implicit && ImplicitlyDefined.
|
||||
bool ImplicitlyDefined : 1;
|
||||
|
||||
FunctionDecl *OperatorDelete;
|
||||
|
||||
|
@ -2265,7 +2231,7 @@ class CXXDestructorDecl : public CXXMethodDecl {
|
|||
bool isInline, bool isImplicitlyDeclared)
|
||||
: CXXMethodDecl(CXXDestructor, RD, StartLoc, NameInfo, T, TInfo,
|
||||
SC_None, isInline, /*isConstexpr=*/false, SourceLocation()),
|
||||
ImplicitlyDefined(false), OperatorDelete(0) {
|
||||
OperatorDelete(0) {
|
||||
setImplicit(isImplicitlyDeclared);
|
||||
}
|
||||
|
||||
|
@ -2278,25 +2244,6 @@ public:
|
|||
bool isImplicitlyDeclared);
|
||||
static CXXDestructorDecl *CreateDeserialized(ASTContext & C, unsigned ID);
|
||||
|
||||
/// \brief Whether this destructor was implicitly defined.
|
||||
///
|
||||
/// If false, then this destructor was defined by the user. This operation
|
||||
/// can only be invoked if the destructor has already been defined.
|
||||
bool isImplicitlyDefined() const {
|
||||
assert(isThisDeclarationADefinition() &&
|
||||
"Can only get the implicit-definition flag once the destructor has "
|
||||
"been defined");
|
||||
return ImplicitlyDefined;
|
||||
}
|
||||
|
||||
/// \brief Set whether this destructor was implicitly defined or not.
|
||||
void setImplicitlyDefined(bool ID) {
|
||||
assert(isThisDeclarationADefinition() &&
|
||||
"Can only set the implicit-definition flag once the destructor has "
|
||||
"been defined");
|
||||
ImplicitlyDefined = ID;
|
||||
}
|
||||
|
||||
void setOperatorDelete(FunctionDecl *OD) { OperatorDelete = OD; }
|
||||
const FunctionDecl *getOperatorDelete() const { return OperatorDelete; }
|
||||
|
||||
|
|
|
@ -563,7 +563,7 @@ static void EmitMemberInitializer(CodeGenFunction &CGF,
|
|||
// in the AST, we could generalize it more easily.
|
||||
const ConstantArrayType *Array
|
||||
= CGF.getContext().getAsConstantArrayType(FieldType);
|
||||
if (Array && Constructor->isImplicitlyDefined() &&
|
||||
if (Array && Constructor->isDefaulted() &&
|
||||
Constructor->isCopyOrMoveConstructor()) {
|
||||
QualType BaseElementTy = CGF.getContext().getBaseElementType(Array);
|
||||
CXXConstructExpr *CE = dyn_cast<CXXConstructExpr>(MemberInit->getInit());
|
||||
|
@ -885,7 +885,7 @@ namespace {
|
|||
/// constructor.
|
||||
static const VarDecl* getTrivialCopySource(const CXXConstructorDecl *CD,
|
||||
FunctionArgList &Args) {
|
||||
if (CD->isCopyOrMoveConstructor() && CD->isImplicitlyDefined())
|
||||
if (CD->isCopyOrMoveConstructor() && CD->isDefaulted())
|
||||
return Args[Args.size() - 1];
|
||||
return 0;
|
||||
}
|
||||
|
@ -919,7 +919,7 @@ namespace {
|
|||
FunctionArgList &Args)
|
||||
: FieldMemcpyizer(CGF, CD->getParent(), getTrivialCopySource(CD, Args)),
|
||||
ConstructorDecl(CD),
|
||||
MemcpyableCtor(CD->isImplicitlyDefined() &&
|
||||
MemcpyableCtor(CD->isDefaulted() &&
|
||||
CD->isCopyOrMoveConstructor() &&
|
||||
CGF.getLangOpts().getGC() == LangOptions::NonGC),
|
||||
Args(Args) { }
|
||||
|
|
|
@ -8424,7 +8424,6 @@ void Sema::DefineImplicitDestructor(SourceLocation CurrentLocation,
|
|||
|
||||
SourceLocation Loc = Destructor->getLocation();
|
||||
Destructor->setBody(new (Context) CompoundStmt(Loc));
|
||||
Destructor->setImplicitlyDefined(true);
|
||||
Destructor->setUsed();
|
||||
MarkVTableUsed(CurrentLocation, ClassDecl);
|
||||
|
||||
|
@ -9819,7 +9818,6 @@ void Sema::DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
|
|||
MultiStmtArg(),
|
||||
/*isStmtExpr=*/false)
|
||||
.takeAs<Stmt>());
|
||||
CopyConstructor->setImplicitlyDefined(true);
|
||||
}
|
||||
|
||||
CopyConstructor->setUsed();
|
||||
|
@ -10009,7 +10007,6 @@ void Sema::DefineImplicitMoveConstructor(SourceLocation CurrentLocation,
|
|||
MultiStmtArg(),
|
||||
/*isStmtExpr=*/false)
|
||||
.takeAs<Stmt>());
|
||||
MoveConstructor->setImplicitlyDefined(true);
|
||||
}
|
||||
|
||||
MoveConstructor->setUsed();
|
||||
|
|
|
@ -1288,7 +1288,6 @@ void ASTDeclReader::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
|
|||
VisitCXXMethodDecl(D);
|
||||
|
||||
D->IsExplicitSpecified = Record[Idx++];
|
||||
D->ImplicitlyDefined = Record[Idx++];
|
||||
llvm::tie(D->CtorInitializers, D->NumCtorInitializers)
|
||||
= Reader.ReadCXXCtorInitializers(F, Record, Idx);
|
||||
}
|
||||
|
@ -1296,7 +1295,6 @@ void ASTDeclReader::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
|
|||
void ASTDeclReader::VisitCXXDestructorDecl(CXXDestructorDecl *D) {
|
||||
VisitCXXMethodDecl(D);
|
||||
|
||||
D->ImplicitlyDefined = Record[Idx++];
|
||||
D->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx);
|
||||
}
|
||||
|
||||
|
|
|
@ -1005,7 +1005,6 @@ void ASTDeclWriter::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
|
|||
VisitCXXMethodDecl(D);
|
||||
|
||||
Record.push_back(D->IsExplicitSpecified);
|
||||
Record.push_back(D->ImplicitlyDefined);
|
||||
Writer.AddCXXCtorInitializers(D->CtorInitializers, D->NumCtorInitializers,
|
||||
Record);
|
||||
|
||||
|
@ -1015,7 +1014,6 @@ void ASTDeclWriter::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
|
|||
void ASTDeclWriter::VisitCXXDestructorDecl(CXXDestructorDecl *D) {
|
||||
VisitCXXMethodDecl(D);
|
||||
|
||||
Record.push_back(D->ImplicitlyDefined);
|
||||
Writer.AddDeclRef(D->OperatorDelete, Record);
|
||||
|
||||
Code = serialization::DECL_CXX_DESTRUCTOR;
|
||||
|
|
|
@ -43,7 +43,7 @@ UndefinedArraySubscriptChecker::checkPreStmt(const ArraySubscriptExpr *A,
|
|||
// Don't warn if we're in an implicitly-generated constructor.
|
||||
const Decl *D = C.getLocationContext()->getDecl();
|
||||
if (const CXXConstructorDecl *Ctor = dyn_cast<CXXConstructorDecl>(D))
|
||||
if (Ctor->isImplicitlyDefined())
|
||||
if (Ctor->isDefaulted())
|
||||
return;
|
||||
|
||||
ExplodedNode *N = C.generateSink();
|
||||
|
|
Loading…
Reference in New Issue