This is an archive of the discontinued LLVM Phabricator instance.

[ADT] Deprecate Optional::getValueOr (NFC)
ClosedPublic

Authored by kazu on Jul 19 2022, 8:02 PM.

Details

Summary

This patch deprecates getValueOr in favor of value_or.

Diff Detail

Event Timeline

kazu created this revision.Jul 19 2022, 8:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2022, 8:02 PM
kazu requested review of this revision.Jul 19 2022, 8:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2022, 8:02 PM

I was originally planning to deprecate this method, but I cannot put [[deprecated]] on C++ templates.

Hmm, I'm not sure I understand what you mean. It looks like you could put [[deprecated]] on a member function template: https://godbolt.org/z/jG1KxMT1f

kazu added a comment.Jul 25 2022, 12:41 PM

I was originally planning to deprecate this method, but I cannot put [[deprecated]] on C++ templates.

Hmm, I'm not sure I understand what you mean. It looks like you could put [[deprecated]] on a member function template: https://godbolt.org/z/jG1KxMT1f

Oops. I was putting [[deprecated]] before template. It works now with [[deprecated]] immediately before the return type. Let me revise the patch.

kazu updated this revision to Diff 447552.Jul 25 2022, 9:06 PM

Use [[deprecate]] instead of removing getValueOr.

kazu retitled this revision from [ADT] Remove Optional::getValueOr (NFC) to [ADT] Deprecate Optional::getValueOr (NFC).Jul 25 2022, 9:07 PM
kazu edited the summary of this revision. (Show Details)

Please take look. Thanks!

dblaikie accepted this revision.Jul 25 2022, 10:13 PM

Looks good to me, if it's sufficiently portable to supported compilers, etc.

llvm/include/llvm/ADT/Optional.h
321

Do we have prior art (other instances of use of the raw [[deprecated]] attribute without any macro conditionals/feature checking/etc) that this is compatible with all LLVM supported compilers, etc?

This revision is now accepted and ready to land.Jul 25 2022, 10:13 PM
This revision was landed with ongoing or failed builds.Jul 25 2022, 11:01 PM
This revision was automatically updated to reflect the committed changes.