[clang-tools-extra] [clang-tidy] Add modernize-use-init-statement check (PR #171086)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Dec 7 23:59:57 PST 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/modernize/UseInitStatementCheck.cpp clang-tools-extra/clang-tidy/modernize/UseInitStatementCheck.h clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp clang-tools-extra/clang-tidy/utils/LexerUtils.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/UseInitStatementCheck.cpp:96:46: warning: the parameter 'VarOrBindingNodeMatcher' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
96 | static Matcher<Stmt> callByRef(Matcher<Decl> VarOrBindingNodeMatcher) {
| ^
| const &
clang-tools-extra/clang-tidy/modernize/UseInitStatementCheck.cpp:97:14: warning: invalid case style for variable 'argMatcher' [readability-identifier-naming]
97 | const auto argMatcher = declRefExpr(to(VarOrBindingNodeMatcher));
| ^~~~~~~~~~
| ArgMatcher
98 | const auto paramMatcher = parmVarDecl(hasType(referenceType()));
99 |
100 | return anyOf(
101 | callExpr(forEachArgumentWithParam(argMatcher, paramMatcher)),
| ~~~~~~~~~~
| ArgMatcher
102 | cxxConstructExpr(forEachArgumentWithParam(argMatcher, paramMatcher)));
| ~~~~~~~~~~
| ArgMatcher
clang-tools-extra/clang-tidy/modernize/UseInitStatementCheck.cpp:98:14: warning: invalid case style for variable 'paramMatcher' [readability-identifier-naming]
98 | const auto paramMatcher = parmVarDecl(hasType(referenceType()));
| ^~~~~~~~~~~~
| ParamMatcher
99 |
100 | return anyOf(
101 | callExpr(forEachArgumentWithParam(argMatcher, paramMatcher)),
| ~~~~~~~~~~~~
| ParamMatcher
102 | cxxConstructExpr(forEachArgumentWithParam(argMatcher, paramMatcher)));
| ~~~~~~~~~~~~
| ParamMatcher
clang-tools-extra/clang-tidy/modernize/UseInitStatementCheck.cpp:152:56: warning: the parameter 'StmtMatcher' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
152 | static Matcher<Stmt> compoundStmtMatcher(Matcher<Stmt> StmtMatcher,
| ^
| const &
clang-tools-extra/clang-tidy/modernize/UseInitStatementCheck.cpp:154:56: warning: the parameter 'PrevStmtMatcher' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
154 | Matcher<Stmt> PrevStmtMatcher,
| ^
| const &
clang-tools-extra/clang-tidy/modernize/UseInitStatementCheck.cpp:155:56: warning: the parameter 'RefToBoundMatcher' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
155 | Matcher<Stmt> RefToBoundMatcher) {
| ^
| const &
clang-tools-extra/clang-tidy/modernize/UseInitStatementCheck.cpp:183:59: warning: parameter 'PrevStmtMatcher' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param]
183 | return compoundStmtMatcher(StmtWithCondition, StmtName, PrevStmtMatcher,
| ^
| std::move( )
clang-tools-extra/clang-tidy/modernize/UseInitStatementCheck.cpp:184:30: warning: parameter 'RefToBoundMatcher' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param]
184 | RefToBoundMatcher);
| ^
| std::move( )
clang-tools-extra/clang-tidy/modernize/UseInitStatementCheck.cpp:188:52: warning: the parameter 'ConditionForReference' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
188 | static auto forBuiltinTypes(Matcher<ReferenceType> ConditionForReference)
| ^
| const &
```
</details>
https://github.com/llvm/llvm-project/pull/171086
More information about the cfe-commits
mailing list