Skip to content

Commit 5fb1d91

Browse files
committed
Swift: further replace getValue and hasValue
This furthers the replacements across the Swift specific paths to update for the API changes in LLVM. This reduces the amount of build warnings during the build.
1 parent 7d8e26e commit 5fb1d91

File tree

7 files changed

+29
-29
lines changed

7 files changed

+29
-29
lines changed

lldb/source/Plugins/Language/Swift/SwiftLanguage.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@ std::unique_ptr<Language::TypeScavenger> SwiftLanguage::GetTypeScavenger() {
12171217
auto as_type = m_result.GetAs<CompilerType>();
12181218
auto as_decl = m_result.GetAs<swift::Decl *>();
12191219

1220-
if (as_type.hasValue() && as_type.getValue()) {
1220+
if (as_type.has_value() && as_type.value()) {
12211221
if (auto swift_ast_ctx = as_type->GetTypeSystem()
12221222
.dyn_cast_or_null<TypeSystemSwift>())
12231223
swift_ast_ctx->DumpTypeDescription(
@@ -1228,10 +1228,10 @@ std::unique_ptr<Language::TypeScavenger> SwiftLanguage::GetTypeScavenger() {
12281228
as_type->DumpTypeDescription(
12291229
&stream, eDescriptionLevelFull,
12301230
exe_scope); // we should always have a swift type here..
1231-
} else if (as_decl.hasValue() && as_decl.getValue()) {
1231+
} else if (as_decl.has_value() && as_decl.value()) {
12321232
std::string buffer;
12331233
llvm::raw_string_ostream str_stream(buffer);
1234-
swift::Decl *decl = as_decl.getValue();
1234+
swift::Decl *decl = as_decl.value();
12351235
decl->print(str_stream,
12361236
SwiftASTContext::GetUserVisibleTypePrintingOptions(
12371237
print_help_if_available));
@@ -1375,8 +1375,8 @@ std::unique_ptr<Language::TypeScavenger> SwiftLanguage::GetTypeScavenger() {
13751375
candidate = ast_ctx->FindTypeOrDecl(
13761376
name_parts[0].str().c_str(), module);
13771377
}
1378-
if (candidate.hasValue()) {
1379-
TypesOrDecls candidates{candidate.getValue()};
1378+
if (candidate.has_value()) {
1379+
TypesOrDecls candidates{candidate.value()};
13801380
for (; idx_of_deeper < name_parts.size();
13811381
idx_of_deeper++) {
13821382
TypesOrDecls new_candidates;

lldb/source/Plugins/Language/Swift/SwiftOptionSet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ lldb_private::formatters::swift::SwiftOptionSetSummaryProvider::
7575

7676
void lldb_private::formatters::swift::SwiftOptionSetSummaryProvider::
7777
FillCasesIfNeeded() {
78-
if (m_cases.hasValue())
78+
if (m_cases.has_value())
7979
return;
8080

8181
m_cases = CasesVector();

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ bool SwiftLanguageRuntimeImpl::AddJitObjectFileToReflectionContext(
695695
likely_module_names);
696696
// We don't care to cache modules generated by the jit, because they will
697697
// only be used by the current process.
698-
return reflection_info_id.hasValue();
698+
return reflection_info_id.has_value();
699699
}
700700

701701
llvm::Optional<uint32_t>

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,8 @@ SwiftLanguageRuntime::MetadataPromise::FulfillTypePromise(Status *error) {
487487
"0x%" PRIx64,
488488
m_metadata_location);
489489

490-
if (m_compiler_type.hasValue())
491-
return m_compiler_type.getValue();
490+
if (m_compiler_type.has_value())
491+
return m_compiler_type.value();
492492

493493
llvm::Optional<SwiftScratchContextReader> maybe_swift_scratch_ctx =
494494
m_for_object_sp->GetSwiftScratchContext();
@@ -517,15 +517,15 @@ SwiftLanguageRuntime::MetadataPromise::FulfillTypePromise(Status *error) {
517517
if (log)
518518
log->Printf("[MetadataPromise] result is type %s",
519519
m_compiler_type->GetTypeName().AsCString());
520-
return m_compiler_type.getValue();
520+
return m_compiler_type.value();
521521
} else {
522522
const auto &failure = result.getFailure();
523523
if (error)
524524
error->SetErrorStringWithFormat("error in resolving type: %s",
525525
failure.render().c_str());
526526
if (log)
527527
log->Printf("[MetadataPromise] failure: %s", failure.render().c_str());
528-
return (m_compiler_type = CompilerType()).getValue();
528+
return (m_compiler_type = CompilerType()).value();
529529
}
530530
}
531531

@@ -963,7 +963,7 @@ llvm::Optional<uint64_t> SwiftLanguageRuntimeImpl::GetMemberVariableOffset(
963963
instance_type = ts->ReconstructType(instance_type);
964964
auto reference = GetMemberVariableOffsetRemoteAST(instance_type, instance,
965965
member_name);
966-
if (reference.hasValue() && offset != reference) {
966+
if (reference.has_value() && offset != reference) {
967967
instance_type.dump();
968968
llvm::dbgs() << "member_name = " << member_name << "\n";
969969
llvm::dbgs() << "remote mirrors: " << offset << "\n";
@@ -2221,7 +2221,7 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Protocol(
22212221
.GetSwiftValidateTypeSystem()) {
22222222
auto reference_pair =
22232223
remote_ast_impl(use_local_buffer, existential_address);
2224-
assert(pair.hasValue() >= reference_pair.hasValue() &&
2224+
assert(pair.has_value() >= reference_pair.has_value() &&
22252225
"RemoteAST and runtime diverge");
22262226

22272227
if (reference_pair) {
@@ -2862,7 +2862,7 @@ SwiftLanguageRuntimeImpl::GetValueType(ValueObject &in_value,
28622862

28632863
// An error has occurred when trying to read value witness table,
28642864
// default to treating it as pointer.
2865-
if (!is_inlined.hasValue())
2865+
if (!is_inlined.has_value())
28662866
return Value::ValueType::LoadAddress;
28672867

28682868
// Inlined data, same as static data.

lldb/source/Plugins/LanguageRuntime/Swift/SwiftMetadataCache.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ SwiftMetadataCache::SwiftMetadataCache() {
2828
}
2929
}
3030

31-
bool SwiftMetadataCache::is_enabled() { return m_data_file_cache.hasValue(); }
31+
bool SwiftMetadataCache::is_enabled() { return m_data_file_cache.has_value(); }
3232

3333
void SwiftMetadataCache::registerModuleWithReflectionInfoID(ModuleSP module,
3434
uint64_t info_id) {

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,10 +1864,10 @@ bool Equivalent(llvm::Optional<T> l, llvm::Optional<T> r) {
18641864
// There are situations where SwiftASTContext incorrectly returns
18651865
// all Clang-imported members of structs as having a size of 0, we
18661866
// thus assume that a larger number is "better".
1867-
if (l.hasValue() && r.hasValue() && *l > *r)
1867+
if (l.has_value() && r.has_value() && *l > *r)
18681868
return true;
18691869
// Assume that any value is "better" than none.
1870-
if (l.hasValue() && !r.hasValue())
1870+
if (l.has_value() && !r.has_value())
18711871
return true;
18721872
llvm::dbgs() << l << " != " << r << "\n";
18731873
return false;

lldb/unittests/Symbol/TestTypeSystemSwiftTypeRef.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ TEST_F(TestTypeSystemSwiftTypeRef, GenericSignature) {
825825
{
826826
auto maybe_signature = SwiftLanguageRuntime::GetGenericSignature(
827827
"$s1a2f42usyx_q_txQp_tq_Rhzr0_lF", *m_swift_ts);
828-
ASSERT_TRUE(maybe_signature.hasValue());
828+
ASSERT_TRUE(maybe_signature.has_value());
829829
auto s = *maybe_signature;
830830
ASSERT_EQ(s.generic_params.size(), 2);
831831
ASSERT_EQ(s.generic_params[0].depth, 0);
@@ -838,7 +838,7 @@ TEST_F(TestTypeSystemSwiftTypeRef, GenericSignature) {
838838
{
839839
auto maybe_signature = SwiftLanguageRuntime::GetGenericSignature(
840840
"$s1a1SV1f2ts1vqd_1_qd__qd__Qp_qd_0_tr1_lF", *m_swift_ts);
841-
ASSERT_TRUE(maybe_signature.hasValue());
841+
ASSERT_TRUE(maybe_signature.has_value());
842842
auto s = *maybe_signature;
843843
ASSERT_EQ(s.generic_params.size(), 3);
844844
ASSERT_EQ(s.generic_params[0].depth, 1);
@@ -859,7 +859,7 @@ TEST_F(TestTypeSystemSwiftTypeRef, GenericSignature) {
859859
// define swiftcc void @"$s1a2f12tsyxxQp_tlF"(%swift.opaque** noalias nocapture %0, i64 %1, %swift.type** %T)
860860
auto maybe_signature = SwiftLanguageRuntime::GetGenericSignature(
861861
"$s1a2f12tsyxxQp_tlF", *m_swift_ts);
862-
ASSERT_TRUE(maybe_signature.hasValue());
862+
ASSERT_TRUE(maybe_signature.has_value());
863863
auto s = *maybe_signature;
864864
ASSERT_EQ(s.generic_params.size(), 1);
865865
ASSERT_EQ(s.pack_expansions.size(), 1);
@@ -873,7 +873,7 @@ TEST_F(TestTypeSystemSwiftTypeRef, GenericSignature) {
873873
// define swiftcc void @"$s1a2f22us2vsyxxQp_q_q_Qptr0_lF"(%swift.opaque** noalias nocapture %0, %swift.opaque** noalias nocapture %1, i64 %2, i64 %3, %swift.type** %U, %swift.type** %V)
874874
auto maybe_signature = SwiftLanguageRuntime::GetGenericSignature(
875875
"$s1a2f22us2vsyxxQp_q_q_Qptr0_lF", *m_swift_ts);
876-
ASSERT_TRUE(maybe_signature.hasValue());
876+
ASSERT_TRUE(maybe_signature.has_value());
877877
auto s = *maybe_signature;
878878
ASSERT_EQ(s.generic_params.size(), 2);
879879
ASSERT_EQ(s.pack_expansions.size(), 2);
@@ -890,7 +890,7 @@ TEST_F(TestTypeSystemSwiftTypeRef, GenericSignature) {
890890

891891
auto maybe_signature = SwiftLanguageRuntime::GetGenericSignature(
892892
"$s1a2f32ts05more_B0yxxQp_xxQptlF", *m_swift_ts);
893-
ASSERT_TRUE(maybe_signature.hasValue());
893+
ASSERT_TRUE(maybe_signature.has_value());
894894
auto s = *maybe_signature;
895895
ASSERT_EQ(s.generic_params.size(), 1);
896896
ASSERT_EQ(s.pack_expansions.size(), 2);
@@ -906,7 +906,7 @@ TEST_F(TestTypeSystemSwiftTypeRef, GenericSignature) {
906906

907907
auto maybe_signature = SwiftLanguageRuntime::GetGenericSignature(
908908
"$s1a2f42usyx_q_txQp_tq_Rhzr0_lF", *m_swift_ts);
909-
ASSERT_TRUE(maybe_signature.hasValue());
909+
ASSERT_TRUE(maybe_signature.has_value());
910910
auto s = *maybe_signature;
911911
ASSERT_EQ(s.generic_params.size(), 2);
912912
ASSERT_EQ(s.pack_expansions.size(), 1);
@@ -922,7 +922,7 @@ TEST_F(TestTypeSystemSwiftTypeRef, GenericSignature) {
922922

923923
auto maybe_signature = SwiftLanguageRuntime::GetGenericSignature(
924924
"$s1a2f52tsyx_q_txQp_tr0_lF", *m_swift_ts);
925-
ASSERT_TRUE(maybe_signature.hasValue());
925+
ASSERT_TRUE(maybe_signature.has_value());
926926
auto s = *maybe_signature;
927927
ASSERT_EQ(s.generic_params.size(), 2);
928928
ASSERT_EQ(s.pack_expansions.size(), 1);
@@ -939,7 +939,7 @@ TEST_F(TestTypeSystemSwiftTypeRef, GenericSignature) {
939939

940940
auto maybe_signature = SwiftLanguageRuntime::GetGenericSignature(
941941
"$s1a2f62us05more_B02vsyxxQp_xxQpq_q_Qptr0_lF", *m_swift_ts);
942-
ASSERT_TRUE(maybe_signature.hasValue());
942+
ASSERT_TRUE(maybe_signature.has_value());
943943
auto s = *maybe_signature;
944944
ASSERT_EQ(s.generic_params.size(), 2);
945945
ASSERT_EQ(s.pack_expansions.size(), 3);
@@ -959,7 +959,7 @@ TEST_F(TestTypeSystemSwiftTypeRef, GenericSignature) {
959959
auto maybe_signature = SwiftLanguageRuntime::GetGenericSignature(
960960
"$s1a2f72us2vs05more_B00d1_C0yxxQp_q_q_QpxxQpq_q_Qptr0_lF",
961961
*m_swift_ts);
962-
ASSERT_TRUE(maybe_signature.hasValue());
962+
ASSERT_TRUE(maybe_signature.has_value());
963963
auto s = *maybe_signature;
964964
ASSERT_EQ(s.generic_params.size(), 2);
965965
ASSERT_EQ(s.pack_expansions.size(), 4);
@@ -981,7 +981,7 @@ TEST_F(TestTypeSystemSwiftTypeRef, GenericSignature) {
981981
//}
982982
auto maybe_signature = SwiftLanguageRuntime::GetGenericSignature(
983983
"$s1t1CC1fyyqd__lF", *m_swift_ts);
984-
ASSERT_TRUE(maybe_signature.hasValue());
984+
ASSERT_TRUE(maybe_signature.has_value());
985985
auto s = *maybe_signature;
986986
// "U" does not count.
987987
ASSERT_EQ(s.dependent_generic_param_count, 1);
@@ -997,7 +997,7 @@ TEST_F(TestTypeSystemSwiftTypeRef, GenericSignature) {
997997
//}
998998
auto maybe_signature = SwiftLanguageRuntime::GetGenericSignature(
999999
"$s1t1CC1fyyx_qd__tlF", *m_swift_ts);
1000-
ASSERT_TRUE(maybe_signature.hasValue());
1000+
ASSERT_TRUE(maybe_signature.has_value());
10011001
auto s = *maybe_signature;
10021002
ASSERT_EQ(s.dependent_generic_param_count, 1);
10031003
ASSERT_EQ(s.generic_params.size(), 2);
@@ -1010,6 +1010,6 @@ TEST_F(TestTypeSystemSwiftTypeRef, GenericSignature) {
10101010
// public func f() {}
10111011
auto maybe_signature = SwiftLanguageRuntime::GetGenericSignature(
10121012
"$s1t1fyyF", *m_swift_ts);
1013-
ASSERT_FALSE(maybe_signature.hasValue());
1013+
ASSERT_FALSE(maybe_signature.has_value());
10141014
}
10151015
}

0 commit comments

Comments
 (0)