From 79071dbd6b3645c5d6202be8c2e0f7ab0962b74e Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Sun, 31 May 2020 10:23:22 -0400 Subject: [PATCH 194/315] FIXME: WIP on selftest::test_get_representative_path_var --- gcc/analyzer/region-model2.cc | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/gcc/analyzer/region-model2.cc b/gcc/analyzer/region-model2.cc index 204d5a03302..e963bbe40be 100644 --- a/gcc/analyzer/region-model2.cc +++ b/gcc/analyzer/region-model2.cc @@ -8822,31 +8822,32 @@ test_get_representative_path_var () get_identifier ("n"), integer_type_node); - region_model2 model; + region_model2_manager mgr; + test_region_model2_context ctxt; + region_model2 model (&mgr); /* Push 5 stack frames for "factorial", each with a param */ - auto_vec parm_regs; - auto_vec parm_svals; + auto_vec parm_regs; + auto_vec parm_svals; for (int depth = 0; depth < 5; depth++) { - const region2 *frame_reg - = model.push_frame (DECL_STRUCT_FUNCTION (fndecl), NULL, NULL); - const region2 *reg_n = model.get_lvalue (path_var (n, depth), NULL); - parm_regs.safe_push (rid_n); + const region2 *frame_n_reg + = model.push_frame (DECL_STRUCT_FUNCTION (fndecl), NULL, &ctxt); + const region2 *parm_n_reg = model.get_lvalue (path_var (n, depth), &ctxt); + parm_regs.safe_push (parm_n_reg); - ASSERT_EQ (model.get_region2 (rid_n)->get_parent (), frame_reg); - - const svalue2 *sval_n - = model.set_to_new_unknown_value (rid_n, integer_type_node, NULL); - parm_svals.safe_push (sid_n); + ASSERT_EQ (parm_n_reg->get_parent_region (), frame_n_reg); + const svalue2 *sval_n = mgr.get_or_create_initial_value (parm_n_reg); + parm_svals.safe_push (sval_n); } /* Verify that we can recognize that the region2s are the parms, at every depth. */ for (int depth = 0; depth < 5; depth++) { - ASSERT_EQ (model.get_representative_path_var (parm_regs[depth]), - path_var (n, depth)); + path_var pv (NULL, 0); + ASSERT_TRUE (parm_regs[depth]->get_representative_path_var (&pv)); + ASSERT_EQ (pv, path_var (n, depth + 1)); /* ...and that we can lookup lvalues for locals for all frames, not just the top. */ ASSERT_EQ (model.get_lvalue (path_var (n, depth), NULL), @@ -8855,10 +8856,9 @@ test_get_representative_path_var () auto_vec pvs; model.get_path_vars_for_svalue2 (parm_svals[depth], &pvs); ASSERT_EQ (pvs.length (), 1); - ASSERT_EQ (pvs[0], path_var (n, depth)); + ASSERT_EQ (pvs[0], path_var (n, depth + 1)); } } -#endif /* Verify that "empty" region_model2 instances are equal to each other. */ @@ -9800,9 +9800,7 @@ analyzer_region_model2_cc_tests () test_compound_assignment (); #endif test_stack_frames (); -#if 0 test_get_representative_path_var (); -#endif test_model_equality_1 (); test_model_equality_2 (); test_model_equality_3 (); -- 2.26.2