analyzer: use DECL_DEBUG_EXPR on SSA names for artificial vars
gcc/analyzer/ChangeLog: * analyzer.cc (fixup_tree_for_diagnostic_1): Use DECL_DEBUG_EXPR if it's available. * engine.cc (readability): Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
This commit is contained in:
parent
a9241df96e
commit
e9711fe482
2 changed files with 23 additions and 5 deletions
|
@ -165,8 +165,13 @@ fixup_tree_for_diagnostic_1 (tree expr, hash_set<tree> *visited)
|
|||
&& TREE_CODE (expr) == SSA_NAME
|
||||
&& (SSA_NAME_VAR (expr) == NULL_TREE
|
||||
|| DECL_ARTIFICIAL (SSA_NAME_VAR (expr))))
|
||||
if (tree expr2 = maybe_reconstruct_from_def_stmt (expr, visited))
|
||||
return expr2;
|
||||
{
|
||||
if (tree var = SSA_NAME_VAR (expr))
|
||||
if (VAR_P (var) && DECL_HAS_DEBUG_EXPR_P (var))
|
||||
return DECL_DEBUG_EXPR (var);
|
||||
if (tree expr2 = maybe_reconstruct_from_def_stmt (expr, visited))
|
||||
return expr2;
|
||||
}
|
||||
return expr;
|
||||
}
|
||||
|
||||
|
|
|
@ -527,9 +527,22 @@ readability (const_tree expr)
|
|||
case SSA_NAME:
|
||||
{
|
||||
if (tree var = SSA_NAME_VAR (expr))
|
||||
/* Slightly favor the underlying var over the SSA name to
|
||||
avoid having them compare equal. */
|
||||
return readability (var) - 1;
|
||||
{
|
||||
if (DECL_ARTIFICIAL (var))
|
||||
{
|
||||
/* If we have an SSA name for an artificial var,
|
||||
only use it if it has a debug expr associated with
|
||||
it that fixup_tree_for_diagnostic can use. */
|
||||
if (VAR_P (var) && DECL_HAS_DEBUG_EXPR_P (var))
|
||||
return readability (DECL_DEBUG_EXPR (var)) - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Slightly favor the underlying var over the SSA name to
|
||||
avoid having them compare equal. */
|
||||
return readability (var) - 1;
|
||||
}
|
||||
}
|
||||
/* Avoid printing '<unknown>' for SSA names for temporaries. */
|
||||
return -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue