Skip to content

Commit

Permalink
Suppress reporting dead fields/methods if name ends in _
Browse files Browse the repository at this point in the history
  • Loading branch information
titzer committed Jul 25, 2024
1 parent e415d02 commit afefccb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions aeneas/src/ir/Reachability.v3
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ class DeadCodeAnalyzer(ra: ReachabilityAnalyzer) {
// report dead fields if any
for (f in ic.fields) {
if (ic.inherits(f)) continue;
if (!f.facts.X_LIVE) {
if (reportDead(f)) {
if (buf.length == 0) addLine("within ", ic);
buf.puts(" dead field: ");
f.render(buf.red());
Expand All @@ -899,7 +899,7 @@ class DeadCodeAnalyzer(ra: ReachabilityAnalyzer) {
if (m == null) continue;
if (ic.inherits(m)) continue;
if (m.facts.M_EMPTY) continue;
if (!m.facts.X_LIVE) {
if (reportDead(m)) {
if (buf.length == 0) addLine("within ", ic);
buf.puts(" dead method: ");
m.render(buf.red());
Expand All @@ -909,6 +909,15 @@ class DeadCodeAnalyzer(ra: ReachabilityAnalyzer) {
}
buf.outt();
}
def reportDead(m: IrMember) -> bool {
if (m.facts.X_LIVE) return false;
// Don't report dead fields or methods whose names end with "_".
match (m) {
x: IrField => return x.source != null && !Strings.endsWith(x.source.name(), "_");
x: IrMethod => return x.source != null && !Strings.endsWith(x.source.name(), "_");
}
return true;
}
def addLine(p: string, ic: IrClass) {
buf.puts(p);
if (V3.isVariant(ic.ctype)) buf.puts("variant ");
Expand Down
2 changes: 1 addition & 1 deletion aeneas/src/main/Version.v3
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

// Updated by VCS scripts. DO NOT EDIT.
component Version {
def version: string = "III-7.1748";
def version: string = "III-7.1749";
var buildData: string;
}

0 comments on commit afefccb

Please sign in to comment.