[clang-tools-extra] [clang-tidy] Add modernize-use-std-tie check (PR #191218)

via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 9 08:53:37 PDT 2026


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/modernize/UseStdTieCheck.cpp clang-tools-extra/clang-tidy/modernize/UseStdTieCheck.h clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.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/modernize/UseStdTieCheck.cpp:30:15: warning: redundant string initialization [readability-redundant-string-init]
   30 |   std::string Autos = "";
      |               ^~~~~~~~~~
      |               Autos
clang-tools-extra/clang-tidy/modernize/UseStdTieCheck.cpp:39:5: warning: variable 'Text' of type 'std::string' (aka 'basic_string<char>') can be declared 'const' [misc-const-correctness]
   39 |     std::string Text =
      |     ^
      |                 const 
clang-tools-extra/clang-tidy/modernize/UseStdTieCheck.cpp:51:7: warning: variable 'LhsSide' of type 'std::string' (aka 'basic_string<char>') can be declared 'const' [misc-const-correctness]
   51 |       std::string LhsSide = Text.substr(0, OpPos);
      |       ^
      |                   const 
clang-tools-extra/clang-tidy/modernize/UseStdTieCheck.cpp:55:19: warning: redundant string initialization [readability-redundant-string-init]
   55 |       std::string CleanLhs = "";
      |                   ^~~~~~~~~~~~~
      |                   CleanLhs
clang-tools-extra/clang-tidy/modernize/UseStdTieCheck.cpp:56:12: warning: variable 'c' of type 'char' can be declared 'const' [misc-const-correctness]
   56 |       for (char c : LhsSide)
      |            ^
      |                 const 
clang-tools-extra/clang-tidy/modernize/UseStdTieCheck.cpp:56:17: warning: invalid case style for variable 'c' [readability-identifier-naming]
   56 |       for (char c : LhsSide)
      |                 ^
      |                 C
   57 |         if (c != ' ' && c != '\t' && c != '\n')
      |             ~           ~            ~
      |             C           C            C
   58 |           CleanLhs += c;
      |                       ~
      |                       C
clang-tools-extra/clang-tidy/modernize/UseStdTieCheck.cpp:62:9: warning: variable 'VarName' of type 'std::string' (aka 'basic_string<char>') can be declared 'const' [misc-const-correctness]
   62 |         std::string VarName = CleanLhs.substr(4); // Extrae "n", "s" o "d()"
      |         ^
      |                     const 
clang-tools-extra/clang-tidy/modernize/UseStdTieCheck.cpp:65:11: warning: variable 'CleanName' of type 'std::string' (aka 'basic_string<char>') can be declared 'const' [misc-const-correctness]
   65 |           std::string CleanName = VarName.substr(0, VarName.length() - 2);
      |           ^
      |                       const 
clang-tools-extra/clang-tidy/modernize/UseStdTieCheck.cpp:67:61: warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation]
   67 |               "    const auto lhs_" + CleanName + " = lhs." + VarName + ";\n";
      |                                                             ^
clang-tools-extra/clang-tidy/modernize/UseStdTieCheck.cpp:69:61: warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation]
   69 |               "    const auto rhs_" + CleanName + " = rhs." + VarName + ";\n";
      |                                                             ^
clang-tools-extra/clang-tidy/modernize/UseStdTieCheck.cpp:93:15: warning: invalid case style for variable 'i' [readability-identifier-naming]
   93 |   for (size_t i = 1; i < TieArgsLhs.size(); ++i) {
      |               ^      ~                        ~
      |               I      I                        I
   94 |     LhsTuple += ", " + TieArgsLhs[i];
      |                                   ~
      |                                   I
   95 |     RhsTuple += ", " + TieArgsRhs[i];
      |                                   ~
      |                                   I
clang-tools-extra/clang-tidy/modernize/UseStdTieCheck.cpp:98:3: warning: variable 'Symbol' of type 'std::string' (aka 'basic_string<char>') can be declared 'const' [misc-const-correctness]
   98 |   std::string Symbol =
      |   ^
      |               const 
clang-tools-extra/clang-tidy/modernize/UseStdTieCheck.cpp:102:3: warning: variable 'Replacement' of type 'std::string' (aka 'basic_string<char>') can be declared 'const' [misc-const-correctness]
  102 |   std::string Replacement = "{\n" + Autos + "    return std::tie(" + LhsTuple +
      |   ^
      |               const
```

</details>


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


More information about the cfe-commits mailing list