This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH to use cpplib's source_location for location_t
- From: Richard Henderson <rth at redhat dot com>
- To: Per Bothner <per at bothner dot com>
- Cc: Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 28 Jun 2004 15:21:14 -0700
- Subject: Re: PATCH to use cpplib's source_location for location_t
- References: <40E093CC.40802@bothner.com>
On Mon, Jun 28, 2004 at 02:55:24PM -0700, Per Bothner wrote:
> +#ifdef __GNUC__
> +#define expand_location(SOURCE_LOCATION) __extension__ ({ \
> + struct location_s __t; \
> + source_location __line = (SOURCE_LOCATION); \
> + if (__line == 0) { __t.file = NULL; __t.line = 0; } \
> + else { \
> + const struct line_map *__map = linemap_lookup (&line_table,__line); \
> + __t.file = __map->to_file; \
> + __t.line = SOURCE_LINE (__map, __line); \
> + };\
> + __t; })
> +#else
> +expanded location
> +expand_location (source_location fline)
Typos. Any reason to have this inline at all, GCC or otherwise?
> +#define LOCATION_FILE(FILELINE) __extension__ \
> +#define LOCATION_LINE(FILELINE) __extension__ \
Likewise. I'm just as happy with these as lowercase out-of-line
functions, always. You'd have to prove to me that they're an
actual bottleneck to want to do otherwise.
> +#ifdef USE_MAPPED_LOCATION
> +/* Say where in the code a source line starts, for symbol table's sake.
> + Operand:
> + 4: unused if line number > 0, note-specific data otherwise.
> + 5: line number if > 0, enum note_insn otherwise.
> + 6: CODE_LABEL_NUMBER if line number == NOTE_INSN_DELETED_LABEL. */
> +#else
> /* Say where in the code a source line starts, for symbol table's sake.
> Operand:
> 4: filename, if line number > 0, note-specific data otherwise.
> + 4: unused if line number > 0, note-specific data otherwise.
One or both of these are wrong.
> +#ifdef USE_MAPPED_LOCATION
> + SET_EXPR_LOCATION (new_stmt, EXPR_LOCATION (orig_stmt));
> +#else
> SET_EXPR_LOCUS (new_stmt, EXPR_LOCUS (orig_stmt));
> +#endif
Seems like this idiom could get mapped to
#define EXPR_LOCUS(N) (&EXPR_LOCATION (N))
#define SET_EXPR_LOCUS(N,L) (EXPR_LOCATION (N) = *(L))
or something similar to avoid the ifdeffery.
> +#ifdef USE_MAPPED_LOCATION
> + SET_EXPR_LOCATION (t, UNKNOWN_LOCATION);
> +#else
> SET_EXPR_LOCUS (t, NULL);
> +#endif
Likewise invent a macro like CLEAR_EXPR_LOCATION.
r~