[llvm] r328655 - [DWARF] Simplify DWARFAddressRange::contains
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 27 12:05:02 PDT 2018
Author: maskray
Date: Tue Mar 27 12:05:02 2018
New Revision: 328655
URL: http://llvm.org/viewvc/llvm-project?rev=328655&view=rev
Log:
[DWARF] Simplify DWARFAddressRange::contains
This transform is valid because the ranges have been validated (LowPC <= HighPC).
Differential Revision: https://reviews.llvm.org/D44772
Modified:
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAddressRange.h
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAddressRange.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAddressRange.h?rev=328655&r1=328654&r2=328655&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAddressRange.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFAddressRange.h Tue Mar 27 12:05:02 2018
@@ -36,17 +36,17 @@ struct DWARFAddressRange {
/// 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,
More information about the llvm-commits
mailing list