From: Jordan Rose Date: Thu, 25 Jul 2013 22:32:35 +0000 (+0000) Subject: [analyzer] Remove dead optimization for MaterializeTemporaryExpr. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b2c405eb22b2b4844ded1f865675329c2d9793ed;p=clang [analyzer] Remove dead optimization for MaterializeTemporaryExpr. Previously, we tried to avoid creating new temporary object regions if the value to be materialized itself came from a temporary object region. However, once we became more strict about lvalues vs. rvalues (months ago), this optimization became dead code, because the input to this function will always be an rvalue (i.e. a symbolic value or compound value rather than a region, at least for structs). This would be a nice optimization to keep, but removing it makes it simpler to reason about temporary regions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187160 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp b/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp index 1342e4149f..c39d779d69 100644 --- a/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp @@ -30,21 +30,7 @@ void ExprEngine::CreateCXXTemporaryObject(const MaterializeTemporaryExpr *ME, ProgramStateRef state = Pred->getState(); const LocationContext *LCtx = Pred->getLocationContext(); - SVal V = state->getSVal(tempExpr, LCtx); - - // If the value is already a CXXTempObjectRegion, it is fine as it is. - // Otherwise, create a new CXXTempObjectRegion, and copy the value into it. - // This is an optimization for when an rvalue is constructed and then - // immediately materialized. - const MemRegion *MR = V.getAsRegion(); - if (const CXXTempObjectRegion *TR = - dyn_cast_or_null(MR)) { - if (getContext().hasSameUnqualifiedType(TR->getValueType(), ME->getType())) - state = state->BindExpr(ME, LCtx, V); - } - - if (state == Pred->getState()) - state = createTemporaryRegionIfNeeded(state, LCtx, tempExpr, ME); + state = createTemporaryRegionIfNeeded(state, LCtx, tempExpr, ME); Bldr.generateNode(ME, Pred, state); }