#include "util.h"
static inline __attribute__((noreturn))
-void out_of_memory(void) {
+void out_of_memory(void)
+{
panic("out of memory");
}
-void *xmalloc(size_t size) {
+void *xmalloc(size_t size)
+{
void *res = malloc(size);
if (UNLIKELY(res == NULL))
return res;
}
-void *xcalloc(size_t num, size_t size) {
+void *xcalloc(size_t num, size_t size)
+{
void *res = calloc(num, size);
if (UNLIKELY(res == NULL))
return res;
}
-void *xrealloc(void *ptr, size_t size) {
+void *xrealloc(void *ptr, size_t size)
+{
void *res = realloc (ptr, size);
if (UNLIKELY(res == NULL))
return res;
}
-char *xstrdup(const char *str) {
+char *xstrdup(const char *str)
+{
size_t len = strlen(str) + 1;
char *res = xmalloc(len);
memcpy(res, str, len);
/**
* Keep all memory edges of the given block.
*/
-static void keep_all_memory(ir_node *block) {
+static void keep_all_memory(ir_node *block)
+{
ir_node *old = get_cur_block();
set_cur_block(block);
* @param dbi debug info
* @param expr the IL assume expression
*/
-static ir_node *handle_assume(dbg_info *dbi, const expression_t *expression) {
+static ir_node *handle_assume(dbg_info *dbi, const expression_t *expression)
+{
switch(expression->kind) {
case EXPR_BINARY_EQUAL:
case EXPR_BINARY_NOTEQUAL:
}
}
-static void ms_try_statement_to_firm(ms_try_statement_t *statement) {
+static void ms_try_statement_to_firm(ms_try_statement_t *statement)
+{
statement_to_firm(statement->try_statement);
warningf(&statement->base.source_position, "structured exception handling ignored");
}
-static void leave_statement_to_firm(leave_statement_t *statement) {
+static void leave_statement_to_firm(leave_statement_t *statement)
+{
errorf(&statement->base.source_position, "__leave not supported yet");
}
/**
* Generate possible IJmp branches to a given label block.
*/
-static void gen_ijmp_branches(ir_node *block) {
+static void gen_ijmp_branches(ir_node *block)
+{
ir_node *ijmp;
for (ijmp = ijmp_list; ijmp != NULL; ijmp = get_irn_link(ijmp)) {
add_immBlock_pred(block, ijmp);
/**
* prints an additional source position
*/
-static void print_source_position(FILE *out, const source_position_t *pos) {
+static void print_source_position(FILE *out, const source_position_t *pos)
+{
fprintf(out, "at line %u", pos->linenr);
if (curr_pos == NULL || curr_pos->input_name != pos->input_name)
fprintf(out, " of \"%s\"", pos->input_name);
int (*is_digit)(unsigned vchar);
};
-static unsigned string_first(vchar_t *self) {
+static unsigned string_first(vchar_t *self)
+{
self->position = 0;
const string_t *string = self->string;
return string->begin[0];
}
-static unsigned string_next(vchar_t *self) {
+static unsigned string_next(vchar_t *self)
+{
++self->position;
const string_t *string = self->string;
return string->begin[self->position];
}
-static int string_isdigit(unsigned vchar) {
+static int string_isdigit(unsigned vchar)
+{
return isdigit(vchar);
}
-static unsigned wstring_first(vchar_t *self) {
+static unsigned wstring_first(vchar_t *self)
+{
self->position = 0;
const wide_string_t *wstring = self->string;
return wstring->begin[0];
}
-static unsigned wstring_next(vchar_t *self) {
+static unsigned wstring_next(vchar_t *self)
+{
++self->position;
const wide_string_t *wstring = self->string;
return wstring->begin[self->position];
}
-static int wstring_isdigit(unsigned vchar) {
+static int wstring_isdigit(unsigned vchar)
+{
return iswdigit(vchar);
}
-static bool atend(vchar_t *self) {
+static bool atend(vchar_t *self)
+{
return self->position + 1 == self->size;
}
* A replacement for strtoull. Only those parts needed for
* our parser are implemented.
*/
-static unsigned long long parse_int_string(const char *s, const char **endptr, int base) {
+static unsigned long long parse_int_string(const char *s, const char **endptr, int base)
+{
unsigned long long v = 0;
switch (base) {
/**
* Parse a pragma directive.
*/
-static void parse_pragma(void) {
+static void parse_pragma(void)
+{
bool unknown_pragma = true;
next_pp_token();
fprintf(stderr, "Usage %s input [-o output] [-c]\n", argv0);
}
-static void print_cparser_version(void) {
+static void print_cparser_version(void)
+{
printf("cparser (%s) using libFirm (%u.%u",
cparser_REVISION, ir_get_version_major(),
ir_get_version_minor());
/**
* Check the semantic restrictions for a div/mod expression.
*/
-static void semantic_divmod_arithmetic(binary_expression_t *expression) {
+static void semantic_divmod_arithmetic(binary_expression_t *expression)
+{
semantic_binexpr_arithmetic(expression);
warn_div_by_zero(expression);
}
*
* @param statement the switch statement to check
*/
-static void check_enum_cases(const switch_statement_t *statement) {
+static void check_enum_cases(const switch_statement_t *statement)
+{
const type_t *type = skip_typeref(statement->expression->base.type);
if (! is_type_enum(type))
return;
* Returns the value of a digit.
* The only portable way to do it ...
*/
-static int digit_value(int digit) {
+static int digit_value(int digit)
+{
switch (digit) {
case '0': return 0;
case '1': return 1;
return type;
}
-type_qualifiers_t get_type_qualifier(const type_t *type, bool skip_array_type) {
+type_qualifiers_t get_type_qualifier(const type_t *type, bool skip_array_type)
+{
type_qualifiers_t qualifiers = TYPE_QUALIFIER_NONE;
while (true) {
/**
* Find the atomic type kind representing a given size (signed).
*/
-atomic_type_kind_t find_signed_int_atomic_type_kind_for_size(unsigned size) {
+atomic_type_kind_t find_signed_int_atomic_type_kind_for_size(unsigned size)
+{
static atomic_type_kind_t kinds[32];
assert(size < 32);
/**
* Find the atomic type kind representing a given size (signed).
*/
-atomic_type_kind_t find_unsigned_int_atomic_type_kind_for_size(unsigned size) {
+atomic_type_kind_t find_unsigned_int_atomic_type_kind_for_size(unsigned size)
+{
static atomic_type_kind_t kinds[32];
assert(size < 32);