diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h index c2ed86b15ce8..4995812388e2 100644 --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -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; } diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp index dd75523d14a9..d00d1d062af8 100644 --- a/clang/lib/CodeGen/CGClass.cpp +++ b/clang/lib/CodeGen/CGClass.cpp @@ -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(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) { } diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index bd8b566769ca..31be93b17193 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -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()); - CopyConstructor->setImplicitlyDefined(true); } CopyConstructor->setUsed(); @@ -10009,7 +10007,6 @@ void Sema::DefineImplicitMoveConstructor(SourceLocation CurrentLocation, MultiStmtArg(), /*isStmtExpr=*/false) .takeAs()); - MoveConstructor->setImplicitlyDefined(true); } MoveConstructor->setUsed(); diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 6694192c8806..3ab11cca1403 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -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(Record, Idx); } diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp index a3e883f057e7..89280d43a4ae 100644 --- a/clang/lib/Serialization/ASTWriterDecl.cpp +++ b/clang/lib/Serialization/ASTWriterDecl.cpp @@ -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; diff --git a/clang/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp index d74b16398694..5df8846766e1 100644 --- a/clang/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/UndefinedArraySubscriptChecker.cpp @@ -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(D)) - if (Ctor->isImplicitlyDefined()) + if (Ctor->isDefaulted()) return; ExplodedNode *N = C.generateSink();