Here's a follow-up patch kit to v2 which extends the C++ FE to capture
source location information for *all* constants and uses-of-decls,
not just at callsites like v2 does.
I kept the simplifying restriction of not adding wrapper nodes when
processing_template_decl.
Unfortunately it's not complete, but given that the end of stage 1
is on us, I thought I'd post what I have.
Much of the kit involves stripping away the wrapper nodes whenever
we need to look at the TREE_CODE of an expression.
Limitations:
* it doesn't bootstrap yet; with a --disable-bootstrap build the
regression tests mostly work (332 new FAILs on x86_64-pc-linux-gnu,
out of ~330k tests). I've been frantically trying to fix all of
these, but I seem to be reaching the harder issues and it's clear
I'm not going to be done.
* only tested so far on x86_64-pc-linux-gnu; I'm fairly sure there
are target-specific attribute handlers that would need fixing.
* no performance data yet.
* the kit doesn't *use* the locations. There are dozens of
diagnostics that are implicitly using input_location, which could
be improved by using an EXPR_LOCATION, given that we'd be able to
guarantee that we had locations for every expression, which would
give lots of little usability wins.
...but it looks like I'm out of time for gcc8 stage1.
Does this approach look promising for gcc 9?
For gcc 8, I'd like to ensure that we have location_t values
for all arguments at C++ callsites; the v2 version of the kit would
do that, alternatively there's the:
"[PATCH] C++: use an optional vec<location_t> for callsites"
https://gcc.gnu.org/ml/gcc-patches/2017-08/msg01392.html
approach.
Thoughts?
Dave
David Malcolm (11):
C++: Add location wrappers for all constants and decls
cp_tree::maybe_add_location_wrapper: no-op for template decls
Implement STRIP_ANY_LOCATION_WRAPPER_SAFE
C++: add cp_expr::strip_any_location_wrapper method
C++: finish_call_expr: strip location wrapper
gcc: Handle location wrappers in operand_equal_p
c-family: handle location wrappers
C++: handle location wrappers
objc: handle location wrappers in objc_maybe_build_component_ref
i386: handle location wrappers in ix86_handle_cconv_attribute
config: handle location wrappers in various attributes (untested)
gcc/c-family/c-attribs.c | 1 +
gcc/c-family/c-common.c | 9 ++++
gcc/c-family/c-format.c | 2 +
gcc/c-family/c-warn.c | 25 ++++++----
gcc/config/arc/arc.c | 2 +
gcc/config/epiphany/epiphany.c | 3 ++
gcc/config/i386/i386.c | 1 +
gcc/config/ia64/ia64.c | 1 +
gcc/config/m32r/m32r.c | 2 +
gcc/config/mips/mips.c | 2 +
gcc/config/msp430/msp430.c | 2 +-
gcc/config/s390/s390.c | 2 +
gcc/cp/call.c | 7 +++
gcc/cp/class.c | 1 +
gcc/cp/constexpr.c | 1 +
gcc/cp/cp-tree.h | 17 +++++--
gcc/cp/cvt.c | 1 +
gcc/cp/decl.c | 4 ++
gcc/cp/expr.c | 2 +
gcc/cp/lambda.c | 3 ++
gcc/cp/name-lookup.c | 1 +
gcc/cp/parser.c | 94 +++++++++++++++++++++----------------
gcc/cp/pt.c | 10 +++-
gcc/cp/semantics.c | 102 +++++++++++++++++++++++++++++------------
gcc/cp/tree.c | 8 ++++
gcc/cp/typeck.c | 25 ++++++++--
gcc/cp/typeck2.c | 4 ++
gcc/fold-const.c | 3 ++
gcc/objc/objc-act.c | 2 +
gcc/tree.c | 1 +
gcc/tree.h | 8 ++++
31 files changed, 260 insertions(+), 86 deletions(-)
--
1.8.5.3