[llvm] a18ca45 - [IR] Use std::optional in Instructions.h (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 27 14:40:19 PST 2022


Author: Kazu Hirata
Date: 2022-11-27T14:40:07-08:00
New Revision: a18ca456342267039edb693850595137169c99dd

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

LOG: [IR] Use std::optional in Instructions.h (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Added: 
    

Modified: 
    llvm/include/llvm/IR/Instructions.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h
index 5dfe0d180453..725ee74b8f20 100644
--- a/llvm/include/llvm/IR/Instructions.h
+++ b/llvm/include/llvm/IR/Instructions.h
@@ -38,6 +38,7 @@
 #include <cstddef>
 #include <cstdint>
 #include <iterator>
+#include <optional>
 
 namespace llvm {
 
@@ -3618,7 +3619,7 @@ class SwitchInst : public Instruction {
 /// their prof branch_weights metadata.
 class SwitchInstProfUpdateWrapper {
   SwitchInst &SI;
-  Optional<SmallVector<uint32_t, 8> > Weights = None;
+  std::optional<SmallVector<uint32_t, 8>> Weights = None;
   bool Changed = false;
 
 protected:
@@ -3629,7 +3630,7 @@ class SwitchInstProfUpdateWrapper {
   void init();
 
 public:
-  using CaseWeightOpt = Optional<uint32_t>;
+  using CaseWeightOpt = std::optional<uint32_t>;
   SwitchInst *operator->() { return &SI; }
   SwitchInst &operator*() { return SI; }
   operator SwitchInst *() { return &SI; }
@@ -5412,7 +5413,7 @@ inline Type *getLoadStoreType(Value *I) {
 
 /// A helper function that returns an atomic operation's sync scope; returns
 /// None if it is not an atomic operation.
-inline Optional<SyncScope::ID> getAtomicSyncScopeID(const Instruction *I) {
+inline std::optional<SyncScope::ID> getAtomicSyncScopeID(const Instruction *I) {
   if (!I->isAtomic())
     return None;
   if (auto *AI = dyn_cast<LoadInst>(I))


        


More information about the llvm-commits mailing list