Author: Kazu Hirata
Date: 2022-06-11T11:24:57-07:00
New Revision: 439a675a5a7d8a61014863b2fbb75cb291cad6a0

URL: 
https://github.com/llvm/llvm-project/commit/439a675a5a7d8a61014863b2fbb75cb291cad6a0
DIFF: 
https://github.com/llvm/llvm-project/commit/439a675a5a7d8a61014863b2fbb75cb291cad6a0.diff

LOG: Use getValueOr (NFC)

Added: 
    

Modified: 
    clang/lib/Frontend/InitPreprocessor.cpp
    llvm/lib/DebugInfo/CodeView/CVSymbolVisitor.cpp
    llvm/lib/InterfaceStub/ELFObjHandler.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 73986b2740760..834946411b84b 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -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;

diff  --git a/llvm/lib/DebugInfo/CodeView/CVSymbolVisitor.cpp 
b/llvm/lib/DebugInfo/CodeView/CVSymbolVisitor.cpp
index 162f1db0189bd..da2041d541040 100644
--- a/llvm/lib/DebugInfo/CodeView/CVSymbolVisitor.cpp
+++ b/llvm/lib/DebugInfo/CodeView/CVSymbolVisitor.cpp
@@ -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);

diff  --git a/llvm/lib/InterfaceStub/ELFObjHandler.cpp 
b/llvm/lib/InterfaceStub/ELFObjHandler.cpp
index 6f37cf6f7e8a9..55d06cd224f79 100644
--- a/llvm/lib/InterfaceStub/ELFObjHandler.cpp
+++ b/llvm/lib/InterfaceStub/ELFObjHandler.cpp
@@ -217,7 +217,7 @@ template <class ELFT> class ELFStubBuilder {
       // 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);
     }


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to