aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Analysis/ProgramEdge.h
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-01-09 22:52:38 +0000
committerTed Kremenek <kremenek@apple.com>2008-01-09 22:52:38 +0000
commitbd129696c554fbbcd9405104641e292f0fb4678d (patch)
tree650c2bc774fd12c6b4212d2949a93b2559107d70 /include/clang/Analysis/ProgramEdge.h
parenta2f4ef2c11c5cd8dcd5aa3d691f3a4bd971f96c2 (diff)
Renamed Stmt***Edge and ***StmtEdge (where *** = "Stmt" or "Blk") classes to
BExpr*** and ***BExpr respectively. These edges represent program locations between the entrance/exit of a block and Block-level Expressions. Also added ***SExpr and SExpr*** ProgramEdges to represent the locations in the program between the evaluation of subexpressions and block-level expressions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45786 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Analysis/ProgramEdge.h')
-rw-r--r--include/clang/Analysis/ProgramEdge.h92
1 files changed, 71 insertions, 21 deletions
diff --git a/include/clang/Analysis/ProgramEdge.h b/include/clang/Analysis/ProgramEdge.h
index fb81c701f3..ee8fae0140 100644
--- a/include/clang/Analysis/ProgramEdge.h
+++ b/include/clang/Analysis/ProgramEdge.h
@@ -27,12 +27,16 @@ namespace clang {
class ProgramEdge {
uintptr_t Src, Dst;
public:
- enum EdgeKind { StmtBlk=0, BlkStmt=1, StmtStmt=2, BlkBlk=3 };
+ enum EdgeKind { BExprBlk=0, BlkBExpr=1, BExprBExpr=2, BlkBlk=3,
+ BExprSExpr=4, SExprSExpr=5, SExprBExpr=6 };
+
static bool classof(const ProgramEdge*) { return true; }
- unsigned getKind() const { return (unsigned) Src & 0x3; }
+ unsigned getKind() const { return (((unsigned) Src & 0x3) << 2) |
+ ((unsigned) Dst & 0x3); }
+
void* RawSrc() const { return reinterpret_cast<void*>(Src & ~0x3); }
- void* RawDst() const { return reinterpret_cast<void*>(Dst); }
+ void* RawDst() const { return reinterpret_cast<void*>(Dst & ~0x3); }
bool operator==(const ProgramEdge & RHS) const {
// comparing pointer values canoncalizes "NULL" edges where both pointers
@@ -55,45 +59,89 @@ public:
protected:
ProgramEdge(const void* src, const void* dst, EdgeKind k) {
- assert (k >= StmtBlk && k <= BlkBlk);
- Src = reinterpret_cast<uintptr_t>(const_cast<void*>(src)) | k;
- Dst = reinterpret_cast<uintptr_t>(const_cast<void*>(dst));
+ assert (k >= BExprBlk && k <= BlkBlk);
+ Src = reinterpret_cast<uintptr_t>(const_cast<void*>(src)) | (k >> 2);
+ Dst = reinterpret_cast<uintptr_t>(const_cast<void*>(dst)) | (k & 0x3);
}
};
-class StmtBlkEdge : public ProgramEdge {
+class BExprBlkEdge : public ProgramEdge {
public:
- StmtBlkEdge(const Stmt* S,const CFGBlock* B)
- : ProgramEdge(S,B,StmtBlk) {}
+ BExprBlkEdge(const Stmt* S,const CFGBlock* B)
+ : ProgramEdge(S,B,BExprBlk) {}
Stmt* Src() const { return reinterpret_cast<Stmt*>(RawSrc()); }
CFGBlock* Dst() const { return reinterpret_cast<CFGBlock*>(RawDst()); }
- static bool classof(const ProgramEdge* E) { return E->getKind() == StmtBlk; }
+ static bool classof(const ProgramEdge* E) {
+ return E->getKind() == BExprBlk;
+ }
};
-class BlkStmtEdge : public ProgramEdge {
+class BlkBExprEdge : public ProgramEdge {
public:
- BlkStmtEdge(const CFGBlock* B, const Stmt* S)
- : ProgramEdge(B,S,BlkStmt) {}
+ BlkBExprEdge(const CFGBlock* B, const Stmt* S)
+ : ProgramEdge(B,S,BlkBExpr) {}
CFGBlock* Src() const { return reinterpret_cast<CFGBlock*>(RawSrc()); }
Stmt* Dst() const { return reinterpret_cast<Stmt*>(RawDst()); }
- static bool classof(const ProgramEdge* E) { return E->getKind() == StmtBlk; }
+ static bool classof(const ProgramEdge* E) {
+ return E->getKind() == BlkBExpr;
+ }
};
-class StmtStmtEdge : public ProgramEdge {
+class BExprBExprEdge : public ProgramEdge {
public:
- StmtStmtEdge(const Stmt* S1, const Stmt* S2)
- : ProgramEdge(S1,S2,StmtStmt) {}
+ BExprBExprEdge(const Stmt* S1, const Stmt* S2)
+ : ProgramEdge(S1,S2,BExprBExpr) {}
- Stmt* Src() const { return reinterpret_cast<Stmt*>(RawSrc()); }
- Stmt* Dst() const { return reinterpret_cast<Stmt*>(RawDst()); }
+ Stmt* Src() const { return reinterpret_cast<Stmt*>(RawSrc()); }
+ Stmt* Dst() const { return reinterpret_cast<Stmt*>(RawDst()); }
+
+ static bool classof(const ProgramEdge* E) {
+ return E->getKind() == BExprBExpr;
+ }
+};
+
+class BExprSExprEdge : public ProgramEdge {
+public:
+ BExprSExprEdge(const Stmt* S1, const Expr* S2)
+ : ProgramEdge(S1,S2,BExprSExpr) {}
+
+ Stmt* Src() const { return reinterpret_cast<Stmt*>(RawSrc()); }
+ Expr* Dst() const { return reinterpret_cast<Expr*>(RawDst()); }
+
+ static bool classof(const ProgramEdge* E) {
+ return E->getKind() == BExprSExpr;
+ }
+};
+
+class SExprSExprEdge : public ProgramEdge {
+public:
+ SExprSExprEdge(const Expr* S1, const Expr* S2)
+ : ProgramEdge(S1,S2,SExprSExpr) {}
+
+ Expr* Src() const { return reinterpret_cast<Expr*>(RawSrc()); }
+ Expr* Dst() const { return reinterpret_cast<Expr*>(RawDst()); }
- static bool classof(const ProgramEdge* E) { return E->getKind() == StmtStmt; }
+ static bool classof(const ProgramEdge* E) {
+ return E->getKind() == SExprSExpr;
+ }
};
+class SExprBExprEdge : public ProgramEdge {
+public:
+ SExprBExprEdge(const Expr* S1, const Stmt* S2)
+ : ProgramEdge(S1,S2,SExprBExpr) {}
+
+ Expr* Src() const { return reinterpret_cast<Expr*>(RawSrc()); }
+ Stmt* Dst() const { return reinterpret_cast<Stmt*>(RawDst()); }
+
+ static bool classof(const ProgramEdge* E) {
+ return E->getKind() == SExprBExpr;
+ }
+};
class BlkBlkEdge : public ProgramEdge {
public:
@@ -103,7 +151,9 @@ public:
CFGBlock* Src() const { return reinterpret_cast<CFGBlock*>(RawSrc()); }
CFGBlock* Dst() const { return reinterpret_cast<CFGBlock*>(RawDst()); }
- static bool classof(const ProgramEdge* E) { return E->getKind() == BlkBlk; }
+ static bool classof(const ProgramEdge* E) {
+ return E->getKind() == BlkBlk;
+ }
};
} // end namespace clang