-
Notifications
You must be signed in to change notification settings - Fork 273
Replace function calls with calls to other functions #2705
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
int f(int a) | ||
{ | ||
return a; | ||
} | ||
|
||
int g(int b) | ||
{ | ||
return b + 1; | ||
} | ||
|
||
int main() | ||
{ | ||
int r; | ||
|
||
r = f(0); | ||
assert(r == 1); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
CORE | ||
main.c | ||
--replace-calls f:g | ||
g\(0\); | ||
^VERIFICATION SUCCESSFUL$ | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
f\(0\); | ||
^warning: ignoring |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
int f() | ||
{ | ||
return 0; | ||
} | ||
|
||
int g() | ||
{ | ||
return 1; | ||
} | ||
|
||
int h() | ||
{ | ||
return 2; | ||
} | ||
|
||
int i() | ||
{ | ||
return 3; | ||
} | ||
|
||
int main() | ||
{ | ||
int r; | ||
|
||
r = f(); | ||
assert(r == 1); | ||
|
||
r = h(); | ||
assert(r == 3); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
CORE | ||
main.c | ||
--replace-calls f:g --replace-calls h:i | ||
g\(\); | ||
i\(\); | ||
^VERIFICATION SUCCESSFUL$ | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
f\(\); | ||
h\(\); | ||
^warning: ignoring |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
int f() | ||
{ | ||
return 0; | ||
} | ||
|
||
char g() | ||
{ | ||
return 1; | ||
} | ||
|
||
int main() | ||
{ | ||
f(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE | ||
main.c | ||
--replace-calls f:g | ||
Functions f and g are not type-compatible | ||
^EXIT=11$ | ||
^SIGNAL=0$ | ||
-- | ||
^warning: ignoring |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
void f(int a) | ||
{ | ||
return 0; | ||
} | ||
|
||
void g(unsigned a) | ||
{ | ||
return 1; | ||
} | ||
|
||
int main() | ||
{ | ||
f(0); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE | ||
main.c | ||
--replace-calls f:g | ||
Functions f and g are not type-compatible | ||
^EXIT=11$ | ||
^SIGNAL=0$ | ||
-- | ||
^warning: ignoring |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
void g() | ||
{ | ||
} | ||
|
||
int main() | ||
{ | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CORE | ||
main.c | ||
--replace-calls f:g --replace-calls h:f | ||
Function f cannot both be replaced and be a replacement | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if I replace the entry point (potentially specified by --function)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a test involving function pointers? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I've added a test that involves function pointers. Regarding the entry point replacement with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it is saying the usual 'No entry point found' then this is fine. An invariant violation would not be ok. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The replace calls pass works both when an entry point is present and when not ( |
||
^EXIT=11$ | ||
^SIGNAL=0$ | ||
-- | ||
^warning: ignoring |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
int f() | ||
{ | ||
return 0; | ||
} | ||
|
||
int g() | ||
{ | ||
return 1; | ||
} | ||
|
||
int main() | ||
{ | ||
int (*h)(void); | ||
|
||
h = g; | ||
h = f; | ||
|
||
int r; | ||
r = h(); | ||
assert(r == 1); | ||
|
||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CORE | ||
main.c | ||
--replace-calls f:g | ||
^VERIFICATION SUCCESSFUL$ | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
-- | ||
f\(\); | ||
^warning: ignoring |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ Author: Daniel Kroening, [email protected] | |
#include <goto-programs/goto_functions.h> | ||
#include <goto-programs/remove_calls_no_body.h> | ||
#include <goto-programs/remove_const_function_pointers.h> | ||
#include <goto-programs/replace_calls.h> | ||
#include <goto-programs/show_goto_functions.h> | ||
#include <goto-programs/show_properties.h> | ||
|
||
|
@@ -97,7 +98,9 @@ Author: Daniel Kroening, [email protected] | |
OPT_REMOVE_CALLS_NO_BODY \ | ||
OPT_REPLACE_FUNCTION_BODY \ | ||
OPT_GOTO_PROGRAM_STATS \ | ||
"(show-local-safe-pointers)(show-safe-dereferences)" | ||
"(show-local-safe-pointers)(show-safe-dereferences)" \ | ||
OPT_REPLACE_CALLS \ | ||
// empty last line | ||
|
||
// clang-format on | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove blank line (same in other files)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, done (but github doesn't seem to notice).