Skip to content

Commit 3ef0391

Browse files
[analyzer][NFC] Move PrettyStackTraceLocationContext into dispatchWorkItem
CPP-6476
1 parent 5b05728 commit 3ef0391

File tree

3 files changed

+6
-19
lines changed

3 files changed

+6
-19
lines changed

clang/lib/StaticAnalyzer/Core/CoreEngine.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//===----------------------------------------------------------------------===//
1313

1414
#include "clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h"
15+
#include "PrettyStackTraceLocationContext.h"
1516
#include "clang/AST/Expr.h"
1617
#include "clang/AST/ExprCXX.h"
1718
#include "clang/AST/Stmt.h"
@@ -216,6 +217,7 @@ void CoreEngine::dispatchWorkItem(ExplodedNode *Pred, ProgramPoint Loc,
216217
llvm::TimeTraceScope tcs{timeTraceScopeName(Loc), [Loc, Pred]() {
217218
return timeTraceMetadata(Pred, Loc);
218219
}};
220+
PrettyStackTraceLocationContext CrashInfo(Pred->getLocationContext());
219221
// Dispatch on the location type.
220222
switch (Loc.getKind()) {
221223
case ProgramPoint::BlockEdgeKind:

clang/lib/StaticAnalyzer/Core/ExprEngine.cpp

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,6 @@ void ExprEngine::processEndWorklist() {
968968

969969
void ExprEngine::processCFGElement(const CFGElement E, ExplodedNode *Pred,
970970
unsigned StmtIdx, NodeBuilderContext *Ctx) {
971-
PrettyStackTraceLocationContext CrashInfo(Pred->getLocationContext());
972971
currStmtIdx = StmtIdx;
973972
currBldrCtx = Ctx;
974973

@@ -2541,7 +2540,6 @@ static const LocationContext *getInlinedLocationContext(ExplodedNode *Node,
25412540
void ExprEngine::processCFGBlockEntrance(const BlockEdge &L,
25422541
NodeBuilderWithSinks &nodeBuilder,
25432542
ExplodedNode *Pred) {
2544-
PrettyStackTraceLocationContext CrashInfo(Pred->getLocationContext());
25452543
// If we reach a loop which has a known bound (and meets
25462544
// other constraints) then consider completely unrolling it.
25472545
if(AMgr.options.ShouldUnrollLoops) {
@@ -2808,8 +2806,6 @@ void ExprEngine::processBranch(
28082806
std::optional<unsigned> IterationsCompletedInLoop) {
28092807
assert((!Condition || !isa<CXXBindTemporaryExpr>(Condition)) &&
28102808
"CXXBindTemporaryExprs are handled by processBindTemporary.");
2811-
const LocationContext *LCtx = Pred->getLocationContext();
2812-
PrettyStackTraceLocationContext StackCrashInfo(LCtx);
28132809
currBldrCtx = &BldCtx;
28142810

28152811
// Check for NULL conditions; e.g. "for(;;)"
@@ -2935,13 +2931,9 @@ void ExprEngine::processBranch(
29352931
REGISTER_TRAIT_WITH_PROGRAMSTATE(InitializedGlobalsSet,
29362932
llvm::ImmutableSet<const VarDecl *>)
29372933

2938-
void ExprEngine::processStaticInitializer(const DeclStmt *DS,
2939-
NodeBuilderContext &BuilderCtx,
2940-
ExplodedNode *Pred,
2941-
ExplodedNodeSet &Dst,
2942-
const CFGBlock *DstT,
2943-
const CFGBlock *DstF) {
2944-
PrettyStackTraceLocationContext CrashInfo(Pred->getLocationContext());
2934+
void ExprEngine::processStaticInitializer(
2935+
const DeclStmt *DS, NodeBuilderContext &BuilderCtx, ExplodedNode *Pred,
2936+
ExplodedNodeSet &Dst, const CFGBlock *DstT, const CFGBlock *DstF) {
29452937
currBldrCtx = &BuilderCtx;
29462938

29472939
const auto *VD = cast<VarDecl>(DS->getSingleDecl());
@@ -3064,9 +3056,6 @@ void ExprEngine::processEndOfFunction(NodeBuilderContext& BC,
30643056
assert(areAllObjectsFullyConstructed(Pred->getState(),
30653057
Pred->getLocationContext(),
30663058
Pred->getStackFrame()->getParent()));
3067-
3068-
PrettyStackTraceLocationContext CrashInfo(Pred->getLocationContext());
3069-
30703059
ExplodedNodeSet Dst;
30713060
if (Pred->getLocationContext()->inTopFrame()) {
30723061
// Remove dead symbols.

clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#include "PrettyStackTraceLocationContext.h"
1413
#include "clang/AST/CXXInheritance.h"
1514
#include "clang/AST/Decl.h"
1615
#include "clang/AST/DeclCXX.h"
@@ -44,8 +43,6 @@ STAT_COUNTER(NumReachedInlineCountMax,
4443
void ExprEngine::processCallEnter(NodeBuilderContext& BC, CallEnter CE,
4544
ExplodedNode *Pred) {
4645
// Get the entry block in the CFG of the callee.
47-
const StackFrameContext *calleeCtx = CE.getCalleeContext();
48-
PrettyStackTraceLocationContext CrashInfo(calleeCtx);
4946
const CFGBlock *Entry = CE.getEntry();
5047

5148
// Validate the CFG.
@@ -56,7 +53,7 @@ void ExprEngine::processCallEnter(NodeBuilderContext& BC, CallEnter CE,
5653
const CFGBlock *Succ = *(Entry->succ_begin());
5754

5855
// Construct an edge representing the starting location in the callee.
59-
BlockEdge Loc(Entry, Succ, calleeCtx);
56+
BlockEdge Loc(Entry, Succ, CE.getCalleeContext());
6057

6158
ProgramStateRef state = Pred->getState();
6259

@@ -253,7 +250,6 @@ ProgramStateRef ExprEngine::removeStateTraitsUsedForArrayEvaluation(
253250
/// 5. PostStmt<CallExpr>
254251
void ExprEngine::processCallExit(ExplodedNode *CEBNode) {
255252
// Step 1 CEBNode was generated before the call.
256-
PrettyStackTraceLocationContext CrashInfo(CEBNode->getLocationContext());
257253
const StackFrameContext *calleeCtx = CEBNode->getStackFrame();
258254

259255
// The parent context might not be a stack frame, so make sure we

0 commit comments

Comments
 (0)