clear and restore input_Location - now handled by lang_dependent_init.
* function.c (init_function_start): Use new DECL_IS_BUILTIN macro.
* xcoffout.c (xcoff_assign_fundamental_type_number): Likewise.
+ * tree-mudflap.c (mf_file_function_line_tree): Take a location_t
+ rather than a pointer to one. Use expand_location.
+ (mf_varname_tree): Use expand_location.
+ * tree-dump.c: Use expand_location on DECL_SOURCE_LOCATION.
+ * coverage.c: Likewise.
+ * print-tree.c: Likewise.
+ * c-aux-info.c (gen_aux_info_record): Likewise.
+ * c-parse.in: Use SET_EXPR_LOCATION macro.
+ * gimple-low.c: Likewise.
+ * tree-mudflap.c: Likewise.
+ * gimplify.c: Likewise. Also use EXPR_LOCATION and EXPR_HAS_LOCATION.
+ * c-ppoutput.c: Use new source_location typedef instead of fileline.
+ * c-semantics.c: Use new macros.
+ * c-typeck.c: Likewise.
2004-06-30 Richard Sandiford <rsandifo@redhat.com>
Eric Christopher <echristo@redhat.com>
if (flag_gen_aux_info)
{
static int compiled_from_record = 0;
+ expanded_location xloc = expand_location (DECL_SOURCE_LOCATION (fndecl));
/* Each output .X file must have a header line. Write one now if we
have not yet done so. */
/* Write the actual line of auxiliary info. */
fprintf (aux_info_file, "/* %s:%d:%c%c */ %s;",
- DECL_SOURCE_FILE (fndecl),
- DECL_SOURCE_LINE (fndecl),
+ xloc.file, xloc.line,
(is_implicit) ? 'I' : (is_prototyped) ? 'N' : 'O',
(is_definition) ? 'F' : 'C',
gen_decl (fndecl, is_definition, ansi));
because (recursively) all of the component statments
should already have line numbers assigned. */
if ($2 && EXPR_P ($2))
- annotate_with_locus ($2, $1);
+ SET_EXPR_LOCATION ($2, $1);
}
;
lineno_label:
save_location label
- { if ($2) annotate_with_locus ($2, $1); }
+ { if ($2) SET_EXPR_LOCATION ($2, $1); }
;
condition: save_location expr
{ $$ = lang_hooks.truthvalue_conversion ($2);
if (EXPR_P ($$))
- annotate_with_locus ($$, $1); }
+ SET_EXPR_LOCATION ($$, $1); }
;
/* Implement -Wparenthesis by special casing IF statement directly nested
{
$$ = lang_hooks.truthvalue_conversion ($2);
if (EXPR_P ($$))
- annotate_with_locus ($$, $1);
+ SET_EXPR_LOCATION ($$, $1);
}
else
$$ = NULL;
/* Callback routines for the parser. Most of these are active only
in specific modes. */
static void cb_line_change (cpp_reader *, const cpp_token *, int);
-static void cb_define (cpp_reader *, fileline, cpp_hashnode *);
-static void cb_undef (cpp_reader *, fileline, cpp_hashnode *);
-static void cb_include (cpp_reader *, fileline, const unsigned char *,
+static void cb_define (cpp_reader *, source_location, cpp_hashnode *);
+static void cb_undef (cpp_reader *, source_location, cpp_hashnode *);
+static void cb_include (cpp_reader *, source_location, const unsigned char *,
const char *, int);
-static void cb_ident (cpp_reader *, fileline, const cpp_string *);
-static void cb_def_pragma (cpp_reader *, fileline);
+static void cb_ident (cpp_reader *, source_location, const cpp_string *);
+static void cb_def_pragma (cpp_reader *, source_location);
static void cb_read_pch (cpp_reader *pfile, const char *name,
int fd, const char *orig_name);
}
static void
-cb_ident (cpp_reader *pfile ATTRIBUTE_UNUSED, fileline line,
+cb_ident (cpp_reader *pfile ATTRIBUTE_UNUSED, source_location line,
const cpp_string *str)
{
maybe_print_line (line);
}
static void
-cb_define (cpp_reader *pfile, fileline line, cpp_hashnode *node)
+cb_define (cpp_reader *pfile, source_location line, cpp_hashnode *node)
{
maybe_print_line (line);
fputs ("#define ", print.outf);
/* Copy a #pragma directive to the preprocessed output. */
static void
-cb_def_pragma (cpp_reader *pfile, fileline line)
+cb_def_pragma (cpp_reader *pfile, source_location line)
{
maybe_print_line (line);
fputs ("#pragma ", print.outf);
if ((EXPR_P (t) || STATEMENT_CODE_P (code)) && code != LABEL_EXPR)
{
- if (!EXPR_LOCUS (t))
- annotate_with_locus (t, input_location);
+ if (!EXPR_HAS_LOCATION (t))
+ SET_EXPR_LOCATION (t, input_location);
/* When we expand a statement-tree, we must know whether or not the
statements are full-expressions. We record that fact here. */
/* Build a generic statement based on the given type of node and
arguments. Similar to `build_nt', except that we set
- EXPR_LOCUS to be the current source location. */
+ EXPR_LOCATION to be the current source location. */
/* ??? This should be obsolete with the lineno_stmt productions
in the grammar. */
ret = make_node (code);
TREE_TYPE (ret) = void_type_node;
length = TREE_CODE_LENGTH (code);
- annotate_with_locus (ret, input_location);
+ SET_EXPR_LOCATION (ret, input_location);
/* Most statements have implicit side effects all on their own,
such as control transfer. For those that do, we'll compute
}
stmt = build3 (COND_EXPR, NULL_TREE, cond, then_block, else_block);
- annotate_with_locus (stmt, if_locus);
+ SET_EXPR_LOCATION (stmt, if_locus);
add_stmt (stmt);
}
}
else
t = build1 (GOTO_EXPR, void_type_node, clab);
- annotate_with_locus (t, start_locus);
+ SET_EXPR_LOCATION (t, start_locus);
add_stmt (t);
}
exit = build (COND_EXPR, void_type_node, cond, exit, t);
exit = fold (exit);
if (cond_is_first)
- annotate_with_locus (exit, start_locus);
+ SET_EXPR_LOCATION (exit, start_locus);
else
- annotate_with_locus (exit, input_location);
+ SET_EXPR_LOCATION (exit, input_location);
}
add_stmt (top);
expr = build1 (NOP_EXPR, TREE_TYPE (expr), expr);
if (EXPR_P (expr))
- annotate_with_locus (expr, input_location);
+ SET_EXPR_LOCATION (expr, input_location);
return expr;
}
static unsigned
compute_checksum (void)
{
- unsigned chksum = DECL_SOURCE_LINE (current_function_decl);
+ expanded_location xloc
+ = expand_location (DECL_SOURCE_LOCATION (current_function_decl));
+ unsigned chksum = xloc.line;
- chksum = coverage_checksum_string (chksum,
- DECL_SOURCE_FILE (current_function_decl));
+ chksum = coverage_checksum_string (chksum, xloc.file);
chksum = coverage_checksum_string
(chksum, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl)));
if (!bbg_function_announced)
{
- const char *file = DECL_SOURCE_FILE (current_function_decl);
- unsigned line = DECL_SOURCE_LINE (current_function_decl);
+ expanded_location xloc
+ = expand_location (DECL_SOURCE_LOCATION (current_function_decl));
unsigned long offset;
if (!bbg_file_opened)
gcov_write_unsigned (compute_checksum ());
gcov_write_string (IDENTIFIER_POINTER
(DECL_ASSEMBLER_NAME (current_function_decl)));
- gcov_write_string (file);
- gcov_write_unsigned (line);
+ gcov_write_string (xloc.file);
+ gcov_write_unsigned (xloc.line);
gcov_write_length (offset);
bbg_function_announced = 1;
|| TREE_OPERAND (TREE_VALUE (data.return_statements), 0) != NULL))
{
x = build (RETURN_EXPR, void_type_node, NULL);
- annotate_with_locus (x, cfun->function_end_locus);
+ SET_EXPR_LOCATION (x, cfun->function_end_locus);
tsi_link_after (&i, x, TSI_CONTINUE_LINKING);
}
It now fills in for many such returns. Failure to remove this
will result in incorrect results for coverage analysis. */
x = TREE_VALUE (t);
+#ifdef USE_MAPPED_LOCATION
+ SET_EXPR_LOCATION (x, UNKNOWN_LOCATION);
+#else
SET_EXPR_LOCUS (x, NULL);
+#endif
tsi_link_after (&i, x, TSI_CONTINUE_LINKING);
}
mod = build (MODIFY_EXPR, TREE_TYPE (t), t, val);
class = TREE_CODE_CLASS (TREE_CODE (val));
- if (EXPR_LOCUS (val))
+ if (EXPR_HAS_LOCATION (val))
SET_EXPR_LOCUS (mod, EXPR_LOCUS (val));
else
- annotate_with_locus (mod, input_location);
+ SET_EXPR_LOCATION (mod, input_location);
/* gimplify_modify_expr might want to reduce this further. */
gimplify_and_add (mod, pre_p);
if (IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (t)))
&& ! EXPR_HAS_LOCATION (t)
&& should_carry_locus_p (t))
- annotate_with_locus (t, locus);
+ SET_EXPR_LOCATION (t, locus);
}
void
/* For reliable diagnostics during inlining, it is necessary that
every call_expr be annotated with file and line. */
- if (!EXPR_LOCUS (*expr_p))
- annotate_with_locus (*expr_p, input_location);
+ if (! EXPR_HAS_LOCATION (*expr_p))
+ SET_EXPR_LOCATION (*expr_p, input_location);
/* This may be a call to a builtin function.
tree internal_post = NULL_TREE;
tree save_expr;
int is_statement = (pre_p == NULL);
- location_t *locus;
location_t saved_location;
enum gimplify_status ret;
post_p = &internal_post;
saved_location = input_location;
- if (save_expr == error_mark_node)
- locus = NULL;
- else
- locus = EXPR_LOCUS (save_expr);
- if (locus)
- input_location = *locus;
+ if (save_expr != error_mark_node
+ && EXPR_HAS_LOCATION (*expr_p))
+ input_location = EXPR_LOCATION (*expr_p);
/* Loop over the specific gimplifiers until the toplevel node
remains the same. */
int len;
int first_rtl;
int i;
+ expanded_location xloc;
if (node == 0)
return;
fputs (" decl_7", file);
fprintf (file, " %s", GET_MODE_NAME (mode));
- fprintf (file, " file %s line %d",
- DECL_SOURCE_FILE (node), DECL_SOURCE_LINE (node));
+ xloc = expand_location (DECL_SOURCE_LOCATION (node));
+ fprintf (file, " file %s line %d", xloc.file, xloc.line);
print_node (file, "size", DECL_SIZE (node), indent + 4);
print_node (file, "unit size", DECL_SIZE_UNIT (node), indent + 4);
if (EXPR_HAS_LOCATION (node))
{
+ expanded_location xloc = expand_location (EXPR_LOCATION (node));
indent_to (file, indent+4);
- fprintf (file, "%s:%d",
- EXPR_FILENAME (node),
- EXPR_LINENO (node));
+ fprintf (file, "%s:%d", xloc.file, xloc.line);
}
fprintf (file, ">");
}
else if (DECL_P (t))
{
+ expanded_location xloc;
/* All declarations have names. */
if (DECL_NAME (t))
dump_child ("name", DECL_NAME (t));
queue_and_dump_type (di, t);
dump_child ("scpe", DECL_CONTEXT (t));
/* And a source position. */
- if (DECL_SOURCE_FILE (t))
+ xloc = expand_location (DECL_SOURCE_LOCATION (t));
+ if (xloc.file)
{
- const char *filename = strrchr (DECL_SOURCE_FILE (t), '/');
+ const char *filename = strrchr (xloc.file, '/');
if (!filename)
- filename = DECL_SOURCE_FILE (t);
+ filename = xloc.file;
else
/* Skip the slash. */
++filename;
dump_maybe_newline (di);
fprintf (di->stream, "srcp: %s:%-6d ", filename,
- DECL_SOURCE_LINE (t));
+ xloc.line);
di->column += 6 + strlen (filename) + 8;
}
/* And any declaration can be compiler-generated. */
/* Helpers. */
static tree mf_build_string (const char *string);
static tree mf_varname_tree (tree);
-static tree mf_file_function_line_tree (location_t *);
+static tree mf_file_function_line_tree (location_t);
/* Initialization of all the mf-runtime.h extern decls. */
static void mf_init_extern_trees (void);
/* Add FILENAME[:LINENUMBER]. */
{
+ expanded_location xloc = expand_location (DECL_SOURCE_LOCATION (decl));
const char *sourcefile;
- unsigned sourceline;
+ unsigned sourceline = xloc.line;
- sourcefile = DECL_SOURCE_FILE (decl);
+ sourcefile = xloc.file;
if (sourcefile == NULL && current_function_decl != NULL_TREE)
sourcefile = DECL_SOURCE_FILE (current_function_decl);
if (sourcefile == NULL)
pp_string (buf, sourcefile);
- sourceline = DECL_SOURCE_LINE (decl);
if (sourceline != 0)
{
pp_string (buf, ":");
/* And another friend, for producing a simpler message. */
static tree
-mf_file_function_line_tree (location_t *locus)
+mf_file_function_line_tree (location_t location)
{
+ expanded_location xloc = expand_location (location);
const char *file = NULL, *colon, *line, *op, *name, *cp;
char linebuf[18];
char *string;
tree result;
- /* Add FILENAME. */
- if (locus != NULL)
- file = locus->file;
- if (file == NULL && current_function_decl != NULL_TREE)
- file = DECL_SOURCE_FILE (current_function_decl);
- if (file == NULL)
- file = "<unknown file>";
+ /* Add FILENAME[:LINENUMBER]. */
+ if (xloc.file == NULL && current_function_decl != NULL_TREE)
+ xloc.file = DECL_SOURCE_FILE (current_function_decl);
+ if (xloc.file == NULL)
+ xloc.file = "<unknown file>";
- /* Add :LINENUMBER. */
- if (locus != NULL && locus->line > 0)
+ if (xloc.line > 0)
{
- sprintf (linebuf, "%d", locus->line);
+ sprintf (linebuf, "%d", xloc.line);
colon = ":";
line = linebuf;
}
globals into the cache variables. */
t = build (MODIFY_EXPR, TREE_TYPE (mf_cache_shift_decl_l),
mf_cache_shift_decl_l, mf_cache_shift_decl);
- annotate_with_locus (t, DECL_SOURCE_LOCATION (current_function_decl));
+ SET_EXPR_LOCATION (t, DECL_SOURCE_LOCATION (current_function_decl));
gimplify_to_stmt_list (&t);
shift_init_stmts = t;
t = build (MODIFY_EXPR, TREE_TYPE (mf_cache_mask_decl_l),
mf_cache_mask_decl_l, mf_cache_mask_decl);
- annotate_with_locus (t, DECL_SOURCE_LOCATION (current_function_decl));
+ SET_EXPR_LOCATION (t, DECL_SOURCE_LOCATION (current_function_decl));
gimplify_to_stmt_list (&t);
mask_init_stmts = t;
This is the body of the conditional. */
- u = tree_cons (NULL_TREE, mf_file_function_line_tree (locus), NULL_TREE);
+ u = tree_cons (NULL_TREE,
+ mf_file_function_line_tree (locus == NULL ? UNKNOWN_LOCATION
+ : *locus),
+ NULL_TREE);
u = tree_cons (NULL_TREE, dirflag, u);
u = tree_cons (NULL_TREE, size, u);
u = tree_cons (NULL_TREE, mf_value, u);
register_fncall_params);
/* Accumulate the two calls. */
- /* ??? Set EXPR_LOCUS. */
+ /* ??? Set EXPR_LOCATION. */
gimplify_stmt (®ister_fncall);
gimplify_stmt (&unregister_fncall);