@@ -1328,7 +1328,7 @@ template <typename T> bool Equivalent(T l, T r) {
1328
1328
1329
1329
// / Specialization for GetTypeInfo().
1330
1330
template <> bool Equivalent<uint32_t >(uint32_t l, uint32_t r) {
1331
- if (l < r) {
1331
+ if (l != r) {
1332
1332
// Failure. Dump it for easier debugging.
1333
1333
llvm::dbgs () << " TypeSystemSwiftTypeRef diverges from SwiftASTContext:\n " ;
1334
1334
#define HANDLE_ENUM_CASE (VAL, CASE ) \
@@ -1399,7 +1399,7 @@ template <> bool Equivalent<uint32_t>(uint32_t l, uint32_t r) {
1399
1399
HANDLE_ENUM_CASE (r, eTypeIsBound);
1400
1400
llvm::dbgs () << " \n " ;
1401
1401
}
1402
- return l > = r;
1402
+ return l = = r;
1403
1403
}
1404
1404
1405
1405
// / Determine wether this demangle tree contains a sugar () node.
@@ -1508,10 +1508,9 @@ template <> bool Equivalent<ConstString>(ConstString l, ConstString r) {
1508
1508
return l == r;
1509
1509
}
1510
1510
1511
- // / Version taylored to GetBitSize & friends.
1512
- template <>
1513
- bool Equivalent<llvm::Optional<uint64_t >>(llvm::Optional<uint64_t > l,
1514
- llvm::Optional<uint64_t > r) {
1511
+ // / Version tailored to GetBitSize & friends.
1512
+ template <typename T>
1513
+ bool Equivalent (llvm::Optional<T> l, llvm::Optional<T> r) {
1515
1514
if (l == r)
1516
1515
return true ;
1517
1516
// There are situations where SwiftASTContext incorrectly returns
@@ -1526,6 +1525,12 @@ bool Equivalent<llvm::Optional<uint64_t>>(llvm::Optional<uint64_t> l,
1526
1525
return false ;
1527
1526
}
1528
1527
1528
+ // Introduced for `GetNumChildren`.
1529
+ template <typename T>
1530
+ bool Equivalent (llvm::Optional<T> l, T r) {
1531
+ return Equivalent (l, llvm::Optional<T>(r));
1532
+ }
1533
+
1529
1534
} // namespace
1530
1535
#endif
1531
1536
@@ -2079,10 +2084,13 @@ TypeSystemSwiftTypeRef::GetNumChildren(opaque_compiler_type_t type,
2079
2084
SwiftLanguageRuntime::Get (exe_scope->CalculateProcess ()))
2080
2085
if (auto num_children =
2081
2086
runtime->GetNumChildren (GetCanonicalType (type), nullptr )) {
2082
- auto impl = [&]() -> uint32_t { return *num_children; };
2083
- VALIDATE_AND_RETURN (
2084
- impl, GetNumChildren, type,
2085
- (ReconstructType (type), omit_empty_base_classes, exe_ctx));
2087
+ // Use lambda to intercept and unwrap the `Optional` return value.
2088
+ return [&]() {
2089
+ auto impl = [&]() { return num_children; };
2090
+ VALIDATE_AND_RETURN (
2091
+ impl, GetNumChildren, type,
2092
+ (ReconstructType (type), omit_empty_base_classes, exe_ctx));
2093
+ }().getValue ();
2086
2094
}
2087
2095
2088
2096
LLDB_LOGF (GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES),
0 commit comments