public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/c++-contracts] c++: use DECL_ABSTRACT_ORIGIN on contract fns
@ 2021-07-06 20:44 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2021-07-06 20:44 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:9160ebeefbdaf0447d2b06af7038bf490e110d49

commit 9160ebeefbdaf0447d2b06af7038bf490e110d49
Author: Jason Merrill <jason@redhat.com>
Date:   Sat Jul 3 05:45:02 2021 -0400

    c++: use DECL_ABSTRACT_ORIGIN on contract fns
    
    DECL_ABSTRACT_ORIGIN represents the relationship between the condition
    functions and the function they are split from, so we can drop one of the
    hash tables.
    
    gcc/cp/ChangeLog:
    
            * cp-tree.h (DECL_ORIGINAL_FN): Use DECL_ABSTRACT_ORIGIN.
            * contracts.cc (get_contracts_original_fn): Remove.
            (set_contracts_original_fn): Remove.
            (build_contract_condition_function): Set DECL_ABSTRACT_ORIGIN.
            * module.cc (trees_in::fn_parms_init): Don't
            set_contracts_original_fn.

Diff:
---
 gcc/cp/cp-tree.h    |  3 +--
 gcc/cp/contracts.cc | 32 +-------------------------------
 gcc/cp/module.cc    |  4 ----
 3 files changed, 2 insertions(+), 37 deletions(-)

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 801595762c4..836bcf7baf2 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3733,7 +3733,7 @@ find_contract (tree attrs)
 /* For a FUNCTION_DECL of a pre/post function, this points back to the
    original guarded function.  */
 #define DECL_ORIGINAL_FN(NODE) \
-  (get_contracts_original_fn (NODE))
+  (DECL_ABSTRACT_ORIGIN (NODE))
 
 /* True iff the FUNCTION_DECL is the pre function for a guarded function.  */
 #define DECL_IS_PRE_FN_P(NODE) \
@@ -7581,7 +7581,6 @@ extern bool contract_any_deferred_p		(tree);
 extern bool all_attributes_are_contracts_p	(tree);
 extern void build_contract_function_decls	(tree);
 extern void set_contract_functions		(tree, tree, tree);
-extern void set_contracts_original_fn		(tree, tree);
 extern tree start_postcondition_statement	();
 extern void finish_postcondition_statement	(tree);
 extern tree build_contract_check		(tree);
diff --git a/gcc/cp/contracts.cc b/gcc/cp/contracts.cc
index 05462328e69..73e6378bf22 100644
--- a/gcc/cp/contracts.cc
+++ b/gcc/cp/contracts.cc
@@ -1276,7 +1276,6 @@ match_deferred_contracts (tree decl)
    of the guarded function.  */
 static GTY(()) hash_map<tree, tree> *decl_pre_fn;
 static GTY(()) hash_map<tree, tree> *decl_post_fn;
-static GTY(()) hash_map<tree, tree> *decl_original_fn;
 
 /* Returns the precondition funtion for D, or null if not set.  */
 
@@ -1332,35 +1331,6 @@ set_contract_functions (tree d, tree pre, tree post)
     set_postcondition_function (d, post);
 }
 
-/* Returns the original guarded function of a precondition or postcondition
-   function D, or null if it does not exist.  */
-
-tree
-get_contracts_original_fn (tree d)
-{
-  hash_map_maybe_create<hm_ggc> (decl_original_fn);
-  tree *result = decl_original_fn->get (d);
-  return result ? *result : NULL_TREE;
-}
-
-
-/* Set the original fn for a contract function D.  */
-
-void
-set_contracts_original_fn (tree d, tree orig)
-{
-  gcc_assert (orig);
-  hash_map_maybe_create<hm_ggc> (decl_original_fn);
-
-  /* FIXME: Why are we resetting the contract function? This is called
-     from finish_function, but seems to just re-assert that the original
-     function is the same.  */
-  if (tree p = get_contracts_original_fn (d))
-    gcc_assert (p == orig);
-
-  decl_original_fn->put (d, orig);
-}
-
 /* Return a copy of the FUNCTION_DECL IDECL with its own unshared
    PARM_DECL and DECL_ATTRIBUTEs.  */
 
@@ -1457,7 +1427,7 @@ build_contract_condition_function (tree fndecl, bool pre)
 
   DECL_NAME (fn) = copy_node (DECL_NAME (fn));
   DECL_INITIAL (fn) = error_mark_node;
-  set_contracts_original_fn (fn, fndecl);
+  DECL_ABSTRACT_ORIGIN (fn) = fndecl;
 
   IDENTIFIER_VIRTUAL_P (DECL_NAME (fn)) = false;
   DECL_VIRTUAL_P (fn) = false;
diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc
index 245ad6ad898..c96c80f7e13 100644
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -10023,10 +10023,6 @@ trees_in::fn_parms_init (tree fn)
   tree pre_fn = tree_node ();
   tree post_fn = tree_node ();
   set_contract_functions (fn, pre_fn, post_fn);
-  if (pre_fn)
-    set_contracts_original_fn (pre_fn, fn);
-  if (post_fn)
-    set_contracts_original_fn (post_fn, fn);
 
   return base_tag;
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-06 20:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-06 20:44 [gcc/devel/c++-contracts] c++: use DECL_ABSTRACT_ORIGIN on contract fns Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).