clang: include/clang/AST/AbstractBasicWriter.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9#ifndef LLVM_CLANG_AST_ABSTRACTBASICWRITER_H
10#define LLVM_CLANG_AST_ABSTRACTBASICWRITER_H
11
14#include
15
18
19template
21 return (value.isNull() ? std::optional() : std::optional(value));
22}
23
25 return (value ? std::optional<T *>(value) : std::optional<T *>());
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#include "clang/AST/AbstractBasicWriter.inc"
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119template
121protected:
122 using BasicWriterBase::asImpl;
124
125public:
126
127
128 Impl &find(const char *propertyName) {
129 return asImpl();
130 }
131
132
133
135
136 template
138 asImpl().writeUInt32(uint32_t(value));
139 }
140
142 asImpl().writeUInt32(array.size());
143 for (const T &elt : array) {
144 WriteDispatcher::write(asImpl(), elt);
145 }
146 }
147
148 template void writeOptional(std::optional value) {
149 WriteDispatcher::write(asImpl(), PackOptionalValue::pack(value));
150 }
151
153 asImpl().writeBool(value.isUnsigned());
154 asImpl().writeAPInt(value);
155 }
156
158 asImpl().writeUInt32(value.getBitWidth());
159 const uint64_t *words = value.getRawData();
160 for (size_t i = 0, e = value.getNumWords(); i != e; ++i)
161 asImpl().writeUInt64(words[i]);
162 }
163
165 asImpl().writeUInt32(sema.getWidth());
166 asImpl().writeUInt32(sema.getScale());
167 asImpl().writeUInt32(sema.isSigned() | sema.isSaturated() << 1 |
168 sema.hasUnsignedPadding() << 2);
169 }
170
175 asImpl().writeQualType(elemTy);
176 asImpl().writeUInt32(path.size());
177 auto &ctx = ((BasicWriterBase *)this)->getASTContext();
178 for (auto elem : path) {
180 asImpl().writeUInt32(elem.getAsBaseOrMember().getInt());
181 const Decl *baseOrMember = elem.getAsBaseOrMember().getPointer();
182 if (const auto *recordDecl = dyn_cast(baseOrMember)) {
184 elemTy = ctx.getCanonicalTagType(recordDecl);
185 } else {
187 asImpl().writeDeclRef(valueDecl);
189 }
190 } else {
191 asImpl().writeUInt32(elem.getAsArrayIndex());
192 elemTy = ctx.getAsArrayType(elemTy)->getElementType();
193 }
194 }
195 }
196
198 static_assert(sizeof(value.getAsOpaqueValue()) <= sizeof(uint64_t),
199 "update this if the value size changes");
201 }
202
205 asImpl().writeUInt32(uint32_t(esi.Type));
211 asImpl().writeDeclRef(esi.SourceDecl);
214 asImpl().writeDeclRef(esi.SourceDecl);
215 }
216 }
217
219 static_assert(sizeof(epi.getOpaqueValue()) <= sizeof(uint32_t),
220 "opaque value doesn't fit into uint32_t");
222 }
223
227
231
233
234
236
237
238 while (NNS) {
239 nestedNames.push_back(NNS);
242 : std::nullopt;
243 }
244
245 asImpl().writeUInt32(nestedNames.size());
246 while (!nestedNames.empty()) {
247 NNS = nestedNames.pop_back_val();
249 asImpl().writeNestedNameSpecifierKind(kind);
250 switch (kind) {
252 asImpl().writeNamespaceBaseDeclRef(
254 continue;
257 continue;
258
260
261 continue;
262
265 continue;
266
268 llvm_unreachable("unexpected null nested name specifier");
269 }
270 llvm_unreachable("bad nested name specifier kind");
271 }
272 }
273};
274
275}
276}
277
278#endif
Defines the clang::ASTContext interface.
Defines the C++ template declaration subclasses.
ArrayRef< LValuePathEntry > Path
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...
Expr * getCondition() const
Represents an abstract function effect, using just an enumeration describing its kind.
uint32_t toOpaqueInt32() const
For serialization.
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::".
CXXRecordDecl * getAsMicrosoftSuper() const
NamespaceAndPrefix getAsNamespaceAndPrefix() const
const Type * getAsType() const
Kind
The kind of specifier that completes this nested name specifier.
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Type
A type, stored as a Type*.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
A (possibly-)qualified type.
The collection of all-type qualifiers we support.
uint64_t getAsOpaqueValue() const
bool isRecordType() const
void writeEffectConditionExpr(EffectConditionExpr CE)
Definition AbstractBasicWriter.h:228
void writeExceptionSpecInfo(const FunctionProtoType::ExceptionSpecInfo &esi)
Definition AbstractBasicWriter.h:203
void writeArray(ArrayRef< T > array)
Definition AbstractBasicWriter.h:141
void writeFixedPointSemantics(const llvm::FixedPointSemantics &sema)
Definition AbstractBasicWriter.h:164
void writeNestedNameSpecifier(NestedNameSpecifier NNS)
Definition AbstractBasicWriter.h:232
void writeFunctionEffect(FunctionEffect E)
Definition AbstractBasicWriter.h:224
void writeEnum(T value)
Definition AbstractBasicWriter.h:137
DataStreamBasicWriter(ASTContext &ctx)
Definition AbstractBasicWriter.h:123
void writeOptional(std::optional< T > value)
Definition AbstractBasicWriter.h:148
void writeExtParameterInfo(FunctionProtoType::ExtParameterInfo epi)
Definition AbstractBasicWriter.h:218
Impl & writeObject()
Definition AbstractBasicWriter.h:134
void writeAPInt(const llvm::APInt &value)
Definition AbstractBasicWriter.h:157
Impl & find(const char *propertyName)
Implement property-find by ignoring it.
Definition AbstractBasicWriter.h:128
void writeAPSInt(const llvm::APSInt &value)
Definition AbstractBasicWriter.h:152
void writeLValuePathSerializationHelper(APValue::LValuePathSerializationHelper lvaluePath)
Definition AbstractBasicWriter.h:171
void writeQualifiers(Qualifiers value)
Definition AbstractBasicWriter.h:197
const internal::VariadicDynCastAllOfMatcher< Decl, ValueDecl > valueDecl
Matches any value declaration.
const internal::VariadicDynCastAllOfMatcher< Decl, RecordDecl > recordDecl
Matches class, struct, and union declarations.
std::optional< T > makeOptionalFromNullable(const T &value)
Definition AbstractBasicWriter.h:20
std::optional< T * > makeOptionalFromPointer(T *value)
Definition AbstractBasicWriter.h:24
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
U cast(CodeGen::Address addr)
@ 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.
const NamespaceBaseDecl * Namespace
NestedNameSpecifier Prefix