[analyzer] Fix unused variable warning in release builds. NFC.
authorBenjamin Kramer <benny.kra@googlemail.com>
Tue, 26 Jul 2022 09:26:52 +0000 (11:26 +0200)
committerBenjamin Kramer <benny.kra@googlemail.com>
Tue, 26 Jul 2022 09:29:38 +0000 (11:29 +0200)
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp

index 936d4ed..19149d0 100644 (file)
@@ -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);