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

View file

@ -1529,12 +1529,10 @@ 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();
}
}
// Allow TypeInfo type painting
if (isTypeInfo_Class(e.type) && e.type.implicitConvTo(to))

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
}
}
@ -5752,7 +5747,7 @@ MATCH matchArg(TemplateParameter tp, Loc instLoc, Scope* sc, Objects* tiargs, si
if (auto ttp = tp.isTemplateTupleParameter())
return matchArgTuple(ttp);
else
return matchArgParameter();
}
@ -6221,7 +6216,7 @@ 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;
}
}

View file

@ -581,7 +581,6 @@ extern (C++) class FuncDeclaration : Declaration
{
if (isMain())
return "D main";
else
return Dsymbol.toPrettyChars(QualifyTypes);
}

View file

@ -2181,7 +2181,6 @@ void asm_merge_opnds(ref OPND o1, ref OPND o2)
{
if (o1.segreg)
return illegalAddressError("o1.segment && o2.segreg");
else
o1.segreg = o2.segreg;
}
@ -2266,7 +2265,7 @@ void asm_merge_opnds(ref OPND o1, ref OPND o2)
{
if (o1.pregDisp2)
return illegalAddressError("o1.pregDisp2 && o2.pregDisp2");
else
o1.pregDisp2 = o2.pregDisp2;
}
@ -2290,7 +2289,7 @@ void asm_merge_opnds(ref OPND o1, ref OPND o2)
{
if (o1.uchMultiplier)
return illegalAddressError("o1.uchMultiplier && o2.uchMultiplier");
else
o1.uchMultiplier = o2.uchMultiplier;
}
if (o2.ptype && !o1.ptype)

View file

@ -435,9 +435,9 @@ 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());
}
@ -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,7 +2362,6 @@ 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;
}

View file

@ -1295,16 +1295,14 @@ extern (C++) abstract class Type : ASTNode
{
if (t.isWildConst())
return MODFlags.wild;
else
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);
}
return 0;

View file

@ -714,7 +714,7 @@ extern(C++) private final class Supported : Objc
{
if (cd.classKind == ClassKind.objc && fd.isStatic && !cd.objc.isMeta)
return cd.objc.metaclass;
else
return cd;
}
@ -805,10 +805,9 @@ extern(C++) private final class Supported : Objc
{
if (classDeclaration.baseClass)
return getRuntimeMetaclass(classDeclaration.baseClass);
else
return classDeclaration;
}
else
return classDeclaration.objc.metaclass;
}

View file

@ -604,7 +604,7 @@ static:
{
if (hasHiddenArgument)
return setMsgSendSymbol!("_objc_msgSendSuper_stret")(TYhfunc);
else
return setMsgSendSymbol!("_objc_msgSendSuper")(TYnfunc);
}
@ -1209,11 +1209,10 @@ 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");
}

View file

@ -525,11 +525,10 @@ 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");
}
@ -1057,7 +1056,7 @@ extern (C++) struct Target
TypeTuple tt = toArgTypes_sysv_x64(tn);
if (!tt)
return false; // void
else
return !tt.arguments.length;
}
@ -1144,7 +1143,7 @@ extern (C++) struct Target
{
if (tns.ty == TY.Tcomplex32)
return false; // in EDX:EAX, not ST1:ST0
else
return true;
}
else if (os == Target.OS.Windows &&
@ -1257,9 +1256,8 @@ 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");
case floatAbi.stringof:
return stringExp("hard");
@ -1555,7 +1553,7 @@ struct TargetCPP
return toCppMangleItanium(s);
if (target.os == Target.OS.Windows)
return toCppMangleMSVC(s);
else
assert(0, "fix this");
}
@ -1575,7 +1573,7 @@ struct TargetCPP
return cppTypeInfoMangleItanium(cd);
if (target.os == Target.OS.Windows)
return cppTypeInfoMangleMSVC(cd);
else
assert(0, "fix this");
}
@ -1645,7 +1643,7 @@ 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;
}
}