1 //===-- GRExprEngineBuilders.h - "Builder" classes for GRExprEngine -*- 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 GRExprEngine objects and their related components.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CLANG_GR_GREXPRENGINE_BUILDERS
16 #define LLVM_CLANG_GR_GREXPRENGINE_BUILDERS
17 #include "clang/GR/PathSensitive/GRExprEngine.h"
18 #include "clang/Analysis/Support/SaveAndRestore.h"
24 class GRStmtNodeBuilderRef
{
31 const unsigned OldSize
;
32 const bool AutoCreateNode
;
33 SaveAndRestore
<bool> OldSink
;
34 SaveAndRestore
<const void*> OldTag
;
38 friend class GRExprEngine
;
40 GRStmtNodeBuilderRef(); // do not implement
41 void operator=(const GRStmtNodeBuilderRef
&); // do not implement
43 GRStmtNodeBuilderRef(ExplodedNodeSet
&dst
,
44 GRStmtNodeBuilder
&builder
,
48 const Stmt
* s
, bool auto_create_node
)
49 : Dst(dst
), B(builder
), Eng(eng
), Pred(pred
),
50 state(st
), stmt(s
), OldSize(Dst
.size()), AutoCreateNode(auto_create_node
),
51 OldSink(B
.BuildSinks
), OldTag(B
.Tag
), OldHasGen(B
.HasGeneratedNode
) {}
55 ~GRStmtNodeBuilderRef() {
56 // Handle the case where no nodes where generated. Auto-generate that
57 // contains the updated state if we aren't generating sinks.
58 if (!B
.BuildSinks
&& Dst
.size() == OldSize
&& !B
.HasGeneratedNode
) {
60 B
.MakeNode(Dst
, const_cast<Stmt
*>(stmt
), Pred
, state
);
66 const GRState
*getState() { return state
; }
68 GRStateManager
& getStateManager() {
69 return Eng
.getStateManager();
72 ExplodedNode
* MakeNode(const GRState
* state
) {
73 return B
.MakeNode(Dst
, const_cast<Stmt
*>(stmt
), Pred
, state
);
79 } // end clang namespace