-
Notifications
You must be signed in to change notification settings - Fork 277
CONTRACTS: add loop contract mode enum and string conversion functions #7628
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
remi-delmas-3000
merged 1 commit into
diffblue:develop
from
remi-delmas-3000:contracts-contract-mode
Apr 3, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/goto-instrument/contracts/dynamic-frames/dfcc_contract_mode.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/*******************************************************************\ | ||
|
||
Module: Dynamic frame condition checking for function contracts | ||
|
||
Author: Remi Delmas, [email protected] | ||
|
||
Date: March 2023 | ||
|
||
\*******************************************************************/ | ||
|
||
#include "dfcc_contract_mode.h" | ||
|
||
#include <util/invariant.h> | ||
|
||
std::string dfcc_contract_mode_to_string(const dfcc_contract_modet mode) | ||
{ | ||
switch(mode) | ||
{ | ||
case dfcc_contract_modet::CHECK: | ||
return "dfcc_contract_modet::CHECK"; | ||
case dfcc_contract_modet::REPLACE: | ||
return "dfcc_contract_modet::REPLACE"; | ||
} | ||
UNREACHABLE; | ||
} | ||
|
||
std::ostream &operator<<(std::ostream &os, const dfcc_contract_modet mode) | ||
{ | ||
os << dfcc_contract_mode_to_string(mode); | ||
return os; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/goto-instrument/contracts/dynamic-frames/dfcc_loop_contract_mode.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/*******************************************************************\ | ||
|
||
Module: Dynamic frame condition checking for function contracts | ||
|
||
Author: Remi Delmas, [email protected] | ||
|
||
Date: March 2023 | ||
|
||
\*******************************************************************/ | ||
|
||
#include "dfcc_loop_contract_mode.h" | ||
|
||
#include <util/invariant.h> | ||
|
||
dfcc_loop_contract_modet dfcc_loop_contract_mode_from_bools( | ||
bool apply_loop_contracts, | ||
bool unwind_transformed_loops) | ||
{ | ||
if(apply_loop_contracts) | ||
{ | ||
if(unwind_transformed_loops) | ||
{ | ||
return dfcc_loop_contract_modet::APPLY_UNWIND; | ||
} | ||
else | ||
{ | ||
return dfcc_loop_contract_modet::APPLY; | ||
} | ||
} | ||
else | ||
{ | ||
return dfcc_loop_contract_modet::NONE; | ||
} | ||
} | ||
|
||
std::string | ||
dfcc_loop_contract_mode_to_string(const dfcc_loop_contract_modet mode) | ||
{ | ||
switch(mode) | ||
{ | ||
case dfcc_loop_contract_modet::NONE: | ||
return "dfcc_loop_contract_modet::NONE"; | ||
case dfcc_loop_contract_modet::APPLY: | ||
return "dfcc_loop_contract_modet::APPLY"; | ||
case dfcc_loop_contract_modet::APPLY_UNWIND: | ||
return "dfcc_loop_contract_modet::APPLY_UNWIND"; | ||
} | ||
UNREACHABLE; | ||
} | ||
|
||
std::ostream &operator<<(std::ostream &os, const dfcc_loop_contract_modet mode) | ||
{ | ||
os << dfcc_loop_contract_mode_to_string(mode); | ||
return os; | ||
} |
37 changes: 37 additions & 0 deletions
37
src/goto-instrument/contracts/dynamic-frames/dfcc_loop_contract_mode.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/*******************************************************************\ | ||
|
||
Module: Dynamic frame condition checking for function contracts | ||
|
||
Author: Remi Delmas, [email protected] | ||
|
||
\*******************************************************************/ | ||
|
||
/// \file | ||
/// Enumeration representing the instrumentation mode for loop contracts. | ||
|
||
#ifndef CPROVER_GOTO_INSTRUMENT_CONTRACTS_DYNAMIC_FRAMES_DFCC_LOOP_CONTRACT_MODE_H | ||
#define CPROVER_GOTO_INSTRUMENT_CONTRACTS_DYNAMIC_FRAMES_DFCC_LOOP_CONTRACT_MODE_H | ||
|
||
#include <string> | ||
|
||
/// Enumeration representing the instrumentation mode for loop contracts. | ||
enum class dfcc_loop_contract_modet | ||
{ | ||
/// Do not apply loop contracts | ||
NONE, | ||
/// Apply loop contracts | ||
APPLY, | ||
/// Apply loop contracts and unwind the resulting base + step encoding | ||
APPLY_UNWIND | ||
}; | ||
|
||
/// Generates an enum value from boolean flags for application and unwinding. | ||
dfcc_loop_contract_modet dfcc_loop_contract_mode_from_bools( | ||
bool apply_loop_contracts, | ||
bool unwind_transformed_loops); | ||
|
||
std::string dfcc_loop_contract_mode_to_string(dfcc_loop_contract_modet mode); | ||
|
||
std::ostream &operator<<(std::ostream &os, const dfcc_loop_contract_modet mode); | ||
|
||
#endif |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.