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
49cd989a
Commit
49cd989a
authored
5 years ago
by
Allan Blanchard
Browse files
Options
Downloads
Patches
Plain Diff
[Instantiate] Takes care of constants in Memset
parent
ac00a6ec
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugins/instantiate/basic_blocks.ml
+2
-1
2 additions, 1 deletion
src/plugins/instantiate/basic_blocks.ml
src/plugins/instantiate/string/memset.ml
+20
-22
20 additions, 22 deletions
src/plugins/instantiate/string/memset.ml
with
22 additions
and
23 deletions
src/plugins/instantiate/basic_blocks.ml
+
2
−
1
View file @
49cd989a
...
...
@@ -54,7 +54,8 @@ let exp_type_of_pointed x =
let
no_cast
=
Cil
.
stripCasts
x
in
if
not
(
Cil
.
isPointerType
(
Cil
.
typeOf
no_cast
))
then
match
Cil
.
constFoldToInt
x
with
|
Some
t
when
Integer
.(
equal
t
(
of_int
0
))
->
Some
(
Cil
.
typeOf
x
)
|
Some
t
when
Integer
.(
equal
t
(
of_int
0
))
->
Some
(
Cil
.
typeOf_pointed
(
Cil
.
typeOf
x
))
|
_
->
None
else
let
xt
=
Cil
.
unrollTypeDeep
(
Cil
.
typeOf
no_cast
)
in
...
...
This diff is collapsed.
Click to expand it.
src/plugins/instantiate/string/memset.ml
+
20
−
22
View file @
49cd989a
...
...
@@ -175,12 +175,6 @@ let generate_spec (_t, e) { svar = vi } loc =
let
ensures
=
generate_ensures
e
loc
t
ptr
value
len
in
make_funspec
[
make_behavior
~
requires
~
assigns
~
ensures
()
]
()
let
type_from_arg
x
=
let
x
=
Cil
.
stripCasts
x
in
let
xt
=
Cil
.
unrollTypeDeep
(
Cil
.
typeOf
x
)
in
let
xt
=
Cil
.
type_remove_qualifier_attributes_deep
xt
in
Cil
.
typeOf_pointed
xt
let
memset_value
e
=
let
ff
=
Integer
.
of_int
255
in
match
(
Cil
.
constFold
false
e
)
.
enode
with
...
...
@@ -199,22 +193,25 @@ let rec contains_union_type t =
|
_
->
false
let
well_typed_call
_ret
=
function
|
[
ptr
;
_
;
_
]
when
any_char_composed_type
(
type_from_arg
ptr
)
->
true
|
[
ptr
;
_
;
_
]
when
contains_union_type
(
type_from_arg
ptr
)
->
false
|
[
ptr
;
_
;
_
]
when
Cil
.
isVoidType
(
type_from_arg
ptr
)
->
false
|
[
ptr
;
_
;
_
]
when
not
(
Cil
.
isCompleteType
(
type_from_arg
ptr
))
->
false
|
[
_
;
value
;
_
]
->
begin
match
memset_value
value
with
|
None
->
false
|
Some
_
->
true
|
[
ptr
;
value
;
_
]
->
begin
match
exp_type_of_pointed
ptr
,
memset_value
value
with
|
None
,
_
->
false
|
Some
t
,
_
when
any_char_composed_type
t
->
true
|
Some
t
,
_
when
contains_union_type
t
->
false
|
Some
t
,
_
when
Cil
.
isVoidType
t
->
false
|
Some
t
,
_
when
not
(
Cil
.
isCompleteType
t
)
->
false
|
_
,
None
->
false
|
_
,
Some
_
->
true
end
|
_
->
false
let
key_from_call
_ret
=
function
|
[
ptr
;
_
;
_
]
when
any_char_composed_type
(
type_from_arg
ptr
)
->
(
type_from_arg
ptr
)
,
None
|
[
ptr
;
value
;
_
]
when
not
(
contains_union_type
(
type_from_arg
ptr
))
->
(
type_from_arg
ptr
)
,
(
memset_value
value
)
|
[
ptr
;
value
;
_
]
->
begin
match
exp_type_of_pointed
ptr
,
memset_value
value
with
|
Some
t
,
_
when
any_char_composed_type
t
->
t
,
None
|
Some
t
,
value
when
not
(
contains_union_type
t
)
->
t
,
value
|
_
,
_
->
unexpected
"trying to generate a key on an ill-typed call"
end
|
_
->
unexpected
"trying to generate a key on an ill-typed call"
let
char_prototype
t
=
...
...
@@ -246,17 +243,18 @@ let generate_prototype = function
|
_
,
_
->
unexpected
"trying to generate a prototype on an ill-typed call"
let
retype_args
(
t
,
e
)
args
=
let
retype_args
(
_
t
,
e
)
args
=
match
e
,
args
with
|
None
,
[
ptr
;
v
;
n
]
->
let
ptr
=
Cil
.
stripCasts
ptr
in
assert
(
any_char_composed_type
(
type_from_arg
ptr
))
;
let
base_type
=
base_char_type
(
type_from_arg
ptr
)
in
let
base_type
=
match
exp_type_of_pointed
ptr
with
|
Some
t
->
base_char_type
t
|
None
->
unexpected
"trying to retype arguments on an ill-typed call"
in
let
v
=
Cil
.
mkCast
(
Cil
.
stripCasts
v
)
base_type
in
[
ptr
;
v
;
n
]
|
Some
fv
,
[
ptr
;
v
;
n
]
->
let
ptr
=
Cil
.
stripCasts
ptr
in
assert
(
Cil_datatype
.
Typ
.
equal
(
type_from_arg
ptr
)
t
)
;
assert
(
match
memset_value
v
with
Some
x
when
x
=
fv
->
true
|
_
->
false
)
;
[
ptr
;
n
]
|
_
->
...
...
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