Use getValueOr (NFC)
authorKazu Hirata <kazu@google.com>
Sat, 11 Jun 2022 18:24:57 +0000 (11:24 -0700)
committerKazu Hirata <kazu@google.com>
Sat, 11 Jun 2022 18:24:57 +0000 (11:24 -0700)
clang/lib/Frontend/InitPreprocessor.cpp
llvm/lib/DebugInfo/CodeView/CVSymbolVisitor.cpp
llvm/lib/InterfaceStub/ELFObjHandler.cpp

index 73986b2..8349464 100644 (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;
index 162f1db..da2041d 100644 (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);
index 6f37cf6..55d06cd 100644 (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);
     }