2005-01-05 Benjamin Kosnik <bkoz@redhat.com>
[official-gcc.git] / libstdc++-v3 / testsuite / testsuite_abi.h
blob2078eb76fa37fb8741f7e871b1d63e5144a0886d
1 // -*- C++ -*-
3 // Copyright (C) 2004, 2005 Free Software Foundation, Inc.
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 2, or (at
8 // your option) any later version.
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.
15 // You should have received a copy of the GNU General Public License
16 // along with this library; see the file COPYING. If not, write to
17 // the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
18 // MA 02111-1307, USA.
20 // As a special exception, you may use this file as part of a free
21 // software library without restriction. Specifically, if other files
22 // instantiate templates or use macros or inline functions from this
23 // file, or you compile this file and link it with other files to
24 // produce an executable, this file does not by itself cause the
25 // resulting executable to be covered by the GNU General Public
26 // License. This exception does not however invalidate any other
27 // reasons why the executable file might be covered by the GNU General
28 // Public License.
30 // Benjamin Kosnik <bkoz@redhat.com>
32 #include <string>
33 #include <stdexcept>
34 #include <deque>
35 #include <ext/hash_map>
36 #include <cxxabi.h>
38 // Encapsulates symbol characteristics.
39 struct symbol
41 enum category { none, function, object, error };
42 enum designation { unknown, added, subtracted, compatible, incompatible };
43 enum compatibility
45 compat_type = 1,
46 compat_name = 2,
47 compat_size = 4,
48 compat_version = 8
51 category type;
52 std::string name;
53 std::string demangled_name;
54 int size;
55 std::string version_name;
56 designation status;
58 symbol() : type(none), size(0), status(unknown) { }
60 symbol(const symbol& other)
61 : type(other.type), name(other.name), demangled_name(other.demangled_name),
62 size(other.size), version_name(other.version_name),
63 status(other.status) { }
65 void
66 print() const;
68 void
69 init(std::string& data);
72 typedef __gnu_cxx::hash_map<std::string, symbol> symbol_objects;
74 typedef std::deque<std::string> symbol_names;
76 typedef std::pair<symbol_names, symbol_objects> symbols;
79 // Check.
80 bool
81 check_version(const symbol& test, bool added = false);
83 bool
84 check_compatible(const symbol& lhs, const symbol& rhs, bool verbose = false);
87 // Examine.
88 bool
89 has_symbol(const std::string& mangled, const symbols& list) throw();
91 symbol&
92 get_symbol(const std::string& mangled, const symbols& list);
94 extern "C" void
95 examine_symbol(const char* name, const char* file);
97 extern "C" void
98 compare_symbols(const char* baseline_file, const char* test_file, bool verb);
101 // Util.
102 symbols
103 create_symbols(const char* file);
105 const char*
106 demangle(const std::string& mangled);
109 // Specialization.
110 namespace __gnu_cxx
112 using namespace std;
114 template<>
115 struct hash<string>
117 size_t operator()(const string& s) const
119 const collate<char>& c = use_facet<collate<char> >(locale::classic());
120 return c.hash(s.c_str(), s.c_str() + s.size());