Skip to content

Commit

Permalink
Add support for fixed-point types
Browse files Browse the repository at this point in the history
  • Loading branch information
Saldivarcher committed Dec 15, 2024
1 parent 15bbde1 commit 157316d
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4054,6 +4054,15 @@ define_vocabulary! {
/// ::= Da # auto
/// ::= Dc # decltype(auto)
/// ::= Dn # std::nullptr_t (i.e., decltype(nullptr))
/// ::= [DS] DA # N1169 fixed-point [_Sat] T _Accum
/// ::= [DS] DR # N1169 fixed-point [_Sat] T _Fract
///
/// <fixed-point-size> ::= s # short
/// ::= t # unsigned short
/// ::= i # plain
/// ::= j # unsigned
/// ::= l # long
/// ::= m # unsigned long
/// ```
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum StandardBuiltinType {
Expand Down Expand Up @@ -4088,7 +4097,31 @@ define_vocabulary! {
Char8 (b"Du", "char8_t"),
Auto (b"Da", "auto"),
Decltype (b"Dc", "decltype(auto)"),
Nullptr (b"Dn", "std::nullptr_t")
Nullptr (b"Dn", "std::nullptr_t"),
AccumShort (b"DAs", "short _Accum"),
AccumUShort (b"DAt", "unsigned short _Accum"),
Accum (b"DAi", "_Accum"),
AccumUnsigned (b"DAj", "unsigned _Accum"),
AccumLong (b"DAl", "long _Accum"),
AccumULong (b"DAm", "unsigned long _Accum"),
FractShort (b"DRs", "short _Fract"),
FractUShort (b"DRt", "unsigned short _Fract"),
Fract (b"DRi", "_Fract"),
FractUnsigned (b"DRj", "unsigned _Fract"),
FractLong (b"DRl", "long _Fract"),
FractULong (b"DRm", "unsigned long _Fract"),
SatAccumShort (b"DSDAs", "_Sat short _Accum"),
SatAccumUShort (b"DSDAt", "_Sat unsigned short _Accum"),
SatAccum (b"DSDAi", "_Sat _Accum"),
SatAccumUnsigned (b"DSDAj", "_Sat unsigned _Accum"),
SatAccumLong (b"DSDAl", "_Sat long _Accum"),
SatAccumULong (b"DSDAm", "_Sat unsigned long _Accum"),
SatFractShort (b"DSDRs", "_Sat short _Fract"),
SatFractUShort (b"DSDRt", "_Sat unsigned short _Fract"),
SatFract (b"DSDRi", "_Sat _Fract"),
SatFractUnsigned (b"DSDRj", "_Sat unsigned _Fract"),
SatFractLong (b"DSDRl", "_Sat long _Fract"),
SatFractULong (b"DSDRm", "_Sat unsigned long _Fract")
}
}

Expand Down
26 changes: 26 additions & 0 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,32 @@ demangles!(
"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&)"
);

// fixed-point types as defined in the N1169 draft of ISO/IEC DTR 18037
demangles!(_Z1fDAs, "f(short _Accum)");
demangles!(_Z1fDAt, "f(unsigned short _Accum)");
demangles!(_Z1fDAi, "f(_Accum)");
demangles!(_Z1fDAj, "f(unsigned _Accum)");
demangles!(_Z1fDAl, "f(long _Accum)");
demangles!(_Z1fDAm, "f(unsigned long _Accum)");
demangles!(_Z1fDRs, "f(short _Fract)");
demangles!(_Z1fDRt, "f(unsigned short _Fract)");
demangles!(_Z1fDRi, "f(_Fract)");
demangles!(_Z1fDRj, "f(unsigned _Fract)");
demangles!(_Z1fDRl, "f(long _Fract)");
demangles!(_Z1fDRm, "f(unsigned long _Fract)");
demangles!(_Z1fDSDAs, "f(_Sat short _Accum)");
demangles!(_Z1fDSDAt, "f(_Sat unsigned short _Accum)");
demangles!(_Z1fDSDAi, "f(_Sat _Accum)");
demangles!(_Z1fDSDAj, "f(_Sat unsigned _Accum)");
demangles!(_Z1fDSDAl, "f(_Sat long _Accum)");
demangles!(_Z1fDSDAm, "f(_Sat unsigned long _Accum)");
demangles!(_Z1fDSDRs, "f(_Sat short _Fract)");
demangles!(_Z1fDSDRt, "f(_Sat unsigned short _Fract)");
demangles!(_Z1fDSDRi, "f(_Sat _Fract)");
demangles!(_Z1fDSDRj, "f(_Sat unsigned _Fract)");
demangles!(_Z1fDSDRl, "f(_Sat long _Fract)");
demangles!(_Z1fDSDRm, "f(_Sat unsigned long _Fract)");

// 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 157316d

Please sign in to comment.