[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-init: Add a hook... (PR #73921)

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 30 07:25:50 PST 2023


================
@@ -302,6 +303,20 @@ void UnnecessaryCopyInitialization::check(
   }
 }
 
+void UnnecessaryCopyInitialization::makeDiagnostic(
+    DiagnosticBuilder Diagnostic, const VarDecl &Var, const Stmt &BlockStmt,
+    const DeclStmt &Stmt, ASTContext &Context, bool IssueFix) {
+  const bool IsVarUnused = isVariableUnused(Var, BlockStmt, Context);
+  Diagnostic << &Var << IsVarUnused;
+  if (IssueFix) {
+    if (IsVarUnused) {
----------------
PiotrZSL wrote:

no need for extra {} for single statement branches

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


More information about the cfe-commits mailing list