summaryrefslogtreecommitdiffstats
path: root/include/clang/Analysis/PathSensitive/ValueManager.h
blob: 89af975de7af1ae6615a9050a0abaa41f67a1e9c (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
//== ValueManager.h - Aggregate manager of symbols and SVals ----*- 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 ValueManager, a class that manages symbolic values
//  and SVals created for use by GRExprEngine and related classes.  It
//  wraps SymbolManager, MemRegionManager, and BasicValueFactory.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_ANALYSIS_AGGREGATE_VALUE_MANAGER_H
#define LLVM_CLANG_ANALYSIS_AGGREGATE_VALUE_MANAGER_H

#include "clang/Analysis/PathSensitive/MemRegion.h"
#include "clang/Analysis/PathSensitive/SVals.h"
#include "clang/Analysis/PathSensitive/BasicValueFactory.h"
#include "clang/Analysis/PathSensitive/SymbolManager.h"

namespace llvm { class BumpPtrAllocator; }

namespace clang {  
class ValueManager {

  ASTContext &Context;  
  BasicValueFactory BasicVals;
  
  /// SymMgr - Object that manages the symbol information.
  SymbolManager SymMgr;


  MemRegionManager MemMgr;
  
public:
  ValueManager(llvm::BumpPtrAllocator &alloc, ASTContext &context)
               : Context(context), BasicVals(Context, alloc),
                 SymMgr(Context, BasicVals, alloc),
                 MemMgr(alloc) {}

  // Accessors to submanagers.
  
  ASTContext &getContext() { return Context; }
  const ASTContext &getContext() const { return Context; }
  
  BasicValueFactory &getBasicValueFactory() { return BasicVals; }
  const BasicValueFactory &getBasicValueFactory() const { return BasicVals; }
  
  SymbolManager &getSymbolManager() { return SymMgr; }
  const SymbolManager &getSymbolManager() const { return SymMgr; }

  MemRegionManager &getRegionManager() { return MemMgr; }
  const MemRegionManager &getRegionManager() const { return MemMgr; }
  
  // Forwarding methods to SymbolManager.
  
  const SymbolConjured* getConjuredSymbol(const Stmt* E, QualType T,
                                          unsigned VisitCount,
                                          const void* SymbolTag = 0) {
    return SymMgr.getConjuredSymbol(E, T, VisitCount, SymbolTag);
  }
  
  const SymbolConjured* getConjuredSymbol(const Expr* E, unsigned VisitCount,
                                          const void* SymbolTag = 0) {    
    return SymMgr.getConjuredSymbol(E, VisitCount, SymbolTag);
  }
  
  // Aggregation methods that use multiple submanagers.
  
  Loc makeRegionVal(SymbolRef Sym) {
    return Loc::MakeVal(MemMgr.getSymbolicRegion(Sym));
  }
  
  /// makeZeroVal - Construct an SVal representing '0' for the specified type.
  SVal makeZeroVal(QualType T);
  /// makeZeroArrayIndex - Construct an SVal representing '0' index for array
  /// elements.
  SVal makeZeroArrayIndex();

  /// GetRegionValueSymbolVal - make a unique symbol for value of R.
  SVal getRegionValueSymbolVal(const MemRegion* R);
  
  SVal getConjuredSymbolVal(const Expr *E, unsigned Count);  
  SVal getConjuredSymbolVal(const Expr* E, QualType T, unsigned Count);

  SVal getFunctionPointer(const FunctionDecl* FD);
  
  NonLoc makeNonLoc(SymbolRef sym);
  
  NonLoc makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op,
                    const llvm::APSInt& rhs, QualType T);
  
  NonLoc makeNonLoc(const SymExpr *lhs, BinaryOperator::Opcode op,
                    const SymExpr *rhs, QualType T);
  
  NonLoc makeTruthVal(bool b, QualType T);
};
} // end clang namespace
#endif

OpenPOWER on IntegriCloud