Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dead debug/version level logic #20802

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions compiler/src/dmd/astbase.d
Original file line number Diff line number Diff line change
Expand Up @@ -451,16 +451,13 @@

extern (C++) final class DebugSymbol : Dsymbol
{
uint level;

extern (D) this(const ref Loc loc, Identifier ident)
{
super(ident);
this.loc = loc;
}
extern (D) this(const ref Loc loc, uint level)
extern (D) this(const ref Loc loc)

Check warning on line 459 in compiler/src/dmd/astbase.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/astbase.d#L459

Added line #L459 was not covered by tests
{
this.level = level;
this.loc = loc;
}

Expand All @@ -472,16 +469,13 @@

extern (C++) final class VersionSymbol : Dsymbol
{
uint level;

extern (D) this(const ref Loc loc, Identifier ident)
{
super(ident);
this.loc = loc;
}
extern (D) this(const ref Loc loc, uint level)
extern (D) this(const ref Loc loc)

Check warning on line 477 in compiler/src/dmd/astbase.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/astbase.d#L477

Added line #L477 was not covered by tests
{
this.level = level;
this.loc = loc;
}

Expand Down Expand Up @@ -6542,11 +6536,10 @@

extern (C++) class DVCondition : Condition
{
uint level;
Identifier ident;
Module mod;

final extern (D) this(const ref Loc loc, Module mod, uint level, Identifier ident)
final extern (D) this(const ref Loc loc, Module mod, Identifier ident)

Check warning on line 6542 in compiler/src/dmd/astbase.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/astbase.d#L6542

Added line #L6542 was not covered by tests
{
super(loc);
this.mod = mod;
Expand All @@ -6561,9 +6554,9 @@

extern (C++) final class DebugCondition : DVCondition
{
extern (D) this(const ref Loc loc, Module mod, uint level, Identifier ident)
extern (D) this(const ref Loc loc, Module mod, Identifier ident)

Check warning on line 6557 in compiler/src/dmd/astbase.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/astbase.d#L6557

Added line #L6557 was not covered by tests
{
super(loc, mod, level, ident);
super(loc, mod, ident);

Check warning on line 6559 in compiler/src/dmd/astbase.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/astbase.d#L6559

Added line #L6559 was not covered by tests
}

override void accept(Visitor v)
Expand All @@ -6574,9 +6567,9 @@

extern (C++) final class VersionCondition : DVCondition
{
extern (D) this(const ref Loc loc, Module mod, uint level, Identifier ident)
extern (D) this(const ref Loc loc, Module mod, Identifier ident)

Check warning on line 6570 in compiler/src/dmd/astbase.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/astbase.d#L6570

Added line #L6570 was not covered by tests
{
super(loc, mod, level, ident);
super(loc, mod, ident);

Check warning on line 6572 in compiler/src/dmd/astbase.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/astbase.d#L6572

Added line #L6572 was not covered by tests
}

override void accept(Visitor v)
Expand Down
23 changes: 7 additions & 16 deletions compiler/src/dmd/cond.d
Original file line number Diff line number Diff line change
Expand Up @@ -493,15 +493,13 @@ extern (C++) final class StaticForeach : RootObject
*/
extern (C++) class DVCondition : Condition
{
uint level;
Identifier ident;
Module mod;

extern (D) this(const ref Loc loc, Module mod, uint level, Identifier ident) @safe
extern (D) this(const ref Loc loc, Module mod, Identifier ident) @safe
{
super(loc);
this.mod = mod;
this.level = level;
this.ident = ident;
}

Expand Down Expand Up @@ -556,15 +554,13 @@ extern (C++) final class DebugCondition : DVCondition
*
* Params:
* mod = Module this node belongs to
* level = Minimum global level this condition needs to pass.
* Only used if `ident` is `null`.
* ident = Identifier required for this condition to pass.
* If `null`, this conditiion will use an integer level.
* loc = Location in the source file
*/
extern (D) this(const ref Loc loc, Module mod, uint level, Identifier ident) @safe
extern (D) this(const ref Loc loc, Module mod, Identifier ident) @safe
{
super(loc, mod, level, ident);
super(loc, mod, ident);
}

override int include(Scope* sc)
Expand Down Expand Up @@ -592,8 +588,9 @@ extern (C++) final class DebugCondition : DVCondition
mod.debugidsNot.push(ident);
}
}
else if (level <= global.params.debuglevel || level <= mod.debuglevel)
else if (global.params.debugEnabled)
inc = Include.yes;

if (!definedInModule)
printDepsConditional(sc, this, "depsDebug ");
return (inc == Include.yes);
Expand Down Expand Up @@ -837,15 +834,13 @@ extern (C++) final class VersionCondition : DVCondition
*
* Params:
* mod = Module this node belongs to
* level = Minimum global level this condition needs to pass.
* Only used if `ident` is `null`.
* ident = Identifier required for this condition to pass.
* If `null`, this conditiion will use an integer level.
* loc = Location in the source file
*/
extern (D) this(const ref Loc loc, Module mod, uint level, Identifier ident) @safe
extern (D) this(const ref Loc loc, Module mod, Identifier ident) @safe
{
super(loc, mod, level, ident);
super(loc, mod, ident);
}

override int include(Scope* sc)
Expand Down Expand Up @@ -875,8 +870,6 @@ extern (C++) final class VersionCondition : DVCondition
mod.versionidsNot.push(ident);
}
}
else if (level <= global.params.versionlevel || level <= mod.versionlevel)
inc = Include.yes;
if (!definedInModule &&
(!ident || (!isReserved(ident.toString()) && ident != Id._unittest && ident != Id._assert)))
{
Expand Down Expand Up @@ -1010,7 +1003,5 @@ private void printDepsConditional(Scope* sc, DVCondition condition, const(char)[
ob.writestring(") : ");
if (condition.ident)
ob.writestring(condition.ident.toString());
else
ob.print(condition.level);
ob.writeByte('\n');
}
1 change: 0 additions & 1 deletion compiler/src/dmd/cond.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class StaticForeach final : public RootObject
class DVCondition : public Condition
{
public:
unsigned level;
Identifier *ident;
Module *mod;

Expand Down
2 changes: 0 additions & 2 deletions compiler/src/dmd/dmodule.d
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,9 @@ extern (C++) final class Module : Package

Modules aimports; // all imported modules

uint debuglevel; // debug level
Identifiers* debugids; // debug identifiers
Identifiers* debugidsNot; // forward referenced debug identifiers

uint versionlevel; // version level
Identifiers* versionids; // version identifiers
Identifiers* versionidsNot; // forward referenced version identifiers

Expand Down
61 changes: 18 additions & 43 deletions compiler/src/dmd/dsymbolsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -4352,34 +4352,21 @@
Module m = sds.isModule();
// Do not add the member to the symbol table,
// just make sure subsequent debug declarations work.
if (ds.ident)
if (!m)
{
if (!m)
{
.error(ds.loc, "%s `%s` declaration must be at module level", ds.kind, ds.toPrettyChars);
ds.errors = true;
}
else
{
if (m.debugidsNot && findCondition(*m.debugidsNot, ds.ident))
{
.error(ds.loc, "%s `%s` defined after use", ds.kind, ds.toPrettyChars);
ds.errors = true;
}
if (!m.debugids)
m.debugids = new Identifiers();
m.debugids.push(ds.ident);
}
.error(ds.loc, "%s `%s` declaration must be at module level", ds.kind, ds.toPrettyChars);
ds.errors = true;

Check warning on line 4358 in compiler/src/dmd/dsymbolsem.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/dsymbolsem.d#L4357-L4358

Added lines #L4357 - L4358 were not covered by tests
}
else
{
if (!m)
if (m.debugidsNot && findCondition(*m.debugidsNot, ds.ident))
{
.error(ds.loc, "%s `%s` level declaration must be at module level", ds.kind, ds.toPrettyChars);
.error(ds.loc, "%s `%s` defined after use", ds.kind, ds.toPrettyChars);

Check warning on line 4364 in compiler/src/dmd/dsymbolsem.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/dsymbolsem.d#L4364

Added line #L4364 was not covered by tests
ds.errors = true;
}
else
m.debuglevel = ds.level;
if (!m.debugids)
m.debugids = new Identifiers();
m.debugids.push(ds.ident);
}
}

Expand All @@ -4389,36 +4376,24 @@
Module m = sds.isModule();
// Do not add the member to the symbol table,
// just make sure subsequent debug declarations work.
if (vs.ident)
VersionCondition.checkReserved(vs.loc, vs.ident.toString());
if (!m)
{
VersionCondition.checkReserved(vs.loc, vs.ident.toString());
if (!m)
{
.error(vs.loc, "%s `%s` declaration must be at module level", vs.kind, vs.toPrettyChars);
vs.errors = true;
}
else
{
if (m.versionidsNot && findCondition(*m.versionidsNot, vs.ident))
{
.error(vs.loc, "%s `%s` defined after use", vs.kind, vs.toPrettyChars);
vs.errors = true;
}
if (!m.versionids)
m.versionids = new Identifiers();
m.versionids.push(vs.ident);
}
.error(vs.loc, "%s `%s` declaration must be at module level", vs.kind, vs.toPrettyChars);
vs.errors = true;

Check warning on line 4383 in compiler/src/dmd/dsymbolsem.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/dsymbolsem.d#L4382-L4383

Added lines #L4382 - L4383 were not covered by tests
}
else
{
if (!m)
if (m.versionidsNot && findCondition(*m.versionidsNot, vs.ident))
{
.error(vs.loc, "%s `%s` level declaration must be at module level", vs.kind, vs.toPrettyChars);
.error(vs.loc, "%s `%s` defined after use", vs.kind, vs.toPrettyChars);

Check warning on line 4389 in compiler/src/dmd/dsymbolsem.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/dsymbolsem.d#L4389

Added line #L4389 was not covered by tests
vs.errors = true;
}
else
m.versionlevel = vs.level;
if (!m.versionids)
m.versionids = new Identifiers();
m.versionids.push(vs.ident);
}

}

override void visit(Nspace ns)
Expand Down
33 changes: 3 additions & 30 deletions compiler/src/dmd/dversion.d
Original file line number Diff line number Diff line change
Expand Up @@ -29,41 +29,27 @@
/***********************************************************
* DebugSymbol's happen for statements like:
* debug = identifier;
* debug = integer;
*/
extern (C++) final class DebugSymbol : Dsymbol
{
uint level;

extern (D) this(const ref Loc loc, Identifier ident) @safe
{
super(loc, ident);
}

extern (D) this(const ref Loc loc, uint level) @safe
extern (D) this(const ref Loc loc) @safe

Check warning on line 40 in compiler/src/dmd/dversion.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/dversion.d#L40

Added line #L40 was not covered by tests
{
super(loc, null);
this.level = level;
}

override DebugSymbol syntaxCopy(Dsymbol s)
{
assert(!s);
auto ds = new DebugSymbol(loc, ident);
ds.comment = comment;
ds.level = level;
return ds;
}

override const(char)* toChars() const nothrow
{
if (ident)
return ident.toChars();
OutBuffer buf;
buf.print(level);
return buf.extractChars();
}

override const(char)* kind() const nothrow
{
return "debug";
Expand All @@ -83,41 +69,28 @@
/***********************************************************
* VersionSymbol's happen for statements like:
* version = identifier;
* version = integer;
*/
extern (C++) final class VersionSymbol : Dsymbol
{
uint level;

extern (D) this(const ref Loc loc, Identifier ident) @safe
{
super(loc, ident);
}

extern (D) this(const ref Loc loc, uint level) @safe
extern (D) this(const ref Loc loc) @safe

Check warning on line 81 in compiler/src/dmd/dversion.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/dversion.d#L81

Added line #L81 was not covered by tests
{
super(loc, null);
this.level = level;
}

override VersionSymbol syntaxCopy(Dsymbol s)
{
assert(!s);
auto ds = ident ? new VersionSymbol(loc, ident)
: new VersionSymbol(loc, level);
auto ds = new VersionSymbol(loc, ident);

Check warning on line 89 in compiler/src/dmd/dversion.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/dversion.d#L89

Added line #L89 was not covered by tests
ds.comment = comment;
return ds;
}

override const(char)* toChars() const nothrow
{
if (ident)
return ident.toChars();
OutBuffer buf;
buf.print(level);
return buf.extractChars();
}

override const(char)* kind() const nothrow
{
return "version";
Expand Down
Loading
Loading