Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
d1c21a20
Commit
d1c21a20
authored
4 years ago
by
David Bühler
Browse files
Options
Downloads
Patches
Plain Diff
[Eva] New requests for unreachable and non terminating statements in a function.
parent
55392f04
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/value/api/general_requests.ml
+71
-0
71 additions, 0 deletions
src/plugins/value/api/general_requests.ml
with
71 additions
and
0 deletions
src/plugins/value/api/general_requests.ml
+
71
−
0
View file @
d1c21a20
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
(**************************************************************************)
(**************************************************************************)
open
Server
open
Server
open
Cil_types
let
package
=
let
package
=
Package
.
package
Package
.
package
...
@@ -30,6 +31,13 @@ let package =
...
@@ -30,6 +31,13 @@ let package =
~
readme
:
"eva.md"
~
readme
:
"eva.md"
()
()
let
is_computed
kf
=
Db
.
Value
.
is_computed
()
&&
match
kf
with
|
{
fundec
=
Definition
(
fundec
,
_
)
}
->
Mark_noresults
.
should_memorize_function
fundec
|
{
fundec
=
Declaration
_
}
->
false
module
CallSite
=
Data
.
Jpair
(
Kernel_ast
.
Kf
)
(
Kernel_ast
.
Stmt
)
module
CallSite
=
Data
.
Jpair
(
Kernel_ast
.
Kf
)
(
Kernel_ast
.
Stmt
)
let
callers
kf
=
let
callers
kf
=
...
@@ -42,4 +50,67 @@ let () = Request.register ~package
...
@@ -42,4 +50,67 @@ let () = Request.register ~package
~
input
:
(
module
Kernel_ast
.
Kf
)
~
output
:
(
module
Data
.
Jlist
(
CallSite
))
~
input
:
(
module
Kernel_ast
.
Kf
)
~
output
:
(
module
Data
.
Jlist
(
CallSite
))
callers
callers
(* ----- Dead code: unreachable and non-terminating statements -------------- *)
type
dead_code
=
{
kf
:
Kernel_function
.
t
;
unreachable
:
stmt
list
;
non_terminating
:
stmt
list
;
}
module
DeadCode
=
struct
open
Server
.
Data
type
record
let
record
:
record
Record
.
signature
=
Record
.
signature
()
let
unreachable
=
Record
.
field
record
~
name
:
"unreachable"
~
descr
:
(
Markdown
.
plain
"List of unreachable statements."
)
(
module
Data
.
Jlist
(
Kernel_ast
.
Marker
))
let
non_terminating
=
Record
.
field
record
~
name
:
"nonTerminating"
~
descr
:
(
Markdown
.
plain
"List of reachable but non terminating statements."
)
(
module
Data
.
Jlist
(
Kernel_ast
.
Marker
))
let
data
=
Record
.
publish
record
~
package
~
name
:
"deadCode"
~
descr
:
(
Markdown
.
plain
"Unreachable and non terminating statements."
)
module
R
:
Record
.
S
with
type
r
=
record
=
(
val
data
)
type
t
=
dead_code
let
jtype
=
R
.
jtype
let
to_json
(
dead_code
)
=
let
make_unreachable
stmt
=
Printer_tag
.
PStmt
(
dead_code
.
kf
,
stmt
)
and
make_non_term
stmt
=
Printer_tag
.
PStmtStart
(
dead_code
.
kf
,
stmt
)
in
R
.
default
|>
R
.
set
unreachable
(
List
.
map
make_unreachable
dead_code
.
unreachable
)
|>
R
.
set
non_terminating
(
List
.
map
make_non_term
dead_code
.
non_terminating
)
|>
R
.
to_json
end
let
dead_code
kf
=
let
empty
=
{
kf
;
unreachable
=
[]
;
non_terminating
=
[]
}
in
if
is_computed
kf
then
let
module
Results
=
(
val
Analysis
.
current_analyzer
()
)
in
let
is_unreachable
~
after
stmt
=
Results
.
get_stmt_state
~
after
stmt
=
`Bottom
in
let
classify
acc
stmt
=
if
is_unreachable
~
after
:
false
stmt
then
{
acc
with
unreachable
=
stmt
::
acc
.
unreachable
}
else
if
is_unreachable
~
after
:
true
stmt
then
{
acc
with
non_terminating
=
stmt
::
acc
.
non_terminating
}
else
acc
in
let
fundec
=
Kernel_function
.
get_definition
kf
in
List
.
fold_left
classify
empty
fundec
.
sallstmts
else
empty
let
()
=
Request
.
register
~
package
~
kind
:
`GET
~
name
:
"getDeadCode"
~
descr
:
(
Markdown
.
plain
"Get the lists of unreachable and of non terminating \
statements in a function"
)
~
input
:
(
module
Kernel_ast
.
Kf
)
~
output
:
(
module
DeadCode
)
dead_code
(**************************************************************************)
(**************************************************************************)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment