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_ANALYSIS_GREXPRENGINE_BUILDERS
16 #define LLVM_CLANG_ANALYSIS_GREXPRENGINE_BUILDERS
17 #include "clang/Checker/PathSensitive/GRExprEngine.h"
18 #include "clang/Analysis/Support/SaveAndRestore.h"
22 class GRStmtNodeBuilderRef
{
29 const unsigned OldSize
;
30 const bool AutoCreateNode
;
31 SaveAndRestore
<bool> OldSink
;
32 SaveAndRestore
<const void*> OldTag
;
36 friend class GRExprEngine
;
38 GRStmtNodeBuilderRef(); // do not implement
39 void operator=(const GRStmtNodeBuilderRef
&); // do not implement
41 GRStmtNodeBuilderRef(ExplodedNodeSet
&dst
,
42 GRStmtNodeBuilder
&builder
,
46 const Stmt
* s
, bool auto_create_node
)
47 : Dst(dst
), B(builder
), Eng(eng
), Pred(pred
),
48 state(st
), stmt(s
), OldSize(Dst
.size()), AutoCreateNode(auto_create_node
),
49 OldSink(B
.BuildSinks
), OldTag(B
.Tag
), OldHasGen(B
.HasGeneratedNode
) {}
53 ~GRStmtNodeBuilderRef() {
54 // Handle the case where no nodes where generated. Auto-generate that
55 // contains the updated state if we aren't generating sinks.
56 if (!B
.BuildSinks
&& Dst
.size() == OldSize
&& !B
.HasGeneratedNode
) {
58 B
.MakeNode(Dst
, const_cast<Stmt
*>(stmt
), Pred
, state
);
64 const GRState
*getState() { return state
; }
66 GRStateManager
& getStateManager() {
67 return Eng
.getStateManager();
70 ExplodedNode
* MakeNode(const GRState
* state
) {
71 return B
.MakeNode(Dst
, const_cast<Stmt
*>(stmt
), Pred
, state
);
75 } // end clang namespace