[Lldb-commits] [clang] [clang-tools-extra] [lld] [lldb] [llvm] [ADT] Deprecate StringSwitch Cases with 3+ args. NFC. (PR #165119)

via lldb-commits lldb-commits at lists.llvm.org
Sat Oct 25 15:33:07 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE LINT COMMENT: clang-tidy-->


:warning: C/C++ code linter clang-tidy found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

```bash

git diff -U0 origin/main...HEAD -- clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp |
python3 clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py \
  -path build -p1 -quiet
```

</details>

<details>
<summary>
View the output from clang-tidy here.
</summary>

```
clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp:93:8: error: no matching member function for call to 'Cases' [clang-diagnostic-error]
   92 |   return StringSwitch<StringRef>(FunctionName)
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   93 |       .Cases({"asctime", "asctime_r"}, "ctime",
      |       ~^~~~~
llvm/include/llvm/ADT/StringSwitch.h:92:17: note: candidate function not viable: cannot convert initializer list argument to 'StringLiteral'
   92 |   StringSwitch &Cases(StringLiteral S0, StringLiteral S1, T Value) {
      |                 ^     ~~~~~~~~~~~~~~~~
llvm/include/llvm/ADT/StringSwitch.h:87:17: note: candidate function not viable: requires 2 arguments, but 3 were provided
   87 |   StringSwitch &Cases(std::initializer_list<StringLiteral> CaseStrings,
      |                 ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   88 |                       T Value) {
      |                       ~~~~~~~
llvm/include/llvm/ADT/StringSwitch.h:97:17: note: candidate function not viable: requires 4 arguments, but 3 were provided
   97 |   StringSwitch &Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2,
      |                 ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   98 |                       T Value) {
      |                       ~~~~~~~
llvm/include/llvm/ADT/StringSwitch.h:103:17: note: candidate function not viable: requires 5 arguments, but 3 were provided
  103 |   StringSwitch &Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2,
      |                 ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  104 |                       StringLiteral S3, T Value) {
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~
llvm/include/llvm/ADT/StringSwitch.h:109:17: note: candidate function not viable: requires 6 arguments, but 3 were provided
  109 |   StringSwitch &Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2,
      |                 ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  110 |                       StringLiteral S3, StringLiteral S4, T Value) {
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
llvm/include/llvm/ADT/StringSwitch.h:115:17: note: candidate function not viable: requires 7 arguments, but 3 were provided
  115 |   StringSwitch &Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2,
      |                 ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  116 |                       StringLiteral S3, StringLiteral S4, StringLiteral S5,
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  117 |                       T Value) {
      |                       ~~~~~~~
llvm/include/llvm/ADT/StringSwitch.h:122:17: note: candidate function not viable: requires 8 arguments, but 3 were provided
  122 |   StringSwitch &Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2,
      |                 ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  123 |                       StringLiteral S3, StringLiteral S4, StringLiteral S5,
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  124 |                       StringLiteral S6, T Value) {
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~
llvm/include/llvm/ADT/StringSwitch.h:129:17: note: candidate function not viable: requires 9 arguments, but 3 were provided
  129 |   StringSwitch &Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2,
      |                 ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  130 |                       StringLiteral S3, StringLiteral S4, StringLiteral S5,
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  131 |                       StringLiteral S6, StringLiteral S7, T Value) {
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
llvm/include/llvm/ADT/StringSwitch.h:136:17: note: candidate function not viable: requires 10 arguments, but 3 were provided
  136 |   StringSwitch &Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2,
      |                 ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  137 |                       StringLiteral S3, StringLiteral S4, StringLiteral S5,
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  138 |                       StringLiteral S6, StringLiteral S7, StringLiteral S8,
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  139 |                       T Value) {
      |                       ~~~~~~~
llvm/include/llvm/ADT/StringSwitch.h:144:17: note: candidate function not viable: requires 11 arguments, but 3 were provided
  144 |   StringSwitch &Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2,
      |                 ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  145 |                       StringLiteral S3, StringLiteral S4, StringLiteral S5,
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  146 |                       StringLiteral S6, StringLiteral S7, StringLiteral S8,
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  147 |                       StringLiteral S9, T Value) {
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~
```

</details>


https://github.com/llvm/llvm-project/pull/165119


More information about the lldb-commits mailing list