[llvm] 894eaf4 - [ADT] Deprecate StringSwitch Cases with 4+ args. NFC. (#164276)

via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 20 11:35:35 PDT 2025


Author: Jakub Kuderski
Date: 2025-10-20T14:35:30-04:00
New Revision: 894eaf481542adefde861a7e39f769f21d3f4fa4

URL: https://github.com/llvm/llvm-project/commit/894eaf481542adefde861a7e39f769f21d3f4fa4
DIFF: https://github.com/llvm/llvm-project/commit/894eaf481542adefde861a7e39f769f21d3f4fa4.diff

LOG: [ADT] Deprecate StringSwitch Cases with 4+ args. NFC. (#164276)

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.

Added: 
    

Modified: 
    llvm/include/llvm/ADT/StringSwitch.h

Removed: 
    


################################################################################
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);


        


More information about the llvm-commits mailing list