@@ -13,25 +13,25 @@ Date: May 2017
13
13
14
14
#include < taint-slicer/irept_instrument.h>
15
15
16
- static bool are_equal ( const irept l, const irept r)
17
- {
18
- return &l. read ()==&r. read ();
19
- }
16
+ // WARNING: ' irept' does not support equality check and its explicit use
17
+ // in functions below was not appreciated (see PR #132). Equivalence
18
+ // checks are thus used. And so, in case of performance issues in the
19
+ // instrumenter focus your attention also to profiling of these checks.
20
20
21
21
irept instrument (const irept irep, const instrumenter_fnt &instrumenter)
22
22
{
23
23
bool modified=false ;
24
24
25
25
irept::subt new_sub;
26
- for (const irept sub : irep.get_sub ())
26
+ for (const irept & sub : irep.get_sub ())
27
27
{
28
28
new_sub.push_back (instrument (sub, instrumenter));
29
- if (! are_equal ( new_sub.back (), sub) )
29
+ if (new_sub.back ()!= sub)
30
30
modified=true ;
31
31
}
32
32
33
33
irept::named_subt new_named_sub;
34
- for (const irept::named_subt::value_type name_sub : irep.get_named_sub ())
34
+ for (const irept::named_subt::value_type & name_sub : irep.get_named_sub ())
35
35
{
36
36
const auto it_bool=
37
37
new_named_sub.insert (
@@ -40,12 +40,12 @@ irept instrument(const irept irep, const instrumenter_fnt &instrumenter)
40
40
instrument (name_sub.second , instrumenter)
41
41
});
42
42
assert (it_bool.second );
43
- if (! are_equal ( it_bool.first ->second , name_sub.second ) )
43
+ if (it_bool.first ->second != name_sub.second )
44
44
modified=true ;
45
45
}
46
46
47
47
irept::named_subt new_comments;
48
- for (const irept::named_subt::value_type name_sub : irep.get_comments ())
48
+ for (const irept::named_subt::value_type & name_sub : irep.get_comments ())
49
49
{
50
50
const auto it_bool=
51
51
new_comments.insert (
@@ -54,7 +54,7 @@ irept instrument(const irept irep, const instrumenter_fnt &instrumenter)
54
54
instrument (name_sub.second , instrumenter)
55
55
});
56
56
assert (it_bool.second );
57
- if (! are_equal ( it_bool.first ->second , name_sub.second ) )
57
+ if (it_bool.first ->second != name_sub.second )
58
58
modified=true ;
59
59
}
60
60
@@ -69,55 +69,57 @@ irept instrument(const irept irep, const instrumenter_fnt &instrumenter)
69
69
return instrumenter (irep);
70
70
}
71
71
72
- irept instrument_using_pivot (
72
+ irept instrument_using_guide (
73
73
const irept pivot,
74
74
const irept irep,
75
- const pivot_instrumenter_fnt &instrumenter)
75
+ const guide_instrumenter_fnt &instrumenter)
76
76
{
77
77
bool modified=false ;
78
78
79
79
irept::subt new_sub;
80
80
for (auto pit=pivot.get_sub ().cbegin (), iit=irep.get_sub ().cbegin ();
81
81
pit!=pivot.get_sub ().cend () && iit!=irep.get_sub ().cend (); ++pit, ++iit)
82
82
{
83
- new_sub.push_back (instrument_using_pivot (*pit, *iit, instrumenter));
84
- if (! are_equal ( new_sub.back (), *iit) )
83
+ new_sub.push_back (instrument_using_guide (*pit, *iit, instrumenter));
84
+ if (new_sub.back ()!= *iit)
85
85
modified=true ;
86
86
}
87
87
88
88
irept::named_subt new_named_sub;
89
- for (auto pit=pivot.get_named_sub ().cbegin (),
90
- iit=irep.get_named_sub ().cbegin ();
91
- pit!=pivot.get_named_sub ().cend () &&
89
+ for (auto iit=irep.get_named_sub ().cbegin ();
92
90
iit!=irep.get_named_sub ().cend ();
93
- ++pit, ++ iit)
91
+ ++iit)
94
92
{
93
+ const auto pit=pivot.get_named_sub ().find (iit->first );
95
94
const auto it_bool=
96
95
new_named_sub.insert (
97
96
{
98
97
iit->first ,
99
- instrument_using_pivot (pit->second , iit->second , instrumenter)
98
+ pit!=pivot.get_named_sub ().cend () ?
99
+ instrument_using_guide (pit->second , iit->second , instrumenter):
100
+ iit->second
100
101
});
101
102
assert (it_bool.second );
102
- if (! are_equal ( it_bool.first ->second , iit->second ) )
103
+ if (it_bool.first ->second != iit->second )
103
104
modified=true ;
104
105
}
105
106
106
107
irept::named_subt new_comments;
107
- for (auto pit=pivot.get_comments ().cbegin (),
108
- iit=irep.get_comments ().cbegin ();
109
- pit!=pivot.get_comments ().cend () &&
108
+ for (auto iit=irep.get_comments ().cbegin ();
110
109
iit!=irep.get_comments ().cend ();
111
- ++pit, ++ iit)
110
+ ++iit)
112
111
{
112
+ auto pit=pivot.get_comments ().find (iit->first );
113
113
const auto it_bool=
114
114
new_comments.insert (
115
115
{
116
116
iit->first ,
117
- instrument_using_pivot (pit->second , iit->second , instrumenter)
117
+ pit!=pivot.get_comments ().cend () ?
118
+ instrument_using_guide (pit->second , iit->second , instrumenter):
119
+ iit->second
118
120
});
119
121
assert (it_bool.second );
120
- if (! are_equal ( it_bool.first ->second , iit->second ) )
122
+ if (it_bool.first ->second != iit->second )
121
123
modified=true ;
122
124
}
123
125
0 commit comments