r290217 - Store the "current position" index within the ASTRecordReader.
David L. Jones via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 20 16:17:49 PST 2016
Author: dlj
Date: Tue Dec 20 18:17:49 2016
New Revision: 290217
URL: http://llvm.org/viewvc/llvm-project?rev=290217&view=rev
Log:
Store the "current position" index within the ASTRecordReader.
Summary:
For ASTDeclReader and ASTStmtReader, every parameter "unsigned &Idx" ultimately
comes from a variable that is defined on the stack, next to the RecordData. This
change moves that index into the ASTRecordReader.
TypeLocReader cannot be transitioned, due to TableGen-generated code which calls
ASTReader::GetTypeSourceInfo.
Reviewers: rsmith
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D27836
Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=290217&r1=290216&r2=290217&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Tue Dec 20 18:17:49 2016
@@ -47,6 +47,7 @@
#include <vector>
namespace llvm {
+ class BitstreamCursor;
class MemoryBuffer;
class APInt;
class APSInt;
@@ -88,6 +89,7 @@ class ASTWriter;
class ASTReader;
class ASTDeclReader;
class ASTStmtReader;
+class ASTRecordReader;
class TypeLocReader;
struct HeaderFileInfo;
class VersionTuple;
@@ -2195,29 +2197,21 @@ class ASTRecordReader {
typedef serialization::ModuleFile ModuleFile;
ASTReader *Reader;
- const ASTReader::RecordData *Record;
ModuleFile *F;
+ unsigned Idx = 0;
+ ASTReader::RecordData Record;
typedef ASTReader::RecordData RecordData;
typedef ASTReader::RecordDataImpl RecordDataImpl;
public:
/// Construct an ASTRecordReader that uses the default encoding scheme.
- ASTRecordReader(ASTReader &Reader, const ASTReader::RecordData &Record,
- ModuleFile& F)
- : Reader(&Reader), Record(&Record), F(&F) {}
-
- /// Construct an ASTRecordReader that uses the same encoding scheme as another
- /// ASTRecordReader.
- ASTRecordReader(ASTRecordReader &Parent)
- : Reader(Parent.Reader), Record(Parent.Record), F(Parent.F) {}
+ ASTRecordReader(ASTReader &Reader, ModuleFile &F)
+ : Reader(&Reader), F(&F) {}
- /// \brief The length of this record.
- size_t size() const { return Record->size(); }
- /// \brief An arbitrary index in this record.
- const uint64_t &operator[](size_t N) { return (*Record)[N]; }
- /// \brief The last element in this record.
- const uint64_t &back() const { return Record->back(); }
+ /// \brief Reads a record with id AbbrevID from Cursor, resetting the
+ /// internal state.
+ unsigned readRecord(llvm::BitstreamCursor &Cursor, unsigned AbbrevID);
/// \brief Is this a module file for a module (rather than a PCH or similar).
bool isModule() const { return F->isModule(); }
@@ -2225,6 +2219,25 @@ public:
/// \brief Retrieve the AST context that this AST reader supplements.
ASTContext &getContext() { return Reader->getContext(); }
+ /// \brief The current position in this record.
+ unsigned getIdx() const { return Idx; }
+ /// \brief The length of this record.
+ size_t size() const { return Record.size(); }
+
+ /// \brief An arbitrary index in this record.
+ const uint64_t &operator[](size_t N) { return Record[N]; }
+ /// \brief The last element in this record.
+ const uint64_t &back() const { return Record.back(); }
+
+ /// \brief Returns the current value in this record, and advances to the
+ /// next value.
+ const uint64_t &readInt() { return Record[Idx++]; }
+ /// \brief Returns the current value in this record, without advancing.
+ const uint64_t &peekInt() { return Record[Idx]; }
+
+ /// \brief Skips the specified number of values.
+ void skipInts(unsigned N) { Idx += N; }
+
/// \brief Retrieve the global submodule ID its local ID number.
serialization::SubmoduleID
getGlobalSubmoduleID(unsigned LocalID) {
@@ -2250,9 +2263,8 @@ public:
}
void readExceptionSpec(SmallVectorImpl<QualType> &ExceptionStorage,
- FunctionProtoType::ExceptionSpecInfo &ESI,
- unsigned &Index) {
- return Reader->readExceptionSpec(*F, ExceptionStorage, ESI, *Record, Index);
+ FunctionProtoType::ExceptionSpecInfo &ESI) {
+ return Reader->readExceptionSpec(*F, ExceptionStorage, ESI, Record, Idx);
}
/// \brief Get the global offset corresponding to a local offset.
@@ -2275,24 +2287,24 @@ public:
/// \brief Reads a TemplateArgumentLocInfo appropriate for the
/// given TemplateArgument kind, advancing Idx.
TemplateArgumentLocInfo
- GetTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind, unsigned &Idx) {
- return Reader->GetTemplateArgumentLocInfo(*F, Kind, *Record, Idx);
+ GetTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind) {
+ return Reader->GetTemplateArgumentLocInfo(*F, Kind, Record, Idx);
}
/// \brief Reads a TemplateArgumentLoc, advancing Idx.
TemplateArgumentLoc
- ReadTemplateArgumentLoc(unsigned &Idx) {
- return Reader->ReadTemplateArgumentLoc(*F, *Record, Idx);
+ ReadTemplateArgumentLoc() {
+ return Reader->ReadTemplateArgumentLoc(*F, Record, Idx);
}
const ASTTemplateArgumentListInfo*
- ReadASTTemplateArgumentListInfo(unsigned &Idx) {
- return Reader->ReadASTTemplateArgumentListInfo(*F, *Record, Idx);
+ ReadASTTemplateArgumentListInfo() {
+ return Reader->ReadASTTemplateArgumentListInfo(*F, Record, Idx);
}
/// \brief Reads a declarator info from the given record, advancing Idx.
- TypeSourceInfo *GetTypeSourceInfo(unsigned &Idx) {
- return Reader->GetTypeSourceInfo(*F, *Record, Idx);
+ TypeSourceInfo *GetTypeSourceInfo() {
+ return Reader->GetTypeSourceInfo(*F, Record, Idx);
}
/// \brief Map a local type ID within a given AST file to a global type ID.
@@ -2301,21 +2313,21 @@ public:
}
/// \brief Read a type from the current position in the record.
- QualType readType(unsigned &Idx) {
- return Reader->readType(*F, *Record, Idx);
+ QualType readType() {
+ return Reader->readType(*F, Record, Idx);
}
/// \brief Reads a declaration ID from the given position in this record.
///
/// \returns The declaration ID read from the record, adjusted to a global ID.
- serialization::DeclID ReadDeclID(unsigned &Idx) {
- return Reader->ReadDeclID(*F, *Record, Idx);
+ serialization::DeclID ReadDeclID() {
+ return Reader->ReadDeclID(*F, Record, Idx);
}
/// \brief Reads a declaration from the given position in a record in the
/// given module, advancing Idx.
- Decl *ReadDecl(unsigned &Idx) {
- return Reader->ReadDecl(*F, *Record, Idx);
+ Decl *ReadDecl() {
+ return Reader->ReadDecl(*F, Record, Idx);
}
/// \brief Reads a declaration from the given position in the record,
@@ -2324,133 +2336,131 @@ public:
/// \returns The declaration read from this location, casted to the given
/// result type.
template<typename T>
- T *ReadDeclAs(unsigned &Idx) {
- return Reader->ReadDeclAs<T>(*F, *Record, Idx);
+ T *ReadDeclAs() {
+ return Reader->ReadDeclAs<T>(*F, Record, Idx);
}
- IdentifierInfo *GetIdentifierInfo(unsigned &Idx) {
- return Reader->GetIdentifierInfo(*F, *Record, Idx);
+ IdentifierInfo *GetIdentifierInfo() {
+ return Reader->GetIdentifierInfo(*F, Record, Idx);
}
/// \brief Read a selector from the Record, advancing Idx.
- Selector ReadSelector(unsigned &Idx) {
- return Reader->ReadSelector(*F, *Record, Idx);
+ Selector ReadSelector() {
+ return Reader->ReadSelector(*F, Record, Idx);
}
/// \brief Read a declaration name, advancing Idx.
- DeclarationName ReadDeclarationName(unsigned &Idx) {
- return Reader->ReadDeclarationName(*F, *Record, Idx);
+ DeclarationName ReadDeclarationName() {
+ return Reader->ReadDeclarationName(*F, Record, Idx);
}
- void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name,
- unsigned &Idx) {
- return Reader->ReadDeclarationNameLoc(*F, DNLoc, Name, *Record, Idx);
+ void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name) {
+ return Reader->ReadDeclarationNameLoc(*F, DNLoc, Name, Record, Idx);
}
- void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo, unsigned &Idx) {
- return Reader->ReadDeclarationNameInfo(*F, NameInfo, *Record, Idx);
+ void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo) {
+ return Reader->ReadDeclarationNameInfo(*F, NameInfo, Record, Idx);
}
- void ReadQualifierInfo(QualifierInfo &Info, unsigned &Idx) {
- return Reader->ReadQualifierInfo(*F, Info, *Record, Idx);
+ void ReadQualifierInfo(QualifierInfo &Info) {
+ return Reader->ReadQualifierInfo(*F, Info, Record, Idx);
}
- NestedNameSpecifier *ReadNestedNameSpecifier(unsigned &Idx) {
- return Reader->ReadNestedNameSpecifier(*F, *Record, Idx);
+ NestedNameSpecifier *ReadNestedNameSpecifier() {
+ return Reader->ReadNestedNameSpecifier(*F, Record, Idx);
}
- NestedNameSpecifierLoc ReadNestedNameSpecifierLoc(unsigned &Idx) {
- return Reader->ReadNestedNameSpecifierLoc(*F, *Record, Idx);
+ NestedNameSpecifierLoc ReadNestedNameSpecifierLoc() {
+ return Reader->ReadNestedNameSpecifierLoc(*F, Record, Idx);
}
/// \brief Read a template name, advancing Idx.
- TemplateName ReadTemplateName(unsigned &Idx) {
- return Reader->ReadTemplateName(*F, *Record, Idx);
+ TemplateName ReadTemplateName() {
+ return Reader->ReadTemplateName(*F, Record, Idx);
}
/// \brief Read a template argument, advancing Idx.
- TemplateArgument ReadTemplateArgument(unsigned &Idx,
- bool Canonicalize = false) {
- return Reader->ReadTemplateArgument(*F, *Record, Idx, Canonicalize);
+ TemplateArgument ReadTemplateArgument(bool Canonicalize = false) {
+ return Reader->ReadTemplateArgument(*F, Record, Idx, Canonicalize);
}
/// \brief Read a template parameter list, advancing Idx.
- TemplateParameterList *ReadTemplateParameterList(unsigned &Idx) {
- return Reader->ReadTemplateParameterList(*F, *Record, Idx);
+ TemplateParameterList *ReadTemplateParameterList() {
+ return Reader->ReadTemplateParameterList(*F, Record, Idx);
}
/// \brief Read a template argument array, advancing Idx.
void ReadTemplateArgumentList(SmallVectorImpl<TemplateArgument> &TemplArgs,
- unsigned &Idx, bool Canonicalize = false) {
- return Reader->ReadTemplateArgumentList(TemplArgs, *F, *Record, Idx,
+ bool Canonicalize = false) {
+ return Reader->ReadTemplateArgumentList(TemplArgs, *F, Record, Idx,
Canonicalize);
}
/// \brief Read a UnresolvedSet structure, advancing Idx.
- void ReadUnresolvedSet(LazyASTUnresolvedSet &Set, unsigned &Idx) {
- return Reader->ReadUnresolvedSet(*F, Set, *Record, Idx);
+ void ReadUnresolvedSet(LazyASTUnresolvedSet &Set) {
+ return Reader->ReadUnresolvedSet(*F, Set, Record, Idx);
}
/// \brief Read a C++ base specifier, advancing Idx.
- CXXBaseSpecifier ReadCXXBaseSpecifier(unsigned &Idx) {
- return Reader->ReadCXXBaseSpecifier(*F, *Record, Idx);
+ CXXBaseSpecifier ReadCXXBaseSpecifier() {
+ return Reader->ReadCXXBaseSpecifier(*F, Record, Idx);
}
/// \brief Read a CXXCtorInitializer array, advancing Idx.
- CXXCtorInitializer **ReadCXXCtorInitializers(unsigned &Idx) {
- return Reader->ReadCXXCtorInitializers(*F, *Record, Idx);
+ CXXCtorInitializer **ReadCXXCtorInitializers() {
+ return Reader->ReadCXXCtorInitializers(*F, Record, Idx);
}
- CXXTemporary *ReadCXXTemporary(unsigned &Idx) {
- return Reader->ReadCXXTemporary(*F, *Record, Idx);
+ CXXTemporary *ReadCXXTemporary() {
+ return Reader->ReadCXXTemporary(*F, Record, Idx);
}
/// \brief Read a source location, advancing Idx.
- SourceLocation ReadSourceLocation(unsigned &Idx) {
- return Reader->ReadSourceLocation(*F, *Record, Idx);
+ SourceLocation ReadSourceLocation() {
+ return Reader->ReadSourceLocation(*F, Record, Idx);
}
/// \brief Read a source range, advancing Idx.
- SourceRange ReadSourceRange(unsigned &Idx) {
- return Reader->ReadSourceRange(*F, *Record, Idx);
+ SourceRange ReadSourceRange() {
+ return Reader->ReadSourceRange(*F, Record, Idx);
}
/// \brief Read an integral value, advancing Idx.
- llvm::APInt ReadAPInt(unsigned &Idx) {
- return Reader->ReadAPInt(*Record, Idx);
+ llvm::APInt ReadAPInt() {
+ return Reader->ReadAPInt(Record, Idx);
}
/// \brief Read a signed integral value, advancing Idx.
- llvm::APSInt ReadAPSInt(unsigned &Idx) {
- return Reader->ReadAPSInt(*Record, Idx);
+ llvm::APSInt ReadAPSInt() {
+ return Reader->ReadAPSInt(Record, Idx);
}
/// \brief Read a floating-point value, advancing Idx.
- llvm::APFloat ReadAPFloat(const llvm::fltSemantics &Sem, unsigned &Idx) {
- return Reader->ReadAPFloat(*Record, Sem,Idx);
+ llvm::APFloat ReadAPFloat(const llvm::fltSemantics &Sem) {
+ return Reader->ReadAPFloat(Record, Sem,Idx);
}
/// \brief Read a string, advancing Idx.
- std::string ReadString(unsigned &Idx) {
- return Reader->ReadString(*Record, Idx);
+ std::string ReadString() {
+ return Reader->ReadString(Record, Idx);
}
/// \brief Read a path, advancing Idx.
- std::string ReadPath(unsigned &Idx) {
- return Reader->ReadPath(*F, *Record, Idx);
+ std::string ReadPath() {
+ return Reader->ReadPath(*F, Record, Idx);
}
/// \brief Read a version tuple, advancing Idx.
- VersionTuple ReadVersionTuple(unsigned &Idx) {
- return ASTReader::ReadVersionTuple(*Record, Idx);
+ VersionTuple ReadVersionTuple() {
+ return ASTReader::ReadVersionTuple(Record, Idx);
}
/// \brief Reads attributes from the current stream position, advancing Idx.
- void ReadAttributes(AttrVec &Attrs, unsigned &Idx) {
- return Reader->ReadAttributes(*F, Attrs, *Record, Idx);
+ void ReadAttributes(AttrVec &Attrs) {
+ return Reader->ReadAttributes(*F, Attrs, Record, Idx);
}
/// \brief Reads a token out of a record, advancing Idx.
- Token ReadToken(unsigned &Idx) {
- return Reader->ReadToken(*F, *Record, Idx);
+ Token ReadToken() {
+ return Reader->ReadToken(*F, Record, Idx);
}
void RecordSwitchCaseID(SwitchCase *SC, unsigned ID) {
@@ -2461,7 +2471,6 @@ public:
SwitchCase *getSwitchCaseWithID(unsigned ID) {
return Reader->getSwitchCaseWithID(ID);
}
-
};
/// \brief Helper class that saves the current stream position and
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=290217&r1=290216&r2=290217&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Dec 20 18:17:49 2016
@@ -5866,17 +5866,27 @@ void ASTReader::readExceptionSpec(Module
}
class clang::TypeLocReader : public TypeLocVisitor<TypeLocReader> {
- ASTRecordReader Reader;
+ ModuleFile *F;
+ ASTReader *Reader;
+ const ASTReader::RecordData &Record;
unsigned &Idx;
SourceLocation ReadSourceLocation() {
- return Reader.ReadSourceLocation(Idx);
+ return Reader->ReadSourceLocation(*F, Record, Idx);
+ }
+
+ TypeSourceInfo *GetTypeSourceInfo() {
+ return Reader->GetTypeSourceInfo(*F, Record, Idx);
+ }
+
+ NestedNameSpecifierLoc ReadNestedNameSpecifierLoc() {
+ return Reader->ReadNestedNameSpecifierLoc(*F, Record, Idx);
}
public:
- TypeLocReader(ASTReader &Reader, ModuleFile &F,
+ TypeLocReader(ModuleFile &F, ASTReader &Reader,
const ASTReader::RecordData &Record, unsigned &Idx)
- : Reader(Reader, Record, F), Idx(Idx) {}
+ : F(&F), Reader(&Reader), Record(Record), Idx(Idx) {}
// We want compile-time assurance that we've enumerated all of
// these, so unfortunately we have to declare them first, then
@@ -5897,10 +5907,10 @@ void TypeLocReader::VisitQualifiedTypeLo
void TypeLocReader::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {
TL.setBuiltinLoc(ReadSourceLocation());
if (TL.needsExtraLocalData()) {
- TL.setWrittenTypeSpec(static_cast<DeclSpec::TST>(Reader[Idx++]));
- TL.setWrittenSignSpec(static_cast<DeclSpec::TSS>(Reader[Idx++]));
- TL.setWrittenWidthSpec(static_cast<DeclSpec::TSW>(Reader[Idx++]));
- TL.setModeAttr(Reader[Idx++]);
+ TL.setWrittenTypeSpec(static_cast<DeclSpec::TST>(Record[Idx++]));
+ TL.setWrittenSignSpec(static_cast<DeclSpec::TSS>(Record[Idx++]));
+ TL.setWrittenWidthSpec(static_cast<DeclSpec::TSW>(Record[Idx++]));
+ TL.setModeAttr(Record[Idx++]);
}
}
@@ -5934,14 +5944,14 @@ void TypeLocReader::VisitRValueReference
void TypeLocReader::VisitMemberPointerTypeLoc(MemberPointerTypeLoc TL) {
TL.setStarLoc(ReadSourceLocation());
- TL.setClassTInfo(Reader.GetTypeSourceInfo(Idx));
+ TL.setClassTInfo(GetTypeSourceInfo());
}
void TypeLocReader::VisitArrayTypeLoc(ArrayTypeLoc TL) {
TL.setLBracketLoc(ReadSourceLocation());
TL.setRBracketLoc(ReadSourceLocation());
- if (Reader[Idx++])
- TL.setSizeExpr(Reader.ReadExpr());
+ if (Record[Idx++])
+ TL.setSizeExpr(Reader->ReadExpr(*F));
else
TL.setSizeExpr(nullptr);
}
@@ -5982,7 +5992,7 @@ void TypeLocReader::VisitFunctionTypeLoc
TL.setRParenLoc(ReadSourceLocation());
TL.setLocalRangeEnd(ReadSourceLocation());
for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i) {
- TL.setParam(i, Reader.ReadDeclAs<ParmVarDecl>(Idx));
+ TL.setParam(i, Reader->ReadDeclAs<ParmVarDecl>(*F, Record, Idx));
}
}
@@ -6008,7 +6018,7 @@ void TypeLocReader::VisitTypeOfTypeLoc(T
TL.setTypeofLoc(ReadSourceLocation());
TL.setLParenLoc(ReadSourceLocation());
TL.setRParenLoc(ReadSourceLocation());
- TL.setUnderlyingTInfo(Reader.GetTypeSourceInfo(Idx));
+ TL.setUnderlyingTInfo(GetTypeSourceInfo());
}
void TypeLocReader::VisitDecltypeTypeLoc(DecltypeTypeLoc TL) {
TL.setNameLoc(ReadSourceLocation());
@@ -6018,7 +6028,7 @@ void TypeLocReader::VisitUnaryTransformT
TL.setKWLoc(ReadSourceLocation());
TL.setLParenLoc(ReadSourceLocation());
TL.setRParenLoc(ReadSourceLocation());
- TL.setUnderlyingTInfo(Reader.GetTypeSourceInfo(Idx));
+ TL.setUnderlyingTInfo(GetTypeSourceInfo());
}
void TypeLocReader::VisitAutoTypeLoc(AutoTypeLoc TL) {
@@ -6042,8 +6052,8 @@ void TypeLocReader::VisitAttributedTypeL
TL.setAttrOperandParensRange(range);
}
if (TL.hasAttrExprOperand()) {
- if (Reader[Idx++])
- TL.setAttrExprOperand(Reader.ReadExpr());
+ if (Record[Idx++])
+ TL.setAttrExprOperand(Reader->ReadExpr(*F));
else
TL.setAttrExprOperand(nullptr);
} else if (TL.hasAttrEnumOperand())
@@ -6069,9 +6079,10 @@ void TypeLocReader::VisitTemplateSpecial
TL.setLAngleLoc(ReadSourceLocation());
TL.setRAngleLoc(ReadSourceLocation());
for (unsigned i = 0, e = TL.getNumArgs(); i != e; ++i)
- TL.setArgLocInfo(i,
- Reader.GetTemplateArgumentLocInfo(TL.getTypePtr()->getArg(i).getKind(),
- Idx));
+ TL.setArgLocInfo(
+ i,
+ Reader->GetTemplateArgumentLocInfo(
+ *F, TL.getTypePtr()->getArg(i).getKind(), Record, Idx));
}
void TypeLocReader::VisitParenTypeLoc(ParenTypeLoc TL) {
TL.setLParenLoc(ReadSourceLocation());
@@ -6080,7 +6091,7 @@ void TypeLocReader::VisitParenTypeLoc(Pa
void TypeLocReader::VisitElaboratedTypeLoc(ElaboratedTypeLoc TL) {
TL.setElaboratedKeywordLoc(ReadSourceLocation());
- TL.setQualifierLoc(Reader.ReadNestedNameSpecifierLoc(Idx));
+ TL.setQualifierLoc(ReadNestedNameSpecifierLoc());
}
void TypeLocReader::VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) {
@@ -6089,22 +6100,23 @@ void TypeLocReader::VisitInjectedClassNa
void TypeLocReader::VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
TL.setElaboratedKeywordLoc(ReadSourceLocation());
- TL.setQualifierLoc(Reader.ReadNestedNameSpecifierLoc(Idx));
+ TL.setQualifierLoc(ReadNestedNameSpecifierLoc());
TL.setNameLoc(ReadSourceLocation());
}
void TypeLocReader::VisitDependentTemplateSpecializationTypeLoc(
DependentTemplateSpecializationTypeLoc TL) {
TL.setElaboratedKeywordLoc(ReadSourceLocation());
- TL.setQualifierLoc(Reader.ReadNestedNameSpecifierLoc(Idx));
+ TL.setQualifierLoc(ReadNestedNameSpecifierLoc());
TL.setTemplateKeywordLoc(ReadSourceLocation());
TL.setTemplateNameLoc(ReadSourceLocation());
TL.setLAngleLoc(ReadSourceLocation());
TL.setRAngleLoc(ReadSourceLocation());
for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I)
- TL.setArgLocInfo(I,
- Reader.GetTemplateArgumentLocInfo(TL.getTypePtr()->getArg(I).getKind(),
- Idx));
+ TL.setArgLocInfo(
+ I,
+ Reader->GetTemplateArgumentLocInfo(
+ *F, TL.getTypePtr()->getArg(I).getKind(), Record, Idx));
}
void TypeLocReader::VisitPackExpansionTypeLoc(PackExpansionTypeLoc TL) {
@@ -6125,11 +6137,11 @@ void TypeLocReader::VisitObjCTypeParamTy
}
void TypeLocReader::VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) {
- TL.setHasBaseTypeAsWritten(Reader[Idx++]);
+ TL.setHasBaseTypeAsWritten(Record[Idx++]);
TL.setTypeArgsLAngleLoc(ReadSourceLocation());
TL.setTypeArgsRAngleLoc(ReadSourceLocation());
for (unsigned i = 0, e = TL.getNumTypeArgs(); i != e; ++i)
- TL.setTypeArgTInfo(i, Reader.GetTypeSourceInfo(Idx));
+ TL.setTypeArgTInfo(i, GetTypeSourceInfo());
TL.setProtocolLAngleLoc(ReadSourceLocation());
TL.setProtocolRAngleLoc(ReadSourceLocation());
for (unsigned i = 0, e = TL.getNumProtocols(); i != e; ++i)
@@ -6150,15 +6162,15 @@ void TypeLocReader::VisitPipeTypeLoc(Pip
TL.setKWLoc(ReadSourceLocation());
}
-TypeSourceInfo *ASTReader::GetTypeSourceInfo(ModuleFile &F,
- const RecordData &Record,
- unsigned &Idx) {
+TypeSourceInfo *
+ASTReader::GetTypeSourceInfo(ModuleFile &F, const ASTReader::RecordData &Record,
+ unsigned &Idx) {
QualType InfoTy = readType(F, Record, Idx);
if (InfoTy.isNull())
return nullptr;
TypeSourceInfo *TInfo = getContext().CreateTypeSourceInfo(InfoTy);
- TypeLocReader TLR(*this, F, Record, Idx);
+ TypeLocReader TLR(F, *this, Record, Idx);
for (TypeLoc TL = TInfo->getTypeLoc(); !TL.isNull(); TL = TL.getNextTypeLoc())
TLR.Visit(TL);
return TInfo;
@@ -8939,3 +8951,10 @@ ASTReader::~ASTReader() {
IdentifierResolver &ASTReader::getIdResolver() {
return SemaObj ? SemaObj->IdResolver : DummyIdResolver;
}
+
+unsigned ASTRecordReader::readRecord(llvm::BitstreamCursor &Cursor,
+ unsigned AbbrevID) {
+ Idx = 0;
+ Record.clear();
+ return Cursor.readRecord(AbbrevID, Record);
+}
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=290217&r1=290216&r2=290217&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Tue Dec 20 18:17:49 2016
@@ -35,12 +35,11 @@ using namespace clang::serialization;
namespace clang {
class ASTDeclReader : public DeclVisitor<ASTDeclReader, void> {
ASTReader &Reader;
- ASTRecordReader Record;
+ ASTRecordReader &Record;
ASTReader::RecordLocation Loc;
const DeclID ThisDeclID;
const SourceLocation ThisDeclLoc;
typedef ASTReader::RecordData RecordData;
- unsigned &Idx;
TypeID TypeIDForTypeDecl;
unsigned AnonymousDeclNumber;
GlobalDeclID NamedDeclForTagDecl;
@@ -56,7 +55,7 @@ namespace clang {
uint64_t GetCurrentCursorOffset();
uint64_t ReadLocalOffset() {
- uint64_t LocalOffset = Record[Idx++];
+ uint64_t LocalOffset = Record.readInt();
assert(LocalOffset < Loc.Offset && "offset point after current record");
return LocalOffset ? Loc.Offset - LocalOffset : 0;
}
@@ -67,56 +66,52 @@ namespace clang {
}
SourceLocation ReadSourceLocation() {
- return Record.ReadSourceLocation(Idx);
+ return Record.ReadSourceLocation();
}
SourceRange ReadSourceRange() {
- return Record.ReadSourceRange(Idx);
+ return Record.ReadSourceRange();
}
TypeSourceInfo *GetTypeSourceInfo() {
- return Record.GetTypeSourceInfo(Idx);
+ return Record.GetTypeSourceInfo();
}
serialization::DeclID ReadDeclID() {
- return Record.ReadDeclID(Idx);
+ return Record.ReadDeclID();
}
std::string ReadString() {
- return Record.ReadString(Idx);
+ return Record.ReadString();
}
void ReadDeclIDList(SmallVectorImpl<DeclID> &IDs) {
- for (unsigned I = 0, Size = Record[Idx++]; I != Size; ++I)
+ for (unsigned I = 0, Size = Record.readInt(); I != Size; ++I)
IDs.push_back(ReadDeclID());
}
Decl *ReadDecl() {
- return Record.ReadDecl(Idx);
+ return Record.ReadDecl();
}
template<typename T>
T *ReadDeclAs() {
- return Record.ReadDeclAs<T>(Idx);
+ return Record.ReadDeclAs<T>();
}
void ReadQualifierInfo(QualifierInfo &Info) {
- Record.ReadQualifierInfo(Info, Idx);
+ Record.ReadQualifierInfo(Info);
}
void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name) {
- Record.ReadDeclarationNameLoc(DNLoc, Name, Idx);
- }
-
- void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo, unsigned &I) {
- Record.ReadDeclarationNameInfo(NameInfo, I);
+ Record.ReadDeclarationNameLoc(DNLoc, Name);
}
serialization::SubmoduleID readSubmoduleID() {
- if (Idx >= Record.size())
+ if (Record.getIdx() == Record.size())
return 0;
- return Record.getGlobalSubmoduleID(Record[Idx++]);
+ return Record.getGlobalSubmoduleID(Record.readInt());
}
Module *readModule() {
@@ -124,12 +119,10 @@ namespace clang {
}
void ReadCXXRecordDefinition(CXXRecordDecl *D, bool Update);
- void ReadCXXDefinitionData(struct CXXRecordDecl::DefinitionData &Data,
- unsigned &I);
+ void ReadCXXDefinitionData(struct CXXRecordDecl::DefinitionData &Data);
void MergeDefinitionData(CXXRecordDecl *D,
struct CXXRecordDecl::DefinitionData &&NewDD);
- void ReadObjCDefinitionData(struct ObjCInterfaceDecl::DefinitionData &Data,
- unsigned &I);
+ void ReadObjCDefinitionData(struct ObjCInterfaceDecl::DefinitionData &Data);
void MergeDefinitionData(ObjCInterfaceDecl *D,
struct ObjCInterfaceDecl::DefinitionData &&NewDD);
@@ -213,12 +206,12 @@ namespace clang {
FindExistingResult findExisting(NamedDecl *D);
public:
- ASTDeclReader(ASTReader &Reader, ASTReader::RecordLocation Loc,
- DeclID thisDeclID, SourceLocation ThisDeclLoc,
- const RecordData &Record, unsigned &Idx)
- : Reader(Reader), Record(Reader, Record, *Loc.F), Loc(Loc),
+ ASTDeclReader(ASTReader &Reader, ASTRecordReader &Record,
+ ASTReader::RecordLocation Loc,
+ DeclID thisDeclID, SourceLocation ThisDeclLoc)
+ : Reader(Reader), Record(Record), Loc(Loc),
ThisDeclID(thisDeclID), ThisDeclLoc(ThisDeclLoc),
- Idx(Idx), TypeIDForTypeDecl(0), NamedDeclForTagDecl(0),
+ TypeIDForTypeDecl(0), NamedDeclForTagDecl(0),
TypedefNameForLinkage(nullptr), HasPendingBody(false),
IsDeclMarkedUsed(false) {}
@@ -464,9 +457,9 @@ void ASTDeclReader::Visit(Decl *D) {
// We only read it if FD doesn't already have a body (e.g., from another
// module).
// FIXME: Can we diagnose ODR violations somehow?
- if (Record[Idx++]) {
+ if (Record.readInt()) {
if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
- CD->NumCtorInitializers = Record[Idx++];
+ CD->NumCtorInitializers = Record.readInt();
if (CD->NumCtorInitializers)
CD->CtorInitializers = ReadGlobalOffset();
}
@@ -505,22 +498,22 @@ void ASTDeclReader::VisitDecl(Decl *D) {
Reader.getContext());
}
D->setLocation(ThisDeclLoc);
- D->setInvalidDecl(Record[Idx++]);
- if (Record[Idx++]) { // hasAttrs
+ D->setInvalidDecl(Record.readInt());
+ if (Record.readInt()) { // hasAttrs
AttrVec Attrs;
- Record.ReadAttributes(Attrs, Idx);
+ Record.ReadAttributes(Attrs);
// Avoid calling setAttrs() directly because it uses Decl::getASTContext()
// internally which is unsafe during derialization.
D->setAttrsImpl(Attrs, Reader.getContext());
}
- D->setImplicit(Record[Idx++]);
- D->Used = Record[Idx++];
+ D->setImplicit(Record.readInt());
+ D->Used = Record.readInt();
IsDeclMarkedUsed |= D->Used;
- D->setReferenced(Record[Idx++]);
- D->setTopLevelDeclInObjCContainer(Record[Idx++]);
- D->setAccess((AccessSpecifier)Record[Idx++]);
+ D->setReferenced(Record.readInt());
+ D->setTopLevelDeclInObjCContainer(Record.readInt());
+ D->setAccess((AccessSpecifier)Record.readInt());
D->FromASTFile = true;
- D->setModulePrivate(Record[Idx++]);
+ D->setModulePrivate(Record.readInt());
D->Hidden = D->isModulePrivate();
// Determine whether this declaration is part of a (sub)module. If so, it
@@ -552,7 +545,7 @@ void ASTDeclReader::VisitDecl(Decl *D) {
void ASTDeclReader::VisitPragmaCommentDecl(PragmaCommentDecl *D) {
VisitDecl(D);
D->setLocation(ReadSourceLocation());
- D->CommentKind = (PragmaMSCommentKind)Record[Idx++];
+ D->CommentKind = (PragmaMSCommentKind)Record.readInt();
std::string Arg = ReadString();
memcpy(D->getTrailingObjects<char>(), Arg.data(), Arg.size());
D->getTrailingObjects<char>()[Arg.size()] = '\0';
@@ -578,15 +571,15 @@ void ASTDeclReader::VisitTranslationUnit
void ASTDeclReader::VisitNamedDecl(NamedDecl *ND) {
VisitDecl(ND);
- ND->setDeclName(Record.ReadDeclarationName(Idx));
- AnonymousDeclNumber = Record[Idx++];
+ ND->setDeclName(Record.ReadDeclarationName());
+ AnonymousDeclNumber = Record.readInt();
}
void ASTDeclReader::VisitTypeDecl(TypeDecl *TD) {
VisitNamedDecl(TD);
TD->setLocStart(ReadSourceLocation());
// Delay type reading until after we have fully initialized the decl.
- TypeIDForTypeDecl = Record.getGlobalTypeID(Record[Idx++]);
+ TypeIDForTypeDecl = Record.getGlobalTypeID(Record.readInt());
}
ASTDeclReader::RedeclarableResult
@@ -594,8 +587,8 @@ ASTDeclReader::VisitTypedefNameDecl(Type
RedeclarableResult Redecl = VisitRedeclarable(TD);
VisitTypeDecl(TD);
TypeSourceInfo *TInfo = GetTypeSourceInfo();
- if (Record[Idx++]) { // isModed
- QualType modedT = Record.readType(Idx);
+ if (Record.readInt()) { // isModed
+ QualType modedT = Record.readType();
TD->setModedTypeSourceInfo(TInfo, modedT);
} else
TD->setTypeSourceInfo(TInfo);
@@ -620,16 +613,16 @@ ASTDeclReader::RedeclarableResult ASTDec
RedeclarableResult Redecl = VisitRedeclarable(TD);
VisitTypeDecl(TD);
- TD->IdentifierNamespace = Record[Idx++];
- TD->setTagKind((TagDecl::TagKind)Record[Idx++]);
+ TD->IdentifierNamespace = Record.readInt();
+ TD->setTagKind((TagDecl::TagKind)Record.readInt());
if (!isa<CXXRecordDecl>(TD))
- TD->setCompleteDefinition(Record[Idx++]);
- TD->setEmbeddedInDeclarator(Record[Idx++]);
- TD->setFreeStanding(Record[Idx++]);
- TD->setCompleteDefinitionRequired(Record[Idx++]);
+ TD->setCompleteDefinition(Record.readInt());
+ TD->setEmbeddedInDeclarator(Record.readInt());
+ TD->setFreeStanding(Record.readInt());
+ TD->setCompleteDefinitionRequired(Record.readInt());
TD->setBraceRange(ReadSourceRange());
- switch (Record[Idx++]) {
+ switch (Record.readInt()) {
case 0:
break;
case 1: { // ExtInfo
@@ -640,7 +633,7 @@ ASTDeclReader::RedeclarableResult ASTDec
}
case 2: // TypedefNameForAnonDecl
NamedDeclForTagDecl = ReadDeclID();
- TypedefNameForLinkage = Record.GetIdentifierInfo(Idx);
+ TypedefNameForLinkage = Record.GetIdentifierInfo();
break;
default:
llvm_unreachable("unexpected tag info kind");
@@ -656,13 +649,13 @@ void ASTDeclReader::VisitEnumDecl(EnumDe
if (TypeSourceInfo *TI = GetTypeSourceInfo())
ED->setIntegerTypeSourceInfo(TI);
else
- ED->setIntegerType(Record.readType(Idx));
- ED->setPromotionType(Record.readType(Idx));
- ED->setNumPositiveBits(Record[Idx++]);
- ED->setNumNegativeBits(Record[Idx++]);
- ED->IsScoped = Record[Idx++];
- ED->IsScopedUsingClassTag = Record[Idx++];
- ED->IsFixed = Record[Idx++];
+ ED->setIntegerType(Record.readType());
+ ED->setPromotionType(Record.readType());
+ ED->setNumPositiveBits(Record.readInt());
+ ED->setNumNegativeBits(Record.readInt());
+ ED->IsScoped = Record.readInt();
+ ED->IsScopedUsingClassTag = Record.readInt();
+ ED->IsFixed = Record.readInt();
// If this is a definition subject to the ODR, and we already have a
// definition, merge this one into it.
@@ -690,7 +683,8 @@ void ASTDeclReader::VisitEnumDecl(EnumDe
}
if (EnumDecl *InstED = ReadDeclAs<EnumDecl>()) {
- TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++];
+ TemplateSpecializationKind TSK =
+ (TemplateSpecializationKind)Record.readInt();
SourceLocation POI = ReadSourceLocation();
ED->setInstantiationOfMemberEnum(Reader.getContext(), InstED, TSK);
ED->getMemberSpecializationInfo()->setPointOfInstantiation(POI);
@@ -700,30 +694,30 @@ void ASTDeclReader::VisitEnumDecl(EnumDe
ASTDeclReader::RedeclarableResult
ASTDeclReader::VisitRecordDeclImpl(RecordDecl *RD) {
RedeclarableResult Redecl = VisitTagDecl(RD);
- RD->setHasFlexibleArrayMember(Record[Idx++]);
- RD->setAnonymousStructOrUnion(Record[Idx++]);
- RD->setHasObjectMember(Record[Idx++]);
- RD->setHasVolatileMember(Record[Idx++]);
+ RD->setHasFlexibleArrayMember(Record.readInt());
+ RD->setAnonymousStructOrUnion(Record.readInt());
+ RD->setHasObjectMember(Record.readInt());
+ RD->setHasVolatileMember(Record.readInt());
return Redecl;
}
void ASTDeclReader::VisitValueDecl(ValueDecl *VD) {
VisitNamedDecl(VD);
- VD->setType(Record.readType(Idx));
+ VD->setType(Record.readType());
}
void ASTDeclReader::VisitEnumConstantDecl(EnumConstantDecl *ECD) {
VisitValueDecl(ECD);
- if (Record[Idx++])
+ if (Record.readInt())
ECD->setInitExpr(Record.ReadExpr());
- ECD->setInitVal(Record.ReadAPSInt(Idx));
+ ECD->setInitVal(Record.ReadAPSInt());
mergeMergeable(ECD);
}
void ASTDeclReader::VisitDeclaratorDecl(DeclaratorDecl *DD) {
VisitValueDecl(DD);
DD->setInnerLocStart(ReadSourceLocation());
- if (Record[Idx++]) { // hasExtInfo
+ if (Record.readInt()) { // hasExtInfo
DeclaratorDecl::ExtInfo *Info
= new (Reader.getContext()) DeclaratorDecl::ExtInfo();
ReadQualifierInfo(*Info);
@@ -736,30 +730,30 @@ void ASTDeclReader::VisitFunctionDecl(Fu
VisitDeclaratorDecl(FD);
ReadDeclarationNameLoc(FD->DNLoc, FD->getDeclName());
- FD->IdentifierNamespace = Record[Idx++];
+ FD->IdentifierNamespace = Record.readInt();
// FunctionDecl's body is handled last at ASTDeclReader::Visit,
// after everything else is read.
- FD->SClass = (StorageClass)Record[Idx++];
- FD->IsInline = Record[Idx++];
- FD->IsInlineSpecified = Record[Idx++];
- FD->IsVirtualAsWritten = Record[Idx++];
- FD->IsPure = Record[Idx++];
- FD->HasInheritedPrototype = Record[Idx++];
- FD->HasWrittenPrototype = Record[Idx++];
- FD->IsDeleted = Record[Idx++];
- FD->IsTrivial = Record[Idx++];
- FD->IsDefaulted = Record[Idx++];
- FD->IsExplicitlyDefaulted = Record[Idx++];
- FD->HasImplicitReturnZero = Record[Idx++];
- FD->IsConstexpr = Record[Idx++];
- FD->HasSkippedBody = Record[Idx++];
- FD->IsLateTemplateParsed = Record[Idx++];
- FD->setCachedLinkage(Linkage(Record[Idx++]));
+ FD->SClass = (StorageClass)Record.readInt();
+ FD->IsInline = Record.readInt();
+ FD->IsInlineSpecified = Record.readInt();
+ FD->IsVirtualAsWritten = Record.readInt();
+ FD->IsPure = Record.readInt();
+ FD->HasInheritedPrototype = Record.readInt();
+ FD->HasWrittenPrototype = Record.readInt();
+ FD->IsDeleted = Record.readInt();
+ FD->IsTrivial = Record.readInt();
+ FD->IsDefaulted = Record.readInt();
+ FD->IsExplicitlyDefaulted = Record.readInt();
+ FD->HasImplicitReturnZero = Record.readInt();
+ FD->IsConstexpr = Record.readInt();
+ FD->HasSkippedBody = Record.readInt();
+ FD->IsLateTemplateParsed = Record.readInt();
+ FD->setCachedLinkage(Linkage(Record.readInt()));
FD->EndRangeLoc = ReadSourceLocation();
- switch ((FunctionDecl::TemplatedKind)Record[Idx++]) {
+ switch ((FunctionDecl::TemplatedKind)Record.readInt()) {
case FunctionDecl::TK_NonTemplate:
mergeRedeclarable(FD, Redecl);
break;
@@ -769,7 +763,8 @@ void ASTDeclReader::VisitFunctionDecl(Fu
break;
case FunctionDecl::TK_MemberSpecialization: {
FunctionDecl *InstFD = ReadDeclAs<FunctionDecl>();
- TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++];
+ TemplateSpecializationKind TSK =
+ (TemplateSpecializationKind)Record.readInt();
SourceLocation POI = ReadSourceLocation();
FD->setInstantiationOfMemberFunction(Reader.getContext(), InstFD, TSK);
FD->getMemberSpecializationInfo()->setPointOfInstantiation(POI);
@@ -778,22 +773,22 @@ void ASTDeclReader::VisitFunctionDecl(Fu
}
case FunctionDecl::TK_FunctionTemplateSpecialization: {
FunctionTemplateDecl *Template = ReadDeclAs<FunctionTemplateDecl>();
- TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++];
+ TemplateSpecializationKind TSK =
+ (TemplateSpecializationKind)Record.readInt();
// Template arguments.
SmallVector<TemplateArgument, 8> TemplArgs;
- Record.ReadTemplateArgumentList(TemplArgs, Idx,
- /*Canonicalize*/ true);
+ Record.ReadTemplateArgumentList(TemplArgs, /*Canonicalize*/ true);
// Template args as written.
SmallVector<TemplateArgumentLoc, 8> TemplArgLocs;
SourceLocation LAngleLoc, RAngleLoc;
- bool HasTemplateArgumentsAsWritten = Record[Idx++];
+ bool HasTemplateArgumentsAsWritten = Record.readInt();
if (HasTemplateArgumentsAsWritten) {
- unsigned NumTemplateArgLocs = Record[Idx++];
+ unsigned NumTemplateArgLocs = Record.readInt();
TemplArgLocs.reserve(NumTemplateArgLocs);
for (unsigned i=0; i != NumTemplateArgLocs; ++i)
- TemplArgLocs.push_back(Record.ReadTemplateArgumentLoc(Idx));
+ TemplArgLocs.push_back(Record.ReadTemplateArgumentLoc());
LAngleLoc = ReadSourceLocation();
RAngleLoc = ReadSourceLocation();
@@ -843,15 +838,15 @@ void ASTDeclReader::VisitFunctionDecl(Fu
case FunctionDecl::TK_DependentFunctionTemplateSpecialization: {
// Templates.
UnresolvedSet<8> TemplDecls;
- unsigned NumTemplates = Record[Idx++];
+ unsigned NumTemplates = Record.readInt();
while (NumTemplates--)
TemplDecls.addDecl(ReadDeclAs<NamedDecl>());
// Templates args.
TemplateArgumentListInfo TemplArgs;
- unsigned NumArgs = Record[Idx++];
+ unsigned NumArgs = Record.readInt();
while (NumArgs--)
- TemplArgs.addArgument(Record.ReadTemplateArgumentLoc(Idx));
+ TemplArgs.addArgument(Record.ReadTemplateArgumentLoc());
TemplArgs.setLAngleLoc(ReadSourceLocation());
TemplArgs.setRAngleLoc(ReadSourceLocation());
@@ -864,7 +859,7 @@ void ASTDeclReader::VisitFunctionDecl(Fu
}
// Read in the parameters.
- unsigned NumParams = Record[Idx++];
+ unsigned NumParams = Record.readInt();
SmallVector<ParmVarDecl *, 16> Params;
Params.reserve(NumParams);
for (unsigned I = 0; I != NumParams; ++I)
@@ -874,7 +869,7 @@ void ASTDeclReader::VisitFunctionDecl(Fu
void ASTDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) {
VisitNamedDecl(MD);
- if (Record[Idx++]) {
+ if (Record.readInt()) {
// Load the body on-demand. Most clients won't care, because method
// definitions rarely show up in headers.
Reader.PendingBodies[MD] = GetCurrentCursorOffset();
@@ -882,33 +877,33 @@ void ASTDeclReader::VisitObjCMethodDecl(
MD->setSelfDecl(ReadDeclAs<ImplicitParamDecl>());
MD->setCmdDecl(ReadDeclAs<ImplicitParamDecl>());
}
- MD->setInstanceMethod(Record[Idx++]);
- MD->setVariadic(Record[Idx++]);
- MD->setPropertyAccessor(Record[Idx++]);
- MD->setDefined(Record[Idx++]);
- MD->IsOverriding = Record[Idx++];
- MD->HasSkippedBody = Record[Idx++];
+ MD->setInstanceMethod(Record.readInt());
+ MD->setVariadic(Record.readInt());
+ MD->setPropertyAccessor(Record.readInt());
+ MD->setDefined(Record.readInt());
+ MD->IsOverriding = Record.readInt();
+ MD->HasSkippedBody = Record.readInt();
- MD->IsRedeclaration = Record[Idx++];
- MD->HasRedeclaration = Record[Idx++];
+ MD->IsRedeclaration = Record.readInt();
+ MD->HasRedeclaration = Record.readInt();
if (MD->HasRedeclaration)
Reader.getContext().setObjCMethodRedeclaration(MD,
ReadDeclAs<ObjCMethodDecl>());
- MD->setDeclImplementation((ObjCMethodDecl::ImplementationControl)Record[Idx++]);
- MD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]);
- MD->SetRelatedResultType(Record[Idx++]);
- MD->setReturnType(Record.readType(Idx));
+ MD->setDeclImplementation((ObjCMethodDecl::ImplementationControl)Record.readInt());
+ MD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record.readInt());
+ MD->SetRelatedResultType(Record.readInt());
+ MD->setReturnType(Record.readType());
MD->setReturnTypeSourceInfo(GetTypeSourceInfo());
MD->DeclEndLoc = ReadSourceLocation();
- unsigned NumParams = Record[Idx++];
+ unsigned NumParams = Record.readInt();
SmallVector<ParmVarDecl *, 16> Params;
Params.reserve(NumParams);
for (unsigned I = 0; I != NumParams; ++I)
Params.push_back(ReadDeclAs<ParmVarDecl>());
- MD->SelLocsKind = Record[Idx++];
- unsigned NumStoredSelLocs = Record[Idx++];
+ MD->SelLocsKind = Record.readInt();
+ unsigned NumStoredSelLocs = Record.readInt();
SmallVector<SourceLocation, 16> SelLocs;
SelLocs.reserve(NumStoredSelLocs);
for (unsigned i = 0; i != NumStoredSelLocs; ++i)
@@ -920,8 +915,8 @@ void ASTDeclReader::VisitObjCMethodDecl(
void ASTDeclReader::VisitObjCTypeParamDecl(ObjCTypeParamDecl *D) {
VisitTypedefNameDecl(D);
- D->Variance = Record[Idx++];
- D->Index = Record[Idx++];
+ D->Variance = Record.readInt();
+ D->Index = Record.readInt();
D->VarianceLoc = ReadSourceLocation();
D->ColonLoc = ReadSourceLocation();
}
@@ -933,7 +928,7 @@ void ASTDeclReader::VisitObjCContainerDe
}
ObjCTypeParamList *ASTDeclReader::ReadObjCTypeParamList() {
- unsigned numParams = Record[Idx++];
+ unsigned numParams = Record.readInt();
if (numParams == 0)
return nullptr;
@@ -955,15 +950,15 @@ ObjCTypeParamList *ASTDeclReader::ReadOb
}
void ASTDeclReader::ReadObjCDefinitionData(
- struct ObjCInterfaceDecl::DefinitionData &Data, unsigned &I) {
+ struct ObjCInterfaceDecl::DefinitionData &Data) {
// Read the superclass.
Data.SuperClassTInfo = GetTypeSourceInfo();
Data.EndLoc = ReadSourceLocation();
- Data.HasDesignatedInitializers = Record[Idx++];
+ Data.HasDesignatedInitializers = Record.readInt();
// Read the directly referenced protocols and their SourceLocations.
- unsigned NumProtocols = Record[Idx++];
+ unsigned NumProtocols = Record.readInt();
SmallVector<ObjCProtocolDecl *, 16> Protocols;
Protocols.reserve(NumProtocols);
for (unsigned I = 0; I != NumProtocols; ++I)
@@ -976,7 +971,7 @@ void ASTDeclReader::ReadObjCDefinitionDa
Reader.getContext());
// Read the transitive closure of protocols referenced by this class.
- NumProtocols = Record[Idx++];
+ NumProtocols = Record.readInt();
Protocols.clear();
Protocols.reserve(NumProtocols);
for (unsigned I = 0; I != NumProtocols; ++I)
@@ -993,15 +988,15 @@ void ASTDeclReader::MergeDefinitionData(
void ASTDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) {
RedeclarableResult Redecl = VisitRedeclarable(ID);
VisitObjCContainerDecl(ID);
- TypeIDForTypeDecl = Record.getGlobalTypeID(Record[Idx++]);
+ TypeIDForTypeDecl = Record.getGlobalTypeID(Record.readInt());
mergeRedeclarable(ID, Redecl);
ID->TypeParamList = ReadObjCTypeParamList();
- if (Record[Idx++]) {
+ if (Record.readInt()) {
// Read the definition.
ID->allocateDefinitionData();
- ReadObjCDefinitionData(ID->data(), Idx);
+ ReadObjCDefinitionData(ID->data());
ObjCInterfaceDecl *Canon = ID->getCanonicalDecl();
if (Canon->Data.getPointer()) {
// If we already have a definition, keep the definition invariant and
@@ -1029,10 +1024,10 @@ void ASTDeclReader::VisitObjCInterfaceDe
void ASTDeclReader::VisitObjCIvarDecl(ObjCIvarDecl *IVD) {
VisitFieldDecl(IVD);
- IVD->setAccessControl((ObjCIvarDecl::AccessControl)Record[Idx++]);
+ IVD->setAccessControl((ObjCIvarDecl::AccessControl)Record.readInt());
// This field will be built lazily.
IVD->setNextIvar(nullptr);
- bool synth = Record[Idx++];
+ bool synth = Record.readInt();
IVD->setSynthesize(synth);
}
@@ -1041,7 +1036,7 @@ void ASTDeclReader::VisitObjCProtocolDec
VisitObjCContainerDecl(PD);
mergeRedeclarable(PD, Redecl);
- if (Record[Idx++]) {
+ if (Record.readInt()) {
// Read the definition.
PD->allocateDefinitionData();
@@ -1049,7 +1044,7 @@ void ASTDeclReader::VisitObjCProtocolDec
// redeclarations will see it.
PD->getCanonicalDecl()->Data = PD->Data;
- unsigned NumProtoRefs = Record[Idx++];
+ unsigned NumProtoRefs = Record.readInt();
SmallVector<ObjCProtocolDecl *, 16> ProtoRefs;
ProtoRefs.reserve(NumProtoRefs);
for (unsigned I = 0; I != NumProtoRefs; ++I)
@@ -1085,7 +1080,7 @@ void ASTDeclReader::VisitObjCCategoryDec
CD->ClassInterface = ReadDeclAs<ObjCInterfaceDecl>();
CD->TypeParamList = ReadObjCTypeParamList();
- unsigned NumProtoRefs = Record[Idx++];
+ unsigned NumProtoRefs = Record.readInt();
SmallVector<ObjCProtocolDecl *, 16> ProtoRefs;
ProtoRefs.reserve(NumProtoRefs);
for (unsigned I = 0; I != NumProtoRefs; ++I)
@@ -1107,17 +1102,17 @@ void ASTDeclReader::VisitObjCPropertyDec
VisitNamedDecl(D);
D->setAtLoc(ReadSourceLocation());
D->setLParenLoc(ReadSourceLocation());
- QualType T = Record.readType(Idx);
+ QualType T = Record.readType();
TypeSourceInfo *TSI = GetTypeSourceInfo();
D->setType(T, TSI);
D->setPropertyAttributes(
- (ObjCPropertyDecl::PropertyAttributeKind)Record[Idx++]);
+ (ObjCPropertyDecl::PropertyAttributeKind)Record.readInt());
D->setPropertyAttributesAsWritten(
- (ObjCPropertyDecl::PropertyAttributeKind)Record[Idx++]);
+ (ObjCPropertyDecl::PropertyAttributeKind)Record.readInt());
D->setPropertyImplementation(
- (ObjCPropertyDecl::PropertyControl)Record[Idx++]);
- D->setGetterName(Record.ReadDeclarationName(Idx).getObjCSelector());
- D->setSetterName(Record.ReadDeclarationName(Idx).getObjCSelector());
+ (ObjCPropertyDecl::PropertyControl)Record.readInt());
+ D->setGetterName(Record.ReadDeclarationName().getObjCSelector());
+ D->setSetterName(Record.ReadDeclarationName().getObjCSelector());
D->setGetterMethodDecl(ReadDeclAs<ObjCMethodDecl>());
D->setSetterMethodDecl(ReadDeclAs<ObjCMethodDecl>());
D->setPropertyIvarDecl(ReadDeclAs<ObjCIvarDecl>());
@@ -1130,7 +1125,7 @@ void ASTDeclReader::VisitObjCImplDecl(Ob
void ASTDeclReader::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) {
VisitObjCImplDecl(D);
- D->setIdentifier(Record.GetIdentifierInfo(Idx));
+ D->setIdentifier(Record.GetIdentifierInfo());
D->CategoryNameLoc = ReadSourceLocation();
}
@@ -1140,9 +1135,9 @@ void ASTDeclReader::VisitObjCImplementat
D->SuperLoc = ReadSourceLocation();
D->setIvarLBraceLoc(ReadSourceLocation());
D->setIvarRBraceLoc(ReadSourceLocation());
- D->setHasNonZeroConstructors(Record[Idx++]);
- D->setHasDestructors(Record[Idx++]);
- D->NumIvarInitializers = Record[Idx++];
+ D->setHasNonZeroConstructors(Record.readInt());
+ D->setHasDestructors(Record.readInt());
+ D->NumIvarInitializers = Record.readInt();
if (D->NumIvarInitializers)
D->IvarInitializers = ReadGlobalOffset();
}
@@ -1159,14 +1154,13 @@ void ASTDeclReader::VisitObjCPropertyImp
void ASTDeclReader::VisitFieldDecl(FieldDecl *FD) {
VisitDeclaratorDecl(FD);
- FD->Mutable = Record[Idx++];
- if (int BitWidthOrInitializer = Record[Idx++]) {
+ FD->Mutable = Record.readInt();
+ if (int BitWidthOrInitializer = Record.readInt()) {
FD->InitStorage.setInt(
static_cast<FieldDecl::InitStorageKind>(BitWidthOrInitializer - 1));
if (FD->InitStorage.getInt() == FieldDecl::ISK_CapturedVLAType) {
// Read captured variable length array.
- FD->InitStorage.setPointer(
- Record.readType(Idx).getAsOpaquePtr());
+ FD->InitStorage.setPointer(Record.readType().getAsOpaquePtr());
} else {
FD->InitStorage.setPointer(Record.ReadExpr());
}
@@ -1180,14 +1174,14 @@ void ASTDeclReader::VisitFieldDecl(Field
void ASTDeclReader::VisitMSPropertyDecl(MSPropertyDecl *PD) {
VisitDeclaratorDecl(PD);
- PD->GetterId = Record.GetIdentifierInfo(Idx);
- PD->SetterId = Record.GetIdentifierInfo(Idx);
+ PD->GetterId = Record.GetIdentifierInfo();
+ PD->SetterId = Record.GetIdentifierInfo();
}
void ASTDeclReader::VisitIndirectFieldDecl(IndirectFieldDecl *FD) {
VisitValueDecl(FD);
- FD->ChainingSize = Record[Idx++];
+ FD->ChainingSize = Record.readInt();
assert(FD->ChainingSize >= 2 && "Anonymous chaining must be >= 2");
FD->Chaining = new (Reader.getContext())NamedDecl*[FD->ChainingSize];
@@ -1201,22 +1195,23 @@ ASTDeclReader::RedeclarableResult ASTDec
RedeclarableResult Redecl = VisitRedeclarable(VD);
VisitDeclaratorDecl(VD);
- VD->VarDeclBits.SClass = (StorageClass)Record[Idx++];
- VD->VarDeclBits.TSCSpec = Record[Idx++];
- VD->VarDeclBits.InitStyle = Record[Idx++];
+ VD->VarDeclBits.SClass = (StorageClass)Record.readInt();
+ VD->VarDeclBits.TSCSpec = Record.readInt();
+ VD->VarDeclBits.InitStyle = Record.readInt();
if (!isa<ParmVarDecl>(VD)) {
- VD->NonParmVarDeclBits.IsThisDeclarationADemotedDefinition = Record[Idx++];
- VD->NonParmVarDeclBits.ExceptionVar = Record[Idx++];
- VD->NonParmVarDeclBits.NRVOVariable = Record[Idx++];
- VD->NonParmVarDeclBits.CXXForRangeDecl = Record[Idx++];
- VD->NonParmVarDeclBits.ARCPseudoStrong = Record[Idx++];
- VD->NonParmVarDeclBits.IsInline = Record[Idx++];
- VD->NonParmVarDeclBits.IsInlineSpecified = Record[Idx++];
- VD->NonParmVarDeclBits.IsConstexpr = Record[Idx++];
- VD->NonParmVarDeclBits.IsInitCapture = Record[Idx++];
- VD->NonParmVarDeclBits.PreviousDeclInSameBlockScope = Record[Idx++];
+ VD->NonParmVarDeclBits.IsThisDeclarationADemotedDefinition =
+ Record.readInt();
+ VD->NonParmVarDeclBits.ExceptionVar = Record.readInt();
+ VD->NonParmVarDeclBits.NRVOVariable = Record.readInt();
+ VD->NonParmVarDeclBits.CXXForRangeDecl = Record.readInt();
+ VD->NonParmVarDeclBits.ARCPseudoStrong = Record.readInt();
+ VD->NonParmVarDeclBits.IsInline = Record.readInt();
+ VD->NonParmVarDeclBits.IsInlineSpecified = Record.readInt();
+ VD->NonParmVarDeclBits.IsConstexpr = Record.readInt();
+ VD->NonParmVarDeclBits.IsInitCapture = Record.readInt();
+ VD->NonParmVarDeclBits.PreviousDeclInSameBlockScope = Record.readInt();
}
- Linkage VarLinkage = Linkage(Record[Idx++]);
+ Linkage VarLinkage = Linkage(Record.readInt());
VD->setCachedLinkage(VarLinkage);
// Reconstruct the one piece of the IdentifierNamespace that we need.
@@ -1224,7 +1219,7 @@ ASTDeclReader::RedeclarableResult ASTDec
VD->getLexicalDeclContext()->isFunctionOrMethod())
VD->setLocalExternDecl();
- if (uint64_t Val = Record[Idx++]) {
+ if (uint64_t Val = Record.readInt()) {
VD->setInit(Record.ReadExpr());
if (Val > 1) { // IsInitKnownICE = 1, IsInitNotICE = 2, IsInitICE = 3
EvaluatedStmt *Eval = VD->ensureEvaluatedStmt();
@@ -1236,7 +1231,7 @@ ASTDeclReader::RedeclarableResult ASTDec
enum VarKind {
VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
};
- switch ((VarKind)Record[Idx++]) {
+ switch ((VarKind)Record.readInt()) {
case VarNotTemplate:
// Only true variables (not parameters or implicit parameters) can be
// merged; the other kinds are not really redeclarable at all.
@@ -1250,7 +1245,8 @@ ASTDeclReader::RedeclarableResult ASTDec
break;
case StaticDataMemberSpecialization: { // HasMemberSpecializationInfo.
VarDecl *Tmpl = ReadDeclAs<VarDecl>();
- TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++];
+ TemplateSpecializationKind TSK =
+ (TemplateSpecializationKind)Record.readInt();
SourceLocation POI = ReadSourceLocation();
Reader.getContext().setInstantiatedFromStaticDataMember(VD, Tmpl, TSK,POI);
mergeRedeclarable(VD, Redecl);
@@ -1267,10 +1263,10 @@ void ASTDeclReader::VisitImplicitParamDe
void ASTDeclReader::VisitParmVarDecl(ParmVarDecl *PD) {
VisitVarDecl(PD);
- unsigned isObjCMethodParam = Record[Idx++];
- unsigned scopeDepth = Record[Idx++];
- unsigned scopeIndex = Record[Idx++];
- unsigned declQualifier = Record[Idx++];
+ unsigned isObjCMethodParam = Record.readInt();
+ unsigned scopeDepth = Record.readInt();
+ unsigned scopeIndex = Record.readInt();
+ unsigned declQualifier = Record.readInt();
if (isObjCMethodParam) {
assert(scopeDepth == 0);
PD->setObjCMethodScopeInfo(scopeIndex);
@@ -1278,9 +1274,9 @@ void ASTDeclReader::VisitParmVarDecl(Par
} else {
PD->setScopeInfo(scopeDepth, scopeIndex);
}
- PD->ParmVarDeclBits.IsKNRPromoted = Record[Idx++];
- PD->ParmVarDeclBits.HasInheritedDefaultArg = Record[Idx++];
- if (Record[Idx++]) // hasUninstantiatedDefaultArg.
+ PD->ParmVarDeclBits.IsKNRPromoted = Record.readInt();
+ PD->ParmVarDeclBits.HasInheritedDefaultArg = Record.readInt();
+ if (Record.readInt()) // hasUninstantiatedDefaultArg.
PD->setUninstantiatedDefaultArg(Record.ReadExpr());
// FIXME: If this is a redeclaration of a function from another module, handle
@@ -1309,24 +1305,24 @@ void ASTDeclReader::VisitBlockDecl(Block
VisitDecl(BD);
BD->setBody(cast_or_null<CompoundStmt>(Record.ReadStmt()));
BD->setSignatureAsWritten(GetTypeSourceInfo());
- unsigned NumParams = Record[Idx++];
+ unsigned NumParams = Record.readInt();
SmallVector<ParmVarDecl *, 16> Params;
Params.reserve(NumParams);
for (unsigned I = 0; I != NumParams; ++I)
Params.push_back(ReadDeclAs<ParmVarDecl>());
BD->setParams(Params);
- BD->setIsVariadic(Record[Idx++]);
- BD->setBlockMissingReturnType(Record[Idx++]);
- BD->setIsConversionFromLambda(Record[Idx++]);
+ BD->setIsVariadic(Record.readInt());
+ BD->setBlockMissingReturnType(Record.readInt());
+ BD->setIsConversionFromLambda(Record.readInt());
- bool capturesCXXThis = Record[Idx++];
- unsigned numCaptures = Record[Idx++];
+ bool capturesCXXThis = Record.readInt();
+ unsigned numCaptures = Record.readInt();
SmallVector<BlockDecl::Capture, 16> captures;
captures.reserve(numCaptures);
for (unsigned i = 0; i != numCaptures; ++i) {
VarDecl *decl = ReadDeclAs<VarDecl>();
- unsigned flags = Record[Idx++];
+ unsigned flags = Record.readInt();
bool byRef = (flags & 1);
bool nested = (flags & 2);
Expr *copyExpr = ((flags & 4) ? Record.ReadExpr() : nullptr);
@@ -1338,8 +1334,8 @@ void ASTDeclReader::VisitBlockDecl(Block
void ASTDeclReader::VisitCapturedDecl(CapturedDecl *CD) {
VisitDecl(CD);
- unsigned ContextParamPos = Record[Idx++];
- CD->setNothrow(Record[Idx++] != 0);
+ unsigned ContextParamPos = Record.readInt();
+ CD->setNothrow(Record.readInt() != 0);
// Body is set by VisitCapturedStmt.
for (unsigned I = 0; I < CD->NumParams; ++I) {
if (I != ContextParamPos)
@@ -1351,7 +1347,7 @@ void ASTDeclReader::VisitCapturedDecl(Ca
void ASTDeclReader::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
VisitDecl(D);
- D->setLanguage((LinkageSpecDecl::LanguageIDs)Record[Idx++]);
+ D->setLanguage((LinkageSpecDecl::LanguageIDs)Record.readInt());
D->setExternLoc(ReadSourceLocation());
D->setRBraceLoc(ReadSourceLocation());
}
@@ -1369,7 +1365,7 @@ void ASTDeclReader::VisitLabelDecl(Label
void ASTDeclReader::VisitNamespaceDecl(NamespaceDecl *D) {
RedeclarableResult Redecl = VisitRedeclarable(D);
VisitNamedDecl(D);
- D->setInline(Record[Idx++]);
+ D->setInline(Record.readInt());
D->LocStart = ReadSourceLocation();
D->RBraceLoc = ReadSourceLocation();
@@ -1403,7 +1399,7 @@ void ASTDeclReader::VisitNamespaceAliasD
VisitNamedDecl(D);
D->NamespaceLoc = ReadSourceLocation();
D->IdentLoc = ReadSourceLocation();
- D->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx);
+ D->QualifierLoc = Record.ReadNestedNameSpecifierLoc();
D->Namespace = ReadDeclAs<NamedDecl>();
mergeRedeclarable(D, Redecl);
}
@@ -1411,10 +1407,10 @@ void ASTDeclReader::VisitNamespaceAliasD
void ASTDeclReader::VisitUsingDecl(UsingDecl *D) {
VisitNamedDecl(D);
D->setUsingLoc(ReadSourceLocation());
- D->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx);
+ D->QualifierLoc = Record.ReadNestedNameSpecifierLoc();
ReadDeclarationNameLoc(D->DNLoc, D->getDeclName());
D->FirstUsingShadow.setPointer(ReadDeclAs<UsingShadowDecl>());
- D->setTypename(Record[Idx++]);
+ D->setTypename(Record.readInt());
if (NamedDecl *Pattern = ReadDeclAs<NamedDecl>())
Reader.getContext().setInstantiatedFromUsingDecl(D, Pattern);
mergeMergeable(D);
@@ -1445,14 +1441,14 @@ void ASTDeclReader::VisitConstructorUsin
VisitUsingShadowDecl(D);
D->NominatedBaseClassShadowDecl = ReadDeclAs<ConstructorUsingShadowDecl>();
D->ConstructedBaseClassShadowDecl = ReadDeclAs<ConstructorUsingShadowDecl>();
- D->IsVirtual = Record[Idx++];
+ D->IsVirtual = Record.readInt();
}
void ASTDeclReader::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) {
VisitNamedDecl(D);
D->UsingLoc = ReadSourceLocation();
D->NamespaceLoc = ReadSourceLocation();
- D->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx);
+ D->QualifierLoc = Record.ReadNestedNameSpecifierLoc();
D->NominatedNamespace = ReadDeclAs<NamedDecl>();
D->CommonAncestor = ReadDeclAs<DeclContext>();
}
@@ -1460,7 +1456,7 @@ void ASTDeclReader::VisitUsingDirectiveD
void ASTDeclReader::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) {
VisitValueDecl(D);
D->setUsingLoc(ReadSourceLocation());
- D->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx);
+ D->QualifierLoc = Record.ReadNestedNameSpecifierLoc();
ReadDeclarationNameLoc(D->DNLoc, D->getDeclName());
D->EllipsisLoc = ReadSourceLocation();
mergeMergeable(D);
@@ -1470,66 +1466,65 @@ void ASTDeclReader::VisitUnresolvedUsing
UnresolvedUsingTypenameDecl *D) {
VisitTypeDecl(D);
D->TypenameLocation = ReadSourceLocation();
- D->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx);
+ D->QualifierLoc = Record.ReadNestedNameSpecifierLoc();
D->EllipsisLoc = ReadSourceLocation();
mergeMergeable(D);
}
void ASTDeclReader::ReadCXXDefinitionData(
- struct CXXRecordDecl::DefinitionData &Data,
- unsigned &Idx) {
+ struct CXXRecordDecl::DefinitionData &Data) {
// Note: the caller has deserialized the IsLambda bit already.
- Data.UserDeclaredConstructor = Record[Idx++];
- Data.UserDeclaredSpecialMembers = Record[Idx++];
- Data.Aggregate = Record[Idx++];
- Data.PlainOldData = Record[Idx++];
- Data.Empty = Record[Idx++];
- Data.Polymorphic = Record[Idx++];
- Data.Abstract = Record[Idx++];
- Data.IsStandardLayout = Record[Idx++];
- Data.HasNoNonEmptyBases = Record[Idx++];
- Data.HasPrivateFields = Record[Idx++];
- Data.HasProtectedFields = Record[Idx++];
- Data.HasPublicFields = Record[Idx++];
- Data.HasMutableFields = Record[Idx++];
- Data.HasVariantMembers = Record[Idx++];
- Data.HasOnlyCMembers = Record[Idx++];
- Data.HasInClassInitializer = Record[Idx++];
- Data.HasUninitializedReferenceMember = Record[Idx++];
- Data.HasUninitializedFields = Record[Idx++];
- Data.HasInheritedConstructor = Record[Idx++];
- Data.HasInheritedAssignment = Record[Idx++];
- Data.NeedOverloadResolutionForMoveConstructor = Record[Idx++];
- Data.NeedOverloadResolutionForMoveAssignment = Record[Idx++];
- Data.NeedOverloadResolutionForDestructor = Record[Idx++];
- Data.DefaultedMoveConstructorIsDeleted = Record[Idx++];
- Data.DefaultedMoveAssignmentIsDeleted = Record[Idx++];
- Data.DefaultedDestructorIsDeleted = Record[Idx++];
- Data.HasTrivialSpecialMembers = Record[Idx++];
- Data.DeclaredNonTrivialSpecialMembers = Record[Idx++];
- Data.HasIrrelevantDestructor = Record[Idx++];
- Data.HasConstexprNonCopyMoveConstructor = Record[Idx++];
- Data.HasDefaultedDefaultConstructor = Record[Idx++];
- Data.DefaultedDefaultConstructorIsConstexpr = Record[Idx++];
- Data.HasConstexprDefaultConstructor = Record[Idx++];
- Data.HasNonLiteralTypeFieldsOrBases = Record[Idx++];
- Data.ComputedVisibleConversions = Record[Idx++];
- Data.UserProvidedDefaultConstructor = Record[Idx++];
- Data.DeclaredSpecialMembers = Record[Idx++];
- Data.ImplicitCopyConstructorHasConstParam = Record[Idx++];
- Data.ImplicitCopyAssignmentHasConstParam = Record[Idx++];
- Data.HasDeclaredCopyConstructorWithConstParam = Record[Idx++];
- Data.HasDeclaredCopyAssignmentWithConstParam = Record[Idx++];
+ Data.UserDeclaredConstructor = Record.readInt();
+ Data.UserDeclaredSpecialMembers = Record.readInt();
+ Data.Aggregate = Record.readInt();
+ Data.PlainOldData = Record.readInt();
+ Data.Empty = Record.readInt();
+ Data.Polymorphic = Record.readInt();
+ Data.Abstract = Record.readInt();
+ Data.IsStandardLayout = Record.readInt();
+ Data.HasNoNonEmptyBases = Record.readInt();
+ Data.HasPrivateFields = Record.readInt();
+ Data.HasProtectedFields = Record.readInt();
+ Data.HasPublicFields = Record.readInt();
+ Data.HasMutableFields = Record.readInt();
+ Data.HasVariantMembers = Record.readInt();
+ Data.HasOnlyCMembers = Record.readInt();
+ Data.HasInClassInitializer = Record.readInt();
+ Data.HasUninitializedReferenceMember = Record.readInt();
+ Data.HasUninitializedFields = Record.readInt();
+ Data.HasInheritedConstructor = Record.readInt();
+ Data.HasInheritedAssignment = Record.readInt();
+ Data.NeedOverloadResolutionForMoveConstructor = Record.readInt();
+ Data.NeedOverloadResolutionForMoveAssignment = Record.readInt();
+ Data.NeedOverloadResolutionForDestructor = Record.readInt();
+ Data.DefaultedMoveConstructorIsDeleted = Record.readInt();
+ Data.DefaultedMoveAssignmentIsDeleted = Record.readInt();
+ Data.DefaultedDestructorIsDeleted = Record.readInt();
+ Data.HasTrivialSpecialMembers = Record.readInt();
+ Data.DeclaredNonTrivialSpecialMembers = Record.readInt();
+ Data.HasIrrelevantDestructor = Record.readInt();
+ Data.HasConstexprNonCopyMoveConstructor = Record.readInt();
+ Data.HasDefaultedDefaultConstructor = Record.readInt();
+ Data.DefaultedDefaultConstructorIsConstexpr = Record.readInt();
+ Data.HasConstexprDefaultConstructor = Record.readInt();
+ Data.HasNonLiteralTypeFieldsOrBases = Record.readInt();
+ Data.ComputedVisibleConversions = Record.readInt();
+ Data.UserProvidedDefaultConstructor = Record.readInt();
+ Data.DeclaredSpecialMembers = Record.readInt();
+ Data.ImplicitCopyConstructorHasConstParam = Record.readInt();
+ Data.ImplicitCopyAssignmentHasConstParam = Record.readInt();
+ Data.HasDeclaredCopyConstructorWithConstParam = Record.readInt();
+ Data.HasDeclaredCopyAssignmentWithConstParam = Record.readInt();
- Data.NumBases = Record[Idx++];
+ Data.NumBases = Record.readInt();
if (Data.NumBases)
Data.Bases = ReadGlobalOffset();
- Data.NumVBases = Record[Idx++];
+ Data.NumVBases = Record.readInt();
if (Data.NumVBases)
Data.VBases = ReadGlobalOffset();
- Record.ReadUnresolvedSet(Data.Conversions, Idx);
- Record.ReadUnresolvedSet(Data.VisibleConversions, Idx);
+ Record.ReadUnresolvedSet(Data.Conversions);
+ Record.ReadUnresolvedSet(Data.VisibleConversions);
assert(Data.Definition && "Data.Definition should be already set!");
Data.FirstFriend = ReadDeclID();
@@ -1537,12 +1532,12 @@ void ASTDeclReader::ReadCXXDefinitionDat
typedef LambdaCapture Capture;
CXXRecordDecl::LambdaDefinitionData &Lambda
= static_cast<CXXRecordDecl::LambdaDefinitionData &>(Data);
- Lambda.Dependent = Record[Idx++];
- Lambda.IsGenericLambda = Record[Idx++];
- Lambda.CaptureDefault = Record[Idx++];
- Lambda.NumCaptures = Record[Idx++];
- Lambda.NumExplicitCaptures = Record[Idx++];
- Lambda.ManglingNumber = Record[Idx++];
+ Lambda.Dependent = Record.readInt();
+ Lambda.IsGenericLambda = Record.readInt();
+ Lambda.CaptureDefault = Record.readInt();
+ Lambda.NumCaptures = Record.readInt();
+ Lambda.NumExplicitCaptures = Record.readInt();
+ Lambda.ManglingNumber = Record.readInt();
Lambda.ContextDecl = ReadDeclID();
Lambda.Captures
= (Capture*)Reader.Context.Allocate(sizeof(Capture)*Lambda.NumCaptures);
@@ -1550,8 +1545,8 @@ void ASTDeclReader::ReadCXXDefinitionDat
Lambda.MethodTyInfo = GetTypeSourceInfo();
for (unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
SourceLocation Loc = ReadSourceLocation();
- bool IsImplicit = Record[Idx++];
- LambdaCaptureKind Kind = static_cast<LambdaCaptureKind>(Record[Idx++]);
+ bool IsImplicit = Record.readInt();
+ LambdaCaptureKind Kind = static_cast<LambdaCaptureKind>(Record.readInt());
switch (Kind) {
case LCK_StarThis:
case LCK_This:
@@ -1683,14 +1678,14 @@ void ASTDeclReader::ReadCXXRecordDefinit
// Determine whether this is a lambda closure type, so that we can
// allocate the appropriate DefinitionData structure.
- bool IsLambda = Record[Idx++];
+ bool IsLambda = Record.readInt();
if (IsLambda)
DD = new (C) CXXRecordDecl::LambdaDefinitionData(D, nullptr, false, false,
LCD_None);
else
DD = new (C) struct CXXRecordDecl::DefinitionData(D);
- ReadCXXDefinitionData(*DD, Idx);
+ ReadCXXDefinitionData(*DD);
// We might already have a definition for this record. This can happen either
// because we're reading an update record, or because we've already done some
@@ -1724,7 +1719,7 @@ ASTDeclReader::VisitCXXRecordDeclImpl(CX
enum CXXRecKind {
CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization
};
- switch ((CXXRecKind)Record[Idx++]) {
+ switch ((CXXRecKind)Record.readInt()) {
case CXXRecNotTemplate:
// Merged when we merge the folding set entry in the primary template.
if (!isa<ClassTemplateSpecializationDecl>(D))
@@ -1747,7 +1742,8 @@ ASTDeclReader::VisitCXXRecordDeclImpl(CX
}
case CXXRecMemberSpecialization: {
CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>();
- TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++];
+ TemplateSpecializationKind TSK =
+ (TemplateSpecializationKind)Record.readInt();
SourceLocation POI = ReadSourceLocation();
MemberSpecializationInfo *MSI = new (C) MemberSpecializationInfo(RD, TSK);
MSI->setPointOfInstantiation(POI);
@@ -1757,7 +1753,7 @@ ASTDeclReader::VisitCXXRecordDeclImpl(CX
}
}
- bool WasDefinition = Record[Idx++];
+ bool WasDefinition = Record.readInt();
if (WasDefinition)
ReadCXXRecordDefinition(D, /*Update*/false);
else
@@ -1781,7 +1777,7 @@ ASTDeclReader::VisitCXXRecordDeclImpl(CX
void ASTDeclReader::VisitCXXMethodDecl(CXXMethodDecl *D) {
VisitFunctionDecl(D);
- unsigned NumOverridenMethods = Record[Idx++];
+ unsigned NumOverridenMethods = Record.readInt();
if (D->isCanonicalDecl()) {
while (NumOverridenMethods--) {
// Avoid invariant checking of CXXMethodDecl::addOverriddenMethod,
@@ -1792,7 +1788,7 @@ void ASTDeclReader::VisitCXXMethodDecl(C
} else {
// We don't care about which declarations this used to override; we get
// the relevant information from the canonical declaration.
- Idx += NumOverridenMethods;
+ Record.skipInts(NumOverridenMethods);
}
}
@@ -1808,7 +1804,7 @@ void ASTDeclReader::VisitCXXConstructorD
VisitCXXMethodDecl(D);
- D->IsExplicitSpecified = Record[Idx++];
+ D->IsExplicitSpecified = Record.readInt();
}
void ASTDeclReader::VisitCXXDestructorDecl(CXXDestructorDecl *D) {
@@ -1824,17 +1820,17 @@ void ASTDeclReader::VisitCXXDestructorDe
void ASTDeclReader::VisitCXXConversionDecl(CXXConversionDecl *D) {
VisitCXXMethodDecl(D);
- D->IsExplicitSpecified = Record[Idx++];
+ D->IsExplicitSpecified = Record.readInt();
}
void ASTDeclReader::VisitImportDecl(ImportDecl *D) {
VisitDecl(D);
D->ImportedAndComplete.setPointer(readModule());
- D->ImportedAndComplete.setInt(Record[Idx++]);
+ D->ImportedAndComplete.setInt(Record.readInt());
SourceLocation *StoredLocs = D->getTrailingObjects<SourceLocation>();
for (unsigned I = 0, N = Record.back(); I != N; ++I)
StoredLocs[I] = ReadSourceLocation();
- ++Idx; // The number of stored source locations.
+ (void)Record.readInt(); // The number of stored source locations.
}
void ASTDeclReader::VisitAccessSpecDecl(AccessSpecDecl *D) {
@@ -1844,26 +1840,26 @@ void ASTDeclReader::VisitAccessSpecDecl(
void ASTDeclReader::VisitFriendDecl(FriendDecl *D) {
VisitDecl(D);
- if (Record[Idx++]) // hasFriendDecl
+ if (Record.readInt()) // hasFriendDecl
D->Friend = ReadDeclAs<NamedDecl>();
else
D->Friend = GetTypeSourceInfo();
for (unsigned i = 0; i != D->NumTPLists; ++i)
D->getTrailingObjects<TemplateParameterList *>()[i] =
- Record.ReadTemplateParameterList(Idx);
+ Record.ReadTemplateParameterList();
D->NextFriend = ReadDeclID();
- D->UnsupportedFriend = (Record[Idx++] != 0);
+ D->UnsupportedFriend = (Record.readInt() != 0);
D->FriendLoc = ReadSourceLocation();
}
void ASTDeclReader::VisitFriendTemplateDecl(FriendTemplateDecl *D) {
VisitDecl(D);
- unsigned NumParams = Record[Idx++];
+ unsigned NumParams = Record.readInt();
D->NumParams = NumParams;
D->Params = new TemplateParameterList*[NumParams];
for (unsigned i = 0; i != NumParams; ++i)
- D->Params[i] = Record.ReadTemplateParameterList(Idx);
- if (Record[Idx++]) // HasFriendDecl
+ D->Params[i] = Record.ReadTemplateParameterList();
+ if (Record.readInt()) // HasFriendDecl
D->Friend = ReadDeclAs<NamedDecl>();
else
D->Friend = GetTypeSourceInfo();
@@ -1875,8 +1871,7 @@ DeclID ASTDeclReader::VisitTemplateDecl(
DeclID PatternID = ReadDeclID();
NamedDecl *TemplatedDecl = cast_or_null<NamedDecl>(Reader.GetDecl(PatternID));
- TemplateParameterList* TemplateParams
- = Record.ReadTemplateParameterList(Idx);
+ TemplateParameterList *TemplateParams = Record.ReadTemplateParameterList();
D->init(TemplatedDecl, TemplateParams);
return PatternID;
@@ -1903,13 +1898,13 @@ ASTDeclReader::VisitRedeclarableTemplate
assert(RTD->getKind() == D->getKind() &&
"InstantiatedFromMemberTemplate kind mismatch");
D->setInstantiatedFromMemberTemplate(RTD);
- if (Record[Idx++])
+ if (Record.readInt())
D->setMemberSpecialization();
}
}
DeclID PatternID = VisitTemplateDecl(D);
- D->IdentifierNamespace = Record[Idx++];
+ D->IdentifierNamespace = Record.readInt();
mergeRedeclarable(D, Redecl, PatternID);
@@ -1996,7 +1991,7 @@ ASTDeclReader::VisitClassTemplateSpecial
D->SpecializedTemplate = CTD;
} else {
SmallVector<TemplateArgument, 8> TemplArgs;
- Record.ReadTemplateArgumentList(TemplArgs, Idx);
+ Record.ReadTemplateArgumentList(TemplArgs);
TemplateArgumentList *ArgList
= TemplateArgumentList::CreateCopy(C, TemplArgs);
ClassTemplateSpecializationDecl::SpecializedPartialSpecialization *PS
@@ -2010,13 +2005,12 @@ ASTDeclReader::VisitClassTemplateSpecial
}
SmallVector<TemplateArgument, 8> TemplArgs;
- Record.ReadTemplateArgumentList(TemplArgs, Idx,
- /*Canonicalize*/ true);
+ Record.ReadTemplateArgumentList(TemplArgs, /*Canonicalize*/ true);
D->TemplateArgs = TemplateArgumentList::CreateCopy(C, TemplArgs);
D->PointOfInstantiation = ReadSourceLocation();
- D->SpecializationKind = (TemplateSpecializationKind)Record[Idx++];
+ D->SpecializationKind = (TemplateSpecializationKind)Record.readInt();
- bool writtenAsCanonicalDecl = Record[Idx++];
+ bool writtenAsCanonicalDecl = Record.readInt();
if (writtenAsCanonicalDecl) {
ClassTemplateDecl *CanonPattern = ReadDeclAs<ClassTemplateDecl>();
if (D->isCanonicalDecl()) { // It's kept in the folding set.
@@ -2064,14 +2058,14 @@ void ASTDeclReader::VisitClassTemplatePa
ClassTemplatePartialSpecializationDecl *D) {
RedeclarableResult Redecl = VisitClassTemplateSpecializationDeclImpl(D);
- D->TemplateParams = Record.ReadTemplateParameterList(Idx);
- D->ArgsAsWritten = Record.ReadASTTemplateArgumentListInfo(Idx);
+ D->TemplateParams = Record.ReadTemplateParameterList();
+ D->ArgsAsWritten = Record.ReadASTTemplateArgumentListInfo();
// These are read/set from/to the first declaration.
if (ThisDeclID == Redecl.getFirstID()) {
D->InstantiatedFromMember.setPointer(
ReadDeclAs<ClassTemplatePartialSpecializationDecl>());
- D->InstantiatedFromMember.setInt(Record[Idx++]);
+ D->InstantiatedFromMember.setInt(Record.readInt());
}
}
@@ -2113,7 +2107,7 @@ ASTDeclReader::VisitVarTemplateSpecializ
D->SpecializedTemplate = VTD;
} else {
SmallVector<TemplateArgument, 8> TemplArgs;
- Record.ReadTemplateArgumentList(TemplArgs, Idx);
+ Record.ReadTemplateArgumentList(TemplArgs);
TemplateArgumentList *ArgList = TemplateArgumentList::CreateCopy(
C, TemplArgs);
VarTemplateSpecializationDecl::SpecializedPartialSpecialization *PS =
@@ -2137,13 +2131,12 @@ ASTDeclReader::VisitVarTemplateSpecializ
}
SmallVector<TemplateArgument, 8> TemplArgs;
- Record.ReadTemplateArgumentList(TemplArgs, Idx,
- /*Canonicalize*/ true);
+ Record.ReadTemplateArgumentList(TemplArgs, /*Canonicalize*/ true);
D->TemplateArgs = TemplateArgumentList::CreateCopy(C, TemplArgs);
D->PointOfInstantiation = ReadSourceLocation();
- D->SpecializationKind = (TemplateSpecializationKind)Record[Idx++];
+ D->SpecializationKind = (TemplateSpecializationKind)Record.readInt();
- bool writtenAsCanonicalDecl = Record[Idx++];
+ bool writtenAsCanonicalDecl = Record.readInt();
if (writtenAsCanonicalDecl) {
VarTemplateDecl *CanonPattern = ReadDeclAs<VarTemplateDecl>();
if (D->isCanonicalDecl()) { // It's kept in the folding set.
@@ -2170,42 +2163,42 @@ void ASTDeclReader::VisitVarTemplatePart
VarTemplatePartialSpecializationDecl *D) {
RedeclarableResult Redecl = VisitVarTemplateSpecializationDeclImpl(D);
- D->TemplateParams = Record.ReadTemplateParameterList(Idx);
- D->ArgsAsWritten = Record.ReadASTTemplateArgumentListInfo(Idx);
+ D->TemplateParams = Record.ReadTemplateParameterList();
+ D->ArgsAsWritten = Record.ReadASTTemplateArgumentListInfo();
// These are read/set from/to the first declaration.
if (ThisDeclID == Redecl.getFirstID()) {
D->InstantiatedFromMember.setPointer(
ReadDeclAs<VarTemplatePartialSpecializationDecl>());
- D->InstantiatedFromMember.setInt(Record[Idx++]);
+ D->InstantiatedFromMember.setInt(Record.readInt());
}
}
void ASTDeclReader::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
VisitTypeDecl(D);
- D->setDeclaredWithTypename(Record[Idx++]);
+ D->setDeclaredWithTypename(Record.readInt());
- if (Record[Idx++])
+ if (Record.readInt())
D->setDefaultArgument(GetTypeSourceInfo());
}
void ASTDeclReader::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
VisitDeclaratorDecl(D);
// TemplateParmPosition.
- D->setDepth(Record[Idx++]);
- D->setPosition(Record[Idx++]);
+ D->setDepth(Record.readInt());
+ D->setPosition(Record.readInt());
if (D->isExpandedParameterPack()) {
auto TypesAndInfos =
D->getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) {
- new (&TypesAndInfos[I].first) QualType(Record.readType(Idx));
+ new (&TypesAndInfos[I].first) QualType(Record.readType());
TypesAndInfos[I].second = GetTypeSourceInfo();
}
} else {
// Rest of NonTypeTemplateParmDecl.
- D->ParameterPack = Record[Idx++];
- if (Record[Idx++])
+ D->ParameterPack = Record.readInt();
+ if (Record.readInt())
D->setDefaultArgument(Record.ReadExpr());
}
}
@@ -2213,20 +2206,20 @@ void ASTDeclReader::VisitNonTypeTemplate
void ASTDeclReader::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
VisitTemplateDecl(D);
// TemplateParmPosition.
- D->setDepth(Record[Idx++]);
- D->setPosition(Record[Idx++]);
+ D->setDepth(Record.readInt());
+ D->setPosition(Record.readInt());
if (D->isExpandedParameterPack()) {
TemplateParameterList **Data =
D->getTrailingObjects<TemplateParameterList *>();
for (unsigned I = 0, N = D->getNumExpansionTemplateParameters();
I != N; ++I)
- Data[I] = Record.ReadTemplateParameterList(Idx);
+ Data[I] = Record.ReadTemplateParameterList();
} else {
// Rest of TemplateTemplateParmDecl.
- D->ParameterPack = Record[Idx++];
- if (Record[Idx++])
+ D->ParameterPack = Record.readInt();
+ if (Record.readInt())
D->setDefaultArgument(Reader.getContext(),
- Record.ReadTemplateArgumentLoc(Idx));
+ Record.ReadTemplateArgumentLoc());
}
}
@@ -2237,7 +2230,7 @@ void ASTDeclReader::VisitTypeAliasTempla
void ASTDeclReader::VisitStaticAssertDecl(StaticAssertDecl *D) {
VisitDecl(D);
D->AssertExprAndFailed.setPointer(Record.ReadExpr());
- D->AssertExprAndFailed.setInt(Record[Idx++]);
+ D->AssertExprAndFailed.setInt(Record.readInt());
D->Message = cast_or_null<StringLiteral>(Record.ReadExpr());
D->RParenLoc = ReadSourceLocation();
}
@@ -2270,7 +2263,7 @@ ASTDeclReader::VisitRedeclarable(Redecla
FirstDeclID = ThisDeclID;
IsKeyDecl = true;
IsFirstLocalDecl = true;
- } else if (unsigned N = Record[Idx++]) {
+ } else if (unsigned N = Record.readInt()) {
// This declaration was the first local declaration, but may have imported
// other declarations.
IsKeyDecl = N == 1;
@@ -3263,13 +3256,12 @@ Decl *ASTReader::ReadDeclRecord(DeclID I
Deserializing ADecl(this);
DeclsCursor.JumpToBit(Loc.Offset);
- RecordData Record;
+ ASTRecordReader Record(*this, *Loc.F);
+ ASTDeclReader Reader(*this, Record, Loc, ID, DeclLoc);
unsigned Code = DeclsCursor.ReadCode();
- unsigned Idx = 0;
- ASTDeclReader Reader(*this, Loc, ID, DeclLoc, Record,Idx);
Decl *D = nullptr;
- switch ((DeclCode)DeclsCursor.readRecord(Code, Record)) {
+ switch ((DeclCode)Record.readRecord(DeclsCursor, Code)) {
case DECL_CONTEXT_LEXICAL:
case DECL_CONTEXT_VISIBLE:
llvm_unreachable("Record cannot be de-serialized with ReadDeclRecord");
@@ -3310,7 +3302,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID I
D = UsingDecl::CreateDeserialized(Context, ID);
break;
case DECL_USING_PACK:
- D = UsingPackDecl::CreateDeserialized(Context, ID, Record[Idx++]);
+ D = UsingPackDecl::CreateDeserialized(Context, ID, Record.readInt());
break;
case DECL_USING_SHADOW:
D = UsingShadowDecl::CreateDeserialized(Context, ID);
@@ -3349,7 +3341,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID I
D = AccessSpecDecl::CreateDeserialized(Context, ID);
break;
case DECL_FRIEND:
- D = FriendDecl::CreateDeserialized(Context, ID, Record[Idx++]);
+ D = FriendDecl::CreateDeserialized(Context, ID, Record.readInt());
break;
case DECL_FRIEND_TEMPLATE:
D = FriendTemplateDecl::CreateDeserialized(Context, ID);
@@ -3385,14 +3377,15 @@ Decl *ASTReader::ReadDeclRecord(DeclID I
D = NonTypeTemplateParmDecl::CreateDeserialized(Context, ID);
break;
case DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK:
- D = NonTypeTemplateParmDecl::CreateDeserialized(Context, ID, Record[Idx++]);
+ D = NonTypeTemplateParmDecl::CreateDeserialized(Context, ID,
+ Record.readInt());
break;
case DECL_TEMPLATE_TEMPLATE_PARM:
D = TemplateTemplateParmDecl::CreateDeserialized(Context, ID);
break;
case DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK:
D = TemplateTemplateParmDecl::CreateDeserialized(Context, ID,
- Record[Idx++]);
+ Record.readInt());
break;
case DECL_TYPE_ALIAS_TEMPLATE:
D = TypeAliasTemplateDecl::CreateDeserialized(Context, ID);
@@ -3449,7 +3442,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID I
D = ParmVarDecl::CreateDeserialized(Context, ID);
break;
case DECL_DECOMPOSITION:
- D = DecompositionDecl::CreateDeserialized(Context, ID, Record[Idx++]);
+ D = DecompositionDecl::CreateDeserialized(Context, ID, Record.readInt());
break;
case DECL_BINDING:
D = BindingDecl::CreateDeserialized(Context, ID);
@@ -3464,7 +3457,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID I
D = MSPropertyDecl::CreateDeserialized(Context, ID);
break;
case DECL_CAPTURED:
- D = CapturedDecl::CreateDeserialized(Context, ID, Record[Idx++]);
+ D = CapturedDecl::CreateDeserialized(Context, ID, Record.readInt());
break;
case DECL_CXX_BASE_SPECIFIERS:
Error("attempt to read a C++ base-specifier record as a declaration");
@@ -3478,7 +3471,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID I
D = ImportDecl::CreateDeserialized(Context, ID, Record.back());
break;
case DECL_OMP_THREADPRIVATE:
- D = OMPThreadPrivateDecl::CreateDeserialized(Context, ID, Record[Idx++]);
+ D = OMPThreadPrivateDecl::CreateDeserialized(Context, ID, Record.readInt());
break;
case DECL_OMP_DECLARE_REDUCTION:
D = OMPDeclareReductionDecl::CreateDeserialized(Context, ID);
@@ -3487,11 +3480,11 @@ Decl *ASTReader::ReadDeclRecord(DeclID I
D = OMPCapturedExprDecl::CreateDeserialized(Context, ID);
break;
case DECL_PRAGMA_COMMENT:
- D = PragmaCommentDecl::CreateDeserialized(Context, ID, Record[Idx++]);
+ D = PragmaCommentDecl::CreateDeserialized(Context, ID, Record.readInt());
break;
case DECL_PRAGMA_DETECT_MISMATCH:
D = PragmaDetectMismatchDecl::CreateDeserialized(Context, ID,
- Record[Idx++]);
+ Record.readInt());
break;
case DECL_EMPTY:
D = EmptyDecl::CreateDeserialized(Context, ID);
@@ -3520,7 +3513,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID I
ReadVisibleDeclContextStorage(*Loc.F, DeclsCursor, Offsets.second, ID))
return nullptr;
}
- assert(Idx == Record.size());
+ assert(Record.getIdx() == Record.size());
// Load any relevant update records.
PendingUpdateRecords.push_back(std::make_pair(ID, D));
@@ -3560,15 +3553,14 @@ void ASTReader::loadDeclUpdateRecords(se
llvm::BitstreamCursor &Cursor = F->DeclsCursor;
SavedStreamPosition SavedPosition(Cursor);
Cursor.JumpToBit(Offset);
- RecordData Record;
unsigned Code = Cursor.ReadCode();
- unsigned RecCode = Cursor.readRecord(Code, Record);
+ ASTRecordReader Record(*this, *F);
+ unsigned RecCode = Record.readRecord(Cursor, Code);
(void)RecCode;
assert(RecCode == DECL_UPDATES && "Expected DECL_UPDATES record!");
- unsigned Idx = 0;
- ASTDeclReader Reader(*this, RecordLocation(F, Offset), ID,
- SourceLocation(), Record, Idx);
+ ASTDeclReader Reader(*this, Record, RecordLocation(F, Offset), ID,
+ SourceLocation());
Reader.UpdateDecl(D);
// We might have made this declaration interesting. If so, remember that
@@ -3777,13 +3769,13 @@ static void forAllLaterRedecls(DeclT *D,
}
void ASTDeclReader::UpdateDecl(Decl *D) {
- while (Idx < Record.size()) {
- switch ((DeclUpdateKind)Record[Idx++]) {
+ while (Record.getIdx() < Record.size()) {
+ switch ((DeclUpdateKind)Record.readInt()) {
case UPD_CXX_ADDED_IMPLICIT_MEMBER: {
auto *RD = cast<CXXRecordDecl>(D);
// FIXME: If we also have an update record for instantiating the
// definition of D, we need that to happen before we get here.
- Decl *MD = Record.ReadDecl(Idx);
+ Decl *MD = Record.ReadDecl();
assert(MD && "couldn't read decl from update record");
// FIXME: We should call addHiddenDecl instead, to add the member
// to its DeclContext.
@@ -3793,7 +3785,7 @@ void ASTDeclReader::UpdateDecl(Decl *D)
case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION:
// It will be added to the template's specializations set when loaded.
- (void)Record.ReadDecl(Idx);
+ (void)Record.ReadDecl();
break;
case UPD_CXX_ADDED_ANONYMOUS_NAMESPACE: {
@@ -3856,7 +3848,7 @@ void ASTDeclReader::UpdateDecl(Decl *D)
return;
}
- if (Record[Idx++]) {
+ if (Record.readInt()) {
// Maintain AST consistency: any later redeclarations of this function
// are inline if this one is. (We might have merged another declaration
// into this one.)
@@ -3866,14 +3858,14 @@ void ASTDeclReader::UpdateDecl(Decl *D)
}
FD->setInnerLocStart(ReadSourceLocation());
if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
- CD->NumCtorInitializers = Record[Idx++];
+ CD->NumCtorInitializers = Record.readInt();
if (CD->NumCtorInitializers)
CD->CtorInitializers = ReadGlobalOffset();
}
// Store the offset of the body so we can lazily load it later.
Reader.PendingBodies[FD] = GetCurrentCursorOffset();
HasPendingBody = true;
- assert(Idx == Record.size() && "lazy body must be last");
+ assert(Record.getIdx() == Record.size() && "lazy body must be last");
break;
}
@@ -3892,7 +3884,7 @@ void ASTDeclReader::UpdateDecl(Decl *D)
Reader.PendingFakeDefinitionData.erase(OldDD);
}
- auto TSK = (TemplateSpecializationKind)Record[Idx++];
+ auto TSK = (TemplateSpecializationKind)Record.readInt();
SourceLocation POI = ReadSourceLocation();
if (MemberSpecializationInfo *MSInfo =
RD->getMemberSpecializationInfo()) {
@@ -3904,11 +3896,11 @@ void ASTDeclReader::UpdateDecl(Decl *D)
Spec->setTemplateSpecializationKind(TSK);
Spec->setPointOfInstantiation(POI);
- if (Record[Idx++]) {
+ if (Record.readInt()) {
auto PartialSpec =
ReadDeclAs<ClassTemplatePartialSpecializationDecl>();
SmallVector<TemplateArgument, 8> TemplArgs;
- Record.ReadTemplateArgumentList(TemplArgs, Idx);
+ Record.ReadTemplateArgumentList(TemplArgs);
auto *TemplArgList = TemplateArgumentList::CreateCopy(
Reader.getContext(), TemplArgs);
@@ -3920,14 +3912,14 @@ void ASTDeclReader::UpdateDecl(Decl *D)
}
}
- RD->setTagKind((TagTypeKind)Record[Idx++]);
+ RD->setTagKind((TagTypeKind)Record.readInt());
RD->setLocation(ReadSourceLocation());
RD->setLocStart(ReadSourceLocation());
RD->setBraceRange(ReadSourceRange());
- if (Record[Idx++]) {
+ if (Record.readInt()) {
AttrVec Attrs;
- Record.ReadAttributes(Attrs, Idx);
+ Record.ReadAttributes(Attrs);
// If the declaration already has attributes, we assume that some other
// AST file already loaded them.
if (!D->hasAttrs())
@@ -3950,7 +3942,7 @@ void ASTDeclReader::UpdateDecl(Decl *D)
case UPD_CXX_RESOLVED_EXCEPTION_SPEC: {
FunctionProtoType::ExceptionSpecInfo ESI;
SmallVector<QualType, 8> ExceptionStorage;
- Record.readExceptionSpec(ExceptionStorage, ESI, Idx);
+ Record.readExceptionSpec(ExceptionStorage, ESI);
// Update this declaration's exception specification, if needed.
auto *FD = cast<FunctionDecl>(D);
@@ -3972,7 +3964,7 @@ void ASTDeclReader::UpdateDecl(Decl *D)
case UPD_CXX_DEDUCED_RETURN_TYPE: {
// FIXME: Also do this when merging redecls.
- QualType DeducedResultType = Record.readType(Idx);
+ QualType DeducedResultType = Record.readType();
for (auto *Redecl : merged_redecls(D)) {
// FIXME: If the return type is already deduced, check that it matches.
FunctionDecl *FD = cast<FunctionDecl>(Redecl);
@@ -3988,11 +3980,11 @@ void ASTDeclReader::UpdateDecl(Decl *D)
}
case UPD_MANGLING_NUMBER:
- Reader.Context.setManglingNumber(cast<NamedDecl>(D), Record[Idx++]);
+ Reader.Context.setManglingNumber(cast<NamedDecl>(D), Record.readInt());
break;
case UPD_STATIC_LOCAL_NUMBER:
- Reader.Context.setStaticLocalNumber(cast<VarDecl>(D), Record[Idx++]);
+ Reader.Context.setStaticLocalNumber(cast<VarDecl>(D), Record.readInt());
break;
case UPD_DECL_MARKED_OPENMP_THREADPRIVATE:
@@ -4025,7 +4017,7 @@ void ASTDeclReader::UpdateDecl(Decl *D)
case UPD_DECL_MARKED_OPENMP_DECLARETARGET:
case UPD_ADDED_ATTR_TO_RECORD:
AttrVec Attrs;
- Record.ReadAttributes(Attrs, Idx);
+ Record.ReadAttributes(Attrs);
assert(Attrs.size() == 1);
D->addAttr(Attrs[0]);
break;
Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=290217&r1=290216&r2=290217&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Tue Dec 20 18:17:49 2016
@@ -27,49 +27,46 @@ namespace clang {
class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
friend class OMPClauseReader;
- ASTRecordReader Record;
+ ASTRecordReader &Record;
llvm::BitstreamCursor &DeclsCursor;
- unsigned &Idx;
SourceLocation ReadSourceLocation() {
- return Record.ReadSourceLocation(Idx);
+ return Record.ReadSourceLocation();
}
SourceRange ReadSourceRange() {
- return Record.ReadSourceRange(Idx);
+ return Record.ReadSourceRange();
}
std::string ReadString() {
- return Record.ReadString(Idx);
+ return Record.ReadString();
}
TypeSourceInfo *GetTypeSourceInfo() {
- return Record.GetTypeSourceInfo(Idx);
+ return Record.GetTypeSourceInfo();
}
Decl *ReadDecl() {
- return Record.ReadDecl(Idx);
+ return Record.ReadDecl();
}
template<typename T>
T *ReadDeclAs() {
- return Record.ReadDeclAs<T>(Idx);
+ return Record.ReadDeclAs<T>();
}
void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc,
DeclarationName Name) {
- Record.ReadDeclarationNameLoc(DNLoc, Name, Idx);
+ Record.ReadDeclarationNameLoc(DNLoc, Name);
}
void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo) {
- Record.ReadDeclarationNameInfo(NameInfo, Idx);
+ Record.ReadDeclarationNameInfo(NameInfo);
}
public:
- ASTStmtReader(ASTReader &Reader, ModuleFile &F,
- llvm::BitstreamCursor &Cursor,
- const ASTReader::RecordData &Record, unsigned &Idx)
- : Record(Reader, Record, F), DeclsCursor(Cursor), Idx(Idx) { }
+ ASTStmtReader(ASTRecordReader &Record, llvm::BitstreamCursor &Cursor)
+ : Record(Record), DeclsCursor(Cursor) {}
/// \brief The number of record fields required for the Stmt class
/// itself.
@@ -102,24 +99,24 @@ void ASTStmtReader::ReadTemplateKWAndArg
ArgInfo.setLAngleLoc(ReadSourceLocation());
ArgInfo.setRAngleLoc(ReadSourceLocation());
for (unsigned i = 0; i != NumTemplateArgs; ++i)
- ArgInfo.addArgument(Record.ReadTemplateArgumentLoc(Idx));
+ ArgInfo.addArgument(Record.ReadTemplateArgumentLoc());
Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray);
}
void ASTStmtReader::VisitStmt(Stmt *S) {
- assert(Idx == NumStmtFields && "Incorrect statement field count");
+ assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count");
}
void ASTStmtReader::VisitNullStmt(NullStmt *S) {
VisitStmt(S);
S->setSemiLoc(ReadSourceLocation());
- S->HasLeadingEmptyMacro = Record[Idx++];
+ S->HasLeadingEmptyMacro = Record.readInt();
}
void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
VisitStmt(S);
SmallVector<Stmt *, 16> Stmts;
- unsigned NumStmts = Record[Idx++];
+ unsigned NumStmts = Record.readInt();
while (NumStmts--)
Stmts.push_back(Record.ReadSubStmt());
S->setStmts(Record.getContext(), Stmts);
@@ -129,7 +126,7 @@ void ASTStmtReader::VisitCompoundStmt(Co
void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
VisitStmt(S);
- Record.RecordSwitchCaseID(S, Record[Idx++]);
+ Record.RecordSwitchCaseID(S, Record.readInt());
S->setKeywordLoc(ReadSourceLocation());
S->setColonLoc(ReadSourceLocation());
}
@@ -158,9 +155,9 @@ void ASTStmtReader::VisitLabelStmt(Label
void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
VisitStmt(S);
- uint64_t NumAttrs = Record[Idx++];
+ uint64_t NumAttrs = Record.readInt();
AttrVec Attrs;
- Record.ReadAttributes(Attrs, Idx);
+ Record.ReadAttributes(Attrs);
(void)NumAttrs;
assert(NumAttrs == S->NumAttrs);
assert(NumAttrs == Attrs.size());
@@ -171,7 +168,7 @@ void ASTStmtReader::VisitAttributedStmt(
void ASTStmtReader::VisitIfStmt(IfStmt *S) {
VisitStmt(S);
- S->setConstexpr(Record[Idx++]);
+ S->setConstexpr(Record.readInt());
S->setInit(Record.ReadSubStmt());
S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
S->setCond(Record.ReadSubExpr());
@@ -188,12 +185,12 @@ void ASTStmtReader::VisitSwitchStmt(Swit
S->setCond(Record.ReadSubExpr());
S->setBody(Record.ReadSubStmt());
S->setSwitchLoc(ReadSourceLocation());
- if (Record[Idx++])
+ if (Record.readInt())
S->setAllEnumCasesCovered();
SwitchCase *PrevSC = nullptr;
- for (unsigned N = Record.size(); Idx != N; ++Idx) {
- SwitchCase *SC = Record.getSwitchCaseWithID(Record[Idx]);
+ for (auto E = Record.size(); Record.getIdx() != E; ) {
+ SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
if (PrevSC)
PrevSC->setNextSwitchCase(SC);
else
@@ -269,13 +266,14 @@ void ASTStmtReader::VisitDeclStmt(DeclSt
S->setStartLoc(ReadSourceLocation());
S->setEndLoc(ReadSourceLocation());
- if (Idx + 1 == Record.size()) {
+ if (Record.size() - Record.getIdx() == 1) {
// Single declaration
S->setDeclGroup(DeclGroupRef(ReadDecl()));
} else {
SmallVector<Decl *, 16> Decls;
- Decls.reserve(Record.size() - Idx);
- for (unsigned N = Record.size(); Idx != N; )
+ int N = Record.size() - Record.getIdx();
+ Decls.reserve(N);
+ for (int I = 0; I < N; ++I)
Decls.push_back(ReadDecl());
S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
Decls.data(),
@@ -285,12 +283,12 @@ void ASTStmtReader::VisitDeclStmt(DeclSt
void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
VisitStmt(S);
- S->NumOutputs = Record[Idx++];
- S->NumInputs = Record[Idx++];
- S->NumClobbers = Record[Idx++];
+ S->NumOutputs = Record.readInt();
+ S->NumInputs = Record.readInt();
+ S->NumClobbers = Record.readInt();
S->setAsmLoc(ReadSourceLocation());
- S->setVolatile(Record[Idx++]);
- S->setSimple(Record[Idx++]);
+ S->setVolatile(Record.readInt());
+ S->setSimple(Record.readInt());
}
void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
@@ -307,7 +305,7 @@ void ASTStmtReader::VisitGCCAsmStmt(GCCA
SmallVector<StringLiteral*, 16> Constraints;
SmallVector<Stmt*, 16> Exprs;
for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
- Names.push_back(Record.GetIdentifierInfo(Idx));
+ Names.push_back(Record.GetIdentifierInfo());
Constraints.push_back(cast_or_null<StringLiteral>(Record.ReadSubStmt()));
Exprs.push_back(Record.ReadSubStmt());
}
@@ -327,14 +325,14 @@ void ASTStmtReader::VisitMSAsmStmt(MSAsm
VisitAsmStmt(S);
S->LBraceLoc = ReadSourceLocation();
S->EndLoc = ReadSourceLocation();
- S->NumAsmToks = Record[Idx++];
+ S->NumAsmToks = Record.readInt();
std::string AsmStr = ReadString();
// Read the tokens.
SmallVector<Token, 16> AsmToks;
AsmToks.reserve(S->NumAsmToks);
for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
- AsmToks.push_back(Record.ReadToken(Idx));
+ AsmToks.push_back(Record.ReadToken());
}
// The calls to reserve() for the FooData vectors are mandatory to
@@ -390,9 +388,9 @@ void ASTStmtReader::VisitCoyieldExpr(Coy
void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
VisitStmt(S);
- ++Idx;
+ Record.skipInts(1);
S->setCapturedDecl(ReadDeclAs<CapturedDecl>());
- S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record[Idx++]));
+ S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
S->setCapturedRecordDecl(ReadDeclAs<RecordDecl>());
// Capture inits
@@ -408,46 +406,47 @@ void ASTStmtReader::VisitCapturedStmt(Ca
// Captures
for (auto &I : S->captures()) {
I.VarAndKind.setPointer(ReadDeclAs<VarDecl>());
- I.VarAndKind
- .setInt(static_cast<CapturedStmt::VariableCaptureKind>(Record[Idx++]));
+ I.VarAndKind.setInt(
+ static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
I.Loc = ReadSourceLocation();
}
}
void ASTStmtReader::VisitExpr(Expr *E) {
VisitStmt(E);
- E->setType(Record.readType(Idx));
- E->setTypeDependent(Record[Idx++]);
- E->setValueDependent(Record[Idx++]);
- E->setInstantiationDependent(Record[Idx++]);
- E->ExprBits.ContainsUnexpandedParameterPack = Record[Idx++];
- E->setValueKind(static_cast<ExprValueKind>(Record[Idx++]));
- E->setObjectKind(static_cast<ExprObjectKind>(Record[Idx++]));
- assert(Idx == NumExprFields && "Incorrect expression field count");
+ E->setType(Record.readType());
+ E->setTypeDependent(Record.readInt());
+ E->setValueDependent(Record.readInt());
+ E->setInstantiationDependent(Record.readInt());
+ E->ExprBits.ContainsUnexpandedParameterPack = Record.readInt();
+ E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
+ E->setObjectKind(static_cast<ExprObjectKind>(Record.readInt()));
+ assert(Record.getIdx() == NumExprFields &&
+ "Incorrect expression field count");
}
void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
VisitExpr(E);
E->setLocation(ReadSourceLocation());
- E->Type = (PredefinedExpr::IdentType)Record[Idx++];
+ E->Type = (PredefinedExpr::IdentType)Record.readInt();
E->FnName = cast_or_null<StringLiteral>(Record.ReadSubExpr());
}
void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
VisitExpr(E);
- E->DeclRefExprBits.HasQualifier = Record[Idx++];
- E->DeclRefExprBits.HasFoundDecl = Record[Idx++];
- E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record[Idx++];
- E->DeclRefExprBits.HadMultipleCandidates = Record[Idx++];
- E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record[Idx++];
+ E->DeclRefExprBits.HasQualifier = Record.readInt();
+ E->DeclRefExprBits.HasFoundDecl = Record.readInt();
+ E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
+ E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
+ E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
unsigned NumTemplateArgs = 0;
if (E->hasTemplateKWAndArgsInfo())
- NumTemplateArgs = Record[Idx++];
+ NumTemplateArgs = Record.readInt();
if (E->hasQualifier())
new (E->getTrailingObjects<NestedNameSpecifierLoc>())
- NestedNameSpecifierLoc(Record.ReadNestedNameSpecifierLoc(Idx));
+ NestedNameSpecifierLoc(Record.ReadNestedNameSpecifierLoc());
if (E->hasFoundDecl())
*E->getTrailingObjects<NamedDecl *>() = ReadDeclAs<NamedDecl>();
@@ -465,14 +464,14 @@ void ASTStmtReader::VisitDeclRefExpr(Dec
void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
VisitExpr(E);
E->setLocation(ReadSourceLocation());
- E->setValue(Record.getContext(), Record.ReadAPInt(Idx));
+ E->setValue(Record.getContext(), Record.ReadAPInt());
}
void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
VisitExpr(E);
- E->setRawSemantics(static_cast<Stmt::APFloatSemantics>(Record[Idx++]));
- E->setExact(Record[Idx++]);
- E->setValue(Record.getContext(), Record.ReadAPFloat(E->getSemantics(), Idx));
+ E->setRawSemantics(static_cast<Stmt::APFloatSemantics>(Record.readInt()));
+ E->setExact(Record.readInt());
+ E->setValue(Record.getContext(), Record.ReadAPFloat(E->getSemantics()));
E->setLocation(ReadSourceLocation());
}
@@ -483,18 +482,19 @@ void ASTStmtReader::VisitImaginaryLitera
void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
VisitExpr(E);
- unsigned Len = Record[Idx++];
- assert(Record[Idx] == E->getNumConcatenated() &&
+ unsigned Len = Record.readInt();
+ assert(Record.peekInt() == E->getNumConcatenated() &&
"Wrong number of concatenated tokens!");
- ++Idx;
+ Record.skipInts(1);
StringLiteral::StringKind kind =
- static_cast<StringLiteral::StringKind>(Record[Idx++]);
- bool isPascal = Record[Idx++];
+ static_cast<StringLiteral::StringKind>(Record.readInt());
+ bool isPascal = Record.readInt();
// Read string data
- SmallString<16> Str(&Record[Idx], &Record[Idx] + Len);
+ auto B = &Record.peekInt();
+ SmallString<16> Str(B, B + Len);
E->setString(Record.getContext(), Str, kind, isPascal);
- Idx += Len;
+ Record.skipInts(Len);
// Read source locations
for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
@@ -503,9 +503,9 @@ void ASTStmtReader::VisitStringLiteral(S
void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
VisitExpr(E);
- E->setValue(Record[Idx++]);
+ E->setValue(Record.readInt());
E->setLocation(ReadSourceLocation());
- E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record[Idx++]));
+ E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
}
void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
@@ -517,7 +517,7 @@ void ASTStmtReader::VisitParenExpr(Paren
void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
VisitExpr(E);
- unsigned NumExprs = Record[Idx++];
+ unsigned NumExprs = Record.readInt();
E->Exprs = new (Record.getContext()) Stmt*[NumExprs];
for (unsigned i = 0; i != NumExprs; ++i)
E->Exprs[i] = Record.ReadSubStmt();
@@ -529,26 +529,26 @@ void ASTStmtReader::VisitParenListExpr(P
void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
VisitExpr(E);
E->setSubExpr(Record.ReadSubExpr());
- E->setOpcode((UnaryOperator::Opcode)Record[Idx++]);
+ E->setOpcode((UnaryOperator::Opcode)Record.readInt());
E->setOperatorLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
VisitExpr(E);
- assert(E->getNumComponents() == Record[Idx]);
- ++Idx;
- assert(E->getNumExpressions() == Record[Idx]);
- ++Idx;
+ assert(E->getNumComponents() == Record.peekInt());
+ Record.skipInts(1);
+ assert(E->getNumExpressions() == Record.peekInt());
+ Record.skipInts(1);
E->setOperatorLoc(ReadSourceLocation());
E->setRParenLoc(ReadSourceLocation());
E->setTypeSourceInfo(GetTypeSourceInfo());
for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
- OffsetOfNode::Kind Kind = static_cast<OffsetOfNode::Kind>(Record[Idx++]);
+ OffsetOfNode::Kind Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
SourceLocation Start = ReadSourceLocation();
SourceLocation End = ReadSourceLocation();
switch (Kind) {
case OffsetOfNode::Array:
- E->setComponent(I, OffsetOfNode(Start, Record[Idx++], End));
+ E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
break;
case OffsetOfNode::Field:
@@ -559,12 +559,12 @@ void ASTStmtReader::VisitOffsetOfExpr(Of
case OffsetOfNode::Identifier:
E->setComponent(
I,
- OffsetOfNode(Start, Record.GetIdentifierInfo(Idx), End));
+ OffsetOfNode(Start, Record.GetIdentifierInfo(), End));
break;
case OffsetOfNode::Base: {
CXXBaseSpecifier *Base = new (Record.getContext()) CXXBaseSpecifier();
- *Base = Record.ReadCXXBaseSpecifier(Idx);
+ *Base = Record.ReadCXXBaseSpecifier();
E->setComponent(I, OffsetOfNode(Base));
break;
}
@@ -577,10 +577,10 @@ void ASTStmtReader::VisitOffsetOfExpr(Of
void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
VisitExpr(E);
- E->setKind(static_cast<UnaryExprOrTypeTrait>(Record[Idx++]));
- if (Record[Idx] == 0) {
+ E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
+ if (Record.peekInt() == 0) {
E->setArgument(Record.ReadSubExpr());
- ++Idx;
+ Record.skipInts(1);
} else {
E->setArgument(GetTypeSourceInfo());
}
@@ -606,7 +606,7 @@ void ASTStmtReader::VisitOMPArraySection
void ASTStmtReader::VisitCallExpr(CallExpr *E) {
VisitExpr(E);
- E->setNumArgs(Record.getContext(), Record[Idx++]);
+ E->setNumArgs(Record.getContext(), Record.readInt());
E->setRParenLoc(ReadSourceLocation());
E->setCallee(Record.ReadSubExpr());
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
@@ -628,33 +628,33 @@ void ASTStmtReader::VisitObjCIsaExpr(Obj
E->setBase(Record.ReadSubExpr());
E->setIsaMemberLoc(ReadSourceLocation());
E->setOpLoc(ReadSourceLocation());
- E->setArrow(Record[Idx++]);
+ E->setArrow(Record.readInt());
}
void ASTStmtReader::
VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
VisitExpr(E);
E->Operand = Record.ReadSubExpr();
- E->setShouldCopy(Record[Idx++]);
+ E->setShouldCopy(Record.readInt());
}
void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
VisitExplicitCastExpr(E);
E->LParenLoc = ReadSourceLocation();
E->BridgeKeywordLoc = ReadSourceLocation();
- E->Kind = Record[Idx++];
+ E->Kind = Record.readInt();
}
void ASTStmtReader::VisitCastExpr(CastExpr *E) {
VisitExpr(E);
- unsigned NumBaseSpecs = Record[Idx++];
+ unsigned NumBaseSpecs = Record.readInt();
assert(NumBaseSpecs == E->path_size());
E->setSubExpr(Record.ReadSubExpr());
- E->setCastKind((CastKind)Record[Idx++]);
+ E->setCastKind((CastKind)Record.readInt());
CastExpr::path_iterator BaseI = E->path_begin();
while (NumBaseSpecs--) {
CXXBaseSpecifier *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
- *BaseSpec = Record.ReadCXXBaseSpecifier(Idx);
+ *BaseSpec = Record.ReadCXXBaseSpecifier();
*BaseI++ = BaseSpec;
}
}
@@ -663,15 +663,15 @@ void ASTStmtReader::VisitBinaryOperator(
VisitExpr(E);
E->setLHS(Record.ReadSubExpr());
E->setRHS(Record.ReadSubExpr());
- E->setOpcode((BinaryOperator::Opcode)Record[Idx++]);
+ E->setOpcode((BinaryOperator::Opcode)Record.readInt());
E->setOperatorLoc(ReadSourceLocation());
- E->setFPContractable((bool)Record[Idx++]);
+ E->setFPContractable((bool)Record.readInt());
}
void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
VisitBinaryOperator(E);
- E->setComputationLHSType(Record.readType(Idx));
- E->setComputationResultType(Record.readType(Idx));
+ E->setComputationLHSType(Record.readType());
+ E->setComputationResultType(Record.readType());
}
void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
@@ -715,13 +715,13 @@ void ASTStmtReader::VisitCompoundLiteral
E->setLParenLoc(ReadSourceLocation());
E->setTypeSourceInfo(GetTypeSourceInfo());
E->setInitializer(Record.ReadSubExpr());
- E->setFileScope(Record[Idx++]);
+ E->setFileScope(Record.readInt());
}
void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
VisitExpr(E);
E->setBase(Record.ReadSubExpr());
- E->setAccessor(Record.GetIdentifierInfo(Idx));
+ E->setAccessor(Record.GetIdentifierInfo());
E->setAccessorLoc(ReadSourceLocation());
}
@@ -731,15 +731,15 @@ void ASTStmtReader::VisitInitListExpr(In
E->setSyntacticForm(SyntForm);
E->setLBraceLoc(ReadSourceLocation());
E->setRBraceLoc(ReadSourceLocation());
- bool isArrayFiller = Record[Idx++];
+ bool isArrayFiller = Record.readInt();
Expr *filler = nullptr;
if (isArrayFiller) {
filler = Record.ReadSubExpr();
E->ArrayFillerOrUnionFieldInit = filler;
} else
E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>();
- E->sawArrayRangeDesignator(Record[Idx++]);
- unsigned NumInits = Record[Idx++];
+ E->sawArrayRangeDesignator(Record.readInt());
+ unsigned NumInits = Record.readInt();
E->reserveInits(Record.getContext(), NumInits);
if (isArrayFiller) {
for (unsigned I = 0; I != NumInits; ++I) {
@@ -756,16 +756,16 @@ void ASTStmtReader::VisitDesignatedInitE
typedef DesignatedInitExpr::Designator Designator;
VisitExpr(E);
- unsigned NumSubExprs = Record[Idx++];
+ unsigned NumSubExprs = Record.readInt();
assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
for (unsigned I = 0; I != NumSubExprs; ++I)
E->setSubExpr(I, Record.ReadSubExpr());
E->setEqualOrColonLoc(ReadSourceLocation());
- E->setGNUSyntax(Record[Idx++]);
+ E->setGNUSyntax(Record.readInt());
SmallVector<Designator, 4> Designators;
- while (Idx < Record.size()) {
- switch ((DesignatorTypes)Record[Idx++]) {
+ while (Record.getIdx() < Record.size()) {
+ switch ((DesignatorTypes)Record.readInt()) {
case DESIG_FIELD_DECL: {
FieldDecl *Field = ReadDeclAs<FieldDecl>();
SourceLocation DotLoc = ReadSourceLocation();
@@ -777,7 +777,7 @@ void ASTStmtReader::VisitDesignatedInitE
}
case DESIG_FIELD_NAME: {
- const IdentifierInfo *Name = Record.GetIdentifierInfo(Idx);
+ const IdentifierInfo *Name = Record.GetIdentifierInfo();
SourceLocation DotLoc = ReadSourceLocation();
SourceLocation FieldLoc = ReadSourceLocation();
Designators.push_back(Designator(Name, DotLoc, FieldLoc));
@@ -785,7 +785,7 @@ void ASTStmtReader::VisitDesignatedInitE
}
case DESIG_ARRAY: {
- unsigned Index = Record[Idx++];
+ unsigned Index = Record.readInt();
SourceLocation LBracketLoc = ReadSourceLocation();
SourceLocation RBracketLoc = ReadSourceLocation();
Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
@@ -793,7 +793,7 @@ void ASTStmtReader::VisitDesignatedInitE
}
case DESIG_ARRAY_RANGE: {
- unsigned Index = Record[Idx++];
+ unsigned Index = Record.readInt();
SourceLocation LBracketLoc = ReadSourceLocation();
SourceLocation EllipsisLoc = ReadSourceLocation();
SourceLocation RBracketLoc = ReadSourceLocation();
@@ -837,7 +837,7 @@ void ASTStmtReader::VisitVAArgExpr(VAArg
E->setWrittenTypeInfo(GetTypeSourceInfo());
E->setBuiltinLoc(ReadSourceLocation());
E->setRParenLoc(ReadSourceLocation());
- E->setIsMicrosoftABI(Record[Idx++]);
+ E->setIsMicrosoftABI(Record.readInt());
}
void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
@@ -861,7 +861,7 @@ void ASTStmtReader::VisitChooseExpr(Choo
E->setRHS(Record.ReadSubExpr());
E->setBuiltinLoc(ReadSourceLocation());
E->setRParenLoc(ReadSourceLocation());
- E->setIsConditionTrue(Record[Idx++]);
+ E->setIsConditionTrue(Record.readInt());
}
void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
@@ -872,7 +872,7 @@ void ASTStmtReader::VisitGNUNullExpr(GNU
void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
VisitExpr(E);
SmallVector<Expr *, 16> Exprs;
- unsigned NumExprs = Record[Idx++];
+ unsigned NumExprs = Record.readInt();
while (NumExprs--)
Exprs.push_back(Record.ReadSubExpr());
E->setExprs(Record.getContext(), Exprs);
@@ -895,7 +895,7 @@ void ASTStmtReader::VisitBlockExpr(Block
void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
VisitExpr(E);
- E->NumAssocs = Record[Idx++];
+ E->NumAssocs = Record.readInt();
E->AssocTypes = new (Record.getContext()) TypeSourceInfo*[E->NumAssocs];
E->SubExprs =
new(Record.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
@@ -905,7 +905,7 @@ void ASTStmtReader::VisitGenericSelectio
E->AssocTypes[I] = GetTypeSourceInfo();
E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Record.ReadSubExpr();
}
- E->ResultIndex = Record[Idx++];
+ E->ResultIndex = Record.readInt();
E->GenericLoc = ReadSourceLocation();
E->DefaultLoc = ReadSourceLocation();
@@ -914,9 +914,9 @@ void ASTStmtReader::VisitGenericSelectio
void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
VisitExpr(E);
- unsigned numSemanticExprs = Record[Idx++];
+ unsigned numSemanticExprs = Record.readInt();
assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
- E->PseudoObjectExprBits.ResultIndex = Record[Idx++];
+ E->PseudoObjectExprBits.ResultIndex = Record.readInt();
// Read the syntactic expression.
E->getSubExprsBuffer()[0] = Record.ReadSubExpr();
@@ -930,7 +930,7 @@ void ASTStmtReader::VisitPseudoObjectExp
void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
VisitExpr(E);
- E->Op = AtomicExpr::AtomicOp(Record[Idx++]);
+ E->Op = AtomicExpr::AtomicOp(Record.readInt());
E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
for (unsigned I = 0; I != E->NumSubExprs; ++I)
E->SubExprs[I] = Record.ReadSubExpr();
@@ -957,7 +957,7 @@ void ASTStmtReader::VisitObjCBoxedExpr(O
void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
VisitExpr(E);
- unsigned NumElements = Record[Idx++];
+ unsigned NumElements = Record.readInt();
assert(NumElements == E->getNumElements() && "Wrong number of elements");
Expr **Elements = E->getElements();
for (unsigned I = 0, N = NumElements; I != N; ++I)
@@ -968,9 +968,9 @@ void ASTStmtReader::VisitObjCArrayLitera
void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
VisitExpr(E);
- unsigned NumElements = Record[Idx++];
+ unsigned NumElements = Record.readInt();
assert(NumElements == E->getNumElements() && "Wrong number of elements");
- bool HasPackExpansions = Record[Idx++];
+ bool HasPackExpansions = Record.readInt();
assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
ObjCDictionaryLiteral::KeyValuePair *KeyValues =
E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
@@ -981,7 +981,7 @@ void ASTStmtReader::VisitObjCDictionaryL
KeyValues[I].Value = Record.ReadSubExpr();
if (HasPackExpansions) {
Expansions[I].EllipsisLoc = ReadSourceLocation();
- Expansions[I].NumExpansionsPlusOne = Record[Idx++];
+ Expansions[I].NumExpansionsPlusOne = Record.readInt();
}
}
E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
@@ -997,7 +997,7 @@ void ASTStmtReader::VisitObjCEncodeExpr(
void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
VisitExpr(E);
- E->setSelector(Record.ReadSelector(Idx));
+ E->setSelector(Record.ReadSelector());
E->setAtLoc(ReadSourceLocation());
E->setRParenLoc(ReadSourceLocation());
}
@@ -1016,14 +1016,14 @@ void ASTStmtReader::VisitObjCIvarRefExpr
E->setLocation(ReadSourceLocation());
E->setOpLoc(ReadSourceLocation());
E->setBase(Record.ReadSubExpr());
- E->setIsArrow(Record[Idx++]);
- E->setIsFreeIvar(Record[Idx++]);
+ E->setIsArrow(Record.readInt());
+ E->setIsFreeIvar(Record.readInt());
}
void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
VisitExpr(E);
- unsigned MethodRefFlags = Record[Idx++];
- bool Implicit = Record[Idx++] != 0;
+ unsigned MethodRefFlags = Record.readInt();
+ bool Implicit = Record.readInt() != 0;
if (Implicit) {
ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>();
ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>();
@@ -1033,12 +1033,12 @@ void ASTStmtReader::VisitObjCPropertyRef
}
E->setLocation(ReadSourceLocation());
E->setReceiverLocation(ReadSourceLocation());
- switch (Record[Idx++]) {
+ switch (Record.readInt()) {
case 0:
E->setBase(Record.ReadSubExpr());
break;
case 1:
- E->setSuperReceiver(Record.readType(Idx));
+ E->setSuperReceiver(Record.readType());
break;
case 2:
E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>());
@@ -1057,14 +1057,14 @@ void ASTStmtReader::VisitObjCSubscriptRe
void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
VisitExpr(E);
- assert(Record[Idx] == E->getNumArgs());
- ++Idx;
- unsigned NumStoredSelLocs = Record[Idx++];
- E->SelLocsKind = Record[Idx++];
- E->setDelegateInitCall(Record[Idx++]);
- E->IsImplicit = Record[Idx++];
+ assert(Record.peekInt() == E->getNumArgs());
+ Record.skipInts(1);
+ unsigned NumStoredSelLocs = Record.readInt();
+ E->SelLocsKind = Record.readInt();
+ E->setDelegateInitCall(Record.readInt());
+ E->IsImplicit = Record.readInt();
ObjCMessageExpr::ReceiverKind Kind
- = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]);
+ = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
switch (Kind) {
case ObjCMessageExpr::Instance:
E->setInstanceReceiver(Record.ReadSubExpr());
@@ -1076,7 +1076,7 @@ void ASTStmtReader::VisitObjCMessageExpr
case ObjCMessageExpr::SuperClass:
case ObjCMessageExpr::SuperInstance: {
- QualType T = Record.readType(Idx);
+ QualType T = Record.readType();
SourceLocation SuperLoc = ReadSourceLocation();
E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
break;
@@ -1085,10 +1085,10 @@ void ASTStmtReader::VisitObjCMessageExpr
assert(Kind == E->getReceiverKind());
- if (Record[Idx++])
+ if (Record.readInt())
E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>());
else
- E->setSelector(Record.ReadSelector(Idx));
+ E->setSelector(Record.ReadSelector());
E->LBracLoc = ReadSourceLocation();
E->RBracLoc = ReadSourceLocation();
@@ -1132,9 +1132,9 @@ void ASTStmtReader::VisitObjCAutorelease
void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
VisitStmt(S);
- assert(Record[Idx] == S->getNumCatchStmts());
- ++Idx;
- bool HasFinally = Record[Idx++];
+ assert(Record.peekInt() == S->getNumCatchStmts());
+ Record.skipInts(1);
+ bool HasFinally = Record.readInt();
S->setTryBody(Record.ReadSubStmt());
for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.ReadSubStmt()));
@@ -1159,16 +1159,16 @@ void ASTStmtReader::VisitObjCAtThrowStmt
void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
VisitExpr(E);
- E->setValue(Record[Idx++]);
+ E->setValue(Record.readInt());
E->setLocation(ReadSourceLocation());
}
void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
VisitExpr(E);
- SourceRange R = Record.ReadSourceRange(Idx);
+ SourceRange R = Record.ReadSourceRange();
E->AtLoc = R.getBegin();
E->RParen = R.getEnd();
- E->VersionToCheck = Record.ReadVersionTuple(Idx);
+ E->VersionToCheck = Record.ReadVersionTuple();
}
//===----------------------------------------------------------------------===//
@@ -1184,8 +1184,8 @@ void ASTStmtReader::VisitCXXCatchStmt(CX
void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
VisitStmt(S);
- assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?");
- ++Idx;
+ assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
+ Record.skipInts(1);
S->TryLoc = ReadSourceLocation();
S->getStmts()[0] = Record.ReadSubStmt();
for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
@@ -1210,34 +1210,34 @@ void ASTStmtReader::VisitCXXForRangeStmt
void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
VisitStmt(S);
S->KeywordLoc = ReadSourceLocation();
- S->IsIfExists = Record[Idx++];
- S->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx);
+ S->IsIfExists = Record.readInt();
+ S->QualifierLoc = Record.ReadNestedNameSpecifierLoc();
ReadDeclarationNameInfo(S->NameInfo);
S->SubStmt = Record.ReadSubStmt();
}
void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
VisitCallExpr(E);
- E->Operator = (OverloadedOperatorKind)Record[Idx++];
- E->Range = Record.ReadSourceRange(Idx);
- E->setFPContractable((bool)Record[Idx++]);
+ E->Operator = (OverloadedOperatorKind)Record.readInt();
+ E->Range = Record.ReadSourceRange();
+ E->setFPContractable((bool)Record.readInt());
}
void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
VisitExpr(E);
- E->NumArgs = Record[Idx++];
+ E->NumArgs = Record.readInt();
if (E->NumArgs)
E->Args = new (Record.getContext()) Stmt*[E->NumArgs];
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
E->setArg(I, Record.ReadSubExpr());
E->setConstructor(ReadDeclAs<CXXConstructorDecl>());
E->setLocation(ReadSourceLocation());
- E->setElidable(Record[Idx++]);
- E->setHadMultipleCandidates(Record[Idx++]);
- E->setListInitialization(Record[Idx++]);
- E->setStdInitListInitialization(Record[Idx++]);
- E->setRequiresZeroInitialization(Record[Idx++]);
- E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]);
+ E->setElidable(Record.readInt());
+ E->setHadMultipleCandidates(Record.readInt());
+ E->setListInitialization(Record.readInt());
+ E->setStdInitListInitialization(Record.readInt());
+ E->setRequiresZeroInitialization(Record.readInt());
+ E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record.readInt());
E->ParenOrBraceRange = ReadSourceRange();
}
@@ -1245,8 +1245,8 @@ void ASTStmtReader::VisitCXXInheritedCto
VisitExpr(E);
E->Constructor = ReadDeclAs<CXXConstructorDecl>();
E->Loc = ReadSourceLocation();
- E->ConstructsVirtualBase = Record[Idx++];
- E->InheritedFromVirtualBase = Record[Idx++];
+ E->ConstructsVirtualBase = Record.readInt();
+ E->InheritedFromVirtualBase = Record.readInt();
}
void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
@@ -1256,13 +1256,13 @@ void ASTStmtReader::VisitCXXTemporaryObj
void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
VisitExpr(E);
- unsigned NumCaptures = Record[Idx++];
+ unsigned NumCaptures = Record.readInt();
assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
E->IntroducerRange = ReadSourceRange();
- E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record[Idx++]);
+ E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record.readInt());
E->CaptureDefaultLoc = ReadSourceLocation();
- E->ExplicitParams = Record[Idx++];
- E->ExplicitResultType = Record[Idx++];
+ E->ExplicitParams = Record.readInt();
+ E->ExplicitResultType = Record.readInt();
E->ClosingBrace = ReadSourceLocation();
// Read capture initializers.
@@ -1316,7 +1316,7 @@ void ASTStmtReader::VisitUserDefinedLite
void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
VisitExpr(E);
- E->setValue(Record[Idx++]);
+ E->setValue(Record.readInt());
E->setLocation(ReadSourceLocation());
}
@@ -1341,14 +1341,14 @@ void ASTStmtReader::VisitCXXTypeidExpr(C
void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
VisitExpr(E);
E->setLocation(ReadSourceLocation());
- E->setImplicit(Record[Idx++]);
+ E->setImplicit(Record.readInt());
}
void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
VisitExpr(E);
E->ThrowLoc = ReadSourceLocation();
E->Op = Record.ReadSubExpr();
- E->IsThrownVariableInScope = Record[Idx++];
+ E->IsThrownVariableInScope = Record.readInt();
}
void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
@@ -1365,7 +1365,7 @@ void ASTStmtReader::VisitCXXDefaultInitE
void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
VisitExpr(E);
- E->setTemporary(Record.ReadCXXTemporary(Idx));
+ E->setTemporary(Record.ReadCXXTemporary());
E->setSubExpr(Record.ReadSubExpr());
}
@@ -1377,12 +1377,12 @@ void ASTStmtReader::VisitCXXScalarValueI
void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
VisitExpr(E);
- E->GlobalNew = Record[Idx++];
- bool isArray = Record[Idx++];
- E->PassAlignment = Record[Idx++];
- E->UsualArrayDeleteWantsSize = Record[Idx++];
- unsigned NumPlacementArgs = Record[Idx++];
- E->StoredInitializationStyle = Record[Idx++];
+ E->GlobalNew = Record.readInt();
+ bool isArray = Record.readInt();
+ E->PassAlignment = Record.readInt();
+ E->UsualArrayDeleteWantsSize = Record.readInt();
+ unsigned NumPlacementArgs = Record.readInt();
+ E->StoredInitializationStyle = Record.readInt();
E->setOperatorNew(ReadDeclAs<FunctionDecl>());
E->setOperatorDelete(ReadDeclAs<FunctionDecl>());
E->AllocatedTypeInfo = GetTypeSourceInfo();
@@ -1401,10 +1401,10 @@ void ASTStmtReader::VisitCXXNewExpr(CXXN
void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
VisitExpr(E);
- E->GlobalDelete = Record[Idx++];
- E->ArrayForm = Record[Idx++];
- E->ArrayFormAsWritten = Record[Idx++];
- E->UsualArrayDeleteWantsSize = Record[Idx++];
+ E->GlobalDelete = Record.readInt();
+ E->ArrayForm = Record.readInt();
+ E->ArrayFormAsWritten = Record.readInt();
+ E->UsualArrayDeleteWantsSize = Record.readInt();
E->OperatorDelete = ReadDeclAs<FunctionDecl>();
E->Argument = Record.ReadSubExpr();
E->Loc = ReadSourceLocation();
@@ -1414,14 +1414,14 @@ void ASTStmtReader::VisitCXXPseudoDestru
VisitExpr(E);
E->Base = Record.ReadSubExpr();
- E->IsArrow = Record[Idx++];
+ E->IsArrow = Record.readInt();
E->OperatorLoc = ReadSourceLocation();
- E->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx);
+ E->QualifierLoc = Record.ReadNestedNameSpecifierLoc();
E->ScopeType = GetTypeSourceInfo();
E->ColonColonLoc = ReadSourceLocation();
E->TildeLoc = ReadSourceLocation();
- IdentifierInfo *II = Record.GetIdentifierInfo(Idx);
+ IdentifierInfo *II = Record.GetIdentifierInfo();
if (II)
E->setDestroyedType(II, ReadSourceLocation());
else
@@ -1431,13 +1431,13 @@ void ASTStmtReader::VisitCXXPseudoDestru
void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
VisitExpr(E);
- unsigned NumObjects = Record[Idx++];
+ unsigned NumObjects = Record.readInt();
assert(NumObjects == E->getNumObjects());
for (unsigned i = 0; i != NumObjects; ++i)
E->getTrailingObjects<BlockDecl *>()[i] =
ReadDeclAs<BlockDecl>();
- E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record[Idx++];
+ E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
E->SubExpr = Record.ReadSubExpr();
}
@@ -1445,17 +1445,17 @@ void
ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
VisitExpr(E);
- if (Record[Idx++]) // HasTemplateKWAndArgsInfo
+ if (Record.readInt()) // HasTemplateKWAndArgsInfo
ReadTemplateKWAndArgsInfo(
*E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
E->getTrailingObjects<TemplateArgumentLoc>(),
- /*NumTemplateArgs=*/Record[Idx++]);
+ /*NumTemplateArgs=*/Record.readInt());
E->Base = Record.ReadSubExpr();
- E->BaseType = Record.readType(Idx);
- E->IsArrow = Record[Idx++];
+ E->BaseType = Record.readType();
+ E->IsArrow = Record.readInt();
E->OperatorLoc = ReadSourceLocation();
- E->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx);
+ E->QualifierLoc = Record.ReadNestedNameSpecifierLoc();
E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>();
ReadDeclarationNameInfo(E->MemberNameInfo);
}
@@ -1464,21 +1464,22 @@ void
ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
VisitExpr(E);
- if (Record[Idx++]) // HasTemplateKWAndArgsInfo
+ if (Record.readInt()) // HasTemplateKWAndArgsInfo
ReadTemplateKWAndArgsInfo(
*E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
E->getTrailingObjects<TemplateArgumentLoc>(),
- /*NumTemplateArgs=*/Record[Idx++]);
+ /*NumTemplateArgs=*/Record.readInt());
- E->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx);
+ E->QualifierLoc = Record.ReadNestedNameSpecifierLoc();
ReadDeclarationNameInfo(E->NameInfo);
}
void
ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
VisitExpr(E);
- assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?");
- ++Idx; // NumArgs;
+ assert(Record.peekInt() == E->arg_size() &&
+ "Read wrong record during creation ?");
+ Record.skipInts(1);
for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
E->setArg(I, Record.ReadSubExpr());
E->Type = GetTypeSourceInfo();
@@ -1489,45 +1490,45 @@ ASTStmtReader::VisitCXXUnresolvedConstru
void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
VisitExpr(E);
- if (Record[Idx++]) // HasTemplateKWAndArgsInfo
+ if (Record.readInt()) // HasTemplateKWAndArgsInfo
ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
E->getTrailingTemplateArgumentLoc(),
- /*NumTemplateArgs=*/Record[Idx++]);
+ /*NumTemplateArgs=*/Record.readInt());
- unsigned NumDecls = Record[Idx++];
+ unsigned NumDecls = Record.readInt();
UnresolvedSet<8> Decls;
for (unsigned i = 0; i != NumDecls; ++i) {
NamedDecl *D = ReadDeclAs<NamedDecl>();
- AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
+ AccessSpecifier AS = (AccessSpecifier)Record.readInt();
Decls.addDecl(D, AS);
}
E->initializeResults(Record.getContext(), Decls.begin(), Decls.end());
ReadDeclarationNameInfo(E->NameInfo);
- E->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx);
+ E->QualifierLoc = Record.ReadNestedNameSpecifierLoc();
}
void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
VisitOverloadExpr(E);
- E->IsArrow = Record[Idx++];
- E->HasUnresolvedUsing = Record[Idx++];
+ E->IsArrow = Record.readInt();
+ E->HasUnresolvedUsing = Record.readInt();
E->Base = Record.ReadSubExpr();
- E->BaseType = Record.readType(Idx);
+ E->BaseType = Record.readType();
E->OperatorLoc = ReadSourceLocation();
}
void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
VisitOverloadExpr(E);
- E->RequiresADL = Record[Idx++];
- E->Overloaded = Record[Idx++];
+ E->RequiresADL = Record.readInt();
+ E->Overloaded = Record.readInt();
E->NamingClass = ReadDeclAs<CXXRecordDecl>();
}
void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
VisitExpr(E);
- E->TypeTraitExprBits.NumArgs = Record[Idx++];
- E->TypeTraitExprBits.Kind = Record[Idx++];
- E->TypeTraitExprBits.Value = Record[Idx++];
+ E->TypeTraitExprBits.NumArgs = Record.readInt();
+ E->TypeTraitExprBits.Kind = Record.readInt();
+ E->TypeTraitExprBits.Value = Record.readInt();
SourceRange Range = ReadSourceRange();
E->Loc = Range.getBegin();
E->RParenLoc = Range.getEnd();
@@ -1539,8 +1540,8 @@ void ASTStmtReader::VisitTypeTraitExpr(T
void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
VisitExpr(E);
- E->ATT = (ArrayTypeTrait)Record[Idx++];
- E->Value = (unsigned int)Record[Idx++];
+ E->ATT = (ArrayTypeTrait)Record.readInt();
+ E->Value = (unsigned int)Record.readInt();
SourceRange Range = ReadSourceRange();
E->Loc = Range.getBegin();
E->RParen = Range.getEnd();
@@ -1550,8 +1551,8 @@ void ASTStmtReader::VisitArrayTypeTraitE
void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
VisitExpr(E);
- E->ET = (ExpressionTrait)Record[Idx++];
- E->Value = (bool)Record[Idx++];
+ E->ET = (ExpressionTrait)Record.readInt();
+ E->Value = (bool)Record.readInt();
SourceRange Range = ReadSourceRange();
E->QueriedExpression = Record.ReadSubExpr();
E->Loc = Range.getBegin();
@@ -1560,7 +1561,7 @@ void ASTStmtReader::VisitExpressionTrait
void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
VisitExpr(E);
- E->Value = (bool)Record[Idx++];
+ E->Value = (bool)Record.readInt();
E->Range = ReadSourceRange();
E->Operand = Record.ReadSubExpr();
}
@@ -1568,25 +1569,25 @@ void ASTStmtReader::VisitCXXNoexceptExpr
void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
VisitExpr(E);
E->EllipsisLoc = ReadSourceLocation();
- E->NumExpansions = Record[Idx++];
+ E->NumExpansions = Record.readInt();
E->Pattern = Record.ReadSubExpr();
}
void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
VisitExpr(E);
- unsigned NumPartialArgs = Record[Idx++];
+ unsigned NumPartialArgs = Record.readInt();
E->OperatorLoc = ReadSourceLocation();
E->PackLoc = ReadSourceLocation();
E->RParenLoc = ReadSourceLocation();
- E->Pack = Record.ReadDeclAs<NamedDecl>(Idx);
+ E->Pack = Record.ReadDeclAs<NamedDecl>();
if (E->isPartiallySubstituted()) {
assert(E->Length == NumPartialArgs);
for (auto *I = E->getTrailingObjects<TemplateArgument>(),
*E = I + NumPartialArgs;
I != E; ++I)
- new (I) TemplateArgument(Record.ReadTemplateArgument(Idx));
+ new (I) TemplateArgument(Record.ReadTemplateArgument());
} else if (!E->isValueDependent()) {
- E->Length = Record[Idx++];
+ E->Length = Record.readInt();
}
}
@@ -1602,7 +1603,7 @@ void ASTStmtReader::VisitSubstNonTypeTem
SubstNonTypeTemplateParmPackExpr *E) {
VisitExpr(E);
E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
- TemplateArgument ArgPack = Record.ReadTemplateArgument(Idx);
+ TemplateArgument ArgPack = Record.ReadTemplateArgument();
if (ArgPack.getKind() != TemplateArgument::Pack)
return;
@@ -1613,7 +1614,7 @@ void ASTStmtReader::VisitSubstNonTypeTem
void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
VisitExpr(E);
- E->NumParameters = Record[Idx++];
+ E->NumParameters = Record.readInt();
E->ParamPack = ReadDeclAs<ParmVarDecl>();
E->NameLoc = ReadSourceLocation();
ParmVarDecl **Parms = E->getTrailingObjects<ParmVarDecl *>();
@@ -1625,7 +1626,7 @@ void ASTStmtReader::VisitMaterializeTemp
VisitExpr(E);
E->State = Record.ReadSubExpr();
auto VD = ReadDeclAs<ValueDecl>();
- unsigned ManglingNumber = Record[Idx++];
+ unsigned ManglingNumber = Record.readInt();
E->setExtendingDecl(VD, ManglingNumber);
}
@@ -1636,7 +1637,7 @@ void ASTStmtReader::VisitCXXFoldExpr(CXX
E->RParenLoc = ReadSourceLocation();
E->SubExprs[0] = Record.ReadSubExpr();
E->SubExprs[1] = Record.ReadSubExpr();
- E->Opcode = (BinaryOperatorKind)Record[Idx++];
+ E->Opcode = (BinaryOperatorKind)Record.readInt();
}
void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
@@ -1654,9 +1655,9 @@ void ASTStmtReader::VisitTypoExpr(TypoEx
//===----------------------------------------------------------------------===//
void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
VisitExpr(E);
- E->IsArrow = (Record[Idx++] != 0);
+ E->IsArrow = (Record.readInt() != 0);
E->BaseExpr = Record.ReadSubExpr();
- E->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx);
+ E->QualifierLoc = Record.ReadNestedNameSpecifierLoc();
E->MemberLoc = ReadSourceLocation();
E->TheDecl = ReadDeclAs<MSPropertyDecl>();
}
@@ -1703,7 +1704,7 @@ void ASTStmtReader::VisitSEHFinallyStmt(
void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
VisitStmt(S);
- S->IsCXXTry = Record[Idx++];
+ S->IsCXXTry = Record.readInt();
S->TryLoc = ReadSourceLocation();
S->Children[SEHTryStmt::TRY] = Record.ReadSubStmt();
S->Children[SEHTryStmt::HANDLER] = Record.ReadSubStmt();
@@ -1736,10 +1737,9 @@ namespace clang {
class OMPClauseReader : public OMPClauseVisitor<OMPClauseReader> {
ASTStmtReader *Reader;
ASTContext &Context;
- unsigned &Idx;
public:
- OMPClauseReader(ASTStmtReader *R, ASTRecordReader &Record, unsigned &Idx)
- : Reader(R), Context(Record.getContext()), Idx(Idx) {}
+ OMPClauseReader(ASTStmtReader *R, ASTRecordReader &Record)
+ : Reader(R), Context(Record.getContext()) {}
#define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *C);
#include "clang/Basic/OpenMPKinds.def"
OMPClause *readClause();
@@ -1750,7 +1750,7 @@ public:
OMPClause *OMPClauseReader::readClause() {
OMPClause *C;
- switch (Reader->Record[Idx++]) {
+ switch (Reader->Record.readInt()) {
case OMPC_if:
C = new (Context) OMPIfClause();
break;
@@ -1815,46 +1815,46 @@ OMPClause *OMPClauseReader::readClause()
C = new (Context) OMPNogroupClause();
break;
case OMPC_private:
- C = OMPPrivateClause::CreateEmpty(Context, Reader->Record[Idx++]);
+ C = OMPPrivateClause::CreateEmpty(Context, Reader->Record.readInt());
break;
case OMPC_firstprivate:
- C = OMPFirstprivateClause::CreateEmpty(Context, Reader->Record[Idx++]);
+ C = OMPFirstprivateClause::CreateEmpty(Context, Reader->Record.readInt());
break;
case OMPC_lastprivate:
- C = OMPLastprivateClause::CreateEmpty(Context, Reader->Record[Idx++]);
+ C = OMPLastprivateClause::CreateEmpty(Context, Reader->Record.readInt());
break;
case OMPC_shared:
- C = OMPSharedClause::CreateEmpty(Context, Reader->Record[Idx++]);
+ C = OMPSharedClause::CreateEmpty(Context, Reader->Record.readInt());
break;
case OMPC_reduction:
- C = OMPReductionClause::CreateEmpty(Context, Reader->Record[Idx++]);
+ C = OMPReductionClause::CreateEmpty(Context, Reader->Record.readInt());
break;
case OMPC_linear:
- C = OMPLinearClause::CreateEmpty(Context, Reader->Record[Idx++]);
+ C = OMPLinearClause::CreateEmpty(Context, Reader->Record.readInt());
break;
case OMPC_aligned:
- C = OMPAlignedClause::CreateEmpty(Context, Reader->Record[Idx++]);
+ C = OMPAlignedClause::CreateEmpty(Context, Reader->Record.readInt());
break;
case OMPC_copyin:
- C = OMPCopyinClause::CreateEmpty(Context, Reader->Record[Idx++]);
+ C = OMPCopyinClause::CreateEmpty(Context, Reader->Record.readInt());
break;
case OMPC_copyprivate:
- C = OMPCopyprivateClause::CreateEmpty(Context, Reader->Record[Idx++]);
+ C = OMPCopyprivateClause::CreateEmpty(Context, Reader->Record.readInt());
break;
case OMPC_flush:
- C = OMPFlushClause::CreateEmpty(Context, Reader->Record[Idx++]);
+ C = OMPFlushClause::CreateEmpty(Context, Reader->Record.readInt());
break;
case OMPC_depend:
- C = OMPDependClause::CreateEmpty(Context, Reader->Record[Idx++]);
+ C = OMPDependClause::CreateEmpty(Context, Reader->Record.readInt());
break;
case OMPC_device:
C = new (Context) OMPDeviceClause();
break;
case OMPC_map: {
- unsigned NumVars = Reader->Record[Idx++];
- unsigned NumDeclarations = Reader->Record[Idx++];
- unsigned NumLists = Reader->Record[Idx++];
- unsigned NumComponents = Reader->Record[Idx++];
+ unsigned NumVars = Reader->Record.readInt();
+ unsigned NumDeclarations = Reader->Record.readInt();
+ unsigned NumLists = Reader->Record.readInt();
+ unsigned NumComponents = Reader->Record.readInt();
C = OMPMapClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists,
NumComponents);
break;
@@ -1884,37 +1884,37 @@ OMPClause *OMPClauseReader::readClause()
C = new (Context) OMPDefaultmapClause();
break;
case OMPC_to: {
- unsigned NumVars = Reader->Record[Idx++];
- unsigned NumDeclarations = Reader->Record[Idx++];
- unsigned NumLists = Reader->Record[Idx++];
- unsigned NumComponents = Reader->Record[Idx++];
+ unsigned NumVars = Reader->Record.readInt();
+ unsigned NumDeclarations = Reader->Record.readInt();
+ unsigned NumLists = Reader->Record.readInt();
+ unsigned NumComponents = Reader->Record.readInt();
C = OMPToClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists,
NumComponents);
break;
}
case OMPC_from: {
- unsigned NumVars = Reader->Record[Idx++];
- unsigned NumDeclarations = Reader->Record[Idx++];
- unsigned NumLists = Reader->Record[Idx++];
- unsigned NumComponents = Reader->Record[Idx++];
+ unsigned NumVars = Reader->Record.readInt();
+ unsigned NumDeclarations = Reader->Record.readInt();
+ unsigned NumLists = Reader->Record.readInt();
+ unsigned NumComponents = Reader->Record.readInt();
C = OMPFromClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists,
NumComponents);
break;
}
case OMPC_use_device_ptr: {
- unsigned NumVars = Reader->Record[Idx++];
- unsigned NumDeclarations = Reader->Record[Idx++];
- unsigned NumLists = Reader->Record[Idx++];
- unsigned NumComponents = Reader->Record[Idx++];
+ unsigned NumVars = Reader->Record.readInt();
+ unsigned NumDeclarations = Reader->Record.readInt();
+ unsigned NumLists = Reader->Record.readInt();
+ unsigned NumComponents = Reader->Record.readInt();
C = OMPUseDevicePtrClause::CreateEmpty(Context, NumVars, NumDeclarations,
NumLists, NumComponents);
break;
}
case OMPC_is_device_ptr: {
- unsigned NumVars = Reader->Record[Idx++];
- unsigned NumDeclarations = Reader->Record[Idx++];
- unsigned NumLists = Reader->Record[Idx++];
- unsigned NumComponents = Reader->Record[Idx++];
+ unsigned NumVars = Reader->Record.readInt();
+ unsigned NumDeclarations = Reader->Record.readInt();
+ unsigned NumLists = Reader->Record.readInt();
+ unsigned NumComponents = Reader->Record.readInt();
C = OMPIsDevicePtrClause::CreateEmpty(Context, NumVars, NumDeclarations,
NumLists, NumComponents);
break;
@@ -1937,7 +1937,7 @@ void OMPClauseReader::VisitOMPClauseWith
}
void OMPClauseReader::VisitOMPIfClause(OMPIfClause *C) {
- C->setNameModifier(static_cast<OpenMPDirectiveKind>(Reader->Record[Idx++]));
+ C->setNameModifier(static_cast<OpenMPDirectiveKind>(Reader->Record.readInt()));
C->setNameModifierLoc(Reader->ReadSourceLocation());
C->setColonLoc(Reader->ReadSourceLocation());
C->setCondition(Reader->Record.ReadSubExpr());
@@ -1971,14 +1971,14 @@ void OMPClauseReader::VisitOMPCollapseCl
void OMPClauseReader::VisitOMPDefaultClause(OMPDefaultClause *C) {
C->setDefaultKind(
- static_cast<OpenMPDefaultClauseKind>(Reader->Record[Idx++]));
+ static_cast<OpenMPDefaultClauseKind>(Reader->Record.readInt()));
C->setLParenLoc(Reader->ReadSourceLocation());
C->setDefaultKindKwLoc(Reader->ReadSourceLocation());
}
void OMPClauseReader::VisitOMPProcBindClause(OMPProcBindClause *C) {
C->setProcBindKind(
- static_cast<OpenMPProcBindClauseKind>(Reader->Record[Idx++]));
+ static_cast<OpenMPProcBindClauseKind>(Reader->Record.readInt()));
C->setLParenLoc(Reader->ReadSourceLocation());
C->setProcBindKindKwLoc(Reader->ReadSourceLocation());
}
@@ -1986,11 +1986,11 @@ void OMPClauseReader::VisitOMPProcBindCl
void OMPClauseReader::VisitOMPScheduleClause(OMPScheduleClause *C) {
VisitOMPClauseWithPreInit(C);
C->setScheduleKind(
- static_cast<OpenMPScheduleClauseKind>(Reader->Record[Idx++]));
+ static_cast<OpenMPScheduleClauseKind>(Reader->Record.readInt()));
C->setFirstScheduleModifier(
- static_cast<OpenMPScheduleClauseModifier>(Reader->Record[Idx++]));
+ static_cast<OpenMPScheduleClauseModifier>(Reader->Record.readInt()));
C->setSecondScheduleModifier(
- static_cast<OpenMPScheduleClauseModifier>(Reader->Record[Idx++]));
+ static_cast<OpenMPScheduleClauseModifier>(Reader->Record.readInt()));
C->setChunkSize(Reader->Record.ReadSubExpr());
C->setLParenLoc(Reader->ReadSourceLocation());
C->setFirstScheduleModifierLoc(Reader->ReadSourceLocation());
@@ -2100,7 +2100,7 @@ void OMPClauseReader::VisitOMPReductionC
VisitOMPClauseWithPostUpdate(C);
C->setLParenLoc(Reader->ReadSourceLocation());
C->setColonLoc(Reader->ReadSourceLocation());
- NestedNameSpecifierLoc NNSL = Reader->Record.ReadNestedNameSpecifierLoc(Idx);
+ NestedNameSpecifierLoc NNSL = Reader->Record.ReadNestedNameSpecifierLoc();
DeclarationNameInfo DNI;
Reader->ReadDeclarationNameInfo(DNI);
C->setQualifierLoc(NNSL);
@@ -2134,7 +2134,7 @@ void OMPClauseReader::VisitOMPLinearClau
VisitOMPClauseWithPostUpdate(C);
C->setLParenLoc(Reader->ReadSourceLocation());
C->setColonLoc(Reader->ReadSourceLocation());
- C->setModifier(static_cast<OpenMPLinearClauseKind>(Reader->Record[Idx++]));
+ C->setModifier(static_cast<OpenMPLinearClauseKind>(Reader->Record.readInt()));
C->setModifierLoc(Reader->ReadSourceLocation());
unsigned NumVars = C->varlist_size();
SmallVector<Expr *, 16> Vars;
@@ -2231,7 +2231,7 @@ void OMPClauseReader::VisitOMPFlushClaus
void OMPClauseReader::VisitOMPDependClause(OMPDependClause *C) {
C->setLParenLoc(Reader->ReadSourceLocation());
C->setDependencyKind(
- static_cast<OpenMPDependClauseKind>(Reader->Record[Idx++]));
+ static_cast<OpenMPDependClauseKind>(Reader->Record.readInt()));
C->setDependencyLoc(Reader->ReadSourceLocation());
C->setColonLoc(Reader->ReadSourceLocation());
unsigned NumVars = C->varlist_size();
@@ -2251,9 +2251,9 @@ void OMPClauseReader::VisitOMPDeviceClau
void OMPClauseReader::VisitOMPMapClause(OMPMapClause *C) {
C->setLParenLoc(Reader->ReadSourceLocation());
C->setMapTypeModifier(
- static_cast<OpenMPMapClauseKind>(Reader->Record[Idx++]));
+ static_cast<OpenMPMapClauseKind>(Reader->Record.readInt()));
C->setMapType(
- static_cast<OpenMPMapClauseKind>(Reader->Record[Idx++]));
+ static_cast<OpenMPMapClauseKind>(Reader->Record.readInt()));
C->setMapLoc(Reader->ReadSourceLocation());
C->setColonLoc(Reader->ReadSourceLocation());
auto NumVars = C->varlist_size();
@@ -2270,26 +2270,26 @@ void OMPClauseReader::VisitOMPMapClause(
SmallVector<ValueDecl *, 16> Decls;
Decls.reserve(UniqueDecls);
for (unsigned i = 0; i < UniqueDecls; ++i)
- Decls.push_back(Reader->Record.ReadDeclAs<ValueDecl>(Idx));
+ Decls.push_back(Reader->Record.ReadDeclAs<ValueDecl>());
C->setUniqueDecls(Decls);
SmallVector<unsigned, 16> ListsPerDecl;
ListsPerDecl.reserve(UniqueDecls);
for (unsigned i = 0; i < UniqueDecls; ++i)
- ListsPerDecl.push_back(Reader->Record[Idx++]);
+ ListsPerDecl.push_back(Reader->Record.readInt());
C->setDeclNumLists(ListsPerDecl);
SmallVector<unsigned, 32> ListSizes;
ListSizes.reserve(TotalLists);
for (unsigned i = 0; i < TotalLists; ++i)
- ListSizes.push_back(Reader->Record[Idx++]);
+ ListSizes.push_back(Reader->Record.readInt());
C->setComponentListSizes(ListSizes);
SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
Components.reserve(TotalComponents);
for (unsigned i = 0; i < TotalComponents; ++i) {
Expr *AssociatedExpr = Reader->Record.ReadSubExpr();
- ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs<ValueDecl>(Idx);
+ ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs<ValueDecl>();
Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
AssociatedExpr, AssociatedDecl));
}
@@ -2329,7 +2329,7 @@ void OMPClauseReader::VisitOMPHintClause
void OMPClauseReader::VisitOMPDistScheduleClause(OMPDistScheduleClause *C) {
VisitOMPClauseWithPreInit(C);
C->setDistScheduleKind(
- static_cast<OpenMPDistScheduleClauseKind>(Reader->Record[Idx++]));
+ static_cast<OpenMPDistScheduleClauseKind>(Reader->Record.readInt()));
C->setChunkSize(Reader->Record.ReadSubExpr());
C->setLParenLoc(Reader->ReadSourceLocation());
C->setDistScheduleKindLoc(Reader->ReadSourceLocation());
@@ -2338,9 +2338,9 @@ void OMPClauseReader::VisitOMPDistSchedu
void OMPClauseReader::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) {
C->setDefaultmapKind(
- static_cast<OpenMPDefaultmapClauseKind>(Reader->Record[Idx++]));
+ static_cast<OpenMPDefaultmapClauseKind>(Reader->Record.readInt()));
C->setDefaultmapModifier(
- static_cast<OpenMPDefaultmapClauseModifier>(Reader->Record[Idx++]));
+ static_cast<OpenMPDefaultmapClauseModifier>(Reader->Record.readInt()));
C->setLParenLoc(Reader->ReadSourceLocation());
C->setDefaultmapModifierLoc(Reader->ReadSourceLocation());
C->setDefaultmapKindLoc(Reader->ReadSourceLocation());
@@ -2362,26 +2362,26 @@ void OMPClauseReader::VisitOMPToClause(O
SmallVector<ValueDecl *, 16> Decls;
Decls.reserve(UniqueDecls);
for (unsigned i = 0; i < UniqueDecls; ++i)
- Decls.push_back(Reader->Record.ReadDeclAs<ValueDecl>(Idx));
+ Decls.push_back(Reader->Record.ReadDeclAs<ValueDecl>());
C->setUniqueDecls(Decls);
SmallVector<unsigned, 16> ListsPerDecl;
ListsPerDecl.reserve(UniqueDecls);
for (unsigned i = 0; i < UniqueDecls; ++i)
- ListsPerDecl.push_back(Reader->Record[Idx++]);
+ ListsPerDecl.push_back(Reader->Record.readInt());
C->setDeclNumLists(ListsPerDecl);
SmallVector<unsigned, 32> ListSizes;
ListSizes.reserve(TotalLists);
for (unsigned i = 0; i < TotalLists; ++i)
- ListSizes.push_back(Reader->Record[Idx++]);
+ ListSizes.push_back(Reader->Record.readInt());
C->setComponentListSizes(ListSizes);
SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
Components.reserve(TotalComponents);
for (unsigned i = 0; i < TotalComponents; ++i) {
Expr *AssociatedExpr = Reader->Record.ReadSubExpr();
- ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs<ValueDecl>(Idx);
+ ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs<ValueDecl>();
Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
AssociatedExpr, AssociatedDecl));
}
@@ -2404,26 +2404,26 @@ void OMPClauseReader::VisitOMPFromClause
SmallVector<ValueDecl *, 16> Decls;
Decls.reserve(UniqueDecls);
for (unsigned i = 0; i < UniqueDecls; ++i)
- Decls.push_back(Reader->Record.ReadDeclAs<ValueDecl>(Idx));
+ Decls.push_back(Reader->Record.ReadDeclAs<ValueDecl>());
C->setUniqueDecls(Decls);
SmallVector<unsigned, 16> ListsPerDecl;
ListsPerDecl.reserve(UniqueDecls);
for (unsigned i = 0; i < UniqueDecls; ++i)
- ListsPerDecl.push_back(Reader->Record[Idx++]);
+ ListsPerDecl.push_back(Reader->Record.readInt());
C->setDeclNumLists(ListsPerDecl);
SmallVector<unsigned, 32> ListSizes;
ListSizes.reserve(TotalLists);
for (unsigned i = 0; i < TotalLists; ++i)
- ListSizes.push_back(Reader->Record[Idx++]);
+ ListSizes.push_back(Reader->Record.readInt());
C->setComponentListSizes(ListSizes);
SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
Components.reserve(TotalComponents);
for (unsigned i = 0; i < TotalComponents; ++i) {
Expr *AssociatedExpr = Reader->Record.ReadSubExpr();
- ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs<ValueDecl>(Idx);
+ ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs<ValueDecl>();
Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
AssociatedExpr, AssociatedDecl));
}
@@ -2454,26 +2454,26 @@ void OMPClauseReader::VisitOMPUseDeviceP
SmallVector<ValueDecl *, 16> Decls;
Decls.reserve(UniqueDecls);
for (unsigned i = 0; i < UniqueDecls; ++i)
- Decls.push_back(Reader->Record.ReadDeclAs<ValueDecl>(Idx));
+ Decls.push_back(Reader->Record.ReadDeclAs<ValueDecl>());
C->setUniqueDecls(Decls);
SmallVector<unsigned, 16> ListsPerDecl;
ListsPerDecl.reserve(UniqueDecls);
for (unsigned i = 0; i < UniqueDecls; ++i)
- ListsPerDecl.push_back(Reader->Record[Idx++]);
+ ListsPerDecl.push_back(Reader->Record.readInt());
C->setDeclNumLists(ListsPerDecl);
SmallVector<unsigned, 32> ListSizes;
ListSizes.reserve(TotalLists);
for (unsigned i = 0; i < TotalLists; ++i)
- ListSizes.push_back(Reader->Record[Idx++]);
+ ListSizes.push_back(Reader->Record.readInt());
C->setComponentListSizes(ListSizes);
SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
Components.reserve(TotalComponents);
for (unsigned i = 0; i < TotalComponents; ++i) {
Expr *AssociatedExpr = Reader->Record.ReadSubExpr();
- ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs<ValueDecl>(Idx);
+ ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs<ValueDecl>();
Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
AssociatedExpr, AssociatedDecl));
}
@@ -2497,26 +2497,26 @@ void OMPClauseReader::VisitOMPIsDevicePt
SmallVector<ValueDecl *, 16> Decls;
Decls.reserve(UniqueDecls);
for (unsigned i = 0; i < UniqueDecls; ++i)
- Decls.push_back(Reader->Record.ReadDeclAs<ValueDecl>(Idx));
+ Decls.push_back(Reader->Record.ReadDeclAs<ValueDecl>());
C->setUniqueDecls(Decls);
SmallVector<unsigned, 16> ListsPerDecl;
ListsPerDecl.reserve(UniqueDecls);
for (unsigned i = 0; i < UniqueDecls; ++i)
- ListsPerDecl.push_back(Reader->Record[Idx++]);
+ ListsPerDecl.push_back(Reader->Record.readInt());
C->setDeclNumLists(ListsPerDecl);
SmallVector<unsigned, 32> ListSizes;
ListSizes.reserve(TotalLists);
for (unsigned i = 0; i < TotalLists; ++i)
- ListSizes.push_back(Reader->Record[Idx++]);
+ ListSizes.push_back(Reader->Record.readInt());
C->setComponentListSizes(ListSizes);
SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
Components.reserve(TotalComponents);
for (unsigned i = 0; i < TotalComponents; ++i) {
Expr *AssociatedExpr = Reader->Record.ReadSubExpr();
- ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs<ValueDecl>(Idx);
+ ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs<ValueDecl>();
Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
AssociatedExpr, AssociatedDecl));
}
@@ -2529,7 +2529,7 @@ void OMPClauseReader::VisitOMPIsDevicePt
void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
E->setLocStart(ReadSourceLocation());
E->setLocEnd(ReadSourceLocation());
- OMPClauseReader ClauseReader(this, Record, Idx);
+ OMPClauseReader ClauseReader(this, Record);
SmallVector<OMPClause *, 5> Clauses;
for (unsigned i = 0; i < E->getNumClauses(); ++i)
Clauses.push_back(ClauseReader.readClause());
@@ -2541,7 +2541,7 @@ void ASTStmtReader::VisitOMPExecutableDi
void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
VisitStmt(D);
// Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
- Idx += 2;
+ Record.skipInts(2);
VisitOMPExecutableDirective(D);
D->setIterationVariable(Record.ReadSubExpr());
D->setLastIteration(Record.ReadSubExpr());
@@ -2594,9 +2594,9 @@ void ASTStmtReader::VisitOMPLoopDirectiv
void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
- D->setHasCancel(Record[Idx++]);
+ D->setHasCancel(Record.readInt());
}
void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
@@ -2605,7 +2605,7 @@ void ASTStmtReader::VisitOMPSimdDirectiv
void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
VisitOMPLoopDirective(D);
- D->setHasCancel(Record[Idx++]);
+ D->setHasCancel(Record.readInt());
}
void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
@@ -2615,21 +2615,21 @@ void ASTStmtReader::VisitOMPForSimdDirec
void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
- D->setHasCancel(Record[Idx++]);
+ D->setHasCancel(Record.readInt());
}
void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
VisitStmt(D);
VisitOMPExecutableDirective(D);
- D->setHasCancel(Record[Idx++]);
+ D->setHasCancel(Record.readInt());
}
void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
}
@@ -2641,14 +2641,14 @@ void ASTStmtReader::VisitOMPMasterDirect
void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
ReadDeclarationNameInfo(D->DirName);
}
void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
VisitOMPLoopDirective(D);
- D->setHasCancel(Record[Idx++]);
+ D->setHasCancel(Record.readInt());
}
void ASTStmtReader::VisitOMPParallelForSimdDirective(
@@ -2660,17 +2660,17 @@ void ASTStmtReader::VisitOMPParallelSect
OMPParallelSectionsDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
- D->setHasCancel(Record[Idx++]);
+ D->setHasCancel(Record.readInt());
}
void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
- D->setHasCancel(Record[Idx++]);
+ D->setHasCancel(Record.readInt());
}
void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
@@ -2696,74 +2696,74 @@ void ASTStmtReader::VisitOMPTaskgroupDir
void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
}
void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
}
void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
D->setX(Record.ReadSubExpr());
D->setV(Record.ReadSubExpr());
D->setExpr(Record.ReadSubExpr());
D->setUpdateExpr(Record.ReadSubExpr());
- D->IsXLHSInRHSPart = Record[Idx++] != 0;
- D->IsPostfixUpdate = Record[Idx++] != 0;
+ D->IsXLHSInRHSPart = Record.readInt() != 0;
+ D->IsPostfixUpdate = Record.readInt() != 0;
}
void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
}
void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
VisitStmt(D);
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
}
void ASTStmtReader::VisitOMPTargetEnterDataDirective(
OMPTargetEnterDataDirective *D) {
VisitStmt(D);
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
}
void ASTStmtReader::VisitOMPTargetExitDataDirective(
OMPTargetExitDataDirective *D) {
VisitStmt(D);
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
}
void ASTStmtReader::VisitOMPTargetParallelDirective(
OMPTargetParallelDirective *D) {
VisitStmt(D);
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
}
void ASTStmtReader::VisitOMPTargetParallelForDirective(
OMPTargetParallelForDirective *D) {
VisitOMPLoopDirective(D);
- D->setHasCancel(Record[Idx++]);
+ D->setHasCancel(Record.readInt());
}
void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
}
@@ -2771,15 +2771,15 @@ void ASTStmtReader::VisitOMPCancellation
OMPCancellationPointDirective *D) {
VisitStmt(D);
VisitOMPExecutableDirective(D);
- D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record[Idx++]));
+ D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
}
void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
- D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record[Idx++]));
+ D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
}
void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
@@ -2796,7 +2796,7 @@ void ASTStmtReader::VisitOMPDistributeDi
void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
VisitStmt(D);
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
}
void ASTStmtReader::VisitOMPDistributeParallelForDirective(
@@ -2846,7 +2846,7 @@ void ASTStmtReader::VisitOMPTeamsDistrib
void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
}
@@ -2896,9 +2896,8 @@ Stmt *ASTReader::ReadStmtFromStream(Modu
unsigned PrevNumStmts = StmtStack.size();
#endif
- RecordData Record;
- unsigned Idx;
- ASTStmtReader Reader(*this, F, Cursor, Record, Idx);
+ ASTRecordReader Record(*this, F);
+ ASTStmtReader Reader(Record, Cursor);
Stmt::EmptyShell Empty;
while (true) {
@@ -2917,11 +2916,9 @@ Stmt *ASTReader::ReadStmtFromStream(Modu
}
Stmt *S = nullptr;
- Idx = 0;
- Record.clear();
bool Finished = false;
bool IsStmtReference = false;
- switch ((StmtCode)Cursor.readRecord(Entry.ID, Record)) {
+ switch ((StmtCode)Record.readRecord(Cursor, Entry.ID)) {
case STMT_STOP:
Finished = true;
break;
@@ -2930,7 +2927,7 @@ Stmt *ASTReader::ReadStmtFromStream(Modu
IsStmtReference = true;
assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
"No stmt was recorded for this offset reference!");
- S = StmtEntries[Record[Idx++]];
+ S = StmtEntries[Record.readInt()];
break;
case STMT_NULL_PTR:
@@ -3094,46 +3091,46 @@ Stmt *ASTReader::ReadStmtFromStream(Modu
// That way we can use MemberExpr::Create and don't have to duplicate its
// logic with a MemberExpr::CreateEmpty.
- assert(Idx == 0);
+ assert(Record.getIdx() == 0);
NestedNameSpecifierLoc QualifierLoc;
- if (Record[Idx++]) { // HasQualifier.
- QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
+ if (Record.readInt()) { // HasQualifier.
+ QualifierLoc = Record.ReadNestedNameSpecifierLoc();
}
SourceLocation TemplateKWLoc;
TemplateArgumentListInfo ArgInfo;
- bool HasTemplateKWAndArgsInfo = Record[Idx++];
+ bool HasTemplateKWAndArgsInfo = Record.readInt();
if (HasTemplateKWAndArgsInfo) {
- TemplateKWLoc = ReadSourceLocation(F, Record, Idx);
- unsigned NumTemplateArgs = Record[Idx++];
- ArgInfo.setLAngleLoc(ReadSourceLocation(F, Record, Idx));
- ArgInfo.setRAngleLoc(ReadSourceLocation(F, Record, Idx));
+ TemplateKWLoc = Record.ReadSourceLocation();
+ unsigned NumTemplateArgs = Record.readInt();
+ ArgInfo.setLAngleLoc(Record.ReadSourceLocation());
+ ArgInfo.setRAngleLoc(Record.ReadSourceLocation());
for (unsigned i = 0; i != NumTemplateArgs; ++i)
- ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx));
+ ArgInfo.addArgument(Record.ReadTemplateArgumentLoc());
}
- bool HadMultipleCandidates = Record[Idx++];
+ bool HadMultipleCandidates = Record.readInt();
- NamedDecl *FoundD = ReadDeclAs<NamedDecl>(F, Record, Idx);
- AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
+ NamedDecl *FoundD = Record.ReadDeclAs<NamedDecl>();
+ AccessSpecifier AS = (AccessSpecifier)Record.readInt();
DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
- QualType T = readType(F, Record, Idx);
- ExprValueKind VK = static_cast<ExprValueKind>(Record[Idx++]);
- ExprObjectKind OK = static_cast<ExprObjectKind>(Record[Idx++]);
+ QualType T = Record.readType();
+ ExprValueKind VK = static_cast<ExprValueKind>(Record.readInt());
+ ExprObjectKind OK = static_cast<ExprObjectKind>(Record.readInt());
Expr *Base = ReadSubExpr();
- ValueDecl *MemberD = ReadDeclAs<ValueDecl>(F, Record, Idx);
- SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx);
+ ValueDecl *MemberD = Record.ReadDeclAs<ValueDecl>();
+ SourceLocation MemberLoc = Record.ReadSourceLocation();
DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
- bool IsArrow = Record[Idx++];
- SourceLocation OperatorLoc = ReadSourceLocation(F, Record, Idx);
+ bool IsArrow = Record.readInt();
+ SourceLocation OperatorLoc = Record.ReadSourceLocation();
S = MemberExpr::Create(Context, Base, IsArrow, OperatorLoc, QualifierLoc,
TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
HasTemplateKWAndArgsInfo ? &ArgInfo : nullptr, T,
VK, OK);
- ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc,
- MemberD->getDeclName(), Record, Idx);
+ Record.ReadDeclarationNameLoc(cast<MemberExpr>(S)->MemberDNLoc,
+ MemberD->getDeclName());
if (HadMultipleCandidates)
cast<MemberExpr>(S)->setHadMultipleCandidates(true);
break;
@@ -3851,8 +3848,8 @@ Stmt *ASTReader::ReadStmtFromStream(Modu
StmtEntries[Cursor.GetCurrentBitNo()] = S;
}
-
- assert(Idx == Record.size() && "Invalid deserialization of statement");
+ assert(Record.getIdx() == Record.size() &&
+ "Invalid deserialization of statement");
StmtStack.push_back(S);
}
Done:
More information about the cfe-commits
mailing list