diff mbox

[pph] Rebuild compilation context from PPH images (5/6) (issue4410045)

Message ID 20110414194141.F3BA2A00D@topo.tor.corp.google.com
State New
Headers show

Commit Message

Diego Novillo April 14, 2011, 7:41 p.m. UTC
This patch factors out the allocation of sorted_fields_type into a new
function so it can be called from the PPH reader.

    
    	* class.c (sorted_fields_type_new): Factor out of ...
    	(finish_struct_1): ... here.



--
This patch is available for review at http://codereview.appspot.com/4410045
diff mbox

Patch

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 1325260..b040449 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -5536,6 +5536,18 @@  determine_key_method (tree type)
   return;
 }
 
+
+/* Allocate and return an instance of struct sorted_fields_type with
+   N fields.  */
+
+struct sorted_fields_type *
+sorted_fields_type_new (int n)
+{
+  return ggc_alloc_sorted_fields_type (sizeof (struct sorted_fields_type)
+				       + n * sizeof (tree));
+}
+
+
 /* Perform processing required when the definition of T (a class type)
    is complete.  */
 
@@ -5665,8 +5677,7 @@  finish_struct_1 (tree t)
   n_fields = count_fields (TYPE_FIELDS (t));
   if (n_fields > 7)
     {
-      struct sorted_fields_type *field_vec = ggc_alloc_sorted_fields_type
-	 (sizeof (struct sorted_fields_type) + n_fields * sizeof (tree));
+      struct sorted_fields_type *field_vec = sorted_fields_type_new (n_fields);
       field_vec->len = n_fields;
       add_fields_to_record_type (TYPE_FIELDS (t), field_vec, 0);
       qsort (field_vec->elts, n_fields, sizeof (tree),