Skip to content

Commit

Permalink
Allow inheriting constructor types to be substitution candidates.
Browse files Browse the repository at this point in the history
Fixes #286.
  • Loading branch information
khuey committed Aug 11, 2023
1 parent 04954c0 commit 963883e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3277,13 +3277,13 @@ impl Parse for VOffset {
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum CtorDtorName {
/// "C1", the "complete object constructor"
CompleteConstructor(Option<Box<Name>>),
CompleteConstructor(Option<TypeHandle>),
/// "C2", the "base object constructor"
BaseConstructor(Option<Box<Name>>),
BaseConstructor(Option<TypeHandle>),
/// "C3", the "complete object allocating constructor"
CompleteAllocatingConstructor(Option<Box<Name>>),
CompleteAllocatingConstructor(Option<TypeHandle>),
/// "C4", the "maybe in-charge constructor"
MaybeInChargeConstructor(Option<Box<Name>>),
MaybeInChargeConstructor(Option<TypeHandle>),
/// "D0", the "deleting destructor"
DeletingDestructor,
/// "D1", the "complete object destructor"
Expand All @@ -3295,7 +3295,7 @@ pub enum CtorDtorName {
}

impl CtorDtorName {
fn inheriting_mut(&mut self) -> &mut Option<Box<Name>> {
fn inheriting_mut(&mut self) -> &mut Option<TypeHandle> {
match self {
CtorDtorName::CompleteConstructor(ref mut inheriting)
| CtorDtorName::BaseConstructor(ref mut inheriting)
Expand Down Expand Up @@ -3354,8 +3354,8 @@ impl Parse for CtorDtorName {
}?;

if inheriting {
let (ty, tail) = Name::parse(ctx, subs, tail)?;
*ctor_type.inheriting_mut() = Some(Box::new(ty));
let (ty, tail) = TypeHandle::parse(ctx, subs, tail)?;
*ctor_type.inheriting_mut() = Some(ty);
Ok((ctor_type, tail))
} else {
Ok((ctor_type, tail))
Expand Down
6 changes: 6 additions & 0 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,12 @@ demangles!(
"nsresult mozilla::extensions::AtomSet::Get<&(mozilla::extensions::WILDCARD_SCHEMES.<char const* at offset 0>)>(RefPtr<mozilla::extensions::AtomSet>&)"
);

// Test that inheriting constructor types are eligible for substitution.
demangles!(
_ZN6deluge3gui9menu_item15MasterTransposeCI18MenuItemERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESB_,
"deluge::gui::menu_item::MasterTranspose::MenuItem(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)"
);

// This symbol previously ran into some mutual recursion and unbounded growth of the substitution table.
// See <https://github.com/gimli-rs/cpp_demangle/issues/277> and <https://github.com/getsentry/symbolic/issues/477>
#[test]
Expand Down

0 comments on commit 963883e

Please sign in to comment.