14 #ifndef LLVM_CLANG_SERIALIZATION_ASTRECORDREADER_H 15 #define LLVM_CLANG_SERIALIZATION_ASTRECORDREADER_H 20 #include "llvm/ADT/APFloat.h" 21 #include "llvm/ADT/APInt.h" 22 #include "llvm/ADT/APSInt.h" 56 unsigned getIdx()
const {
return Idx; }
59 size_t size()
const {
return Record.size(); }
62 const uint64_t &
operator[](
size_t N) {
return Record[N]; }
65 uint64_t
back() {
return Record.back(); }
69 uint64_t
readInt() {
return Record[Idx++]; }
72 auto Array = llvm::makeArrayRef(Record).slice(Idx, Len);
78 uint64_t
peekInt() {
return Record[Idx]; }
96 return Reader->ReadLexicalDeclContextStorage(*F, F->
DeclsCursor, Offset,
103 return Reader->ReadVisibleDeclContextStorage(*F, F->
DeclsCursor, Offset,
109 bool HasExpr = Kind & 0x1;
112 static_cast<ExplicitSpecKind>(Kind));
121 return Reader->getGlobalBitOffset(*F, LocalOffset);
142 return cast_or_null<T>(Reader->
GetLocalDecl(*F, LocalID));
174 return Reader->
readType(*F, Record, Idx);
190 return Reader->
ReadDecl(*F, Record, Idx);
203 return Reader->
ReadDeclAs<T>(*F, Record, Idx);
232 using DataStreamBasicReader::readTemplateArgument;
246 bool Canonicalize =
false);
284 llvm::APFloat
readAPFloat(
const llvm::fltSemantics &Sem);
306 return Reader->
ReadPath(*F, Record, Idx);
322 return Reader->
ReadToken(*F, Record, Idx);
339 : Cursor(Cursor),
Offset(Cursor.GetCurrentBitNo()) {}
343 llvm::report_fatal_error(
344 "Cursor should always be able to go back, failed: " +
349 llvm::BitstreamCursor &
Cursor;
353 inline void PCHValidator::Error(
const char *Msg) {
Decl * GetLocalDecl(ModuleFile &F, uint32_t LocalID)
Reads a declaration with the given local ID in the given module.
SourceLocation readSourceLocation()
Read a source location, advancing Idx.
Smart pointer class that efficiently represents Objective-C method names.
void readQualifierInfo(QualifierInfo &Info)
A (possibly-)qualified type.
CXXBaseSpecifier readCXXBaseSpecifier()
Read a C++ base specifier, advancing Idx.
ASTRecordReader(ASTReader &Reader, ModuleFile &F)
Construct an ASTRecordReader that uses the default encoding scheme.
Stmt - This represents one statement.
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
SourceLocation ReadSourceLocation(ModuleFile &ModuleFile, uint32_t Raw) const
Read a source location from raw form.
Decl - This represents one declaration (or definition), e.g.
void readUnresolvedSet(LazyASTUnresolvedSet &Set)
Read a UnresolvedSet structure, advancing Idx.
A container of type source information.
Store information needed for an explicit specifier.
DeclarationNameInfo readDeclarationNameInfo()
TemplateParameterList * readTemplateParameterList()
Read a template parameter list, advancing Idx.
static Qualifiers fromOpaqueValue(unsigned opaque)
void recordSwitchCaseID(SwitchCase *SC, unsigned ID)
const ASTTemplateArgumentListInfo * readASTTemplateArgumentListInfo()
QualType readType()
Read a type from the current position in the record.
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.
T * ReadDeclAs(ModuleFile &F, const RecordData &R, unsigned &I)
Reads a declaration from the given position in a record in the given module.
Selector ReadSelector(ModuleFile &M, const RecordData &Record, unsigned &Idx)
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
The collection of all-type qualifiers we support.
An UnresolvedSet-like class that might not have been loaded from the external AST source yet...
Base wrapper for a particular "section" of type source info.
serialization::TypeID getGlobalTypeID(unsigned LocalID) const
Map a local type ID within a given AST file to a global type ID.
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
DataStreamBasicReader(ASTContext &ctx)
One of these records is kept for each identifier that is lexed.
T * readDeclAs()
Reads a declaration from the given position in the record, advancing Idx.
uint64_t readUInt64()
Read a 64-bit unsigned value; required to satisfy BasicReader.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
Expr * readExpr()
Reads an expression.
Helper class that saves the current stream position and then restores it when destroyed.
Token - This structure provides full information about a lexed token.
Stmt * ReadSubStmt()
Reads a sub-statement operand during statement reading.
DeclarationNameLoc readDeclarationNameLoc(DeclarationName Name)
Read a declaration name, advancing Idx.
Describes a module or submodule.
size_t size() const
The length of this record.
static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx)
Read a version tuple.
uint32_t readUInt32()
Read a 32-bit unsigned value; required to satisfy BasicReader.
TemplateArgument readTemplateArgument(bool Canonicalize)
std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx)
serialization::SubmoduleID getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID)
Retrieve the global submodule ID given a module and its local ID number.
CXXTemporary * ReadCXXTemporary(ModuleFile &F, const RecordData &Record, unsigned &Idx)
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
SourceRange readSourceRange()
Read a source range, advancing Idx.
CXXCtorInitializer ** readCXXCtorInitializers()
Read a CXXCtorInitializer array, advancing Idx.
static std::string ReadString(const RecordData &Record, unsigned &Idx)
uint64_t back()
Returns the last value in this record.
DataStreamBasicReader provides convenience implementations for many BasicReader methods based on the ...
TypeSourceInfo * readTypeSourceInfo()
Reads a declarator info from the given record, advancing Idx.
APValue readAPValue()
Read an arbitrary constant value, advancing Idx.
Decl * ReadDecl(ModuleFile &F, const RecordData &R, unsigned &I)
Reads a declaration from the given position in a record in the given module.
std::string readPath()
Read a path, advancing Idx.
ArrayRef< uint64_t > readIntArray(unsigned Len)
serialization::TypeID getGlobalTypeID(ModuleFile &F, unsigned LocalID) const
Map a local type ID within a given AST file into a global type ID.
This represents one expression.
SwitchCase * getSwitchCaseWithID(unsigned ID)
Retrieve the switch-case statement with the given ID.
QualType readType(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a type from the current position in the given record, which was read from the given AST file...
Stmt * ReadStmt(ModuleFile &F)
Reads a statement.
Stmt * readStmt()
Reads a statement.
Expected< unsigned > readRecord(llvm::BitstreamCursor &Cursor, unsigned AbbrevID)
Reads a record with id AbbrevID from Cursor, resetting the internal state.
ArgKind
The kind of template argument we're storing.
SourceRange ReadSourceRange(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a source range.
Decl * readDecl()
Reads a declaration from the given position in a record in the given module, advancing Idx...
Information about a module that has been loaded by the ASTReader.
OMPClause * readOMPClause()
Read an OpenMP clause, advancing Idx.
SavedStreamPosition(llvm::BitstreamCursor &Cursor)
std::string readString()
Read a string, advancing Idx.
void skipInts(unsigned N)
Skips the specified number of values.
const uint64_t & operator[](size_t N)
An arbitrary index in this record.
bool isModule() const
Is this a module file for a module (rather than a PCH or similar).
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
A struct with extended info about a syntactic name qualifier, to be used for the case of out-of-line ...
CXXTemporary * readCXXTemporary()
Encodes a location in the source.
Stmt * readSubStmt()
Reads a sub-statement operand during statement reading.
Represents a C++ temporary.
IdentifierInfo * readIdentifier(ModuleFile &M, const RecordData &Record, unsigned &Idx)
bool readLexicalDeclContextStorage(uint64_t Offset, DeclContext *DC)
Read the record that describes the lexical contents of a DC.
void readAttributes(AttrVec &Attrs)
Reads attributes from the current stream position, advancing Idx.
bool isModule() const
Is this a module file for a module (rather than a PCH or similar).
Attr * readAttr()
Reads one attribute from the current stream position, advancing Idx.
Expr * readSubExpr()
Reads a sub-expression operand during statement reading.
T * GetLocalDeclAs(uint32_t LocalID)
Reads a declaration with the given local ID in the given module.
This is a basic class for representing single OpenMP clause.
unsigned getIdx() const
The current position in this record.
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
uint32_t TypeID
An ID number that refers to a type in an AST file.
serialization::SubmoduleID getGlobalSubmoduleID(unsigned LocalID)
Retrieve the global submodule ID its local ID number.
serialization::DeclID readDeclID()
Reads a declaration ID from the given position in this record.
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
Represents a template argument.
Dataflow Directional Tag Classes.
llvm::BitstreamCursor DeclsCursor
DeclsCursor - This is a cursor to the start of the DECLS_BLOCK block.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Reads an AST files chain containing the contents of a translation unit.
Selector readSelector()
Read a selector from the Record, advancing Idx.
Expr * ReadExpr(ModuleFile &F)
Reads an expression.
IdentifierInfo * readIdentifier()
uint64_t peekInt()
Returns the current value in this record, without advancing.
The name of a declaration.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
void readTypeLoc(TypeLoc TL)
Reads the location information for a type.
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
VersionTuple readVersionTuple()
Read a version tuple, advancing Idx.
uint64_t readInt()
Returns the current value in this record, and advances to the next value.
TemplateArgumentLocInfo readTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind)
Reads a TemplateArgumentLocInfo appropriate for the given TemplateArgument kind, advancing Idx...
SmallVector< uint64_t, 64 > RecordData
Location wrapper for a TemplateArgument.
TemplateArgumentLoc readTemplateArgumentLoc()
Reads a TemplateArgumentLoc, advancing Idx.
Represents a C++ base or member initializer.
uint64_t getGlobalBitOffset(uint32_t LocalOffset)
Read information about an exception specification (inherited).
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
Represents a base class of a C++ class.
Qualifiers readQualifiers()
SmallVectorImpl< uint64_t > RecordDataImpl
void readTemplateArgumentList(SmallVectorImpl< TemplateArgument > &TemplArgs, bool Canonicalize=false)
Read a template argument array, advancing Idx.
serialization::DeclID ReadDeclID(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a declaration ID from the given position in a record in the given module.
llvm::APFloat readAPFloat(const llvm::fltSemantics &Sem)
Read an integral value, advancing Idx.
Expr * ReadSubExpr()
Reads a sub-expression operand during statement reading.
Token ReadToken(ModuleFile &M, const RecordDataImpl &Record, unsigned &Idx)
Reads a token out of a record.
Location information for a TemplateArgument.
NestedNameSpecifierLoc readNestedNameSpecifierLoc()
Return a nested name specifier, advancing Idx.
ExplicitSpecifier readExplicitSpec()
An object for streaming information from a record.
bool readVisibleDeclContextStorage(uint64_t Offset, serialization::DeclID ID)
Read the record that describes the visible contents of a DC.
bool readBool()
Read a boolean value, advancing Idx.
Token readToken()
Reads a token out of a record, advancing Idx.
A trivial tuple used to represent a source range.
SwitchCase * getSwitchCaseWithID(unsigned ID)
Retrieve the switch-case statement with the given ID.
Attr - This represents one attribute.
void RecordSwitchCaseID(SwitchCase *SC, unsigned ID)
Record that the given ID maps to the given switch-case statement.