This is an archive of the discontinued LLVM Phabricator instance.

[ADT] Deprecate llvm::NoneType
ClosedPublic

Authored by kazu on Nov 23 2022, 3:36 PM.

Details

Summary

I've migrated all known uses of NoneType to std::nullopt_t. This
patch deprecates NoneType.

I'm using "typedef" instead of "using" because somehow
"[[deprecated]]" and "using" do not seem to get along.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Diff Detail

Event Timeline

kazu created this revision.Nov 23 2022, 3:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 23 2022, 3:36 PM
kazu requested review of this revision.Nov 23 2022, 3:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 23 2022, 3:36 PM
MaskRay accepted this revision.EditedNov 23 2022, 4:00 PM

LGTM. using can be used as well, but the attribute is at a different place.

MSVC supports deprecated for using/typedef but it doesn't warn about function arguments ([Facepalm]). g++/clang++ are good.

using NoneType [[depercated("xxx")]] = std::nullopt_t;
[[depercated("xxx")]] typedef std::nullopt_t NoneType2;

void foo(NoneType a) {}
void foo2(NoneType2 a) {}

void use() {
    foo(std::nullopt);
    foo2(std::nullopt);
}
llvm/include/llvm/ADT/None.h
25–26

typo: std::nullopt_t

I think the period can be omitted.

This revision is now accepted and ready to land.Nov 23 2022, 4:00 PM
kazu added a comment.Nov 23 2022, 4:32 PM

LGTM. using can be used as well, but the attribute is at a different place.

MSVC supports deprecated for using/typedef but it doesn't warn about function arguments ([Facepalm]). g++/clang++ are good.

Ah, thank you for the explanation (and the review, of course)!

This revision was landed with ongoing or failed builds.Nov 23 2022, 4:33 PM
This revision was automatically updated to reflect the committed changes.