r289870 - Add a class ASTRecordReader which wraps an ASTReader, a RecordData, and ModuleFile.

David L. Jones via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 15 12:53:27 PST 2016


Author: dlj
Date: Thu Dec 15 14:53:26 2016
New Revision: 289870

URL: http://llvm.org/viewvc/llvm-project?rev=289870&view=rev
Log:
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

Modified:
    cfe/trunk/include/clang/Serialization/ASTReader.h
    cfe/trunk/lib/Serialization/ASTReader.cpp
    cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
    cfe/trunk/lib/Serialization/ASTReaderStmt.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=289870&r1=289869&r2=289870&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Dec 15 14:53:26 2016
@@ -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<QualType> &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<typename T>
+  T *ReadDeclAs(unsigned &Idx) {
+    return Reader->ReadDeclAs<T>(*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<TemplateArgument> &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 {

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=289870&r1=289869&r2=289870&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Dec 15 14:53:26 2016
@@ -735,7 +735,7 @@ ASTSelectorLookupTrait::ReadKeyDataLengt
   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 un
   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(M
   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(M
       // 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<SourceLocation, StringRef> AST
 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(Mo
     // 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(Mo
   }
 }
 
-PreprocessedEntityID 
+PreprocessedEntityID
 ASTReader::getGlobalPreprocessedEntityID(ModuleFile &M, unsigned LocalID) const {
-  ContinuousRangeMap<uint32_t, int, 2>::const_iterator 
+  ContinuousRangeMap<uint32_t, int, 2>::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::ComputeHas
   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(inter
   const FileEntry *FEB = GetFile(b);
   return FEA && FEA == FEB;
 }
-    
+
 std::pair<unsigned, unsigned>
 HeaderFileInfoTrait::ReadKeyDataLength(const unsigned char*& d) {
   using namespace llvm::support;
@@ -1638,7 +1638,7 @@ HeaderFileInfoTrait::ReadKey(const unsig
   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_k
       M, endian::readNext<uint32_t, little, unaligned>(d));
   if (unsigned FrameworkOffset =
           endian::readNext<uint32_t, little, unaligned>(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::updateOutOfDateIdentifie
 void ASTReader::markIdentifierUpToDate(IdentifierInfo *II) {
   if (!II)
     return;
-  
+
   II->setOutOfDate(false);
 
   // Update the generation for this identifier.
@@ -2000,7 +2000,7 @@ InputFile ASTReader::getInputFile(Module
   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::Read
   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 &
   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 &
           return Failure;
         }
         continue;
-          
+
       default:
         if (Stream.SkipBlock()) {
           Error("malformed block record in AST file");
@@ -2357,7 +2357,7 @@ ASTReader::ReadControlBlock(ModuleFile &
         }
         continue;
       }
-      
+
     case llvm::BitstreamEntry::Record:
       // The interesting case.
       break;
@@ -2409,7 +2409,7 @@ ASTReader::ReadControlBlock(ModuleFile &
       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, u
   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, u
       if (DC->hasExternalLexicalStorage() &&
           !getContext().getLangOpts().CPlusPlus)
         DC->setMustBuildLookupTable();
-      
+
       return Success;
     }
     case llvm::BitstreamEntry::SubBlock:
@@ -2569,7 +2569,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
         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, u
         }
         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, u
             }
         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, u
         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, u
         break;
       }
       continue;
-    
+
     case llvm::BitstreamEntry::Record:
       // The interesting case.
       break;
@@ -2646,21 +2646,21 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
       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, u
       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, u
       }
       break;
     }
-        
+
     case TU_UPDATE_LEXICAL: {
       DeclContext *TU = Context.getTranslationUnitDecl();
       LexicalContents Contents(
@@ -2722,7 +2722,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
             (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, u
       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, u
         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, u
       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, u
       }
       break;
     }
-        
+
     case METHOD_POOL:
       F.SelectorLookupTableData = (const unsigned char *)Blob.data();
       if (Record[0])
@@ -2862,7 +2862,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
     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, u
       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, u
       // This module. Base was 2 when being compiled.
       F.SLocRemap.insertOrReplace(std::make_pair(2U,
                                   static_cast<int>(F.SLocEntryBaseOffset - 2)));
-      
+
       TotalNumSLocEntries += F.LocalNumSLocEntries;
       break;
     }
@@ -3003,7 +3003,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
         Error("Multiple SOURCE_LOCATION_PRELOADS records in AST file");
         return Failure;
       }
-      
+
       F.PreloadSLocEntries.swap(Record);
       break;
     }
@@ -3018,12 +3018,12 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
         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, u
       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, u
         // 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, u
 
       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, u
         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, u
         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, u
           = 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, u
       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::Read
         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::Read
   // 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::Read
   // 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::Read
 
   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::Read
       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 FileNam
   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 FileNam
   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::Read
 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<TypedefType>())
           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<TypedefType>())
           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<TypedefType>())
           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::getOriginalSource
     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::getOriginalSource
     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
   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
       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
       }
       break;
     }
-        
+
     case SUBMODULE_HEADER:
     case SUBMODULE_EXCLUDED_HEADER:
     case SUBMODULE_PRIVATE_HEADER:
@@ -4711,17 +4711,17 @@ ASTReader::ReadSubmoduleBlock(ModuleFile
       }
       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
       }
       break;
     }
-        
+
     case SUBMODULE_IMPORTS: {
       for (unsigned Idx = 0; Idx != Record.size(); ++Idx) {
         UnresolvedModuleRef Unresolved;
@@ -4755,8 +4755,8 @@ ASTReader::ReadSubmoduleBlock(ModuleFile
         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<ModuleFile *, unsigned>
 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::ReadPrepr
     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::ReadPrepr
 
     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::ReadPrepr
 
     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<InclusionDirective::InclusionKind>(Record[2]);
@@ -5205,11 +5205,11 @@ Optional<bool> ASTReader::isPreprocessed
   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<HeaderFileInfo> HFI;
-    
+
   public:
     explicit HeaderFileInfoVisitor(const FileEntry *FE)
       : FE(FE) { }
@@ -5242,7 +5242,7 @@ namespace {
       HFI = *Pos;
       return true;
     }
-    
+
     Optional<HeaderFileInfo> getHeaderFileInfo() const { return HFI; }
   };
 
@@ -5253,7 +5253,7 @@ HeaderFileInfo ASTReader::GetHeaderFileI
   ModuleMgr.visit(Visitor);
   if (Optional<HeaderFileInfo> HFI = Visitor.getHeaderFileInfo())
     return *HFI;
-  
+
   return HeaderFileInfo();
 }
 
@@ -5275,7 +5275,7 @@ void ASTReader::ReadPragmaDiagnosticMapp
                     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(unsig
     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(unsig
     return Context.getTypeDeclType(
                   ReadDeclAs<UnresolvedUsingTypenameDecl>(*Loc.F, Record, Idx));
   }
-      
+
   case TYPE_TYPEDEF: {
     if (Record.size() != 2) {
       Error("incorrect encoding of typedef type");
@@ -5836,26 +5836,17 @@ void ASTReader::readExceptionSpec(Module
 }
 
 class clang::TypeLocReader : public TypeLocVisitor<TypeLocReader> {
-  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<typename T>
-  T *ReadDeclAs(const ASTReader::RecordData &Record, unsigned &Idx) {
-    return Reader.ReadDeclAs<T>(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::VisitQualifiedTypeLo
 }
 
 void TypeLocReader::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {
-  TL.setBuiltinLoc(ReadSourceLocation(Record, Idx));
+  TL.setBuiltinLoc(ReadSourceLocation());
   if (TL.needsExtraLocalData()) {
-    TL.setWrittenTypeSpec(static_cast<DeclSpec::TST>(Record[Idx++]));
-    TL.setWrittenSignSpec(static_cast<DeclSpec::TSS>(Record[Idx++]));
-    TL.setWrittenWidthSpec(static_cast<DeclSpec::TSW>(Record[Idx++]));
-    TL.setModeAttr(Record[Idx++]);
+    TL.setWrittenTypeSpec(static_cast<DeclSpec::TST>(Reader[Idx++]));
+    TL.setWrittenSignSpec(static_cast<DeclSpec::TSS>(Reader[Idx++]));
+    TL.setWrittenWidthSpec(static_cast<DeclSpec::TSW>(Reader[Idx++]));
+    TL.setModeAttr(Reader[Idx++]);
   }
 }
 
 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
 }
 
 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::VisitDependentSizedA
 
 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<ParmVarDecl>(Record, Idx));
+    TL.setParam(i, Reader.ReadDeclAs<ParmVarDecl>(Idx));
   }
 }
 
@@ -5973,162 +5964,160 @@ void TypeLocReader::VisitFunctionNoProto
   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(ModuleF
   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<uint32_t, int, 2>::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(Mo
   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::GetExternal
   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
   ContinuousRangeMap<uint32_t, int, 2>::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(seria
   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::mapGlobalIDToModuleFil
     = 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(File
                              EndLoc, DIDComp);
   if (EndIt != DInfo.Decls.end())
     ++EndIt;
-  
+
   for (ArrayRef<serialization::LocalDeclID>::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<typename Key, typename ModuleFile, unsigned InitialCapacity>
-static void 
+static void
 dumpModuleIDMap(StringRef Name,
-                const ContinuousRangeMap<Key, ModuleFile *, 
+                const ContinuousRangeMap<Key, ModuleFile *,
                                          InitialCapacity> &Map) {
   if (Map.begin() == Map.end())
     return;
-  
+
   typedef ContinuousRangeMap<Key, ModuleFile *, InitialCapacity> 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<ObjCMethodDecl *> getInstanceMethods() const { 
-      return InstanceMethods; 
+    ArrayRef<ObjCMethodDecl *> getInstanceMethods() const {
+      return InstanceMethods;
     }
 
     /// \brief Retrieve the instance methods found by this visitor.
-    ArrayRef<ObjCMethodDecl *> getFactoryMethods() const { 
+    ArrayRef<ObjCMethodDecl *> getFactoryMethods() const {
       return FactoryMethods;
     }
 
@@ -7368,14 +7357,14 @@ static void addMethodsToPool(Sema &S, Ar
     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
 
   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(
 void ASTReader::ReadKnownNamespaces(
                           SmallVectorImpl<NamespaceDecl *> &Namespaces) {
   Namespaces.clear();
-  
+
   for (unsigned I = 0, N = KnownNamespaces.size(); I != N; ++I) {
-    if (NamespaceDecl *Namespace 
+    if (NamespaceDecl *Namespace
                 = dyn_cast_or_null<NamespaceDecl>(GetDecl(KnownNamespaces[I])))
       Namespaces.push_back(Namespace);
   }
@@ -7505,7 +7494,7 @@ void ASTReader::ReadReferencedSelectors(
        SmallVectorImpl<std::pair<Selector, SourceLocation> > &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::ReadWeakUndeclaredIdenti
     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(SmallVec
     VT.DefinitionRequired = VTableUses[Idx++];
     VTables.push_back(VT);
   }
-  
+
   VTableUses.clear();
 }
 
@@ -7559,7 +7548,7 @@ void ASTReader::ReadPendingInstantiation
       = SourceLocation::getFromRawEncoding(PendingInstantiations[Idx++]);
 
     Pending.push_back(std::make_pair(D, Loc));
-  }  
+  }
   PendingInstantiations.clear();
 }
 
@@ -7691,12 +7680,12 @@ IdentifierInfo *ASTReader::getLocalIdent
 IdentifierID ASTReader::getGlobalIdentifierID(ModuleFile &M, unsigned LocalID) {
   if (LocalID < NUM_PREDEF_IDENT_IDS)
     return LocalID;
-  
+
   ContinuousRangeMap<uint32_t, int, 2>::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 I
     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<uint32_t, int, 2>::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(Submodul
     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<uint32_t, int, 2>::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(Module
 }
 
 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 &
     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 &
     TemplateName replacement = ReadTemplateName(F, Record, Idx);
     return Context.getSubstTemplateTemplateParm(param, replacement);
   }
-      
+
   case TemplateName::SubstTemplateTemplateParmPack: {
-    TemplateTemplateParmDecl *Param 
+    TemplateTemplateParmDecl *Param
       = ReadDeclAs<TemplateTemplateParmDecl>(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::ReadTemplate
     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(ModuleFi
   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(Modul
 }
 
 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(Mo
       = (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(Mo
       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(ModuleFi
   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
   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<CXXDestructorDecl>(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<TagDecl>(D)) {
@@ -8717,7 +8706,7 @@ void ASTReader::diagnoseOdrViolations()
       // completed. We only really need to mark FieldDecls as invalid here.
       if (!isa<TagDecl>(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();
 }
 

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=289870&r1=289869&r2=289870&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Thu Dec 15 14:53:26 2016
@@ -35,12 +35,11 @@ using namespace clang::serialization;
 namespace clang {
   class ASTDeclReader : public DeclVisitor<ASTDeclReader, void> {
     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<DeclID> &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<typename T>
-    T *ReadDeclAs(const RecordData &R, unsigned &I) {
-      return Reader.ReadDeclAs<T>(F, R, I);
+    T *ReadDeclAs() {
+      return Record.ReadDeclAs<T>(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<DeclaratorDecl::ExtInfo *>();
-      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<CXXConstructorDecl>(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<DeclContext>(Record, Idx);
-    DeclContext *LexicalDC = ReadDeclAs<DeclContext>(Record, Idx);
+    DeclContext *SemaDC = ReadDeclAs<DeclContext>();
+    DeclContext *LexicalDC = ReadDeclAs<DeclContext>();
     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<char>(), Arg.data(), Arg.size());
   D->getTrailingObjects<char>()[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<char>(), Name.data(), Name.size());
   D->getTrailingObjects<char>()[Name.size()] = '\0';
 
   D->ValueStart = Name.size() + 1;
-  std::string Value = ReadString(Record, Idx);
+  std::string Value = ReadString();
   memcpy(D->getTrailingObjects<char>() + D->ValueStart, Value.data(),
          Value.size());
   D->getTrailingObjects<char>()[D->ValueStart + Value.size()] = '\0';
@@ -584,24 +577,24 @@ void ASTDeclReader::VisitTranslationUnit
 
 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(Typ
 
 void ASTDeclReader::VisitTypeAliasDecl(TypeAliasDecl *TD) {
   RedeclarableResult Redecl = VisitTypedefNameDecl(TD);
-  if (auto *Template = ReadDeclAs<TypeAliasTemplateDecl>(Record, Idx))
+  if (auto *Template = ReadDeclAs<TypeAliasTemplateDecl>())
     // Merged when we merge the template.
     TD->setDescribedAliasTemplate(Template);
   else
@@ -633,20 +626,20 @@ ASTDeclReader::RedeclarableResult ASTDec
   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 ASTDec
 
 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(EnumDe
     }
   }
 
-  if (EnumDecl *InstED = ReadDeclAs<EnumDecl>(Record, Idx)) {
+  if (EnumDecl *InstED = ReadDeclAs<EnumDecl>()) {
     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(Recor
 
 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(Fu
   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(Fu
   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(Fu
     break;
   case FunctionDecl::TK_FunctionTemplate:
     // Merged when we merge the template.
-    FD->setDescribedFunctionTemplate(ReadDeclAs<FunctionTemplateDecl>(Record, 
-                                                                      Idx));
+    FD->setDescribedFunctionTemplate(ReadDeclAs<FunctionTemplateDecl>());
     break;
   case FunctionDecl::TK_MemberSpecialization: {
-    FunctionDecl *InstFD = ReadDeclAs<FunctionDecl>(Record, Idx);
+    FunctionDecl *InstFD = ReadDeclAs<FunctionDecl>();
     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<FunctionTemplateDecl>(Record, 
-                                                                      Idx);
+    FunctionTemplateDecl *Template = ReadDeclAs<FunctionTemplateDecl>();
     TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++];
-    
+
     // Template arguments.
     SmallVector<TemplateArgument, 8> TemplArgs;
-    Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx,
+    Record.ReadTemplateArgumentList(TemplArgs, Idx,
                                     /*Canonicalize*/ true);
 
     // Template args as written.
@@ -801,14 +792,13 @@ void ASTDeclReader::VisitFunctionDecl(Fu
       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(Fu
     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<FunctionTemplateDecl>(Record, Idx);
+      FunctionTemplateDecl *CanonTemplate = ReadDeclAs<FunctionTemplateDecl>();
       // 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(Fu
     UnresolvedSet<8> TemplDecls;
     unsigned NumTemplates = Record[Idx++];
     while (NumTemplates--)
-      TemplDecls.addDecl(ReadDeclAs<NamedDecl>(Record, Idx));
-    
+      TemplDecls.addDecl(ReadDeclAs<NamedDecl>());
+
     // 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(Fu
   SmallVector<ParmVarDecl *, 16> Params;
   Params.reserve(NumParams);
   for (unsigned I = 0; I != NumParams; ++I)
-    Params.push_back(ReadDeclAs<ParmVarDecl>(Record, Idx));
+    Params.push_back(ReadDeclAs<ParmVarDecl>());
   FD->setParams(Reader.getContext(), Params);
 }
 
@@ -889,8 +878,8 @@ void ASTDeclReader::VisitObjCMethodDecl(
     // definitions rarely show up in headers.
     Reader.PendingBodies[MD] = GetCurrentCursorOffset();
     HasPendingBody = true;
-    MD->setSelfDecl(ReadDeclAs<ImplicitParamDecl>(Record, Idx));
-    MD->setCmdDecl(ReadDeclAs<ImplicitParamDecl>(Record, Idx));
+    MD->setSelfDecl(ReadDeclAs<ImplicitParamDecl>());
+    MD->setCmdDecl(ReadDeclAs<ImplicitParamDecl>());
   }
   MD->setInstanceMethod(Record[Idx++]);
   MD->setVariadic(Record[Idx++]);
@@ -903,26 +892,26 @@ void ASTDeclReader::VisitObjCMethodDecl(
   MD->HasRedeclaration = Record[Idx++];
   if (MD->HasRedeclaration)
     Reader.getContext().setObjCMethodRedeclaration(MD,
-                                       ReadDeclAs<ObjCMethodDecl>(Record, Idx));
+                                       ReadDeclAs<ObjCMethodDecl>());
 
   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<ParmVarDecl *, 16> Params;
   Params.reserve(NumParams);
   for (unsigned I = 0; I != NumParams; ++I)
-    Params.push_back(ReadDeclAs<ParmVarDecl>(Record, Idx));
+    Params.push_back(ReadDeclAs<ParmVarDecl>());
 
   MD->SelLocsKind = Record[Idx++];
   unsigned NumStoredSelLocs = Record[Idx++];
   SmallVector<SourceLocation, 16> 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::VisitObjCTypeParamDe
 
   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::ReadOb
   SmallVector<ObjCTypeParamDecl *, 4> typeParams;
   typeParams.reserve(numParams);
   for (unsigned i = 0; i != numParams; ++i) {
-    auto typeParam = ReadDeclAs<ObjCTypeParamDecl>(Record, Idx);
+    auto typeParam = ReadDeclAs<ObjCTypeParamDecl>();
     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<ObjCProtocolDecl *, 16> Protocols;
   Protocols.reserve(NumProtocols);
   for (unsigned I = 0; I != NumProtocols; ++I)
-    Protocols.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
+    Protocols.push_back(ReadDeclAs<ObjCProtocolDecl>());
   SmallVector<SourceLocation, 16> 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<ObjCProtocolDecl>(Record, Idx));
+    Protocols.push_back(ReadDeclAs<ObjCProtocolDecl>());
   Data.AllReferencedProtocols.set(Protocols.data(), NumProtocols,
                                   Reader.getContext());
 }
@@ -1004,7 +992,7 @@ void ASTDeclReader::MergeDefinitionData(
 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::VisitObjCInterfaceDe
     // 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::VisitObjCInterfaceDe
       // 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::VisitObjCProtocolDec
   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::VisitObjCProtocolDec
     SmallVector<ObjCProtocolDecl *, 16> ProtoRefs;
     ProtoRefs.reserve(NumProtoRefs);
     for (unsigned I = 0; I != NumProtoRefs; ++I)
-      ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
+      ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>());
     SmallVector<SourceLocation, 16> 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::VisitObjCAtDefsField
 
 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<ObjCInterfaceDecl>(Record, Idx);
+  CD->ClassInterface = ReadDeclAs<ObjCInterfaceDecl>();
   CD->TypeParamList = ReadObjCTypeParamList();
   unsigned NumProtoRefs = Record[Idx++];
   SmallVector<ObjCProtocolDecl *, 16> ProtoRefs;
   ProtoRefs.reserve(NumProtoRefs);
   for (unsigned I = 0; I != NumProtoRefs; ++I)
-    ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
+    ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>());
   SmallVector<SourceLocation, 16> 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<ObjCInterfaceDecl>(Record, Idx));
+  CAD->setClassInterface(ReadDeclAs<ObjCInterfaceDecl>());
 }
 
 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::VisitObjCPropertyDec
                       (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<ObjCMethodDecl>(Record, Idx));
-  D->setSetterMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx));
-  D->setPropertyIvarDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx));
+  D->setGetterName(Record.ReadDeclarationName(Idx).getObjCSelector());
+  D->setSetterName(Record.ReadDeclarationName(Idx).getObjCSelector());
+  D->setGetterMethodDecl(ReadDeclAs<ObjCMethodDecl>());
+  D->setSetterMethodDecl(ReadDeclAs<ObjCMethodDecl>());
+  D->setPropertyIvarDecl(ReadDeclAs<ObjCIvarDecl>());
 }
 
 void ASTDeclReader::VisitObjCImplDecl(ObjCImplDecl *D) {
   VisitObjCContainerDecl(D);
-  D->setClassInterface(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
+  D->setClassInterface(ReadDeclAs<ObjCInterfaceDecl>());
 }
 
 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<ObjCInterfaceDecl>(Record, Idx));
-  D->SuperLoc = ReadSourceLocation(Record, Idx);
-  D->setIvarLBraceLoc(ReadSourceLocation(Record, Idx));
-  D->setIvarRBraceLoc(ReadSourceLocation(Record, Idx));
+  D->setSuperClass(ReadDeclAs<ObjCInterfaceDecl>());
+  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<ObjCPropertyDecl>(Record, Idx));
-  D->PropertyIvarDecl = ReadDeclAs<ObjCIvarDecl>(Record, Idx);
-  D->IvarLoc = ReadSourceLocation(Record, Idx);
-  D->setGetterCXXConstructor(Reader.ReadExpr(F));
-  D->setSetterCXXAssignment(Reader.ReadExpr(F));
+  D->setAtLoc(ReadSourceLocation());
+  D->setPropertyDecl(ReadDeclAs<ObjCPropertyDecl>());
+  D->PropertyIvarDecl = ReadDeclAs<ObjCIvarDecl>();
+  D->IvarLoc = ReadSourceLocation();
+  D->setGetterCXXConstructor(Record.ReadExpr());
+  D->setSetterCXXAssignment(Record.ReadExpr());
 }
 
 void ASTDeclReader::VisitFieldDecl(FieldDecl *FD) {
@@ -1177,13 +1165,13 @@ void ASTDeclReader::VisitFieldDecl(Field
     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<FieldDecl>(Record, Idx))
+    if (FieldDecl *Tmpl = ReadDeclAs<FieldDecl>())
       Reader.getContext().setInstantiatedFromUnnamedFieldDecl(FD, Tmpl);
   }
   mergeMergeable(FD);
@@ -1191,8 +1179,8 @@ void ASTDeclReader::VisitFieldDecl(Field
 
 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::VisitIndirectFieldDe
   FD->Chaining = new (Reader.getContext())NamedDecl*[FD->ChainingSize];
 
   for (unsigned I = 0; I != FD->ChainingSize; ++I)
-    FD->Chaining[I] = ReadDeclAs<NamedDecl>(Record, Idx);
+    FD->Chaining[I] = ReadDeclAs<NamedDecl>();
 
   mergeMergeable(FD);
 }
@@ -1236,7 +1224,7 @@ ASTDeclReader::RedeclarableResult ASTDec
     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 ASTDec
     break;
   case VarTemplate:
     // Merged when we merge the template.
-    VD->setDescribedVarTemplate(ReadDeclAs<VarTemplateDecl>(Record, Idx));
+    VD->setDescribedVarTemplate(ReadDeclAs<VarTemplateDecl>());
     break;
   case StaticDataMemberSpecialization: { // HasMemberSpecializationInfo.
-    VarDecl *Tmpl = ReadDeclAs<VarDecl>(Record, Idx);
+    VarDecl *Tmpl = ReadDeclAs<VarDecl>();
     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(Par
   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::VisitDecompositionDe
   VisitVarDecl(DD);
   BindingDecl **BDs = DD->getTrailingObjects<BindingDecl*>();
   for (unsigned I = 0; I != DD->NumBindings; ++I)
-    BDs[I] = ReadDeclAs<BindingDecl>(Record, Idx);
+    BDs[I] = ReadDeclAs<BindingDecl>();
 }
 
 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<StringLiteral>(Reader.ReadExpr(F)));
-  AD->setRParenLoc(ReadSourceLocation(Record, Idx));
+  AD->setAsmString(cast<StringLiteral>(Record.ReadExpr()));
+  AD->setRParenLoc(ReadSourceLocation());
 }
 
 void ASTDeclReader::VisitBlockDecl(BlockDecl *BD) {
   VisitDecl(BD);
-  BD->setBody(cast_or_null<CompoundStmt>(Reader.ReadStmt(F)));
-  BD->setSignatureAsWritten(GetTypeSourceInfo(Record, Idx));
+  BD->setBody(cast_or_null<CompoundStmt>(Record.ReadStmt()));
+  BD->setSignatureAsWritten(GetTypeSourceInfo());
   unsigned NumParams = Record[Idx++];
   SmallVector<ParmVarDecl *, 16> Params;
   Params.reserve(NumParams);
   for (unsigned I = 0; I != NumParams; ++I)
-    Params.push_back(ReadDeclAs<ParmVarDecl>(Record, Idx));
+    Params.push_back(ReadDeclAs<ParmVarDecl>());
   BD->setParams(Params);
 
   BD->setIsVariadic(Record[Idx++]);
@@ -1336,11 +1324,11 @@ void ASTDeclReader::VisitBlockDecl(Block
   SmallVector<BlockDecl::Capture, 16> captures;
   captures.reserve(numCaptures);
   for (unsigned i = 0; i != numCaptures; ++i) {
-    VarDecl *decl = ReadDeclAs<VarDecl>(Record, Idx);
+    VarDecl *decl = ReadDeclAs<VarDecl>();
     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(Ca
   // Body is set by VisitCapturedStmt.
   for (unsigned I = 0; I < CD->NumParams; ++I) {
     if (I != ContextParamPos)
-      CD->setParam(I, ReadDeclAs<ImplicitParamDecl>(Record, Idx));
+      CD->setParam(I, ReadDeclAs<ImplicitParamDecl>());
     else
-      CD->setContextParam(I, ReadDeclAs<ImplicitParamDecl>(Record, Idx));
+      CD->setContextParam(I, ReadDeclAs<ImplicitParamDecl>());
   }
 }
 
 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(N
   // 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(N
     // any other module's anonymous namespaces, so don't attach the anonymous
     // namespace at all.
     NamespaceDecl *Anon = cast<NamespaceDecl>(Reader.GetDecl(AnonNamespace));
-    if (!F.isModule())
+    if (!Record.isModule())
       D->setAnonymousNamespace(Anon);
   }
 }
@@ -1412,21 +1400,21 @@ void ASTDeclReader::VisitNamespaceDecl(N
 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<NamedDecl>(Record, Idx);
+  D->NamespaceLoc = ReadSourceLocation();
+  D->IdentLoc = ReadSourceLocation();
+  D->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx);
+  D->Namespace = ReadDeclAs<NamedDecl>();
   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<UsingShadowDecl>(Record, Idx));
+  D->setUsingLoc(ReadSourceLocation());
+  D->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx);
+  ReadDeclarationNameLoc(D->DNLoc, D->getDeclName());
+  D->FirstUsingShadow.setPointer(ReadDeclAs<UsingShadowDecl>());
   D->setTypename(Record[Idx++]);
-  if (NamedDecl *Pattern = ReadDeclAs<NamedDecl>(Record, Idx))
+  if (NamedDecl *Pattern = ReadDeclAs<NamedDecl>())
     Reader.getContext().setInstantiatedFromUsingDecl(D, Pattern);
   mergeMergeable(D);
 }
@@ -1434,9 +1422,9 @@ void ASTDeclReader::VisitUsingDecl(Using
 void ASTDeclReader::VisitUsingShadowDecl(UsingShadowDecl *D) {
   RedeclarableResult Redecl = VisitRedeclarable(D);
   VisitNamedDecl(D);
-  D->setTargetDecl(ReadDeclAs<NamedDecl>(Record, Idx));
-  D->UsingOrNextShadow = ReadDeclAs<NamedDecl>(Record, Idx);
-  UsingShadowDecl *Pattern = ReadDeclAs<UsingShadowDecl>(Record, Idx);
+  D->setTargetDecl(ReadDeclAs<NamedDecl>());
+  D->UsingOrNextShadow = ReadDeclAs<NamedDecl>();
+  UsingShadowDecl *Pattern = ReadDeclAs<UsingShadowDecl>();
   if (Pattern)
     Reader.getContext().setInstantiatedFromUsingShadowDecl(D, Pattern);
   mergeRedeclarable(D, Redecl);
@@ -1445,41 +1433,39 @@ void ASTDeclReader::VisitUsingShadowDecl
 void ASTDeclReader::VisitConstructorUsingShadowDecl(
     ConstructorUsingShadowDecl *D) {
   VisitUsingShadowDecl(D);
-  D->NominatedBaseClassShadowDecl =
-      ReadDeclAs<ConstructorUsingShadowDecl>(Record, Idx);
-  D->ConstructedBaseClassShadowDecl =
-      ReadDeclAs<ConstructorUsingShadowDecl>(Record, Idx);
+  D->NominatedBaseClassShadowDecl = ReadDeclAs<ConstructorUsingShadowDecl>();
+  D->ConstructedBaseClassShadowDecl = ReadDeclAs<ConstructorUsingShadowDecl>();
   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<NamedDecl>(Record, Idx);
-  D->CommonAncestor = ReadDeclAs<DeclContext>(Record, Idx);
+  D->UsingLoc = ReadSourceLocation();
+  D->NamespaceLoc = ReadSourceLocation();
+  D->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx);
+  D->NominatedNamespace = ReadDeclAs<NamedDecl>();
+  D->CommonAncestor = ReadDeclAs<DeclContext>();
 }
 
 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::ReadCXXDefinitionDat
 
   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::ReadCXXDefinitionDat
     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<LambdaCaptureKind>(Record[Idx++]);
       switch (Kind) {
@@ -1562,8 +1548,8 @@ void ASTDeclReader::ReadCXXDefinitionDat
         break;
       case LCK_ByCopy:
       case LCK_ByRef:
-        VarDecl *Var = ReadDeclAs<VarDecl>(Record, Idx);
-        SourceLocation EllipsisLoc = ReadSourceLocation(Record, Idx);
+        VarDecl *Var = ReadDeclAs<VarDecl>();
+        SourceLocation EllipsisLoc = ReadSourceLocation();
         *ToCapture++ = Capture(Loc, IsImplicit, Kind, Var, EllipsisLoc);
         break;
       }
@@ -1692,7 +1678,7 @@ void ASTDeclReader::ReadCXXRecordDefinit
   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(CX
     break;
   case CXXRecTemplate: {
     // Merged when we merge the template.
-    ClassTemplateDecl *Template = ReadDeclAs<ClassTemplateDecl>(Record, Idx);
+    ClassTemplateDecl *Template = ReadDeclAs<ClassTemplateDecl>();
     D->TemplateOrInstantiation = Template;
     if (!Template->getTemplatedDecl()) {
       // We've not actually loaded the ClassTemplateDecl yet, because we're
@@ -1748,9 +1734,9 @@ ASTDeclReader::VisitCXXRecordDeclImpl(CX
     break;
   }
   case CXXRecMemberSpecialization: {
-    CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>(Record, Idx);
+    CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>();
     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(CX
   // 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(C
     while (NumOverridenMethods--) {
       // Avoid invariant checking of CXXMethodDecl::addOverriddenMethod,
       // MD may be initializing.
-      if (CXXMethodDecl *MD = ReadDeclAs<CXXMethodDecl>(Record, Idx))
+      if (CXXMethodDecl *MD = ReadDeclAs<CXXMethodDecl>())
         Reader.getContext().addOverriddenMethod(D, MD->getCanonicalDecl());
     }
   } else {
@@ -1802,8 +1788,8 @@ void ASTDeclReader::VisitCXXConstructorD
   // 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<ConstructorUsingShadowDecl>(Record, Idx);
-    auto *Ctor = ReadDeclAs<CXXConstructorDecl>(Record, Idx);
+    auto *Shadow = ReadDeclAs<ConstructorUsingShadowDecl>();
+    auto *Ctor = ReadDeclAs<CXXConstructorDecl>();
     *D->getTrailingObjects<InheritedConstructor>() =
         InheritedConstructor(Shadow, Ctor);
   }
@@ -1816,7 +1802,7 @@ void ASTDeclReader::VisitCXXConstructorD
 void ASTDeclReader::VisitCXXDestructorDecl(CXXDestructorDecl *D) {
   VisitCXXMethodDecl(D);
 
-  if (auto *OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx)) {
+  if (auto *OperatorDelete = ReadDeclAs<FunctionDecl>()) {
     auto *Canon = cast<CXXDestructorDecl>(D->getCanonicalDecl());
     // FIXME: Check consistency if we have an old and new operator delete.
     if (!Canon->OperatorDelete)
@@ -1831,31 +1817,31 @@ void ASTDeclReader::VisitCXXConversionDe
 
 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<SourceLocation>();
   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<NamedDecl>(Record, Idx);
+    D->Friend = ReadDeclAs<NamedDecl>();
   else
-    D->Friend = GetTypeSourceInfo(Record, Idx);
+    D->Friend = GetTypeSourceInfo();
   for (unsigned i = 0; i != D->NumTPLists; ++i)
     D->getTrailingObjects<TemplateParameterList *>()[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::VisitFriendTemplateD
   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<NamedDecl>(Record, Idx);
+    D->Friend = ReadDeclAs<NamedDecl>();
   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<NamedDecl>(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::VisitRedeclarableTemplate
   // for the 'common' pointer.
   if (ThisDeclID == Redecl.getFirstID()) {
     if (RedeclarableTemplateDecl *RTD
-          = ReadDeclAs<RedeclarableTemplateDecl>(Record, Idx)) {
+          = ReadDeclAs<RedeclarableTemplateDecl>()) {
       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<ClassTemplateDecl>(InstD)) {
       D->SpecializedTemplate = CTD;
     } else {
       SmallVector<TemplateArgument, 8> 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::VisitClassTemplateSpecial
   }
 
   SmallVector<TemplateArgument, 8> 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<ClassTemplateDecl>(Record,Idx);
+    ClassTemplateDecl *CanonPattern = ReadDeclAs<ClassTemplateDecl>();
     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::VisitClassTemplateSpecial
   }
 
   // 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::VisitClassTemplatePa
                                     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<ClassTemplatePartialSpecializationDecl>(Record, Idx));
+      ReadDeclAs<ClassTemplatePartialSpecializationDecl>());
     D->InstantiatedFromMember.setInt(Record[Idx++]);
   }
 }
@@ -2080,7 +2066,7 @@ void ASTDeclReader::VisitClassTemplatePa
 void ASTDeclReader::VisitClassScopeFunctionSpecializationDecl(
                                     ClassScopeFunctionSpecializationDecl *D) {
   VisitDecl(D);
-  D->Specialization = ReadDeclAs<CXXMethodDecl>(Record, Idx);
+  D->Specialization = ReadDeclAs<CXXMethodDecl>();
 }
 
 void ASTDeclReader::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
@@ -2110,12 +2096,12 @@ ASTDeclReader::VisitVarTemplateSpecializ
   RedeclarableResult Redecl = VisitVarDeclImpl(D);
 
   ASTContext &C = Reader.getContext();
-  if (Decl *InstD = ReadDecl(Record, Idx)) {
+  if (Decl *InstD = ReadDecl()) {
     if (VarTemplateDecl *VTD = dyn_cast<VarTemplateDecl>(InstD)) {
       D->SpecializedTemplate = VTD;
     } else {
       SmallVector<TemplateArgument, 8> 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::VisitVarTemplateSpecializ
   }
 
   // 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<TemplateArgument, 8> 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<VarTemplateDecl>(Record, Idx);
+    VarTemplateDecl *CanonPattern = ReadDeclAs<VarTemplateDecl>();
     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::VisitVarTemplatePart
     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<VarTemplatePartialSpecializationDecl>(Record, Idx));
+        ReadDeclAs<VarTemplatePartialSpecializationDecl>());
     D->InstantiatedFromMember.setInt(Record[Idx++]);
   }
 }
@@ -2189,7 +2175,7 @@ void ASTDeclReader::VisitTemplateTypePar
   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::VisitNonTypeTemplate
     auto TypesAndInfos =
         D->getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
     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::VisitTemplateTemplat
         D->getTrailingObjects<TemplateParameterList *>();
     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::VisitTypeAliasTempla
 
 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<StringLiteral>(Reader.ReadExpr(F));
-  D->RParenLoc = ReadSourceLocation(Record, Idx);
+  D->Message = cast_or_null<StringLiteral>(Record.ReadExpr());
+  D->RParenLoc = ReadSourceLocation();
 }
 
 void ASTDeclReader::VisitEmptyDecl(EmptyDecl *D) {
@@ -2250,15 +2236,15 @@ void ASTDeclReader::VisitEmptyDecl(Empty
 
 std::pair<uint64_t, uint64_t>
 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 <typename T>
 ASTDeclReader::RedeclarableResult
 ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) {
-  DeclID FirstDeclID = ReadDeclID(Record, Idx);
+  DeclID FirstDeclID = ReadDeclID();
   Decl *MergeWith = nullptr;
 
   bool IsKeyDecl = ThisDeclID == FirstDeclID;
@@ -2284,13 +2270,13 @@ ASTDeclReader::VisitRedeclarable(Redecla
     // 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<T>(Reader.GetDecl(FirstDeclID));
@@ -2301,7 +2287,7 @@ ASTDeclReader::VisitRedeclarable(Redecla
     // loaded & attached later on.
     D->RedeclLink = Redeclarable<T>::PreviousDeclLink(FirstDecl);
     D->First = FirstDecl->getCanonicalDecl();
-  }    
+  }
 
   T *DAsT = static_cast<T*>(D);
 
@@ -2354,10 +2340,10 @@ void ASTDeclReader::mergeTemplatePattern
                                          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<CXXRecordDecl>(DPattern)) {
     // Merge with any existing definition.
     // FIXME: This is duplicated in several places. Refactor.
@@ -2457,17 +2443,17 @@ void ASTDeclReader::VisitOMPThreadPrivat
   SmallVector<Expr *, 16> 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(se
       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,
   }
 }
 
-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<CXXRecordDecl>(D);
       // FIXME: If we also have an update record for instantiating the
       // definition of D, we need that to happen before we get here.
-      Decl *MD = 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,
 
     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<NamespaceDecl>(ModuleFile, Record, Idx);
-      
+      NamespaceDecl *Anon = ReadDeclAs<NamespaceDecl>();
+
       // 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<TranslationUnitDecl>(D))
           TU->setAnonymousNamespace(Anon);
         else
@@ -3814,7 +3798,7 @@ void ASTDeclReader::UpdateDecl(Decl *D,
 
     case UPD_CXX_INSTANTIATED_STATIC_DATA_MEMBER:
       cast<VarDecl>(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,
       // 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,
 
     case UPD_CXX_INSTANTIATED_DEFAULT_MEMBER_INITIALIZER: {
       auto FD = cast<FieldDecl>(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,
           FD->setImplicitlyInline();
         });
       }
-      FD->setInnerLocStart(Reader.ReadSourceLocation(ModuleFile, Record, Idx));
+      FD->setInnerLocStart(ReadSourceLocation());
       if (auto *CD = dyn_cast<CXXConstructorDecl>(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,
       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,
 
         if (Record[Idx++]) {
           auto PartialSpec =
-              ReadDeclAs<ClassTemplatePartialSpecializationDecl>(Record, Idx);
+              ReadDeclAs<ClassTemplatePartialSpecializationDecl>();
           SmallVector<TemplateArgument, 8> 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,
       }
 
       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,
     case UPD_CXX_RESOLVED_DTOR_DELETE: {
       // Set the 'operator delete' directly to avoid emitting another update
       // record.
-      auto *Del = Reader.ReadDeclAs<FunctionDecl>(ModuleFile, Record, Idx);
+      auto *Del = ReadDeclAs<FunctionDecl>();
       auto *First = cast<CXXDestructorDecl>(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,
     case UPD_CXX_RESOLVED_EXCEPTION_SPEC: {
       FunctionProtoType::ExceptionSpecInfo ESI;
       SmallVector<QualType, 8> ExceptionStorage;
-      Reader.readExceptionSpec(ModuleFile, ExceptionStorage, ESI, Record, Idx);
+      Record.readExceptionSpec(ExceptionStorage, ESI, Idx);
 
       // Update this declaration's exception specification, if needed.
       auto *FD = cast<FunctionDecl>(D);
@@ -3974,7 +3957,7 @@ void ASTDeclReader::UpdateDecl(Decl *D,
 
     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<FunctionDecl>(Redecl);
@@ -3999,11 +3982,11 @@ void ASTDeclReader::UpdateDecl(Decl *D,
 
     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<NamedDecl>(D);
       if (auto *TD = dyn_cast<TagDecl>(Exported))
         Exported = TD->getDefinition();
@@ -4027,7 +4010,7 @@ void ASTDeclReader::UpdateDecl(Decl *D,
     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;

Modified: cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderStmt.cpp?rev=289870&r1=289869&r2=289870&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderStmt.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderStmt.cpp Thu Dec 15 14:53:26 2016
@@ -26,62 +26,50 @@ namespace clang {
 
   class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
     friend class OMPClauseReader;
-    typedef ASTReader::RecordData RecordData;
-    
-    ASTReader &Reader;
-    ModuleFile &F;
+
+    ASTRecordReader Record;
     llvm::BitstreamCursor &DeclsCursor;
-    const ASTReader::RecordData &Record;
     unsigned &Idx;
 
-    Token ReadToken(const RecordData &R, unsigned &I) {
-      return Reader.ReadToken(F, R, I);
+    SourceLocation ReadSourceLocation() {
+      return Record.ReadSourceLocation(Idx);
     }
 
-    SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) {
-      return Reader.ReadSourceLocation(F, R, I);
+    SourceRange ReadSourceRange() {
+      return Record.ReadSourceRange(Idx);
     }
 
-    SourceRange ReadSourceRange(const RecordData &R, unsigned &I) {
-      return Reader.ReadSourceRange(F, R, I);
+    std::string ReadString() {
+      return Record.ReadString(Idx);
     }
 
-    std::string ReadString(const RecordData &R, unsigned &I) {
-      return Reader.ReadString(R, I);
-    }
-        
-    TypeSourceInfo *GetTypeSourceInfo(const RecordData &R, unsigned &I) {
-      return Reader.GetTypeSourceInfo(F, R, I);
-    }
-    
-    serialization::DeclID ReadDeclID(const RecordData &R, unsigned &I) {
-      return Reader.ReadDeclID(F, R, I);
+    TypeSourceInfo *GetTypeSourceInfo() {
+      return Record.GetTypeSourceInfo(Idx);
     }
-    
-    Decl *ReadDecl(const RecordData &R, unsigned &I) {
-      return Reader.ReadDecl(F, R, I);
+
+    Decl *ReadDecl() {
+      return Record.ReadDecl(Idx);
     }
-    
+
     template<typename T>
-    T *ReadDeclAs(const RecordData &R, unsigned &I) {
-      return Reader.ReadDeclAs<T>(F, R, I);
+    T *ReadDeclAs() {
+      return Record.ReadDeclAs<T>(Idx);
     }
 
-    void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name,
-                                const ASTReader::RecordData &R, unsigned &I) {
-      Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I);
-    }
-    
-    void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo,
-                                const ASTReader::RecordData &R, unsigned &I) {
-      Reader.ReadDeclarationNameInfo(F, NameInfo, R, I);
+    void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc,
+                                DeclarationName Name) {
+      Record.ReadDeclarationNameLoc(DNLoc, Name, Idx);
+    }
+
+    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(Co
   SmallVector<Stmt *, 16> 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<LabelDecl>(Record, Idx);
+  LabelDecl *LD = ReadDeclAs<LabelDecl>();
   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<VarDecl>(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<VarDecl>());
+  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<VarDecl>(Record, Idx));
-  S->setCond(Reader.ReadSubExpr());
-  S->setBody(Reader.ReadSubStmt());
-  S->setSwitchLoc(ReadSourceLocation(Record, Idx));
+  S->setInit(Record.ReadSubStmt());
+  S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
+  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(Swit
 
 void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
   VisitStmt(S);
-  S->setConditionVariable(Reader.getContext(),
-                          ReadDeclAs<VarDecl>(Record, Idx));
+  S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
 
-  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<VarDecl>(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<VarDecl>());
+  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<LabelDecl>(Record, Idx));
-  S->setGotoLoc(ReadSourceLocation(Record, Idx));
-  S->setLabelLoc(ReadSourceLocation(Record, Idx));
+  S->setLabel(ReadDeclAs<LabelDecl>());
+  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<VarDecl>(Record, Idx));
+  S->setRetValue(Record.ReadSubExpr());
+  S->setReturnLoc(ReadSourceLocation());
+  S->setNRVOCandidate(ReadDeclAs<VarDecl>());
 }
 
 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<Decl *, 16> 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->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<StringLiteral>(Reader.ReadSubStmt()));
+  S->setRParenLoc(ReadSourceLocation());
+  S->setAsmString(cast_or_null<StringLiteral>(Record.ReadSubStmt()));
 
   unsigned NumOutputs = S->getNumOutputs();
   unsigned NumInputs = S->getNumInputs();
@@ -324,34 +307,34 @@ void ASTStmtReader::VisitGCCAsmStmt(GCCA
   SmallVector<StringLiteral*, 16> Constraints;
   SmallVector<Stmt*, 16> Exprs;
   for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
-    Names.push_back(Reader.GetIdentifierInfo(F, Record, Idx));
-    Constraints.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
-    Exprs.push_back(Reader.ReadSubStmt());
+    Names.push_back(Record.GetIdentifierInfo(Idx));
+    Constraints.push_back(cast_or_null<StringLiteral>(Record.ReadSubStmt()));
+    Exprs.push_back(Record.ReadSubStmt());
   }
 
   // Constraints
   SmallVector<StringLiteral*, 16> Clobbers;
   for (unsigned I = 0; I != NumClobbers; ++I)
-    Clobbers.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
+    Clobbers.push_back(cast_or_null<StringLiteral>(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<Token, 16> 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(MSAsm
   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(MSAsm
   ConstraintsData.reserve(NumOperands);
   Constraints.reserve(NumOperands);
   for (unsigned i = 0; i != NumOperands; ++i) {
-    Exprs.push_back(cast<Expr>(Reader.ReadSubStmt()));
-    ConstraintsData.push_back(ReadString(Record, Idx));
+    Exprs.push_back(cast<Expr>(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(Coy
 void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
   VisitStmt(S);
   ++Idx;
-  S->setCapturedDecl(ReadDeclAs<CapturedDecl>(Record, Idx));
+  S->setCapturedDecl(ReadDeclAs<CapturedDecl>());
   S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record[Idx++]));
-  S->setCapturedRecordDecl(ReadDeclAs<RecordDecl>(Record, Idx));
+  S->setCapturedRecordDecl(ReadDeclAs<RecordDecl>());
 
   // 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<VarDecl>(Record, Idx));
+    I.VarAndKind.setPointer(ReadDeclAs<VarDecl>());
     I.VarAndKind
         .setInt(static_cast<CapturedStmt::VariableCaptureKind>(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<StringLiteral>(Reader.ReadSubExpr());
+  E->FnName = cast_or_null<StringLiteral>(Record.ReadSubExpr());
 }
 
 void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
@@ -464,40 +447,38 @@ void ASTStmtReader::VisitDeclRefExpr(Dec
 
   if (E->hasQualifier())
     new (E->getTrailingObjects<NestedNameSpecifierLoc>())
-        NestedNameSpecifierLoc(
-            Reader.ReadNestedNameSpecifierLoc(F, Record, Idx));
+        NestedNameSpecifierLoc(Record.ReadNestedNameSpecifierLoc(Idx));
 
   if (E->hasFoundDecl())
-    *E->getTrailingObjects<NamedDecl *>() = ReadDeclAs<NamedDecl>(Record, Idx);
+    *E->getTrailingObjects<NamedDecl *>() = ReadDeclAs<NamedDecl>();
 
   if (E->hasTemplateKWAndArgsInfo())
     ReadTemplateKWAndArgsInfo(
         *E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
         E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
 
-  E->setDecl(ReadDeclAs<ValueDecl>(Record, Idx));
-  E->setLocation(ReadSourceLocation(Record, Idx));
-  ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record, Idx);
+  E->setDecl(ReadDeclAs<ValueDecl>());
+  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<Stmt::APFloatSemantics>(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(S
 
   // 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<CharacterLiteral::CharacterKind>(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(Of
   ++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<OffsetOfNode::Kind>(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(Of
 
     case OffsetOfNode::Field:
       E->setComponent(
-          I, OffsetOfNode(Start, ReadDeclAs<FieldDecl>(Record, Idx), End));
+          I, OffsetOfNode(Start, ReadDeclAs<FieldDecl>(), 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<UnaryExprOrTypeTrait>(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(Memb
 
 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(CastEx
   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<OpaqueValueExpr>(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<OpaqueValueExpr>(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::VisitImplicitCastExp
 
 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<InitListExpr>(Reader.ReadSubStmt()))
+  if (InitListExpr *SyntForm = cast_or_null<InitListExpr>(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<FieldDecl>(Record, Idx);
+    E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>();
   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::VisitDesignatedInitE
   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<Designator, 4> Designators;
   while (Idx < Record.size()) {
     switch ((DesignatorTypes)Record[Idx++]) {
     case DESIG_FIELD_DECL: {
-      FieldDecl *Field = ReadDeclAs<FieldDecl>(Record, Idx);
-      SourceLocation DotLoc
-        = ReadSourceLocation(Record, Idx);
-      SourceLocation FieldLoc
-        = ReadSourceLocation(Record, Idx);
+      FieldDecl *Field = ReadDeclAs<FieldDecl>();
+      SourceLocation DotLoc = ReadSourceLocation();
+      SourceLocation FieldLoc = ReadSourceLocation();
       Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
                                        FieldLoc));
       Designators.back().setField(Field);
@@ -798,47 +777,40 @@ void ASTStmtReader::VisitDesignatedInitE
     }
 
     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(NoIn
 
 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::VisitImplicitValueIn
 
 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<LabelDecl>(Record, Idx));
+  E->setAmpAmpLoc(ReadSourceLocation());
+  E->setLabelLoc(ReadSourceLocation());
+  E->setLabel(ReadDeclAs<LabelDecl>());
 }
 
 void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
   VisitExpr(E);
-  E->setLParenLoc(ReadSourceLocation(Record, Idx));
-  E->setRParenLoc(ReadSourceLocation(Record, Idx));
-  E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt()));
+  E->setLParenLoc(ReadSourceLocation());
+  E->setRParenLoc(ReadSourceLocation());
+  E->setSubStmt(cast_or_null<CompoundStmt>(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::VisitShuffleVectorEx
   SmallVector<Expr *, 16> 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<BlockDecl>(Record, Idx));
+  E->setBlockDecl(ReadDeclAs<BlockDecl>());
 }
 
 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::VisitPseudoObjectExp
   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(Atom
   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(Atom
 
 void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
   VisitExpr(E);
-  E->setString(cast<StringLiteral>(Reader.ReadSubStmt()));
-  E->setAtLoc(ReadSourceLocation(Record, Idx));
+  E->setString(cast<StringLiteral>(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<ObjCMethodDecl>(Record, Idx);
-  E->Range = ReadSourceRange(Record, Idx);
+  E->SubExpr = Record.ReadSubStmt();
+  E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>();
+  E->Range = ReadSourceRange();
 }
 
 void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
@@ -989,9 +961,9 @@ void ASTStmtReader::VisitObjCArrayLitera
   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<ObjCMethodDecl>(Record, Idx);
-  E->Range = ReadSourceRange(Record, Idx);
+    Elements[I] = Record.ReadSubExpr();
+  E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
+  E->Range = ReadSourceRange();
 }
 
 void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
@@ -1005,45 +977,45 @@ void ASTStmtReader::VisitObjCDictionaryL
   ObjCDictionaryLiteral::ExpansionData *Expansions =
       E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
   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<ObjCMethodDecl>(Record, Idx);
-  E->Range = ReadSourceRange(Record, Idx);
+  E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
+  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<ObjCProtocolDecl>(Record, Idx));
-  E->setAtLoc(ReadSourceLocation(Record, Idx));
-  E->ProtoLoc = ReadSourceLocation(Record, Idx);
-  E->setRParenLoc(ReadSourceLocation(Record, Idx));
+  E->setProtocol(ReadDeclAs<ObjCProtocolDecl>());
+  E->setAtLoc(ReadSourceLocation());
+  E->ProtoLoc = ReadSourceLocation();
+  E->setRParenLoc(ReadSourceLocation());
 }
 
 void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
   VisitExpr(E);
-  E->setDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx));
-  E->setLocation(ReadSourceLocation(Record, Idx));
-  E->setOpLoc(ReadSourceLocation(Record, Idx));
-  E->setBase(Reader.ReadSubExpr());
+  E->setDecl(ReadDeclAs<ObjCIvarDecl>());
+  E->setLocation(ReadSourceLocation());
+  E->setOpLoc(ReadSourceLocation());
+  E->setBase(Record.ReadSubExpr());
   E->setIsArrow(Record[Idx++]);
   E->setIsFreeIvar(Record[Idx++]);
 }
@@ -1053,35 +1025,34 @@ void ASTStmtReader::VisitObjCPropertyRef
   unsigned MethodRefFlags = Record[Idx++];
   bool Implicit = Record[Idx++] != 0;
   if (Implicit) {
-    ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
-    ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
+    ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>();
+    ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>();
     E->setImplicitProperty(Getter, Setter, MethodRefFlags);
   } else {
-    E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(Record, Idx),
-                           MethodRefFlags);
+    E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(), 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<ObjCInterfaceDecl>(Record, Idx));
+    E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>());
     break;
   }
 }
 
 void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
   VisitExpr(E);
-  E->setRBracket(ReadSourceLocation(Record, Idx));
-  E->setBaseExpr(Reader.ReadSubExpr());
-  E->setKeyExpr(Reader.ReadSubExpr());
-  E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
-  E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
+  E->setRBracket(ReadSourceLocation());
+  E->setBaseExpr(Record.ReadSubExpr());
+  E->setKeyExpr(Record.ReadSubExpr());
+  E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
+  E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
 }
 
 void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
@@ -1089,24 +1060,24 @@ void ASTStmtReader::VisitObjCMessageExpr
   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<ObjCMessageExpr::ReceiverKind>(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
   assert(Kind == E->getReceiverKind());
 
   if (Record[Idx++])
-    E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx));
+    E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>());
   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<VarDecl>(Record, Idx));
-  S->setAtCatchLoc(ReadSourceLocation(Record, Idx));
-  S->setRParenLoc(ReadSourceLocation(Record, Idx));
+  S->setCatchBody(Record.ReadSubStmt());
+  S->setCatchParamDecl(ReadDeclAs<VarDecl>());
+  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(O
   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<ObjCAtCatchStmt>(Reader.ReadSubStmt()));
+    S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(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::VisitObjCAvailabilit
 
 void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
   VisitStmt(S);
-  S->CatchLoc = ReadSourceLocation(Record, Idx);
-  S->ExceptionDecl = ReadDeclAs<VarDecl>(Record, Idx);
-  S->HandlerBlock = Reader.ReadSubStmt();
+  S->CatchLoc = ReadSourceLocation();
+  S->ExceptionDecl = ReadDeclAs<VarDecl>();
+  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::VisitCXXConstructExp
   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<CXXConstructorDecl>(Record, Idx));
-  E->setLocation(ReadSourceLocation(Record, Idx));
+    E->setArg(I, Record.ReadSubExpr());
+  E->setConstructor(ReadDeclAs<CXXConstructorDecl>());
+  E->setLocation(ReadSourceLocation());
   E->setElidable(Record[Idx++]);
   E->setHadMultipleCandidates(Record[Idx++]);
   E->setListInitialization(Record[Idx++]);
   E->setStdInitListInitialization(Record[Idx++]);
   E->setRequiresZeroInitialization(Record[Idx++]);
   E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]);
-  E->ParenOrBraceRange = ReadSourceRange(Record, Idx);
+  E->ParenOrBraceRange = ReadSourceRange();
 }
 
 void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
   VisitExpr(E);
-  E->Constructor = ReadDeclAs<CXXConstructorDecl>(Record, Idx);
-  E->Loc = ReadSourceLocation(Record, Idx);
+  E->Constructor = ReadDeclAs<CXXConstructorDecl>();
+  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<LambdaCaptureDefault>(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::VisitCXXConstCastExp
 
 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<ParmVarDecl>(Record, Idx);
-  E->Loc = ReadSourceLocation(Record, Idx);
+  E->Param = ReadDeclAs<ParmVarDecl>();
+  E->Loc = ReadSourceLocation();
 }
 
 void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
   VisitExpr(E);
-  E->Field = ReadDeclAs<FieldDecl>(Record, Idx);
-  E->Loc = ReadSourceLocation(Record, Idx);
+  E->Field = ReadDeclAs<FieldDecl>();
+  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(CXXN
   E->UsualArrayDeleteWantsSize = Record[Idx++];
   unsigned NumPlacementArgs = Record[Idx++];
   E->StoredInitializationStyle = Record[Idx++];
-  E->setOperatorNew(ReadDeclAs<FunctionDecl>(Record, Idx));
-  E->setOperatorDelete(ReadDeclAs<FunctionDecl>(Record, Idx));
-  E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx);
-  E->TypeIdParens = ReadSourceRange(Record, Idx);
-  E->Range = ReadSourceRange(Record, Idx);
-  E->DirectInitRange = ReadSourceRange(Record, Idx);
+  E->setOperatorNew(ReadDeclAs<FunctionDecl>());
+  E->setOperatorDelete(ReadDeclAs<FunctionDecl>());
+  E->AllocatedTypeInfo = GetTypeSourceInfo();
+  E->TypeIdParens = ReadSourceRange();
+  E->Range = ReadSourceRange();
+  E->DirectInitRange = ReadSourceRange();
 
-  E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs,
+  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(C
   E->ArrayForm = Record[Idx++];
   E->ArrayFormAsWritten = Record[Idx++];
   E->UsualArrayDeleteWantsSize = Record[Idx++];
-  E->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx);
-  E->Argument = Reader.ReadSubExpr();
-  E->Loc = ReadSourceLocation(Record, Idx);
+  E->OperatorDelete = ReadDeclAs<FunctionDecl>();
+  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::VisitExprWithCleanup
   assert(NumObjects == E->getNumObjects());
   for (unsigned i = 0; i != NumObjects; ++i)
     E->getTrailingObjects<BlockDecl *>()[i] =
-        ReadDeclAs<BlockDecl>(Record, Idx);
+        ReadDeclAs<BlockDecl>();
 
   E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record[Idx++];
-  E->SubExpr = Reader.ReadSubExpr();
+  E->SubExpr = Record.ReadSubExpr();
 }
 
 void
@@ -1480,13 +1451,13 @@ ASTStmtReader::VisitCXXDependentScopeMem
         E->getTrailingObjects<TemplateArgumentLoc>(),
         /*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<NamedDecl>(Record, Idx);
-  ReadDeclarationNameInfo(E->MemberNameInfo, Record, Idx);
+  E->OperatorLoc = ReadSourceLocation();
+  E->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx);
+  E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>();
+  ReadDeclarationNameInfo(E->MemberNameInfo);
 }
 
 void
@@ -1499,8 +1470,8 @@ ASTStmtReader::VisitDependentScopeDeclRe
         E->getTrailingObjects<TemplateArgumentLoc>(),
         /*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::VisitCXXUnresolvedConstru
   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(Ov
   unsigned NumDecls = Record[Idx++];
   UnresolvedSet<8> Decls;
   for (unsigned i = 0; i != NumDecls; ++i) {
-    NamedDecl *D = ReadDeclAs<NamedDecl>(Record, Idx);
+    NamedDecl *D = ReadDeclAs<NamedDecl>();
     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<CXXRecordDecl>(Record, Idx);
+  E->NamingClass = ReadDeclAs<CXXRecordDecl>();
 }
 
 void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
@@ -1557,32 +1528,32 @@ void ASTStmtReader::VisitTypeTraitExpr(T
   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<TypeSourceInfo *>();
   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::VisitExpressionTrait
 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<NamedDecl>(F, Record, Idx);
+  E->OperatorLoc = ReadSourceLocation();
+  E->PackLoc = ReadSourceLocation();
+  E->RParenLoc = ReadSourceLocation();
+  E->Pack = Record.ReadDeclAs<NamedDecl>(Idx);
   if (E->isPartiallySubstituted()) {
     assert(E->Length == NumPartialArgs);
     for (auto *I = E->getTrailingObjects<TemplateArgument>(),
               *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(
 void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
                                               SubstNonTypeTemplateParmExpr *E) {
   VisitExpr(E);
-  E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
-  E->NameLoc = ReadSourceLocation(Record, Idx);
-  E->Replacement = Reader.ReadSubExpr();
+  E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
+  E->NameLoc = ReadSourceLocation();
+  E->Replacement = Record.ReadSubExpr();
 }
 
 void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
                                           SubstNonTypeTemplateParmPackExpr *E) {
   VisitExpr(E);
-  E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
-  TemplateArgument ArgPack = Reader.ReadTemplateArgument(F, Record, Idx);
+  E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
+  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<ParmVarDecl>(Record, Idx);
-  E->NameLoc = ReadSourceLocation(Record, Idx);
+  E->ParamPack = ReadDeclAs<ParmVarDecl>();
+  E->NameLoc = ReadSourceLocation();
   ParmVarDecl **Parms = E->getTrailingObjects<ParmVarDecl *>();
   for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
-    Parms[i] = ReadDeclAs<ParmVarDecl>(Record, Idx);
+    Parms[i] = ReadDeclAs<ParmVarDecl>();
 }
 
 void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
   VisitExpr(E);
-  E->State = Reader.ReadSubExpr();
-  auto VD = ReadDeclAs<ValueDecl>(Record, Idx);
+  E->State = Record.ReadSubExpr();
+  auto VD = ReadDeclAs<ValueDecl>();
   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(TypoEx
 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<MSPropertyDecl>(Record, Idx);
+  E->BaseExpr = Record.ReadSubExpr();
+  E->QualifierLoc = Record.ReadNestedNameSpecifierLoc(Idx);
+  E->MemberLoc = ReadSourceLocation();
+  E->TheDecl = ReadDeclAs<MSPropertyDecl>();
 }
 
 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(SEHT
 
 void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
   VisitCallExpr(E);
-  E->setConfig(cast<CallExpr>(Reader.ReadSubExpr()));
+  E->setConfig(cast<CallExpr>(Record.ReadSubExpr()));
 }
 
 //===----------------------------------------------------------------------===//
@@ -1752,9 +1723,9 @@ void ASTStmtReader::VisitCUDAKernelCallE
 //===----------------------------------------------------------------------===//
 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<OMPClauseReader> {
   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<OpenMPDirectiveKind>(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<OpenMPDirectiveKind>(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<OpenMPDefaultClauseKind>(Record[Idx++]));
-  C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
-  C->setDefaultKindKwLoc(Reader->ReadSourceLocation(Record, Idx));
+       static_cast<OpenMPDefaultClauseKind>(Reader->Record[Idx++]));
+  C->setLParenLoc(Reader->ReadSourceLocation());
+  C->setDefaultKindKwLoc(Reader->ReadSourceLocation());
 }
 
 void OMPClauseReader::VisitOMPProcBindClause(OMPProcBindClause *C) {
   C->setProcBindKind(
-       static_cast<OpenMPProcBindClauseKind>(Record[Idx++]));
-  C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
-  C->setProcBindKindKwLoc(Reader->ReadSourceLocation(Record, Idx));
+       static_cast<OpenMPProcBindClauseKind>(Reader->Record[Idx++]));
+  C->setLParenLoc(Reader->ReadSourceLocation());
+  C->setProcBindKindKwLoc(Reader->ReadSourceLocation());
 }
 
 void OMPClauseReader::VisitOMPScheduleClause(OMPScheduleClause *C) {
   VisitOMPClauseWithPreInit(C);
   C->setScheduleKind(
-       static_cast<OpenMPScheduleClauseKind>(Record[Idx++]));
+       static_cast<OpenMPScheduleClauseKind>(Reader->Record[Idx++]));
   C->setFirstScheduleModifier(
-      static_cast<OpenMPScheduleClauseModifier>(Record[Idx++]));
+      static_cast<OpenMPScheduleClauseModifier>(Reader->Record[Idx++]));
   C->setSecondScheduleModifier(
-      static_cast<OpenMPScheduleClauseModifier>(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<OpenMPScheduleClauseModifier>(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
 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<Expr *, 16> 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<Expr *, 16> 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<Expr *, 16> 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<Expr *, 16> 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::VisitOMPReductionC
   SmallVector<Expr *, 16> 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<OpenMPLinearClauseKind>(Record[Idx++]));
-  C->setModifierLoc(Reader->ReadSourceLocation(Record, Idx));
+  C->setLParenLoc(Reader->ReadSourceLocation());
+  C->setColonLoc(Reader->ReadSourceLocation());
+  C->setModifier(static_cast<OpenMPLinearClauseKind>(Reader->Record[Idx++]));
+  C->setModifierLoc(Reader->ReadSourceLocation());
   unsigned NumVars = C->varlist_size();
   SmallVector<Expr *, 16> 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<Expr *, 16> 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<Expr *, 16> 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<Expr *, 16> 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<Expr *, 16> 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<OpenMPDependClauseKind>(Record[Idx++]));
-  C->setDependencyLoc(Reader->ReadSourceLocation(Record, Idx));
-  C->setColonLoc(Reader->ReadSourceLocation(Record, Idx));
+  C->setLParenLoc(Reader->ReadSourceLocation());
+  C->setDependencyKind(
+      static_cast<OpenMPDependClauseKind>(Reader->Record[Idx++]));
+  C->setDependencyLoc(Reader->ReadSourceLocation());
+  C->setColonLoc(Reader->ReadSourceLocation());
   unsigned NumVars = C->varlist_size();
   SmallVector<Expr *, 16> 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<OpenMPMapClauseKind>(Record[Idx++]));
+     static_cast<OpenMPMapClauseKind>(Reader->Record[Idx++]));
   C->setMapType(
-     static_cast<OpenMPMapClauseKind>(Record[Idx++]));
-  C->setMapLoc(Reader->ReadSourceLocation(Record, Idx));
-  C->setColonLoc(Reader->ReadSourceLocation(Record, Idx));
+     static_cast<OpenMPMapClauseKind>(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(
   SmallVector<Expr *, 16> 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<ValueDecl *, 16> Decls;
   Decls.reserve(UniqueDecls);
   for (unsigned i = 0; i < UniqueDecls; ++i)
-    Decls.push_back(
-        Reader->Reader.ReadDeclAs<ValueDecl>(Reader->F, Record, Idx));
+    Decls.push_back(Reader->Record.ReadDeclAs<ValueDecl>(Idx));
   C->setUniqueDecls(Decls);
 
   SmallVector<unsigned, 16> 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<unsigned, 32> 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<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
   Components.reserve(TotalComponents);
   for (unsigned i = 0; i < TotalComponents; ++i) {
-    Expr *AssociatedExpr = Reader->Reader.ReadSubExpr();
-    ValueDecl *AssociatedDecl =
-        Reader->Reader.ReadDeclAs<ValueDecl>(Reader->F, Record, Idx);
+    Expr *AssociatedExpr = Reader->Record.ReadSubExpr();
+    ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs<ValueDecl>(Idx);
     Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
         AssociatedExpr, AssociatedDecl));
   }
@@ -2330,57 +2297,57 @@ void OMPClauseReader::VisitOMPMapClause(
 }
 
 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<OpenMPDistScheduleClauseKind>(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<OpenMPDistScheduleClauseKind>(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<OpenMPDefaultmapClauseKind>(Record[Idx++]));
+       static_cast<OpenMPDefaultmapClauseKind>(Reader->Record[Idx++]));
   C->setDefaultmapModifier(
-      static_cast<OpenMPDefaultmapClauseModifier>(Record[Idx++]));
-  C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
-  C->setDefaultmapModifierLoc(Reader->ReadSourceLocation(Record, Idx));
-  C->setDefaultmapKindLoc(Reader->ReadSourceLocation(Record, Idx));
+      static_cast<OpenMPDefaultmapClauseModifier>(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(O
   SmallVector<Expr *, 16> 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<ValueDecl *, 16> Decls;
   Decls.reserve(UniqueDecls);
   for (unsigned i = 0; i < UniqueDecls; ++i)
-    Decls.push_back(
-        Reader->Reader.ReadDeclAs<ValueDecl>(Reader->F, Record, Idx));
+    Decls.push_back(Reader->Record.ReadDeclAs<ValueDecl>(Idx));
   C->setUniqueDecls(Decls);
 
   SmallVector<unsigned, 16> 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<unsigned, 32> 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<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
   Components.reserve(TotalComponents);
   for (unsigned i = 0; i < TotalComponents; ++i) {
-    Expr *AssociatedExpr = Reader->Reader.ReadSubExpr();
-    ValueDecl *AssociatedDecl =
-        Reader->Reader.ReadDeclAs<ValueDecl>(Reader->F, Record, Idx);
+    Expr *AssociatedExpr = Reader->Record.ReadSubExpr();
+    ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs<ValueDecl>(Idx);
     Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
         AssociatedExpr, AssociatedDecl));
   }
@@ -2424,7 +2389,7 @@ void OMPClauseReader::VisitOMPToClause(O
 }
 
 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
   SmallVector<Expr *, 16> 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<ValueDecl *, 16> Decls;
   Decls.reserve(UniqueDecls);
   for (unsigned i = 0; i < UniqueDecls; ++i)
-    Decls.push_back(
-        Reader->Reader.ReadDeclAs<ValueDecl>(Reader->F, Record, Idx));
+    Decls.push_back(Reader->Record.ReadDeclAs<ValueDecl>(Idx));
   C->setUniqueDecls(Decls);
 
   SmallVector<unsigned, 16> 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<unsigned, 32> 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<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
   Components.reserve(TotalComponents);
   for (unsigned i = 0; i < TotalComponents; ++i) {
-    Expr *AssociatedExpr = Reader->Reader.ReadSubExpr();
-    ValueDecl *AssociatedDecl =
-        Reader->Reader.ReadDeclAs<ValueDecl>(Reader->F, Record, Idx);
+    Expr *AssociatedExpr = Reader->Record.ReadSubExpr();
+    ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs<ValueDecl>(Idx);
     Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
         AssociatedExpr, AssociatedDecl));
   }
@@ -2468,7 +2431,7 @@ void OMPClauseReader::VisitOMPFromClause
 }
 
 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::VisitOMPUseDeviceP
   SmallVector<Expr *, 16> 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<ValueDecl *, 16> Decls;
   Decls.reserve(UniqueDecls);
   for (unsigned i = 0; i < UniqueDecls; ++i)
-    Decls.push_back(
-        Reader->Reader.ReadDeclAs<ValueDecl>(Reader->F, Record, Idx));
+    Decls.push_back(Reader->Record.ReadDeclAs<ValueDecl>(Idx));
   C->setUniqueDecls(Decls);
 
   SmallVector<unsigned, 16> 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<unsigned, 32> 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<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
   Components.reserve(TotalComponents);
   for (unsigned i = 0; i < TotalComponents; ++i) {
-    Expr *AssociatedExpr = Reader->Reader.ReadSubExpr();
-    ValueDecl *AssociatedDecl =
-        Reader->Reader.ReadDeclAs<ValueDecl>(Reader->F, Record, Idx);
+    Expr *AssociatedExpr = Reader->Record.ReadSubExpr();
+    ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs<ValueDecl>(Idx);
     Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
         AssociatedExpr, AssociatedDecl));
   }
@@ -2520,7 +2481,7 @@ void OMPClauseReader::VisitOMPUseDeviceP
 }
 
 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::VisitOMPIsDevicePt
   SmallVector<Expr *, 16> 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<ValueDecl *, 16> Decls;
   Decls.reserve(UniqueDecls);
   for (unsigned i = 0; i < UniqueDecls; ++i)
-    Decls.push_back(
-        Reader->Reader.ReadDeclAs<ValueDecl>(Reader->F, Record, Idx));
+    Decls.push_back(Reader->Record.ReadDeclAs<ValueDecl>(Idx));
   C->setUniqueDecls(Decls);
 
   SmallVector<unsigned, 16> 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<unsigned, 32> 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<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
   Components.reserve(TotalComponents);
   for (unsigned i = 0; i < TotalComponents; ++i) {
-    Expr *AssociatedExpr = Reader->Reader.ReadSubExpr();
-    ValueDecl *AssociatedDecl =
-        Reader->Reader.ReadDeclAs<ValueDecl>(Reader->F, Record, Idx);
+    Expr *AssociatedExpr = Reader->Record.ReadSubExpr();
+    ValueDecl *AssociatedDecl = Reader->Record.ReadDeclAs<ValueDecl>(Idx);
     Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
         AssociatedExpr, AssociatedDecl));
   }
@@ -2568,15 +2527,15 @@ void OMPClauseReader::VisitOMPIsDevicePt
 // 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<OMPClause *, 5> 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::VisitOMPLoopDirectiv
   // 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<Expr *, 4> 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::VisitOMPCriticalDire
   // 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::VisitOMPAtomicDirect
   // 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(Modu
 
   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<uint64_t, Stmt *> StmtEntries;
@@ -2937,7 +2896,7 @@ Stmt *ASTReader::ReadStmtFromStream(Modu
 
   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(Modu
       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(Modu
       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(Modu
     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(Modu
     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(Modu
     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(Modu
       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(Modu
     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(Modu
     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;




More information about the cfe-commits mailing list