summaryrefslogtreecommitdiffstats
path: root/include/clang/Checker/PathSensitive/GRSubEngine.h
blob: 1904835fbc34c09b27003f34f7b90235dfb1a68f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//== GRSubEngine.h - Interface of the subengine of GRCoreEngine ----*- C++ -*-//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the interface of a subengine of the GRCoreEngine.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_ANALYSIS_GRSUBENGINE_H
#define LLVM_CLANG_ANALYSIS_GRSUBENGINE_H

#include "clang/Checker/PathSensitive/SVals.h"

namespace clang {

class AnalysisManager;
class CFGBlock;
class CFGElement;
class ExplodedNode;
class GRState;
class GRStateManager;
class GRBlockCounter;
class GRStmtNodeBuilder;
class GRBranchNodeBuilder;
class GRIndirectGotoNodeBuilder;
class GRSwitchNodeBuilder;
class GREndPathNodeBuilder;
class GRCallEnterNodeBuilder;
class GRCallExitNodeBuilder;
class LocationContext;
class MemRegion;
class Stmt;

class GRSubEngine {
public:
  virtual ~GRSubEngine() {}

  virtual const GRState* getInitialState(const LocationContext *InitLoc) = 0;

  virtual AnalysisManager &getAnalysisManager() = 0;

  virtual GRStateManager &getStateManager() = 0;

  /// Called by GRCoreEngine. Used to generate new successor
  /// nodes by processing the 'effects' of a block-level statement.
  virtual void ProcessStmt(const CFGElement E, GRStmtNodeBuilder& builder) = 0;

  /// Called by GRCoreEngine when start processing
  /// a CFGBlock.  This method returns true if the analysis should continue
  /// exploring the given path, and false otherwise.
  virtual bool ProcessBlockEntrance(const CFGBlock* B, const ExplodedNode *Pred,
                                    GRBlockCounter BC) = 0;

  /// Called by GRCoreEngine.  Used to generate successor
  ///  nodes by processing the 'effects' of a branch condition.
  virtual void ProcessBranch(const Stmt* Condition, const Stmt* Term,
                             GRBranchNodeBuilder& builder) = 0;

  /// Called by GRCoreEngine.  Used to generate successor
  /// nodes by processing the 'effects' of a computed goto jump.
  virtual void ProcessIndirectGoto(GRIndirectGotoNodeBuilder& builder) = 0;

  /// Called by GRCoreEngine.  Used to generate successor
  /// nodes by processing the 'effects' of a switch statement.
  virtual void ProcessSwitch(GRSwitchNodeBuilder& builder) = 0;

  /// ProcessEndPath - Called by GRCoreEngine.  Used to generate end-of-path
  ///  nodes when the control reaches the end of a function.
  virtual void ProcessEndPath(GREndPathNodeBuilder& builder) = 0;

  // Generate the entry node of the callee.
  virtual void ProcessCallEnter(GRCallEnterNodeBuilder &builder) = 0;

  // Generate the first post callsite node.
  virtual void ProcessCallExit(GRCallExitNodeBuilder &builder) = 0;

  /// Called by ConstraintManager. Used to call checker-specific
  /// logic for handling assumptions on symbolic values.
  virtual const GRState* ProcessAssume(const GRState *state,
                                       SVal cond, bool assumption) = 0;

  /// WantsRegionChangeUpdate - Called by GRStateManager to determine if a
  ///  region change should trigger a ProcessRegionChanges update.
  virtual bool WantsRegionChangeUpdate(const GRState* state) = 0;

  /// ProcessRegionChanges - Called by GRStateManager whenever a change is made
  ///  to the store. Used to update checkers that track region values.
  virtual const GRState* ProcessRegionChanges(const GRState* state,
                                              const MemRegion* const *Begin,
                                              const MemRegion* const *End) = 0;

  inline const GRState* ProcessRegionChange(const GRState* state,
                                            const MemRegion* MR) {
    return ProcessRegionChanges(state, &MR, &MR+1);
  }

  /// Called by GRCoreEngine when the analysis worklist is either empty or the
  //  maximum number of analysis steps have been reached.
  virtual void ProcessEndWorklist(bool hasWorkRemaining) = 0;
};
}

#endif
OpenPOWER on IntegriCloud