Index: clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp +++ clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp @@ -1151,7 +1151,7 @@ // Check if we're inside an ArrayInitLoopExpr, and it's sufficiently small. if (auto Size = getPendingInitLoop(State, CE, LCtx)) - return *Size <= AMgr.options.maxBlockVisitOnPath; + return shouldInlineArrayDestruction(*Size); return false; } @@ -1246,7 +1246,21 @@ } } - // If we can't inline it, handle the return value and invalidate the regions. + // If we can't inline it, clean up the state traits used only if the function + // is inlined. + if (const auto *CE = dyn_cast_or_null(E)) { + const auto *LCtx = Call->getLocationContext(); + if (getPendingInitLoop(State, CE, LCtx)) + State = removePendingInitLoop(State, CE, LCtx); + + if (getIndexOfElementToConstruct(State, CE, LCtx)) + State = removeIndexOfElementToConstruct(State, CE, LCtx); + + if (getPendingArrayDestruction(State, LCtx)) + State = removePendingArrayDestruction(State, LCtx); + } + + // Also handle the return value and invalidate the regions. conservativeEvalCall(*Call, Bldr, Pred, State); }