blob: edb20eb0c61a7a85a5c7a23856322478cca60ac6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
/**
** \file inlining/pruner.cc
** \brief Implementation of inlining::Pruner.
*/
#include <inlining/pruner.hh>
namespace inlining
{
using namespace ast;
ast::FunctionChunk* Pruner::prune(ast::FunctionChunk& e)
{
while (true)
{
auto [remove_begin, remove_end] =
std::ranges::remove_if(e, [&](ast::FunctionDec* func_dec) {
if (!func_dec->body_get() || func_dec->name_get() == "_main")
return false;
else
return called_functions_[func_dec->name_get()] == 0;
});
if (remove_begin == remove_end)
break;
e.erase(remove_begin, remove_end);
}
return new FunctionChunk(e.location_get(), &e.decs_get());
}
// FIXME: Some code was deleted here.
} // namespace inlining
|