================
@@ -263,19 +264,26 @@ void 
UnnecessaryCopyInitialization::registerMatchers(MatchFinder *Finder) {
 
 void UnnecessaryCopyInitialization::check(
     const MatchFinder::MatchResult &Result) {
-  const auto *NewVar = Result.Nodes.getNodeAs<VarDecl>("newVarDecl");
+  const auto &NewVar = *Result.Nodes.getNodeAs<VarDecl>("newVarDecl");
+  const auto &BlockStmt = *Result.Nodes.getNodeAs<Stmt>("blockStmt");
+  const auto &VarDeclStmt = *Result.Nodes.getNodeAs<DeclStmt>("declStmt");
+  const CheckContext Context{
+      NewVar, BlockStmt, VarDeclStmt, *Result.Context,
+      // Do not propose fixes if the DeclStmt has multiple VarDecls or in
+      // macros since we cannot place them correctly.
+      /*IssueFix*/ VarDeclStmt.isSingleDecl() &&
----------------
PiotrZSL wrote:

Do not call functions in this initialization, simple create local variables 
IssueFix, IsVarUnused, IsVarOnlyUsedAsConst and pass them to Context. In such 
case Context construction will be a simple one liner.

https://github.com/llvm/llvm-project/pull/73921
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to