[clang-tools-extra] [clang-tidy] Fix performance-move-const-arg false negative in ternary… (PR #128402)
David Rivera via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 26 19:21:22 PST 2025
RiverDave wrote:
> ⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️
>
> You can test this locally with the following command:
> ```shell
> git-clang-format --diff 5d501c6137976ff1f14f3b0e2e593fb9740d0146 848be2ccd25fd68b6a2d2037198184b08ff5d6e2 --extensions cpp -- clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp clang-tools-extra/test/clang-tidy/checkers/performance/move-const-arg.cpp
> ```
>
> View the diff from clang-format here.
> ```diff
> diff --git a/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp b/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
> index 553c1d20cb..703ad162f9 100644
> --- a/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
> +++ b/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
> @@ -63,16 +63,15 @@ void MoveConstArgCheck::registerMatchers(MatchFinder *Finder) {
> // Matches respective ParmVarDecl for a CallExpr or CXXConstructExpr.
> auto ArgumentWithParamMatcher = forEachArgumentWithParam(
> anyOf(MoveCallMatcher, TernaryWithMoveMatcher),
> - parmVarDecl(anyOf(hasType(ConstTypeParmMatcher),
> - hasType(RValueTypeParmMatcher)))
> - .bind("invocation-parm"));
> + parmVarDecl(
> + anyOf(hasType(ConstTypeParmMatcher), hasType(RValueTypeParmMatcher)))
> + .bind("invocation-parm"));
> // Matches respective types of arguments for a CallExpr or CXXConstructExpr
> // and it works on calls through function pointers as well.
> auto ArgumentWithParamTypeMatcher = forEachArgumentWithParamType(
> anyOf(MoveCallMatcher, TernaryWithMoveMatcher),
> anyOf(ConstTypeParmMatcher, RValueTypeParmMatcher));
>
> -
> Finder->addMatcher(
> invocation(anyOf(ArgumentWithParamMatcher, ArgumentWithParamTypeMatcher))
> .bind("receiving-expr"),
> ```
This should be fixed now
https://github.com/llvm/llvm-project/pull/128402
More information about the cfe-commits
mailing list