+2020-01-27 David Malcolm <dmalcolm@redhat.com>
+
+ * call-string.cc (call_string::cmp_1): Delete, moving body to...
+ (call_string::cmp): ...here.
+ * call-string.h (call_string::cmp_1): Delete decl.
+ * engine.cc (worklist::key_t::cmp_1): Delete, moving body to...
+ (worklist::key_t::cmp): ...here. Implement hash comparisons
+ via comparison rather than subtraction to avoid overflow issues.
+ * exploded-graph.h (worklist::key_t::cmp_1): Delete decl.
+ * region-model.cc (tree_cmp): Eliminate buggy checking for
+ symmetry.
+
2020-01-27 David Malcolm <dmalcolm@redhat.com>
* analyzer.cc (is_named_call_p): Check that fndecl is "extern"
}
/* Comparator for call strings.
+ This implements a version of lexicographical order.
Return negative if A is before B.
Return positive if B is after A.
Return 0 if they are equal. */
int
call_string::cmp (const call_string &a,
const call_string &b)
-{
- int result = cmp_1 (a, b);
-
- /* Check that the ordering is symmetric */
-#if CHECKING_P
- int reversed = cmp_1 (b, a);
- gcc_assert (reversed == -result);
-#endif
-
- /* We should only have 0 for equal pairs. */
- gcc_assert (result != 0
- || a == b);
-
- return result;
-}
-
-/* Implementation of call_string::cmp.
- This implements a version of lexicographical order. */
-
-int
-call_string::cmp_1 (const call_string &a,
- const call_string &b)
{
unsigned len_a = a.length ();
unsigned len_b = b.length ();
void validate () const;
private:
- static int cmp_1 (const call_string &a,
- const call_string &b);
-
auto_vec<const return_superedge *> m_return_edges;
};
Return 0 if they are equal. */
int
-worklist::key_t::cmp_1 (const worklist::key_t &ka, const worklist::key_t &kb)
+worklist::key_t::cmp (const worklist::key_t &ka, const worklist::key_t &kb)
{
const program_point &point_a = ka.m_enode->get_point ();
const program_point &point_b = kb.m_enode->get_point ();
sm_state_map *smap_a = state_a.m_checker_states[sm_idx];
sm_state_map *smap_b = state_b.m_checker_states[sm_idx];
- int sm_cmp = smap_a->hash () - smap_b->hash ();
- if (sm_cmp)
- return sm_cmp;
+ hashval_t hash_a = smap_a->hash ();
+ hashval_t hash_b = smap_b->hash ();
+ if (hash_a < hash_b)
+ return -1;
+ else if (hash_a > hash_b)
+ return 1;
}
/* Otherwise, we have two enodes at the same program point but with
return ka.m_enode->m_index - kb.m_enode->m_index;
}
-/* Comparator for implementing worklist::key_t comparison operators.
- Return negative if KA is before KB
- Return positive if KA is after KB
- Return 0 if they are equal. */
-
-int
-worklist::key_t::cmp (const worklist::key_t &ka, const worklist::key_t &kb)
-{
- int result = cmp_1 (ka, kb);
-
- /* Check that the ordering is symmetric */
-#if CHECKING_P
- int reversed = cmp_1 (kb, ka);
- gcc_assert (reversed == -result);
-#endif
-
- /* We should only have 0 for equal (point, state) pairs. */
- gcc_assert (result != 0
- || (*ka.m_enode->get_ps_key ()
- == *kb.m_enode->get_ps_key ()));
-
- return result;
-}
-
/* exploded_graph's ctor. */
exploded_graph::exploded_graph (const supergraph &sg, logger *logger,
}
private:
- static int cmp_1 (const key_t &ka, const key_t &kb);
static int cmp (const key_t &ka, const key_t &kb);
int get_scc_id (const exploded_node *enode) const
const_tree t1 = *(const_tree const *)p1;
const_tree t2 = *(const_tree const *)p2;
- int result = tree_cmp (t1, t2);
-
- /* Check that the ordering is symmetric */
-#if CHECKING_P
- int reversed = tree_cmp (t2, t1);
- gcc_assert (reversed == -result);
-#endif
-
- /* We should only have 0 for equal pairs. */
-#if 0
- gcc_assert (result != 0
- || t1 == t2);
-#endif
-
- return result;
+ return tree_cmp (t1, t2);
}
/* Attempt to merge MAP_REGION_A and MAP_REGION_B into MERGED_MAP_REGION,