[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-init: Add a hook... (PR #73921)
Clement Courbet via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 6 04:25:59 PST 2023
================
@@ -32,14 +32,34 @@ class UnnecessaryCopyInitialization : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+protected:
+ // A helper to manipulate the state common to
+ // `CopyFromMethodReturn` and `CopyFromLocalVar`.
+ struct CheckContext {
+ CheckContext(const ast_matchers::MatchFinder::MatchResult &Result);
+ const VarDecl &Var;
+ const Stmt &BlockStmt;
+ const DeclStmt &VarDeclStmt;
+ clang::ASTContext &ASTCtx;
+ const bool IssueFix;
+ const bool IsVarUnused;
+ const bool IsVarOnlyUsedAsConst;
+ };
+
+ // Create diagnostics. These are virtual so that derived classes can change
+ // behaviour.
+ virtual void diagnoseCopyFromMethodReturn(const CheckContext &Ctx,
----------------
legrosbuffle wrote:
`ObjectArg` is a pointer because it can be null (unlike other variables, which are always non-null. Anyway, this is no longer provided as pre the previous comment.
https://github.com/llvm/llvm-project/pull/73921
More information about the cfe-commits
mailing list