Use has_value instead of hasValue (NFC)

This commit is contained in:
Kazu Hirata 2022-07-13 01:58:03 -07:00
parent 7c3cda551a
commit e5f568a49f
7 changed files with 19 additions and 19 deletions

View file

@ -275,10 +275,10 @@ public:
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;

View file

@ -28,7 +28,7 @@ protected:
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;

View file

@ -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();

View file

@ -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(

View file

@ -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());

View file

@ -183,7 +183,7 @@ Streams:
)"),
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 @@ Streams:
)"),
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());
}

View file

@ -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());