Skip to content

Crangler: also apply remove-static to declarations #6816

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions regression/crangler/remove-static/remove_static1.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ int foo()

int bar();

static void foobar2();

static void foobar1()
{
}
Expand Down
1 change: 1 addition & 0 deletions regression/crangler/remove-static/remove_static1.desc
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ remove_static1.json
^EXIT=0$
^SIGNAL=0$
--
static\s+(void\s+)?foobar[12]\(\)$
12 changes: 9 additions & 3 deletions src/crangler/c_wrangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ static void mangle_function(
const c_wranglert::functiont &function_config,
std::ostream &out)
{
if(function_config.stub.has_value())
if(function_config.stub.has_value() && declaration.has_body())
{
// replace by stub
out << function_config.stub.value();
Expand Down Expand Up @@ -399,6 +399,13 @@ static void mangle_function(
for(auto &t : declaration.post_declarator)
out << t.text;

if(!declaration.has_body())
{
for(auto &t : declaration.initializer)
out << t.text;
return;
}

for(const auto &entry : function_config.contract)
out << ' ' << CPROVER_PREFIX << entry.clause << '('
<< defines(entry.content) << ')';
Expand Down Expand Up @@ -498,8 +505,7 @@ static void mangle(
std::ostream &out)
{
auto name_opt = declaration.declared_identifier();
if(
declaration.is_function() && name_opt.has_value() && declaration.has_body())
if(declaration.is_function() && name_opt.has_value())
{
for(const auto &entry : config.functions)
{
Expand Down