Index: include/clang/Analysis/ProgramPoint.h =================================================================== --- include/clang/Analysis/ProgramPoint.h +++ include/clang/Analysis/ProgramPoint.h @@ -181,6 +181,10 @@ return L.getPointer(); } + const StackFrameContext *getCurrentStackFrame() const { + return getLocationContext()->getCurrentStackFrame(); + } + // For use with DenseMap. This hash is probably slow. unsigned getHashValue() const { llvm::FoldingSetNodeID ID; Index: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h =================================================================== --- include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h @@ -139,8 +139,8 @@ return Pred->getLocationContext(); } - const StackFrameContext *getStackFrame() const { - return Pred->getStackFrame(); + const StackFrameContext *getCurrentStackFrame() const { + return Pred->getCurrentStackFrame(); } /// Return true if the current LocationContext has no caller context. Index: include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h =================================================================== --- include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h +++ include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h @@ -146,8 +146,8 @@ return getLocation().getLocationContext(); } - const StackFrameContext *getStackFrame() const { - return getLocationContext()->getCurrentStackFrame(); + const StackFrameContext *getCurrentStackFrame() const { + return getLocation().getCurrentStackFrame(); } const Decl &getCodeDecl() const { return *getLocationContext()->getDecl(); } Index: lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp +++ lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp @@ -338,7 +338,7 @@ RecE= RecE->IgnoreParenImpCasts(); if (const DeclRefExpr *DRE = dyn_cast(RecE)) { - const StackFrameContext *SFCtx = C.getStackFrame(); + const StackFrameContext *SFCtx = C.getCurrentStackFrame(); // Are we calling [self alloc]? If this is self, get the type of the // enclosing ObjC class. if (DRE->getDecl() == SFCtx->getSelfDecl()) { Index: lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp +++ lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp @@ -186,8 +186,7 @@ } static QualType parameterTypeFromSVal(SVal val, CheckerContext &C) { - const StackFrameContext * - SFC = C.getLocationContext()->getCurrentStackFrame(); + const StackFrameContext * SFC = C.getCurrentStackFrame(); if (Optional X = val.getAs()) { const MemRegion* R = X->getRegion(); if (const VarRegion *VR = R->getAs()) Index: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -2964,7 +2964,7 @@ // If we've seen this symbol before, or we're only seeing it now because // of something the analyzer has synthesized, don't do anything. if (RV->getIvarAccessHistory() != RefVal::IvarAccessHistory::None || - isSynthesizedAccessor(C.getStackFrame())) { + isSynthesizedAccessor(C.getCurrentStackFrame())) { return; } @@ -2976,7 +2976,7 @@ RefVal PlusZero = RefVal::makeNotOwned(Kind, Ty); // In a synthesized accessor, the effective retain count is +0. - if (isSynthesizedAccessor(C.getStackFrame())) { + if (isSynthesizedAccessor(C.getCurrentStackFrame())) { C.addTransition(setRefBinding(State, Sym, PlusZero)); return; } Index: lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp +++ lib/StaticAnalyzer/Checkers/ReturnUndefChecker.cpp @@ -43,7 +43,7 @@ return; SVal RetVal = C.getSVal(RetE); - const StackFrameContext *SFC = C.getStackFrame(); + const StackFrameContext *SFC = C.getCurrentStackFrame(); QualType RT = CallEvent::getDeclaredResultType(SFC->getDecl()); if (RetVal.isUndef()) { Index: lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp +++ lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp @@ -120,7 +120,7 @@ bool StackAddrEscapeChecker::isNotInCurrentFrame(const MemRegion *R, CheckerContext &C) { const StackSpaceRegion *S = cast(R->getMemorySpace()); - return S->getStackFrame() != C.getLocationContext()->getCurrentStackFrame(); + return S->getStackFrame() != C.getCurrentStackFrame(); } bool StackAddrEscapeChecker::isSemaphoreCaptured(const BlockDecl &B) const { @@ -303,8 +303,7 @@ public: SmallVector, 10> V; - CallBack(CheckerContext &CC) - : Ctx(CC), CurSFC(CC.getLocationContext()->getCurrentStackFrame()) {} + CallBack(CheckerContext &CC) : Ctx(CC), CurSFC(CC.getCurrentStackFrame()) {} bool HandleBinding(StoreManager &SMgr, Store S, const MemRegion *Region, SVal Val) override { Index: lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp +++ lib/StaticAnalyzer/Checkers/TestAfterDivZeroChecker.cpp @@ -115,7 +115,7 @@ return nullptr; SVal S = Succ->getSVal(E); - if (ZeroSymbol == S.getAsSymbol() && SFC == Succ->getStackFrame()) { + if (ZeroSymbol == S.getAsSymbol() && SFC == Succ->getCurrentStackFrame()) { Satisfied = true; // Construct a new PathDiagnosticPiece. @@ -150,7 +150,7 @@ ProgramStateRef State = C.getState(); State = - State->add(ZeroState(SR, C.getBlockID(), C.getStackFrame())); + State->add(ZeroState(SR, C.getBlockID(), C.getCurrentStackFrame())); C.addTransition(State); } @@ -160,7 +160,7 @@ if (!SR) return false; - ZeroState ZS(SR, C.getBlockID(), C.getStackFrame()); + ZeroState ZS(SR, C.getBlockID(), C.getCurrentStackFrame()); return C.getState()->contains(ZS); } @@ -175,7 +175,7 @@ N); R->addVisitor(llvm::make_unique(Val.getAsSymbol(), - C.getStackFrame())); + C.getCurrentStackFrame())); C.emitReport(std::move(R)); } } @@ -192,7 +192,7 @@ E = DivZeroes.end(); I != E; ++I) { ZeroState ZS = *I; - if (ZS.getStackFrameContext() == C.getStackFrame()) + if (ZS.getStackFrameContext() == C.getCurrentStackFrame()) DivZeroes = F.remove(DivZeroes, ZS); } C.addTransition(State->set(DivZeroes)); Index: lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp +++ lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp @@ -80,7 +80,7 @@ // This should allow to swap partially uninitialized structs // (radar://14129997) if (const FunctionDecl *EnclosingFunctionDecl = - dyn_cast(C.getStackFrame()->getDecl())) + dyn_cast(C.getCurrentStackFrame()->getDecl())) if (C.getCalleeName(EnclosingFunctionDecl) == "swap") return; Index: lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp =================================================================== --- lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp +++ lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp @@ -42,7 +42,7 @@ // This should allow to swap partially uninitialized structs // (radar://14129997) if (const FunctionDecl *EnclosingFunctionDecl = - dyn_cast(C.getStackFrame()->getDecl())) + dyn_cast(C.getCurrentStackFrame()->getDecl())) if (C.getCalleeName(EnclosingFunctionDecl) == "swap") return; @@ -91,7 +91,7 @@ } if (const auto *CD = - dyn_cast(C.getStackFrame()->getDecl())) { + dyn_cast(C.getCurrentStackFrame()->getDecl())) { if (CD->isImplicit()) { for (auto I : CD->inits()) { if (I->getInit()->IgnoreImpCasts() == StoreE) { Index: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp =================================================================== --- lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -313,8 +313,7 @@ } if (LastReturnState && wasRegionOfInterestModifiedAt(N, LastReturnState)) { - const StackFrameContext *SCtx = - N->getLocationContext()->getCurrentStackFrame(); + const StackFrameContext *SCtx = N->getCurrentStackFrame(); while (!SCtx->inTopFrame()) { auto p = FramesModifyingRegion.insert(SCtx); if (!p.second) Index: lib/StaticAnalyzer/Core/CoreEngine.cpp =================================================================== --- lib/StaticAnalyzer/Core/CoreEngine.cpp +++ lib/StaticAnalyzer/Core/CoreEngine.cpp @@ -187,7 +187,7 @@ StackUnexplored.push_back(U); } else { LocIdentifier LocId = std::make_pair( - BE->getBlock()->getBlockID(), N->getStackFrame()); + BE->getBlock()->getBlockID(), N->getCurrentStackFrame()); auto InsertInfo = Reachable.insert(LocId); if (InsertInfo.second) { @@ -261,7 +261,7 @@ unsigned NumVisited = 0; if (auto BE = N->getLocation().getAs()) { LocIdentifier LocId = std::make_pair( - BE->getBlock()->getBlockID(), N->getStackFrame()); + BE->getBlock()->getBlockID(), N->getCurrentStackFrame()); NumVisited = NumReached[LocId]++; } Index: lib/StaticAnalyzer/Core/ExprEngine.cpp =================================================================== --- lib/StaticAnalyzer/Core/ExprEngine.cpp +++ lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -1124,12 +1124,12 @@ const MemRegion *MR = nullptr; if (const CXXTempObjectRegion *const *MRPtr = State->get(std::make_pair( - D.getBindTemporaryExpr(), Pred->getStackFrame()))) { + D.getBindTemporaryExpr(), Pred->getCurrentStackFrame()))) { // FIXME: Currently we insert temporary destructors for default parameters, // but we don't insert the constructors, so the entry in // InitializedTemporaries may be missing. State = State->remove( - std::make_pair(D.getBindTemporaryExpr(), Pred->getStackFrame())); + std::make_pair(D.getBindTemporaryExpr(), Pred->getCurrentStackFrame())); // *MRPtr may still be null when the construction context for the temporary // was not implemented. MR = *MRPtr; @@ -1172,7 +1172,7 @@ const CFGBlock *DstF) { BranchNodeBuilder TempDtorBuilder(Pred, Dst, BldCtx, DstT, DstF); if (Pred->getState()->contains( - std::make_pair(BTE, Pred->getStackFrame()))) { + std::make_pair(BTE, Pred->getCurrentStackFrame()))) { TempDtorBuilder.markInfeasible(false); TempDtorBuilder.generateNode(Pred->getState(), true, Pred); } else { @@ -1196,7 +1196,7 @@ StmtNodeBuilder StmtBldr(PreVisit, Dst, *currBldrCtx); for (ExplodedNode *Node : PreVisit) { ProgramStateRef State = Node->getState(); - const auto &Key = std::make_pair(BTE, Node->getStackFrame()); + const auto &Key = std::make_pair(BTE, Node->getCurrentStackFrame()); if (!State->contains(Key)) { // FIXME: Currently the state might also already contain the marker due to @@ -1892,7 +1892,7 @@ N = N->pred_empty() ? nullptr : *(N->pred_begin()); // Skip the nodes corresponding to the inlined code. - if (L.getLocationContext()->getCurrentStackFrame() != CallerSF) + if (L.getCurrentStackFrame() != CallerSF) continue; // We reached the caller. Find the node right before we started // processing the call. @@ -2302,7 +2302,7 @@ // See if we have any stale C++ allocator values. assert(areCXXNewAllocatorValuesClear(Pred->getState(), Pred->getLocationContext(), - Pred->getStackFrame()->getParent())); + Pred->getCurrentStackFrame()->getParent())); // FIXME: We currently cannot assert that temporaries are clear, because // lifetime extended temporaries are not always modelled correctly. In some @@ -2337,10 +2337,10 @@ } assert(areInitializedTemporariesClear(Pred->getState(), Pred->getLocationContext(), - Pred->getStackFrame()->getParent())); + Pred->getCurrentStackFrame()->getParent())); assert(areTemporaryMaterializationsClear(Pred->getState(), Pred->getLocationContext(), - Pred->getStackFrame()->getParent())); + Pred->getCurrentStackFrame()->getParent())); PrettyStackTraceLocationContext CrashInfo(Pred->getLocationContext()); StateMgr.EndPath(Pred->getState()); Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp =================================================================== --- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp +++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp @@ -74,15 +74,14 @@ const CFGBlock*> getLastStmt(const ExplodedNode *Node) { const Stmt *S = nullptr; const CFGBlock *Blk = nullptr; - const StackFrameContext *SF = - Node->getLocation().getLocationContext()->getCurrentStackFrame(); + const StackFrameContext *SF = Node->getCurrentStackFrame(); // Back up through the ExplodedGraph until we reach a statement node in this // stack frame. while (Node) { const ProgramPoint &PP = Node->getLocation(); - if (PP.getLocationContext()->getCurrentStackFrame() == SF) { + if (PP.getCurrentStackFrame() == SF) { if (Optional SP = PP.getAs()) { S = SP->getStmt(); break; @@ -221,8 +220,7 @@ void ExprEngine::processCallExit(ExplodedNode *CEBNode) { // Step 1 CEBNode was generated before the call. PrettyStackTraceLocationContext CrashInfo(CEBNode->getLocationContext()); - const StackFrameContext *calleeCtx = - CEBNode->getLocationContext()->getCurrentStackFrame(); + const StackFrameContext *calleeCtx = CEBNode->getCurrentStackFrame(); // The parent context might not be a stack frame, so make sure we // look up the first enclosing stack frame.