Skip to content

Commit

Permalink
Convert vec<> into a POD.
Browse files Browse the repository at this point in the history
This fixes PR 55398 by making vec<> a true POD.  I thought we could get
away with having private fields, but we can't.  We fail to pass vec<>
instances through varargs.

The patch makes every field public and mangles the field names in the
hope that no future patch will try to make use of them directly.  It's
horrible, but I could not think of anything better.

Tested with clang++ as the host compiler.

2012-11-20  Diego Novillo  <[email protected]>

    PR middle-end/55398
    * vec.h (class vec_prefix): Make every field public.
    Rename field alloc_ to alloc_PRIVATE_.
    Rename field num_ to num_PRIVATE_.
    Update all users.
    (class vec<T, A, vl_embed>): Make every field public.
    Rename field pfx_ to pfx_PRIVATE_.
    Rename field data_ to data_PRIVATE_.
    Update all users.
    (class vec<T, A, vl_ptr>): Make every field public.
    Rename field vec_ to vec_PRIVATE_.
    Update all users.

From-SVN: r193667
  • Loading branch information
dnovillo authored and Diego Novillo committed Nov 20, 2012
1 parent 4a397c3 commit 38f2ca3
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 101 deletions.
15 changes: 15 additions & 0 deletions gcc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
2012-11-20 Diego Novillo <[email protected]>

PR middle-end/55398
* vec.h (class vec_prefix): Make every field public.
Rename field alloc_ to alloc_PRIVATE_.
Rename field num_ to num_PRIVATE_.
Update all users.
(class vec<T, A, vl_embed>): Make every field public.
Rename field pfx_ to pfx_PRIVATE_.
Rename field data_ to data_PRIVATE_.
Update all users.
(class vec<T, A, vl_ptr>): Make every field public.
Rename field vec_ to vec_PRIVATE_.
Update all users.

2012-11-20 Kai Tietz <[email protected]>

PR target/55268
Expand Down
13 changes: 7 additions & 6 deletions gcc/vec.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ vec_descriptor (const char *name, int line, const char *function)
/* Account the overhead. */

void
vec_prefix::register_overhead (size_t size, const char *name, int line,
const char *function)
vec_prefix::register_overhead_PRIVATE_ (size_t size, const char *name, int line,
const char *function)
{
struct vec_descriptor *loc = vec_descriptor (name, line, function);
struct ptr_hash_entry *p = XNEW (struct ptr_hash_entry);
Expand All @@ -148,7 +148,7 @@ vec_prefix::register_overhead (size_t size, const char *name, int line,
/* Notice that the memory allocated for the vector has been freed. */

void
vec_prefix::release_overhead (void)
vec_prefix::release_overhead_PRIVATE_ (void)
{
PTR *slot = htab_find_slot_with_hash (ptr_hash, this,
htab_hash_pointer (this),
Expand All @@ -165,15 +165,16 @@ vec_prefix::release_overhead (void)
exponentially. PFX is the control data for the vector. */

unsigned
vec_prefix::calculate_allocation (vec_prefix *pfx, unsigned reserve, bool exact)
vec_prefix::calculate_allocation_PRIVATE_ (vec_prefix *pfx, unsigned reserve,
bool exact)
{
unsigned alloc = 0;
unsigned num = 0;

if (pfx)
{
alloc = pfx->alloc_;
num = pfx->num_;
alloc = pfx->alloc_PRIVATE_;
num = pfx->num_PRIVATE_;
}
else if (!reserve)
/* If there's no vector, and we've not requested anything, then we
Expand Down
Loading

0 comments on commit 38f2ca3

Please sign in to comment.