[PATCH] D137205: [clang-tidy] Add performance-unnecessary-copy-on-last-use check
Fabian Keßler via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 24 14:29:02 PST 2022
Febbe marked 2 inline comments as done.
Febbe added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/performance/UnnecessaryCopyOnLastUseCheck.cpp:123
+ hasLHS(ignoringParenImpCasts(declRefExpr(equalsNode(DeclRef)))))),
+ Context);
+ return !Matches.empty();
----------------
Febbe wrote:
> njames93 wrote:
> > Matching over the entire context seems pretty and a huge drain on performance, would it not make sense to just match inside the function declaration.
> > Side note maybe a RecursiveASTVisitor would make more sense here in terms of performance.
> >
> > Same goes for isInLambdaCapture.
> How can I reduce the Context?
>
> Also, in which terms, the RecursiveASTVisitor would make more sense here?
Replaced with RecursiveASTVisitor.
================
Comment at: clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-on-last-use.cpp:1
+// RUN: %check_clang_tidy %s -std=c++17 performance-unnecessary-copy-on-last-use %t
+// RUN: %check_clang_tidy %s -std=c++11 performance-unnecessary-copy-on-last-use %t
----------------
njames93 wrote:
> Running this check explicitly in c++11/17 implies you expect different diagnostics, if so you can use the `--check-suffixes` flag to enable checking configurations. Search for other tests which use that if you're unsure
Not necessarily, I just want the check to work with c++11 and after the changes to the language after c++17 (e.g. guaranteed copy elision).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137205/new/
https://reviews.llvm.org/D137205
More information about the cfe-commits
mailing list