This is an archive of the discontinued LLVM Phabricator instance.

[demangler] Support C23 _BitInt type
ClosedPublic

Authored by zsrkmyn on Mar 26 2022, 10:02 AM.

Diff Detail

Event Timeline

zsrkmyn created this revision.Mar 26 2022, 10:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 26 2022, 10:02 AM
zsrkmyn requested review of this revision.Mar 26 2022, 10:02 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMar 26 2022, 10:02 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript

Thank you for this! It looks correct to me, but the changes should probably come with some test coverage as well.

Thank you for this! It looks correct to me, but the changes should probably come with some test coverage as well.

There are actually some tests in libcxxabi/test/test_demangle.pass.cpp, but since the file is too large, phab folds it as a binary file :-(

zsrkmyn updated this revision to Diff 418486.Mar 27 2022, 7:57 PM

Update match function

Thank you for this! It looks correct to me, but the changes should probably come with some test coverage as well.

There are actually some tests in libcxxabi/test/test_demangle.pass.cpp, but since the file is too large, phab folds it as a binary file :-(

Oh wow, I've never seen that happen before, thanks for letting me know!

aaron.ballman accepted this revision.Mar 28 2022, 4:06 AM

LGTM! Please be sure to wait for someone from libcxxabi to approve before landing, though.

Thank you for this! It looks correct to me, but the changes should probably come with some test coverage as well.

There are actually some tests in libcxxabi/test/test_demangle.pass.cpp, but since the file is too large, phab folds it as a binary file :-(

yeah, that's getting problematic. I wonder if we should break out all the testcases to a set of files in a subdir that the testprogram reads?

I wonder if there is value, for backwards compatibility to ALSO parse the old _ExtInt mangling?

urnathan added inline comments.Mar 28 2022, 6:55 AM
libcxxabi/src/demangle/ItaniumDemangle.h
498–500

Now that D120905 is landed please reword this as

OB += "_BitInt";
OB.printOpen();
Size->printAsOperand(OB);
OB.printClose();

(See NoexceptSpec as an example). This will handle parens inside Size if this is inside template arg list.

zsrkmyn updated this revision to Diff 418581.Mar 28 2022, 7:31 AM
zsrkmyn updated this revision to Diff 418584.Mar 28 2022, 7:36 AM
zsrkmyn marked an inline comment as done.EditedMar 28 2022, 7:42 AM

I wonder if there is value, for backwards compatibility to ALSO parse the old _ExtInt mangling?

@erichkeane, I'm not sure what _ExtInt was mangled to in the past, but it now is also mangled as DB/DU using the latest clang, so it's enough to demangle DB and DU IMO.

$ echo 'int foo(_ExtInt(3), unsigned _ExtInt(5)) {}' | ./builds/dev/bin/clang -S -emit-llvm -xc++ - -o - 2>/dev/null | grep '^define'
define dso_local noundef i32 @_Z3fooDB3_DU5_(i3 noundef signext %0, i5 noundef zeroext %1) #0 {

@aaron.ballman, I also uploaded the test as a small diff using the web interface (instead of the whole file uploaded by arc), so we can see the test change now :-)

libcxxabi/src/demangle/ItaniumDemangle.h
498–500

Done. Thanks!

I wonder if there is value, for backwards compatibility to ALSO parse the old _ExtInt mangling?

@erichkeane, I'm not sure what _ExtInt was mangled to in the past, but it now is also mangled as DB/DU using the latest clang, so it's enough to demangle DB and DU IMO.

I went to look it up, we used to mangle it as a 'struct', so it demangled anyway (so _ExtInt13 was : U7_ExtIntILi13, so void foo(_ExtInt(13)) was _Z3fooU7_ExtIntILi13EEi.

$ echo 'int foo(_ExtInt(3), unsigned _ExtInt(5)) {}' | ./builds/dev/bin/clang -S -emit-llvm -xc++ - -o - 2>/dev/null | grep '^define'
define dso_local noundef i32 @_Z3fooDB3_DU5_(i3 noundef signext %0, i5 noundef zeroext %1) #0 {

@aaron.ballman, I also uploaded the test as a small diff using the web interface (instead of the whole file uploaded by arc), so we can see the test change now :-)

zsrkmyn marked an inline comment as done.Mar 28 2022, 7:58 AM

I wonder if there is value, for backwards compatibility to ALSO parse the old _ExtInt mangling?

@erichkeane, I'm not sure what _ExtInt was mangled to in the past, but it now is also mangled as DB/DU using the latest clang, so it's enough to demangle DB and DU IMO.

I went to look it up, we used to mangle it as a 'struct', so it demangled anyway (so _ExtInt13 was : U7_ExtIntILi13, so void foo(_ExtInt(13)) was _Z3fooU7_ExtIntILi13EEi.

Thanks for explaination! So we don't need to make changes, right?

I wonder if there is value, for backwards compatibility to ALSO parse the old _ExtInt mangling?

@erichkeane, I'm not sure what _ExtInt was mangled to in the past, but it now is also mangled as DB/DU using the latest clang, so it's enough to demangle DB and DU IMO.

I went to look it up, we used to mangle it as a 'struct', so it demangled anyway (so _ExtInt13 was : U7_ExtIntILi13, so void foo(_ExtInt(13)) was _Z3fooU7_ExtIntILi13EEi.

Thanks for explaination! So we don't need to make changes, right?

Correct, I don't believe so. Sorry for the distraction/digression.

@ldionne, may I get your comments or approval? Thanks!

A soft ping.

@urnathan @ldionne, may I get your comments or approval? Thanks!

urnathan accepted this revision.Apr 6 2022, 4:40 AM

looks good. You'll need to adjust for the ItaniumNodes.def file replacing FOR_EACH_NODE macro, but that'll be obvious.

This revision is now accepted and ready to land.Apr 6 2022, 4:40 AM
zsrkmyn updated this revision to Diff 421391.Apr 7 2022, 8:00 PM

Rebase to the latest commit

This revision was landed with ongoing or failed builds.Apr 7 2022, 9:21 PM
This revision was automatically updated to reflect the committed changes.