clang: include/clang/Analysis/FlowSensitive/StorageLocation.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_STORAGELOCATION_H
15#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_STORAGELOCATION_H
16
19#include "llvm/ADT/DenseMap.h"
20#include "llvm/Support/Debug.h"
21#include
22
23#define DEBUG_TYPE "dataflow"
24
26namespace dataflow {
27
28
29
30
31
33public:
37 };
38
41 }
42
43
44
45
48
50
52
54
55private:
58};
59
60
61
63public:
66
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
95public:
96 using FieldToLoc = llvm::DenseMap<const ValueDecl *, StorageLocation *>;
98
102 SyntheticFields(std::move(TheSyntheticFields)) {
103 assert(.isNull());
105 assert([this] {
106 for (auto [Field, Loc] : Children) {
107 if (!Field->getType()->isReferenceType() && Loc == nullptr)
108 return false;
109 }
110 return true;
111 }());
112 }
113
116 }
117
118
119
120
121
122
123
124
126 auto It = Children.find(&D);
127 LLVM_DEBUG({
128 if (It == Children.end()) {
129 llvm::dbgs() << "Couldn't find child " << D.getNameAsString()
130 << " on StorageLocation " << this << " of type "
131 << getType() << "\n";
132 llvm::dbgs() << "Existing children:\n";
133 for ([[maybe_unused]] auto [Field, Loc] : Children) {
134 llvm::dbgs() << Field->getNameAsString() << "\n";
135 }
136 }
137 });
138 assert(It != Children.end());
139 return It->second;
140 }
141
142
143
146 assert(Loc != nullptr);
147 return *Loc;
148 }
149
150 llvm::iterator_rangeSyntheticFieldMap::const\_iterator
152 return {SyntheticFields.begin(), SyntheticFields.end()};
153 }
154
155
156
157
158
159
160
161
163 assert(D.getType()->isReferenceType());
165 }
166
167 llvm::iterator_rangeFieldToLoc::const\_iterator children() const {
168 return {Children.begin(), Children.end()};
169 }
170
171private:
172 FieldToLoc Children;
173 SyntheticFieldMap SyntheticFields;
174};
175
176}
177}
178
179#undef DEBUG_TYPE
180
181#endif
llvm::MachO::Record Record
C Language Family Type Representation.
A (possibly-)qualified type.
The base class of the type hierarchy.
bool isReferenceType() const
bool isRecordType() const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
A storage location for a record (struct, class, or union).
llvm::iterator_range< SyntheticFieldMap::const_iterator > synthetic_fields() const
StorageLocation * getChild(const ValueDecl &D) const
Returns the child storage location for D.
llvm::DenseMap< const ValueDecl *, StorageLocation * > FieldToLoc
llvm::StringMap< StorageLocation * > SyntheticFieldMap
RecordStorageLocation(QualType Type, FieldToLoc TheChildren, SyntheticFieldMap TheSyntheticFields)
void setChild(const ValueDecl &D, StorageLocation *Loc)
Changes the child storage location for a field D of reference type.
StorageLocation & getSyntheticField(llvm::StringRef Name) const
Returns the storage location for the synthetic field Name.
static bool classof(const StorageLocation *Loc)
llvm::iterator_range< FieldToLoc::const_iterator > children() const
A storage location that is not subdivided further for the purposes of abstract interpretation.
ScalarStorageLocation(QualType Type)
static bool classof(const StorageLocation *Loc)
Base class for elements of the local variable store and of the heap.
virtual ~StorageLocation()=default
StorageLocation(Kind LocKind, QualType Type)
StorageLocation & operator=(const StorageLocation &)=delete
StorageLocation(const StorageLocation &)=delete
The JSON file list parser is used to communicate input to InstallAPI.