forked from diffblue/cbmc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Fully interpret __attribute__((always_inline))"
This partly reverts commit 9c93f59. The regression test stays in place, but is now marked as KNOWNBUG.
- Loading branch information
1 parent
d20a12e
commit 016ad92
Showing
11 changed files
with
4 additions
and
123 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
CORE | ||
KNOWNBUG | ||
main.c | ||
|
||
^EXIT=0$ | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -18,11 +18,9 @@ Author: Daniel Kroening, [email protected] | |
#include <util/c_types.h> | ||
#include <util/config.h> | ||
#include <util/cprover_prefix.h> | ||
#include <util/expr_util.h> | ||
#include <util/ieee_float.h> | ||
#include <util/pointer_offset_size.h> | ||
#include <util/pointer_predicates.h> | ||
#include <util/replace_symbol.h> | ||
#include <util/simplify_expr.h> | ||
#include <util/string_constant.h> | ||
|
||
|
@@ -1920,10 +1918,7 @@ void c_typecheck_baset::typecheck_side_effect_function_call( | |
if(entry!=asm_label_map.end()) | ||
identifier=entry->second; | ||
|
||
symbol_tablet::symbolst::const_iterator sym_entry = | ||
symbol_table.symbols.find(identifier); | ||
|
||
if(sym_entry == symbol_table.symbols.end()) | ||
if(symbol_table.symbols.find(identifier)==symbol_table.symbols.end()) | ||
{ | ||
// This is an undeclared function. | ||
// Is this a builtin? | ||
|
@@ -1965,87 +1960,6 @@ void c_typecheck_baset::typecheck_side_effect_function_call( | |
warning() << "function `" << identifier << "' is not declared" << eom; | ||
} | ||
} | ||
else if( | ||
sym_entry->second.type.get_bool(ID_C_inlined) && | ||
sym_entry->second.is_macro && sym_entry->second.value.is_not_nil()) | ||
{ | ||
// calling a function marked as always_inline | ||
const symbolt &func_sym = sym_entry->second; | ||
const code_typet &func_type = to_code_type(func_sym.type); | ||
|
||
replace_symbolt replace; | ||
|
||
const code_typet::parameterst ¶meters = func_type.parameters(); | ||
auto p_it = parameters.begin(); | ||
for(const auto &arg : expr.arguments()) | ||
{ | ||
if(p_it == parameters.end()) | ||
{ | ||
// we don't support varargs with always_inline | ||
err_location(f_op); | ||
error() << "function call has additional arguments, " | ||
<< "cannot apply always_inline" << eom; | ||
throw 0; | ||
} | ||
|
||
irep_idt p_id = p_it->get_identifier(); | ||
if(p_id.empty()) | ||
{ | ||
p_id = id2string(func_sym.base_name) + "::" + | ||
id2string(p_it->get_base_name()); | ||
} | ||
replace.insert(p_id, arg); | ||
|
||
++p_it; | ||
} | ||
|
||
if(p_it != parameters.end()) | ||
{ | ||
err_location(f_op); | ||
error() << "function call has missing arguments, " | ||
<< "cannot apply always_inline" << eom; | ||
throw 0; | ||
} | ||
|
||
codet body = to_code(func_sym.value); | ||
replace(body); | ||
|
||
side_effect_exprt side_effect_expr( | ||
ID_statement_expression, func_type.return_type()); | ||
body.make_block(); | ||
|
||
// simulates parts of typecheck_function_body | ||
typet cur_return_type = return_type; | ||
return_type = func_type.return_type(); | ||
typecheck_code(body); | ||
return_type.swap(cur_return_type); | ||
|
||
// replace final return by an ID_expression | ||
codet &last = to_code_block(body).find_last_statement(); | ||
|
||
if(last.get_statement() == ID_return) | ||
last.set_statement(ID_expression); | ||
|
||
// NOLINTNEXTLINE(whitespace/braces) | ||
const bool has_returns = has_subexpr(body, [&](const exprt &e) { | ||
return e.id() == ID_code && to_code(e).get_statement() == ID_return; | ||
}); | ||
if(has_returns) | ||
{ | ||
// we don't support multiple return statements with always_inline | ||
err_location(last); | ||
error() << "function has multiple return statements, " | ||
<< "cannot apply always_inline" << eom; | ||
throw 0; | ||
} | ||
|
||
side_effect_expr.copy_to_operands(body); | ||
typecheck_side_effect_statement_expression(side_effect_expr); | ||
|
||
expr.swap(side_effect_expr); | ||
|
||
return; | ||
} | ||
} | ||
|
||
// typecheck it now | ||
|
This file contains 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
This file contains 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
This file contains 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