forked from OSchip/llvm-project
[clang] NFC: Remove else-after-return pattern from some files
Follow-up on D95336. A bunch of these cases were found manually, the rest made sense to be included to eliminate llvm-else-after-return Clang-Tidy warnings.
This commit is contained in:
parent
9c89dcf807
commit
c8d2ae52c1
|
@ -2401,12 +2401,10 @@ public:
|
|||
return (*SuperTnullability == NullabilityKind::NonNull &&
|
||||
*SubTnullability == NullabilityKind::Nullable);
|
||||
}
|
||||
else {
|
||||
// For the return type, it's okay for the superclass method to specify
|
||||
// "nullable" and the subclass method specify "nonnull"
|
||||
return (*SuperTnullability == NullabilityKind::Nullable &&
|
||||
*SubTnullability == NullabilityKind::NonNull);
|
||||
}
|
||||
// For the return type, it's okay for the superclass method to specify
|
||||
// "nullable" and the subclass method specify "nonnull"
|
||||
return (*SuperTnullability == NullabilityKind::Nullable &&
|
||||
*SubTnullability == NullabilityKind::NonNull);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1823,8 +1823,7 @@ template <typename DeclT>
|
|||
static SourceLocation getTemplateOrInnerLocStart(const DeclT *decl) {
|
||||
if (decl->getNumTemplateParameterLists() > 0)
|
||||
return decl->getTemplateParameterList(0)->getTemplateLoc();
|
||||
else
|
||||
return decl->getInnerLocStart();
|
||||
return decl->getInnerLocStart();
|
||||
}
|
||||
|
||||
SourceLocation DeclaratorDecl::getTypeSpecStartLoc() const {
|
||||
|
@ -2132,10 +2131,9 @@ VarDecl::isThisDeclarationADefinition(ASTContext &C) const {
|
|||
TSK_ExplicitSpecialization) ||
|
||||
isa<VarTemplatePartialSpecializationDecl>(this)))
|
||||
return Definition;
|
||||
else if (!isOutOfLine() && isInline())
|
||||
if (!isOutOfLine() && isInline())
|
||||
return Definition;
|
||||
else
|
||||
return DeclarationOnly;
|
||||
return DeclarationOnly;
|
||||
}
|
||||
// C99 6.7p5:
|
||||
// A definition of an identifier is a declaration for that identifier that
|
||||
|
@ -2198,7 +2196,7 @@ VarDecl *VarDecl::getActingDefinition() {
|
|||
Kind = I->isThisDeclarationADefinition();
|
||||
if (Kind == Definition)
|
||||
return nullptr;
|
||||
else if (Kind == TentativeDefinition)
|
||||
if (Kind == TentativeDefinition)
|
||||
LastTentative = I;
|
||||
}
|
||||
return LastTentative;
|
||||
|
@ -2270,8 +2268,7 @@ VarDecl *VarDecl::getInitializingDeclaration() {
|
|||
if (I->isThisDeclarationADefinition()) {
|
||||
if (isStaticDataMember())
|
||||
return I;
|
||||
else
|
||||
Def = I;
|
||||
Def = I;
|
||||
}
|
||||
}
|
||||
return Def;
|
||||
|
@ -3595,8 +3592,7 @@ bool FunctionDecl::isInlineDefinitionExternallyVisible() const {
|
|||
OverloadedOperatorKind FunctionDecl::getOverloadedOperator() const {
|
||||
if (getDeclName().getNameKind() == DeclarationName::CXXOperatorName)
|
||||
return getDeclName().getCXXOverloadedOperator();
|
||||
else
|
||||
return OO_None;
|
||||
return OO_None;
|
||||
}
|
||||
|
||||
/// getLiteralIdentifier - The literal suffix identifier this function
|
||||
|
@ -3604,8 +3600,7 @@ OverloadedOperatorKind FunctionDecl::getOverloadedOperator() const {
|
|||
const IdentifierInfo *FunctionDecl::getLiteralIdentifier() const {
|
||||
if (getDeclName().getNameKind() == DeclarationName::CXXLiteralOperatorName)
|
||||
return getDeclName().getCXXLiteralIdentifier();
|
||||
else
|
||||
return nullptr;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FunctionDecl::TemplatedKind FunctionDecl::getTemplatedKind() const {
|
||||
|
@ -3938,8 +3933,8 @@ SourceLocation FunctionDecl::getPointOfInstantiation() const {
|
|||
= TemplateOrSpecialization.dyn_cast<
|
||||
FunctionTemplateSpecializationInfo*>())
|
||||
return FTSInfo->getPointOfInstantiation();
|
||||
else if (MemberSpecializationInfo *MSInfo
|
||||
= TemplateOrSpecialization.dyn_cast<MemberSpecializationInfo*>())
|
||||
if (MemberSpecializationInfo *MSInfo =
|
||||
TemplateOrSpecialization.dyn_cast<MemberSpecializationInfo *>())
|
||||
return MSInfo->getPointOfInstantiation();
|
||||
|
||||
return SourceLocation();
|
||||
|
@ -4053,29 +4048,29 @@ unsigned FunctionDecl::getMemoryFunctionKind() const {
|
|||
if (isExternC()) {
|
||||
if (FnInfo->isStr("memset"))
|
||||
return Builtin::BImemset;
|
||||
else if (FnInfo->isStr("memcpy"))
|
||||
if (FnInfo->isStr("memcpy"))
|
||||
return Builtin::BImemcpy;
|
||||
else if (FnInfo->isStr("mempcpy"))
|
||||
if (FnInfo->isStr("mempcpy"))
|
||||
return Builtin::BImempcpy;
|
||||
else if (FnInfo->isStr("memmove"))
|
||||
if (FnInfo->isStr("memmove"))
|
||||
return Builtin::BImemmove;
|
||||
else if (FnInfo->isStr("memcmp"))
|
||||
if (FnInfo->isStr("memcmp"))
|
||||
return Builtin::BImemcmp;
|
||||
else if (FnInfo->isStr("bcmp"))
|
||||
if (FnInfo->isStr("bcmp"))
|
||||
return Builtin::BIbcmp;
|
||||
else if (FnInfo->isStr("strncpy"))
|
||||
if (FnInfo->isStr("strncpy"))
|
||||
return Builtin::BIstrncpy;
|
||||
else if (FnInfo->isStr("strncmp"))
|
||||
if (FnInfo->isStr("strncmp"))
|
||||
return Builtin::BIstrncmp;
|
||||
else if (FnInfo->isStr("strncasecmp"))
|
||||
if (FnInfo->isStr("strncasecmp"))
|
||||
return Builtin::BIstrncasecmp;
|
||||
else if (FnInfo->isStr("strncat"))
|
||||
if (FnInfo->isStr("strncat"))
|
||||
return Builtin::BIstrncat;
|
||||
else if (FnInfo->isStr("strndup"))
|
||||
if (FnInfo->isStr("strndup"))
|
||||
return Builtin::BIstrndup;
|
||||
else if (FnInfo->isStr("strlen"))
|
||||
if (FnInfo->isStr("strlen"))
|
||||
return Builtin::BIstrlen;
|
||||
else if (FnInfo->isStr("bzero"))
|
||||
if (FnInfo->isStr("bzero"))
|
||||
return Builtin::BIbzero;
|
||||
} else if (isInStdNamespace()) {
|
||||
if (FnInfo->isStr("free"))
|
||||
|
|
|
@ -230,11 +230,11 @@ bool Decl::isTemplateDecl() const {
|
|||
TemplateDecl *Decl::getDescribedTemplate() const {
|
||||
if (auto *FD = dyn_cast<FunctionDecl>(this))
|
||||
return FD->getDescribedFunctionTemplate();
|
||||
else if (auto *RD = dyn_cast<CXXRecordDecl>(this))
|
||||
if (auto *RD = dyn_cast<CXXRecordDecl>(this))
|
||||
return RD->getDescribedClassTemplate();
|
||||
else if (auto *VD = dyn_cast<VarDecl>(this))
|
||||
if (auto *VD = dyn_cast<VarDecl>(this))
|
||||
return VD->getDescribedVarTemplate();
|
||||
else if (auto *AD = dyn_cast<TypeAliasDecl>(this))
|
||||
if (auto *AD = dyn_cast<TypeAliasDecl>(this))
|
||||
return AD->getDescribedAliasTemplate();
|
||||
|
||||
return nullptr;
|
||||
|
@ -695,24 +695,23 @@ bool Decl::canBeWeakImported(bool &IsDefinition) const {
|
|||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
// Functions, if they aren't definitions.
|
||||
} else if (const auto *FD = dyn_cast<FunctionDecl>(this)) {
|
||||
if (const auto *FD = dyn_cast<FunctionDecl>(this)) {
|
||||
if (FD->hasBody()) {
|
||||
IsDefinition = true;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
// Objective-C classes, if this is the non-fragile runtime.
|
||||
} else if (isa<ObjCInterfaceDecl>(this) &&
|
||||
if (isa<ObjCInterfaceDecl>(this) &&
|
||||
getASTContext().getLangOpts().ObjCRuntime.hasWeakClassImport()) {
|
||||
return true;
|
||||
|
||||
// Nothing else.
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
// Nothing else.
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Decl::isWeakImported() const {
|
||||
|
@ -1027,16 +1026,16 @@ template <class T> static Decl *getNonClosureContext(T *D) {
|
|||
MD->getParent()->isLambda())
|
||||
return getNonClosureContext(MD->getParent()->getParent());
|
||||
return MD;
|
||||
} else if (auto *FD = dyn_cast<FunctionDecl>(D))
|
||||
}
|
||||
if (auto *FD = dyn_cast<FunctionDecl>(D))
|
||||
return FD;
|
||||
else if (auto *MD = dyn_cast<ObjCMethodDecl>(D))
|
||||
if (auto *MD = dyn_cast<ObjCMethodDecl>(D))
|
||||
return MD;
|
||||
else if (auto *BD = dyn_cast<BlockDecl>(D))
|
||||
if (auto *BD = dyn_cast<BlockDecl>(D))
|
||||
return getNonClosureContext(BD->getParent());
|
||||
else if (auto *CD = dyn_cast<CapturedDecl>(D))
|
||||
if (auto *CD = dyn_cast<CapturedDecl>(D))
|
||||
return getNonClosureContext(CD->getParent());
|
||||
else
|
||||
return nullptr;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Decl *Decl::getNonClosureContext() {
|
||||
|
|
|
@ -117,7 +117,8 @@ const Expr *Expr::skipRValueSubobjectAdjustments(
|
|||
BO->getRHS()->getType()->getAs<MemberPointerType>();
|
||||
Adjustments.push_back(SubobjectAdjustment(MPT, BO->getRHS()));
|
||||
continue;
|
||||
} else if (BO->getOpcode() == BO_Comma) {
|
||||
}
|
||||
if (BO->getOpcode() == BO_Comma) {
|
||||
CommaLHSs.push_back(BO->getLHS());
|
||||
E = BO->getRHS();
|
||||
continue;
|
||||
|
@ -586,8 +587,8 @@ std::string PredefinedExpr::ComputeName(IdentKind IK, const Decl *CurrentDecl) {
|
|||
if (!Buffer.empty() && Buffer.front() == '\01')
|
||||
return std::string(Buffer.substr(1));
|
||||
return std::string(Buffer.str());
|
||||
} else
|
||||
return std::string(ND->getIdentifier()->getName());
|
||||
}
|
||||
return std::string(ND->getIdentifier()->getName());
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
@ -3700,7 +3701,7 @@ Expr::isNullPointerConstant(ASTContext &Ctx,
|
|||
const IntegerLiteral *Lit = dyn_cast<IntegerLiteral>(this);
|
||||
if (Lit && !Lit->getValue())
|
||||
return NPCK_ZeroLiteral;
|
||||
else if (!Ctx.getLangOpts().MSVCCompat || !isCXX98IntegralConstantExpr(Ctx))
|
||||
if (!Ctx.getLangOpts().MSVCCompat || !isCXX98IntegralConstantExpr(Ctx))
|
||||
return NPCK_NotNull;
|
||||
} else {
|
||||
// If we have an integer constant expression, we need to *evaluate* it and
|
||||
|
@ -4129,9 +4130,8 @@ GenericSelectionExpr::CreateEmpty(const ASTContext &Context,
|
|||
IdentifierInfo *DesignatedInitExpr::Designator::getFieldName() const {
|
||||
assert(Kind == FieldDesignator && "Only valid on a field designator");
|
||||
if (Field.NameOrField & 0x01)
|
||||
return reinterpret_cast<IdentifierInfo *>(Field.NameOrField&~0x01);
|
||||
else
|
||||
return getField()->getIdentifier();
|
||||
return reinterpret_cast<IdentifierInfo *>(Field.NameOrField & ~0x01);
|
||||
return getField()->getIdentifier();
|
||||
}
|
||||
|
||||
DesignatedInitExpr::DesignatedInitExpr(const ASTContext &C, QualType Ty,
|
||||
|
@ -4249,7 +4249,8 @@ void DesignatedInitExpr::ExpandDesignator(const ASTContext &C, unsigned Idx,
|
|||
Designators + Idx);
|
||||
--NumNewDesignators;
|
||||
return;
|
||||
} else if (NumNewDesignators == 1) {
|
||||
}
|
||||
if (NumNewDesignators == 1) {
|
||||
Designators[Idx] = *First;
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue