9#ifndef LLVM_CLANG_AST_ABSTRACTBASICWRITER_H
10#define LLVM_CLANG_AST_ABSTRACTBASICWRITER_H
17namespace serialization {
21 return (value.isNull() ? std::optional<T>() : std::optional<T>(value));
25 return (value ? std::optional<T *>(value) : std::optional<T *>());
98#include "clang/AST/AbstractBasicWriter.inc"
122 using BasicWriterBase<Impl>::asImpl;
128 Impl &
find(
const char *propertyName) {
138 asImpl().writeUInt32(uint32_t(value));
143 asImpl().writeUInt32(array.size());
144 for (
const T &elt : array) {
145 WriteDispatcher<T>::write(asImpl(), elt);
150 WriteDispatcher<T>::write(asImpl(), PackOptionalValue<T>::pack(value));
154 asImpl().writeBool(value.isUnsigned());
155 asImpl().writeAPInt(value);
159 asImpl().writeUInt32(value.getBitWidth());
160 const uint64_t *words = value.getRawData();
161 for (
size_t i = 0, e = value.getNumWords(); i != e; ++i)
162 asImpl().writeUInt64(words[i]);
166 asImpl().writeUInt32(sema.getWidth());
167 asImpl().writeUInt32(sema.getScale());
168 asImpl().writeUInt32(sema.isSigned() | sema.isSaturated() << 1 |
169 sema.hasUnsignedPadding() << 2);
176 asImpl().writeQualType(elemTy);
177 asImpl().writeUInt32(path.size());
178 auto &ctx = ((BasicWriterBase<Impl> *)
this)->getASTContext();
179 for (
auto elem : path) {
181 asImpl().writeUInt32(elem.getAsBaseOrMember().getInt());
182 const Decl *baseOrMember = elem.getAsBaseOrMember().getPointer();
183 if (
const auto *
recordDecl = dyn_cast<CXXRecordDecl>(baseOrMember)) {
187 const auto *
valueDecl = cast<ValueDecl>(baseOrMember);
192 asImpl().writeUInt32(elem.getAsArrayIndex());
193 elemTy = ctx.getAsArrayType(elemTy)->getElementType();
200 "update this if the value size changes");
206 asImpl().writeUInt32(uint32_t(esi.
Type));
221 "opaque value doesn't fit into uint32_t");
226 asImpl().writeUInt32(
E.toOpaqueInt32());
240 nestedNames.push_back(NNS);
244 asImpl().writeUInt32(nestedNames.size());
245 while (!nestedNames.empty()) {
246 NNS = nestedNames.pop_back_val();
248 asImpl().writeNestedNameSpecifierKind(kind);
275 llvm_unreachable(
"bad nested name specifier kind");
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.
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<int>::".
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier 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.
@ 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*.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
A (possibly-)qualified type.
The collection of all-type qualifiers we support.
uint64_t getAsOpaqueValue() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
const T * getAs() const
Member-template getAs<specific type>'.
DataStreamBasicWriter provides convenience implementations for many BasicWriter methods based on the ...
void writeEffectConditionExpr(EffectConditionExpr CE)
void writeExceptionSpecInfo(const FunctionProtoType::ExceptionSpecInfo &esi)
void writeFixedPointSemantics(const llvm::FixedPointSemantics &sema)
void writeFunctionEffect(FunctionEffect E)
void writeArray(llvm::ArrayRef< T > array)
DataStreamBasicWriter(ASTContext &ctx)
void writeOptional(std::optional< T > value)
void writeExtParameterInfo(FunctionProtoType::ExtParameterInfo epi)
void writeAPInt(const llvm::APInt &value)
Impl & find(const char *propertyName)
Implement property-find by ignoring it.
void writeAPSInt(const llvm::APSInt &value)
void writeLValuePathSerializationHelper(APValue::LValuePathSerializationHelper lvaluePath)
void writeQualifiers(Qualifiers value)
void writeNestedNameSpecifier(NestedNameSpecifier *NNS)
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)
std::optional< T * > makeOptionalFromPointer(T *value)
The JSON file list parser is used to communicate input to InstallAPI.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
const FunctionProtoType * T
@ 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.