From a780da70f74ab09ed1f91c1e992abf850e5268ea Mon Sep 17 00:00:00 2001 From: Sean Hunt Date: Tue, 10 May 2011 00:41:46 +0000 Subject: [PATCH] The last of the trivial constructor changes, make CXXSpecialMember reflect our new, more accurate AST. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131114 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Sema/Sema.h | 2 +- lib/Sema/SemaDecl.cpp | 17 ++++++++++------- lib/Sema/SemaDeclCXX.cpp | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 13a8a9a5b5..50d57e98ae 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -1105,7 +1105,7 @@ public: enum CXXSpecialMember { CXXInvalid = -1, - CXXConstructor = 0, + CXXDefaultConstructor = 0, CXXCopyConstructor = 1, CXXCopyAssignment = 2, CXXDestructor = 3 diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 15f168117d..5965181e5b 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1508,15 +1508,18 @@ Sema::CXXSpecialMember Sema::getSpecialMember(const CXXMethodDecl *MD) { if (Ctor->isCopyConstructor()) return Sema::CXXCopyConstructor; - return Sema::CXXConstructor; + if (Ctor->isDefaultConstructor()) + return Sema::CXXDefaultConstructor; } if (isa(MD)) return Sema::CXXDestructor; - assert(MD->isCopyAssignmentOperator() && - "Must have copy assignment operator"); - return Sema::CXXCopyAssignment; + if (MD->isCopyAssignmentOperator()) + return Sema::CXXCopyAssignment; + + llvm_unreachable("getSpecialMember on non-special member"); + return Sema::CXXInvalid; } /// canRedefineFunction - checks if a function can be redefined. Currently, @@ -7670,7 +7673,7 @@ bool Sema::CheckNontrivialField(FieldDecl *FD) { if (!RDecl->hasTrivialCopyConstructor()) member = CXXCopyConstructor; else if (!RDecl->hasTrivialDefaultConstructor()) - member = CXXConstructor; + member = CXXDefaultConstructor; else if (!RDecl->hasTrivialCopyAssignment()) member = CXXCopyAssignment; else if (!RDecl->hasTrivialDestructor()) @@ -7699,7 +7702,7 @@ void Sema::DiagnoseNontrivial(const RecordType* T, CXXSpecialMember member) { case CXXInvalid: break; - case CXXConstructor: + case CXXDefaultConstructor: if (RD->hasUserDeclaredConstructor()) { typedef CXXRecordDecl::ctor_iterator ctor_iter; for (ctor_iter ci = RD->ctor_begin(), ce = RD->ctor_end(); ci != ce;++ci){ @@ -7773,7 +7776,7 @@ void Sema::DiagnoseNontrivial(const RecordType* T, CXXSpecialMember member) { bool (CXXRecordDecl::*hasTrivial)() const; switch (member) { - case CXXConstructor: + case CXXDefaultConstructor: hasTrivial = &CXXRecordDecl::hasTrivialDefaultConstructor; break; case CXXCopyConstructor: hasTrivial = &CXXRecordDecl::hasTrivialCopyConstructor; break; diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 837a1bdae2..fe2de52adb 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -5091,7 +5091,7 @@ void Sema::DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, if (SetCtorInitializers(Constructor, 0, 0, /*AnyErrors=*/false) || Trap.hasErrorOccurred()) { Diag(CurrentLocation, diag::note_member_synthesized_at) - << CXXConstructor << Context.getTagDeclType(ClassDecl); + << CXXDefaultConstructor << Context.getTagDeclType(ClassDecl); Constructor->setInvalidDecl(); return; } -- 2.40.0