Index: include/clang/Serialization/ASTReader.h =================================================================== --- include/clang/Serialization/ASTReader.h +++ include/clang/Serialization/ASTReader.h @@ -356,7 +356,7 @@ /// \brief The AST file has errors. HadErrors }; - + /// \brief Types of AST files. friend class PCHValidator; friend class ASTDeclReader; @@ -364,6 +364,7 @@ friend class ASTIdentifierIterator; friend class serialization::reader::ASTIdentifierLookupTrait; friend class TypeLocReader; + friend class ASTRecordReader; friend class ASTWriter; friend class ASTUnit; // ASTUnit needs to remap source locations. friend class serialization::ReadMethodPoolVisitor; @@ -1939,7 +1940,7 @@ /// number. serialization::SubmoduleID getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID); - + /// \brief Retrieve the submodule that corresponds to a global submodule ID. /// Module *getSubmodule(serialization::SubmoduleID GlobalID); @@ -2183,6 +2184,282 @@ bool isProcessingUpdateRecords() { return ProcessingUpdateRecords; } }; +/// \brief An object for streaming information from a record. +class ASTRecordReader { + typedef serialization::ModuleFile ModuleFile; + + ASTReader *Reader; + const ASTReader::RecordData *Record; + ModuleFile *F; + + typedef ASTReader::RecordData RecordData; + typedef ASTReader::RecordDataImpl RecordDataImpl; + +public: + /// Construct an ASTRecordReader that uses the default encoding scheme. + ASTRecordReader(ASTReader &Reader, const ASTReader::RecordData &Record, + ModuleFile& F) + : Reader(&Reader), Record(&Record), F(&F) {} + + /// Construct an ASTRecordReader that uses the same encoding scheme as another + /// ASTRecordReader. + ASTRecordReader(ASTRecordReader &Parent) + : Reader(Parent.Reader), Record(Parent.Record), F(Parent.F) {} + + const ASTReader::RecordData &getRecordData() const { return *Record; } + + /// \brief The length of this record. + size_t size() const { return getRecordData().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 Is this a module file for a module (rather than a PCH or similar). + bool isModule() const { return F->isModule(); } + + /// \brief Retrieve the AST context that this AST reader supplements. + ASTContext &getContext() { return Reader->getContext(); } + + /// \brief Retrieve the global submodule ID its local ID number. + serialization::SubmoduleID + getGlobalSubmoduleID(unsigned LocalID) { + return Reader->getGlobalSubmoduleID(*F, LocalID); + } + + /// \brief Retrieve the submodule that corresponds to a global submodule ID. + Module *getSubmodule(serialization::SubmoduleID GlobalID) { + return Reader->getSubmodule(GlobalID); + } + + /// \brief Read the record that describes the lexical contents of a DC. + bool ReadLexicalDeclContextStorage(uint64_t Offset, DeclContext *DC) { + return Reader->ReadLexicalDeclContextStorage(*F, F->DeclsCursor, Offset, + DC); + } + + /// \brief Read the record that describes the visible contents of a DC. + bool ReadVisibleDeclContextStorage(uint64_t Offset, + serialization::DeclID ID) { + return Reader->ReadVisibleDeclContextStorage(*F, F->DeclsCursor, Offset, + ID); + } + + void readExceptionSpec(SmallVectorImpl &ExceptionStorage, + FunctionProtoType::ExceptionSpecInfo &ESI, + unsigned &Index) { + return Reader->readExceptionSpec(*F, ExceptionStorage, ESI, *Record, Index); + } + + /// \brief Get the global offset corresponding to a local offset. + uint64_t getGlobalBitOffset(uint32_t LocalOffset) { + return Reader->getGlobalBitOffset(*F, LocalOffset); + } + + /// \brief Reads a statement. + Stmt *ReadStmt() { return Reader->ReadStmt(*F); } + + /// \brief Reads an expression. + Expr *ReadExpr() { return Reader->ReadExpr(*F); } + + /// \brief Reads a sub-statement operand during statement reading. + Stmt *ReadSubStmt() { return Reader->ReadSubStmt(); } + + /// \brief Reads a sub-expression operand during statement reading. + Expr *ReadSubExpr() { return Reader->ReadSubExpr(); } + + /// \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); + } + + /// \brief Reads a TemplateArgumentLoc, advancing Idx. + TemplateArgumentLoc + ReadTemplateArgumentLoc(unsigned &Idx) { + return Reader->ReadTemplateArgumentLoc(*F, *Record, Idx); + } + + const ASTTemplateArgumentListInfo* + ReadASTTemplateArgumentListInfo(unsigned &Idx) { + 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); + } + + /// \brief Map a local type ID within a given AST file to a global type ID. + serialization::TypeID getGlobalTypeID(unsigned LocalID) const { + return Reader->getGlobalTypeID(*F, LocalID); + } + + /// \brief Read a type from the current position in the record. + QualType readType(unsigned &Idx) { + 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); + } + + /// \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); + } + + /// \brief Reads a declaration from the given position in the record, + /// advancing Idx. + /// + /// \returns The declaration read from this location, casted to the given + /// result type. + template + T *ReadDeclAs(unsigned &Idx) { + return Reader->ReadDeclAs(*F, *Record, Idx); + } + + IdentifierInfo *GetIdentifierInfo(unsigned &Idx) { + 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); + } + + /// \brief Read a declaration name, advancing Idx. + DeclarationName ReadDeclarationName(unsigned &Idx) { + return Reader->ReadDeclarationName(*F, *Record, Idx); + } + void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name, + unsigned &Idx) { + return Reader->ReadDeclarationNameLoc(*F, DNLoc, Name, *Record, Idx); + } + void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo, unsigned &Idx) { + return Reader->ReadDeclarationNameInfo(*F, NameInfo, *Record, Idx); + } + + void ReadQualifierInfo(QualifierInfo &Info, unsigned &Idx) { + return Reader->ReadQualifierInfo(*F, Info, *Record, Idx); + } + + NestedNameSpecifier *ReadNestedNameSpecifier(unsigned &Idx) { + return Reader->ReadNestedNameSpecifier(*F, *Record, Idx); + } + + NestedNameSpecifierLoc ReadNestedNameSpecifierLoc(unsigned &Idx) { + return Reader->ReadNestedNameSpecifierLoc(*F, *Record, Idx); + } + + /// \brief Read a template name, advancing Idx. + TemplateName ReadTemplateName(unsigned &Idx) { + 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); + } + + /// \brief Read a template parameter list, advancing Idx. + TemplateParameterList *ReadTemplateParameterList(unsigned &Idx) { + 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, + Canonicalize); + } + + /// \brief Read a UnresolvedSet structure, advancing Idx. + void ReadUnresolvedSet(LazyASTUnresolvedSet &Set, unsigned &Idx) { + 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); + } + + /// \brief Read a CXXCtorInitializer array, advancing Idx. + CXXCtorInitializer **ReadCXXCtorInitializers(unsigned &Idx) { + return Reader->ReadCXXCtorInitializers(*F, *Record, Idx); + } + + CXXTemporary *ReadCXXTemporary(unsigned &Idx) { + return Reader->ReadCXXTemporary(*F, *Record, Idx); + } + + /// \brief Read a source location, advancing Idx. + SourceLocation ReadSourceLocation(unsigned &Idx) { + return Reader->ReadSourceLocation(*F, *Record, Idx); + } + + /// \brief Read a source range, advancing Idx. + SourceRange ReadSourceRange(unsigned &Idx) { + return Reader->ReadSourceRange(*F, *Record, Idx); + } + + /// \brief Read an integral value, advancing Idx. + llvm::APInt ReadAPInt(unsigned &Idx) { + return Reader->ReadAPInt(*Record, Idx); + } + + /// \brief Read a signed integral value, advancing Idx. + llvm::APSInt ReadAPSInt(unsigned &Idx) { + 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); + } + + /// \brief Read a string, advancing Idx. + std::string ReadString(unsigned &Idx) { + return Reader->ReadString(*Record, Idx); + } + + /// \brief Read a path, advancing Idx. + std::string ReadPath(unsigned &Idx) { + return Reader->ReadPath(*F, *Record, Idx); + } + + /// \brief Read a version tuple, advancing Idx. + VersionTuple ReadVersionTuple(unsigned &Idx) { + 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); + } + + /// \brief Reads a token out of a record, advancing Idx. + Token ReadToken(unsigned &Idx) { + return Reader->ReadToken(*F, *Record, Idx); + } + + void RecordSwitchCaseID(SwitchCase *SC, unsigned ID) { + Reader->RecordSwitchCaseID(SC, ID); + } + + /// \brief Retrieve the switch-case statement with the given ID. + SwitchCase *getSwitchCaseWithID(unsigned ID) { + return Reader->getSwitchCaseWithID(ID); + } + +}; + /// \brief Helper class that saves the current stream position and /// then restores it when destroyed. struct SavedStreamPosition { Index: lib/Serialization/ASTReader.cpp =================================================================== --- lib/Serialization/ASTReader.cpp +++ lib/Serialization/ASTReader.cpp @@ -5836,26 +5836,17 @@ } class clang::TypeLocReader : public TypeLocVisitor { - ASTReader &Reader; - ModuleFile &F; - const ASTReader::RecordData &Record; + ASTRecordReader Reader; unsigned &Idx; - SourceLocation ReadSourceLocation(const ASTReader::RecordData &R, - unsigned &I) { - return Reader.ReadSourceLocation(F, R, I); + SourceLocation ReadSourceLocation() { + return Reader.ReadSourceLocation(Idx); } - template - T *ReadDeclAs(const ASTReader::RecordData &Record, unsigned &Idx) { - return Reader.ReadDeclAs(F, Record, Idx); - } - public: TypeLocReader(ASTReader &Reader, ModuleFile &F, const ASTReader::RecordData &Record, unsigned &Idx) - : Reader(Reader), F(F), Record(Record), Idx(Idx) - { } + : Reader(Reader, Record, F), Idx(Idx) {} // We want compile-time assurance that we've enumerated all of // these, so unfortunately we have to declare them first, then @@ -5874,21 +5865,24 @@ } void TypeLocReader::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) { - TL.setBuiltinLoc(ReadSourceLocation(Record, Idx)); + TL.setBuiltinLoc(ReadSourceLocation()); if (TL.needsExtraLocalData()) { - TL.setWrittenTypeSpec(static_cast(Record[Idx++])); - TL.setWrittenSignSpec(static_cast(Record[Idx++])); - TL.setWrittenWidthSpec(static_cast(Record[Idx++])); - TL.setModeAttr(Record[Idx++]); + TL.setWrittenTypeSpec( + static_cast(Reader.getRecordData()[Idx++])); + TL.setWrittenSignSpec( + static_cast(Reader.getRecordData()[Idx++])); + TL.setWrittenWidthSpec( + static_cast(Reader.getRecordData()[Idx++])); + TL.setModeAttr(Reader.getRecordData()[Idx++]); } } void TypeLocReader::VisitComplexTypeLoc(ComplexTypeLoc TL) { - TL.setNameLoc(ReadSourceLocation(Record, Idx)); + TL.setNameLoc(ReadSourceLocation()); } void TypeLocReader::VisitPointerTypeLoc(PointerTypeLoc TL) { - TL.setStarLoc(ReadSourceLocation(Record, Idx)); + TL.setStarLoc(ReadSourceLocation()); } void TypeLocReader::VisitDecayedTypeLoc(DecayedTypeLoc TL) { @@ -5900,27 +5894,27 @@ } void TypeLocReader::VisitBlockPointerTypeLoc(BlockPointerTypeLoc TL) { - TL.setCaretLoc(ReadSourceLocation(Record, Idx)); + TL.setCaretLoc(ReadSourceLocation()); } void TypeLocReader::VisitLValueReferenceTypeLoc(LValueReferenceTypeLoc TL) { - TL.setAmpLoc(ReadSourceLocation(Record, Idx)); + TL.setAmpLoc(ReadSourceLocation()); } void TypeLocReader::VisitRValueReferenceTypeLoc(RValueReferenceTypeLoc TL) { - TL.setAmpAmpLoc(ReadSourceLocation(Record, Idx)); + TL.setAmpAmpLoc(ReadSourceLocation()); } void TypeLocReader::VisitMemberPointerTypeLoc(MemberPointerTypeLoc TL) { - TL.setStarLoc(ReadSourceLocation(Record, Idx)); - TL.setClassTInfo(Reader.GetTypeSourceInfo(F, Record, Idx)); + TL.setStarLoc(ReadSourceLocation()); + TL.setClassTInfo(Reader.GetTypeSourceInfo(Idx)); } void TypeLocReader::VisitArrayTypeLoc(ArrayTypeLoc TL) { - TL.setLBracketLoc(ReadSourceLocation(Record, Idx)); - TL.setRBracketLoc(ReadSourceLocation(Record, Idx)); - if (Record[Idx++]) - TL.setSizeExpr(Reader.ReadExpr(F)); + TL.setLBracketLoc(ReadSourceLocation()); + TL.setRBracketLoc(ReadSourceLocation()); + if (Reader.getRecordData()[Idx++]) + TL.setSizeExpr(Reader.ReadExpr()); else TL.setSizeExpr(nullptr); } @@ -5944,24 +5938,24 @@ void TypeLocReader::VisitDependentSizedExtVectorTypeLoc( DependentSizedExtVectorTypeLoc TL) { - TL.setNameLoc(ReadSourceLocation(Record, Idx)); + TL.setNameLoc(ReadSourceLocation()); } void TypeLocReader::VisitVectorTypeLoc(VectorTypeLoc TL) { - TL.setNameLoc(ReadSourceLocation(Record, Idx)); + TL.setNameLoc(ReadSourceLocation()); } void TypeLocReader::VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) { - TL.setNameLoc(ReadSourceLocation(Record, Idx)); + TL.setNameLoc(ReadSourceLocation()); } void TypeLocReader::VisitFunctionTypeLoc(FunctionTypeLoc TL) { - TL.setLocalRangeBegin(ReadSourceLocation(Record, Idx)); - TL.setLParenLoc(ReadSourceLocation(Record, Idx)); - TL.setRParenLoc(ReadSourceLocation(Record, Idx)); - TL.setLocalRangeEnd(ReadSourceLocation(Record, Idx)); + TL.setLocalRangeBegin(ReadSourceLocation()); + TL.setLParenLoc(ReadSourceLocation()); + TL.setRParenLoc(ReadSourceLocation()); + TL.setLocalRangeEnd(ReadSourceLocation()); for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i) { - TL.setParam(i, ReadDeclAs(Record, Idx)); + TL.setParam(i, Reader.ReadDeclAs(Idx)); } } @@ -5973,162 +5967,160 @@ VisitFunctionTypeLoc(TL); } void TypeLocReader::VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc TL) { - TL.setNameLoc(ReadSourceLocation(Record, Idx)); + TL.setNameLoc(ReadSourceLocation()); } void TypeLocReader::VisitTypedefTypeLoc(TypedefTypeLoc TL) { - TL.setNameLoc(ReadSourceLocation(Record, Idx)); + TL.setNameLoc(ReadSourceLocation()); } void TypeLocReader::VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) { - TL.setTypeofLoc(ReadSourceLocation(Record, Idx)); - TL.setLParenLoc(ReadSourceLocation(Record, Idx)); - TL.setRParenLoc(ReadSourceLocation(Record, Idx)); + TL.setTypeofLoc(ReadSourceLocation()); + TL.setLParenLoc(ReadSourceLocation()); + TL.setRParenLoc(ReadSourceLocation()); } void TypeLocReader::VisitTypeOfTypeLoc(TypeOfTypeLoc TL) { - TL.setTypeofLoc(ReadSourceLocation(Record, Idx)); - TL.setLParenLoc(ReadSourceLocation(Record, Idx)); - TL.setRParenLoc(ReadSourceLocation(Record, Idx)); - TL.setUnderlyingTInfo(Reader.GetTypeSourceInfo(F, Record, Idx)); + TL.setTypeofLoc(ReadSourceLocation()); + TL.setLParenLoc(ReadSourceLocation()); + TL.setRParenLoc(ReadSourceLocation()); + TL.setUnderlyingTInfo(Reader.GetTypeSourceInfo(Idx)); } void TypeLocReader::VisitDecltypeTypeLoc(DecltypeTypeLoc TL) { - TL.setNameLoc(ReadSourceLocation(Record, Idx)); + TL.setNameLoc(ReadSourceLocation()); } void TypeLocReader::VisitUnaryTransformTypeLoc(UnaryTransformTypeLoc TL) { - TL.setKWLoc(ReadSourceLocation(Record, Idx)); - TL.setLParenLoc(ReadSourceLocation(Record, Idx)); - TL.setRParenLoc(ReadSourceLocation(Record, Idx)); - TL.setUnderlyingTInfo(Reader.GetTypeSourceInfo(F, Record, Idx)); + TL.setKWLoc(ReadSourceLocation()); + TL.setLParenLoc(ReadSourceLocation()); + TL.setRParenLoc(ReadSourceLocation()); + TL.setUnderlyingTInfo(Reader.GetTypeSourceInfo(Idx)); } void TypeLocReader::VisitAutoTypeLoc(AutoTypeLoc TL) { - TL.setNameLoc(ReadSourceLocation(Record, Idx)); + TL.setNameLoc(ReadSourceLocation()); } void TypeLocReader::VisitRecordTypeLoc(RecordTypeLoc TL) { - TL.setNameLoc(ReadSourceLocation(Record, Idx)); + TL.setNameLoc(ReadSourceLocation()); } void TypeLocReader::VisitEnumTypeLoc(EnumTypeLoc TL) { - TL.setNameLoc(ReadSourceLocation(Record, Idx)); + TL.setNameLoc(ReadSourceLocation()); } void TypeLocReader::VisitAttributedTypeLoc(AttributedTypeLoc TL) { - TL.setAttrNameLoc(ReadSourceLocation(Record, Idx)); + TL.setAttrNameLoc(ReadSourceLocation()); if (TL.hasAttrOperand()) { SourceRange range; - range.setBegin(ReadSourceLocation(Record, Idx)); - range.setEnd(ReadSourceLocation(Record, Idx)); + range.setBegin(ReadSourceLocation()); + range.setEnd(ReadSourceLocation()); TL.setAttrOperandParensRange(range); } if (TL.hasAttrExprOperand()) { - if (Record[Idx++]) - TL.setAttrExprOperand(Reader.ReadExpr(F)); + if (Reader.getRecordData()[Idx++]) + TL.setAttrExprOperand(Reader.ReadExpr()); else TL.setAttrExprOperand(nullptr); } else if (TL.hasAttrEnumOperand()) - TL.setAttrEnumOperandLoc(ReadSourceLocation(Record, Idx)); + TL.setAttrEnumOperandLoc(ReadSourceLocation()); } void TypeLocReader::VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) { - TL.setNameLoc(ReadSourceLocation(Record, Idx)); + TL.setNameLoc(ReadSourceLocation()); } void TypeLocReader::VisitSubstTemplateTypeParmTypeLoc( SubstTemplateTypeParmTypeLoc TL) { - TL.setNameLoc(ReadSourceLocation(Record, Idx)); + TL.setNameLoc(ReadSourceLocation()); } void TypeLocReader::VisitSubstTemplateTypeParmPackTypeLoc( SubstTemplateTypeParmPackTypeLoc TL) { - TL.setNameLoc(ReadSourceLocation(Record, Idx)); + TL.setNameLoc(ReadSourceLocation()); } void TypeLocReader::VisitTemplateSpecializationTypeLoc( TemplateSpecializationTypeLoc TL) { - TL.setTemplateKeywordLoc(ReadSourceLocation(Record, Idx)); - TL.setTemplateNameLoc(ReadSourceLocation(Record, Idx)); - TL.setLAngleLoc(ReadSourceLocation(Record, Idx)); - TL.setRAngleLoc(ReadSourceLocation(Record, Idx)); + 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(F, - TL.getTypePtr()->getArg(i).getKind(), - Record, Idx)); + Reader.GetTemplateArgumentLocInfo(TL.getTypePtr()->getArg(i).getKind(), + Idx)); } void TypeLocReader::VisitParenTypeLoc(ParenTypeLoc TL) { - TL.setLParenLoc(ReadSourceLocation(Record, Idx)); - TL.setRParenLoc(ReadSourceLocation(Record, Idx)); + TL.setLParenLoc(ReadSourceLocation()); + TL.setRParenLoc(ReadSourceLocation()); } void TypeLocReader::VisitElaboratedTypeLoc(ElaboratedTypeLoc TL) { - TL.setElaboratedKeywordLoc(ReadSourceLocation(Record, Idx)); - TL.setQualifierLoc(Reader.ReadNestedNameSpecifierLoc(F, Record, Idx)); + TL.setElaboratedKeywordLoc(ReadSourceLocation()); + TL.setQualifierLoc(Reader.ReadNestedNameSpecifierLoc(Idx)); } void TypeLocReader::VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) { - TL.setNameLoc(ReadSourceLocation(Record, Idx)); + TL.setNameLoc(ReadSourceLocation()); } void TypeLocReader::VisitDependentNameTypeLoc(DependentNameTypeLoc TL) { - TL.setElaboratedKeywordLoc(ReadSourceLocation(Record, Idx)); - TL.setQualifierLoc(Reader.ReadNestedNameSpecifierLoc(F, Record, Idx)); - TL.setNameLoc(ReadSourceLocation(Record, Idx)); + TL.setElaboratedKeywordLoc(ReadSourceLocation()); + TL.setQualifierLoc(Reader.ReadNestedNameSpecifierLoc(Idx)); + TL.setNameLoc(ReadSourceLocation()); } void TypeLocReader::VisitDependentTemplateSpecializationTypeLoc( DependentTemplateSpecializationTypeLoc TL) { - TL.setElaboratedKeywordLoc(ReadSourceLocation(Record, Idx)); - TL.setQualifierLoc(Reader.ReadNestedNameSpecifierLoc(F, Record, Idx)); - TL.setTemplateKeywordLoc(ReadSourceLocation(Record, Idx)); - TL.setTemplateNameLoc(ReadSourceLocation(Record, Idx)); - TL.setLAngleLoc(ReadSourceLocation(Record, Idx)); - TL.setRAngleLoc(ReadSourceLocation(Record, Idx)); + TL.setElaboratedKeywordLoc(ReadSourceLocation()); + TL.setQualifierLoc(Reader.ReadNestedNameSpecifierLoc(Idx)); + 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(F, - TL.getTypePtr()->getArg(I).getKind(), - Record, Idx)); + Reader.GetTemplateArgumentLocInfo(TL.getTypePtr()->getArg(I).getKind(), + Idx)); } void TypeLocReader::VisitPackExpansionTypeLoc(PackExpansionTypeLoc TL) { - TL.setEllipsisLoc(ReadSourceLocation(Record, Idx)); + TL.setEllipsisLoc(ReadSourceLocation()); } void TypeLocReader::VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) { - TL.setNameLoc(ReadSourceLocation(Record, Idx)); + TL.setNameLoc(ReadSourceLocation()); } void TypeLocReader::VisitObjCTypeParamTypeLoc(ObjCTypeParamTypeLoc TL) { if (TL.getNumProtocols()) { - TL.setProtocolLAngleLoc(ReadSourceLocation(Record, Idx)); - TL.setProtocolRAngleLoc(ReadSourceLocation(Record, Idx)); + TL.setProtocolLAngleLoc(ReadSourceLocation()); + TL.setProtocolRAngleLoc(ReadSourceLocation()); } for (unsigned i = 0, e = TL.getNumProtocols(); i != e; ++i) - TL.setProtocolLoc(i, ReadSourceLocation(Record, Idx)); + TL.setProtocolLoc(i, ReadSourceLocation()); } void TypeLocReader::VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) { - TL.setHasBaseTypeAsWritten(Record[Idx++]); - TL.setTypeArgsLAngleLoc(ReadSourceLocation(Record, Idx)); - TL.setTypeArgsRAngleLoc(ReadSourceLocation(Record, Idx)); + TL.setHasBaseTypeAsWritten(Reader.getRecordData()[Idx++]); + TL.setTypeArgsLAngleLoc(ReadSourceLocation()); + TL.setTypeArgsRAngleLoc(ReadSourceLocation()); for (unsigned i = 0, e = TL.getNumTypeArgs(); i != e; ++i) - TL.setTypeArgTInfo(i, Reader.GetTypeSourceInfo(F, Record, Idx)); - TL.setProtocolLAngleLoc(ReadSourceLocation(Record, Idx)); - TL.setProtocolRAngleLoc(ReadSourceLocation(Record, Idx)); + TL.setTypeArgTInfo(i, Reader.GetTypeSourceInfo(Idx)); + TL.setProtocolLAngleLoc(ReadSourceLocation()); + TL.setProtocolRAngleLoc(ReadSourceLocation()); for (unsigned i = 0, e = TL.getNumProtocols(); i != e; ++i) - TL.setProtocolLoc(i, ReadSourceLocation(Record, Idx)); + TL.setProtocolLoc(i, ReadSourceLocation()); } void TypeLocReader::VisitObjCObjectPointerTypeLoc(ObjCObjectPointerTypeLoc TL) { - TL.setStarLoc(ReadSourceLocation(Record, Idx)); + TL.setStarLoc(ReadSourceLocation()); } void TypeLocReader::VisitAtomicTypeLoc(AtomicTypeLoc TL) { - TL.setKWLoc(ReadSourceLocation(Record, Idx)); - TL.setLParenLoc(ReadSourceLocation(Record, Idx)); - TL.setRParenLoc(ReadSourceLocation(Record, Idx)); + TL.setKWLoc(ReadSourceLocation()); + TL.setLParenLoc(ReadSourceLocation()); + TL.setRParenLoc(ReadSourceLocation()); } void TypeLocReader::VisitPipeTypeLoc(PipeTypeLoc TL) { - TL.setKWLoc(ReadSourceLocation(Record, Idx)); + TL.setKWLoc(ReadSourceLocation()); } TypeSourceInfo *ASTReader::GetTypeSourceInfo(ModuleFile &F, 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; - ModuleFile &F; - uint64_t Offset; + ASTRecordReader Record; + ASTReader::RecordLocation Loc; const DeclID ThisDeclID; const SourceLocation ThisDeclLoc; typedef ASTReader::RecordData RecordData; - const RecordData &Record; unsigned &Idx; TypeID TypeIDForTypeDecl; unsigned AnonymousDeclNumber; @@ -56,85 +55,81 @@ uint64_t GetCurrentCursorOffset(); - uint64_t ReadLocalOffset(const RecordData &R, unsigned &I) { - uint64_t LocalOffset = R[I++]; - assert(LocalOffset < Offset && "offset point after current record"); - return LocalOffset ? Offset - LocalOffset : 0; + uint64_t ReadLocalOffset() { + uint64_t LocalOffset = Record[Idx++]; + assert(LocalOffset < Loc.Offset && "offset point after current record"); + return LocalOffset ? Loc.Offset - LocalOffset : 0; } - uint64_t ReadGlobalOffset(ModuleFile &F, const RecordData &R, unsigned &I) { - uint64_t Local = ReadLocalOffset(R, I); - return Local ? Reader.getGlobalBitOffset(F, Local) : 0; + uint64_t ReadGlobalOffset() { + uint64_t Local = ReadLocalOffset(); + return Local ? Record.getGlobalBitOffset(Local) : 0; } - SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) { - return Reader.ReadSourceLocation(F, R, I); + SourceLocation ReadSourceLocation() { + return Record.ReadSourceLocation(Idx); } - SourceRange ReadSourceRange(const RecordData &R, unsigned &I) { - return Reader.ReadSourceRange(F, R, I); + SourceRange ReadSourceRange() { + return Record.ReadSourceRange(Idx); } - TypeSourceInfo *GetTypeSourceInfo(const RecordData &R, unsigned &I) { - return Reader.GetTypeSourceInfo(F, R, I); + TypeSourceInfo *GetTypeSourceInfo() { + return Record.GetTypeSourceInfo(Idx); } - serialization::DeclID ReadDeclID(const RecordData &R, unsigned &I) { - return Reader.ReadDeclID(F, R, I); + serialization::DeclID ReadDeclID() { + return Record.ReadDeclID(Idx); } - std::string ReadString(const RecordData &R, unsigned &I) { - return Reader.ReadString(R, I); + std::string ReadString() { + return Record.ReadString(Idx); } void ReadDeclIDList(SmallVectorImpl &IDs) { for (unsigned I = 0, Size = Record[Idx++]; I != Size; ++I) - IDs.push_back(ReadDeclID(Record, Idx)); + IDs.push_back(ReadDeclID()); } - Decl *ReadDecl(const RecordData &R, unsigned &I) { - return Reader.ReadDecl(F, R, I); + Decl *ReadDecl() { + return Record.ReadDecl(Idx); } template - T *ReadDeclAs(const RecordData &R, unsigned &I) { - return Reader.ReadDeclAs(F, R, I); + T *ReadDeclAs() { + return Record.ReadDeclAs(Idx); } - void ReadQualifierInfo(QualifierInfo &Info, - const RecordData &R, unsigned &I) { - Reader.ReadQualifierInfo(F, Info, R, I); + void ReadQualifierInfo(QualifierInfo &Info) { + Record.ReadQualifierInfo(Info, Idx); } - - void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name, - const RecordData &R, unsigned &I) { - Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I); + + void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name) { + Record.ReadDeclarationNameLoc(DNLoc, Name, Idx); } - - void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo, - const RecordData &R, unsigned &I) { - Reader.ReadDeclarationNameInfo(F, NameInfo, R, I); + + void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo, unsigned &I) { + Record.ReadDeclarationNameInfo(NameInfo, I); } - serialization::SubmoduleID readSubmoduleID(const RecordData &R, - unsigned &I) { - if (I >= R.size()) + serialization::SubmoduleID readSubmoduleID() { + if (Idx >= Record.size()) return 0; - - return Reader.getGlobalSubmoduleID(F, R[I++]); + + return Record.getGlobalSubmoduleID(Record[Idx++]); } - - Module *readModule(const RecordData &R, unsigned &I) { - return Reader.getSubmodule(readSubmoduleID(R, I)); + + Module *readModule() { + return Record.getSubmodule(readSubmoduleID()); } void ReadCXXRecordDefinition(CXXRecordDecl *D, bool Update); void ReadCXXDefinitionData(struct CXXRecordDecl::DefinitionData &Data, - const RecordData &R, unsigned &I); + unsigned &I); void MergeDefinitionData(CXXRecordDecl *D, struct CXXRecordDecl::DefinitionData &&NewDD); void ReadObjCDefinitionData(struct ObjCInterfaceDecl::DefinitionData &Data, - const RecordData &R, unsigned &I); + unsigned &I); void MergeDefinitionData(ObjCInterfaceDecl *D, struct ObjCInterfaceDecl::DefinitionData &&NewDD); @@ -221,9 +216,9 @@ ASTDeclReader(ASTReader &Reader, ASTReader::RecordLocation Loc, DeclID thisDeclID, SourceLocation ThisDeclLoc, const RecordData &Record, unsigned &Idx) - : Reader(Reader), F(*Loc.F), Offset(Loc.Offset), ThisDeclID(thisDeclID), - ThisDeclLoc(ThisDeclLoc), Record(Record), Idx(Idx), - TypeIDForTypeDecl(0), NamedDeclForTagDecl(0), + : Reader(Reader), Record(Reader, Record, *Loc.F), Loc(Loc), + ThisDeclID(thisDeclID), ThisDeclLoc(ThisDeclLoc), + Idx(Idx), TypeIDForTypeDecl(0), NamedDeclForTagDecl(0), TypedefNameForLinkage(nullptr), HasPendingBody(false), IsDeclMarkedUsed(false) {} @@ -254,8 +249,7 @@ void Visit(Decl *D); - void UpdateDecl(Decl *D, ModuleFile &ModuleFile, - const RecordData &Record); + void UpdateDecl(Decl *D); static void setNextObjCCategory(ObjCCategoryDecl *Cat, ObjCCategoryDecl *Next) { @@ -430,7 +424,7 @@ } uint64_t ASTDeclReader::GetCurrentCursorOffset() { - return F.DeclsCursor.GetCurrentBitNo() + F.GlobalBitOffset; + return Loc.F->DeclsCursor.GetCurrentBitNo() + Loc.F->GlobalBitOffset; } void ASTDeclReader::Visit(Decl *D) { @@ -445,11 +439,10 @@ if (DD->DeclInfo) { DeclaratorDecl::ExtInfo *Info = DD->DeclInfo.get(); - Info->TInfo = - GetTypeSourceInfo(Record, Idx); + Info->TInfo = GetTypeSourceInfo(); } else { - DD->DeclInfo = GetTypeSourceInfo(Record, Idx); + DD->DeclInfo = GetTypeSourceInfo(); } } @@ -474,7 +467,7 @@ if (auto *CD = dyn_cast(FD)) { CD->NumCtorInitializers = Record[Idx++]; if (CD->NumCtorInitializers) - CD->CtorInitializers = ReadGlobalOffset(F, Record, Idx); + CD->CtorInitializers = ReadGlobalOffset(); } Reader.PendingBodies[FD] = GetCurrentCursorOffset(); HasPendingBody = true; @@ -491,8 +484,8 @@ // example, a function parameter can be used in decltype() in trailing // return type of the function). Use the translation unit DeclContext as a // placeholder. - GlobalDeclID SemaDCIDForTemplateParmDecl = ReadDeclID(Record, Idx); - GlobalDeclID LexicalDCIDForTemplateParmDecl = ReadDeclID(Record, Idx); + GlobalDeclID SemaDCIDForTemplateParmDecl = ReadDeclID(); + GlobalDeclID LexicalDCIDForTemplateParmDecl = ReadDeclID(); if (!LexicalDCIDForTemplateParmDecl) LexicalDCIDForTemplateParmDecl = SemaDCIDForTemplateParmDecl; Reader.addPendingDeclContextInfo(D, @@ -500,8 +493,8 @@ LexicalDCIDForTemplateParmDecl); D->setDeclContext(Reader.getContext().getTranslationUnitDecl()); } else { - DeclContext *SemaDC = ReadDeclAs(Record, Idx); - DeclContext *LexicalDC = ReadDeclAs(Record, Idx); + DeclContext *SemaDC = ReadDeclAs(); + DeclContext *LexicalDC = ReadDeclAs(); if (!LexicalDC) LexicalDC = SemaDC; DeclContext *MergedSemaDC = Reader.MergedDeclContexts.lookup(SemaDC); @@ -514,7 +507,7 @@ D->setInvalidDecl(Record[Idx++]); if (Record[Idx++]) { // hasAttrs AttrVec Attrs; - Reader.ReadAttributes(F, Attrs, Record, Idx); + Record.ReadAttributes(Attrs, Idx); // Avoid calling setAttrs() directly because it uses Decl::getASTContext() // internally which is unsafe during derialization. D->setAttrsImpl(Attrs, Reader.getContext()); @@ -531,7 +524,7 @@ // Determine whether this declaration is part of a (sub)module. If so, it // may not yet be visible. - if (unsigned SubmoduleID = readSubmoduleID(Record, Idx)) { + if (unsigned SubmoduleID = readSubmoduleID()) { // Store the owning submodule ID in the declaration. D->setOwningModuleID(SubmoduleID); @@ -557,22 +550,22 @@ void ASTDeclReader::VisitPragmaCommentDecl(PragmaCommentDecl *D) { VisitDecl(D); - D->setLocation(ReadSourceLocation(Record, Idx)); + D->setLocation(ReadSourceLocation()); D->CommentKind = (PragmaMSCommentKind)Record[Idx++]; - std::string Arg = ReadString(Record, Idx); + std::string Arg = ReadString(); memcpy(D->getTrailingObjects(), Arg.data(), Arg.size()); D->getTrailingObjects()[Arg.size()] = '\0'; } void ASTDeclReader::VisitPragmaDetectMismatchDecl(PragmaDetectMismatchDecl *D) { VisitDecl(D); - D->setLocation(ReadSourceLocation(Record, Idx)); - std::string Name = ReadString(Record, Idx); + D->setLocation(ReadSourceLocation()); + std::string Name = ReadString(); memcpy(D->getTrailingObjects(), Name.data(), Name.size()); D->getTrailingObjects()[Name.size()] = '\0'; D->ValueStart = Name.size() + 1; - std::string Value = ReadString(Record, Idx); + std::string Value = ReadString(); memcpy(D->getTrailingObjects() + D->ValueStart, Value.data(), Value.size()); D->getTrailingObjects()[D->ValueStart + Value.size()] = '\0'; @@ -584,24 +577,24 @@ void ASTDeclReader::VisitNamedDecl(NamedDecl *ND) { VisitDecl(ND); - ND->setDeclName(Reader.ReadDeclarationName(F, Record, Idx)); + ND->setDeclName(Record.ReadDeclarationName(Idx)); AnonymousDeclNumber = Record[Idx++]; } void ASTDeclReader::VisitTypeDecl(TypeDecl *TD) { VisitNamedDecl(TD); - TD->setLocStart(ReadSourceLocation(Record, Idx)); + TD->setLocStart(ReadSourceLocation()); // Delay type reading until after we have fully initialized the decl. - TypeIDForTypeDecl = Reader.getGlobalTypeID(F, Record[Idx++]); + TypeIDForTypeDecl = Record.getGlobalTypeID(Record[Idx++]); } ASTDeclReader::RedeclarableResult ASTDeclReader::VisitTypedefNameDecl(TypedefNameDecl *TD) { RedeclarableResult Redecl = VisitRedeclarable(TD); VisitTypeDecl(TD); - TypeSourceInfo *TInfo = GetTypeSourceInfo(Record, Idx); + TypeSourceInfo *TInfo = GetTypeSourceInfo(); if (Record[Idx++]) { // isModed - QualType modedT = Reader.readType(F, Record, Idx); + QualType modedT = Record.readType(Idx); TD->setModedTypeSourceInfo(TInfo, modedT); } else TD->setTypeSourceInfo(TInfo); @@ -615,7 +608,7 @@ void ASTDeclReader::VisitTypeAliasDecl(TypeAliasDecl *TD) { RedeclarableResult Redecl = VisitTypedefNameDecl(TD); - if (auto *Template = ReadDeclAs(Record, Idx)) + if (auto *Template = ReadDeclAs()) // Merged when we merge the template. TD->setDescribedAliasTemplate(Template); else @@ -633,20 +626,20 @@ TD->setEmbeddedInDeclarator(Record[Idx++]); TD->setFreeStanding(Record[Idx++]); TD->setCompleteDefinitionRequired(Record[Idx++]); - TD->setBraceRange(ReadSourceRange(Record, Idx)); + TD->setBraceRange(ReadSourceRange()); switch (Record[Idx++]) { case 0: break; case 1: { // ExtInfo TagDecl::ExtInfo *Info = new (Reader.getContext()) TagDecl::ExtInfo(); - ReadQualifierInfo(*Info, Record, Idx); + ReadQualifierInfo(*Info); TD->TypedefNameDeclOrQualifier = Info; break; } case 2: // TypedefNameForAnonDecl - NamedDeclForTagDecl = ReadDeclID(Record, Idx); - TypedefNameForLinkage = Reader.GetIdentifierInfo(F, Record, Idx); + NamedDeclForTagDecl = ReadDeclID(); + TypedefNameForLinkage = Record.GetIdentifierInfo(Idx); break; default: llvm_unreachable("unexpected tag info kind"); @@ -659,11 +652,11 @@ void ASTDeclReader::VisitEnumDecl(EnumDecl *ED) { VisitTagDecl(ED); - if (TypeSourceInfo *TI = Reader.GetTypeSourceInfo(F, Record, Idx)) + if (TypeSourceInfo *TI = GetTypeSourceInfo()) ED->setIntegerTypeSourceInfo(TI); else - ED->setIntegerType(Reader.readType(F, Record, Idx)); - ED->setPromotionType(Reader.readType(F, Record, Idx)); + ED->setIntegerType(Record.readType(Idx)); + ED->setPromotionType(Record.readType(Idx)); ED->setNumPositiveBits(Record[Idx++]); ED->setNumNegativeBits(Record[Idx++]); ED->IsScoped = Record[Idx++]; @@ -695,9 +688,9 @@ } } - if (EnumDecl *InstED = ReadDeclAs(Record, Idx)) { + if (EnumDecl *InstED = ReadDeclAs()) { TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; - SourceLocation POI = ReadSourceLocation(Record, Idx); + SourceLocation POI = ReadSourceLocation(); ED->setInstantiationOfMemberEnum(Reader.getContext(), InstED, TSK); ED->getMemberSpecializationInfo()->setPointOfInstantiation(POI); } @@ -715,24 +708,24 @@ void ASTDeclReader::VisitValueDecl(ValueDecl *VD) { VisitNamedDecl(VD); - VD->setType(Reader.readType(F, Record, Idx)); + VD->setType(Record.readType(Idx)); } void ASTDeclReader::VisitEnumConstantDecl(EnumConstantDecl *ECD) { VisitValueDecl(ECD); if (Record[Idx++]) - ECD->setInitExpr(Reader.ReadExpr(F)); - ECD->setInitVal(Reader.ReadAPSInt(Record, Idx)); + ECD->setInitExpr(Record.ReadExpr()); + ECD->setInitVal(Record.ReadAPSInt(Idx)); mergeMergeable(ECD); } void ASTDeclReader::VisitDeclaratorDecl(DeclaratorDecl *DD) { VisitValueDecl(DD); - DD->setInnerLocStart(ReadSourceLocation(Record, Idx)); + DD->setInnerLocStart(ReadSourceLocation()); if (Record[Idx++]) { // hasExtInfo DeclaratorDecl::ExtInfo *Info = new (Reader.getContext()) DeclaratorDecl::ExtInfo(); - ReadQualifierInfo(*Info, Record, Idx); + ReadQualifierInfo(*Info); DD->DeclInfo = Info; } } @@ -741,9 +734,9 @@ RedeclarableResult Redecl = VisitRedeclarable(FD); VisitDeclaratorDecl(FD); - ReadDeclarationNameLoc(FD->DNLoc, FD->getDeclName(), Record, Idx); + ReadDeclarationNameLoc(FD->DNLoc, FD->getDeclName()); FD->IdentifierNamespace = Record[Idx++]; - + // FunctionDecl's body is handled last at ASTDeclReader::Visit, // after everything else is read. @@ -763,7 +756,7 @@ FD->HasSkippedBody = Record[Idx++]; FD->IsLateTemplateParsed = Record[Idx++]; FD->setCachedLinkage(Linkage(Record[Idx++])); - FD->EndRangeLoc = ReadSourceLocation(Record, Idx); + FD->EndRangeLoc = ReadSourceLocation(); switch ((FunctionDecl::TemplatedKind)Record[Idx++]) { case FunctionDecl::TK_NonTemplate: @@ -771,26 +764,24 @@ break; case FunctionDecl::TK_FunctionTemplate: // Merged when we merge the template. - FD->setDescribedFunctionTemplate(ReadDeclAs(Record, - Idx)); + FD->setDescribedFunctionTemplate(ReadDeclAs()); break; case FunctionDecl::TK_MemberSpecialization: { - FunctionDecl *InstFD = ReadDeclAs(Record, Idx); + FunctionDecl *InstFD = ReadDeclAs(); TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; - SourceLocation POI = ReadSourceLocation(Record, Idx); + SourceLocation POI = ReadSourceLocation(); FD->setInstantiationOfMemberFunction(Reader.getContext(), InstFD, TSK); FD->getMemberSpecializationInfo()->setPointOfInstantiation(POI); mergeRedeclarable(FD, Redecl); break; } case FunctionDecl::TK_FunctionTemplateSpecialization: { - FunctionTemplateDecl *Template = ReadDeclAs(Record, - Idx); + FunctionTemplateDecl *Template = ReadDeclAs(); TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; - + // Template arguments. SmallVector TemplArgs; - Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx, + Record.ReadTemplateArgumentList(TemplArgs, Idx, /*Canonicalize*/ true); // Template args as written. @@ -801,14 +792,13 @@ unsigned NumTemplateArgLocs = Record[Idx++]; TemplArgLocs.reserve(NumTemplateArgLocs); for (unsigned i=0; i != NumTemplateArgLocs; ++i) - TemplArgLocs.push_back( - Reader.ReadTemplateArgumentLoc(F, Record, Idx)); - - LAngleLoc = ReadSourceLocation(Record, Idx); - RAngleLoc = ReadSourceLocation(Record, Idx); + TemplArgLocs.push_back(Record.ReadTemplateArgumentLoc(Idx)); + + LAngleLoc = ReadSourceLocation(); + RAngleLoc = ReadSourceLocation(); } - - SourceLocation POI = ReadSourceLocation(Record, Idx); + + SourceLocation POI = ReadSourceLocation(); ASTContext &C = Reader.getContext(); TemplateArgumentList *TemplArgList @@ -827,8 +817,7 @@ if (FD->isCanonicalDecl()) { // if canonical add to template's set. // The template that contains the specializations set. It's not safe to // use getCanonicalDecl on Template since it may still be initializing. - FunctionTemplateDecl *CanonTemplate - = ReadDeclAs(Record, Idx); + FunctionTemplateDecl *CanonTemplate = ReadDeclAs(); // Get the InsertPos by FindNodeOrInsertPos() instead of calling // InsertNode(FTInfo) directly to avoid the getASTContext() call in // FunctionTemplateSpecializationInfo's Profile(). @@ -855,16 +844,16 @@ UnresolvedSet<8> TemplDecls; unsigned NumTemplates = Record[Idx++]; while (NumTemplates--) - TemplDecls.addDecl(ReadDeclAs(Record, Idx)); - + TemplDecls.addDecl(ReadDeclAs()); + // Templates args. TemplateArgumentListInfo TemplArgs; unsigned NumArgs = Record[Idx++]; while (NumArgs--) - TemplArgs.addArgument(Reader.ReadTemplateArgumentLoc(F, Record, Idx)); - TemplArgs.setLAngleLoc(ReadSourceLocation(Record, Idx)); - TemplArgs.setRAngleLoc(ReadSourceLocation(Record, Idx)); - + TemplArgs.addArgument(Record.ReadTemplateArgumentLoc(Idx)); + TemplArgs.setLAngleLoc(ReadSourceLocation()); + TemplArgs.setRAngleLoc(ReadSourceLocation()); + FD->setDependentTemplateSpecialization(Reader.getContext(), TemplDecls, TemplArgs); // These are not merged; we don't need to merge redeclarations of dependent @@ -878,7 +867,7 @@ SmallVector Params; Params.reserve(NumParams); for (unsigned I = 0; I != NumParams; ++I) - Params.push_back(ReadDeclAs(Record, Idx)); + Params.push_back(ReadDeclAs()); FD->setParams(Reader.getContext(), Params); } @@ -889,8 +878,8 @@ // definitions rarely show up in headers. Reader.PendingBodies[MD] = GetCurrentCursorOffset(); HasPendingBody = true; - MD->setSelfDecl(ReadDeclAs(Record, Idx)); - MD->setCmdDecl(ReadDeclAs(Record, Idx)); + MD->setSelfDecl(ReadDeclAs()); + MD->setCmdDecl(ReadDeclAs()); } MD->setInstanceMethod(Record[Idx++]); MD->setVariadic(Record[Idx++]); @@ -903,26 +892,26 @@ MD->HasRedeclaration = Record[Idx++]; if (MD->HasRedeclaration) Reader.getContext().setObjCMethodRedeclaration(MD, - ReadDeclAs(Record, Idx)); + ReadDeclAs()); MD->setDeclImplementation((ObjCMethodDecl::ImplementationControl)Record[Idx++]); MD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]); MD->SetRelatedResultType(Record[Idx++]); - MD->setReturnType(Reader.readType(F, Record, Idx)); - MD->setReturnTypeSourceInfo(GetTypeSourceInfo(Record, Idx)); - MD->DeclEndLoc = ReadSourceLocation(Record, Idx); + MD->setReturnType(Record.readType(Idx)); + MD->setReturnTypeSourceInfo(GetTypeSourceInfo()); + MD->DeclEndLoc = ReadSourceLocation(); unsigned NumParams = Record[Idx++]; SmallVector Params; Params.reserve(NumParams); for (unsigned I = 0; I != NumParams; ++I) - Params.push_back(ReadDeclAs(Record, Idx)); + Params.push_back(ReadDeclAs()); MD->SelLocsKind = Record[Idx++]; unsigned NumStoredSelLocs = Record[Idx++]; SmallVector SelLocs; SelLocs.reserve(NumStoredSelLocs); for (unsigned i = 0; i != NumStoredSelLocs; ++i) - SelLocs.push_back(ReadSourceLocation(Record, Idx)); + SelLocs.push_back(ReadSourceLocation()); MD->setParamsAndSelLocs(Reader.getContext(), Params, SelLocs); } @@ -932,14 +921,14 @@ D->Variance = Record[Idx++]; D->Index = Record[Idx++]; - D->VarianceLoc = ReadSourceLocation(Record, Idx); - D->ColonLoc = ReadSourceLocation(Record, Idx); + D->VarianceLoc = ReadSourceLocation(); + D->ColonLoc = ReadSourceLocation(); } void ASTDeclReader::VisitObjCContainerDecl(ObjCContainerDecl *CD) { VisitNamedDecl(CD); - CD->setAtStartLoc(ReadSourceLocation(Record, Idx)); - CD->setAtEndRange(ReadSourceRange(Record, Idx)); + CD->setAtStartLoc(ReadSourceLocation()); + CD->setAtEndRange(ReadSourceRange()); } ObjCTypeParamList *ASTDeclReader::ReadObjCTypeParamList() { @@ -950,48 +939,47 @@ SmallVector typeParams; typeParams.reserve(numParams); for (unsigned i = 0; i != numParams; ++i) { - auto typeParam = ReadDeclAs(Record, Idx); + auto typeParam = ReadDeclAs(); if (!typeParam) return nullptr; typeParams.push_back(typeParam); } - SourceLocation lAngleLoc = ReadSourceLocation(Record, Idx); - SourceLocation rAngleLoc = ReadSourceLocation(Record, Idx); + SourceLocation lAngleLoc = ReadSourceLocation(); + SourceLocation rAngleLoc = ReadSourceLocation(); return ObjCTypeParamList::create(Reader.getContext(), lAngleLoc, typeParams, rAngleLoc); } void ASTDeclReader::ReadObjCDefinitionData( - struct ObjCInterfaceDecl::DefinitionData &Data, - const RecordData &R, unsigned &I) { + struct ObjCInterfaceDecl::DefinitionData &Data, unsigned &I) { // Read the superclass. - Data.SuperClassTInfo = GetTypeSourceInfo(Record, Idx); + Data.SuperClassTInfo = GetTypeSourceInfo(); - Data.EndLoc = ReadSourceLocation(Record, Idx); + Data.EndLoc = ReadSourceLocation(); Data.HasDesignatedInitializers = Record[Idx++]; - + // Read the directly referenced protocols and their SourceLocations. unsigned NumProtocols = Record[Idx++]; SmallVector Protocols; Protocols.reserve(NumProtocols); for (unsigned I = 0; I != NumProtocols; ++I) - Protocols.push_back(ReadDeclAs(Record, Idx)); + Protocols.push_back(ReadDeclAs()); SmallVector ProtoLocs; ProtoLocs.reserve(NumProtocols); for (unsigned I = 0; I != NumProtocols; ++I) - ProtoLocs.push_back(ReadSourceLocation(Record, Idx)); + ProtoLocs.push_back(ReadSourceLocation()); Data.ReferencedProtocols.set(Protocols.data(), NumProtocols, ProtoLocs.data(), Reader.getContext()); - + // Read the transitive closure of protocols referenced by this class. NumProtocols = Record[Idx++]; Protocols.clear(); Protocols.reserve(NumProtocols); for (unsigned I = 0; I != NumProtocols; ++I) - Protocols.push_back(ReadDeclAs(Record, Idx)); + Protocols.push_back(ReadDeclAs()); Data.AllReferencedProtocols.set(Protocols.data(), NumProtocols, Reader.getContext()); } @@ -1004,7 +992,7 @@ void ASTDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) { RedeclarableResult Redecl = VisitRedeclarable(ID); VisitObjCContainerDecl(ID); - TypeIDForTypeDecl = Reader.getGlobalTypeID(F, Record[Idx++]); + TypeIDForTypeDecl = Record.getGlobalTypeID(Record[Idx++]); mergeRedeclarable(ID, Redecl); ID->TypeParamList = ReadObjCTypeParamList(); @@ -1012,7 +1000,7 @@ // Read the definition. ID->allocateDefinitionData(); - ReadObjCDefinitionData(ID->data(), Record, Idx); + ReadObjCDefinitionData(ID->data(), Idx); ObjCInterfaceDecl *Canon = ID->getCanonicalDecl(); if (Canon->Data.getPointer()) { // If we already have a definition, keep the definition invariant and @@ -1023,14 +1011,14 @@ // Set the definition data of the canonical declaration, so other // redeclarations will see it. ID->getCanonicalDecl()->Data = ID->Data; - + // We will rebuild this list lazily. ID->setIvarList(nullptr); } // Note that we have deserialized a definition. Reader.PendingDefinitions.insert(ID); - + // Note that we've loaded this Objective-C class. Reader.ObjCClassesLoaded.push_back(ID); } else { @@ -1051,11 +1039,11 @@ RedeclarableResult Redecl = VisitRedeclarable(PD); VisitObjCContainerDecl(PD); mergeRedeclarable(PD, Redecl); - + if (Record[Idx++]) { // Read the definition. PD->allocateDefinitionData(); - + // Set the definition data of the canonical declaration, so other // redeclarations will see it. PD->getCanonicalDecl()->Data = PD->Data; @@ -1064,14 +1052,14 @@ SmallVector ProtoRefs; ProtoRefs.reserve(NumProtoRefs); for (unsigned I = 0; I != NumProtoRefs; ++I) - ProtoRefs.push_back(ReadDeclAs(Record, Idx)); + ProtoRefs.push_back(ReadDeclAs()); SmallVector ProtoLocs; ProtoLocs.reserve(NumProtoRefs); for (unsigned I = 0; I != NumProtoRefs; ++I) - ProtoLocs.push_back(ReadSourceLocation(Record, Idx)); + ProtoLocs.push_back(ReadSourceLocation()); PD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(), Reader.getContext()); - + // Note that we have deserialized a definition. Reader.PendingDefinitions.insert(PD); } else { @@ -1085,41 +1073,41 @@ void ASTDeclReader::VisitObjCCategoryDecl(ObjCCategoryDecl *CD) { VisitObjCContainerDecl(CD); - CD->setCategoryNameLoc(ReadSourceLocation(Record, Idx)); - CD->setIvarLBraceLoc(ReadSourceLocation(Record, Idx)); - CD->setIvarRBraceLoc(ReadSourceLocation(Record, Idx)); - + CD->setCategoryNameLoc(ReadSourceLocation()); + CD->setIvarLBraceLoc(ReadSourceLocation()); + CD->setIvarRBraceLoc(ReadSourceLocation()); + // Note that this category has been deserialized. We do this before // deserializing the interface declaration, so that it will consider this /// category. Reader.CategoriesDeserialized.insert(CD); - CD->ClassInterface = ReadDeclAs(Record, Idx); + CD->ClassInterface = ReadDeclAs(); CD->TypeParamList = ReadObjCTypeParamList(); unsigned NumProtoRefs = Record[Idx++]; SmallVector ProtoRefs; ProtoRefs.reserve(NumProtoRefs); for (unsigned I = 0; I != NumProtoRefs; ++I) - ProtoRefs.push_back(ReadDeclAs(Record, Idx)); + ProtoRefs.push_back(ReadDeclAs()); SmallVector ProtoLocs; ProtoLocs.reserve(NumProtoRefs); for (unsigned I = 0; I != NumProtoRefs; ++I) - ProtoLocs.push_back(ReadSourceLocation(Record, Idx)); + ProtoLocs.push_back(ReadSourceLocation()); CD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(), Reader.getContext()); } void ASTDeclReader::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *CAD) { VisitNamedDecl(CAD); - CAD->setClassInterface(ReadDeclAs(Record, Idx)); + CAD->setClassInterface(ReadDeclAs()); } void ASTDeclReader::VisitObjCPropertyDecl(ObjCPropertyDecl *D) { VisitNamedDecl(D); - D->setAtLoc(ReadSourceLocation(Record, Idx)); - D->setLParenLoc(ReadSourceLocation(Record, Idx)); - QualType T = Reader.readType(F, Record, Idx); - TypeSourceInfo *TSI = GetTypeSourceInfo(Record, Idx); + D->setAtLoc(ReadSourceLocation()); + D->setLParenLoc(ReadSourceLocation()); + QualType T = Record.readType(Idx); + TypeSourceInfo *TSI = GetTypeSourceInfo(); D->setType(T, TSI); D->setPropertyAttributes( (ObjCPropertyDecl::PropertyAttributeKind)Record[Idx++]); @@ -1127,45 +1115,45 @@ (ObjCPropertyDecl::PropertyAttributeKind)Record[Idx++]); D->setPropertyImplementation( (ObjCPropertyDecl::PropertyControl)Record[Idx++]); - D->setGetterName(Reader.ReadDeclarationName(F,Record, Idx).getObjCSelector()); - D->setSetterName(Reader.ReadDeclarationName(F,Record, Idx).getObjCSelector()); - D->setGetterMethodDecl(ReadDeclAs(Record, Idx)); - D->setSetterMethodDecl(ReadDeclAs(Record, Idx)); - D->setPropertyIvarDecl(ReadDeclAs(Record, Idx)); + D->setGetterName(Record.ReadDeclarationName(Idx).getObjCSelector()); + D->setSetterName(Record.ReadDeclarationName(Idx).getObjCSelector()); + D->setGetterMethodDecl(ReadDeclAs()); + D->setSetterMethodDecl(ReadDeclAs()); + D->setPropertyIvarDecl(ReadDeclAs()); } void ASTDeclReader::VisitObjCImplDecl(ObjCImplDecl *D) { VisitObjCContainerDecl(D); - D->setClassInterface(ReadDeclAs(Record, Idx)); + D->setClassInterface(ReadDeclAs()); } void ASTDeclReader::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) { VisitObjCImplDecl(D); - D->setIdentifier(Reader.GetIdentifierInfo(F, Record, Idx)); - D->CategoryNameLoc = ReadSourceLocation(Record, Idx); + D->setIdentifier(Record.GetIdentifierInfo(Idx)); + D->CategoryNameLoc = ReadSourceLocation(); } void ASTDeclReader::VisitObjCImplementationDecl(ObjCImplementationDecl *D) { VisitObjCImplDecl(D); - D->setSuperClass(ReadDeclAs(Record, Idx)); - D->SuperLoc = ReadSourceLocation(Record, Idx); - D->setIvarLBraceLoc(ReadSourceLocation(Record, Idx)); - D->setIvarRBraceLoc(ReadSourceLocation(Record, Idx)); + D->setSuperClass(ReadDeclAs()); + D->SuperLoc = ReadSourceLocation(); + D->setIvarLBraceLoc(ReadSourceLocation()); + D->setIvarRBraceLoc(ReadSourceLocation()); D->setHasNonZeroConstructors(Record[Idx++]); D->setHasDestructors(Record[Idx++]); D->NumIvarInitializers = Record[Idx++]; if (D->NumIvarInitializers) - D->IvarInitializers = ReadGlobalOffset(F, Record, Idx); + D->IvarInitializers = ReadGlobalOffset(); } void ASTDeclReader::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) { VisitDecl(D); - D->setAtLoc(ReadSourceLocation(Record, Idx)); - D->setPropertyDecl(ReadDeclAs(Record, Idx)); - D->PropertyIvarDecl = ReadDeclAs(Record, Idx); - D->IvarLoc = ReadSourceLocation(Record, Idx); - D->setGetterCXXConstructor(Reader.ReadExpr(F)); - D->setSetterCXXAssignment(Reader.ReadExpr(F)); + D->setAtLoc(ReadSourceLocation()); + D->setPropertyDecl(ReadDeclAs()); + D->PropertyIvarDecl = ReadDeclAs(); + D->IvarLoc = ReadSourceLocation(); + D->setGetterCXXConstructor(Record.ReadExpr()); + D->setSetterCXXAssignment(Record.ReadExpr()); } void ASTDeclReader::VisitFieldDecl(FieldDecl *FD) { @@ -1177,13 +1165,13 @@ if (FD->InitStorage.getInt() == FieldDecl::ISK_CapturedVLAType) { // Read captured variable length array. FD->InitStorage.setPointer( - Reader.readType(F, Record, Idx).getAsOpaquePtr()); + Record.readType(Idx).getAsOpaquePtr()); } else { - FD->InitStorage.setPointer(Reader.ReadExpr(F)); + FD->InitStorage.setPointer(Record.ReadExpr()); } } if (!FD->getDeclName()) { - if (FieldDecl *Tmpl = ReadDeclAs(Record, Idx)) + if (FieldDecl *Tmpl = ReadDeclAs()) Reader.getContext().setInstantiatedFromUnnamedFieldDecl(FD, Tmpl); } mergeMergeable(FD); @@ -1191,8 +1179,8 @@ void ASTDeclReader::VisitMSPropertyDecl(MSPropertyDecl *PD) { VisitDeclaratorDecl(PD); - PD->GetterId = Reader.GetIdentifierInfo(F, Record, Idx); - PD->SetterId = Reader.GetIdentifierInfo(F, Record, Idx); + PD->GetterId = Record.GetIdentifierInfo(Idx); + PD->SetterId = Record.GetIdentifierInfo(Idx); } void ASTDeclReader::VisitIndirectFieldDecl(IndirectFieldDecl *FD) { @@ -1203,7 +1191,7 @@ FD->Chaining = new (Reader.getContext())NamedDecl*[FD->ChainingSize]; for (unsigned I = 0; I != FD->ChainingSize; ++I) - FD->Chaining[I] = ReadDeclAs(Record, Idx); + FD->Chaining[I] = ReadDeclAs(); mergeMergeable(FD); } @@ -1236,7 +1224,7 @@ VD->setLocalExternDecl(); if (uint64_t Val = Record[Idx++]) { - VD->setInit(Reader.ReadExpr(F)); + VD->setInit(Record.ReadExpr()); if (Val > 1) { // IsInitKnownICE = 1, IsInitNotICE = 2, IsInitICE = 3 EvaluatedStmt *Eval = VD->ensureEvaluatedStmt(); Eval->CheckedICE = true; @@ -1257,12 +1245,12 @@ break; case VarTemplate: // Merged when we merge the template. - VD->setDescribedVarTemplate(ReadDeclAs(Record, Idx)); + VD->setDescribedVarTemplate(ReadDeclAs()); break; case StaticDataMemberSpecialization: { // HasMemberSpecializationInfo. - VarDecl *Tmpl = ReadDeclAs(Record, Idx); + VarDecl *Tmpl = ReadDeclAs(); TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; - SourceLocation POI = ReadSourceLocation(Record, Idx); + SourceLocation POI = ReadSourceLocation(); Reader.getContext().setInstantiatedFromStaticDataMember(VD, Tmpl, TSK,POI); mergeRedeclarable(VD, Redecl); break; @@ -1292,7 +1280,7 @@ PD->ParmVarDeclBits.IsKNRPromoted = Record[Idx++]; PD->ParmVarDeclBits.HasInheritedDefaultArg = Record[Idx++]; if (Record[Idx++]) // hasUninstantiatedDefaultArg. - PD->setUninstantiatedDefaultArg(Reader.ReadExpr(F)); + PD->setUninstantiatedDefaultArg(Record.ReadExpr()); // FIXME: If this is a redeclaration of a function from another module, handle // inheritance of default arguments. @@ -1302,29 +1290,29 @@ VisitVarDecl(DD); BindingDecl **BDs = DD->getTrailingObjects(); for (unsigned I = 0; I != DD->NumBindings; ++I) - BDs[I] = ReadDeclAs(Record, Idx); + BDs[I] = ReadDeclAs(); } void ASTDeclReader::VisitBindingDecl(BindingDecl *BD) { VisitValueDecl(BD); - BD->Binding = Reader.ReadExpr(F); + BD->Binding = Record.ReadExpr(); } void ASTDeclReader::VisitFileScopeAsmDecl(FileScopeAsmDecl *AD) { VisitDecl(AD); - AD->setAsmString(cast(Reader.ReadExpr(F))); - AD->setRParenLoc(ReadSourceLocation(Record, Idx)); + AD->setAsmString(cast(Record.ReadExpr())); + AD->setRParenLoc(ReadSourceLocation()); } void ASTDeclReader::VisitBlockDecl(BlockDecl *BD) { VisitDecl(BD); - BD->setBody(cast_or_null(Reader.ReadStmt(F))); - BD->setSignatureAsWritten(GetTypeSourceInfo(Record, Idx)); + BD->setBody(cast_or_null(Record.ReadStmt())); + BD->setSignatureAsWritten(GetTypeSourceInfo()); unsigned NumParams = Record[Idx++]; SmallVector Params; Params.reserve(NumParams); for (unsigned I = 0; I != NumParams; ++I) - Params.push_back(ReadDeclAs(Record, Idx)); + Params.push_back(ReadDeclAs()); BD->setParams(Params); BD->setIsVariadic(Record[Idx++]); @@ -1336,11 +1324,11 @@ SmallVector captures; captures.reserve(numCaptures); for (unsigned i = 0; i != numCaptures; ++i) { - VarDecl *decl = ReadDeclAs(Record, Idx); + VarDecl *decl = ReadDeclAs(); unsigned flags = Record[Idx++]; bool byRef = (flags & 1); bool nested = (flags & 2); - Expr *copyExpr = ((flags & 4) ? Reader.ReadExpr(F) : nullptr); + Expr *copyExpr = ((flags & 4) ? Record.ReadExpr() : nullptr); captures.push_back(BlockDecl::Capture(decl, byRef, nested, copyExpr)); } @@ -1354,35 +1342,35 @@ // Body is set by VisitCapturedStmt. for (unsigned I = 0; I < CD->NumParams; ++I) { if (I != ContextParamPos) - CD->setParam(I, ReadDeclAs(Record, Idx)); + CD->setParam(I, ReadDeclAs()); else - CD->setContextParam(I, ReadDeclAs(Record, Idx)); + CD->setContextParam(I, ReadDeclAs()); } } void ASTDeclReader::VisitLinkageSpecDecl(LinkageSpecDecl *D) { VisitDecl(D); D->setLanguage((LinkageSpecDecl::LanguageIDs)Record[Idx++]); - D->setExternLoc(ReadSourceLocation(Record, Idx)); - D->setRBraceLoc(ReadSourceLocation(Record, Idx)); + D->setExternLoc(ReadSourceLocation()); + D->setRBraceLoc(ReadSourceLocation()); } void ASTDeclReader::VisitExportDecl(ExportDecl *D) { VisitDecl(D); - D->RBraceLoc = ReadSourceLocation(Record, Idx); + D->RBraceLoc = ReadSourceLocation(); } void ASTDeclReader::VisitLabelDecl(LabelDecl *D) { VisitNamedDecl(D); - D->setLocStart(ReadSourceLocation(Record, Idx)); + D->setLocStart(ReadSourceLocation()); } void ASTDeclReader::VisitNamespaceDecl(NamespaceDecl *D) { RedeclarableResult Redecl = VisitRedeclarable(D); VisitNamedDecl(D); D->setInline(Record[Idx++]); - D->LocStart = ReadSourceLocation(Record, Idx); - D->RBraceLoc = ReadSourceLocation(Record, Idx); + D->LocStart = ReadSourceLocation(); + D->RBraceLoc = ReadSourceLocation(); // Defer loading the anonymous namespace until we've finished merging // this namespace; loading it might load a later declaration of the @@ -1390,7 +1378,7 @@ // get merged before newer ones try to merge. GlobalDeclID AnonNamespace = 0; if (Redecl.getFirstID() == ThisDeclID) { - AnonNamespace = ReadDeclID(Record, Idx); + AnonNamespace = ReadDeclID(); } else { // Link this namespace back to the first declaration, which has already // been deserialized. @@ -1404,7 +1392,7 @@ // any other module's anonymous namespaces, so don't attach the anonymous // namespace at all. NamespaceDecl *Anon = cast(Reader.GetDecl(AnonNamespace)); - if (!F.isModule()) + if (!Record.isModule()) D->setAnonymousNamespace(Anon); } } @@ -1412,21 +1400,21 @@ void ASTDeclReader::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) { RedeclarableResult Redecl = VisitRedeclarable(D); VisitNamedDecl(D); - D->NamespaceLoc = ReadSourceLocation(Record, Idx); - D->IdentLoc = ReadSourceLocation(Record, Idx); - D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); - D->Namespace = ReadDeclAs(Record, Idx); + D->NamespaceLoc = ReadSourceLocation(); + D->IdentLoc = ReadSourceLocation(); + D->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx); + D->Namespace = ReadDeclAs(); mergeRedeclarable(D, Redecl); } void ASTDeclReader::VisitUsingDecl(UsingDecl *D) { VisitNamedDecl(D); - D->setUsingLoc(ReadSourceLocation(Record, Idx)); - D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); - ReadDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record, Idx); - D->FirstUsingShadow.setPointer(ReadDeclAs(Record, Idx)); + D->setUsingLoc(ReadSourceLocation()); + D->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx); + ReadDeclarationNameLoc(D->DNLoc, D->getDeclName()); + D->FirstUsingShadow.setPointer(ReadDeclAs()); D->setTypename(Record[Idx++]); - if (NamedDecl *Pattern = ReadDeclAs(Record, Idx)) + if (NamedDecl *Pattern = ReadDeclAs()) Reader.getContext().setInstantiatedFromUsingDecl(D, Pattern); mergeMergeable(D); } @@ -1434,9 +1422,9 @@ void ASTDeclReader::VisitUsingShadowDecl(UsingShadowDecl *D) { RedeclarableResult Redecl = VisitRedeclarable(D); VisitNamedDecl(D); - D->setTargetDecl(ReadDeclAs(Record, Idx)); - D->UsingOrNextShadow = ReadDeclAs(Record, Idx); - UsingShadowDecl *Pattern = ReadDeclAs(Record, Idx); + D->setTargetDecl(ReadDeclAs()); + D->UsingOrNextShadow = ReadDeclAs(); + UsingShadowDecl *Pattern = ReadDeclAs(); if (Pattern) Reader.getContext().setInstantiatedFromUsingShadowDecl(D, Pattern); mergeRedeclarable(D, Redecl); @@ -1445,41 +1433,39 @@ void ASTDeclReader::VisitConstructorUsingShadowDecl( ConstructorUsingShadowDecl *D) { VisitUsingShadowDecl(D); - D->NominatedBaseClassShadowDecl = - ReadDeclAs(Record, Idx); - D->ConstructedBaseClassShadowDecl = - ReadDeclAs(Record, Idx); + D->NominatedBaseClassShadowDecl = ReadDeclAs(); + D->ConstructedBaseClassShadowDecl = ReadDeclAs(); D->IsVirtual = Record[Idx++]; } void ASTDeclReader::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) { VisitNamedDecl(D); - D->UsingLoc = ReadSourceLocation(Record, Idx); - D->NamespaceLoc = ReadSourceLocation(Record, Idx); - D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); - D->NominatedNamespace = ReadDeclAs(Record, Idx); - D->CommonAncestor = ReadDeclAs(Record, Idx); + D->UsingLoc = ReadSourceLocation(); + D->NamespaceLoc = ReadSourceLocation(); + D->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx); + D->NominatedNamespace = ReadDeclAs(); + D->CommonAncestor = ReadDeclAs(); } void ASTDeclReader::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) { VisitValueDecl(D); - D->setUsingLoc(ReadSourceLocation(Record, Idx)); - D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); - ReadDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record, Idx); + D->setUsingLoc(ReadSourceLocation()); + D->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx); + ReadDeclarationNameLoc(D->DNLoc, D->getDeclName()); mergeMergeable(D); } void ASTDeclReader::VisitUnresolvedUsingTypenameDecl( UnresolvedUsingTypenameDecl *D) { VisitTypeDecl(D); - D->TypenameLocation = ReadSourceLocation(Record, Idx); - D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); + D->TypenameLocation = ReadSourceLocation(); + D->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx); mergeMergeable(D); } void ASTDeclReader::ReadCXXDefinitionData( struct CXXRecordDecl::DefinitionData &Data, - const RecordData &Record, unsigned &Idx) { + unsigned &Idx) { // Note: the caller has deserialized the IsLambda bit already. Data.UserDeclaredConstructor = Record[Idx++]; Data.UserDeclaredSpecialMembers = Record[Idx++]; @@ -1525,15 +1511,15 @@ Data.NumBases = Record[Idx++]; if (Data.NumBases) - Data.Bases = ReadGlobalOffset(F, Record, Idx); + Data.Bases = ReadGlobalOffset(); Data.NumVBases = Record[Idx++]; if (Data.NumVBases) - Data.VBases = ReadGlobalOffset(F, Record, Idx); - - Reader.ReadUnresolvedSet(F, Data.Conversions, Record, Idx); - Reader.ReadUnresolvedSet(F, Data.VisibleConversions, Record, Idx); + Data.VBases = ReadGlobalOffset(); + + Record.ReadUnresolvedSet(Data.Conversions, Idx); + Record.ReadUnresolvedSet(Data.VisibleConversions, Idx); assert(Data.Definition && "Data.Definition should be already set!"); - Data.FirstFriend = ReadDeclID(Record, Idx); + Data.FirstFriend = ReadDeclID(); if (Data.IsLambda) { typedef LambdaCapture Capture; @@ -1545,13 +1531,13 @@ Lambda.NumCaptures = Record[Idx++]; Lambda.NumExplicitCaptures = Record[Idx++]; Lambda.ManglingNumber = Record[Idx++]; - Lambda.ContextDecl = ReadDeclID(Record, Idx); + Lambda.ContextDecl = ReadDeclID(); Lambda.Captures = (Capture*)Reader.Context.Allocate(sizeof(Capture)*Lambda.NumCaptures); Capture *ToCapture = Lambda.Captures; - Lambda.MethodTyInfo = GetTypeSourceInfo(Record, Idx); + Lambda.MethodTyInfo = GetTypeSourceInfo(); for (unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) { - SourceLocation Loc = ReadSourceLocation(Record, Idx); + SourceLocation Loc = ReadSourceLocation(); bool IsImplicit = Record[Idx++]; LambdaCaptureKind Kind = static_cast(Record[Idx++]); switch (Kind) { @@ -1562,8 +1548,8 @@ break; case LCK_ByCopy: case LCK_ByRef: - VarDecl *Var = ReadDeclAs(Record, Idx); - SourceLocation EllipsisLoc = ReadSourceLocation(Record, Idx); + VarDecl *Var = ReadDeclAs(); + SourceLocation EllipsisLoc = ReadSourceLocation(); *ToCapture++ = Capture(Loc, IsImplicit, Kind, Var, EllipsisLoc); break; } @@ -1692,7 +1678,7 @@ else DD = new (C) struct CXXRecordDecl::DefinitionData(D); - ReadCXXDefinitionData(*DD, Record, Idx); + ReadCXXDefinitionData(*DD, Idx); // 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 @@ -1734,7 +1720,7 @@ break; case CXXRecTemplate: { // Merged when we merge the template. - ClassTemplateDecl *Template = ReadDeclAs(Record, Idx); + ClassTemplateDecl *Template = ReadDeclAs(); D->TemplateOrInstantiation = Template; if (!Template->getTemplatedDecl()) { // We've not actually loaded the ClassTemplateDecl yet, because we're @@ -1748,9 +1734,9 @@ break; } case CXXRecMemberSpecialization: { - CXXRecordDecl *RD = ReadDeclAs(Record, Idx); + CXXRecordDecl *RD = ReadDeclAs(); TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++]; - SourceLocation POI = ReadSourceLocation(Record, Idx); + SourceLocation POI = ReadSourceLocation(); MemberSpecializationInfo *MSI = new (C) MemberSpecializationInfo(RD, TSK); MSI->setPointOfInstantiation(POI); D->TemplateOrInstantiation = MSI; @@ -1769,7 +1755,7 @@ // Lazily load the key function to avoid deserializing every method so we can // compute it. if (WasDefinition) { - DeclID KeyFn = ReadDeclID(Record, Idx); + DeclID KeyFn = ReadDeclID(); if (KeyFn && D->IsCompleteDefinition) // FIXME: This is wrong for the ARM ABI, where some other module may have // made this function no longer be a key function. We need an update @@ -1788,7 +1774,7 @@ while (NumOverridenMethods--) { // Avoid invariant checking of CXXMethodDecl::addOverriddenMethod, // MD may be initializing. - if (CXXMethodDecl *MD = ReadDeclAs(Record, Idx)) + if (CXXMethodDecl *MD = ReadDeclAs()) Reader.getContext().addOverriddenMethod(D, MD->getCanonicalDecl()); } } else { @@ -1802,8 +1788,8 @@ // We need the inherited constructor information to merge the declaration, // so we have to read it before we call VisitCXXMethodDecl. if (D->isInheritingConstructor()) { - auto *Shadow = ReadDeclAs(Record, Idx); - auto *Ctor = ReadDeclAs(Record, Idx); + auto *Shadow = ReadDeclAs(); + auto *Ctor = ReadDeclAs(); *D->getTrailingObjects() = InheritedConstructor(Shadow, Ctor); } @@ -1816,7 +1802,7 @@ void ASTDeclReader::VisitCXXDestructorDecl(CXXDestructorDecl *D) { VisitCXXMethodDecl(D); - if (auto *OperatorDelete = ReadDeclAs(Record, Idx)) { + if (auto *OperatorDelete = ReadDeclAs()) { auto *Canon = cast(D->getCanonicalDecl()); // FIXME: Check consistency if we have an old and new operator delete. if (!Canon->OperatorDelete) @@ -1831,31 +1817,31 @@ void ASTDeclReader::VisitImportDecl(ImportDecl *D) { VisitDecl(D); - D->ImportedAndComplete.setPointer(readModule(Record, Idx)); + D->ImportedAndComplete.setPointer(readModule()); D->ImportedAndComplete.setInt(Record[Idx++]); SourceLocation *StoredLocs = D->getTrailingObjects(); for (unsigned I = 0, N = Record.back(); I != N; ++I) - StoredLocs[I] = ReadSourceLocation(Record, Idx); + StoredLocs[I] = ReadSourceLocation(); ++Idx; // The number of stored source locations. } void ASTDeclReader::VisitAccessSpecDecl(AccessSpecDecl *D) { VisitDecl(D); - D->setColonLoc(ReadSourceLocation(Record, Idx)); + D->setColonLoc(ReadSourceLocation()); } void ASTDeclReader::VisitFriendDecl(FriendDecl *D) { VisitDecl(D); if (Record[Idx++]) // hasFriendDecl - D->Friend = ReadDeclAs(Record, Idx); + D->Friend = ReadDeclAs(); else - D->Friend = GetTypeSourceInfo(Record, Idx); + D->Friend = GetTypeSourceInfo(); for (unsigned i = 0; i != D->NumTPLists; ++i) D->getTrailingObjects()[i] = - Reader.ReadTemplateParameterList(F, Record, Idx); - D->NextFriend = ReadDeclID(Record, Idx); + Record.ReadTemplateParameterList(Idx); + D->NextFriend = ReadDeclID(); D->UnsupportedFriend = (Record[Idx++] != 0); - D->FriendLoc = ReadSourceLocation(Record, Idx); + D->FriendLoc = ReadSourceLocation(); } void ASTDeclReader::VisitFriendTemplateDecl(FriendTemplateDecl *D) { @@ -1864,27 +1850,27 @@ D->NumParams = NumParams; D->Params = new TemplateParameterList*[NumParams]; for (unsigned i = 0; i != NumParams; ++i) - D->Params[i] = Reader.ReadTemplateParameterList(F, Record, Idx); + D->Params[i] = Record.ReadTemplateParameterList(Idx); if (Record[Idx++]) // HasFriendDecl - D->Friend = ReadDeclAs(Record, Idx); + D->Friend = ReadDeclAs(); else - D->Friend = GetTypeSourceInfo(Record, Idx); - D->FriendLoc = ReadSourceLocation(Record, Idx); + D->Friend = GetTypeSourceInfo(); + D->FriendLoc = ReadSourceLocation(); } DeclID ASTDeclReader::VisitTemplateDecl(TemplateDecl *D) { VisitNamedDecl(D); - DeclID PatternID = ReadDeclID(Record, Idx); + DeclID PatternID = ReadDeclID(); NamedDecl *TemplatedDecl = cast_or_null(Reader.GetDecl(PatternID)); TemplateParameterList* TemplateParams - = Reader.ReadTemplateParameterList(F, Record, Idx); + = Record.ReadTemplateParameterList(Idx); D->init(TemplatedDecl, TemplateParams); return PatternID; } -ASTDeclReader::RedeclarableResult +ASTDeclReader::RedeclarableResult ASTDeclReader::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) { RedeclarableResult Redecl = VisitRedeclarable(D); @@ -1901,7 +1887,7 @@ // for the 'common' pointer. if (ThisDeclID == Redecl.getFirstID()) { if (RedeclarableTemplateDecl *RTD - = ReadDeclAs(Record, Idx)) { + = ReadDeclAs()) { assert(RTD->getKind() == D->getKind() && "InstantiatedFromMemberTemplate kind mismatch"); D->setInstantiatedFromMemberTemplate(RTD); @@ -1991,14 +1977,14 @@ ASTDeclReader::VisitClassTemplateSpecializationDeclImpl( ClassTemplateSpecializationDecl *D) { RedeclarableResult Redecl = VisitCXXRecordDeclImpl(D); - + ASTContext &C = Reader.getContext(); - if (Decl *InstD = ReadDecl(Record, Idx)) { + if (Decl *InstD = ReadDecl()) { if (ClassTemplateDecl *CTD = dyn_cast(InstD)) { D->SpecializedTemplate = CTD; } else { SmallVector TemplArgs; - Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx); + Record.ReadTemplateArgumentList(TemplArgs, Idx); TemplateArgumentList *ArgList = TemplateArgumentList::CreateCopy(C, TemplArgs); ClassTemplateSpecializationDecl::SpecializedPartialSpecialization *PS @@ -2012,15 +1998,15 @@ } SmallVector TemplArgs; - Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx, + Record.ReadTemplateArgumentList(TemplArgs, Idx, /*Canonicalize*/ true); D->TemplateArgs = TemplateArgumentList::CreateCopy(C, TemplArgs); - D->PointOfInstantiation = ReadSourceLocation(Record, Idx); + D->PointOfInstantiation = ReadSourceLocation(); D->SpecializationKind = (TemplateSpecializationKind)Record[Idx++]; bool writtenAsCanonicalDecl = Record[Idx++]; if (writtenAsCanonicalDecl) { - ClassTemplateDecl *CanonPattern = ReadDeclAs(Record,Idx); + ClassTemplateDecl *CanonPattern = ReadDeclAs(); if (D->isCanonicalDecl()) { // It's kept in the folding set. // Set this as, or find, the canonical declaration for this specialization ClassTemplateSpecializationDecl *CanonSpec; @@ -2050,12 +2036,12 @@ } // Explicit info. - if (TypeSourceInfo *TyInfo = GetTypeSourceInfo(Record, Idx)) { + if (TypeSourceInfo *TyInfo = GetTypeSourceInfo()) { ClassTemplateSpecializationDecl::ExplicitSpecializationInfo *ExplicitInfo = new (C) ClassTemplateSpecializationDecl::ExplicitSpecializationInfo; ExplicitInfo->TypeAsWritten = TyInfo; - ExplicitInfo->ExternLoc = ReadSourceLocation(Record, Idx); - ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation(Record, Idx); + ExplicitInfo->ExternLoc = ReadSourceLocation(); + ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation(); D->ExplicitInfo = ExplicitInfo; } @@ -2066,13 +2052,13 @@ ClassTemplatePartialSpecializationDecl *D) { RedeclarableResult Redecl = VisitClassTemplateSpecializationDeclImpl(D); - D->TemplateParams = Reader.ReadTemplateParameterList(F, Record, Idx); - D->ArgsAsWritten = Reader.ReadASTTemplateArgumentListInfo(F, Record, Idx); + D->TemplateParams = Record.ReadTemplateParameterList(Idx); + D->ArgsAsWritten = Record.ReadASTTemplateArgumentListInfo(Idx); // These are read/set from/to the first declaration. if (ThisDeclID == Redecl.getFirstID()) { D->InstantiatedFromMember.setPointer( - ReadDeclAs(Record, Idx)); + ReadDeclAs()); D->InstantiatedFromMember.setInt(Record[Idx++]); } } @@ -2080,7 +2066,7 @@ void ASTDeclReader::VisitClassScopeFunctionSpecializationDecl( ClassScopeFunctionSpecializationDecl *D) { VisitDecl(D); - D->Specialization = ReadDeclAs(Record, Idx); + D->Specialization = ReadDeclAs(); } void ASTDeclReader::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { @@ -2110,12 +2096,12 @@ RedeclarableResult Redecl = VisitVarDeclImpl(D); ASTContext &C = Reader.getContext(); - if (Decl *InstD = ReadDecl(Record, Idx)) { + if (Decl *InstD = ReadDecl()) { if (VarTemplateDecl *VTD = dyn_cast(InstD)) { D->SpecializedTemplate = VTD; } else { SmallVector TemplArgs; - Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx); + Record.ReadTemplateArgumentList(TemplArgs, Idx); TemplateArgumentList *ArgList = TemplateArgumentList::CreateCopy( C, TemplArgs); VarTemplateSpecializationDecl::SpecializedPartialSpecialization *PS = @@ -2129,25 +2115,25 @@ } // Explicit info. - if (TypeSourceInfo *TyInfo = GetTypeSourceInfo(Record, Idx)) { + if (TypeSourceInfo *TyInfo = GetTypeSourceInfo()) { VarTemplateSpecializationDecl::ExplicitSpecializationInfo *ExplicitInfo = new (C) VarTemplateSpecializationDecl::ExplicitSpecializationInfo; ExplicitInfo->TypeAsWritten = TyInfo; - ExplicitInfo->ExternLoc = ReadSourceLocation(Record, Idx); - ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation(Record, Idx); + ExplicitInfo->ExternLoc = ReadSourceLocation(); + ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation(); D->ExplicitInfo = ExplicitInfo; } SmallVector TemplArgs; - Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx, + Record.ReadTemplateArgumentList(TemplArgs, Idx, /*Canonicalize*/ true); D->TemplateArgs = TemplateArgumentList::CreateCopy(C, TemplArgs); - D->PointOfInstantiation = ReadSourceLocation(Record, Idx); + D->PointOfInstantiation = ReadSourceLocation(); D->SpecializationKind = (TemplateSpecializationKind)Record[Idx++]; bool writtenAsCanonicalDecl = Record[Idx++]; if (writtenAsCanonicalDecl) { - VarTemplateDecl *CanonPattern = ReadDeclAs(Record, Idx); + VarTemplateDecl *CanonPattern = ReadDeclAs(); if (D->isCanonicalDecl()) { // It's kept in the folding set. // FIXME: If it's already present, merge it. if (VarTemplatePartialSpecializationDecl *Partial = @@ -2172,13 +2158,13 @@ VarTemplatePartialSpecializationDecl *D) { RedeclarableResult Redecl = VisitVarTemplateSpecializationDeclImpl(D); - D->TemplateParams = Reader.ReadTemplateParameterList(F, Record, Idx); - D->ArgsAsWritten = Reader.ReadASTTemplateArgumentListInfo(F, Record, Idx); + D->TemplateParams = Record.ReadTemplateParameterList(Idx); + D->ArgsAsWritten = Record.ReadASTTemplateArgumentListInfo(Idx); // These are read/set from/to the first declaration. if (ThisDeclID == Redecl.getFirstID()) { D->InstantiatedFromMember.setPointer( - ReadDeclAs(Record, Idx)); + ReadDeclAs()); D->InstantiatedFromMember.setInt(Record[Idx++]); } } @@ -2189,7 +2175,7 @@ D->setDeclaredWithTypename(Record[Idx++]); if (Record[Idx++]) - D->setDefaultArgument(GetTypeSourceInfo(Record, Idx)); + D->setDefaultArgument(GetTypeSourceInfo()); } void ASTDeclReader::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) { @@ -2201,14 +2187,14 @@ auto TypesAndInfos = D->getTrailingObjects>(); for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) { - new (&TypesAndInfos[I].first) QualType(Reader.readType(F, Record, Idx)); - TypesAndInfos[I].second = GetTypeSourceInfo(Record, Idx); + new (&TypesAndInfos[I].first) QualType(Record.readType(Idx)); + TypesAndInfos[I].second = GetTypeSourceInfo(); } } else { // Rest of NonTypeTemplateParmDecl. D->ParameterPack = Record[Idx++]; if (Record[Idx++]) - D->setDefaultArgument(Reader.ReadExpr(F)); + D->setDefaultArgument(Record.ReadExpr()); } } @@ -2222,13 +2208,13 @@ D->getTrailingObjects(); for (unsigned I = 0, N = D->getNumExpansionTemplateParameters(); I != N; ++I) - Data[I] = Reader.ReadTemplateParameterList(F, Record, Idx); + Data[I] = Record.ReadTemplateParameterList(Idx); } else { // Rest of TemplateTemplateParmDecl. D->ParameterPack = Record[Idx++]; if (Record[Idx++]) D->setDefaultArgument(Reader.getContext(), - Reader.ReadTemplateArgumentLoc(F, Record, Idx)); + Record.ReadTemplateArgumentLoc(Idx)); } } @@ -2238,10 +2224,10 @@ void ASTDeclReader::VisitStaticAssertDecl(StaticAssertDecl *D) { VisitDecl(D); - D->AssertExprAndFailed.setPointer(Reader.ReadExpr(F)); + D->AssertExprAndFailed.setPointer(Record.ReadExpr()); D->AssertExprAndFailed.setInt(Record[Idx++]); - D->Message = cast_or_null(Reader.ReadExpr(F)); - D->RParenLoc = ReadSourceLocation(Record, Idx); + D->Message = cast_or_null(Record.ReadExpr()); + D->RParenLoc = ReadSourceLocation(); } void ASTDeclReader::VisitEmptyDecl(EmptyDecl *D) { @@ -2250,15 +2236,15 @@ std::pair ASTDeclReader::VisitDeclContext(DeclContext *DC) { - uint64_t LexicalOffset = ReadLocalOffset(Record, Idx); - uint64_t VisibleOffset = ReadLocalOffset(Record, Idx); + uint64_t LexicalOffset = ReadLocalOffset(); + uint64_t VisibleOffset = ReadLocalOffset(); return std::make_pair(LexicalOffset, VisibleOffset); } template ASTDeclReader::RedeclarableResult ASTDeclReader::VisitRedeclarable(Redeclarable *D) { - DeclID FirstDeclID = ReadDeclID(Record, Idx); + DeclID FirstDeclID = ReadDeclID(); Decl *MergeWith = nullptr; bool IsKeyDecl = ThisDeclID == FirstDeclID; @@ -2284,13 +2270,13 @@ // FIXME: Provide a known merge target to the second and subsequent such // declaration. for (unsigned I = 0; I != N - 1; ++I) - MergeWith = ReadDecl(Record, Idx/*, MergeWith*/); + MergeWith = ReadDecl(); - RedeclOffset = ReadLocalOffset(Record, Idx); + RedeclOffset = ReadLocalOffset(); } else { // This declaration was not the first local declaration. Read the first // local declaration now, to trigger the import of other redeclarations. - (void)ReadDecl(Record, Idx); + (void)ReadDecl(); } T *FirstDecl = cast_or_null(Reader.GetDecl(FirstDeclID)); @@ -2301,7 +2287,7 @@ // loaded & attached later on. D->RedeclLink = Redeclarable::PreviousDeclLink(FirstDecl); D->First = FirstDecl->getCanonicalDecl(); - } + } T *DAsT = static_cast(D); @@ -2354,10 +2340,10 @@ DeclID DsID, bool IsKeyDecl) { auto *DPattern = D->getTemplatedDecl(); auto *ExistingPattern = Existing->getTemplatedDecl(); - RedeclarableResult Result(/*MergeWith*/ ExistingPattern, - DPattern->getCanonicalDecl()->getGlobalID(), + RedeclarableResult Result(/*MergeWith*/ ExistingPattern, + DPattern->getCanonicalDecl()->getGlobalID(), IsKeyDecl); - + if (auto *DClass = dyn_cast(DPattern)) { // Merge with any existing definition. // FIXME: This is duplicated in several places. Refactor. @@ -2457,17 +2443,17 @@ SmallVector Vars; Vars.reserve(NumVars); for (unsigned i = 0; i != NumVars; ++i) { - Vars.push_back(Reader.ReadExpr(F)); + Vars.push_back(Record.ReadExpr()); } D->setVars(Vars); } void ASTDeclReader::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D) { VisitValueDecl(D); - D->setLocation(Reader.ReadSourceLocation(F, Record, Idx)); - D->setCombiner(Reader.ReadExpr(F)); - D->setInitializer(Reader.ReadExpr(F)); - D->PrevDeclInScope = Reader.ReadDeclID(F, Record, Idx); + D->setLocation(ReadSourceLocation()); + D->setCombiner(Record.ReadExpr()); + D->setInitializer(Record.ReadExpr()); + D->PrevDeclInScope = ReadDeclID(); } void ASTDeclReader::VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D) { @@ -3568,7 +3554,7 @@ unsigned Idx = 0; ASTDeclReader Reader(*this, RecordLocation(F, Offset), ID, SourceLocation(), Record, Idx); - Reader.UpdateDecl(D, *F, Record); + Reader.UpdateDecl(D); // We might have made this declaration interesting. If so, remember that // we need to hand it off to the consumer. @@ -3775,15 +3761,14 @@ } } -void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile, - const RecordData &Record) { +void ASTDeclReader::UpdateDecl(Decl *D) { while (Idx < Record.size()) { switch ((DeclUpdateKind)Record[Idx++]) { 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 = Reader.ReadDecl(ModuleFile, Record, Idx); + Decl *MD = Record.ReadDecl(Idx); assert(MD && "couldn't read decl from update record"); // FIXME: We should call addHiddenDecl instead, to add the member // to its DeclContext. @@ -3793,17 +3778,16 @@ case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION: // It will be added to the template's specializations set when loaded. - (void)Reader.ReadDecl(ModuleFile, Record, Idx); + (void)Record.ReadDecl(Idx); break; case UPD_CXX_ADDED_ANONYMOUS_NAMESPACE: { - NamespaceDecl *Anon - = Reader.ReadDeclAs(ModuleFile, Record, Idx); - + NamespaceDecl *Anon = ReadDeclAs(); + // Each module has its own anonymous namespace, which is disjoint from // any other module's anonymous namespaces, so don't attach the anonymous // namespace at all. - if (!ModuleFile.isModule()) { + if (!Record.isModule()) { if (TranslationUnitDecl *TU = dyn_cast(D)) TU->setAnonymousNamespace(Anon); else @@ -3814,7 +3798,7 @@ case UPD_CXX_INSTANTIATED_STATIC_DATA_MEMBER: cast(D)->getMemberSpecializationInfo()->setPointOfInstantiation( - Reader.ReadSourceLocation(ModuleFile, Record, Idx)); + ReadSourceLocation()); break; case UPD_CXX_INSTANTIATED_DEFAULT_ARGUMENT: { @@ -3823,7 +3807,7 @@ // We have to read the default argument regardless of whether we use it // so that hypothetical further update records aren't messed up. // TODO: Add a function to skip over the next expr record. - auto DefaultArg = Reader.ReadExpr(F); + auto DefaultArg = Record.ReadExpr(); // Only apply the update if the parameter still has an uninstantiated // default argument. @@ -3834,7 +3818,7 @@ case UPD_CXX_INSTANTIATED_DEFAULT_MEMBER_INITIALIZER: { auto FD = cast(D); - auto DefaultInit = Reader.ReadExpr(F); + auto DefaultInit = Record.ReadExpr(); // Only apply the update if the field still has an uninstantiated // default member initializer. @@ -3865,11 +3849,11 @@ FD->setImplicitlyInline(); }); } - FD->setInnerLocStart(Reader.ReadSourceLocation(ModuleFile, Record, Idx)); + FD->setInnerLocStart(ReadSourceLocation()); if (auto *CD = dyn_cast(FD)) { CD->NumCtorInitializers = Record[Idx++]; if (CD->NumCtorInitializers) - CD->CtorInitializers = ReadGlobalOffset(F, Record, Idx); + CD->CtorInitializers = ReadGlobalOffset(); } // Store the offset of the body so we can lazily load it later. Reader.PendingBodies[FD] = GetCurrentCursorOffset(); @@ -3887,15 +3871,14 @@ ReadCXXRecordDefinition(RD, /*Update*/true); // Visible update is handled separately. - uint64_t LexicalOffset = ReadLocalOffset(Record, Idx); + uint64_t LexicalOffset = ReadLocalOffset(); if (!HadRealDefinition && LexicalOffset) { - Reader.ReadLexicalDeclContextStorage(ModuleFile, ModuleFile.DeclsCursor, - LexicalOffset, RD); + Record.ReadLexicalDeclContextStorage(LexicalOffset, RD); Reader.PendingFakeDefinitionData.erase(OldDD); } auto TSK = (TemplateSpecializationKind)Record[Idx++]; - SourceLocation POI = Reader.ReadSourceLocation(ModuleFile, Record, Idx); + SourceLocation POI = ReadSourceLocation(); if (MemberSpecializationInfo *MSInfo = RD->getMemberSpecializationInfo()) { MSInfo->setTemplateSpecializationKind(TSK); @@ -3908,9 +3891,9 @@ if (Record[Idx++]) { auto PartialSpec = - ReadDeclAs(Record, Idx); + ReadDeclAs(); SmallVector TemplArgs; - Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx); + Record.ReadTemplateArgumentList(TemplArgs, Idx); auto *TemplArgList = TemplateArgumentList::CreateCopy( Reader.getContext(), TemplArgs); @@ -3923,13 +3906,13 @@ } RD->setTagKind((TagTypeKind)Record[Idx++]); - RD->setLocation(Reader.ReadSourceLocation(ModuleFile, Record, Idx)); - RD->setLocStart(Reader.ReadSourceLocation(ModuleFile, Record, Idx)); - RD->setBraceRange(Reader.ReadSourceRange(ModuleFile, Record, Idx)); + RD->setLocation(ReadSourceLocation()); + RD->setLocStart(ReadSourceLocation()); + RD->setBraceRange(ReadSourceRange()); if (Record[Idx++]) { AttrVec Attrs; - Reader.ReadAttributes(F, Attrs, Record, Idx); + Record.ReadAttributes(Attrs, Idx); // If the declaration already has attributes, we assume that some other // AST file already loaded them. if (!D->hasAttrs()) @@ -3941,7 +3924,7 @@ case UPD_CXX_RESOLVED_DTOR_DELETE: { // Set the 'operator delete' directly to avoid emitting another update // record. - auto *Del = Reader.ReadDeclAs(ModuleFile, Record, Idx); + auto *Del = ReadDeclAs(); auto *First = cast(D->getCanonicalDecl()); // FIXME: Check consistency if we have an old and new operator delete. if (!First->OperatorDelete) @@ -3952,7 +3935,7 @@ case UPD_CXX_RESOLVED_EXCEPTION_SPEC: { FunctionProtoType::ExceptionSpecInfo ESI; SmallVector ExceptionStorage; - Reader.readExceptionSpec(ModuleFile, ExceptionStorage, ESI, Record, Idx); + Record.readExceptionSpec(ExceptionStorage, ESI, Idx); // Update this declaration's exception specification, if needed. auto *FD = cast(D); @@ -3974,7 +3957,7 @@ case UPD_CXX_DEDUCED_RETURN_TYPE: { // FIXME: Also do this when merging redecls. - QualType DeducedResultType = Reader.readType(ModuleFile, Record, Idx); + QualType DeducedResultType = Record.readType(Idx); for (auto *Redecl : merged_redecls(D)) { // FIXME: If the return type is already deduced, check that it matches. FunctionDecl *FD = cast(Redecl); @@ -3999,11 +3982,11 @@ case UPD_DECL_MARKED_OPENMP_THREADPRIVATE: D->addAttr(OMPThreadPrivateDeclAttr::CreateImplicit( - Reader.Context, ReadSourceRange(Record, Idx))); + Reader.Context, ReadSourceRange())); break; case UPD_DECL_EXPORTED: { - unsigned SubmoduleID = readSubmoduleID(Record, Idx); + unsigned SubmoduleID = readSubmoduleID(); auto *Exported = cast(D); if (auto *TD = dyn_cast(Exported)) Exported = TD->getDefinition(); @@ -4027,7 +4010,7 @@ case UPD_DECL_MARKED_OPENMP_DECLARETARGET: case UPD_ADDED_ATTR_TO_RECORD: AttrVec Attrs; - Reader.ReadAttributes(F, Attrs, Record, Idx); + Record.ReadAttributes(Attrs, Idx); assert(Attrs.size() == 1); D->addAttr(Attrs[0]); break; Index: lib/Serialization/ASTReaderStmt.cpp =================================================================== --- lib/Serialization/ASTReaderStmt.cpp +++ lib/Serialization/ASTReaderStmt.cpp @@ -26,62 +26,50 @@ class ASTStmtReader : public StmtVisitor { friend class OMPClauseReader; - typedef ASTReader::RecordData RecordData; - - ASTReader &Reader; - ModuleFile &F; + + ASTRecordReader Record; llvm::BitstreamCursor &DeclsCursor; - const ASTReader::RecordData &Record; unsigned &Idx; - Token ReadToken(const RecordData &R, unsigned &I) { - return Reader.ReadToken(F, R, I); + SourceLocation ReadSourceLocation() { + return Record.ReadSourceLocation(Idx); } - SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) { - return Reader.ReadSourceLocation(F, R, I); + SourceRange ReadSourceRange() { + return Record.ReadSourceRange(Idx); } - SourceRange ReadSourceRange(const RecordData &R, unsigned &I) { - return Reader.ReadSourceRange(F, R, I); + std::string ReadString() { + return Record.ReadString(Idx); } - std::string ReadString(const RecordData &R, unsigned &I) { - return Reader.ReadString(R, I); - } - - TypeSourceInfo *GetTypeSourceInfo(const RecordData &R, unsigned &I) { - return Reader.GetTypeSourceInfo(F, R, I); - } - - serialization::DeclID ReadDeclID(const RecordData &R, unsigned &I) { - return Reader.ReadDeclID(F, R, I); + TypeSourceInfo *GetTypeSourceInfo() { + return Record.GetTypeSourceInfo(Idx); } - - Decl *ReadDecl(const RecordData &R, unsigned &I) { - return Reader.ReadDecl(F, R, I); + + Decl *ReadDecl() { + return Record.ReadDecl(Idx); } - + template - T *ReadDeclAs(const RecordData &R, unsigned &I) { - return Reader.ReadDeclAs(F, R, I); + T *ReadDeclAs() { + return Record.ReadDeclAs(Idx); } - void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name, - const ASTReader::RecordData &R, unsigned &I) { - Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I); + void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, + DeclarationName Name) { + Record.ReadDeclarationNameLoc(DNLoc, Name, Idx); } - - void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo, - const ASTReader::RecordData &R, unsigned &I) { - Reader.ReadDeclarationNameInfo(F, NameInfo, R, I); + + void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo) { + Record.ReadDeclarationNameInfo(NameInfo, Idx); } public: ASTStmtReader(ASTReader &Reader, ModuleFile &F, llvm::BitstreamCursor &Cursor, const ASTReader::RecordData &Record, unsigned &Idx) - : Reader(Reader), F(F), DeclsCursor(Cursor), Record(Record), Idx(Idx) { } + : Record(Reader, Record, F), DeclsCursor(Cursor), Idx(Idx) { } /// \brief The number of record fields required for the Stmt class /// itself. @@ -109,13 +97,12 @@ void ASTStmtReader::ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args, TemplateArgumentLoc *ArgsLocArray, unsigned NumTemplateArgs) { - SourceLocation TemplateKWLoc = ReadSourceLocation(Record, Idx); + SourceLocation TemplateKWLoc = ReadSourceLocation(); TemplateArgumentListInfo ArgInfo; - ArgInfo.setLAngleLoc(ReadSourceLocation(Record, Idx)); - ArgInfo.setRAngleLoc(ReadSourceLocation(Record, Idx)); + ArgInfo.setLAngleLoc(ReadSourceLocation()); + ArgInfo.setRAngleLoc(ReadSourceLocation()); for (unsigned i = 0; i != NumTemplateArgs; ++i) - ArgInfo.addArgument( - Reader.ReadTemplateArgumentLoc(F, Record, Idx)); + ArgInfo.addArgument(Record.ReadTemplateArgumentLoc(Idx)); Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray); } @@ -125,7 +112,7 @@ void ASTStmtReader::VisitNullStmt(NullStmt *S) { VisitStmt(S); - S->setSemiLoc(ReadSourceLocation(Record, Idx)); + S->setSemiLoc(ReadSourceLocation()); S->HasLeadingEmptyMacro = Record[Idx++]; } @@ -134,81 +121,79 @@ SmallVector Stmts; unsigned NumStmts = Record[Idx++]; while (NumStmts--) - Stmts.push_back(Reader.ReadSubStmt()); - S->setStmts(Reader.getContext(), Stmts); - S->LBraceLoc = ReadSourceLocation(Record, Idx); - S->RBraceLoc = ReadSourceLocation(Record, Idx); + Stmts.push_back(Record.ReadSubStmt()); + S->setStmts(Record.getContext(), Stmts); + S->LBraceLoc = ReadSourceLocation(); + S->RBraceLoc = ReadSourceLocation(); } void ASTStmtReader::VisitSwitchCase(SwitchCase *S) { VisitStmt(S); - Reader.RecordSwitchCaseID(S, Record[Idx++]); - S->setKeywordLoc(ReadSourceLocation(Record, Idx)); - S->setColonLoc(ReadSourceLocation(Record, Idx)); + Record.RecordSwitchCaseID(S, Record[Idx++]); + S->setKeywordLoc(ReadSourceLocation()); + S->setColonLoc(ReadSourceLocation()); } void ASTStmtReader::VisitCaseStmt(CaseStmt *S) { VisitSwitchCase(S); - S->setLHS(Reader.ReadSubExpr()); - S->setRHS(Reader.ReadSubExpr()); - S->setSubStmt(Reader.ReadSubStmt()); - S->setEllipsisLoc(ReadSourceLocation(Record, Idx)); + S->setLHS(Record.ReadSubExpr()); + S->setRHS(Record.ReadSubExpr()); + S->setSubStmt(Record.ReadSubStmt()); + S->setEllipsisLoc(ReadSourceLocation()); } void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) { VisitSwitchCase(S); - S->setSubStmt(Reader.ReadSubStmt()); + S->setSubStmt(Record.ReadSubStmt()); } void ASTStmtReader::VisitLabelStmt(LabelStmt *S) { VisitStmt(S); - LabelDecl *LD = ReadDeclAs(Record, Idx); + LabelDecl *LD = ReadDeclAs(); LD->setStmt(S); S->setDecl(LD); - S->setSubStmt(Reader.ReadSubStmt()); - S->setIdentLoc(ReadSourceLocation(Record, Idx)); + S->setSubStmt(Record.ReadSubStmt()); + S->setIdentLoc(ReadSourceLocation()); } void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) { VisitStmt(S); uint64_t NumAttrs = Record[Idx++]; AttrVec Attrs; - Reader.ReadAttributes(F, Attrs, Record, Idx); + Record.ReadAttributes(Attrs, Idx); (void)NumAttrs; assert(NumAttrs == S->NumAttrs); assert(NumAttrs == Attrs.size()); std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr()); - S->SubStmt = Reader.ReadSubStmt(); - S->AttrLoc = ReadSourceLocation(Record, Idx); + S->SubStmt = Record.ReadSubStmt(); + S->AttrLoc = ReadSourceLocation(); } void ASTStmtReader::VisitIfStmt(IfStmt *S) { VisitStmt(S); S->setConstexpr(Record[Idx++]); - S->setInit(Reader.ReadSubStmt()); - S->setConditionVariable(Reader.getContext(), - ReadDeclAs(Record, Idx)); - S->setCond(Reader.ReadSubExpr()); - S->setThen(Reader.ReadSubStmt()); - S->setElse(Reader.ReadSubStmt()); - S->setIfLoc(ReadSourceLocation(Record, Idx)); - S->setElseLoc(ReadSourceLocation(Record, Idx)); + S->setInit(Record.ReadSubStmt()); + S->setConditionVariable(Record.getContext(), ReadDeclAs()); + S->setCond(Record.ReadSubExpr()); + S->setThen(Record.ReadSubStmt()); + S->setElse(Record.ReadSubStmt()); + S->setIfLoc(ReadSourceLocation()); + S->setElseLoc(ReadSourceLocation()); } void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) { VisitStmt(S); - S->setInit(Reader.ReadSubStmt()); - S->setConditionVariable(Reader.getContext(), - ReadDeclAs(Record, Idx)); - S->setCond(Reader.ReadSubExpr()); - S->setBody(Reader.ReadSubStmt()); - S->setSwitchLoc(ReadSourceLocation(Record, Idx)); + S->setInit(Record.ReadSubStmt()); + S->setConditionVariable(Record.getContext(), ReadDeclAs()); + S->setCond(Record.ReadSubExpr()); + S->setBody(Record.ReadSubStmt()); + S->setSwitchLoc(ReadSourceLocation()); if (Record[Idx++]) S->setAllEnumCasesCovered(); SwitchCase *PrevSC = nullptr; for (unsigned N = Record.size(); Idx != N; ++Idx) { - SwitchCase *SC = Reader.getSwitchCaseWithID(Record[Idx]); + SwitchCase *SC = Record.getSwitchCaseWithID(Record[Idx]); if (PrevSC) PrevSC->setNextSwitchCase(SC); else @@ -220,81 +205,79 @@ void ASTStmtReader::VisitWhileStmt(WhileStmt *S) { VisitStmt(S); - S->setConditionVariable(Reader.getContext(), - ReadDeclAs(Record, Idx)); + S->setConditionVariable(Record.getContext(), ReadDeclAs()); - S->setCond(Reader.ReadSubExpr()); - S->setBody(Reader.ReadSubStmt()); - S->setWhileLoc(ReadSourceLocation(Record, Idx)); + S->setCond(Record.ReadSubExpr()); + S->setBody(Record.ReadSubStmt()); + S->setWhileLoc(ReadSourceLocation()); } void ASTStmtReader::VisitDoStmt(DoStmt *S) { VisitStmt(S); - S->setCond(Reader.ReadSubExpr()); - S->setBody(Reader.ReadSubStmt()); - S->setDoLoc(ReadSourceLocation(Record, Idx)); - S->setWhileLoc(ReadSourceLocation(Record, Idx)); - S->setRParenLoc(ReadSourceLocation(Record, Idx)); + S->setCond(Record.ReadSubExpr()); + S->setBody(Record.ReadSubStmt()); + S->setDoLoc(ReadSourceLocation()); + S->setWhileLoc(ReadSourceLocation()); + S->setRParenLoc(ReadSourceLocation()); } void ASTStmtReader::VisitForStmt(ForStmt *S) { VisitStmt(S); - S->setInit(Reader.ReadSubStmt()); - S->setCond(Reader.ReadSubExpr()); - S->setConditionVariable(Reader.getContext(), - ReadDeclAs(Record, Idx)); - S->setInc(Reader.ReadSubExpr()); - S->setBody(Reader.ReadSubStmt()); - S->setForLoc(ReadSourceLocation(Record, Idx)); - S->setLParenLoc(ReadSourceLocation(Record, Idx)); - S->setRParenLoc(ReadSourceLocation(Record, Idx)); + S->setInit(Record.ReadSubStmt()); + S->setCond(Record.ReadSubExpr()); + S->setConditionVariable(Record.getContext(), ReadDeclAs()); + S->setInc(Record.ReadSubExpr()); + S->setBody(Record.ReadSubStmt()); + S->setForLoc(ReadSourceLocation()); + S->setLParenLoc(ReadSourceLocation()); + S->setRParenLoc(ReadSourceLocation()); } void ASTStmtReader::VisitGotoStmt(GotoStmt *S) { VisitStmt(S); - S->setLabel(ReadDeclAs(Record, Idx)); - S->setGotoLoc(ReadSourceLocation(Record, Idx)); - S->setLabelLoc(ReadSourceLocation(Record, Idx)); + S->setLabel(ReadDeclAs()); + S->setGotoLoc(ReadSourceLocation()); + S->setLabelLoc(ReadSourceLocation()); } void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) { VisitStmt(S); - S->setGotoLoc(ReadSourceLocation(Record, Idx)); - S->setStarLoc(ReadSourceLocation(Record, Idx)); - S->setTarget(Reader.ReadSubExpr()); + S->setGotoLoc(ReadSourceLocation()); + S->setStarLoc(ReadSourceLocation()); + S->setTarget(Record.ReadSubExpr()); } void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) { VisitStmt(S); - S->setContinueLoc(ReadSourceLocation(Record, Idx)); + S->setContinueLoc(ReadSourceLocation()); } void ASTStmtReader::VisitBreakStmt(BreakStmt *S) { VisitStmt(S); - S->setBreakLoc(ReadSourceLocation(Record, Idx)); + S->setBreakLoc(ReadSourceLocation()); } void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) { VisitStmt(S); - S->setRetValue(Reader.ReadSubExpr()); - S->setReturnLoc(ReadSourceLocation(Record, Idx)); - S->setNRVOCandidate(ReadDeclAs(Record, Idx)); + S->setRetValue(Record.ReadSubExpr()); + S->setReturnLoc(ReadSourceLocation()); + S->setNRVOCandidate(ReadDeclAs()); } void ASTStmtReader::VisitDeclStmt(DeclStmt *S) { VisitStmt(S); - S->setStartLoc(ReadSourceLocation(Record, Idx)); - S->setEndLoc(ReadSourceLocation(Record, Idx)); + S->setStartLoc(ReadSourceLocation()); + S->setEndLoc(ReadSourceLocation()); if (Idx + 1 == Record.size()) { // Single declaration - S->setDeclGroup(DeclGroupRef(ReadDecl(Record, Idx))); + S->setDeclGroup(DeclGroupRef(ReadDecl())); } else { SmallVector Decls; - Decls.reserve(Record.size() - Idx); + Decls.reserve(Record.size() - Idx); for (unsigned N = Record.size(); Idx != N; ) - Decls.push_back(ReadDecl(Record, Idx)); - S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Reader.getContext(), + Decls.push_back(ReadDecl()); + S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(), Decls.data(), Decls.size()))); } @@ -305,15 +288,15 @@ S->NumOutputs = Record[Idx++]; S->NumInputs = Record[Idx++]; S->NumClobbers = Record[Idx++]; - S->setAsmLoc(ReadSourceLocation(Record, Idx)); + S->setAsmLoc(ReadSourceLocation()); S->setVolatile(Record[Idx++]); S->setSimple(Record[Idx++]); } void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) { VisitAsmStmt(S); - S->setRParenLoc(ReadSourceLocation(Record, Idx)); - S->setAsmString(cast_or_null(Reader.ReadSubStmt())); + S->setRParenLoc(ReadSourceLocation()); + S->setAsmString(cast_or_null(Record.ReadSubStmt())); unsigned NumOutputs = S->getNumOutputs(); unsigned NumInputs = S->getNumInputs(); @@ -324,17 +307,17 @@ SmallVector Constraints; SmallVector Exprs; for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) { - Names.push_back(Reader.GetIdentifierInfo(F, Record, Idx)); - Constraints.push_back(cast_or_null(Reader.ReadSubStmt())); - Exprs.push_back(Reader.ReadSubStmt()); + Names.push_back(Record.GetIdentifierInfo(Idx)); + Constraints.push_back(cast_or_null(Record.ReadSubStmt())); + Exprs.push_back(Record.ReadSubStmt()); } // Constraints SmallVector Clobbers; for (unsigned I = 0; I != NumClobbers; ++I) - Clobbers.push_back(cast_or_null(Reader.ReadSubStmt())); + Clobbers.push_back(cast_or_null(Record.ReadSubStmt())); - S->setOutputsAndInputsAndClobbers(Reader.getContext(), + S->setOutputsAndInputsAndClobbers(Record.getContext(), Names.data(), Constraints.data(), Exprs.data(), NumOutputs, NumInputs, Clobbers.data(), NumClobbers); @@ -342,16 +325,16 @@ void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) { VisitAsmStmt(S); - S->LBraceLoc = ReadSourceLocation(Record, Idx); - S->EndLoc = ReadSourceLocation(Record, Idx); + S->LBraceLoc = ReadSourceLocation(); + S->EndLoc = ReadSourceLocation(); S->NumAsmToks = Record[Idx++]; - std::string AsmStr = ReadString(Record, Idx); + 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(ReadToken(Record, Idx)); + AsmToks.push_back(Record.ReadToken(Idx)); } // The calls to reserve() for the FooData vectors are mandatory to @@ -363,7 +346,7 @@ ClobbersData.reserve(S->NumClobbers); Clobbers.reserve(S->NumClobbers); for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) { - ClobbersData.push_back(ReadString(Record, Idx)); + ClobbersData.push_back(ReadString()); Clobbers.push_back(ClobbersData.back()); } @@ -376,12 +359,12 @@ ConstraintsData.reserve(NumOperands); Constraints.reserve(NumOperands); for (unsigned i = 0; i != NumOperands; ++i) { - Exprs.push_back(cast(Reader.ReadSubStmt())); - ConstraintsData.push_back(ReadString(Record, Idx)); + Exprs.push_back(cast(Record.ReadSubStmt())); + ConstraintsData.push_back(ReadString()); Constraints.push_back(ConstraintsData.back()); } - S->initialize(Reader.getContext(), AsmStr, AsmToks, + S->initialize(Record.getContext(), AsmStr, AsmToks, Constraints, Exprs, Clobbers); } @@ -408,32 +391,32 @@ void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) { VisitStmt(S); ++Idx; - S->setCapturedDecl(ReadDeclAs(Record, Idx)); + S->setCapturedDecl(ReadDeclAs()); S->setCapturedRegionKind(static_cast(Record[Idx++])); - S->setCapturedRecordDecl(ReadDeclAs(Record, Idx)); + S->setCapturedRecordDecl(ReadDeclAs()); // Capture inits for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(), E = S->capture_init_end(); I != E; ++I) - *I = Reader.ReadSubExpr(); + *I = Record.ReadSubExpr(); // Body - S->setCapturedStmt(Reader.ReadSubStmt()); + S->setCapturedStmt(Record.ReadSubStmt()); S->getCapturedDecl()->setBody(S->getCapturedStmt()); // Captures for (auto &I : S->captures()) { - I.VarAndKind.setPointer(ReadDeclAs(Record, Idx)); + I.VarAndKind.setPointer(ReadDeclAs()); I.VarAndKind .setInt(static_cast(Record[Idx++])); - I.Loc = ReadSourceLocation(Record, Idx); + I.Loc = ReadSourceLocation(); } } void ASTStmtReader::VisitExpr(Expr *E) { VisitStmt(E); - E->setType(Reader.readType(F, Record, Idx)); + E->setType(Record.readType(Idx)); E->setTypeDependent(Record[Idx++]); E->setValueDependent(Record[Idx++]); E->setInstantiationDependent(Record[Idx++]); @@ -445,9 +428,9 @@ void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) { VisitExpr(E); - E->setLocation(ReadSourceLocation(Record, Idx)); + E->setLocation(ReadSourceLocation()); E->Type = (PredefinedExpr::IdentType)Record[Idx++]; - E->FnName = cast_or_null(Reader.ReadSubExpr()); + E->FnName = cast_or_null(Record.ReadSubExpr()); } void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) { @@ -464,40 +447,38 @@ if (E->hasQualifier()) new (E->getTrailingObjects()) - NestedNameSpecifierLoc( - Reader.ReadNestedNameSpecifierLoc(F, Record, Idx)); + NestedNameSpecifierLoc(Record.ReadNestedNameSpecifierLoc(Idx)); if (E->hasFoundDecl()) - *E->getTrailingObjects() = ReadDeclAs(Record, Idx); + *E->getTrailingObjects() = ReadDeclAs(); if (E->hasTemplateKWAndArgsInfo()) ReadTemplateKWAndArgsInfo( *E->getTrailingObjects(), E->getTrailingObjects(), NumTemplateArgs); - E->setDecl(ReadDeclAs(Record, Idx)); - E->setLocation(ReadSourceLocation(Record, Idx)); - ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record, Idx); + E->setDecl(ReadDeclAs()); + E->setLocation(ReadSourceLocation()); + ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName()); } void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) { VisitExpr(E); - E->setLocation(ReadSourceLocation(Record, Idx)); - E->setValue(Reader.getContext(), Reader.ReadAPInt(Record, Idx)); + E->setLocation(ReadSourceLocation()); + E->setValue(Record.getContext(), Record.ReadAPInt(Idx)); } void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) { VisitExpr(E); E->setRawSemantics(static_cast(Record[Idx++])); E->setExact(Record[Idx++]); - E->setValue(Reader.getContext(), - Reader.ReadAPFloat(Record, E->getSemantics(), Idx)); - E->setLocation(ReadSourceLocation(Record, Idx)); + E->setValue(Record.getContext(), Record.ReadAPFloat(E->getSemantics(), Idx)); + E->setLocation(ReadSourceLocation()); } void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) { VisitExpr(E); - E->setSubExpr(Reader.ReadSubExpr()); + E->setSubExpr(Record.ReadSubExpr()); } void ASTStmtReader::VisitStringLiteral(StringLiteral *E) { @@ -512,44 +493,44 @@ // Read string data SmallString<16> Str(&Record[Idx], &Record[Idx] + Len); - E->setString(Reader.getContext(), Str, kind, isPascal); + E->setString(Record.getContext(), Str, kind, isPascal); Idx += Len; // Read source locations for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I) - E->setStrTokenLoc(I, ReadSourceLocation(Record, Idx)); + E->setStrTokenLoc(I, ReadSourceLocation()); } void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) { VisitExpr(E); E->setValue(Record[Idx++]); - E->setLocation(ReadSourceLocation(Record, Idx)); + E->setLocation(ReadSourceLocation()); E->setKind(static_cast(Record[Idx++])); } void ASTStmtReader::VisitParenExpr(ParenExpr *E) { VisitExpr(E); - E->setLParen(ReadSourceLocation(Record, Idx)); - E->setRParen(ReadSourceLocation(Record, Idx)); - E->setSubExpr(Reader.ReadSubExpr()); + E->setLParen(ReadSourceLocation()); + E->setRParen(ReadSourceLocation()); + E->setSubExpr(Record.ReadSubExpr()); } void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) { VisitExpr(E); unsigned NumExprs = Record[Idx++]; - E->Exprs = new (Reader.getContext()) Stmt*[NumExprs]; + E->Exprs = new (Record.getContext()) Stmt*[NumExprs]; for (unsigned i = 0; i != NumExprs; ++i) - E->Exprs[i] = Reader.ReadSubStmt(); + E->Exprs[i] = Record.ReadSubStmt(); E->NumExprs = NumExprs; - E->LParenLoc = ReadSourceLocation(Record, Idx); - E->RParenLoc = ReadSourceLocation(Record, Idx); + E->LParenLoc = ReadSourceLocation(); + E->RParenLoc = ReadSourceLocation(); } void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) { VisitExpr(E); - E->setSubExpr(Reader.ReadSubExpr()); + E->setSubExpr(Record.ReadSubExpr()); E->setOpcode((UnaryOperator::Opcode)Record[Idx++]); - E->setOperatorLoc(ReadSourceLocation(Record, Idx)); + E->setOperatorLoc(ReadSourceLocation()); } void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) { @@ -558,13 +539,13 @@ ++Idx; assert(E->getNumExpressions() == Record[Idx]); ++Idx; - E->setOperatorLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); - E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx)); + 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++]); - SourceLocation Start = ReadSourceLocation(Record, Idx); - SourceLocation End = ReadSourceLocation(Record, Idx); + SourceLocation Start = ReadSourceLocation(); + SourceLocation End = ReadSourceLocation(); switch (Kind) { case OffsetOfNode::Array: E->setComponent(I, OffsetOfNode(Start, Record[Idx++], End)); @@ -572,18 +553,18 @@ case OffsetOfNode::Field: E->setComponent( - I, OffsetOfNode(Start, ReadDeclAs(Record, Idx), End)); + I, OffsetOfNode(Start, ReadDeclAs(), End)); break; case OffsetOfNode::Identifier: E->setComponent( I, - OffsetOfNode(Start, Reader.GetIdentifierInfo(F, Record, Idx), End)); + OffsetOfNode(Start, Record.GetIdentifierInfo(Idx), End)); break; case OffsetOfNode::Base: { - CXXBaseSpecifier *Base = new (Reader.getContext()) CXXBaseSpecifier(); - *Base = Reader.ReadCXXBaseSpecifier(F, Record, Idx); + CXXBaseSpecifier *Base = new (Record.getContext()) CXXBaseSpecifier(); + *Base = Record.ReadCXXBaseSpecifier(Idx); E->setComponent(I, OffsetOfNode(Base)); break; } @@ -591,45 +572,45 @@ } for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I) - E->setIndexExpr(I, Reader.ReadSubExpr()); + E->setIndexExpr(I, Record.ReadSubExpr()); } void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) { VisitExpr(E); E->setKind(static_cast(Record[Idx++])); if (Record[Idx] == 0) { - E->setArgument(Reader.ReadSubExpr()); + E->setArgument(Record.ReadSubExpr()); ++Idx; } else { - E->setArgument(GetTypeSourceInfo(Record, Idx)); + E->setArgument(GetTypeSourceInfo()); } - E->setOperatorLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); + E->setOperatorLoc(ReadSourceLocation()); + E->setRParenLoc(ReadSourceLocation()); } void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) { VisitExpr(E); - E->setLHS(Reader.ReadSubExpr()); - E->setRHS(Reader.ReadSubExpr()); - E->setRBracketLoc(ReadSourceLocation(Record, Idx)); + E->setLHS(Record.ReadSubExpr()); + E->setRHS(Record.ReadSubExpr()); + E->setRBracketLoc(ReadSourceLocation()); } void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) { VisitExpr(E); - E->setBase(Reader.ReadSubExpr()); - E->setLowerBound(Reader.ReadSubExpr()); - E->setLength(Reader.ReadSubExpr()); - E->setColonLoc(ReadSourceLocation(Record, Idx)); - E->setRBracketLoc(ReadSourceLocation(Record, Idx)); + E->setBase(Record.ReadSubExpr()); + E->setLowerBound(Record.ReadSubExpr()); + E->setLength(Record.ReadSubExpr()); + E->setColonLoc(ReadSourceLocation()); + E->setRBracketLoc(ReadSourceLocation()); } void ASTStmtReader::VisitCallExpr(CallExpr *E) { VisitExpr(E); - E->setNumArgs(Reader.getContext(), Record[Idx++]); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); - E->setCallee(Reader.ReadSubExpr()); + E->setNumArgs(Record.getContext(), Record[Idx++]); + E->setRParenLoc(ReadSourceLocation()); + E->setCallee(Record.ReadSubExpr()); for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) - E->setArg(I, Reader.ReadSubExpr()); + E->setArg(I, Record.ReadSubExpr()); } void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) { @@ -644,23 +625,23 @@ void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) { VisitExpr(E); - E->setBase(Reader.ReadSubExpr()); - E->setIsaMemberLoc(ReadSourceLocation(Record, Idx)); - E->setOpLoc(ReadSourceLocation(Record, Idx)); + E->setBase(Record.ReadSubExpr()); + E->setIsaMemberLoc(ReadSourceLocation()); + E->setOpLoc(ReadSourceLocation()); E->setArrow(Record[Idx++]); } void ASTStmtReader:: VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) { VisitExpr(E); - E->Operand = Reader.ReadSubExpr(); + E->Operand = Record.ReadSubExpr(); E->setShouldCopy(Record[Idx++]); } void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) { VisitExplicitCastExpr(E); - E->LParenLoc = ReadSourceLocation(Record, Idx); - E->BridgeKeywordLoc = ReadSourceLocation(Record, Idx); + E->LParenLoc = ReadSourceLocation(); + E->BridgeKeywordLoc = ReadSourceLocation(); E->Kind = Record[Idx++]; } @@ -668,50 +649,50 @@ VisitExpr(E); unsigned NumBaseSpecs = Record[Idx++]; assert(NumBaseSpecs == E->path_size()); - E->setSubExpr(Reader.ReadSubExpr()); + E->setSubExpr(Record.ReadSubExpr()); E->setCastKind((CastKind)Record[Idx++]); CastExpr::path_iterator BaseI = E->path_begin(); while (NumBaseSpecs--) { - CXXBaseSpecifier *BaseSpec = new (Reader.getContext()) CXXBaseSpecifier; - *BaseSpec = Reader.ReadCXXBaseSpecifier(F, Record, Idx); + CXXBaseSpecifier *BaseSpec = new (Record.getContext()) CXXBaseSpecifier; + *BaseSpec = Record.ReadCXXBaseSpecifier(Idx); *BaseI++ = BaseSpec; } } void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) { VisitExpr(E); - E->setLHS(Reader.ReadSubExpr()); - E->setRHS(Reader.ReadSubExpr()); + E->setLHS(Record.ReadSubExpr()); + E->setRHS(Record.ReadSubExpr()); E->setOpcode((BinaryOperator::Opcode)Record[Idx++]); - E->setOperatorLoc(ReadSourceLocation(Record, Idx)); + E->setOperatorLoc(ReadSourceLocation()); E->setFPContractable((bool)Record[Idx++]); } void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) { VisitBinaryOperator(E); - E->setComputationLHSType(Reader.readType(F, Record, Idx)); - E->setComputationResultType(Reader.readType(F, Record, Idx)); + E->setComputationLHSType(Record.readType(Idx)); + E->setComputationResultType(Record.readType(Idx)); } void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) { VisitExpr(E); - E->SubExprs[ConditionalOperator::COND] = Reader.ReadSubExpr(); - E->SubExprs[ConditionalOperator::LHS] = Reader.ReadSubExpr(); - E->SubExprs[ConditionalOperator::RHS] = Reader.ReadSubExpr(); - E->QuestionLoc = ReadSourceLocation(Record, Idx); - E->ColonLoc = ReadSourceLocation(Record, Idx); + E->SubExprs[ConditionalOperator::COND] = Record.ReadSubExpr(); + E->SubExprs[ConditionalOperator::LHS] = Record.ReadSubExpr(); + E->SubExprs[ConditionalOperator::RHS] = Record.ReadSubExpr(); + E->QuestionLoc = ReadSourceLocation(); + E->ColonLoc = ReadSourceLocation(); } void ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) { VisitExpr(E); - E->OpaqueValue = cast(Reader.ReadSubExpr()); - E->SubExprs[BinaryConditionalOperator::COMMON] = Reader.ReadSubExpr(); - E->SubExprs[BinaryConditionalOperator::COND] = Reader.ReadSubExpr(); - E->SubExprs[BinaryConditionalOperator::LHS] = Reader.ReadSubExpr(); - E->SubExprs[BinaryConditionalOperator::RHS] = Reader.ReadSubExpr(); - E->QuestionLoc = ReadSourceLocation(Record, Idx); - E->ColonLoc = ReadSourceLocation(Record, Idx); + E->OpaqueValue = cast(Record.ReadSubExpr()); + E->SubExprs[BinaryConditionalOperator::COMMON] = Record.ReadSubExpr(); + E->SubExprs[BinaryConditionalOperator::COND] = Record.ReadSubExpr(); + E->SubExprs[BinaryConditionalOperator::LHS] = Record.ReadSubExpr(); + E->SubExprs[BinaryConditionalOperator::RHS] = Record.ReadSubExpr(); + E->QuestionLoc = ReadSourceLocation(); + E->ColonLoc = ReadSourceLocation(); } void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) { @@ -720,54 +701,54 @@ void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) { VisitCastExpr(E); - E->setTypeInfoAsWritten(GetTypeSourceInfo(Record, Idx)); + E->setTypeInfoAsWritten(GetTypeSourceInfo()); } void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) { VisitExplicitCastExpr(E); - E->setLParenLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); + E->setLParenLoc(ReadSourceLocation()); + E->setRParenLoc(ReadSourceLocation()); } void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) { VisitExpr(E); - E->setLParenLoc(ReadSourceLocation(Record, Idx)); - E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx)); - E->setInitializer(Reader.ReadSubExpr()); + E->setLParenLoc(ReadSourceLocation()); + E->setTypeSourceInfo(GetTypeSourceInfo()); + E->setInitializer(Record.ReadSubExpr()); E->setFileScope(Record[Idx++]); } void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) { VisitExpr(E); - E->setBase(Reader.ReadSubExpr()); - E->setAccessor(Reader.GetIdentifierInfo(F, Record, Idx)); - E->setAccessorLoc(ReadSourceLocation(Record, Idx)); + E->setBase(Record.ReadSubExpr()); + E->setAccessor(Record.GetIdentifierInfo(Idx)); + E->setAccessorLoc(ReadSourceLocation()); } void ASTStmtReader::VisitInitListExpr(InitListExpr *E) { VisitExpr(E); - if (InitListExpr *SyntForm = cast_or_null(Reader.ReadSubStmt())) + if (InitListExpr *SyntForm = cast_or_null(Record.ReadSubStmt())) E->setSyntacticForm(SyntForm); - E->setLBraceLoc(ReadSourceLocation(Record, Idx)); - E->setRBraceLoc(ReadSourceLocation(Record, Idx)); + E->setLBraceLoc(ReadSourceLocation()); + E->setRBraceLoc(ReadSourceLocation()); bool isArrayFiller = Record[Idx++]; Expr *filler = nullptr; if (isArrayFiller) { - filler = Reader.ReadSubExpr(); + filler = Record.ReadSubExpr(); E->ArrayFillerOrUnionFieldInit = filler; } else - E->ArrayFillerOrUnionFieldInit = ReadDeclAs(Record, Idx); + E->ArrayFillerOrUnionFieldInit = ReadDeclAs(); E->sawArrayRangeDesignator(Record[Idx++]); unsigned NumInits = Record[Idx++]; - E->reserveInits(Reader.getContext(), NumInits); + E->reserveInits(Record.getContext(), NumInits); if (isArrayFiller) { for (unsigned I = 0; I != NumInits; ++I) { - Expr *init = Reader.ReadSubExpr(); - E->updateInit(Reader.getContext(), I, init ? init : filler); + Expr *init = Record.ReadSubExpr(); + E->updateInit(Record.getContext(), I, init ? init : filler); } } else { for (unsigned I = 0; I != NumInits; ++I) - E->updateInit(Reader.getContext(), I, Reader.ReadSubExpr()); + E->updateInit(Record.getContext(), I, Record.ReadSubExpr()); } } @@ -778,19 +759,19 @@ unsigned NumSubExprs = Record[Idx++]; assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs"); for (unsigned I = 0; I != NumSubExprs; ++I) - E->setSubExpr(I, Reader.ReadSubExpr()); - E->setEqualOrColonLoc(ReadSourceLocation(Record, Idx)); + E->setSubExpr(I, Record.ReadSubExpr()); + E->setEqualOrColonLoc(ReadSourceLocation()); E->setGNUSyntax(Record[Idx++]); SmallVector Designators; while (Idx < Record.size()) { switch ((DesignatorTypes)Record[Idx++]) { case DESIG_FIELD_DECL: { - FieldDecl *Field = ReadDeclAs(Record, Idx); + FieldDecl *Field = ReadDeclAs(); SourceLocation DotLoc - = ReadSourceLocation(Record, Idx); + = ReadSourceLocation(); SourceLocation FieldLoc - = ReadSourceLocation(Record, Idx); + = ReadSourceLocation(); Designators.push_back(Designator(Field->getIdentifier(), DotLoc, FieldLoc)); Designators.back().setField(Field); @@ -798,11 +779,11 @@ } case DESIG_FIELD_NAME: { - const IdentifierInfo *Name = Reader.GetIdentifierInfo(F, Record, Idx); + const IdentifierInfo *Name = Record.GetIdentifierInfo(Idx); SourceLocation DotLoc - = ReadSourceLocation(Record, Idx); + = ReadSourceLocation(); SourceLocation FieldLoc - = ReadSourceLocation(Record, Idx); + = ReadSourceLocation(); Designators.push_back(Designator(Name, DotLoc, FieldLoc)); break; } @@ -810,9 +791,9 @@ case DESIG_ARRAY: { unsigned Index = Record[Idx++]; SourceLocation LBracketLoc - = ReadSourceLocation(Record, Idx); + = ReadSourceLocation(); SourceLocation RBracketLoc - = ReadSourceLocation(Record, Idx); + = ReadSourceLocation(); Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc)); break; } @@ -820,25 +801,25 @@ case DESIG_ARRAY_RANGE: { unsigned Index = Record[Idx++]; SourceLocation LBracketLoc - = ReadSourceLocation(Record, Idx); + = ReadSourceLocation(); SourceLocation EllipsisLoc - = ReadSourceLocation(Record, Idx); + = ReadSourceLocation(); SourceLocation RBracketLoc - = ReadSourceLocation(Record, Idx); + = ReadSourceLocation(); Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc, RBracketLoc)); break; } } } - E->setDesignators(Reader.getContext(), + E->setDesignators(Record.getContext(), Designators.data(), Designators.size()); } void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) { VisitExpr(E); - E->setBase(Reader.ReadSubExpr()); - E->setUpdater(Reader.ReadSubExpr()); + E->setBase(Record.ReadSubExpr()); + E->setUpdater(Record.ReadSubExpr()); } void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) { @@ -847,8 +828,8 @@ void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) { VisitExpr(E); - E->SubExprs[0] = Reader.ReadSubExpr(); - E->SubExprs[1] = Reader.ReadSubExpr(); + E->SubExprs[0] = Record.ReadSubExpr(); + E->SubExprs[1] = Record.ReadSubExpr(); } void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) { @@ -861,40 +842,40 @@ void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) { VisitExpr(E); - E->setSubExpr(Reader.ReadSubExpr()); - E->setWrittenTypeInfo(GetTypeSourceInfo(Record, Idx)); - E->setBuiltinLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); + E->setSubExpr(Record.ReadSubExpr()); + E->setWrittenTypeInfo(GetTypeSourceInfo()); + E->setBuiltinLoc(ReadSourceLocation()); + E->setRParenLoc(ReadSourceLocation()); E->setIsMicrosoftABI(Record[Idx++]); } void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) { VisitExpr(E); - E->setAmpAmpLoc(ReadSourceLocation(Record, Idx)); - E->setLabelLoc(ReadSourceLocation(Record, Idx)); - E->setLabel(ReadDeclAs(Record, Idx)); + E->setAmpAmpLoc(ReadSourceLocation()); + E->setLabelLoc(ReadSourceLocation()); + E->setLabel(ReadDeclAs()); } void ASTStmtReader::VisitStmtExpr(StmtExpr *E) { VisitExpr(E); - E->setLParenLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); - E->setSubStmt(cast_or_null(Reader.ReadSubStmt())); + E->setLParenLoc(ReadSourceLocation()); + E->setRParenLoc(ReadSourceLocation()); + E->setSubStmt(cast_or_null(Record.ReadSubStmt())); } void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) { VisitExpr(E); - E->setCond(Reader.ReadSubExpr()); - E->setLHS(Reader.ReadSubExpr()); - E->setRHS(Reader.ReadSubExpr()); - E->setBuiltinLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); + E->setCond(Record.ReadSubExpr()); + E->setLHS(Record.ReadSubExpr()); + E->setRHS(Record.ReadSubExpr()); + E->setBuiltinLoc(ReadSourceLocation()); + E->setRParenLoc(ReadSourceLocation()); E->setIsConditionTrue(Record[Idx++]); } void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) { VisitExpr(E); - E->setTokenLocation(ReadSourceLocation(Record, Idx)); + E->setTokenLocation(ReadSourceLocation()); } void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { @@ -902,42 +883,42 @@ SmallVector Exprs; unsigned NumExprs = Record[Idx++]; while (NumExprs--) - Exprs.push_back(Reader.ReadSubExpr()); - E->setExprs(Reader.getContext(), Exprs); - E->setBuiltinLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); + Exprs.push_back(Record.ReadSubExpr()); + E->setExprs(Record.getContext(), Exprs); + E->setBuiltinLoc(ReadSourceLocation()); + E->setRParenLoc(ReadSourceLocation()); } void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) { VisitExpr(E); - E->BuiltinLoc = ReadSourceLocation(Record, Idx); - E->RParenLoc = ReadSourceLocation(Record, Idx); - E->TInfo = GetTypeSourceInfo(Record, Idx); - E->SrcExpr = Reader.ReadSubExpr(); + E->BuiltinLoc = ReadSourceLocation(); + E->RParenLoc = ReadSourceLocation(); + E->TInfo = GetTypeSourceInfo(); + E->SrcExpr = Record.ReadSubExpr(); } void ASTStmtReader::VisitBlockExpr(BlockExpr *E) { VisitExpr(E); - E->setBlockDecl(ReadDeclAs(Record, Idx)); + E->setBlockDecl(ReadDeclAs()); } void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) { VisitExpr(E); E->NumAssocs = Record[Idx++]; - E->AssocTypes = new (Reader.getContext()) TypeSourceInfo*[E->NumAssocs]; + E->AssocTypes = new (Record.getContext()) TypeSourceInfo*[E->NumAssocs]; E->SubExprs = - new(Reader.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs]; + new(Record.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs]; - E->SubExprs[GenericSelectionExpr::CONTROLLING] = Reader.ReadSubExpr(); + E->SubExprs[GenericSelectionExpr::CONTROLLING] = Record.ReadSubExpr(); for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) { - E->AssocTypes[I] = GetTypeSourceInfo(Record, Idx); - E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Reader.ReadSubExpr(); + E->AssocTypes[I] = GetTypeSourceInfo(); + E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Record.ReadSubExpr(); } E->ResultIndex = Record[Idx++]; - E->GenericLoc = ReadSourceLocation(Record, Idx); - E->DefaultLoc = ReadSourceLocation(Record, Idx); - E->RParenLoc = ReadSourceLocation(Record, Idx); + E->GenericLoc = ReadSourceLocation(); + E->DefaultLoc = ReadSourceLocation(); + E->RParenLoc = ReadSourceLocation(); } void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) { @@ -947,11 +928,11 @@ E->PseudoObjectExprBits.ResultIndex = Record[Idx++]; // Read the syntactic expression. - E->getSubExprsBuffer()[0] = Reader.ReadSubExpr(); + E->getSubExprsBuffer()[0] = Record.ReadSubExpr(); // Read all the semantic expressions. for (unsigned i = 0; i != numSemanticExprs; ++i) { - Expr *subExpr = Reader.ReadSubExpr(); + Expr *subExpr = Record.ReadSubExpr(); E->getSubExprsBuffer()[i+1] = subExpr; } } @@ -961,9 +942,9 @@ E->Op = AtomicExpr::AtomicOp(Record[Idx++]); E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op); for (unsigned I = 0; I != E->NumSubExprs; ++I) - E->SubExprs[I] = Reader.ReadSubExpr(); - E->BuiltinLoc = ReadSourceLocation(Record, Idx); - E->RParenLoc = ReadSourceLocation(Record, Idx); + E->SubExprs[I] = Record.ReadSubExpr(); + E->BuiltinLoc = ReadSourceLocation(); + E->RParenLoc = ReadSourceLocation(); } //===----------------------------------------------------------------------===// @@ -971,16 +952,16 @@ void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) { VisitExpr(E); - E->setString(cast(Reader.ReadSubStmt())); - E->setAtLoc(ReadSourceLocation(Record, Idx)); + E->setString(cast(Record.ReadSubStmt())); + E->setAtLoc(ReadSourceLocation()); } void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) { VisitExpr(E); // could be one of several IntegerLiteral, FloatLiteral, etc. - E->SubExpr = Reader.ReadSubStmt(); - E->BoxingMethod = ReadDeclAs(Record, Idx); - E->Range = ReadSourceRange(Record, Idx); + E->SubExpr = Record.ReadSubStmt(); + E->BoxingMethod = ReadDeclAs(); + E->Range = ReadSourceRange(); } void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) { @@ -989,9 +970,9 @@ assert(NumElements == E->getNumElements() && "Wrong number of elements"); Expr **Elements = E->getElements(); for (unsigned I = 0, N = NumElements; I != N; ++I) - Elements[I] = Reader.ReadSubExpr(); - E->ArrayWithObjectsMethod = ReadDeclAs(Record, Idx); - E->Range = ReadSourceRange(Record, Idx); + Elements[I] = Record.ReadSubExpr(); + E->ArrayWithObjectsMethod = ReadDeclAs(); + E->Range = ReadSourceRange(); } void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) { @@ -1005,45 +986,45 @@ ObjCDictionaryLiteral::ExpansionData *Expansions = E->getTrailingObjects(); for (unsigned I = 0; I != NumElements; ++I) { - KeyValues[I].Key = Reader.ReadSubExpr(); - KeyValues[I].Value = Reader.ReadSubExpr(); + KeyValues[I].Key = Record.ReadSubExpr(); + KeyValues[I].Value = Record.ReadSubExpr(); if (HasPackExpansions) { - Expansions[I].EllipsisLoc = ReadSourceLocation(Record, Idx); + Expansions[I].EllipsisLoc = ReadSourceLocation(); Expansions[I].NumExpansionsPlusOne = Record[Idx++]; } } - E->DictWithObjectsMethod = ReadDeclAs(Record, Idx); - E->Range = ReadSourceRange(Record, Idx); + E->DictWithObjectsMethod = ReadDeclAs(); + E->Range = ReadSourceRange(); } void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) { VisitExpr(E); - E->setEncodedTypeSourceInfo(GetTypeSourceInfo(Record, Idx)); - E->setAtLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); + E->setEncodedTypeSourceInfo(GetTypeSourceInfo()); + E->setAtLoc(ReadSourceLocation()); + E->setRParenLoc(ReadSourceLocation()); } void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) { VisitExpr(E); - E->setSelector(Reader.ReadSelector(F, Record, Idx)); - E->setAtLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); + E->setSelector(Record.ReadSelector(Idx)); + E->setAtLoc(ReadSourceLocation()); + E->setRParenLoc(ReadSourceLocation()); } void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) { VisitExpr(E); - E->setProtocol(ReadDeclAs(Record, Idx)); - E->setAtLoc(ReadSourceLocation(Record, Idx)); - E->ProtoLoc = ReadSourceLocation(Record, Idx); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); + E->setProtocol(ReadDeclAs()); + E->setAtLoc(ReadSourceLocation()); + E->ProtoLoc = ReadSourceLocation(); + E->setRParenLoc(ReadSourceLocation()); } void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { VisitExpr(E); - E->setDecl(ReadDeclAs(Record, Idx)); - E->setLocation(ReadSourceLocation(Record, Idx)); - E->setOpLoc(ReadSourceLocation(Record, Idx)); - E->setBase(Reader.ReadSubExpr()); + E->setDecl(ReadDeclAs()); + E->setLocation(ReadSourceLocation()); + E->setOpLoc(ReadSourceLocation()); + E->setBase(Record.ReadSubExpr()); E->setIsArrow(Record[Idx++]); E->setIsFreeIvar(Record[Idx++]); } @@ -1053,35 +1034,34 @@ unsigned MethodRefFlags = Record[Idx++]; bool Implicit = Record[Idx++] != 0; if (Implicit) { - ObjCMethodDecl *Getter = ReadDeclAs(Record, Idx); - ObjCMethodDecl *Setter = ReadDeclAs(Record, Idx); + ObjCMethodDecl *Getter = ReadDeclAs(); + ObjCMethodDecl *Setter = ReadDeclAs(); E->setImplicitProperty(Getter, Setter, MethodRefFlags); } else { - E->setExplicitProperty(ReadDeclAs(Record, Idx), - MethodRefFlags); + E->setExplicitProperty(ReadDeclAs(), MethodRefFlags); } - E->setLocation(ReadSourceLocation(Record, Idx)); - E->setReceiverLocation(ReadSourceLocation(Record, Idx)); + E->setLocation(ReadSourceLocation()); + E->setReceiverLocation(ReadSourceLocation()); switch (Record[Idx++]) { case 0: - E->setBase(Reader.ReadSubExpr()); + E->setBase(Record.ReadSubExpr()); break; case 1: - E->setSuperReceiver(Reader.readType(F, Record, Idx)); + E->setSuperReceiver(Record.readType(Idx)); break; case 2: - E->setClassReceiver(ReadDeclAs(Record, Idx)); + E->setClassReceiver(ReadDeclAs()); break; } } void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) { VisitExpr(E); - E->setRBracket(ReadSourceLocation(Record, Idx)); - E->setBaseExpr(Reader.ReadSubExpr()); - E->setKeyExpr(Reader.ReadSubExpr()); - E->GetAtIndexMethodDecl = ReadDeclAs(Record, Idx); - E->SetAtIndexMethodDecl = ReadDeclAs(Record, Idx); + E->setRBracket(ReadSourceLocation()); + E->setBaseExpr(Record.ReadSubExpr()); + E->setKeyExpr(Record.ReadSubExpr()); + E->GetAtIndexMethodDecl = ReadDeclAs(); + E->SetAtIndexMethodDecl = ReadDeclAs(); } void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) { @@ -1096,17 +1076,17 @@ = static_cast(Record[Idx++]); switch (Kind) { case ObjCMessageExpr::Instance: - E->setInstanceReceiver(Reader.ReadSubExpr()); + E->setInstanceReceiver(Record.ReadSubExpr()); break; case ObjCMessageExpr::Class: - E->setClassReceiver(GetTypeSourceInfo(Record, Idx)); + E->setClassReceiver(GetTypeSourceInfo()); break; case ObjCMessageExpr::SuperClass: case ObjCMessageExpr::SuperInstance: { - QualType T = Reader.readType(F, Record, Idx); - SourceLocation SuperLoc = ReadSourceLocation(Record, Idx); + QualType T = Record.readType(Idx); + SourceLocation SuperLoc = ReadSourceLocation(); E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance); break; } @@ -1115,48 +1095,48 @@ assert(Kind == E->getReceiverKind()); if (Record[Idx++]) - E->setMethodDecl(ReadDeclAs(Record, Idx)); + E->setMethodDecl(ReadDeclAs()); else - E->setSelector(Reader.ReadSelector(F, Record, Idx)); + E->setSelector(Record.ReadSelector(Idx)); - E->LBracLoc = ReadSourceLocation(Record, Idx); - E->RBracLoc = ReadSourceLocation(Record, Idx); + E->LBracLoc = ReadSourceLocation(); + E->RBracLoc = ReadSourceLocation(); for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) - E->setArg(I, Reader.ReadSubExpr()); + E->setArg(I, Record.ReadSubExpr()); SourceLocation *Locs = E->getStoredSelLocs(); for (unsigned I = 0; I != NumStoredSelLocs; ++I) - Locs[I] = ReadSourceLocation(Record, Idx); + Locs[I] = ReadSourceLocation(); } void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) { VisitStmt(S); - S->setElement(Reader.ReadSubStmt()); - S->setCollection(Reader.ReadSubExpr()); - S->setBody(Reader.ReadSubStmt()); - S->setForLoc(ReadSourceLocation(Record, Idx)); - S->setRParenLoc(ReadSourceLocation(Record, Idx)); + S->setElement(Record.ReadSubStmt()); + S->setCollection(Record.ReadSubExpr()); + S->setBody(Record.ReadSubStmt()); + S->setForLoc(ReadSourceLocation()); + S->setRParenLoc(ReadSourceLocation()); } void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) { VisitStmt(S); - S->setCatchBody(Reader.ReadSubStmt()); - S->setCatchParamDecl(ReadDeclAs(Record, Idx)); - S->setAtCatchLoc(ReadSourceLocation(Record, Idx)); - S->setRParenLoc(ReadSourceLocation(Record, Idx)); + S->setCatchBody(Record.ReadSubStmt()); + S->setCatchParamDecl(ReadDeclAs()); + S->setAtCatchLoc(ReadSourceLocation()); + S->setRParenLoc(ReadSourceLocation()); } void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) { VisitStmt(S); - S->setFinallyBody(Reader.ReadSubStmt()); - S->setAtFinallyLoc(ReadSourceLocation(Record, Idx)); + S->setFinallyBody(Record.ReadSubStmt()); + S->setAtFinallyLoc(ReadSourceLocation()); } void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) { VisitStmt(S); - S->setSubStmt(Reader.ReadSubStmt()); - S->setAtLoc(ReadSourceLocation(Record, Idx)); + S->setSubStmt(Record.ReadSubStmt()); + S->setAtLoc(ReadSourceLocation()); } void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) { @@ -1164,40 +1144,40 @@ assert(Record[Idx] == S->getNumCatchStmts()); ++Idx; bool HasFinally = Record[Idx++]; - S->setTryBody(Reader.ReadSubStmt()); + S->setTryBody(Record.ReadSubStmt()); for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) - S->setCatchStmt(I, cast_or_null(Reader.ReadSubStmt())); + S->setCatchStmt(I, cast_or_null(Record.ReadSubStmt())); if (HasFinally) - S->setFinallyStmt(Reader.ReadSubStmt()); - S->setAtTryLoc(ReadSourceLocation(Record, Idx)); + S->setFinallyStmt(Record.ReadSubStmt()); + S->setAtTryLoc(ReadSourceLocation()); } void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) { VisitStmt(S); - S->setSynchExpr(Reader.ReadSubStmt()); - S->setSynchBody(Reader.ReadSubStmt()); - S->setAtSynchronizedLoc(ReadSourceLocation(Record, Idx)); + S->setSynchExpr(Record.ReadSubStmt()); + S->setSynchBody(Record.ReadSubStmt()); + S->setAtSynchronizedLoc(ReadSourceLocation()); } void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) { VisitStmt(S); - S->setThrowExpr(Reader.ReadSubStmt()); - S->setThrowLoc(ReadSourceLocation(Record, Idx)); + S->setThrowExpr(Record.ReadSubStmt()); + S->setThrowLoc(ReadSourceLocation()); } void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) { VisitExpr(E); E->setValue(Record[Idx++]); - E->setLocation(ReadSourceLocation(Record, Idx)); + E->setLocation(ReadSourceLocation()); } void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) { VisitExpr(E); - SourceRange R = Reader.ReadSourceRange(F, Record, Idx); + SourceRange R = Record.ReadSourceRange(Idx); E->AtLoc = R.getBegin(); E->RParen = R.getEnd(); - E->VersionToCheck = Reader.ReadVersionTuple(Record, Idx); + E->VersionToCheck = Record.ReadVersionTuple(Idx); } //===----------------------------------------------------------------------===// @@ -1206,49 +1186,49 @@ void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) { VisitStmt(S); - S->CatchLoc = ReadSourceLocation(Record, Idx); - S->ExceptionDecl = ReadDeclAs(Record, Idx); - S->HandlerBlock = Reader.ReadSubStmt(); + S->CatchLoc = ReadSourceLocation(); + S->ExceptionDecl = ReadDeclAs(); + S->HandlerBlock = Record.ReadSubStmt(); } void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) { VisitStmt(S); assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?"); ++Idx; - S->TryLoc = ReadSourceLocation(Record, Idx); - S->getStmts()[0] = Reader.ReadSubStmt(); + S->TryLoc = ReadSourceLocation(); + S->getStmts()[0] = Record.ReadSubStmt(); for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i) - S->getStmts()[i + 1] = Reader.ReadSubStmt(); + S->getStmts()[i + 1] = Record.ReadSubStmt(); } void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) { VisitStmt(S); - S->ForLoc = ReadSourceLocation(Record, Idx); - S->CoawaitLoc = ReadSourceLocation(Record, Idx); - S->ColonLoc = ReadSourceLocation(Record, Idx); - S->RParenLoc = ReadSourceLocation(Record, Idx); - S->setRangeStmt(Reader.ReadSubStmt()); - S->setBeginStmt(Reader.ReadSubStmt()); - S->setEndStmt(Reader.ReadSubStmt()); - S->setCond(Reader.ReadSubExpr()); - S->setInc(Reader.ReadSubExpr()); - S->setLoopVarStmt(Reader.ReadSubStmt()); - S->setBody(Reader.ReadSubStmt()); + S->ForLoc = ReadSourceLocation(); + S->CoawaitLoc = ReadSourceLocation(); + S->ColonLoc = ReadSourceLocation(); + S->RParenLoc = ReadSourceLocation(); + S->setRangeStmt(Record.ReadSubStmt()); + S->setBeginStmt(Record.ReadSubStmt()); + S->setEndStmt(Record.ReadSubStmt()); + S->setCond(Record.ReadSubExpr()); + S->setInc(Record.ReadSubExpr()); + S->setLoopVarStmt(Record.ReadSubStmt()); + S->setBody(Record.ReadSubStmt()); } void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) { VisitStmt(S); - S->KeywordLoc = ReadSourceLocation(Record, Idx); + S->KeywordLoc = ReadSourceLocation(); S->IsIfExists = Record[Idx++]; - S->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); - ReadDeclarationNameInfo(S->NameInfo, Record, Idx); - S->SubStmt = Reader.ReadSubStmt(); + S->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx); + ReadDeclarationNameInfo(S->NameInfo); + S->SubStmt = Record.ReadSubStmt(); } void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) { VisitCallExpr(E); E->Operator = (OverloadedOperatorKind)Record[Idx++]; - E->Range = Reader.ReadSourceRange(F, Record, Idx); + E->Range = Record.ReadSourceRange(Idx); E->setFPContractable((bool)Record[Idx++]); } @@ -1256,63 +1236,63 @@ VisitExpr(E); E->NumArgs = Record[Idx++]; if (E->NumArgs) - E->Args = new (Reader.getContext()) Stmt*[E->NumArgs]; + E->Args = new (Record.getContext()) Stmt*[E->NumArgs]; for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) - E->setArg(I, Reader.ReadSubExpr()); - E->setConstructor(ReadDeclAs(Record, Idx)); - E->setLocation(ReadSourceLocation(Record, Idx)); + 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->ParenOrBraceRange = ReadSourceRange(Record, Idx); + E->ParenOrBraceRange = ReadSourceRange(); } void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) { VisitExpr(E); - E->Constructor = ReadDeclAs(Record, Idx); - E->Loc = ReadSourceLocation(Record, Idx); + E->Constructor = ReadDeclAs(); + E->Loc = ReadSourceLocation(); E->ConstructsVirtualBase = Record[Idx++]; E->InheritedFromVirtualBase = Record[Idx++]; } void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) { VisitCXXConstructExpr(E); - E->Type = GetTypeSourceInfo(Record, Idx); + E->Type = GetTypeSourceInfo(); } void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) { VisitExpr(E); unsigned NumCaptures = Record[Idx++]; assert(NumCaptures == E->NumCaptures);(void)NumCaptures; - E->IntroducerRange = ReadSourceRange(Record, Idx); + E->IntroducerRange = ReadSourceRange(); E->CaptureDefault = static_cast(Record[Idx++]); - E->CaptureDefaultLoc = ReadSourceLocation(Record, Idx); + E->CaptureDefaultLoc = ReadSourceLocation(); E->ExplicitParams = Record[Idx++]; E->ExplicitResultType = Record[Idx++]; - E->ClosingBrace = ReadSourceLocation(Record, Idx); + E->ClosingBrace = ReadSourceLocation(); // Read capture initializers. for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(), CEnd = E->capture_init_end(); C != CEnd; ++C) - *C = Reader.ReadSubExpr(); + *C = Record.ReadSubExpr(); } void ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) { VisitExpr(E); - E->SubExpr = Reader.ReadSubExpr(); + E->SubExpr = Record.ReadSubExpr(); } void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) { VisitExplicitCastExpr(E); - SourceRange R = ReadSourceRange(Record, Idx); + SourceRange R = ReadSourceRange(); E->Loc = R.getBegin(); E->RParenLoc = R.getEnd(); - R = ReadSourceRange(Record, Idx); + R = ReadSourceRange(); E->AngleBrackets = R; } @@ -1334,74 +1314,74 @@ void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) { VisitExplicitCastExpr(E); - E->setLParenLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); + E->setLParenLoc(ReadSourceLocation()); + E->setRParenLoc(ReadSourceLocation()); } void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) { VisitCallExpr(E); - E->UDSuffixLoc = ReadSourceLocation(Record, Idx); + E->UDSuffixLoc = ReadSourceLocation(); } void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) { VisitExpr(E); E->setValue(Record[Idx++]); - E->setLocation(ReadSourceLocation(Record, Idx)); + E->setLocation(ReadSourceLocation()); } void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) { VisitExpr(E); - E->setLocation(ReadSourceLocation(Record, Idx)); + E->setLocation(ReadSourceLocation()); } void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) { VisitExpr(E); - E->setSourceRange(ReadSourceRange(Record, Idx)); + E->setSourceRange(ReadSourceRange()); if (E->isTypeOperand()) { // typeid(int) E->setTypeOperandSourceInfo( - GetTypeSourceInfo(Record, Idx)); + GetTypeSourceInfo()); return; } // typeid(42+2) - E->setExprOperand(Reader.ReadSubExpr()); + E->setExprOperand(Record.ReadSubExpr()); } void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) { VisitExpr(E); - E->setLocation(ReadSourceLocation(Record, Idx)); + E->setLocation(ReadSourceLocation()); E->setImplicit(Record[Idx++]); } void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) { VisitExpr(E); - E->ThrowLoc = ReadSourceLocation(Record, Idx); - E->Op = Reader.ReadSubExpr(); + E->ThrowLoc = ReadSourceLocation(); + E->Op = Record.ReadSubExpr(); E->IsThrownVariableInScope = Record[Idx++]; } void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) { VisitExpr(E); - E->Param = ReadDeclAs(Record, Idx); - E->Loc = ReadSourceLocation(Record, Idx); + E->Param = ReadDeclAs(); + E->Loc = ReadSourceLocation(); } void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) { VisitExpr(E); - E->Field = ReadDeclAs(Record, Idx); - E->Loc = ReadSourceLocation(Record, Idx); + E->Field = ReadDeclAs(); + E->Loc = ReadSourceLocation(); } void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) { VisitExpr(E); - E->setTemporary(Reader.ReadCXXTemporary(F, Record, Idx)); - E->setSubExpr(Reader.ReadSubExpr()); + E->setTemporary(Record.ReadCXXTemporary(Idx)); + E->setSubExpr(Record.ReadSubExpr()); } void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) { VisitExpr(E); - E->TypeInfo = GetTypeSourceInfo(Record, Idx); - E->RParenLoc = ReadSourceLocation(Record, Idx); + E->TypeInfo = GetTypeSourceInfo(); + E->RParenLoc = ReadSourceLocation(); } void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) { @@ -1412,20 +1392,20 @@ E->UsualArrayDeleteWantsSize = Record[Idx++]; unsigned NumPlacementArgs = Record[Idx++]; E->StoredInitializationStyle = Record[Idx++]; - E->setOperatorNew(ReadDeclAs(Record, Idx)); - E->setOperatorDelete(ReadDeclAs(Record, Idx)); - E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx); - E->TypeIdParens = ReadSourceRange(Record, Idx); - E->Range = ReadSourceRange(Record, Idx); - E->DirectInitRange = ReadSourceRange(Record, Idx); - - E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs, + E->setOperatorNew(ReadDeclAs()); + E->setOperatorDelete(ReadDeclAs()); + E->AllocatedTypeInfo = GetTypeSourceInfo(); + E->TypeIdParens = ReadSourceRange(); + E->Range = ReadSourceRange(); + E->DirectInitRange = ReadSourceRange(); + + E->AllocateArgsArray(Record.getContext(), isArray, NumPlacementArgs, E->StoredInitializationStyle != 0); // Install all the subexpressions. for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end(); I != e; ++I) - *I = Reader.ReadSubStmt(); + *I = Record.ReadSubStmt(); } void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) { @@ -1434,27 +1414,27 @@ E->ArrayForm = Record[Idx++]; E->ArrayFormAsWritten = Record[Idx++]; E->UsualArrayDeleteWantsSize = Record[Idx++]; - E->OperatorDelete = ReadDeclAs(Record, Idx); - E->Argument = Reader.ReadSubExpr(); - E->Loc = ReadSourceLocation(Record, Idx); + E->OperatorDelete = ReadDeclAs(); + E->Argument = Record.ReadSubExpr(); + E->Loc = ReadSourceLocation(); } void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) { VisitExpr(E); - E->Base = Reader.ReadSubExpr(); + E->Base = Record.ReadSubExpr(); E->IsArrow = Record[Idx++]; - E->OperatorLoc = ReadSourceLocation(Record, Idx); - E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); - E->ScopeType = GetTypeSourceInfo(Record, Idx); - E->ColonColonLoc = ReadSourceLocation(Record, Idx); - E->TildeLoc = ReadSourceLocation(Record, Idx); + E->OperatorLoc = ReadSourceLocation(); + E->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx); + E->ScopeType = GetTypeSourceInfo(); + E->ColonColonLoc = ReadSourceLocation(); + E->TildeLoc = ReadSourceLocation(); - IdentifierInfo *II = Reader.GetIdentifierInfo(F, Record, Idx); + IdentifierInfo *II = Record.GetIdentifierInfo(Idx); if (II) - E->setDestroyedType(II, ReadSourceLocation(Record, Idx)); + E->setDestroyedType(II, ReadSourceLocation()); else - E->setDestroyedType(GetTypeSourceInfo(Record, Idx)); + E->setDestroyedType(GetTypeSourceInfo()); } void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) { @@ -1464,10 +1444,10 @@ assert(NumObjects == E->getNumObjects()); for (unsigned i = 0; i != NumObjects; ++i) E->getTrailingObjects()[i] = - ReadDeclAs(Record, Idx); + ReadDeclAs(); E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record[Idx++]; - E->SubExpr = Reader.ReadSubExpr(); + E->SubExpr = Record.ReadSubExpr(); } void @@ -1480,13 +1460,13 @@ E->getTrailingObjects(), /*NumTemplateArgs=*/Record[Idx++]); - E->Base = Reader.ReadSubExpr(); - E->BaseType = Reader.readType(F, Record, Idx); + E->Base = Record.ReadSubExpr(); + E->BaseType = Record.readType(Idx); E->IsArrow = Record[Idx++]; - E->OperatorLoc = ReadSourceLocation(Record, Idx); - E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); - E->FirstQualifierFoundInScope = ReadDeclAs(Record, Idx); - ReadDeclarationNameInfo(E->MemberNameInfo, Record, Idx); + E->OperatorLoc = ReadSourceLocation(); + E->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx); + E->FirstQualifierFoundInScope = ReadDeclAs(); + ReadDeclarationNameInfo(E->MemberNameInfo); } void @@ -1499,8 +1479,8 @@ E->getTrailingObjects(), /*NumTemplateArgs=*/Record[Idx++]); - E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); - ReadDeclarationNameInfo(E->NameInfo, Record, Idx); + E->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx); + ReadDeclarationNameInfo(E->NameInfo); } void @@ -1509,10 +1489,10 @@ assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?"); ++Idx; // NumArgs; for (unsigned I = 0, N = E->arg_size(); I != N; ++I) - E->setArg(I, Reader.ReadSubExpr()); - E->Type = GetTypeSourceInfo(Record, Idx); - E->setLParenLoc(ReadSourceLocation(Record, Idx)); - E->setRParenLoc(ReadSourceLocation(Record, Idx)); + E->setArg(I, Record.ReadSubExpr()); + E->Type = GetTypeSourceInfo(); + E->setLParenLoc(ReadSourceLocation()); + E->setRParenLoc(ReadSourceLocation()); } void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) { @@ -1526,30 +1506,30 @@ unsigned NumDecls = Record[Idx++]; UnresolvedSet<8> Decls; for (unsigned i = 0; i != NumDecls; ++i) { - NamedDecl *D = ReadDeclAs(Record, Idx); + NamedDecl *D = ReadDeclAs(); AccessSpecifier AS = (AccessSpecifier)Record[Idx++]; Decls.addDecl(D, AS); } - E->initializeResults(Reader.getContext(), Decls.begin(), Decls.end()); + E->initializeResults(Record.getContext(), Decls.begin(), Decls.end()); - ReadDeclarationNameInfo(E->NameInfo, Record, Idx); - E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); + ReadDeclarationNameInfo(E->NameInfo); + E->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx); } void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) { VisitOverloadExpr(E); E->IsArrow = Record[Idx++]; E->HasUnresolvedUsing = Record[Idx++]; - E->Base = Reader.ReadSubExpr(); - E->BaseType = Reader.readType(F, Record, Idx); - E->OperatorLoc = ReadSourceLocation(Record, Idx); + E->Base = Record.ReadSubExpr(); + E->BaseType = Record.readType(Idx); + E->OperatorLoc = ReadSourceLocation(); } void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) { VisitOverloadExpr(E); E->RequiresADL = Record[Idx++]; E->Overloaded = Record[Idx++]; - E->NamingClass = ReadDeclAs(Record, Idx); + E->NamingClass = ReadDeclAs(); } void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) { @@ -1557,32 +1537,32 @@ E->TypeTraitExprBits.NumArgs = Record[Idx++]; E->TypeTraitExprBits.Kind = Record[Idx++]; E->TypeTraitExprBits.Value = Record[Idx++]; - SourceRange Range = ReadSourceRange(Record, Idx); + SourceRange Range = ReadSourceRange(); E->Loc = Range.getBegin(); E->RParenLoc = Range.getEnd(); TypeSourceInfo **Args = E->getTrailingObjects(); for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) - Args[I] = GetTypeSourceInfo(Record, Idx); + Args[I] = GetTypeSourceInfo(); } void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) { VisitExpr(E); E->ATT = (ArrayTypeTrait)Record[Idx++]; E->Value = (unsigned int)Record[Idx++]; - SourceRange Range = ReadSourceRange(Record, Idx); + SourceRange Range = ReadSourceRange(); E->Loc = Range.getBegin(); E->RParen = Range.getEnd(); - E->QueriedType = GetTypeSourceInfo(Record, Idx); - E->Dimension = Reader.ReadSubExpr(); + E->QueriedType = GetTypeSourceInfo(); + E->Dimension = Record.ReadSubExpr(); } void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) { VisitExpr(E); E->ET = (ExpressionTrait)Record[Idx++]; E->Value = (bool)Record[Idx++]; - SourceRange Range = ReadSourceRange(Record, Idx); - E->QueriedExpression = Reader.ReadSubExpr(); + SourceRange Range = ReadSourceRange(); + E->QueriedExpression = Record.ReadSubExpr(); E->Loc = Range.getBegin(); E->RParen = Range.getEnd(); } @@ -1590,30 +1570,30 @@ void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) { VisitExpr(E); E->Value = (bool)Record[Idx++]; - E->Range = ReadSourceRange(Record, Idx); - E->Operand = Reader.ReadSubExpr(); + E->Range = ReadSourceRange(); + E->Operand = Record.ReadSubExpr(); } void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) { VisitExpr(E); - E->EllipsisLoc = ReadSourceLocation(Record, Idx); + E->EllipsisLoc = ReadSourceLocation(); E->NumExpansions = Record[Idx++]; - E->Pattern = Reader.ReadSubExpr(); + E->Pattern = Record.ReadSubExpr(); } void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) { VisitExpr(E); unsigned NumPartialArgs = Record[Idx++]; - E->OperatorLoc = ReadSourceLocation(Record, Idx); - E->PackLoc = ReadSourceLocation(Record, Idx); - E->RParenLoc = ReadSourceLocation(Record, Idx); - E->Pack = Reader.ReadDeclAs(F, Record, Idx); + E->OperatorLoc = ReadSourceLocation(); + E->PackLoc = ReadSourceLocation(); + E->RParenLoc = ReadSourceLocation(); + E->Pack = Record.ReadDeclAs(Idx); if (E->isPartiallySubstituted()) { assert(E->Length == NumPartialArgs); for (auto *I = E->getTrailingObjects(), *E = I + NumPartialArgs; I != E; ++I) - new (I) TemplateArgument(Reader.ReadTemplateArgument(F, Record, Idx)); + new (I) TemplateArgument(Record.ReadTemplateArgument(Idx)); } else if (!E->isValueDependent()) { E->Length = Record[Idx++]; } @@ -1622,56 +1602,56 @@ void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr( SubstNonTypeTemplateParmExpr *E) { VisitExpr(E); - E->Param = ReadDeclAs(Record, Idx); - E->NameLoc = ReadSourceLocation(Record, Idx); - E->Replacement = Reader.ReadSubExpr(); + E->Param = ReadDeclAs(); + E->NameLoc = ReadSourceLocation(); + E->Replacement = Record.ReadSubExpr(); } void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr( SubstNonTypeTemplateParmPackExpr *E) { VisitExpr(E); - E->Param = ReadDeclAs(Record, Idx); - TemplateArgument ArgPack = Reader.ReadTemplateArgument(F, Record, Idx); + E->Param = ReadDeclAs(); + TemplateArgument ArgPack = Record.ReadTemplateArgument(Idx); if (ArgPack.getKind() != TemplateArgument::Pack) return; E->Arguments = ArgPack.pack_begin(); E->NumArguments = ArgPack.pack_size(); - E->NameLoc = ReadSourceLocation(Record, Idx); + E->NameLoc = ReadSourceLocation(); } void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) { VisitExpr(E); E->NumParameters = Record[Idx++]; - E->ParamPack = ReadDeclAs(Record, Idx); - E->NameLoc = ReadSourceLocation(Record, Idx); + E->ParamPack = ReadDeclAs(); + E->NameLoc = ReadSourceLocation(); ParmVarDecl **Parms = E->getTrailingObjects(); for (unsigned i = 0, n = E->NumParameters; i != n; ++i) - Parms[i] = ReadDeclAs(Record, Idx); + Parms[i] = ReadDeclAs(); } void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) { VisitExpr(E); - E->State = Reader.ReadSubExpr(); - auto VD = ReadDeclAs(Record, Idx); + E->State = Record.ReadSubExpr(); + auto VD = ReadDeclAs(); unsigned ManglingNumber = Record[Idx++]; E->setExtendingDecl(VD, ManglingNumber); } void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) { VisitExpr(E); - E->LParenLoc = ReadSourceLocation(Record, Idx); - E->EllipsisLoc = ReadSourceLocation(Record, Idx); - E->RParenLoc = ReadSourceLocation(Record, Idx); - E->SubExprs[0] = Reader.ReadSubExpr(); - E->SubExprs[1] = Reader.ReadSubExpr(); + E->LParenLoc = ReadSourceLocation(); + E->EllipsisLoc = ReadSourceLocation(); + E->RParenLoc = ReadSourceLocation(); + E->SubExprs[0] = Record.ReadSubExpr(); + E->SubExprs[1] = Record.ReadSubExpr(); E->Opcode = (BinaryOperatorKind)Record[Idx++]; } void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) { VisitExpr(E); - E->SourceExpr = Reader.ReadSubExpr(); - E->Loc = ReadSourceLocation(Record, Idx); + E->SourceExpr = Record.ReadSubExpr(); + E->Loc = ReadSourceLocation(); } void ASTStmtReader::VisitTypoExpr(TypoExpr *E) { @@ -1684,58 +1664,58 @@ void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) { VisitExpr(E); E->IsArrow = (Record[Idx++] != 0); - E->BaseExpr = Reader.ReadSubExpr(); - E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx); - E->MemberLoc = ReadSourceLocation(Record, Idx); - E->TheDecl = ReadDeclAs(Record, Idx); + E->BaseExpr = Record.ReadSubExpr(); + E->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx); + E->MemberLoc = ReadSourceLocation(); + E->TheDecl = ReadDeclAs(); } void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) { VisitExpr(E); - E->setBase(Reader.ReadSubExpr()); - E->setIdx(Reader.ReadSubExpr()); - E->setRBracketLoc(ReadSourceLocation(Record, Idx)); + E->setBase(Record.ReadSubExpr()); + E->setIdx(Record.ReadSubExpr()); + E->setRBracketLoc(ReadSourceLocation()); } void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) { VisitExpr(E); - E->setSourceRange(ReadSourceRange(Record, Idx)); - std::string UuidStr = ReadString(Record, Idx); - E->setUuidStr(StringRef(UuidStr).copy(Reader.getContext())); + E->setSourceRange(ReadSourceRange()); + std::string UuidStr = ReadString(); + E->setUuidStr(StringRef(UuidStr).copy(Record.getContext())); if (E->isTypeOperand()) { // __uuidof(ComType) E->setTypeOperandSourceInfo( - GetTypeSourceInfo(Record, Idx)); + GetTypeSourceInfo()); return; } // __uuidof(expr) - E->setExprOperand(Reader.ReadSubExpr()); + E->setExprOperand(Record.ReadSubExpr()); } void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) { VisitStmt(S); - S->setLeaveLoc(ReadSourceLocation(Record, Idx)); + S->setLeaveLoc(ReadSourceLocation()); } void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) { VisitStmt(S); - S->Loc = ReadSourceLocation(Record, Idx); - S->Children[SEHExceptStmt::FILTER_EXPR] = Reader.ReadSubStmt(); - S->Children[SEHExceptStmt::BLOCK] = Reader.ReadSubStmt(); + S->Loc = ReadSourceLocation(); + S->Children[SEHExceptStmt::FILTER_EXPR] = Record.ReadSubStmt(); + S->Children[SEHExceptStmt::BLOCK] = Record.ReadSubStmt(); } void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) { VisitStmt(S); - S->Loc = ReadSourceLocation(Record, Idx); - S->Block = Reader.ReadSubStmt(); + S->Loc = ReadSourceLocation(); + S->Block = Record.ReadSubStmt(); } void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) { VisitStmt(S); S->IsCXXTry = Record[Idx++]; - S->TryLoc = ReadSourceLocation(Record, Idx); - S->Children[SEHTryStmt::TRY] = Reader.ReadSubStmt(); - S->Children[SEHTryStmt::HANDLER] = Reader.ReadSubStmt(); + S->TryLoc = ReadSourceLocation(); + S->Children[SEHTryStmt::TRY] = Record.ReadSubStmt(); + S->Children[SEHTryStmt::HANDLER] = Record.ReadSubStmt(); } //===----------------------------------------------------------------------===// @@ -1744,7 +1724,7 @@ void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) { VisitCallExpr(E); - E->setConfig(cast(Reader.ReadSubExpr())); + E->setConfig(cast(Record.ReadSubExpr())); } //===----------------------------------------------------------------------===// @@ -1752,9 +1732,9 @@ //===----------------------------------------------------------------------===// void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) { VisitExpr(E); - E->BuiltinLoc = ReadSourceLocation(Record, Idx); - E->RParenLoc = ReadSourceLocation(Record, Idx); - E->SrcExpr = Reader.ReadSubExpr(); + E->BuiltinLoc = ReadSourceLocation(); + E->RParenLoc = ReadSourceLocation(); + E->SrcExpr = Record.ReadSubExpr(); } //===----------------------------------------------------------------------===// @@ -1764,13 +1744,12 @@ namespace clang { class OMPClauseReader : public OMPClauseVisitor { ASTStmtReader *Reader; + ASTRecordReader &Record; ASTContext &Context; - const ASTReader::RecordData &Record; unsigned &Idx; public: - OMPClauseReader(ASTStmtReader *R, ASTContext &C, - const ASTReader::RecordData &Record, unsigned &Idx) - : Reader(R), Context(C), Record(Record), Idx(Idx) { } + OMPClauseReader(ASTStmtReader *R, ASTRecordReader &Record, unsigned &Idx) + : Reader(R), Record(Record), Context(Record.getContext()), Idx(Idx) {} #define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *C); #include "clang/Basic/OpenMPKinds.def" OMPClause *readClause(); @@ -1952,66 +1931,66 @@ } } Visit(C); - C->setLocStart(Reader->ReadSourceLocation(Record, Idx)); - C->setLocEnd(Reader->ReadSourceLocation(Record, Idx)); + C->setLocStart(Reader->ReadSourceLocation()); + C->setLocEnd(Reader->ReadSourceLocation()); return C; } void OMPClauseReader::VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C) { - C->setPreInitStmt(Reader->Reader.ReadSubStmt()); + C->setPreInitStmt(Reader->Record.ReadSubStmt()); } void OMPClauseReader::VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C) { VisitOMPClauseWithPreInit(C); - C->setPostUpdateExpr(Reader->Reader.ReadSubExpr()); + C->setPostUpdateExpr(Reader->Record.ReadSubExpr()); } void OMPClauseReader::VisitOMPIfClause(OMPIfClause *C) { C->setNameModifier(static_cast(Record[Idx++])); - C->setNameModifierLoc(Reader->ReadSourceLocation(Record, Idx)); - C->setColonLoc(Reader->ReadSourceLocation(Record, Idx)); - C->setCondition(Reader->Reader.ReadSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setNameModifierLoc(Reader->ReadSourceLocation()); + C->setColonLoc(Reader->ReadSourceLocation()); + C->setCondition(Reader->Record.ReadSubExpr()); + C->setLParenLoc(Reader->ReadSourceLocation()); } void OMPClauseReader::VisitOMPFinalClause(OMPFinalClause *C) { - C->setCondition(Reader->Reader.ReadSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setCondition(Reader->Record.ReadSubExpr()); + C->setLParenLoc(Reader->ReadSourceLocation()); } void OMPClauseReader::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) { - C->setNumThreads(Reader->Reader.ReadSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setNumThreads(Reader->Record.ReadSubExpr()); + C->setLParenLoc(Reader->ReadSourceLocation()); } void OMPClauseReader::VisitOMPSafelenClause(OMPSafelenClause *C) { - C->setSafelen(Reader->Reader.ReadSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setSafelen(Reader->Record.ReadSubExpr()); + C->setLParenLoc(Reader->ReadSourceLocation()); } void OMPClauseReader::VisitOMPSimdlenClause(OMPSimdlenClause *C) { - C->setSimdlen(Reader->Reader.ReadSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setSimdlen(Reader->Record.ReadSubExpr()); + C->setLParenLoc(Reader->ReadSourceLocation()); } void OMPClauseReader::VisitOMPCollapseClause(OMPCollapseClause *C) { - C->setNumForLoops(Reader->Reader.ReadSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setNumForLoops(Reader->Record.ReadSubExpr()); + C->setLParenLoc(Reader->ReadSourceLocation()); } void OMPClauseReader::VisitOMPDefaultClause(OMPDefaultClause *C) { C->setDefaultKind( static_cast(Record[Idx++])); - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); - C->setDefaultKindKwLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setLParenLoc(Reader->ReadSourceLocation()); + C->setDefaultKindKwLoc(Reader->ReadSourceLocation()); } void OMPClauseReader::VisitOMPProcBindClause(OMPProcBindClause *C) { C->setProcBindKind( static_cast(Record[Idx++])); - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); - C->setProcBindKindKwLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setLParenLoc(Reader->ReadSourceLocation()); + C->setProcBindKindKwLoc(Reader->ReadSourceLocation()); } void OMPClauseReader::VisitOMPScheduleClause(OMPScheduleClause *C) { @@ -2022,17 +2001,17 @@ static_cast(Record[Idx++])); C->setSecondScheduleModifier( static_cast(Record[Idx++])); - C->setChunkSize(Reader->Reader.ReadSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); - C->setFirstScheduleModifierLoc(Reader->ReadSourceLocation(Record, Idx)); - C->setSecondScheduleModifierLoc(Reader->ReadSourceLocation(Record, Idx)); - C->setScheduleKindLoc(Reader->ReadSourceLocation(Record, Idx)); - C->setCommaLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setChunkSize(Reader->Record.ReadSubExpr()); + C->setLParenLoc(Reader->ReadSourceLocation()); + C->setFirstScheduleModifierLoc(Reader->ReadSourceLocation()); + C->setSecondScheduleModifierLoc(Reader->ReadSourceLocation()); + C->setScheduleKindLoc(Reader->ReadSourceLocation()); + C->setCommaLoc(Reader->ReadSourceLocation()); } void OMPClauseReader::VisitOMPOrderedClause(OMPOrderedClause *C) { - C->setNumForLoops(Reader->Reader.ReadSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setNumForLoops(Reader->Record.ReadSubExpr()); + C->setLParenLoc(Reader->ReadSourceLocation()); } void OMPClauseReader::VisitOMPNowaitClause(OMPNowaitClause *) {} @@ -2058,83 +2037,82 @@ void OMPClauseReader::VisitOMPNogroupClause(OMPNogroupClause *) {} void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setLParenLoc(Reader->ReadSourceLocation()); unsigned NumVars = C->varlist_size(); SmallVector Vars; Vars.reserve(NumVars); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setVarRefs(Vars); Vars.clear(); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setPrivateCopies(Vars); } void OMPClauseReader::VisitOMPFirstprivateClause(OMPFirstprivateClause *C) { VisitOMPClauseWithPreInit(C); - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setLParenLoc(Reader->ReadSourceLocation()); unsigned NumVars = C->varlist_size(); SmallVector Vars; Vars.reserve(NumVars); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setVarRefs(Vars); Vars.clear(); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setPrivateCopies(Vars); Vars.clear(); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setInits(Vars); } void OMPClauseReader::VisitOMPLastprivateClause(OMPLastprivateClause *C) { VisitOMPClauseWithPostUpdate(C); - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setLParenLoc(Reader->ReadSourceLocation()); unsigned NumVars = C->varlist_size(); SmallVector Vars; Vars.reserve(NumVars); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setVarRefs(Vars); Vars.clear(); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setPrivateCopies(Vars); Vars.clear(); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setSourceExprs(Vars); Vars.clear(); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setDestinationExprs(Vars); Vars.clear(); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setAssignmentOps(Vars); } void OMPClauseReader::VisitOMPSharedClause(OMPSharedClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setLParenLoc(Reader->ReadSourceLocation()); unsigned NumVars = C->varlist_size(); SmallVector Vars; Vars.reserve(NumVars); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setVarRefs(Vars); } void OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *C) { VisitOMPClauseWithPostUpdate(C); - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); - C->setColonLoc(Reader->ReadSourceLocation(Record, Idx)); - NestedNameSpecifierLoc NNSL = - Reader->Reader.ReadNestedNameSpecifierLoc(Reader->F, Record, Idx); + C->setLParenLoc(Reader->ReadSourceLocation()); + C->setColonLoc(Reader->ReadSourceLocation()); + NestedNameSpecifierLoc NNSL = Record.ReadNestedNameSpecifierLoc(Idx); DeclarationNameInfo DNI; - Reader->ReadDeclarationNameInfo(DNI, Record, Idx); + Reader->ReadDeclarationNameInfo(DNI); C->setQualifierLoc(NNSL); C->setNameInfo(DNI); @@ -2142,151 +2120,151 @@ SmallVector Vars; Vars.reserve(NumVars); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setVarRefs(Vars); Vars.clear(); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setPrivates(Vars); Vars.clear(); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setLHSExprs(Vars); Vars.clear(); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setRHSExprs(Vars); Vars.clear(); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setReductionOps(Vars); } void OMPClauseReader::VisitOMPLinearClause(OMPLinearClause *C) { VisitOMPClauseWithPostUpdate(C); - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); - C->setColonLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setLParenLoc(Reader->ReadSourceLocation()); + C->setColonLoc(Reader->ReadSourceLocation()); C->setModifier(static_cast(Record[Idx++])); - C->setModifierLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setModifierLoc(Reader->ReadSourceLocation()); unsigned NumVars = C->varlist_size(); SmallVector Vars; Vars.reserve(NumVars); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setVarRefs(Vars); Vars.clear(); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setPrivates(Vars); Vars.clear(); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setInits(Vars); Vars.clear(); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setUpdates(Vars); Vars.clear(); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setFinals(Vars); - C->setStep(Reader->Reader.ReadSubExpr()); - C->setCalcStep(Reader->Reader.ReadSubExpr()); + C->setStep(Reader->Record.ReadSubExpr()); + C->setCalcStep(Reader->Record.ReadSubExpr()); } void OMPClauseReader::VisitOMPAlignedClause(OMPAlignedClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); - C->setColonLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setLParenLoc(Reader->ReadSourceLocation()); + C->setColonLoc(Reader->ReadSourceLocation()); unsigned NumVars = C->varlist_size(); SmallVector Vars; Vars.reserve(NumVars); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setVarRefs(Vars); - C->setAlignment(Reader->Reader.ReadSubExpr()); + C->setAlignment(Reader->Record.ReadSubExpr()); } void OMPClauseReader::VisitOMPCopyinClause(OMPCopyinClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setLParenLoc(Reader->ReadSourceLocation()); unsigned NumVars = C->varlist_size(); SmallVector Exprs; Exprs.reserve(NumVars); for (unsigned i = 0; i != NumVars; ++i) - Exprs.push_back(Reader->Reader.ReadSubExpr()); + Exprs.push_back(Reader->Record.ReadSubExpr()); C->setVarRefs(Exprs); Exprs.clear(); for (unsigned i = 0; i != NumVars; ++i) - Exprs.push_back(Reader->Reader.ReadSubExpr()); + Exprs.push_back(Reader->Record.ReadSubExpr()); C->setSourceExprs(Exprs); Exprs.clear(); for (unsigned i = 0; i != NumVars; ++i) - Exprs.push_back(Reader->Reader.ReadSubExpr()); + Exprs.push_back(Reader->Record.ReadSubExpr()); C->setDestinationExprs(Exprs); Exprs.clear(); for (unsigned i = 0; i != NumVars; ++i) - Exprs.push_back(Reader->Reader.ReadSubExpr()); + Exprs.push_back(Reader->Record.ReadSubExpr()); C->setAssignmentOps(Exprs); } void OMPClauseReader::VisitOMPCopyprivateClause(OMPCopyprivateClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setLParenLoc(Reader->ReadSourceLocation()); unsigned NumVars = C->varlist_size(); SmallVector Exprs; Exprs.reserve(NumVars); for (unsigned i = 0; i != NumVars; ++i) - Exprs.push_back(Reader->Reader.ReadSubExpr()); + Exprs.push_back(Reader->Record.ReadSubExpr()); C->setVarRefs(Exprs); Exprs.clear(); for (unsigned i = 0; i != NumVars; ++i) - Exprs.push_back(Reader->Reader.ReadSubExpr()); + Exprs.push_back(Reader->Record.ReadSubExpr()); C->setSourceExprs(Exprs); Exprs.clear(); for (unsigned i = 0; i != NumVars; ++i) - Exprs.push_back(Reader->Reader.ReadSubExpr()); + Exprs.push_back(Reader->Record.ReadSubExpr()); C->setDestinationExprs(Exprs); Exprs.clear(); for (unsigned i = 0; i != NumVars; ++i) - Exprs.push_back(Reader->Reader.ReadSubExpr()); + Exprs.push_back(Reader->Record.ReadSubExpr()); C->setAssignmentOps(Exprs); } void OMPClauseReader::VisitOMPFlushClause(OMPFlushClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setLParenLoc(Reader->ReadSourceLocation()); unsigned NumVars = C->varlist_size(); SmallVector Vars; Vars.reserve(NumVars); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setVarRefs(Vars); } void OMPClauseReader::VisitOMPDependClause(OMPDependClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setLParenLoc(Reader->ReadSourceLocation()); C->setDependencyKind(static_cast(Record[Idx++])); - C->setDependencyLoc(Reader->ReadSourceLocation(Record, Idx)); - C->setColonLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setDependencyLoc(Reader->ReadSourceLocation()); + C->setColonLoc(Reader->ReadSourceLocation()); unsigned NumVars = C->varlist_size(); SmallVector Vars; Vars.reserve(NumVars); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setVarRefs(Vars); - C->setCounterValue(Reader->Reader.ReadSubExpr()); + C->setCounterValue(Reader->Record.ReadSubExpr()); } void OMPClauseReader::VisitOMPDeviceClause(OMPDeviceClause *C) { - C->setDevice(Reader->Reader.ReadSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setDevice(Reader->Record.ReadSubExpr()); + C->setLParenLoc(Reader->ReadSourceLocation()); } void OMPClauseReader::VisitOMPMapClause(OMPMapClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setLParenLoc(Reader->ReadSourceLocation()); C->setMapTypeModifier( static_cast(Record[Idx++])); C->setMapType( static_cast(Record[Idx++])); - C->setMapLoc(Reader->ReadSourceLocation(Record, Idx)); - C->setColonLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setMapLoc(Reader->ReadSourceLocation()); + C->setColonLoc(Reader->ReadSourceLocation()); auto NumVars = C->varlist_size(); auto UniqueDecls = C->getUniqueDeclarationsNum(); auto TotalLists = C->getTotalComponentListNum(); @@ -2295,14 +2273,13 @@ SmallVector Vars; Vars.reserve(NumVars); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setVarRefs(Vars); SmallVector Decls; Decls.reserve(UniqueDecls); for (unsigned i = 0; i < UniqueDecls; ++i) - Decls.push_back( - Reader->Reader.ReadDeclAs(Reader->F, Record, Idx)); + Decls.push_back(Record.ReadDeclAs(Idx)); C->setUniqueDecls(Decls); SmallVector ListsPerDecl; @@ -2320,9 +2297,9 @@ SmallVector Components; Components.reserve(TotalComponents); for (unsigned i = 0; i < TotalComponents; ++i) { - Expr *AssociatedExpr = Reader->Reader.ReadSubExpr(); + Expr *AssociatedExpr = Reader->Record.ReadSubExpr(); ValueDecl *AssociatedDecl = - Reader->Reader.ReadDeclAs(Reader->F, Record, Idx); + Record.ReadDeclAs(Idx); Components.push_back(OMPClauseMappableExprCommon::MappableComponent( AssociatedExpr, AssociatedDecl)); } @@ -2330,43 +2307,43 @@ } void OMPClauseReader::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) { - C->setNumTeams(Reader->Reader.ReadSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setNumTeams(Reader->Record.ReadSubExpr()); + C->setLParenLoc(Reader->ReadSourceLocation()); } void OMPClauseReader::VisitOMPThreadLimitClause(OMPThreadLimitClause *C) { - C->setThreadLimit(Reader->Reader.ReadSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setThreadLimit(Reader->Record.ReadSubExpr()); + C->setLParenLoc(Reader->ReadSourceLocation()); } void OMPClauseReader::VisitOMPPriorityClause(OMPPriorityClause *C) { - C->setPriority(Reader->Reader.ReadSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setPriority(Reader->Record.ReadSubExpr()); + C->setLParenLoc(Reader->ReadSourceLocation()); } void OMPClauseReader::VisitOMPGrainsizeClause(OMPGrainsizeClause *C) { - C->setGrainsize(Reader->Reader.ReadSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setGrainsize(Reader->Record.ReadSubExpr()); + C->setLParenLoc(Reader->ReadSourceLocation()); } void OMPClauseReader::VisitOMPNumTasksClause(OMPNumTasksClause *C) { - C->setNumTasks(Reader->Reader.ReadSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setNumTasks(Reader->Record.ReadSubExpr()); + C->setLParenLoc(Reader->ReadSourceLocation()); } void OMPClauseReader::VisitOMPHintClause(OMPHintClause *C) { - C->setHint(Reader->Reader.ReadSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setHint(Reader->Record.ReadSubExpr()); + C->setLParenLoc(Reader->ReadSourceLocation()); } void OMPClauseReader::VisitOMPDistScheduleClause(OMPDistScheduleClause *C) { VisitOMPClauseWithPreInit(C); C->setDistScheduleKind( static_cast(Record[Idx++])); - C->setChunkSize(Reader->Reader.ReadSubExpr()); - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); - C->setDistScheduleKindLoc(Reader->ReadSourceLocation(Record, Idx)); - C->setCommaLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setChunkSize(Reader->Record.ReadSubExpr()); + C->setLParenLoc(Reader->ReadSourceLocation()); + C->setDistScheduleKindLoc(Reader->ReadSourceLocation()); + C->setCommaLoc(Reader->ReadSourceLocation()); } void OMPClauseReader::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) { @@ -2374,13 +2351,13 @@ static_cast(Record[Idx++])); C->setDefaultmapModifier( static_cast(Record[Idx++])); - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); - C->setDefaultmapModifierLoc(Reader->ReadSourceLocation(Record, Idx)); - C->setDefaultmapKindLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setLParenLoc(Reader->ReadSourceLocation()); + C->setDefaultmapModifierLoc(Reader->ReadSourceLocation()); + C->setDefaultmapKindLoc(Reader->ReadSourceLocation()); } void OMPClauseReader::VisitOMPToClause(OMPToClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setLParenLoc(Reader->ReadSourceLocation()); auto NumVars = C->varlist_size(); auto UniqueDecls = C->getUniqueDeclarationsNum(); auto TotalLists = C->getTotalComponentListNum(); @@ -2389,14 +2366,13 @@ SmallVector Vars; Vars.reserve(NumVars); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setVarRefs(Vars); SmallVector Decls; Decls.reserve(UniqueDecls); for (unsigned i = 0; i < UniqueDecls; ++i) - Decls.push_back( - Reader->Reader.ReadDeclAs(Reader->F, Record, Idx)); + Decls.push_back(Record.ReadDeclAs(Idx)); C->setUniqueDecls(Decls); SmallVector ListsPerDecl; @@ -2414,9 +2390,8 @@ SmallVector Components; Components.reserve(TotalComponents); for (unsigned i = 0; i < TotalComponents; ++i) { - Expr *AssociatedExpr = Reader->Reader.ReadSubExpr(); - ValueDecl *AssociatedDecl = - Reader->Reader.ReadDeclAs(Reader->F, Record, Idx); + Expr *AssociatedExpr = Reader->Record.ReadSubExpr(); + ValueDecl *AssociatedDecl = Record.ReadDeclAs(Idx); Components.push_back(OMPClauseMappableExprCommon::MappableComponent( AssociatedExpr, AssociatedDecl)); } @@ -2424,7 +2399,7 @@ } void OMPClauseReader::VisitOMPFromClause(OMPFromClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setLParenLoc(Reader->ReadSourceLocation()); auto NumVars = C->varlist_size(); auto UniqueDecls = C->getUniqueDeclarationsNum(); auto TotalLists = C->getTotalComponentListNum(); @@ -2433,14 +2408,13 @@ SmallVector Vars; Vars.reserve(NumVars); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setVarRefs(Vars); SmallVector Decls; Decls.reserve(UniqueDecls); for (unsigned i = 0; i < UniqueDecls; ++i) - Decls.push_back( - Reader->Reader.ReadDeclAs(Reader->F, Record, Idx)); + Decls.push_back(Record.ReadDeclAs(Idx)); C->setUniqueDecls(Decls); SmallVector ListsPerDecl; @@ -2458,9 +2432,8 @@ SmallVector Components; Components.reserve(TotalComponents); for (unsigned i = 0; i < TotalComponents; ++i) { - Expr *AssociatedExpr = Reader->Reader.ReadSubExpr(); - ValueDecl *AssociatedDecl = - Reader->Reader.ReadDeclAs(Reader->F, Record, Idx); + Expr *AssociatedExpr = Reader->Record.ReadSubExpr(); + ValueDecl *AssociatedDecl = Record.ReadDeclAs(Idx); Components.push_back(OMPClauseMappableExprCommon::MappableComponent( AssociatedExpr, AssociatedDecl)); } @@ -2468,7 +2441,7 @@ } void OMPClauseReader::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setLParenLoc(Reader->ReadSourceLocation()); auto NumVars = C->varlist_size(); auto UniqueDecls = C->getUniqueDeclarationsNum(); auto TotalLists = C->getTotalComponentListNum(); @@ -2477,22 +2450,21 @@ SmallVector Vars; Vars.reserve(NumVars); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setVarRefs(Vars); Vars.clear(); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setPrivateCopies(Vars); Vars.clear(); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setInits(Vars); SmallVector Decls; Decls.reserve(UniqueDecls); for (unsigned i = 0; i < UniqueDecls; ++i) - Decls.push_back( - Reader->Reader.ReadDeclAs(Reader->F, Record, Idx)); + Decls.push_back(Record.ReadDeclAs(Idx)); C->setUniqueDecls(Decls); SmallVector ListsPerDecl; @@ -2510,9 +2482,8 @@ SmallVector Components; Components.reserve(TotalComponents); for (unsigned i = 0; i < TotalComponents; ++i) { - Expr *AssociatedExpr = Reader->Reader.ReadSubExpr(); - ValueDecl *AssociatedDecl = - Reader->Reader.ReadDeclAs(Reader->F, Record, Idx); + Expr *AssociatedExpr = Reader->Record.ReadSubExpr(); + ValueDecl *AssociatedDecl = Record.ReadDeclAs(Idx); Components.push_back(OMPClauseMappableExprCommon::MappableComponent( AssociatedExpr, AssociatedDecl)); } @@ -2520,7 +2491,7 @@ } void OMPClauseReader::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *C) { - C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setLParenLoc(Reader->ReadSourceLocation()); auto NumVars = C->varlist_size(); auto UniqueDecls = C->getUniqueDeclarationsNum(); auto TotalLists = C->getTotalComponentListNum(); @@ -2529,15 +2500,14 @@ SmallVector Vars; Vars.reserve(NumVars); for (unsigned i = 0; i != NumVars; ++i) - Vars.push_back(Reader->Reader.ReadSubExpr()); + Vars.push_back(Reader->Record.ReadSubExpr()); C->setVarRefs(Vars); Vars.clear(); SmallVector Decls; Decls.reserve(UniqueDecls); for (unsigned i = 0; i < UniqueDecls; ++i) - Decls.push_back( - Reader->Reader.ReadDeclAs(Reader->F, Record, Idx)); + Decls.push_back(Record.ReadDeclAs(Idx)); C->setUniqueDecls(Decls); SmallVector ListsPerDecl; @@ -2555,9 +2525,8 @@ SmallVector Components; Components.reserve(TotalComponents); for (unsigned i = 0; i < TotalComponents; ++i) { - Expr *AssociatedExpr = Reader->Reader.ReadSubExpr(); - ValueDecl *AssociatedDecl = - Reader->Reader.ReadDeclAs(Reader->F, Record, Idx); + Expr *AssociatedExpr = Reader->Record.ReadSubExpr(); + ValueDecl *AssociatedDecl = Record.ReadDeclAs(Idx); Components.push_back(OMPClauseMappableExprCommon::MappableComponent( AssociatedExpr, AssociatedDecl)); } @@ -2568,15 +2537,15 @@ // OpenMP Directives. //===----------------------------------------------------------------------===// void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) { - E->setLocStart(ReadSourceLocation(Record, Idx)); - E->setLocEnd(ReadSourceLocation(Record, Idx)); - OMPClauseReader ClauseReader(this, Reader.getContext(), Record, Idx); + E->setLocStart(ReadSourceLocation()); + E->setLocEnd(ReadSourceLocation()); + OMPClauseReader ClauseReader(this, Record, Idx); SmallVector Clauses; for (unsigned i = 0; i < E->getNumClauses(); ++i) Clauses.push_back(ClauseReader.readClause()); E->setClauses(Clauses); if (E->hasAssociatedStmt()) - E->setAssociatedStmt(Reader.ReadSubStmt()); + E->setAssociatedStmt(Record.ReadSubStmt()); } void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) { @@ -2584,51 +2553,51 @@ // Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream. Idx += 2; VisitOMPExecutableDirective(D); - D->setIterationVariable(Reader.ReadSubExpr()); - D->setLastIteration(Reader.ReadSubExpr()); - D->setCalcLastIteration(Reader.ReadSubExpr()); - D->setPreCond(Reader.ReadSubExpr()); - D->setCond(Reader.ReadSubExpr()); - D->setInit(Reader.ReadSubExpr()); - D->setInc(Reader.ReadSubExpr()); - D->setPreInits(Reader.ReadSubStmt()); + D->setIterationVariable(Record.ReadSubExpr()); + D->setLastIteration(Record.ReadSubExpr()); + D->setCalcLastIteration(Record.ReadSubExpr()); + D->setPreCond(Record.ReadSubExpr()); + D->setCond(Record.ReadSubExpr()); + D->setInit(Record.ReadSubExpr()); + D->setInc(Record.ReadSubExpr()); + D->setPreInits(Record.ReadSubStmt()); if (isOpenMPWorksharingDirective(D->getDirectiveKind()) || isOpenMPTaskLoopDirective(D->getDirectiveKind()) || isOpenMPDistributeDirective(D->getDirectiveKind())) { - D->setIsLastIterVariable(Reader.ReadSubExpr()); - D->setLowerBoundVariable(Reader.ReadSubExpr()); - D->setUpperBoundVariable(Reader.ReadSubExpr()); - D->setStrideVariable(Reader.ReadSubExpr()); - D->setEnsureUpperBound(Reader.ReadSubExpr()); - D->setNextLowerBound(Reader.ReadSubExpr()); - D->setNextUpperBound(Reader.ReadSubExpr()); - D->setNumIterations(Reader.ReadSubExpr()); + D->setIsLastIterVariable(Record.ReadSubExpr()); + D->setLowerBoundVariable(Record.ReadSubExpr()); + D->setUpperBoundVariable(Record.ReadSubExpr()); + D->setStrideVariable(Record.ReadSubExpr()); + D->setEnsureUpperBound(Record.ReadSubExpr()); + D->setNextLowerBound(Record.ReadSubExpr()); + D->setNextUpperBound(Record.ReadSubExpr()); + D->setNumIterations(Record.ReadSubExpr()); } if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) { - D->setPrevLowerBoundVariable(Reader.ReadSubExpr()); - D->setPrevUpperBoundVariable(Reader.ReadSubExpr()); + D->setPrevLowerBoundVariable(Record.ReadSubExpr()); + D->setPrevUpperBoundVariable(Record.ReadSubExpr()); } SmallVector Sub; unsigned CollapsedNum = D->getCollapsedNumber(); Sub.reserve(CollapsedNum); for (unsigned i = 0; i < CollapsedNum; ++i) - Sub.push_back(Reader.ReadSubExpr()); + Sub.push_back(Record.ReadSubExpr()); D->setCounters(Sub); Sub.clear(); for (unsigned i = 0; i < CollapsedNum; ++i) - Sub.push_back(Reader.ReadSubExpr()); + Sub.push_back(Record.ReadSubExpr()); D->setPrivateCounters(Sub); Sub.clear(); for (unsigned i = 0; i < CollapsedNum; ++i) - Sub.push_back(Reader.ReadSubExpr()); + Sub.push_back(Record.ReadSubExpr()); D->setInits(Sub); Sub.clear(); for (unsigned i = 0; i < CollapsedNum; ++i) - Sub.push_back(Reader.ReadSubExpr()); + Sub.push_back(Record.ReadSubExpr()); D->setUpdates(Sub); Sub.clear(); for (unsigned i = 0; i < CollapsedNum; ++i) - Sub.push_back(Reader.ReadSubExpr()); + Sub.push_back(Record.ReadSubExpr()); D->setFinals(Sub); } @@ -2684,7 +2653,7 @@ // The NumClauses field was read in ReadStmtFromStream. ++Idx; VisitOMPExecutableDirective(D); - ReadDeclarationNameInfo(D->DirName, Record, Idx); + ReadDeclarationNameInfo(D->DirName); } void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) { @@ -2753,10 +2722,10 @@ // The NumClauses field was read in ReadStmtFromStream. ++Idx; VisitOMPExecutableDirective(D); - D->setX(Reader.ReadSubExpr()); - D->setV(Reader.ReadSubExpr()); - D->setExpr(Reader.ReadSubExpr()); - D->setUpdateExpr(Reader.ReadSubExpr()); + 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; } @@ -2921,7 +2890,7 @@ ReadingKindTracker ReadingKind(Read_Stmt, *this); llvm::BitstreamCursor &Cursor = F.DeclsCursor; - + // Map of offset to previously deserialized stmt. The offset points /// just after the stmt record. llvm::DenseMap StmtEntries; @@ -2937,7 +2906,7 @@ while (true) { llvm::BitstreamEntry Entry = Cursor.advanceSkippingSubblocks(); - + switch (Entry.Kind) { case llvm::BitstreamEntry::SubBlock: // Handled for us already. case llvm::BitstreamEntry::Error: @@ -3102,11 +3071,11 @@ break; case EXPR_OFFSETOF: - S = OffsetOfExpr::CreateEmpty(Context, + S = OffsetOfExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields], Record[ASTStmtReader::NumExprFields + 1]); break; - + case EXPR_SIZEOF_ALIGN_OF: S = new (Context) UnaryExprOrTypeTraitExpr(Empty); break; @@ -3332,7 +3301,7 @@ S = new (Context) ObjCAtFinallyStmt(Empty); break; case STMT_OBJC_AT_TRY: - S = ObjCAtTryStmt::CreateEmpty(Context, + S = ObjCAtTryStmt::CreateEmpty(Context, Record[ASTStmtReader::NumStmtFields], Record[ASTStmtReader::NumStmtFields + 1]); break;