[lld] e5f568a - Use has_value instead of hasValue (NFC)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 13 01:58:09 PDT 2022


Author: Kazu Hirata
Date: 2022-07-13T01:58:03-07:00
New Revision: e5f568a49f2bbc69a1fc30be818613e0c7fe0499

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

LOG: Use has_value instead of hasValue (NFC)

Added: 
    

Modified: 
    lld/wasm/InputChunks.h
    lld/wasm/InputElement.h
    lld/wasm/Writer.cpp
    lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
    lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
    lldb/unittests/Process/minidump/MinidumpParserTest.cpp
    polly/lib/Exchange/JSONExporter.cpp

Removed: 
    


################################################################################
diff  --git a/lld/wasm/InputChunks.h b/lld/wasm/InputChunks.h
index 022a8ad5a4221..49283e142b4de 100644
--- a/lld/wasm/InputChunks.h
+++ b/lld/wasm/InputChunks.h
@@ -275,10 +275,10 @@ class InputFunction : public InputChunk {
   uint32_t getFunctionInputOffset() const { return getInputSectionOffset(); }
   uint32_t getFunctionCodeOffset() const { return function->CodeOffset; }
   uint32_t getFunctionIndex() const { return functionIndex.getValue(); }
-  bool hasFunctionIndex() const { return functionIndex.hasValue(); }
+  bool hasFunctionIndex() const { return functionIndex.has_value(); }
   void setFunctionIndex(uint32_t index);
   uint32_t getTableIndex() const { return tableIndex.getValue(); }
-  bool hasTableIndex() const { return tableIndex.hasValue(); }
+  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 9bea90b87640c..66f8e85ff3b7c 100644
--- a/lld/wasm/InputElement.h
+++ b/lld/wasm/InputElement.h
@@ -28,7 +28,7 @@ class InputElement {
 public:
   StringRef getName() const { return name; }
   uint32_t getAssignedIndex() const { return assignedIndex.getValue(); }
-  bool hasAssignedIndex() const { return assignedIndex.hasValue(); }
+  bool hasAssignedIndex() const { return assignedIndex.has_value(); }
   void assignIndex(uint32_t index) {
     assert(!hasAssignedIndex());
     assignedIndex = index;

diff  --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index 8eed209ba2172..fc5462a18bb78 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -446,7 +446,7 @@ void Writer::populateTargetFeatures() {
   }
 
   // Only infer used features if user did not specify features
-  bool inferFeatures = !config->features.hasValue();
+  bool inferFeatures = !config->features.has_value();
 
   if (!inferFeatures) {
     auto &explicitFeatures = config->features.getValue();

diff  --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index 700e6ebdf84c1..c44ace96dd55c 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -2727,7 +2727,7 @@ bool GDBRemoteCommunicationClient::SetCurrentThread(uint64_t tid,
       m_curr_pid = ret->pid;
     m_curr_tid = ret->tid;
   }
-  return ret.hasValue();
+  return ret.has_value();
 }
 
 bool GDBRemoteCommunicationClient::SetCurrentThreadForRun(uint64_t tid,
@@ -2742,7 +2742,7 @@ bool GDBRemoteCommunicationClient::SetCurrentThreadForRun(uint64_t tid,
       m_curr_pid_run = ret->pid;
     m_curr_tid_run = ret->tid;
   }
-  return ret.hasValue();
+  return ret.has_value();
 }
 
 bool GDBRemoteCommunicationClient::GetStopReply(

diff  --git a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
index d15b85204b555..a57890c0733de 100644
--- a/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
+++ b/lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
@@ -190,7 +190,7 @@ TEST_F(GDBRemoteCommunicationClientTest, GetModulesInfo) {
       R"("file_path":"/foo/bar.so","file_offset":0,"file_size":1234}]])");
 
   auto result = async_result.get();
-  ASSERT_TRUE(result.hasValue());
+  ASSERT_TRUE(result.has_value());
   ASSERT_EQ(1u, result->size());
   EXPECT_EQ("/foo/bar.so", result.getValue()[0].GetFileSpec().GetPath());
   EXPECT_EQ(triple, result.getValue()[0].GetArchitecture().GetTriple());
@@ -215,7 +215,7 @@ TEST_F(GDBRemoteCommunicationClientTest, GetModulesInfo_UUID20) {
       R"("file_path":"/foo/bar.so","file_offset":0,"file_size":1234}]])");
 
   auto result = async_result.get();
-  ASSERT_TRUE(result.hasValue());
+  ASSERT_TRUE(result.has_value());
   ASSERT_EQ(1u, result->size());
   EXPECT_EQ("/foo/bar.so", result.getValue()[0].GetFileSpec().GetPath());
   EXPECT_EQ(triple, result.getValue()[0].GetArchitecture().GetTriple());

diff  --git a/lldb/unittests/Process/minidump/MinidumpParserTest.cpp b/lldb/unittests/Process/minidump/MinidumpParserTest.cpp
index b8143d53eb0b3..55e1609aa5a78 100644
--- a/lldb/unittests/Process/minidump/MinidumpParserTest.cpp
+++ b/lldb/unittests/Process/minidump/MinidumpParserTest.cpp
@@ -183,7 +183,7 @@ TEST_F(MinidumpParserTest, GetLinuxProcStatus) {
 )"),
                     llvm::Succeeded());
   llvm::Optional<LinuxProcStatus> proc_status = parser->GetLinuxProcStatus();
-  ASSERT_TRUE(proc_status.hasValue());
+  ASSERT_TRUE(proc_status.has_value());
   lldb::pid_t pid = proc_status->GetPid();
   ASSERT_EQ(16001UL, pid);
 }
@@ -218,7 +218,7 @@ TEST_F(MinidumpParserTest, GetPid) {
 )"),
                     llvm::Succeeded());
   llvm::Optional<lldb::pid_t> pid = parser->GetPid();
-  ASSERT_TRUE(pid.hasValue());
+  ASSERT_TRUE(pid.has_value());
   ASSERT_EQ(16001UL, pid.getValue());
 }
 
@@ -260,7 +260,7 @@ TEST_F(MinidumpParserTest, GetExceptionStream) {
 void check_mem_range_exists(MinidumpParser &parser, const uint64_t range_start,
                             const uint64_t range_size) {
   llvm::Optional<minidump::Range> range = parser.FindMemoryRange(range_start);
-  ASSERT_TRUE(range.hasValue()) << "There is no range containing this address";
+  ASSERT_TRUE(range.has_value()) << "There is no range containing this address";
   EXPECT_EQ(range_start, range->start);
   EXPECT_EQ(range_start + range_size, range->start + range->range_ref.size());
 }
@@ -321,14 +321,14 @@ TEST_F(MinidumpParserTest, FindMemoryRangeWithFullMemoryMinidump) {
   SetUpData("fizzbuzz_wow64.dmp");
 
   // There are a lot of ranges in the file, just testing with some of them
-  EXPECT_FALSE(parser->FindMemoryRange(0x00).hasValue());
-  EXPECT_FALSE(parser->FindMemoryRange(0x2a).hasValue());
+  EXPECT_FALSE(parser->FindMemoryRange(0x00).has_value());
+  EXPECT_FALSE(parser->FindMemoryRange(0x2a).has_value());
   check_mem_range_exists(*parser, 0x10000, 65536); // first range
   check_mem_range_exists(*parser, 0x40000, 4096);
-  EXPECT_FALSE(parser->FindMemoryRange(0x40000 + 4096).hasValue());
+  EXPECT_FALSE(parser->FindMemoryRange(0x40000 + 4096).has_value());
   check_mem_range_exists(*parser, 0x77c12000, 8192);
   check_mem_range_exists(*parser, 0x7ffe0000, 4096); // last range
-  EXPECT_FALSE(parser->FindMemoryRange(0x7ffe0000 + 4096).hasValue());
+  EXPECT_FALSE(parser->FindMemoryRange(0x7ffe0000 + 4096).has_value());
 }
 
 constexpr auto yes = MemoryRegionInfo::eYes;
@@ -544,14 +544,14 @@ TEST_F(MinidumpParserTest, GetMiscInfoWindows) {
   const MinidumpMiscInfo *misc_info = parser->GetMiscInfo();
   ASSERT_NE(nullptr, misc_info);
   llvm::Optional<lldb::pid_t> pid = misc_info->GetPid();
-  ASSERT_TRUE(pid.hasValue());
+  ASSERT_TRUE(pid.has_value());
   ASSERT_EQ(4440UL, pid.getValue());
 }
 
 TEST_F(MinidumpParserTest, GetPidWindows) {
   SetUpData("fizzbuzz_no_heap.dmp");
   llvm::Optional<lldb::pid_t> pid = parser->GetPid();
-  ASSERT_TRUE(pid.hasValue());
+  ASSERT_TRUE(pid.has_value());
   ASSERT_EQ(4440UL, pid.getValue());
 }
 
@@ -559,7 +559,7 @@ TEST_F(MinidumpParserTest, GetPidWindows) {
 TEST_F(MinidumpParserTest, GetPidWow64) {
   SetUpData("fizzbuzz_wow64.dmp");
   llvm::Optional<lldb::pid_t> pid = parser->GetPid();
-  ASSERT_TRUE(pid.hasValue());
+  ASSERT_TRUE(pid.has_value());
   ASSERT_EQ(7836UL, pid.getValue());
 }
 

diff  --git a/polly/lib/Exchange/JSONExporter.cpp b/polly/lib/Exchange/JSONExporter.cpp
index e92055bfb9af6..ca9c1b8b6ef63 100644
--- a/polly/lib/Exchange/JSONExporter.cpp
+++ b/polly/lib/Exchange/JSONExporter.cpp
@@ -290,7 +290,7 @@ static bool importSchedule(Scop &S, const json::Object &JScop,
     }
     Optional<StringRef> Schedule =
         statements[Index].getAsObject()->getString("schedule");
-    assert(Schedule.hasValue() &&
+    assert(Schedule.has_value() &&
            "Schedules that contain extension nodes require special handling.");
     isl_map *Map = isl_map_read_from_str(S.getIslCtx().get(),
                                          Schedule.getValue().str().c_str());


        


More information about the llvm-commits mailing list