Skip to content

Revert "Fully process always_inline" #1527

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
Oct 25, 2017
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
32 changes: 0 additions & 32 deletions regression/ansi-c/always_inline1/main.c

This file was deleted.

8 changes: 0 additions & 8 deletions regression/ansi-c/always_inline1/test.desc

This file was deleted.

2 changes: 0 additions & 2 deletions src/ansi-c/ansi_c_convert_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ void ansi_c_convert_typet::read_rec(const typet &type)
c_storage_spec.is_register=true;
else if(type.id()==ID_weak)
c_storage_spec.is_weak=true;
else if(type.id()==ID_always_inline)
c_storage_spec.is_always_inline=true;
else if(type.id()==ID_auto)
{
// ignore
Expand Down
5 changes: 0 additions & 5 deletions src/ansi-c/ansi_c_declaration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ void ansi_c_declarationt::output(std::ostream &out) const
out << " is_extern";
if(get_is_static_assert())
out << " is_static_assert";
if(get_is_always_inline())
out << " is_always_inline";
out << "\n";

out << "Type: " << type().pretty() << "\n";
Expand Down Expand Up @@ -166,9 +164,6 @@ void ansi_c_declarationt::to_symbol(
symbol.is_extern=false;
else if(get_is_extern()) // traditional GCC
symbol.is_file_local=true;

if(get_is_always_inline())
symbol.is_macro=true;
}
}
}
Expand Down
10 changes: 0 additions & 10 deletions src/ansi-c/ansi_c_declaration.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,16 +195,6 @@ class ansi_c_declarationt:public exprt
set(ID_is_weak, is_weak);
}

bool get_is_always_inline() const
{
return get_bool(ID_is_always_inline);
}

void set_is_always_inline(bool is_always_inline)
{
set(ID_is_always_inline, is_always_inline);
}

void to_symbol(
const ansi_c_declaratort &,
symbolt &symbol) const;
Expand Down
2 changes: 0 additions & 2 deletions src/ansi-c/c_storage_spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ void c_storage_spect::read(const typet &type)
is_register=true;
else if(type.id()==ID_weak)
is_weak=true;
else if(type.id()==ID_always_inline)
is_always_inline=true;
else if(type.id()==ID_auto)
{
// ignore
Expand Down
5 changes: 1 addition & 4 deletions src/ansi-c/c_storage_spec.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ class c_storage_spect
is_register=false;
is_inline=false;
is_weak=false;
is_always_inline=false;
alias.clear();
asm_label.clear();
section.clear();
}

bool is_typedef, is_extern, is_static, is_register,
is_inline, is_thread_local, is_weak, is_always_inline;
is_inline, is_thread_local, is_weak;

// __attribute__((alias("foo")))
irep_idt alias;
Expand All @@ -60,7 +59,6 @@ class c_storage_spect
is_thread_local==other.is_thread_local &&
is_inline==other.is_inline &&
is_weak==other.is_weak &&
is_always_inline==other.is_always_inline &&
alias==other.alias &&
asm_label==other.asm_label &&
section==other.section;
Expand All @@ -80,7 +78,6 @@ class c_storage_spect
is_inline |=other.is_inline;
is_thread_local |=other.is_thread_local;
is_weak |=other.is_weak;
is_always_inline|=other.is_always_inline;
if(alias.empty())
alias=other.alias;
if(asm_label.empty())
Expand Down
1 change: 0 additions & 1 deletion src/ansi-c/c_typecheck_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,6 @@ void c_typecheck_baset::typecheck_declaration(
declaration.set_is_register(full_spec.is_register);
declaration.set_is_typedef(full_spec.is_typedef);
declaration.set_is_weak(full_spec.is_weak);
declaration.set_is_always_inline(full_spec.is_always_inline);

symbolt symbol;
declaration.to_symbol(*d_it, symbol);
Expand Down
72 changes: 1 addition & 71 deletions src/ansi-c/c_typecheck_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Author: Daniel Kroening, [email protected]
#include <util/std_expr.h>
#include <util/pointer_offset_size.h>
#include <util/pointer_predicates.h>
#include <util/replace_symbol.h>

#include "c_typecast.h"
#include "c_qualifiers.h"
Expand Down Expand Up @@ -1914,10 +1913,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. Let's just add it.
// We do a bit of return-type guessing, but just a bit.
Expand Down Expand Up @@ -1949,72 +1945,6 @@ void c_typecheck_baset::typecheck_side_effect_function_call(
warning().source_location=f_op.find_source_location();
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 &parameters=func_type.parameters();
auto p_it=parameters.begin();
for(const auto &arg : expr.arguments())
{
if(p_it==parameters.end())
{
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);

side_effect_expr.copy_to_operands(body);
typecheck_side_effect_statement_expression(side_effect_expr);

expr.swap(side_effect_expr);

return;
}
}

// typecheck it now
Expand Down
3 changes: 0 additions & 3 deletions src/ansi-c/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ extern char *yyansi_ctext;
%token TOK_GCC_ATTRIBUTE_NORETURN "noreturn"
%token TOK_GCC_ATTRIBUTE_CONSTRUCTOR "constructor"
%token TOK_GCC_ATTRIBUTE_DESTRUCTOR "destructor"
%token TOK_GCC_ATTRIBUTE_ALWAYS_INLINE "always_inline"
%token TOK_GCC_LABEL "__label__"
%token TOK_MSC_ASM "__asm"
%token TOK_MSC_BASED "__based"
Expand Down Expand Up @@ -1532,8 +1531,6 @@ gcc_type_attribute:
{ $$=$1; set($$, ID_constructor); }
| TOK_GCC_ATTRIBUTE_DESTRUCTOR
{ $$=$1; set($$, ID_destructor); }
| TOK_GCC_ATTRIBUTE_ALWAYS_INLINE
{ $$=$1; set($$, ID_always_inline); }
;

gcc_attribute:
Expand Down
3 changes: 0 additions & 3 deletions src/ansi-c/scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -1537,9 +1537,6 @@ __decltype { if(PARSER.cpp98 &&
"destructor" |
"__destructor__" { BEGIN(GCC_ATTRIBUTE3); loc(); return TOK_GCC_ATTRIBUTE_DESTRUCTOR; }

"always_inline" |
"__always_inline__" { BEGIN(GCC_ATTRIBUTE3); loc(); return TOK_GCC_ATTRIBUTE_ALWAYS_INLINE; }

{ws} { /* ignore */ }
{newline} { /* ignore */ }
{identifier} { BEGIN(GCC_ATTRIBUTE4); }
Expand Down
2 changes: 0 additions & 2 deletions src/util/irep_ids.def
Original file line number Diff line number Diff line change
Expand Up @@ -830,8 +830,6 @@ IREP_ID_TWO(C_java_generics_class_type, #java_generics_class_type)
IREP_ID_TWO(generic_types, #generic_types)
IREP_ID_TWO(type_variables, #type_variables)
IREP_ID_ONE(havoc_object)
IREP_ID_ONE(always_inline)
IREP_ID_ONE(is_always_inline)

#undef IREP_ID_ONE
#undef IREP_ID_TWO
16 changes: 0 additions & 16 deletions src/util/replace_symbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,6 @@ bool replace_symbolt::replace(
result=false;
}

const irept &type_arg=dest.find(ID_type_arg);

if(type_arg.is_not_nil())
{
typet &type=static_cast<typet &>(dest.add(ID_type_arg));

if(!replace(type))
result=false;
}

const irept &va_arg_type=dest.find(ID_C_va_arg_type);

if(va_arg_type.is_not_nil())
Expand Down Expand Up @@ -149,12 +139,6 @@ bool replace_symbolt::have_to_replace(const exprt &dest) const
if(have_to_replace(static_cast<const typet &>(c_sizeof_type)))
return true;

const irept &type_arg=dest.find(ID_type_arg);

if(type_arg.is_not_nil())
if(have_to_replace(static_cast<const typet &>(type_arg)))
return true;

const irept &va_arg_type=dest.find(ID_C_va_arg_type);

if(va_arg_type.is_not_nil())
Expand Down