diff --git a/src/kernel_services/ast_queries/cil_datatype.ml b/src/kernel_services/ast_queries/cil_datatype.ml index c9f743a32f6e55252fbed085583b467a45c07492..36c2d644f4678075e8515401b601ed91b3ef308c 100644 --- a/src/kernel_services/ast_queries/cil_datatype.ml +++ b/src/kernel_services/ast_queries/cil_datatype.ml @@ -214,10 +214,23 @@ module Location = struct else Format.fprintf fmt "generated" + let pretty_debug fmt loc = + Format.fprintf fmt "(%a:%d:%d,%a:%d:%d)" + Datatype.Filepath.pretty (fst loc).Filepath.pos_path + (fst loc).Filepath.pos_lnum (fst loc).Filepath.pos_cnum + Datatype.Filepath.pretty (snd loc).Filepath.pos_path + (snd loc).Filepath.pos_lnum (snd loc).Filepath.pos_cnum + let of_lexing_loc (pos1, pos2) = Position.of_lexing_pos pos1, Position.of_lexing_pos pos2 let to_lexing_loc (pos1, pos2) = Position.to_lexing_pos pos1, Position.to_lexing_pos pos2 + + let equal_start_semantic (pos1, _) (pos2, _) = + Filepath.(Datatype.Filepath.equal pos1.pos_path pos2.pos_path + && pos1.pos_lnum = pos2.pos_lnum + && pos1.pos_cnum - pos1.pos_bol = pos2.pos_cnum - pos2.pos_bol) + end module Instr = struct diff --git a/src/kernel_services/ast_queries/cil_datatype.mli b/src/kernel_services/ast_queries/cil_datatype.mli index 52f914d8ebe394785d5d998afbe9cf7e640a7e0b..f83bc30afaad8b70869486bbfaa1ba8c473877fa 100644 --- a/src/kernel_services/ast_queries/cil_datatype.mli +++ b/src/kernel_services/ast_queries/cil_datatype.mli @@ -69,9 +69,26 @@ module Location: sig the full-path to the file. The default pretty-printer [pretty] echoes [<dir/f>:<l>] *) val pretty_line: t Pretty_utils.formatter + + (** Pretty-print both location start and end, including file, line and + character offset. + + @since Frama-C+dev + *) + val pretty_debug: t Pretty_utils.formatter + (** Prints only the line of the location *) val of_lexing_loc : Lexing.position * Lexing.position -> t val to_lexing_loc : t -> Lexing.position * Lexing.position + + (** Compares two locations semantically, only taking into account their + starting position. Compares normalized filenames, lines and columns, + but no absolute character offsets. + + @since Frama-C+dev + *) + val equal_start_semantic : location -> location -> bool + end module Localisation: Datatype.S with type t = localisation