mirror of
https://github.com/dlang/dmd.git
synced 2025-04-28 22:20:37 +03:00
Remove redundant else (#20751)
This commit is contained in:
parent
080a4d840f
commit
71213dfbf8
10 changed files with 60 additions and 77 deletions
|
@ -194,7 +194,6 @@ private struct ModuleComponentRange
|
||||||
return packages[index];
|
return packages[index];
|
||||||
if (index == packages.length)
|
if (index == packages.length)
|
||||||
return name;
|
return name;
|
||||||
else
|
|
||||||
return Identifier.idPool("package");
|
return Identifier.idPool("package");
|
||||||
}
|
}
|
||||||
void popFront() @safe { index++; }
|
void popFront() @safe { index++; }
|
||||||
|
|
|
@ -1529,12 +1529,10 @@ Expression ctfeCast(UnionExp* pue, const ref Loc loc, Type type, Type to, Expres
|
||||||
: tclass.implicitConvTo(to.mutableOf());
|
: tclass.implicitConvTo(to.mutableOf());
|
||||||
if (match)
|
if (match)
|
||||||
return paint();
|
return paint();
|
||||||
else
|
|
||||||
{
|
|
||||||
emplaceExp!(NullExp)(pue, loc, to);
|
emplaceExp!(NullExp)(pue, loc, to);
|
||||||
return pue.exp();
|
return pue.exp();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Allow TypeInfo type painting
|
// Allow TypeInfo type painting
|
||||||
if (isTypeInfo_Class(e.type) && e.type.implicitConvTo(to))
|
if (isTypeInfo_Class(e.type) && e.type.implicitConvTo(to))
|
||||||
|
|
|
@ -217,17 +217,12 @@ Dsymbol getDsymbol(RootObject oarg)
|
||||||
return te.td;
|
return te.td;
|
||||||
if (auto te = ea.isScopeExp())
|
if (auto te = ea.isScopeExp())
|
||||||
return te.sds;
|
return te.sds;
|
||||||
else
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// Try to convert Type to symbol
|
// Try to convert Type to symbol
|
||||||
if (auto ta = isType(oarg))
|
if (auto ta = isType(oarg))
|
||||||
return ta.toDsymbol(null);
|
return ta.toDsymbol(null);
|
||||||
else
|
|
||||||
return isDsymbol(oarg); // if already a symbol
|
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())
|
if (auto ttp = tp.isTemplateTupleParameter())
|
||||||
return matchArgTuple(ttp);
|
return matchArgTuple(ttp);
|
||||||
else
|
|
||||||
return matchArgParameter();
|
return matchArgParameter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6221,7 +6216,7 @@ void printTemplateStats(bool listInstances, ErrorSink eSink)
|
||||||
auto diff = b.ts.uniqueInstantiations - a.ts.uniqueInstantiations;
|
auto diff = b.ts.uniqueInstantiations - a.ts.uniqueInstantiations;
|
||||||
if (diff)
|
if (diff)
|
||||||
return diff;
|
return diff;
|
||||||
else
|
|
||||||
return b.ts.numInstantiations - a.ts.numInstantiations;
|
return b.ts.numInstantiations - a.ts.numInstantiations;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -581,7 +581,6 @@ extern (C++) class FuncDeclaration : Declaration
|
||||||
{
|
{
|
||||||
if (isMain())
|
if (isMain())
|
||||||
return "D main";
|
return "D main";
|
||||||
else
|
|
||||||
return Dsymbol.toPrettyChars(QualifyTypes);
|
return Dsymbol.toPrettyChars(QualifyTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2181,7 +2181,6 @@ void asm_merge_opnds(ref OPND o1, ref OPND o2)
|
||||||
{
|
{
|
||||||
if (o1.segreg)
|
if (o1.segreg)
|
||||||
return illegalAddressError("o1.segment && o2.segreg");
|
return illegalAddressError("o1.segment && o2.segreg");
|
||||||
else
|
|
||||||
o1.segreg = o2.segreg;
|
o1.segreg = o2.segreg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2266,7 +2265,7 @@ void asm_merge_opnds(ref OPND o1, ref OPND o2)
|
||||||
{
|
{
|
||||||
if (o1.pregDisp2)
|
if (o1.pregDisp2)
|
||||||
return illegalAddressError("o1.pregDisp2 && o2.pregDisp2");
|
return illegalAddressError("o1.pregDisp2 && o2.pregDisp2");
|
||||||
else
|
|
||||||
o1.pregDisp2 = o2.pregDisp2;
|
o1.pregDisp2 = o2.pregDisp2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2290,7 +2289,7 @@ void asm_merge_opnds(ref OPND o1, ref OPND o2)
|
||||||
{
|
{
|
||||||
if (o1.uchMultiplier)
|
if (o1.uchMultiplier)
|
||||||
return illegalAddressError("o1.uchMultiplier && o2.uchMultiplier");
|
return illegalAddressError("o1.uchMultiplier && o2.uchMultiplier");
|
||||||
else
|
|
||||||
o1.uchMultiplier = o2.uchMultiplier;
|
o1.uchMultiplier = o2.uchMultiplier;
|
||||||
}
|
}
|
||||||
if (o2.ptype && !o1.ptype)
|
if (o2.ptype && !o1.ptype)
|
||||||
|
|
|
@ -435,9 +435,9 @@ private final class CppMangleVisitor : Visitor
|
||||||
// 4. null pointer: std::nullptr_t (since C++11)
|
// 4. null pointer: std::nullptr_t (since C++11)
|
||||||
if (t.ty == Tvoid || t.ty == Tbool)
|
if (t.ty == Tvoid || t.ty == Tbool)
|
||||||
return true;
|
return true;
|
||||||
else if (t.ty == Tnull && global.params.cplusplus >= CppStdRevision.cpp11)
|
if (t.ty == Tnull && global.params.cplusplus >= CppStdRevision.cpp11)
|
||||||
return true;
|
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());
|
//printf("enum id = '%s'\n", id.toChars());
|
||||||
if (id == Id.__c_long)
|
if (id == Id.__c_long)
|
||||||
return writeBasicType(t, 0, 'l');
|
return writeBasicType(t, 0, 'l');
|
||||||
else if (id == Id.__c_ulong)
|
if (id == Id.__c_ulong)
|
||||||
return writeBasicType(t, 0, 'm');
|
return writeBasicType(t, 0, 'm');
|
||||||
else if (id == Id.__c_char)
|
if (id == Id.__c_char)
|
||||||
return writeBasicType(t, 0, 'c');
|
return writeBasicType(t, 0, 'c');
|
||||||
else if (id == Id.__c_wchar_t)
|
if (id == Id.__c_wchar_t)
|
||||||
return writeBasicType(t, 0, 'w');
|
return writeBasicType(t, 0, 'w');
|
||||||
else if (id == Id.__c_longlong)
|
if (id == Id.__c_longlong)
|
||||||
return writeBasicType(t, 0, 'x');
|
return writeBasicType(t, 0, 'x');
|
||||||
else if (id == Id.__c_ulonglong)
|
if (id == Id.__c_ulonglong)
|
||||||
return writeBasicType(t, 0, 'y');
|
return writeBasicType(t, 0, 'y');
|
||||||
else if (id == Id.__c_complex_float)
|
if (id == Id.__c_complex_float)
|
||||||
return Type.tcomplex32.accept(this);
|
return Type.tcomplex32.accept(this);
|
||||||
else if (id == Id.__c_complex_double)
|
if (id == Id.__c_complex_double)
|
||||||
return Type.tcomplex64.accept(this);
|
return Type.tcomplex64.accept(this);
|
||||||
else if (id == Id.__c_complex_real)
|
if (id == Id.__c_complex_real)
|
||||||
return Type.tcomplex80.accept(this);
|
return Type.tcomplex80.accept(this);
|
||||||
|
|
||||||
doSymbol(t);
|
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
|
// We need to see if there's more ident enclosing
|
||||||
if (auto pb = b.toParent().isNspace())
|
if (auto pb = b.toParent().isNspace())
|
||||||
return isNamespaceEqual(a.cppnamespace, pb);
|
return isNamespaceEqual(a.cppnamespace, pb);
|
||||||
else
|
|
||||||
return a.cppnamespace is null;
|
return a.cppnamespace is null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1295,16 +1295,14 @@ extern (C++) abstract class Type : ASTNode
|
||||||
{
|
{
|
||||||
if (t.isWildConst())
|
if (t.isWildConst())
|
||||||
return MODFlags.wild;
|
return MODFlags.wild;
|
||||||
else
|
|
||||||
return MODFlags.wildconst;
|
return MODFlags.wildconst;
|
||||||
}
|
}
|
||||||
else if (isWild())
|
if (isWild())
|
||||||
return MODFlags.wild;
|
return MODFlags.wild;
|
||||||
else if (isConst())
|
if (isConst())
|
||||||
return MODFlags.const_;
|
return MODFlags.const_;
|
||||||
else if (isMutable())
|
if (isMutable())
|
||||||
return MODFlags.mutable;
|
return MODFlags.mutable;
|
||||||
else
|
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -714,7 +714,7 @@ extern(C++) private final class Supported : Objc
|
||||||
{
|
{
|
||||||
if (cd.classKind == ClassKind.objc && fd.isStatic && !cd.objc.isMeta)
|
if (cd.classKind == ClassKind.objc && fd.isStatic && !cd.objc.isMeta)
|
||||||
return cd.objc.metaclass;
|
return cd.objc.metaclass;
|
||||||
else
|
|
||||||
return cd;
|
return cd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -805,10 +805,9 @@ extern(C++) private final class Supported : Objc
|
||||||
{
|
{
|
||||||
if (classDeclaration.baseClass)
|
if (classDeclaration.baseClass)
|
||||||
return getRuntimeMetaclass(classDeclaration.baseClass);
|
return getRuntimeMetaclass(classDeclaration.baseClass);
|
||||||
else
|
|
||||||
return classDeclaration;
|
return classDeclaration;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return classDeclaration.objc.metaclass;
|
return classDeclaration.objc.metaclass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -604,7 +604,7 @@ static:
|
||||||
{
|
{
|
||||||
if (hasHiddenArgument)
|
if (hasHiddenArgument)
|
||||||
return setMsgSendSymbol!("_objc_msgSendSuper_stret")(TYhfunc);
|
return setMsgSendSymbol!("_objc_msgSendSuper_stret")(TYhfunc);
|
||||||
else
|
|
||||||
return setMsgSendSymbol!("_objc_msgSendSuper")(TYnfunc);
|
return setMsgSendSymbol!("_objc_msgSendSuper")(TYnfunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1209,11 +1209,10 @@ private:
|
||||||
if (var.toParent() is classDeclaration)
|
if (var.toParent() is classDeclaration)
|
||||||
return Symbols.getIVarOffset(classDeclaration, var, false);
|
return Symbols.getIVarOffset(classDeclaration, var, false);
|
||||||
|
|
||||||
else if (classDeclaration.baseClass)
|
if (classDeclaration.baseClass)
|
||||||
return ObjcClassDeclaration(classDeclaration.baseClass, false)
|
return ObjcClassDeclaration(classDeclaration.baseClass, false)
|
||||||
.getIVarOffset(var);
|
.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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -525,11 +525,10 @@ extern (C++) struct Target
|
||||||
{
|
{
|
||||||
if (os == Target.OS.OSX)
|
if (os == Target.OS.OSX)
|
||||||
return Target.ObjectFormat.macho;
|
return Target.ObjectFormat.macho;
|
||||||
else if (os & Target.OS.Posix)
|
if (os & Target.OS.Posix)
|
||||||
return Target.ObjectFormat.elf;
|
return Target.ObjectFormat.elf;
|
||||||
else if (os == Target.OS.Windows)
|
if (os == Target.OS.Windows)
|
||||||
return Target.ObjectFormat.coff;
|
return Target.ObjectFormat.coff;
|
||||||
else
|
|
||||||
assert(0, "unkown object format");
|
assert(0, "unkown object format");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1057,7 +1056,7 @@ extern (C++) struct Target
|
||||||
TypeTuple tt = toArgTypes_sysv_x64(tn);
|
TypeTuple tt = toArgTypes_sysv_x64(tn);
|
||||||
if (!tt)
|
if (!tt)
|
||||||
return false; // void
|
return false; // void
|
||||||
else
|
|
||||||
return !tt.arguments.length;
|
return !tt.arguments.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1144,7 +1143,7 @@ extern (C++) struct Target
|
||||||
{
|
{
|
||||||
if (tns.ty == TY.Tcomplex32)
|
if (tns.ty == TY.Tcomplex32)
|
||||||
return false; // in EDX:EAX, not ST1:ST0
|
return false; // in EDX:EAX, not ST1:ST0
|
||||||
else
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (os == Target.OS.Windows &&
|
else if (os == Target.OS.Windows &&
|
||||||
|
@ -1257,9 +1256,8 @@ extern (C++) struct Target
|
||||||
case objectFormat.stringof:
|
case objectFormat.stringof:
|
||||||
if (os == Target.OS.Windows)
|
if (os == Target.OS.Windows)
|
||||||
return stringExp("coff");
|
return stringExp("coff");
|
||||||
else if (os == Target.OS.OSX)
|
if (os == Target.OS.OSX)
|
||||||
return stringExp("macho");
|
return stringExp("macho");
|
||||||
else
|
|
||||||
return stringExp("elf");
|
return stringExp("elf");
|
||||||
case floatAbi.stringof:
|
case floatAbi.stringof:
|
||||||
return stringExp("hard");
|
return stringExp("hard");
|
||||||
|
@ -1555,7 +1553,7 @@ struct TargetCPP
|
||||||
return toCppMangleItanium(s);
|
return toCppMangleItanium(s);
|
||||||
if (target.os == Target.OS.Windows)
|
if (target.os == Target.OS.Windows)
|
||||||
return toCppMangleMSVC(s);
|
return toCppMangleMSVC(s);
|
||||||
else
|
|
||||||
assert(0, "fix this");
|
assert(0, "fix this");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1575,7 +1573,7 @@ struct TargetCPP
|
||||||
return cppTypeInfoMangleItanium(cd);
|
return cppTypeInfoMangleItanium(cd);
|
||||||
if (target.os == Target.OS.Windows)
|
if (target.os == Target.OS.Windows)
|
||||||
return cppTypeInfoMangleMSVC(cd);
|
return cppTypeInfoMangleMSVC(cd);
|
||||||
else
|
|
||||||
assert(0, "fix this");
|
assert(0, "fix this");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1645,7 +1643,7 @@ struct TargetCPP
|
||||||
// MSVC adds padding between base and derived fields if required.
|
// MSVC adds padding between base and derived fields if required.
|
||||||
if (target.os == Target.OS.Windows)
|
if (target.os == Target.OS.Windows)
|
||||||
return (baseClass.structsize + baseClass.alignsize - 1) & ~(baseClass.alignsize - 1);
|
return (baseClass.structsize + baseClass.alignsize - 1) & ~(baseClass.alignsize - 1);
|
||||||
else
|
|
||||||
return baseClass.structsize;
|
return baseClass.structsize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue