Update baseline symbols for hppa-linux.
[official-gcc.git] / gcc / tree-logical-location.cc
blob79d8add7d837e83f773ea7155286d5016f8b8de2
1 /* Subclasses of logical_location with knowledge of "tree".
2 Copyright (C) 2022 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tree.h"
25 #include "pretty-print.h"
26 #include "tree-logical-location.h"
27 #include "langhooks.h"
29 /* class compiler_logical_location : public logical_location. */
31 /* Get a string for DECL suitable for use by the SARIF logicalLocation
32 "name" property (SARIF v2.1.0 section 3.33.4). */
34 const char *
35 compiler_logical_location::get_short_name_for_tree (tree decl)
37 gcc_assert (decl);
38 return identifier_to_locale (lang_hooks.decl_printable_name (decl, 0));
41 /* Get a string for DECL suitable for use by the SARIF logicalLocation
42 "fullyQualifiedName" property (SARIF v2.1.0 section 3.33.5). */
44 const char *
45 compiler_logical_location::get_name_with_scope_for_tree (tree decl)
47 gcc_assert (decl);
48 return identifier_to_locale (lang_hooks.decl_printable_name (decl, 1));
51 /* Get a string for DECL suitable for use by the SARIF logicalLocation
52 "decoratedName" property (SARIF v2.1.0 section 3.33.6). */
54 const char *
55 compiler_logical_location::get_internal_name_for_tree (tree decl)
57 gcc_assert (decl);
58 if (HAS_DECL_ASSEMBLER_NAME_P (decl))
59 if (tree id = DECL_ASSEMBLER_NAME (decl))
60 return IDENTIFIER_POINTER (id);
61 return NULL;
64 /* Get what kind of SARIF logicalLocation DECL is (if any). */
66 enum logical_location_kind
67 compiler_logical_location::get_kind_for_tree (tree decl)
69 if (!decl)
70 return LOGICAL_LOCATION_KIND_UNKNOWN;
72 switch (TREE_CODE (decl))
74 default:
75 return LOGICAL_LOCATION_KIND_UNKNOWN;
76 case FUNCTION_DECL:
77 return LOGICAL_LOCATION_KIND_FUNCTION;
78 case PARM_DECL:
79 return LOGICAL_LOCATION_KIND_PARAMETER;
80 case VAR_DECL:
81 return LOGICAL_LOCATION_KIND_VARIABLE;
85 /* class tree_logical_location : public compiler_logical_location. */
87 /* Implementation of the logical_location vfuncs, using m_decl. */
89 const char *
90 tree_logical_location::get_short_name () const
92 gcc_assert (m_decl);
93 return get_short_name_for_tree (m_decl);
96 const char *
97 tree_logical_location::get_name_with_scope () const
99 gcc_assert (m_decl);
100 return get_name_with_scope_for_tree (m_decl);
103 const char *
104 tree_logical_location::get_internal_name () const
106 gcc_assert (m_decl);
107 return get_internal_name_for_tree (m_decl);
110 enum logical_location_kind
111 tree_logical_location::get_kind () const
113 gcc_assert (m_decl);
114 return get_kind_for_tree (m_decl);
117 /* class current_fndecl_logical_location : public compiler_logical_location. */
119 /* Implementation of the logical_location vfuncs, using
120 current_function_decl. */
122 const char *
123 current_fndecl_logical_location::get_short_name () const
125 gcc_assert (current_function_decl);
126 return get_short_name_for_tree (current_function_decl);
129 const char *
130 current_fndecl_logical_location::get_name_with_scope () const
132 gcc_assert (current_function_decl);
133 return get_name_with_scope_for_tree (current_function_decl);
136 const char *
137 current_fndecl_logical_location::get_internal_name () const
139 gcc_assert (current_function_decl);
140 return get_internal_name_for_tree (current_function_decl);
143 enum logical_location_kind
144 current_fndecl_logical_location::get_kind () const
146 gcc_assert (current_function_decl);
147 return get_kind_for_tree (current_function_decl);