-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Fix C++ demangling for _BitInt type #143466
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
Conversation
* FE expects _BitInt to be available for substitution; ensure DB<n> is added to Subs in ItaniumDemangle.h * Add a test case to libcxxabi * Copy changed files to llvm/include/llvm/
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-libcxxabi Author: Larry Meadows (lfmeadow) Changes
Full diff: https://github.com/llvm/llvm-project/pull/143466.diff 4 Files Affected:
diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h
index 4e7f92dd1991a..b15cf03aa1f9c 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -4468,7 +4468,9 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() {
return nullptr;
if (!consumeIf('_'))
return nullptr;
- return make<BitIntType>(Size, Signed);
+ // The FE expects this to be available for Substitution
+ Result = make<BitIntType>(Size, Signed);
+ break;
}
// ::= Di # char32_t
case 'i':
diff --git a/libcxxabi/test/DemangleTestCases.inc b/libcxxabi/test/DemangleTestCases.inc
index 1e3f7459deaa2..2721d2aa5504e 100644
--- a/libcxxabi/test/DemangleTestCases.inc
+++ b/libcxxabi/test/DemangleTestCases.inc
@@ -6,6 +6,7 @@
{"_Z1fDU10_", "f(unsigned _BitInt(10))"},
{"_Z1fIfEvDUstPT__", "void f<float>(unsigned _BitInt(sizeof (float*)))"},
{"_Z1fIiEvDBstPT__", "void f<int>(_BitInt(sizeof (int*)))"},
+{"_Z6myfuncRDB8_S0_", "myfunc(_BitInt(8)&, _BitInt(8)&)"},
{"_Z4testI1A1BE1Cv", "C test<A, B>()"},
{"_Z4testI1A1BET0_T_S3_", "B test<A, B>(A, A)"},
{"_ZN1SgtEi", "S::operator>(int)"},
diff --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h
index f4569850b093c..38ac8473e3e97 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -4468,7 +4468,9 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() {
return nullptr;
if (!consumeIf('_'))
return nullptr;
- return make<BitIntType>(Size, Signed);
+ // The FE expects this to be available for Substitution
+ Result = make<BitIntType>(Size, Signed);
+ break;
}
// ::= Di # char32_t
case 'i':
diff --git a/llvm/include/llvm/Testing/Demangle/DemangleTestCases.inc b/llvm/include/llvm/Testing/Demangle/DemangleTestCases.inc
index 1e3f7459deaa2..2721d2aa5504e 100644
--- a/llvm/include/llvm/Testing/Demangle/DemangleTestCases.inc
+++ b/llvm/include/llvm/Testing/Demangle/DemangleTestCases.inc
@@ -6,6 +6,7 @@
{"_Z1fDU10_", "f(unsigned _BitInt(10))"},
{"_Z1fIfEvDUstPT__", "void f<float>(unsigned _BitInt(sizeof (float*)))"},
{"_Z1fIiEvDBstPT__", "void f<int>(_BitInt(sizeof (int*)))"},
+{"_Z6myfuncRDB8_S0_", "myfunc(_BitInt(8)&, _BitInt(8)&)"},
{"_Z4testI1A1BE1Cv", "C test<A, B>()"},
{"_Z4testI1A1BET0_T_S3_", "B test<A, B>(A, A)"},
{"_ZN1SgtEi", "S::operator>(int)"},
|
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.
Looks reasonable, thank you. But I am not a maintainer for the demangler, so I would recommend to also request a review from someone in the owners list.
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 mentioning me here. But AFAIK, _BitInt and _FloatN were not candidates for substitution by c++abi. Are there any updates now? I once made a proposal to fix the ABI but wasn't merged. See also: https://reviews.llvm.org/D140359 |
Is Clang treating these as substitution candidates, and for how long? |
@zsrkmyn, I got a notification about a response you made, but I don't see it here anymore. I think you're saying that this is not so much a fix as a change intended to unblock a future clang change. But in either case, we seem to have a serious problem if we're retroactively changing the mangling rules for |
@rjmccall Sorry, I posted a comment but just found that I was wrong, so I deleted it. I believe you were questioning about how long clang mangler treated these as substitute candidates, but I was answering about demangler. I haven't worked with |
improve comment
Improve comment
I did not look into how long the FE has been making _BitInt substitutable. I will look into it. |
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.
I assumed that Clang already produced these manglings. I'd like to have clarity on whether we already do produce these manglings, otherwise this change may indeed never be required. @lfmeadow Can you chime in?
Yes, clang does produce the mangling for _BitInt, and it does not demangle properly without this change. It's been there for quite some time, with a broken demangler. |
@ldionne Are you satisfied with my response, or do you need me to try to figure out when/where clang started producing these manglings? |
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.
I think this is fine, then.
@lfmeadow Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
Thanks, yeah, that was what I was asking. If clang is producing manglings that assume that this is substitutable, seems like this should be accepted. |
@rjmccall I would suggest updating itanium abi as well :-D |
The front-end expects _BitInt to be available for substitution; ensure DB<n> is added to Subs in ItaniumDemangle.h. Also add a test case to libc++abi and sync the files to llvm/include/llvm.
The front-end expects _BitInt to be available for substitution; ensure DB<n> is added to Subs in ItaniumDemangle.h. Also add a test case to libc++abi and sync the files to llvm/include/llvm.
Uh oh!
There was an error while loading. Please reload this page.