From: Anna Zaks Date: Tue, 25 Oct 2011 19:57:06 +0000 (+0000) Subject: [analyzer] Simplify CheckerContext X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=063e0887ad65d666d23ee3178436ad6507abbd1b;p=clang [analyzer] Simplify CheckerContext Remove dead members/parameters: ProgramState, respondsToCallback, autoTransition. Remove addTransition method since it's the same as generateNode. Maybe we should rename generateNode to genTransition (since a transition is always automatically generated)? git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142946 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h b/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h index f2e1e2fb23..3edb0d868b 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h @@ -24,25 +24,17 @@ class CheckerContext { ExprEngine &Eng; ExplodedNode *Pred; const ProgramPoint Location; - const ProgramState *ST; NodeBuilder &NB; -public: - bool *respondsToCallback; + public: CheckerContext(NodeBuilder &builder, ExprEngine &eng, ExplodedNode *pred, - const ProgramPoint &loc, - bool *respondsToCB = 0, - const ProgramState *st = 0) + const ProgramPoint &loc) : Eng(eng), Pred(pred), Location(loc), - ST(st), - NB(builder), - respondsToCallback(respondsToCB) { - assert(!(ST && ST != Pred->getState())); - } + NB(builder) {} ~CheckerContext(); @@ -63,7 +55,7 @@ public: } ExplodedNode *&getPredecessor() { return Pred; } - const ProgramState *getState() { return ST ? ST : Pred->getState(); } + const ProgramState *getState() { return Pred->getState(); } /// \brief Returns the number of times the current block has been visited /// along the analyzed path. @@ -95,29 +87,29 @@ public: return Eng.isObjCGCEnabled(); } + AnalysisDeclContext *getCurrentAnalysisDeclContext() const { + return Pred->getLocationContext()->getAnalysisDeclContext(); + } + /// \brief Generate a default checker node (containing checker tag but no /// checker state changes). - ExplodedNode *generateNode(bool autoTransition = true) { - return generateNode(getState(), autoTransition); + ExplodedNode *generateNode() { + return generateNode(getState()); } + /// \brief Generate a new checker node. + ExplodedNode *generateNode(const ProgramState *state, + const ProgramPointTag *tag = 0) { + return generateNodeImpl(state, false, 0, tag); + } + /// \brief Generate a new checker node with the given predecessor. /// Allows checkers to generate a chain of nodes. ExplodedNode *generateNode(const ProgramState *state, ExplodedNode *pred, const ProgramPointTag *tag = 0, - bool autoTransition = true, bool isSink = false) { - ExplodedNode *N = generateNodeImpl(state, isSink, pred, tag); - return N; - } - - /// \brief Generate a new checker node. - ExplodedNode *generateNode(const ProgramState *state, - bool autoTransition = true, - const ProgramPointTag *tag = 0) { - ExplodedNode *N = generateNodeImpl(state, false, 0, tag); - return N; + return generateNodeImpl(state, isSink, pred, tag); } /// \brief Generate a sink node. Generating sink stops exploration of the @@ -126,28 +118,17 @@ public: return generateNodeImpl(state ? state : getState(), true); } - void addTransition(const ProgramState *state, - const ProgramPointTag *tag = 0) { - assert(state); - // If the 'state' is not new, we need to check if the cached state 'ST' - // is new. - if (state != getState()) - generateNode(state, true, tag); - } - + /// \brief Emit the diagnostics report. void EmitReport(BugReport *R) { Eng.getBugReporter().EmitReport(R); } - AnalysisDeclContext *getCurrentAnalysisDeclContext() const { - return Pred->getLocationContext()->getAnalysisDeclContext(); - } - private: ExplodedNode *generateNodeImpl(const ProgramState *state, bool markAsSink, ExplodedNode *pred = 0, const ProgramPointTag *tag = 0) { + assert(state); ExplodedNode *node = NB.generateNode(tag ? Location.withTag(tag) : Location, state, pred ? pred : Pred, markAsSink); diff --git a/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp b/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp index 6935c5f1c1..f8cd335258 100644 --- a/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp @@ -84,8 +84,7 @@ void ArrayBoundChecker::checkLocation(SVal l, bool isLoad, const Stmt* LoadS, // Array bound check succeeded. From this point forward the array bound // should always succeed. - assert(StInBound); - C.addTransition(StInBound); + C.generateNode(StInBound); } void ento::registerArrayBoundChecker(CheckerManager &mgr) { diff --git a/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp b/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp index 8296eb93c5..fa96d62ce3 100644 --- a/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/AttrNonNullChecker.cpp @@ -125,7 +125,7 @@ void AttrNonNullChecker::checkPreStmt(const CallExpr *CE, // If we reach here all of the arguments passed the nonnull check. // If 'state' has been updated generated a new node. - C.addTransition(state); + C.generateNode(state); } void ento::registerAttrNonNullChecker(CheckerManager &mgr) { diff --git a/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp b/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp index 08cff0fd42..0d68db3c8a 100644 --- a/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp +++ b/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp @@ -421,7 +421,7 @@ void CFRetainReleaseChecker::checkPreStmt(const CallExpr *CE, } // From here on, we know the argument is non-null. - C.addTransition(stateFalse); + C.generateNode(stateFalse); } //===----------------------------------------------------------------------===// diff --git a/lib/StaticAnalyzer/Checkers/CStringChecker.cpp b/lib/StaticAnalyzer/Checkers/CStringChecker.cpp index 1625219fc8..78c92ee8ea 100644 --- a/lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -859,7 +859,7 @@ void CStringChecker::evalCopyCommon(CheckerContext &C, // just bind the return value to the destination buffer and return. if (stateZeroSize) { stateZeroSize = stateZeroSize->BindExpr(CE, destVal); - C.addTransition(stateZeroSize); + C.generateNode(stateZeroSize); } // If the size can be nonzero, we have to check the other arguments. @@ -931,7 +931,7 @@ void CStringChecker::evalCopyCommon(CheckerContext &C, // This would probably remove any existing bindings past the end of the // copied region, but that's still an improvement over blank invalidation. state = InvalidateBuffer(C, state, Dest, state->getSVal(Dest)); - C.addTransition(state); + C.generateNode(state); } } @@ -993,7 +993,7 @@ void CStringChecker::evalMemcmp(CheckerContext &C, const CallExpr *CE) const { if (stateZeroSize) { state = stateZeroSize; state = state->BindExpr(CE, svalBuilder.makeZeroVal(CE->getType())); - C.addTransition(state); + C.generateNode(state); } // If the size can be nonzero, we have to check the other arguments. @@ -1017,7 +1017,7 @@ void CStringChecker::evalMemcmp(CheckerContext &C, const CallExpr *CE) const { state = CheckBufferAccess(C, state, Size, Left); if (state) { state = StSameBuf->BindExpr(CE, svalBuilder.makeZeroVal(CE->getType())); - C.addTransition(state); + C.generateNode(state); } } @@ -1031,7 +1031,7 @@ void CStringChecker::evalMemcmp(CheckerContext &C, const CallExpr *CE) const { unsigned Count = C.getCurrentBlockCount(); SVal CmpV = svalBuilder.getConjuredSymbolVal(NULL, CE, Count); state = state->BindExpr(CE, CmpV); - C.addTransition(state); + C.generateNode(state); } } } @@ -1067,7 +1067,7 @@ void CStringChecker::evalstrLengthCommon(CheckerContext &C, const CallExpr *CE, if (stateZeroSize) { SVal zero = C.getSValBuilder().makeZeroVal(CE->getType()); stateZeroSize = stateZeroSize->BindExpr(CE, zero); - C.addTransition(stateZeroSize); + C.generateNode(stateZeroSize); } // If the size is GUARANTEED to be zero, we're done! @@ -1170,7 +1170,7 @@ void CStringChecker::evalstrLengthCommon(CheckerContext &C, const CallExpr *CE, // Bind the return value. assert(!result.isUnknown() && "Should have conjured a value by now"); state = state->BindExpr(CE, result); - C.addTransition(state); + C.generateNode(state); } void CStringChecker::evalStrcpy(CheckerContext &C, const CallExpr *CE) const { @@ -1512,7 +1512,7 @@ void CStringChecker::evalStrcpyCommon(CheckerContext &C, const CallExpr *CE, // Set the return value. state = state->BindExpr(CE, Result); - C.addTransition(state); + C.generateNode(state); } void CStringChecker::evalStrcmp(CheckerContext &C, const CallExpr *CE) const { @@ -1582,7 +1582,7 @@ void CStringChecker::evalStrcmpCommon(CheckerContext &C, const CallExpr *CE, // and we only need to check one size. if (StSameBuf) { StSameBuf = StSameBuf->BindExpr(CE, svalBuilder.makeZeroVal(CE->getType())); - C.addTransition(StSameBuf); + C.generateNode(StSameBuf); // If the two arguments are GUARANTEED to be the same, we're done! if (!StNotSameBuf) @@ -1656,7 +1656,7 @@ void CStringChecker::evalStrcmpCommon(CheckerContext &C, const CallExpr *CE, } // Record this as a possible path. - C.addTransition(state); + C.generateNode(state); } //===----------------------------------------------------------------------===// @@ -1746,7 +1746,7 @@ void CStringChecker::checkPreStmt(const DeclStmt *DS, CheckerContext &C) const { state = state->set(MR, strLength); } - C.addTransition(state); + C.generateNode(state); } bool CStringChecker::wantsRegionChangeUpdate(const ProgramState *state) const { diff --git a/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp b/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp index 4db6ac0181..112424256a 100644 --- a/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp @@ -312,7 +312,7 @@ void CallAndMessageChecker::HandleNilReceiver(CheckerContext &C, // The result is not consumed by a surrounding expression. Just propagate // the current state. - C.addTransition(state); + C.generateNode(state); return; } @@ -353,7 +353,7 @@ void CallAndMessageChecker::HandleNilReceiver(CheckerContext &C, return; } - C.addTransition(state); + C.generateNode(state); } void ento::registerCallAndMessageChecker(CheckerManager &mgr) { diff --git a/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp b/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp index 3c9238190d..769a93e161 100644 --- a/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp @@ -94,7 +94,7 @@ void ChrootChecker::Chroot(CheckerContext &C, const CallExpr *CE) const { // Once encouter a chroot(), set the enum value ROOT_CHANGED directly in // the GDM. state = Mgr.addGDM(state, ChrootChecker::getTag(), (void*) ROOT_CHANGED); - C.addTransition(state); + C.generateNode(state); } void ChrootChecker::Chdir(CheckerContext &C, const CallExpr *CE) const { @@ -120,7 +120,7 @@ void ChrootChecker::Chdir(CheckerContext &C, const CallExpr *CE) const { } } - C.addTransition(state); + C.generateNode(state); } // Check the jail state before any function call except chroot and chdir(). diff --git a/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp b/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp index eeda734a07..ab9631dd3f 100644 --- a/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp @@ -184,7 +184,7 @@ void DereferenceChecker::checkLocation(SVal l, bool isLoad, const Stmt* S, } // From this point forward, we know that the location is not null. - C.addTransition(notNullState); + C.generateNode(notNullState); } void ento::registerDereferenceChecker(CheckerManager &mgr) { diff --git a/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp b/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp index 75b7cc47aa..3bae92b2ec 100644 --- a/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/DivZeroChecker.cpp @@ -73,7 +73,7 @@ void DivZeroChecker::checkPreStmt(const BinaryOperator *B, // If we get here, then the denom should not be zero. We abandon the implicit // zero denom case for now. - C.addTransition(stateNotZero); + C.generateNode(stateNotZero); } void ento::registerDivZeroChecker(CheckerManager &mgr) { diff --git a/lib/StaticAnalyzer/Checkers/IteratorsChecker.cpp b/lib/StaticAnalyzer/Checkers/IteratorsChecker.cpp index fbc57d336f..d7496b1a6e 100644 --- a/lib/StaticAnalyzer/Checkers/IteratorsChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/IteratorsChecker.cpp @@ -472,7 +472,7 @@ void IteratorsChecker::checkPreStmt(const CXXOperatorCallExpr *OCE, if (Kind == OO_Equal) { checkExpr(C, OCE->getArg(1)); state = handleAssign(state, OCE->getArg(0), OCE->getArg(1), LC); - C.addTransition(state); + C.generateNode(state); return; } else { @@ -550,7 +550,7 @@ void IteratorsChecker::checkPreStmt(const DeclStmt *DS, } } } - C.addTransition(state); + C.generateNode(state); } @@ -600,6 +600,6 @@ void IteratorsChecker::checkPreStmt(const CXXMemberCallExpr *MCE, state = state->add(MR); if (state != C.getState()) - C.addTransition(state); + C.generateNode(state); } diff --git a/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp b/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp index e975dd55a8..29e119da4d 100644 --- a/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/MacOSKeychainAPIChecker.cpp @@ -400,7 +400,7 @@ void MacOSKeychainAPIChecker::checkPreStmt(const CallExpr *CE, // custom deallocator which does the right thing. if (DE->getFoundDecl()->getName() != "kCFAllocatorNull") { State = State->remove(ArgSM); - C.addTransition(State); + C.generateNode(State); return; } } @@ -434,7 +434,7 @@ void MacOSKeychainAPIChecker::checkPreStmt(const CallExpr *CE, return; } - C.addTransition(State); + C.generateNode(State); } void MacOSKeychainAPIChecker::checkPostStmt(const CallExpr *CE, @@ -482,7 +482,7 @@ void MacOSKeychainAPIChecker::checkPostStmt(const CallExpr *CE, State = State->set(V, AllocationState(ArgExpr, idx, RetStatusSymbol)); assert(State); - C.addTransition(State); + C.generateNode(State); } } @@ -500,7 +500,7 @@ void MacOSKeychainAPIChecker::checkPreStmt(const ReturnStmt *S, state = state->remove(getSymbolForRegion(C, V)); // Proceed from the new state. - C.addTransition(state); + C.generateNode(state); } BugReport *MacOSKeychainAPIChecker:: diff --git a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index a04f02493d..edea33ea69 100644 --- a/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -197,7 +197,7 @@ bool MallocChecker::evalCall(const CallExpr *CE, CheckerContext &C) const { void MallocChecker::MallocMem(CheckerContext &C, const CallExpr *CE) { const ProgramState *state = MallocMemAux(C, CE, CE->getArg(0), UndefinedVal(), C.getState()); - C.addTransition(state); + C.generateNode(state); } void MallocChecker::MallocMemReturnsAttr(CheckerContext &C, const CallExpr *CE, @@ -209,12 +209,12 @@ void MallocChecker::MallocMemReturnsAttr(CheckerContext &C, const CallExpr *CE, if (I != E) { const ProgramState *state = MallocMemAux(C, CE, CE->getArg(*I), UndefinedVal(), C.getState()); - C.addTransition(state); + C.generateNode(state); return; } const ProgramState *state = MallocMemAux(C, CE, UnknownVal(), UndefinedVal(), C.getState()); - C.addTransition(state); + C.generateNode(state); } const ProgramState *MallocChecker::MallocMemAux(CheckerContext &C, @@ -252,7 +252,7 @@ void MallocChecker::FreeMem(CheckerContext &C, const CallExpr *CE) const { const ProgramState *state = FreeMemAux(C, CE, C.getState(), 0, false); if (state) - C.addTransition(state); + C.generateNode(state); } void MallocChecker::FreeMemAttr(CheckerContext &C, const CallExpr *CE, @@ -265,7 +265,7 @@ void MallocChecker::FreeMemAttr(CheckerContext &C, const CallExpr *CE, const ProgramState *state = FreeMemAux(C, CE, C.getState(), *I, Att->getOwnKind() == OwnershipAttr::Holds); if (state) - C.addTransition(state); + C.generateNode(state); } } @@ -531,7 +531,7 @@ void MallocChecker::ReallocMem(CheckerContext &C, const CallExpr *CE) const { const ProgramState *stateMalloc = MallocMemAux(C, CE, CE->getArg(1), UndefinedVal(), stateEqual); - C.addTransition(stateMalloc); + C.generateNode(stateMalloc); } if (const ProgramState *stateNotEqual = state->assume(PtrEQ, false)) { @@ -541,7 +541,7 @@ void MallocChecker::ReallocMem(CheckerContext &C, const CallExpr *CE) const { FreeMemAux(C, CE, stateSizeZero, 0, false)) { // Bind the return value to NULL because it is now free. - C.addTransition(stateFree->BindExpr(CE, svalBuilder.makeNull(), true)); + C.generateNode(stateFree->BindExpr(CE, svalBuilder.makeNull(), true)); } if (const ProgramState *stateSizeNotZero = stateNotEqual->assume(SizeZero,false)) if (const ProgramState *stateFree = FreeMemAux(C, CE, stateSizeNotZero, @@ -549,7 +549,7 @@ void MallocChecker::ReallocMem(CheckerContext &C, const CallExpr *CE) const { // FIXME: We should copy the content of the original buffer. const ProgramState *stateRealloc = MallocMemAux(C, CE, CE->getArg(1), UnknownVal(), stateFree); - C.addTransition(stateRealloc); + C.generateNode(stateRealloc); } } } @@ -564,7 +564,7 @@ void MallocChecker::CallocMem(CheckerContext &C, const CallExpr *CE) { svalBuilder.getContext().getSizeType()); SVal zeroVal = svalBuilder.makeZeroVal(svalBuilder.getContext().CharTy); - C.addTransition(MallocMemAux(C, CE, TotalSize, zeroVal, state)); + C.generateNode(MallocMemAux(C, CE, TotalSize, zeroVal, state)); } void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, @@ -642,7 +642,7 @@ void MallocChecker::checkPreStmt(const ReturnStmt *S, CheckerContext &C) const { if (RS->isAllocated()) state = state->set(Sym, RefState::getEscaped(S)); - C.addTransition(state); + C.generateNode(state); } const ProgramState *MallocChecker::evalAssume(const ProgramState *state, SVal Cond, @@ -707,7 +707,7 @@ void MallocChecker::checkBind(SVal location, SVal val, // Generate a transition for 'nullState' to record the assumption // that the state was null. if (nullState) - C.addTransition(nullState); + C.generateNode(nullState); if (!notNullState) return; @@ -735,7 +735,7 @@ void MallocChecker::checkBind(SVal location, SVal val, } while (false); } - C.addTransition(notNullState); + C.generateNode(notNullState); } } } diff --git a/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp b/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp index 5678998359..92702ebb3d 100644 --- a/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp @@ -193,7 +193,7 @@ template static void setFlag(const ProgramState *state, SVal val, CheckerContext &C) { // We tag the symbol that the SVal wraps. if (SymbolRef sym = val.getAsSymbol()) - C.addTransition(state->set(sym, true)); + C.generateNode(state->set(sym, true)); } static QualType parameterTypeFromSVal(SVal val, CheckerContext &C) { diff --git a/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp b/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp index 3e4e07b650..85ed86021c 100644 --- a/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp @@ -84,7 +84,7 @@ void ObjCAtSyncChecker::checkPreStmt(const ObjCAtSynchronizedStmt *S, } if (notNullState) - C.addTransition(notNullState); + C.generateNode(notNullState); } void ento::registerObjCAtSyncChecker(CheckerManager &mgr) { diff --git a/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp b/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp index 8b29a20dc6..e480ec55d0 100644 --- a/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp @@ -145,7 +145,7 @@ static void addSelfFlag(const ProgramState *state, SVal val, SelfFlagEnum flag, CheckerContext &C) { // We tag the symbol that the SVal wraps. if (SymbolRef sym = val.getAsSymbol()) - C.addTransition(state->set(sym, getSelfFlags(val, C) | flag)); + C.generateNode(state->set(sym, getSelfFlags(val, C) | flag)); } static bool hasSelfFlag(SVal val, SelfFlagEnum flag, CheckerContext &C) { @@ -265,11 +265,11 @@ void ObjCSelfInitChecker::checkPreStmt(const CallExpr *CE, SVal argV = state->getSVal(*I); if (isSelfVar(argV, C)) { unsigned selfFlags = getSelfFlags(state->getSVal(cast(argV)), C); - C.addTransition(state->set(selfFlags)); + C.generateNode(state->set(selfFlags)); return; } else if (hasSelfFlag(argV, SelfFlag_Self, C)) { unsigned selfFlags = getSelfFlags(argV, C); - C.addTransition(state->set(selfFlags)); + C.generateNode(state->set(selfFlags)); return; } } diff --git a/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp b/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp index c02b5b14ca..c83e17c268 100644 --- a/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp @@ -141,7 +141,7 @@ void PthreadLockChecker::AcquireLock(CheckerContext &C, const CallExpr *CE, break; } assert(lockFail && lockSucc); - C.addTransition(lockFail); + C.generateNode(lockFail); } else if (semantics == PthreadSemantics) { // Assume that the return value was 0. @@ -156,7 +156,7 @@ void PthreadLockChecker::AcquireLock(CheckerContext &C, const CallExpr *CE, // Record that the lock was acquired. lockSucc = lockSucc->add(lockR); - C.addTransition(lockSucc); + C.generateNode(lockSucc); } void PthreadLockChecker::ReleaseLock(CheckerContext &C, const CallExpr *CE, @@ -193,7 +193,7 @@ void PthreadLockChecker::ReleaseLock(CheckerContext &C, const CallExpr *CE, // Record that the lock was released. state = state->set(LS.getTail()); - C.addTransition(state); + C.generateNode(state); } diff --git a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp index c7d108b2f7..03096c1b9c 100644 --- a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -53,7 +53,7 @@ public: ExplodedNode *MakeNode(const ProgramState *state, ExplodedNode *Pred, bool MarkAsSink = false) { assert(C); - return C->generateNode(state, Pred, tag, false, MarkAsSink); + return C->generateNode(state, Pred, tag, MarkAsSink); } }; } // end anonymous namespace @@ -2517,7 +2517,7 @@ void RetainCountChecker::checkPostStmt(const BlockExpr *BE, state = state->scanReachableSymbols(Regions.data(), Regions.data() + Regions.size()).getState(); - C.addTransition(state); + C.generateNode(state); } void RetainCountChecker::checkPostStmt(const CastExpr *CE, @@ -3047,7 +3047,7 @@ bool RetainCountChecker::evalCall(const CallExpr *CE, CheckerContext &C) const { state = state->set(Sym, *Binding); } - C.addTransition(state); + C.generateNode(state); return true; } @@ -3252,7 +3252,7 @@ void RetainCountChecker::checkBind(SVal loc, SVal val, const Stmt *S, // Otherwise, find all symbols referenced by 'val' that we are tracking // and stop tracking them. state = state->scanReachableSymbols(val).getState(); - C.addTransition(state); + C.generateNode(state); } const ProgramState *RetainCountChecker::evalAssume(const ProgramState *state, diff --git a/lib/StaticAnalyzer/Checkers/StreamChecker.cpp b/lib/StaticAnalyzer/Checkers/StreamChecker.cpp index 8010e8dbac..36b1e71ac5 100644 --- a/lib/StaticAnalyzer/Checkers/StreamChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/StreamChecker.cpp @@ -241,15 +241,15 @@ void StreamChecker::OpenFileAux(CheckerContext &C, const CallExpr *CE) const { stateNull = stateNull->set(Sym, StreamState::getOpenFailed(CE)); - C.addTransition(stateNotNull); - C.addTransition(stateNull); + C.generateNode(stateNotNull); + C.generateNode(stateNull); } } void StreamChecker::Fclose(CheckerContext &C, const CallExpr *CE) const { const ProgramState *state = CheckDoubleClose(CE, C.getState(), C); if (state) - C.addTransition(state); + C.generateNode(state); } void StreamChecker::Fread(CheckerContext &C, const CallExpr *CE) const { @@ -457,7 +457,7 @@ void StreamChecker::checkPreStmt(const ReturnStmt *S, CheckerContext &C) const { if (SS->isOpened()) state = state->set(Sym, StreamState::getEscaped(S)); - C.addTransition(state); + C.generateNode(state); } void ento::registerStreamChecker(CheckerManager &mgr) { diff --git a/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp b/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp index cec286d2f3..87f532a774 100644 --- a/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp @@ -215,7 +215,7 @@ void UnixAPIChecker::CheckMallocZero(CheckerContext &C, // Assume the the value is non-zero going forward. assert(trueState); if (trueState != state) { - C.addTransition(trueState); + C.generateNode(trueState); } } diff --git a/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp b/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp index b34b97c5b3..7e4dfc57d2 100644 --- a/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp @@ -129,7 +129,7 @@ void VLASizeChecker::checkPreStmt(const DeclStmt *DS, CheckerContext &C) const { assert(state); // Remember our assumptions! - C.addTransition(state); + C.generateNode(state); } void ento::registerVLASizeChecker(CheckerManager &mgr) { diff --git a/lib/StaticAnalyzer/Core/CheckerManager.cpp b/lib/StaticAnalyzer/Core/CheckerManager.cpp index ecb1a7a4ce..a3d2bfd5fe 100644 --- a/lib/StaticAnalyzer/Core/CheckerManager.cpp +++ b/lib/StaticAnalyzer/Core/CheckerManager.cpp @@ -153,7 +153,7 @@ namespace { ProgramPoint::PostStmtKind; const ProgramPoint &L = ProgramPoint::getProgramPoint(S, K, Pred->getLocationContext(), checkFn.Checker); - CheckerContext C(Bldr, Eng, Pred, L, 0); + CheckerContext C(Bldr, Eng, Pred, L); checkFn(S, C); } @@ -192,7 +192,7 @@ namespace { ProgramPoint::PostStmtKind; const ProgramPoint &L = ProgramPoint::getProgramPoint(Msg.getOriginExpr(), K, Pred->getLocationContext(), checkFn.Checker); - CheckerContext C(Bldr, Eng, Pred, L, 0); + CheckerContext C(Bldr, Eng, Pred, L); checkFn(Msg, C); } @@ -234,7 +234,7 @@ namespace { ProgramPoint::PreStoreKind; const ProgramPoint &L = ProgramPoint::getProgramPoint(S, K, Pred->getLocationContext(), checkFn.Checker); - CheckerContext C(Bldr, Eng, Pred, L, 0); + CheckerContext C(Bldr, Eng, Pred, L); checkFn(Loc, IsLoad, S, C); } @@ -273,7 +273,7 @@ namespace { NodeBuilder &Bldr, ExplodedNode *Pred) { const ProgramPoint &L = ProgramPoint::getProgramPoint(S, PointKind, Pred->getLocationContext(), checkFn.Checker); - CheckerContext C(Bldr, Eng, Pred, L, 0); + CheckerContext C(Bldr, Eng, Pred, L); checkFn(Loc, Val, S, C); } @@ -315,7 +315,7 @@ void CheckerManager::runCheckersForEndPath(NodeBuilderContext &BC, const ProgramPoint &L = BlockEntrance(BC.Block, Pred->getLocationContext(), checkFn.Checker); - CheckerContext C(Bldr, Eng, Pred, L, 0); + CheckerContext C(Bldr, Eng, Pred, L); checkFn(C); } } @@ -338,7 +338,7 @@ namespace { NodeBuilder &Bldr, ExplodedNode *Pred) { ProgramPoint L = PostCondition(Condition, Pred->getLocationContext(), checkFn.Checker); - CheckerContext C(Bldr, Eng, Pred, L, 0); + CheckerContext C(Bldr, Eng, Pred, L); checkFn(Condition, C); } }; @@ -382,7 +382,7 @@ namespace { ProgramPoint::Kind K = ProgramPoint::PostPurgeDeadSymbolsKind; const ProgramPoint &L = ProgramPoint::getProgramPoint(S, K, Pred->getLocationContext(), checkFn.Checker); - CheckerContext C(Bldr, Eng, Pred, L, 0); + CheckerContext C(Bldr, Eng, Pred, L); checkFn(SR, C); } @@ -500,7 +500,7 @@ void CheckerManager::runCheckersForEvalCall(ExplodedNodeSet &Dst, { // CheckerContext generates transitions(populates checkDest) on // destruction, so introduce the scope to make sure it gets properly // populated. - CheckerContext C(B, Eng, Pred, L, 0); + CheckerContext C(B, Eng, Pred, L); evaluated = (*EI)(CE, C); } assert(!(evaluated && anyEvaluated)