summaryrefslogtreecommitdiff
path: root/include/clang/Analysis/PathSensitive/GRExprEngineBuilders.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/Analysis/PathSensitive/GRExprEngineBuilders.h')
-rw-r--r--include/clang/Analysis/PathSensitive/GRExprEngineBuilders.h55
1 files changed, 16 insertions, 39 deletions
diff --git a/include/clang/Analysis/PathSensitive/GRExprEngineBuilders.h b/include/clang/Analysis/PathSensitive/GRExprEngineBuilders.h
index 0f3a1372a0f04..60db406cd13df 100644
--- a/include/clang/Analysis/PathSensitive/GRExprEngineBuilders.h
+++ b/include/clang/Analysis/PathSensitive/GRExprEngineBuilders.h
@@ -15,38 +15,15 @@
#ifndef LLVM_CLANG_ANALYSIS_GREXPRENGINE_BUILDERS
#define LLVM_CLANG_ANALYSIS_GREXPRENGINE_BUILDERS
#include "clang/Analysis/PathSensitive/GRExprEngine.h"
+#include "clang/Analysis/Support/SaveAndRestore.h"
namespace clang {
-
-
-// SaveAndRestore - A utility class that uses RAII to save and restore
-// the value of a variable.
-template<typename T>
-struct SaveAndRestore {
- SaveAndRestore(T& x) : X(x), old_value(x) {}
- ~SaveAndRestore() { X = old_value; }
- T get() { return old_value; }
-private:
- T& X;
- T old_value;
-};
-
-// SaveOr - Similar to SaveAndRestore. Operates only on bools; the old
-// value of a variable is saved, and during the dstor the old value is
-// or'ed with the new value.
-struct SaveOr {
- SaveOr(bool& x) : X(x), old_value(x) { x = false; }
- ~SaveOr() { X |= old_value; }
-private:
- bool& X;
- const bool old_value;
-};
class GRStmtNodeBuilderRef {
- GRExprEngine::NodeSet &Dst;
- GRExprEngine::StmtNodeBuilder &B;
+ ExplodedNodeSet &Dst;
+ GRStmtNodeBuilder &B;
GRExprEngine& Eng;
- GRExprEngine::NodeTy* Pred;
+ ExplodedNode* Pred;
const GRState* state;
const Stmt* stmt;
const unsigned OldSize;
@@ -57,25 +34,25 @@ class GRStmtNodeBuilderRef {
private:
friend class GRExprEngine;
-
+
GRStmtNodeBuilderRef(); // do not implement
void operator=(const GRStmtNodeBuilderRef&); // do not implement
-
- GRStmtNodeBuilderRef(GRExprEngine::NodeSet &dst,
- GRExprEngine::StmtNodeBuilder &builder,
+
+ GRStmtNodeBuilderRef(ExplodedNodeSet &dst,
+ GRStmtNodeBuilder &builder,
GRExprEngine& eng,
- GRExprEngine::NodeTy* pred,
+ ExplodedNode* pred,
const GRState *st,
const Stmt* s, bool auto_create_node)
: Dst(dst), B(builder), Eng(eng), Pred(pred),
state(st), stmt(s), OldSize(Dst.size()), AutoCreateNode(auto_create_node),
OldSink(B.BuildSinks), OldTag(B.Tag), OldHasGen(B.HasGeneratedNode) {}
-
+
public:
~GRStmtNodeBuilderRef() {
// Handle the case where no nodes where generated. Auto-generate that
- // contains the updated state if we aren't generating sinks.
+ // contains the updated state if we aren't generating sinks.
if (!B.BuildSinks && Dst.size() == OldSize && !B.HasGeneratedNode) {
if (AutoCreateNode)
B.MakeNode(Dst, const_cast<Stmt*>(stmt), Pred, state);
@@ -85,14 +62,14 @@ public:
}
const GRState *getState() { return state; }
-
+
GRStateManager& getStateManager() {
return Eng.getStateManager();
}
-
- GRExprEngine::NodeTy* MakeNode(const GRState* state) {
- return B.MakeNode(Dst, const_cast<Stmt*>(stmt), Pred, state);
- }
+
+ ExplodedNode* MakeNode(const GRState* state) {
+ return B.MakeNode(Dst, const_cast<Stmt*>(stmt), Pred, state);
+ }
};
} // end clang namespace