[lld] d88e8dc - [lld] llvm::Optional::value => operator*/operator->

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 16 21:04:03 PST 2022


Author: Fangrui Song
Date: 2022-12-17T05:03:57Z
New Revision: d88e8dcc728c6a536270c0ce06aed2ef45b78c6b

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

LOG: [lld] 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: 
    lld/wasm/SyntheticSections.cpp
    lld/wasm/Writer.cpp

Removed: 
    


################################################################################
diff  --git a/lld/wasm/SyntheticSections.cpp b/lld/wasm/SyntheticSections.cpp
index 9411aa4233aa..bf32754e2991 100644
--- a/lld/wasm/SyntheticSections.cpp
+++ b/lld/wasm/SyntheticSections.cpp
@@ -236,8 +236,8 @@ void ImportSection::writeBody() {
 
   if (config->memoryImport) {
     WasmImport import;
-    import.Module = config->memoryImport.value().first;
-    import.Field = config->memoryImport.value().second;
+    import.Module = config->memoryImport->first;
+    import.Field = config->memoryImport->second;
     import.Kind = WASM_EXTERNAL_MEMORY;
     import.Memory.Flags = 0;
     import.Memory.Minimum = out.memorySec->numMemoryPages;

diff  --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index 6906da0ab693..5a0026b62b98 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -475,7 +475,7 @@ void Writer::populateTargetFeatures() {
   }
 
   if (config->extraFeatures.has_value()) {
-    auto &extraFeatures = config->extraFeatures.value();
+    auto &extraFeatures = *config->extraFeatures;
     allowed.insert(extraFeatures.begin(), extraFeatures.end());
   }
 
@@ -483,7 +483,7 @@ void Writer::populateTargetFeatures() {
   bool inferFeatures = !config->features.has_value();
 
   if (!inferFeatures) {
-    auto &explicitFeatures = config->features.value();
+    auto &explicitFeatures = *config->features;
     allowed.insert(explicitFeatures.begin(), explicitFeatures.end());
     if (!config->checkFeatures)
       goto done;


        


More information about the llvm-commits mailing list