14#ifndef LLVM_CLANG_SERIALIZATION_ASTRECORDWRITER_H
15#define LLVM_CLANG_SERIALIZATION_ASTRECORDWRITER_H
48 void PrepareToEmit(uint64_t MyOffset) {
50 for (
unsigned I : OffsetIndices) {
51 auto &StoredOffset = (*Record)[I];
52 assert(StoredOffset < MyOffset &&
"invalid offset");
54 StoredOffset = MyOffset - StoredOffset;
56 OffsetIndices.clear();
79 void push_back(uint64_t N) { Record->push_back(N); }
80 template<
typename InputIterator>
81 void append(InputIterator begin, InputIterator end) {
82 Record->append(begin, end);
84 bool empty()
const {
return Record->empty(); }
85 size_t size()
const {
return Record->size(); }
92 uint64_t
Emit(
unsigned Code,
unsigned Abbrev = 0) {
93 uint64_t
Offset = Writer->Stream.GetCurrentBitNo();
95 Writer->Stream.EmitRecord(Code, *Record, Abbrev);
101 uint64_t
EmitStmt(
unsigned Code,
unsigned Abbrev = 0) {
103 PrepareToEmit(Writer->Stream.GetCurrentBitNo());
104 Writer->Stream.EmitRecord(Code, *Record, Abbrev);
105 return Writer->Stream.GetCurrentBitNo();
111 OffsetIndices.push_back(Record->size());
112 Record->push_back(BitOffset);
123 StmtsToEmit.push_back(S);
150 Record->push_back(
Value);
154 Record->push_back(
Value);
158 Record->push_back(
Value);
235 writeDeclarationName(Name);
254 writeTemplateName(Name);
259 writeTemplateArgument(Arg);
294 return Writer->
AddPath(Path, *Record);
This file defines OpenMP AST classes for clauses.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
An object for streaming information to a record.
void AddDeclarationNameInfo(const DeclarationNameInfo &NameInfo)
ASTRecordWriter & operator=(const ASTRecordWriter &)=delete
void AddCXXBaseSpecifiers(ArrayRef< CXXBaseSpecifier > Bases)
Emit a set of C++ base specifiers.
void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs)
Emit a template argument list.
void AddFunctionDefinition(const FunctionDecl *FD)
Add a definition for the given function to the queue of statements to emit.
uint64_t Emit(unsigned Code, unsigned Abbrev=0)
Emit the record to the stream, followed by its substatements, and return its offset.
void AddCXXTemporary(const CXXTemporary *Temp)
Emit a CXXTemporary.
void writeOMPTraitInfo(const OMPTraitInfo *TI)
Write an OMPTraitInfo object.
void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base)
Emit a C++ base specifier.
ASTWriter::RecordDataImpl & getRecordData() const
Extract the underlying record storage.
void writeOMPClause(OMPClause *C)
void writeBool(bool Value)
void AddAPValue(const APValue &Value)
Emit an APvalue.
void AddNestedNameSpecifier(NestedNameSpecifier *NNS)
Emit a nested name specifier.
void AddUnresolvedSet(const ASTUnresolvedSet &Set)
Emit a UnresolvedSet structure.
void AddIdentifierRef(const IdentifierInfo *II)
Emit a reference to an identifier.
void AddStmt(Stmt *S)
Add the given statement or expression to the queue of statements to emit.
void AddDeclarationName(DeclarationName Name)
Emit a declaration name.
void AddSelectorRef(Selector S)
Emit a Selector (which is a smart pointer reference).
void writeUInt64(uint64_t Value)
uint64_t EmitStmt(unsigned Code, unsigned Abbrev=0)
Emit the record to the stream, preceded by its substatements.
void AddSourceRange(SourceRange Range, LocSeq *Seq=nullptr)
Emit a source range.
void AddPath(StringRef Path)
Emit a path.
void writeSourceLocation(SourceLocation Loc)
void AddOffset(uint64_t BitOffset)
Add a bit offset into the record.
void AddTypeRef(QualType T)
Emit a reference to a type.
void writeQualType(QualType T)
void AddSourceLocation(SourceLocation Loc, LocSeq *Seq=nullptr)
Emit a source location.
void push_back(uint64_t N)
Minimal vector-like interface.
void append(InputIterator begin, InputIterator end)
void AddTypeLoc(TypeLoc TL, LocSeq *Seq=nullptr)
Emits source location information for a type. Does not emit the type.
void AddCXXCtorInitializers(ArrayRef< CXXCtorInitializer * > CtorInits)
Emit a CXXCtorInitializer array.
void AddTemplateParameterList(const TemplateParameterList *TemplateParams)
Emit a template parameter list.
void AddTemplateArgument(const TemplateArgument &Arg)
Emit a template argument.
void AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc, DeclarationName Name)
void writeSelector(Selector sel)
void AddTemplateName(TemplateName Name)
Emit a template name.
void AddAPFloat(const llvm::APFloat &Value)
Emit a floating-point value.
void AddTypeSourceInfo(TypeSourceInfo *TInfo)
Emits a reference to a declarator info.
ASTRecordWriter(ASTWriter &W, ASTWriter::RecordDataImpl &Record)
Construct a ASTRecordWriter that uses the default encoding scheme.
void AddQualifierInfo(const QualifierInfo &Info)
void writeUInt32(uint32_t Value)
void AddDeclRef(const Decl *D)
Emit a reference to a declaration.
void writeOMPChildren(OMPChildren *Data)
Writes data related to the OpenMP directives.
ASTRecordWriter(const ASTRecordWriter &)=delete
Copying an ASTRecordWriter is almost certainly a bug.
void AddAPSInt(const llvm::APSInt &Value)
Emit a signed integral value.
void AddVersionTuple(const VersionTuple &Version)
Emit a version tuple.
void AddString(StringRef Str)
Emit a string.
void writeIdentifier(const IdentifierInfo *II)
void AddAPInt(const llvm::APInt &Value)
Emit an integral value.
void AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind, const TemplateArgumentLocInfo &Arg)
Emits a template argument location info.
ASTRecordWriter(ASTRecordWriter &Parent, ASTWriter::RecordDataImpl &Record)
Construct a ASTRecordWriter that uses the same encoding scheme as another ASTRecordWriter.
void AddAttributes(ArrayRef< const Attr * > Attrs)
Emit a list of attributes.
void AddASTTemplateArgumentListInfo(const ASTTemplateArgumentListInfo *ASTTemplArgList)
Emits an AST template argument list info.
void AddCXXDefinitionData(const CXXRecordDecl *D)
void AddVarDeclInit(const VarDecl *VD)
Emit information about the initializer of a VarDecl.
void writeStmtRef(const Stmt *S)
uint64_t & operator[](size_t N)
void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg)
Emits a template argument location.
void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
Emit a nested name specifier with source-location information.
void writeBTFTypeTagAttr(const BTFTypeTagAttr *A)
Write an BTFTypeTagAttr object.
void AddAttr(const Attr *A)
void writeDeclRef(const Decl *D)
An UnresolvedSet-like class which uses the ASTContext's allocator.
Writes an AST file containing the contents of a translation unit.
void AddSourceRange(SourceRange Range, RecordDataImpl &Record, LocSeq *Seq=nullptr)
Emit a source range.
void AddPath(StringRef Path, RecordDataImpl &Record)
Add a path to the given record.
void AddVersionTuple(const VersionTuple &Version, RecordDataImpl &Record)
Add a version tuple to the given record.
void AddString(StringRef Str, RecordDataImpl &Record)
Add a string to the given record.
void AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record)
Emit a reference to an identifier.
void AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record, LocSeq *Seq=nullptr)
Emit a source location.
void AddTypeRef(QualType T, RecordDataImpl &Record)
Emit a reference to a type.
void AddDeclRef(const Decl *D, RecordDataImpl &Record)
Emit a reference to a declaration.
Attr - This represents one attribute.
Represents a base class of a C++ class.
Represents a C++ struct/union/class.
Represents a C++ temporary.
Decl - This represents one declaration (or definition), e.g.
DeclarationNameLoc - Additional source/type location info for a declaration name.
The name of a declaration.
Represents a function declaration or definition.
One of these records is kept for each identifier that is lexed.
A C++ nested-name-specifier augmented with source location information.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
Contains data for OpenMP directives: clauses, children expressions/statements (helpers for codegen) a...
This is a basic class for representing single OpenMP clause.
Helper data structure representing the traits in a match clause of an declare variant or metadirectiv...
A (possibly-)qualified type.
Smart pointer class that efficiently represents Objective-C method names.
Serialized encoding of a sequence of SourceLocations.
Encodes a location in the source.
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
A template argument list.
Location wrapper for a TemplateArgument.
Represents a template argument.
ArgKind
The kind of template argument we're storing.
Represents a C++ template name within the type system.
Stores a list of template parameters for a TemplateDecl and its derived classes.
Base wrapper for a particular "section" of type source info.
A container of type source information.
Represents a variable declaration or definition.
DataStreamBasicWriter provides convenience implementations for many BasicWriter methods based on the ...
DataStreamBasicWriter(ASTContext &ctx)
void writeAPInt(const llvm::APInt &value)
void writeAPSInt(const llvm::APSInt &value)
void writeNestedNameSpecifier(NestedNameSpecifier *NNS)
@ C
Languages that the frontend can parse and compile.
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
A struct with extended info about a syntactic name qualifier, to be used for the case of out-of-line ...
Location information for a TemplateArgument.