r187891 - Eliminate CXXConstructorDecl::IsImplicitlyDefined.
Jordan Rose
jordan_rose at apple.com
Wed Aug 7 09:16:48 PDT 2013
Author: jrose
Date: Wed Aug 7 11:16:48 2013
New Revision: 187891
URL: http://llvm.org/viewvc/llvm-project?rev=187891&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp
Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=187891&r1=187890&r2=187891&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Wed Aug 7 11:16:48 2013
@@ -2025,14 +2025,6 @@ class CXXConstructorDecl : public CXXMet
/// 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 CXXMet
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 CXXMeth
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; }
Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=187891&r1=187890&r2=187891&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Wed Aug 7 11:16:48 2013
@@ -563,7 +563,7 @@ static void EmitMemberInitializer(CodeGe
// 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) { }
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=187891&r1=187890&r2=187891&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Aug 7 11:16:48 2013
@@ -8424,7 +8424,6 @@ void Sema::DefineImplicitDestructor(Sour
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
MultiStmtArg(),
/*isStmtExpr=*/false)
.takeAs<Stmt>());
- CopyConstructor->setImplicitlyDefined(true);
}
CopyConstructor->setUsed();
@@ -10009,7 +10007,6 @@ void Sema::DefineImplicitMoveConstructor
MultiStmtArg(),
/*isStmtExpr=*/false)
.takeAs<Stmt>());
- MoveConstructor->setImplicitlyDefined(true);
}
MoveConstructor->setUsed();
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=187891&r1=187890&r2=187891&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Aug 7 11:16:48 2013
@@ -1288,7 +1288,6 @@ void ASTDeclReader::VisitCXXConstructorD
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::VisitCXXConstructorD
void ASTDeclReader::VisitCXXDestructorDecl(CXXDestructorDecl *D) {
VisitCXXMethodDecl(D);
- D->ImplicitlyDefined = Record[Idx++];
D->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx);
}
Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=187891&r1=187890&r2=187891&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Wed Aug 7 11:16:48 2013
@@ -1005,7 +1005,6 @@ void ASTDeclWriter::VisitCXXConstructorD
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::VisitCXXConstructorD
void ASTDeclWriter::VisitCXXDestructorDecl(CXXDestructorDecl *D) {
VisitCXXMethodDecl(D);
- Record.push_back(D->ImplicitlyDefined);
Writer.AddDeclRef(D->OperatorDelete, Record);
Code = serialization::DECL_CXX_DESTRUCTOR;
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp?rev=187891&r1=187890&r2=187891&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp Wed Aug 7 11:16:48 2013
@@ -43,7 +43,7 @@ UndefinedArraySubscriptChecker::checkPre
// 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();
More information about the cfe-commits
mailing list