Skip to content

Commit f9c67f6

Browse files
committed
Added support for ProgramPoints to represent ExplodedNodes in another
ExplodedGraph. This allows us to build "layered" ExplodedGraphs where one simulation is layered on another. llvm-svn: 47926
1 parent 43c103a commit f9c67f6

File tree

1 file changed

+38
-4
lines changed

1 file changed

+38
-4
lines changed

clang/include/clang/Analysis/ProgramPoint.h

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ namespace clang {
2525

2626
class ProgramPoint {
2727
public:
28-
enum Kind { BlockEntranceKind=0, PostStmtKind=1, BlockExitKind=2,
29-
BlockEdgeSrcKind=3, BlockEdgeDstKind=4, BlockEdgeAuxKind=5 };
28+
enum Kind { LayeredNodeKind = 0x0,
29+
BlockEntranceKind = 0x1,
30+
PostStmtKind = 0x2,
31+
BlockExitKind = 0x3,
32+
BlockEdgeSrcKind = 0x5, // Skip 0x4.
33+
BlockEdgeDstKind = 0x6,
34+
BlockEdgeAuxKind = 0x7 };
3035
protected:
3136
uintptr_t Data;
3237

@@ -40,8 +45,16 @@ class ProgramPoint {
4045
ProgramPoint() : Data(0) {}
4146

4247
public:
43-
unsigned getKind() const { return Data & 0x7; }
44-
void* getRawPtr() const { return reinterpret_cast<void*>(Data & ~0x7); }
48+
49+
unsigned getKind() const {
50+
unsigned x = Data & 0x7;
51+
return x & 0x3 ? x : 0; // Use only lower 2 bits for 0x0.
52+
}
53+
54+
void* getRawPtr() const {
55+
return (void*) (getKind() ? Data & ~0x7 : Data & ~0x3);
56+
}
57+
4558
void* getRawData() const { return reinterpret_cast<void*>(Data); }
4659

4760
static bool classof(const ProgramPoint*) { return true; }
@@ -53,6 +66,27 @@ class ProgramPoint {
5366
ID.AddPointer(getRawPtr());
5467
}
5568
};
69+
70+
class ExplodedNodeImpl;
71+
template <typename StateTy> class ExplodedNode;
72+
73+
class LayeredNode : public ProgramPoint {
74+
public:
75+
LayeredNode(ExplodedNodeImpl* N) : ProgramPoint(N, LayeredNodeKind) {
76+
assert (reinterpret_cast<uintptr_t>(N) & 0x3 == 0 &&
77+
"Address of ExplodedNode must have 4-byte alignment.");
78+
}
79+
80+
ExplodedNodeImpl* getNodeImpl() const {
81+
return (ExplodedNodeImpl*) getRawPtr();
82+
}
83+
84+
template <typename StateTy>
85+
ExplodedNode<StateTy>* getNode() const {
86+
return (ExplodedNode<StateTy>*) getRawPtr();
87+
}
88+
89+
};
5690

5791
class BlockEntrance : public ProgramPoint {
5892
public:

0 commit comments

Comments
 (0)