Branch data Line data Source code
1 : : /* Concrete subclass of logical_locations::manager for use in selftests.
2 : : Copyright (C) 2024-2025 Free Software Foundation, Inc.
3 : : Contributed by David Malcolm <dmalcolm@redhat.com>.
4 : :
5 : : This file is part of GCC.
6 : :
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.
11 : :
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.
16 : :
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/>. */
20 : :
21 : : #ifndef GCC_DIAGNOSTICS_SELFTEST_LOGICAL_LOCATIONS_H
22 : : #define GCC_DIAGNOSTICS_SELFTEST_LOGICAL_LOCATIONS_H
23 : :
24 : : #include "diagnostics/logical-locations.h"
25 : :
26 : : /* The selftest code should entirely disappear in a production
27 : : configuration, hence we guard all of it with #if CHECKING_P. */
28 : :
29 : : #if CHECKING_P
30 : :
31 : : namespace diagnostics {
32 : : namespace logical_locations {
33 : : namespace selftest {
34 : :
35 : : /* Concrete subclass of logical_locations::manager for use in selftests. */
36 : :
37 : : class test_manager : public manager
38 : : {
39 : : public:
40 : : ~test_manager ();
41 : :
42 : : void dump (FILE *out, int indent) const final override;
43 : :
44 : : const char *get_short_name (key) const final override;
45 : : const char *get_name_with_scope (key) const final override;
46 : : const char *get_internal_name (key) const final override;
47 : : kind get_kind (key) const final override;
48 : : label_text get_name_for_path_output (key) const final override;
49 : 0 : key get_parent (key) const final override
50 : : {
51 : 0 : return key ();
52 : : }
53 : :
54 : : key
55 : : logical_location_from_funcname (const char *funcname);
56 : :
57 : : private:
58 : : struct item
59 : : {
60 : 48 : item (kind kind_,
61 : : const char *name)
62 : 48 : : m_kind (kind_),
63 : 48 : m_name (name)
64 : : {
65 : : }
66 : :
67 : : kind m_kind;
68 : : const char *m_name;
69 : : };
70 : :
71 : : const item *
72 : : item_from_funcname (const char *funcname);
73 : :
74 : : static const item *item_from_key (key k)
75 : : {
76 : 0 : return k.cast_to<const item *> ();
77 : : }
78 : :
79 : : hash_map<nofree_string_hash, item *> m_name_to_item_map;
80 : : };
81 : :
82 : : } // namespace diagnostics::logical_locations::selftest
83 : : } // namespace diagnostics::logical_locations::
84 : : } // namespace diagnostics
85 : :
86 : : #endif /* #if CHECKING_P */
87 : :
88 : : #endif /* GCC_DIAGNOSTICS_SELFTEST_LOGICAL_LOCATIONS_H. */
|