Skip to content

Commit d5e2a49

Browse files
committed
flag_resett: use source_locationt, no need for full instruction
There isn't any use of fields other than the instruction's source location, so take just that. Also use `as_string()` instead of `pretty()` for more nicely formatted error reporting.
1 parent 1144e48 commit d5e2a49

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/analyses/goto_check_c.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,8 @@ class goto_check_ct
347347
class flag_resett
348348
{
349349
public:
350-
explicit flag_resett(const goto_programt::instructiont &_instruction)
351-
: instruction(_instruction)
350+
explicit flag_resett(const source_locationt &source_location)
351+
: source_location(source_location)
352352
{
353353
}
354354

@@ -367,7 +367,7 @@ class flag_resett
367367
INVARIANT(
368368
flags_to_reset.find(&flag) == flags_to_reset.end(),
369369
"Flag " + id2string(flag_name) + " set twice at \n" +
370-
instruction.source_location().pretty());
370+
source_location.as_string());
371371
if(flag != new_value)
372372
{
373373
flags_to_reset[&flag] = flag;
@@ -384,7 +384,7 @@ class flag_resett
384384
INVARIANT(
385385
disabled_flags.find(&flag) == disabled_flags.end(),
386386
"Flag " + id2string(flag_name) + " disabled twice at \n" +
387-
instruction.source_location().pretty());
387+
source_location.as_string());
388388

389389
disabled_flags.insert(&flag);
390390

@@ -408,7 +408,7 @@ class flag_resett
408408
}
409409

410410
private:
411-
const goto_programt::instructiont &instruction;
411+
const source_locationt &source_location;
412412
std::map<bool *, bool> flags_to_reset;
413413
std::set<bool *> disabled_flags;
414414
};
@@ -2027,7 +2027,7 @@ void goto_check_ct::goto_check(
20272027
current_target = it;
20282028
goto_programt::instructiont &i = *it;
20292029

2030-
flag_resett resetter(i);
2030+
flag_resett resetter(i.source_location());
20312031
const auto &pragmas = i.source_location().get_pragmas();
20322032
for(const auto &d : pragmas)
20332033
{
@@ -2110,7 +2110,7 @@ void goto_check_ct::goto_check(
21102110
// Disable enum range checks for left-hand sides as their values are yet
21112111
// to be set (by this assignment).
21122112
{
2113-
flag_resett resetter(i);
2113+
flag_resett resetter(i.source_location());
21142114
resetter.disable_flag(enable_enum_range_check, "enum_range_check");
21152115
check(assign_lhs);
21162116
}

0 commit comments

Comments
 (0)