-
Notifications
You must be signed in to change notification settings - Fork 1
/
thread_local.ml
106 lines (93 loc) · 3.6 KB
/
thread_local.ml
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
(**************************************************************************)
(* This file is part of Conc2Seq plug-in of Frama-C. *)
(* *)
(* Copyright (C) 2016-2017 *)
(* CEA (Commissariat a l'energie atomique et aux energies *)
(* alternatives) *)
(* *)
(* you can redistribute it and/or modify it under the terms of the GNU *)
(* Lesser General Public License as published by the Free Software *)
(* Foundation, version 3. *)
(* *)
(* It is distributed in the hope that it will be useful, *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)
(* GNU Lesser General Public License for more details. *)
(* *)
(* See the GNU Lesser General Public License version 3 *)
(* for more details (enclosed in the file LICENCE). *)
(* *)
(**************************************************************************)
open Cil_types
let has_thread_local_attribute attr =
match attr with Attr("thread_local",[]) -> true | _ -> false
let variable v =
List.exists has_thread_local_attribute v.vattr
exception InvolveThreadLocal ;;
(** TODO : Add a cache to avoid multiple logic_info traversals *)
class th_detector = object(me)
inherit Visitor.frama_c_inplace
method! vterm t =
match t.term_node with
| Tapp(li,_,_) ->
ignore(Visitor.visitFramacLogicInfo (me :> Visitor.frama_c_inplace) li) ;
Cil.DoChildren
| _ -> Cil.DoChildren
method! vpredicate_node n =
match n with
| Papp(li,_,_) ->
ignore(Visitor.visitFramacLogicInfo (me :> Visitor.frama_c_inplace) li) ;
Cil.DoChildren
| _ -> Cil.DoChildren
method! vterm_lval lv =
match lv with
| TVar(lv), _ ->
begin match lv.lv_origin with
| Some v when variable v ->
raise InvolveThreadLocal
| _ ->
Cil.DoChildren
end
| _ -> Cil.DoChildren
end
let logic_info li =
try
ignore (Visitor.visitFramacLogicInfo (new th_detector) li) ;
false
with InvolveThreadLocal -> true
let predicate p =
try
ignore (Visitor.visitFramacPredicate (new th_detector) p) ;
false
with InvolveThreadLocal -> true
let term t =
try
ignore (Visitor.visitFramacTerm (new th_detector) t) ;
false
with InvolveThreadLocal -> true
let rec gannot ga =
let msg_end = "are not supported, just keep them unchanged." in
match ga with
| Dfun_or_pred(li,_) | Dinvariant(li, _) ->
logic_info li
| Dlemma(_,_,_,_, p, _,_) ->
predicate p
| Daxiomatic(_, list, _, _) ->
List.exists gannot list
| Dtype(_) ->
false
| Dvolatile(_) ->
Options.warning "Volatile annotations %s" msg_end ;
false
| Dtype_annot(_) ->
Options.warning "Type invariant annotations %s" msg_end ;
false
| Dmodel_annot(_) ->
Options.warning "Model fields annotations %s" msg_end ;
false
| Dcustom_annot(_) ->
Options.warning "Custom annotations %s" msg_end ;
false
| Dextended(_) ->
Options.warning "Extended annotations %s" msg_end ;
false