diff options
Diffstat (limited to 'gcc/tree-logical-location.h')
-rw-r--r-- | gcc/tree-logical-location.h | 62 |
1 files changed, 21 insertions, 41 deletions
diff --git a/gcc/tree-logical-location.h b/gcc/tree-logical-location.h index 1e15bee..0d57888 100644 --- a/gcc/tree-logical-location.h +++ b/gcc/tree-logical-location.h @@ -1,4 +1,4 @@ -/* Subclasses of logical_location with knowledge of "tree". +/* Subclass of logical_location_manager with knowledge of "tree". Copyright (C) 2022-2025 Free Software Foundation, Inc. Contributed by David Malcolm <dmalcolm@redhat.com>. @@ -23,48 +23,28 @@ along with GCC; see the file COPYING3. If not see #include "logical-location.h" -/* Abstract subclass of logical_location, with knowledge of "tree", but - for no specific tree. */ - -class compiler_logical_location : public logical_location -{ - protected: - static const char *get_short_name_for_tree (tree); - static const char *get_name_with_scope_for_tree (tree); - static const char *get_internal_name_for_tree (tree); - static enum logical_location_kind get_kind_for_tree (tree); - static label_text get_name_for_tree_for_path_output (tree); -}; - -/* Concrete subclass of logical_location, with reference to a specific - tree. */ - -class tree_logical_location : public compiler_logical_location -{ -public: - tree_logical_location (tree decl) : m_decl (decl) {} - - const char *get_short_name () const final override; - const char *get_name_with_scope () const final override; - const char *get_internal_name () const final override; - enum logical_location_kind get_kind () const final override; - label_text get_name_for_path_output () const final override; - -private: - tree m_decl; -}; - -/* Concrete subclass of logical_location, with reference to - current_function_decl. */ - -class current_fndecl_logical_location : public compiler_logical_location +/* A subclass of logical_location_manager in which the keys are + "tree". + Note that there is no integration with the garbage collector, + and so logical_location instances can only be short-lived. */ +class tree_logical_location_manager : public logical_location_manager { public: - const char *get_short_name () const final override; - const char *get_name_with_scope () const final override; - const char *get_internal_name () const final override; - enum logical_location_kind get_kind () const final override; - label_text get_name_for_path_output () const final override; + const char *get_short_name (key) const final override; + const char *get_name_with_scope (key) const final override; + const char *get_internal_name (key) const final override; + enum logical_location_kind get_kind (key) const final override; + label_text get_name_for_path_output (key) const final override; + key get_parent (key) const final override; + + static tree tree_from_key (logical_location k) + { + return const_cast<tree> (k.cast_to<const_tree> ()); + } + static logical_location key_from_tree (tree node) + { + return logical_location::from_ptr (node); + } }; #endif /* GCC_TREE_LOGICAL_LOCATION_H. */ |