Commit Graph

467 Commits

Author SHA1 Message Date
Dodji Seketeli
ca53b99c5a Use the same representation for member and non-member types
* include/abg-fwd.h (is_at_class_scope): Add new oveloads.
	(as_non_member_type, as_non_member_class_decl): Remove.
	(has_scope, is_member_decl, is_member_type): New function
	declarations.  (get_member_is_static, set_member_is_static):
	Likewise.  * include/abg-ir.h (enum access_specifier): Move to
	the abigail:: namespace, from ...
	(class_decl::access_specifier): ... here.  (class
	context_rel): New type.  (decl_base::hash_as_member): New
	hasher.  (decl_base::context_): Change the type of this to
	context_rel_sptr.  (decl_base::get_context_rel): New protected
	getter.  (decl_base::get_scope): Move this out-of-line.
	(class_decl::member_type): Remove.
	(class_decl::member_types): Adjust this typedef.
	(class_decl::{insert,add}_member_type): Make these take a
	type_base_sptr now.  (class_decl::add_member_type): Change the
	overload that returned a member_type to return a
	type_base_sptr.  (get_member_access_specifier,
	set_member_access_specifier): New function declarations.  *
	include/abg-comparison.h (class member_type_diff): Remove.
	(compute_diff): Remove the overload for member_type_diff.  *
	src/abg-comparison.cc (compute_diff_for_types): Adjust for the
	removal of class_decl::member_type.
	(maybe_report_diff_for_class_members): New static function.
	(report_name_size_and_alignment_changes): Do not report a name
	change just because of a struct -> class change.  ({var_diff,
	enum_diff, function_decl_diff}::report): Use the new
	maybe_report_diff_for_class_members.  (class_diff::report):
	Adjust for the removal of class_decl::member_type.  Use the
	new maybe_report_diff_for_class_members.  (class member_diff):
	Remove.  * src/abg-dwarf-reader.cc (die_access_specifier)
	(get_scope_for_die, build_translation_unit_and_add_to_ir)
	(build_class_type_and_add_to_ir, build_function_decl)
	(build_ir_node_from_die): Adjust.  * abg-hash.cc (struct
	decl_base::hash_as_member): Define.  ({scope_type_decl,
	enum_type_decl, typedef_decl}:#️⃣:operator()): Use the
	decl_base::hash_as_member.
	* src/abg-ir.cc (decl_base::decl_base): Adjust.
	(decl_base::get_scope): New out-of-line getter.
	(decl_base::{operator==, set_scope): Adjust.
	(has_scope, is_member_decl, is_member_type)
	(get_member_access_specifier, set_member_access_specifier)
	(get_member_is_static, set_member_is_static, is_at_class_scope):
	New function definitions.
	(as_non_member_type, as_non_member_class_decl): Remove.
	(get_node_name): Adjust.
	(class_decl::{class_decl, set_earlier_declaration,
	insert_member_decl, insert_member_type, add_member_type):
	Likewise.
	(class_decl::member_type::*) Remove.
	* src/abg-reader.cc (read_access, build_qualified_type_decl)
	(build_reference_type_def, build_typedef_decl)
	(build_class_decl): Adjust.
	* src/abg-writer.cc (write_access, write_member_type)
	(write_class_decl): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-13 11:13:54 +01:00
Dodji Seketeli
a58f60c08f Avoid more static_casts in the (comparison) code
* src/abg-ir.cc (class_decl::insert_member_type, operator==):
	Remove static_casts.
	(class_decl::member_type::operator==): Likewise.
	(class_decl::member_class_template::operator==): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-12 16:42:18 +01:00
Dodji Seketeli
df7c672219 Allow adding members to decl-only classes making them defined classes
* include/abg-fwd.h (lookup_type_in_scope)
	(lookup_var_decl_in_scope): New declarations.
	* include/abg-ir.h (class_decl::get_is_declaration_only): Rename
	is_declaration_only on this.
	(class_decl::set_is_declaration_only):
	* src/abg-comparison.cc (try_to_diff<class_decl>)
	(class_diff::ensure_lookup_tables_populated)
	(scope_diff::ensure_lookup_tables_populated): Update for the
	get_is_declaration_only renaming.
	* src/abg-dwarf-reader.cc (get_scope_for_die): Likewize.
	(build_class_type_and_add_to_ir): Make sure that a member type or
	data member is not already present in the class before adding it.
	Also, if a decl-only class gets a data member, it's not a
	decl-only class anymore.
	* src/abg-hash.cc (class_decl:#️⃣:operator()): Update for the
	get_is_declaration_only renaming.
	* src/abg-ir.cc (scope_decl::find_iterator_for_member)
	(look_through_decl_only_class): Likewise.
	(lookup_type_in_scope, lookup_var_decl_in_scope, get_node_name)
	(convert_node_to_decl, lookup_node_in_scope)
	(lookup_type_in_scope): New definitions.
	(class_decl::{set_definition_of_declaration,
	set_earlier_declaration, operator==}): Update for the
	get_is_declaration_only renaming.
	* src/abg-reader.cc (build_class_decl): Likewise.
	* src/abg-writer.cc (write_class_is_declaration_only): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-12 16:26:14 +01:00
Jonathan Wakely
9fcd72ca39 Fixed typos in abg-diff-utils.h
* include/abg-diff-utils.h (compute_diff): Fix typos in the API
	doc.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-12 14:52:41 +01:00
Dodji Seketeli
35d83f61eb Initialize a variable
* tools/bilint.cc (main): Initialize the 'r' variable.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-11 13:59:01 +01:00
Dodji Seketeli
42aaa3124e Do not declare classes before defining them anymore
* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir): Do not
	declare classes before defining them because both the declaration
	and the definition now compare equal.
	* tests/data/test-read-dwarf/test1.abi: Update test.
	* tests/data/test-read-write/test20.xml: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-11 13:55:35 +01:00
Dodji Seketeli
b78e3371e5 Little style fix
* src/abg-comparison.cc (class_diff::report): Slight style fix.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-11 09:08:47 +01:00
Dodji Seketeli
6667c21fe4 Better support for decl-only classes in diffing and comparison
* include/abg-fwd.h (look_through_decl_only_class): New function
	declaration.
	* src/abg-comparison.cc (class_diff::length): Just compare the two
	classes.
	(compute_diff): Look through the two classes if they are
	decl-only, and use their declaration for the diffing.
	* src/abg-ir.cc (look_through_decl_only_class): Define this new
	entry point.
	(class_decl::set_definition_of_declaration): Allow setting a
	definition that is itself a declaration-only.
	* src/abg-writer.cc (write_class_decl): Declaration-only can now
	have members, namely member types.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-10 23:29:10 +01:00
Dodji Seketeli
6021659d3b Fix comparison wrt hash number
* src/abg-ir.cc (decl_base::operator==): Do not consider empty
	hashes.
	(class_decl::operator==): Better support for comparing decl-only
	classes against non-decl-only classes.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-10 23:15:54 +01:00
Dodji Seketeli
372cd79430 Better support of class DIEs with DW_AT_specification
* src/abg-dwarf-reader.cc (get_scope_for_die): The definition of a
	declaration-only class can be NULL.  Do not look through in that
	case.
	(build_class_type_and_add_to_ir): Support adding class members to
	an existing class.
	(build_ir_node_from_die): If a class DIE has a DW_AT_specification,
	get the specification DIE, get its matching IR node and add the
	current members of the current DIE to that IR node.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-10 22:41:05 +01:00
Dodji Seketeli
1c6f62bad7 Tell struct and class apart
* include/abg-ir.h (class_decl::is_struct_): New member.
	(class_decl::class_decl): Take an additional is_struct member.
	(class_decl::is_struct): New getter.
	* src/abg-ir.cc (class_decl::class_decl): Initialize the new
	is_struct_ data member.
	(class_decl::get_pretty_representation): Tell struct and class
	apart.
	* abg-reader.cc (read_is_struct): New static function.
	(build_class_decl): Capture the struct-ness of the class.
	* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir):
	Likewise.
	* src/abg-writer.cc (write_is_struct): New static function.
	(write_class_decl): Write the struct-ness of the class.
	* tests/data/test-read-dwarf/test1.abi: Update test.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-10 10:04:34 +01:00
Dodji Seketeli
10ba4d6e7d Fix typedef_diff emptyness detection
* src/abg-comparison.cc (typedef_diff::length): Do not mask away the
	dynamic type of the typedef_decl before the comparison.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-03-06 09:29:11 +01:00
Dodji Seketeli
bac732ff5a Add --drop/--keep options to bidiff
* include/abg-sptr-utils.h: New file.
	* include/Makefile.am: Add abg-sptr-utils. to the build system.
	* include/abg-libxml-utils.h (reader_sptr, xml_char_sptr): Remove
	these typedefs as there are now in abg-sptr-utils.
	(build_sptr): Likewise for this template and its specializations
	declarations.
	* src/abg-libxml-utils.cc (sptr_utils::build_sptr): Mode the
	definition of the specializations for xmlTextReader and xmlChar
	into the sptr_utils namespace.
	* include/abg-corpus.h
	(corpus::{get_regex_patterns_of_fns_to_suppress,
	get_regex_patterns_of_vars_to_suppress,
	get_regex_patterns_of_fns_to_keep,
	get_regex_patterns_of_vars_to_keep}): Declare new member
	functions.
	* src/abg-comparison.cc (sptr_utils::regex_t_deleter): Define new
	functor.
	(build_sptr) Define new specialization for regex_t.
	(struct array_deleter): Remove unused functor.
	(corpus::priv::regex_patterns_{fns,vars}_to_{suppress,keep}): New data
	members.
	(symtab_build_visitor_type::regex_patterns_{fns,vars}_to_{suppress,keep}):
	Likewise.
	(symtab_build_visitor_type::r_{fns,vars}_{suppress,keep})):
	Likewise.
	(symtab_build_visitor_type::symtab_build_visitor_type): Update the
	signature of this constructor to take regex patterns for functions
	and variables to suppress and to keep.  Also, initialize the data
	members from these new parameters.
	(symtab_build_visitor_type::regex_{fns,vars}_{suppress,keep}): New
	member functions.
	(symtab_build_visitor_type::{add_fn_to_wip_fns,
	add_var_to_wip_vars}): Likewise.
	(symtab_build_visitor_type::visit) Use either add_fn_to_wip_fns or
	add_var_to_wip_vars depending on the overload of the visit()
	member.
	(corpus::priv::build_symbol_table): Update for the change of the
	symtab_build_visitor_type constructor signature.
	(corpus::get_regex_patterns_of_{fns,vars}_to_{suppress,keep}):
	Define new member functions.
	* tools/bidiff.cc (options::{drop,keep}_{fn,var}_regex_patterns}):
	New data member.
	(display_usage): Add help strings for --drop, --drop-fn,
	--drop-var, --keep, --keep-fn, --keep-var
	(parse_command_line): Parse the command lines above.
	(set_corpus_keep_drop_regex_patterns): Define new static function.
	(main): Use the new set_corpus_keep_drop_regex_patterns.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 17:59:39 +01:00
Dodji Seketeli
8058f9da70 Style fix in the dwarf reader
* src/abg-dwarf-reader.cc (die_is_public_decl): Rename
	is_public_decl into this.
	(die_is_declaration_only): Rename is_declaration_only into this.
	(build_class_type_and_add_to_ir, build_var_decl)
	(build_function_decl): Adjust for the renames above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 17:59:39 +01:00
Dodji Seketeli
5ff3176ad1 Skip artificial (member) functions from DWARF
* src/abg-dwarf-reader.cc (die_is_artificial): New static
	function.
	(build_class_type_and_add_to_ir, build_ir_node_from_die): Use the
	die_is_artificial function to test if the function DIE is
	artificial and then skip it.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 17:59:39 +01:00
Dodji Seketeli
6c34ffd67e Fix function parameter addition/deletion/change detection
* include/abg-ir.h (function_decl::parameter::get_name_id):
	Declare new entry point.
	* src/abg-comparison.cc
	(function_decl_diff::ensure_lookup_tables_populated): Use the new
	function_decl::parameter::get_name_id() for the unique name of the
	parameter.  Also, fix a little logic error: if a parm is deleted
	and inserted, in all cases, consider it as not deleted.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 15:00:34 +01:00
Dodji Seketeli
fde5a31a2a Add a --stat option to bidiff
* include/abg-comparison.h (diff_context::show_stats_only):
	Declare new accessors.
	* src/abg-comparison.cc
	(diff_context::priv::show_stats_only_): New member.
	(diff_context::show_stats_only): Define new accessors.
	(corpus_diff::report): If showing stats only, quit right after
	showing the summary.
	* tools/bidiff.cc (options::show_stats_only): New data member.
	(options::options): Initialize the new data member.
	(display_usage): Add help string for --stat.
	(parse_command_line): Parse the --stat option.
	(set_diff_context_from_opts): Update to set the show_stats_only
	onto the context.  Cleanup the logic to make it more compact.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 13:03:53 +01:00
Dodji Seketeli
d24c3d6341 Report about functions of different names
* src/abg-comparison.cc (function_decl_diff::report): Consider the
	case of functions with different names.  This doesn't happen in
	the current pipeline b/c they just show up as deleted/added
	functions so the function reporter doesn't see them as they have
	been already reported by now.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 12:40:38 +01:00
Dodji Seketeli
5da389b486 Fix length calculation for type diffs.
* src/abg-comparison.cc (diff_length_of_type_bases): Fix stupid
	harmful thinko here.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 12:37:51 +01:00
Dodji Seketeli
d5f37ea7f4 Fix calculation of the length of distinct_diff
* src/abg-comparison.cc (distinct_diff::length): Also perform a
	deep comparison here.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 12:35:36 +01:00
Dodji Seketeli
6407c66fc6 Fix diff length calculation for typedef diffs
* src/abg-comparison.cc (typedef_diff::length): Just use
	comparison for this.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 12:11:41 +01:00
Dodji Seketeli
241166a601 Fix layout of diff summary
* src/abg-comparison.cc
	(corpus_diff::priv::emit_corpus_diff_stats): Remove useless
	vertical and horizontal white spaces.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 12:08:01 +01:00
Dodji Seketeli
0aec4376d8 Fix indentation of pieces of class diff report
* src/abg-comparison.cc (represent, class_diff::report): Fix
	indentation.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 12:03:57 +01:00
Dodji Seketeli
0f397606a1 Fix detection of entities of different kinds for diff purposes
* src/abg-comparison.cc
	(distinct_diff::entities_are_of_distinct_kinds): Consider two NULL
	decls are distinct types for the purpose of diffing.  This is just
	a shortcut to avoid creating a null_diff type for now.  But then,
	stop considering same pointers as different.  This was a bug.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 11:38:34 +01:00
Dodji Seketeli
5f7ce682e2 Constify function_decl::parameter::get_type_pretty_representation()
* include/abg-ir.h
	(function_decl::parameter::get_type_pretty_representation): This
	is now const.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 10:42:46 +01:00
Dodji Seketeli
fb2de7bb71 Improve API doc for the location machinery
* include/abg-ir.h (class location): Improve doc.
	(decl_base::{get,set}_location): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-28 10:26:00 +01:00
Dodji Seketeli
26fcf60d2c Remove useless dynamic cast
* src/abg-ir.cc (class_decl::insert_member_decl): Remove useless
	dynamic cast from here.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-26 12:40:59 +01:00
Dodji Seketeli
a97dd610f6 Insert reference, pointers and qual types at their declaration point
* src/abg-dwarf-reader.cc (build_ir_node_from_die): Insert
	reference, pointers and qualified types at the point where we see
	them, in their scope, rather than under the scope of their
	underlying type.  This is because their might be first declared as
	member types and we don't want to loose that information.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-26 12:40:59 +01:00
Dodji Seketeli
e3113a2ea2 Fix documentation for the diff_utils namespace
* include/abg-diff-utils.h (namespace diff_utils): Add comment.
	(compute_diff): Update comments for some overloads where they were
	missing.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-24 22:47:14 +01:00
Dodji Seketeli
85d2af2708 Misc style fixes
* src/abg-comparison.cc
	(class_diff::ensure_lookup_tables_populated): use
	as_non_member_class_decl rather that complicated casting.
	src/abg-ir.cc (var_decl::get_pretty_representation): Use
	get_type_declaration rather than casting.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-21 17:02:13 +01:00
Dodji Seketeli
e36b46d8e1 Fix a glitch in member data diff reporting
* src/abg-comparison.cc (represent): Do not forget the "'" around
	the access specifier.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-21 17:02:13 +01:00
Dodji Seketeli
9ed0572f16 Proper support for diffing member types
* include/abg-comparison.h (class member_type_diff): New class.
	(member_type_diff_sptr): New convenience typedef.
	(compute_diff): New overload for member_type_diff.
	* src/abg-comparison.cc (struct member_type_diff::priv): New
	definition.
	(member_type_diff::{first_member_type, second_member_type,
	underlying_type_diff, length}): New member function definitions.
	(compute_diff): New definition for member type diffs.
	(compute_diff_for_types): Support diffing
	member types.
	(class_diff::report): Do not use strip member types now that we
	can properly diff them.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-21 17:02:13 +01:00
Dodji Seketeli
aa7ac96d62 Fix the support for printing cv-qualified names
* include/abg-ir.h (decl_base::{location_, name_,
	qualified_parent_name_, qualified_name_}): Make these data members
	protected rather than private.
	(decl_base::get_qualified_parent_name): Declare new member
	functions.
	(decl_base::get_qualified_name): Make the core overload virtual.
	Simplify the other overload that calls the core one.
	(qualified_type_def::build_name): Declare new protected helper
	function.
	(qualified_type_def::{get_cv_quals_string_prefix,
	get_qualified_name}): Declare new functions.
	(pointer_type_def::{get_qualified_name}}): Likewise.
	(class_decl::member_type::get_qualified_name): Likewise.
	* src/abg-ir.cc (decl_base::get_qualified_parent_name): New
	definition.
	(decl_base::get_name): Make this out-of-line.
	(decl_base::get_qualified_name): The signature of this got
	simplified.  Make it use the new get_qualified_parent_name.
	(qualified_type_def::{build_name, get_qualified_name,
	get_cv_quals_string_prefix}): New definitions.
	(qualified_type_def::qualified_type_def): Update the constructor
	to use the new build_name function above.
	(pointer_type_def::get_qualified_name): New definitions.
	(reference_type_def::get_qualified_name): Likewise.
	(class_decl::member_type::get_qualified_name): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-21 17:02:13 +01:00
Dodji Seketeli
e908cad5fa Misc style fix
* src/abg-comparison.cc (represent): Remove useless curly braces
	and vertical spaces.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-21 17:02:13 +01:00
Dodji Seketeli
df6df3d813 Support DW_AT_specification on class/struct DIEs
* src/abg-dwarf-reader.cc (build_ir_node_from_die): Support
	DW_AT_specification on DW_TAG_{class,structure}type.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-21 17:02:13 +01:00
Dodji Seketeli
fa3815a9e6 Avoid comparing member types and class templates
* src/abg-comparison.h (compute_diff): For class_decl_sptr, do not
	compare member types and member class templates.  This adds a lots
	of noise that is not necessarily useful for now.
	* tests/data/test-bidiff/test-qual-type0-report.txt: Update tests.
	* 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>
2014-02-21 17:02:13 +01:00
Dodji Seketeli
4e82113199 Fix the report of added/removed function parameters
* src/abg-comparison.cc
	(function_decl_diff::priv::{inserted_parms_, removed_parms_}):
	Remove these.
	(function_decl_diff::ensure_lookup_tables_populated): Fix thinko.
	Avoid using the members removed above.  Use one less loop to
	update the changed params.
	(function_decl_diff::report): Avoid using the removed_parms_
	data member that was removed above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-21 17:02:13 +01:00
Dodji Seketeli
56973d0ac3 Put the setter of access specifiers in class_decl::member_base
* include/abg-ir.h
	(class_decl::member_base::set_access_specifier): Put the setter
	for access specifier here, where it belongs ...
	(class_decl::member_type::set_access_specifier): ... not here.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-21 17:02:13 +01:00
Dodji Seketeli
505fa1c008 First approach to avoid duplication of IR nodes for forward-declared classes
* src/abg-dwarf-reader.cc (is_declaration_only): Put this back (I
	removed it earlier).
	(build_class_type_and_add_to_ir): If the class is a
	declaration-only (a forward declaration), do not add a new
	declaration only IR node.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-21 15:05:46 +01:00
Dodji Seketeli
bce6bba514 Do not forget to set the indexes of fn parms
* include/abg-ir.h (function_type::function_type): In the
	constructor that takes a vector of parms, walk the vector and set
	the indexes of the parms.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-21 14:22:18 +01:00
Dodji Seketeli
fcdd6d0e66 Misc diff reporting output cleanup
* src/abg-comparison.cc (function_decl_diff::report): Do not talk
	about changed function anymore.  Rather, say that some indirect
	sub-types changed in the function.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-19 22:44:50 +01:00
Dodji Seketeli
fe698b14bb Do not forget some member types/functions we built IR nodes for
* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir):
	Associate the member type IR node to the offset of the die of the
	member type.
	(build_ir_node_from_die): For a DW_TAG_subprogram DIE that has a
	DW_AT_specification pointing to another subprogram DIE, associate
	the offset of this DIE to the IR node of that other DIE.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-19 22:44:50 +01:00
Dodji Seketeli
82e83d9c5e Better support of static member variables
* include/abg-fwd.h (fqn_to_components)
	(lookup_type_in_translation_unit, demangle_cplus_mangled_name):
	Declare new public entry points
	* src/abg-comparison.cc (corpus_diff::report): Report stuff about
	global variables using their mangled name, and demangle them.  If
	there is no mangled name for the variable, then use its pretty
	representation.
	(compute_diff): For the corpus overload, compare global variables
	using their mangled name, if its available; otherwise, fall back
	to using their pretty representation.
	* src/abg-corpus.cc (var_comp::operator()(const var_decl*,
	const_var_decl*)): Compare variables using their mangled name in
	priority.  If it's not available then use their pretty
	representation.
	* src/abg-dwarf-reader.cc
	(read_context::var_decls_to_re_add_to_tree): New accessor.
	(build_translation_unit_and_add_to_ir): If there is what appears
	to be a definition of a static member variable variable -- this is
	in case this definition lacks the DW_AT_specification attribute
	that links it to the DW_TAG_member or DW_TAG_variable DIE that is
	a child of the right class/structure DIE -- that is not at the
	right place in the DIE tree, remove it from the its current place
	in the tree and try to hang it off of the right DIE.  To do this,
	de-mangle its mangled name, look at what is supposed to be the
	parent class name, look it up in the translation unit IR, and if
	found, stick the variable IR node in there, as a static member
	variable.  If not found, then bad luck.
	(build_class_type_and_add_to_ir): Do not try to see if a member
	variable is static here as the way I was doing it was unreliable.
	Build the data member node directly w/o going through building a
	variable node first.  Register the data member in the die offset
	-> IR node map.
	(build_ir_node_from_die): When seeing DW_TAG_variable, look for a
	DW_AT_specification attribute.  If there is one, then it points to
	a the DIE of a data member and means that data member is static.
	Flag the IR node of that data member as static thus.  Update the
	die offset -> IR node map.  If there is no DW_AT_specification
	attribute or if it doesn't point to a data member DIE, schedule
	this variable tag for a stage when after the whole IR is built for
	the translation unit, the variable's mangled named is inspected,
	its hypothetical parent struct/class is looked up and the variable
	IR node is put into the node of the right struct/class IR node.
	* src/abg-ir.cc (enum lookup_entity_kind): New.
	(fqn_to_components, iterator, lookup_type_in_translation_unit)
	(lookup_node_in_translation_unit, lookup_type_in_translation_unit)
	(demangle_cplus_mangled_name): New function definitions.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-19 22:44:50 +01:00
Dodji Seketeli
a5e9c127ce Shorten an accessor name in the DWARF reader
* src/abg-dwarf-reader.cc (read_context::cur_tu): Rename
	read_context::current_translation_unit into this.
	(read_context::current_scope, die_location)
	(build_translation_unit_and_add_to_ir, build_enum_type)
	(build_function_decl): Adjust wrt the change above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-19 22:44:50 +01:00
Dodji Seketeli
1046ba96e6 Unset decl scope when removing the decl from its scope
* src/abg-ir.cc (remove_decl_from_scope): Unset the scope of the
	decl.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-19 22:44:49 +01:00
Dodji Seketeli
5b3a552d8f Support adding data member from var_decl
* src/abg-ir.cc (class_decl::insert_member_decl):  Support taking
	a var_decl.
	(class_decl::add_data_member): Do not insert a data member twice.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-19 16:35:06 +01:00
Dodji Seketeli
a16566b93e Fix qualified type pretty printing
* src/abg-ir.cc (qualified_type_def::qualified_type_def): Remove
	useless white space.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-19 16:29:29 +01:00
Dodji Seketeli
278520086e Add class_decl::member_base::set_is_static() accessor
* include/abg-ir.h (class_decl::member_base::get_is_static):
	Rename is_static into get_is_static.
	(class_decl::member_base::set_is_static): New accessor.
	* src/abg-comparison.cc (represent): Adjust for
	class_decl::member_base::is_static -> get_is_static.
	* src/abg-corpus.cc (symtab_build_visitor_type::visit): Likewise.
	src/abg-hash.cc (class_decl::member_function:#️⃣:operator()):
	Likewise.
	* src/abg-ir.cc (class_decl::member_base::operator==): Likewise.
	* src/abg-writer.cc (write_class_decl): Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-19 16:04:45 +01:00
Dodji Seketeli
6cece6803b Fixes needed to diff libstdc++ v4_4 against master
* src/abg-comparison.cc
	(class_diff::ensure_lookup_tables_populated): Support several
	instances of the same member function being deleted.  That can
	happen when the same member function was present in the initial
	class several times.  Yeah, I've seen that in dwarf.
	* src/abg-corpus.cc (corpus::priv::build_symbol_table): Do not add
	the same variable (identified by its mangled name) twice in the
	variable symbol table.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-13 12:05:03 +01:00
Dodji Seketeli
7f59e159f2 Fix wrong deleted functions count when diffing corpora
* src/abg-comparison.cc
	(corpus_diff::priv::ensure_lookup_tables_populated): If a function
	has changed, deleted it from the list the removed functions.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2014-02-13 11:11:56 +01:00