-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
c8ef
wants to merge
2
commits into
llvm:main
Choose a base branch
from
c8ef:demangle
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+254
−39
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-libcxxabi Author: None (c8ef) ChangesThis patch adds support for fixed-point type in demanger. Closes #114090. Full diff: https://github.com/llvm/llvm-project/pull/114257.diff 3 Files Affected:
diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h
index 501d0b6fdfcd16..52755e6f851032 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -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)
diff --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h
index 56ff3cfb148f09..3dfe838bf5fd2d 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -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)
diff --git a/llvm/unittests/Demangle/PartialDemangleTest.cpp b/llvm/unittests/Demangle/PartialDemangleTest.cpp
index 60193cdf9e1ace..9cb26c47d8f243 100644
--- a/llvm/unittests/Demangle/PartialDemangleTest.cpp
+++ b/llvm/unittests/Demangle/PartialDemangleTest.cpp
@@ -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) {
|
PiJoules
approved these changes
Oct 30, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking this. LGTM for the llvm/
changes.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch adds support for fixed-point type in demanger.
Closes #114090.