From c4808b9e0ada45aaef7f103f50a714c79f4ff2d5 Mon Sep 17 00:00:00 2001 From: "David L. Jones" Date: Thu, 15 Dec 2016 20:53:26 +0000 Subject: [PATCH] Add a class ASTRecordReader which wraps an ASTReader, a RecordData, and ModuleFile. Summary: When reading an ASTRecord, each RecordData is logically contained within a single ModuleFile, and global(er) state is contained by a single ASTReader. This means that any operations that read from a RecordData and reference an ASTReader or a ModuleFile, will always reference the same ASTReader or ModuleFile. ASTRecordReader groups these together so that parameters don't need to be duplicated ad infinitum. Most uses of the Idx variable seem to be redunant aliases as well, but I'll leave that for now. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27784 llvm-svn: 289870 --- clang/include/clang/Serialization/ASTReader.h | 279 ++++- clang/lib/Serialization/ASTReader.cpp | 587 +++++----- clang/lib/Serialization/ASTReaderDecl.cpp | 681 ++++++----- clang/lib/Serialization/ASTReaderStmt.cpp | 1557 ++++++++++++------------- 4 files changed, 1655 insertions(+), 1449 deletions(-) diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h index 38e252e..6f1a6ac 100644 --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/include/clang/Serialization/ASTReader.h @@ -356,7 +356,7 @@ public: /// \brief The AST file has errors. HadErrors }; - + /// \brief Types of AST files. friend class PCHValidator; friend class ASTDeclReader; @@ -364,6 +364,7 @@ public: 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 @@ public: /// 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,280 @@ public: 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) {} + + /// \brief The length of this record. + size_t size() const { return Record->size(); } + /// \brief An arbitrary index in this record. + const uint64_t &operator[](size_t N) { return (*Record)[N]; } + /// \brief The last element in this record. + const uint64_t &back() const { return Record->back(); } + + /// \brief 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 { diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 656298b..8d6735c 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -735,7 +735,7 @@ ASTSelectorLookupTrait::ReadKeyDataLength(const unsigned char*& d) { return std::make_pair(KeyLen, DataLen); } -ASTSelectorLookupTrait::internal_key_type +ASTSelectorLookupTrait::internal_key_type ASTSelectorLookupTrait::ReadKey(const unsigned char* d, unsigned) { using namespace llvm::support; SelectorTable &SelTable = Reader.getContext().Selectors; @@ -756,8 +756,8 @@ ASTSelectorLookupTrait::ReadKey(const unsigned char* d, unsigned) { return SelTable.getSelector(N, Args.data()); } -ASTSelectorLookupTrait::data_type -ASTSelectorLookupTrait::ReadData(Selector, const unsigned char* d, +ASTSelectorLookupTrait::data_type +ASTSelectorLookupTrait::ReadData(Selector, const unsigned char* d, unsigned DataLen) { using namespace llvm::support; @@ -1196,7 +1196,7 @@ bool ASTReader::ReadSourceManagerBlock(ModuleFile &F) { RecordData Record; while (true) { llvm::BitstreamEntry E = SLocEntryCursor.advanceSkippingSubblocks(); - + switch (E.Kind) { case llvm::BitstreamEntry::SubBlock: // Handled for us already. case llvm::BitstreamEntry::Error: @@ -1208,7 +1208,7 @@ bool ASTReader::ReadSourceManagerBlock(ModuleFile &F) { // The interesting case. break; } - + // Read a record. Record.clear(); StringRef Blob; @@ -1304,7 +1304,7 @@ bool ASTReader::ReadSLocEntry(int ID) { Error("incorrectly-formatted source location entry in AST file"); return true; } - + RecordData Record; StringRef Blob; switch (SLocEntryCursor.readRecord(Entry.ID, Record, &Blob)) { @@ -1420,7 +1420,7 @@ std::pair ASTReader::getModuleImportLoc(int ID) { SourceLocation ASTReader::getImportLocation(ModuleFile *F) { if (F->ImportLoc.isValid()) return F->ImportLoc; - + // Otherwise we have a PCH. It's considered to be "imported" at the first // location of its includer. if (F->ImportedBy.empty() || !F->ImportedBy[0]) { @@ -1482,7 +1482,7 @@ MacroInfo *ASTReader::ReadMacroRecord(ModuleFile &F, uint64_t Offset) { // be able to reseek within the block and read entries. unsigned Flags = BitstreamCursor::AF_DontPopBlockAtEnd; llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks(Flags); - + switch (Entry.Kind) { case llvm::BitstreamEntry::SubBlock: // Handled for us already. case llvm::BitstreamEntry::Error: @@ -1574,13 +1574,13 @@ MacroInfo *ASTReader::ReadMacroRecord(ModuleFile &F, uint64_t Offset) { } } -PreprocessedEntityID +PreprocessedEntityID ASTReader::getGlobalPreprocessedEntityID(ModuleFile &M, unsigned LocalID) const { - ContinuousRangeMap::const_iterator + ContinuousRangeMap::const_iterator I = M.PreprocessedEntityRemap.find(LocalID - NUM_PREDEF_PP_ENTITY_IDS); - assert(I != M.PreprocessedEntityRemap.end() + assert(I != M.PreprocessedEntityRemap.end() && "Invalid index into preprocessed entity index remap"); - + return LocalID + I->second; } @@ -1588,21 +1588,21 @@ unsigned HeaderFileInfoTrait::ComputeHash(internal_key_ref ikey) { return llvm::hash_combine(ikey.Size, ikey.ModTime); } -HeaderFileInfoTrait::internal_key_type +HeaderFileInfoTrait::internal_key_type HeaderFileInfoTrait::GetInternalKey(const FileEntry *FE) { internal_key_type ikey = {FE->getSize(), M.HasTimestamps ? FE->getModificationTime() : 0, FE->getName(), /*Imported*/ false}; return ikey; } - + bool HeaderFileInfoTrait::EqualKey(internal_key_ref a, internal_key_ref b) { if (a.Size != b.Size || (a.ModTime && b.ModTime && a.ModTime != b.ModTime)) return false; if (llvm::sys::path::is_absolute(a.Filename) && a.Filename == b.Filename) return true; - + // Determine whether the actual files are equivalent. FileManager &FileMgr = Reader.getFileManager(); auto GetFile = [&](const internal_key_type &Key) -> const FileEntry* { @@ -1618,7 +1618,7 @@ bool HeaderFileInfoTrait::EqualKey(internal_key_ref a, internal_key_ref b) { const FileEntry *FEB = GetFile(b); return FEA && FEA == FEB; } - + std::pair HeaderFileInfoTrait::ReadKeyDataLength(const unsigned char*& d) { using namespace llvm::support; @@ -1638,7 +1638,7 @@ HeaderFileInfoTrait::ReadKey(const unsigned char *d, unsigned) { return ikey; } -HeaderFileInfoTrait::data_type +HeaderFileInfoTrait::data_type HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d, unsigned DataLen) { const unsigned char *End = d + DataLen; @@ -1658,7 +1658,7 @@ HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d, M, endian::readNext(d)); if (unsigned FrameworkOffset = endian::readNext(d)) { - // The framework offset is 1 greater than the actual offset, + // The framework offset is 1 greater than the actual offset, // since 0 is used as an indicator for "no framework name". StringRef FrameworkName(FrameworkStrings + FrameworkOffset - 1); HFI.Framework = HS->getUniqueFrameworkName(FrameworkName); @@ -1720,7 +1720,7 @@ void ASTReader::ReadDefinedMacros() { RecordData Record; while (true) { llvm::BitstreamEntry E = Cursor.advanceSkippingSubblocks(); - + switch (E.Kind) { case llvm::BitstreamEntry::SubBlock: // Handled for us already. case llvm::BitstreamEntry::Error: @@ -1728,13 +1728,13 @@ void ASTReader::ReadDefinedMacros() { return; case llvm::BitstreamEntry::EndBlock: goto NextCursor; - + case llvm::BitstreamEntry::Record: Record.clear(); switch (Cursor.readRecord(E.ID, Record)) { default: // Default behavior: ignore. break; - + case PP_MACRO_OBJECT_LIKE: case PP_MACRO_FUNCTION_LIKE: { IdentifierInfo *II = getLocalIdentifier(*I, Record[0]); @@ -1742,7 +1742,7 @@ void ASTReader::ReadDefinedMacros() { updateOutOfDateIdentifier(*II); break; } - + case PP_TOKEN: // Ignore tokens. break; @@ -1794,7 +1794,7 @@ namespace { IdTable->find_hashed(Name, NameHash, &Trait); if (Pos == IdTable->end()) return false; - + // Dereferencing the iterator has the effect of building the // IdentifierInfo node and populating it with the various // declarations it needs. @@ -1802,7 +1802,7 @@ namespace { Found = *Pos; return true; } - + // \brief Retrieve the identifier info found within the module // files. IdentifierInfo *getIdentifierInfo() const { return Found; } @@ -1838,7 +1838,7 @@ void ASTReader::updateOutOfDateIdentifier(IdentifierInfo &II) { void ASTReader::markIdentifierUpToDate(IdentifierInfo *II) { if (!II) return; - + II->setOutOfDate(false); // Update the generation for this identifier. @@ -2000,7 +2000,7 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) { BitstreamCursor &Cursor = F.InputFilesCursor; SavedStreamPosition SavedPosition(Cursor); Cursor.JumpToBit(F.InputFileOffsets[ID-1]); - + InputFileInfo FI = readInputFileInfo(F, ID); off_t StoredSize = FI.StoredSize; time_t StoredTime = FI.StoredTime; @@ -2158,7 +2158,7 @@ ASTReader::ASTReadResult ASTReader::ReadOptionsBlock( ASTReadResult Result = Success; while (true) { llvm::BitstreamEntry Entry = Stream.advance(); - + switch (Entry.Kind) { case llvm::BitstreamEntry::Error: case llvm::BitstreamEntry::SubBlock: @@ -2246,7 +2246,7 @@ ASTReader::ReadControlBlock(ModuleFile &F, unsigned NumUserInputs = 0; while (true) { llvm::BitstreamEntry Entry = Stream.advance(); - + switch (Entry.Kind) { case llvm::BitstreamEntry::Error: Error("malformed block record in AST file"); @@ -2349,7 +2349,7 @@ ASTReader::ReadControlBlock(ModuleFile &F, return Failure; } continue; - + default: if (Stream.SkipBlock()) { Error("malformed block record in AST file"); @@ -2357,7 +2357,7 @@ ASTReader::ReadControlBlock(ModuleFile &F, } continue; } - + case llvm::BitstreamEntry::Record: // The interesting case. break; @@ -2409,7 +2409,7 @@ ASTReader::ReadControlBlock(ModuleFile &F, break; case IMPORTS: { - // Load each of the imported PCH files. + // Load each of the imported PCH files. unsigned Idx = 0, N = Record.size(); while (Idx < N) { // Read information about the AST file. @@ -2531,7 +2531,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { RecordData Record; while (true) { llvm::BitstreamEntry Entry = Stream.advance(); - + switch (Entry.Kind) { case llvm::BitstreamEntry::Error: Error("error at end of module block in AST file"); @@ -2546,7 +2546,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { if (DC->hasExternalLexicalStorage() && !getContext().getLangOpts().CPlusPlus) DC->setMustBuildLookupTable(); - + return Success; } case llvm::BitstreamEntry::SubBlock: @@ -2569,7 +2569,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { F.MacroCursor = Stream; if (!PP.getExternalSource()) PP.setExternalSource(this); - + if (Stream.SkipBlock() || ReadBlockAbbrevs(F.MacroCursor, PREPROCESSOR_BLOCK_ID)) { Error("malformed block record in AST file"); @@ -2577,7 +2577,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { } F.MacroStartOffset = F.MacroCursor.GetCurrentBitNo(); break; - + case PREPROCESSOR_DETAIL_BLOCK_ID: F.PreprocessorDetailCursor = Stream; if (Stream.SkipBlock() || @@ -2588,23 +2588,23 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { } F.PreprocessorDetailStartOffset = F.PreprocessorDetailCursor.GetCurrentBitNo(); - + if (!PP.getPreprocessingRecord()) PP.createPreprocessingRecord(); if (!PP.getPreprocessingRecord()->getExternalSource()) PP.getPreprocessingRecord()->SetExternalSource(*this); break; - + case SOURCE_MANAGER_BLOCK_ID: if (ReadSourceManagerBlock(F)) return Failure; break; - + case SUBMODULE_BLOCK_ID: if (ASTReadResult Result = ReadSubmoduleBlock(F, ClientLoadCapabilities)) return Result; break; - + case COMMENTS_BLOCK_ID: { BitstreamCursor C = Stream; if (Stream.SkipBlock() || @@ -2615,7 +2615,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { CommentsCursors.push_back(std::make_pair(C, &F)); break; } - + default: if (Stream.SkipBlock()) { Error("malformed block record in AST file"); @@ -2624,7 +2624,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { break; } continue; - + case llvm::BitstreamEntry::Record: // The interesting case. break; @@ -2646,21 +2646,21 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { F.LocalNumTypes = Record[0]; unsigned LocalBaseTypeIndex = Record[1]; F.BaseTypeIndex = getTotalNumTypes(); - + if (F.LocalNumTypes > 0) { // Introduce the global -> local mapping for types within this module. GlobalTypeMap.insert(std::make_pair(getTotalNumTypes(), &F)); - + // Introduce the local -> global mapping for types within this module. F.TypeRemap.insertOrReplace( - std::make_pair(LocalBaseTypeIndex, + std::make_pair(LocalBaseTypeIndex, F.BaseTypeIndex - LocalBaseTypeIndex)); TypesLoaded.resize(TypesLoaded.size() + F.LocalNumTypes); } break; } - + case DECL_OFFSET: { if (F.LocalNumDecls != 0) { Error("duplicate DECL_OFFSET record in AST file"); @@ -2670,18 +2670,18 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { F.LocalNumDecls = Record[0]; unsigned LocalBaseDeclID = Record[1]; F.BaseDeclID = getTotalNumDecls(); - + if (F.LocalNumDecls > 0) { - // Introduce the global -> local mapping for declarations within this + // Introduce the global -> local mapping for declarations within this // module. GlobalDeclMap.insert( std::make_pair(getTotalNumDecls() + NUM_PREDEF_DECL_IDS, &F)); - + // Introduce the local -> global mapping for declarations within this // module. F.DeclRemap.insertOrReplace( std::make_pair(LocalBaseDeclID, F.BaseDeclID - LocalBaseDeclID)); - + // Introduce the global -> local mapping for declarations within this // module. F.GlobalToLocalDeclIDs[&F] = LocalBaseDeclID; @@ -2690,7 +2690,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { } break; } - + case TU_UPDATE_LEXICAL: { DeclContext *TU = Context.getTranslationUnitDecl(); LexicalContents Contents( @@ -2722,7 +2722,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { (const unsigned char *)F.IdentifierTableData + sizeof(uint32_t), (const unsigned char *)F.IdentifierTableData, ASTIdentifierLookupTrait(*this, F)); - + PP.getIdentifierTable().setExternalIdentifierLookup(this); } break; @@ -2736,13 +2736,13 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { F.LocalNumIdentifiers = Record[0]; unsigned LocalBaseIdentifierID = Record[1]; F.BaseIdentifierID = getTotalNumIdentifiers(); - + if (F.LocalNumIdentifiers > 0) { // Introduce the global -> local mapping for identifiers within this // module. - GlobalIdentifierMap.insert(std::make_pair(getTotalNumIdentifiers() + 1, + GlobalIdentifierMap.insert(std::make_pair(getTotalNumIdentifiers() + 1, &F)); - + // Introduce the local -> global mapping for identifiers within this // module. F.IdentifierRemap.insertOrReplace( @@ -2809,11 +2809,11 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { Error("invalid weak identifiers record"); return Failure; } - - // FIXME: Ignore weak undeclared identifiers from non-original PCH + + // FIXME: Ignore weak undeclared identifiers from non-original PCH // files. This isn't the way to do it :) WeakUndeclaredIdentifiers.clear(); - + // Translate the weak, undeclared identifiers into global IDs. for (unsigned I = 0, N = Record.size(); I < N; /* in loop */) { WeakUndeclaredIdentifiers.push_back( @@ -2831,13 +2831,13 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { F.LocalNumSelectors = Record[0]; unsigned LocalBaseSelectorID = Record[1]; F.BaseSelectorID = getTotalNumSelectors(); - + if (F.LocalNumSelectors > 0) { - // Introduce the global -> local mapping for selectors within this + // Introduce the global -> local mapping for selectors within this // module. GlobalSelectorMap.insert(std::make_pair(getTotalNumSelectors()+1, &F)); - - // Introduce the local -> global mapping for selectors within this + + // Introduce the local -> global mapping for selectors within this // module. F.SelectorRemap.insertOrReplace( std::make_pair(LocalBaseSelectorID, @@ -2847,7 +2847,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { } break; } - + case METHOD_POOL: F.SelectorLookupTableData = (const unsigned char *)Blob.data(); if (Record[0]) @@ -2862,7 +2862,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { case REFERENCED_SELECTOR_POOL: if (!Record.empty()) { for (unsigned Idx = 0, N = Record.size() - 1; Idx < N; /* in loop */) { - ReferencedSelectorsData.push_back(getGlobalSelectorID(F, + ReferencedSelectorsData.push_back(getGlobalSelectorID(F, Record[Idx++])); ReferencedSelectorsData.push_back(ReadSourceLocation(F, Record, Idx). getRawEncoding()); @@ -2874,7 +2874,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { if (!Record.empty() && Listener) Listener->ReadCounter(F, Record[0]); break; - + case FILE_SORTED_DECLS: F.FileSortedDecls = (const DeclID *)Blob.data(); F.NumFileSortedDecls = Record[0]; @@ -2911,7 +2911,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { // This module. Base was 2 when being compiled. F.SLocRemap.insertOrReplace(std::make_pair(2U, static_cast(F.SLocEntryBaseOffset - 2))); - + TotalNumSLocEntries += F.LocalNumSLocEntries; break; } @@ -3003,7 +3003,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { Error("Multiple SOURCE_LOCATION_PRELOADS records in AST file"); return Failure; } - + F.PreloadSLocEntries.swap(Record); break; } @@ -3018,12 +3018,12 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { Error("Invalid VTABLE_USES record"); return Failure; } - + // Later tables overwrite earlier ones. // FIXME: Modules will have some trouble with this. This is clearly not // the right way to do this. VTableUses.clear(); - + for (unsigned Idx = 0, N = Record.size(); Idx != N; /* In loop */) { VTableUses.push_back(getGlobalDeclID(F, Record[Idx++])); VTableUses.push_back( @@ -3065,13 +3065,13 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { F.NumPreprocessedEntities = Blob.size() / sizeof(PPEntityOffset); unsigned LocalBasePreprocessedEntityID = Record[0]; - + unsigned StartingID; if (!PP.getPreprocessingRecord()) PP.createPreprocessingRecord(); if (!PP.getPreprocessingRecord()->getExternalSource()) PP.getPreprocessingRecord()->SetExternalSource(*this); - StartingID + StartingID = PP.getPreprocessingRecord() ->allocateLoadedEntities(F.NumPreprocessedEntities); F.BasePreprocessedEntityID = StartingID; @@ -3080,7 +3080,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { // Introduce the global -> local mapping for preprocessed entities in // this module. GlobalPreprocessedEntityMap.insert(std::make_pair(StartingID, &F)); - + // Introduce the local -> global mapping for preprocessed entities in // this module. F.PreprocessedEntityRemap.insertOrReplace( @@ -3090,7 +3090,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { break; } - + case DECL_UPDATE_OFFSETS: { if (Record.size() % 2 != 0) { Error("invalid DECL_UPDATE_OFFSETS block in AST file"); @@ -3113,12 +3113,12 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { Error("duplicate OBJC_CATEGORIES_MAP record in AST file"); return Failure; } - + F.LocalNumObjCCategoriesInMap = Record[0]; F.ObjCCategoriesMap = (const ObjCCategoriesInfo *)Blob.data(); break; } - + case OBJC_CATEGORIES: F.ObjCCategories.swap(Record); break; @@ -3130,7 +3130,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { F.PragmaDiagMappings.insert(F.PragmaDiagMappings.end(), Record.begin(), Record.end()); break; - + case CUDA_SPECIAL_DECL_REFS: // Later tables overwrite earlier ones. // FIXME: Modules will have trouble with this. @@ -3147,17 +3147,17 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { = HeaderFileInfoLookupTable::Create( (const unsigned char *)F.HeaderFileInfoTableData + Record[0], (const unsigned char *)F.HeaderFileInfoTableData, - HeaderFileInfoTrait(*this, F, + HeaderFileInfoTrait(*this, F, &PP.getHeaderSearchInfo(), Blob.data() + Record[2])); - + PP.getHeaderSearchInfo().SetExternalSource(this); if (!PP.getHeaderSearchInfo().getExternalLookup()) PP.getHeaderSearchInfo().SetExternalLookup(this); } break; } - + case FP_PRAGMA_OPTIONS: // Later tables overwrite earlier ones. FPPragmaOptions.swap(Record); @@ -3172,7 +3172,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { for (unsigned I = 0, N = Record.size(); I != N; ++I) TentativeDefinitions.push_back(getGlobalDeclID(F, Record[I])); break; - + case KNOWN_NAMESPACES: for (unsigned I = 0, N = Record.size(); I != N; ++I) KnownNamespaces.push_back(getGlobalDeclID(F, Record[I])); @@ -3515,7 +3515,7 @@ bool ASTReader::loadGlobalIndex() { if (TriedLoadingGlobalIndex || !UseGlobalIndex || !Context.getLangOpts().Modules) return true; - + // Try to load the global index. TriedLoadingGlobalIndex = true; StringRef ModuleCachePath @@ -3639,12 +3639,12 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName, return Result; } - // Once read, set the ModuleFile bit base offset and update the size in + // Once read, set the ModuleFile bit base offset and update the size in // bits of all files we've seen. F.GlobalBitOffset = TotalModulesSizeInBits; TotalModulesSizeInBits += F.SizeInBits; GlobalBitOffsetsMap.insert(std::make_pair(F.GlobalBitOffset, &F)); - + // Preload SLocEntries. for (unsigned I = 0, N = F.PreloadSLocEntries.size(); I != N; ++I) { int Index = int(F.PreloadSLocEntries[I] - 1) + F.SLocEntryBaseID; @@ -3714,7 +3714,7 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName, // Mark selectors as out of date. for (auto Sel : SelectorGeneration) SelectorOutOfDate[Sel.first] = true; - + // Resolve any unresolved module exports. for (unsigned I = 0, N = UnresolvedModuleRefs.size(); I != N; ++I) { UnresolvedModuleRef &Unresolved = UnresolvedModuleRefs[I]; @@ -3752,7 +3752,7 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName, // FIXME: How do we load the 'use'd modules? They may not be submodules. // Might be unnecessary as use declarations are only used to build the // module itself. - + InitializeContext(); if (SemaObj) @@ -3763,7 +3763,7 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName, ModuleFile &PrimaryModule = ModuleMgr.getPrimaryModule(); if (PrimaryModule.OriginalSourceFileID.isValid()) { - PrimaryModule.OriginalSourceFileID + PrimaryModule.OriginalSourceFileID = FileID::get(PrimaryModule.SLocEntryBaseID + PrimaryModule.OriginalSourceFileID.getOpaqueValue() - 1); @@ -3776,11 +3776,11 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName, SourceMgr.setMainFileID(PrimaryModule.OriginalSourceFileID); } } - + // For any Objective-C class definitions we have already loaded, make sure // that we load any additional categories. for (unsigned I = 0, N = ObjCClassesLoaded.size(); I != N; ++I) { - loadObjCCategories(ObjCClassesLoaded[I]->getGlobalID(), + loadObjCCategories(ObjCClassesLoaded[I]->getGlobalID(), ObjCClassesLoaded[I], PreviousGeneration); } @@ -3892,7 +3892,7 @@ ASTReader::ReadASTCore(StringRef FileName, BitstreamCursor &Stream = F.Stream; Stream = BitstreamCursor(PCHContainerRdr.ExtractPCH(*F.Buffer)); F.SizeInBits = F.Buffer->getBufferSize() * 8; - + // Sniff for the signature. if (!startsWithASTFileMagic(Stream)) { Diag(diag::err_module_file_invalid) << moduleKindForDiagnostic(Type) @@ -3904,14 +3904,14 @@ ASTReader::ReadASTCore(StringRef FileName, bool HaveReadControlBlock = false; while (true) { llvm::BitstreamEntry Entry = Stream.advance(); - + switch (Entry.Kind) { case llvm::BitstreamEntry::Error: case llvm::BitstreamEntry::Record: case llvm::BitstreamEntry::EndBlock: Error("invalid record at top-level of AST file"); return Failure; - + case llvm::BitstreamEntry::SubBlock: break; } @@ -4042,26 +4042,26 @@ ASTReader::ASTReadResult ASTReader::ReadExtensionBlock(ModuleFile &F) { void ASTReader::InitializeContext() { // If there's a listener, notify them that we "read" the translation unit. if (DeserializationListener) - DeserializationListener->DeclRead(PREDEF_DECL_TRANSLATION_UNIT_ID, + DeserializationListener->DeclRead(PREDEF_DECL_TRANSLATION_UNIT_ID, Context.getTranslationUnitDecl()); // FIXME: Find a better way to deal with collisions between these // built-in types. Right now, we just ignore the problem. - + // Load the special types. if (SpecialTypes.size() >= NumSpecialTypeIDs) { if (unsigned String = SpecialTypes[SPECIAL_TYPE_CF_CONSTANT_STRING]) { if (!Context.CFConstantStringTypeDecl) Context.setCFConstantStringType(GetType(String)); } - + if (unsigned File = SpecialTypes[SPECIAL_TYPE_FILE]) { QualType FileType = GetType(File); if (FileType.isNull()) { Error("FILE type is NULL"); return; } - + if (!Context.FILEDecl) { if (const TypedefType *Typedef = FileType->getAs()) Context.setFILEDecl(Typedef->getDecl()); @@ -4075,14 +4075,14 @@ void ASTReader::InitializeContext() { } } } - + if (unsigned Jmp_buf = SpecialTypes[SPECIAL_TYPE_JMP_BUF]) { QualType Jmp_bufType = GetType(Jmp_buf); if (Jmp_bufType.isNull()) { Error("jmp_buf type is NULL"); return; } - + if (!Context.jmp_bufDecl) { if (const TypedefType *Typedef = Jmp_bufType->getAs()) Context.setjmp_bufDecl(Typedef->getDecl()); @@ -4096,14 +4096,14 @@ void ASTReader::InitializeContext() { } } } - + if (unsigned Sigjmp_buf = SpecialTypes[SPECIAL_TYPE_SIGJMP_BUF]) { QualType Sigjmp_bufType = GetType(Sigjmp_buf); if (Sigjmp_bufType.isNull()) { Error("sigjmp_buf type is NULL"); return; } - + if (!Context.sigjmp_bufDecl) { if (const TypedefType *Typedef = Sigjmp_bufType->getAs()) Context.setsigjmp_bufDecl(Typedef->getDecl()); @@ -4151,7 +4151,7 @@ void ASTReader::InitializeContext() { } } } - + ReadPragmaDiagnosticMappings(Context.getDiagnostics()); // If there were any CUDA special declarations, deserialize them. @@ -4226,7 +4226,7 @@ std::string ASTReader::getOriginalSourceFile( Diags.Report(diag::err_fe_not_a_pch_file) << ASTFileName; return std::string(); } - + // Scan for the CONTROL_BLOCK_ID block. if (SkipCursorToBlock(Stream, CONTROL_BLOCK_ID)) { Diags.Report(diag::err_fe_pch_malformed_block) << ASTFileName; @@ -4239,12 +4239,12 @@ std::string ASTReader::getOriginalSourceFile( llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks(); if (Entry.Kind == llvm::BitstreamEntry::EndBlock) return std::string(); - + if (Entry.Kind != llvm::BitstreamEntry::Record) { Diags.Report(diag::err_fe_pch_malformed_block) << ASTFileName; return std::string(); } - + Record.clear(); StringRef Blob; if (Stream.readRecord(Entry.ID, Record, &Blob) == ORIGINAL_FILE) @@ -4393,7 +4393,7 @@ bool ASTReader::readASTFileControlBlock( if (Listener.ReadFullVersionInformation(Blob)) return true; - + break; } case MODULE_NAME: @@ -4539,7 +4539,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { RecordData Record; while (true) { llvm::BitstreamEntry Entry = F.Stream.advanceSkippingSubblocks(); - + switch (Entry.Kind) { case llvm::BitstreamEntry::SubBlock: // Handled for us already. case llvm::BitstreamEntry::Error: @@ -4637,7 +4637,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { CurrentModule->ConfigMacrosExhaustive = ConfigMacrosExhaustive; if (DeserializationListener) DeserializationListener->ModuleRead(GlobalID, CurrentModule); - + SubmodulesLoaded[GlobalIndex] = CurrentModule; // Clear out data that will be replaced by what is in the module file. @@ -4677,7 +4677,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { } break; } - + case SUBMODULE_HEADER: case SUBMODULE_EXCLUDED_HEADER: case SUBMODULE_PRIVATE_HEADER: @@ -4711,17 +4711,17 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { } break; } - + case SUBMODULE_METADATA: { F.BaseSubmoduleID = getTotalNumSubmodules(); F.LocalNumSubmodules = Record[0]; unsigned LocalBaseSubmoduleID = Record[1]; if (F.LocalNumSubmodules > 0) { - // Introduce the global -> local mapping for submodules within this + // Introduce the global -> local mapping for submodules within this // module. GlobalSubmoduleMap.insert(std::make_pair(getTotalNumSubmodules()+1,&F)); - - // Introduce the local -> global mapping for submodules within this + + // Introduce the local -> global mapping for submodules within this // module. F.SubmoduleRemap.insertOrReplace( std::make_pair(LocalBaseSubmoduleID, @@ -4731,7 +4731,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { } break; } - + case SUBMODULE_IMPORTS: { for (unsigned Idx = 0; Idx != Record.size(); ++Idx) { UnresolvedModuleRef Unresolved; @@ -4755,8 +4755,8 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { Unresolved.IsWildcard = Record[Idx + 1]; UnresolvedModuleRefs.push_back(Unresolved); } - - // Once we've loaded the set of exports, there's no reason to keep + + // Once we've loaded the set of exports, there's no reason to keep // the parsed, unresolved exports around. CurrentModule->UnresolvedExports.clear(); break; @@ -4969,7 +4969,7 @@ std::pair ASTReader::getModulePreprocessedEntity(unsigned GlobalIndex) { GlobalPreprocessedEntityMapType::iterator I = GlobalPreprocessedEntityMap.find(GlobalIndex); - assert(I != GlobalPreprocessedEntityMap.end() && + assert(I != GlobalPreprocessedEntityMap.end() && "Corrupted global preprocessed entity map"); ModuleFile *M = I->second; unsigned LocalIndex = GlobalIndex - M->BasePreprocessedEntityID; @@ -5005,8 +5005,8 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) { Error("no preprocessing record"); return nullptr; } - - SavedStreamPosition SavedPosition(M.PreprocessorDetailCursor); + + SavedStreamPosition SavedPosition(M.PreprocessorDetailCursor); M.PreprocessorDetailCursor.JumpToBit(PPOffs.BitOffset); llvm::BitstreamEntry Entry = @@ -5045,7 +5045,7 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) { return ME; } - + case PPD_MACRO_DEFINITION: { // Decode the identifier info and then check again; if the macro is // still defined and associated with the identifier, @@ -5057,14 +5057,14 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) { return MD; } - + case PPD_INCLUSION_DIRECTIVE: { const char *FullFileNameStart = Blob.data() + Record[0]; StringRef FullFileName(FullFileNameStart, Blob.size() - Record[0]); const FileEntry *File = nullptr; if (!FullFileName.empty()) File = PP.getFileManager().getFile(FullFileName); - + // FIXME: Stable encoding InclusionDirective::InclusionKind Kind = static_cast(Record[2]); @@ -5205,11 +5205,11 @@ Optional ASTReader::isPreprocessedEntityInFileID(unsigned Index, ModuleFile &M = *PPInfo.first; unsigned LocalIndex = PPInfo.second; const PPEntityOffset &PPOffs = M.PreprocessedEntityOffsets[LocalIndex]; - + SourceLocation Loc = TranslateSourceLocation(M, PPOffs.getBegin()); if (Loc.isInvalid()) return false; - + if (SourceMgr.isInFileID(SourceMgr.getFileLoc(Loc), FID)) return true; else @@ -5221,9 +5221,9 @@ namespace { /// \brief Visitor used to search for information about a header file. class HeaderFileInfoVisitor { const FileEntry *FE; - + Optional HFI; - + public: explicit HeaderFileInfoVisitor(const FileEntry *FE) : FE(FE) { } @@ -5242,7 +5242,7 @@ namespace { HFI = *Pos; return true; } - + Optional getHeaderFileInfo() const { return HFI; } }; @@ -5253,7 +5253,7 @@ HeaderFileInfo ASTReader::GetHeaderFileInfo(const FileEntry *FE) { ModuleMgr.visit(Visitor); if (Optional HFI = Visitor.getHeaderFileInfo()) return *HFI; - + return HeaderFileInfo(); } @@ -5275,7 +5275,7 @@ void ASTReader::ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag) { FullSourceLoc(Loc, SourceMgr))); continue; } - + assert(DiagStateID == 0); // A new DiagState was created here. Diag.DiagStates.push_back(*Diag.GetCurDiagState()); @@ -5421,7 +5421,7 @@ QualType ASTReader::readTypeRecord(unsigned Index) { QualType ClassType = readType(*Loc.F, Record, Idx); if (PointeeType.isNull() || ClassType.isNull()) return QualType(); - + return Context.getMemberPointerType(PointeeType, ClassType.getTypePtr()); } @@ -5531,7 +5531,7 @@ QualType ASTReader::readTypeRecord(unsigned Index) { return Context.getTypeDeclType( ReadDeclAs(*Loc.F, Record, Idx)); } - + case TYPE_TYPEDEF: { if (Record.size() != 2) { Error("incorrect encoding of typedef type"); @@ -5836,26 +5836,17 @@ void ASTReader::readExceptionSpec(ModuleFile &ModuleFile, } 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,21 @@ void TypeLocReader::VisitQualifiedTypeLoc(QualifiedTypeLoc TL) { } 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[Idx++])); + TL.setWrittenSignSpec(static_cast(Reader[Idx++])); + TL.setWrittenWidthSpec(static_cast(Reader[Idx++])); + TL.setModeAttr(Reader[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 +5891,27 @@ void TypeLocReader::VisitAdjustedTypeLoc(AdjustedTypeLoc TL) { } 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[Idx++]) + TL.setSizeExpr(Reader.ReadExpr()); else TL.setSizeExpr(nullptr); } @@ -5944,24 +5935,24 @@ void TypeLocReader::VisitDependentSizedArrayTypeLoc( 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 +5964,160 @@ void TypeLocReader::VisitFunctionNoProtoTypeLoc(FunctionNoProtoTypeLoc TL) { 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[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[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, @@ -6322,18 +6311,18 @@ QualType ASTReader::getLocalType(ModuleFile &F, unsigned LocalID) { return GetType(getGlobalTypeID(F, LocalID)); } -serialization::TypeID +serialization::TypeID ASTReader::getGlobalTypeID(ModuleFile &F, unsigned LocalID) const { unsigned FastQuals = LocalID & Qualifiers::FastMask; unsigned LocalIndex = LocalID >> Qualifiers::FastWidth; - + if (LocalIndex < NUM_PREDEF_TYPE_IDS) return LocalID; ContinuousRangeMap::iterator I = F.TypeRemap.find(LocalIndex - NUM_PREDEF_TYPE_IDS); assert(I != F.TypeRemap.end() && "Invalid index into type index remap"); - + unsigned GlobalIndex = LocalIndex + I->second; return (GlobalIndex << Qualifiers::FastWidth) | FastQuals; } @@ -6349,18 +6338,18 @@ ASTReader::GetTemplateArgumentLocInfo(ModuleFile &F, case TemplateArgument::Type: return GetTypeSourceInfo(F, Record, Index); case TemplateArgument::Template: { - NestedNameSpecifierLoc QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, + NestedNameSpecifierLoc QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Index); SourceLocation TemplateNameLoc = ReadSourceLocation(F, Record, Index); return TemplateArgumentLocInfo(QualifierLoc, TemplateNameLoc, SourceLocation()); } case TemplateArgument::TemplateExpansion: { - NestedNameSpecifierLoc QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, + NestedNameSpecifierLoc QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Index); SourceLocation TemplateNameLoc = ReadSourceLocation(F, Record, Index); SourceLocation EllipsisLoc = ReadSourceLocation(F, Record, Index); - return TemplateArgumentLocInfo(QualifierLoc, TemplateNameLoc, + return TemplateArgumentLocInfo(QualifierLoc, TemplateNameLoc, EllipsisLoc); } case TemplateArgument::Null: @@ -6505,7 +6494,7 @@ CXXBaseSpecifier *ASTReader::GetExternalCXXBaseSpecifiers(uint64_t Offset) { return Bases; } -serialization::DeclID +serialization::DeclID ASTReader::getGlobalDeclID(ModuleFile &F, LocalDeclID LocalID) const { if (LocalID < NUM_PREDEF_DECL_IDS) return LocalID; @@ -6513,7 +6502,7 @@ ASTReader::getGlobalDeclID(ModuleFile &F, LocalDeclID LocalID) const { ContinuousRangeMap::iterator I = F.DeclRemap.find(LocalID - NUM_PREDEF_DECL_IDS); assert(I != F.DeclRemap.end() && "Invalid index into decl index remap"); - + return LocalID + I->second; } @@ -6523,7 +6512,7 @@ bool ASTReader::isDeclIDFromModule(serialization::GlobalDeclID ID, if (ID < NUM_PREDEF_DECL_IDS) return false; - return ID - NUM_PREDEF_DECL_IDS >= M.BaseDeclID && + return ID - NUM_PREDEF_DECL_IDS >= M.BaseDeclID && ID - NUM_PREDEF_DECL_IDS < M.BaseDeclID + M.LocalNumDecls; } @@ -6655,11 +6644,11 @@ Decl *ASTReader::GetDecl(DeclID ID) { return DeclsLoaded[Index]; } -DeclID ASTReader::mapGlobalIDToModuleFileGlobalID(ModuleFile &M, +DeclID ASTReader::mapGlobalIDToModuleFileGlobalID(ModuleFile &M, DeclID GlobalID) { if (GlobalID < NUM_PREDEF_DECL_IDS) return GlobalID; - + GlobalDeclMapType::const_iterator I = GlobalDeclMap.find(GlobalID); assert(I != GlobalDeclMap.end() && "Corrupted global declaration map"); ModuleFile *Owner = I->second; @@ -6668,18 +6657,18 @@ DeclID ASTReader::mapGlobalIDToModuleFileGlobalID(ModuleFile &M, = M.GlobalToLocalDeclIDs.find(Owner); if (Pos == M.GlobalToLocalDeclIDs.end()) return 0; - + return GlobalID - Owner->BaseDeclID + Pos->second; } -serialization::DeclID ASTReader::ReadDeclID(ModuleFile &F, +serialization::DeclID ASTReader::ReadDeclID(ModuleFile &F, const RecordData &Record, unsigned &Idx) { if (Idx >= Record.size()) { Error("Corrupted AST file"); return 0; } - + return getGlobalDeclID(F, Record[Idx++]); } @@ -6811,7 +6800,7 @@ void ASTReader::FindFileRegionDecls(FileID File, EndLoc, DIDComp); if (EndIt != DInfo.Decls.end()) ++EndIt; - + for (ArrayRef::iterator DIt = BeginIt; DIt != EndIt; ++DIt) Decls.push_back(GetDecl(getGlobalDeclID(*DInfo.Mod, *DIt))); @@ -7022,23 +7011,23 @@ void ASTReader::PrintStats() { std::fprintf(stderr, "\n"); GlobalIndex->printStats(); } - + std::fprintf(stderr, "\n"); dump(); std::fprintf(stderr, "\n"); } template -static void +static void dumpModuleIDMap(StringRef Name, - const ContinuousRangeMap &Map) { if (Map.begin() == Map.end()) return; - + typedef ContinuousRangeMap MapType; llvm::errs() << Name << ":\n"; - for (typename MapType::const_iterator I = Map.begin(), IEnd = Map.end(); + for (typename MapType::const_iterator I = Map.begin(), IEnd = Map.end(); I != IEnd; ++I) { llvm::errs() << " " << I->first << " -> " << I->second->FileName << "\n"; @@ -7055,11 +7044,11 @@ LLVM_DUMP_METHOD void ASTReader::dump() { dumpModuleIDMap("Global macro map", GlobalMacroMap); dumpModuleIDMap("Global submodule map", GlobalSubmoduleMap); dumpModuleIDMap("Global selector map", GlobalSelectorMap); - dumpModuleIDMap("Global preprocessed entity map", + dumpModuleIDMap("Global preprocessed entity map", GlobalPreprocessedEntityMap); - + llvm::errs() << "\n*** PCH/Modules Loaded:"; - for (ModuleManager::ModuleConstIterator M = ModuleMgr.begin(), + for (ModuleManager::ModuleConstIterator M = ModuleMgr.begin(), MEnd = ModuleMgr.end(); M != MEnd; ++M) (*M)->dump(); @@ -7309,7 +7298,7 @@ namespace serialization { bool operator()(ModuleFile &M) { if (!M.SelectorLookupTable) return false; - + // If we've already searched this module file, skip it now. if (M.Generation <= PriorGeneration) return true; @@ -7339,14 +7328,14 @@ namespace serialization { FactoryHasMoreThanOneDecl = Data.FactoryHasMoreThanOneDecl; return true; } - + /// \brief Retrieve the instance methods found by this visitor. - ArrayRef getInstanceMethods() const { - return InstanceMethods; + ArrayRef getInstanceMethods() const { + return InstanceMethods; } /// \brief Retrieve the instance methods found by this visitor. - ArrayRef getFactoryMethods() const { + ArrayRef getFactoryMethods() const { return FactoryMethods; } @@ -7368,14 +7357,14 @@ static void addMethodsToPool(Sema &S, ArrayRef Methods, S.addMethodToGlobalList(&List, Methods[I]); } } - + void ASTReader::ReadMethodPool(Selector Sel) { // Get the selector generation and update it to the current generation. unsigned &Generation = SelectorGeneration[Sel]; unsigned PriorGeneration = Generation; Generation = getGeneration(); SelectorOutOfDate[Sel] = false; - + // Search for methods defined with this selector. ++NumMethodPoolLookups; ReadMethodPoolVisitor Visitor(*this, Sel, PriorGeneration); @@ -7389,7 +7378,7 @@ void ASTReader::ReadMethodPool(Selector Sel) { if (!getSema()) return; - + Sema &S = *getSema(); Sema::GlobalMethodPool::iterator Pos = S.MethodPool.insert(std::make_pair(Sel, Sema::GlobalMethods())).first; @@ -7414,9 +7403,9 @@ void ASTReader::updateOutOfDateSelector(Selector Sel) { void ASTReader::ReadKnownNamespaces( SmallVectorImpl &Namespaces) { Namespaces.clear(); - + for (unsigned I = 0, N = KnownNamespaces.size(); I != N; ++I) { - if (NamespaceDecl *Namespace + if (NamespaceDecl *Namespace = dyn_cast_or_null(GetDecl(KnownNamespaces[I]))) Namespaces.push_back(Namespace); } @@ -7505,7 +7494,7 @@ void ASTReader::ReadReferencedSelectors( SmallVectorImpl > &Sels) { if (ReferencedSelectorsData.empty()) return; - + // If there are @selector references added them to its pool. This is for // implementation of -Wselector. unsigned int DataSize = ReferencedSelectorsData.size()-1; @@ -7525,9 +7514,9 @@ void ASTReader::ReadWeakUndeclaredIdentifiers( return; for (unsigned I = 0, N = WeakUndeclaredIdentifiers.size(); I < N; /*none*/) { - IdentifierInfo *WeakId + IdentifierInfo *WeakId = DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]); - IdentifierInfo *AliasId + IdentifierInfo *AliasId = DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]); SourceLocation Loc = SourceLocation::getFromRawEncoding(WeakUndeclaredIdentifiers[I++]); @@ -7547,7 +7536,7 @@ void ASTReader::ReadUsedVTables(SmallVectorImpl &VTables) { VT.DefinitionRequired = VTableUses[Idx++]; VTables.push_back(VT); } - + VTableUses.clear(); } @@ -7559,7 +7548,7 @@ void ASTReader::ReadPendingInstantiations( = SourceLocation::getFromRawEncoding(PendingInstantiations[Idx++]); Pending.push_back(std::make_pair(D, Loc)); - } + } PendingInstantiations.clear(); } @@ -7691,12 +7680,12 @@ IdentifierInfo *ASTReader::getLocalIdentifier(ModuleFile &M, unsigned LocalID) { IdentifierID ASTReader::getGlobalIdentifierID(ModuleFile &M, unsigned LocalID) { if (LocalID < NUM_PREDEF_IDENT_IDS) return LocalID; - + ContinuousRangeMap::iterator I = M.IdentifierRemap.find(LocalID - NUM_PREDEF_IDENT_IDS); - assert(I != M.IdentifierRemap.end() + assert(I != M.IdentifierRemap.end() && "Invalid index into identifier index remap"); - + return LocalID + I->second; } @@ -7717,7 +7706,7 @@ MacroInfo *ASTReader::getMacro(MacroID ID) { ModuleFile *M = I->second; unsigned Index = ID - M->BaseMacroID; MacrosLoaded[ID] = ReadMacroRecord(*M, M->MacroOffsets[Index]); - + if (DeserializationListener) DeserializationListener->MacroRead(ID + NUM_PREDEF_MACRO_IDS, MacrosLoaded[ID]); @@ -7741,12 +7730,12 @@ serialization::SubmoduleID ASTReader::getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID) { if (LocalID < NUM_PREDEF_SUBMODULE_IDS) return LocalID; - + ContinuousRangeMap::iterator I = M.SubmoduleRemap.find(LocalID - NUM_PREDEF_SUBMODULE_IDS); - assert(I != M.SubmoduleRemap.end() + assert(I != M.SubmoduleRemap.end() && "Invalid index into submodule index remap"); - + return LocalID + I->second; } @@ -7755,12 +7744,12 @@ Module *ASTReader::getSubmodule(SubmoduleID GlobalID) { assert(GlobalID == 0 && "Unhandled global submodule ID"); return nullptr; } - + if (GlobalID > SubmodulesLoaded.size()) { Error("submodule ID out of range in AST file"); return nullptr; } - + return SubmodulesLoaded[GlobalID - NUM_PREDEF_SUBMODULE_IDS]; } @@ -7857,17 +7846,17 @@ serialization::SelectorID ASTReader::getGlobalSelectorID(ModuleFile &M, unsigned LocalID) const { if (LocalID < NUM_PREDEF_SELECTOR_IDS) return LocalID; - + ContinuousRangeMap::iterator I = M.SelectorRemap.find(LocalID - NUM_PREDEF_SELECTOR_IDS); - assert(I != M.SelectorRemap.end() + assert(I != M.SelectorRemap.end() && "Invalid index into selector index remap"); - + return LocalID + I->second; } DeclarationName -ASTReader::ReadDeclarationName(ModuleFile &F, +ASTReader::ReadDeclarationName(ModuleFile &F, const RecordData &Record, unsigned &Idx) { DeclarationName::NameKind Kind = (DeclarationName::NameKind)Record[Idx++]; switch (Kind) { @@ -7961,7 +7950,7 @@ void ASTReader::ReadQualifierInfo(ModuleFile &F, QualifierInfo &Info, } TemplateName -ASTReader::ReadTemplateName(ModuleFile &F, const RecordData &Record, +ASTReader::ReadTemplateName(ModuleFile &F, const RecordData &Record, unsigned &Idx) { TemplateName::NameKind Kind = (TemplateName::NameKind)Record[Idx++]; switch (Kind) { @@ -7988,7 +7977,7 @@ ASTReader::ReadTemplateName(ModuleFile &F, const RecordData &Record, NestedNameSpecifier *NNS = ReadNestedNameSpecifier(F, Record, Idx); if (Record[Idx++]) // isIdentifier return Context.getDependentTemplateName(NNS, - GetIdentifierInfo(F, Record, + GetIdentifierInfo(F, Record, Idx)); return Context.getDependentTemplateName(NNS, (OverloadedOperatorKind)Record[Idx++]); @@ -8001,17 +7990,17 @@ ASTReader::ReadTemplateName(ModuleFile &F, const RecordData &Record, TemplateName replacement = ReadTemplateName(F, Record, Idx); return Context.getSubstTemplateTemplateParm(param, replacement); } - + case TemplateName::SubstTemplateTemplateParmPack: { - TemplateTemplateParmDecl *Param + TemplateTemplateParmDecl *Param = ReadDeclAs(F, Record, Idx); if (!Param) return TemplateName(); - + TemplateArgument ArgPack = ReadTemplateArgument(F, Record, Idx); if (ArgPack.getKind() != TemplateArgument::Pack) return TemplateName(); - + return Context.getSubstTemplateTemplateParmPack(Param, ArgPack); } } @@ -8049,7 +8038,7 @@ TemplateArgument ASTReader::ReadTemplateArgument(ModuleFile &F, QualType T = readType(F, Record, Idx); return TemplateArgument(Context, Value, T); } - case TemplateArgument::Template: + case TemplateArgument::Template: return TemplateArgument(ReadTemplateName(F, Record, Idx)); case TemplateArgument::TemplateExpansion: { TemplateName Name = ReadTemplateName(F, Record, Idx); @@ -8125,7 +8114,7 @@ ASTReader::ReadCXXBaseSpecifier(ModuleFile &F, TypeSourceInfo *TInfo = GetTypeSourceInfo(F, Record, Idx); SourceRange Range = ReadSourceRange(F, Record, Idx); SourceLocation EllipsisLoc = ReadSourceLocation(F, Record, Idx); - CXXBaseSpecifier Result(Range, isVirtual, isBaseOfClass, AS, TInfo, + CXXBaseSpecifier Result(Range, isVirtual, isBaseOfClass, AS, TInfo, EllipsisLoc); Result.setInheritConstructors(inheritConstructors); return Result; @@ -8252,7 +8241,7 @@ ASTReader::ReadNestedNameSpecifier(ModuleFile &F, } NestedNameSpecifierLoc -ASTReader::ReadNestedNameSpecifierLoc(ModuleFile &F, const RecordData &Record, +ASTReader::ReadNestedNameSpecifierLoc(ModuleFile &F, const RecordData &Record, unsigned &Idx) { unsigned N = Record[Idx++]; NestedNameSpecifierLocBuilder Builder; @@ -8261,7 +8250,7 @@ ASTReader::ReadNestedNameSpecifierLoc(ModuleFile &F, const RecordData &Record, = (NestedNameSpecifier::SpecifierKind)Record[Idx++]; switch (Kind) { case NestedNameSpecifier::Identifier: { - IdentifierInfo *II = GetIdentifierInfo(F, Record, Idx); + IdentifierInfo *II = GetIdentifierInfo(F, Record, Idx); SourceRange Range = ReadSourceRange(F, Record, Idx); Builder.Extend(Context, II, Range.getBegin(), Range.getEnd()); break; @@ -8290,7 +8279,7 @@ ASTReader::ReadNestedNameSpecifierLoc(ModuleFile &F, const RecordData &Record, SourceLocation ColonColonLoc = ReadSourceLocation(F, Record, Idx); // FIXME: 'template' keyword location not saved anywhere, so we fake it. - Builder.Extend(Context, + Builder.Extend(Context, Template? T->getTypeLoc().getBeginLoc() : SourceLocation(), T->getTypeLoc(), ColonColonLoc); break; @@ -8359,7 +8348,7 @@ std::string ASTReader::ReadPath(ModuleFile &F, const RecordData &Record, return Filename; } -VersionTuple ASTReader::ReadVersionTuple(const RecordData &Record, +VersionTuple ASTReader::ReadVersionTuple(const RecordData &Record, unsigned &Idx) { unsigned Major = Record[Idx++]; unsigned Minor = Record[Idx++]; @@ -8371,7 +8360,7 @@ VersionTuple ASTReader::ReadVersionTuple(const RecordData &Record, return VersionTuple(Major, Minor - 1, Subminor - 1); } -CXXTemporary *ASTReader::ReadCXXTemporary(ModuleFile &F, +CXXTemporary *ASTReader::ReadCXXTemporary(ModuleFile &F, const RecordData &Record, unsigned &Idx) { CXXDestructorDecl *Decl = ReadDeclAs(F, Record, Idx); @@ -8562,7 +8551,7 @@ void ASTReader::finishPendingActions() { // If we deserialized any C++ or Objective-C class definitions, any // Objective-C protocol definitions, or any redeclarable templates, make sure - // that all redeclarations point to the definitions. Note that this can only + // that all redeclarations point to the definitions. Note that this can only // happen now, after the redeclaration chains have been fully wired. for (Decl *D : PendingDefinitions) { if (TagDecl *TD = dyn_cast(D)) { @@ -8717,7 +8706,7 @@ void ASTReader::diagnoseOdrViolations() { // completed. We only really need to mark FieldDecls as invalid here. if (!isa(D)) D->setInvalidDecl(); - + // Ensure we don't accidentally recursively enter deserialization while // we're producing our diagnostic. Deserializing RecursionGuard(this); @@ -8792,7 +8781,7 @@ void ASTReader::diagnoseOdrViolations() { } void ASTReader::StartedDeserializing() { - if (++NumCurrentElementsDeserializing == 1 && ReadTimer.get()) + if (++NumCurrentElementsDeserializing == 1 && ReadTimer.get()) ReadTimer->startTimer(); } diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 07df754..913a141 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -35,12 +35,11 @@ using namespace clang::serialization; 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 @@ namespace clang { 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 @@ namespace clang { 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 @@ namespace clang { 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 @@ merged_redecls(DeclT *D) { } 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 @@ void ASTDeclReader::Visit(Decl *D) { 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 @@ void ASTDeclReader::Visit(Decl *D) { 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 @@ void ASTDeclReader::VisitDecl(Decl *D) { // 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 @@ void ASTDeclReader::VisitDecl(Decl *D) { 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 @@ void ASTDeclReader::VisitDecl(Decl *D) { 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 @@ void ASTDeclReader::VisitDecl(Decl *D) { // 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::VisitDecl(Decl *D) { 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::VisitTranslationUnitDecl(TranslationUnitDecl *TU) { 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::VisitTypedefDecl(TypedefDecl *TD) { 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 @@ ASTDeclReader::RedeclarableResult ASTDeclReader::VisitTagDecl(TagDecl *TD) { 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 @@ ASTDeclReader::RedeclarableResult ASTDeclReader::VisitTagDecl(TagDecl *TD) { 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 @@ void ASTDeclReader::VisitEnumDecl(EnumDecl *ED) { } } - 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 @@ ASTDeclReader::VisitRecordDeclImpl(RecordDecl *RD) { 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 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) { 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 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) { 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 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) { 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 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) { 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 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) { 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 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) { 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 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) { 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 @@ void ASTDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) { // 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 @@ void ASTDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) { 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 @@ void ASTDeclReader::VisitObjCTypeParamDecl(ObjCTypeParamDecl *D) { 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 @@ ObjCTypeParamList *ASTDeclReader::ReadObjCTypeParamList() { 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::MergeDefinitionData(ObjCInterfaceDecl *D, 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 @@ void ASTDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) { // 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 @@ void ASTDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) { // 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 @@ void ASTDeclReader::VisitObjCProtocolDecl(ObjCProtocolDecl *PD) { 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 @@ void ASTDeclReader::VisitObjCProtocolDecl(ObjCProtocolDecl *PD) { 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::VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *FD) { 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 @@ void ASTDeclReader::VisitObjCPropertyDecl(ObjCPropertyDecl *D) { (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 @@ void ASTDeclReader::VisitFieldDecl(FieldDecl *FD) { 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::VisitFieldDecl(FieldDecl *FD) { 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 @@ void ASTDeclReader::VisitIndirectFieldDecl(IndirectFieldDecl *FD) { 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 @@ ASTDeclReader::RedeclarableResult ASTDeclReader::VisitVarDeclImpl(VarDecl *VD) { 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 @@ ASTDeclReader::RedeclarableResult ASTDeclReader::VisitVarDeclImpl(VarDecl *VD) { 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 @@ void ASTDeclReader::VisitParmVarDecl(ParmVarDecl *PD) { 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 @@ void ASTDeclReader::VisitDecompositionDecl(DecompositionDecl *DD) { 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 @@ void ASTDeclReader::VisitBlockDecl(BlockDecl *BD) { 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 @@ void ASTDeclReader::VisitCapturedDecl(CapturedDecl *CD) { // 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 @@ void ASTDeclReader::VisitNamespaceDecl(NamespaceDecl *D) { // 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 @@ void ASTDeclReader::VisitNamespaceDecl(NamespaceDecl *D) { // 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::VisitNamespaceDecl(NamespaceDecl *D) { 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::VisitUsingDecl(UsingDecl *D) { 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::VisitUsingShadowDecl(UsingShadowDecl *D) { 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 @@ void ASTDeclReader::ReadCXXDefinitionData( 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 @@ void ASTDeclReader::ReadCXXDefinitionData( 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 @@ void ASTDeclReader::ReadCXXDefinitionData( 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 @@ void ASTDeclReader::ReadCXXRecordDefinition(CXXRecordDecl *D, bool Update) { 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 @@ ASTDeclReader::VisitCXXRecordDeclImpl(CXXRecordDecl *D) { 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 @@ ASTDeclReader::VisitCXXRecordDeclImpl(CXXRecordDecl *D) { 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 @@ ASTDeclReader::VisitCXXRecordDeclImpl(CXXRecordDecl *D) { // 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 @@ void ASTDeclReader::VisitCXXMethodDecl(CXXMethodDecl *D) { 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 @@ void ASTDeclReader::VisitCXXConstructorDecl(CXXConstructorDecl *D) { // 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::VisitCXXConstructorDecl(CXXConstructorDecl *D) { 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::VisitCXXConversionDecl(CXXConversionDecl *D) { 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 @@ void ASTDeclReader::VisitFriendTemplateDecl(FriendTemplateDecl *D) { 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 @@ ASTDeclReader::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) { // 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::RedeclarableResult 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 @@ ASTDeclReader::VisitClassTemplateSpecializationDeclImpl( } 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 @@ ASTDeclReader::VisitClassTemplateSpecializationDeclImpl( } // 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 @@ void ASTDeclReader::VisitClassTemplatePartialSpecializationDecl( 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::VisitClassTemplatePartialSpecializationDecl( void ASTDeclReader::VisitClassScopeFunctionSpecializationDecl( ClassScopeFunctionSpecializationDecl *D) { VisitDecl(D); - D->Specialization = ReadDeclAs(Record, Idx); + D->Specialization = ReadDeclAs(); } void ASTDeclReader::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) { @@ -2110,12 +2096,12 @@ ASTDeclReader::VisitVarTemplateSpecializationDeclImpl( 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 @@ ASTDeclReader::VisitVarTemplateSpecializationDeclImpl( } // 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 @@ void ASTDeclReader::VisitVarTemplatePartialSpecializationDecl( 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 @@ void ASTDeclReader::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) { D->setDeclaredWithTypename(Record[Idx++]); if (Record[Idx++]) - D->setDefaultArgument(GetTypeSourceInfo(Record, Idx)); + D->setDefaultArgument(GetTypeSourceInfo()); } void ASTDeclReader::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) { @@ -2201,14 +2187,14 @@ void ASTDeclReader::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) { 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 @@ void ASTDeclReader::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) { 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::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) { 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 @@ void ASTDeclReader::VisitEmptyDecl(EmptyDecl *D) { 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 @@ ASTDeclReader::VisitRedeclarable(Redeclarable *D) { // 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 @@ ASTDeclReader::VisitRedeclarable(Redeclarable *D) { // loaded & attached later on. D->RedeclLink = Redeclarable::PreviousDeclLink(FirstDecl); D->First = FirstDecl->getCanonicalDecl(); - } + } T *DAsT = static_cast(D); @@ -2354,10 +2340,10 @@ void ASTDeclReader::mergeTemplatePattern(RedeclarableTemplateDecl *D, 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 @@ void ASTDeclReader::VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D) { 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 @@ void ASTReader::loadDeclUpdateRecords(serialization::DeclID ID, Decl *D) { 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 @@ static void forAllLaterRedecls(DeclT *D, Fn F) { } } -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 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile, 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 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile, 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 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile, // 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 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile, 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 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile, 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 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile, 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 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile, 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 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile, } 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 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile, 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 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile, 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 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile, 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 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile, 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 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile, 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; diff --git a/clang/lib/Serialization/ASTReaderStmt.cpp b/clang/lib/Serialization/ASTReaderStmt.cpp index dcadfdc..4254430 100644 --- a/clang/lib/Serialization/ASTReaderStmt.cpp +++ b/clang/lib/Serialization/ASTReaderStmt.cpp @@ -26,62 +26,50 @@ namespace clang { 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); + TypeSourceInfo *GetTypeSourceInfo() { + return Record.GetTypeSourceInfo(Idx); } - - serialization::DeclID ReadDeclID(const RecordData &R, unsigned &I) { - return Reader.ReadDeclID(F, R, I); - } - - 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 @@ namespace clang { 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::VisitStmt(Stmt *S) { void ASTStmtReader::VisitNullStmt(NullStmt *S) { VisitStmt(S); - S->setSemiLoc(ReadSourceLocation(Record, Idx)); + S->setSemiLoc(ReadSourceLocation()); S->HasLeadingEmptyMacro = Record[Idx++]; } @@ -134,81 +121,79 @@ void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) { 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::VisitSwitchStmt(SwitchStmt *S) { 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 @@ void ASTStmtReader::VisitAsmStmt(AsmStmt *S) { 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,34 +307,34 @@ void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) { 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(), - Names.data(), Constraints.data(), - Exprs.data(), NumOutputs, NumInputs, + S->setOutputsAndInputsAndClobbers(Record.getContext(), + Names.data(), Constraints.data(), + Exprs.data(), NumOutputs, NumInputs, Clobbers.data(), NumClobbers); } 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 @@ void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) { 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 @@ void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) { 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::VisitCoyieldExpr(CoyieldExpr *S) { 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::VisitExpr(Expr *E) { 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 @@ void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) { 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 @@ void ASTStmtReader::VisitStringLiteral(StringLiteral *E) { // 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 @@ void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) { ++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,64 +553,64 @@ void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) { 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; } } } - + 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::VisitMemberExpr(MemberExpr *E) { 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 @@ void ASTStmtReader::VisitCastExpr(CastExpr *E) { 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::VisitImplicitCastExpr(ImplicitCastExpr *E) { 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,17 @@ void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) { 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); - SourceLocation DotLoc - = ReadSourceLocation(Record, Idx); - SourceLocation FieldLoc - = ReadSourceLocation(Record, Idx); + FieldDecl *Field = ReadDeclAs(); + SourceLocation DotLoc = ReadSourceLocation(); + SourceLocation FieldLoc = ReadSourceLocation(); Designators.push_back(Designator(Field->getIdentifier(), DotLoc, FieldLoc)); Designators.back().setField(Field); @@ -798,47 +777,40 @@ void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) { } case DESIG_FIELD_NAME: { - const IdentifierInfo *Name = Reader.GetIdentifierInfo(F, Record, Idx); - SourceLocation DotLoc - = ReadSourceLocation(Record, Idx); - SourceLocation FieldLoc - = ReadSourceLocation(Record, Idx); + const IdentifierInfo *Name = Record.GetIdentifierInfo(Idx); + SourceLocation DotLoc = ReadSourceLocation(); + SourceLocation FieldLoc = ReadSourceLocation(); Designators.push_back(Designator(Name, DotLoc, FieldLoc)); break; } case DESIG_ARRAY: { unsigned Index = Record[Idx++]; - SourceLocation LBracketLoc - = ReadSourceLocation(Record, Idx); - SourceLocation RBracketLoc - = ReadSourceLocation(Record, Idx); + SourceLocation LBracketLoc = ReadSourceLocation(); + SourceLocation RBracketLoc = ReadSourceLocation(); Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc)); break; } case DESIG_ARRAY_RANGE: { unsigned Index = Record[Idx++]; - SourceLocation LBracketLoc - = ReadSourceLocation(Record, Idx); - SourceLocation EllipsisLoc - = ReadSourceLocation(Record, Idx); - SourceLocation RBracketLoc - = ReadSourceLocation(Record, Idx); + SourceLocation LBracketLoc = ReadSourceLocation(); + SourceLocation EllipsisLoc = ReadSourceLocation(); + SourceLocation RBracketLoc = 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 +819,8 @@ void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) { 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 +833,40 @@ void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) { 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 +874,42 @@ void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { 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 +919,11 @@ void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) { 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 +933,9 @@ void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) { 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 +943,16 @@ void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) { 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 +961,9 @@ void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) { 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 +977,45 @@ void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) { 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 +1025,34 @@ void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { 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) { @@ -1089,24 +1060,24 @@ void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) { assert(Record[Idx] == E->getNumArgs()); ++Idx; unsigned NumStoredSelLocs = Record[Idx++]; - E->SelLocsKind = Record[Idx++]; + E->SelLocsKind = Record[Idx++]; E->setDelegateInitCall(Record[Idx++]); E->IsImplicit = Record[Idx++]; ObjCMessageExpr::ReceiverKind Kind = 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 +1086,48 @@ void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) { 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 +1135,40 @@ void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) { 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 +1177,49 @@ void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) 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 +1227,63 @@ void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) { 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 +1305,74 @@ void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) { 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 +1383,20 @@ void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) { 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 +1405,27 @@ void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) { 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); - - IdentifierInfo *II = Reader.GetIdentifierInfo(F, Record, Idx); + E->OperatorLoc = ReadSourceLocation(); + E->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx); + E->ScopeType = GetTypeSourceInfo(); + E->ColonColonLoc = ReadSourceLocation(); + E->TildeLoc = ReadSourceLocation(); + + 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 +1435,10 @@ void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) { 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 +1451,13 @@ ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){ 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 +1470,8 @@ ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) { 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 +1480,10 @@ ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) { 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 +1497,30 @@ void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) { 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 +1528,32 @@ void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) { 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 +1561,30 @@ void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) { 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 +1593,56 @@ void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) { 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 +1655,58 @@ void ASTStmtReader::VisitTypoExpr(TypoExpr *E) { 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 +1715,7 @@ void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) { void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) { VisitCallExpr(E); - E->setConfig(cast(Reader.ReadSubExpr())); + E->setConfig(cast(Record.ReadSubExpr())); } //===----------------------------------------------------------------------===// @@ -1752,9 +1723,9 @@ void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) { //===----------------------------------------------------------------------===// 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(); } //===----------------------------------------------------------------------===// @@ -1765,12 +1736,10 @@ namespace clang { class OMPClauseReader : public OMPClauseVisitor { ASTStmtReader *Reader; 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), Context(Record.getContext()), Idx(Idx) {} #define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *C); #include "clang/Basic/OpenMPKinds.def" OMPClause *readClause(); @@ -1781,7 +1750,7 @@ public: OMPClause *OMPClauseReader::readClause() { OMPClause *C; - switch (Record[Idx++]) { + switch (Reader->Record[Idx++]) { case OMPC_if: C = new (Context) OMPIfClause(); break; @@ -1846,46 +1815,46 @@ OMPClause *OMPClauseReader::readClause() { C = new (Context) OMPNogroupClause(); break; case OMPC_private: - C = OMPPrivateClause::CreateEmpty(Context, Record[Idx++]); + C = OMPPrivateClause::CreateEmpty(Context, Reader->Record[Idx++]); break; case OMPC_firstprivate: - C = OMPFirstprivateClause::CreateEmpty(Context, Record[Idx++]); + C = OMPFirstprivateClause::CreateEmpty(Context, Reader->Record[Idx++]); break; case OMPC_lastprivate: - C = OMPLastprivateClause::CreateEmpty(Context, Record[Idx++]); + C = OMPLastprivateClause::CreateEmpty(Context, Reader->Record[Idx++]); break; case OMPC_shared: - C = OMPSharedClause::CreateEmpty(Context, Record[Idx++]); + C = OMPSharedClause::CreateEmpty(Context, Reader->Record[Idx++]); break; case OMPC_reduction: - C = OMPReductionClause::CreateEmpty(Context, Record[Idx++]); + C = OMPReductionClause::CreateEmpty(Context, Reader->Record[Idx++]); break; case OMPC_linear: - C = OMPLinearClause::CreateEmpty(Context, Record[Idx++]); + C = OMPLinearClause::CreateEmpty(Context, Reader->Record[Idx++]); break; case OMPC_aligned: - C = OMPAlignedClause::CreateEmpty(Context, Record[Idx++]); + C = OMPAlignedClause::CreateEmpty(Context, Reader->Record[Idx++]); break; case OMPC_copyin: - C = OMPCopyinClause::CreateEmpty(Context, Record[Idx++]); + C = OMPCopyinClause::CreateEmpty(Context, Reader->Record[Idx++]); break; case OMPC_copyprivate: - C = OMPCopyprivateClause::CreateEmpty(Context, Record[Idx++]); + C = OMPCopyprivateClause::CreateEmpty(Context, Reader->Record[Idx++]); break; case OMPC_flush: - C = OMPFlushClause::CreateEmpty(Context, Record[Idx++]); + C = OMPFlushClause::CreateEmpty(Context, Reader->Record[Idx++]); break; case OMPC_depend: - C = OMPDependClause::CreateEmpty(Context, Record[Idx++]); + C = OMPDependClause::CreateEmpty(Context, Reader->Record[Idx++]); break; case OMPC_device: C = new (Context) OMPDeviceClause(); break; case OMPC_map: { - unsigned NumVars = Record[Idx++]; - unsigned NumDeclarations = Record[Idx++]; - unsigned NumLists = Record[Idx++]; - unsigned NumComponents = Record[Idx++]; + unsigned NumVars = Reader->Record[Idx++]; + unsigned NumDeclarations = Reader->Record[Idx++]; + unsigned NumLists = Reader->Record[Idx++]; + unsigned NumComponents = Reader->Record[Idx++]; C = OMPMapClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists, NumComponents); break; @@ -1915,124 +1884,124 @@ OMPClause *OMPClauseReader::readClause() { C = new (Context) OMPDefaultmapClause(); break; case OMPC_to: { - unsigned NumVars = Record[Idx++]; - unsigned NumDeclarations = Record[Idx++]; - unsigned NumLists = Record[Idx++]; - unsigned NumComponents = Record[Idx++]; + unsigned NumVars = Reader->Record[Idx++]; + unsigned NumDeclarations = Reader->Record[Idx++]; + unsigned NumLists = Reader->Record[Idx++]; + unsigned NumComponents = Reader->Record[Idx++]; C = OMPToClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists, NumComponents); break; } case OMPC_from: { - unsigned NumVars = Record[Idx++]; - unsigned NumDeclarations = Record[Idx++]; - unsigned NumLists = Record[Idx++]; - unsigned NumComponents = Record[Idx++]; + unsigned NumVars = Reader->Record[Idx++]; + unsigned NumDeclarations = Reader->Record[Idx++]; + unsigned NumLists = Reader->Record[Idx++]; + unsigned NumComponents = Reader->Record[Idx++]; C = OMPFromClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists, NumComponents); break; } case OMPC_use_device_ptr: { - unsigned NumVars = Record[Idx++]; - unsigned NumDeclarations = Record[Idx++]; - unsigned NumLists = Record[Idx++]; - unsigned NumComponents = Record[Idx++]; + unsigned NumVars = Reader->Record[Idx++]; + unsigned NumDeclarations = Reader->Record[Idx++]; + unsigned NumLists = Reader->Record[Idx++]; + unsigned NumComponents = Reader->Record[Idx++]; C = OMPUseDevicePtrClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists, NumComponents); break; } case OMPC_is_device_ptr: { - unsigned NumVars = Record[Idx++]; - unsigned NumDeclarations = Record[Idx++]; - unsigned NumLists = Record[Idx++]; - unsigned NumComponents = Record[Idx++]; + unsigned NumVars = Reader->Record[Idx++]; + unsigned NumDeclarations = Reader->Record[Idx++]; + unsigned NumLists = Reader->Record[Idx++]; + unsigned NumComponents = Reader->Record[Idx++]; C = OMPIsDevicePtrClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists, NumComponents); break; } } 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->setNameModifier(static_cast(Reader->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)); + static_cast(Reader->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)); + static_cast(Reader->Record[Idx++])); + C->setLParenLoc(Reader->ReadSourceLocation()); + C->setProcBindKindKwLoc(Reader->ReadSourceLocation()); } void OMPClauseReader::VisitOMPScheduleClause(OMPScheduleClause *C) { VisitOMPClauseWithPreInit(C); C->setScheduleKind( - static_cast(Record[Idx++])); + static_cast(Reader->Record[Idx++])); C->setFirstScheduleModifier( - static_cast(Record[Idx++])); + static_cast(Reader->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)); + static_cast(Reader->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 +2027,82 @@ void OMPClauseReader::VisitOMPSIMDClause(OMPSIMDClause *) {} 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 = Reader->Record.ReadNestedNameSpecifierLoc(Idx); DeclarationNameInfo DNI; - Reader->ReadDeclarationNameInfo(DNI, Record, Idx); + Reader->ReadDeclarationNameInfo(DNI); C->setQualifierLoc(NNSL); C->setNameInfo(DNI); @@ -2142,151 +2110,152 @@ void OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *C) { 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->setModifier(static_cast(Record[Idx++])); - C->setModifierLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setLParenLoc(Reader->ReadSourceLocation()); + C->setColonLoc(Reader->ReadSourceLocation()); + C->setModifier(static_cast(Reader->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->setDependencyKind(static_cast(Record[Idx++])); - C->setDependencyLoc(Reader->ReadSourceLocation(Record, Idx)); - C->setColonLoc(Reader->ReadSourceLocation(Record, Idx)); + C->setLParenLoc(Reader->ReadSourceLocation()); + C->setDependencyKind( + static_cast(Reader->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++])); + static_cast(Reader->Record[Idx++])); C->setMapType( - static_cast(Record[Idx++])); - C->setMapLoc(Reader->ReadSourceLocation(Record, Idx)); - C->setColonLoc(Reader->ReadSourceLocation(Record, Idx)); + static_cast(Reader->Record[Idx++])); + C->setMapLoc(Reader->ReadSourceLocation()); + C->setColonLoc(Reader->ReadSourceLocation()); auto NumVars = C->varlist_size(); auto UniqueDecls = C->getUniqueDeclarationsNum(); auto TotalLists = C->getTotalComponentListNum(); @@ -2295,34 +2264,32 @@ void OMPClauseReader::VisitOMPMapClause(OMPMapClause *C) { 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(Reader->Record.ReadDeclAs(Idx)); C->setUniqueDecls(Decls); SmallVector ListsPerDecl; ListsPerDecl.reserve(UniqueDecls); for (unsigned i = 0; i < UniqueDecls; ++i) - ListsPerDecl.push_back(Record[Idx++]); + ListsPerDecl.push_back(Reader->Record[Idx++]); C->setDeclNumLists(ListsPerDecl); SmallVector ListSizes; ListSizes.reserve(TotalLists); for (unsigned i = 0; i < TotalLists; ++i) - ListSizes.push_back(Record[Idx++]); + ListSizes.push_back(Reader->Record[Idx++]); C->setComponentListSizes(ListSizes); 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 = Reader->Record.ReadDeclAs(Idx); Components.push_back(OMPClauseMappableExprCommon::MappableComponent( AssociatedExpr, AssociatedDecl)); } @@ -2330,57 +2297,57 @@ void OMPClauseReader::VisitOMPMapClause(OMPMapClause *C) { } 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)); + static_cast(Reader->Record[Idx++])); + C->setChunkSize(Reader->Record.ReadSubExpr()); + C->setLParenLoc(Reader->ReadSourceLocation()); + C->setDistScheduleKindLoc(Reader->ReadSourceLocation()); + C->setCommaLoc(Reader->ReadSourceLocation()); } void OMPClauseReader::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) { C->setDefaultmapKind( - static_cast(Record[Idx++])); + static_cast(Reader->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)); + static_cast(Reader->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,34 +2356,32 @@ void OMPClauseReader::VisitOMPToClause(OMPToClause *C) { 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(Reader->Record.ReadDeclAs(Idx)); C->setUniqueDecls(Decls); SmallVector ListsPerDecl; ListsPerDecl.reserve(UniqueDecls); for (unsigned i = 0; i < UniqueDecls; ++i) - ListsPerDecl.push_back(Record[Idx++]); + ListsPerDecl.push_back(Reader->Record[Idx++]); C->setDeclNumLists(ListsPerDecl); SmallVector ListSizes; ListSizes.reserve(TotalLists); for (unsigned i = 0; i < TotalLists; ++i) - ListSizes.push_back(Record[Idx++]); + ListSizes.push_back(Reader->Record[Idx++]); C->setComponentListSizes(ListSizes); 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 = Reader->Record.ReadDeclAs(Idx); Components.push_back(OMPClauseMappableExprCommon::MappableComponent( AssociatedExpr, AssociatedDecl)); } @@ -2424,7 +2389,7 @@ void OMPClauseReader::VisitOMPToClause(OMPToClause *C) { } 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,34 +2398,32 @@ void OMPClauseReader::VisitOMPFromClause(OMPFromClause *C) { 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(Reader->Record.ReadDeclAs(Idx)); C->setUniqueDecls(Decls); SmallVector ListsPerDecl; ListsPerDecl.reserve(UniqueDecls); for (unsigned i = 0; i < UniqueDecls; ++i) - ListsPerDecl.push_back(Record[Idx++]); + ListsPerDecl.push_back(Reader->Record[Idx++]); C->setDeclNumLists(ListsPerDecl); SmallVector ListSizes; ListSizes.reserve(TotalLists); for (unsigned i = 0; i < TotalLists; ++i) - ListSizes.push_back(Record[Idx++]); + ListSizes.push_back(Reader->Record[Idx++]); C->setComponentListSizes(ListSizes); 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 = Reader->Record.ReadDeclAs(Idx); Components.push_back(OMPClauseMappableExprCommon::MappableComponent( AssociatedExpr, AssociatedDecl)); } @@ -2468,7 +2431,7 @@ void OMPClauseReader::VisitOMPFromClause(OMPFromClause *C) { } 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,42 +2440,40 @@ void OMPClauseReader::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *C) { 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(Reader->Record.ReadDeclAs(Idx)); C->setUniqueDecls(Decls); SmallVector ListsPerDecl; ListsPerDecl.reserve(UniqueDecls); for (unsigned i = 0; i < UniqueDecls; ++i) - ListsPerDecl.push_back(Record[Idx++]); + ListsPerDecl.push_back(Reader->Record[Idx++]); C->setDeclNumLists(ListsPerDecl); SmallVector ListSizes; ListSizes.reserve(TotalLists); for (unsigned i = 0; i < TotalLists; ++i) - ListSizes.push_back(Record[Idx++]); + ListSizes.push_back(Reader->Record[Idx++]); C->setComponentListSizes(ListSizes); 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 = Reader->Record.ReadDeclAs(Idx); Components.push_back(OMPClauseMappableExprCommon::MappableComponent( AssociatedExpr, AssociatedDecl)); } @@ -2520,7 +2481,7 @@ void OMPClauseReader::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *C) { } 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,35 +2490,33 @@ void OMPClauseReader::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *C) { 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(Reader->Record.ReadDeclAs(Idx)); C->setUniqueDecls(Decls); SmallVector ListsPerDecl; ListsPerDecl.reserve(UniqueDecls); for (unsigned i = 0; i < UniqueDecls; ++i) - ListsPerDecl.push_back(Record[Idx++]); + ListsPerDecl.push_back(Reader->Record[Idx++]); C->setDeclNumLists(ListsPerDecl); SmallVector ListSizes; ListSizes.reserve(TotalLists); for (unsigned i = 0; i < TotalLists; ++i) - ListSizes.push_back(Record[Idx++]); + ListSizes.push_back(Reader->Record[Idx++]); C->setComponentListSizes(ListSizes); 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 = Reader->Record.ReadDeclAs(Idx); Components.push_back(OMPClauseMappableExprCommon::MappableComponent( AssociatedExpr, AssociatedDecl)); } @@ -2568,15 +2527,15 @@ void OMPClauseReader::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *C) { // 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 +2543,51 @@ void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) { // 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 +2643,7 @@ void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) { // 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 +2712,10 @@ void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) { // 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 +2880,7 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) { 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 +2896,7 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) { while (true) { llvm::BitstreamEntry Entry = Cursor.advanceSkippingSubblocks(); - + switch (Entry.Kind) { case llvm::BitstreamEntry::SubBlock: // Handled for us already. case llvm::BitstreamEntry::Error: @@ -3102,11 +3061,11 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) { 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 +3291,7 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) { 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; @@ -3735,7 +3694,7 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) { case EXPR_CXX_BIND_TEMPORARY: S = new (Context) CXXBindTemporaryExpr(Empty); break; - + case EXPR_CXX_SCALAR_VALUE_INIT: S = new (Context) CXXScalarValueInitExpr(Empty); break; @@ -3748,54 +3707,54 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) { case EXPR_CXX_PSEUDO_DESTRUCTOR: S = new (Context) CXXPseudoDestructorExpr(Empty); break; - + case EXPR_EXPR_WITH_CLEANUPS: S = ExprWithCleanups::Create(Context, Empty, Record[ASTStmtReader::NumExprFields]); break; - + case EXPR_CXX_DEPENDENT_SCOPE_MEMBER: S = CXXDependentScopeMemberExpr::CreateEmpty(Context, /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields], /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields] - ? Record[ASTStmtReader::NumExprFields + 1] + ? Record[ASTStmtReader::NumExprFields + 1] : 0); break; - + case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF: S = DependentScopeDeclRefExpr::CreateEmpty(Context, /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields], /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields] - ? Record[ASTStmtReader::NumExprFields + 1] + ? Record[ASTStmtReader::NumExprFields + 1] : 0); break; - + case EXPR_CXX_UNRESOLVED_CONSTRUCT: S = CXXUnresolvedConstructExpr::CreateEmpty(Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields]); break; - + case EXPR_CXX_UNRESOLVED_MEMBER: S = UnresolvedMemberExpr::CreateEmpty(Context, /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields], /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields] - ? Record[ASTStmtReader::NumExprFields + 1] + ? Record[ASTStmtReader::NumExprFields + 1] : 0); break; - + case EXPR_CXX_UNRESOLVED_LOOKUP: S = UnresolvedLookupExpr::CreateEmpty(Context, /*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields], /*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields] - ? Record[ASTStmtReader::NumExprFields + 1] + ? Record[ASTStmtReader::NumExprFields + 1] : 0); break; case EXPR_TYPE_TRAIT: - S = TypeTraitExpr::CreateDeserialized(Context, + S = TypeTraitExpr::CreateDeserialized(Context, Record[ASTStmtReader::NumExprFields]); break; - + case EXPR_ARRAY_TYPE_TRAIT: S = new (Context) ArrayTypeTraitExpr(Empty); break; @@ -3811,17 +3770,17 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) { case EXPR_PACK_EXPANSION: S = new (Context) PackExpansionExpr(Empty); break; - + case EXPR_SIZEOF_PACK: S = SizeOfPackExpr::CreateDeserialized( Context, /*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]); break; - + case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM: S = new (Context) SubstNonTypeTemplateParmExpr(Empty); break; - + case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK: S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty); break; @@ -3830,7 +3789,7 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) { S = FunctionParmPackExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields]); break; - + case EXPR_MATERIALIZE_TEMPORARY: S = new (Context) MaterializeTemporaryExpr(Empty); break; @@ -3846,7 +3805,7 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) { case EXPR_CUDA_KERNEL_CALL: S = new (Context) CUDAKernelCallExpr(Context, Empty); break; - + case EXPR_ASTYPE: S = new (Context) AsTypeExpr(Empty); break; @@ -3860,14 +3819,14 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) { case EXPR_ATOMIC: S = new (Context) AtomicExpr(Empty); break; - + case EXPR_LAMBDA: { unsigned NumCaptures = Record[ASTStmtReader::NumExprFields]; S = LambdaExpr::CreateDeserialized(Context, NumCaptures); break; } } - + // We hit a STMT_STOP, so we're done with this expression. if (Finished) break; -- 2.7.4