[llvm] [ADT] Deprecate StringSwitch Cases with 4+ args. NFC. (PR #164276)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 20 09:09:36 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-adt
Author: Jakub Kuderski (kuhar)
<details>
<summary>Changes</summary>
Suggest the `initializer_list` overload instead.
4+ args is an arbitrary number that allows for incremental deprecation without having too update too many call sites.
For more context, see https://github.com/llvm/llvm-project/pull/163117.
---
Full diff: https://github.com/llvm/llvm-project/pull/164276.diff
1 Files Affected:
- (modified) llvm/include/llvm/ADT/StringSwitch.h (+4)
``````````diff
diff --git a/llvm/include/llvm/ADT/StringSwitch.h b/llvm/include/llvm/ADT/StringSwitch.h
index 26d568298207e..2262b1162e330 100644
--- a/llvm/include/llvm/ADT/StringSwitch.h
+++ b/llvm/include/llvm/ADT/StringSwitch.h
@@ -98,11 +98,13 @@ class StringSwitch {
return CasesImpl({S0, S1, S2}, Value);
}
+ [[deprecated("Pass cases in std::initializer_list instead")]]
StringSwitch &Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2,
StringLiteral S3, T Value) {
return CasesImpl({S0, S1, S2, S3}, Value);
}
+ [[deprecated("Pass cases in std::initializer_list instead")]]
StringSwitch &Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2,
StringLiteral S3, StringLiteral S4, T Value) {
return CasesImpl({S0, S1, S2, S3, S4}, Value);
@@ -179,11 +181,13 @@ class StringSwitch {
return CasesLowerImpl({S0, S1, S2}, Value);
}
+ [[deprecated("Pass cases in std::initializer_list instead")]]
StringSwitch &CasesLower(StringLiteral S0, StringLiteral S1, StringLiteral S2,
StringLiteral S3, T Value) {
return CasesLowerImpl({S0, S1, S2, S3}, Value);
}
+ [[deprecated("Pass cases in std::initializer_list instead")]]
StringSwitch &CasesLower(StringLiteral S0, StringLiteral S1, StringLiteral S2,
StringLiteral S3, StringLiteral S4, T Value) {
return CasesLowerImpl({S0, S1, S2, S3, S4}, Value);
``````````
</details>
https://github.com/llvm/llvm-project/pull/164276
More information about the llvm-commits
mailing list