* symtab.cc (Odr_violation_compare::operator()): Sort by just the
filename.
This commit is contained in:
parent
4d0fd3f682
commit
55382fb77a
|
@ -1,3 +1,8 @@
|
||||||
|
2011-02-04 Jeffrey Yasskin <jyasskin@google.com>
|
||||||
|
|
||||||
|
* symtab.cc (Odr_violation_compare::operator()): Sort by just the
|
||||||
|
filename.
|
||||||
|
|
||||||
2011-02-02 Sriraman Tallam <tmsriram@google.com>
|
2011-02-02 Sriraman Tallam <tmsriram@google.com>
|
||||||
|
|
||||||
* icf.h (is_section_foldable_candidate): Change type of parameter
|
* icf.h (is_section_foldable_candidate): Change type of parameter
|
||||||
|
|
|
@ -3012,11 +3012,12 @@ Symbol_table::print_stats() const
|
||||||
// We check for ODR violations by looking for symbols with the same
|
// We check for ODR violations by looking for symbols with the same
|
||||||
// name for which the debugging information reports that they were
|
// name for which the debugging information reports that they were
|
||||||
// defined in different source locations. When comparing the source
|
// defined in different source locations. When comparing the source
|
||||||
// location, we consider instances with the same base filename and
|
// location, we consider instances with the same base filename to be
|
||||||
// line number to be the same. This is because different object
|
// the same. This is because different object files/shared libraries
|
||||||
// files/shared libraries can include the same header file using
|
// can include the same header file using different paths, and
|
||||||
// different paths, and we don't want to report an ODR violation in
|
// different optimization settings can make the line number appear to
|
||||||
// that case.
|
// be a couple lines off, and we don't want to report an ODR violation
|
||||||
|
// in those cases.
|
||||||
|
|
||||||
// This struct is used to compare line information, as returned by
|
// This struct is used to compare line information, as returned by
|
||||||
// Dwarf_line_info::one_addr2line. It implements a < comparison
|
// Dwarf_line_info::one_addr2line. It implements a < comparison
|
||||||
|
@ -3027,13 +3028,28 @@ struct Odr_violation_compare
|
||||||
bool
|
bool
|
||||||
operator()(const std::string& s1, const std::string& s2) const
|
operator()(const std::string& s1, const std::string& s2) const
|
||||||
{
|
{
|
||||||
std::string::size_type pos1 = s1.rfind('/');
|
// Inputs should be of the form "dirname/filename:linenum" where
|
||||||
std::string::size_type pos2 = s2.rfind('/');
|
// "dirname/" is optional. We want to compare just the filename.
|
||||||
if (pos1 == std::string::npos
|
|
||||||
|| pos2 == std::string::npos)
|
// Find the last '/' and ':' in each string.
|
||||||
return s1 < s2;
|
std::string::size_type s1begin = s1.rfind('/');
|
||||||
return s1.compare(pos1, std::string::npos,
|
std::string::size_type s2begin = s2.rfind('/');
|
||||||
s2, pos2, std::string::npos) < 0;
|
std::string::size_type s1end = s1.rfind(':');
|
||||||
|
std::string::size_type s2end = s2.rfind(':');
|
||||||
|
// If there was no '/' in a string, start at the beginning.
|
||||||
|
if (s1begin == std::string::npos)
|
||||||
|
s1begin = 0;
|
||||||
|
if (s2begin == std::string::npos)
|
||||||
|
s2begin = 0;
|
||||||
|
// If the ':' appeared in the directory name, compare to the end
|
||||||
|
// of the string.
|
||||||
|
if (s1end < s1begin)
|
||||||
|
s1end = s1.size();
|
||||||
|
if (s2end < s2begin)
|
||||||
|
s2end = s2.size();
|
||||||
|
// Compare takes lengths, not end indices.
|
||||||
|
return s1.compare(s1begin, s1end - s1begin,
|
||||||
|
s2, s2begin, s2end - s2begin) < 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue