Remove redundant else (#20751)

This commit is contained in:
0-v-0 2025-01-22 05:03:42 +08:00 committed by GitHub
parent 080a4d840f
commit 71213dfbf8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 60 additions and 77 deletions

View file

@ -194,8 +194,7 @@ private struct ModuleComponentRange
return packages[index];
if (index == packages.length)
return name;
else
return Identifier.idPool("package");
return Identifier.idPool("package");
}
void popFront() @safe { index++; }
}

View file

@ -1529,11 +1529,9 @@ Expression ctfeCast(UnionExp* pue, const ref Loc loc, Type type, Type to, Expres
: tclass.implicitConvTo(to.mutableOf());
if (match)
return paint();
else
{
emplaceExp!(NullExp)(pue, loc, to);
return pue.exp();
}
emplaceExp!(NullExp)(pue, loc, to);
return pue.exp();
}
// Allow TypeInfo type painting

View file

@ -217,17 +217,12 @@ Dsymbol getDsymbol(RootObject oarg)
return te.td;
if (auto te = ea.isScopeExp())
return te.sds;
else
return null;
}
else
{
// Try to convert Type to symbol
if (auto ta = isType(oarg))
return ta.toDsymbol(null);
else
return isDsymbol(oarg); // if already a symbol
return null;
}
// Try to convert Type to symbol
if (auto ta = isType(oarg))
return ta.toDsymbol(null);
return isDsymbol(oarg); // if already a symbol
}
@ -5752,8 +5747,8 @@ MATCH matchArg(TemplateParameter tp, Loc instLoc, Scope* sc, Objects* tiargs, si
if (auto ttp = tp.isTemplateTupleParameter())
return matchArgTuple(ttp);
else
return matchArgParameter();
return matchArgParameter();
}
MATCH matchArg(TemplateParameter tp, Scope* sc, RootObject oarg, size_t i, TemplateParameters* parameters, ref Objects dedtypes, Declaration* psparam)
@ -6221,8 +6216,8 @@ void printTemplateStats(bool listInstances, ErrorSink eSink)
auto diff = b.ts.uniqueInstantiations - a.ts.uniqueInstantiations;
if (diff)
return diff;
else
return b.ts.numInstantiations - a.ts.numInstantiations;
return b.ts.numInstantiations - a.ts.numInstantiations;
}
}

View file

@ -581,8 +581,7 @@ extern (C++) class FuncDeclaration : Declaration
{
if (isMain())
return "D main";
else
return Dsymbol.toPrettyChars(QualifyTypes);
return Dsymbol.toPrettyChars(QualifyTypes);
}
/** for diagnostics, e.g. 'int foo(int x, int y) pure' */

View file

@ -2181,8 +2181,7 @@ void asm_merge_opnds(ref OPND o1, ref OPND o2)
{
if (o1.segreg)
return illegalAddressError("o1.segment && o2.segreg");
else
o1.segreg = o2.segreg;
o1.segreg = o2.segreg;
}
// combine the OPND's symbol field
@ -2266,8 +2265,8 @@ void asm_merge_opnds(ref OPND o1, ref OPND o2)
{
if (o1.pregDisp2)
return illegalAddressError("o1.pregDisp2 && o2.pregDisp2");
else
o1.pregDisp2 = o2.pregDisp2;
o1.pregDisp2 = o2.pregDisp2;
}
if (o1.bRIP && (o1.pregDisp1 || o2.bRIP || o1.base))
@ -2290,8 +2289,8 @@ void asm_merge_opnds(ref OPND o1, ref OPND o2)
{
if (o1.uchMultiplier)
return illegalAddressError("o1.uchMultiplier && o2.uchMultiplier");
else
o1.uchMultiplier = o2.uchMultiplier;
o1.uchMultiplier = o2.uchMultiplier;
}
if (o2.ptype && !o1.ptype)
o1.ptype = o2.ptype;

View file

@ -435,10 +435,10 @@ private final class CppMangleVisitor : Visitor
// 4. null pointer: std::nullptr_t (since C++11)
if (t.ty == Tvoid || t.ty == Tbool)
return true;
else if (t.ty == Tnull && global.params.cplusplus >= CppStdRevision.cpp11)
if (t.ty == Tnull && global.params.cplusplus >= CppStdRevision.cpp11)
return true;
else
return t.isTypeBasic() && (t.isIntegral() || t.isReal());
return t.isTypeBasic() && (t.isIntegral() || t.isReal());
}
/******************************
@ -1939,21 +1939,21 @@ extern(C++):
//printf("enum id = '%s'\n", id.toChars());
if (id == Id.__c_long)
return writeBasicType(t, 0, 'l');
else if (id == Id.__c_ulong)
if (id == Id.__c_ulong)
return writeBasicType(t, 0, 'm');
else if (id == Id.__c_char)
if (id == Id.__c_char)
return writeBasicType(t, 0, 'c');
else if (id == Id.__c_wchar_t)
if (id == Id.__c_wchar_t)
return writeBasicType(t, 0, 'w');
else if (id == Id.__c_longlong)
if (id == Id.__c_longlong)
return writeBasicType(t, 0, 'x');
else if (id == Id.__c_ulonglong)
if (id == Id.__c_ulonglong)
return writeBasicType(t, 0, 'y');
else if (id == Id.__c_complex_float)
if (id == Id.__c_complex_float)
return Type.tcomplex32.accept(this);
else if (id == Id.__c_complex_double)
if (id == Id.__c_complex_double)
return Type.tcomplex64.accept(this);
else if (id == Id.__c_complex_real)
if (id == Id.__c_complex_real)
return Type.tcomplex80.accept(this);
doSymbol(t);
@ -2362,8 +2362,7 @@ private bool isNamespaceEqual (CPPNamespaceDeclaration a, Nspace b, size_t idx =
// We need to see if there's more ident enclosing
if (auto pb = b.toParent().isNspace())
return isNamespaceEqual(a.cppnamespace, pb);
else
return a.cppnamespace is null;
return a.cppnamespace is null;
}
/// Returns:

View file

@ -1295,17 +1295,15 @@ extern (C++) abstract class Type : ASTNode
{
if (t.isWildConst())
return MODFlags.wild;
else
return MODFlags.wildconst;
return MODFlags.wildconst;
}
else if (isWild())
if (isWild())
return MODFlags.wild;
else if (isConst())
if (isConst())
return MODFlags.const_;
else if (isMutable())
if (isMutable())
return MODFlags.mutable;
else
assert(0);
assert(0);
}
return 0;
}

View file

@ -714,8 +714,8 @@ extern(C++) private final class Supported : Objc
{
if (cd.classKind == ClassKind.objc && fd.isStatic && !cd.objc.isMeta)
return cd.objc.metaclass;
else
return cd;
return cd;
}
override void addToClassMethodList(FuncDeclaration fd, ClassDeclaration cd) const
@ -805,11 +805,10 @@ extern(C++) private final class Supported : Objc
{
if (classDeclaration.baseClass)
return getRuntimeMetaclass(classDeclaration.baseClass);
else
return classDeclaration;
return classDeclaration;
}
else
return classDeclaration.objc.metaclass;
return classDeclaration.objc.metaclass;
}
override void addSymbols(AttribDeclaration attribDeclaration,

View file

@ -604,8 +604,8 @@ static:
{
if (hasHiddenArgument)
return setMsgSendSymbol!("_objc_msgSendSuper_stret")(TYhfunc);
else
return setMsgSendSymbol!("_objc_msgSendSuper")(TYnfunc);
return setMsgSendSymbol!("_objc_msgSendSuper")(TYnfunc);
}
Symbol* getImageInfo()
@ -1209,12 +1209,11 @@ private:
if (var.toParent() is classDeclaration)
return Symbols.getIVarOffset(classDeclaration, var, false);
else if (classDeclaration.baseClass)
if (classDeclaration.baseClass)
return ObjcClassDeclaration(classDeclaration.baseClass, false)
.getIVarOffset(var);
else
assert(false, "Trying to get the base class of a root class");
assert(false, "Trying to get the base class of a root class");
}
/**

View file

@ -525,12 +525,11 @@ extern (C++) struct Target
{
if (os == Target.OS.OSX)
return Target.ObjectFormat.macho;
else if (os & Target.OS.Posix)
if (os & Target.OS.Posix)
return Target.ObjectFormat.elf;
else if (os == Target.OS.Windows)
if (os == Target.OS.Windows)
return Target.ObjectFormat.coff;
else
assert(0, "unkown object format");
assert(0, "unkown object format");
}
/**
@ -1057,8 +1056,8 @@ extern (C++) struct Target
TypeTuple tt = toArgTypes_sysv_x64(tn);
if (!tt)
return false; // void
else
return !tt.arguments.length;
return !tt.arguments.length;
}
Lagain:
@ -1144,8 +1143,8 @@ extern (C++) struct Target
{
if (tns.ty == TY.Tcomplex32)
return false; // in EDX:EAX, not ST1:ST0
else
return true;
return true;
}
else if (os == Target.OS.Windows &&
isX86 &&
@ -1257,10 +1256,9 @@ extern (C++) struct Target
case objectFormat.stringof:
if (os == Target.OS.Windows)
return stringExp("coff");
else if (os == Target.OS.OSX)
if (os == Target.OS.OSX)
return stringExp("macho");
else
return stringExp("elf");
return stringExp("elf");
case floatAbi.stringof:
return stringExp("hard");
case cppRuntimeLibrary.stringof:
@ -1555,8 +1553,8 @@ struct TargetCPP
return toCppMangleItanium(s);
if (target.os == Target.OS.Windows)
return toCppMangleMSVC(s);
else
assert(0, "fix this");
assert(0, "fix this");
}
/**
@ -1575,8 +1573,8 @@ struct TargetCPP
return cppTypeInfoMangleItanium(cd);
if (target.os == Target.OS.Windows)
return cppTypeInfoMangleMSVC(cd);
else
assert(0, "fix this");
assert(0, "fix this");
}
/**
@ -1645,8 +1643,8 @@ struct TargetCPP
// MSVC adds padding between base and derived fields if required.
if (target.os == Target.OS.Windows)
return (baseClass.structsize + baseClass.alignsize - 1) & ~(baseClass.alignsize - 1);
else
return baseClass.structsize;
return baseClass.structsize;
}
}