Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[llvm] Use llvm::any_cast instead of any_cast (NFC) #65565

Merged
merged 1 commit into from
Sep 7, 2023

Conversation

kazutakahirata
Copy link
Contributor

This patch replaces any_cast with llvm::any_cast. This in turn allows us to gracefully switch to std::any in future by forwarding llvm::Any and llvm::any_cast to:

using Any = std::any;

template T *any_cast(Any *Value) {
return std::any_cast(Value);
}

respectively.

Without this patch, it's ambiguous whether any_cast refers to std::any_cast or llvm::any_cast.

As an added bonus, this patch makes it easier to mechanically replace llvm::any_cast with std::any_cast without affecting other occurrences of any_cast (e.g. in libcxx).

This patch replaces any_cast with llvm::any_cast.  This in turn allows
us to gracefully switch to std::any in future by forwarding llvm::Any
and llvm::any_cast to:

  using Any = std::any;

  template <class T> T *any_cast(Any *Value) {
    return std::any_cast<T>(Value);
  }

respectively.

Without this patch, it's ambiguous whether any_cast refers to
std::any_cast or llvm::any_cast.

As an added bonus, this patch makes it easier to mechanically replace
llvm::any_cast with std::any_cast without affecting other occurrences
of any_cast (e.g. in libcxx).
Copy link
Member

@Flakebi Flakebi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM.
Just for completeness, as mentioned in D139974, std::any is broken until Visual Studio 2022 17.4, so we need to wait until LLVM’s minimum VS version is there. Currently, LLVM supports anything down to VS 2019.

@kazutakahirata kazutakahirata merged commit f8a1c8b into llvm:main Sep 7, 2023
1 of 2 checks passed
@kazutakahirata kazutakahirata deleted the adt_llvm_any_cast branch September 7, 2023 16:07
avillega pushed a commit to avillega/llvm-project that referenced this pull request Sep 11, 2023
This patch replaces any_cast with llvm::any_cast. This in turn allows us
to gracefully switch to std::any in future by forwarding llvm::Any and
llvm::any_cast to:

  using Any = std::any;

  template <class T> T *any_cast(Any *Value) {
    return std::any_cast<T>(Value);
  }

respectively.

Without this patch, it's ambiguous whether any_cast refers to
std::any_cast or llvm::any_cast.

As an added bonus, this patch makes it easier to mechanically replace
llvm::any_cast with std::any_cast without affecting other occurrences of
any_cast (e.g. in libcxx).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants