Implicitly expand argument packs when performing template argument
[clang.git] / include / clang / Checker / PathSensitive / Environment.h
bloba2b3567a4ff764dcca0f081156c899a4086b44a7
1 //== Environment.h - Map from Stmt* to Locations/Values ---------*- C++ -*--==//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defined the Environment and EnvironmentManager classes.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_ANALYSIS_ENVIRONMENT_H
15 #define LLVM_CLANG_ANALYSIS_ENVIRONMENT_H
17 #include "clang/Checker/PathSensitive/Store.h"
18 #include "clang/Checker/PathSensitive/SVals.h"
19 #include "llvm/ADT/ImmutableMap.h"
21 namespace clang {
23 class EnvironmentManager;
24 class SValBuilder;
25 class LiveVariables;
27 /// Environment - An immutable map from Stmts to their current
28 /// symbolic values (SVals).
29 ///
30 class Environment {
31 private:
32 friend class EnvironmentManager;
34 // Type definitions.
35 typedef llvm::ImmutableMap<const Stmt*,SVal> BindingsTy;
37 // Data.
38 BindingsTy ExprBindings;
40 Environment(BindingsTy eb)
41 : ExprBindings(eb) {}
43 SVal lookupExpr(const Stmt* E) const;
45 public:
46 typedef BindingsTy::iterator iterator;
47 iterator begin() const { return ExprBindings.begin(); }
48 iterator end() const { return ExprBindings.end(); }
51 /// GetSVal - Fetches the current binding of the expression in the
52 /// Environment.
53 SVal getSVal(const Stmt* Ex, SValBuilder& svalBuilder) const;
55 /// Profile - Profile the contents of an Environment object for use
56 /// in a FoldingSet.
57 static void Profile(llvm::FoldingSetNodeID& ID, const Environment* env) {
58 env->ExprBindings.Profile(ID);
61 /// Profile - Used to profile the contents of this object for inclusion
62 /// in a FoldingSet.
63 void Profile(llvm::FoldingSetNodeID& ID) const {
64 Profile(ID, this);
67 bool operator==(const Environment& RHS) const {
68 return ExprBindings == RHS.ExprBindings;
72 class EnvironmentManager {
73 private:
74 typedef Environment::BindingsTy::Factory FactoryTy;
75 FactoryTy F;
77 public:
78 EnvironmentManager(llvm::BumpPtrAllocator& Allocator) : F(Allocator) {}
79 ~EnvironmentManager() {}
81 Environment getInitialEnvironment() {
82 return Environment(F.getEmptyMap());
85 /// Bind the value 'V' to the statement 'S'.
86 Environment bindExpr(Environment Env, const Stmt *S, SVal V,
87 bool Invalidate);
89 /// Bind the location 'location' and value 'V' to the statement 'S'. This
90 /// is used when simulating loads/stores.
91 Environment bindExprAndLocation(Environment Env, const Stmt *S, SVal location,
92 SVal V);
94 Environment RemoveDeadBindings(Environment Env,
95 SymbolReaper &SymReaper, const GRState *ST,
96 llvm::SmallVectorImpl<const MemRegion*>& RegionRoots);
99 } // end clang namespace
101 #endif