diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-07-22 21:39:25 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-07-22 21:39:25 +0000 |
commit | cdd4f1783da7c7565be2376d14ca6ab2625aa4b6 (patch) | |
tree | d8439d3f6502f9a44488bce66b28909c1addbf57 /include/clang/Analysis/ProgramPoint.h | |
parent | cc2c6eb04d882466c7cfbb544c251d7e0ba0f356 (diff) |
Add 'PreStmt' program point. This will be used to represent checking for
preconditions (in GRExprEngine) before the statement itself is evaluated.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76791 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Analysis/ProgramPoint.h')
-rw-r--r-- | include/clang/Analysis/ProgramPoint.h | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/include/clang/Analysis/ProgramPoint.h b/include/clang/Analysis/ProgramPoint.h index 1c6f998b9c..a22fd25f28 100644 --- a/include/clang/Analysis/ProgramPoint.h +++ b/include/clang/Analysis/ProgramPoint.h @@ -27,20 +27,21 @@ namespace clang { class ProgramPoint { public: - enum Kind { BlockEdgeKind = 0x0, - BlockEntranceKind = 0x1, - BlockExitKind = 0x2, - // Keep the following four together and in this order. - PostStmtKind = 0x3, - PostLocationChecksSucceedKind = 0x4, - PostOutOfBoundsCheckFailedKind = 0x5, - PostNullCheckFailedKind = 0x6, - PostUndefLocationCheckFailedKind = 0x7, - PostLoadKind = 0x8, - PostStoreKind = 0x9, - PostPurgeDeadSymbolsKind = 0x10, - PostStmtCustomKind = 0x11, - PostLValueKind = 0x12, + enum Kind { BlockEdgeKind, + BlockEntranceKind, + BlockExitKind, + PreStmtKind, + // Keep the following together and in this order. + PostStmtKind, + PostLocationChecksSucceedKind, + PostOutOfBoundsCheckFailedKind, + PostNullCheckFailedKind, + PostUndefLocationCheckFailedKind, + PostLoadKind, + PostStoreKind, + PostPurgeDeadSymbolsKind, + PostStmtCustomKind, + PostLValueKind, MinPostStmtKind = PostStmtKind, MaxPostStmtKind = PostLValueKind }; @@ -130,9 +131,25 @@ public: } }; +class PreStmt : public ProgramPoint { +public: + PreStmt(const Stmt *S, const void *tag, const Stmt *SubStmt = 0) + : ProgramPoint(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 { protected: - PostStmt(const Stmt* S, Kind k,const void *tag = 0) + PostStmt(const Stmt* S, Kind k, const void *tag = 0) : ProgramPoint(S, k, tag) {} PostStmt(const Stmt* S, const void* data, Kind k, const void *tag =0) |