[llvm-branch-commits] [libcxxabi] [libc++abi] Make the dst_type uniqueness flag in dynamic_cast a bool (PR #243530)
Nikolas Klauser via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Nov 19 02:17:53 PST 2026
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/243530
>From e1994608717df1c425b280c20f73afe3c3da1290 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Tue, 17 Nov 2026 17:40:38 +0100
Subject: [PATCH] [libc++abi] Make the dst_type uniqueness flag in dynamic_cast
a bool
---
libcxxabi/src/private_typeinfo.cpp | 13 ++++++-------
libcxxabi/src/private_typeinfo.h | 4 ++--
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/libcxxabi/src/private_typeinfo.cpp b/libcxxabi/src/private_typeinfo.cpp
index 279eb0fc22969..7d30d86b449bb 100644
--- a/libcxxabi/src/private_typeinfo.cpp
+++ b/libcxxabi/src/private_typeinfo.cpp
@@ -179,7 +179,7 @@ const void* dyn_cast_to_derived(
0,
0,
true,
- 1, // number_of_dst_type
+ true, // has_unique_dst_type
false,
false};
// Do the search
@@ -214,11 +214,10 @@ const void* dyn_cast_to_derived(
0,
0,
true,
- 0,
+ true, // has_unique_dst_type
false,
false};
- info.number_of_dst_type = 1;
- res = dst_type->search_above_dst<true>(&info, dynamic_ptr, dynamic_ptr, path_kind::public_path);
+ res = dst_type->search_above_dst<true>(&info, dynamic_ptr, dynamic_ptr, path_kind::public_path);
}
#endif // _LIBCXXABI_FORGIVING_DYNAMIC_CAST
switch (res) {
@@ -269,7 +268,7 @@ const void* dyn_cast_try_downcast(
0,
0,
true,
- 1, // number_of_dst_type
+ true, // has_unique_dst_type
false,
false};
result res =
@@ -926,7 +925,7 @@ result __class_type_info::process_static_type_above_dst(
info->has_path_to_static_ptr = true;
// If there is only one dst_type in the entire tree and the path from
// there to here is public then we are done!
- return info->number_of_dst_type == 1 && info->path_dst_ptr_to_static_ptr == path_kind::public_path
+ return info->has_unique_dst_type && info->path_dst_ptr_to_static_ptr == path_kind::public_path
? result::success
: result::unknown;
} else if (info->dst_ptr_leading_to_static_ptr == dst_ptr) {
@@ -935,7 +934,7 @@ result __class_type_info::process_static_type_above_dst(
info->path_dst_ptr_to_static_ptr = path_below;
// If there is only one dst_type in the entire tree and the path from
// there to here is public then we are done!
- return info->number_of_dst_type == 1 && info->path_dst_ptr_to_static_ptr == path_kind::public_path
+ return info->has_unique_dst_type && info->path_dst_ptr_to_static_ptr == path_kind::public_path
? result::success
: result::unknown;
} else {
diff --git a/libcxxabi/src/private_typeinfo.h b/libcxxabi/src/private_typeinfo.h
index 9a6e0b1a893be..60865c1894972 100644
--- a/libcxxabi/src/private_typeinfo.h
+++ b/libcxxabi/src/private_typeinfo.h
@@ -108,8 +108,8 @@ struct _LIBCXXABI_HIDDEN __dynamic_cast_info {
// Data that helps stop the search before the entire tree is searched:
bool dst_type_might_be_derived_from_static_type;
- // Number of dst_type in tree. If 0, then that means unknown.
- int number_of_dst_type;
+ // Whether we know that there is a unique dst_type in the graph.
+ bool has_unique_dst_type;
// communicates to a dst_type node that (static_ptr, static_type) was found
// above it.
bool found_our_static_ptr;
More information about the llvm-branch-commits
mailing list