1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
(* *********************************************************************)
(* *)
(* The Compcert verified compiler *)
(* *)
(* Xavier Leroy, INRIA Paris-Rocquencourt *)
(* *)
(* Copyright Institut National de Recherche en Informatique et en *)
(* Automatique. All rights reserved. This file is distributed *)
(* under the terms of the GNU Lesser General Public License as *)
(* published by the Free Software Foundation, either version 2.1 of *)
(* the License, or (at your option) any later version. *)
(* This file is also distributed under the terms of the *)
(* INRIA Non-Commercial License Agreement. *)
(* *)
(* *********************************************************************)
open Cabs
(*********** HELPER FUNCTIONS **********)
let rec isStatic = function
[] -> false
| (SpecStorage STATIC) :: _ -> true
| _ :: rest -> isStatic rest
let rec isExtern = function
[] -> false
| (SpecStorage EXTERN) :: _ -> true
| _ :: rest -> isExtern rest
let rec isInline = function
[] -> false
| (SpecFunction INLINE) :: _ -> true
| _ :: rest -> isInline rest
let rec isTypedef = function
[] -> false
| SpecStorage TYPEDEF :: _ -> true
| _ :: rest -> isTypedef rest
let get_definitionloc (d : definition) : loc =
match d with
| FUNDEF(_, _, _, _, l) -> l
| DECDEF(_, l) -> l
| PRAGMA(_, l) -> l
| STATIC_ASSERT(_, _, _, _, l) -> l
let get_statementloc (s : statement) : loc =
begin
match s with
| NOP(loc) -> loc
| COMPUTATION(_,loc) -> loc
| BLOCK(_,loc) -> loc
| If(_,_,_,loc) -> loc
| WHILE(_,_,loc) -> loc
| DOWHILE(_,_,loc) -> loc
| FOR(_,_,_,_,loc) -> loc
| BREAK(loc) -> loc
| CONTINUE(loc) -> loc
| RETURN(_,loc) -> loc
| SWITCH(_,_,loc) -> loc
| CASE(_,_,loc) -> loc
| DEFAULT(_,loc) -> loc
| LABEL(_,_,loc) -> loc
| GOTO(_,loc) -> loc
| DEFINITION d -> get_definitionloc d
| ASM(_,_,_,_,_,_,loc) -> loc
end
let string_of_loc l =
Printf.sprintf "%s:%d" l.filename l.lineno
let format_loc pp l =
Format.fprintf pp "%s:%d" l.filename l.lineno
|