Remove the serialization code that predates precompiled
headers. Future approaches to (de-)serializing ASTs will be based on
the PCH infrastructure.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69828 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Basic/CMakeLists.txt b/lib/Basic/CMakeLists.txt
index a3731cb..1cbf11c 100644
--- a/lib/Basic/CMakeLists.txt
+++ b/lib/Basic/CMakeLists.txt
@@ -5,7 +5,6 @@
   Diagnostic.cpp
   FileManager.cpp
   IdentifierTable.cpp
-  LangOptions.cpp
   SourceLocation.cpp
   SourceManager.cpp
   TargetInfo.cpp
diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp
index 773d366..2cd140d 100644
--- a/lib/Basic/FileManager.cpp
+++ b/lib/Basic/FileManager.cpp
@@ -19,8 +19,6 @@
 
 #include "clang/Basic/FileManager.h"
 #include "llvm/ADT/SmallString.h"
-#include "llvm/Bitcode/Serialize.h"
-#include "llvm/Bitcode/Deserialize.h"
 #include "llvm/Support/Streams.h"
 #include "llvm/Config/config.h"
 using namespace clang;
diff --git a/lib/Basic/IdentifierTable.cpp b/lib/Basic/IdentifierTable.cpp
index 78758d7..344c4eb 100644
--- a/lib/Basic/IdentifierTable.cpp
+++ b/lib/Basic/IdentifierTable.cpp
@@ -16,8 +16,6 @@
 #include "clang/Basic/LangOptions.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/DenseMap.h"
-#include "llvm/Bitcode/Serialize.h"
-#include "llvm/Bitcode/Deserialize.h"
 #include <cstdio>
 
 using namespace clang;
@@ -54,10 +52,6 @@
   AddKeywords(LangOpts);
 }
 
-// This cstor is intended to be used only for serialization.
-IdentifierTable::IdentifierTable() 
-  : HashTable(8192), ExternalLookup(0) { }
-
 //===----------------------------------------------------------------------===//
 // Language Keyword Implementation
 //===----------------------------------------------------------------------===//
@@ -264,7 +258,6 @@
 /// this class is provided strictly through Selector.
 class MultiKeywordSelector 
   : public DeclarationNameExtra, public llvm::FoldingSetNode {
-  friend SelectorTable* SelectorTable::CreateAndRegister(llvm::Deserializer&);
   MultiKeywordSelector(unsigned nKeys) {
     ExtraKindOrNumArgs = NUM_EXTRA_KINDS + nKeys;
   }
@@ -414,155 +407,3 @@
   delete &getSelectorTableImpl(Impl);
 }
 
-//===----------------------------------------------------------------------===//
-// Serialization for IdentifierInfo and IdentifierTable.
-//===----------------------------------------------------------------------===//
-
-void IdentifierInfo::Emit(llvm::Serializer& S) const {
-  S.EmitInt(getTokenID());
-  S.EmitInt(getBuiltinID());
-  S.EmitInt(getObjCKeywordID());  
-  S.EmitBool(hasMacroDefinition());
-  S.EmitBool(isExtensionToken());
-  S.EmitBool(isPoisoned());
-  S.EmitBool(isCPlusPlusOperatorKeyword());
-  // FIXME: FETokenInfo
-}
-
-void IdentifierInfo::Read(llvm::Deserializer& D) {
-  setTokenID((tok::TokenKind) D.ReadInt());
-  setBuiltinID(D.ReadInt());  
-  setObjCKeywordID((tok::ObjCKeywordKind) D.ReadInt());  
-  setHasMacroDefinition(D.ReadBool());
-  setIsExtensionToken(D.ReadBool());
-  setIsPoisoned(D.ReadBool());
-  setIsCPlusPlusOperatorKeyword(D.ReadBool());
-  // FIXME: FETokenInfo
-}
-
-void IdentifierTable::Emit(llvm::Serializer& S) const {
-  S.EnterBlock();
-  
-  S.EmitPtr(this);
-  
-  for (iterator I=begin(), E=end(); I != E; ++I) {
-    const char* Key = I->getKeyData();
-    const IdentifierInfo* Info = I->getValue();
-    
-    bool KeyRegistered = S.isRegistered(Key);
-    bool InfoRegistered = S.isRegistered(Info);
-    
-    if (KeyRegistered || InfoRegistered) {
-      // These acrobatics are so that we don't incur the cost of registering
-      // a pointer with the backpatcher during deserialization if nobody
-      // references the object.
-      S.EmitPtr(InfoRegistered ? Info : NULL);
-      S.EmitPtr(KeyRegistered ? Key : NULL);
-      S.EmitCStr(Key);
-      S.Emit(*Info);
-    }
-  }
-  
-  S.ExitBlock();
-}
-
-IdentifierTable* IdentifierTable::CreateAndRegister(llvm::Deserializer& D) {
-  llvm::Deserializer::Location BLoc = D.getCurrentBlockLocation();
-
-  std::vector<char> buff;
-  buff.reserve(200);
-
-  IdentifierTable* t = new IdentifierTable();
-  D.RegisterPtr(t);  
-  
-  while (!D.FinishedBlock(BLoc)) {
-    llvm::SerializedPtrID InfoPtrID = D.ReadPtrID();
-    llvm::SerializedPtrID KeyPtrID = D.ReadPtrID();
-    
-    D.ReadCStr(buff);
-    IdentifierInfo *II = &t->get(&buff[0], &buff[0] + buff.size());
-    II->Read(D);
-    
-    if (InfoPtrID) D.RegisterPtr(InfoPtrID, II);
-    if (KeyPtrID)  D.RegisterPtr(KeyPtrID, II->getName());
-  }
-  
-  return t;
-}
-
-//===----------------------------------------------------------------------===//
-// Serialization for Selector and SelectorTable.
-//===----------------------------------------------------------------------===//
-
-void Selector::Emit(llvm::Serializer& S) const {
-  S.EmitInt(getIdentifierInfoFlag());
-  S.EmitPtr(reinterpret_cast<void*>(InfoPtr & ~ArgFlags));
-}
-
-Selector Selector::ReadVal(llvm::Deserializer& D) {
-  unsigned flag = D.ReadInt();
-  
-  uintptr_t ptr;  
-  D.ReadUIntPtr(ptr,false); // No backpatching.
-  
-  return Selector(ptr | flag);
-}
-
-void SelectorTable::Emit(llvm::Serializer& S) const {
-  typedef llvm::FoldingSet<MultiKeywordSelector>::iterator iterator;
-  llvm::FoldingSet<MultiKeywordSelector> *SelTab;
-  SelTab = static_cast<llvm::FoldingSet<MultiKeywordSelector> *>(Impl);
-  
-  S.EnterBlock();
-  
-  S.EmitPtr(this);
-  
-  for (iterator I=SelTab->begin(), E=SelTab->end(); I != E; ++I) {
-    if (!S.isRegistered(&*I))
-      continue;
-    
-    S.FlushRecord(); // Start a new record.
-
-    S.EmitPtr(&*I);
-    S.EmitInt(I->getNumArgs());
-
-    for (MultiKeywordSelector::keyword_iterator KI = I->keyword_begin(),
-         KE = I->keyword_end(); KI != KE; ++KI)
-      S.EmitPtr(*KI);
-  }
-  
-  S.ExitBlock();
-}
-
-SelectorTable* SelectorTable::CreateAndRegister(llvm::Deserializer& D) {
-  llvm::Deserializer::Location BLoc = D.getCurrentBlockLocation();
-  
-  SelectorTable* t = new SelectorTable();
-  D.RegisterPtr(t);
-  
-  llvm::FoldingSet<MultiKeywordSelector>& SelTab =
-    *static_cast<llvm::FoldingSet<MultiKeywordSelector>*>(t->Impl);
-
-  while (!D.FinishedBlock(BLoc)) {
-
-    llvm::SerializedPtrID PtrID = D.ReadPtrID();
-    unsigned nKeys = D.ReadInt();
-    
-    MultiKeywordSelector *SI = 
-      (MultiKeywordSelector*)malloc(sizeof(MultiKeywordSelector) + 
-                                    nKeys*sizeof(IdentifierInfo *));
-
-    new (SI) MultiKeywordSelector(nKeys);
-    
-    D.RegisterPtr(PtrID,SI);
-
-    IdentifierInfo **KeyInfo = reinterpret_cast<IdentifierInfo **>(SI+1);
-
-    for (unsigned i = 0; i != nKeys; ++i)
-      D.ReadPtr(KeyInfo[i],false);
-    
-    SelTab.GetOrInsertNode(SI);
-  }
-  
-  return t;
-}
diff --git a/lib/Basic/LangOptions.cpp b/lib/Basic/LangOptions.cpp
deleted file mode 100644
index 6119afc..0000000
--- a/lib/Basic/LangOptions.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-//===--- LangOptions.cpp - Language feature info --------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-//  This file implements the methods for LangOptions.
-//
-//===----------------------------------------------------------------------===//
-
-#include "clang/Basic/LangOptions.h"
-#include "llvm/Bitcode/Serialize.h"
-#include "llvm/Bitcode/Deserialize.h"
-
-using namespace clang;
-
-void LangOptions::Emit(llvm::Serializer& S) const {
-  S.EmitBool((bool) Trigraphs);
-  S.EmitBool((bool) BCPLComment);
-  S.EmitBool((bool) DollarIdents);
-  S.EmitBool((bool) Digraphs);
-  S.EmitBool((bool) HexFloats);
-  S.EmitBool((bool) C99);
-  S.EmitBool((bool) Microsoft);
-  S.EmitBool((bool) CPlusPlus);
-  S.EmitBool((bool) CPlusPlus0x);
-  S.EmitBool((bool) NoExtensions);
-  S.EmitBool((bool) CXXOperatorNames);             
-  S.EmitBool((bool) ObjC1);
-  S.EmitBool((bool) ObjC2);
-  S.EmitBool((unsigned) GC);
-  S.EmitBool((bool) PascalStrings);
-  S.EmitBool((bool) Boolean);
-  S.EmitBool((bool) WritableStrings);
-  S.EmitBool((bool) LaxVectorConversions);
-}
-
-void LangOptions::Read(llvm::Deserializer& D) {
-  Trigraphs = D.ReadBool() ? 1 : 0;
-  BCPLComment = D.ReadBool() ? 1 : 0;
-  DollarIdents = D.ReadBool() ? 1 : 0;
-  Digraphs = D.ReadBool() ? 1 : 0;
-  HexFloats = D.ReadBool() ? 1 : 0;
-  C99 = D.ReadBool() ? 1 : 0;
-  Microsoft = D.ReadBool() ? 1 : 0;
-  CPlusPlus = D.ReadBool() ? 1 : 0;
-  CPlusPlus0x = D.ReadBool() ? 1 : 0;
-  NoExtensions = D.ReadBool() ? 1 : 0;
-  CXXOperatorNames = D.ReadBool() ? 1 : 0;
-  ObjC1 = D.ReadBool() ? 1 : 0;
-  ObjC2 = D.ReadBool() ? 1 : 0;
-  GC = D.ReadInt();
-  PascalStrings = D.ReadBool() ? 1 : 0;
-  Boolean = D.ReadBool() ? 1 : 0;
-  WritableStrings = D.ReadBool() ? 1 : 0;
-  LaxVectorConversions = D.ReadBool() ? 1 : 0;
-}
diff --git a/lib/Basic/SourceLocation.cpp b/lib/Basic/SourceLocation.cpp
index 82e24d0..f21ec8b 100644
--- a/lib/Basic/SourceLocation.cpp
+++ b/lib/Basic/SourceLocation.cpp
@@ -7,7 +7,6 @@
 //
 //===----------------------------------------------------------------------===//
 //
-//  This file defines serialization methods for the SourceLocation class.
 //  This file defines accessor methods for the FullSourceLoc class.
 //
 //===----------------------------------------------------------------------===//
@@ -15,8 +14,6 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/PrettyStackTrace.h"
 #include "clang/Basic/SourceManager.h"
-#include "llvm/Bitcode/Serialize.h"
-#include "llvm/Bitcode/Deserialize.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/raw_ostream.h"
 #include <cstdio>
@@ -38,14 +35,6 @@
 // SourceLocation
 //===----------------------------------------------------------------------===//
 
-void SourceLocation::Emit(llvm::Serializer& S) const {
-  S.EmitInt(getRawEncoding());  
-}
-
-SourceLocation SourceLocation::ReadVal(llvm::Deserializer& D) {
-  return SourceLocation::getFromRawEncoding(D.ReadInt());   
-}
-
 void SourceLocation::print(llvm::raw_ostream &OS, const SourceManager &SM)const{
   if (!isValid()) {
     OS << "<invalid loc>";
@@ -71,17 +60,6 @@
   print(llvm::errs(), SM);
 }
 
-void SourceRange::Emit(llvm::Serializer& S) const {
-  B.Emit(S);
-  E.Emit(S);
-}
-
-SourceRange SourceRange::ReadVal(llvm::Deserializer& D) {
-  SourceLocation A = SourceLocation::ReadVal(D);
-  SourceLocation B = SourceLocation::ReadVal(D);
-  return SourceRange(A,B);
-}
-
 //===----------------------------------------------------------------------===//
 // FullSourceLoc
 //===----------------------------------------------------------------------===//
diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp
index ed541bf..9ed2163 100644
--- a/lib/Basic/SourceManager.cpp
+++ b/lib/Basic/SourceManager.cpp
@@ -17,10 +17,9 @@
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/System/Path.h"
-#include "llvm/Bitcode/Serialize.h"
-#include "llvm/Bitcode/Deserialize.h"
 #include "llvm/Support/Streams.h"
 #include <algorithm>
+#include <iostream>
 using namespace clang;
 using namespace SrcMgr;
 using llvm::MemoryBuffer;
@@ -866,134 +865,3 @@
   llvm::cerr << "FileID scans: " << NumLinearScans << " linear, "
              << NumBinaryProbes << " binary.\n";
 }
-
-//===----------------------------------------------------------------------===//
-// Serialization.
-//===----------------------------------------------------------------------===//
-  
-void ContentCache::Emit(llvm::Serializer& S) const {
-  S.FlushRecord();
-  S.EmitPtr(this);
-
-  if (Entry) {
-    llvm::sys::Path Fname(Buffer->getBufferIdentifier());
-
-    if (Fname.isAbsolute())
-      S.EmitCStr(Fname.c_str());
-    else {
-      // Create an absolute path.
-      // FIXME: This will potentially contain ".." and "." in the path.
-      llvm::sys::Path path = llvm::sys::Path::GetCurrentDirectory();
-      path.appendComponent(Fname.c_str());      
-      S.EmitCStr(path.c_str());
-    }
-  }
-  else {
-    const char* p = Buffer->getBufferStart();
-    const char* e = Buffer->getBufferEnd();
-    
-    S.EmitInt(e-p);
-    
-    for ( ; p != e; ++p)
-      S.EmitInt(*p);    
-  }
-  
-  S.FlushRecord();  
-}
-
-void ContentCache::ReadToSourceManager(llvm::Deserializer& D,
-                                       SourceManager& SMgr,
-                                       FileManager* FMgr,
-                                       std::vector<char>& Buf) {
-  if (FMgr) {
-    llvm::SerializedPtrID PtrID = D.ReadPtrID();    
-    D.ReadCStr(Buf,false);
-    
-    // Create/fetch the FileEntry.
-    const char* start = &Buf[0];
-    const FileEntry* E = FMgr->getFile(start,start+Buf.size());
-    
-    // FIXME: Ideally we want a lazy materialization of the ContentCache
-    //  anyway, because we don't want to read in source files unless this
-    //  is absolutely needed.
-    if (!E)
-      D.RegisterPtr(PtrID,NULL);
-    else
-      // Get the ContextCache object and register it with the deserializer.
-      D.RegisterPtr(PtrID, SMgr.getOrCreateContentCache(E));
-    return;
-  }
-  
-  // Register the ContextCache object with the deserializer.
-  /* FIXME:
-  ContentCache *Entry
-  SMgr.MemBufferInfos.push_back(ContentCache());
-   = const_cast<ContentCache&>(SMgr.MemBufferInfos.back());
-  D.RegisterPtr(&Entry);
-  
-  // Create the buffer.
-  unsigned Size = D.ReadInt();
-  Entry.Buffer = MemoryBuffer::getNewUninitMemBuffer(Size);
-  
-  // Read the contents of the buffer.
-  char* p = const_cast<char*>(Entry.Buffer->getBufferStart());
-  for (unsigned i = 0; i < Size ; ++i)
-    p[i] = D.ReadInt();    
-   */
-}
-
-void SourceManager::Emit(llvm::Serializer& S) const {
-  S.EnterBlock();
-  S.EmitPtr(this);
-  S.EmitInt(MainFileID.getOpaqueValue());
-  
-  // Emit: FileInfos.  Just emit the file name.
-  S.EnterBlock();    
-
-  // FIXME: Emit FileInfos.
-  //std::for_each(FileInfos.begin(), FileInfos.end(),
-  //              S.MakeEmitter<ContentCache>());
-  
-  S.ExitBlock();
-  
-  // Emit: MemBufferInfos
-  S.EnterBlock();
-
-  /* FIXME: EMIT.
-  std::for_each(MemBufferInfos.begin(), MemBufferInfos.end(),
-                S.MakeEmitter<ContentCache>());
-   */
-  
-  S.ExitBlock();
-  
-  // FIXME: Emit SLocEntryTable.
-  
-  S.ExitBlock();
-}
-
-SourceManager*
-SourceManager::CreateAndRegister(llvm::Deserializer &D, FileManager &FMgr) {
-  SourceManager *M = new SourceManager();
-  D.RegisterPtr(M);
-  
-  // Read: the FileID of the main source file of the translation unit.
-  M->MainFileID = FileID::get(D.ReadInt());
-  
-  std::vector<char> Buf;
-    
-  /*{ // FIXME Read: FileInfos.
-    llvm::Deserializer::Location BLoc = D.getCurrentBlockLocation();
-    while (!D.FinishedBlock(BLoc))
-    ContentCache::ReadToSourceManager(D,*M,&FMgr,Buf);
-  }*/
-    
-  /*{ // FIXME Read: MemBufferInfos.
-    llvm::Deserializer::Location BLoc = D.getCurrentBlockLocation();
-    while (!D.FinishedBlock(BLoc))
-    ContentCache::ReadToSourceManager(D,*M,NULL,Buf);
-    }*/
-  
-  // FIXME: Read SLocEntryTable.
-  
-  return M;
-}