This is an archive of the discontinued LLVM Phabricator instance.

[ADT] Extend EnableIfCallable for callables with incomplete returns
ClosedPublic

Authored by math-fehr on Jun 22 2021, 5:15 AM.

Details

Summary

std::is_convertible has no defined behavior when its arguments
are incomplete, even if they are equal. In practice, it returns false.
Adding std::is_same allows us to use the constructor using a callable,
even if the return value is incomplete. We also check the case where
we convert a T into a const T.

Diff Detail

Event Timeline

math-fehr created this revision.Jun 22 2021, 5:15 AM
math-fehr requested review of this revision.Jun 22 2021, 5:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 22 2021, 5:15 AM
math-fehr updated this revision to Diff 354263.Jun 24 2021, 8:28 AM

Fix formatting

math-fehr updated this revision to Diff 354740.Jun 27 2021, 5:13 AM

Fix formatting

This revision is now accepted and ready to land.Jul 7 2021, 5:09 PM
math-fehr updated this revision to Diff 357923.Jul 12 2021, 6:23 AM

Fix compilation on windows by introducing and using llvm::conjuctions

DaniilSuchkov requested changes to this revision.Jul 12 2021, 2:44 PM
  1. Since you're replacing an OR chain you need to re-implement std::disjunction, not std::conjunction (no s at the end), which you mostly did, except for the name and the (2).
  2. According to the specification std::disjunction should return std::false_type for an empty argument list. I.e. here you should use std::false_type instead:
template <typename... Conds> struct conjunctions : std::true_type {};

Also please add a couple of tests for your llvm::disjunction implementation to llvm/unittests/Support/TypeTraitsTest.cpp.

This revision now requires changes to proceed.Jul 12 2021, 2:44 PM
math-fehr updated this revision to Diff 358448.Jul 13 2021, 3:32 PM

Remove llvm::conjunctions, and use llvm::disjunction

Oh yes, thanks for that!
I realized that there was also already a llvm::disjunction in ADT/STLForwardCompat.h, so I used it.

This revision is now accepted and ready to land.Jul 13 2021, 3:51 PM

Hey! I do not have commit access, could someone commit this patch?

I'll commit it.

This revision was landed with ongoing or failed builds.Sep 13 2021, 12:17 PM
This revision was automatically updated to reflect the committed changes.