+2020-01-14 David Malcolm <dmalcolm@redhat.com>
+
+ PR analyzer/58237
+ * engine.cc (leak_stmt_finder::find_stmt): Use get_pure_location
+ when comparing against UNKNOWN_LOCATION.
+ (stmt_requires_new_enode_p): Likewise.
+ (exploded_graph::dump_exploded_nodes): Likewise.
+ * supergraph.cc (supernode::get_start_location): Likewise.
+ (supernode::get_end_location): Likewise.
+
2020-01-14 David Malcolm <dmalcolm@redhat.com>
PR analyzer/58237
const program_point &dst_point = dst_node->get_point ();
const gimple *stmt = dst_point.get_stmt ();
if (stmt)
- if (stmt->location != UNKNOWN_LOCATION)
+ if (get_pure_location (stmt->location) != UNKNOWN_LOCATION)
return stmt;
}
could be consolidated into PREV_STMT, giving us an event with
no location. Ensure that STMT gets its own exploded_node to
avoid this. */
- if (prev_stmt->location == UNKNOWN_LOCATION
- && stmt->location != UNKNOWN_LOCATION)
+ if (get_pure_location (prev_stmt->location) == UNKNOWN_LOCATION
+ && get_pure_location (stmt->location) != UNKNOWN_LOCATION)
return true;
return false;
{
if (const gimple *stmt = enode->get_stmt ())
{
- if (richloc.get_loc () == UNKNOWN_LOCATION)
+ if (get_pure_location (richloc.get_loc ()) == UNKNOWN_LOCATION)
richloc.set_range (0, stmt->location, SHOW_RANGE_WITH_CARET);
else
richloc.add_range (stmt->location,
location_t
supernode::get_start_location () const
{
- if (m_returning_call && m_returning_call->location != UNKNOWN_LOCATION)
+ if (m_returning_call
+ && get_pure_location (m_returning_call->location) != UNKNOWN_LOCATION)
return m_returning_call->location;
int i;
gimple *stmt;
FOR_EACH_VEC_ELT (m_stmts, i, stmt)
- if (stmt->location != UNKNOWN_LOCATION)
+ if (get_pure_location (stmt->location) != UNKNOWN_LOCATION)
return stmt->location;
if (entry_p ())
int i;
gimple *stmt;
FOR_EACH_VEC_ELT_REVERSE (m_stmts, i, stmt)
- if (stmt->location != UNKNOWN_LOCATION)
+ if (get_pure_location (stmt->location) != UNKNOWN_LOCATION)
return stmt->location;
- if (m_returning_call && m_returning_call->location != UNKNOWN_LOCATION)
+ if (m_returning_call
+ && get_pure_location (m_returning_call->location) != UNKNOWN_LOCATION)
return m_returning_call->location;
if (entry_p ())
+2020-01-14 David Malcolm <dmalcolm@redhat.com>
+
+ PR analyzer/58237
+ * gcc.dg/analyzer/file-paths-1.c: New test.
+
2020-01-14 David Malcolm <dmalcolm@redhat.com>
PR analyzer/58237
--- /dev/null
+#include <stdio.h>
+
+/* Verify that we correctly emit CFG events in the face of buffers
+ being clobbered in these leak reports. */
+
+void f1 (const char *str)
+{
+ FILE * fp = fopen(str, "r"); /* { dg-message "opened here" } */
+ char buf[10];
+
+ while (fgets(buf, 10, fp) != NULL) /* { dg-message "following 'false' branch\\.\\.\\." } */
+ {
+ }
+} /* { dg-warning "leak of FILE 'fp'" } */
+/* { dg-message "\\.\\.\\.to here" "" { target *-*-* } .-1 } */
+
+void f2(const char *str, int flag)
+{
+ FILE * fp = fopen(str, "r"); /* { dg-message "opened here" } */
+ char buf[10];
+
+ if (flag) /* { dg-message "when 'flag == 0'" } */
+ fclose(fp);
+} /* { dg-warning "leak of FILE 'fp'" } */
+/* { dg-message "\\.\\.\\.to here" "" { target *-*-* } .-1 } */