This is an archive of the discontinued LLVM Phabricator instance.

[clang] Extend __is_trivially_equality_comparable to check for hidden friends
ClosedPublic

Authored by philnik on May 27 2023, 6:30 PM.

Details

Summary

This allows types to be considered trivially equality comparable if a defaulted hidden friend is used.

Diff Detail

Event Timeline

philnik created this revision.May 27 2023, 6:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 27 2023, 6:30 PM
philnik requested review of this revision.May 27 2023, 6:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 27 2023, 6:30 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Is this a builtin that is supposed to model something in the standard? It isn't clear to me how this one is supposed to work.

clang/test/SemaCXX/type-traits.cpp
3439

Is there a reason these tests need to be c++20 only?

Is this a builtin that is supposed to model something in the standard? It isn't clear to me how this one is supposed to work.

No, this is for optimization purposes. It is true when it is know that comparing two instances of T is equivalent to a memcmp. Or in other words every bit in the type is part of its value representation. Does that help?

clang/test/SemaCXX/type-traits.cpp
3439

Defaulted equality comparison is a C++20 feature.

erichkeane accepted this revision.May 30 2023, 7:52 AM

Is this a builtin that is supposed to model something in the standard? It isn't clear to me how this one is supposed to work.

No, this is for optimization purposes. It is true when it is know that comparing two instances of T is equivalent to a memcmp. Or in other words every bit in the type is part of its value representation. Does that help?

I found the patch a few months ago where you added this, so I'm more knowledgeable now.

clang/test/SemaCXX/type-traits.cpp
3439

Ah, right, thanks!

This revision is now accepted and ready to land.May 30 2023, 7:52 AM