diff options
author | Greg Clayton <gclayton@apple.com> | 2016-12-13 23:20:56 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2016-12-13 23:20:56 +0000 |
commit | 1cbf3fa94a6ef7a3dd4f5d177aeed5ea3fa539bc (patch) | |
tree | e7878576b7b64074b8144a8ef3b233c2962711c5 /llvm/lib/DebugInfo/DWARF/DWARFDie.cpp | |
parent | 98d40e0557290d7b17533ed86a5ce41f90ff1626 (diff) | |
download | bcm5719-llvm-1cbf3fa94a6ef7a3dd4f5d177aeed5ea3fa539bc.tar.gz bcm5719-llvm-1cbf3fa94a6ef7a3dd4f5d177aeed5ea3fa539bc.zip |
Switch functions that returned bool and filled in a DWARFFormValue arg with ones that return Optional<DWARFFormValue>
Differential Revision: https://reviews.llvm.org/D27737
llvm-svn: 289611
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF/DWARFDie.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFDie.cpp | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp index a41fe6fce1d..f52cc112f7f 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp @@ -133,68 +133,68 @@ bool DWARFDie::isSubroutineDIE() const { return Tag == DW_TAG_subprogram || Tag == DW_TAG_inlined_subroutine; } -bool DWARFDie::getAttributeValue(dwarf::Attribute Attr, - DWARFFormValue &FormValue) const { - if (!U) - return false; +Optional<DWARFFormValue> +DWARFDie::getAttributeValue(dwarf::Attribute Attr) const { + if (!isValid()) + return None; auto AbbrevDecl = getAbbreviationDeclarationPtr(); if (AbbrevDecl) - return AbbrevDecl->getAttributeValue(getOffset(), Attr, *U, FormValue); - return false; + return AbbrevDecl->getAttributeValue(getOffset(), Attr, *U); + return None; } const char *DWARFDie::getAttributeValueAsString(dwarf::Attribute Attr, const char *FailValue) const { - DWARFFormValue FormValue; - if (!getAttributeValue(Attr, FormValue)) + auto FormValue = getAttributeValue(Attr); + if (!FormValue) return FailValue; - Optional<const char *> Result = FormValue.getAsCString(); + Optional<const char *> Result = FormValue->getAsCString(); return Result.hasValue() ? Result.getValue() : FailValue; } uint64_t DWARFDie::getAttributeValueAsAddress(dwarf::Attribute Attr, uint64_t FailValue) const { - DWARFFormValue FormValue; - if (!getAttributeValue(Attr, FormValue)) + auto FormValue = getAttributeValue(Attr); + if (!FormValue) return FailValue; - Optional<uint64_t> Result = FormValue.getAsAddress(); + Optional<uint64_t> Result = FormValue->getAsAddress(); return Result.hasValue() ? Result.getValue() : FailValue; } int64_t DWARFDie::getAttributeValueAsSignedConstant(dwarf::Attribute Attr, int64_t FailValue) const { - DWARFFormValue FormValue; - if (!getAttributeValue(Attr, FormValue)) + auto FormValue = getAttributeValue(Attr); + if (!FormValue) return FailValue; - Optional<int64_t> Result = FormValue.getAsSignedConstant(); + Optional<int64_t> Result = FormValue->getAsSignedConstant(); return Result.hasValue() ? Result.getValue() : FailValue; } uint64_t DWARFDie::getAttributeValueAsUnsignedConstant(dwarf::Attribute Attr, uint64_t FailValue) const { - DWARFFormValue FormValue; - if (!getAttributeValue(Attr, FormValue)) + auto FormValue = getAttributeValue(Attr); + if (!FormValue) return FailValue; - Optional<uint64_t> Result = FormValue.getAsUnsignedConstant(); + Optional<uint64_t> Result = FormValue->getAsUnsignedConstant(); return Result.hasValue() ? Result.getValue() : FailValue; } uint64_t DWARFDie::getAttributeValueAsReference(dwarf::Attribute Attr, uint64_t FailValue) const { - DWARFFormValue FormValue; - if (!getAttributeValue(Attr, FormValue)) + auto FormValue = getAttributeValue(Attr); + if (!FormValue) return FailValue; - Optional<uint64_t> Result = FormValue.getAsReference(); + Optional<uint64_t> Result = FormValue->getAsReference(); return Result.hasValue() ? Result.getValue() : FailValue; } uint64_t DWARFDie::getAttributeValueAsSectionOffset(dwarf::Attribute Attr, uint64_t FailValue) const { - DWARFFormValue FormValue; - if (!getAttributeValue(Attr, FormValue)) + auto FormValue = getAttributeValue(Attr); + if (!FormValue) return FailValue; - Optional<uint64_t> Result = FormValue.getAsSectionOffset(); + Optional<uint64_t> Result = FormValue->getAsSectionOffset(); return Result.hasValue() ? Result.getValue() : FailValue; } |