Skip to content

Commit e527f64

Browse files
committed
Consistently resize instead of just reserving in codet classes
1 parent c1304cd commit e527f64

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/util/std_code.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,7 @@ class code_assumet:public codet
281281
public:
282282
inline code_assumet():codet(ID_assume)
283283
{
284-
// will change to resize(1) in the future
285-
reserve_operands(1);
284+
operands().resize(1);
286285
}
287286

288287
inline explicit code_assumet(const exprt &expr):codet(ID_assume)
@@ -320,8 +319,7 @@ class code_assertt:public codet
320319
public:
321320
inline code_assertt():codet(ID_assert)
322321
{
323-
// will change to resize(1) in the future
324-
reserve_operands(1);
322+
operands().resize(1);
325323
}
326324

327325
inline explicit code_assertt(const exprt &expr):codet(ID_assert)
@@ -723,7 +721,8 @@ class code_returnt:public codet
723721
public:
724722
inline code_returnt():codet(ID_return)
725723
{
726-
reserve_operands(1);
724+
operands().resize(1);
725+
op0().make_nil();
727726
}
728727

729728
explicit inline code_returnt(const exprt &_op):codet(ID_return)
@@ -738,13 +737,14 @@ class code_returnt:public codet
738737

739738
inline exprt &return_value()
740739
{
741-
operands().resize(1);
742740
return op0();
743741
}
744742

745743
inline bool has_return_value() const
746744
{
747-
return operands().size()==1;
745+
if(operands().empty())
746+
return false; // backwards compatibility
747+
return return_value().is_not_nil();
748748
}
749749
};
750750

0 commit comments

Comments
 (0)