aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPer Bothner <per@bothner.com>2004-06-30 11:11:14 -0700
committerPer Bothner <bothner@gcc.gnu.org>2004-06-30 11:11:14 -0700
commita281759fdf4cc20f179d37ef875f7c233ab68f46 (patch)
tree01829581c8eb09eede00ea3a28703fb4b3440dc5
parent3c20847b8301eb9aa407ee8273b6e738e7067ee0 (diff)
Conditionally compile support for --enable-mapped_location.
* 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. From-SVN: r83920
-rw-r--r--gcc/ChangeLog14
-rw-r--r--gcc/c-aux-info.c4
-rw-r--r--gcc/c-parse.in8
-rw-r--r--gcc/c-ppoutput.c16
-rw-r--r--gcc/c-semantics.c8
-rw-r--r--gcc/c-typeck.c10
-rw-r--r--gcc/coverage.c15
-rw-r--r--gcc/gimple-low.c6
-rw-r--r--gcc/gimplify.c20
-rw-r--r--gcc/print-tree.c10
-rw-r--r--gcc/tree-dump.c10
-rw-r--r--gcc/tree-mudflap.c39
12 files changed, 89 insertions, 71 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c477d538859..b0eb970d161 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -40,6 +40,20 @@
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>
diff --git a/gcc/c-aux-info.c b/gcc/c-aux-info.c
index 70c85a225d8..8d457836c75 100644
--- a/gcc/c-aux-info.c
+++ b/gcc/c-aux-info.c
@@ -554,6 +554,7 @@ gen_aux_info_record (tree fndecl, int is_definition, int is_implicit,
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. */
@@ -569,8 +570,7 @@ gen_aux_info_record (tree fndecl, int is_definition, int is_implicit,
/* 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));
diff --git a/gcc/c-parse.in b/gcc/c-parse.in
index 96468279245..d70139182b3 100644
--- a/gcc/c-parse.in
+++ b/gcc/c-parse.in
@@ -2092,19 +2092,19 @@ lineno_stmt:
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
@@ -2191,7 +2191,7 @@ for_cond_expr: save_location xexpr
{
$$ = lang_hooks.truthvalue_conversion ($2);
if (EXPR_P ($$))
- annotate_with_locus ($$, $1);
+ SET_EXPR_LOCATION ($$, $1);
}
else
$$ = NULL;
diff --git a/gcc/c-ppoutput.c b/gcc/c-ppoutput.c
index 06816e9b885..d34ec61fc85 100644
--- a/gcc/c-ppoutput.c
+++ b/gcc/c-ppoutput.c
@@ -51,12 +51,12 @@ static void maybe_print_line (source_location);
/* 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);
@@ -300,7 +300,7 @@ cb_line_change (cpp_reader *pfile, const cpp_token *token,
}
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);
@@ -309,7 +309,7 @@ cb_ident (cpp_reader *pfile ATTRIBUTE_UNUSED, fileline 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);
@@ -401,7 +401,7 @@ pp_file_change (const struct line_map *map)
/* 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);
diff --git a/gcc/c-semantics.c b/gcc/c-semantics.c
index 9512947216c..f164c9596ed 100644
--- a/gcc/c-semantics.c
+++ b/gcc/c-semantics.c
@@ -132,8 +132,8 @@ add_stmt (tree t)
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. */
@@ -149,7 +149,7 @@ add_stmt (tree t)
/* 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. */
@@ -166,7 +166,7 @@ build_stmt (enum tree_code code, ...)
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
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 2a2c2548e14..5b2be72445b 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -6540,7 +6540,7 @@ c_finish_if_stmt (location_t if_locus, tree cond, tree then_block,
}
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);
}
@@ -6584,7 +6584,7 @@ c_finish_loop (location_t start_locus, tree cond, tree incr, tree body,
}
else
t = build1 (GOTO_EXPR, void_type_node, clab);
- annotate_with_locus (t, start_locus);
+ SET_EXPR_LOCATION (t, start_locus);
add_stmt (t);
}
@@ -6592,9 +6592,9 @@ c_finish_loop (location_t start_locus, tree cond, tree incr, tree body,
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);
@@ -6687,7 +6687,7 @@ c_process_expr_stmt (tree expr)
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;
}
diff --git a/gcc/coverage.c b/gcc/coverage.c
index e39f0a66cc7..c67300b8a7c 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -500,10 +500,11 @@ coverage_checksum_string (unsigned chksum, const char *string)
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)));
@@ -523,8 +524,8 @@ coverage_begin_output (void)
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)
@@ -546,8 +547,8 @@ coverage_begin_output (void)
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;
diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c
index 32e5ceec5f4..f5ee15bdd3b 100644
--- a/gcc/gimple-low.c
+++ b/gcc/gimple-low.c
@@ -94,7 +94,7 @@ lower_function_body (void)
|| 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);
}
@@ -109,7 +109,11 @@ lower_function_body (void)
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);
}
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index c596ad90428..276c1990f14 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -453,10 +453,10 @@ internal_get_tmp_var (tree val, tree *pre_p, tree *post_p, bool is_formal)
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);
@@ -559,7 +559,7 @@ annotate_one_with_locus (tree t, location_t locus)
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
@@ -1832,8 +1832,8 @@ gimplify_call_expr (tree *expr_p, tree *pre_p, bool (*gimple_test_f) (tree))
/* 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.
@@ -3435,7 +3435,6 @@ gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p,
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;
@@ -3455,12 +3454,9 @@ gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p,
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. */
diff --git a/gcc/print-tree.c b/gcc/print-tree.c
index 1d8ca961831..055f8f36097 100644
--- a/gcc/print-tree.c
+++ b/gcc/print-tree.c
@@ -160,6 +160,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
int len;
int first_rtl;
int i;
+ expanded_location xloc;
if (node == 0)
return;
@@ -372,8 +373,8 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
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);
@@ -745,10 +746,9 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
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, ">");
diff --git a/gcc/tree-dump.c b/gcc/tree-dump.c
index 314c29f8e8e..2e945e46143 100644
--- a/gcc/tree-dump.c
+++ b/gcc/tree-dump.c
@@ -315,6 +315,7 @@ dequeue_and_dump (dump_info_p di)
}
else if (DECL_P (t))
{
+ expanded_location xloc;
/* All declarations have names. */
if (DECL_NAME (t))
dump_child ("name", DECL_NAME (t));
@@ -325,18 +326,19 @@ dequeue_and_dump (dump_info_p di)
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. */
diff --git a/gcc/tree-mudflap.c b/gcc/tree-mudflap.c
index dcde2ac9555..dbb994d679a 100644
--- a/gcc/tree-mudflap.c
+++ b/gcc/tree-mudflap.c
@@ -50,7 +50,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
/* 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);
@@ -117,10 +117,11 @@ mf_varname_tree (tree decl)
/* 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)
@@ -128,7 +129,6 @@ mf_varname_tree (tree decl)
pp_string (buf, sourcefile);
- sourceline = DECL_SOURCE_LINE (decl);
if (sourceline != 0)
{
pp_string (buf, ":");
@@ -188,25 +188,23 @@ mf_varname_tree (tree decl)
/* 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;
}
@@ -348,13 +346,13 @@ mf_decl_cache_locals (void)
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;
@@ -548,7 +546,10 @@ mf_build_check_statement_for (tree addr, tree size,
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);
@@ -920,7 +921,7 @@ mx_register_decls (tree decl, tree *stmt_list)
register_fncall_params);
/* Accumulate the two calls. */
- /* ??? Set EXPR_LOCUS. */
+ /* ??? Set EXPR_LOCATION. */
gimplify_stmt (&register_fncall);
gimplify_stmt (&unregister_fncall);