[clang] [NFC][CLANG] Fix static analyzer bugs about unnecessary object copies… (PR #85962)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 20 09:42:46 PDT 2024
https://github.com/smanna12 created https://github.com/llvm/llvm-project/pull/85962
… with auto keyword
Reported by Static Analyzer Tool:
In clang::dataflow::Environment::initialize(): Using the auto keyword without an & causes the copy of an object of type LambdaCapture
>From cb419a47b371a6d70549619304a1b99731e5764f Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" <soumi.manna at intel.com>
Date: Wed, 20 Mar 2024 09:40:00 -0700
Subject: [PATCH] [NFC][CLANG] Fix static analyzer bugs about unnecessary
object copies with auto keyword
Reported by Static Analyzer Tool:
In clang::dataflow::Environment::initialize(): Using the auto keyword without an & causes the copy of an object of type LambdaCapture
---
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index cc1ebd511191a9..70e0623805a8cf 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -416,7 +416,7 @@ void Environment::initialize() {
assert(Parent != nullptr);
if (Parent->isLambda()) {
- for (auto Capture : Parent->captures()) {
+ for (const auto &Capture : Parent->captures()) {
if (Capture.capturesVariable()) {
const auto *VarDecl = Capture.getCapturedVar();
assert(VarDecl != nullptr);
More information about the cfe-commits
mailing list