[clang] c2c2a53 - [NFC][analyzer] Streamline calls of makeNode (#247282)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 1 02:54:24 PST 2026
Author: DonĂ¡t Nagy
Date: 2026-12-01T11:54:17+01:00
New Revision: c2c2a530d21e79549868e1a14e0d4fab7aca558d
URL: https://github.com/llvm/llvm-project/commit/c2c2a530d21e79549868e1a14e0d4fab7aca558d
DIFF: https://github.com/llvm/llvm-project/commit/c2c2a530d21e79549868e1a14e0d4fab7aca558d.diff
LOG: [NFC][analyzer] Streamline calls of makeNode (#247282)
Recent commit 838a8a74fb6b6f319593b5af9fbd725a45b665f8 changed the type
of the program state argument of several node-making methods from
`ProgramStateRef` to `const ProgramState *` in order to improve
performance by avoiding copying (which involves virtual calls and
refcount operations).
However, this way many parts of the engine had to call
`ProgramStateRef::get()` because `ProgramStateRef` isn't implicitly
converted to `const ProgramState *`.
To get rid of the `.get()` calls, this commit introduces inlinable
overloads of `CoreEngine::makeNode` and `CoreEngine::makePostStmtNode`
that accept an `const ProgramStateRef &` and immediately call the other
overload. This way the performance improvements are preserved (the
compiler can easily optimize away these wrapper calls) but there is no
need to use `.get()` in so many expressions.
Added:
Modified:
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
index 02b59ced4321f..05e8a142422ec 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
@@ -445,7 +445,7 @@ class CheckerContext {
Frontier.erase(P);
ExplodedNode *N = Eng.getCoreEngine().makeNode(
- LocalLoc, State ? State.get() : P->getState().get(), P, MarkAsSink);
+ LocalLoc, State ? State : P->getState(), P, MarkAsSink);
Frontier.insert(N);
return N;
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
index 4feaa592c4cc6..791b0537300e6 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h
@@ -171,9 +171,20 @@ class CoreEngine {
auto aborted_blocks() const { return llvm::iterator_range(blocksAborted); }
+ ExplodedNode *makeNode(const ProgramPoint &Loc, const ProgramStateRef &State,
+ ExplodedNode *Pred, bool MarkAsSink = false) const {
+ return makeNode(Loc, State.get(), Pred, MarkAsSink);
+ }
+
ExplodedNode *makeNode(const ProgramPoint &Loc, const ProgramState *State,
ExplodedNode *Pred, bool MarkAsSink = false) const;
+ ExplodedNode *makePostStmtNode(const Stmt *S, const ProgramStateRef &State,
+ ExplodedNode *Pred,
+ bool MarkAsSink = false) const {
+ return makePostStmtNode(S, State.get(), Pred, MarkAsSink);
+ }
+
ExplodedNode *makePostStmtNode(const Stmt *S, const ProgramState *State,
ExplodedNode *Pred,
bool MarkAsSink = false) const {
@@ -188,7 +199,7 @@ class CoreEngine {
const StackFrame *SF = Pred->getStackFrame();
State = State->BindExpr(E, SF, V);
const auto &L = ProgramPoint::getProgramPoint(E, K, SF, /*tag=*/nullptr);
- return makeNode(L, State.get(), Pred);
+ return makeNode(L, State, Pred);
}
ExplodedNode *
diff --git a/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp b/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
index 32f3463a80901..50a4978ce404f 100644
--- a/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -287,7 +287,7 @@ void CoreEngine::HandleBlockEdge(const BlockEdge &L, ExplodedNode *Pred) {
},
/*IsPrunable=*/true));
// Perform the transition.
- Pred = makeNode(P, Pred->getState().get(), Pred);
+ Pred = makeNode(P, Pred->getState(), Pred);
if (!Pred)
return;
}
@@ -396,7 +396,7 @@ void CoreEngine::HandleBlockExit(const CFGBlock * B, ExplodedNode *Pred) {
for (const CFGBlock *Succ : B->succs()) {
if (Succ) {
BlockEdge BE(B, Succ, Pred->getStackFrame());
- if (ExplodedNode *N = makeNode(BE, Pred->State.get(), Pred))
+ if (ExplodedNode *N = makeNode(BE, Pred->State, Pred))
WList->enqueue(N);
}
}
@@ -477,7 +477,7 @@ void CoreEngine::HandleBlockExit(const CFGBlock * B, ExplodedNode *Pred) {
"Blocks with no terminator should have at most 1 successor.");
BlockEdge BE(B, *(B->succ_begin()), Pred->getStackFrame());
- if (ExplodedNode *N = makeNode(BE, Pred->State.get(), Pred))
+ if (ExplodedNode *N = makeNode(BE, Pred->State, Pred))
WList->enqueue(N);
}
@@ -615,7 +615,7 @@ void CoreEngine::enqueueStmtNode(ExplodedNode *N,
return;
}
- ExplodedNode *Succ = makeNode(Loc, N->getState().get(), N);
+ ExplodedNode *Succ = makeNode(Loc, N->getState(), N);
if (Succ)
WList->enqueue(Succ, Block, Idx+1);
@@ -657,7 +657,7 @@ void CoreEngine::enqueueEndOfFunction(ExplodedNodeSet &Set, const ReturnStmt *RS
if (SF->getParent()) {
// Use the callee stack frame.
CallExitBegin Loc(SF, RS);
- if (ExplodedNode *Succ = makeNode(Loc, Node->getState().get(), Node))
+ if (ExplodedNode *Succ = makeNode(Loc, Node->getState(), Node))
WList->enqueue(Succ);
} else {
// TODO: We should run remove dead bindings here.
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index d9669b872cf39..57d44b275d31e 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1092,7 +1092,7 @@ void ExprEngine::removeDead(ExplodedNode *Pred, ExplodedNodeSet &Out,
StateMgr.getPersistentStateWithGDM(CleanedState, CheckerState);
const ProgramPoint &L = ProgramPoint::getProgramPoint(
DiagnosticStmt, K, I->getStackFrame(), cleanupNodeTag());
- Out.insert(Engine.makeNode(L, CleanedCheckerSt.get(), I));
+ Out.insert(Engine.makeNode(L, CleanedCheckerSt, I));
}
}
@@ -1318,7 +1318,7 @@ void ExprEngine::ProcessLoopExit(const Stmt* S, ExplodedNode *Pred) {
NewState = processLoopEnd(S, NewState);
LoopExit PP(S, Pred->getStackFrame());
- if (ExplodedNode *N = Engine.makeNode(PP, NewState.get(), Pred))
+ if (ExplodedNode *N = Engine.makeNode(PP, NewState, Pred))
enqueueStmtNodes(N);
}
@@ -1327,7 +1327,7 @@ void ExprEngine::ProcessLifetimeEnd(const Stmt *S, const VarDecl *D,
PrettyStackTraceStmt CrashInfo(getContext().getSourceManager(), S,
"Error evaluating end of a lifetime");
LifetimeEnd PP(S, D, Pred->getStackFrame());
- ExplodedNode *Src = Engine.makeNode(PP, Pred->getState().get(), Pred);
+ ExplodedNode *Src = Engine.makeNode(PP, Pred->getState(), Pred);
ExplodedNodeSet Dst;
getCheckerManager().runCheckersForLifetimeEnd(Dst, Src, D, *this);
@@ -1362,7 +1362,7 @@ void ExprEngine::ProcessInitializer(const CFGInitializer CFGInit,
// But we still need to stop tracking the object under construction.
State = finishObjectConstruction(State, BMI, SF);
PostStore PS(Init, SF, /*Loc*/ nullptr, /*tag*/ nullptr);
- Tmp.insert(Engine.makeNode(PS, State.get(), Pred));
+ Tmp.insert(Engine.makeNode(PS, State, Pred));
} else {
const ValueDecl *Field;
if (BMI->isIndirectMemberInitializer()) {
@@ -1416,7 +1416,7 @@ void ExprEngine::ProcessInitializer(const CFGInitializer CFGInit,
ExplodedNodeSet Dst;
for (ExplodedNode *Pred : Tmp)
- Dst.insert(Engine.makeNode(PP, Pred->getState().get(), Pred));
+ Dst.insert(Engine.makeNode(PP, Pred->getState(), Pred));
// Enqueue the new nodes onto the work list.
enqueueStmtNodes(Dst);
}
@@ -1499,7 +1499,7 @@ void ExprEngine::ProcessNewAllocator(const CXXNewExpr *NE,
const StackFrame *SF = Pred->getStackFrame();
PostImplicitCall PP(NE->getOperatorNew(), NE->getBeginLoc(), SF,
getCFGElementRef());
- Dst.insert(Engine.makeNode(PP, Pred->getState().get(), Pred));
+ Dst.insert(Engine.makeNode(PP, Pred->getState(), Pred));
}
enqueueStmtNodes(Dst);
}
@@ -1548,7 +1548,7 @@ void ExprEngine::ProcessAutomaticObjDtor(const CFGAutomaticObjDtor Dtor,
"which shouldn't be in the CFG.");
PostImplicitCall PP(DtorDecl, varDecl->getLocation(), SF,
getCFGElementRef(), &PT);
- Engine.makeNode(PP, Pred->getState().get(), Pred, /*MarkAsSink=*/true);
+ Engine.makeNode(PP, Pred->getState(), Pred, /*MarkAsSink=*/true);
return;
}
}
@@ -1563,7 +1563,7 @@ void ExprEngine::ProcessAutomaticObjDtor(const CFGAutomaticObjDtor Dtor,
"Prepare for object destruction");
PreImplicitCall PP(DtorDecl, varDecl->getLocation(), SF, getCFGElementRef(),
&PT);
- Pred = Engine.makeNode(PP, state.get(), Pred);
+ Pred = Engine.makeNode(PP, state, Pred);
if (!Pred)
return;
@@ -1590,7 +1590,7 @@ void ExprEngine::ProcessDeleteDtor(const CFGDeleteDtor Dtor,
const CXXDestructorDecl *Dtor = RD->getDestructor();
PostImplicitCall PP(Dtor, DE->getBeginLoc(), SF, getCFGElementRef());
- Dst.insert(Engine.makeNode(PP, Pred->getState().get(), Pred));
+ Dst.insert(Engine.makeNode(PP, Pred->getState(), Pred));
return;
}
@@ -1623,7 +1623,7 @@ void ExprEngine::ProcessDeleteDtor(const CFGDeleteDtor Dtor,
"ExprEngine", "Skipping 0 length array delete destruction");
PostImplicitCall PP(getDtorDecl(DTy), DE->getBeginLoc(), SF,
getCFGElementRef(), &PT);
- Dst.insert(Engine.makeNode(PP, Pred->getState().get(), Pred));
+ Dst.insert(Engine.makeNode(PP, Pred->getState(), Pred));
return;
}
@@ -1636,7 +1636,7 @@ void ExprEngine::ProcessDeleteDtor(const CFGDeleteDtor Dtor,
"Prepare for object destruction");
PreImplicitCall PP(getDtorDecl(DTy), DE->getBeginLoc(), SF,
getCFGElementRef(), &PT);
- Pred = Engine.makeNode(PP, State.get(), Pred);
+ Pred = Engine.makeNode(PP, State, Pred);
if (!Pred)
return;
@@ -1694,7 +1694,7 @@ void ExprEngine::ProcessMemberDtor(const CFGMemberDtor D,
"shouldn't be in the CFG.");
PostImplicitCall PP(DtorDecl, Member->getLocation(), SF,
getCFGElementRef(), &PT);
- Engine.makeNode(PP, Pred->getState().get(), Pred, /*MarkAsSink=*/true);
+ Engine.makeNode(PP, Pred->getState(), Pred, /*MarkAsSink=*/true);
return;
}
}
@@ -1708,7 +1708,7 @@ void ExprEngine::ProcessMemberDtor(const CFGMemberDtor D,
"Prepare for object destruction");
PreImplicitCall PP(DtorDecl, Member->getLocation(), SF, getCFGElementRef(),
&PT);
- Pred = Engine.makeNode(PP, State.get(), Pred);
+ Pred = Engine.makeNode(PP, State, Pred);
if (!Pred)
return;
@@ -1739,11 +1739,11 @@ void ExprEngine::ProcessTemporaryDtor(const CFGTemporaryDtor D,
State = cleanupElidedDestructor(State, BTE, SF);
PostImplicitCall PP(D.getDestructorDecl(getContext()), BTE->getBeginLoc(),
SF, getCFGElementRef());
- Dst.insert(Engine.makeNode(PP, State.get(), Pred));
+ Dst.insert(Engine.makeNode(PP, State, Pred));
return;
}
- ExplodedNode *CleanPred = Engine.makePostStmtNode(BTE, State.get(), Pred);
+ ExplodedNode *CleanPred = Engine.makePostStmtNode(BTE, State, Pred);
if (!CleanPred) {
// FIXME: We can get a null node here due to temporaries being
// bound to default parameters.
@@ -1798,7 +1798,7 @@ void ExprEngine::processCleanupTemporaryBranch(const CXXBindTemporaryExpr *BTE,
std::optional<SVal> Obj = getObjectUnderConstruction(State, BTE, SF);
if (const CFGBlock *DstBlock = Obj ? DstT : DstF) {
BlockEdge BE(getCurrBlock(), DstBlock, SF);
- Dst.insert(Engine.makeNode(BE, State.get(), Pred));
+ Dst.insert(Engine.makeNode(BE, State, Pred));
}
}
@@ -1823,7 +1823,7 @@ void ExprEngine::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *BTE,
// temporary destructor nodes.
State = addObjectUnderConstruction(State, BTE, SF, UnknownVal());
}
- Dst.insert(Engine.makePostStmtNode(BTE, State.get(), Pred));
+ Dst.insert(Engine.makePostStmtNode(BTE, State, Pred));
}
ProgramStateRef ExprEngine::escapeValues(ProgramStateRef State,
@@ -1996,7 +1996,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
case Stmt::OMPMetaDirectiveClass:
case Stmt::HLSLOutArgExprClass: {
const ExplodedNode *Node = Engine.makePostStmtNode(
- S, Pred->getState().get(), Pred, /*MarkAsSink=*/true);
+ S, Pred->getState(), Pred, /*MarkAsSink=*/true);
Engine.addAbortedBlock(Node, getCurrBlock());
break;
}
@@ -2152,7 +2152,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
if (IsTemporary)
State = createTemporaryRegionIfNeeded(State, SF, cast<Expr>(S),
cast<Expr>(S));
- Dst.insert(Engine.makePostStmtNode(S, State.get(), Pred));
+ Dst.insert(Engine.makePostStmtNode(S, State, Pred));
break;
}
@@ -2182,7 +2182,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
State = escapeValues(State, Val, PSK_EscapeOther);
}
- Dst.insert(Engine.makePostStmtNode(S, State.get(), Pred));
+ Dst.insert(Engine.makePostStmtNode(S, State, Pred));
break;
}
@@ -2348,8 +2348,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
case Stmt::CXXThrowExprClass:
// FIXME: This is not complete. We basically treat @throw as
// an abort.
- Engine.makePostStmtNode(S, Pred->getState().get(), Pred,
- /*MarkAsSink=*/true);
+ Engine.makePostStmtNode(S, Pred->getState(), Pred, /*MarkAsSink=*/true);
break;
case Stmt::ReturnStmtClass:
@@ -2482,7 +2481,7 @@ ExplodedNode *ExprEngine::processCFGBlockEntrance(const BlockEntrance &BE,
LoopCache);
// Is we are inside an unrolled loop then no need the check the counters.
if (isUnrolledState(State))
- return Engine.makeNode(BE, State.get(), Pred);
+ return Engine.makeNode(BE, State, Pred);
}
// If this block is terminated by a loop and it has already been visited the
@@ -2490,21 +2489,21 @@ ExplodedNode *ExprEngine::processCFGBlockEntrance(const BlockEntrance &BE,
unsigned int BlockCount = getNumVisitedCurrent();
if (BlockCount == MaxBlockVisit - 1 && AMgr.options.ShouldWidenLoops) {
if (!isa_and_nonnull<ForStmt, WhileStmt, DoStmt, CXXForRangeStmt>(Term))
- return Engine.makeNode(BE, State.get(), Pred);
+ return Engine.makeNode(BE, State, Pred);
ProgramStateRef WidenedState =
getWidenedLoopState(State, SF, BlockCount, getCFGElementRef());
- return Engine.makeNode(BE, WidenedState.get(), Pred);
+ return Engine.makeNode(BE, WidenedState, Pred);
}
// If we did not reach MaxBlockVisitOnPath, continue the analysis normally.
if (BlockCount < MaxBlockVisit)
- return Engine.makeNode(BE, State.get(), Pred);
+ return Engine.makeNode(BE, State, Pred);
// ... otherwise, discard this execution path.
static SimpleProgramPointTag Tag(TagProviderName, "Block count exceeded");
const ExplodedNode *Sink =
- Engine.makeNode(BE.withTag(&Tag), State.get(), Pred, /*MarkAsSink=*/true);
+ Engine.makeNode(BE.withTag(&Tag), State, Pred, /*MarkAsSink=*/true);
if (!SF->inTopFrame()) {
// FIXME: This will unconditionally prevent inlining this function (even
@@ -2755,7 +2754,7 @@ void ExprEngine::processBranch(
return;
}
BlockEdge BE(getCurrBlock(), DstT, SF);
- Dst.insert(Engine.makeNode(BE, Pred->getState().get(), Pred));
+ Dst.insert(Engine.makeNode(BE, Pred->getState(), Pred));
return;
}
@@ -2820,7 +2819,7 @@ void ExprEngine::processBranch(
if (!SkipTrueBranch || AMgr.options.ShouldWidenLoops) {
if (DstT) {
BlockEdge BE(getCurrBlock(), DstT, SF);
- Dst.insert(Engine.makeNode(BE, StTrue.get(), PredN));
+ Dst.insert(Engine.makeNode(BE, StTrue, PredN));
}
} else if (!AMgr.options.InlineFunctionsWithAmbiguousLoops) {
// FIXME: There is an ancient and arbitrary heuristic in
@@ -2862,7 +2861,7 @@ void ExprEngine::processBranch(
AMgr.options.ShouldAssumeAtLeastOneIteration;
if (!SkipFalseBranch && DstF) {
BlockEdge BE(getCurrBlock(), DstF, SF);
- Dst.insert(Engine.makeNode(BE, StFalse.get(), PredN));
+ Dst.insert(Engine.makeNode(BE, StFalse, PredN));
}
}
}
@@ -2886,7 +2885,7 @@ void ExprEngine::processStaticInitializer(const DeclStmt *DS,
if (const CFGBlock *DstBlock = InitHasRun ? DstT : DstF) {
BlockEdge BE(getCurrBlock(), DstBlock, Pred->getStackFrame());
- Dst.insert(Engine.makeNode(BE, State.get(), Pred));
+ Dst.insert(Engine.makeNode(BE, State, Pred));
}
}
@@ -2918,7 +2917,7 @@ void ExprEngine::processIndirectGoto(ExplodedNodeSet &Dst, const Expr *Tgt,
// FIXME: If 'V' was a symbolic value, then record that on this execution
// path it is equal to the address of the label leading to 'Succ'.
BlockEdge BE(getCurrBlock(), Succ, Pred->getStackFrame());
- Dst.insert(Engine.makeNode(BE, State.get(), Pred));
+ Dst.insert(Engine.makeNode(BE, State, Pred));
}
}
}
@@ -2970,7 +2969,7 @@ void ExprEngine::processEndOfFunction(ExplodedNode *Pred,
// Perform the transition with cleanups.
if (State != Pred->getState()) {
- Pred = Engine.makeNode(Pred->getLocation(), State.get(), Pred);
+ Pred = Engine.makeNode(Pred->getLocation(), State, Pred);
if (!Pred) {
// The node with clean temporaries already exists. We might have reached
// it on a path on which we initialize
diff erent temporaries.
@@ -3064,7 +3063,7 @@ void ExprEngine::processSwitch(const SwitchStmt *Switch, ExplodedNode *Pred,
if (StateMatching) {
BlockEdge BE(SwitchBlock, CaseBlock, SF);
- Dst.insert(Engine.makeNode(BE, StateMatching.get(), Node));
+ Dst.insert(Engine.makeNode(BE, StateMatching, Node));
}
// If _not_ entering the current case is infeasible, then we are done
@@ -3092,7 +3091,7 @@ void ExprEngine::processSwitch(const SwitchStmt *Switch, ExplodedNode *Pred,
}
BlockEdge BE(SwitchBlock, DefaultBlock, SF);
- Dst.insert(Engine.makeNode(BE, State.get(), Node));
+ Dst.insert(Engine.makeNode(BE, State, Node));
}
}
@@ -3406,7 +3405,7 @@ void ExprEngine::VisitArraySubscriptExpr(const ArraySubscriptExpr *A,
Engine.makeNodeWithBinding(Pred, A, V, ProgramPoint::PostLValueKind));
} else if (IsVectorType) {
// FIXME: non-glvalue vector reads are not modelled.
- Dst.insert(Engine.makePostStmtNode(A, state.get(), Pred));
+ Dst.insert(Engine.makePostStmtNode(A, state, Pred));
} else {
llvm_unreachable("Array subscript should be an lValue when not \
a vector and not a forbidden lvalue type");
@@ -3641,7 +3640,7 @@ void ExprEngine::evalBind(ExplodedNodeSet &Dst, const Stmt *StoreE,
}
PostStore PS(StoreE, SF, Location.getAsRegion(), /*tag=*/nullptr);
- Dst.insert(Engine.makeNode(PS, State.get(), PredI));
+ Dst.insert(Engine.makeNode(PS, State, PredI));
}
}
@@ -3711,7 +3710,7 @@ void ExprEngine::evalLoad(ExplodedNodeSet &Dst,
const auto *SF = I->getStackFrame();
PostLoad Loc(NodeEx, SF, tag);
- Dst.insert(Engine.makeNode(Loc, state->BindExpr(BoundEx, SF, V).get(), I));
+ Dst.insert(Engine.makeNode(Loc, state->BindExpr(BoundEx, SF, V), I));
}
}
@@ -3740,7 +3739,7 @@ void ExprEngine::evalLocation(ExplodedNodeSet &Dst, const Stmt *NodeEx,
static SimpleProgramPointTag tag(TagProviderName, "Location");
PostStmt Loc(NodeEx, Pred->getStackFrame(), &tag);
- Src.insert(Engine.makeNode(Loc, state.get(), Pred));
+ Src.insert(Engine.makeNode(Loc, state, Pred));
}
ExplodedNodeSet Tmp;
@@ -3796,7 +3795,7 @@ void ExprEngine::evalEagerlyAssumeBifurcation(ExplodedNodeSet &Dst,
SVal Val = svalBuilder.makeIntVal(1U, Ex->getType());
StateTrue = StateTrue->BindExpr(Ex, SF, Val);
PostStmt PostStmtTrue(Ex, SF, TrueTag);
- Dst.insert(Engine.makeNode(PostStmtTrue, StateTrue.get(), Pred));
+ Dst.insert(Engine.makeNode(PostStmtTrue, StateTrue, Pred));
}
// Next, assume that the condition is false.
@@ -3804,7 +3803,7 @@ void ExprEngine::evalEagerlyAssumeBifurcation(ExplodedNodeSet &Dst,
SVal Val = svalBuilder.makeIntVal(0U, Ex->getType());
StateFalse = StateFalse->BindExpr(Ex, SF, Val);
PostStmt PostStmtFalse(Ex, SF, FalseTag);
- Dst.insert(Engine.makeNode(PostStmtFalse, StateFalse.get(), Pred));
+ Dst.insert(Engine.makeNode(PostStmtFalse, StateFalse, Pred));
}
} else {
Dst.insert(Pred);
@@ -3850,12 +3849,12 @@ void ExprEngine::VisitGCCAsmStmt(const GCCAsmStmt *A, ExplodedNode *Pred,
/*CausedByPointerEscape=*/true);
}
- Dst.insert(Engine.makePostStmtNode(A, state.get(), Pred));
+ Dst.insert(Engine.makePostStmtNode(A, state, Pred));
}
void ExprEngine::VisitMSAsmStmt(const MSAsmStmt *A, ExplodedNode *Pred,
ExplodedNodeSet &Dst) {
- Dst.insert(Engine.makePostStmtNode(A, Pred->getState().get(), Pred));
+ Dst.insert(Engine.makePostStmtNode(A, Pred->getState(), Pred));
}
//===----------------------------------------------------------------------===//
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
index 795d98eda234f..7a0b81494cf1e 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -88,7 +88,7 @@ void ExprEngine::VisitBinaryOperator(const BinaryOperator* B,
State = escapeValues(State, RightV, PSK_EscapeOther);
}
- Tmp2.insert(Engine.makePostStmtNode(B, State.get(), N));
+ Tmp2.insert(Engine.makePostStmtNode(B, State, N));
continue;
}
@@ -241,7 +241,7 @@ void ExprEngine::handleLValueBitCast(ProgramStateRef state, const Expr *Ex,
if (V.isUnknown() && !OrigV.isUnknown()) {
state = escapeValues(state, OrigV, PSK_EscapeOther);
}
- Dst.insert(Engine.makePostStmtNode(CastE, state.get(), Pred));
+ Dst.insert(Engine.makePostStmtNode(CastE, state, Pred));
}
void ExprEngine::VisitCastExpr(const CastExpr *CastE, ExplodedNode *Pred,
@@ -420,7 +420,7 @@ void ExprEngine::VisitCastExpr(const CastExpr *CastE, ExplodedNode *Pred,
if (T->isReferenceType()) {
// A bad_cast exception is thrown if input value is a reference.
// Currently, we model this, by generating a sink.
- Engine.makePostStmtNode(CastE, State.get(), Pred, /*MarkAsSink=*/true);
+ Engine.makePostStmtNode(CastE, State, Pred, /*MarkAsSink=*/true);
return;
} else {
// If the cast fails on a pointer, bind to 0.
@@ -438,7 +438,7 @@ void ExprEngine::VisitCastExpr(const CastExpr *CastE, ExplodedNode *Pred,
// Else, bind to the derived region value.
State = State->BindExpr(CastE, SF, val);
}
- Dst.insert(Engine.makePostStmtNode(CastE, State.get(), Pred));
+ Dst.insert(Engine.makePostStmtNode(CastE, State, Pred));
return;
}
case CK_BaseToDerived: {
@@ -596,7 +596,7 @@ void ExprEngine::VisitDeclStmt(const DeclStmt *DS, ExplodedNode *Pred,
state = finishObjectConstruction(state, DS, SF);
// We constructed the object directly in the variable.
// No need to bind anything.
- dstEvaluated.insert(Engine.makePostStmtNode(DS, state.get(), UpdatedN));
+ dstEvaluated.insert(Engine.makePostStmtNode(DS, state, UpdatedN));
} else {
// Recover some path-sensitivity if a scalar value evaluated to
// UnknownVal.
@@ -616,7 +616,7 @@ void ExprEngine::VisitDeclStmt(const DeclStmt *DS, ExplodedNode *Pred,
}
}
else {
- dstEvaluated.insert(Engine.makePostStmtNode(DS, state.get(), N));
+ dstEvaluated.insert(Engine.makePostStmtNode(DS, state, N));
}
}
@@ -651,7 +651,7 @@ void ExprEngine::VisitLogicalExpr(const BinaryOperator* B, ExplodedNode *Pred,
// logical operators on vectors are not short-circuit. Currently they are
// modeled as short-circuit in Clang CFG but this is incorrect.
// Do not set the value for the expression. It'd be UnknownVal by default.
- Dst.insert(Engine.makePostStmtNode(B, state.get(), Pred));
+ Dst.insert(Engine.makePostStmtNode(B, state, Pred));
return;
}
@@ -663,7 +663,7 @@ void ExprEngine::VisitLogicalExpr(const BinaryOperator* B, ExplodedNode *Pred,
(void) P;
if (N->pred_size() != 1) {
// We failed to track back where we came from.
- Dst.insert(Engine.makePostStmtNode(B, state.get(), Pred));
+ Dst.insert(Engine.makePostStmtNode(B, state, Pred));
return;
}
N = *N->pred_begin();
@@ -671,7 +671,7 @@ void ExprEngine::VisitLogicalExpr(const BinaryOperator* B, ExplodedNode *Pred,
if (N->pred_size() != 1) {
// We failed to track back where we came from.
- Dst.insert(Engine.makePostStmtNode(B, state.get(), Pred));
+ Dst.insert(Engine.makePostStmtNode(B, state, Pred));
return;
}
@@ -964,7 +964,7 @@ void ExprEngine::VisitUnaryOperator(const UnaryOperator* U, ExplodedNode *Pred,
state = state->BindExpr(U, SF, Result);
break;
}
- EvalSet.insert(Engine.makePostStmtNode(U, state.get(), N));
+ EvalSet.insert(Engine.makePostStmtNode(U, state, N));
break;
}
}
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
index 09b515a13a71e..373ca4b5d1bab 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -38,7 +38,7 @@ void ExprEngine::VisitMaterializeTemporaryExpr(
const StackFrame *SF = Pred->getStackFrame();
State = createTemporaryRegionIfNeeded(State, SF, TempExpr, MTE);
- Dst.insert(Engine.makePostStmtNode(MTE, State.get(), Pred));
+ Dst.insert(Engine.makePostStmtNode(MTE, State, Pred));
}
void ExprEngine::performTrivialCopy(ExplodedNodeSet &Dst, ExplodedNode *Pred,
@@ -98,7 +98,7 @@ void ExprEngine::performTrivialCopy(ExplodedNodeSet &Dst, ExplodedNode *Pred,
State = State->BindExpr(CallExpr, SF, ThisVal);
else
State = bindReturnValue(Call, SF, State);
- Dst.insert(Engine.makePostStmtNode(CallExpr, State.get(), N));
+ Dst.insert(Engine.makePostStmtNode(CallExpr, State, N));
}
}
@@ -540,7 +540,7 @@ void ExprEngine::handleConstructor(const Expr *E, ExplodedNode *Pred,
State = finishObjectConstruction(State, CE, SF);
if (auto L = Target.getAs<Loc>())
State = State->BindExpr(CE, SF, State->getSVal(*L, CE->getType()));
- Dst.insert(Engine.makePostStmtNode(CE, State.get(), Pred));
+ Dst.insert(Engine.makePostStmtNode(CE, State, Pred));
return;
}
}
@@ -580,7 +580,7 @@ void ExprEngine::handleConstructor(const Expr *E, ExplodedNode *Pred,
static SimpleProgramPointTag T{"ExprEngine",
"Skipping 0 size array construction"};
PostStmt Loc(CE, Pred->getStackFrame(), &T);
- Dst.insert(Engine.makeNode(Loc, State.get(), Pred));
+ Dst.insert(Engine.makeNode(Loc, State, Pred));
return;
}
@@ -658,7 +658,7 @@ void ExprEngine::handleConstructor(const Expr *E, ExplodedNode *Pred,
if (State != Pred->getState()) {
static SimpleProgramPointTag T("ExprEngine",
"Prepare for object construction");
- Pred = Engine.makeNode(PreStmt(E, SF, &T), State.get(), Pred);
+ Pred = Engine.makeNode(PreStmt(E, SF, &T), State, Pred);
if (!Pred)
return;
}
@@ -700,7 +700,7 @@ void ExprEngine::handleConstructor(const Expr *E, ExplodedNode *Pred,
}
PreStmt P(CE, N->getStackFrame(), /*tag=*/nullptr);
- PreInitialized.insert(Engine.makeNode(P, State.get(), N));
+ PreInitialized.insert(Engine.makeNode(P, State, N));
}
} else {
PreInitialized = DstPreVisit;
@@ -752,7 +752,7 @@ void ExprEngine::handleConstructor(const Expr *E, ExplodedNode *Pred,
"We should not have inlined this constructor!");
for (ExplodedNode *N : DstEvaluated) {
- Engine.makePostStmtNode(E, N->getState().get(), N, /*MarkAsSink=*/true);
+ Engine.makePostStmtNode(E, N->getState(), N, /*MarkAsSink=*/true);
}
// There is no need to run the PostCall and PostStmt checker
@@ -811,7 +811,7 @@ void ExprEngine::VisitCXXDestructor(QualType ObjectType,
// FIXME: PostImplicitCall with a null decl may crash elsewhere anyway.
PostImplicitCall PP(/*Decl=*/nullptr, S->getEndLoc(), SF,
getCFGElementRef(), &T);
- Dst.insert(Engine.makeNode(PP, Pred->getState().get(), Pred));
+ Dst.insert(Engine.makeNode(PP, Pred->getState(), Pred));
return;
}
@@ -826,8 +826,7 @@ void ExprEngine::VisitCXXDestructor(QualType ObjectType,
Dest = MRMgr.getCXXTempObjectRegion(E, Pred->getStackFrame());
} else {
static SimpleProgramPointTag T("ExprEngine", "SkipInvalidDestructor");
- Engine.makeNode(Pred->getLocation().withTag(&T), Pred->getState().get(),
- Pred,
+ Engine.makeNode(Pred->getLocation().withTag(&T), Pred->getState(), Pred,
/*MarkAsSink=*/true);
return;
}
@@ -919,7 +918,7 @@ void ExprEngine::VisitCXXNewAllocatorCall(const CXXNewExpr *CNE,
}
DstPostValue.insert(Engine.makePostStmtNode(
- CNE, addObjectUnderConstruction(State, CNE, SF, RetVal).get(), I));
+ CNE, addObjectUnderConstruction(State, CNE, SF, RetVal), I));
}
ExplodedNodeSet DstPostPostCallCallback;
@@ -1013,7 +1012,7 @@ void ExprEngine::VisitCXXNewExpr(const CXXNewExpr *CNE, ExplodedNode *Pred,
// If the array is list initialized, we bind the initializer list to the
// memory region here, otherwise we would lose it.
if (isInitList) {
- Pred = Engine.makePostStmtNode(CNE, State.get(), Pred);
+ Pred = Engine.makePostStmtNode(CNE, State, Pred);
SVal V = State->getSVal(Init, SF);
ExplodedNodeSet Evaluated;
@@ -1097,7 +1096,7 @@ void ExprEngine::VisitCXXCatchStmt(const CXXCatchStmt *CS, ExplodedNode *Pred,
ProgramStateRef state = Pred->getState();
state = state->bindLoc(state->getLValue(VD, SF), V, SF);
- Dst.insert(Engine.makePostStmtNode(CS, state.get(), Pred));
+ Dst.insert(Engine.makePostStmtNode(CS, state, Pred));
}
void ExprEngine::VisitCXXParenListInitExpr(const CXXParenListInitExpr *E,
@@ -1123,7 +1122,7 @@ void ExprEngine::VisitLambdaExpr(const LambdaExpr *LE, ExplodedNode *Pred,
if (!AMgr.options.ShouldInlineLambdas) {
const ExplodedNode *Node = Engine.makePostStmtNode(
- LE, Pred->getState().get(), Pred, /*MarkAsSink=*/true);
+ LE, Pred->getState(), Pred, /*MarkAsSink=*/true);
Engine.addAbortedBlock(Node, getCurrBlock());
return;
}
@@ -1214,5 +1213,5 @@ void ExprEngine::VisitAttributedStmt(const AttributedStmt *A,
}
if (State)
- Dst.insert(Engine.makePostStmtNode(A, State.get(), Pred));
+ Dst.insert(Engine.makePostStmtNode(A, State, Pred));
}
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
index 821d708db40d9..625694da1799e 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -55,7 +55,7 @@ void ExprEngine::processCallEnter(CallEnter CE, ExplodedNode *Pred) {
// Construct a new node, notify checkers that analysis of the function has
// begun, and add the resultant nodes to the worklist.
- ExplodedNode *Node = Engine.makeNode(Loc, Pred->getState().get(), Pred);
+ ExplodedNode *Node = Engine.makeNode(Loc, Pred->getState(), Pred);
if (Node) {
// FIXME: In the `processBeginOfFunction` callback
// `ExprEngine::getCurrStackFrame()` can be
diff erent from the
@@ -353,7 +353,7 @@ void ExprEngine::processCallExit(ExplodedNode *CEBNode) {
: ProgramPoint{EpsilonPoint(CalleeSF, /*Data1=*/nullptr,
/*Data2=*/nullptr, &RetValBind)};
- ExplodedNode *BoundRetNode = Engine.makeNode(Loc, State.get(), CEBNode);
+ ExplodedNode *BoundRetNode = Engine.makeNode(Loc, State, CEBNode);
if (!BoundRetNode)
return;
@@ -379,7 +379,7 @@ void ExprEngine::processCallExit(ExplodedNode *CEBNode) {
CallExitEnd Loc(CalleeSF, CallerSF);
ProgramStateRef CEEState = (N == CEBNode) ? State : N->getState();
- ExplodedNode *CEENode = Engine.makeNode(Loc, CEEState.get(), N);
+ ExplodedNode *CEENode = Engine.makeNode(Loc, CEEState, N);
if (!CEENode)
continue;
@@ -542,7 +542,7 @@ void ExprEngine::inlineCall(WorkList *WList, const CallEvent &Call,
// formal arguments.
State = State->enterStackFrame(Call, CalleeSF);
- if (ExplodedNode *N = Engine.makeNode(Loc, State.get(), Pred))
+ if (ExplodedNode *N = Engine.makeNode(Loc, State, Pred))
WList->enqueue(N);
NumInlinedCalls++;
@@ -588,7 +588,7 @@ void ExprEngine::VisitCallExpr(const CallExpr *CE, ExplodedNode *Pred,
createTemporaryRegionIfNeeded(State, SF, OCE->getArg(0));
if (NewState != State) {
PreStmt PS(OCE, SF, /*tag=*/nullptr);
- Pred = Engine.makeNode(PS, NewState.get(), Pred);
+ Pred = Engine.makeNode(PS, NewState, Pred);
if (!Pred)
return; // Cached out.
}
@@ -662,7 +662,7 @@ void ExprEngine::finishArgumentConstruction(ExplodedNodeSet &Dst,
const StackFrame *SF = Call.getStackFrame();
static SimpleProgramPointTag Tag("ExprEngine",
"Finish argument construction");
- Dst.insert(Engine.makeNode(PreStmt(E, SF, &Tag), CleanedState.get(), Pred));
+ Dst.insert(Engine.makeNode(PreStmt(E, SF, &Tag), CleanedState, Pred));
}
void ExprEngine::evalCall(ExplodedNodeSet &Dst, ExplodedNode *Pred,
@@ -725,7 +725,7 @@ void ExprEngine::evalCall(ExplodedNodeSet &Dst, ExplodedNode *Pred,
PSK_EscapeOutParameters, &*Call);
if (State != I->getState())
- I = Engine.makeNode(I->getLocation(), State.get(), I);
+ I = Engine.makeNode(I->getLocation(), State, I);
Dst.insert(I);
}
@@ -830,7 +830,7 @@ ExplodedNode *ExprEngine::conservativeEvalCall(const CallEvent &Call,
// And make the result node.
static SimpleProgramPointTag PT("ExprEngine", "Conservative eval call");
- return Engine.makeNode(Call.getProgramPoint(false, &PT), State.get(), Pred);
+ return Engine.makeNode(Call.getProgramPoint(false, &PT), State, Pred);
}
ExprEngine::CallInlinePolicy
@@ -1298,7 +1298,7 @@ void ExprEngine::dynDispatchBifurcate(const MemRegion *BifurReg,
void ExprEngine::VisitReturnStmt(const ReturnStmt *RS, ExplodedNode *Pred,
ExplodedNodeSet &Dst) {
if (RS->getRetValue()) {
- Dst.insert(Engine.makePostStmtNode(RS, Pred->getState().get(), Pred));
+ Dst.insert(Engine.makePostStmtNode(RS, Pred->getState(), Pred));
} else {
Dst.insert(Pred);
}
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
index 3012f514a1bab..ada445815b1d5 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
@@ -58,7 +58,7 @@ void ExprEngine::populateObjCForDestinationSet(const ObjCForCollectionStmt *S,
State = State->bindLoc(ElementV, V, SF);
}
- Dst.insert(Engine.makePostStmtNode(S, State.get(), Pred));
+ Dst.insert(Engine.makePostStmtNode(S, State, Pred));
}
void ExprEngine::VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S,
@@ -184,7 +184,7 @@ void ExprEngine::VisitObjCMessage(const ObjCMessageExpr *ME,
// Receiver is definitely nil, so run ObjCMessageNil callbacks and return.
if (nilState && !notNilState) {
PreStmt PS(ME, Pred->getStackFrame(), nullptr);
- Pred = Engine.makeNode(PS, nilState.get(), Pred);
+ Pred = Engine.makeNode(PS, nilState, Pred);
if (!Pred)
return;
@@ -199,7 +199,7 @@ void ExprEngine::VisitObjCMessage(const ObjCMessageExpr *ME,
// Generate a transition to the non-nil state, dropping any potential
// nil flow.
if (notNilState != State) {
- Pred = Engine.makePostStmtNode(ME, notNilState.get(), Pred);
+ Pred = Engine.makePostStmtNode(ME, notNilState, Pred);
if (!Pred)
return;
}
@@ -226,7 +226,7 @@ void ExprEngine::VisitObjCMessage(const ObjCMessageExpr *ME,
UpdatedMsg->getReceiverSVal().isUndef())) {
// If we raise an exception, for now treat it as a sink.
// Eventually we will want to handle exceptions properly.
- Engine.makePostStmtNode(ME, State.get(), Pred, /*MarkAsSink=*/true);
+ Engine.makePostStmtNode(ME, State, Pred, /*MarkAsSink=*/true);
continue;
}
More information about the cfe-commits
mailing list