Skip to content

Commit 69b0ff1

Browse files
Added base_name in comments for all symbols
1 parent e86080a commit 69b0ff1

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/goto-programs/json_goto_trace.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,38 @@ void convert(
9595
step.full_lhs.is_not_nil(),
9696
"full_lhs in assignment must not be nil");
9797
exprt simplified=simplify_expr(step.full_lhs, ns);
98+
99+
class comment_base_name_visitort : public expr_visitort
100+
{
101+
private:
102+
const namespacet &ns;
103+
104+
public:
105+
explicit comment_base_name_visitort(const namespacet &ns) : ns(ns)
106+
{
107+
}
108+
109+
void operator()(exprt &expr) override
110+
{
111+
if(expr.id() == ID_symbol)
112+
{
113+
const symbolt &symbol = ns.lookup(expr.get(ID_identifier));
114+
// Don't break sharing unless need to write to it
115+
const irept::named_subt &comments =
116+
static_cast<const exprt &>(expr).get_comments();
117+
if(comments.count(ID_C_base_name) != 0)
118+
INVARIANT(
119+
comments.at(ID_C_base_name).id() == symbol.base_name,
120+
"base_name comment does not match symbol's base_name");
121+
else
122+
expr.get_comments().emplace(
123+
ID_C_base_name, irept(symbol.base_name));
124+
}
125+
}
126+
};
127+
comment_base_name_visitort comment_base_name_visitor(ns);
128+
simplified.visit(comment_base_name_visitor);
129+
98130
full_lhs_string=from_expr(ns, identifier, simplified);
99131

100132
const symbolt *symbol;

0 commit comments

Comments
 (0)