aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaLookup.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-11-27 21:20:31 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-11-27 21:20:31 +0000
commitd0adeb65c743e01ca3436db1d47a97cdcc78df89 (patch)
tree6754b30c30fe9650b23e76047c08e430921e92c5 /lib/Sema/SemaLookup.cpp
parentf8fc6273ed33386f5081f5cd5d30abd339eec030 (diff)
Simplify checking for whether we should implicitly declare special members and
add some assertions. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168725 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaLookup.cpp')
-rw-r--r--lib/Sema/SemaLookup.cpp25
1 files changed, 9 insertions, 16 deletions
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp
index f257a499d4..003c525e9f 100644
--- a/lib/Sema/SemaLookup.cpp
+++ b/lib/Sema/SemaLookup.cpp
@@ -528,22 +528,17 @@ static bool LookupBuiltin(Sema &S, LookupResult &R) {
/// \brief Determine whether we can declare a special member function within
/// the class at this point.
-static bool CanDeclareSpecialMemberFunction(ASTContext &Context,
- const CXXRecordDecl *Class) {
+static bool CanDeclareSpecialMemberFunction(const CXXRecordDecl *Class) {
// We need to have a definition for the class.
if (!Class->getDefinition() || Class->isDependentContext())
return false;
// We can't be in the middle of defining the class.
- if (const RecordType *RecordTy
- = Context.getTypeDeclType(Class)->getAs<RecordType>())
- return !RecordTy->isBeingDefined();
-
- return false;
+ return !Class->isBeingDefined();
}
void Sema::ForceDeclarationOfImplicitMembers(CXXRecordDecl *Class) {
- if (!CanDeclareSpecialMemberFunction(Context, Class))
+ if (!CanDeclareSpecialMemberFunction(Class))
return;
// If the default constructor has not yet been declared, do so now.
@@ -602,8 +597,7 @@ static void DeclareImplicitMemberFunctionsWithName(Sema &S,
switch (Name.getNameKind()) {
case DeclarationName::CXXConstructorName:
if (const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(DC))
- if (Record->getDefinition() &&
- CanDeclareSpecialMemberFunction(S.Context, Record)) {
+ if (Record->getDefinition() && CanDeclareSpecialMemberFunction(Record)) {
CXXRecordDecl *Class = const_cast<CXXRecordDecl *>(Record);
if (Record->needsImplicitDefaultConstructor())
S.DeclareImplicitDefaultConstructor(Class);
@@ -618,7 +612,7 @@ static void DeclareImplicitMemberFunctionsWithName(Sema &S,
case DeclarationName::CXXDestructorName:
if (const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(DC))
if (Record->getDefinition() && !Record->hasDeclaredDestructor() &&
- CanDeclareSpecialMemberFunction(S.Context, Record))
+ CanDeclareSpecialMemberFunction(Record))
S.DeclareImplicitDestructor(const_cast<CXXRecordDecl *>(Record));
break;
@@ -627,8 +621,7 @@ static void DeclareImplicitMemberFunctionsWithName(Sema &S,
break;
if (const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(DC)) {
- if (Record->getDefinition() &&
- CanDeclareSpecialMemberFunction(S.Context, Record)) {
+ if (Record->getDefinition() && CanDeclareSpecialMemberFunction(Record)) {
CXXRecordDecl *Class = const_cast<CXXRecordDecl *>(Record);
if (!Record->hasDeclaredCopyAssignment())
S.DeclareImplicitCopyAssignment(Class);
@@ -2233,9 +2226,9 @@ Sema::SpecialMemberOverloadResult *Sema::LookupSpecialMember(CXXRecordDecl *RD,
bool RValueThis,
bool ConstThis,
bool VolatileThis) {
- RD = RD->getDefinition();
- assert((RD && !RD->isBeingDefined()) &&
+ assert(CanDeclareSpecialMemberFunction(RD) &&
"doing special member lookup into record that isn't fully complete");
+ RD = RD->getDefinition();
if (RValueThis || ConstThis || VolatileThis)
assert((SM == CXXCopyAssignment || SM == CXXMoveAssignment) &&
"constructors and destructors always have unqualified lvalue this");
@@ -2451,7 +2444,7 @@ CXXConstructorDecl *Sema::LookupMovingConstructor(CXXRecordDecl *Class,
/// \brief Look up the constructors for the given class.
DeclContext::lookup_result Sema::LookupConstructors(CXXRecordDecl *Class) {
// If the implicit constructors have not yet been declared, do so now.
- if (CanDeclareSpecialMemberFunction(Context, Class)) {
+ if (CanDeclareSpecialMemberFunction(Class)) {
if (Class->needsImplicitDefaultConstructor())
DeclareImplicitDefaultConstructor(Class);
if (!Class->hasDeclaredCopyConstructor())