This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tree-ssa] PATCH to return to DECL_SOURCE_LOCATION


The change to use TREE_LOCUS for both expressions and decls seemed like a
good idea at the time, but it has caused a number of bugs: when we ask for
the location of an expression, we want to know where it occurs in the text.
But if that expression is actually a decl, the answer we get is where the
original declaration is located, not where the use we're dealing with
occurs.  As a result, code that wants the expr location needed to write

  if (TREE_LOCUS (expr) && IS_EXPR_CODE_CLASS (expr))

I've fixed a couple of bugs caused by omitting the second part of this
check.

The fix is to use different macros for the two concepts.  This patch
returns to using DECL_SOURCE_LOCATION for the point of declaration, as on
the trunk, and changes expressions to use EXPR_LOCUS.  It also moves the
locus field from tree_common into tree_decl and tree_expr, saving some
space in things like lists and vectors that have no inherent source
location.

This patch produces a small speed improvement: 0.07% in bootstrap and 1% in
testing.  It should also simplify merges from the trunk quite a bit.

Booted and tested athlon-pc-linux-gnu.

2003-09-24  Jason Merrill  <jason@redhat.com>

	* tree.h (DECL_SOURCE_LOCATION): Resurrect.
	(DECL_SOURCE_FILE, DECL_SOURCE_LINE): Likewise.
	(EXPR_LOCUS): Renamed from TREE_LOCUS.  Null for non-exprs.
	(SET_EXPR_LOCUS): New macro.
	(EXPR_FILENAME): Renamed from TREE_FILENAME.
	(EXPR_LINENO): Renamed from TREE_LINENO.
	(struct tree_common): Remove locus field.
	(struct tree_decl): Re-add locus field.
	(struct tree_expr): Add locus field.
	* c-aux-info.c, c-decl.c, coverage.c, c-parse.in, dbxout.c,
	diagnostic.c, dwarf2out.c, expr.c, function.c, gimplify.c,
	integrate.c, print-tree.c, stmt.c, tree.c, tree-cfg.c,
	tree-dump.c, tree-flow-inline.h, config/alpha/alpha.c,
	config/mips/mips.c, objc/objc-act.c: Adjust.
cp/
	* class.c, decl.c, decl2.c, error.c, init.c, lex.c, method.c,
	pt.c, semantics.c, tree.c: Revert from TREE_LOCUS to
	DECL_SOURCE_LOCATION.
f/
	* com.c, ste.c: Revert earlier change.
fortran/
	* f95-lang.c, trans-decl.c: Use DECL_SOURCE_LOCATION instead of
	TREE_LOCUS.
java/
	* decl.c, jcf-parse.c, jcf-write.c, parse.h, parse.y, resource.c:
	Revert from TREE_LOCUS to DECL_SOURCE_LOCATION.
treelang/
	* treetree.c: Revert 2003-01-15 change.

Attachment: locus.patch.gz
Description: GNU Zip compressed data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]