[llvm] cc6d3f0 - [M68k] Fix MSVC llvm::Optional<> deprecation warnings

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 14 10:55:11 PDT 2022


Author: Simon Pilgrim
Date: 2022-08-14T18:54:41+01:00
New Revision: cc6d3f07f444385c76430ceaed00610a4c058767

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

LOG: [M68k] Fix MSVC llvm::Optional<> deprecation warnings

Use has_value()/value() instead of hasValue()/getValue()

Added: 
    

Modified: 
    llvm/lib/Target/M68k/M68kMCInstLower.cpp
    llvm/lib/Target/M68k/M68kTargetMachine.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/M68k/M68kMCInstLower.cpp b/llvm/lib/Target/M68k/M68kMCInstLower.cpp
index a0b1452ee6639..93a60ab739b8d 100644
--- a/llvm/lib/Target/M68k/M68kMCInstLower.cpp
+++ b/llvm/lib/Target/M68k/M68kMCInstLower.cpp
@@ -150,8 +150,8 @@ void M68kMCInstLower::Lower(const MachineInstr *MI, MCInst &OutMI) const {
     const MachineOperand &MO = MI->getOperand(i);
     Optional<MCOperand> MCOp = LowerOperand(MI, MO);
 
-    if (MCOp.hasValue() && MCOp.getValue().isValid())
-      OutMI.addOperand(MCOp.getValue());
+    if (MCOp.has_value() && MCOp.value().isValid())
+      OutMI.addOperand(MCOp.value());
   }
 
   // TAILJMPj, TAILJMPq - Lower to the correct jump instructions.

diff  --git a/llvm/lib/Target/M68k/M68kTargetMachine.cpp b/llvm/lib/Target/M68k/M68kTargetMachine.cpp
index fd21fe6bcea8d..f781e1ea55e87 100644
--- a/llvm/lib/Target/M68k/M68kTargetMachine.cpp
+++ b/llvm/lib/Target/M68k/M68kTargetMachine.cpp
@@ -72,9 +72,8 @@ std::string computeDataLayout(const Triple &TT, StringRef CPU,
 Reloc::Model getEffectiveRelocModel(const Triple &TT,
                                     Optional<Reloc::Model> RM) {
   // If not defined we default to static
-  if (!RM.hasValue()) {
+  if (!RM.has_value())
     return Reloc::Static;
-  }
 
   return *RM;
 }
@@ -88,7 +87,7 @@ CodeModel::Model getEffectiveCodeModel(Optional<CodeModel::Model> CM,
   } else if (CM == CodeModel::Kernel) {
     llvm_unreachable("Kernel code model is not implemented yet");
   }
-  return CM.getValue();
+  return CM.value();
 }
 } // end anonymous namespace
 


        


More information about the llvm-commits mailing list