This is an archive of the discontinued LLVM Phabricator instance.

Fix a bug in VMRange
ClosedPublic

Authored by lemo on Aug 3 2018, 5:49 PM.

Details

Summary

I noticed a suspicious failure:

[ RUN ] VMRange.CollectionContains
llvm/src/tools/lldb/unittests/Utility/VMRangeTest.cpp:146: Failure
Value of: VMRange::ContainsRange(collection, VMRange(0x100, 0x104))

Actual: false

Expected: true

Looking at the code, it is a very real bug:

class RangeInRangeUnaryPredicate {
public:
  RangeInRangeUnaryPredicate(VMRange range) : _range(range) {} // note that _range binds to a temporary!
  bool operator()(const VMRange &range) const {
    return range.Contains(_range);
  }
  const VMRange &_range;
};

This change fixes the bug.

Diff Detail

Repository
rL LLVM

Event Timeline

lemo created this revision.Aug 3 2018, 5:49 PM
zturner added a subscriber: lemo.Aug 3 2018, 5:57 PM

I think we have llvm::contains() which would allow you to make this
slightly better. Other than that, good find!

Thanks Zach. I can't find llvm::contains() though, any pointers to it?

Looks like i was wrong, nevermind!

This revision was not accepted when it landed; it landed in state Needs Review.Aug 3 2018, 7:16 PM
Closed by commit rL338949: Fix a bug in VMRange (authored by lemo). · Explain Why
This revision was automatically updated to reflect the committed changes.