Really detect static-ness of data members. Oops.

* src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir): Let's
	consider that a data member being not laid out (i.e, not having a
	data_member_location) is is a static data member.  Otherwise, we
	were not detecting static data members at all.  Well we were only
	inferring their presence from seeing the static variable
	definition later on.  That means we were missing most of the
	static variables.  Woops.
	* src/abg-comparison.cc
	(corpus_diff::priv::ensure_lookup_tables_populated): Now that we
	are really seeing static data members, let's be prepare to the
	fact that we can the same static data member being declared
	several times in a corpus.
	* tests/data/test-diff-dwarf/test7-report.txt: New test input file.
	* tests/data/test-diff-dwarf/test7-v0.cc: Likewise.
	* tests/data/test-diff-dwarf/test7-v0.o: Likewise.
	* tests/data/test-diff-dwarf/test7-v1.cc: Likewise.
	* tests/data/test-diff-dwarf/test7-v1.o: Likewise.
	* tests/test-diff-dwarf.cc: Update this to consume the new test
	input files.
	* tests/Makefile.am: Update this to add the missing test files to
	the source distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
Dodji Seketeli 2014-04-16 17:14:48 +02:00
parent c545e58b52
commit c4d202099e
9 changed files with 94 additions and 3 deletions

View File

@ -5765,7 +5765,15 @@ corpus_diff::priv::ensure_lookup_tables_populated()
if (n.empty())
n = added_var->get_name();
assert(!n.empty());
assert(added_vars_.find(n) == added_vars_.end());
{
string_var_ptr_map::const_iterator k = added_vars_.find(n);
if ( k != added_vars_.end())
{
assert(is_member_decl(k->second)
&& get_member_is_static(k->second));
continue;
}
}
string_var_ptr_map::const_iterator j =
deleted_vars_.find(n);
if (j != deleted_vars_.end())

View File

@ -2362,7 +2362,12 @@ build_class_type_and_add_to_ir(read_context& ctxt,
var_decl_sptr dm(new var_decl(n, t, loc, m));
result->add_data_member(dm, access, is_laid_out,
/*is_static=*/false,
// For now, is_static ==
// !is_laid_out. When we have
// templates, we'll try to be
// more specific. For now, this
// approximation should do OK.
/*is_static=*/!is_laid_out,
offset_in_bits);
assert(has_scope(dm));
ctxt.die_decl_map()[dwarf_dieoffset(&child)] = dm;

View File

@ -137,6 +137,21 @@ data/test-diff-dwarf/test4-v0.o \
data/test-diff-dwarf/test4-v1.cc \
data/test-diff-dwarf/test4-v1.o \
data/test-diff-dwarf/test4-report.txt \
data/test-diff-dwarf/test5-v0.cc \
data/test-diff-dwarf/test5-v0.o \
data/test-diff-dwarf/test5-v1.cc \
data/test-diff-dwarf/test5-v1.o \
data/test-diff-dwarf/test5-report.txt \
data/test-diff-dwarf/test6-v0.cc \
data/test-diff-dwarf/test6-v0.o \
data/test-diff-dwarf/test6-v1.cc \
data/test-diff-dwarf/test6-v1.o \
data/test-diff-dwarf/test6-report.txt \
data/test-diff-dwarf/test7-v0.cc \
data/test-diff-dwarf/test7-v0.o \
data/test-diff-dwarf/test7-v1.cc \
data/test-diff-dwarf/test7-v1.o \
data/test-diff-dwarf/test7-report.txt \
\
data/test-read-dwarf/test0 \
data/test-read-dwarf/test0.abi \
@ -184,7 +199,27 @@ data/test-diff-filter/test7-v0.cc \
data/test-diff-filter/test7-v1.cc \
data/test-diff-filter/test7-v0.o \
data/test-diff-filter/test7-v1.o \
data/test-diff-filter/test7-report.txt
data/test-diff-filter/test7-report.txt \
data/test-diff-filter/test8-v0.cc \
data/test-diff-filter/test8-v1.cc \
data/test-diff-filter/test8-v0.o \
data/test-diff-filter/test8-v1.o \
data/test-diff-filter/test8-report.txt \
data/test-diff-filter/test9-v0.cc \
data/test-diff-filter/test9-v1.cc \
data/test-diff-filter/test9-v0.o \
data/test-diff-filter/test9-v1.o \
data/test-diff-filter/test9-report.txt \
data/test-diff-filter/test10-v0.cc \
data/test-diff-filter/test10-v1.cc \
data/test-diff-filter/test10-v0.o \
data/test-diff-filter/test10-v1.o \
data/test-diff-filter/test10-report.txt \
data/test-diff-filter/test11-v0.cc \
data/test-diff-filter/test11-v1.cc \
data/test-diff-filter/test11-v0.o \
data/test-diff-filter/test11-v1.o \
data/test-diff-filter/test11-report.txt
clean-local: clean-local-check
.PHONY: clean-local-check

View File

@ -0,0 +1,15 @@
Functions changes summary: 0 Removed, 1 Changed, 0 Added function
Variables changes summary: 0 Removed, 0 Changed, 1 Added variable
1 function with some indirect sub-type change:
[C]'function void foo(const S&)' has some indirect sub-type changes:
parameter 0 of type 'const S&' has sub-type changes:
in unqualified underlying type 'S&':
in referenced type 'struct S':
1 data member insertion:
'static char S::m0'
1 Added variable:
'static char S::m0

View File

@ -0,0 +1,10 @@
struct S
{
static int m1;
};
int S::m1;
void
foo(S&)
{}

Binary file not shown.

View File

@ -0,0 +1,12 @@
struct S
{
static char m0;
static int m1;
};
char S::m0;
int S::m1;
void
foo(S&)
{}

Binary file not shown.

View File

@ -104,6 +104,12 @@ InOutSpec in_out_specs[] =
"data/test-diff-dwarf/test6-report.txt",
"output/test-diff-dwarf/test6-report.txt"
},
{
"data/test-diff-dwarf/test7-v0.o",
"data/test-diff-dwarf/test7-v1.o",
"data/test-diff-dwarf/test7-report.txt",
"output/test-diff-dwarf/test6-report.txt"
},
// This should be the last entry
{NULL, NULL, NULL, NULL}
};