libabigail/include/abg-ir.h

2529 lines
58 KiB
C
Raw Normal View History

// -*- Mode: C++ -*-
//
// Copyright (C) 2013 Red Hat, Inc.
//
// This file is part of the GNU Application Binary Interface Generic
// Analysis and Instrumentation Library (libabigail). This library is
// free software; you can redistribute it and/or modify it under the
// terms of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 3, or (at your option) any
// later version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details.
// You should have received a copy of the GNU Lesser General Public
// License along with this program; see the file COPYING-LGPLV3. If
// not, see <http://www.gnu.org/licenses/>.
//
// Author: Dodji Seketeli
/// @file
#ifndef __ABG_IR_H__
#define __ABG_IR_H__
#include <assert.h>
#include "abg-fwd.h"
#include "abg-hash.h"
#include "abg-traverse.h"
namespace abigail
{
/// @brief The source location of a token.
///
/// This represents the location of a token coming from a given
/// translation unit. This location is actually an abstraction of
/// cursor in the table of all the locations of all the tokens of the
/// translation unit. That table is managed by the location_manager
/// type.
class location
{
unsigned value_;
location(unsigned v) : value_(v) { }
public:
location() : value_(0) { }
unsigned
get_value() const
{return value_;}
operator bool() const
{ return !!value_; }
bool
operator==(const location other) const
{return value_ == other.value_;}
bool
operator<(const location other) const
{ return value_ < other.value_; }
friend class location_manager;
};
/// @brief The entry point to manage locations.
///
/// This type keeps a table of all the locations for tokens of a
/// given translation unit.
class location_manager
{
struct priv;
/// Pimpl.
shared_ptr<priv> priv_;
public:
location_manager();
location
create_new_location(const std::string& fle, size_t lne, size_t col);
void
expand_location(const location location, std::string& path,
unsigned& line, unsigned& column) const;
};
struct ir_node_visitor;
/// Convenience typedef for a shared pointer on a @ref
/// translation_unit type.
typedef shared_ptr<translation_unit> translation_unit_sptr;
/// Convenience typedef for a vector of @ref translation_unit_sptr.
typedef std::vector<translation_unit_sptr> translation_units;
Prune types that are not ref'ed by public decls * include/abg-fwd.h (remove_decl_from_scope): Declare new function. * include/abg-ir.h (type_base_sptr, decl_base_sptr): Move these convenience typedef before the translation_unit declaration. (translation_unit::{mark_type_as_used, prune_unused_types}): Declare new methods. (decl_base::remove_member_decl): Likewise. (class_decl::{remove_member_decl, remove_member_type): Likewise. * src/abg-dwarf-reader.cc (die_decl_map_type): Change this map type so that the value is now a DIE offset, rather than a DIE. This is because many times the lifetime of DIEs is shorter than the one of the reader_context. Also, the die offset uniquely designates a physical DIE even if several different instances of logical DIE might point to it. (struct die_hash): Remove this as it's useless now that we store DIE offsets in the map. (build_translation_unit): Call build_ir_node_from_die w/o setting the called_from_public_decl flag. Prune the types that are not used by any public decls. (build_namespace_decl_and_add_to_ir): all build_ir_node_from_die w/o setting the called_from_public_decl flag. (build_ir_node_from_die): Change the only_public_decl flag into a called_from_public_decl flag. Mark types used by public decls as such. Adjust for the parm changes of build_qualified_type build_pointer_type_def, build_reference_type, and build_typedef_type. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type): Take a new called_from_public_decl. Pass it to build_ir_node_from_die. (build_var_decl): Call build_ir_node_from_die with the called_from_public_decl flag set to true to flag the types referenced by this variable as being used. (build_function_decl): Take a called_from_public_decl flag as well, as this function can now call build_function_decl itself to build a function decl out of the value of the DW_AT_specification attribute, for DIEs representing function definitions. Also, flag the types referenced by public functions are being used. * src/abg-ir.cc (translation_unit::priv::used_types_): New map for the used types. (translation_unit::{mark_type_as_used, prune_unused_types}): Define new methods. (scope_decl::remove_member_decl): Likewise. (remove_decl_from_scope): Define new function. (class_decl::{remove_member_decl, remove_member_type}): Define new methods. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-13 16:30:41 +00:00
/// Convenience typedef for a shared pointer on a @ref type_base
typedef shared_ptr<type_base> type_base_sptr;
/// Convenience typedef for a smart pointer on @ref decl_base.
typedef shared_ptr<decl_base> decl_base_sptr;
struct ir_traversable_base;
/// Convenience typedef for a shared pointer to @ref
/// ir_traversable_base.
typedef shared_ptr<ir_traversable_base> ir_traversable_base_sptr;
/// The base of an entity of the intermediate representation that is
/// to be traversed.
struct ir_traversable_base : public traversable_base
{
virtual void
traverse(ir_node_visitor&);
}; // end class ir_traversable_base
/// This is the abstraction of the set of relevant artefacts (types,
/// variable declarations, functions, templates, etc) bundled together
/// into a translation unit.
class translation_unit : public traversable_base
{
struct priv;
typedef shared_ptr<priv> priv_sptr;
priv_sptr priv_;
// Forbidden
translation_unit();
public:
/// Convenience typedef for a shared pointer on a @ref global_scope.
typedef shared_ptr<global_scope> global_scope_sptr;
public:
translation_unit(const std::string& path,
char address_size = 0);
virtual ~translation_unit();
const std::string&
get_path() const;
void
set_path(const string&);
const global_scope_sptr
get_global_scope() const;
location_manager&
get_loc_mgr();
const location_manager&
get_loc_mgr() const;
bool
is_empty() const;
char
get_address_size() const;
void
set_address_size(char);
Initial support for diffing ABI corpus files * include/abg-comparison.h (string_function_ptr_map) (changed_function_ptr, string_changed_function_ptr_map) (corpus_diff_sptr): New convenience typedefs. (translation_unit_diff): Add comments. (class corpus_diff): New type. (compute_diff): New overload for corpus_diff. * include/abg-corpus.h (corpus::{functions, variables}): New typedefs. (corpus::{operator==, get_functions, get_variables}): New members. * include/abg-diff-utils.h (struct deep_ptr_eq_functor): New functor. * include/abg-ir.h (translation_unit::operator==): New member equality operator. * src/abg-comparison.cc (struct corpus_diff::priv): New private struct holding the private members of corpus_diff. (corpus_diff::priv::{lookup_tables_empty, clear_lookup_tables, ensure_lookup_tables_populated}): Define new private member functions. (corpus_diff::{corpus_diff, first_corpus, second_corpus, function_changes, variable_changes, length, report}): New public members. (struct noop_deleter): New struct. (compute_diff): New implementation for corpus_diff. * src/abg-corpus.cc (struct corpus::priv): Renamed corpus::impl into this. Add new fns, vars and is_symbol_table_built data members. (corpus::priv::build_symbol_table): New member function. (class symtab_build_visitor_type): New visitor type to build the symbol table. (struct func_comp, struct var_comp): New comparison functors. (corpus::priv::build_symbol_table): Define new member function. (corpus::{corpus, add, get_translation_units, operator==, get_functions, get_variables}): Define new members. * src/abg-ir.cc (translation_unit::operator==): Define new member equality operator. (operator==(translation_unit_sptr l, translation_unit_sptr r)): Define new equality operator. * tools/abg-tools-utils.h (enum file_type): New enum. (guess_file_type): Declare new function. * tools/abg-tools-utils.cc (guess_file_type): define new function. * tools/bidiff.cc (main): Guess the type of the files given in input and support elf files reading and diffing. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-23 13:05:19 +00:00
bool
operator==(const translation_unit&) const;
virtual void
traverse(ir_node_visitor& v);
};//end class translation_unit
Initial support for diffing ABI corpus files * include/abg-comparison.h (string_function_ptr_map) (changed_function_ptr, string_changed_function_ptr_map) (corpus_diff_sptr): New convenience typedefs. (translation_unit_diff): Add comments. (class corpus_diff): New type. (compute_diff): New overload for corpus_diff. * include/abg-corpus.h (corpus::{functions, variables}): New typedefs. (corpus::{operator==, get_functions, get_variables}): New members. * include/abg-diff-utils.h (struct deep_ptr_eq_functor): New functor. * include/abg-ir.h (translation_unit::operator==): New member equality operator. * src/abg-comparison.cc (struct corpus_diff::priv): New private struct holding the private members of corpus_diff. (corpus_diff::priv::{lookup_tables_empty, clear_lookup_tables, ensure_lookup_tables_populated}): Define new private member functions. (corpus_diff::{corpus_diff, first_corpus, second_corpus, function_changes, variable_changes, length, report}): New public members. (struct noop_deleter): New struct. (compute_diff): New implementation for corpus_diff. * src/abg-corpus.cc (struct corpus::priv): Renamed corpus::impl into this. Add new fns, vars and is_symbol_table_built data members. (corpus::priv::build_symbol_table): New member function. (class symtab_build_visitor_type): New visitor type to build the symbol table. (struct func_comp, struct var_comp): New comparison functors. (corpus::priv::build_symbol_table): Define new member function. (corpus::{corpus, add, get_translation_units, operator==, get_functions, get_variables}): Define new members. * src/abg-ir.cc (translation_unit::operator==): Define new member equality operator. (operator==(translation_unit_sptr l, translation_unit_sptr r)): Define new equality operator. * tools/abg-tools-utils.h (enum file_type): New enum. (guess_file_type): Declare new function. * tools/abg-tools-utils.cc (guess_file_type): define new function. * tools/bidiff.cc (main): Guess the type of the files given in input and support elf files reading and diffing. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-23 13:05:19 +00:00
bool
operator==(translation_unit_sptr, translation_unit_sptr);
/// The base type of all declarations.
class decl_base : public ir_traversable_base
{
public:
/// Facility to hash instances of decl_base.
struct hash;
/// ELF visibility
enum visibility
{
VISIBILITY_NONE,
VISIBILITY_DEFAULT,
VISIBILITY_PROTECTED,
VISIBILITY_HIDDEN,
VISIBILITY_INTERNAL
};
Support var decl & mangled_name attributes * src/abg-ir.h (decl_base::binding, decl_base::get_mangled_name) (decl_base::set_mangled_name, decl_base::m_mangled_name): New declarations. (scope_decl::scope_decl: type_decl::type_decl) (scope_type_decl::scope_type_decl, typedef_decl::typedef_decl): Initialize mangled_name. (namespace_decl::namespace_decl): Initialize visibility. (class var_decl): New declaration. * src/abg-ir.cc (decl_base::decl_base, scope_decl::scope_decl) (type_decl::type_decl, scope_type_decl::scope_type_decl): Initialize mangled name. (namespace_decl::namespace_decl): Initialize visibility. (qualified_type_def::qualified_type_def) (pointer_type_def::pointer_type_def) (reference_type_def::reference_type_def): By default, set the visibility to the same as for the underlying type. (enum_type_decl::enum_type_decl, typedef_decl::typedef_decl): Initialize mangled name. (var_decl::var_decl, var_decl::operator==, var_decl::~var_decl): New definitions. * src/abg-reader.cc (read_visibility, read_binding, handle_var_decl): New definitions. (read_file): Handle var-decl elements. * src/abg-writer.cc (write_location): Rename write_decl_location into this. (write_var_decl, write_visibility, write_binding): New definitions. (write_decl, write_type_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl): Adjust to use write_location. * tests/data/test-read-write/test8.xml: New test input. * tests/test-read-write.cc: De-serialize the above and serialize it back and ensure both are equal. * tests/Makefile.am: add tests/data/test-read-write/test8.xml to the distribution.
2013-04-02 12:24:08 +00:00
/// ELF binding
Support var decl & mangled_name attributes * src/abg-ir.h (decl_base::binding, decl_base::get_mangled_name) (decl_base::set_mangled_name, decl_base::m_mangled_name): New declarations. (scope_decl::scope_decl: type_decl::type_decl) (scope_type_decl::scope_type_decl, typedef_decl::typedef_decl): Initialize mangled_name. (namespace_decl::namespace_decl): Initialize visibility. (class var_decl): New declaration. * src/abg-ir.cc (decl_base::decl_base, scope_decl::scope_decl) (type_decl::type_decl, scope_type_decl::scope_type_decl): Initialize mangled name. (namespace_decl::namespace_decl): Initialize visibility. (qualified_type_def::qualified_type_def) (pointer_type_def::pointer_type_def) (reference_type_def::reference_type_def): By default, set the visibility to the same as for the underlying type. (enum_type_decl::enum_type_decl, typedef_decl::typedef_decl): Initialize mangled name. (var_decl::var_decl, var_decl::operator==, var_decl::~var_decl): New definitions. * src/abg-reader.cc (read_visibility, read_binding, handle_var_decl): New definitions. (read_file): Handle var-decl elements. * src/abg-writer.cc (write_location): Rename write_decl_location into this. (write_var_decl, write_visibility, write_binding): New definitions. (write_decl, write_type_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl): Adjust to use write_location. * tests/data/test-read-write/test8.xml: New test input. * tests/test-read-write.cc: De-serialize the above and serialize it back and ensure both are equal. * tests/Makefile.am: add tests/data/test-read-write/test8.xml to the distribution.
2013-04-02 12:24:08 +00:00
enum binding
{
BINDING_NONE,
BINDING_LOCAL,
BINDING_GLOBAL,
BINDING_WEAK
};
Implement hash caching * include/abg-ir.h (decl_base::hash_): New member. (decl_base::{g,s}et_hash): New accessors. (type_base_::cached_hash): Forward-declare new hasher. (struct type_ptr_equal): New equality predicate. (type_shared_ptr_equal::operator()): Do not forget to test pointer equality. (type_base::cached_hash): Declare new hasher. * src/abg-hash.cc ({decl_base, type_decl, scope_type_decl, qualified_type_def, pointer_type_def, reference_type_def, enum_type_decl, typedef_decl, var_decl, function_decl, function_decl::parameter, class_decl::data_member, class_decl::member_function, class_decl, }::hash::operator()): Implement caching. (type_base::cached_hash::operator()(const type_base*)): Define. (type_base::cached_hash::operator() (const type_base_sptr): Define. * src/abg-ir.cc (type_ptr_map): Make this map use type_base::cached_hash instead of type_base::ptr_hash now. (decl_base::decl_base): Initialize the new decl_base::hash_. member. (decl_base::{s,g}et_hash): Define. (decl_base::operator==(const decl_base& other)): Take the hash in account to speed up inequality detection. * src/abg-writer.cc (type_ptr_map): Renamed type_shared_ptr_map into this. Make it use type_base::cached_hash and type_ptr_equal instead of type_base::shared_ptr_hash and type_shared_ptr_equal. (get_id_for_type): Add overload for type_base*. Re-write the previous overload in terms of this one. (write_context::m_type_id_map): Use type_ptr_map as the type for this. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 15:02:46 +00:00
protected:
mutable size_t hash_;
Implement hash caching * include/abg-ir.h (decl_base::hash_): New member. (decl_base::{g,s}et_hash): New accessors. (type_base_::cached_hash): Forward-declare new hasher. (struct type_ptr_equal): New equality predicate. (type_shared_ptr_equal::operator()): Do not forget to test pointer equality. (type_base::cached_hash): Declare new hasher. * src/abg-hash.cc ({decl_base, type_decl, scope_type_decl, qualified_type_def, pointer_type_def, reference_type_def, enum_type_decl, typedef_decl, var_decl, function_decl, function_decl::parameter, class_decl::data_member, class_decl::member_function, class_decl, }::hash::operator()): Implement caching. (type_base::cached_hash::operator()(const type_base*)): Define. (type_base::cached_hash::operator() (const type_base_sptr): Define. * src/abg-ir.cc (type_ptr_map): Make this map use type_base::cached_hash instead of type_base::ptr_hash now. (decl_base::decl_base): Initialize the new decl_base::hash_. member. (decl_base::{s,g}et_hash): Define. (decl_base::operator==(const decl_base& other)): Take the hash in account to speed up inequality detection. * src/abg-writer.cc (type_ptr_map): Renamed type_shared_ptr_map into this. Make it use type_base::cached_hash and type_ptr_equal instead of type_base::shared_ptr_hash and type_shared_ptr_equal. (get_id_for_type): Add overload for type_base*. Re-write the previous overload in terms of this one. (write_context::m_type_id_map): Use type_ptr_map as the type for this. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 15:02:46 +00:00
private:
location location_;
std::string name_;
mutable std::string qualified_name_;
Implement hash caching * include/abg-ir.h (decl_base::hash_): New member. (decl_base::{g,s}et_hash): New accessors. (type_base_::cached_hash): Forward-declare new hasher. (struct type_ptr_equal): New equality predicate. (type_shared_ptr_equal::operator()): Do not forget to test pointer equality. (type_base::cached_hash): Declare new hasher. * src/abg-hash.cc ({decl_base, type_decl, scope_type_decl, qualified_type_def, pointer_type_def, reference_type_def, enum_type_decl, typedef_decl, var_decl, function_decl, function_decl::parameter, class_decl::data_member, class_decl::member_function, class_decl, }::hash::operator()): Implement caching. (type_base::cached_hash::operator()(const type_base*)): Define. (type_base::cached_hash::operator() (const type_base_sptr): Define. * src/abg-ir.cc (type_ptr_map): Make this map use type_base::cached_hash instead of type_base::ptr_hash now. (decl_base::decl_base): Initialize the new decl_base::hash_. member. (decl_base::{s,g}et_hash): Define. (decl_base::operator==(const decl_base& other)): Take the hash in account to speed up inequality detection. * src/abg-writer.cc (type_ptr_map): Renamed type_shared_ptr_map into this. Make it use type_base::cached_hash and type_ptr_equal instead of type_base::shared_ptr_hash and type_shared_ptr_equal. (get_id_for_type): Add overload for type_base*. Re-write the previous overload in terms of this one. (write_context::m_type_id_map): Use type_ptr_map as the type for this. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 15:02:46 +00:00
std::string mangled_name_;
scope_decl* context_;
visibility visibility_;
// Forbidden
decl_base();
virtual void
set_scope(scope_decl*);
public:
decl_base(const std::string& name, location locus,
Support var decl & mangled_name attributes * src/abg-ir.h (decl_base::binding, decl_base::get_mangled_name) (decl_base::set_mangled_name, decl_base::m_mangled_name): New declarations. (scope_decl::scope_decl: type_decl::type_decl) (scope_type_decl::scope_type_decl, typedef_decl::typedef_decl): Initialize mangled_name. (namespace_decl::namespace_decl): Initialize visibility. (class var_decl): New declaration. * src/abg-ir.cc (decl_base::decl_base, scope_decl::scope_decl) (type_decl::type_decl, scope_type_decl::scope_type_decl): Initialize mangled name. (namespace_decl::namespace_decl): Initialize visibility. (qualified_type_def::qualified_type_def) (pointer_type_def::pointer_type_def) (reference_type_def::reference_type_def): By default, set the visibility to the same as for the underlying type. (enum_type_decl::enum_type_decl, typedef_decl::typedef_decl): Initialize mangled name. (var_decl::var_decl, var_decl::operator==, var_decl::~var_decl): New definitions. * src/abg-reader.cc (read_visibility, read_binding, handle_var_decl): New definitions. (read_file): Handle var-decl elements. * src/abg-writer.cc (write_location): Rename write_decl_location into this. (write_var_decl, write_visibility, write_binding): New definitions. (write_decl, write_type_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl): Adjust to use write_location. * tests/data/test-read-write/test8.xml: New test input. * tests/test-read-write.cc: De-serialize the above and serialize it back and ensure both are equal. * tests/Makefile.am: add tests/data/test-read-write/test8.xml to the distribution.
2013-04-02 12:24:08 +00:00
const std::string& mangled_name = "",
visibility vis = VISIBILITY_DEFAULT);
decl_base(location);
decl_base(const decl_base&);
virtual bool
operator==(const decl_base&) const;
virtual void
traverse(ir_node_visitor& v);
virtual ~decl_base();
Implement hash caching * include/abg-ir.h (decl_base::hash_): New member. (decl_base::{g,s}et_hash): New accessors. (type_base_::cached_hash): Forward-declare new hasher. (struct type_ptr_equal): New equality predicate. (type_shared_ptr_equal::operator()): Do not forget to test pointer equality. (type_base::cached_hash): Declare new hasher. * src/abg-hash.cc ({decl_base, type_decl, scope_type_decl, qualified_type_def, pointer_type_def, reference_type_def, enum_type_decl, typedef_decl, var_decl, function_decl, function_decl::parameter, class_decl::data_member, class_decl::member_function, class_decl, }::hash::operator()): Implement caching. (type_base::cached_hash::operator()(const type_base*)): Define. (type_base::cached_hash::operator() (const type_base_sptr): Define. * src/abg-ir.cc (type_ptr_map): Make this map use type_base::cached_hash instead of type_base::ptr_hash now. (decl_base::decl_base): Initialize the new decl_base::hash_. member. (decl_base::{s,g}et_hash): Define. (decl_base::operator==(const decl_base& other)): Take the hash in account to speed up inequality detection. * src/abg-writer.cc (type_ptr_map): Renamed type_shared_ptr_map into this. Make it use type_base::cached_hash and type_ptr_equal instead of type_base::shared_ptr_hash and type_shared_ptr_equal. (get_id_for_type): Add overload for type_base*. Re-write the previous overload in terms of this one. (write_context::m_type_id_map): Use type_ptr_map as the type for this. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 15:02:46 +00:00
size_t
get_hash() const;
void
set_hash(size_t) const;
location
get_location() const
{return location_;}
void
Support var decl & mangled_name attributes * src/abg-ir.h (decl_base::binding, decl_base::get_mangled_name) (decl_base::set_mangled_name, decl_base::m_mangled_name): New declarations. (scope_decl::scope_decl: type_decl::type_decl) (scope_type_decl::scope_type_decl, typedef_decl::typedef_decl): Initialize mangled_name. (namespace_decl::namespace_decl): Initialize visibility. (class var_decl): New declaration. * src/abg-ir.cc (decl_base::decl_base, scope_decl::scope_decl) (type_decl::type_decl, scope_type_decl::scope_type_decl): Initialize mangled name. (namespace_decl::namespace_decl): Initialize visibility. (qualified_type_def::qualified_type_def) (pointer_type_def::pointer_type_def) (reference_type_def::reference_type_def): By default, set the visibility to the same as for the underlying type. (enum_type_decl::enum_type_decl, typedef_decl::typedef_decl): Initialize mangled name. (var_decl::var_decl, var_decl::operator==, var_decl::~var_decl): New definitions. * src/abg-reader.cc (read_visibility, read_binding, handle_var_decl): New definitions. (read_file): Handle var-decl elements. * src/abg-writer.cc (write_location): Rename write_decl_location into this. (write_var_decl, write_visibility, write_binding): New definitions. (write_decl, write_type_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl): Adjust to use write_location. * tests/data/test-read-write/test8.xml: New test input. * tests/test-read-write.cc: De-serialize the above and serialize it back and ensure both are equal. * tests/Makefile.am: add tests/data/test-read-write/test8.xml to the distribution.
2013-04-02 12:24:08 +00:00
set_location(const location& l)
{location_ = l;}
const string&
get_name() const
{return name_;}
Support diff/reporting for functions & better diff/report in general * include/abg-ir.h ({decl_base, class_decl, function_decl}::get_pretty_representation): New virtual member to get a pretty string name for decls & types. (class_decl::parameter): Add an index to the parameter type. (class_decl::parameter::parameter): Update the constructor for the change above. (class_decl::parameter::{get_index, set_index}): Accessors for the new index. (class_decl::parameter::operator==): Take in account the index. (function_type::append_parameter): Set the index of the parameter here. * include/abg-fwd.h (get_type_name): New declaration. * src/abg-ir.cc (get_type_name): New definition. ({decl_base, function_decl, class_decl}::get_pretty_representation): New implementations. (method_type::set_class_type): Update this to set function parameter's index by default. (function_decl::append_parameters): Use the append_parameter method from function_type. * include/abg-comparison.h (class function_decl_diff): New type declaration. * src/abg-comparison.cc (compute_diff_for_decls, compute_diff): New definitions. ({pointer_diff, class_diff, scope_diff}::report): Use the new get_pretty_representation. Output a prettier report. (function_decl_diff::priv): New type. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at, ensure_lookup_tables_populated, function_decl_diff, first_function_decl, second_function_decl, changed_parms, removed_parms, added_parms, length, report}): New member function definitions. * src/abg-hash.cc (function_decl::parameter::hash): Update this to take the index in account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
virtual string
get_pretty_representation() const;
Un-debugged initial implementation of class diffing. * include/abg-ir.h (decl_base::get_qualified_name): New declaration. (class_decl::{base_specs, member_types, data_members, member_functions, member_function_templates, member_class_templates}): Make all these containers be vectors, rather than list. This makes these containers (like class_decl::base_specs, class_decl::member_types, etc) be suitable to be used by the core diffing algorithms to diff their content. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Declare these new equality operators. These are to be used by the core diffing algorithms when comparing two vectors of shared pointers of members of class_decls. * src/abg-ir.cc (decl_base::get_qualified_name): Define. (class_decl::class_decl, class_decl::operator==(class_decl&)): Adjust for the containers type change to a vector. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Define these. * include/abg-comparison.h (diff::scope_): Remove (diff::{first_scope_, second_scope_}): New members. (class_decl_diff::class_decl_diff): Pass the new scopes to this constructor. (class_decl_diff::{first_class_decl, second_class_decl}) (report_changes): New declarations. * src/abg-comparison.cc (class_decl_diff::class_decl_diff): Update as per the declaration. (class_decl_diff::{first_class_decl, second_class_decl}): Define as per the declaration. (compute_diff): Initial implementation for this. (report_changes): Define. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-04 15:39:08 +00:00
void
get_qualified_name(string& qualified_name,
const string& separator = "::") const;
string
get_qualified_name(const string& separator = "::") const;
void
set_name(const string& n)
{ name_ = n; }
Support var decl & mangled_name attributes * src/abg-ir.h (decl_base::binding, decl_base::get_mangled_name) (decl_base::set_mangled_name, decl_base::m_mangled_name): New declarations. (scope_decl::scope_decl: type_decl::type_decl) (scope_type_decl::scope_type_decl, typedef_decl::typedef_decl): Initialize mangled_name. (namespace_decl::namespace_decl): Initialize visibility. (class var_decl): New declaration. * src/abg-ir.cc (decl_base::decl_base, scope_decl::scope_decl) (type_decl::type_decl, scope_type_decl::scope_type_decl): Initialize mangled name. (namespace_decl::namespace_decl): Initialize visibility. (qualified_type_def::qualified_type_def) (pointer_type_def::pointer_type_def) (reference_type_def::reference_type_def): By default, set the visibility to the same as for the underlying type. (enum_type_decl::enum_type_decl, typedef_decl::typedef_decl): Initialize mangled name. (var_decl::var_decl, var_decl::operator==, var_decl::~var_decl): New definitions. * src/abg-reader.cc (read_visibility, read_binding, handle_var_decl): New definitions. (read_file): Handle var-decl elements. * src/abg-writer.cc (write_location): Rename write_decl_location into this. (write_var_decl, write_visibility, write_binding): New definitions. (write_decl, write_type_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl): Adjust to use write_location. * tests/data/test-read-write/test8.xml: New test input. * tests/test-read-write.cc: De-serialize the above and serialize it back and ensure both are equal. * tests/Makefile.am: add tests/data/test-read-write/test8.xml to the distribution.
2013-04-02 12:24:08 +00:00
const string&
get_mangled_name() const
{return mangled_name_;}
Support var decl & mangled_name attributes * src/abg-ir.h (decl_base::binding, decl_base::get_mangled_name) (decl_base::set_mangled_name, decl_base::m_mangled_name): New declarations. (scope_decl::scope_decl: type_decl::type_decl) (scope_type_decl::scope_type_decl, typedef_decl::typedef_decl): Initialize mangled_name. (namespace_decl::namespace_decl): Initialize visibility. (class var_decl): New declaration. * src/abg-ir.cc (decl_base::decl_base, scope_decl::scope_decl) (type_decl::type_decl, scope_type_decl::scope_type_decl): Initialize mangled name. (namespace_decl::namespace_decl): Initialize visibility. (qualified_type_def::qualified_type_def) (pointer_type_def::pointer_type_def) (reference_type_def::reference_type_def): By default, set the visibility to the same as for the underlying type. (enum_type_decl::enum_type_decl, typedef_decl::typedef_decl): Initialize mangled name. (var_decl::var_decl, var_decl::operator==, var_decl::~var_decl): New definitions. * src/abg-reader.cc (read_visibility, read_binding, handle_var_decl): New definitions. (read_file): Handle var-decl elements. * src/abg-writer.cc (write_location): Rename write_decl_location into this. (write_var_decl, write_visibility, write_binding): New definitions. (write_decl, write_type_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl): Adjust to use write_location. * tests/data/test-read-write/test8.xml: New test input. * tests/test-read-write.cc: De-serialize the above and serialize it back and ensure both are equal. * tests/Makefile.am: add tests/data/test-read-write/test8.xml to the distribution.
2013-04-02 12:24:08 +00:00
void
set_mangled_name(const std::string& m)
{ mangled_name_ = m; }
Support var decl & mangled_name attributes * src/abg-ir.h (decl_base::binding, decl_base::get_mangled_name) (decl_base::set_mangled_name, decl_base::m_mangled_name): New declarations. (scope_decl::scope_decl: type_decl::type_decl) (scope_type_decl::scope_type_decl, typedef_decl::typedef_decl): Initialize mangled_name. (namespace_decl::namespace_decl): Initialize visibility. (class var_decl): New declaration. * src/abg-ir.cc (decl_base::decl_base, scope_decl::scope_decl) (type_decl::type_decl, scope_type_decl::scope_type_decl): Initialize mangled name. (namespace_decl::namespace_decl): Initialize visibility. (qualified_type_def::qualified_type_def) (pointer_type_def::pointer_type_def) (reference_type_def::reference_type_def): By default, set the visibility to the same as for the underlying type. (enum_type_decl::enum_type_decl, typedef_decl::typedef_decl): Initialize mangled name. (var_decl::var_decl, var_decl::operator==, var_decl::~var_decl): New definitions. * src/abg-reader.cc (read_visibility, read_binding, handle_var_decl): New definitions. (read_file): Handle var-decl elements. * src/abg-writer.cc (write_location): Rename write_decl_location into this. (write_var_decl, write_visibility, write_binding): New definitions. (write_decl, write_type_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl): Adjust to use write_location. * tests/data/test-read-write/test8.xml: New test input. * tests/test-read-write.cc: De-serialize the above and serialize it back and ensure both are equal. * tests/Makefile.am: add tests/data/test-read-write/test8.xml to the distribution.
2013-04-02 12:24:08 +00:00
scope_decl*
get_scope() const
{return context_;}
visibility
get_visibility() const
{return visibility_;}
void
set_visibility(visibility v)
{visibility_ = v;}
Fix class scope setting & member type de-serializing from dwarf * include/abg-fwd.h (add_decl_to_scope, insert_decl_into_scope): return the decl added to the scope. (as_non_member_type, get_type_declaration): Declare new entry points. * include/abg-ir.h (class decl_base::insert_decl_into_scope): Update this friend declaration. (class scope_decl, class_decl): Update the friend add_decl_to_scope declaration. (scope_decl::add_member_decl): Return the added decl. (class_decl_sptr): Move this typedef befoer the class_decl class declaration. (class_decl::definition_of_declaration_): New member. (class_decl::{set_definition_of_declaration, get_definition_of_declaration}): New accessors. (class_decl::add_member_decl): Return the added member. (class_decl::insert_member_type): New member. (class_decl::member_base::access_specifier): Make this protected. (class_decl::member_type): Make this inherit from type_vase. (class_decl::member_type::type_): Remove this member. (class_decl::member_type::as_type): Remove this accessor. (class_decl::member_type::operator==(const type_base&)): New. (class_decl::member_type::operator shared_ptr<type_base>() const): Remove. (class_decl::member_type::get_underlying_type): New. (class_decl::member_type::operator==(const member_type&) const): New. * src/abg-comparison.cc (class_diff::{ensure_lookup_tables_populated, report}): Adjust for the removal of class_decl::member_type::as_type. * src/abg-dwarf-reader.cc (scope_stack_type): Change this as a typedef to stack<scope_decl*>. (current_scope): Change return type from scope_decl_sptr to scope_decl*. (insert_decl_into_scope): New. (build_namespace_decl_and_add_to_ir): Use insert_decl_into_scope in lieu of add_decl_to_scope. (build_class_type_and_add_to_ir): likewise. Link a class definition to its declaration. Push the current scope on the scope stack. Use as_non_member_type. Fix setting member types. (get_scope_for_die): Look through declaration-only classe to get its definition. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type, build_var_decl) (build_function_decl): Use as_non_member_type. (build_ir_node_from_die): Fix member variable & function adding. * src/abg-ir.cc (scope_decl::{add_member_decl, insert_member_decl}): Return the added member. (add_decl_to_scope): Likewise. (insert_decl_into_scope): Likewise. (get_top_most_scope_under): Fix logic. (get_type_declaration): New overload that return a decl_base*. (as_non_member_type): New definition. (class_decl::{get_definition_of_declaration, set_definition_of_declaration, insert_member_decl}): Likewise. (class_decl::add_member_decl): Re-write in terms of class::insert_member_decl. (class_decl::insert_member_type): New definition. (class_decl::add_member_type): Re-write in terms of class_decl::insert_member_type. (class_decl::remove_member_type): Update for the class_decl::member_type::as_type removal. (class_decl::{add_data_member, add_member_function, add_member_function_template, add_member_class_template}): Call scope_decl::add_member_decl. (class_decl::member_type::member_type): Update as the type now virtually inherits from type_base. (class_decl::member_type::{set,get}_access_specifier): New definitions. (class_decl::member_type::get_underlying_type): Likewise. (class_decl::member_type::set_scope): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. (class_decl::member_type::operator==(const decl_base& other)): There is no more class_decl::member_type::as_type. (class_decl::member_type::operator==(const type_base& other)): New. (class_decl::member_type::get_pretty_representation): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. * src/abg-reader.cc (build_class_decl): New that add add_member_decl adds even member types, no need to add it explicitly anymore. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 11:27:47 +00:00
friend decl_base_sptr
add_decl_to_scope(decl_base_sptr dcl, scope_decl* scpe);
Avoid missing member types while reading bi files * include/abg-fwd.h (get_type_declaration): Declare function. * include/abg-ir.h (class decl_base): Add class_decl as a friend. This to be able to call decl_base::set_scope from class_decl. (scope_decl::add_member_decl): Make this virtual protected, so that it can be called (virtually) from e.g, class_decl. (type_decl_sptr, typedef_decl_sptr): New convenience typedefs. (class_decl::add_member_decl): New virtual overload for scope_decl::add_member_decl. (class_decl::{add_member_type, add_data_member, add_member_function}): New overloads. * src/abg-ir.cc (add_decl_to_scope): Benign style cleanup. (get_type_declaration): Define new function. (class_decl::add_member_decl): New method. (class_decl::add_member_type): Avoid silently added a new member type when that member type has already been (perhaps inadvertently) added to a scope already. Rather, put a strict assert in place there. Also add a new overload that constructs the member type out of a classic type and adds it to the class. (class_decl::{add_data_member, add_member_function}): Likewise. (class_decl::{add_member_function_template, add_member_class_template}): Avoid silently added a new member template when that template has already been (perhaps inadvertently) added to a scope already. Rather, put a strict assert in place there. * src/abg-reader.cc (push_decl_to_current_scope): Take a an extra flag saying if the current decl should be added to the current scope as well (in addition to being pushed onto the stack of scopes maintained in the reader context). (push_and_key_type_decl): Likewise, take that extra flag and pass it to push_decl_to_current_scope. (build_function_decl, build_var_decl, build_type_decl) (build_qualified_type_decl, build_pointer_type_def) (build_reference_type_def, build_enum_type_decl, build_typedef_decl) (build_function_tdecl, build_class_tdecl): Likewise. (build_class_decl): Likewise. When building member data, types, and functions, make sure /not/ to add the data, type of function to the current scope before adding it to the class_decl. This was making the member not being added to the class because it already had a scope. (build_type_tparameter, build_type_composition) (build_non_type_tparameter, build_template_tparameter) (build_type): Adjust to add the template parm to the current scope explicitly, like previously. (handle_type_decl): Use build_type_decl function. Add the type_decl to the current scope, like previously. (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl) (handle_function_decl, handle_class_decl, handle_function_tdecl) (handle_class_tdecl): Adjust to add the decl to the current scope, like previously. * tests/data/test-read-write/test21.xml: New test input with member type(def). Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:06:04 +00:00
friend void
remove_decl_from_scope(decl_base_sptr);
Fix class scope setting & member type de-serializing from dwarf * include/abg-fwd.h (add_decl_to_scope, insert_decl_into_scope): return the decl added to the scope. (as_non_member_type, get_type_declaration): Declare new entry points. * include/abg-ir.h (class decl_base::insert_decl_into_scope): Update this friend declaration. (class scope_decl, class_decl): Update the friend add_decl_to_scope declaration. (scope_decl::add_member_decl): Return the added decl. (class_decl_sptr): Move this typedef befoer the class_decl class declaration. (class_decl::definition_of_declaration_): New member. (class_decl::{set_definition_of_declaration, get_definition_of_declaration}): New accessors. (class_decl::add_member_decl): Return the added member. (class_decl::insert_member_type): New member. (class_decl::member_base::access_specifier): Make this protected. (class_decl::member_type): Make this inherit from type_vase. (class_decl::member_type::type_): Remove this member. (class_decl::member_type::as_type): Remove this accessor. (class_decl::member_type::operator==(const type_base&)): New. (class_decl::member_type::operator shared_ptr<type_base>() const): Remove. (class_decl::member_type::get_underlying_type): New. (class_decl::member_type::operator==(const member_type&) const): New. * src/abg-comparison.cc (class_diff::{ensure_lookup_tables_populated, report}): Adjust for the removal of class_decl::member_type::as_type. * src/abg-dwarf-reader.cc (scope_stack_type): Change this as a typedef to stack<scope_decl*>. (current_scope): Change return type from scope_decl_sptr to scope_decl*. (insert_decl_into_scope): New. (build_namespace_decl_and_add_to_ir): Use insert_decl_into_scope in lieu of add_decl_to_scope. (build_class_type_and_add_to_ir): likewise. Link a class definition to its declaration. Push the current scope on the scope stack. Use as_non_member_type. Fix setting member types. (get_scope_for_die): Look through declaration-only classe to get its definition. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type, build_var_decl) (build_function_decl): Use as_non_member_type. (build_ir_node_from_die): Fix member variable & function adding. * src/abg-ir.cc (scope_decl::{add_member_decl, insert_member_decl}): Return the added member. (add_decl_to_scope): Likewise. (insert_decl_into_scope): Likewise. (get_top_most_scope_under): Fix logic. (get_type_declaration): New overload that return a decl_base*. (as_non_member_type): New definition. (class_decl::{get_definition_of_declaration, set_definition_of_declaration, insert_member_decl}): Likewise. (class_decl::add_member_decl): Re-write in terms of class::insert_member_decl. (class_decl::insert_member_type): New definition. (class_decl::add_member_type): Re-write in terms of class_decl::insert_member_type. (class_decl::remove_member_type): Update for the class_decl::member_type::as_type removal. (class_decl::{add_data_member, add_member_function, add_member_function_template, add_member_class_template}): Call scope_decl::add_member_decl. (class_decl::member_type::member_type): Update as the type now virtually inherits from type_base. (class_decl::member_type::{set,get}_access_specifier): New definitions. (class_decl::member_type::get_underlying_type): Likewise. (class_decl::member_type::set_scope): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. (class_decl::member_type::operator==(const decl_base& other)): There is no more class_decl::member_type::as_type. (class_decl::member_type::operator==(const type_base& other)): New. (class_decl::member_type::get_pretty_representation): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. * src/abg-reader.cc (build_class_decl): New that add add_member_decl adds even member types, no need to add it explicitly anymore. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 11:27:47 +00:00
friend decl_base_sptr
insert_decl_into_scope(decl_base_sptr,
Support reading namespaces * include/abg-fwd.h (get_global_scope): Return a const global_scope. Add a new overload that takes a naked pointer as parm. (insert_decl_into_scope, get_top_most_scope_under): Declare new entry points. * include/abg-ir.h (class decl_base, class scope_decl): Add insert_decl_into_scope as a friend of these classes. (scope_decl::{insert_decl_into_scope, find_iterator_for_member}): Declare new member. (scope_decl::get_member_decls): New non-const overload. * src/abg-dwarf-reader.cc (build_translation_unit): Remove the "recurse" parameter. Adjust the call to build_ir_node_from_die to read just public decls that are at namespace scope. Anything else should be dropped unless it's needed to emitting the public namespace-level decls. (build_namespace_decl_and_add_to_ir) (canonicalize_and_insert_type_into_ir): Define new static functions. (build_corpus): Adjust ad build_translation_unit doesn't have the "recurse" parameter anymore. (canonicalize_and_add_type_to_ir): Make this static. Fix comments. (build_ir_node_from_die): Take a new "only_public_decl" parameter. For DW_TAG_base_type case, use the new canonicalize_and_insert_type_into_ir to insert the type at the right place in the global scope making sure it is seen before the current scope. For pointer, references and qualified types, use canonicalize_and_insert_type_into_ir to add the type at the same scope as its underlying type. Handle DW_TAG_{namespace,module} using the new build_namespace_decl_and_add_to_ir function. Add some vertical spaces and some assertions. * src/abg-ir.cc (scope_decl::add_member_decl): Use scope_decl_sptr typedef. (scope_decl::{insert_member_decl,find_iterator_for_member}): Define new methods. (insert_decl_into_scope, get_top_most_scope_under): Define new functions. (get_global_scope): Constify the return type. (get_translation_unit): Adjust as get_global_scope now returns a const. * src/abg-reader.cc (get_translation_unit): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-12 14:40:52 +00:00
vector<shared_ptr<decl_base> >::iterator,
scope_decl*);
Avoid missing member types while reading bi files * include/abg-fwd.h (get_type_declaration): Declare function. * include/abg-ir.h (class decl_base): Add class_decl as a friend. This to be able to call decl_base::set_scope from class_decl. (scope_decl::add_member_decl): Make this virtual protected, so that it can be called (virtually) from e.g, class_decl. (type_decl_sptr, typedef_decl_sptr): New convenience typedefs. (class_decl::add_member_decl): New virtual overload for scope_decl::add_member_decl. (class_decl::{add_member_type, add_data_member, add_member_function}): New overloads. * src/abg-ir.cc (add_decl_to_scope): Benign style cleanup. (get_type_declaration): Define new function. (class_decl::add_member_decl): New method. (class_decl::add_member_type): Avoid silently added a new member type when that member type has already been (perhaps inadvertently) added to a scope already. Rather, put a strict assert in place there. Also add a new overload that constructs the member type out of a classic type and adds it to the class. (class_decl::{add_data_member, add_member_function}): Likewise. (class_decl::{add_member_function_template, add_member_class_template}): Avoid silently added a new member template when that template has already been (perhaps inadvertently) added to a scope already. Rather, put a strict assert in place there. * src/abg-reader.cc (push_decl_to_current_scope): Take a an extra flag saying if the current decl should be added to the current scope as well (in addition to being pushed onto the stack of scopes maintained in the reader context). (push_and_key_type_decl): Likewise, take that extra flag and pass it to push_decl_to_current_scope. (build_function_decl, build_var_decl, build_type_decl) (build_qualified_type_decl, build_pointer_type_def) (build_reference_type_def, build_enum_type_decl, build_typedef_decl) (build_function_tdecl, build_class_tdecl): Likewise. (build_class_decl): Likewise. When building member data, types, and functions, make sure /not/ to add the data, type of function to the current scope before adding it to the class_decl. This was making the member not being added to the class because it already had a scope. (build_type_tparameter, build_type_composition) (build_non_type_tparameter, build_template_tparameter) (build_type): Adjust to add the template parm to the current scope explicitly, like previously. (handle_type_decl): Use build_type_decl function. Add the type_decl to the current scope, like previously. (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl) (handle_function_decl, handle_class_decl, handle_function_tdecl) (handle_class_tdecl): Adjust to add the decl to the current scope, like previously. * tests/data/test-read-write/test21.xml: New test input with member type(def). Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:06:04 +00:00
friend class class_decl;
};// end class decl_base
bool
operator==(decl_base_sptr, decl_base_sptr);
std::ostream&
operator<<(std::ostream&, decl_base::visibility);
std::ostream&
operator<<(std::ostream&, decl_base::binding);
/// Convenience typedef for a shared pointer on a @ref scope_decl.
typedef shared_ptr<scope_decl> scope_decl_sptr;
/// A declaration that introduces a scope.
class scope_decl : public virtual decl_base
{
public:
/// Convenience typedef for a vector of @ref decl_base_sptr.
typedef std::vector<decl_base_sptr > declarations;
/// Convenience typedef for a vector of @ref scope_decl_sptr.
typedef std::vector<scope_decl_sptr> scopes;
private:
declarations members_;
scopes member_scopes_;
scope_decl();
Avoid missing member types while reading bi files * include/abg-fwd.h (get_type_declaration): Declare function. * include/abg-ir.h (class decl_base): Add class_decl as a friend. This to be able to call decl_base::set_scope from class_decl. (scope_decl::add_member_decl): Make this virtual protected, so that it can be called (virtually) from e.g, class_decl. (type_decl_sptr, typedef_decl_sptr): New convenience typedefs. (class_decl::add_member_decl): New virtual overload for scope_decl::add_member_decl. (class_decl::{add_member_type, add_data_member, add_member_function}): New overloads. * src/abg-ir.cc (add_decl_to_scope): Benign style cleanup. (get_type_declaration): Define new function. (class_decl::add_member_decl): New method. (class_decl::add_member_type): Avoid silently added a new member type when that member type has already been (perhaps inadvertently) added to a scope already. Rather, put a strict assert in place there. Also add a new overload that constructs the member type out of a classic type and adds it to the class. (class_decl::{add_data_member, add_member_function}): Likewise. (class_decl::{add_member_function_template, add_member_class_template}): Avoid silently added a new member template when that template has already been (perhaps inadvertently) added to a scope already. Rather, put a strict assert in place there. * src/abg-reader.cc (push_decl_to_current_scope): Take a an extra flag saying if the current decl should be added to the current scope as well (in addition to being pushed onto the stack of scopes maintained in the reader context). (push_and_key_type_decl): Likewise, take that extra flag and pass it to push_decl_to_current_scope. (build_function_decl, build_var_decl, build_type_decl) (build_qualified_type_decl, build_pointer_type_def) (build_reference_type_def, build_enum_type_decl, build_typedef_decl) (build_function_tdecl, build_class_tdecl): Likewise. (build_class_decl): Likewise. When building member data, types, and functions, make sure /not/ to add the data, type of function to the current scope before adding it to the class_decl. This was making the member not being added to the class because it already had a scope. (build_type_tparameter, build_type_composition) (build_non_type_tparameter, build_template_tparameter) (build_type): Adjust to add the template parm to the current scope explicitly, like previously. (handle_type_decl): Use build_type_decl function. Add the type_decl to the current scope, like previously. (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl) (handle_function_decl, handle_class_decl, handle_function_tdecl) (handle_class_tdecl): Adjust to add the decl to the current scope, like previously. * tests/data/test-read-write/test21.xml: New test input with member type(def). Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:06:04 +00:00
protected:
Fix class scope setting & member type de-serializing from dwarf * include/abg-fwd.h (add_decl_to_scope, insert_decl_into_scope): return the decl added to the scope. (as_non_member_type, get_type_declaration): Declare new entry points. * include/abg-ir.h (class decl_base::insert_decl_into_scope): Update this friend declaration. (class scope_decl, class_decl): Update the friend add_decl_to_scope declaration. (scope_decl::add_member_decl): Return the added decl. (class_decl_sptr): Move this typedef befoer the class_decl class declaration. (class_decl::definition_of_declaration_): New member. (class_decl::{set_definition_of_declaration, get_definition_of_declaration}): New accessors. (class_decl::add_member_decl): Return the added member. (class_decl::insert_member_type): New member. (class_decl::member_base::access_specifier): Make this protected. (class_decl::member_type): Make this inherit from type_vase. (class_decl::member_type::type_): Remove this member. (class_decl::member_type::as_type): Remove this accessor. (class_decl::member_type::operator==(const type_base&)): New. (class_decl::member_type::operator shared_ptr<type_base>() const): Remove. (class_decl::member_type::get_underlying_type): New. (class_decl::member_type::operator==(const member_type&) const): New. * src/abg-comparison.cc (class_diff::{ensure_lookup_tables_populated, report}): Adjust for the removal of class_decl::member_type::as_type. * src/abg-dwarf-reader.cc (scope_stack_type): Change this as a typedef to stack<scope_decl*>. (current_scope): Change return type from scope_decl_sptr to scope_decl*. (insert_decl_into_scope): New. (build_namespace_decl_and_add_to_ir): Use insert_decl_into_scope in lieu of add_decl_to_scope. (build_class_type_and_add_to_ir): likewise. Link a class definition to its declaration. Push the current scope on the scope stack. Use as_non_member_type. Fix setting member types. (get_scope_for_die): Look through declaration-only classe to get its definition. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type, build_var_decl) (build_function_decl): Use as_non_member_type. (build_ir_node_from_die): Fix member variable & function adding. * src/abg-ir.cc (scope_decl::{add_member_decl, insert_member_decl}): Return the added member. (add_decl_to_scope): Likewise. (insert_decl_into_scope): Likewise. (get_top_most_scope_under): Fix logic. (get_type_declaration): New overload that return a decl_base*. (as_non_member_type): New definition. (class_decl::{get_definition_of_declaration, set_definition_of_declaration, insert_member_decl}): Likewise. (class_decl::add_member_decl): Re-write in terms of class::insert_member_decl. (class_decl::insert_member_type): New definition. (class_decl::add_member_type): Re-write in terms of class_decl::insert_member_type. (class_decl::remove_member_type): Update for the class_decl::member_type::as_type removal. (class_decl::{add_data_member, add_member_function, add_member_function_template, add_member_class_template}): Call scope_decl::add_member_decl. (class_decl::member_type::member_type): Update as the type now virtually inherits from type_base. (class_decl::member_type::{set,get}_access_specifier): New definitions. (class_decl::member_type::get_underlying_type): Likewise. (class_decl::member_type::set_scope): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. (class_decl::member_type::operator==(const decl_base& other)): There is no more class_decl::member_type::as_type. (class_decl::member_type::operator==(const type_base& other)): New. (class_decl::member_type::get_pretty_representation): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. * src/abg-reader.cc (build_class_decl): New that add add_member_decl adds even member types, no need to add it explicitly anymore. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 11:27:47 +00:00
virtual decl_base_sptr
add_member_decl(const decl_base_sptr member);
Fix class scope setting & member type de-serializing from dwarf * include/abg-fwd.h (add_decl_to_scope, insert_decl_into_scope): return the decl added to the scope. (as_non_member_type, get_type_declaration): Declare new entry points. * include/abg-ir.h (class decl_base::insert_decl_into_scope): Update this friend declaration. (class scope_decl, class_decl): Update the friend add_decl_to_scope declaration. (scope_decl::add_member_decl): Return the added decl. (class_decl_sptr): Move this typedef befoer the class_decl class declaration. (class_decl::definition_of_declaration_): New member. (class_decl::{set_definition_of_declaration, get_definition_of_declaration}): New accessors. (class_decl::add_member_decl): Return the added member. (class_decl::insert_member_type): New member. (class_decl::member_base::access_specifier): Make this protected. (class_decl::member_type): Make this inherit from type_vase. (class_decl::member_type::type_): Remove this member. (class_decl::member_type::as_type): Remove this accessor. (class_decl::member_type::operator==(const type_base&)): New. (class_decl::member_type::operator shared_ptr<type_base>() const): Remove. (class_decl::member_type::get_underlying_type): New. (class_decl::member_type::operator==(const member_type&) const): New. * src/abg-comparison.cc (class_diff::{ensure_lookup_tables_populated, report}): Adjust for the removal of class_decl::member_type::as_type. * src/abg-dwarf-reader.cc (scope_stack_type): Change this as a typedef to stack<scope_decl*>. (current_scope): Change return type from scope_decl_sptr to scope_decl*. (insert_decl_into_scope): New. (build_namespace_decl_and_add_to_ir): Use insert_decl_into_scope in lieu of add_decl_to_scope. (build_class_type_and_add_to_ir): likewise. Link a class definition to its declaration. Push the current scope on the scope stack. Use as_non_member_type. Fix setting member types. (get_scope_for_die): Look through declaration-only classe to get its definition. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type, build_var_decl) (build_function_decl): Use as_non_member_type. (build_ir_node_from_die): Fix member variable & function adding. * src/abg-ir.cc (scope_decl::{add_member_decl, insert_member_decl}): Return the added member. (add_decl_to_scope): Likewise. (insert_decl_into_scope): Likewise. (get_top_most_scope_under): Fix logic. (get_type_declaration): New overload that return a decl_base*. (as_non_member_type): New definition. (class_decl::{get_definition_of_declaration, set_definition_of_declaration, insert_member_decl}): Likewise. (class_decl::add_member_decl): Re-write in terms of class::insert_member_decl. (class_decl::insert_member_type): New definition. (class_decl::add_member_type): Re-write in terms of class_decl::insert_member_type. (class_decl::remove_member_type): Update for the class_decl::member_type::as_type removal. (class_decl::{add_data_member, add_member_function, add_member_function_template, add_member_class_template}): Call scope_decl::add_member_decl. (class_decl::member_type::member_type): Update as the type now virtually inherits from type_base. (class_decl::member_type::{set,get}_access_specifier): New definitions. (class_decl::member_type::get_underlying_type): Likewise. (class_decl::member_type::set_scope): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. (class_decl::member_type::operator==(const decl_base& other)): There is no more class_decl::member_type::as_type. (class_decl::member_type::operator==(const type_base& other)): New. (class_decl::member_type::get_pretty_representation): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. * src/abg-reader.cc (build_class_decl): New that add add_member_decl adds even member types, no need to add it explicitly anymore. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 11:27:47 +00:00
virtual decl_base_sptr
Support reading namespaces * include/abg-fwd.h (get_global_scope): Return a const global_scope. Add a new overload that takes a naked pointer as parm. (insert_decl_into_scope, get_top_most_scope_under): Declare new entry points. * include/abg-ir.h (class decl_base, class scope_decl): Add insert_decl_into_scope as a friend of these classes. (scope_decl::{insert_decl_into_scope, find_iterator_for_member}): Declare new member. (scope_decl::get_member_decls): New non-const overload. * src/abg-dwarf-reader.cc (build_translation_unit): Remove the "recurse" parameter. Adjust the call to build_ir_node_from_die to read just public decls that are at namespace scope. Anything else should be dropped unless it's needed to emitting the public namespace-level decls. (build_namespace_decl_and_add_to_ir) (canonicalize_and_insert_type_into_ir): Define new static functions. (build_corpus): Adjust ad build_translation_unit doesn't have the "recurse" parameter anymore. (canonicalize_and_add_type_to_ir): Make this static. Fix comments. (build_ir_node_from_die): Take a new "only_public_decl" parameter. For DW_TAG_base_type case, use the new canonicalize_and_insert_type_into_ir to insert the type at the right place in the global scope making sure it is seen before the current scope. For pointer, references and qualified types, use canonicalize_and_insert_type_into_ir to add the type at the same scope as its underlying type. Handle DW_TAG_{namespace,module} using the new build_namespace_decl_and_add_to_ir function. Add some vertical spaces and some assertions. * src/abg-ir.cc (scope_decl::add_member_decl): Use scope_decl_sptr typedef. (scope_decl::{insert_member_decl,find_iterator_for_member}): Define new methods. (insert_decl_into_scope, get_top_most_scope_under): Define new functions. (get_global_scope): Constify the return type. (get_translation_unit): Adjust as get_global_scope now returns a const. * src/abg-reader.cc (get_translation_unit): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-12 14:40:52 +00:00
insert_member_decl(const decl_base_sptr member,
declarations::iterator before);
Prune types that are not ref'ed by public decls * include/abg-fwd.h (remove_decl_from_scope): Declare new function. * include/abg-ir.h (type_base_sptr, decl_base_sptr): Move these convenience typedef before the translation_unit declaration. (translation_unit::{mark_type_as_used, prune_unused_types}): Declare new methods. (decl_base::remove_member_decl): Likewise. (class_decl::{remove_member_decl, remove_member_type): Likewise. * src/abg-dwarf-reader.cc (die_decl_map_type): Change this map type so that the value is now a DIE offset, rather than a DIE. This is because many times the lifetime of DIEs is shorter than the one of the reader_context. Also, the die offset uniquely designates a physical DIE even if several different instances of logical DIE might point to it. (struct die_hash): Remove this as it's useless now that we store DIE offsets in the map. (build_translation_unit): Call build_ir_node_from_die w/o setting the called_from_public_decl flag. Prune the types that are not used by any public decls. (build_namespace_decl_and_add_to_ir): all build_ir_node_from_die w/o setting the called_from_public_decl flag. (build_ir_node_from_die): Change the only_public_decl flag into a called_from_public_decl flag. Mark types used by public decls as such. Adjust for the parm changes of build_qualified_type build_pointer_type_def, build_reference_type, and build_typedef_type. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type): Take a new called_from_public_decl. Pass it to build_ir_node_from_die. (build_var_decl): Call build_ir_node_from_die with the called_from_public_decl flag set to true to flag the types referenced by this variable as being used. (build_function_decl): Take a called_from_public_decl flag as well, as this function can now call build_function_decl itself to build a function decl out of the value of the DW_AT_specification attribute, for DIEs representing function definitions. Also, flag the types referenced by public functions are being used. * src/abg-ir.cc (translation_unit::priv::used_types_): New map for the used types. (translation_unit::{mark_type_as_used, prune_unused_types}): Define new methods. (scope_decl::remove_member_decl): Likewise. (remove_decl_from_scope): Define new function. (class_decl::{remove_member_decl, remove_member_type}): Define new methods. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-13 16:30:41 +00:00
virtual void
remove_member_decl(const decl_base_sptr member);
public:
scope_decl(const std::string& name, location locus,
Introduce/use translation_unit & global_scope types * abg-corpus.h (abi_corpus::{get_decls, get_loc_mgr}): Remove. (abi_corpus::add): New function to add a translation unit. (abi_corpus::get_translation_units): New declaration. * abg-corpus.cc (abi_corpus::*): Remove all the definitions of abi_corpus for now, as the abi_corpus type is not used anymore -- for now at least. * src/abg-ir.h (add_decl_to_scope, get_global_scope) (get_translation_unit, is_global_scope, is_decl_at_global_scope) (class translation_unit, class global_scope): New declarations * src/abg-ir.cc (translation_unit::translation_unit) (translation_unit::get_global_scope) (translation_unit::get_loc_mgr, translation_unit::get_loc_mgr) (translation_unit::is_empty, get_global_scope) (get_translation_unit, is_global_scope, is_global_scope) (is_decl_at_global_scope, global_scope::~global_scope): New definitions. (scope_decl::scope_decl, scope_decl::scope_decl) (scope_decl::add_member_decl, scope_decl::get_member_decls): Move to abg-ir.h, inline. * src/abg-reader.h (read_file): Don't use abi_corpus in the api. Rather, use translation_unit. * src/abg-reader.cc (read_context::get_cur_scope): Now that we have a specific instance of global_scope to represent global scope, don't play games with empty scopes to detect a global scope. (read_context::get_translation_unit): New definition. (read_context::finish_decl_creation, finish_type_decl_creation): (read_input, read_file, read_location, handle_element) (handle_type_decl) (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl): Don't use abi_corpus anymore. Rather, the translation unit a decl belongs to is accessible from the decl itself. * src/abg-writer.h (write_to_ostream): Use translation_unit in this API, rather than abi_corpus. * src/abg-writer.cc (write_translation_unit): Rename write_corpus into this. And stop using abi_corpus here. (write_to_ostream, write_corpus, write_location, write_decl) (write_type_decl, write_namespace_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl, write_var_decl): Stop using abi_corpus. Use the translation_unit that is accessible from the decl being serialized, if need be. * test-read-write.cc (main): De-serialize the input into an instance of translation_unit, not an abi_corpus anymore, and serialize that translation_unit.
2013-04-03 12:36:22 +00:00
visibility vis = VISIBILITY_DEFAULT)
: decl_base(name, locus, /*mangled_name=*/name, vis)
{}
scope_decl(location l) : decl_base("", l)
{}
virtual bool
operator==(const decl_base&) const;
const declarations&
Introduce/use translation_unit & global_scope types * abg-corpus.h (abi_corpus::{get_decls, get_loc_mgr}): Remove. (abi_corpus::add): New function to add a translation unit. (abi_corpus::get_translation_units): New declaration. * abg-corpus.cc (abi_corpus::*): Remove all the definitions of abi_corpus for now, as the abi_corpus type is not used anymore -- for now at least. * src/abg-ir.h (add_decl_to_scope, get_global_scope) (get_translation_unit, is_global_scope, is_decl_at_global_scope) (class translation_unit, class global_scope): New declarations * src/abg-ir.cc (translation_unit::translation_unit) (translation_unit::get_global_scope) (translation_unit::get_loc_mgr, translation_unit::get_loc_mgr) (translation_unit::is_empty, get_global_scope) (get_translation_unit, is_global_scope, is_global_scope) (is_decl_at_global_scope, global_scope::~global_scope): New definitions. (scope_decl::scope_decl, scope_decl::scope_decl) (scope_decl::add_member_decl, scope_decl::get_member_decls): Move to abg-ir.h, inline. * src/abg-reader.h (read_file): Don't use abi_corpus in the api. Rather, use translation_unit. * src/abg-reader.cc (read_context::get_cur_scope): Now that we have a specific instance of global_scope to represent global scope, don't play games with empty scopes to detect a global scope. (read_context::get_translation_unit): New definition. (read_context::finish_decl_creation, finish_type_decl_creation): (read_input, read_file, read_location, handle_element) (handle_type_decl) (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl): Don't use abi_corpus anymore. Rather, the translation unit a decl belongs to is accessible from the decl itself. * src/abg-writer.h (write_to_ostream): Use translation_unit in this API, rather than abi_corpus. * src/abg-writer.cc (write_translation_unit): Rename write_corpus into this. And stop using abi_corpus here. (write_to_ostream, write_corpus, write_location, write_decl) (write_type_decl, write_namespace_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl, write_var_decl): Stop using abi_corpus. Use the translation_unit that is accessible from the decl being serialized, if need be. * test-read-write.cc (main): De-serialize the input into an instance of translation_unit, not an abi_corpus anymore, and serialize that translation_unit.
2013-04-03 12:36:22 +00:00
get_member_decls() const
{return members_;}
Introduce/use translation_unit & global_scope types * abg-corpus.h (abi_corpus::{get_decls, get_loc_mgr}): Remove. (abi_corpus::add): New function to add a translation unit. (abi_corpus::get_translation_units): New declaration. * abg-corpus.cc (abi_corpus::*): Remove all the definitions of abi_corpus for now, as the abi_corpus type is not used anymore -- for now at least. * src/abg-ir.h (add_decl_to_scope, get_global_scope) (get_translation_unit, is_global_scope, is_decl_at_global_scope) (class translation_unit, class global_scope): New declarations * src/abg-ir.cc (translation_unit::translation_unit) (translation_unit::get_global_scope) (translation_unit::get_loc_mgr, translation_unit::get_loc_mgr) (translation_unit::is_empty, get_global_scope) (get_translation_unit, is_global_scope, is_global_scope) (is_decl_at_global_scope, global_scope::~global_scope): New definitions. (scope_decl::scope_decl, scope_decl::scope_decl) (scope_decl::add_member_decl, scope_decl::get_member_decls): Move to abg-ir.h, inline. * src/abg-reader.h (read_file): Don't use abi_corpus in the api. Rather, use translation_unit. * src/abg-reader.cc (read_context::get_cur_scope): Now that we have a specific instance of global_scope to represent global scope, don't play games with empty scopes to detect a global scope. (read_context::get_translation_unit): New definition. (read_context::finish_decl_creation, finish_type_decl_creation): (read_input, read_file, read_location, handle_element) (handle_type_decl) (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl): Don't use abi_corpus anymore. Rather, the translation unit a decl belongs to is accessible from the decl itself. * src/abg-writer.h (write_to_ostream): Use translation_unit in this API, rather than abi_corpus. * src/abg-writer.cc (write_translation_unit): Rename write_corpus into this. And stop using abi_corpus here. (write_to_ostream, write_corpus, write_location, write_decl) (write_type_decl, write_namespace_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl, write_var_decl): Stop using abi_corpus. Use the translation_unit that is accessible from the decl being serialized, if need be. * test-read-write.cc (main): De-serialize the input into an instance of translation_unit, not an abi_corpus anymore, and serialize that translation_unit.
2013-04-03 12:36:22 +00:00
Support reading namespaces * include/abg-fwd.h (get_global_scope): Return a const global_scope. Add a new overload that takes a naked pointer as parm. (insert_decl_into_scope, get_top_most_scope_under): Declare new entry points. * include/abg-ir.h (class decl_base, class scope_decl): Add insert_decl_into_scope as a friend of these classes. (scope_decl::{insert_decl_into_scope, find_iterator_for_member}): Declare new member. (scope_decl::get_member_decls): New non-const overload. * src/abg-dwarf-reader.cc (build_translation_unit): Remove the "recurse" parameter. Adjust the call to build_ir_node_from_die to read just public decls that are at namespace scope. Anything else should be dropped unless it's needed to emitting the public namespace-level decls. (build_namespace_decl_and_add_to_ir) (canonicalize_and_insert_type_into_ir): Define new static functions. (build_corpus): Adjust ad build_translation_unit doesn't have the "recurse" parameter anymore. (canonicalize_and_add_type_to_ir): Make this static. Fix comments. (build_ir_node_from_die): Take a new "only_public_decl" parameter. For DW_TAG_base_type case, use the new canonicalize_and_insert_type_into_ir to insert the type at the right place in the global scope making sure it is seen before the current scope. For pointer, references and qualified types, use canonicalize_and_insert_type_into_ir to add the type at the same scope as its underlying type. Handle DW_TAG_{namespace,module} using the new build_namespace_decl_and_add_to_ir function. Add some vertical spaces and some assertions. * src/abg-ir.cc (scope_decl::add_member_decl): Use scope_decl_sptr typedef. (scope_decl::{insert_member_decl,find_iterator_for_member}): Define new methods. (insert_decl_into_scope, get_top_most_scope_under): Define new functions. (get_global_scope): Constify the return type. (get_translation_unit): Adjust as get_global_scope now returns a const. * src/abg-reader.cc (get_translation_unit): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-12 14:40:52 +00:00
declarations&
get_member_decls()
{return members_;}
scopes&
get_member_scopes()
{return member_scopes_;}
Introduce/use translation_unit & global_scope types * abg-corpus.h (abi_corpus::{get_decls, get_loc_mgr}): Remove. (abi_corpus::add): New function to add a translation unit. (abi_corpus::get_translation_units): New declaration. * abg-corpus.cc (abi_corpus::*): Remove all the definitions of abi_corpus for now, as the abi_corpus type is not used anymore -- for now at least. * src/abg-ir.h (add_decl_to_scope, get_global_scope) (get_translation_unit, is_global_scope, is_decl_at_global_scope) (class translation_unit, class global_scope): New declarations * src/abg-ir.cc (translation_unit::translation_unit) (translation_unit::get_global_scope) (translation_unit::get_loc_mgr, translation_unit::get_loc_mgr) (translation_unit::is_empty, get_global_scope) (get_translation_unit, is_global_scope, is_global_scope) (is_decl_at_global_scope, global_scope::~global_scope): New definitions. (scope_decl::scope_decl, scope_decl::scope_decl) (scope_decl::add_member_decl, scope_decl::get_member_decls): Move to abg-ir.h, inline. * src/abg-reader.h (read_file): Don't use abi_corpus in the api. Rather, use translation_unit. * src/abg-reader.cc (read_context::get_cur_scope): Now that we have a specific instance of global_scope to represent global scope, don't play games with empty scopes to detect a global scope. (read_context::get_translation_unit): New definition. (read_context::finish_decl_creation, finish_type_decl_creation): (read_input, read_file, read_location, handle_element) (handle_type_decl) (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl): Don't use abi_corpus anymore. Rather, the translation unit a decl belongs to is accessible from the decl itself. * src/abg-writer.h (write_to_ostream): Use translation_unit in this API, rather than abi_corpus. * src/abg-writer.cc (write_translation_unit): Rename write_corpus into this. And stop using abi_corpus here. (write_to_ostream, write_corpus, write_location, write_decl) (write_type_decl, write_namespace_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl, write_var_decl): Stop using abi_corpus. Use the translation_unit that is accessible from the decl being serialized, if need be. * test-read-write.cc (main): De-serialize the input into an instance of translation_unit, not an abi_corpus anymore, and serialize that translation_unit.
2013-04-03 12:36:22 +00:00
bool
is_empty() const
{return get_member_decls().empty();}
Support reading namespaces * include/abg-fwd.h (get_global_scope): Return a const global_scope. Add a new overload that takes a naked pointer as parm. (insert_decl_into_scope, get_top_most_scope_under): Declare new entry points. * include/abg-ir.h (class decl_base, class scope_decl): Add insert_decl_into_scope as a friend of these classes. (scope_decl::{insert_decl_into_scope, find_iterator_for_member}): Declare new member. (scope_decl::get_member_decls): New non-const overload. * src/abg-dwarf-reader.cc (build_translation_unit): Remove the "recurse" parameter. Adjust the call to build_ir_node_from_die to read just public decls that are at namespace scope. Anything else should be dropped unless it's needed to emitting the public namespace-level decls. (build_namespace_decl_and_add_to_ir) (canonicalize_and_insert_type_into_ir): Define new static functions. (build_corpus): Adjust ad build_translation_unit doesn't have the "recurse" parameter anymore. (canonicalize_and_add_type_to_ir): Make this static. Fix comments. (build_ir_node_from_die): Take a new "only_public_decl" parameter. For DW_TAG_base_type case, use the new canonicalize_and_insert_type_into_ir to insert the type at the right place in the global scope making sure it is seen before the current scope. For pointer, references and qualified types, use canonicalize_and_insert_type_into_ir to add the type at the same scope as its underlying type. Handle DW_TAG_{namespace,module} using the new build_namespace_decl_and_add_to_ir function. Add some vertical spaces and some assertions. * src/abg-ir.cc (scope_decl::add_member_decl): Use scope_decl_sptr typedef. (scope_decl::{insert_member_decl,find_iterator_for_member}): Define new methods. (insert_decl_into_scope, get_top_most_scope_under): Define new functions. (get_global_scope): Constify the return type. (get_translation_unit): Adjust as get_global_scope now returns a const. * src/abg-reader.cc (get_translation_unit): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-12 14:40:52 +00:00
bool
find_iterator_for_member(const decl_base*, declarations::iterator&);
bool
find_iterator_for_member(const decl_base_sptr, declarations::iterator&);
virtual void
traverse(ir_node_visitor&);
virtual ~scope_decl();
Fix class scope setting & member type de-serializing from dwarf * include/abg-fwd.h (add_decl_to_scope, insert_decl_into_scope): return the decl added to the scope. (as_non_member_type, get_type_declaration): Declare new entry points. * include/abg-ir.h (class decl_base::insert_decl_into_scope): Update this friend declaration. (class scope_decl, class_decl): Update the friend add_decl_to_scope declaration. (scope_decl::add_member_decl): Return the added decl. (class_decl_sptr): Move this typedef befoer the class_decl class declaration. (class_decl::definition_of_declaration_): New member. (class_decl::{set_definition_of_declaration, get_definition_of_declaration}): New accessors. (class_decl::add_member_decl): Return the added member. (class_decl::insert_member_type): New member. (class_decl::member_base::access_specifier): Make this protected. (class_decl::member_type): Make this inherit from type_vase. (class_decl::member_type::type_): Remove this member. (class_decl::member_type::as_type): Remove this accessor. (class_decl::member_type::operator==(const type_base&)): New. (class_decl::member_type::operator shared_ptr<type_base>() const): Remove. (class_decl::member_type::get_underlying_type): New. (class_decl::member_type::operator==(const member_type&) const): New. * src/abg-comparison.cc (class_diff::{ensure_lookup_tables_populated, report}): Adjust for the removal of class_decl::member_type::as_type. * src/abg-dwarf-reader.cc (scope_stack_type): Change this as a typedef to stack<scope_decl*>. (current_scope): Change return type from scope_decl_sptr to scope_decl*. (insert_decl_into_scope): New. (build_namespace_decl_and_add_to_ir): Use insert_decl_into_scope in lieu of add_decl_to_scope. (build_class_type_and_add_to_ir): likewise. Link a class definition to its declaration. Push the current scope on the scope stack. Use as_non_member_type. Fix setting member types. (get_scope_for_die): Look through declaration-only classe to get its definition. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type, build_var_decl) (build_function_decl): Use as_non_member_type. (build_ir_node_from_die): Fix member variable & function adding. * src/abg-ir.cc (scope_decl::{add_member_decl, insert_member_decl}): Return the added member. (add_decl_to_scope): Likewise. (insert_decl_into_scope): Likewise. (get_top_most_scope_under): Fix logic. (get_type_declaration): New overload that return a decl_base*. (as_non_member_type): New definition. (class_decl::{get_definition_of_declaration, set_definition_of_declaration, insert_member_decl}): Likewise. (class_decl::add_member_decl): Re-write in terms of class::insert_member_decl. (class_decl::insert_member_type): New definition. (class_decl::add_member_type): Re-write in terms of class_decl::insert_member_type. (class_decl::remove_member_type): Update for the class_decl::member_type::as_type removal. (class_decl::{add_data_member, add_member_function, add_member_function_template, add_member_class_template}): Call scope_decl::add_member_decl. (class_decl::member_type::member_type): Update as the type now virtually inherits from type_base. (class_decl::member_type::{set,get}_access_specifier): New definitions. (class_decl::member_type::get_underlying_type): Likewise. (class_decl::member_type::set_scope): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. (class_decl::member_type::operator==(const decl_base& other)): There is no more class_decl::member_type::as_type. (class_decl::member_type::operator==(const type_base& other)): New. (class_decl::member_type::get_pretty_representation): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. * src/abg-reader.cc (build_class_decl): New that add add_member_decl adds even member types, no need to add it explicitly anymore. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 11:27:47 +00:00
friend decl_base_sptr
add_decl_to_scope(decl_base_sptr dcl, scope_decl* scpe);
Support reading namespaces * include/abg-fwd.h (get_global_scope): Return a const global_scope. Add a new overload that takes a naked pointer as parm. (insert_decl_into_scope, get_top_most_scope_under): Declare new entry points. * include/abg-ir.h (class decl_base, class scope_decl): Add insert_decl_into_scope as a friend of these classes. (scope_decl::{insert_decl_into_scope, find_iterator_for_member}): Declare new member. (scope_decl::get_member_decls): New non-const overload. * src/abg-dwarf-reader.cc (build_translation_unit): Remove the "recurse" parameter. Adjust the call to build_ir_node_from_die to read just public decls that are at namespace scope. Anything else should be dropped unless it's needed to emitting the public namespace-level decls. (build_namespace_decl_and_add_to_ir) (canonicalize_and_insert_type_into_ir): Define new static functions. (build_corpus): Adjust ad build_translation_unit doesn't have the "recurse" parameter anymore. (canonicalize_and_add_type_to_ir): Make this static. Fix comments. (build_ir_node_from_die): Take a new "only_public_decl" parameter. For DW_TAG_base_type case, use the new canonicalize_and_insert_type_into_ir to insert the type at the right place in the global scope making sure it is seen before the current scope. For pointer, references and qualified types, use canonicalize_and_insert_type_into_ir to add the type at the same scope as its underlying type. Handle DW_TAG_{namespace,module} using the new build_namespace_decl_and_add_to_ir function. Add some vertical spaces and some assertions. * src/abg-ir.cc (scope_decl::add_member_decl): Use scope_decl_sptr typedef. (scope_decl::{insert_member_decl,find_iterator_for_member}): Define new methods. (insert_decl_into_scope, get_top_most_scope_under): Define new functions. (get_global_scope): Constify the return type. (get_translation_unit): Adjust as get_global_scope now returns a const. * src/abg-reader.cc (get_translation_unit): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-12 14:40:52 +00:00
Fix class scope setting & member type de-serializing from dwarf * include/abg-fwd.h (add_decl_to_scope, insert_decl_into_scope): return the decl added to the scope. (as_non_member_type, get_type_declaration): Declare new entry points. * include/abg-ir.h (class decl_base::insert_decl_into_scope): Update this friend declaration. (class scope_decl, class_decl): Update the friend add_decl_to_scope declaration. (scope_decl::add_member_decl): Return the added decl. (class_decl_sptr): Move this typedef befoer the class_decl class declaration. (class_decl::definition_of_declaration_): New member. (class_decl::{set_definition_of_declaration, get_definition_of_declaration}): New accessors. (class_decl::add_member_decl): Return the added member. (class_decl::insert_member_type): New member. (class_decl::member_base::access_specifier): Make this protected. (class_decl::member_type): Make this inherit from type_vase. (class_decl::member_type::type_): Remove this member. (class_decl::member_type::as_type): Remove this accessor. (class_decl::member_type::operator==(const type_base&)): New. (class_decl::member_type::operator shared_ptr<type_base>() const): Remove. (class_decl::member_type::get_underlying_type): New. (class_decl::member_type::operator==(const member_type&) const): New. * src/abg-comparison.cc (class_diff::{ensure_lookup_tables_populated, report}): Adjust for the removal of class_decl::member_type::as_type. * src/abg-dwarf-reader.cc (scope_stack_type): Change this as a typedef to stack<scope_decl*>. (current_scope): Change return type from scope_decl_sptr to scope_decl*. (insert_decl_into_scope): New. (build_namespace_decl_and_add_to_ir): Use insert_decl_into_scope in lieu of add_decl_to_scope. (build_class_type_and_add_to_ir): likewise. Link a class definition to its declaration. Push the current scope on the scope stack. Use as_non_member_type. Fix setting member types. (get_scope_for_die): Look through declaration-only classe to get its definition. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type, build_var_decl) (build_function_decl): Use as_non_member_type. (build_ir_node_from_die): Fix member variable & function adding. * src/abg-ir.cc (scope_decl::{add_member_decl, insert_member_decl}): Return the added member. (add_decl_to_scope): Likewise. (insert_decl_into_scope): Likewise. (get_top_most_scope_under): Fix logic. (get_type_declaration): New overload that return a decl_base*. (as_non_member_type): New definition. (class_decl::{get_definition_of_declaration, set_definition_of_declaration, insert_member_decl}): Likewise. (class_decl::add_member_decl): Re-write in terms of class::insert_member_decl. (class_decl::insert_member_type): New definition. (class_decl::add_member_type): Re-write in terms of class_decl::insert_member_type. (class_decl::remove_member_type): Update for the class_decl::member_type::as_type removal. (class_decl::{add_data_member, add_member_function, add_member_function_template, add_member_class_template}): Call scope_decl::add_member_decl. (class_decl::member_type::member_type): Update as the type now virtually inherits from type_base. (class_decl::member_type::{set,get}_access_specifier): New definitions. (class_decl::member_type::get_underlying_type): Likewise. (class_decl::member_type::set_scope): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. (class_decl::member_type::operator==(const decl_base& other)): There is no more class_decl::member_type::as_type. (class_decl::member_type::operator==(const type_base& other)): New. (class_decl::member_type::get_pretty_representation): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. * src/abg-reader.cc (build_class_decl): New that add add_member_decl adds even member types, no need to add it explicitly anymore. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 11:27:47 +00:00
friend decl_base_sptr
Support reading namespaces * include/abg-fwd.h (get_global_scope): Return a const global_scope. Add a new overload that takes a naked pointer as parm. (insert_decl_into_scope, get_top_most_scope_under): Declare new entry points. * include/abg-ir.h (class decl_base, class scope_decl): Add insert_decl_into_scope as a friend of these classes. (scope_decl::{insert_decl_into_scope, find_iterator_for_member}): Declare new member. (scope_decl::get_member_decls): New non-const overload. * src/abg-dwarf-reader.cc (build_translation_unit): Remove the "recurse" parameter. Adjust the call to build_ir_node_from_die to read just public decls that are at namespace scope. Anything else should be dropped unless it's needed to emitting the public namespace-level decls. (build_namespace_decl_and_add_to_ir) (canonicalize_and_insert_type_into_ir): Define new static functions. (build_corpus): Adjust ad build_translation_unit doesn't have the "recurse" parameter anymore. (canonicalize_and_add_type_to_ir): Make this static. Fix comments. (build_ir_node_from_die): Take a new "only_public_decl" parameter. For DW_TAG_base_type case, use the new canonicalize_and_insert_type_into_ir to insert the type at the right place in the global scope making sure it is seen before the current scope. For pointer, references and qualified types, use canonicalize_and_insert_type_into_ir to add the type at the same scope as its underlying type. Handle DW_TAG_{namespace,module} using the new build_namespace_decl_and_add_to_ir function. Add some vertical spaces and some assertions. * src/abg-ir.cc (scope_decl::add_member_decl): Use scope_decl_sptr typedef. (scope_decl::{insert_member_decl,find_iterator_for_member}): Define new methods. (insert_decl_into_scope, get_top_most_scope_under): Define new functions. (get_global_scope): Constify the return type. (get_translation_unit): Adjust as get_global_scope now returns a const. * src/abg-reader.cc (get_translation_unit): Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-12 14:40:52 +00:00
insert_decl_into_scope(decl_base_sptr decl,
scope_decl::declarations::iterator before,
scope_decl* scope);
Prune types that are not ref'ed by public decls * include/abg-fwd.h (remove_decl_from_scope): Declare new function. * include/abg-ir.h (type_base_sptr, decl_base_sptr): Move these convenience typedef before the translation_unit declaration. (translation_unit::{mark_type_as_used, prune_unused_types}): Declare new methods. (decl_base::remove_member_decl): Likewise. (class_decl::{remove_member_decl, remove_member_type): Likewise. * src/abg-dwarf-reader.cc (die_decl_map_type): Change this map type so that the value is now a DIE offset, rather than a DIE. This is because many times the lifetime of DIEs is shorter than the one of the reader_context. Also, the die offset uniquely designates a physical DIE even if several different instances of logical DIE might point to it. (struct die_hash): Remove this as it's useless now that we store DIE offsets in the map. (build_translation_unit): Call build_ir_node_from_die w/o setting the called_from_public_decl flag. Prune the types that are not used by any public decls. (build_namespace_decl_and_add_to_ir): all build_ir_node_from_die w/o setting the called_from_public_decl flag. (build_ir_node_from_die): Change the only_public_decl flag into a called_from_public_decl flag. Mark types used by public decls as such. Adjust for the parm changes of build_qualified_type build_pointer_type_def, build_reference_type, and build_typedef_type. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type): Take a new called_from_public_decl. Pass it to build_ir_node_from_die. (build_var_decl): Call build_ir_node_from_die with the called_from_public_decl flag set to true to flag the types referenced by this variable as being used. (build_function_decl): Take a called_from_public_decl flag as well, as this function can now call build_function_decl itself to build a function decl out of the value of the DW_AT_specification attribute, for DIEs representing function definitions. Also, flag the types referenced by public functions are being used. * src/abg-ir.cc (translation_unit::priv::used_types_): New map for the used types. (translation_unit::{mark_type_as_used, prune_unused_types}): Define new methods. (scope_decl::remove_member_decl): Likewise. (remove_decl_from_scope): Define new function. (class_decl::{remove_member_decl, remove_member_type}): Define new methods. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-13 16:30:41 +00:00
friend void
remove_decl_from_scope(decl_base_sptr decl);
};//end class scope_decl
/// Convenience typedef for shared pointer on @ref global_scope.
typedef shared_ptr<global_scope> global_scope_sptr;
Introduce/use translation_unit & global_scope types * abg-corpus.h (abi_corpus::{get_decls, get_loc_mgr}): Remove. (abi_corpus::add): New function to add a translation unit. (abi_corpus::get_translation_units): New declaration. * abg-corpus.cc (abi_corpus::*): Remove all the definitions of abi_corpus for now, as the abi_corpus type is not used anymore -- for now at least. * src/abg-ir.h (add_decl_to_scope, get_global_scope) (get_translation_unit, is_global_scope, is_decl_at_global_scope) (class translation_unit, class global_scope): New declarations * src/abg-ir.cc (translation_unit::translation_unit) (translation_unit::get_global_scope) (translation_unit::get_loc_mgr, translation_unit::get_loc_mgr) (translation_unit::is_empty, get_global_scope) (get_translation_unit, is_global_scope, is_global_scope) (is_decl_at_global_scope, global_scope::~global_scope): New definitions. (scope_decl::scope_decl, scope_decl::scope_decl) (scope_decl::add_member_decl, scope_decl::get_member_decls): Move to abg-ir.h, inline. * src/abg-reader.h (read_file): Don't use abi_corpus in the api. Rather, use translation_unit. * src/abg-reader.cc (read_context::get_cur_scope): Now that we have a specific instance of global_scope to represent global scope, don't play games with empty scopes to detect a global scope. (read_context::get_translation_unit): New definition. (read_context::finish_decl_creation, finish_type_decl_creation): (read_input, read_file, read_location, handle_element) (handle_type_decl) (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl): Don't use abi_corpus anymore. Rather, the translation unit a decl belongs to is accessible from the decl itself. * src/abg-writer.h (write_to_ostream): Use translation_unit in this API, rather than abi_corpus. * src/abg-writer.cc (write_translation_unit): Rename write_corpus into this. And stop using abi_corpus here. (write_to_ostream, write_corpus, write_location, write_decl) (write_type_decl, write_namespace_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl, write_var_decl): Stop using abi_corpus. Use the translation_unit that is accessible from the decl being serialized, if need be. * test-read-write.cc (main): De-serialize the input into an instance of translation_unit, not an abi_corpus anymore, and serialize that translation_unit.
2013-04-03 12:36:22 +00:00
/// This abstracts the global scope of a given translation unit.
///
/// Only one instance of this class must be present in a given
/// translation_unit. That instance is implicitely created the first
/// time translatin_unit::get_global_scope is invoked.
class global_scope : public scope_decl
{
translation_unit* translation_unit_;
global_scope(translation_unit *tu)
: decl_base("", location()), scope_decl("", location()),
translation_unit_(tu)
{}
Introduce/use translation_unit & global_scope types * abg-corpus.h (abi_corpus::{get_decls, get_loc_mgr}): Remove. (abi_corpus::add): New function to add a translation unit. (abi_corpus::get_translation_units): New declaration. * abg-corpus.cc (abi_corpus::*): Remove all the definitions of abi_corpus for now, as the abi_corpus type is not used anymore -- for now at least. * src/abg-ir.h (add_decl_to_scope, get_global_scope) (get_translation_unit, is_global_scope, is_decl_at_global_scope) (class translation_unit, class global_scope): New declarations * src/abg-ir.cc (translation_unit::translation_unit) (translation_unit::get_global_scope) (translation_unit::get_loc_mgr, translation_unit::get_loc_mgr) (translation_unit::is_empty, get_global_scope) (get_translation_unit, is_global_scope, is_global_scope) (is_decl_at_global_scope, global_scope::~global_scope): New definitions. (scope_decl::scope_decl, scope_decl::scope_decl) (scope_decl::add_member_decl, scope_decl::get_member_decls): Move to abg-ir.h, inline. * src/abg-reader.h (read_file): Don't use abi_corpus in the api. Rather, use translation_unit. * src/abg-reader.cc (read_context::get_cur_scope): Now that we have a specific instance of global_scope to represent global scope, don't play games with empty scopes to detect a global scope. (read_context::get_translation_unit): New definition. (read_context::finish_decl_creation, finish_type_decl_creation): (read_input, read_file, read_location, handle_element) (handle_type_decl) (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl): Don't use abi_corpus anymore. Rather, the translation unit a decl belongs to is accessible from the decl itself. * src/abg-writer.h (write_to_ostream): Use translation_unit in this API, rather than abi_corpus. * src/abg-writer.cc (write_translation_unit): Rename write_corpus into this. And stop using abi_corpus here. (write_to_ostream, write_corpus, write_location, write_decl) (write_type_decl, write_namespace_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl, write_var_decl): Stop using abi_corpus. Use the translation_unit that is accessible from the decl being serialized, if need be. * test-read-write.cc (main): De-serialize the input into an instance of translation_unit, not an abi_corpus anymore, and serialize that translation_unit.
2013-04-03 12:36:22 +00:00
public:
friend class translation_unit;
translation_unit*
get_translation_unit() const
{return translation_unit_;}
Introduce/use translation_unit & global_scope types * abg-corpus.h (abi_corpus::{get_decls, get_loc_mgr}): Remove. (abi_corpus::add): New function to add a translation unit. (abi_corpus::get_translation_units): New declaration. * abg-corpus.cc (abi_corpus::*): Remove all the definitions of abi_corpus for now, as the abi_corpus type is not used anymore -- for now at least. * src/abg-ir.h (add_decl_to_scope, get_global_scope) (get_translation_unit, is_global_scope, is_decl_at_global_scope) (class translation_unit, class global_scope): New declarations * src/abg-ir.cc (translation_unit::translation_unit) (translation_unit::get_global_scope) (translation_unit::get_loc_mgr, translation_unit::get_loc_mgr) (translation_unit::is_empty, get_global_scope) (get_translation_unit, is_global_scope, is_global_scope) (is_decl_at_global_scope, global_scope::~global_scope): New definitions. (scope_decl::scope_decl, scope_decl::scope_decl) (scope_decl::add_member_decl, scope_decl::get_member_decls): Move to abg-ir.h, inline. * src/abg-reader.h (read_file): Don't use abi_corpus in the api. Rather, use translation_unit. * src/abg-reader.cc (read_context::get_cur_scope): Now that we have a specific instance of global_scope to represent global scope, don't play games with empty scopes to detect a global scope. (read_context::get_translation_unit): New definition. (read_context::finish_decl_creation, finish_type_decl_creation): (read_input, read_file, read_location, handle_element) (handle_type_decl) (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl): Don't use abi_corpus anymore. Rather, the translation unit a decl belongs to is accessible from the decl itself. * src/abg-writer.h (write_to_ostream): Use translation_unit in this API, rather than abi_corpus. * src/abg-writer.cc (write_translation_unit): Rename write_corpus into this. And stop using abi_corpus here. (write_to_ostream, write_corpus, write_location, write_decl) (write_type_decl, write_namespace_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl, write_var_decl): Stop using abi_corpus. Use the translation_unit that is accessible from the decl being serialized, if need be. * test-read-write.cc (main): De-serialize the input into an instance of translation_unit, not an abi_corpus anymore, and serialize that translation_unit.
2013-04-03 12:36:22 +00:00
virtual ~global_scope();
};
Introduce/use translation_unit & global_scope types * abg-corpus.h (abi_corpus::{get_decls, get_loc_mgr}): Remove. (abi_corpus::add): New function to add a translation unit. (abi_corpus::get_translation_units): New declaration. * abg-corpus.cc (abi_corpus::*): Remove all the definitions of abi_corpus for now, as the abi_corpus type is not used anymore -- for now at least. * src/abg-ir.h (add_decl_to_scope, get_global_scope) (get_translation_unit, is_global_scope, is_decl_at_global_scope) (class translation_unit, class global_scope): New declarations * src/abg-ir.cc (translation_unit::translation_unit) (translation_unit::get_global_scope) (translation_unit::get_loc_mgr, translation_unit::get_loc_mgr) (translation_unit::is_empty, get_global_scope) (get_translation_unit, is_global_scope, is_global_scope) (is_decl_at_global_scope, global_scope::~global_scope): New definitions. (scope_decl::scope_decl, scope_decl::scope_decl) (scope_decl::add_member_decl, scope_decl::get_member_decls): Move to abg-ir.h, inline. * src/abg-reader.h (read_file): Don't use abi_corpus in the api. Rather, use translation_unit. * src/abg-reader.cc (read_context::get_cur_scope): Now that we have a specific instance of global_scope to represent global scope, don't play games with empty scopes to detect a global scope. (read_context::get_translation_unit): New definition. (read_context::finish_decl_creation, finish_type_decl_creation): (read_input, read_file, read_location, handle_element) (handle_type_decl) (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl): Don't use abi_corpus anymore. Rather, the translation unit a decl belongs to is accessible from the decl itself. * src/abg-writer.h (write_to_ostream): Use translation_unit in this API, rather than abi_corpus. * src/abg-writer.cc (write_translation_unit): Rename write_corpus into this. And stop using abi_corpus here. (write_to_ostream, write_corpus, write_location, write_decl) (write_type_decl, write_namespace_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl, write_var_decl): Stop using abi_corpus. Use the translation_unit that is accessible from the decl being serialized, if need be. * test-read-write.cc (main): De-serialize the input into an instance of translation_unit, not an abi_corpus anymore, and serialize that translation_unit.
2013-04-03 12:36:22 +00:00
/// An abstraction helper for type declarations
class type_base
{
size_t size_in_bits_;
size_t alignment_in_bits_;
// Forbid this.
type_base();
public:
/// A hasher for type_base types.
struct hash;
/// A hasher for types. It gets the dynamic type of the current
/// instance of type and hashes it accordingly. Note that the hashing
/// function of this hasher must be updated each time a new kind of
/// type is added to the IR.
struct dynamic_hash;
/// A hasher for shared_ptr<type_base> that will hash it based on the
/// runtime type of the type pointed to.
struct shared_ptr_hash;
Implement hash caching * include/abg-ir.h (decl_base::hash_): New member. (decl_base::{g,s}et_hash): New accessors. (type_base_::cached_hash): Forward-declare new hasher. (struct type_ptr_equal): New equality predicate. (type_shared_ptr_equal::operator()): Do not forget to test pointer equality. (type_base::cached_hash): Declare new hasher. * src/abg-hash.cc ({decl_base, type_decl, scope_type_decl, qualified_type_def, pointer_type_def, reference_type_def, enum_type_decl, typedef_decl, var_decl, function_decl, function_decl::parameter, class_decl::data_member, class_decl::member_function, class_decl, }::hash::operator()): Implement caching. (type_base::cached_hash::operator()(const type_base*)): Define. (type_base::cached_hash::operator() (const type_base_sptr): Define. * src/abg-ir.cc (type_ptr_map): Make this map use type_base::cached_hash instead of type_base::ptr_hash now. (decl_base::decl_base): Initialize the new decl_base::hash_. member. (decl_base::{s,g}et_hash): Define. (decl_base::operator==(const decl_base& other)): Take the hash in account to speed up inequality detection. * src/abg-writer.cc (type_ptr_map): Renamed type_shared_ptr_map into this. Make it use type_base::cached_hash and type_ptr_equal instead of type_base::shared_ptr_hash and type_shared_ptr_equal. (get_id_for_type): Add overload for type_base*. Re-write the previous overload in terms of this one. (write_context::m_type_id_map): Use type_ptr_map as the type for this. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 15:02:46 +00:00
struct cached_hash;
type_base(size_t s, size_t a);
virtual bool
operator==(const type_base&) const;
virtual ~type_base();
void
set_size_in_bits(size_t);
size_t
get_size_in_bits() const;
void
set_alignment_in_bits(size_t);
size_t
get_alignment_in_bits() const;
};//end class type_base
Support qualified types & Misc ancillary fixes * src/abg-ir.h (struct type_base_hash, struct dynamic_type_hash) (struct type_shared_ptr_hash, struct scope_type_decl_hash, class qualified_type_def, struct qualified_type_def_hash): New. (decl_base_hash::operator()): Constify. Don't crash if the scope of the decl we are hashing is null. (class type_decl): Add comment at the end. (type_decl_hash::operator()): Constify. Reuse the new type_base_hash hasher. (class namespace_decl): Add comment. * src/abg-ir.cc (qualified_type_def::qualified_type_def) (qualified_type_def::~qualified_type_def) (qualified_type_def::get_cv_quals) (qualified_type_def::set_cv_quals) (qualified_type_def::get_underlying_type) (dynamic_type_hash::operator()): New function definitions. * src/abg-reader.cc (handle_qualified_type_decl): New. (read_file): Handle elements named "qualified-type-def". (read::context::add_type_decl): Assert that the type being associated to the unique ID is non-null. (handle_type_decl): Fix this in the process; don't crash if some attributes are not present. Associate the unique id present in the xml document with the type we just parsed. (handle_namespace_decl): Add some comments. Don't crash if the name attribute is not present. * src/abg-writer.cc (write_context::get_id_for_type) (write_context::m_type_id_map, write_decl_location) (write_qualified_type_def): New. (write_decl): Handle instances of qualified_type_def. (write_type_decl): Use the new write_decl_location and write_context::get_id_for_type. * tests/data/test-read-write/test0.xml: Update id format since we are now using the new write_context::get_id_for_type to generate it. * tests/data/test-read-write/test1.xml: Likewise. * tests/data/test-read-write/test2.xml: Likewise. * tests/data/test-read-write/test3.xml: New test. * tests/test-read-write.cc: Test De-serializing tests/data/test-read-write/test3.xml and serializing it back. Also don't bail out if we fail on one input. * tests/Makefile.am: Add tests/data/test-read-write/test3.xml to the distribution.
2013-03-27 22:34:07 +00:00
Implement hash caching * include/abg-ir.h (decl_base::hash_): New member. (decl_base::{g,s}et_hash): New accessors. (type_base_::cached_hash): Forward-declare new hasher. (struct type_ptr_equal): New equality predicate. (type_shared_ptr_equal::operator()): Do not forget to test pointer equality. (type_base::cached_hash): Declare new hasher. * src/abg-hash.cc ({decl_base, type_decl, scope_type_decl, qualified_type_def, pointer_type_def, reference_type_def, enum_type_decl, typedef_decl, var_decl, function_decl, function_decl::parameter, class_decl::data_member, class_decl::member_function, class_decl, }::hash::operator()): Implement caching. (type_base::cached_hash::operator()(const type_base*)): Define. (type_base::cached_hash::operator() (const type_base_sptr): Define. * src/abg-ir.cc (type_ptr_map): Make this map use type_base::cached_hash instead of type_base::ptr_hash now. (decl_base::decl_base): Initialize the new decl_base::hash_. member. (decl_base::{s,g}et_hash): Define. (decl_base::operator==(const decl_base& other)): Take the hash in account to speed up inequality detection. * src/abg-writer.cc (type_ptr_map): Renamed type_shared_ptr_map into this. Make it use type_base::cached_hash and type_ptr_equal instead of type_base::shared_ptr_hash and type_shared_ptr_equal. (get_id_for_type): Add overload for type_base*. Re-write the previous overload in terms of this one. (write_context::m_type_id_map): Use type_ptr_map as the type for this. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 15:02:46 +00:00
/// A predicate for deep equality of instances of
/// type_base*
struct type_ptr_equal
{
bool
operator()(const type_base* l, const type_base* r) const
{
if (!!l != !!r)
return false;
if (l == r)
return true;
if (l)
return *l == *r;
return true;
}
};
/// A predicate for deep equality of instances of
/// shared_ptr<type_base>
struct type_shared_ptr_equal
{
bool
operator()(const type_base_sptr l, const type_base_sptr r) const
{
Fix IR node comparison bugs * include/abg-ir.h (type_shared_ptr_equal::operator()): Fix thinko in checking for the boolean value of the pointers to types. * src/abg-ir.cc (type_decl::operator==(const decl_base&)): Do not forget to compare the decl_base part of the type too. (type_decl::operator==(const type_base&)): To ease maintenance, re-use the equality operator that takes a decl_base. (scope_type_decl::operator==(const type_base&)): Likewise. (qualified_type_def::operator==(const type_base&)): Likewise. (compare_function_types): New sub-routine to compare function types. It fixes an infinite recursion when comparing two methods of the same class. (function_type::operator==(const type_base&)): Use the new compare_function_types function. (class_decl::operator==(const decl_base&)): Fix a thinko in the first test of the function. Use a dedicated scope for each class section comparison; that way, there won't be any chance to misuse the variables pertaining to a different section. Fix the member function sections; we were mistakenly using the variables for the *data* section there. (class_decl::operator==(const type_base&)): Re-use the operator that takes a decl_base. (class_decl::operator==(const class_decl&)): Don't remove const-ness during the static cast. (class_decl::member_function::operator==(const member_function&)): Do not remove the reference from the static cast. (class_decl::member_class_template::operator==(const member_base&)): Likewise. (type_tparameter::operator==(const template_parameter&)): Likewise. (template_tparameter::operator==(const template_parameter&)): Likewise. (function_tdecl::operator==(const template_decl&)): Likewise. (class_tdecl::operator==(const template_decl&)): Likewise. (class_tdecl::operator==(const class_tdecl&)): Likewise. * tests/data/test-read-write/test12.xml: Update this because the test now correctly considers two type template parameters at the same index as being equivalent. * tests/data/test-read-write/test13.xml: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-16 15:39:40 +00:00
if (!!l != !!r)
return false;
Implement hash caching * include/abg-ir.h (decl_base::hash_): New member. (decl_base::{g,s}et_hash): New accessors. (type_base_::cached_hash): Forward-declare new hasher. (struct type_ptr_equal): New equality predicate. (type_shared_ptr_equal::operator()): Do not forget to test pointer equality. (type_base::cached_hash): Declare new hasher. * src/abg-hash.cc ({decl_base, type_decl, scope_type_decl, qualified_type_def, pointer_type_def, reference_type_def, enum_type_decl, typedef_decl, var_decl, function_decl, function_decl::parameter, class_decl::data_member, class_decl::member_function, class_decl, }::hash::operator()): Implement caching. (type_base::cached_hash::operator()(const type_base*)): Define. (type_base::cached_hash::operator() (const type_base_sptr): Define. * src/abg-ir.cc (type_ptr_map): Make this map use type_base::cached_hash instead of type_base::ptr_hash now. (decl_base::decl_base): Initialize the new decl_base::hash_. member. (decl_base::{s,g}et_hash): Define. (decl_base::operator==(const decl_base& other)): Take the hash in account to speed up inequality detection. * src/abg-writer.cc (type_ptr_map): Renamed type_shared_ptr_map into this. Make it use type_base::cached_hash and type_ptr_equal instead of type_base::shared_ptr_hash and type_shared_ptr_equal. (get_id_for_type): Add overload for type_base*. Re-write the previous overload in terms of this one. (write_context::m_type_id_map): Use type_ptr_map as the type for this. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 15:02:46 +00:00
if (l.get() == r.get())
return true;
if (l)
return *l == *r;
return true;
}
};
/// Convenience typedef for a shared pointer on a @ref type_decl.
Avoid missing member types while reading bi files * include/abg-fwd.h (get_type_declaration): Declare function. * include/abg-ir.h (class decl_base): Add class_decl as a friend. This to be able to call decl_base::set_scope from class_decl. (scope_decl::add_member_decl): Make this virtual protected, so that it can be called (virtually) from e.g, class_decl. (type_decl_sptr, typedef_decl_sptr): New convenience typedefs. (class_decl::add_member_decl): New virtual overload for scope_decl::add_member_decl. (class_decl::{add_member_type, add_data_member, add_member_function}): New overloads. * src/abg-ir.cc (add_decl_to_scope): Benign style cleanup. (get_type_declaration): Define new function. (class_decl::add_member_decl): New method. (class_decl::add_member_type): Avoid silently added a new member type when that member type has already been (perhaps inadvertently) added to a scope already. Rather, put a strict assert in place there. Also add a new overload that constructs the member type out of a classic type and adds it to the class. (class_decl::{add_data_member, add_member_function}): Likewise. (class_decl::{add_member_function_template, add_member_class_template}): Avoid silently added a new member template when that template has already been (perhaps inadvertently) added to a scope already. Rather, put a strict assert in place there. * src/abg-reader.cc (push_decl_to_current_scope): Take a an extra flag saying if the current decl should be added to the current scope as well (in addition to being pushed onto the stack of scopes maintained in the reader context). (push_and_key_type_decl): Likewise, take that extra flag and pass it to push_decl_to_current_scope. (build_function_decl, build_var_decl, build_type_decl) (build_qualified_type_decl, build_pointer_type_def) (build_reference_type_def, build_enum_type_decl, build_typedef_decl) (build_function_tdecl, build_class_tdecl): Likewise. (build_class_decl): Likewise. When building member data, types, and functions, make sure /not/ to add the data, type of function to the current scope before adding it to the class_decl. This was making the member not being added to the class because it already had a scope. (build_type_tparameter, build_type_composition) (build_non_type_tparameter, build_template_tparameter) (build_type): Adjust to add the template parm to the current scope explicitly, like previously. (handle_type_decl): Use build_type_decl function. Add the type_decl to the current scope, like previously. (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl) (handle_function_decl, handle_class_decl, handle_function_tdecl) (handle_class_tdecl): Adjust to add the decl to the current scope, like previously. * tests/data/test-read-write/test21.xml: New test input with member type(def). Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:06:04 +00:00
typedef shared_ptr<type_decl> type_decl_sptr;
/// A basic type declaration that introduces no scope.
Avoid missing member types while reading bi files * include/abg-fwd.h (get_type_declaration): Declare function. * include/abg-ir.h (class decl_base): Add class_decl as a friend. This to be able to call decl_base::set_scope from class_decl. (scope_decl::add_member_decl): Make this virtual protected, so that it can be called (virtually) from e.g, class_decl. (type_decl_sptr, typedef_decl_sptr): New convenience typedefs. (class_decl::add_member_decl): New virtual overload for scope_decl::add_member_decl. (class_decl::{add_member_type, add_data_member, add_member_function}): New overloads. * src/abg-ir.cc (add_decl_to_scope): Benign style cleanup. (get_type_declaration): Define new function. (class_decl::add_member_decl): New method. (class_decl::add_member_type): Avoid silently added a new member type when that member type has already been (perhaps inadvertently) added to a scope already. Rather, put a strict assert in place there. Also add a new overload that constructs the member type out of a classic type and adds it to the class. (class_decl::{add_data_member, add_member_function}): Likewise. (class_decl::{add_member_function_template, add_member_class_template}): Avoid silently added a new member template when that template has already been (perhaps inadvertently) added to a scope already. Rather, put a strict assert in place there. * src/abg-reader.cc (push_decl_to_current_scope): Take a an extra flag saying if the current decl should be added to the current scope as well (in addition to being pushed onto the stack of scopes maintained in the reader context). (push_and_key_type_decl): Likewise, take that extra flag and pass it to push_decl_to_current_scope. (build_function_decl, build_var_decl, build_type_decl) (build_qualified_type_decl, build_pointer_type_def) (build_reference_type_def, build_enum_type_decl, build_typedef_decl) (build_function_tdecl, build_class_tdecl): Likewise. (build_class_decl): Likewise. When building member data, types, and functions, make sure /not/ to add the data, type of function to the current scope before adding it to the class_decl. This was making the member not being added to the class because it already had a scope. (build_type_tparameter, build_type_composition) (build_non_type_tparameter, build_template_tparameter) (build_type): Adjust to add the template parm to the current scope explicitly, like previously. (handle_type_decl): Use build_type_decl function. Add the type_decl to the current scope, like previously. (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl) (handle_function_decl, handle_class_decl, handle_function_tdecl) (handle_class_tdecl): Adjust to add the decl to the current scope, like previously. * tests/data/test-read-write/test21.xml: New test input with member type(def). Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:06:04 +00:00
class type_decl : public virtual decl_base, public virtual type_base
{
// Forbidden.
type_decl();
public:
/// Facility to hash instance of type_decl
struct hash;
type_decl(const std::string& name,
size_t size_in_bits, size_t alignment_in_bits,
location locus, const std::string& mangled_name = "",
visibility vis = VISIBILITY_DEFAULT);
virtual bool
operator==(const type_base&) const;
virtual bool
operator==(const decl_base&) const;
virtual bool
operator==(const type_decl&) const;
virtual string
get_pretty_representation() const;
virtual void
traverse(ir_node_visitor&);
virtual ~type_decl();
};// end class type_decl.
/// A type that introduces a scope.
class scope_type_decl : public scope_decl, public virtual type_base
{
scope_type_decl();
public:
/// Hasher for instances of scope_type_decl
struct hash;
scope_type_decl(const std::string& name, size_t size_in_bits,
size_t alignment_in_bits, location locus,
visibility vis = VISIBILITY_DEFAULT);
virtual bool
operator==(const decl_base&) const;
virtual bool
operator==(const type_base&) const;
virtual ~scope_type_decl();
};
/// Convenience typedef for a shared pointer on namespace_decl.
typedef shared_ptr<namespace_decl> namespace_decl_sptr;
Support qualified types & Misc ancillary fixes * src/abg-ir.h (struct type_base_hash, struct dynamic_type_hash) (struct type_shared_ptr_hash, struct scope_type_decl_hash, class qualified_type_def, struct qualified_type_def_hash): New. (decl_base_hash::operator()): Constify. Don't crash if the scope of the decl we are hashing is null. (class type_decl): Add comment at the end. (type_decl_hash::operator()): Constify. Reuse the new type_base_hash hasher. (class namespace_decl): Add comment. * src/abg-ir.cc (qualified_type_def::qualified_type_def) (qualified_type_def::~qualified_type_def) (qualified_type_def::get_cv_quals) (qualified_type_def::set_cv_quals) (qualified_type_def::get_underlying_type) (dynamic_type_hash::operator()): New function definitions. * src/abg-reader.cc (handle_qualified_type_decl): New. (read_file): Handle elements named "qualified-type-def". (read::context::add_type_decl): Assert that the type being associated to the unique ID is non-null. (handle_type_decl): Fix this in the process; don't crash if some attributes are not present. Associate the unique id present in the xml document with the type we just parsed. (handle_namespace_decl): Add some comments. Don't crash if the name attribute is not present. * src/abg-writer.cc (write_context::get_id_for_type) (write_context::m_type_id_map, write_decl_location) (write_qualified_type_def): New. (write_decl): Handle instances of qualified_type_def. (write_type_decl): Use the new write_decl_location and write_context::get_id_for_type. * tests/data/test-read-write/test0.xml: Update id format since we are now using the new write_context::get_id_for_type to generate it. * tests/data/test-read-write/test1.xml: Likewise. * tests/data/test-read-write/test2.xml: Likewise. * tests/data/test-read-write/test3.xml: New test. * tests/test-read-write.cc: Test De-serializing tests/data/test-read-write/test3.xml and serializing it back. Also don't bail out if we fail on one input. * tests/Makefile.am: Add tests/data/test-read-write/test3.xml to the distribution.
2013-03-27 22:34:07 +00:00
/// The abstraction of a namespace declaration
class namespace_decl : public scope_decl
{
public:
namespace_decl(const std::string& name, location locus,
visibility vis = VISIBILITY_DEFAULT);
virtual bool
operator==(const decl_base&) const;
virtual void
traverse(ir_node_visitor&);
virtual ~namespace_decl();
};// end class namespace_decl
Support qualified types & Misc ancillary fixes * src/abg-ir.h (struct type_base_hash, struct dynamic_type_hash) (struct type_shared_ptr_hash, struct scope_type_decl_hash, class qualified_type_def, struct qualified_type_def_hash): New. (decl_base_hash::operator()): Constify. Don't crash if the scope of the decl we are hashing is null. (class type_decl): Add comment at the end. (type_decl_hash::operator()): Constify. Reuse the new type_base_hash hasher. (class namespace_decl): Add comment. * src/abg-ir.cc (qualified_type_def::qualified_type_def) (qualified_type_def::~qualified_type_def) (qualified_type_def::get_cv_quals) (qualified_type_def::set_cv_quals) (qualified_type_def::get_underlying_type) (dynamic_type_hash::operator()): New function definitions. * src/abg-reader.cc (handle_qualified_type_decl): New. (read_file): Handle elements named "qualified-type-def". (read::context::add_type_decl): Assert that the type being associated to the unique ID is non-null. (handle_type_decl): Fix this in the process; don't crash if some attributes are not present. Associate the unique id present in the xml document with the type we just parsed. (handle_namespace_decl): Add some comments. Don't crash if the name attribute is not present. * src/abg-writer.cc (write_context::get_id_for_type) (write_context::m_type_id_map, write_decl_location) (write_qualified_type_def): New. (write_decl): Handle instances of qualified_type_def. (write_type_decl): Use the new write_decl_location and write_context::get_id_for_type. * tests/data/test-read-write/test0.xml: Update id format since we are now using the new write_context::get_id_for_type to generate it. * tests/data/test-read-write/test1.xml: Likewise. * tests/data/test-read-write/test2.xml: Likewise. * tests/data/test-read-write/test3.xml: New test. * tests/test-read-write.cc: Test De-serializing tests/data/test-read-write/test3.xml and serializing it back. Also don't bail out if we fail on one input. * tests/Makefile.am: Add tests/data/test-read-write/test3.xml to the distribution.
2013-03-27 22:34:07 +00:00
typedef shared_ptr<qualified_type_def> qualified_type_def_sptr;
Support qualified types & Misc ancillary fixes * src/abg-ir.h (struct type_base_hash, struct dynamic_type_hash) (struct type_shared_ptr_hash, struct scope_type_decl_hash, class qualified_type_def, struct qualified_type_def_hash): New. (decl_base_hash::operator()): Constify. Don't crash if the scope of the decl we are hashing is null. (class type_decl): Add comment at the end. (type_decl_hash::operator()): Constify. Reuse the new type_base_hash hasher. (class namespace_decl): Add comment. * src/abg-ir.cc (qualified_type_def::qualified_type_def) (qualified_type_def::~qualified_type_def) (qualified_type_def::get_cv_quals) (qualified_type_def::set_cv_quals) (qualified_type_def::get_underlying_type) (dynamic_type_hash::operator()): New function definitions. * src/abg-reader.cc (handle_qualified_type_decl): New. (read_file): Handle elements named "qualified-type-def". (read::context::add_type_decl): Assert that the type being associated to the unique ID is non-null. (handle_type_decl): Fix this in the process; don't crash if some attributes are not present. Associate the unique id present in the xml document with the type we just parsed. (handle_namespace_decl): Add some comments. Don't crash if the name attribute is not present. * src/abg-writer.cc (write_context::get_id_for_type) (write_context::m_type_id_map, write_decl_location) (write_qualified_type_def): New. (write_decl): Handle instances of qualified_type_def. (write_type_decl): Use the new write_decl_location and write_context::get_id_for_type. * tests/data/test-read-write/test0.xml: Update id format since we are now using the new write_context::get_id_for_type to generate it. * tests/data/test-read-write/test1.xml: Likewise. * tests/data/test-read-write/test2.xml: Likewise. * tests/data/test-read-write/test3.xml: New test. * tests/test-read-write.cc: Test De-serializing tests/data/test-read-write/test3.xml and serializing it back. Also don't bail out if we fail on one input. * tests/Makefile.am: Add tests/data/test-read-write/test3.xml to the distribution.
2013-03-27 22:34:07 +00:00
/// The abstraction of a qualified type.
class qualified_type_def : public virtual type_base, public virtual decl_base
Support qualified types & Misc ancillary fixes * src/abg-ir.h (struct type_base_hash, struct dynamic_type_hash) (struct type_shared_ptr_hash, struct scope_type_decl_hash, class qualified_type_def, struct qualified_type_def_hash): New. (decl_base_hash::operator()): Constify. Don't crash if the scope of the decl we are hashing is null. (class type_decl): Add comment at the end. (type_decl_hash::operator()): Constify. Reuse the new type_base_hash hasher. (class namespace_decl): Add comment. * src/abg-ir.cc (qualified_type_def::qualified_type_def) (qualified_type_def::~qualified_type_def) (qualified_type_def::get_cv_quals) (qualified_type_def::set_cv_quals) (qualified_type_def::get_underlying_type) (dynamic_type_hash::operator()): New function definitions. * src/abg-reader.cc (handle_qualified_type_decl): New. (read_file): Handle elements named "qualified-type-def". (read::context::add_type_decl): Assert that the type being associated to the unique ID is non-null. (handle_type_decl): Fix this in the process; don't crash if some attributes are not present. Associate the unique id present in the xml document with the type we just parsed. (handle_namespace_decl): Add some comments. Don't crash if the name attribute is not present. * src/abg-writer.cc (write_context::get_id_for_type) (write_context::m_type_id_map, write_decl_location) (write_qualified_type_def): New. (write_decl): Handle instances of qualified_type_def. (write_type_decl): Use the new write_decl_location and write_context::get_id_for_type. * tests/data/test-read-write/test0.xml: Update id format since we are now using the new write_context::get_id_for_type to generate it. * tests/data/test-read-write/test1.xml: Likewise. * tests/data/test-read-write/test2.xml: Likewise. * tests/data/test-read-write/test3.xml: New test. * tests/test-read-write.cc: Test De-serializing tests/data/test-read-write/test3.xml and serializing it back. Also don't bail out if we fail on one input. * tests/Makefile.am: Add tests/data/test-read-write/test3.xml to the distribution.
2013-03-27 22:34:07 +00:00
{
char cv_quals_;
shared_ptr<type_base> underlying_type_;
Support qualified types & Misc ancillary fixes * src/abg-ir.h (struct type_base_hash, struct dynamic_type_hash) (struct type_shared_ptr_hash, struct scope_type_decl_hash, class qualified_type_def, struct qualified_type_def_hash): New. (decl_base_hash::operator()): Constify. Don't crash if the scope of the decl we are hashing is null. (class type_decl): Add comment at the end. (type_decl_hash::operator()): Constify. Reuse the new type_base_hash hasher. (class namespace_decl): Add comment. * src/abg-ir.cc (qualified_type_def::qualified_type_def) (qualified_type_def::~qualified_type_def) (qualified_type_def::get_cv_quals) (qualified_type_def::set_cv_quals) (qualified_type_def::get_underlying_type) (dynamic_type_hash::operator()): New function definitions. * src/abg-reader.cc (handle_qualified_type_decl): New. (read_file): Handle elements named "qualified-type-def". (read::context::add_type_decl): Assert that the type being associated to the unique ID is non-null. (handle_type_decl): Fix this in the process; don't crash if some attributes are not present. Associate the unique id present in the xml document with the type we just parsed. (handle_namespace_decl): Add some comments. Don't crash if the name attribute is not present. * src/abg-writer.cc (write_context::get_id_for_type) (write_context::m_type_id_map, write_decl_location) (write_qualified_type_def): New. (write_decl): Handle instances of qualified_type_def. (write_type_decl): Use the new write_decl_location and write_context::get_id_for_type. * tests/data/test-read-write/test0.xml: Update id format since we are now using the new write_context::get_id_for_type to generate it. * tests/data/test-read-write/test1.xml: Likewise. * tests/data/test-read-write/test2.xml: Likewise. * tests/data/test-read-write/test3.xml: New test. * tests/test-read-write.cc: Test De-serializing tests/data/test-read-write/test3.xml and serializing it back. Also don't bail out if we fail on one input. * tests/Makefile.am: Add tests/data/test-read-write/test3.xml to the distribution.
2013-03-27 22:34:07 +00:00
// Forbidden.
qualified_type_def();
Support qualified types & Misc ancillary fixes * src/abg-ir.h (struct type_base_hash, struct dynamic_type_hash) (struct type_shared_ptr_hash, struct scope_type_decl_hash, class qualified_type_def, struct qualified_type_def_hash): New. (decl_base_hash::operator()): Constify. Don't crash if the scope of the decl we are hashing is null. (class type_decl): Add comment at the end. (type_decl_hash::operator()): Constify. Reuse the new type_base_hash hasher. (class namespace_decl): Add comment. * src/abg-ir.cc (qualified_type_def::qualified_type_def) (qualified_type_def::~qualified_type_def) (qualified_type_def::get_cv_quals) (qualified_type_def::set_cv_quals) (qualified_type_def::get_underlying_type) (dynamic_type_hash::operator()): New function definitions. * src/abg-reader.cc (handle_qualified_type_decl): New. (read_file): Handle elements named "qualified-type-def". (read::context::add_type_decl): Assert that the type being associated to the unique ID is non-null. (handle_type_decl): Fix this in the process; don't crash if some attributes are not present. Associate the unique id present in the xml document with the type we just parsed. (handle_namespace_decl): Add some comments. Don't crash if the name attribute is not present. * src/abg-writer.cc (write_context::get_id_for_type) (write_context::m_type_id_map, write_decl_location) (write_qualified_type_def): New. (write_decl): Handle instances of qualified_type_def. (write_type_decl): Use the new write_decl_location and write_context::get_id_for_type. * tests/data/test-read-write/test0.xml: Update id format since we are now using the new write_context::get_id_for_type to generate it. * tests/data/test-read-write/test1.xml: Likewise. * tests/data/test-read-write/test2.xml: Likewise. * tests/data/test-read-write/test3.xml: New test. * tests/test-read-write.cc: Test De-serializing tests/data/test-read-write/test3.xml and serializing it back. Also don't bail out if we fail on one input. * tests/Makefile.am: Add tests/data/test-read-write/test3.xml to the distribution.
2013-03-27 22:34:07 +00:00
public:
/// A Hasher for instances of qualified_type_def
struct hash;
Support qualified types & Misc ancillary fixes * src/abg-ir.h (struct type_base_hash, struct dynamic_type_hash) (struct type_shared_ptr_hash, struct scope_type_decl_hash, class qualified_type_def, struct qualified_type_def_hash): New. (decl_base_hash::operator()): Constify. Don't crash if the scope of the decl we are hashing is null. (class type_decl): Add comment at the end. (type_decl_hash::operator()): Constify. Reuse the new type_base_hash hasher. (class namespace_decl): Add comment. * src/abg-ir.cc (qualified_type_def::qualified_type_def) (qualified_type_def::~qualified_type_def) (qualified_type_def::get_cv_quals) (qualified_type_def::set_cv_quals) (qualified_type_def::get_underlying_type) (dynamic_type_hash::operator()): New function definitions. * src/abg-reader.cc (handle_qualified_type_decl): New. (read_file): Handle elements named "qualified-type-def". (read::context::add_type_decl): Assert that the type being associated to the unique ID is non-null. (handle_type_decl): Fix this in the process; don't crash if some attributes are not present. Associate the unique id present in the xml document with the type we just parsed. (handle_namespace_decl): Add some comments. Don't crash if the name attribute is not present. * src/abg-writer.cc (write_context::get_id_for_type) (write_context::m_type_id_map, write_decl_location) (write_qualified_type_def): New. (write_decl): Handle instances of qualified_type_def. (write_type_decl): Use the new write_decl_location and write_context::get_id_for_type. * tests/data/test-read-write/test0.xml: Update id format since we are now using the new write_context::get_id_for_type to generate it. * tests/data/test-read-write/test1.xml: Likewise. * tests/data/test-read-write/test2.xml: Likewise. * tests/data/test-read-write/test3.xml: New test. * tests/test-read-write.cc: Test De-serializing tests/data/test-read-write/test3.xml and serializing it back. Also don't bail out if we fail on one input. * tests/Makefile.am: Add tests/data/test-read-write/test3.xml to the distribution.
2013-03-27 22:34:07 +00:00
/// Bit field values representing the cv qualifiers of the
/// underlying type.
enum CV
{
CV_NONE = 0,
CV_CONST = 1,
CV_VOLATILE = 1 << 1,
CV_RESTRICT = 1 << 2
Support qualified types & Misc ancillary fixes * src/abg-ir.h (struct type_base_hash, struct dynamic_type_hash) (struct type_shared_ptr_hash, struct scope_type_decl_hash, class qualified_type_def, struct qualified_type_def_hash): New. (decl_base_hash::operator()): Constify. Don't crash if the scope of the decl we are hashing is null. (class type_decl): Add comment at the end. (type_decl_hash::operator()): Constify. Reuse the new type_base_hash hasher. (class namespace_decl): Add comment. * src/abg-ir.cc (qualified_type_def::qualified_type_def) (qualified_type_def::~qualified_type_def) (qualified_type_def::get_cv_quals) (qualified_type_def::set_cv_quals) (qualified_type_def::get_underlying_type) (dynamic_type_hash::operator()): New function definitions. * src/abg-reader.cc (handle_qualified_type_decl): New. (read_file): Handle elements named "qualified-type-def". (read::context::add_type_decl): Assert that the type being associated to the unique ID is non-null. (handle_type_decl): Fix this in the process; don't crash if some attributes are not present. Associate the unique id present in the xml document with the type we just parsed. (handle_namespace_decl): Add some comments. Don't crash if the name attribute is not present. * src/abg-writer.cc (write_context::get_id_for_type) (write_context::m_type_id_map, write_decl_location) (write_qualified_type_def): New. (write_decl): Handle instances of qualified_type_def. (write_type_decl): Use the new write_decl_location and write_context::get_id_for_type. * tests/data/test-read-write/test0.xml: Update id format since we are now using the new write_context::get_id_for_type to generate it. * tests/data/test-read-write/test1.xml: Likewise. * tests/data/test-read-write/test2.xml: Likewise. * tests/data/test-read-write/test3.xml: New test. * tests/test-read-write.cc: Test De-serializing tests/data/test-read-write/test3.xml and serializing it back. Also don't bail out if we fail on one input. * tests/Makefile.am: Add tests/data/test-read-write/test3.xml to the distribution.
2013-03-27 22:34:07 +00:00
};
qualified_type_def(shared_ptr<type_base> type, CV quals, location locus);
Support qualified types & Misc ancillary fixes * src/abg-ir.h (struct type_base_hash, struct dynamic_type_hash) (struct type_shared_ptr_hash, struct scope_type_decl_hash, class qualified_type_def, struct qualified_type_def_hash): New. (decl_base_hash::operator()): Constify. Don't crash if the scope of the decl we are hashing is null. (class type_decl): Add comment at the end. (type_decl_hash::operator()): Constify. Reuse the new type_base_hash hasher. (class namespace_decl): Add comment. * src/abg-ir.cc (qualified_type_def::qualified_type_def) (qualified_type_def::~qualified_type_def) (qualified_type_def::get_cv_quals) (qualified_type_def::set_cv_quals) (qualified_type_def::get_underlying_type) (dynamic_type_hash::operator()): New function definitions. * src/abg-reader.cc (handle_qualified_type_decl): New. (read_file): Handle elements named "qualified-type-def". (read::context::add_type_decl): Assert that the type being associated to the unique ID is non-null. (handle_type_decl): Fix this in the process; don't crash if some attributes are not present. Associate the unique id present in the xml document with the type we just parsed. (handle_namespace_decl): Add some comments. Don't crash if the name attribute is not present. * src/abg-writer.cc (write_context::get_id_for_type) (write_context::m_type_id_map, write_decl_location) (write_qualified_type_def): New. (write_decl): Handle instances of qualified_type_def. (write_type_decl): Use the new write_decl_location and write_context::get_id_for_type. * tests/data/test-read-write/test0.xml: Update id format since we are now using the new write_context::get_id_for_type to generate it. * tests/data/test-read-write/test1.xml: Likewise. * tests/data/test-read-write/test2.xml: Likewise. * tests/data/test-read-write/test3.xml: New test. * tests/test-read-write.cc: Test De-serializing tests/data/test-read-write/test3.xml and serializing it back. Also don't bail out if we fail on one input. * tests/Makefile.am: Add tests/data/test-read-write/test3.xml to the distribution.
2013-03-27 22:34:07 +00:00
virtual bool
operator==(const decl_base&) const;
virtual bool
operator==(const type_base&) const;
Support qualified types & Misc ancillary fixes * src/abg-ir.h (struct type_base_hash, struct dynamic_type_hash) (struct type_shared_ptr_hash, struct scope_type_decl_hash, class qualified_type_def, struct qualified_type_def_hash): New. (decl_base_hash::operator()): Constify. Don't crash if the scope of the decl we are hashing is null. (class type_decl): Add comment at the end. (type_decl_hash::operator()): Constify. Reuse the new type_base_hash hasher. (class namespace_decl): Add comment. * src/abg-ir.cc (qualified_type_def::qualified_type_def) (qualified_type_def::~qualified_type_def) (qualified_type_def::get_cv_quals) (qualified_type_def::set_cv_quals) (qualified_type_def::get_underlying_type) (dynamic_type_hash::operator()): New function definitions. * src/abg-reader.cc (handle_qualified_type_decl): New. (read_file): Handle elements named "qualified-type-def". (read::context::add_type_decl): Assert that the type being associated to the unique ID is non-null. (handle_type_decl): Fix this in the process; don't crash if some attributes are not present. Associate the unique id present in the xml document with the type we just parsed. (handle_namespace_decl): Add some comments. Don't crash if the name attribute is not present. * src/abg-writer.cc (write_context::get_id_for_type) (write_context::m_type_id_map, write_decl_location) (write_qualified_type_def): New. (write_decl): Handle instances of qualified_type_def. (write_type_decl): Use the new write_decl_location and write_context::get_id_for_type. * tests/data/test-read-write/test0.xml: Update id format since we are now using the new write_context::get_id_for_type to generate it. * tests/data/test-read-write/test1.xml: Likewise. * tests/data/test-read-write/test2.xml: Likewise. * tests/data/test-read-write/test3.xml: New test. * tests/test-read-write.cc: Test De-serializing tests/data/test-read-write/test3.xml and serializing it back. Also don't bail out if we fail on one input. * tests/Makefile.am: Add tests/data/test-read-write/test3.xml to the distribution.
2013-03-27 22:34:07 +00:00
char
get_cv_quals() const;
void
set_cv_quals(char cv_quals);
const shared_ptr<type_base>&
Support qualified types & Misc ancillary fixes * src/abg-ir.h (struct type_base_hash, struct dynamic_type_hash) (struct type_shared_ptr_hash, struct scope_type_decl_hash, class qualified_type_def, struct qualified_type_def_hash): New. (decl_base_hash::operator()): Constify. Don't crash if the scope of the decl we are hashing is null. (class type_decl): Add comment at the end. (type_decl_hash::operator()): Constify. Reuse the new type_base_hash hasher. (class namespace_decl): Add comment. * src/abg-ir.cc (qualified_type_def::qualified_type_def) (qualified_type_def::~qualified_type_def) (qualified_type_def::get_cv_quals) (qualified_type_def::set_cv_quals) (qualified_type_def::get_underlying_type) (dynamic_type_hash::operator()): New function definitions. * src/abg-reader.cc (handle_qualified_type_decl): New. (read_file): Handle elements named "qualified-type-def". (read::context::add_type_decl): Assert that the type being associated to the unique ID is non-null. (handle_type_decl): Fix this in the process; don't crash if some attributes are not present. Associate the unique id present in the xml document with the type we just parsed. (handle_namespace_decl): Add some comments. Don't crash if the name attribute is not present. * src/abg-writer.cc (write_context::get_id_for_type) (write_context::m_type_id_map, write_decl_location) (write_qualified_type_def): New. (write_decl): Handle instances of qualified_type_def. (write_type_decl): Use the new write_decl_location and write_context::get_id_for_type. * tests/data/test-read-write/test0.xml: Update id format since we are now using the new write_context::get_id_for_type to generate it. * tests/data/test-read-write/test1.xml: Likewise. * tests/data/test-read-write/test2.xml: Likewise. * tests/data/test-read-write/test3.xml: New test. * tests/test-read-write.cc: Test De-serializing tests/data/test-read-write/test3.xml and serializing it back. Also don't bail out if we fail on one input. * tests/Makefile.am: Add tests/data/test-read-write/test3.xml to the distribution.
2013-03-27 22:34:07 +00:00
get_underlying_type() const;
virtual void
traverse(ir_node_visitor& v);
Support qualified types & Misc ancillary fixes * src/abg-ir.h (struct type_base_hash, struct dynamic_type_hash) (struct type_shared_ptr_hash, struct scope_type_decl_hash, class qualified_type_def, struct qualified_type_def_hash): New. (decl_base_hash::operator()): Constify. Don't crash if the scope of the decl we are hashing is null. (class type_decl): Add comment at the end. (type_decl_hash::operator()): Constify. Reuse the new type_base_hash hasher. (class namespace_decl): Add comment. * src/abg-ir.cc (qualified_type_def::qualified_type_def) (qualified_type_def::~qualified_type_def) (qualified_type_def::get_cv_quals) (qualified_type_def::set_cv_quals) (qualified_type_def::get_underlying_type) (dynamic_type_hash::operator()): New function definitions. * src/abg-reader.cc (handle_qualified_type_decl): New. (read_file): Handle elements named "qualified-type-def". (read::context::add_type_decl): Assert that the type being associated to the unique ID is non-null. (handle_type_decl): Fix this in the process; don't crash if some attributes are not present. Associate the unique id present in the xml document with the type we just parsed. (handle_namespace_decl): Add some comments. Don't crash if the name attribute is not present. * src/abg-writer.cc (write_context::get_id_for_type) (write_context::m_type_id_map, write_decl_location) (write_qualified_type_def): New. (write_decl): Handle instances of qualified_type_def. (write_type_decl): Use the new write_decl_location and write_context::get_id_for_type. * tests/data/test-read-write/test0.xml: Update id format since we are now using the new write_context::get_id_for_type to generate it. * tests/data/test-read-write/test1.xml: Likewise. * tests/data/test-read-write/test2.xml: Likewise. * tests/data/test-read-write/test3.xml: New test. * tests/test-read-write.cc: Test De-serializing tests/data/test-read-write/test3.xml and serializing it back. Also don't bail out if we fail on one input. * tests/Makefile.am: Add tests/data/test-read-write/test3.xml to the distribution.
2013-03-27 22:34:07 +00:00
virtual ~qualified_type_def();
}; // end class qualified_type_def.
Support qualified types & Misc ancillary fixes * src/abg-ir.h (struct type_base_hash, struct dynamic_type_hash) (struct type_shared_ptr_hash, struct scope_type_decl_hash, class qualified_type_def, struct qualified_type_def_hash): New. (decl_base_hash::operator()): Constify. Don't crash if the scope of the decl we are hashing is null. (class type_decl): Add comment at the end. (type_decl_hash::operator()): Constify. Reuse the new type_base_hash hasher. (class namespace_decl): Add comment. * src/abg-ir.cc (qualified_type_def::qualified_type_def) (qualified_type_def::~qualified_type_def) (qualified_type_def::get_cv_quals) (qualified_type_def::set_cv_quals) (qualified_type_def::get_underlying_type) (dynamic_type_hash::operator()): New function definitions. * src/abg-reader.cc (handle_qualified_type_decl): New. (read_file): Handle elements named "qualified-type-def". (read::context::add_type_decl): Assert that the type being associated to the unique ID is non-null. (handle_type_decl): Fix this in the process; don't crash if some attributes are not present. Associate the unique id present in the xml document with the type we just parsed. (handle_namespace_decl): Add some comments. Don't crash if the name attribute is not present. * src/abg-writer.cc (write_context::get_id_for_type) (write_context::m_type_id_map, write_decl_location) (write_qualified_type_def): New. (write_decl): Handle instances of qualified_type_def. (write_type_decl): Use the new write_decl_location and write_context::get_id_for_type. * tests/data/test-read-write/test0.xml: Update id format since we are now using the new write_context::get_id_for_type to generate it. * tests/data/test-read-write/test1.xml: Likewise. * tests/data/test-read-write/test2.xml: Likewise. * tests/data/test-read-write/test3.xml: New test. * tests/test-read-write.cc: Test De-serializing tests/data/test-read-write/test3.xml and serializing it back. Also don't bail out if we fail on one input. * tests/Makefile.am: Add tests/data/test-read-write/test3.xml to the distribution.
2013-03-27 22:34:07 +00:00
qualified_type_def::CV
operator|(qualified_type_def::CV, qualified_type_def::CV);
std::ostream&
operator<<(std::ostream&, qualified_type_def::CV);
/// Convenience typedef for a shared pointer on a @ref pointer_type_def
typedef shared_ptr<pointer_type_def> pointer_type_def_sptr;
/// The abstraction of a pointer type.
class pointer_type_def : public virtual type_base, public virtual decl_base
{
shared_ptr<type_base> pointed_to_type_;
// Forbidden.
pointer_type_def();
public:
/// A hasher for instances of pointer_type_def
struct hash;
pointer_type_def(shared_ptr<type_base>& pointed_to_type, size_t size_in_bits,
size_t alignment_in_bits, location locus);
virtual bool
operator==(const decl_base&) const;
virtual bool
operator==(const type_base&) const;
const shared_ptr<type_base>&
get_pointed_to_type() const;
virtual void
traverse(ir_node_visitor& v);
virtual ~pointer_type_def();
}; // end class pointer_type_def
/// Convenience typedef for a shared pointer on a @ref reference_type_def
typedef shared_ptr<reference_type_def> reference_type_def_sptr;
/// Abstracts a reference type.
class reference_type_def : public virtual type_base, public virtual decl_base
{
shared_ptr<type_base> pointed_to_type_;
bool is_lvalue_;
// Forbidden.
reference_type_def();
public:
/// Hasher for intances of reference_type_def.
struct hash;
reference_type_def(const type_base_sptr pointed_to_type,
bool lvalue, size_t size_in_bits,
size_t alignment_in_bits, location locus);
virtual bool
operator==(const decl_base&) const;
virtual bool
operator==(const type_base&) const;
const shared_ptr<type_base>&
get_pointed_to_type() const;
bool
is_lvalue() const;
virtual void
traverse(ir_node_visitor& v);
virtual ~reference_type_def();
}; // end class reference_type_def
/// Convenience typedef for shared pointer on enum_type_decl.
typedef shared_ptr<enum_type_decl> enum_type_decl_sptr;
/// Abstracts a declaration for an enum type.
class enum_type_decl : public virtual type_base, public virtual decl_base
{
public:
/// A hasher for an enum_type_decl.
struct hash;
/// Enumerator Datum.
class enumerator
{
string name_;
size_t value_;
public:
enumerator()
: value_(0)
{}
enumerator(const string& name, size_t value)
: name_(name), value_(value) { }
bool
operator==(const enumerator& other) const
{
return (get_name() == other.get_name()
&& get_value() == other.get_value());
}
const string&
get_name() const
{return name_;}
const string
get_qualified_name(const enum_type_decl_sptr enum_type) const
{return enum_type->get_qualified_name() + "::" + get_name();}
void
set_name(const string& n)
{name_ = n;}
size_t
get_value() const
{return value_;}
void
set_value(size_t v)
{value_=v;}
};
/// Convenience typedef for a list of @ref enumerator.
typedef std::vector<enumerator> enumerators;
private:
type_base_sptr underlying_type_;
enumerators enumerators_;
// Forbidden
enum_type_decl();
public:
/// Constructor of an enum type declaration.
///
/// @param name the name of the enum
///
/// @param locus the locus at which the enum appears in the source
/// code.
///
/// @param underlying_type the underlying type of the enum
///
/// @param enms a list of enumerators for this enum.
///
/// @param mangled_name the mangled name of the enum type.
///
/// @param vis the visibility of instances of this type.
enum_type_decl(const string& name, location locus,
type_base_sptr underlying_type,
enumerators& enms, const std::string& mangled_name = "",
visibility vis = VISIBILITY_DEFAULT)
: type_base(underlying_type->get_size_in_bits(),
underlying_type->get_alignment_in_bits()),
decl_base(name, locus, mangled_name, vis),
underlying_type_(underlying_type),
enumerators_(enms)
{}
type_base_sptr
get_underlying_type() const;
const enumerators&
get_enumerators() const;
virtual string
get_pretty_representation() const;
Support var decl & mangled_name attributes * src/abg-ir.h (decl_base::binding, decl_base::get_mangled_name) (decl_base::set_mangled_name, decl_base::m_mangled_name): New declarations. (scope_decl::scope_decl: type_decl::type_decl) (scope_type_decl::scope_type_decl, typedef_decl::typedef_decl): Initialize mangled_name. (namespace_decl::namespace_decl): Initialize visibility. (class var_decl): New declaration. * src/abg-ir.cc (decl_base::decl_base, scope_decl::scope_decl) (type_decl::type_decl, scope_type_decl::scope_type_decl): Initialize mangled name. (namespace_decl::namespace_decl): Initialize visibility. (qualified_type_def::qualified_type_def) (pointer_type_def::pointer_type_def) (reference_type_def::reference_type_def): By default, set the visibility to the same as for the underlying type. (enum_type_decl::enum_type_decl, typedef_decl::typedef_decl): Initialize mangled name. (var_decl::var_decl, var_decl::operator==, var_decl::~var_decl): New definitions. * src/abg-reader.cc (read_visibility, read_binding, handle_var_decl): New definitions. (read_file): Handle var-decl elements. * src/abg-writer.cc (write_location): Rename write_decl_location into this. (write_var_decl, write_visibility, write_binding): New definitions. (write_decl, write_type_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl): Adjust to use write_location. * tests/data/test-read-write/test8.xml: New test input. * tests/test-read-write.cc: De-serialize the above and serialize it back and ensure both are equal. * tests/Makefile.am: add tests/data/test-read-write/test8.xml to the distribution.
2013-04-02 12:24:08 +00:00
virtual bool
operator==(const decl_base&) const;
virtual bool
operator==(const type_base&) const;
virtual void
traverse(ir_node_visitor& v);
virtual ~enum_type_decl();
}; // end class enum_type_decl
/// Convenience typedef for a shared pointer on a @ref typedef_decl.
Avoid missing member types while reading bi files * include/abg-fwd.h (get_type_declaration): Declare function. * include/abg-ir.h (class decl_base): Add class_decl as a friend. This to be able to call decl_base::set_scope from class_decl. (scope_decl::add_member_decl): Make this virtual protected, so that it can be called (virtually) from e.g, class_decl. (type_decl_sptr, typedef_decl_sptr): New convenience typedefs. (class_decl::add_member_decl): New virtual overload for scope_decl::add_member_decl. (class_decl::{add_member_type, add_data_member, add_member_function}): New overloads. * src/abg-ir.cc (add_decl_to_scope): Benign style cleanup. (get_type_declaration): Define new function. (class_decl::add_member_decl): New method. (class_decl::add_member_type): Avoid silently added a new member type when that member type has already been (perhaps inadvertently) added to a scope already. Rather, put a strict assert in place there. Also add a new overload that constructs the member type out of a classic type and adds it to the class. (class_decl::{add_data_member, add_member_function}): Likewise. (class_decl::{add_member_function_template, add_member_class_template}): Avoid silently added a new member template when that template has already been (perhaps inadvertently) added to a scope already. Rather, put a strict assert in place there. * src/abg-reader.cc (push_decl_to_current_scope): Take a an extra flag saying if the current decl should be added to the current scope as well (in addition to being pushed onto the stack of scopes maintained in the reader context). (push_and_key_type_decl): Likewise, take that extra flag and pass it to push_decl_to_current_scope. (build_function_decl, build_var_decl, build_type_decl) (build_qualified_type_decl, build_pointer_type_def) (build_reference_type_def, build_enum_type_decl, build_typedef_decl) (build_function_tdecl, build_class_tdecl): Likewise. (build_class_decl): Likewise. When building member data, types, and functions, make sure /not/ to add the data, type of function to the current scope before adding it to the class_decl. This was making the member not being added to the class because it already had a scope. (build_type_tparameter, build_type_composition) (build_non_type_tparameter, build_template_tparameter) (build_type): Adjust to add the template parm to the current scope explicitly, like previously. (handle_type_decl): Use build_type_decl function. Add the type_decl to the current scope, like previously. (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl) (handle_function_decl, handle_class_decl, handle_function_tdecl) (handle_class_tdecl): Adjust to add the decl to the current scope, like previously. * tests/data/test-read-write/test21.xml: New test input with member type(def). Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:06:04 +00:00
typedef shared_ptr<typedef_decl> typedef_decl_sptr;
/// The abstraction of a typedef declaration.
class typedef_decl : public virtual type_base, public virtual decl_base
{
shared_ptr<type_base> underlying_type_;
// Forbidden
typedef_decl();
public:
/// Hasher for the typedef_decl type.
struct hash;
typedef_decl(const string& name, const shared_ptr<type_base> underlying_type,
location locus, const std::string& mangled_name = "",
visibility vis = VISIBILITY_DEFAULT);
Support var decl & mangled_name attributes * src/abg-ir.h (decl_base::binding, decl_base::get_mangled_name) (decl_base::set_mangled_name, decl_base::m_mangled_name): New declarations. (scope_decl::scope_decl: type_decl::type_decl) (scope_type_decl::scope_type_decl, typedef_decl::typedef_decl): Initialize mangled_name. (namespace_decl::namespace_decl): Initialize visibility. (class var_decl): New declaration. * src/abg-ir.cc (decl_base::decl_base, scope_decl::scope_decl) (type_decl::type_decl, scope_type_decl::scope_type_decl): Initialize mangled name. (namespace_decl::namespace_decl): Initialize visibility. (qualified_type_def::qualified_type_def) (pointer_type_def::pointer_type_def) (reference_type_def::reference_type_def): By default, set the visibility to the same as for the underlying type. (enum_type_decl::enum_type_decl, typedef_decl::typedef_decl): Initialize mangled name. (var_decl::var_decl, var_decl::operator==, var_decl::~var_decl): New definitions. * src/abg-reader.cc (read_visibility, read_binding, handle_var_decl): New definitions. (read_file): Handle var-decl elements. * src/abg-writer.cc (write_location): Rename write_decl_location into this. (write_var_decl, write_visibility, write_binding): New definitions. (write_decl, write_type_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl): Adjust to use write_location. * tests/data/test-read-write/test8.xml: New test input. * tests/test-read-write.cc: De-serialize the above and serialize it back and ensure both are equal. * tests/Makefile.am: add tests/data/test-read-write/test8.xml to the distribution.
2013-04-02 12:24:08 +00:00
virtual bool
operator==(const decl_base&) const;
virtual bool
operator==(const type_base&) const;
virtual string
get_pretty_representation() const;
const shared_ptr<type_base>&
get_underlying_type() const;
virtual void
traverse(ir_node_visitor&);
virtual ~typedef_decl();
Avoid missing member types while reading bi files * include/abg-fwd.h (get_type_declaration): Declare function. * include/abg-ir.h (class decl_base): Add class_decl as a friend. This to be able to call decl_base::set_scope from class_decl. (scope_decl::add_member_decl): Make this virtual protected, so that it can be called (virtually) from e.g, class_decl. (type_decl_sptr, typedef_decl_sptr): New convenience typedefs. (class_decl::add_member_decl): New virtual overload for scope_decl::add_member_decl. (class_decl::{add_member_type, add_data_member, add_member_function}): New overloads. * src/abg-ir.cc (add_decl_to_scope): Benign style cleanup. (get_type_declaration): Define new function. (class_decl::add_member_decl): New method. (class_decl::add_member_type): Avoid silently added a new member type when that member type has already been (perhaps inadvertently) added to a scope already. Rather, put a strict assert in place there. Also add a new overload that constructs the member type out of a classic type and adds it to the class. (class_decl::{add_data_member, add_member_function}): Likewise. (class_decl::{add_member_function_template, add_member_class_template}): Avoid silently added a new member template when that template has already been (perhaps inadvertently) added to a scope already. Rather, put a strict assert in place there. * src/abg-reader.cc (push_decl_to_current_scope): Take a an extra flag saying if the current decl should be added to the current scope as well (in addition to being pushed onto the stack of scopes maintained in the reader context). (push_and_key_type_decl): Likewise, take that extra flag and pass it to push_decl_to_current_scope. (build_function_decl, build_var_decl, build_type_decl) (build_qualified_type_decl, build_pointer_type_def) (build_reference_type_def, build_enum_type_decl, build_typedef_decl) (build_function_tdecl, build_class_tdecl): Likewise. (build_class_decl): Likewise. When building member data, types, and functions, make sure /not/ to add the data, type of function to the current scope before adding it to the class_decl. This was making the member not being added to the class because it already had a scope. (build_type_tparameter, build_type_composition) (build_non_type_tparameter, build_template_tparameter) (build_type): Adjust to add the template parm to the current scope explicitly, like previously. (handle_type_decl): Use build_type_decl function. Add the type_decl to the current scope, like previously. (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl) (handle_function_decl, handle_class_decl, handle_function_tdecl) (handle_class_tdecl): Adjust to add the decl to the current scope, like previously. * tests/data/test-read-write/test21.xml: New test input with member type(def). Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:06:04 +00:00
};// end class typedef_decl
/// Convenience typedef for a shared pointer on a @ref var_decl
typedef shared_ptr<var_decl> var_decl_sptr;
Support var decl & mangled_name attributes * src/abg-ir.h (decl_base::binding, decl_base::get_mangled_name) (decl_base::set_mangled_name, decl_base::m_mangled_name): New declarations. (scope_decl::scope_decl: type_decl::type_decl) (scope_type_decl::scope_type_decl, typedef_decl::typedef_decl): Initialize mangled_name. (namespace_decl::namespace_decl): Initialize visibility. (class var_decl): New declaration. * src/abg-ir.cc (decl_base::decl_base, scope_decl::scope_decl) (type_decl::type_decl, scope_type_decl::scope_type_decl): Initialize mangled name. (namespace_decl::namespace_decl): Initialize visibility. (qualified_type_def::qualified_type_def) (pointer_type_def::pointer_type_def) (reference_type_def::reference_type_def): By default, set the visibility to the same as for the underlying type. (enum_type_decl::enum_type_decl, typedef_decl::typedef_decl): Initialize mangled name. (var_decl::var_decl, var_decl::operator==, var_decl::~var_decl): New definitions. * src/abg-reader.cc (read_visibility, read_binding, handle_var_decl): New definitions. (read_file): Handle var-decl elements. * src/abg-writer.cc (write_location): Rename write_decl_location into this. (write_var_decl, write_visibility, write_binding): New definitions. (write_decl, write_type_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl): Adjust to use write_location. * tests/data/test-read-write/test8.xml: New test input. * tests/test-read-write.cc: De-serialize the above and serialize it back and ensure both are equal. * tests/Makefile.am: add tests/data/test-read-write/test8.xml to the distribution.
2013-04-02 12:24:08 +00:00
/// Abstracts a variable declaration.
class var_decl : public virtual decl_base
Support var decl & mangled_name attributes * src/abg-ir.h (decl_base::binding, decl_base::get_mangled_name) (decl_base::set_mangled_name, decl_base::m_mangled_name): New declarations. (scope_decl::scope_decl: type_decl::type_decl) (scope_type_decl::scope_type_decl, typedef_decl::typedef_decl): Initialize mangled_name. (namespace_decl::namespace_decl): Initialize visibility. (class var_decl): New declaration. * src/abg-ir.cc (decl_base::decl_base, scope_decl::scope_decl) (type_decl::type_decl, scope_type_decl::scope_type_decl): Initialize mangled name. (namespace_decl::namespace_decl): Initialize visibility. (qualified_type_def::qualified_type_def) (pointer_type_def::pointer_type_def) (reference_type_def::reference_type_def): By default, set the visibility to the same as for the underlying type. (enum_type_decl::enum_type_decl, typedef_decl::typedef_decl): Initialize mangled name. (var_decl::var_decl, var_decl::operator==, var_decl::~var_decl): New definitions. * src/abg-reader.cc (read_visibility, read_binding, handle_var_decl): New definitions. (read_file): Handle var-decl elements. * src/abg-writer.cc (write_location): Rename write_decl_location into this. (write_var_decl, write_visibility, write_binding): New definitions. (write_decl, write_type_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl): Adjust to use write_location. * tests/data/test-read-write/test8.xml: New test input. * tests/test-read-write.cc: De-serialize the above and serialize it back and ensure both are equal. * tests/Makefile.am: add tests/data/test-read-write/test8.xml to the distribution.
2013-04-02 12:24:08 +00:00
{
shared_ptr<type_base> type_;
binding binding_;
Support var decl & mangled_name attributes * src/abg-ir.h (decl_base::binding, decl_base::get_mangled_name) (decl_base::set_mangled_name, decl_base::m_mangled_name): New declarations. (scope_decl::scope_decl: type_decl::type_decl) (scope_type_decl::scope_type_decl, typedef_decl::typedef_decl): Initialize mangled_name. (namespace_decl::namespace_decl): Initialize visibility. (class var_decl): New declaration. * src/abg-ir.cc (decl_base::decl_base, scope_decl::scope_decl) (type_decl::type_decl, scope_type_decl::scope_type_decl): Initialize mangled name. (namespace_decl::namespace_decl): Initialize visibility. (qualified_type_def::qualified_type_def) (pointer_type_def::pointer_type_def) (reference_type_def::reference_type_def): By default, set the visibility to the same as for the underlying type. (enum_type_decl::enum_type_decl, typedef_decl::typedef_decl): Initialize mangled name. (var_decl::var_decl, var_decl::operator==, var_decl::~var_decl): New definitions. * src/abg-reader.cc (read_visibility, read_binding, handle_var_decl): New definitions. (read_file): Handle var-decl elements. * src/abg-writer.cc (write_location): Rename write_decl_location into this. (write_var_decl, write_visibility, write_binding): New definitions. (write_decl, write_type_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl): Adjust to use write_location. * tests/data/test-read-write/test8.xml: New test input. * tests/test-read-write.cc: De-serialize the above and serialize it back and ensure both are equal. * tests/Makefile.am: add tests/data/test-read-write/test8.xml to the distribution.
2013-04-02 12:24:08 +00:00
// Forbidden
var_decl();
public:
/// Hasher for a var_decl type.
struct hash;
/// Equality functor to compare pointers to variable_decl.
struct ptr_equal;
Support var decl & mangled_name attributes * src/abg-ir.h (decl_base::binding, decl_base::get_mangled_name) (decl_base::set_mangled_name, decl_base::m_mangled_name): New declarations. (scope_decl::scope_decl: type_decl::type_decl) (scope_type_decl::scope_type_decl, typedef_decl::typedef_decl): Initialize mangled_name. (namespace_decl::namespace_decl): Initialize visibility. (class var_decl): New declaration. * src/abg-ir.cc (decl_base::decl_base, scope_decl::scope_decl) (type_decl::type_decl, scope_type_decl::scope_type_decl): Initialize mangled name. (namespace_decl::namespace_decl): Initialize visibility. (qualified_type_def::qualified_type_def) (pointer_type_def::pointer_type_def) (reference_type_def::reference_type_def): By default, set the visibility to the same as for the underlying type. (enum_type_decl::enum_type_decl, typedef_decl::typedef_decl): Initialize mangled name. (var_decl::var_decl, var_decl::operator==, var_decl::~var_decl): New definitions. * src/abg-reader.cc (read_visibility, read_binding, handle_var_decl): New definitions. (read_file): Handle var-decl elements. * src/abg-writer.cc (write_location): Rename write_decl_location into this. (write_var_decl, write_visibility, write_binding): New definitions. (write_decl, write_type_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl): Adjust to use write_location. * tests/data/test-read-write/test8.xml: New test input. * tests/test-read-write.cc: De-serialize the above and serialize it back and ensure both are equal. * tests/Makefile.am: add tests/data/test-read-write/test8.xml to the distribution.
2013-04-02 12:24:08 +00:00
var_decl(const std::string& name,
Initial Support for class declarations * src/abg-ir.h (scope_decl::scope_decl) (scope_type_decl::scope_type_decl): Don't set mangled name for scope_decl instances as it doesn't make sense. (var_decl::var_decl): Pass the type shared pointer by value. (struct var_decl_hash, function_decl::parameter::operator==) (struct function_decl::parameter_hash, function_decl::operator==) (struct function_decl_hash, class class_decl, struct class_decl_hash): New declarations. * src/abg-ir.cc (scope_type_decl::scope_type_decl): Don't set the mangled name. It doesn't make sense for scope_decls. (dynamic_type_hash::operator): Fix comment. Run the hashing for scope_type_decl instances *after* running it for class_decl instance, otherwise, the class_decl instances case will never get hit. (var_decl::var_decl): Pass the type shared pointer by value. (function_decl::operator==, class_decl::operator==) (class_decl_hash::operator()): New fns. * src/abg-libxml-utils.h (get_xml_node_depth): Declare new fn. (XML_READER_GET_ATTRIBUTE): Fix comment. (XML_NODE_GET_ATTRIBUTE): New getter macro. * src/abg-libxml-utils.cc (get_xml_node_depth): New definition. * src/abg-reader.cc (update_read_context) (update_depth_info_of_read_context, read_visibility, read_binding) (read_access, read_size_and_alignment, read_static) (read_var_offset_in_bits, read_cdtor_const, build_function_decl) ( build_var_decl, build_type_decl, build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_enum_type_decl, build_typedef_decl, build_class_decl) (build_type, handle_class_decl): New functions or overloads. (handle_element): Update to handle "class-decl" xml elements. * src/abg-writer.cc (write_size_and_alignment, write_access) (write_class, do_indent_to_level, get_indent_to_level): New fns. (write_decl): Update to serialize instances of class_decl. (write_type_decl, write_pointer_type_def) (write_reference_type_def): Use the new write_size_and_alignment instead of writing the attributes directly. * tests/data/test-read-write/test10.xml: New test file. * tests/Makefile.am: Add tests/data/test-read-write/test10.xml to the build system. * tests/test-read-write.cc (in_out_spec): De-serialize data/test-read-write/test10.xml, serialize it back into output/test-read-write/test10.xml, and compare the two output that should be identical.
2013-04-11 20:02:08 +00:00
shared_ptr<type_base> type,
Support var decl & mangled_name attributes * src/abg-ir.h (decl_base::binding, decl_base::get_mangled_name) (decl_base::set_mangled_name, decl_base::m_mangled_name): New declarations. (scope_decl::scope_decl: type_decl::type_decl) (scope_type_decl::scope_type_decl, typedef_decl::typedef_decl): Initialize mangled_name. (namespace_decl::namespace_decl): Initialize visibility. (class var_decl): New declaration. * src/abg-ir.cc (decl_base::decl_base, scope_decl::scope_decl) (type_decl::type_decl, scope_type_decl::scope_type_decl): Initialize mangled name. (namespace_decl::namespace_decl): Initialize visibility. (qualified_type_def::qualified_type_def) (pointer_type_def::pointer_type_def) (reference_type_def::reference_type_def): By default, set the visibility to the same as for the underlying type. (enum_type_decl::enum_type_decl, typedef_decl::typedef_decl): Initialize mangled name. (var_decl::var_decl, var_decl::operator==, var_decl::~var_decl): New definitions. * src/abg-reader.cc (read_visibility, read_binding, handle_var_decl): New definitions. (read_file): Handle var-decl elements. * src/abg-writer.cc (write_location): Rename write_decl_location into this. (write_var_decl, write_visibility, write_binding): New definitions. (write_decl, write_type_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl): Adjust to use write_location. * tests/data/test-read-write/test8.xml: New test input. * tests/test-read-write.cc: De-serialize the above and serialize it back and ensure both are equal. * tests/Makefile.am: add tests/data/test-read-write/test8.xml to the distribution.
2013-04-02 12:24:08 +00:00
location locus,
const std::string& mangled_name,
visibility vis = VISIBILITY_DEFAULT,
binding bind = BINDING_NONE);
virtual bool
operator==(const decl_base&) const;
Support var decl & mangled_name attributes * src/abg-ir.h (decl_base::binding, decl_base::get_mangled_name) (decl_base::set_mangled_name, decl_base::m_mangled_name): New declarations. (scope_decl::scope_decl: type_decl::type_decl) (scope_type_decl::scope_type_decl, typedef_decl::typedef_decl): Initialize mangled_name. (namespace_decl::namespace_decl): Initialize visibility. (class var_decl): New declaration. * src/abg-ir.cc (decl_base::decl_base, scope_decl::scope_decl) (type_decl::type_decl, scope_type_decl::scope_type_decl): Initialize mangled name. (namespace_decl::namespace_decl): Initialize visibility. (qualified_type_def::qualified_type_def) (pointer_type_def::pointer_type_def) (reference_type_def::reference_type_def): By default, set the visibility to the same as for the underlying type. (enum_type_decl::enum_type_decl, typedef_decl::typedef_decl): Initialize mangled name. (var_decl::var_decl, var_decl::operator==, var_decl::~var_decl): New definitions. * src/abg-reader.cc (read_visibility, read_binding, handle_var_decl): New definitions. (read_file): Handle var-decl elements. * src/abg-writer.cc (write_location): Rename write_decl_location into this. (write_var_decl, write_visibility, write_binding): New definitions. (write_decl, write_type_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl): Adjust to use write_location. * tests/data/test-read-write/test8.xml: New test input. * tests/test-read-write.cc: De-serialize the above and serialize it back and ensure both are equal. * tests/Makefile.am: add tests/data/test-read-write/test8.xml to the distribution.
2013-04-02 12:24:08 +00:00
const shared_ptr<type_base>&
Support var decl & mangled_name attributes * src/abg-ir.h (decl_base::binding, decl_base::get_mangled_name) (decl_base::set_mangled_name, decl_base::m_mangled_name): New declarations. (scope_decl::scope_decl: type_decl::type_decl) (scope_type_decl::scope_type_decl, typedef_decl::typedef_decl): Initialize mangled_name. (namespace_decl::namespace_decl): Initialize visibility. (class var_decl): New declaration. * src/abg-ir.cc (decl_base::decl_base, scope_decl::scope_decl) (type_decl::type_decl, scope_type_decl::scope_type_decl): Initialize mangled name. (namespace_decl::namespace_decl): Initialize visibility. (qualified_type_def::qualified_type_def) (pointer_type_def::pointer_type_def) (reference_type_def::reference_type_def): By default, set the visibility to the same as for the underlying type. (enum_type_decl::enum_type_decl, typedef_decl::typedef_decl): Initialize mangled name. (var_decl::var_decl, var_decl::operator==, var_decl::~var_decl): New definitions. * src/abg-reader.cc (read_visibility, read_binding, handle_var_decl): New definitions. (read_file): Handle var-decl elements. * src/abg-writer.cc (write_location): Rename write_decl_location into this. (write_var_decl, write_visibility, write_binding): New definitions. (write_decl, write_type_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl): Adjust to use write_location. * tests/data/test-read-write/test8.xml: New test input. * tests/test-read-write.cc: De-serialize the above and serialize it back and ensure both are equal. * tests/Makefile.am: add tests/data/test-read-write/test8.xml to the distribution.
2013-04-02 12:24:08 +00:00
get_type() const
{return type_;}
Support var decl & mangled_name attributes * src/abg-ir.h (decl_base::binding, decl_base::get_mangled_name) (decl_base::set_mangled_name, decl_base::m_mangled_name): New declarations. (scope_decl::scope_decl: type_decl::type_decl) (scope_type_decl::scope_type_decl, typedef_decl::typedef_decl): Initialize mangled_name. (namespace_decl::namespace_decl): Initialize visibility. (class var_decl): New declaration. * src/abg-ir.cc (decl_base::decl_base, scope_decl::scope_decl) (type_decl::type_decl, scope_type_decl::scope_type_decl): Initialize mangled name. (namespace_decl::namespace_decl): Initialize visibility. (qualified_type_def::qualified_type_def) (pointer_type_def::pointer_type_def) (reference_type_def::reference_type_def): By default, set the visibility to the same as for the underlying type. (enum_type_decl::enum_type_decl, typedef_decl::typedef_decl): Initialize mangled name. (var_decl::var_decl, var_decl::operator==, var_decl::~var_decl): New definitions. * src/abg-reader.cc (read_visibility, read_binding, handle_var_decl): New definitions. (read_file): Handle var-decl elements. * src/abg-writer.cc (write_location): Rename write_decl_location into this. (write_var_decl, write_visibility, write_binding): New definitions. (write_decl, write_type_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl): Adjust to use write_location. * tests/data/test-read-write/test8.xml: New test input. * tests/test-read-write.cc: De-serialize the above and serialize it back and ensure both are equal. * tests/Makefile.am: add tests/data/test-read-write/test8.xml to the distribution.
2013-04-02 12:24:08 +00:00
binding
get_binding() const
{return binding_;}
Support var decl & mangled_name attributes * src/abg-ir.h (decl_base::binding, decl_base::get_mangled_name) (decl_base::set_mangled_name, decl_base::m_mangled_name): New declarations. (scope_decl::scope_decl: type_decl::type_decl) (scope_type_decl::scope_type_decl, typedef_decl::typedef_decl): Initialize mangled_name. (namespace_decl::namespace_decl): Initialize visibility. (class var_decl): New declaration. * src/abg-ir.cc (decl_base::decl_base, scope_decl::scope_decl) (type_decl::type_decl, scope_type_decl::scope_type_decl): Initialize mangled name. (namespace_decl::namespace_decl): Initialize visibility. (qualified_type_def::qualified_type_def) (pointer_type_def::pointer_type_def) (reference_type_def::reference_type_def): By default, set the visibility to the same as for the underlying type. (enum_type_decl::enum_type_decl, typedef_decl::typedef_decl): Initialize mangled name. (var_decl::var_decl, var_decl::operator==, var_decl::~var_decl): New definitions. * src/abg-reader.cc (read_visibility, read_binding, handle_var_decl): New definitions. (read_file): Handle var-decl elements. * src/abg-writer.cc (write_location): Rename write_decl_location into this. (write_var_decl, write_visibility, write_binding): New definitions. (write_decl, write_type_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl): Adjust to use write_location. * tests/data/test-read-write/test8.xml: New test input. * tests/test-read-write.cc: De-serialize the above and serialize it back and ensure both are equal. * tests/Makefile.am: add tests/data/test-read-write/test8.xml to the distribution.
2013-04-02 12:24:08 +00:00
void
set_binding(binding b)
{binding_ = b;}
Support var decl & mangled_name attributes * src/abg-ir.h (decl_base::binding, decl_base::get_mangled_name) (decl_base::set_mangled_name, decl_base::m_mangled_name): New declarations. (scope_decl::scope_decl: type_decl::type_decl) (scope_type_decl::scope_type_decl, typedef_decl::typedef_decl): Initialize mangled_name. (namespace_decl::namespace_decl): Initialize visibility. (class var_decl): New declaration. * src/abg-ir.cc (decl_base::decl_base, scope_decl::scope_decl) (type_decl::type_decl, scope_type_decl::scope_type_decl): Initialize mangled name. (namespace_decl::namespace_decl): Initialize visibility. (qualified_type_def::qualified_type_def) (pointer_type_def::pointer_type_def) (reference_type_def::reference_type_def): By default, set the visibility to the same as for the underlying type. (enum_type_decl::enum_type_decl, typedef_decl::typedef_decl): Initialize mangled name. (var_decl::var_decl, var_decl::operator==, var_decl::~var_decl): New definitions. * src/abg-reader.cc (read_visibility, read_binding, handle_var_decl): New definitions. (read_file): Handle var-decl elements. * src/abg-writer.cc (write_location): Rename write_decl_location into this. (write_var_decl, write_visibility, write_binding): New definitions. (write_decl, write_type_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl): Adjust to use write_location. * tests/data/test-read-write/test8.xml: New test input. * tests/test-read-write.cc: De-serialize the above and serialize it back and ensure both are equal. * tests/Makefile.am: add tests/data/test-read-write/test8.xml to the distribution.
2013-04-02 12:24:08 +00:00
virtual string
get_pretty_representation() const;
virtual void
traverse(ir_node_visitor& v);
Support var decl & mangled_name attributes * src/abg-ir.h (decl_base::binding, decl_base::get_mangled_name) (decl_base::set_mangled_name, decl_base::m_mangled_name): New declarations. (scope_decl::scope_decl: type_decl::type_decl) (scope_type_decl::scope_type_decl, typedef_decl::typedef_decl): Initialize mangled_name. (namespace_decl::namespace_decl): Initialize visibility. (class var_decl): New declaration. * src/abg-ir.cc (decl_base::decl_base, scope_decl::scope_decl) (type_decl::type_decl, scope_type_decl::scope_type_decl): Initialize mangled name. (namespace_decl::namespace_decl): Initialize visibility. (qualified_type_def::qualified_type_def) (pointer_type_def::pointer_type_def) (reference_type_def::reference_type_def): By default, set the visibility to the same as for the underlying type. (enum_type_decl::enum_type_decl, typedef_decl::typedef_decl): Initialize mangled name. (var_decl::var_decl, var_decl::operator==, var_decl::~var_decl): New definitions. * src/abg-reader.cc (read_visibility, read_binding, handle_var_decl): New definitions. (read_file): Handle var-decl elements. * src/abg-writer.cc (write_location): Rename write_decl_location into this. (write_var_decl, write_visibility, write_binding): New definitions. (write_decl, write_type_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl): Adjust to use write_location. * tests/data/test-read-write/test8.xml: New test input. * tests/test-read-write.cc: De-serialize the above and serialize it back and ensure both are equal. * tests/Makefile.am: add tests/data/test-read-write/test8.xml to the distribution.
2013-04-02 12:24:08 +00:00
virtual ~var_decl();
}; // end class var_decl
Support var decl & mangled_name attributes * src/abg-ir.h (decl_base::binding, decl_base::get_mangled_name) (decl_base::set_mangled_name, decl_base::m_mangled_name): New declarations. (scope_decl::scope_decl: type_decl::type_decl) (scope_type_decl::scope_type_decl, typedef_decl::typedef_decl): Initialize mangled_name. (namespace_decl::namespace_decl): Initialize visibility. (class var_decl): New declaration. * src/abg-ir.cc (decl_base::decl_base, scope_decl::scope_decl) (type_decl::type_decl, scope_type_decl::scope_type_decl): Initialize mangled name. (namespace_decl::namespace_decl): Initialize visibility. (qualified_type_def::qualified_type_def) (pointer_type_def::pointer_type_def) (reference_type_def::reference_type_def): By default, set the visibility to the same as for the underlying type. (enum_type_decl::enum_type_decl, typedef_decl::typedef_decl): Initialize mangled name. (var_decl::var_decl, var_decl::operator==, var_decl::~var_decl): New definitions. * src/abg-reader.cc (read_visibility, read_binding, handle_var_decl): New definitions. (read_file): Handle var-decl elements. * src/abg-writer.cc (write_location): Rename write_decl_location into this. (write_var_decl, write_visibility, write_binding): New definitions. (write_decl, write_type_decl, write_qualified_type_def) (write_pointer_type_def, write_reference_type_def) (write_enum_type_decl, write_typedef_decl): Adjust to use write_location. * tests/data/test-read-write/test8.xml: New test input. * tests/test-read-write.cc: De-serialize the above and serialize it back and ensure both are equal. * tests/Makefile.am: add tests/data/test-read-write/test8.xml to the distribution.
2013-04-02 12:24:08 +00:00
/// Convenience typedef for a shared pointer on a @ref function_decl
Support diff/reporting for functions & better diff/report in general * include/abg-ir.h ({decl_base, class_decl, function_decl}::get_pretty_representation): New virtual member to get a pretty string name for decls & types. (class_decl::parameter): Add an index to the parameter type. (class_decl::parameter::parameter): Update the constructor for the change above. (class_decl::parameter::{get_index, set_index}): Accessors for the new index. (class_decl::parameter::operator==): Take in account the index. (function_type::append_parameter): Set the index of the parameter here. * include/abg-fwd.h (get_type_name): New declaration. * src/abg-ir.cc (get_type_name): New definition. ({decl_base, function_decl, class_decl}::get_pretty_representation): New implementations. (method_type::set_class_type): Update this to set function parameter's index by default. (function_decl::append_parameters): Use the append_parameter method from function_type. * include/abg-comparison.h (class function_decl_diff): New type declaration. * src/abg-comparison.cc (compute_diff_for_decls, compute_diff): New definitions. ({pointer_diff, class_diff, scope_diff}::report): Use the new get_pretty_representation. Output a prettier report. (function_decl_diff::priv): New type. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at, ensure_lookup_tables_populated, function_decl_diff, first_function_decl, second_function_decl, changed_parms, removed_parms, added_parms, length, report}): New member function definitions. * src/abg-hash.cc (function_decl::parameter::hash): Update this to take the index in account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
typedef shared_ptr<function_decl> function_decl_sptr;
/// Abstraction for a function declaration.
class function_decl : public virtual decl_base
{
protected:
shared_ptr<function_type> type_;
private:
bool declared_inline_;
decl_base::binding binding_;
public:
/// Hasher for function_decl
struct hash;
/// Equality functor to compare pointers to function_decl
struct ptr_equal;
Support diff/reporting for functions & better diff/report in general * include/abg-ir.h ({decl_base, class_decl, function_decl}::get_pretty_representation): New virtual member to get a pretty string name for decls & types. (class_decl::parameter): Add an index to the parameter type. (class_decl::parameter::parameter): Update the constructor for the change above. (class_decl::parameter::{get_index, set_index}): Accessors for the new index. (class_decl::parameter::operator==): Take in account the index. (function_type::append_parameter): Set the index of the parameter here. * include/abg-fwd.h (get_type_name): New declaration. * src/abg-ir.cc (get_type_name): New definition. ({decl_base, function_decl, class_decl}::get_pretty_representation): New implementations. (method_type::set_class_type): Update this to set function parameter's index by default. (function_decl::append_parameters): Use the append_parameter method from function_type. * include/abg-comparison.h (class function_decl_diff): New type declaration. * src/abg-comparison.cc (compute_diff_for_decls, compute_diff): New definitions. ({pointer_diff, class_diff, scope_diff}::report): Use the new get_pretty_representation. Output a prettier report. (function_decl_diff::priv): New type. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at, ensure_lookup_tables_populated, function_decl_diff, first_function_decl, second_function_decl, changed_parms, removed_parms, added_parms, length, report}): New member function definitions. * src/abg-hash.cc (function_decl::parameter::hash): Update this to take the index in account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
class parameter;
/// Convenience typedef for a shared pointer on a @ref
/// function_decl::parameter
Support diff/reporting for functions & better diff/report in general * include/abg-ir.h ({decl_base, class_decl, function_decl}::get_pretty_representation): New virtual member to get a pretty string name for decls & types. (class_decl::parameter): Add an index to the parameter type. (class_decl::parameter::parameter): Update the constructor for the change above. (class_decl::parameter::{get_index, set_index}): Accessors for the new index. (class_decl::parameter::operator==): Take in account the index. (function_type::append_parameter): Set the index of the parameter here. * include/abg-fwd.h (get_type_name): New declaration. * src/abg-ir.cc (get_type_name): New definition. ({decl_base, function_decl, class_decl}::get_pretty_representation): New implementations. (method_type::set_class_type): Update this to set function parameter's index by default. (function_decl::append_parameters): Use the append_parameter method from function_type. * include/abg-comparison.h (class function_decl_diff): New type declaration. * src/abg-comparison.cc (compute_diff_for_decls, compute_diff): New definitions. ({pointer_diff, class_diff, scope_diff}::report): Use the new get_pretty_representation. Output a prettier report. (function_decl_diff::priv): New type. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at, ensure_lookup_tables_populated, function_decl_diff, first_function_decl, second_function_decl, changed_parms, removed_parms, added_parms, length, report}): New member function definitions. * src/abg-hash.cc (function_decl::parameter::hash): Update this to take the index in account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
typedef shared_ptr<parameter> parameter_sptr;
/// Convenience typedef for a vector of @ref parameter_sptr
Support diff/reporting for functions & better diff/report in general * include/abg-ir.h ({decl_base, class_decl, function_decl}::get_pretty_representation): New virtual member to get a pretty string name for decls & types. (class_decl::parameter): Add an index to the parameter type. (class_decl::parameter::parameter): Update the constructor for the change above. (class_decl::parameter::{get_index, set_index}): Accessors for the new index. (class_decl::parameter::operator==): Take in account the index. (function_type::append_parameter): Set the index of the parameter here. * include/abg-fwd.h (get_type_name): New declaration. * src/abg-ir.cc (get_type_name): New definition. ({decl_base, function_decl, class_decl}::get_pretty_representation): New implementations. (method_type::set_class_type): Update this to set function parameter's index by default. (function_decl::append_parameters): Use the append_parameter method from function_type. * include/abg-comparison.h (class function_decl_diff): New type declaration. * src/abg-comparison.cc (compute_diff_for_decls, compute_diff): New definitions. ({pointer_diff, class_diff, scope_diff}::report): Use the new get_pretty_representation. Output a prettier report. (function_decl_diff::priv): New type. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at, ensure_lookup_tables_populated, function_decl_diff, first_function_decl, second_function_decl, changed_parms, removed_parms, added_parms, length, report}): New member function definitions. * src/abg-hash.cc (function_decl::parameter::hash): Update this to take the index in account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
typedef std::vector<parameter_sptr> parameters;
/// Abtraction for the parameter of a function.
class parameter
{
shared_ptr<type_base> type_;
Support diff/reporting for functions & better diff/report in general * include/abg-ir.h ({decl_base, class_decl, function_decl}::get_pretty_representation): New virtual member to get a pretty string name for decls & types. (class_decl::parameter): Add an index to the parameter type. (class_decl::parameter::parameter): Update the constructor for the change above. (class_decl::parameter::{get_index, set_index}): Accessors for the new index. (class_decl::parameter::operator==): Take in account the index. (function_type::append_parameter): Set the index of the parameter here. * include/abg-fwd.h (get_type_name): New declaration. * src/abg-ir.cc (get_type_name): New definition. ({decl_base, function_decl, class_decl}::get_pretty_representation): New implementations. (method_type::set_class_type): Update this to set function parameter's index by default. (function_decl::append_parameters): Use the append_parameter method from function_type. * include/abg-comparison.h (class function_decl_diff): New type declaration. * src/abg-comparison.cc (compute_diff_for_decls, compute_diff): New definitions. ({pointer_diff, class_diff, scope_diff}::report): Use the new get_pretty_representation. Output a prettier report. (function_decl_diff::priv): New type. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at, ensure_lookup_tables_populated, function_decl_diff, first_function_decl, second_function_decl, changed_parms, removed_parms, added_parms, length, report}): New member function definitions. * src/abg-hash.cc (function_decl::parameter::hash): Update this to take the index in account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
unsigned index_;
bool variadic_marker_;
std::string name_;
location location_;
bool artificial_;
public:
/// Hasher for an instance of function::parameter
struct hash;
Support diff/reporting for functions & better diff/report in general * include/abg-ir.h ({decl_base, class_decl, function_decl}::get_pretty_representation): New virtual member to get a pretty string name for decls & types. (class_decl::parameter): Add an index to the parameter type. (class_decl::parameter::parameter): Update the constructor for the change above. (class_decl::parameter::{get_index, set_index}): Accessors for the new index. (class_decl::parameter::operator==): Take in account the index. (function_type::append_parameter): Set the index of the parameter here. * include/abg-fwd.h (get_type_name): New declaration. * src/abg-ir.cc (get_type_name): New definition. ({decl_base, function_decl, class_decl}::get_pretty_representation): New implementations. (method_type::set_class_type): Update this to set function parameter's index by default. (function_decl::append_parameters): Use the append_parameter method from function_type. * include/abg-comparison.h (class function_decl_diff): New type declaration. * src/abg-comparison.cc (compute_diff_for_decls, compute_diff): New definitions. ({pointer_diff, class_diff, scope_diff}::report): Use the new get_pretty_representation. Output a prettier report. (function_decl_diff::priv): New type. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at, ensure_lookup_tables_populated, function_decl_diff, first_function_decl, second_function_decl, changed_parms, removed_parms, added_parms, length, report}): New member function definitions. * src/abg-hash.cc (function_decl::parameter::hash): Update this to take the index in account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
parameter(const shared_ptr<type_base> type,
unsigned index,
const std::string& name,
location loc, bool variadic_marker = false)
Support diff/reporting for functions & better diff/report in general * include/abg-ir.h ({decl_base, class_decl, function_decl}::get_pretty_representation): New virtual member to get a pretty string name for decls & types. (class_decl::parameter): Add an index to the parameter type. (class_decl::parameter::parameter): Update the constructor for the change above. (class_decl::parameter::{get_index, set_index}): Accessors for the new index. (class_decl::parameter::operator==): Take in account the index. (function_type::append_parameter): Set the index of the parameter here. * include/abg-fwd.h (get_type_name): New declaration. * src/abg-ir.cc (get_type_name): New definition. ({decl_base, function_decl, class_decl}::get_pretty_representation): New implementations. (method_type::set_class_type): Update this to set function parameter's index by default. (function_decl::append_parameters): Use the append_parameter method from function_type. * include/abg-comparison.h (class function_decl_diff): New type declaration. * src/abg-comparison.cc (compute_diff_for_decls, compute_diff): New definitions. ({pointer_diff, class_diff, scope_diff}::report): Use the new get_pretty_representation. Output a prettier report. (function_decl_diff::priv): New type. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at, ensure_lookup_tables_populated, function_decl_diff, first_function_decl, second_function_decl, changed_parms, removed_parms, added_parms, length, report}): New member function definitions. * src/abg-hash.cc (function_decl::parameter::hash): Update this to take the index in account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
: type_(type), index_(index), variadic_marker_ (variadic_marker),
name_(name), location_(loc),
artificial_(false)
{}
Support diff/reporting for functions & better diff/report in general * include/abg-ir.h ({decl_base, class_decl, function_decl}::get_pretty_representation): New virtual member to get a pretty string name for decls & types. (class_decl::parameter): Add an index to the parameter type. (class_decl::parameter::parameter): Update the constructor for the change above. (class_decl::parameter::{get_index, set_index}): Accessors for the new index. (class_decl::parameter::operator==): Take in account the index. (function_type::append_parameter): Set the index of the parameter here. * include/abg-fwd.h (get_type_name): New declaration. * src/abg-ir.cc (get_type_name): New definition. ({decl_base, function_decl, class_decl}::get_pretty_representation): New implementations. (method_type::set_class_type): Update this to set function parameter's index by default. (function_decl::append_parameters): Use the append_parameter method from function_type. * include/abg-comparison.h (class function_decl_diff): New type declaration. * src/abg-comparison.cc (compute_diff_for_decls, compute_diff): New definitions. ({pointer_diff, class_diff, scope_diff}::report): Use the new get_pretty_representation. Output a prettier report. (function_decl_diff::priv): New type. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at, ensure_lookup_tables_populated, function_decl_diff, first_function_decl, second_function_decl, changed_parms, removed_parms, added_parms, length, report}): New member function definitions. * src/abg-hash.cc (function_decl::parameter::hash): Update this to take the index in account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
parameter(const shared_ptr<type_base> type,
const std::string& name,
location loc, bool variadic_marker = false,
bool is_artificial = false)
Support diff/reporting for functions & better diff/report in general * include/abg-ir.h ({decl_base, class_decl, function_decl}::get_pretty_representation): New virtual member to get a pretty string name for decls & types. (class_decl::parameter): Add an index to the parameter type. (class_decl::parameter::parameter): Update the constructor for the change above. (class_decl::parameter::{get_index, set_index}): Accessors for the new index. (class_decl::parameter::operator==): Take in account the index. (function_type::append_parameter): Set the index of the parameter here. * include/abg-fwd.h (get_type_name): New declaration. * src/abg-ir.cc (get_type_name): New definition. ({decl_base, function_decl, class_decl}::get_pretty_representation): New implementations. (method_type::set_class_type): Update this to set function parameter's index by default. (function_decl::append_parameters): Use the append_parameter method from function_type. * include/abg-comparison.h (class function_decl_diff): New type declaration. * src/abg-comparison.cc (compute_diff_for_decls, compute_diff): New definitions. ({pointer_diff, class_diff, scope_diff}::report): Use the new get_pretty_representation. Output a prettier report. (function_decl_diff::priv): New type. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at, ensure_lookup_tables_populated, function_decl_diff, first_function_decl, second_function_decl, changed_parms, removed_parms, added_parms, length, report}): New member function definitions. * src/abg-hash.cc (function_decl::parameter::hash): Update this to take the index in account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
: type_(type), index_(0), variadic_marker_ (variadic_marker),
name_(name), location_(loc), artificial_(is_artificial)
Support diff/reporting for functions & better diff/report in general * include/abg-ir.h ({decl_base, class_decl, function_decl}::get_pretty_representation): New virtual member to get a pretty string name for decls & types. (class_decl::parameter): Add an index to the parameter type. (class_decl::parameter::parameter): Update the constructor for the change above. (class_decl::parameter::{get_index, set_index}): Accessors for the new index. (class_decl::parameter::operator==): Take in account the index. (function_type::append_parameter): Set the index of the parameter here. * include/abg-fwd.h (get_type_name): New declaration. * src/abg-ir.cc (get_type_name): New definition. ({decl_base, function_decl, class_decl}::get_pretty_representation): New implementations. (method_type::set_class_type): Update this to set function parameter's index by default. (function_decl::append_parameters): Use the append_parameter method from function_type. * include/abg-comparison.h (class function_decl_diff): New type declaration. * src/abg-comparison.cc (compute_diff_for_decls, compute_diff): New definitions. ({pointer_diff, class_diff, scope_diff}::report): Use the new get_pretty_representation. Output a prettier report. (function_decl_diff::priv): New type. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at, ensure_lookup_tables_populated, function_decl_diff, first_function_decl, second_function_decl, changed_parms, removed_parms, added_parms, length, report}): New member function definitions. * src/abg-hash.cc (function_decl::parameter::hash): Update this to take the index in account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
{}
parameter(const shared_ptr<type_base> type,
unsigned index = 0,
bool variadic_marker = false)
: type_(type),
Support diff/reporting for functions & better diff/report in general * include/abg-ir.h ({decl_base, class_decl, function_decl}::get_pretty_representation): New virtual member to get a pretty string name for decls & types. (class_decl::parameter): Add an index to the parameter type. (class_decl::parameter::parameter): Update the constructor for the change above. (class_decl::parameter::{get_index, set_index}): Accessors for the new index. (class_decl::parameter::operator==): Take in account the index. (function_type::append_parameter): Set the index of the parameter here. * include/abg-fwd.h (get_type_name): New declaration. * src/abg-ir.cc (get_type_name): New definition. ({decl_base, function_decl, class_decl}::get_pretty_representation): New implementations. (method_type::set_class_type): Update this to set function parameter's index by default. (function_decl::append_parameters): Use the append_parameter method from function_type. * include/abg-comparison.h (class function_decl_diff): New type declaration. * src/abg-comparison.cc (compute_diff_for_decls, compute_diff): New definitions. ({pointer_diff, class_diff, scope_diff}::report): Use the new get_pretty_representation. Output a prettier report. (function_decl_diff::priv): New type. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at, ensure_lookup_tables_populated, function_decl_diff, first_function_decl, second_function_decl, changed_parms, removed_parms, added_parms, length, report}): New member function definitions. * src/abg-hash.cc (function_decl::parameter::hash): Update this to take the index in account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
index_(index),
variadic_marker_ (variadic_marker),
artificial_(false)
{}
Support method type/decl, variadic functions, class declarations-only * src/abg-ir.h (function_decl::parameter::parameter): New constructor with variadic parameter marker. (function_decl::m_type): Make this protected to let method_decl inheriting class to access it. (function_decl::get_type): Move this out-of-line. (class method_type, method_type_hash): New types. (enum class_decl::access_specifier): Add no_access new enumerator. (class_decl::data_member::data_member): Move this out-of-line. (class_decl::data_member::~data_member): Declare virtual destructor. (class method_decl): New class. (class member_function): Make this inherit method_decl, instead of function_decl. (class_decl::class_decl): New constructors. (class_decl::{hashing_started, is_declaration_only, set_earlier_declaration, get_earlier_declaration}): New methods. * src/abg-ir.cc (add_decl_to_scope): If a decl is already in a scope, don't add it to this scope. (get_global_scope): Make this work when passed an instance of global_scope. (dynamic_type_hash::operator()): Add support for method_type. (method_type::{method_type, set_class_type, ~method_type, }) (method_type_hash::operator()): New defintions. (function_decl::get_type, class_decl::class_decl): Move these out-of-line here. (class_decl::method_decl::{method_decl, ~method_decl, get_type}): New definitions. (class_decl::member_function::member_function): Move this out-of-line here. Support method_decl. (class_decl::data_member::data_member): Likewise. (class_decl_hash::operator()): Guard this against endless loop. * src/abg-reader.cc (write_class_is_declaration_only): New static function. (write_var_decl): Take a flag to write the mangled name or not. (write_function_decl): Take a flag to skip the first parameter. (write_cdtor_const_static): Use 'yes' instead of 'true' as value of the properties. (write_decl, write_function_template_decl): Adjust wrt the new signatures of write_var_decl and write_function_decl. (write_enum_type_decl): Simplify call to write_location. (write_class_decl): Support serializing declaration-only classes. * src/abg-writer.cc: * tests/data/test-read-write/test17.xml: New test input. * tests/test-read-write.cc: De-serialize the above, and serialize it back. * tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
const type_base_sptr&
get_type()const
{return type_;}
/// @return a copy of the type name of the parameter.
const string
get_type_name() const
{
string str;
if (variadic_marker_)
str = "...";
else
{
type_base_sptr t = get_type();
assert(t);
str += abigail::get_type_name(t);
}
return str;
}
/// @return a copy of the pretty representation of the type of the
/// parameter.
const string
get_type_pretty_representation()
{
string str;
if (variadic_marker_)
str = "...";
else
{
type_base_sptr t = get_type();
assert(t);
str += get_type_declaration(t)->get_pretty_representation();
}
return str;
}
const shared_ptr<type_base>&
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
get_type()
{return type_;}
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
Support diff/reporting for functions & better diff/report in general * include/abg-ir.h ({decl_base, class_decl, function_decl}::get_pretty_representation): New virtual member to get a pretty string name for decls & types. (class_decl::parameter): Add an index to the parameter type. (class_decl::parameter::parameter): Update the constructor for the change above. (class_decl::parameter::{get_index, set_index}): Accessors for the new index. (class_decl::parameter::operator==): Take in account the index. (function_type::append_parameter): Set the index of the parameter here. * include/abg-fwd.h (get_type_name): New declaration. * src/abg-ir.cc (get_type_name): New definition. ({decl_base, function_decl, class_decl}::get_pretty_representation): New implementations. (method_type::set_class_type): Update this to set function parameter's index by default. (function_decl::append_parameters): Use the append_parameter method from function_type. * include/abg-comparison.h (class function_decl_diff): New type declaration. * src/abg-comparison.cc (compute_diff_for_decls, compute_diff): New definitions. ({pointer_diff, class_diff, scope_diff}::report): Use the new get_pretty_representation. Output a prettier report. (function_decl_diff::priv): New type. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at, ensure_lookup_tables_populated, function_decl_diff, first_function_decl, second_function_decl, changed_parms, removed_parms, added_parms, length, report}): New member function definitions. * src/abg-hash.cc (function_decl::parameter::hash): Update this to take the index in account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
unsigned
get_index() const
{return index_;}
void
set_index(unsigned i)
{index_ = i;}
const std::string&
get_name() const
{return name_;}
location
get_location() const
{return location_;}
/// Test if the parameter is artificial.
///
/// Being artificial means the parameter was not explicitely
/// mentionned in the source code, but was rather artificially
/// created by the compiler.
///
/// @return true if the parameter is artificial, false otherwise.
bool
get_artificial() const
{return artificial_;}
/// Getter for the artificial-ness of the parameter.
///
/// Being artificial means the parameter was not explicitely
/// mentionned in the source code, but was rather artificially
/// created by the compiler.
///
/// @param f set to true if the parameter is artificial.
void
set_artificial(bool f)
{artificial_ = f;}
Initial Support for class declarations * src/abg-ir.h (scope_decl::scope_decl) (scope_type_decl::scope_type_decl): Don't set mangled name for scope_decl instances as it doesn't make sense. (var_decl::var_decl): Pass the type shared pointer by value. (struct var_decl_hash, function_decl::parameter::operator==) (struct function_decl::parameter_hash, function_decl::operator==) (struct function_decl_hash, class class_decl, struct class_decl_hash): New declarations. * src/abg-ir.cc (scope_type_decl::scope_type_decl): Don't set the mangled name. It doesn't make sense for scope_decls. (dynamic_type_hash::operator): Fix comment. Run the hashing for scope_type_decl instances *after* running it for class_decl instance, otherwise, the class_decl instances case will never get hit. (var_decl::var_decl): Pass the type shared pointer by value. (function_decl::operator==, class_decl::operator==) (class_decl_hash::operator()): New fns. * src/abg-libxml-utils.h (get_xml_node_depth): Declare new fn. (XML_READER_GET_ATTRIBUTE): Fix comment. (XML_NODE_GET_ATTRIBUTE): New getter macro. * src/abg-libxml-utils.cc (get_xml_node_depth): New definition. * src/abg-reader.cc (update_read_context) (update_depth_info_of_read_context, read_visibility, read_binding) (read_access, read_size_and_alignment, read_static) (read_var_offset_in_bits, read_cdtor_const, build_function_decl) ( build_var_decl, build_type_decl, build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_enum_type_decl, build_typedef_decl, build_class_decl) (build_type, handle_class_decl): New functions or overloads. (handle_element): Update to handle "class-decl" xml elements. * src/abg-writer.cc (write_size_and_alignment, write_access) (write_class, do_indent_to_level, get_indent_to_level): New fns. (write_decl): Update to serialize instances of class_decl. (write_type_decl, write_pointer_type_def) (write_reference_type_def): Use the new write_size_and_alignment instead of writing the attributes directly. * tests/data/test-read-write/test10.xml: New test file. * tests/Makefile.am: Add tests/data/test-read-write/test10.xml to the build system. * tests/test-read-write.cc (in_out_spec): De-serialize data/test-read-write/test10.xml, serialize it back into output/test-read-write/test10.xml, and compare the two output that should be identical.
2013-04-11 20:02:08 +00:00
bool
operator==(const parameter& o) const
Support diff/reporting for functions & better diff/report in general * include/abg-ir.h ({decl_base, class_decl, function_decl}::get_pretty_representation): New virtual member to get a pretty string name for decls & types. (class_decl::parameter): Add an index to the parameter type. (class_decl::parameter::parameter): Update the constructor for the change above. (class_decl::parameter::{get_index, set_index}): Accessors for the new index. (class_decl::parameter::operator==): Take in account the index. (function_type::append_parameter): Set the index of the parameter here. * include/abg-fwd.h (get_type_name): New declaration. * src/abg-ir.cc (get_type_name): New definition. ({decl_base, function_decl, class_decl}::get_pretty_representation): New implementations. (method_type::set_class_type): Update this to set function parameter's index by default. (function_decl::append_parameters): Use the append_parameter method from function_type. * include/abg-comparison.h (class function_decl_diff): New type declaration. * src/abg-comparison.cc (compute_diff_for_decls, compute_diff): New definitions. ({pointer_diff, class_diff, scope_diff}::report): Use the new get_pretty_representation. Output a prettier report. (function_decl_diff::priv): New type. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at, ensure_lookup_tables_populated, function_decl_diff, first_function_decl, second_function_decl, changed_parms, removed_parms, added_parms, length, report}): New member function definitions. * src/abg-hash.cc (function_decl::parameter::hash): Update this to take the index in account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
{
if ((get_variadic_marker() != o.get_variadic_marker())
|| (get_index() != o.get_index())
|| (!!get_type() != !!o.get_type())
|| (get_type() && (*get_type() != *o.get_type())))
return false;
return true;
Support diff/reporting for functions & better diff/report in general * include/abg-ir.h ({decl_base, class_decl, function_decl}::get_pretty_representation): New virtual member to get a pretty string name for decls & types. (class_decl::parameter): Add an index to the parameter type. (class_decl::parameter::parameter): Update the constructor for the change above. (class_decl::parameter::{get_index, set_index}): Accessors for the new index. (class_decl::parameter::operator==): Take in account the index. (function_type::append_parameter): Set the index of the parameter here. * include/abg-fwd.h (get_type_name): New declaration. * src/abg-ir.cc (get_type_name): New definition. ({decl_base, function_decl, class_decl}::get_pretty_representation): New implementations. (method_type::set_class_type): Update this to set function parameter's index by default. (function_decl::append_parameters): Use the append_parameter method from function_type. * include/abg-comparison.h (class function_decl_diff): New type declaration. * src/abg-comparison.cc (compute_diff_for_decls, compute_diff): New definitions. ({pointer_diff, class_diff, scope_diff}::report): Use the new get_pretty_representation. Output a prettier report. (function_decl_diff::priv): New type. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at, ensure_lookup_tables_populated, function_decl_diff, first_function_decl, second_function_decl, changed_parms, removed_parms, added_parms, length, report}): New member function definitions. * src/abg-hash.cc (function_decl::parameter::hash): Update this to take the index in account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
}
Initial Support for class declarations * src/abg-ir.h (scope_decl::scope_decl) (scope_type_decl::scope_type_decl): Don't set mangled name for scope_decl instances as it doesn't make sense. (var_decl::var_decl): Pass the type shared pointer by value. (struct var_decl_hash, function_decl::parameter::operator==) (struct function_decl::parameter_hash, function_decl::operator==) (struct function_decl_hash, class class_decl, struct class_decl_hash): New declarations. * src/abg-ir.cc (scope_type_decl::scope_type_decl): Don't set the mangled name. It doesn't make sense for scope_decls. (dynamic_type_hash::operator): Fix comment. Run the hashing for scope_type_decl instances *after* running it for class_decl instance, otherwise, the class_decl instances case will never get hit. (var_decl::var_decl): Pass the type shared pointer by value. (function_decl::operator==, class_decl::operator==) (class_decl_hash::operator()): New fns. * src/abg-libxml-utils.h (get_xml_node_depth): Declare new fn. (XML_READER_GET_ATTRIBUTE): Fix comment. (XML_NODE_GET_ATTRIBUTE): New getter macro. * src/abg-libxml-utils.cc (get_xml_node_depth): New definition. * src/abg-reader.cc (update_read_context) (update_depth_info_of_read_context, read_visibility, read_binding) (read_access, read_size_and_alignment, read_static) (read_var_offset_in_bits, read_cdtor_const, build_function_decl) ( build_var_decl, build_type_decl, build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_enum_type_decl, build_typedef_decl, build_class_decl) (build_type, handle_class_decl): New functions or overloads. (handle_element): Update to handle "class-decl" xml elements. * src/abg-writer.cc (write_size_and_alignment, write_access) (write_class, do_indent_to_level, get_indent_to_level): New fns. (write_decl): Update to serialize instances of class_decl. (write_type_decl, write_pointer_type_def) (write_reference_type_def): Use the new write_size_and_alignment instead of writing the attributes directly. * tests/data/test-read-write/test10.xml: New test file. * tests/Makefile.am: Add tests/data/test-read-write/test10.xml to the build system. * tests/test-read-write.cc (in_out_spec): De-serialize data/test-read-write/test10.xml, serialize it back into output/test-read-write/test10.xml, and compare the two output that should be identical.
2013-04-11 20:02:08 +00:00
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
bool
get_variadic_marker() const
{return variadic_marker_;}
};
function_decl(const std::string& name,
const std::vector<parameter_sptr>& parms,
shared_ptr<type_base> return_type,
size_t fptr_size_in_bits,
size_t fptr_align_in_bits,
bool declared_inline,
location locus,
const std::string& mangled_name = "",
visibility vis = VISIBILITY_DEFAULT,
binding bind = BINDING_GLOBAL);
function_decl(const std::string& name,
shared_ptr<function_type> function_type, bool declared_inline,
location locus, const std::string& mangled_name = "",
visibility vis = VISIBILITY_DEFAULT,
binding bind = BINDING_GLOBAL)
: decl_base(name, locus, mangled_name, vis),
type_(function_type),
declared_inline_(declared_inline),
binding_(bind)
{}
function_decl(const std::string& name,
shared_ptr<type_base> fn_type,
bool declared_inline,
location locus,
const std::string& mangled_name = "",
visibility vis = VISIBILITY_DEFAULT,
binding bind = BINDING_GLOBAL);
Support diff/reporting for functions & better diff/report in general * include/abg-ir.h ({decl_base, class_decl, function_decl}::get_pretty_representation): New virtual member to get a pretty string name for decls & types. (class_decl::parameter): Add an index to the parameter type. (class_decl::parameter::parameter): Update the constructor for the change above. (class_decl::parameter::{get_index, set_index}): Accessors for the new index. (class_decl::parameter::operator==): Take in account the index. (function_type::append_parameter): Set the index of the parameter here. * include/abg-fwd.h (get_type_name): New declaration. * src/abg-ir.cc (get_type_name): New definition. ({decl_base, function_decl, class_decl}::get_pretty_representation): New implementations. (method_type::set_class_type): Update this to set function parameter's index by default. (function_decl::append_parameters): Use the append_parameter method from function_type. * include/abg-comparison.h (class function_decl_diff): New type declaration. * src/abg-comparison.cc (compute_diff_for_decls, compute_diff): New definitions. ({pointer_diff, class_diff, scope_diff}::report): Use the new get_pretty_representation. Output a prettier report. (function_decl_diff::priv): New type. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at, ensure_lookup_tables_populated, function_decl_diff, first_function_decl, second_function_decl, changed_parms, removed_parms, added_parms, length, report}): New member function definitions. * src/abg-hash.cc (function_decl::parameter::hash): Update this to take the index in account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
virtual string
get_pretty_representation() const;
const std::vector<parameter_sptr >&
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
get_parameters() const;
void
Support diff/reporting for functions & better diff/report in general * include/abg-ir.h ({decl_base, class_decl, function_decl}::get_pretty_representation): New virtual member to get a pretty string name for decls & types. (class_decl::parameter): Add an index to the parameter type. (class_decl::parameter::parameter): Update the constructor for the change above. (class_decl::parameter::{get_index, set_index}): Accessors for the new index. (class_decl::parameter::operator==): Take in account the index. (function_type::append_parameter): Set the index of the parameter here. * include/abg-fwd.h (get_type_name): New declaration. * src/abg-ir.cc (get_type_name): New definition. ({decl_base, function_decl, class_decl}::get_pretty_representation): New implementations. (method_type::set_class_type): Update this to set function parameter's index by default. (function_decl::append_parameters): Use the append_parameter method from function_type. * include/abg-comparison.h (class function_decl_diff): New type declaration. * src/abg-comparison.cc (compute_diff_for_decls, compute_diff): New definitions. ({pointer_diff, class_diff, scope_diff}::report): Use the new get_pretty_representation. Output a prettier report. (function_decl_diff::priv): New type. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at, ensure_lookup_tables_populated, function_decl_diff, first_function_decl, second_function_decl, changed_parms, removed_parms, added_parms, length, report}): New member function definitions. * src/abg-hash.cc (function_decl::parameter::hash): Update this to take the index in account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
append_parameter(parameter_sptr parm);
void
Support diff/reporting for functions & better diff/report in general * include/abg-ir.h ({decl_base, class_decl, function_decl}::get_pretty_representation): New virtual member to get a pretty string name for decls & types. (class_decl::parameter): Add an index to the parameter type. (class_decl::parameter::parameter): Update the constructor for the change above. (class_decl::parameter::{get_index, set_index}): Accessors for the new index. (class_decl::parameter::operator==): Take in account the index. (function_type::append_parameter): Set the index of the parameter here. * include/abg-fwd.h (get_type_name): New declaration. * src/abg-ir.cc (get_type_name): New definition. ({decl_base, function_decl, class_decl}::get_pretty_representation): New implementations. (method_type::set_class_type): Update this to set function parameter's index by default. (function_decl::append_parameters): Use the append_parameter method from function_type. * include/abg-comparison.h (class function_decl_diff): New type declaration. * src/abg-comparison.cc (compute_diff_for_decls, compute_diff): New definitions. ({pointer_diff, class_diff, scope_diff}::report): Use the new get_pretty_representation. Output a prettier report. (function_decl_diff::priv): New type. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at, ensure_lookup_tables_populated, function_decl_diff, first_function_decl, second_function_decl, changed_parms, removed_parms, added_parms, length, report}): New member function definitions. * src/abg-hash.cc (function_decl::parameter::hash): Update this to take the index in account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
append_parameters(std::vector<parameter_sptr >& parms);
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
const shared_ptr<function_type>
Support method type/decl, variadic functions, class declarations-only * src/abg-ir.h (function_decl::parameter::parameter): New constructor with variadic parameter marker. (function_decl::m_type): Make this protected to let method_decl inheriting class to access it. (function_decl::get_type): Move this out-of-line. (class method_type, method_type_hash): New types. (enum class_decl::access_specifier): Add no_access new enumerator. (class_decl::data_member::data_member): Move this out-of-line. (class_decl::data_member::~data_member): Declare virtual destructor. (class method_decl): New class. (class member_function): Make this inherit method_decl, instead of function_decl. (class_decl::class_decl): New constructors. (class_decl::{hashing_started, is_declaration_only, set_earlier_declaration, get_earlier_declaration}): New methods. * src/abg-ir.cc (add_decl_to_scope): If a decl is already in a scope, don't add it to this scope. (get_global_scope): Make this work when passed an instance of global_scope. (dynamic_type_hash::operator()): Add support for method_type. (method_type::{method_type, set_class_type, ~method_type, }) (method_type_hash::operator()): New defintions. (function_decl::get_type, class_decl::class_decl): Move these out-of-line here. (class_decl::method_decl::{method_decl, ~method_decl, get_type}): New definitions. (class_decl::member_function::member_function): Move this out-of-line here. Support method_decl. (class_decl::data_member::data_member): Likewise. (class_decl_hash::operator()): Guard this against endless loop. * src/abg-reader.cc (write_class_is_declaration_only): New static function. (write_var_decl): Take a flag to write the mangled name or not. (write_function_decl): Take a flag to skip the first parameter. (write_cdtor_const_static): Use 'yes' instead of 'true' as value of the properties. (write_decl, write_function_template_decl): Adjust wrt the new signatures of write_var_decl and write_function_decl. (write_enum_type_decl): Simplify call to write_location. (write_class_decl): Support serializing declaration-only classes. * src/abg-writer.cc: * tests/data/test-read-write/test17.xml: New test input. * tests/test-read-write.cc: De-serialize the above, and serialize it back. * tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
get_type() const;
const shared_ptr<type_base>
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
get_return_type() const;
Initial support for function templates * src/abg-ir.h (function_decl::set_return_type): New inline definition. (class template_decl, struct template_decl_hash, class template_parameter, struct template_parameter_hash, struct dynamic_template_parameter_hash, struct template_parameter_shared_ptr_hash, class template_type_parameter) (struct template_type_parameter_hash, class template_non_type_parameter, struct template_non_type_parameter_hash, class template_template_parameter, struct template_template_parameter_hash, class function_template_decl) (struct function_template_decl_hash, struct fn_tmpl_shared_ptr_hash): New declarations. * src/abg-ir.cc (dynamic_type_hash::operator()): Add hashing for template template, and template type parameters. (template_decl_hash::operator, template_decl::~template_decl) (template_decl::operator==, template_parameter::operator==) (template_parameter_hash::operator()) (dynamic_template_parameter_hash::operator()) (template_type_parameter::operator==) (template_type_parameter::~template_type_parameter) (template_type_parameter_hash::operator()) (template_non_type_parameter::operator==) (template_non_type_parameter::~template_non_type_parameter) (template_non_type_parameter_hash::operator()) (template_template_parameter::operator==) (template_template_parameter::~template_template_parameter) (template_template_parameter_hash::operator()) (function_template_decl::operator==) (function_template_decl_hash::operator()) (fn_tmpl_shared_ptr_hash::operator()) (function_template_decl::~function_template_decl()): New definitions. * src/abg-reader.cc (read_context::get_fn_tmpl_decl) (read_context::key_fn_tmpl_decl): New functions. (read_context::m_fn_tmpl_map): New data member. (read_context::key_type_decl): Renamed read_context::add_type_decl into this. (read_context::push_decl_to_current_scope): Renamed read_context::finish_decl_creation into this. Add an assert. (read_context::push_and_key_type_decl): Renamed read_context::finish_type_decl_creation into this. Adjust to the use of push_decl_to_current_scope and key_type_decl. (build_function_template_decl, build_template_type_parameter) (build_template_non_type_parameter) (build_template_template_parameter, build_template_parameter) (handle_function_template_decl): New functions. (handle_element): Call handle_function_template_decl. (build_function_decl): Take a bool parameter to update depth information in parsing context. Move instantiation of function_decl before parsing its xml sub-nodes. Update the depth info in the parsing context if necessary. Push the newly intantiated decl to scope. And then parse the sub nodes. Do not forget to add the fn parameters and return type using function_decl::add_parameter and function_decl::set_return_type. (build_var_decl, build_type_decl, build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_enum_type_decl, build_typedef_decl, handled_type_decl) (handle_qualified_type_decl, handle_pointer_type_def) (handle_reference_type_def, handle_enum_type_decl) (handle_typedef_decl, handle_var_decl, handle_function_decl) (handle_class_decl): Adjust. (build_class_decl): Take a bool parameter to update depth information in parsing context. Add comment. Wait for the class members to be built, before keying (and thus hashing it) the class. (build_type): Fix logic, and adjust. * src/abg-writer.cc (write_context::type_has_existing_id) (write_context::get_id_for_fn_tmpl, write_template_type_parameter) (write_template_non_type_parameter) (write_template_template_parameter, write_template_parameter) (write_function_template_decl): New functions. (write_context::get_id_for_type): Simplify logic. (write_decl): Support writing function template. * tests/data/test-read-write/test11.xml: New test input. * tests/test-read-write.cc (InoutSpec in_out_specs[]): De-serialize the new test11.xml test, serialize it back and diff output and input. * tests/Makefile.am: Add test11.xml to the distribution.
2013-04-23 09:27:32 +00:00
void
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
set_type(shared_ptr<function_type> fn_type)
{type_ = fn_type; }
Initial support for function templates * src/abg-ir.h (function_decl::set_return_type): New inline definition. (class template_decl, struct template_decl_hash, class template_parameter, struct template_parameter_hash, struct dynamic_template_parameter_hash, struct template_parameter_shared_ptr_hash, class template_type_parameter) (struct template_type_parameter_hash, class template_non_type_parameter, struct template_non_type_parameter_hash, class template_template_parameter, struct template_template_parameter_hash, class function_template_decl) (struct function_template_decl_hash, struct fn_tmpl_shared_ptr_hash): New declarations. * src/abg-ir.cc (dynamic_type_hash::operator()): Add hashing for template template, and template type parameters. (template_decl_hash::operator, template_decl::~template_decl) (template_decl::operator==, template_parameter::operator==) (template_parameter_hash::operator()) (dynamic_template_parameter_hash::operator()) (template_type_parameter::operator==) (template_type_parameter::~template_type_parameter) (template_type_parameter_hash::operator()) (template_non_type_parameter::operator==) (template_non_type_parameter::~template_non_type_parameter) (template_non_type_parameter_hash::operator()) (template_template_parameter::operator==) (template_template_parameter::~template_template_parameter) (template_template_parameter_hash::operator()) (function_template_decl::operator==) (function_template_decl_hash::operator()) (fn_tmpl_shared_ptr_hash::operator()) (function_template_decl::~function_template_decl()): New definitions. * src/abg-reader.cc (read_context::get_fn_tmpl_decl) (read_context::key_fn_tmpl_decl): New functions. (read_context::m_fn_tmpl_map): New data member. (read_context::key_type_decl): Renamed read_context::add_type_decl into this. (read_context::push_decl_to_current_scope): Renamed read_context::finish_decl_creation into this. Add an assert. (read_context::push_and_key_type_decl): Renamed read_context::finish_type_decl_creation into this. Adjust to the use of push_decl_to_current_scope and key_type_decl. (build_function_template_decl, build_template_type_parameter) (build_template_non_type_parameter) (build_template_template_parameter, build_template_parameter) (handle_function_template_decl): New functions. (handle_element): Call handle_function_template_decl. (build_function_decl): Take a bool parameter to update depth information in parsing context. Move instantiation of function_decl before parsing its xml sub-nodes. Update the depth info in the parsing context if necessary. Push the newly intantiated decl to scope. And then parse the sub nodes. Do not forget to add the fn parameters and return type using function_decl::add_parameter and function_decl::set_return_type. (build_var_decl, build_type_decl, build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_enum_type_decl, build_typedef_decl, handled_type_decl) (handle_qualified_type_decl, handle_pointer_type_def) (handle_reference_type_def, handle_enum_type_decl) (handle_typedef_decl, handle_var_decl, handle_function_decl) (handle_class_decl): Adjust. (build_class_decl): Take a bool parameter to update depth information in parsing context. Add comment. Wait for the class members to be built, before keying (and thus hashing it) the class. (build_type): Fix logic, and adjust. * src/abg-writer.cc (write_context::type_has_existing_id) (write_context::get_id_for_fn_tmpl, write_template_type_parameter) (write_template_non_type_parameter) (write_template_template_parameter, write_template_parameter) (write_function_template_decl): New functions. (write_context::get_id_for_type): Simplify logic. (write_decl): Support writing function template. * tests/data/test-read-write/test11.xml: New test input. * tests/test-read-write.cc (InoutSpec in_out_specs[]): De-serialize the new test11.xml test, serialize it back and diff output and input. * tests/Makefile.am: Add test11.xml to the distribution.
2013-04-23 09:27:32 +00:00
bool
is_declared_inline() const
{return declared_inline_;}
binding
get_binding() const
{return binding_;}
Initial Support for class declarations * src/abg-ir.h (scope_decl::scope_decl) (scope_type_decl::scope_type_decl): Don't set mangled name for scope_decl instances as it doesn't make sense. (var_decl::var_decl): Pass the type shared pointer by value. (struct var_decl_hash, function_decl::parameter::operator==) (struct function_decl::parameter_hash, function_decl::operator==) (struct function_decl_hash, class class_decl, struct class_decl_hash): New declarations. * src/abg-ir.cc (scope_type_decl::scope_type_decl): Don't set the mangled name. It doesn't make sense for scope_decls. (dynamic_type_hash::operator): Fix comment. Run the hashing for scope_type_decl instances *after* running it for class_decl instance, otherwise, the class_decl instances case will never get hit. (var_decl::var_decl): Pass the type shared pointer by value. (function_decl::operator==, class_decl::operator==) (class_decl_hash::operator()): New fns. * src/abg-libxml-utils.h (get_xml_node_depth): Declare new fn. (XML_READER_GET_ATTRIBUTE): Fix comment. (XML_NODE_GET_ATTRIBUTE): New getter macro. * src/abg-libxml-utils.cc (get_xml_node_depth): New definition. * src/abg-reader.cc (update_read_context) (update_depth_info_of_read_context, read_visibility, read_binding) (read_access, read_size_and_alignment, read_static) (read_var_offset_in_bits, read_cdtor_const, build_function_decl) ( build_var_decl, build_type_decl, build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_enum_type_decl, build_typedef_decl, build_class_decl) (build_type, handle_class_decl): New functions or overloads. (handle_element): Update to handle "class-decl" xml elements. * src/abg-writer.cc (write_size_and_alignment, write_access) (write_class, do_indent_to_level, get_indent_to_level): New fns. (write_decl): Update to serialize instances of class_decl. (write_type_decl, write_pointer_type_def) (write_reference_type_def): Use the new write_size_and_alignment instead of writing the attributes directly. * tests/data/test-read-write/test10.xml: New test file. * tests/Makefile.am: Add tests/data/test-read-write/test10.xml to the build system. * tests/test-read-write.cc (in_out_spec): De-serialize data/test-read-write/test10.xml, serialize it back into output/test-read-write/test10.xml, and compare the two output that should be identical.
2013-04-11 20:02:08 +00:00
virtual bool
operator==(const decl_base& o) const;
Initial Support for class declarations * src/abg-ir.h (scope_decl::scope_decl) (scope_type_decl::scope_type_decl): Don't set mangled name for scope_decl instances as it doesn't make sense. (var_decl::var_decl): Pass the type shared pointer by value. (struct var_decl_hash, function_decl::parameter::operator==) (struct function_decl::parameter_hash, function_decl::operator==) (struct function_decl_hash, class class_decl, struct class_decl_hash): New declarations. * src/abg-ir.cc (scope_type_decl::scope_type_decl): Don't set the mangled name. It doesn't make sense for scope_decls. (dynamic_type_hash::operator): Fix comment. Run the hashing for scope_type_decl instances *after* running it for class_decl instance, otherwise, the class_decl instances case will never get hit. (var_decl::var_decl): Pass the type shared pointer by value. (function_decl::operator==, class_decl::operator==) (class_decl_hash::operator()): New fns. * src/abg-libxml-utils.h (get_xml_node_depth): Declare new fn. (XML_READER_GET_ATTRIBUTE): Fix comment. (XML_NODE_GET_ATTRIBUTE): New getter macro. * src/abg-libxml-utils.cc (get_xml_node_depth): New definition. * src/abg-reader.cc (update_read_context) (update_depth_info_of_read_context, read_visibility, read_binding) (read_access, read_size_and_alignment, read_static) (read_var_offset_in_bits, read_cdtor_const, build_function_decl) ( build_var_decl, build_type_decl, build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_enum_type_decl, build_typedef_decl, build_class_decl) (build_type, handle_class_decl): New functions or overloads. (handle_element): Update to handle "class-decl" xml elements. * src/abg-writer.cc (write_size_and_alignment, write_access) (write_class, do_indent_to_level, get_indent_to_level): New fns. (write_decl): Update to serialize instances of class_decl. (write_type_decl, write_pointer_type_def) (write_reference_type_def): Use the new write_size_and_alignment instead of writing the attributes directly. * tests/data/test-read-write/test10.xml: New test file. * tests/Makefile.am: Add tests/data/test-read-write/test10.xml to the build system. * tests/test-read-write.cc (in_out_spec): De-serialize data/test-read-write/test10.xml, serialize it back into output/test-read-write/test10.xml, and compare the two output that should be identical.
2013-04-11 20:02:08 +00:00
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
/// Return true iff the function takes a variable number of
/// parameters.
///
/// @return true if the function taks a variable number
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
/// of parameters.
bool
is_variadic() const
{
return (!get_parameters().empty()
&& get_parameters().back()->get_variadic_marker());
}
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
virtual void
traverse(ir_node_visitor&);
virtual ~function_decl();
}; // end class function_decl
/// Convenience typedef for a shared pointer on a @ref function_type
Support diff/reporting for functions & better diff/report in general * include/abg-ir.h ({decl_base, class_decl, function_decl}::get_pretty_representation): New virtual member to get a pretty string name for decls & types. (class_decl::parameter): Add an index to the parameter type. (class_decl::parameter::parameter): Update the constructor for the change above. (class_decl::parameter::{get_index, set_index}): Accessors for the new index. (class_decl::parameter::operator==): Take in account the index. (function_type::append_parameter): Set the index of the parameter here. * include/abg-fwd.h (get_type_name): New declaration. * src/abg-ir.cc (get_type_name): New definition. ({decl_base, function_decl, class_decl}::get_pretty_representation): New implementations. (method_type::set_class_type): Update this to set function parameter's index by default. (function_decl::append_parameters): Use the append_parameter method from function_type. * include/abg-comparison.h (class function_decl_diff): New type declaration. * src/abg-comparison.cc (compute_diff_for_decls, compute_diff): New definitions. ({pointer_diff, class_diff, scope_diff}::report): Use the new get_pretty_representation. Output a prettier report. (function_decl_diff::priv): New type. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at, ensure_lookup_tables_populated, function_decl_diff, first_function_decl, second_function_decl, changed_parms, removed_parms, added_parms, length, report}): New member function definitions. * src/abg-hash.cc (function_decl::parameter::hash): Update this to take the index in account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
typedef shared_ptr<function_type> function_type_sptr;
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
/// Abstraction of a function type.
class function_type : public virtual type_base
{
public:
/// Hasher for an instance of function_type
struct hash;
/// Convenience typedef for a shared pointer on a @ref
/// function_decl::parameter
typedef shared_ptr<function_decl::parameter> parameter_sptr;
/// Convenience typedef for a vector of @ref parameter_sptr
typedef std::vector<parameter_sptr> parameters;
private:
function_type();
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
shared_ptr<type_base> return_type_;
protected:
parameters parms_;
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
public:
/// The most straightforward constructor for the the function_type
/// class.
///
/// @param return_type the return type of the function type.
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
///
/// @param parms the list of parameters of the function type.
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
/// Stricto sensu, we just need a list of types; we are using a list
/// of parameters (where each parameter also carries the name of the
/// parameter and its source location) to try and provide better
/// diagnostics whenever it makes sense. If it appears that this
/// wasts too many resources, we can fall back to taking just a
/// vector of types here.
///
/// @param size_in_bits the size of this type, in bits.
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
///
/// @param alignment_in_bits the alignment of this type, in bits.
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
///
/// @param size_in_bits the size of this type.
function_type(shared_ptr<type_base> return_type, const parameters& parms,
size_t size_in_bits, size_t alignment_in_bits)
: type_base(size_in_bits, alignment_in_bits), return_type_(return_type),
parms_(parms)
{
for (parameters::size_type i = 0; i != parms_.size(); ++i)
parms_[i]->set_index(i);
}
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
/// A constructor for a function_type that takes no parameters.
///
/// @param return_type the return type of this function_type.
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
///
/// @param size_in_bits the size of this type, in bits.
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
///
/// @param alignment_in_bits the alignment of this type, in bits.
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
function_type(shared_ptr<type_base> return_type,
size_t size_in_bits, size_t alignment_in_bits)
: type_base(size_in_bits, alignment_in_bits),
return_type_(return_type)
{}
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
/// A constructor for a function_type that takes no parameter and
/// that has no return_type yet. These missing parts can (and must)
/// be added later.
///
/// @param size_in_bits the size of this type, in bits.
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
///
/// @param alignment_in_bits the alignment of this type, in bits.
function_type(size_t size_in_bits, size_t alignment_in_bits)
: type_base(size_in_bits, alignment_in_bits)
{}
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
const shared_ptr<type_base>&
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
get_return_type() const
{return return_type_;}
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
void
set_return_type(shared_ptr<type_base> t)
{return_type_ = t;}
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
const parameters&
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
get_parameters() const
{return parms_;}
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
parameters&
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
get_parameters()
{return parms_;}
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
void
set_parameters(const parameters &p)
{parms_ = p;}
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
void
append_parameter(parameter_sptr parm)
Support diff/reporting for functions & better diff/report in general * include/abg-ir.h ({decl_base, class_decl, function_decl}::get_pretty_representation): New virtual member to get a pretty string name for decls & types. (class_decl::parameter): Add an index to the parameter type. (class_decl::parameter::parameter): Update the constructor for the change above. (class_decl::parameter::{get_index, set_index}): Accessors for the new index. (class_decl::parameter::operator==): Take in account the index. (function_type::append_parameter): Set the index of the parameter here. * include/abg-fwd.h (get_type_name): New declaration. * src/abg-ir.cc (get_type_name): New definition. ({decl_base, function_decl, class_decl}::get_pretty_representation): New implementations. (method_type::set_class_type): Update this to set function parameter's index by default. (function_decl::append_parameters): Use the append_parameter method from function_type. * include/abg-comparison.h (class function_decl_diff): New type declaration. * src/abg-comparison.cc (compute_diff_for_decls, compute_diff): New definitions. ({pointer_diff, class_diff, scope_diff}::report): Use the new get_pretty_representation. Output a prettier report. (function_decl_diff::priv): New type. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at, ensure_lookup_tables_populated, function_decl_diff, first_function_decl, second_function_decl, changed_parms, removed_parms, added_parms, length, report}): New member function definitions. * src/abg-hash.cc (function_decl::parameter::hash): Update this to take the index in account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
{
parm->set_index(parms_.size());
parms_.push_back(parm);
}
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
bool
is_variadic() const
{return !parms_.empty() && parms_.back()->get_variadic_marker();}
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
virtual bool
operator==(const type_base&) const;
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
virtual ~function_type();
};//end class function_type
Support function_type and adapt a function_decl to use it * src/abg-ir.h (class function_type): Forward decl prior to class function_decl. (function_decl::parameter): Pass string by const reference. Add a variadic marker member and initialize it. (function_decl::parameter::get_type): Add a non-const overload. (function_decl::parameter::get_variadic_marker): New getter. (function_decl::function_decl) Take a const reference to a vector for parameters, type size/alignment. Add two overloads that takes a pointer to function_type. (function_decl::get_parameters): Move this out-of-line. (function_decl::append_parameter(s)): Renamed function_decl::add_parameter(s) into these. Move it out-of-line. Add an overload. (function_decl::{get_type, set_type}): New declaration. (function_decl::get_return_type): Move this out-of-line. (function_decl::is_variadic): New in-line function. (function_decl::m_type): New data member. (function_decl::{m_parms, m_return_type}): Remove. This are now carried by function_decl::m_type. (class function_type, struct function_type_hash): New declarations. (member_function::member_function): Take a vector of pointers to parameters. Take size/align of the type of the member function. Adjust initialization. * src/abg-ir.cc (dynamic_type_hash): Hash instance of function_type accessed through a pointer. (function_type::{operator==, ~function_type}) (function_type_hash::operaror(), function_decl::{get_return_type, }, function_decl::parameter::hash::operator()): New definitions. (function_decl::function_decl): The out-of-line definitions of the declarations above. (function_decl::append_parameter): Moved this out-of-line from inline function_decl::add_parameter. Make this rely on the underlying m_type. (function_decl::operator==): Adjust for use of vector for the parameters. Also, there is no need anymore to compare the parameters or the return types as they are compared by the comparison of the function types. * src/abg-reader.cc (build_function_decl): Read the new size/alignment attributes on the function-decl element. Build a function_type and use it to build the function_decl. Parameters and return type are now hung off of the function_type. (handle_function_decl): use build_function_decl. * src/abg-writer.cc (write_function_decl): Write the new size/alignment properties of the function-decl element. Adjust for the use of vectors for function parameters now. * tests/data/test-read-write/test10.xml: Adjust for the presence of size/alignment properties in the function-decl element now. * tests/data/test-read-write/test11.xml: Likewise. * tests/data/test-read-write/test12.xml: Likewise. * tests/data/test-read-write/test13.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test9.xml: Likewise.
2013-06-01 13:41:59 +00:00
Support reading member functions and member types from DWARF * include/abg-ir.h (method_type_sptr): New convenience typedef. * src/abg-dwarf-reader.cc (read_context::{dwarf_version, die_wip_classes_map}): New accessors. (die_is_virtual): Rename is_virtual into this. (is_type_tag, is_type_die, die_virtual_function_index): Define new static functions. (die_member_offset): Fix comment. (get_scope_for_die): Take the read context as argument. (canonicalize_and_add_type_to_ir): Likewise. On NULL scope, get the current translation unit from the read context. (canonicalize_and_insert_type_into_ir_under_scope): Handle NULL context. (build_function_decl): Support creating method_decls from here when necessary. (build_class_type_and_add_to_ir): Rename build_class_type into this. Handle adding the class to the IR and to the relevant maps. During the creation of the class, arrange for build_ir_node_from_die on the current DIE to return a declaration-only class, representing the declaration for the class that is being constructed. This breaks circular dependencies induced by decls/types that refer to the class being built, before the class is fully built and has a (logical) type ID. Once the class is created, make it refer to the class declaration that was previously handed for the requests to the class DIE. Now requests to the class DIE will just yield the newly built class. Add support for member functions and member types. (build_corpus): Support reading the dwarf version and stick it into the context. (build_ir_node_from_die): Adjust for change in canonicalize_and_add_type_to_ir and build_class_type signature change. * src/abg-ir.cc (class_decl::method_decl::get_type): Support returning NULL type. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-20 15:19:58 +00:00
/// Convenience typedef for shared pointer to @ref method_type.
typedef shared_ptr<method_type> method_type_sptr;
Support method type/decl, variadic functions, class declarations-only * src/abg-ir.h (function_decl::parameter::parameter): New constructor with variadic parameter marker. (function_decl::m_type): Make this protected to let method_decl inheriting class to access it. (function_decl::get_type): Move this out-of-line. (class method_type, method_type_hash): New types. (enum class_decl::access_specifier): Add no_access new enumerator. (class_decl::data_member::data_member): Move this out-of-line. (class_decl::data_member::~data_member): Declare virtual destructor. (class method_decl): New class. (class member_function): Make this inherit method_decl, instead of function_decl. (class_decl::class_decl): New constructors. (class_decl::{hashing_started, is_declaration_only, set_earlier_declaration, get_earlier_declaration}): New methods. * src/abg-ir.cc (add_decl_to_scope): If a decl is already in a scope, don't add it to this scope. (get_global_scope): Make this work when passed an instance of global_scope. (dynamic_type_hash::operator()): Add support for method_type. (method_type::{method_type, set_class_type, ~method_type, }) (method_type_hash::operator()): New defintions. (function_decl::get_type, class_decl::class_decl): Move these out-of-line here. (class_decl::method_decl::{method_decl, ~method_decl, get_type}): New definitions. (class_decl::member_function::member_function): Move this out-of-line here. Support method_decl. (class_decl::data_member::data_member): Likewise. (class_decl_hash::operator()): Guard this against endless loop. * src/abg-reader.cc (write_class_is_declaration_only): New static function. (write_var_decl): Take a flag to write the mangled name or not. (write_function_decl): Take a flag to skip the first parameter. (write_cdtor_const_static): Use 'yes' instead of 'true' as value of the properties. (write_decl, write_function_template_decl): Adjust wrt the new signatures of write_var_decl and write_function_decl. (write_enum_type_decl): Simplify call to write_location. (write_class_decl): Support serializing declaration-only classes. * src/abg-writer.cc: * tests/data/test-read-write/test17.xml: New test input. * tests/test-read-write.cc: De-serialize the above, and serialize it back. * tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
/// Abstracts the type of a class member function.
class method_type : public function_type
{
shared_ptr<class_decl> class_type_;
Support method type/decl, variadic functions, class declarations-only * src/abg-ir.h (function_decl::parameter::parameter): New constructor with variadic parameter marker. (function_decl::m_type): Make this protected to let method_decl inheriting class to access it. (function_decl::get_type): Move this out-of-line. (class method_type, method_type_hash): New types. (enum class_decl::access_specifier): Add no_access new enumerator. (class_decl::data_member::data_member): Move this out-of-line. (class_decl::data_member::~data_member): Declare virtual destructor. (class method_decl): New class. (class member_function): Make this inherit method_decl, instead of function_decl. (class_decl::class_decl): New constructors. (class_decl::{hashing_started, is_declaration_only, set_earlier_declaration, get_earlier_declaration}): New methods. * src/abg-ir.cc (add_decl_to_scope): If a decl is already in a scope, don't add it to this scope. (get_global_scope): Make this work when passed an instance of global_scope. (dynamic_type_hash::operator()): Add support for method_type. (method_type::{method_type, set_class_type, ~method_type, }) (method_type_hash::operator()): New defintions. (function_decl::get_type, class_decl::class_decl): Move these out-of-line here. (class_decl::method_decl::{method_decl, ~method_decl, get_type}): New definitions. (class_decl::member_function::member_function): Move this out-of-line here. Support method_decl. (class_decl::data_member::data_member): Likewise. (class_decl_hash::operator()): Guard this against endless loop. * src/abg-reader.cc (write_class_is_declaration_only): New static function. (write_var_decl): Take a flag to write the mangled name or not. (write_function_decl): Take a flag to skip the first parameter. (write_cdtor_const_static): Use 'yes' instead of 'true' as value of the properties. (write_decl, write_function_template_decl): Adjust wrt the new signatures of write_var_decl and write_function_decl. (write_enum_type_decl): Simplify call to write_location. (write_class_decl): Support serializing declaration-only classes. * src/abg-writer.cc: * tests/data/test-read-write/test17.xml: New test input. * tests/test-read-write.cc: De-serialize the above, and serialize it back. * tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
method_type();
public:
/// Hasher for intances of method_type
struct hash;
Support method type/decl, variadic functions, class declarations-only * src/abg-ir.h (function_decl::parameter::parameter): New constructor with variadic parameter marker. (function_decl::m_type): Make this protected to let method_decl inheriting class to access it. (function_decl::get_type): Move this out-of-line. (class method_type, method_type_hash): New types. (enum class_decl::access_specifier): Add no_access new enumerator. (class_decl::data_member::data_member): Move this out-of-line. (class_decl::data_member::~data_member): Declare virtual destructor. (class method_decl): New class. (class member_function): Make this inherit method_decl, instead of function_decl. (class_decl::class_decl): New constructors. (class_decl::{hashing_started, is_declaration_only, set_earlier_declaration, get_earlier_declaration}): New methods. * src/abg-ir.cc (add_decl_to_scope): If a decl is already in a scope, don't add it to this scope. (get_global_scope): Make this work when passed an instance of global_scope. (dynamic_type_hash::operator()): Add support for method_type. (method_type::{method_type, set_class_type, ~method_type, }) (method_type_hash::operator()): New defintions. (function_decl::get_type, class_decl::class_decl): Move these out-of-line here. (class_decl::method_decl::{method_decl, ~method_decl, get_type}): New definitions. (class_decl::member_function::member_function): Move this out-of-line here. Support method_decl. (class_decl::data_member::data_member): Likewise. (class_decl_hash::operator()): Guard this against endless loop. * src/abg-reader.cc (write_class_is_declaration_only): New static function. (write_var_decl): Take a flag to write the mangled name or not. (write_function_decl): Take a flag to skip the first parameter. (write_cdtor_const_static): Use 'yes' instead of 'true' as value of the properties. (write_decl, write_function_template_decl): Adjust wrt the new signatures of write_var_decl and write_function_decl. (write_enum_type_decl): Simplify call to write_location. (write_class_decl): Support serializing declaration-only classes. * src/abg-writer.cc: * tests/data/test-read-write/test17.xml: New test input. * tests/test-read-write.cc: De-serialize the above, and serialize it back. * tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
method_type(shared_ptr<type_base> return_type,
shared_ptr<class_decl> class_type,
const std::vector<shared_ptr<function_decl::parameter> >& parms,
size_t size_in_bits,
size_t alignment_in_bits);
method_type(shared_ptr<type_base> return_type,
shared_ptr<type_base> class_type,
const std::vector<shared_ptr<function_decl::parameter> >& parms,
size_t size_in_bits,
size_t alignment_in_bits);
method_type(shared_ptr<class_decl> class_type,
size_t size_in_bits,
size_t alignment_in_bits);
method_type(size_t size_in_bits,
size_t alignment_in_bits);
const shared_ptr<class_decl>&
Support method type/decl, variadic functions, class declarations-only * src/abg-ir.h (function_decl::parameter::parameter): New constructor with variadic parameter marker. (function_decl::m_type): Make this protected to let method_decl inheriting class to access it. (function_decl::get_type): Move this out-of-line. (class method_type, method_type_hash): New types. (enum class_decl::access_specifier): Add no_access new enumerator. (class_decl::data_member::data_member): Move this out-of-line. (class_decl::data_member::~data_member): Declare virtual destructor. (class method_decl): New class. (class member_function): Make this inherit method_decl, instead of function_decl. (class_decl::class_decl): New constructors. (class_decl::{hashing_started, is_declaration_only, set_earlier_declaration, get_earlier_declaration}): New methods. * src/abg-ir.cc (add_decl_to_scope): If a decl is already in a scope, don't add it to this scope. (get_global_scope): Make this work when passed an instance of global_scope. (dynamic_type_hash::operator()): Add support for method_type. (method_type::{method_type, set_class_type, ~method_type, }) (method_type_hash::operator()): New defintions. (function_decl::get_type, class_decl::class_decl): Move these out-of-line here. (class_decl::method_decl::{method_decl, ~method_decl, get_type}): New definitions. (class_decl::member_function::member_function): Move this out-of-line here. Support method_decl. (class_decl::data_member::data_member): Likewise. (class_decl_hash::operator()): Guard this against endless loop. * src/abg-reader.cc (write_class_is_declaration_only): New static function. (write_var_decl): Take a flag to write the mangled name or not. (write_function_decl): Take a flag to skip the first parameter. (write_cdtor_const_static): Use 'yes' instead of 'true' as value of the properties. (write_decl, write_function_template_decl): Adjust wrt the new signatures of write_var_decl and write_function_decl. (write_enum_type_decl): Simplify call to write_location. (write_class_decl): Support serializing declaration-only classes. * src/abg-writer.cc: * tests/data/test-read-write/test17.xml: New test input. * tests/test-read-write.cc: De-serialize the above, and serialize it back. * tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
get_class_type() const
{return class_type_;}
Support method type/decl, variadic functions, class declarations-only * src/abg-ir.h (function_decl::parameter::parameter): New constructor with variadic parameter marker. (function_decl::m_type): Make this protected to let method_decl inheriting class to access it. (function_decl::get_type): Move this out-of-line. (class method_type, method_type_hash): New types. (enum class_decl::access_specifier): Add no_access new enumerator. (class_decl::data_member::data_member): Move this out-of-line. (class_decl::data_member::~data_member): Declare virtual destructor. (class method_decl): New class. (class member_function): Make this inherit method_decl, instead of function_decl. (class_decl::class_decl): New constructors. (class_decl::{hashing_started, is_declaration_only, set_earlier_declaration, get_earlier_declaration}): New methods. * src/abg-ir.cc (add_decl_to_scope): If a decl is already in a scope, don't add it to this scope. (get_global_scope): Make this work when passed an instance of global_scope. (dynamic_type_hash::operator()): Add support for method_type. (method_type::{method_type, set_class_type, ~method_type, }) (method_type_hash::operator()): New defintions. (function_decl::get_type, class_decl::class_decl): Move these out-of-line here. (class_decl::method_decl::{method_decl, ~method_decl, get_type}): New definitions. (class_decl::member_function::member_function): Move this out-of-line here. Support method_decl. (class_decl::data_member::data_member): Likewise. (class_decl_hash::operator()): Guard this against endless loop. * src/abg-reader.cc (write_class_is_declaration_only): New static function. (write_var_decl): Take a flag to write the mangled name or not. (write_function_decl): Take a flag to skip the first parameter. (write_cdtor_const_static): Use 'yes' instead of 'true' as value of the properties. (write_decl, write_function_template_decl): Adjust wrt the new signatures of write_var_decl and write_function_decl. (write_enum_type_decl): Simplify call to write_location. (write_class_decl): Support serializing declaration-only classes. * src/abg-writer.cc: * tests/data/test-read-write/test17.xml: New test input. * tests/test-read-write.cc: De-serialize the above, and serialize it back. * tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
void
set_class_type(shared_ptr<class_decl> t);
Support method type/decl, variadic functions, class declarations-only * src/abg-ir.h (function_decl::parameter::parameter): New constructor with variadic parameter marker. (function_decl::m_type): Make this protected to let method_decl inheriting class to access it. (function_decl::get_type): Move this out-of-line. (class method_type, method_type_hash): New types. (enum class_decl::access_specifier): Add no_access new enumerator. (class_decl::data_member::data_member): Move this out-of-line. (class_decl::data_member::~data_member): Declare virtual destructor. (class method_decl): New class. (class member_function): Make this inherit method_decl, instead of function_decl. (class_decl::class_decl): New constructors. (class_decl::{hashing_started, is_declaration_only, set_earlier_declaration, get_earlier_declaration}): New methods. * src/abg-ir.cc (add_decl_to_scope): If a decl is already in a scope, don't add it to this scope. (get_global_scope): Make this work when passed an instance of global_scope. (dynamic_type_hash::operator()): Add support for method_type. (method_type::{method_type, set_class_type, ~method_type, }) (method_type_hash::operator()): New defintions. (function_decl::get_type, class_decl::class_decl): Move these out-of-line here. (class_decl::method_decl::{method_decl, ~method_decl, get_type}): New definitions. (class_decl::member_function::member_function): Move this out-of-line here. Support method_decl. (class_decl::data_member::data_member): Likewise. (class_decl_hash::operator()): Guard this against endless loop. * src/abg-reader.cc (write_class_is_declaration_only): New static function. (write_var_decl): Take a flag to write the mangled name or not. (write_function_decl): Take a flag to skip the first parameter. (write_cdtor_const_static): Use 'yes' instead of 'true' as value of the properties. (write_decl, write_function_template_decl): Adjust wrt the new signatures of write_var_decl and write_function_decl. (write_enum_type_decl): Simplify call to write_location. (write_class_decl): Support serializing declaration-only classes. * src/abg-writer.cc: * tests/data/test-read-write/test17.xml: New test input. * tests/test-read-write.cc: De-serialize the above, and serialize it back. * tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
virtual ~method_type();
};// end class method_type.
Support method type/decl, variadic functions, class declarations-only * src/abg-ir.h (function_decl::parameter::parameter): New constructor with variadic parameter marker. (function_decl::m_type): Make this protected to let method_decl inheriting class to access it. (function_decl::get_type): Move this out-of-line. (class method_type, method_type_hash): New types. (enum class_decl::access_specifier): Add no_access new enumerator. (class_decl::data_member::data_member): Move this out-of-line. (class_decl::data_member::~data_member): Declare virtual destructor. (class method_decl): New class. (class member_function): Make this inherit method_decl, instead of function_decl. (class_decl::class_decl): New constructors. (class_decl::{hashing_started, is_declaration_only, set_earlier_declaration, get_earlier_declaration}): New methods. * src/abg-ir.cc (add_decl_to_scope): If a decl is already in a scope, don't add it to this scope. (get_global_scope): Make this work when passed an instance of global_scope. (dynamic_type_hash::operator()): Add support for method_type. (method_type::{method_type, set_class_type, ~method_type, }) (method_type_hash::operator()): New defintions. (function_decl::get_type, class_decl::class_decl): Move these out-of-line here. (class_decl::method_decl::{method_decl, ~method_decl, get_type}): New definitions. (class_decl::member_function::member_function): Move this out-of-line here. Support method_decl. (class_decl::data_member::data_member): Likewise. (class_decl_hash::operator()): Guard this against endless loop. * src/abg-reader.cc (write_class_is_declaration_only): New static function. (write_var_decl): Take a flag to write the mangled name or not. (write_function_decl): Take a flag to skip the first parameter. (write_cdtor_const_static): Use 'yes' instead of 'true' as value of the properties. (write_decl, write_function_template_decl): Adjust wrt the new signatures of write_var_decl and write_function_decl. (write_enum_type_decl): Simplify call to write_location. (write_class_decl): Support serializing declaration-only classes. * src/abg-writer.cc: * tests/data/test-read-write/test17.xml: New test input. * tests/test-read-write.cc: De-serialize the above, and serialize it back. * tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
/// The base class of templates.
class template_decl
{
// XXX
std::list<shared_ptr<template_parameter> > parms_;
public:
/// Hasher.
struct hash;
template_decl()
{}
void
add_template_parameter(shared_ptr<template_parameter> p)
{parms_.push_back(p);}
const std::list<shared_ptr<template_parameter> >&
get_template_parameters() const
{return parms_;}
virtual bool
operator==(const template_decl& o) const;
virtual ~template_decl();
};//end class template_decl
/// Base class for a template parameter. Client code should use the
/// more specialized type_template_parameter,
/// non_type_template_parameter and template_template_parameter below.
class template_parameter
{
unsigned index_;
// Forbidden
template_parameter();
public:
/// Hashers.
struct hash;
struct dynamic_hash;
struct shared_ptr_hash;
template_parameter(unsigned index) : index_(index)
{}
virtual bool
operator==(const template_parameter&) const;
unsigned
get_index() const
{return index_;}
virtual ~template_parameter();
};//end class template_parameter
/// Abstracts a type template parameter.
class type_tparameter : public template_parameter, public virtual type_decl
{
// Forbidden
type_tparameter();
public:
/// Hasher.
struct hash;
type_tparameter(unsigned index,
const std::string& name,
location locus)
: decl_base(name, locus),
type_base(0, 0),
type_decl(name, 0, 0, locus),
template_parameter(index)
{}
virtual bool
operator==(const type_base&) const;
virtual bool
operator==(const template_parameter&) const;
virtual bool
operator==(const type_tparameter&) const;
virtual ~type_tparameter();
};// end class type_tparameter.
/// Abstracts non type template parameters.
class non_type_tparameter : public template_parameter, public virtual decl_base
{
shared_ptr<type_base> type_;
// Forbidden
non_type_tparameter();
public:
/// Hasher.
struct hash;
non_type_tparameter(unsigned index, const std::string& name,
shared_ptr<type_base> type, location locus)
: decl_base(name, locus, ""),
template_parameter(index),
type_(type)
{}
virtual bool
operator==(const decl_base&) const;
virtual bool
operator==(const template_parameter&) const;
shared_ptr<type_base>
get_type() const
{return type_;}
virtual ~non_type_tparameter();
};// end class non_type_tparameter
/// Abstracts a template template parameter.
class template_tparameter : public type_tparameter, public template_decl
{
// Forbidden
template_tparameter();
public:
/// A hasher for instances of template_tparameter
struct hash;
template_tparameter(unsigned index,
const std::string& name,
location locus)
: decl_base(name, locus),
type_base(0, 0),
type_decl(name, 0, 0, locus, name, VISIBILITY_DEFAULT),
type_tparameter(index, name, locus)
{}
virtual bool
operator==(const type_base&) const;
virtual bool
operator==(const template_parameter&) const;
virtual bool
operator==(const template_decl&) const;
virtual ~template_tparameter();
};
/// This abstracts a composition of types based on template type
/// parameters. The result of the composition is a type that can be
/// referred to by a template non-type parameter. Instances of this
/// type can appear at the same level as template parameters, in the
/// scope of a template_decl.
class type_composition : public template_parameter, public virtual decl_base
{
shared_ptr<type_base> type_;
type_composition();
public:
type_composition(unsigned index,
shared_ptr<type_base> composed_type);
shared_ptr<type_base>
get_composed_type() const
{return type_;}
void
set_composed_type(shared_ptr<type_base> t)
{type_ = t;}
virtual ~type_composition();
};
/// Convenience typedef for a shared pointer on a @ref function_tdecl
typedef shared_ptr<function_tdecl> function_tdecl_sptr;
/// Abstract a function template declaration.
class function_tdecl : public template_decl, public scope_decl
{
shared_ptr<function_decl> pattern_;
binding binding_;
// Forbidden
function_tdecl();
public:
/// Hash functor for function templates.
struct hash;
struct shared_ptr_hash;
function_tdecl(location locus,
visibility vis = VISIBILITY_DEFAULT,
binding bind = BINDING_NONE)
: decl_base("", locus, "", vis), scope_decl("", locus),
binding_(bind)
{}
function_tdecl(shared_ptr<function_decl> pattern,
location locus,
visibility vis = VISIBILITY_DEFAULT,
binding bind = BINDING_NONE)
: decl_base(pattern->get_name(), locus,
pattern->get_name(), vis),
scope_decl(pattern->get_name(), locus),
binding_(bind)
{set_pattern(pattern);}
virtual bool
operator==(const decl_base&) const;
virtual bool
operator==(const template_decl&) const;
void
set_pattern(shared_ptr<function_decl> p)
{
pattern_ = p;
add_decl_to_scope(p, this);
set_name(p->get_name());
}
shared_ptr<function_decl>
get_pattern() const
{return pattern_;}
binding
get_binding() const
{return binding_;}
virtual void
traverse(ir_node_visitor& v);
virtual ~function_tdecl();
}; // end class function_tdecl.
/// Convenience typedef for a shared pointer on a @ref class_tdecl
typedef shared_ptr<class_tdecl> class_tdecl_sptr;
Initial support of class templates * src/abg-ir.cc (class_template_decl::class_template_decl) (class_template_decl::set_pattern) (class_template_decl::operator==) (class_template_decl::~class_template_decl) (class_template_decl_hash::operator()) (class_tmpl_shared_ptr_hash::operator()): New definitions. * src/abg-ir.h (class class_template_decl, struct class_tmpl_shared_ptr_hash, struct class_tmpl_shared_ptr_hash): New declarations. * src/abg-reader.cc (read_context::const_class_tmpl_map_it): New typedef. (read_context::get_fn_tmpl_decl): Fix comment. (read_context::{get_class_tmpl_decl,key_class_tmpl_decl}) (build_class_template_decl, handle_class_template_decl): New definitions. (read_context::m_class_tmpl_map): New member. (handle_element): Support "class-template-decl" xml elements nodes. (build_class_decl): Add missing bits to comment. (build_function_template_decl): Fix spacing. * src/abg-writer.cc (class_tmpl_shared_ptr_map): New typedef. (write_context::m_class_tmpl_map): New member. (write_context::get_id_for_class_tmpl, write_class_template_decl): New definitions. (write_template_parameters): Factorize this this out from ... (write_function_template_decl): ... here. (write_decl): Support writing instances of class_template_decl. Fix spacing. * tests/data/test-read-write/test15.xml: New test input. * tests/Makefile.am: Add the new test15.xml input to the distribution. * tests/test-read-write.cc (in_out_specs): Add the new test15.xml test to the list of serialized output to be de-serialized and serialized back.
2013-05-02 13:25:04 +00:00
/// Abstract a class template.
class class_tdecl : public template_decl, public scope_decl
Initial support of class templates * src/abg-ir.cc (class_template_decl::class_template_decl) (class_template_decl::set_pattern) (class_template_decl::operator==) (class_template_decl::~class_template_decl) (class_template_decl_hash::operator()) (class_tmpl_shared_ptr_hash::operator()): New definitions. * src/abg-ir.h (class class_template_decl, struct class_tmpl_shared_ptr_hash, struct class_tmpl_shared_ptr_hash): New declarations. * src/abg-reader.cc (read_context::const_class_tmpl_map_it): New typedef. (read_context::get_fn_tmpl_decl): Fix comment. (read_context::{get_class_tmpl_decl,key_class_tmpl_decl}) (build_class_template_decl, handle_class_template_decl): New definitions. (read_context::m_class_tmpl_map): New member. (handle_element): Support "class-template-decl" xml elements nodes. (build_class_decl): Add missing bits to comment. (build_function_template_decl): Fix spacing. * src/abg-writer.cc (class_tmpl_shared_ptr_map): New typedef. (write_context::m_class_tmpl_map): New member. (write_context::get_id_for_class_tmpl, write_class_template_decl): New definitions. (write_template_parameters): Factorize this this out from ... (write_function_template_decl): ... here. (write_decl): Support writing instances of class_template_decl. Fix spacing. * tests/data/test-read-write/test15.xml: New test input. * tests/Makefile.am: Add the new test15.xml input to the distribution. * tests/test-read-write.cc (in_out_specs): Add the new test15.xml test to the list of serialized output to be de-serialized and serialized back.
2013-05-02 13:25:04 +00:00
{
shared_ptr<class_decl> pattern_;
Initial support of class templates * src/abg-ir.cc (class_template_decl::class_template_decl) (class_template_decl::set_pattern) (class_template_decl::operator==) (class_template_decl::~class_template_decl) (class_template_decl_hash::operator()) (class_tmpl_shared_ptr_hash::operator()): New definitions. * src/abg-ir.h (class class_template_decl, struct class_tmpl_shared_ptr_hash, struct class_tmpl_shared_ptr_hash): New declarations. * src/abg-reader.cc (read_context::const_class_tmpl_map_it): New typedef. (read_context::get_fn_tmpl_decl): Fix comment. (read_context::{get_class_tmpl_decl,key_class_tmpl_decl}) (build_class_template_decl, handle_class_template_decl): New definitions. (read_context::m_class_tmpl_map): New member. (handle_element): Support "class-template-decl" xml elements nodes. (build_class_decl): Add missing bits to comment. (build_function_template_decl): Fix spacing. * src/abg-writer.cc (class_tmpl_shared_ptr_map): New typedef. (write_context::m_class_tmpl_map): New member. (write_context::get_id_for_class_tmpl, write_class_template_decl): New definitions. (write_template_parameters): Factorize this this out from ... (write_function_template_decl): ... here. (write_decl): Support writing instances of class_template_decl. Fix spacing. * tests/data/test-read-write/test15.xml: New test input. * tests/Makefile.am: Add the new test15.xml input to the distribution. * tests/test-read-write.cc (in_out_specs): Add the new test15.xml test to the list of serialized output to be de-serialized and serialized back.
2013-05-02 13:25:04 +00:00
// Forbidden
class_tdecl();
Initial support of class templates * src/abg-ir.cc (class_template_decl::class_template_decl) (class_template_decl::set_pattern) (class_template_decl::operator==) (class_template_decl::~class_template_decl) (class_template_decl_hash::operator()) (class_tmpl_shared_ptr_hash::operator()): New definitions. * src/abg-ir.h (class class_template_decl, struct class_tmpl_shared_ptr_hash, struct class_tmpl_shared_ptr_hash): New declarations. * src/abg-reader.cc (read_context::const_class_tmpl_map_it): New typedef. (read_context::get_fn_tmpl_decl): Fix comment. (read_context::{get_class_tmpl_decl,key_class_tmpl_decl}) (build_class_template_decl, handle_class_template_decl): New definitions. (read_context::m_class_tmpl_map): New member. (handle_element): Support "class-template-decl" xml elements nodes. (build_class_decl): Add missing bits to comment. (build_function_template_decl): Fix spacing. * src/abg-writer.cc (class_tmpl_shared_ptr_map): New typedef. (write_context::m_class_tmpl_map): New member. (write_context::get_id_for_class_tmpl, write_class_template_decl): New definitions. (write_template_parameters): Factorize this this out from ... (write_function_template_decl): ... here. (write_decl): Support writing instances of class_template_decl. Fix spacing. * tests/data/test-read-write/test15.xml: New test input. * tests/Makefile.am: Add the new test15.xml input to the distribution. * tests/test-read-write.cc (in_out_specs): Add the new test15.xml test to the list of serialized output to be de-serialized and serialized back.
2013-05-02 13:25:04 +00:00
public:
/// Hashers.
struct hash;
struct shared_ptr_hash;
class_tdecl(location locus, visibility vis = VISIBILITY_DEFAULT)
: decl_base("", locus, "", vis), scope_decl("", locus)
{}
Initial support of class templates * src/abg-ir.cc (class_template_decl::class_template_decl) (class_template_decl::set_pattern) (class_template_decl::operator==) (class_template_decl::~class_template_decl) (class_template_decl_hash::operator()) (class_tmpl_shared_ptr_hash::operator()): New definitions. * src/abg-ir.h (class class_template_decl, struct class_tmpl_shared_ptr_hash, struct class_tmpl_shared_ptr_hash): New declarations. * src/abg-reader.cc (read_context::const_class_tmpl_map_it): New typedef. (read_context::get_fn_tmpl_decl): Fix comment. (read_context::{get_class_tmpl_decl,key_class_tmpl_decl}) (build_class_template_decl, handle_class_template_decl): New definitions. (read_context::m_class_tmpl_map): New member. (handle_element): Support "class-template-decl" xml elements nodes. (build_class_decl): Add missing bits to comment. (build_function_template_decl): Fix spacing. * src/abg-writer.cc (class_tmpl_shared_ptr_map): New typedef. (write_context::m_class_tmpl_map): New member. (write_context::get_id_for_class_tmpl, write_class_template_decl): New definitions. (write_template_parameters): Factorize this this out from ... (write_function_template_decl): ... here. (write_decl): Support writing instances of class_template_decl. Fix spacing. * tests/data/test-read-write/test15.xml: New test input. * tests/Makefile.am: Add the new test15.xml input to the distribution. * tests/test-read-write.cc (in_out_specs): Add the new test15.xml test to the list of serialized output to be de-serialized and serialized back.
2013-05-02 13:25:04 +00:00
class_tdecl(shared_ptr<class_decl> pattern,
location locus, visibility vis = VISIBILITY_DEFAULT);
Initial support of class templates * src/abg-ir.cc (class_template_decl::class_template_decl) (class_template_decl::set_pattern) (class_template_decl::operator==) (class_template_decl::~class_template_decl) (class_template_decl_hash::operator()) (class_tmpl_shared_ptr_hash::operator()): New definitions. * src/abg-ir.h (class class_template_decl, struct class_tmpl_shared_ptr_hash, struct class_tmpl_shared_ptr_hash): New declarations. * src/abg-reader.cc (read_context::const_class_tmpl_map_it): New typedef. (read_context::get_fn_tmpl_decl): Fix comment. (read_context::{get_class_tmpl_decl,key_class_tmpl_decl}) (build_class_template_decl, handle_class_template_decl): New definitions. (read_context::m_class_tmpl_map): New member. (handle_element): Support "class-template-decl" xml elements nodes. (build_class_decl): Add missing bits to comment. (build_function_template_decl): Fix spacing. * src/abg-writer.cc (class_tmpl_shared_ptr_map): New typedef. (write_context::m_class_tmpl_map): New member. (write_context::get_id_for_class_tmpl, write_class_template_decl): New definitions. (write_template_parameters): Factorize this this out from ... (write_function_template_decl): ... here. (write_decl): Support writing instances of class_template_decl. Fix spacing. * tests/data/test-read-write/test15.xml: New test input. * tests/Makefile.am: Add the new test15.xml input to the distribution. * tests/test-read-write.cc (in_out_specs): Add the new test15.xml test to the list of serialized output to be de-serialized and serialized back.
2013-05-02 13:25:04 +00:00
virtual bool
operator==(const decl_base&) const;
virtual bool
operator==(const template_decl&) const;
Initial support of class templates * src/abg-ir.cc (class_template_decl::class_template_decl) (class_template_decl::set_pattern) (class_template_decl::operator==) (class_template_decl::~class_template_decl) (class_template_decl_hash::operator()) (class_tmpl_shared_ptr_hash::operator()): New definitions. * src/abg-ir.h (class class_template_decl, struct class_tmpl_shared_ptr_hash, struct class_tmpl_shared_ptr_hash): New declarations. * src/abg-reader.cc (read_context::const_class_tmpl_map_it): New typedef. (read_context::get_fn_tmpl_decl): Fix comment. (read_context::{get_class_tmpl_decl,key_class_tmpl_decl}) (build_class_template_decl, handle_class_template_decl): New definitions. (read_context::m_class_tmpl_map): New member. (handle_element): Support "class-template-decl" xml elements nodes. (build_class_decl): Add missing bits to comment. (build_function_template_decl): Fix spacing. * src/abg-writer.cc (class_tmpl_shared_ptr_map): New typedef. (write_context::m_class_tmpl_map): New member. (write_context::get_id_for_class_tmpl, write_class_template_decl): New definitions. (write_template_parameters): Factorize this this out from ... (write_function_template_decl): ... here. (write_decl): Support writing instances of class_template_decl. Fix spacing. * tests/data/test-read-write/test15.xml: New test input. * tests/Makefile.am: Add the new test15.xml input to the distribution. * tests/test-read-write.cc (in_out_specs): Add the new test15.xml test to the list of serialized output to be de-serialized and serialized back.
2013-05-02 13:25:04 +00:00
virtual bool
operator==(const class_tdecl&) const;
Initial support of class templates * src/abg-ir.cc (class_template_decl::class_template_decl) (class_template_decl::set_pattern) (class_template_decl::operator==) (class_template_decl::~class_template_decl) (class_template_decl_hash::operator()) (class_tmpl_shared_ptr_hash::operator()): New definitions. * src/abg-ir.h (class class_template_decl, struct class_tmpl_shared_ptr_hash, struct class_tmpl_shared_ptr_hash): New declarations. * src/abg-reader.cc (read_context::const_class_tmpl_map_it): New typedef. (read_context::get_fn_tmpl_decl): Fix comment. (read_context::{get_class_tmpl_decl,key_class_tmpl_decl}) (build_class_template_decl, handle_class_template_decl): New definitions. (read_context::m_class_tmpl_map): New member. (handle_element): Support "class-template-decl" xml elements nodes. (build_class_decl): Add missing bits to comment. (build_function_template_decl): Fix spacing. * src/abg-writer.cc (class_tmpl_shared_ptr_map): New typedef. (write_context::m_class_tmpl_map): New member. (write_context::get_id_for_class_tmpl, write_class_template_decl): New definitions. (write_template_parameters): Factorize this this out from ... (write_function_template_decl): ... here. (write_decl): Support writing instances of class_template_decl. Fix spacing. * tests/data/test-read-write/test15.xml: New test input. * tests/Makefile.am: Add the new test15.xml input to the distribution. * tests/test-read-write.cc (in_out_specs): Add the new test15.xml test to the list of serialized output to be de-serialized and serialized back.
2013-05-02 13:25:04 +00:00
void
set_pattern(shared_ptr<class_decl> p);
shared_ptr<class_decl>
get_pattern() const
{return pattern_;}
Initial support of class templates * src/abg-ir.cc (class_template_decl::class_template_decl) (class_template_decl::set_pattern) (class_template_decl::operator==) (class_template_decl::~class_template_decl) (class_template_decl_hash::operator()) (class_tmpl_shared_ptr_hash::operator()): New definitions. * src/abg-ir.h (class class_template_decl, struct class_tmpl_shared_ptr_hash, struct class_tmpl_shared_ptr_hash): New declarations. * src/abg-reader.cc (read_context::const_class_tmpl_map_it): New typedef. (read_context::get_fn_tmpl_decl): Fix comment. (read_context::{get_class_tmpl_decl,key_class_tmpl_decl}) (build_class_template_decl, handle_class_template_decl): New definitions. (read_context::m_class_tmpl_map): New member. (handle_element): Support "class-template-decl" xml elements nodes. (build_class_decl): Add missing bits to comment. (build_function_template_decl): Fix spacing. * src/abg-writer.cc (class_tmpl_shared_ptr_map): New typedef. (write_context::m_class_tmpl_map): New member. (write_context::get_id_for_class_tmpl, write_class_template_decl): New definitions. (write_template_parameters): Factorize this this out from ... (write_function_template_decl): ... here. (write_decl): Support writing instances of class_template_decl. Fix spacing. * tests/data/test-read-write/test15.xml: New test input. * tests/Makefile.am: Add the new test15.xml input to the distribution. * tests/test-read-write.cc (in_out_specs): Add the new test15.xml test to the list of serialized output to be de-serialized and serialized back.
2013-05-02 13:25:04 +00:00
virtual void
traverse(ir_node_visitor& v);
Initial support of class templates * src/abg-ir.cc (class_template_decl::class_template_decl) (class_template_decl::set_pattern) (class_template_decl::operator==) (class_template_decl::~class_template_decl) (class_template_decl_hash::operator()) (class_tmpl_shared_ptr_hash::operator()): New definitions. * src/abg-ir.h (class class_template_decl, struct class_tmpl_shared_ptr_hash, struct class_tmpl_shared_ptr_hash): New declarations. * src/abg-reader.cc (read_context::const_class_tmpl_map_it): New typedef. (read_context::get_fn_tmpl_decl): Fix comment. (read_context::{get_class_tmpl_decl,key_class_tmpl_decl}) (build_class_template_decl, handle_class_template_decl): New definitions. (read_context::m_class_tmpl_map): New member. (handle_element): Support "class-template-decl" xml elements nodes. (build_class_decl): Add missing bits to comment. (build_function_template_decl): Fix spacing. * src/abg-writer.cc (class_tmpl_shared_ptr_map): New typedef. (write_context::m_class_tmpl_map): New member. (write_context::get_id_for_class_tmpl, write_class_template_decl): New definitions. (write_template_parameters): Factorize this this out from ... (write_function_template_decl): ... here. (write_decl): Support writing instances of class_template_decl. Fix spacing. * tests/data/test-read-write/test15.xml: New test input. * tests/Makefile.am: Add the new test15.xml input to the distribution. * tests/test-read-write.cc (in_out_specs): Add the new test15.xml test to the list of serialized output to be de-serialized and serialized back.
2013-05-02 13:25:04 +00:00
virtual ~class_tdecl();
};// end class class_tdecl
Initial support of class templates * src/abg-ir.cc (class_template_decl::class_template_decl) (class_template_decl::set_pattern) (class_template_decl::operator==) (class_template_decl::~class_template_decl) (class_template_decl_hash::operator()) (class_tmpl_shared_ptr_hash::operator()): New definitions. * src/abg-ir.h (class class_template_decl, struct class_tmpl_shared_ptr_hash, struct class_tmpl_shared_ptr_hash): New declarations. * src/abg-reader.cc (read_context::const_class_tmpl_map_it): New typedef. (read_context::get_fn_tmpl_decl): Fix comment. (read_context::{get_class_tmpl_decl,key_class_tmpl_decl}) (build_class_template_decl, handle_class_template_decl): New definitions. (read_context::m_class_tmpl_map): New member. (handle_element): Support "class-template-decl" xml elements nodes. (build_class_decl): Add missing bits to comment. (build_function_template_decl): Fix spacing. * src/abg-writer.cc (class_tmpl_shared_ptr_map): New typedef. (write_context::m_class_tmpl_map): New member. (write_context::get_id_for_class_tmpl, write_class_template_decl): New definitions. (write_template_parameters): Factorize this this out from ... (write_function_template_decl): ... here. (write_decl): Support writing instances of class_template_decl. Fix spacing. * tests/data/test-read-write/test15.xml: New test input. * tests/Makefile.am: Add the new test15.xml input to the distribution. * tests/test-read-write.cc (in_out_specs): Add the new test15.xml test to the list of serialized output to be de-serialized and serialized back.
2013-05-02 13:25:04 +00:00
Fix class scope setting & member type de-serializing from dwarf * include/abg-fwd.h (add_decl_to_scope, insert_decl_into_scope): return the decl added to the scope. (as_non_member_type, get_type_declaration): Declare new entry points. * include/abg-ir.h (class decl_base::insert_decl_into_scope): Update this friend declaration. (class scope_decl, class_decl): Update the friend add_decl_to_scope declaration. (scope_decl::add_member_decl): Return the added decl. (class_decl_sptr): Move this typedef befoer the class_decl class declaration. (class_decl::definition_of_declaration_): New member. (class_decl::{set_definition_of_declaration, get_definition_of_declaration}): New accessors. (class_decl::add_member_decl): Return the added member. (class_decl::insert_member_type): New member. (class_decl::member_base::access_specifier): Make this protected. (class_decl::member_type): Make this inherit from type_vase. (class_decl::member_type::type_): Remove this member. (class_decl::member_type::as_type): Remove this accessor. (class_decl::member_type::operator==(const type_base&)): New. (class_decl::member_type::operator shared_ptr<type_base>() const): Remove. (class_decl::member_type::get_underlying_type): New. (class_decl::member_type::operator==(const member_type&) const): New. * src/abg-comparison.cc (class_diff::{ensure_lookup_tables_populated, report}): Adjust for the removal of class_decl::member_type::as_type. * src/abg-dwarf-reader.cc (scope_stack_type): Change this as a typedef to stack<scope_decl*>. (current_scope): Change return type from scope_decl_sptr to scope_decl*. (insert_decl_into_scope): New. (build_namespace_decl_and_add_to_ir): Use insert_decl_into_scope in lieu of add_decl_to_scope. (build_class_type_and_add_to_ir): likewise. Link a class definition to its declaration. Push the current scope on the scope stack. Use as_non_member_type. Fix setting member types. (get_scope_for_die): Look through declaration-only classe to get its definition. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type, build_var_decl) (build_function_decl): Use as_non_member_type. (build_ir_node_from_die): Fix member variable & function adding. * src/abg-ir.cc (scope_decl::{add_member_decl, insert_member_decl}): Return the added member. (add_decl_to_scope): Likewise. (insert_decl_into_scope): Likewise. (get_top_most_scope_under): Fix logic. (get_type_declaration): New overload that return a decl_base*. (as_non_member_type): New definition. (class_decl::{get_definition_of_declaration, set_definition_of_declaration, insert_member_decl}): Likewise. (class_decl::add_member_decl): Re-write in terms of class::insert_member_decl. (class_decl::insert_member_type): New definition. (class_decl::add_member_type): Re-write in terms of class_decl::insert_member_type. (class_decl::remove_member_type): Update for the class_decl::member_type::as_type removal. (class_decl::{add_data_member, add_member_function, add_member_function_template, add_member_class_template}): Call scope_decl::add_member_decl. (class_decl::member_type::member_type): Update as the type now virtually inherits from type_base. (class_decl::member_type::{set,get}_access_specifier): New definitions. (class_decl::member_type::get_underlying_type): Likewise. (class_decl::member_type::set_scope): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. (class_decl::member_type::operator==(const decl_base& other)): There is no more class_decl::member_type::as_type. (class_decl::member_type::operator==(const type_base& other)): New. (class_decl::member_type::get_pretty_representation): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. * src/abg-reader.cc (build_class_decl): New that add add_member_decl adds even member types, no need to add it explicitly anymore. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 11:27:47 +00:00
/// Convenience typedef for a shared pointer on a @ref class_decl
typedef shared_ptr<class_decl> class_decl_sptr;
Initial Support for class declarations * src/abg-ir.h (scope_decl::scope_decl) (scope_type_decl::scope_type_decl): Don't set mangled name for scope_decl instances as it doesn't make sense. (var_decl::var_decl): Pass the type shared pointer by value. (struct var_decl_hash, function_decl::parameter::operator==) (struct function_decl::parameter_hash, function_decl::operator==) (struct function_decl_hash, class class_decl, struct class_decl_hash): New declarations. * src/abg-ir.cc (scope_type_decl::scope_type_decl): Don't set the mangled name. It doesn't make sense for scope_decls. (dynamic_type_hash::operator): Fix comment. Run the hashing for scope_type_decl instances *after* running it for class_decl instance, otherwise, the class_decl instances case will never get hit. (var_decl::var_decl): Pass the type shared pointer by value. (function_decl::operator==, class_decl::operator==) (class_decl_hash::operator()): New fns. * src/abg-libxml-utils.h (get_xml_node_depth): Declare new fn. (XML_READER_GET_ATTRIBUTE): Fix comment. (XML_NODE_GET_ATTRIBUTE): New getter macro. * src/abg-libxml-utils.cc (get_xml_node_depth): New definition. * src/abg-reader.cc (update_read_context) (update_depth_info_of_read_context, read_visibility, read_binding) (read_access, read_size_and_alignment, read_static) (read_var_offset_in_bits, read_cdtor_const, build_function_decl) ( build_var_decl, build_type_decl, build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_enum_type_decl, build_typedef_decl, build_class_decl) (build_type, handle_class_decl): New functions or overloads. (handle_element): Update to handle "class-decl" xml elements. * src/abg-writer.cc (write_size_and_alignment, write_access) (write_class, do_indent_to_level, get_indent_to_level): New fns. (write_decl): Update to serialize instances of class_decl. (write_type_decl, write_pointer_type_def) (write_reference_type_def): Use the new write_size_and_alignment instead of writing the attributes directly. * tests/data/test-read-write/test10.xml: New test file. * tests/Makefile.am: Add tests/data/test-read-write/test10.xml to the build system. * tests/test-read-write.cc (in_out_spec): De-serialize data/test-read-write/test10.xml, serialize it back into output/test-read-write/test10.xml, and compare the two output that should be identical.
2013-04-11 20:02:08 +00:00
/// Abstracts a class declaration.
class class_decl : public scope_type_decl
{
// Forbidden
class_decl();
public:
/// Hasher.
struct hash;
Initial Support for class declarations * src/abg-ir.h (scope_decl::scope_decl) (scope_type_decl::scope_type_decl): Don't set mangled name for scope_decl instances as it doesn't make sense. (var_decl::var_decl): Pass the type shared pointer by value. (struct var_decl_hash, function_decl::parameter::operator==) (struct function_decl::parameter_hash, function_decl::operator==) (struct function_decl_hash, class class_decl, struct class_decl_hash): New declarations. * src/abg-ir.cc (scope_type_decl::scope_type_decl): Don't set the mangled name. It doesn't make sense for scope_decls. (dynamic_type_hash::operator): Fix comment. Run the hashing for scope_type_decl instances *after* running it for class_decl instance, otherwise, the class_decl instances case will never get hit. (var_decl::var_decl): Pass the type shared pointer by value. (function_decl::operator==, class_decl::operator==) (class_decl_hash::operator()): New fns. * src/abg-libxml-utils.h (get_xml_node_depth): Declare new fn. (XML_READER_GET_ATTRIBUTE): Fix comment. (XML_NODE_GET_ATTRIBUTE): New getter macro. * src/abg-libxml-utils.cc (get_xml_node_depth): New definition. * src/abg-reader.cc (update_read_context) (update_depth_info_of_read_context, read_visibility, read_binding) (read_access, read_size_and_alignment, read_static) (read_var_offset_in_bits, read_cdtor_const, build_function_decl) ( build_var_decl, build_type_decl, build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_enum_type_decl, build_typedef_decl, build_class_decl) (build_type, handle_class_decl): New functions or overloads. (handle_element): Update to handle "class-decl" xml elements. * src/abg-writer.cc (write_size_and_alignment, write_access) (write_class, do_indent_to_level, get_indent_to_level): New fns. (write_decl): Update to serialize instances of class_decl. (write_type_decl, write_pointer_type_def) (write_reference_type_def): Use the new write_size_and_alignment instead of writing the attributes directly. * tests/data/test-read-write/test10.xml: New test file. * tests/Makefile.am: Add tests/data/test-read-write/test10.xml to the build system. * tests/test-read-write.cc (in_out_spec): De-serialize data/test-read-write/test10.xml, serialize it back into output/test-read-write/test10.xml, and compare the two output that should be identical.
2013-04-11 20:02:08 +00:00
/// Language access specifier.
Initial Support for class declarations * src/abg-ir.h (scope_decl::scope_decl) (scope_type_decl::scope_type_decl): Don't set mangled name for scope_decl instances as it doesn't make sense. (var_decl::var_decl): Pass the type shared pointer by value. (struct var_decl_hash, function_decl::parameter::operator==) (struct function_decl::parameter_hash, function_decl::operator==) (struct function_decl_hash, class class_decl, struct class_decl_hash): New declarations. * src/abg-ir.cc (scope_type_decl::scope_type_decl): Don't set the mangled name. It doesn't make sense for scope_decls. (dynamic_type_hash::operator): Fix comment. Run the hashing for scope_type_decl instances *after* running it for class_decl instance, otherwise, the class_decl instances case will never get hit. (var_decl::var_decl): Pass the type shared pointer by value. (function_decl::operator==, class_decl::operator==) (class_decl_hash::operator()): New fns. * src/abg-libxml-utils.h (get_xml_node_depth): Declare new fn. (XML_READER_GET_ATTRIBUTE): Fix comment. (XML_NODE_GET_ATTRIBUTE): New getter macro. * src/abg-libxml-utils.cc (get_xml_node_depth): New definition. * src/abg-reader.cc (update_read_context) (update_depth_info_of_read_context, read_visibility, read_binding) (read_access, read_size_and_alignment, read_static) (read_var_offset_in_bits, read_cdtor_const, build_function_decl) ( build_var_decl, build_type_decl, build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_enum_type_decl, build_typedef_decl, build_class_decl) (build_type, handle_class_decl): New functions or overloads. (handle_element): Update to handle "class-decl" xml elements. * src/abg-writer.cc (write_size_and_alignment, write_access) (write_class, do_indent_to_level, get_indent_to_level): New fns. (write_decl): Update to serialize instances of class_decl. (write_type_decl, write_pointer_type_def) (write_reference_type_def): Use the new write_size_and_alignment instead of writing the attributes directly. * tests/data/test-read-write/test10.xml: New test file. * tests/Makefile.am: Add tests/data/test-read-write/test10.xml to the build system. * tests/test-read-write.cc (in_out_spec): De-serialize data/test-read-write/test10.xml, serialize it back into output/test-read-write/test10.xml, and compare the two output that should be identical.
2013-04-11 20:02:08 +00:00
enum access_specifier
{
Support method type/decl, variadic functions, class declarations-only * src/abg-ir.h (function_decl::parameter::parameter): New constructor with variadic parameter marker. (function_decl::m_type): Make this protected to let method_decl inheriting class to access it. (function_decl::get_type): Move this out-of-line. (class method_type, method_type_hash): New types. (enum class_decl::access_specifier): Add no_access new enumerator. (class_decl::data_member::data_member): Move this out-of-line. (class_decl::data_member::~data_member): Declare virtual destructor. (class method_decl): New class. (class member_function): Make this inherit method_decl, instead of function_decl. (class_decl::class_decl): New constructors. (class_decl::{hashing_started, is_declaration_only, set_earlier_declaration, get_earlier_declaration}): New methods. * src/abg-ir.cc (add_decl_to_scope): If a decl is already in a scope, don't add it to this scope. (get_global_scope): Make this work when passed an instance of global_scope. (dynamic_type_hash::operator()): Add support for method_type. (method_type::{method_type, set_class_type, ~method_type, }) (method_type_hash::operator()): New defintions. (function_decl::get_type, class_decl::class_decl): Move these out-of-line here. (class_decl::method_decl::{method_decl, ~method_decl, get_type}): New definitions. (class_decl::member_function::member_function): Move this out-of-line here. Support method_decl. (class_decl::data_member::data_member): Likewise. (class_decl_hash::operator()): Guard this against endless loop. * src/abg-reader.cc (write_class_is_declaration_only): New static function. (write_var_decl): Take a flag to write the mangled name or not. (write_function_decl): Take a flag to skip the first parameter. (write_cdtor_const_static): Use 'yes' instead of 'true' as value of the properties. (write_decl, write_function_template_decl): Adjust wrt the new signatures of write_var_decl and write_function_decl. (write_enum_type_decl): Simplify call to write_location. (write_class_decl): Support serializing declaration-only classes. * src/abg-writer.cc: * tests/data/test-read-write/test17.xml: New test input. * tests/test-read-write.cc: De-serialize the above, and serialize it back. * tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
no_access,
public_access,
Initial Support for class declarations * src/abg-ir.h (scope_decl::scope_decl) (scope_type_decl::scope_type_decl): Don't set mangled name for scope_decl instances as it doesn't make sense. (var_decl::var_decl): Pass the type shared pointer by value. (struct var_decl_hash, function_decl::parameter::operator==) (struct function_decl::parameter_hash, function_decl::operator==) (struct function_decl_hash, class class_decl, struct class_decl_hash): New declarations. * src/abg-ir.cc (scope_type_decl::scope_type_decl): Don't set the mangled name. It doesn't make sense for scope_decls. (dynamic_type_hash::operator): Fix comment. Run the hashing for scope_type_decl instances *after* running it for class_decl instance, otherwise, the class_decl instances case will never get hit. (var_decl::var_decl): Pass the type shared pointer by value. (function_decl::operator==, class_decl::operator==) (class_decl_hash::operator()): New fns. * src/abg-libxml-utils.h (get_xml_node_depth): Declare new fn. (XML_READER_GET_ATTRIBUTE): Fix comment. (XML_NODE_GET_ATTRIBUTE): New getter macro. * src/abg-libxml-utils.cc (get_xml_node_depth): New definition. * src/abg-reader.cc (update_read_context) (update_depth_info_of_read_context, read_visibility, read_binding) (read_access, read_size_and_alignment, read_static) (read_var_offset_in_bits, read_cdtor_const, build_function_decl) ( build_var_decl, build_type_decl, build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_enum_type_decl, build_typedef_decl, build_class_decl) (build_type, handle_class_decl): New functions or overloads. (handle_element): Update to handle "class-decl" xml elements. * src/abg-writer.cc (write_size_and_alignment, write_access) (write_class, do_indent_to_level, get_indent_to_level): New fns. (write_decl): Update to serialize instances of class_decl. (write_type_decl, write_pointer_type_def) (write_reference_type_def): Use the new write_size_and_alignment instead of writing the attributes directly. * tests/data/test-read-write/test10.xml: New test file. * tests/Makefile.am: Add tests/data/test-read-write/test10.xml to the build system. * tests/test-read-write.cc (in_out_spec): De-serialize data/test-read-write/test10.xml, serialize it back into output/test-read-write/test10.xml, and compare the two output that should be identical.
2013-04-11 20:02:08 +00:00
protected_access,
private_access,
};
Initial Support for class declarations * src/abg-ir.h (scope_decl::scope_decl) (scope_type_decl::scope_type_decl): Don't set mangled name for scope_decl instances as it doesn't make sense. (var_decl::var_decl): Pass the type shared pointer by value. (struct var_decl_hash, function_decl::parameter::operator==) (struct function_decl::parameter_hash, function_decl::operator==) (struct function_decl_hash, class class_decl, struct class_decl_hash): New declarations. * src/abg-ir.cc (scope_type_decl::scope_type_decl): Don't set the mangled name. It doesn't make sense for scope_decls. (dynamic_type_hash::operator): Fix comment. Run the hashing for scope_type_decl instances *after* running it for class_decl instance, otherwise, the class_decl instances case will never get hit. (var_decl::var_decl): Pass the type shared pointer by value. (function_decl::operator==, class_decl::operator==) (class_decl_hash::operator()): New fns. * src/abg-libxml-utils.h (get_xml_node_depth): Declare new fn. (XML_READER_GET_ATTRIBUTE): Fix comment. (XML_NODE_GET_ATTRIBUTE): New getter macro. * src/abg-libxml-utils.cc (get_xml_node_depth): New definition. * src/abg-reader.cc (update_read_context) (update_depth_info_of_read_context, read_visibility, read_binding) (read_access, read_size_and_alignment, read_static) (read_var_offset_in_bits, read_cdtor_const, build_function_decl) ( build_var_decl, build_type_decl, build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_enum_type_decl, build_typedef_decl, build_class_decl) (build_type, handle_class_decl): New functions or overloads. (handle_element): Update to handle "class-decl" xml elements. * src/abg-writer.cc (write_size_and_alignment, write_access) (write_class, do_indent_to_level, get_indent_to_level): New fns. (write_decl): Update to serialize instances of class_decl. (write_type_decl, write_pointer_type_def) (write_reference_type_def): Use the new write_size_and_alignment instead of writing the attributes directly. * tests/data/test-read-write/test10.xml: New test file. * tests/Makefile.am: Add tests/data/test-read-write/test10.xml to the build system. * tests/test-read-write.cc (in_out_spec): De-serialize data/test-read-write/test10.xml, serialize it back into output/test-read-write/test10.xml, and compare the two output that should be identical.
2013-04-11 20:02:08 +00:00
/// Forward declarations.
class member_base;
class member_type;
class base_spec;
class data_member;
class method_decl;
class member_function;
class member_function_template;
class member_class_template;
/// Convenience typedef
/// @{
typedef shared_ptr<base_spec> base_spec_sptr;
Un-debugged initial implementation of class diffing. * include/abg-ir.h (decl_base::get_qualified_name): New declaration. (class_decl::{base_specs, member_types, data_members, member_functions, member_function_templates, member_class_templates}): Make all these containers be vectors, rather than list. This makes these containers (like class_decl::base_specs, class_decl::member_types, etc) be suitable to be used by the core diffing algorithms to diff their content. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Declare these new equality operators. These are to be used by the core diffing algorithms when comparing two vectors of shared pointers of members of class_decls. * src/abg-ir.cc (decl_base::get_qualified_name): Define. (class_decl::class_decl, class_decl::operator==(class_decl&)): Adjust for the containers type change to a vector. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Define these. * include/abg-comparison.h (diff::scope_): Remove (diff::{first_scope_, second_scope_}): New members. (class_decl_diff::class_decl_diff): Pass the new scopes to this constructor. (class_decl_diff::{first_class_decl, second_class_decl}) (report_changes): New declarations. * src/abg-comparison.cc (class_decl_diff::class_decl_diff): Update as per the declaration. (class_decl_diff::{first_class_decl, second_class_decl}): Define as per the declaration. (compute_diff): Initial implementation for this. (report_changes): Define. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-04 15:39:08 +00:00
typedef std::vector<base_spec_sptr> base_specs;
typedef shared_ptr<member_type> member_type_sptr;
Un-debugged initial implementation of class diffing. * include/abg-ir.h (decl_base::get_qualified_name): New declaration. (class_decl::{base_specs, member_types, data_members, member_functions, member_function_templates, member_class_templates}): Make all these containers be vectors, rather than list. This makes these containers (like class_decl::base_specs, class_decl::member_types, etc) be suitable to be used by the core diffing algorithms to diff their content. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Declare these new equality operators. These are to be used by the core diffing algorithms when comparing two vectors of shared pointers of members of class_decls. * src/abg-ir.cc (decl_base::get_qualified_name): Define. (class_decl::class_decl, class_decl::operator==(class_decl&)): Adjust for the containers type change to a vector. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Define these. * include/abg-comparison.h (diff::scope_): Remove (diff::{first_scope_, second_scope_}): New members. (class_decl_diff::class_decl_diff): Pass the new scopes to this constructor. (class_decl_diff::{first_class_decl, second_class_decl}) (report_changes): New declarations. * src/abg-comparison.cc (class_decl_diff::class_decl_diff): Update as per the declaration. (class_decl_diff::{first_class_decl, second_class_decl}): Define as per the declaration. (compute_diff): Initial implementation for this. (report_changes): Define. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-04 15:39:08 +00:00
typedef std::vector<member_type_sptr> member_types;
typedef shared_ptr<data_member> data_member_sptr;
Un-debugged initial implementation of class diffing. * include/abg-ir.h (decl_base::get_qualified_name): New declaration. (class_decl::{base_specs, member_types, data_members, member_functions, member_function_templates, member_class_templates}): Make all these containers be vectors, rather than list. This makes these containers (like class_decl::base_specs, class_decl::member_types, etc) be suitable to be used by the core diffing algorithms to diff their content. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Declare these new equality operators. These are to be used by the core diffing algorithms when comparing two vectors of shared pointers of members of class_decls. * src/abg-ir.cc (decl_base::get_qualified_name): Define. (class_decl::class_decl, class_decl::operator==(class_decl&)): Adjust for the containers type change to a vector. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Define these. * include/abg-comparison.h (diff::scope_): Remove (diff::{first_scope_, second_scope_}): New members. (class_decl_diff::class_decl_diff): Pass the new scopes to this constructor. (class_decl_diff::{first_class_decl, second_class_decl}) (report_changes): New declarations. * src/abg-comparison.cc (class_decl_diff::class_decl_diff): Update as per the declaration. (class_decl_diff::{first_class_decl, second_class_decl}): Define as per the declaration. (compute_diff): Initial implementation for this. (report_changes): Define. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-04 15:39:08 +00:00
typedef std::vector<data_member_sptr> data_members;
typedef shared_ptr<member_function> member_function_sptr;
Un-debugged initial implementation of class diffing. * include/abg-ir.h (decl_base::get_qualified_name): New declaration. (class_decl::{base_specs, member_types, data_members, member_functions, member_function_templates, member_class_templates}): Make all these containers be vectors, rather than list. This makes these containers (like class_decl::base_specs, class_decl::member_types, etc) be suitable to be used by the core diffing algorithms to diff their content. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Declare these new equality operators. These are to be used by the core diffing algorithms when comparing two vectors of shared pointers of members of class_decls. * src/abg-ir.cc (decl_base::get_qualified_name): Define. (class_decl::class_decl, class_decl::operator==(class_decl&)): Adjust for the containers type change to a vector. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Define these. * include/abg-comparison.h (diff::scope_): Remove (diff::{first_scope_, second_scope_}): New members. (class_decl_diff::class_decl_diff): Pass the new scopes to this constructor. (class_decl_diff::{first_class_decl, second_class_decl}) (report_changes): New declarations. * src/abg-comparison.cc (class_decl_diff::class_decl_diff): Update as per the declaration. (class_decl_diff::{first_class_decl, second_class_decl}): Define as per the declaration. (compute_diff): Initial implementation for this. (report_changes): Define. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-04 15:39:08 +00:00
typedef std::vector<member_function_sptr> member_functions;
typedef shared_ptr<member_function_template> member_function_template_sptr;
Un-debugged initial implementation of class diffing. * include/abg-ir.h (decl_base::get_qualified_name): New declaration. (class_decl::{base_specs, member_types, data_members, member_functions, member_function_templates, member_class_templates}): Make all these containers be vectors, rather than list. This makes these containers (like class_decl::base_specs, class_decl::member_types, etc) be suitable to be used by the core diffing algorithms to diff their content. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Declare these new equality operators. These are to be used by the core diffing algorithms when comparing two vectors of shared pointers of members of class_decls. * src/abg-ir.cc (decl_base::get_qualified_name): Define. (class_decl::class_decl, class_decl::operator==(class_decl&)): Adjust for the containers type change to a vector. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Define these. * include/abg-comparison.h (diff::scope_): Remove (diff::{first_scope_, second_scope_}): New members. (class_decl_diff::class_decl_diff): Pass the new scopes to this constructor. (class_decl_diff::{first_class_decl, second_class_decl}) (report_changes): New declarations. * src/abg-comparison.cc (class_decl_diff::class_decl_diff): Update as per the declaration. (class_decl_diff::{first_class_decl, second_class_decl}): Define as per the declaration. (compute_diff): Initial implementation for this. (report_changes): Define. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-04 15:39:08 +00:00
typedef std::vector<member_function_template_sptr> member_function_templates;
typedef shared_ptr<member_class_template> member_class_template_sptr;
Un-debugged initial implementation of class diffing. * include/abg-ir.h (decl_base::get_qualified_name): New declaration. (class_decl::{base_specs, member_types, data_members, member_functions, member_function_templates, member_class_templates}): Make all these containers be vectors, rather than list. This makes these containers (like class_decl::base_specs, class_decl::member_types, etc) be suitable to be used by the core diffing algorithms to diff their content. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Declare these new equality operators. These are to be used by the core diffing algorithms when comparing two vectors of shared pointers of members of class_decls. * src/abg-ir.cc (decl_base::get_qualified_name): Define. (class_decl::class_decl, class_decl::operator==(class_decl&)): Adjust for the containers type change to a vector. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Define these. * include/abg-comparison.h (diff::scope_): Remove (diff::{first_scope_, second_scope_}): New members. (class_decl_diff::class_decl_diff): Pass the new scopes to this constructor. (class_decl_diff::{first_class_decl, second_class_decl}) (report_changes): New declarations. * src/abg-comparison.cc (class_decl_diff::class_decl_diff): Update as per the declaration. (class_decl_diff::{first_class_decl, second_class_decl}): Define as per the declaration. (compute_diff): Initial implementation for this. (report_changes): Define. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-04 15:39:08 +00:00
typedef std::vector<member_class_template_sptr> member_class_templates;
/// @}
Initial support for function templates * src/abg-ir.h (function_decl::set_return_type): New inline definition. (class template_decl, struct template_decl_hash, class template_parameter, struct template_parameter_hash, struct dynamic_template_parameter_hash, struct template_parameter_shared_ptr_hash, class template_type_parameter) (struct template_type_parameter_hash, class template_non_type_parameter, struct template_non_type_parameter_hash, class template_template_parameter, struct template_template_parameter_hash, class function_template_decl) (struct function_template_decl_hash, struct fn_tmpl_shared_ptr_hash): New declarations. * src/abg-ir.cc (dynamic_type_hash::operator()): Add hashing for template template, and template type parameters. (template_decl_hash::operator, template_decl::~template_decl) (template_decl::operator==, template_parameter::operator==) (template_parameter_hash::operator()) (dynamic_template_parameter_hash::operator()) (template_type_parameter::operator==) (template_type_parameter::~template_type_parameter) (template_type_parameter_hash::operator()) (template_non_type_parameter::operator==) (template_non_type_parameter::~template_non_type_parameter) (template_non_type_parameter_hash::operator()) (template_template_parameter::operator==) (template_template_parameter::~template_template_parameter) (template_template_parameter_hash::operator()) (function_template_decl::operator==) (function_template_decl_hash::operator()) (fn_tmpl_shared_ptr_hash::operator()) (function_template_decl::~function_template_decl()): New definitions. * src/abg-reader.cc (read_context::get_fn_tmpl_decl) (read_context::key_fn_tmpl_decl): New functions. (read_context::m_fn_tmpl_map): New data member. (read_context::key_type_decl): Renamed read_context::add_type_decl into this. (read_context::push_decl_to_current_scope): Renamed read_context::finish_decl_creation into this. Add an assert. (read_context::push_and_key_type_decl): Renamed read_context::finish_type_decl_creation into this. Adjust to the use of push_decl_to_current_scope and key_type_decl. (build_function_template_decl, build_template_type_parameter) (build_template_non_type_parameter) (build_template_template_parameter, build_template_parameter) (handle_function_template_decl): New functions. (handle_element): Call handle_function_template_decl. (build_function_decl): Take a bool parameter to update depth information in parsing context. Move instantiation of function_decl before parsing its xml sub-nodes. Update the depth info in the parsing context if necessary. Push the newly intantiated decl to scope. And then parse the sub nodes. Do not forget to add the fn parameters and return type using function_decl::add_parameter and function_decl::set_return_type. (build_var_decl, build_type_decl, build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_enum_type_decl, build_typedef_decl, handled_type_decl) (handle_qualified_type_decl, handle_pointer_type_def) (handle_reference_type_def, handle_enum_type_decl) (handle_typedef_decl, handle_var_decl, handle_function_decl) (handle_class_decl): Adjust. (build_class_decl): Take a bool parameter to update depth information in parsing context. Add comment. Wait for the class members to be built, before keying (and thus hashing it) the class. (build_type): Fix logic, and adjust. * src/abg-writer.cc (write_context::type_has_existing_id) (write_context::get_id_for_fn_tmpl, write_template_type_parameter) (write_template_non_type_parameter) (write_template_template_parameter, write_template_parameter) (write_function_template_decl): New functions. (write_context::get_id_for_type): Simplify logic. (write_decl): Support writing function template. * tests/data/test-read-write/test11.xml: New test input. * tests/test-read-write.cc (InoutSpec in_out_specs[]): De-serialize the new test11.xml test, serialize it back and diff output and input. * tests/Makefile.am: Add test11.xml to the distribution.
2013-04-23 09:27:32 +00:00
private:
mutable bool hashing_started_;
Support looking through decl-only classes and update diff reports accordingly * include/abg-comparison.h (class diff_context): New class. (class diff::{ctxt_, reported_once_, currently_reporting_}): New data members. (diff::diff): Initialize the new data members above. (diff::{context, currently_reporting, reported_once}): New accessors. (compute_diff, var_diff::var_diff, pointer_diff::pointer_diff) (reference_diff::reference_diff, qualified_type_diff) (enum_diff:enum_diff, class_diff::class_diff) (scope_diff::scope_diff, function_decl_diff::function_decl_diff) (type_decl_diff::type_decl_diff, typedef_diff::typedef_diff) (translation_unit_diff::translation_unit_diff, corpus_diff::corpus_diff): Take an additional pointer to diff_context. * abg-comparison.cc (diff_context::{has_diff_for, has_diff_for_types, add_diff}): New methods. (try_to_diff, compute_diff_for_types, compute_diff_for_decls) (represent): Take an additional pointer to diff_context in argument. In the later function, do not re-report a diff if it has already been reported, or if it's being reported already. (var_diff::var_diff, pointer_diff::pointer_diff) (reference_diff::reference_diff) (qualified_type_diff::qualified_type_diff, enum_diff::enum_diff) (class_diff::class_diff, scope_diff::scope_diff) (function_decl_diff::function_decl_diff, type_decl::type_decl) (typedef_diff::typedef_diff) (translation_unit_diff::translation_unit_diff) (corpus_diff::corpus_diff): Take an additional pointer to diff_context in argument. ({pointer_diff, qualified_type_diff, reference_type_diff}::report): do not re-report a diff about the underlying type if it has already been reported, or if it's being reported already. (enum_diff::report): Fix this to properly use the populated lookup tables. (compute_diff): take an additional pointer to diff_context in argument. For the var_decl, pointer_diff reference_type_diff, qualified_type_diff enum_diff, scope_diff, function_decl_diff, type_decl_diff and typedef_diff overloads, do not re-build a diff object, if one exits already. Otherwise, record the new diff object created so that it can be re-used later. (enum_diff::ensure_lookup_tables_populated): Fix logic to avoid one loop. (class_decl::priv::{deleted_member_functions_, inserted_member_functions_, changed_member_function_}): New members to support reporting about member functions changes. (class_decl::{lookup_tables_empty, clear_lookup_tables, length): Update for the new additions above. (class_decl::ensure_lookup_tables_populated): Likewise. Fix to properly use the lookup tables and also avoid a going through several loops to compute the changed members. (class_decl::report): Flip a switch to make the beginning and end of the reporting, in the context. Also, do not try to report again, if we were already reporting this diff. Fix quite some spots to properly use the lookup tables. (scope_diff::ensure_lookup_tables_populated): Skip decl-only classes during comparison. Fix some thinkos. Fix logic to avoid a loop. (scope_diff::report): Adjust to pass a context to compute_diff_for_types. (function_decl_diff::ensure_lookup_tables_populated): Fix logic to avoid a loop. (function_decl_diff::report): Adjust call to compute_diff_for_types to pass the context. (typedef::report): Avoid re-reporting the diff of the underlying types, if we are already reporting it. (corpus_diff::priv::ensure_lookup_tables_populated): Use the pretty representation of the function rather than its name to key the maps of deleted and added functions. Fix logic to avoid going through an additional loop for the changed functions. (corpus_diff::report): Add a title for removed/added/changed functions. Fix indentation for added/removed/changed functions. * include/abg-ir.h (class_decl::comparison_started_): New member * src/abg-dwarf-reader.cc (is_public_decl): Style fix. (is_declaration_only_): New static function. (build_class_type_and_add_to_ir): Create decl-only classes (IR) for classes flagged as declaration-only in the DWARF. * src/abg-hash.cc (class_decl::hash::operator()): Do not forget to include the "is_declaration_only" flag into the hashing. * src/abg-ir.cc (class_decl::operator==): Look through decl-only classes to get their definitions and compare the definitions instead. Avoid comparing member types and fns if the comparison of this type has already started. * src/abg-reader.cc (build_class_decl): Set the definition of a declaration, when we see it. * tests/data/test-bidiff/test-qual-type0-report.txt: Update. * tests/data/test-bidiff/test-struct0-report.txt: Likewise. * tests/data/test-bidiff/test-struct1-report.txt: Likewise. signed-off-by: Dodji Seketeli <dodji@redhat.com> Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-07 17:52:45 +00:00
mutable bool comparison_started_;
decl_base_sptr declaration_;
bool is_declaration_only_;
Fix class scope setting & member type de-serializing from dwarf * include/abg-fwd.h (add_decl_to_scope, insert_decl_into_scope): return the decl added to the scope. (as_non_member_type, get_type_declaration): Declare new entry points. * include/abg-ir.h (class decl_base::insert_decl_into_scope): Update this friend declaration. (class scope_decl, class_decl): Update the friend add_decl_to_scope declaration. (scope_decl::add_member_decl): Return the added decl. (class_decl_sptr): Move this typedef befoer the class_decl class declaration. (class_decl::definition_of_declaration_): New member. (class_decl::{set_definition_of_declaration, get_definition_of_declaration}): New accessors. (class_decl::add_member_decl): Return the added member. (class_decl::insert_member_type): New member. (class_decl::member_base::access_specifier): Make this protected. (class_decl::member_type): Make this inherit from type_vase. (class_decl::member_type::type_): Remove this member. (class_decl::member_type::as_type): Remove this accessor. (class_decl::member_type::operator==(const type_base&)): New. (class_decl::member_type::operator shared_ptr<type_base>() const): Remove. (class_decl::member_type::get_underlying_type): New. (class_decl::member_type::operator==(const member_type&) const): New. * src/abg-comparison.cc (class_diff::{ensure_lookup_tables_populated, report}): Adjust for the removal of class_decl::member_type::as_type. * src/abg-dwarf-reader.cc (scope_stack_type): Change this as a typedef to stack<scope_decl*>. (current_scope): Change return type from scope_decl_sptr to scope_decl*. (insert_decl_into_scope): New. (build_namespace_decl_and_add_to_ir): Use insert_decl_into_scope in lieu of add_decl_to_scope. (build_class_type_and_add_to_ir): likewise. Link a class definition to its declaration. Push the current scope on the scope stack. Use as_non_member_type. Fix setting member types. (get_scope_for_die): Look through declaration-only classe to get its definition. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type, build_var_decl) (build_function_decl): Use as_non_member_type. (build_ir_node_from_die): Fix member variable & function adding. * src/abg-ir.cc (scope_decl::{add_member_decl, insert_member_decl}): Return the added member. (add_decl_to_scope): Likewise. (insert_decl_into_scope): Likewise. (get_top_most_scope_under): Fix logic. (get_type_declaration): New overload that return a decl_base*. (as_non_member_type): New definition. (class_decl::{get_definition_of_declaration, set_definition_of_declaration, insert_member_decl}): Likewise. (class_decl::add_member_decl): Re-write in terms of class::insert_member_decl. (class_decl::insert_member_type): New definition. (class_decl::add_member_type): Re-write in terms of class_decl::insert_member_type. (class_decl::remove_member_type): Update for the class_decl::member_type::as_type removal. (class_decl::{add_data_member, add_member_function, add_member_function_template, add_member_class_template}): Call scope_decl::add_member_decl. (class_decl::member_type::member_type): Update as the type now virtually inherits from type_base. (class_decl::member_type::{set,get}_access_specifier): New definitions. (class_decl::member_type::get_underlying_type): Likewise. (class_decl::member_type::set_scope): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. (class_decl::member_type::operator==(const decl_base& other)): There is no more class_decl::member_type::as_type. (class_decl::member_type::operator==(const type_base& other)): New. (class_decl::member_type::get_pretty_representation): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. * src/abg-reader.cc (build_class_decl): New that add add_member_decl adds even member types, no need to add it explicitly anymore. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 11:27:47 +00:00
class_decl_sptr definition_of_declaration_;
base_specs bases_;
member_types member_types_;
data_members data_members_;
member_functions member_functions_;
member_function_templates member_function_templates_;
member_class_templates member_class_templates_;
Prune types that are not ref'ed by public decls * include/abg-fwd.h (remove_decl_from_scope): Declare new function. * include/abg-ir.h (type_base_sptr, decl_base_sptr): Move these convenience typedef before the translation_unit declaration. (translation_unit::{mark_type_as_used, prune_unused_types}): Declare new methods. (decl_base::remove_member_decl): Likewise. (class_decl::{remove_member_decl, remove_member_type): Likewise. * src/abg-dwarf-reader.cc (die_decl_map_type): Change this map type so that the value is now a DIE offset, rather than a DIE. This is because many times the lifetime of DIEs is shorter than the one of the reader_context. Also, the die offset uniquely designates a physical DIE even if several different instances of logical DIE might point to it. (struct die_hash): Remove this as it's useless now that we store DIE offsets in the map. (build_translation_unit): Call build_ir_node_from_die w/o setting the called_from_public_decl flag. Prune the types that are not used by any public decls. (build_namespace_decl_and_add_to_ir): all build_ir_node_from_die w/o setting the called_from_public_decl flag. (build_ir_node_from_die): Change the only_public_decl flag into a called_from_public_decl flag. Mark types used by public decls as such. Adjust for the parm changes of build_qualified_type build_pointer_type_def, build_reference_type, and build_typedef_type. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type): Take a new called_from_public_decl. Pass it to build_ir_node_from_die. (build_var_decl): Call build_ir_node_from_die with the called_from_public_decl flag set to true to flag the types referenced by this variable as being used. (build_function_decl): Take a called_from_public_decl flag as well, as this function can now call build_function_decl itself to build a function decl out of the value of the DW_AT_specification attribute, for DIEs representing function definitions. Also, flag the types referenced by public functions are being used. * src/abg-ir.cc (translation_unit::priv::used_types_): New map for the used types. (translation_unit::{mark_type_as_used, prune_unused_types}): Define new methods. (scope_decl::remove_member_decl): Likewise. (remove_decl_from_scope): Define new function. (class_decl::{remove_member_decl, remove_member_type}): Define new methods. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-13 16:30:41 +00:00
protected:
Fix class scope setting & member type de-serializing from dwarf * include/abg-fwd.h (add_decl_to_scope, insert_decl_into_scope): return the decl added to the scope. (as_non_member_type, get_type_declaration): Declare new entry points. * include/abg-ir.h (class decl_base::insert_decl_into_scope): Update this friend declaration. (class scope_decl, class_decl): Update the friend add_decl_to_scope declaration. (scope_decl::add_member_decl): Return the added decl. (class_decl_sptr): Move this typedef befoer the class_decl class declaration. (class_decl::definition_of_declaration_): New member. (class_decl::{set_definition_of_declaration, get_definition_of_declaration}): New accessors. (class_decl::add_member_decl): Return the added member. (class_decl::insert_member_type): New member. (class_decl::member_base::access_specifier): Make this protected. (class_decl::member_type): Make this inherit from type_vase. (class_decl::member_type::type_): Remove this member. (class_decl::member_type::as_type): Remove this accessor. (class_decl::member_type::operator==(const type_base&)): New. (class_decl::member_type::operator shared_ptr<type_base>() const): Remove. (class_decl::member_type::get_underlying_type): New. (class_decl::member_type::operator==(const member_type&) const): New. * src/abg-comparison.cc (class_diff::{ensure_lookup_tables_populated, report}): Adjust for the removal of class_decl::member_type::as_type. * src/abg-dwarf-reader.cc (scope_stack_type): Change this as a typedef to stack<scope_decl*>. (current_scope): Change return type from scope_decl_sptr to scope_decl*. (insert_decl_into_scope): New. (build_namespace_decl_and_add_to_ir): Use insert_decl_into_scope in lieu of add_decl_to_scope. (build_class_type_and_add_to_ir): likewise. Link a class definition to its declaration. Push the current scope on the scope stack. Use as_non_member_type. Fix setting member types. (get_scope_for_die): Look through declaration-only classe to get its definition. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type, build_var_decl) (build_function_decl): Use as_non_member_type. (build_ir_node_from_die): Fix member variable & function adding. * src/abg-ir.cc (scope_decl::{add_member_decl, insert_member_decl}): Return the added member. (add_decl_to_scope): Likewise. (insert_decl_into_scope): Likewise. (get_top_most_scope_under): Fix logic. (get_type_declaration): New overload that return a decl_base*. (as_non_member_type): New definition. (class_decl::{get_definition_of_declaration, set_definition_of_declaration, insert_member_decl}): Likewise. (class_decl::add_member_decl): Re-write in terms of class::insert_member_decl. (class_decl::insert_member_type): New definition. (class_decl::add_member_type): Re-write in terms of class_decl::insert_member_type. (class_decl::remove_member_type): Update for the class_decl::member_type::as_type removal. (class_decl::{add_data_member, add_member_function, add_member_function_template, add_member_class_template}): Call scope_decl::add_member_decl. (class_decl::member_type::member_type): Update as the type now virtually inherits from type_base. (class_decl::member_type::{set,get}_access_specifier): New definitions. (class_decl::member_type::get_underlying_type): Likewise. (class_decl::member_type::set_scope): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. (class_decl::member_type::operator==(const decl_base& other)): There is no more class_decl::member_type::as_type. (class_decl::member_type::operator==(const type_base& other)): New. (class_decl::member_type::get_pretty_representation): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. * src/abg-reader.cc (build_class_decl): New that add add_member_decl adds even member types, no need to add it explicitly anymore. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 11:27:47 +00:00
virtual decl_base_sptr
Prune types that are not ref'ed by public decls * include/abg-fwd.h (remove_decl_from_scope): Declare new function. * include/abg-ir.h (type_base_sptr, decl_base_sptr): Move these convenience typedef before the translation_unit declaration. (translation_unit::{mark_type_as_used, prune_unused_types}): Declare new methods. (decl_base::remove_member_decl): Likewise. (class_decl::{remove_member_decl, remove_member_type): Likewise. * src/abg-dwarf-reader.cc (die_decl_map_type): Change this map type so that the value is now a DIE offset, rather than a DIE. This is because many times the lifetime of DIEs is shorter than the one of the reader_context. Also, the die offset uniquely designates a physical DIE even if several different instances of logical DIE might point to it. (struct die_hash): Remove this as it's useless now that we store DIE offsets in the map. (build_translation_unit): Call build_ir_node_from_die w/o setting the called_from_public_decl flag. Prune the types that are not used by any public decls. (build_namespace_decl_and_add_to_ir): all build_ir_node_from_die w/o setting the called_from_public_decl flag. (build_ir_node_from_die): Change the only_public_decl flag into a called_from_public_decl flag. Mark types used by public decls as such. Adjust for the parm changes of build_qualified_type build_pointer_type_def, build_reference_type, and build_typedef_type. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type): Take a new called_from_public_decl. Pass it to build_ir_node_from_die. (build_var_decl): Call build_ir_node_from_die with the called_from_public_decl flag set to true to flag the types referenced by this variable as being used. (build_function_decl): Take a called_from_public_decl flag as well, as this function can now call build_function_decl itself to build a function decl out of the value of the DW_AT_specification attribute, for DIEs representing function definitions. Also, flag the types referenced by public functions are being used. * src/abg-ir.cc (translation_unit::priv::used_types_): New map for the used types. (translation_unit::{mark_type_as_used, prune_unused_types}): Define new methods. (scope_decl::remove_member_decl): Likewise. (remove_decl_from_scope): Define new function. (class_decl::{remove_member_decl, remove_member_type}): Define new methods. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-13 16:30:41 +00:00
add_member_decl(decl_base_sptr);
Fix class scope setting & member type de-serializing from dwarf * include/abg-fwd.h (add_decl_to_scope, insert_decl_into_scope): return the decl added to the scope. (as_non_member_type, get_type_declaration): Declare new entry points. * include/abg-ir.h (class decl_base::insert_decl_into_scope): Update this friend declaration. (class scope_decl, class_decl): Update the friend add_decl_to_scope declaration. (scope_decl::add_member_decl): Return the added decl. (class_decl_sptr): Move this typedef befoer the class_decl class declaration. (class_decl::definition_of_declaration_): New member. (class_decl::{set_definition_of_declaration, get_definition_of_declaration}): New accessors. (class_decl::add_member_decl): Return the added member. (class_decl::insert_member_type): New member. (class_decl::member_base::access_specifier): Make this protected. (class_decl::member_type): Make this inherit from type_vase. (class_decl::member_type::type_): Remove this member. (class_decl::member_type::as_type): Remove this accessor. (class_decl::member_type::operator==(const type_base&)): New. (class_decl::member_type::operator shared_ptr<type_base>() const): Remove. (class_decl::member_type::get_underlying_type): New. (class_decl::member_type::operator==(const member_type&) const): New. * src/abg-comparison.cc (class_diff::{ensure_lookup_tables_populated, report}): Adjust for the removal of class_decl::member_type::as_type. * src/abg-dwarf-reader.cc (scope_stack_type): Change this as a typedef to stack<scope_decl*>. (current_scope): Change return type from scope_decl_sptr to scope_decl*. (insert_decl_into_scope): New. (build_namespace_decl_and_add_to_ir): Use insert_decl_into_scope in lieu of add_decl_to_scope. (build_class_type_and_add_to_ir): likewise. Link a class definition to its declaration. Push the current scope on the scope stack. Use as_non_member_type. Fix setting member types. (get_scope_for_die): Look through declaration-only classe to get its definition. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type, build_var_decl) (build_function_decl): Use as_non_member_type. (build_ir_node_from_die): Fix member variable & function adding. * src/abg-ir.cc (scope_decl::{add_member_decl, insert_member_decl}): Return the added member. (add_decl_to_scope): Likewise. (insert_decl_into_scope): Likewise. (get_top_most_scope_under): Fix logic. (get_type_declaration): New overload that return a decl_base*. (as_non_member_type): New definition. (class_decl::{get_definition_of_declaration, set_definition_of_declaration, insert_member_decl}): Likewise. (class_decl::add_member_decl): Re-write in terms of class::insert_member_decl. (class_decl::insert_member_type): New definition. (class_decl::add_member_type): Re-write in terms of class_decl::insert_member_type. (class_decl::remove_member_type): Update for the class_decl::member_type::as_type removal. (class_decl::{add_data_member, add_member_function, add_member_function_template, add_member_class_template}): Call scope_decl::add_member_decl. (class_decl::member_type::member_type): Update as the type now virtually inherits from type_base. (class_decl::member_type::{set,get}_access_specifier): New definitions. (class_decl::member_type::get_underlying_type): Likewise. (class_decl::member_type::set_scope): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. (class_decl::member_type::operator==(const decl_base& other)): There is no more class_decl::member_type::as_type. (class_decl::member_type::operator==(const type_base& other)): New. (class_decl::member_type::get_pretty_representation): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. * src/abg-reader.cc (build_class_decl): New that add add_member_decl adds even member types, no need to add it explicitly anymore. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 11:27:47 +00:00
virtual decl_base_sptr
insert_member_decl(decl_base_sptr member, declarations::iterator before);
Prune types that are not ref'ed by public decls * include/abg-fwd.h (remove_decl_from_scope): Declare new function. * include/abg-ir.h (type_base_sptr, decl_base_sptr): Move these convenience typedef before the translation_unit declaration. (translation_unit::{mark_type_as_used, prune_unused_types}): Declare new methods. (decl_base::remove_member_decl): Likewise. (class_decl::{remove_member_decl, remove_member_type): Likewise. * src/abg-dwarf-reader.cc (die_decl_map_type): Change this map type so that the value is now a DIE offset, rather than a DIE. This is because many times the lifetime of DIEs is shorter than the one of the reader_context. Also, the die offset uniquely designates a physical DIE even if several different instances of logical DIE might point to it. (struct die_hash): Remove this as it's useless now that we store DIE offsets in the map. (build_translation_unit): Call build_ir_node_from_die w/o setting the called_from_public_decl flag. Prune the types that are not used by any public decls. (build_namespace_decl_and_add_to_ir): all build_ir_node_from_die w/o setting the called_from_public_decl flag. (build_ir_node_from_die): Change the only_public_decl flag into a called_from_public_decl flag. Mark types used by public decls as such. Adjust for the parm changes of build_qualified_type build_pointer_type_def, build_reference_type, and build_typedef_type. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type): Take a new called_from_public_decl. Pass it to build_ir_node_from_die. (build_var_decl): Call build_ir_node_from_die with the called_from_public_decl flag set to true to flag the types referenced by this variable as being used. (build_function_decl): Take a called_from_public_decl flag as well, as this function can now call build_function_decl itself to build a function decl out of the value of the DW_AT_specification attribute, for DIEs representing function definitions. Also, flag the types referenced by public functions are being used. * src/abg-ir.cc (translation_unit::priv::used_types_): New map for the used types. (translation_unit::{mark_type_as_used, prune_unused_types}): Define new methods. (scope_decl::remove_member_decl): Likewise. (remove_decl_from_scope): Define new function. (class_decl::{remove_member_decl, remove_member_type}): Define new methods. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-13 16:30:41 +00:00
virtual void
remove_member_decl(decl_base_sptr);
public:
class_decl(const std::string& name, size_t size_in_bits,
size_t align_in_bits, location locus, visibility vis,
base_specs& bases, member_types& mbrs,
data_members& data_mbrs, member_functions& member_fns);
class_decl(const std::string& name, size_t size_in_bits,
size_t align_in_bits, location locus, visibility vis);
class_decl(const std::string& name, bool is_declaration_only = true);
Support method type/decl, variadic functions, class declarations-only * src/abg-ir.h (function_decl::parameter::parameter): New constructor with variadic parameter marker. (function_decl::m_type): Make this protected to let method_decl inheriting class to access it. (function_decl::get_type): Move this out-of-line. (class method_type, method_type_hash): New types. (enum class_decl::access_specifier): Add no_access new enumerator. (class_decl::data_member::data_member): Move this out-of-line. (class_decl::data_member::~data_member): Declare virtual destructor. (class method_decl): New class. (class member_function): Make this inherit method_decl, instead of function_decl. (class_decl::class_decl): New constructors. (class_decl::{hashing_started, is_declaration_only, set_earlier_declaration, get_earlier_declaration}): New methods. * src/abg-ir.cc (add_decl_to_scope): If a decl is already in a scope, don't add it to this scope. (get_global_scope): Make this work when passed an instance of global_scope. (dynamic_type_hash::operator()): Add support for method_type. (method_type::{method_type, set_class_type, ~method_type, }) (method_type_hash::operator()): New defintions. (function_decl::get_type, class_decl::class_decl): Move these out-of-line here. (class_decl::method_decl::{method_decl, ~method_decl, get_type}): New definitions. (class_decl::member_function::member_function): Move this out-of-line here. Support method_decl. (class_decl::data_member::data_member): Likewise. (class_decl_hash::operator()): Guard this against endless loop. * src/abg-reader.cc (write_class_is_declaration_only): New static function. (write_var_decl): Take a flag to write the mangled name or not. (write_function_decl): Take a flag to skip the first parameter. (write_cdtor_const_static): Use 'yes' instead of 'true' as value of the properties. (write_decl, write_function_template_decl): Adjust wrt the new signatures of write_var_decl and write_function_decl. (write_enum_type_decl): Simplify call to write_location. (write_class_decl): Support serializing declaration-only classes. * src/abg-writer.cc: * tests/data/test-read-write/test17.xml: New test input. * tests/test-read-write.cc: De-serialize the above, and serialize it back. * tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
bool
hashing_started() const
{return hashing_started_;}
Support method type/decl, variadic functions, class declarations-only * src/abg-ir.h (function_decl::parameter::parameter): New constructor with variadic parameter marker. (function_decl::m_type): Make this protected to let method_decl inheriting class to access it. (function_decl::get_type): Move this out-of-line. (class method_type, method_type_hash): New types. (enum class_decl::access_specifier): Add no_access new enumerator. (class_decl::data_member::data_member): Move this out-of-line. (class_decl::data_member::~data_member): Declare virtual destructor. (class method_decl): New class. (class member_function): Make this inherit method_decl, instead of function_decl. (class_decl::class_decl): New constructors. (class_decl::{hashing_started, is_declaration_only, set_earlier_declaration, get_earlier_declaration}): New methods. * src/abg-ir.cc (add_decl_to_scope): If a decl is already in a scope, don't add it to this scope. (get_global_scope): Make this work when passed an instance of global_scope. (dynamic_type_hash::operator()): Add support for method_type. (method_type::{method_type, set_class_type, ~method_type, }) (method_type_hash::operator()): New defintions. (function_decl::get_type, class_decl::class_decl): Move these out-of-line here. (class_decl::method_decl::{method_decl, ~method_decl, get_type}): New definitions. (class_decl::member_function::member_function): Move this out-of-line here. Support method_decl. (class_decl::data_member::data_member): Likewise. (class_decl_hash::operator()): Guard this against endless loop. * src/abg-reader.cc (write_class_is_declaration_only): New static function. (write_var_decl): Take a flag to write the mangled name or not. (write_function_decl): Take a flag to skip the first parameter. (write_cdtor_const_static): Use 'yes' instead of 'true' as value of the properties. (write_decl, write_function_template_decl): Adjust wrt the new signatures of write_var_decl and write_function_decl. (write_enum_type_decl): Simplify call to write_location. (write_class_decl): Support serializing declaration-only classes. * src/abg-writer.cc: * tests/data/test-read-write/test17.xml: New test input. * tests/test-read-write.cc: De-serialize the above, and serialize it back. * tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
void
hashing_started(bool b) const
{hashing_started_ = b;}
Support method type/decl, variadic functions, class declarations-only * src/abg-ir.h (function_decl::parameter::parameter): New constructor with variadic parameter marker. (function_decl::m_type): Make this protected to let method_decl inheriting class to access it. (function_decl::get_type): Move this out-of-line. (class method_type, method_type_hash): New types. (enum class_decl::access_specifier): Add no_access new enumerator. (class_decl::data_member::data_member): Move this out-of-line. (class_decl::data_member::~data_member): Declare virtual destructor. (class method_decl): New class. (class member_function): Make this inherit method_decl, instead of function_decl. (class_decl::class_decl): New constructors. (class_decl::{hashing_started, is_declaration_only, set_earlier_declaration, get_earlier_declaration}): New methods. * src/abg-ir.cc (add_decl_to_scope): If a decl is already in a scope, don't add it to this scope. (get_global_scope): Make this work when passed an instance of global_scope. (dynamic_type_hash::operator()): Add support for method_type. (method_type::{method_type, set_class_type, ~method_type, }) (method_type_hash::operator()): New defintions. (function_decl::get_type, class_decl::class_decl): Move these out-of-line here. (class_decl::method_decl::{method_decl, ~method_decl, get_type}): New definitions. (class_decl::member_function::member_function): Move this out-of-line here. Support method_decl. (class_decl::data_member::data_member): Likewise. (class_decl_hash::operator()): Guard this against endless loop. * src/abg-reader.cc (write_class_is_declaration_only): New static function. (write_var_decl): Take a flag to write the mangled name or not. (write_function_decl): Take a flag to skip the first parameter. (write_cdtor_const_static): Use 'yes' instead of 'true' as value of the properties. (write_decl, write_function_template_decl): Adjust wrt the new signatures of write_var_decl and write_function_decl. (write_enum_type_decl): Simplify call to write_location. (write_class_decl): Support serializing declaration-only classes. * src/abg-writer.cc: * tests/data/test-read-write/test17.xml: New test input. * tests/test-read-write.cc: De-serialize the above, and serialize it back. * tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
Support diff/reporting for functions & better diff/report in general * include/abg-ir.h ({decl_base, class_decl, function_decl}::get_pretty_representation): New virtual member to get a pretty string name for decls & types. (class_decl::parameter): Add an index to the parameter type. (class_decl::parameter::parameter): Update the constructor for the change above. (class_decl::parameter::{get_index, set_index}): Accessors for the new index. (class_decl::parameter::operator==): Take in account the index. (function_type::append_parameter): Set the index of the parameter here. * include/abg-fwd.h (get_type_name): New declaration. * src/abg-ir.cc (get_type_name): New definition. ({decl_base, function_decl, class_decl}::get_pretty_representation): New implementations. (method_type::set_class_type): Update this to set function parameter's index by default. (function_decl::append_parameters): Use the append_parameter method from function_type. * include/abg-comparison.h (class function_decl_diff): New type declaration. * src/abg-comparison.cc (compute_diff_for_decls, compute_diff): New definitions. ({pointer_diff, class_diff, scope_diff}::report): Use the new get_pretty_representation. Output a prettier report. (function_decl_diff::priv): New type. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at, ensure_lookup_tables_populated, function_decl_diff, first_function_decl, second_function_decl, changed_parms, removed_parms, added_parms, length, report}): New member function definitions. * src/abg-hash.cc (function_decl::parameter::hash): Update this to take the index in account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
virtual string
get_pretty_representation() const;
Support method type/decl, variadic functions, class declarations-only * src/abg-ir.h (function_decl::parameter::parameter): New constructor with variadic parameter marker. (function_decl::m_type): Make this protected to let method_decl inheriting class to access it. (function_decl::get_type): Move this out-of-line. (class method_type, method_type_hash): New types. (enum class_decl::access_specifier): Add no_access new enumerator. (class_decl::data_member::data_member): Move this out-of-line. (class_decl::data_member::~data_member): Declare virtual destructor. (class method_decl): New class. (class member_function): Make this inherit method_decl, instead of function_decl. (class_decl::class_decl): New constructors. (class_decl::{hashing_started, is_declaration_only, set_earlier_declaration, get_earlier_declaration}): New methods. * src/abg-ir.cc (add_decl_to_scope): If a decl is already in a scope, don't add it to this scope. (get_global_scope): Make this work when passed an instance of global_scope. (dynamic_type_hash::operator()): Add support for method_type. (method_type::{method_type, set_class_type, ~method_type, }) (method_type_hash::operator()): New defintions. (function_decl::get_type, class_decl::class_decl): Move these out-of-line here. (class_decl::method_decl::{method_decl, ~method_decl, get_type}): New definitions. (class_decl::member_function::member_function): Move this out-of-line here. Support method_decl. (class_decl::data_member::data_member): Likewise. (class_decl_hash::operator()): Guard this against endless loop. * src/abg-reader.cc (write_class_is_declaration_only): New static function. (write_var_decl): Take a flag to write the mangled name or not. (write_function_decl): Take a flag to skip the first parameter. (write_cdtor_const_static): Use 'yes' instead of 'true' as value of the properties. (write_decl, write_function_template_decl): Adjust wrt the new signatures of write_var_decl and write_function_decl. (write_enum_type_decl): Simplify call to write_location. (write_class_decl): Support serializing declaration-only classes. * src/abg-writer.cc: * tests/data/test-read-write/test17.xml: New test input. * tests/test-read-write.cc: De-serialize the above, and serialize it back. * tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
bool
is_declaration_only() const
{return is_declaration_only_;}
Support method type/decl, variadic functions, class declarations-only * src/abg-ir.h (function_decl::parameter::parameter): New constructor with variadic parameter marker. (function_decl::m_type): Make this protected to let method_decl inheriting class to access it. (function_decl::get_type): Move this out-of-line. (class method_type, method_type_hash): New types. (enum class_decl::access_specifier): Add no_access new enumerator. (class_decl::data_member::data_member): Move this out-of-line. (class_decl::data_member::~data_member): Declare virtual destructor. (class method_decl): New class. (class member_function): Make this inherit method_decl, instead of function_decl. (class_decl::class_decl): New constructors. (class_decl::{hashing_started, is_declaration_only, set_earlier_declaration, get_earlier_declaration}): New methods. * src/abg-ir.cc (add_decl_to_scope): If a decl is already in a scope, don't add it to this scope. (get_global_scope): Make this work when passed an instance of global_scope. (dynamic_type_hash::operator()): Add support for method_type. (method_type::{method_type, set_class_type, ~method_type, }) (method_type_hash::operator()): New defintions. (function_decl::get_type, class_decl::class_decl): Move these out-of-line here. (class_decl::method_decl::{method_decl, ~method_decl, get_type}): New definitions. (class_decl::member_function::member_function): Move this out-of-line here. Support method_decl. (class_decl::data_member::data_member): Likewise. (class_decl_hash::operator()): Guard this against endless loop. * src/abg-reader.cc (write_class_is_declaration_only): New static function. (write_var_decl): Take a flag to write the mangled name or not. (write_function_decl): Take a flag to skip the first parameter. (write_cdtor_const_static): Use 'yes' instead of 'true' as value of the properties. (write_decl, write_function_template_decl): Adjust wrt the new signatures of write_var_decl and write_function_decl. (write_enum_type_decl): Simplify call to write_location. (write_class_decl): Support serializing declaration-only classes. * src/abg-writer.cc: * tests/data/test-read-write/test17.xml: New test input. * tests/test-read-write.cc: De-serialize the above, and serialize it back. * tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
void
Fix class scope setting & member type de-serializing from dwarf * include/abg-fwd.h (add_decl_to_scope, insert_decl_into_scope): return the decl added to the scope. (as_non_member_type, get_type_declaration): Declare new entry points. * include/abg-ir.h (class decl_base::insert_decl_into_scope): Update this friend declaration. (class scope_decl, class_decl): Update the friend add_decl_to_scope declaration. (scope_decl::add_member_decl): Return the added decl. (class_decl_sptr): Move this typedef befoer the class_decl class declaration. (class_decl::definition_of_declaration_): New member. (class_decl::{set_definition_of_declaration, get_definition_of_declaration}): New accessors. (class_decl::add_member_decl): Return the added member. (class_decl::insert_member_type): New member. (class_decl::member_base::access_specifier): Make this protected. (class_decl::member_type): Make this inherit from type_vase. (class_decl::member_type::type_): Remove this member. (class_decl::member_type::as_type): Remove this accessor. (class_decl::member_type::operator==(const type_base&)): New. (class_decl::member_type::operator shared_ptr<type_base>() const): Remove. (class_decl::member_type::get_underlying_type): New. (class_decl::member_type::operator==(const member_type&) const): New. * src/abg-comparison.cc (class_diff::{ensure_lookup_tables_populated, report}): Adjust for the removal of class_decl::member_type::as_type. * src/abg-dwarf-reader.cc (scope_stack_type): Change this as a typedef to stack<scope_decl*>. (current_scope): Change return type from scope_decl_sptr to scope_decl*. (insert_decl_into_scope): New. (build_namespace_decl_and_add_to_ir): Use insert_decl_into_scope in lieu of add_decl_to_scope. (build_class_type_and_add_to_ir): likewise. Link a class definition to its declaration. Push the current scope on the scope stack. Use as_non_member_type. Fix setting member types. (get_scope_for_die): Look through declaration-only classe to get its definition. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type, build_var_decl) (build_function_decl): Use as_non_member_type. (build_ir_node_from_die): Fix member variable & function adding. * src/abg-ir.cc (scope_decl::{add_member_decl, insert_member_decl}): Return the added member. (add_decl_to_scope): Likewise. (insert_decl_into_scope): Likewise. (get_top_most_scope_under): Fix logic. (get_type_declaration): New overload that return a decl_base*. (as_non_member_type): New definition. (class_decl::{get_definition_of_declaration, set_definition_of_declaration, insert_member_decl}): Likewise. (class_decl::add_member_decl): Re-write in terms of class::insert_member_decl. (class_decl::insert_member_type): New definition. (class_decl::add_member_type): Re-write in terms of class_decl::insert_member_type. (class_decl::remove_member_type): Update for the class_decl::member_type::as_type removal. (class_decl::{add_data_member, add_member_function, add_member_function_template, add_member_class_template}): Call scope_decl::add_member_decl. (class_decl::member_type::member_type): Update as the type now virtually inherits from type_base. (class_decl::member_type::{set,get}_access_specifier): New definitions. (class_decl::member_type::get_underlying_type): Likewise. (class_decl::member_type::set_scope): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. (class_decl::member_type::operator==(const decl_base& other)): There is no more class_decl::member_type::as_type. (class_decl::member_type::operator==(const type_base& other)): New. (class_decl::member_type::get_pretty_representation): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. * src/abg-reader.cc (build_class_decl): New that add add_member_decl adds even member types, no need to add it explicitly anymore. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 11:27:47 +00:00
set_definition_of_declaration(class_decl_sptr);
const class_decl_sptr&
get_definition_of_declaration() const
{return definition_of_declaration_;}
void
set_earlier_declaration(decl_base_sptr declaration);
Support method type/decl, variadic functions, class declarations-only * src/abg-ir.h (function_decl::parameter::parameter): New constructor with variadic parameter marker. (function_decl::m_type): Make this protected to let method_decl inheriting class to access it. (function_decl::get_type): Move this out-of-line. (class method_type, method_type_hash): New types. (enum class_decl::access_specifier): Add no_access new enumerator. (class_decl::data_member::data_member): Move this out-of-line. (class_decl::data_member::~data_member): Declare virtual destructor. (class method_decl): New class. (class member_function): Make this inherit method_decl, instead of function_decl. (class_decl::class_decl): New constructors. (class_decl::{hashing_started, is_declaration_only, set_earlier_declaration, get_earlier_declaration}): New methods. * src/abg-ir.cc (add_decl_to_scope): If a decl is already in a scope, don't add it to this scope. (get_global_scope): Make this work when passed an instance of global_scope. (dynamic_type_hash::operator()): Add support for method_type. (method_type::{method_type, set_class_type, ~method_type, }) (method_type_hash::operator()): New defintions. (function_decl::get_type, class_decl::class_decl): Move these out-of-line here. (class_decl::method_decl::{method_decl, ~method_decl, get_type}): New definitions. (class_decl::member_function::member_function): Move this out-of-line here. Support method_decl. (class_decl::data_member::data_member): Likewise. (class_decl_hash::operator()): Guard this against endless loop. * src/abg-reader.cc (write_class_is_declaration_only): New static function. (write_var_decl): Take a flag to write the mangled name or not. (write_function_decl): Take a flag to skip the first parameter. (write_cdtor_const_static): Use 'yes' instead of 'true' as value of the properties. (write_decl, write_function_template_decl): Adjust wrt the new signatures of write_var_decl and write_function_decl. (write_enum_type_decl): Simplify call to write_location. (write_class_decl): Support serializing declaration-only classes. * src/abg-writer.cc: * tests/data/test-read-write/test17.xml: New test input. * tests/test-read-write.cc: De-serialize the above, and serialize it back. * tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
decl_base_sptr
Support method type/decl, variadic functions, class declarations-only * src/abg-ir.h (function_decl::parameter::parameter): New constructor with variadic parameter marker. (function_decl::m_type): Make this protected to let method_decl inheriting class to access it. (function_decl::get_type): Move this out-of-line. (class method_type, method_type_hash): New types. (enum class_decl::access_specifier): Add no_access new enumerator. (class_decl::data_member::data_member): Move this out-of-line. (class_decl::data_member::~data_member): Declare virtual destructor. (class method_decl): New class. (class member_function): Make this inherit method_decl, instead of function_decl. (class_decl::class_decl): New constructors. (class_decl::{hashing_started, is_declaration_only, set_earlier_declaration, get_earlier_declaration}): New methods. * src/abg-ir.cc (add_decl_to_scope): If a decl is already in a scope, don't add it to this scope. (get_global_scope): Make this work when passed an instance of global_scope. (dynamic_type_hash::operator()): Add support for method_type. (method_type::{method_type, set_class_type, ~method_type, }) (method_type_hash::operator()): New defintions. (function_decl::get_type, class_decl::class_decl): Move these out-of-line here. (class_decl::method_decl::{method_decl, ~method_decl, get_type}): New definitions. (class_decl::member_function::member_function): Move this out-of-line here. Support method_decl. (class_decl::data_member::data_member): Likewise. (class_decl_hash::operator()): Guard this against endless loop. * src/abg-reader.cc (write_class_is_declaration_only): New static function. (write_var_decl): Take a flag to write the mangled name or not. (write_function_decl): Take a flag to skip the first parameter. (write_cdtor_const_static): Use 'yes' instead of 'true' as value of the properties. (write_decl, write_function_template_decl): Adjust wrt the new signatures of write_var_decl and write_function_decl. (write_enum_type_decl): Simplify call to write_location. (write_class_decl): Support serializing declaration-only classes. * src/abg-writer.cc: * tests/data/test-read-write/test17.xml: New test input. * tests/test-read-write.cc: De-serialize the above, and serialize it back. * tests/data/test-read-write/test10.xml: Update this test.
2013-06-14 08:35:09 +00:00
get_earlier_declaration() const
{return declaration_;}
void
add_base_specifier(shared_ptr<base_spec> b)
{bases_.push_back(b);}
const base_specs&
get_base_specifiers() const
{return bases_;}
void
Fix class scope setting & member type de-serializing from dwarf * include/abg-fwd.h (add_decl_to_scope, insert_decl_into_scope): return the decl added to the scope. (as_non_member_type, get_type_declaration): Declare new entry points. * include/abg-ir.h (class decl_base::insert_decl_into_scope): Update this friend declaration. (class scope_decl, class_decl): Update the friend add_decl_to_scope declaration. (scope_decl::add_member_decl): Return the added decl. (class_decl_sptr): Move this typedef befoer the class_decl class declaration. (class_decl::definition_of_declaration_): New member. (class_decl::{set_definition_of_declaration, get_definition_of_declaration}): New accessors. (class_decl::add_member_decl): Return the added member. (class_decl::insert_member_type): New member. (class_decl::member_base::access_specifier): Make this protected. (class_decl::member_type): Make this inherit from type_vase. (class_decl::member_type::type_): Remove this member. (class_decl::member_type::as_type): Remove this accessor. (class_decl::member_type::operator==(const type_base&)): New. (class_decl::member_type::operator shared_ptr<type_base>() const): Remove. (class_decl::member_type::get_underlying_type): New. (class_decl::member_type::operator==(const member_type&) const): New. * src/abg-comparison.cc (class_diff::{ensure_lookup_tables_populated, report}): Adjust for the removal of class_decl::member_type::as_type. * src/abg-dwarf-reader.cc (scope_stack_type): Change this as a typedef to stack<scope_decl*>. (current_scope): Change return type from scope_decl_sptr to scope_decl*. (insert_decl_into_scope): New. (build_namespace_decl_and_add_to_ir): Use insert_decl_into_scope in lieu of add_decl_to_scope. (build_class_type_and_add_to_ir): likewise. Link a class definition to its declaration. Push the current scope on the scope stack. Use as_non_member_type. Fix setting member types. (get_scope_for_die): Look through declaration-only classe to get its definition. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type, build_var_decl) (build_function_decl): Use as_non_member_type. (build_ir_node_from_die): Fix member variable & function adding. * src/abg-ir.cc (scope_decl::{add_member_decl, insert_member_decl}): Return the added member. (add_decl_to_scope): Likewise. (insert_decl_into_scope): Likewise. (get_top_most_scope_under): Fix logic. (get_type_declaration): New overload that return a decl_base*. (as_non_member_type): New definition. (class_decl::{get_definition_of_declaration, set_definition_of_declaration, insert_member_decl}): Likewise. (class_decl::add_member_decl): Re-write in terms of class::insert_member_decl. (class_decl::insert_member_type): New definition. (class_decl::add_member_type): Re-write in terms of class_decl::insert_member_type. (class_decl::remove_member_type): Update for the class_decl::member_type::as_type removal. (class_decl::{add_data_member, add_member_function, add_member_function_template, add_member_class_template}): Call scope_decl::add_member_decl. (class_decl::member_type::member_type): Update as the type now virtually inherits from type_base. (class_decl::member_type::{set,get}_access_specifier): New definitions. (class_decl::member_type::get_underlying_type): Likewise. (class_decl::member_type::set_scope): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. (class_decl::member_type::operator==(const decl_base& other)): There is no more class_decl::member_type::as_type. (class_decl::member_type::operator==(const type_base& other)): New. (class_decl::member_type::get_pretty_representation): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. * src/abg-reader.cc (build_class_decl): New that add add_member_decl adds even member types, no need to add it explicitly anymore. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 11:27:47 +00:00
insert_member_type(member_type_sptr t,
declarations::iterator before);
Avoid missing member types while reading bi files * include/abg-fwd.h (get_type_declaration): Declare function. * include/abg-ir.h (class decl_base): Add class_decl as a friend. This to be able to call decl_base::set_scope from class_decl. (scope_decl::add_member_decl): Make this virtual protected, so that it can be called (virtually) from e.g, class_decl. (type_decl_sptr, typedef_decl_sptr): New convenience typedefs. (class_decl::add_member_decl): New virtual overload for scope_decl::add_member_decl. (class_decl::{add_member_type, add_data_member, add_member_function}): New overloads. * src/abg-ir.cc (add_decl_to_scope): Benign style cleanup. (get_type_declaration): Define new function. (class_decl::add_member_decl): New method. (class_decl::add_member_type): Avoid silently added a new member type when that member type has already been (perhaps inadvertently) added to a scope already. Rather, put a strict assert in place there. Also add a new overload that constructs the member type out of a classic type and adds it to the class. (class_decl::{add_data_member, add_member_function}): Likewise. (class_decl::{add_member_function_template, add_member_class_template}): Avoid silently added a new member template when that template has already been (perhaps inadvertently) added to a scope already. Rather, put a strict assert in place there. * src/abg-reader.cc (push_decl_to_current_scope): Take a an extra flag saying if the current decl should be added to the current scope as well (in addition to being pushed onto the stack of scopes maintained in the reader context). (push_and_key_type_decl): Likewise, take that extra flag and pass it to push_decl_to_current_scope. (build_function_decl, build_var_decl, build_type_decl) (build_qualified_type_decl, build_pointer_type_def) (build_reference_type_def, build_enum_type_decl, build_typedef_decl) (build_function_tdecl, build_class_tdecl): Likewise. (build_class_decl): Likewise. When building member data, types, and functions, make sure /not/ to add the data, type of function to the current scope before adding it to the class_decl. This was making the member not being added to the class because it already had a scope. (build_type_tparameter, build_type_composition) (build_non_type_tparameter, build_template_tparameter) (build_type): Adjust to add the template parm to the current scope explicitly, like previously. (handle_type_decl): Use build_type_decl function. Add the type_decl to the current scope, like previously. (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl) (handle_function_decl, handle_class_decl, handle_function_tdecl) (handle_class_tdecl): Adjust to add the decl to the current scope, like previously. * tests/data/test-read-write/test21.xml: New test input with member type(def). Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:06:04 +00:00
void
Fix class scope setting & member type de-serializing from dwarf * include/abg-fwd.h (add_decl_to_scope, insert_decl_into_scope): return the decl added to the scope. (as_non_member_type, get_type_declaration): Declare new entry points. * include/abg-ir.h (class decl_base::insert_decl_into_scope): Update this friend declaration. (class scope_decl, class_decl): Update the friend add_decl_to_scope declaration. (scope_decl::add_member_decl): Return the added decl. (class_decl_sptr): Move this typedef befoer the class_decl class declaration. (class_decl::definition_of_declaration_): New member. (class_decl::{set_definition_of_declaration, get_definition_of_declaration}): New accessors. (class_decl::add_member_decl): Return the added member. (class_decl::insert_member_type): New member. (class_decl::member_base::access_specifier): Make this protected. (class_decl::member_type): Make this inherit from type_vase. (class_decl::member_type::type_): Remove this member. (class_decl::member_type::as_type): Remove this accessor. (class_decl::member_type::operator==(const type_base&)): New. (class_decl::member_type::operator shared_ptr<type_base>() const): Remove. (class_decl::member_type::get_underlying_type): New. (class_decl::member_type::operator==(const member_type&) const): New. * src/abg-comparison.cc (class_diff::{ensure_lookup_tables_populated, report}): Adjust for the removal of class_decl::member_type::as_type. * src/abg-dwarf-reader.cc (scope_stack_type): Change this as a typedef to stack<scope_decl*>. (current_scope): Change return type from scope_decl_sptr to scope_decl*. (insert_decl_into_scope): New. (build_namespace_decl_and_add_to_ir): Use insert_decl_into_scope in lieu of add_decl_to_scope. (build_class_type_and_add_to_ir): likewise. Link a class definition to its declaration. Push the current scope on the scope stack. Use as_non_member_type. Fix setting member types. (get_scope_for_die): Look through declaration-only classe to get its definition. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type, build_var_decl) (build_function_decl): Use as_non_member_type. (build_ir_node_from_die): Fix member variable & function adding. * src/abg-ir.cc (scope_decl::{add_member_decl, insert_member_decl}): Return the added member. (add_decl_to_scope): Likewise. (insert_decl_into_scope): Likewise. (get_top_most_scope_under): Fix logic. (get_type_declaration): New overload that return a decl_base*. (as_non_member_type): New definition. (class_decl::{get_definition_of_declaration, set_definition_of_declaration, insert_member_decl}): Likewise. (class_decl::add_member_decl): Re-write in terms of class::insert_member_decl. (class_decl::insert_member_type): New definition. (class_decl::add_member_type): Re-write in terms of class_decl::insert_member_type. (class_decl::remove_member_type): Update for the class_decl::member_type::as_type removal. (class_decl::{add_data_member, add_member_function, add_member_function_template, add_member_class_template}): Call scope_decl::add_member_decl. (class_decl::member_type::member_type): Update as the type now virtually inherits from type_base. (class_decl::member_type::{set,get}_access_specifier): New definitions. (class_decl::member_type::get_underlying_type): Likewise. (class_decl::member_type::set_scope): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. (class_decl::member_type::operator==(const decl_base& other)): There is no more class_decl::member_type::as_type. (class_decl::member_type::operator==(const type_base& other)): New. (class_decl::member_type::get_pretty_representation): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. * src/abg-reader.cc (build_class_decl): New that add add_member_decl adds even member types, no need to add it explicitly anymore. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 11:27:47 +00:00
add_member_type(member_type_sptr t);
member_type_sptr
Avoid missing member types while reading bi files * include/abg-fwd.h (get_type_declaration): Declare function. * include/abg-ir.h (class decl_base): Add class_decl as a friend. This to be able to call decl_base::set_scope from class_decl. (scope_decl::add_member_decl): Make this virtual protected, so that it can be called (virtually) from e.g, class_decl. (type_decl_sptr, typedef_decl_sptr): New convenience typedefs. (class_decl::add_member_decl): New virtual overload for scope_decl::add_member_decl. (class_decl::{add_member_type, add_data_member, add_member_function}): New overloads. * src/abg-ir.cc (add_decl_to_scope): Benign style cleanup. (get_type_declaration): Define new function. (class_decl::add_member_decl): New method. (class_decl::add_member_type): Avoid silently added a new member type when that member type has already been (perhaps inadvertently) added to a scope already. Rather, put a strict assert in place there. Also add a new overload that constructs the member type out of a classic type and adds it to the class. (class_decl::{add_data_member, add_member_function}): Likewise. (class_decl::{add_member_function_template, add_member_class_template}): Avoid silently added a new member template when that template has already been (perhaps inadvertently) added to a scope already. Rather, put a strict assert in place there. * src/abg-reader.cc (push_decl_to_current_scope): Take a an extra flag saying if the current decl should be added to the current scope as well (in addition to being pushed onto the stack of scopes maintained in the reader context). (push_and_key_type_decl): Likewise, take that extra flag and pass it to push_decl_to_current_scope. (build_function_decl, build_var_decl, build_type_decl) (build_qualified_type_decl, build_pointer_type_def) (build_reference_type_def, build_enum_type_decl, build_typedef_decl) (build_function_tdecl, build_class_tdecl): Likewise. (build_class_decl): Likewise. When building member data, types, and functions, make sure /not/ to add the data, type of function to the current scope before adding it to the class_decl. This was making the member not being added to the class because it already had a scope. (build_type_tparameter, build_type_composition) (build_non_type_tparameter, build_template_tparameter) (build_type): Adjust to add the template parm to the current scope explicitly, like previously. (handle_type_decl): Use build_type_decl function. Add the type_decl to the current scope, like previously. (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl) (handle_function_decl, handle_class_decl, handle_function_tdecl) (handle_class_tdecl): Adjust to add the decl to the current scope, like previously. * tests/data/test-read-write/test21.xml: New test input with member type(def). Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:06:04 +00:00
add_member_type(type_base_sptr t, access_specifier a);
Prune types that are not ref'ed by public decls * include/abg-fwd.h (remove_decl_from_scope): Declare new function. * include/abg-ir.h (type_base_sptr, decl_base_sptr): Move these convenience typedef before the translation_unit declaration. (translation_unit::{mark_type_as_used, prune_unused_types}): Declare new methods. (decl_base::remove_member_decl): Likewise. (class_decl::{remove_member_decl, remove_member_type): Likewise. * src/abg-dwarf-reader.cc (die_decl_map_type): Change this map type so that the value is now a DIE offset, rather than a DIE. This is because many times the lifetime of DIEs is shorter than the one of the reader_context. Also, the die offset uniquely designates a physical DIE even if several different instances of logical DIE might point to it. (struct die_hash): Remove this as it's useless now that we store DIE offsets in the map. (build_translation_unit): Call build_ir_node_from_die w/o setting the called_from_public_decl flag. Prune the types that are not used by any public decls. (build_namespace_decl_and_add_to_ir): all build_ir_node_from_die w/o setting the called_from_public_decl flag. (build_ir_node_from_die): Change the only_public_decl flag into a called_from_public_decl flag. Mark types used by public decls as such. Adjust for the parm changes of build_qualified_type build_pointer_type_def, build_reference_type, and build_typedef_type. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type): Take a new called_from_public_decl. Pass it to build_ir_node_from_die. (build_var_decl): Call build_ir_node_from_die with the called_from_public_decl flag set to true to flag the types referenced by this variable as being used. (build_function_decl): Take a called_from_public_decl flag as well, as this function can now call build_function_decl itself to build a function decl out of the value of the DW_AT_specification attribute, for DIEs representing function definitions. Also, flag the types referenced by public functions are being used. * src/abg-ir.cc (translation_unit::priv::used_types_): New map for the used types. (translation_unit::{mark_type_as_used, prune_unused_types}): Define new methods. (scope_decl::remove_member_decl): Likewise. (remove_decl_from_scope): Define new function. (class_decl::{remove_member_decl, remove_member_type}): Define new methods. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-12-13 16:30:41 +00:00
void
remove_member_type(type_base_sptr t);
const member_types&
get_member_types() const
{return member_types_;}
void
Avoid missing member types while reading bi files * include/abg-fwd.h (get_type_declaration): Declare function. * include/abg-ir.h (class decl_base): Add class_decl as a friend. This to be able to call decl_base::set_scope from class_decl. (scope_decl::add_member_decl): Make this virtual protected, so that it can be called (virtually) from e.g, class_decl. (type_decl_sptr, typedef_decl_sptr): New convenience typedefs. (class_decl::add_member_decl): New virtual overload for scope_decl::add_member_decl. (class_decl::{add_member_type, add_data_member, add_member_function}): New overloads. * src/abg-ir.cc (add_decl_to_scope): Benign style cleanup. (get_type_declaration): Define new function. (class_decl::add_member_decl): New method. (class_decl::add_member_type): Avoid silently added a new member type when that member type has already been (perhaps inadvertently) added to a scope already. Rather, put a strict assert in place there. Also add a new overload that constructs the member type out of a classic type and adds it to the class. (class_decl::{add_data_member, add_member_function}): Likewise. (class_decl::{add_member_function_template, add_member_class_template}): Avoid silently added a new member template when that template has already been (perhaps inadvertently) added to a scope already. Rather, put a strict assert in place there. * src/abg-reader.cc (push_decl_to_current_scope): Take a an extra flag saying if the current decl should be added to the current scope as well (in addition to being pushed onto the stack of scopes maintained in the reader context). (push_and_key_type_decl): Likewise, take that extra flag and pass it to push_decl_to_current_scope. (build_function_decl, build_var_decl, build_type_decl) (build_qualified_type_decl, build_pointer_type_def) (build_reference_type_def, build_enum_type_decl, build_typedef_decl) (build_function_tdecl, build_class_tdecl): Likewise. (build_class_decl): Likewise. When building member data, types, and functions, make sure /not/ to add the data, type of function to the current scope before adding it to the class_decl. This was making the member not being added to the class because it already had a scope. (build_type_tparameter, build_type_composition) (build_non_type_tparameter, build_template_tparameter) (build_type): Adjust to add the template parm to the current scope explicitly, like previously. (handle_type_decl): Use build_type_decl function. Add the type_decl to the current scope, like previously. (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl) (handle_function_decl, handle_class_decl, handle_function_tdecl) (handle_class_tdecl): Adjust to add the decl to the current scope, like previously. * tests/data/test-read-write/test21.xml: New test input with member type(def). Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:06:04 +00:00
add_data_member(data_member_sptr m);
void
add_data_member(var_decl_sptr v, access_specifier a,
bool is_laid_out, bool is_static,
size_t offset_in_bits);
const data_members&
get_data_members() const
{return data_members_;}
Initial support for function templates * src/abg-ir.h (function_decl::set_return_type): New inline definition. (class template_decl, struct template_decl_hash, class template_parameter, struct template_parameter_hash, struct dynamic_template_parameter_hash, struct template_parameter_shared_ptr_hash, class template_type_parameter) (struct template_type_parameter_hash, class template_non_type_parameter, struct template_non_type_parameter_hash, class template_template_parameter, struct template_template_parameter_hash, class function_template_decl) (struct function_template_decl_hash, struct fn_tmpl_shared_ptr_hash): New declarations. * src/abg-ir.cc (dynamic_type_hash::operator()): Add hashing for template template, and template type parameters. (template_decl_hash::operator, template_decl::~template_decl) (template_decl::operator==, template_parameter::operator==) (template_parameter_hash::operator()) (dynamic_template_parameter_hash::operator()) (template_type_parameter::operator==) (template_type_parameter::~template_type_parameter) (template_type_parameter_hash::operator()) (template_non_type_parameter::operator==) (template_non_type_parameter::~template_non_type_parameter) (template_non_type_parameter_hash::operator()) (template_template_parameter::operator==) (template_template_parameter::~template_template_parameter) (template_template_parameter_hash::operator()) (function_template_decl::operator==) (function_template_decl_hash::operator()) (fn_tmpl_shared_ptr_hash::operator()) (function_template_decl::~function_template_decl()): New definitions. * src/abg-reader.cc (read_context::get_fn_tmpl_decl) (read_context::key_fn_tmpl_decl): New functions. (read_context::m_fn_tmpl_map): New data member. (read_context::key_type_decl): Renamed read_context::add_type_decl into this. (read_context::push_decl_to_current_scope): Renamed read_context::finish_decl_creation into this. Add an assert. (read_context::push_and_key_type_decl): Renamed read_context::finish_type_decl_creation into this. Adjust to the use of push_decl_to_current_scope and key_type_decl. (build_function_template_decl, build_template_type_parameter) (build_template_non_type_parameter) (build_template_template_parameter, build_template_parameter) (handle_function_template_decl): New functions. (handle_element): Call handle_function_template_decl. (build_function_decl): Take a bool parameter to update depth information in parsing context. Move instantiation of function_decl before parsing its xml sub-nodes. Update the depth info in the parsing context if necessary. Push the newly intantiated decl to scope. And then parse the sub nodes. Do not forget to add the fn parameters and return type using function_decl::add_parameter and function_decl::set_return_type. (build_var_decl, build_type_decl, build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_enum_type_decl, build_typedef_decl, handled_type_decl) (handle_qualified_type_decl, handle_pointer_type_def) (handle_reference_type_def, handle_enum_type_decl) (handle_typedef_decl, handle_var_decl, handle_function_decl) (handle_class_decl): Adjust. (build_class_decl): Take a bool parameter to update depth information in parsing context. Add comment. Wait for the class members to be built, before keying (and thus hashing it) the class. (build_type): Fix logic, and adjust. * src/abg-writer.cc (write_context::type_has_existing_id) (write_context::get_id_for_fn_tmpl, write_template_type_parameter) (write_template_non_type_parameter) (write_template_template_parameter, write_template_parameter) (write_function_template_decl): New functions. (write_context::get_id_for_type): Simplify logic. (write_decl): Support writing function template. * tests/data/test-read-write/test11.xml: New test input. * tests/test-read-write.cc (InoutSpec in_out_specs[]): De-serialize the new test11.xml test, serialize it back and diff output and input. * tests/Makefile.am: Add test11.xml to the distribution.
2013-04-23 09:27:32 +00:00
void
Avoid missing member types while reading bi files * include/abg-fwd.h (get_type_declaration): Declare function. * include/abg-ir.h (class decl_base): Add class_decl as a friend. This to be able to call decl_base::set_scope from class_decl. (scope_decl::add_member_decl): Make this virtual protected, so that it can be called (virtually) from e.g, class_decl. (type_decl_sptr, typedef_decl_sptr): New convenience typedefs. (class_decl::add_member_decl): New virtual overload for scope_decl::add_member_decl. (class_decl::{add_member_type, add_data_member, add_member_function}): New overloads. * src/abg-ir.cc (add_decl_to_scope): Benign style cleanup. (get_type_declaration): Define new function. (class_decl::add_member_decl): New method. (class_decl::add_member_type): Avoid silently added a new member type when that member type has already been (perhaps inadvertently) added to a scope already. Rather, put a strict assert in place there. Also add a new overload that constructs the member type out of a classic type and adds it to the class. (class_decl::{add_data_member, add_member_function}): Likewise. (class_decl::{add_member_function_template, add_member_class_template}): Avoid silently added a new member template when that template has already been (perhaps inadvertently) added to a scope already. Rather, put a strict assert in place there. * src/abg-reader.cc (push_decl_to_current_scope): Take a an extra flag saying if the current decl should be added to the current scope as well (in addition to being pushed onto the stack of scopes maintained in the reader context). (push_and_key_type_decl): Likewise, take that extra flag and pass it to push_decl_to_current_scope. (build_function_decl, build_var_decl, build_type_decl) (build_qualified_type_decl, build_pointer_type_def) (build_reference_type_def, build_enum_type_decl, build_typedef_decl) (build_function_tdecl, build_class_tdecl): Likewise. (build_class_decl): Likewise. When building member data, types, and functions, make sure /not/ to add the data, type of function to the current scope before adding it to the class_decl. This was making the member not being added to the class because it already had a scope. (build_type_tparameter, build_type_composition) (build_non_type_tparameter, build_template_tparameter) (build_type): Adjust to add the template parm to the current scope explicitly, like previously. (handle_type_decl): Use build_type_decl function. Add the type_decl to the current scope, like previously. (handle_namespace_decl, handle_qualified_type_decl) (handle_pointer_type_def, handle_reference_type_def) (handle_enum_type_decl, handle_typedef_decl, handle_var_decl) (handle_function_decl, handle_class_decl, handle_function_tdecl) (handle_class_tdecl): Adjust to add the decl to the current scope, like previously. * tests/data/test-read-write/test21.xml: New test input with member type(def). Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-11-19 09:06:04 +00:00
add_member_function(member_function_sptr m);
void
add_member_function(function_decl_sptr f,
access_specifier a,
size_t vtable_offset,
bool is_static, bool is_ctor,
bool is_dtor, bool is_const);
Initial support for function templates * src/abg-ir.h (function_decl::set_return_type): New inline definition. (class template_decl, struct template_decl_hash, class template_parameter, struct template_parameter_hash, struct dynamic_template_parameter_hash, struct template_parameter_shared_ptr_hash, class template_type_parameter) (struct template_type_parameter_hash, class template_non_type_parameter, struct template_non_type_parameter_hash, class template_template_parameter, struct template_template_parameter_hash, class function_template_decl) (struct function_template_decl_hash, struct fn_tmpl_shared_ptr_hash): New declarations. * src/abg-ir.cc (dynamic_type_hash::operator()): Add hashing for template template, and template type parameters. (template_decl_hash::operator, template_decl::~template_decl) (template_decl::operator==, template_parameter::operator==) (template_parameter_hash::operator()) (dynamic_template_parameter_hash::operator()) (template_type_parameter::operator==) (template_type_parameter::~template_type_parameter) (template_type_parameter_hash::operator()) (template_non_type_parameter::operator==) (template_non_type_parameter::~template_non_type_parameter) (template_non_type_parameter_hash::operator()) (template_template_parameter::operator==) (template_template_parameter::~template_template_parameter) (template_template_parameter_hash::operator()) (function_template_decl::operator==) (function_template_decl_hash::operator()) (fn_tmpl_shared_ptr_hash::operator()) (function_template_decl::~function_template_decl()): New definitions. * src/abg-reader.cc (read_context::get_fn_tmpl_decl) (read_context::key_fn_tmpl_decl): New functions. (read_context::m_fn_tmpl_map): New data member. (read_context::key_type_decl): Renamed read_context::add_type_decl into this. (read_context::push_decl_to_current_scope): Renamed read_context::finish_decl_creation into this. Add an assert. (read_context::push_and_key_type_decl): Renamed read_context::finish_type_decl_creation into this. Adjust to the use of push_decl_to_current_scope and key_type_decl. (build_function_template_decl, build_template_type_parameter) (build_template_non_type_parameter) (build_template_template_parameter, build_template_parameter) (handle_function_template_decl): New functions. (handle_element): Call handle_function_template_decl. (build_function_decl): Take a bool parameter to update depth information in parsing context. Move instantiation of function_decl before parsing its xml sub-nodes. Update the depth info in the parsing context if necessary. Push the newly intantiated decl to scope. And then parse the sub nodes. Do not forget to add the fn parameters and return type using function_decl::add_parameter and function_decl::set_return_type. (build_var_decl, build_type_decl, build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_enum_type_decl, build_typedef_decl, handled_type_decl) (handle_qualified_type_decl, handle_pointer_type_def) (handle_reference_type_def, handle_enum_type_decl) (handle_typedef_decl, handle_var_decl, handle_function_decl) (handle_class_decl): Adjust. (build_class_decl): Take a bool parameter to update depth information in parsing context. Add comment. Wait for the class members to be built, before keying (and thus hashing it) the class. (build_type): Fix logic, and adjust. * src/abg-writer.cc (write_context::type_has_existing_id) (write_context::get_id_for_fn_tmpl, write_template_type_parameter) (write_template_non_type_parameter) (write_template_template_parameter, write_template_parameter) (write_function_template_decl): New functions. (write_context::get_id_for_type): Simplify logic. (write_decl): Support writing function template. * tests/data/test-read-write/test11.xml: New test input. * tests/test-read-write.cc (InoutSpec in_out_specs[]): De-serialize the new test11.xml test, serialize it back and diff output and input. * tests/Makefile.am: Add test11.xml to the distribution.
2013-04-23 09:27:32 +00:00
const member_functions&
get_member_functions() const
{return member_functions_;}
Initial support for function templates * src/abg-ir.h (function_decl::set_return_type): New inline definition. (class template_decl, struct template_decl_hash, class template_parameter, struct template_parameter_hash, struct dynamic_template_parameter_hash, struct template_parameter_shared_ptr_hash, class template_type_parameter) (struct template_type_parameter_hash, class template_non_type_parameter, struct template_non_type_parameter_hash, class template_template_parameter, struct template_template_parameter_hash, class function_template_decl) (struct function_template_decl_hash, struct fn_tmpl_shared_ptr_hash): New declarations. * src/abg-ir.cc (dynamic_type_hash::operator()): Add hashing for template template, and template type parameters. (template_decl_hash::operator, template_decl::~template_decl) (template_decl::operator==, template_parameter::operator==) (template_parameter_hash::operator()) (dynamic_template_parameter_hash::operator()) (template_type_parameter::operator==) (template_type_parameter::~template_type_parameter) (template_type_parameter_hash::operator()) (template_non_type_parameter::operator==) (template_non_type_parameter::~template_non_type_parameter) (template_non_type_parameter_hash::operator()) (template_template_parameter::operator==) (template_template_parameter::~template_template_parameter) (template_template_parameter_hash::operator()) (function_template_decl::operator==) (function_template_decl_hash::operator()) (fn_tmpl_shared_ptr_hash::operator()) (function_template_decl::~function_template_decl()): New definitions. * src/abg-reader.cc (read_context::get_fn_tmpl_decl) (read_context::key_fn_tmpl_decl): New functions. (read_context::m_fn_tmpl_map): New data member. (read_context::key_type_decl): Renamed read_context::add_type_decl into this. (read_context::push_decl_to_current_scope): Renamed read_context::finish_decl_creation into this. Add an assert. (read_context::push_and_key_type_decl): Renamed read_context::finish_type_decl_creation into this. Adjust to the use of push_decl_to_current_scope and key_type_decl. (build_function_template_decl, build_template_type_parameter) (build_template_non_type_parameter) (build_template_template_parameter, build_template_parameter) (handle_function_template_decl): New functions. (handle_element): Call handle_function_template_decl. (build_function_decl): Take a bool parameter to update depth information in parsing context. Move instantiation of function_decl before parsing its xml sub-nodes. Update the depth info in the parsing context if necessary. Push the newly intantiated decl to scope. And then parse the sub nodes. Do not forget to add the fn parameters and return type using function_decl::add_parameter and function_decl::set_return_type. (build_var_decl, build_type_decl, build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_enum_type_decl, build_typedef_decl, handled_type_decl) (handle_qualified_type_decl, handle_pointer_type_def) (handle_reference_type_def, handle_enum_type_decl) (handle_typedef_decl, handle_var_decl, handle_function_decl) (handle_class_decl): Adjust. (build_class_decl): Take a bool parameter to update depth information in parsing context. Add comment. Wait for the class members to be built, before keying (and thus hashing it) the class. (build_type): Fix logic, and adjust. * src/abg-writer.cc (write_context::type_has_existing_id) (write_context::get_id_for_fn_tmpl, write_template_type_parameter) (write_template_non_type_parameter) (write_template_template_parameter, write_template_parameter) (write_function_template_decl): New functions. (write_context::get_id_for_type): Simplify logic. (write_decl): Support writing function template. * tests/data/test-read-write/test11.xml: New test input. * tests/test-read-write.cc (InoutSpec in_out_specs[]): De-serialize the new test11.xml test, serialize it back and diff output and input. * tests/Makefile.am: Add test11.xml to the distribution.
2013-04-23 09:27:32 +00:00
size_t
get_num_virtual_functions() const;
Initial support for function templates * src/abg-ir.h (function_decl::set_return_type): New inline definition. (class template_decl, struct template_decl_hash, class template_parameter, struct template_parameter_hash, struct dynamic_template_parameter_hash, struct template_parameter_shared_ptr_hash, class template_type_parameter) (struct template_type_parameter_hash, class template_non_type_parameter, struct template_non_type_parameter_hash, class template_template_parameter, struct template_template_parameter_hash, class function_template_decl) (struct function_template_decl_hash, struct fn_tmpl_shared_ptr_hash): New declarations. * src/abg-ir.cc (dynamic_type_hash::operator()): Add hashing for template template, and template type parameters. (template_decl_hash::operator, template_decl::~template_decl) (template_decl::operator==, template_parameter::operator==) (template_parameter_hash::operator()) (dynamic_template_parameter_hash::operator()) (template_type_parameter::operator==) (template_type_parameter::~template_type_parameter) (template_type_parameter_hash::operator()) (template_non_type_parameter::operator==) (template_non_type_parameter::~template_non_type_parameter) (template_non_type_parameter_hash::operator()) (template_template_parameter::operator==) (template_template_parameter::~template_template_parameter) (template_template_parameter_hash::operator()) (function_template_decl::operator==) (function_template_decl_hash::operator()) (fn_tmpl_shared_ptr_hash::operator()) (function_template_decl::~function_template_decl()): New definitions. * src/abg-reader.cc (read_context::get_fn_tmpl_decl) (read_context::key_fn_tmpl_decl): New functions. (read_context::m_fn_tmpl_map): New data member. (read_context::key_type_decl): Renamed read_context::add_type_decl into this. (read_context::push_decl_to_current_scope): Renamed read_context::finish_decl_creation into this. Add an assert. (read_context::push_and_key_type_decl): Renamed read_context::finish_type_decl_creation into this. Adjust to the use of push_decl_to_current_scope and key_type_decl. (build_function_template_decl, build_template_type_parameter) (build_template_non_type_parameter) (build_template_template_parameter, build_template_parameter) (handle_function_template_decl): New functions. (handle_element): Call handle_function_template_decl. (build_function_decl): Take a bool parameter to update depth information in parsing context. Move instantiation of function_decl before parsing its xml sub-nodes. Update the depth info in the parsing context if necessary. Push the newly intantiated decl to scope. And then parse the sub nodes. Do not forget to add the fn parameters and return type using function_decl::add_parameter and function_decl::set_return_type. (build_var_decl, build_type_decl, build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_enum_type_decl, build_typedef_decl, handled_type_decl) (handle_qualified_type_decl, handle_pointer_type_def) (handle_reference_type_def, handle_enum_type_decl) (handle_typedef_decl, handle_var_decl, handle_function_decl) (handle_class_decl): Adjust. (build_class_decl): Take a bool parameter to update depth information in parsing context. Add comment. Wait for the class members to be built, before keying (and thus hashing it) the class. (build_type): Fix logic, and adjust. * src/abg-writer.cc (write_context::type_has_existing_id) (write_context::get_id_for_fn_tmpl, write_template_type_parameter) (write_template_non_type_parameter) (write_template_template_parameter, write_template_parameter) (write_function_template_decl): New functions. (write_context::get_id_for_type): Simplify logic. (write_decl): Support writing function template. * tests/data/test-read-write/test11.xml: New test input. * tests/test-read-write.cc (InoutSpec in_out_specs[]): De-serialize the new test11.xml test, serialize it back and diff output and input. * tests/Makefile.am: Add test11.xml to the distribution.
2013-04-23 09:27:32 +00:00
void
Initial support for member class templates * src/abg-ir.cc (class_decl::add_member_function_template): Fix comment. (class_decl::add_member_class_template) (class_decl::member_class_template::operator==) (class_decl::member_class_template_hash::operator()): New definitions. (class_decl::operator==): Compare member templates. Fix logic. (class_decl::data_member_hash::operator()) (class_decl::member_function_hash::operator()) (class_decl::member_function_template_hash::operator()): Don't hash the is_static boolean as it's hashed as part of the 'member' sub-object hashing. (class_decl::member_function_template::operator==): Move this out of line here, from the header file. (class_decl_hash::operator()): Hash member class templates. * src/abg-ir.h (class_decl::member::{m_is_static,is_static}): Add the is_static boolean here, so that it's factorized out of the inherited classes of this class. (class_decl::data_member::{is_static, m_is_static}) (class_decl::member_function::{is_static, m_is_static}) (class_decl::member_function_template::{is_static, m_is_static}): Remove this as it's now part of the base 'member' class. (class_decl::data_member::operator==) (class_decl::member_function::operator==): Don't compare the is_static boolean as it's now compared as part of the 'member' sub-object comparison. (class_decl::member_function_template::operator==): Move this out-of-line into src/abg-ir.cc. (class class_decl::member_class_template, struct class_decl::member_class_template_hash) (class_decl::{add_member_class_template, get_member_class_templates}): New declarations. (class_decl::member_class_templates_type): New typedef. * src/abg-reader.cc (build_class_decl): Support de-serializing member class templates. * src/abg-writer.cc (write_class_decl): Likewise, support serializing member class templates. * tests/data/test-read-write/test16.xml: New test input. * tests/test-read-write.cc (int_out_specs[]): Add the new test input to the list of inputs that are de-serialized and serialized back. * tests/Makefile.am: Add the new test input to the distribution.
2013-05-02 15:12:55 +00:00
add_member_function_template(shared_ptr<member_function_template>);
Initial support for function templates * src/abg-ir.h (function_decl::set_return_type): New inline definition. (class template_decl, struct template_decl_hash, class template_parameter, struct template_parameter_hash, struct dynamic_template_parameter_hash, struct template_parameter_shared_ptr_hash, class template_type_parameter) (struct template_type_parameter_hash, class template_non_type_parameter, struct template_non_type_parameter_hash, class template_template_parameter, struct template_template_parameter_hash, class function_template_decl) (struct function_template_decl_hash, struct fn_tmpl_shared_ptr_hash): New declarations. * src/abg-ir.cc (dynamic_type_hash::operator()): Add hashing for template template, and template type parameters. (template_decl_hash::operator, template_decl::~template_decl) (template_decl::operator==, template_parameter::operator==) (template_parameter_hash::operator()) (dynamic_template_parameter_hash::operator()) (template_type_parameter::operator==) (template_type_parameter::~template_type_parameter) (template_type_parameter_hash::operator()) (template_non_type_parameter::operator==) (template_non_type_parameter::~template_non_type_parameter) (template_non_type_parameter_hash::operator()) (template_template_parameter::operator==) (template_template_parameter::~template_template_parameter) (template_template_parameter_hash::operator()) (function_template_decl::operator==) (function_template_decl_hash::operator()) (fn_tmpl_shared_ptr_hash::operator()) (function_template_decl::~function_template_decl()): New definitions. * src/abg-reader.cc (read_context::get_fn_tmpl_decl) (read_context::key_fn_tmpl_decl): New functions. (read_context::m_fn_tmpl_map): New data member. (read_context::key_type_decl): Renamed read_context::add_type_decl into this. (read_context::push_decl_to_current_scope): Renamed read_context::finish_decl_creation into this. Add an assert. (read_context::push_and_key_type_decl): Renamed read_context::finish_type_decl_creation into this. Adjust to the use of push_decl_to_current_scope and key_type_decl. (build_function_template_decl, build_template_type_parameter) (build_template_non_type_parameter) (build_template_template_parameter, build_template_parameter) (handle_function_template_decl): New functions. (handle_element): Call handle_function_template_decl. (build_function_decl): Take a bool parameter to update depth information in parsing context. Move instantiation of function_decl before parsing its xml sub-nodes. Update the depth info in the parsing context if necessary. Push the newly intantiated decl to scope. And then parse the sub nodes. Do not forget to add the fn parameters and return type using function_decl::add_parameter and function_decl::set_return_type. (build_var_decl, build_type_decl, build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_enum_type_decl, build_typedef_decl, handled_type_decl) (handle_qualified_type_decl, handle_pointer_type_def) (handle_reference_type_def, handle_enum_type_decl) (handle_typedef_decl, handle_var_decl, handle_function_decl) (handle_class_decl): Adjust. (build_class_decl): Take a bool parameter to update depth information in parsing context. Add comment. Wait for the class members to be built, before keying (and thus hashing it) the class. (build_type): Fix logic, and adjust. * src/abg-writer.cc (write_context::type_has_existing_id) (write_context::get_id_for_fn_tmpl, write_template_type_parameter) (write_template_non_type_parameter) (write_template_template_parameter, write_template_parameter) (write_function_template_decl): New functions. (write_context::get_id_for_type): Simplify logic. (write_decl): Support writing function template. * tests/data/test-read-write/test11.xml: New test input. * tests/test-read-write.cc (InoutSpec in_out_specs[]): De-serialize the new test11.xml test, serialize it back and diff output and input. * tests/Makefile.am: Add test11.xml to the distribution.
2013-04-23 09:27:32 +00:00
const member_function_templates&
get_member_function_templates() const
{return member_function_templates_;}
Initial support for function templates * src/abg-ir.h (function_decl::set_return_type): New inline definition. (class template_decl, struct template_decl_hash, class template_parameter, struct template_parameter_hash, struct dynamic_template_parameter_hash, struct template_parameter_shared_ptr_hash, class template_type_parameter) (struct template_type_parameter_hash, class template_non_type_parameter, struct template_non_type_parameter_hash, class template_template_parameter, struct template_template_parameter_hash, class function_template_decl) (struct function_template_decl_hash, struct fn_tmpl_shared_ptr_hash): New declarations. * src/abg-ir.cc (dynamic_type_hash::operator()): Add hashing for template template, and template type parameters. (template_decl_hash::operator, template_decl::~template_decl) (template_decl::operator==, template_parameter::operator==) (template_parameter_hash::operator()) (dynamic_template_parameter_hash::operator()) (template_type_parameter::operator==) (template_type_parameter::~template_type_parameter) (template_type_parameter_hash::operator()) (template_non_type_parameter::operator==) (template_non_type_parameter::~template_non_type_parameter) (template_non_type_parameter_hash::operator()) (template_template_parameter::operator==) (template_template_parameter::~template_template_parameter) (template_template_parameter_hash::operator()) (function_template_decl::operator==) (function_template_decl_hash::operator()) (fn_tmpl_shared_ptr_hash::operator()) (function_template_decl::~function_template_decl()): New definitions. * src/abg-reader.cc (read_context::get_fn_tmpl_decl) (read_context::key_fn_tmpl_decl): New functions. (read_context::m_fn_tmpl_map): New data member. (read_context::key_type_decl): Renamed read_context::add_type_decl into this. (read_context::push_decl_to_current_scope): Renamed read_context::finish_decl_creation into this. Add an assert. (read_context::push_and_key_type_decl): Renamed read_context::finish_type_decl_creation into this. Adjust to the use of push_decl_to_current_scope and key_type_decl. (build_function_template_decl, build_template_type_parameter) (build_template_non_type_parameter) (build_template_template_parameter, build_template_parameter) (handle_function_template_decl): New functions. (handle_element): Call handle_function_template_decl. (build_function_decl): Take a bool parameter to update depth information in parsing context. Move instantiation of function_decl before parsing its xml sub-nodes. Update the depth info in the parsing context if necessary. Push the newly intantiated decl to scope. And then parse the sub nodes. Do not forget to add the fn parameters and return type using function_decl::add_parameter and function_decl::set_return_type. (build_var_decl, build_type_decl, build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_enum_type_decl, build_typedef_decl, handled_type_decl) (handle_qualified_type_decl, handle_pointer_type_def) (handle_reference_type_def, handle_enum_type_decl) (handle_typedef_decl, handle_var_decl, handle_function_decl) (handle_class_decl): Adjust. (build_class_decl): Take a bool parameter to update depth information in parsing context. Add comment. Wait for the class members to be built, before keying (and thus hashing it) the class. (build_type): Fix logic, and adjust. * src/abg-writer.cc (write_context::type_has_existing_id) (write_context::get_id_for_fn_tmpl, write_template_type_parameter) (write_template_non_type_parameter) (write_template_template_parameter, write_template_parameter) (write_function_template_decl): New functions. (write_context::get_id_for_type): Simplify logic. (write_decl): Support writing function template. * tests/data/test-read-write/test11.xml: New test input. * tests/test-read-write.cc (InoutSpec in_out_specs[]): De-serialize the new test11.xml test, serialize it back and diff output and input. * tests/Makefile.am: Add test11.xml to the distribution.
2013-04-23 09:27:32 +00:00
Initial support for member class templates * src/abg-ir.cc (class_decl::add_member_function_template): Fix comment. (class_decl::add_member_class_template) (class_decl::member_class_template::operator==) (class_decl::member_class_template_hash::operator()): New definitions. (class_decl::operator==): Compare member templates. Fix logic. (class_decl::data_member_hash::operator()) (class_decl::member_function_hash::operator()) (class_decl::member_function_template_hash::operator()): Don't hash the is_static boolean as it's hashed as part of the 'member' sub-object hashing. (class_decl::member_function_template::operator==): Move this out of line here, from the header file. (class_decl_hash::operator()): Hash member class templates. * src/abg-ir.h (class_decl::member::{m_is_static,is_static}): Add the is_static boolean here, so that it's factorized out of the inherited classes of this class. (class_decl::data_member::{is_static, m_is_static}) (class_decl::member_function::{is_static, m_is_static}) (class_decl::member_function_template::{is_static, m_is_static}): Remove this as it's now part of the base 'member' class. (class_decl::data_member::operator==) (class_decl::member_function::operator==): Don't compare the is_static boolean as it's now compared as part of the 'member' sub-object comparison. (class_decl::member_function_template::operator==): Move this out-of-line into src/abg-ir.cc. (class class_decl::member_class_template, struct class_decl::member_class_template_hash) (class_decl::{add_member_class_template, get_member_class_templates}): New declarations. (class_decl::member_class_templates_type): New typedef. * src/abg-reader.cc (build_class_decl): Support de-serializing member class templates. * src/abg-writer.cc (write_class_decl): Likewise, support serializing member class templates. * tests/data/test-read-write/test16.xml: New test input. * tests/test-read-write.cc (int_out_specs[]): Add the new test input to the list of inputs that are de-serialized and serialized back. * tests/Makefile.am: Add the new test input to the distribution.
2013-05-02 15:12:55 +00:00
void
add_member_class_template(shared_ptr<member_class_template> m);
Initial support for member class templates * src/abg-ir.cc (class_decl::add_member_function_template): Fix comment. (class_decl::add_member_class_template) (class_decl::member_class_template::operator==) (class_decl::member_class_template_hash::operator()): New definitions. (class_decl::operator==): Compare member templates. Fix logic. (class_decl::data_member_hash::operator()) (class_decl::member_function_hash::operator()) (class_decl::member_function_template_hash::operator()): Don't hash the is_static boolean as it's hashed as part of the 'member' sub-object hashing. (class_decl::member_function_template::operator==): Move this out of line here, from the header file. (class_decl_hash::operator()): Hash member class templates. * src/abg-ir.h (class_decl::member::{m_is_static,is_static}): Add the is_static boolean here, so that it's factorized out of the inherited classes of this class. (class_decl::data_member::{is_static, m_is_static}) (class_decl::member_function::{is_static, m_is_static}) (class_decl::member_function_template::{is_static, m_is_static}): Remove this as it's now part of the base 'member' class. (class_decl::data_member::operator==) (class_decl::member_function::operator==): Don't compare the is_static boolean as it's now compared as part of the 'member' sub-object comparison. (class_decl::member_function_template::operator==): Move this out-of-line into src/abg-ir.cc. (class class_decl::member_class_template, struct class_decl::member_class_template_hash) (class_decl::{add_member_class_template, get_member_class_templates}): New declarations. (class_decl::member_class_templates_type): New typedef. * src/abg-reader.cc (build_class_decl): Support de-serializing member class templates. * src/abg-writer.cc (write_class_decl): Likewise, support serializing member class templates. * tests/data/test-read-write/test16.xml: New test input. * tests/test-read-write.cc (int_out_specs[]): Add the new test input to the list of inputs that are de-serialized and serialized back. * tests/Makefile.am: Add the new test input to the distribution.
2013-05-02 15:12:55 +00:00
const member_class_templates&
Initial support for member class templates * src/abg-ir.cc (class_decl::add_member_function_template): Fix comment. (class_decl::add_member_class_template) (class_decl::member_class_template::operator==) (class_decl::member_class_template_hash::operator()): New definitions. (class_decl::operator==): Compare member templates. Fix logic. (class_decl::data_member_hash::operator()) (class_decl::member_function_hash::operator()) (class_decl::member_function_template_hash::operator()): Don't hash the is_static boolean as it's hashed as part of the 'member' sub-object hashing. (class_decl::member_function_template::operator==): Move this out of line here, from the header file. (class_decl_hash::operator()): Hash member class templates. * src/abg-ir.h (class_decl::member::{m_is_static,is_static}): Add the is_static boolean here, so that it's factorized out of the inherited classes of this class. (class_decl::data_member::{is_static, m_is_static}) (class_decl::member_function::{is_static, m_is_static}) (class_decl::member_function_template::{is_static, m_is_static}): Remove this as it's now part of the base 'member' class. (class_decl::data_member::operator==) (class_decl::member_function::operator==): Don't compare the is_static boolean as it's now compared as part of the 'member' sub-object comparison. (class_decl::member_function_template::operator==): Move this out-of-line into src/abg-ir.cc. (class class_decl::member_class_template, struct class_decl::member_class_template_hash) (class_decl::{add_member_class_template, get_member_class_templates}): New declarations. (class_decl::member_class_templates_type): New typedef. * src/abg-reader.cc (build_class_decl): Support de-serializing member class templates. * src/abg-writer.cc (write_class_decl): Likewise, support serializing member class templates. * tests/data/test-read-write/test16.xml: New test input. * tests/test-read-write.cc (int_out_specs[]): Add the new test input to the list of inputs that are de-serialized and serialized back. * tests/Makefile.am: Add the new test input to the distribution.
2013-05-02 15:12:55 +00:00
get_member_class_templates() const
{return member_class_templates_;}
Initial support for member class templates * src/abg-ir.cc (class_decl::add_member_function_template): Fix comment. (class_decl::add_member_class_template) (class_decl::member_class_template::operator==) (class_decl::member_class_template_hash::operator()): New definitions. (class_decl::operator==): Compare member templates. Fix logic. (class_decl::data_member_hash::operator()) (class_decl::member_function_hash::operator()) (class_decl::member_function_template_hash::operator()): Don't hash the is_static boolean as it's hashed as part of the 'member' sub-object hashing. (class_decl::member_function_template::operator==): Move this out of line here, from the header file. (class_decl_hash::operator()): Hash member class templates. * src/abg-ir.h (class_decl::member::{m_is_static,is_static}): Add the is_static boolean here, so that it's factorized out of the inherited classes of this class. (class_decl::data_member::{is_static, m_is_static}) (class_decl::member_function::{is_static, m_is_static}) (class_decl::member_function_template::{is_static, m_is_static}): Remove this as it's now part of the base 'member' class. (class_decl::data_member::operator==) (class_decl::member_function::operator==): Don't compare the is_static boolean as it's now compared as part of the 'member' sub-object comparison. (class_decl::member_function_template::operator==): Move this out-of-line into src/abg-ir.cc. (class class_decl::member_class_template, struct class_decl::member_class_template_hash) (class_decl::{add_member_class_template, get_member_class_templates}): New declarations. (class_decl::member_class_templates_type): New typedef. * src/abg-reader.cc (build_class_decl): Support de-serializing member class templates. * src/abg-writer.cc (write_class_decl): Likewise, support serializing member class templates. * tests/data/test-read-write/test16.xml: New test input. * tests/test-read-write.cc (int_out_specs[]): Add the new test input to the list of inputs that are de-serialized and serialized back. * tests/Makefile.am: Add the new test input to the distribution.
2013-05-02 15:12:55 +00:00
bool
has_no_base_nor_member() const;
virtual bool
operator==(const decl_base&) const;
virtual bool
operator==(const type_base&) const;
bool
operator==(const class_decl&) const;
Initial support for function templates * src/abg-ir.h (function_decl::set_return_type): New inline definition. (class template_decl, struct template_decl_hash, class template_parameter, struct template_parameter_hash, struct dynamic_template_parameter_hash, struct template_parameter_shared_ptr_hash, class template_type_parameter) (struct template_type_parameter_hash, class template_non_type_parameter, struct template_non_type_parameter_hash, class template_template_parameter, struct template_template_parameter_hash, class function_template_decl) (struct function_template_decl_hash, struct fn_tmpl_shared_ptr_hash): New declarations. * src/abg-ir.cc (dynamic_type_hash::operator()): Add hashing for template template, and template type parameters. (template_decl_hash::operator, template_decl::~template_decl) (template_decl::operator==, template_parameter::operator==) (template_parameter_hash::operator()) (dynamic_template_parameter_hash::operator()) (template_type_parameter::operator==) (template_type_parameter::~template_type_parameter) (template_type_parameter_hash::operator()) (template_non_type_parameter::operator==) (template_non_type_parameter::~template_non_type_parameter) (template_non_type_parameter_hash::operator()) (template_template_parameter::operator==) (template_template_parameter::~template_template_parameter) (template_template_parameter_hash::operator()) (function_template_decl::operator==) (function_template_decl_hash::operator()) (fn_tmpl_shared_ptr_hash::operator()) (function_template_decl::~function_template_decl()): New definitions. * src/abg-reader.cc (read_context::get_fn_tmpl_decl) (read_context::key_fn_tmpl_decl): New functions. (read_context::m_fn_tmpl_map): New data member. (read_context::key_type_decl): Renamed read_context::add_type_decl into this. (read_context::push_decl_to_current_scope): Renamed read_context::finish_decl_creation into this. Add an assert. (read_context::push_and_key_type_decl): Renamed read_context::finish_type_decl_creation into this. Adjust to the use of push_decl_to_current_scope and key_type_decl. (build_function_template_decl, build_template_type_parameter) (build_template_non_type_parameter) (build_template_template_parameter, build_template_parameter) (handle_function_template_decl): New functions. (handle_element): Call handle_function_template_decl. (build_function_decl): Take a bool parameter to update depth information in parsing context. Move instantiation of function_decl before parsing its xml sub-nodes. Update the depth info in the parsing context if necessary. Push the newly intantiated decl to scope. And then parse the sub nodes. Do not forget to add the fn parameters and return type using function_decl::add_parameter and function_decl::set_return_type. (build_var_decl, build_type_decl, build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_enum_type_decl, build_typedef_decl, handled_type_decl) (handle_qualified_type_decl, handle_pointer_type_def) (handle_reference_type_def, handle_enum_type_decl) (handle_typedef_decl, handle_var_decl, handle_function_decl) (handle_class_decl): Adjust. (build_class_decl): Take a bool parameter to update depth information in parsing context. Add comment. Wait for the class members to be built, before keying (and thus hashing it) the class. (build_type): Fix logic, and adjust. * src/abg-writer.cc (write_context::type_has_existing_id) (write_context::get_id_for_fn_tmpl, write_template_type_parameter) (write_template_non_type_parameter) (write_template_template_parameter, write_template_parameter) (write_function_template_decl): New functions. (write_context::get_id_for_type): Simplify logic. (write_decl): Support writing function template. * tests/data/test-read-write/test11.xml: New test input. * tests/test-read-write.cc (InoutSpec in_out_specs[]): De-serialize the new test11.xml test, serialize it back and diff output and input. * tests/Makefile.am: Add test11.xml to the distribution.
2013-04-23 09:27:32 +00:00
virtual void
traverse(ir_node_visitor& v);
virtual ~class_decl();
};// end class class_decl
std::ostream&
operator<<(std::ostream&, class_decl::access_specifier);
Un-debugged initial implementation of class diffing. * include/abg-ir.h (decl_base::get_qualified_name): New declaration. (class_decl::{base_specs, member_types, data_members, member_functions, member_function_templates, member_class_templates}): Make all these containers be vectors, rather than list. This makes these containers (like class_decl::base_specs, class_decl::member_types, etc) be suitable to be used by the core diffing algorithms to diff their content. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Declare these new equality operators. These are to be used by the core diffing algorithms when comparing two vectors of shared pointers of members of class_decls. * src/abg-ir.cc (decl_base::get_qualified_name): Define. (class_decl::class_decl, class_decl::operator==(class_decl&)): Adjust for the containers type change to a vector. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Define these. * include/abg-comparison.h (diff::scope_): Remove (diff::{first_scope_, second_scope_}): New members. (class_decl_diff::class_decl_diff): Pass the new scopes to this constructor. (class_decl_diff::{first_class_decl, second_class_decl}) (report_changes): New declarations. * src/abg-comparison.cc (class_decl_diff::class_decl_diff): Update as per the declaration. (class_decl_diff::{first_class_decl, second_class_decl}): Define as per the declaration. (compute_diff): Initial implementation for this. (report_changes): Define. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-04 15:39:08 +00:00
bool
operator==(class_decl_sptr l, class_decl_sptr r);
/// The base class for member types, data members and member
/// functions. Its purpose is mainly to carry the access specifier
/// (and possibly other properties that might be shared by all class
/// members) for the member.
class class_decl::member_base
{
Fix class scope setting & member type de-serializing from dwarf * include/abg-fwd.h (add_decl_to_scope, insert_decl_into_scope): return the decl added to the scope. (as_non_member_type, get_type_declaration): Declare new entry points. * include/abg-ir.h (class decl_base::insert_decl_into_scope): Update this friend declaration. (class scope_decl, class_decl): Update the friend add_decl_to_scope declaration. (scope_decl::add_member_decl): Return the added decl. (class_decl_sptr): Move this typedef befoer the class_decl class declaration. (class_decl::definition_of_declaration_): New member. (class_decl::{set_definition_of_declaration, get_definition_of_declaration}): New accessors. (class_decl::add_member_decl): Return the added member. (class_decl::insert_member_type): New member. (class_decl::member_base::access_specifier): Make this protected. (class_decl::member_type): Make this inherit from type_vase. (class_decl::member_type::type_): Remove this member. (class_decl::member_type::as_type): Remove this accessor. (class_decl::member_type::operator==(const type_base&)): New. (class_decl::member_type::operator shared_ptr<type_base>() const): Remove. (class_decl::member_type::get_underlying_type): New. (class_decl::member_type::operator==(const member_type&) const): New. * src/abg-comparison.cc (class_diff::{ensure_lookup_tables_populated, report}): Adjust for the removal of class_decl::member_type::as_type. * src/abg-dwarf-reader.cc (scope_stack_type): Change this as a typedef to stack<scope_decl*>. (current_scope): Change return type from scope_decl_sptr to scope_decl*. (insert_decl_into_scope): New. (build_namespace_decl_and_add_to_ir): Use insert_decl_into_scope in lieu of add_decl_to_scope. (build_class_type_and_add_to_ir): likewise. Link a class definition to its declaration. Push the current scope on the scope stack. Use as_non_member_type. Fix setting member types. (get_scope_for_die): Look through declaration-only classe to get its definition. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type, build_var_decl) (build_function_decl): Use as_non_member_type. (build_ir_node_from_die): Fix member variable & function adding. * src/abg-ir.cc (scope_decl::{add_member_decl, insert_member_decl}): Return the added member. (add_decl_to_scope): Likewise. (insert_decl_into_scope): Likewise. (get_top_most_scope_under): Fix logic. (get_type_declaration): New overload that return a decl_base*. (as_non_member_type): New definition. (class_decl::{get_definition_of_declaration, set_definition_of_declaration, insert_member_decl}): Likewise. (class_decl::add_member_decl): Re-write in terms of class::insert_member_decl. (class_decl::insert_member_type): New definition. (class_decl::add_member_type): Re-write in terms of class_decl::insert_member_type. (class_decl::remove_member_type): Update for the class_decl::member_type::as_type removal. (class_decl::{add_data_member, add_member_function, add_member_function_template, add_member_class_template}): Call scope_decl::add_member_decl. (class_decl::member_type::member_type): Update as the type now virtually inherits from type_base. (class_decl::member_type::{set,get}_access_specifier): New definitions. (class_decl::member_type::get_underlying_type): Likewise. (class_decl::member_type::set_scope): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. (class_decl::member_type::operator==(const decl_base& other)): There is no more class_decl::member_type::as_type. (class_decl::member_type::operator==(const type_base& other)): New. (class_decl::member_type::get_pretty_representation): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. * src/abg-reader.cc (build_class_decl): New that add add_member_decl adds even member types, no need to add it explicitly anymore. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 11:27:47 +00:00
protected:
enum access_specifier access_;
bool is_static_;
Fix class scope setting & member type de-serializing from dwarf * include/abg-fwd.h (add_decl_to_scope, insert_decl_into_scope): return the decl added to the scope. (as_non_member_type, get_type_declaration): Declare new entry points. * include/abg-ir.h (class decl_base::insert_decl_into_scope): Update this friend declaration. (class scope_decl, class_decl): Update the friend add_decl_to_scope declaration. (scope_decl::add_member_decl): Return the added decl. (class_decl_sptr): Move this typedef befoer the class_decl class declaration. (class_decl::definition_of_declaration_): New member. (class_decl::{set_definition_of_declaration, get_definition_of_declaration}): New accessors. (class_decl::add_member_decl): Return the added member. (class_decl::insert_member_type): New member. (class_decl::member_base::access_specifier): Make this protected. (class_decl::member_type): Make this inherit from type_vase. (class_decl::member_type::type_): Remove this member. (class_decl::member_type::as_type): Remove this accessor. (class_decl::member_type::operator==(const type_base&)): New. (class_decl::member_type::operator shared_ptr<type_base>() const): Remove. (class_decl::member_type::get_underlying_type): New. (class_decl::member_type::operator==(const member_type&) const): New. * src/abg-comparison.cc (class_diff::{ensure_lookup_tables_populated, report}): Adjust for the removal of class_decl::member_type::as_type. * src/abg-dwarf-reader.cc (scope_stack_type): Change this as a typedef to stack<scope_decl*>. (current_scope): Change return type from scope_decl_sptr to scope_decl*. (insert_decl_into_scope): New. (build_namespace_decl_and_add_to_ir): Use insert_decl_into_scope in lieu of add_decl_to_scope. (build_class_type_and_add_to_ir): likewise. Link a class definition to its declaration. Push the current scope on the scope stack. Use as_non_member_type. Fix setting member types. (get_scope_for_die): Look through declaration-only classe to get its definition. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type, build_var_decl) (build_function_decl): Use as_non_member_type. (build_ir_node_from_die): Fix member variable & function adding. * src/abg-ir.cc (scope_decl::{add_member_decl, insert_member_decl}): Return the added member. (add_decl_to_scope): Likewise. (insert_decl_into_scope): Likewise. (get_top_most_scope_under): Fix logic. (get_type_declaration): New overload that return a decl_base*. (as_non_member_type): New definition. (class_decl::{get_definition_of_declaration, set_definition_of_declaration, insert_member_decl}): Likewise. (class_decl::add_member_decl): Re-write in terms of class::insert_member_decl. (class_decl::insert_member_type): New definition. (class_decl::add_member_type): Re-write in terms of class_decl::insert_member_type. (class_decl::remove_member_type): Update for the class_decl::member_type::as_type removal. (class_decl::{add_data_member, add_member_function, add_member_function_template, add_member_class_template}): Call scope_decl::add_member_decl. (class_decl::member_type::member_type): Update as the type now virtually inherits from type_base. (class_decl::member_type::{set,get}_access_specifier): New definitions. (class_decl::member_type::get_underlying_type): Likewise. (class_decl::member_type::set_scope): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. (class_decl::member_type::operator==(const decl_base& other)): There is no more class_decl::member_type::as_type. (class_decl::member_type::operator==(const type_base& other)): New. (class_decl::member_type::get_pretty_representation): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. * src/abg-reader.cc (build_class_decl): New that add add_member_decl adds even member types, no need to add it explicitly anymore. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 11:27:47 +00:00
private:
// Forbidden
member_base();
public:
/// Hasher.
struct hash;
member_base(access_specifier a, bool is_static = false)
: access_(a), is_static_(is_static)
{}
/// Getter for the access specifier of this member.
///
/// @return the access specifier for this member.
access_specifier
get_access_specifier() const
{return access_;}
/// Setter for the access specifier of this member.
///
/// @param a the new access specifier.
void
set_access_specifier(access_specifier a)
{access_ = a;}
/// @return true if the member is static, false otherwise.
bool
get_is_static() const
{return is_static_;}
/// Set a flag saying if the parameter is static or not.
///
/// @param f set to true if the member is static, false otherwise.
void
set_is_static(bool f)
{is_static_ = f;}
virtual bool
operator==(const member_base& o) const;
};// end class class_decl::member_base
/// Abstracts a member type declaration.
///
/// It's important to understand the interactions between this type
/// and the other types. When a type T appears in the scope of a
/// class, it becomes a member type MT. T is said to be the
/// underlying type of MT. MT and T are different types. In
/// practice, when the function class_decl::add_member_type is given a
/// type T, it adds it to the class scope and returns MT, which is the
/// resulting member type that is created. T can be retrieved from MT
/// by invoking either MT::get_underlying_type(), or by invoking
/// as_non_member_type(MT).
Fix class scope setting & member type de-serializing from dwarf * include/abg-fwd.h (add_decl_to_scope, insert_decl_into_scope): return the decl added to the scope. (as_non_member_type, get_type_declaration): Declare new entry points. * include/abg-ir.h (class decl_base::insert_decl_into_scope): Update this friend declaration. (class scope_decl, class_decl): Update the friend add_decl_to_scope declaration. (scope_decl::add_member_decl): Return the added decl. (class_decl_sptr): Move this typedef befoer the class_decl class declaration. (class_decl::definition_of_declaration_): New member. (class_decl::{set_definition_of_declaration, get_definition_of_declaration}): New accessors. (class_decl::add_member_decl): Return the added member. (class_decl::insert_member_type): New member. (class_decl::member_base::access_specifier): Make this protected. (class_decl::member_type): Make this inherit from type_vase. (class_decl::member_type::type_): Remove this member. (class_decl::member_type::as_type): Remove this accessor. (class_decl::member_type::operator==(const type_base&)): New. (class_decl::member_type::operator shared_ptr<type_base>() const): Remove. (class_decl::member_type::get_underlying_type): New. (class_decl::member_type::operator==(const member_type&) const): New. * src/abg-comparison.cc (class_diff::{ensure_lookup_tables_populated, report}): Adjust for the removal of class_decl::member_type::as_type. * src/abg-dwarf-reader.cc (scope_stack_type): Change this as a typedef to stack<scope_decl*>. (current_scope): Change return type from scope_decl_sptr to scope_decl*. (insert_decl_into_scope): New. (build_namespace_decl_and_add_to_ir): Use insert_decl_into_scope in lieu of add_decl_to_scope. (build_class_type_and_add_to_ir): likewise. Link a class definition to its declaration. Push the current scope on the scope stack. Use as_non_member_type. Fix setting member types. (get_scope_for_die): Look through declaration-only classe to get its definition. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type, build_var_decl) (build_function_decl): Use as_non_member_type. (build_ir_node_from_die): Fix member variable & function adding. * src/abg-ir.cc (scope_decl::{add_member_decl, insert_member_decl}): Return the added member. (add_decl_to_scope): Likewise. (insert_decl_into_scope): Likewise. (get_top_most_scope_under): Fix logic. (get_type_declaration): New overload that return a decl_base*. (as_non_member_type): New definition. (class_decl::{get_definition_of_declaration, set_definition_of_declaration, insert_member_decl}): Likewise. (class_decl::add_member_decl): Re-write in terms of class::insert_member_decl. (class_decl::insert_member_type): New definition. (class_decl::add_member_type): Re-write in terms of class_decl::insert_member_type. (class_decl::remove_member_type): Update for the class_decl::member_type::as_type removal. (class_decl::{add_data_member, add_member_function, add_member_function_template, add_member_class_template}): Call scope_decl::add_member_decl. (class_decl::member_type::member_type): Update as the type now virtually inherits from type_base. (class_decl::member_type::{set,get}_access_specifier): New definitions. (class_decl::member_type::get_underlying_type): Likewise. (class_decl::member_type::set_scope): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. (class_decl::member_type::operator==(const decl_base& other)): There is no more class_decl::member_type::as_type. (class_decl::member_type::operator==(const type_base& other)): New. (class_decl::member_type::get_pretty_representation): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. * src/abg-reader.cc (build_class_decl): New that add add_member_decl adds even member types, no need to add it explicitly anymore. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 11:27:47 +00:00
class class_decl::member_type : public member_base,
public virtual decl_base,
public virtual type_base
{
Fix class scope setting & member type de-serializing from dwarf * include/abg-fwd.h (add_decl_to_scope, insert_decl_into_scope): return the decl added to the scope. (as_non_member_type, get_type_declaration): Declare new entry points. * include/abg-ir.h (class decl_base::insert_decl_into_scope): Update this friend declaration. (class scope_decl, class_decl): Update the friend add_decl_to_scope declaration. (scope_decl::add_member_decl): Return the added decl. (class_decl_sptr): Move this typedef befoer the class_decl class declaration. (class_decl::definition_of_declaration_): New member. (class_decl::{set_definition_of_declaration, get_definition_of_declaration}): New accessors. (class_decl::add_member_decl): Return the added member. (class_decl::insert_member_type): New member. (class_decl::member_base::access_specifier): Make this protected. (class_decl::member_type): Make this inherit from type_vase. (class_decl::member_type::type_): Remove this member. (class_decl::member_type::as_type): Remove this accessor. (class_decl::member_type::operator==(const type_base&)): New. (class_decl::member_type::operator shared_ptr<type_base>() const): Remove. (class_decl::member_type::get_underlying_type): New. (class_decl::member_type::operator==(const member_type&) const): New. * src/abg-comparison.cc (class_diff::{ensure_lookup_tables_populated, report}): Adjust for the removal of class_decl::member_type::as_type. * src/abg-dwarf-reader.cc (scope_stack_type): Change this as a typedef to stack<scope_decl*>. (current_scope): Change return type from scope_decl_sptr to scope_decl*. (insert_decl_into_scope): New. (build_namespace_decl_and_add_to_ir): Use insert_decl_into_scope in lieu of add_decl_to_scope. (build_class_type_and_add_to_ir): likewise. Link a class definition to its declaration. Push the current scope on the scope stack. Use as_non_member_type. Fix setting member types. (get_scope_for_die): Look through declaration-only classe to get its definition. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type, build_var_decl) (build_function_decl): Use as_non_member_type. (build_ir_node_from_die): Fix member variable & function adding. * src/abg-ir.cc (scope_decl::{add_member_decl, insert_member_decl}): Return the added member. (add_decl_to_scope): Likewise. (insert_decl_into_scope): Likewise. (get_top_most_scope_under): Fix logic. (get_type_declaration): New overload that return a decl_base*. (as_non_member_type): New definition. (class_decl::{get_definition_of_declaration, set_definition_of_declaration, insert_member_decl}): Likewise. (class_decl::add_member_decl): Re-write in terms of class::insert_member_decl. (class_decl::insert_member_type): New definition. (class_decl::add_member_type): Re-write in terms of class_decl::insert_member_type. (class_decl::remove_member_type): Update for the class_decl::member_type::as_type removal. (class_decl::{add_data_member, add_member_function, add_member_function_template, add_member_class_template}): Call scope_decl::add_member_decl. (class_decl::member_type::member_type): Update as the type now virtually inherits from type_base. (class_decl::member_type::{set,get}_access_specifier): New definitions. (class_decl::member_type::get_underlying_type): Likewise. (class_decl::member_type::set_scope): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. (class_decl::member_type::operator==(const decl_base& other)): There is no more class_decl::member_type::as_type. (class_decl::member_type::operator==(const type_base& other)): New. (class_decl::member_type::get_pretty_representation): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. * src/abg-reader.cc (build_class_decl): New that add add_member_decl adds even member types, no need to add it explicitly anymore. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 11:27:47 +00:00
type_base_sptr type_;
//Forbidden
member_type();
public:
// Hasher.
struct hash;
member_type(shared_ptr<type_base> t, access_specifier access);
virtual void
set_scope(scope_decl*);
virtual bool
operator==(const decl_base&) const;
virtual bool
operator==(const member_base&) const;
Fix class scope setting & member type de-serializing from dwarf * include/abg-fwd.h (add_decl_to_scope, insert_decl_into_scope): return the decl added to the scope. (as_non_member_type, get_type_declaration): Declare new entry points. * include/abg-ir.h (class decl_base::insert_decl_into_scope): Update this friend declaration. (class scope_decl, class_decl): Update the friend add_decl_to_scope declaration. (scope_decl::add_member_decl): Return the added decl. (class_decl_sptr): Move this typedef befoer the class_decl class declaration. (class_decl::definition_of_declaration_): New member. (class_decl::{set_definition_of_declaration, get_definition_of_declaration}): New accessors. (class_decl::add_member_decl): Return the added member. (class_decl::insert_member_type): New member. (class_decl::member_base::access_specifier): Make this protected. (class_decl::member_type): Make this inherit from type_vase. (class_decl::member_type::type_): Remove this member. (class_decl::member_type::as_type): Remove this accessor. (class_decl::member_type::operator==(const type_base&)): New. (class_decl::member_type::operator shared_ptr<type_base>() const): Remove. (class_decl::member_type::get_underlying_type): New. (class_decl::member_type::operator==(const member_type&) const): New. * src/abg-comparison.cc (class_diff::{ensure_lookup_tables_populated, report}): Adjust for the removal of class_decl::member_type::as_type. * src/abg-dwarf-reader.cc (scope_stack_type): Change this as a typedef to stack<scope_decl*>. (current_scope): Change return type from scope_decl_sptr to scope_decl*. (insert_decl_into_scope): New. (build_namespace_decl_and_add_to_ir): Use insert_decl_into_scope in lieu of add_decl_to_scope. (build_class_type_and_add_to_ir): likewise. Link a class definition to its declaration. Push the current scope on the scope stack. Use as_non_member_type. Fix setting member types. (get_scope_for_die): Look through declaration-only classe to get its definition. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type, build_var_decl) (build_function_decl): Use as_non_member_type. (build_ir_node_from_die): Fix member variable & function adding. * src/abg-ir.cc (scope_decl::{add_member_decl, insert_member_decl}): Return the added member. (add_decl_to_scope): Likewise. (insert_decl_into_scope): Likewise. (get_top_most_scope_under): Fix logic. (get_type_declaration): New overload that return a decl_base*. (as_non_member_type): New definition. (class_decl::{get_definition_of_declaration, set_definition_of_declaration, insert_member_decl}): Likewise. (class_decl::add_member_decl): Re-write in terms of class::insert_member_decl. (class_decl::insert_member_type): New definition. (class_decl::add_member_type): Re-write in terms of class_decl::insert_member_type. (class_decl::remove_member_type): Update for the class_decl::member_type::as_type removal. (class_decl::{add_data_member, add_member_function, add_member_function_template, add_member_class_template}): Call scope_decl::add_member_decl. (class_decl::member_type::member_type): Update as the type now virtually inherits from type_base. (class_decl::member_type::{set,get}_access_specifier): New definitions. (class_decl::member_type::get_underlying_type): Likewise. (class_decl::member_type::set_scope): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. (class_decl::member_type::operator==(const decl_base& other)): There is no more class_decl::member_type::as_type. (class_decl::member_type::operator==(const type_base& other)): New. (class_decl::member_type::get_pretty_representation): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. * src/abg-reader.cc (build_class_decl): New that add add_member_decl adds even member types, no need to add it explicitly anymore. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 11:27:47 +00:00
virtual bool
operator==(const type_base&) const;
virtual string
get_pretty_representation() const;
virtual void
traverse(ir_node_visitor& v);
const type_base_sptr&
Fix class scope setting & member type de-serializing from dwarf * include/abg-fwd.h (add_decl_to_scope, insert_decl_into_scope): return the decl added to the scope. (as_non_member_type, get_type_declaration): Declare new entry points. * include/abg-ir.h (class decl_base::insert_decl_into_scope): Update this friend declaration. (class scope_decl, class_decl): Update the friend add_decl_to_scope declaration. (scope_decl::add_member_decl): Return the added decl. (class_decl_sptr): Move this typedef befoer the class_decl class declaration. (class_decl::definition_of_declaration_): New member. (class_decl::{set_definition_of_declaration, get_definition_of_declaration}): New accessors. (class_decl::add_member_decl): Return the added member. (class_decl::insert_member_type): New member. (class_decl::member_base::access_specifier): Make this protected. (class_decl::member_type): Make this inherit from type_vase. (class_decl::member_type::type_): Remove this member. (class_decl::member_type::as_type): Remove this accessor. (class_decl::member_type::operator==(const type_base&)): New. (class_decl::member_type::operator shared_ptr<type_base>() const): Remove. (class_decl::member_type::get_underlying_type): New. (class_decl::member_type::operator==(const member_type&) const): New. * src/abg-comparison.cc (class_diff::{ensure_lookup_tables_populated, report}): Adjust for the removal of class_decl::member_type::as_type. * src/abg-dwarf-reader.cc (scope_stack_type): Change this as a typedef to stack<scope_decl*>. (current_scope): Change return type from scope_decl_sptr to scope_decl*. (insert_decl_into_scope): New. (build_namespace_decl_and_add_to_ir): Use insert_decl_into_scope in lieu of add_decl_to_scope. (build_class_type_and_add_to_ir): likewise. Link a class definition to its declaration. Push the current scope on the scope stack. Use as_non_member_type. Fix setting member types. (get_scope_for_die): Look through declaration-only classe to get its definition. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type, build_var_decl) (build_function_decl): Use as_non_member_type. (build_ir_node_from_die): Fix member variable & function adding. * src/abg-ir.cc (scope_decl::{add_member_decl, insert_member_decl}): Return the added member. (add_decl_to_scope): Likewise. (insert_decl_into_scope): Likewise. (get_top_most_scope_under): Fix logic. (get_type_declaration): New overload that return a decl_base*. (as_non_member_type): New definition. (class_decl::{get_definition_of_declaration, set_definition_of_declaration, insert_member_decl}): Likewise. (class_decl::add_member_decl): Re-write in terms of class::insert_member_decl. (class_decl::insert_member_type): New definition. (class_decl::add_member_type): Re-write in terms of class_decl::insert_member_type. (class_decl::remove_member_type): Update for the class_decl::member_type::as_type removal. (class_decl::{add_data_member, add_member_function, add_member_function_template, add_member_class_template}): Call scope_decl::add_member_decl. (class_decl::member_type::member_type): Update as the type now virtually inherits from type_base. (class_decl::member_type::{set,get}_access_specifier): New definitions. (class_decl::member_type::get_underlying_type): Likewise. (class_decl::member_type::set_scope): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. (class_decl::member_type::operator==(const decl_base& other)): There is no more class_decl::member_type::as_type. (class_decl::member_type::operator==(const type_base& other)): New. (class_decl::member_type::get_pretty_representation): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. * src/abg-reader.cc (build_class_decl): New that add add_member_decl adds even member types, no need to add it explicitly anymore. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 11:27:47 +00:00
get_underlying_type() const;
Fix class scope setting & member type de-serializing from dwarf * include/abg-fwd.h (add_decl_to_scope, insert_decl_into_scope): return the decl added to the scope. (as_non_member_type, get_type_declaration): Declare new entry points. * include/abg-ir.h (class decl_base::insert_decl_into_scope): Update this friend declaration. (class scope_decl, class_decl): Update the friend add_decl_to_scope declaration. (scope_decl::add_member_decl): Return the added decl. (class_decl_sptr): Move this typedef befoer the class_decl class declaration. (class_decl::definition_of_declaration_): New member. (class_decl::{set_definition_of_declaration, get_definition_of_declaration}): New accessors. (class_decl::add_member_decl): Return the added member. (class_decl::insert_member_type): New member. (class_decl::member_base::access_specifier): Make this protected. (class_decl::member_type): Make this inherit from type_vase. (class_decl::member_type::type_): Remove this member. (class_decl::member_type::as_type): Remove this accessor. (class_decl::member_type::operator==(const type_base&)): New. (class_decl::member_type::operator shared_ptr<type_base>() const): Remove. (class_decl::member_type::get_underlying_type): New. (class_decl::member_type::operator==(const member_type&) const): New. * src/abg-comparison.cc (class_diff::{ensure_lookup_tables_populated, report}): Adjust for the removal of class_decl::member_type::as_type. * src/abg-dwarf-reader.cc (scope_stack_type): Change this as a typedef to stack<scope_decl*>. (current_scope): Change return type from scope_decl_sptr to scope_decl*. (insert_decl_into_scope): New. (build_namespace_decl_and_add_to_ir): Use insert_decl_into_scope in lieu of add_decl_to_scope. (build_class_type_and_add_to_ir): likewise. Link a class definition to its declaration. Push the current scope on the scope stack. Use as_non_member_type. Fix setting member types. (get_scope_for_die): Look through declaration-only classe to get its definition. (build_qualified_type, build_pointer_type_def) (build_reference_type, build_typedef_type, build_var_decl) (build_function_decl): Use as_non_member_type. (build_ir_node_from_die): Fix member variable & function adding. * src/abg-ir.cc (scope_decl::{add_member_decl, insert_member_decl}): Return the added member. (add_decl_to_scope): Likewise. (insert_decl_into_scope): Likewise. (get_top_most_scope_under): Fix logic. (get_type_declaration): New overload that return a decl_base*. (as_non_member_type): New definition. (class_decl::{get_definition_of_declaration, set_definition_of_declaration, insert_member_decl}): Likewise. (class_decl::add_member_decl): Re-write in terms of class::insert_member_decl. (class_decl::insert_member_type): New definition. (class_decl::add_member_type): Re-write in terms of class_decl::insert_member_type. (class_decl::remove_member_type): Update for the class_decl::member_type::as_type removal. (class_decl::{add_data_member, add_member_function, add_member_function_template, add_member_class_template}): Call scope_decl::add_member_decl. (class_decl::member_type::member_type): Update as the type now virtually inherits from type_base. (class_decl::member_type::{set,get}_access_specifier): New definitions. (class_decl::member_type::get_underlying_type): Likewise. (class_decl::member_type::set_scope): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. (class_decl::member_type::operator==(const decl_base& other)): There is no more class_decl::member_type::as_type. (class_decl::member_type::operator==(const type_base& other)): New. (class_decl::member_type::get_pretty_representation): Update wrt class_decl::member_type::as_type -> get_underlying_type rename. * src/abg-reader.cc (build_class_decl): New that add add_member_decl adds even member types, no need to add it explicitly anymore. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 11:27:47 +00:00
bool
operator==(const member_type&) const;
};// end class member_type
Un-debugged initial implementation of class diffing. * include/abg-ir.h (decl_base::get_qualified_name): New declaration. (class_decl::{base_specs, member_types, data_members, member_functions, member_function_templates, member_class_templates}): Make all these containers be vectors, rather than list. This makes these containers (like class_decl::base_specs, class_decl::member_types, etc) be suitable to be used by the core diffing algorithms to diff their content. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Declare these new equality operators. These are to be used by the core diffing algorithms when comparing two vectors of shared pointers of members of class_decls. * src/abg-ir.cc (decl_base::get_qualified_name): Define. (class_decl::class_decl, class_decl::operator==(class_decl&)): Adjust for the containers type change to a vector. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Define these. * include/abg-comparison.h (diff::scope_): Remove (diff::{first_scope_, second_scope_}): New members. (class_decl_diff::class_decl_diff): Pass the new scopes to this constructor. (class_decl_diff::{first_class_decl, second_class_decl}) (report_changes): New declarations. * src/abg-comparison.cc (class_decl_diff::class_decl_diff): Update as per the declaration. (class_decl_diff::{first_class_decl, second_class_decl}): Define as per the declaration. (compute_diff): Initial implementation for this. (report_changes): Define. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-04 15:39:08 +00:00
bool
operator==(class_decl::member_type_sptr l, class_decl::member_type_sptr r);
/// Abstraction of a base specifier in a class declaration.
class class_decl::base_spec : public member_base
{
shared_ptr<class_decl> base_class_;
long offset_in_bits_;
bool is_virtual_;
// Forbidden
base_spec();
public:
/// Hasher.
struct hash;
base_spec(shared_ptr<class_decl> base, access_specifier a,
long offset_in_bits = -1, bool is_virtual = false);
base_spec(shared_ptr<type_base> base, access_specifier a,
long offset_in_bits = -1, bool is_virtual = false);
const shared_ptr<class_decl>&
get_base_class() const
{return base_class_;}
bool
get_is_virtual() const
{return is_virtual_;}
long
get_offset_in_bits() const
{return offset_in_bits_;}
virtual bool
operator==(const member_base&) const;
};// end class class_decl::base_spec
Un-debugged initial implementation of class diffing. * include/abg-ir.h (decl_base::get_qualified_name): New declaration. (class_decl::{base_specs, member_types, data_members, member_functions, member_function_templates, member_class_templates}): Make all these containers be vectors, rather than list. This makes these containers (like class_decl::base_specs, class_decl::member_types, etc) be suitable to be used by the core diffing algorithms to diff their content. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Declare these new equality operators. These are to be used by the core diffing algorithms when comparing two vectors of shared pointers of members of class_decls. * src/abg-ir.cc (decl_base::get_qualified_name): Define. (class_decl::class_decl, class_decl::operator==(class_decl&)): Adjust for the containers type change to a vector. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Define these. * include/abg-comparison.h (diff::scope_): Remove (diff::{first_scope_, second_scope_}): New members. (class_decl_diff::class_decl_diff): Pass the new scopes to this constructor. (class_decl_diff::{first_class_decl, second_class_decl}) (report_changes): New declarations. * src/abg-comparison.cc (class_decl_diff::class_decl_diff): Update as per the declaration. (class_decl_diff::{first_class_decl, second_class_decl}): Define as per the declaration. (compute_diff): Initial implementation for this. (report_changes): Define. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-04 15:39:08 +00:00
bool
operator==(class_decl::base_spec_sptr l, class_decl::base_spec_sptr r);
/// Abstract a data member declaration in a class declaration.
class class_decl::data_member : public var_decl, public member_base
{
bool is_laid_out_;
size_t offset_in_bits_;
// Forbidden
data_member();
public:
/// Hasher.
struct hash;
/// Constructor for instances of class_decl::data_member.
///
/// @param data_member the variable to be used as data member.
///
/// @param access the access specifier for the data member.
///
/// @param is_laid_out set to true if the data member has been laid out.
///
/// @param is_static set ot true if the data member is static.
///
/// @param offset_in_bits the offset of the data member, expressed in bits.
data_member(shared_ptr<var_decl> data_member, access_specifier access,
bool is_laid_out, bool is_static, size_t offset_in_bits)
: decl_base(data_member->get_name(),
data_member->get_location(),
data_member->get_mangled_name(),
data_member->get_visibility()),
var_decl(data_member->get_name(),
data_member->get_type(),
data_member->get_location(),
data_member->get_mangled_name(),
data_member->get_visibility(),
data_member->get_binding()),
member_base(access, is_static),
is_laid_out_(is_laid_out),
offset_in_bits_(offset_in_bits)
{}
/// Constructor for instances of class_decl::data_member.
///
/// @param name the name of the data member.
///
/// @param type the type of the data member.
///
/// @param access the access specifier for the data member.
///
/// @param locus the source location of the data member.
///
/// @param mangled_name the mangled name of the data member, or an
/// empty string if not applicable.
///
/// @param vis the visibility of the data member.
///
/// @param bind the binding of the data member.
///
/// @param is_laid_out set to true if the data member has been laid out.
///
/// @param is_static set ot true if the data member is static.
///
/// @param offset_in_bits the offset of the data member, expressed in bits.
data_member(const std::string& name,
shared_ptr<type_base>& type,
access_specifier access,
location locus,
const std::string& mangled_name,
visibility vis,
binding bind,
bool is_laid_out,
bool is_static,
size_t offset_in_bits)
: decl_base(name, locus, mangled_name, vis),
var_decl(name, type, locus, mangled_name, vis, bind),
member_base(access, is_static),
is_laid_out_(is_laid_out),
offset_in_bits_(offset_in_bits)
{}
bool
is_laid_out() const
{return is_laid_out_;}
size_t
get_offset_in_bits() const
{return offset_in_bits_;}
virtual bool
operator==(const decl_base& other) const;
/// This implements the traversable_base::traverse pure virtual
/// function.
///
/// @param v the visitor used on the current instance.
virtual void
traverse(ir_node_visitor&);
virtual ~data_member();
};// end class class_decl::data_member
Un-debugged initial implementation of class diffing. * include/abg-ir.h (decl_base::get_qualified_name): New declaration. (class_decl::{base_specs, member_types, data_members, member_functions, member_function_templates, member_class_templates}): Make all these containers be vectors, rather than list. This makes these containers (like class_decl::base_specs, class_decl::member_types, etc) be suitable to be used by the core diffing algorithms to diff their content. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Declare these new equality operators. These are to be used by the core diffing algorithms when comparing two vectors of shared pointers of members of class_decls. * src/abg-ir.cc (decl_base::get_qualified_name): Define. (class_decl::class_decl, class_decl::operator==(class_decl&)): Adjust for the containers type change to a vector. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Define these. * include/abg-comparison.h (diff::scope_): Remove (diff::{first_scope_, second_scope_}): New members. (class_decl_diff::class_decl_diff): Pass the new scopes to this constructor. (class_decl_diff::{first_class_decl, second_class_decl}) (report_changes): New declarations. * src/abg-comparison.cc (class_decl_diff::class_decl_diff): Update as per the declaration. (class_decl_diff::{first_class_decl, second_class_decl}): Define as per the declaration. (compute_diff): Initial implementation for this. (report_changes): Define. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-04 15:39:08 +00:00
bool
operator==(class_decl::data_member_sptr l, class_decl::data_member_sptr r);
/// Abstraction of the declaration of a method. This is an
/// implementation detail for class_decl::member_function.
class class_decl::method_decl : public function_decl
{
method_decl();
public:
method_decl(const std::string& name,
Support diff/reporting for functions & better diff/report in general * include/abg-ir.h ({decl_base, class_decl, function_decl}::get_pretty_representation): New virtual member to get a pretty string name for decls & types. (class_decl::parameter): Add an index to the parameter type. (class_decl::parameter::parameter): Update the constructor for the change above. (class_decl::parameter::{get_index, set_index}): Accessors for the new index. (class_decl::parameter::operator==): Take in account the index. (function_type::append_parameter): Set the index of the parameter here. * include/abg-fwd.h (get_type_name): New declaration. * src/abg-ir.cc (get_type_name): New definition. ({decl_base, function_decl, class_decl}::get_pretty_representation): New implementations. (method_type::set_class_type): Update this to set function parameter's index by default. (function_decl::append_parameters): Use the append_parameter method from function_type. * include/abg-comparison.h (class function_decl_diff): New type declaration. * src/abg-comparison.cc (compute_diff_for_decls, compute_diff): New definitions. ({pointer_diff, class_diff, scope_diff}::report): Use the new get_pretty_representation. Output a prettier report. (function_decl_diff::priv): New type. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at, ensure_lookup_tables_populated, function_decl_diff, first_function_decl, second_function_decl, changed_parms, removed_parms, added_parms, length, report}): New member function definitions. * src/abg-hash.cc (function_decl::parameter::hash): Update this to take the index in account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
const std::vector<parameter_sptr >& parms,
shared_ptr<type_base> return_type,
shared_ptr<class_decl> class_type,
size_t ftype_size_in_bits,
size_t ftype_align_in_bits,
bool declared_inline,
location locus,
const std::string& mangled_name = "",
visibility vis = VISIBILITY_DEFAULT,
binding bind = BINDING_GLOBAL);
method_decl(const std::string& name, shared_ptr<method_type> type,
bool declared_inline, location locus,
const std::string& mangled_name = "",
visibility vis = VISIBILITY_DEFAULT,
binding bind = BINDING_GLOBAL);
method_decl(const std::string& name,
shared_ptr<function_type> type,
bool declared_inline,
location locus,
const std::string& mangled_name = "",
visibility vis = VISIBILITY_DEFAULT,
binding bind = BINDING_GLOBAL);
method_decl(const std::string& name, shared_ptr<type_base> type,
bool declared_inline, location locus,
const std::string& mangled_name = "",
visibility vis = VISIBILITY_DEFAULT,
binding bind = BINDING_GLOBAL);
/// @return the type of the current instance of the
/// class_decl::method_decl.
const shared_ptr<method_type>
get_type() const;
void
set_type(shared_ptr<method_type> fn_type)
{ function_decl::set_type(fn_type); }
virtual ~method_decl();
};// end class class_decl::method_decl
/// Abstracts a member function declaration in a class declaration.
class class_decl::member_function : public method_decl, public member_base
{
size_t vtable_offset_in_bits_;
bool is_constructor_;
bool is_destructor_;
bool is_const_;
// Forbidden
member_function();
public:
/// Hasher.
struct hash;
member_function(const std::string& name,
Support diff/reporting for functions & better diff/report in general * include/abg-ir.h ({decl_base, class_decl, function_decl}::get_pretty_representation): New virtual member to get a pretty string name for decls & types. (class_decl::parameter): Add an index to the parameter type. (class_decl::parameter::parameter): Update the constructor for the change above. (class_decl::parameter::{get_index, set_index}): Accessors for the new index. (class_decl::parameter::operator==): Take in account the index. (function_type::append_parameter): Set the index of the parameter here. * include/abg-fwd.h (get_type_name): New declaration. * src/abg-ir.cc (get_type_name): New definition. ({decl_base, function_decl, class_decl}::get_pretty_representation): New implementations. (method_type::set_class_type): Update this to set function parameter's index by default. (function_decl::append_parameters): Use the append_parameter method from function_type. * include/abg-comparison.h (class function_decl_diff): New type declaration. * src/abg-comparison.cc (compute_diff_for_decls, compute_diff): New definitions. ({pointer_diff, class_diff, scope_diff}::report): Use the new get_pretty_representation. Output a prettier report. (function_decl_diff::priv): New type. (function_decl_diff::{deleted_parameter_at, inserted_parameter_at, ensure_lookup_tables_populated, function_decl_diff, first_function_decl, second_function_decl, changed_parms, removed_parms, added_parms, length, report}): New member function definitions. * src/abg-hash.cc (function_decl::parameter::hash): Update this to take the index in account. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-19 14:33:40 +00:00
std::vector<parameter_sptr > parms,
shared_ptr<type_base> return_type,
shared_ptr<class_decl> class_type,
size_t ftype_size_in_bits,
size_t ftype_align_in_bits,
access_specifier access,
bool declared_inline,
location locus,
const std::string& mangled_name,
visibility vis,
binding bind,
size_t vtable_offset_in_bits,
bool is_static,
bool is_constructor,
bool is_destructor,
bool is_const)
: decl_base(name, locus, name, vis),
method_decl(name, parms, return_type, class_type,
ftype_size_in_bits, ftype_align_in_bits,
declared_inline, locus,
mangled_name, vis, bind),
member_base(access, is_static),
vtable_offset_in_bits_(vtable_offset_in_bits),
is_constructor_(is_constructor),
is_destructor_(is_destructor),
is_const_(is_const)
{ }
member_function(shared_ptr<method_decl> fn,
access_specifier access,
size_t vtable_offset_in_bits,
bool is_static,
bool is_constructor,
bool is_destructor,
bool is_const)
: decl_base(fn->get_name(), fn->get_location(),
fn->get_mangled_name(), fn->get_visibility()),
method_decl(fn->get_name(),
fn->get_type(),
fn->is_declared_inline(),
fn->get_location(),
fn->get_mangled_name(),
fn->get_visibility(),
fn->get_binding()),
member_base(access, is_static),
vtable_offset_in_bits_(vtable_offset_in_bits),
is_constructor_(is_constructor),
is_destructor_(is_destructor),
is_const_(is_const)
{}
member_function(shared_ptr<function_decl> fn,
access_specifier access,
size_t vtable_offset_in_bits,
bool is_static,
bool is_constructor,
bool is_destructor,
bool is_const);
size_t
get_vtable_offset() const
{return vtable_offset_in_bits_;}
bool
is_constructor() const
{return is_constructor_;}
bool
is_destructor() const
{return is_destructor_;}
bool
is_const() const
{return is_const_;}
virtual bool
operator==(const decl_base&) const;
virtual bool
operator==(const member_base&) const;
bool
operator==(const member_function&) const;
virtual void
traverse(ir_node_visitor& v);
};// class_decl::member_function
Un-debugged initial implementation of class diffing. * include/abg-ir.h (decl_base::get_qualified_name): New declaration. (class_decl::{base_specs, member_types, data_members, member_functions, member_function_templates, member_class_templates}): Make all these containers be vectors, rather than list. This makes these containers (like class_decl::base_specs, class_decl::member_types, etc) be suitable to be used by the core diffing algorithms to diff their content. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Declare these new equality operators. These are to be used by the core diffing algorithms when comparing two vectors of shared pointers of members of class_decls. * src/abg-ir.cc (decl_base::get_qualified_name): Define. (class_decl::class_decl, class_decl::operator==(class_decl&)): Adjust for the containers type change to a vector. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Define these. * include/abg-comparison.h (diff::scope_): Remove (diff::{first_scope_, second_scope_}): New members. (class_decl_diff::class_decl_diff): Pass the new scopes to this constructor. (class_decl_diff::{first_class_decl, second_class_decl}) (report_changes): New declarations. * src/abg-comparison.cc (class_decl_diff::class_decl_diff): Update as per the declaration. (class_decl_diff::{first_class_decl, second_class_decl}): Define as per the declaration. (compute_diff): Initial implementation for this. (report_changes): Define. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-04 15:39:08 +00:00
bool
operator==(class_decl::member_function_sptr l,
class_decl::member_function_sptr r);
/// Abstract a member function template.
class class_decl::member_function_template
: public member_base, public virtual decl_base
{
bool is_constructor_;
bool is_const_;
shared_ptr<function_tdecl> fn_tmpl_;
// Forbiden
member_function_template();
public:
/// Hasher.
struct hash;
member_function_template(function_tdecl_sptr f,
access_specifier access, bool is_static,
bool is_constructor, bool is_const)
: decl_base(f->get_name(), location()),
member_base(access, is_static), is_constructor_(is_constructor),
is_const_(is_const), fn_tmpl_(f)
{}
bool
is_constructor() const
{return is_constructor_;}
bool
is_const() const
{return is_const_;}
operator const function_tdecl& () const
{return *fn_tmpl_;}
function_tdecl_sptr
as_function_tdecl() const
{return fn_tmpl_;}
virtual bool
operator==(const member_base& o) const;
virtual void
traverse(ir_node_visitor&);
};// end class class_decl::member_function_template
Un-debugged initial implementation of class diffing. * include/abg-ir.h (decl_base::get_qualified_name): New declaration. (class_decl::{base_specs, member_types, data_members, member_functions, member_function_templates, member_class_templates}): Make all these containers be vectors, rather than list. This makes these containers (like class_decl::base_specs, class_decl::member_types, etc) be suitable to be used by the core diffing algorithms to diff their content. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Declare these new equality operators. These are to be used by the core diffing algorithms when comparing two vectors of shared pointers of members of class_decls. * src/abg-ir.cc (decl_base::get_qualified_name): Define. (class_decl::class_decl, class_decl::operator==(class_decl&)): Adjust for the containers type change to a vector. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Define these. * include/abg-comparison.h (diff::scope_): Remove (diff::{first_scope_, second_scope_}): New members. (class_decl_diff::class_decl_diff): Pass the new scopes to this constructor. (class_decl_diff::{first_class_decl, second_class_decl}) (report_changes): New declarations. * src/abg-comparison.cc (class_decl_diff::class_decl_diff): Update as per the declaration. (class_decl_diff::{first_class_decl, second_class_decl}): Define as per the declaration. (compute_diff): Initial implementation for this. (report_changes): Define. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-04 15:39:08 +00:00
bool
operator==(class_decl::member_function_template_sptr l,
class_decl::member_function_template_sptr r);
/// Abstracts a member class template template
class class_decl::member_class_template
: public member_base,
public virtual decl_base
{
shared_ptr<class_tdecl> class_tmpl_;
// Forbidden
member_class_template();
public:
/// Hasher.
struct hash;
member_class_template(shared_ptr<class_tdecl> c,
access_specifier access, bool is_static)
: decl_base(c->get_name(), location()),
member_base(access, is_static),
class_tmpl_(c)
{}
operator const class_tdecl& () const
{ return *class_tmpl_; }
shared_ptr<class_tdecl>
as_class_tdecl() const
{return class_tmpl_;}
virtual bool
operator==(const member_base& o) const;
virtual bool
operator==(const member_class_template&) const;
virtual void
traverse(ir_node_visitor& v);
};// end class class_decl::member_class_template
Un-debugged initial implementation of class diffing. * include/abg-ir.h (decl_base::get_qualified_name): New declaration. (class_decl::{base_specs, member_types, data_members, member_functions, member_function_templates, member_class_templates}): Make all these containers be vectors, rather than list. This makes these containers (like class_decl::base_specs, class_decl::member_types, etc) be suitable to be used by the core diffing algorithms to diff their content. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Declare these new equality operators. These are to be used by the core diffing algorithms when comparing two vectors of shared pointers of members of class_decls. * src/abg-ir.cc (decl_base::get_qualified_name): Define. (class_decl::class_decl, class_decl::operator==(class_decl&)): Adjust for the containers type change to a vector. (operator==(class_decl_sptr, class_decl_sptr)) (operator==(class_decl::member_type_sptr, class_decl::member_type_sptr)) (operator==(class_decl::base_spec_sptr, class_decl::base_spec_sptr)) (operator==(class_decl::data_member_sptr, class_decl::data_member_sptr)) (operator==(class_decl::member_function_sptr, class_decl::member_function_sptr)) (operator==(class_decl::member_function_template_sptr, class_decl::member_function_template_sptr)) (operator==(class_decl::member_class_template_sptr, class_decl::member_class_template_sptr)): Define these. * include/abg-comparison.h (diff::scope_): Remove (diff::{first_scope_, second_scope_}): New members. (class_decl_diff::class_decl_diff): Pass the new scopes to this constructor. (class_decl_diff::{first_class_decl, second_class_decl}) (report_changes): New declarations. * src/abg-comparison.cc (class_decl_diff::class_decl_diff): Update as per the declaration. (class_decl_diff::{first_class_decl, second_class_decl}): Define as per the declaration. (compute_diff): Initial implementation for this. (report_changes): Define. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2013-10-04 15:39:08 +00:00
bool
operator==(class_decl::member_class_template_sptr l,
class_decl::member_class_template_sptr r);
// Forward declarations for select nested hashers.
struct type_base::shared_ptr_hash
{
size_t
operator()(const shared_ptr<type_base> t) const;
};
struct type_base::dynamic_hash
{
size_t
operator()(const type_base* t) const;
};
/// A hasher that manages to cache the computed hash and re-use it if
Implement hash caching * include/abg-ir.h (decl_base::hash_): New member. (decl_base::{g,s}et_hash): New accessors. (type_base_::cached_hash): Forward-declare new hasher. (struct type_ptr_equal): New equality predicate. (type_shared_ptr_equal::operator()): Do not forget to test pointer equality. (type_base::cached_hash): Declare new hasher. * src/abg-hash.cc ({decl_base, type_decl, scope_type_decl, qualified_type_def, pointer_type_def, reference_type_def, enum_type_decl, typedef_decl, var_decl, function_decl, function_decl::parameter, class_decl::data_member, class_decl::member_function, class_decl, }::hash::operator()): Implement caching. (type_base::cached_hash::operator()(const type_base*)): Define. (type_base::cached_hash::operator() (const type_base_sptr): Define. * src/abg-ir.cc (type_ptr_map): Make this map use type_base::cached_hash instead of type_base::ptr_hash now. (decl_base::decl_base): Initialize the new decl_base::hash_. member. (decl_base::{s,g}et_hash): Define. (decl_base::operator==(const decl_base& other)): Take the hash in account to speed up inequality detection. * src/abg-writer.cc (type_ptr_map): Renamed type_shared_ptr_map into this. Make it use type_base::cached_hash and type_ptr_equal instead of type_base::shared_ptr_hash and type_shared_ptr_equal. (get_id_for_type): Add overload for type_base*. Re-write the previous overload in terms of this one. (write_context::m_type_id_map): Use type_ptr_map as the type for this. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-01-13 15:02:46 +00:00
/// it is available.
struct type_base::cached_hash
{
size_t
operator() (const type_base* t) const;
size_t
operator() (const type_base_sptr t) const;
};
/// A hashing functor for instances and pointers of @ref var_decl.
struct var_decl::hash
{
size_t
operator()(const var_decl& t) const;
size_t
operator()(const var_decl* t) const;
}; //end struct var_decl::hash
/// A comparison functor for pointers to @ref var_decl.
struct var_decl::ptr_equal
{
/// Return true if the two instances of @ref var_decl are equal.
///
/// @param l the first variable to compare.
///
/// @param r the second variable to compare.
///
/// @return true if @p l equals @p r.
bool
operator()(const var_decl* l, const var_decl* r) const
{
if (l == r)
return true;
if (!!l != !!r)
return false;
return (*l == *r);
}
};// end struct var_decl::ptr_equal
/// A hashing functor fo instances and pointers of @ref function_decl.
struct function_decl::hash
{
size_t
operator()(const function_decl& t) const;
size_t
operator()(const function_decl* t) const;
};//end struct function_decl::hash
/// Equality functor for instances of @ref function_decl
struct function_decl::ptr_equal
{
/// Tests if two pointers to @ref function_decl are equal.
///
/// @param l the first pointer to @ref function_decl to consider in
/// the comparison.
///
/// @param r the second pointer to @ref function_decl to consider in
/// the comparison.
///
/// @return true if the two functions @p l and @p r are equal, false
/// otherwise.
bool
operator()(const function_decl* l, const function_decl* r) const
{
if (l == r)
return true;
if (!!l != !!r)
return false;
return (*l == *r);
}
};// function_decl::ptr_equal
/// The hashing functor for class_decl::base_spec.
struct class_decl::base_spec::hash
{
size_t
operator()(const base_spec& t) const;
};
/// The hashing functor for class_decl::member_base.
struct class_decl::member_base::hash
{
size_t
operator()(const member_base& m) const;
};
/// The hashing functor for class_decl::member_type.
struct class_decl::member_type::hash
{
size_t
operator()(const member_type& t) const ;
};
/// The hashing functor for class_decl::data_member.
struct class_decl::data_member::hash
{
size_t
operator()(const data_member& t) const;
};
/// The hashing functor for class_decl::member_function.
struct class_decl::member_function::hash
{
size_t
operator()(const member_function& t) const;
};
/// The hashing functor for class_decl::member_function_template.
struct class_decl::member_function_template::hash
{
size_t
operator()(const member_function_template& t) const;
};
/// The hashing functor for class_decl::member_class_template
struct class_decl::member_class_template::hash
{
size_t
operator()(const member_class_template& t) const;
};
struct function_tdecl::hash
Initial support for function templates * src/abg-ir.h (function_decl::set_return_type): New inline definition. (class template_decl, struct template_decl_hash, class template_parameter, struct template_parameter_hash, struct dynamic_template_parameter_hash, struct template_parameter_shared_ptr_hash, class template_type_parameter) (struct template_type_parameter_hash, class template_non_type_parameter, struct template_non_type_parameter_hash, class template_template_parameter, struct template_template_parameter_hash, class function_template_decl) (struct function_template_decl_hash, struct fn_tmpl_shared_ptr_hash): New declarations. * src/abg-ir.cc (dynamic_type_hash::operator()): Add hashing for template template, and template type parameters. (template_decl_hash::operator, template_decl::~template_decl) (template_decl::operator==, template_parameter::operator==) (template_parameter_hash::operator()) (dynamic_template_parameter_hash::operator()) (template_type_parameter::operator==) (template_type_parameter::~template_type_parameter) (template_type_parameter_hash::operator()) (template_non_type_parameter::operator==) (template_non_type_parameter::~template_non_type_parameter) (template_non_type_parameter_hash::operator()) (template_template_parameter::operator==) (template_template_parameter::~template_template_parameter) (template_template_parameter_hash::operator()) (function_template_decl::operator==) (function_template_decl_hash::operator()) (fn_tmpl_shared_ptr_hash::operator()) (function_template_decl::~function_template_decl()): New definitions. * src/abg-reader.cc (read_context::get_fn_tmpl_decl) (read_context::key_fn_tmpl_decl): New functions. (read_context::m_fn_tmpl_map): New data member. (read_context::key_type_decl): Renamed read_context::add_type_decl into this. (read_context::push_decl_to_current_scope): Renamed read_context::finish_decl_creation into this. Add an assert. (read_context::push_and_key_type_decl): Renamed read_context::finish_type_decl_creation into this. Adjust to the use of push_decl_to_current_scope and key_type_decl. (build_function_template_decl, build_template_type_parameter) (build_template_non_type_parameter) (build_template_template_parameter, build_template_parameter) (handle_function_template_decl): New functions. (handle_element): Call handle_function_template_decl. (build_function_decl): Take a bool parameter to update depth information in parsing context. Move instantiation of function_decl before parsing its xml sub-nodes. Update the depth info in the parsing context if necessary. Push the newly intantiated decl to scope. And then parse the sub nodes. Do not forget to add the fn parameters and return type using function_decl::add_parameter and function_decl::set_return_type. (build_var_decl, build_type_decl, build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_enum_type_decl, build_typedef_decl, handled_type_decl) (handle_qualified_type_decl, handle_pointer_type_def) (handle_reference_type_def, handle_enum_type_decl) (handle_typedef_decl, handle_var_decl, handle_function_decl) (handle_class_decl): Adjust. (build_class_decl): Take a bool parameter to update depth information in parsing context. Add comment. Wait for the class members to be built, before keying (and thus hashing it) the class. (build_type): Fix logic, and adjust. * src/abg-writer.cc (write_context::type_has_existing_id) (write_context::get_id_for_fn_tmpl, write_template_type_parameter) (write_template_non_type_parameter) (write_template_template_parameter, write_template_parameter) (write_function_template_decl): New functions. (write_context::get_id_for_type): Simplify logic. (write_decl): Support writing function template. * tests/data/test-read-write/test11.xml: New test input. * tests/test-read-write.cc (InoutSpec in_out_specs[]): De-serialize the new test11.xml test, serialize it back and diff output and input. * tests/Makefile.am: Add test11.xml to the distribution.
2013-04-23 09:27:32 +00:00
{
size_t
operator()(const function_tdecl& t) const;
};
Initial support for function templates * src/abg-ir.h (function_decl::set_return_type): New inline definition. (class template_decl, struct template_decl_hash, class template_parameter, struct template_parameter_hash, struct dynamic_template_parameter_hash, struct template_parameter_shared_ptr_hash, class template_type_parameter) (struct template_type_parameter_hash, class template_non_type_parameter, struct template_non_type_parameter_hash, class template_template_parameter, struct template_template_parameter_hash, class function_template_decl) (struct function_template_decl_hash, struct fn_tmpl_shared_ptr_hash): New declarations. * src/abg-ir.cc (dynamic_type_hash::operator()): Add hashing for template template, and template type parameters. (template_decl_hash::operator, template_decl::~template_decl) (template_decl::operator==, template_parameter::operator==) (template_parameter_hash::operator()) (dynamic_template_parameter_hash::operator()) (template_type_parameter::operator==) (template_type_parameter::~template_type_parameter) (template_type_parameter_hash::operator()) (template_non_type_parameter::operator==) (template_non_type_parameter::~template_non_type_parameter) (template_non_type_parameter_hash::operator()) (template_template_parameter::operator==) (template_template_parameter::~template_template_parameter) (template_template_parameter_hash::operator()) (function_template_decl::operator==) (function_template_decl_hash::operator()) (fn_tmpl_shared_ptr_hash::operator()) (function_template_decl::~function_template_decl()): New definitions. * src/abg-reader.cc (read_context::get_fn_tmpl_decl) (read_context::key_fn_tmpl_decl): New functions. (read_context::m_fn_tmpl_map): New data member. (read_context::key_type_decl): Renamed read_context::add_type_decl into this. (read_context::push_decl_to_current_scope): Renamed read_context::finish_decl_creation into this. Add an assert. (read_context::push_and_key_type_decl): Renamed read_context::finish_type_decl_creation into this. Adjust to the use of push_decl_to_current_scope and key_type_decl. (build_function_template_decl, build_template_type_parameter) (build_template_non_type_parameter) (build_template_template_parameter, build_template_parameter) (handle_function_template_decl): New functions. (handle_element): Call handle_function_template_decl. (build_function_decl): Take a bool parameter to update depth information in parsing context. Move instantiation of function_decl before parsing its xml sub-nodes. Update the depth info in the parsing context if necessary. Push the newly intantiated decl to scope. And then parse the sub nodes. Do not forget to add the fn parameters and return type using function_decl::add_parameter and function_decl::set_return_type. (build_var_decl, build_type_decl, build_qualified_type_decl) (build_pointer_type_def, build_reference_type_def) (build_enum_type_decl, build_typedef_decl, handled_type_decl) (handle_qualified_type_decl, handle_pointer_type_def) (handle_reference_type_def, handle_enum_type_decl) (handle_typedef_decl, handle_var_decl, handle_function_decl) (handle_class_decl): Adjust. (build_class_decl): Take a bool parameter to update depth information in parsing context. Add comment. Wait for the class members to be built, before keying (and thus hashing it) the class. (build_type): Fix logic, and adjust. * src/abg-writer.cc (write_context::type_has_existing_id) (write_context::get_id_for_fn_tmpl, write_template_type_parameter) (write_template_non_type_parameter) (write_template_template_parameter, write_template_parameter) (write_function_template_decl): New functions. (write_context::get_id_for_type): Simplify logic. (write_decl): Support writing function template. * tests/data/test-read-write/test11.xml: New test input. * tests/test-read-write.cc (InoutSpec in_out_specs[]): De-serialize the new test11.xml test, serialize it back and diff output and input. * tests/Makefile.am: Add test11.xml to the distribution.
2013-04-23 09:27:32 +00:00
struct function_tdecl::shared_ptr_hash
{
size_t
operator()(const shared_ptr<function_tdecl> f) const;
};
struct class_tdecl::hash
{
size_t
operator()(const class_tdecl& t) const;
};
struct class_tdecl::shared_ptr_hash
{
size_t
operator()(const shared_ptr<class_tdecl> t) const;
};
/// The base class for the visitor type hierarchy used for traversing
/// a translation unit.
///
/// Client code willing to get notified for a certain kind of node
/// during the IR traversal might want to define a visitor class that
/// inherit ir_node_visitor, overload the ir_node_visitor::visit
/// method of its choice, and provide and implementation for it. That
/// new visitor class would then be passed to e.g,
/// translation_unit::traverse or to the traverse method of any type
/// where the traversal is supposed to start from.
struct ir_node_visitor : public node_visitor_base
{
virtual void visit(scope_decl*);
virtual void visit(type_decl*);
virtual void visit(namespace_decl*);
virtual void visit(qualified_type_def*);
virtual void visit(pointer_type_def*);
virtual void visit(reference_type_def*);
virtual void visit(enum_type_decl*);
virtual void visit(typedef_decl*);
virtual void visit(var_decl*);
virtual void visit(function_decl*);
virtual void visit(function_tdecl*);
virtual void visit(class_tdecl*);
virtual void visit(class_decl*);
virtual void visit(class_decl::data_member*);
virtual void visit(class_decl::member_type*);
virtual void visit(class_decl::member_function*);
virtual void visit(class_decl::member_function_template*);
virtual void visit(class_decl::member_class_template*);
};
// Debugging facility
void
fns_to_str(vector<function_decl*>::const_iterator a_begin,
vector<function_decl*>::const_iterator a_end,
vector<function_decl*>::const_iterator b_begin,
vector<function_decl*>::const_iterator b_end,
std::ostream& o);
} // end namespace abigail
#endif // __ABG_IR_H__