]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/util/testsuite_abi.h
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / util / testsuite_abi.h
1 // -*- C++ -*-
2
3 // Copyright (C) 2004-2020 Free Software Foundation, Inc.
4
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 3, or (at
8 // your option) any later version.
9
10 // This library is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14
15 // You should have received a copy of the GNU General Public License
16 // along with this library; see the file COPYING3. If not see
17 // <http://www.gnu.org/licenses/>.
18
19 // Benjamin Kosnik <bkoz@redhat.com>
20
21 #include <string>
22 #include <stdexcept>
23 #include <vector>
24 #include <locale>
25 #if __cplusplus >= 201103L
26 # include <unordered_map>
27 namespace unord = std;
28 #else
29 # include <tr1/unordered_map>
30 namespace unord = std::tr1;
31 #endif
32 #include <cxxabi.h>
33
34 // Encapsulates symbol characteristics.
35 struct symbol
36 {
37 enum category { function, object, tls, uncategorized };
38 enum designation { existing, added, subtracted, undesignated };
39 enum version { none, compatible, incompatible, unversioned };
40 enum compatibility
41 {
42 compat_type = 1,
43 compat_name = 2,
44 compat_size = 4,
45 compat_version = 8
46 };
47
48 category type;
49 std::string name;
50 std::string raw_name; // Name with versioning info still attached.
51 std::string demangled_name;
52 int size;
53 std::string version_name;
54 version version_status;
55 designation status;
56
57 symbol()
58 : type(uncategorized), size(0), version_status(unversioned),
59 status(undesignated) { }
60
61 symbol(const symbol& other)
62 : type(other.type), name(other.name), demangled_name(other.demangled_name),
63 size(other.size), version_name(other.version_name),
64 version_status(other.version_status), status(other.status) { }
65
66 void
67 print() const;
68
69 void
70 init(std::string& data);
71 };
72
73 // Map type between symbol names and full symbol info.
74 typedef unord::unordered_map<std::string, symbol> symbols;
75
76
77 // Check.
78 bool
79 check_version(symbol& test, bool added = false);
80
81 bool
82 check_compatible(symbol& lhs, symbol& rhs, bool verbose = false);
83
84
85 // Examine.
86 bool
87 has_symbol(const std::string& mangled, const symbols& list) throw();
88
89 const symbol&
90 get_symbol(const std::string& mangled, const symbols& list);
91
92 extern "C" void
93 examine_symbol(const char* name, const char* file);
94
95 extern "C" int
96 compare_symbols(const char* baseline_file, const char* test_file, bool verb);
97
98
99 // Util.
100 symbols
101 create_symbols(const char* file);
102
103 std::string
104 demangle(const std::string& mangled);