14 #ifndef LLVM_CLANG_SERIALIZATION_ASTRECORDWRITER_H 15 #define LLVM_CLANG_SERIALIZATION_ASTRECORDWRITER_H 45 void PrepareToEmit(uint64_t MyOffset) {
47 for (
unsigned I : OffsetIndices) {
48 auto &StoredOffset = (*Record)[I];
49 assert(StoredOffset < MyOffset &&
"invalid offset");
51 StoredOffset = MyOffset - StoredOffset;
53 OffsetIndices.clear();
59 : Writer(&Writer), Record(&Record) {}
64 : Writer(Parent.Writer), Record(&Record) {}
75 void push_back(uint64_t N) { Record->push_back(N); }
76 template<
typename InputIterator>
77 void append(InputIterator begin, InputIterator end) {
78 Record->append(begin, end);
80 bool empty()
const {
return Record->empty(); }
81 size_t size()
const {
return Record->size(); }
88 uint64_t
Emit(
unsigned Code,
unsigned Abbrev = 0) {
89 uint64_t
Offset = Writer->Stream.GetCurrentBitNo();
90 PrepareToEmit(Offset);
91 Writer->Stream.EmitRecord(Code, *Record, Abbrev);
97 uint64_t
EmitStmt(
unsigned Code,
unsigned Abbrev = 0) {
99 PrepareToEmit(Writer->Stream.GetCurrentBitNo());
100 Writer->Stream.EmitRecord(Code, *Record, Abbrev);
101 return Writer->Stream.GetCurrentBitNo();
107 OffsetIndices.push_back(Record->size());
108 Record->push_back(BitOffset);
119 StmtsToEmit.push_back(S);
143 Record->push_back(Value);
147 Record->push_back(Value);
151 Record->push_back(Value);
228 writeDeclarationName(Name);
247 writeTemplateName(Name);
252 writeTemplateArgument(Arg);
278 return Writer->
AddPath(Path, *Record);
Represents a function declaration or definition.
Smart pointer class that efficiently represents Objective-C method names.
A (possibly-)qualified type.
Stmt - This represents one statement.
void AddUnresolvedSet(const ASTUnresolvedSet &Set)
Emit a UnresolvedSet structure.
void AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
Emit a nested name specifier with source-location information.
Decl - This represents one declaration (or definition), e.g.
void writeBool(bool Value)
uint64_t & operator[](size_t N)
A container of type source information.
void AddTypeRef(QualType T, RecordDataImpl &Record)
Emit a reference to a type.
void writeStmtRef(const Stmt *S)
uint64_t Emit(unsigned Code, unsigned Abbrev=0)
Emit the record to the stream, followed by its substatements, and return its offset.
void AddFunctionDefinition(const FunctionDecl *FD)
Add a definition for the given function to the queue of statements to emit.
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Stores a list of template parameters for a TemplateDecl and its derived classes.
void AddString(StringRef Str)
Emit a string.
void AddSourceRange(SourceRange Range)
Emit a source range.
void AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record)
Emit a reference to an identifier.
void AddTypeSourceInfo(TypeSourceInfo *TInfo)
Emits a reference to a declarator info.
Base wrapper for a particular "section" of type source info.
One of these records is kept for each identifier that is lexed.
ASTRecordWriter(ASTRecordWriter &Parent, ASTWriter::RecordDataImpl &Record)
Construct a ASTRecordWriter that uses the same encoding scheme as another ASTRecordWriter.
void AddTypeRef(QualType T)
Emit a reference to a type.
A C++ nested-name-specifier augmented with source location information.
void AddTemplateParameterList(const TemplateParameterList *TemplateParams)
Emit a template parameter list.
void AddIdentifierRef(const IdentifierInfo *II)
Emit a reference to an identifier.
ASTWriter::RecordDataImpl & getRecordData() const
Extract the underlying record storage.
void append(InputIterator begin, InputIterator end)
void writeUInt64(uint64_t Value)
ASTRecordWriter & operator=(const ASTRecordWriter &)=delete
void AddSourceRange(SourceRange Range, RecordDataImpl &Record)
Emit a source range.
void AddTypeLoc(TypeLoc TL)
Emits source location information for a type. Does not emit the type.
void AddAPInt(const llvm::APInt &Value)
Emit an integral value.
void AddAPValue(const APValue &Value)
Emit an APvalue.
void AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc, DeclarationName Name)
void AddCXXTemporary(const CXXTemporary *Temp)
Emit a CXXTemporary.
void AddTemplateName(TemplateName Name)
Emit a template name.
void AddPath(StringRef Path, RecordDataImpl &Record)
Add a path to the given record.
void AddAttr(const Attr *A)
void writeAPSInt(const llvm::APSInt &value)
void AddTemplateArgument(const TemplateArgument &Arg)
Emit a template argument.
void AddDeclarationName(DeclarationName Name)
Emit a declaration name.
void AddCXXDefinitionData(const CXXRecordDecl *D)
ArgKind
The kind of template argument we're storing.
void writeSelector(Selector sel)
Represents a C++ template name within the type system.
void AddString(StringRef Str, RecordDataImpl &Record)
Add a string to the given record.
void AddPath(StringRef Path)
Emit a path.
void AddDeclRef(const Decl *D)
Emit a reference to a declaration.
void AddQualifierInfo(const QualifierInfo &Info)
void AddStmt(Stmt *S)
Add the given statement or expression to the queue of statements to emit.
void AddSelectorRef(Selector S)
Emit a Selector (which is a smart pointer reference).
void writeOMPClause(OMPClause *C)
This file defines OpenMP AST classes for clauses.
void AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record)
Emit a source location.
void push_back(uint64_t N)
Minimal vector-like interface.
A struct with extended info about a syntactic name qualifier, to be used for the case of out-of-line ...
Encodes a location in the source.
DataStreamBasicWriter provides convenience implementations for many BasicWriter methods based on the ...
void AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind, const TemplateArgumentLocInfo &Arg)
Emits a template argument location info.
Represents a C++ temporary.
void AddOffset(uint64_t BitOffset)
Add a bit offset into the record.
void writeSourceLocation(SourceLocation Loc)
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
This is a basic class for representing single OpenMP clause.
void writeAPInt(const llvm::APInt &value)
void AddAttributes(ArrayRef< const Attr *> Attrs)
Emit a list of attributes.
void AddVersionTuple(const VersionTuple &Version, RecordDataImpl &Record)
Add a version tuple to the given record.
void AddSourceLocation(SourceLocation Loc)
Emit a source location.
void AddDeclRef(const Decl *D, RecordDataImpl &Record)
Emit a reference to a declaration.
void writeIdentifier(const IdentifierInfo *II)
void AddAPFloat(const llvm::APFloat &Value)
Emit a floating-point value.
void AddDeclarationNameInfo(const DeclarationNameInfo &NameInfo)
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
Represents a template argument.
Dataflow Directional Tag Classes.
void AddCXXBaseSpecifiers(ArrayRef< CXXBaseSpecifier > Bases)
Emit a set of C++ base specifiers.
void AddCXXCtorInitializers(ArrayRef< CXXCtorInitializer *> CtorInits)
Emit a CXXCtorInitializer array.
The name of a declaration.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
void AddVersionTuple(const VersionTuple &Version)
Emit a version tuple.
Location wrapper for a TemplateArgument.
void writeDeclRef(const Decl *D)
void writeUInt32(uint32_t Value)
An UnresolvedSet-like class which uses the ASTContext's allocator.
uint64_t EmitStmt(unsigned Code, unsigned Abbrev=0)
Emit the record to the stream, preceded by its substatements.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
Represents a base class of a C++ class.
A template argument list.
Represents a C++ struct/union/class.
An object for streaming information to a record.
Location information for a TemplateArgument.
Writes an AST file containing the contents of a translation unit.
void AddCXXBaseSpecifier(const CXXBaseSpecifier &Base)
Emit a C++ base specifier.
void AddASTTemplateArgumentListInfo(const ASTTemplateArgumentListInfo *ASTTemplArgList)
Emits an AST template argument list info.
void AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs)
Emit a template argument list.
void AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg)
Emits a template argument location.
A trivial tuple used to represent a source range.
void AddNestedNameSpecifier(NestedNameSpecifier *NNS)
Emit a nested name specifier.
void writeNestedNameSpecifier(NestedNameSpecifier *NNS)
void writeQualType(QualType T)
void AddAPSInt(const llvm::APSInt &Value)
Emit a signed integral value.
ASTRecordWriter(ASTWriter &Writer, ASTWriter::RecordDataImpl &Record)
Construct a ASTRecordWriter that uses the default encoding scheme.
Attr - This represents one attribute.