Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[demangler] Enhance demangling in llvm-cxxfilt for fixed-point types. #114257

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions libcxxabi/src/demangle/ItaniumDemangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -4331,6 +4331,101 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() {
return nullptr;
return make<BinaryFPType>(DimensionNumber);
}
// ::= [DS] DA # N1169 fixed-point [_Sat] T _Accum
// ::= [DS] DR # N1169 fixed-point [_Sat] T _Frac
// <fixed-point-size>
// ::= s # short
// ::= t # unsigned short
// ::= i # plain
// ::= j # unsigned
// ::= l # long
// ::= m # unsigned long
case 'A': {
char c = look(2);
First += 3;
switch (c) {
case 's':
return make<NameType>("short _Accum");
case 't':
return make<NameType>("unsigned short _Accum");
case 'i':
return make<NameType>("_Accum");
case 'j':
return make<NameType>("unsigned _Accum");
case 'l':
return make<NameType>("long _Accum");
case 'm':
return make<NameType>("unsigned long _Accum");
default:
return nullptr;
}
}
case 'R': {
char c = look(2);
First += 3;
switch (c) {
case 's':
return make<NameType>("short _Fract");
case 't':
return make<NameType>("unsigned short _Fract");
case 'i':
return make<NameType>("_Fract");
case 'j':
return make<NameType>("unsigned _Fract");
case 'l':
return make<NameType>("long _Fract");
case 'm':
return make<NameType>("unsigned long _Fract");
default:
return nullptr;
}
}
case 'S': {
First += 2;
if (look() != 'D')
return nullptr;
if (look(1) == 'A') {
char c = look(2);
First += 3;
switch (c) {
case 's':
return make<NameType>("_Sat short _Accum");
case 't':
return make<NameType>("_Sat unsigned short _Accum");
case 'i':
return make<NameType>("_Sat _Accum");
case 'j':
return make<NameType>("_Sat unsigned _Accum");
case 'l':
return make<NameType>("_Sat long _Accum");
case 'm':
return make<NameType>("_Sat unsigned long _Accum");
default:
return nullptr;
}
}
if (look(1) == 'R') {
char c = look(2);
First += 3;
switch (c) {
case 's':
return make<NameType>("_Sat short _Fract");
case 't':
return make<NameType>("_Sat unsigned short _Fract");
case 'i':
return make<NameType>("_Sat _Fract");
case 'j':
return make<NameType>("_Sat unsigned _Fract");
case 'l':
return make<NameType>("_Sat long _Fract");
case 'm':
return make<NameType>("_Sat unsigned long _Fract");
default:
return nullptr;
}
}
return nullptr;
}
// ::= DB <number> _ # C23 signed _BitInt(N)
// ::= DB <instantiation-dependent expression> _ # C23 signed _BitInt(N)
// ::= DU <number> _ # C23 unsigned _BitInt(N)
Expand Down
95 changes: 95 additions & 0 deletions llvm/include/llvm/Demangle/ItaniumDemangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -4331,6 +4331,101 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() {
return nullptr;
return make<BinaryFPType>(DimensionNumber);
}
// ::= [DS] DA # N1169 fixed-point [_Sat] T _Accum
// ::= [DS] DR # N1169 fixed-point [_Sat] T _Frac
// <fixed-point-size>
// ::= s # short
// ::= t # unsigned short
// ::= i # plain
// ::= j # unsigned
// ::= l # long
// ::= m # unsigned long
case 'A': {
char c = look(2);
First += 3;
switch (c) {
case 's':
return make<NameType>("short _Accum");
case 't':
return make<NameType>("unsigned short _Accum");
case 'i':
return make<NameType>("_Accum");
case 'j':
return make<NameType>("unsigned _Accum");
case 'l':
return make<NameType>("long _Accum");
case 'm':
return make<NameType>("unsigned long _Accum");
default:
return nullptr;
}
}
case 'R': {
char c = look(2);
First += 3;
switch (c) {
case 's':
return make<NameType>("short _Fract");
case 't':
return make<NameType>("unsigned short _Fract");
case 'i':
return make<NameType>("_Fract");
case 'j':
return make<NameType>("unsigned _Fract");
case 'l':
return make<NameType>("long _Fract");
case 'm':
return make<NameType>("unsigned long _Fract");
default:
return nullptr;
}
}
case 'S': {
First += 2;
if (look() != 'D')
return nullptr;
if (look(1) == 'A') {
char c = look(2);
First += 3;
switch (c) {
case 's':
return make<NameType>("_Sat short _Accum");
case 't':
return make<NameType>("_Sat unsigned short _Accum");
case 'i':
return make<NameType>("_Sat _Accum");
case 'j':
return make<NameType>("_Sat unsigned _Accum");
case 'l':
return make<NameType>("_Sat long _Accum");
case 'm':
return make<NameType>("_Sat unsigned long _Accum");
default:
return nullptr;
}
}
if (look(1) == 'R') {
char c = look(2);
First += 3;
switch (c) {
case 's':
return make<NameType>("_Sat short _Fract");
case 't':
return make<NameType>("_Sat unsigned short _Fract");
case 'i':
return make<NameType>("_Sat _Fract");
case 'j':
return make<NameType>("_Sat unsigned _Fract");
case 'l':
return make<NameType>("_Sat long _Fract");
case 'm':
return make<NameType>("_Sat unsigned long _Fract");
default:
return nullptr;
}
}
return nullptr;
}
// ::= DB <number> _ # C23 signed _BitInt(N)
// ::= DB <instantiation-dependent expression> _ # C23 signed _BitInt(N)
// ::= DU <number> _ # C23 unsigned _BitInt(N)
Expand Down
103 changes: 64 additions & 39 deletions llvm/unittests/Demangle/PartialDemangleTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,70 @@ struct ChoppedName {
};

static ChoppedName NamesToTest[] = {
{"_Z1fv", "", "f", "", "()"},
{"_ZN1a1b1cIiiiEEvm", "a::b", "c", "void", "(unsigned long)"},
{"_ZZ5OuterIiEivEN5Inner12inner_memberEv",
"int Outer<int>()::Inner", "inner_member", "", "()"},
{"_Z1fIiEPFvvEv", "", "f", "void (*)()", "()"},
{"_ZN1S1fIiEEvv", "S", "f", "void", "()"},

// Call operator for a lambda in f().
{"_ZZ1fvENK3$_0clEi", "f()::$_0", "operator()", "", "(int)"},

// A call operator for a lambda in a lambda in f().
{"_ZZZ1fvENK3$_0clEvENKUlvE_clEv",
"f()::$_0::operator()() const::'lambda'()", "operator()", "", "()"},

{"_ZZN1S1fEiiEd0_NKUlvE_clEv",
"S::f(int, int)::'lambda'()", "operator()", "", "()"},

{"_ZN1Scv7MuncherIJDpPT_EEIJFivEA_iEEEv",
"S", "operator Muncher<int (*)(), int (*) []>", "", "()"},

// Attributes.
{"_ZN5test4IdE1fEUa9enable_ifIXeqfL0p_Li1EEXeqfL0p0_Li2EEEi",
"test4<double>", "f", "", "(int)"},
{"_ZN1SC2B8ctor_tagEv", "S", "S", "", "()"},
{"_ZN1S1fB4MERPIiEEvv", "S", "f", "void", "()"},

{"_ZNSsC1EmcRKSaIcE",
"std::basic_string<char, std::char_traits<char>, std::allocator<char>>",
"basic_string", "", "(unsigned long, char, std::allocator<char> const&)"},
{"_ZNSsixEm", "std::string", "operator[]", "", "(unsigned long)"},
{"_ZSt17__throw_bad_allocv", "std", "__throw_bad_alloc", "", "()"},

{"_ZN1AI1BEC2Ev", "A<B>", "A", "", "()"},
{"_ZN1AI1BED2Ev", "A<B>", "~A", "", "()"},
{"_ZN1AI1BECI24BaseEi", "A<B>", "A", "", "(int)"},
{"_ZNKR1AI1BE1fIiEEiv", "A<B>", "f", "int", "()"},

{"_ZN1SIJicfEE3mfnIJjcdEEEvicfDpT_", "S<int, char, float>",
"mfn", "void", "(int, char, float, unsigned int, char, double)"},
{"_Z1fv", "", "f", "", "()"},
{"_ZN1a1b1cIiiiEEvm", "a::b", "c", "void", "(unsigned long)"},
{"_ZZ5OuterIiEivEN5Inner12inner_memberEv", "int Outer<int>()::Inner",
"inner_member", "", "()"},
{"_Z1fIiEPFvvEv", "", "f", "void (*)()", "()"},
{"_ZN1S1fIiEEvv", "S", "f", "void", "()"},

// Call operator for a lambda in f().
{"_ZZ1fvENK3$_0clEi", "f()::$_0", "operator()", "", "(int)"},

// A call operator for a lambda in a lambda in f().
{"_ZZZ1fvENK3$_0clEvENKUlvE_clEv",
"f()::$_0::operator()() const::'lambda'()", "operator()", "", "()"},

{"_ZZN1S1fEiiEd0_NKUlvE_clEv", "S::f(int, int)::'lambda'()", "operator()",
"", "()"},

{"_ZN1Scv7MuncherIJDpPT_EEIJFivEA_iEEEv", "S",
"operator Muncher<int (*)(), int (*) []>", "", "()"},

// Attributes.
{"_ZN5test4IdE1fEUa9enable_ifIXeqfL0p_Li1EEXeqfL0p0_Li2EEEi",
"test4<double>", "f", "", "(int)"},
{"_ZN1SC2B8ctor_tagEv", "S", "S", "", "()"},
{"_ZN1S1fB4MERPIiEEvv", "S", "f", "void", "()"},

{"_ZNSsC1EmcRKSaIcE",
"std::basic_string<char, std::char_traits<char>, std::allocator<char>>",
"basic_string", "", "(unsigned long, char, std::allocator<char> const&)"},
{"_ZNSsixEm", "std::string", "operator[]", "", "(unsigned long)"},
{"_ZSt17__throw_bad_allocv", "std", "__throw_bad_alloc", "", "()"},

{"_ZN1AI1BEC2Ev", "A<B>", "A", "", "()"},
{"_ZN1AI1BED2Ev", "A<B>", "~A", "", "()"},
{"_ZN1AI1BECI24BaseEi", "A<B>", "A", "", "(int)"},
{"_ZNKR1AI1BE1fIiEEiv", "A<B>", "f", "int", "()"},

{"_ZN1SIJicfEE3mfnIJjcdEEEvicfDpT_", "S<int, char, float>", "mfn", "void",
"(int, char, float, unsigned int, char, double)"},

{"_Z1fDAs", "", "f", "", "(short _Accum)"},
{"_Z1fDAt", "", "f", "", "(unsigned short _Accum)"},
{"_Z1fDAi", "", "f", "", "(_Accum)"},
{"_Z1fDAj", "", "f", "", "(unsigned _Accum)"},
{"_Z1fDAl", "", "f", "", "(long _Accum)"},
{"_Z1fDAm", "", "f", "", "(unsigned long _Accum)"},
{"_Z1fDRs", "", "f", "", "(short _Fract)"},
{"_Z1fDRt", "", "f", "", "(unsigned short _Fract)"},
{"_Z1fDRi", "", "f", "", "(_Fract)"},
{"_Z1fDRj", "", "f", "", "(unsigned _Fract)"},
{"_Z1fDRl", "", "f", "", "(long _Fract)"},
{"_Z1fDRm", "", "f", "", "(unsigned long _Fract)"},
{"_Z1fDSDAs", "", "f", "", "(_Sat short _Accum)"},
{"_Z1fDSDAt", "", "f", "", "(_Sat unsigned short _Accum)"},
{"_Z1fDSDAi", "", "f", "", "(_Sat _Accum)"},
{"_Z1fDSDAj", "", "f", "", "(_Sat unsigned _Accum)"},
{"_Z1fDSDAl", "", "f", "", "(_Sat long _Accum)"},
{"_Z1fDSDAm", "", "f", "", "(_Sat unsigned long _Accum)"},
{"_Z1fDSDRs", "", "f", "", "(_Sat short _Fract)"},
{"_Z1fDSDRt", "", "f", "", "(_Sat unsigned short _Fract)"},
{"_Z1fDSDRi", "", "f", "", "(_Sat _Fract)"},
{"_Z1fDSDRj", "", "f", "", "(_Sat unsigned _Fract)"},
{"_Z1fDSDRl", "", "f", "", "(_Sat long _Fract)"},
{"_Z1fDSDRm", "", "f", "", "(_Sat unsigned long _Fract)"},
};

TEST(PartialDemanglerTest, TestNameChopping) {
Expand Down
Loading