1 //===- DWARFLocationExpression.h --------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_DEBUGINFO_DWARF_DWARFLOCATIONEXPRESSION_H 10 #define LLVM_DEBUGINFO_DWARF_DWARFLOCATIONEXPRESSION_H 11 12 #include "llvm/DebugInfo/DWARF/DWARFAddressRange.h" 13 14 namespace llvm { 15 16 class raw_ostream; 17 18 /// Represents a single DWARF expression, whose value is location-dependent. 19 /// Typically used in DW_AT_location attributes to describe the location of 20 /// objects. 21 struct DWARFLocationExpression { 22 /// The address range in which this expression is valid. std::nullopt denotes a 23 /// default entry which is valid in addresses not covered by other location 24 /// expressions, or everywhere if there are no other expressions. 25 std::optional<DWARFAddressRange> Range; 26 27 /// The expression itself. 28 SmallVector<uint8_t, 4> Expr; 29 }; 30 31 inline bool operator==(const DWARFLocationExpression &L, 32 const DWARFLocationExpression &R) { 33 return L.Range == R.Range && L.Expr == R.Expr; 34 } 35 36 inline bool operator!=(const DWARFLocationExpression &L, 37 const DWARFLocationExpression &R) { 38 return !(L == R); 39 } 40 41 raw_ostream &operator<<(raw_ostream &OS, const DWARFLocationExpression &Loc); 42 43 /// Represents a set of absolute location expressions. 44 using DWARFLocationExpressionsVector = std::vector<DWARFLocationExpression>; 45 46 } // end namespace llvm 47 48 #endif // LLVM_DEBUGINFO_DWARF_DWARFLOCATIONEXPRESSION_H 49