14#ifndef LLVM_CLANG_SERIALIZATION_ASTRECORDREADER_H
15#define LLVM_CLANG_SERIALIZATION_ASTRECORDREADER_H
22#include "llvm/ADT/APFloat.h"
23#include "llvm/ADT/APInt.h"
24#include "llvm/ADT/APSInt.h"
55 bool isModule()
const {
return F->isModule(); }
61 unsigned getIdx()
const {
return Idx; }
64 size_t size()
const {
return Record.size(); }
67 const uint64_t &
operator[](
size_t N) {
return Record[N]; }
70 uint64_t
back() {
return Record.back(); }
74 uint64_t
readInt() {
return Record[Idx++]; }
83 uint64_t
peekInt() {
return Record[Idx]; }
91 return Reader->getGlobalSubmoduleID(*F, LocalID);
96 return Reader->getSubmodule(GlobalID);
101 return Reader->ReadLexicalDeclContextStorage(*F, F->DeclsCursor, Offset,
107 bool HasExpr = Kind & 0x1;
119 return Reader->getGlobalBitOffset(*F, LocalOffset);
139 return cast_or_null<T>(Reader->GetLocalDecl(*F, LocalID));
166 return Reader->getGlobalTypeID(*F, LocalID);
175 return Reader->readType(*F, Record, Idx);
189 return Reader->ReadDecl(*F, Record, Idx);
202 return Reader->ReadDeclAs<
T>(*F, Record, Idx);
206 return Reader->readIdentifier(*F, Record, Idx);
211 return Reader->ReadSelector(*F, Record, Idx);
235 using DataStreamBasicReader::readTemplateArgument;
249 bool Canonicalize =
false);
261 return Reader->ReadCXXTemporary(*F, Record, Idx);
290 return Reader->ReadSourceLocation(*F, Record, Idx);
295 return Reader->ReadSourceRange(*F, Record, Idx);
308 llvm::APFloat
readAPFloat(
const llvm::fltSemantics &Sem);
329 return Reader->ReadString(Record, Idx);
334 return Reader->ReadPath(*F, Record, Idx);
355 return Reader->ReadToken(*F, Record, Idx);
359 Reader->RecordSwitchCaseID(SC, ID);
364 return Reader->getSwitchCaseWithID(ID);
372 : Cursor(Cursor), Offset(Cursor.GetCurrentBitNo()) {}
375 if (llvm::Error Err = Cursor.JumpToBit(Offset))
376 llvm::report_fatal_error(
377 llvm::Twine(
"Cursor should always be able to go back, failed: ") +
382 llvm::BitstreamCursor &Cursor;
Defines the clang::ASTContext interface.
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg) const
Retrieve the "canonical" template argument.
Reads an AST files chain containing the contents of a translation unit.
SmallVectorImpl< uint64_t > RecordDataImpl
static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx)
Read a version tuple.
SmallVector< uint64_t, 64 > RecordData
bool readBool()
Read a boolean value, advancing Idx.
std::string readString()
Read a string, advancing Idx.
Decl * readDecl()
Reads a declaration from the given position in a record in the given module, advancing Idx.
uint32_t readUInt32()
Read a 32-bit unsigned value; required to satisfy BasicReader.
llvm::APFloat readAPFloat(const llvm::fltSemantics &Sem)
Read an arbitrary constant value, advancing Idx.
TemplateArgumentLoc readTemplateArgumentLoc()
Reads a TemplateArgumentLoc, advancing Idx.
SourceRange readSourceRange()
Read a source range, advancing Idx.
SourceLocation readSourceLocation()
Read a source location, advancing Idx.
ExplicitSpecifier readExplicitSpec()
uint64_t getGlobalBitOffset(uint64_t LocalOffset)
Read information about an exception specification (inherited).
void readUnresolvedSet(LazyASTUnresolvedSet &Set)
Read a UnresolvedSet structure, advancing Idx.
bool readLexicalDeclContextStorage(uint64_t Offset, DeclContext *DC)
Read the record that describes the lexical contents of a DC.
void readTemplateArgumentList(SmallVectorImpl< TemplateArgument > &TemplArgs, bool Canonicalize=false)
Read a template argument array, advancing Idx.
void readAttributes(AttrVec &Attrs)
Reads attributes from the current stream position, advancing Idx.
void readQualifierInfo(QualifierInfo &Info)
T * GetLocalDeclAs(LocalDeclID LocalID)
Reads a declaration with the given local ID in the given module.
unsigned getIdx() const
The current position in this record.
DeclarationNameLoc readDeclarationNameLoc(DeclarationName Name)
Read a declaration name, advancing Idx.
CXXBaseSpecifier readCXXBaseSpecifier()
Read a C++ base specifier, advancing Idx.
QualType readType()
Read a type from the current position in the record.
bool isModule() const
Is this a module file for a module (rather than a PCH or similar).
T * readDeclAs()
Reads a declaration from the given position in the record, advancing Idx.
Expected< unsigned > readRecord(llvm::BitstreamCursor &Cursor, unsigned AbbrevID)
Reads a record with id AbbrevID from Cursor, resetting the internal state.
DeclarationNameInfo readDeclarationNameInfo()
const uint64_t & operator[](size_t N)
An arbitrary index in this record.
void readTypeLoc(TypeLoc TL)
Reads the location information for a type.
size_t size() const
The length of this record.
IdentifierInfo * readIdentifier()
TemplateArgumentLocInfo readTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind)
Reads a TemplateArgumentLocInfo appropriate for the given TemplateArgument kind, advancing Idx.
uint64_t readUInt64()
Read a 64-bit unsigned value; required to satisfy BasicReader.
TemplateArgument readTemplateArgument(bool Canonicalize)
std::string readPath()
Read a path, advancing Idx.
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
TypeSourceInfo * readTypeSourceInfo()
Reads a declarator info from the given record, advancing Idx.
uint64_t peekInt()
Returns the current value in this record, without advancing.
void readTemplateArgumentListInfo(TemplateArgumentListInfo &Result)
TypeCoupledDeclRefInfo readTypeCoupledDeclRefInfo()
BTFTypeTagAttr * readBTFTypeTagAttr()
Read an BTFTypeTagAttr object.
void skipInts(unsigned N)
Skips the specified number of values.
GlobalDeclID readDeclID()
Reads a declaration ID from the given position in this record.
serialization::TypeID getGlobalTypeID(serialization::TypeID LocalID) const
Map a local type ID within a given AST file to a global type ID.
NestedNameSpecifierLoc readNestedNameSpecifierLoc()
Return a nested name specifier, advancing Idx.
ASTRecordReader(ASTReader &Reader, ModuleFile &F)
Construct an ASTRecordReader that uses the default encoding scheme.
ConceptReference * readConceptReference()
SwitchCase * getSwitchCaseWithID(unsigned ID)
Retrieve the switch-case statement with the given ID.
Token readToken()
Reads a token out of a record, advancing Idx.
void recordSwitchCaseID(SwitchCase *SC, unsigned ID)
void readOMPChildren(OMPChildren *Data)
Read an OpenMP children, advancing Idx.
OMPClause * readOMPClause()
Read an OpenMP clause, advancing Idx.
void readOpenACCClauseList(MutableArrayRef< const OpenACCClause * > Clauses)
Read a list of OpenACC clauses into the passed SmallVector, during statement reading.
Selector readSelector()
Read a selector from the Record, advancing Idx.
CXXTemporary * readCXXTemporary()
OMPTraitInfo * readOMPTraitInfo()
Read an OMPTraitInfo object, advancing Idx.
Qualifiers readQualifiers()
TemplateParameterList * readTemplateParameterList()
Read a template parameter list, advancing Idx.
OpenACCClause * readOpenACCClause()
Read an OpenACC clause, advancing Idx.
VersionTuple readVersionTuple()
Read a version tuple, advancing Idx.
llvm::SmallVector< Expr * > readOpenACCVarList()
Read a list of Exprs used for a var-list.
UnsignedOrNone readUnsignedOrNone()
uint64_t back()
Returns the last value in this record.
serialization::SubmoduleID getGlobalSubmoduleID(unsigned LocalID)
Retrieve the global submodule ID its local ID number.
CXXCtorInitializer ** readCXXCtorInitializers()
Read a CXXCtorInitializer array, advancing Idx.
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
SpirvOperand readHLSLSpirvOperand()
Stmt * readStmt()
Reads a statement.
const ASTTemplateArgumentListInfo * readASTTemplateArgumentListInfo()
Stmt * readSubStmt()
Reads a sub-statement operand during statement reading.
uint64_t readInt()
Returns the current value in this record, and advances to the next value.
Attr * readAttr()
Reads one attribute from the current stream position, advancing Idx.
Expr * readExpr()
Reads an expression.
void readOpenACCRoutineDeclAttr(OpenACCRoutineDeclAttr *A)
ArrayRef< uint64_t > readIntArray(unsigned Len)
llvm::SmallVector< Expr * > readOpenACCIntExprList()
Read a list of Exprs used for a int-expr-list.
Expr * readSubExpr()
Reads a sub-expression operand during statement reading.
Attr - This represents one attribute.
Represents a base class of a C++ class.
Represents a C++ base or member initializer.
Represents a C++ temporary.
A reference to a concept and its template args, as it appears in the code.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Decl - This represents one declaration (or definition), e.g.
DeclarationNameLoc - Additional source/type location info for a declaration name.
The name of a declaration.
Store information needed for an explicit specifier.
This represents one expression.
One of these records is kept for each identifier that is lexed.
An UnresolvedSet-like class that might not have been loaded from the external AST source yet.
Describes a module or submodule.
A C++ nested-name-specifier augmented with source location information.
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...
This is the base type for all OpenACC Clauses.
A (possibly-)qualified type.
The collection of all-type qualifiers we support.
static Qualifiers fromOpaqueValue(uint64_t opaque)
Smart pointer class that efficiently represents Objective-C method names.
Encodes a location in the source.
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
A convenient class for passing around template argument information.
Location wrapper for a TemplateArgument.
Represents a template argument.
ArgKind
The kind of template argument we're storing.
Stores a list of template parameters for a TemplateDecl and its derived classes.
Token - This structure provides full information about a lexed token.
[BoundsSafety] Represents information of declarations referenced by the arguments of the counted_by a...
Base wrapper for a particular "section" of type source info.
A container of type source information.
DataStreamBasicReader provides convenience implementations for many BasicReader methods based on the ...
DataStreamBasicReader(ASTContext &ctx)
Information about a module that has been loaded by the ASTReader.
uint64_t TypeID
An ID number that refers to a type in an AST file.
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
The JSON file list parser is used to communicate input to InstallAPI.
SmallVector< Attr *, 4 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
@ Result
The result type of a method or function.
const FunctionProtoType * T
ExplicitSpecKind
Define the meaning of possible values of the kind in ExplicitSpecifier.
U cast(CodeGen::Address addr)
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 ...
SavedStreamPosition(llvm::BitstreamCursor &Cursor)
Location information for a TemplateArgument.
static constexpr UnsignedOrNone fromInternalRepresentation(unsigned Rep)