1 //===-- ExprEngineBuilders.h - "Builder" classes for ExprEngine ---*- C++ -*-=//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines smart builder "references" which are used to marshal
11 // builders between ExprEngine objects and their related components.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CLANG_GR_EXPRENGINE_BUILDERS
16 #define LLVM_CLANG_GR_EXPRENGINE_BUILDERS
17 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
18 #include "clang/Analysis/Support/SaveAndRestore.h"
24 class StmtNodeBuilderRef {
29 const ProgramState *state;
31 const unsigned OldSize;
32 const bool AutoCreateNode;
33 SaveAndRestore<bool> OldSink;
37 friend class ExprEngine;
39 StmtNodeBuilderRef(); // do not implement
40 void operator=(const StmtNodeBuilderRef&); // do not implement
42 StmtNodeBuilderRef(ExplodedNodeSet &dst,
43 StmtNodeBuilder &builder,
46 const ProgramState *st,
47 const Stmt *s, bool auto_create_node)
48 : Dst(dst), B(builder), Eng(eng), Pred(pred),
49 state(st), stmt(s), OldSize(Dst.size()), AutoCreateNode(auto_create_node),
50 OldSink(B.BuildSinks), OldHasGen(B.hasGeneratedNode) {}
54 ~StmtNodeBuilderRef() {
55 // Handle the case where no nodes where generated. Auto-generate that
56 // contains the updated state if we aren't generating sinks.
57 if (!B.BuildSinks && Dst.size() == OldSize && !B.hasGeneratedNode) {
59 B.MakeNode(Dst, const_cast<Stmt*>(stmt), Pred, state);
65 const ProgramState *getState() { return state; }
67 ProgramStateManager& getStateManager() {
68 return Eng.getStateManager();
71 ExplodedNode *MakeNode(const ProgramState *state) {
72 return B.MakeNode(Dst, const_cast<Stmt*>(stmt), Pred, state);
78 } // end clang namespace