aboutsummaryrefslogtreecommitdiff
path: root/include/clang
diff options
context:
space:
mode:
authorJordy Rose <jediknil@belkadan.com>2010-08-04 07:10:57 +0000
committerJordy Rose <jediknil@belkadan.com>2010-08-04 07:10:57 +0000
commit72905cfa81cfd126f322c4173f56d332aac5539e (patch)
tree48feba9b40a8b9db70444a94f7e0f256745b4d84 /include/clang
parent5fcefd965990899b9093656a5242be5a273d7135 (diff)
Change the checker callback cache in GRExprEngine to be more compact (and IMHO a little easier to understand), and add the same sort of caching for EvalAssume (tied for least-used callback), mostly as proof-of-concept.
Before we go further with these, we should figure out a way to reuse the visit-and-cache code in CheckerVisit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110191 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang')
-rw-r--r--include/clang/Checker/PathSensitive/Checker.h3
-rw-r--r--include/clang/Checker/PathSensitive/GRExprEngine.h23
2 files changed, 21 insertions, 5 deletions
diff --git a/include/clang/Checker/PathSensitive/Checker.h b/include/clang/Checker/PathSensitive/Checker.h
index d254071bdf..1c9f85b937 100644
--- a/include/clang/Checker/PathSensitive/Checker.h
+++ b/include/clang/Checker/PathSensitive/Checker.h
@@ -279,7 +279,8 @@ public:
}
virtual const GRState *EvalAssume(const GRState *state, SVal Cond,
- bool Assumption) {
+ bool Assumption, bool *respondsToCallback) {
+ *respondsToCallback = false;
return state;
}
diff --git a/include/clang/Checker/PathSensitive/GRExprEngine.h b/include/clang/Checker/PathSensitive/GRExprEngine.h
index ffdf9de049..f7b7d7012a 100644
--- a/include/clang/Checker/PathSensitive/GRExprEngine.h
+++ b/include/clang/Checker/PathSensitive/GRExprEngine.h
@@ -75,10 +75,25 @@ class GRExprEngine : public GRSubEngine {
llvm::OwningPtr<GRSimpleAPICheck> BatchAuditor;
+ enum CallbackKind {
+ PreVisitStmtCallback,
+ PostVisitStmtCallback,
+ ProcessAssumeCallback
+ };
+
+ typedef uint32_t CallbackTag;
+
+ /// GetCallbackTag - Create a tag for a certain kind of callback. The 'Sub'
+ /// argument can be used to differentiate callbacks that depend on another
+ /// value from a small set of possibilities, such as statement classes.
+ static inline CallbackTag GetCallbackTag(CallbackKind K, uint32_t Sub = 0) {
+ assert(Sub == ((Sub << 8) >> 8) && "Tag sub-kind must fit into 24 bits");
+ return K | (Sub << 8);
+ }
+
typedef llvm::DenseMap<void *, unsigned> CheckerMap;
typedef std::vector<std::pair<void *, Checker*> > CheckersOrdered;
- typedef llvm::DenseMap<std::pair<unsigned, unsigned>, CheckersOrdered *>
- CheckersOrderedCache;
+ typedef llvm::DenseMap<CallbackTag, CheckersOrdered *> CheckersOrderedCache;
/// A registration map from checker tag to the index into the
/// ordered checkers vector.
@@ -89,7 +104,7 @@ class GRExprEngine : public GRSubEngine {
CheckersOrdered Checkers;
/// A map used for caching the checkers that respond to the callback for
- /// a particular statement and visitation order.
+ /// a particular callback tag.
CheckersOrderedCache COCache;
/// The BugReporter associated with this engine. It is important that
@@ -258,7 +273,7 @@ public:
/// CheckerVisit - Dispatcher for performing checker-specific logic
/// at specific statements.
void CheckerVisit(const Stmt *S, ExplodedNodeSet &Dst, ExplodedNodeSet &Src,
- bool isPrevisit);
+ CallbackKind Kind);
bool CheckerEvalCall(const CallExpr *CE,
ExplodedNodeSet &Dst,