[PATCH] D44772: [DWARF] Simplify DWARFAddressRange::contains
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 27 12:06:59 PDT 2018
MaskRay updated this revision to Diff 139970.
MaskRay added a comment.
Add validity 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,17 @@
/// Returns true if [LowPC, HighPC) intersects with [RHS.LowPC, RHS.HighPC).
bool intersects(const DWARFAddressRange &RHS) const {
+ assert(valid() && RHS.valid());
// Empty ranges can't intersect.
if (LowPC == HighPC || RHS.LowPC == RHS.HighPC)
return false;
- return (LowPC < RHS.HighPC) && (HighPC > RHS.LowPC);
+ 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.139970.patch
Type: text/x-patch
Size: 1073 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180327/0e7a1223/attachment.bin>
More information about the llvm-commits
mailing list