[clang] ad17e69 - [analyzer] Fix unused variable warning in release builds. NFC.

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 26 02:32:21 PDT 2022


Author: Benjamin Kramer
Date: 2022-07-26T11:29:38+02:00
New Revision: ad17e69923ec39b6439ac0041e69de1f1f5ecec4

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

LOG: [analyzer] Fix unused variable warning in release builds. NFC.

Added: 
    

Modified: 
    clang/lib/StaticAnalyzer/Core/ExprEngine.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 936d4ed7c89b..19149d079822 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -541,8 +541,6 @@ ExprEngine::addObjectUnderConstruction(ProgramStateRef State,
   if (const auto *AILE = dyn_cast_or_null<ArrayInitLoopExpr>(Init))
     Init = AILE->getSubExpr();
 
-  const auto *E = dyn_cast_or_null<CXXConstructExpr>(Init);
-
   // FIXME: Currently the state might already contain the marker due to
   // incorrect handling of temporaries bound to default parameters.
   // The state will already contain the marker if we construct elements
@@ -552,7 +550,8 @@ ExprEngine::addObjectUnderConstruction(ProgramStateRef State,
   assert((!State->get<ObjectsUnderConstruction>(Key) ||
           Key.getItem().getKind() ==
               ConstructionContextItem::TemporaryDestructorKind ||
-          State->contains<IndexOfElementToConstruct>({E, LC})) &&
+          State->contains<IndexOfElementToConstruct>(
+              {dyn_cast_or_null<CXXConstructExpr>(Init), LC})) &&
          "The object is already marked as `UnderConstruction`, when it's not "
          "supposed to!");
   return State->set<ObjectsUnderConstruction>(Key, V);


        


More information about the cfe-commits mailing list