mirror of
https://github.com/intel/llvm.git
synced 2026-02-04 20:00:11 +08:00
[analyzer] [NFC] A convenient getter for getting a current stack frame
Differential Revision: https://reviews.llvm.org/D44756 llvm-svn: 335701
This commit is contained in:
@@ -264,7 +264,7 @@ public:
|
||||
return Ctx->getSelfDecl();
|
||||
}
|
||||
|
||||
const StackFrameContext *getCurrentStackFrame() const;
|
||||
const StackFrameContext *getStackFrame() const;
|
||||
|
||||
/// Return true if the current LocationContext has no caller context.
|
||||
virtual bool inTopFrame() const;
|
||||
|
||||
@@ -181,6 +181,10 @@ public:
|
||||
return L.getPointer();
|
||||
}
|
||||
|
||||
const StackFrameContext *getStackFrame() const {
|
||||
return getLocationContext()->getStackFrame();
|
||||
}
|
||||
|
||||
// For use with DenseMap. This hash is probably slow.
|
||||
unsigned getHashValue() const {
|
||||
llvm::FoldingSetNodeID ID;
|
||||
|
||||
@@ -211,7 +211,7 @@ struct NodeBuilderContext {
|
||||
/// visited on the exploded graph path.
|
||||
unsigned blockCount() const {
|
||||
return Eng.WList->getBlockCounter().getNumVisited(
|
||||
LC->getCurrentStackFrame(),
|
||||
LC->getStackFrame(),
|
||||
Block->getBlockID());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -147,7 +147,7 @@ public:
|
||||
}
|
||||
|
||||
const StackFrameContext *getStackFrame() const {
|
||||
return getLocationContext()->getCurrentStackFrame();
|
||||
return getLocation().getStackFrame();
|
||||
}
|
||||
|
||||
const Decl &getCodeDecl() const { return *getLocationContext()->getDecl(); }
|
||||
|
||||
@@ -442,7 +442,7 @@ LocationContextManager::getBlockInvocationContext(AnalysisDeclContext *ctx,
|
||||
// LocationContext methods.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
const StackFrameContext *LocationContext::getCurrentStackFrame() const {
|
||||
const StackFrameContext *LocationContext::getStackFrame() const {
|
||||
const LocationContext *LC = this;
|
||||
while (LC) {
|
||||
if (const auto *SFC = dyn_cast<StackFrameContext>(LC))
|
||||
@@ -453,7 +453,7 @@ const StackFrameContext *LocationContext::getCurrentStackFrame() const {
|
||||
}
|
||||
|
||||
bool LocationContext::inTopFrame() const {
|
||||
return getCurrentStackFrame()->inTopFrame();
|
||||
return getStackFrame()->inTopFrame();
|
||||
}
|
||||
|
||||
bool LocationContext::isParentOf(const LocationContext *LC) const {
|
||||
|
||||
@@ -48,7 +48,7 @@ void CXXSelfAssignmentChecker::checkBeginFunction(CheckerContext &C) const {
|
||||
auto &State = C.getState();
|
||||
auto &SVB = C.getSValBuilder();
|
||||
auto ThisVal =
|
||||
State->getSVal(SVB.getCXXThis(MD, LCtx->getCurrentStackFrame()));
|
||||
State->getSVal(SVB.getCXXThis(MD, LCtx->getStackFrame()));
|
||||
auto Param = SVB.makeLoc(State->getRegion(MD->getParamDecl(0), LCtx));
|
||||
auto ParamVal = State->getSVal(Param);
|
||||
ProgramStateRef SelfAssignState = State->bindLoc(Param, ThisVal, LCtx);
|
||||
|
||||
@@ -149,7 +149,7 @@ void ExprInspectionChecker::analyzerEval(const CallExpr *CE,
|
||||
|
||||
// A specific instantiation of an inlined function may have more constrained
|
||||
// values than can generally be assumed. Skip the check.
|
||||
if (LC->getCurrentStackFrame()->getParent() != nullptr)
|
||||
if (LC->getStackFrame()->getParent() != nullptr)
|
||||
return;
|
||||
|
||||
reportBug(getArgumentValueString(CE, C), C);
|
||||
@@ -178,7 +178,7 @@ void ExprInspectionChecker::analyzerCheckInlined(const CallExpr *CE,
|
||||
// when we are analyzing it as an inlined function. This means that
|
||||
// clang_analyzer_checkInlined(true) should always print TRUE, but
|
||||
// clang_analyzer_checkInlined(false) should never actually print anything.
|
||||
if (LC->getCurrentStackFrame()->getParent() == nullptr)
|
||||
if (LC->getStackFrame()->getParent() == nullptr)
|
||||
return;
|
||||
|
||||
reportBug(getArgumentValueString(CE, C), C);
|
||||
|
||||
@@ -2258,7 +2258,7 @@ MallocChecker::getAllocationSite(const ExplodedNode *N, SymbolRef Sym,
|
||||
// Do not show local variables belonging to a function other than
|
||||
// where the error is reported.
|
||||
if (!VR ||
|
||||
(VR->getStackFrame() == LeakContext->getCurrentStackFrame()))
|
||||
(VR->getStackFrame() == LeakContext->getStackFrame()))
|
||||
ReferenceRegion = MR;
|
||||
}
|
||||
}
|
||||
@@ -2919,7 +2919,7 @@ std::shared_ptr<PathDiagnosticPiece> MallocChecker::MallocBugVisitor::VisitNode(
|
||||
// reference counting operations within it (see the code above),
|
||||
// and if so, we'd conclude that it likely is a reference counting
|
||||
// pointer destructor.
|
||||
ReleaseDestructorLC = LC->getCurrentStackFrame();
|
||||
ReleaseDestructorLC = LC->getStackFrame();
|
||||
// It is unlikely that releasing memory is delegated to a destructor
|
||||
// inside a destructor of a shared pointer, because it's fairly hard
|
||||
// to pass the information that the pointer indeed needs to be
|
||||
|
||||
@@ -186,8 +186,7 @@ static void setFlag(ProgramStateRef state, SVal val, CheckerContext &C) {
|
||||
}
|
||||
|
||||
static QualType parameterTypeFromSVal(SVal val, CheckerContext &C) {
|
||||
const StackFrameContext *
|
||||
SFC = C.getLocationContext()->getCurrentStackFrame();
|
||||
const StackFrameContext * SFC = C.getStackFrame();
|
||||
if (Optional<loc::MemRegionVal> X = val.getAs<loc::MemRegionVal>()) {
|
||||
const MemRegion* R = X->getRegion();
|
||||
if (const VarRegion *VR = R->getAs<VarRegion>())
|
||||
|
||||
@@ -1968,8 +1968,8 @@ CFRefReportVisitor::VisitNode(const ExplodedNode *N, const ExplodedNode *PrevN,
|
||||
const Stmt *S = N->getLocation().castAs<StmtPoint>().getStmt();
|
||||
|
||||
if (isa<ObjCIvarRefExpr>(S) &&
|
||||
isSynthesizedAccessor(LCtx->getCurrentStackFrame())) {
|
||||
S = LCtx->getCurrentStackFrame()->getCallSite();
|
||||
isSynthesizedAccessor(LCtx->getStackFrame())) {
|
||||
S = LCtx->getStackFrame()->getCallSite();
|
||||
}
|
||||
|
||||
if (isa<ObjCArrayLiteral>(S)) {
|
||||
@@ -2297,7 +2297,7 @@ GetAllocationSite(ProgramStateManager& StateMgr, const ExplodedNode *N,
|
||||
const VarRegion *VR = R->getBaseRegion()->getAs<VarRegion>();
|
||||
// Do not show local variables belonging to a function other than
|
||||
// where the error is reported.
|
||||
if (!VR || VR->getStackFrame() == LeakContext->getCurrentStackFrame())
|
||||
if (!VR || VR->getStackFrame() == LeakContext->getStackFrame())
|
||||
FirstBinding = R;
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ bool StackAddrEscapeChecker::isArcManagedBlock(const MemRegion *R,
|
||||
bool StackAddrEscapeChecker::isNotInCurrentFrame(const MemRegion *R,
|
||||
CheckerContext &C) {
|
||||
const StackSpaceRegion *S = cast<StackSpaceRegion>(R->getMemorySpace());
|
||||
return S->getStackFrame() != C.getLocationContext()->getCurrentStackFrame();
|
||||
return S->getStackFrame() != C.getStackFrame();
|
||||
}
|
||||
|
||||
bool StackAddrEscapeChecker::isSemaphoreCaptured(const BlockDecl &B) const {
|
||||
@@ -303,8 +303,7 @@ void StackAddrEscapeChecker::checkEndFunction(CheckerContext &Ctx) const {
|
||||
public:
|
||||
SmallVector<std::pair<const MemRegion *, const MemRegion *>, 10> V;
|
||||
|
||||
CallBack(CheckerContext &CC)
|
||||
: Ctx(CC), CurSFC(CC.getLocationContext()->getCurrentStackFrame()) {}
|
||||
CallBack(CheckerContext &CC) : Ctx(CC), CurSFC(CC.getStackFrame()) {}
|
||||
|
||||
bool HandleBinding(StoreManager &SMgr, Store S, const MemRegion *Region,
|
||||
SVal Val) override {
|
||||
|
||||
@@ -108,7 +108,7 @@ VirtualCallChecker::VirtualBugVisitor::VisitNode(const ExplodedNode *N,
|
||||
if (!MD)
|
||||
return nullptr;
|
||||
auto ThiSVal =
|
||||
State->getSVal(SVB.getCXXThis(MD, LCtx->getCurrentStackFrame()));
|
||||
State->getSVal(SVB.getCXXThis(MD, LCtx->getStackFrame()));
|
||||
const MemRegion *Reg = ThiSVal.castAs<loc::MemRegionVal>().getRegion();
|
||||
if (!Reg)
|
||||
return nullptr;
|
||||
@@ -230,7 +230,7 @@ void VirtualCallChecker::registerCtorDtorCallInState(bool IsBeginFunction,
|
||||
// Enter a constructor, set the corresponding memregion be true.
|
||||
if (isa<CXXConstructorDecl>(MD)) {
|
||||
auto ThiSVal =
|
||||
State->getSVal(SVB.getCXXThis(MD, LCtx->getCurrentStackFrame()));
|
||||
State->getSVal(SVB.getCXXThis(MD, LCtx->getStackFrame()));
|
||||
const MemRegion *Reg = ThiSVal.getAsRegion();
|
||||
if (IsBeginFunction)
|
||||
State = State->set<CtorDtorMap>(Reg, ObjectState::CtorCalled);
|
||||
@@ -244,7 +244,7 @@ void VirtualCallChecker::registerCtorDtorCallInState(bool IsBeginFunction,
|
||||
// Enter a Destructor, set the corresponding memregion be true.
|
||||
if (isa<CXXDestructorDecl>(MD)) {
|
||||
auto ThiSVal =
|
||||
State->getSVal(SVB.getCXXThis(MD, LCtx->getCurrentStackFrame()));
|
||||
State->getSVal(SVB.getCXXThis(MD, LCtx->getStackFrame()));
|
||||
const MemRegion *Reg = ThiSVal.getAsRegion();
|
||||
if (IsBeginFunction)
|
||||
State = State->set<CtorDtorMap>(Reg, ObjectState::DtorCalled);
|
||||
|
||||
@@ -865,7 +865,7 @@ static void reversePropagateInterestingSymbols(BugReport &R,
|
||||
const LocationContext *CallerCtx)
|
||||
{
|
||||
// FIXME: Handle non-CallExpr-based CallEvents.
|
||||
const StackFrameContext *Callee = CalleeCtx->getCurrentStackFrame();
|
||||
const StackFrameContext *Callee = CalleeCtx->getStackFrame();
|
||||
const Stmt *CallSite = Callee->getCallSite();
|
||||
if (const auto *CE = dyn_cast_or_null<CallExpr>(CallSite)) {
|
||||
if (const auto *FD = dyn_cast<FunctionDecl>(CalleeCtx->getDecl())) {
|
||||
@@ -1956,7 +1956,7 @@ static std::unique_ptr<PathDiagnostic> generatePathDiagnosticForConsumer(
|
||||
if (AddPathEdges) {
|
||||
// Add an edge to the start of the function.
|
||||
// We'll prune it out later, but it helps make diagnostics more uniform.
|
||||
const StackFrameContext *CalleeLC = PDB.LC->getCurrentStackFrame();
|
||||
const StackFrameContext *CalleeLC = PDB.LC->getStackFrame();
|
||||
const Decl *D = CalleeLC->getDecl();
|
||||
addEdgeToPath(PD->getActivePath(), PrevLoc,
|
||||
PathDiagnosticLocation::createBegin(D, SM), CalleeLC);
|
||||
@@ -2051,7 +2051,7 @@ const Decl *BugReport::getDeclWithIssue() const {
|
||||
return nullptr;
|
||||
|
||||
const LocationContext *LC = N->getLocationContext();
|
||||
return LC->getCurrentStackFrame()->getDecl();
|
||||
return LC->getStackFrame()->getDecl();
|
||||
}
|
||||
|
||||
void BugReport::Profile(llvm::FoldingSetNodeID& hash) const {
|
||||
|
||||
@@ -264,7 +264,7 @@ public:
|
||||
BugReport &BR) override {
|
||||
|
||||
const LocationContext *Ctx = N->getLocationContext();
|
||||
const StackFrameContext *SCtx = Ctx->getCurrentStackFrame();
|
||||
const StackFrameContext *SCtx = Ctx->getStackFrame();
|
||||
ProgramStateRef State = N->getState();
|
||||
auto CallExitLoc = N->getLocationAs<CallExitBegin>();
|
||||
|
||||
@@ -319,7 +319,7 @@ private:
|
||||
/// The calculation is cached in FramesModifyingRegion.
|
||||
bool isRegionOfInterestModifiedInFrame(const ExplodedNode *N) {
|
||||
const LocationContext *Ctx = N->getLocationContext();
|
||||
const StackFrameContext *SCtx = Ctx->getCurrentStackFrame();
|
||||
const StackFrameContext *SCtx = Ctx->getStackFrame();
|
||||
if (!FramesModifyingCalculated.count(SCtx))
|
||||
findModifyingFrames(N);
|
||||
return FramesModifyingRegion.count(SCtx);
|
||||
@@ -333,7 +333,7 @@ private:
|
||||
ProgramStateRef LastReturnState = N->getState();
|
||||
SVal ValueAtReturn = LastReturnState->getSVal(RegionOfInterest);
|
||||
const LocationContext *Ctx = N->getLocationContext();
|
||||
const StackFrameContext *OriginalSCtx = Ctx->getCurrentStackFrame();
|
||||
const StackFrameContext *OriginalSCtx = Ctx->getStackFrame();
|
||||
|
||||
do {
|
||||
ProgramStateRef State = N->getState();
|
||||
@@ -344,16 +344,15 @@ private:
|
||||
}
|
||||
|
||||
FramesModifyingCalculated.insert(
|
||||
N->getLocationContext()->getCurrentStackFrame());
|
||||
N->getLocationContext()->getStackFrame());
|
||||
|
||||
if (wasRegionOfInterestModifiedAt(N, LastReturnState, ValueAtReturn)) {
|
||||
const StackFrameContext *SCtx =
|
||||
N->getLocationContext()->getCurrentStackFrame();
|
||||
const StackFrameContext *SCtx = N->getStackFrame();
|
||||
while (!SCtx->inTopFrame()) {
|
||||
auto p = FramesModifyingRegion.insert(SCtx);
|
||||
if (!p.second)
|
||||
break; // Frame and all its parents already inserted.
|
||||
SCtx = SCtx->getParent()->getCurrentStackFrame();
|
||||
SCtx = SCtx->getParent()->getStackFrame();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -913,7 +912,7 @@ static bool isInitializationOfVar(const ExplodedNode *N, const VarRegion *VR) {
|
||||
|
||||
assert(VR->getDecl()->hasLocalStorage());
|
||||
const LocationContext *LCtx = N->getLocationContext();
|
||||
return FrameSpace->getStackFrame() == LCtx->getCurrentStackFrame();
|
||||
return FrameSpace->getStackFrame() == LCtx->getStackFrame();
|
||||
}
|
||||
|
||||
/// Show diagnostics for initializing or declaring a region \p R with a bad value.
|
||||
@@ -2310,7 +2309,7 @@ CXXSelfAssignmentBRVisitor::VisitNode(const ExplodedNode *Succ,
|
||||
const auto Param =
|
||||
State->getSVal(State->getRegion(Met->getParamDecl(0), LCtx));
|
||||
const auto This =
|
||||
State->getSVal(SVB.getCXXThis(Met, LCtx->getCurrentStackFrame()));
|
||||
State->getSVal(SVB.getCXXThis(Met, LCtx->getStackFrame()));
|
||||
|
||||
auto L = PathDiagnosticLocation::create(Met, BRC.getSourceManager());
|
||||
|
||||
|
||||
@@ -1221,7 +1221,7 @@ CallEventRef<>
|
||||
CallEventManager::getCaller(const StackFrameContext *CalleeCtx,
|
||||
ProgramStateRef State) {
|
||||
const LocationContext *ParentCtx = CalleeCtx->getParent();
|
||||
const LocationContext *CallerCtx = ParentCtx->getCurrentStackFrame();
|
||||
const LocationContext *CallerCtx = ParentCtx->getStackFrame();
|
||||
assert(CallerCtx && "This should not be used for top-level stack frames");
|
||||
|
||||
const Stmt *CallSite = CalleeCtx->getCallSite();
|
||||
|
||||
@@ -256,7 +256,7 @@ void CoreEngine::HandleBlockEntrance(const BlockEntrance &L,
|
||||
const LocationContext *LC = Pred->getLocationContext();
|
||||
unsigned BlockId = L.getBlock()->getBlockID();
|
||||
BlockCounter Counter = WList->getBlockCounter();
|
||||
Counter = BCounterFactory.IncrementCount(Counter, LC->getCurrentStackFrame(),
|
||||
Counter = BCounterFactory.IncrementCount(Counter, LC->getStackFrame(),
|
||||
BlockId);
|
||||
WList->setBlockCounter(Counter);
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ static const Stmt *ignoreTransparentExprs(const Stmt *S) {
|
||||
EnvironmentEntry::EnvironmentEntry(const Stmt *S, const LocationContext *L)
|
||||
: std::pair<const Stmt *,
|
||||
const StackFrameContext *>(ignoreTransparentExprs(S),
|
||||
L ? L->getCurrentStackFrame()
|
||||
L ? L->getStackFrame()
|
||||
: nullptr) {}
|
||||
|
||||
SVal Environment::lookupExpr(const EnvironmentEntry &E) const {
|
||||
|
||||
@@ -282,7 +282,7 @@ ProgramStateRef ExprEngine::getInitialState(const LocationContext *InitLoc) {
|
||||
// Precondition: 'this' is always non-null upon entry to the
|
||||
// top-level function. This is our starting assumption for
|
||||
// analyzing an "open" program.
|
||||
const StackFrameContext *SFC = InitLoc->getCurrentStackFrame();
|
||||
const StackFrameContext *SFC = InitLoc->getStackFrame();
|
||||
if (SFC->getParent() == nullptr) {
|
||||
loc::MemRegionVal L = svalBuilder.getCXXThis(MD, SFC);
|
||||
SVal V = state->getSVal(L);
|
||||
@@ -450,7 +450,7 @@ ProgramStateRef ExprEngine::addObjectUnderConstruction(
|
||||
ProgramStateRef State,
|
||||
llvm::PointerUnion<const Stmt *, const CXXCtorInitializer *> P,
|
||||
const LocationContext *LC, SVal V) {
|
||||
ConstructedObjectKey Key(P, LC->getCurrentStackFrame());
|
||||
ConstructedObjectKey Key(P, LC->getStackFrame());
|
||||
// FIXME: Currently the state might already contain the marker due to
|
||||
// incorrect handling of temporaries bound to default parameters.
|
||||
assert(!State->get<ObjectsUnderConstruction>(Key) ||
|
||||
@@ -462,7 +462,7 @@ Optional<SVal> ExprEngine::getObjectUnderConstruction(
|
||||
ProgramStateRef State,
|
||||
llvm::PointerUnion<const Stmt *, const CXXCtorInitializer *> P,
|
||||
const LocationContext *LC) {
|
||||
ConstructedObjectKey Key(P, LC->getCurrentStackFrame());
|
||||
ConstructedObjectKey Key(P, LC->getStackFrame());
|
||||
return Optional<SVal>::create(State->get<ObjectsUnderConstruction>(Key));
|
||||
}
|
||||
|
||||
@@ -470,7 +470,7 @@ ProgramStateRef ExprEngine::finishObjectConstruction(
|
||||
ProgramStateRef State,
|
||||
llvm::PointerUnion<const Stmt *, const CXXCtorInitializer *> P,
|
||||
const LocationContext *LC) {
|
||||
ConstructedObjectKey Key(P, LC->getCurrentStackFrame());
|
||||
ConstructedObjectKey Key(P, LC->getStackFrame());
|
||||
assert(State->contains<ObjectsUnderConstruction>(Key));
|
||||
return State->remove<ObjectsUnderConstruction>(Key);
|
||||
}
|
||||
@@ -640,7 +640,7 @@ void ExprEngine::removeDead(ExplodedNode *Pred, ExplodedNodeSet &Out,
|
||||
LC = LC->getParent();
|
||||
}
|
||||
|
||||
const StackFrameContext *SFC = LC ? LC->getCurrentStackFrame() : nullptr;
|
||||
const StackFrameContext *SFC = LC ? LC->getStackFrame() : nullptr;
|
||||
SymbolReaper SymReaper(SFC, ReferenceStmt, SymMgr, getStoreManager());
|
||||
|
||||
for (auto I : CleanedState->get<ObjectsUnderConstruction>()) {
|
||||
@@ -963,7 +963,7 @@ void ExprEngine::ProcessBaseDtor(const CFGBaseDtor D,
|
||||
|
||||
const auto *CurDtor = cast<CXXDestructorDecl>(LCtx->getDecl());
|
||||
Loc ThisPtr = getSValBuilder().getCXXThis(CurDtor,
|
||||
LCtx->getCurrentStackFrame());
|
||||
LCtx->getStackFrame());
|
||||
SVal ThisVal = Pred->getState()->getSVal(ThisPtr);
|
||||
|
||||
// Create the base object region.
|
||||
@@ -985,7 +985,7 @@ void ExprEngine::ProcessMemberDtor(const CFGMemberDtor D,
|
||||
|
||||
const auto *CurDtor = cast<CXXDestructorDecl>(LCtx->getDecl());
|
||||
Loc ThisVal = getSValBuilder().getCXXThis(CurDtor,
|
||||
LCtx->getCurrentStackFrame());
|
||||
LCtx->getStackFrame());
|
||||
SVal FieldVal =
|
||||
State->getLValue(Member, State->getSVal(ThisVal).castAs<Loc>());
|
||||
|
||||
@@ -1758,8 +1758,8 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
|
||||
|
||||
bool ExprEngine::replayWithoutInlining(ExplodedNode *N,
|
||||
const LocationContext *CalleeLC) {
|
||||
const StackFrameContext *CalleeSF = CalleeLC->getCurrentStackFrame();
|
||||
const StackFrameContext *CallerSF = CalleeSF->getParent()->getCurrentStackFrame();
|
||||
const StackFrameContext *CalleeSF = CalleeLC->getStackFrame();
|
||||
const StackFrameContext *CallerSF = CalleeSF->getParent()->getStackFrame();
|
||||
assert(CalleeSF && CallerSF);
|
||||
ExplodedNode *BeforeProcessingCall = nullptr;
|
||||
const Stmt *CE = CalleeSF->getCallSite();
|
||||
@@ -1771,7 +1771,7 @@ bool ExprEngine::replayWithoutInlining(ExplodedNode *N,
|
||||
N = N->pred_empty() ? nullptr : *(N->pred_begin());
|
||||
|
||||
// Skip the nodes corresponding to the inlined code.
|
||||
if (L.getLocationContext()->getCurrentStackFrame() != CallerSF)
|
||||
if (L.getStackFrame() != CallerSF)
|
||||
continue;
|
||||
// We reached the caller. Find the node right before we started
|
||||
// processing the call.
|
||||
@@ -1870,10 +1870,10 @@ void ExprEngine::processCFGBlockEntrance(const BlockEdge &L,
|
||||
// Check if we stopped at the top level function or not.
|
||||
// Root node should have the location context of the top most function.
|
||||
const LocationContext *CalleeLC = Pred->getLocation().getLocationContext();
|
||||
const LocationContext *CalleeSF = CalleeLC->getCurrentStackFrame();
|
||||
const LocationContext *CalleeSF = CalleeLC->getStackFrame();
|
||||
const LocationContext *RootLC =
|
||||
(*G.roots_begin())->getLocation().getLocationContext();
|
||||
if (RootLC->getCurrentStackFrame() != CalleeSF) {
|
||||
if (RootLC->getStackFrame() != CalleeSF) {
|
||||
Engine.FunctionSummaries->markReachedMaxBlockCount(CalleeSF->getDecl());
|
||||
|
||||
// Re-run the call evaluation without inlining it, by storing the
|
||||
@@ -2190,7 +2190,7 @@ void ExprEngine::processEndOfFunction(NodeBuilderContext& BC,
|
||||
NodeBuilder Bldr(Pred, CleanUpObjects, BC);
|
||||
ProgramStateRef State = Pred->getState();
|
||||
const LocationContext *FromLC = Pred->getLocationContext();
|
||||
const LocationContext *ToLC = FromLC->getCurrentStackFrame()->getParent();
|
||||
const LocationContext *ToLC = FromLC->getStackFrame()->getParent();
|
||||
const LocationContext *LC = FromLC;
|
||||
while (LC != ToLC) {
|
||||
assert(LC && "ToLC must be a parent of FromLC!");
|
||||
@@ -2353,7 +2353,7 @@ void ExprEngine::VisitCommonDeclRefExpr(const Expr *Ex, const NamedDecl *D,
|
||||
// variable should be captured.
|
||||
if (const FieldDecl *FD = LambdaCaptureFields[VD]) {
|
||||
Loc CXXThis =
|
||||
svalBuilder.getCXXThis(MD, LocCtxt->getCurrentStackFrame());
|
||||
svalBuilder.getCXXThis(MD, LocCtxt->getStackFrame());
|
||||
SVal CXXThisVal = state->getSVal(CXXThis);
|
||||
VInfo = std::make_pair(state->getLValue(FD, CXXThisVal), FD->getType());
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ std::pair<ProgramStateRef, SVal> ExprEngine::prepareForObjectConstruction(
|
||||
assert(Init->isAnyMemberInitializer());
|
||||
const CXXMethodDecl *CurCtor = cast<CXXMethodDecl>(LCtx->getDecl());
|
||||
Loc ThisPtr =
|
||||
getSValBuilder().getCXXThis(CurCtor, LCtx->getCurrentStackFrame());
|
||||
getSValBuilder().getCXXThis(CurCtor, LCtx->getStackFrame());
|
||||
SVal ThisVal = State->getSVal(ThisPtr);
|
||||
|
||||
const ValueDecl *Field;
|
||||
@@ -185,7 +185,7 @@ std::pair<ProgramStateRef, SVal> ExprEngine::prepareForObjectConstruction(
|
||||
// The temporary is to be managed by the parent stack frame.
|
||||
// So build it in the parent stack frame if we're not in the
|
||||
// top frame of the analysis.
|
||||
const StackFrameContext *SFC = LCtx->getCurrentStackFrame();
|
||||
const StackFrameContext *SFC = LCtx->getStackFrame();
|
||||
if (const LocationContext *CallerLCtx = SFC->getParent()) {
|
||||
auto RTC = (*SFC->getCallSiteBlock())[SFC->getIndex()]
|
||||
.getAs<CFGCXXRecordTypedCall>();
|
||||
@@ -289,7 +289,7 @@ void ExprEngine::VisitCXXConstructExpr(const CXXConstructExpr *CE,
|
||||
case CXXConstructExpr::CK_VirtualBase:
|
||||
// Make sure we are not calling virtual base class initializers twice.
|
||||
// Only the most-derived object should initialize virtual base classes.
|
||||
if (const Stmt *Outer = LCtx->getCurrentStackFrame()->getCallSite()) {
|
||||
if (const Stmt *Outer = LCtx->getStackFrame()->getCallSite()) {
|
||||
const CXXConstructExpr *OuterCtor = dyn_cast<CXXConstructExpr>(Outer);
|
||||
if (OuterCtor) {
|
||||
switch (OuterCtor->getConstructionKind()) {
|
||||
@@ -327,7 +327,7 @@ void ExprEngine::VisitCXXConstructExpr(const CXXConstructExpr *CE,
|
||||
case CXXConstructExpr::CK_Delegating: {
|
||||
const CXXMethodDecl *CurCtor = cast<CXXMethodDecl>(LCtx->getDecl());
|
||||
Loc ThisPtr = getSValBuilder().getCXXThis(CurCtor,
|
||||
LCtx->getCurrentStackFrame());
|
||||
LCtx->getStackFrame());
|
||||
SVal ThisVal = State->getSVal(ThisPtr);
|
||||
|
||||
if (CE->getConstructionKind() == CXXConstructExpr::CK_Delegating) {
|
||||
|
||||
@@ -74,15 +74,14 @@ static std::pair<const Stmt*,
|
||||
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->getStackFrame();
|
||||
|
||||
// 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.getStackFrame() == SF) {
|
||||
if (Optional<StmtPoint> SP = PP.getAs<StmtPoint>()) {
|
||||
S = SP->getStmt();
|
||||
break;
|
||||
@@ -204,13 +203,12 @@ static bool wasDifferentDeclUsedForInlining(CallEventRef<> Call,
|
||||
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->getStackFrame();
|
||||
|
||||
// The parent context might not be a stack frame, so make sure we
|
||||
// look up the first enclosing stack frame.
|
||||
const StackFrameContext *callerCtx =
|
||||
calleeCtx->getParent()->getCurrentStackFrame();
|
||||
calleeCtx->getParent()->getStackFrame();
|
||||
|
||||
const Stmt *CE = calleeCtx->getCallSite();
|
||||
ProgramStateRef state = CEBNode->getState();
|
||||
@@ -418,7 +416,7 @@ bool ExprEngine::inlineCall(const CallEvent &Call, const Decl *D,
|
||||
assert(D);
|
||||
|
||||
const LocationContext *CurLC = Pred->getLocationContext();
|
||||
const StackFrameContext *CallerSFC = CurLC->getCurrentStackFrame();
|
||||
const StackFrameContext *CallerSFC = CurLC->getStackFrame();
|
||||
const LocationContext *ParentOfCallee = CallerSFC;
|
||||
if (Call.getKind() == CE_Block &&
|
||||
!cast<BlockCall>(Call).isConversionFromLambda()) {
|
||||
@@ -612,7 +610,7 @@ ExprEngine::mayInlineCallKind(const CallEvent &Call, const ExplodedNode *Pred,
|
||||
AnalyzerOptions &Opts,
|
||||
const ExprEngine::EvalCallOptions &CallOpts) {
|
||||
const LocationContext *CurLC = Pred->getLocationContext();
|
||||
const StackFrameContext *CallerSFC = CurLC->getCurrentStackFrame();
|
||||
const StackFrameContext *CallerSFC = CurLC->getStackFrame();
|
||||
switch (Call.getKind()) {
|
||||
case CE_Function:
|
||||
case CE_Block:
|
||||
|
||||
@@ -56,7 +56,7 @@ ProgramStateRef getWidenedLoopState(ProgramStateRef PrevState,
|
||||
// being so inprecise. When the invalidation is improved, the handling
|
||||
// of nested loops will also need to be improved.
|
||||
ASTContext &ASTCtx = LCtx->getAnalysisDeclContext()->getASTContext();
|
||||
const StackFrameContext *STC = LCtx->getCurrentStackFrame();
|
||||
const StackFrameContext *STC = LCtx->getStackFrame();
|
||||
MemRegionManager &MRMgr = PrevState->getStateManager().getRegionManager();
|
||||
const MemRegion *Regions[] = {MRMgr.getStackLocalsRegion(STC),
|
||||
MRMgr.getStackArgumentsRegion(STC),
|
||||
|
||||
@@ -921,7 +921,7 @@ MemRegionManager::getBlockDataRegion(const BlockCodeRegion *BC,
|
||||
if (LC) {
|
||||
// FIXME: Once we implement scope handling, we want the parent region
|
||||
// to be the scope.
|
||||
const StackFrameContext *STC = LC->getCurrentStackFrame();
|
||||
const StackFrameContext *STC = LC->getStackFrame();
|
||||
assert(STC);
|
||||
sReg = getStackLocalsRegion(STC);
|
||||
}
|
||||
@@ -949,7 +949,7 @@ MemRegionManager::getCompoundLiteralRegion(const CompoundLiteralExpr *CL,
|
||||
if (CL->isFileScope())
|
||||
sReg = getGlobalsRegion();
|
||||
else {
|
||||
const StackFrameContext *STC = LC->getCurrentStackFrame();
|
||||
const StackFrameContext *STC = LC->getStackFrame();
|
||||
assert(STC);
|
||||
sReg = getStackLocalsRegion(STC);
|
||||
}
|
||||
@@ -1014,7 +1014,7 @@ MemRegionManager::getObjCIvarRegion(const ObjCIvarDecl *d,
|
||||
const CXXTempObjectRegion*
|
||||
MemRegionManager::getCXXTempObjectRegion(Expr const *E,
|
||||
LocationContext const *LC) {
|
||||
const StackFrameContext *SFC = LC->getCurrentStackFrame();
|
||||
const StackFrameContext *SFC = LC->getStackFrame();
|
||||
assert(SFC);
|
||||
return getSubRegion<CXXTempObjectRegion>(E, getStackLocalsRegion(SFC));
|
||||
}
|
||||
@@ -1078,7 +1078,7 @@ MemRegionManager::getCXXThisRegion(QualType thisPointerTy,
|
||||
LC = LC->getParent();
|
||||
D = dyn_cast<CXXMethodDecl>(LC->getDecl());
|
||||
}
|
||||
const StackFrameContext *STC = LC->getCurrentStackFrame();
|
||||
const StackFrameContext *STC = LC->getStackFrame();
|
||||
assert(STC);
|
||||
return getSubRegion<CXXThisRegion>(PT, getStackArgumentsRegion(STC));
|
||||
}
|
||||
@@ -1086,7 +1086,7 @@ MemRegionManager::getCXXThisRegion(QualType thisPointerTy,
|
||||
const AllocaRegion*
|
||||
MemRegionManager::getAllocaRegion(const Expr *E, unsigned cnt,
|
||||
const LocationContext *LC) {
|
||||
const StackFrameContext *STC = LC->getCurrentStackFrame();
|
||||
const StackFrameContext *STC = LC->getStackFrame();
|
||||
assert(STC);
|
||||
return getSubRegion<AllocaRegion>(E, cnt, getStackLocalsRegion(STC));
|
||||
}
|
||||
|
||||
@@ -542,7 +542,7 @@ bool SymbolReaper::isLive(const VarRegion *VR, bool includeStoreBindings) const{
|
||||
|
||||
if (!LCtx)
|
||||
return false;
|
||||
const StackFrameContext *CurrentContext = LCtx->getCurrentStackFrame();
|
||||
const StackFrameContext *CurrentContext = LCtx->getStackFrame();
|
||||
|
||||
if (VarContext == CurrentContext) {
|
||||
// If no statement is provided, everything is live.
|
||||
|
||||
@@ -158,7 +158,7 @@ public:
|
||||
} else {
|
||||
LocIdentifier LocId = std::make_pair(
|
||||
BE->getBlock()->getBlockID(),
|
||||
N->getLocationContext()->getCurrentStackFrame());
|
||||
N->getLocationContext()->getStackFrame());
|
||||
auto InsertInfo = Reachable.insert(LocId);
|
||||
|
||||
if (InsertInfo.second) {
|
||||
@@ -234,7 +234,7 @@ public:
|
||||
if (auto BE = N->getLocation().getAs<BlockEntrance>()) {
|
||||
LocIdentifier LocId = std::make_pair(
|
||||
BE->getBlock()->getBlockID(),
|
||||
N->getLocationContext()->getCurrentStackFrame());
|
||||
N->getLocationContext()->getStackFrame());
|
||||
NumVisited = NumReached[LocId]++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user