This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Fix std::type_info comparison
Needs ReviewPublic

Authored by ldionne on Apr 8 2021, 1:11 PM.

Details

Reviewers
rjmccall
Group Reviewers
Restricted Project
Summary

As noted by Richard Smith in https://reviews.llvm.org/D97802#2675067, the
current implementation of std::type_info less-than comparison was not an
ordering relation. This commit fixes that.

It's technically a behavior change, however anyone relying on the ordering
as given by the previous implementation was relying on something extremely
brittle, so I think it's safe to fix this.

Diff Detail

Event Timeline

ldionne created this revision.Apr 8 2021, 1:11 PM
ldionne requested review of this revision.Apr 8 2021, 1:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 8 2021, 1:11 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne added inline comments.Apr 8 2021, 1:12 PM
libcxx/test/std/language.support/support.rtti/type.info/type_info.order.sh.cpp
1

This is my best attempt at trying to test this, but TBH I'm not sure how good it is.

rjmccall accepted this revision.Apr 8 2021, 3:54 PM

Patch functionally LGTM. Not sure what you're asking about the test script, but I don't know the libc++ test suite.

Seems the Windows build fails, can you look why the XFAIL doesn't work.

libcxx/include/typeinfo
269

I love this kind of comment, however it's now duplicated here and in the implementation. Would it make sense to move this comment in the implementation so we have only one copy?

libcxx/test/std/language.support/support.rtti/type.info/type_info.order.sh.cpp
1

Also not to sure how good it is. Can we test whether the order is different in the TUs? Would it help to run the test with different linker orders for TU1 and TU2? e.g. TU1 TU2 MAIN and TU2 TU1 MAIN.

36

Is there a reason to put this function here instead of in MAIN?