clang: include/clang/AST/AbstractBasicReader.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9#ifndef LLVM_CLANG_AST_ABSTRACTBASICREADER_H
10#define LLVM_CLANG_AST_ABSTRACTBASICREADER_H
11
13#include
14
16namespace serialization {
17
18template
20 return (value ? *value : T());
21}
22
24 return value.value_or(nullptr);
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#include "clang/AST/AbstractBasicReader.inc"
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122template
124protected:
127
128public:
130
131
132
133 Impl &find(const char *propertyName) {
134 return asImpl();
135 }
136
137 template
139 return T(asImpl().readUInt32());
140 }
141
142
143
145
146 template
148 assert(buffer.empty());
149
150 uint32_t size = asImpl().readUInt32();
151 buffer.reserve(size);
152
153 for (uint32_t i = 0; i != size; ++i) {
154 buffer.push_back(ReadDispatcher::read(asImpl()));
155 }
156 return buffer;
157 }
158
159 template <class T, class... Args>
161 return UnpackOptionalValue::unpack(
162 ReadDispatcher::read(asImpl(), std::forward(args)...));
163 }
164
166 bool isUnsigned = asImpl().readBool();
167 llvm::APInt value = asImpl().readAPInt();
168 return llvm::APSInt(std::move(value), isUnsigned);
169 }
170
172 unsigned bitWidth = asImpl().readUInt32();
173 unsigned numWords = llvm::APInt::getNumWords(bitWidth);
175 for (uint32_t i = 0; i != numWords; ++i)
176 data.push_back(asImpl().readUInt64());
177 return llvm::APInt(bitWidth, numWords, &data[0]);
178 }
179
181 unsigned width = asImpl().readUInt32();
182 unsigned scale = asImpl().readUInt32();
183 unsigned tmp = asImpl().readUInt32();
184 bool isSigned = tmp & 0x1;
185 bool isSaturated = tmp & 0x2;
186 bool hasUnsignedPadding = tmp & 0x4;
187 return llvm::FixedPointSemantics(width, scale, isSigned, isSaturated,
188 hasUnsignedPadding);
189 }
190
193 auto origTy = asImpl().readQualType();
194 auto elemTy = origTy;
195 unsigned pathLength = asImpl().readUInt32();
196 for (unsigned i = 0; i < pathLength; ++i) {
197 if (elemTy->template getAs()) {
198 unsigned int_ = asImpl().readUInt32();
199 Decl *decl = asImpl().template readDeclAs();
200 if (auto *recordDecl = dyn_cast(decl))
201 elemTy = getASTContext().getRecordType(recordDecl);
202 else
203 elemTy = cast(decl)->getType();
204 path.push_back(
206 } else {
207 elemTy = getASTContext().getAsArrayType(elemTy)->getElementType();
208 path.push_back(
210 }
211 }
213 }
214
217 "update this if the value size changes");
218 uint64_t value = asImpl().readUInt64();
220 }
221
227 esi.Exceptions = asImpl().template readArray(buffer);
231 esi.SourceDecl = asImpl().readFunctionDeclRef();
234 esi.SourceDecl = asImpl().readFunctionDeclRef();
235 }
236 return esi;
237 }
238
241 <= sizeof(uint32_t),
242 "opaque value doesn't fit into uint32_t");
243 uint32_t value = asImpl().readUInt32();
244 return FunctionProtoType::ExtParameterInfo::getFromOpaqueValue(value);
245 }
246
248 uint32_t value = asImpl().readUInt32();
250 }
251
254 }
255
257 auto &ctx = getASTContext();
258
259
261
262 uint32_t depth = asImpl().readUInt32();
263 for (uint32_t i = 0; i != depth; ++i) {
264 auto kind = asImpl().readNestedNameSpecifierKind();
265 switch (kind) {
268 asImpl().readIdentifier());
269 continue;
270
273 asImpl().readNamespaceDeclRef());
274 continue;
275
278 asImpl().readNamespaceAliasDeclRef());
279 continue;
280
285 asImpl().readQualType().getTypePtr());
286 continue;
287
290 continue;
291
294 asImpl().readCXXRecordDeclRef());
295 continue;
296 }
297 llvm_unreachable("bad nested name specifier kind");
298 }
299
300 return cur;
301 }
302};
303
304}
305}
306
307#endif
static bool isUnsigned(SValBuilder &SVB, NonLoc Value)
Defines the C++ template declaration subclasses.
A non-discriminated union of a base, field, or array index.
static LValuePathEntry ArrayIndex(uint64_t Index)
llvm::PointerIntPair< const Decl *, 1, bool > BaseOrMemberType
A FieldDecl or CXXRecordDecl, along with a flag indicating whether we mean a virtual or non-virtual b...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Decl - This represents one declaration (or definition), e.g.
Wrap a function effect's condition expression in another struct so that FunctionProtoType's TrailingO...
Represents an abstract function effect, using just an enumeration describing its kind.
static FunctionEffect fromOpaqueInt32(uint32_t Value)
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
unsigned char getOpaqueValue() const
Represents a C++ nested name specifier, such as "\::std::vector::".
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, const IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.
@ NamespaceAlias
A namespace alias, stored as a NamespaceAliasDecl*.
@ TypeSpec
A type, stored as a Type*.
@ TypeSpecWithTemplate
A type that was preceded by the 'template' keyword, stored as a Type*.
@ Super
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Identifier
An identifier, stored as an IdentifierInfo*.
@ Global
The global specifier '::'. There is no stored value.
@ Namespace
A namespace, stored as a NamespaceDecl*.
static NestedNameSpecifier * SuperSpecifier(const ASTContext &Context, CXXRecordDecl *RD)
Returns the nested name specifier representing the __super scope for the given CXXRecordDecl.
The collection of all-type qualifiers we support.
uint64_t getAsOpaqueValue() const
static Qualifiers fromOpaqueValue(uint64_t opaque)
DataStreamBasicReader provides convenience implementations for many BasicReader methods based on the ...
FunctionProtoType::ExceptionSpecInfo readExceptionSpecInfo(llvm::SmallVectorImpl< QualType > &buffer)
FunctionProtoType::ExtParameterInfo readExtParameterInfo()
APValue::LValuePathSerializationHelper readLValuePathSerializationHelper(SmallVectorImpl< APValue::LValuePathEntry > &path)
llvm::APSInt readAPSInt()
DataStreamBasicReader(ASTContext &ctx)
EffectConditionExpr readEffectConditionExpr()
Qualifiers readQualifiers()
FunctionEffect readFunctionEffect()
std::optional< T > readOptional(Args &&...args)
llvm::ArrayRef< T > readArray(llvm::SmallVectorImpl< T > &buffer)
Impl & find(const char *propertyName)
Implement property-find by ignoring it.
NestedNameSpecifier * readNestedNameSpecifier()
llvm::FixedPointSemantics readFixedPointSemantics()
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, RecordDecl > recordDecl
Matches class, struct, and union declarations.
T * makePointerFromOptional(std::optional< T * > value)
T makeNullableFromOptional(const std::optional< T > &value)
The JSON file list parser is used to communicate input to InstallAPI.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
const FunctionProtoType * T
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_Uninstantiated
not instantiated yet
@ EST_Unevaluated
not evaluated yet, for special member function
@ EST_Dynamic
throw(T1, T2)
Holds information about the various types of exception specification.
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
ExceptionSpecificationType Type
The kind of exception specification this is.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.