Commit 71a8c117 authored by Andre Maroneze's avatar Andre Maroneze 💬
Browse files

Merge branch 'fix/ast-diff/forward-def-struct' into 'master'

[kernel] fix ast-diff on code with forward-decl of struct

Closes #1164

See merge request frama-c/frama-c!3908
parents 44608cfe 54badc7f
This diff is collapsed.
......@@ -30,10 +30,10 @@ open Cil_types
(** the original project from which a diff is computed. *)
module Orig_project: State_builder.Option_ref with type data = Project.t
(** possible correspondances between new items and original ones. *)
type 'a correspondance =
(** possible correspondences between new items and original ones. *)
type 'a correspondence =
[ `Same of 'a (** symbol with identical definition has been found. *)
| `Not_present (** no correspondance *)
| `Not_present (** no correspondence *)
]
(** for kernel function, we are a bit more precise than a yes/no answer.
......@@ -42,80 +42,80 @@ type 'a correspondance =
the body itself is identical, otherwise, there's no point in checking
the callees.
*)
type partial_correspondance =
type partial_correspondence =
[ `Spec_changed (** body and callees haven't changed *)
| `Body_changed (** spec hasn't changed *)
| `Callees_changed (** spec and body haven't changed *)
| `Callees_spec_changed (** body hasn't changed *)
]
type 'a code_correspondance =
[ 'a correspondance
| `Partial of 'a * partial_correspondance
type 'a code_correspondence =
[ 'a correspondence
| `Partial of 'a * partial_correspondence
]
module type Correspondance_table = sig
module type Correspondence_table = sig
include State_builder.Hashtbl
val pretty_data: Format.formatter -> data -> unit
end
(** varinfos correspondances *)
(** varinfos correspondences *)
module Varinfo:
Correspondance_table
with type key = varinfo and type data = varinfo correspondance
Correspondence_table
with type key = varinfo and type data = varinfo correspondence
module Compinfo:
Correspondance_table
with type key = compinfo and type data = compinfo correspondance
Correspondence_table
with type key = compinfo and type data = compinfo correspondence
module Enuminfo:
Correspondance_table
with type key = enuminfo and type data = enuminfo correspondance
Correspondence_table
with type key = enuminfo and type data = enuminfo correspondence
module Enumitem:
Correspondance_table
with type key = enumitem and type data = enumitem correspondance
Correspondence_table
with type key = enumitem and type data = enumitem correspondence
module Typeinfo:
Correspondance_table
with type key = typeinfo and type data = typeinfo correspondance
Correspondence_table
with type key = typeinfo and type data = typeinfo correspondence
module Stmt:
Correspondance_table
with type key = stmt and type data = stmt code_correspondance
Correspondence_table
with type key = stmt and type data = stmt code_correspondence
module Logic_info:
Correspondance_table
with type key = logic_info and type data = logic_info correspondance
Correspondence_table
with type key = logic_info and type data = logic_info correspondence
module Logic_type_info:
Correspondance_table
with type key = logic_type_info and type data = logic_type_info correspondance
Correspondence_table
with type key = logic_type_info and type data = logic_type_info correspondence
module Logic_ctor_info:
Correspondance_table
with type key = logic_ctor_info and type data = logic_ctor_info correspondance
Correspondence_table
with type key = logic_ctor_info and type data = logic_ctor_info correspondence
module Fieldinfo:
Correspondance_table
with type key = fieldinfo and type data = fieldinfo correspondance
Correspondence_table
with type key = fieldinfo and type data = fieldinfo correspondence
module Model_info:
Correspondance_table
with type key = model_info and type data = model_info correspondance
Correspondence_table
with type key = model_info and type data = model_info correspondence
module Logic_var:
Correspondance_table
with type key = logic_var and type data = logic_var correspondance
Correspondence_table
with type key = logic_var and type data = logic_var correspondence
module Kernel_function:
Correspondance_table
Correspondence_table
with type key = kernel_function
and type data = kernel_function code_correspondance
and type data = kernel_function code_correspondence
module Fundec:
Correspondance_table
with type key = fundec and type data = fundec correspondance
Correspondence_table
with type key = fundec and type data = fundec correspondence
(** performs a comparison of AST between the current and the original
project, which must have been set beforehand.
......
/* run.config
MODULE: @PTEST_NAME@
OPT: -then -ast-diff %{dep:ast_diff_2.i}
OPT: -then -ast-diff %{dep:ast_diff_2.c}
OPT: -then -ast-diff %{dep:ast_diff_2.c} -cpp-extra-args="-DADD_ENUM_TAG"
*/
int X;
int Y=3;
......@@ -94,3 +95,15 @@ void with_goto_unchanged(int c) {
L1: X++;
L2: X++;
}
enum e {
t = 1,
u = t + 2
};
struct s { char c[t]; };
void se() {
struct s S;
S.c[0] = 1;
}
......@@ -87,3 +87,18 @@ void with_goto_unchanged(int c) {
L1: X++;
L2: X++;
}
enum e {
t = 1,
u = t + 2,
#ifdef ADD_ENUM_TAG
v = t + u,
#endif
};
struct s { char c[t]; };
void se() {
struct s S;
S.c[0] = 1;
}
[kernel] Parsing ast_diff_1.i (no preprocessing)
[kernel] Parsing ast_diff_2.i (no preprocessing)
[kernel] Parsing ast_diff_2.c (with preprocessing)
[AST diff test] Showing correspondances between orig_default and default
[AST diff test] Variable i: => i
[AST diff test] Variable local_var_use: => local_var_use
......@@ -19,9 +19,11 @@
[AST diff test] Variable x: => x
[AST diff test] Variable c: => c
[AST diff test] Variable g: => g
[AST diff test] Variable se: => se
[AST diff test] Variable S: => S
[AST diff test] Variable has_static_local_x: => has_static_local_y
[AST diff test] Variable __retres: => __retres
[AST diff test] Variable h: => h
[AST diff test] Variable __retres: => __retres
[AST diff test] Variable use_logic_builtin: => use_logic_builtin
[AST diff test] Variable x: => x
[AST diff test] Variable y: => y
......@@ -36,6 +38,7 @@
[AST diff test] Function f: => f
[AST diff test] Function with_goto_unchanged: => with_goto_unchanged
[AST diff test] Function g: N/A
[AST diff test] Function se: => se
[AST diff test] Function h: -> h (body changed)
[AST diff test] Function use_logic_builtin: => use_logic_builtin
[AST diff test] Function has_static_local: => has_static_local
......
[kernel] Parsing ast_diff_1.i (no preprocessing)
[kernel] Parsing ast_diff_2.c (with preprocessing)
[kernel] Parsing ast_diff_1.i (no preprocessing)
[AST diff test] Showing correspondances between orig_default and default
[AST diff test] Variable use_logic_builtin: => use_logic_builtin
[AST diff test] Variable x: => x
[AST diff test] Variable y: => y
[AST diff test] Variable has_static_local: => has_static_local
[AST diff test] Variable decl: => decl
[AST diff test] Variable used_in_decl: => used_in_decl
[AST diff test] Variable ptr_func: => ptr_func
[AST diff test] Variable i: => i
[AST diff test] Variable local_var_use: => local_var_use
[AST diff test] Variable v: => w
[AST diff test] Variable a: => q
[AST diff test] Variable x: => z
[AST diff test] Variable y: => t
[AST diff test] Variable s: N/A
[AST diff test] Variable use_s: N/A
[AST diff test] Variable with_goto_changed: => with_goto_changed
[AST diff test] Variable X: => X
[AST diff test] Variable Y: N/A
[AST diff test] Variable c: => c
[AST diff test] Variable f: => f
[AST diff test] Variable with_goto_unchanged: => with_goto_unchanged
[AST diff test] Variable x: => x
[AST diff test] Variable c: => c
[AST diff test] Variable g: => g
[AST diff test] Variable se: => se
[AST diff test] Variable has_static_local_x: => has_static_local_y
[AST diff test] Variable h: => h
[AST diff test] Function use_logic_builtin: => use_logic_builtin
[AST diff test] Function has_static_local: => has_static_local
[AST diff test] Function decl: => decl
[AST diff test] Function i: => i
[AST diff test] Function local_var_use: => local_var_use
[AST diff test] Function use_s: N/A
[AST diff test] Function with_goto_changed: -> with_goto_changed (body changed)
[AST diff test] Function f: => f
[AST diff test] Function with_goto_unchanged: => with_goto_unchanged
[AST diff test] Function g: N/A
[AST diff test] Function se: -> se (body changed)
[AST diff test] Function h: -> h (body changed)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment