[PATCH] D44772: [DWARF] Simplify DWARFAddressRange::{intersects, contains}.
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 22 11:09:02 PDT 2018
MaskRay updated this revision to Diff 139478.
MaskRay added a comment.
Add assert().
Repository:
rL LLVM
https://reviews.llvm.org/D44772
Files:
include/llvm/DebugInfo/DWARF/DWARFAddressRange.h
Index: include/llvm/DebugInfo/DWARF/DWARFAddressRange.h
===================================================================
--- include/llvm/DebugInfo/DWARF/DWARFAddressRange.h
+++ include/llvm/DebugInfo/DWARF/DWARFAddressRange.h
@@ -36,17 +36,14 @@
/// Returns true if [LowPC, HighPC) intersects with [RHS.LowPC, RHS.HighPC).
bool intersects(const DWARFAddressRange &RHS) const {
- // Empty ranges can't intersect.
- if (LowPC == HighPC || RHS.LowPC == RHS.HighPC)
- return false;
- return (LowPC < RHS.HighPC) && (HighPC > RHS.LowPC);
+ assert(valid() && RHS.valid());
+ return LowPC < RHS.HighPC && RHS.LowPC < HighPC;
}
/// Returns true if [LowPC, HighPC) fully contains [RHS.LowPC, RHS.HighPC).
bool contains(const DWARFAddressRange &RHS) const {
- if (LowPC <= RHS.LowPC && RHS.LowPC <= HighPC)
- return LowPC <= RHS.HighPC && RHS.HighPC <= HighPC;
- return false;
+ assert(valid() && RHS.valid());
+ return LowPC <= RHS.LowPC && RHS.HighPC <= HighPC;
}
void dump(raw_ostream &OS, uint32_t AddressSize,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44772.139478.patch
Type: text/x-patch
Size: 1073 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180322/4e5a7ace/attachment.bin>
More information about the llvm-commits
mailing list