Skip to content

Commit a119d89

Browse files
committed
Refactor to early returns
1 parent d58962b commit a119d89

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9440,7 +9440,7 @@ bool SpecialMemberDeletionInfo::shouldDeleteForSubobjectCall(
94409440
CXXMethodDecl *Decl = SMOR.getMethod();
94419441
FieldDecl *Field = Subobj.dyn_cast<FieldDecl*>();
94429442

9443-
int DiagKind = -1;
9443+
int DiagKind;
94449444

94459445
if (SMOR.getKind() == Sema::SpecialMemberOverloadResult::NoMemberOrDeleted) {
94469446
if (CSM == Sema::CXXDefaultConstructor && Field &&
@@ -9451,11 +9451,10 @@ bool SpecialMemberDeletionInfo::shouldDeleteForSubobjectCall(
94519451
// constructor and no variant member of X has a default member
94529452
// initializer
94539453
const auto *RD = cast<CXXRecordDecl>(Field->getParent());
9454-
if (!RD->hasInClassInitializer())
9455-
DiagKind = !Decl ? 0 : 1;
9456-
} else {
9457-
DiagKind = !Decl ? 0 : 1;
9454+
if (RD->hasInClassInitializer())
9455+
return false;
94589456
}
9457+
DiagKind = !Decl ? 0 : 1;
94599458
} else if (SMOR.getKind() == Sema::SpecialMemberOverloadResult::Ambiguous)
94609459
DiagKind = 2;
94619460
else if (!isAccessible(Subobj, Decl))
@@ -9474,15 +9473,13 @@ bool SpecialMemberDeletionInfo::shouldDeleteForSubobjectCall(
94749473
// constructor and no variant member of X has a default member
94759474
// initializer
94769475
const auto *RD = cast<CXXRecordDecl>(Field->getParent());
9477-
if (!RD->hasInClassInitializer())
9478-
DiagKind = 4;
9479-
} else {
9480-
DiagKind = 4;
9476+
if (RD->hasInClassInitializer())
9477+
return false;
94819478
}
9482-
}
9483-
9484-
if (DiagKind == -1)
9479+
DiagKind = 4;
9480+
} else {
94859481
return false;
9482+
}
94869483

94879484
if (Diagnose) {
94889485
if (Field) {

0 commit comments

Comments
 (0)