This is an archive of the discontinued LLVM Phabricator instance.

[ADT] Fix Optional<> with llvm::is_trivially_move_constructible
ClosedPublic

Authored by steven_wu on Jan 13 2022, 2:35 PM.

Details

Summary

Fix the compatibility of Optional<> with some GCC versions that it will fail
to compile when T is getting checked for is_trivially_move_constructible
as mentioned here: https://reviews.llvm.org/D93510#2538983

Fix the problem by using llvm::is_trivially_move_constructible.

Diff Detail

Event Timeline

steven_wu created this revision.Jan 13 2022, 2:35 PM
steven_wu requested review of this revision.Jan 13 2022, 2:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 13 2022, 2:35 PM
steven_wu updated this revision to Diff 399797.Jan 13 2022, 2:39 PM

Rename the variables to be more accurate.

This LGTM, but it'd be great if someone involved in the discussion for https://reviews.llvm.org/D93510 could chime in to confirm this isn't too surprising.

llvm/include/llvm/ADT/Optional.h
36–42

I think this comment should be expanded to cover is_trivially_move_constructible as well.

Probably should add some text to the comment explaining why this workaround is needed.

steven_wu updated this revision to Diff 399818.Jan 13 2022, 3:47 PM

Address review feedback.

jplayer-nv added inline comments.Jan 13 2022, 3:52 PM
llvm/include/llvm/ADT/Optional.h
52–53

I don't have a test in mind yet, but any concern for the same instantiation bug with std::is_trivially_move_assignable pre-gcc7.4?

steven_wu updated this revision to Diff 399851.Jan 13 2022, 5:20 PM
steven_wu marked an inline comment as done.

Fix test name.

steven_wu added inline comments.Jan 13 2022, 5:22 PM
llvm/include/llvm/ADT/Optional.h
52–53

I am not sure and we also do not have a LLVM version of that implementation. Maybe we can address that in a separate patch if that is a problem?

jplayer-nv accepted this revision.Jan 13 2022, 5:39 PM

we also do not have a LLVM version of that implementation.

Good point.

Change looks good to me. Thanks!

This revision is now accepted and ready to land.Jan 13 2022, 5:39 PM

LGTM, thank you for this fix!

steven_wu updated this revision to Diff 400155.Jan 14 2022, 2:43 PM

Rebase to TOT

steven_wu updated this revision to Diff 400707.Jan 17 2022, 9:29 PM

clang-format

This revision was landed with ongoing or failed builds.Jan 18 2022, 8:37 AM
This revision was automatically updated to reflect the committed changes.