From b81715aca871ac4f14513b853336fb6acf0a1d78 Mon Sep 17 00:00:00 2001 From: Frederic Riss Date: Thu, 4 Sep 2014 06:14:35 +0000 Subject: [PATCH] Add DWARFFormValue::getAsBlock() and add FC_Flag as an acceptable class for an unsigned constant. To be used in further patches that improve the dumpers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217129 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo/DWARFFormValue.h | 1 + lib/DebugInfo/DWARFFormValue.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/llvm/DebugInfo/DWARFFormValue.h b/include/llvm/DebugInfo/DWARFFormValue.h index d517a72d62e..2dde8fe242a 100644 --- a/include/llvm/DebugInfo/DWARFFormValue.h +++ b/include/llvm/DebugInfo/DWARFFormValue.h @@ -70,6 +70,7 @@ public: Optional getAsCString(const DWARFUnit *U) const; Optional getAsAddress(const DWARFUnit *U) const; Optional getAsSectionOffset() const; + Optional> getAsBlock() const; bool skipValue(DataExtractor debug_info_data, uint32_t *offset_ptr, const DWARFUnit *u) const; diff --git a/lib/DebugInfo/DWARFFormValue.cpp b/lib/DebugInfo/DWARFFormValue.cpp index 8d0f96620a4..2f8affc8623 100644 --- a/lib/DebugInfo/DWARFFormValue.cpp +++ b/lib/DebugInfo/DWARFFormValue.cpp @@ -543,7 +543,15 @@ Optional DWARFFormValue::getAsSectionOffset() const { } Optional DWARFFormValue::getAsUnsignedConstant() const { - if (!isFormClass(FC_Constant) || Form == DW_FORM_sdata) + if ((!isFormClass(FC_Constant) && !isFormClass(FC_Flag)) + || Form == DW_FORM_sdata) return None; return Value.uval; } + +Optional> DWARFFormValue::getAsBlock() const { + if (!isFormClass(FC_Block) && !isFormClass(FC_Exprloc)) + return None; + return ArrayRef(Value.data, Value.uval); +} + -- 2.34.1