Go to the documentation of this file.
9 #ifndef LLVM_CLANG_AST_ABSTRACTBASICWRITER_H
10 #define LLVM_CLANG_AST_ABSTRACTBASICWRITER_H
16 namespace serialization {
20 return (value.isNull()
100 #include "clang/AST/AbstractBasicWriter.inc"
121 template <
class Impl>
124 using BasicWriterBase<Impl>::asImpl;
130 Impl &
find(
const char *propertyName) {
140 asImpl().writeUInt32(uint32_t(value));
145 asImpl().writeUInt32(array.size());
146 for (
const T &elt : array) {
147 WriteDispatcher<T>::write(asImpl(), elt);
153 WriteDispatcher<T>::write(asImpl(), PackOptionalValue<T>::pack(value));
157 asImpl().writeBool(value.isUnsigned());
158 asImpl().writeAPInt(value);
162 asImpl().writeUInt32(value.getBitWidth());
163 const uint64_t *words = value.getRawData();
164 for (
size_t i = 0, e = value.getNumWords(); i != e; ++i)
165 asImpl().writeUInt64(words[i]);
169 asImpl().writeUInt32(sema.getWidth());
170 asImpl().writeUInt32(sema.getScale());
171 asImpl().writeUInt32(sema.isSigned() | sema.isSaturated() << 1 |
172 sema.hasUnsignedPadding() << 2);
179 asImpl().writeQualType(elemTy);
180 asImpl().writeUInt32(path.size());
181 auto &ctx = ((BasicWriterBase<Impl> *)
this)->getASTContext();
182 for (
auto elem : path) {
184 asImpl().writeUInt32(elem.getAsBaseOrMember().getInt());
185 const Decl *baseOrMember = elem.getAsBaseOrMember().getPointer();
186 if (
const auto *
recordDecl = dyn_cast<CXXRecordDecl>(baseOrMember)) {
190 const auto *
valueDecl = cast<ValueDecl>(baseOrMember);
195 asImpl().writeUInt32(elem.getAsArrayIndex());
196 elemTy = ctx.getAsArrayType(elemTy)->getElementType();
203 "update this if the value size changes");
209 asImpl().writeUInt32(uint32_t(esi.
Type));
224 "opaque value doesn't fit into uint32_t");
235 nestedNames.push_back(NNS);
239 asImpl().writeUInt32(nestedNames.size());
240 while (!nestedNames.empty()) {
241 NNS = nestedNames.pop_back_val();
243 asImpl().writeNestedNameSpecifierKind(
kind);
270 llvm_unreachable(
"bad nested name specifier kind");
@ Identifier
An identifier, stored as an IdentifierInfo*.
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
@ Super
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
void writeArray(llvm::ArrayRef< T > array)
unsigned char getOpaqueValue() const
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
llvm::Optional< T > makeOptionalFromNullable(const T &value)
llvm::Optional< T * > makeOptionalFromPointer(T *value)
@ NamespaceAlias
A namespace alias, stored as a NamespaceAliasDecl*.
A (possibly-)qualified type.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
@ EST_Dynamic
throw(T1, T2)
The collection of all-type qualifiers we support.
DataStreamBasicWriter provides convenience implementations for many BasicWriter methods based on the ...
void writeLValuePathSerializationHelper(APValue::LValuePathSerializationHelper lvaluePath)
unsigned getAsOpaqueValue() const
void writeOptional(llvm::Optional< T > value)
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
const internal::VariadicDynCastAllOfMatcher< Decl, ValueDecl > valueDecl
Matches any value declaration.
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
@ EST_Unevaluated
not evaluated yet, for special member function
void writeQualifiers(Qualifiers value)
@ Namespace
A namespace, stored as a NamespaceDecl*.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
Holds information about the various types of exception specification.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const T * getAs() const
Member-template getAs<specific type>'.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
void writeAPSInt(const llvm::APSInt &value)
@ Global
The global specifier '::'. There is no stored value.
@ TypeSpecWithTemplate
A type that was preceded by the 'template' keyword, stored as a Type*.
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
void writeAPInt(const llvm::APInt &value)
@ EST_Uninstantiated
not instantiated yet
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
void writeExtParameterInfo(FunctionProtoType::ExtParameterInfo epi)
Decl - This represents one declaration (or definition), e.g.
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
const internal::VariadicDynCastAllOfMatcher< Decl, RecordDecl > recordDecl
Matches class, struct, and union declarations.
void writeFixedPointSemantics(const llvm::FixedPointSemantics &sema)
ExceptionSpecificationType Type
The kind of exception specification this is.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
SpecifierKind
The kind of specifier that completes this nested name specifier.
ArrayRef< LValuePathEntry > Path
@ TypeSpec
A type, stored as a Type*.
Impl & find(const char *propertyName)
Implement property-find by ignoring it.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
void writeExceptionSpecInfo(const FunctionProtoType::ExceptionSpecInfo &esi)
unsigned kind
All of the diagnostics that can be emitted by the frontend.
DataStreamBasicWriter(ASTContext &ctx)
void writeNestedNameSpecifier(NestedNameSpecifier *NNS)