[clang] f4b9077 - llvm::Optional::value => operator*/operator->

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 16 20:45:17 PST 2022


Author: Fangrui Song
Date: 2022-12-17T04:45:11Z
New Revision: f4b90773dc3d4773546a30a70c96deba3b858e5c

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

LOG: llvm::Optional::value => operator*/operator->

std::optional::value() has undesired exception checking semantics and is
unavailable in some older Xcode. The call sites block std::optional migration.

Added: 
    

Modified: 
    clang/include/clang/Support/RISCVVIntrinsicUtils.h
    clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
    clang/lib/Support/RISCVVIntrinsicUtils.cpp
    lld/wasm/InputChunks.h
    lld/wasm/InputElement.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Support/RISCVVIntrinsicUtils.h b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
index 8b9f994a4e31a..a3a2a3c068604 100644
--- a/clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -234,8 +234,8 @@ class RVVType {
   }
 
   bool isValid() const { return Valid; }
-  bool isScalar() const { return Scale && Scale.value() == 0; }
-  bool isVector() const { return Scale && Scale.value() != 0; }
+  bool isScalar() const { return Scale && *Scale == 0; }
+  bool isVector() const { return Scale && *Scale != 0; }
   bool isVector(unsigned Width) const {
     return isVector() && ElementBitwidth == Width;
   }

diff  --git a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
index efff3498b4ee0..8f820f235f485 100644
--- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
+++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
@@ -95,8 +95,7 @@ class CachedFileSystemEntry {
     assert(Contents && "contents not initialized");
     if (auto *Directives = Contents->DepDirectives.load()) {
       if (Directives->has_value())
-        return ArrayRef<dependency_directives_scan::Directive>(
-            Directives->value());
+        return ArrayRef<dependency_directives_scan::Directive>(**Directives);
     }
     return std::nullopt;
   }

diff  --git a/clang/lib/Support/RISCVVIntrinsicUtils.cpp b/clang/lib/Support/RISCVVIntrinsicUtils.cpp
index 18dd9403f17d1..843cee3506263 100644
--- a/clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ b/clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -112,7 +112,7 @@ bool RVVType::verifyType() const {
     return false;
   if (isFloat() && ElementBitwidth == 8)
     return false;
-  unsigned V = Scale.value();
+  unsigned V = *Scale;
   switch (ElementBitwidth) {
   case 1:
   case 8:

diff  --git a/lld/wasm/InputChunks.h b/lld/wasm/InputChunks.h
index 37494172a69e8..34b1572584a10 100644
--- a/lld/wasm/InputChunks.h
+++ b/lld/wasm/InputChunks.h
@@ -275,10 +275,10 @@ class InputFunction : public InputChunk {
   void setExportName(std::string exportName) { this->exportName = exportName; }
   uint32_t getFunctionInputOffset() const { return getInputSectionOffset(); }
   uint32_t getFunctionCodeOffset() const { return function->CodeOffset; }
-  uint32_t getFunctionIndex() const { return functionIndex.value(); }
+  uint32_t getFunctionIndex() const { return *functionIndex; }
   bool hasFunctionIndex() const { return functionIndex.has_value(); }
   void setFunctionIndex(uint32_t index);
-  uint32_t getTableIndex() const { return tableIndex.value(); }
+  uint32_t getTableIndex() const { return *tableIndex; }
   bool hasTableIndex() const { return tableIndex.has_value(); }
   void setTableIndex(uint32_t index);
   void writeCompressed(uint8_t *buf) const;

diff  --git a/lld/wasm/InputElement.h b/lld/wasm/InputElement.h
index 7d77a92bc7424..0d4e9b388b31d 100644
--- a/lld/wasm/InputElement.h
+++ b/lld/wasm/InputElement.h
@@ -27,7 +27,7 @@ class InputElement {
 
 public:
   StringRef getName() const { return name; }
-  uint32_t getAssignedIndex() const { return assignedIndex.value(); }
+  uint32_t getAssignedIndex() const { return *assignedIndex; }
   bool hasAssignedIndex() const { return assignedIndex.has_value(); }
   void assignIndex(uint32_t index) {
     assert(!hasAssignedIndex());


        


More information about the cfe-commits mailing list