From: Gabor Horvath Date: Sat, 15 Dec 2018 13:20:33 +0000 (+0000) Subject: [analyzer] Assume that we always have a SubEngine available X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b1e9e90f5d1f8fd83845996e549368c11cf1f4ea;p=clang [analyzer] Assume that we always have a SubEngine available The removed codepath was dead. Differential Revision: https://reviews.llvm.org/D55697 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349266 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h b/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h index f544204497..c3a7028d87 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h @@ -555,15 +555,15 @@ public: MemRegionManager& getRegionManager() { return svalBuilder->getRegionManager(); } - const MemRegionManager& getRegionManager() const { + const MemRegionManager &getRegionManager() const { return svalBuilder->getRegionManager(); } CallEventManager &getCallEventManager() { return *CallEventMgr; } - StoreManager& getStoreManager() { return *StoreMgr; } - ConstraintManager& getConstraintManager() { return *ConstraintMgr; } - SubEngine* getOwningEngine() { return Eng; } + StoreManager &getStoreManager() { return *StoreMgr; } + ConstraintManager &getConstraintManager() { return *ConstraintMgr; } + SubEngine &getOwningEngine() { return *Eng; } ProgramStateRef removeDeadBindings(ProgramStateRef St, const StackFrameContext *LCtx, diff --git a/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp b/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp index f9cf97e508..590bdd20ad 100644 --- a/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp @@ -56,7 +56,7 @@ class AnalysisOrderChecker bool isCallbackEnabled(ProgramStateRef State, StringRef CallbackName) const { AnalyzerOptions &Opts = State->getStateManager().getOwningEngine() - ->getAnalysisManager().getAnalyzerOptions(); + .getAnalysisManager().getAnalyzerOptions(); return isCallbackEnabled(Opts, CallbackName); } diff --git a/lib/StaticAnalyzer/Core/CallEvent.cpp b/lib/StaticAnalyzer/Core/CallEvent.cpp index 8d9338b21c..20baa30265 100644 --- a/lib/StaticAnalyzer/Core/CallEvent.cpp +++ b/lib/StaticAnalyzer/Core/CallEvent.cpp @@ -550,15 +550,15 @@ RuntimeDefinition AnyFunctionCall::getRuntimeDefinition() const { return RuntimeDefinition(Decl); } - SubEngine *Engine = getState()->getStateManager().getOwningEngine(); - AnalyzerOptions &Opts = Engine->getAnalysisManager().options; + SubEngine &Engine = getState()->getStateManager().getOwningEngine(); + AnalyzerOptions &Opts = Engine.getAnalysisManager().options; // Try to get CTU definition only if CTUDir is provided. if (!Opts.IsNaiveCTUEnabled) return {}; cross_tu::CrossTranslationUnitContext &CTUCtx = - *Engine->getCrossTranslationUnitContext(); + *Engine.getCrossTranslationUnitContext(); llvm::Expected CTUDeclOrError = CTUCtx.getCrossTUDefinition(FD, Opts.CTUDir, Opts.CTUIndexName, Opts.DisplayCTUProgress); @@ -1087,7 +1087,7 @@ bool ObjCMethodCall::canBeOverridenInSubclass(ObjCInterfaceDecl *IDecl, Selector Sel) const { assert(IDecl); AnalysisManager &AMgr = - getState()->getStateManager().getOwningEngine()->getAnalysisManager(); + getState()->getStateManager().getOwningEngine().getAnalysisManager(); // If the class interface is declared inside the main file, assume it is not // subcassed. // TODO: It could actually be subclassed if the subclass is private as well. diff --git a/lib/StaticAnalyzer/Core/ExprEngine.cpp b/lib/StaticAnalyzer/Core/ExprEngine.cpp index 45d0df7ae4..151eef56fe 100644 --- a/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -2951,8 +2951,8 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits { DOTGraphTraits (bool isSimple = false) : DefaultDOTGraphTraits(isSimple) {} static bool nodeHasBugReport(const ExplodedNode *N) { - BugReporter &BR = static_cast( - N->getState()->getStateManager().getOwningEngine())->getBugReporter(); + BugReporter &BR = static_cast( + N->getState()->getStateManager().getOwningEngine()).getBugReporter(); const auto EQClasses = llvm::make_range(BR.EQClasses_begin(), BR.EQClasses_end()); diff --git a/lib/StaticAnalyzer/Core/ProgramState.cpp b/lib/StaticAnalyzer/Core/ProgramState.cpp index ceb4fbdf78..2e2e2ec94f 100644 --- a/lib/StaticAnalyzer/Core/ProgramState.cpp +++ b/lib/StaticAnalyzer/Core/ProgramState.cpp @@ -125,8 +125,8 @@ ProgramStateRef ProgramState::bindLoc(Loc LV, ProgramStateRef newState = makeWithStore(Mgr.StoreMgr->Bind(getStore(), LV, V)); const MemRegion *MR = LV.getAsRegion(); - if (MR && Mgr.getOwningEngine() && notifyChanges) - return Mgr.getOwningEngine()->processRegionChange(newState, MR, LCtx); + if (MR && notifyChanges) + return Mgr.getOwningEngine().processRegionChange(newState, MR, LCtx); return newState; } @@ -138,9 +138,7 @@ ProgramState::bindDefaultInitial(SVal loc, SVal V, const MemRegion *R = loc.castAs().getRegion(); const StoreRef &newStore = Mgr.StoreMgr->BindDefaultInitial(getStore(), R, V); ProgramStateRef new_state = makeWithStore(newStore); - return Mgr.getOwningEngine() - ? Mgr.getOwningEngine()->processRegionChange(new_state, R, LCtx) - : new_state; + return Mgr.getOwningEngine().processRegionChange(new_state, R, LCtx); } ProgramStateRef @@ -149,9 +147,7 @@ ProgramState::bindDefaultZero(SVal loc, const LocationContext *LCtx) const { const MemRegion *R = loc.castAs().getRegion(); const StoreRef &newStore = Mgr.StoreMgr->BindDefaultZero(getStore(), R); ProgramStateRef new_state = makeWithStore(newStore); - return Mgr.getOwningEngine() - ? Mgr.getOwningEngine()->processRegionChange(new_state, R, LCtx) - : new_state; + return Mgr.getOwningEngine().processRegionChange(new_state, R, LCtx); } typedef ArrayRef RegionList; @@ -196,41 +192,34 @@ ProgramState::invalidateRegionsImpl(ValueList Values, RegionAndSymbolInvalidationTraits *ITraits, const CallEvent *Call) const { ProgramStateManager &Mgr = getStateManager(); - SubEngine* Eng = Mgr.getOwningEngine(); + SubEngine &Eng = Mgr.getOwningEngine(); - InvalidatedSymbols Invalidated; + InvalidatedSymbols InvalidatedSyms; if (!IS) - IS = &Invalidated; + IS = &InvalidatedSyms; RegionAndSymbolInvalidationTraits ITraitsLocal; if (!ITraits) ITraits = &ITraitsLocal; - if (Eng) { - StoreManager::InvalidatedRegions TopLevelInvalidated; - StoreManager::InvalidatedRegions Invalidated; - const StoreRef &newStore - = Mgr.StoreMgr->invalidateRegions(getStore(), Values, E, Count, LCtx, Call, - *IS, *ITraits, &TopLevelInvalidated, - &Invalidated); - - ProgramStateRef newState = makeWithStore(newStore); - - if (CausedByPointerEscape) { - newState = Eng->notifyCheckersOfPointerEscape(newState, IS, - TopLevelInvalidated, - Call, - *ITraits); - } + StoreManager::InvalidatedRegions TopLevelInvalidated; + StoreManager::InvalidatedRegions Invalidated; + const StoreRef &newStore + = Mgr.StoreMgr->invalidateRegions(getStore(), Values, E, Count, LCtx, Call, + *IS, *ITraits, &TopLevelInvalidated, + &Invalidated); + + ProgramStateRef newState = makeWithStore(newStore); - return Eng->processRegionChanges(newState, IS, TopLevelInvalidated, - Invalidated, LCtx, Call); + if (CausedByPointerEscape) { + newState = Eng.notifyCheckersOfPointerEscape(newState, IS, + TopLevelInvalidated, + Call, + *ITraits); } - const StoreRef &newStore = - Mgr.StoreMgr->invalidateRegions(getStore(), Values, E, Count, LCtx, Call, - *IS, *ITraits, nullptr, nullptr); - return makeWithStore(newStore); + return Eng.processRegionChanges(newState, IS, TopLevelInvalidated, + Invalidated, LCtx, Call); } ProgramStateRef ProgramState::killBinding(Loc LV) const { @@ -474,7 +463,7 @@ void ProgramState::print(raw_ostream &Out, printTaint(Out, NL); // Print checker-specific data. - Mgr.getOwningEngine()->printState(Out, this, NL, Sep, LC); + Mgr.getOwningEngine().printState(Out, this, NL, Sep, LC); } void ProgramState::printDOT(raw_ostream &Out, @@ -503,7 +492,7 @@ void ProgramState::dumpTaint() const { } AnalysisManager& ProgramState::getAnalysisManager() const { - return stateMgr->getOwningEngine()->getAnalysisManager(); + return stateMgr->getOwningEngine().getAnalysisManager(); } //===----------------------------------------------------------------------===// diff --git a/lib/StaticAnalyzer/Core/RegionStore.cpp b/lib/StaticAnalyzer/Core/RegionStore.cpp index f5eb9b5e72..b2339be4f2 100644 --- a/lib/StaticAnalyzer/Core/RegionStore.cpp +++ b/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -347,11 +347,9 @@ public: : StoreManager(mgr), Features(f), RBFactory(mgr.getAllocator()), CBFactory(mgr.getAllocator()), SmallStructLimit(0) { - if (SubEngine *Eng = StateMgr.getOwningEngine()) { - AnalyzerOptions &Options = Eng->getAnalysisManager().options; - SmallStructLimit = - Options.RegionStoreSmallStructLimit; - } + SubEngine &Eng = StateMgr.getOwningEngine(); + AnalyzerOptions &Options = Eng.getAnalysisManager().options; + SmallStructLimit = Options.RegionStoreSmallStructLimit; } diff --git a/lib/StaticAnalyzer/Core/SValBuilder.cpp b/lib/StaticAnalyzer/Core/SValBuilder.cpp index 617c4ba27d..aeb27fefed 100644 --- a/lib/StaticAnalyzer/Core/SValBuilder.cpp +++ b/lib/StaticAnalyzer/Core/SValBuilder.cpp @@ -384,7 +384,7 @@ SVal SValBuilder::makeSymExprValNN(BinaryOperator::Opcode Op, // TODO: When the Max Complexity is reached, we should conjure a symbol // instead of generating an Unknown value and propagate the taint info to it. const unsigned MaxComp = StateMgr.getOwningEngine() - ->getAnalysisManager() + .getAnalysisManager() .options.MaxSymbolComplexity; if (symLHS && symRHS && diff --git a/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp b/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp index 2f6a0c8ffc..fc57cecac9 100644 --- a/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp +++ b/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp @@ -454,7 +454,7 @@ static Optional tryRearrange(ProgramStateRef State, QualType SingleTy; auto &Opts = - StateMgr.getOwningEngine()->getAnalysisManager().getAnalyzerOptions(); + StateMgr.getOwningEngine().getAnalysisManager().getAnalyzerOptions(); // FIXME: After putting complexity threshold to the symbols we can always // rearrange additive operations but rearrange comparisons only if