[llvm] [ADT] Deprecate StringSwitch Cases with 3+ args. NFC. (PR #165119)
Jakub Kuderski via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 25 14:46:49 PDT 2025
https://github.com/kuhar created https://github.com/llvm/llvm-project/pull/165119
Suggest the `initializer_list` overload instead.
3+ args is an arbitrary number that allows for incremental depreciation without having to update too many call sites.
For more context, see https://github.com/llvm/llvm-project/pull/163117.
>From 6aa443a19746145a409ccac3c7af4b41d5d42186 Mon Sep 17 00:00:00 2001
From: Jakub Kuderski <jakub at nod-labs.com>
Date: Sat, 25 Oct 2025 17:45:04 -0400
Subject: [PATCH] [ADT] Deprecate StringSwitch Cases with 3+ args. NFC.
Suggest the `initializer_list` overload instead.
3+ args is an arbitrary number that allows for incremental depreciation
without having to update too many call sites.
For more context, see https://github.com/llvm/llvm-project/pull/163117.
---
llvm/include/llvm/ADT/StringSwitch.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/llvm/include/llvm/ADT/StringSwitch.h b/llvm/include/llvm/ADT/StringSwitch.h
index 2262b1162e330..98685de8573fa 100644
--- a/llvm/include/llvm/ADT/StringSwitch.h
+++ b/llvm/include/llvm/ADT/StringSwitch.h
@@ -93,6 +93,7 @@ class StringSwitch {
return CasesImpl({S0, S1}, Value);
}
+ [[deprecated("Pass cases in std::initializer_list instead")]]
StringSwitch &Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2,
T Value) {
return CasesImpl({S0, S1, S2}, Value);
@@ -176,6 +177,7 @@ class StringSwitch {
return CasesLowerImpl({S0, S1}, Value);
}
+ [[deprecated("Pass cases in std::initializer_list instead")]]
StringSwitch &CasesLower(StringLiteral S0, StringLiteral S1, StringLiteral S2,
T Value) {
return CasesLowerImpl({S0, S1, S2}, Value);
More information about the llvm-commits
mailing list