Fix DWARFUnitSection::getUnitForOffset().
authorFrederic Riss <friss@apple.com>
Thu, 18 Sep 2014 09:38:15 +0000 (09:38 +0000)
committerFrederic Riss <friss@apple.com>
Thu, 18 Sep 2014 09:38:15 +0000 (09:38 +0000)
commit344b66866d9991104bdd675efff7f510817bdb1d
tree4c5add018c10abe416e46af07a4a146af1320c88
parent72f0d9515e304395c2874c8750c69272d424e4ae
Fix DWARFUnitSection::getUnitForOffset().

The current code is only able to return the right unit if the passed offset
is the exact offset of a section. Generalize the search function by comparing
againt the offset of the next unit instead and by switching the search
algorithm to upper_bound.

This way, the unit returned is the first unit with a getNextUnitOffset()
strictly greater than the searched offset, which is exactly what we want.
Note that there is no need for testing the range of the resulting unit as
the offsets of a DWARFUnitSection are in a single contiguous range from
0 inclusive to lastUnit->getNextUnitOffset() exclusive.

Reviewers: dblaikie samsonov

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D5262

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218040 91177308-0d34-0410-b5e6-96231b3b80d8
lib/DebugInfo/DWARFUnit.h