-
Notifications
You must be signed in to change notification settings - Fork 88
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 3 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 |
|---|---|---|
|
|
@@ -151,19 +151,21 @@ struct | |
| let warn_file f = StringMap.iter (warn_func f) in | ||
| if get_bool "dbg.print_dead_code" then ( | ||
| if StringMap.is_empty !dead_lines | ||
| then printf "No lines with dead code found by solver (there might still be dead code removed by CIL).\n" (* TODO https://github.com/goblint/analyzer/issues/94 *) | ||
| then printf "No lines with dead code found by solver%s.\n" (if GobConfig.get_bool "alldeadcode" then "" else "(there might still be dead code removed by CIL, try running with --enable alldeadcode to see all) ") (* TODO https://github.com/goblint/analyzer/issues/94 *) | ||
| else ( | ||
| StringMap.iter warn_file !dead_lines; (* populates count by side-effect *) | ||
| let total_dead = !count + uncalled_fn_loc in | ||
| printf "Found dead code on %d line%s%s!\n" total_dead (if total_dead>1 then "s" else "") (if uncalled_fn_loc > 0 then Printf.sprintf " (including %d in uncalled functions)" uncalled_fn_loc else "") | ||
| printf "Found dead code on %d line%s%s!\n" total_dead (if total_dead>1 then "s" else "") (if uncalled_fn_loc > 0 then Printf.sprintf " (including %d in uncalled functions)" uncalled_fn_loc else ""); | ||
| (if not @@ GobConfig.get_bool "alldeadcode" then printf "There might still be more dead code removed by CIL, try running with --enable alldeadcode to see all.\n") | ||
| ); | ||
| printf "Total lines (logical LoC): %d\n" (live_count + !count + uncalled_fn_loc); (* We can only give total LoC if we counted dead code *) | ||
| ); | ||
| let str = function true -> "then" | false -> "else" in | ||
| let cilinserted = function true -> "(possibly inserted by CIL) " | false -> "" in | ||
| let report tv (loc, dead) = | ||
| match dead, Deadcode.Locmap.find_option Deadcode.dead_branches_cond loc with | ||
| | true, Some exp -> M.warn ~loc ~category:Deadcode ~tags:[CWE (if tv then 570 else 571)] "the %s branch over expression '%a' is dead" (str tv) d_exp exp | ||
| | true, None -> M.warn ~loc ~category:Deadcode ~tags:[CWE (if tv then 570 else 571)] "an %s branch is dead" (str tv) | ||
| | true, Some exp -> M.warn ~loc ~category:Deadcode ~tags:[CWE (if tv then 570 else 571)] "the %s branch %sover expression '%a' is dead" (str tv) (cilinserted loc.synthetic) d_exp exp | ||
| | true, None -> M.warn ~loc ~category:Deadcode ~tags:[CWE (if tv then 570 else 571)] "an %s branch %sis dead" (str tv) (cilinserted loc.synthetic) | ||
|
Comment on lines
+166
to
+167
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. I'm not sure if I haven't checked with this PR, but I'm suspicious about cases like the following:
Maybe it's something we should address separately in the future, for example by adding
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. Yes, that sounds like a good idea. However, I'd think that we should do this in an new issue & PR. |
||
| | _ -> () | ||
| in | ||
| if get_bool "dbg.print_dead_code" then ( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.