It turns out we allow member function cloning only for functions that
are members of classes, not for functions that are member of unions.
This patch fixes that by turning the method
class_decl::add_member_function into the
class_or_union::add_member_function. Note that there was already an
overload of class_or_union::add_member_function; now, all the member
functions add_member_function are members of the class_or_union type.
The patch then modifies function_decl::clone to make that code avoid
assuming that only member functions of classes can be cloned.
* include/abg-ir.h (class_or_union::add_member_function): Move the
class_decl::add_member_function overload declaration into the
class class_or_union class.
(class class_decl): Make the class class_or_union be a friend of
class_decl.
* src/abg-ir.cc (class_decl::add_member_function): Transform the
definition of this overload into ...
(class_or_union::add_member_function): ... this one. Make sure
that when setting the virtual-ness attributes of the member
function, we are effectively looking at the a function that is a
member of a class.
(function_decl::clone): Do not assert that a member function is
necessarily a member of a class_decl. It can also a member of a
union_decl!. So, rather, assert that the scope of the member
function is of type class_or_union.
* tests/data/test-diff-pkg/tbb-2017-8.
20161128.fc26.x86_64.rpm:
New test input RPM.
* tests/data/test-diff-pkg/tbb-2017-9.
20170118.fc27.x86_64.rpm:
* tests/data/test-diff-pkg/tbb-debuginfo-2017-8.
20161128.fc26.x86_64.rpm:
Likewise.
* tests/data/test-diff-pkg/tbb-debuginfo-2017-9.
20170118.fc27.x86_64.rpm:
Likewise.
* tests/data/test-diff-pkg/tbb-2017-8.
20161128.fc26.x86_64--tbb-2017-9.
20170118.fc27.x86_64.txt:
New reference test output.
* tests/data/Makefile.am: Add the new test input RPMs to the
source distribution.
* tests/test-diff-pkg.cc (in_out_specs): Take the new input tests
above into account.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
bool is_static, bool is_ctor,
bool is_dtor, bool is_const);
+ void
+ add_member_function(method_decl_sptr f,
+ access_specifier a,
+ bool is_virtual,
+ size_t vtable_offset,
+ bool is_static, bool is_ctor,
+ bool is_dtor, bool is_const);
+
const member_functions&
get_member_functions() const;
class_decl_sptr
find_base_class(const string&) const;
- void
- add_member_function(method_decl_sptr f,
- access_specifier a,
- bool is_virtual,
- size_t vtable_offset,
- bool is_static, bool is_ctor,
- bool is_dtor, bool is_const);
-
const member_functions&
get_virtual_mem_fns() const;
equals(const class_decl&, const class_decl&, change_kind*);
friend class method_decl;
+ friend class class_or_union;
};// end class class_decl
bool
get_linkage_name(),
get_visibility(),
get_binding()));
- class_decl* scope = dynamic_cast<class_decl*>(get_scope());
+ class_or_union* scope = is_class_or_union_type(get_scope());
assert(scope);
scope->add_member_function(m, get_member_access_specifier(*this),
get_member_function_is_virtual(*this),
std::sort(mem_fns.begin(), mem_fns.end(), lt);
}
-/// Add a member function to the current instance of class_decl.
+/// Add a member function to the current instance of @ref class_or_union.
///
/// @param f a method_decl to add to the current class. This function
/// should not have been already added to a scope.
///
/// @param access the access specifier for the member function to add.
///
+/// @param is_virtual if this is true then it means the function @p f
+/// is a virtual function. That also means that the current instance
+/// of @ref class_or_union is actually an instance of @ref class_decl.
+///
/// @param vtable_offset the offset of the member function in the
-/// virtual table. If the member function is not virtual, this offset
-/// must be 0 (zero).
+/// virtual table. This parameter is taken into account only if @p
+/// is_virtual is true.
///
/// @param is_static whether the member function is static.
///
///
/// @param is_const whether the member function is const.
void
-class_decl::add_member_function(method_decl_sptr f,
- access_specifier a,
- bool is_virtual,
- size_t vtable_offset,
- bool is_static, bool is_ctor,
- bool is_dtor, bool is_const)
-{
- class_or_union::add_member_function(f, a, is_static, is_ctor,
- is_dtor, is_const);
- set_member_function_vtable_offset(f, vtable_offset);
- set_member_function_is_virtual(f, is_virtual);
-
- if (is_virtual)
- sort_virtual_member_functions(priv_->virtual_mem_fns_);
+class_or_union::add_member_function(method_decl_sptr f,
+ access_specifier a,
+ bool is_virtual,
+ size_t vtable_offset,
+ bool is_static, bool is_ctor,
+ bool is_dtor, bool is_const)
+{
+ add_member_function(f, a, is_static, is_ctor,
+ is_dtor, is_const);
+
+ if (class_decl* klass = is_class_type(this))
+ {
+ set_member_function_is_virtual(f, is_virtual);
+ if (is_virtual)
+ {
+ set_member_function_vtable_offset(f, vtable_offset);
+ sort_virtual_member_functions(klass->priv_->virtual_mem_fns_);
+ }
+ }
}
/// When a virtual member function has seen its virtualness set by
test-diff-pkg/tbb-devel-4.3-3.20141204.fc23.x86_64.rpm \
test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt \
test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt \
+test-diff-pkg/tbb-2017-9.20170118.fc27.x86_64.rpm \
+test-diff-pkg/tbb-2017-8.20161128.fc26.x86_64.rpm \
+test-diff-pkg/tbb-debuginfo-2017-8.20161128.fc26.x86_64.rpm \
+test-diff-pkg/tbb-debuginfo-2017-9.20170118.fc27.x86_64.rpm \
+test-diff-pkg/tbb-2017-8.20161128.fc26.x86_64--tbb-2017-9.20170118.fc27.x86_64.txt \
test-diff-pkg/libICE-debuginfo-1.0.6-1.el6.x86_64.rpm \
test-diff-pkg/libICE-debuginfo-1.0.9-2.el7.x86_64.rpm \
test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm \
// -*- Mode: C++ -*-
//
-// Copyright (C) 2013-2016 Red Hat, Inc.
+// Copyright (C) 2013-2017 Red Hat, Inc.
//
// This file is part of the GNU Application Binary Interface Generic
// Analysis and Instrumentation Library (libabigail). This library is
"data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt",
"output/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt"
},
+ {
+ "data/test-diff-pkg/tbb-2017-8.20161128.fc26.x86_64.rpm",
+ "data/test-diff-pkg/tbb-2017-9.20170118.fc27.x86_64.rpm",
+ "--no-default-suppression",
+ "",
+ "data/test-diff-pkg/tbb-debuginfo-2017-8.20161128.fc26.x86_64.rpm",
+ "data/test-diff-pkg/tbb-debuginfo-2017-9.20170118.fc27.x86_64.rpm",
+ "",
+ "",
+ "data/test-diff-pkg/tbb-2017-8.20161128.fc26.x86_64--tbb-2017-9.20170118.fc27.x86_64.txt",
+ "output/test-diff-pkg/tbb-2017-8.20161128.fc26.x86_64--tbb-2017-9.20170118.fc27.x86_64.txt"
+ },
{
"data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm",
"data/test-diff-pkg/libICE-1.0.9-2.el7.x86_64.rpm",