[libcpp] RFA: Add support for comments retrieval

Tom Tromey tromey@redhat.com
Fri Sep 26 16:07:00 GMT 2008


>>>>> "Arnaud" == Arnaud Charlet <charlet@adacore.com> writes:

Arnaud> This is a patch that adds support for easy retrieval of C/C++ comments
Arnaud> parsed by libcpp.

I think the general idea is ok.

There are a few changes I would like.  Some of these are nits :)

Arnaud> 	* lex.c (store_comment, cpp_get_comments): New function.s 

Trailing 's'.

Arnaud> +typedef struct
Arnaud> +{
Arnaud> +  const char *comment;
Arnaud> +  source_location sloc;
Arnaud> +} cpp_comment;

Please put a comment on the struct and the various fields.

Arnaud> +typedef struct
Arnaud> +{
Arnaud> +  cpp_comment *entries;
Arnaud> +  int count;
Arnaud> +  int allocated;
Arnaud> +} cpp_comment_table;

Ditto.

Arnaud> +/* Table for storing comments in the pfile->state.save_comments case.
Arnaud> +   In other cases there is no overhead. */
Arnaud> +
Arnaud> +static cpp_comment_table comments = {NULL, 0, 0};

Instead of a global, I think this should be in struct cpp_reader.
This implies that cpp_get_comments needs a cpp_reader argument.
Also, destroying the cpp_reader should free the comment entries.

I wonder if we should have a new option (in cpp_options) controlling
this.

Tom



More information about the Gcc-patches mailing list