[clang] [ASTMatchers] Migrate away from ArrayRef(std::nullopt) (NFC) (PR #145840)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 25 22:55:34 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/145840
ArrayRef has a constructor that accepts std::nullopt. This
constructor dates back to the days when we still had llvm::Optional.
Since the use of std::nullopt outside the context of std::optional is
kind of abuse and not intuitive to new comers, I would like to move
away from the constructor and eventually remove it.
This patch migrates away from std::nullopt in favor of ArrayRef<T>().
Note that {} would be ambiguous for perfect forwarding to work here.
>From 9167309ca0d238f7d9972ae15ef69a971d175eec Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 25 Jun 2025 12:06:54 -0700
Subject: [PATCH] [ASTMatchers] Migrate away from ArrayRef(std::nullopt) (NFC)
ArrayRef has a constructor that accepts std::nullopt. This
constructor dates back to the days when we still had llvm::Optional.
Since the use of std::nullopt outside the context of std::optional is
kind of abuse and not intuitive to new comers, I would like to move
away from the constructor and eventually remove it.
This patch migrates away from std::nullopt in favor of ArrayRef<T>().
Note that {} would be ambiguous for perfect forwarding to work here.
---
clang/lib/ASTMatchers/Dynamic/Marshallers.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/ASTMatchers/Dynamic/Marshallers.h b/clang/lib/ASTMatchers/Dynamic/Marshallers.h
index 0e640cbada726..d44e42a524f27 100644
--- a/clang/lib/ASTMatchers/Dynamic/Marshallers.h
+++ b/clang/lib/ASTMatchers/Dynamic/Marshallers.h
@@ -1060,7 +1060,7 @@ makeMatcherAutoMarshall(ReturnType (*Func)(), StringRef MatcherName) {
BuildReturnTypeVector<ReturnType>::build(RetTypes);
return std::make_unique<FixedArgCountMatcherDescriptor>(
matcherMarshall0<ReturnType>, reinterpret_cast<void (*)()>(Func),
- MatcherName, RetTypes, std::nullopt);
+ MatcherName, RetTypes, ArrayRef<ArgKind>());
}
/// 1-arg overload
More information about the cfe-commits
mailing list