Print this page
11972 resync smatch

*** 70,83 **** struct context *context; int i; if (!sym) return; ! fprintf(stderr, "%.*s%s%3d:%lu %s %s (as: %d) %p (%s:%d:%d) %s\n", indent, indent_string, typestr[sym->type], sym->bit_size, sym->ctype.alignment, ! modifier_string(sym->ctype.modifiers), show_ident(sym->ident), sym->ctype.as, sym, stream_name(sym->pos.stream), sym->pos.line, sym->pos.pos, builtin_typename(sym) ?: ""); i = 0; FOR_EACH_PTR(sym->ctype.contexts, context) { /* FIXME: should print context expression */ --- 70,84 ---- struct context *context; int i; if (!sym) return; ! fprintf(stderr, "%.*s%s%3d:%lu %s %s (as: %s) %p (%s:%d:%d) %s\n", indent, indent_string, typestr[sym->type], sym->bit_size, sym->ctype.alignment, ! modifier_string(sym->ctype.modifiers), show_ident(sym->ident), ! show_as(sym->ctype.as), sym, stream_name(sym->pos.stream), sym->pos.line, sym->pos.pos, builtin_typename(sym) ?: ""); i = 0; FOR_EACH_PTR(sym->ctype.contexts, context) { /* FIXME: should print context expression */
*** 123,146 **** {MOD_REGISTER, "register"}, {MOD_STATIC, "static"}, {MOD_EXTERN, "extern"}, {MOD_CONST, "const"}, {MOD_VOLATILE, "volatile"}, {MOD_SIGNED, "[signed]"}, {MOD_UNSIGNED, "[unsigned]"}, {MOD_CHAR, "[char]"}, {MOD_SHORT, "[short]"}, {MOD_LONG, "[long]"}, {MOD_LONGLONG, "[long long]"}, {MOD_LONGLONGLONG, "[long long long]"}, - {MOD_TYPEDEF, "[typedef]"}, {MOD_TLS, "[tls]"}, {MOD_INLINE, "inline"}, {MOD_ADDRESSABLE, "[addressable]"}, {MOD_NOCAST, "[nocast]"}, {MOD_NODEREF, "[noderef]"}, - {MOD_ACCESSED, "[accessed]"}, {MOD_TOPLEVEL, "[toplevel]"}, {MOD_ASSIGNED, "[assigned]"}, {MOD_TYPE, "[type]"}, {MOD_SAFE, "[safe]"}, {MOD_USERTYPE, "[usertype]"}, --- 124,147 ---- {MOD_REGISTER, "register"}, {MOD_STATIC, "static"}, {MOD_EXTERN, "extern"}, {MOD_CONST, "const"}, {MOD_VOLATILE, "volatile"}, + {MOD_RESTRICT, "restrict"}, + {MOD_ATOMIC, "[atomic]"}, {MOD_SIGNED, "[signed]"}, {MOD_UNSIGNED, "[unsigned]"}, {MOD_CHAR, "[char]"}, {MOD_SHORT, "[short]"}, {MOD_LONG, "[long]"}, {MOD_LONGLONG, "[long long]"}, {MOD_LONGLONGLONG, "[long long long]"}, {MOD_TLS, "[tls]"}, {MOD_INLINE, "inline"}, {MOD_ADDRESSABLE, "[addressable]"}, {MOD_NOCAST, "[nocast]"}, {MOD_NODEREF, "[noderef]"}, {MOD_TOPLEVEL, "[toplevel]"}, {MOD_ASSIGNED, "[assigned]"}, {MOD_TYPE, "[type]"}, {MOD_SAFE, "[safe]"}, {MOD_USERTYPE, "[usertype]"},
*** 180,189 **** --- 181,197 ---- prepend = ", "; show_symbol(sym); } END_FOR_EACH_PTR(sym); } + const char *show_as(struct ident *as) + { + if (!as) + return ""; + return show_ident(as); + } + struct type_name { char *start; char *end; };
*** 216,257 **** } static struct ctype_name { struct symbol *sym; const char *name; } typenames[] = { ! { & char_ctype, "char" }, ! { &schar_ctype, "signed char" }, ! { &uchar_ctype, "unsigned char" }, ! { & short_ctype, "short" }, ! { &sshort_ctype, "signed short" }, ! { &ushort_ctype, "unsigned short" }, ! { & int_ctype, "int" }, ! { &sint_ctype, "signed int" }, ! { &uint_ctype, "unsigned int" }, ! { &slong_ctype, "signed long" }, ! { & long_ctype, "long" }, ! { &ulong_ctype, "unsigned long" }, ! { & llong_ctype, "long long" }, ! { &sllong_ctype, "signed long long" }, ! { &ullong_ctype, "unsigned long long" }, ! { & lllong_ctype, "long long long" }, ! { &slllong_ctype, "signed long long long" }, ! { &ulllong_ctype, "unsigned long long long" }, ! { &void_ctype, "void" }, ! { &bool_ctype, "bool" }, ! { &string_ctype, "string" }, ! { &float_ctype, "float" }, ! { &double_ctype, "double" }, ! { &ldouble_ctype,"long double" }, ! { &incomplete_ctype, "incomplete type" }, ! { &int_type, "abstract int" }, ! { &fp_type, "abstract fp" }, ! { &label_ctype, "label type" }, ! { &bad_ctype, "bad type" }, }; const char *builtin_typename(struct symbol *sym) { int i; --- 224,265 ---- } static struct ctype_name { struct symbol *sym; const char *name; + const char *suffix; } typenames[] = { ! { & char_ctype, "char", "" }, ! { &schar_ctype, "signed char", "" }, ! { &uchar_ctype, "unsigned char", "" }, ! { & short_ctype, "short", "" }, ! { &sshort_ctype, "signed short", "" }, ! { &ushort_ctype, "unsigned short", "" }, ! { & int_ctype, "int", "" }, ! { &sint_ctype, "signed int", "" }, ! { &uint_ctype, "unsigned int", "U" }, ! { & long_ctype, "long", "L" }, ! { &slong_ctype, "signed long", "L" }, ! { &ulong_ctype, "unsigned long", "UL" }, ! { & llong_ctype, "long long", "LL" }, ! { &sllong_ctype, "signed long long", "LL" }, ! { &ullong_ctype, "unsigned long long", "ULL" }, ! { & lllong_ctype, "long long long", "LLL" }, ! { &slllong_ctype, "signed long long long", "LLL" }, ! { &ulllong_ctype, "unsigned long long long", "ULLL" }, ! { &void_ctype, "void", "" }, ! { &bool_ctype, "bool", "" }, ! { &float_ctype, "float", "F" }, ! { &double_ctype, "double", "" }, ! { &ldouble_ctype,"long double", "L" }, ! { &incomplete_ctype, "incomplete type", "" }, ! { &int_type, "abstract int", "" }, ! { &fp_type, "abstract fp", "" }, ! { &label_ctype, "label type", "" }, ! { &bad_ctype, "bad type", "" }, }; const char *builtin_typename(struct symbol *sym) { int i;
*** 260,269 **** --- 268,287 ---- if (typenames[i].sym == sym) return typenames[i].name; return NULL; } + const char *builtin_type_suffix(struct symbol *sym) + { + int i; + + for (i = 0; i < ARRAY_SIZE(typenames); i++) + if (typenames[i].sym == sym) + return typenames[i].suffix; + return NULL; + } + const char *builtin_ctypename(struct ctype *ctype) { int i; for (i = 0; i < ARRAY_SIZE(typenames); i++)
*** 274,284 **** static void do_show_type(struct symbol *sym, struct type_name *name) { const char *typename; unsigned long mod = 0; ! int as = 0; int was_ptr = 0; int restr = 0; int fouled = 0; deeper: --- 292,302 ---- static void do_show_type(struct symbol *sym, struct type_name *name) { const char *typename; unsigned long mod = 0; ! struct ident *as = NULL; int was_ptr = 0; int restr = 0; int fouled = 0; deeper:
*** 286,303 **** sym->type != SYM_BITFIELD)) { const char *s; size_t len; if (as) ! prepend(name, "<asn:%d>", as); s = modifier_string(mod); len = strlen(s); name->start -= len; memcpy(name->start, s, len); mod = 0; ! as = 0; } if (!sym) goto out; --- 304,323 ---- sym->type != SYM_BITFIELD)) { const char *s; size_t len; if (as) ! prepend(name, "%s ", show_as(as)); + if (sym->type == SYM_BASETYPE || sym->type == SYM_ENUM) + mod &= ~MOD_SPECIFIER; s = modifier_string(mod); len = strlen(s); name->start -= len; memcpy(name->start, s, len); mod = 0; ! as = NULL; } if (!sym) goto out;
*** 343,370 **** case SYM_ENUM: prepend(name, "enum %s ", show_ident(sym->ident)); break; case SYM_NODE: append(name, "%s", show_ident(sym->ident)); mod |= sym->ctype.modifiers; ! as |= sym->ctype.as; break; case SYM_BITFIELD: mod |= sym->ctype.modifiers; ! as |= sym->ctype.as; append(name, ":%d", sym->bit_size); break; case SYM_LABEL: append(name, "label(%s:%p)", show_ident(sym->ident), sym); return; case SYM_ARRAY: mod |= sym->ctype.modifiers; ! as |= sym->ctype.as; if (was_ptr) { prepend(name, "( "); append(name, " )"); was_ptr = 0; } --- 363,391 ---- case SYM_ENUM: prepend(name, "enum %s ", show_ident(sym->ident)); break; case SYM_NODE: + if (sym->ident) append(name, "%s", show_ident(sym->ident)); mod |= sym->ctype.modifiers; ! combine_address_space(sym->pos, &as, sym->ctype.as); break; case SYM_BITFIELD: mod |= sym->ctype.modifiers; ! combine_address_space(sym->pos, &as, sym->ctype.as); append(name, ":%d", sym->bit_size); break; case SYM_LABEL: append(name, "label(%s:%p)", show_ident(sym->ident), sym); return; case SYM_ARRAY: mod |= sym->ctype.modifiers; ! combine_address_space(sym->pos, &as, sym->ctype.as); if (was_ptr) { prepend(name, "( "); append(name, " )"); was_ptr = 0; }
*** 398,407 **** --- 419,432 ---- out: if (restr) prepend(name, "restricted "); if (fouled) prepend(name, "fouled "); + + // strip trailing space + if (name->end > name->start && name->end[-1] == ' ') + name->end--; } void show_type(struct symbol *sym) { char array[200];
*** 925,935 **** if (sym->ctype.modifiers & (MOD_TOPLEVEL | MOD_EXTERN | MOD_STATIC)) { printf("\tmovi.%d\t\tv%d,$%s\n", bits_in_pointer, new, show_ident(sym->ident)); return new; } if (sym->ctype.modifiers & MOD_ADDRESSABLE) { ! printf("\taddi.%d\t\tv%d,vFP,$%lld\n", bits_in_pointer, new, sym->value); return new; } printf("\taddi.%d\t\tv%d,vFP,$offsetof(%s:%p)\n", bits_in_pointer, new, show_ident(sym->ident), sym); return new; } --- 950,960 ---- if (sym->ctype.modifiers & (MOD_TOPLEVEL | MOD_EXTERN | MOD_STATIC)) { printf("\tmovi.%d\t\tv%d,$%s\n", bits_in_pointer, new, show_ident(sym->ident)); return new; } if (sym->ctype.modifiers & MOD_ADDRESSABLE) { ! printf("\taddi.%d\t\tv%d,vFP,$%lld\n", bits_in_pointer, new, 0LL); return new; } printf("\taddi.%d\t\tv%d,vFP,$offsetof(%s:%p)\n", bits_in_pointer, new, show_ident(sym->ident), sym); return new; }
*** 947,965 **** show_store_gen(bits, val, NULL, addr); } return 0; } - static int type_is_signed(struct symbol *sym) - { - if (sym->type == SYM_NODE) - sym = sym->ctype.base_type; - if (sym->type == SYM_PTR) - return 0; - return !(sym->ctype.modifiers & MOD_UNSIGNED); - } - static int show_cast_expr(struct expression *expr) { struct symbol *old_type, *new_type; int op = show_expression(expr->cast_expression); int oldbits, newbits; --- 972,981 ----
*** 971,981 **** oldbits = old_type->bit_size; newbits = new_type->bit_size; if (oldbits >= newbits) return op; new = new_pseudo(); ! is_signed = type_is_signed(old_type); if (is_signed) { printf("\tsext%d.%d\tv%d,v%d\n", oldbits, newbits, new, op); } else { printf("\tandl.%d\t\tv%d,v%d,$%lu\n", newbits, new, op, (1UL << oldbits)-1); } --- 987,997 ---- oldbits = old_type->bit_size; newbits = new_type->bit_size; if (oldbits >= newbits) return op; new = new_pseudo(); ! is_signed = is_signed_type(old_type); if (is_signed) { printf("\tsext%d.%d\tv%d,v%d\n", oldbits, newbits, new, op); } else { printf("\tandl.%d\t\tv%d,v%d,$%lu\n", newbits, new, op, (1UL << oldbits)-1); }
*** 994,1004 **** static int show_fvalue(struct expression *expr) { int new = new_pseudo(); long double value = expr->fvalue; ! printf("\tmovf.%d\t\tv%d,$%Lf\n", expr->ctype->bit_size, new, value); return new; } static int show_string_expr(struct expression *expr) { --- 1010,1020 ---- static int show_fvalue(struct expression *expr) { int new = new_pseudo(); long double value = expr->fvalue; ! printf("\tmovf.%d\t\tv%d,$%Le\n", expr->ctype->bit_size, new, value); return new; } static int show_string_expr(struct expression *expr) {
*** 1016,1030 **** } static int show_conditional_expr(struct expression *expr) { int cond = show_expression(expr->conditional); ! int true = show_expression(expr->cond_true); ! int false = show_expression(expr->cond_false); int new = new_pseudo(); ! printf("[v%d]\tcmov.%d\t\tv%d,v%d,v%d\n", cond, expr->ctype->bit_size, new, true, false); return new; } static int show_statement_expr(struct expression *expr) { --- 1032,1046 ---- } static int show_conditional_expr(struct expression *expr) { int cond = show_expression(expr->conditional); ! int valt = show_expression(expr->cond_true); ! int valf = show_expression(expr->cond_false); int new = new_pseudo(); ! printf("[v%d]\tcmov.%d\t\tv%d,v%d,v%d\n", cond, expr->ctype->bit_size, new, valt, valf); return new; } static int show_statement_expr(struct expression *expr) {
*** 1167,1174 **** --- 1183,1193 ---- warning(expr->pos, "unable to show index expression"); return 0; case EXPR_TYPE: warning(expr->pos, "unable to show type expression"); return 0; + case EXPR_ASM_OPERAND: + warning(expr->pos, "unable to show asm operand expression"); + return 0; } return 0; }