Skip to content

[ADT] Deprecate ArrayRef(std::nullopt) #146011

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

Conversation

kazutakahirata
Copy link
Contributor

Since the use of std::nullopt outside the context of std::optional is
kind of abuse and not intuitive to new comers, this patch deprecates
the constructor. All known uses within the LLVM codebase have been
migrated to other constructors.

Since the use of std::nullopt outside the context of std::optional is
kind of abuse and not intuitive to new comers, this patch deprecates
the constructor.  All known uses within the LLVM codebase have been
migrated to other constructors.
@llvmbot
Copy link
Member

llvmbot commented Jun 27, 2025

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

Changes

Since the use of std::nullopt outside the context of std::optional is
kind of abuse and not intuitive to new comers, this patch deprecates
the constructor. All known uses within the LLVM codebase have been
migrated to other constructors.


Full diff: https://github.com/llvm/llvm-project/pull/146011.diff

1 Files Affected:

  • (modified) llvm/include/llvm/ADT/ArrayRef.h (+1-1)
diff --git a/llvm/include/llvm/ADT/ArrayRef.h b/llvm/include/llvm/ADT/ArrayRef.h
index 892482d64e4a1..7a228d9915cde 100644
--- a/llvm/include/llvm/ADT/ArrayRef.h
+++ b/llvm/include/llvm/ADT/ArrayRef.h
@@ -67,7 +67,7 @@ namespace llvm {
     /*implicit*/ ArrayRef() = default;
 
     /// Construct an empty ArrayRef from std::nullopt.
-    /*implicit*/ ArrayRef(std::nullopt_t) {}
+    /*implicit*/ [[deprecated]] ArrayRef(std::nullopt_t) {}
 
     /// Construct an ArrayRef from a single element.
     /*implicit*/ ArrayRef(const T &OneElt LLVM_LIFETIME_BOUND)

Copy link

github-actions bot commented Jun 27, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@kazutakahirata kazutakahirata merged commit 2529de5 into llvm:main Jun 27, 2025
7 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20250626_deprecate_ArrayRef_nullopt branch June 27, 2025 08:03
jeanPerier added a commit to jeanPerier/llvm-project that referenced this pull request Jun 27, 2025
jeanPerier added a commit that referenced this pull request Jun 27, 2025
…#146043)

Clean-up some std::nullopt usages in FIR ops builder that triggers a
deprecated warning after #146011.
@erichkeane
Copy link
Collaborator

This patch missed a few uses in MLIR and CIR as well, so those probably need updating @andykaylor @mmha

rlavaee pushed a commit to rlavaee/llvm-project that referenced this pull request Jul 1, 2025
Since the use of std::nullopt outside the context of std::optional is
kind of abuse and not intuitive to new comers, this patch deprecates
the constructor.  All known uses within the LLVM codebase have been
migrated to other constructors.
rlavaee pushed a commit to rlavaee/llvm-project that referenced this pull request Jul 1, 2025
…6011 (llvm#146043)

Clean-up some std::nullopt usages in FIR ops builder that triggers a
deprecated warning after llvm#146011.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants