Skip to content

Commit 7bee91f

Browse files
authored
[analyzer][NFC] Turn NodeBuilderContext into a class (#84638)
From issue #73088. I changed `NodeBuilderContext` into a class. Additionally, there were some other mentions of the former being a struct which I also changed into a class. This is my first time working with an issue so I will be open to hearing any advice or changes that need to be done.
1 parent 683a9ac commit 7bee91f

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

clang/include/clang/StaticAnalyzer/Core/CheckerManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ExplodedNodeSet;
4949
class ExprEngine;
5050
struct EvalCallOptions;
5151
class MemRegion;
52-
struct NodeBuilderContext;
52+
class NodeBuilderContext;
5353
class ObjCMethodCall;
5454
class RegionAndSymbolInvalidationTraits;
5555
class SVal;

clang/include/clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class CoreEngine {
5959
friend class ExprEngine;
6060
friend class IndirectGotoNodeBuilder;
6161
friend class NodeBuilder;
62-
friend struct NodeBuilderContext;
62+
friend class NodeBuilderContext;
6363
friend class SwitchNodeBuilder;
6464

6565
public:
@@ -193,12 +193,12 @@ class CoreEngine {
193193
DataTag::Factory &getDataTags() { return DataTags; }
194194
};
195195

196-
// TODO: Turn into a class.
197-
struct NodeBuilderContext {
196+
class NodeBuilderContext {
198197
const CoreEngine &Eng;
199198
const CFGBlock *Block;
200199
const LocationContext *LC;
201200

201+
public:
202202
NodeBuilderContext(const CoreEngine &E, const CFGBlock *B,
203203
const LocationContext *L)
204204
: Eng(E), Block(B), LC(L) {
@@ -208,9 +208,15 @@ struct NodeBuilderContext {
208208
NodeBuilderContext(const CoreEngine &E, const CFGBlock *B, ExplodedNode *N)
209209
: NodeBuilderContext(E, B, N->getLocationContext()) {}
210210

211+
/// Return the CoreEngine associated with this builder.
212+
const CoreEngine &getEngine() const { return Eng; }
213+
211214
/// Return the CFGBlock associated with this builder.
212215
const CFGBlock *getBlock() const { return Block; }
213216

217+
/// Return the location context associated with this builder.
218+
const LocationContext *getLocationContext() const { return LC; }
219+
214220
/// Returns the number of times the current basic block has been
215221
/// visited on the exploded graph path.
216222
unsigned blockCount() const {

clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class ExplodedNodeSet;
8585
class ExplodedNode;
8686
class IndirectGotoNodeBuilder;
8787
class MemRegion;
88-
struct NodeBuilderContext;
88+
class NodeBuilderContext;
8989
class NodeBuilderWithSinks;
9090
class ProgramState;
9191
class ProgramStateManager;

clang/lib/StaticAnalyzer/Core/CoreEngine.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,8 @@ ExplodedNode* NodeBuilder::generateNodeImpl(const ProgramPoint &Loc,
625625
bool MarkAsSink) {
626626
HasGeneratedNodes = true;
627627
bool IsNew;
628-
ExplodedNode *N = C.Eng.G.getNode(Loc, State, MarkAsSink, &IsNew);
629-
N->addPredecessor(FromN, C.Eng.G);
628+
ExplodedNode *N = C.getEngine().G.getNode(Loc, State, MarkAsSink, &IsNew);
629+
N->addPredecessor(FromN, C.getEngine().G);
630630
Frontier.erase(FromN);
631631

632632
if (!IsNew)
@@ -655,7 +655,7 @@ ExplodedNode *BranchNodeBuilder::generateNode(ProgramStateRef State,
655655
if (!isFeasible(branch))
656656
return nullptr;
657657

658-
ProgramPoint Loc = BlockEdge(C.Block, branch ? DstT:DstF,
658+
ProgramPoint Loc = BlockEdge(C.getBlock(), branch ? DstT : DstF,
659659
NodePred->getLocationContext());
660660
ExplodedNode *Succ = generateNodeImpl(Loc, State, NodePred);
661661
return Succ;

0 commit comments

Comments
 (0)