LCOV - code coverage report
Current view: top level - include/llvm/DebugInfo/DWARF - DWARFAddressRange.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 5 5 100.0 %
Date: 2018-02-22 16:16:46 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- DWARFAddressRange.h --------------------------------------*- C++ -*-===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : 
      10             : #ifndef LLVM_DEBUGINFO_DWARF_DWARFADDRESSRANGE_H
      11             : #define LLVM_DEBUGINFO_DWARF_DWARFADDRESSRANGE_H
      12             : 
      13             : #include <cstdint>
      14             : #include <tuple>
      15             : #include <vector>
      16             : 
      17             : namespace llvm {
      18             : 
      19             : class raw_ostream;
      20             : 
      21             : struct DWARFAddressRange {
      22             :   uint64_t LowPC;
      23             :   uint64_t HighPC;
      24             :   uint64_t SectionIndex;
      25             : 
      26             :   DWARFAddressRange() = default;
      27             : 
      28             :   /// Used for unit testing.
      29             :   DWARFAddressRange(uint64_t LowPC, uint64_t HighPC, uint64_t SectionIndex = 0)
      30        1166 :       : LowPC(LowPC), HighPC(HighPC), SectionIndex(SectionIndex) {}
      31             : 
      32             :   /// Returns true if LowPC is smaller or equal to HighPC. This accounts for
      33             :   /// dead-stripped ranges.
      34             :   bool valid() const { return LowPC <= HighPC; }
      35             : 
      36             :   /// Returns true if [LowPC, HighPC) intersects with [RHS.LowPC, RHS.HighPC).
      37             :   bool intersects(const DWARFAddressRange &RHS) const {
      38             :     // Empty ranges can't intersect.
      39         291 :     if (LowPC == HighPC || RHS.LowPC == RHS.HighPC)
      40             :       return false;
      41         284 :     return (LowPC < RHS.HighPC) && (HighPC > RHS.LowPC);
      42             :   }
      43             : 
      44             :   /// Returns true if [LowPC, HighPC) fully contains [RHS.LowPC, RHS.HighPC).
      45             :   bool contains(const DWARFAddressRange &RHS) const {
      46          83 :     if (LowPC <= RHS.LowPC && RHS.LowPC <= HighPC)
      47          75 :       return LowPC <= RHS.HighPC && RHS.HighPC <= HighPC;
      48             :     return false;
      49             :   }
      50             : 
      51             :   void dump(raw_ostream &OS, uint32_t AddressSize) const;
      52             : };
      53             : 
      54             : static inline bool operator<(const DWARFAddressRange &LHS,
      55             :                              const DWARFAddressRange &RHS) {
      56             :   return std::tie(LHS.LowPC, LHS.HighPC) < std::tie(RHS.LowPC, RHS.HighPC);
      57             : }
      58             : 
      59             : raw_ostream &operator<<(raw_ostream &OS, const DWARFAddressRange &R);
      60             : 
      61             : /// DWARFAddressRangesVector - represents a set of absolute address ranges.
      62             : using DWARFAddressRangesVector = std::vector<DWARFAddressRange>;
      63             : 
      64             : } // end namespace llvm
      65             : 
      66             : #endif // LLVM_DEBUGINFO_DWARF_DWARFADDRESSRANGE_H

Generated by: LCOV version 1.13