aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Analysis/ProgramPoint.h
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-07-22 22:35:28 +0000
committerTed Kremenek <kremenek@apple.com>2009-07-22 22:35:28 +0000
commit5f85e17df3f5b0a8021443f2b590daecfb2cbd17 (patch)
tree27f50e167a2cf236ee16a7aadc89b330a62389a1 /include/clang/Analysis/ProgramPoint.h
parentde99a45c1295ec8e2eea20d35906178ff10722b5 (diff)
Refactor 'PostStmt' and 'PreStmt' to subclass a common parent 'StmtPoint'.
Educate GRExprEngine::VisitGraph() about 'PreStmt'. Mark the constructor of 'PostStmt' to be explicit, preventing implicit conversions and the selection of the wrong 'generateNode' method in GRStmtNodeBuilder. Constify a bunch of arguments, which falls out of the changes to ProgramPoint. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76809 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Analysis/ProgramPoint.h')
-rw-r--r--include/clang/Analysis/ProgramPoint.h41
1 files changed, 24 insertions, 17 deletions
diff --git a/include/clang/Analysis/ProgramPoint.h b/include/clang/Analysis/ProgramPoint.h
index a22fd25f28..8951e83a7c 100644
--- a/include/clang/Analysis/ProgramPoint.h
+++ b/include/clang/Analysis/ProgramPoint.h
@@ -130,40 +130,47 @@ public:
return Location->getKind() == BlockExitKind;
}
};
+
+class StmtPoint : public ProgramPoint {
+public:
+ StmtPoint(const Stmt *S, const void *p2, Kind k, const void *tag)
+ : ProgramPoint(S, p2, k, tag) {}
+
+ const Stmt *getStmt() const { return (const Stmt*) getData1(); }
+
+ template <typename T>
+ const T* getStmtAs() const { return llvm::dyn_cast<T>(getStmt()); }
+
+ static bool classof(const ProgramPoint* Location) {
+ unsigned k = Location->getKind();
+ return k >= PreStmtKind && k <= MaxPostStmtKind;
+ }
+};
-class PreStmt : public ProgramPoint {
+
+class PreStmt : public StmtPoint {
public:
PreStmt(const Stmt *S, const void *tag, const Stmt *SubStmt = 0)
- : ProgramPoint(S, SubStmt, PreStmtKind, tag) {}
+ : StmtPoint(S, SubStmt, PreStmtKind, tag) {}
- const Stmt *getStmt() const { return (const Stmt*) getData1(); }
const Stmt *getSubStmt() const { return (const Stmt*) getData2(); }
- template <typename T>
- const T* getStmtAs() const { return llvm::dyn_cast<T>(getStmt()); }
-
static bool classof(const ProgramPoint* Location) {
return Location->getKind() == PreStmtKind;
}
};
-class PostStmt : public ProgramPoint {
+class PostStmt : public StmtPoint {
protected:
PostStmt(const Stmt* S, Kind k, const void *tag = 0)
- : ProgramPoint(S, k, tag) {}
+ : StmtPoint(S, NULL, k, tag) {}
PostStmt(const Stmt* S, const void* data, Kind k, const void *tag =0)
- : ProgramPoint(S, data, k, tag) {}
+ : StmtPoint(S, data, k, tag) {}
public:
- PostStmt(const Stmt* S, const void *tag = 0)
- : ProgramPoint(S, PostStmtKind, tag) {}
-
-
- Stmt* getStmt() const { return (Stmt*) getData1(); }
-
- template <typename T>
- T* getStmtAs() const { return llvm::dyn_cast<T>(getStmt()); }
+ explicit PostStmt(const Stmt* S, const void *tag = 0)
+ : StmtPoint(S, NULL, PostStmtKind, tag) {}
static bool classof(const ProgramPoint* Location) {
unsigned k = Location->getKind();