[lld] 2390bb2 - [NFC] use has_value instead of hasValue

Florian Mayer via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 31 16:44:05 PDT 2022


Author: Florian Mayer
Date: 2022-10-31T16:43:14-07:00
New Revision: 2390bb2347703bf500333fcd4d8c1b513a6e1740

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

LOG: [NFC] use has_value instead of hasValue

Added: 
    

Modified: 
    lld/wasm/Driver.cpp
    lld/wasm/SyntheticSections.cpp
    lld/wasm/SyntheticSections.h
    lld/wasm/Writer.cpp

Removed: 
    


################################################################################
diff  --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index 68e217f7e9877..db1ef5ffff778 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -530,10 +530,10 @@ static void setConfigs() {
   }
 
   if (config->shared) {
-    if (config->memoryExport.hasValue()) {
+    if (config->memoryExport.has_value()) {
       error("--export-memory is incompatible with --shared");
     }
-    if (!config->memoryImport.hasValue()) {
+    if (!config->memoryImport.has_value()) {
       config->memoryImport =
           std::pair<llvm::StringRef, llvm::StringRef>(defaultModule, memoryName);
     }
@@ -542,7 +542,7 @@ static void setConfigs() {
 
   // If neither export-memory nor import-memory is specified, default to
   // exporting memory under its default name.
-  if (!config->memoryExport.hasValue() && !config->memoryImport.hasValue()) {
+  if (!config->memoryExport.has_value() && !config->memoryImport.has_value()) {
     config->memoryExport = memoryName;
   }
 }

diff  --git a/lld/wasm/SyntheticSections.cpp b/lld/wasm/SyntheticSections.cpp
index 3be2beb735787..1cded0e49a0dc 100644
--- a/lld/wasm/SyntheticSections.cpp
+++ b/lld/wasm/SyntheticSections.cpp
@@ -162,7 +162,7 @@ void TypeSection::writeBody() {
 uint32_t ImportSection::getNumImports() const {
   assert(isSealed);
   uint32_t numImports = importedSymbols.size() + gotSymbols.size();
-  if (config->memoryImport.hasValue())
+  if (config->memoryImport.has_value())
     ++numImports;
   return numImports;
 }
@@ -236,8 +236,8 @@ void ImportSection::writeBody() {
 
   if (config->memoryImport) {
     WasmImport import;
-    import.Module = config->memoryImport.getValue().first;
-    import.Field = config->memoryImport.getValue().second;
+    import.Module = config->memoryImport.value().first;
+    import.Field = config->memoryImport.value().second;
     import.Kind = WASM_EXTERNAL_MEMORY;
     import.Memory.Flags = 0;
     import.Memory.Minimum = out.memorySec->numMemoryPages;

diff  --git a/lld/wasm/SyntheticSections.h b/lld/wasm/SyntheticSections.h
index fe2d3879b6e2d..dce2c935aa23e 100644
--- a/lld/wasm/SyntheticSections.h
+++ b/lld/wasm/SyntheticSections.h
@@ -230,7 +230,7 @@ class MemorySection : public SyntheticSection {
 public:
   MemorySection() : SyntheticSection(llvm::wasm::WASM_SEC_MEMORY) {}
 
-  bool isNeeded() const override { return !config->memoryImport.hasValue(); }
+  bool isNeeded() const override { return !config->memoryImport.has_value(); }
   void writeBody() override;
 
   uint64_t numMemoryPages = 0;

diff  --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index bd01474353338..95061ab22a260 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -577,7 +577,7 @@ void Writer::populateTargetFeatures() {
   // memory is not being imported then we can assume its zero initialized.
   // In the case the memory is imported, and we can use the memory.fill
   // instruction, then we can also avoid including the segments.
-  if (config->memoryImport.hasValue() && !allowed.count("bulk-memory"))
+  if (config->memoryImport.has_value() && !allowed.count("bulk-memory"))
     config->emitBssSegments = true;
 
   if (allowed.count("extended-const"))
@@ -671,7 +671,7 @@ void Writer::calculateExports() {
   if (config->relocatable)
     return;
 
-  if (!config->relocatable && config->memoryExport.hasValue()) {
+  if (!config->relocatable && config->memoryExport.has_value()) {
     out.exportSec->exports.push_back(
         WasmExport{*config->memoryExport, WASM_EXTERNAL_MEMORY, 0});
   }
@@ -1008,7 +1008,7 @@ static void createFunction(DefinedFunction *func, StringRef bodyContent) {
 bool Writer::needsPassiveInitialization(const OutputSegment *segment) {
   // If bulk memory features is supported then we can perform bss initialization
   // (via memory.fill) during `__wasm_init_memory`.
-  if (config->memoryImport.hasValue() && !segment->requiredInBinary())
+  if (config->memoryImport.has_value() && !segment->requiredInBinary())
     return true;
   return segment->initFlags & WASM_DATA_SEGMENT_IS_PASSIVE;
 }


        


More information about the llvm-commits mailing list