-
Notifications
You must be signed in to change notification settings - Fork 84
Cleanup reporting of dead code #785
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
Changes from all commits
36f4dc5
9e754a6
924c219
7eaf367
57fcc31
884c8dd
15186b0
f7154da
b2e38e9
be1b4db
4d998c4
9f76a64
ab670af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -881,6 +881,31 @@ | |
| } | ||
| }, | ||
| "additionalProperties": false | ||
| }, | ||
| "dead-code" : { | ||
| "title": "ana.dead-code", | ||
| "type": "object", | ||
| "properties": { | ||
| "lines": { | ||
| "title": "ana.dead-code.lines", | ||
| "description": "Print information about lines of dead code.", | ||
| "type": "boolean", | ||
| "default": true | ||
| }, | ||
| "branches": { | ||
| "title": "ana.dead-code.branches", | ||
| "description": "Print information about dead branches.", | ||
| "type": "boolean", | ||
| "default": true | ||
| }, | ||
| "functions": { | ||
| "title": "ana.dead-code.functions", | ||
| "description": "Print information about dead (uncalled) functions.", | ||
| "type": "boolean", | ||
| "default": true | ||
| } | ||
| }, | ||
| "additionalProperties": false | ||
| } | ||
| }, | ||
| "additionalProperties": false | ||
|
|
@@ -1373,12 +1398,6 @@ | |
| }, | ||
| "additionalProperties": false | ||
| }, | ||
| "uncalled": { | ||
| "title": "dbg.uncalled", | ||
| "description": "Display uncalled functions.", | ||
| "type": "boolean", | ||
| "default": true | ||
| }, | ||
| "dump": { | ||
| "title": "dbg.dump", | ||
| "description": "Dumps the results to the given path", | ||
|
|
@@ -1433,12 +1452,6 @@ | |
| "type": "boolean", | ||
| "default": false | ||
| }, | ||
| "print_dead_code": { | ||
| "title": "dbg.print_dead_code", | ||
| "description": "Print information about dead code", | ||
| "type": "boolean", | ||
| "default": false | ||
| }, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just as a post-merge note: the renaming of
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True! |
||
| "slice": { | ||
| "title": "dbg.slice", | ||
| "type": "object", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if
loc.syntheticis the appropriate thing to base this output on, because the location being synthetic doesn't necessarily correspond to anIfthat CIL created. In some cases it does, e.g. ina && b, whenbhas a constant value, then there's a dead branch in that CIL-createdIfand its location is synthetic because there's no program point in the original source code between the evaluation ofaandb, which is why the location is synthetic.I haven't checked with this PR, but I'm suspicious about cases like the following:
a && b, whenahas a constant value and there's a dead branch in that CIL-createdIf, then there is a program point (right before the whole expression) where an invariant assert (which the synthetic locations are for) aboutacould be inserted. So that location needn't be synthetic, it might currently be since synthetic locations are probably assigned more crudely than necessary, but if that is ever improved, then the output about a dead branch would actually become more wrong.forloops are transformed by CIL, the branching node (for which the branching expression literally exists in the original source code!) has a synthetic location, because an (assert) statement cannot be inserted between theforinitializer and condition.Maybe it's something we should address separately in the future, for example by adding
syntheticfields to CIL statements (such that it's explicit whichIfs were added by CIL) and variables (such that it's explicit which temporaries, etc it came up with) instead of semi-heuristics for these.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that sounds like a good idea. However, I'd think that we should do this in an new issue & PR.