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/ADT/Optional.h" 13 #include "llvm/DebugInfo/DWARF/DWARFAddressRange.h" 14 15 namespace llvm { 16 17 class raw_ostream; 18 19 /// Represents a single DWARF expression, whose value is location-dependent. 20 /// Typically used in DW_AT_location attributes to describe the location of 21 /// objects. 22 struct DWARFLocationExpression { 23 /// The address range in which this expression is valid. None denotes a 24 /// default entry which is valid in addresses not covered by other location 25 /// expressions, or everywhere if there are no other expressions. 26 Optional<DWARFAddressRange> Range; 27 28 /// The expression itself. 29 SmallVector<uint8_t, 4> Expr; 30 }; 31 32 inline bool operator==(const DWARFLocationExpression &L, 33 const DWARFLocationExpression &R) { 34 return L.Range == R.Range && L.Expr == R.Expr; 35 } 36 37 inline bool operator!=(const DWARFLocationExpression &L, 38 const DWARFLocationExpression &R) { 39 return !(L == R); 40 } 41 42 raw_ostream &operator<<(raw_ostream &OS, const DWARFLocationExpression &Loc); 43 44 /// Represents a set of absolute location expressions. 45 using DWARFLocationExpressionsVector = std::vector<DWARFLocationExpression>; 46 47 } // end namespace llvm 48 49 #endif // LLVM_DEBUGINFO_DWARF_DWARFLOCATIONEXPRESSION_H 50