Skip to content

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)

@github-actions
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

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