const DWARFObject *Obj = nullptr) const;
};
-static inline bool operator<(const DWARFAddressRange &LHS,
- const DWARFAddressRange &RHS) {
+inline bool operator<(const DWARFAddressRange &LHS,
+ const DWARFAddressRange &RHS) {
return std::tie(LHS.LowPC, LHS.HighPC) < std::tie(RHS.LowPC, RHS.HighPC);
}
+inline bool operator==(const DWARFAddressRange &LHS,
+ const DWARFAddressRange &RHS) {
+ return std::tie(LHS.LowPC, LHS.HighPC) == std::tie(RHS.LowPC, RHS.HighPC);
+}
+
raw_ostream &operator<<(raw_ostream &OS, const DWARFAddressRange &R);
/// DWARFAddressRangesVector - represents a set of absolute address ranges.
namespace llvm {
+class raw_ostream;
+
/// Represents a single DWARF expression, whose value is location-dependent.
/// Typically used in DW_AT_location attributes to describe the location of
/// objects.
SmallVector<uint8_t, 4> Expr;
};
+inline bool operator==(const DWARFLocationExpression &L,
+ const DWARFLocationExpression &R) {
+ return L.Range == R.Range && L.Expr == R.Expr;
+}
+
+inline bool operator!=(const DWARFLocationExpression &L,
+ const DWARFLocationExpression &R) {
+ return !(L == R);
+}
+
+raw_ostream &operator<<(raw_ostream &OS, const DWARFLocationExpression &Loc);
+
} // end namespace llvm
#endif // LLVM_DEBUGINFO_DWARF_DWARFLOCATIONEXPRESSION_H
DWARFFormValue.cpp
DWARFGdbIndex.cpp
DWARFListTable.cpp
+ DWARFLocationExpression.cpp
DWARFTypeUnit.cpp
DWARFUnitIndex.cpp
DWARFUnit.cpp
--- /dev/null
+//===- DWARFLocationExpression.cpp ----------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/DebugInfo/DWARF/DWARFLocationExpression.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/FormatVariadic.h"
+
+using namespace llvm;
+
+raw_ostream &llvm::operator<<(raw_ostream &OS,
+ const DWARFLocationExpression &Loc) {
+ return OS << Loc.Range << ": "
+ << formatv("{0}", make_range(Loc.Expr.begin(), Loc.Expr.end()));
+}
DWARFDebugInfoTest.cpp
DWARFDebugLineTest.cpp
DWARFFormValueTest.cpp
+ DWARFLocationExpressionTest.cpp
)
target_link_libraries(DebugInfoDWARFTests PRIVATE LLVMTestingSupport)
--- /dev/null
+//===- llvm/unittest/DebugInfo/DWARFLocationExpressionTest.cpp ------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/DebugInfo/DWARF/DWARFLocationExpression.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using object::SectionedAddress;
+
+TEST(DWARFLocationExpression, Equality) {
+ EXPECT_EQ((DWARFLocationExpression{None, {}}),
+ (DWARFLocationExpression{None, {}}));
+ EXPECT_NE((DWARFLocationExpression{DWARFAddressRange{1, 47}, {}}),
+ (DWARFLocationExpression{DWARFAddressRange{1, 48}, {}}));
+ EXPECT_NE((DWARFLocationExpression{DWARFAddressRange{1, 47}, {}}),
+ (DWARFLocationExpression{DWARFAddressRange{1, 47}, {42}}));
+}
+
+TEST(DWARFLocationExpression, StreamingOperator) {
+ EXPECT_EQ("None: 1, 2", to_string(DWARFLocationExpression{None, {1, 2}}));
+ EXPECT_EQ(
+ "[0x0000000000000042, 0x0000000000000047): 1",
+ to_string(DWARFLocationExpression{DWARFAddressRange{0x42, 0x47}, {1}}));
+}