Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pub
frama-c
Commits
439ca7c9
Commit
439ca7c9
authored
Mar 02, 2020
by
Virgile Prevosto
Committed by
Andre Maroneze
Mar 06, 2020
Browse files
[kernel] dust off debug messages of constfolding
parent
e3fc0281
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/kernel_services/ast_queries/cil.ml
View file @
439ca7c9
...
...
@@ -208,8 +208,6 @@ let () =
let
selfMachine_is_computed
=
TheMachine
.
is_computed
let
debugConstFold
=
false
let
new_exp
~
loc
e
=
{
eloc
=
loc
;
eid
=
Cil_const
.
Eid
.
next
()
;
enode
=
e
}
let
dummy_exp
e
=
{
eid
=
-
1
;
enode
=
e
;
eloc
=
Cil_datatype
.
Location
.
unknown
}
...
...
@@ -4412,7 +4410,8 @@ and bitsOffset (baset: typ) (off: offset) : int * int =
See also {!Cil.constFoldVisitor}, which will run constFold on all
expressions in a given AST node.*)
and
constFold
(
machdep
:
bool
)
(
e
:
exp
)
:
exp
=
if
debugConstFold
then
Kernel
.
debug
"ConstFold to %a@."
!
pp_exp_ref
e
;
let
dkey
=
Kernel
.
dkey_constfold
in
Kernel
.
debug
~
dkey
"ConstFold %a@."
!
pp_exp_ref
e
;
let
loc
=
e
.
eloc
in
match
e
.
enode
with
BinOp
(
bop
,
e1
,
e2
,
tres
)
->
constFoldBinOp
~
loc
machdep
bop
e1
e2
tres
...
...
@@ -4496,15 +4495,13 @@ and constFold (machdep: bool) (e: exp) : exp =
end
|
CastE
(
t
,
e
)
->
begin
if
debugConstFold
then
Kernel
.
debug
"ConstFold CAST to to %a@."
!
pp_typ_ref
t
;
Kernel
.
debug
~
dkey
"ConstFold CAST to %a@."
!
pp_typ_ref
t
;
let
e
=
constFold
machdep
e
in
match
e
.
enode
,
unrollType
t
with
|
Const
(
CInt64
(
i
,_
k
,_
))
,
(
TInt
(
nk
,
a
)
|
TEnum
({
ekind
=
nk
}
,
a
))
when
a
=
[]
->
begin
(* If the cast has attributes, leave it alone. *)
if
debugConstFold
then
Kernel
.
debug
"ConstFold to %a : %a@."
Kernel
.
debug
~
dkey
"ConstFold to %a : %a@."
!
pp_ikind_ref
nk
Datatype
.
Integer
.
pretty
i
;
(* Downcasts might truncate silently *)
kinteger64
~
loc
~
kind
:
nk
i
...
...
@@ -4718,10 +4715,9 @@ and constFoldBinOp ~loc (machdep: bool) bop e1 e2 tres =
one
~
loc
|
_
->
new_exp
~
loc
(
BinOp
(
bop
,
e1'
,
e2'
,
tres
))
in
if
debugConstFold
then
Format
.
printf
"Folded %a to %a@."
!
pp_exp_ref
(
new_exp
~
loc
(
BinOp
(
bop
,
e1'
,
e2'
,
tres
)))
!
pp_exp_ref
newe
;
Kernel
.
debug
~
dkey
:
Kernel
.
dkey_constfold
"Folded %a to %a@."
!
pp_exp_ref
(
new_exp
~
loc
(
BinOp
(
bop
,
e1'
,
e2'
,
tres
)))
!
pp_exp_ref
newe
;
newe
end
else
if
isArithmeticType
tres
&&
not
(
isLongDoubleType
tres
)
then
begin
let
tk
=
...
...
src/kernel_services/plugin_entry_points/kernel.ml
View file @
439ca7c9
...
...
@@ -49,6 +49,8 @@ let dkey_ast = register_category "ast"
let
dkey_check
=
register_category
"check"
let
dkey_constfold
=
register_category
"constfold"
let
dkey_comments
=
register_category
"parser:comments"
let
dkey_dataflow
=
register_category
"dataflow"
...
...
src/kernel_services/plugin_entry_points/kernel.mli
View file @
439ca7c9
...
...
@@ -43,6 +43,8 @@ val dkey_ast: category
val
dkey_check
:
category
val
dkey_constfold
:
category
val
dkey_comments
:
category
val
dkey_compilation_db
:
category
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment