Use getValueOr (NFC)

This commit is contained in:
Kazu Hirata 2022-06-11 11:24:57 -07:00
parent 5ee3876905
commit 439a675a5a
3 changed files with 4 additions and 6 deletions

View File

@ -410,7 +410,7 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI,
if (TI.getTriple().getOS() == llvm::Triple::ShaderModel) {
VersionTuple Version = TI.getTriple().getOSVersion();
Builder.defineMacro("__SHADER_TARGET_MAJOR", Twine(Version.getMajor()));
unsigned Minor = Version.getMinor() ? *Version.getMinor() : 0;
unsigned Minor = Version.getMinor().getValueOr(0);
Builder.defineMacro("__SHADER_TARGET_MINOR", Twine(Minor));
}
return;

View File

@ -90,10 +90,8 @@ Error CVSymbolVisitor::visitSymbolStreamFiltered(const CVSymbolArray &Symbols,
if (!Filter.SymbolOffset)
return visitSymbolStream(Symbols);
uint32_t SymbolOffset = *Filter.SymbolOffset;
uint32_t ParentRecurseDepth =
Filter.ParentRecursiveDepth ? *Filter.ParentRecursiveDepth : 0;
uint32_t ChildrenRecurseDepth =
Filter.ChildRecursiveDepth ? *Filter.ChildRecursiveDepth : 0;
uint32_t ParentRecurseDepth = Filter.ParentRecursiveDepth.getValueOr(0);
uint32_t ChildrenRecurseDepth = Filter.ChildRecursiveDepth.getValueOr(0);
if (!Symbols.isOffsetValid(SymbolOffset))
return createStringError(inconvertibleErrorCode(), "Invalid symbol offset");
CVSymbol Sym = *Symbols.at(SymbolOffset);

View File

@ -217,7 +217,7 @@ public:
// time as long as it is not SHN_UNDEF. Set shndx to 1, which
// points to ".dynsym".
uint16_t Shndx = Sym.Undefined ? SHN_UNDEF : 1;
uint64_t Size = Sym.Size ? *Sym.Size : 0;
uint64_t Size = Sym.Size.getValueOr(0);
DynSym.Content.add(DynStr.Content.getOffset(Sym.Name), Size, Bind,
convertIFSSymbolTypeToELF(Sym.Type), 0, Shndx);
}