From: Ted Kremenek Date: Mon, 7 Jul 2008 16:21:19 +0000 (+0000) Subject: Updated clients of ImmutableMap::SlimFind to use ImmutableMap::lookup instead. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e8fdc83ee4819336f5b201e2aa14d0dddcf14b63;p=clang Updated clients of ImmutableMap::SlimFind to use ImmutableMap::lookup instead. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53172 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp index a9c4f840f0..7a3df3153e 100644 --- a/lib/Analysis/CFRefCount.cpp +++ b/lib/Analysis/CFRefCount.cpp @@ -1377,13 +1377,13 @@ void CFRefCount::EvalSummary(ExplodedNodeSet& Dst, SymbolID Sym = cast(V).getSymbol(); RefBindings B = GetRefBindings(StVals); - if (RefBindings::TreeTy* T = B.SlimFind(Sym)) { - B = Update(B, Sym, T->getValue().second, GetArgE(Summ, idx), hasErr); + if (RefBindings::data_type* T = B.lookup(Sym)) { + B = Update(B, Sym, *T, GetArgE(Summ, idx), hasErr); SetRefBindings(StVals, B); if (hasErr) { ErrorExpr = *I; - ErrorSym = T->getValue().first; + ErrorSym = Sym; break; } } @@ -1431,13 +1431,13 @@ void CFRefCount::EvalSummary(ExplodedNodeSet& Dst, SymbolID Sym = cast(V).getSymbol(); RefBindings B = GetRefBindings(StVals); - if (RefBindings::TreeTy* T = B.SlimFind(Sym)) { - B = Update(B, Sym, T->getValue().second, GetReceiverE(Summ), hasErr); + if (const RefVal* T = B.lookup(Sym)) { + B = Update(B, Sym, *T, GetReceiverE(Summ), hasErr); SetRefBindings(StVals, B); if (hasErr) { ErrorExpr = Receiver; - ErrorSym = T->getValue().first; + ErrorSym = Sym; } } } @@ -1581,8 +1581,8 @@ void CFRefCount::EvalObjCMessageExpr(ExplodedNodeSet& Dst, if (isa(V)) { SymbolID Sym = cast(V).getSymbol(); - if (RefBindings::TreeTy* T = GetRefBindings(*St).SlimFind(Sym)) { - QualType Ty = T->getValue().second.getType(); + if (const RefVal* T = GetRefBindings(*St).lookup(Sym)) { + QualType Ty = T->getType(); if (const PointerType* PT = Ty->getAsPointerType()) { QualType PointeeTy = PT->getPointeeType(); @@ -1630,10 +1630,8 @@ void CFRefCount::EvalStore(ExplodedNodeSet& Dst, return; SymbolID Sym = cast(Val).getSymbol(); - RefBindings B = GetRefBindings(*St); - RefBindings::TreeTy* T = B.SlimFind(Sym); - if (!T) + if (!GetRefBindings(*St).lookup(Sym)) return; // Nuke the binding. @@ -1723,17 +1721,17 @@ void CFRefCount::EvalDeadSymbols(ExplodedNodeSet& Dst, for (ValueStateManager::DeadSymbolsTy::const_iterator I=Dead.begin(), E=Dead.end(); I!=E; ++I) { - RefBindings::TreeTy* T = B.SlimFind(*I); + const RefVal* T = B.lookup(*I); if (!T) continue; bool hasLeak = false; - St = HandleSymbolDeath(Eng.getStateManager(), St, - *I, T->getValue().second, hasLeak); + St = HandleSymbolDeath(Eng.getStateManager(), St, *I, *T, hasLeak); - if (hasLeak) Leaked.push_back(*I); + if (hasLeak) + Leaked.push_back(*I); } if (Leaked.empty()) @@ -1774,14 +1772,14 @@ void CFRefCount::EvalReturn(ExplodedNodeSet& Dst, // Get the reference count binding (if any). SymbolID Sym = cast(V).getSymbol(); RefBindings B = GetRefBindings(*St); - RefBindings::TreeTy* T = B.SlimFind(Sym); + const RefVal* T = B.lookup(Sym); if (!T) return; // Change the reference count. - RefVal X = T->getValue().second; + RefVal X = *T; switch (X.getKind()) { @@ -2122,14 +2120,14 @@ PathDiagnosticPiece* CFRefReport::VisitNode(ExplodedNode* N, CFRefCount::RefBindings PrevB = CFRefCount::GetRefBindings(*PrevSt); CFRefCount::RefBindings CurrB = CFRefCount::GetRefBindings(*CurrSt); - CFRefCount::RefBindings::TreeTy* PrevT = PrevB.SlimFind(Sym); - CFRefCount::RefBindings::TreeTy* CurrT = CurrB.SlimFind(Sym); + const RefVal* PrevT = PrevB.lookup(Sym); + const RefVal* CurrT = CurrB.lookup(Sym); if (!CurrT) return NULL; const char* Msg = NULL; - RefVal CurrV = CurrB.SlimFind(Sym)->getValue().second; + const RefVal& CurrV = *CurrB.lookup(Sym); if (!PrevT) { @@ -2168,9 +2166,8 @@ PathDiagnosticPiece* CFRefReport::VisitNode(ExplodedNode* N, return P; } - // Determine if the typestate has changed. - - RefVal PrevV = PrevB.SlimFind(Sym)->getValue().second; + // Determine if the typestate has changed. + RefVal PrevV = *PrevB.lookup(Sym); if (PrevV == CurrV) return NULL; @@ -2258,9 +2255,8 @@ GetAllocationSite(ExplodedNode* N, SymbolID Sym) { while (N) { ValueState* St = N->getState(); RefBindings B = RefBindings((RefBindings::TreeTy*) St->CheckerState); - RefBindings::TreeTy* T = B.SlimFind(Sym); - if (!T) + if (!B.lookup(Sym)) break; VarDecl* VD = 0; @@ -2301,16 +2297,10 @@ PathDiagnosticPiece* CFRefReport::getEndPath(BugReporter& BR, typedef CFRefCount::RefBindings RefBindings; // Get the retain count. - unsigned long RetCount = 0; - - { - ValueState* St = EndN->getState(); - RefBindings B = RefBindings((RefBindings::TreeTy*) St->CheckerState); - RefBindings::TreeTy* T = B.SlimFind(Sym); - assert (T); - RetCount = T->getValue().second.getCount(); - } + unsigned long RetCount = + CFRefCount::GetRefBindings(*EndN->getState()).lookup(Sym)->getCount(); + // We are a leak. Walk up the graph to get to the first node where the // symbol appeared, and also get the first VarDecl that tracked object // is stored to. diff --git a/lib/Analysis/GRBlockCounter.cpp b/lib/Analysis/GRBlockCounter.cpp index 3ecc39d322..f69a16da40 100644 --- a/lib/Analysis/GRBlockCounter.cpp +++ b/lib/Analysis/GRBlockCounter.cpp @@ -30,8 +30,8 @@ static inline CountMap::Factory& GetFactory(void* F) { unsigned GRBlockCounter::getNumVisited(unsigned BlockID) const { CountMap M = GetMap(Data); - CountMap::TreeTy* T = M.SlimFind(BlockID); - return T ? T->getValue().second : 0; + CountMap::data_type* T = M.lookup(BlockID); + return T ? *T : 0; } GRBlockCounter::Factory::Factory(llvm::BumpPtrAllocator& Alloc) { diff --git a/lib/Analysis/ValueState.cpp b/lib/Analysis/ValueState.cpp index 96b94ea8cf..097969ba96 100644 --- a/lib/Analysis/ValueState.cpp +++ b/lib/Analysis/ValueState.cpp @@ -19,15 +19,15 @@ using namespace clang; bool ValueState::isNotEqual(SymbolID sym, const llvm::APSInt& V) const { // Retrieve the NE-set associated with the given symbol. - ConstNotEqTy::TreeTy* T = ConstNotEq.SlimFind(sym); + const ConstNotEqTy::data_type* T = ConstNotEq.lookup(sym); // See if V is present in the NE-set. - return T ? T->getValue().second.contains(&V) : false; + return T ? T->contains(&V) : false; } const llvm::APSInt* ValueState::getSymVal(SymbolID sym) const { - ConstEqTy::TreeTy* T = ConstEq.SlimFind(sym); - return T ? T->getValue().second : NULL; + ConstEqTy::data_type* T = ConstEq.lookup(sym); + return T ? *T : NULL; } ValueState* @@ -170,10 +170,10 @@ RVal ValueStateManager::GetRVal(ValueState* St, LVal LV, QualType T) { switch (LV.getSubKind()) { case lval::DeclValKind: { - ValueState::VarBindingsTy::TreeTy* T = - St->VarBindings.SlimFind(cast(LV).getDecl()); + ValueState::VarBindingsTy::data_type* T = + St->VarBindings.lookup(cast(LV).getDecl()); - return T ? T->getValue().second : UnknownVal(); + return T ? *T : UnknownVal(); } // FIXME: We should limit how far a "ContentsOf" will go... @@ -233,8 +233,8 @@ ValueState* ValueStateManager::AddNE(ValueState* St, SymbolID sym, const llvm::APSInt& V) { // First, retrieve the NE-set associated with the given symbol. - ValueState::ConstNotEqTy::TreeTy* T = St->ConstNotEq.SlimFind(sym); - ValueState::IntSetTy S = T ? T->getValue().second : ISetFactory.GetEmptySet(); + ValueState::ConstNotEqTy::data_type* T = St->ConstNotEq.lookup(sym); + ValueState::IntSetTy S = T ? *T : ISetFactory.GetEmptySet(); // Now add V to the NE set. S = ISetFactory.Add(S, &V); @@ -321,13 +321,13 @@ RVal ValueStateManager::GetRVal(ValueState* St, Expr* E) { break; } - ValueState::ExprBindingsTy::TreeTy* T = St->SubExprBindings.SlimFind(E); + ValueState::ExprBindingsTy::data_type* T = St->SubExprBindings.lookup(E); if (T) - return T->getValue().second; + return *T; - T = St->BlockExprBindings.SlimFind(E); - return T ? T->getValue().second : UnknownVal(); + T = St->BlockExprBindings.lookup(E); + return T ? *T : UnknownVal(); } RVal ValueStateManager::GetBlkExprRVal(ValueState* St, Expr* E) { @@ -345,8 +345,8 @@ RVal ValueStateManager::GetBlkExprRVal(ValueState* St, Expr* E) { } default: { - ValueState::ExprBindingsTy::TreeTy* T = St->BlockExprBindings.SlimFind(E); - return T ? T->getValue().second : UnknownVal(); + ValueState::ExprBindingsTy::data_type* T=St->BlockExprBindings.lookup(E); + return T ? *T : UnknownVal(); } } }