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