[clang] [clang-format] Lambda parameter should be passed by const reference (PR #87306)

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 1 20:11:25 PDT 2024


https://github.com/owenca created https://github.com/llvm/llvm-project/pull/87306

Closes #87254.

>From 91edc2bff0ea98e39b5614ae91ab562c1135b6e7 Mon Sep 17 00:00:00 2001
From: Owen Pan <owenpiano at gmail.com>
Date: Mon, 1 Apr 2024 20:08:21 -0700
Subject: [PATCH] [clang-format] Lambda parameter should be passed by const
 reference

Closes #87254.
---
 clang/lib/Format/Format.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 46ed5baaeacead..1a45d5089e209c 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -3578,7 +3578,7 @@ cleanupAroundReplacements(StringRef Code, const tooling::Replacements &Replaces,
   // We need to use lambda function here since there are two versions of
   // `cleanup`.
   auto Cleanup = [](const FormatStyle &Style, StringRef Code,
-                    std::vector<tooling::Range> Ranges,
+                    const std::vector<tooling::Range> &Ranges,
                     StringRef FileName) -> tooling::Replacements {
     return cleanup(Style, Code, Ranges, FileName);
   };



More information about the cfe-commits mailing list