Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(4038)

Issue 4392047: [pph] Reconstruct a header file from a pph image (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years ago by Diego Novillo
Modified:
13 years ago
Reviewers:
CC:
Lawrence Crowl, gcc-patches_gcc.gnu.org
Visibility:
Public.

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+30 lines, -6 lines) Patch
M gcc/cp/pph.c View 2 chunks +30 lines, -6 lines 0 comments Download

Messages

Total messages: 2
Diego Novillo
This patch, together with the others I sent today, allows us to reconstruct all the ...
13 years ago (2011-04-12 20:02:45 UTC) #1
Lawrence Crowl
13 years ago (2011-04-13 00:35:38 UTC) #2
LGTM

On 4/12/11, Diego Novillo <dnovillo@google.com> wrote:
>
> This patch, together with the others I sent today, allows us to
> reconstruct all the symbols and types stored inside a pph image.  This
> is not all we need, but it allows me to get basic declarations and
> types reconstructed from pph images.
>
> This causes ~57 failures in pph.exp.  The more problematic one is an
> infinite recursion that causes memory bloat.  I'm not committing this
> patch yet until I figure this one out.
>
> Other failures are due to missing bits in the pickling.  I'll be
> fixing those in subsequent patches.
>
>
> 2011-04-12  Diego Novillo  <dnovillo@google.com>
>
> 	* pph.c (pph_add_names_to_namespace): New.
> 	(pph_read_file_contents): Call it.
> 	Call cpp_lt_replay.
>
> diff --git a/gcc/cp/pph.c b/gcc/cp/pph.c
> index 74d1d50..6584e72 100644
> --- a/gcc/cp/pph.c
> +++ b/gcc/cp/pph.c
> @@ -1937,6 +1937,28 @@ report_validation_error (const char *filename,
>  }
>
>
> +
> +/* Add all the new names declared in NEW_NS to NS.  */
> +
> +static void
> +pph_add_names_to_namespace (tree ns, tree new_ns)
> +{
> +  struct cp_binding_level *new_level, *level;
> +  tree t, chain;
> +
> +  level = NAMESPACE_LEVEL (ns);
> +  new_level = NAMESPACE_LEVEL (new_ns);
> +
> +  for (t = new_level->names; t; t = chain)
> +    {
> +      /* Pushing a decl into a scope clobbers its DECL_CHAIN.
> +	 Preserve it.  */
> +      chain = DECL_CHAIN (t);
> +      pushdecl_with_scope (t, level, /*is_friend=*/false);
> +    }
> +}
> +
> +
>  /* Read contents of PPH file in STREAM.  */
>
>  static void
> @@ -1946,25 +1968,27 @@ pph_read_file_contents (pph_stream *stream)
>    cpp_ident_use *bad_use;
>    const char *cur_def;
>    cpp_idents_used idents_used;
> +  tree file_ns;
>
>    pth_load_identifiers (&idents_used, stream);
>
> -  /*FIXME pph: This validation is weak.  */
> +  /* FIXME pph: This validation is weak.  */
>    verified = cpp_lt_verify_1 (parse_in, &idents_used, &bad_use, &cur_def,
> true);
>    if (!verified)
>      report_validation_error (stream->name, bad_use->ident_str, cur_def,
>                               bad_use->before_str, bad_use->after_str);
>
> -  /* FIXME pph: We cannot replay the macro definitions
> -     as long as we are still reading the actual file.
> +  /* Re-instantiate all the pre-processor symbols defined by STREAM.  */
>    cpp_lt_replay (parse_in, &idents_used);
> -  */
>
> -  pph_input_tree (stream);
> +  /* Read global_namespace from STREAM and add all the names defined
> +     there to the current global_namespace.  */
> +  file_ns = pph_input_tree (stream);
> +  pph_add_names_to_namespace (global_namespace, file_ns);
>  }
>
>
> -/* Read PPH file.  */
> +/* Read PPH file FILENAME.  */
>
>  static void
>  pph_read_file (const char *filename)
>
> --
> This patch is available for review at http://codereview.appspot.com/4392047
>


-- 
Lawrence Crowl
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b