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
51aee8f3
Commit
51aee8f3
authored
5 years ago
by
Virgile Prevosto
Browse files
Options
Downloads
Patches
Plain Diff
[logic] Cosmetic transformation
Converting a boolean `b` into predicate with `b != \false` is definitely too ugly.
parent
d9c0c704
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/kernel_services/ast_queries/logic_utils.ml
+11
-9
11 additions, 9 deletions
src/kernel_services/ast_queries/logic_utils.ml
with
11 additions
and
9 deletions
src/kernel_services/ast_queries/logic_utils.ml
+
11
−
9
View file @
51aee8f3
...
@@ -343,24 +343,24 @@ let is_zero_comparable t =
...
@@ -343,24 +343,24 @@ let is_zero_comparable t =
let
scalar_term_conversion
conversion
t
=
let
scalar_term_conversion
conversion
t
=
let
loc
=
t
.
term_loc
in
let
loc
=
t
.
term_loc
in
let
arith_conversion
()
=
conversion
~
loc
(
Cil
.
lzero
~
loc
()
)
t
in
let
arith_conversion
()
=
conversion
~
loc
false
t
(
Cil
.
lzero
~
loc
()
)
in
let
ptr_conversion
()
=
let
ptr_conversion
()
=
conversion
~
loc
(
Logic_const
.
term
~
loc
Tnull
t
.
term_type
)
t
conversion
~
loc
false
t
(
Logic_const
.
term
~
loc
Tnull
t
.
term_type
)
in
in
match
unroll_type
t
.
term_type
with
match
unroll_type
t
.
term_type
with
|
Ctype
(
TInt
_
)
->
arith_conversion
()
|
Ctype
(
TInt
_
)
->
arith_conversion
()
|
Ctype
(
TFloat
_
)
->
|
Ctype
(
TFloat
_
)
->
conversion
~
loc
(
Logic_const
.
treal_zero
~
loc
~
ltyp
:
t
.
term_type
()
)
t
conversion
~
loc
false
t
(
Logic_const
.
treal_zero
~
loc
~
ltyp
:
t
.
term_type
()
)
|
Ctype
(
TPtr
_
)
->
ptr_conversion
()
|
Ctype
(
TPtr
_
)
->
ptr_conversion
()
|
Ctype
(
TArray
_
)
->
ptr_conversion
()
|
Ctype
(
TArray
_
)
->
ptr_conversion
()
(* Could be transformed to \true: an array is never \null *)
(* Could be transformed to \true: an array is never \null *)
|
Ctype
(
TFun
_
)
->
ptr_conversion
()
|
Ctype
(
TFun
_
)
->
ptr_conversion
()
(* decay as pointer *)
(* decay as pointer *)
|
Linteger
->
arith_conversion
()
|
Linteger
->
arith_conversion
()
|
Lreal
->
conversion
~
loc
(
Logic_const
.
treal_zero
~
loc
()
)
t
|
Lreal
->
conversion
~
loc
false
t
(
Logic_const
.
treal_zero
~
loc
()
)
|
Ltype
({
lt_name
=
name
}
,
[]
)
when
name
=
Utf8_logic
.
boolean
->
|
Ltype
({
lt_name
=
name
}
,
[]
)
when
name
=
Utf8_logic
.
boolean
->
let
ctrue
=
Logic_env
.
Logic_ctor_info
.
find
"
\\
fals
e"
in
let
ctrue
=
Logic_env
.
Logic_ctor_info
.
find
"
\\
tru
e"
in
conversion
~
loc
(
term
~
loc
(
TDataCons
(
ctrue
,
[]
))
boolean_type
)
t
conversion
~
loc
true
t
(
term
~
loc
(
TDataCons
(
ctrue
,
[]
))
boolean_type
)
|
Ltype
_
|
Lvar
_
|
Larrow
_
|
Ltype
_
|
Lvar
_
|
Larrow
_
|
Ctype
(
TVoid
_
|
TNamed
_
|
TComp
_
|
TEnum
_
|
TBuiltin_va_list
_
)
|
Ctype
(
TVoid
_
|
TNamed
_
|
TComp
_
|
TEnum
_
|
TBuiltin_va_list
_
)
->
Kernel
.
fatal
->
Kernel
.
fatal
...
@@ -368,12 +368,14 @@ let scalar_term_conversion conversion t =
...
@@ -368,12 +368,14 @@ let scalar_term_conversion conversion t =
Cil_printer
.
pp_logic_type
t
.
term_type
Cil_printer
.
pp_logic_type
t
.
term_type
let
scalar_term_to_predicate
=
let
scalar_term_to_predicate
=
let
conversion
~
loc
zero
t
=
prel
~
loc
(
Cil_types
.
Rneq
,
t
,
zero
)
in
let
conversion
~
loc
is_eq
t1
t2
=
let
op
=
if
is_eq
then
Req
else
Rneq
in
prel
~
loc
(
op
,
t1
,
t2
)
in
scalar_term_conversion
conversion
scalar_term_conversion
conversion
let
scalar_term_to_boolean
=
let
scalar_term_to_boolean
=
let
conversion
~
loc
zero
t
=
let
conversion
~
loc
is_eq
t1
t2
=
term
~
loc
(
TBinOp
(
Ne
,
t
,
zero
))
Logic_const
.
boolean_type
let
op
=
if
is_eq
then
Eq
else
Ne
in
term
~
loc
(
TBinOp
(
op
,
t1
,
t2
))
Logic_const
.
boolean_type
in
in
scalar_term_conversion
conversion
scalar_term_conversion
conversion
...
...
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