1//===- StoreRef.h - Smart pointer for store objects -------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defined the type StoreRef.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_STOREREF_H
14#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_STOREREF_H
15
16#include <cassert>
17
18namespace clang {
19namespace ento {
20
21class StoreManager;
22
23/// Store - This opaque type encapsulates an immutable mapping from
24/// locations to values. At a high-level, it represents the symbolic
25/// memory model. Different subclasses of StoreManager may choose
26/// different types to represent the locations and values.
27using Store = const void *;
28
29class StoreRef {
30 Store store;
31 StoreManager &mgr;
32
33public:
34 StoreRef(Store store, StoreManager &smgr);
35 StoreRef(const StoreRef &sr);
36 StoreRef &operator=(StoreRef const &newStore);
37 ~StoreRef();
38
39 bool operator==(const StoreRef &x) const {
40 assert(&mgr == &x.mgr);
41 return x.store == store;
42 }
43
44 bool operator!=(const StoreRef &x) const { return !operator==(x); }
45
46 Store getStore() const { return store; }
47 const StoreManager &getStoreManager() const { return mgr; }
48};
49
50} // namespace ento
51} // namespace clang
52
53#endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_STOREREF_H
54

source code of clang/include/clang/StaticAnalyzer/Core/PathSensitive/StoreRef.h