mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00
refactor nested reference checking (#16693)
This commit is contained in:
parent
cfdbf560ef
commit
f727e7fb36
13 changed files with 19 additions and 36 deletions
|
@ -237,8 +237,7 @@ extern (C++) class StorageClassDeclaration : AttribDeclaration
|
|||
* before the semantic analysis of 'to', so that template overloading based on the
|
||||
* 'this' pointer can be successful.
|
||||
*/
|
||||
FuncDeclaration fd = ps.isFuncDeclaration();
|
||||
if (fd)
|
||||
if (FuncDeclaration fd = ps.isFuncDeclaration())
|
||||
{
|
||||
/* Use storage_class2 instead of storage_class otherwise when we do .di generation
|
||||
* we'll wind up with 'const const' rather than 'const'.
|
||||
|
|
|
@ -99,8 +99,7 @@ StorageClass mergeFuncAttrs(StorageClass s1, const FuncDeclaration f) pure
|
|||
*/
|
||||
FuncDeclaration hasIdentityOpAssign(AggregateDeclaration ad, Scope* sc)
|
||||
{
|
||||
Dsymbol assign = search_function(ad, Id.assign);
|
||||
if (assign)
|
||||
if (Dsymbol assign = search_function(ad, Id.assign))
|
||||
{
|
||||
/* check identity opAssign exists
|
||||
*/
|
||||
|
|
|
@ -826,8 +826,7 @@ private final class CppMangleVisitor : Visitor
|
|||
return buf.writestring("St");
|
||||
|
||||
auto si = getInstance(s);
|
||||
Dsymbol p = getQualifier(si);
|
||||
if (p)
|
||||
if (Dsymbol p = getQualifier(si))
|
||||
{
|
||||
if (isStd(p))
|
||||
{
|
||||
|
|
|
@ -490,8 +490,7 @@ extern (C++) class ClassDeclaration : AggregateDeclaration
|
|||
return null;
|
||||
if (cdb.ident.equals(ident))
|
||||
return cdb;
|
||||
auto result = cdb.searchBase(ident);
|
||||
if (result)
|
||||
if (auto result = cdb.searchBase(ident))
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -1238,8 +1238,7 @@ extern (C++) class VarDeclaration : Declaration
|
|||
*/
|
||||
for (auto s = cast(Dsymbol)this; s; s = s.parent)
|
||||
{
|
||||
auto ad = (cast(inout)s).isMember();
|
||||
if (ad)
|
||||
if (auto ad = (cast(inout)s).isMember())
|
||||
return ad;
|
||||
if (!s.parent || !s.parent.isTemplateMixin())
|
||||
break;
|
||||
|
|
|
@ -495,8 +495,7 @@ extern (C++) struct Scope
|
|||
if (global.params.fixAliasThis)
|
||||
{
|
||||
Expression exp = new ThisExp(loc);
|
||||
Dsymbol aliasSym = checkAliasThis(sc.scopesym.isAggregateDeclaration(), ident, flags, &exp);
|
||||
if (aliasSym)
|
||||
if (Dsymbol aliasSym = checkAliasThis(sc.scopesym.isAggregateDeclaration(), ident, flags, &exp))
|
||||
{
|
||||
//printf("found aliassym: %s\n", aliasSym.toChars());
|
||||
pscopesym = new ExpressionDsymbol(exp);
|
||||
|
|
|
@ -396,8 +396,7 @@ extern (C++) class Dsymbol : ASTNode
|
|||
while (s)
|
||||
{
|
||||
//printf("\ts = %s '%s'\n", s.kind(), s.toPrettyChars());
|
||||
Module m = s.isModule();
|
||||
if (m)
|
||||
if (Module m = s.isModule())
|
||||
return m;
|
||||
s = s.parent;
|
||||
}
|
||||
|
@ -428,8 +427,7 @@ extern (C++) class Dsymbol : ASTNode
|
|||
while (s)
|
||||
{
|
||||
//printf("\ts = %s '%s'\n", s.kind(), s.toPrettyChars());
|
||||
Module m = s.isModule();
|
||||
if (m)
|
||||
if (Module m = s.isModule())
|
||||
return m;
|
||||
TemplateInstance ti = s.isTemplateInstance();
|
||||
if (ti && ti.enclosing)
|
||||
|
|
|
@ -431,8 +431,7 @@ extern (C++) class FuncDeclaration : Declaration
|
|||
{
|
||||
//printf("FuncDeclaration::overloadInsert(s = %s) this = %s\n", s.toChars(), toChars());
|
||||
assert(s != this);
|
||||
AliasDeclaration ad = s.isAliasDeclaration();
|
||||
if (ad)
|
||||
if (AliasDeclaration ad = s.isAliasDeclaration())
|
||||
{
|
||||
if (overnext)
|
||||
return overnext.overloadInsert(ad);
|
||||
|
@ -501,8 +500,7 @@ extern (C++) class FuncDeclaration : Declaration
|
|||
while (f && f.overnext)
|
||||
{
|
||||
//printf("f.overnext = %p %s\n", f.overnext, f.overnext.toChars());
|
||||
TemplateDeclaration td = f.overnext.isTemplateDeclaration();
|
||||
if (td)
|
||||
if (TemplateDeclaration td = f.overnext.isTemplateDeclaration())
|
||||
return td;
|
||||
f = f.overnext.isFuncDeclaration();
|
||||
}
|
||||
|
@ -1731,8 +1729,7 @@ extern (C++) final class FuncLiteralDeclaration : FuncDeclaration
|
|||
{
|
||||
if (parent)
|
||||
{
|
||||
TemplateInstance ti = parent.isTemplateInstance();
|
||||
if (ti)
|
||||
if (TemplateInstance ti = parent.isTemplateInstance())
|
||||
return ti.tempdecl.toPrettyChars(QualifyTypes);
|
||||
}
|
||||
return Dsymbol.toPrettyChars(QualifyTypes);
|
||||
|
|
|
@ -1047,8 +1047,7 @@ Ldone:
|
|||
}
|
||||
|
||||
// If it's a member template
|
||||
ClassDeclaration cd = ti.tempdecl.isClassMember();
|
||||
if (cd)
|
||||
if (ClassDeclaration cd = ti.tempdecl.isClassMember())
|
||||
{
|
||||
.error(funcdecl.loc, "%s `%s` cannot use template to add virtual function to class `%s`", funcdecl.kind, funcdecl.toPrettyChars, cd.toChars());
|
||||
}
|
||||
|
|
|
@ -1239,11 +1239,9 @@ public:
|
|||
void scanVar(Dsymbol s)
|
||||
{
|
||||
//printf("scanVar(%s %s)\n", s.kind(), s.toPrettyChars());
|
||||
VarDeclaration vd = s.isVarDeclaration();
|
||||
if (vd)
|
||||
if (VarDeclaration vd = s.isVarDeclaration())
|
||||
{
|
||||
TupleDeclaration td = vd.toAlias().isTupleDeclaration();
|
||||
if (td)
|
||||
if (TupleDeclaration td = vd.toAlias().isTupleDeclaration())
|
||||
{
|
||||
td.foreachVar((s)
|
||||
{
|
||||
|
|
|
@ -1197,8 +1197,7 @@ private size_t emitVtbl(ref DtBuilder dtb, BaseClass *b, ref FuncDeclarations bv
|
|||
|
||||
foreach (j; jstart .. id_vtbl_dim)
|
||||
{
|
||||
FuncDeclaration fd = bvtbl[j];
|
||||
if (fd)
|
||||
if (FuncDeclaration fd = bvtbl[j])
|
||||
{
|
||||
auto offset2 = b.offset;
|
||||
if (fd.interfaceVirtual)
|
||||
|
|
|
@ -38,8 +38,7 @@ class Statement : Node
|
|||
{
|
||||
foreach(m; members)
|
||||
{
|
||||
Value v = m.interpret(sc);
|
||||
if(v)
|
||||
if (Value v = m.interpret(sc))
|
||||
return v;
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -1609,7 +1609,7 @@ struct Gcx
|
|||
void Invariant() const { }
|
||||
|
||||
debug(INVARIANT)
|
||||
invariant()
|
||||
invariant
|
||||
{
|
||||
if (initialized)
|
||||
{
|
||||
|
@ -3171,8 +3171,7 @@ Lmark:
|
|||
{
|
||||
// first, we find the Pool this block is in, then check to see if the
|
||||
// mark bit is clear.
|
||||
auto pool = findPool(addr);
|
||||
if (pool)
|
||||
if (auto pool = findPool(addr))
|
||||
{
|
||||
auto offset = cast(size_t)(addr - pool.baseAddr);
|
||||
auto pn = offset / PAGESIZE;
|
||||
|
@ -3924,7 +3923,7 @@ struct Pool
|
|||
void Invariant() const {}
|
||||
|
||||
debug(INVARIANT)
|
||||
invariant()
|
||||
invariant
|
||||
{
|
||||
if (baseAddr)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue