https://github.com/shafik created https://github.com/llvm/llvm-project/pull/153863
Static analysis flagged this code because it will cause unneeded copies of std::string. This fix is merely to use const auto & in the trailing return type. >From f0c903995ffb19e02394601179f05082c132d037 Mon Sep 17 00:00:00 2001 From: Shafik Yaghmour <shafik.yaghm...@intel.com> Date: Fri, 15 Aug 2025 12:43:25 -0700 Subject: [PATCH] [Clang][NFC] Avoid repeating copy of std::string in lambda implementation Static analysis flagged this code because it will cause unneeded copies of std::string. This fix is merely to use const auto & in the trailing return type. --- .../clang/Tooling/DependencyScanning/DependencyScanningTool.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h index c3601a4e73e1f..81177a04654bb 100644 --- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h +++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h @@ -205,7 +205,7 @@ class FullDependencyConsumer : public DependencyConsumer { std::vector<P1689ModuleInfo> Requires) override { ModuleName = Provided ? Provided->ModuleName : ""; llvm::transform(Requires, std::back_inserter(NamedModuleDeps), - [](const auto &Module) { return Module.ModuleName; }); + [](const auto &Module) -> const auto & { return Module.ModuleName; }); } TranslationUnitDeps takeTranslationUnitDeps(); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits