[PATCH] D27071: Add the ability to get a signed integer attribute from a DWARFDebugInfoEntry.

Greg Clayton via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 23 15:53:09 PST 2016


clayborg created this revision.
clayborg added reviewers: dblaikie, aprantl, probinson, llvm-commits.

Trying to keep things smaller. This will be needed by an upcoming DWARF generator patch, but this is small and self contained.


https://reviews.llvm.org/D27071

Files:
  include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h
  lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp


Index: lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp
===================================================================
--- lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp
+++ lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp
@@ -269,6 +269,15 @@
   return Result.hasValue() ? Result.getValue() : FailValue;
 }
 
+int64_t DWARFDebugInfoEntryMinimal::getAttributeValueAsSignedConstant(
+    const DWARFUnit *U, dwarf::Attribute Attr, int64_t FailValue) const {
+  DWARFFormValue FormValue;
+  if (!getAttributeValue(U, Attr, FormValue))
+    return FailValue;
+  Optional<int64_t> Result = FormValue.getAsSignedConstant();
+  return Result.hasValue() ? Result.getValue() : FailValue;
+}
+
 uint64_t DWARFDebugInfoEntryMinimal::getAttributeValueAsUnsignedConstant(
     const DWARFUnit *U, dwarf::Attribute Attr, 
     uint64_t FailValue) const {
Index: include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h
===================================================================
--- include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h
+++ include/llvm/DebugInfo/DWARF/DWARFDebugInfoEntry.h
@@ -101,6 +101,10 @@
                                       dwarf::Attribute Attr,
                                       uint64_t FailValue) const;
 
+  int64_t getAttributeValueAsSignedConstant(const DWARFUnit *U,
+                                            dwarf::Attribute Attr,
+                                            int64_t FailValue) const;
+
   uint64_t getAttributeValueAsUnsignedConstant(const DWARFUnit *U,
                                                dwarf::Attribute Attr,
                                                uint64_t FailValue) const;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27071.79164.patch
Type: text/x-patch
Size: 1641 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161123/94455a0c/attachment.bin>


More information about the llvm-commits mailing list