Index: include/clang/Serialization/ASTReader.h =================================================================== --- include/clang/Serialization/ASTReader.h +++ include/clang/Serialization/ASTReader.h @@ -47,6 +47,7 @@ #include namespace llvm { + class BitstreamCursor; class MemoryBuffer; class APInt; class APSInt; @@ -88,6 +89,7 @@ class ASTReader; class ASTDeclReader; class ASTStmtReader; +class ASTRecordReader; class TypeLocReader; struct HeaderFileInfo; class VersionTuple; @@ -2189,29 +2191,21 @@ 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) {} + ASTRecordReader(ASTReader &Reader, ModuleFile &F) + : Reader(&Reader), 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) {} - - /// \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(); } @@ -2219,6 +2213,25 @@ /// \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) { @@ -2244,9 +2257,8 @@ } void readExceptionSpec(SmallVectorImpl &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. @@ -2269,24 +2281,24 @@ /// \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. @@ -2295,21 +2307,21 @@ } /// \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, @@ -2318,133 +2330,131 @@ /// \returns The declaration read from this location, casted to the given /// result type. template - T *ReadDeclAs(unsigned &Idx) { - return Reader->ReadDeclAs(*F, *Record, Idx); + T *ReadDeclAs() { + return Reader->ReadDeclAs(*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 &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) { @@ -2455,7 +2465,6 @@ SwitchCase *getSwitchCaseWithID(unsigned ID) { return Reader->getSwitchCaseWithID(ID); } - }; /// \brief Helper class that saves the current stream position and Index: lib/Serialization/ASTReader.cpp =================================================================== --- lib/Serialization/ASTReader.cpp +++ lib/Serialization/ASTReader.cpp @@ -5836,17 +5836,27 @@ } class clang::TypeLocReader : public TypeLocVisitor { - 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 @@ -5867,10 +5877,10 @@ void TypeLocReader::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) { TL.setBuiltinLoc(ReadSourceLocation()); if (TL.needsExtraLocalData()) { - TL.setWrittenTypeSpec(static_cast(Reader[Idx++])); - TL.setWrittenSignSpec(static_cast(Reader[Idx++])); - TL.setWrittenWidthSpec(static_cast(Reader[Idx++])); - TL.setModeAttr(Reader[Idx++]); + TL.setWrittenTypeSpec(static_cast(Record[Idx++])); + TL.setWrittenSignSpec(static_cast(Record[Idx++])); + TL.setWrittenWidthSpec(static_cast(Record[Idx++])); + TL.setModeAttr(Record[Idx++]); } } @@ -5904,14 +5914,14 @@ 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); } @@ -5952,7 +5962,7 @@ TL.setRParenLoc(ReadSourceLocation()); TL.setLocalRangeEnd(ReadSourceLocation()); for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i) { - TL.setParam(i, Reader.ReadDeclAs(Idx)); + TL.setParam(i, Reader->ReadDeclAs(*F, Record, Idx)); } } @@ -5978,7 +5988,7 @@ 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()); @@ -5988,7 +5998,7 @@ TL.setKWLoc(ReadSourceLocation()); TL.setLParenLoc(ReadSourceLocation()); TL.setRParenLoc(ReadSourceLocation()); - TL.setUnderlyingTInfo(Reader.GetTypeSourceInfo(Idx)); + TL.setUnderlyingTInfo(GetTypeSourceInfo()); } void TypeLocReader::VisitAutoTypeLoc(AutoTypeLoc TL) { @@ -6012,8 +6022,8 @@ 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()) @@ -6039,9 +6049,10 @@ 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()); @@ -6050,7 +6061,7 @@ void TypeLocReader::VisitElaboratedTypeLoc(ElaboratedTypeLoc TL) { TL.setElaboratedKeywordLoc(ReadSourceLocation()); - TL.setQualifierLoc(Reader.ReadNestedNameSpecifierLoc(Idx)); + TL.setQualifierLoc(ReadNestedNameSpecifierLoc()); } void TypeLocReader::VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) { @@ -6059,22 +6070,23 @@ 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) { @@ -6095,11 +6107,11 @@ } 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) @@ -6120,15 +6132,15 @@ 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; @@ -8910,3 +8922,10 @@ 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); +} Index: lib/Serialization/ASTReaderDecl.cpp =================================================================== --- lib/Serialization/ASTReaderDecl.cpp +++ lib/Serialization/ASTReaderDecl.cpp @@ -35,12 +35,11 @@ namespace clang { class ASTDeclReader : public DeclVisitor { 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 @@ 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 @@ } 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 &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 T *ReadDeclAs() { - return Record.ReadDeclAs(Idx); + return Record.ReadDeclAs(); } 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 @@ } 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 @@ 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) {} @@ -463,9 +456,9 @@ // 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(FD)) { - CD->NumCtorInitializers = Record[Idx++]; + CD->NumCtorInitializers = Record.readInt(); if (CD->NumCtorInitializers) CD->CtorInitializers = ReadGlobalOffset(); } @@ -504,22 +497,22 @@ 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 @@ -551,7 +544,7 @@ 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(), Arg.data(), Arg.size()); D->getTrailingObjects()[Arg.size()] = '\0'; @@ -577,15 +570,15 @@ 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 @@ -593,8 +586,8 @@ 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); @@ -619,16 +612,16 @@ 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(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 @@ -639,7 +632,7 @@ } case 2: // TypedefNameForAnonDecl NamedDeclForTagDecl = ReadDeclID(); - TypedefNameForLinkage = Record.GetIdentifierInfo(Idx); + TypedefNameForLinkage = Record.GetIdentifierInfo(); break; default: llvm_unreachable("unexpected tag info kind"); @@ -655,13 +648,13 @@ 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. @@ -689,7 +682,8 @@ } if (EnumDecl *InstED = ReadDeclAs()) { - TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; + TemplateSpecializationKind TSK = + (TemplateSpecializationKind)Record.readInt(); SourceLocation POI = ReadSourceLocation(); ED->setInstantiationOfMemberEnum(Reader.getContext(), InstED, TSK); ED->getMemberSpecializationInfo()->setPointOfInstantiation(POI); @@ -699,30 +693,30 @@ 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); @@ -735,30 +729,30 @@ 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; @@ -768,7 +762,8 @@ break; case FunctionDecl::TK_MemberSpecialization: { FunctionDecl *InstFD = ReadDeclAs(); - TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; + TemplateSpecializationKind TSK = + (TemplateSpecializationKind)Record.readInt(); SourceLocation POI = ReadSourceLocation(); FD->setInstantiationOfMemberFunction(Reader.getContext(), InstFD, TSK); FD->getMemberSpecializationInfo()->setPointOfInstantiation(POI); @@ -777,22 +772,22 @@ } case FunctionDecl::TK_FunctionTemplateSpecialization: { FunctionTemplateDecl *Template = ReadDeclAs(); - TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; + TemplateSpecializationKind TSK = + (TemplateSpecializationKind)Record.readInt(); // Template arguments. SmallVector TemplArgs; - Record.ReadTemplateArgumentList(TemplArgs, Idx, - /*Canonicalize*/ true); + Record.ReadTemplateArgumentList(TemplArgs, /*Canonicalize*/ true); // Template args as written. SmallVector 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(); @@ -842,15 +837,15 @@ case FunctionDecl::TK_DependentFunctionTemplateSpecialization: { // Templates. UnresolvedSet<8> TemplDecls; - unsigned NumTemplates = Record[Idx++]; + unsigned NumTemplates = Record.readInt(); while (NumTemplates--) TemplDecls.addDecl(ReadDeclAs()); // 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()); @@ -863,7 +858,7 @@ } // Read in the parameters. - unsigned NumParams = Record[Idx++]; + unsigned NumParams = Record.readInt(); SmallVector Params; Params.reserve(NumParams); for (unsigned I = 0; I != NumParams; ++I) @@ -873,7 +868,7 @@ 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(); @@ -881,33 +876,33 @@ MD->setSelfDecl(ReadDeclAs()); MD->setCmdDecl(ReadDeclAs()); } - 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()); - 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 Params; Params.reserve(NumParams); for (unsigned I = 0; I != NumParams; ++I) Params.push_back(ReadDeclAs()); - MD->SelLocsKind = Record[Idx++]; - unsigned NumStoredSelLocs = Record[Idx++]; + MD->SelLocsKind = Record.readInt(); + unsigned NumStoredSelLocs = Record.readInt(); SmallVector SelLocs; SelLocs.reserve(NumStoredSelLocs); for (unsigned i = 0; i != NumStoredSelLocs; ++i) @@ -919,8 +914,8 @@ 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(); } @@ -932,7 +927,7 @@ } ObjCTypeParamList *ASTDeclReader::ReadObjCTypeParamList() { - unsigned numParams = Record[Idx++]; + unsigned numParams = Record.readInt(); if (numParams == 0) return nullptr; @@ -954,15 +949,15 @@ } 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 Protocols; Protocols.reserve(NumProtocols); for (unsigned I = 0; I != NumProtocols; ++I) @@ -975,7 +970,7 @@ 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) @@ -992,15 +987,15 @@ 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 @@ -1028,10 +1023,10 @@ 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); } @@ -1040,7 +1035,7 @@ VisitObjCContainerDecl(PD); mergeRedeclarable(PD, Redecl); - if (Record[Idx++]) { + if (Record.readInt()) { // Read the definition. PD->allocateDefinitionData(); @@ -1048,7 +1043,7 @@ // redeclarations will see it. PD->getCanonicalDecl()->Data = PD->Data; - unsigned NumProtoRefs = Record[Idx++]; + unsigned NumProtoRefs = Record.readInt(); SmallVector ProtoRefs; ProtoRefs.reserve(NumProtoRefs); for (unsigned I = 0; I != NumProtoRefs; ++I) @@ -1084,7 +1079,7 @@ CD->ClassInterface = ReadDeclAs(); CD->TypeParamList = ReadObjCTypeParamList(); - unsigned NumProtoRefs = Record[Idx++]; + unsigned NumProtoRefs = Record.readInt(); SmallVector ProtoRefs; ProtoRefs.reserve(NumProtoRefs); for (unsigned I = 0; I != NumProtoRefs; ++I) @@ -1106,17 +1101,17 @@ 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()); D->setSetterMethodDecl(ReadDeclAs()); D->setPropertyIvarDecl(ReadDeclAs()); @@ -1129,7 +1124,7 @@ void ASTDeclReader::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) { VisitObjCImplDecl(D); - D->setIdentifier(Record.GetIdentifierInfo(Idx)); + D->setIdentifier(Record.GetIdentifierInfo()); D->CategoryNameLoc = ReadSourceLocation(); } @@ -1139,9 +1134,9 @@ 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(); } @@ -1158,14 +1153,13 @@ 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(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()); } @@ -1179,14 +1173,14 @@ 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]; @@ -1200,22 +1194,23 @@ 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(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++]; - } - Linkage VarLinkage = Linkage(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.readInt()); VD->setCachedLinkage(VarLinkage); // Reconstruct the one piece of the IdentifierNamespace that we need. @@ -1223,7 +1218,7 @@ 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(); @@ -1235,7 +1230,7 @@ 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. @@ -1249,7 +1244,8 @@ break; case StaticDataMemberSpecialization: { // HasMemberSpecializationInfo. VarDecl *Tmpl = ReadDeclAs(); - TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; + TemplateSpecializationKind TSK = + (TemplateSpecializationKind)Record.readInt(); SourceLocation POI = ReadSourceLocation(); Reader.getContext().setInstantiatedFromStaticDataMember(VD, Tmpl, TSK,POI); mergeRedeclarable(VD, Redecl); @@ -1266,10 +1262,10 @@ 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); @@ -1277,9 +1273,9 @@ } 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 @@ -1308,24 +1304,24 @@ VisitDecl(BD); BD->setBody(cast_or_null(Record.ReadStmt())); BD->setSignatureAsWritten(GetTypeSourceInfo()); - unsigned NumParams = Record[Idx++]; + unsigned NumParams = Record.readInt(); SmallVector Params; Params.reserve(NumParams); for (unsigned I = 0; I != NumParams; ++I) Params.push_back(ReadDeclAs()); 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 captures; captures.reserve(numCaptures); for (unsigned i = 0; i != numCaptures; ++i) { VarDecl *decl = ReadDeclAs(); - unsigned flags = Record[Idx++]; + unsigned flags = Record.readInt(); bool byRef = (flags & 1); bool nested = (flags & 2); Expr *copyExpr = ((flags & 4) ? Record.ReadExpr() : nullptr); @@ -1337,8 +1333,8 @@ 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) @@ -1350,7 +1346,7 @@ 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()); } @@ -1368,7 +1364,7 @@ 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(); @@ -1402,7 +1398,7 @@ VisitNamedDecl(D); D->NamespaceLoc = ReadSourceLocation(); D->IdentLoc = ReadSourceLocation(); - D->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx); + D->QualifierLoc = Record.ReadNestedNameSpecifierLoc(); D->Namespace = ReadDeclAs(); mergeRedeclarable(D, Redecl); } @@ -1410,10 +1406,10 @@ 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()); - D->setTypename(Record[Idx++]); + D->setTypename(Record.readInt()); if (NamedDecl *Pattern = ReadDeclAs()) Reader.getContext().setInstantiatedFromUsingDecl(D, Pattern); mergeMergeable(D); @@ -1435,14 +1431,14 @@ VisitUsingShadowDecl(D); D->NominatedBaseClassShadowDecl = ReadDeclAs(); D->ConstructedBaseClassShadowDecl = ReadDeclAs(); - 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(); D->CommonAncestor = ReadDeclAs(); } @@ -1450,7 +1446,7 @@ void ASTDeclReader::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) { VisitValueDecl(D); D->setUsingLoc(ReadSourceLocation()); - D->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx); + D->QualifierLoc = Record.ReadNestedNameSpecifierLoc(); ReadDeclarationNameLoc(D->DNLoc, D->getDeclName()); mergeMergeable(D); } @@ -1459,65 +1455,64 @@ UnresolvedUsingTypenameDecl *D) { VisitTypeDecl(D); D->TypenameLocation = ReadSourceLocation(); - D->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx); + D->QualifierLoc = Record.ReadNestedNameSpecifierLoc(); 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.NumBases = 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.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(); @@ -1525,12 +1520,12 @@ typedef LambdaCapture Capture; CXXRecordDecl::LambdaDefinitionData &Lambda = static_cast(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); @@ -1538,8 +1533,8 @@ Lambda.MethodTyInfo = GetTypeSourceInfo(); for (unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) { SourceLocation Loc = ReadSourceLocation(); - bool IsImplicit = Record[Idx++]; - LambdaCaptureKind Kind = static_cast(Record[Idx++]); + bool IsImplicit = Record.readInt(); + LambdaCaptureKind Kind = static_cast(Record.readInt()); switch (Kind) { case LCK_StarThis: case LCK_This: @@ -1671,14 +1666,14 @@ // 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 @@ -1712,7 +1707,7 @@ 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(D)) @@ -1735,7 +1730,8 @@ } case CXXRecMemberSpecialization: { CXXRecordDecl *RD = ReadDeclAs(); - TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; + TemplateSpecializationKind TSK = + (TemplateSpecializationKind)Record.readInt(); SourceLocation POI = ReadSourceLocation(); MemberSpecializationInfo *MSI = new (C) MemberSpecializationInfo(RD, TSK); MSI->setPointOfInstantiation(POI); @@ -1745,7 +1741,7 @@ } } - bool WasDefinition = Record[Idx++]; + bool WasDefinition = Record.readInt(); if (WasDefinition) ReadCXXRecordDefinition(D, /*Update*/false); else @@ -1769,7 +1765,7 @@ 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, @@ -1780,7 +1776,7 @@ } 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); } } @@ -1796,7 +1792,7 @@ VisitCXXMethodDecl(D); - D->IsExplicitSpecified = Record[Idx++]; + D->IsExplicitSpecified = Record.readInt(); } void ASTDeclReader::VisitCXXDestructorDecl(CXXDestructorDecl *D) { @@ -1812,17 +1808,17 @@ 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(); 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) { @@ -1832,26 +1828,26 @@ void ASTDeclReader::VisitFriendDecl(FriendDecl *D) { VisitDecl(D); - if (Record[Idx++]) // hasFriendDecl + if (Record.readInt()) // hasFriendDecl D->Friend = ReadDeclAs(); else D->Friend = GetTypeSourceInfo(); for (unsigned i = 0; i != D->NumTPLists; ++i) D->getTrailingObjects()[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(); else D->Friend = GetTypeSourceInfo(); @@ -1863,8 +1859,7 @@ DeclID PatternID = ReadDeclID(); NamedDecl *TemplatedDecl = cast_or_null(Reader.GetDecl(PatternID)); - TemplateParameterList* TemplateParams - = Record.ReadTemplateParameterList(Idx); + TemplateParameterList *TemplateParams = Record.ReadTemplateParameterList(); D->init(TemplatedDecl, TemplateParams); return PatternID; @@ -1891,13 +1886,13 @@ 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); @@ -1984,7 +1979,7 @@ D->SpecializedTemplate = CTD; } else { SmallVector TemplArgs; - Record.ReadTemplateArgumentList(TemplArgs, Idx); + Record.ReadTemplateArgumentList(TemplArgs); TemplateArgumentList *ArgList = TemplateArgumentList::CreateCopy(C, TemplArgs); ClassTemplateSpecializationDecl::SpecializedPartialSpecialization *PS @@ -1998,13 +1993,12 @@ } SmallVector 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(); if (D->isCanonicalDecl()) { // It's kept in the folding set. @@ -2052,14 +2046,14 @@ 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()); - D->InstantiatedFromMember.setInt(Record[Idx++]); + D->InstantiatedFromMember.setInt(Record.readInt()); } } @@ -2101,7 +2095,7 @@ D->SpecializedTemplate = VTD; } else { SmallVector TemplArgs; - Record.ReadTemplateArgumentList(TemplArgs, Idx); + Record.ReadTemplateArgumentList(TemplArgs); TemplateArgumentList *ArgList = TemplateArgumentList::CreateCopy( C, TemplArgs); VarTemplateSpecializationDecl::SpecializedPartialSpecialization *PS = @@ -2125,13 +2119,12 @@ } SmallVector 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(); if (D->isCanonicalDecl()) { // It's kept in the folding set. @@ -2158,42 +2151,42 @@ 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()); - 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>(); 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()); } } @@ -2201,20 +2194,20 @@ 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(); 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()); } } @@ -2225,7 +2218,7 @@ 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(Record.ReadExpr()); D->RParenLoc = ReadSourceLocation(); } @@ -2258,7 +2251,7 @@ 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; @@ -3251,13 +3244,12 @@ 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"); @@ -3334,7 +3326,7 @@ 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); @@ -3370,14 +3362,15 @@ 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); @@ -3434,7 +3427,7 @@ 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); @@ -3449,7 +3442,7 @@ 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"); @@ -3463,7 +3456,7 @@ 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); @@ -3472,11 +3465,11 @@ 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); @@ -3505,7 +3498,7 @@ 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)); @@ -3545,15 +3538,14 @@ 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 @@ -3762,13 +3754,13 @@ } 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(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. @@ -3778,7 +3770,7 @@ 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: { @@ -3841,7 +3833,7 @@ 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.) @@ -3851,14 +3843,14 @@ } FD->setInnerLocStart(ReadSourceLocation()); if (auto *CD = dyn_cast(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; } @@ -3877,7 +3869,7 @@ Reader.PendingFakeDefinitionData.erase(OldDD); } - auto TSK = (TemplateSpecializationKind)Record[Idx++]; + auto TSK = (TemplateSpecializationKind)Record.readInt(); SourceLocation POI = ReadSourceLocation(); if (MemberSpecializationInfo *MSInfo = RD->getMemberSpecializationInfo()) { @@ -3889,11 +3881,11 @@ Spec->setTemplateSpecializationKind(TSK); Spec->setPointOfInstantiation(POI); - if (Record[Idx++]) { + if (Record.readInt()) { auto PartialSpec = ReadDeclAs(); SmallVector TemplArgs; - Record.ReadTemplateArgumentList(TemplArgs, Idx); + Record.ReadTemplateArgumentList(TemplArgs); auto *TemplArgList = TemplateArgumentList::CreateCopy( Reader.getContext(), TemplArgs); @@ -3905,14 +3897,14 @@ } } - 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()) @@ -3935,7 +3927,7 @@ case UPD_CXX_RESOLVED_EXCEPTION_SPEC: { FunctionProtoType::ExceptionSpecInfo ESI; SmallVector ExceptionStorage; - Record.readExceptionSpec(ExceptionStorage, ESI, Idx); + Record.readExceptionSpec(ExceptionStorage, ESI); // Update this declaration's exception specification, if needed. auto *FD = cast(D); @@ -3957,7 +3949,7 @@ 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(Redecl); @@ -3973,11 +3965,11 @@ } case UPD_MANGLING_NUMBER: - Reader.Context.setManglingNumber(cast(D), Record[Idx++]); + Reader.Context.setManglingNumber(cast(D), Record.readInt()); break; case UPD_STATIC_LOCAL_NUMBER: - Reader.Context.setStaticLocalNumber(cast(D), Record[Idx++]); + Reader.Context.setStaticLocalNumber(cast(D), Record.readInt()); break; case UPD_DECL_MARKED_OPENMP_THREADPRIVATE: @@ -4010,7 +4002,7 @@ 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; Index: lib/Serialization/ASTReaderStmt.cpp =================================================================== --- lib/Serialization/ASTReaderStmt.cpp +++ lib/Serialization/ASTReaderStmt.cpp @@ -27,49 +27,46 @@ class ASTStmtReader : public StmtVisitor { 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 T *ReadDeclAs() { - return Record.ReadDeclAs(Idx); + return Record.ReadDeclAs(); } 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 @@ 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 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::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::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::VisitIfStmt(IfStmt *S) { VisitStmt(S); - S->setConstexpr(Record[Idx++]); + S->setConstexpr(Record.readInt()); S->setInit(Record.ReadSubStmt()); S->setConditionVariable(Record.getContext(), ReadDeclAs()); S->setCond(Record.ReadSubExpr()); @@ -188,12 +185,12 @@ 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 @@ 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 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::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 @@ SmallVector Constraints; SmallVector 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(Record.ReadSubStmt())); Exprs.push_back(Record.ReadSubStmt()); } @@ -327,14 +325,14 @@ VisitAsmStmt(S); S->LBraceLoc = ReadSourceLocation(); S->EndLoc = ReadSourceLocation(); - S->NumAsmToks = Record[Idx++]; + S->NumAsmToks = Record.readInt(); std::string AsmStr = ReadString(); // Read the tokens. SmallVector 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::VisitCapturedStmt(CapturedStmt *S) { VisitStmt(S); - ++Idx; + (void)Record.readInt(); S->setCapturedDecl(ReadDeclAs()); - S->setCapturedRegionKind(static_cast(Record[Idx++])); + S->setCapturedRegionKind(static_cast(Record.readInt())); S->setCapturedRecordDecl(ReadDeclAs()); // Capture inits @@ -408,46 +406,47 @@ // Captures for (auto &I : S->captures()) { I.VarAndKind.setPointer(ReadDeclAs()); - I.VarAndKind - .setInt(static_cast(Record[Idx++])); + I.VarAndKind.setInt( + static_cast(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(Record[Idx++])); - E->setObjectKind(static_cast(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(Record.readInt())); + E->setObjectKind(static_cast(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(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(Record.ReadNestedNameSpecifierLoc(Idx)); + NestedNameSpecifierLoc(Record.ReadNestedNameSpecifierLoc()); if (E->hasFoundDecl()) *E->getTrailingObjects() = ReadDeclAs(); @@ -465,14 +464,14 @@ 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(Record[Idx++])); - E->setExact(Record[Idx++]); - E->setValue(Record.getContext(), Record.ReadAPFloat(E->getSemantics(), Idx)); + E->setRawSemantics(static_cast(Record.readInt())); + E->setExact(Record.readInt()); + E->setValue(Record.getContext(), Record.ReadAPFloat(E->getSemantics())); E->setLocation(ReadSourceLocation()); } @@ -483,18 +482,19 @@ 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; + (void)Record.readInt(); StringLiteral::StringKind kind = - static_cast(Record[Idx++]); - bool isPascal = Record[Idx++]; + static_cast(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::VisitCharacterLiteral(CharacterLiteral *E) { VisitExpr(E); - E->setValue(Record[Idx++]); + E->setValue(Record.readInt()); E->setLocation(ReadSourceLocation()); - E->setKind(static_cast(Record[Idx++])); + E->setKind(static_cast(Record.readInt())); } void ASTStmtReader::VisitParenExpr(ParenExpr *E) { @@ -517,7 +517,7 @@ 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::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()); + (void)Record.readInt(); + assert(E->getNumExpressions() == Record.peekInt()); + (void)Record.readInt(); E->setOperatorLoc(ReadSourceLocation()); E->setRParenLoc(ReadSourceLocation()); E->setTypeSourceInfo(GetTypeSourceInfo()); for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) { - OffsetOfNode::Kind Kind = static_cast(Record[Idx++]); + OffsetOfNode::Kind Kind = static_cast(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 @@ 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::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) { VisitExpr(E); - E->setKind(static_cast(Record[Idx++])); - if (Record[Idx] == 0) { + E->setKind(static_cast(Record.readInt())); + if (Record.peekInt() == 0) { E->setArgument(Record.ReadSubExpr()); - ++Idx; + (void)Record.readInt(); } else { E->setArgument(GetTypeSourceInfo()); } @@ -606,7 +606,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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(); - 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 @@ 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 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(); SourceLocation DotLoc = ReadSourceLocation(); @@ -777,7 +777,7 @@ } 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 @@ } 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 @@ } 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 @@ 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 @@ 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::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { VisitExpr(E); SmallVector 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::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 @@ 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::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::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::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::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(); @@ -981,7 +981,7 @@ KeyValues[I].Value = Record.ReadSubExpr(); if (HasPackExpansions) { Expansions[I].EllipsisLoc = ReadSourceLocation(); - Expansions[I].NumExpansionsPlusOne = Record[Idx++]; + Expansions[I].NumExpansionsPlusOne = Record.readInt(); } } E->DictWithObjectsMethod = ReadDeclAs(); @@ -997,7 +997,7 @@ 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 @@ 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 *Setter = ReadDeclAs(); @@ -1033,12 +1033,12 @@ } 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()); @@ -1057,14 +1057,14 @@ 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()); + (void)Record.readInt(); + unsigned NumStoredSelLocs = Record.readInt(); + E->SelLocsKind = Record.readInt(); + E->setDelegateInitCall(Record.readInt()); + E->IsImplicit = Record.readInt(); ObjCMessageExpr::ReceiverKind Kind - = static_cast(Record[Idx++]); + = static_cast(Record.readInt()); switch (Kind) { case ObjCMessageExpr::Instance: E->setInstanceReceiver(Record.ReadSubExpr()); @@ -1076,7 +1076,7 @@ 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 @@ assert(Kind == E->getReceiverKind()); - if (Record[Idx++]) + if (Record.readInt()) E->setMethodDecl(ReadDeclAs()); else - E->setSelector(Record.ReadSelector(Idx)); + E->setSelector(Record.ReadSelector()); E->LBracLoc = ReadSourceLocation(); E->RBracLoc = ReadSourceLocation(); @@ -1132,9 +1132,9 @@ void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) { VisitStmt(S); - assert(Record[Idx] == S->getNumCatchStmts()); - ++Idx; - bool HasFinally = Record[Idx++]; + assert(Record.peekInt() == S->getNumCatchStmts()); + (void)Record.readInt(); + bool HasFinally = Record.readInt(); S->setTryBody(Record.ReadSubStmt()); for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) S->setCatchStmt(I, cast_or_null(Record.ReadSubStmt())); @@ -1159,16 +1159,16 @@ 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::VisitCXXTryStmt(CXXTryStmt *S) { VisitStmt(S); - assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?"); - ++Idx; + assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?"); + (void)Record.readInt(); S->TryLoc = ReadSourceLocation(); S->getStmts()[0] = Record.ReadSubStmt(); for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i) @@ -1210,34 +1210,34 @@ 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()); 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 @@ VisitExpr(E); E->Constructor = ReadDeclAs(); 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::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(Record[Idx++]); + E->CaptureDefault = static_cast(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::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) { VisitExpr(E); - E->setValue(Record[Idx++]); + E->setValue(Record.readInt()); E->setLocation(ReadSourceLocation()); } @@ -1341,14 +1341,14 @@ 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::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) { VisitExpr(E); - E->setTemporary(Record.ReadCXXTemporary(Idx)); + E->setTemporary(Record.ReadCXXTemporary()); E->setSubExpr(Record.ReadSubExpr()); } @@ -1377,12 +1377,12 @@ 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()); E->setOperatorDelete(ReadDeclAs()); E->AllocatedTypeInfo = GetTypeSourceInfo(); @@ -1401,10 +1401,10 @@ 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(); E->Argument = Record.ReadSubExpr(); E->Loc = ReadSourceLocation(); @@ -1414,14 +1414,14 @@ 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::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()[i] = ReadDeclAs(); - E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record[Idx++]; + E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt(); E->SubExpr = Record.ReadSubExpr(); } @@ -1445,17 +1445,17 @@ ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){ VisitExpr(E); - if (Record[Idx++]) // HasTemplateKWAndArgsInfo + if (Record.readInt()) // HasTemplateKWAndArgsInfo ReadTemplateKWAndArgsInfo( *E->getTrailingObjects(), E->getTrailingObjects(), - /*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(); ReadDeclarationNameInfo(E->MemberNameInfo); } @@ -1464,21 +1464,22 @@ ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) { VisitExpr(E); - if (Record[Idx++]) // HasTemplateKWAndArgsInfo + if (Record.readInt()) // HasTemplateKWAndArgsInfo ReadTemplateKWAndArgsInfo( *E->getTrailingObjects(), E->getTrailingObjects(), - /*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 ?"); + (void)Record.readInt(); for (unsigned I = 0, N = E->arg_size(); I != N; ++I) E->setArg(I, Record.ReadSubExpr()); E->Type = GetTypeSourceInfo(); @@ -1489,45 +1490,45 @@ 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(); - 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(); } 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::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::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::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::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(Idx); + E->Pack = Record.ReadDeclAs(); if (E->isPartiallySubstituted()) { assert(E->Length == NumPartialArgs); for (auto *I = E->getTrailingObjects(), *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 @@ SubstNonTypeTemplateParmPackExpr *E) { VisitExpr(E); E->Param = ReadDeclAs(); - TemplateArgument ArgPack = Record.ReadTemplateArgument(Idx); + TemplateArgument ArgPack = Record.ReadTemplateArgument(); if (ArgPack.getKind() != TemplateArgument::Pack) return; @@ -1613,7 +1614,7 @@ void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) { VisitExpr(E); - E->NumParameters = Record[Idx++]; + E->NumParameters = Record.readInt(); E->ParamPack = ReadDeclAs(); E->NameLoc = ReadSourceLocation(); ParmVarDecl **Parms = E->getTrailingObjects(); @@ -1625,7 +1626,7 @@ VisitExpr(E); E->State = Record.ReadSubExpr(); auto VD = ReadDeclAs(); - unsigned ManglingNumber = Record[Idx++]; + unsigned ManglingNumber = Record.readInt(); E->setExtendingDecl(VD, ManglingNumber); } @@ -1636,7 +1637,7 @@ 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::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(); } @@ -1703,7 +1704,7 @@ 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 @@ class OMPClauseReader : public OMPClauseVisitor { 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 @@ 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 @@ 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 @@ 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::VisitOMPIfClause(OMPIfClause *C) { - C->setNameModifier(static_cast(Reader->Record[Idx++])); + C->setNameModifier(static_cast(Reader->Record.readInt())); C->setNameModifierLoc(Reader->ReadSourceLocation()); C->setColonLoc(Reader->ReadSourceLocation()); C->setCondition(Reader->Record.ReadSubExpr()); @@ -1971,14 +1971,14 @@ void OMPClauseReader::VisitOMPDefaultClause(OMPDefaultClause *C) { C->setDefaultKind( - static_cast(Reader->Record[Idx++])); + static_cast(Reader->Record.readInt())); C->setLParenLoc(Reader->ReadSourceLocation()); C->setDefaultKindKwLoc(Reader->ReadSourceLocation()); } void OMPClauseReader::VisitOMPProcBindClause(OMPProcBindClause *C) { C->setProcBindKind( - static_cast(Reader->Record[Idx++])); + static_cast(Reader->Record.readInt())); C->setLParenLoc(Reader->ReadSourceLocation()); C->setProcBindKindKwLoc(Reader->ReadSourceLocation()); } @@ -1986,11 +1986,11 @@ void OMPClauseReader::VisitOMPScheduleClause(OMPScheduleClause *C) { VisitOMPClauseWithPreInit(C); C->setScheduleKind( - static_cast(Reader->Record[Idx++])); + static_cast(Reader->Record.readInt())); C->setFirstScheduleModifier( - static_cast(Reader->Record[Idx++])); + static_cast(Reader->Record.readInt())); C->setSecondScheduleModifier( - static_cast(Reader->Record[Idx++])); + static_cast(Reader->Record.readInt())); C->setChunkSize(Reader->Record.ReadSubExpr()); C->setLParenLoc(Reader->ReadSourceLocation()); C->setFirstScheduleModifierLoc(Reader->ReadSourceLocation()); @@ -2100,7 +2100,7 @@ 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 @@ VisitOMPClauseWithPostUpdate(C); C->setLParenLoc(Reader->ReadSourceLocation()); C->setColonLoc(Reader->ReadSourceLocation()); - C->setModifier(static_cast(Reader->Record[Idx++])); + C->setModifier(static_cast(Reader->Record.readInt())); C->setModifierLoc(Reader->ReadSourceLocation()); unsigned NumVars = C->varlist_size(); SmallVector Vars; @@ -2231,7 +2231,7 @@ void OMPClauseReader::VisitOMPDependClause(OMPDependClause *C) { C->setLParenLoc(Reader->ReadSourceLocation()); C->setDependencyKind( - static_cast(Reader->Record[Idx++])); + static_cast(Reader->Record.readInt())); C->setDependencyLoc(Reader->ReadSourceLocation()); C->setColonLoc(Reader->ReadSourceLocation()); unsigned NumVars = C->varlist_size(); @@ -2251,9 +2251,9 @@ void OMPClauseReader::VisitOMPMapClause(OMPMapClause *C) { C->setLParenLoc(Reader->ReadSourceLocation()); C->setMapTypeModifier( - static_cast(Reader->Record[Idx++])); + static_cast(Reader->Record.readInt())); C->setMapType( - static_cast(Reader->Record[Idx++])); + static_cast(Reader->Record.readInt())); C->setMapLoc(Reader->ReadSourceLocation()); C->setColonLoc(Reader->ReadSourceLocation()); auto NumVars = C->varlist_size(); @@ -2270,26 +2270,26 @@ SmallVector Decls; Decls.reserve(UniqueDecls); for (unsigned i = 0; i < UniqueDecls; ++i) - Decls.push_back(Reader->Record.ReadDeclAs(Idx)); + Decls.push_back(Reader->Record.ReadDeclAs()); C->setUniqueDecls(Decls); SmallVector 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 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 Components; Components.reserve(TotalComponents); for (unsigned i = 0; i < TotalComponents; ++i) { Expr *AssociatedExpr = Reader->Record.ReadSubExpr(); - ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs(Idx); + ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs(); Components.push_back(OMPClauseMappableExprCommon::MappableComponent( AssociatedExpr, AssociatedDecl)); } @@ -2329,7 +2329,7 @@ void OMPClauseReader::VisitOMPDistScheduleClause(OMPDistScheduleClause *C) { VisitOMPClauseWithPreInit(C); C->setDistScheduleKind( - static_cast(Reader->Record[Idx++])); + static_cast(Reader->Record.readInt())); C->setChunkSize(Reader->Record.ReadSubExpr()); C->setLParenLoc(Reader->ReadSourceLocation()); C->setDistScheduleKindLoc(Reader->ReadSourceLocation()); @@ -2338,9 +2338,9 @@ void OMPClauseReader::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) { C->setDefaultmapKind( - static_cast(Reader->Record[Idx++])); + static_cast(Reader->Record.readInt())); C->setDefaultmapModifier( - static_cast(Reader->Record[Idx++])); + static_cast(Reader->Record.readInt())); C->setLParenLoc(Reader->ReadSourceLocation()); C->setDefaultmapModifierLoc(Reader->ReadSourceLocation()); C->setDefaultmapKindLoc(Reader->ReadSourceLocation()); @@ -2362,26 +2362,26 @@ SmallVector Decls; Decls.reserve(UniqueDecls); for (unsigned i = 0; i < UniqueDecls; ++i) - Decls.push_back(Reader->Record.ReadDeclAs(Idx)); + Decls.push_back(Reader->Record.ReadDeclAs()); C->setUniqueDecls(Decls); SmallVector 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 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 Components; Components.reserve(TotalComponents); for (unsigned i = 0; i < TotalComponents; ++i) { Expr *AssociatedExpr = Reader->Record.ReadSubExpr(); - ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs(Idx); + ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs(); Components.push_back(OMPClauseMappableExprCommon::MappableComponent( AssociatedExpr, AssociatedDecl)); } @@ -2404,26 +2404,26 @@ SmallVector Decls; Decls.reserve(UniqueDecls); for (unsigned i = 0; i < UniqueDecls; ++i) - Decls.push_back(Reader->Record.ReadDeclAs(Idx)); + Decls.push_back(Reader->Record.ReadDeclAs()); C->setUniqueDecls(Decls); SmallVector 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 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 Components; Components.reserve(TotalComponents); for (unsigned i = 0; i < TotalComponents; ++i) { Expr *AssociatedExpr = Reader->Record.ReadSubExpr(); - ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs(Idx); + ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs(); Components.push_back(OMPClauseMappableExprCommon::MappableComponent( AssociatedExpr, AssociatedDecl)); } @@ -2454,26 +2454,26 @@ SmallVector Decls; Decls.reserve(UniqueDecls); for (unsigned i = 0; i < UniqueDecls; ++i) - Decls.push_back(Reader->Record.ReadDeclAs(Idx)); + Decls.push_back(Reader->Record.ReadDeclAs()); C->setUniqueDecls(Decls); SmallVector 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 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 Components; Components.reserve(TotalComponents); for (unsigned i = 0; i < TotalComponents; ++i) { Expr *AssociatedExpr = Reader->Record.ReadSubExpr(); - ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs(Idx); + ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs(); Components.push_back(OMPClauseMappableExprCommon::MappableComponent( AssociatedExpr, AssociatedDecl)); } @@ -2497,26 +2497,26 @@ SmallVector Decls; Decls.reserve(UniqueDecls); for (unsigned i = 0; i < UniqueDecls; ++i) - Decls.push_back(Reader->Record.ReadDeclAs(Idx)); + Decls.push_back(Reader->Record.ReadDeclAs()); C->setUniqueDecls(Decls); SmallVector 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 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 Components; Components.reserve(TotalComponents); for (unsigned i = 0; i < TotalComponents; ++i) { Expr *AssociatedExpr = Reader->Record.ReadSubExpr(); - ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs(Idx); + ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs(); Components.push_back(OMPClauseMappableExprCommon::MappableComponent( AssociatedExpr, AssociatedDecl)); } @@ -2529,7 +2529,7 @@ void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) { E->setLocStart(ReadSourceLocation()); E->setLocEnd(ReadSourceLocation()); - OMPClauseReader ClauseReader(this, Record, Idx); + OMPClauseReader ClauseReader(this, Record); SmallVector Clauses; for (unsigned i = 0; i < E->getNumClauses(); ++i) Clauses.push_back(ClauseReader.readClause()); @@ -2541,7 +2541,7 @@ 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::VisitOMPParallelDirective(OMPParallelDirective *D) { VisitStmt(D); // The NumClauses field was read in ReadStmtFromStream. - ++Idx; + (void)Record.readInt(); VisitOMPExecutableDirective(D); - D->setHasCancel(Record[Idx++]); + D->setHasCancel(Record.readInt()); } void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) { @@ -2605,7 +2605,7 @@ 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::VisitOMPSectionsDirective(OMPSectionsDirective *D) { VisitStmt(D); // The NumClauses field was read in ReadStmtFromStream. - ++Idx; + (void)Record.readInt(); 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; + (void)Record.readInt(); VisitOMPExecutableDirective(D); } @@ -2641,14 +2641,14 @@ void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) { VisitStmt(D); // The NumClauses field was read in ReadStmtFromStream. - ++Idx; + (void)Record.readInt(); 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 @@ OMPParallelSectionsDirective *D) { VisitStmt(D); // The NumClauses field was read in ReadStmtFromStream. - ++Idx; + (void)Record.readInt(); 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; + (void)Record.readInt(); VisitOMPExecutableDirective(D); - D->setHasCancel(Record[Idx++]); + D->setHasCancel(Record.readInt()); } void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) { @@ -2696,74 +2696,74 @@ void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) { VisitStmt(D); // The NumClauses field was read in ReadStmtFromStream. - ++Idx; + (void)Record.readInt(); VisitOMPExecutableDirective(D); } void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) { VisitStmt(D); // The NumClauses field was read in ReadStmtFromStream. - ++Idx; + (void)Record.readInt(); VisitOMPExecutableDirective(D); } void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) { VisitStmt(D); // The NumClauses field was read in ReadStmtFromStream. - ++Idx; + (void)Record.readInt(); 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; + (void)Record.readInt(); VisitOMPExecutableDirective(D); } void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) { VisitStmt(D); - ++Idx; + (void)Record.readInt(); VisitOMPExecutableDirective(D); } void ASTStmtReader::VisitOMPTargetEnterDataDirective( OMPTargetEnterDataDirective *D) { VisitStmt(D); - ++Idx; + (void)Record.readInt(); VisitOMPExecutableDirective(D); } void ASTStmtReader::VisitOMPTargetExitDataDirective( OMPTargetExitDataDirective *D) { VisitStmt(D); - ++Idx; + (void)Record.readInt(); VisitOMPExecutableDirective(D); } void ASTStmtReader::VisitOMPTargetParallelDirective( OMPTargetParallelDirective *D) { VisitStmt(D); - ++Idx; + (void)Record.readInt(); 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; + (void)Record.readInt(); VisitOMPExecutableDirective(D); } @@ -2771,15 +2771,15 @@ OMPCancellationPointDirective *D) { VisitStmt(D); VisitOMPExecutableDirective(D); - D->setCancelRegion(static_cast(Record[Idx++])); + D->setCancelRegion(static_cast(Record.readInt())); } void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) { VisitStmt(D); // The NumClauses field was read in ReadStmtFromStream. - ++Idx; + (void)Record.readInt(); VisitOMPExecutableDirective(D); - D->setCancelRegion(static_cast(Record[Idx++])); + D->setCancelRegion(static_cast(Record.readInt())); } void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) { @@ -2796,7 +2796,7 @@ void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) { VisitStmt(D); - ++Idx; + (void)Record.readInt(); VisitOMPExecutableDirective(D); } void ASTStmtReader::VisitOMPDistributeParallelForDirective( @@ -2889,9 +2889,8 @@ 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) { @@ -2910,11 +2909,9 @@ } 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; @@ -2923,7 +2920,7 @@ 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: @@ -3087,46 +3084,46 @@ // 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(F, Record, Idx); - AccessSpecifier AS = (AccessSpecifier)Record[Idx++]; + NamedDecl *FoundD = Record.ReadDeclAs(); + AccessSpecifier AS = (AccessSpecifier)Record.readInt(); DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS); - QualType T = readType(F, Record, Idx); - ExprValueKind VK = static_cast(Record[Idx++]); - ExprObjectKind OK = static_cast(Record[Idx++]); + QualType T = Record.readType(); + ExprValueKind VK = static_cast(Record.readInt()); + ExprObjectKind OK = static_cast(Record.readInt()); Expr *Base = ReadSubExpr(); - ValueDecl *MemberD = ReadDeclAs(F, Record, Idx); - SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx); + ValueDecl *MemberD = Record.ReadDeclAs(); + 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(S)->MemberDNLoc, - MemberD->getDeclName(), Record, Idx); + Record.ReadDeclarationNameLoc(cast(S)->MemberDNLoc, + MemberD->getDeclName()); if (HadMultipleCandidates) cast(S)->setHadMultipleCandidates(true); break; @@ -3838,8 +3835,8 @@ 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: