Translate position to a GCC location

This commit is contained in:
2024-12-27 23:38:25 +01:00
parent 51f5603c4a
commit d46608b358
9 changed files with 182 additions and 61 deletions

26
gcc/elna-diagnostic.cc Normal file
View File

@ -0,0 +1,26 @@
#include "elna/gcc/elna-diagnostic.h"
location_t elna_gcc_location(const elna::source::position *position)
{
linemap_line_start(line_table, position->line, 0);
return linemap_position_for_column(line_table, position->column);
}
const char *elna_gcc_print_type(tree type)
{
gcc_assert(TYPE_P(type));
if (type == integer_type_node)
{
return "Int";
}
else if (type == boolean_type_node)
{
return "Boolean";
}
else
{
return "<<unknown-type>>";
}
}