[clang] 4c4ea24 - [NFC][CLANG] Fix static analyzer bugs about unnecessary object copies with auto keyword (#85962)

via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 26 10:05:44 PDT 2024


Author: smanna12
Date: 2024-03-26T12:05:40-05:00
New Revision: 4c4ea249cef8db71d30517aab60a081e764260e1

URL: https://github.com/llvm/llvm-project/commit/4c4ea249cef8db71d30517aab60a081e764260e1
DIFF: https://github.com/llvm/llvm-project/commit/4c4ea249cef8db71d30517aab60a081e764260e1.diff

LOG: [NFC][CLANG] Fix static analyzer bugs about unnecessary object copies with auto keyword (#85962)

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

Added: 
    

Modified: 
    clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp

Removed: 
    


################################################################################
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