StoreRef.h revision 341825
1//===- StoreRef.h - Smart pointer for store objects -------------*- 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 type StoreRef. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_STOREREF_H 15#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_STOREREF_H 16 17#include <cassert> 18 19namespace clang { 20namespace ento { 21 22class StoreManager; 23 24/// Store - This opaque type encapsulates an immutable mapping from 25/// locations to values. At a high-level, it represents the symbolic 26/// memory model. Different subclasses of StoreManager may choose 27/// different types to represent the locations and values. 28using Store = const void *; 29 30class StoreRef { 31 Store store; 32 StoreManager &mgr; 33 34public: 35 StoreRef(Store store, StoreManager &smgr); 36 StoreRef(const StoreRef &sr); 37 StoreRef &operator=(StoreRef const &newStore); 38 ~StoreRef(); 39 40 bool operator==(const StoreRef &x) const { 41 assert(&mgr == &x.mgr); 42 return x.store == store; 43 } 44 45 bool operator!=(const StoreRef &x) const { return !operator==(x); } 46 47 Store getStore() const { return store; } 48 const StoreManager &getStoreManager() const { return mgr; } 49}; 50 51} // namespace ento 52} // namespace clang 53 54#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_STOREREF_H 55